An open-source, self-hosted system for apps built with web technologies.
Desktop answers each Client's drawing and tells its changes; raw layers take move gestures; writes in pixels
zohayrslileh4905ee822ae8
diff --git a/source/client/view/components/desktop-host/client-process-boundary.ts b/source/client/view/components/desktop-host/client-process-boundary.tsindex bcf3b73..6943eab 100644--- a/source/client/view/components/desktop-host/client-process-boundary.ts+++ b/source/client/view/components/desktop-host/client-process-boundary.ts@@ -5,7 +5,7 @@ import ClientTraffic from "./client-traffic"import { failed, succeeded } from "@libs/request-outcome"import { type TrafficKind } from "@server/core/link-manager/auth-manager/process-manager/process-traffic"import { isServiceAddress, parseProgramInstallOptions, type ServiceAddress, type ShellOptions, type WindowMovePoint } from "@phreshos/core"-import { type PresentationMoveCoordinates, type PresentationMovePoint, type WindowPresentationHost } from "./window-presentation"+import { type PresentationFrame, 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 moveCoordinates: PresentationMoveCoordinates+ private readonly frame: PresentationFrameprivate readonly systemAccess: SystemAccess@@ -55,6 +55,10 @@ export default class ClientProcessBoundary extends TheLink {private stopAppearance: (() => void) | null = null+ private readonly presentationSubscriptions = new Set<string>()++ private stopPresentation: (() => void) | null = null+private readonly trafficDeliveries = new WeakSet<object>()// A document can begin executing before its iframe load event gives the@@ -89,7 +93,7 @@ export default class ClientProcessBoundary extends TheLink {this.presentation = presentation- this.moveCoordinates = new FrameMoveCoordinates(element)+ this.frame = new ClientFrame(element)this.systemAccess = new SystemAccess(authManager, pane)@@ -308,7 +312,7 @@ export default class ClientProcessBoundary extends TheLink {this.pane,this.viewport,() => this.owner,- this.moveCoordinates,+ this.frame,this.presentation)(word, ...args)@@ -550,6 +554,13 @@ export default class ClientProcessBoundary extends TheLink {}+ if (presentationSubscription(description)) {++ this.presentationSubscriptions.add(subscription)++ if (!this.stopPresentation) this.stopPresentation = this.followDrawing()+ }+if (kind === "ask") this.releaseWaiting(route, event)return@@ -964,6 +975,13 @@ export default class ClientProcessBoundary extends TheLink {this.stopAppearance = null}+ if (this.presentationSubscriptions.delete(subscription) && this.presentationSubscriptions.size === 0) {++ this.stopPresentation?.()++ this.stopPresentation = null+ }+const key = JSON.stringify([existing.kind, existing.route, existing.event])const traffic = this.trafficSubscriptions.get(key)@@ -1038,6 +1056,73 @@ export default class ClientProcessBoundary extends TheLink {this.pending.splice(0, this.pending.length, ...remaining)}+ /**+ * Tells the Client each change in how it is drawn: whatever this Desktop draws changes, or the+ * frame or the Desktop changes size. A change is told once the drawing has arrived, not along+ * the motion that carries it there.+ */+ private followDrawing() {++ const read = () => {+ try { return this.presentation.drawing(this.pane, this.element) }+ catch { return null }+ }++ let told = read()++ let scheduled = 0++ const check = () => {++ if (scheduled) return++ // The layout of the change is read after it is drawn.+ scheduled = requestAnimationFrame(() => {++ scheduled = 0++ const drawing = read()++ if (!drawing || !this.presentation.settled(this.pane)) return++ const before = told++ told = drawing++ if (!before) return++ if (drawing.position.x !== before.position.x || drawing.position.y !== before.position.y) this.deliver("host-presentation", "move", drawing.position).catch(() => undefined)++ if (drawing.size.width !== before.size.width || drawing.size.height !== before.size.height) this.deliver("host-presentation", "resize", drawing.size).catch(() => undefined)++ if (drawing.front !== before.front) this.deliver("host-presentation", "front", drawing.front).catch(() => undefined)++ if (drawing.interactive !== before.interactive) this.deliver("host-presentation", "changeInteractive", drawing.interactive).catch(() => undefined)++ if (JSON.stringify(drawing.surface) !== JSON.stringify(before.surface)) this.deliver("host-presentation", "changeSurface", drawing.surface).catch(() => undefined)+ })+ }++ const stopObserving = this.presentation.observe(check)++ const resizing = new ResizeObserver(check)++ resizing.observe(this.element)++ const desktop = this.element.closest("[data-desktop-layers]")++ if (desktop) resizing.observe(desktop)++ return () => {++ stopObserving()++ resizing.disconnect()++ cancelAnimationFrame(scheduled)+ }+ }+private resetEndpoint() {for (const stop of this.requests.values()) stop()@@ -1067,6 +1152,12 @@ export default class ClientProcessBoundary extends TheLink {this.stopAppearance = null+ this.presentationSubscriptions.clear()++ this.stopPresentation?.()++ this.stopPresentation = null+for (const { stop } of this.trafficSubscriptions.values()) stop()this.trafficSubscriptions.clear()@@ -1091,11 +1182,11 @@ export function frameMovePoint(frame: HTMLIFrameElement, point: PresentationMovereturn { x: bounds.left + point.x * scaleX, y: bounds.top + point.y * scaleY }}-export class FrameMoveCoordinates implements PresentationMoveCoordinates {- public constructor(private readonly frame: HTMLIFrameElement) {}+export class ClientFrame implements PresentationFrame {+ public constructor(public readonly element: HTMLIFrameElement) {}public point(point: WindowMovePoint) {- return frameMovePoint(this.frame, point)+ return frameMovePoint(this.element, point)}}@@ -1221,9 +1312,14 @@ 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 === "host-presentation"+}+function desktopOwnedSubscription(subscription: EndpointSubscription) {- return desktopPreferencesSubscription(subscription) || appearanceSubscription(subscription)+ return desktopPreferencesSubscription(subscription) || appearanceSubscription(subscription) || presentationSubscription(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 1795521..126801e 100644--- a/source/client/view/components/desktop-host/host.ts+++ b/source/client/view/components/desktop-host/host.ts@@ -30,7 +30,7 @@ import {presentationPosition,presentationSize,presentationTransaction,- type PresentationMoveCoordinates,+ type PresentationFrame,type WindowPresentationHost} from "./window-presentation"import SystemAccess from "./system-access"@@ -51,7 +51,7 @@ export interface DesktopViewportHost {move(offset: DesktopOffset): void}-export default function host(authManager: AuthManager, pane: string, viewport: DesktopViewportHost, frameOwner: () => string | null, moveCoordinates: PresentationMoveCoordinates, presentation: WindowPresentationHost) {+export default function host(authManager: AuthManager, pane: string, viewport: DesktopViewportHost, frameOwner: () => string | null, frame: PresentationFrame, presentation: WindowPresentationHost) {const { processManager, programManager } = authManager@@ -904,9 +904,9 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dreturn [pane]}- if (word === "windowPresentationLayer") {+ if (word === "windowPresentation") {const target = presentationProcess(args[0])- return [presentation.layer(target.identity)]+ return [presentation.drawing(target.identity, frame.element)]}if (word === "windowPresentationMoveGestureBegin") {@@ -916,8 +916,8 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dawait presentation.beginMoveGesture(target.identity,gesture,- moveCoordinates.point(start.origin),- moveCoordinates.point(start.point)+ frame.point(start.origin),+ frame.point(start.point))return []}diff --git a/source/client/view/components/desktop-host/window-presentation.ts b/source/client/view/components/desktop-host/window-presentation.tsindex 0fedd97..b9ec607 100644--- a/source/client/view/components/desktop-host/window-presentation.ts+++ b/source/client/view/components/desktop-host/window-presentation.ts@@ -1,13 +1,12 @@import {- isRelativeValue,parseWindowPresentationSurface,parseWindowPresentationTransaction,- type Position,- type Size,- type WindowGeometry,type WindowLayer,type WindowMoveGestureStart,type WindowMovePoint,+ type WindowPresentationGeometry,+ type WindowPresentationPosition,+ type WindowPresentationSize,type WindowPresentationSurface,type WindowPresentationTransaction} from "@phreshos/core"@@ -24,7 +23,11 @@ export type PresentationTransactionRequest = Readonly<{export type PresentationMovePoint = Readonly<{ x: number, y: number }>-export interface PresentationMoveCoordinates {+/** The frame one Client document is drawn in, as the Desktop sees it. */+export interface PresentationFrame {+ readonly element: HTMLIFrameElement++ /** Where a point of the Client document is in the Desktop's viewport. */point(point: WindowMovePoint): PresentationMovePoint}@@ -39,17 +42,29 @@ export interface PresentationMoveGesture {cancel(): void}+/** How one Client is actually drawn on this Desktop, as its presentation reads it. */+export type WindowPresentationDrawing = Readonly<{+ layer: WindowLayer+ position: WindowPresentationPosition+ size: WindowPresentationSize+ front: boolean+ interactive: boolean+ surface: WindowPresentationSurface+}>+/** Local commands available to the current Client representation. */export interface WindowPresentationHost {begin(identity: string): void- layer(identity: string): WindowLayer+ drawing(identity: string, frame: HTMLIFrameElement): WindowPresentationDrawing+ settled(identity: string): boolean+ observe(listener: () => void): () => voidbeginMoveGesture(identity: string, gesture: string, origin: PresentationMovePoint, point: PresentationMovePoint): Promise<void>waitMoveGesture(identity: string, gesture: string): Promise<void>cancelMoveGesture(identity: string, gesture: string): voidcancelMoveGestures(identity: string): void- move(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>+ move(identity: string, position: WindowPresentationPosition, transaction?: PresentationTransactionRequest): Promise<void>+ resize(identity: string, size: WindowPresentationSize, transaction?: PresentationTransactionRequest): Promise<void>+ setGeometry(identity: string, geometry: WindowPresentationGeometry, transaction?: PresentationTransactionRequest): Promise<void>setSurface(identity: string, surface: WindowPresentationSurface, transaction?: PresentationTransactionRequest): Promise<void>setInteractive(identity: string, interactive: boolean): voidraise(identity: string): void@@ -68,27 +83,20 @@ export function presentationMoveGestureStart(value: unknown): WindowMoveGestureSreturn Object.freeze({ origin: presentationMovePoint(record.origin), point: presentationMovePoint(record.point) })}-export function presentationPosition(value: unknown): Position {+/** The drawing is written in pixels; shares belong to the Window, which every Desktop resolves itself. */+export function presentationPosition(value: unknown): WindowPresentationPosition {const record = plain(value, "Window presentation position")- valueTerm(record.x, "x")- valueTerm(record.y, "y")- return Object.freeze({ x: record.x, y: record.y }) as Position+ return Object.freeze({ x: pixels(record.x, "x"), y: pixels(record.y, "y") })}-export function presentationSize(value: unknown): Size {+export function presentationSize(value: unknown): WindowPresentationSize {const record = plain(value, "Window presentation size")- valueTerm(record.width, "width")- valueTerm(record.height, "height")- return Object.freeze({ width: record.width, height: record.height }) as Size+ return Object.freeze({ width: pixels(record.width, "width"), height: pixels(record.height, "height") })}-export function presentationGeometry(value: unknown): WindowGeometry {+export function presentationGeometry(value: unknown): WindowPresentationGeometry {const record = plain(value, "Window presentation geometry")- valueTerm(record.x, "x")- valueTerm(record.y, "y")- valueTerm(record.width, "width")- valueTerm(record.height, "height")- return Object.freeze({ x: record.x, y: record.y, width: record.width, height: record.height }) as WindowGeometry+ return Object.freeze({ x: pixels(record.x, "x"), y: pixels(record.y, "y"), width: pixels(record.width, "width"), height: pixels(record.height, "height") })}export function presentationSurface(value: unknown) {@@ -105,8 +113,9 @@ export function presentationTransaction(value: unknown): PresentationTransaction})}-function valueTerm(value: unknown, name: string) {- if (!isRelativeValue(value)) throw new Error(`Window presentation ${name} must be a finite number or relative value`)+function pixels(value: unknown, name: string) {+ if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`Window presentation ${name} must be a finite number of pixels`)+ return value}function plain(value: unknown, name: string): Record<string, unknown> {diff --git a/source/client/view/components/window-manager/window-presentations.ts b/source/client/view/components/window-manager/window-presentations.tsindex 1b4e215..6a53580 100644--- a/source/client/view/components/window-manager/window-presentations.ts+++ b/source/client/view/components/window-manager/window-presentations.ts@@ -4,6 +4,9 @@ import type {Size,WindowGeometry,WindowLayer,+ WindowPresentationGeometry,+ WindowPresentationPosition,+ WindowPresentationSize,WindowPresentationSurface} from "@phreshos/core"import type {@@ -11,9 +14,10 @@ import type {PresentationMoveGestureController,PresentationMovePoint,PresentationTransactionRequest,+ WindowPresentationDrawing,WindowPresentationHost} from "../desktop-host/window-presentation"-import type { WindowRegion } from "./window-geometry"+import { resolveWindowGeometry, type WindowRegion } from "./window-geometry"import { requireRawWindowPresentation, requireWindowMoveGesture } from "@shared/window-layers"export interface WindowPresentationEntry {@@ -59,6 +63,7 @@ export default class WindowPresentations implements WindowPresentationHost {private readonly moveGestureControllers = new Map<string, PresentationMoveGestureController>()private readonly moveGestures = new Map<string, ActiveMoveGesture>()private readonly anticipated = new Map<string, { change: AnticipatedWindow, pending: number }>()+ private readonly observers = new Set<() => void>()private fronts = 0private revision = 0private changed: (windows: ReadonlyMap<string, PresentedWindow>) => void = () => undefined@@ -126,10 +131,42 @@ export default class WindowPresentations implements WindowPresentationHost {})}- public layer(process: string) { return this.existing(process).state.layer }-public projection(process: string) { return this.existing(process).state }+ /** Hears every change to what this Desktop draws, so a Client can learn how its own drawing changed. */+ public observe(listener: () => void) {+ this.observers.add(listener)+ return () => { this.observers.delete(listener) }+ }++ /** Whether a Client's drawing has arrived where it is going, with no motion still carrying it. */+ public settled(process: string) {+ const { state } = this.existing(process)+ return !state.geometryAnimation && !state.surfaceAnimation && !state.minimizeAnimation+ }++ /**+ * How a Client is actually drawn: its frame, in pixels, counted from the center of the Desktop.+ * The Window's box is read where the Desktop draws it, and the frame's place inside the box from+ * the layout, so a scale the box is entering with does not change what is read.+ */+ public drawing(process: string, frame: HTMLIFrameElement): WindowPresentationDrawing {+ const { identity, state } = this.existing(process)+ const surface = frame.closest<HTMLElement>("[data-desktop-layers]")+ const width = surface?.offsetWidth ?? 0+ const height = surface?.offsetHeight ?? 0+ const box = this.representations.get(identity)?.read() ?? resolveWindowGeometry(state.position, state.size, { width, height })+ const inside = offsetWithin(frame, "[data-window-box]")+ return {+ layer: state.layer,+ position: { x: box.x + inside.x - width / 2, y: box.y + inside.y - height / 2 },+ size: { width: frame.offsetWidth, height: frame.offsetHeight },+ front: frontmost(this.windows, state.layer) === identity,+ interactive: state.interactive,+ surface: state.surface+ }+ }+public readonly represent = (process: string, representation: PresentationGeometryRepresentation | null) => {const identity = this.live.get(process)if (!identity) return@@ -212,17 +249,17 @@ export default class WindowPresentations implements WindowPresentationHost {if (identity) this.representations.get(identity)?.cancel()}- public move(process: string, position: Position, transaction?: PresentationTransactionRequest) {+ public move(process: string, position: WindowPresentationPosition, transaction?: PresentationTransactionRequest) {const { identity, state } = this.raw(process)return this.changeGeometry(identity, { ...position, ...state.size }, transaction)}- public resize(process: string, size: Size, transaction?: PresentationTransactionRequest) {+ public resize(process: string, size: WindowPresentationSize, transaction?: PresentationTransactionRequest) {const { identity, state } = this.raw(process)return this.changeGeometry(identity, { ...state.position, ...size }, transaction)}- public setGeometry(process: string, geometry: WindowGeometry, transaction?: PresentationTransactionRequest) {+ public setGeometry(process: string, geometry: WindowPresentationGeometry, transaction?: PresentationTransactionRequest) {const { identity } = this.raw(process)return this.changeGeometry(identity, geometry, transaction)}@@ -344,6 +381,7 @@ export default class WindowPresentations implements WindowPresentationHost {private publish(next: ReadonlyMap<string, PresentedWindow>) {this.windows = nextthis.changed(next)+ for (const observer of this.observers) observer()}private cancel(identity: string, kind: AnimationKind, reason = "The Window presentation transaction was interrupted") {@@ -488,6 +526,17 @@ export interface PresentationGeometryRepresentation {cancel: () => void}+/** Where an element sits inside the nearest ancestor matching a selector, by layout alone. */+function offsetWithin(element: HTMLElement, boundary: string) {+ let x = 0+ let y = 0+ for (let current: HTMLElement | null = element; current && !current.matches(boundary); current = current.offsetParent as HTMLElement | null) {+ x += current.offsetLeft+ y += current.offsetTop+ }+ return { x, y }+}+function frontmost(windows: ReadonlyMap<string, PresentedWindow>, layer: WindowLayer) {let best: [string, PresentedWindow] | null = nullfor (const candidate of windows) {diff --git a/source/client/view/structure/desktop/desktop.tsx b/source/client/view/structure/desktop/desktop.tsxindex dcd92b6..ea812dc 100644--- a/source/client/view/structure/desktop/desktop.tsx+++ b/source/client/view/structure/desktop/desktop.tsx@@ -117,11 +117,14 @@ export default function Workspace() {const move = useCallback(function (record: Process, x: number, y: number) {+ // A raw drawing moved by hand stays this Desktop's drawing; only a standard Window's place is the System's.+ if (windows.presentation.projection(record.identity).layer !== "window") return windows.presentation.move(record.identity, { x, y }).then(() => true)+const recorded = shiftPosition({ x, y }, back)return windows.move(record, recorded.x, recorded.y)- }, [windows.move, back.x, back.y])+ }, [windows.move, windows.presentation, back.x, back.y])const resize = useCallback((record: Process, width: number, height: number, position: { x: number, y: number } | null) => windows.resize(record, width, height, position && shiftPosition(position, back)), [windows.resize, back.x, back.y])diff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsxindex 39fe73d..33c35ad 100644--- a/source/client/view/structure/desktop/windows/window.tsx+++ b/source/client/view/structure/desktop/windows/window.tsx@@ -170,7 +170,8 @@ export default function ({ title, header = true, surface, layer, icon, children,}useLayoutEffect(function () {- if (!standard || !onPresentationMoveGesture) return+ // Every drawing but the wallpaper can hand a move to the Desktop.+ if (layer === "wallpaper" || !onPresentationMoveGesture) return// Program-owned chrome supplies pointer intent, while this controller// remains the single owner of geometry, snapping, and commit behavior.onPresentationMoveGesture(moveGestureController.current)@@ -178,7 +179,7 @@ export default function ({ title, header = true, surface, layer, icon, children,moveGestureController.current?.cancel()onPresentationMoveGesture(null)}- }, [standard, onPresentationMoveGesture])+ }, [layer, onPresentationMoveGesture])useEffect(function () {if (!externalMoveActive) return@@ -458,7 +459,8 @@ export default function ({ title, header = true, surface, layer, icon, children,current = { ...origin, x: origin.x + dx, y: origin.y + dy }- zone = moved ? snapTerm(motion) : null+ // Only the Desktop's own Windows snap; a raw drawing goes where it is taken.+ zone = moved && standard ? snapTerm(motion) : nullif (zone) shown = zone}@@ -507,7 +509,7 @@ export default function ({ title, header = true, surface, layer, icon, children,return}- const term = moved && edge === null && committed ? snapTerm(motion) : null+ const term = moved && edge === null && committed && standard ? snapTerm(motion) : null// Pointer input has ended, but visible gesture ownership remains// until every authoritative mutation below has settled.@@ -621,6 +623,9 @@ export default function ({ title, header = true, surface, layer, icon, children,ref={frameElement}+ // The box the Client's drawing is read in.+ data-window-box=""+onPointerDown={onActivate}// DOM focus and desktop focus are one fact. Tabbing into adiff --git a/source/shared/window-layers.ts b/source/shared/window-layers.tsindex 577bf90..097a7d3 100644--- a/source/shared/window-layers.ts+++ b/source/shared/window-layers.ts@@ -8,8 +8,9 @@ export function requireRawWindowPresentation(layer: WindowLayer) {if (!isRawWindowPresentationLayer(layer)) throw new Error(`The ${layer} layer does not support raw presentation operations`)}+/** A move gesture hands a pointer move to the Desktop in every layer but the wallpaper, which has nowhere to move. */export function requireWindowMoveGesture(layer: WindowLayer) {- if (layer !== "window") throw new Error("Move gestures belong to standard Windows")+ if (layer === "wallpaper") throw new Error("The wallpaper has nowhere to move")}/** Window roles that own one fixed Desktop presentation at a time. */diff --git a/tests/client-layer-permissions.test.ts b/tests/client-layer-permissions.test.tsindex cb2246b..7d9e48b 100644--- a/tests/client-layer-permissions.test.ts+++ b/tests/client-layer-permissions.test.ts@@ -6,8 +6,9 @@ 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() {+function clientFrame() {return {+ element: {},point: (point: { x: number, y: number }) => point} as never}@@ -62,7 +63,7 @@ function fixture() {authentication, connection, session,grantsPermission: async <Name extends PermissionName>(_pane: string, name: Name, values: readonly PermissionValue<Name>[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, process.identity, { state: () => ({ size: { width: 100, height: 100 }, offset: { x: 0, y: 0 } }), move: () => undefined }, () => "frame", moveCoordinates(), {} as never)+ const answer = host(auth, process.identity, { state: () => ({ size: { width: 100, height: 100 }, offset: { x: 0, y: 0 } }), move: () => undefined }, () => "frame", clientFrame(), {} as never)return {auth, program, process, answer, createProcess, findOrCreateProcess, startup, startEndpoint, command, connection,permissions(value: Permissions) { permissions = value }diff --git a/tests/client-permission-boundary.test.ts b/tests/client-permission-boundary.test.tsindex 5c1ef4f..fd78562 100644--- a/tests/client-permission-boundary.test.ts+++ b/tests/client-permission-boundary.test.ts@@ -4,8 +4,9 @@ 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() {+function clientFrame() {return {+ element: {},point: (point: { x: number, y: number }) => point} as never}@@ -25,7 +26,7 @@ test("Client Program creation requires all before reaching the creation boundaryprocessManager: { processes: new Map([["caller", { identity: "caller", program: program.identity }]]) },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, moveCoordinates(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)const source = { identity: "created" }for (const operation of ["host-program-create", "host-program-force-create"]) {await expect(answer(operation, source)).rejects.toThrow("Execution is not permitted")@@ -55,7 +56,7 @@ test("Program and Process discovery exposes only the accessible scope", async ()processManager: { processes: new Map([[current.identity, current], [hidden.identity, hidden]]) },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, moveCoordinates(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)await expect(answer("host-program-list")).resolves.toEqual([[expect.objectContaining({ identity: owner.identity })]])await expect(answer("host-process-list")).resolves.toEqual([[expect.objectContaining({ identity: current.identity })]])@@ -96,7 +97,7 @@ test("Program permission reads require Program access while owner decisions requprocessManager: { processes: new Map([[current.identity, current]]) },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, moveCoordinates(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)const target = { identity: outside.identity, reference: outside.reference }await expect(answer("program-permissions", target, "get", "network")).resolves.toEqual([["https://example.com"]])@@ -124,7 +125,7 @@ test("Program log access follows the Program handle while System logs require lologs: systemLogs,grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, moveCoordinates(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)const own = { identity: owner.identity, reference: owner.reference }const other = { identity: outside.identity, reference: outside.reference }@@ -149,7 +150,7 @@ test("a Client Context requests only for its own Endpoint Program", async () =>processManager: { processes: new Map([[current.identity, current]]) },requestPermission} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, moveCoordinates(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)const timeout = 1_000await expect(answer("context-permission-request", "request", "network", ["https://example.com"], timeout))@@ -169,7 +170,7 @@ test("the system-wide permission registry requires all", async () => {permissionManager: { list },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, moveCoordinates(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)await expect(answer("host-permission-requests")).rejects.toThrow("Execution is not permitted")expect(list).not.toHaveBeenCalled()@@ -225,7 +226,7 @@ test.each([},grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => "frame", moveCoordinates(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => "frame", clientFrame(), {} as never)const key = { program: owningProgram, process: "main", endpoint: "server" } as constconst operations = [["service-available", key],@@ -266,7 +267,7 @@ test("Service discovery filters ready addresses only by Service-name authority",},grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => "frame", moveCoordinates(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => "frame", clientFrame(), {} as never)await expect(answer("host-service-list")).resolves.toEqual([[]])await expect(answer("host-service-list", { name: "main" })).resolves.toEqual([[]])@@ -322,7 +323,7 @@ test("Reading the Desktop view is open, and moving it requires desktopViewport",} as unknown as AuthManagerconst state = { size: { width: 1200, height: 800 }, offset: { x: 0, y: 0 } }const move = vi.fn()- const answer = host(auth, "caller", { state: () => state, move }, () => null, moveCoordinates(), {} as never)+ const answer = host(auth, "caller", { state: () => state, move }, () => null, clientFrame(), {} as never)expect(await answer("desktopViewport")).toEqual([state])await expect(answer("moveDesktopViewport", { x: 1200, y: 0 })).rejects.toThrow("Execution is not permitted")diff --git a/tests/client-process-boundary-lifecycle.test.ts b/tests/client-process-boundary-lifecycle.test.tsindex 91085b0..a8b4ee9 100644--- a/tests/client-process-boundary-lifecycle.test.ts+++ b/tests/client-process-boundary-lifecycle.test.ts@@ -1,6 +1,6 @@import assert from "node:assert/strict"import messagepack from "@the-link/messagepack"-import ClientProcessBoundary, { FrameMoveCoordinates, frameMovePoint } from "@client/view/components/desktop-host/client-process-boundary"+import ClientProcessBoundary, { ClientFrame, frameMovePoint } from "@client/view/components/desktop-host/client-process-boundary"import type AuthManager from "@client/core/link-manager/auth-manager/auth-manager"import type ClientTraffic from "@client/view/components/desktop-host/client-traffic"import type { WindowPresentationHost } from "@client/view/components/desktop-host/window-presentation"@@ -16,10 +16,10 @@ test("frame pointer positions map into the Desktop's physical viewport space", (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 })+ const clientFrame = new ClientFrame(frame)+ assert.deepEqual(clientFrame.point({ x: 40, y: 20 }), { x: 160, y: 80 })left = 240- assert.deepEqual(coordinates.point({ x: -50, y: 30 }), { x: 165, y: 95 })+ assert.deepEqual(clientFrame.point({ x: -50, y: 30 }), { x: 165, y: 95 })})test("a Client question expectation survives initial iframe ownership", async () => {diff --git a/tests/window-presentation-layers.test.ts b/tests/window-presentation-layers.test.tsindex 42cc8b8..13fb6b1 100644--- a/tests/window-presentation-layers.test.ts+++ b/tests/window-presentation-layers.test.ts@@ -19,19 +19,19 @@ function fixture(layer: WindowLayer) {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").layer).toBe("wallpaper")expect(presentations.projection("own")).toMatchObject({position: { x: "-1/2", y: "-1/2" }, size: { width: "1/1", height: "1/1" }, surface: false, interactive: true})expect(() => presentations.move("own", { x: 1, y: 2 })).toThrow(/does not support raw/)expect(() => presentations.setInteractive("own", false)).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/)+ expect(() => presentations.beginMoveGesture("own", "gesture", { x: 0, y: 0 }, { x: 1, y: 1 })).toThrow(/nowhere to move/)})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").layer).toBe(layer)expect(presentations.projection("own")).toMatchObject({position: { x: 0, y: 0 }, size: { width: 0, height: 0 }, surface: false, header: false, interactive: true})@@ -51,12 +51,13 @@ test.each(["under", "over", "shell"] as const)("%s is controlled only through rapresentations.begin("own")expect(presentations.projection("own").interactive).toBe(true)- expect(() => presentations.beginMoveGesture("own", "gesture", { x: 0, y: 0 }, { x: 1, y: 1 })).toThrow(/standard Windows/)+ // A raw drawing may hand a move to the Desktop too, once its Window can take one.+ expect(() => presentations.beginMoveGesture("own", "gesture", { x: 0, y: 0 }, { x: 1, y: 1 })).toThrow(/cannot currently begin/)})test("standard Window presentation is exclusively Desktop-controlled", () => {const { presentations } = fixture("window")- expect(presentations.layer("own")).toBe("window")+ expect(presentations.projection("own").layer).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.setInteractive("own", false)).toThrow(/does not support raw/)