16. Svelte views register themselves
16. Svelte views register themselves (#317)
Section titled “16. Svelte views register themselves (#317)”-
[E] Decided by the owner (2026-11-20, #317):
MOUNTandANEWofsrc/client/views/mount.tsandVIEWSand the menu ofsrc/client/views/index.tsstop being edited by every view. -
[V] A module in
src/client/views/exportsclientViews, a list ofClientView(contract.ts):key,mount(a Svelte view) orhtml(a view still drawn as a string),anew(mounted anew on every render) orfresh(mounted anew by a fresh render only, see below),menu(order,label,divider),glyph,tab,offeredandaddress. The menu order of today is data: the entries stand at 10 to 180 (seeMenuItemincontract.ts), the tabs of a phone at 10 to 40. The list is the git-ignoredviews.gen.ts(CLIENT_VIEWS);assemble.tsputs the modules together (MOUNTED,ANEW,VIEWS, the menu, the tabs and the glyphs are derived from it) and throws when a key, a menu number, a tab number or a glyph exists twice, naming both files; the guard issrc/client/views/registry.test.ts.mount.tsandindex.tsname no view andmain.tsis not edited. Moved with #317: Übersicht, Gebäude, Rohstoffe, Marktplatz, Forschung, Schiffsschmiede, Verteidigung, Flotte, Sternenkarte, Nachrichten, Highscore, Gilden, Freunde, Achievements, Neuigkeiten, Lexicanum, Optionen and Admin; the four lists sharecatalog-list.ts, the glyph helper isglyph.ts. The menu, the labels, the glyphs and the tabs stay as they were (index.test.tsandframe-reference.test.tscheck it). -
[V] The mark of a menu entry is on the view too (#426 part 3; owner, 2026-11-26, 193b; the coordinator’s choices of 2026-11-27):
hint: { mark, join? }, wheremark({ state, unread })gives the line or nothing; the functions stay insrc/client/logic/(menu-hints.ts,friends.ts).assembleHintscollects them asMENU_HINTS(views/index.ts, a view with two stops the start),navigation.tshands them tomenuHints(), and „Nachrichten“, „Achievements“, „Flotte“, „Gilden“ and „Freunde“ have one. A mark replaces a completed text of its view (completions.ts), or withjoinfollows it after „ · “; only „Flotte“ joins, as before #426. Two modes, not one rule:frame-reference.test.tsgenerates a completed text for every view, and only the two modes keep it byte-identical. The mark of „Neuigkeiten“ is the one still set by hand innavigation.ts: it needs the news and the version seen, which are not in the state of the server. -
[E] Whether a view is offered is one rule on the view (#373; owner, 2026-11-22, #351: a refactor of the v3 foundation without a change of behaviour, in a normal release). [V] The member
offered(round, admin)ofClientView(default: always), put together byassembleOfferedand asked throughoffered()ofviews/offered.ts: a view that is not offered has no menu entry (menu()), no tab (phoneMenu()drops a tab without a menu entry), no address (hiddenView()oflogic/navigation.ts, sogameView()sends it to the overview) and is not mounted (mountView()falls back to the overview). Before the first state every view is open, as before. It replacesMenuItem.showand the names admin, achievements and guilds thathiddenView()kept by hand; „Admin“ (admin), „Gilden“ (round.guilds, #191) and „Achievements“ (round.achievements || round.daily) carry their rule.registry.test.tschecks for every view and round that the menu, the tabs and the address follow the rule, and that the navigation, the address, the mount andindex.tsname none of these views. -
[E] A feature switched off for the round is hidden, not shown as closed (#404; owner, 2026-11-25): (112a) the marketplace gets its rule and every switch of the round is swept, so a player sees a switched-off feature nowhere: not in the menu, the tabs, a link, a mark or a card of the overview, and a guard test checks that every switch has its rule; (113a) the Lexicanum page of a switched-off feature is not listed and not reached by its address or a link, it falls back like an unknown article; (114a) the admin sees the same as every player, and the switch stays in the admin tab „Universum“. [V] „Marktplatz“ says
offered: marketOpen(round.marketOn === 1); „Gilden“ and „Achievements“ take their rule as a function of the core too (guildsOnofcore/guild-chat.ts,rewardsOnofcore/achievements.ts). The switches are read from the registry of the round settings (aswitch, or a number from 0 to 1, as a live switch is kept);src/client/views/round-switches.test.tsmaps each to the views it turns off (achievementsanddailyto „Achievements“,guildsto „Gilden“,marketOnto „Marktplatz“) or names why it turns off none (colonyResearch: the research Kolonialverwaltung, a catalog entry the research list already leaves out, #237, catalog entries being #375;expeditionSpeed: a rule of the stay, no feature), and fails for a new switch until it is mapped, for a mapped view without a rule, and for a rule that does not hide the view while all its switches are off or hides it while one is on, for a player and the admin alike; with every switch on every view is offered, as before. The page of a feature in the Lexicanum carries the very function of its view (PageDef.offered; the guard checks the identity), becauselogic/lexicanum.tsis reached from the views and may not importviews/offered.ts(a cycle);opens(v)oflogic/lexicanum.tsleaves a hidden page out of the lists, „Begriffe A–Z“, the start page and its counts, the other articles of its kind, „Siehe auch“ and the search, keeps the words of a link to it as plain text, andpage()answers its address with the start page, as for an unknown id. An open view of a feature switched off during the round falls back to the overview at the next state (applyofsync.tsasksgameView,sync.test.ts). The menu marks and the cards of the overview need no rule of their own: a mark stands on a menu entry only, and the only card linking such a view („Abholen“) shows a reward the server sends only while it is on. [E] (owner, 2026-11-25) (122a) the answer „Wie bekomme ich mehr Rohstoffe?“ of the Lexicanum has no row „Tauschen“ while the marketplace is off and no row „Belohnungen“ while both rewards are off (faq-resources.ts,pages.blocks.test.ts); (123a) „Dieses Universum“ keeps every row, it states the settings of the round; (121a, 124a) the catalog entries Handelsposten and Kolonialverwaltung are hidden with #375, not here. [V] The closed branch of the page „Marktplatz“ stays until #375, though no player reaches it now. -
[E] A view declares its own address parameters (#379; owner, 2026-11-22, #351: a refactor of the v3 foundation without a change of behaviour, for the deep links of the star map, #160). [V] The member
addressofClientViewlists the names (&name=…) in the ordergotakes their values;assembleAddresscollects them, each name for one view (a name twice stops the start).viewUrloflogic/address.tskeeps the parameters of the open view with a value and drops those of every other view and the hash;addressParamsreads them back.client.ui.paramsholds those of the open view instead ofui.guild(coordinator, 2026-11-24, option 1, [V]);go(view, push, ...values), the start (ui-init.ts) and „back“ (routing.ts) fill it without naming a parameter. „Gilden“ declaresguild, the Lexicanuma(it still reads its article itself,articleParam).address-today.test.tslists the addresses of today, dropped cases too, and passed before and after the change;registry.test.tschecks that the address, the routing and the start name no parameter. -
[E] The boxes of „Optionen“ register themselves (#378; owner, 2026-11-24: the option boxes only). [V] A module in
src/client/views/options/exportsoptionBoxes, a list ofOptionBox(options/contract.ts, declared withoptionBox()):key,order(the boxes of today stand at 10 to 140, seeOptionBoxincontract.ts),section(the section of the phone switch, #189),component(the Svelte component that draws the box with itsdata-sec),data(its part of the page at the view state, moved out ofoptionsPage()) andshown(default: always; „Benachrichtigungen“ only with push kinds).dataandshownwith their part types are pure logic insrc/client/logic/options/<box>.ts(no Svelte, nothing of the views; they readOptionsStateoflogic/options/state.ts), so they stay under mutation testing aslogic/options.tswas; the module inviews/options/only declares the box. The list is the git-ignoredoptions/boxes.gen.ts(OPTION_BOXES);assembleBoxes()ofoptions/assemble.tsputs the modules together in their order and throws when a key or an order number exists twice, naming both files;options/boxes.tsderives the page (OptionsPage,optionsPage(), still exported bylogic/options.ts) from the parts of all boxes.Options.sveltekeeps the switch and draws the boxes in their order; it names no box, nor doeslogic/options.ts. The guard issrc/client/views/options/boxes.test.ts(key, order, section, members; no key, order or field of the page twice; the clash messages; the generated list, insrc/test/gen-option-boxes.test.ts). The markup stays the same up to the white space between the boxes and within a line of text (options.test.ts,options-reference.test.ts). The census of the keyed lists (keyed-lists.test.ts, #369) moved the loops of the choices, the main planet and the push kinds to their box components with the same verdicts and judges the new loop of the boxes by the guard (coordinator, 2026-11-24, [V]). -
[V] A view mounted anew on every render loses the selection and the caret of a field the player is editing: the field is a new element, and
render.tsgives the focus back by id only (#352; a selected number typed over became the old number with the new digit appended). A view with fields saysfreshinstead ofanew: a fresh render (another view, a step of the page) mounts it anew and drops what was typed (forgetForms, #332); any other render (the poll, the clock, the news) keeps it and hands itsupdatethe view state.mountsAnew()ofmount.tsis the rule;registry.test.tschecks it for every view. Built for the Sternenkarte (views/galaxy.ts,GalaxyView.svelte), for „Optionen“ (views/options.ts,OptionsView.svelte, #355: the page jumped on a phone and a tap hit the wrong switch) and, with the shared mountkeptMount()ofviews/kept.ts(KeptView.svelte), for the fleet, the marketplace, „Freunde“, „Achievements“, „Gilden“ and „Admin“ (#361; owner, 2026-11-22: all of them for 26.11.25). -
[V] The rule as a guard (#361): no view with a field a player types into is
anew.registry.test.tsreads it from the sources: the Svelte components a view module imports, with every component they import, and a text area or an input that is not a box, a button or hidden is a typed field. A view stillanewwith such a field stands in its listANEW_WITH_FIELDSwith the reason, and the list holds only views that are stillanew. The dialogs of the admin and the guilds stand in the modal, which a render does not touch. A countdown (Due.svelte) gets a new element for a new end, so a kept view never carries the clock’s mark of a fired countdown (data-fired) into the next one.