plugins: a plugin's README waits for its bird to land on three lines

The owner (10-30): opening a plugin's page, the README came so fast that
the bird dropped in and flew straight off, the same flash the skeleton
bird had (9b4d0bda8 fixed that one only; this loader is plugins.js's
bounceLoader, a bird of its own that comes at once, with no 450ms wait).

The loader now has a ready promise: it is kept once the bird has landed
on its third line (drop 300ms, three landings, two hops: ~1.7s), at once
with reduced motion or the Loading bird off, when the box is gone, and
after 3s at most for a window that draws no frames. detail()'s fill waits
for it before the README goes in, then the bird flies off over it as
before. A dialog closed while it waits is left alone.

The core scripts' budget is raised to 1,532,602, the exact size, with no
room added, after the loader's comment was cut down.

Run on mote (macOS 27), at this tree on origin/main 9b833205f:
- plugin-readme-bird, skeleton-bird, tray-bird, plugin-page,
  plugin-market, plugin-progressive, plugin-github-wait, plugin-local,
  plugin-release, both engines: 80 pass, 0 fail. New: "a README back at
  once waits for the bird to land on three lines" (three lines lit when
  the README went in, after more than 1.3s and less than 3.5s).
- Broken by hand on main's plugins.js: the new test fails in both engines
  (README in after 18ms and 10ms, no line landed on).
- go test -run Budget ./internal/gui/: ok. gofmt -l: clean.

Not run: the full GUI suite (another session's full suite holds mote),
Linux and Windows.
This commit is contained in:
yetone
2026-10-30 03:36:14 +08:00
parent 9b833205f7
commit 56bc3d515a
3 changed files with 40 additions and 6 deletions
+9 -2
View File
@@ -1552,6 +1552,10 @@
requestAnimationFrame(step);
});
const easeIn = (t) => t * t * t, easeOut = (t) => 1 - (1 - t) ** 3;
// a README waits for three landings (the owner, 10-30), 3s at most
let ready;
box.ready = new Promise((ok) => { ready = ok; });
setTimeout(ready, 3000);
(async () => {
await new Promise(requestAnimationFrame);
if (!box.isConnected || gone) return;
@@ -1583,6 +1587,7 @@
await tween(90, (e) => { put({ y: top + deep * (1 - e), sx: 1.16 - .16 * e, sy: .8 + .3 * e }); l.d = y - top; }, easeIn);
l.hold = false;
l.v = -deep * 14;
if (i === 2) ready();
const xa = x, ya = y;
if (i + 1 < L.length) {
const xb = at[i + 1] * W, yb = L[i + 1].y - 5;
@@ -1597,7 +1602,7 @@
}
}
}
})().catch(() => {});
})().catch(() => {}).finally(ready);
box.leave = () => {
if (off) return box.remove();
gone = true;
@@ -1690,7 +1695,9 @@
// the README takes the skeleton's place, and the dialog grows to it on
// the spring it opened on, centred as it goes, not in one jump; the
// bird flies off over it
const fill = (n) => {
const fill = async (n) => {
await readme.querySelector(".pm-bounce")?.ready;
if (!ed.isConnected) return;
const d = ed.parentElement, h = d.offsetHeight, y = d.style.top, wait = readme.querySelector(".pm-bounce");
const m = d.parentElement, at = wait?.getBoundingClientRect(), o = m.getBoundingClientRect();
readme.replaceChildren(n);
File diff suppressed because one or more lines are too long
+30 -3
View File
@@ -1,9 +1,11 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// A plugin's README loads under magpie's bird: it drops onto the skeleton's
// lines, each one bending under it as it bounces down them. When the README
// comes the bird flies off and the box goes. With reduced motion the lines
// stay straight and the bird sits still on the first. With Settings'
// Loading bird off the lines stay straight and no bird comes.
// comes the bird flies off and the box goes, but not before it has landed
// on three lines, however soon the README came (the owner, 10-30). With
// reduced motion the lines stay straight and the bird sits still on the
// first. With Settings' Loading bird off the lines stay straight and no
// bird comes.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -118,6 +120,31 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(errors, []);
});
test(engine + ": a README back at once waits for the bird to land on three lines", async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const { page, errors, release } = await open(browser, false);
// how many lines it had landed on when the README went in, and when
await page.evaluate(() => {
window.__lit = new Set(); window.__t0 = performance.now();
const step = () => {
const b = document.querySelector("#modal .pm-bounce");
b?.querySelectorAll("path").forEach((p, i) => "lit" in p.dataset && __lit.add(i));
if (document.querySelector("#modal .pm-md")) return void (window.__swap = { lit: __lit.size, ms: performance.now() - __t0 });
requestAnimationFrame(step);
};
step();
});
release({ readme: readme(3), updated: "2026-09-01T00:00:00Z" });
await page.locator("#modal .pm-md p", { hasText: "Paragraph 2." }).waitFor();
const swap = await page.evaluate(() => window.__swap);
assert.ok(swap.lit >= 3, `it landed on three lines first: ${JSON.stringify(swap)}`);
// drop 300ms, three landings 230ms each, two hops 340ms each: ~1.67s
assert.ok(swap.ms > 1300 && swap.ms < 3500, `the README waited for them, no longer: ${JSON.stringify(swap)}`);
await page.waitForFunction(() => !document.querySelector("#modal .pm-bounce"), null, { timeout: 2000 });
assert.deepEqual(errors, []);
});
test(engine + ": with reduced motion the lines stay straight and the bird sits still", async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());