Skip to content

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

Release System 0.1.31

zohayrslileh26dfabbc243f
diff --git a/bun.lock b/bun.lock
index 90e1792..418c2c0 100644
--- a/bun.lock
+++ b/bun.lock
@@ -24,8 +24,8 @@
"devDependencies": {
"@babel/core": "^7.29.7",
"@babel/plugin-proposal-decorators": "^7.29.7",
- "@phreshos/core": "^0.1.14",
- "@phreshos/react-ui": "^0.1.6",
+ "@phreshos/core": "^0.1.15",
+ "@phreshos/react-ui": "^0.1.7",
"@rolldown/plugin-babel": "^0.2.3",
"@tailwindcss/vite": "^4.3.3",
"@types/adm-zip": "^0.5.8",
@@ -230,9 +230,9 @@
"@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-nuhZIOLuI6TFQ32I/WnUx+SCPY7SdSKwgnFHydAuoS1+Z4BRcaP+RRJmGzl9lw+0OFF7UmaESf7KQRXaNLHypg=="],
- "@phreshos/core": ["@phreshos/[email protected]", "", {}, "sha512-57Js6CmnWvbE3f/NQ35hbIIPQmmPmCaLs3dee+m4P367wDgeMP/52WNBpTZoiJYbONaJGDDpIPxg8d7ohX9MXQ=="],
+ "@phreshos/core": ["@phreshos/[email protected]", "", {}, "sha512-4KXyOO8dGCdsMj90sFSsD0B084H8LvLlWfsGYzIHUT0I21/NLZxl3/vnO2djbg1fizU82WSwOKoDzbZp7AyMpA=="],
- "@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "react-aria-components": "^1.20.0" }, "peerDependencies": { "@phreshos/core": "^0.1.13", "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-Vm5nHAe7DK3+CW3AX2CA745+jeLs/pJFZyRQKNOJtzic2m21X3WX2eHAmxlY+c6bjrz8kkT34PIY4synjPTh/Q=="],
+ "@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "react-aria-components": "^1.20.0" }, "peerDependencies": { "@phreshos/core": "^0.1.15", "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-b3QC9cjYNKeEettVpat2UkmxvR0gvYz7ViAZEoG7mgIQvdOPTOgJP6QQj21U3Pwaz5xEAy/y/0qqewFNAqJYKQ=="],
"@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=="],
diff --git a/package.json b/package.json
index 8706e7c..7bf4245 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "phreshos",
"displayName": "PhreshOS",
- "version": "0.1.30",
+ "version": "0.1.31",
"description": "The PhreshOS server, desktop, and authoritative system runtime.",
"type": "module",
"private": true,
@@ -54,8 +54,8 @@
"devDependencies": {
"@babel/core": "^7.29.7",
"@babel/plugin-proposal-decorators": "^7.29.7",
- "@phreshos/core": "^0.1.14",
- "@phreshos/react-ui": "^0.1.6",
+ "@phreshos/core": "^0.1.15",
+ "@phreshos/react-ui": "^0.1.7",
"@rolldown/plugin-babel": "^0.2.3",
"@tailwindcss/vite": "^4.3.3",
"@types/adm-zip": "^0.5.8",
diff --git a/scripts/verify-client-surface.mjs b/scripts/verify-client-surface.mjs
index 6c5b147..d5e7c77 100644
--- a/scripts/verify-client-surface.mjs
+++ b/scripts/verify-client-surface.mjs
@@ -1,7 +1,7 @@
import assert from "node:assert/strict"
import ClientProcessBoundary from "../source/client/view/desktop/client-host/client-process-boundary.ts"
import ClientProcessManager from "../source/client/core/link-manager/auth-manager/process-manager/process-manager.ts"
-import { surfaceSettings, visualTransaction } from "../source/client/view/desktop/client-host/local-window.ts"
+import { visibilityTransition, visualTransaction } from "../source/client/view/desktop/client-host/local-window.ts"
import host from "../source/client/view/desktop/client-host/host.ts"
import LocalWindows from "../source/client/view/desktop/window-manager/local-windows.ts"
import ServerWindow from "../source/server/core/link-manager/auth-manager/process-manager/window.ts"
@@ -17,15 +17,14 @@ const authoritativeWindow = new ServerWindow(
assert.equal("surface" in authoritativeWindow, false)
assert.equal("surface" in authoritativeWindow.toJSON(), false)
-const settings = surfaceSettings({ opacity: 0.5, radius: "large" })
const transaction = visualTransaction({ duration: 240, easing: "ease-out", wait: true })
+const visibility = visibilityTransition({ duration: 240, easing: "ease-out", wait: true })
-assert.throws(() => surfaceSettings({ opacity: 2 }), /from 0 to 1/)
-assert.throws(() => surfaceSettings({ radius: -1 }), /ScaleLevel/)
assert.throws(() => visualTransaction({}), /must provide duration or easing/)
assert.throws(() => visualTransaction({ wait: true }), /must provide duration or easing/)
assert.throws(() => visualTransaction({ duration: 60_001 }), /0 to 60000/)
-assert.throws(() => surfaceSettings({ unknown: true }), /no "unknown" field/)
+assert.throws(() => visibilityTransition(undefined), /required/)
+assert.throws(() => visibilityTransition({ unknown: true }), /no "unknown" field/)
const ordinary = client("window")
const bare = client("over")
@@ -91,13 +90,21 @@ const interrupted = first.move("bare", { x: 100, y: 110 }, { duration: 200, wait
await first.move("bare", { x: 120, y: 130 })
await assert.rejects(interrupted, /interrupted/)
-const surfaceWaiting = first.setSurface("bare", settings, transaction)
-const surfaceRevision = first.windows.get("bare:0").surface.animation.revision
+const surfaceWaiting = first.setSurface("bare", visibility)
+const surfaceRevision = first.windows.get("bare:0").surface.transition.revision
first.complete("bare", "surface", surfaceRevision)
await surfaceWaiting
-assert.equal(first.windows.get("bare:0").surface.animation, null)
+assert.equal(first.windows.get("bare:0").surface.transition, null)
+assert.equal(first.windows.get("bare:0").surface.visible, true)
+
+const surfaceRemoval = first.removeSurface("bare", visibility)
+const removalRevision = first.windows.get("bare:0").surface.transition.revision
+assert.equal(first.windows.get("bare:0").surface.visible, false)
+first.complete("bare", "surface", removalRevision)
+await surfaceRemoval
+assert.equal(first.windows.get("bare:0").surface, null)
-assert.throws(() => first.setSurface("ordinary", settings), /window-layer/)
+assert.throws(() => first.setSurface("ordinary", visibility), /window-layer/)
assert.equal(second.windows.get("bare:0").surface, null)
first.release("bare")
@@ -125,8 +132,8 @@ const calls = []
const localWindow = {
state(identity) { return { position: identity === "target" ? { x: 70, y: 80 } : { x: 0, y: 0 } } },
move(identity, value, motion) { calls.push(["move", identity, value, motion]) },
- setSurface(identity, value, motion) { calls.push(["set", identity, value, motion]) },
- removeSurface(identity) { calls.push(["remove", identity]) }
+ setSurface(identity, motion) { calls.push(["set", identity, motion]) },
+ removeSurface(identity, motion) { calls.push(["remove", identity, motion]) }
}
const processManager = {
processes,
@@ -146,17 +153,17 @@ assert.deepEqual(await request("desktop"), [{ width: 1, height: 1 }])
const targetAddress = { identity: target.identity, reference: target.reference }
assert.deepEqual(await request("windowLocal", targetAddress), [{ position: { x: 70, y: 80 } }])
await request("windowLocalMove", targetAddress, { x: 70, y: 80 })
-await request("windowLocalSurfaceSet", targetAddress, settings, transaction)
-await request("windowLocalSurfaceRemove", targetAddress)
+await request("windowLocalSurfaceSet", targetAddress, visibility)
+await request("windowLocalSurfaceRemove", targetAddress, visibility)
assert.deepEqual(calls, [
["move", "target", { x: 70, y: 80 }, undefined],
- ["set", "target", settings, transaction],
- ["remove", "target"]
+ ["set", "target", visibility],
+ ["remove", "target", visibility]
])
assert.deepEqual(target.client.window.position, { x: 10, y: 20 })
await assert.rejects(request("windowLocalSurfaceSet", targetAddress, { identity: "unexpected" }), /no "identity" field/)
-await assert.rejects(request("windowLocalSurfaceSet", { ...targetAddress, reference: "wrong" }, settings), /does not know this process/)
+await assert.rejects(request("windowLocalSurfaceSet", { ...targetAddress, reference: "wrong" }, visibility), /does not know this process/)
const lifecycle = []
const boundary = new ClientProcessBoundary(
diff --git a/scripts/verify-theme.mjs b/scripts/verify-theme.mjs
index 67ff913..2ee3730 100644
--- a/scripts/verify-theme.mjs
+++ b/scripts/verify-theme.mjs
@@ -11,7 +11,7 @@ const expected = {
surface: {
grain: 0,
grainAmount: 0,
- animation: 0,
+ grainAnimation: 0,
backdrop: 0,
opacity: 1,
distortion: 0,
@@ -28,7 +28,7 @@ const configured = themeSchema.parse({
surface: {
grain: 0.9,
grainAmount: 0.5,
- animation: 16,
+ grainAnimation: 16,
backdrop: 24,
opacity: 0,
distortion: 140,
@@ -42,7 +42,7 @@ assert.equal(configured.background, "black")
assert.deepEqual(configured.surface, {
grain: 0.9,
grainAmount: 0.5,
- animation: 16,
+ grainAnimation: 16,
backdrop: 24,
opacity: 0,
distortion: 140,
@@ -55,7 +55,8 @@ assert.throws(() => themeSchema.parse({ surface: { color: "black" } }))
assert.throws(() => themeSchema.parse({ glass: {} }))
assert.throws(() => themeSchema.parse({ surface: { grain: 1.01 } }))
assert.throws(() => themeSchema.parse({ surface: { grainAmount: -0.01 } }))
-assert.throws(() => themeSchema.parse({ surface: { animation: 17 } }))
+assert.throws(() => themeSchema.parse({ surface: { animation: 1 } }))
+assert.throws(() => themeSchema.parse({ surface: { grainAnimation: 17 } }))
assert.throws(() => themeSchema.parse({ surface: { backdrop: 25 } }))
assert.throws(() => themeSchema.parse({ surface: { distortion: 141 } }))
assert.throws(() => themeSchema.parse({ surface: { waves: 41 } }))
diff --git a/source/client/view/desktop/client-host/host.ts b/source/client/view/desktop/client-host/host.ts
index 01fd784..60a27cf 100644
--- a/source/client/view/desktop/client-host/host.ts
+++ b/source/client/view/desktop/client-host/host.ts
@@ -10,7 +10,7 @@ import {
localGeometry,
localPosition,
localSize,
- surfaceSettings,
+ visibilityTransition,
visualTransaction,
type LocalWindowHost
} from "./local-window"
@@ -562,14 +562,14 @@ export default function host(authManager: AuthManager, pane: string, desktop: ()
if (word === "windowLocalSurfaceSet") {
- await localWindow.setSurface(scope.localProcess(args[0]).identity, surfaceSettings(args[1] === undefined ? {} : args[1]), visualTransaction(args[2]))
+ await localWindow.setSurface(scope.localProcess(args[0]).identity, visibilityTransition(args[1]))
return []
}
if (word === "windowLocalSurfaceRemove") {
- localWindow.removeSurface(scope.localProcess(args[0]).identity)
+ await localWindow.removeSurface(scope.localProcess(args[0]).identity, visibilityTransition(args[1]))
return []
}
diff --git a/source/client/view/desktop/client-host/local-window.ts b/source/client/view/desktop/client-host/local-window.ts
index 08a261a..87ecf2d 100644
--- a/source/client/view/desktop/client-host/local-window.ts
+++ b/source/client/view/desktop/client-host/local-window.ts
@@ -1,12 +1,10 @@
import {
isRelativeValue,
- isScaleLevel,
type Easing,
type Position,
- type ScaleLevel,
type Size,
- type SurfaceSettings,
type Transaction,
+ type VisibilityTransition,
type WindowGeometry,
type WindowLayer,
type WindowState
@@ -18,8 +16,8 @@ export type LocalAnimation = Readonly<{
}>
export type LocalSurfaceState = Readonly<{
- settings: SurfaceSettings
- animation: LocalAnimation | null
+ visible: boolean
+ transition: LocalAnimation | null
}>
/** Everything physically represented by one exact live Client iframe. */
@@ -38,8 +36,8 @@ export interface LocalWindowHost {
minimize(identity: string, minimized: boolean): void
title(identity: string, title: string): void
raise(identity: string): void
- setSurface(identity: string, settings: SurfaceSettings, transaction?: Transaction): Promise<void>
- removeSurface(identity: string): void
+ setSurface(identity: string, transition: VisibilityTransition): Promise<void>
+ removeSurface(identity: string, transition: VisibilityTransition): Promise<void>
complete(identity: string, kind: "geometry" | "surface", revision: number): void
release(identity: string): void
}
@@ -66,26 +64,6 @@ export function localGeometry(value: unknown): WindowGeometry {
return Object.freeze({ position: localPosition(record.position), size: localSize(record.size) })
}
-export function surfaceSettings(value: unknown): SurfaceSettings {
- const record = plain(value, "Surface settings")
- fields(record, ["opacity", "radius"], "Surface settings")
- const result: { opacity?: number, radius?: ScaleLevel | number | "full" } = {}
-
- if ("opacity" in record) {
-
- if (!finite(record.opacity) || record.opacity < 0 || record.opacity > 1) throw new Error("Surface opacity must be a finite number from 0 to 1")
- result.opacity = record.opacity
- }
-
- if ("radius" in record) {
-
- if (record.radius !== "full" && !isScaleLevel(record.radius) && (!finite(record.radius) || record.radius < 0)) throw new Error('Surface radius must be a ScaleLevel, a finite nonnegative pixel number, or "full"')
- result.radius = record.radius
- }
-
- return Object.freeze(result)
-}
-
export function visualTransaction(value: unknown): Transaction | undefined {
if (value === undefined) return undefined
@@ -113,6 +91,12 @@ export function visualTransaction(value: unknown): Transaction | undefined {
return Object.freeze(result) as Transaction
}
+export function visibilityTransition(value: unknown): VisibilityTransition {
+ const transition = visualTransaction(value)
+ if (!transition) throw new Error("A VisibilityTransition is required")
+ return transition
+}
+
export function layerAllowsSurface(layer: WindowLayer) {
if (layer === "window") throw new Error("A window-layer representation cannot own a Surface")
diff --git a/source/client/view/desktop/window-manager/local-windows.ts b/source/client/view/desktop/window-manager/local-windows.ts
index 74fc886..c903200 100644
--- a/source/client/view/desktop/window-manager/local-windows.ts
+++ b/source/client/view/desktop/window-manager/local-windows.ts
@@ -142,24 +142,28 @@ export default class LocalWindows implements LocalWindowHost {
this.replace(identity, { ...state, depth: depth + 1 })
}
- public setSurface(process: string, settings: NonNullable<LocalWindowState["surface"]>["settings"], transaction?: Transaction) {
+ public setSurface(process: string, transaction: Transaction) {
const { identity, state } = this.existing(process)
layerAllowsSurface(state.layer)
- if (state.surface && JSON.stringify(state.surface.settings) === JSON.stringify(settings)) return Promise.resolve()
+ if (state.surface?.visible) return Promise.resolve()
this.cancel(identity, "surface")
- const animation = transaction ? { revision: ++this.revision, transaction } : null
- this.replace(identity, { ...state, surface: { settings, animation } })
- return this.waitFor(identity, "surface", animation)
+ const transition = { revision: ++this.revision, transaction }
+ this.replace(identity, { ...state, surface: { visible: true, transition } })
+ return this.waitFor(identity, "surface", transition)
}
- public removeSurface(process: string) {
+ public removeSurface(process: string, transaction: Transaction) {
const { identity, state } = this.existing(process)
layerAllowsSurface(state.layer)
+ if (!state.surface || !state.surface.visible) return Promise.resolve()
+
this.cancel(identity, "surface")
- this.replace(identity, { ...state, surface: null })
+ const transition = { revision: ++this.revision, transaction }
+ this.replace(identity, { ...state, surface: { visible: false, transition } })
+ return this.waitFor(identity, "surface", transition)
}
public complete(process: string, kind: AnimationKind, revision: number) {
@@ -167,12 +171,12 @@ export default class LocalWindows implements LocalWindowHost {
const identity = this.live.get(process)
if (!identity) return
const state = this.windows.get(identity)
- const animation = kind === "geometry" ? state?.geometryAnimation : state?.surface?.animation
+ const animation = kind === "geometry" ? state?.geometryAnimation : state?.surface?.transition
if (!state || animation?.revision !== revision) return
this.replace(identity, kind === "geometry"
? { ...state, geometryAnimation: null }
- : { ...state, surface: state.surface && { ...state.surface, animation: null } })
+ : { ...state, surface: state.surface?.visible ? { ...state.surface, transition: null } : null })
const key = animationKey(identity, kind)
const waiting = this.waiting.get(key)
diff --git a/source/client/view/desktop/window-manager/window-surface.tsx b/source/client/view/desktop/window-manager/window-surface.tsx
index 3008f9f..a48d91d 100644
--- a/source/client/view/desktop/window-manager/window-surface.tsx
+++ b/source/client/view/desktop/window-manager/window-surface.tsx
@@ -1,6 +1,5 @@
import { useReducedMotion } from "@libs/react-motion"
-import { isScaleLevel, scale, type SurfaceSettings } from "@phreshos/core"
-import { Surface, useTheme } from "@phreshos/react-ui"
+import { Surface } from "@phreshos/react-ui"
import { useLayoutEffect, useRef, useState } from "react"
import { type LocalSurfaceState } from "../client-host/local-window"
import gsap, { motionDuration, motionEase } from "../../appearance/motion"
@@ -10,7 +9,7 @@ const systemDuration = 240
/** Projects one representation-local target and animates explicit replacements. */
export default function WindowSurface({ state, onComplete }: WindowSurfaceProps) {
- const { settings, animation: requestedAnimation } = state
+ const { transition, visible } = state
const element = useRef<HTMLDivElement>(null)
@@ -18,12 +17,9 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
const reducedMotion = useReducedMotion()
- const themeRadius = useTheme().radius
-
- // Rendering retains the last settled target while an incoming target is
- // prepared imperatively. This leaves the element's current visual values
- // available when a new transaction interrupts one already in flight.
- const [rendered, setRendered] = useState(settings)
+ // Keep the last painted target in React while an incoming transition is
+ // prepared from the element's current compositor value.
+ const [renderedVisible, setRenderedVisible] = useState(visible)
useLayoutEffect(function () {
@@ -31,23 +27,17 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
if (!surface) return
- const target = values(settings, themeRadius)
-
const current = getComputedStyle(surface)
- const revision = requestedAnimation?.revision ?? null
+ const revision = transition?.revision ?? null
const changed = revision !== null
- const from = firstRender.current && changed
-
- ? { opacity: 0, borderRadius: "0px" }
-
- : { opacity: Number(current.opacity), borderRadius: current.borderRadius }
+ const from = { opacity: firstRender.current && visible ? 0 : Number(current.opacity) }
firstRender.current = false
- const transaction = requestedAnimation?.transaction
+ const transaction = transition?.transaction
const duration = transaction?.duration ?? systemDuration
@@ -55,8 +45,8 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
if (!transaction || !changed || reducedMotion || duration === 0) {
- gsap.set(surface, target)
- setRendered(settings)
+ gsap.set(surface, { opacity: visible ? 1 : 0 })
+ setRenderedVisible(visible)
if (transaction && changed) onComplete(revision!)
@@ -64,13 +54,13 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
}
const animation = gsap.fromTo(surface, from, {
- ...target,
+ opacity: visible ? 1 : 0,
duration: motionDuration(duration),
ease: motionEase(transaction.easing),
overwrite: "auto",
onComplete: function () {
- setRendered(settings)
+ setRenderedVisible(visible)
onComplete(revision!)
}
})
@@ -81,14 +71,10 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
surface.style.opacity = shown.opacity
- surface.style.borderRadius = shown.borderRadius
-
animation.kill()
}
- }, [reducedMotion, requestedAnimation?.revision, settings, themeRadius])
-
- const target = values(rendered, themeRadius)
+ }, [reducedMotion, transition?.revision, visible])
return <Surface
@@ -100,23 +86,11 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
className="pointer-events-none absolute inset-0"
- style={{ opacity: target.opacity, borderRadius: target.borderRadius }}
+ style={{ opacity: renderedVisible ? 1 : 0 }}
/>
}
-function values(settings: SurfaceSettings, themeRadius: number) {
-
- const radius = settings.radius
-
- return {
-
- opacity: settings.opacity ?? 1,
-
- borderRadius: radius === "full" ? "50%" : `${isScaleLevel(radius) ? scale(themeRadius, radius) : radius ?? 0}px`
- }
-}
-
interface WindowSurfaceProps {
state: LocalSurfaceState
diff --git a/source/server/core/theme-manager.ts b/source/server/core/theme-manager.ts
index a870c88..ee091fb 100644
--- a/source/server/core/theme-manager.ts
+++ b/source/server/core/theme-manager.ts
@@ -14,7 +14,7 @@ export const themeSchema: z.ZodType<ThemeProperties> = z.strictObject({
surface: z.strictObject({
grain: bounded(themeLimits.surface.grain).default(standardTheme.surface.grain),
grainAmount: bounded(themeLimits.surface.grainAmount).default(standardTheme.surface.grainAmount),
- animation: bounded(themeLimits.surface.animation).default(standardTheme.surface.animation),
+ grainAnimation: bounded(themeLimits.surface.grainAnimation).default(standardTheme.surface.grainAnimation),
backdrop: bounded(themeLimits.surface.backdrop).default(standardTheme.surface.backdrop),
opacity: bounded(themeLimits.surface.opacity).default(standardTheme.surface.opacity),
distortion: bounded(themeLimits.surface.distortion).default(standardTheme.surface.distortion),