diff --git a/.bun-version b/.bun-version new file mode 100644 index 0000000..1c99cf0 --- /dev/null +++ b/.bun-version @@ -0,0 +1 @@ +1.4.4 diff --git a/README.md b/README.md index 641d58b..3547ca5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ > Public project website and account frontend for VNOX Central. [![License: GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-lightgrey.svg)](LICENSE) -[![Node.js](https://img.shields.io/badge/node-22%2B-lightgrey.svg)](https://nodejs.org/) +[![Bun](https://img.shields.io/badge/Bun-1.4.4-lightgrey.svg)](https://bun.sh/) +[![TypeScript](https://img.shields.io/badge/TypeScript-7.0.2-lightgrey.svg)](https://www.typescriptlang.org/) --- @@ -11,7 +12,23 @@ A lightweight, self-hosted website for VNOX, a Rust voice and text communication platform. This is a separate repository from [VNOX Client](https://git.wihuk.pro/boba/VNOX-Client) and [VNOX Server](https://git.wihuk.pro/boba/VNOX-Server). -The site uses plain HTML, CSS and JavaScript modules. There are **no runtime or build dependencies**, third-party scripts, analytics or external fonts. +The application is written in **TypeScript**, HTML and CSS. **Bun** installs dependencies, runs development previews and tests, formats source and bundles production assets. Strict types cover Hub responses, sessions, profiles, language keys and UI state; untrusted JSON is also validated at runtime. + +Browsers execute JavaScript, so Bun compiles the TypeScript source into one static browser bundle. A frontend framework is unnecessary for the landing page and account flow. There are **no browser runtime dependencies**, third-party scripts, analytics or external fonts. Production serves static files through Nginx; neither Bun nor Node.js runs on the website server. + +## Screenshots + +Actual screenshots of [central.loki-code.dev](https://central.loki-code.dev), captured on 24 October 2026 in a fresh, anonymous browser context. No private account data or credentials appear in these images. + +### Project page + +![VNOX project page with a graphite palette, approved V mark and interactive client illustration](docs/screenshots/landing-desktop.png) + +### Central account + +![Anonymous VNOX Central account page offering GitHub sign-in](docs/screenshots/account-desktop.png) + +[Mobile screenshot](docs/screenshots/landing-mobile.png) ## Features @@ -25,32 +42,38 @@ The website does not implement identity verification itself. The Rust Hub exchan ## Development -Requires Node.js 22 or newer. No `npm install` is needed. +Requires **Bun 1.4.4** or newer. The verified version is pinned in `packageManager` and `.bun-version`; development package versions and integrity hashes are committed in `bun.lock`. ```sh -npm run dev # Local preview at http://127.0.0.1:4176 -npm test # Node tests: locale parity, API/security and preview routing -npm run build # Copy public/ and src/ into dist/, normalize permissions -npm run preview # Preview the built dist/ directory +bun install --frozen-lockfile +bun run dev # Local preview at http://127.0.0.1:4176 +bun run check # Strict TypeScript checking, without emitting files +bun test # API, locale and Bun preview regression tests +bun run build # Check types and create the static dist/ release +bun run preview # Preview the built dist/ directory +bun run format:check # Check formatting with Bun's built-in formatter +bun run format # Format TypeScript, CSS, HTML and configuration ``` -Optional browser QA: `python3 tests/browser_qa.py` uses an existing local Playwright installation and Chromium against the running preview. It does not add a project dependency. +No Node.js installation is required. TypeScript and Bun type definitions are development-only dependencies; the browser bundle contains only this application's code. See the [dependency audit](docs/dependencies.md) for checked versions and licenses. -Set `PORT=4180` to change the preview port. The preview intentionally returns HTTP 503 for API requests; it contains no fake backend or development credentials. +Set `PORT=4180` to change the preview port. Reload the browser after editing source: the development preview compiles the current TypeScript when `/src/app.js` is requested. The preview intentionally returns HTTP 503 for API requests; it contains no fake backend or development credentials. + +Optional browser QA: `python3 tests/browser_qa.py` uses an existing local Playwright installation and Chromium against the running preview. It does not add a JavaScript project dependency. ## Structure ```text public/ HTML entry point and self-hosted assets -src/ Application, API helpers, RU/EN catalogs and styling -scripts/ Dependency-free build and loopback preview -tests/ Node regression tests -docs/ Design direction and Nginx integration example +src/ Typed application, API helpers, RU/EN catalogs and CSS +scripts/ Bun browser bundling, static build and loopback preview +tests/ Bun regression tests and optional browser QA +docs/ Design, deployment notes and repository-hosted screenshots ``` ## Hub integration -Serve `dist/` at the same HTTPS origin as VNOX Hub. `/` and `/account` use `index.html`; preserve proxy routes `/v1/`, `/health`, `/ready` and `/version`. See [Nginx example](docs/nginx-static.conf). +Serve `dist/` at the same HTTPS origin as VNOX Hub. `/` and `/account` use `index.html`; preserve proxy routes `/v1/`, `/health`, `/ready` and `/version`. See the [Nginx example](docs/nginx-static.conf). | Endpoint | Frontend behaviour | | --- | --- | @@ -63,7 +86,7 @@ The Hub sets Secure, HttpOnly cookies. Tokens are never stored in browser storag ## Contributing -Keep RU/EN catalog keys aligned, render profile values as text and retain keyboard navigation and reduced-motion support. Use descriptive Conventional Commits such as `fix(web): preserve account state when changing language`. Run tests and build before submitting a focused PR; include screenshots for visual changes. See [verification notes](docs/verification.md) for browser QA and current limits. +Keep RU/EN catalog keys aligned, render profile values as text and retain keyboard navigation and reduced-motion support. Use descriptive Conventional Commits such as `fix(web): preserve account state when changing language`. Run type checks, tests, formatting checks and a production build before submitting a focused PR; include screenshots for visual changes. See [verification notes](docs/verification.md) for browser QA and current limits. ## License diff --git a/bun.lock b/bun.lock new file mode 100644 index 0000000..c41f2f2 --- /dev/null +++ b/bun.lock @@ -0,0 +1,64 @@ +{ + "lockfileVersion": 2, + "configVersion": 1, + "workspaces": { + "": { + "name": "vnox-web", + "devDependencies": { + "@types/bun": "1.4.4", + "typescript": "7.0.2", + }, + }, + }, + "packages": { + "@types/bun": ["@types/bun@1.4.4", "", { "dependencies": { "bun-types": "1.4.4" } }, "sha512-9wkRDXUXK124pEnAutE6n/l18j+i9GC5IAHK8TmX/2nlySETmky0OU6yL5U8pW1AoKh++AN9auDCr647BfurjQ=="], + + "@types/node": ["@types/node@26.6.5", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg=="], + + "@typescript/typescript-aix-ppc64": ["@typescript/typescript-aix-ppc64@7.0.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ=="], + + "@typescript/typescript-darwin-arm64": ["@typescript/typescript-darwin-arm64@7.0.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA=="], + + "@typescript/typescript-darwin-x64": ["@typescript/typescript-darwin-x64@7.0.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA=="], + + "@typescript/typescript-freebsd-arm64": ["@typescript/typescript-freebsd-arm64@7.0.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ=="], + + "@typescript/typescript-freebsd-x64": ["@typescript/typescript-freebsd-x64@7.0.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw=="], + + "@typescript/typescript-linux-arm": ["@typescript/typescript-linux-arm@7.0.2", "", { "os": "linux", "cpu": "arm" }, "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ=="], + + "@typescript/typescript-linux-arm64": ["@typescript/typescript-linux-arm64@7.0.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ=="], + + "@typescript/typescript-linux-loong64": ["@typescript/typescript-linux-loong64@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ=="], + + "@typescript/typescript-linux-mips64el": ["@typescript/typescript-linux-mips64el@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA=="], + + "@typescript/typescript-linux-ppc64": ["@typescript/typescript-linux-ppc64@7.0.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA=="], + + "@typescript/typescript-linux-riscv64": ["@typescript/typescript-linux-riscv64@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ=="], + + "@typescript/typescript-linux-s390x": ["@typescript/typescript-linux-s390x@7.0.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw=="], + + "@typescript/typescript-linux-x64": ["@typescript/typescript-linux-x64@7.0.2", "", { "os": "linux", "cpu": "x64" }, "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A=="], + + "@typescript/typescript-netbsd-arm64": ["@typescript/typescript-netbsd-arm64@7.0.2", "", { "os": "none", "cpu": "arm64" }, "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA=="], + + "@typescript/typescript-netbsd-x64": ["@typescript/typescript-netbsd-x64@7.0.2", "", { "os": "none", "cpu": "x64" }, "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA=="], + + "@typescript/typescript-openbsd-arm64": ["@typescript/typescript-openbsd-arm64@7.0.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ=="], + + "@typescript/typescript-openbsd-x64": ["@typescript/typescript-openbsd-x64@7.0.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg=="], + + "@typescript/typescript-sunos-x64": ["@typescript/typescript-sunos-x64@7.0.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g=="], + + "@typescript/typescript-win32-arm64": ["@typescript/typescript-win32-arm64@7.0.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ=="], + + "@typescript/typescript-win32-x64": ["@typescript/typescript-win32-x64@7.0.2", "", { "os": "win32", "cpu": "x64" }, "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g=="], + + "bun-types": ["bun-types@1.4.4", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-yjrJh5oGX7mMPKGd19YXyIjmEuj4G4zNC30bs7PM9Az7NQ3ndF3j6hbeRdvJTRQEhJ/FYQwW0a2moweEi2hMxQ=="], + + "typescript": ["typescript@7.0.2", "", { "optionalDependencies": { "@typescript/typescript-aix-ppc64": "7.0.2", "@typescript/typescript-darwin-arm64": "7.0.2", "@typescript/typescript-darwin-x64": "7.0.2", "@typescript/typescript-freebsd-arm64": "7.0.2", "@typescript/typescript-freebsd-x64": "7.0.2", "@typescript/typescript-linux-arm": "7.0.2", "@typescript/typescript-linux-arm64": "7.0.2", "@typescript/typescript-linux-loong64": "7.0.2", "@typescript/typescript-linux-mips64el": "7.0.2", "@typescript/typescript-linux-ppc64": "7.0.2", "@typescript/typescript-linux-riscv64": "7.0.2", "@typescript/typescript-linux-s390x": "7.0.2", "@typescript/typescript-linux-x64": "7.0.2", "@typescript/typescript-netbsd-arm64": "7.0.2", "@typescript/typescript-netbsd-x64": "7.0.2", "@typescript/typescript-openbsd-arm64": "7.0.2", "@typescript/typescript-openbsd-x64": "7.0.2", "@typescript/typescript-sunos-x64": "7.0.2", "@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="], + + "undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="], + } +} diff --git a/docs/dependencies.md b/docs/dependencies.md new file mode 100644 index 0000000..1276244 --- /dev/null +++ b/docs/dependencies.md @@ -0,0 +1,42 @@ +# Tool and dependency audit + +Checked on 24 October 2026 against the official Bun and TypeScript releases and npm registry package metadata. + +| Tool/package | Selected | Latest | License | Scope | +| --- | --- | --- | --- | --- | +| Bun | 1.4.4 | 1.4.4 | MIT | Development runtime, bundler, formatter and test runner | +| `typescript` | 7.0.2 | 7.0.2 | Apache-2.0 | Strict project type checking and editor types | +| `@types/bun` | 1.4.4 | 1.4.4 | MIT | Bun development API definitions | +| `bun-types` | 1.4.4 | 1.4.4 | MIT | Transitive Bun definitions | +| `@types/node` | 26.6.5 | 26.6.5 | MIT | Transitive definitions for compatible system APIs | +| `@typescript/typescript-linux-x64` | 7.0.2 | 7.0.2 | Apache-2.0 | Native checker binary for the tested Linux x64 platform | +| `undici-types` | 8.9.0 | 8.12.3 globally; 8.9.0 within the parent's allowed range | MIT | Transitive fetch definitions | + +The latest `@types/node` constrains `undici-types` to `~8.9.0`. The lock uses the newest compatible version; no override bypasses that upstream constraint. Other optional TypeScript platform binaries in the lock are pinned to the same 7.0.2 release and are installed only on matching platforms. None of these packages is imported into browser code or required by Nginx in production. + +Bun was verified using the official Linux x64 release archive, SHA-256 `bf8ccbfb2b0b80159e0f9a6d15c55317add8077534dbc6130a3edb52fccb395c`. Project verification used a task-local copy of Bun 1.4.4; it did not change the workstation's global runtime. + +## Sources + +- [Official Bun 1.4.4 release](https://github.com/oven-sh/bun/releases/tag/bun-v1.4.4) +- [Official TypeScript 7.0.2 release](https://github.com/microsoft/TypeScript/releases/tag/v7.0.2) +- [Bun TypeScript documentation](https://bun.sh/docs/runtime/typescript) +- [Bun bundler documentation](https://bun.sh/docs/bundler) +- [TypeScript package metadata](https://registry.npmjs.org/typescript/latest) +- [Bun definitions metadata](https://registry.npmjs.org/@types/bun/latest) +- [Node definitions metadata and Undici range](https://registry.npmjs.org/@types/node/latest) +- [Undici definitions metadata](https://registry.npmjs.org/undici-types/latest) + +## Reproduction + +```sh +bun install --frozen-lockfile +bun outdated +bun pm ls --all +bun audit +bun run check +bun test +bun run build +``` + +The audit reported **no known vulnerabilities** across 25 checked lockfile packages. On Linux x64, six development packages were installed. `bun outdated` reported no outdated direct dependencies. The complete compatible resolution and integrity hashes are committed in `bun.lock`. diff --git a/docs/screenshots/README.md b/docs/screenshots/README.md new file mode 100644 index 0000000..0771177 --- /dev/null +++ b/docs/screenshots/README.md @@ -0,0 +1,9 @@ +# Website screenshots + +Captured on 24 October 2026 from `https://central.loki-code.dev` using a new anonymous Chromium context with Russian selected. + +- `landing-desktop.png`: project landing page, 1440 × 1000. +- `account-desktop.png`: anonymous account / GitHub sign-in, 1440 × 1000. +- `landing-mobile.png`: landing page, 390 × 844. + +No user logged in, no GitHub consent flow was started, and no private profiles, credentials or tokens are shown. These are actual website screenshots, not generated mockups. The labelled client illustration on the page remains illustrative; the native settings image embedded in the page is a real client screenshot. diff --git a/docs/screenshots/account-desktop.png b/docs/screenshots/account-desktop.png new file mode 100644 index 0000000..ad888a8 Binary files /dev/null and b/docs/screenshots/account-desktop.png differ diff --git a/docs/screenshots/landing-desktop.png b/docs/screenshots/landing-desktop.png new file mode 100644 index 0000000..0c3bce5 Binary files /dev/null and b/docs/screenshots/landing-desktop.png differ diff --git a/docs/screenshots/landing-mobile.png b/docs/screenshots/landing-mobile.png new file mode 100644 index 0000000..7e50012 Binary files /dev/null and b/docs/screenshots/landing-mobile.png differ diff --git a/docs/verification.md b/docs/verification.md index 7767679..8846554 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -1,13 +1,16 @@ # Verification -Verified locally on 24 October 2026: +Verified locally on 24 October 2026 using pinned Bun 1.4.4 and TypeScript 7.0.2: -- `npm test`: 7 Node tests passed, including exact catalog parity, authentication request options, malformed-session checks, avatar-origin validation and encoded preview-path traversal. -- `npm run build`: static build completed; assets normalized to mode 0644, directories 0755. -- `node --check src/app.js`: JavaScript syntax check passed. -- `python3 tests/browser_qa.py`: passed with the workstation's existing Playwright and `/usr/bin/chromium`; no browser or dependency was installed by this project. +- `bun install --frozen-lockfile`: committed resolution accepted without changes. +- `bun run check`: strict TypeScript check passed for frontend, Bun scripts and tests. +- `bun test`: 8 Bun tests passed, including catalog parity, authentication request options, malformed Hub/session checks, avatar-origin validation and encoded preview-path traversal. +- `bun run build`: TypeScript browser bundle and static build completed; assets normalized to mode 0644, directories 0755. Source TypeScript and development dependencies are excluded from the release. +- `bun run format:check`: Bun's built-in formatter passed. +- `bun audit`: no known vulnerabilities across 25 checked lockfile packages; direct dependencies are current. +- `python3 tests/browser_qa.py`: passed against both the Bun development preview and the minified production `dist/` preview with the workstation's existing Playwright and `/usr/bin/chromium`; no browser dependency was installed by this project. -The optional browser script requires the loopback preview from `npm run dev` or `npm run preview`. It replaces API responses with test fixtures and refuses non-loopback origins. It checks: +The optional browser script requires the loopback preview from `bun run dev` or `bun run preview`. It replaces API responses with test fixtures and refuses non-loopback origins. It checks: - Keyboard-operated illustration tabs and theme selection. - Runtime RU/EN changes and layouts at 320, 390, 768 and 1440 pixels, including account views. @@ -16,7 +19,7 @@ The optional browser script requires the loopback preview from `npm run dev` or - CSRF-header/Origin/POST sign-out and expired-session handling. - Browser storage contains only the UI language; no account tokens are persisted. -Screenshots were visually inspected at `/tmp/vnox-web-qa/desktop-hero.png`, `mobile-full.png`, `account-login-mobile.png` and `account-profile-desktop.png`. Screenshot profile data is explicitly a browser fixture, absent from production assets. +Local QA screenshots were visually inspected in `/tmp/vnox-web-qa/`. Any authenticated profile in those temporary images is explicitly a browser fixture. The repository-hosted [README screenshots](screenshots/README.md) were captured separately from the live production site using a fresh anonymous context and contain no test profile or private data. ## Limits diff --git a/package.json b/package.json index dbc56a9..f17398d 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,21 @@ "type": "module", "license": "GPL-3.0-only", "description": "VNOX public website and central account frontend", - "engines": { "node": ">=22" }, "scripts": { - "dev": "node scripts/serve.mjs", - "build": "node scripts/build.mjs", - "preview": "node scripts/serve.mjs --dist", - "test": "node --test" + "dev": "bun scripts/serve.ts", + "build": "bun run check && bun scripts/build.ts", + "preview": "bun scripts/serve.ts --dist", + "check": "bun x --bun --no-install tsc --noEmit", + "test": "bun test", + "format": "bun fmt src scripts tests public/index.html package.json tsconfig.json", + "format:check": "bun fmt --check src scripts tests public/index.html package.json tsconfig.json" + }, + "engines": { + "bun": ">=1.4.4" + }, + "packageManager": "bun@1.4.4", + "devDependencies": { + "@types/bun": "1.4.4", + "typescript": "7.0.2" } } diff --git a/public/index.html b/public/index.html index 2e1d278..6af066d 100644 --- a/public/index.html +++ b/public/index.html @@ -1,26 +1,75 @@ - - - - - - VNOX — Своя связь - - - - - - - -
- - - + + + + + + VNOX — Своя связь + + + + + + + +
+ + + diff --git a/scripts/browser.ts b/scripts/browser.ts new file mode 100644 index 0000000..4b9cde6 --- /dev/null +++ b/scripts/browser.ts @@ -0,0 +1,18 @@ +import { fileURLToPath } from "node:url"; + +export async function browserBundle(minify = false): Promise { + const result = await Bun.build({ + entrypoints: [fileURLToPath(new URL("../src/app.ts", import.meta.url))], + target: "browser", + format: "esm", + minify, + sourcemap: "none", + }); + if (!result.success || !result.outputs[0]) { + throw new AggregateError( + result.logs, + "Browser TypeScript compilation failed", + ); + } + return result.outputs[0]; +} diff --git a/scripts/build.mjs b/scripts/build.mjs deleted file mode 100644 index 3c09509..0000000 --- a/scripts/build.mjs +++ /dev/null @@ -1,17 +0,0 @@ -import { cp, mkdir, rm, chmod, readdir } from 'node:fs/promises'; -import { fileURLToPath } from 'node:url'; -const root = fileURLToPath(new URL('../', import.meta.url)); -await rm(`${root}dist`, { recursive: true, force: true }); -await mkdir(`${root}dist`, { recursive: true }); -await cp(`${root}public`, `${root}dist`, { recursive: true }); -await cp(`${root}src`, `${root}dist/src`, { recursive: true }); -async function permissions(directory) { - await chmod(directory, 0o755); - for (const entry of await readdir(directory, { withFileTypes: true })) { - const path = `${directory}/${entry.name}`; - if (entry.isDirectory()) await permissions(path); - else await chmod(path, 0o644); - } -} -await permissions(`${root}dist`); -console.log('Built dependency-free static website in dist/'); diff --git a/scripts/build.ts b/scripts/build.ts new file mode 100644 index 0000000..32fe06a --- /dev/null +++ b/scripts/build.ts @@ -0,0 +1,21 @@ +import { cp, mkdir, rm, chmod, readdir } from "node:fs/promises"; +import { fileURLToPath } from "node:url"; +import { browserBundle } from "./browser"; + +const root = fileURLToPath(new URL("../", import.meta.url)); +await rm(`${root}dist`, { recursive: true, force: true }); +await mkdir(`${root}dist/src`, { recursive: true }); +await cp(`${root}public`, `${root}dist`, { recursive: true }); +await cp(`${root}src/styles.css`, `${root}dist/src/styles.css`); +await Bun.write(`${root}dist/src/app.js`, await browserBundle(true)); + +async function permissions(directory: string): Promise { + await chmod(directory, 0o755); + for (const entry of await readdir(directory, { withFileTypes: true })) { + const path = `${directory}/${entry.name}`; + if (entry.isDirectory()) await permissions(path); + else await chmod(path, 0o644); + } +} +await permissions(`${root}dist`); +console.log("Built TypeScript browser bundle and static website in dist/"); diff --git a/scripts/serve.mjs b/scripts/serve.mjs deleted file mode 100644 index 5ecc84f..0000000 --- a/scripts/serve.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import { createServer } from 'node:http'; -import { readFile, stat } from 'node:fs/promises'; -import { fileURLToPath } from 'node:url'; -import { extname, resolve, sep } from 'node:path'; -const root = fileURLToPath(new URL('../', import.meta.url)); -const production = process.argv.includes('--dist'); -const port = Number(process.env.PORT ?? 4176); -const types = {'.html':'text/html; charset=utf-8','.js':'text/javascript; charset=utf-8','.css':'text/css; charset=utf-8','.svg':'image/svg+xml','.png':'image/png','.json':'application/json'}; -const server = createServer(async (request,response) => { - try { - const path = decodeURIComponent(new URL(request.url,'http://localhost').pathname); - if (request.method!=='GET' && request.method!=='HEAD') { response.writeHead(405);response.end();return; } - if (path.startsWith('/v1/') || ['/health','/ready','/version'].includes(path)) { - response.writeHead(503,{'content-type':'application/json','cache-control':'no-store'}); - response.end(JSON.stringify({error:'preview_has_no_backend'}));return; - } - const sourcePath = !production && path.startsWith('/src/'); - const base = production ? resolve(root,'dist') : sourcePath ? resolve(root,'src') : resolve(root,'public'); - let file = resolve(base, sourcePath ? path.slice('/src/'.length) : `.${path}`); - if (path==='/' || path==='/account' || path==='/account/') file=resolve(base,'index.html'); - if (!file.startsWith(base+sep)) { response.writeHead(403);response.end();return; } - const info=await stat(file); - if (!info.isFile()) throw new Error('not_file'); - response.writeHead(200,{'content-type':types[extname(file)]??'application/octet-stream','cache-control':'no-store','x-content-type-options':'nosniff'}); - response.end(request.method==='HEAD'?undefined:await readFile(file)); - } catch { response.writeHead(404,{'content-type':'text/plain'});response.end('Not found'); } -}); -server.listen(port,'127.0.0.1',()=>console.log(`VNOX Web: http://127.0.0.1:${port}`)); -for (const signal of ['SIGINT','SIGTERM']) process.on(signal,()=>server.close(()=>process.exit(0))); diff --git a/scripts/serve.ts b/scripts/serve.ts new file mode 100644 index 0000000..e6ebcfa --- /dev/null +++ b/scripts/serve.ts @@ -0,0 +1,74 @@ +import { stat } from "node:fs/promises"; +import { fileURLToPath } from "node:url"; +import { extname, resolve, sep } from "node:path"; +import { browserBundle } from "./browser"; + +const root = fileURLToPath(new URL("../", import.meta.url)); +const production = Bun.argv.includes("--dist"); +const port = Number(Bun.env.PORT ?? 4176); +const types: Record = { + ".html": "text/html; charset=utf-8", + ".js": "text/javascript; charset=utf-8", + ".css": "text/css; charset=utf-8", + ".svg": "image/svg+xml", + ".png": "image/png", +}; +const headers = { + "cache-control": "no-store", + "x-content-type-options": "nosniff", +}; + +const server = Bun.serve({ + port, + hostname: "127.0.0.1", + async fetch(request): Promise { + try { + const path = decodeURIComponent(new URL(request.url).pathname); + if (request.method !== "GET" && request.method !== "HEAD") + return new Response(null, { status: 405 }); + if (path.split("/").includes("..")) + return new Response(null, { status: 403 }); + if ( + path.startsWith("/v1/") || + ["/health", "/ready", "/version"].includes(path) + ) { + return Response.json( + { error: "preview_has_no_backend" }, + { status: 503, headers }, + ); + } + if (!production && path === "/src/app.js") { + const bundle = await browserBundle(); + return new Response(request.method === "HEAD" ? null : bundle, { + headers: { ...headers, "content-type": types[".js"]! }, + }); + } + const sourceStyle = !production && path === "/src/styles.css"; + const base = production + ? resolve(root, "dist") + : sourceStyle + ? resolve(root, "src") + : resolve(root, "public"); + let file = resolve(base, sourceStyle ? "styles.css" : `.${path}`); + if (path === "/" || path === "/account" || path === "/account/") + file = resolve(base, "index.html"); + if (!file.startsWith(base + sep)) + return new Response(null, { status: 403 }); + if (!(await stat(file)).isFile()) + return new Response("Not found", { status: 404 }); + return new Response(request.method === "HEAD" ? null : Bun.file(file), { + headers: { + ...headers, + "content-type": types[extname(file)] ?? "application/octet-stream", + }, + }); + } catch { + return new Response("Not found", { status: 404, headers }); + } + }, +}); +console.log(`VNOX Web: http://127.0.0.1:${server.port}`); +for (const signal of ["SIGINT", "SIGTERM"] as const) + process.on(signal, () => { + void server.stop(true).then(() => process.exit(0)); + }); diff --git a/src/api.js b/src/api.js deleted file mode 100644 index 5e3baca..0000000 --- a/src/api.js +++ /dev/null @@ -1,27 +0,0 @@ -export class ApiError extends Error { - constructor(status, code) { super(code); this.name = 'ApiError'; this.status = status; } -} -export async function request(path, { signal, method = 'GET', csrf, fetcher = fetch } = {}) { - if (!path.startsWith('/v1/')) throw new TypeError('Only same-origin VNOX API paths are allowed'); - const response = await fetcher(path, { - method, signal, credentials: 'same-origin', cache: 'no-store', - headers: { Accept: 'application/json', ...(csrf ? { 'X-CSRF-Token': csrf } : {}) }, - }); - if (!response.ok) throw new ApiError(response.status, 'request_failed'); - if (response.status === 204) return null; - return response.json(); -} -export function isSession(value) { - return value?.authenticated === false || (value?.authenticated === true - && typeof value.csrf_token === 'string' && value.csrf_token.length > 0 - && typeof value.user?.user_id === 'string' && typeof value.user?.handle === 'string' - && typeof value.user?.display_name === 'string'); -} -export function safeAvatar(value) { - if (typeof value !== 'string') return null; - try { - const url = new URL(value); - return url.protocol === 'https:' && url.hostname === 'avatars.githubusercontent.com' - && !url.username && !url.password && !url.port ? url.href : null; - } catch { return null; } -} diff --git a/src/api.ts b/src/api.ts new file mode 100644 index 0000000..027f11e --- /dev/null +++ b/src/api.ts @@ -0,0 +1,90 @@ +export interface User { + user_id: string; + handle: string; + display_name: string; + avatar_url?: string | null; +} +export type Session = + | { authenticated: false } + | { authenticated: true; user: User; csrf_token: string }; +export interface HubInfo { + capabilities: { github_auth: string }; +} +export interface RequestOptions { + signal?: AbortSignal; + method?: "GET" | "POST"; + csrf?: string; + fetcher?: (input: string, options: RequestInit) => Promise; +} +export class ApiError extends Error { + readonly status: number; + constructor(status: number, code: string) { + super(code); + this.name = "ApiError"; + this.status = status; + } +} +export async function request( + path: string, + { signal, method = "GET", csrf, fetcher = fetch }: RequestOptions = {}, +): Promise { + if (!path.startsWith("/v1/")) + throw new TypeError("Only same-origin VNOX API paths are allowed"); + const response = await fetcher(path, { + method, + signal, + credentials: "same-origin", + cache: "no-store", + headers: { + Accept: "application/json", + ...(csrf ? { "X-CSRF-Token": csrf } : {}), + }, + }); + if (!response.ok) throw new ApiError(response.status, "request_failed"); + if (response.status === 204) return null; + return response.json(); +} +function record(value: unknown): value is Record { + return typeof value === "object" && value !== null; +} +export function isSession(value: unknown): value is Session { + if (!record(value)) return false; + if (value.authenticated === false) return true; + if ( + value.authenticated !== true || + typeof value.csrf_token !== "string" || + value.csrf_token.length === 0 || + !record(value.user) + ) + return false; + return ( + typeof value.user.user_id === "string" && + typeof value.user.handle === "string" && + typeof value.user.display_name === "string" && + (value.user.avatar_url === undefined || + value.user.avatar_url === null || + typeof value.user.avatar_url === "string") + ); +} +export function isInfo(value: unknown): value is HubInfo { + return ( + record(value) && + record(value.capabilities) && + typeof value.capabilities.github_auth === "string" + ); +} +export function safeAvatar(value: unknown): string | null { + if (typeof value !== "string") return null; + try { + const url = new URL(value); + return url.protocol === "https:" && + url.hostname === "avatars.githubusercontent.com" && + !url.username && + !url.password && + !url.port + ? url.href + : null; + } catch { + return null; + } +} diff --git a/src/app.js b/src/app.js deleted file mode 100644 index 1938749..0000000 --- a/src/app.js +++ /dev/null @@ -1,165 +0,0 @@ -import { detectLanguage, translate } from './i18n.js'; -import { request, isSession, safeAvatar } from './api.js'; - -let savedLanguage; -try { savedLanguage = localStorage.getItem('vnox-web-language'); } catch { /* Storage is optional. */ } -let language = detectLanguage(savedLanguage, navigator.languages ?? [navigator.language]); -const accountPage = /^\/account\/?$/.test(location.pathname); -const main = document.querySelector('main'); -let activeTab = 'text'; -let activeTheme = 'dark'; -let controller; -let currentSession; -let githubEnabled = false; -let sessionState = 'loading'; -let infoState = 'loading'; -let logoutState = 'idle'; -const t = key => translate(language, key); -const icon = (name, size = 20) => { - const paths = { - github: '', - voice: '', - mic: '', - chat: '', - external: '', - check: '', - copy: '', - back: '', - }; - return ``; -}; -const tr = (key, tag = 'span', attrs = '') => `<${tag} data-i18n="${key}" ${attrs}>${t(key)}`; -const external = (href, key) => `${tr(key)}${icon('external', 15)}`; -function landing() { - main.innerHTML = ` -
-

${tr('development')}

${tr('heroTitle', 'h1', 'id="hero-title"')}${tr('heroText', 'p', 'class="hero-description"')} - ${tr('earlyNote','p','class="small hero-note"')}
-
${tr('diagramLabel')}
-
${tr('community')}
# ${tr('general')}
# ${tr('ideas')}
${icon('voice',16)}${tr('voiceRoom')}
${tr('you')}${tr('friend')}
V${tr('you')}${icon('mic',15)}
-
# ${tr('general')}${icon('chat',17)}
${tr('voiceConnected')}${icon('mic',16)}
-
${tr('diagramNote','p','class="small diagram-note"')} -
-
-
${tr('projectTitle','h2','id="project-title"')}${tr('projectText','p')}
${icon('chat',24)}
${tr('projectNative','h3')}${tr('projectNativeText','p')}
${icon('voice',24)}
${tr('projectServer','h3')}${tr('projectServerText','p')}
${tr('projectCentral','h3')}${tr('projectCentralText','p')}
-
${tr('clientTitle','h2','id="client-title"')}${tr('clientText','p')}
${t('clientScreenshot')}${tr('screenshotCaption','figcaption')}
${tr('appearanceTitle','h3')}${tr('appearanceText','p')}
${tr('identityTitle','h3')}${tr('identityText','p')}
-
${tr('roadmapTitle','h2','id="roadmap-title"')}${tr('roadmapText','p')}

${tr('available')}

  • ${tr('availableOne')}
  • ${tr('availableTwo')}
  • ${tr('availableThree')}
  • ${tr('availableFour')}
  • ${tr('availableFive')}

${tr('next')}

  • ${tr('nextOne')}
  • ${tr('nextTwo')}
  • ${tr('nextThree')}
${tr('downloadNote','p','class="release-note"')}
-
${tr('faqTitle','h2','id="faq-title"')}
${['Server','Central','Release'].map(key=>`
${tr(`faq${key}`)}${tr(`faq${key}Answer`,'p')}
`).join('')}
-

${t('statusLoading')}

${tr('openCentral')}${icon('external',15)}
`; - renderDiagram(); - main.querySelectorAll('[data-tab]').forEach(button => { - button.addEventListener('click', () => { activeTab = button.dataset.tab; renderDiagram(); }); - button.addEventListener('keydown', event => { - const tabs = [...main.querySelectorAll('[data-tab]')]; - let index = tabs.indexOf(button); - if (event.key === 'ArrowRight') index = (index + 1) % tabs.length; - else if (event.key === 'ArrowLeft') index = (index + tabs.length - 1) % tabs.length; - else if (event.key === 'Home') index = 0; - else if (event.key === 'End') index = tabs.length - 1; - else return; - event.preventDefault(); activeTab = tabs[index].dataset.tab; renderDiagram(); tabs[index].focus(); - }); - }); -} -function renderDiagram() { - const content = document.querySelector('#diagram-content'); - if (!content) return; - main.querySelectorAll('[data-tab]').forEach(button => { - const active = button.dataset.tab === activeTab; - button.setAttribute('aria-selected', String(active));button.tabIndex = active ? 0 : -1; - }); - content.setAttribute('role','tabpanel');content.setAttribute('aria-labelledby', `tab-${activeTab}`); - if (activeTab === 'text') content.innerHTML = `
V
${tr('community','strong')}
${tr('messageSample','p')}${tr('messageNote','p','class="diagram-caption"')}
`; - if (activeTab === 'voice') content.innerHTML = `
V${icon('voice',30)}
${tr('voiceExplain','p')}${tr('voiceCaption','p','class="diagram-caption"')}
`; - if (activeTab === 'theme') { - content.innerHTML = `
${tr('themeCaption','h3')}
${['light','dark','black','custom'].map(theme=>``).join('')}
`; - content.querySelectorAll('[data-theme]').forEach(button => button.addEventListener('click',()=>{ - activeTheme = button.dataset.theme; - document.querySelector('.product-diagram').dataset.previewTheme = activeTheme; - content.querySelectorAll('[data-theme]').forEach(item=>item.setAttribute('aria-pressed',String(item===button))); - })); - } -} -function account() { - main.innerHTML = ``; - renderAccount(); -} -function renderAccount() { - const panel = document.querySelector('#account-content'); - if (!panel) return; - panel.replaceChildren(); - if (sessionState === 'loading') { panel.innerHTML = ``;return; } - if (sessionState === 'error') { - panel.innerHTML = `${tr('accountError','h2')}${tr('accountErrorText','p')}`; - panel.querySelector('#retry-session').addEventListener('click',refresh);return; - } - if (currentSession?.authenticated) { - panel.innerHTML = `
${tr('profileTitle','h2')}

${tr('profileIntro','p')}
${tr('handle')}
${tr('userId')}
${tr('provider')}
GitHub

`; - const user = currentSession.user; - panel.querySelector('#profile-name').textContent = user.display_name || t('profileFallback'); - panel.querySelector('#profile-handle').textContent = user.handle; - panel.querySelector('#profile-id').textContent = user.user_id; - const avatar = safeAvatar(user.avatar_url); - if (avatar) { const image = document.createElement('img');image.src=avatar;image.alt='';image.referrerPolicy='no-referrer';image.addEventListener('error',()=>image.remove(),{once:true});panel.querySelector('#profile-avatar').append(image); } - panel.querySelector('#copy-id').addEventListener('click',async()=>{ - try { await navigator.clipboard.writeText(user.user_id); panel.querySelector('#profile-message').textContent=t('copied'); } - catch { panel.querySelector('#profile-message').textContent=t('copyError'); } - }); - panel.querySelector('#logout').addEventListener('click',logout); - if (logoutState==='error') panel.querySelector('#profile-message').textContent=t('logoutError'); - return; - } - panel.innerHTML = `${tr('loginTitle','h2')}${tr('loginText','p')}

${icon('check',16)}${tr('privacy','p')}
`; - panel.querySelector('#login-availability').textContent = infoState==='loading'?t('loginLoading'):infoState==='error'?t('loginUnavailable'):githubEnabled?'':t('loginDisabled'); - panel.querySelector('#retry-info').addEventListener('click',refresh); -} -async function logout() { - if (!currentSession?.authenticated || logoutState==='pending') return; - const csrf = currentSession.csrf_token; - logoutState='pending';renderAccount(); - try { - await request('/v1/auth/logout',{method:'POST',csrf,signal:AbortSignal.timeout(15000)}); - currentSession={authenticated:false};logoutState='idle';renderAccount(); - } catch(error) { - if (error.status===401) { currentSession={authenticated:false};logoutState='idle';renderAccount(); } - else { logoutState='error';renderAccount(); } - } -} -function updateStatus() { - const status = document.querySelector('#service-status'); - if (status) { status.textContent = t(infoState==='loading'?'statusLoading':infoState==='ready'?'statusReady':'statusUnavailable');document.querySelector('#service-dot').dataset.state=infoState; } -} -async function refresh() { - controller?.abort();controller=new AbortController(); - const currentController = controller; - const signal = AbortSignal.any([currentController.signal,AbortSignal.timeout(15000)]); - infoState='loading'; - if (accountPage) { sessionState='loading';renderAccount(); } else updateStatus(); - const info = request('/v1/info',{signal}).then(value=>{ - if (controller !== currentController) return; - if (typeof value?.capabilities?.github_auth !== 'string') throw new Error('invalid_info'); - githubEnabled=value.capabilities.github_auth==='enabled';infoState='ready'; - }).catch(()=>{if(!currentController.signal.aborted){githubEnabled=false;infoState='error';}}).finally(()=>{if(controller===currentController){updateStatus();if(accountPage)renderAccount();}}); - if (accountPage) { - await Promise.allSettled([info,request('/v1/auth/session',{signal}).then(value=>{ - if (controller !== currentController) return; - if (!isSession(value)) throw new Error('invalid_session'); - currentSession=value;sessionState='ready'; - }).catch(()=>{if(!currentController.signal.aborted)sessionState='error';}).finally(()=>{if(controller===currentController)renderAccount();})]); - } else await info; -} -function setLanguage(next) { - language=next; - try { localStorage.setItem('vnox-web-language',next); } catch { /* No authentication data is persisted. */ } - document.documentElement.lang=next; - document.title=t(accountPage?'accountTitle':'title'); - document.querySelector('meta[name="description"]').content=t('description'); - document.querySelectorAll('[data-i18n]').forEach(element=>element.textContent=t(element.dataset.i18n)); - for(const [attribute,dataKey] of [['aria-label','i18nAria'],['alt','i18nAlt']]) document.querySelectorAll(`[data-${attribute==='alt'?'i18n-alt':'i18n-aria'}]`).forEach(element=>element.setAttribute(attribute,t(element.dataset[dataKey]))); - document.querySelectorAll('[data-language]').forEach(button=>button.setAttribute('aria-pressed',String(button.dataset.language===next))); - if (accountPage) renderAccount();else {renderDiagram();updateStatus();} -} -if(accountPage) account();else landing(); -document.querySelectorAll('[data-language]').forEach(button=>button.addEventListener('click',()=>setLanguage(button.dataset.language))); -setLanguage(language);refresh(); -window.addEventListener('pageshow',event=>{if(event.persisted)refresh();}); diff --git a/src/app.ts b/src/app.ts new file mode 100644 index 0000000..637ecf7 --- /dev/null +++ b/src/app.ts @@ -0,0 +1,338 @@ +import type { Language, MessageKey } from "./i18n"; +import type { Session } from "./api"; +import { detectLanguage, translate } from "./i18n"; +import { request, isSession, isInfo, safeAvatar, ApiError } from "./api"; + +let savedLanguage: string | null | undefined; +try { + savedLanguage = localStorage.getItem("vnox-web-language"); +} catch { + /* Storage is optional. */ +} +let language = detectLanguage( + savedLanguage, + navigator.languages ?? [navigator.language], +); +const accountPage = /^\/account\/?$/.test(location.pathname); +function find( + selector: string, + root: ParentNode = document, +): T { + const element = root.querySelector(selector); + if (!element) throw new Error(`Missing required element: ${selector}`); + return element; +} +const main = find("main"); +type Tab = "text" | "voice" | "theme"; +type Theme = "light" | "dark" | "black" | "custom"; +let activeTab: Tab = "text"; +let activeTheme: Theme = "dark"; +let controller: AbortController | undefined; +let currentSession: Session | null = null; +let githubEnabled = false; +let sessionState: "loading" | "ready" | "error" = "loading"; +let infoState: "loading" | "ready" | "error" = "loading"; +let logoutState: "idle" | "pending" | "error" = "idle"; +const t = (key: MessageKey) => translate(language, key); +const icon = ( + name: + | "github" + | "voice" + | "mic" + | "chat" + | "external" + | "check" + | "copy" + | "back", + size = 20, +) => { + const paths = { + github: + '', + voice: + '', + mic: '', + chat: '', + external: + '', + check: '', + copy: '', + back: '', + }; + return ``; +}; +const tr = (key: MessageKey, tag = "span", attrs = "") => + `<${tag} data-i18n="${key}" ${attrs}>${t(key)}`; +const external = (href: string, key: MessageKey) => + `${tr(key)}${icon("external", 15)}`; +function landing() { + main.innerHTML = ` +
+

${tr("development")}

${tr("heroTitle", "h1", 'id="hero-title"')}${tr("heroText", "p", 'class="hero-description"')} + ${tr("earlyNote", "p", 'class="small hero-note"')}
+
${tr("diagramLabel")}
+
${tr("community")}
# ${tr("general")}
# ${tr("ideas")}
${icon("voice", 16)}${tr("voiceRoom")}
${tr("you")}${tr("friend")}
V${tr("you")}${icon("mic", 15)}
+
# ${tr("general")}${icon("chat", 17)}
${tr("voiceConnected")}${icon("mic", 16)}
+
${tr("diagramNote", "p", 'class="small diagram-note"')} +
+
+
${tr("projectTitle", "h2", 'id="project-title"')}${tr("projectText", "p")}
${icon("chat", 24)}
${tr("projectNative", "h3")}${tr("projectNativeText", "p")}
${icon("voice", 24)}
${tr("projectServer", "h3")}${tr("projectServerText", "p")}
${tr("projectCentral", "h3")}${tr("projectCentralText", "p")}
+
${tr("clientTitle", "h2", 'id="client-title"')}${tr("clientText", "p")}
${t(${tr("screenshotCaption", "figcaption")}
${tr("appearanceTitle", "h3")}${tr("appearanceText", "p")}
${tr("identityTitle", "h3")}${tr("identityText", "p")}
+
${tr("roadmapTitle", "h2", 'id="roadmap-title"')}${tr("roadmapText", "p")}

${tr("available")}

  • ${tr("availableOne")}
  • ${tr("availableTwo")}
  • ${tr("availableThree")}
  • ${tr("availableFour")}
  • ${tr("availableFive")}

${tr("next")}

  • ${tr("nextOne")}
  • ${tr("nextTwo")}
  • ${tr("nextThree")}
${tr("downloadNote", "p", 'class="release-note"')}
+
${tr("faqTitle", "h2", 'id="faq-title"')}
${(["Server", "Central", "Release"] as const).map((key) => `
${tr(`faq${key}`)}${tr(`faq${key}Answer`, "p")}
`).join("")}
+

${t("statusLoading")}

${tr("openCentral")}${icon("external", 15)}
`; + renderDiagram(); + main.querySelectorAll("[data-tab]").forEach((button) => { + button.addEventListener("click", () => { + activeTab = button.dataset.tab as Tab; + renderDiagram(); + }); + button.addEventListener("keydown", (event) => { + const tabs = [...main.querySelectorAll("[data-tab]")]; + let index = tabs.indexOf(button); + if (event.key === "ArrowRight") index = (index + 1) % tabs.length; + else if (event.key === "ArrowLeft") + index = (index + tabs.length - 1) % tabs.length; + else if (event.key === "Home") index = 0; + else if (event.key === "End") index = tabs.length - 1; + else return; + event.preventDefault(); + activeTab = tabs[index]!.dataset.tab as Tab; + renderDiagram(); + tabs[index]!.focus(); + }); + }); +} +function renderDiagram() { + const content = document.querySelector("#diagram-content"); + if (!content) return; + main.querySelectorAll("[data-tab]").forEach((button) => { + const active = button.dataset.tab === activeTab; + button.setAttribute("aria-selected", String(active)); + button.tabIndex = active ? 0 : -1; + }); + content.setAttribute("role", "tabpanel"); + content.setAttribute("aria-labelledby", `tab-${activeTab}`); + if (activeTab === "text") + content.innerHTML = `
V
${tr("community", "strong")}
${tr("messageSample", "p")}${tr("messageNote", "p", 'class="diagram-caption"')}
`; + if (activeTab === "voice") + content.innerHTML = `
V${icon("voice", 30)}
${tr("voiceExplain", "p")}${tr("voiceCaption", "p", 'class="diagram-caption"')}
`; + if (activeTab === "theme") { + content.innerHTML = `
${tr("themeCaption", "h3")}
${(["light", "dark", "black", "custom"] as const).map((theme) => ``).join("")}
`; + content.querySelectorAll("[data-theme]").forEach((button) => + button.addEventListener("click", () => { + activeTheme = button.dataset.theme as Theme; + find(".product-diagram").dataset.previewTheme = activeTheme; + content + .querySelectorAll("[data-theme]") + .forEach((item) => + item.setAttribute("aria-pressed", String(item === button)), + ); + }), + ); + } +} +function account() { + main.innerHTML = ``; + renderAccount(); +} +function renderAccount() { + const panel = document.querySelector("#account-content"); + if (!panel) return; + panel.replaceChildren(); + if (sessionState === "loading") { + panel.innerHTML = ``; + return; + } + if (sessionState === "error") { + panel.innerHTML = `${tr("accountError", "h2")}${tr("accountErrorText", "p")}`; + find("#retry-session", panel).addEventListener("click", refresh); + return; + } + if (currentSession?.authenticated) { + panel.innerHTML = `
${tr("profileTitle", "h2")}

${tr("profileIntro", "p")}
${tr("handle")}
${tr("userId")}
${tr("provider")}
GitHub

`; + const user = currentSession.user; + find("#profile-name", panel).textContent = + user.display_name || t("profileFallback"); + find("#profile-handle", panel).textContent = user.handle; + find("#profile-id", panel).textContent = user.user_id; + const avatar = safeAvatar(user.avatar_url); + if (avatar) { + const image = document.createElement("img"); + image.src = avatar; + image.alt = ""; + image.referrerPolicy = "no-referrer"; + image.addEventListener("error", () => image.remove(), { once: true }); + find("#profile-avatar", panel).append(image); + } + find("#copy-id", panel).addEventListener("click", async () => { + try { + await navigator.clipboard.writeText(user.user_id); + find("#profile-message", panel).textContent = t("copied"); + } catch { + find("#profile-message", panel).textContent = t("copyError"); + } + }); + find("#logout", panel).addEventListener("click", logout); + if (logoutState === "error") + find("#profile-message", panel).textContent = t("logoutError"); + return; + } + panel.innerHTML = `${tr("loginTitle", "h2")}${tr("loginText", "p")}

${icon("check", 16)}${tr("privacy", "p")}
`; + find("#login-availability", panel).textContent = + infoState === "loading" + ? t("loginLoading") + : infoState === "error" + ? t("loginUnavailable") + : githubEnabled + ? "" + : t("loginDisabled"); + find("#retry-info", panel).addEventListener("click", refresh); +} +async function logout() { + if (!currentSession?.authenticated || logoutState === "pending") return; + const csrf = currentSession.csrf_token; + logoutState = "pending"; + renderAccount(); + try { + await request("/v1/auth/logout", { + method: "POST", + csrf, + signal: AbortSignal.timeout(15000), + }); + currentSession = { authenticated: false }; + logoutState = "idle"; + renderAccount(); + } catch (error) { + if (error instanceof ApiError && error.status === 401) { + currentSession = { authenticated: false }; + logoutState = "idle"; + renderAccount(); + } else { + logoutState = "error"; + renderAccount(); + } + } +} +function updateStatus() { + const status = document.querySelector("#service-status"); + if (status) { + status.textContent = t( + infoState === "loading" + ? "statusLoading" + : infoState === "ready" + ? "statusReady" + : "statusUnavailable", + ); + find("#service-dot").dataset.state = infoState; + } +} +async function refresh() { + controller?.abort(); + controller = new AbortController(); + const currentController = controller; + const signal = AbortSignal.any([ + currentController.signal, + AbortSignal.timeout(15000), + ]); + infoState = "loading"; + if (accountPage) { + sessionState = "loading"; + renderAccount(); + } else updateStatus(); + const info = request("/v1/info", { signal }) + .then((value) => { + if (controller !== currentController) return; + if (!isInfo(value)) throw new Error("invalid_info"); + githubEnabled = value.capabilities.github_auth === "enabled"; + infoState = "ready"; + }) + .catch(() => { + if (!currentController.signal.aborted) { + githubEnabled = false; + infoState = "error"; + } + }) + .finally(() => { + if (controller === currentController) { + updateStatus(); + if (accountPage) renderAccount(); + } + }); + if (accountPage) { + await Promise.allSettled([ + info, + request("/v1/auth/session", { signal }) + .then((value) => { + if (controller !== currentController) return; + if (!isSession(value)) throw new Error("invalid_session"); + currentSession = value; + sessionState = "ready"; + }) + .catch(() => { + if (!currentController.signal.aborted) sessionState = "error"; + }) + .finally(() => { + if (controller === currentController) renderAccount(); + }), + ]); + } else await info; +} +function setLanguage(next: Language) { + language = next; + try { + localStorage.setItem("vnox-web-language", next); + } catch { + /* No authentication data is persisted. */ + } + document.documentElement.lang = next; + document.title = t(accountPage ? "accountTitle" : "title"); + find('meta[name="description"]').content = t("description"); + document + .querySelectorAll("[data-i18n]") + .forEach( + (element) => + (element.textContent = t(element.dataset.i18n as MessageKey)), + ); + for (const [attribute, dataKey] of [ + ["aria-label", "i18nAria"], + ["alt", "i18nAlt"], + ] as const) + document + .querySelectorAll( + `[data-${attribute === "alt" ? "i18n-alt" : "i18n-aria"}]`, + ) + .forEach((element) => + element.setAttribute( + attribute, + t(element.dataset[dataKey] as MessageKey), + ), + ); + document + .querySelectorAll("[data-language]") + .forEach((button) => + button.setAttribute( + "aria-pressed", + String(button.dataset.language === next), + ), + ); + if (accountPage) renderAccount(); + else { + renderDiagram(); + updateStatus(); + } +} +if (accountPage) account(); +else landing(); +document + .querySelectorAll("[data-language]") + .forEach((button) => + button.addEventListener("click", () => + setLanguage(button.dataset.language as Language), + ), + ); +setLanguage(language); +refresh(); +window.addEventListener("pageshow", (event) => { + if (event.persisted) refresh(); +}); diff --git a/src/i18n.js b/src/i18n.js deleted file mode 100644 index 5bf96a5..0000000 --- a/src/i18n.js +++ /dev/null @@ -1,31 +0,0 @@ -export const messages = { - ru: { - skip:'Перейти к содержимому', nav:'Основная навигация', navProject:'Проект', navClient:'Клиент', navRoadmap:'Дальше', language:'Язык', account:'Аккаунт', footer:'Сделано для разговоров, которые хочется продолжать.', source:'Исходный код', - title:'VNOX — Своя связь', accountTitle:'Аккаунт — VNOX Central', description:'VNOX — голос и чат для своих сообществ. Нативный клиент, собственный сервер и открытый код.', - development:'В открытой разработке', heroTitle:'Свои люди.\nСвоя связь.', heroText:'Место для вашего сообщества. Обсуждайте планы, оставайтесь в голосе и управляйте своим сервером сами.', openCentral:'Открыть Vnox Central', explore:'О проекте', earlyNote:'Ранняя версия. Разрабатываем открыто, без обещаний на вырост.', - diagramLabel:'Схема общения', diagramNote:'Иллюстрация устройства клиента', textTab:'Текст', voiceTab:'Голос', themeTab:'Внешний вид', community:'Ваше сообщество', general:'общий', ideas:'идеи', voiceRoom:'Вечерний войс', voiceConnected:'Голос остаётся с вами', voiceExplain:'Переключайте текстовые каналы, не выходя из разговора.', you:'Вы', friend:'Друг', messageSample:'Общий чат для идей, ссылок и планов.', messageNote:'Чат и голос доступны в одном окне.', voiceCaption:'Отдельное управление микрофоном и звуком.', themeCaption:'Четыре варианта. Один ваш.', light:'Светлая', dark:'Тёмная', black:'Мега-тёмная', custom:'Своя', preview:'Предпросмотр', previewTheme:'Тема иллюстрации', - projectTitle:'Одно приложение.\nВаш сервер.', projectText:'VNOX объединяет текст и голос в нативном клиенте. Сервер сообщества запускается одним приложением и остаётся под управлением его владельца.', projectNative:'Нативный клиент', projectNativeText:'Написан на Rust и Slint. Настройки звука, профиля и внешнего вида собраны в одном месте.', projectServer:'Сервер сообщества', projectServerText:'Текстовые каналы и голос в одном серверном приложении. Владелец выбирает, где его запускать.', projectCentral:'Vnox Central', projectCentralText:'Центральный сервис для аккаунта. Каталог серверов и друзья — следующие этапы разработки.', clientCode:'Код клиента', serverCode:'Код сервера', - clientTitle:'Удобство начинается\nс простых вещей.', clientText:'Светлая, тёмная, мега-тёмная или собственная тема. Размер текста, звук и профиль — там, где их ожидаешь найти.', clientScreenshot:'Настройки внешнего вида нативного клиента VNOX: четыре темы и размер текста.', screenshotCaption:'Настоящий снимок нативного клиента. Интерфейс продолжает развиваться.', appearanceTitle:'Внешний вид — ваш', appearanceText:'Своя палитра через поддерживаемые CSS-переменные. Без загрузки внешних ресурсов.', identityTitle:'Профиль без суеты', identityText:'Выберите фотографию, настройте масштаб и положение в круглом предпросмотре.', - roadmapTitle:'Сначала надёжная связь.\nПотом всё остальное.', roadmapText:'Проект ещё в разработке. Здесь разделены доступные части и то, над чем мы работаем.', available:'Уже в коде', next:'В работе и планах', availableOne:'Нативный клиент, каналы и голос', availableTwo:'Настройки, темы и редактор аватара', availableThree:'Центральный сервис и защищённое соединение', availableFour:'Веб-аккаунт GitHub и интерфейс RU / EN', availableFive:'Входящие и подписанные исходящие вебхуки на сервере', nextOne:'Управление вебхуками в клиенте', nextTwo:'Трансляция экрана с раздельным звуком', nextThree:'Друзья и поиск серверов', downloadNote:'Публичные сборки появятся после проверки совместимости клиента и сервера. Пока доступны исходники.', - faqTitle:'До первого разговора', faqServer:'Нужен ли отдельный голосовой сервер?', faqServerAnswer:'Нет. Для сообщества планируется одно серверное приложение, которое включает чат и голос.', faqCentral:'Зачем нужен Vnox Central?', faqCentralAnswer:'Для общего аккаунта и будущих социальных функций. Само сообщество размещает свой сервер отдельно.', faqRelease:'Где скачать клиент?', faqReleaseAnswer:'Проверенного публичного релиза пока нет. Код клиента и сервера открыт; инструкции по сборке находятся в их репозиториях.', - statusLoading:'Проверяем Vnox Central…', statusReady:'Vnox Central отвечает', statusUnavailable:'Не удалось связаться с Vnox Central', statusNote:'Состояние центрального сервиса', retry:'Повторить', - back:'На главную', accountHeading:'Ваш Vnox Central.', accountIntro:'Один аккаунт для будущих сообществ. Начните с безопасного входа через GitHub.', loginTitle:'Продолжить с GitHub', loginText:'VNOX получает ваш публичный профиль GitHub. Доступ к репозиториям для входа не запрашивается.', loginButton:'Войти через GitHub', loginLoading:'Проверяем возможность входа…', loginDisabled:'Вход через GitHub пока не включён на сервере.', loginUnavailable:'Не удалось проверить доступность входа. Повторите попытку.', privacy:'Авторизация происходит на github.com. Пароль GitHub остаётся у GitHub.', accountStage:'Центральный аккаунт пока не привязывается к локальным ключам настольного клиента. Друзья, серверы и сообщения появятся позже.', sessionLoading:'Загружаем аккаунт…', profileTitle:'Вы на связи.', profileIntro:'Вход через GitHub выполнен. Это ваш центральный аккаунт VNOX.', handle:'Имя аккаунта', userId:'ID аккаунта', provider:'Способ входа', logout:'Выйти из аккаунта', loggingOut:'Выходим…', logoutError:'Не удалось выйти. Повторите попытку.', sessionExpired:'Сессия завершилась. Войдите снова.', profileFallback:'Пользователь VNOX', accountError:'Аккаунт сейчас недоступен', accountErrorText:'Не удалось загрузить сессию. Проверьте соединение и повторите попытку.', copy:'Скопировать ID', copied:'ID скопирован', copyError:'Не удалось скопировать ID. Выделите его вручную.', - }, - en: { - skip:'Skip to content', nav:'Main navigation', navProject:'Project', navClient:'Client', navRoadmap:'What’s next', language:'Language', account:'Account', footer:'Made for conversations you want to continue.', source:'Source code', - title:'VNOX — Your own connection', accountTitle:'Account — VNOX Central', description:'VNOX brings voice and chat to your community. Native client, your own server, open source.', - development:'In open development', heroTitle:'Your people.\nYour connection.', heroText:'A place for your community. Share your plans, stay in voice and run your server on your terms.', openCentral:'Open Vnox Central', explore:'Explore the project', earlyNote:'An early version, developed in the open.', - diagramLabel:'How you stay connected', diagramNote:'An illustration of the client layout', textTab:'Text', voiceTab:'Voice', themeTab:'Appearance', community:'Your community', general:'general', ideas:'ideas', voiceRoom:'Evening voice', voiceConnected:'Voice stays with you', voiceExplain:'Browse text channels without leaving the conversation.', you:'You', friend:'Friend', messageSample:'A shared chat for ideas, links and plans.', messageNote:'Chat and voice, together in one window.', voiceCaption:'Separate controls for your microphone and sound.', themeCaption:'Four options. One that’s yours.', light:'Light', dark:'Dark', black:'Mega dark', custom:'Custom', preview:'Preview', previewTheme:'Illustration theme', - projectTitle:'One application.\nYour own server.', projectText:'VNOX brings text and voice together in a native client. One server application runs your community, under its owner’s control.', projectNative:'Native client', projectNativeText:'Built with Rust and Slint. Audio, profile and appearance settings, all in one place.', projectServer:'Community server', projectServerText:'Text channels and voice in one server application. Its owner chooses where to run it.', projectCentral:'Vnox Central', projectCentralText:'The central service for your account. Server discovery and friends are the next stages.', clientCode:'Client source', serverCode:'Server source', - clientTitle:'Comfort starts\nwith simple things.', clientText:'Light, dark, mega dark or your own theme. Text size, audio and your profile, right where you expect them.', clientScreenshot:'Appearance settings in the native VNOX client, with four themes and a text size slider.', screenshotCaption:'A real screenshot of the native client. The interface is still evolving.', appearanceTitle:'Make it yours', appearanceText:'Create your palette with supported CSS variables. No external resources are loaded.', identityTitle:'A profile without the fuss', identityText:'Choose a photo, then adjust its zoom and position inside a circular preview.', - roadmapTitle:'Reliable conversation first.\nThe rest comes next.', roadmapText:'VNOX is still being developed. Here is what exists in the code and what we’re building next.', available:'Already in the code', next:'In progress and planned', availableOne:'Native client, channels and voice', availableTwo:'Settings, themes and avatar editor', availableThree:'Central service and HTTPS', availableFour:'GitHub web account and RU / EN interface', availableFive:'Incoming and signed outgoing server webhooks', nextOne:'Webhook management in the client', nextTwo:'Screen broadcasting with separate audio sources', nextThree:'Friends and server discovery', downloadNote:'Public builds will follow client and server compatibility checks. Source code is available now.', - faqTitle:'Before the first conversation', faqServer:'Do I need a separate voice server?', faqServerAnswer:'No. A community is intended to run one server application with both chat and voice.', faqCentral:'What is Vnox Central for?', faqCentralAnswer:'Your shared account and future social features. Each community hosts its own server separately.', faqRelease:'Where can I download the client?', faqReleaseAnswer:'There is no verified public release yet. Client and server code is open, with build instructions in their repositories.', - statusLoading:'Checking Vnox Central…', statusReady:'Vnox Central is responding', statusUnavailable:'Could not reach Vnox Central', statusNote:'Central service status', retry:'Try again', - back:'Back to home', accountHeading:'Your Vnox Central.', accountIntro:'One account for future communities. Start with secure GitHub sign-in.', loginTitle:'Continue with GitHub', loginText:'VNOX receives your public GitHub profile. Signing in does not request access to your repositories.', loginButton:'Sign in with GitHub', loginLoading:'Checking sign-in availability…', loginDisabled:'GitHub sign-in is not enabled on the server yet.', loginUnavailable:'Could not check sign-in availability. Try again.', privacy:'You authorize on github.com. Your GitHub password stays with GitHub.', accountStage:'Your central account is not yet linked to the desktop client’s local keys. Friends, servers and messages will follow.', sessionLoading:'Loading your account…', profileTitle:'You’re connected.', profileIntro:'Signed in with GitHub. This is your central VNOX account.', handle:'Account handle', userId:'Account ID', provider:'Signed in with', logout:'Sign out', loggingOut:'Signing out…', logoutError:'Could not sign out. Try again.', sessionExpired:'Your session ended. Sign in again.', profileFallback:'VNOX user', accountError:'Your account is currently unavailable', accountErrorText:'Could not load your session. Check your connection and try again.', copy:'Copy account ID', copied:'Account ID copied', copyError:'Could not copy the ID. Select it manually.', - }, -}; -export function detectLanguage(saved, languages = []) { - if (saved === 'ru' || saved === 'en') return saved; - return languages.some(value => /^ru(?:-|$)/i.test(value)) ? 'ru' : 'en'; -} -export function translate(language, key) { return messages[language]?.[key] ?? messages.en[key] ?? key; } diff --git a/src/i18n.ts b/src/i18n.ts new file mode 100644 index 0000000..e36272f --- /dev/null +++ b/src/i18n.ts @@ -0,0 +1,284 @@ +export const messages = { + ru: { + skip: "Перейти к содержимому", + nav: "Основная навигация", + navProject: "Проект", + navClient: "Клиент", + navRoadmap: "Дальше", + language: "Язык", + account: "Аккаунт", + footer: "Сделано для разговоров, которые хочется продолжать.", + source: "Исходный код", + title: "VNOX — Своя связь", + accountTitle: "Аккаунт — VNOX Central", + description: + "VNOX — голос и чат для своих сообществ. Нативный клиент, собственный сервер и открытый код.", + development: "В открытой разработке", + heroTitle: "Свои люди.\nСвоя связь.", + heroText: + "Место для вашего сообщества. Обсуждайте планы, оставайтесь в голосе и управляйте своим сервером сами.", + openCentral: "Открыть Vnox Central", + explore: "О проекте", + earlyNote: "Ранняя версия. Разрабатываем открыто, без обещаний на вырост.", + diagramLabel: "Схема общения", + diagramNote: "Иллюстрация устройства клиента", + textTab: "Текст", + voiceTab: "Голос", + themeTab: "Внешний вид", + community: "Ваше сообщество", + general: "общий", + ideas: "идеи", + voiceRoom: "Вечерний войс", + voiceConnected: "Голос остаётся с вами", + voiceExplain: "Переключайте текстовые каналы, не выходя из разговора.", + you: "Вы", + friend: "Друг", + messageSample: "Общий чат для идей, ссылок и планов.", + messageNote: "Чат и голос доступны в одном окне.", + voiceCaption: "Отдельное управление микрофоном и звуком.", + themeCaption: "Четыре варианта. Один ваш.", + light: "Светлая", + dark: "Тёмная", + black: "Мега-тёмная", + custom: "Своя", + preview: "Предпросмотр", + previewTheme: "Тема иллюстрации", + projectTitle: "Одно приложение.\nВаш сервер.", + projectText: + "VNOX объединяет текст и голос в нативном клиенте. Сервер сообщества запускается одним приложением и остаётся под управлением его владельца.", + projectNative: "Нативный клиент", + projectNativeText: + "Написан на Rust и Slint. Настройки звука, профиля и внешнего вида собраны в одном месте.", + projectServer: "Сервер сообщества", + projectServerText: + "Текстовые каналы и голос в одном серверном приложении. Владелец выбирает, где его запускать.", + projectCentral: "Vnox Central", + projectCentralText: + "Центральный сервис для аккаунта. Каталог серверов и друзья — следующие этапы разработки.", + clientCode: "Код клиента", + serverCode: "Код сервера", + clientTitle: "Удобство начинается\nс простых вещей.", + clientText: + "Светлая, тёмная, мега-тёмная или собственная тема. Размер текста, звук и профиль — там, где их ожидаешь найти.", + clientScreenshot: + "Настройки внешнего вида нативного клиента VNOX: четыре темы и размер текста.", + screenshotCaption: + "Настоящий снимок нативного клиента. Интерфейс продолжает развиваться.", + appearanceTitle: "Внешний вид — ваш", + appearanceText: + "Своя палитра через поддерживаемые CSS-переменные. Без загрузки внешних ресурсов.", + identityTitle: "Профиль без суеты", + identityText: + "Выберите фотографию, настройте масштаб и положение в круглом предпросмотре.", + roadmapTitle: "Сначала надёжная связь.\nПотом всё остальное.", + roadmapText: + "Проект ещё в разработке. Здесь разделены доступные части и то, над чем мы работаем.", + available: "Уже в коде", + next: "В работе и планах", + availableOne: "Нативный клиент, каналы и голос", + availableTwo: "Настройки, темы и редактор аватара", + availableThree: "Центральный сервис и защищённое соединение", + availableFour: "Веб-аккаунт GitHub и интерфейс RU / EN", + availableFive: "Входящие и подписанные исходящие вебхуки на сервере", + nextOne: "Управление вебхуками в клиенте", + nextTwo: "Трансляция экрана с раздельным звуком", + nextThree: "Друзья и поиск серверов", + downloadNote: + "Публичные сборки появятся после проверки совместимости клиента и сервера. Пока доступны исходники.", + faqTitle: "До первого разговора", + faqServer: "Нужен ли отдельный голосовой сервер?", + faqServerAnswer: + "Нет. Для сообщества планируется одно серверное приложение, которое включает чат и голос.", + faqCentral: "Зачем нужен Vnox Central?", + faqCentralAnswer: + "Для общего аккаунта и будущих социальных функций. Само сообщество размещает свой сервер отдельно.", + faqRelease: "Где скачать клиент?", + faqReleaseAnswer: + "Проверенного публичного релиза пока нет. Код клиента и сервера открыт; инструкции по сборке находятся в их репозиториях.", + statusLoading: "Проверяем Vnox Central…", + statusReady: "Vnox Central отвечает", + statusUnavailable: "Не удалось связаться с Vnox Central", + statusNote: "Состояние центрального сервиса", + retry: "Повторить", + back: "На главную", + accountHeading: "Ваш Vnox Central.", + accountIntro: + "Один аккаунт для будущих сообществ. Начните с безопасного входа через GitHub.", + loginTitle: "Продолжить с GitHub", + loginText: + "VNOX получает ваш публичный профиль GitHub. Доступ к репозиториям для входа не запрашивается.", + loginButton: "Войти через GitHub", + loginLoading: "Проверяем возможность входа…", + loginDisabled: "Вход через GitHub пока не включён на сервере.", + loginUnavailable: + "Не удалось проверить доступность входа. Повторите попытку.", + privacy: + "Авторизация происходит на github.com. Пароль GitHub остаётся у GitHub.", + accountStage: + "Центральный аккаунт пока не привязывается к локальным ключам настольного клиента. Друзья, серверы и сообщения появятся позже.", + sessionLoading: "Загружаем аккаунт…", + profileTitle: "Вы на связи.", + profileIntro: + "Вход через GitHub выполнен. Это ваш центральный аккаунт VNOX.", + handle: "Имя аккаунта", + userId: "ID аккаунта", + provider: "Способ входа", + logout: "Выйти из аккаунта", + loggingOut: "Выходим…", + logoutError: "Не удалось выйти. Повторите попытку.", + sessionExpired: "Сессия завершилась. Войдите снова.", + profileFallback: "Пользователь VNOX", + accountError: "Аккаунт сейчас недоступен", + accountErrorText: + "Не удалось загрузить сессию. Проверьте соединение и повторите попытку.", + copy: "Скопировать ID", + copied: "ID скопирован", + copyError: "Не удалось скопировать ID. Выделите его вручную.", + }, + en: { + skip: "Skip to content", + nav: "Main navigation", + navProject: "Project", + navClient: "Client", + navRoadmap: "What’s next", + language: "Language", + account: "Account", + footer: "Made for conversations you want to continue.", + source: "Source code", + title: "VNOX — Your own connection", + accountTitle: "Account — VNOX Central", + description: + "VNOX brings voice and chat to your community. Native client, your own server, open source.", + development: "In open development", + heroTitle: "Your people.\nYour connection.", + heroText: + "A place for your community. Share your plans, stay in voice and run your server on your terms.", + openCentral: "Open Vnox Central", + explore: "Explore the project", + earlyNote: "An early version, developed in the open.", + diagramLabel: "How you stay connected", + diagramNote: "An illustration of the client layout", + textTab: "Text", + voiceTab: "Voice", + themeTab: "Appearance", + community: "Your community", + general: "general", + ideas: "ideas", + voiceRoom: "Evening voice", + voiceConnected: "Voice stays with you", + voiceExplain: "Browse text channels without leaving the conversation.", + you: "You", + friend: "Friend", + messageSample: "A shared chat for ideas, links and plans.", + messageNote: "Chat and voice, together in one window.", + voiceCaption: "Separate controls for your microphone and sound.", + themeCaption: "Four options. One that’s yours.", + light: "Light", + dark: "Dark", + black: "Mega dark", + custom: "Custom", + preview: "Preview", + previewTheme: "Illustration theme", + projectTitle: "One application.\nYour own server.", + projectText: + "VNOX brings text and voice together in a native client. One server application runs your community, under its owner’s control.", + projectNative: "Native client", + projectNativeText: + "Built with Rust and Slint. Audio, profile and appearance settings, all in one place.", + projectServer: "Community server", + projectServerText: + "Text channels and voice in one server application. Its owner chooses where to run it.", + projectCentral: "Vnox Central", + projectCentralText: + "The central service for your account. Server discovery and friends are the next stages.", + clientCode: "Client source", + serverCode: "Server source", + clientTitle: "Comfort starts\nwith simple things.", + clientText: + "Light, dark, mega dark or your own theme. Text size, audio and your profile, right where you expect them.", + clientScreenshot: + "Appearance settings in the native VNOX client, with four themes and a text size slider.", + screenshotCaption: + "A real screenshot of the native client. The interface is still evolving.", + appearanceTitle: "Make it yours", + appearanceText: + "Create your palette with supported CSS variables. No external resources are loaded.", + identityTitle: "A profile without the fuss", + identityText: + "Choose a photo, then adjust its zoom and position inside a circular preview.", + roadmapTitle: "Reliable conversation first.\nThe rest comes next.", + roadmapText: + "VNOX is still being developed. Here is what exists in the code and what we’re building next.", + available: "Already in the code", + next: "In progress and planned", + availableOne: "Native client, channels and voice", + availableTwo: "Settings, themes and avatar editor", + availableThree: "Central service and HTTPS", + availableFour: "GitHub web account and RU / EN interface", + availableFive: "Incoming and signed outgoing server webhooks", + nextOne: "Webhook management in the client", + nextTwo: "Screen broadcasting with separate audio sources", + nextThree: "Friends and server discovery", + downloadNote: + "Public builds will follow client and server compatibility checks. Source code is available now.", + faqTitle: "Before the first conversation", + faqServer: "Do I need a separate voice server?", + faqServerAnswer: + "No. A community is intended to run one server application with both chat and voice.", + faqCentral: "What is Vnox Central for?", + faqCentralAnswer: + "Your shared account and future social features. Each community hosts its own server separately.", + faqRelease: "Where can I download the client?", + faqReleaseAnswer: + "There is no verified public release yet. Client and server code is open, with build instructions in their repositories.", + statusLoading: "Checking Vnox Central…", + statusReady: "Vnox Central is responding", + statusUnavailable: "Could not reach Vnox Central", + statusNote: "Central service status", + retry: "Try again", + back: "Back to home", + accountHeading: "Your Vnox Central.", + accountIntro: + "One account for future communities. Start with secure GitHub sign-in.", + loginTitle: "Continue with GitHub", + loginText: + "VNOX receives your public GitHub profile. Signing in does not request access to your repositories.", + loginButton: "Sign in with GitHub", + loginLoading: "Checking sign-in availability…", + loginDisabled: "GitHub sign-in is not enabled on the server yet.", + loginUnavailable: "Could not check sign-in availability. Try again.", + privacy: + "You authorize on github.com. Your GitHub password stays with GitHub.", + accountStage: + "Your central account is not yet linked to the desktop client’s local keys. Friends, servers and messages will follow.", + sessionLoading: "Loading your account…", + profileTitle: "You’re connected.", + profileIntro: "Signed in with GitHub. This is your central VNOX account.", + handle: "Account handle", + userId: "Account ID", + provider: "Signed in with", + logout: "Sign out", + loggingOut: "Signing out…", + logoutError: "Could not sign out. Try again.", + sessionExpired: "Your session ended. Sign in again.", + profileFallback: "VNOX user", + accountError: "Your account is currently unavailable", + accountErrorText: + "Could not load your session. Check your connection and try again.", + copy: "Copy account ID", + copied: "Account ID copied", + copyError: "Could not copy the ID. Select it manually.", + }, +} as const; +export type Language = keyof typeof messages; +export type MessageKey = keyof typeof messages.en; +export function detectLanguage( + saved: unknown, + languages: readonly string[] = [], +): Language { + if (saved === "ru" || saved === "en") return saved; + return languages.some((value) => /^ru(?:-|$)/i.test(value)) ? "ru" : "en"; +} +export function translate(language: Language, key: MessageKey): string { + return messages[language]?.[key] ?? messages.en[key] ?? key; +} diff --git a/src/styles.css b/src/styles.css index 1877f5e..d80e648 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1,9 +1,1881 @@ -:root{color-scheme:dark;--bg:#19191b;--surface:#232325;--raised:#2b2b2e;--ink:#efede8;--muted:#aaa6a0;--line:#38383a;--sand:#dac5a6;--sage:#aabcaa;font-family:"Segoe UI","Noto Sans",Arial,sans-serif;font-synthesis:none;font-size:16px;line-height:1.55;scroll-behavior:smooth;scroll-padding-top:32px} -*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink)}button,a{-webkit-tap-highlight-color:transparent}a{color:inherit;text-decoration:none}button{font:inherit;color:inherit;cursor:pointer}button:disabled{cursor:wait;opacity:.6}button,input{border-radius:0}button:focus-visible,a:focus-visible,summary:focus-visible{outline:2px solid var(--sand);outline-offset:5px}img{display:block;max-width:100%}svg{flex-shrink:0;vertical-align:middle}h1,h2,h3,p{margin:0}h1,h2{white-space:pre-line;font-weight:600;letter-spacing:-.045em;line-height:1.07}h1{font-size:clamp(3.6rem,6.9vw,6.5rem)}h2{font-size:clamp(2.25rem,4vw,3.6rem)}h3{font-size:1.1rem;font-weight:600;line-height:1.3;letter-spacing:-.015em}p{color:var(--muted);max-width:65ch}.shell{width:min(1240px,calc(100% - 96px));margin-inline:auto}.small{font-size:.77rem;line-height:1.5}.skip-link{position:fixed;top:12px;left:12px;transform:translateY(-180%);z-index:20;background:var(--sand);color:var(--bg);padding:10px 18px;border-radius:6px}.skip-link:focus{transform:none}.site-header{height:106px;display:flex;align-items:center;gap:48px;border-bottom:1px solid var(--line)}.brand{display:inline-flex;align-items:center;gap:11px;font-size:1.18rem;letter-spacing:.09em;font-weight:650;flex-shrink:0}.site-header nav{display:flex;gap:30px;color:var(--muted);font-size:.87rem}.site-header nav a:hover,.site-footer a:hover{color:var(--sand)}.header-actions{display:flex;align-items:center;gap:24px;margin-left:auto;font-size:.85rem}.language-switch{display:flex;gap:2px}.language-switch button{background:none;border:0;padding:5px 6px;color:#8e8b87;font-size:.75rem}.language-switch button[aria-pressed=true]{color:var(--ink);text-decoration:underline;text-underline-offset:5px}.account-link{padding:9px 17px;border:1px solid #55514b;border-radius:7px;font-size:.85rem}.account-link:hover{background:#2a2927}.hero{padding-top:108px;padding-bottom:116px;display:grid;grid-template-columns:1fr 1.04fr;gap:58px;align-items:center;min-height:720px}.development{display:flex;align-items:center;gap:10px;font-size:.8rem;color:var(--sand);margin-bottom:25px}.development:before{content:"";width:7px;height:7px;background:var(--sand);border-radius:50%}.hero h1{max-width:8em}.hero-description{font-size:1.09rem;line-height:1.65;max-width:32ch;margin-top:27px}.hero-actions{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:32px}.button{display:inline-flex;justify-content:center;align-items:center;gap:10px;padding:13px 21px;border:1px solid transparent;border-radius:7px;font-size:.87rem;font-weight:600;line-height:1.5;min-height:48px}.primary{background:var(--sand);color:#29241e}.primary:hover{background:#e6d5bc}.quiet{background:transparent;color:var(--ink)}.quiet:hover{background:#29292b}.secondary{background:#303032;color:var(--ink);border-color:#4d4b47}.secondary:hover{background:#3a3937}.hero-note{margin-top:17px;max-width:35ch;color:#8f8b85}.diagram-wrap{width:100%;min-width:0;align-self:center;transform:translateY(12px)}.diagram-meta{display:flex;align-items:center;justify-content:space-between;padding:0 4px 14px;color:#c5c0b8;font-size:.75rem}.diagram-dots{display:flex;gap:5px}.diagram-dots i{height:4px;width:4px;background:#6f6b65;border-radius:50%}.product-diagram{--diagram-bg:#272729;--diagram-sidebar:#202022;--diagram-text:#eeece7;--diagram-muted:#a29e97;display:grid;grid-template-columns:35% 65%;background:var(--diagram-bg);border:1px solid #4c4842;box-shadow:0 24px 70px #00000035;border-radius:13px;overflow:hidden;color:var(--diagram-text);min-height:326px;transform:rotate(-2deg)}.diagram-sidebar{background:var(--diagram-sidebar);padding:17px 12px;display:flex;flex-direction:column;gap:7px;min-width:0}.diagram-sidebar>img{margin-bottom:7px}.diagram-community{font-size:.75rem;font-weight:600;margin:0 0 8px 4px;overflow-wrap:anywhere}.diagram-channel{font-size:.69rem;color:var(--diagram-muted);padding:6px 7px;border-radius:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.diagram-channel.selected{background:#dac5a61e;color:var(--diagram-text)}.diagram-voice{display:flex;gap:6px;align-items:center;font-size:.65rem;margin:13px 3px 3px;color:var(--diagram-muted);white-space:nowrap;overflow:hidden}.diagram-people{font-size:.59rem;color:var(--diagram-muted);display:grid;grid-template-columns:5px 1fr;align-items:center;gap:8px;margin:0 6px 12px 23px}.person-dot{width:5px;height:5px;border-radius:50%;background:var(--sage)}.person-dot.second{background:#c2b6c7}.diagram-self{display:flex;align-items:center;gap:8px;font-size:.65rem;border-top:1px solid #ffffff12;margin-top:auto;padding-top:12px}.diagram-self>svg{margin-left:auto;color:var(--diagram-muted)}.mini-avatar{width:22px;height:22px;display:grid;place-items:center;border-radius:6px;color:#232325;background:var(--sand);font-size:.6rem}.diagram-main{display:flex;flex-direction:column;min-width:0}.diagram-header{padding:19px 17px;font-size:.75rem;font-weight:600;border-bottom:1px solid #ffffff0c;display:flex;align-items:center;justify-content:space-between}.diagram-header>span{color:var(--diagram-muted)}#diagram-content{flex:1;min-height:211px;padding:20px 18px 12px}.diagram-call{border-top:1px solid #ffffff0c;display:flex;align-items:center;gap:7px;padding:13px 16px;font-size:.59rem;color:var(--sage)}.diagram-call>svg{margin-left:auto}.connection-dot{display:inline-block;width:7px;height:7px;background:var(--sage);border-radius:50%;flex-shrink:0}.diagram-tabs{display:flex;justify-content:center;gap:5px;padding-top:28px}.diagram-tabs button{background:transparent;border:0;font-size:.76rem;padding:7px 11px;color:var(--muted);border-radius:5px}.diagram-tabs button[aria-selected=true]{background:#343230;color:var(--sand)}.diagram-note{text-align:center;max-width:none;margin-top:7px;color:#84817b;font-size:.67rem}.message-heading{display:flex;gap:10px;align-items:center}.chat-avatar{display:grid;place-items:center;width:29px;height:29px;background:#b9a080;color:#252321;border-radius:9px;font-size:.7rem}.message-heading strong{font-size:.65rem;font-weight:600}.message-lines{display:flex;flex-direction:column;gap:5px;margin-top:6px}.message-lines i{height:4px;width:125px;background:#ffffff20;border-radius:2px}.message-lines i+i{width:91px;background:#ffffff12}.illustration-chat>p:not(.diagram-caption){font-size:.73rem;color:var(--diagram-muted);margin-top:20px;max-width:25ch;min-height:40px}.illustration-composer{margin-top:18px;background:#ffffff09;border:1px solid #ffffff0b;border-radius:6px;display:flex;align-items:center;gap:12px;height:31px;padding:7px 10px;color:var(--diagram-muted)}.illustration-composer i{display:block;width:54%;height:4px;background:#ffffff15;border-radius:2px}.illustration-composer>svg{margin-left:auto}.diagram-caption{font-size:.55rem!important;color:var(--diagram-muted)!important;margin-top:11px;text-align:center;max-width:none;line-height:1.45}.illustration-voice{text-align:center}.voice-orbit{display:flex;align-items:center;justify-content:center;gap:12px;margin:4px 0 20px}.voice-avatar{display:grid;place-items:center;width:51px;height:51px;background:#dac5a62b;border:1px solid #dac5a677;color:var(--sand);border-radius:17px;font-size:1rem}.friend-avatar{background:#aabcaa18;color:var(--sage);border-color:#aabcaa55}.waveform{display:flex;align-items:center;justify-content:center;gap:3px;width:80px}.waveform i{width:3px;background:#dac5a6a0;border-radius:2px;max-height:38px}.illustration-voice>p:not(.diagram-caption){font-size:.7rem;color:var(--diagram-muted);max-width:26ch;margin-inline:auto}.voice-controls{display:flex;gap:9px;justify-content:center;margin-top:13px}.voice-controls>span{background:#ffffff0c;border-radius:50%;padding:5px;display:grid;place-items:center}.voice-controls svg{width:15px;height:15px}.illustration-themes h3{font-size:.85rem;font-weight:500;margin-bottom:15px;text-align:center}.theme-options{display:grid;grid-template-columns:1fr 1fr;gap:9px}.theme-option{padding:6px;border:1px solid #ffffff12;background:transparent;border-radius:6px;font-size:.56rem;color:var(--diagram-muted)}.theme-option[aria-pressed=true]{border-color:var(--sand);color:var(--diagram-text)}.theme-sample{display:flex;flex-direction:column;gap:4px;padding:9px 10px;min-height:41px;background:#303032;border-radius:3px;margin-bottom:5px}.theme-sample i{width:80%;height:3px;background:#aaa8a2;border-radius:2px}.theme-sample i+i{width:95%;opacity:.6}.theme-sample i+i+i{width:61%;opacity:.35}.theme-option.light .theme-sample{background:#eeede8}.theme-option.light i{background:#73716c}.theme-option.black .theme-sample{background:#080809}.theme-option.custom .theme-sample{background:#36322d}.theme-option.custom i{background:#dac5a6}.product-diagram[data-preview-theme=light]{--diagram-bg:#eae8e3;--diagram-sidebar:#dfddd8;--diagram-text:#292827;--diagram-muted:#66615a}.product-diagram[data-preview-theme=light] .diagram-channel.selected{background:#28242017}.product-diagram[data-preview-theme=light] .theme-option{border-color:#0000001c}.product-diagram[data-preview-theme=black]{--diagram-bg:#09090a;--diagram-sidebar:#030304}.product-diagram[data-preview-theme=custom]{--diagram-bg:#312e29;--diagram-sidebar:#25231f}.project-section{padding-block:85px 108px;border-top:1px solid var(--line);display:grid;grid-template-columns:1fr 1fr;gap:110px}.section-intro>p{font-size:1rem;margin-top:25px;max-width:40ch}.source-links{display:flex;gap:28px;margin-top:27px;flex-wrap:wrap}.text-link{display:inline-flex;align-items:center;gap:9px;color:var(--sand);font-size:.86rem}.text-link:hover{text-decoration:underline;text-underline-offset:5px}.project-points{display:flex;flex-direction:column;gap:32px;padding-top:4px}.project-points article{display:grid;grid-template-columns:42px 1fr;gap:20px}.point-icon{width:40px;height:40px;border-radius:10px;background:#262628;color:var(--sand);display:grid;place-items:center}.project-points p{font-size:.9rem;margin-top:8px;max-width:44ch}.client-section{background:#202022;border-block:1px solid #343436;padding-block:90px}.client-heading{display:grid;grid-template-columns:1fr 1fr;gap:75px;align-items:end;margin-bottom:45px}.client-heading>p{font-size:1rem;max-width:42ch;margin-bottom:3px}.client-image{margin:0;background:#18181a;padding:10px;border:1px solid #46433f;border-radius:12px;overflow:hidden}.client-image img{width:100%;height:auto;border-radius:5px}.client-image figcaption{font-size:.75rem;text-align:center;color:#a8a29a;padding:14px 10px 5px}.client-details{display:grid;grid-template-columns:1fr 1fr;gap:90px;padding:37px 10px 0}.client-details p{font-size:.9rem;margin-top:9px;max-width:43ch}.roadmap{padding-block:100px 80px}.roadmap-heading{display:grid;grid-template-columns:1.2fr 1fr;gap:80px;align-items:end}.roadmap-heading>p{max-width:38ch;padding-bottom:4px}.roadmap-columns{display:grid;grid-template-columns:1fr 1fr;gap:64px;margin-top:52px}.roadmap-columns article{border-top:1px solid #47443f;padding-top:22px}.roadmap-columns h3{display:flex;gap:12px;align-items:center;font-size:1rem}.planned-dot{width:7px;height:7px;border:1px solid var(--sand);border-radius:50%}.roadmap-columns ul{margin:20px 0 0;padding-left:19px;color:var(--muted);font-size:.9rem;line-height:2.1}.roadmap-columns li::marker{color:#6b665f;font-size:.7rem}.release-note{font-size:.84rem;border-left:2px solid #776953;padding:3px 20px;margin-top:36px;max-width:80ch}.faq{border-top:1px solid var(--line);padding-block:65px 80px;display:grid;grid-template-columns:.85fr 1.15fr;gap:70px}.faq h2{font-size:2rem;line-height:1.15}.faq details{border-bottom:1px solid var(--line);padding:17px 0}.faq details:first-child{padding-top:0}.faq summary{list-style:none;cursor:pointer;display:flex;align-items:baseline;justify-content:space-between;gap:15px;font-size:.98rem}.faq summary::-webkit-details-marker{display:none}.faq summary>span:last-child{font-size:1.35rem;color:var(--sand);font-weight:300}.faq details[open] summary>span:last-child{transform:rotate(45deg)}.faq details p{font-size:.9rem;margin-top:12px;padding-right:32px}.status-section{padding:25px 0;display:flex;justify-content:space-between;gap:20px;align-items:center;border-top:1px solid var(--line)}.status-section>div{display:flex;align-items:center;gap:10px}.status-section p{font-size:.8rem}.status-dot{width:6px;height:6px;background:#8c867b;border-radius:50%}.status-dot[data-state=ready]{background:var(--sage)}.status-dot[data-state=error]{background:#d6a6a0}.site-footer{padding:35px 0 40px;display:flex;align-items:center;gap:26px;border-top:1px solid var(--line);font-size:.75rem;color:var(--muted)}.site-footer .brand{font-size:.9rem;gap:8px}.site-footer p{font-size:.75rem;margin-right:auto}.site-footer>a:not(.brand){white-space:nowrap}.account-section{padding-block:46px 110px;min-height:calc(100vh - 220px)}.back-link{font-size:.8rem;color:var(--muted)}.account-layout{display:grid;grid-template-columns:1fr 1fr;gap:110px;padding-top:68px;align-items:start}.account-mark{margin-bottom:28px}.account-intro h1{font-size:clamp(3rem,4.7vw,4.4rem);max-width:9ch}.account-intro>p{font-size:1.04rem;margin-top:24px;max-width:36ch}.account-explanation{border-top:1px solid var(--line);margin-top:34px;padding-top:23px}.account-explanation p{font-size:.8rem;max-width:43ch;color:#a29d96}.account-panel{background:#232325;border:1px solid #44413c;border-radius:12px;padding:38px;margin-top:21px;min-width:0;box-shadow:0 18px 55px #00000020}.account-panel h2{font-size:1.8rem;letter-spacing:-.03em;line-height:1.15}.account-panel>p{font-size:.92rem;margin-top:17px}.login-provider{color:var(--sand);margin-bottom:26px}.github-login{width:100%;margin-top:27px}.github-login.unavailable{cursor:default;opacity:.5}.form-message{font-size:.78rem!important;color:#d2b7a5;min-height:1.5em;margin-top:14px!important;overflow-wrap:anywhere}.privacy-note{display:flex;gap:10px;margin-top:24px;padding-top:20px;border-top:1px solid #ffffff0b;align-items:flex-start;color:var(--sage)}.privacy-note p{font-size:.75rem;color:#aaa59d}.privacy-note svg{margin-top:2px}.text-button{background:none;border:none;color:var(--sand);padding:4px 0;font-size:.8rem;text-decoration:underline;text-underline-offset:4px}.account-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:22px;min-height:260px}.account-loading p{font-size:.88rem}.loading-ring{border:2px solid #dac5a622;border-top-color:var(--sand);border-radius:50%;height:28px;width:28px;animation:spin .9s linear infinite}.profile-heading{display:flex;align-items:center;gap:19px}.profile-avatar{width:62px;height:62px;display:grid;place-items:center;background:#dac5a625;color:var(--sand);font-size:1.4rem;border-radius:18px;position:relative;overflow:hidden;flex-shrink:0}.profile-avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.profile-heading h2{font-size:1.6rem}.profile-heading p{margin-top:7px;font-size:.9rem;overflow-wrap:anywhere;max-width:25ch}.profile-fields{margin:28px 0 25px}.profile-fields>div{padding-block:15px;border-top:1px solid #ffffff0c}.profile-fields dt{color:#a19c94;font-size:.72rem;margin-bottom:5px}.profile-fields dd{margin:0;font-size:.85rem;overflow-wrap:anywhere;user-select:all}.profile-actions{display:flex;gap:10px;flex-wrap:wrap}.profile-actions .button{padding:11px 13px;min-height:43px;font-size:.76rem}.noscript{padding:22px 48px;background:#3c3027;color:var(--ink)}[hidden]{display:none!important}@keyframes spin{to{transform:rotate(360deg)}} -@media(min-width:1450px){.hero{gap:88px;min-height:770px}.diagram-wrap{max-width:560px}.product-diagram{min-height:350px}#diagram-content{padding-top:27px}.hero-description{font-size:1.17rem}.diagram-sidebar{padding:20px 15px}.diagram-community{font-size:.8rem}.diagram-channel{font-size:.74rem}.diagram-voice{font-size:.72rem}.diagram-call{font-size:.65rem}.illustration-chat>p:not(.diagram-caption){font-size:.8rem}.diagram-caption{font-size:.62rem!important}} -@media(max-width:1100px){.shell{width:calc(100% - 64px)}.site-header{gap:30px}.site-header nav{gap:22px}.hero{gap:30px;padding-top:85px;padding-bottom:90px}.hero h1{font-size:clamp(3.2rem,6.8vw,5rem)}.hero-description{font-size:.98rem}.hero-actions{gap:4px}.hero-actions .button{padding-inline:15px;font-size:.8rem}.diagram-sidebar{padding-inline:9px}.diagram-voice{font-size:.56rem}.diagram-call{font-size:.52rem;padding-inline:11px}.project-section{gap:60px}.account-layout{gap:60px}.account-panel{padding:28px}.client-heading,.roadmap-heading{gap:50px}.product-diagram{min-height:315px}.diagram-header{padding:17px 13px}#diagram-content{padding-inline:13px}.message-lines i{width:98px}.waveform{width:57px;gap:2px}.voice-avatar{height:40px;width:40px;border-radius:13px}.friend-avatar svg{width:24px;height:24px}.voice-orbit{gap:9px}.voice-controls{margin-top:9px}.illustration-voice>p:not(.diagram-caption){font-size:.65rem}} -@media(max-width:800px){.site-header{height:88px}.site-header nav{display:none}.hero{grid-template-columns:1fr;gap:45px;padding-top:64px;padding-bottom:75px}.hero h1{font-size:clamp(3.6rem,10vw,5.5rem);max-width:11ch}.hero-description{font-size:1.05rem;max-width:44ch}.hero-actions .button{font-size:.87rem;padding-inline:20px}.hero-note{max-width:none}.diagram-wrap{width:min(100%,550px);margin-inline:auto;transform:none}.product-diagram{min-height:340px;transform:rotate(-1deg)}.diagram-sidebar{padding:20px 15px}.diagram-community{font-size:.78rem}.diagram-channel{font-size:.74rem}.diagram-voice{font-size:.7rem}.diagram-call{font-size:.65rem;padding-inline:17px}.diagram-header{font-size:.83rem;padding:20px 17px}#diagram-content{padding:22px 18px 15px}.illustration-chat>p:not(.diagram-caption){font-size:.79rem}.diagram-caption{font-size:.64rem!important}.illustration-composer{margin-top:19px}.diagram-people{font-size:.65rem}.voice-orbit{margin-top:6px;gap:15px}.waveform{width:80px;gap:3px}.voice-avatar{height:52px;width:52px;border-radius:17px}.illustration-voice>p:not(.diagram-caption){font-size:.77rem}.voice-controls{margin-top:14px}.theme-option{font-size:.68rem}.theme-sample{min-height:44px}.project-section{padding-block:65px;grid-template-columns:1fr;gap:42px}.section-intro>p{max-width:58ch}.project-points{gap:26px}.project-points p{max-width:56ch}.client-section{padding-block:65px}.client-heading{grid-template-columns:1fr;gap:24px;margin-bottom:30px}.client-heading>p{max-width:55ch}.client-details{gap:35px}.roadmap{padding-block:70px 60px}.roadmap-heading{grid-template-columns:1fr;gap:23px}.roadmap-heading>p{max-width:55ch}.roadmap-columns{gap:30px;margin-top:36px}.roadmap-columns ul{font-size:.83rem;line-height:1.8}.faq{grid-template-columns:1fr;gap:28px;padding-block:50px 60px}.site-footer{flex-wrap:wrap;gap:20px}.site-footer p{order:4;flex-basis:100%;font-size:.7rem}.site-footer .brand{margin-right:auto}.site-footer>a:not(.brand){font-size:.7rem}.account-layout{grid-template-columns:1fr;gap:30px;padding-top:40px;max-width:570px;margin-inline:auto}.account-intro h1{max-width:none;font-size:3.1rem}.account-intro>p{max-width:46ch}.account-mark{width:60px;height:60px;margin-bottom:20px}.account-explanation{margin-top:24px;padding-top:18px}.account-explanation p{max-width:60ch}.account-panel{margin-top:0;padding:32px}.account-section{padding-bottom:70px}.status-section .text-link{font-size:.78rem}} -@media(max-width:480px){.shell{width:calc(100% - 40px)}.site-header{height:80px;gap:15px}.brand{font-size:1rem;gap:8px}.brand img{width:31px;height:31px}.header-actions{gap:12px}.language-switch button{padding-inline:4px;font-size:.68rem}.account-link{padding:8px 10px;font-size:.73rem}.hero{padding-top:44px;gap:38px;padding-bottom:55px}.hero h1{font-size:clamp(3.25rem,12vw,4.5rem)}.development{margin-bottom:21px;font-size:.74rem}.hero-description{margin-top:22px;font-size:.94rem;line-height:1.65}.hero-actions{margin-top:25px;gap:1px}.hero-actions .button{font-size:.77rem;padding:12px 13px;min-height:44px}.hero-note{font-size:.68rem;max-width:38ch;margin-top:14px}.diagram-wrap{padding-inline:2px}.diagram-meta{font-size:.67rem}.product-diagram{min-height:294px;grid-template-columns:34% 66%}.diagram-sidebar{padding:15px 9px}.diagram-sidebar>img{width:25px;height:25px}.diagram-community{font-size:.62rem;margin-left:2px}.diagram-channel{font-size:.58rem;padding:6px}.diagram-voice{font-size:.52rem;gap:4px;margin-left:1px}.diagram-voice svg{width:13px;height:13px}.diagram-people{font-size:.55rem;margin-left:18px;gap:7px}.diagram-self{font-size:.54rem;gap:6px}.mini-avatar{width:20px;height:20px}.diagram-header{padding:16px 12px;font-size:.68rem}#diagram-content{padding:18px 13px 12px;min-height:180px}.diagram-call{font-size:.49rem;padding:12px 10px;gap:5px}.diagram-call svg{width:12px;height:12px}.diagram-call .connection-dot{width:5px;height:5px}.chat-avatar{width:25px;height:25px;border-radius:8px}.message-heading{gap:8px}.message-heading strong{font-size:.6rem}.message-lines i{width:87px;height:3px}.message-lines i+i{width:61px}.illustration-chat>p:not(.diagram-caption){font-size:.64rem;margin-top:17px;min-height:37px}.illustration-composer{height:28px;margin-top:12px}.diagram-caption{font-size:.49rem!important;margin-top:8px}.diagram-tabs{padding-top:20px}.diagram-tabs button{padding:7px 9px;font-size:.68rem}.diagram-note{font-size:.6rem;margin-top:5px}.voice-orbit{gap:9px;margin-bottom:14px;margin-top:3px}.voice-avatar{width:37px;height:37px;border-radius:12px;font-size:.8rem}.friend-avatar svg{width:20px;height:20px}.waveform{width:55px;gap:2px}.waveform i{width:2px;max-height:29px}.illustration-voice>p:not(.diagram-caption){font-size:.6rem}.voice-controls{margin-top:10px}.voice-controls>span{padding:4px}.voice-controls svg{width:13px;height:13px}.illustration-themes h3{font-size:.72rem;margin-bottom:12px}.theme-options{gap:7px}.theme-option{font-size:.52rem;padding:5px}.theme-sample{padding:8px;min-height:33px;gap:3px}.theme-sample i{height:2px}.project-section{padding-block:50px;gap:32px}.section-intro>p{font-size:.9rem;margin-top:20px}.source-links{gap:25px;margin-top:22px}.text-link{font-size:.8rem}.project-points article{gap:15px;grid-template-columns:36px 1fr}.project-points article>img,.point-icon{width:34px;height:34px;border-radius:8px}.point-icon svg{width:21px;height:21px}.project-points h3{font-size:1rem}.project-points p{font-size:.83rem}.client-section{padding-block:48px}.client-heading{gap:20px}.client-heading>p{font-size:.9rem}.client-image{padding:5px;border-radius:8px}.client-image figcaption{font-size:.63rem;padding:10px 8px 5px}.client-details{grid-template-columns:1fr;gap:22px;padding:27px 2px 0}.client-details h3{font-size:1rem}.client-details p{font-size:.84rem;margin-top:6px}.roadmap{padding-block:52px}.roadmap-heading{gap:20px}.roadmap-heading>p{font-size:.9rem}.roadmap h2{font-size:2.1rem}.roadmap-columns{grid-template-columns:1fr;gap:27px;margin-top:28px}.roadmap-columns h3{font-size:.95rem}.roadmap-columns ul{margin-top:14px;line-height:1.9}.release-note{font-size:.76rem;margin-top:28px;padding-inline:15px}.faq{padding-block:45px 48px}.faq h2{font-size:1.8rem}.faq summary{font-size:.9rem}.faq details p{font-size:.82rem;padding-right:12px}.status-section{align-items:flex-start;flex-direction:column;gap:12px;padding-block:21px}.status-section p{font-size:.75rem}.status-section .text-link{margin-left:16px;font-size:.75rem}.site-footer{gap:16px;padding-block:27px}.site-footer .brand{font-size:.8rem}.site-footer .brand img{width:25px;height:25px}.site-footer p{line-height:1.7;max-width:32ch}.account-section{padding-top:29px;padding-bottom:48px}.account-layout{padding-top:30px;gap:28px}.account-intro h1{font-size:2.75rem}.account-intro>p{font-size:.95rem;margin-top:19px}.account-explanation{margin-top:21px}.account-explanation p{font-size:.75rem}.account-panel{padding:25px 21px;border-radius:10px}.account-panel h2{font-size:1.5rem}.account-panel>p{font-size:.85rem}.profile-heading{gap:13px}.profile-avatar{height:50px;width:50px;border-radius:15px}.profile-heading h2{font-size:1.35rem}.profile-heading p{font-size:.8rem}.profile-fields dd{font-size:.76rem}.profile-actions{gap:3px}.profile-actions .button{font-size:.7rem;padding-inline:10px}.github-login{font-size:.8rem}.form-message{font-size:.72rem!important}.privacy-note p{font-size:.69rem}} -@media(prefers-reduced-motion:reduce){:root{scroll-behavior:auto}.loading-ring{animation:none;border-style:dotted}} +:root { + color-scheme: dark; + --bg: #19191b; + --surface: #232325; + --raised: #2b2b2e; + --ink: #efede8; + --muted: #aaa6a0; + --line: #38383a; + --sand: #dac5a6; + --sage: #aabcaa; + font-family: "Segoe UI", "Noto Sans", Arial, sans-serif; + font-synthesis: none; + font-size: 16px; + line-height: 1.55; + scroll-behavior: smooth; + scroll-padding-top: 32px; +} +* { + box-sizing: border-box; +} +body { + margin: 0; + background: var(--bg); + color: var(--ink); +} +button, +a { + -webkit-tap-highlight-color: transparent; +} +a { + color: inherit; + text-decoration: none; +} +button { + font: inherit; + color: inherit; + cursor: pointer; +} +button:disabled { + cursor: wait; + opacity: 0.6; +} +button, +input { + border-radius: 0; +} +button:focus-visible, +a:focus-visible, +summary:focus-visible { + outline: 2px solid var(--sand); + outline-offset: 5px; +} +img { + display: block; + max-width: 100%; +} +svg { + flex-shrink: 0; + vertical-align: middle; +} +h1, +h2, +h3, +p { + margin: 0; +} +h1, +h2 { + white-space: pre-line; + font-weight: 600; + letter-spacing: -0.045em; + line-height: 1.07; +} +h1 { + font-size: clamp(3.6rem, 6.9vw, 6.5rem); +} +h2 { + font-size: clamp(2.25rem, 4vw, 3.6rem); +} +h3 { + font-size: 1.1rem; + font-weight: 600; + line-height: 1.3; + letter-spacing: -0.015em; +} +p { + color: var(--muted); + max-width: 65ch; +} +.shell { + width: min(1240px, calc(100% - 96px)); + margin-inline: auto; +} +.small { + font-size: 0.77rem; + line-height: 1.5; +} +.skip-link { + position: fixed; + top: 12px; + left: 12px; + transform: translateY(-180%); + z-index: 20; + background: var(--sand); + color: var(--bg); + padding: 10px 18px; + border-radius: 6px; +} +.skip-link:focus { + transform: none; +} +.site-header { + height: 106px; + display: flex; + align-items: center; + gap: 48px; + border-bottom: 1px solid var(--line); +} +.brand { + display: inline-flex; + align-items: center; + gap: 11px; + font-size: 1.18rem; + letter-spacing: 0.09em; + font-weight: 650; + flex-shrink: 0; +} +.site-header nav { + display: flex; + gap: 30px; + color: var(--muted); + font-size: 0.87rem; +} +.site-header nav a:hover, +.site-footer a:hover { + color: var(--sand); +} +.header-actions { + display: flex; + align-items: center; + gap: 24px; + margin-left: auto; + font-size: 0.85rem; +} +.language-switch { + display: flex; + gap: 2px; +} +.language-switch button { + background: none; + border: 0; + padding: 5px 6px; + color: #8e8b87; + font-size: 0.75rem; +} +.language-switch button[aria-pressed="true"] { + color: var(--ink); + text-decoration: underline; + text-underline-offset: 5px; +} +.account-link { + padding: 9px 17px; + border: 1px solid #55514b; + border-radius: 7px; + font-size: 0.85rem; +} +.account-link:hover { + background: #2a2927; +} +.hero { + padding-top: 108px; + padding-bottom: 116px; + display: grid; + grid-template-columns: 1fr 1.04fr; + gap: 58px; + align-items: center; + min-height: 720px; +} +.development { + display: flex; + align-items: center; + gap: 10px; + font-size: 0.8rem; + color: var(--sand); + margin-bottom: 25px; +} +.development:before { + content: ""; + width: 7px; + height: 7px; + background: var(--sand); + border-radius: 50%; +} +.hero h1 { + max-width: 8em; +} +.hero-description { + font-size: 1.09rem; + line-height: 1.65; + max-width: 32ch; + margin-top: 27px; +} +.hero-actions { + display: flex; + gap: 12px; + align-items: center; + flex-wrap: wrap; + margin-top: 32px; +} +.button { + display: inline-flex; + justify-content: center; + align-items: center; + gap: 10px; + padding: 13px 21px; + border: 1px solid transparent; + border-radius: 7px; + font-size: 0.87rem; + font-weight: 600; + line-height: 1.5; + min-height: 48px; +} +.primary { + background: var(--sand); + color: #29241e; +} +.primary:hover { + background: #e6d5bc; +} +.quiet { + background: transparent; + color: var(--ink); +} +.quiet:hover { + background: #29292b; +} +.secondary { + background: #303032; + color: var(--ink); + border-color: #4d4b47; +} +.secondary:hover { + background: #3a3937; +} +.hero-note { + margin-top: 17px; + max-width: 35ch; + color: #8f8b85; +} +.diagram-wrap { + width: 100%; + min-width: 0; + align-self: center; + transform: translateY(12px); +} +.diagram-meta { + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 4px 14px; + color: #c5c0b8; + font-size: 0.75rem; +} +.diagram-dots { + display: flex; + gap: 5px; +} +.diagram-dots i { + height: 4px; + width: 4px; + background: #6f6b65; + border-radius: 50%; +} +.product-diagram { + --diagram-bg: #272729; + --diagram-sidebar: #202022; + --diagram-text: #eeece7; + --diagram-muted: #a29e97; + display: grid; + grid-template-columns: 35% 65%; + background: var(--diagram-bg); + border: 1px solid #4c4842; + box-shadow: 0 24px 70px #00000035; + border-radius: 13px; + overflow: hidden; + color: var(--diagram-text); + min-height: 326px; + transform: rotate(-2deg); +} +.diagram-sidebar { + background: var(--diagram-sidebar); + padding: 17px 12px; + display: flex; + flex-direction: column; + gap: 7px; + min-width: 0; +} +.diagram-sidebar > img { + margin-bottom: 7px; +} +.diagram-community { + font-size: 0.75rem; + font-weight: 600; + margin: 0 0 8px 4px; + overflow-wrap: anywhere; +} +.diagram-channel { + font-size: 0.69rem; + color: var(--diagram-muted); + padding: 6px 7px; + border-radius: 4px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.diagram-channel.selected { + background: #dac5a61e; + color: var(--diagram-text); +} +.diagram-voice { + display: flex; + gap: 6px; + align-items: center; + font-size: 0.65rem; + margin: 13px 3px 3px; + color: var(--diagram-muted); + white-space: nowrap; + overflow: hidden; +} +.diagram-people { + font-size: 0.59rem; + color: var(--diagram-muted); + display: grid; + grid-template-columns: 5px 1fr; + align-items: center; + gap: 8px; + margin: 0 6px 12px 23px; +} +.person-dot { + width: 5px; + height: 5px; + border-radius: 50%; + background: var(--sage); +} +.person-dot.second { + background: #c2b6c7; +} +.diagram-self { + display: flex; + align-items: center; + gap: 8px; + font-size: 0.65rem; + border-top: 1px solid #ffffff12; + margin-top: auto; + padding-top: 12px; +} +.diagram-self > svg { + margin-left: auto; + color: var(--diagram-muted); +} +.mini-avatar { + width: 22px; + height: 22px; + display: grid; + place-items: center; + border-radius: 6px; + color: #232325; + background: var(--sand); + font-size: 0.6rem; +} +.diagram-main { + display: flex; + flex-direction: column; + min-width: 0; +} +.diagram-header { + padding: 19px 17px; + font-size: 0.75rem; + font-weight: 600; + border-bottom: 1px solid #ffffff0c; + display: flex; + align-items: center; + justify-content: space-between; +} +.diagram-header > span { + color: var(--diagram-muted); +} +#diagram-content { + flex: 1; + min-height: 211px; + padding: 20px 18px 12px; +} +.diagram-call { + border-top: 1px solid #ffffff0c; + display: flex; + align-items: center; + gap: 7px; + padding: 13px 16px; + font-size: 0.59rem; + color: var(--sage); +} +.diagram-call > svg { + margin-left: auto; +} +.connection-dot { + display: inline-block; + width: 7px; + height: 7px; + background: var(--sage); + border-radius: 50%; + flex-shrink: 0; +} +.diagram-tabs { + display: flex; + justify-content: center; + gap: 5px; + padding-top: 28px; +} +.diagram-tabs button { + background: transparent; + border: 0; + font-size: 0.76rem; + padding: 7px 11px; + color: var(--muted); + border-radius: 5px; +} +.diagram-tabs button[aria-selected="true"] { + background: #343230; + color: var(--sand); +} +.diagram-note { + text-align: center; + max-width: none; + margin-top: 7px; + color: #84817b; + font-size: 0.67rem; +} +.message-heading { + display: flex; + gap: 10px; + align-items: center; +} +.chat-avatar { + display: grid; + place-items: center; + width: 29px; + height: 29px; + background: #b9a080; + color: #252321; + border-radius: 9px; + font-size: 0.7rem; +} +.message-heading strong { + font-size: 0.65rem; + font-weight: 600; +} +.message-lines { + display: flex; + flex-direction: column; + gap: 5px; + margin-top: 6px; +} +.message-lines i { + height: 4px; + width: 125px; + background: #ffffff20; + border-radius: 2px; +} +.message-lines i + i { + width: 91px; + background: #ffffff12; +} +.illustration-chat > p:not(.diagram-caption) { + font-size: 0.73rem; + color: var(--diagram-muted); + margin-top: 20px; + max-width: 25ch; + min-height: 40px; +} +.illustration-composer { + margin-top: 18px; + background: #ffffff09; + border: 1px solid #ffffff0b; + border-radius: 6px; + display: flex; + align-items: center; + gap: 12px; + height: 31px; + padding: 7px 10px; + color: var(--diagram-muted); +} +.illustration-composer i { + display: block; + width: 54%; + height: 4px; + background: #ffffff15; + border-radius: 2px; +} +.illustration-composer > svg { + margin-left: auto; +} +.diagram-caption { + font-size: 0.55rem !important; + color: var(--diagram-muted) !important; + margin-top: 11px; + text-align: center; + max-width: none; + line-height: 1.45; +} +.illustration-voice { + text-align: center; +} +.voice-orbit { + display: flex; + align-items: center; + justify-content: center; + gap: 12px; + margin: 4px 0 20px; +} +.voice-avatar { + display: grid; + place-items: center; + width: 51px; + height: 51px; + background: #dac5a62b; + border: 1px solid #dac5a677; + color: var(--sand); + border-radius: 17px; + font-size: 1rem; +} +.friend-avatar { + background: #aabcaa18; + color: var(--sage); + border-color: #aabcaa55; +} +.waveform { + display: flex; + align-items: center; + justify-content: center; + gap: 3px; + width: 80px; +} +.waveform i { + width: 3px; + background: #dac5a6a0; + border-radius: 2px; + max-height: 38px; +} +.illustration-voice > p:not(.diagram-caption) { + font-size: 0.7rem; + color: var(--diagram-muted); + max-width: 26ch; + margin-inline: auto; +} +.voice-controls { + display: flex; + gap: 9px; + justify-content: center; + margin-top: 13px; +} +.voice-controls > span { + background: #ffffff0c; + border-radius: 50%; + padding: 5px; + display: grid; + place-items: center; +} +.voice-controls svg { + width: 15px; + height: 15px; +} +.illustration-themes h3 { + font-size: 0.85rem; + font-weight: 500; + margin-bottom: 15px; + text-align: center; +} +.theme-options { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 9px; +} +.theme-option { + padding: 6px; + border: 1px solid #ffffff12; + background: transparent; + border-radius: 6px; + font-size: 0.56rem; + color: var(--diagram-muted); +} +.theme-option[aria-pressed="true"] { + border-color: var(--sand); + color: var(--diagram-text); +} +.theme-sample { + display: flex; + flex-direction: column; + gap: 4px; + padding: 9px 10px; + min-height: 41px; + background: #303032; + border-radius: 3px; + margin-bottom: 5px; +} +.theme-sample i { + width: 80%; + height: 3px; + background: #aaa8a2; + border-radius: 2px; +} +.theme-sample i + i { + width: 95%; + opacity: 0.6; +} +.theme-sample i + i + i { + width: 61%; + opacity: 0.35; +} +.theme-option.light .theme-sample { + background: #eeede8; +} +.theme-option.light i { + background: #73716c; +} +.theme-option.black .theme-sample { + background: #080809; +} +.theme-option.custom .theme-sample { + background: #36322d; +} +.theme-option.custom i { + background: #dac5a6; +} +.product-diagram[data-preview-theme="light"] { + --diagram-bg: #eae8e3; + --diagram-sidebar: #dfddd8; + --diagram-text: #292827; + --diagram-muted: #66615a; +} +.product-diagram[data-preview-theme="light"] .diagram-channel.selected { + background: #28242017; +} +.product-diagram[data-preview-theme="light"] .theme-option { + border-color: #0000001c; +} +.product-diagram[data-preview-theme="black"] { + --diagram-bg: #09090a; + --diagram-sidebar: #030304; +} +.product-diagram[data-preview-theme="custom"] { + --diagram-bg: #312e29; + --diagram-sidebar: #25231f; +} +.project-section { + padding-block: 85px 108px; + border-top: 1px solid var(--line); + display: grid; + grid-template-columns: 1fr 1fr; + gap: 110px; +} +.section-intro > p { + font-size: 1rem; + margin-top: 25px; + max-width: 40ch; +} +.source-links { + display: flex; + gap: 28px; + margin-top: 27px; + flex-wrap: wrap; +} +.text-link { + display: inline-flex; + align-items: center; + gap: 9px; + color: var(--sand); + font-size: 0.86rem; +} +.text-link:hover { + text-decoration: underline; + text-underline-offset: 5px; +} +.project-points { + display: flex; + flex-direction: column; + gap: 32px; + padding-top: 4px; +} +.project-points article { + display: grid; + grid-template-columns: 42px 1fr; + gap: 20px; +} +.point-icon { + width: 40px; + height: 40px; + border-radius: 10px; + background: #262628; + color: var(--sand); + display: grid; + place-items: center; +} +.project-points p { + font-size: 0.9rem; + margin-top: 8px; + max-width: 44ch; +} +.client-section { + background: #202022; + border-block: 1px solid #343436; + padding-block: 90px; +} +.client-heading { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 75px; + align-items: end; + margin-bottom: 45px; +} +.client-heading > p { + font-size: 1rem; + max-width: 42ch; + margin-bottom: 3px; +} +.client-image { + margin: 0; + background: #18181a; + padding: 10px; + border: 1px solid #46433f; + border-radius: 12px; + overflow: hidden; +} +.client-image img { + width: 100%; + height: auto; + border-radius: 5px; +} +.client-image figcaption { + font-size: 0.75rem; + text-align: center; + color: #a8a29a; + padding: 14px 10px 5px; +} +.client-details { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 90px; + padding: 37px 10px 0; +} +.client-details p { + font-size: 0.9rem; + margin-top: 9px; + max-width: 43ch; +} +.roadmap { + padding-block: 100px 80px; +} +.roadmap-heading { + display: grid; + grid-template-columns: 1.2fr 1fr; + gap: 80px; + align-items: end; +} +.roadmap-heading > p { + max-width: 38ch; + padding-bottom: 4px; +} +.roadmap-columns { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 64px; + margin-top: 52px; +} +.roadmap-columns article { + border-top: 1px solid #47443f; + padding-top: 22px; +} +.roadmap-columns h3 { + display: flex; + gap: 12px; + align-items: center; + font-size: 1rem; +} +.planned-dot { + width: 7px; + height: 7px; + border: 1px solid var(--sand); + border-radius: 50%; +} +.roadmap-columns ul { + margin: 20px 0 0; + padding-left: 19px; + color: var(--muted); + font-size: 0.9rem; + line-height: 2.1; +} +.roadmap-columns li::marker { + color: #6b665f; + font-size: 0.7rem; +} +.release-note { + font-size: 0.84rem; + border-left: 2px solid #776953; + padding: 3px 20px; + margin-top: 36px; + max-width: 80ch; +} +.faq { + border-top: 1px solid var(--line); + padding-block: 65px 80px; + display: grid; + grid-template-columns: 0.85fr 1.15fr; + gap: 70px; +} +.faq h2 { + font-size: 2rem; + line-height: 1.15; +} +.faq details { + border-bottom: 1px solid var(--line); + padding: 17px 0; +} +.faq details:first-child { + padding-top: 0; +} +.faq summary { + list-style: none; + cursor: pointer; + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 15px; + font-size: 0.98rem; +} +.faq summary::-webkit-details-marker { + display: none; +} +.faq summary > span:last-child { + font-size: 1.35rem; + color: var(--sand); + font-weight: 300; +} +.faq details[open] summary > span:last-child { + transform: rotate(45deg); +} +.faq details p { + font-size: 0.9rem; + margin-top: 12px; + padding-right: 32px; +} +.status-section { + padding: 25px 0; + display: flex; + justify-content: space-between; + gap: 20px; + align-items: center; + border-top: 1px solid var(--line); +} +.status-section > div { + display: flex; + align-items: center; + gap: 10px; +} +.status-section p { + font-size: 0.8rem; +} +.status-dot { + width: 6px; + height: 6px; + background: #8c867b; + border-radius: 50%; +} +.status-dot[data-state="ready"] { + background: var(--sage); +} +.status-dot[data-state="error"] { + background: #d6a6a0; +} +.site-footer { + padding: 35px 0 40px; + display: flex; + align-items: center; + gap: 26px; + border-top: 1px solid var(--line); + font-size: 0.75rem; + color: var(--muted); +} +.site-footer .brand { + font-size: 0.9rem; + gap: 8px; +} +.site-footer p { + font-size: 0.75rem; + margin-right: auto; +} +.site-footer > a:not(.brand) { + white-space: nowrap; +} +.account-section { + padding-block: 46px 110px; + min-height: calc(100vh - 220px); +} +.back-link { + font-size: 0.8rem; + color: var(--muted); +} +.account-layout { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 110px; + padding-top: 68px; + align-items: start; +} +.account-mark { + margin-bottom: 28px; +} +.account-intro h1 { + font-size: clamp(3rem, 4.7vw, 4.4rem); + max-width: 9ch; +} +.account-intro > p { + font-size: 1.04rem; + margin-top: 24px; + max-width: 36ch; +} +.account-explanation { + border-top: 1px solid var(--line); + margin-top: 34px; + padding-top: 23px; +} +.account-explanation p { + font-size: 0.8rem; + max-width: 43ch; + color: #a29d96; +} +.account-panel { + background: #232325; + border: 1px solid #44413c; + border-radius: 12px; + padding: 38px; + margin-top: 21px; + min-width: 0; + box-shadow: 0 18px 55px #00000020; +} +.account-panel h2 { + font-size: 1.8rem; + letter-spacing: -0.03em; + line-height: 1.15; +} +.account-panel > p { + font-size: 0.92rem; + margin-top: 17px; +} +.login-provider { + color: var(--sand); + margin-bottom: 26px; +} +.github-login { + width: 100%; + margin-top: 27px; +} +.github-login.unavailable { + cursor: default; + opacity: 0.5; +} +.form-message { + font-size: 0.78rem !important; + color: #d2b7a5; + min-height: 1.5em; + margin-top: 14px !important; + overflow-wrap: anywhere; +} +.privacy-note { + display: flex; + gap: 10px; + margin-top: 24px; + padding-top: 20px; + border-top: 1px solid #ffffff0b; + align-items: flex-start; + color: var(--sage); +} +.privacy-note p { + font-size: 0.75rem; + color: #aaa59d; +} +.privacy-note svg { + margin-top: 2px; +} +.text-button { + background: none; + border: none; + color: var(--sand); + padding: 4px 0; + font-size: 0.8rem; + text-decoration: underline; + text-underline-offset: 4px; +} +.account-loading { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 22px; + min-height: 260px; +} +.account-loading p { + font-size: 0.88rem; +} +.loading-ring { + border: 2px solid #dac5a622; + border-top-color: var(--sand); + border-radius: 50%; + height: 28px; + width: 28px; + animation: spin 0.9s linear infinite; +} +.profile-heading { + display: flex; + align-items: center; + gap: 19px; +} +.profile-avatar { + width: 62px; + height: 62px; + display: grid; + place-items: center; + background: #dac5a625; + color: var(--sand); + font-size: 1.4rem; + border-radius: 18px; + position: relative; + overflow: hidden; + flex-shrink: 0; +} +.profile-avatar img { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; +} +.profile-heading h2 { + font-size: 1.6rem; +} +.profile-heading p { + margin-top: 7px; + font-size: 0.9rem; + overflow-wrap: anywhere; + max-width: 25ch; +} +.profile-fields { + margin: 28px 0 25px; +} +.profile-fields > div { + padding-block: 15px; + border-top: 1px solid #ffffff0c; +} +.profile-fields dt { + color: #a19c94; + font-size: 0.72rem; + margin-bottom: 5px; +} +.profile-fields dd { + margin: 0; + font-size: 0.85rem; + overflow-wrap: anywhere; + user-select: all; +} +.profile-actions { + display: flex; + gap: 10px; + flex-wrap: wrap; +} +.profile-actions .button { + padding: 11px 13px; + min-height: 43px; + font-size: 0.76rem; +} +.noscript { + padding: 22px 48px; + background: #3c3027; + color: var(--ink); +} +[hidden] { + display: none !important; +} +@keyframes spin { + to { + transform: rotate(360deg); + } +} +@media (min-width: 1450px) { + .hero { + gap: 88px; + min-height: 770px; + } + .diagram-wrap { + max-width: 560px; + } + .product-diagram { + min-height: 350px; + } + #diagram-content { + padding-top: 27px; + } + .hero-description { + font-size: 1.17rem; + } + .diagram-sidebar { + padding: 20px 15px; + } + .diagram-community { + font-size: 0.8rem; + } + .diagram-channel { + font-size: 0.74rem; + } + .diagram-voice { + font-size: 0.72rem; + } + .diagram-call { + font-size: 0.65rem; + } + .illustration-chat > p:not(.diagram-caption) { + font-size: 0.8rem; + } + .diagram-caption { + font-size: 0.62rem !important; + } +} +@media (max-width: 1100px) { + .shell { + width: calc(100% - 64px); + } + .site-header { + gap: 30px; + } + .site-header nav { + gap: 22px; + } + .hero { + gap: 30px; + padding-top: 85px; + padding-bottom: 90px; + } + .hero h1 { + font-size: clamp(3.2rem, 6.8vw, 5rem); + } + .hero-description { + font-size: 0.98rem; + } + .hero-actions { + gap: 4px; + } + .hero-actions .button { + padding-inline: 15px; + font-size: 0.8rem; + } + .diagram-sidebar { + padding-inline: 9px; + } + .diagram-voice { + font-size: 0.56rem; + } + .diagram-call { + font-size: 0.52rem; + padding-inline: 11px; + } + .project-section { + gap: 60px; + } + .account-layout { + gap: 60px; + } + .account-panel { + padding: 28px; + } + .client-heading, + .roadmap-heading { + gap: 50px; + } + .product-diagram { + min-height: 315px; + } + .diagram-header { + padding: 17px 13px; + } + #diagram-content { + padding-inline: 13px; + } + .message-lines i { + width: 98px; + } + .waveform { + width: 57px; + gap: 2px; + } + .voice-avatar { + height: 40px; + width: 40px; + border-radius: 13px; + } + .friend-avatar svg { + width: 24px; + height: 24px; + } + .voice-orbit { + gap: 9px; + } + .voice-controls { + margin-top: 9px; + } + .illustration-voice > p:not(.diagram-caption) { + font-size: 0.65rem; + } +} +@media (max-width: 800px) { + .site-header { + height: 88px; + } + .site-header nav { + display: none; + } + .hero { + grid-template-columns: 1fr; + gap: 45px; + padding-top: 64px; + padding-bottom: 75px; + } + .hero h1 { + font-size: clamp(3.6rem, 10vw, 5.5rem); + max-width: 11ch; + } + .hero-description { + font-size: 1.05rem; + max-width: 44ch; + } + .hero-actions .button { + font-size: 0.87rem; + padding-inline: 20px; + } + .hero-note { + max-width: none; + } + .diagram-wrap { + width: min(100%, 550px); + margin-inline: auto; + transform: none; + } + .product-diagram { + min-height: 340px; + transform: rotate(-1deg); + } + .diagram-sidebar { + padding: 20px 15px; + } + .diagram-community { + font-size: 0.78rem; + } + .diagram-channel { + font-size: 0.74rem; + } + .diagram-voice { + font-size: 0.7rem; + } + .diagram-call { + font-size: 0.65rem; + padding-inline: 17px; + } + .diagram-header { + font-size: 0.83rem; + padding: 20px 17px; + } + #diagram-content { + padding: 22px 18px 15px; + } + .illustration-chat > p:not(.diagram-caption) { + font-size: 0.79rem; + } + .diagram-caption { + font-size: 0.64rem !important; + } + .illustration-composer { + margin-top: 19px; + } + .diagram-people { + font-size: 0.65rem; + } + .voice-orbit { + margin-top: 6px; + gap: 15px; + } + .waveform { + width: 80px; + gap: 3px; + } + .voice-avatar { + height: 52px; + width: 52px; + border-radius: 17px; + } + .illustration-voice > p:not(.diagram-caption) { + font-size: 0.77rem; + } + .voice-controls { + margin-top: 14px; + } + .theme-option { + font-size: 0.68rem; + } + .theme-sample { + min-height: 44px; + } + .project-section { + padding-block: 65px; + grid-template-columns: 1fr; + gap: 42px; + } + .section-intro > p { + max-width: 58ch; + } + .project-points { + gap: 26px; + } + .project-points p { + max-width: 56ch; + } + .client-section { + padding-block: 65px; + } + .client-heading { + grid-template-columns: 1fr; + gap: 24px; + margin-bottom: 30px; + } + .client-heading > p { + max-width: 55ch; + } + .client-details { + gap: 35px; + } + .roadmap { + padding-block: 70px 60px; + } + .roadmap-heading { + grid-template-columns: 1fr; + gap: 23px; + } + .roadmap-heading > p { + max-width: 55ch; + } + .roadmap-columns { + gap: 30px; + margin-top: 36px; + } + .roadmap-columns ul { + font-size: 0.83rem; + line-height: 1.8; + } + .faq { + grid-template-columns: 1fr; + gap: 28px; + padding-block: 50px 60px; + } + .site-footer { + flex-wrap: wrap; + gap: 20px; + } + .site-footer p { + order: 4; + flex-basis: 100%; + font-size: 0.7rem; + } + .site-footer .brand { + margin-right: auto; + } + .site-footer > a:not(.brand) { + font-size: 0.7rem; + } + .account-layout { + grid-template-columns: 1fr; + gap: 30px; + padding-top: 40px; + max-width: 570px; + margin-inline: auto; + } + .account-intro h1 { + max-width: none; + font-size: 3.1rem; + } + .account-intro > p { + max-width: 46ch; + } + .account-mark { + width: 60px; + height: 60px; + margin-bottom: 20px; + } + .account-explanation { + margin-top: 24px; + padding-top: 18px; + } + .account-explanation p { + max-width: 60ch; + } + .account-panel { + margin-top: 0; + padding: 32px; + } + .account-section { + padding-bottom: 70px; + } + .status-section .text-link { + font-size: 0.78rem; + } +} +@media (max-width: 480px) { + .shell { + width: calc(100% - 40px); + } + .site-header { + height: 80px; + gap: 15px; + } + .brand { + font-size: 1rem; + gap: 8px; + } + .brand img { + width: 31px; + height: 31px; + } + .header-actions { + gap: 12px; + } + .language-switch button { + padding-inline: 4px; + font-size: 0.68rem; + } + .account-link { + padding: 8px 10px; + font-size: 0.73rem; + } + .hero { + padding-top: 44px; + gap: 38px; + padding-bottom: 55px; + } + .hero h1 { + font-size: clamp(3.25rem, 12vw, 4.5rem); + } + .development { + margin-bottom: 21px; + font-size: 0.74rem; + } + .hero-description { + margin-top: 22px; + font-size: 0.94rem; + line-height: 1.65; + } + .hero-actions { + margin-top: 25px; + gap: 1px; + } + .hero-actions .button { + font-size: 0.77rem; + padding: 12px 13px; + min-height: 44px; + } + .hero-note { + font-size: 0.68rem; + max-width: 38ch; + margin-top: 14px; + } + .diagram-wrap { + padding-inline: 2px; + } + .diagram-meta { + font-size: 0.67rem; + } + .product-diagram { + min-height: 294px; + grid-template-columns: 34% 66%; + } + .diagram-sidebar { + padding: 15px 9px; + } + .diagram-sidebar > img { + width: 25px; + height: 25px; + } + .diagram-community { + font-size: 0.62rem; + margin-left: 2px; + } + .diagram-channel { + font-size: 0.58rem; + padding: 6px; + } + .diagram-voice { + font-size: 0.52rem; + gap: 4px; + margin-left: 1px; + } + .diagram-voice svg { + width: 13px; + height: 13px; + } + .diagram-people { + font-size: 0.55rem; + margin-left: 18px; + gap: 7px; + } + .diagram-self { + font-size: 0.54rem; + gap: 6px; + } + .mini-avatar { + width: 20px; + height: 20px; + } + .diagram-header { + padding: 16px 12px; + font-size: 0.68rem; + } + #diagram-content { + padding: 18px 13px 12px; + min-height: 180px; + } + .diagram-call { + font-size: 0.49rem; + padding: 12px 10px; + gap: 5px; + } + .diagram-call svg { + width: 12px; + height: 12px; + } + .diagram-call .connection-dot { + width: 5px; + height: 5px; + } + .chat-avatar { + width: 25px; + height: 25px; + border-radius: 8px; + } + .message-heading { + gap: 8px; + } + .message-heading strong { + font-size: 0.6rem; + } + .message-lines i { + width: 87px; + height: 3px; + } + .message-lines i + i { + width: 61px; + } + .illustration-chat > p:not(.diagram-caption) { + font-size: 0.64rem; + margin-top: 17px; + min-height: 37px; + } + .illustration-composer { + height: 28px; + margin-top: 12px; + } + .diagram-caption { + font-size: 0.49rem !important; + margin-top: 8px; + } + .diagram-tabs { + padding-top: 20px; + } + .diagram-tabs button { + padding: 7px 9px; + font-size: 0.68rem; + } + .diagram-note { + font-size: 0.6rem; + margin-top: 5px; + } + .voice-orbit { + gap: 9px; + margin-bottom: 14px; + margin-top: 3px; + } + .voice-avatar { + width: 37px; + height: 37px; + border-radius: 12px; + font-size: 0.8rem; + } + .friend-avatar svg { + width: 20px; + height: 20px; + } + .waveform { + width: 55px; + gap: 2px; + } + .waveform i { + width: 2px; + max-height: 29px; + } + .illustration-voice > p:not(.diagram-caption) { + font-size: 0.6rem; + } + .voice-controls { + margin-top: 10px; + } + .voice-controls > span { + padding: 4px; + } + .voice-controls svg { + width: 13px; + height: 13px; + } + .illustration-themes h3 { + font-size: 0.72rem; + margin-bottom: 12px; + } + .theme-options { + gap: 7px; + } + .theme-option { + font-size: 0.52rem; + padding: 5px; + } + .theme-sample { + padding: 8px; + min-height: 33px; + gap: 3px; + } + .theme-sample i { + height: 2px; + } + .project-section { + padding-block: 50px; + gap: 32px; + } + .section-intro > p { + font-size: 0.9rem; + margin-top: 20px; + } + .source-links { + gap: 25px; + margin-top: 22px; + } + .text-link { + font-size: 0.8rem; + } + .project-points article { + gap: 15px; + grid-template-columns: 36px 1fr; + } + .project-points article > img, + .point-icon { + width: 34px; + height: 34px; + border-radius: 8px; + } + .point-icon svg { + width: 21px; + height: 21px; + } + .project-points h3 { + font-size: 1rem; + } + .project-points p { + font-size: 0.83rem; + } + .client-section { + padding-block: 48px; + } + .client-heading { + gap: 20px; + } + .client-heading > p { + font-size: 0.9rem; + } + .client-image { + padding: 5px; + border-radius: 8px; + } + .client-image figcaption { + font-size: 0.63rem; + padding: 10px 8px 5px; + } + .client-details { + grid-template-columns: 1fr; + gap: 22px; + padding: 27px 2px 0; + } + .client-details h3 { + font-size: 1rem; + } + .client-details p { + font-size: 0.84rem; + margin-top: 6px; + } + .roadmap { + padding-block: 52px; + } + .roadmap-heading { + gap: 20px; + } + .roadmap-heading > p { + font-size: 0.9rem; + } + .roadmap h2 { + font-size: 2.1rem; + } + .roadmap-columns { + grid-template-columns: 1fr; + gap: 27px; + margin-top: 28px; + } + .roadmap-columns h3 { + font-size: 0.95rem; + } + .roadmap-columns ul { + margin-top: 14px; + line-height: 1.9; + } + .release-note { + font-size: 0.76rem; + margin-top: 28px; + padding-inline: 15px; + } + .faq { + padding-block: 45px 48px; + } + .faq h2 { + font-size: 1.8rem; + } + .faq summary { + font-size: 0.9rem; + } + .faq details p { + font-size: 0.82rem; + padding-right: 12px; + } + .status-section { + align-items: flex-start; + flex-direction: column; + gap: 12px; + padding-block: 21px; + } + .status-section p { + font-size: 0.75rem; + } + .status-section .text-link { + margin-left: 16px; + font-size: 0.75rem; + } + .site-footer { + gap: 16px; + padding-block: 27px; + } + .site-footer .brand { + font-size: 0.8rem; + } + .site-footer .brand img { + width: 25px; + height: 25px; + } + .site-footer p { + line-height: 1.7; + max-width: 32ch; + } + .account-section { + padding-top: 29px; + padding-bottom: 48px; + } + .account-layout { + padding-top: 30px; + gap: 28px; + } + .account-intro h1 { + font-size: 2.75rem; + } + .account-intro > p { + font-size: 0.95rem; + margin-top: 19px; + } + .account-explanation { + margin-top: 21px; + } + .account-explanation p { + font-size: 0.75rem; + } + .account-panel { + padding: 25px 21px; + border-radius: 10px; + } + .account-panel h2 { + font-size: 1.5rem; + } + .account-panel > p { + font-size: 0.85rem; + } + .profile-heading { + gap: 13px; + } + .profile-avatar { + height: 50px; + width: 50px; + border-radius: 15px; + } + .profile-heading h2 { + font-size: 1.35rem; + } + .profile-heading p { + font-size: 0.8rem; + } + .profile-fields dd { + font-size: 0.76rem; + } + .profile-actions { + gap: 3px; + } + .profile-actions .button { + font-size: 0.7rem; + padding-inline: 10px; + } + .github-login { + font-size: 0.8rem; + } + .form-message { + font-size: 0.72rem !important; + } + .privacy-note p { + font-size: 0.69rem; + } +} +@media (prefers-reduced-motion: reduce) { + :root { + scroll-behavior: auto; + } + .loading-ring { + animation: none; + border-style: dotted; + } +} -.waveform i:nth-child(11n+1){height:12px}.waveform i:nth-child(11n+2){height:25px}.waveform i:nth-child(11n+3){height:18px}.waveform i:nth-child(11n+4){height:37px}.waveform i:nth-child(11n+5){height:48px}.waveform i:nth-child(11n+6){height:29px}.waveform i:nth-child(11n+7){height:41px}.waveform i:nth-child(11n+8){height:21px}.waveform i:nth-child(11n+9){height:32px}.waveform i:nth-child(11n+10){height:14px}.waveform i:nth-child(11n+11){height:24px} +.waveform i:nth-child(11n + 1) { + height: 12px; +} +.waveform i:nth-child(11n + 2) { + height: 25px; +} +.waveform i:nth-child(11n + 3) { + height: 18px; +} +.waveform i:nth-child(11n + 4) { + height: 37px; +} +.waveform i:nth-child(11n + 5) { + height: 48px; +} +.waveform i:nth-child(11n + 6) { + height: 29px; +} +.waveform i:nth-child(11n + 7) { + height: 41px; +} +.waveform i:nth-child(11n + 8) { + height: 21px; +} +.waveform i:nth-child(11n + 9) { + height: 32px; +} +.waveform i:nth-child(11n + 10) { + height: 14px; +} +.waveform i:nth-child(11n + 11) { + height: 24px; +} diff --git a/tests/api.test.js b/tests/api.test.js deleted file mode 100644 index 484b988..0000000 --- a/tests/api.test.js +++ /dev/null @@ -1,43 +0,0 @@ -import test from 'node:test'; -import assert from 'node:assert/strict'; -import { request, isSession, safeAvatar, ApiError } from '../src/api.js'; -import { messages, detectLanguage } from '../src/i18n.js'; - -test('catalogs match and never silently fall back to a missing translation',()=>{ - assert.deepEqual(Object.keys(messages.ru).sort(),Object.keys(messages.en).sort()); - for (const catalog of Object.values(messages)) for (const value of Object.values(catalog)) assert.ok(typeof value==='string' && value.length>0); -}); -test('language preference is bounded and follows the OS without storage',()=>{ - assert.equal(detectLanguage('en',['ru-RU']),'en'); - assert.equal(detectLanguage('bad',['ru-RU']),'ru'); - assert.equal(detectLanguage(undefined,['pl-PL']),'en'); - assert.equal(detectLanguage('RU',['en-US']),'en'); -}); -test('API keeps authentication on the same origin and sends CSRF only in header',async()=>{ - let observed; - const result=await request('/v1/auth/logout',{method:'POST',csrf:'fixture-csrf',fetcher:async(path,options)=>{ - observed={path,options};return {ok:true,status:204}; - }}); - assert.equal(result,null); - assert.equal(observed.path,'/v1/auth/logout'); - assert.equal(observed.options.credentials,'same-origin'); - assert.equal(observed.options.cache,'no-store'); - assert.equal(observed.options.headers['X-CSRF-Token'],'fixture-csrf'); - assert.equal(observed.options.method,'POST'); - await assert.rejects(request('https://evil.example/v1/auth/session'),TypeError); - await assert.rejects(request('//evil.example/v1/auth/session'),TypeError); -}); -test('API failures expose a generic code and preserve status for expired sessions',async()=>{ - await assert.rejects(request('/v1/auth/session',{fetcher:async()=>({ok:false,status:401})}),error=>error instanceof ApiError && error.status===401 && error.message==='request_failed'); -}); -test('session validation rejects malformed authenticated payloads',()=>{ - assert.ok(isSession({authenticated:false})); - assert.ok(isSession({authenticated:true,csrf_token:'fixture',user:{user_id:'fixture',handle:'test',display_name:'Test'}})); - assert.equal(isSession({authenticated:true,user:{}}),false); - assert.equal(isSession({authenticated:'true'}),false); - assert.equal(isSession({authenticated:true,csrf_token:'',user:{user_id:'fixture',handle:'test',display_name:'Test'}}),false); -}); -test('avatars allow only uncredentialed HTTPS GitHub image origin',()=>{ - assert.equal(safeAvatar('https://avatars.githubusercontent.com/u/1?v=4'),'https://avatars.githubusercontent.com/u/1?v=4'); - for (const url of ['javascript:alert(1)','data:image/svg+xml,','http://avatars.githubusercontent.com/u/1','https://avatars.githubusercontent.com.evil.example/u/1','https://evil@avatars.githubusercontent.com/u/1','https://avatars.githubusercontent.com:8443/u/1','https://evil.example/u/1',null]) assert.equal(safeAvatar(url),null); -}); diff --git a/tests/api.test.ts b/tests/api.test.ts new file mode 100644 index 0000000..d0ef16e --- /dev/null +++ b/tests/api.test.ts @@ -0,0 +1,107 @@ +import { test } from "bun:test"; +import assert from "node:assert/strict"; +import { request, isSession, isInfo, safeAvatar, ApiError } from "../src/api"; +import { messages, detectLanguage } from "../src/i18n"; + +test("catalogs match and never silently fall back to a missing translation", () => { + assert.deepEqual( + Object.keys(messages.ru).sort(), + Object.keys(messages.en).sort(), + ); + for (const catalog of Object.values(messages)) + for (const value of Object.values(catalog)) + assert.ok(typeof value === "string" && value.length > 0); +}); +test("language preference is bounded and follows the OS without storage", () => { + assert.equal(detectLanguage("en", ["ru-RU"]), "en"); + assert.equal(detectLanguage("bad", ["ru-RU"]), "ru"); + assert.equal(detectLanguage(undefined, ["pl-PL"]), "en"); + assert.equal(detectLanguage("RU", ["en-US"]), "en"); +}); +test("API keeps authentication on the same origin and sends CSRF only in header", async () => { + let observed: { path: string; options: RequestInit } | undefined; + const result = await request("/v1/auth/logout", { + method: "POST", + csrf: "fixture-csrf", + fetcher: async (path, options) => { + observed = { path, options }; + return new Response(null, { status: 204 }); + }, + }); + assert.equal(result, null); + assert.ok(observed); + assert.equal(observed.path, "/v1/auth/logout"); + assert.equal(observed.options.credentials, "same-origin"); + assert.equal(observed.options.cache, "no-store"); + assert.equal( + new Headers(observed.options.headers).get("X-CSRF-Token"), + "fixture-csrf", + ); + assert.equal(observed.options.method, "POST"); + await assert.rejects( + request("https://evil.example/v1/auth/session"), + TypeError, + ); + await assert.rejects(request("//evil.example/v1/auth/session"), TypeError); +}); +test("API failures expose a generic code and preserve status for expired sessions", async () => { + await assert.rejects( + request("/v1/auth/session", { + fetcher: async () => new Response(null, { status: 401 }), + }), + (error: unknown) => + error instanceof ApiError && + error.status === 401 && + error.message === "request_failed", + ); +}); +test("session validation rejects malformed authenticated payloads", () => { + assert.ok(isSession({ authenticated: false })); + assert.ok( + isSession({ + authenticated: true, + csrf_token: "fixture", + user: { user_id: "fixture", handle: "test", display_name: "Test" }, + }), + ); + assert.equal(isSession({ authenticated: true, user: {} }), false); + assert.equal(isSession({ authenticated: "true" }), false); + assert.equal( + isSession({ + authenticated: true, + csrf_token: "", + user: { user_id: "fixture", handle: "test", display_name: "Test" }, + }), + false, + ); +}); +test("avatars allow only uncredentialed HTTPS GitHub image origin", () => { + assert.equal( + safeAvatar("https://avatars.githubusercontent.com/u/1?v=4"), + "https://avatars.githubusercontent.com/u/1?v=4", + ); + for (const url of [ + "javascript:alert(1)", + "data:image/svg+xml,", + "http://avatars.githubusercontent.com/u/1", + "https://avatars.githubusercontent.com.evil.example/u/1", + "https://evil@avatars.githubusercontent.com/u/1", + "https://avatars.githubusercontent.com:8443/u/1", + "https://evil.example/u/1", + null, + ]) + assert.equal(safeAvatar(url), null); +}); + +test("Hub capabilities reject malformed JSON before enabling sign-in", () => { + assert.ok(isInfo({ capabilities: { github_auth: "enabled" } })); + for (const value of [ + null, + false, + {}, + { capabilities: null }, + { capabilities: { github_auth: true } }, + ]) { + assert.equal(isInfo(value), false); + } +}); diff --git a/tests/server.test.js b/tests/server.test.js deleted file mode 100644 index 915dd7f..0000000 --- a/tests/server.test.js +++ /dev/null @@ -1,16 +0,0 @@ -import test from 'node:test'; -import assert from 'node:assert/strict'; -import { spawn } from 'node:child_process'; -import { once } from 'node:events'; -import http from 'node:http'; -function fetchRaw(port,path){return new Promise((resolve,reject)=>{http.get({host:'127.0.0.1',port,path},response=>{let body='';response.on('data',chunk=>body+=chunk);response.on('end',()=>resolve({status:response.statusCode,body}));}).on('error',reject);});} -test('preview serves only public/source assets and blocks encoded traversal',async t=>{ - const port=24176; - const process=spawn(globalThis.process.execPath,['scripts/serve.mjs'],{env:{...globalThis.process.env,PORT:String(port)},stdio:['ignore','pipe','pipe']}); - t.after(()=>process.kill('SIGTERM')); - await Promise.race([once(process.stdout,'data'),once(process,'exit').then(()=>{throw new Error('preview failed to start');})]); - for(const path of ['/','/account','/account/','/src/app.js','/assets/vnox-mark.png']) assert.equal((await fetchRaw(port,path)).status,200,path); - for(const path of ['/src/%2e%2e%2fpackage.json','/src/%2e%2e%2f.env','/src/%2e%2e%2fLICENSE']) assert.equal((await fetchRaw(port,path)).status,403,path); - assert.equal((await fetchRaw(port,'/package.json')).status,404); - assert.equal((await fetchRaw(port,'/v1/auth/session')).status,503); -}); diff --git a/tests/server.test.ts b/tests/server.test.ts new file mode 100644 index 0000000..6781849 --- /dev/null +++ b/tests/server.test.ts @@ -0,0 +1,72 @@ +import { test, expect } from "bun:test"; +import { spawn } from "node:child_process"; +import { once } from "node:events"; +import http from "node:http"; + +function fetchRaw( + port: number, + path: string, +): Promise<{ status: number | undefined; body: string }> { + return new Promise((resolve, reject) => { + http + .get({ host: "127.0.0.1", port, path }, (response) => { + let body = ""; + response.on("data", (chunk) => { + body += chunk; + }); + response.on("end", () => + resolve({ status: response.statusCode, body }), + ); + }) + .on("error", reject); + }); +} + +test("Bun preview serves browser JavaScript and blocks private files/encoded traversal", async () => { + const child = spawn(process.execPath, ["scripts/serve.ts"], { + env: { ...process.env, PORT: "0" }, + stdio: ["ignore", "pipe", "pipe"], + }); + try { + const output = await Promise.race([ + once(child.stdout, "data").then(([value]) => String(value)), + once(child, "exit").then(() => { + throw new Error("Preview failed to start"); + }), + ]); + const port = Number(output.match(/127\.0\.0\.1:(\d+)/)?.[1]); + expect(port).toBeGreaterThan(0); + for (const path of [ + "/", + "/account", + "/account/", + "/src/app.js", + "/src/styles.css", + "/assets/vnox-mark.png", + ]) { + expect((await fetchRaw(port, path)).status).toBe(200); + } + for (const path of [ + "/src/%2e%2e%2fpackage.json", + "/src/%2e%2e%2f.env", + "/src/%2e%2e%2fLICENSE", + ]) { + expect((await fetchRaw(port, path)).status).toBe(403); + } + for (const path of [ + "/package.json", + "/src/app.ts", + "/src/api.ts", + "/scripts/serve.ts", + ]) { + expect((await fetchRaw(port, path)).status).toBe(404); + } + expect((await fetchRaw(port, "/v1/auth/session")).status).toBe(503); + const javascript = await fetchRaw(port, "/src/app.js"); + expect(javascript.body).not.toContain("import type"); + expect(javascript.body).toContain("vnox-web-language"); + } finally { + child.kill("SIGTERM"); + await once(child, "exit"); + } +}, 15000); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..081f8e8 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2023", + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "module": "ESNext", + "moduleResolution": "Bundler", + "types": ["bun"], + "strict": true, + "noUncheckedIndexedAccess": true, + "noEmit": true, + "isolatedModules": true, + "verbatimModuleSyntax": true, + "allowImportingTsExtensions": true, + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "scripts/**/*.ts", "tests/**/*.ts"] +}