castle-web-cli 0.4.239 → 0.4.241
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 +163 -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 +6 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +2 -0
- package/dist/platformDoc.js +3 -2
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +1 -0
- package/dist/roomLogs.js +30 -6
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -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 +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- 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/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/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 +481 -57
- 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/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/padCues.js +11 -7
- package/kits/hub-game/code/client/padReadability.js +3 -3
- 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 +72 -51
- 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 +205 -25
- 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 +35 -3
- 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/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 +991 -72
- 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/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 +14 -2
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/standing.js +7 -3
- 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/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 +429 -55
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +956 -101
- 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 +79 -0
- 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 +421 -4
- 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-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 +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- 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-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- 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-pad-cues.mjs +39 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +648 -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 +242 -3
- 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-role-client.mjs +2 -1
- 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-standing.mjs +135 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +36 -1
- 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-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 +68 -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 +340 -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 +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +66 -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 +108 -18
- 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 +417 -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-coaxial-escape.mjs +176 -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 +59 -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
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
// v1.169 client: the player's own door end (`hub-end` with `door`) in a place
|
|
2
|
+
// without a result, taken while the connection was away, is cancelled rather
|
|
3
|
+
// than retried after reconnect, and `hub-stay` goes once the session has the
|
|
4
|
+
// player again. Any other end is retried and completes as before. Runs the
|
|
5
|
+
// production client system (code/systems/hub.js) with castle-web-sdk and the
|
|
6
|
+
// pack loader stubbed, as test-hub-trip does. `npm run check` runs this.
|
|
7
|
+
import assert from 'node:assert/strict';
|
|
8
|
+
import { register } from 'node:module';
|
|
9
|
+
|
|
10
|
+
const sdkStub = 'export const Hub = globalThis.__stayHub; export const User = { getCurrent: async () => ({ userId: "101", isAnonymous: false }) };';
|
|
11
|
+
const packStub = `
|
|
12
|
+
export const loadPack = (...args) => globalThis.__stayLoadPack(...args);
|
|
13
|
+
export const cachedPacks = () => [];
|
|
14
|
+
export const matchesOwn = () => false;
|
|
15
|
+
export const resolveDeckDoor = () => Promise.reject(new Error('no dev decks here'));
|
|
16
|
+
`;
|
|
17
|
+
const mediaStub = 'export const initialMedia = {}; export const playMedia = () => {}; export const stopMedia = () => {};';
|
|
18
|
+
register(
|
|
19
|
+
'data:text/javascript,' +
|
|
20
|
+
encodeURIComponent(`
|
|
21
|
+
import { readFile } from 'node:fs/promises';
|
|
22
|
+
import { fileURLToPath } from 'node:url';
|
|
23
|
+
export async function resolve(specifier, context, next) {
|
|
24
|
+
if (['pxmodel', 'optimize', 'look', 'lookbake'].some((m) => specifier === '@imports/castle.physics-3d/engine3d/' + m)) return { url: ${JSON.stringify(new URL('./fixtures/engine-models-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
25
|
+
if (specifier === '@imports/castle.physics-3d/engine3d/orbitlens.js') return { url: ${JSON.stringify(new URL('../../physics-3d/engine3d/orbitlens.js', import.meta.url).href)}, shortCircuit: true };
|
|
26
|
+
if (specifier === '@imports/castle.real-time/code/client/messages.js') return { url: ${JSON.stringify(new URL('../../real-time/code/client/messages.js', import.meta.url).href)}, shortCircuit: true };
|
|
27
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/client/avatars.js') return { url: 'data:text/javascript,export const dropMissing = () => {};', shortCircuit: true };
|
|
28
|
+
if (specifier === 'castle-web-sdk') {
|
|
29
|
+
return { url: ${JSON.stringify('data:text/javascript,' + encodeURIComponent(sdkStub))}, shortCircuit: true };
|
|
30
|
+
}
|
|
31
|
+
if (specifier.startsWith('@imports/castle.physics-2d/engine/')) {
|
|
32
|
+
return { url: ${JSON.stringify('data:text/javascript,' + encodeURIComponent(mediaStub))}, shortCircuit: true };
|
|
33
|
+
}
|
|
34
|
+
if (specifier === '../client/pack.js') {
|
|
35
|
+
return { url: ${JSON.stringify('data:text/javascript,' + encodeURIComponent(packStub))}, shortCircuit: true };
|
|
36
|
+
}
|
|
37
|
+
return next(specifier, context);
|
|
38
|
+
}
|
|
39
|
+
export async function load(url, context, next) {
|
|
40
|
+
if (url.endsWith('/code/client/hookLayer.js')) {
|
|
41
|
+
const source = await readFile(fileURLToPath(url), 'utf8');
|
|
42
|
+
return { format: 'module', source: source.replaceAll('import.meta.glob(', '(() => ({}))('), shortCircuit: true };
|
|
43
|
+
}
|
|
44
|
+
return next(url, context);
|
|
45
|
+
}`),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const calls = [];
|
|
49
|
+
const answers = {};
|
|
50
|
+
globalThis.__stayHub = {
|
|
51
|
+
go: async (doorId) => {
|
|
52
|
+
calls.push(['go', doorId]);
|
|
53
|
+
return answers.go;
|
|
54
|
+
},
|
|
55
|
+
back: async () => {
|
|
56
|
+
calls.push(['back']);
|
|
57
|
+
if (answers.backOffline) {
|
|
58
|
+
throw new TypeError('Failed to fetch');
|
|
59
|
+
}
|
|
60
|
+
return answers.back;
|
|
61
|
+
},
|
|
62
|
+
cancel: async () => {
|
|
63
|
+
calls.push(['cancel']);
|
|
64
|
+
return { status: 'ok' };
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
globalThis.__stayLoadPack = async (sha, url) => {
|
|
68
|
+
calls.push(['loadPack', sha, url]);
|
|
69
|
+
return { id: `pack-${sha}`, sha256: sha, bytes: 10, ms: 1, cached: false, places: { main: { scene: 'scenes/town.scene', title: 'Town' } } };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const { installSystem } = await import('../code/systems/hub.js');
|
|
73
|
+
const HubState = await import('../code/client/state.js');
|
|
74
|
+
const Rehello = await import('../code/client/rehello.js');
|
|
75
|
+
const HookLayer = (await import('../code/client/hookLayer.js')).default;
|
|
76
|
+
|
|
77
|
+
const flush = async () => {
|
|
78
|
+
for (let i = 0; i < 4; i += 1) {
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const handoff = () => ({ status: 'ok', url: 'wss://x', nonce: 'n', sessionId: 'town-1', bundleHash: 'town', contentUrl: 'https://cdn/town.json' });
|
|
83
|
+
|
|
84
|
+
// A House reached by a hub trip from the Town; `link` is what the connection
|
|
85
|
+
// is doing: `away` (the resume gate armed), `tail` (out from behind it within
|
|
86
|
+
// the return window) and `placed`.
|
|
87
|
+
function setup({ place = { id: 'main', title: 'House', result: null } } = {}) {
|
|
88
|
+
let system;
|
|
89
|
+
installSystem({ registerSystem: (s) => (system = s) });
|
|
90
|
+
system.chrome = { setCover() {}, showBack() {}, setToast() {} };
|
|
91
|
+
system.scenePath = 'scenes/main.scene';
|
|
92
|
+
const link = { away: false, tail: false, placed: true };
|
|
93
|
+
const sent = [];
|
|
94
|
+
const scene = {
|
|
95
|
+
persistent: { hubTickets: [{ hub: true, scene: 'scenes/town.scene', content: null, join: { mode: 'public' }, door: 'house', title: 'Town' }], hubDepth: 1 },
|
|
96
|
+
multiplayer: {
|
|
97
|
+
target: { mode: 'hub', handoff: { sessionId: 'house-1' } },
|
|
98
|
+
joinState: () => 'joined',
|
|
99
|
+
resume: { get armed() { return link.away; } },
|
|
100
|
+
returning: () => link.away || link.tail,
|
|
101
|
+
placed: () => link.placed && !link.away,
|
|
102
|
+
net: { send: (msg) => sent.push(msg) },
|
|
103
|
+
switchSession() {},
|
|
104
|
+
},
|
|
105
|
+
content: null,
|
|
106
|
+
files: {},
|
|
107
|
+
mountsContent: true,
|
|
108
|
+
setContent() {},
|
|
109
|
+
actorWith: () => null,
|
|
110
|
+
getActor: () => null,
|
|
111
|
+
getActors: () => [],
|
|
112
|
+
};
|
|
113
|
+
calls.length = 0;
|
|
114
|
+
for (const key of Object.keys(answers)) {
|
|
115
|
+
delete answers[key];
|
|
116
|
+
}
|
|
117
|
+
HubState.clear();
|
|
118
|
+
HubState.hub.place = place;
|
|
119
|
+
const end = (msg, now) => {
|
|
120
|
+
HubState.hub.commands.push(msg);
|
|
121
|
+
system.runCommands(scene, now);
|
|
122
|
+
};
|
|
123
|
+
// One frame of what the end and its stay do.
|
|
124
|
+
const frame = (now) => {
|
|
125
|
+
system.stepEnd(scene, scene.multiplayer, now);
|
|
126
|
+
system.sendStay(scene, scene.multiplayer);
|
|
127
|
+
};
|
|
128
|
+
const backs = () => calls.filter((c) => c[0] === 'back').length;
|
|
129
|
+
const stays = () => sent.filter((m) => m.k === 'hub-stay').length;
|
|
130
|
+
return { system, scene, link, sent, end, frame, backs, stays };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const warn = console.warn;
|
|
134
|
+
const log = console.log;
|
|
135
|
+
console.warn = () => {};
|
|
136
|
+
console.log = () => {};
|
|
137
|
+
|
|
138
|
+
let n = 0;
|
|
139
|
+
async function test(name, fn) {
|
|
140
|
+
try {
|
|
141
|
+
await fn();
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.warn = warn;
|
|
144
|
+
console.log = log;
|
|
145
|
+
console.error(`not ok: ${name}`);
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
n += 1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const DOOR_END = { k: 'hub-end', why: 'end', door: 'front-door', end: 1 };
|
|
152
|
+
|
|
153
|
+
await test('ownDoor reads the tag only in a place without a result', () => {
|
|
154
|
+
assert.equal(Rehello.ownDoor(DOOR_END, { result: null }), 'front-door');
|
|
155
|
+
assert.equal(Rehello.ownDoor(DOOR_END, null), 'front-door');
|
|
156
|
+
assert.equal(Rehello.ownDoor(DOOR_END, { result: {} }), null);
|
|
157
|
+
assert.equal(Rehello.ownDoor({ k: 'hub-end', why: 'end' }, { result: null }), null);
|
|
158
|
+
assert.equal(Rehello.ownDoor({ k: 'hub-end', door: 3 }, { result: null }), null);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await test('a door end met while away is cancelled at once; hub-stay goes once, after re-admission', async () => {
|
|
162
|
+
const r = setup();
|
|
163
|
+
r.link.away = true;
|
|
164
|
+
r.end(DOOR_END, 1000);
|
|
165
|
+
assert.equal(r.system.pendingEnd, null, 'not armed');
|
|
166
|
+
for (const now of [1000, 3000, 6000]) {
|
|
167
|
+
r.frame(now);
|
|
168
|
+
}
|
|
169
|
+
await flush();
|
|
170
|
+
assert.equal(r.backs(), 0, 'no way back is asked for');
|
|
171
|
+
assert.equal(r.stays(), 0, 'nothing is said while away');
|
|
172
|
+
// The repeat of the same end, still away, is the same end.
|
|
173
|
+
r.end(DOOR_END, 6500);
|
|
174
|
+
assert.equal(r.system.pendingEnd, null);
|
|
175
|
+
// Back: the session has the player again.
|
|
176
|
+
r.link.away = false;
|
|
177
|
+
r.link.placed = false;
|
|
178
|
+
r.frame(7000);
|
|
179
|
+
assert.equal(r.stays(), 0, 'not before the session places them');
|
|
180
|
+
r.link.placed = true;
|
|
181
|
+
r.frame(7100);
|
|
182
|
+
r.frame(9000);
|
|
183
|
+
r.frame(20000);
|
|
184
|
+
await flush();
|
|
185
|
+
assert.deepEqual(r.sent, [{ k: 'hub-stay', end: 1 }], 'exactly one hub-stay, numbered to its end');
|
|
186
|
+
assert.equal(r.backs(), 0, 'and never a retried Back');
|
|
187
|
+
assert.equal(r.system.trip, null);
|
|
188
|
+
assert.deepEqual(r.scene.persistent.hubTickets.map((t) => t.title), ['Town'], 'the way back is kept');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
await test('the QA ordering: an end taken online whose Back fails offline as away arms is cancelled, not retried', async () => {
|
|
192
|
+
const r = setup();
|
|
193
|
+
r.end(DOOR_END, 1000);
|
|
194
|
+
assert.ok(r.system.pendingEnd > 1000, 'an online end pauses first');
|
|
195
|
+
r.frame(r.system.pendingEnd);
|
|
196
|
+
assert.ok(r.system.trip, 'the way back starts');
|
|
197
|
+
// The network goes: the fetch fails, and the resume gate arms.
|
|
198
|
+
answers.backOffline = true;
|
|
199
|
+
r.link.away = true;
|
|
200
|
+
await flush();
|
|
201
|
+
r.frame(3000);
|
|
202
|
+
assert.equal(r.system.contentReady(r.scene, r.system.trip, 3000), false);
|
|
203
|
+
assert.equal(r.system.pendingEnd, null, 'the end is cancelled, not re-armed');
|
|
204
|
+
assert.equal(r.system.trip.shut, 'its end was taken while offline', 'the cover lifts on the House');
|
|
205
|
+
r.system.trip = null;
|
|
206
|
+
// Reconnect: no retry, one hub-stay.
|
|
207
|
+
answers.backOffline = false;
|
|
208
|
+
answers.back = handoff();
|
|
209
|
+
r.link.away = false;
|
|
210
|
+
for (const now of [4000, 6000, 9000, 20000]) {
|
|
211
|
+
r.frame(now);
|
|
212
|
+
}
|
|
213
|
+
await flush();
|
|
214
|
+
assert.equal(r.backs(), 1, 'Back is never asked again');
|
|
215
|
+
assert.equal(r.stays(), 1);
|
|
216
|
+
assert.deepEqual(r.scene.persistent.hubTickets.map((t) => t.title), ['Town'], 'the ticket went back on the trail');
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
await test('a Back that failed before away was seen is cancelled at its retry once the connection was away', async () => {
|
|
220
|
+
const r = setup();
|
|
221
|
+
r.end(DOOR_END, 1000);
|
|
222
|
+
r.frame(r.system.pendingEnd);
|
|
223
|
+
answers.backOffline = true;
|
|
224
|
+
await flush();
|
|
225
|
+
// Failed while still reported connected: the ordinary stuck door.
|
|
226
|
+
assert.equal(r.system.contentReady(r.scene, r.system.trip, 2300), false);
|
|
227
|
+
assert.ok(r.system.pendingEnd !== null, 'still armed');
|
|
228
|
+
r.system.trip = null;
|
|
229
|
+
// Away arms before the retry, and the connection comes back.
|
|
230
|
+
r.link.away = true;
|
|
231
|
+
r.frame(2400);
|
|
232
|
+
r.link.away = false;
|
|
233
|
+
answers.backOffline = false;
|
|
234
|
+
answers.back = handoff();
|
|
235
|
+
r.frame(r.system.pendingEnd ?? 2500);
|
|
236
|
+
r.frame(10000);
|
|
237
|
+
await flush();
|
|
238
|
+
assert.equal(r.backs(), 1, 'the retry after reconnect does not go to the Town');
|
|
239
|
+
assert.equal(r.system.pendingEnd, null);
|
|
240
|
+
assert.equal(r.stays(), 1);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
await test('an acquisition that lands after reconnect for an end taken offline is given back', async () => {
|
|
244
|
+
const r = setup();
|
|
245
|
+
r.end(DOOR_END, 1000);
|
|
246
|
+
r.frame(r.system.pendingEnd);
|
|
247
|
+
answers.back = handoff();
|
|
248
|
+
r.link.away = true;
|
|
249
|
+
r.frame(2400);
|
|
250
|
+
r.link.away = false;
|
|
251
|
+
await flush();
|
|
252
|
+
assert.equal(r.system.contentReady(r.scene, r.system.trip, 2500), false);
|
|
253
|
+
await flush();
|
|
254
|
+
assert.deepEqual(calls.map((c) => c[0]), ['back', 'loadPack', 'cancel'], 'Hub.cancel returns it');
|
|
255
|
+
assert.equal(r.system.pendingEnd, null);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
await test('an untagged end, met while away or failing offline, still completes as before', async () => {
|
|
259
|
+
// Met while away: straight out, under the cover.
|
|
260
|
+
let r = setup();
|
|
261
|
+
r.link.away = true;
|
|
262
|
+
r.end({ k: 'hub-end', why: 'end' }, 1000);
|
|
263
|
+
assert.equal(r.system.pendingEnd, 1000);
|
|
264
|
+
r.frame(1000);
|
|
265
|
+
await flush();
|
|
266
|
+
assert.equal(r.backs(), 1);
|
|
267
|
+
// Online, its Back fails offline, and it is retried after reconnect.
|
|
268
|
+
r = setup();
|
|
269
|
+
r.end({ k: 'hub-end', why: 'end' }, 1000);
|
|
270
|
+
r.frame(r.system.pendingEnd);
|
|
271
|
+
answers.backOffline = true;
|
|
272
|
+
r.link.away = true;
|
|
273
|
+
await flush();
|
|
274
|
+
r.frame(2300);
|
|
275
|
+
assert.equal(r.system.contentReady(r.scene, r.system.trip, 2300), false);
|
|
276
|
+
r.system.trip = null;
|
|
277
|
+
r.link.away = false;
|
|
278
|
+
answers.backOffline = false;
|
|
279
|
+
answers.back = handoff();
|
|
280
|
+
r.frame(r.system.pendingEnd);
|
|
281
|
+
await flush();
|
|
282
|
+
assert.equal(r.backs(), 2, 'retried');
|
|
283
|
+
assert.equal(r.system.contentReady(r.scene, r.system.trip, 5000), true, 'and goes');
|
|
284
|
+
assert.equal(r.stays(), 0);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
await test('a game end (a place with a result) is never cancelled, tag or not', async () => {
|
|
288
|
+
const r = setup({ place: { id: 'race', title: 'Foot Race', result: {} } });
|
|
289
|
+
r.link.away = true;
|
|
290
|
+
r.end(DOOR_END, 1000);
|
|
291
|
+
assert.notEqual(r.system.pendingEnd, null);
|
|
292
|
+
r.frame(1000);
|
|
293
|
+
await flush();
|
|
294
|
+
assert.equal(r.backs(), 1);
|
|
295
|
+
r.link.away = false;
|
|
296
|
+
r.frame(10000);
|
|
297
|
+
assert.equal(r.stays(), 0);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
await test('a door end taken and finished online is unchanged', async () => {
|
|
301
|
+
const r = setup();
|
|
302
|
+
answers.back = handoff();
|
|
303
|
+
r.end(DOOR_END, 1000);
|
|
304
|
+
r.frame(r.system.pendingEnd);
|
|
305
|
+
await flush();
|
|
306
|
+
assert.equal(r.system.contentReady(r.scene, r.system.trip, 2300), true);
|
|
307
|
+
assert.equal(r.stays(), 0);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
await test('a pad that fires while away in a town is dropped, and the place hears hub-shut once back', async () => {
|
|
311
|
+
const r = setup({ place: { id: 'main', title: 'Town', result: null } });
|
|
312
|
+
r.link.away = true;
|
|
313
|
+
r.end({ k: 'hub-go', door: 'race', key: null, title: 'Foot Race', party: 1 }, 1000);
|
|
314
|
+
await flush();
|
|
315
|
+
assert.equal(r.system.trip, null, 'no trip');
|
|
316
|
+
assert.deepEqual(calls, [], 'nothing acquired');
|
|
317
|
+
r.frame(2000);
|
|
318
|
+
assert.deepEqual(r.sent, []);
|
|
319
|
+
r.link.away = false;
|
|
320
|
+
r.frame(3000);
|
|
321
|
+
r.frame(4000);
|
|
322
|
+
assert.deepEqual(r.sent, [{ k: 'hub-shut', door: 'race' }]);
|
|
323
|
+
// Online, the same pad goes as it always did.
|
|
324
|
+
const s = setup({ place: { id: 'main', title: 'Town', result: null } });
|
|
325
|
+
answers.go = handoff();
|
|
326
|
+
s.end({ k: 'hub-go', door: 'race', key: null, title: 'Foot Race', party: 1 }, 1000);
|
|
327
|
+
await flush();
|
|
328
|
+
assert.ok(s.system.trip, 'the trip starts');
|
|
329
|
+
assert.deepEqual(calls[0], ['go', 'race']);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
await test('review: a door end that arrives after the gate released, in the return tail, completes', async () => {
|
|
333
|
+
const r = setup();
|
|
334
|
+
r.link.tail = true;
|
|
335
|
+
answers.back = handoff();
|
|
336
|
+
r.end(DOOR_END, 1000);
|
|
337
|
+
assert.equal(r.system.pendingEnd, 1000, 'taken, under the cover with no pause, as before v1.169');
|
|
338
|
+
r.frame(r.system.pendingEnd);
|
|
339
|
+
await flush();
|
|
340
|
+
assert.equal(r.system.contentReady(r.scene, r.system.trip, 2300), true, 'and it goes');
|
|
341
|
+
assert.equal(r.backs(), 1);
|
|
342
|
+
r.frame(10000);
|
|
343
|
+
assert.equal(r.stays(), 0);
|
|
344
|
+
// A pad in the tail goes too.
|
|
345
|
+
const s = setup({ place: { id: 'main', title: 'Town', result: null } });
|
|
346
|
+
s.link.tail = true;
|
|
347
|
+
answers.go = handoff();
|
|
348
|
+
s.end({ k: 'hub-go', door: 'race', key: null, title: 'Foot Race', party: 1 }, 1000);
|
|
349
|
+
await flush();
|
|
350
|
+
assert.ok(s.system.trip, 'the pad trip starts');
|
|
351
|
+
assert.deepEqual(s.sent, []);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
await test('review: an end drained in the drain that releases the gate still counts as away', async () => {
|
|
355
|
+
for (const k of ['hub-end', 'hub-go']) {
|
|
356
|
+
const r = setup();
|
|
357
|
+
r.link.away = true;
|
|
358
|
+
// The multiplayer kit drains it with the gate still armed...
|
|
359
|
+
const msg = k === 'hub-end' ? { ...DOOR_END } : { k: 'hub-go', door: 'race', key: null, title: 'Foot Race', party: 1 };
|
|
360
|
+
HookLayer.message(r.scene, msg);
|
|
361
|
+
assert.equal(Rehello.arrivedAway(msg), true);
|
|
362
|
+
// ...and releases it at the end of that drain; this system reads it later.
|
|
363
|
+
r.link.away = false;
|
|
364
|
+
r.link.tail = true;
|
|
365
|
+
r.system.runCommands(r.scene, 1000);
|
|
366
|
+
await flush();
|
|
367
|
+
assert.equal(r.system.pendingEnd, null, `${k}: not taken`);
|
|
368
|
+
assert.equal(r.system.trip, null, `${k}: no trip`);
|
|
369
|
+
r.frame(2000);
|
|
370
|
+
assert.equal(r.sent.length, 1, `${k}: the place hears once`);
|
|
371
|
+
assert.equal(r.sent[0].k, k === 'hub-end' ? 'hub-stay' : 'hub-shut');
|
|
372
|
+
}
|
|
373
|
+
// One drained connected is not marked.
|
|
374
|
+
const msg = { ...DOOR_END };
|
|
375
|
+
HookLayer.message({ files: {}, multiplayer: { resume: { armed: false }, net: { status: () => ({ state: 'connected' }) } } }, msg);
|
|
376
|
+
assert.equal(Rehello.arrivedAway(msg), false);
|
|
377
|
+
const down = { ...DOOR_END };
|
|
378
|
+
HookLayer.message({ files: {}, multiplayer: { resume: { armed: false }, net: { status: () => ({ state: 'reconnecting' }) } } }, down);
|
|
379
|
+
assert.equal(Rehello.arrivedAway(down), true, 'a transport not connected is away');
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// A net as the multiplayer kit holds it, whose socket can be down: what is
|
|
383
|
+
// sent then is lost. The session takes the connection back with a WORLD.
|
|
384
|
+
function liveNet(r) {
|
|
385
|
+
const net = {
|
|
386
|
+
down: false,
|
|
387
|
+
lost: [],
|
|
388
|
+
inbox: [],
|
|
389
|
+
send(msg) { (net.down ? net.lost : r.sent).push(msg); },
|
|
390
|
+
selfId: () => 'p1',
|
|
391
|
+
drain() { const out = net.inbox; net.inbox = []; return out; },
|
|
392
|
+
};
|
|
393
|
+
const mp = r.scene.multiplayer;
|
|
394
|
+
mp.net = net;
|
|
395
|
+
mp.joined = false;
|
|
396
|
+
r.system.sayHello(r.scene, mp);
|
|
397
|
+
net.inbox.push({ k: 'w' });
|
|
398
|
+
net.drain();
|
|
399
|
+
mp.joined = true;
|
|
400
|
+
r.sent.length = 0;
|
|
401
|
+
// The session gives the connection a body again; the client says a resume hello.
|
|
402
|
+
net.readmit = () => { net.inbox.push({ k: 'w' }); net.drain(); r.system.sayHello(r.scene, mp); };
|
|
403
|
+
return net;
|
|
404
|
+
}
|
|
405
|
+
const kinds = (list) => list.map((m) => (m.k === 'hub-hello' ? `hello${m.resume ? ':resume' : ''}` : m.k));
|
|
406
|
+
|
|
407
|
+
// The place's answer, as the hook layer queues it.
|
|
408
|
+
const ack = (r, end, now) => { HookLayer.message(r.scene, { k: 'hub-stayed', end }); r.system.runCommands(r.scene, now); };
|
|
409
|
+
|
|
410
|
+
await test('fix: a stay said into a dead socket (the gate gave up on a visible offline page) goes again after the resume hello, until acknowledged', async () => {
|
|
411
|
+
const r = setup();
|
|
412
|
+
const net = liveNet(r);
|
|
413
|
+
r.link.away = true;
|
|
414
|
+
r.end({ ...DOOR_END }, 1000);
|
|
415
|
+
assert.equal(r.system.pendingEnd, null, 'cancelled');
|
|
416
|
+
// The page is visible and still offline: after RESUME_WAIT_MS the gate gives
|
|
417
|
+
// up, so the client counts as placed while the socket is down.
|
|
418
|
+
net.down = true;
|
|
419
|
+
r.link.away = false;
|
|
420
|
+
r.frame(12000);
|
|
421
|
+
assert.deepEqual(net.lost, [{ k: 'hub-stay', end: 1 }], 'said into the dead socket, and lost');
|
|
422
|
+
for (const now of [13000, 15000, 20000]) {r.frame(now);}
|
|
423
|
+
assert.equal(net.lost.length, 1, 'not said again each frame');
|
|
424
|
+
// The socket comes back and the session takes the player back.
|
|
425
|
+
net.down = false;
|
|
426
|
+
net.readmit();
|
|
427
|
+
assert.deepEqual(kinds(r.sent), ['hello:resume', 'hub-stay'], 'again, right behind the resume hello');
|
|
428
|
+
r.frame(31000);
|
|
429
|
+
r.frame(32000);
|
|
430
|
+
net.readmit();
|
|
431
|
+
assert.deepEqual(kinds(r.sent), ['hello:resume', 'hub-stay', 'hello:resume', 'hub-stay'], 'placement is no proof: still owed without the answer');
|
|
432
|
+
ack(r, 1, 33000);
|
|
433
|
+
assert.equal(r.system.stayDue, null, 'the answer ends it');
|
|
434
|
+
net.readmit();
|
|
435
|
+
r.frame(40000);
|
|
436
|
+
assert.deepEqual(kinds(r.sent), ['hello:resume', 'hub-stay', 'hello:resume', 'hub-stay', 'hello:resume'], 'nothing owed after the answer');
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
await test("Sol #2: a second drop swallows the resume hello and the stay; placed by the offline timeout; the next real recovery still says it", async () => {
|
|
440
|
+
const r = setup();
|
|
441
|
+
const net = liveNet(r);
|
|
442
|
+
r.link.away = true;
|
|
443
|
+
r.end({ ...DOOR_END }, 1000);
|
|
444
|
+
// The first recovery's WORLD is drained, and the socket dies at once: the
|
|
445
|
+
// resume hello and the stay behind it are lost.
|
|
446
|
+
r.link.away = false;
|
|
447
|
+
net.down = true;
|
|
448
|
+
net.readmit();
|
|
449
|
+
assert.deepEqual(kinds(net.lost), ['hello:resume', 'hub-stay']);
|
|
450
|
+
// The gate gives up while offline: placed() is true over a dead socket.
|
|
451
|
+
r.frame(12000);
|
|
452
|
+
r.frame(13000);
|
|
453
|
+
assert.deepEqual(r.sent, [], 'nothing reached the place');
|
|
454
|
+
assert.notEqual(r.system.stayDue, null, 'still owed');
|
|
455
|
+
// The real recovery.
|
|
456
|
+
net.down = false;
|
|
457
|
+
net.readmit();
|
|
458
|
+
assert.deepEqual(kinds(r.sent), ['hello:resume', 'hub-stay']);
|
|
459
|
+
assert.deepEqual(r.sent[1], { k: 'hub-stay', end: 1 });
|
|
460
|
+
ack(r, 1, 20000);
|
|
461
|
+
assert.equal(r.system.stayDue, null);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
await test("Sol #3: an old stay whose answer was lost is dropped by a newer door end, and never said again", async () => {
|
|
465
|
+
const r = setup();
|
|
466
|
+
const net = liveNet(r);
|
|
467
|
+
r.link.away = true;
|
|
468
|
+
r.end({ ...DOOR_END }, 1000);
|
|
469
|
+
r.link.away = false;
|
|
470
|
+
r.frame(5000);
|
|
471
|
+
assert.deepEqual(r.sent, [{ k: 'hub-stay', end: 1 }], 'delivered; its answer is lost');
|
|
472
|
+
// Online, the guest steps off and walks into the door again: a newer end.
|
|
473
|
+
r.end({ ...DOOR_END, end: 2 }, 6000);
|
|
474
|
+
assert.notEqual(r.system.pendingEnd, null, 'the newer end is taken');
|
|
475
|
+
assert.equal(r.system.stayDue, null, 'the old stay is owed no more');
|
|
476
|
+
net.readmit();
|
|
477
|
+
assert.deepEqual(kinds(r.sent), ['hub-stay', 'hello:resume'], 'the old stay is not said behind the resume hello');
|
|
478
|
+
// An answer for some other end changes nothing owed.
|
|
479
|
+
const s = setup();
|
|
480
|
+
liveNet(s);
|
|
481
|
+
s.link.away = true;
|
|
482
|
+
s.end({ ...DOOR_END, end: 3 }, 1000);
|
|
483
|
+
ack(s, 2, 1100);
|
|
484
|
+
assert.equal(s.system.stayDue?.end, 3, 'only its own number answers it');
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
await test('fix: an owed stay is dropped by a session change, a later end, or a trip', async () => {
|
|
488
|
+
// A session change.
|
|
489
|
+
let r = setup();
|
|
490
|
+
let net = liveNet(r);
|
|
491
|
+
r.link.away = true;
|
|
492
|
+
r.end({ ...DOOR_END }, 1000);
|
|
493
|
+
r.scene.multiplayer.target = { mode: 'hub', handoff: { sessionId: 'house-2' } };
|
|
494
|
+
r.link.away = false;
|
|
495
|
+
r.frame(5000);
|
|
496
|
+
net.readmit();
|
|
497
|
+
assert.deepEqual(kinds(r.sent), ['hello:resume'], 'never said in another session');
|
|
498
|
+
assert.equal(r.system.stayDue, null);
|
|
499
|
+
// A later end taken in the same session.
|
|
500
|
+
r = setup();
|
|
501
|
+
net = liveNet(r);
|
|
502
|
+
r.link.away = true;
|
|
503
|
+
r.end({ ...DOOR_END }, 1000);
|
|
504
|
+
net.down = true;
|
|
505
|
+
r.link.away = false;
|
|
506
|
+
r.frame(12000);
|
|
507
|
+
net.down = false;
|
|
508
|
+
r.end({ k: 'hub-end', why: 'end' }, 13000);
|
|
509
|
+
assert.notEqual(r.system.pendingEnd, null, 'the owner\'s end is taken');
|
|
510
|
+
assert.equal(r.system.stayDue, null, 'and the stay is owed no more');
|
|
511
|
+
// A trip.
|
|
512
|
+
r = setup();
|
|
513
|
+
net = liveNet(r);
|
|
514
|
+
r.link.away = true;
|
|
515
|
+
r.end({ ...DOOR_END }, 1000);
|
|
516
|
+
r.link.away = false;
|
|
517
|
+
r.system.startTrip(r.scene, { scene: 'scenes/town.scene', join: { mode: 'public' }, title: 'Town', exitDoor: null, arrive: null });
|
|
518
|
+
assert.equal(r.system.stayDue, null, 'a trip leaves the place');
|
|
519
|
+
r.system.trip = null;
|
|
520
|
+
net.readmit();
|
|
521
|
+
assert.deepEqual(kinds(r.sent), ['hello:resume']);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
// The first-room split's send met under a resume gate a frame stall armed: a
|
|
525
|
+
// low-memory phone's frames stop while it loads the Town, the gate arms on
|
|
526
|
+
// the gap, and the place's hub-go (the nux door) arrives in the drain right
|
|
527
|
+
// after it, page visible and socket connected (repro on a moto e22, Nov 5).
|
|
528
|
+
// The gate as the multiplayer kit holds it: `since` the page time the room was
|
|
529
|
+
// last current, `dropped` whether the connection left `connected` meanwhile.
|
|
530
|
+
function stallSetup({ since, dropped = false, state = 'connected' }) {
|
|
531
|
+
const r = setup({ place: { id: 'main', title: 'Town', result: null } });
|
|
532
|
+
const gate = { armed: true, since, dropped };
|
|
533
|
+
r.scene.multiplayer.resume = gate;
|
|
534
|
+
r.scene.multiplayer.returning = () => gate.armed;
|
|
535
|
+
r.scene.multiplayer.net.status = () => ({ state });
|
|
536
|
+
return { ...r, gate };
|
|
537
|
+
}
|
|
538
|
+
const NUX_GO = () => ({ k: 'hub-go', door: 'nux', key: null, title: 'Welcome to Castle', party: 1 });
|
|
539
|
+
|
|
540
|
+
await test('a hub-go met under a gate armed by a short frame stall, visible and connected, goes', async () => {
|
|
541
|
+
const r = stallSetup({ since: performance.now() - 3000 });
|
|
542
|
+
answers.go = handoff();
|
|
543
|
+
const msg = NUX_GO();
|
|
544
|
+
HookLayer.message(r.scene, msg);
|
|
545
|
+
assert.equal(Rehello.arrivedAway(msg), false, 'a 3 s stall is not an away');
|
|
546
|
+
r.gate.armed = false;
|
|
547
|
+
r.system.runCommands(r.scene, 1000);
|
|
548
|
+
await flush();
|
|
549
|
+
assert.ok(r.system.trip, 'the trip starts');
|
|
550
|
+
assert.deepEqual(calls[0], ['go', 'nux'], 'the door call is made');
|
|
551
|
+
r.frame(3000);
|
|
552
|
+
assert.deepEqual(r.sent.filter((m) => m.k === 'hub-shut'), [], 'and nothing is said shut');
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
await test('a stall that lasted STALL_AWAY_MS, dropped the connection, or ran into a hide is still an away', async () => {
|
|
556
|
+
const cases = [
|
|
557
|
+
['a long stall', { since: performance.now() - Rehello.STALL_AWAY_MS - 100 }],
|
|
558
|
+
['a dropped connection', { since: performance.now() - 1000, dropped: true }],
|
|
559
|
+
['a transport not connected', { since: performance.now() - 1000, state: 'reconnecting' }],
|
|
560
|
+
['a gate that says nothing of when it began', { since: undefined }],
|
|
561
|
+
];
|
|
562
|
+
for (const [what, opts] of cases) {
|
|
563
|
+
const r = stallSetup(opts);
|
|
564
|
+
const msg = NUX_GO();
|
|
565
|
+
HookLayer.message(r.scene, msg);
|
|
566
|
+
assert.equal(Rehello.arrivedAway(msg), true, `${what}: away`);
|
|
567
|
+
r.gate.armed = false;
|
|
568
|
+
r.system.runCommands(r.scene, 1000);
|
|
569
|
+
await flush();
|
|
570
|
+
assert.equal(r.system.trip, null, `${what}: no trip`);
|
|
571
|
+
assert.deepEqual(calls, [], `${what}: nothing acquired`);
|
|
572
|
+
}
|
|
573
|
+
// A short stall that went on into a hide (the page hidden after it began).
|
|
574
|
+
const r = stallSetup({ since: performance.now() - 1500 });
|
|
575
|
+
Rehello.notePageHidden(performance.now() - 500);
|
|
576
|
+
const msg = NUX_GO();
|
|
577
|
+
HookLayer.message(r.scene, msg);
|
|
578
|
+
assert.equal(Rehello.arrivedAway(msg), true, 'hidden since the away began: away');
|
|
579
|
+
// A hide before this away began does not count.
|
|
580
|
+
const s = stallSetup({ since: performance.now() - 100 });
|
|
581
|
+
const later = NUX_GO();
|
|
582
|
+
HookLayer.message(s.scene, later);
|
|
583
|
+
assert.equal(Rehello.arrivedAway(later), false, 'a hide before the away began is not this away');
|
|
584
|
+
Rehello.notePageHidden(null);
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
await test('a door end met under a short visible stall completes, as online', async () => {
|
|
588
|
+
const r = stallSetup({ since: performance.now() - 2000 });
|
|
589
|
+
r.scene.persistent.hubTickets = [{ hub: true, scene: 'scenes/town.scene', content: null, join: { mode: 'public' }, door: 'house', title: 'Town' }];
|
|
590
|
+
r.scene.persistent.hubDepth = 1;
|
|
591
|
+
answers.back = handoff();
|
|
592
|
+
const msg = { ...DOOR_END };
|
|
593
|
+
HookLayer.message(r.scene, msg);
|
|
594
|
+
assert.equal(Rehello.arrivedAway(msg), false);
|
|
595
|
+
r.gate.armed = false;
|
|
596
|
+
r.system.runCommands(r.scene, 1000);
|
|
597
|
+
assert.notEqual(r.system.pendingEnd, null, 'the end is taken, not cancelled');
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
console.warn = warn;
|
|
601
|
+
console.log = log;
|
|
602
|
+
console.log(`door stay client: ${n} tests passed`);
|