Skip to content

An open-source, self-hosted system for apps built with web technologies.

Keep desktop measurements numeric

zohayrslileh4122390c5d65
diff --git a/source/client/view/desktop/client-host/client-host.ts b/source/client/view/desktop/client-host/client-host.ts
index c4f856a..751f987 100644
--- a/source/client/view/desktop/client-host/client-host.ts
+++ b/source/client/view/desktop/client-host/client-host.ts
@@ -1,6 +1,7 @@
import ReactTunnel from "@libs/the-link/plugins/react-helper/react-tunnel"
-import { isPermissionName, type Size } from "@phreshos/core"
+import { isPermissionName } from "@phreshos/core"
import useAnnouncements from "./announcements"
+import { type DesktopSize } from "./host"
import DesktopPointer from "./pointer"
import ClientProcessBoundary from "./client-process-boundary"
import ClientTraffic from "./client-traffic"
@@ -31,9 +32,9 @@ export default function useClientHost(desktop: RefObject<HTMLDivElement | null>,
const [windowSurfaceSize, setWindowSurfaceSize] = useState<SurfaceSize>({ width: 0, height: 0 })
- const latestDesktopSize = useRef<Size>({ width: 0, height: 0 })
+ const latestDesktopSize = useRef<DesktopSize>({ width: 0, height: 0 })
- const desktopSize = useCallback(function (): Size {
+ const desktopSize = useCallback(function (): DesktopSize {
const bounds = desktop.current?.getBoundingClientRect()
@@ -47,12 +48,12 @@ export default function useClientHost(desktop: RefObject<HTMLDivElement | null>,
if (!desktop.current || !windowSurfaceRef.current) return
- function measure(bounds: { width: number, height: number }): Size {
+ function measure(bounds: { width: number, height: number }): DesktopSize {
return { width: Math.round(bounds.width), height: Math.round(bounds.height) }
}
- function announceDesktop(now: Size) {
+ function announceDesktop(now: DesktopSize) {
if (latestDesktopSize.current.width === now.width && latestDesktopSize.current.height === now.height) return
diff --git a/source/client/view/desktop/client-host/client-process-boundary.ts b/source/client/view/desktop/client-host/client-process-boundary.ts
index 34887c4..3298f7e 100644
--- a/source/client/view/desktop/client-host/client-process-boundary.ts
+++ b/source/client/view/desktop/client-host/client-process-boundary.ts
@@ -1,11 +1,11 @@
import AuthManager from "@client/core/link-manager/auth-manager/auth-manager"
import TheLink from "@libs/the-link/the-link"
-import host, { TransferredAnswer } from "./host"
+import host, { type DesktopSize, TransferredAnswer } from "./host"
import { type PointerHost } from "./pointer"
import ClientTraffic from "./client-traffic"
import { failed, succeeded } from "@server/core/outcome"
import { type TrafficKind } from "@server/core/link-manager/auth-manager/process-manager/process-traffic"
-import { isPermissionName, type PermissionName, type Size } from "@phreshos/core"
+import { isPermissionName, type PermissionName } from "@phreshos/core"
import { type LocalWindowHost } from "./local-window"
/** The desktop boundary around one iframe execution endpoint. */
@@ -17,7 +17,7 @@ export default class ClientProcessBoundary extends TheLink {
private readonly authManager: AuthManager
- private readonly desktop: () => Size
+ private readonly desktop: () => DesktopSize
private readonly pointer: PointerHost
@@ -58,7 +58,7 @@ export default class ClientProcessBoundary extends TheLink {
private document: string | null = null
- public constructor(pane: string, element: HTMLIFrameElement, authManager: AuthManager, desktop: () => Size, pointer: PointerHost, traffic: ClientTraffic, localWindow: LocalWindowHost) {
+ public constructor(pane: string, element: HTMLIFrameElement, authManager: AuthManager, desktop: () => DesktopSize, pointer: PointerHost, traffic: ClientTraffic, localWindow: LocalWindowHost) {
super()
diff --git a/source/client/view/desktop/client-host/host.ts b/source/client/view/desktop/client-host/host.ts
index 7e1816d..4da9b58 100644
--- a/source/client/view/desktop/client-host/host.ts
+++ b/source/client/view/desktop/client-host/host.ts
@@ -5,7 +5,7 @@ import { type ClientBody, type ProxiedResponse, type ServedValue } from "@client
import { type PointerHost } from "./pointer"
import { type TrafficKind } from "@server/core/link-manager/auth-manager/process-manager/process-traffic"
import { sdkProcess, sdkProgram } from "./sdk-records"
-import { isPermissionName, isServiceKey, type ProgramIconSize, type Size, type WindowLayer } from "@phreshos/core"
+import { isPermissionName, isServiceKey, type ProgramIconSize, type WindowLayer } from "@phreshos/core"
import {
localGeometry,
localPosition,
@@ -21,6 +21,14 @@ export class TransferredAnswer {
public constructor(public readonly result: unknown[], public readonly transfer: Transferable[]) { }
}
+/** The complete measured desktop area in CSS pixels. */
+export interface DesktopSize {
+
+ width: number
+
+ height: number
+}
+
/**
* The desktop's vocabulary: what a client half may ask of the interface
* that frames it.
@@ -45,7 +53,7 @@ export class TransferredAnswer {
* no prototypes and refuses functions — so every word answers with plain
* values built here, never with an instance the desktop holds.
*/
-export default function host(authManager: AuthManager, pane: string, desktop: () => Size, frameOwner: () => string | null, pointer: PointerHost, localWindow: LocalWindowHost) {
+export default function host(authManager: AuthManager, pane: string, desktop: () => DesktopSize, frameOwner: () => string | null, pointer: PointerHost, localWindow: LocalWindowHost) {
const { processManager, programManager } = authManager