An open-source, self-hosted system for apps built with web technologies.
Release System 0.1.90
zohayrslileha94d7f7fe279
diff --git a/bun.lock b/bun.lockindex abafd26..f27dd24 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.59",- "@phreshos/react-ui": "^0.1.34",+ "@phreshos/core": "^0.1.60",+ "@phreshos/react-ui": "^0.1.35","@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-/9qMUkCIw1qYKc/lDhzkcxpdvkCOmI00jdWoKkoBMGzB13PkN5My1zi0J8Veu2JX0j+h4zmJa5C+0JpQ4PDwmA=="],+ "@phreshos/core": ["@phreshos/[email protected]", "", { "dependencies": { "zod": "^4.6.5" } }, "sha512-EK76XvlQGySOhd4+ZdqP9fwOY7IaDDLHs2R6iqLuoNZUKpMJEi1vWHaR8ALbTYNkDo4OOaSjnibK/4djPeZtTw=="],- "@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-GaWuftM6hhvxQi5G79TJG8yQ5++O4hfYRXlAvmXzQN00OWAPxAMqq2uw/Xo8TWY9eh68oA+HbfXcQQga/6HcCQ=="],+ "@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "@base-ui/react": "^1.7.0", "@internationalized/date": "^3.12.3", "@phreshos/core": "^0.1.60", "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-uNjk0ET0ry5hmMnPK4U/MtLu7SXGsByjqc20sSsgtp7MdYMuY7gpxXSyWUVYFJKgEMXS330Yt7iYWJfU/7hRpw=="],"@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.jsonindex 92a1eb2..b265589 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "phreshos","displayName": "PhreshOS",- "version": "0.1.89",+ "version": "0.1.90","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.59",- "@phreshos/react-ui": "^0.1.34",+ "@phreshos/core": "^0.1.60",+ "@phreshos/react-ui": "^0.1.35","@the-link/core": "^0.3.1","@the-link/http": "^0.1.1","@the-link/ipc": "^0.2.2",diff --git a/scripts/dev.ts b/scripts/dev.tsindex be77b80..2f22235 100644--- a/scripts/dev.ts+++ b/scripts/dev.ts@@ -1,7 +1,7 @@import { displayName, name, version } from "@/package.json"import doors from "@server/view/http/doors"import view from "@server/view/view"-import { defaultHome, defaultPorts, environmentHome, environmentPorts } from "@server/view/configuration"+import { defaultHome, defaultHostname, defaultPorts, environmentHome, environmentHostname, environmentPorts } from "@server/view/configuration"import { createServer } from "vite"const home = environmentHome(name, process.env) ?? defaultHome(true)@@ -16,7 +16,7 @@ const host = await view({mode: "development",- hostname: "localhost",+ hostname: environmentHostname(name, process.env) ?? defaultHostname(),home,diff --git a/source/server/main.ts b/source/server/main.tsindex ba63685..d0ef82b 100644--- a/source/server/main.ts+++ b/source/server/main.ts@@ -1,6 +1,6 @@import { displayName, name, version } from "@/package.json"import view from "./view/view"-import { defaultHome, defaultPorts, environmentHome, environmentPorts, requestedHome, requestedPorts } from "./view/configuration"+import { defaultHome, defaultHostname, defaultPorts, environmentHome, environmentHostname, environmentPorts, requestedHome, requestedPorts } from "./view/configuration"import { fileURLToPath } from "node:url"const development = process.env.NODE_ENV === "development"@@ -20,6 +20,10 @@ await view({mode: "production",+ // A published container port cannot reach a listener confined to the+ // container's loopback interface, so the deployment owns this selection.+ hostname: environmentHostname(name, process.env) ?? defaultHostname(),+home,ports: environmentPorts(name, process.env) ?? requestedPortSelection ?? defaultPorts(development),diff --git a/source/server/view/configuration.ts b/source/server/view/configuration.tsindex 31d6fd8..44a13db 100644--- a/source/server/view/configuration.ts+++ b/source/server/view/configuration.ts@@ -22,6 +22,24 @@ export function defaultPorts(development: boolean) {return development ? portRange(5300, 5399) : portRange(4300, 4399)}+/** Select the default interface exposed by the System listener. */+export function defaultHostname() {++ return "localhost"+}++/** Read the optional interface selected for the production listener. */+export function environmentHostname(name: string, variables: NodeJS.ProcessEnv) {++ const selected = environment(name, "HOST", variables)+ const value = selected.value++ if (value === undefined) return undefined+ if (!value || value !== value.trim() || /\s/.test(value)) throw new Error(`${selected.key} must contain one hostname or IP address`)++ return value+}+/** Read the optional ordered production port selection. */export function environmentPorts(name: string, variables: NodeJS.ProcessEnv) {diff --git a/tests/distribution.test.mjs b/tests/distribution.test.mjsindex 8d65973..081d0d6 100644--- a/tests/distribution.test.mjs+++ b/tests/distribution.test.mjs@@ -111,7 +111,12 @@ test("distribution contract", async () => {runtime = spawn(process.execPath, ["server/main.js"], {cwd: directory,- env: { ...process.env, PHRESHOS_HOME: join(temporary, "home"), [portVariable]: String(port) },+ env: {+ ...process.env,+ PHRESHOS_HOME: join(temporary, "home"),+ PHRESHOS_HOST: "0.0.0.0",+ [portVariable]: String(port)+ },stdio: ["ignore", "pipe", "pipe"]})diff --git a/tests/hostname.test.ts b/tests/hostname.test.tsnew file mode 100644index 0000000..7526f3c--- /dev/null+++ b/tests/hostname.test.ts@@ -0,0 +1,18 @@+import { strict as assert } from "node:assert"+import { defaultHostname, environmentHostname } from "@server/view/configuration"+import { test } from "vitest"++test("listener hostname contract", () => {+ assert.equal(defaultHostname(), "localhost")+ assert.equal(environmentHostname("phreshos", {}), undefined)+ assert.equal(environmentHostname("phreshos", { PHRESHOS_HOST: "0.0.0.0" }), "0.0.0.0")+ assert.equal(environmentHostname("phreshos", { PHRESHOS_HOST: "::" }), "::")+ assert.equal(environmentHostname("phreshos", { PHRESHOS_HOST: "desktop.internal" }), "desktop.internal")++ for (const value of ["", " ", " localhost", "localhost ", "two hosts"]) {+ assert.throws(+ () => environmentHostname("phreshos", { PHRESHOS_HOST: value }),+ /PHRESHOS_HOST must contain one hostname or IP address/+ )+ }+})