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
|
@@ -19,6 +19,10 @@ import { AUDIO_TYPES, MEDIA_TYPES, PACK_FORMAT, PACK_VERSION, TEXT_EXTS, extOf,
|
|
|
19
19
|
|
|
20
20
|
const KIT_ALIAS = 'castle.hub-game';
|
|
21
21
|
const SKIP_DIRS = new Set(['node_modules', '.castle', 'dist', '.git']);
|
|
22
|
+
// Behind a symlink -- an import linked to a kit checkout -- these are the
|
|
23
|
+
// checkout's own, never the deck's, and are not walked. A reference into one
|
|
24
|
+
// refuses the pack rather than going missing.
|
|
25
|
+
const LINKED_SKIP_DIRS = new Set(['node_modules', '.git']);
|
|
22
26
|
// The kit's avatars are the engine's, never a game's.
|
|
23
27
|
const AVATAR = /^(imports\/castle\.hub-game\/)?blueprints\/((blocky|bean|pixel)\/)?avatar-\d+\.scene$/;
|
|
24
28
|
// The kits a hub game's content is drawn by; their pins say which engine it
|
|
@@ -32,7 +36,13 @@ export default async function pack({ deckDir, self = false, outFile }) {
|
|
|
32
36
|
return { errors, warnings: [] };
|
|
33
37
|
}
|
|
34
38
|
const available = new Set();
|
|
35
|
-
|
|
39
|
+
const walkErrors = [];
|
|
40
|
+
const skipped = [];
|
|
41
|
+
const found = walk(deckDir, walkErrors, skipped);
|
|
42
|
+
if (walkErrors.length) {
|
|
43
|
+
return { errors: walkErrors, warnings: [] };
|
|
44
|
+
}
|
|
45
|
+
for (const rel of found) {
|
|
36
46
|
if (isPackPath(rel) && (TEXT_EXTS.includes(extOf(rel)) || MEDIA_TYPES[extOf(rel)]) && !AVATAR.test(rel)) {
|
|
37
47
|
available.add(rel);
|
|
38
48
|
}
|
|
@@ -44,7 +54,11 @@ export default async function pack({ deckDir, self = false, outFile }) {
|
|
|
44
54
|
roots.push(place.sign.model);
|
|
45
55
|
}
|
|
46
56
|
}
|
|
47
|
-
const
|
|
57
|
+
const closureErrors = [];
|
|
58
|
+
const included = closure(deckDir, roots, available, skipped, closureErrors);
|
|
59
|
+
if (closureErrors.length) {
|
|
60
|
+
return { errors: [...new Set(closureErrors)], warnings: [] };
|
|
61
|
+
}
|
|
48
62
|
|
|
49
63
|
const files = {};
|
|
50
64
|
const media = {};
|
|
@@ -105,9 +119,24 @@ export default async function pack({ deckDir, self = false, outFile }) {
|
|
|
105
119
|
// deck has: as written, without a leading `@` or `./`, or -- inside an
|
|
106
120
|
// import's file -- relative to that import, the way the engine resolves
|
|
107
121
|
// blueprint, model and art refs.
|
|
108
|
-
function closure(deckDir, roots, available) {
|
|
122
|
+
function closure(deckDir, roots, available, skipped, errors) {
|
|
123
|
+
const inSkipped = (candidate) => skipped.find((dir) => candidate.startsWith(`${dir}/`));
|
|
109
124
|
const seen = new Set();
|
|
110
|
-
const queue =
|
|
125
|
+
const queue = [];
|
|
126
|
+
// Every reference -- a manifest root, or a string in a scene, blueprint or
|
|
127
|
+
// model -- goes through here: one the walk skipped refuses the pack.
|
|
128
|
+
const reach = (candidate, from) => {
|
|
129
|
+
if (available.has(candidate)) {
|
|
130
|
+
if (!seen.has(candidate)) {
|
|
131
|
+
queue.push(candidate);
|
|
132
|
+
}
|
|
133
|
+
} else if (inSkipped(candidate)) {
|
|
134
|
+
errors.push(`content pack: ${from} names ${candidate}, inside ${inSkipped(candidate)}, which is not walked`);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
for (const root of roots) {
|
|
138
|
+
reach(root, 'castle.json hub');
|
|
139
|
+
}
|
|
111
140
|
while (queue.length) {
|
|
112
141
|
const rel = queue.shift();
|
|
113
142
|
if (seen.has(rel)) {
|
|
@@ -126,9 +155,7 @@ function closure(deckDir, roots, available) {
|
|
|
126
155
|
const base = /^(imports\/[^/]+\/)/.exec(rel)?.[1] ?? '';
|
|
127
156
|
for (const s of strings(value)) {
|
|
128
157
|
for (const candidate of refCandidates(s, base)) {
|
|
129
|
-
|
|
130
|
-
queue.push(candidate);
|
|
131
|
-
}
|
|
158
|
+
reach(candidate, rel);
|
|
132
159
|
}
|
|
133
160
|
}
|
|
134
161
|
}
|
|
@@ -163,24 +190,63 @@ function* strings(value) {
|
|
|
163
190
|
}
|
|
164
191
|
}
|
|
165
192
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
193
|
+
// Every file under the deck, as deck-relative paths. Symlinks are followed --
|
|
194
|
+
// a deck's imports (or folders under them) may be links to a kit checkout, and
|
|
195
|
+
// the bundler follows them too -- so a linked file is packed at the path the
|
|
196
|
+
// deck names it by. What cannot be walked is an error, never a silent gap: a
|
|
197
|
+
// dangling link, a link loop, or a folder that cannot be read would otherwise
|
|
198
|
+
// drop every file behind it from the pack while the hashes of what was copied
|
|
199
|
+
// still look exact.
|
|
200
|
+
function walk(root, errors, skipped) {
|
|
201
|
+
const out = [];
|
|
202
|
+
const visit = (rel, ancestors, linked) => {
|
|
203
|
+
let entries;
|
|
204
|
+
try {
|
|
205
|
+
entries = fs.readdirSync(path.join(root, rel), { withFileTypes: true });
|
|
206
|
+
} catch (e) {
|
|
207
|
+
errors.push(`content pack: cannot read ${rel || '.'} (${e.code ?? e.message})`);
|
|
208
|
+
return;
|
|
176
209
|
}
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
210
|
+
for (const entry of entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {
|
|
211
|
+
const child = rel ? `${rel}/${entry.name}` : entry.name;
|
|
212
|
+
if (!rel && SKIP_DIRS.has(entry.name)) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (rel && linked && LINKED_SKIP_DIRS.has(entry.name)) {
|
|
216
|
+
skipped.push(child);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
let kind = entry.isDirectory() ? 'dir' : entry.isFile() ? 'file' : null;
|
|
220
|
+
if (entry.isSymbolicLink()) {
|
|
221
|
+
let stat;
|
|
222
|
+
try {
|
|
223
|
+
stat = fs.statSync(path.join(root, child));
|
|
224
|
+
} catch (e) {
|
|
225
|
+
errors.push(`content pack: ${child} is a symlink that does not resolve (${e.code ?? e.message})`);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
kind = stat.isDirectory() ? 'dir' : stat.isFile() ? 'file' : null;
|
|
229
|
+
}
|
|
230
|
+
if (kind === 'file') {
|
|
231
|
+
out.push(child);
|
|
232
|
+
} else if (kind === 'dir') {
|
|
233
|
+
let real;
|
|
234
|
+
try {
|
|
235
|
+
real = fs.realpathSync(path.join(root, child));
|
|
236
|
+
} catch (e) {
|
|
237
|
+
errors.push(`content pack: cannot resolve ${child} (${e.code ?? e.message})`);
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (ancestors.has(real)) {
|
|
241
|
+
errors.push(`content pack: ${child} is a symlink loop (it leads back to ${real})`);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
visit(child, new Set(ancestors).add(real), linked || entry.isSymbolicLink());
|
|
245
|
+
}
|
|
182
246
|
}
|
|
183
|
-
}
|
|
247
|
+
};
|
|
248
|
+
visit('', new Set([fs.realpathSync(root)]), false);
|
|
249
|
+
return out;
|
|
184
250
|
}
|
|
185
251
|
|
|
186
252
|
function readJson(file) {
|
|
@@ -91,6 +91,11 @@ for (const pointerType of ['touch', 'pen', 'mouse']) {
|
|
|
91
91
|
assert.equal(prompts()[0].textContent, 'Play', `${pointerType} input clears keyboard hint`);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
// v1.204: catching up dims Act and the prompts, and both clear when it ends.
|
|
95
|
+
hub.catching = now - 300; frame();
|
|
96
|
+
assert.equal(node('act').textContent, 'Catching up'); assert.equal(prompts()[0].style.opacity, '.4');
|
|
97
|
+
hub.catching = null; frame();
|
|
98
|
+
assert.equal(node('act').textContent, 'Act', 'Act is itself again once catching ends');
|
|
94
99
|
assert.equal(prompts()[0].style.opacity, '1'); assert.equal(Number(prompts()[1].style.opacity), 0.55);
|
|
95
100
|
handlers.get('keydown')(event('KeyE')); assert.equal(sent.at(-1).id, 'one');
|
|
96
101
|
const nonce = sent.at(-1).n;
|
|
@@ -164,4 +164,36 @@ assert.equal(sent.at(-1).down, false); assert.equal(core.pressSource(), null);
|
|
|
164
164
|
plain.start(plain.items().find(i => i.id === 'ball'), 'KeyE');
|
|
165
165
|
assert.deepEqual(bare, [{ k: 'hub-act', id: 'ball', n: 1 }]);
|
|
166
166
|
}
|
|
167
|
+
// v1.204: while the server reads the player's progress a press is refused
|
|
168
|
+
// with a line, once per press, and nothing is sent; the pair dims only after
|
|
169
|
+
// CATCHING_DIM_MS, and a release of a hold begun before it is refused too.
|
|
170
|
+
{
|
|
171
|
+
const wire = [], refusals = [];
|
|
172
|
+
let t = 0;
|
|
173
|
+
const caught = { ...state, prompts: [offer('play', 'Play'), offer('buy-hat', 'Buy', true)], catching: null };
|
|
174
|
+
const c = makeActCore({ now: () => t, state: caught, seq: 0, send: (m) => wire.push(m), effects: { refused: () => refusals.push(t) } });
|
|
175
|
+
c.frame(facade(), true);
|
|
176
|
+
const hold = c.items().find(i => i.id === 'buy-hat');
|
|
177
|
+
c.start(hold, 'Space');
|
|
178
|
+
assert.equal(wire.length, 1, 'a hold began before catching');
|
|
179
|
+
caught.catching = 0; t = 249; c.frame(facade(), true);
|
|
180
|
+
assert.deepEqual(c.pairState(), { show: true, enabled: true }, 'not dimmed before 250 ms');
|
|
181
|
+
t = HOLD_MS + 10; c.release();
|
|
182
|
+
assert.equal(wire.length, 1, 'the finished hold is not sent');
|
|
183
|
+
assert.equal(refusals.length, 1);
|
|
184
|
+
c.start(c.items().find(i => i.id === 'play'), 'KeyE');
|
|
185
|
+
assert.equal(wire.length, 1); assert.equal(refusals.length, 2, 'one line per press');
|
|
186
|
+
c.frame(facade(), true);
|
|
187
|
+
assert.deepEqual(c.pairState(), { show: true, enabled: true, catching: true }, 'dimmed after 250 ms');
|
|
188
|
+
assert.equal(c.can(), true, 'Act stays pressable, so the press can say why');
|
|
189
|
+
const empty = caught.prompts; caught.prompts = []; c.frame(facade(), true);
|
|
190
|
+
c.start(c.current(), 'pointer:1');
|
|
191
|
+
assert.equal(refusals.length, 3, 'a press with nothing in reach still says why');
|
|
192
|
+
caught.prompts = empty;
|
|
193
|
+
caught.catching = null; c.frame(facade(), true);
|
|
194
|
+
assert.deepEqual(c.pairState(), { show: true, enabled: true });
|
|
195
|
+
c.start(c.items().find(i => i.id === 'play'), 'KeyE');
|
|
196
|
+
assert.deepEqual(wire.at(-1), { k: 'hub-act', id: 'play', n: 2 }, 'presses go again once it ends');
|
|
197
|
+
assert.equal(refusals.length, 3);
|
|
198
|
+
}
|
|
167
199
|
console.log('Act core: rank and reach, Stand/Throw, taps and effects, holds, cancels, context changes, held/seated, pair state and Jump passed');
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// The act-gate log (v1.203): the manifest key, the act core's reasons, the
|
|
2
|
+
// client's debounced reports and the server's whitelist, caps and lines.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { publicPlace, readManifest } from '../code/server/manifest.js';
|
|
5
|
+
import * as ActGate from '../code/server/actGate.js';
|
|
6
|
+
import { blockedReasons, DEBOUNCE_MS, makeActGateLog } from '../code/client/actGateLog.js';
|
|
7
|
+
import { makeActCore } from '../code/client/actCore.js';
|
|
8
|
+
|
|
9
|
+
const has = scene => scene === 'scenes/main.scene';
|
|
10
|
+
const base = hub => ({ server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Game', ...hub } });
|
|
11
|
+
|
|
12
|
+
// The key: boolean, needs hub.act, reaches the place and its public copy only when on.
|
|
13
|
+
{
|
|
14
|
+
const on = readManifest(base({ act: true, actGateLog: true }), has);
|
|
15
|
+
assert.deepEqual(on.errors, []);
|
|
16
|
+
assert.equal(on.manifest.places.main.actGateLog, true);
|
|
17
|
+
assert.equal(publicPlace('main', on.manifest.places.main).actGateLog, true);
|
|
18
|
+
const off = readManifest(base({ act: true }), has);
|
|
19
|
+
assert.equal(off.manifest.places.main.actGateLog, undefined);
|
|
20
|
+
assert.equal(publicPlace('main', off.manifest.places.main).actGateLog, undefined);
|
|
21
|
+
assert.equal(readManifest(base({ act: true, actGateLog: false }), has).manifest.places.main.actGateLog, undefined);
|
|
22
|
+
assert.match(readManifest(base({ actGateLog: true }), has).errors.join(), /actGateLog needs hub.act/);
|
|
23
|
+
for (const actGateLog of ['true', 1, null]) {
|
|
24
|
+
assert.match(readManifest(base({ act: true, actGateLog }), has).errors.join(), /actGateLog must be true or false/);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The act core names why the pair is hidden: the host's reasons, a hold
|
|
29
|
+
// (not a seat), no connection, no body.
|
|
30
|
+
{
|
|
31
|
+
const state = { place: { id: 'main', act: true }, prompts: [], held: new Set(), seated: {}, spawned: {}, hidden: new Set() };
|
|
32
|
+
const link = { net: { id: 'net' } };
|
|
33
|
+
const facade = (over = {}) => ({ scene: 's', link, self: 'p1', player: { x: 0, y: 0, z: 0 }, online: true, actors: () => [], getActor: () => null, ...over });
|
|
34
|
+
const core = makeActCore({ now: () => 0, send: () => {}, state, seq: 1 });
|
|
35
|
+
core.frame(facade(), true);
|
|
36
|
+
assert.deepEqual(core.gate(), { show: true, reasons: [] });
|
|
37
|
+
core.frame(facade(), false, blockedReasons({ talking: true, menuInput: {}, carded: true }));
|
|
38
|
+
assert.deepEqual(core.gate(), { show: false, reasons: ['talk', 'menu', 'card'] });
|
|
39
|
+
state.held.add('p1');
|
|
40
|
+
core.frame(facade(), true);
|
|
41
|
+
assert.deepEqual(core.gate(), { show: false, reasons: ['hold'] });
|
|
42
|
+
state.seated.p1 = 'bench';
|
|
43
|
+
core.frame(facade(), true);
|
|
44
|
+
assert.deepEqual(core.gate(), { show: true, reasons: [] });
|
|
45
|
+
core.frame(facade({ online: false }), true);
|
|
46
|
+
assert.deepEqual(core.gate(), { show: false, reasons: ['offline'] });
|
|
47
|
+
core.frame(facade({ player: undefined }), true);
|
|
48
|
+
assert.deepEqual(core.gate(), { show: false, reasons: ['nobody'] });
|
|
49
|
+
assert.deepEqual(blockedReasons({ trip: {}, pendingEnd: true, decorating: true, actionInput: {}, askInput: {} }), ['trip', 'end', 'decor', 'action', 'ask']);
|
|
50
|
+
assert.deepEqual(blockedReasons({}), []);
|
|
51
|
+
// The shown steady state reads one object, not a new one a frame.
|
|
52
|
+
core.frame(facade(), true); const a = core.gate();
|
|
53
|
+
core.frame(facade(), true);
|
|
54
|
+
assert.equal(core.gate(), a);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The client: a state is sent once it has held DEBOUNCE_MS; a flicker and a
|
|
58
|
+
// steady state send nothing; offline sends nothing; a new link reports afresh.
|
|
59
|
+
{
|
|
60
|
+
let t = 0;
|
|
61
|
+
const sent = [];
|
|
62
|
+
const net = { send: m => sent.push(m) };
|
|
63
|
+
const log = makeActGateLog({ now: () => t });
|
|
64
|
+
const step = (gate, link = net, ms = 100, frames = 1) => {for (let i = 0; i < frames; i++) {t += ms; log.frame(link, gate);}};
|
|
65
|
+
const shown = { show: true, reasons: [] }, menu = { show: false, reasons: ['menu'] };
|
|
66
|
+
step(shown, net, 100, 4);
|
|
67
|
+
assert.equal(sent.length, 0, 'not yet held for the debounce');
|
|
68
|
+
step(shown, net, 100, 2);
|
|
69
|
+
assert.deepEqual(sent, [{ k: 'hub-gate', show: true, reasons: [] }]);
|
|
70
|
+
step(shown, net, 16, 600);
|
|
71
|
+
assert.equal(sent.length, 1, 'a steady state sends nothing more');
|
|
72
|
+
step(menu, net, 100, 3); step(shown, net, 100, 3);
|
|
73
|
+
assert.equal(sent.length, 1, 'a 300 ms flicker sends nothing');
|
|
74
|
+
step(menu, net, 100, 7);
|
|
75
|
+
assert.deepEqual(sent.at(-1), { k: 'hub-gate', show: false, reasons: ['menu'] });
|
|
76
|
+
assert.equal(sent.length, 2);
|
|
77
|
+
step({ show: false, reasons: ['menu', 'card'] }, net, 100, 7);
|
|
78
|
+
assert.deepEqual(sent.at(-1).reasons, ['menu', 'card'], 'a new reason set is a change');
|
|
79
|
+
const count = sent.length;
|
|
80
|
+
step({ show: false, reasons: ['offline'] }, net, 100, 20);
|
|
81
|
+
assert.equal(sent.length, count, 'offline sends nothing');
|
|
82
|
+
step({ show: false, reasons: ['menu', 'card'] }, net, 100, 7);
|
|
83
|
+
assert.equal(sent.length, count + 1, 'back online, the state is reported again');
|
|
84
|
+
const other = [];
|
|
85
|
+
step({ show: false, reasons: ['menu', 'card'] }, { send: m => other.push(m) }, 100, 7);
|
|
86
|
+
assert.equal(other.length, 1, 'a new connection reports its state');
|
|
87
|
+
step(shown, null, 100, 10);
|
|
88
|
+
assert.ok(DEBOUNCE_MS === 500);
|
|
89
|
+
// A same-net rejoin (a new place spec) that no frame saw offline reports again.
|
|
90
|
+
const again = [], same = { send: m => again.push(m) };
|
|
91
|
+
const log2 = makeActGateLog({ now: () => t });
|
|
92
|
+
const placeA = { id: 'main' }, placeB = { id: 'main' };
|
|
93
|
+
for (let i = 0; i < 7; i++) {t += 100; log2.frame(same, shown, placeA);}
|
|
94
|
+
for (let i = 0; i < 20; i++) {t += 100; log2.frame(same, shown, placeA);}
|
|
95
|
+
assert.equal(again.length, 1);
|
|
96
|
+
for (let i = 0; i < 7; i++) {t += 100; log2.frame(same, shown, placeB);}
|
|
97
|
+
assert.equal(again.length, 2, 'a new admission reports its state again');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// The server.
|
|
101
|
+
const fakeHub = (...ids) => ({ session: { players: ids.map(playerId => ({ playerId })) } });
|
|
102
|
+
const capture = () => {const lines = []; return { lines, log: line => lines.push(line) };};
|
|
103
|
+
|
|
104
|
+
// Whitelist: unknown, over-long, repeated and extra reasons are dropped, at
|
|
105
|
+
// most 8 kept; malformed reports print nothing; a shown report has no reasons.
|
|
106
|
+
{
|
|
107
|
+
const r = ActGate.readReport;
|
|
108
|
+
assert.deepEqual(r({ k: 'hub-gate', show: false, reasons: ['menu', 'nope', 'x'.repeat(40), 'menu', 7, 'card'] }), { show: false, reasons: ['menu', 'card'] });
|
|
109
|
+
const all = [...ActGate.GATE_REASONS];
|
|
110
|
+
assert.equal(r({ k: 'hub-gate', show: false, reasons: all }).reasons.length, ActGate.MAX_REASONS);
|
|
111
|
+
assert.deepEqual(r({ k: 'hub-gate', show: true, reasons: ['menu'] }), { show: true, reasons: [] });
|
|
112
|
+
for (const bad of [null, {}, { k: 'hub-gate', show: 'no', reasons: [] }, { k: 'hub-gate', show: false, reasons: 'menu' },
|
|
113
|
+
{ k: 'hub-gate', show: false, reasons: [], text: 'hi' }]) {assert.equal(r(bad), null);}
|
|
114
|
+
assert.equal(ActGate.GATE_REASONS.has('offline'), false);
|
|
115
|
+
|
|
116
|
+
const h = fakeHub('p1'), { lines, log } = capture();
|
|
117
|
+
ActGate.message(h, { playerId: 'p1' }, { k: 'hub-gate', show: false, reasons: ['menu', 'Hello there, typed text'] }, '123', 1000, log);
|
|
118
|
+
assert.deepEqual(lines, ['[hub] act-gate 123 -->hidden reasons=menu t=1000']);
|
|
119
|
+
ActGate.message(h, { playerId: 'p1' }, { k: 'hub-gate', show: false, reasons: ['menu'] }, '123', 1100, log);
|
|
120
|
+
assert.equal(lines.length, 1, 'the same state again prints nothing');
|
|
121
|
+
ActGate.message(h, { playerId: 'p1' }, { k: 'hub-gate', show: true, reasons: [] }, '123', 1200, log);
|
|
122
|
+
assert.equal(lines.at(-1), '[hub] act-gate 123 hidden->shown reasons=- t=1200');
|
|
123
|
+
ActGate.message(h, { playerId: 'ghost' }, { k: 'hub-gate', show: false, reasons: ['menu'] }, '9', 1300, log);
|
|
124
|
+
ActGate.message(h, { playerId: 'p1' }, { k: 'hub-gate', show: false, reasons: [], extra: 1 }, '123', 1300, log);
|
|
125
|
+
assert.equal(lines.length, 2, 'no line for a player not in the session or a malformed report');
|
|
126
|
+
ActGate.message(h, { playerId: 'p1' }, { k: 'hub-gate', show: false, reasons: [] }, null, 1400, log);
|
|
127
|
+
assert.match(lines.at(-1), /^\[hub\] act-gate guest shown->hidden reasons=- t=1400$/);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Caps: 20 lines a minute, then one suppressed-count line; 400 lines a server
|
|
131
|
+
// per account, then one muted line and nothing more.
|
|
132
|
+
{
|
|
133
|
+
const h = fakeHub('p1'), { lines, log } = capture();
|
|
134
|
+
const flip = (i, t) => ActGate.message(h, { playerId: 'p1' }, { k: 'hub-gate', show: i % 2 === 0, reasons: i % 2 ? ['talk'] : [] }, '5', t, log);
|
|
135
|
+
for (let i = 0; i < 30; i++) {flip(i, i);}
|
|
136
|
+
assert.equal(lines.length, ActGate.PER_MINUTE);
|
|
137
|
+
flip(30, 60000);
|
|
138
|
+
assert.equal(lines.at(-2), '[hub] act-gate 5 suppressed=10 t=60000');
|
|
139
|
+
assert.match(lines.at(-1), /^\[hub\] act-gate 5 hidden->shown reasons=- t=60000$/, 'old->new follows the last report, suppressed or not');
|
|
140
|
+
for (let i = 31; i < 40; i++) {flip(i, 60000 + i);}
|
|
141
|
+
ActGate.forget(h, 'p1', '5', 61000, log);
|
|
142
|
+
assert.equal(lines.at(-1).startsWith('[hub] act-gate 5 '), true);
|
|
143
|
+
|
|
144
|
+
// Leaving and rejoining every report does not lift the minute's cap.
|
|
145
|
+
{
|
|
146
|
+
const h3 = fakeHub('p3'), c3 = capture();
|
|
147
|
+
for (let i = 0; i < 200; i++) {
|
|
148
|
+
ActGate.message(h3, { playerId: 'p3' }, { k: 'hub-gate', show: i % 2 === 0, reasons: i % 2 ? ['talk'] : [] }, '8', 1000 + i, c3.log);
|
|
149
|
+
ActGate.forget(h3, 'p3', '8', 1000 + i, c3.log);
|
|
150
|
+
}
|
|
151
|
+
assert.equal(c3.lines.length, ActGate.PER_MINUTE + 1, c3.lines.slice(-3).join('\n'));
|
|
152
|
+
assert.match(c3.lines.at(-1), /suppressed=1 /);
|
|
153
|
+
// The window's rollover prints no second summary for it.
|
|
154
|
+
ActGate.message(h3, { playerId: 'p3' }, { k: 'hub-gate', show: true, reasons: [] }, '8', 61500, c3.log);
|
|
155
|
+
assert.equal(c3.lines.filter(line => line.includes('suppressed=')).length, 1);
|
|
156
|
+
assert.match(c3.lines.at(-1), /->shown /);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
lines.length = 0;
|
|
160
|
+
const h2 = fakeHub('p2'), cap = capture();
|
|
161
|
+
for (let i = 0; i < 1000; i++) {
|
|
162
|
+
ActGate.message(h2, { playerId: 'p2' }, { k: 'hub-gate', show: i % 2 === 0, reasons: i % 2 ? ['card'] : [] }, '7', i * 3001, cap.log);
|
|
163
|
+
}
|
|
164
|
+
const gate = cap.lines.filter(line => line.includes('->'));
|
|
165
|
+
assert.equal(cap.lines.filter(line => !line.includes('muted')).length, ActGate.PER_SERVER);
|
|
166
|
+
assert.equal(cap.lines.filter(line => line.includes('muted')).length, 1);
|
|
167
|
+
assert.equal(cap.lines.at(-1), `[hub] act-gate 7 muted after ${ActGate.PER_SERVER} lines t=${cap.lines.at(-1).split('t=')[1]}`);
|
|
168
|
+
assert.ok(gate.length <= ActGate.PER_SERVER);
|
|
169
|
+
// A rejoin keeps the account's budget.
|
|
170
|
+
ActGate.forget(h2, 'p2', '7', 0, cap.log);
|
|
171
|
+
ActGate.message(h2, { playerId: 'p2' }, { k: 'hub-gate', show: true, reasons: [] }, '7', 9e9, cap.log);
|
|
172
|
+
assert.equal(cap.lines.filter(line => line.includes('muted')).length, 1);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Steady state: a client in one state for a long while sends one report and
|
|
176
|
+
// the server prints one line.
|
|
177
|
+
{
|
|
178
|
+
let t = 0;
|
|
179
|
+
const h = fakeHub('p1'), { lines, log } = capture();
|
|
180
|
+
const client = makeActGateLog({ now: () => t });
|
|
181
|
+
const net = { send: m => ActGate.message(h, { playerId: 'p1' }, m, '42', t, log) };
|
|
182
|
+
for (let i = 0; i < 60 * 60 * 5; i++) {t += 16; client.frame(net, { show: true, reasons: [] });}
|
|
183
|
+
assert.deepEqual(lines, ['[hub] act-gate 42 -->shown reasons=- t=528']);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
console.log('act gate: ok');
|
|
@@ -100,8 +100,13 @@ try {
|
|
|
100
100
|
for (const offer of reportRail) for (const control of [...reported('act'), ...reported('jump')]) if (overlaps(offer, control)) reportHits.push([offer.name, control.name]);
|
|
101
101
|
const reportStale = reportRail.some(r => Math.abs(r.top - box(document.querySelector('[data-hub="action-rail"]')).top) > 0.5);
|
|
102
102
|
const outside = rail.filter(r => r.left < 0 || r.top < 0 || r.right > innerWidth || r.bottom > innerHeight).map(r => r.name);
|
|
103
|
+
// A follower walking under the rail: its invisible Chat button never
|
|
104
|
+
// takes a chip's tap.
|
|
105
|
+
const first = rail[0];
|
|
106
|
+
chrome.setCompanionTalk({ x: (first.left + first.right) / 2, y: (first.top + first.bottom) / 2 }, 'Chirp', () => {});
|
|
107
|
+
const followerOverRail = [...document.querySelectorAll('button[aria-label="Chat with Chirp"]')].some(shown);
|
|
103
108
|
act.dispose?.(); chrome.dispose();
|
|
104
|
-
return { rail, controls, hits, promptHits, outside, reportHits, reportStale, reportRail: reportRail.length };
|
|
109
|
+
return { rail, controls, hits, promptHits, outside, reportHits, reportStale, reportRail: reportRail.length, followerOverRail };
|
|
105
110
|
}, { setup, OFFERS, PROMPT });
|
|
106
111
|
const label = `${width}x${height}`;
|
|
107
112
|
assert(result.rail.length > 0, `${label}: the rail shows at least one entry`);
|
|
@@ -113,6 +118,7 @@ try {
|
|
|
113
118
|
assert.equal(result.reportStale, false, `${label}: report matches the drawn rail`);
|
|
114
119
|
assert.deepEqual(result.promptHits, [], `${label}: rail clears the HUD prompt`);
|
|
115
120
|
assert.deepEqual(result.outside, [], `${label}: rail inside the viewport`);
|
|
121
|
+
assert.equal(result.followerOverRail, false, `${label}: the follower's Chat button stays off the rail`);
|
|
116
122
|
console.log(`${label}: rail ${result.rail.map(r => `${r.name}@${Math.round(r.left)},${Math.round(r.top)}`).join(' ')}; act/jump clear`);
|
|
117
123
|
}
|
|
118
124
|
} finally { await browser.close(); }
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// v1.187: a landscape place without hub.safeInsets or hubActionOverflow draws
|
|
2
|
+
// its offers on the overflow rail. At 844x390 with three short offers every
|
|
3
|
+
// offer stays in view, as on the legacy column; in a crowded 509x218 frame the
|
|
4
|
+
// legacy column dropped an offer, and the rail keeps it behind More.
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { readFile } from 'node:fs/promises';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { chromium } from 'playwright-core';
|
|
9
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
10
|
+
const root = new URL('../../../', import.meta.url);
|
|
11
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
12
|
+
const cases = [
|
|
13
|
+
{ w: 844, h: 390, crowded: false, offers: [{ id: 'start', label: 'Start' }, { id: 'invite', label: 'Invite' }, { id: 'share', label: 'Share' }] },
|
|
14
|
+
{ w: 509, h: 218, crowded: true, offers: [{ id: 'search', label: 'Search desk' }, { id: 'locker', label: 'Open locker' }, { id: 'ready', label: 'Ready up' }] },
|
|
15
|
+
];
|
|
16
|
+
try {
|
|
17
|
+
for (const { w, h, crowded, offers } of cases) {
|
|
18
|
+
const shown = {};
|
|
19
|
+
for (const overflow of [false, true]) {
|
|
20
|
+
const context = await browser.newContext({ viewport: { width: w, height: h }, isMobile: true, hasTouch: true });
|
|
21
|
+
const page = await context.newPage();
|
|
22
|
+
await page.route('http://rail.test/**', async route => {
|
|
23
|
+
const pathname = new URL(route.request().url()).pathname;
|
|
24
|
+
if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: '<meta name="viewport" content="width=device-width,initial-scale=1"><body style="margin:0"></body>' });
|
|
25
|
+
const url = new URL(`.${pathname}`, root);
|
|
26
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
27
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
28
|
+
});
|
|
29
|
+
await page.goto('http://rail.test/');
|
|
30
|
+
await logRenderer(page, 'action rail default');
|
|
31
|
+
shown[overflow] = await page.evaluate(async ({ crowded, offers, overflow }) => {
|
|
32
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
33
|
+
let cues = 0;
|
|
34
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, onChip() { cues += 1; } });
|
|
35
|
+
chrome.soundControl(true, { volume: 0.7, muted: false }, { onMuted() {}, onVolume() {} });
|
|
36
|
+
chrome.showPicker(true, 0);
|
|
37
|
+
chrome.setEmotes([['wave', '👋']]); chrome.setSay({ reactions: [], phrases: [] });
|
|
38
|
+
chrome.showBack(true, 'Back');
|
|
39
|
+
if (crowded) {
|
|
40
|
+
chrome.grabPrompt('Grab'); chrome.sitPrompt('Sit');
|
|
41
|
+
chrome.setHud({ title: 'Escape', big: 'Prep', text: 'Pick a route, then Start solo or wait for a friend' }, null);
|
|
42
|
+
} else {
|
|
43
|
+
chrome.setHud({ title: 'Town', text: 'Walk to a door' }, null);
|
|
44
|
+
}
|
|
45
|
+
const pressed = [];
|
|
46
|
+
const paint = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
47
|
+
const draw = async () => {for (let i = 0; i < 4; i++) {chrome.setActions(offers, (id) => pressed.push(id), true, 1, overflow); await paint();}};
|
|
48
|
+
await draw();
|
|
49
|
+
const visible = node => { for (let n = node; n && n.nodeType === 1; n = n.parentElement) { const s = getComputedStyle(n); if (s.display === 'none' || s.visibility === 'hidden') return false; } const r = node.getBoundingClientRect(); return r.width > 0 && r.height > 0; };
|
|
50
|
+
const labels = new Set(offers.map(o => o.label));
|
|
51
|
+
const chipsNow = () => [...document.querySelectorAll('button')].filter(b => visible(b) && (labels.has(b.textContent) || /^(More|Actions) \(/.test(b.textContent)));
|
|
52
|
+
const chips = chipsNow();
|
|
53
|
+
const tops = chips.map(b => Math.round(b.getBoundingClientRect().top));
|
|
54
|
+
const inView = chips.every(b => { const r = b.getBoundingClientRect(); return r.left >= 0 && r.top >= 0 && r.right <= innerWidth && r.bottom <= innerHeight; });
|
|
55
|
+
const out = { buttons: chips.map(b => b.textContent), inView, oneRow: new Set(tops).size === 1 };
|
|
56
|
+
if (overflow) {
|
|
57
|
+
// A pointer tap sounds the cue, reaches the handler and leaves no focus behind.
|
|
58
|
+
const tap = node => { const r = node.getBoundingClientRect(); const o = { bubbles: true, cancelable: true, clientX: r.left + 4, clientY: r.top + 4, detail: 1 }; node.dispatchEvent(new MouseEvent('mousedown', o)); node.dispatchEvent(new MouseEvent('mouseup', o)); node.dispatchEvent(new MouseEvent('click', o)); };
|
|
59
|
+
const first = chips[0];
|
|
60
|
+
first.focus();
|
|
61
|
+
tap(first);
|
|
62
|
+
out.firstPress = { pressed: [...pressed], cues, focusLeft: document.activeElement !== first };
|
|
63
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
64
|
+
const launcher = chipsNow().find(b => /^(More|Actions) \(/.test(b.textContent));
|
|
65
|
+
if (launcher) {
|
|
66
|
+
tap(launcher); await paint();
|
|
67
|
+
const sheet = document.querySelector('[data-hub="action-sheet"]');
|
|
68
|
+
out.sheet = [...sheet.querySelectorAll('button')].filter(visible).map(b => b.textContent);
|
|
69
|
+
const last = [...sheet.querySelectorAll('button')].find(b => b.textContent === offers.at(-1).label);
|
|
70
|
+
tap(last); await new Promise(resolve => setTimeout(resolve, 150)); await paint();
|
|
71
|
+
out.sheetPress = { pressed: [...pressed], closed: !document.querySelector('[data-hub="action-sheet"]'), focusInRail: Boolean(document.activeElement?.closest?.('[data-hub="action-rail"]')) };
|
|
72
|
+
}
|
|
73
|
+
// An open panel (Quick chat) hides the offers, as it hid the legacy chips.
|
|
74
|
+
document.querySelector('button[aria-label="Quick chat"]').dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, cancelable: true }));
|
|
75
|
+
await draw();
|
|
76
|
+
out.hiddenUnderPanel = chipsNow().length === 0;
|
|
77
|
+
}
|
|
78
|
+
chrome.dispose();
|
|
79
|
+
return out;
|
|
80
|
+
}, { crowded, offers, overflow });
|
|
81
|
+
await context.close();
|
|
82
|
+
}
|
|
83
|
+
const offered = r => r.buttons.filter(text => !/^(More|Actions) \(/.test(text));
|
|
84
|
+
const launcher = r => r.buttons.find(text => /^(More|Actions) \(/.test(text));
|
|
85
|
+
console.log(`${w}x${h} legacy: ${shown.false.buttons.join(', ')} | rail: ${shown.true.buttons.join(', ')}`);
|
|
86
|
+
assert.ok(shown.true.inView, `${w}x${h}: every rail chip is inside the view`);
|
|
87
|
+
assert.deepEqual(shown.true.firstPress, { pressed: [offers[0].id], cues: 1, focusLeft: true }, `${w}x${h}: a tap sounds the cue, presses the offer and leaves no focus`);
|
|
88
|
+
assert.ok(shown.true.hiddenUnderPanel, `${w}x${h}: offers yield to an open panel`);
|
|
89
|
+
if (crowded) {
|
|
90
|
+
assert.ok(offered(shown.false).length < offers.length && !launcher(shown.false), 'the legacy column silently drops an offer here');
|
|
91
|
+
assert.ok(offered(shown.true).length === offers.length || launcher(shown.true), `${w}x${h}: every offer is shown or behind More`);
|
|
92
|
+
assert.deepEqual(shown.true.sheet.filter(text => text !== 'Close'), offers.map(o => o.label), 'More opens a sheet listing every offer');
|
|
93
|
+
assert.deepEqual(shown.true.sheetPress.pressed.at(-1), offers.at(-1).id, 'the offer the column dropped is pressable from the sheet');
|
|
94
|
+
assert.ok(shown.true.sheetPress.closed && !shown.true.sheetPress.focusInRail, 'a pointer pick closes the sheet and leaves no chip focused');
|
|
95
|
+
} else {
|
|
96
|
+
assert.ok(shown.true.oneRow, `${w}x${h}: the three offers stand in one row`);
|
|
97
|
+
assert.deepEqual(offered(shown.false), offers.map(o => o.label), 'the legacy column shows all three');
|
|
98
|
+
assert.deepEqual(offered(shown.true), offers.map(o => o.label), `${w}x${h}: the rail shows all three in authored order`);
|
|
99
|
+
assert.equal(launcher(shown.true), undefined, `${w}x${h}: nothing goes behind More`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} finally { await browser.close(); }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// A crowded small landscape frame (509x218: Back, a big HUD, its prompt, Sit,
|
|
2
|
+
// Grab, Character): the overflow rail goes over passing text rather than
|
|
3
|
+
// hiding, so every offer is shown or behind More.
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { chromium } from 'playwright-core';
|
|
8
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
9
|
+
const root = new URL('../../../', import.meta.url);
|
|
10
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
11
|
+
try {
|
|
12
|
+
for (const safeInsets of [false, true]) {
|
|
13
|
+
const context = await browser.newContext({ viewport: { width: 509, height: 218 }, isMobile: true, hasTouch: true });
|
|
14
|
+
const page = await context.newPage();
|
|
15
|
+
await page.route('http://rail.test/**', async route => {
|
|
16
|
+
const pathname = new URL(route.request().url()).pathname;
|
|
17
|
+
if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: '<meta name="viewport" content="width=device-width,initial-scale=1"><body style="margin:0"></body>' });
|
|
18
|
+
const url = new URL(`.${pathname}`, root);
|
|
19
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
20
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
21
|
+
});
|
|
22
|
+
await page.goto('http://rail.test/');
|
|
23
|
+
await logRenderer(page, 'action rail never silent');
|
|
24
|
+
const result = await page.evaluate(async (safeInsets) => {
|
|
25
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
26
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, safeInsets });
|
|
27
|
+
chrome.soundControl(true, { volume: 0.7, muted: false }, { onMuted() {}, onVolume() {} });
|
|
28
|
+
chrome.showPicker(true, 0);
|
|
29
|
+
chrome.setEmotes([['wave', '👋']]); chrome.setSay({ reactions: [], phrases: [] });
|
|
30
|
+
chrome.showBack(true, 'Back');
|
|
31
|
+
chrome.grabPrompt('Grab'); chrome.sitPrompt('Sit');
|
|
32
|
+
chrome.setHud({ title: 'Escape', big: 'Prep', text: 'Pick a route, then Start solo or wait for a friend' }, null);
|
|
33
|
+
const offers = [{ id: 'search', label: 'Search desk' }, { id: 'locker', label: 'Open locker' }, { id: 'ready', label: 'Ready up' }];
|
|
34
|
+
const paint = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
35
|
+
for (let i = 0; i < 4; i++) {
|
|
36
|
+
chrome.setActions(offers, () => {}, true, 1, true); chrome.frameSafeInsets?.();
|
|
37
|
+
await paint(); await new Promise(resolve => setTimeout(resolve, safeInsets ? 550 : 0));
|
|
38
|
+
}
|
|
39
|
+
const shown = node => { for (let n = node; n && n.nodeType === 1; n = n.parentElement) { const s = getComputedStyle(n); if (s.display === 'none' || s.visibility === 'hidden') return false; } return node.getBoundingClientRect().width > 0; };
|
|
40
|
+
const buttons = [...document.querySelectorAll('[data-hub="action-rail"] button')].filter(shown).map(b => b.textContent);
|
|
41
|
+
chrome.dispose();
|
|
42
|
+
return buttons;
|
|
43
|
+
}, safeInsets);
|
|
44
|
+
const offers = result.filter(text => !/^(More|Actions) \(/.test(text));
|
|
45
|
+
const launcher = result.find(text => /^(More|Actions) \(/.test(text));
|
|
46
|
+
assert.ok(offers.length === 3 || launcher, `safeInsets=${safeInsets}: every offer is shown or behind More (${JSON.stringify(result)})`);
|
|
47
|
+
console.log(`509x218 safeInsets=${safeInsets}: ${result.join(', ')}`);
|
|
48
|
+
await context.close();
|
|
49
|
+
}
|
|
50
|
+
} finally { await browser.close(); }
|