castle-web-cli 0.4.238 → 0.4.240
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/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +218 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +22 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +4 -2
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +12 -3
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +2 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +240 -8
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +8 -2
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +79 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +198 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/castle.json +4 -4
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +474 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +75 -52
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +215 -26
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +40 -15
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +854 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +437 -57
- package/kits/hub-game/docs/analytics.md +20 -3
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +80 -1
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-resync.mjs +13 -0
- package/kits/hub-game/scripts/test-role-client.mjs +10 -3
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -55,6 +55,8 @@ register(`data:text/javascript,${encodeURIComponent(`
|
|
|
55
55
|
return next(u, c);
|
|
56
56
|
}
|
|
57
57
|
`)}`);
|
|
58
|
+
// multiplayer.js's JOIN_STALL_MS: a frame gap that reads as a suspended page.
|
|
59
|
+
const JOIN_STALL_MS = 10000;
|
|
58
60
|
let now = 1000;
|
|
59
61
|
Object.defineProperty(globalThis, 'performance', { value: { now: () => now }, configurable: true });
|
|
60
62
|
const warnings = [];
|
|
@@ -212,7 +214,8 @@ await check('queued WORLD placement at 15.1s survives stalls and visible returns
|
|
|
212
214
|
});
|
|
213
215
|
await check('connected unplaced nets survive returns without WORLD and retain their visible watchdog budget', async () => {
|
|
214
216
|
const { system } = setup(); const n = await connect();
|
|
215
|
-
step(19000); frame(
|
|
217
|
+
step(19000); frame(JOIN_STALL_MS + 100);
|
|
218
|
+
assert.equal(system.net, n, 'a long freeze never discards a connected net');
|
|
216
219
|
visibility(true); now += 120000; visibility(false); frame();
|
|
217
220
|
assert.equal(system.net, n); assert.equal(attempts.length, 1);
|
|
218
221
|
assert.equal(system.joinAttempt.visibleMs, 19000, 'parked time is excluded');
|
|
@@ -254,11 +257,59 @@ await check('hidden time spends no watchdog budget; attempts started hidden refr
|
|
|
254
257
|
});
|
|
255
258
|
await check('frame gaps without visibilitychange refresh pending and disconnected joins', async () => {
|
|
256
259
|
for (const assigned of [false, true]) {
|
|
257
|
-
const { system } = setup();
|
|
260
|
+
const { system } = setup(); const old = assigned ? await connect() : null;
|
|
261
|
+
if (old) { old.state = 'reconnecting'; }
|
|
262
|
+
frame(JOIN_STALL_MS - 100);
|
|
263
|
+
assert.equal(attempts.length, 1, 'just under the threshold is a hitch');
|
|
264
|
+
frame(JOIN_STALL_MS + 100);
|
|
258
265
|
assert.equal(attempts.length, 2); assert.equal(stages('visible rejoin').length, 1);
|
|
266
|
+
assert.equal(old?.closes ?? 0, assigned ? 1 : 0);
|
|
259
267
|
assert.equal(stages('watchdog abort').length, 0); assert.equal(system.joinFailures, 1);
|
|
260
268
|
}
|
|
261
269
|
});
|
|
270
|
+
await check('load hitches under JOIN_STALL_MS keep the first join and count no failure', async () => {
|
|
271
|
+
// A cold Town load: the first tick after the attempt starts lands 1.6 s
|
|
272
|
+
// later, and more hitches follow while the world builds.
|
|
273
|
+
for (const kind of ['pending', 'connecting', 'connected', 'reconnecting']) {
|
|
274
|
+
const { system } = setup();
|
|
275
|
+
frame(1600);
|
|
276
|
+
let n = null;
|
|
277
|
+
if (kind !== 'pending') { n = await connect(); n.state = kind === 'connected' ? 'connected' : kind; }
|
|
278
|
+
frame(1100); step(300); frame(4000); step(200); frame(9000);
|
|
279
|
+
assert.equal(attempts.length, 1, `${kind}: no new attempt`);
|
|
280
|
+
assert.equal(stages('visible rejoin').length, 0, kind);
|
|
281
|
+
assert.equal(stages('failure').length, 0, kind);
|
|
282
|
+
assert.equal(stages('watchdog abort').length, 0, kind);
|
|
283
|
+
assert.equal(system.joinFailures, 0, kind);
|
|
284
|
+
assert.equal(n?.closes ?? 0, 0, `${kind}: the assigned net stays open`);
|
|
285
|
+
if (!n) { n = await connect(); }
|
|
286
|
+
assert.equal(system.net, n);
|
|
287
|
+
n.state = 'connected'; placed(n);
|
|
288
|
+
assert.equal(stages('placed')[0].attempt, 1, `${kind}: placed on attempt 1`);
|
|
289
|
+
assert.equal(n.closes, 0); assert.equal(system.joinFailures, 0);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
await check('hitches spend the visible watchdog budget; a placement queued on that frame still wins', async () => {
|
|
293
|
+
const { system } = setup(); const n = await connect(); n.state = 'connecting';
|
|
294
|
+
step(12000); frame(9000);
|
|
295
|
+
assert.equal(system.joinAttempt.visibleMs, 21000, 'a hitch is visible wall time');
|
|
296
|
+
assert.equal(stages('watchdog abort').length, 1, 'over 20 s of visible time is a timeout');
|
|
297
|
+
assert.equal(n.closes, 1); assert.equal(system.joinFailures, 1);
|
|
298
|
+
const { system: again } = setup(); const m = await connect(); m.state = 'connecting';
|
|
299
|
+
step(12000); now += 9000;
|
|
300
|
+
m.inbox.push({ k: 'w', t: now, localMs: now, ps: [['self', 0, 0, 0, 0]], os: [], own: [] });
|
|
301
|
+
frame(); assert.equal(again.joined, true); assert.equal(m.closes, 0); assert.equal(again.joinFailures, 0);
|
|
302
|
+
});
|
|
303
|
+
await check('three load hitches in a row never show the join failure panel', async () => {
|
|
304
|
+
for (const assigned of [false, true]) {
|
|
305
|
+
const { system } = setup(); const n = assigned ? await connect() : null;
|
|
306
|
+
if (n) { n.state = 'connecting'; }
|
|
307
|
+
for (const hitch of [1600, 3000, 5000]) { frame(hitch); step(200); }
|
|
308
|
+
assert.equal(panel(), undefined); assert.equal(system.joinFailed, false);
|
|
309
|
+
assert.equal(system.joinFailures, 0); assert.equal(attempts.length, 1);
|
|
310
|
+
assert.equal(stages('gave up').length, 0);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
262
313
|
await check('three mixed failures stop retries; body panel and Retry recover exactly once', async () => {
|
|
263
314
|
const { system, scene } = setup();
|
|
264
315
|
const hubCover = makeLoadingCover({ enabled: true, title: 'Town', document });
|
|
@@ -380,7 +431,7 @@ await check('destination cancellation cannot fall back publicly and cancel its r
|
|
|
380
431
|
const join = (options) => { attempts.push({ options }); return connectSession(options); };
|
|
381
432
|
const { system } = setup(target, join);
|
|
382
433
|
assert.equal(destinations.length, 1);
|
|
383
|
-
frame(
|
|
434
|
+
frame(JOIN_STALL_MS + 100); // the parked acquisition is abandoned and a fresh one starts
|
|
384
435
|
await settle();
|
|
385
436
|
assert.equal(destinations.length, 2);
|
|
386
437
|
assert.equal(envelopes.filter((e) => e.cancel).length, 1, 'SDK cancels only the old acquisition');
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// Real Rapier bodies and the kit's actual ownership/world handlers: accepted
|
|
2
|
+
// targets do not become body positions until physics steps. Reports may arrive
|
|
3
|
+
// together, so both their positional baseline and earned allowance must survive
|
|
4
|
+
// more than one report between steps.
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
7
|
+
import { loadKit } from './ownership-harness.mjs';
|
|
8
|
+
|
|
9
|
+
const { Ownership, World } = await loadKit({
|
|
10
|
+
ground: { none: true },
|
|
11
|
+
actors: [{
|
|
12
|
+
id: 'pal',
|
|
13
|
+
components: {
|
|
14
|
+
Transform: { x: 0, y: 3, z: 0 },
|
|
15
|
+
Shape: { kind: 'sphere', radius: 0.2 },
|
|
16
|
+
Body: { type: 'dynamic', gravityScale: 0 },
|
|
17
|
+
},
|
|
18
|
+
}],
|
|
19
|
+
});
|
|
20
|
+
const Players = await import('../code/server/players.js');
|
|
21
|
+
const Limits = await import('../code/server/limits.js');
|
|
22
|
+
|
|
23
|
+
let passed = 0;
|
|
24
|
+
async function test(name, run) {
|
|
25
|
+
const sim = await World.createSimulation();
|
|
26
|
+
try {
|
|
27
|
+
Players.addPlayer(sim, 'cook', [0, 0, 0, 0]);
|
|
28
|
+
Players.addPlayer(sim, 'guest', [0, 0, 0, 0]);
|
|
29
|
+
Ownership.claim(sim, 'cook', ['pal'], []);
|
|
30
|
+
const entry = sim.objects.get('pal');
|
|
31
|
+
assert.equal(entry.owner, 'cook');
|
|
32
|
+
let seq = 0;
|
|
33
|
+
const handovers = [];
|
|
34
|
+
const report = (x, player = 'cook', epoch = entry.epoch) => {
|
|
35
|
+
Ownership.setObjectPoses(sim, player, [
|
|
36
|
+
['pal', x, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, epoch, ++seq, 0],
|
|
37
|
+
], handovers);
|
|
38
|
+
};
|
|
39
|
+
await run({ sim, entry, report, handovers });
|
|
40
|
+
passed += 1;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
console.error(`test-owned-moves: ${name}`);
|
|
43
|
+
throw err;
|
|
44
|
+
} finally {
|
|
45
|
+
sim.world.free();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (const speed of [4, 8]) {
|
|
50
|
+
for (const count of [2, 3]) {
|
|
51
|
+
await test(`${count} reports bunched at ${speed} m/s keep ownership`, ({ sim, entry, report, handovers }) => {
|
|
52
|
+
let x = 0;
|
|
53
|
+
for (let burst = 0; burst < 12; burst++) {
|
|
54
|
+
World.step(sim, count * 0.1);
|
|
55
|
+
const stepped = entry.body.translation().x;
|
|
56
|
+
for (let i = 0; i < count; i++) {
|
|
57
|
+
x += speed * 0.1;
|
|
58
|
+
report(x);
|
|
59
|
+
assert.equal(entry.owner, 'cook', `burst ${burst}, report ${i}`);
|
|
60
|
+
assert.equal(entry.body.translation().x, stepped, 'the pending target has not stepped');
|
|
61
|
+
}
|
|
62
|
+
assert.equal(entry.pose.at.x, x);
|
|
63
|
+
assert.equal(Ownership.acks(sim).length, 1, 'the newest accepted report is acknowledged');
|
|
64
|
+
World.step(sim, 1 / 60);
|
|
65
|
+
assert.ok(Math.abs(entry.body.translation().x - x) < 1e-4);
|
|
66
|
+
}
|
|
67
|
+
assert.deepEqual(handovers, []);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const cadence of [100, 150, 200, 250]) {
|
|
73
|
+
for (const speed of [4, 8]) {
|
|
74
|
+
await test(`${cadence} ms cadence with jitter at ${speed} m/s keeps ownership`, ({ sim, entry, report, handovers }) => {
|
|
75
|
+
const jitter = [0, 40, -20, 60, 0, -30];
|
|
76
|
+
let receivedAt = 0;
|
|
77
|
+
for (let i = 0; i < 30; i++) {
|
|
78
|
+
const next = (i + 1) * cadence + jitter[i % jitter.length];
|
|
79
|
+
World.step(sim, (next - receivedAt) / 1000);
|
|
80
|
+
receivedAt = next;
|
|
81
|
+
report(speed * (i + 1) * cadence / 1000);
|
|
82
|
+
Ownership.sweepOwners(sim, handovers);
|
|
83
|
+
assert.equal(entry.owner, 'cook', `report ${i}`);
|
|
84
|
+
}
|
|
85
|
+
assert.deepEqual(handovers, []);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await test('a 5 m jump with no elapsed time returns the object to the server', ({ entry, report, handovers }) => {
|
|
91
|
+
const epoch = entry.epoch;
|
|
92
|
+
report(5);
|
|
93
|
+
assert.equal(entry.owner, null);
|
|
94
|
+
assert.equal(entry.epoch, epoch + 1);
|
|
95
|
+
assert.equal(entry.body.bodyType(), RAPIER.RigidBodyType.Dynamic);
|
|
96
|
+
assert.equal(entry.body.translation().x, 0, 'the rejected target is never applied');
|
|
97
|
+
assert.equal(entry.ack, null);
|
|
98
|
+
assert.equal(handovers.length, 1);
|
|
99
|
+
assert.equal(handovers[0][1], 0);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
await test('a burst spends elapsed allowance once, not once per report', ({ sim, entry, report }) => {
|
|
103
|
+
World.step(sim, 0.15);
|
|
104
|
+
for (const x of [2, 4, 6]) {
|
|
105
|
+
report(x);
|
|
106
|
+
assert.equal(entry.owner, 'cook');
|
|
107
|
+
assert.equal(entry.body.translation().x, 0);
|
|
108
|
+
}
|
|
109
|
+
report(7);
|
|
110
|
+
assert.equal(entry.owner, null, '7 m exceeds 40 m/s * 0.15 s + 0.6 m');
|
|
111
|
+
assert.equal(entry.body.translation().x, 6, 'handover applies the last accepted target');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await test('zero-time reports cannot each mint another delivery slack', ({ entry, report }) => {
|
|
115
|
+
report(0.4);
|
|
116
|
+
assert.equal(entry.owner, 'cook');
|
|
117
|
+
report(0.8);
|
|
118
|
+
assert.equal(entry.owner, null, 'the burst exceeds the single 0.6 m slack');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
for (const idle of ['long gap', 'many stationary reports']) {
|
|
122
|
+
await test(`${idle} cannot bank more than the elapsed cap`, ({ sim, entry, report }) => {
|
|
123
|
+
if (idle === 'long gap') {
|
|
124
|
+
// Exercise the receipt handler before its next timeout sweep, as after a
|
|
125
|
+
// stalled event loop: even this cannot spend ten seconds of allowance.
|
|
126
|
+
World.step(sim, 10);
|
|
127
|
+
} else {
|
|
128
|
+
for (let i = 0; i < 50; i++) {
|
|
129
|
+
World.step(sim, 0.1);
|
|
130
|
+
report(0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const cap = Limits.MAX_OBJECT_SPEED * Limits.OWNER_TIMEOUT_MS / 1000 + Limits.MOVE_SLACK;
|
|
134
|
+
report(cap / 2);
|
|
135
|
+
assert.equal(entry.owner, 'cook');
|
|
136
|
+
report(cap - 0.01);
|
|
137
|
+
assert.equal(entry.owner, 'cook');
|
|
138
|
+
report(cap + 0.01);
|
|
139
|
+
assert.equal(entry.owner, null, 'the whole burst, not each report, shares the capped bank');
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Any single report the old per-report rule (speed times the gap, plus
|
|
144
|
+
// slack) accepted inside the ownership timeout is still accepted.
|
|
145
|
+
for (const [speed, gapMs] of [[30, 1000], [16, 1400], [38, 1450], [8, 600]]) {
|
|
146
|
+
await test(`a ${speed} m/s move after a ${gapMs} ms gap keeps ownership`, ({ sim, entry, report }) => {
|
|
147
|
+
World.step(sim, gapMs / 1000);
|
|
148
|
+
report(speed * gapMs / 1000);
|
|
149
|
+
assert.equal(entry.owner, 'cook');
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await test('a new grant clears the old pending pose, target and unused movement budget', ({ sim, entry, report, handovers }) => {
|
|
154
|
+
World.step(sim, 0.5);
|
|
155
|
+
const oldEpoch = entry.epoch;
|
|
156
|
+
report(8);
|
|
157
|
+
assert.equal(entry.owner, 'cook');
|
|
158
|
+
assert.equal(entry.pose.at.x, 8);
|
|
159
|
+
assert.equal(entry.body.translation().x, 0, 'the old owner has an unstepped target');
|
|
160
|
+
sim.players.get('cook').at.x = 4;
|
|
161
|
+
Ownership.claim(sim, 'guest', ['pal'], handovers);
|
|
162
|
+
assert.equal(entry.owner, 'guest');
|
|
163
|
+
assert.equal(entry.epoch, oldEpoch + 1);
|
|
164
|
+
assert.equal(entry.pose, null);
|
|
165
|
+
// Step Rapier without advancing simulation time, isolating the old target
|
|
166
|
+
// from any new movement allowance.
|
|
167
|
+
sim.world.step();
|
|
168
|
+
assert.equal(entry.body.translation().x, 0, 'the previous grant cannot move the body');
|
|
169
|
+
report(0, 'guest');
|
|
170
|
+
assert.equal(entry.owner, 'guest', 'the grant starts from its body, not the old target at 8 m');
|
|
171
|
+
report(5, 'guest');
|
|
172
|
+
assert.equal(entry.owner, null, 'the guest cannot spend the old owner\'s unused bank');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
await test('a grant after server movement starts from the current server body', ({ sim, entry, report }) => {
|
|
176
|
+
World.step(sim, 0.5);
|
|
177
|
+
report(8);
|
|
178
|
+
Ownership.release(sim, 'cook', ['pal'], []);
|
|
179
|
+
entry.body.setTranslation({ x: 20, y: 3, z: 0 }, true);
|
|
180
|
+
sim.players.get('guest').at.x = 20;
|
|
181
|
+
Ownership.claim(sim, 'guest', ['pal'], []);
|
|
182
|
+
assert.equal(entry.owner, 'guest');
|
|
183
|
+
assert.equal(entry.pose, null);
|
|
184
|
+
report(20, 'guest');
|
|
185
|
+
assert.equal(entry.owner, 'guest');
|
|
186
|
+
report(8, 'guest');
|
|
187
|
+
assert.equal(entry.owner, null, 'the old accepted pose is no longer a baseline');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
console.log(`test-owned-moves: ${passed} passed (real Rapier; bursts, jitter, teleport rejection, capped bank, fresh grants)`);
|
|
@@ -30,7 +30,8 @@ const stubs = {
|
|
|
30
30
|
'export const connectSession = async (options) => { globalThis.__connect = options; return globalThis.__net; };',
|
|
31
31
|
'@imports/castle.real-time/code/client/soloBadge.js': 'export const showSoloBadge = () => {}; export const updateSoloBadge = () => {};',
|
|
32
32
|
'@imports/castle.real-time/code/client/joinOverlay.js':
|
|
33
|
-
|
|
33
|
+
// A cover with no words (a return's quiet first QUIET_RETURN_MS) is still a cover.
|
|
34
|
+
'export const showJoinOverlay = (visible, text) => { globalThis.__cover = visible ? (text ?? "Joining…") || "(no words)" : null; };',
|
|
34
35
|
'@imports/castle.real-time/code/client/gameHooks.js': 'export const game = {};',
|
|
35
36
|
};
|
|
36
37
|
register(
|
|
@@ -73,8 +74,12 @@ globalThis.document = {
|
|
|
73
74
|
removeEventListener: (type) => listeners.delete(type),
|
|
74
75
|
};
|
|
75
76
|
const quiet = console.log;
|
|
77
|
+
const warnings = [];
|
|
76
78
|
console.log = (...args) => (String(args[0]).startsWith('[multiplayer]') ? undefined : quiet(...args));
|
|
77
|
-
console.warn = (...args) =>
|
|
79
|
+
console.warn = (...args) => {
|
|
80
|
+
warnings.push(args);
|
|
81
|
+
if (!String(args[0]).startsWith('[multiplayer]')) quiet(...args);
|
|
82
|
+
};
|
|
78
83
|
|
|
79
84
|
const { installSystem } = await import('../code/systems/multiplayer.js');
|
|
80
85
|
|
|
@@ -118,6 +123,7 @@ async function makeRoom({ objects, players = {} }) {
|
|
|
118
123
|
frames: [],
|
|
119
124
|
// What the client sent the session.
|
|
120
125
|
outbox: [],
|
|
126
|
+
forcedReconnects: 0,
|
|
121
127
|
};
|
|
122
128
|
for (const id of Object.keys(objects)) {
|
|
123
129
|
room.actors.set(id, { id, components: { Transform: { x: 0, y: 0, z: 0 } } });
|
|
@@ -133,6 +139,12 @@ async function makeRoom({ objects, players = {} }) {
|
|
|
133
139
|
send: (msg) => room.outbox.push(msg),
|
|
134
140
|
closed: () => false,
|
|
135
141
|
close() {},
|
|
142
|
+
reconnect: () => {
|
|
143
|
+
room.forcedReconnects++;
|
|
144
|
+
room.state = 'reconnecting';
|
|
145
|
+
room.socket = false;
|
|
146
|
+
return true;
|
|
147
|
+
},
|
|
136
148
|
};
|
|
137
149
|
// This player, whose body the session's WORLD placement moves.
|
|
138
150
|
const local = { id: 'local', components: { Transform: { x: 0, y: 0, z: 0 } } };
|
|
@@ -325,7 +337,7 @@ async function prismReturn(awayMs, { reconnectEvent = true } = {}) {
|
|
|
325
337
|
|
|
326
338
|
hide(room);
|
|
327
339
|
if (!baseline) {
|
|
328
|
-
assert.equal(globalThis.__cover, '
|
|
340
|
+
assert.equal(globalThis.__cover, '(no words)', 'the cover is up, with no words, before the page goes');
|
|
329
341
|
}
|
|
330
342
|
run(room, pageMs + 500);
|
|
331
343
|
room.socket = false;
|
|
@@ -627,7 +639,7 @@ if (baseline) {
|
|
|
627
639
|
room.lastFrame = pageMs - FRAME_MS;
|
|
628
640
|
frame(room);
|
|
629
641
|
assert.equal(room.system.resume.armed, true, 'a long frame gap arms the gate');
|
|
630
|
-
assert.equal(globalThis.__cover, '
|
|
642
|
+
assert.equal(globalThis.__cover, '(no words)', 'a return says nothing at first');
|
|
631
643
|
assert.equal(room.system.resume.since, paused);
|
|
632
644
|
room.sentObjects.clear();
|
|
633
645
|
run(room, pageMs + 200);
|
|
@@ -692,5 +704,179 @@ if (baseline) {
|
|
|
692
704
|
assert.equal(room.system.resume.armed, false, 'solo play has nothing to wait for');
|
|
693
705
|
}
|
|
694
706
|
|
|
707
|
+
// A half-open socket: it still reports connected after a long app switch,
|
|
708
|
+
// accepts the resync, and delivers nothing. Keep page time deterministic so
|
|
709
|
+
// the deadline and the order of receive versus recovery are checked exactly.
|
|
710
|
+
async function silentReturn({ resyncs = true, limit = 3000 } = {}) {
|
|
711
|
+
const room = await makeRoom({ objects: { 'b0-beam-3': BEAM_OLD } });
|
|
712
|
+
assert.equal(room.system.resyncReplyMs, 3000);
|
|
713
|
+
room.system.resyncReplyMs = limit;
|
|
714
|
+
deliver(room, world(room, { rs: resyncs ? 1 : 0 }), pageMs);
|
|
715
|
+
run(room, pageMs + 2000);
|
|
716
|
+
hide(room);
|
|
717
|
+
room.socket = false;
|
|
718
|
+
pageMs += 180000;
|
|
719
|
+
show(room);
|
|
720
|
+
frame(room);
|
|
721
|
+
return room;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
{
|
|
725
|
+
const room = await silentReturn();
|
|
726
|
+
const askedAt = room.system.resume.askedAt;
|
|
727
|
+
const warned = warnings.length;
|
|
728
|
+
run(room, askedAt + 2999);
|
|
729
|
+
assert.equal(room.forcedReconnects, 0, 'no forced recovery before the reply deadline');
|
|
730
|
+
pageMs = askedAt + 3000;
|
|
731
|
+
frame(room);
|
|
732
|
+
assert.equal(room.forcedReconnects, 1, 'a silent return forces recovery at the deadline');
|
|
733
|
+
assert.equal(room.state, 'reconnecting');
|
|
734
|
+
assert.deepEqual(warnings.slice(warned), [['[multiplayer] resync unanswered; reconnecting']]);
|
|
735
|
+
run(room, pageMs + 100);
|
|
736
|
+
assert.equal(room.system.resume.dropped, true, 'the next frame notes the SDK drop');
|
|
737
|
+
let named = 0, returned = 0;
|
|
738
|
+
const nameScene = room.system.nameScene.bind(room.system);
|
|
739
|
+
const reconnected = room.system.reconnected.bind(room.system);
|
|
740
|
+
room.system.nameScene = (...args) => { named++; nameScene(...args); };
|
|
741
|
+
room.system.reconnected = () => { returned++; reconnected(); };
|
|
742
|
+
reconnect(room);
|
|
743
|
+
assert.equal(named, 1, 'onConnected names the scene again');
|
|
744
|
+
assert.equal(returned, 1, 'onConnected runs the ordinary reconnect handler');
|
|
745
|
+
deliver(room, world(room), askedAt - 1);
|
|
746
|
+
run(room, pageMs + 500);
|
|
747
|
+
assert.equal(room.system.resume.armed, true, 'broadcasts and a WORLD from before return do not release it');
|
|
748
|
+
assert.equal(room.outbox.filter((m) => m.k === 'r').length, 1, 'recovery does not ask for another resync');
|
|
749
|
+
room.objects['b0-beam-3'] = BEAM_NOW;
|
|
750
|
+
deliver(room, world(room, { rs: 1 }));
|
|
751
|
+
run(room, pageMs + 800);
|
|
752
|
+
assert.equal(room.system.resume.armed, false, 'only the WORLD after return releases it');
|
|
753
|
+
assert.equal(room.forcedReconnects, 1);
|
|
754
|
+
assert.equal(globalThis.__cover, null);
|
|
755
|
+
assert.ok(offBy(room.frames.at(-1).drawn['b0-beam-3'], BEAM_NOW) < TOLERANCE);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// Drain before checking the timer: even a reply queued at the deadline wins.
|
|
759
|
+
for (const elapsed of [2999, 3000]) {
|
|
760
|
+
const room = await silentReturn();
|
|
761
|
+
run(room, room.system.resume.askedAt + elapsed - FRAME_MS);
|
|
762
|
+
pageMs = room.system.resume.askedAt + elapsed;
|
|
763
|
+
deliver(room, world(room, { rs: 1, again: 1 }), pageMs);
|
|
764
|
+
frame(room);
|
|
765
|
+
run(room, pageMs + 4000);
|
|
766
|
+
assert.equal(room.system.resume.armed, false, 'a current resync WORLD releases the gate');
|
|
767
|
+
assert.equal(room.forcedReconnects, 0, 'a timely WORLD prevents recovery');
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// These sessions retain the existing ten-second give-up and never force a
|
|
771
|
+
// reconnect: no resync support, a disabled limit, or a drop already observed.
|
|
772
|
+
for (const options of [{ resyncs: false }, { limit: 0 }, { limit: -1 }, { dropped: true }]) {
|
|
773
|
+
const room = await silentReturn(options);
|
|
774
|
+
if (options.dropped) room.state = 'reconnecting';
|
|
775
|
+
run(room, pageMs + 11000);
|
|
776
|
+
assert.equal(room.forcedReconnects, 0, JSON.stringify(options));
|
|
777
|
+
assert.equal(room.system.resume.armed, false, 'the ordinary give-up remains');
|
|
778
|
+
assert.equal(room.outbox.filter((m) => m.k === 'r').length, options.resyncs === false ? 0 : 1);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
{
|
|
782
|
+
const room = await silentReturn();
|
|
783
|
+
hide(room);
|
|
784
|
+
pageMs += 11000; // longer than the give-up, which must not be spent while hidden
|
|
785
|
+
frame(room); // a hidden page can still get a frame
|
|
786
|
+
assert.equal(room.forcedReconnects, 0, 'a hidden page never forces recovery');
|
|
787
|
+
show(room);
|
|
788
|
+
frame(room);
|
|
789
|
+
assert.equal(room.forcedReconnects, 0, 'hiding restarts the wait, so a return is not condemned on its first frame');
|
|
790
|
+
pageMs += 2999;
|
|
791
|
+
frame(room);
|
|
792
|
+
assert.equal(room.forcedReconnects, 0);
|
|
793
|
+
pageMs += 1;
|
|
794
|
+
frame(room);
|
|
795
|
+
assert.equal(room.forcedReconnects, 1, 'the restarted wait still ends in one forced recovery');
|
|
796
|
+
run(room, pageMs + 11000);
|
|
797
|
+
assert.equal(room.forcedReconnects, 1, 'a failed reconnect is attempted only once per away');
|
|
798
|
+
assert.equal(room.system.resume.armed, false, 'failed recovery still reaches the ten-second give-up');
|
|
799
|
+
assert.equal(room.system.gaveUp, true);
|
|
800
|
+
assert.equal(globalThis.__cover, null);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
{
|
|
804
|
+
// Hiding over and over reaches both limits on visible time alone.
|
|
805
|
+
const room = await silentReturn();
|
|
806
|
+
for (let i = 0; i < 100 && room.system.resume.armed; i += 1) {
|
|
807
|
+
hide(room);
|
|
808
|
+
pageMs += 2000;
|
|
809
|
+
show(room);
|
|
810
|
+
frame(room);
|
|
811
|
+
pageMs += 1000;
|
|
812
|
+
frame(room);
|
|
813
|
+
}
|
|
814
|
+
assert.equal(room.forcedReconnects, 1, 'repeated hides still force recovery once');
|
|
815
|
+
assert.equal(room.system.resume.armed, false, 'repeated hides still reach the give-up');
|
|
816
|
+
assert.equal(room.system.gaveUp, true);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
{
|
|
820
|
+
const room = await silentReturn();
|
|
821
|
+
delete room.system.net.reconnect; // the optional wrapper may itself be older
|
|
822
|
+
const warned = warnings.length;
|
|
823
|
+
run(room, pageMs + 11000);
|
|
824
|
+
assert.equal(warnings.slice(warned).filter(([m]) => m === '[multiplayer] resync unanswered; reconnecting').length, 1);
|
|
825
|
+
assert.equal(room.system.resume.armed, false, 'an older wrapper still gives up normally');
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
for (const action of ['close', 'switch']) {
|
|
829
|
+
const room = await silentReturn();
|
|
830
|
+
const old = room.system.net;
|
|
831
|
+
if (action === 'close') {
|
|
832
|
+
old.closed = () => true;
|
|
833
|
+
} else {
|
|
834
|
+
room.system.switchSession(room.scene, { mode: 'named', key: 'next' }, { quiet: true });
|
|
835
|
+
await Promise.resolve();
|
|
836
|
+
assert.equal(room.system.resume.askedAt, null, 'switching clears the old reply deadline');
|
|
837
|
+
}
|
|
838
|
+
pageMs += 4000;
|
|
839
|
+
frame(room);
|
|
840
|
+
assert.equal(room.forcedReconnects, 0, `${action} never recovers the old session`);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// A return's cover says nothing for QUIET_RETURN_MS after the page shows
|
|
844
|
+
// again, then that it is reconnecting; hiding again starts the quiet over.
|
|
845
|
+
{
|
|
846
|
+
const room = await makeRoom({ objects: { 'b0-beam-3': BEAM_OLD } });
|
|
847
|
+
deliver(room, world(room), pageMs);
|
|
848
|
+
run(room, pageMs + 2000);
|
|
849
|
+
hide(room);
|
|
850
|
+
room.socket = false;
|
|
851
|
+
room.state = 'reconnecting';
|
|
852
|
+
pageMs += 180000;
|
|
853
|
+
room.nextTick = pageMs;
|
|
854
|
+
room.lastFrame = pageMs - FRAME_MS;
|
|
855
|
+
show(room);
|
|
856
|
+
const shown = pageMs;
|
|
857
|
+
run(room, shown + 2400);
|
|
858
|
+
assert.equal(globalThis.__cover, '(no words)', 'quiet for the first 2.5 s after the return');
|
|
859
|
+
run(room, shown + 2600);
|
|
860
|
+
assert.equal(globalThis.__cover, 'Reconnecting…', 'then it says so');
|
|
861
|
+
// A frame stall while still away is another return: quiet again.
|
|
862
|
+
pageMs += 2000;
|
|
863
|
+
room.nextTick = pageMs;
|
|
864
|
+
frame(room);
|
|
865
|
+
assert.equal(room.system.resume.armed, true);
|
|
866
|
+
assert.equal(globalThis.__cover, '(no words)', 'a stall return is quiet again');
|
|
867
|
+
run(room, pageMs + 2600);
|
|
868
|
+
assert.equal(globalThis.__cover, 'Reconnecting…');
|
|
869
|
+
// Hidden and shown: the words go at each event, before any frame.
|
|
870
|
+
hide(room);
|
|
871
|
+
assert.equal(globalThis.__cover, '(no words)', 'quiet as the page hides');
|
|
872
|
+
pageMs += 5000;
|
|
873
|
+
room.nextTick = pageMs;
|
|
874
|
+
room.lastFrame = pageMs - FRAME_MS;
|
|
875
|
+
show(room);
|
|
876
|
+
assert.equal(room.frames.at(-1).cover, '(no words)', 'the first composited frame says nothing');
|
|
877
|
+
frame(room);
|
|
878
|
+
assert.equal(globalThis.__cover, '(no words)', 'a second return is quiet again');
|
|
879
|
+
}
|
|
880
|
+
|
|
695
881
|
console.table(results);
|
|
696
|
-
console.log('test-resume-gate:
|
|
882
|
+
console.log('test-resume-gate: current snapshots release returns; silent resyncs recover once');
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Run with: node kits/multiplayer-3d/scripts/test-resync-reconnect.mjs
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { register } from 'node:module';
|
|
4
|
+
import * as Gate from '../code/client/resumeGate.js';
|
|
5
|
+
|
|
6
|
+
const gate = Gate.makeGate();
|
|
7
|
+
const limit = Gate.RESYNC_REPLY_MS;
|
|
8
|
+
assert.equal(limit, 3000);
|
|
9
|
+
assert.equal(Gate.unanswered(gate, 10000, limit), false, 'an unarmed gate does nothing');
|
|
10
|
+
Gate.arm(gate, 0, 0);
|
|
11
|
+
assert.equal(Gate.unanswered(gate, 10000, limit), false, 'no request means no timeout');
|
|
12
|
+
assert.equal(Gate.ask(gate, Gate.RESYNC_AWAY_MS - 1), false, 'a short away needs no resync');
|
|
13
|
+
assert.equal(Gate.ask(gate, 5000), true);
|
|
14
|
+
assert.equal(gate.askedAt, 5000);
|
|
15
|
+
assert.equal(Gate.ask(gate, 6000), false);
|
|
16
|
+
assert.equal(gate.askedAt, 5000, 'a repeat ask does not move the deadline');
|
|
17
|
+
assert.equal(Gate.unanswered(gate, 5000 + limit - 1, limit), false);
|
|
18
|
+
assert.equal(Gate.unanswered(gate, 5000 + limit, 0), false, 'zero disables forced recovery');
|
|
19
|
+
assert.equal(Gate.unanswered(gate, 5000 + limit, -1), false, 'negative limits disable it too');
|
|
20
|
+
assert.equal(Gate.unanswered(gate, 5000 + limit, limit), true, 'the exact deadline counts');
|
|
21
|
+
assert.equal(Gate.unanswered(gate, 5000 + 2 * limit, limit), false, 'only once per away');
|
|
22
|
+
assert.equal(Gate.arm(gate, 7000, 0), false, 'an overlapping away keeps that decision');
|
|
23
|
+
assert.equal(Gate.unanswered(gate, 20000, limit), false);
|
|
24
|
+
Gate.clear(gate);
|
|
25
|
+
assert.equal(gate.askedAt, null);
|
|
26
|
+
assert.equal(Gate.unanswered(gate, 20000, limit), false);
|
|
27
|
+
Gate.arm(gate, 10000, 0);
|
|
28
|
+
assert.equal(gate.askedAt, null);
|
|
29
|
+
assert.equal(Gate.ask(gate, 15000), true);
|
|
30
|
+
assert.equal(Gate.unanswered(gate, 15000 + limit, limit), true, 'a later away gets its own attempt');
|
|
31
|
+
Gate.clear(gate);
|
|
32
|
+
Gate.arm(gate, 20000, 0);
|
|
33
|
+
Gate.ask(gate, 25000);
|
|
34
|
+
Gate.noteConnection(gate, false, 26000);
|
|
35
|
+
assert.equal(Gate.unanswered(gate, 30000, limit), false, 'a natural drop needs no forced recovery');
|
|
36
|
+
Gate.noteConnection(gate, true, 30000);
|
|
37
|
+
assert.equal(Gate.unanswered(gate, 31000, limit), false, 'nor does that drop returning');
|
|
38
|
+
|
|
39
|
+
// The real transport wrapper, with only SDK acquisition replaced. Calling a
|
|
40
|
+
// method on the connection must preserve its receiver; old SDKs have no method.
|
|
41
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
42
|
+
export async function resolve(s, c, next) {
|
|
43
|
+
if (s === 'castle-web-sdk') {
|
|
44
|
+
return { url: 'data:text/javascript,export const Multiplayer = { join: () => globalThis.__sdkConnection };', shortCircuit: true };
|
|
45
|
+
}
|
|
46
|
+
return next(s, c);
|
|
47
|
+
}
|
|
48
|
+
`)}`);
|
|
49
|
+
const { connectSession } = await import('../../real-time/code/client/connection.js');
|
|
50
|
+
for (const support of ['absent', 'non-function', false, true]) {
|
|
51
|
+
let calls = 0;
|
|
52
|
+
const connection = {
|
|
53
|
+
onMessage() {}, onRoster() {}, onStateChange() {},
|
|
54
|
+
...(support === 'absent' ? {} : {
|
|
55
|
+
reconnect: support === 'non-function' ? null : function () {
|
|
56
|
+
assert.equal(this, connection);
|
|
57
|
+
calls++;
|
|
58
|
+
return support;
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
globalThis.__sdkConnection = connection;
|
|
63
|
+
const net = await connectSession();
|
|
64
|
+
assert.equal(net.reconnect(), support === true);
|
|
65
|
+
assert.equal(calls, typeof support === 'boolean' ? 1 : 0);
|
|
66
|
+
}
|
|
67
|
+
delete globalThis.__sdkConnection;
|
|
68
|
+
console.log('test-resync-reconnect: one-shot reply deadline and SDK feature detection passed');
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"onUpdate": "scripts/onUpdate.mjs",
|
|
69
69
|
"title": "physics-2d",
|
|
70
70
|
"description": "Scene Editor. Works like classic Castle: actors, blueprints, behaviors and drawing tools, with physics built in.",
|
|
71
|
-
"publishedVersion": "2026-
|
|
71
|
+
"publishedVersion": "2026-11-15T00:41:50.817Z",
|
|
72
72
|
"imports": {
|
|
73
73
|
"castle.base": {
|
|
74
74
|
"deckId": "yRcmH4_aYllE",
|
|
75
|
-
"version": "2026-
|
|
75
|
+
"version": "2026-11-15T00:40:25.157Z"
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -602,10 +602,17 @@ export class SceneRuntime {
|
|
|
602
602
|
// visit awake actors. Spawns wake their ID and loads discard the sleep set.
|
|
603
603
|
#awakeActors = null;
|
|
604
604
|
#sleepingActors = null;
|
|
605
|
+
// Rendering caches can finish work for a sleep set without polling actors.
|
|
606
|
+
// Loads and replacement/removal of a sleeper invalidate that completion too.
|
|
607
|
+
#sleepVersion = 0;
|
|
608
|
+
|
|
609
|
+
get sleepVersion() { return this.#sleepVersion; }
|
|
610
|
+
get sleepingActorCount() { return this.#sleepingActors?.size ?? 0; }
|
|
605
611
|
|
|
606
612
|
setActorSleeping(actorOrId, sleeping) {
|
|
607
613
|
const actor = typeof actorOrId === 'string' ? this.actors.get(actorOrId) : actorOrId;
|
|
608
614
|
if (!actor || this.actors.get(actor.id) !== actor) return false;
|
|
615
|
+
if (this.isActorSleeping(actor) !== Boolean(sleeping)) this.#sleepVersion++;
|
|
609
616
|
this.#frozen?.mark(actor);
|
|
610
617
|
if (!sleeping && !this.#awakeActors) return true;
|
|
611
618
|
this.#awakeActors ??= new Map(this.actors);
|
|
@@ -647,6 +654,7 @@ export class SceneRuntime {
|
|
|
647
654
|
for (const system of this.systems) system.reset?.(this);
|
|
648
655
|
this.#awakeActors = null;
|
|
649
656
|
this.#sleepingActors = null;
|
|
657
|
+
this.#sleepVersion++;
|
|
650
658
|
this.data = structuredClone(sceneData);
|
|
651
659
|
this.#skipUnchanged = sceneSkipsUnchangedActors(this.data);
|
|
652
660
|
this.#nearShadowDistance = sceneNearShadowDistance(this.data);
|
|
@@ -835,7 +843,7 @@ export class SceneRuntime {
|
|
|
835
843
|
this.#initActor(next);
|
|
836
844
|
this.data.actors.push(next);
|
|
837
845
|
this.actors.set(id, next);
|
|
838
|
-
this.#sleepingActors?.delete(id)
|
|
846
|
+
if (this.#sleepingActors?.delete(id)) this.#sleepVersion++;
|
|
839
847
|
this.#awakeActors?.set(id, next);
|
|
840
848
|
this.#frozen?.add(next, true);
|
|
841
849
|
return next;
|
|
@@ -857,7 +865,7 @@ export class SceneRuntime {
|
|
|
857
865
|
this.#frozen?.remove(actor);
|
|
858
866
|
if (this.#still !== null && this.#still.delete(actor)) this.#stillVersion = nextStillVersion();
|
|
859
867
|
this.actors.delete(actorId);
|
|
860
|
-
this.#sleepingActors?.delete(actorId)
|
|
868
|
+
if (this.#sleepingActors?.delete(actorId)) this.#sleepVersion++;
|
|
861
869
|
this.#awakeActors?.delete(actorId);
|
|
862
870
|
const idx = this.data.actors.findIndex((a) => a.id === actorId);
|
|
863
871
|
if (idx !== -1) this.data.actors.splice(idx, 1);
|