castle-web-cli 0.4.254 → 0.4.255
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kits/hub-game/code/client/chrome.js +15 -0
- package/kits/hub-game/code/client/hudTree.js +9 -1
- package/kits/hub-game/docs/contract.md +10 -2
- package/kits/hub-game/scripts/fixtures/hud-surface.json +6 -6
- package/kits/hub-game/scripts/test-prompt-portrait-dom.mjs +128 -0
- package/kits/multiplayer-3d/CLAUDE.md +13 -0
- package/kits/multiplayer-3d/castle.json +3 -3
- package/kits/multiplayer-3d/code/client/resumeGate.js +70 -8
- package/kits/multiplayer-3d/code/systems/multiplayer.js +3 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +133 -1
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +39 -0
- package/package.json +1 -1
|
@@ -82,6 +82,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
|
|
|
82
82
|
}
|
|
83
83
|
let canvasSource = null;
|
|
84
84
|
let safeLayout = null;
|
|
85
|
+
// The prompt's words and display the safe layout last placed (`setHud`).
|
|
86
|
+
let promptPlaced = null;
|
|
85
87
|
let worldLayout = null;
|
|
86
88
|
let worldViewport = null;
|
|
87
89
|
let worldAvatar = null;
|
|
@@ -2228,10 +2230,23 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
|
|
|
2228
2230
|
setHud(spec, timerSeconds, simNow) {
|
|
2229
2231
|
if (!spec) {
|
|
2230
2232
|
hudSurface.setHud(null);
|
|
2233
|
+
// Hidden, the safe layout may let go of its width: the same words
|
|
2234
|
+
// shown again are placed again.
|
|
2235
|
+
promptPlaced = null;
|
|
2231
2236
|
return;
|
|
2232
2237
|
}
|
|
2233
2238
|
const { big, clock } = hudSurface.setHud(spec, timerSeconds, simNow);
|
|
2234
2239
|
if (clock && uiTreeDomEnabled()) {hudDom.tick();}
|
|
2240
|
+
// A prompt shown or reworded is placed in this frame: upright it may be
|
|
2241
|
+
// as wide as the row until the safe layout narrows it beside the
|
|
2242
|
+
// control column, and the layout's own pass can be 500 ms away.
|
|
2243
|
+
if (safeLayout) {
|
|
2244
|
+
const promptKey = `${hudText.style.display}\u0001${hudText.textContent}`;
|
|
2245
|
+
if (promptKey !== promptPlaced) {
|
|
2246
|
+
promptPlaced = promptKey;
|
|
2247
|
+
safeLayout.flush();
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2235
2250
|
if (hudClear) {
|
|
2236
2251
|
layoutHudClear(big, spec.text ?? '');
|
|
2237
2252
|
}
|
|
@@ -20,6 +20,8 @@ import { h } from './uiTree.js';
|
|
|
20
20
|
// HUD_COPY_STYLE (`hudCopy.js`) as tree style: a pill as wide as its words,
|
|
21
21
|
// at most its column, centred, wrapping anywhere.
|
|
22
22
|
const COPY = { bg: 'copy', radius: 14, pad: [4, 8], box: 'border', w: 'wrap', maxW: '100%', self: 'center', lh: 1.3, wrap: ['word', 'anywhere'] };
|
|
23
|
+
// The prompt's row: the view less 16 px (or the safe area) at each side.
|
|
24
|
+
const PROMPT_ROW = { vw: 100, sub: { l: 16, r: 16 } };
|
|
23
25
|
// An edge kept clear of the safe area only where the place asks for it.
|
|
24
26
|
const edge = (safeInsets, px) => (safeInsets ? [px, 0] : px);
|
|
25
27
|
|
|
@@ -85,7 +87,13 @@ export function buildHud(state) {
|
|
|
85
87
|
h('text', {
|
|
86
88
|
key: 'prompt', hub: 'hud-prompt', data: { hubCopy: 'instruction' }, text: hud.prompt ?? '',
|
|
87
89
|
at: { anchor: 'bottom', bottom: [54, 48], left: [16, 0], right: [16, 0], z: 2 },
|
|
88
|
-
|
|
90
|
+
// The prompt keeps to 60% of the width, except upright where the safe
|
|
91
|
+
// layout places it (`hub.safeInsets`, or Act): there it may take the
|
|
92
|
+
// whole row, and the safe layout narrows it to the lane beside the
|
|
93
|
+
// control column. 60% of a 390 px phone is 234 px, and a 48-character
|
|
94
|
+
// sentence wrapped there on most doors. Without the safe layout
|
|
95
|
+
// nothing would move it off Grab or the column, so it keeps the cap.
|
|
96
|
+
style: { ...COPY, size: 14, weight: 500, clip: false, maxW: !landscape && safeInsets ? [{ px: 560 }, PROMPT_ROW] : [{ vw: 60 }, { px: 560 }, PROMPT_ROW], talign: 'center', gone: !hud.promptShown },
|
|
89
97
|
}),
|
|
90
98
|
h('text', {
|
|
91
99
|
key: 'toast', hub: 'toast', text: toastText,
|
|
@@ -2073,8 +2073,15 @@ While an NPC conversation offers suggestion or choice buttons, those buttons
|
|
|
2073
2073
|
are the next action: the bottom prompt hides until they close. Toasts yield
|
|
2074
2074
|
when they cannot fit clear of those buttons.
|
|
2075
2075
|
The wire/API stays unchanged; the client omits later sentences without adding
|
|
2076
|
-
an ellipsis. Door authors write only the next action, about 48 characters
|
|
2077
|
-
|
|
2076
|
+
an ellipsis. Door authors write only the next action, about 48 characters,
|
|
2077
|
+
and fewer for a phone held upright: there, in a place laid out by the safe
|
|
2078
|
+
layout (`hub.safeInsets`, or Act), the pill may take the whole row and is
|
|
2079
|
+
narrowed to the lane beside the bottom-right control column in the frame it
|
|
2080
|
+
is shown. That lane is about 314 px of a 390 px view beside Emote and Quick
|
|
2081
|
+
chat (about 40 characters) and about 232 px where the pill stands beside the
|
|
2082
|
+
Jump/Act pair, as in a place without Emote (about 32 characters). Elsewhere,
|
|
2083
|
+
and in landscape, it keeps to 60% of the width (234 px upright on 390). Story
|
|
2084
|
+
belongs in NPC talk or a later prompt. Dev serving warns on wrapping,
|
|
2078
2085
|
and the layout check reports it as a failure. Existing overlong first sentences
|
|
2079
2086
|
remain fully readable by wrapping in the bottom pill until their authors
|
|
2080
2087
|
shorten them; the kit never silently clips a sentence. Empty prompts have no pill.
|
|
@@ -5421,6 +5428,7 @@ a deck written before them remains valid.
|
|
|
5421
5428
|
|
|
5422
5429
|
| date | change |
|
|
5423
5430
|
| --- | --- |
|
|
5431
|
+
| 2026-11-19 | §9 the next-action prompt on a phone held upright is no longer capped at 60% of the view's width (234 px on a 390 px phone, about 30 characters), which wrapped it on 34 of 58 doors in the Nov 19 every-door pass, wherever the safe layout places it (`hub.safeInsets` or Act): it may take the row less 16 px a side (at most 560 px), the safe layout narrows it to the lane beside the control column, and a prompt shown or reworded is placed in that frame rather than at the layout's next 500 ms pass. A place without the safe layout keeps the 60% cap, since nothing would move the prompt off Grab or the column. A 40-character sentence now stays on one line on a 360 px phone beside Emote; beside the Jump/Act pair (17 of 58 doors, those without Emote) the lane is about 232 px at 390, about 32 characters. Landscape keeps its 60% cap. Copy longer than about 40 characters still wraps upright, and door authors shorten it. No key, API or wire change. Test: `test-prompt-portrait-dom`. |
|
|
5424
5432
|
| 2026-11-18 (v1.221) | §4/§12 first-input signals: a place that exports a `signal(hub, playerId, { kind, npc?, door? })` hook hears `move`, `jump` and the first door `prompt` from the client (each at most once per arrival, within 120 s of it; `hub-arrived` carries the arrival's `signals` number only where the hook exists, each `hub-signal` carries it back as `a`, and a retained rehello is answered `hub-signals` with that arrival's remaining window and spent kinds) and the kit's own `talk`, `press` (door jump, party Go/Go-yes, House visit) and `pad` (`hub.pad` step-on). A fixed vocabulary of authored ids, no free text and no manifest key. Without the hook: no wrapper, message, state, hook dispatch or wire field. |
|
|
5425
5433
|
| 2026-11-18 (v1.220) | §"A place replaced under its players" copy: when the ending is seen as the player comes back from away (`multiplayer.returning()`), the line is "<this place's title> closed while you were away. Back to <the place left>…" ("This place closed while you were away…" with no title) instead of "This place was updated", which was not true for an owner's House left empty past its reconnect window. A player who was present still sees the updated line. Copy only: no key, API or wire change. |
|
|
5426
5434
|
| 2026-11-18 (v1.219) | §12 page visibility after a rejoin: a client whose connection is not up forgets the state it last sent and sends its current state once it is connected again (a send into a socket that died unseen, as on an app switch, no longer leaves the server holding a stale hidden); the server takes a rejoin's first `hub-visibility` even when it repeats the kept value, then coalesces as before. An avatar-change hello is not a rejoin. No new key or wire field. |
|
|
@@ -487,7 +487,7 @@
|
|
|
487
487
|
],
|
|
488
488
|
[
|
|
489
489
|
"root",
|
|
490
|
-
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":true},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":true},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":true}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"
|
|
490
|
+
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":true},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":true},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":true}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"px\":560},{\"vw\":100,\"sub\":{\"l\":16,\"r\":16}}],\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":14,\"weight\":500,\"clip\":false,\"talign\":\"center\",\"gone\":true}},{\"t\":\"text\",\"k\":\"toast\",\"hub\":\"toast\",\"text\":\"\",\"at\":{\"anchor\":\"top\",\"top\":[12,0],\"avoid\":[\"hud/hud\",\"ask/card\"]},\"s\":{\"w\":\"wrap\",\"maxW\":[{\"vw\":100,\"px\":-24}],\"box\":\"border\",\"talign\":\"center\",\"pad\":[8,14],\"radius\":8,\"bg\":\"toast\",\"size\":14,\"gone\":true}}]}",
|
|
491
491
|
1,
|
|
492
492
|
1700000001,
|
|
493
493
|
[
|
|
@@ -496,7 +496,7 @@
|
|
|
496
496
|
],
|
|
497
497
|
[
|
|
498
498
|
"root",
|
|
499
|
-
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":true},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":true}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"
|
|
499
|
+
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":true},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":true}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"px\":560},{\"vw\":100,\"sub\":{\"l\":16,\"r\":16}}],\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":14,\"weight\":500,\"clip\":false,\"talign\":\"center\",\"gone\":true}},{\"t\":\"text\",\"k\":\"toast\",\"hub\":\"toast\",\"text\":\"\",\"at\":{\"anchor\":\"top\",\"top\":[12,0],\"avoid\":[\"hud/hud\",\"ask/card\"]},\"s\":{\"w\":\"wrap\",\"maxW\":[{\"vw\":100,\"px\":-24}],\"box\":\"border\",\"talign\":\"center\",\"pad\":[8,14],\"radius\":8,\"bg\":\"toast\",\"size\":14,\"gone\":true}}]}",
|
|
500
500
|
2,
|
|
501
501
|
1700000001,
|
|
502
502
|
[
|
|
@@ -505,7 +505,7 @@
|
|
|
505
505
|
],
|
|
506
506
|
[
|
|
507
507
|
"root",
|
|
508
|
-
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":true},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":true}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"
|
|
508
|
+
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":true},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":true}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"px\":560},{\"vw\":100,\"sub\":{\"l\":16,\"r\":16}}],\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":14,\"weight\":500,\"clip\":false,\"talign\":\"center\",\"gone\":true}},{\"t\":\"text\",\"k\":\"toast\",\"hub\":\"toast\",\"text\":\"\",\"at\":{\"anchor\":\"top\",\"top\":[12,0],\"avoid\":[\"hud/hud\",\"ask/card\"]},\"s\":{\"w\":\"wrap\",\"maxW\":[{\"vw\":100,\"px\":-24}],\"box\":\"border\",\"talign\":\"center\",\"pad\":[8,14],\"radius\":8,\"bg\":\"toast\",\"size\":14,\"gone\":true}},{\"t\":\"stack\",\"k\":\"actpair\",\"at\":{\"anchor\":\"bottomRight\",\"bottom\":[60,50],\"right\":[14,0],\"rail\":{\"name\":\"right\",\"order\":1}},\"s\":{\"w\":134,\"h\":48,\"hit\":\"none\",\"gone\":false},\"c\":[{\"t\":\"button\",\"k\":\"act\",\"data\":{\"hubAct\":\"act\"},\"disabled\":true,\"at\":{\"anchor\":\"topLeft\",\"top\":0,\"left\":70},\"s\":{\"h\":48,\"w\":64,\"minH\":44,\"pad\":8,\"radius\":22,\"border\":{\"w\":2,\"c\":\"rgba(255,255,255,.55)\"},\"bg\":\"rgba(20,16,12,.88)\",\"color\":\"#fff\",\"font\":\"ui\",\"size\":14,\"weight\":700,\"lh\":\"normal\",\"box\":\"border\",\"wrap\":\"none\",\"gone\":false,\"opacity\":0.5},\"on\":{\"press\":\"hud/actpair/act#press\",\"release\":\"hud/actpair/act#release\",\"cancel\":\"hud/actpair/act#cancel\"},\"c\":[{\"t\":\"text\",\"text\":\"Act\"}]},{\"t\":\"button\",\"k\":\"jump\",\"data\":{\"hubAct\":\"jump\"},\"fire\":\"down\",\"keepFocus\":true,\"at\":{\"anchor\":\"topLeft\",\"top\":0,\"left\":0},\"s\":{\"h\":48,\"w\":64,\"minH\":44,\"pad\":8,\"radius\":22,\"border\":{\"w\":2,\"c\":\"rgba(255,255,255,.55)\"},\"bg\":\"rgba(20,16,12,.88)\",\"color\":\"#fff\",\"font\":\"ui\",\"size\":14,\"weight\":700,\"lh\":\"normal\",\"box\":\"border\",\"wrap\":\"none\",\"gone\":false},\"on\":{\"tap\":\"hud/actpair/jump#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"Jump\"}]}]}]}",
|
|
509
509
|
3,
|
|
510
510
|
1700000001,
|
|
511
511
|
[
|
|
@@ -518,7 +518,7 @@
|
|
|
518
518
|
],
|
|
519
519
|
[
|
|
520
520
|
"root",
|
|
521
|
-
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":false},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"Plot\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":false}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"Plant.\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"
|
|
521
|
+
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":false},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"Plot\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":false}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"Plant.\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"px\":560},{\"vw\":100,\"sub\":{\"l\":16,\"r\":16}}],\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":14,\"weight\":500,\"clip\":false,\"talign\":\"center\",\"gone\":false}},{\"t\":\"text\",\"k\":\"toast\",\"hub\":\"toast\",\"text\":\"\",\"at\":{\"anchor\":\"top\",\"top\":[12,0],\"avoid\":[\"hud/hud\",\"ask/card\"]},\"s\":{\"w\":\"wrap\",\"maxW\":[{\"vw\":100,\"px\":-24}],\"box\":\"border\",\"talign\":\"center\",\"pad\":[8,14],\"radius\":8,\"bg\":\"toast\",\"size\":14,\"gone\":true}},{\"t\":\"stack\",\"k\":\"actpair\",\"at\":{\"anchor\":\"bottomRight\",\"bottom\":[60,50],\"right\":[14,0],\"rail\":{\"name\":\"right\",\"order\":1}},\"s\":{\"w\":134,\"h\":48,\"hit\":\"none\",\"gone\":false},\"c\":[{\"t\":\"button\",\"k\":\"act\",\"data\":{\"hubAct\":\"act\"},\"disabled\":true,\"at\":{\"anchor\":\"topLeft\",\"top\":0,\"left\":70},\"s\":{\"h\":48,\"w\":64,\"minH\":44,\"pad\":8,\"radius\":22,\"border\":{\"w\":2,\"c\":\"rgba(255,255,255,.55)\"},\"bg\":\"rgba(20,16,12,.88)\",\"color\":\"#fff\",\"font\":\"ui\",\"size\":14,\"weight\":700,\"lh\":\"normal\",\"box\":\"border\",\"wrap\":\"none\",\"gone\":false,\"opacity\":0.5},\"on\":{\"press\":\"hud/actpair/act#press\",\"release\":\"hud/actpair/act#release\",\"cancel\":\"hud/actpair/act#cancel\"},\"c\":[{\"t\":\"text\",\"text\":\"Act\"}]},{\"t\":\"button\",\"k\":\"jump\",\"data\":{\"hubAct\":\"jump\"},\"fire\":\"down\",\"keepFocus\":true,\"at\":{\"anchor\":\"topLeft\",\"top\":0,\"left\":0},\"s\":{\"h\":48,\"w\":64,\"minH\":44,\"pad\":8,\"radius\":22,\"border\":{\"w\":2,\"c\":\"rgba(255,255,255,.55)\"},\"bg\":\"rgba(20,16,12,.88)\",\"color\":\"#fff\",\"font\":\"ui\",\"size\":14,\"weight\":700,\"lh\":\"normal\",\"box\":\"border\",\"wrap\":\"none\",\"gone\":false},\"on\":{\"tap\":\"hud/actpair/jump#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"Jump\"}]}]}]}",
|
|
522
522
|
4,
|
|
523
523
|
1700000001,
|
|
524
524
|
[
|
|
@@ -531,7 +531,7 @@
|
|
|
531
531
|
],
|
|
532
532
|
[
|
|
533
533
|
"root",
|
|
534
|
-
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":false},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"Plot\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":false}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"Plant.\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"
|
|
534
|
+
"{\"t\":\"stack\",\"k\":\"hud\",\"s\":{\"font\":\"ui\",\"size\":15,\"weight\":600,\"lh\":1.3,\"color\":\"#fff\"},\"c\":[{\"t\":\"button\",\"k\":\"back\",\"fire\":\"down\",\"at\":{\"anchor\":\"topLeft\",\"top\":[12,0],\"left\":[12,0]},\"s\":{\"pad\":[9,16,9,12],\"radius\":22,\"border\":{\"w\":1,\"c\":\"line35\"},\"bg\":\"chip\",\"color\":\"#fff\",\"gone\":false},\"on\":{\"tap\":\"hud/back#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"‹ Town\"}]},{\"t\":\"column\",\"k\":\"hud\",\"at\":{\"anchor\":\"top\",\"top\":[12,0]},\"s\":{\"maxW\":[{\"vw\":70}],\"talign\":\"center\",\"tshadow\":\"outline\",\"gone\":false},\"c\":[{\"t\":\"text\",\"k\":\"title\",\"data\":{\"hubCopy\":\"subtitle\"},\"text\":\"Plot\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":13,\"lines\":2,\"ellipsis\":false,\"ls\":0.06,\"upper\":true,\"gone\":false}},{\"t\":\"text\",\"k\":\"big\",\"text\":\"\",\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[0,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":\"100%\",\"self\":\"center\",\"mt\":4,\"wrap\":\"anywhere\",\"size\":56,\"weight\":800,\"lh\":1.05,\"gone\":true}}]},{\"t\":\"text\",\"k\":\"prompt\",\"hub\":\"hud-prompt\",\"data\":{\"hubCopy\":\"instruction\"},\"text\":\"Plant.\",\"at\":{\"anchor\":\"bottom\",\"bottom\":[54,48],\"left\":[16,0],\"right\":[16,0],\"z\":2},\"s\":{\"bg\":\"copy\",\"radius\":14,\"pad\":[4,8],\"box\":\"border\",\"w\":\"wrap\",\"maxW\":[{\"px\":560},{\"vw\":100,\"sub\":{\"l\":16,\"r\":16}}],\"self\":\"center\",\"lh\":1.3,\"wrap\":[\"word\",\"anywhere\"],\"size\":14,\"weight\":500,\"clip\":false,\"talign\":\"center\",\"gone\":false}},{\"t\":\"text\",\"k\":\"toast\",\"hub\":\"toast\",\"text\":\"Planted\",\"at\":{\"anchor\":\"top\",\"top\":[12,0],\"avoid\":[\"hud/hud\",\"ask/card\"]},\"s\":{\"w\":\"wrap\",\"maxW\":[{\"vw\":100,\"px\":-24}],\"box\":\"border\",\"talign\":\"center\",\"pad\":[8,14],\"radius\":8,\"bg\":\"toast\",\"size\":14,\"gone\":false}},{\"t\":\"stack\",\"k\":\"actpair\",\"at\":{\"anchor\":\"bottomRight\",\"bottom\":[60,50],\"right\":[14,0],\"rail\":{\"name\":\"right\",\"order\":1}},\"s\":{\"w\":134,\"h\":48,\"hit\":\"none\",\"gone\":false},\"c\":[{\"t\":\"button\",\"k\":\"act\",\"data\":{\"hubAct\":\"act\"},\"disabled\":true,\"at\":{\"anchor\":\"topLeft\",\"top\":0,\"left\":70},\"s\":{\"h\":48,\"w\":64,\"minH\":44,\"pad\":8,\"radius\":22,\"border\":{\"w\":2,\"c\":\"rgba(255,255,255,.55)\"},\"bg\":\"rgba(20,16,12,.88)\",\"color\":\"#fff\",\"font\":\"ui\",\"size\":14,\"weight\":700,\"lh\":\"normal\",\"box\":\"border\",\"wrap\":\"none\",\"gone\":false,\"opacity\":0.5},\"on\":{\"press\":\"hud/actpair/act#press\",\"release\":\"hud/actpair/act#release\",\"cancel\":\"hud/actpair/act#cancel\"},\"c\":[{\"t\":\"text\",\"text\":\"Act\"}]},{\"t\":\"button\",\"k\":\"jump\",\"data\":{\"hubAct\":\"jump\"},\"fire\":\"down\",\"keepFocus\":true,\"at\":{\"anchor\":\"topLeft\",\"top\":0,\"left\":0},\"s\":{\"h\":48,\"w\":64,\"minH\":44,\"pad\":8,\"radius\":22,\"border\":{\"w\":2,\"c\":\"rgba(255,255,255,.55)\"},\"bg\":\"rgba(20,16,12,.88)\",\"color\":\"#fff\",\"font\":\"ui\",\"size\":14,\"weight\":700,\"lh\":\"normal\",\"box\":\"border\",\"wrap\":\"none\",\"gone\":false},\"on\":{\"tap\":\"hud/actpair/jump#tap\"},\"c\":[{\"t\":\"text\",\"text\":\"Jump\"}]}]}]}",
|
|
535
535
|
5,
|
|
536
536
|
1700000001,
|
|
537
537
|
[
|
|
@@ -559,7 +559,7 @@
|
|
|
559
559
|
[]
|
|
560
560
|
]
|
|
561
561
|
],
|
|
562
|
-
"dom": "
|
|
562
|
+
"dom": "0d9810d41553002d63d012b3ba5f1012821de5ee35349487a4d287d30ded845a",
|
|
563
563
|
"writes": 669
|
|
564
564
|
},
|
|
565
565
|
"safeLandscape": {
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// The bottom prompt on a phone held upright (Nov 19 door pass: it wrapped on
|
|
2
|
+
// 37 doors in portrait, capped at 60% of a 390 px view, 234 px, about 30
|
|
3
|
+
// characters). Upright, where the safe layout places it (`hub.safeInsets` or
|
|
4
|
+
// Act), it now takes the lane beside the control column: a 40-character
|
|
5
|
+
// sentence stays on one line on a 360 px phone, a longer one is as wide as
|
|
6
|
+
// that lane before it wraps, and every one stays clear of the controls, in
|
|
7
|
+
// the first frame it is shown too (not 500 ms later). Without the safe layout,
|
|
8
|
+
// and in landscape, the prompt keeps its 60% cap. Run with CHROME pointing to the QA browser (and BROWSER_WS when
|
|
9
|
+
// using a remote GPU browser).
|
|
10
|
+
import assert from 'node:assert/strict';
|
|
11
|
+
import { readFile } from 'node:fs/promises';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { chromium } from 'playwright-core';
|
|
14
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
15
|
+
|
|
16
|
+
const root = new URL('../../../', import.meta.url);
|
|
17
|
+
const source = await readFile(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
18
|
+
const setup = source.slice(source.indexOf(' this.chrome.setWorldLabelFocus'), source.indexOf(' Avatar.load(scene);'));
|
|
19
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
20
|
+
try {
|
|
21
|
+
const page = await browser.newPage();
|
|
22
|
+
await page.route('http://layout.test/**', async route => {
|
|
23
|
+
const path = new URL(route.request().url()).pathname;
|
|
24
|
+
if (path === '/') return route.fulfill({ contentType: 'text/html', body: '<script type="importmap">{"imports":{"three":"/node_modules/three/build/three.module.js"}}</script><body style="margin:0"></body>' });
|
|
25
|
+
const url = new URL(`.${path}`, root);
|
|
26
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
27
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
28
|
+
});
|
|
29
|
+
const SHORT = 'Pulse the pink sentry, then fix the seal';
|
|
30
|
+
const LONG = 'Pulse the pink sentry, then restore the old seal';
|
|
31
|
+
assert.equal(SHORT.length, 40);
|
|
32
|
+
assert.equal(LONG.length, 48);
|
|
33
|
+
for (const [width, height] of [[390, 844], [360, 740], [412, 915], [375, 667], [844, 390]]) {
|
|
34
|
+
await page.setViewportSize({ width, height });
|
|
35
|
+
for (const mode of ['act', 'safe', 'legacy']) for (const PROMPT of [SHORT, LONG]) {
|
|
36
|
+
await page.goto('http://layout.test/');
|
|
37
|
+
await logRenderer(page, 'prompt portrait');
|
|
38
|
+
const result = await page.evaluate(async ({ mode, setup, text }) => {
|
|
39
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
40
|
+
const { overlaps } = await import('/kits/hub-game/code/client/safeLayout.js');
|
|
41
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, safeInsets: ['safe', 'act'].includes(mode) });
|
|
42
|
+
chrome.soundControl(true, { volume: 0.7, muted: false }, { onMuted() {}, onVolume() {} });
|
|
43
|
+
chrome.showPicker(true, 0);
|
|
44
|
+
chrome.setEmotes([['wave', '👋']]); chrome.setSay({ reactions: [], phrases: [] });
|
|
45
|
+
chrome.setDoors([{ id: 'cove', title: 'Cove' }]);
|
|
46
|
+
const { attachOrbitInput } = await import('/kits/physics-3d/engine3d/orbitinput.js');
|
|
47
|
+
const canvas = document.createElement('canvas'); document.body.append(canvas);
|
|
48
|
+
const runtime = { cameraControl: 'orbit', keys: new Set() };
|
|
49
|
+
const engine = attachOrbitInput(canvas, runtime, { set() {} }, () => {});
|
|
50
|
+
runtime.lookInput.listen();
|
|
51
|
+
window.dispatchEvent(new PointerEvent('pointerdown', { pointerType: 'touch' }));
|
|
52
|
+
const scene = { persistent: {}, three: { renderer: { domElement: { parentElement: document.body } } } };
|
|
53
|
+
const Hub = { deck: { safeInsets: mode === 'safe', act: mode === 'act' }, hub: {} };
|
|
54
|
+
const context = { chrome };
|
|
55
|
+
let words = '';
|
|
56
|
+
const draw = () => {
|
|
57
|
+
chrome.setHud({ title: 'Bell Quay', text: words }, null);
|
|
58
|
+
new Function('Hub', 'scene', 'worldLabelFocus', setup).call(context, Hub, scene, () => false);
|
|
59
|
+
chrome.grabPrompt(null); chrome.sitPrompt(null); chrome.talkPrompt(null);
|
|
60
|
+
chrome.layoutInteractionRail();
|
|
61
|
+
chrome.setActions([{ id: 'invite-friend', label: 'Invite a friend' }], () => {}, true, 1, false);
|
|
62
|
+
chrome.frameSafeInsets?.();
|
|
63
|
+
};
|
|
64
|
+
if (mode === 'act') {
|
|
65
|
+
const { makeAct } = await import('/kits/hub-game/code/client/act.js');
|
|
66
|
+
const { hub } = await import('/kits/hub-game/code/client/state.js');
|
|
67
|
+
hub.place = { id: 'main', act: true };
|
|
68
|
+
hub.prompts = [];
|
|
69
|
+
const act = makeAct(chrome, { perform() {} }, { prepare() {} });
|
|
70
|
+
Object.assign(scene, { getActors: () => [], getActor: () => null, moveInput: { consumeJump() {} } });
|
|
71
|
+
scene.three.camera = { position: { clone: () => ({ set() { return this; }, project: () => ({ x: 0, y: 0, z: 0 }) }) } };
|
|
72
|
+
act.frame(scene, { net: { selfId: () => 'p', send() {} } }, { components: { Transform: { x: 0, y: 1, z: 0 } } }, true);
|
|
73
|
+
}
|
|
74
|
+
const paint = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
75
|
+
draw(); await paint(); draw(); await paint();
|
|
76
|
+
await new Promise(resolve => setTimeout(resolve, 550));
|
|
77
|
+
for (let frame = 0; frame < 8; frame++) {draw(); await paint();}
|
|
78
|
+
// Shown on a settled screen: placed in its first frame, before the
|
|
79
|
+
// layout's own 500 ms pass.
|
|
80
|
+
words = text; draw(); await paint();
|
|
81
|
+
const prompt = document.querySelector('[data-hub="hud-prompt"]');
|
|
82
|
+
const firstBox = prompt.getBoundingClientRect();
|
|
83
|
+
await new Promise(resolve => setTimeout(resolve, 550));
|
|
84
|
+
for (let frame = 0; frame < 4; frame++) {draw(); await paint();}
|
|
85
|
+
// Taken down (no HUD) long enough for the layout to let go of it,
|
|
86
|
+
// then the same words again: placed again in their first frame.
|
|
87
|
+
chrome.setHud(null, null); await paint();
|
|
88
|
+
await new Promise(resolve => setTimeout(resolve, 550));
|
|
89
|
+
await paint();
|
|
90
|
+
draw(); await paint();
|
|
91
|
+
const againBox = prompt.getBoundingClientRect();
|
|
92
|
+
await new Promise(resolve => setTimeout(resolve, 550));
|
|
93
|
+
for (let frame = 0; frame < 4; frame++) {draw(); await paint();}
|
|
94
|
+
const style = getComputedStyle(prompt);
|
|
95
|
+
const box = prompt.getBoundingClientRect();
|
|
96
|
+
const oneLine = Math.ceil(parseFloat(style.lineHeight) + parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
|
|
97
|
+
const nodes = [...document.querySelectorAll('button')].filter(node => ['Character', 'Invite a friend', 'Doors'].includes(node.textContent) || /^(Emote|Quick chat|Sound:)/.test(node.getAttribute('aria-label') ?? '') || ['act', 'jump'].includes(node.dataset.hubAct));
|
|
98
|
+
const controls = nodes.filter(node => node.getBoundingClientRect().width > 0 && getComputedStyle(node).visibility !== 'hidden')
|
|
99
|
+
.map(node => ({ name: node.getAttribute('aria-label') || node.textContent, ...Object.fromEntries(['left', 'right', 'top', 'bottom'].map(key => [key, node.getBoundingClientRect()[key]])) }));
|
|
100
|
+
const hits = controls.filter(control => overlaps(control, box)).map(control => control.name);
|
|
101
|
+
const wrapped = prompt.scrollHeight > oneLine;
|
|
102
|
+
const shown = style.display !== 'none' && style.visibility !== 'hidden';
|
|
103
|
+
const said = prompt.textContent;
|
|
104
|
+
const freshHits = controls.filter(control => overlaps(control, firstBox)).map(control => control.name);
|
|
105
|
+
const againHits = controls.filter(control => overlaps(control, againBox)).map(control => control.name);
|
|
106
|
+
const result = { text: said, visible: shown, wrapped,
|
|
107
|
+
left: box.left, right: box.right, top: box.top, bottom: box.bottom, width: box.width, hits, freshHits, againHits, w: innerWidth, h: innerHeight };
|
|
108
|
+
engine.detach(); chrome.dispose(); canvas.remove();
|
|
109
|
+
return result;
|
|
110
|
+
}, { mode, setup, text: PROMPT });
|
|
111
|
+
const at = `${width}x${height} ${mode} ${PROMPT.length} chars`;
|
|
112
|
+
assert(result.visible && result.text === PROMPT, `${at}: prompt drawn`);
|
|
113
|
+
assert.deepEqual(result.hits, [], `${at}: prompt clears the controls`);
|
|
114
|
+
assert.deepEqual(result.freshHits, [], `${at}: a newly shown prompt clears the controls in its first frame`);
|
|
115
|
+
assert.deepEqual(result.againHits, [], `${at}: the same prompt shown again clears the controls in its first frame`);
|
|
116
|
+
assert(result.left >= 0 && result.right <= result.w && result.bottom <= result.h, `${at}: prompt inside the view`);
|
|
117
|
+
if (width < height && mode !== 'legacy') {
|
|
118
|
+
if (PROMPT === SHORT) {assert.equal(result.wrapped, false, `${at}: stays on one line (${Math.round(result.width)} px)`);}
|
|
119
|
+
// Before: 234 px at 390, 216 at 360. The lane beside the column is
|
|
120
|
+
// about 314 at 390 and 284 at 360.
|
|
121
|
+
else {assert(result.width >= result.w - 106, `${at}: as wide as the lane beside the column (${Math.round(result.width)} px)`);}
|
|
122
|
+
} else {
|
|
123
|
+
assert(result.width <= result.w * 0.6 + 1, `${at}: a landscape or legacy prompt keeps its 60% cap`);
|
|
124
|
+
}
|
|
125
|
+
console.log(`${at}: prompt ${Math.round(result.width)} px, ${result.wrapped ? 'wrapped' : 'one line'}, clear`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} finally { await browser.close(); }
|
|
@@ -348,3 +348,16 @@ text (comparing the raw username rebuilt an anonymous player's canvas and textur
|
|
|
348
348
|
every frame), and `connection.js`'s `status().you` falls back to the roster entry
|
|
349
349
|
for the local playerId, so a local player's own tag is not missing while the
|
|
350
350
|
SDK's `you` is still null.
|
|
351
|
+
|
|
352
|
+
## Change notes
|
|
353
|
+
|
|
354
|
+
- 2026-11-19 (572b9ab0b): a short away (a frame stall past `STALL_MS`, or an app
|
|
355
|
+
switch under `RESYNC_AWAY_MS` with the socket kept) asks for its resync once the
|
|
356
|
+
page has been shown `RESYNC_QUIET_MS` (250 ms) since it last hid and a drain
|
|
357
|
+
brought nothing current (`ResumeGate.askQuiet`). The session sends nothing on a
|
|
358
|
+
tick where nothing changed, so a still room (Foot Race's start line) used to keep
|
|
359
|
+
the resume cover up until 5 s: black, then "Reconnecting…". A page that hides
|
|
360
|
+
with a resync out asks again on return, and only a WORLD arriving after the latest
|
|
361
|
+
request answers it. Known limit: replies carry no request id, so a late reply to
|
|
362
|
+
an earlier request still counts. No wire change; aways of 5 s or more and dropped
|
|
363
|
+
connections behave as before.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"castle.physics-3d": {
|
|
13
13
|
"deckId": "JH0SclbPVP0y",
|
|
14
|
-
"version": "2026-11-
|
|
14
|
+
"version": "2026-11-19T11:14:34.739Z"
|
|
15
15
|
},
|
|
16
16
|
"castle.physics-2d": {
|
|
17
17
|
"deckId": "ckRZGFW4iPrx",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"castle.base": {
|
|
22
22
|
"deckId": "yRcmH4_aYllE",
|
|
23
|
-
"version": "2026-11-
|
|
23
|
+
"version": "2026-11-19T09:37:15.255Z"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"autoUpdateWhenImported": true,
|
|
27
27
|
"deckId": "ZwA_P_-VO-Qh",
|
|
28
28
|
"cardId": "bvRmCzyUpt_a",
|
|
29
|
-
"publishedVersion": "2026-11-
|
|
29
|
+
"publishedVersion": "2026-11-19T12:39:24.311Z",
|
|
30
30
|
"main": "main.jsx",
|
|
31
31
|
"server": {
|
|
32
32
|
"main": "code/server/index.js",
|
|
@@ -57,6 +57,15 @@ const WORLD = 'w';
|
|
|
57
57
|
// ordinary release, as does a session that offers none.
|
|
58
58
|
export const RESYNC_AWAY_MS = 5000;
|
|
59
59
|
|
|
60
|
+
// A session broadcasts nothing on a tick where nothing changed, so a still room
|
|
61
|
+
// (players waiting at a start line) may send no current broadcast at all after
|
|
62
|
+
// a short away: a phone rotation or an arrival hitch past `STALL_MS` then kept
|
|
63
|
+
// the cover up until `RESYNC_AWAY_MS`, black and then 'Reconnecting…'. A shorter
|
|
64
|
+
// away is asked for its resync once the page has been shown this long, without
|
|
65
|
+
// hiding, and a whole drain still brought nothing current (`askQuiet`); a busy
|
|
66
|
+
// room's next broadcast releases it well before.
|
|
67
|
+
export const RESYNC_QUIET_MS = 250;
|
|
68
|
+
|
|
60
69
|
// A socket can read connected and carry nothing after an away. A resync left
|
|
61
70
|
// unanswered this long asks the transport to recover instead of waiting for
|
|
62
71
|
// its keepalive deadline.
|
|
@@ -69,9 +78,13 @@ export const RESYNC_REPLY_MS = 3000;
|
|
|
69
78
|
// it was seen not connected, `backAt` when it came back after that, and
|
|
70
79
|
// `asked` whether a resync was asked for (`ask`), `askedAt` the page time then,
|
|
71
80
|
// `replyExpired` whether its unanswered reply has been reported, and `hiddenAt`
|
|
72
|
-
// the page time the page hid with a resync out (`suspendReply`).
|
|
81
|
+
// the page time the page hid with a resync out (`suspendReply`). `visibleAt` is
|
|
82
|
+
// the first frame of the page's current showing (cleared by a hide), `replyAfter`
|
|
83
|
+
// the page time of the latest resync sent, which only a WORLD arriving after
|
|
84
|
+
// answers, and `reask` whether the page hid with a resync out, so its return
|
|
85
|
+
// asks again.
|
|
73
86
|
export function makeGate() {
|
|
74
|
-
return { armed: false, since: 0, serverAt: null, shownAt: null, dropped: false, lostAt: null, backAt: null, asked: false, askedAt: null, replyExpired: false, hiddenAt: null, pausedAt: null };
|
|
87
|
+
return { armed: false, since: 0, serverAt: null, shownAt: null, dropped: false, lostAt: null, backAt: null, asked: false, askedAt: null, replyExpired: false, hiddenAt: null, pausedAt: null, visibleAt: null, replyAfter: null, reask: false };
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
// Arm the gate for an away that began at page time `since`, when the server's
|
|
@@ -93,6 +106,9 @@ export function arm(gate, since, serverAt) {
|
|
|
93
106
|
gate.replyExpired = false;
|
|
94
107
|
gate.hiddenAt = null;
|
|
95
108
|
gate.pausedAt = null;
|
|
109
|
+
gate.visibleAt = null;
|
|
110
|
+
gate.replyAfter = null;
|
|
111
|
+
gate.reask = false;
|
|
96
112
|
return true;
|
|
97
113
|
}
|
|
98
114
|
|
|
@@ -108,17 +124,49 @@ export function clear(gate) {
|
|
|
108
124
|
gate.replyExpired = false;
|
|
109
125
|
gate.hiddenAt = null;
|
|
110
126
|
gate.pausedAt = null;
|
|
127
|
+
gate.visibleAt = null;
|
|
128
|
+
gate.replyAfter = null;
|
|
129
|
+
gate.reask = false;
|
|
111
130
|
}
|
|
112
131
|
|
|
113
|
-
// Whether to ask for a resync now, at page time `now
|
|
114
|
-
// of at least `RESYNC_AWAY_MS` over a connection that never dropped (one
|
|
115
|
-
// dropped is sent a WORLD anyway)
|
|
132
|
+
// Whether to ask for a resync now, at page time `now`, before a drain: once per
|
|
133
|
+
// away of at least `RESYNC_AWAY_MS` over a connection that never dropped (one
|
|
134
|
+
// that dropped is sent a WORLD anyway), and again after the page hid with one
|
|
135
|
+
// out, since a reply that came while hidden may be followed by dropped frames.
|
|
136
|
+
// Marks the gate asked when it says yes.
|
|
116
137
|
export function ask(gate, now) {
|
|
117
|
-
if (!gate.armed || gate.dropped
|
|
138
|
+
if (!gate.armed || gate.dropped) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (gate.asked) {
|
|
142
|
+
if (!gate.reask) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
gate.reask = false;
|
|
146
|
+
gate.replyAfter = now;
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (now - gate.since < RESYNC_AWAY_MS) {
|
|
118
150
|
return false;
|
|
119
151
|
}
|
|
152
|
+
return asking(gate, now);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Whether to ask for a resync now, at page time `now`, after a drain that left
|
|
156
|
+
// the gate armed: a shorter away over a connection that never dropped, whose
|
|
157
|
+
// page has been shown for `RESYNC_QUIET_MS` since it last hid. A still room
|
|
158
|
+
// sends no broadcast to release it.
|
|
159
|
+
export function askQuiet(gate, now) {
|
|
160
|
+
if (!gate.armed || gate.dropped || gate.asked || gate.visibleAt === null || now - gate.visibleAt < RESYNC_QUIET_MS) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return asking(gate, now);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function asking(gate, now) {
|
|
120
167
|
gate.asked = true;
|
|
121
168
|
gate.askedAt = now;
|
|
169
|
+
gate.replyAfter = now;
|
|
122
170
|
return true;
|
|
123
171
|
}
|
|
124
172
|
|
|
@@ -137,8 +185,17 @@ export function unanswered(gate, now, limit) {
|
|
|
137
185
|
// be drained while hidden, so the reply wait and the give-up both count visible
|
|
138
186
|
// time only: `resumeReply` moves them on by the time away. Neither restarts, so
|
|
139
187
|
// a page that keeps hiding still reaches both.
|
|
188
|
+
// The page hiding also ends its current showing (`askQuiet` counts from the
|
|
189
|
+
// next), and a resync out is asked again on the return (`ask`).
|
|
140
190
|
export function suspendReply(gate, now) {
|
|
141
|
-
if (gate.armed
|
|
191
|
+
if (!gate.armed) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
gate.visibleAt = null;
|
|
195
|
+
if (gate.asked) {
|
|
196
|
+
gate.reask = true;
|
|
197
|
+
}
|
|
198
|
+
if (gate.asked && gate.hiddenAt === null) {
|
|
142
199
|
gate.hiddenAt = now;
|
|
143
200
|
}
|
|
144
201
|
}
|
|
@@ -189,8 +246,12 @@ export function current(gate, msg) {
|
|
|
189
246
|
if (gate.dropped) {
|
|
190
247
|
return msg.k === WORLD && gate.backAt !== null && msg.localMs >= gate.backAt;
|
|
191
248
|
}
|
|
249
|
+
// Asked for a resync, only a WORLD after the latest request answers it.
|
|
250
|
+
// Known limit: a reply carries no request id, so a reply to an earlier
|
|
251
|
+
// request that is delivered late (after a hide's re-ask) still counts. Closing
|
|
252
|
+
// that needs the session to echo a request id: a wire change.
|
|
192
253
|
if (msg.k === WORLD) {
|
|
193
|
-
return
|
|
254
|
+
return !gate.asked || msg.localMs >= gate.replyAfter;
|
|
194
255
|
}
|
|
195
256
|
// A resync was asked for: no broadcast can say what the dropped ones did.
|
|
196
257
|
if (gate.asked) {
|
|
@@ -227,5 +288,6 @@ export function waited(gate, now, visible) {
|
|
|
227
288
|
gate.pausedAt = null;
|
|
228
289
|
}
|
|
229
290
|
gate.shownAt ??= now;
|
|
291
|
+
gate.visibleAt ??= now;
|
|
230
292
|
return now - gate.shownAt > RESUME_WAIT_MS;
|
|
231
293
|
}
|
|
@@ -918,6 +918,9 @@ class MultiplayerSystem {
|
|
|
918
918
|
}
|
|
919
919
|
if (fresh) {
|
|
920
920
|
this.resumed();
|
|
921
|
+
} else if (resuming && this.resyncs && ResumeGate.askQuiet(this.resume, performance.now())) {
|
|
922
|
+
// After the drain, so a current broadcast already queued releases first.
|
|
923
|
+
this.net.send({ k: RESYNC });
|
|
921
924
|
}
|
|
922
925
|
this.placeGrants(scene);
|
|
923
926
|
}
|
|
@@ -246,7 +246,9 @@ function run(room, until) {
|
|
|
246
246
|
if (pageMs >= room.nextTick) {
|
|
247
247
|
room.nextTick += TICK_MS;
|
|
248
248
|
const msg = broadcast(room);
|
|
249
|
-
|
|
249
|
+
// A real session sends nothing on a tick where nothing changed (`still`).
|
|
250
|
+
const empty = !msg.os.length && !msg.ps.length;
|
|
251
|
+
if (room.socket && !(room.still && empty)) {
|
|
250
252
|
deliver(room, msg);
|
|
251
253
|
}
|
|
252
254
|
}
|
|
@@ -572,6 +574,136 @@ if (baseline) {
|
|
|
572
574
|
check('1.1 s frame stall', room, { uncoverBy: 200 });
|
|
573
575
|
}
|
|
574
576
|
|
|
577
|
+
// A frame stall in a still room (Foot Race's start line: nobody moves, so the
|
|
578
|
+
// session sends nothing at all) has no broadcast to release it. The gate asks
|
|
579
|
+
// for its resync once the page has been shown RESYNC_QUIET_MS, and the reply
|
|
580
|
+
// releases it well before RESYNC_AWAY_MS and before the cover finds words:
|
|
581
|
+
// it was black, then 'Reconnecting…', for 5 s on every phone rotation.
|
|
582
|
+
{
|
|
583
|
+
const room = await makeRoom({ objects: { crate: [3, 0.5, 3, 0, 0, 0, 1] }, players: { partner: [1, 0, 1, 0] } });
|
|
584
|
+
room.still = true;
|
|
585
|
+
deliver(room, world(room, { rs: 1 }), pageMs);
|
|
586
|
+
run(room, pageMs + 2000);
|
|
587
|
+
room.lastFrame = pageMs - FRAME_MS;
|
|
588
|
+
frame(room);
|
|
589
|
+
pageMs += 1500;
|
|
590
|
+
room.nextTick = pageMs;
|
|
591
|
+
room.shownAt = pageMs;
|
|
592
|
+
const asks = () => room.outbox.filter((m) => m.k === 'r').length;
|
|
593
|
+
run(room, pageMs + FRAME_MS * 2);
|
|
594
|
+
assert.equal(room.system.resume.armed, true, 'the stall arms the gate');
|
|
595
|
+
assert.equal(asks(), 0, 'no resync before the quiet wait');
|
|
596
|
+
run(room, room.shownAt + 350);
|
|
597
|
+
assert.equal(asks(), 1, 'a still room is asked for its resync once');
|
|
598
|
+
deliver(room, world(room, { rs: 1, again: 1 }));
|
|
599
|
+
run(room, pageMs + 300);
|
|
600
|
+
assert.equal(room.system.resume.armed, false, 'the resync releases it');
|
|
601
|
+
assert.equal(asks(), 1);
|
|
602
|
+
check('1.5 s frame stall in a still room', room, { uncoverBy: 700 });
|
|
603
|
+
assert.ok(room.frames.every((f) => f.cover !== 'Reconnecting…'), 'the cover never says Reconnecting');
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// A stall in a still room whose page hides again with the quiet resync out:
|
|
607
|
+
// the reply that came while hidden can be followed by dropped frames (here the
|
|
608
|
+
// crate moved), so the return asks again and only that reply releases it.
|
|
609
|
+
{
|
|
610
|
+
const room = await makeRoom({ objects: { crate: [3, 0.5, 3, 0, 0, 0, 1] }, players: { partner: [1, 0, 1, 0] } });
|
|
611
|
+
room.still = true;
|
|
612
|
+
deliver(room, world(room, { rs: 1 }), pageMs);
|
|
613
|
+
run(room, pageMs + 2000);
|
|
614
|
+
room.lastFrame = pageMs - FRAME_MS;
|
|
615
|
+
frame(room);
|
|
616
|
+
pageMs += 1500;
|
|
617
|
+
room.nextTick = pageMs;
|
|
618
|
+
const asks = () => room.outbox.filter((m) => m.k === 'r').length;
|
|
619
|
+
run(room, pageMs + 350);
|
|
620
|
+
assert.equal(asks(), 1, 'the quiet ask went out');
|
|
621
|
+
hide(room);
|
|
622
|
+
deliver(room, world(room, { rs: 1, again: 1 }));
|
|
623
|
+
run(room, pageMs + 100);
|
|
624
|
+
room.socket = false;
|
|
625
|
+
room.objects.crate = [5, 0.5, 1, 0, 0, 0, 1];
|
|
626
|
+
run(room, pageMs + 300);
|
|
627
|
+
room.socket = true;
|
|
628
|
+
run(room, pageMs + 500);
|
|
629
|
+
show(room);
|
|
630
|
+
run(room, pageMs + 300);
|
|
631
|
+
assert.equal(room.system.resume.armed, true, 'the reply from while hidden does not release it');
|
|
632
|
+
assert.equal(asks(), 2, 'the return asks again');
|
|
633
|
+
deliver(room, world(room, { rs: 1, again: 1 }));
|
|
634
|
+
run(room, pageMs + 300);
|
|
635
|
+
assert.equal(room.system.resume.armed, false, 'the new reply releases it');
|
|
636
|
+
check('quiet resync out, hidden again', room, { uncoverBy: 700 });
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// A current broadcast already queued when the quiet wait runs out releases the
|
|
640
|
+
// cover itself: the quiet ask comes only after a drain that brought nothing.
|
|
641
|
+
{
|
|
642
|
+
const room = await makeRoom({ objects: { crate: [3, 0.5, 3, 0, 0, 0, 1] }, players: { partner: [1, 0, 1, 0] } });
|
|
643
|
+
room.still = true;
|
|
644
|
+
deliver(room, world(room, { rs: 1 }), pageMs);
|
|
645
|
+
run(room, pageMs + 2000);
|
|
646
|
+
room.lastFrame = pageMs - FRAME_MS;
|
|
647
|
+
frame(room);
|
|
648
|
+
pageMs += 1500;
|
|
649
|
+
room.nextTick = pageMs;
|
|
650
|
+
room.shownAt = pageMs;
|
|
651
|
+
run(room, room.shownAt + 240);
|
|
652
|
+
assert.equal(room.system.resume.armed, true);
|
|
653
|
+
room.players.partner = [1.3, 0, 1.1, 0.2];
|
|
654
|
+
deliver(room, broadcast(room), pageMs);
|
|
655
|
+
pageMs = room.shownAt + 260;
|
|
656
|
+
room.nextTick = pageMs + TICK_MS;
|
|
657
|
+
frame(room);
|
|
658
|
+
assert.equal(room.system.resume.armed, false, 'the queued broadcast released it');
|
|
659
|
+
assert.equal(room.outbox.filter((m) => m.k === 'r').length, 0, 'with no resync asked');
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// A genuine drop in the same still room is not hidden by the quiet ask: the
|
|
663
|
+
// cover stays up and says Reconnecting, no resync is asked over the dead
|
|
664
|
+
// connection, and the WORLD the session sends the connection that comes back
|
|
665
|
+
// releases it.
|
|
666
|
+
{
|
|
667
|
+
const room = await makeRoom({ objects: { crate: [3, 0.5, 3, 0, 0, 0, 1] }, players: { partner: [1, 0, 1, 0] } });
|
|
668
|
+
room.still = true;
|
|
669
|
+
deliver(room, world(room, { rs: 1 }), pageMs);
|
|
670
|
+
run(room, pageMs + 2000);
|
|
671
|
+
room.shownAt = pageMs;
|
|
672
|
+
room.socket = false;
|
|
673
|
+
room.state = 'reconnecting';
|
|
674
|
+
run(room, pageMs + 3500);
|
|
675
|
+
assert.equal(room.system.resume.armed, true, 'a drop arms the gate');
|
|
676
|
+
assert.equal(room.outbox.filter((m) => m.k === 'r').length, 0, 'no resync over a dropped connection');
|
|
677
|
+
assert.equal(globalThis.__cover, 'Reconnecting…', 'a drop past the quiet start says Reconnecting');
|
|
678
|
+
reconnect(room);
|
|
679
|
+
run(room, pageMs + 1000);
|
|
680
|
+
assert.equal(room.system.resume.armed, true, 'the connection back is not enough');
|
|
681
|
+
assert.equal(room.outbox.filter((m) => m.k === 'r').length, 0, 'nor is it asked for a resync');
|
|
682
|
+
deliver(room, world(room, { rs: 1 }));
|
|
683
|
+
run(room, pageMs + 300);
|
|
684
|
+
assert.equal(room.system.resume.armed, false, 'the WORLD after the drop releases it');
|
|
685
|
+
check('3.5 s drop in a still room', room, { uncoverBy: 3500 + 1000 + 300 });
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// The same stall in a room that moves releases on its next broadcast, with no
|
|
689
|
+
// resync asked for.
|
|
690
|
+
{
|
|
691
|
+
const room = await makeRoom({ objects: { crate: [3, 0.5, 3, 0, 0, 0, 1] }, players: { partner: [1, 0, 1, 0] } });
|
|
692
|
+
room.still = true;
|
|
693
|
+
deliver(room, world(room, { rs: 1 }), pageMs);
|
|
694
|
+
run(room, pageMs + 2000);
|
|
695
|
+
room.lastFrame = pageMs - FRAME_MS;
|
|
696
|
+
frame(room);
|
|
697
|
+
pageMs += 1500;
|
|
698
|
+
room.nextTick = pageMs;
|
|
699
|
+
room.shownAt = pageMs;
|
|
700
|
+
room.players.partner = [1.4, 0, 1.2, 0.3];
|
|
701
|
+
run(room, pageMs + 600);
|
|
702
|
+
assert.equal(room.system.resume.armed, false);
|
|
703
|
+
assert.equal(room.outbox.filter((m) => m.k === 'r').length, 0, 'a moving room needs no resync');
|
|
704
|
+
check('1.5 s frame stall in a moving room', room, { uncoverBy: 200 });
|
|
705
|
+
}
|
|
706
|
+
|
|
575
707
|
// A dropped connection that comes back with ordinary broadcasts and no WORLD
|
|
576
708
|
// (a session from before the kept-body WORLD) is never uncovered on them, since
|
|
577
709
|
// they say nothing of what moved while it was gone; the wait gives up instead.
|
|
@@ -36,6 +36,45 @@ assert.equal(Gate.unanswered(gate, 30000, limit), false, 'a natural drop needs n
|
|
|
36
36
|
Gate.noteConnection(gate, true, 30000);
|
|
37
37
|
assert.equal(Gate.unanswered(gate, 31000, limit), false, 'nor does that drop returning');
|
|
38
38
|
|
|
39
|
+
// A short away whose page has been shown RESYNC_QUIET_MS since it last hid,
|
|
40
|
+
// with nothing current (a still room sends no broadcast), is asked for its
|
|
41
|
+
// resync then; one not shown yet is not, nor one whose connection dropped (a
|
|
42
|
+
// WORLD comes anyway). Hidden time does not count toward the quiet wait.
|
|
43
|
+
{
|
|
44
|
+
const quiet = Gate.makeGate();
|
|
45
|
+
Gate.arm(quiet, 1000, 0);
|
|
46
|
+
assert.equal(Gate.askQuiet(quiet, 2000), false, 'not before the page is shown');
|
|
47
|
+
assert.equal(Gate.waited(quiet, 2500, true), false);
|
|
48
|
+
assert.equal(quiet.visibleAt, 2500);
|
|
49
|
+
Gate.suspendReply(quiet, 2590);
|
|
50
|
+
assert.equal(quiet.visibleAt, null, 'a hide ends the showing');
|
|
51
|
+
assert.equal(Gate.askQuiet(quiet, 3100), false, 'hidden time does not count');
|
|
52
|
+
Gate.waited(quiet, 3100, true);
|
|
53
|
+
assert.equal(Gate.askQuiet(quiet, 3100 + Gate.RESYNC_QUIET_MS - 1), false);
|
|
54
|
+
assert.equal(Gate.ask(quiet, 3100 + Gate.RESYNC_QUIET_MS), false, 'the pre-drain ask leaves a short away alone');
|
|
55
|
+
assert.equal(Gate.askQuiet(quiet, 3100 + Gate.RESYNC_QUIET_MS), true, 'a quiet return asks early');
|
|
56
|
+
assert.equal(quiet.replyAfter, 3100 + Gate.RESYNC_QUIET_MS);
|
|
57
|
+
assert.equal(Gate.askQuiet(quiet, 9000), false, 'once per showing');
|
|
58
|
+
assert.equal(Gate.ask(quiet, 9000), false, 'and not again before the drain');
|
|
59
|
+
// Only a WORLD after the latest request answers it.
|
|
60
|
+
assert.equal(Gate.current(quiet, { k: 'w', localMs: 3300 }), false, 'a WORLD from before the request');
|
|
61
|
+
assert.equal(Gate.current(quiet, { k: 'w', localMs: 3400 }), true);
|
|
62
|
+
assert.equal(Gate.current(quiet, { k: 's', t: 1e9, localMs: 3400 }), false, 'no broadcast once asked');
|
|
63
|
+
// Hidden with the request out: the return asks again, and only that reply counts.
|
|
64
|
+
Gate.suspendReply(quiet, 3500);
|
|
65
|
+
assert.equal(quiet.reask, true);
|
|
66
|
+
assert.equal(Gate.ask(quiet, 4000), true, 'the return asks again');
|
|
67
|
+
assert.equal(Gate.ask(quiet, 4100), false, 'once');
|
|
68
|
+
assert.equal(Gate.current(quiet, { k: 'w', localMs: 3600 }), false, 'a reply that came while hidden');
|
|
69
|
+
assert.equal(Gate.current(quiet, { k: 'w', localMs: 4050 }), true, 'the new reply');
|
|
70
|
+
const dropped = Gate.makeGate();
|
|
71
|
+
Gate.arm(dropped, 1000, 0);
|
|
72
|
+
Gate.waited(dropped, 1500, true);
|
|
73
|
+
Gate.noteConnection(dropped, false, 1600);
|
|
74
|
+
assert.equal(Gate.askQuiet(dropped, 9000), false, 'a dropped connection is never asked');
|
|
75
|
+
assert.equal(Gate.ask(dropped, 9000), false);
|
|
76
|
+
}
|
|
77
|
+
|
|
39
78
|
// The real transport wrapper, with only SDK acquisition replaced. Calling a
|
|
40
79
|
// method on the connection must preserve its receiver; old SDKs have no method.
|
|
41
80
|
register(`data:text/javascript,${encodeURIComponent(`
|