An open-source, self-hosted system for apps built with web technologies.
Release System 0.1.88
zohayrslileh6ba85920a46a
diff --git a/bun.lock b/bun.lockindex de5e9bf..4a62a66 100644--- a/bun.lock+++ b/bun.lock@@ -8,8 +8,8 @@"@fontsource/roboto": "^5.3.0","@hono/node-server": "^2.1.1","@jitl/quickjs-ng-wasmfile-release-sync": "^0.32.0",- "@phreshos/core": "^0.1.58",- "@phreshos/react-ui": "^0.1.32",+ "@phreshos/core": "^0.1.59",+ "@phreshos/react-ui": "^0.1.33","@the-link/core": "^0.3.1","@the-link/http": "^0.1.1","@the-link/ipc": "^0.2.2",@@ -199,9 +199,9 @@"@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-rDS5/31E9HfPl/CIzGrn0DOlvBbXFseQ5URJ9sYMfstbKLD/c6Gm9vmRzRGDdAXyOIL4zmO37lc9RIwYqVruZw=="],- "@phreshos/core": ["@phreshos/[email protected]", "", { "dependencies": { "zod": "^4.6.5" } }, "sha512-qj7tKMloJpYI117ICNRKvaywan15KOaasCH+uLSU9nDf8RXjZJ3lGE+QlGJWNBpBLfzRft3GZt3U1zK83uRbrA=="],+ "@phreshos/core": ["@phreshos/[email protected]", "", { "dependencies": { "zod": "^4.6.5" } }, "sha512-/9qMUkCIw1qYKc/lDhzkcxpdvkCOmI00jdWoKkoBMGzB13PkN5My1zi0J8Veu2JX0j+h4zmJa5C+0JpQ4PDwmA=="],- "@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "@base-ui/react": "^1.7.0", "@internationalized/date": "^3.12.3", "@phreshos/core": "^0.1.56", "colorjs.io": "^0.7.1", "motion": "^13.2.0", "react-aria": "^3.51.0", "react-aria-components": "^1.20.0" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-QmmpNTrM4lRaQPcAhmIwfMnf+g0lG83Z/jW3CG2HSEN5TQmlN86gzNFKED52xLY/XRfQ7VU+Ptj6MHgL0hX8zg=="],+ "@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "@base-ui/react": "^1.7.0", "@internationalized/date": "^3.12.3", "@phreshos/core": "^0.1.59", "colorjs.io": "^0.7.1", "motion": "^13.2.0", "react-aria": "^3.51.0", "react-aria-components": "^1.20.0" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-M04X8kPcXmi+JQ/Ogo5A7UJbQDVmeZoICtq5FDgZ7JXuEidOc5klQBX3Bm4UTWpaTvLEf3dwtbV0kX+8De05lQ=="],"@react-types/shared": ["@react-types/[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-AzsuD9OfxTOZMMvTRhlN3oHBwOmFN7tDh27LzqmHt4+uOgPhJT7ZM7/kVs/8/o0WxayMUIk3hBmCFRHv1FUoag=="],@@ -527,8 +527,6 @@"zod": ["[email protected]", "", {}, "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q=="],- "@phreshos/react-ui/@phreshos/core": ["@phreshos/[email protected]", "", { "dependencies": { "zod": "^4.6.5" } }, "sha512-X5JphvijFBfhzo7JplkrIra/61dXVQFQ2Y1tzpGFHycvHA3L7g6D9FriiBZcmDFk5RzohivYzJGpXq1tPeXDQQ=="],-"@tailwindcss/node/lightningcss": ["[email protected]", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.32.0", "lightningcss-darwin-arm64": "1.32.0", "lightningcss-darwin-x64": "1.32.0", "lightningcss-freebsd-x64": "1.32.0", "lightningcss-linux-arm-gnueabihf": "1.32.0", "lightningcss-linux-arm64-gnu": "1.32.0", "lightningcss-linux-arm64-musl": "1.32.0", "lightningcss-linux-x64-gnu": "1.32.0", "lightningcss-linux-x64-musl": "1.32.0", "lightningcss-win32-arm64-msvc": "1.32.0", "lightningcss-win32-x64-msvc": "1.32.0" } }, "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ=="],"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/[email protected]", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.3", "tslib": "^2.4.0" }, "bundled": true }, "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg=="],diff --git a/package.json b/package.jsonindex 47f926c..95d3c2d 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "phreshos","displayName": "PhreshOS",- "version": "0.1.86",+ "version": "0.1.88","description": "The PhreshOS server, desktop, and authoritative system runtime.","type": "module","private": true,@@ -37,8 +37,8 @@"@fontsource/roboto": "^5.3.0","@hono/node-server": "^2.1.1","@jitl/quickjs-ng-wasmfile-release-sync": "^0.32.0",- "@phreshos/core": "^0.1.58",- "@phreshos/react-ui": "^0.1.32",+ "@phreshos/core": "^0.1.59",+ "@phreshos/react-ui": "^0.1.33","@the-link/core": "^0.3.1","@the-link/http": "^0.1.1","@the-link/ipc": "^0.2.2",diff --git a/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts b/source/client/core/link-manager/auth-manager/process-manager/process-manager.tsindex f0dc0b9..9fd45bc 100644--- a/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts+++ b/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts@@ -355,20 +355,6 @@ export default class ProcessManager extends TheLink {return this.followed(payload)}- @Subscribe("/change-surface")- @Publish("/processes", "inbound")- protected async changeSurfaceHandle(payload: { identity: string, window: WindowSnapshot } | null) {-- return this.followed(payload)- }-- @Subscribe("/change-transaction")- @Publish("/processes", "inbound")- protected async changeTransactionHandle(payload: { identity: string, window: WindowSnapshot } | null) {-- return this.followed(payload)- }-@Subscribe("/maximize")@Publish("/processes", "inbound")protected async maximizeHandle(payload: { identity: string, window: WindowSnapshot } | null) {diff --git a/source/client/core/link-manager/auth-manager/process-manager/process.ts b/source/client/core/link-manager/auth-manager/process-manager/process.tsindex bd685a1..e7cdb04 100644--- a/source/client/core/link-manager/auth-manager/process-manager/process.ts+++ b/source/client/core/link-manager/auth-manager/process-manager/process.ts@@ -5,9 +5,8 @@ import Window from "./window"/*** A running instance, as this side holds it: rebuilt from what the core- * transmitted. Its Client Endpoint retains its Window counterpart independently- * of the current execution context. Every act is a request; the truth answers- * with an echo.+ * transmitted. Its Client Endpoint handle survives between runs, while the+ * Window values belong only to the current execution context.*/export default class Process {@@ -31,7 +30,7 @@ export default class Process {public client: ClientState | null- /** Permanent Client Endpoint state retained between execution contexts. */+ /** Permanent Client Endpoint handle retained between execution contexts. */public readonly clientEndpoint: Readonly<{ window: Window }> | null// Retained lineage from creation. It remains sufficient to reconstruct@@ -95,7 +94,9 @@ export default class Process {if (!payload.client || !this.clientEndpoint) return- if (payload.clientEndpoint) this.clientEndpoint.window.follow(payload.clientEndpoint.window)+ if (!payload.clientEndpoint?.window) throw new Error("A running Client Endpoint requires Window state")++ this.clientEndpoint.window.start(payload.clientEndpoint.window)// A Process creation snapshot already contains every endpoint that is// live at birth. Its following lifecycle announcement describes that@@ -109,6 +110,8 @@ export default class Process {public clientStopped() {this.client = null++ this.clientEndpoint?.window.stop()}}diff --git a/source/client/core/link-manager/auth-manager/process-manager/window.ts b/source/client/core/link-manager/auth-manager/process-manager/window.tsindex 687c3fd..b34200e 100644--- a/source/client/core/link-manager/auth-manager/process-manager/window.ts+++ b/source/client/core/link-manager/auth-manager/process-manager/window.ts@@ -1,152 +1,48 @@-import { type WindowSnapshot, type Position, type Size } from "@server/core/link-manager/auth-manager/process-manager/window"-import { type WindowSurface, type WindowGeometry, type WindowLayer, type WindowState, type WindowTransaction } from "@phreshos/core"+import type { WindowSnapshot, Position, Size } from "@server/core/link-manager/auth-manager/process-manager/window"+import type { WindowGeometry, WindowLayer, WindowState } from "@phreshos/core"import ProcessManager from "./process-manager"-/**- * How a process is shown, as this side holds it. The values are the core's- * own — pixels or linear expressions of relative and pixel terms — and every- * operation is a request: the truth changes on the server and the echo lands- * back here, so a window never moves because a session wished it.- *- * Its own instance, rebuilt from what crossed. It shares no code with- * the core's window; they are alike because they are the same idea.- */-export default class Window implements Omit<WindowState, "front"> {-- public readonly processManager: ProcessManager-- public readonly process: string-- public position: Position-- public size: Size-- public depth: number-- public minimized: boolean-- public maximized: boolean-- // What is shown on it, born from its program when the window was- // made. Not looked up again: how a thing is shown is not a fact- // about whether its program is installed. Changeable, because the- // window owns it.- public title: string-- public header: boolean-- public surface: WindowSurface-- public transaction: WindowTransaction-- // The authoritative Desktop layer.- public layer: WindowLayer-- public constructor(processManager: ProcessManager, process: string, payload: WindowSnapshot) {-- this.title = payload.title-- this.header = payload.header-- this.surface = payload.surface-- this.transaction = payload.transaction-- this.layer = payload.layer-- this.processManager = processManager-- this.process = process-- this.position = payload.position-- this.size = payload.size-- this.depth = payload.depth-- this.minimized = payload.minimized-- this.maximized = payload.maximized-- }-- // What the echo carries, applied whole: one shape for any change.- public follow(payload: WindowSnapshot) {-- this.title = payload.title-- this.header = payload.header-- this.surface = payload.surface-- this.transaction = payload.transaction-- this.layer = payload.layer-- this.position = payload.position-- this.size = payload.size-- this.depth = payload.depth-- this.minimized = payload.minimized-- this.maximized = payload.maximized-- }-- public async move(position: Position) {-- await this.processManager.$outbound.publish("/move", this.process, position)- }-- public async resize(size: Size) {-- await this.processManager.$outbound.publish("/resize", this.process, size)- }-- public async setGeometry(geometry: WindowGeometry) {-- await this.processManager.$outbound.publish("/set-geometry", this.process, geometry)- }-- public async setTitle(title: string) {-- await this.processManager.$outbound.publish("/set-title", this.process, title)- }-- public async setHeader(header: boolean) {-- await this.processManager.$outbound.publish("/set-header", this.process, header)- }-- public async setSurface(surface: WindowSurface) {-- await this.processManager.$outbound.publish("/set-surface", this.process, surface)- }-- public async setTransaction(transaction: WindowTransaction) {-- await this.processManager.$outbound.publish("/set-transaction", this.process, transaction)- }-- // To the front of its own layer, and nothing else. A hidden window- // raised stays hidden and appears at its new place in the order when- // it is shown.- public async raise() {-- await this.processManager.$outbound.publish("/raise", this.process)- }-- public async maximize(maximized: boolean) {-- await this.processManager.$outbound.publish("/maximize", this.process, maximized)- }-- public async minimize(minimized: boolean) {-- await this.processManager.$outbound.publish("/minimize", this.process, minimized)- }+/** Desktop projection of the authoritative Window for the current Client run. */+export default class Window {+ private state: WindowSnapshot | null = null++ public constructor(+ public readonly processManager: ProcessManager,+ public readonly process: string,+ payload: WindowSnapshot | null+ ) {+ if (payload) this.start(payload)+ }++ public start(payload: WindowSnapshot) { this.state = { ...payload } }+ public stop() { this.state = null }+ public follow(payload: WindowSnapshot) { this.start(payload) }++ public get live() { return this.state !== null }+ public get position() { return this.current.position }+ public get size() { return this.current.size }+ public get depth() { return this.current.depth }+ public get minimized() { return this.current.minimized }+ public get maximized() { return this.current.maximized }+ public get title() { return this.current.title }+ public get header() { return this.current.header }+ public get layer(): WindowLayer { return this.current.layer }++ private get current() {+ if (!this.state) throw new Error("This Client Endpoint is not running")+ return this.state+ }++ public stateSnapshot(): Omit<WindowState, "front"> & { depth: number } { return { ...this.current } }++ public async move(position: Position) { await this.processManager.$outbound.publish("/move", this.process, position) }+ public async resize(size: Size) { await this.processManager.$outbound.publish("/resize", this.process, size) }+ public async setGeometry(geometry: WindowGeometry) { await this.processManager.$outbound.publish("/set-geometry", this.process, geometry) }+ public async setTitle(title: string) { await this.processManager.$outbound.publish("/set-title", this.process, title) }+ public async setHeader(header: boolean) { await this.processManager.$outbound.publish("/set-header", this.process, header) }+ public async raise() { await this.processManager.$outbound.publish("/raise", this.process) }+ public async maximize(maximized: boolean) { await this.processManager.$outbound.publish("/maximize", this.process, maximized) }+ public async minimize(minimized: boolean) { await this.processManager.$outbound.publish("/minimize", this.process, minimized) }}export type { Position, Size }diff --git a/source/client/view/appearance/motion.ts b/source/client/view/appearance/motion.tsindex ce4188c..e1bec94 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 WindowTransaction } from "@phreshos/core"+import { type AppearanceTransaction, type Easing, type WindowPresentationTransaction } from "@phreshos/core"import { type Transition } from "motion/react"const easings: Record<Exclude<Easing, readonly number[]>, Transition["ease"]> = {@@ -19,12 +19,10 @@ export function motionTransition(transaction: AppearanceTransaction, reduced = f}}-/** Resolves a Window transaction against the current Appearance transaction. */-export function resolveWindowTransaction(transaction: WindowTransaction, appearance: AppearanceTransaction): AppearanceTransaction | null {+/** Resolves an optional presentation timing against the current Appearance. */+export function resolveWindowTransaction(transaction: WindowPresentationTransaction | undefined, appearance: AppearanceTransaction): AppearanceTransaction {- if (transaction === false) return null-- if (transaction === true) return appearance+ if (transaction === undefined) return appearanceif (typeof transaction === "number") return { duration: transaction, easing: appearance.easing }diff --git a/source/client/view/components/desktop-host/client-process-boundary.ts b/source/client/view/components/desktop-host/client-process-boundary.tsindex 50a2b07..15561ae 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 } 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 DesktopViewportSnapshot, type ServiceAddress, type ShellOptions } from "@phreshos/core"-import { type WindowPresentationHost } from "./window-presentation"+import { isServiceAddress, parseProgramInstallOptions, type DesktopViewportSnapshot, type ServiceAddress, type ShellOptions, type WindowMovePoint } from "@phreshos/core"+import { type PresentationMoveCoordinates, type PresentationMovePoint, type WindowPresentationHost } from "./window-presentation"import messagepack from "@the-link/messagepack"import { sdkProcess, type SdkProcessSource } from "./sdk-records"import SystemAccess from "./system-access"@@ -25,7 +25,7 @@ export default class ClientProcessBoundary extends TheLink {private readonly presentation: WindowPresentationHost- private readonly presentationSubscriptions = new Map<string, () => void>()+ private readonly moveCoordinates: PresentationMoveCoordinatesprivate readonly systemAccess: SystemAccess@@ -83,6 +83,8 @@ export default class ClientProcessBoundary extends TheLink {this.presentation = presentation+ this.moveCoordinates = new FrameMoveCoordinates(element)+this.systemAccess = new SystemAccess(authManager, pane)this.$outbound.forwardTo((route, ...values) => {@@ -137,6 +139,8 @@ export default class ClientProcessBoundary extends TheLink {public async release() {+ this.presentation.cancelMoveGestures(this.pane)+const owner = this.leasedthis.owner = null@@ -288,7 +292,14 @@ export default class ClientProcessBoundary extends TheLink {private runHost(word: unknown, args: unknown[]) {- const operation = () => host(this.authManager, this.pane, this.viewport, () => this.owner, this.presentation)(word, ...args)+ const operation = () => host(+ this.authManager,+ this.pane,+ this.viewport,+ () => this.owner,+ this.moveCoordinates,+ this.presentation+ )(word, ...args)return hostRegistrationOperation(word)? this.orderHostRegistration(operation)@@ -493,12 +504,6 @@ export default class ClientProcessBoundary extends TheLink {this.subscriptions.set(subscription, description)- if (presentationSubscription(description)) {- this.presentationSubscriptions.set(subscription, this.presentation.observe(this.pane, event, (word, value) => {- this.deliver("presentation", word, value).catch(() => undefined)- }))- }-if (!desktopOwnedSubscription(description)) this.addTraffic(kind, route, event)const owner = this.owner@@ -920,10 +925,6 @@ export default class ClientProcessBoundary extends TheLink {this.subscriptions.delete(subscription)- this.presentationSubscriptions.get(subscription)?.()-- this.presentationSubscriptions.delete(subscription)-if (this.desktopPreferencesSubscriptions.delete(subscription) && this.desktopPreferencesSubscriptions.size === 0) {this.stopDesktopPreferences?.()@@ -1033,10 +1034,6 @@ export default class ClientProcessBoundary extends TheLink {this.appearanceSubscriptions.clear()- for (const stop of this.presentationSubscriptions.values()) stop()-- this.presentationSubscriptions.clear()-this.stopDesktopPreferences?.()this.stopDesktopPreferences = null@@ -1060,6 +1057,23 @@ export default class ClientProcessBoundary extends TheLink {}+export function frameMovePoint(frame: HTMLIFrameElement, point: PresentationMovePoint): PresentationMovePoint {+ const bounds = frame.getBoundingClientRect()+ // Frame-local CSS pixels must enter the same physical viewport coordinate+ // space as pointer events captured directly by the Desktop.+ const scaleX = frame.clientWidth === 0 ? 1 : bounds.width / frame.clientWidth+ const scaleY = frame.clientHeight === 0 ? 1 : bounds.height / frame.clientHeight+ return { x: bounds.left + point.x * scaleX, y: bounds.top + point.y * scaleY }+}++export class FrameMoveCoordinates implements PresentationMoveCoordinates {+ public constructor(private readonly frame: HTMLIFrameElement) {}++ public point(point: WindowMovePoint) {+ return frameMovePoint(this.frame, point)+ }+}+function storagePath(value: unknown) {if (!Array.isArray(value) || value.some(part => typeof part !== "string")) throw new Error("A Storage path is a list of names")@@ -1182,14 +1196,9 @@ function appearanceSubscription(subscription: EndpointSubscription) {return subscription.kind === "publish" && subscription.route === "host-appearance" && (subscription.event === null || subscription.event === "change")}-function presentationSubscription(subscription: EndpointSubscription) {-- return subscription.kind === "publish" && subscription.route === "presentation"-}-function desktopOwnedSubscription(subscription: EndpointSubscription) {- return desktopPreferencesSubscription(subscription) || appearanceSubscription(subscription) || presentationSubscription(subscription)+ return desktopPreferencesSubscription(subscription) || appearanceSubscription(subscription)}function directSubscription(subscription: EndpointSubscription) {diff --git a/source/client/view/components/desktop-host/host.ts b/source/client/view/components/desktop-host/host.tsindex 71b4a3e..dfa6a27 100644--- a/source/client/view/components/desktop-host/host.ts+++ b/source/client/view/components/desktop-host/host.ts@@ -23,12 +23,13 @@ import {import {presentationSurface,presentationGeometry,+ presentationMoveGestureStart,presentationPosition,presentationSize,presentationTransaction,+ type PresentationMoveCoordinates,type WindowPresentationHost} from "./window-presentation"-import { isWindowPresentationProperty, requireWindowPresentationTransactions } from "@shared/window-layers"import SystemAccess from "./system-access"import { allowsSynchronizedPermission } from "@shared/permission-state"@@ -39,7 +40,7 @@ export class TransferredAnswer {}/** Adapts the complete System contract and contextual Desktop capabilities to one Client frame. */-export default function host(authManager: AuthManager, pane: string, viewport: () => DesktopViewportSnapshot, frameOwner: () => string | null, presentation: WindowPresentationHost) {+export default function host(authManager: AuthManager, pane: string, viewport: () => DesktopViewportSnapshot, frameOwner: () => string | null, moveCoordinates: PresentationMoveCoordinates, presentation: WindowPresentationHost) {const { processManager, programManager } = authManager@@ -142,6 +143,8 @@ export default function host(authManager: AuthManager, pane: string, viewport: (if (!found.clientEndpoint) throw new Error("This Program declared no Client Endpoint")+ if (!found.client) throw new Error("This Client Endpoint is not running")+return found.clientEndpoint.window}@@ -826,10 +829,6 @@ export default function host(authManager: AuthManager, pane: string, viewport: (header: shown.header,- surface: shown.surface,-- transaction: shown.transaction,-position: shown.position,size: shown.size,@@ -865,94 +864,67 @@ export default function host(authManager: AuthManager, pane: string, viewport: (return [pane]}- if (word === "windowPresentationRead") {+ if (word === "windowPresentationLayer") {const target = presentationProcess(args[0])- if (!isWindowPresentationProperty(args[1])) throw new Error("The Window presentation property does not exist")- return [presentation.read(target.identity, args[1])]+ return [presentation.layer(target.identity)]}- const selectedTransaction = (target: ClientProcess) => {- const selected = presentationTransaction(args[2], args[3])- if (selected) requireWindowPresentationTransactions(clientOf(target).window.layer)- return selected- }-- if (word === "windowPresentationMove") {-+ if (word === "windowPresentationMoveGestureBegin") {const target = presentationProcess(args[0])- await presentation.move(target.identity, presentationPosition(args[1]), selectedTransaction(target))-+ const gesture = gestureIdentity(args[1])+ const start = presentationMoveGestureStart(args[2])+ await presentation.beginMoveGesture(+ target.identity,+ gesture,+ moveCoordinates.point(start.origin),+ moveCoordinates.point(start.point)+ )return []}- if (word === "windowPresentationResize") {-+ if (word === "windowPresentationMoveGestureWait") {const target = presentationProcess(args[0])- await presentation.resize(target.identity, presentationSize(args[1]), selectedTransaction(target))-+ const gesture = gestureIdentity(args[1])+ await presentation.waitMoveGesture(target.identity, gesture)return []}- if (word === "windowPresentationGeometry") {-+ if (word === "windowPresentationMoveGestureCancel") {const target = presentationProcess(args[0])- await presentation.setGeometry(target.identity, presentationGeometry(args[1]), selectedTransaction(target))-+ const gesture = gestureIdentity(args[1])+ presentation.cancelMoveGesture(target.identity, gesture)return []}- if (word === "windowPresentationTitle") {- const target = presentationProcess(args[0])- const title = String(args[1] ?? "").trim()- if (!title) throw new Error("A Window title must not be empty")- presentation.setTitle(target.identity, title)- return []- }+ const selectedTransaction = () => presentationTransaction(args[2])- if (word === "windowPresentationHeader") {- const target = presentationProcess(args[0])- if (typeof args[1] !== "boolean") throw new Error("Window presentation header state must be true or false")- presentation.setHeader(target.identity, args[1])- return []- }+ if (word === "windowPresentationMove") {- if (word === "windowPresentationSurface") {const target = presentationProcess(args[0])- await presentation.setSurface(target.identity, presentationSurface(args[1]), selectedTransaction(target))- return []- }+ await presentation.move(target.identity, presentationPosition(args[1]), selectedTransaction())- if (word === "windowPresentationMaximize") {- const target = presentationProcess(args[0])- if (typeof args[1] !== "boolean") throw new Error("Window presentation maximize takes a boolean state")- await presentation.maximize(target.identity, args[1], selectedTransaction(target))return []}- if (word === "windowPresentationMinimize") {+ if (word === "windowPresentationResize") {const target = presentationProcess(args[0])-- if (typeof args[1] !== "boolean") throw new Error("Window presentation minimize takes a boolean state")-- await presentation.minimize(target.identity, args[1], selectedTransaction(target))+ await presentation.resize(target.identity, presentationSize(args[1]), selectedTransaction())return []}- if (word === "windowPresentationFollow") {+ if (word === "windowPresentationGeometry") {const target = presentationProcess(args[0])- await presentation.follow(target.identity, selectedTransaction(target))+ await presentation.setGeometry(target.identity, presentationGeometry(args[1]), selectedTransaction())return []}- if (word === "windowPresentationUnfollow") {-+ if (word === "windowPresentationSurface") {const target = presentationProcess(args[0])- await presentation.unfollow(target.identity)-+ await presentation.setSurface(target.identity, presentationSurface(args[1]), selectedTransaction())return []}@@ -980,20 +952,6 @@ export default function host(authManager: AuthManager, pane: string, viewport: (return [pane]}- if (word === "setSurface") {-- await windowOf(await permittedProcess(args[0])).setSurface(args[1] as never)-- return [pane]- }-- if (word === "setTransaction") {-- await windowOf(await permittedProcess(args[0])).setTransaction(args[1] as never)-- return [pane]- }-if (word === "raise") {await windowOf(await permittedProcess(args[0])).raise()@@ -1371,6 +1329,11 @@ export default function host(authManager: AuthManager, pane: string, viewport: (}}+function gestureIdentity(value: unknown) {+ if (typeof value !== "string" || value.length === 0) throw new Error("A Window move gesture identity is required")+ return value+}+function isTrafficKind(value: unknown): value is TrafficKind {return value === "publish" || value === "ask" || value === "answer"diff --git a/source/client/view/components/desktop-host/window-presentation.ts b/source/client/view/components/desktop-host/window-presentation.tsindex 9967ad1..3ba1153 100644--- a/source/client/view/components/desktop-host/window-presentation.ts+++ b/source/client/view/components/desktop-host/window-presentation.ts@@ -1,52 +1,70 @@import {isRelativeValue,- parseWindowSurface,- parseWindowTransaction,+ parseWindowPresentationSurface,+ parseWindowPresentationTransaction,type Position,type Size,- type WindowSurface,type WindowGeometry,- type WindowState,- type WindowTransaction+ type WindowLayer,+ type WindowMoveGestureStart,+ type WindowMovePoint,+ type WindowPresentationSurface,+ type WindowPresentationTransaction} from "@phreshos/core"-import type { WindowPresentationProperty } from "@shared/window-layers"export type PresentationAnimation = Readonly<{revision: number- transaction: WindowTransaction-}>--/** Values this Desktop relies on for one Client Window, not measured rendered output. */-export type WindowPresentationState = WindowState & Readonly<{- depth: number- surfaceAnimation: PresentationAnimation | null- geometryAnimation: PresentationAnimation | null- minimizeAnimation: PresentationAnimation | null+ transaction?: WindowPresentationTransaction}>export type PresentationTransactionRequest = Readonly<{- transaction: WindowTransaction+ transaction?: WindowPresentationTransactionwait: boolean}>-/** The only interface through which an iframe changes or observes its Desktop presentation. */+export type PresentationMovePoint = Readonly<{ x: number, y: number }>++export interface PresentationMoveCoordinates {+ point(point: WindowMovePoint): PresentationMovePoint+}++export interface PresentationMoveGestureController {+ begin(origin: PresentationMovePoint, point: PresentationMovePoint): PresentationMoveGesture+ cancel(): void+}++export interface PresentationMoveGesture {+ ready: Promise<void>+ finished: Promise<void>+ cancel(): void+}++/** Local commands available to the current Client representation. */export interface WindowPresentationHost {- /** Begins a new iframe presentation from the authoritative Window state. */begin(identity: string): void- read(identity: string, property: WindowPresentationProperty): unknown+ layer(identity: string): WindowLayer+ beginMoveGesture(identity: string, gesture: string, origin: PresentationMovePoint, point: PresentationMovePoint): Promise<void>+ waitMoveGesture(identity: string, gesture: string): Promise<void>+ cancelMoveGesture(identity: string, gesture: string): void+ cancelMoveGestures(identity: string): voidmove(identity: string, position: Position, transaction?: PresentationTransactionRequest): Promise<void>resize(identity: string, size: Size, transaction?: PresentationTransactionRequest): Promise<void>setGeometry(identity: string, geometry: WindowGeometry, transaction?: PresentationTransactionRequest): Promise<void>- maximize(identity: string, maximized: boolean, transaction?: PresentationTransactionRequest): Promise<void>- minimize(identity: string, minimized: boolean, transaction?: PresentationTransactionRequest): Promise<void>- follow(identity: string, transaction?: PresentationTransactionRequest): Promise<void>- unfollow(identity: string): Promise<void>- setTitle(identity: string, title: string): void- setHeader(identity: string, header: boolean): void- setSurface(identity: string, surface: WindowSurface, transaction?: PresentationTransactionRequest): Promise<void>+ setSurface(identity: string, surface: WindowPresentationSurface, transaction?: PresentationTransactionRequest): Promise<void>raise(identity: string): void- observe(identity: string, event: string | null, listener: (event: string, value: unknown) => void): () => void- complete(identity: string, kind: "geometry" | "minimize" | "surface", revision: number): void+ complete(identity: string, kind: "geometry" | "surface", revision: number): void+}++export function presentationMovePoint(value: unknown): WindowMovePoint {+ 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 {+ const record = plain(value, "Window move gesture start")+ return Object.freeze({ origin: presentationMovePoint(record.origin), point: presentationMovePoint(record.point) })}export function presentationPosition(value: unknown): Position {@@ -73,13 +91,17 @@ export function presentationGeometry(value: unknown): WindowGeometry {}export function presentationSurface(value: unknown) {- return parseWindowSurface(value)+ return parseWindowPresentationSurface(value)}-export function presentationTransaction(value: unknown, wait: unknown): PresentationTransactionRequest | undefined {- if (value === undefined) return undefined- if (wait !== undefined && typeof wait !== "boolean") throw new Error("A Window presentation wait value must be true or false")- return Object.freeze({ transaction: parseWindowTransaction(value), wait: wait === true })+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")+ return Object.freeze({+ ...selected.transaction === undefined ? {} : { transaction: parseWindowPresentationTransaction(selected.transaction) },+ wait: selected.wait+ })}function valueTerm(value: unknown, name: string) {diff --git a/source/client/view/components/window-manager/layer-policy.ts b/source/client/view/components/window-manager/layer-policy.tsdeleted file mode 100644index 7ad802d..0000000--- a/source/client/view/components/window-manager/layer-policy.ts+++ /dev/null@@ -1,18 +0,0 @@-import type { WindowPresentationState } from "../desktop-host/window-presentation"-import { requireWindowPresentationMutation, supportsWindowPresentationApplication, type WindowPresentationProperty } from "@shared/window-layers"--export const requirePresentationMutation = requireWindowPresentationMutation--/** A target contributes only properties allowed by the receiving role. */-export function followedState(current: WindowPresentationState, target: WindowPresentationState, previous?: WindowPresentationState) {- const changes: Partial<WindowPresentationState> = {}- for (const property of followedProperties) {- if (!supportsWindowPresentationApplication(current.layer, property)) continue- if (!previous || JSON.stringify(previous[property]) !== JSON.stringify(target[property])) {- Object.assign(changes, { [property]: target[property] })- }- }- return changes-}--const followedProperties = ["title", "header", "surface", "position", "size", "minimized", "maximized"] as const satisfies readonly WindowPresentationProperty[]diff --git a/source/client/view/components/window-manager/window-manager.ts b/source/client/view/components/window-manager/window-manager.tsindex 8c4050d..970e8ac 100644--- a/source/client/view/components/window-manager/window-manager.ts+++ b/source/client/view/components/window-manager/window-manager.ts@@ -241,7 +241,7 @@ export default function useWindows(authManager: AuthManager) {if (!window || window.layer !== "window") return- if (presentation.state(process.identity).minimized) minimize(process, false)+ if (presentation.projection(process.identity).minimized) minimize(process, false)raise(process)diff --git a/source/client/view/components/window-manager/window-presentations.ts b/source/client/view/components/window-manager/window-presentations.tsindex e8d6c36..efb6f8e 100644--- a/source/client/view/components/window-manager/window-presentations.ts+++ b/source/client/view/components/window-manager/window-presentations.ts@@ -1,333 +1,221 @@-import { followedState, requirePresentationMutation } from "./layer-policy"import ClientState from "@client/core/link-manager/auth-manager/process-manager/client-state"-import {- type WindowSurface,- type WindowGeometry,- type WindowState+import type {+ Position,+ Size,+ WindowGeometry,+ WindowLayer,+ WindowPresentationSurface} from "@phreshos/core"-import { type PresentationTransactionRequest, type WindowPresentationHost, type WindowPresentationState } from "../desktop-host/window-presentation"-import { type WindowRegion } from "./window-geometry"-import { isFixedWindowPresentationLayer, requireWindowPresentationRead, supportsWindowPresentationApplication } from "@shared/window-layers"+import type {+ PresentationAnimation,+ PresentationMoveGestureController,+ PresentationMovePoint,+ PresentationTransactionRequest,+ WindowPresentationHost+} from "../desktop-host/window-presentation"+import type { WindowRegion } from "./window-geometry"+import { requireRawWindowPresentation, requireWindowMoveGesture } from "@shared/window-layers"export interface WindowPresentationEntry {identity: stringclient: ClientState}-/** Owns the representations of one desktop without entering server transport. */-export default class WindowPresentations implements WindowPresentationHost {+/** Values this Desktop currently uses to render one Client context. */+export interface PresentedWindow {+ title: string+ header: boolean+ surface: WindowPresentationSurface+ position: Position+ size: Size+ minimized: boolean+ maximized: boolean+ layer: WindowLayer+ depth: number+ surfaceAnimation: PresentationAnimation | null+ geometryAnimation: PresentationAnimation | null+ minimizeAnimation: PresentationAnimation | null+}- public windows: ReadonlyMap<string, WindowPresentationState>+/** Owns only the local representations of one Desktop. */+export default class WindowPresentations implements WindowPresentationHost {+ public windows: ReadonlyMap<string, PresentedWindow>private readonly live = new Map<string, string>()- private readonly authoritative = new Map<string, WindowPresentationState>()private readonly waiting = new Map<string, WaitingAnimation>()private readonly representations = new Map<string, PresentationGeometryRepresentation>()- private readonly following = new Map<string, FollowingWindow>()- private readonly observers = new Map<string, Set<(event: string, value: unknown) => void>>()- private readonly emitted = new Map<string, WindowState>()+ private readonly moveGestureControllers = new Map<string, PresentationMoveGestureController>()+ private readonly moveGestures = new Map<string, ActiveMoveGesture>()private revision = 0- private changed: (windows: ReadonlyMap<string, WindowPresentationState>) => void = () => undefined+ private changed: (windows: ReadonlyMap<string, PresentedWindow>) => void = () => undefinedpublic constructor(initial: ReadonlyMap<string, WindowPresentationEntry>, private readonly client: (process: string) => ClientState | null) {-- this.windows = new Map([...initial.values()].map(({ identity, client }) => [identity, initialPresentationState(client)]))- for (const [identity, state] of this.windows) this.emitted.set(identity, windowState(state, frontmost(this.windows, state.layer) === identity))+ this.windows = new Map()this.reconcile(initial)}- public listen(changed: (windows: ReadonlyMap<string, WindowPresentationState>) => void) {-- this.changed = changed- }+ public listen(changed: (windows: ReadonlyMap<string, PresentedWindow>) => void) { this.changed = changed }- /** Following projects the authoritative properties owned by the receiving layer. */public reconcile(current: ReadonlyMap<string, WindowPresentationEntry>) {- for (const [process, identity] of this.live) {+ const previousLive = new Map(this.live)+ this.live.clear()+ const next = new Map(this.windows)++ for (const [process, identity] of previousLive) {if (current.get(process)?.identity === identity) continue- this.cancel(identity, "geometry", "The Window presentation was removed")- this.cancel(identity, "minimize", "The Window presentation was removed")- this.cancel(identity, "surface", "The Window presentation was removed")- this.following.delete(identity)- this.authoritative.delete(identity)+ next.delete(identity)+ this.release(identity, "The Window presentation was removed")}- this.live.clear()- const next = new Map(this.windows)for (const [process, { identity, client }] of current) {this.live.set(process, identity)- const snapshot = authoritativeState(client)- if (!this.authoritative.has(identity) && client.window.layer === "window") {- this.following.set(identity, { snapshot })- }- if (!next.has(identity)) next.set(identity, initialPresentationState(client))- else next.set(identity, { ...next.get(identity)!, transaction: snapshot.transaction })- this.authoritative.set(identity, snapshot)+ const existing = next.get(identity)+ if (!existing) next.set(identity, initialPresentationState(client))+ else if (existing.layer === "window") next.set(identity, followStandardWindow(existing, client, ++this.revision))}- const alive = new Set(this.live.values())- for (const [identity, relation] of this.following) {- if (!alive.has(identity)) {- this.following.delete(identity)- continue- }- const state = next.get(identity)!- const target = this.authoritative.get(identity)!- const previous = relation.snapshot- const changes = { transaction: target.transaction, depth: target.depth, ...followedState(state, target, previous) }- const maximized = changes.maximized ?? state.maximized- const minimized = changes.minimized ?? state.minimized- const geometryChanged = ("position" in changes && JSON.stringify(state.position) !== JSON.stringify(changes.position))- || ("size" in changes && JSON.stringify(state.size) !== JSON.stringify(changes.size))- if (maximized !== state.maximized || (!maximized && geometryChanged) || (minimized && !state.minimized)) {- this.cancel(identity, "geometry", "The followed Window presentation changed")- const target = { ...state, ...changes }- changes.geometryAnimation = minimized- ? null- : presentationAnimation(++this.revision, defaultPresentationTransaction(target))- }- if ("minimized" in changes && state.minimized !== changes.minimized) {- this.cancel(identity, "minimize", "The followed Window visibility changed")- const target = { ...state, ...changes }- changes.minimizeAnimation = presentationAnimation(++this.revision, defaultPresentationTransaction(target))- }- next.set(identity, { ...state, ...changes })- relation.snapshot = target- }this.publish(next)}public remove(identity: string) {-if (!this.windows.has(identity)) returnconst next = new Map(this.windows)next.delete(identity)- this.removeRepresentation(identity)- this.authoritative.delete(identity)- this.following.delete(identity)- this.observers.delete(identity)- this.emitted.delete(identity)-+ this.release(identity, "The Window presentation was removed")this.publish(next)}- public state(process: string) {-- const { identity, state } = this.existing(process)- return windowState(state, frontmost(this.windows, state.layer) === identity)- }-- public read(process: string, property: import("@shared/window-layers").WindowPresentationProperty) {- const { state } = this.existing(process)- requireWindowPresentationRead(state.layer, property)- return this.state(process)[property]- }-- /** Returns the values currently driving this desktop's representation. */- public projection(process: string) {+ public layer(process: string) { return this.existing(process).state.layer }- return this.existing(process).state- }+ public projection(process: string) { return this.existing(process).state }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.publish(new Map(this.windows))+ }- this.removeRepresentation(identity)+ public readonly registerMoveGesture = (process: string, controller: PresentationMoveGestureController | null) => {+ const identity = this.live.get(process)+ if (!identity) return+ if (this.moveGestureControllers.get(identity) === controller) return+ this.cancelIdentityMoveGestures(identity)+ if (controller) this.moveGestureControllers.set(identity, controller)+ else this.moveGestureControllers.delete(identity)+ }- if (representation) {+ public beginMoveGesture(process: string, gesture: string, origin: PresentationMovePoint, point: PresentationMovePoint) {+ const { identity, state } = this.existing(process)+ requireWindowMoveGesture(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")+ const movement = controller.begin(origin, point)+ const active = { identity, movement }+ this.moveGestures.set(gesture, active)+ void movement.finished.catch(() => undefined)+ // The iframe must retain pointer capture until the Desktop capture+ // surface exists; otherwise early movement falls between documents.+ return movement.ready.catch(error => {+ if (this.moveGestures.get(gesture) === active) this.moveGestures.delete(gesture)+ throw error+ })+ }- this.representations.set(identity, representation)+ public async waitMoveGesture(process: string, gesture: string) {+ const active = this.moveGesture(process, gesture)+ try { await active.movement.finished }+ finally {+ if (this.moveGestures.get(gesture) === active) this.moveGestures.delete(gesture)}-- this.publish(new Map(this.windows))}- public representedGeometry(process: string) {+ public cancelMoveGesture(process: string, gesture: string) {+ const active = this.moveGesture(process, gesture)+ this.moveGestures.delete(gesture)+ active.movement.cancel()+ }+ public cancelMoveGestures(process: string) {const identity = this.live.get(process)+ if (identity) this.cancelIdentityMoveGestures(identity)+ }+ public representedGeometry(process: string) {+ const identity = this.live.get(process)return identity ? this.representations.get(identity)?.read() ?? null : null}public presentGeometry(process: string, geometry: WindowRegion) {-const identity = this.live.get(process)-- if (!identity) return false-- const representation = this.representations.get(identity)-+ const representation = identity ? this.representations.get(identity) : nullif (!representation) return false-representation.present(geometry)-return true}public beginGeometry(process: string) {-const identity = this.live.get(process)-return identity ? this.representations.get(identity)?.begin() ?? null : null}public finishGeometry(process: string) {-const identity = this.live.get(process)-if (identity) this.representations.get(identity)?.finish()}public cancelGeometry(process: string) {-const identity = this.live.get(process)-if (identity) this.representations.get(identity)?.cancel()}- public move(process: string, position: WindowState["position"], transaction?: PresentationTransactionRequest) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "position")+ public move(process: string, position: Position, transaction?: PresentationTransactionRequest) {+ const { identity, state } = this.raw(process)return this.changeGeometry(identity, { ...position, ...state.size }, transaction)}- public resize(process: string, size: WindowState["size"], transaction?: PresentationTransactionRequest) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "size")+ public resize(process: string, size: Size, transaction?: PresentationTransactionRequest) {+ const { identity, state } = this.raw(process)return this.changeGeometry(identity, { ...state.position, ...size }, transaction)}- public setGeometry(process: string, value: WindowGeometry, transaction?: PresentationTransactionRequest) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "position")- return this.changeGeometry(identity, value, transaction)- }-- public minimize(process: string, minimized: boolean, transaction?: PresentationTransactionRequest) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "minimized")- return this.changeMinimized(identity, minimized, transaction)- }-- public maximize(process: string, maximized: boolean, transaction?: PresentationTransactionRequest) {- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "maximized")- if (state.maximized === maximized) return Promise.resolve()- this.cancel(identity, "geometry")- const animation = !state.minimized ? presentationAnimation(++this.revision, defaultPresentationTransaction(state), transaction) : null- this.replace(identity, { ...state, maximized, geometryAnimation: animation })- return this.waitFor(identity, "geometry", animation, transaction)- }-- public follow(process: string, transaction?: PresentationTransactionRequest) {- // Following is an intersection with the current layer's capabilities;- // an empty intersection is a successful no-op, never a layer error.- const { identity } = this.existing(process)- const snapshot = this.authoritative.get(identity)!- this.following.set(identity, { snapshot })- const current = this.windows.get(identity)!- const projected = { ...current, ...followedState(current, snapshot) }- const geometryChanged = JSON.stringify([current.position, current.size, current.maximized]) !== JSON.stringify([projected.position, projected.size, projected.maximized])- const visibilityChanged = current.minimized !== projected.minimized- this.cancel(identity, "geometry")- this.cancel(identity, "minimize")- const selectedTransaction = defaultPresentationTransaction(projected)- const geometryAnimation = geometryChanged && !projected.minimized ? presentationAnimation(++this.revision, selectedTransaction, transaction) : null- const minimizeAnimation = visibilityChanged ? presentationAnimation(++this.revision, selectedTransaction, transaction) : null- this.replace(identity, {- ...projected,- geometryAnimation,- minimizeAnimation- })- return Promise.all([- this.waitFor(identity, "geometry", geometryAnimation, transaction),- this.waitFor(identity, "minimize", minimizeAnimation, transaction)- ]).then(() => undefined)- }-- public unfollow(process: string) {- const { identity } = this.existing(process)- this.following.delete(identity)- return Promise.resolve()- }-- public setTitle(process: string, title: string) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "title")- this.replace(identity, { ...state, title })+ public setGeometry(process: string, geometry: WindowGeometry, transaction?: PresentationTransactionRequest) {+ const { identity } = this.raw(process)+ return this.changeGeometry(identity, geometry, transaction)}- public setHeader(process: string, header: boolean) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "header")- if (state.header === header) return- this.replace(identity, { ...state, header })+ public setSurface(process: string, surface: WindowPresentationSurface, transaction?: PresentationTransactionRequest) {+ const { identity, state } = this.raw(process)+ if (JSON.stringify(state.surface) === JSON.stringify(surface)) return Promise.resolve()+ this.cancel(identity, "surface")+ const animation = this.animation(transaction)+ this.replace(identity, { ...state, surface, surfaceAnimation: animation })+ return this.waitFor(identity, "surface", animation, transaction)}public raise(process: string) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "front")+ const { identity, state } = this.raw(process)if (frontmost(this.windows, state.layer) === identity) returnconst depth = [...this.windows.values()].reduce((highest, other) => other.layer === state.layer ? Math.max(highest, other.depth) : highest, 0)this.replace(identity, { ...state, depth: depth + 1 })}- public observe(process: string, event: string | null, listener: (event: string, value: unknown) => void) {-- const { identity } = this.existing(process)- const listeners = this.observers.get(identity) ?? new Set()- const selected = (emitted: string, value: unknown) => {- if (event === null || event === emitted) listener(emitted, value)- }- listeners.add(selected)- this.observers.set(identity, listeners)-- return () => {- listeners.delete(selected)- if (!listeners.size) this.observers.delete(identity)- }- }-- public setSurface(process: string, surface: WindowSurface, transaction?: PresentationTransactionRequest) {-- const { identity, state } = this.existing(process)- requirePresentationMutation(state.layer, "surface")- if (JSON.stringify(state.surface) === JSON.stringify(surface)) return Promise.resolve()-- this.cancel(identity, "surface")- const animation = presentationAnimation(++this.revision, defaultPresentationTransaction(state), transaction)- this.replace(identity, { ...state, surface, surfaceAnimation: animation })- return this.waitFor(identity, "surface", animation, transaction)- }-public complete(process: string, kind: AnimationKind, revision: number) {-const identity = this.live.get(process)- if (!identity) return- const state = this.windows.get(identity)+ const state = identity ? this.windows.get(identity) : nullconst animation = kind === "geometry"? state?.geometryAnimation- : kind === "minimize"- ? state?.minimizeAnimation- : state?.surfaceAnimation- if (!state || animation?.revision !== revision) return-+ : kind === "surface"+ ? state?.surfaceAnimation+ : state?.minimizeAnimation+ if (!identity || !state || animation?.revision !== revision) returnthis.replace(identity, kind === "geometry"? { ...state, geometryAnimation: null }- : kind === "minimize"- ? { ...state, minimizeAnimation: null }- : { ...state, surfaceAnimation: null })-+ : kind === "surface"+ ? { ...state, surfaceAnimation: null }+ : { ...state, minimizeAnimation: null })const key = animationKey(identity, kind)const waiting = this.waiting.get(key)if (!waiting || waiting.revision !== revision) return@@ -335,113 +223,72 @@ export default class WindowPresentations implements WindowPresentationHost {waiting.resolve()}- /** A new iframe representation always begins from authoritative truth. */+ /** A newly mounted iframe always begins from its layer's ownership rule. */public begin(process: string) {-const identity = this.live.get(process)- if (!identity) return- this.cancel(identity, "geometry", "The Window presentation was removed")- this.cancel(identity, "minimize", "The Window presentation was removed")- this.cancel(identity, "surface", "The Window presentation was removed")-const client = this.client(process)- if (!client) return- this.authoritative.set(identity, authoritativeState(client))- this.following.delete(identity)- if (client.window.layer === "window") this.following.set(identity, { snapshot: authoritativeState(client) })+ if (!identity || !client) return+ this.releaseTransient(identity, "The Window presentation was replaced")this.replace(identity, initialPresentationState(client))}- private existing(process: string) {+ private raw(process: string) {+ const found = this.existing(process)+ requireRawWindowPresentation(found.state.layer)+ return found+ }+ private existing(process: string) {const identity = this.live.get(process)- if (!identity) throw new Error("This Client has no Window presentation")- const state = this.windows.get(identity)- if (!state) throw new Error("This Client has no Window presentation")+ const state = identity ? this.windows.get(identity) : null+ if (!identity || !state) throw new Error("This Client has no Window presentation")return { identity, state }}- private replace(identity: string, state: WindowPresentationState) {-+ private replace(identity: string, state: PresentedWindow) {const next = new Map(this.windows)next.set(identity, state)this.publish(next)}- private removeRepresentation(identity: string) {+ private moveGesture(process: string, gesture: string) {+ const { identity } = this.existing(process)+ const active = this.moveGestures.get(gesture)+ if (!active || active.identity !== identity) throw new Error("This Window move gesture does not exist")+ return active+ }- this.representations.delete(identity)+ private cancelIdentityMoveGestures(identity: string) {+ for (const [gesture, active] of this.moveGestures) {+ if (active.identity !== identity) continue+ this.moveGestures.delete(gesture)+ active.movement.cancel()+ }}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")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()-- if (state.minimized || state.maximized) {- this.replace(identity, { ...state, position, size })- return Promise.resolve()- }this.cancel(identity, "geometry")- const animation = presentationAnimation(++this.revision, defaultPresentationTransaction(state), transaction)+ const animation = this.animation(transaction)this.replace(identity, { ...state, position, size, geometryAnimation: animation })return this.waitFor(identity, "geometry", animation, transaction)}- private changeMinimized(identity: string, minimized: boolean, transaction?: PresentationTransactionRequest) {-- const state = this.windows.get(identity)- if (!state) throw new Error("This Client has no Window presentation")- if (state.minimized === minimized) return Promise.resolve()-- this.cancel(identity, "minimize")- if (minimized) this.cancel(identity, "geometry", "The Window presentation was minimized")- const animation = presentationAnimation(++this.revision, defaultPresentationTransaction(state), transaction)- this.replace(identity, { ...state, minimized, minimizeAnimation: animation, geometryAnimation: minimized ? null : state.geometryAnimation })- return this.waitFor(identity, "minimize", animation, transaction)+ private animation(request?: PresentationTransactionRequest): PresentationAnimation | null {+ if (!request) return null+ return Object.freeze({ revision: ++this.revision, ...request.transaction === undefined ? {} : { transaction: request.transaction } })}- private publish(next: ReadonlyMap<string, WindowPresentationState>) {-+ private publish(next: ReadonlyMap<string, PresentedWindow>) {this.windows = next- this.emitPresentationEvents()this.changed(next)}- private emitPresentationEvents() {-- for (const [identity, presentation] of this.windows) {- // Renderer measurements are private output. Presentation events expose- // the values the Desktop relies on, so maximize and animation cannot- // rewrite or continuously reinterpret the retained geometry.- const current = windowState(presentation, frontmost(this.windows, presentation.layer) === identity)- const previous = this.emitted.get(identity)- this.emitted.set(identity, current)- if (!previous) continue-- const emit = (property: import("@shared/window-layers").WindowPresentationProperty, event: string, value: unknown) => {- if (!supportsWindowPresentationApplication(presentation.layer, property)) return- for (const listener of this.observers.get(identity) ?? []) listener(event, value)- }-- const moved = JSON.stringify(previous.position) !== JSON.stringify(current.position)- const resized = JSON.stringify(previous.size) !== JSON.stringify(current.size)- if (moved) emit("position", "move", current.position)- if (resized) emit("size", "resize", current.size)- if (previous.minimized !== current.minimized) emit("minimized", "minimize", current.minimized)- if (previous.maximized !== current.maximized) emit("maximized", "maximize", current.maximized)- if (previous.title !== current.title) emit("title", "changeTitle", current.title)- if (previous.header !== current.header) emit("header", "changeHeader", current.header)- if (JSON.stringify(previous.surface) !== JSON.stringify(current.surface)) emit("surface", "changeSurface", current.surface)- if (previous.front !== current.front) emit("front", "front", current.front)- }- }-private cancel(identity: string, kind: AnimationKind, reason = "The Window presentation transaction was interrupted") {-const key = animationKey(identity, kind)const waiting = this.waiting.get(key)if (!waiting) return@@ -449,117 +296,123 @@ export default class WindowPresentations implements WindowPresentationHost {waiting.reject(new Error(reason))}- private waitFor(identity: string, kind: AnimationKind, animation: WindowPresentationState["geometryAnimation"], transaction?: PresentationTransactionRequest) {-+ private waitFor(identity: string, kind: AnimationKind, animation: PresentationAnimation | null, transaction?: PresentationTransactionRequest) {if (!animation || !transaction?.wait) return Promise.resolve()return new Promise<void>((resolve, reject) => {-this.waiting.set(animationKey(identity, kind), { revision: animation.revision, resolve, reject })})}-}-type AnimationKind = "geometry" | "minimize" | "surface"--interface WaitingAnimation {- revision: number- resolve: () => void- reject: (error: Error) => void-}+ private releaseTransient(identity: string, reason: string) {+ this.cancel(identity, "geometry", reason)+ this.cancel(identity, "surface", reason)+ this.cancelIdentityMoveGestures(identity)+ this.representations.delete(identity)+ }-interface FollowingWindow {- snapshot: WindowPresentationState+ private release(identity: string, reason: string) {+ this.releaseTransient(identity, reason)+ this.moveGestureControllers.delete(identity)+ }}-function animationKey(identity: string, kind: AnimationKind) {-- return `${identity}:${kind}`+interface ActiveMoveGesture {+ identity: string+ movement: ReturnType<PresentationMoveGestureController["begin"]>}-function presentationAnimation(revision: number, fallback: WindowState["transaction"], request?: PresentationTransactionRequest) {+type AnimationKind = "geometry" | "surface" | "minimize"- const transaction = request?.transaction === undefined || request.transaction === true- ? fallback- : request.transaction- return transaction === false ? null : Object.freeze({ revision, transaction })-}--function defaultPresentationTransaction(state: Pick<WindowPresentationState, "layer" | "transaction">) {- return state.transaction+interface WaitingAnimation {+ revision: number+ resolve: () => void+ reject: (error: Error) => void}-function initialPresentationState(client: ClientState): WindowPresentationState {+function animationKey(identity: string, kind: AnimationKind) { return `${identity}:${kind}` }+function initialPresentationState(client: ClientState): PresentedWindow {const window = client.window- const fixed = isFixedWindowPresentationLayer(window.layer)+ const layer = window.layer+ if (layer === "window") return {+ title: window.title,+ header: window.header,+ surface: true,+ position: window.position,+ size: window.size,+ minimized: window.minimized,+ maximized: window.maximized,+ layer,+ depth: window.depth,+ surfaceAnimation: null,+ geometryAnimation: null,+ minimizeAnimation: null+ }+ if (layer === "wallpaper") return {+ title: window.title,+ header: false,+ surface: false,+ position: { x: 0, y: 0 },+ size: { width: "100%", height: "100%" },+ minimized: false,+ maximized: true,+ layer,+ depth: 0,+ surfaceAnimation: null,+ geometryAnimation: null,+ minimizeAnimation: null+ }+ // Raw layers deliberately do not interpret the authoritative Window even+ // on first mount. Program code must explicitly build its local projection.return {- ...authoritativeState(client),title: window.title,- header: window.layer === "window" ? window.header : false,- surface: fixed ? false : window.surface,- position: fixed ? { x: 0, y: 0 } : window.position,- size: fixed ? { width: "100%", height: "100%" } : window.size,- minimized: fixed ? false : window.minimized,- maximized: fixed ? true : window.maximized,- depth: fixed ? 0 : window.depth,+ header: false,+ surface: false,+ position: { x: 0, y: 0 },+ size: { width: 0, height: 0 },+ minimized: false,+ maximized: false,+ layer,+ depth: window.depth,surfaceAnimation: null,+ geometryAnimation: null,+ minimizeAnimation: null}}-function authoritativeState(client: ClientState): WindowPresentationState {+function followStandardWindow(current: PresentedWindow, client: ClientState, revision: number): PresentedWindow {const window = client.window+ const geometryChanged = JSON.stringify([current.position, current.size]) !== JSON.stringify([window.position, window.size])+ const minimizedChanged = current.minimized !== window.minimizedreturn {+ ...current,title: window.title,header: window.header,- surface: window.surface,- transaction: window.transaction,position: window.position,size: window.size,minimized: window.minimized,maximized: window.maximized,- front: false,- layer: window.layer,depth: window.depth,- surfaceAnimation: null,- geometryAnimation: null,- minimizeAnimation: null- }-}--function windowState(local: WindowPresentationState, front: boolean): WindowState {-- return {- title: local.title,- header: local.header,- surface: local.surface,- transaction: local.transaction,- position: local.position,- size: local.size,- minimized: local.minimized,- maximized: local.maximized,- front,- layer: local.layer,+ geometryAnimation: geometryChanged && !window.minimized+ ? { revision }+ : current.geometryAnimation,+ minimizeAnimation: minimizedChanged+ ? { revision }+ : current.minimizeAnimation}}export interface PresentationGeometryRepresentation {-read: () => WindowRegion-present: (geometry: WindowRegion) => void-begin: () => WindowRegion | null-finish: () => void-cancel: () => void}-function frontmost(windows: ReadonlyMap<string, WindowPresentationState>, layer: WindowPresentationState["layer"]) {-- let best: [string, WindowPresentationState] | null = null+function frontmost(windows: ReadonlyMap<string, PresentedWindow>, layer: WindowLayer) {+ let best: [string, PresentedWindow] | null = nullfor (const candidate of windows) {-const [, window] = candidateif (window.layer !== layer || window.minimized) continueif (!best || best[1].depth <= window.depth) best = candidatediff --git a/source/client/view/structure/desktop/desktop.tsx b/source/client/view/structure/desktop/desktop.tsxindex 7db99eb..dd1ad25 100644--- a/source/client/view/structure/desktop/desktop.tsx+++ b/source/client/view/structure/desktop/desktop.tsx@@ -128,8 +128,6 @@ export default function Workspace() {layer={presentation.layer}- transaction={presentation.transaction}-icon={icon(record)}position={presentation.position}@@ -146,6 +144,8 @@ export default function Workspace() {onPresentationRepresentation={windows.presentation.represent}+ onPresentationMoveGesture={windows.presentation.registerMoveGesture}+// Only system-painted windows need to know which paint edges// touch their surface. Positioning is identical in every layer.paintSurfaceSize={layer === "window" ? windowSurfaceSize : undefined}diff --git a/source/client/view/structure/desktop/windows/process-window.tsx b/source/client/view/structure/desktop/windows/process-window.tsxindex 5eef4e1..5ba2bea 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 WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"-import { type PresentationAnimation } from "@client/view/components/desktop-host/window-presentation"+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 Theme, type WindowSurface, type WindowLayer, type WindowTransaction } from "@phreshos/core"+import { type Position, type Size, type Theme, type WindowPresentationSurface, type WindowLayer } from "@phreshos/core"import Spinner from "@client/view/components/spinner"import Window from "./window"import ProgramFrame, { programFrameSource } from "@client/view/components/program-frame"@@ -17,7 +17,7 @@ const settleDelay = 80* 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, transaction, icon, position, size, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, paintSurfaceSize, spacing, depth, active, minimized, maximized, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {+export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, icon, position, size, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, paintSurfaceSize, spacing, depth, active, minimized, maximized, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {const activate = useCallback(() => onRaise(record), [onRaise, record])@@ -39,6 +39,8 @@ 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 frameSource = programFrameSource(assetId, door)const [loading, setLoading] = useState<LoadingState>({ source: null, phase: "loading" })@@ -100,8 +102,6 @@ export default memo(function ({ identity, record, assetId, client, title, headerlayer={layer}- transaction={transaction}-icon={icon}position={position}@@ -118,6 +118,8 @@ export default memo(function ({ identity, record, assetId, client, title, headeronPresentationRepresentation={represent}+ onPresentationMoveGesture={moveGesture}+paintSurfaceSize={paintSurfaceSize}spacing={spacing}@@ -218,12 +220,10 @@ interface ProcessWindowProps {header: boolean- surface: WindowSurface+ surface: WindowPresentationSurfacelayer: WindowLayer- transaction: WindowTransaction-icon: stringposition: Position@@ -240,6 +240,8 @@ interface ProcessWindowProps {onPresentationRepresentation: (identity: string, representation: PresentationGeometryRepresentation | null) => void+ onPresentationMoveGesture: (identity: string, controller: PresentationMoveGestureController | null) => void+paintSurfaceSize?: WindowSurfaceSizespacing: numberdiff --git a/source/client/view/structure/desktop/windows/snap-preview.tsx b/source/client/view/structure/desktop/windows/snap-preview.tsxindex a49ebc2..bfe7b4d 100644--- a/source/client/view/structure/desktop/windows/snap-preview.tsx+++ b/source/client/view/structure/desktop/windows/snap-preview.tsx@@ -15,7 +15,7 @@ export default function SnapPreview({ shown, visible, bare, minimumSize, paintSuposition: shown.position,size: shown.size,animation: null,- transaction: true,+ transaction,immediate: reducedMotion,minimumSize})diff --git a/source/client/view/structure/desktop/windows/window-geometry-motion.ts b/source/client/view/structure/desktop/windows/window-geometry-motion.tsindex f96fa7b..7dd63c0 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 { resolveWindowTransaction } from "@client/view/appearance/motion"-import { type AppearanceTransaction, type Position, type Size, type WindowTransaction } from "@phreshos/core"+import { type AppearanceTransaction, type Position, type Size, type WindowPresentationTransaction } 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?: WindowTransaction | null+ transaction?: WindowPresentationTransaction | nullimmediate: booleanminimumSize?: WindowSurfaceSizeonComplete?: (revision: number) => voiddiff --git a/source/client/view/structure/desktop/windows/window-surface.tsx b/source/client/view/structure/desktop/windows/window-surface.tsxindex 508f154..6d5b913 100644--- a/source/client/view/structure/desktop/windows/window-surface.tsx+++ b/source/client/view/structure/desktop/windows/window-surface.tsx@@ -3,7 +3,7 @@ import { resolveRadius, Surface, type Appearance, type Color, type MaterialOptioimport { 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 WindowSurface as WindowSurfaceDefinition } from "@phreshos/core"+import { type AppearanceColor, type WindowPresentationSurface 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"@@ -20,7 +20,7 @@ export default function WindowSurface({ surface, animation, onComplete }: Windowconst animated = revision !== undefined && transaction !== nullconst [hidden, setHidden] = useState(!visible)const completed = useRef<number | null>(null)- const retained = useRef<Exclude<WindowSurfaceDefinition, false>>(true)+ const retained = useRef<VisibleWindowSurface>(true)if (surface !== false) retained.current = surface@@ -74,7 +74,9 @@ interface WindowSurfaceProps {onComplete: (revision: number) => void}-function surfaceColor(surface: Exclude<WindowSurfaceDefinition, false>): Color | undefined {+type VisibleWindowSurface = Exclude<WindowSurfaceDefinition, false>++function surfaceColor(surface: VisibleWindowSurface): Color | undefined {if (surface === true || surface.color === undefined) return undefined@@ -83,7 +85,7 @@ function surfaceColor(surface: Exclude<WindowSurfaceDefinition, false>): Color |: surface.color}-function surfaceMaterial(surface: Exclude<WindowSurfaceDefinition, false>): "none" | "full" | MaterialOptions {+function surfaceMaterial(surface: VisibleWindowSurface): "none" | "full" | MaterialOptions {if (surface === true || surface.material === undefined) return "full"@@ -95,7 +97,7 @@ function surfaceMaterial(surface: Exclude<WindowSurfaceDefinition, false>): "nonconst appearanceColors = ["background", "foreground", "default", "primary", "secondary", "success", "warning", "danger", "info"] as const satisfies readonly AppearanceColor[]/** Resolves the one boundary shared by Desktop paint and standard-window content. */-export function windowSurfaceRadius(surface: Exclude<WindowSurfaceDefinition, false>, appearance: Appearance) {+export function windowSurfaceRadius(surface: VisibleWindowSurface, appearance: Appearance) {const radius = typeof surface === "object" ? surface.radius : undefineddiff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsxindex 6acf965..2442444 100644--- a/source/client/view/structure/desktop/windows/window.tsx+++ b/source/client/view/structure/desktop/windows/window.tsx@@ -3,10 +3,10 @@ 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, resolveWindowGeometry, windowPaintInsets, type WindowRegion, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"-import { type Position, type Size, type WindowSurface as WindowSurfaceDefinition, type WindowLayer, type WindowTransaction } from "@phreshos/core"+import { type Position, type Size, type WindowPresentationSurface as WindowSurfaceDefinition, type WindowLayer } from "@phreshos/core"import WindowHeader from "./window-header"import WindowSurface, { windowSurfaceRadius } from "./window-surface"-import { type PresentationAnimation } from "@client/view/components/desktop-host/window-presentation"+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 { motion } from "motion/react"import { motionTransition, resolveWindowTransaction } from "@client/view/appearance/motion"@@ -14,6 +14,7 @@ import { useAppearance } from "@phreshos/react-ui"import SnapPreview, { type SnapTarget } from "./snap-preview"import useWindowGeometryMotion from "./window-geometry-motion"import { physicalToDesktopPixels, useDesktopScale } from "../desktop-scale"+import { createPortal } from "react-dom"/*** A window: a pure function of the record it is given. Every render@@ -49,14 +50,14 @@ const edges: { edge: WindowEdge, className: string }[] = [const minimizedSurfacePose = { scale: 0.86, y: 28, opacity: 0 }-export default function ({ title, header = true, surface, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, entering = false, transaction = false, position = { x: 0, y: 0 }, size = { width: 520, height: 340 }, surfaceAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, spacing = 0, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {+export default function ({ title, header = true, surface, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, entering = false, position = { x: 0, y: 0 }, size = { width: 520, height: 340 }, surfaceAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, spacing = 0, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {const reducedMotion = useReducedMotion()const appearance = useAppearance()const appearanceTransaction = appearance.transactionconst desktopScale = useDesktopScale()const standard = layer === "window"- const surfaceDefinition = surface ?? standard+ const surfaceDefinition = surface ?? (standard ? true : false)const surfaceRadius = surfaceDefinition === false ? undefined : windowSurfaceRadius(surfaceDefinition, appearance)const presentationMinimum = standard ? { width: minWidth, height: minHeight } : undefined@@ -85,6 +86,14 @@ export default function ({ title, header = true, surface, layer, icon, children,const frameElement = geometryMotion.frameconst [gesture, setGesture] = useState<Gesture | null>(null)+ const [externalMoveActive, setExternalMoveActive] = useState(false)+ const externalMove = useRef<ExternalMove | null>(null)+ const beginMoveGesture = useRef<(point: PresentationMovePoint) => ActivePointerGesture | null>(() => null)+ beginMoveGesture.current = point => {+ let active: ActivePointerGesture | null = null+ grab(point, null, gesture => { active = gesture })+ return active+ }useLayoutEffect(function () {@@ -104,6 +113,62 @@ export default function ({ title, header = true, surface, layer, icon, children,}, [onPresentationRepresentation])+ const moveGestureController = useRef<PresentationMoveGestureController | null>(null)+ if (!moveGestureController.current) {+ moveGestureController.current = {+ begin(origin, point) {+ if (externalMove.current) throw new Error("This Window already has an active move gesture")+ const pointer = beginMoveGesture.current(origin)+ if (!pointer) throw new Error("This Window cannot currently begin a move gesture")+ pointer.update(point)+ let markReady: () => void = () => undefined+ const ready = new Promise<void>(resolve => { markReady = resolve })+ let finish: () => void = () => undefined+ const finished = new Promise<void>(resolve => { finish = resolve })+ externalMove.current = { pointer, markReady, finish }+ setExternalMoveActive(true)+ return { ready, finished, cancel: () => finishExternalMove(null) }+ },+ cancel: () => finishExternalMove(null)+ }+ }++ function finishExternalMove(point: PresentationMovePoint | null) {+ const active = externalMove.current+ if (!active) return+ externalMove.current = null+ setExternalMoveActive(false)+ // Cancellation may happen before the portal commits. Readiness must+ // still settle so the remote owner can observe the completed gesture.+ active.markReady()+ if (point) active.pointer.end(point)+ else active.pointer.cancel()+ active.finish()+ }++ useLayoutEffect(function () {+ if (!standard || !onPresentationMoveGesture) return+ // Program-owned chrome supplies pointer intent, while this controller+ // remains the single owner of geometry, snapping, and commit behavior.+ onPresentationMoveGesture(moveGestureController.current)+ return () => {+ moveGestureController.current?.cancel()+ onPresentationMoveGesture(null)+ }+ }, [standard, onPresentationMoveGesture])++ useEffect(function () {+ if (!externalMoveActive) return+ const cancel = () => finishExternalMove(null)+ const visibility = () => { if (document.hidden) cancel() }+ window.addEventListener("blur", cancel)+ document.addEventListener("visibilitychange", visibility)+ return () => {+ window.removeEventListener("blur", cancel)+ document.removeEventListener("visibilitychange", visibility)+ }+ }, [externalMoveActive])+const closureCompleted = useRef(false)function completeClosure() {@@ -156,9 +221,7 @@ export default function ({ title, header = true, surface, layer, icon, children,}, [minimizeAnimation?.revision, reducedMotion])- const entryTransaction = layer === "under" || layer === "over"- ? resolveWindowTransaction(transaction, appearanceTransaction)- : standard ? appearanceTransaction : null+ const entryTransaction = standard ? appearanceTransaction : nullconst opening = entering && !reducedMotion ? entryTransaction : nullconst [opened, setOpened] = useState(opening === null)const minimizeTransaction = minimizeAnimation@@ -198,18 +261,23 @@ export default function ({ title, header = true, surface, layer, icon, children,}}- function grab(event: ReactPointerEvent<HTMLElement>, edge: WindowEdge | null) {+ function grab(event: ReactPointerEvent<HTMLElement> | PresentationMovePoint, edge: WindowEdge | null, receive?: (gesture: ActivePointerGesture) => void) {if (maximized && edge !== null) return+ const external = receive !== undefined+ const pointer = external+ ? event as PresentationMovePoint+ : { x: (event as ReactPointerEvent<HTMLElement>).clientX, y: (event as ReactPointerEvent<HTMLElement>).clientY }+// A cancelled pointerdown suppresses double-click synthesis, and// a shared window restores by double-click; absolute ones keep// it to block native drags.- if (absolute) event.preventDefault()+ if (absolute && !external) (event as ReactPointerEvent<HTMLElement>).preventDefault()- const handle = event.currentTarget+ const handle = external ? null : (event as ReactPointerEvent<HTMLElement>).currentTarget- handle.setPointerCapture(event.pointerId)+ if (handle) handle.setPointerCapture((event as ReactPointerEvent<HTMLElement>).pointerId)const started = geometryMotion.beginGesture()@@ -239,7 +307,7 @@ export default function ({ title, header = true, surface, layer, icon, children,let renderFrame = 0- const start = { pointerX: event.clientX, pointerY: event.clientY }+ const start = { pointerX: pointer.x, pointerY: pointer.y }// Pointer hardware can report faster than the display can paint. Keep// gesture state authoritative while scheduling at most one React@@ -259,11 +327,11 @@ 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: globalThis.PointerEvent): Snap | null {+ function snapTerm(motion: PresentationMovePoint): Snap | null {- const pointerX = physicalToDesktopPixels(motion.clientX - bounds!.left, desktopScale)+ const pointerX = physicalToDesktopPixels(motion.x - bounds!.left, desktopScale)- const pointerY = physicalToDesktopPixels(motion.clientY - bounds!.top, desktopScale)+ const pointerY = physicalToDesktopPixels(motion.y - bounds!.top, desktopScale)const west = pointerX <= 16@@ -283,11 +351,11 @@ export default function ({ title, header = true, surface, layer, icon, children,}}- function move(motion: globalThis.PointerEvent) {+ function move(motion: PresentationMovePoint) {- const physicalX = motion.clientX - start.pointerX+ const physicalX = motion.x - start.pointerX- const physicalY = motion.clientY - start.pointerY+ const physicalY = motion.y - start.pointerYconst dx = physicalToDesktopPixels(physicalX, desktopScale)@@ -306,9 +374,9 @@ export default function ({ title, header = true, surface, layer, icon, children,// The window returns to its floating size placed so the// pointer keeps its proportional position across the// header, and the same gesture carries on dragging.- const pointerX = physicalToDesktopPixels(motion.clientX - bounds!.left, desktopScale)+ const pointerX = physicalToDesktopPixels(motion.x - bounds!.left, desktopScale)- const pointerY = physicalToDesktopPixels(motion.clientY - bounds!.top, desktopScale)+ const pointerY = physicalToDesktopPixels(motion.y - bounds!.top, desktopScale)const ratio = Math.min(Math.max((pointerX - origin.x) / origin.width, 0), 1)@@ -324,9 +392,9 @@ export default function ({ title, header = true, surface, layer, icon, children,current = { ...origin }- start.pointerX = motion.clientX+ start.pointerX = motion.x- start.pointerY = motion.clientY+ start.pointerY = motion.yonMove?.(origin.x, origin.y)@@ -376,16 +444,10 @@ export default function ({ title, header = true, surface, layer, icon, children,renderGesture()}- function release(motion: globalThis.PointerEvent) {+ function release(motion: PresentationMovePoint, committed: boolean) {if (renderFrame) cancelAnimationFrame(renderFrame)- handle.removeEventListener("pointermove", move)-- handle.removeEventListener("pointerup", release)-- handle.removeEventListener("pointercancel", release)-// A tiled press that never crossed the threshold changed// nothing: the render returns to the tile it never left.if (restoring) {@@ -396,7 +458,7 @@ export default function ({ title, header = true, surface, layer, icon, children,return}- const term = moved && edge === null && motion.type === "pointerup" ? snapTerm(motion) : null+ const term = moved && edge === null && committed ? snapTerm(motion) : null// The outcome and the gesture's end land in one batch: the// record updates as the gesture stops overriding it, so the@@ -407,7 +469,7 @@ export default function ({ title, header = true, surface, layer, icon, children,onSnap?.(term.position, term.size)}- else if (moved && motion.type === "pointerup") {+ else if (moved && committed) {geometryMotion.finishGesture()@@ -421,18 +483,30 @@ export default function ({ title, header = true, surface, layer, icon, children,}- else if (motion.type === "pointercancel") geometryMotion.cancelGesture()+ else if (!committed) geometryMotion.cancelGesture()else geometryMotion.finishGesture()setGesture(null)}- handle.addEventListener("pointermove", move)-- handle.addEventListener("pointerup", release)-- handle.addEventListener("pointercancel", release)+ if (handle) {+ const movePointer = (motion: globalThis.PointerEvent) => move({ x: motion.clientX, y: motion.clientY })+ const releasePointer = (motion: globalThis.PointerEvent) => {+ handle.removeEventListener("pointermove", movePointer)+ handle.removeEventListener("pointerup", releasePointer)+ handle.removeEventListener("pointercancel", releasePointer)+ release({ x: motion.clientX, y: motion.clientY }, motion.type === "pointerup")+ }+ handle.addEventListener("pointermove", movePointer)+ handle.addEventListener("pointerup", releasePointer)+ handle.addEventListener("pointercancel", releasePointer)+ }+ else receive?.({+ update: move,+ end(point) { release(point, true) },+ cancel() { release(pointer, false) }+ })setGesture({ origin, current, zone, shown })}@@ -447,6 +521,22 @@ export default function ({ title, header = true, surface, layer, icon, children,return <>+ {externalMoveActive && createPortal(<div+ data-window-move-capture+ ref={element => { if (element) externalMove.current?.markReady() }}+ className="fixed inset-0 touch-none select-none cursor-move"+ style={{ zIndex: 2147483647 }}+ onPointerMove={event => {+ if (!event.currentTarget.hasPointerCapture(event.pointerId)) {+ try { event.currentTarget.setPointerCapture(event.pointerId) }+ catch { /* The full-viewport capture surface still owns in-bounds movement. */ }+ }+ externalMove.current?.pointer.update({ x: event.clientX, y: event.clientY })+ }}+ onPointerUp={event => finishExternalMove({ x: event.clientX, y: event.clientY })}+ onPointerCancel={() => finishExternalMove(null)}+ />, document.body)}+{/* The snap preview and its result resolve the same edge contacts. */}{gesture?.shown && <SnapPreviewshown={gesture.shown}@@ -624,9 +714,6 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "/** Whether mounting this element represents a newly opened Window. */entering?: boolean- /** Default transaction used by presentation operations. */- transaction?: WindowTransaction-position?: Positionsize?: Size@@ -641,6 +728,8 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "onPresentationRepresentation?: (representation: PresentationGeometryRepresentation | null) => void+ onPresentationMoveGesture?: (controller: PresentationMoveGestureController | null) => void+/** Surface used only to decide which painted edges receive an inset. */paintSurfaceSize?: WindowSurfaceSize@@ -663,3 +752,15 @@ interface Gesture {shown: Snap | null}++interface ActivePointerGesture {+ update(point: PresentationMovePoint): void+ end(point: PresentationMovePoint): void+ cancel(): void+}++interface ExternalMove {+ pointer: ActivePointerGesture+ markReady: () => void+ finish: () => void+}diff --git a/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts b/source/server/core/link-manager/auth-manager/process-manager/process-manager.tsindex 3f7a8c2..4cf4967 100644--- a/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts@@ -164,6 +164,10 @@ export default class ProcessManager extends TheLink {private mutableWindowOf(identity: string) {+ const process = this.find(identity)++ if (!process.client) throw new Error("This Client Endpoint is not running")+const window = this.windowOf(identity)return window@@ -175,13 +179,14 @@ export default class ProcessManager extends TheLink {public windowSnapshot(identity: string): WindowState {const process = this.find(identity)++ if (!process.client) throw new Error("This Client Endpoint is not running")+const window = this.windowOf(identity)return Object.freeze({title: window.title,header: window.header,- surface: window.surface,- transaction: window.transaction,position: window.position,size: window.size,minimized: window.minimized,@@ -945,11 +950,21 @@ export default class ProcessManager extends TheLink {return target ? access.canProcess(target) : false}- private window(shape: Shape) {+ private window() {++ return new Window()+ }- const shown = { title: shape.title, header: shape.header, surface: shape.surface, transaction: shape.transaction, layer: shape.layer }+ private startWindow(window: Window, shape: Shape) {- return new Window(shown, shape.position, shape.size, ++this.highest, shape.minimize, shape.maximize)+ window.start(+ { title: shape.title, header: shape.header, layer: shape.layer },+ shape.position,+ shape.size,+ ++this.highest,+ shape.minimize,+ shape.maximize+ )}private readonly layerClaims = new Map<SerializedClientLayer, Promise<unknown>>()@@ -1021,7 +1036,7 @@ export default class ProcessManager extends TheLink {// do not hear about it.const front = shape && this.front(shape.layer)- const window = registration?.window ? this.window(registration.window) : shape ? this.window(shape) : null+ const window = registration?.window || shape ? this.window() : nullconst process = new Process(@@ -1061,7 +1076,10 @@ export default class ProcessManager extends TheLink {// order: Process creation, endpoint start, endpoint stop, Process exit.await this.transition(process, async () => {- if (client && window) this.activateClient(process, launch.client?.service ?? false)+ if (client && window && shape) {+ this.startWindow(window, shape)+ this.activateClient(process, launch.client?.service ?? false)+ }if (runtime) this.activateServer(process, runtime, launch.server?.service ?? false)@@ -1084,7 +1102,7 @@ export default class ProcessManager extends TheLink {registration?.created?.(process)- if (window) this.settleFront(window.layer, front)+ if (process.client && window) this.settleFront(window.layer, front)if (process.server) await this.serverStarted(process)@@ -1284,9 +1302,7 @@ export default class ProcessManager extends TheLink {const shape = this.authManager.programManager.clientShape(process.program, launch)- const layer = launch.layer ?? process.clientEndpoint?.window.layer ?? shape.layer-- return await this.serializeClientLayer(layer, () => this.startClientInLayer(identity, launch, shape))+ return await this.serializeClientLayer(shape.layer, () => this.startClientInLayer(identity, launch, shape))}private async startClientInLayer(identity: string, launch: ClientLaunch, shape: StandardShape) {@@ -1307,7 +1323,9 @@ export default class ProcessManager extends TheLink {if (!window) throw new Error("This Program declared no Client Endpoint")- this.applyClientLaunch(process, window, shape, launch)+ // Every Client execution owns a fresh authoritative Window. No+ // value from the previous execution is available to inherit.+ this.startWindow(window, shape)const before = this.front(window.layer)@@ -1338,42 +1356,6 @@ export default class ProcessManager extends TheLink {return identity}- /** Explicit restart values replace their retained authoritative counterparts. */- private applyClientLaunch(process: Process, window: Window, shape: StandardShape, launch: ClientLaunch) {-- if (launch.title !== undefined && window.setTitle(shape.title)) this.said(process.identity, "changeTitle", window.title)-- if (launch.header !== undefined && window.setHeader(shape.header)) this.said(process.identity, "changeHeader", window.header)-- if (launch.surface !== undefined && window.setSurface(shape.surface)) this.said(process.identity, "changeSurface", window.surface)-- if (launch.transaction !== undefined && window.setTransaction(shape.transaction)) this.said(process.identity, "changeTransaction", window.transaction)-- if (launch.position !== undefined && launch.size !== undefined) {- const changed = window.setGeometry({ ...shape.position, ...shape.size })- if (changed.moved || changed.resized) {- if (changed.moved) this.said(process.identity, "move", window.position)- if (changed.resized) this.said(process.identity, "resize", window.size)- }- }- else {- if (launch.position !== undefined && window.move(shape.position)) this.said(process.identity, "move", window.position)- if (launch.size !== undefined && window.resize(shape.size)) this.said(process.identity, "resize", window.size)- }-- if (launch.minimize !== undefined && window.minimized !== shape.minimize) {- window.minimized = shape.minimize- this.said(process.identity, "minimize", window.minimized)- }-- if (launch.maximize !== undefined && window.maximized !== shape.maximize) {- window.maximized = shape.maximize- this.said(process.identity, "maximize", window.maximized)- }-- if (launch.layer !== undefined) window.layer = shape.layer- }-public async stopClient(identity: string) {const process = this.find(identity)@@ -2349,24 +2331,6 @@ export default class ProcessManager extends TheLink {return [target.identity]}- if (word === "setSurface") {-- const target = heldWindow(rest[0]).process-- await this.system.setWindowSurface(target, rest[1] as never)-- return [target.identity]- }-- if (word === "setTransaction") {-- const target = heldWindow(rest[0]).process-- await this.system.setWindowTransaction(target, rest[1] as never)-- return [target.identity]- }-if (word === "raise") {const target = heldWindow(rest[0]).process@@ -3270,30 +3234,6 @@ export default class ProcessManager extends TheLink {return await this.publishWindowChange("/change-header", identity, window)}- @Subscribe("/set-surface")- public async setSurface(identity: string, surface: import("@phreshos/core").WindowSurface) {-- const window = this.mutableWindowOf(identity)-- if (!window.setSurface(surface)) return { identity, window }-- this.said(identity, "changeSurface", window.surface)-- return await this.publishWindowChange("/change-surface", identity, window)- }-- @Subscribe("/set-transaction")- public async setTransaction(identity: string, transaction: import("@phreshos/core").WindowTransaction) {-- const window = this.mutableWindowOf(identity)-- if (!window.setTransaction(transaction)) return { identity, window }-- this.said(identity, "changeTransaction", window.transaction)-- return await this.publishWindowChange("/change-transaction", identity, window)- }-// To the front of its own layer, and that is the whole of it.//// It was called `focus` and it did three things: it showed a hidden@@ -3578,10 +3518,6 @@ interface ShapeBase {header: boolean- surface: import("@phreshos/core").WindowSurface-- transaction: import("@phreshos/core").WindowTransaction-position: Positionsize: Sizediff --git a/source/server/core/link-manager/auth-manager/process-manager/process.ts b/source/server/core/link-manager/auth-manager/process-manager/process.tsindex 09592fd..774276e 100644--- a/source/server/core/link-manager/auth-manager/process-manager/process.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/process.ts@@ -5,7 +5,7 @@ import ServerProcessBoundary, { type HostVisibility } from "./server-process-bouimport HostTraffic from "./host-traffic"import ClientState from "./client-state"import { randomUUID } from "node:crypto"-import { type Layer, type WindowSurface, type WindowTransaction } from "@phreshos/core"+import { type Layer } from "@phreshos/core"import { Tunnel } from "@the-link/core"import type { ServerRuntime } from "@server/core/server-runtime"@@ -64,7 +64,7 @@ export default class Process {// belongs to the Desktop session and ends when this context stops.public client: ClientState | null = null- /** Permanent Client Endpoint state retained between execution contexts. */+ /** Permanent Client Endpoint handle; its Window state exists only while running. */public readonly clientEndpoint: Readonly<{ window: Window }> | null// The process whose call to `program.createProcess()` created this@@ -178,6 +178,10 @@ export default class Process {this.client = null+ // Stopping ends this incarnation rather than retaining values for the+ // next start. Subscriptions remain attached to the stable handle.+ this.clientEndpoint?.window.stop()+for (const listener of this.clientStops) listener()return true@@ -325,7 +329,7 @@ export default class Process {parent: this.parent?.record() ?? null,clientEndpoint: this.clientEndpoint- ? { window: this.clientEndpoint.window.toJSON() }+ ? { window: this.client ? this.clientEndpoint.window.toJSON() : null }: null,client: this.client ? { ...this.client, sandbox: this.program.client?.sandbox ?? true } : null@@ -372,10 +376,6 @@ export interface ProcessLaunch {header: boolean- surface: WindowSurface-- transaction: WindowTransaction-position: Position | nullsize: Size | nulldiff --git a/source/server/core/link-manager/auth-manager/process-manager/window.ts b/source/server/core/link-manager/auth-manager/process-manager/window.tsindex 04f5176..5581d69 100644--- a/source/server/core/link-manager/auth-manager/process-manager/window.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/window.ts@@ -1,227 +1,140 @@import {isRelativeValue,- parseWindowSurface,- parseWindowTransaction,type Position,type Size,type Value,- type WindowSurface,type WindowGeometry,- type WindowLayer,- type WindowState,- type WindowTransaction+ type WindowLayer} from "@phreshos/core"-/** Authoritative geometry, visibility, maximization, title, and layer ordering. */-// What a Window says about the Program behind it. Resolved when the Process-// first gains Window state and again only when a stopped client is restarted-// with explicit overrides; ordinary live Window operations remain narrower.+/** Values from which one running Client Endpoint begins its authoritative Window. */export interface Shown {-title: string-header: boolean-- surface: WindowSurface-- transaction: WindowTransaction-- // Which structurally isolated Desktop layer this Window occupies.layer: WindowLayer-}-export default class Window implements Omit<WindowState, "front"> {-- public position: Position-- public size: Size-- public depth: number-- // Whether it is shown. A window may be born hidden, which is a- // state at birth rather than an act afterwards: hidden from the- // first rendered frame is not the same as shown once and then hidden.- public minimized: boolean-- public maximized: boolean-- // What a person reads on it. Born from the program, the window's- // own afterwards.- public title: string-- public header: boolean-- // The Window's authoritative Desktop layer.- public layer: WindowLayer-- public surface: WindowSurface-- public transaction: WindowTransaction-- public constructor(shown: Shown, position: Position, size: Size, depth: number, minimized: boolean, maximized = false) {-- this.title = shown.title-- this.header = shown.header-- this.surface = parseWindowSurface(shown.surface)-- this.transaction = parseWindowTransaction(shown.transaction)-- this.layer = shown.layer-- this.position = position-- this.size = size+/**+ * Stable Window handle whose authoritative state exists only while its Client+ * Endpoint is running. A restart replaces the complete state in one step.+ */+export default class Window {+ private state: WindowSnapshot | null = null+ public start(shown: Shown, position: Position, size: Size, depth: number, minimized: boolean, maximized = false) {validate(position.x, "x")-validate(position.y, "y")-validate(size.width, "width")-validate(size.height, "height")- this.depth = depth-- this.minimized = minimized+ this.state = {+ title: readableTitle(shown.title),+ header: boolean(shown.header, "Window header state"),+ layer: shown.layer,+ position,+ size,+ depth,+ minimized: boolean(minimized, "Window minimized state"),+ maximized: boolean(maximized, "Window maximized state")+ }+ }- this.maximized = maximized+ public stop() { this.state = null }++ public get live() { return this.state !== null }+ public get position() { return this.current.position }+ public set position(value) { this.current.position = value }+ public get size() { return this.current.size }+ public set size(value) { this.current.size = value }+ public get depth() { return this.current.depth }+ public set depth(value) { this.current.depth = value }+ public get minimized() { return this.current.minimized }+ public set minimized(value) { this.current.minimized = value }+ public get maximized() { return this.current.maximized }+ public set maximized(value) { this.current.maximized = value }+ public get title() { return this.current.title }+ public set title(value) { this.current.title = value }+ public get header() { return this.current.header }+ public set header(value) { this.current.header = value }+ public get layer() { return this.current.layer }+ public set layer(value) { this.current.layer = value }++ private get current() {+ if (!this.state) throw new Error("This Client Endpoint is not running")+ return this.state}public move(position: Position) {-validate(position.x, "x")-validate(position.y, "y")-if (this.position.x === position.x && this.position.y === position.y) return false-this.position = position-return true}public resize(size: Size) {-validate(size.width, "width")-validate(size.height, "height")-if (this.size.width === size.width && this.size.height === size.height) return false-this.size = size-return true}/** Validates and commits a complete geometry without an intermediate state. */public setGeometry(geometry: WindowGeometry) {-validate(geometry.x, "x")-validate(geometry.y, "y")-validate(geometry.width, "width")-validate(geometry.height, "height")-const moved = this.position.x !== geometry.x || this.position.y !== geometry.y-const resized = this.size.width !== geometry.width || this.size.height !== geometry.height-if (!moved && !resized) return { moved, resized }-this.position = { x: geometry.x, y: geometry.y }-this.size = { width: geometry.width, height: geometry.height }-return { moved, resized }}public setTitle(title: string) {-- const said = String(title ?? "").trim()-- if (!said) throw new Error("A window's title is something a person can read")-+ const said = readableTitle(title)if (this.title === said) return false-this.title = said-return true}public setHeader(header: boolean) {-- if (typeof header !== "boolean") throw new Error("Window header state must be true or false")-- if (this.header === header) return false-- this.header = header-- return true- }-- public setSurface(surface: WindowSurface) {-- const parsed = parseWindowSurface(surface)-- if (JSON.stringify(this.surface) === JSON.stringify(parsed)) return false-- this.surface = parsed-+ const value = boolean(header, "Window header state")+ if (this.header === value) return false+ this.header = valuereturn true}- public setTransaction(transaction: WindowTransaction) {-- const parsed = parseWindowTransaction(transaction)-- if (JSON.stringify(this.transaction) === JSON.stringify(parsed)) return false-- this.transaction = parsed-- return true- }-- public toJSON() {-- return {-- title: this.title,-- header: this.header,-- surface: this.surface,-- transaction: this.transaction,-- layer: this.layer,-- position: this.position,-- size: this.size,-- depth: this.depth,+ public toJSON() { return { ...this.current } }+}- minimized: this.minimized,+function readableTitle(value: unknown) {+ const title = String(value ?? "").trim()+ if (!title) throw new Error("A window's title is something a person can read")+ return title+}- maximized: this.maximized- }- }+function boolean(value: unknown, name: string) {+ if (typeof value !== "boolean") throw new Error(`${name} must be true or false`)+ return value}-// A value is pixels or one linear relative expression; anything else is-// refused where it is written, not where it is rendered.function validate(value: Value, name: string) {-if (isRelativeValue(value)) return-throw new Error(`${name} must be a finite pixel number or a relative expression such as "50% + 10"`)}-export type WindowSnapshot = ReturnType<Window["toJSON"]>-+export interface WindowSnapshot {+ title: string+ header: boolean+ position: Position+ size: Size+ minimized: boolean+ maximized: boolean+ layer: WindowLayer+ depth: number+}export type { Position, Size, Value } from "@phreshos/core"diff --git a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts b/source/server/core/link-manager/auth-manager/program-manager/program-manager.tsindex 392857d..3a52f38 100644--- a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts+++ b/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts@@ -1585,10 +1585,6 @@ export default class ProgramManager extends TheLink {header: asked.header ?? client.header ?? defaults.header,- surface: asked.surface ?? client.surface ?? defaults.surface,-- transaction: asked.transaction ?? client.transaction ?? defaults.transaction,-position: asked.position ?? client.position ?? { x: 120 + shift, y: 80 + shift },size: asked.size ?? client.size ?? { width: 520, height: 340 },diff --git a/source/server/core/link-manager/auth-manager/program-manager/program.ts b/source/server/core/link-manager/auth-manager/program-manager/program.tsindex e06efff..218aeb8 100644--- a/source/server/core/link-manager/auth-manager/program-manager/program.ts+++ b/source/server/core/link-manager/auth-manager/program-manager/program.ts@@ -4,7 +4,7 @@ import { dirname, isAbsolute, normalize, relative, resolve, sep } from "node:patimport { spawn } from "node:child_process"import { randomUUID } from "node:crypto"import { validateIcon } from "./icon"-import { defaultProgramVersion, parseLaunch, parseProgramDefinition, parseWindowSurface, parseWindowTransaction, type ProgramCommandChunk, type ProgramDefinition, type ProgramSnapshot } from "@phreshos/core"+import { defaultProgramVersion, parseLaunch, parseProgramDefinition, type ProgramCommandChunk, type ProgramDefinition, type ProgramSnapshot } from "@phreshos/core"import { permissionCatalog, type DeclaredPermissions } from "@server/core/permissions"/**@@ -232,10 +232,6 @@ export default class Program {header: client.header ?? null,- surface: client.surface ?? null,-- transaction: client.transaction ?? null,-size: client.size ?? null,position: client.position ?? null,@@ -412,10 +408,6 @@ function coherent(config: ProgramConfig) {if (config.client?.sandbox !== undefined && typeof config.client.sandbox !== "boolean") throw new Error("A client half's sandbox mode must be true or false")- if (config.client?.surface !== undefined) parseWindowSurface(config.client.surface)-- if (config.client?.transaction !== undefined) parseWindowTransaction(config.client.transaction)-if (config.client?.maximize !== undefined && typeof config.client.maximize !== "boolean") throw new Error("A client half's maximize default must be true or false")if (config.client?.minimize !== undefined && typeof config.client.minimize !== "boolean") throw new Error("A client half's minimize default must be true or false")diff --git a/source/server/core/system.ts b/source/server/core/system.tsindex 7ddaaf7..a44b42d 100644--- a/source/server/core/system.ts+++ b/source/server/core/system.ts@@ -15,9 +15,7 @@ import type {ServerLaunch,ShellOptions,Size,- WindowSurface,- WindowGeometry,- WindowTransaction+ WindowGeometry} from "@phreshos/core"import type { Half, TrafficKind } from "./link-manager/auth-manager/process-manager/process-traffic"import { processReference, type ProcessReference } from "./link-manager/auth-manager/process-manager/endpoint-reference"@@ -372,16 +370,6 @@ export default class System {await this.processManager.setHeader(process.identity, header)}- public async setWindowSurface(process: Process, surface: WindowSurface) {-- await this.processManager.setSurface(process.identity, surface)- }-- public async setWindowTransaction(process: Process, transaction: WindowTransaction) {-- await this.processManager.setTransaction(process.identity, transaction)- }-public async raiseWindow(process: Process) {await this.processManager.raise(process.identity)@@ -406,8 +394,6 @@ export default class System {service: program.client.service,title: program.client.title ?? null,header: program.client.header ?? null,- surface: program.client.surface ?? null,- transaction: program.client.transaction ?? null,size: program.client.size ?? null,position: program.client.position ?? null,layer: program.client.layer ?? null,diff --git a/source/shared/window-layers.ts b/source/shared/window-layers.tsindex 48a94fc..33a7fd3 100644--- a/source/shared/window-layers.ts+++ b/source/shared/window-layers.ts@@ -1,112 +1,19 @@-import type { WindowLayer, WindowTransaction } from "@phreshos/core"--/** Window facts a Desktop presentation may understand for one layer role. */-export type WindowPresentationProperty =- | "title"- | "header"- | "surface"- | "position"- | "size"- | "minimized"- | "maximized"- | "front"- | "layer"--/**- * The System's explicit model for how authoritative Windows are presented.- *- * A Window retains every authoritative value. These capabilities govern only- * what the current Desktop presentation can apply, read, or emit.- */-type WindowLayerPresentation = Readonly<{- /** Facts this presentation role can report. */- readable: readonly WindowPresentationProperty[]-- /** Facts the Desktop can apply from authoritative state and emit. */- applicable: readonly WindowPresentationProperty[]- defaults: Readonly<{- surface: boolean- header: boolean- transaction: WindowTransaction- }>- fixed: boolean- transactions: boolean-}>--export const windowLayerModel: Readonly<Record<WindowLayer, WindowLayerPresentation>> = Object.freeze({- wallpaper: Object.freeze({- readable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),- applicable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),- defaults: Object.freeze({ surface: false, header: false, transaction: false }),- fixed: true,- transactions: false- }),- under: Object.freeze({- readable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- applicable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- defaults: Object.freeze({ surface: false, header: false, transaction: false }),- fixed: false,- transactions: true- }),- window: Object.freeze({- readable: Object.freeze(["title", "header", "surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- applicable: Object.freeze(["title", "header", "surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- // Standard Window motion uses the shared Appearance transaction unless- // its authoritative Window value explicitly selects another behavior.- defaults: Object.freeze({ surface: true, header: true, transaction: true }),- fixed: false,- transactions: true- }),- over: Object.freeze({- readable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- applicable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- defaults: Object.freeze({ surface: false, header: false, transaction: false }),- fixed: false,- transactions: true- }),- shell: Object.freeze({- readable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- applicable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),- defaults: Object.freeze({ surface: false, header: false, transaction: false }),- fixed: false,- transactions: true- })-})+import type { WindowLayer } from "@phreshos/core"export function windowLayerDefaults(layer: WindowLayer) {- return windowLayerModel[layer].defaults+ return Object.freeze({ header: layer === "window" })}-export function supportsWindowPresentationRead(layer: WindowLayer, property: WindowPresentationProperty) {- return windowLayerModel[layer].readable.includes(property)+export function isRawWindowPresentationLayer(layer: WindowLayer) {+ return layer === "under" || layer === "over" || layer === "shell"}-export function supportsWindowPresentationApplication(layer: WindowLayer, property: WindowPresentationProperty) {- return windowLayerModel[layer].applicable.includes(property)+export function requireRawWindowPresentation(layer: WindowLayer) {+ if (!isRawWindowPresentationLayer(layer)) throw new Error(`The ${layer} layer does not support raw presentation operations`)}-export function isWindowPresentationProperty(value: unknown): value is WindowPresentationProperty {- return presentationProperties.includes(value as WindowPresentationProperty)-}--export function requireWindowPresentationRead(layer: WindowLayer, property: WindowPresentationProperty) {- if (!supportsWindowPresentationRead(layer, property)) {- throw new Error(`The ${layer} layer has no ${property} presentation value`)- }-}--export function requireWindowPresentationApplication(layer: WindowLayer, property: WindowPresentationProperty) {- if (!supportsWindowPresentationApplication(layer, property)) {- throw new Error(`The ${layer} layer cannot apply ${property} presentation changes`)- }-}--export function requireWindowPresentationMutation(layer: WindowLayer, property: WindowPresentationProperty) {- requireWindowPresentationApplication(layer, property)-}--export function supportsWindowPresentationTransactions(layer: WindowLayer) {- return windowLayerModel[layer].transactions+export function requireWindowMoveGesture(layer: WindowLayer) {+ if (layer !== "window") throw new Error("Move gestures belong to standard Windows")}/** Window roles that own one fixed Desktop presentation at a time. */@@ -115,15 +22,3 @@ export type DesktopReplacementLayer = Extract<WindowLayer, "wallpaper">export function isDesktopReplacementLayer(layer: WindowLayer | undefined): layer is DesktopReplacementLayer {return layer === "wallpaper"}--export function isFixedWindowPresentationLayer(layer: WindowLayer) {- return windowLayerModel[layer].fixed-}--export function requireWindowPresentationTransactions(layer: WindowLayer) {- if (!supportsWindowPresentationTransactions(layer)) {- throw new Error(`The ${layer} layer does not support explicit presentation transactions`)- }-}--const presentationProperties = ["title", "header", "surface", "position", "size", "minimized", "maximized", "front", "layer"] as const satisfies readonly WindowPresentationProperty[]diff --git a/tests/client-layer-permissions.test.ts b/tests/client-layer-permissions.test.tsindex 10f836c..6933f65 100644--- a/tests/client-layer-permissions.test.ts+++ b/tests/client-layer-permissions.test.ts@@ -6,12 +6,18 @@ import SystemAccess from "@client/view/components/desktop-host/system-access"import host from "@client/view/components/desktop-host/host"import { permissionCatalog } from "@server/core/permissions"+function moveCoordinates() {+ return {+ point: (point: { x: number, y: number }) => point+ } as never+}+function fixture() {let permissions: Permissions = {}const program: ProgramSnapshot & { readonly permissions: Permissions } = {identity: "owner", reference: "program-reference", assetId: "assets", name: "Owner",version: "0.0.0", description: null, hasAgent: false, server: null,- client: { sandbox: true, start: true, service: false, title: null, header: null, surface: null, transaction: null, size: null, position: null, layer: "over", minimize: null, maximize: null },+ client: { sandbox: true, start: true, service: false, title: null, header: null, size: null, position: null, layer: "over", minimize: null, maximize: null },get permissions() { return permissions }}const process = { identity: "caller", reference: "process-reference", program: program.identity, name: null, startedAt: 0, options: {}, server: null, client: null }@@ -56,7 +62,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, () => ({ size: { width: 100, height: 100 } }), () => "frame", {} as never)+ const answer = host(auth, process.identity, () => ({ size: { width: 100, height: 100 } }), () => "frame", moveCoordinates(), {} as never)return {auth, program, process, answer, createProcess, findOrCreateProcess, startup, startEndpoint, command, connection,permissions(value: Permissions) { permissions = value }@@ -148,7 +154,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,- () => ({ size: { width: 100, height: 100 } }), {} as never, { begin: vi.fn() } as never)+ () => ({ size: { width: 100, height: 100 } }), {} 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 c2d27c9..c001691 100644--- a/tests/client-permission-boundary.test.ts+++ b/tests/client-permission-boundary.test.ts@@ -4,6 +4,12 @@ import type AuthManager from "@client/core/link-manager/auth-manager/auth-manageimport host from "@client/view/components/desktop-host/host"import { permissionCatalog } from "@server/core/permissions"+function moveCoordinates() {+ return {+ point: (point: { x: number, y: number }) => point+ } as never+}+test("Client Program creation requires all before reaching the creation boundary", async () => {let permissions: Permissions = { programs: [] }const program: ProgramSnapshot & { readonly permissions: Permissions } = {@@ -19,7 +25,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", () => { throw new Error("unused viewport") }, () => null, {} as never)+ const answer = host(auth, "caller", () => { throw new Error("unused viewport") }, () => null, moveCoordinates(), {} 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")@@ -47,7 +53,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, () => { throw new Error("unused viewport") }, () => null, {} as never)+ const answer = host(auth, current.identity, () => { throw new Error("unused viewport") }, () => null, moveCoordinates(), {} 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 })]])@@ -87,7 +93,7 @@ test("Program permission reads and requests require Program access while directgrantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions),requestPermission} as unknown as AuthManager- const answer = host(auth, current.identity, () => { throw new Error("unused viewport") }, () => null, {} as never)+ const answer = host(auth, current.identity, () => { throw new Error("unused viewport") }, () => null, moveCoordinates(), {} as never)const target = { identity: outside.identity, reference: outside.reference }await expect(answer("program-permissions", target, "get", "network")).resolves.toEqual([["https://example.com"]])@@ -149,7 +155,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", () => { throw new Error("unused viewport") }, () => "frame", {} as never)+ const answer = host(auth, "caller", () => { throw new Error("unused viewport") }, () => "frame", moveCoordinates(), {} as never)const key = { program: owningProgram, process: "main", endpoint: "server" } as constconst operations = [["service-available", key],@@ -190,7 +196,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", () => { throw new Error("unused viewport") }, () => "frame", {} as never)+ const answer = host(auth, "caller", () => { throw new Error("unused viewport") }, () => "frame", moveCoordinates(), {} as never)await expect(answer("host-service-list")).resolves.toEqual([[]])await expect(answer("host-service-search", "main")).resolves.toEqual([[]])diff --git a/tests/client-process-boundary-lifecycle.test.ts b/tests/client-process-boundary-lifecycle.test.tsindex 5404143..af1a4d8 100644--- a/tests/client-process-boundary-lifecycle.test.ts+++ b/tests/client-process-boundary-lifecycle.test.ts@@ -1,11 +1,27 @@import assert from "node:assert/strict"import messagepack from "@the-link/messagepack"-import ClientProcessBoundary from "@client/view/components/desktop-host/client-process-boundary"+import ClientProcessBoundary, { FrameMoveCoordinates, 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 { test, vi } from "vitest"+test("frame pointer positions map into the Desktop's physical viewport space", () => {+ let left = 100+ const frame = {+ clientWidth: 400,+ clientHeight: 300,+ getBoundingClientRect: () => ({ left, top: 50, width: 600, height: 450 })+ } as HTMLIFrameElement++ assert.deepEqual(frameMovePoint(frame, { x: 40, y: 20 }), { x: 160, y: 80 })++ const coordinates = new FrameMoveCoordinates(frame)+ assert.deepEqual(coordinates.point({ x: 40, y: 20 }), { x: 160, y: 80 })+ left = 240+ assert.deepEqual(coordinates.point({ x: -50, y: 30 }), { x: 165, y: 95 })+})+test("a Client question expectation survives initial iframe ownership", async () => {const sent: unknown[][] = []diff --git a/tests/client-sandbox.test.ts b/tests/client-sandbox.test.tsindex c7a0665..503b252 100644--- a/tests/client-sandbox.test.ts+++ b/tests/client-sandbox.test.ts@@ -22,18 +22,7 @@ test("client sandbox contract", async () => {{} as HostTraffic,- new Window(-- { title: "Client", header: true, surface: true, transaction: false, layer: "window" },-- { x: 0, y: 0 },-- { width: 640, height: 480 },-- 1,-- false- )+ liveWindow())sandboxed.startClient(false)@@ -48,15 +37,15 @@ test("client sandbox contract", async () => {{ server: null, client: null, options: {} },null,{} as HostTraffic,- new Window(- { title: "Client", header: true, surface: true, transaction: false, layer: "window" },- { x: 0, y: 0 },- { width: 640, height: 480 },- 1,- false- )+ liveWindow())trusted.startClient(false)assert.equal(trusted.hosted().client?.sandbox, false)}, 120_000)++function liveWindow() {+ const window = new Window()+ window.start({ title: "Client", header: true, layer: "window" }, { x: 0, y: 0 }, { width: 640, height: 480 }, 1, false)+ return window+}diff --git a/tests/desktop-replacement-lifecycle.test.ts b/tests/desktop-replacement-lifecycle.test.tsindex b41ca7b..d6cdaa4 100644--- a/tests/desktop-replacement-lifecycle.test.ts+++ b/tests/desktop-replacement-lifecycle.test.ts@@ -17,7 +17,7 @@ function fixture(replacementLayer: DesktopReplacementLayer) {vi.spyOn(program, "validate").mockResolvedValue()vi.spyOn(other, "validate").mockResolvedValue()const shape = (layer: Layer = replacementLayer) => ({- title: "Replacement", header: layer === "window", surface: false, transaction: false,+ title: "Replacement", header: layer === "window",position: { x: 20, y: 30 }, size: { width: 320, height: 240 },layer, minimize: false, maximize: false})diff --git a/tests/desktop-replacements.test.tsx b/tests/desktop-replacements.test.tsxindex 6878cf4..8848b5e 100644--- a/tests/desktop-replacements.test.tsx+++ b/tests/desktop-replacements.test.tsx@@ -118,7 +118,7 @@ test("Desktop replaces its default wallpaper with the running Client and restoreidentity: "wallpaper-process", program: "wallpaper-program",client: { window: {layer: "wallpaper", title: "Internal", position: { x: 200, y: 300 },- header: false, surface: false, transaction: false,+ header: false,size: { width: 100, height: 100 }, minimized: true, maximized: false, depth: 20} }} as unknown as Process@@ -151,7 +151,7 @@ test("Desktop replaces the complete built-in Shell and restores it after stop",identity: "shell-process", program: "shell-program",client: { window: {layer: "shell", title: "Internal", position: { x: 200, y: 300 },- header: false, surface: false, transaction: false,+ header: false,size: { width: 100, height: 100 }, minimized: true, maximized: false, depth: 20} }} as unknown as Process@@ -162,8 +162,8 @@ test("Desktop replaces the complete built-in Shell and restores it after stop",expect(running).not.toContain("data-default-start-menu")expect(running).not.toContain("data-taskbar")expect(fixture.pane.mock.lastCall?.[0]).toMatchObject({- layer: "shell", surface: false, minimized: true, maximized: false, entering: false,- position: { x: 200, y: 300 }, size: { width: 100, height: 100 }, depth: 20+ layer: "shell", surface: false, minimized: false, maximized: false, entering: false,+ position: { x: 0, y: 0 }, size: { width: 0, height: 0 }, depth: 20})record.client = nulldiff --git a/tests/panel.test.tsx b/tests/panel.test.tsxindex 5aaefe7..eb7512d 100644--- a/tests/panel.test.tsx+++ b/tests/panel.test.tsx@@ -51,10 +51,6 @@ test("panel contract", async () => {assert.match(windowPanel, /overflow:hidden/)assert.match(windowPanel, new RegExp(`border-radius:${resolveRadius("medium", defaultAppearance)}`))- const surfaceFreeWindow = markup(<Window layer="window" surface={false} icon="/icon.svg" title="Window"><iframe title="Content" /></Window>)- const surfaceFreePanel = surfaceFreeWindow.match(/<div style="([^"]*grid-template-rows:auto minmax\(0, 1fr\)[^"]*)">/)?.[1] ?? ""- assert.doesNotMatch(surfaceFreePanel, /border-radius:/)-const bare = markup(<Window layer="over" icon="/icon.svg" title="Bare"><iframe title="Content" /></Window>)assert.doesNotMatch(bare, /data-material/)assert.doesNotMatch(bare, /grid-template-rows:auto minmax\(0, 1fr\)/)diff --git a/tests/permission-requests.test.ts b/tests/permission-requests.test.tsindex 5149322..11b121f 100644--- a/tests/permission-requests.test.ts+++ b/tests/permission-requests.test.ts@@ -22,8 +22,9 @@ test("permission requests contract", async () => {let whilePending: (() => void) | undefinedlet dialogProgram: Program | null = null- const process = new Process("process", null, program, {}, { server: null, client: null, options: {} }, null, {} as HostTraffic,- new Window({ title: "Client", header: true, surface: true, transaction: false, layer: "window" }, { x: 0, y: 0 }, { width: 640, height: 480 }, 1, false))+ const window = new Window()+ window.start({ title: "Client", header: true, layer: "window" }, { x: 0, y: 0 }, { width: 640, height: 480 }, 1, false)+ const process = new Process("process", null, program, {}, { server: null, client: null, options: {} }, null, {} as HostTraffic, window)process.startClient(false)const authManager = {diff --git a/tests/process-lifecycle.test.ts b/tests/process-lifecycle.test.tsindex 40f1f81..33fcf05 100644--- a/tests/process-lifecycle.test.ts+++ b/tests/process-lifecycle.test.ts@@ -29,8 +29,6 @@ test("process lifecycle contract", async () => {return {title: launch.title ?? "Client",header: launch.header ?? true,- surface: launch.surface ?? true,- transaction: launch.transaction ?? false,position: launch.position ?? { x: 0, y: 0 },size: launch.size ?? { width: 640, height: 480 },layer: launch.layer ?? "window",@@ -62,10 +60,8 @@ test("process lifecycle contract", async () => {return manager}- // Window state belongs permanently to the Client Endpoint, not to one of- // its execution contexts. Stopping the Client preserves the Window; omitted- // restart values preserve it, while explicit launch values replace only- // themselves.+ // The handle survives a stop, but Window state does not. A new execution is+ // created from declaration defaults plus only that start's override.{const manager = processManager()const owner = new Program({@@ -76,8 +72,6 @@ test("process lifecycle contract", async () => {const initial = {title: "Initial",header: true,- surface: true,- transaction: false,position: { x: 12, y: 24 },size: { width: 640, height: 480 },layer: "window" as const,@@ -103,33 +97,25 @@ test("process lifecycle contract", async () => {assert.equal(process.client, null)assert.ok(process.clientEndpoint)- await manager.move(process.identity, { x: 80, y: 90 })- await manager.setHeader(process.identity, false)- await manager.setSurface(process.identity, { radius: "full", color: "primary" })+ await assert.rejects(manager.move(process.identity, { x: 80, y: 90 }), /not running/)+ await assert.rejects(manager.setHeader(process.identity, false), /not running/)+ assert.throws(() => process.clientEndpoint!.window.toJSON(), /not running/)await manager.startClient(process.identity)- assert.deepEqual(process.clientEndpoint.window.position, { x: 80, y: 90 })- assert.equal(process.clientEndpoint.window.header, false)- assert.deepEqual(process.clientEndpoint.window.surface, { radius: "full", color: "primary" })+ assert.deepEqual(process.clientEndpoint.window.position, { x: 0, y: 0 })+ assert.equal(process.clientEndpoint.window.header, true)++ await manager.move(process.identity, { x: 80, y: 90 })+ await manager.setHeader(process.identity, false)await manager.stopClient(process.identity)await manager.startClient(process.identity, { layer: "over", title: "Overlay" })assert.equal(process.clientEndpoint.window.layer, "over")assert.equal(process.clientEndpoint.window.title, "Overlay")- assert.deepEqual(process.clientEndpoint.window.position, { x: 80, y: 90 })- assert.equal(process.clientEndpoint.window.header, false)-- await manager.stopClient(process.identity)- await manager.setHeader(process.identity, true)- await manager.move(process.identity, { x: 140, y: 150 })- await manager.startClient(process.identity, { layer: "window" })-- assert.equal(process.clientEndpoint.window.layer, "window")+ assert.deepEqual(process.clientEndpoint.window.position, { x: 0, y: 0 })assert.equal(process.clientEndpoint.window.header, true)- assert.deepEqual(process.clientEndpoint.window.position, { x: 140, y: 150 })- assert.deepEqual(process.clientEndpoint.window.surface, { radius: "full", color: "primary" })}function program(identity: string) {@@ -165,8 +151,6 @@ test("process lifecycle contract", async () => {{title: "Client",header: true,- surface: true,- transaction: false,position: { x: 0, y: 0 },size: { width: 640, height: 480 },layer: "window",@@ -260,10 +244,10 @@ test("process lifecycle contract", async () => {null,client,{},- { ...launch, client: { title: "Partial", header: true, surface: true, transaction: false, position: null, size: null, layer: "window", minimize: false, maximize: false, service: false } },+ { ...launch, client: { title: "Partial", header: true, position: null, size: null, layer: "window", minimize: false, maximize: false, service: false } },null,true,- { title: "Partial", header: true, surface: true, transaction: false, position: { x: 0, y: 0 }, size: { width: 320, height: 240 }, layer: "window", minimize: false, maximize: false },+ { title: "Partial", header: true, position: { x: 0, y: 0 }, size: { width: 320, height: 240 }, layer: "window", minimize: false, maximize: false },null), /creation publication failed/)diff --git a/tests/window-geometry.test.ts b/tests/window-geometry.test.tsindex 2e458fc..644e273 100644--- a/tests/window-geometry.test.ts+++ b/tests/window-geometry.test.ts@@ -38,13 +38,8 @@ test("window geometry contract", async () => {size: { width: 300, height: 200 }}- const authority = new ServerWindow(- { title: "Geometry", header: true, surface: true, transaction: false, layer: "window" },- initial.position,- initial.size,- 1,- false- )+ const authority = new ServerWindow()+ authority.start({ title: "Geometry", header: true, layer: "window" }, initial.position, initial.size, 1, false)assert.throws(() => authority.setGeometry({x: 40,@@ -112,11 +107,6 @@ test("window geometry contract", async () => {assert.equal(authority.header, false)assert.deepEqual(events.at(-1), ["process", "changeHeader", false])- const transaction = { duration: 240, easing: "ease-out" } as const- await ProcessManager.prototype.setTransaction.call(manager as unknown as ProcessManager, "process", transaction)- assert.deepEqual(authority.transaction, transaction)- assert.deepEqual(events.at(-1), ["process", "changeTransaction", transaction])-const resized = { width: "1/2", height: 260 }await ProcessManager.prototype.setGeometry.call(manager as unknown as ProcessManager, "process", { ...nextPosition, ...resized })assert.deepEqual(events.at(-1), ["process", "resize", resized])@@ -142,9 +132,6 @@ test("window geometry contract", async () => {await counterpart.setGeometry(next)assert.deepEqual(publications, [["/set-geometry", "process", next]])- await counterpart.setTransaction(false)- assert.deepEqual(publications.at(-1), ["/set-transaction", "process", false])-authority.minimized = trueawait ProcessManager.prototype.maximize.call(manager as unknown as ProcessManager, "process", true)assert.equal(authority.maximized, true)diff --git a/tests/window-presentation-layers.test.ts b/tests/window-presentation-layers.test.tsindex 76c1a2d..2351fea 100644--- a/tests/window-presentation-layers.test.ts+++ b/tests/window-presentation-layers.test.ts@@ -3,110 +3,55 @@ import type { WindowLayer } from "@phreshos/core"import WindowPresentations, { type WindowPresentationEntry } from "@client/view/components/window-manager/window-presentations"function fixture(layer: WindowLayer) {- const client = (selected: WindowLayer) => ({ window: {- layer: selected,- title: "Original",- header: selected === "window",- surface: selected === "window",- transaction: false,- position: { x: 20, y: 30 },- size: { width: 320, height: 240 },- minimized: true,- maximized: false,- depth: 5- } })- const own = client(layer)- const entries = new Map([- ["own", { identity: "own:0", client: own }]- ]) as unknown as ReadonlyMap<string, WindowPresentationEntry>- const presentations = new WindowPresentations(entries, process => entries.get(process)?.client ?? null)- return { own, entries, presentations }+ const client = { window: {+ layer,+ title: "Original",+ header: layer === "window",+ position: { x: 20, y: 30 },+ size: { width: 320, height: 240 },+ minimized: true,+ 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) }}-test("wallpaper exposes only concepts understood by its presentation", async () => {- const layer = "wallpaper"- const { own, entries, presentations } = fixture(layer)-- expect(presentations.read("own", "layer")).toBe(layer)- for (const property of ["title", "position", "size", "minimized", "maximized", "header", "surface", "front"] as const) {- expect(() => presentations.read("own", property)).toThrow(new RegExp(`${layer} layer has no`))- }-- const unsupported = [- () => presentations.move("own", { x: 1, y: 2 }),- () => presentations.resize("own", { width: 1, height: 2 }),- () => presentations.setGeometry("own", { x: 1, y: 2, width: 1, height: 2 }),- () => presentations.minimize("own", true),- () => presentations.maximize("own", false),- () => presentations.setTitle("own", "Changed"),- () => presentations.setHeader("own", false),- () => presentations.setSurface("own", true),- () => presentations.raise("own")- ]- for (const operation of unsupported) expect(operation).toThrow(new RegExp(`${layer} layer cannot apply`))-- own.window.position = { x: 500, y: 600 }- own.window.title = "Changed"- presentations.reconcile(entries)- expect(presentations.projection("own").position).toEqual({ x: 0, y: 0 })- expect(presentations.projection("own").title).toBe("Original")-- await expect(presentations.follow("own")).resolves.toBeUndefined()- await expect(presentations.unfollow("own")).resolves.toBeUndefined()- expect(presentations.projection("own").title).toBe("Original")- expect(presentations.projection("own").position).toEqual({ x: 0, y: 0 })+test("wallpaper is fixed and rejects both raw operations and move gestures", () => {+ const { presentations } = fixture("wallpaper")+ expect(presentations.layer("own")).toBe("wallpaper")+ expect(presentations.projection("own")).toMatchObject({+ position: { x: 0, y: 0 }, size: { width: "100%", height: "100%" }, surface: false+ })+ expect(() => presentations.move("own", { x: 1, y: 2 })).toThrow(/does not support raw/)+ expect(() => presentations.raise("own")).toThrow(/does not support raw/)+ expect(() => presentations.beginMoveGesture("own", "gesture", { x: 0, y: 0 }, { x: 1, y: 1 })).toThrow(/standard Windows/)})-test.each(["under", "over", "shell"] as const)("%s presents geometry and surface without a header", async layer => {- const { own, entries, presentations } = fixture(layer)-- expect(() => presentations.read("own", "header")).toThrow(new RegExp(`${layer} layer has no header`))- expect(() => presentations.read("own", "title")).toThrow(new RegExp(`${layer} layer has no title`))- expect(() => presentations.setHeader("own", false)).toThrow(new RegExp(`${layer} layer cannot apply header`))- expect(() => presentations.setTitle("own", "Changed")).toThrow(new RegExp(`${layer} layer cannot apply title`))-- await presentations.setSurface("own", { color: "primary", radius: "full" })- expect(presentations.read("own", "surface")).toEqual({ color: "primary", radius: "full" })-- await presentations.follow("own")- own.window.position = { x: 100, y: 200 }- own.window.surface = true- presentations.reconcile(entries)- expect(presentations.projection("own").position).toEqual({ x: 100, y: 200 })- expect(presentations.projection("own").surface).toBe(true)-- await presentations.unfollow("own")- own.window.position = { x: 900, y: 900 }- presentations.reconcile(entries)- expect(presentations.projection("own").position).toEqual({ x: 100, y: 200 })-})--test("a standard presentation can leave authoritative following and take local control", async () => {- const { presentations } = fixture("window")-- expect(presentations.read("own", "surface")).toBe(true)- await presentations.unfollow("own")- await presentations.setGeometry("own", { x: 1, y: 2, width: 300, height: 200 })- presentations.setTitle("own", "Changed")- presentations.setHeader("own", false)- await presentations.setSurface("own", false)- expect(presentations.state("own")).toMatchObject({- title: "Changed", header: false, surface: false,- position: { x: 1, y: 2 }, size: { width: 300, height: 200 }- })- await expect(presentations.follow("own")).resolves.toBeUndefined()- await expect(presentations.unfollow("own")).resolves.toBeUndefined()+test.each(["under", "over", "shell"] as const)("%s is controlled only through raw presentation operations", async layer => {+ const { client, entries, presentations } = fixture(layer)+ expect(presentations.layer("own")).toBe(layer)+ expect(presentations.projection("own")).toMatchObject({+ position: { x: 0, y: 0 }, size: { width: 0, height: 0 }, surface: false, header: false+ })+ await presentations.setGeometry("own", { x: 10, y: 20, width: 400, height: 300 })+ await presentations.setSurface("own", true)+ expect(presentations.projection("own")).toMatchObject({+ position: { x: 10, y: 20 }, size: { width: 400, height: 300 }, surface: true+ })++ client.window.position = { x: 800, y: 900 }+ client.window.size = { width: 900, height: 700 }+ entries.get("own")!.client = client as never+ presentations.reconcile(entries)+ expect(presentations.projection("own").position).toEqual({ x: 10, y: 20 })+ expect(() => presentations.beginMoveGesture("own", "gesture", { x: 0, y: 0 }, { x: 1, y: 1 })).toThrow(/standard Windows/)})-test("unsupported presentation events remain silent", async () => {- const { own, entries, presentations } = fixture("wallpaper")- const received: string[] = []- presentations.observe("own", null, event => received.push(event))-- own.window.position = { x: 500, y: 600 }- own.window.title = "Changed"- await expect(presentations.follow("own")).resolves.toBeUndefined()- presentations.reconcile(entries)-- expect(received).toEqual([])+test("standard Window presentation is exclusively Desktop-controlled", () => {+ const { presentations } = fixture("window")+ expect(presentations.layer("own")).toBe("window")+ expect(() => presentations.resize("own", { width: 1, height: 2 })).toThrow(/does not support raw/)+ expect(() => presentations.setSurface("own", false)).toThrow(/does not support raw/)+ expect(() => presentations.raise("own")).toThrow(/does not support raw/)})diff --git a/tests/window-presentation.test.ts b/tests/window-presentation.test.tsindex af8fb92..2f9db42 100644--- a/tests/window-presentation.test.ts+++ b/tests/window-presentation.test.ts@@ -2,199 +2,130 @@ 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 { requireWindowPresentationTransactions, windowLayerDefaults } from "@shared/window-layers"-import type { WindowLayer, WindowTransaction } from "@phreshos/core"+import type { WindowLayer } from "@phreshos/core"import { test } from "vitest"-test("Window presentation transactions remain independent from Appearance limits", () => {- assert.deepEqual(presentationTransaction(true, false), { transaction: true, wait: false })- assert.deepEqual(presentationTransaction(false, true), { transaction: false, wait: true })- assert.deepEqual(presentationTransaction(120_000, true), { transaction: 120_000, wait: true })- assert.deepEqual(presentationTransaction({ duration: 120_000, easing: "ease-out" }, false), {- transaction: { duration: 120_000, easing: "ease-out" }, wait: false+test("presentation transaction selection has no boolean compatibility values", () => {+ assert.deepEqual(presentationTransaction({ wait: false }), { wait: false })+ assert.deepEqual(presentationTransaction({ transaction: 120_000, wait: true }), { transaction: 120_000, wait: true })+ assert.deepEqual(presentationTransaction({ transaction: { duration: 240, easing: "ease-out" }, wait: false }), {+ transaction: { duration: 240, easing: "ease-out" }, wait: false})- assert.throws(() => presentationTransaction(-1, false), /non-negative/)- assert.throws(() => presentationTransaction(true, "yes"), /true or false/)- assert.doesNotThrow(() => requireWindowPresentationTransactions("under"))- assert.doesNotThrow(() => requireWindowPresentationTransactions("over"))- assert.doesNotThrow(() => requireWindowPresentationTransactions("window"))- assert.doesNotThrow(() => requireWindowPresentationTransactions("shell"))- assert.throws(() => requireWindowPresentationTransactions("wallpaper"), /does not support/)+ assert.throws(() => presentationTransaction({ transaction: true, wait: false }), /must be an object/)+ assert.throws(() => presentationTransaction({ wait: "yes" }), /true or false/)})-test("each Desktop owns an independent Window presentation", async () => {- const ordinary = client("window")+test("each Desktop owns an independent raw presentation initialized at zero", async () => {const overlay = client("over")- const entries = new Map([- ["ordinary", { identity: "ordinary:0", client: ordinary }],- ["overlay", { identity: "overlay:0", client: overlay }]- ]) as unknown as ReadonlyMap<string, WindowPresentationEntry>- const byProcess = new Map([["ordinary", ordinary], ["overlay", overlay]])- const first = new WindowPresentations(entries, identity => byProcess.get(identity) as never ?? null)- const second = new WindowPresentations(entries, identity => byProcess.get(identity) as never ?? null)-- await first.unfollow("ordinary")- await first.move("ordinary", { x: 40, y: 50 })- await first.move("overlay", { x: 60, y: 70 })-- assert.deepEqual(first.state("ordinary").position, { x: 40, y: 50 })- assert.deepEqual(first.state("overlay").position, { x: 60, y: 70 })- assert.deepEqual(second.state("ordinary").position, { x: 0, y: 0 })- assert.deepEqual(ordinary.window.position, { x: 0, y: 0 })-- ordinary.window.position = { x: 15, y: 25 }- overlay.window.position = { x: 20, y: 30 }- first.reconcile(entries)+ const entries = entry("overlay", overlay)+ const first = new WindowPresentations(entries, () => overlay as never)+ const second = new WindowPresentations(entries, () => overlay as never)- assert.deepEqual(first.state("ordinary").position, { x: 40, y: 50 })- assert.deepEqual(first.state("overlay").position, { x: 60, y: 70 })+ assert.deepEqual(first.projection("overlay").position, { x: 0, y: 0 })+ assert.deepEqual(first.projection("overlay").size, { width: 0, height: 0 })+ assert.equal(first.projection("overlay").surface, false)- await first.follow("overlay")- assert.deepEqual(first.state("overlay").position, { x: 20, y: 30 })- overlay.window.position = { x: 80, y: 90 }- first.reconcile(entries)- assert.deepEqual(first.state("overlay").position, { x: 80, y: 90 })+ await first.setGeometry("overlay", { x: 40, y: 50, width: 600, height: 400 })+ await first.setSurface("overlay", { color: "primary", radius: "full" })+ assert.deepEqual(first.projection("overlay").position, { x: 40, y: 50 })+ assert.deepEqual(second.projection("overlay").position, { x: 0, y: 0 })++ await first.setSurface("overlay", false)+ assert.equal(first.projection("overlay").surface, false)- await first.unfollow("overlay")- overlay.window.position = { x: 100, y: 110 }+ overlay.window.position = { x: 900, y: 900 }first.reconcile(entries)- assert.deepEqual(first.state("overlay").position, { x: 80, y: 90 })+ assert.deepEqual(first.projection("overlay").position, { x: 40, y: 50 })})-test("transactionAndWait semantics resolve on completion and reject on interruption", async () => {+test("transactionAndWait resolves only after the matching local animation", async () => {const overlay = client("over")- const entries = new Map([- ["overlay", { identity: "overlay:0", client: overlay }]- ]) as unknown as ReadonlyMap<string, WindowPresentationEntry>- const presentations = new WindowPresentations(entries, () => overlay as never)+ const presentations = new WindowPresentations(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)- const revision = presentations.projection("overlay").geometryAnimation?.revision- assert.equal(typeof revision, "number")- presentations.complete("overlay", "geometry", revision!)+ const animation = presentations.projection("overlay").geometryAnimation+ assert.deepEqual(animation?.transaction, request.transaction)+ presentations.complete("overlay", "geometry", animation!.revision)await movingconst interrupted = presentations.move("overlay", { x: 50, y: 60 }, request)- await presentations.move("overlay", { x: 70, y: 80 })+ await presentations.move("overlay", { x: 70, y: 80 }, { wait: false })await assert.rejects(interrupted, /interrupted/)- const changingSurface = presentations.setSurface("overlay", { color: "primary", radius: "full" }, request)- const surfaceRevision = presentations.projection("overlay").surfaceAnimation?.revision- presentations.complete("overlay", "surface", surfaceRevision!)- await changingSurface- assert.deepEqual(presentations.state("overlay").surface, { color: "primary", radius: "full" })-})--test("transaction-capable presentations use the authoritative Window transaction by default", async () => {- const overlay = client("over")- overlay.window.transaction = { duration: 240, easing: "ease-out" }- const entries = new Map([- ["overlay", { identity: "overlay:0", client: overlay }]- ]) as unknown as ReadonlyMap<string, WindowPresentationEntry>- const presentations = new WindowPresentations(entries, () => overlay as never)-- const first = presentations.move("overlay", { x: 20, y: 30 })- const firstAnimation = presentations.projection("overlay").geometryAnimation- assert.deepEqual(firstAnimation?.transaction, overlay.window.transaction)- presentations.complete("overlay", "geometry", firstAnimation!.revision)- await first-- overlay.window.transaction = false- presentations.reconcile(entries)- await presentations.move("overlay", { x: 40, y: 50 })- assert.equal(presentations.projection("overlay").geometryAnimation, null)-- overlay.window.transaction = { duration: 180, easing: "linear" }- presentations.reconcile(entries)- const inherited = presentations.move("overlay", { x: 60, y: 70 }, { transaction: true, wait: true })- const inheritedAnimation = presentations.projection("overlay").geometryAnimation- assert.deepEqual(inheritedAnimation?.transaction, overlay.window.transaction)- presentations.complete("overlay", "geometry", inheritedAnimation!.revision)- await inherited+ const usingAppearance = presentations.setSurface("overlay", true, { wait: true })+ const surface = presentations.projection("overlay").surfaceAnimation+ assert.equal(surface?.transaction, undefined)+ presentations.complete("overlay", "surface", surface!.revision)+ await usingAppearance})-test("standard Window presentation uses its authoritative default transaction", async () => {+test("a standard Window follows authoritative state but accepts only move gestures", async () => {const ordinary = client("window")- ordinary.window.transaction = { duration: 160, easing: "ease-out" }- const entries = new Map([- ["ordinary", { identity: "ordinary:0", client: ordinary }]- ]) as unknown as ReadonlyMap<string, WindowPresentationEntry>+ const entries = entry("ordinary", ordinary)const presentations = new WindowPresentations(entries, () => ordinary as never)ordinary.window.position = { x: 80, y: 90 }+ ordinary.window.size = { width: 500, height: 350 }presentations.reconcile(entries)- assert.deepEqual(presentations.projection("ordinary").geometryAnimation?.transaction, ordinary.window.transaction)-})--test("standard Windows default to the shared Appearance transaction", () => {- assert.equal(windowLayerDefaults("window").transaction, true)- assert.equal(windowLayerDefaults("under").transaction, false)- assert.equal(windowLayerDefaults("over").transaction, false)- assert.equal(windowLayerDefaults("shell").transaction, false)-})--test("presentation state and events do not expose renderer measurements", () => {- const ordinary = client("window")- const entries = new Map([- ["ordinary", { identity: "ordinary:0", client: ordinary }]- ]) as unknown as ReadonlyMap<string, WindowPresentationEntry>- const presentations = new WindowPresentations(entries, () => ordinary as never)- const moves: unknown[] = []-- presentations.observe("ordinary", "move", (_event, value) => moves.push(value))- presentations.represent("ordinary", {- read: () => ({ x: 0, y: 0, width: 1200, height: 800 }),- present() {},- begin: () => null,- finish() {},- cancel() {}+ assert.deepEqual(presentations.projection("ordinary").position, ordinary.window.position)+ assert.throws(() => presentations.move("ordinary", { x: 1, y: 2 }), /does not support raw/)+ assert.throws(() => presentations.setSurface("ordinary", false), /does not support raw/)++ const events: unknown[] = []+ let ready!: () => void+ let finish!: () => void+ presentations.registerMoveGesture("ordinary", {+ begin(origin, point) {+ events.push([origin, point])+ return {+ ready: new Promise<void>(resolve => { ready = resolve }),+ finished: new Promise<void>(resolve => { finish = resolve }),+ cancel() { events.push("gesture-cancel") }+ }+ },+ cancel() { events.push("cancel") }})-- // A maximized renderer may occupy the viewport, but those measurements are- // not presentation values and cannot overwrite the retained geometry.- ordinary.window.maximized = true- presentations.reconcile(entries)- assert.deepEqual(presentations.state("ordinary").position, { x: 0, y: 0 })- assert.deepEqual(presentations.state("ordinary").size, { width: 300, height: 200 })- assert.deepEqual(moves, [])-- ordinary.window.position = { x: 20, y: 30 }- presentations.reconcile(entries)- assert.deepEqual(moves, [{ x: 20, y: 30 }])+ const beginning = presentations.beginMoveGesture("ordinary", "gesture", { x: 10, y: 20 }, { x: 30, y: 40 })+ assert.deepEqual(events, [[{ x: 10, y: 20 }, { x: 30, y: 40 }]])+ ready()+ await beginning+ const moving = presentations.waitMoveGesture("ordinary", "gesture")+ finish()+ await moving})-test("a Client boundary begins each document from authoritative presentation state without resetting on release", async () => {+test("a Client boundary initializes each new document exactly once", async () => {const lifecycle: string[] = []const boundary = new ClientProcessBoundary(- "requester",- { contentWindow: null } as unknown as HTMLIFrameElement,- { processManager: { async ownFrame() {}, async releaseFrame() {} } } as never,- () => ({ size: { width: 1, height: 1 } }),- {} as never,- { begin(identity: string) { lifecycle.push(identity) } } as never+ "requester",+ { contentWindow: null } as unknown as HTMLIFrameElement,+ { processManager: { async ownFrame() {}, async releaseFrame() {} } } as never,+ () => ({ size: { width: 1, height: 1 } }),+ {} as never,+ { begin(identity: string) { lifecycle.push(identity) }, cancelMoveGestures() {} } as never)-await boundary.own("first-owner")await boundary.own("second-owner")await boundary.release()-assert.deepEqual(lifecycle, ["requester", "requester"])})+function entry(process: string, selected: ReturnType<typeof client>) {+ return new Map([[process, { identity: `${process}:0`, client: selected }]]) as unknown as ReadonlyMap<string, WindowPresentationEntry>+}+function client(layer: WindowLayer) {return {- window: {- title: "Window",- header: layer === "window",- surface: layer === "window",- transaction: false as WindowTransaction,- position: { x: 0, y: 0 },- size: { width: 300, height: 200 },- minimized: false,- maximized: false,- layer,- depth: 1- }+ window: {+ title: "Window",+ header: layer === "window",+ position: { x: 10, y: 20 },+ size: { width: 300, height: 200 },+ minimized: false,+ maximized: false,+ layer,+ depth: 1+ }}}