castle-web-cli 0.4.239 → 0.4.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +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/platformDoc.js +2 -1
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- 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 +473 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +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 +851 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/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 +427 -54
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +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 +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-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-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-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-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-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 +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -53,6 +53,7 @@ function boot(keys = {}, more = {}) {
|
|
|
53
53
|
},
|
|
54
54
|
fall: more.fall,
|
|
55
55
|
resume: more.resume,
|
|
56
|
+
message: more.message,
|
|
56
57
|
leave(ctx, playerId) {
|
|
57
58
|
leaves.push(playerId);
|
|
58
59
|
more.leave?.(ctx, playerId);
|
|
@@ -1631,6 +1632,51 @@ for (const readFirst of [true, false]) {
|
|
|
1631
1632
|
}
|
|
1632
1633
|
}
|
|
1633
1634
|
|
|
1635
|
+
// A sign-up's account read that never settles lets the placed player go at
|
|
1636
|
+
// five seconds, logged, and a read landing afterwards keeps the carried look.
|
|
1637
|
+
{
|
|
1638
|
+
const realNow = Date.now, warn = console.warn, warned = [];
|
|
1639
|
+
let now = realNow();
|
|
1640
|
+
Date.now = () => now;
|
|
1641
|
+
console.warn = (...args) => warned.push(args.join(' '));
|
|
1642
|
+
try {
|
|
1643
|
+
const r = boot({ anonymousEntry: true, avatarColors: true }, { players: guestRoster() });
|
|
1644
|
+
const at = { x: 21, y: 2, z: -4 };
|
|
1645
|
+
r.ctx().placeAt('p2', at, 40);
|
|
1646
|
+
r.say('p2', { k: 'hub-hello', avatar: 7, color: 11, again: true });
|
|
1647
|
+
r.tick();
|
|
1648
|
+
let resolveRead;
|
|
1649
|
+
const read = new Promise((resolve) => { resolveRead = resolve; });
|
|
1650
|
+
r.session.hub = { arrival: () => null, readResults: (input) => input.userIds ? read : Promise.resolve({ boards: {} }) };
|
|
1651
|
+
Object.assign(r.session.players.find((p) => p.playerId === 'p2'), { username: 'Bo', isAnonymous: false });
|
|
1652
|
+
r.say('p2', { k: 'hub-hello', avatar: 0, color: 0, party: 1 });
|
|
1653
|
+
r.tick();
|
|
1654
|
+
const arrivals = r.arrivedTimes('p2');
|
|
1655
|
+
now += 2000; r.tick();
|
|
1656
|
+
assert.equal(r.arrivedTimes('p2'), arrivals, 'placed, still waiting on the read');
|
|
1657
|
+
assert.ok(r.server.join().held.includes('p2'));
|
|
1658
|
+
now += 4999; r.tick();
|
|
1659
|
+
assert.equal(r.arrivedTimes('p2'), arrivals, 'a read that settles in time holds as before');
|
|
1660
|
+
assert.equal(warned.some((line) => line.startsWith('[hub] arrival hold released')), false);
|
|
1661
|
+
now += 1; r.tick();
|
|
1662
|
+
assert.equal(r.arrivedTimes('p2'), arrivals + 1, 'the sign-up hold lets go at the bound');
|
|
1663
|
+
assert.equal(r.server.join().held.includes('p2'), false);
|
|
1664
|
+
assert.deepEqual(r.world.players.get('p2').at, at);
|
|
1665
|
+
assert.equal(r.server.join().hubAv2.p2, 7);
|
|
1666
|
+
assert.deepEqual(warned.filter((line) => line.startsWith('[hub] arrival hold released')), ['[hub] arrival hold released after 5 s: signup-results']);
|
|
1667
|
+
resolveRead({ players: { 102: { avatar: 0, avatarColor: 0 } }, boards: {} });
|
|
1668
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
1669
|
+
r.tick();
|
|
1670
|
+
assert.equal(r.server.join().hubAv2.p2, 7, 'a late read cannot replace the carried avatar');
|
|
1671
|
+
assert.equal(r.server.join().hubAvC.p2, 11);
|
|
1672
|
+
assert.equal(r.arrivedTimes('p2'), arrivals + 1, 'the late read replays no arrival');
|
|
1673
|
+
console.log('ok: an unsettled sign-up read releases at 5 s');
|
|
1674
|
+
} finally {
|
|
1675
|
+
Date.now = realNow;
|
|
1676
|
+
console.warn = warn;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1634
1680
|
// Terminal carry regression matrix against the real hub server: both orders,
|
|
1635
1681
|
// success/empty/rejection, delayed reads, repeated hellos, explicit choices,
|
|
1636
1682
|
// account switches and throwing authored arrivals. Carry is consumed once.
|
|
@@ -1776,6 +1822,25 @@ test('pose-only explicit travel cannot return to its old pose', () => {
|
|
|
1776
1822
|
assert.notEqual(r.world.players.get('p2').at.x, -3);
|
|
1777
1823
|
});
|
|
1778
1824
|
|
|
1825
|
+
test('v1.173 pose-only: a drop right after hub-back keeps no arrival pose; a stale or other-account mark does not', () => keeping((advance) => {
|
|
1826
|
+
for (const [how, restores] of [['back', false], ['stale', true], ['account', true]]) {
|
|
1827
|
+
const r = boot({ resumeArrivalPose: true });
|
|
1828
|
+
r.ctx().placeAt('p2', { x: -3, y: 1, z: -2 }, 40); r.tick();
|
|
1829
|
+
r.say('p2', { k: 'hub-back' }); r.tick();
|
|
1830
|
+
if (how === 'stale') {advance(36_000); r.tick();}
|
|
1831
|
+
// A new hello under another account on the same socket drops the mark.
|
|
1832
|
+
if (how === 'account') {
|
|
1833
|
+
r.session.players.find(p => p.playerId === 'p2').userId = '103';
|
|
1834
|
+
r.say('p2', rehello); r.tick(); r.tick();
|
|
1835
|
+
r.ctx().placeAt('p2', { x: -3, y: 1, z: -2 }, 40); r.tick();
|
|
1836
|
+
}
|
|
1837
|
+
r.drop(); r.tick(); r.back();
|
|
1838
|
+
if (how === 'account') {r.session.players.find(p => p.playerId === 'p2').userId = '103';}
|
|
1839
|
+
r.say('p2', rehello); r.tick();
|
|
1840
|
+
assert.equal(r.world.players.get('p2').at.x === -3, restores, how);
|
|
1841
|
+
}
|
|
1842
|
+
}));
|
|
1843
|
+
|
|
1779
1844
|
test('pose-only mode fails closed across changed or anonymous identity', () => {
|
|
1780
1845
|
for (const identity of [{ userId: '103', isAnonymous: false }, { userId: '102', isAnonymous: true }]) {
|
|
1781
1846
|
const r = boot({ resumeArrivalPose: true });
|
|
@@ -1985,4 +2050,176 @@ test('a lone arrival stepping off an occupied slot keeps clear of placed furnitu
|
|
|
1985
2050
|
console.log('ok: a drop without an end still restores its pose');
|
|
1986
2051
|
}
|
|
1987
2052
|
|
|
2053
|
+
// v1.173: the player's own Back (`hub-back`, said just before Hub.back) ends
|
|
2054
|
+
// the visit, so the next entry is a fresh arrival; a drop with no word still
|
|
2055
|
+
// resumes. A game, a repeat, an earlier trip and a player not here change
|
|
2056
|
+
// nothing, and the place's own message hook never hears it.
|
|
2057
|
+
{
|
|
2058
|
+
const floor = { id: 'floor', components: { Solid: {}, Transform: { x: 0, y: -0.07, z: 0 }, Shape: { kind: 'box', width: 40, height: 0.14, depth: 40 } } };
|
|
2059
|
+
const arrival = { x: 3, y: 1, z: -4 };
|
|
2060
|
+
const spot = { x: -3.5, y: 1, z: 2.3 };
|
|
2061
|
+
const heard = [];
|
|
2062
|
+
// One visit by p2: arrive, move to `spot`, then `before(r)` (the Back, or
|
|
2063
|
+
// nothing), a drop, and a return under the same account: a resume of the
|
|
2064
|
+
// same player id, or (`fresh`) a new connection with a new id.
|
|
2065
|
+
async function visit(keys, { before = () => {}, fresh = true, door = false } = {}) {
|
|
2066
|
+
const storage = makePoseStorage();
|
|
2067
|
+
const r = boot({ resumePose: true, arrival: { actor: 'arrival', spread: 0.65, face: 60 }, ...(door ? { places: { lobby: { title: 'Lobby', scene: 'scenes/lobby.scene' } } } : {}), ...keys }, {
|
|
2068
|
+
actors: [...actors, floor, { id: 'arrival', components: { Transform: arrival } },
|
|
2069
|
+
...(door ? [{ id: 'door', components: { HubDoor: { id: 'out', to: 'lobby' }, Transform: { x: 5, y: 0, z: 5 } } }] : [])],
|
|
2070
|
+
ground: { none: true }, storage, message: (c, player, data) => heard.push(data.k),
|
|
2071
|
+
});
|
|
2072
|
+
await flushPose(); r.tick(2000); r.tick();
|
|
2073
|
+
r.ctx().placeAt('p2', spot); r.tick();
|
|
2074
|
+
const from = r.sent.length;
|
|
2075
|
+
await before(r);
|
|
2076
|
+
const answered = toP2(r, from);
|
|
2077
|
+
r.tick(); r.drop(); r.tick(); await flushPose();
|
|
2078
|
+
const stored = [...storage.rows.keys()].filter((k) => k.includes('"102"')).length;
|
|
2079
|
+
let id = 'p2';
|
|
2080
|
+
if (fresh) {
|
|
2081
|
+
id = 'new-p2';
|
|
2082
|
+
r.session.players.push({ playerId: id, userId: '102', username: 'Bo', isAnonymous: false });
|
|
2083
|
+
r.world.players.set(id, body());
|
|
2084
|
+
r.say(id, { k: 'hub-hello', avatar: 1, party: 1 });
|
|
2085
|
+
} else {
|
|
2086
|
+
r.back(); r.say('p2', rehello);
|
|
2087
|
+
}
|
|
2088
|
+
await flushPose(); r.tick(2000); r.tick();
|
|
2089
|
+
const at = r.world.players.get(id).at;
|
|
2090
|
+
return { r, stored, answered, restored: Math.hypot(at.x - spot.x, at.z - spot.z) < 0.01 };
|
|
2091
|
+
}
|
|
2092
|
+
const backOnce = (r) => r.say('p2', { k: 'hub-back' });
|
|
2093
|
+
|
|
2094
|
+
for (const fresh of [true, false]) {
|
|
2095
|
+
const how = fresh ? 'a new connection' : 'a same-id resume';
|
|
2096
|
+
const control = await visit({}, { fresh });
|
|
2097
|
+
assert.equal(control.restored, true, `${how}: a drop with no hub-back restores the stored pose`);
|
|
2098
|
+
const backed = await visit({}, { fresh, before: backOnce });
|
|
2099
|
+
assert.equal(backed.restored, false, `${how}: after hub-back the return is placed at the arrival`);
|
|
2100
|
+
assert.deepEqual(backed.answered, [], 'hub-back is answered with nothing');
|
|
2101
|
+
assert.equal(backed.stored, 0, 'hub-back leaves no durable pose');
|
|
2102
|
+
if (!fresh) {assert.equal(backed.r.arrivedTimes('p2'), 2, 'the same-id return arrives afresh');}
|
|
2103
|
+
console.log(`ok: hub-back ends the visit: ${how} after it is a fresh arrival; without it the pose is restored`);
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
const twice = await visit({}, { before: (r) => { backOnce(r); r.tick(); backOnce(r); backOnce(r); } });
|
|
2107
|
+
assert.equal(twice.restored, false);
|
|
2108
|
+
assert.deepEqual(twice.answered, [], 'a repeat sends nothing');
|
|
2109
|
+
console.log('ok: a repeated hub-back is harmless');
|
|
2110
|
+
|
|
2111
|
+
const gone = await visit({}, { door: true, before: (r) => { assert.ok(r.ctx().go('out', ['p2'])); const n = r.sent.length; backOnce(r); assert.deepEqual(toP2(r, n), [], 'hub-back after the trip sends nothing'); } });
|
|
2112
|
+
const goneAlone = await visit({}, { door: true, before: (r) => { assert.ok(r.ctx().go('out', ['p2'])); } });
|
|
2113
|
+
const kinds = (ms) => ms.map((m) => [m.k, m.door]);
|
|
2114
|
+
assert.deepEqual(kinds(gone.answered), kinds(goneAlone.answered), 'the trip says the same with or without a hub-back after it');
|
|
2115
|
+
assert.equal(gone.restored, false); assert.equal(goneAlone.restored, false);
|
|
2116
|
+
console.log('ok: hub-back after a kit trip (sendGo) is a no-op');
|
|
2117
|
+
|
|
2118
|
+
// A player the session does not list (an id it never had, or one briefly
|
|
2119
|
+
// out of the roster) ends no visit: the later drop still resumes.
|
|
2120
|
+
const unlisted = await visit({}, { fresh: false, before: (r) => {
|
|
2121
|
+
r.say('ghost', { k: 'hub-back' });
|
|
2122
|
+
const row = r.session.players.find((p) => p.playerId === 'p2');
|
|
2123
|
+
r.session.players = r.session.players.filter((p) => p !== row);
|
|
2124
|
+
backOnce(r);
|
|
2125
|
+
r.session.players.push(row);
|
|
2126
|
+
} });
|
|
2127
|
+
assert.equal(unlisted.restored, true, 'the unlisted hub-back is ignored');
|
|
2128
|
+
console.log('ok: hub-back from a player not in the roster is ignored');
|
|
2129
|
+
|
|
2130
|
+
// A session that shuts down before any tick saw the drop still lets the
|
|
2131
|
+
// Back's visit go, and keeps a plain drop's pose as before.
|
|
2132
|
+
for (const backed of [false, true]) {
|
|
2133
|
+
const storage = makePoseStorage();
|
|
2134
|
+
const r = boot({ resumePose: true, arrival: { actor: 'arrival', spread: 0.65, face: 60 } }, {
|
|
2135
|
+
actors: [...actors, floor, { id: 'arrival', components: { Transform: arrival } }], ground: { none: true }, storage,
|
|
2136
|
+
});
|
|
2137
|
+
await flushPose(); r.tick(2000); r.tick();
|
|
2138
|
+
r.ctx().placeAt('p2', spot); r.tick();
|
|
2139
|
+
if (backed) {backOnce(r);}
|
|
2140
|
+
r.drop();
|
|
2141
|
+
await r.server.shutdown(r.session); await flushPose();
|
|
2142
|
+
const stored = [...storage.rows.keys()].filter((k) => k.includes('"102"')).length;
|
|
2143
|
+
assert.equal(stored, backed ? 0 : 1, backed ? 'a Back before shutdown keeps no pose' : 'a plain drop at shutdown keeps its pose');
|
|
2144
|
+
}
|
|
2145
|
+
console.log('ok: hub-back then a shutdown before the next tick keeps no pose');
|
|
2146
|
+
|
|
2147
|
+
// The Back only arms: with no drop inside the window (Hub.back refused or
|
|
2148
|
+
// timed out, the player still here), a later genuine drop resumes.
|
|
2149
|
+
{
|
|
2150
|
+
const realNow = Date.now;
|
|
2151
|
+
let now = realNow();
|
|
2152
|
+
Date.now = () => now;
|
|
2153
|
+
try {
|
|
2154
|
+
for (const fresh of [true, false]) {
|
|
2155
|
+
const stale = await visit({}, { fresh, before: (r) => { backOnce(r); r.tick(); now += 36_000; r.tick(); } });
|
|
2156
|
+
assert.equal(stale.restored, true, `${fresh ? 'a new connection' : 'a same-id resume'}: a Back whose window passed leaves the visit as it was`);
|
|
2157
|
+
assert.equal(stale.stored, 1, 'the drop stores the pose as usual');
|
|
2158
|
+
if (!fresh) {assert.equal(stale.r.arrivedTimes('p2'), 1, 'resumed, not arrived again');}
|
|
2159
|
+
const inside = await visit({}, { fresh, before: (r) => { backOnce(r); r.tick(); now += 30_000; r.tick(); } });
|
|
2160
|
+
assert.equal(inside.restored, false, 'a drop inside the window is the Back leaving');
|
|
2161
|
+
// A repeat refreshes the mark: 20 s + 20 s is still inside.
|
|
2162
|
+
const refreshed = await visit({}, { fresh, before: (r) => { backOnce(r); now += 20_000; r.tick(); backOnce(r); now += 20_000; r.tick(); } });
|
|
2163
|
+
assert.equal(refreshed.restored, false, 'a repeated hub-back refreshes the window');
|
|
2164
|
+
}
|
|
2165
|
+
} finally {
|
|
2166
|
+
Date.now = realNow;
|
|
2167
|
+
}
|
|
2168
|
+
console.log('ok: hub-back only arms: a drop inside 35 s ends the visit, one after it resumes');
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
// A pending pose read holds the whole arrival group. A hub-back before
|
|
2172
|
+
// arrival is ignored, and a read discarded by a departure still ends its
|
|
2173
|
+
// wait, so the others in the group arrive.
|
|
2174
|
+
for (const how of ['back', 'end']) {
|
|
2175
|
+
const base = makePoseStorage();
|
|
2176
|
+
let release = null;
|
|
2177
|
+
const storage = { ...base, rows: base.rows, snapshot: async (a) => { if (release) {await release.promise;} return base.snapshot(a); } };
|
|
2178
|
+
const r = boot({ resumePose: true }, { storage });
|
|
2179
|
+
await flushPose(); r.tick(2000); r.tick();
|
|
2180
|
+
release = Promise.withResolvers();
|
|
2181
|
+
for (const [id, userId] of [['p3', '103'], ['p4', '104']]) {
|
|
2182
|
+
r.session.players.push({ playerId: id, userId, username: id, isAnonymous: false });
|
|
2183
|
+
r.world.players.set(id, body());
|
|
2184
|
+
r.say(id, { k: 'hub-hello', avatar: 1, party: 1 });
|
|
2185
|
+
}
|
|
2186
|
+
if (how === 'back') {r.say('p3', { k: 'hub-back' });} else {r.ctx().end(['p3']);}
|
|
2187
|
+
r.tick(2000); r.tick();
|
|
2188
|
+
assert.equal(r.arrivedTimes('p4'), 0, 'the group waits on the reads');
|
|
2189
|
+
const resolve = release.resolve; release = null; resolve();
|
|
2190
|
+
await flushPose(); r.tick(2000); r.tick();
|
|
2191
|
+
assert.equal(r.arrivedTimes('p4'), 1, `the group arrives after a ${how} during p3's read`);
|
|
2192
|
+
if (how === 'back') {assert.equal(r.arrivedTimes('p3'), 1, 'and the early hub-back changed nothing for p3');}
|
|
2193
|
+
}
|
|
2194
|
+
console.log('ok: hub-back before arrival is ignored, and a discarded pose read never holds the group');
|
|
2195
|
+
|
|
2196
|
+
// A game (`result`) is unchanged by it: the same bytes, and a retained
|
|
2197
|
+
// hello still reaches the resume hook (a departing player's would not).
|
|
2198
|
+
for (const keys of [result, { ...result, resume: true }]) {
|
|
2199
|
+
const run = (backFirst) => {
|
|
2200
|
+
const calls = [];
|
|
2201
|
+
const r = boot(keys, { resume: (c, { playerId }) => calls.push(playerId), message: (c, player, data) => heard.push(data.k) });
|
|
2202
|
+
if (backFirst) {backOnce(r); backOnce(r);}
|
|
2203
|
+
r.tick(); r.say('p2', rehello); r.tick(); r.tick();
|
|
2204
|
+
return { calls, sent: r.sent, arrivals: r.arrivals };
|
|
2205
|
+
};
|
|
2206
|
+
const plain = run(false);
|
|
2207
|
+
const backed = run(true);
|
|
2208
|
+
assert.deepEqual(plain.calls, ['p2'], 'the game resumes the retained hello');
|
|
2209
|
+
assert.deepEqual(backed.calls, plain.calls, 'hub-back in a game does not mark the player departing');
|
|
2210
|
+
assert.deepEqual(backed.sent, plain.sent, 'a game sends the same bytes');
|
|
2211
|
+
assert.deepEqual(backed.arrivals, plain.arrivals);
|
|
2212
|
+
}
|
|
2213
|
+
console.log('ok: hub-back in a place with result changes nothing');
|
|
2214
|
+
|
|
2215
|
+
// A place that retains no visit: nothing to end, and still never the hook's.
|
|
2216
|
+
{
|
|
2217
|
+
const r = boot({}, { message: (c, player, data) => heard.push(data.k) });
|
|
2218
|
+
r.say('p2', { k: 'hub-back' }); r.tick();
|
|
2219
|
+
r.drop(); r.tick(); r.back(); r.say('p2', rehello); r.tick(2000); r.tick();
|
|
2220
|
+
}
|
|
2221
|
+
assert.equal(heard.includes('hub-back'), false, 'the place message hook never hears hub-back');
|
|
2222
|
+
console.log('ok: hub-back is consumed by the kit, never passed to the place hook');
|
|
2223
|
+
}
|
|
2224
|
+
|
|
1988
2225
|
console.log(`rehello: ${passed} tests passed`);
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// A rejoin under a new player id on the same connection (the page away past
|
|
2
|
+
// the place's reconnect window) keeps the camera yaw; a fresh arrival, a trip's
|
|
3
|
+
// arrival and another connection's arrival still face the arrival.
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import { register } from 'node:module';
|
|
6
|
+
|
|
7
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
8
|
+
import { readFile } from 'node:fs/promises';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
export async function resolve(specifier, context, next) {
|
|
11
|
+
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 };
|
|
12
|
+
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 };
|
|
13
|
+
if (specifier === 'castle-web-sdk') return { url: 'data:text/javascript,export {};', shortCircuit: true };
|
|
14
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/client/avatars.js') return { url: 'data:text/javascript,export const dropMissing = () => {};', shortCircuit: true };
|
|
15
|
+
if (specifier.startsWith('@imports/castle.physics-2d/engine/')) return { url: 'data:text/javascript,export const initialMedia = {}; export const playMedia = () => {}; export const stopMedia = () => {};', shortCircuit: true };
|
|
16
|
+
if (specifier === '../client/pack.js') return { url: 'data:text/javascript,export const cachedPacks = () => []; export const loadPack = () => {}; export const matchesOwn = () => false; export const resolveDeckDoor = () => {};', shortCircuit: true };
|
|
17
|
+
return next(specifier, context);
|
|
18
|
+
}
|
|
19
|
+
export async function load(url, context, next) {
|
|
20
|
+
if (url.endsWith('/code/client/hookLayer.js')) {
|
|
21
|
+
const source = await readFile(fileURLToPath(url), 'utf8');
|
|
22
|
+
return { format: 'module', source: source.replaceAll('import.meta.glob(', '(() => ({}))('), shortCircuit: true };
|
|
23
|
+
}
|
|
24
|
+
return next(url, context);
|
|
25
|
+
}
|
|
26
|
+
`)}`);
|
|
27
|
+
const State = await import('../code/client/state.js');
|
|
28
|
+
const { installSystem } = await import('../code/systems/hub.js');
|
|
29
|
+
|
|
30
|
+
let system;
|
|
31
|
+
installSystem({ registerSystem(value) { system = value; } });
|
|
32
|
+
const net = { selfId: () => 'p2' };
|
|
33
|
+
const scene = (camAngle, n = net) => ({ persistent: { camAngle }, multiplayer: { net: n } });
|
|
34
|
+
const log = console.log;
|
|
35
|
+
console.log = () => {};
|
|
36
|
+
|
|
37
|
+
// Fresh arrival: the camera starts behind the arrival facing.
|
|
38
|
+
State.clear();
|
|
39
|
+
State.hub.arrivedFacing = 0.5;
|
|
40
|
+
let s = scene(1);
|
|
41
|
+
system.faceArrival(s);
|
|
42
|
+
assert.equal(s.persistent.camAngle, Math.PI - 0.5);
|
|
43
|
+
assert.equal(State.hub.faced, true);
|
|
44
|
+
|
|
45
|
+
// A page that never arrived keeps nothing: its first arrival faces.
|
|
46
|
+
system.helloNet = net;
|
|
47
|
+
State.clear();
|
|
48
|
+
system.newIdentity();
|
|
49
|
+
State.hub.arrivedFacing = 0.5;
|
|
50
|
+
s = scene(1);
|
|
51
|
+
system.faceArrival(s);
|
|
52
|
+
assert.equal(s.persistent.camAngle, Math.PI - 0.5, 'no arrival yet: faces');
|
|
53
|
+
|
|
54
|
+
// A rejoin during a trip keeps nothing, even if the arrival lands after it.
|
|
55
|
+
system.trip = {};
|
|
56
|
+
system.newIdentity();
|
|
57
|
+
system.trip = null;
|
|
58
|
+
State.hub.arrivedFacing = 0.5;
|
|
59
|
+
s = scene(1);
|
|
60
|
+
system.faceArrival(s);
|
|
61
|
+
assert.equal(s.persistent.camAngle, Math.PI - 0.5, 'rejoin under a trip: faces');
|
|
62
|
+
|
|
63
|
+
// Rejoin on the same connection: the yaw the player had is kept.
|
|
64
|
+
system.newIdentity();
|
|
65
|
+
assert.equal(State.hub.faced, false);
|
|
66
|
+
State.hub.arrivedFacing = -0.443;
|
|
67
|
+
s = scene(1);
|
|
68
|
+
system.faceArrival(s);
|
|
69
|
+
assert.equal(s.persistent.camAngle, 1, 'rejoin keeps the camera yaw');
|
|
70
|
+
assert.equal(State.hub.faced, true);
|
|
71
|
+
assert.equal(s.faceRequest, undefined, 'and the avatar facing');
|
|
72
|
+
|
|
73
|
+
// Once only: the next arrival on that connection faces again.
|
|
74
|
+
State.hub.faced = false;
|
|
75
|
+
system.faceArrival(s);
|
|
76
|
+
assert.equal(s.persistent.camAngle, Math.PI + 0.443);
|
|
77
|
+
|
|
78
|
+
// A trip's arrival after a rejoin faces, and spends the keep.
|
|
79
|
+
State.hub.faced = true;
|
|
80
|
+
system.newIdentity();
|
|
81
|
+
State.hub.arrivedFacing = 0.25;
|
|
82
|
+
system.trip = {};
|
|
83
|
+
s = scene(1);
|
|
84
|
+
system.faceArrival(s);
|
|
85
|
+
assert.equal(s.persistent.camAngle, Math.PI - 0.25);
|
|
86
|
+
system.trip = null;
|
|
87
|
+
State.hub.faced = false;
|
|
88
|
+
s = scene(1);
|
|
89
|
+
system.faceArrival(s);
|
|
90
|
+
assert.equal(s.persistent.camAngle, Math.PI - 0.25);
|
|
91
|
+
|
|
92
|
+
// An arrival on another connection faces.
|
|
93
|
+
State.hub.faced = true;
|
|
94
|
+
system.newIdentity();
|
|
95
|
+
State.hub.arrivedFacing = 0.25;
|
|
96
|
+
s = scene(1, { selfId: () => 'p3' });
|
|
97
|
+
system.faceArrival(s);
|
|
98
|
+
assert.equal(s.persistent.camAngle, Math.PI - 0.25);
|
|
99
|
+
|
|
100
|
+
// No yaw yet on the page: faces.
|
|
101
|
+
State.hub.faced = true;
|
|
102
|
+
system.newIdentity();
|
|
103
|
+
State.hub.arrivedFacing = 0.25;
|
|
104
|
+
s = { persistent: {}, multiplayer: { net } };
|
|
105
|
+
system.faceArrival(s);
|
|
106
|
+
assert.equal(s.persistent.camAngle, Math.PI - 0.25);
|
|
107
|
+
|
|
108
|
+
// A fixed-view arrival still waiting for its shot does not turn a kept rejoin.
|
|
109
|
+
const { faceArrivalCamera, seedArrivalShot } = await import('../code/client/arrivalCamera.js');
|
|
110
|
+
s = { persistent: { camAngle: 0 }, multiplayer: { net, generation: 1 }, cameraControl: 'orbit',
|
|
111
|
+
data: { engine: { camera: { arrivalFromShot: { yaw: -38 } } } }, currentScenePath: 'a', sceneKey: 'k' };
|
|
112
|
+
State.clear();
|
|
113
|
+
faceArrivalCamera(s, 0.2);
|
|
114
|
+
State.hub.faced = true;
|
|
115
|
+
system.newIdentity();
|
|
116
|
+
s.persistent.camAngle = 1;
|
|
117
|
+
State.hub.arrivedFacing = 0.2;
|
|
118
|
+
system.faceArrival(s);
|
|
119
|
+
assert.equal(s.persistent.camAngle, 1);
|
|
120
|
+
seedArrivalShot(s, { yaw: -38, pitch: 30, distance: 10 });
|
|
121
|
+
assert.equal(s.persistent.camAngle, 1, 'the earlier wait for a shot was cancelled');
|
|
122
|
+
|
|
123
|
+
// Nor does the new session's shot when it comes before the arrival.
|
|
124
|
+
State.clear();
|
|
125
|
+
faceArrivalCamera(s, 0.2);
|
|
126
|
+
State.hub.faced = true;
|
|
127
|
+
system.scene = s;
|
|
128
|
+
system.freshSession = () => {};
|
|
129
|
+
system.newIdentity();
|
|
130
|
+
s.persistent.camAngle = 1;
|
|
131
|
+
seedArrivalShot(s, { yaw: -38, pitch: 30, distance: 10 });
|
|
132
|
+
assert.equal(s.persistent.camAngle, 1, 'a shot before the rejoin arrival does not turn it');
|
|
133
|
+
State.hub.arrivedFacing = 0.2;
|
|
134
|
+
system.faceArrival(s);
|
|
135
|
+
assert.equal(s.persistent.camAngle, 1);
|
|
136
|
+
|
|
137
|
+
console.log = log;
|
|
138
|
+
console.log('test-rejoin-yaw: ok');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import { register } from 'node:module';
|
|
3
|
-
import { friendsAmong, prime, tick } from '../code/server/friendsAmong.js';
|
|
3
|
+
import { EARLY_EMPTY_MS, EARLY_WINDOW_MS, friendsAmong, prime, tick } from '../code/server/friendsAmong.js';
|
|
4
4
|
|
|
5
5
|
// Exercise SDK source without a build or changing the generated base kit.
|
|
6
6
|
register(`data:text/javascript,${encodeURIComponent(`
|
|
@@ -55,7 +55,9 @@ let now = 100000;
|
|
|
55
55
|
Date.now = () => now;
|
|
56
56
|
console.warn = () => {};
|
|
57
57
|
const flush = () => new Promise((resolve) => setImmediate(resolve));
|
|
58
|
-
|
|
58
|
+
// `seen`: accounts that already read in this session, so none of their reads is the
|
|
59
|
+
// session's provisional first (v1.166); the cases that predate it describe those.
|
|
60
|
+
function room(on = true, relations = async (_id, ids) => ({ friends: [], follows: ids, followedBy: [] }), seen = ['1']) {
|
|
59
61
|
const identities = new Map([['a', '1'], ['b', '2'], ['guest', null], ['dev', 'dev-guest-1']]);
|
|
60
62
|
const calls = [], sent = [];
|
|
61
63
|
const h = {
|
|
@@ -66,6 +68,7 @@ function room(on = true, relations = async (_id, ids) => ({ friends: [], follows
|
|
|
66
68
|
friendsAmong: async (id, ids) => { calls.push({ op: 'friends', id, ids, at: now }); return ids; },
|
|
67
69
|
relationsAmong: (id, ids) => { calls.push({ op: 'relations', id, ids, at: now }); return relations(id, ids); },
|
|
68
70
|
} },
|
|
71
|
+
friendsRead: new Map(seen.map((userId) => [userId, -Infinity])),
|
|
69
72
|
};
|
|
70
73
|
const identity = (_h, id) => identities.get(id);
|
|
71
74
|
return { h, calls, sent, identity, add(id, userId = id) {
|
|
@@ -142,10 +145,12 @@ try {
|
|
|
142
145
|
assert.equal(capped.calls[0].ids.length, 100);
|
|
143
146
|
assert.deepEqual(capped.calls[0].ids.slice(0, 4), ['999', '998', '2', '10']);
|
|
144
147
|
|
|
145
|
-
// Five minutes of arrivals, both nonempty and empty answers
|
|
146
|
-
// traffic respects the minimum read gap for every
|
|
148
|
+
// Five minutes of arrivals, both nonempty and empty answers, every account new
|
|
149
|
+
// to the session: background traffic respects the minimum read gap for every
|
|
150
|
+
// signed-in player, except one early re-read of a provisional first empty
|
|
151
|
+
// answer (v1.166), and never more than two reads in an account's first minute.
|
|
147
152
|
for (const empty of [false, true]) {
|
|
148
|
-
const rate = room(true, async (_id, ids) => ({ friends: [], follows: empty ? [] : ids, followedBy: [] }));
|
|
153
|
+
const rate = room(true, async (_id, ids) => ({ friends: [], follows: empty ? [] : ids, followedBy: [] }), []);
|
|
149
154
|
const start = now;
|
|
150
155
|
for (let seconds = 0; seconds <= 300; seconds += 5) {
|
|
151
156
|
now = start + seconds * 1000;
|
|
@@ -155,8 +160,9 @@ try {
|
|
|
155
160
|
}
|
|
156
161
|
for (const id of new Set(rate.calls.map((call) => call.id))) {
|
|
157
162
|
const times = rate.calls.filter((call) => call.id === id).map((call) => call.at);
|
|
158
|
-
assert.ok(times.every((at, i) => i === 0 || at - times[i - 1] >= 31000), `${id}: minimum read gap`);
|
|
159
|
-
assert.ok(times.
|
|
163
|
+
assert.ok(times.every((at, i) => i === 0 || at - times[i - 1] >= (i === 1 ? EARLY_EMPTY_MS : 31000)), `${id}: minimum read gap`);
|
|
164
|
+
assert.ok(times.filter((at) => at - times[0] < EARLY_WINDOW_MS).length <= 2, `${id}: two reads in the first minute`);
|
|
165
|
+
assert.ok(times.length <= Math.floor(300000 / 31000) + 2, `${id}: five minute count bound`);
|
|
160
166
|
}
|
|
161
167
|
assert.ok(rate.calls.every(({ id, op }) => !['guest', 'dev'].includes(id) && op === 'relations'));
|
|
162
168
|
}
|
|
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
|
|
2
2
|
import test from 'node:test';
|
|
3
3
|
import { execFile } from 'node:child_process';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
|
-
import { friendsAmong, prime, tick } from '../code/server/friendsAmong.js';
|
|
5
|
+
import { EARLY_EMPTY_MS, EARLY_WINDOW_MS, emptyFor, forget, friendsAmong, prime, tick } from '../code/server/friendsAmong.js';
|
|
6
6
|
import { friendBests } from '../code/server/friendBests.js';
|
|
7
7
|
|
|
8
8
|
const { stdout } = await promisify(execFile)('git', [
|
|
@@ -18,7 +18,9 @@ Date.now = () => now;
|
|
|
18
18
|
console.warn = () => {};
|
|
19
19
|
const flush = () => new Promise((resolve) => setImmediate(resolve));
|
|
20
20
|
const empty = () => ({ friends: [], follows: [], followedBy: [] });
|
|
21
|
-
|
|
21
|
+
// `seen`: both accounts read earlier in this session, so no read is a session's
|
|
22
|
+
// provisional first (v1.166); the cases below that predate it describe those reads.
|
|
23
|
+
function room(relations, on = true, seen = true) {
|
|
22
24
|
const calls = [], sent = [];
|
|
23
25
|
const identity = (_h, id) => ({ a: '1', b: '2' })[id] ?? null;
|
|
24
26
|
const h = {
|
|
@@ -34,6 +36,7 @@ function room(relations, on = true) {
|
|
|
34
36
|
},
|
|
35
37
|
},
|
|
36
38
|
ctx: {},
|
|
39
|
+
...(seen ? { friendsRead: new Map([['1', -Infinity], ['2', -Infinity]]) } : {}),
|
|
37
40
|
};
|
|
38
41
|
h.ctx.friendsAmong = (id, ids) => friendsAmong(h, id, ids, identity);
|
|
39
42
|
return { h, calls, sent, identity };
|
|
@@ -154,6 +157,91 @@ try {
|
|
|
154
157
|
}
|
|
155
158
|
});
|
|
156
159
|
|
|
160
|
+
await test('v1.166: a session\'s first empty prime is redone after 5 s, then nothing until a minute after the first', async () => {
|
|
161
|
+
let marked = false;
|
|
162
|
+
const r = room(async (_id, ids) => ({ ...empty(), friends: marked ? ids.filter((id) => id === '2') : [] }), true, false);
|
|
163
|
+
const start = now;
|
|
164
|
+
for (let elapsed = 0; elapsed <= 120000; elapsed += 1000) {
|
|
165
|
+
now = start + elapsed;
|
|
166
|
+
// Deck asks naming new off-place ids every few seconds press for reads.
|
|
167
|
+
if (elapsed % 3000 === 0) await r.h.ctx.friendsAmong('a', [String(100 + elapsed)]);
|
|
168
|
+
tick(r.h, r.identity);
|
|
169
|
+
await flush();
|
|
170
|
+
}
|
|
171
|
+
for (const id of ['a', 'b']) {
|
|
172
|
+
const reads = r.calls.filter((call) => call.id === id).map((call) => call.at - start);
|
|
173
|
+
assert.ok(reads[1] - reads[0] >= EARLY_EMPTY_MS && reads[1] - reads[0] < GAP, `${id}: one early re-read`);
|
|
174
|
+
assert.equal(reads.filter((at) => at - reads[0] < EARLY_WINDOW_MS).length, 2, `${id}: two reads in the first minute`);
|
|
175
|
+
assert.ok(reads[2] - reads[0] >= EARLY_WINDOW_MS, `${id}: the third waits out the window`);
|
|
176
|
+
assert.ok(reads.slice(2).every((at, i) => at - reads[i + 1] >= GAP), `${id}: then the usual gap`);
|
|
177
|
+
}
|
|
178
|
+
// The early re-read sees a friend ghost marked meanwhile.
|
|
179
|
+
const late = room(async (_id, ids) => (marked ? ids : []), false, false);
|
|
180
|
+
marked = false;
|
|
181
|
+
const begin = now;
|
|
182
|
+
assert.deepEqual(await late.h.ctx.friendsAmong('a', ['2']), []);
|
|
183
|
+
assert.equal(late.h.friendsCache.get('a').ttl, EARLY_EMPTY_MS);
|
|
184
|
+
marked = true;
|
|
185
|
+
now = begin + EARLY_EMPTY_MS - 1;
|
|
186
|
+
assert.deepEqual(await late.h.ctx.friendsAmong('a', ['2']), []);
|
|
187
|
+
now = begin + EARLY_EMPTY_MS;
|
|
188
|
+
assert.deepEqual(await late.h.ctx.friendsAmong('a', ['2']), ['2']);
|
|
189
|
+
assert.equal(late.calls.length, 2);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
await test('v1.166: keyless, a later empty after the early re-read waits out the first minute; a rejoin is no new first', async () => {
|
|
193
|
+
const r = room(async () => [], false, false);
|
|
194
|
+
const start = now;
|
|
195
|
+
assert.deepEqual(await r.h.ctx.friendsAmong('a', ['2']), []);
|
|
196
|
+
now = start + EARLY_EMPTY_MS;
|
|
197
|
+
assert.deepEqual(await r.h.ctx.friendsAmong('a', ['2']), []);
|
|
198
|
+
assert.equal(r.calls.length, 2);
|
|
199
|
+
now = start + EARLY_WINDOW_MS - 1;
|
|
200
|
+
assert.deepEqual(await r.h.ctx.friendsAmong('a', ['2']), []);
|
|
201
|
+
assert.equal(r.calls.length, 2);
|
|
202
|
+
now = start + EARLY_WINDOW_MS;
|
|
203
|
+
assert.deepEqual(await r.h.ctx.friendsAmong('a', ['2']), []);
|
|
204
|
+
assert.equal(r.calls.length, 3);
|
|
205
|
+
assert.equal(r.h.friendsCache.get('a').ttl, EMPTY, 'outside the window, empties keep 40 s');
|
|
206
|
+
// Leaving and coming back in the same session is not another first read.
|
|
207
|
+
forget(r.h, 'a');
|
|
208
|
+
r.h.friendsCache.delete('a');
|
|
209
|
+
now += 1;
|
|
210
|
+
assert.deepEqual(await r.h.ctx.friendsAmong('a', ['2']), []);
|
|
211
|
+
assert.equal(r.h.friendsCache.get('a').ttl, EMPTY);
|
|
212
|
+
assert.equal(r.h.friendsCache.get('a').provisional, false);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
await test('an ask waiting on a prime starts no read once the account has changed', async () => {
|
|
216
|
+
let settle;
|
|
217
|
+
const r = room(() => new Promise((resolve) => { settle = resolve; }), true, false);
|
|
218
|
+
let who = '1';
|
|
219
|
+
const identity = (_h, id) => (id === 'a' ? who : { b: '2' }[id]);
|
|
220
|
+
prime(r.h, 'a', identity);
|
|
221
|
+
const ask = friendsAmong(r.h, 'a', ['9'], identity);
|
|
222
|
+
who = '3';
|
|
223
|
+
now += EARLY_EMPTY_MS;
|
|
224
|
+
settle(empty());
|
|
225
|
+
assert.deepEqual(await ask, []);
|
|
226
|
+
assert.equal(r.calls.filter(({ id }) => id === 'a').length, 1, 'no covering read for another account');
|
|
227
|
+
assert.equal(r.h.friendsCache.get('a').owner, '1');
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
await test('v1.166: friendBests keeps an empty answer only until friendsAmong may read again, even after a friend', async () => {
|
|
231
|
+
const r = room(async (_id, ids) => ({ ...empty(), friends: r.calls.length > 1 ? ids.filter((id) => id === '2') : [] }), true, false);
|
|
232
|
+
const start = now;
|
|
233
|
+
prime(r.h, 'a', r.identity);
|
|
234
|
+
await flush();
|
|
235
|
+
assert.equal(emptyFor(r.h, 'a', '1'), EARLY_EMPTY_MS);
|
|
236
|
+
now = start + EARLY_EMPTY_MS;
|
|
237
|
+
prime(r.h, 'a', r.identity);
|
|
238
|
+
await flush();
|
|
239
|
+
assert.deepEqual(r.h.friendsCache.get('a').ids, ['2']);
|
|
240
|
+
// Uncovered candidates may be read at the end of the first minute, not in 10 min.
|
|
241
|
+
assert.equal(emptyFor(r.h, 'a', '1'), EARLY_WINDOW_MS - EARLY_EMPTY_MS);
|
|
242
|
+
assert.equal(emptyFor(r.h, 'a', '2'), EMPTY);
|
|
243
|
+
});
|
|
244
|
+
|
|
157
245
|
await test('keyless answers, calls, args and timestamps equal origin/main', async () => {
|
|
158
246
|
async function trace(api) {
|
|
159
247
|
now = 100000;
|