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
2 changes: 1 addition & 1 deletion .github/workflows/DeveloperDistribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
echo "::notice::Sources build $building; DeveloperReleaseData.hpp still pins the published $pinned."
node js/developer/tools/pin-check.mjs
fi
node --test js/developer/tools/check.mjs js/developer/tools/distribution-check.mjs js/developer/tools/manifest-check.mjs
node --test js/developer/tools/check.mjs js/developer/tools/distribution-check.mjs js/developer/tools/manifest-check.mjs js/developer/tools/restore-check.mjs
- name: Check the dedicated release tag
if: startsWith(github.ref, 'refs/tags/developer-v')
env:
Expand Down
10 changes: 10 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@
`wf install` now needs `wf init` first, which adopts the roots of an existing lock so a project locked before 0.5.0
keeps its locked graph. A committed publication that cannot be completed does not prevent opening the project:
it is reported (`developer::IncompletePublication`) and completed by the next command.
- `wf restore [--offline]` (developer distribution 0.5.0): rebuilds the package cache from the lock alone, at the
locked versions and integrities, idempotent and interruptible; `--offline` only checks the cache and lists the
missing or corrupted packages. Cached packages carry a record of their files' digests. The registry is the
application's option, else the manifest's `registry`, else registry.npmjs.org; `wf install` and `wf restore`
print it with its origin. A reproducible local npm registry fixture (`js/developer/tools/registry-fixture.mjs`)
serves the tests.

### Changed

- `DeveloperBootstrapOptions::registry` is now `std::optional<std::string>`: unset, the manifest's registry
applies; set, it must be HTTPS or a same-origin path and takes precedence over the manifest. The environment
configuration gains `registryExplicit`; earlier environments keep reading `registry`.

- **Breaking:** library headers moved to `include/webfront/`; include them as `<webfront/WebFront.hpp>`,
`<webfront/http/...>`, `<webfront/system/...>` and so on. The former spellings (`<WebFront.hpp>`,
`<http/...>`, `<system/...>`) are removed with no redirect headers, so these generic names no longer
Expand Down
57 changes: 51 additions & 6 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,45 @@ the fingerprint of both files as read when the command began: if another browser
them meanwhile, it is refused with "The project changed since it was read; run the command again" and
nothing is lost. Recovery and group publications also hold an advisory lock on `.webfront/developer/journal/.lock`, so
several processes sharing a project (or several stores of one process) are serialized rather than abandoning one
another's publication; other project files stay unprotected against concurrent local modification. `wf restore` (#306) will fill the cache from a consistent lock without ever writing them.
another's publication; other project files stay unprotected against concurrent local modification. `wf restore` fills the cache from the lock without ever writing them.

## Restoring the cache and choosing the registry (`wf restore`)

The cache under `.webfront/developer/packages/` is not committed. On a new machine, after a clone, or
when it is damaged, `wf restore` rebuilds it from the lock alone:

- each locked package is downloaded at its exact locked version (no range is resolved again) and checked
against the lock's SHA-512 integrity; packages already valid in the cache are not downloaded again, so the
command is idempotent;
- every package is published on its own: Ctrl+C or an error (changed archive, package absent from the
registry) keeps the packages already restored and never writes the manifest or the lock; run the command again;
- `wf restore --offline` contacts no registry at all: it checks the cache against the lock and fails with the
list of missing or corrupted packages, without downloading anything.

Each cached package directory `<key>/` is followed by a record `<key>.json` naming the archive's integrity and the
SHA-256 of every file; the record is written last, so an interrupted copy is *missing*, and a file that differs
from its record, or exceeds the bound below, is *corrupted*. The 256 MiB bound applies to the whole unpacked graph,
packages already in the cache included, and is checked before each package is published, so resuming a restore
cannot exceed it. `wf install` with a consistent lock performs the same restoration.

The registry used by `wf install` and `wf restore` is, in order of precedence:

1. the application's `DeveloperBootstrapOptions::registry` (the distributor's trusted channel; a test driver
uses it to impose its local registry),
2. the manifest's `registry`,
3. `https://registry.npmjs.org/`.

Both commands print the registry in use and where it comes from, for example
`Registry: /mirror/ (application option)`. A registry must use HTTPS or be a path on the application's own
origin, like the environment archive (a path starting with `//` or containing a backslash, which browsers read as
another host, is refused); tarballs must use HTTPS or the registry's origin. The lock's `registry`
field records where the graph was resolved and is not used to restore it, so a mirror can serve a lock resolved
from the public registry.

Offline provisioning, extending ADR-013's explicit local provisioning: serve a directory of packuments (`<name>`)
and tarballs from the application (`fs::NativeDebugFS` or an application provider) and pass its path as
`registry`, then run `wf restore`; or copy `.webfront/developer/packages/` from another machine and check it with
`wf restore --offline`. The environment archive is provisioned the same way (see below).

## Dependencies, storage and limitations

Expand All @@ -216,8 +254,9 @@ another's publication; other project files stay unprotected against concurrent l
- `webfront-packages.lock.json` records exact package versions, dependency edges, source integrities,
requested roots and the digest of the manifest dependencies it resolved. Commit it and the source TSX/CSS; the generated provider can also be committed.
Preview/embed consume the locked local files without resolving versions again.
- Unpacked packages are cached by name, version and integrity under `.webfront/developer/packages/`.
A failed install can leave unused cached packages, but the lock file remains unchanged. The tools
- Unpacked packages are cached by name, version and integrity under `.webfront/developer/packages/`,
each with a record of its files' digests. A failed install can leave unused cached packages, but the lock
file remains unchanged. A lock naming more than 512 packages is refused. The tools
installed by the existing `ToolManager` keep their separate store and `webfront-tools.lock.json`.
- Published environment/preview resources are served under `/webfront/developer/`. The protected
`/WebFront.js` remains the library's version. Sources, staging and cached archives are not HTTP
Expand All @@ -229,7 +268,7 @@ another's publication; other project files stay unprotected against concurrent l
abandoned, and staging left by a crashed process is removed after an hour. Browser builds time out after 120 seconds.
- Installing another package keeps every locked version that still satisfies a requested range and fails if its
archive no longer matches the recorded integrity; only new ranges are resolved. Review the resulting lock
changes. Restoring packages from a lockfile on a fresh machine is not yet a separate command.
changes. `wf restore` rebuilds the cache of a lock on a fresh machine (see above).

## Environment distribution and offline tests (maintainers)

Expand Down Expand Up @@ -265,8 +304,14 @@ The preview command later replaces that directory, but the verified archive is a
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.
Fixture provisioning writes the tests' local npm registry (`js/developer/tools/registry-fixture.mjs`):
packuments and tarballs packed reproducibly from the pinned `jasmine-core`, React, React DOM and scheduler of the
maintainer's npm installation, plus synthetic packages for the edge cases (a newer version under a locked range,
an archive that no longer matches its integrity). The test application serves it from its own origin and imposes
it through the `registry` option. The CEF-off `DeveloperJavaScript` case generates the synthetic part in memory to
test `wf restore`. No CTest case downloads from the public registry. Generating the fixture and the packages'
logic use only browser APIs; reading `node_modules` and writing files (`registry-fixture-node.mjs`) are the
Node-only part, so that `wf` can take the fixture over (#318).

```sh
cmake -S . -B build-native -DCMAKE_BUILD_TYPE=Release \
Expand Down
3 changes: 2 additions & 1 deletion docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ Status snapshot: 2026-07-19. Optional mddlog integration note: 2026-10-02. Newco
Pages returned HTTP 200, CORS `*` and byte-identical pinned environment data on 2026-10-20.
- Browser packages only: no installation scripts, native modules, Node API shims, optional
dependencies or TypeScript type checking. Peers require explicit compatible roots/direct
dependencies. Lockfile restore on a fresh machine and automatic rebuild/watch are future work.
dependencies. Automatic rebuild/watch is future work. `wf restore [--offline]` (0.5.0, #306) rebuilds or checks
the cache from the lock, from the application's registry option, else the manifest's, else npmjs.
See [DEVELOPER_ENVIRONMENT](DEVELOPER_ENVIRONMENT.md) for exact commands and limits.

## Embedded dependency refresh (#284, 2026-10-19)
Expand Down
5 changes: 5 additions & 0 deletions docs/adr/ADR-013-bootstrap-developpeur-a-la-demande.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| --- | --- | --- | --- | --- | --- |
| 0.1 | 2026-10-20 | Proposée | Ambroise Leclerc | Proposition et première implémentation du bootstrap développeur versionné. | À 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) |
| 0.3 | 2026-10-22 | Proposée | Ambroise Leclerc | Provisioning local des paquets (#306) : `wf restore [--offline]`, priorité du registre de l'application sur celui du manifeste. | À renseigner après intégration. |

## Statut et date

Expand Down Expand Up @@ -60,6 +61,10 @@ trajectoire de retrait de l'ADR-016.
- Exécuter une page distante avec le bridge : écarté ; l'environnement validé est servi localement.
- Le premier lancement nécessite l'accès au dépôt ou un provisioning local explicite. Le cache
vérifié autorise ensuite un lancement hors ligne.
- Les paquets suivent la même règle : `wf restore` reconstruit leur cache depuis le lock, depuis le
registre fixé par l'application (canal de confiance du distributeur), sinon celui du manifeste, sinon
registry.npmjs.org, toujours en HTTPS ou sur l'origine de l'application. Un registre servi par
l'application est leur provisioning local explicite ; `wf restore --offline` vérifie le cache sans réseau.
- Le code téléchargé possède l'autorité du bridge et du projet autorisé ; ce n'est pas un sandbox.
Le mode distribution n'active pas ces callbacks. Aucun accès au shell n'est ajouté.

Expand Down
27 changes: 24 additions & 3 deletions include/webfront/DeveloperApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
#include "system/DeveloperReleaseData.hpp"
#include "WebFront.hpp"

#include <optional>

namespace webfront {

struct DeveloperBootstrapOptions {
/// HTTPS npm tarball URL, or same-origin URL for local provisioning/tests.
std::string environment;
/// Trusted SHA-512 SRI of that exact tarball, supplied independently of its download.
std::string integrity;
std::string registry{"https://registry.npmjs.org/"};
/// npm registry chosen by the application: HTTPS, or a same-origin path such as "/registry/" for a
/// local mirror. It takes precedence over the project manifest's "registry"; unset, the manifest's
/// registry applies, else registry.npmjs.org.
std::optional<std::string> registry{};
};

namespace developer {
Expand All @@ -24,13 +29,30 @@ inline WebFrontConfig projectConfig(WebFrontConfig config, const std::filesystem
return config;
}

/// A path that stays on the application's origin: browsers read "//host" and "/\\host" as another host.
inline bool sameOriginPath(std::string_view path) {
return path.starts_with('/') && !path.starts_with("//") && !path.contains('\\');
}

inline void validateBootstrap(std::string_view mode, const std::filesystem::path& project, const DeveloperBootstrapOptions& options) {
if (mode != "developer")
throw std::invalid_argument("Unknown bootstrap mode");
if (project.empty())
throw std::invalid_argument("Developer bootstrap requires an explicit project directory");
if (options.environment.empty() || !options.integrity.starts_with("sha512-"))
throw std::invalid_argument("Developer bootstrap requires an environment URL and trusted SHA-512 integrity");
if (options.registry && !options.registry->starts_with("https://") && !developer::sameOriginPath(*options.registry))
throw std::invalid_argument("The developer registry must be an HTTPS URL or a same-origin path");
}

inline constexpr std::string_view defaultRegistry{"https://registry.npmjs.org/"};

/// The configuration the environment reads. "registry" always names a usable registry, for environments
/// that predate "registryExplicit"; the latter tells whether the application chose it.
inline std::string bootstrapConfig(const DeveloperBootstrapOptions& options) {
return "{\"environment\":" + json::quote(options.environment) + ",\"integrity\":" + json::quote(options.integrity)
+ ",\"registry\":" + json::quote(options.registry.value_or(std::string(defaultRegistry)))
+ ",\"registryExplicit\":" + (options.registry ? "true" : "false") + "}";
}
} // namespace developer

Expand All @@ -51,8 +73,7 @@ class BasicDeveloperApp : public BasicWF<NetProvider, fs::Multi<fs::DeveloperFS,
throw std::logic_error("Developer bootstrap is already configured");
developer::validateBootstrap(mode, project, options);
store = std::make_shared<developer::Store>(project);
registerBridge("{\"environment\":" + json::quote(options.environment) + ",\"integrity\":" + json::quote(options.integrity)
+ ",\"registry\":" + json::quote(options.registry) + "}");
registerBridge(developer::bootstrapConfig(options));
}

void show(std::string_view page = {}) {
Expand Down
2 changes: 1 addition & 1 deletion js/core/WebFrontAssets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function(webfront_add_embedded_assets)
find_program(WEBFRONT_NODE_EXECUTABLE NAMES node nodejs REQUIRED)
add_test(NAME DeveloperJavaScript COMMAND "${WEBFRONT_NODE_EXECUTABLE}"
--test "${root}/js/developer/tools/check.mjs" "${root}/js/developer/tools/distribution-check.mjs"
"${root}/js/developer/tools/manifest-check.mjs")
"${root}/js/developer/tools/manifest-check.mjs" "${root}/js/developer/tools/restore-check.mjs")
set_tests_properties(DeveloperJavaScript PROPERTIES TIMEOUT 30)
add_test(NAME EmbeddedAssetGenerator COMMAND ${CMAKE_COMMAND} -E env
"WEBFRONT_TEST_CMAKE=${CMAKE_COMMAND}" "${WEBFRONT_NODE_EXECUTABLE}"
Expand Down
18 changes: 10 additions & 8 deletions js/developer/environment/bundles.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"js/developer/environment/manifest.mjs": "1cb0c70c87ca31ec81ad0591c0c1d1cb2637ecc491caef9c3d3ec8f1670ea900",
"js/developer/environment/manifest.mjs": "126f0f0e5d64ebb85191c70ff7b42c3c8f9abd5133b4e3e96acc29f089419e6c",
"js/developer/environment/project.mjs": "525bc1545f6ff9a70c744c536e46c2404bdc20daa83b25b29419222161003c3b",
"js/developer/environment/installer.mjs": "e02e047f591a539b04c519570902aa6166614958ac96b61e2aff4dc167d8c816",
"js/developer/environment/packages-entry.mjs": "7b5dc8aac408b741ccd3f9098165fca7645c4e88fd7ca7b8822fe37b7ad21fce",
"js/developer/environment/installer.mjs": "f3e919535847c93f62498ee0ad3fec49ff5f7531fb657feaca80e2ccb6da1c0c",
"js/developer/environment/restore.mjs": "cdd22eebd55d68bd705685cd5ee3059e228a35053eaad116ab99c4c05b908098",
"js/developer/environment/cache.mjs": "6fd0e3b760dfc1070a28e2e2eb3c86621c970c775045e7a9ae665da4f6845922",
"js/developer/environment/packages-entry.mjs": "edf47d25099428ea8d33f9fe4552f239035715b98fd2bff6be0f9143ab0cfe8a",
"js/developer/environment/bootstrap.mjs": "534af4b3d07891338c3390e1d5e06c2fb6dd8df11ca6547735565b17f1b9cd70",
"js/developer/environment/bootstrap-entry.mjs": "ff8084f23f5acc721f97eb1ed0a454e7bfee1894de17d54f0100fa11f7ef8b77",
"js/developer/environment/packages.mjs": "faed29500a34c6ce24756d07bd4b47b9168ccec4bd49d12f00096a869637d74d",
"js/developer/environment/starter.mjs": "048cf2af36b407bc075323f78a1195b4be91ad7da51f6ce941d9fb230f314ff9",
"js/developer/environment/paths.mjs": "6ebb626610756143c58762c87af18980802809d7f0f53d3b588e4b20e8db0161",
"js/developer/environment/runtime.mjs": "8c1eec7e111ac33ad40a33baa7722bcb2f0e5e3301981cc4c14e1d07771946aa",
"js/developer/environment/runtime.mjs": "a8018ff010f17119c90853c883f895bd229ea091bc0edc416467086a34c3b4a3",
"js/developer/environment/compiler.mjs": "3f7e187ca9a4c2645ef3823127457cad655919cbea3c7c0f22fb7ae2cc87e0e5",
"js/developer/environment/bundler.mjs": "b0ff79a1b0caa012c25ec7b7f121d7d50af1aa1651231d3dcf2f39470c4ea25c",
"js/developer/environment/entry.mjs": "b2b942443e3c74ae2c008392ba244d9b7e91db70ba1b4ebbe1357c455ebf51bb",
"js/developer/environment/conditions.mjs": "7f0ecba239480831e38985ccffd4c82309949924f4eb9d938e4ad1b09f5f36ed",
"js/developer/environment/io.mjs": "21af39f07c7eb863908c1df768e3c31de1c6eb8ff757c2a287c4a47c76855db6",
"js/developer/environment/recipe.mjs": "5e7b80cb9090dce63fafafbb852879fce9f6ed2399ac364bbe5af1cf6f4c1758",
"js/developer/environment/registry.mjs": "f566f07ea066155ab7209d925cee2cf12a664ac51b07bc0ca3e3fd8fde49a9c8",
"js/developer/environment/registry.mjs": "717b928b47d1eb8d1635cbfda60473f4a8e0918c1345d5364b6b7d2ffe199195",
"js/developer/environment/archive.mjs": "1fb8b9c3c27219858597801104639bba1104c7a7d33973609cd556b5e5f81d2d",
"js/developer/environment/lock.mjs": "60d0ea14d24793cd5e85bbd4bb4bfe90d2c7d76c0d20ffc99f462595a6e57291",
"js/developer/environment/lock.mjs": "d69a3a877b92da52b21dcc78877345015ac31b7dec1c484ee1ff1f97f154d51f",
"js/developer/environment/pins.mjs": "df07f6f01edaf86a1052d0e76f6c6745cb6e7a3309bbd256ac720ee8adc85297",
"js/developer/environment/peers.mjs": "e1d999892138682fc0134ef1f4d4b19b9a9ad8d7fb16e37fc9c6c684bd853896",
"js/developer/environment/resolve.mjs": "8b96b850af215be51f5cb85cc9c69e057afa04dfb8a57e572620c07059c17fa3",
Expand All @@ -28,11 +30,11 @@
"examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44",
"js/developer/components/tools/wf.mjs": "2a8b463b2da223deb8d54d9fdd6037fdd079afeb24e39337693df03cdbcbd0ec",
"js/developer/tools/distribution.json": "12b40657d1bc34c4093cd5f793d772bf3fa6fd8615ab7b766ad1756092438f83",
"js/developer/tools/build.mjs": "70ae5acdcd08dcde777c042d1b27f384746530ba97f89a81a91d04c5bd4c8e66",
"js/developer/tools/build.mjs": "3579b0adb2dd92f2cf06874697efa5cf44e1fe80782633b923e9b2a06a8d2123",
"js/developer/tools/site.mjs": "1827d3fd7e1e470336aab25ea8686c912c2b674a10f7be496f2f0077fbc45292",
"js/developer/tools/archive.mjs": "bfe9feeb5e4d4e1b7c44c4dec4dcbeab4ae59c2bf16a1d2b32cd6910a2b84e7b",
"js/developer/vendor/package-lock.json": "eb545112b672f9dbf520125df1f44a878d62cc8e611f0e33baee36470ded4dec",
"js/core/bootstrap/bootstrap.bundle.mjs": "792fe7cf564bd12ac47fef419d8c71e2070925764a17706552e7d3f5d6ba2181",
"js/developer/environment/packages.bundle.mjs": "1bd773a901b747e2a38607171b49e7976af4792214c1e50fc7ed3710fed3bf22",
"js/developer/environment/packages.bundle.mjs": "81b575e77911e7a21fb477df84d955aac0c0017969d93c717e0c9622d4eed913",
"include/webfront/system/DeveloperReleaseData.hpp": "c97a8c3b21df3306c179f7b46d945159b5854f9d2810f135a4ab224c768c75d7"
}
Loading
Loading