Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ these entries stays in the GitHub releases and the Git history.
- First measurements of image streams to the page: raw frames, JPEG and WebCodecs availability under CEF and WebKitGTK (#769, `docs/IMAGE_STREAMS.md`).
- Open an embedded window maximized, full screen, without a frame or with a minimum size (`WindowOptions`), on WebKitGTK and CEF (#764, `docs/FRONTENDS.md`).
- `wf dev` applies a change of the stylesheet alone without reloading the page, once an environment with it is published (#763, ADR-014).
- `wf dev` replaces modules in place, keeping the page's state and its connection: React Fast Refresh and `import.meta.hot`, with a full reload when neither applies; the Life React component moved to `Life.tsx`. In the sources of environment 1.3.2, not yet published (#763, ADR-014, `docs/DEVELOPER_ENVIRONMENT.md`).
- Check your pages for accessibility in `wf test` with axe-core: a guide says how, and the forms generated from C++ and the fallback page are checked in CI (#768, `docs/ACCESSIBILITY.md`).
- Fail a spec on an accessibility violation with `await expectAsync(document).toBeAccessible()` once `axe-core` is locked; the `app` and `life` starters carry such a spec (environment 1.3.2, not yet published, #768, `docs/ACCESSIBILITY.md`).
- Use the developer terminal and the inspectors with the keyboard alone: Shift+Tab leaves the terminal, Escape closes an inspector window and gives the focus back; the terminal supports screen readers (environment 1.3.2, #768).
Expand Down
51 changes: 45 additions & 6 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ commands of the terminal operate on it:
| `wf init`, `wf create <starter>` | write the manifest; copy a starter (`app` or `life`, not your project's name) into a new directory |
| `wf help [command\|agents]` | list the commands, describe one, or print the sequence for an agent |
| `wf install`, `wf restore` | resolve, download and lock packages; rebuild or verify the cache from the lock |
| `wf dev`, `wf build`, `wf preview` | rebuild and reload the preview on every change; build once; preview once |
| `wf dev`, `wf build`, `wf preview` | rebuild and update the preview on every change; build once; preview once |
| `wf check` | type-check with the locked TypeScript compiler |
| `wf test` | run Jasmine specs in the application's window |
| `wf run`, `wf exec` | run a manifest script or a package's executable entry |
Expand Down Expand Up @@ -783,11 +783,50 @@ input, read in 256 KiB chunks; each compilation has a 120 s deadline. Polling ne
another poll. Large projects can hit these explicit limits. An edit made during a build is detected by
the next poll; polling can miss a change that is reverted completely between reads.

When a build differs from the one shown by its stylesheet only (`app.css`), the preview does not reload: the new
stylesheet is loaded into the document, which keeps its state, its bridge and its `UI`. JavaScript modules have no hot
replacement: any other change reloads the page.
### Hot replacement

`wf dev` changes a running preview without reloading it when it can. The page keeps its state, its bridge and its
`UI` (same `ui.id()`), so C++ stores, watches and per-browser sessions are not reset.

- **Stylesheet.** When a build differs by `app.css` only, the new stylesheet is loaded into the document.
- **React components.** A project that bundles `react-dom` is previewed with React's development build and
[Fast Refresh](https://react.dev/learn/fast-refresh): editing a module whose exports are all components renders them
again, keeping their local state (a change of the hooks resets that component). Declare components at the top level
of a module that exports nothing else (types aside), as `examples/life/react/Life.tsx` does; the entry that calls
`createRoot` accepts no update. A component Fast Refresh does not register (anonymous, re-exported from another
module, in a `.cjs` file or a source its transform refuses) does not count: such a module accepts nothing.
- **`import.meta.hot`.** Any other module can accept its own updates:

```ts
if (import.meta.hot) {
import.meta.hot.dispose(data => { data.count = count; }); // data is the next version's import.meta.hot.data
import.meta.hot.accept(next => { /* the new exports of this module */ });
}
```

`data`, `accept([callback])`, `dispose(callback)` and `invalidate()` are all there is: a module cannot accept
updates of its dependencies. As elsewhere, the modules that imported it keep the former exports. Declare the type for
`wf check`, since the environment provides none: `interface ImportMeta { readonly hot?: any }` in a `.d.ts` file.

An update runs the changed modules again, then their importers up to the first that accepts or is a module of
components. The page is reloaded instead, with `Full reload: <reason>` in the terminal, when a path reaches the entry or a module
nothing imports without being accepted, when an import cycle reaches no module that accepts, when a module of components starts exporting anything else, when a new version throws while it
runs or calls `invalidate()`, and when the imported packages, the lock, the entry or a copied asset changed. An error
thrown later, while React renders, is React's: correct the source and the next update renders again.

A project with neither `react-dom` nor `import.meta.hot` is previewed as `wf build` bundles it and reloads on every
change other than the stylesheet. So is a project that the module registry cannot link (an `import()` of one of its own
modules, or of a package, by a literal name; a top-level `await`): the terminal says `No hot update: <reason>`.

A hot preview differs from a build: project modules are not minified or tree-shaken, packages and
`process.env.NODE_ENV` are those of development, and modules run through a registry, not as one ES module. Check
behaviour that depends on it with `wf preview`. Nothing of this reaches `wf build`, `wf preview`, `wf test` or
`wf embed`, where `import.meta.hot` is `undefined`.

Hot replacement is in the sources of environment 1.3.2, which is not published: the released environment reloads the
page on every change.

Only a successful build and publication reload the preview, replacing its session history entry. A build
Only a successful build and publication update the preview; a reload replaces its session history entry. A build
error leaves its last successful files and running document intact. Diagnostics (`file:line:column`, with
one-based line and column numbers) stream to the terminal and appear as a text overlay in the preview.
Fixing the source resumes rebuilding and clears the overlay. An interruption ends it with exit code 130, terminates
Expand Down Expand Up @@ -1116,7 +1155,7 @@ WKWebView and all 14 Linux CEF/Xvfb cases with both GCC and Clang in
The packed 0.3.0 version passes WKWebView and all 14 GCC CEF/Xvfb cases in
[run 39490581423](https://github.com/ambroise-leclerc/WebFront/actions/runs/39490581423).
For Linux, select CEF and Xvfb instead; the same developer tests use the selected test frontend.
`DeveloperBrowserIntegration` (the application part: starter, build, `wf dev`, Life preview, embedding) and `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine`, `-terminal` and `-workspace` (the page layout: first launch, launch on an existing interface, floating terminal and its session) exercise, in parallel and each from its own project, the real WASM compiler, local registry, `wf test` under the locked jasmine-core (pass, fail, pending, asynchronous failures, pattern, time limit, interruption, non-interactive report to C++), build without navigation, incremental dev reload/error/recovery/interruption, keyboard copy and paste in the terminal (CEF), the Life preview, C++ generation/animation and repeatable header generation. The developer journey (`Journey*`) then
`DeveloperBrowserIntegration` (the application part: starter, build, `wf dev`, Life preview, embedding) and `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine`, `-terminal` and `-workspace` (the page layout: first launch, launch on an existing interface, floating terminal and its session) and `-hot` (hot replacement with Life React) exercise, in parallel and each from its own project, the real WASM compiler, local registry, `wf test` under the locked jasmine-core (pass, fail, pending, asynchronous failures, pattern, time limit, interruption, non-interactive report to C++), build without navigation, incremental dev reload/error/recovery/interruption, keyboard copy and paste in the terminal (CEF), the Life preview, C++ generation/animation and repeatable header generation. The developer journey (`Journey*`) then
builds the header that its own `wf embed` generated and runs `JourneyEmbeddedRun` from an empty working directory
with no developer callbacks.
Deadline and grace-period regressions advance a scoped clock instead of sleeping for seconds; Worker startup,
Expand Down
1 change: 1 addition & 0 deletions docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ are retained for investigation; diagnostics alone do not establish a correction.
encoding; the first request of a connection has no read timeout. WebSocket connections remain open. Accepted stdnet sockets
enable `TCP_NODELAY`. Gzip fallback has bounded decoding, cache retention and worker admission;
reads from filesystem providers remain synchronous on the I/O context. See [HTTP assets](HTTP_ASSETS.md).
- Hot replacement in `wf dev` (React Fast Refresh, `import.meta.hot`) is exercised under CEF by the browser suite with React 19.3.1; it is in the sources of environment 1.3.2, not yet published. A hot preview is a development build run through a module registry, not the bundle `wf build` makes; literal dynamic imports of bundled modules and top-level `await` are previewed with a full reload.
- The developer environment and `NativeDebugFS` are trusted development facilities, not sandboxes.
Manifest permissions bound only the scripts' `context` API. Only browser packages install;
installation scripts and native add-ons do not run. The [content policy](CONTENT_POLICY.md)
Expand Down
8 changes: 5 additions & 3 deletions docs/REACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ simulation, released on disconnect. The original Life starter remains available.

Build the `WebFrontLifeReact` CMake target. The application only creates an
empty project directory when it is missing (without argument `./life-project`);
it does not copy the example's sources. Use a new directory, so that no existing project is touched: `mkdir` fails if it exists and `cp -n` never overwrites a file. Copy `main.tsx` and
it does not copy the example's sources. Use a new directory, so that no existing project is touched: `mkdir` fails if it exists and `cp -n` never overwrites a file. Copy `main.tsx`, `Life.tsx` and
`webfront.project.json` from `examples/life/react/` into that directory first,
then start the application:

```sh
mkdir life-react-project
cp -n examples/life/react/main.tsx examples/life/react/webfront.project.json life-react-project/
cp -n examples/life/react/main.tsx examples/life/react/Life.tsx examples/life/react/webfront.project.json life-react-project/
./build/examples/WebFrontLifeReact life-react-project
```

In its terminal, run `wf install`, then `wf preview`. The configured registry must
In its terminal, run `wf install`, then `wf preview` (or `wf dev`: editing the rendering in
`Life.tsx` then keeps the grid, the generation and the connection, see
[hot replacement](DEVELOPER_ENVIRONMENT.md#hot-replacement); `main.tsx` only starts the page, so a change of it reloads). The configured registry must
carry `@webfront/react@0.2.0` and its dependency `@webfront/store@0.1.0`; this change prepares the archive but does not publish
to npm. The repository's test registry already carries the package. For a local
evaluation, configure the driver with `--registry-dir <build>/test/web/self-build-project/build-registry`;
Expand Down
29 changes: 29 additions & 0 deletions docs/adr/ADR-014-construction-javascript-dans-le-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
| 0.1 | 2026-10-20 | Proposée | Ambroise Leclerc | Proposition et première implémentation du résolveur npm et du compilateur navigateur. | À renseigner après intégration. |
| 0.2 | 2026-10-22 | Proposée | Ambroise Leclerc | Alignement sur ADR-016 : la proposition devient la base de l'architecture ; preuves multiplateformes manquantes listées. | [404fed2](https://github.com/ambroise-leclerc/WebFront/commit/404fed2c2145d4faba8efee035e10522ff87a91f) |
| 1.0 | 2026-10-24 | Acceptée | Ambroise Leclerc | Qualification multiplateforme du parcours développeur (#316) : la proposition est acceptée. | [#348](https://github.com/ambroise-leclerc/WebFront/pull/348) |
| 1.1 | 2026-12-05 | Proposée | Ambroise Leclerc | `wf dev` remplace la feuille de style seule sans recharger la page (#763). | [e1bc438](https://github.com/ambroise-leclerc/WebFront/commit/e1bc4381) |
| 1.2 | 2026-12-06 | Proposée | Ambroise Leclerc | Remplacement à chaud des modules en développement : graphe de modules, canal de mise à jour, React Fast Refresh, `import.meta.hot` et limites (#763). | Branche `763-hmr` |

## Statut et date

Expand Down Expand Up @@ -47,6 +49,33 @@ processus C++ de compilation ou shell n'est lancé. La transformation TS n'effec
Elle est **Acceptée** depuis les preuves de #316 (voir le statut). Les providers et composants historiques évoqués ici suivent la
trajectoire de retrait de l'ADR-016.

## Remplacement à chaud des modules (1.1 et 1.2, développement seulement)

`wf dev`, et lui seul, met à jour l'aperçu sans le recharger, pour que le document, le pont et son `UI` demeurent.

- **Feuille de style.** Si seul `app.css` change, la nouvelle feuille est chargée dans le document.
- **Aperçus concernés.** Ceux qui incluent `react-dom` ou utilisent `import.meta.hot`. Les autres restent le bundle
ordinaire, rechargé à chaque changement.
- **Graphe.** Le build esbuild ordinaire reste exécuté d'abord : il donne les diagnostics, le CSS, les ressources et,
par son `metafile`, le graphe résolu. Chaque module du projet est ensuite transformé seul en une fabrique CommonJS
d'un registre, retransformé uniquement quand sa source change ; les paquets importés forment un seul script, reconstruit
quand leurs entrées ou le lock changent. Aucune seconde résolution d'imports n'est écrite.
- **Canal.** Le même `app.js` publié contient le registre et tous les modules ; une publication y joint `update.js`
avec les seuls modules modifiés, que la boucle charge comme script dans le document affiché (même origine, sans
`eval`). Aucune connexion ni fonction C++ nouvelle.
- **Frontières.** Un module accepte par `import.meta.hot.accept()` (lui-même seulement ; `dispose`, `data`,
`invalidate`) ou parce que tous ses exports sont des composants React. Sinon la mise à jour remonte vers ses
importateurs ; sans frontière, ou en cas d'échec, la page est rechargée et la raison écrite.
- **React Fast Refresh.** `react-refresh` et la transformation Babel (`@babel/standalone`) sont verrouillés dans le
lock de l'environnement, servis par lui, la transformation n'étant téléchargée que pour un projet React.
`build`, `preview`, `test` et `embed` ne les incluent pas et définissent `import.meta.hot` comme `undefined`.
- **Limites.** Aperçu en mode développement, modules du projet non minifiés ; pas d'`import()` littéral d'un module
groupé ni d'`await` de premier niveau (bundle ordinaire dans ce cas) ; pas d'`accept` des dépendances ni de liaisons
ES vivantes vers les anciens importateurs. Ce n'est pas la sémantique d'un build : `wf preview` reste la référence.
- **Alternatives écartées.** Une transformation Refresh écrite à la main ou par expressions régulières (signatures des
hooks incertaines) ; un serveur de modules ES natifs (une requête par module et une seconde résolution des paquets) ;
Babel pour tous les projets (poids sans utilité).

## Alternatives et conséquences

- Un service distant de bundling introduirait une dépendance de construction externe et un autre
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ verification evidence remain in [PROJECT_STATUS](../PROJECT_STATUS.md).
| [ADR-011](ADR-011-diagnostics-optionnels.md) | Confining mddlog behind an optional diagnostics façade | Accepted | 2026-10-01 | 1.2 — 2026-10-02 |
| [ADR-012](ADR-012-preuves-et-tests.md) | Demonstrating contracts through deterministic tests and browser integration | Accepted | 2020-04-19 | 1.9 — 2026-11-25 |
| [ADR-013](ADR-013-bootstrap-developpeur-a-la-demande.md) | Bootstrapping a downloaded developer environment | Accepted | 2026-10-20 | 1.0 — 2026-10-24 |
| [ADR-014](ADR-014-construction-javascript-dans-le-browser.md) | Resolving npm dependencies and building inside the browser | Accepted through 1.0; 1.1 proposed | 2026-10-20 | 1.1 — 2026-12-05 |
| [ADR-014](ADR-014-construction-javascript-dans-le-browser.md) | Resolving npm dependencies and building inside the browser | Accepted through 1.0; 1.1 and 1.2 proposed | 2026-10-20 | 1.2 — 2026-12-06 |
| [ADR-015](ADR-015-ressources-generees-par-application.md) | Generating application-owned embedded resources | Accepted | 2026-10-20 | 1.0 — 2026-10-24 |
| [ADR-016](ADR-016-bootstrap-comme-socle.md) | The bootstrap environment as WebFront's foundation | Accepted | 2026-10-22 | 1.8 — 2026-11-28 |
| [ADR-017](ADR-017-acces-direct-aux-frontends.md) | Direct access to embedded frontends, with HTML kept normative | Proposed | 2026-10-24 | 1.1 — 2026-10-25 |
Expand Down
Loading
Loading