castle-web-cli 0.4.238 → 0.4.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +218 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +22 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +4 -2
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +12 -3
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +2 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +240 -8
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +8 -2
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +79 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +198 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/castle.json +4 -4
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +474 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +75 -52
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +215 -26
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +40 -15
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +854 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +437 -57
- package/kits/hub-game/docs/analytics.md +20 -3
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +80 -1
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-resync.mjs +13 -0
- package/kits/hub-game/scripts/test-role-client.mjs +10 -3
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
// The action rail surface (`code/client/actionRailSurface.js`) and its tree
|
|
2
|
+
// (`actionRailTree.js`): the opt-in action rail and its overflow sheet as
|
|
3
|
+
// the `actions` UI tree root, with no DOM, for a native host. Checks that
|
|
4
|
+
// the trees validate in every state, portrait and landscape; that their
|
|
5
|
+
// bytes and binding ids do not move across rebuilds with fresh closures;
|
|
6
|
+
// and that events dispatched as a host sends them (`dispatchUiEvent`) reach
|
|
7
|
+
// the right action: an offer press, the launcher opening the sheet, Close
|
|
8
|
+
// and Back shutting it, an offer in the sheet shutting it after its press.
|
|
9
|
+
import assert from 'node:assert/strict';
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
11
|
+
import { dispatchUiEvent, resetUiTrees, serialize, setUiTreeSink, validate } from '../code/client/uiTree.js';
|
|
12
|
+
import { buildActionRail, launcherWords, RAIL_AVOID } from '../code/client/actionRailTree.js';
|
|
13
|
+
import { makeActionRailSurface } from '../code/client/actionRailSurface.js';
|
|
14
|
+
import { actionLayout } from '../code/client/actionLayout.js';
|
|
15
|
+
import { cssFor } from '../code/client/uiDom.js';
|
|
16
|
+
|
|
17
|
+
let passed = 0;
|
|
18
|
+
const test = async (name, fn) => {
|
|
19
|
+
try {await fn();} catch (error) {error.message = `${name}: ${error.message}`; throw error;}
|
|
20
|
+
passed += 1;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const VIEWS = { portrait: { w: 390, h: 844 }, landscape: { w: 844, h: 390 } };
|
|
24
|
+
const ITEMS = [{ id: 'fish', label: 'Fish here' }, { id: 'sell', label: 'Sell your catch' }, { id: 'a/b', label: 'Ring the bell' }];
|
|
25
|
+
|
|
26
|
+
// The node at a path of keys under a wire (or builder) tree.
|
|
27
|
+
function at(tree, path) {
|
|
28
|
+
let node = tree;
|
|
29
|
+
for (const key of path.split('/').slice(1)) {
|
|
30
|
+
node = node?.c?.find((child) => child.k === key);
|
|
31
|
+
}
|
|
32
|
+
return node ?? null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// A host: a sink that keeps each root as sent, and a fake timer.
|
|
36
|
+
function makeHost() {
|
|
37
|
+
const host = { roots: new Map(), posts: [], timers: [], calls: [] };
|
|
38
|
+
setUiTreeSink((name, wire, handlers, info) => {
|
|
39
|
+
host.posts.push([name, info.rev]);
|
|
40
|
+
host.roots.set(name, { wire, handlers, json: info.json });
|
|
41
|
+
}, { dom: false });
|
|
42
|
+
host.later = (fn, ms) => {host.timers.push({ fn, ms }); return host.timers.length;};
|
|
43
|
+
host.cancelLater = (token) => {if (host.timers[token - 1]) {host.timers[token - 1].fn = null;}};
|
|
44
|
+
host.run = () => {
|
|
45
|
+
const due = host.timers.splice(0);
|
|
46
|
+
for (const timer of due) {timer.fn?.();}
|
|
47
|
+
};
|
|
48
|
+
host.wire = () => host.roots.get('actions')?.wire ?? null;
|
|
49
|
+
host.ids = () => [...(host.roots.get('actions')?.handlers.keys() ?? [])];
|
|
50
|
+
host.event = (id, payload) => dispatchUiEvent('actions', id, payload);
|
|
51
|
+
return host;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
await test('trees validate in every state, portrait and landscape', () => {
|
|
55
|
+
const placements = [null, { mode: 'all', rect: { left: 100, right: 380, top: 700, bottom: 744 } }, { mode: 'all-two', rect: { left: 140, right: 380, top: 650, bottom: 744 } },
|
|
56
|
+
{ mode: 'more', rect: { left: 200, right: 380, top: 700, bottom: 744 } }, { mode: 'launcher', rect: { left: 260, right: 380, top: 700, bottom: 744 } }, { mode: 'none' }];
|
|
57
|
+
for (const view of Object.values(VIEWS)) {
|
|
58
|
+
for (const layout of placements) {
|
|
59
|
+
for (const count of [0, 1, 2, 3]) {
|
|
60
|
+
for (const [open, changed, canAct, safeInsets] of [[false, false, true, true], [true, false, true, false], [true, true, true, true], [false, false, false, false]]) {
|
|
61
|
+
const state = { items: ITEMS.slice(0, count), n: 4, canAct, open, changed, layout, view, safeInsets };
|
|
62
|
+
const tree = buildActionRail(state, { act() {}, open() {}, close() {} });
|
|
63
|
+
assert.deepEqual(validate(tree), [], JSON.stringify(state));
|
|
64
|
+
assert.deepEqual(validate(buildActionRail(state)), [], 'no handlers');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await test('bytes and binding ids do not move across rebuilds with fresh closures', () => {
|
|
72
|
+
for (const view of Object.values(VIEWS)) {
|
|
73
|
+
const state = { items: ITEMS, n: 2, canAct: true, open: true, changed: false, layout: { mode: 'more' }, view, safeInsets: true };
|
|
74
|
+
const one = serialize(buildActionRail(state, { act: () => 1, open: () => 1, close: () => 1 }), 'actions');
|
|
75
|
+
const two = serialize(buildActionRail(state, { act: () => 2, open: () => 2, close: () => 2 }), 'actions');
|
|
76
|
+
assert.equal(one.json, two.json);
|
|
77
|
+
assert.deepEqual([...one.handlers.keys()], [...two.handlers.keys()]);
|
|
78
|
+
assert.deepEqual([...one.handlers.keys()], [
|
|
79
|
+
'actions#cancel',
|
|
80
|
+
'actions/rail/o:fish#tap', 'actions/rail/o:sell#tap', 'actions/rail/o:a%2Fb#tap', 'actions/rail/launcher#tap',
|
|
81
|
+
'actions/sheet/safe/card/close#tap',
|
|
82
|
+
'actions/sheet/safe/card/list/grid/o:fish#tap', 'actions/sheet/safe/card/list/grid/o:sell#tap', 'actions/sheet/safe/card/list/grid/o:a%2Fb#tap',
|
|
83
|
+
]);
|
|
84
|
+
// A key with '/' is one segment of the path, and stays its own raw key.
|
|
85
|
+
assert.equal(at(one.wire, 'actions/rail').c.find((b) => b.k === 'o:a/b')?.label, 'Ring the bell');
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
await test('the rail: words, modes, placement and avoidance', () => {
|
|
90
|
+
const state = { items: ITEMS, n: 1, canAct: true, open: false, layout: null, view: VIEWS.portrait, safeInsets: true };
|
|
91
|
+
let tree = buildActionRail(state);
|
|
92
|
+
const rail = at(tree, 'actions/rail');
|
|
93
|
+
assert.deepEqual(rail.at, { anchor: 'bottomRight', bottom: [8, 0], right: [8, 0], z: 8, avoid: RAIL_AVOID, avoidHide: true });
|
|
94
|
+
assert.deepEqual(rail.c.map((b) => [b.k, b.c[0].text, Boolean(b.s.gone)]), [['o:fish', 'Fish here', false], ['o:sell', 'Sell your catch', false], ['o:a/b', 'Ring the bell', false], ['launcher', 'Actions (3)', true]]);
|
|
95
|
+
assert.equal(at(tree, 'actions/rail/launcher').on, undefined, 'a hidden launcher binds nothing');
|
|
96
|
+
assert.equal(at(tree, 'actions/sheet'), null, 'no sheet while shut');
|
|
97
|
+
assert.equal(tree.on, undefined, 'a shut sheet binds no cancel');
|
|
98
|
+
// Not in a safe-inset place: inset + 8.
|
|
99
|
+
assert.deepEqual(at(buildActionRail({ ...state, safeInsets: false }), 'actions/rail').at.bottom, [8, 8]);
|
|
100
|
+
state.layout = { mode: 'more', rect: { left: 200, right: 382, top: 692, bottom: 736 } };
|
|
101
|
+
tree = buildActionRail(state);
|
|
102
|
+
assert.deepEqual(at(tree, 'actions/rail').at, { anchor: 'topLeft', top: 692, left: 200, z: 8 });
|
|
103
|
+
assert.equal(at(tree, 'actions/rail').s.w, 182);
|
|
104
|
+
assert.deepEqual(at(tree, 'actions/rail').c.map((b) => Boolean(b.s.gone)), [false, true, true, false]);
|
|
105
|
+
assert.equal(at(tree, 'actions/rail/launcher').c[0].text, 'More (2)');
|
|
106
|
+
assert.equal(at(tree, 'actions/rail/launcher').label, '2 more actions, 3 actions total');
|
|
107
|
+
state.layout = { mode: 'launcher' };
|
|
108
|
+
tree = buildActionRail(state);
|
|
109
|
+
assert.deepEqual(at(tree, 'actions/rail').c.map((b) => Boolean(b.s.gone)), [true, true, true, false]);
|
|
110
|
+
assert.deepEqual(launcherWords('launcher', 3), { text: 'Actions (3)', label: '3 actions' });
|
|
111
|
+
assert.equal(at(buildActionRail({ ...state, layout: { mode: 'none' } }), 'actions/rail').s.gone, true);
|
|
112
|
+
assert.equal(at(buildActionRail({ ...state, canAct: false }), 'actions/rail').s.gone, true);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await test('the sheet: portrait lists one column, landscape two', () => {
|
|
116
|
+
for (const [name, view] of Object.entries(VIEWS)) {
|
|
117
|
+
const tree = buildActionRail({ items: ITEMS, n: 1, canAct: true, open: true, layout: { mode: 'launcher' }, view, safeInsets: true });
|
|
118
|
+
assert.equal(at(tree, 'actions/rail').s.gone, true, 'the rail hides under the sheet');
|
|
119
|
+
const card = at(tree, 'actions/sheet/safe/card');
|
|
120
|
+
assert.equal(card.role, 'dialog');
|
|
121
|
+
assert.equal(card.label, 'Actions');
|
|
122
|
+
assert.equal(at(tree, 'actions/sheet').at.z, 12);
|
|
123
|
+
assert.equal(at(tree, 'actions/sheet/safe/card/close').label, 'Close actions');
|
|
124
|
+
assert.equal(at(tree, 'actions/sheet/safe/card/list/grid').cols, name === 'portrait' ? 1 : 2);
|
|
125
|
+
assert.deepEqual(at(tree, 'actions/sheet/safe/card/list/grid').c.map((b) => b.c[0].text), ['Fish here', 'Sell your catch', 'Ring the bell']);
|
|
126
|
+
}
|
|
127
|
+
// A short landscape stage under 480 px wide is narrow too.
|
|
128
|
+
const small = buildActionRail({ items: ITEMS, canAct: true, open: true, layout: { mode: 'more' }, view: { w: 460, h: 300 } });
|
|
129
|
+
assert.equal(at(small, 'actions/sheet/safe/card/list/grid').cols, 1);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
await test('surface: an offer press reaches the handler once, through the host sink', () => {
|
|
133
|
+
resetUiTrees();
|
|
134
|
+
const host = makeHost();
|
|
135
|
+
const surface = makeActionRailSurface({ view: () => VIEWS.portrait, safeInsets: true, later: host.later, cancelLater: host.cancelLater });
|
|
136
|
+
surface.set(ITEMS, (id, n) => host.calls.push(['act', id, n]), true, 7);
|
|
137
|
+
const rev = host.posts.length;
|
|
138
|
+
// Said every frame with nothing changed: nothing is sent again.
|
|
139
|
+
surface.set(ITEMS, (id, n) => host.calls.push(['act', id, n]), true, 7);
|
|
140
|
+
surface.set(ITEMS, (id, n) => host.calls.push(['act', id, n]), true, 7);
|
|
141
|
+
assert.equal(host.posts.length, rev);
|
|
142
|
+
assert.equal(host.event('actions/rail/o:sell#tap', {}), true);
|
|
143
|
+
assert.equal(host.event('actions/rail/o:sell#tap', {}), true, 'the binding ran');
|
|
144
|
+
assert.deepEqual(host.calls, [['act', 'sell', 7]], 'a second press inside the debounce is dropped');
|
|
145
|
+
host.run();
|
|
146
|
+
host.event('actions/rail/o:a%2Fb#tap', {});
|
|
147
|
+
assert.deepEqual(host.calls.at(-1), ['act', 'a/b', 7]);
|
|
148
|
+
// The launcher is hidden in the default lane: no sheet to open.
|
|
149
|
+
assert.equal(host.event('actions/rail/launcher#tap', {}), false);
|
|
150
|
+
assert.equal(surface.isOpen(), false);
|
|
151
|
+
// Unable to act: the rail hides and a press does nothing.
|
|
152
|
+
host.run();
|
|
153
|
+
surface.set(ITEMS, (id, n) => host.calls.push(['act', id, n]), false, 7);
|
|
154
|
+
assert.equal(at(host.wire(), 'actions/rail').s.gone, true);
|
|
155
|
+
const calls = host.calls.length;
|
|
156
|
+
host.event('actions/rail/o:fish#tap', {});
|
|
157
|
+
assert.equal(host.calls.length, calls);
|
|
158
|
+
surface.dispose();
|
|
159
|
+
assert.equal(host.wire(), null, 'dispose drops the root');
|
|
160
|
+
resetUiTrees();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
await test('surface: the launcher opens the sheet; Close, Back and an offer in it shut it', () => {
|
|
164
|
+
for (const view of Object.values(VIEWS)) {
|
|
165
|
+
resetUiTrees();
|
|
166
|
+
const host = makeHost();
|
|
167
|
+
const surface = makeActionRailSurface({ view: () => view, safeInsets: true, later: host.later, cancelLater: host.cancelLater });
|
|
168
|
+
const opens = [];
|
|
169
|
+
const set = (items = ITEMS, canAct = true, n = 3) => surface.set(items, (id, at) => host.calls.push(['act', id, at]), canAct, n, (open) => opens.push(open));
|
|
170
|
+
set();
|
|
171
|
+
surface.setLayout({ mode: 'more', rect: { left: 180, right: view.w - 8, top: view.h - 52, bottom: view.h - 8 } });
|
|
172
|
+
assert.equal(at(host.wire(), 'actions/rail/launcher').c[0].text, 'More (2)');
|
|
173
|
+
// Open, then Close.
|
|
174
|
+
assert.equal(host.event('actions/rail/launcher#tap', {}), true);
|
|
175
|
+
assert.equal(surface.isOpen(), true);
|
|
176
|
+
assert.deepEqual(opens, [true]);
|
|
177
|
+
assert.equal(at(host.wire(), 'actions/rail').s.gone, true);
|
|
178
|
+
assert.equal(host.wire().on.cancel, 'actions#cancel');
|
|
179
|
+
host.event('actions/sheet/safe/card/close#tap', {});
|
|
180
|
+
assert.equal(surface.isOpen(), false);
|
|
181
|
+
assert.deepEqual(opens, [true, false]);
|
|
182
|
+
assert.equal(at(host.wire(), 'actions/sheet'), null);
|
|
183
|
+
assert.equal(host.wire().on, undefined, 'a shut sheet binds no cancel');
|
|
184
|
+
assert.equal(host.event('actions#cancel', {}), false, 'Back passes a shut sheet by');
|
|
185
|
+
// Open, then Back (a host's cancel on the root).
|
|
186
|
+
host.event('actions/rail/launcher#tap', {});
|
|
187
|
+
assert.equal(host.event('actions#cancel', {}), true);
|
|
188
|
+
assert.equal(surface.isOpen(), false);
|
|
189
|
+
// Open, then an offer in the sheet: pressed at once, shut 80 ms later.
|
|
190
|
+
host.event('actions/rail/launcher#tap', {});
|
|
191
|
+
host.event('actions/sheet/safe/card/list/grid/o:fish#tap', {});
|
|
192
|
+
assert.deepEqual(host.calls.at(-1), ['act', 'fish', 3]);
|
|
193
|
+
assert.equal(surface.isOpen(), true);
|
|
194
|
+
assert.deepEqual(host.timers.map((t) => t.ms), [80]);
|
|
195
|
+
host.run();
|
|
196
|
+
assert.equal(surface.isOpen(), false);
|
|
197
|
+
assert.deepEqual(opens, [true, false, true, false, true, false]);
|
|
198
|
+
// The offers change while the sheet is open: redrawn, announced once,
|
|
199
|
+
// and a pending shut is void.
|
|
200
|
+
host.event('actions/rail/launcher#tap', {});
|
|
201
|
+
host.event('actions/sheet/safe/card/list/grid/o:sell#tap', {});
|
|
202
|
+
set([ITEMS[0], ITEMS[1]], true, 4);
|
|
203
|
+
assert.equal(at(host.wire(), 'actions/sheet/safe/card').label, 'Actions changed. Actions');
|
|
204
|
+
assert.deepEqual(at(host.wire(), 'actions/sheet/safe/card/list/grid').c.map((b) => b.k), ['o:fish', 'o:sell']);
|
|
205
|
+
host.run();
|
|
206
|
+
assert.equal(surface.isOpen(), true, 'the redraw voided the shut');
|
|
207
|
+
// Unable to act: the sheet shuts.
|
|
208
|
+
set([ITEMS[0], ITEMS[1]], false, 4);
|
|
209
|
+
assert.equal(surface.isOpen(), false);
|
|
210
|
+
// No offers at all: shut, the rail empty.
|
|
211
|
+
set([ITEMS[0], ITEMS[1]], true, 4);
|
|
212
|
+
host.event('actions/rail/launcher#tap', {});
|
|
213
|
+
set([], true, 5);
|
|
214
|
+
assert.equal(surface.isOpen(), false);
|
|
215
|
+
assert.deepEqual(at(host.wire(), 'actions/rail').c.map((b) => b.k), ['launcher']);
|
|
216
|
+
assert.equal(at(host.wire(), 'actions/rail').s.gone, true);
|
|
217
|
+
assert.deepEqual(validate(host.wire()), []);
|
|
218
|
+
surface.dispose();
|
|
219
|
+
resetUiTrees();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
await test('a measured placement keeps actionLayout\'s rows: buttons at their cells, inside the checked rect', () => {
|
|
224
|
+
resetUiTrees();
|
|
225
|
+
const host = makeHost();
|
|
226
|
+
const view = { w: 330, h: 300 };
|
|
227
|
+
const surface = makeActionRailSurface({ view: () => view, safeInsets: true, later: host.later, cancelLater: host.cancelLater });
|
|
228
|
+
surface.set(ITEMS, () => {}, true, 1);
|
|
229
|
+
const inputs = { view, safe: {}, offers: [{ w: 100, h: 44 }, { w: 100, h: 100 }, { w: 200, h: 100 }] };
|
|
230
|
+
const placed = surface.fit(inputs);
|
|
231
|
+
// actionLayout splits [0] / [1, 2], 152 px high; plain wrapping in its
|
|
232
|
+
// width would give [0, 1] / [2], 208 px, out of the rect it checked.
|
|
233
|
+
assert.equal(placed.mode, 'all-two');
|
|
234
|
+
assert.equal(placed.rect.bottom - placed.rect.top, 152);
|
|
235
|
+
const rail = at(host.wire(), 'actions/rail');
|
|
236
|
+
assert.equal(rail.t, 'stack', 'laid out by cells, not by wrapping');
|
|
237
|
+
assert.deepEqual([rail.s.w, rail.s.h], [placed.rect.right - placed.rect.left, 152]);
|
|
238
|
+
const buttons = rail.c.filter((b) => b.k.startsWith('o:'));
|
|
239
|
+
for (const [index, button] of buttons.entries()) {
|
|
240
|
+
const cell = placed.cells.find((c) => c.index === index);
|
|
241
|
+
assert.deepEqual(button.at, { anchor: 'topLeft', top: cell.top - placed.rect.top, left: cell.left - placed.rect.left });
|
|
242
|
+
assert.deepEqual([button.s.w, button.s.h], [cell.width, cell.height]);
|
|
243
|
+
assert(button.at.left >= 0 && button.at.left + button.s.w <= rail.s.w && button.at.top >= 0 && button.at.top + button.s.h <= rail.s.h, button.k);
|
|
244
|
+
}
|
|
245
|
+
assert.equal(buttons[0].at.top, 0, 'the first offer alone on the first row');
|
|
246
|
+
assert.equal(buttons[1].at.top, buttons[2].at.top, 'the other two share the second');
|
|
247
|
+
assert(buttons[1].at.top >= 44 + 8);
|
|
248
|
+
assert.equal(at(host.wire(), 'actions/rail/launcher').s.gone, true);
|
|
249
|
+
// More: the first offer and the launcher at the two cells.
|
|
250
|
+
const more = actionLayout({ view: { w: 390, h: 844 }, offers: inputs.offers, more: { w: 110, h: 44 }, obstacles: [{ left: 0, right: 390, top: 0, bottom: 700 }, { left: 0, right: 100, top: 700, bottom: 844 }] });
|
|
251
|
+
assert.equal(more.mode, 'more');
|
|
252
|
+
surface.setLayout(more);
|
|
253
|
+
const railMore = at(host.wire(), 'actions/rail');
|
|
254
|
+
const cell1 = more.cells.find((c) => c.index === 1);
|
|
255
|
+
assert.deepEqual(at(railMore, 'x/launcher').at, { anchor: 'topLeft', top: cell1.top - more.rect.top, left: cell1.left - more.rect.left });
|
|
256
|
+
assert.equal(at(railMore, 'x/launcher').c[0].text, 'More (2)');
|
|
257
|
+
assert.deepEqual(railMore.c.map((b) => Boolean(b.s.gone)), [false, true, true, false]);
|
|
258
|
+
assert.deepEqual(validate(host.wire()), []);
|
|
259
|
+
// Bytes do not move across rebuilds with fresh closures.
|
|
260
|
+
const state = { ...surface.state };
|
|
261
|
+
assert.equal(serialize(buildActionRail(state, { act: () => 1 }), 'actions').json, serialize(buildActionRail(state, { act: () => 2 }), 'actions').json);
|
|
262
|
+
surface.dispose();
|
|
263
|
+
resetUiTrees();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
await test('the sheet is centred inside the safe area, not against the full view', () => {
|
|
267
|
+
const tree = buildActionRail({ items: ITEMS, canAct: true, open: true, layout: { mode: 'launcher' }, view: VIEWS.landscape, safeInsets: true });
|
|
268
|
+
const safe = at(tree, 'actions/sheet/safe');
|
|
269
|
+
// Both horizontal edges at the insets: the frame spans exactly the safe
|
|
270
|
+
// width (a 44 px left inset and none on the right: from 44 px to the
|
|
271
|
+
// right edge), and the card is centred within it, at most 560 wide.
|
|
272
|
+
assert.deepEqual(safe.at, { anchor: 'bottom', bottom: [0, 0], left: [0, 0], right: [0, 0] });
|
|
273
|
+
assert.equal(safe.s.align, 'center');
|
|
274
|
+
const card = at(tree, 'actions/sheet/safe/card');
|
|
275
|
+
assert.equal(card.at, undefined);
|
|
276
|
+
assert.deepEqual([card.s.w, card.s.maxW], ['fill', 560]);
|
|
277
|
+
// The web renderer would write it the same way: both insets, no centring transform.
|
|
278
|
+
const css = cssFor(safe, 'stack');
|
|
279
|
+
assert.equal(css.left, 'max(0px, env(safe-area-inset-left))');
|
|
280
|
+
assert.equal(css.right, 'max(0px, env(safe-area-inset-right))');
|
|
281
|
+
assert.equal(css.transform, undefined);
|
|
282
|
+
assert.equal(cssFor(card, 'column').width, '100%');
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
await test('surface: fit places the rail with actionLayout over measured sizes', () => {
|
|
286
|
+
resetUiTrees();
|
|
287
|
+
const host = makeHost();
|
|
288
|
+
const surface = makeActionRailSurface({ view: () => VIEWS.portrait, safeInsets: true, later: host.later, cancelLater: host.cancelLater });
|
|
289
|
+
surface.set(ITEMS, () => {}, true, 1);
|
|
290
|
+
const sizes = { offers: [{ w: 120, h: 44 }, { w: 170, h: 44 }, { w: 150, h: 44 }], more: { w: 110, h: 44 }, launcher: { w: 130, h: 44 } };
|
|
291
|
+
const safe = { left: 0, right: 0, top: 47, bottom: 34 };
|
|
292
|
+
// Room for everything in two rows.
|
|
293
|
+
let placed = surface.fit({ view: VIEWS.portrait, safe, ...sizes });
|
|
294
|
+
assert.equal(placed.mode, 'all-two');
|
|
295
|
+
assert.equal(at(host.wire(), 'actions/rail').at.anchor, 'topLeft');
|
|
296
|
+
assert.deepEqual(at(host.wire(), 'actions/rail').c.map((b) => Boolean(b.s.gone)), [false, false, false, true]);
|
|
297
|
+
// Controls fill the low right: the first offer and More.
|
|
298
|
+
const obstacles = [{ left: 0, right: 390, top: 0, bottom: 700 }, { left: 0, right: 100, top: 700, bottom: 844 }];
|
|
299
|
+
placed = surface.fit({ view: VIEWS.portrait, safe, ...sizes, obstacles });
|
|
300
|
+
assert.equal(placed.mode, 'more');
|
|
301
|
+
assert.equal(at(host.wire(), 'actions/rail/launcher').c[0].text, 'More (2)');
|
|
302
|
+
// Nothing fits: hidden.
|
|
303
|
+
placed = surface.fit({ view: VIEWS.portrait, safe, ...sizes, obstacles: [{ left: 0, right: 390, top: 0, bottom: 844 }] });
|
|
304
|
+
assert.equal(placed, null);
|
|
305
|
+
assert.equal(at(host.wire(), 'actions/rail').s.gone, true);
|
|
306
|
+
surface.setLayout(null);
|
|
307
|
+
assert.equal(at(host.wire(), 'actions/rail').s.gone, false);
|
|
308
|
+
surface.dispose();
|
|
309
|
+
resetUiTrees();
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
await test('surface: a safeInsets flip in view() moves the rail without a rebuild', () => {
|
|
313
|
+
resetUiTrees();
|
|
314
|
+
const host = makeHost();
|
|
315
|
+
const stage = { ...VIEWS.portrait, safeInsets: false };
|
|
316
|
+
const draws = [];
|
|
317
|
+
const surface = makeActionRailSurface({ view: () => stage, safeInsets: false, later: host.later, cancelLater: host.cancelLater, draw: (tree) => draws.push(tree) });
|
|
318
|
+
surface.set(ITEMS, () => {}, true, 1);
|
|
319
|
+
assert.deepEqual(at(host.wire(), 'actions/rail').at.bottom, [8, 8]);
|
|
320
|
+
const ids = host.ids();
|
|
321
|
+
// The manifest update turns it on: the next render takes it, and the
|
|
322
|
+
// state the rail had (its offers) stays.
|
|
323
|
+
stage.safeInsets = true;
|
|
324
|
+
surface.render();
|
|
325
|
+
assert.equal(surface.state.safeInsets, true);
|
|
326
|
+
assert.deepEqual(at(host.wire(), 'actions/rail').at.bottom, [8, 0]);
|
|
327
|
+
assert.deepEqual(host.ids(), ids);
|
|
328
|
+
const count = draws.length;
|
|
329
|
+
surface.render();
|
|
330
|
+
assert.equal(draws.length, count);
|
|
331
|
+
// fit takes the flip too: edgeMax only while it is on.
|
|
332
|
+
const sizes = { offers: [{ w: 120, h: 44 }, { w: 170, h: 44 }, { w: 150, h: 44 }], more: { w: 110, h: 44 }, launcher: { w: 130, h: 44 } };
|
|
333
|
+
const inputs = { view: VIEWS.portrait, safe: { left: 0, right: 0, top: 47, bottom: 34 }, ...sizes };
|
|
334
|
+
assert.deepEqual(surface.fit(inputs).rect, actionLayout({ ...inputs, edgeMax: true }).rect);
|
|
335
|
+
stage.safeInsets = false;
|
|
336
|
+
assert.deepEqual(surface.fit(inputs).rect, actionLayout(inputs).rect);
|
|
337
|
+
surface.setLayout(null);
|
|
338
|
+
assert.deepEqual(at(host.wire(), 'actions/rail').at.bottom, [8, 8]);
|
|
339
|
+
// A view() that says nothing keeps the flag the surface was made with.
|
|
340
|
+
delete stage.safeInsets;
|
|
341
|
+
const fixed = makeActionRailSurface({ view: () => stage, safeInsets: true });
|
|
342
|
+
assert.equal(fixed.state.safeInsets, true);
|
|
343
|
+
fixed.dispose();
|
|
344
|
+
surface.dispose();
|
|
345
|
+
resetUiTrees();
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
await test('the surface loads and runs in a process that never had a DOM', () => {
|
|
349
|
+
const probe = `
|
|
350
|
+
if (globalThis.document || globalThis.window) throw new Error('a DOM');
|
|
351
|
+
const { setUiTreeSink, dispatchUiEvent } = await import(${JSON.stringify(new URL('../code/client/uiTree.js', import.meta.url).href)});
|
|
352
|
+
const { makeActionRailSurface } = await import(${JSON.stringify(new URL('../code/client/actionRailSurface.js', import.meta.url).href)});
|
|
353
|
+
const seen = [];
|
|
354
|
+
setUiTreeSink((name, wire) => seen.push(name + ':' + (wire ? wire.c.length : null)), { dom: false });
|
|
355
|
+
const surface = makeActionRailSurface({ view: () => ({ w: 390, h: 844 }), safeInsets: true });
|
|
356
|
+
surface.set([{ id: 'a', label: 'A' }, { id: 'b', label: 'B' }], (id) => seen.push('act:' + id), true, 1);
|
|
357
|
+
surface.setLayout({ mode: 'launcher' });
|
|
358
|
+
dispatchUiEvent('actions', 'actions/rail/launcher#tap', {});
|
|
359
|
+
dispatchUiEvent('actions', 'actions/sheet/safe/card/list/grid/b#tap', {});
|
|
360
|
+
dispatchUiEvent('actions', 'actions/sheet/safe/card/list/grid/o:b#tap', {});
|
|
361
|
+
dispatchUiEvent('actions', 'actions#cancel', {});
|
|
362
|
+
surface.dispose();
|
|
363
|
+
console.log(seen.join(' '));
|
|
364
|
+
`;
|
|
365
|
+
assert.equal(execFileSync(process.execPath, ['--input-type=module', '-e', probe], { encoding: 'utf8' }).trim(), 'actions:1 actions:1 actions:1 actions:2 act:b actions:1 actions:null');
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
console.log(`action rail surface: ${passed} checks passed`);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Oct 10 card: at the Town's fountain jobs board, 844x390 landscape, with a
|
|
2
|
+
// "Chat with Tamsin" act prompt, the People/Party control and a long jobs HUD
|
|
3
|
+
// up, the old bottom-right chip column trimmed 'Carry bread' and 'Sweep pier'
|
|
4
|
+
// off screen. Since v1.187 every place draws offers on the overflow rail: each
|
|
5
|
+
// of the three picks must be fully in view and clear of every other control,
|
|
6
|
+
// or behind a visible More whose sheet lists all three. Run with CHROME
|
|
7
|
+
// pointing to the QA browser (and BROWSER_WS when using a remote GPU browser).
|
|
8
|
+
import assert from 'node:assert/strict';
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { chromium } from 'playwright-core';
|
|
12
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
13
|
+
|
|
14
|
+
const root = new URL('../../../', import.meta.url);
|
|
15
|
+
const source = await readFile(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
16
|
+
const setup = source.slice(source.indexOf(' this.chrome.setWorldLabelFocus'), source.indexOf(' Avatar.load(scene);'));
|
|
17
|
+
// The labels jobs.js TITLES gives the board's three picks.
|
|
18
|
+
const OFFERS = [
|
|
19
|
+
{ id: 'jg02-pick-water', label: 'Water planters' }, { id: 'jg02-pick-delivery', label: 'Carry bread' }, { id: 'jg02-pick-sweep', label: 'Sweep pier' },
|
|
20
|
+
];
|
|
21
|
+
const HUD = { title: 'Jobs 0 of 3 · 2+ days', text: 'Choose a short job. Each pays 5 town tokens. Saving your job. You can keep walking while Tamsin waits by the fountain.'.slice(0, 120) };
|
|
22
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
23
|
+
try {
|
|
24
|
+
const context = await browser.newContext({ viewport: { width: 844, height: 390 }, isMobile: true, hasTouch: true });
|
|
25
|
+
const page = await context.newPage();
|
|
26
|
+
await page.route('http://jobs.test/**', async route => {
|
|
27
|
+
const path = new URL(route.request().url()).pathname;
|
|
28
|
+
if (path === '/') return route.fulfill({ contentType: 'text/html', body: '<meta name="viewport" content="width=device-width,initial-scale=1"><script type="importmap">{"imports":{"three":"/node_modules/three/build/three.module.js"}}</script><body style="margin:0"></body>' });
|
|
29
|
+
const url = new URL(`.${path}`, root);
|
|
30
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
31
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
32
|
+
});
|
|
33
|
+
await page.goto('http://jobs.test/');
|
|
34
|
+
await logRenderer(page, 'action rail town jobs');
|
|
35
|
+
const result = await page.evaluate(async ({ setup, OFFERS, HUD }) => {
|
|
36
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
37
|
+
const { overlaps } = await import('/kits/hub-game/code/client/safeLayout.js');
|
|
38
|
+
const { makeAct } = await import('/kits/hub-game/code/client/act.js');
|
|
39
|
+
const { hub } = await import('/kits/hub-game/code/client/state.js');
|
|
40
|
+
// The Town declares hub.act, which turns on safeInsets (hub.js).
|
|
41
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, safeInsets: true });
|
|
42
|
+
chrome.soundControl(true, { volume: 0.7, muted: false }, { onMuted() {}, onVolume() {} });
|
|
43
|
+
chrome.showPicker(true, 0);
|
|
44
|
+
chrome.setEmotes([['wave', '👋']]); chrome.setSay({ reactions: [], phrases: [] });
|
|
45
|
+
chrome.showBack(true, 'Back');
|
|
46
|
+
chrome.setPeople([{ key: 'u2', playerId: 'p2', userId: 'u2', username: 'juniper', actions: [] }], 'Party · 2');
|
|
47
|
+
const scene = { persistent: {}, three: { renderer: { domElement: { parentElement: document.body } } } };
|
|
48
|
+
const Hub = { deck: { act: true }, hub: {} };
|
|
49
|
+
hub.place = { id: 'main', act: true };
|
|
50
|
+
// Tamsin is a mind: her act prompt reads "Chat with Tamsin".
|
|
51
|
+
hub.prompts = [{ id: 'tamsin', verb: 'Chat with Tamsin' }];
|
|
52
|
+
const tamsin = { id: 'tamsin', components: { HubNpc: { name: 'Tamsin' }, Transform: { x: 0.6, y: 1, z: 0 } } };
|
|
53
|
+
const act = makeAct(chrome, { perform() {} }, { prepare() {} });
|
|
54
|
+
Object.assign(scene, { getActors: () => [tamsin], getActor: () => tamsin, moveInput: { consumeJump() {} } });
|
|
55
|
+
scene.three.camera = { position: { clone: () => ({ set() { return this; }, project: () => ({ x: 0.08, y: -0.1, z: 0 }) }) } };
|
|
56
|
+
const local = { components: { Transform: { x: 0, y: 1, z: 0 } } };
|
|
57
|
+
const avatar = { left: innerWidth * 0.5 - 30, right: innerWidth * 0.5 + 40, top: innerHeight * 0.3, bottom: innerHeight * 0.62 };
|
|
58
|
+
const draw = () => {
|
|
59
|
+
new Function('Hub', 'scene', 'worldLabelFocus', setup).call({ chrome }, Hub, scene, () => false);
|
|
60
|
+
chrome.setHud(HUD, null);
|
|
61
|
+
chrome.setWorldAvatar(avatar);
|
|
62
|
+
act.frame(scene, { net: { selfId: () => 'p', send() {} } }, local, true);
|
|
63
|
+
chrome.layoutInteractionRail();
|
|
64
|
+
chrome.setActions(OFFERS, () => {}, true, 1, true);
|
|
65
|
+
chrome.frameSafeInsets?.();
|
|
66
|
+
};
|
|
67
|
+
const paint = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
68
|
+
for (let round = 0; round < 3; round++) {
|
|
69
|
+
for (let frame = 0; frame < 4; frame++) {draw(); await paint();}
|
|
70
|
+
await new Promise(resolve => setTimeout(resolve, 550));
|
|
71
|
+
}
|
|
72
|
+
for (let frame = 0; frame < 6; frame++) {draw(); await paint();}
|
|
73
|
+
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; };
|
|
74
|
+
const box = node => { const r = node.getBoundingClientRect(); return { left: r.left, right: r.right, top: r.top, bottom: r.bottom }; };
|
|
75
|
+
const name = node => node.getAttribute('aria-label') || node.textContent;
|
|
76
|
+
const rail = [...document.querySelectorAll('[data-hub="action-rail"] button')].filter(visible).map(node => ({ name: node.textContent, ...box(node) }));
|
|
77
|
+
const railNodes = new Set(document.querySelectorAll('[data-hub="action-rail"] button'));
|
|
78
|
+
// Every other visible control: the act prompt, Act/Jump, People, Back,
|
|
79
|
+
// picker, sound, emote, say.
|
|
80
|
+
const others = [...document.querySelectorAll('button')].filter(node => !railNodes.has(node) && visible(node)).map(node => ({ name: name(node), ...box(node) }));
|
|
81
|
+
// And the long jobs HUD (title and its text), as the layout report has them.
|
|
82
|
+
for (const b of chrome.layout().boxes) if (b.id === 'hud' || b.id === 'hud-prompt') others.push({ name: b.id, left: b.x, top: b.y, right: b.x + b.w, bottom: b.y + b.h });
|
|
83
|
+
const hits = [];
|
|
84
|
+
for (const chip of rail) for (const other of others) if (overlaps(chip, other)) hits.push([chip.name, other.name]);
|
|
85
|
+
const outside = rail.filter(r => r.left < 0 || r.top < 0 || r.right > innerWidth || r.bottom > innerHeight).map(r => r.name);
|
|
86
|
+
const out = { rail, others, hits, outside, oneRow: new Set(rail.map(r => Math.round(r.top))).size === 1 };
|
|
87
|
+
const launcher = [...railNodes].find(node => visible(node) && /^(More|Actions) \(/.test(node.textContent));
|
|
88
|
+
if (launcher) {
|
|
89
|
+
const r = launcher.getBoundingClientRect();
|
|
90
|
+
const o = { bubbles: true, cancelable: true, clientX: r.left + 4, clientY: r.top + 4, detail: 1 };
|
|
91
|
+
for (const type of ['mousedown', 'mouseup', 'click']) launcher.dispatchEvent(new MouseEvent(type, o));
|
|
92
|
+
await paint();
|
|
93
|
+
out.sheet = [...document.querySelector('[data-hub="action-sheet"]').querySelectorAll('button')].filter(visible).map(b => b.textContent);
|
|
94
|
+
}
|
|
95
|
+
act.dispose?.(); chrome.dispose();
|
|
96
|
+
return out;
|
|
97
|
+
}, { setup, OFFERS, HUD });
|
|
98
|
+
const labels = OFFERS.map(o => o.label);
|
|
99
|
+
console.log(`844x390 rail: ${result.rail.map(r => `${r.name}@${Math.round(r.left)},${Math.round(r.top)}-${Math.round(r.right)},${Math.round(r.bottom)}`).join(' ')}`);
|
|
100
|
+
console.log(`others: ${result.others.map(r => `${r.name}@${Math.round(r.left)},${Math.round(r.top)}-${Math.round(r.right)},${Math.round(r.bottom)}`).join(' | ')}`);
|
|
101
|
+
assert(result.others.some(o => o.name === 'Chat with Tamsin'), 'the Chat with Tamsin prompt is up');
|
|
102
|
+
assert(result.others.some(o => /^People/.test(o.name)), 'the People/Party control is up');
|
|
103
|
+
assert(result.others.some(o => /Back$/.test(o.name)), 'Back is up');
|
|
104
|
+
assert(result.others.some(o => o.name === 'Act'), 'Act is up');
|
|
105
|
+
assert(result.others.some(o => o.name === 'Jump'), 'Jump is up');
|
|
106
|
+
assert(result.others.some(o => o.name === 'hud-prompt'), 'the jobs HUD text is up');
|
|
107
|
+
assert.deepEqual(result.outside, [], 'every rail chip is inside the viewport');
|
|
108
|
+
assert.deepEqual(result.hits, [], 'no rail chip sits under another control');
|
|
109
|
+
const direct = result.rail.map(r => r.name).filter(n => labels.includes(n));
|
|
110
|
+
if (direct.length === labels.length) {
|
|
111
|
+
assert(result.oneRow, 'the three picks stand in one row');
|
|
112
|
+
console.log('town jobs: all three picks visible in one row');
|
|
113
|
+
} else {
|
|
114
|
+
assert(result.sheet, `missing ${labels.filter(l => !direct.includes(l)).join(', ')} with no More launcher`);
|
|
115
|
+
assert.deepEqual(result.sheet.filter(t => t !== 'Close'), labels, 'More opens a sheet listing all three picks');
|
|
116
|
+
console.log(`town jobs: ${direct.length} direct, rest behind More (sheet: ${result.sheet.join(', ')})`);
|
|
117
|
+
}
|
|
118
|
+
} finally { await browser.close(); }
|
|
@@ -638,9 +638,11 @@ test('frame wiring only draws in opted-in places and clears once on keyless trav
|
|
|
638
638
|
const draw = calls.findLast(([name]) => name === 'setActions');
|
|
639
639
|
assert.deepEqual(draw[1], items); assert.equal(draw[3], true);
|
|
640
640
|
assert.equal(draw[4], 1); assert.equal(draw[5], true, 'portrait uses compact overflow without an authored flag');
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
641
|
+
for (const [w, h] of [[844, 390], [509, 218]]) {
|
|
642
|
+
window.innerWidth = w; window.innerHeight = h;
|
|
643
|
+
system.afterBehaviors(scene, 0.05);
|
|
644
|
+
assert.equal(calls.findLast(([name]) => name === 'setActions')[5], true, `v1.187: landscape ${w}x${h} uses the overflow rail without an authored flag`);
|
|
645
|
+
}
|
|
644
646
|
draw[2]('start', draw[4]); assert.deepEqual(sent, [{ k: 'hub-action', id: 'start', n: 1 }]);
|
|
645
647
|
scene.data = { engine: { hubActionOverflow: true } };
|
|
646
648
|
system.afterBehaviors(scene, 0.05);
|
|
@@ -244,6 +244,30 @@ await test('hook throws and rejections are contained and logged once', async ()
|
|
|
244
244
|
assert.equal(warnings.filter((text) => text.includes('action hook failed')).length, 1);
|
|
245
245
|
} finally { console.warn = warn; }
|
|
246
246
|
});
|
|
247
|
+
await test('a refused list still throws and logs once per rule with the offending id', () => {
|
|
248
|
+
const warnings = [], warn = console.warn;
|
|
249
|
+
console.warn = (text) => warnings.push(String(text));
|
|
250
|
+
try {
|
|
251
|
+
const r = boot({ actions: true });
|
|
252
|
+
const refused = () => warnings.filter((text) => text.includes('hub.actions refused'));
|
|
253
|
+
for (const id of ['Start', 'Start', 'ok!']) {
|
|
254
|
+
assert.throws(() => r.hub.actions('p1', [{ id, label: 'Go' }]), TypeError);
|
|
255
|
+
assert.throws(() => r.hub.actions('p2', [{ id, label: 'Go' }]), TypeError);
|
|
256
|
+
}
|
|
257
|
+
assert.deepEqual(refused(), ['[hub] hub.actions refused a list: id must be a short id (id "Start")']);
|
|
258
|
+
assert.throws(() => r.hub.actions('p1', [{ id: 'go', label: '' }]), TypeError);
|
|
259
|
+
assert.throws(() => r.hub.actions('p1', [items[0], { id: 'b', label: 'B' }, items[0]]), TypeError);
|
|
260
|
+
assert.throws(() => r.hub.actions('p1', [items[0], 'x']), TypeError);
|
|
261
|
+
assert.deepEqual(refused().slice(1), [
|
|
262
|
+
'[hub] hub.actions refused a list: label must be 1..16 characters (code points), no control, direction or zero-width characters (id "go")',
|
|
263
|
+
`[hub] hub.actions refused a list: ids must be unique (id ${JSON.stringify(items[0].id)})`,
|
|
264
|
+
'[hub] hub.actions refused a list: item must be a plain object (item 1)',
|
|
265
|
+
]);
|
|
266
|
+
// A list that passes says nothing.
|
|
267
|
+
assert.equal(r.hub.actions('p1', items), true);
|
|
268
|
+
assert.equal(refused().length, 4);
|
|
269
|
+
} finally { console.warn = warn; }
|
|
270
|
+
});
|
|
247
271
|
await test('async hooks run concurrently and continue after departure', async () => {
|
|
248
272
|
const pending = [], completed = [];
|
|
249
273
|
const r = boot({ actions: true }, { hooks: { action(ctx, playerId) { return new Promise((resolve) => pending.push(() => { completed.push(playerId); resolve(); })); } } });
|
|
@@ -397,6 +397,25 @@ test('spawn copies a scene actor for everyone, under its caps; despawn removes i
|
|
|
397
397
|
assert.equal(Object.keys(h.join().spawned).length, Actors.MAX_SPAWNED);
|
|
398
398
|
});
|
|
399
399
|
|
|
400
|
+
test('v1.162 a copy may name its carer; without one its record and snapshot keep the same bytes', () => {
|
|
401
|
+
const { h, world, hub } = boot();
|
|
402
|
+
h.message({ sessionId: 's-1', players: [] }, { playerId: 'p1' }, { k: 'hub-hello', avatar: 0 });
|
|
403
|
+
const plain = hub.spawn('wall', { x: 1, rotationY: 0 });
|
|
404
|
+
const ignored = [{}, { carer: 'nobody' }, { carer: 7 }, null].map((options) => hub.spawn('wall', { x: 1, rotationY: 0 }, options));
|
|
405
|
+
const pet = hub.spawn('wall', { x: 2, rotationY: 0 }, { carer: 'p1' });
|
|
406
|
+
const join = h.join().spawned;
|
|
407
|
+
// Exactly the record a copy had before v1.162.
|
|
408
|
+
assert.equal(JSON.stringify(join[plain]), '{"from":"wall","x":1,"y":1,"z":0,"rotationY":0}');
|
|
409
|
+
for (const id of ignored) assert.equal(JSON.stringify(join[id]), JSON.stringify(join[plain]), id);
|
|
410
|
+
assert.equal(JSON.stringify(join[pet]), '{"from":"wall","x":2,"y":1,"z":0,"rotationY":0,"carer":"p1"}');
|
|
411
|
+
assert.deepEqual(h.delta().spawned[pet], join[pet]);
|
|
412
|
+
// The carer leaving keeps the copy's carer; the place despawns it.
|
|
413
|
+
h.place(world);
|
|
414
|
+
assert.equal(h.join().spawned[pet].carer, 'p1');
|
|
415
|
+
assert.equal(hub.despawn(pet), true);
|
|
416
|
+
assert.equal(JSON.stringify(h.join().spawned), JSON.stringify(Object.fromEntries([plain, ...ignored].map((id) => [id, join[plain]]))));
|
|
417
|
+
});
|
|
418
|
+
|
|
400
419
|
test('v1.161 a deck may raise the spawn cap to 192; absent keeps 96 and the same manifest bytes', () => {
|
|
401
420
|
const engine = { createBody: () => body(), removeActor: (sim, id) => { sim.bodies.delete(id); sim.objects.delete(id); } };
|
|
402
421
|
const filled = (hubKeys) => {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// v1.186: without hub.safeInsets the kit's Again leaves the reserved top-left
|
|
2
|
+
// 64x56 Back corner for the bottom centre wherever it would meet it; landscape
|
|
3
|
+
// with no left inset, Back to a door, and safe-inset places keep their place.
|
|
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
|
+
const corner = { left: 0, top: 0, right: 64, bottom: 56 };
|
|
12
|
+
const meets = (a, b) => a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;
|
|
13
|
+
try {
|
|
14
|
+
const cases = [
|
|
15
|
+
// [width, height, safeInsets, label, expect]
|
|
16
|
+
[412, 870, false, 'Again', 'low'],
|
|
17
|
+
[390, 844, false, 'Again', 'low'],
|
|
18
|
+
[844, 390, false, 'Again', 'top'],
|
|
19
|
+
[412, 870, false, 'Town', 'top'],
|
|
20
|
+
[412, 870, true, 'Again', 'top'],
|
|
21
|
+
];
|
|
22
|
+
for (const [width, height, safeInsets, label, expect] of cases) {
|
|
23
|
+
const context = await browser.newContext({ viewport: { width, height }, isMobile: true, hasTouch: true });
|
|
24
|
+
const page = await context.newPage();
|
|
25
|
+
await page.route('http://again.test/**', async route => {
|
|
26
|
+
const pathname = new URL(route.request().url()).pathname;
|
|
27
|
+
if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: '<meta name="viewport" content="width=device-width,initial-scale=1"><body style="margin:0"></body>' });
|
|
28
|
+
const url = new URL(`.${pathname}`, root);
|
|
29
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
30
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
31
|
+
});
|
|
32
|
+
await page.goto('http://again.test/');
|
|
33
|
+
await logRenderer(page, 'again corner');
|
|
34
|
+
const box = await page.evaluate(async ({ safeInsets, label }) => {
|
|
35
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
36
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, safeInsets });
|
|
37
|
+
chrome.showBack(true, label);
|
|
38
|
+
chrome.setHud({ title: 'Summit', big: 'YOU WIN', text: 'Again to play another round' }, null);
|
|
39
|
+
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
40
|
+
await new Promise(resolve => setTimeout(resolve, safeInsets ? 600 : 0));
|
|
41
|
+
const node = [...document.querySelectorAll('button')].find(n => n.textContent.includes(label));
|
|
42
|
+
const r = node.getBoundingClientRect();
|
|
43
|
+
const p = document.querySelector('[data-hub="hud-prompt"]').getBoundingClientRect();
|
|
44
|
+
chrome.dispose();
|
|
45
|
+
return { left: r.left, right: r.right, top: r.top, bottom: r.bottom, prompt: { left: p.left, right: p.right, top: p.top, bottom: p.bottom } };
|
|
46
|
+
}, { safeInsets, label });
|
|
47
|
+
const tag = `${width}x${height} safeInsets=${safeInsets} ${label}`;
|
|
48
|
+
if (expect === 'low') {
|
|
49
|
+
assert.ok(!meets(box, corner), `${tag}: clear of the Back corner`);
|
|
50
|
+
assert.ok(!meets(box, box.prompt), `${tag}: clear of the prompt pill`);
|
|
51
|
+
assert.ok(Math.abs((box.left + box.right) / 2 - width / 2) <= 1, `${tag}: centred`);
|
|
52
|
+
assert.ok(height - box.bottom >= 11 && height - box.bottom <= 13, `${tag}: 12 px from the bottom edge with no inset`);
|
|
53
|
+
} else {
|
|
54
|
+
assert.ok(box.top < height / 2, `${tag}: keeps its top place`);
|
|
55
|
+
}
|
|
56
|
+
console.log(`${tag}: ${expect === 'low' ? 'bottom centre' : 'top'} ${Math.round(box.left)},${Math.round(box.top)}`);
|
|
57
|
+
await context.close();
|
|
58
|
+
}
|
|
59
|
+
} finally { await browser.close(); }
|