diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..d30081a2 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,5 @@ +# Commits that only reformat or re-header files; `git config blame.ignoreRevsFile .git-blame-ignore-revs` makes git blame skip them. +# Reformat the C++ sources with clang-format (#653) +48eea66d540c4921c447bebab1811f40ed177cd5 +# Reformat with clang-format 23.1.5, the reference version (#653) +32b8d55a732e6333de9537fa6b73b4bc30321a58 diff --git a/.gitattributes b/.gitattributes index 6efadabb..8c6bf328 100644 --- a/.gitattributes +++ b/.gitattributes @@ -37,6 +37,7 @@ # Exclude files from exporting .gitattributes export-ignore .gitignore export-ignore +.git-blame-ignore-revs export-ignore .gitkeep export-ignore # Embedded headers hold the exact bytes of their text sources. Freshness tests diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9e19c234..a4108eef 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -110,6 +110,36 @@ To ensure consistency, we use `.clang-format` and `clang-tidy` to enforce our co Please run these tools on your code before submitting a pull request. +CI runs `.github/scripts/check-clang-format.sh` weekly, on pull requests into `master` and on manual dispatch (not on every pull request into `develop`), on every tracked C++ source (`clang-format --dry-run --Werror`) with a pinned version of `clang-format` +(`.github/workflows/SourceFormat.yml`); the reference version is **clang-format 23.1.5** (`python3 -m pip install clang-format==23.1.5`, or any 23.x: a patch release does not change the output, another major version may); run the script locally with it before you push, and never run `clang-format -i` with another major version. Generated headers (the embedded assets) and the gzip +fixtures are exempt. The commit that reformatted the whole code base is listed in `.git-blame-ignore-revs`; to make `git blame` skip it, run +`git config blame.ignoreRevsFile .git-blame-ignore-revs` once (GitHub applies the file by itself). + +## File header + +Every tracked C++ source (`.hpp`, `.cpp`, `.h`, `.cu`, `.cuh`, `.mm`) starts with this header, before `#pragma once` or the first `#include`: + +```cpp +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: AAAA-MM-JJ +// +// WebFront — +// Role: . +// Thread: | Alloc: +// LLM: +``` + +- **Author** is the author of the file; **Created** is the date of its first commit, in ISO format. +- **Thread** tells where the code may run: `ui-loop` (the thread of `show()` or of the frontend's interface loop), `bridge-io` (the server's I/O context thread), + `worker-safe` (a pure or self-contained unit that any thread may use on its own objects) or `thread-safe` (shared objects synchronized inside). +- **Alloc** tells what the code may allocate: `zero-hot-path` (nothing on the hot path), `heap-init` (heap allocation at construction or setup only) or `unrestricted`. +- **Role** and **LLM** are written for the file, from its content and the invariants of `AGENTS.md` and the ADRs; never copy a generic value. An agent reads them + first, so keep them true when the file changes. +- Files with another license (third-party code) and generated files (the embedded asset headers, the gzip fixtures) keep their own header; they are listed in + `test/cmake/CheckSourceHeaders.cmake`, which fails the `SourceHeaders` CTest case for a tracked source whose header is missing or malformed. +- Build files (`CMakeLists.txt`, `*.cmake`) and the TypeScript under `js/` do not need the header. + ## Changelog format [`docs/CHANGELOG.md`](../docs/CHANGELOG.md) answers three questions quickly: what changes for me, is anything breaking, and diff --git a/.github/scripts/check-clang-format.sh b/.github/scripts/check-clang-format.sh new file mode 100755 index 00000000..518169ad --- /dev/null +++ b/.github/scripts/check-clang-format.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Fails when a tracked C++ source differs from what its clang-format configuration produces (#653). +# .github/scripts/check-clang-format.sh [clang-format] the executable defaults to clang-format +# Each source uses the .clang-format of its directory (include/webfront/, test/, examples/); cmake/ has none and follows include/webfront/. +# Generated or fixed data is exempt; the list matches test/cmake/CheckSourceHeaders.cmake. The reference version is the one pinned in +# .github/workflows/SourceFormat.yml (clang-format 23.1.5): another major version may format differently. +set -euo pipefail + +clang_format="${1:-clang-format}" +cd "$(git rev-parse --show-toplevel)" + +reference_major=23 +version="$("$clang_format" --version)" +if ! grep -Eq "version ${reference_major}\." <<< "$version"; then + echo "warning: the reference is clang-format ${reference_major}.x, this is: $version" >&2 +fi + +exempt='^(include/webfront/system/(DeveloperBootstrapData|DeveloperIndexHtmlData|DeveloperReleaseData|DomInterpreterData|FallbackIndexHtmlData|FallbackModuleData|FaviconData|WebFrontJsData)\.hpp|test/unit/GzipFixtures\.hpp)$' + +status=0 +count=0 +while IFS= read -r file; do + style=file + case "$file" in + cmake/*) style=file:include/webfront/.clang-format ;; + esac + count=$((count + 1)) + if ! "$clang_format" --dry-run --Werror --style="$style" "$file" 2> /dev/null; then + echo "not formatted: $file" + status=1 + fi +done < <(git ls-files '*.hpp' '*.cpp' '*.h' '*.cu' '*.cuh' '*.mm' | grep -Ev "$exempt") + +if [ "$status" -ne 0 ]; then + echo "Run clang-format -i on the files above (version: $("$clang_format" --version))." >&2 +else + echo "$count files formatted" +fi +exit "$status" diff --git a/.github/workflows/SourceFormat.yml b/.github/workflows/SourceFormat.yml new file mode 100644 index 00000000..3c76e1a9 --- /dev/null +++ b/.github/workflows/SourceFormat.yml @@ -0,0 +1,28 @@ +name: Source Format + +# Rare on purpose (#653): the advanced tier only, like the other weekly and release-branch checks. A pull request into develop is not checked. +on: + pull_request: + branches: [ master ] + schedule: + - cron: '23 4 * * 1' + workflow_dispatch: + +permissions: + contents: read + +jobs: + clang-format: + name: clang-format + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + # The version is pinned: clang-format changes its output from one release to the next. + - name: Install clang-format + run: python3 -m pip install --user clang-format==23.1.5 + + - name: Check the tracked sources + run: .github/scripts/check-clang-format.sh "$HOME/.local/bin/clang-format" diff --git a/AGENTS.md b/AGENTS.md index e70646a1..a7b60aa7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -117,6 +117,7 @@ Exception: a purely C++ change that reuses an existing encoding, introduces no n ## Coding and testing conventions - Use C++23, four-space indentation, the `.clang-format` of the directory (`include/webfront/`, `test/`, `examples/`), and the naming rules in `.github/CONTRIBUTING.md`. +- Every tracked C++ source starts with the normalized file header (SPDX, Author, Created, subsystem, Role, Thread, Alloc, LLM) described in `.github/CONTRIBUTING.md`; read it first, keep it true when you change the file, and give a new file one. The `SourceHeaders` CTest case checks it, and CI checks the format with `.github/scripts/check-clang-format.sh` (pinned `clang-format`); generated headers are exempt. - Keep production implementation header-only under `include/`; browser resources live in `js/`. - Prefer standard-library facilities and explicit ownership. Keep public headers ODR-safe (`inline`/templates as appropriate). - Unit tests are named `const Scenario` objects whose `given`/`when`/`then` sections are lambdas, checked with `require`/`check` (`include/webfront/testing/Bdd.hpp`), and use deterministic mocks. diff --git a/cmake/mddlog/Logger.cpp b/cmake/mddlog/Logger.cpp index 96123a70..addc7f6c 100644 --- a/cmake/mddlog/Logger.cpp +++ b/cmake/mddlog/Logger.cpp @@ -1,4 +1,12 @@ -/** @brief WebFront-owned module-consuming TU; the facade header remains independent of modules. */ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-01 +// +// WebFront — build/mddlog +// Role: WebFront-owned module-consuming translation unit implementing the logger facade over mddlog; the facade header stays independent of modules. +// Thread: thread-safe | Alloc: unrestricted +// LLM: compiled only when modules are available; keep module types out of LoggerApi.hpp + import std; import mddlog.core.loglevel; import mddlog.adapter.textlogger; @@ -307,7 +315,7 @@ RingClaim::~RingClaim() { /** @brief Stops the consumer during static destruction, before the text adapter it may use. */ struct LaneShutdown { - explicit LaneShutdown(TransportLane& value) : lane(&value) {} + explicit LaneShutdown(TransportLane& value) : lane(&value) { } LaneShutdown(const LaneShutdown&) = delete; LaneShutdown& operator=(const LaneShutdown&) = delete; LaneShutdown(LaneShutdown&&) = delete; @@ -503,15 +511,15 @@ TransportHandle addTransport(std::function write) const auto text = renderTransportText(record); try { write({.level = facadeLevel(record.level), - .timeAvailable = record.timeAvailable, - .time = std::chrono::time_point_cast(record.timestamp), - .location = record.location, - .message = record.message, - .messageTruncated = record.messageTruncated, - .component = record.category, - .operationId = record.operationId, - .correlationId = record.correlationId, - .text = text}); + .timeAvailable = record.timeAvailable, + .time = std::chrono::time_point_cast(record.timestamp), + .location = record.location, + .message = record.message, + .messageTruncated = record.messageTruncated, + .component = record.category, + .operationId = record.operationId, + .correlationId = record.correlationId, + .text = text}); } catch (...) { // TransportConsumer detaches this transport and counts the failure. static_cast(lane.detach(*attached)); diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 89f45756..0aabe7f0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -51,6 +51,7 @@ in a native pseudoterminal, and a faster, less flashy start of the native window - Choose the colour of the WebKitGTK view under the page with `WindowOptions::background` (WebKitGTK; the other embedded frontends are listed here), and read the start-up milestones of a WebKitGTK view with `WEBFRONT_STARTUP_TRACE=1` (#611, `docs/WEBKITGTK.md`). ### Changed +- The whole C++ code base is reformatted with `clang-format` and every source starts with a normalized header (SPDX, author, creation date, role, thread and allocation model, reading hint); CI checks both (`SourceHeaders` case, `.github/workflows/SourceFormat.yml`), and `.git-blame-ignore-revs` skips the reformatting in `git blame` (#653, `.github/CONTRIBUTING.md`). - WebKitGTK takes a `startupTimeout` (30 s by default), and WebView2 refuses a secondary window once the first one closed, even for a page already open (#652). - Open every native window from one `ViewOptions` (`WKWebViewOptions` and `WebView2Options` are aliases), whose test injections reach the secondary windows too (#652, `docs/FRONTENDS.md`). - Write a native frontend from shared headers: `EmbeddedFrontend` (facade and every `open()` overload), `WindowRegistry`/`InterfaceSession`, `StartupTrace` and `Presentation`, tested on Linux with fake windows (#652, `docs/FRONTENDS.md`). diff --git a/examples/.clang-format b/examples/.clang-format index 45e9ebf1..f0d2f8fa 100644 --- a/examples/.clang-format +++ b/examples/.clang-format @@ -1,6 +1,6 @@ --- # Modern C++20+ clang-format configuration for WebFront project -# Compatible with clang-format 22+ +# Reference version: clang-format 23.1.5 (pinned in .github/workflows/SourceFormat.yml); another major version may format differently Language: Cpp BasedOnStyle: WebKit diff --git a/examples/PortOption.hpp b/examples/PortOption.hpp index 13da9498..c9d5ee2a 100644 --- a/examples/PortOption.hpp +++ b/examples/PortOption.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-20 +// +// WebFront — examples +// Role: Handles `--port ` and `--port=` of an example and makes it the default port of the applications that follow. +// Thread: ui-loop | Alloc: heap-init +// LLM: example support; prints the reason and returns false on an invalid value + #pragma once #include diff --git a/examples/hello-world/HelloWorld.cpp b/examples/hello-world/HelloWorld.cpp index aaa55a73..f7801bb9 100644 --- a/examples/hello-world/HelloWorld.cpp +++ b/examples/hello-world/HelloWorld.cpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2022-02-03 +// +// WebFront — examples +// Role: Minimal example: a C++ callback called from the browser, served by an embedded page. +// Thread: ui-loop | Alloc: unrestricted +// LLM: smallest complete application; the README quick start must stay in step with it + #include // Switching to an embedded Chromium window only changes this alias (CEF must be enabled at diff --git a/examples/host-loop/BoingCuda.cu b/examples/host-loop/BoingCuda.cu index 92cdb998..1d53094b 100644 --- a/examples/host-loop/BoingCuda.cu +++ b/examples/host-loop/BoingCuda.cu @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-16 +// +// WebFront — examples +// Role: CUDA unit of the host-loop example: the ray-traced Boing Ball computed on the device. +// Thread: worker-safe | Alloc: unrestricted +// LLM: optional CUDA build; device memory is allocated lazily and freed by cudaRelease + // The CUDA renderer of the Boing Ball: one thread per pixel runs the same pixel() as the CPU renderer. // Compiled by nvcc at C++17; includes no WebFront header. @@ -25,8 +34,8 @@ const char* failure(cudaError_t status) { } // namespace const char* cudaDevice() { - static char name[256] = ""; - int count = 0; + static char name[256] = ""; + int count = 0; cudaDeviceProp properties; if (name[0] == '\0' && cudaGetDeviceCount(&count) == cudaSuccess && count > 0 && cudaGetDeviceProperties(&properties, 0) == cudaSuccess) for (std::size_t i = 0; i + 1 < sizeof name && properties.name[i] != '\0'; ++i) diff --git a/examples/host-loop/BoingCuda.hpp b/examples/host-loop/BoingCuda.hpp index e05e97c4..8752454b 100644 --- a/examples/host-loop/BoingCuda.hpp +++ b/examples/host-loop/BoingCuda.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-16 +// +// WebFront — examples +// Role: Interface of the optional CUDA unit: device name, whole-image computation, copy back and release. +// Thread: worker-safe | Alloc: zero-hot-path +// LLM: functions return nullptr or the reason of a failure; see docs/HOST_LOOP_EXAMPLE.md + #pragma once // The optional CUDA renderer of the Boing Ball (BoingCuda.cu). Its interface is plain C++ so that the unit nvcc @@ -30,7 +39,7 @@ inline const char* cudaCompute(const Scene&) { inline const char* cudaCopy(std::uint32_t*, std::size_t) { return "this build has no CUDA renderer"; } -inline void cudaRelease() {} +inline void cudaRelease() { } #endif } // namespace boing diff --git a/examples/host-loop/BoingHost.hpp b/examples/host-loop/BoingHost.hpp index 79058942..a410e934 100644 --- a/examples/host-loop/BoingHost.hpp +++ b/examples/host-loop/BoingHost.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-16 +// +// WebFront — examples +// Role: Host of the Boing Ball example: engines, image quality and the frames the host loop produces for the browser. +// Thread: worker-safe | Alloc: unrestricted +// LLM: example of an application keeping its own loop; see docs/HOST_LOOP_EXAMPLE.md + #pragma once // The host application of the example: it owns the scene, its clock, the renderers and its loop. Nothing here knows @@ -265,7 +274,7 @@ class Host { Settings settings; std::uint32_t revision{0}; std::map waiting; - std::set inFlight; // retained until this consumer's delivery begins + std::set inFlight; // retained until this consumer's delivery begins Displayed lastDisplayed; bool stopping{false}, ended{false}; diff --git a/examples/host-loop/BoingScene.hpp b/examples/host-loop/BoingScene.hpp index fdd2c916..89e4a42d 100644 --- a/examples/host-loop/BoingScene.hpp +++ b/examples/host-loop/BoingScene.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-16 +// +// WebFront — examples +// Role: The animated Boing Ball scene and its CPU ray tracer, a pure function of time. +// Thread: worker-safe | Alloc: zero-hot-path +// LLM: deterministic computation; the CUDA unit must produce the same image + #pragma once // The Boing Ball scene: the colour of one pixel as a function of the scene of a frame. The CPU renderer and the CUDA @@ -236,11 +245,11 @@ BOING_FN std::uint32_t pixel(const Scene& scene, int x, int y) { const float toBall = hitBall(scene, camera, direction), toFloor = hitFloor(camera, direction); const auto ray = static_cast(x) * 1973U + static_cast(y) * 9277U + static_cast(sy * 2 + sx) * 26699U; sum = sum - + beamsAlong(scene, - camera, - direction, - toBall > 0.F && (toFloor <= 0.F || toBall < toFloor) ? toBall : toFloor, - static_cast(ray & 255U) / 256.F); + + beamsAlong(scene, + camera, + direction, + toBall > 0.F && (toFloor <= 0.F || toBall < toFloor) ? toBall : toFloor, + static_cast(ray & 255U) / 256.F); } } const float scale = 1.F / static_cast(scene.samples * scene.samples); diff --git a/examples/host-loop/HostLoop.cpp b/examples/host-loop/HostLoop.cpp index fdf0c011..f57ff59a 100644 --- a/examples/host-loop/HostLoop.cpp +++ b/examples/host-loop/HostLoop.cpp @@ -1,6 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-13 +// +// WebFront — examples +// Role: Host-loop example application: runs the Boing Ball beside a native window or a system browser, or as a benchmark. +// Thread: ui-loop | Alloc: unrestricted +// LLM: example entry point; see docs/HOST_INTEGRATION.md for the three integration paths + +#include "../PortOption.hpp" #include "HostLoopCapture.hpp" #include "HostLoopUI.hpp" -#include "../PortOption.hpp" #include #include @@ -80,17 +89,18 @@ int runWithBrowser(boing::Host& host, const Options& options) { int runWithWindow(boing::Host& host, const Options& options) { using App = webfront::WebFrontWithFrontend; // The server's connection handler refers to these; keep them alive until after app is destroyed. - std::mutex uiMutex; + std::mutex uiMutex; std::optional captureUI; - App app{webfront::WebFrontConfig{.window = {.title = "WebFront host loop", .width = options.captureDemo ? 640 : 800, .height = options.captureDemo ? 480 : 600}}}; + App app{webfront::WebFrontConfig{ + .window = {.title = "WebFront host loop", .width = options.captureDemo ? 640 : 800, .height = options.captureDemo ? 480 : 600}}}; boing::install(app, host); app.onUIStarted([&](App::UI ui) { const std::scoped_lock lock{uiMutex}; - captureUI = ui; + captureUI = ui; const std::string mode = options.captureFrames > 1 - ? (options.settings.glass ? "globalThis.hostLoopCapture = {glass: true};" : "globalThis.hostLoopCapture = {glass: false};") : ""; - const std::string style = options.captureDemo - ? "document.querySelector('#host-loop .stats').remove();" : ""; + ? (options.settings.glass ? "globalThis.hostLoopCapture = {glass: true};" : "globalThis.hostLoopCapture = {glass: false};") + : ""; + const std::string style = options.captureDemo ? "document.querySelector('#host-loop .stats').remove();" : ""; ui.addScript(mode + ownPage + style); }); std::atomic showReturned{false}; @@ -135,7 +145,7 @@ int runWithWindow(boing::Host& host, const Options& options) { return; if (options.captureFrames > 1) { const bool glass = options.captureDemo ? i >= options.captureFrames * 2 / 3 : options.settings.glass; - auto drawn = ui->jsFunction("hostLoop.captureNext")(glass); + auto drawn = ui->jsFunction("hostLoop.captureNext")(glass); if (drawn.wait_for(10s) != std::future_status::ready) throw std::runtime_error("No capture: the browser did not draw the next frame"); (void)drawn.get(); @@ -228,7 +238,7 @@ bool parse(std::span arguments, Options& options) { if (options.captureDemo && !captureFramesSpecified) options.captureFrames = 300; return (!(captureFramesSpecified || options.captureDemo) || !options.capture.empty()) - && (!options.captureDemo || (options.captureFrames >= 3 && options.captureFrames % 3 == 0)); + && (!options.captureDemo || (options.captureFrames >= 3 && options.captureFrames % 3 == 0)); } } // namespace @@ -237,18 +247,18 @@ int main(int argc, char** argv) { return 2; Options options; if (!parse({argv + 1, static_cast(argc - 1)}, options)) { - std::cerr - << "Usage: WebFrontHostLoop [--port ] [--engine cpu|cuda] [--quality 0-3] [--glass] [--browser] [--stats] [--capture ] [--capture-frames 1-600] [--capture-demo]\n" - " WebFrontHostLoop --benchmark\n" - " --engine the renderer at start (default cpu); cuda is an error where it is unavailable\n" - " --quality 0: 320x240, 1: 640x480, 2: 640x480 with 4 rays per pixel, 3: 960x720 with 4 (default)\n" - " --port the port of the browser interface, 0 for a free port (default WEBFRONT_PORT, else 9002)\n" - " --browser open the system browser even when the native window is built\n" - " --stats print the timings of an image every second\n" - " --capture write a PNG of the native window after six seconds, then stop\n" - " --capture-frames save numbered PNGs with a fixed 25 fps scene clock (default 1); requires --capture\n" - " --capture-demo hide statistics and switch to glass after two thirds (default 300 frames)\n" - " --benchmark time both renderers without any interface, and exit\n"; + std::cerr << "Usage: WebFrontHostLoop [--port ] [--engine cpu|cuda] [--quality 0-3] [--glass] [--browser] [--stats] [--capture ] " + "[--capture-frames 1-600] [--capture-demo]\n" + " WebFrontHostLoop --benchmark\n" + " --engine the renderer at start (default cpu); cuda is an error where it is unavailable\n" + " --quality 0: 320x240, 1: 640x480, 2: 640x480 with 4 rays per pixel, 3: 960x720 with 4 (default)\n" + " --port the port of the browser interface, 0 for a free port (default WEBFRONT_PORT, else 9002)\n" + " --browser open the system browser even when the native window is built\n" + " --stats print the timings of an image every second\n" + " --capture write a PNG of the native window after six seconds, then stop\n" + " --capture-frames save numbered PNGs with a fixed 25 fps scene clock (default 1); requires --capture\n" + " --capture-demo hide statistics and switch to glass after two thirds (default 300 frames)\n" + " --benchmark time both renderers without any interface, and exit\n"; return 2; } // WebFront's warnings on the console: a development build says there that its native window has no sandbox. diff --git a/examples/host-loop/HostLoopCapture.hpp b/examples/host-loop/HostLoopCapture.hpp index 21f73f9f..97b95751 100644 --- a/examples/host-loop/HostLoopCapture.hpp +++ b/examples/host-loop/HostLoopCapture.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-16 +// +// WebFront — examples +// Role: Bounded capture options of the host-loop example: frame count, file naming and checked writes. +// Thread: worker-safe | Alloc: heap-init +// LLM: example support; at most 600 frames at a fixed 25 fps scene clock + #pragma once #include diff --git a/examples/host-loop/HostLoopUI.hpp b/examples/host-loop/HostLoopUI.hpp index 2c24cd54..1fa88556 100644 --- a/examples/host-loop/HostLoopUI.hpp +++ b/examples/host-loop/HostLoopUI.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-16 +// +// WebFront — examples +// Role: The page of the host-loop example and the callbacks that connect it to the host. +// Thread: bridge-io | Alloc: unrestricted +// LLM: example UI; the host must outlive the application that registers its callbacks + #pragma once // The interface WebFront adds to the host: four callbacks and one page. The callbacks run on WebFront's server thread diff --git a/examples/life/Life.hpp b/examples/life/Life.hpp index 590cfd5e..3a2777ba 100644 --- a/examples/life/Life.hpp +++ b/examples/life/Life.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-20 +// +// WebFront — examples +// Role: Game of Life rules shared by the console, developer and embedded stages. +// Thread: worker-safe | Alloc: heap-init +// LLM: pure computation of the walkthrough; no WebFront dependency + #pragma once #include diff --git a/examples/life/LifeConsole.cpp b/examples/life/LifeConsole.cpp index b65a5672..24100c28 100644 --- a/examples/life/LifeConsole.cpp +++ b/examples/life/LifeConsole.cpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-20 +// +// WebFront — examples +// Role: Console stage of the Game of Life walkthrough. +// Thread: ui-loop | Alloc: unrestricted +// LLM: first stage of the README walkthrough + #include "Life.hpp" #include diff --git a/examples/life/LifeDeveloper.cpp b/examples/life/LifeDeveloper.cpp index 754799cb..983f9d58 100644 --- a/examples/life/LifeDeveloper.cpp +++ b/examples/life/LifeDeveloper.cpp @@ -1,7 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-20 +// +// WebFront — examples +// Role: Developer stage of the Game of Life walkthrough: the application opens the developer environment on a project. +// Thread: ui-loop | Alloc: unrestricted +// LLM: uses NativeApp::bootstrap("developer"); options live in LifeDeveloperOptions.hpp + +#include "../PortOption.hpp" #include "Life.hpp" -#include "LifeFrontend.hpp" #include "LifeDeveloperOptions.hpp" -#include "../PortOption.hpp" +#include "LifeFrontend.hpp" #include #include diff --git a/examples/life/LifeDeveloperOptions.hpp b/examples/life/LifeDeveloperOptions.hpp index 822a328e..33a14865 100644 --- a/examples/life/LifeDeveloperOptions.hpp +++ b/examples/life/LifeDeveloperOptions.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-25 +// +// WebFront — examples +// Role: Command line of WebFrontLifeDeveloper: project directory and optional pinned environment tarball. +// Thread: ui-loop | Alloc: heap-init +// LLM: example support; no argument selects life-project in the current directory + #pragma once #include @@ -10,9 +19,9 @@ namespace webfront::demo { struct LifeDeveloperOptions { static constexpr const char* defaultProject = "life-project"; - std::filesystem::path project = defaultProject; - std::optional environment; - std::optional integrity; + std::filesystem::path project = defaultProject; + std::optional environment; + std::optional integrity; }; /// Returns nullopt when the arguments do not follow the usage; no argument selects `life-project` in the diff --git a/examples/life/LifeEmbedded.cpp b/examples/life/LifeEmbedded.cpp index 94a80ee5..3bdfb6c1 100644 --- a/examples/life/LifeEmbedded.cpp +++ b/examples/life/LifeEmbedded.cpp @@ -1,8 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-20 +// +// WebFront — examples +// Role: Embedded stage of the Game of Life walkthrough: the compiled UI served from the embedded provider. +// Thread: ui-loop | Alloc: unrestricted +// LLM: final stage of the README walkthrough; the provider is generated by wf embed + #include #include WEBFRONT_LIFE_ASSETS_HEADER +#include "../PortOption.hpp" #include "Life.hpp" #include "LifeFrontend.hpp" -#include "../PortOption.hpp" #include diff --git a/examples/life/LifeFrontend.hpp b/examples/life/LifeFrontend.hpp index 65909e45..7b10764e 100644 --- a/examples/life/LifeFrontend.hpp +++ b/examples/life/LifeFrontend.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-25 +// +// WebFront — examples +// Role: Selects the frontend of the Game of Life examples. +// Thread: ui-loop | Alloc: zero-hot-path +// LLM: alias only; the examples never select CEF + #pragma once #include diff --git a/examples/life/react/LifeReact.cpp b/examples/life/react/LifeReact.cpp index a69f6d7e..8e11417a 100644 --- a/examples/life/react/LifeReact.cpp +++ b/examples/life/react/LifeReact.cpp @@ -1,8 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-27 +// +// WebFront — examples +// Role: Game of Life variant with a C++ panel inside a React page. +// Thread: ui-loop | Alloc: unrestricted +// LLM: see docs/REACT.md; entry point of the react variant + #include "LifeReact.hpp" +#include "../../PortOption.hpp" #include "../LifeDeveloperOptions.hpp" #include "../LifeFrontend.hpp" -#include "../../PortOption.hpp" #include #include @@ -14,7 +23,8 @@ int main(int argc, char** argv) { if (argc > 2 || (argc == 2 && *argv[1] == '\0')) { std::cerr << "Usage: WebFrontLifeReact [--port ] []\n" "Without argument the project is ./" - << webfront::demo::LifeDeveloperOptions::defaultProject << ", created empty when missing: copy main.tsx and webfront.project.json from examples/life/react/ into it first.\n"; + << webfront::demo::LifeDeveloperOptions::defaultProject + << ", created empty when missing: copy main.tsx and webfront.project.json from examples/life/react/ into it first.\n"; return 2; } try { diff --git a/examples/life/react/LifeReact.hpp b/examples/life/react/LifeReact.hpp index a4f44fb8..b9e30e1c 100644 --- a/examples/life/react/LifeReact.hpp +++ b/examples/life/react/LifeReact.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-27 +// +// WebFront — examples +// Role: The C++ side of the React variant: per-browser sessions publishing snapshots through a Store. +// Thread: bridge-io | Alloc: unrestricted +// LLM: example of react::Store; one Session per connected browser + #pragma once #include "../Life.hpp" #include diff --git a/examples/pty/main.cpp b/examples/pty/main.cpp index b27495c9..87046dfc 100644 --- a/examples/pty/main.cpp +++ b/examples/pty/main.cpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-19 +// +// WebFront — examples +// Role: Standalone PTY example: a native pseudoterminal shown in an xterm.js page. +// Thread: ui-loop | Alloc: unrestricted +// LLM: has its own CMake entry point; see docs/PTY.md + #include #include #ifdef _WIN32 diff --git a/include/webfront/.clang-format b/include/webfront/.clang-format index 45e9ebf1..f0d2f8fa 100644 --- a/include/webfront/.clang-format +++ b/include/webfront/.clang-format @@ -1,6 +1,6 @@ --- # Modern C++20+ clang-format configuration for WebFront project -# Compatible with clang-format 22+ +# Reference version: clang-format 23.1.5 (pinned in .github/workflows/SourceFormat.yml); another major version may format differently Language: Cpp BasedOnStyle: WebKit diff --git a/include/webfront/ApplicationOrigin.hpp b/include/webfront/ApplicationOrigin.hpp index 92e02914..03e07eb5 100644 --- a/include/webfront/ApplicationOrigin.hpp +++ b/include/webfront/ApplicationOrigin.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-18 +// +// WebFront — core +// Role: Canonical application authority (host, port, scheme) shared by the HTTP server and the frontend URL builders. +// Thread: worker-safe | Alloc: heap-init +// LLM: pure string helpers; keep in sync with the origin checks of ContentPolicy.hpp + #pragma once #include diff --git a/include/webfront/BridgeError.hpp b/include/webfront/BridgeError.hpp index c9e05c6f..2197cddc 100644 --- a/include/webfront/BridgeError.hpp +++ b/include/webfront/BridgeError.hpp @@ -1,4 +1,12 @@ -/// @brief The failure of a bridge call, with a code that lets the caller tell failures apart. +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-05 +// +// WebFront — core +// Role: The failure of a bridge call, with a code that lets the caller tell failures apart. +// Thread: worker-safe | Alloc: unrestricted +// LLM: public API; reserved `webfront.` codes are part of the wire contract with WebFront.js + #pragma once #include @@ -39,7 +47,7 @@ inline constexpr std::string_view cancelled = "webfront.cancelled"; */ class BridgeError : public std::runtime_error { public: - static constexpr std::size_t maxCodeSize = 64; + static constexpr std::size_t maxCodeSize = 64; static constexpr std::string_view reservedPrefix = "webfront."; /// @throws std::invalid_argument for an ill-formed or reserved code @@ -73,8 +81,8 @@ class BridgeError : public std::runtime_error { private: friend BridgeError detail::makeBridgeError(std::string_view, const std::string&); - struct Bridge {}; - BridgeError(Bridge, std::string errorCode, const std::string& message) : std::runtime_error(message), codeText(std::move(errorCode)) {} + struct Bridge { }; + BridgeError(Bridge, std::string errorCode, const std::string& message) : std::runtime_error(message), codeText(std::move(errorCode)) { } std::string codeText; }; diff --git a/include/webfront/Broadcast.hpp b/include/webfront/Broadcast.hpp index ecabf617..52d7ca85 100644 --- a/include/webfront/Broadcast.hpp +++ b/include/webfront/Broadcast.hpp @@ -1,5 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 OR CECILL-B -/// @brief A JavaScript function called on every connected browser (BasicWF::broadcast). +// Author: Ambroise Leclerc +// Created: 2026-10-30 +// +// WebFront — core +// Role: A JavaScript function called on every connected browser (BasicWF::broadcast), with an optional per-browser backlog limit. +// Thread: thread-safe | Alloc: unrestricted +// LLM: public API; read BroadcastOptions before the sender implementation + #pragma once #include "http/WebSocket.hpp" #include "weblink/CallFrame.hpp" diff --git a/include/webfront/Commands.hpp b/include/webfront/Commands.hpp index 0129c6e0..20cf04c7 100644 --- a/include/webfront/Commands.hpp +++ b/include/webfront/Commands.hpp @@ -1,5 +1,15 @@ -/// @brief Terminal commands of an application: coroutines that the developer environment's terminal discovers and -/// runs, one browser session at a time, streaming their output and cancelled by Ctrl+C, a disconnection or shutdown. +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-22 +// +// WebFront — core +// Role: Terminal commands of an application: coroutines the developer environment's terminal discovers and runs, one browser session at a time. +// Thread: bridge-io | Alloc: unrestricted +// LLM: public API; read the command contract and reserved names before the registration code + +// Terminal commands of an application: coroutines that the developer environment's terminal discovers and +// runs, one browser session at a time, streaming their output and cancelled by Ctrl+C, a disconnection or shutdown. + #pragma once #include "networking/Tasks.hpp" @@ -81,8 +91,8 @@ inline std::vector parseArguments(std::string_view json) { inline void validateName(std::string_view name) { const auto invalid = name.empty() || std::ranges::any_of(name, [](char c) { - return static_cast(c) <= ' ' || c == '\x7f' || c == '\'' || c == '"' || c == '\\'; - }); + return static_cast(c) <= ' ' || c == '\x7f' || c == '\'' || c == '"' || c == '\\'; + }); if (invalid) throw std::invalid_argument("Invalid command name '" + std::string(name) + "'"); if (std::ranges::find(reservedNames, name) != reservedNames.end()) @@ -98,8 +108,8 @@ struct Run { int exitCode = 0; // The command's own stop source, requested with its task's: a copy of the Context that outlives the task still // reads a valid source. - ex::inplace_stop_source stop; - std::atomic disconnected{false}; + ex::inplace_stop_source stop; + std::atomic disconnected{false}; Run(UI caller, std::uint32_t commandId, std::vector args) : ui(std::move(caller)), id(commandId), arguments(std::move(args)) { } @@ -314,19 +324,20 @@ class Registry : public std::enable_shared_from_this> { // command it stopped waiting for. A stopped command still reports: its coroutine was unwound, not this one. struct ForwardStop { Run* run; - void operator()() noexcept { run->stop.request_stop(); } + void operator()() noexcept { + run->stop.request_stop(); + } }; static Task execute(std::weak_ptr registry, std::shared_ptr handler, std::shared_ptr> run) { const auto taskStop = co_await ex::read_env(ex::get_stop_token); // Forwards the task's stop request (Ctrl+C, disconnection, shutdown) to the command's source while it runs. const ex::stop_callback_for_t, ForwardStop> forward{taskStop, ForwardStop{run.get()}}; - bool stopped = false; - std::string error; + bool stopped = false; + std::string error; try { // The command observes its own source: requested before the senders it awaits are stopped. - co_await ex::let_stopped(ex::write_env((*handler)(Context{run}), ex::prop{ex::get_stop_token, run->stop.get_token()}), - [&stopped]() noexcept { + co_await ex::let_stopped(ex::write_env((*handler)(Context{run}), ex::prop{ex::get_stop_token, run->stop.get_token()}), [&stopped]() noexcept { stopped = true; return ex::just(); }); @@ -382,7 +393,8 @@ class Commands { return owner->list(); })); registered(app.template cppFunction( - "webfront.commands.start", [owner = registry](UI ui, std::uint32_t id, const std::string& name, const std::string& arguments) { + "webfront.commands.start", + [owner = registry](UI ui, std::uint32_t id, const std::string& name, const std::string& arguments) { owner->start(std::move(ui), id, name, arguments); })); registered(app.template cppFunction("webfront.commands.cancel", [owner = registry](UI ui, std::uint32_t id) { diff --git a/include/webfront/ContentPolicy.hpp b/include/webfront/ContentPolicy.hpp index 2ad1aecd..91f42648 100644 --- a/include/webfront/ContentPolicy.hpp +++ b/include/webfront/ContentPolicy.hpp @@ -1,3 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-18 +// +// WebFront — core +// Role: Shared per-application content rules (origins, popups, navigation) applied by every frontend. +// Thread: worker-safe | Alloc: heap-init +// LLM: public API; see docs/CONTENT_POLICY.md before changing defaults + #pragma once #include diff --git a/include/webfront/DeferredCalls.hpp b/include/webfront/DeferredCalls.hpp index b45c22e0..e22ded7a 100644 --- a/include/webfront/DeferredCalls.hpp +++ b/include/webfront/DeferredCalls.hpp @@ -1,4 +1,12 @@ -/// @brief The JavaScript calls a C++ callback has not answered yet, per browser connection. +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-05 +// +// WebFront — core +// Role: The JavaScript calls a C++ callback has not answered yet, per browser connection. +// Thread: bridge-io | Alloc: unrestricted +// LLM: internal; completion may come from any thread, keep the per-connection ownership rules intact + #pragma once #include "Task.hpp" @@ -7,8 +15,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -104,11 +112,11 @@ class DeferredCalls { } private: - mutable std::mutex mutex; - std::set inFlightIds; + mutable std::mutex mutex; + std::set inFlightIds; std::map> tasks; - std::uint64_t lastKey = 0; - bool closed = false; + std::uint64_t lastKey = 0; + bool closed = false; }; } // namespace webfront::detail diff --git a/include/webfront/DeveloperApp.hpp b/include/webfront/DeveloperApp.hpp index f2ce65fa..01420ab6 100644 --- a/include/webfront/DeveloperApp.hpp +++ b/include/webfront/DeveloperApp.hpp @@ -1,4 +1,12 @@ -/// @brief Opt-in developer environment (terminal and wf commands) running in the application window. Downloaded code has project/bridge authority. +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-20 +// +// WebFront — core +// Role: Opt-in developer environment (terminal and wf commands) running in the application window. +// Thread: ui-loop | Alloc: heap-init +// LLM: public API; downloaded code has project and bridge authority, read DeveloperBootstrapOptions first + #pragma once #include "system/DeveloperFS.hpp" @@ -66,11 +74,10 @@ inline constexpr std::string_view defaultRegistry{"https://registry.npmjs.org/"} /// The configuration the environment reads. "registry" always names a usable registry, for environments /// that predate "registryExplicit"; the latter tells whether the application chose it. inline std::string bootstrapConfig(const DeveloperBootstrapOptions& options) { - return "{\"environment\":" + json::quote(options.environment) + ",\"integrity\":" + json::quote(options.integrity) - + ",\"registry\":" + json::quote(options.registry.value_or(std::string(defaultRegistry))) - + ",\"registryExplicit\":" + (options.registry ? "true" : "false") - + (options.manifestDirectory.empty() ? std::string{} : ",\"manifestDirectory\":" + json::quote(options.manifestDirectory)) - + ",\"supported\":{\"protocol\":[" + std::to_string(protocolVersion) + "],\"api\":[" + std::to_string(apiVersion) + "]}}"; + return "{\"environment\":" + json::quote(options.environment) + ",\"integrity\":" + json::quote(options.integrity) + ",\"registry\":" + + json::quote(options.registry.value_or(std::string(defaultRegistry))) + ",\"registryExplicit\":" + (options.registry ? "true" : "false") + + (options.manifestDirectory.empty() ? std::string{} : ",\"manifestDirectory\":" + json::quote(options.manifestDirectory)) + + ",\"supported\":{\"protocol\":[" + std::to_string(protocolVersion) + "],\"api\":[" + std::to_string(apiVersion) + "]}}"; } } // namespace developer diff --git a/include/webfront/JsFunction.hpp b/include/webfront/JsFunction.hpp index 3b1c1863..6541f757 100644 --- a/include/webfront/JsFunction.hpp +++ b/include/webfront/JsFunction.hpp @@ -1,6 +1,12 @@ -/// @date 04/02/2022 13:15:27 -/// @author Ambroise Leclerc -/// @brief A functor which invokes a corresponding javascript function +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2022-02-04 +// +// WebFront — core +// Role: A functor that invokes a corresponding JavaScript function, fire-and-forget or returning a std::future. +// Thread: worker-safe | Alloc: unrestricted +// LLM: public API; the untyped form is fire-and-forget, the typed form returns a future + #pragma once #include "http/WebSocket.hpp" #include "tooling/HexDump.hpp" @@ -12,24 +18,23 @@ #include #include #include +#include #include #include #include #include -#include - namespace webfront { namespace detail { -struct IgnoreJsResult {}; -} +struct IgnoreJsResult { }; +} // namespace detail -template +template class JsFunction { public: JsFunction(std::string_view functionName, WebFront& wf, WebLinkId linkId, WebLinkGeneration connectionGeneration) - : name(functionName), webFront(wf), webLinkId(linkId), generation(connectionGeneration) {} + : name(functionName), webFront(wf), webLinkId(linkId), generation(connectionGeneration) { } auto operator()(auto&&... ts) { msg::FunctionCall command; @@ -58,10 +63,10 @@ class JsFunction { } private: - std::string name; - WebFront& webFront; - WebLinkId webLinkId; + std::string name; + WebFront& webFront; + WebLinkId webLinkId; WebLinkGeneration generation; }; -} // namespace webfront +} // namespace webfront diff --git a/include/webfront/JsFunctionSender.hpp b/include/webfront/JsFunctionSender.hpp index a7ffcf68..273140d3 100644 --- a/include/webfront/JsFunctionSender.hpp +++ b/include/webfront/JsFunctionSender.hpp @@ -1,4 +1,12 @@ -/// @brief Lazy, cancellable C++ to browser calls using C++26 sender completions. +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-10-18 +// +// WebFront — core +// Role: Lazy, cancellable C++ to browser calls using C++26 sender completions. +// Thread: worker-safe | Alloc: unrestricted +// LLM: internal; cancellation is local, a late reply is discarded; see docs/ASYNC_EXECUTION.md + #pragma once #include "http/WebSocket.hpp" #include "weblink/CallFrame.hpp" @@ -199,11 +207,11 @@ class BrowserCallSender { public: using operation_state_concept = ex::operation_state_tag; explicit Operation(std::shared_ptr> value) : state(std::move(value)) { } - Operation(const Operation&) = delete; - Operation(Operation&&) = delete; - Operation& operator=(const Operation&) = delete; - Operation& operator=(Operation&&) = delete; - void start() noexcept { + Operation(const Operation&) = delete; + Operation(Operation&&) = delete; + Operation& operator=(const Operation&) = delete; + Operation& operator=(Operation&&) = delete; + void start() noexcept { auto keepAlive = state; // receiver completion may destroy this operation inline keepAlive->start(); } @@ -249,7 +257,7 @@ class JsFunctionSender { auto operator()(auto&&... arguments) const { msg::FunctionCall command; const auto frame = detail::encodeCall(command, name, std::forward(arguments)...); - std::vector payload; + std::vector payload; payload.reserve(frame.size()); auto buffers = frame.toBuffers(); for (std::size_t i = 1; i < buffers.size(); ++i) { diff --git a/include/webfront/Pty.hpp b/include/webfront/Pty.hpp index 4ee2b3b6..daf1e77c 100644 --- a/include/webfront/Pty.hpp +++ b/include/webfront/Pty.hpp @@ -1,4 +1,12 @@ -/// @brief Optional native pseudoterminal for an application-selected program. +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-19 +// +// WebFront — core +// Role: Optional native pseudoterminal for an application-selected program, with a bounded output ring. +// Thread: worker-safe | Alloc: unrestricted +// LLM: optional component; one worker thread owns the child, see docs/PTY.md + #pragma once #ifdef _WIN32 @@ -23,7 +31,7 @@ namespace webfront::pty::detail { class ByteRing { public: - explicit ByteRing(std::size_t capacity) : storage(capacity) {} + explicit ByteRing(std::size_t capacity) : storage(capacity) { } std::size_t size() const { return used; @@ -78,7 +86,7 @@ class Pty { explicit Pty(PtyOptions options) : native(pty::detail::prepare(std::move(options))), worker([this] { run(); - }) {} + }) { } ~Pty() { hangUp(); diff --git a/include/webfront/PtyPage.hpp b/include/webfront/PtyPage.hpp index fbc1a23c..1eb6a6e9 100644 --- a/include/webfront/PtyPage.hpp +++ b/include/webfront/PtyPage.hpp @@ -1,4 +1,12 @@ -/// @brief Registers an application-chosen PTY for the optional xterm.js adapter. +// SPDX-License-Identifier: Apache-2.0 OR CECILL-B +// Author: Ambroise Leclerc +// Created: 2026-11-19 +// +// WebFront — core +// Role: Registers an application-chosen PTY for the optional xterm.js adapter. +// Thread: bridge-io | Alloc: unrestricted +// LLM: optional component; one session per name, retained across page reloads + #pragma once #include "http/Encodings.hpp" @@ -67,7 +75,7 @@ void registerPtyPage(App& app, PtyOptions options, std::string name = "webfront. launch->generation = state->generation + 1; launch->terminal = std::async(std::launch::async, [options = state->options]() mutable { return std::make_shared(std::move(options)); - }).share(); + }).share(); state->launching = std::move(launch); } auto launch = state->launching; diff --git a/include/webfront/ReadBinding.hpp b/include/webfront/ReadBinding.hpp index 600873f4..8faae924 100644 --- a/include/webfront/ReadBinding.hpp +++ b/include/webfront/ReadBinding.hpp @@ -1,23 +1,32 @@ // SPDX-License-Identifier: Apache-2.0 OR CECILL-B -/// @brief Binds the plain HTTP reads of a page (``, `