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,110 @@
|
|
|
1
|
+
// Vehicle preset v1.160: real model build, controller seam, seats and cleanup.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { register } from 'node:module';
|
|
5
|
+
import { Group, PerspectiveCamera, Raycaster } from 'three';
|
|
6
|
+
const root = new URL('../../', import.meta.url).href;
|
|
7
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
8
|
+
export async function resolve(specifier, context, next) {
|
|
9
|
+
if (specifier === '@imports/castle.physics-2d/engine/art') return { url: 'data:text/javascript,export const renderArtFrame=()=>null;export const artReady=()=>false;export const artFrameCount=()=>0;', shortCircuit: true };
|
|
10
|
+
if (specifier.startsWith('@imports/')) {
|
|
11
|
+
const file = specifier.replace('@imports/castle.', '');
|
|
12
|
+
return { url: ${JSON.stringify(root)} + file + (file.endsWith('.js') ? '' : '.js'), shortCircuit: true };
|
|
13
|
+
}
|
|
14
|
+
try {return await next(specifier, context);} catch(e) {
|
|
15
|
+
if (specifier.startsWith('.') && !specifier.endsWith('.js')) return next(specifier + '.js', context);
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`)}`);
|
|
20
|
+
const { makeReplay, replays, sampleTrace } = await import('../code/client/replay.js');
|
|
21
|
+
const { clear } = await import('../code/client/state.js');
|
|
22
|
+
const trace = { v: 1, step: 250, ms: 400, poses: [0, 100, 0, 170, 100, 200, 200, -170, 300, 300, 400, -150] };
|
|
23
|
+
const near = (a, b) => assert.ok(Math.abs(a - b) < 1e-8, `${a} ≈ ${b}`);
|
|
24
|
+
assert.deepEqual(sampleTrace(trace, -5), { x: 0, y: 1, z: 0, yaw: 170 });
|
|
25
|
+
assert.deepEqual(sampleTrace(trace, 125), { x: .5, y: 1.5, z: 1, yaw: -180 });
|
|
26
|
+
assert.deepEqual(sampleTrace(trace, 325), { x: 2, y: 2.5, z: 3, yaw: -160 });
|
|
27
|
+
assert.deepEqual(sampleTrace(trace, 900), { x: 3, y: 3, z: 4, yaw: -150 });
|
|
28
|
+
assert.deepEqual(sampleTrace({ ...trace, ms: 250 }, 250), { x: 3, y: 3, z: 4, yaw: -150 });
|
|
29
|
+
const model = JSON.stringify({ format: 'pxmodel', look: { outline: 0, ao: 0, rim: 0 }, parts: [
|
|
30
|
+
{ id: 'paint', kind: 'box', width: 1, height: 1, depth: 1, color: '#00ff00' },
|
|
31
|
+
] });
|
|
32
|
+
function boot() {
|
|
33
|
+
return { sceneKey: 1, currentScenePath: 'main', three: { scene: new Group(), nodes: new Map() },
|
|
34
|
+
files: { 'look.pxmodel': model }, getActor: id => id === 'look' ? { components: { Model: { file: 'look.pxmodel', scale: 2 } } } : null,
|
|
35
|
+
multiplayer: { generation: 1, net: { closed: () => false, status: () => ({ state: 'connected' }) } } };
|
|
36
|
+
}
|
|
37
|
+
function flags(group) {
|
|
38
|
+
group.traverse(o => {
|
|
39
|
+
assert.equal(o.castShadow, false); assert.equal(o.receiveShadow, false);
|
|
40
|
+
const hits = []; o.raycast(new Raycaster(), hits); assert.deepEqual(hits, []);
|
|
41
|
+
for (const m of [o.material].flat()) if (m) {
|
|
42
|
+
assert.equal(m.transparent, true); near(m.opacity, m.userData?.label ? .95 : .4); assert.equal(m.depthWrite, false);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
{
|
|
47
|
+
const s = boot(), r = makeReplay();
|
|
48
|
+
r.receive(s, 0, { trace }, 1000);
|
|
49
|
+
assert.equal(s.three.scene.children.length, 1); flags(s.three.scene.children[0]);
|
|
50
|
+
const first = s.three.scene.children[0]; let geometryDisposed = 0, materialDisposed = 0;
|
|
51
|
+
first.traverse(o => { o.geometry?.addEventListener('dispose', () => geometryDisposed++); for (const m of [o.material].flat()) m?.addEventListener('dispose', () => materialDisposed++); });
|
|
52
|
+
r.frame(s, 1125); near(first.position.x, .5); near(first.rotation.y, -Math.PI);
|
|
53
|
+
r.receive(s, 1, { trace }, 1000); assert.equal(s.three.scene.children.length, 2);
|
|
54
|
+
r.receive(s, 2, { trace }, 1000); assert.equal(s.three.scene.children.length, 2);
|
|
55
|
+
// Malformed optional fields allocate nothing (a NaN offset would never expire).
|
|
56
|
+
for (const bad of [{ offsetMs: 'bad' }, { offsetMs: -1 }, { offsetMs: trace.ms + 1 }, { label: 7 }, { label: ' ' }, { label: 'x'.repeat(25) }, { color: 'red' }, { look: 3 }]) {
|
|
57
|
+
r.receive(s, 0, { trace, ...bad }, 1000); assert.equal(s.three.scene.children.length, 2);
|
|
58
|
+
}
|
|
59
|
+
r.receive(s, 0, { trace, offsetMs: 250, color: '#ffffff' }, 1125);
|
|
60
|
+
assert.equal(s.three.scene.children.length, 2); assert.equal(first.parent, null); assert.equal(geometryDisposed, 2); assert.ok(materialDisposed);
|
|
61
|
+
const replacement = s.three.scene.children.at(-1); near(replacement.position.x, 1);
|
|
62
|
+
r.receive(s, 1, null, 1125); assert.equal(s.three.scene.children.length, 1);
|
|
63
|
+
r.frame(s, 1775); near(replacement.position.x, 3); near(replacement.children[0].material.opacity, .2);
|
|
64
|
+
r.frame(s, 2275); assert.equal(s.three.scene.children.length, 0);
|
|
65
|
+
r.clear();
|
|
66
|
+
}
|
|
67
|
+
{
|
|
68
|
+
// Real cached Model build. Per-copy translucent materials, shared geometry,
|
|
69
|
+
// and reference-counted release: removing one never breaks the other.
|
|
70
|
+
const s = boot(), r = makeReplay();
|
|
71
|
+
r.receive(s, 0, { trace, look: 'look' }, 0); r.receive(s, 1, { trace, look: 'look' }, 0);
|
|
72
|
+
assert.equal(s.three.scene.children.length, 2);
|
|
73
|
+
const [a, b] = s.three.scene.children;
|
|
74
|
+
flags(a); flags(b); assert.equal(a.children[0].scale.x, 2);
|
|
75
|
+
const meshes = g => { const out = []; g.traverse(o => { if (o.isMesh) out.push(o); }); return out; };
|
|
76
|
+
const ma = meshes(a)[0], mb = meshes(b)[0];
|
|
77
|
+
assert.equal(ma.geometry, mb.geometry); assert.notEqual(ma.material, mb.material);
|
|
78
|
+
let released = 0; ma.geometry.addEventListener('dispose', () => released++);
|
|
79
|
+
r.receive(s, 0, null, 0); assert.equal(released, 0); flags(b);
|
|
80
|
+
r.clear(); assert.ok(released > 0); assert.equal(s.three.scene.children.length, 0);
|
|
81
|
+
}
|
|
82
|
+
for (const change of [s => s.sceneKey++, s => {s.currentScenePath = 'next';}, s => s.multiplayer.generation++, s => {s.multiplayer.net = {};}, s => {s.multiplayer.net.closed = () => true;}]) {
|
|
83
|
+
const s = boot(), r = makeReplay(); r.receive(s, 0, { trace }, 0); change(s); r.frame(s, 10); assert.equal(s.three.scene.children.length, 0);
|
|
84
|
+
}
|
|
85
|
+
{
|
|
86
|
+
const s = boot(); replays.receive(s, 0, { trace }, 0); replays.receive(s, 1, { trace }, 0);
|
|
87
|
+
clear(); assert.equal(s.three.scene.children.length, 0);
|
|
88
|
+
replays.receive(s, 0, { trace }, 0); replays.frame(boot(), 1); assert.equal(s.three.scene.children.length, 0);
|
|
89
|
+
}
|
|
90
|
+
{
|
|
91
|
+
// Simple kit-owned sprite label with owned texture/material cleanup.
|
|
92
|
+
const realDocument = globalThis.document;
|
|
93
|
+
globalThis.document = { createElement: () => ({ getContext: () => ({ fillText() {}, strokeText() {} }) }) };
|
|
94
|
+
try {
|
|
95
|
+
const s = boot(), r = makeReplay(); r.receive(s, 0, { trace, label: 'Your best' }, 0);
|
|
96
|
+
const label = s.three.scene.children[0].children.find(o => o.isSprite); assert.ok(label); flags(label);
|
|
97
|
+
// The label stays readable over a faint figure and is never tinted.
|
|
98
|
+
assert.equal(label.material.opacity, .95);
|
|
99
|
+
let textures = 0; label.material.map.addEventListener('dispose', () => textures++); r.clear(); assert.equal(textures, 1);
|
|
100
|
+
} finally { if (realDocument === undefined) delete globalThis.document; else globalThis.document = realDocument; }
|
|
101
|
+
}
|
|
102
|
+
// Lifecycle integration must include travel/reset, scene disposal and fresh hello.
|
|
103
|
+
for (const [file, expected] of [['../code/client/hookLayer.js', ["case 'hub-replay':", 'replayCleanup.receive(scene, msg.slot, msg.replay)', 'replayCleanup.clear()', "if (msg.k === 'w' && msg.again !== 1) {replayCleanup.clear();}"]],
|
|
104
|
+
['../code/client/state.js', ['replayCleanup.clear();']],
|
|
105
|
+
['../code/client/replay.js', ['replayCleanup.receive = replays.receive;']],
|
|
106
|
+
['../code/systems/hub.js', ['replays.frame(s)', 'if (!again) {this.clearReplays?.();}', 'replays.clear()']]]) {
|
|
107
|
+
const source = fs.readFileSync(new URL(file, import.meta.url), 'utf8');
|
|
108
|
+
for (const needle of expected) assert.ok(source.includes(needle), needle);
|
|
109
|
+
}
|
|
110
|
+
console.log('replay client: interpolation/yaw/final interval, lifecycle/slots, real cached look, translucent/no-picking, label and resource cleanup passed');
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Vehicle preset v1.160: real hub layer, fake transport/body, no Rapier needed.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { register } from 'node:module';
|
|
4
|
+
const sceneStub = 'export const readScene = () => globalThis.__hubTestActors ?? [];';
|
|
5
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
6
|
+
export async function resolve(specifier, context, next) {
|
|
7
|
+
if (specifier === './replay.js' && context.parentURL.endsWith('?without-replay')) return { url: 'data:text/javascript,export function tick(){};export function forget(){};export function end(){};', shortCircuit: true };
|
|
8
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/server/sceneBodies.js') return { url: ${JSON.stringify('data:text/javascript,' + encodeURIComponent(sceneStub))}, shortCircuit: true };
|
|
9
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/server/players.js') return { url: 'data:text/javascript,export function setPose(sim,id,msg){sim.reports.push([id,msg])}', shortCircuit: true };
|
|
10
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/server/limits.js') return { url: 'data:text/javascript,export const readPoint=()=>null', shortCircuit: true };
|
|
11
|
+
return next(specifier, context);
|
|
12
|
+
}
|
|
13
|
+
`)}`);
|
|
14
|
+
const { layer } = await import('../code/server/hub.js');
|
|
15
|
+
const { layer: baselineLayer } = await import('../code/server/hub.js?without-replay');
|
|
16
|
+
const { hubPlayers } = await import('../code/server/players.js');
|
|
17
|
+
const { cleanTrace } = await import('../code/shared/replay.js');
|
|
18
|
+
const Replay = await import('../code/server/replay.js');
|
|
19
|
+
let clock = 1_800_000_000_000;
|
|
20
|
+
const realNow = Date.now;
|
|
21
|
+
Date.now = () => clock;
|
|
22
|
+
function boot({ retained = false, count = 3, control = false } = {}) {
|
|
23
|
+
globalThis.__hubTestActors = [
|
|
24
|
+
{ id: 'spawn', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } },
|
|
25
|
+
{ id: 'car', components: { Model: { file: 'car.pxmodel' }, Transform: {} } },
|
|
26
|
+
{ id: 'bench', components: { HubSeat: {}, Transform: {}, Shape: { kind: 'box', height: 0.3 } } },
|
|
27
|
+
{ id: 'door', components: { HubDoor: { id: 'game', to: 'game' }, Transform: {} } },
|
|
28
|
+
];
|
|
29
|
+
const sent = [], broadcast = [], left = [];
|
|
30
|
+
const players = Array.from({ length: count }, (_, i) => ({ playerId: `p${i + 1}`, username: `user${i}`, userId: `${i + 1}` }));
|
|
31
|
+
const session = { sessionId: 'dev', players: [...players], send: (id, msg) => sent.push([id, msg]), broadcast: msg => broadcast.push(msg) };
|
|
32
|
+
const body = () => ({ at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } });
|
|
33
|
+
const sim = { timeMs: 0, scenePath: retained ? 'scenes/game.scene' : 'scenes/main.scene', players: new Map(players.map(p => [p.playerId, body()])), objects: new Map(), bodies: new Map(), reports: [] };
|
|
34
|
+
let hub;
|
|
35
|
+
const opts = { title: 'Town', contract: 1, stuck: true, idle: { seats: true, sounds: ['sounds/horn.wav'] }, places: { game: { title: 'Game', scene: 'scenes/game.scene', result: {}, ...(retained ? { resume: { keep: true } } : {}) } } };
|
|
36
|
+
if (retained) {session.place = 'game'; opts.places.game.idle = opts.idle;}
|
|
37
|
+
// resolvePlace reads session's authoritative place field.
|
|
38
|
+
const hooks = { ready(ctx) {hub = ctx;}, leave(ctx, id) {left.push(id);} };
|
|
39
|
+
const server = (control ? baselineLayer : layer)({ server: { maxPlayers: Math.max(8, count) }, hub: opts }, hooks, { game: hooks }, () => true);
|
|
40
|
+
server.sceneFor(session); server.ready(sim);
|
|
41
|
+
const say = (id, data) => server.message(session, { playerId: id }, data);
|
|
42
|
+
const tick = (ms = 50) => {sim.timeMs += ms; clock += ms; server.place(sim); server.step(sim, []);};
|
|
43
|
+
players.forEach(p => say(p.playerId, { k: 'hub-hello', avatar: 0, party: 1 }));
|
|
44
|
+
tick(2000); tick(5000);
|
|
45
|
+
for (const p of sim.players.values()) {p.at = { x: 0, y: 1, z: 0 };}
|
|
46
|
+
const drop = id => {session.players.splice(session.players.findIndex(p => p.playerId === id), 1); sim.players.delete(id);};
|
|
47
|
+
const back = id => {session.players.push(players.find(p => p.playerId === id)); sim.players.set(id, body()); say(id, { k: 'hub-hello', avatar: 0, party: 1, resume: true });};
|
|
48
|
+
return { hub, server, sim, session, sent, broadcast, say, tick, drop, back, left };
|
|
49
|
+
}
|
|
50
|
+
const trace = (ms = 500) => ({ v: 1, step: 250, ms, poses: Array.from({ length: Math.ceil(ms / 250) + 1 }, (_, i) => [i * 100, 100, 0, 0]).flat() });
|
|
51
|
+
const messages = r => r.sent.filter(([, m]) => m.k === 'hub-replay');
|
|
52
|
+
let tests = 0;
|
|
53
|
+
function test(name, fn) { fn(); tests++; console.log(`ok: ${name}`); }
|
|
54
|
+
try {
|
|
55
|
+
test('strict trace and spec validation, immutable copies, no change on refusal', () => {
|
|
56
|
+
const r = boot(), t = trace();
|
|
57
|
+
assert.equal(r.hub.replay('p1', 0, { trace: t, label: ' Best ', color: '#AABBCC', look: 'car' }), true);
|
|
58
|
+
const sent = messages(r)[0][1].replay;
|
|
59
|
+
assert.equal(sent.label, 'Best'); assert.equal(sent.color, '#aabbcc');
|
|
60
|
+
t.poses[0] = 999; assert.equal(sent.trace.poses[0], 0);
|
|
61
|
+
for (const bad of [null, {}, { ...trace(), v: 2 }, { ...trace(), step: 251 }, { ...trace(), ms: 600001 }, { ...trace(), ms: 1.5 }, { ...trace(), ms: 10000 },
|
|
62
|
+
{ ...trace(), extra: 1 }, { ...trace(), poses: [] }, { ...trace(), poses: [0, 0, 0, 0] }, { ...trace(), poses: Array(772).fill(0) },
|
|
63
|
+
...[NaN, Infinity, 1.2, 100001, Number.MAX_SAFE_INTEGER + 1].map(n => ({ ...trace(), poses: [n, 0, 0, 0, 0, 0, 0, 0] })),
|
|
64
|
+
...[-181, 180].map(n => ({ ...trace(250), poses: [0, 0, 0, n, 0, 0, 0, 0] }))]) {
|
|
65
|
+
assert.equal(cleanTrace(bad), null);
|
|
66
|
+
assert.equal(r.hub.replay('p1', 0, { trace: bad }), false);
|
|
67
|
+
}
|
|
68
|
+
for (const extra of [{ label: '' }, { label: 'x'.repeat(25) }, { label: '\u0001' }, { label: '\u0085' }, { color: 'red' }, { offsetMs: -1 }, { offsetMs: 501 }, { offsetMs: 1.1 }, { look: 'bench' }, { nope: 1 }]) {
|
|
69
|
+
assert.equal(r.hub.replay('p1', 0, { trace: trace(), ...extra }), false);
|
|
70
|
+
}
|
|
71
|
+
assert.equal(r.hub.replay('unknown', 0, { trace: trace() }), false);
|
|
72
|
+
assert.equal(r.hub.replay('p1', 2, { trace: trace() }), false);
|
|
73
|
+
assert.equal(messages(r).length, 1);
|
|
74
|
+
assert.ok(Replay.cleanReplay({ actors: [] }, { trace: trace(), label: '🐱'.repeat(24), offsetMs: 500 }));
|
|
75
|
+
});
|
|
76
|
+
test('records server pose, integer cm/yaw, final sample and fresh JSON', () => {
|
|
77
|
+
const r = boot(), b = r.sim.players.get('p1');
|
|
78
|
+
assert.equal(r.hub.record('p1', 'stop'), null);
|
|
79
|
+
b.at = { x: 1.234, y: -2.345, z: .006 }; b.facing = 3 * Math.PI;
|
|
80
|
+
assert.equal(r.hub.record('p1', 'start'), true);
|
|
81
|
+
r.say('p1', { k: 'deck-pose', at: { x: 999 } });
|
|
82
|
+
r.sim.timeMs += 300; b.at = { x: 2, y: 3, z: 4 }; b.facing = -Math.PI / 2;
|
|
83
|
+
const t = r.hub.record('p1', 'stop');
|
|
84
|
+
assert.deepEqual(t, { v: 1, step: 250, ms: 300, poses: [123, -235, 1, -180, 200, 300, 400, -90] });
|
|
85
|
+
assert.equal(Object.getPrototypeOf(t), Object.prototype);
|
|
86
|
+
assert.deepEqual(JSON.parse(JSON.stringify(t)), t);
|
|
87
|
+
t.poses[0] = 999; assert.equal(r.hub.record('p1', 'stop'), null);
|
|
88
|
+
r.hub.record('p1', 'start'); assert.equal(r.hub.record('p1', 'stop'), null);
|
|
89
|
+
r.hub.record('p1', 'start'); r.sim.timeMs += 10; assert.equal(r.hub.record('p1', 'stop').poses.length, 8);
|
|
90
|
+
r.hub.record('p1', 'start'); assert.equal(r.hub.record('p1', 'cancel'), true); assert.equal(r.hub.record('p1', 'stop'), null);
|
|
91
|
+
r.hub.record('p1', 'start'); r.sim.timeMs += 333.333333; assert.equal(r.hub.record('p1', 'stop').ms, 333);
|
|
92
|
+
});
|
|
93
|
+
test('samples on kit cadence, bounded decimation preserves the start and doubles step', () => {
|
|
94
|
+
const h = { players: new Map([['p', { hello: true, arrived: true, arrivedAt: 0 }]]), session: { players: [{ playerId: 'p' }] }, sim: { timeMs: 0, players: new Map([['p', { at: { x: 0, y: 1, z: 0 }, facing: 0 }]]) } };
|
|
95
|
+
Replay.record(h, 'p', 'start');
|
|
96
|
+
for (let t = 250; t <= 600000; t += 250) {
|
|
97
|
+
h.sim.timeMs = t; h.sim.players.get('p').at.x = t / 1000;
|
|
98
|
+
Replay.tick(h);
|
|
99
|
+
const r = h.recordings.get('p'); assert.ok(r.poses.length <= 768);
|
|
100
|
+
if (t === 48000) {assert.equal(r.step, 500); assert.equal(r.poses[4], 50);}
|
|
101
|
+
}
|
|
102
|
+
const t = Replay.record(h, 'p', 'stop'); assert.ok(t); assert.equal(t.ms, 600000); assert.equal(t.step, 4000);
|
|
103
|
+
assert.equal(t.poses[0], 0); assert.equal(t.poses.at(-4), 60000);
|
|
104
|
+
Replay.record(h, 'p', 'start'); h.sim.timeMs += 600001; assert.equal(Replay.record(h, 'p', 'stop'), null);
|
|
105
|
+
Replay.record(h, 'p', 'start'); h.sim.timeMs += 600001; Replay.tick(h); assert.equal(h.recordings.size, 0);
|
|
106
|
+
});
|
|
107
|
+
test('nonfinite/out-of-bounds authoritative poses abort; max eight present recordings', () => {
|
|
108
|
+
for (const bad of [NaN, Infinity, 1000.001, -1000.001]) {
|
|
109
|
+
const r = boot(); r.hub.record('p1', 'start'); r.sim.players.get('p1').at.x = bad; r.tick(250); assert.equal(r.hub.record('p1', 'stop'), null);
|
|
110
|
+
}
|
|
111
|
+
const r = boot({ count: 9 });
|
|
112
|
+
for (let i = 1; i <= 8; i++) assert.equal(r.hub.record(`p${i}`, 'start'), true);
|
|
113
|
+
assert.equal(r.hub.record('p9', 'start'), false); r.hub.record('p1', 'cancel'); assert.equal(r.hub.record('p9', 'start'), true);
|
|
114
|
+
});
|
|
115
|
+
test('leave, identity, anonymous flag, body and arrival fences cancel traces and clear private slots', () => {
|
|
116
|
+
for (const change of [r => r.drop('p1'), r => {r.session.players[0].userId = 'else';}, r => {r.session.players[0].isAnonymous = true;},
|
|
117
|
+
r => {r.sim.players.set('p1', { ...r.sim.players.get('p1') });},
|
|
118
|
+
r => r.hub.go('game', ['p1']), r => r.hub.end(['p1'])]) {
|
|
119
|
+
const r = boot(); r.hub.record('p1', 'start'); r.hub.replay('p1', 0, { trace: trace() }); change(r); r.tick(250);
|
|
120
|
+
assert.equal(r.hub.record('p1', 'stop'), null); const previous = messages(r).length; r.tick(4000); assert.equal(messages(r).filter(([, m]) => m.replay).length, 1);
|
|
121
|
+
assert.ok(messages(r).length >= previous);
|
|
122
|
+
}
|
|
123
|
+
// Direct fixture permits an arrival-generation change without teleporting.
|
|
124
|
+
const sent = [], h = { actors: [], players: new Map([['p', { hello: true, arrived: true, arrivedAt: 0 }]]), session: { players: [{ playerId: 'p' }], send: (id, m) => sent.push(m) }, sim: { timeMs: 0, players: new Map([['p', { at: { x: 0, y: 1, z: 0 }, facing: 0 }]]) } };
|
|
125
|
+
Replay.record(h, 'p', 'start'); Replay.replay(h, 'p', 0, { trace: trace() }); h.players.get('p').arrivedAt = 2; h.sim.timeMs = 250; Replay.tick(h);
|
|
126
|
+
assert.equal(Replay.record(h, 'p', 'stop'), null); assert.equal(sent.at(-1).replay, null); assert.equal(h.replays.size, 0);
|
|
127
|
+
});
|
|
128
|
+
test('a transport leave ends recording and ghosts even when the body is kept', () => {
|
|
129
|
+
const r = boot(); r.hub.record('p1', 'start'); r.hub.replay('p1', 0, { trace: trace() }); r.tick(250);
|
|
130
|
+
r.server.replayDeparted(r.session, { playerId: 'p1' }); r.tick(250);
|
|
131
|
+
assert.equal(r.hub.record('p1', 'stop'), null);
|
|
132
|
+
const other = boot(); other.server.replayDeparted(other.session, { playerId: 'p1' }); assert.equal(other.hub.record('p1', 'start'), true);
|
|
133
|
+
});
|
|
134
|
+
test('retained short drop between ticks and fresh hello never resend stale ghosts', () => {
|
|
135
|
+
for (const retained of [false, true]) {
|
|
136
|
+
const r = boot({ retained }); r.hub.record('p1', 'start'); r.hub.replay('p1', 0, { trace: trace() });
|
|
137
|
+
// No transport hook: the fresh hello and the body/roster fence clear it.
|
|
138
|
+
r.drop('p1'); r.back('p1'); r.tick(250);
|
|
139
|
+
assert.equal(r.hub.record('p1', 'stop'), null);
|
|
140
|
+
assert.equal(messages(r).filter(([, m]) => m.replay).length, 1);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
test('private bytes never enter join, snapshot/delta, broadcast, actors or second/late viewers', () => {
|
|
144
|
+
const r = boot(), join = JSON.stringify(r.server.join()); r.server.delta();
|
|
145
|
+
r.hub.replay('p1', 0, { trace: trace() }); r.hub.replay('p1', 1, { trace: trace(), label: 'Secret' });
|
|
146
|
+
assert.equal(JSON.stringify(r.server.join()), join); assert.equal(r.server.delta(), null);
|
|
147
|
+
r.session.players.push({ playerId: 'late', userId: '123' }); r.sim.players.set('late', { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } });
|
|
148
|
+
r.say('late', { k: 'hub-hello', avatar: 0, party: 1 }); r.tick(2000);
|
|
149
|
+
assert.deepEqual(new Set(messages(r).map(([id]) => id)), new Set(['p1']));
|
|
150
|
+
for (const [id, msg] of r.sent) if (id !== 'p1') assert.ok(!JSON.stringify(msg).includes('hub-replay'));
|
|
151
|
+
assert.ok(!JSON.stringify([r.server.join(), r.server.delta(), r.broadcast]).includes('hub-replay'));
|
|
152
|
+
assert.equal(r.sim.players.size, 4); assert.equal(r.sim.objects.size, 0);
|
|
153
|
+
});
|
|
154
|
+
test('rolling rate limit, explicit null, offset expiry and shutdown', () => {
|
|
155
|
+
const r = boot();
|
|
156
|
+
for (let i = 0; i < 4; i++) assert.equal(r.hub.replay('p1', i % 2, { trace: trace(), offsetMs: 250 }), true);
|
|
157
|
+
assert.equal(r.hub.replay('p1', 0, { trace: trace() }), false); r.sim.timeMs += 999;
|
|
158
|
+
assert.equal(r.hub.replay('p1', 0, { trace: trace() }), false);
|
|
159
|
+
// Clears are never budgeted; an empty slot sends nothing.
|
|
160
|
+
assert.equal(r.hub.replay('p1', 0, null), true); assert.equal(messages(r).at(-1)[1].replay, null);
|
|
161
|
+
const count = messages(r).length;
|
|
162
|
+
assert.equal(r.hub.replay('p1', 0, null), true); assert.equal(messages(r).length, count);
|
|
163
|
+
r.sim.timeMs++;
|
|
164
|
+
assert.equal(r.hub.replay('p1', 0, { trace: trace(), offsetMs: 250 }), true);
|
|
165
|
+
r.tick(2251); assert.equal(messages(r).at(-1)[1].slot, 1); assert.equal(messages(r).at(-1)[1].replay, null);
|
|
166
|
+
r.tick(1000); assert.equal(messages(r).at(-1)[1].slot, 0); assert.equal(messages(r).at(-1)[1].replay, null);
|
|
167
|
+
r.hub.record('p1', 'start'); r.hub.replay('p1', 0, { trace: trace() }); r.server.shutdown();
|
|
168
|
+
assert.equal(r.hub.record('p1', 'stop'), null); assert.equal(messages(r).at(-1)[1].replay, null);
|
|
169
|
+
});
|
|
170
|
+
test('unused layer output is byte-identical with replay lifecycle removed', () => {
|
|
171
|
+
const capture = r => { r.server.delta(); r.tick(250); return JSON.stringify([r.sent, r.broadcast, r.server.join(), r.server.delta()]); };
|
|
172
|
+
const before = clock, a = capture(boot()); clock = before;
|
|
173
|
+
// The control follows the pre-v1.163 path: no replay calls at all.
|
|
174
|
+
const b = capture(boot({ control: true })); assert.equal(a, b);
|
|
175
|
+
const h = {}; Replay.tick(h); Replay.end(h); Replay.forget(h, 'p'); assert.deepEqual(h, {});
|
|
176
|
+
});
|
|
177
|
+
} finally { Date.now = realNow; }
|
|
178
|
+
console.log(`${tests} replay server tests passed`);
|
|
@@ -129,6 +129,19 @@ for (const ms of [30_000, 180_000]) {
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
test('v1.184: a held visit replays a solid private hide with its solid list', () => {
|
|
133
|
+
const r = boot();
|
|
134
|
+
assert.equal(r.hub.hide('job-cue', { to: ['p1'], solid: true }), true);
|
|
135
|
+
r.step();
|
|
136
|
+
r.drop();
|
|
137
|
+
r.away(30_000);
|
|
138
|
+
r.back();
|
|
139
|
+
const from = r.sent.length;
|
|
140
|
+
r.hello('p1', { resume: true });
|
|
141
|
+
r.step();
|
|
142
|
+
assert.deepEqual(to(r, 'hub-vis', from), [{ k: 'hub-vis', hide: ['boat-hull', 'boat-sail', 'job-cue'], show: [], solid: ['job-cue'] }]);
|
|
143
|
+
});
|
|
144
|
+
|
|
132
145
|
test('expiry forgets both: the late return arrives afresh and gets its masks from arrive', () => {
|
|
133
146
|
const r = boot();
|
|
134
147
|
r.drop();
|
|
@@ -90,10 +90,15 @@ export default Object.fromEntries(Object.entries(callbacks).map(([key, value]) =
|
|
|
90
90
|
[key, typeof value === 'function' ? (session, ...rest) => value(wrap(session), ...rest) : value]));
|
|
91
91
|
`);
|
|
92
92
|
await writeFile(path.join(dir, 'code/server/game.js'), `
|
|
93
|
+
// Server steps run: the kit records the pose a leave stores on a step.
|
|
94
|
+
let steps = 0;
|
|
93
95
|
export default {
|
|
96
|
+
step() { steps += 1; },
|
|
94
97
|
message(h, p, d) {
|
|
95
98
|
if (d?.test === 'move') h.placeAt(p.playerId, ${JSON.stringify(cold)}, 40);
|
|
96
|
-
|
|
99
|
+
const body = h.sim.players.get(p.playerId);
|
|
100
|
+
// clamped: false once the server took a report from where the body stands.
|
|
101
|
+
if (d?.test) h.send(p.playerId, { test: d.test, pose: body && { ...body.at }, clamped: body?.clamped, steps });
|
|
97
102
|
},
|
|
98
103
|
};
|
|
99
104
|
`);
|
|
@@ -108,11 +113,29 @@ export default {
|
|
|
108
113
|
a.local = { ...spawn };
|
|
109
114
|
a.reporting = true;
|
|
110
115
|
await a.wait(f => f.t === 'm' && f.d?.k === 'hub-arrived');
|
|
111
|
-
await
|
|
112
|
-
|
|
116
|
+
await world(a);
|
|
117
|
+
// Set up the pose under test without racing the browser-like reports. Until
|
|
118
|
+
// the server has taken one report from where the arrival left the body, it
|
|
119
|
+
// keeps marking that spot as a correction (clamped) in every snapshot, and a
|
|
120
|
+
// snapshot still on its way when the client moved on put the client back at
|
|
121
|
+
// the spawn; the client's next report then pulled the body there too (the
|
|
122
|
+
// movement clamp allows 0.6 m at once, and a whole spawn-to-spot walk after
|
|
123
|
+
// a stall). So: wait for the server to agree with the client at the spawn;
|
|
124
|
+
// this answer is read after every snapshot sent before it. Then the client
|
|
125
|
+
// stands at the moved spot from the moment it asks to be put there, so no
|
|
126
|
+
// report after the ask names the spawn (taking the spot up only on the
|
|
127
|
+
// reply let each spawn report in between pull the body back a step, and the
|
|
128
|
+
// clamped row sent back put the client there too: 0.6 to 1.2 m under load).
|
|
129
|
+
const agreed = await until(a, 'state', {}, s => s.clamped === false);
|
|
130
|
+
assert.equal(agreed.clamped, false, `server takes the client's reports at the spawn ${JSON.stringify(agreed)}`);
|
|
113
131
|
a.local = { ...cold };
|
|
114
|
-
await
|
|
115
|
-
|
|
132
|
+
await query(a, 'move');
|
|
133
|
+
// Done when the server has taken a report from the moved spot and then run
|
|
134
|
+
// a step with the body there: the leave stores the pose its last step
|
|
135
|
+
// recorded, so a close before that step stored the spawn.
|
|
136
|
+
const near = s => s.clamped === false && Math.hypot(s.pose.x - cold.x, s.pose.z - cold.z) < 0.3;
|
|
137
|
+
const moved = await until(a, 'state', {}, near);
|
|
138
|
+
const before = (await until(a, 'state', {}, s => near(s) && s.steps > moved.steps)).pose;
|
|
116
139
|
assert.ok(Math.hypot(before.x - cold.x, before.z - cold.z) < 0.3, `first visit stands at the moved spot ${JSON.stringify(before)}`);
|
|
117
140
|
a.socket.close();
|
|
118
141
|
await new Promise(resolve => a.socket.once('close', resolve));
|
|
@@ -155,6 +178,21 @@ export default {
|
|
|
155
178
|
await server?.shutdown();
|
|
156
179
|
await rm(dir, { recursive: true, force: true });
|
|
157
180
|
}
|
|
181
|
+
// The client's starting WORLD (the frame that places its body; see connect).
|
|
182
|
+
function world(client) {
|
|
183
|
+
return client.wait(f => f.t === 'm' && [].concat(f.d?.batch ?? f.d).some(d => d?.k === 'w' && !d.again));
|
|
184
|
+
}
|
|
185
|
+
// Asks again until `done` holds or the deadline passes, then returns the last
|
|
186
|
+
// answer, so the caller's assertion still decides (and fails) on it.
|
|
187
|
+
async function until(client, test, extra, done, ms = 10000) {
|
|
188
|
+
const deadline = Date.now() + ms;
|
|
189
|
+
let answer = await query(client, test, extra);
|
|
190
|
+
while (!done(answer) && Date.now() < deadline) {
|
|
191
|
+
await sleep(50);
|
|
192
|
+
answer = await query(client, test, extra);
|
|
193
|
+
}
|
|
194
|
+
return answer;
|
|
195
|
+
}
|
|
158
196
|
async function query(client, test, extra = {}) {
|
|
159
197
|
client.send({ test, ...extra });
|
|
160
198
|
return (await client.wait(f => f.t === 'm' && f.d?.test === test)).d;
|
|
@@ -35,6 +35,7 @@ register(`data:text/javascript,${encodeURIComponent(hooks)}`);
|
|
|
35
35
|
const THREE = await import('three');
|
|
36
36
|
const Avatar = await import('../code/client/avatar.js');
|
|
37
37
|
const Role = await import('../code/client/role.js');
|
|
38
|
+
const HoldShow = await import('../code/client/holdShow.js');
|
|
38
39
|
const State = await import('../code/client/state.js');
|
|
39
40
|
const hooksLayer = (await import('../code/client/hookLayer.js')).default;
|
|
40
41
|
const { makeWear, makeEarned, makeRole } = await import('../code/client/wear.js');
|
|
@@ -183,7 +184,7 @@ test('system uses drawn-avatar fit and masks the live earned renderer, restoring
|
|
|
183
184
|
const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
184
185
|
const method = source.slice(source.indexOf(' applyWear(scene, local) {') + 2, source.indexOf(" // The place's tuning", source.indexOf(' applyWear(scene, local) {')));
|
|
185
186
|
const Hub = { hub: State.hub };
|
|
186
|
-
const apply = new Function('Hub', 'Avatar', 'AvatarCap', 'roleWearing', 'roleEarned', `return ({${method}}).applyWear`)(Hub, { ...Avatar, style: () => 'toon', current: () => 1 }, { shown: () => 2 }, Role.roleWearing, Role.roleEarned);
|
|
187
|
+
const apply = new Function('Hub', 'Avatar', 'AvatarCap', 'roleWearing', 'roleEarned', 'holdShowEarned', 'holdShowVisible', `return ({${method}}).applyWear`)(Hub, { ...Avatar, style: () => 'toon', current: () => 1 }, { shown: () => 2 }, Role.roleWearing, Role.roleEarned, HoldShow.holdShowEarned, HoldShow.holdShowVisible);
|
|
187
188
|
const scene = sceneOf(); const draw = { wear: makeWear(), earned: makeEarned(), roles: makeRole() };
|
|
188
189
|
for (const [cls, shape] of [['belt', 'belt-plain'], ['sash', 'sash-plain'], ['held', 'held-lantern'], ['pin', 'pin-round']]) {
|
|
189
190
|
State.clear(); State.hub.earned.set('me', { class: cls, shape, color: '#abcdef' }); State.hub.roles.set('me', police);
|