The home page shows at once

It was blank until every module had loaded and the page's examples had
been run, a fuzzer's report among them (about a second of work): first
paint came 1.3 seconds into a repeat visit and about 3 into a first one.

- The assembler draws the home page once, in Node, with the app's own
  homeView, and puts it inside #app. The browser paints it with the
  HTML and the stylesheet.
- When the app has loaded it draws the page again, with its controls,
  and puts it in the prerendered one's place; the fuzzer's reports and
  the proof's counts are copied from the prerendered page, not worked
  out again.
- The prerendered page shows only on the home address: the page's first
  inline script marks it before the first paint, and without the mark it
  stays hidden, so an embed or a problem's address never shows it. That
  script changed, and its hash in docs/Caddyfile with it.

Served locally, first paint is at 0.1 to 0.2 seconds and the page with
its controls at 0.2 to 0.3; both were at 1.2 to 1.4.
This commit is contained in:
alexm committed 2026-11-13 07:28:38 -05:00
1 parent 7000662539
commit 5202c96318
12 files changed
+154 -19

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@
# X-Frame-Options here; framing is allowed from the course
# origins, and from a local `quarto preview` of them.
header {
Content-Security-Policy "default-src 'self'; script-src 'self' 'sha256-I0FTUDEvZjevwnUsTxL/Wv6yjSk4+kJk+rHFqkJdfzU=' 'sha256-RDS2ylVnVHGfhqa7CxiLHKiZwFxVxLSwfQQ6NYsJmuM='; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data: blob:; connect-src 'self' https://godbolt.org; frame-src 'self'; worker-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'self' https://scient.ing https://*.scient.ing http://localhost:* http://127.0.0.1:*"
Content-Security-Policy "default-src 'self'; script-src 'self' 'sha256-H7kdvxp0TUI4FRNjpz2GbeB4zUUFSA0SVJWlzJL2bb8=' 'sha256-RDS2ylVnVHGfhqa7CxiLHKiZwFxVxLSwfQQ6NYsJmuM='; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data: blob:; connect-src 'self' https://godbolt.org; frame-src 'self'; worker-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'self' https://scient.ing https://*.scient.ing http://localhost:* http://127.0.0.1:*"
Referrer-Policy "no-referrer"
X-Content-Type-Options "nosniff"
Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=(), clipboard-write=(self)"
+2
View File
@@ -105,6 +105,8 @@ A student can save the state of their work under a name and come back to any sav
**Work that takes the page down.** The engines stop a program that runs too long or makes values too large (core's [limits.md](../core/docs/limits.md)), but should a program still use up the tab's memory first, the browser kills the page. Saved work runs again as the page opens, so before it runs its save is marked busy in this tab (`src/core/guard.ts`, in `sessionStorage`), and the mark is cleared once the page has been idle for a moment and when it closes normally. A reload that finds the mark puts that save aside as a named version, "When the page stopped (time)", opens the problem as written, and says so; an embed drops the reader's edits instead. If a saved state makes the page fail in any other way, the page that says so offers the same: keep the work as a version and open the problem as written.
The home page is the one page that is drawn before the app starts: the assembled site carries it prerendered (`docs/deploy.md`), and `homeView` then takes its place. A part of it that is costly to work out and holds no control is wrapped in `kept(key, build)` (`src/ui/prerender.ts`), which copies it from the prerendered page; give a new part of that kind the same wrapper, and never one with a listener, since a copy has none.
Nothing else is a route: `#/p/<problem>`, `#/s/<state>` and the other earlier forms open the home page, with a note at the foot of the page that there is no page at that address (`isUnknownRoute` in `src/core/state.ts`). A problem or library routine that does not exist, in the app or in an embed, is a page that says so (in the app it keeps the site's navigation and links the problem list); so is a link that does not open (below). `<view>` is `playground` (the whole workspace; `?area=dev` picks the area, Bridge by default or the problem's own), `trace`, `table`, `flow`, `data`, `life`, `proof`, `tests`, `problems`, `compiler`, `asm` (the machine numbers), or a pane name (`lingo`, `pseudo`, `speco`, `mojo`, `asm`) to show just that editor with its problems under it. Query parameters on an embed: `?t=12` parks the stepper, `?ro=1` makes the editor read-only; `area`, `panel`, `lang`, `build`, `machine`, `dock`, `docktab`, `editor`, `side`, `dockheight` and `theme` arrange the example as the playground's controls do (`applyEmbedParams` in `src/core/state.ts`).
A reader's edits in an embed are saved in their browser, in that embed's own save (one per embedded example, shared by pages that embed the same one), never in the app's save for the problem. Once they have changed something, **Reset** appears beside "open in Programming+" and puts the author's version back. An embed keeps a save only while it holds edits, so a reader who has not changed an example always sees the author's current version. A read-only embed (`?ro=1`) saves nothing.
+1 -1
View File
@@ -4,7 +4,7 @@ The site builds against pplus-core, the git submodule `core/`, at the commit thi
`pixi run site` tests the app and assembles `site/`; `pixi run deploy [slug] [user@host]` does that and publishes it. CI (`.gitea/workflows/deploy.yml`) runs `pixi run ci` (the site's tests and core's `mojo-status-strict`) on every push and pull request, and on a push to `main` checks the chain of pointers (`pixi run release-check`), assembles and publishes.
The site is seven things: `index.html`, `styles.css`, `fonts/` (IBM Plex, served by the site so a visit asks no font host for anything; `fonts/README.md` says where the files came from), `styles/` (the course's widget styles, which the Hardware area's machine views use), `dist/`, `core/` (pplus-core's built `core/dist/`, which `index.html`'s import map names as `#core/`), and the Quarto extension (`quarto/_extensions/pplus`, without an engine copy), which the With Quarto page loads (`pplus.css`, `pplus.js`) and links to file by file. `scripts/assemble.sh` copies them into `site/` with a `VERSION` file holding the commit, a `build.json` naming the three commits the site was built from (below), and the license and notices (`LICENSE.md`, `NOTICE.md`, `THIRD_PARTY.md`, which the footer links), then `scripts/assemble-page.mjs` adds two things to `site/index.html`: the commit as `<meta name="pplus-version">`, which the footer shows, and a `<link rel="modulepreload">` for every module the page's imports reach, after the import map, so a first visit asks for all of them at once instead of one level of imports at a time (`tests/load.test.mjs` holds the list to the import graph and the inline scripts to their hashes). And `scripts/deploy.sh <slug> [user@host]` publishes `site/` to `/srv/www/<slug>` as an atomic release:
The site is seven things: `index.html`, `styles.css`, `fonts/` (IBM Plex, served by the site so a visit asks no font host for anything; `fonts/README.md` says where the files came from), `styles/` (the course's widget styles, which the Hardware area's machine views use), `dist/`, `core/` (pplus-core's built `core/dist/`, which `index.html`'s import map names as `#core/`), and the Quarto extension (`quarto/_extensions/pplus`, without an engine copy), which the With Quarto page loads (`pplus.css`, `pplus.js`) and links to file by file. `scripts/assemble.sh` copies them into `site/` with a `VERSION` file holding the commit, a `build.json` naming the three commits the site was built from (below), and the license and notices (`LICENSE.md`, `NOTICE.md`, `THIRD_PARTY.md`, which the footer links), then `scripts/assemble-page.mjs` adds three things to `site/index.html`: the commit as `<meta name="pplus-version">`, which the footer shows; a `<link rel="modulepreload">` for every module the page's imports reach, after the import map, so a first visit asks for all of them at once instead of one level of imports at a time; and the home page already drawn, inside `#app` (`tests/load.test.mjs` holds the list to the import graph, the inline scripts to their hashes, and the prerendered page to its place). **The home page is prerendered** because drawing it runs the engines on its own examples, a fuzzer's report among them, about a second of work that came after 150 modules had loaded: a visitor saw nothing for 1.3 to 3 seconds. The assembler draws it once in Node with the app's own `homeView` (on the small document the Quarto views use), so the browser paints it with the HTML and the stylesheet, in about a tenth of a second; when the app has loaded it draws the page again, with its controls, and puts it in the prerendered one's place, copying the two costly parts from it instead of working them out again (`src/ui/prerender.ts`). The prerendered page shows only on the home address: the page's first inline script marks it before the first paint, and without the mark it stays hidden, so an embed or a problem's address never shows the home page first. A checkout served as it is (`pixi run dev`) has no prerendered page and draws the home page as before. And `scripts/deploy.sh <slug> [user@host]` publishes `site/` to `/srv/www/<slug>` as an atomic release:
```
/srv/www/pplus -> symlink to the live release