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,616 @@
|
|
|
1
|
+
// The emote surface (`code/client/emoteSurface.js`) and its trees
|
|
2
|
+
// (`emoteTree.js`): idle play's Emote button, its row, the expression wheel
|
|
3
|
+
// and Sit / Stand as the `emotes` and `emotewheel` UI tree roots, with no
|
|
4
|
+
// DOM, for a native host. Checks that the trees validate, portrait and
|
|
5
|
+
// landscape; that bytes and binding ids do not move across rebuilds with
|
|
6
|
+
// fresh closures; that the wheel's sheet and every cell sit where
|
|
7
|
+
// emoteWheel.js puts them (the ring's cos/sin, the compact grid, the pages);
|
|
8
|
+
// and that every tap, driven through idle.js's own makeIdle, sends what the
|
|
9
|
+
// DOM's does: a row emote, a wheel emote, the wheel's ground Sit, paging,
|
|
10
|
+
// the shield and Back shutting the wheel, Sit and Stand.
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import { execFileSync } from 'node:child_process';
|
|
13
|
+
import { register } from 'node:module';
|
|
14
|
+
import { domRect, fakeDom } from './fixtures/fake-dom.mjs';
|
|
15
|
+
import { dispatchUiEvent, resetUiTrees, serialize, setUiTreeSink, validate } from '../code/client/uiTree.js';
|
|
16
|
+
import { buildEmoteWheel, buildEmotes, clampPage, wheelCells, wheelLayout, WHEEL_W } from '../code/client/emoteTree.js';
|
|
17
|
+
import { EMOTE_ROOTS, makeEmoteSurface } from '../code/client/emoteSurface.js';
|
|
18
|
+
import { makeEmoteWheel } from '../code/client/emoteWheel.js';
|
|
19
|
+
import { EMOTES, expressionChoices, makeIdle } from '../code/client/idle.js';
|
|
20
|
+
import { clear, hub } from '../code/client/state.js';
|
|
21
|
+
|
|
22
|
+
let passed = 0;
|
|
23
|
+
const test = async (name, fn) => {
|
|
24
|
+
try {await fn();} catch (error) {error.message = `${name}: ${error.message}`; throw error;}
|
|
25
|
+
passed += 1;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const NO_INSETS = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
29
|
+
const VIEWS = {
|
|
30
|
+
portrait: { landscape: false, safeInsets: false, w: 390, h: 844, lift: 0, insets: NO_INSETS },
|
|
31
|
+
landscape: { landscape: true, safeInsets: false, w: 844, h: 390, lift: 0, insets: NO_INSETS },
|
|
32
|
+
};
|
|
33
|
+
const role = { id: 'doctor', emoji: '๐ฉบ', label: 'Checkup', motion: 'bow', ms: 3500 };
|
|
34
|
+
const EXPRESSION = { roleEmotes: [role, { ...role, id: 'baker', emoji: '๐ฅ', label: 'Baking' }] };
|
|
35
|
+
const CHOICES = expressionChoices(EXPRESSION, ['doctor', 'baker']);
|
|
36
|
+
// A corner stack down the right and a HUD band over the top.
|
|
37
|
+
const BANDS = {
|
|
38
|
+
none: [],
|
|
39
|
+
corner: (v) => [{ left: v.w - 90, right: v.w - 10, top: v.h - 300, bottom: v.h - 10 }],
|
|
40
|
+
squeeze: (v) => [{ left: 0, right: v.w, top: 0, bottom: v.h / 2 - 40 }],
|
|
41
|
+
};
|
|
42
|
+
const bandsFor = (name, v) => (typeof BANDS[name] === 'function' ? BANDS[name](v) : BANDS[name]);
|
|
43
|
+
const noop = { toggle() {}, pick() {}, sit() {}, close() {}, page() {} };
|
|
44
|
+
|
|
45
|
+
function find(tree, k) {
|
|
46
|
+
if (!tree) {return null;}
|
|
47
|
+
if (tree.k === k) {return tree;}
|
|
48
|
+
for (const child of tree.c ?? []) {
|
|
49
|
+
const hit = find(child, k);
|
|
50
|
+
if (hit) {return hit;}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const words = (node) => node?.text ?? node?.c?.find((child) => child.t === 'text' && !child.k)?.text;
|
|
55
|
+
|
|
56
|
+
// emoteWheel.js drawn into a fake DOM: its sheet, and each cell's box.
|
|
57
|
+
function domWheel(v, bands) {
|
|
58
|
+
const make = (tag, style = {}, parent = null) => {
|
|
59
|
+
const node = {
|
|
60
|
+
tag, style: { ...style }, children: [], dataset: {}, attrs: {}, listeners: {}, textContent: '', parent,
|
|
61
|
+
setAttribute(key, value) {node.attrs[key] = String(value);},
|
|
62
|
+
addEventListener(type, fn) {node.listeners[type] = fn;},
|
|
63
|
+
replaceChildren() {node.children = [];},
|
|
64
|
+
remove() {},
|
|
65
|
+
contains(other) {return node === other || node.children.some((child) => child.contains(other));},
|
|
66
|
+
};
|
|
67
|
+
parent?.children.push(node);
|
|
68
|
+
return node;
|
|
69
|
+
};
|
|
70
|
+
const root = make('div');
|
|
71
|
+
const wheel = makeEmoteWheel({ root, el: make, view: () => ({ w: v.w, h: v.h, insets: { ...v.insets } }), bands: () => bands, trigger: null, pick() {}, close() {} });
|
|
72
|
+
const all = (node) => [node, ...node.children.flatMap(all)];
|
|
73
|
+
const px = (value) => Number.parseFloat(value);
|
|
74
|
+
return {
|
|
75
|
+
open(choices) {wheel.set(choices); wheel.open(true);},
|
|
76
|
+
sheet: () => ({ left: px(wheel.node.style.left), top: px(wheel.node.style.top), w: px(wheel.node.style.width), h: px(wheel.node.style.height), maxH: px(wheel.node.style.maxHeight) }),
|
|
77
|
+
cells: () => all(wheel.node).filter((node) => node.dataset.emote).map((node) => ({
|
|
78
|
+
id: node.dataset.emote, label: node.attrs['aria-label'], left: px(node.style.left), top: px(node.style.top), w: px(node.style.width), h: px(node.style.height),
|
|
79
|
+
})),
|
|
80
|
+
nav: () => all(wheel.node).filter((node) => node.tag === 'button' && !node.dataset.emote).map((node) => [node.textContent, node.attrs['aria-label']]),
|
|
81
|
+
press(label) {all(wheel.node).find((node) => node.attrs['aria-label'] === label).listeners.click();},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function treeWheel(v, bands, page) {
|
|
86
|
+
const layout = wheelLayout(v, bands, page);
|
|
87
|
+
const clamped = clampPage(page, CHOICES, layout);
|
|
88
|
+
return { layout, page: clamped, tree: buildEmoteWheel({ open: true, choices: CHOICES, page: clamped, layout }, noop) };
|
|
89
|
+
}
|
|
90
|
+
const close = (a, b, label) => assert(Math.abs(a - b) < 5e-4, `${label}: ${a} vs ${b}`);
|
|
91
|
+
|
|
92
|
+
await test('trees validate: the row, the wheel at every page, portrait and landscape', () => {
|
|
93
|
+
for (const view of [...Object.values(VIEWS), { ...VIEWS.portrait, safeInsets: true, lift: 40 }, { ...VIEWS.landscape, safeInsets: true }]) {
|
|
94
|
+
for (const extra of [
|
|
95
|
+
{ emotes: null }, { emotes: EMOTES }, { emotes: EMOTES, open: true }, { emotes: EMOTES, open: true, wheel: true },
|
|
96
|
+
{ emotes: EMOTES, hidden: true }, { emotes: EMOTES, sit: 'Sit' }, { emotes: null, sit: 'Stand' }, { emotes: EMOTES, sit: 'Lie down', open: true },
|
|
97
|
+
{ emotes: EMOTES, open: true, sit: 'Sit', place: { emote: { x: view.w - 64, y: view.h - 120, w: 44, h: 44 }, sit: { x: view.w - 172, y: view.h - 60, w: 160, h: 44 } } },
|
|
98
|
+
]) {
|
|
99
|
+
assert.deepEqual(validate(buildEmotes({ view, ...extra }, noop), 'emotes'), [], JSON.stringify(extra));
|
|
100
|
+
assert.deepEqual(validate(buildEmotes({ view, ...extra }), 'emotes'), []);
|
|
101
|
+
}
|
|
102
|
+
for (const bands of Object.keys(BANDS)) {
|
|
103
|
+
const layout = wheelLayout(view, bandsFor(bands, view), 0);
|
|
104
|
+
for (let page = 0; page <= Math.ceil(CHOICES.more.length / layout.pageSize); page += 1) {
|
|
105
|
+
const state = { open: true, choices: CHOICES, page, layout: wheelLayout(view, bandsFor(bands, view), page) };
|
|
106
|
+
assert.deepEqual(validate(buildEmoteWheel(state, noop), 'emotewheel'), [], `${bands} ${page}`);
|
|
107
|
+
assert.deepEqual(validate(buildEmoteWheel(state), 'emotewheel'), []);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
assert.deepEqual(validate(buildEmoteWheel({ open: false, choices: CHOICES, page: 0, layout: null }, noop), 'emotewheel'), []);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await test('bytes and binding ids do not move across rebuilds with fresh closures', () => {
|
|
115
|
+
for (const view of Object.values(VIEWS)) {
|
|
116
|
+
const fresh = (n) => ({ toggle: () => n, pick: () => n, sit: () => n, close: () => n, page: () => n });
|
|
117
|
+
const row = { view, emotes: EMOTES, open: true, sit: 'Sit' };
|
|
118
|
+
const one = serialize(buildEmotes(row, fresh(1)), 'emotes');
|
|
119
|
+
const two = serialize(buildEmotes(row, fresh(2)), 'emotes');
|
|
120
|
+
assert.equal(one.json, two.json);
|
|
121
|
+
assert.deepEqual([...one.handlers.keys()], [...two.handlers.keys()]);
|
|
122
|
+
for (const page of [0, 1, 2]) {
|
|
123
|
+
const state = { open: true, choices: CHOICES, page, layout: wheelLayout(view, [], page) };
|
|
124
|
+
const a = serialize(buildEmoteWheel(state, fresh(1)), 'emotewheel');
|
|
125
|
+
const b = serialize(buildEmoteWheel(structuredClone(state), fresh(2)), 'emotewheel');
|
|
126
|
+
assert.equal(a.json, b.json);
|
|
127
|
+
assert.deepEqual([...a.handlers.keys()], [...b.handlers.keys()]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
assert.deepEqual([...serialize(buildEmotes({ view: VIEWS.portrait, emotes: EMOTES, open: true, sit: 'Sit' }, noop), 'emotes').handlers.keys()], [
|
|
131
|
+
'emotes#cancel', 'emotes/emote#tap', 'emotes/row/e:wave#tap', 'emotes/row/e:dance#tap', 'emotes/row/e:cheer#tap', 'emotes/row/e:bow#tap', 'emotes/row/e:spin#tap', 'emotes/sit#tap',
|
|
132
|
+
]);
|
|
133
|
+
assert.deepEqual([...serialize(buildEmoteWheel({ open: true, choices: CHOICES, page: 1, layout: wheelLayout(VIEWS.portrait, [], 1) }, noop), 'emotewheel').handlers.keys()], [
|
|
134
|
+
'emotewheel#cancel', 'emotewheel/shield#tap',
|
|
135
|
+
'emotewheel/sheet/body/e:cheer#tap', 'emotewheel/sheet/body/e:bow#tap', 'emotewheel/sheet/body/e:spin#tap', 'emotewheel/sheet/body/e:doctor#tap', 'emotewheel/sheet/body/e:baker#tap',
|
|
136
|
+
'emotewheel/sheet/nav/page#tap', 'emotewheel/sheet/nav/close#tap',
|
|
137
|
+
]);
|
|
138
|
+
// A shut wheel and a hidden button bind nothing.
|
|
139
|
+
assert.equal(serialize(buildEmoteWheel({ open: false }, noop), 'emotewheel').json, '{"t":"stack","k":"emotewheel","s":{"font":"ui","size":15,"weight":600,"lh":1.3,"color":"#fff"}}');
|
|
140
|
+
assert.equal(serialize(buildEmotes({ view: VIEWS.portrait, emotes: null }, noop), 'emotes').handlers.size, 0);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
await test('the wheel\'s sheet and cells are where emoteWheel.js puts them: the ring, the compact grid, every page', () => {
|
|
144
|
+
const views = [
|
|
145
|
+
{ w: 360, h: 640 }, { w: 640, h: 360 }, { w: 390, h: 844 }, { w: 844, h: 390 }, { w: 320, h: 480 },
|
|
146
|
+
{ w: 844, h: 390, insets: { top: 0, right: 47, bottom: 21, left: 47 } },
|
|
147
|
+
].map((v) => ({ insets: NO_INSETS, ...v }));
|
|
148
|
+
const seen = { ring: 0, grid: 0, paged: 0 };
|
|
149
|
+
for (const v of views) {
|
|
150
|
+
for (const name of Object.keys(BANDS)) {
|
|
151
|
+
const bands = bandsFor(name, v);
|
|
152
|
+
const dom = domWheel(v, bands);
|
|
153
|
+
dom.open(CHOICES);
|
|
154
|
+
let page = 0;
|
|
155
|
+
for (let step = 0; step < 6; step += 1) {
|
|
156
|
+
const { layout, tree } = treeWheel(v, bands, page);
|
|
157
|
+
const sheet = find(tree, 'sheet');
|
|
158
|
+
const want = dom.sheet();
|
|
159
|
+
const label = `${v.w}x${v.h} ${name} page ${page}`;
|
|
160
|
+
close(sheet.at.left, want.left, `${label} left`);
|
|
161
|
+
close(sheet.at.top, want.top, `${label} top`);
|
|
162
|
+
close(sheet.s.w, want.w, `${label} w`);
|
|
163
|
+
close(sheet.s.h, want.h, `${label} h`);
|
|
164
|
+
close(sheet.s.maxH, want.maxH, `${label} maxH`);
|
|
165
|
+
const cells = find(tree, 'body').c;
|
|
166
|
+
const domCells = dom.cells();
|
|
167
|
+
assert.deepEqual(cells.map((c) => c.data.emote), domCells.map((c) => c.id), label);
|
|
168
|
+
assert.deepEqual(cells.map((c) => c.label), domCells.map((c) => c.label), label);
|
|
169
|
+
cells.forEach((cell, i) => {
|
|
170
|
+
close(cell.at.left, domCells[i].left, `${label} ${cell.k} left`);
|
|
171
|
+
close(cell.at.top, domCells[i].top, `${label} ${cell.k} top`);
|
|
172
|
+
close(cell.s.w, domCells[i].w, `${label} ${cell.k} w`);
|
|
173
|
+
close(cell.s.h, domCells[i].h, `${label} ${cell.k} h`);
|
|
174
|
+
});
|
|
175
|
+
assert.deepEqual(find(tree, 'nav').c.map((b) => [words(b), b.label]), dom.nav(), label);
|
|
176
|
+
seen[page ? 'paged' : layout.ring ? 'ring' : 'grid'] += 1;
|
|
177
|
+
// Next page, as the DOM's own buttons turn it.
|
|
178
|
+
const next = find(tree, 'next') ? 'Next emotes' : find(tree, 'page').label;
|
|
179
|
+
dom.press(next);
|
|
180
|
+
page = next === 'Next emotes' ? page % Math.ceil(CHOICES.more.length / layout.pageSize) + 1 : page ? 0 : 1;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
assert(seen.ring > 0 && seen.grid > 0 && seen.paged > 0, JSON.stringify(seen));
|
|
185
|
+
// The ring itself: 86 px about (88, 92), the first cell at the top, 45ยฐ
|
|
186
|
+
// apart clockwise, each 56 x 48; the basics' Sit is the ground variant.
|
|
187
|
+
const ring = wheelCells(CHOICES, wheelLayout(VIEWS.portrait, [], 0), 0);
|
|
188
|
+
assert.equal(ring.length, 8);
|
|
189
|
+
ring.forEach((cell, i) => {
|
|
190
|
+
const angle = i * Math.PI / 4 - Math.PI / 2;
|
|
191
|
+
close(cell.left, 88 + Math.cos(angle) * 86, `ring ${i} left`);
|
|
192
|
+
close(cell.top, 92 + Math.sin(angle) * 86, `ring ${i} top`);
|
|
193
|
+
assert.deepEqual([cell.w, cell.h, cell.ground], [56, 48, cell.id === 'sit']);
|
|
194
|
+
});
|
|
195
|
+
assert.deepEqual(ring.slice(0, 3).map((c) => [c.left, c.top]), [[88, 6], [148.811, 31.189], [174, 92]]);
|
|
196
|
+
assert.equal(wheelLayout(VIEWS.portrait, [], 0).placed.w, WHEEL_W);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
await test('grid cells before the layout is known carry no width, and known widths are as before', () => {
|
|
200
|
+
const r3 = (v) => Math.round(v * 1000) / 1000;
|
|
201
|
+
// The cells as the grid placed them before the unknown width was handled.
|
|
202
|
+
const before = (layout, page) => {
|
|
203
|
+
const { placed, ring, columns, pageSize } = layout;
|
|
204
|
+
const entries = page ? CHOICES.more.slice((page - 1) * pageSize, page * pageSize) : CHOICES.basics;
|
|
205
|
+
const count = page ? columns : 4;
|
|
206
|
+
const width = (placed.w - 8 - (count - 1) * 6) / count;
|
|
207
|
+
return entries.map(([id, emoji, label], i) => ({
|
|
208
|
+
id, emoji, label, ground: !page && id === 'sit',
|
|
209
|
+
left: r3(i % count * (width + 6)), top: Math.floor(i / count) * (ring ? 54 : 48) + (ring ? 62 : 0), w: r3(width), h: ring ? 48 : 44,
|
|
210
|
+
}));
|
|
211
|
+
};
|
|
212
|
+
const zero = { placed: { w: 0, h: 0 }, ring: false, columns: 3, bodyHeight: 96, pageSize: 6 };
|
|
213
|
+
for (const page of [0, 1]) {
|
|
214
|
+
const cells = wheelCells(CHOICES, zero, page);
|
|
215
|
+
assert(cells.length > 0, `page ${page}`);
|
|
216
|
+
for (const cell of cells) {
|
|
217
|
+
assert(!('w' in cell) || (Number.isFinite(cell.w) && cell.w >= 0), `page ${page} w ${cell.w}`);
|
|
218
|
+
assert(Number.isFinite(cell.left) && cell.left >= 0, `page ${page} left ${cell.left}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const tree = buildEmoteWheel({ open: true, choices: CHOICES, layout: zero, page: 0 }, noop);
|
|
222
|
+
assert.deepEqual(validate(tree, 'emotewheel'), []);
|
|
223
|
+
const { json } = serialize(tree, 'emotewheel');
|
|
224
|
+
assert(!/"w":-|NaN|null/.test(json), json);
|
|
225
|
+
const all = [];
|
|
226
|
+
const walk = (n) => {if (String(n?.k).startsWith('e:')) {all.push(n);} (n?.c ?? []).forEach(walk);};
|
|
227
|
+
walk(tree);
|
|
228
|
+
assert.equal(all.length, CHOICES.basics.length);
|
|
229
|
+
all.forEach((cell) => assert.equal(cell.s.w, undefined, cell.k));
|
|
230
|
+
let compared = 0;
|
|
231
|
+
for (const [name, v] of Object.entries(VIEWS)) {
|
|
232
|
+
for (const bands of ['none', 'corner', 'squeeze']) {
|
|
233
|
+
for (const page of [0, 1, 2]) {
|
|
234
|
+
const layout = wheelLayout(v, bandsFor(bands, v), page);
|
|
235
|
+
if (page === 0 && layout.ring) {continue;}
|
|
236
|
+
assert.equal(JSON.stringify(wheelCells(CHOICES, layout, page)), JSON.stringify(before(layout, page)), `${name} ${bands} ${page}`);
|
|
237
|
+
compared += 1;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
for (const w of [120, 200, 263.5, 333]) {
|
|
242
|
+
for (const page of [0, 1]) {
|
|
243
|
+
const layout = { placed: { w, h: 140 }, ring: false, columns: 3, bodyHeight: 96, pageSize: 6 };
|
|
244
|
+
assert.equal(JSON.stringify(wheelCells(CHOICES, layout, page)), JSON.stringify(before(layout, page)), `w ${w} ${page}`);
|
|
245
|
+
compared += 1;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
assert(compared > 8, String(compared));
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
await test('portrait and landscape: the button, the row and Sit where the chrome draws them, or at the host\'s boxes', () => {
|
|
252
|
+
const portrait = buildEmotes({ view: VIEWS.portrait, emotes: EMOTES, open: true, sit: 'Sit' }, noop);
|
|
253
|
+
const emote = find(portrait, 'emote');
|
|
254
|
+
assert.deepEqual([emote.label, emote.fire, words(emote), emote.s.w, emote.s.radius, emote.s.size], ['Emote', 'down', 'โบ', 52, 26, 24]);
|
|
255
|
+
assert.deepEqual(emote.at, { anchor: 'bottomRight', right: 20, bottom: [146, 136] });
|
|
256
|
+
const row = find(portrait, 'row');
|
|
257
|
+
assert.equal(row.t, 'row');
|
|
258
|
+
assert.deepEqual(row.at, { anchor: 'bottomRight', right: 80, bottom: [146, 136] });
|
|
259
|
+
assert.deepEqual(row.c.map((b) => [b.label, words(b), b.fire]), EMOTES.map(([id, emoji]) => [id, emoji, 'down']));
|
|
260
|
+
assert.deepEqual(find(portrait, 'sit').at, { anchor: 'bottom', bottom: [112, 102] });
|
|
261
|
+
assert.equal(words(find(portrait, 'sit')), 'Sit');
|
|
262
|
+
// A safe-inset place with a shift-lock lift.
|
|
263
|
+
const lifted = buildEmotes({ view: { ...VIEWS.portrait, safeInsets: true, lift: 40 }, emotes: EMOTES, open: true }, noop);
|
|
264
|
+
assert.deepEqual(find(lifted, 'emote').at, { anchor: 'bottomRight', right: [20, 0], bottom: [186, 176] });
|
|
265
|
+
assert.deepEqual(find(lifted, 'row').at, { anchor: 'bottomRight', right: [80, 0], bottom: [186, 176] });
|
|
266
|
+
// Landscape: smaller round button, a row that scrolls across, Sit on the right.
|
|
267
|
+
const landscape = buildEmotes({ view: VIEWS.landscape, emotes: EMOTES, open: true, sit: 'Stand' }, noop);
|
|
268
|
+
assert.deepEqual([find(landscape, 'emote').s.w, find(landscape, 'emote').s.radius], [44, 22]);
|
|
269
|
+
assert.deepEqual(find(landscape, 'emote').at, { anchor: 'bottomRight', right: 18, bottom: [146, 136] });
|
|
270
|
+
const lrow = find(landscape, 'row');
|
|
271
|
+
assert.deepEqual([lrow.t, lrow.axis, lrow.s.maxW], ['scroll', 'x', [{ vw: 100, px: -156 }]]);
|
|
272
|
+
assert.deepEqual(find(landscape, 'sit').at, { anchor: 'bottomRight', right: 12, bottom: [112, 102] });
|
|
273
|
+
assert.deepEqual(find(landscape, 'sit').s.maxW, [{ vw: 38 }, { px: 160 }]);
|
|
274
|
+
// The host's rail boxes: the button and Sit pinned there, the row beside
|
|
275
|
+
// the button (8 px upright, clear of the 184 px lane turned).
|
|
276
|
+
const box = { x: 844 - 62, y: 390 - 160, w: 44, h: 44 };
|
|
277
|
+
const placed = buildEmotes({ view: VIEWS.landscape, emotes: EMOTES, open: true, sit: 'Sit', place: { emote: box, sit: { x: 600, y: 300, w: 160, h: 44 } } }, noop);
|
|
278
|
+
assert.deepEqual(find(placed, 'emote').at, { anchor: 'topLeft', top: 230, left: 782 });
|
|
279
|
+
assert.deepEqual(find(placed, 'row').at, { anchor: 'bottomRight', right: 184, bottom: 116 });
|
|
280
|
+
assert.deepEqual(find(placed, 'sit').at, { anchor: 'topLeft', top: 300, left: 600 });
|
|
281
|
+
const upright = buildEmotes({ view: VIEWS.portrait, emotes: EMOTES, open: true, place: { emote: { x: 390 - 72, y: 600, w: 52, h: 52 } } }, noop);
|
|
282
|
+
assert.deepEqual(find(upright, 'row').at, { anchor: 'bottomRight', right: 80, bottom: 192 });
|
|
283
|
+
// The wheel replaces the row; the hidden button keeps its place.
|
|
284
|
+
assert.equal(find(buildEmotes({ view: VIEWS.portrait, emotes: EMOTES, open: true, wheel: true }, noop), 'row'), null);
|
|
285
|
+
assert.equal(find(buildEmotes({ view: VIEWS.portrait, emotes: EMOTES, hidden: true }, noop), 'emote').s.hidden, true);
|
|
286
|
+
// The wheel: a full-view shield under the sheet; a ring where 284 px fit
|
|
287
|
+
// between the 64 px top and the 12 px bottom margin, else the compact grid.
|
|
288
|
+
for (const [view, ring] of [[VIEWS.portrait, true], [VIEWS.landscape, true], [{ ...VIEWS.landscape, w: 568, h: 320 }, false]]) {
|
|
289
|
+
const { tree, layout } = treeWheel(view, [], 0);
|
|
290
|
+
assert.equal(layout.ring, ring);
|
|
291
|
+
assert.deepEqual(tree.c.map((c) => c.k), ['shield', 'sheet']);
|
|
292
|
+
const shield = find(tree, 'shield');
|
|
293
|
+
assert.deepEqual([shield.t, shield.fire, shield.at, shield.s.hit], ['button', 'down', { anchor: 'fill' }, 'auto']);
|
|
294
|
+
const sheet = find(tree, 'sheet');
|
|
295
|
+
assert.deepEqual([sheet.t, sheet.axis, sheet.role, sheet.label, sheet.report], ['scroll', 'y', 'dialog', 'Emotes', true]);
|
|
296
|
+
assert.equal(sheet.s.h, layout.bodyHeight + 52);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// A host: the surface as idle.js's chrome, the place's idle state, and the
|
|
301
|
+
// messages idle.js sends.
|
|
302
|
+
function makeHost(view = VIEWS.portrait, { expression = null, seats = false, bands = [] } = {}) {
|
|
303
|
+
resetUiTrees();
|
|
304
|
+
clear();
|
|
305
|
+
hub.place = { idle: { emotes: true, ...(seats ? { seats: true } : {}), ...(expression ? { expression } : {}) } };
|
|
306
|
+
hub.roleEmotes = ['doctor', 'baker'];
|
|
307
|
+
const host = { roots: [], sent: [], chips: 0, view };
|
|
308
|
+
setUiTreeSink((name, wire, handlers) => {host.roots.push({ name, wire, handlers });}, { dom: false });
|
|
309
|
+
host.surface = makeEmoteSurface({ view: () => host.view, bands: () => bands, onChip: () => {host.chips += 1;} });
|
|
310
|
+
const actors = seats ? [{ id: 'bench', components: { HubSeat: {}, Transform: { x: 0, y: 0.25, z: 0 }, Shape: { kind: 'box', width: 2, depth: 0.6 } } }] : [];
|
|
311
|
+
const scene = { keys: new Set(), moveInput: { consumeJump: () => false }, getActors: () => actors, getActor: (id) => actors.find((a) => a.id === id) ?? null };
|
|
312
|
+
const local = { id: 'local', components: { Transform: { x: 0, y: 1, z: 0.5 } } };
|
|
313
|
+
const mp = { net: { selfId: () => 'self', send: (data) => host.sent.push(data) } };
|
|
314
|
+
host.idle = makeIdle(host.surface);
|
|
315
|
+
let now = 0;
|
|
316
|
+
const realNow = performance.now;
|
|
317
|
+
host.frame = () => {
|
|
318
|
+
now += 500;
|
|
319
|
+
performance.now = () => now;
|
|
320
|
+
try {host.idle.frame(scene, mp, local, true, 'main');} finally {performance.now = realNow;}
|
|
321
|
+
};
|
|
322
|
+
host.wire = (name) => host.roots.filter((r) => r.name === name).at(-1)?.wire ?? null;
|
|
323
|
+
host.ids = (name) => [...(host.roots.filter((r) => r.name === name).at(-1)?.handlers.keys() ?? [])];
|
|
324
|
+
host.event = (name, id) => dispatchUiEvent(name, id, {});
|
|
325
|
+
host.frame();
|
|
326
|
+
return host;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
await test('events: the row\'s Emote button, an emote, Back; Sit and Stand', () => {
|
|
330
|
+
for (const view of Object.values(VIEWS)) {
|
|
331
|
+
const host = makeHost(view, { seats: true });
|
|
332
|
+
assert.equal(find(host.wire('emotes'), 'row'), null);
|
|
333
|
+
assert.equal(words(find(host.wire('emotes'), 'sit')), 'Sit', 'a free seat in reach is offered');
|
|
334
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
335
|
+
assert.equal(host.surface.mode(), 'row');
|
|
336
|
+
assert.deepEqual(find(host.wire('emotes'), 'row').c.map((b) => b.label), EMOTES.map(([id]) => id));
|
|
337
|
+
assert.equal(host.event('emotes', 'emotes/row/e:dance#tap'), true);
|
|
338
|
+
assert.equal(host.surface.isOpen(), false, 'a pick shuts the row');
|
|
339
|
+
host.frame();
|
|
340
|
+
assert.deepEqual(host.sent.splice(0), [{ k: 'hub-emote', id: 'dance' }]);
|
|
341
|
+
// The button toggles; Back shuts the row and binds no cancel after.
|
|
342
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
343
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
344
|
+
assert.equal(host.surface.isOpen(), false);
|
|
345
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
346
|
+
assert.equal(host.event('emotes', 'emotes#cancel'), true);
|
|
347
|
+
assert.equal(host.surface.isOpen(), false);
|
|
348
|
+
assert.equal(host.event('emotes', 'emotes#cancel'), false);
|
|
349
|
+
// Sit, then Stand once seated.
|
|
350
|
+
host.event('emotes', 'emotes/sit#tap');
|
|
351
|
+
host.frame();
|
|
352
|
+
assert.deepEqual(host.sent.splice(0), [{ k: 'hub-sit', seat: 'bench' }]);
|
|
353
|
+
hub.seated = { self: 'bench' };
|
|
354
|
+
host.frame();
|
|
355
|
+
assert.equal(words(find(host.wire('emotes'), 'sit')), 'Stand');
|
|
356
|
+
host.event('emotes', 'emotes/sit#tap');
|
|
357
|
+
host.frame();
|
|
358
|
+
assert.deepEqual(host.sent.splice(0), [{ k: 'hub-stand' }]);
|
|
359
|
+
assert.equal(host.chips, 1, 'the chip sounds for the pick only');
|
|
360
|
+
// A player who cannot act: no button, no Sit.
|
|
361
|
+
host.idle.frame({ keys: new Set(), getActors: () => [] }, { net: { selfId: () => 'self', send() {} } }, null, false, 'main');
|
|
362
|
+
assert.equal(host.wire('emotes').c, undefined);
|
|
363
|
+
host.surface.dispose();
|
|
364
|
+
assert.equal(host.wire('emotes'), null);
|
|
365
|
+
assert.equal(host.wire('emotewheel'), null);
|
|
366
|
+
resetUiTrees();
|
|
367
|
+
}
|
|
368
|
+
clear();
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
await test('events: the wheel\'s emote, its ground Sit, paging, the shield and Back', () => {
|
|
372
|
+
for (const view of Object.values(VIEWS)) {
|
|
373
|
+
const host = makeHost(view, { expression: EXPRESSION });
|
|
374
|
+
assert.equal(host.wire('emotewheel').c, undefined, 'a shut wheel draws nothing');
|
|
375
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
376
|
+
assert.equal(host.surface.mode(), 'wheel');
|
|
377
|
+
assert.equal(find(host.wire('emotes'), 'row'), null);
|
|
378
|
+
assert.equal(host.wire('emotes').on, undefined, 'Back with the wheel up is the wheel root\'s');
|
|
379
|
+
const basics = () => find(host.wire('emotewheel'), 'body').c.map((c) => c.data.emote);
|
|
380
|
+
assert.deepEqual(basics(), CHOICES.basics.map(([id]) => id));
|
|
381
|
+
// A wheel emote.
|
|
382
|
+
host.event('emotewheel', 'emotewheel/sheet/body/e:laugh#tap');
|
|
383
|
+
assert.equal(host.surface.isOpen(), false);
|
|
384
|
+
assert.equal(host.wire('emotewheel').c, undefined);
|
|
385
|
+
host.frame();
|
|
386
|
+
assert.deepEqual(host.sent.splice(0), [{ k: 'hub-emote', id: 'laugh' }]);
|
|
387
|
+
// The basics' Sit is the ground variant: sit where you stand.
|
|
388
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
389
|
+
host.event('emotewheel', 'emotewheel/sheet/body/e:sit#tap');
|
|
390
|
+
host.frame();
|
|
391
|
+
assert.deepEqual(host.sent.splice(0), [{ k: 'hub-sit-here' }]);
|
|
392
|
+
hub.seated = { self: 'ground' };
|
|
393
|
+
host.frame();
|
|
394
|
+
hub.seated = {};
|
|
395
|
+
host.sent.length = 0;
|
|
396
|
+
// Paging: More, Next (wrapping), Basics; a place emote from a page.
|
|
397
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
398
|
+
const layout = wheelLayout(view, [], 1);
|
|
399
|
+
host.event('emotewheel', 'emotewheel/sheet/nav/page#tap');
|
|
400
|
+
assert.equal(host.surface.page(), 1);
|
|
401
|
+
const pages = Math.ceil(CHOICES.more.length / layout.pageSize);
|
|
402
|
+
const shown = [];
|
|
403
|
+
for (let i = 0; i < pages; i += 1) {
|
|
404
|
+
shown.push(...find(host.wire('emotewheel'), 'body').c.map((c) => c.data.emote));
|
|
405
|
+
if (pages > 1) {host.event('emotewheel', 'emotewheel/sheet/nav/next#tap');}
|
|
406
|
+
}
|
|
407
|
+
assert.deepEqual(shown, CHOICES.more.map(([id]) => id), `${view.landscape ? 'landscape' : 'portrait'}: every page once`);
|
|
408
|
+
assert.equal(host.surface.page(), 1, 'Next wraps to the first page');
|
|
409
|
+
assert.equal(words(find(host.wire('emotewheel'), 'page')), 'Basics');
|
|
410
|
+
host.event('emotewheel', 'emotewheel/sheet/body/e:doctor#tap');
|
|
411
|
+
host.frame();
|
|
412
|
+
assert.deepEqual(host.sent.splice(0), [{ k: 'hub-emote', id: 'doctor' }]);
|
|
413
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
414
|
+
assert.equal(host.surface.page(), 0, 'the wheel opens on its basics');
|
|
415
|
+
host.event('emotewheel', 'emotewheel/sheet/nav/page#tap');
|
|
416
|
+
host.event('emotewheel', 'emotewheel/sheet/nav/page#tap');
|
|
417
|
+
assert.deepEqual(basics(), CHOICES.basics.map(([id]) => id), 'Basics');
|
|
418
|
+
// A press outside the sheet (the shield) and Back shut it, sending nothing.
|
|
419
|
+
assert.equal(host.event('emotewheel', 'emotewheel/shield#tap'), true);
|
|
420
|
+
assert.equal(host.surface.isOpen(), false);
|
|
421
|
+
assert.equal(host.wire('emotewheel').on, undefined, 'a shut wheel binds no cancel');
|
|
422
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
423
|
+
assert.equal(host.event('emotewheel', 'emotewheel#cancel'), true);
|
|
424
|
+
assert.equal(host.surface.isOpen(), false);
|
|
425
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
426
|
+
host.event('emotewheel', 'emotewheel/sheet/nav/close#tap');
|
|
427
|
+
assert.equal(host.surface.isOpen(), false);
|
|
428
|
+
host.frame();
|
|
429
|
+
assert.deepEqual(host.sent, []);
|
|
430
|
+
assert.equal(host.chips, 3);
|
|
431
|
+
// The host's own shuts: the picker over the corner, quick chat opening.
|
|
432
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
433
|
+
host.surface.setHidden(true);
|
|
434
|
+
assert.equal(host.surface.isOpen(), false);
|
|
435
|
+
assert.equal(find(host.wire('emotes'), 'emote').s.hidden, true);
|
|
436
|
+
host.surface.setHidden(false);
|
|
437
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
438
|
+
assert.equal(host.surface.close(), true);
|
|
439
|
+
assert.equal(host.surface.cancel(), false);
|
|
440
|
+
// The place leaves expression: the row again, the wheel shut.
|
|
441
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
442
|
+
hub.place = { idle: { emotes: true } };
|
|
443
|
+
host.frame();
|
|
444
|
+
assert.equal(host.surface.isOpen(), false);
|
|
445
|
+
host.event('emotes', 'emotes/emote#tap');
|
|
446
|
+
assert.equal(host.surface.mode(), 'row');
|
|
447
|
+
host.surface.dispose();
|
|
448
|
+
resetUiTrees();
|
|
449
|
+
}
|
|
450
|
+
clear();
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
await test('a rebuild with nothing changed sends nothing; new bands move the wheel', () => {
|
|
454
|
+
let bands = [];
|
|
455
|
+
resetUiTrees();
|
|
456
|
+
const posts = [];
|
|
457
|
+
setUiTreeSink((name) => posts.push(name), { dom: false });
|
|
458
|
+
const surface = makeEmoteSurface({ view: () => VIEWS.portrait, bands: () => bands });
|
|
459
|
+
surface.setEmotes(EMOTES, CHOICES);
|
|
460
|
+
surface.setEmotes(EMOTES, structuredClone(CHOICES));
|
|
461
|
+
surface.sitPrompt(null);
|
|
462
|
+
const before = posts.length;
|
|
463
|
+
surface.render();
|
|
464
|
+
assert.equal(posts.length, before);
|
|
465
|
+
dispatchUiEvent(EMOTE_ROOTS.emotes, 'emotes/emote#tap', {});
|
|
466
|
+
const ring = posts.length;
|
|
467
|
+
surface.render();
|
|
468
|
+
assert.equal(posts.length, ring, 'idle frames re-say setEmotes without a resend');
|
|
469
|
+
bands = BANDS.squeeze(VIEWS.portrait);
|
|
470
|
+
surface.render();
|
|
471
|
+
assert.equal(posts.at(-1), 'emotewheel');
|
|
472
|
+
surface.dispose();
|
|
473
|
+
resetUiTrees();
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// chrome.js with safe insets on, over a stand-in DOM that lays its absolute
|
|
477
|
+
// nodes out from their own CSS (right / bottom / width / height, env()
|
|
478
|
+
// insets, max and calc), so its safe layout moves them as it does on a
|
|
479
|
+
// phone. Returns the boxes the safe layout reports.
|
|
480
|
+
async function chromeSafeLayout(v, crowded) {
|
|
481
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
482
|
+
export async function resolve(specifier, context, next) {
|
|
483
|
+
if (specifier === 'castle-web-sdk') return { url: ${JSON.stringify(new URL('./fixtures/sdk-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
484
|
+
return next(specifier, context);
|
|
485
|
+
}`)}`);
|
|
486
|
+
const { makeChrome } = await import('../code/client/chrome.js');
|
|
487
|
+
const dom = fakeDom({ viewW: v.w, viewH: v.h });
|
|
488
|
+
globalThis.window.innerHeight = v.h;
|
|
489
|
+
const css = (value) => Function(`return (${String(value)
|
|
490
|
+
.replace(/env\(safe-area-inset-(\w+)\)/g, (_, side) => `${v.insets[side]}px`).replace(/(\d+(?:\.\d+)?)px/g, '$1')
|
|
491
|
+
.replace(/calc\(/g, '(').replace(/max\(/g, 'Math.max(').replace(/min\(/g, 'Math.min(')})`)();
|
|
492
|
+
const previous = globalThis.getComputedStyle;
|
|
493
|
+
globalThis.getComputedStyle = (el) => ({ ...el.styles, paddingLeft: `${v.insets.left}px`, paddingRight: `${v.insets.right}px`, paddingTop: `${v.insets.top}px`, paddingBottom: `${v.insets.bottom}px` });
|
|
494
|
+
try {
|
|
495
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, safeInsets: true });
|
|
496
|
+
chrome.setEmotes(EMOTES);
|
|
497
|
+
if (crowded) {
|
|
498
|
+
chrome.sitPrompt('Sit');
|
|
499
|
+
chrome.grabPrompt('Grab');
|
|
500
|
+
chrome.setSay({ reactions: ['๐'], phrases: [] });
|
|
501
|
+
chrome.nearPrompt('๏ผ Party ยท bo', () => {});
|
|
502
|
+
}
|
|
503
|
+
dom.made.find((n) => n.attrs['aria-label'] === 'Emote').handlers.pointerdown({ stopPropagation() {}, preventDefault() {} });
|
|
504
|
+
const row = dom.made.find((n) => n.attrs['aria-label'] === 'wave').parent;
|
|
505
|
+
// Five 44 px emoji, 6 px apart, 4 px of padding round them.
|
|
506
|
+
row.size = { w: 5 * 44 + 4 * 6 + 8, h: 52 };
|
|
507
|
+
for (const n of dom.made) {
|
|
508
|
+
n.getBoundingClientRect = function rect() {
|
|
509
|
+
const st = this.styles;
|
|
510
|
+
if (st.display === 'none' || st.position !== 'absolute') {return domRect({ left: 0, right: 0, top: 0, bottom: 0 });}
|
|
511
|
+
const { w, h } = this.size ?? { w: Number.parseFloat(st.width) || this.textContent.length * 7 + 20, h: Number.parseFloat(st.height) || 24 };
|
|
512
|
+
const x = st.right ? v.w - css(st.right) - w : st.left && !st.left.includes('%') && st.left !== 'auto' ? css(st.left) : 0;
|
|
513
|
+
const y = st.bottom ? v.h - css(st.bottom) - h : st.top ? css(st.top) : 0;
|
|
514
|
+
const [dx, dy] = (st.translate || '0 0').split(' ').map((n) => Number.parseFloat(n) || 0);
|
|
515
|
+
return domRect({ left: x + dx, right: x + w + dx, top: y + dy, bottom: y + h + dy });
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
const boxes = chrome.layout().boxes;
|
|
519
|
+
chrome.dispose();
|
|
520
|
+
return Object.fromEntries(boxes.map((b) => [b.id, b]));
|
|
521
|
+
} finally {
|
|
522
|
+
globalThis.getComputedStyle = previous;
|
|
523
|
+
delete globalThis.document;
|
|
524
|
+
delete globalThis.window;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
await test('safe insets: the row is where chrome.js\'s safe layout puts it, TECNO- and moto-sized, with or without the host\'s boxes', async () => {
|
|
529
|
+
const PHONES = {
|
|
530
|
+
tecno: { landscape: true, safeInsets: true, w: 806, h: 360, lift: 0, insets: { top: 0, right: 0, bottom: 0, left: 36 } },
|
|
531
|
+
moto: { landscape: true, safeInsets: true, w: 800, h: 360, lift: 0, insets: { top: 0, right: 32, bottom: 12, left: 0 } },
|
|
532
|
+
};
|
|
533
|
+
const ROW = { w: 252, h: 52 };
|
|
534
|
+
// A tree edge resolved at a view: n px, or [min, add] = max(min, inset + add).
|
|
535
|
+
const resolve = (value, inset) => (Array.isArray(value) ? Math.max(value[0], inset + value[1]) : value);
|
|
536
|
+
const rowBox = (tree, v) => {
|
|
537
|
+
const at = find(tree, 'row').at;
|
|
538
|
+
assert.equal(at.anchor, 'bottomRight');
|
|
539
|
+
const right = resolve(at.right, v.insets.right);
|
|
540
|
+
const bottom = resolve(at.bottom, v.insets.bottom);
|
|
541
|
+
return { x: v.w - right - ROW.w, y: v.h - bottom - ROW.h, w: ROW.w, h: ROW.h };
|
|
542
|
+
};
|
|
543
|
+
const pick = ({ x, y, w, h }) => ({ x, y, w, h });
|
|
544
|
+
for (const [name, view] of Object.entries(PHONES)) {
|
|
545
|
+
// Nothing in its way: the safe layout leaves the row on its own corner
|
|
546
|
+
// spot, which the tree draws with no boxes and with only the Emote
|
|
547
|
+
// button's (as a host's rail layout passes it) -- never the 184 px lane.
|
|
548
|
+
const clear = await chromeSafeLayout(view, false);
|
|
549
|
+
const emote = clear.emote;
|
|
550
|
+
for (const place of [{}, { emote }]) {
|
|
551
|
+
const tree = buildEmotes({ view, emotes: EMOTES, open: true, place }, noop);
|
|
552
|
+
assert.deepEqual(rowBox(tree, view), pick(clear.emotes), `${name} ${JSON.stringify(place)}`);
|
|
553
|
+
}
|
|
554
|
+
const lane = buildEmotes({ view: { ...view, safeInsets: false }, emotes: EMOTES, open: true, place: { emote } }, noop);
|
|
555
|
+
assert.equal(find(lane, 'row').at.right, Math.max(184, view.w - emote.x + 6), 'the non-safe lane is unchanged');
|
|
556
|
+
assert.notDeepEqual(rowBox(lane, view), pick(clear.emotes), `${name}: the lane is not where the safe layout puts it`);
|
|
557
|
+
// Crowded: the safe layout moves the row clear of the other controls;
|
|
558
|
+
// the host's box for it is where the tree draws it.
|
|
559
|
+
const crowded = await chromeSafeLayout(view, true);
|
|
560
|
+
const baseline = pick(clear.emotes);
|
|
561
|
+
assert.notDeepEqual(pick(crowded.emotes), baseline, `${name}: the crowded row moved`);
|
|
562
|
+
const placed = buildEmotes({ view, emotes: EMOTES, open: true, place: { emote: crowded.emote, row: crowded.emotes } }, noop);
|
|
563
|
+
assert.deepEqual(rowBox(placed, view), pick(crowded.emotes), `${name} crowded with the row's box`);
|
|
564
|
+
// Without the row's box, the row's own corner spot.
|
|
565
|
+
assert.deepEqual(rowBox(buildEmotes({ view, emotes: EMOTES, open: true, place: { emote: crowded.emote } }, noop), view), baseline);
|
|
566
|
+
assert.deepEqual(validate(placed, 'emotes'), []);
|
|
567
|
+
}
|
|
568
|
+
// Upright with safe insets: the row's own spot (80, lifted), not 8 px
|
|
569
|
+
// off the button's box; a row box is the host's; non-safe views ignore it.
|
|
570
|
+
const upright = { landscape: false, safeInsets: true, w: 390, h: 844, lift: 40 };
|
|
571
|
+
const box = { x: 318, y: 600, w: 52, h: 52 };
|
|
572
|
+
assert.deepEqual(find(buildEmotes({ view: upright, emotes: EMOTES, open: true, place: { emote: box } }, noop), 'row').at, { anchor: 'bottomRight', right: [80, 0], bottom: [186, 176] });
|
|
573
|
+
assert.deepEqual(find(buildEmotes({ view: upright, emotes: EMOTES, open: true, place: { row: { x: 50, y: 500, w: 252, h: 52 } } }, noop), 'row').at, { anchor: 'bottomRight', right: 88, bottom: 292 });
|
|
574
|
+
// The host's box also bounds the row's width, so a narrower box keeps it inside.
|
|
575
|
+
// Upright the row is fixed buttons in a plain row: no cap, which would only overflow it.
|
|
576
|
+
assert.equal(find(buildEmotes({ view: upright, emotes: EMOTES, open: true, place: { row: { x: 50, y: 500, w: 230, h: 52 } } }, noop), 'row').s.maxW, undefined);
|
|
577
|
+
const turned = { landscape: true, safeInsets: true, w: 806, h: 360 };
|
|
578
|
+
assert.deepEqual(find(buildEmotes({ view: turned, emotes: EMOTES, open: true, place: { row: { x: 500, y: 250, w: 230, h: 52 } } }, noop), 'row').s.maxW, [{ vw: 100, px: -156 }, { px: 222 }], 'turned, the outer width with its 4 px padding stays in the 230 px box');
|
|
579
|
+
assert.deepEqual(find(buildEmotes({ view: turned, emotes: EMOTES, open: true }, noop), 'row').s.maxW, [{ vw: 100, px: -156 }]);
|
|
580
|
+
const plain = { ...upright, safeInsets: false, lift: 0 };
|
|
581
|
+
assert.equal(
|
|
582
|
+
serialize(buildEmotes({ view: plain, emotes: EMOTES, open: true, place: { emote: box, row: { x: 1, y: 2, w: 3, h: 4 } } }, noop), 'emotes').json,
|
|
583
|
+
serialize(buildEmotes({ view: plain, emotes: EMOTES, open: true, place: { emote: box } }, noop), 'emotes').json,
|
|
584
|
+
);
|
|
585
|
+
// The surface takes the row's box through place().
|
|
586
|
+
resetUiTrees();
|
|
587
|
+
const roots = [];
|
|
588
|
+
setUiTreeSink((name, wire) => roots.push({ name, wire }), { dom: false });
|
|
589
|
+
const surface = makeEmoteSurface({ view: () => PHONES.tecno });
|
|
590
|
+
surface.setEmotes(EMOTES);
|
|
591
|
+
dispatchUiEvent('emotes', 'emotes/emote#tap', {});
|
|
592
|
+
surface.place({ emote: { x: 750, y: 256, w: 44, h: 44 }, row: { x: 486, y: 164, w: 252, h: 52 } });
|
|
593
|
+
assert.deepEqual(find(roots.filter((r) => r.name === 'emotes').at(-1).wire, 'row').at, { anchor: 'bottomRight', right: 68, bottom: 144 });
|
|
594
|
+
surface.dispose();
|
|
595
|
+
resetUiTrees();
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
await test('the surface loads and runs in a process that never had a DOM', () => {
|
|
599
|
+
const probe = `
|
|
600
|
+
if (globalThis.document || globalThis.window) throw new Error('a DOM');
|
|
601
|
+
const { setUiTreeSink, dispatchUiEvent } = await import(${JSON.stringify(new URL('../code/client/uiTree.js', import.meta.url).href)});
|
|
602
|
+
const { makeEmoteSurface } = await import(${JSON.stringify(new URL('../code/client/emoteSurface.js', import.meta.url).href)});
|
|
603
|
+
const seen = [];
|
|
604
|
+
setUiTreeSink((name, wire) => seen.push(name + ':' + (wire ? (wire.c ?? []).length : null)), { dom: false });
|
|
605
|
+
const surface = makeEmoteSurface({ view: () => ({ landscape: false, w: 390, h: 844 }) });
|
|
606
|
+
surface.onEmote((id, ground) => seen.push(id + (ground ? '!' : '')));
|
|
607
|
+
surface.setEmotes([['wave', 'w']], { basics: [['wave', 'w', 'Wave'], ['sit', 's', 'Sit']], more: [] });
|
|
608
|
+
dispatchUiEvent('emotes', 'emotes/emote#tap', {});
|
|
609
|
+
dispatchUiEvent('emotewheel', 'emotewheel/sheet/body/e:sit#tap', {});
|
|
610
|
+
surface.dispose();
|
|
611
|
+
console.log(seen.join(' '));
|
|
612
|
+
`;
|
|
613
|
+
assert.equal(execFileSync(process.execPath, ['--input-type=module', '-e', probe], { encoding: 'utf8' }).trim(), 'emotes:0 emotewheel:0 emotes:1 emotewheel:2 emotewheel:0 sit! emotes:null emotewheel:null');
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
console.log(`emote surface: ${passed} checks passed`);
|