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
24 changes: 22 additions & 2 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,28 @@ environment's `mount`, not to the embedded bootstrap page):
the application after changing it. The tab's tooltip names the shortcut in use.
- While the terminal is collapsed, `wf dev` keeps reloading the full-window interface, and a failed build still shows its
diagnostic over it.

The tab is a button (`aria-expanded`, 44 px target) and the window a non-modal dialog. The interface stays in the preview
- **The tab's menu** opens with a right click, a long press on a touch screen, or the Menu key or Shift+F10 while the tab
has the focus; a click and the shortcut keep opening and collapsing the terminal. Its entries are **Terminal**,
**C++ state ▸** (Functions, Browsers and tasks, Watches) and **TypeScript state ▸** (Packages, Bridge), the inspectors
of the application's state ([ADR-027](adr/ADR-027-inspecteurs-de-l-etat-de-l-application.md)). The arrow keys move in
it and open a submenu (right arrow, Enter or Space; the left arrow closes it), Escape closes the whole menu, from a
submenu too, and gives the focus back to the tab, and a press elsewhere closes it. It opens beside the tab and stays inside the browser window, on the other
side or upwards when there is no room, and narrows to a window smaller than its width. Closed, it takes no key from
the interface. A manifest may name Shift+F10 as the terminal's shortcut: on the focused tab, Shift+F10 then opens the
menu, and the tab's click (Enter or Space) or the menu's Terminal entry opens the terminal; anywhere else, the menu
included, the shortcut toggles the terminal.

An inspector entry that cannot open is greyed, and the menu says why. The page asks C++ once which containers would
reach the inspectors (`webfront.inspector.containers()`, section 8 of the ADR). A library without that function is too
old for the inspectors. The inspectors answer only a page that is admitted (`UI::isLocalClient`): the view of an
embedded frontend (WebKitGTK, WKWebView, WebView2, CEF), which proves itself at the handshake, or any loopback page when
the application sets `WebFrontConfig::trustLoopbackClients`. With the system browser, which never receives that proof,
the entries are therefore unavailable by default, and the menu says to choose an embedded frontend or to set
`trustLoopbackClients`, knowing that any local process can then read the state of the application. The inspector panels
themselves come with the next versions of the environment; until then an admitted page's entries say so.

The tab is a button (`aria-expanded`, `aria-haspopup="menu"`, 44 px target), its menu a `menu` of `menuitem`s of 44 px,
and the window a non-modal dialog. The interface stays in the preview
frame, as before: the layout adds nothing to the application's documents except the shortcut's listener and the preview page's announcement, installed in the interface
and in the same-origin frames it embeds (not in a frame of another origin, nor one inside a shadow tree: click the interface
or the tab first). This is a layout, not a
Expand Down
17 changes: 17 additions & 0 deletions include/webfront/DeveloperApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "WebFront.hpp"

#include <optional>
#include <tuple>

namespace webfront {

Expand Down Expand Up @@ -71,6 +72,14 @@ inline constexpr int apiVersion = 1;

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

/// What webfront.inspector.containers() answers (ADR-027, section 8): whether the calling page can open a secondary window
/// that reaches the inspectors (the frontend opens one and the page is admitted, since opening it is checked like any
/// inspector call), whether the page itself is admitted (UI::isLocalClient), and whether a new connection that is not
/// proven would be (trustLoopbackClients). Three booleans and no state of the application: the call checks no access.
inline constexpr std::tuple<bool, bool, bool> inspectorContainers(bool frontendOpensWindows, bool hostAdmitted, bool trustLoopback) noexcept {
return {frontendOpensWindows && hostAdmitted, hostAdmitted, trustLoopback};
}

/// 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) {
Expand Down Expand Up @@ -131,6 +140,14 @@ class DeveloperAppWithNetwork : public BasicWF<Network, fs::Multi<fs::DeveloperF
expose<&Store::abort, void, std::string>("webfront.developer.abort");
expose<&Store::stateOfLines, std::string, std::string>("webfront.developer.state");
expose<&Store::commitGroupLines, void, std::string, std::string, std::string>("webfront.developer.commitGroup");
#if !(defined(WEBFRONT_DISTRIBUTION) && WEBFRONT_DISTRIBUTION)
// The inspectors exist only in the developer environment and never in a distribution build (ADR-027, section 1).
// The menu of the environment's tab asks it first: an environment that does not find it says the library is too old.
using Caller = typename Base::UI;
this->template cppFunction<std::tuple<bool, bool, bool>, Caller>("webfront.inspector.containers", [trust = this->trustsLoopbackClients()](Caller ui) {
return developer::inspectorContainers(Base::canShowSecondaryWindow(), ui.isLocalClient(), trust);
});
#endif
}

/// Registers a store operation as a bridge callback; the store stays alive as long as the callback.
Expand Down
6 changes: 6 additions & 0 deletions include/webfront/WebFront.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,12 @@ class BasicWF {
windowOptions.background = "#141821";
}

/// Whether the application chose WebFrontConfig::trustLoopbackClients: a new connection that is not proven would then
/// be a local client when its peer is the loopback (the inspectors' containers, ADR-027 section 8).
[[nodiscard]] bool trustsLoopbackClients() const noexcept {
return trustLoopbackClients;
}

private:
// The constructor has already bound and listened; this thread services the queued I/O.
// Launch server only once or restart if previous thread ended
Expand Down
5 changes: 3 additions & 2 deletions js/developer/environment/bundles.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"js/developer/environment/development.mjs": "1f32f911610c72ad3e935de1c2b138fa275ce9eda04bb63c824d5e09923305a6",
"js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c",
"js/developer/environment/terminal.mjs": "1d81a28a6e6cfd5bdb1ff8854e17a273b7bcfebf2c97d469b8706db636f3799e",
"js/developer/environment/workspace.mjs": "05d3474f1581eff1b41cea38318d20166e672997c2fec94d16ba8dd50edd09fb",
"js/developer/environment/workspace.mjs": "5af5ea2a9a27c403d60fe54c268ae07741cae8a89da2cc148e4f64114f2b71d7",
"js/developer/environment/menu.mjs": "9399a5d6a4c28cbf775713ae87e59de905a109d67034024abe03b81a5af9eeb4",
"js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39",
"js/developer/environment/commands.mjs": "a759f48584b78aed79e9965fd202d2ec108a6948ef6f1b8d689fed87a458b265",
"js/developer/environment/files.mjs": "199336f7f3d23f6370da352993bf4686738b1f394b79aa9883769d19824540e0",
Expand All @@ -45,7 +46,7 @@
"js/developer/starters/agent-guide.md": "45dcbcb06cd6c04e048a6fcb9eb4305efde169f97b1c2bafbcc8c127127077f0",
"js/developer/starters/app/main.ts": "b4f43fd3cd9136d86dd3e6e89e29092ddf3b67066c2cc08d78078d15a445054e",
"js/developer/starters/app/style.css": "6a042eff15ee9b1603c95d3e4e974a03876e1c365389553e84eb7c472aded180",
"js/developer/tools/distribution.json": "bdb27ea91159b1371c568a6fce3f851c5fd1ed44bafdc68f42ce2232198e3c92",
"js/developer/tools/distribution.json": "06c5e81e5fbbe3407488840646fb8dd1b36b540fca43dd85dcd5d7342261a36a",
"js/developer/tools/archive.mjs": "da63bb9d796ddfd24ed945b15c53f66a0400eb177886fd4f1c8fd10cafb5a91b",
"js/developer/tools/distribution.mjs": "43dfdccc912693db46fd095fd78ae79325abab672d99f89fd569914ef3499cad",
"js/developer/scripts/build.mjs": "a577f4396ab867096bc6fe6876e16e5220121ec8e8dd234fa1e4819d0a1173e1",
Expand Down
Loading
Loading