30using DocumentMap = std::map<std::string, std::shared_ptr<Document const>, std::less<>>;
39 auto const documents = [](
Manifest const& manifest) {
40 std::map<std::string, std::string, std::less<>> hashes;
43 hashes.insert_or_assign(file.
id, file.
hash);
48 auto const old = documents(before);
49 auto const now = documents(after);
50 std::vector<std::string> changed;
51 for (
auto const& [document, hash] : now) {
52 auto const found = old.find(document);
53 if (found == old.end() || found->second != hash) {
54 changed.push_back(document);
57 for (
auto const& [document, hash] : old) {
58 static_cast<void>(hash);
59 if (!now.contains(document)) {
60 changed.push_back(document);
63 std::ranges::sort(changed);
103 for (std::string
const& screenId : changed) {
110 Refusal refusal = std::move(loaded.error());
114 outcome.
refused.push_back(std::move(refusal));
117 auto const document = std::make_shared<Document const>(std::move(*loaded));
120 if (screen.screenId != screenId || screen.handle ==
nullptr) {
123 if (
auto remounted = host.remount(*screen.handle, document); !remounted) {
125 Refusal{.document = screenId, .path = {}, .reason = std::move(remounted.error().reason)});
134 documents.insert_or_assign(screenId, document);
What the UI service's client and server share (spec 5 §12): content hashes, the bundle's manifest,...
constexpr std::string_view kScreenFile
The file kinds of a manifest.
constexpr std::string_view kAppFile
The app document (spec 6 §5).
The framework's ScreenHost over UI documents: it mounts them through an Interpreter,...
One mounted screen, as its host sees it.
ReloadOutcome reloadDocuments(std::span< std::string const > changed, Bundle const &bundle, LoadOptions const &options, DocumentMap &documents, DocumentScreenHost &host, std::span< MountedScreen const > mounted)
Loads the changed documents of a new bundle and remounts the mounted screens that show them.
std::vector< std::string > changedDocuments(Manifest const &before, Manifest const &after)
The ids of the documents (screens and the app document) whose files differ between two manifests: cha...
std::map< std::string, std::shared_ptr< Document const >, std::less<> > DocumentMap
The loaded documents a host mounts from, by screen id.
The UI document (spec 5 §3): its model — declarations, commands, view nodes, components and customiza...
std::expected< Document, Refusal > loadDocumentText(std::string_view text, LoadOptions const &options={})
Parses JSON text as a UI document and runs its load-time validation.
The host contract (spec 6 §4): how a host mounts UI documents and closes them, whether it owns its ow...
What an open source hands the frontend: the application's screens, verified.
std::map< std::string, std::string, std::less<> > documents
Every document of the bundle, by id, as its JSON text: the screens, the app shell,...
std::string hash
The file's content hash.
std::string kind
screen, app, theme, messages, component or icon; a client fetches no kind it does not know.
std::string id
The file's id: a screen's document id, app, a theme's, a catalogue's or a component's name.
A bundle's manifest: every file the application serves, by its hash (spec 5 §12, "Content addressing"...
A mounted screen a reload may remount.
std::string screenId
The screen id it was mounted from.
ScreenHandle * handle
Its handle, mounted by the host the reload is given. Borrowed for the call.
Why a document, an expression or a value was refused: where, and the reason.
std::string document
The id of the document refused; empty when the refusal is not about a whole document.
What reloadDocuments did.
std::vector< Refusal > refused
Each new document that did not load, and each remount the interpreter refused; the screen and the doc...
std::vector< std::string > remounted
The screen id of each screen remounted on its new document, once per screen.
The frontend seam: main picks a frontend at runtime, and the frontend runs whatever an AppSource open...
The UI document's typed values (ui::Value), its types (ui::Type), their JSON form,...
Node text(Text spec)
Static or bound text.