castle-web-cli 0.4.253 → 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/hubEntry.js +13 -4
- package/kits/hub-game/code/client/hudTree.js +9 -1
- package/kits/hub-game/code/client/safeLayout.js +137 -1
- package/kits/hub-game/code/client/safeStyle.js +1 -1
- package/kits/hub-game/code/systems/hub.js +5 -1
- package/kits/hub-game/docs/contract.md +12 -3
- package/kits/hub-game/scripts/fixtures/hud-surface.json +7 -7
- package/kits/hub-game/scripts/test-hub-entry.mjs +27 -5
- package/kits/hub-game/scripts/test-hud-back-dom.mjs +138 -0
- 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
|
@@ -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(`
|