diff --git a/.codescene/code-health-rules.json b/.codescene/code-health-rules.json index 29e1bf2c..3077539b 100644 --- a/.codescene/code-health-rules.json +++ b/.codescene/code-health-rules.json @@ -29,8 +29,8 @@ ] }, { - "matching_content_path": "src/developer/*.bundle.mjs", - "matching_content_path_doc": "Minified esbuild output of the sources next to it, checked in so that the bootstrap and package resolver need no Node.js at consumption time. It is regenerated by tools/developer/build.mjs --refresh-bootstrap and verified against src/developer/bundles.json, never edited by hand; the readable sources are analysed instead.", + "matching_content_path": "assets/developer/*.bundle.mjs", + "matching_content_path_doc": "Minified esbuild output of the sources next to it, checked in so that the bootstrap and package resolver need no Node.js at consumption time. It is regenerated by tools/developer/build.mjs --refresh-bootstrap and verified against assets/developer/bundles.json, never edited by hand; the readable sources are analysed instead.", "rules": [ { "name": "Complex Method", "weight": 0.0 }, { "name": "Bumpy Road Ahead", "weight": 0.0 }, diff --git a/.gitattributes b/.gitattributes index 498d800b..0e89bd2b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -51,14 +51,14 @@ # Embedded headers hold the exact bytes of their text sources. Freshness tests # re-read those sources, so Windows checkouts must preserve LF for every asset. -src/WebFront.js text eol=lf +assets/WebFront.js text eol=lf include/system/WebFrontJsData.hpp text eol=lf -src/fallback/index.html text eol=lf -src/fallback/webfront-fallback.mjs text eol=lf +assets/fallback/index.html text eol=lf +assets/fallback/webfront-fallback.mjs text eol=lf include/system/FallbackIndexHtmlData.hpp text eol=lf include/system/FallbackModuleData.hpp text eol=lf -src/components/terminal/* text eol=lf -src/components/tools/* text eol=lf +assets/components/terminal/* text eol=lf +assets/components/tools/* text eol=lf include/system/ToolManagerModuleData.hpp text eol=lf third_party/xterm/* text eol=lf include/system/TerminalIndexHtmlData.hpp text eol=lf @@ -179,10 +179,10 @@ third_party/fflate/* text eol=lf include/system/*Data.hpp text eol=lf # Browser-powered developer bootstrap sources and generated payloads. -src/developer/* text eol=lf -tools/assets/package-lock.json text eol=lf +assets/developer/* text eol=lf +tools/assets/package-lock.json text eol=lf # Starter archives and every hashed distribution input must be identical on Windows. -src/pi/* text eol=lf -src/life/* text eol=lf -tools/developer/* text eol=lf +tools/developer/starters/pi/* text eol=lf +examples/life/ui/* text eol=lf +tools/developer/* text eol=lf diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index e98e198d..688b8f23 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -2,124 +2,109 @@ name: Build and Test on: push: - branches: [ '**' ] + branches: [develop, master] pull_request: - branches: [ master, develop ] + branches: [master, develop] + schedule: + - cron: '23 4 * * 1' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: build-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + # Never cancel a push to a release branch: its coverage upload must complete. + cancel-in-progress: ${{ github.event_name == 'pull_request' }} env: - BUILD_TYPE: Release - GIST_ID: 317c22bfe80b2b51663187fbebfba533 + CPM_SOURCE_CACHE: ${{ github.workspace }}/.cache/CPM + SCCACHE_GHA_ENABLED: 'true' +# Third-party actions are pinned to commit SHAs; GitHub-owned actions/* use version tags. jobs: - build: + desktop: + # PR/push jobs already cover desktops; manual runs add only the extended checks. + if: github.event_name != 'workflow_dispatch' + name: ${{ matrix.name }} + timeout-minutes: 25 strategy: fail-fast: false matrix: - config: - - { - name: "Windows MSVC", - os: windows-2025, - compiler: msvc, - coverage: false - } - - { - name: "Windows MSVC WebView2", - os: windows-2025, - compiler: msvc, - coverage: false, - webview2: true - } - - { - name: "Ubuntu GCC with Coverage", - os: ubuntu-24.04, - compiler: gcc, - coverage: true - } - - { - name: "Ubuntu Clang", - os: ubuntu-24.04, - compiler: clang, - coverage: false - } - - { - name: "macOS (Apple Silicon)", - os: macos-26, - compiler: appleClang, - coverage: false - } - runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.name }} - + include: + - name: Linux GCC / WebKitGTK + os: ubuntu-26.04 + build_type: Debug + test_env: {WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1'} + options: -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DENABLE_COVERAGE=ON + - name: Windows MSVC / WebView2 + os: windows-2025 + build_type: Release + test_env: {} + options: -DWEBFRONT_EMBED_WEBVIEW2=ON -DWEBFRONT_WEBTEST_FRONTEND=WebView2 + - name: macOS Apple Clang / WKWebView + os: macos-26 + build_type: Release + test_env: {} + options: -DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v6 with: node-version: 24 - - - name: Initialize MSVC environment - if: matrix.config.compiler == 'msvc' - uses: ilammy/msvc-dev-cmd@v1 - - - name: Setup CMake - uses: jwlawson/actions-setup-cmake@v2 + cache: npm + cache-dependency-path: tools/assets/package-lock.json + - uses: jwlawson/actions-setup-cmake@0d6a7d60b009d01c9e7523be22153ff8f19460d3 # v2 with: cmake-version: '4.4.4' - - - name: Install Clang 23 - if: matrix.config.compiler == 'clang' + - uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9 + - uses: actions/cache@v4 + with: + path: .cache/CPM + key: cpm-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'cmake/*.cmake', 'test/CMakeLists.txt') }} + restore-keys: cpm-${{ runner.os }}- + - name: Initialize MSVC environment + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1 + # Ubuntu 26.04 ships GCC 16 in its main archive (no flaky toolchain PPA). The image already + # provides CMake, Ninja, Node.js, pkg-config and Xvfb, so install only the missing pieces. + - name: Install GCC 16, WebKitGTK and coverage tools + if: runner.os == 'Linux' run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/llvm-archive-keyring.gpg > /dev/null - echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] https://apt.llvm.org/noble/ llvm-toolchain-noble-23 main" | sudo tee /etc/apt/sources.list.d/llvm.list sudo apt-get update - sudo apt-get install -y clang-23 lld-23 lldb-23 - echo "CC=clang-23" >> $GITHUB_ENV - echo "CXX=clang++-23" >> $GITHUB_ENV - - - name: Setup GCC - uses: egor-tensin/setup-gcc@v1.3 - with: - version: 16 - if: matrix.config.compiler == 'gcc' - + sudo apt-get install -y --no-install-recommends -o Acquire::Retries=3 \ + gcc-16 g++-16 libwebkitgtk-6.0-dev lcov + echo "CC=gcc-16" >> "$GITHUB_ENV" + echo "CXX=g++-16" >> "$GITHUB_ENV" - name: Setup Xcode - uses: maxim-lobanov/setup-xcode@v1 + if: runner.os == 'macOS' + uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1 with: xcode-version: latest - if: matrix.config.compiler == 'appleClang' - - - name: Report compiler and sender support + - name: Verify compiler cache launcher shell: bash run: | - cat > cpp_lib_senders_probe.cpp <<'EOF' - #include - #ifdef __cpp_lib_senders - #pragma message("__cpp_lib_senders is defined") - #else - #pragma message("__cpp_lib_senders is NOT defined") - #endif - int main() {} - EOF - if [ "${{ matrix.config.compiler }}" = "msvc" ]; then - cl /nologo /std:c++latest /c cpp_lib_senders_probe.cpp || true - else - ${CXX:-c++} --version | head -1 - ${CXX:-c++} -std=c++26 -fsyntax-only cpp_lib_senders_probe.cpp 2>&1 | grep -i "__cpp_lib_senders" || true - fi - rm -f cpp_lib_senders_probe.cpp - - - name: Install Coverage Tools - if: matrix.config.coverage + command -v sccache + sccache --version + - name: Prepare offline developer fixtures run: | - sudo apt-get update - sudo apt-get install -y lcov - - - name: Config & Build - run: | - cmake . -B ${{github.workspace}}/build -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON ${{ matrix.config.webview2 && '-DWEBFRONT_EMBED_WEBVIEW2=ON -DWEBFRONT_DEMO_FRONTEND=Native' || '' }} ${{ matrix.config.coverage && '-DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON' || '' }} - cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel 1 - + npm ci --prefix tools/assets --ignore-scripts + node tools/developer/build.mjs build-developer-environment + node tools/developer/fixtures.mjs build-developer-environment + # ENABLE_CACHE controls automatic ccache discovery; the explicit sccache launcher stays enabled. + - name: Configure + run: >- + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON + -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_SCAN_FOR_MODULES=OFF + ${{ matrix.options }} + -DWEBFRONT_DEVELOPER_FIXTURES=${{ github.workspace }}/build-developer-environment + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} --parallel 2 - name: Ensure WebView2 Evergreen runtime - if: matrix.config.webview2 + if: runner.os == 'Windows' shell: pwsh run: | function Get-WebView2Runtime { @@ -145,106 +130,40 @@ jobs: if (-not $version) { throw "WebView2 runtime version is missing: $($executable.FullName)" } Write-Host "WebView2 runtime $version at $($executable.FullName)" } - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest --verbose --output-on-failure --no-tests=error -C ${{env.BUILD_TYPE}} ${{ matrix.config.webview2 && '-LE web-integration' || '' }} - - - name: Test WebView2 browser lifecycle - if: matrix.config.webview2 - working-directory: ${{github.workspace}}/build - run: ctest -L web-integration --output-on-failure --no-tests=error -C ${{env.BUILD_TYPE}} - - - name: Rerun Failed Tests (if any) - if: failure() - working-directory: ${{github.workspace}}/build - run: ctest --rerun-failed --output-on-failure --no-tests=error -C ${{env.BUILD_TYPE}} - - - name: Collect Coverage - if: matrix.config.coverage - working-directory: ${{github.workspace}}/build + - name: Test C++ and native browser integration + # Only Linux trusted fixtures need the sandbox opt-out on hosted runners. + env: ${{ matrix.test_env }} + run: ctest --test-dir build -C ${{ matrix.build_type }} --output-on-failure --no-tests=error + - name: Collect coverage + if: runner.os == 'Linux' + working-directory: build run: | - lcov --gcov-tool gcov-16 --capture --directory . --output-file coverage.info - lcov --remove coverage.info '/usr/*' '*/src/*' --output-file coverage.info + # lcov 2 on Ubuntu 26.04 rejects the benign line/function hit inconsistencies GCC emits for templates. + lcov --ignore-errors inconsistent,inconsistent --gcov-tool gcov-16 --capture --directory . --output-file coverage.info + lcov --ignore-errors inconsistent,inconsistent --remove coverage.info '/usr/*' '*/examples/*' --output-file coverage.info lcov --list coverage.info - - - name: Upload Coverage - if: matrix.config.coverage - uses: codecov/codecov-action@v7 + - name: Upload coverage + if: runner.os == 'Linux' + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 with: - files: ${{github.workspace}}/build/coverage.info + files: build/coverage.info fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} - - - name: Set Badge Info - if: always() && github.ref == 'refs/heads/master' - id: badge - run: | - # Set badge label - echo "label=${{ matrix.config.name }}" >> $GITHUB_OUTPUT - - # Set badge color - case "${{ job.status }}" in - "success") echo "color=2EA043" >> $GITHUB_OUTPUT ;; - "failure") echo "color=E6484F" >> $GITHUB_OUTPUT ;; - *) echo "color=DBAB0A" >> $GITHUB_OUTPUT ;; - esac - - # Set filename - echo "filename=${{ matrix.config.os }}-${{ matrix.config.compiler }}${{ matrix.config.webview2 && '-webview2' || '' }}.json" >> $GITHUB_OUTPUT - shell: bash - - - name: Update Gist - if: always() && github.ref == 'refs/heads/master' - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GIST_SECRET }} - script: | - const filename = '${{ steps.badge.outputs.filename }}'; - const content = { - schemaVersion: 1, - label: '${{ steps.badge.outputs.label }}', - message: '${{ job.status }}', - color: '${{ steps.badge.outputs.color }}' - }; - - try { - await github.rest.gists.update({ - gist_id: process.env.GIST_ID, - files: { - [filename]: { - content: JSON.stringify(content) - } - } - }); - } catch (error) { - core.error(`Failed to update gist: ${error.message}`); - if (error.response) { - core.error(`Status: ${error.response.status}`); - core.error(`Response: ${JSON.stringify(error.response.data)}`); - } - throw error; - } - - - name: Update Badge - if: always() && github.ref == 'refs/heads/master' - uses: schneegans/dynamic-badges-action@v1.7.0 + - name: Retain diagnostics + if: failure() + uses: actions/upload-artifact@v4 with: - auth: ${{ secrets.GIST_SECRET }} - gistID: ${{ env.GIST_ID }} - filename: ${{ steps.badge.outputs.filename }} - label: ${{ steps.badge.outputs.label }} - message: ${{ job.status }} - color: ${{ steps.badge.outputs.color }} + name: test-log-${{ runner.os }} + path: build/Testing/Temporary/LastTest.log sanitizers: + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-24.04 timeout-minutes: 30 strategy: fail-fast: false matrix: sanitizer: [address-undefined, thread] - name: Linux Clang (${{ matrix.sanitizer }}) env: CC: clang-23 CXX: clang++-23 @@ -253,10 +172,15 @@ jobs: TSAN_OPTIONS: halt_on_error=1:second_deadlock_stack=1 steps: - uses: actions/checkout@v7 + - uses: actions/cache@v4 + with: + path: .cache/CPM + key: cpm-extended-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'cmake/*.cmake') }} + restore-keys: cpm-extended-${{ runner.os }}- - uses: actions/setup-node@v6 with: node-version: 24 - - uses: jwlawson/actions-setup-cmake@v2 + - uses: jwlawson/actions-setup-cmake@0d6a7d60b009d01c9e7523be22153ff8f19460d3 # v2 with: cmake-version: '4.4.4' - name: Install Clang 23 and sanitizer runtimes @@ -272,7 +196,7 @@ jobs: - name: Configure hardened sanitizer tests run: >- cmake -S . -B build-sanitizers -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF + -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF ${{ matrix.sanitizer == 'thread' && '-DCMAKE_CXX_FLAGS=-stdlib=libc++ -DENABLE_SANITIZER_THREAD=ON' || '-DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DENABLE_FUZZING=ON' }} - name: Build run: cmake --build build-sanitizers --parallel 2 @@ -297,62 +221,30 @@ jobs: path: build-sanitizers/fuzz/artifacts/ if-no-files-found: ignore - wkwebview-integration: - runs-on: macos-26 - timeout-minutes: 25 - name: macOS WKWebView Jasmine and lifecycle - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v6 - with: - node-version: 24 - - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: '4.4.4' - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest - - name: Check WindowServer session - run: | - launchctl print gui/$(id -u) >/dev/null - pgrep -x WindowServer - - name: Prepare offline developer environment and starter fixtures - run: | - npm ci --prefix tools/assets --ignore-scripts - node tools/developer/build.mjs build-developer-environment - node tools/developer/fixtures.mjs build-developer-environment - - name: Configure system WebKit frontend - run: >- - cmake -S . -B build-wkwebview -DCMAKE_BUILD_TYPE=Release - -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON - -DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView - -DWEBFRONT_DEMO_FRONTEND=Native - -DWEBFRONT_DEVELOPER_FIXTURES=${{github.workspace}}/build-developer-environment - - name: Build - run: cmake --build build-wkwebview --parallel 2 - - name: Test - run: ctest --test-dir build-wkwebview --output-on-failure --no-tests=error - - name: Retain browser test diagnostics - if: failure() - uses: actions/upload-artifact@v4 - with: - name: wkwebview-test-log - path: build-wkwebview/Testing/Temporary/LastTest.log - web-integration: + timeout-minutes: 30 + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' strategy: fail-fast: false matrix: compiler: [gcc, clang] runs-on: ubuntu-24.04 # Clang 19+ expands stdexec attributes that GCC leaves empty, so only Clang catches CEF macro clashes (#243) - name: Ubuntu CEF Jasmine integration${{ matrix.compiler == 'clang' && ' (Clang)' || '' }} steps: - uses: actions/checkout@v7 + - uses: actions/cache@v4 + with: + path: .cache/CPM + key: cpm-extended-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'cmake/*.cmake') }} + restore-keys: cpm-extended-${{ runner.os }}- - uses: actions/setup-node@v6 with: node-version: 24 + - uses: jwlawson/actions-setup-cmake@0d6a7d60b009d01c9e7523be22153ff8f19460d3 # v2 + with: + cmake-version: '4.4.4' + - name: Install Clang 23 if: matrix.compiler == 'clang' run: | @@ -360,13 +252,8 @@ jobs: echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] https://apt.llvm.org/noble/ llvm-toolchain-noble-23 main" | sudo tee /etc/apt/sources.list.d/llvm.list sudo apt-get update sudo apt-get install -y clang-23 lld-23 - echo "CC=clang-23" >> $GITHUB_ENV - echo "CXX=clang++-23" >> $GITHUB_ENV - - - name: Install virtual display - run: | - sudo apt-get update - sudo apt-get install -y xvfb + echo "CC=clang-23" >> "$GITHUB_ENV" + echo "CXX=clang++-23" >> "$GITHUB_ENV" - name: Prepare offline developer environment and starter fixtures run: | @@ -374,48 +261,10 @@ jobs: node tools/developer/build.mjs build-developer-environment node tools/developer/fixtures.mjs build-developer-environment - name: Configure CEF integration build - run: cmake . -B ${{github.workspace}}/build-cef -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=ON -DENABLE_TESTING=ON -DWEBFRONT_DEVELOPER_FIXTURES=${{github.workspace}}/build-developer-environment + run: cmake . -B ${{github.workspace}}/build-cef -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DENABLE_TESTING=ON -DWEBFRONT_DEVELOPER_FIXTURES=${{github.workspace}}/build-developer-environment - name: Build browser test - run: cmake --build ${{github.workspace}}/build-cef --target webtest developer_integration --parallel 1 + run: cmake --build ${{github.workspace}}/build-cef --target webtest developer_integration --parallel 2 - name: Run Jasmine bridge test run: ctest --test-dir ${{github.workspace}}/build-cef -L web-integration --output-on-failure --no-tests=error - - webkitgtk-integration: - runs-on: ubuntu-24.04 - timeout-minutes: 30 - name: Ubuntu WebKitGTK Jasmine and lifecycle - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v6 - with: - node-version: 24 - - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: '4.4.4' - - uses: egor-tensin/setup-gcc@v1.3 - with: - version: 16 - - name: Install WebKitGTK and virtual display - run: | - sudo apt-get update - sudo apt-get install -y libwebkitgtk-6.0-dev pkg-config xvfb - pkg-config --modversion webkitgtk-6.0 - - name: Configure WebKitGTK - run: >- - cmake -S . -B build-webkitgtk -DCMAKE_BUILD_TYPE=Release - -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WEBKITGTK=ON -DENABLE_TESTING=ON - -DWEBFRONT_DEMO_FRONTEND=Native -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK - - name: Build - run: cmake --build build-webkitgtk --parallel 2 - - name: Test - env: - # Trusted repository fixtures only; restricted runners may lack user namespaces. - WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1' - run: ctest --test-dir build-webkitgtk -LE web-integration --output-on-failure --no-tests=error - - name: Require browser coverage - env: - # Trusted repository fixtures only; restricted runners may lack user namespaces. - WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1' - run: ctest --test-dir build-webkitgtk -L web-integration --output-on-failure --no-tests=error diff --git a/.github/workflows/DeveloperDistribution.yml b/.github/workflows/DeveloperDistribution.yml index 585c7444..08bba2ad 100644 --- a/.github/workflows/DeveloperDistribution.yml +++ b/.github/workflows/DeveloperDistribution.yml @@ -3,11 +3,12 @@ name: Developer packages on: push: tags: ['developer-v*'] - branches: ['**'] + branches: [develop, master] paths: - - 'src/developer/**' - - 'src/pi/**' - - 'src/life/**' + - 'assets/developer/**' + - 'assets/components/tools/**' + - 'tools/developer/starters/pi/**' + - 'examples/life/ui/**' - 'tools/developer/**' - 'tools/assets/package*.json' - 'include/system/DeveloperReleaseData.hpp' @@ -15,9 +16,10 @@ on: pull_request: branches: [develop, master] paths: - - 'src/developer/**' - - 'src/pi/**' - - 'src/life/**' + - 'assets/developer/**' + - 'assets/components/tools/**' + - 'tools/developer/starters/pi/**' + - 'examples/life/ui/**' - 'tools/developer/**' - 'tools/assets/package*.json' - 'include/system/DeveloperReleaseData.hpp' @@ -32,6 +34,10 @@ on: permissions: contents: read +concurrency: + group: developer-packages-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') }} + jobs: package: runs-on: ubuntu-24.04 diff --git a/.github/workflows/MddlogIntegration.yml b/.github/workflows/MddlogIntegration.yml index 87d417de..192d277e 100644 --- a/.github/workflows/MddlogIntegration.yml +++ b/.github/workflows/MddlogIntegration.yml @@ -1,10 +1,11 @@ name: Optional mddlog integration on: - pull_request: - branches: [develop] - push: - branches: [develop] + schedule: + - cron: '43 4 * * 1' workflow_dispatch: +concurrency: + group: mddlog-${{ github.ref }} + cancel-in-progress: true permissions: contents: read jobs: @@ -21,7 +22,7 @@ jobs: ref: 5b43265664d83c3b7135d328f611e685792a1b02 path: dependencies/mddlog - name: Setup CMake (4.3.1, within the qualified 4.0-4.3 window) - uses: jwlawson/actions-setup-cmake@v2 + uses: jwlawson/actions-setup-cmake@0d6a7d60b009d01c9e7523be22153ff8f19460d3 # v2 with: cmake-version: '4.3.1' @@ -46,7 +47,7 @@ jobs: - name: Configure source integration run: >- cmake -S . -B build-mddlog-source -G Ninja - -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON + -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake -DWEBFRONT_USE_MDDLOG=ON -DWEBFRONT_MDDLOG_SOURCE_DIR=${{ github.workspace }}/dependencies/mddlog @@ -59,7 +60,7 @@ jobs: - name: Configure installed integration run: >- cmake -S . -B build-mddlog-install -G Ninja - -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON + -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake -DWEBFRONT_USE_MDDLOG=ON -DCMAKE_PREFIX_PATH=${{ github.workspace }}/mddlog-install @@ -96,7 +97,7 @@ jobs: ref: 5b43265664d83c3b7135d328f611e685792a1b02 path: dependencies/mddlog - name: Setup CMake (4.3.1, within the qualified 4.0-4.3 window) - uses: jwlawson/actions-setup-cmake@v2 + uses: jwlawson/actions-setup-cmake@0d6a7d60b009d01c9e7523be22153ff8f19460d3 # v2 with: cmake-version: '4.3.1' @@ -123,7 +124,7 @@ jobs: - name: Configure instrumented source integration run: >- cmake -S . -B build-sanitized -G Ninja - -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_CACHE=OFF -DENABLE_TESTING=ON + -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake "-DCMAKE_CXX_FLAGS=-stdlib=libc++ ${{ matrix.flags }} -fno-omit-frame-pointer" "-DCMAKE_EXE_LINKER_FLAGS=${{ matrix.flags }}" @@ -133,7 +134,8 @@ jobs: run: cmake --build build-sanitized --parallel 2 --target tests - name: Run the transport and WebLink scenarios repeatedly run: | - for run in 1 2 3 4 5; do + for iteration in 1 2 3 4 5; do + echo "Transport iteration $iteration" ./build-sanitized/test/tests "[transport],[weblink]" --order rand done - name: Run every test once diff --git a/AGENTS.md b/AGENTS.md index 33164cea..d8304aff 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ WebFront is a C++23 header-only library for serving a browser UI from a C++ appl - C++ calls browser functions with `ui.jsFunction(name)(arguments...)`, which is fire-and-forget and ignores the result, or with `ui.jsFunction(name)(arguments...)`, which returns a `std::future`. Only the untyped C++ form is fire-and-forget. - `webFront.ready` resolves after the WebSocket handshake acknowledgement and rejects if the initial connection fails or closes. -The project is an experimental foundation, not a production-ready UI framework. The newcomer path is `webfront::WebFront app; app.show();` (examples `HelloWorld` and `WebFrontGreeter`); the minimum automated demonstration is the native ES-module example plus the Jasmine browser integration test. General DOM abstractions remain future work. Application coroutines use `webfront::Task` and `app.spawn(task)`/`ui.spawn(task)`; retain a `TaskHandle` to request individual cancellation. WebFront owns and drains these tasks. Spawn is callable from any thread while the application lives; a call rejected during shutdown returns a stopped handle. Destructors wait for outstanding operations; explicit shutdown reports a stalled join. Typed C++ sender calls support local cancellation; futures and JavaScript Promises do not expose cancellation. +The README introduces WebFront through the Game of Life walkthrough, demonstrating the developer bootstrap, reactive TypeScript UI and embedded distribution. The minimal `HelloWorld` example remains available under `examples/hello-world/`. Native modules and the bridge are covered by the Jasmine browser integration test. General DOM abstractions remain future work. Application coroutines use `webfront::Task` and `app.spawn(task)`/`ui.spawn(task)`; retain a `TaskHandle` to request individual cancellation. WebFront owns and drains these tasks. Spawn is callable from any thread while the application lives; a call rejected during shutdown returns a stopped handle. Destructors wait for outstanding operations; explicit shutdown reports a stalled join. Typed C++ sender calls support local cancellation; futures and JavaScript Promises do not expose cancellation. ## Repository map @@ -18,7 +18,9 @@ The project is an experimental foundation, not a production-ready UI framework. - `include/system/`: layered virtual filesystems and embedded web resources. - `include/frontend/`: system-browser, CEF, optional Windows WebView2 and macOS WKWebView frontend adapters. - `include/components/`: opt-in UI components (`Terminal.hpp`, `ToolManager.hpp`); their assets are served by embedded providers such as `include/system/TerminalFS.hpp`, and installed tools by `include/system/PackageFS.hpp` from `ToolStore.hpp`'s project directory. -- `src/`: example applications and browser assets: `HelloWorld.cpp` (no assets, embedded fallback page), `Greeter.cpp` with `greeter/` (editable UI), `ModuleDemo.cpp` with `module-demo.html` and `react.html`, `Terminal.cpp` (terminal component demo), and the readable embedded sources `WebFront.js`, `fallback/` and `components/`. +- `examples/`: only Hello World (`hello-world/`) and Game of Life (`life/`, with console, developer and embedded stages). +- `assets/`: readable browser bridge, fallback, component and developer-environment sources; production C++ remains header-only in `include/`. +- `tools/developer/starters/pi/`, `test/fixtures/`, `webtest/fixtures/`: retained package and regression fixtures, not public example applications. - `test/`: Catch2 unit tests. - `webtest/`: Jasmine real-browser integration test. - `cmake/` and `.github/workflows/`: build support and CI. @@ -35,13 +37,12 @@ The legacy `webfront/`, `tests/`, and `webtest` directories are not interchangea Use out-of-source builds. CPM downloads dependencies during first configure, so network access may be required. ```bash -# Newcomer quick start: no options, no CEF, no tests; builds HelloWorld, WebFrontGreeter, WebFrontApp +# Newcomer quick start: no options, no CEF, no tests mkdir build cd build cmake .. -cmake --build . -./src/HelloWorld -./src/WebFrontGreeter +cmake --build . --parallel 2 +./examples/HelloWorld # Fast, portable C++ baseline (no CEF download) cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ @@ -58,24 +59,19 @@ cmake -S . -B build-cef -DCMAKE_BUILD_TYPE=Release \ cmake --build build-cef --target webtest --parallel ctest --test-dir build-cef -L web-integration --output-on-failure -# Manual native-module demo (opens the system browser unless the source selects CEFFrontend) -./build/src/WebFrontApp - -# Optional React example -./build/src/WebFrontApp react.html ``` Important CMake options: - `WEBFRONT_EMBED_CEF=OFF` (default): CEF is unavailable; this is the normal unit-test build. `ON` downloads/links CEF and enables the automated browser test; it makes `CEFFrontend` available but does not select it: `webfront::WebFront` always uses the system browser. -- `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases; `WEBFRONT_DEMO_FRONTEND=WebView2` selects it for the module demo. -- `WEBFRONT_EMBED_WKWEBVIEW=OFF` (default): macOS 13.3+ opt-in Cocoa/WebKit frontend, with no engine download. Select `WebFrontWithFrontend` on the main thread; `WEBFRONT_WEBTEST_FRONTEND=WKWebView` runs Jasmine and lifecycle coverage, and `WEBFRONT_DEMO_FRONTEND=WKWebView` selects it for the module demo. -- `WEBFRONT_DEMO_FRONTEND=Native` selects `NativeWebViewFrontend` for the module demo: WebView2 on Windows, WKWebView on macOS and WebKitGTK on Linux. Enable the corresponding `WEBFRONT_EMBED_WEBVIEW2`, `WEBFRONT_EMBED_WKWEBVIEW` or `WEBFRONT_EMBED_WEBKITGTK` option explicitly. It never changes `webfront::WebFront`'s system-browser default. +- `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases. +- `WEBFRONT_EMBED_WKWEBVIEW=OFF` (default): macOS 13.3+ opt-in Cocoa/WebKit frontend, with no engine download. Select `WebFrontWithFrontend` on the main thread; `WEBFRONT_WEBTEST_FRONTEND=WKWebView` runs Jasmine and lifecycle coverage. + - `ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. - `WEBFRONT_BUILD_EXAMPLES` (default `ON` only for the top-level project): build the examples. As a subproject (`add_subdirectory`), link `WebFront::WebFront`; no examples, tests or global compiler settings are added. - `ENABLE_COVERAGE=ON`: add GCC/Clang coverage instrumentation to the C++ tests. -If the environment provides a read-only default ccache directory, set `CCACHE_DIR` to a writable temporary directory for local builds. Do not encode machine-specific cache paths in project files. +If the environment provides a read-only default ccache directory, set `CCACHE_DIR` to a writable temporary directory for local builds. Do not encode machine-specific cache paths in project files. In CI, `ENABLE_CACHE=OFF` disables automatic cache discovery while `CMAKE_CXX_COMPILER_LAUNCHER=sccache` explicitly enables sccache; a PATH/version probe runs on all three platforms. The combined Linux job uses Debug with GCC coverage on every PR; Windows and macOS use Release. The WebKitGTK sandbox opt-out is confined to the Linux test step and trusted fixtures. ## Architecture and invariants @@ -96,14 +92,14 @@ Exception: a purely C++ change that reuses an existing encoding, introduces no n ## Coding and testing conventions - Use C++23, four-space indentation, the repository `.clang-format`, and the naming rules in `CONTRIBUTING.md`. -- Keep production implementation header-only under `include/`; `src/` contains examples only. +- Keep production implementation header-only under `include/`; `examples/` contains the two public examples; browser resources live in `assets/`. - Prefer standard-library facilities and explicit ownership. Keep public headers ODR-safe (`inline`/templates as appropriate). - Catch2 tests use `SCENARIO`/`GIVEN`/`WHEN`/`THEN` and deterministic mocks. - Jasmine tests use native modules and must report completion to C++, close themselves, return a meaningful process status, and have a CTest timeout. - Every bug fix needs a failing regression test at the lowest useful level. Bridge changes also need the browser integration test. - Tests must not require user input, a fixed pre-existing browser session, or public network access after dependencies are configured. -Before declaring work complete, run the CEF-off build and CTest suite. Run the CEF/Xvfb test when changing the bridge, browser lifecycle, module serving, Jasmine assets, or CEF frontend. Update README/status documentation when commands, public behavior, or limitations change. The `NewcomerDocsMatchExamples` CTest case fails when the README quick-start commands or snippets drift from the examples, CMake targets, or CI commands, and `AddSubdirectoryConsumer` builds a minimal parent project linking `WebFront::WebFront`. +Before declaring work complete, run the CEF-off build and CTest suite. Run the CEF/Xvfb test when changing the bridge, browser lifecycle, module serving, Jasmine assets, or CEF frontend. These PRs must also dispatch `BuildAndTest.yml` on the PR head branch before merging (`gh workflow run BuildAndTest.yml --ref `), then wait for both GCC and Clang CEF jobs to pass. Manual dispatch runs the extended CEF/sanitizer checks without repeating the desktop matrix. It is the required per-PR CEF validation for these changes; the weekly run is a backstop, not a substitute. Update README/status documentation when commands, public behavior, or limitations change. The `NewcomerDocsMatchExamples` CTest case fails when the README quick-start commands or snippets drift from the examples, CMake targets, or CI commands, and `AddSubdirectoryConsumer` builds a minimal parent project linking `WebFront::WebFront`. ## Git and workspace safety diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e2d2c00..2a078808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Changelog -## Unreleased +## Unreleased — 0.4 presentation + +- Move the public examples to `examples/` and retain only Hello World and Game of Life. + Readable library web resources now live in `assets/`; regression fixtures remain under tests/tools. +- Rework the README around a minimal Hello World, an early Life thumbnail and a step-by-step + bootstrap, dependency-installation, preview and embedded-distribution walkthrough. +- Combine per-change CI into three native desktop jobs with caches and cancellation. + GCC coverage stays in the Linux job on every PR. Extended CEF, sanitizer and fuzz checks run weekly or manually. +- Run `MddlogIntegration.yml` source/installed integration and sanitizer qualification weekly or manually. +- No new library functionality. ## 0.3.0 - 2026-10-21 @@ -9,7 +18,7 @@ - `std::bitset` callback arguments and results, C++ call arguments and typed future/sender results cross the bridge as packed `Uint8Array` bytes (bit `i` in byte `i / 8`, least-significant first), with exact-length and zero-padding validation. A packed Life demonstration exchanges 128 bytes per generation. - Opt-in browser-powered developer environment: `NativeApp::bootstrap("developer")` downloads a SHA-512-pinned environment (distribution 0.3.1 on GitHub Pages) whose terminal offers `wf create|install|list|preview|embed`. It resolves npm packages in the browser, locks and re-verifies them, compiles with esbuild-WASM, previews in an iframe and generates a gzip-compressed C++ resource header. The bridge callbacks `webfront.developer.*` publish files through staged, bounded, transactional writes confined to the explicit project directory; abandoned transactions expire and stale staging is purged at startup. WebSocket clients without an `Origin` are refused. -- - `webfront::Task`, `app.spawn(task)` and `ui.spawn(task)` launch application-owned coroutines without execution plumbing; a returned `TaskHandle` cancels an individual task. `app.shutdown()` joins owned work explicitly. Spawning during stop/shutdown returns a stopped handle when rejected; destructor joins log and wait for stalled external work instead of propagating drain errors. `jsFunctionSender(name)` defaults to `void`. `WebFrontAwaitBrowser` is a compiled example matching the README. +- `webfront::Task`, `app.spawn(task)` and `ui.spawn(task)` launch application-owned coroutines without execution plumbing; a returned `TaskHandle` cancels an individual task. `app.shutdown()` joins owned work explicitly. Spawning during stop/shutdown returns a stopped handle when rejected; destructor joins log and wait for stalled external work instead of propagating drain errors. `jsFunctionSender(name)` defaults to `void`. `WebFrontAwaitBrowser` is a compiled example matching the README. - `ui.jsFunctionSender(name)(...)` returns a lazy sender that can be awaited in a task and cancelled through its receiver's stop token. Cancellation stops the local wait; dispatched JavaScript continues. Existing `std::future` calls remain available. diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c7b9130..909465f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,5 +119,5 @@ if(ENABLE_TESTING) endif() if(WEBFRONT_BUILD_EXAMPLES) - add_subdirectory(src) + add_subdirectory(examples) endif() diff --git a/README.md b/README.md index bccb076e..df9e6d26 100644 --- a/README.md +++ b/README.md @@ -1,484 +1,223 @@ # WebFront -**[Version 0.3.0](https://github.com/ambroise-leclerc/WebFront/releases/tag/v0.3.0)** adds packed `std::bitset` bridge values and an opt-in, browser-powered developer environment (`webfront::NativeApp::bootstrap("developer")`) with a packed Life demonstration. The 0.2.0 native windows (WebView2, WKWebView, WebKitGTK via `NativeWebViewFrontend`) remain opt-in and the system browser remains the default. +[![CI](https://github.com/ambroise-leclerc/WebFront/actions/workflows/BuildAndTest.yml/badge.svg?branch=develop)](https://github.com/ambroise-leclerc/WebFront/actions/workflows/BuildAndTest.yml) +[![Windows · MSVC](https://img.shields.io/badge/CI-Windows%20%C2%B7%20MSVC-0078D4)](https://github.com/ambroise-leclerc/WebFront/actions/workflows/BuildAndTest.yml) +[![macOS · Apple Clang](https://img.shields.io/badge/CI-macOS%20%C2%B7%20Apple%20Clang-555555)](https://github.com/ambroise-leclerc/WebFront/actions/workflows/BuildAndTest.yml) +[![Linux · GCC](https://img.shields.io/badge/CI-Linux%20%C2%B7%20GCC-E95420)](https://github.com/ambroise-leclerc/WebFront/actions/workflows/BuildAndTest.yml) +[![C++23](https://img.shields.io/badge/C%2B%2B-23-00599C)](CMakeLists.txt) +[![Header-only](https://img.shields.io/badge/library-header--only-2EA043)](include/) -**A straightforward way to add a cross-platform GUI to your C++ application.** +**WebFront is a header-only C++23 library for building rich, modern user interfaces.** +Keep application logic in C++ and create reactive interfaces with TypeScript, React and the existing JavaScript package ecosystem. WebFront brings the UI tools into your application: no Node.js, npm or separate JavaScript development environment to install. -WebFront is a header-only C++23 graphical user interface library for Windows, Linux and macOS. Keep your application logic in C++, design the interface with HTML and CSS, and connect the two with ordinary C++ callbacks. Start with a few lines, then build the interface your application needs. +## From C++ to a reactive UI -Your application keeps its own types and ownership model. There is no required base class for application objects, no meta-object compiler and no application-wide event loop to adopt. WebFront runs its server on a background thread; the chosen frontend handles displaying the interface. [How it fits your application](#how-it-fits-your-application) explains the threading and lifetime details. +Register your simulation, bootstrap the tools, then build the interface in the application's terminal. `life-project` is the working directory for the UI sources: -![Signal Studio running in a native Windows window with WebView2: React controls and a waveform generated in C++](docs/images/signal-studio-webview2.png) - -*Signal Studio, running in a native WebView2 application window. C++ generates the samples; the embedded React draws the waveform and provides the controls. No browser tabs, CDN or JavaScript build step. [Try the example](#signal-studio-the-react-example).* - -Use your existing browser to get started, or choose an embedded application window. The simplest example needs no HTML, JavaScript, Node.js, bundler or separately managed web server. - -**WebFront is experimental.** The examples work and the bridge is tested across platforms, but APIs and packaging are still developing. Read the [limitations](#limitations) before choosing it for a released product. - -[Get started](#hello-world) · [Connect your interface to C++](#connect-your-interface-to-c) · [Add it to your project](#use-webfront-in-your-project) · [Choose a window](#choose-how-your-interface-opens) - -## Hello World + + + +
C++ applicationCreate, install, preview
```cpp #include - -using App = webfront::WebFront; +#include + +using namespace std; +constexpr int N = 32; +using Grid = bitset; + +Grid nextLife(const Grid& cells) { + Grid next; + auto index = [](int x, int y) { + return size_t((y + N) % N * N + (x + N) % N); + }; + for (int y = 0; y < N; ++y) + for (int x = 0; x < N; ++x) { + int n = 0; + for (int dy = -1; dy <= 1; ++dy) + for (int dx = -1; dx <= 1; ++dx) + if (dx || dy) + n += cells[index(x + dx, y + dy)]; + auto i = index(x, y); + next[i] = n == 3 || (cells[i] && n == 2); + } + return next; +} int main() { - App app; + webfront::NativeApp app{"life-project"}; + app.cppFunction("life.step", &nextLife); + app.bootstrap("developer"); app.show(); } ``` -That is the complete program (`src/HelloWorld.cpp`). Build it with the classic CMake workflow; it needs no options and downloads neither Chromium nor a test framework: + +Game of Life walkthrough: an empty application, wf create life, dependency installation, then the React interface running below the terminal +
+ +The animation shows the Game of Life example, with terminal output and timing condensed and the preview expanded for readability. [Follow the walkthrough below ↓](#game-of-life-from-console-to-native-application) + +## Game of Life: from console to native application + +The example starts with a C++ simulation, adds a React interface, then embeds that interface in the executable. You need Git, CMake **3.31+** and a C++23 compiler. Initial CMake configuration, bootstrap and dependency installation require internet access. ```bash git clone https://github.com/ambroise-leclerc/WebFront.git cd WebFront -git checkout v0.3.0 -mkdir build -cd build -cmake .. -cmake --build . +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build --parallel 2 ``` -Then launch it from the build directory: - -```bash -./src/HelloWorld -``` +The developer package for this 0.4 development branch is prepared but not yet published. For local review, use [local archive provisioning](docs/DEVELOPER_ENVIRONMENT.md#environment-distribution-and-offline-tests-maintainers). -Your system browser opens the interface below. The page is included in the library, so there are no assets to prepare. **Connected to WebFront** confirms that the interface has connected to your C++ application. Press Enter in the terminal to stop the server. +### 1. Start with the C++ simulation -![The embedded Hello, WebFront! page showing the connected indicator](docs/images/hello-world.png) +[Life.hpp](examples/life/Life.hpp) implements Conway's B3/S23 rules on a wrapping 32 × 32 grid. Each step creates a new `std::bitset<1024>`. [LifeConsole.cpp](examples/life/LifeConsole.cpp) runs it without a GUI: -## Browser-powered development (experimental) +```bash +# From the repository root: +./build/examples/WebFrontLifeConsole +``` -The optional [developer environment](docs/DEVELOPER_ENVIRONMENT.md) downloads its terminal and -JavaScript/WASM build tools on demand. Install browser libraries with `wf install`, preview local -TSX, then generate compressed C++ resource headers with `wf embed`. The Game of Life example pairs a small C++23 bitset simulation with a spatial React interface, -then demonstrates -recompiling an offline native application without installing Node.js or npm on the developer's machine. -The [version-pinned environment and starters](https://ambroise-leclerc.github.io/WebFront/) -are hosted on GitHub Pages; see the guide for the complete walkthrough. +On Windows the executable is `build\examples\Release\WebFrontLifeConsole.exe`. -## Connect your interface to C++ +### 2. Add a window and bootstrap the tools -For a small first example, the Greeter connects a name field and a button to application code. Register an ordinary C++ lambda; WebFront deduces its signature: +The essential change in [LifeDeveloper.cpp](examples/life/LifeDeveloper.cpp) is: ```cpp -App app{webfront::WebFrontConfig{.documentRoot = "src/greeter"}}; - -app.cppFunction("greet", [](std::string name) { - return "Hello, " + name + "!"; -}); - +webfront::NativeApp app{"life-project"}; +app.cppFunction("life.step", &webfront::demo::nextLife); +app.bootstrap("developer"); app.show(); ``` -The document root is an explicit, development-only opt-in: WebFront then serves the files of that directory (here `src/greeter/index.html`) instead of the fallback page. Without a document root WebFront performs no local file access at all. +The project directory gives the application access to its development files. `bootstrap("developer")` opens the integrated terminal and loads the version-pinned UI tools, checking their SHA-512 integrity. Downloads are cached. Use `wf` commands there to create, install, preview and embed your interface. -The page is plain HTML plus one native JavaScript module (`src/greeter/greeter.mjs`). It waits for the bridge, then awaits the Promise that `cppFunction` returns: +Enable **one** engine for your platform: -```js -await webFront.ready; // resolves after the WebSocket handshake -const greet = webFront.cppFunction("greet"); -const message = await greet("Ada"); // "Hello, Ada!" computed in C++ -result.textContent = message; -``` +| Platform | CMake option | Runtime | +| --- | --- | --- | +| Windows | `-DWEBFRONT_EMBED_WEBVIEW2=ON` | Microsoft Edge WebView2 Evergreen | +| macOS 13.3+ | `-DWEBFRONT_EMBED_WKWEBVIEW=ON` | System Cocoa / WebKit | +| Linux | `-DWEBFRONT_EMBED_WEBKITGTK=ON` | WebKitGTK 6.0; [installation](docs/WEBKITGTK.md) | -Run it from the build directory (the build copies the assets to `src/greeter`): +For local review of this unpublished branch, first [build the local archive](docs/DEVELOPER_ENVIRONMENT.md#environment-distribution-and-offline-tests-maintainers). That preparation requires Node/npm for the maintainer only. Then, on macOS, from the repository root: ```bash -./src/WebFrontGreeter -``` - -Exceptions thrown by the C++ callback reject the JavaScript Promise. `webFront.ready` rejects if the initial connection fails or closes; it does not report later disconnects. - -Callback signatures are deduced for ordinary and `mutable` lambdas, function pointers and `std::function`. Generic lambdas and overloaded call operators cannot be deduced; register those with `app.cppFunction(name, callable)`. - -## How it fits your application - -Keep calculations, data structures and resource ownership in C++. The interface calls the functions you register, and C++ can call back into the interface. There is no requirement to make your application objects inherit from a widget hierarchy or adopt a parent-owned object model. - -The connection is asynchronous: interface code awaits a Promise when it calls C++, and C++ can request a result through `std::future`. WebFront owns its server thread and cleans it up when the application object is destroyed. Callbacks run on that server thread; synchronise access to shared application state and hand lengthy work to your own workers. - -`show()` starts the server and opens the interface. It is a blocking call: the default frontend waits for Enter in the terminal, while an embedded frontend runs its window loop until the window closes. Embedded frontends also have platform thread requirements; WebView2 normally belongs on the main thread. You do not write a GUI event loop, but you still need to choose where `show()` belongs in your application's lifecycle. - -For a command-line tool, this can mean adding a graphical control panel around existing functions. For an interactive application, it gives you HTML and CSS for layout while your C++ code continues to own the work. See [Bridge basics](#bridge-basics) for return values, errors and connection handling. - -## A terminal for your application - -`WebFrontTerminal` adds an interactive terminal to your application's interface. Its embedded [xterm.js](https://xtermjs.org/) line editor provides history and Tab completion, and sends each line to commands registered in C++. It is the first optional UI component; it needs no document root or internet access at run time. - -```cpp -#include - -webfront::TerminalApp app; -webfront::Terminal terminal{app, {.prompt = "demo> "}}; -terminal.command("greet", "Greet someone", [](webfront::CommandArgs args) { - return "Hello, " + (args.empty() ? std::string{"world"} : args[0]) + "!"; -}); -app.show(terminal.page); +cmake -S . -B build-native -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_WKWEBVIEW=ON +cmake --build build-native --target WebFrontLifeDeveloper --parallel 2 +mkdir -p life-project/.webfront/developer/preview/provision +cp build-developer-environment/*.tgz life-project/.webfront/developer/preview/provision/ +integrity=$(node -p "require('./build-developer-environment/provision.json').integrity") +./build-native/examples/WebFrontLifeDeveloper "$PWD/life-project" \ + /webfront/developer/preview/provision/environment.tgz "$integrity" ``` -A command's return value (or what it writes to a `std::ostream&` parameter) is printed; an exception is shown as an error. `help` and `clear` are built in. Output appears when the command finishes: there is no streaming, and Ctrl+C interrupts only browser commands. See [docs/UI_COMPONENTS.md](docs/UI_COMPONENTS.md) for the component architecture and the `wf` tool manager. +Replace the engine option on Linux or Windows. With Visual Studio, add `--config Release` when building. After preparing the local archive, launch from PowerShell with: -```bash -./src/WebFrontTerminal +```powershell +New-Item -ItemType Directory -Force life-project/.webfront/developer/preview/provision | Out-Null +Copy-Item build-developer-environment/*.tgz life-project/.webfront/developer/preview/provision/ +$integrity = (Get-Content build-developer-environment/provision.json -Raw | ConvertFrom-Json).integrity +.\build-native\examples\Release\WebFrontLifeDeveloper.exe "$PWD/life-project" ` + /webfront/developer/preview/provision/environment.tgz "$integrity" ``` -`WebFrontTools` (`src/Tools.cpp`) adds the `wf` tool manager to the terminal: `wf search`, `wf install [@version]`, `wf list`, `wf open` and `wf remove` manage web tools published on npm with the `webfront-tool` keyword. The page downloads them from registry.npmjs.org, checks their SHA-512 integrity and stores them in the working directory (`.webfront/tools/`, recorded in `webfront-tools.lock.json`). An installed tool can call every registered C++ function: install only tools you trust, during development. - -## Choose how your interface opens - -The application code and interface assets stay the same whichever frontend you select. +The example reports startup failures with a nonzero exit status. Use a fresh project directory for this walkthrough. Once developer distribution 0.4.0 is published, the archive URL and integrity arguments can be omitted to use the pinned defaults. -| Frontend | Platforms | What you need | -| --- | --- | --- | -| System browser (default) | Windows, Linux, macOS | An installed browser; no embedded engine download | -| Embedded CEF window | Windows, Linux, macOS | Enable CEF at configuration time; a large download | -| Embedded WebView2 window | Windows | Enable the SDK and install the Evergreen Runtime | -| Embedded WKWebView window | macOS 13.3+ | Enable Cocoa/WebKit support; the engine ships with macOS | -| Embedded WebKitGTK window | Linux | Install WebKitGTK 6.0 development packages and enable the option | -| Native web view alias (opt-in) | Windows, macOS, Linux | Enable the platform adapter above; select `NativeWebViewFrontend` | -| Embedded WebKitGTK window | Linux | Install WebKitGTK 6.0 (GTK 4) development packages and enable the option | - -WebView2 uses Chromium; WKWebView and WebKitGTK use WebKit. Rendering can differ between -platforms. Choose CEF when you need the same engine across desktop platforms. Each embedded -frontend is opt-in; `webfront::WebFront` keeps the system browser as its default. +### 3. Install dependencies in the application's terminal -Construct the application and call `show()` on the main thread for embedded frontends. Their `open()` -blocks until window closure; `show()` then stops and joins the server. A `keepServerRunning` frontend -leaves the server active after opening returns; the system-browser adapter waits for Enter first. -If opening throws, `show()` stops and joins the server before propagating the exception. Unavailable -frontend types remain declared and throw a diagnostic naming the required CMake option. +In the downloaded terminal, run: -The [shared content policy](docs/CONTENT_POLICY.md) restricts bridge connections to the application origin, -limits embedded navigation to that origin and blocks embedded popups by default. Explicit allow-lists and -development opt-outs are available. See the [frontend contract](docs/FRONTENDS.md#the-contract) for initialization and threading. +```text +wf create life +wf install react@19.3.1 react-dom@19.3.1 +wf preview ui/main.tsx +``` -### Embedded window with CEF (opt-in) +`wf create life` writes the editable [TSX and CSS starter](examples/life/ui), without overwriting an existing project. `wf install` fetches the browser packages and their dependencies, verifies their integrity and records exact versions in `webfront-packages.lock.json`. It does not run npm installation scripts. `wf preview` compiles TSX with WebAssembly and opens the interface inside the application. -By default WebFront opens your system browser. To get an application window instead, enable the Chromium Embedded Framework when configuring. CEF is a **large download** and is never fetched unless you ask for it: +Edit `life-project/ui/main.tsx` and `style.css` with your usual editor, then run `wf preview` again. React renders the field and controls; each generation awaits the C++ callback: -```bash -cmake -DWEBFRONT_EMBED_CEF=ON .. +```js +await webFront.ready; +const step = webFront.cppFunction('life.step'); +const next = await step(cells); ``` -`WEBFRONT_EMBED_CEF` only makes CEF *available*; the frontend is chosen in your source by changing the alias, nothing else: - -```cpp -using App = webfront::WebFrontWithFrontend; -``` +`cells` and `next` are 128-byte `Uint8Array` grids mapped to C++ `std::bitset<1024>`, least-significant bit first in each byte. JavaScript calls always return a Promise: await them or handle rejection. No Life rules run in JavaScript. -Selecting `CEFFrontend` in a build without CEF fails with a clear error. An embedded window stops the server when it closes. `webfront::WebFront` always uses the system browser, even in a CEF-enabled build. +### 4. Try the result -### Embedded window with WebKitGTK (Linux, opt-in) +![Game of Life running in a native window](docs/images/life-preview.jpg) -On supported Ubuntu/Debian systems, install the development package and pkg-config: +Play or pause, advance one generation, paint cells, switch patterns, change speed or select a plan view. Generation and population counters reflect the C++ simulation. Only one generation request is outstanding at a time; failures stop playback and appear in the interface. -```bash -sudo apt install libwebkitgtk-6.0-dev pkg-config -``` +### 5. Embed the interface for distribution -Configure with `-DWEBFRONT_EMBED_WEBKITGTK=ON`, then select: +In the application's terminal: -```cpp -using App = webfront::WebFrontWithFrontend; -App app; -app.show(); +```text +wf embed ui/main.tsx --output generated/LifeUI.hpp ``` -Construct and open on the process main thread with a working X11 or Wayland display. -The window uses the system WebKitGTK 6.0 / GTK 4 runtime and returns when closed, including -pages that never connect to the bridge. GTK headers do not propagate through -`WebFront.hpp`. Each executable has persistent data/cache directories under the XDG roots, -restricted to `0700`; processes launched from the same executable share that profile. -Automated coverage uses X11/Xvfb; native Wayland and WSLg still need desktop qualification. -See [WebKitGTK setup, profiles and tests](docs/WEBKITGTK.md) for other distributions and runtime requirements. - -To run the React demo in this window from the repository root: +This builds the interface and packages its resources and dependency notices into a compressed C++ header. Close the development window, then reconfigure with the **same engine option** used above. On macOS: ```bash -cmake -S . -B build-webkitgtk -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WEBKITGTK=ON \ - -DWEBFRONT_DEMO_FRONTEND=WebKitGTK -cmake --build build-webkitgtk --target WebFrontApp --parallel -./build-webkitgtk/src/WebFrontApp react.html +cmake -S . -B build-native -DWEBFRONT_EMBED_WKWEBVIEW=ON \ + -DWEBFRONT_LIFE_ASSETS="$PWD/life-project/generated/LifeUI.hpp" +cmake --build build-native --target WebFrontLifeEmbedded --parallel 2 +./build-native/examples/WebFrontLifeEmbedded ``` -### Embedded window with WebView2 (Windows, opt-in) +For Visual Studio add `--config Release` and launch `build-native\examples\Release\WebFrontLifeEmbedded.exe`. -Configure with `-DWEBFRONT_EMBED_WEBVIEW2=ON`, then select the frontend explicitly: +[LifeEmbedded.cpp](examples/life/LifeEmbedded.cpp) replaces the development project and bootstrap with the generated provider: ```cpp -using App = webfront::WebFrontWithFrontend; -App app; -app.show(); // returns when the window closes and the server has stopped -``` - -CMake fetches Microsoft.Web.WebView2 SDK **1.0.3537.50**, verifies its SHA-256 and links the static loader; no machine-wide SDK or loader DLL is required. The option defaults to `OFF` and requires Windows with an MSVC-compatible compiler (MSVC or clang-cl); MinGW is rejected at configuration time. The loader follows the compiler's x86, x64 or ARM64 target, including when it differs from the host; unsupported targets fail during configuration. It never changes `webfront::WebFront`'s system-browser default. Selecting the adapter without support throws an error explaining how to enable it. - -The separately installed **Microsoft Edge WebView2 Evergreen Runtime** is required. Follow the shared main-thread contract; WebView2 additionally requires STA-compatible COM. The window handles resizing and keyboard focus, and closing it stops the server. - -This frontend applies the [shared content policy](docs/CONTENT_POLICY.md); DevTools and context menus remain available by default. See the [WebView2 frontend notes](docs/WEBVIEW2.md) for runtime distribution, configurable startup deadlines and profiles, DPI and the navigation policy. - -### Embedded window with WKWebView (macOS, opt-in) - -On macOS 13.3 or newer, configure with `-DWEBFRONT_EMBED_WKWEBVIEW=ON` and select: - -```cpp -using App = webfront::WebFrontWithFrontend; -App app; -app.show(); // returns after the window closes and the server stops +webfront::NativeAppWithAssets app; +app.cppFunction("life.step", &webfront::demo::nextLife); +app.show(); ``` -The system supplies WebKit; there is no engine download or runtime installation. Construct and -open on the main thread. Each opening uses a non-persistent website data store. Quit and -`window.close()` return control to C++. The module demo selects this adapter with -`-DWEBFRONT_DEMO_FRONTEND=WKWebView`. See [WKWebView notes](docs/WKWEBVIEW.md) for lifecycle, -inspection, content-policy limits and bundled-executable networking. +Recompilation is explicit. The resulting application runs offline without the project directory, developer callbacks or downloaded tool cache. The selected native engine's deployment requirements still apply; this is not an application installer. ## Use WebFront in your project -```cmake -cmake_minimum_required(VERSION 3.31) -project(MyApp LANGUAGES CXX) +WebFront's implementation lives under `include/`. There is no WebFront library binary to build; CMake supplies its C++ dependencies and platform settings: -add_subdirectory(WebFront) # e.g. a git submodule or a vendored checkout +```cmake +add_subdirectory(path/to/WebFront) add_executable(MyApp main.cpp) target_link_libraries(MyApp PRIVATE WebFront::WebFront) ``` -When WebFront is not the top-level project it builds neither its examples nor its tests (opt in with `-DWEBFRONT_BUILD_EXAMPLES=ON` or `-DENABLE_TESTING=ON`). Dependencies are fetched with CPM during the first configure, so that step needs network access. There is no installable CMake package yet. +As a subproject, examples and tests are off by default and compiler settings do not leak into your targets. `WEBFRONT_BUILD_EXAMPLES=OFF` disables examples in a standalone build too. -## Limitations +`webfront::WebFront` always uses the system browser. Native adapters are explicit choices and remain optional; CEF is available when you need an embedded Chromium distribution. See [WKWebView](docs/WKWEBVIEW.md), [WebKitGTK](docs/WEBKITGTK.md) and the [frontend architecture](docs/adr/README.md). -- WebFront is an experimental foundation. APIs and the wire format may change. -- Gzip fallback to identity runs synchronously on the server thread with a configurable 4 MiB default decoded-byte budget, including HEAD. See the [fallback budget](docs/HTTP_ASSETS.md#fallback-budget); decoded-asset caching and byte-wise reading remain follow-ups. -- Calls are asynchronous. Results cross the bridge as `std::future` (C++ calling JavaScript, `ui.jsFunction(name)`) and Promises (JavaScript calling C++, `webFront.cppFunction(name)`), limited to scalars, strings (up to 65535 bytes each), tuples, numeric typed arrays and packed `std::bitset` values. Richer objects and a DOM abstraction are out of scope. -- A configured document root exposes local files for **development only**; it is not a sandbox or a production packaging format. -- Nothing authenticates the browser: the server binds to loopback by default, but any local process can connect. -- With WebView2 enabled, `WebFront.hpp` exposes Windows SDK, Shell and WRL global names, including `::byte`. Qualify `std::byte` instead of relying on `using namespace std;`. -- The tested toolchains are listed in the CI workflow; other compilers may not work yet. - -## Build options - -| Option | Default | Meaning | -| --- | --- | --- | -| `WEBFRONT_EMBED_CEF` | `OFF` | Download and link CEF so `CEFFrontend` is available (Windows, Linux and macOS only). Other platforms fail at configure time | -| `WEBFRONT_EMBED_WEBKITGTK` | `OFF` | Enable the system WebKitGTK 6.0 embedded frontend (Linux only) | -| `WEBFRONT_EMBED_WEBVIEW2` | `OFF` | Download the pinned WebView2 SDK and link its static loader (Windows only) | -| `WEBFRONT_EMBED_WKWEBVIEW` | `OFF` | Link the system Cocoa and WebKit frameworks for WKWebViewFrontend (macOS 13.3+ only) | -| `WEBFRONT_DEMO_FRONTEND` | `DefaultBrowser` | Frontend for `WebFrontApp`: `DefaultBrowser`, `CEF`, `WebView2`, `WKWebView`, `WebKitGTK` or `Native` (enable the matching platform adapter) | -| `WEBFRONT_WEBTEST_FRONTEND` | Initial cache value: first enabled embedded frontend for the platform; `CEF` if none | Embedded frontend for the shared Jasmine and lifecycle runners; WebView2 takes priority over CEF on Windows, WKWebView on macOS, WebKitGTK on Linux; explicit selection overrides the default | -| `ENABLE_TESTING` | `OFF` | Build the Catch2 suite and the Jasmine browser test | -| `WEBFRONT_BUILD_EXAMPLES` | `ON` when top-level | Build `HelloWorld`, `WebFrontGreeter` and `WebFrontApp` | -| `ENABLE_COVERAGE` | `OFF` | Instrument the C++ tests (GCC/Clang) | -| `ENABLE_SANITIZER_ADDRESS` / `ENABLE_SANITIZER_UNDEFINED_BEHAVIOR` | `OFF` | Enable ASan / UBSan on internal targets (GCC/Clang) | -| `ENABLE_SANITIZER_THREAD` | `OFF` | Enable TSan separately from ASan (GCC/Clang) | -| `ENABLE_FUZZING` | `OFF` | Build three libFuzzer decoders with ASan+UBSan (Clang with compiler-rt/libFuzzer; Linux CI) | - -Frontend selectors keep their cached value on reconfiguration, even when another engine is enabled later. On Windows, use `-DWEBFRONT_WEBTEST_FRONTEND=WebView2` to switch an existing CEF runner, or `-UWEBFRONT_WEBTEST_FRONTEND` to recompute the default. CEF browser tests are validated only on Linux/Xvfb; selecting CEF on Windows or macOS builds the runner but emits a warning and registers no browser test. - -Test targets automatically enable the vendor's hardened standard library: `_GLIBCXX_ASSERTIONS` -with libstdc++, `_LIBCPP_HARDENING_MODE_EXTENSIVE` with libc++, or `_MSVC_STL_HARDENING=1` -with MSVC STL. Supporting GCC/Clang compilers also use `-ftrivial-auto-var-init=pattern`; -older compilers emit a warning and retain the other hardening settings. These settings, -sanitizers and fuzz instrumentation are private to internal targets; linking `WebFront::WebFront` -does not impose them on a consumer. - -For ASan+UBSan, add `-DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON` -to the configure command in [Contributing: build and test](#contributing-build-and-test). For a separate TSan build use -`-DENABLE_SANITIZER_THREAD=ON`. CI runs both configurations on the full CEF-off suite (libstdc++ for ASan+UBSan, -libc++ for TSan, which also exercises retry after a throwing `std::call_once` callback); -`UBSAN_OPTIONS=halt_on_error=1` makes a UBSan diagnostic fail the run. - -Fuzzing requires a Clang distribution with the compiler-rt libFuzzer, ASan and UBSan runtimes. -Linux is the CI-validated configuration. Apple Clang does not ship libFuzzer: macOS requires -an external installation such as LLVM with compiler-rt, and compatible sanitizer runtimes. -CMake checks that these runtimes link before adding the fuzz targets. - -```bash -cmake -S . -B build-fuzz -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF -DENABLE_FUZZING=ON -cmake --build build-fuzz --parallel -# Repeat with http and websocket. Corpora are copied into the build tree. -./build-fuzz/fuzz/fuzz_messages build-fuzz/fuzz/corpus/messages \ - -max_total_time=30 -timeout=5 -max_len=65536 -rss_limit_mb=1024 -``` - -Fuzzers cover bridge headers and every owning parameter family, incremental HTTP parsing, -and WebSocket headers/payloads with complete and chunked input. The checked-in seed corpus -comes from unit-test examples; CI runs each decoder for 30 seconds and uploads crash inputs -on failure. This is bounded smoke coverage, not an exhaustive security audit. - -## Contributing: build and test +## Build and test ```bash cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -cmake --build build --parallel +cmake --build build --parallel 2 ctest --test-dir build --output-on-failure ``` -The automated real-browser tests run on Linux with Xvfb: - -```bash -cmake -S . -B build-cef -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=ON -DENABLE_TESTING=ON -cmake --build build-cef --target webtest --parallel -ctest --test-dir build-cef -L web-integration --output-on-failure -``` - -The asset freshness checks require Node.js 22.18+ (24 in CI); ordinary C++ consumer builds do not require Node.js or npm. - -The Jasmine specs are native ES modules. They prove relative module loading, both bridge directions, all supported numeric typed arrays and `webFront.ready`; report the final result to C++; close the embedded window automatically; and fail CTest on an assertion, bridge, startup or timeout error. CTest also checks that the commands and snippets in this README match the built examples. - -The shared lifecycle suite checks closure without a bridge, immediate page closure, a rejected -`webFront.ready`, failed initial navigation, encoded filenames, blocked navigation/popups and an explicit -navigation allow-list. It runs with the same selected -frontend as Jasmine; every case has a timeout and the `web-integration` label. See -[frontend lifecycle coverage](docs/FRONTENDS.md#lifecycle-tests) for details. - -On Linux, WebKitGTK runs the same Jasmine and shared lifecycle suites plus adapter-specific cases. -Install the WebKitGTK development package, pkg-config and Xvfb, then configure explicitly: - -```bash -sudo apt install libwebkitgtk-6.0-dev pkg-config xvfb -cmake -S . -B build-webkitgtk -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WEBKITGTK=ON -DENABLE_TESTING=ON \ - -DWEBFRONT_DEMO_FRONTEND=WebKitGTK -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -cmake --build build-webkitgtk --parallel -ctest --test-dir build-webkitgtk -L web-integration --output-on-failure --no-tests=error -``` - -CTest invokes Xvfb and gives each WebKitGTK test private XDG data/cache paths. The Ubuntu CI -lane runs these tests with timeouts. See [WebKitGTK verification notes](docs/WEBKITGTK.md) -for display and container setup. - -On Windows, the same Jasmine and lifecycle suites, plus WebView2-specific cases, run in WebView2 (Evergreen runtime required): - -```powershell -cmake -S . -B build-webview2 -DWEBFRONT_EMBED_WEBVIEW2=ON -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -DWEBFRONT_DEMO_FRONTEND=WebView2 -DWEBFRONT_WEBTEST_FRONTEND=WebView2 -cmake --build build-webview2 --config Release --parallel -ctest --test-dir build-webview2 -C Release --output-on-failure -``` - -The `windows-2025` CI matrix includes both the default MSVC build and this WebView2 configuration. Every browser test has a CTest timeout. Lifecycle tests cover repeated opening, closure requested during native window creation, queued startup timer messages after closure or failure, a held page resource after runtime creation, a page that never connects, a rejected `webFront.ready`, initial and later failed navigation, incompatible COM and a missing runtime. Unit tests cover shared URL construction, configured addresses and deadlines, process-failure policy, native focus/move/DPI forwarding, reentrant shutdown and hexadecimal HRESULT diagnostics. - -The shared Jasmine suite also runs the actual Signal Studio React interface against its C++ callback, including parameter changes and recovery after a failed call. Unit tests check the generated samples and parameter validation. - -CI runs the WebView2 browser label separately with `--no-tests=error`, so absent browser tests fail the job. Runtime provisioning uses Microsoft's mutable Evergreen bootstrapper redirect, verifies its Microsoft signature if downloaded, and logs installed executable versions. The runtime is intentionally not pinned; the browser suite verifies initialisation with the selected runtime. - -## Signal Studio: the React example - -[Signal Studio](src/react.html) is the application pictured above. Adjust the frequency, amplitude and harmonic mix, then generate a new waveform. An ordinary [C++ function](src/SignalDemo.hpp) calculates 256 samples and returns a numeric typed array; React renders the curve and derives its peak and RMS measurements. The data is synthetic, rather than a live device feed. - -React and React DOM 19.3.1 share a locally embedded ES-module runtime; Babel 8.0.7 translates the editable JSX with the automatic transform at run time. The example needs no npm install, CDN or separate JavaScript build. Jasmine 7.0.2 and xterm 6.0.0 / Fit 0.11.0 are also embedded locally. JavaScript/CSS dependency assets use reproducible gzip; see [versions, regeneration and size measurements](docs/EMBEDDED_ASSETS.md). - -To open it in a native window on Windows, configure from the repository root (WebView2 Evergreen Runtime required): - -```powershell -cmake -S . -B build-webview2 -DWEBFRONT_EMBED_WEBVIEW2=ON -DWEBFRONT_DEMO_FRONTEND=WebView2 -cmake --build build-webview2 --config Release --target WebFrontApp -./build-webview2/src/Release/WebFrontApp.exe react.html -``` - -This is how the screenshot was captured: the real application in its WebView2 window, including the Windows title bar and window controls. The same React page also runs in [CEF](#embedded-window-with-cef-opt-in), [WKWebView](#embedded-window-with-wkwebview-macos-opt-in) and [WebKitGTK](#embedded-window-with-webkitgtk-linux-opt-in). Enable the chosen adapter and set `WEBFRONT_DEMO_FRONTEND` to `CEF`, `WKWebView` or `WebKitGTK`. In the default build, launch `./src/WebFrontApp react.html` from the build directory to use the system browser instead. - -## Native-module demo - -Without a page argument, `WebFrontApp` serves `src/module-demo.html`, whose entry module imports other `.mjs` files with relative URLs, calls the registered C++ `moduleReady` callback and receives a C++ call back: - -```bash -./src/WebFrontApp # native-module demo -./src/WebFrontApp react.html # Signal Studio (embedded React) -``` - -## Bridge basics - -Built-in frontends open the configured server address. Page arguments are URI references: `app.show("index.html?view=details#result")` preserves the query and fragment. Spaces and UTF-8 characters are encoded automatically; use `%23`, `%3F` and `%25` for literal `#`, `?` and `%` in a filename. Existing percent escapes are preserved consistently across frontends. - -- The two directions differ. JavaScript obtains a registered callback with `webFront.cppFunction('name')` and calls C++; the call always returns a Promise, even for a `void` C++ callback, so await it or handle its rejection (an ignored rejected Promise raises an unhandled rejection). -- C++ obtains a browser function with `ui.jsFunction("name")` and calls served JavaScript. Only the untyped form is fire-and-forget; `ui.jsFunction(name)(...)` returns a `std::future`. -- `co_await ui.jsFunctionSender(name)(...)` starts a typed call when awaited and supports receiver stop-token cancellation. Cancellation stops the C++ wait; JavaScript already dispatched continues. The future API remains available. See [structured execution and cancellation](docs/ASYNC_EXECUTION.md). -- Bridge parameters include scalars, strings, tuples, numeric typed arrays and `std::bitset`. C++ `std::vector`, `std::array` and `std::span` map to the matching JavaScript typed-array class; ordinary JavaScript arrays remain tuple-like argument groups. Bitsets map to `Uint8Array` with exactly `ceil(N / 8)` bytes: bit `i` is bit `i % 8` of byte `i / 8` (least significant first). Unused high bits must be zero; wrong types, lengths, truncated data and nonzero padding reject the call. `std::bitset<0>` maps to an empty byte array. JavaScript must know `N` from the application contract; it is not sent separately. -- Missing functions, callback exceptions, malformed returns and disconnected browsers complete a C++ future exceptionally (`get()` throws) and reject a JavaScript Promise. -- A callback whose first parameter is the application's `UI` type receives the browser that called it, for example to call it back later; JavaScript passes only the other parameters: - ```cpp - app.cppFunction("subscribe", [](webfront::UI caller, std::string topic) { - caller.jsFunction("onEvent")(topic); - }); - ``` -- `onUIStarted(handler)` sets the application's handler for each connected browser. Code that must not replace it, such as a reusable component, uses `auto subscription = app.subscribeUIStarted(handler);`; the handler stays registered while `subscription` lives. - -WebFront owns spawned coroutines, runs them on its server thread and cancels and drains them at shutdown. No execution context or scope is needed: - -```cpp -#include - -webfront::Task showSquareRoot(webfront::UI ui) { - auto result = co_await ui.jsFunctionSender("Math.sqrt")(81); - co_await ui.jsFunctionSender("console.log")("sqrt(81) =", result); -} - -int main() { - webfront::WebFront app; - app.onUIStarted([&app](webfront::UI ui) { - app.spawn(showSquareRoot(ui)); - }); - app.show(); -} -``` - -This is the compiled example [AwaitBrowser.cpp](src/AwaitBrowser.cpp); run `./src/WebFrontAwaitBrowser` from the build directory and open the browser console. `ui.spawn(task)` is also available. Both spawn methods accept calls from any thread while the application lives; coroutine bodies run on the server thread. A call rejected during shutdown returns an already stopped handle. - -`app.shutdown()` waits for already admitted calls to finish starting their tasks before draining owned work. -Call it outside server callbacks, after external callers of `run()`/`runOne()` have returned. -A task that ignores cancellation and waits for external completion can still cause explicit shutdown -to report a stalled join; destruction waits for that completion. - -Keep the returned handle to cancel one task with `handle.requestStop()`; discarding the handle keeps the task running. Catch browser errors inside the coroutine when recovery is needed; unhandled errors are logged. Do not block the server thread with lengthy work. See [execution and lifetime rules](docs/ASYNC_EXECUTION.md). - -## Advanced: frontend aliases - -```cpp -using BrowserFront = webfront::WebFrontWithFrontend; -using EmbeddedFront = webfront::WebFrontWithFrontend; -using WindowsFront = webfront::WebFrontWithFrontend; -using MacFront = webfront::WebFrontWithFrontend; -using NativeFront = webfront::WebFrontWithFrontend; -using LinuxFront = webfront::WebFrontWithFrontend; -``` - -`NativeWebViewFrontend` is a pure alias: `WebView2Frontend` on Windows, `WKWebViewFrontend` -on macOS and `WebKitGTKFrontend` on Linux. Enable the corresponding CMake option -(`WEBFRONT_EMBED_WEBVIEW2`, `WEBFRONT_EMBED_WKWEBVIEW` or `WEBFRONT_EMBED_WEBKITGTK`). -At runtime, selecting the alias without that support throws the adapter's existing exception -naming the platform option. CMake selectors using `REQUIRE_AVAILABLE` instead reject the -configuration with `requires WEBFRONT_EMBED_=ON`; the module demo permits -configuration without support so it can report the runtime diagnostic. -The alias is declared only on Windows, macOS and Linux; CMake rejects `Native` on other platforms. -The adapters' runtime, main-thread and deployment requirements still apply. The alias never -changes `webfront::WebFront`, which always uses the system browser. - -The module demo accepts `-DWEBFRONT_DEMO_FRONTEND=Native`. For example, on Linux: - -```bash -cmake -S . -B build-native -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_DEMO_FRONTEND=Native -cmake --build build-native --target WebFrontApp -./build-native/src/WebFrontApp -``` +Tests additionally require Node.js for offline JavaScript checks. Browser tests require an enabled engine; Linux CEF tests use Xvfb. See [AGENTS.md](AGENTS.md) for contributor commands and [developer environment testing](docs/DEVELOPER_ENVIRONMENT.md#environment-distribution-and-offline-tests-maintainers). -Native engines differ: Windows uses Chromium through WebView2; macOS and Linux use -WebKit. Choose [CEF](#embedded-window-with-cef-opt-in) when identical rendering across -platforms is required, and embed the same CEF version on every platform. +CI runs one combined C++ / native-browser job per desktop platform on each code change. The Linux job also uploads GCC coverage on each PR. Linux Clang, sanitizers, fuzzing and CEF compatibility run weekly and on demand. Workflow concurrency cancels superseded runs; dependency and compiler caches avoid repeated work. Platform badges above identify the configured matrix; the CI badge reports its aggregate status. Execution times depend on cache state and runner availability. -See [AGENTS.md](AGENTS.md) for architecture, development commands, conventions, test requirements and safety guidance. The current evidence-based status and backlog recommendations are in [docs/PROJECT_STATUS.md](docs/PROJECT_STATUS.md) and [docs/ISSUE_AUDIT.md](docs/ISSUE_AUDIT.md). +## Contracts and limitations -The [architecture decision records](docs/adr/README.md) explain the design choices, their Git history, tradeoffs and implementation rules for future changes and code generation. +- WebFront owns an HTTP/WebSocket server on a background thread. Callbacks run there; avoid blocking it. Native windows must be created and shown on the main thread. Application coroutines use `app.spawn(task)` or `ui.spawn(task)`; see [execution and cancellation](docs/ASYNC_EXECUTION.md). +- JavaScript calls to C++ always return Promises. C++ `ui.jsFunction(name)(...)` is fire-and-forget; `ui.jsFunction(name)(...)` returns `std::future`. Missing functions, exceptions, malformed replies and disconnects fail the typed call. +- The binary bridge supports scalars, strings, tuples, numeric typed arrays and packed bitsets. Arbitrary objects do not cross it. Strings have a 16-bit encoded length limit. +- Development project access is explicit and intended for trusted local code. Downloaded tools run with the application's bridge authority. Package scripts, native Node add-ons and Node APIs are unsupported. TypeScript is transformed without type checking. +- Packaging, accessibility and native-engine deployment still need application-specific work. General DOM abstractions remain future work. See [project status](docs/PROJECT_STATUS.md) for known limitations. -Optional mddlog diagnostics are available through `WEBFRONT_USE_MDDLOG=ON` (default: `OFF`). Consumers keep including `tooling/Logger.hpp`; WebFront links its compiled adapter. See [dependencies, toolchain matrix and verification](docs/mddlog-integration.md). +[Developer environment reference](docs/DEVELOPER_ENVIRONMENT.md) · [UI components](docs/UI_COMPONENTS.md) · [architecture decisions](docs/adr/README.md) · [contributing](CONTRIBUTING.md) diff --git a/src/WebFront.js b/assets/WebFront.js similarity index 100% rename from src/WebFront.js rename to assets/WebFront.js diff --git a/src/components/terminal/index.html b/assets/components/terminal/index.html similarity index 100% rename from src/components/terminal/index.html rename to assets/components/terminal/index.html diff --git a/src/components/terminal/terminal.mjs b/assets/components/terminal/terminal.mjs similarity index 100% rename from src/components/terminal/terminal.mjs rename to assets/components/terminal/terminal.mjs diff --git a/src/components/tools/wf.mjs b/assets/components/tools/wf.mjs similarity index 100% rename from src/components/tools/wf.mjs rename to assets/components/tools/wf.mjs diff --git a/src/developer/PACKAGES-LICENSE.txt b/assets/developer/PACKAGES-LICENSE.txt similarity index 100% rename from src/developer/PACKAGES-LICENSE.txt rename to assets/developer/PACKAGES-LICENSE.txt diff --git a/src/developer/archive.mjs b/assets/developer/archive.mjs similarity index 100% rename from src/developer/archive.mjs rename to assets/developer/archive.mjs diff --git a/src/developer/bootstrap-entry.mjs b/assets/developer/bootstrap-entry.mjs similarity index 100% rename from src/developer/bootstrap-entry.mjs rename to assets/developer/bootstrap-entry.mjs diff --git a/src/developer/bootstrap.bundle.mjs b/assets/developer/bootstrap.bundle.mjs similarity index 100% rename from src/developer/bootstrap.bundle.mjs rename to assets/developer/bootstrap.bundle.mjs diff --git a/src/developer/bootstrap.mjs b/assets/developer/bootstrap.mjs similarity index 100% rename from src/developer/bootstrap.mjs rename to assets/developer/bootstrap.mjs diff --git a/src/developer/bundler.mjs b/assets/developer/bundler.mjs similarity index 100% rename from src/developer/bundler.mjs rename to assets/developer/bundler.mjs diff --git a/assets/developer/bundles.json b/assets/developer/bundles.json new file mode 100644 index 00000000..ca39e451 --- /dev/null +++ b/assets/developer/bundles.json @@ -0,0 +1,34 @@ +{ + "assets/developer/bootstrap.mjs": "534af4b3d07891338c3390e1d5e06c2fb6dd8df11ca6547735565b17f1b9cd70", + "assets/developer/bootstrap-entry.mjs": "ff8084f23f5acc721f97eb1ed0a454e7bfee1894de17d54f0100fa11f7ef8b77", + "assets/developer/packages.mjs": "faed29500a34c6ce24756d07bd4b47b9168ccec4bd49d12f00096a869637d74d", + "assets/developer/starter.mjs": "f8cdef1218ae14f8bbe49eae495d931cc29e33f74444f0e37d61aea416b9d750", + "assets/developer/paths.mjs": "6ebb626610756143c58762c87af18980802809d7f0f53d3b588e4b20e8db0161", + "assets/developer/runtime.mjs": "36847f4413928908ebc8a1909e608c783701b13274a289d81e43df0e5125a0e8", + "assets/developer/compiler.mjs": "3f7e187ca9a4c2645ef3823127457cad655919cbea3c7c0f22fb7ae2cc87e0e5", + "assets/developer/bundler.mjs": "b0ff79a1b0caa012c25ec7b7f121d7d50af1aa1651231d3dcf2f39470c4ea25c", + "assets/developer/entry.mjs": "b2b942443e3c74ae2c008392ba244d9b7e91db70ba1b4ebbe1357c455ebf51bb", + "assets/developer/conditions.mjs": "7f0ecba239480831e38985ccffd4c82309949924f4eb9d938e4ad1b09f5f36ed", + "assets/developer/io.mjs": "a155719c612e065c30272c0dfdc456df28b5efa90ca26f8cfcb55c9cb46de690", + "assets/developer/recipe.mjs": "809f2091c50ebd13d23f92de9876b584658dc687324f73d48ee9f1271319f1ed", + "assets/developer/registry.mjs": "f566f07ea066155ab7209d925cee2cf12a664ac51b07bc0ca3e3fd8fde49a9c8", + "assets/developer/archive.mjs": "1fb8b9c3c27219858597801104639bba1104c7a7d33973609cd556b5e5f81d2d", + "assets/developer/lock.mjs": "60d0ea14d24793cd5e85bbd4bb4bfe90d2c7d76c0d20ffc99f462595a6e57291", + "assets/developer/pins.mjs": "ddb2214a2e906cb117dc1bac0b5b056decd4f6c6e3d4713615176c1876db3534", + "assets/developer/peers.mjs": "e1d999892138682fc0134ef1f4d4b19b9a9ad8d7fb16e37fc9c6c684bd853896", + "assets/developer/resolve.mjs": "8b96b850af215be51f5cb85cc9c69e057afa04dfb8a57e572620c07059c17fa3", + "assets/developer/embed.mjs": "c8fb80998abecdd5fdeba77aa549ff638d849dc9fd7f34c896fb6c0c0bf15f34", + "tools/developer/starters/pi/main.tsx": "d3161b35db204ba54f782f711183e8d96aeff7c92d885c33a6ec168cf461e453", + "tools/developer/starters/pi/style.css": "360e2c7ae6d3699b00e18cbf67efbae7a8d8863d88926b31139e102cf38e5abd", + "examples/life/ui/main.tsx": "ed11a82aad1639eb6997af8b0fca4d5c5ed4c36422c22a74ac49ae73078d0a91", + "examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44", + "assets/components/tools/wf.mjs": "6ee86d85ec96bf548ca25ea3ea3554b7dacbed7d047d6a9cfdc1e0f3f42de05e", + "tools/developer/distribution.json": "f17197a710d994a83dd35fbb983ae672ae00144bc81eb3f22a78bbaf5f26f658", + "tools/developer/build.mjs": "c486ac6816e7c18c51d4b75dd3b032616ee081a4461a4125a5c1753f00d36c8d", + "tools/developer/site.mjs": "d4b7112f0aa5f277f291505a3dce84e676fee9d4da386973af7c6df9885d4dd4", + "tools/developer/archive.mjs": "bfe9feeb5e4d4e1b7c44c4dec4dcbeab4ae59c2bf16a1d2b32cd6910a2b84e7b", + "tools/assets/package-lock.json": "eb545112b672f9dbf520125df1f44a878d62cc8e611f0e33baee36470ded4dec", + "assets/developer/bootstrap.bundle.mjs": "792fe7cf564bd12ac47fef419d8c71e2070925764a17706552e7d3f5d6ba2181", + "assets/developer/packages.bundle.mjs": "994c13a8b30a40ecea98414caa72a17927dcea81a1f62d47744b4f55d87005be", + "include/system/DeveloperReleaseData.hpp": "89dd809cf07eb5f3c11c772f385941b81cf78b94ad3719ab1c40e844c246bc76" +} diff --git a/src/developer/compiler.mjs b/assets/developer/compiler.mjs similarity index 100% rename from src/developer/compiler.mjs rename to assets/developer/compiler.mjs diff --git a/src/developer/conditions.mjs b/assets/developer/conditions.mjs similarity index 100% rename from src/developer/conditions.mjs rename to assets/developer/conditions.mjs diff --git a/src/developer/embed.mjs b/assets/developer/embed.mjs similarity index 100% rename from src/developer/embed.mjs rename to assets/developer/embed.mjs diff --git a/src/developer/entry.mjs b/assets/developer/entry.mjs similarity index 100% rename from src/developer/entry.mjs rename to assets/developer/entry.mjs diff --git a/src/developer/index.html b/assets/developer/index.html similarity index 100% rename from src/developer/index.html rename to assets/developer/index.html diff --git a/src/developer/io.mjs b/assets/developer/io.mjs similarity index 100% rename from src/developer/io.mjs rename to assets/developer/io.mjs diff --git a/src/developer/lock.mjs b/assets/developer/lock.mjs similarity index 100% rename from src/developer/lock.mjs rename to assets/developer/lock.mjs diff --git a/src/developer/packages.bundle.mjs b/assets/developer/packages.bundle.mjs similarity index 100% rename from src/developer/packages.bundle.mjs rename to assets/developer/packages.bundle.mjs diff --git a/src/developer/packages.mjs b/assets/developer/packages.mjs similarity index 100% rename from src/developer/packages.mjs rename to assets/developer/packages.mjs diff --git a/src/developer/paths.mjs b/assets/developer/paths.mjs similarity index 100% rename from src/developer/paths.mjs rename to assets/developer/paths.mjs diff --git a/src/developer/peers.mjs b/assets/developer/peers.mjs similarity index 100% rename from src/developer/peers.mjs rename to assets/developer/peers.mjs diff --git a/src/developer/pins.mjs b/assets/developer/pins.mjs similarity index 100% rename from src/developer/pins.mjs rename to assets/developer/pins.mjs diff --git a/src/developer/recipe.mjs b/assets/developer/recipe.mjs similarity index 100% rename from src/developer/recipe.mjs rename to assets/developer/recipe.mjs diff --git a/src/developer/registry.mjs b/assets/developer/registry.mjs similarity index 100% rename from src/developer/registry.mjs rename to assets/developer/registry.mjs diff --git a/src/developer/resolve.mjs b/assets/developer/resolve.mjs similarity index 100% rename from src/developer/resolve.mjs rename to assets/developer/resolve.mjs diff --git a/src/developer/runtime.mjs b/assets/developer/runtime.mjs similarity index 100% rename from src/developer/runtime.mjs rename to assets/developer/runtime.mjs diff --git a/src/developer/starter.mjs b/assets/developer/starter.mjs similarity index 100% rename from src/developer/starter.mjs rename to assets/developer/starter.mjs diff --git a/src/fallback/index.html b/assets/fallback/index.html similarity index 100% rename from src/fallback/index.html rename to assets/fallback/index.html diff --git a/src/fallback/webfront-fallback.mjs b/assets/fallback/webfront-fallback.mjs similarity index 100% rename from src/fallback/webfront-fallback.mjs rename to assets/fallback/webfront-fallback.mjs diff --git a/cmake/CheckNewcomerDocs.cmake b/cmake/CheckNewcomerDocs.cmake index a943020c..36c987d7 100644 --- a/cmake/CheckNewcomerDocs.cmake +++ b/cmake/CheckNewcomerDocs.cmake @@ -1,18 +1,13 @@ -# Verifies that the newcomer commands and snippets documented in the README still match the -# examples, the CMake targets and the CI/contributor commands. Run with: -# cmake -DROOT= -P cmake/CheckNewcomerDocs.cmake +# Keep the two public examples, README commands and frontend option reference in sync. cmake_minimum_required(VERSION 3.31) - if(NOT ROOT) message(FATAL_ERROR "ROOT must point at the WebFront checkout") endif() - -function(_read var relative_path) - file(READ "${ROOT}/${relative_path}" content) +function(_read var path) + file(READ "${ROOT}/${path}" content) string(REPLACE "\r\n" "\n" content "${content}") set(${var} "${content}" PARENT_SCOPE) endfunction() - set(failures "") function(_require haystack needle description) string(FIND "${haystack}" "${needle}" position) @@ -21,23 +16,65 @@ function(_require haystack needle description) set(failures "${failures}" PARENT_SCOPE) endif() endfunction() - _read(readme README.md) _read(agents AGENTS.md) -_read(hello src/HelloWorld.cpp) -_read(greeter src/Greeter.cpp) -_read(await_example src/AwaitBrowser.cpp) -# Omit coverage-only comments from the runnable README snippet. -string(REGEX REPLACE "// LCOV_EXCL_[^\n]*\n" "" await_example "${await_example}") -_read(greeter_js src/greeter/greeter.mjs) -_read(src_cmake src/CMakeLists.txt) -_read(root_cmake CMakeLists.txt) +_read(life examples/life/LifeDeveloper.cpp) +_read(embedded examples/life/LifeEmbedded.cpp) +_read(examples examples/CMakeLists.txt) +_read(root CMakeLists.txt) _read(ci .github/workflows/BuildAndTest.yml) +_read(frontends docs/FRONTENDS.md) +_read(developer_guide docs/DEVELOPER_ENVIRONMENT.md) +_read(wkwebview_guide docs/WKWEBVIEW.md) +_read(developer_release include/system/DeveloperReleaseData.hpp) +# The local-review instructions must not silently use an unpublished default archive. +foreach(text readme wkwebview_guide) + _require("${${text}}" "/webfront/developer/preview/provision/environment.tgz \"$integrity\"" "${text} local bootstrap arguments") + _require("${${text}}" "require('./build-developer-environment/provision.json').integrity" "${text} trusted local integrity") +endforeach() +string(REGEX MATCH "https://[^\"]+/environment\\.tgz" developer_url "${developer_release}") +if(NOT developer_url) + list(APPEND failures "Cannot read the pinned developer environment URL") +else() + _require("${developer_guide}" "${developer_url}" "documented default developer environment") +endif() -# Evaluate real option declarations with a clean cache, then require the exact README row, -# including the per-engine plain-text help. Ignore Markdown code delimiters in the README. -# This catches changed defaults and description drift without exposing Markdown in CMake GUIs. -string(REPLACE "`" "" readme_options "${readme}") +_require("${root}" "add_subdirectory(examples)" "examples directory") +_require("${root}" "option(ENABLE_TESTING \"Enable Test Builds\" OFF)" "tests opt-in") +_require("${root}" "add_library(WebFront::WebFront ALIAS WebFront)" "consumer alias") +_require("${readme}" "target_link_libraries(MyApp PRIVATE WebFront::WebFront)" "consumer instructions") +_require("${readme}" "cmake -S . -B build -DCMAKE_BUILD_TYPE=Release\ncmake --build build --parallel 2" "Life initial build") +foreach(line "app.cppFunction(\"life.step\", &webfront::demo::nextLife);" "app.bootstrap(\"developer\");" "app.show();") + _require("${readme}" "${line}" "Life bootstrap snippet") + _require("${life}" "${line}" "compiled Life bootstrap") +endforeach() +foreach(line "#include " "Grid nextLife(const Grid& cells)" "app.cppFunction(\"life.step\", &nextLife);") + _require("${readme}" "${line}" "self-contained introductory Life application") +endforeach() +_require("${readme}" "webfront::NativeAppWithAssets app;" "offline application snippet") +_require("${embedded}" "webfront::NativeAppWithAssets app;" "compiled offline application") +foreach(target HelloWorld WebFrontLifeConsole WebFrontLifeDeveloper WebFrontLifeEmbedded) + _require("${examples}" "add_executable(${target} " "compiled example stage") + if(NOT target STREQUAL "HelloWorld") + _require("${readme}" "${target}" "documented Life stage") + endif() +endforeach() +string(REGEX MATCHALL "add_executable\\(" targets "${examples}") +list(LENGTH targets target_count) +if(NOT target_count EQUAL 4) + list(APPEND failures "Only Hello World and the three Life stages should be built") +endif() +foreach(command "wf create life" "wf install react@19.3.1 react-dom@19.3.1" "wf preview ui/main.tsx" "wf embed ui/main.tsx --output generated/LifeUI.hpp") + _require("${readme}" "${command}" "developer-terminal walkthrough") +endforeach() +_require("${readme}" "-DWEBFRONT_LIFE_ASSETS=\"$PWD/life-project/generated/LifeUI.hpp\"" "generated-header build") +_require("${readme}" "src=\"docs/images/life-bootstrap.gif\" width=\"560\"" "early Life animation") +foreach(path examples/hello-world/HelloWorld.cpp examples/life/Life.hpp examples/life/ui/main.tsx docs/images/life-preview.jpg docs/images/life-bootstrap.gif) + if(NOT EXISTS "${ROOT}/${path}") + list(APPEND failures "missing walkthrough asset ${path}") + endif() +endforeach() +# Option declarations stay opt-in and their plain help is documented in the frontend reference. include("${ROOT}/cmake/Frontends.cmake") foreach(name IN LISTS WEBFRONT_FRONTEND_REGISTRY) set(option "${WEBFRONT_FRONTEND_${name}_OPTION}") @@ -47,6 +84,7 @@ foreach(name IN LISTS WEBFRONT_FRONTEND_REGISTRY) endif() endforeach() webfront_declare_frontend_options() +string(REPLACE "`" "" frontends "${frontends}") foreach(name IN LISTS WEBFRONT_FRONTEND_REGISTRY) set(option "${WEBFRONT_FRONTEND_${name}_OPTION}") if(option STREQUAL "") @@ -54,82 +92,17 @@ foreach(name IN LISTS WEBFRONT_FRONTEND_REGISTRY) endif() get_property(default CACHE ${option} PROPERTY VALUE) get_property(description CACHE ${option} PROPERTY HELPSTRING) - if(NOT default STREQUAL "OFF") - list(APPEND failures "${option} must default to OFF, got '${default}'") - endif() - if(description MATCHES "`") - list(APPEND failures "${option} help must not contain Markdown backticks") + if(NOT default STREQUAL "OFF" OR description MATCHES "`") + list(APPEND failures "${option} must default to OFF with plain help text") endif() - _require("${readme_options}" "| ${option} | ${default} | ${description} |" "README ${option} default and description") + _require("${frontends}" "| ${option} | ${default} | ${description} |" "frontend option reference") endforeach() -# Option-free quick start: exact commands, in order. -_require("${readme}" "mkdir build\ncd build\ncmake ..\ncmake --build .\n" "README option-free build") -_require("${readme}" "./src/HelloWorld" "README Hello launch command") -_require("${readme}" "./src/WebFrontGreeter" "README greeter launch command") -_require("${src_cmake}" "add_executable(HelloWorld HelloWorld.cpp)" "examples CMake") -_require("${src_cmake}" "add_executable(WebFrontGreeter Greeter.cpp)" "examples CMake") -_require("${src_cmake}" "/greeter" "greeter asset copy") -_require("${root_cmake}" "option(ENABLE_TESTING \"Enable Test Builds\" OFF)" "testing default") -_require("${root_cmake}" "add_library(WebFront::WebFront ALIAS WebFront)" "namespaced alias") -_require("${readme}" "target_link_libraries(MyApp PRIVATE WebFront::WebFront)" "README subproject example") - -# The minimal program shown in the README is the real source. -foreach(line "#include " "using App = webfront::WebFront;" "App app;" "app.show();") - _require("${readme}" "${line}" "README Hello snippet") - _require("${hello}" "${line}" "HelloWorld.cpp") -endforeach() -string(REGEX MATCHALL "[^\n]*(filesystem|log|cppFunction|onUIStarted|port|\"index)[^\n]*" noisy "${hello}") -foreach(line IN LISTS noisy) - if(NOT line MATCHES "^ *//") - list(APPEND failures "HelloWorld.cpp must stay minimal, found: ${line}") - endif() -endforeach() -_require("${hello}" "// using App = webfront::WebFrontWithFrontend;" "HelloWorld.cpp CEF hint") -foreach(text hello greeter readme) - _require("${${text}}" "using App = webfront::WebFrontWithFrontend;" "${text} WebView2 alias") -endforeach() -foreach(text hello greeter readme) - _require("${${text}}" "using App = webfront::WebFrontWithFrontend;" "${text} WKWebView alias") -endforeach() -_require("${readme}" "-DWEBFRONT_EMBED_WKWEBVIEW=ON" "README WKWebView configure") -_require("${ci}" "-DWEBFRONT_WEBTEST_FRONTEND=WKWebView" "CI WKWebView browser selection") -_require("${readme}" "-DWEBFRONT_EMBED_WEBVIEW2=ON" "README WebView2 configure") -_require("${readme}" "using App = webfront::WebFrontWithFrontend;" "README CEF alias") -_require("${readme}" "cmake -DWEBFRONT_EMBED_CEF=ON .." "README CEF configure") - -# The runnable coroutine snippet must stay identical to the compiled example. -_require("${readme}" "${await_example}" "README coroutine example") -_require("${src_cmake}" "add_executable(WebFrontAwaitBrowser AwaitBrowser.cpp)" "coroutine example target") -_require("${readme}" "./src/WebFrontAwaitBrowser" "README coroutine example launch") - -# Greeter snippets. -foreach(line "App app{webfront::WebFrontConfig{.documentRoot = \"src/greeter\"}};" "app.cppFunction(\"greet\", [](std::string name) {" "app.show();") - _require("${readme}" "${line}" "README greeter C++ snippet") - _require("${greeter}" "${line}" "Greeter.cpp") +foreach(text readme agents ci) + _require("${${text}}" "-DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON" "${text} baseline configuration") endforeach() -foreach(line "await webFront.ready;" "const greet = webFront.cppFunction(\"greet\");") - _require("${readme}" "${line}" "README greeter JS snippet") - _require("${greeter_js}" "${line}" "greeter.mjs") -endforeach() -foreach(asset index.html greeter.mjs) - if(NOT EXISTS "${ROOT}/src/greeter/${asset}") - list(APPEND failures "missing greeter asset ${asset}") - endif() -endforeach() - -# The screenshot is committed and referenced. -_require("${readme}" "](docs/images/hello-world.png)" "README screenshot") -if(NOT EXISTS "${ROOT}/docs/images/hello-world.png") - list(APPEND failures "docs/images/hello-world.png is missing") -endif() - -# Documented contributor commands equal the CI/agent commands. foreach(text readme agents) - _require("${${text}}" "-DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON" "${text} CEF-off test command") - _require("${${text}}" "ctest --test-dir build --output-on-failure" "${text} ctest command") + _require("${${text}}" "ctest --test-dir build --output-on-failure" "${text} test command") endforeach() -_require("${ci}" "-DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON" "CI configure command") - if(failures) list(JOIN failures "\n " joined) message(FATAL_ERROR "Newcomer documentation drifted from the code:\n ${joined}") diff --git a/cmake/WebFrontAssets.cmake b/cmake/WebFrontAssets.cmake index 2bf0b85d..53623f0b 100644 --- a/cmake/WebFrontAssets.cmake +++ b/cmake/WebFrontAssets.cmake @@ -34,33 +34,33 @@ function(webfront_add_embedded_assets) cmake_path(NORMAL_PATH root) add_custom_target(webfront-embedded-assets COMMENT "Regenerating embedded browser bridge and fallback-page assets") _webfront_add_embedded_text_asset( - "${root}/src/WebFront.js" "${root}/include/system/WebFrontJsData.hpp" + "${root}/assets/WebFront.js" "${root}/include/system/WebFrontJsData.hpp" WebFrontJsData WebFrontJsAssetsFresh) _webfront_add_embedded_text_asset( - "${root}/src/fallback/index.html" "${root}/include/system/FallbackIndexHtmlData.hpp" + "${root}/assets/fallback/index.html" "${root}/include/system/FallbackIndexHtmlData.hpp" FallbackIndexHtmlData FallbackIndexHtmlAssetFresh) _webfront_add_embedded_text_asset( - "${root}/src/fallback/webfront-fallback.mjs" "${root}/include/system/FallbackModuleData.hpp" + "${root}/assets/fallback/webfront-fallback.mjs" "${root}/include/system/FallbackModuleData.hpp" FallbackModuleData FallbackModuleAssetFresh) _webfront_add_embedded_text_asset( - "${root}/src/developer/index.html" "${root}/include/system/DeveloperIndexHtmlData.hpp" + "${root}/assets/developer/index.html" "${root}/include/system/DeveloperIndexHtmlData.hpp" DeveloperIndexHtmlData DeveloperIndexHtmlAssetFresh) _webfront_add_embedded_text_asset( - "${root}/src/developer/bootstrap.bundle.mjs" "${root}/include/system/DeveloperBootstrapData.hpp" + "${root}/assets/developer/bootstrap.bundle.mjs" "${root}/include/system/DeveloperBootstrapData.hpp" DeveloperBootstrapData DeveloperBootstrapAssetFresh) # Terminal component (include/system/TerminalFS.hpp). xterm.js files are vendored verbatim in # third_party/xterm (see its VERSION file); refresh them with cmake/UpdateXterm.cmake. _webfront_add_embedded_text_asset( - "${root}/src/components/terminal/index.html" "${root}/include/system/TerminalIndexHtmlData.hpp" + "${root}/assets/components/terminal/index.html" "${root}/include/system/TerminalIndexHtmlData.hpp" TerminalIndexHtmlData TerminalIndexHtmlAssetFresh) _webfront_add_embedded_text_asset( - "${root}/src/components/terminal/terminal.mjs" "${root}/include/system/TerminalModuleData.hpp" + "${root}/assets/components/terminal/terminal.mjs" "${root}/include/system/TerminalModuleData.hpp" TerminalModuleData TerminalModuleAssetFresh) # Browser side of the wf tool manager (include/system/ToolManagerFS.hpp). _webfront_add_embedded_text_asset( - "${root}/src/components/tools/wf.mjs" "${root}/include/system/ToolManagerModuleData.hpp" + "${root}/assets/components/tools/wf.mjs" "${root}/include/system/ToolManagerModuleData.hpp" ToolManagerModuleData ToolManagerModuleAssetFresh) _webfront_add_embedded_text_asset( "${root}/third_party/xterm/xterm.mjs" "${root}/include/system/XtermModuleData.hpp" diff --git a/codecov.yml b/codecov.yml index 4b4ae77f..cb759f37 100644 --- a/codecov.yml +++ b/codecov.yml @@ -9,4 +9,4 @@ coverage: target: 95% ignore: - "webtest/**" - - "src/**" + - "examples/**" diff --git a/docs/ASYNC_EXECUTION.md b/docs/ASYNC_EXECUTION.md index 30bc65c9..518b685d 100644 --- a/docs/ASYNC_EXECUTION.md +++ b/docs/ASYNC_EXECUTION.md @@ -61,8 +61,14 @@ auto result = co_await ui.jsFunctionSender("Math.sqrt")(81); `webfront::Task` is the public coroutine type. `app.spawn(task)` or `ui.spawn(task)` starts it on the server context, owns it until completion and cancels it during application shutdown. No scheduler, scope or context is -needed. The complete runnable example is [AwaitBrowser.cpp](../src/AwaitBrowser.cpp), -compiled as `WebFrontAwaitBrowser` and reproduced in the README. +needed. For example: + +```cpp +webfront::Task showSquareRoot(webfront::UI ui) { + auto result = co_await ui.jsFunctionSender("Math.sqrt")(81); + co_await ui.jsFunctionSender("console.log")("sqrt(81) =", result); +} +``` ```cpp auto handle = app.spawn(showSquareRoot(ui)); diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index ab5283c0..0f935183 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -10,6 +10,12 @@ This is an experimental, explicit development facility. The downloaded environme the application's bridge authority and may read/write the selected project. It exposes no shell. Do not ship developer mode as the distribution configuration. +The 0.4 presentation update prepares developer distribution **0.4.0** with the revised Life text. +It is not published as part of the repository cleanup. Before releasing this branch, publish the +prepared archives using [the package release procedure](../tools/developer/PUBLISHING.md). +For local review, provision the generated archive as described below and pass its URL/integrity +to `WebFrontLifeDeveloper`. Existing published versions remain unchanged. + ## Minimal C++ application Enable the platform's native frontend in CMake: `WEBFRONT_EMBED_WKWEBVIEW=ON` on macOS, @@ -41,7 +47,7 @@ native tests from empty working directories, with developer callbacks absent. Pa HTTP 200, CORS `*` and the pinned archive bytes. These checks supplement offline CTest fixtures. The default configuration is generated in `include/system/DeveloperReleaseData.hpp` and targets -`https://ambroise-leclerc.github.io/WebFront/developer/0.3.1/environment.tgz`. It pins one version and +`https://ambroise-leclerc.github.io/WebFront/developer/0.4.0/environment.tgz`. This version is prepared but not yet published; use local provisioning for now. The configuration pins one version and its SHA-512 rather than resolving a mutable `latest` channel. An explicit `DeveloperBootstrapOptions{.environment = url, .integrity = trustedHash}` still selects a different HTTPS/CORS repository or a same-origin test fixture. Users install neither npm nor Node.js. @@ -60,19 +66,23 @@ environment is not silently substituted. ## The Game of Life walkthrough -`src/Life.hpp` is a small C++23 B3/S23 simulation on a `std::bitset<1024>`. +`examples/life/Life.hpp` is a small C++23 B3/S23 simulation on a `std::bitset<1024>`. Each generation reads the old grid and creates a new one; the 32 × 32 world wraps on both axes. The core needs no React, server, thread, timer or graphics dependency. `nextLife` is registered directly with its `const LifeGrid&` argument and bitset result. React stores and exchanges a 128-byte `Uint8Array`, with cell `i` in bit `i % 8` of byte `i / 8`. The bridge validates the exact unsigned-byte type and length. -`src/LifeConsole.cpp` runs it without WebFront; build and run `WebFrontLifeConsole` to start +`examples/life/LifeConsole.cpp` runs it without WebFront; build and run `WebFrontLifeConsole` to start with a plain console application. -`src/LifeDeveloper.cpp` adds the native window and downloaded developer bootstrap. Configure -`build-native` with the native frontend option above, then start with an empty project directory: +`examples/life/LifeDeveloper.cpp` adds the native window and downloaded developer bootstrap. Configure +`build-native` with the native frontend option above, then [prepare the local archive](#environment-distribution-and-offline-tests-maintainers) and start with a fresh project directory: ```sh -./build-native/src/WebFrontLifeDeveloper /path/to/life-project +mkdir -p life-project/.webfront/developer/preview/provision +cp build-developer-environment/*.tgz life-project/.webfront/developer/preview/provision/ +integrity=$(node -p "require('./build-developer-environment/provision.json').integrity") +./build-native/examples/WebFrontLifeDeveloper "$PWD/life-project" \ + /webfront/developer/preview/provision/environment.tgz "$integrity" ``` Optional extra arguments ` ` override the pinned default. @@ -101,7 +111,7 @@ Canvas rendering has an accessible description; patterns and simulation controls keyboard. Individual canvas cells are pointer-editable, without keyboard cell navigation. No fonts, images, 3D library or additional UI framework are downloaded. -![The native Game of Life demo at generation 34](images/life-preview.png) +![The native Game of Life demo at generation 26](images/life-preview.jpg) `wf embed` builds JS/CSS/resources, creates an HTML entry page, preserves dependency notices and writes a header-only `webfront::fs::LifeUI` provider using deterministic gzip. The filename stem @@ -125,11 +135,9 @@ Reconfigure the native build with `WebFrontLifeEmbedded` and run it. Recompilation is explicit. The resulting binary needs neither project sources, downloaded cache nor network. -The original PI example remains available: `WebFrontPiDeveloper`, `wf create pi`, -`wf embed ui/main.tsx --output generated/PiUI.hpp`, and -`-DWEBFRONT_PI_ASSETS=/absolute/path/to/generated/PiUI.hpp` / `WebFrontPiEmbedded`. -Use a separate project directory for each starter. Existing embedded React/Babel providers -remain supported. +The PI starter remains available through `wf create pi` for existing projects and regression +coverage. Its sources are maintained under `tools/developer/starters/pi/`; the public C++ +examples are limited to Hello World and Life. Existing embedded React/Babel providers remain supported. ## Dependencies, storage and limitations @@ -180,10 +188,19 @@ it writes only to the output directory. The archives have the package identifier `@webfront/life-starter` and `@webfront/pi-starter`. They are distributed as static GitHub Pages downloads; no npm publication or scope ownership is required. Node/npm is only used by maintainers to build them. -To try the local archive without an HTTPS server, copy `environment.tgz` to the project's -`.webfront/developer/preview/provision/environment.tgz` and pass -`/webfront/developer/preview/provision/environment.tgz` as its URL. The preview command later replaces -that directory, but the verified archive is already cached independently for subsequent launches. +To try the local archive without an HTTPS server, after building the packages above: + +```sh +mkdir -p life-project/.webfront/developer/preview/provision +cp build-developer-environment/*.tgz life-project/.webfront/developer/preview/provision/ +integrity=$(node -p "require('./build-developer-environment/provision.json').integrity") +./build-native/examples/WebFrontLifeDeveloper "$PWD/life-project" \ + /webfront/developer/preview/provision/environment.tgz "$integrity" +``` + +The preview command later replaces that directory, but the verified archive is already cached +independently for subsequent launches. These are maintainer provisioning commands; the application's +terminal still installs and builds browser dependencies without a local Node/npm installation. Fixture provisioning packs the pinned React, React DOM and scheduler sources from the maintainer's npm installation into a fake local registry. No CTest case downloads from the public registry. diff --git a/docs/EMBEDDED_ASSETS.md b/docs/EMBEDDED_ASSETS.md index 83f44dff..23f64bf5 100644 --- a/docs/EMBEDDED_ASSETS.md +++ b/docs/EMBEDDED_ASSETS.md @@ -17,7 +17,7 @@ React 19 removed UMD builds and requires the automatic JSX transform ([upstream upgrade guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide)). `tools/assets/update.mjs` bundles React, React DOM and `react/jsx-runtime` together as `/react@19.3.1/runtime.mjs`. This keeps hooks, DOM rendering and JSX on one React instance. -The import map in `src/react.html` maps `react`, `react-dom/client` and `react/jsx-runtime` +The import map in `webtest/fixtures/react.html` maps `react`, `react-dom/client` and `react/jsx-runtime` to that runtime. Babel's custom `webfront-react` preset uses `runtime: "automatic"` and emits a native module. The JSX remains editable in the HTML file, without a consumer build step. Babel is served at `/babel-standalone@8.0.7/babel.min.js`. @@ -83,6 +83,8 @@ fflate and esbuild are maintenance tools; fflate is not embedded in C++ applicat ## Size measurements +The measurements below predate the 0.4 example cleanup; removed target names identify historical binaries. Current build commands use the retained examples. + The measurements below predate the integration of #274 and isolate the asset refresh from its HTTP decoder changes. They describe the original #284 implementation, not current binary sizes after rebasing onto the identity-fallback work. @@ -98,7 +100,7 @@ Executable sizes include Mach-O alignment and the existing test hardening option cmake -S . -B build-measure -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_COMPILER=/path/to/clang++ -DWEBFRONT_EMBED_CEF=OFF \ -DENABLE_TESTING=ON -DENABLE_CACHE=OFF -cmake --build build-measure --target HelloWorld WebFrontGreeter WebFrontApp WebFrontTerminal WebFrontTools webtest --parallel 4 +cmake --build build-measure --target HelloWorld WebFrontLifeDeveloper webtest --parallel 2 # On macOS with standalone LLVM, also pass -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path). # Compare file sizes, not CEF frameworks or other external engine resources. ``` diff --git a/docs/FRONTENDS.md b/docs/FRONTENDS.md index c189ced4..a609bd3e 100644 --- a/docs/FRONTENDS.md +++ b/docs/FRONTENDS.md @@ -1,6 +1,6 @@ # Frontends -[Back to the README](../README.md#choose-how-your-interface-opens) +[Back to the README](../README.md#use-webfront-in-your-project) A frontend decides how the interface is displayed: the system browser (`DefaultBrowserFrontend`, the default), an embedded Chromium window (`CEFFrontend`) or an embedded native web view (`WebView2Frontend` on Windows, `WKWebViewFrontend` on macOS, `WebKitGTKFrontend` on Linux). The application code and interface assets do not change when the frontend does. Platform-specific notes live next to each frontend, for example [WebView2](WEBVIEW2.md) and [WKWebView](WKWEBVIEW.md). This page states the rules they all follow; the C++ concept is `frontend::FrontendType` in `include/frontend/Frontend.hpp`. @@ -45,7 +45,7 @@ initialization, frontend selection and unavailable-engine diagnostics. These tes | Field | Meaning | | --- | --- | | `OPTION` | Availability option named `WEBFRONT_EMBED_`, always defaulting to `OFF`. | -| `DESCRIPTION` | Plain-text CMake option help, checked against the README after removing Markdown code delimiters. | +| `DESCRIPTION` | Plain-text CMake option help, checked against the option table below after removing Markdown code delimiters. | | `PLATFORMS` | Supported CMake platform names. Enabling the option elsewhere fails before fetching dependencies. | | `SUPPORT` | Module loaded when the engine is enabled. Registration checks that its file exists. | | `SETUP` | Optional function configuring each application's target, including runtime deployment. | @@ -89,3 +89,15 @@ their own CTest timeouts. WKWebView adds native main-thread, Quit/closure, repeated-opening, initial HTTP failure, stalled-loading deadline and data-store/inspector/menu tests. See [WKWebView verification](WKWEBVIEW.md#unattended-verification). + +## Build options + +Enabling an engine makes its adapter available; select it explicitly in your application. +`webfront::NativeApp` chooses the native engine for the current platform. + +| Option | Default | Description | +| --- | --- | --- | +| `WEBFRONT_EMBED_WEBVIEW2` | OFF | Download the pinned WebView2 SDK and link its static loader (Windows only) | +| `WEBFRONT_EMBED_WKWEBVIEW` | OFF | Link the system Cocoa and WebKit frameworks for WKWebViewFrontend (macOS 13.3+ only) | +| `WEBFRONT_EMBED_WEBKITGTK` | OFF | Enable the system WebKitGTK 6.0 embedded frontend (Linux only) | +| `WEBFRONT_EMBED_CEF` | OFF | Download and link CEF so CEFFrontend is available (Windows, Linux and macOS only). Other platforms fail at configure time | diff --git a/docs/PROJECT_STATUS.md b/docs/PROJECT_STATUS.md index 53c02fc5..5a99cf73 100644 --- a/docs/PROJECT_STATUS.md +++ b/docs/PROJECT_STATUS.md @@ -1,5 +1,19 @@ # WebFront project status +## Repository presentation for 0.4 (2026-10-21) + +- Public examples now live in `examples/`: Hello World and the three stages of Game of Life. + Browser bridge/component/bootstrap sources live in `assets/`; the library remains header-only. + PI and Signal Studio resources required by regression tests remain fixtures, without public demo targets. +- The README starts with Hello World and a linked Life thumbnail, then walks through the native + bootstrap, dependency installation, preview and offline embedding. No library feature is added. +- Per-change CI combines unit tests and native browser coverage into three desktop jobs, with + npm, CPM and compiler caches. The Linux job uploads GCC coverage on every PR. Sanitizers, fuzzing, + both CEF compiler variants and optional mddlog qualification run weekly or manually. Superseded runs are cancelled. +- Developer distribution 0.4.0 is prepared locally for the revised Life text; publication is a separate release step. +- The dated entries below record earlier implementations and their original target names. + + Status snapshot: 2026-07-19. Optional mddlog integration note: 2026-10-02. Newcomer-first epic (#205) note: 2026-10-13. UI components note: 2026-10-14. Embedded dependency refresh: 2026-10-19. ## Packed bitsets (#289, 2026-10-20) @@ -247,21 +261,21 @@ See [WebKitGTK notes](WEBKITGTK.md). ## Newcomer-first workflow (epic #205) -- `webfront::WebFront app; app.show();` is a complete program (`src/HelloWorld.cpp`). With no document root WebFront serves an embedded "Hello, WebFront!" page whose status badge shows **connected** only after `webFront.ready` resolves (WebSocket handshake acknowledgement) and an error state if the initial connection fails. `ready` does not track later disconnects. -- `WebFrontGreeter` (`src/Greeter.cpp`, `src/greeter/`) uses an explicit development document root and a deduced `greet(std::string)` callback; the page awaits the returned Promise and shows success or errors via `textContent`. -- The option-free `cmake ..` / `cmake --build .` build downloads neither CEF nor Catch2 (`ENABLE_TESTING` and `WEBFRONT_EMBED_CEF` default to `OFF`) and builds the examples into `/src`. As a subproject only `WebFront::WebFront` is added: no examples, tests, warning flags, or global compiler settings leak into the parent. +- `webfront::WebFront app; app.show();` is a complete program (`examples/hello-world/HelloWorld.cpp`). With no document root WebFront serves an embedded "Hello, WebFront!" page whose status badge shows **connected** only after `webFront.ready` resolves (WebSocket handshake acknowledgement) and an error state if the initial connection fails. `ready` does not track later disconnects. +- The Life walkthrough (`examples/life/LifeDeveloper.cpp`, `examples/life/ui/`) registers the deduced `life.step` callback and awaits its Promise from React. The standalone Greeter was removed in 0.4. +- The option-free `cmake ..` / `cmake --build .` build downloads neither CEF nor Catch2 (`ENABLE_TESTING` and `WEBFRONT_EMBED_CEF` default to `OFF`) and builds the examples into `/examples`. As a subproject only `WebFront::WebFront` is added: no examples, tests, warning flags, or global compiler settings leak into the parent. - The CTest cases `NewcomerDocsMatchExamples` and `AddSubdirectoryConsumer` guard the documented commands, snippets and subproject integration. - Verified 2026-10-13 on Linux (Ubuntu 24.04, GCC 13.3, CMake 4.4.4): option-free build; CEF-off testing build with all CTest cases passing; Hello and Greeter pages served and driven in a real Chromium (connected badge, empty-input message, `Hello, Ada!`). **Not verified in that environment:** the CEF-enabled build and the Jasmine/Xvfb integration (the CEF download was blocked), Windows, macOS and Clang. - Limitation: a configured document root serves arbitrary local files and is a development convenience, not a production sandbox or packaging format. ## UI components: the terminal and the tool manager -- First opt-in UI component (#230), designed in [UI_COMPONENTS.md](UI_COMPONENTS.md): `webfront::Terminal` (`include/components/Terminal.hpp`) registers C++ commands behind an embedded xterm.js 6.0.0 terminal (`fs::TerminalFS`, served under `webfront/components/terminal/`; composed with `fs::DefaultFSWith<>`). Example: `WebFrontTerminal` (`src/Terminal.cpp`). The bridge protocol is unchanged. +- First opt-in UI component (#230), designed in [UI_COMPONENTS.md](UI_COMPONENTS.md): `webfront::Terminal` (`include/components/Terminal.hpp`) registers C++ commands behind an embedded xterm.js 6.0.0 terminal (`fs::TerminalFS`, served under `webfront/components/terminal/`; composed with `fs::DefaultFSWith<>`). The standalone terminal target was removed in 0.4; see the component API example in [UI_COMPONENTS.md](UI_COMPONENTS.md). The bridge protocol is unchanged. - Line editing, history and Tab completion run in the browser; C++ receives whole lines and returns the output as the Promise result. A command exception rejects the Promise and is printed as an error. Output is capped at 60000 bytes because bridge strings carry a 16-bit length. - Covered by Catch2 (`TerminalTests.cpp`, `TerminalFSTests.cpp`), five asset freshness CTest cases and Jasmine specs (`webtest/js/terminal-specs.mjs`) in the browser integration test. - Verified 2026-10-14 on Linux (GCC 16.1, Unix Makefiles generator): CEF-off build with all 100 CTest cases passing; the example driven in headless Chromium (commands, errors, quoting, completion, history, `help`, `clear`); and the Jasmine suite, terminal specs included, run in headless Chromium through a scratch copy of the runner that replaces `CEFFrontend`. A deliberately broken terminal spec made that run fail. **Not verified:** the CEF/Xvfb CTest itself, Windows, macOS and Clang. - Limitations: no output streaming, no cancellation, no per-browser sessions, and single-row line redraw (see the design note). -- The `wf` tool manager (#234, npm-hosted web tools installed during debugging): `webfront::ToolManager` (`include/components/ToolManager.hpp`) stores tools with `fs::ToolStore` under `.webfront/tools/`, records them in `webfront-tools.lock.json`, serves them with `fs::PackageFS` under `webfront/tools/` and runs `wf list`, `wf remove` and `wf help` in C++. `wf search`, `wf install` and `wf open` run in the page, in `wf.mjs` (`src/components/tools/`, served by `fs::ToolManagerFS`), a terminal extension module loaded through the new `Terminal::extension()`: it fetches the packument and tarball, checks the SHA-512 `dist.integrity` with `crypto.subtle`, gunzips with `DecompressionStream`, reads the ustar archive (pax and prefixed paths included) and sends the files in 256 KiB chunks through `webfront.pkg.*`, after refusing archives unpacking to more than 256 MiB. Ctrl+C interrupts it through the `signal` the terminal passes to browser commands. The registry is set by `ToolManagerOptions::registry`. Example: `WebFrontTools` (`src/Tools.cpp`). Covered by `ToolStoreTests.cpp`, `ToolManagerTests.cpp`, `TerminalTests.cpp` and the Jasmine specs `webtest/js/tools-specs.mjs`, which install a fixture package from a fake registry served by the test (`webtest/registry/`, regenerated by `make_fixture.py`) into a temporary directory. +- The `wf` tool manager (#234, npm-hosted web tools installed during debugging): `webfront::ToolManager` (`include/components/ToolManager.hpp`) stores tools with `fs::ToolStore` under `.webfront/tools/`, records them in `webfront-tools.lock.json`, serves them with `fs::PackageFS` under `webfront/tools/` and runs `wf list`, `wf remove` and `wf help` in C++. `wf search`, `wf install` and `wf open` run in the page, in `wf.mjs` (`assets/components/tools/`, served by `fs::ToolManagerFS`), a terminal extension module loaded through the new `Terminal::extension()`: it fetches the packument and tarball, checks the SHA-512 `dist.integrity` with `crypto.subtle`, gunzips with `DecompressionStream`, reads the ustar archive (pax and prefixed paths included) and sends the files in 256 KiB chunks through `webfront.pkg.*`, after refusing archives unpacking to more than 256 MiB. Ctrl+C interrupts it through the `signal` the terminal passes to browser commands. The registry is set by `ToolManagerOptions::registry`. The standalone tools target was removed in 0.4; the component remains documented in [UI_COMPONENTS.md](UI_COMPONENTS.md). Covered by `ToolStoreTests.cpp`, `ToolManagerTests.cpp`, `TerminalTests.cpp` and the Jasmine specs `webtest/js/tools-specs.mjs`, which install a fixture package from a fake registry served by the test (`webtest/registry/`, regenerated by `make_fixture.py`) into a temporary directory. - Verified 2026-10-15 on macOS (Apple clang, CEF off): all CTest cases pass except `AddSubdirectoryConsumer`, which fails locally because of the outdated libc++ headers of the Command Line Tools; the Jasmine suite, tools specs included, run in Chromium through a scratch copy of the runner that replaces `CEFFrontend` (one terminal spec, "reports an application without terminal functions", fails there as it does on develop, because that browser gave its unsized terminal a two-column width); `WebFrontTools` driven against registry.npmjs.org (`wf help`, `wf search`, `wf list`, `wf install left-pad` downloaded, verified and refused as not a tool). **Not verified locally:** the CEF/Xvfb CTest (Linux only; the macOS CEF build of `webtest` fails inside stdexec), Windows. - Limitations of the tool manager: no semver ranges (an exact version or a dist-tag), no dependencies (a tool must bundle what it uses), no progress bar beyond step messages, sequential chunk uploads, and the trust model of `npm install`. - Found while building it: the C++ encoder wrapped the 16-bit length of strings over 65535 bytes (#231, fixed: such strings now fail explicitly, see "Implemented baseline"); `MimeType::toString()` mapped `csv` to `text/css` (#232, fixed: a `static_assert` now ties the name table to the enum); with GCC 16.1 and the Ninja generator, CMake's module dependency scanning (`-fmodules-ts`) crashes the compiler inside stdexec, while Unix Makefiles builds work. @@ -291,9 +305,9 @@ The minimum demonstration milestone is deliberately narrower than the long-term - Catch2 covers `.mjs` MIME handling. - Jasmine native-module specs report their final status to C++. The executable verifies both bridge directions, asks JavaScript to close the CEF window, and returns nonzero on any failed condition. - The browser integration is a timeout-bounded CTest test for CEF-enabled Linux builds and runs under Xvfb in a focused CI job, built with GCC and with Clang. CEF's `NO_UNIQUE_ADDRESS`, `ALWAYS_INLINE` and `NOINLINE` macros break stdexec headers included after CEF's headers, which only Clang 19+ (and, by stdexec's configuration, MSVC) reveals (#243): `frontend/CEF.hpp` includes `networking/SenderHeaders.hpp`, which lists every stdnet and stdexec header WebFront uses, first, and the Catch2 case `CEFMacrosTests.cpp` compiles `WebFront.hpp` after those macros. Verified 2026-10-16 on Linux with Clang 22: the CEF build of `webtest` failed before the fix and `WebFrontBrowserIntegration` passes after it. Not verified: CEF with MSVC or Apple clang. -- `WEBFRONT_EMBED_CEF=ON` uses CEF 154.0.34 (Chromium 154.0.8037.98, package `ambroise-leclerc/CEF@154.0.34`). An existing CEF 137 build directory must be reconfigured from scratch. On Windows, `libEGL.dll`, `libGLESv2.dll`, `dxcompiler.dll`, `dxil.dll` and `vk_swiftshader_icd.json` are copied only when the distribution ships them (CEF 154 has no ANGLE DLLs, #249). Verified 2026-10-16 on Linux (GCC 16.1, Unix Makefiles): the CEF build with all 138 CTest cases passing, `WebFrontBrowserIntegration` included, and the CEF-off build with all 137; with Clang 22, the CEF build of `webtest` and `WebFrontBrowserIntegration`. **Not verified:** CEF 154 on Windows and macOS (the macOS ARM64 framework requires macOS 13.0+). A parallel build of every example fails intermittently because their post-build steps copy `locales/` into the same `src/` directory at once. +- `WEBFRONT_EMBED_CEF=ON` uses CEF 154.0.34 (Chromium 154.0.8037.98, package `ambroise-leclerc/CEF@154.0.34`). An existing CEF 137 build directory must be reconfigured from scratch. On Windows, `libEGL.dll`, `libGLESv2.dll`, `dxcompiler.dll`, `dxil.dll` and `vk_swiftshader_icd.json` are copied only when the distribution ships them (CEF 154 has no ANGLE DLLs, #249). Verified 2026-10-16 on Linux (GCC 16.1, Unix Makefiles): the CEF build with all 138 CTest cases passing, `WebFrontBrowserIntegration` included, and the CEF-off build with all 137; with Clang 22, the CEF build of `webtest` and `WebFrontBrowserIntegration`. **Not verified:** CEF 154 on Windows and macOS (the macOS ARM64 framework requires macOS 13.0+). The earlier multi-example build intermittently raced while copying CEF `locales/` to its shared output directory. The retained examples now use `/examples`. - The bridge carries all JavaScript numeric typed-array variants in both directions. C++ `std::vector`, `std::array`, and `std::span` values use the matching typed-array encoding, while decoded parameters own their storage. -- `src/WebFront.js` is the readable browser bridge source. CMake deterministically regenerates the embedded `include/system/WebFrontJsData.hpp` asset and CTest rejects a stale generated copy. +- `assets/WebFront.js` is the readable browser bridge source. CMake deterministically regenerates the embedded `include/system/WebFrontJsData.hpp` asset and CTest rejects a stale generated copy. - Encoded HTTP assets (#274): accepted gzip is served unchanged; otherwise the server decodes gzip to identity with the decoded length, no `Content-Encoding` and `Vary: Accept-Encoding`. The default decoded-byte budget is 4 MiB and applications can override it through their buffer @@ -303,7 +317,7 @@ The minimum demonstration milestone is deliberately narrower than the long-term Regression tests and gzip/HTTP fuzzers cover decoding and encoding preferences. Verified 2026-10-19 on Linux for #274: the CEF-off build/CTest suite, CEF/Xvfb integration and WebKitGTK integration passed. The macOS results above describe earlier platform validation. -- First-party bridge/component text assets are embedded **verbatim rather than compressed**, so `HTTPServer` serves them without a `Content-Encoding` header. Deflate streams are not reproducible across the zlib builds on our macOS, Linux, and Windows runners, so a pre-compressed blob could not be verified by the staleness check. Restoring compression — either a reproducible build-time gzip or on-the-fly compression keyed on `Accept-Encoding` — is tracked as a follow-up. The fallback HTML and module have readable sources under `src/fallback/`; `favicon.ico` uses gzip. Legacy third-party Jasmine/React/Babel assets now use gzip for WKWebView local-HTTP compatibility (#258); their decoded payloads are unchanged. Regenerate the text headers with `cmake --build build --target webfront-embedded-assets`. Sources and generated headers use LF on every platform so the CTest freshness checks compare identical bytes. +- First-party bridge/component text assets are embedded **verbatim rather than compressed**, so `HTTPServer` serves them without a `Content-Encoding` header. Deflate streams are not reproducible across the zlib builds on our macOS, Linux, and Windows runners, so a pre-compressed blob could not be verified by the staleness check. Restoring compression — either a reproducible build-time gzip or on-the-fly compression keyed on `Accept-Encoding` — is tracked as a follow-up. The fallback HTML and module have readable sources under `assets/fallback/`; `favicon.ico` uses gzip. Legacy third-party Jasmine/React/Babel assets now use gzip for WKWebView local-HTTP compatibility (#258); their decoded payloads are unchanged. Regenerate the text headers with `cmake --build build --target webfront-embedded-assets`. Sources and generated headers use LF on every platform so the CTest freshness checks compare identical bytes. - The fallback page awaits `webFront.ready` to display the initial bridge connection result. This promise resolves after the handshake acknowledgement and rejects if the initial connection fails or closes; it does not track later disconnects. Jasmine exercises failure against a test-owned HTTP server on an OS-assigned loopback port that rejects WebSocket upgrades, including the case where the application never consumes `ready`. - WebSocket writes own their payload buffers until asynchronous completion and are serialized per connection. - The HTTP server looks files up by the request path without its query string (`/app.js?v=2` serves `app.js`); the path is cut at the first `?` before percent-decoding, so an encoded `%3F` stays part of the file name, and the `..` check applies to the decoded path only. The query is not passed to filesystems. diff --git a/docs/UI_COMPONENTS.md b/docs/UI_COMPONENTS.md index aa65ee56..05a73d08 100644 --- a/docs/UI_COMPONENTS.md +++ b/docs/UI_COMPONENTS.md @@ -14,8 +14,8 @@ A component has four parts. | Part | Rule | Terminal | | --- | --- | --- | -| Assets | An embedded `fs::Provider` serving under the reserved prefix `webfront/components//`, so it never collides with a development document root or the application's own pages. Readable sources live in `src/components//`, third-party code in `third_party/`, and generated headers are checked in and kept fresh by CTest, like `WebFront.js`. | `fs::TerminalFS` (`include/system/TerminalFS.hpp`) | -| Browser module | A native ES module exporting `mount(element, options)`. It depends only on the global `webFront` bridge and its own assets (relative imports), and waits for `webFront.ready`. | `src/components/terminal/terminal.mjs` | +| Assets | An embedded `fs::Provider` serving under the reserved prefix `webfront/components//`, so it never collides with a development document root or the application's own pages. Readable sources live in `assets/components//`, third-party code in `third_party/`, and generated headers are checked in and kept fresh by CTest, like `WebFront.js`. | `fs::TerminalFS` (`include/system/TerminalFS.hpp`) | +| Browser module | A native ES module exporting `mount(element, options)`. It depends only on the global `webFront` bridge and its own assets (relative imports), and waits for `webFront.ready`. | `assets/components/terminal/terminal.mjs` | | C++ façade | A header under `include/components/` that registers its bridge functions under `webfront..`. `BasicWF::cppFunction` ignores a second registration of the same name, so the prefix is what keeps components and applications apart. | `webfront::Terminal` (`include/components/Terminal.hpp`) | | Wire format | Only the existing bridge types: scalars, strings (at most 65535 bytes), tuples and numeric typed arrays. Lists of words cross as `"\n"`-separated strings. A component never changes `Messages.hpp` or `WebFront.js`. | `run(line) -> output`, `complete(line) -> candidates` | @@ -46,7 +46,7 @@ int main() { } ``` -`src/Terminal.cpp` (target `WebFrontTerminal`) is the complete example. +The snippet above shows the standalone component API. The [Life walkthrough](../README.md#game-of-life-from-console-to-native-application) demonstrates the downloaded developer terminal. - **Rendering:** [xterm.js](https://xtermjs.org/) 6.0.0 and its fit addon 0.11.0 (MIT; the terminal used by VS Code, Tabby and Hyper), vendored verbatim in `third_party/xterm/` and embedded as reproducible gzip (95,272 bytes including word padding). @@ -177,7 +177,7 @@ header-only C++ library. ### Browser side (implemented) -`src/components/tools/wf.mjs` is served by `fs::ToolManagerFS` at +`assets/components/tools/wf.mjs` is served by `fs::ToolManagerFS` at `webfront/components/tools/wf.mjs` and added to the terminal by `ToolManager`. Besides the `commands` it exports `search`, `install`, `installed`, `open`, `readTar`, `gunzip`, `verifyIntegrity` and `parseSpec`, so other pages can use them. diff --git a/docs/WEBKITGTK.md b/docs/WEBKITGTK.md index 96d22a60..d320b34c 100644 --- a/docs/WEBKITGTK.md +++ b/docs/WEBKITGTK.md @@ -23,7 +23,7 @@ Install development packages before configuring: ```bash cmake -S . -B build-webkitgtk -DCMAKE_BUILD_TYPE=Release \ -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WEBKITGTK=ON -DENABLE_TESTING=ON \ - -DWEBFRONT_DEMO_FRONTEND=WebKitGTK -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK + -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK cmake --build build-webkitgtk --parallel 2 ctest --test-dir build-webkitgtk -L web-integration --output-on-failure --no-tests=error ``` diff --git a/docs/WKWEBVIEW.md b/docs/WKWEBVIEW.md index 3d4886fc..33e620f3 100644 --- a/docs/WKWEBVIEW.md +++ b/docs/WKWEBVIEW.md @@ -3,15 +3,20 @@ `WKWebViewFrontend` opens a native AppKit window with the WebKit engine supplied by macOS. It is optional and never changes `webfront::WebFront`'s system-browser default. +For this unpublished 0.4 branch, first [build the local developer archive](DEVELOPER_ENVIRONMENT.md#environment-distribution-and-offline-tests-maintainers), then run from the repository root: + ```bash cmake -S . -B build-wkwebview -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WKWEBVIEW=ON \ - -DWEBFRONT_DEMO_FRONTEND=WKWebView -cmake --build build-wkwebview --parallel -./build-wkwebview/src/WebFrontApp + -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WKWEBVIEW=ON +cmake --build build-wkwebview --target WebFrontLifeDeveloper --parallel 2 +mkdir -p life-project/.webfront/developer/preview/provision +cp build-developer-environment/*.tgz life-project/.webfront/developer/preview/provision/ +integrity=$(node -p "require('./build-developer-environment/provision.json').integrity") +./build-wkwebview/examples/WebFrontLifeDeveloper "$PWD/life-project" \ + /webfront/developer/preview/provision/environment.tgz "$integrity" ``` -For HelloWorld, Greeter or your application, select the adapter in C++: +For HelloWorld or your application, select the adapter in C++: ```cpp #include diff --git a/docs/adr/ADR-003-protocole-binaire-et-bornes.md b/docs/adr/ADR-003-protocole-binaire-et-bornes.md index 7f4948d3..e058cbdd 100644 --- a/docs/adr/ADR-003-protocole-binaire-et-bornes.md +++ b/docs/adr/ADR-003-protocole-binaire-et-bornes.md @@ -31,6 +31,8 @@ arguments et corrompu les messages. ## Décision Que soit préservé le protocole binaire de `weblink/Messages.hpp` et de la source `src/WebFront.js`. + +Note de renommage (0.4) : la source JavaScript est désormais `assets/WebFront.js` ; ce déplacement ne modifie pas le protocole décrit ici. Les messages d’appel et de retour portent des identifiants de corrélation sur 16 bits. Les types pris en charge sont les scalaires, chaînes, tuples, tableaux numériques typés et `std::bitset` ; les objets JavaScript arbitraires et objets DOM ne traversent pas automatiquement le pont. @@ -88,7 +90,7 @@ refusé dès l’en-tête, fragments compris. Les trames de contrôle ont leur p ## Sources et vérification -- [Codec C++](../../include/weblink/Messages.hpp), [codec JS](../../src/WebFront.js), +- [Codec C++](../../include/weblink/Messages.hpp), [codec JS](../../assets/WebFront.js), [politique de buffers](../../include/http/BuffersPolicy.hpp). - Tests : [MessagesTests](../../test/MessagesTests.cpp), [WebSocketTests](../../test/WebSocketTests.cpp), [spécifications navigateur](../../webtest/js/webfront-specs.mjs). diff --git a/docs/adr/ADR-006-taches-structurees-et-arret.md b/docs/adr/ADR-006-taches-structurees-et-arret.md index 03e25299..62b94bc1 100644 --- a/docs/adr/ADR-006-taches-structurees-et-arret.md +++ b/docs/adr/ADR-006-taches-structurees-et-arret.md @@ -76,4 +76,4 @@ prévaut entre résultat, arrêt et déconnexion. - [Contrat détaillé](../ASYNC_EXECUTION.md), [TaskScope](../../include/networking/Tasks.hpp). - Tests : [StructuredShutdownTests](../../test/StructuredShutdownTests.cpp), [ApplicationTaskTests](../../test/ApplicationTaskTests.cpp), [JsFunctionSenderTests](../../test/JsFunctionSenderTests.cpp). -- Exemple compilé : [AwaitBrowser.cpp](../../src/AwaitBrowser.cpp). +- Exemple compilé : [AwaitBrowser.cpp (historique 0.3)](https://github.com/ambroise-leclerc/WebFront/blob/30665cab6e1d68636ef160d8c2f34bd29bff601f/src/AwaitBrowser.cpp). diff --git a/docs/adr/README.md b/docs/adr/README.md index 8ecdc981..17978706 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -106,3 +106,9 @@ Keep previous rows and update the current version in the index. may extend an existing ADR’s history without erasing its previous state. - A future possibility mentioned here is not an accepted decision: general DOM abstractions, tool isolation, response deadlines and a decoding cache require their own decisions. + +## Chemins depuis la version 0.4 + +Les exemples publics résident dans `examples/` et les ressources web lisibles dans `assets/`. +Les mentions de `src/` dans les décisions précédentes décrivent l’ancienne organisation ; elles ne +changent pas les contrats. Les démonstrations supprimées restent consultables dans l’historique Git. diff --git a/docs/images/life-bootstrap.gif b/docs/images/life-bootstrap.gif new file mode 100644 index 00000000..5f232a2e Binary files /dev/null and b/docs/images/life-bootstrap.gif differ diff --git a/docs/images/life-generations.webp b/docs/images/life-generations.webp new file mode 100644 index 00000000..5db79a52 Binary files /dev/null and b/docs/images/life-generations.webp differ diff --git a/docs/images/life-preview.jpg b/docs/images/life-preview.jpg new file mode 100644 index 00000000..19fcd766 Binary files /dev/null and b/docs/images/life-preview.jpg differ diff --git a/docs/images/life-preview.png b/docs/images/life-preview.png deleted file mode 100644 index a110ebb1..00000000 Binary files a/docs/images/life-preview.png and /dev/null differ diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..4c6b442d --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,25 @@ +# Only two examples: the minimal application and the successive Game of Life stages. +include(Frontends) + +add_executable(HelloWorld hello-world/HelloWorld.cpp) +target_link_libraries(HelloWorld PRIVATE WebFront WebFront_warnings WebFront_options) +webfront_setup_frontends_for_target(HelloWorld) + +# The simulation can be explored before adding a UI or enabling a native engine. +add_executable(WebFrontLifeConsole life/LifeConsole.cpp) +target_link_libraries(WebFrontLifeConsole PRIVATE WebFront_warnings WebFront_options) + +add_executable(WebFrontLifeDeveloper life/LifeDeveloper.cpp) +target_link_libraries(WebFrontLifeDeveloper PRIVATE WebFront WebFront_warnings WebFront_options) +webfront_setup_frontends_for_target(WebFrontLifeDeveloper) + +set(WEBFRONT_LIFE_ASSETS "" CACHE FILEPATH "LifeUI.hpp generated by wf embed (enables the offline Life example)") +if(WEBFRONT_LIFE_ASSETS) + if(NOT EXISTS "${WEBFRONT_LIFE_ASSETS}") + message(FATAL_ERROR "WEBFRONT_LIFE_ASSETS must name an existing LifeUI.hpp generated by wf embed") + endif() + add_executable(WebFrontLifeEmbedded life/LifeEmbedded.cpp) + target_link_libraries(WebFrontLifeEmbedded PRIVATE WebFront WebFront_warnings WebFront_options) + target_compile_definitions(WebFrontLifeEmbedded PRIVATE WEBFRONT_LIFE_ASSETS_HEADER="${WEBFRONT_LIFE_ASSETS}") + webfront_setup_frontends_for_target(WebFrontLifeEmbedded) +endif() diff --git a/src/HelloWorld.cpp b/examples/hello-world/HelloWorld.cpp similarity index 100% rename from src/HelloWorld.cpp rename to examples/hello-world/HelloWorld.cpp diff --git a/src/Life.hpp b/examples/life/Life.hpp similarity index 100% rename from src/Life.hpp rename to examples/life/Life.hpp diff --git a/src/LifeConsole.cpp b/examples/life/LifeConsole.cpp similarity index 100% rename from src/LifeConsole.cpp rename to examples/life/LifeConsole.cpp diff --git a/src/LifeDeveloper.cpp b/examples/life/LifeDeveloper.cpp similarity index 100% rename from src/LifeDeveloper.cpp rename to examples/life/LifeDeveloper.cpp diff --git a/src/LifeEmbedded.cpp b/examples/life/LifeEmbedded.cpp similarity index 100% rename from src/LifeEmbedded.cpp rename to examples/life/LifeEmbedded.cpp diff --git a/src/life/main.tsx b/examples/life/ui/main.tsx similarity index 94% rename from src/life/main.tsx rename to examples/life/ui/main.tsx index 422f14cf..6955bd1b 100644 --- a/src/life/main.tsx +++ b/examples/life/ui/main.tsx @@ -97,7 +97,7 @@ async function nextGeneration(session: Session, revision: number) { const countBits = (cells: Uint8Array) => cells.reduce((count, byte) => { while (byte) { count += byte & 1; byte >>>= 1; } return count; }, 0); function Telemetry({generation, population}: {generation: number; population: number}) { - return