castle-web-cli 0.4.239 → 0.4.241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +163 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +6 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +2 -0
- package/dist/platformDoc.js +3 -2
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +1 -0
- package/dist/roomLogs.js +30 -6
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +481 -57
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/padCues.js +11 -7
- package/kits/hub-game/code/client/padReadability.js +3 -3
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +72 -51
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +205 -25
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +35 -3
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +991 -72
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +14 -2
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/standing.js +7 -3
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +429 -55
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +956 -101
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +79 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +421 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +242 -3
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-role-client.mjs +2 -1
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-standing.mjs +135 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +36 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +59 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
// The quick chat surface (`code/client/quickChatSurface.js`) and its tree
|
|
2
|
+
// (`quickChatTree.js`): the 💬 button, its card and the feed of what was
|
|
3
|
+
// just said as the `quickchat` UI tree root, with no DOM, for a native host.
|
|
4
|
+
// Checks that the trees validate, portrait and landscape (the corner stack,
|
|
5
|
+
// a host's rail slot, the safe edges and the lock's lift); that bytes and
|
|
6
|
+
// binding ids do not move across rebuilds with fresh closures; and that every
|
|
7
|
+
// event dispatched as a host sends it reaches the right action: the button
|
|
8
|
+
// opening and shutting the card (Esc / Back too), a reaction and a phrase
|
|
9
|
+
// saying { r } and { p } with the chip sound, a typed line trimmed and said
|
|
10
|
+
// as { text } (a late or empty submit dropped, Esc shutting the card), typed
|
|
11
|
+
// chat off taking nothing, a feed line asking to be reported, Report, and
|
|
12
|
+
// Report & block only with moderation on; the Character sheet hiding the
|
|
13
|
+
// button, a list emptying the feed, new phrases dropping a typed line.
|
|
14
|
+
import assert from 'node:assert/strict';
|
|
15
|
+
import { execFileSync } from 'node:child_process';
|
|
16
|
+
import { readFileSync } from 'node:fs';
|
|
17
|
+
import { dispatchUiEvent, resetUiTrees, serialize, setUiTreeSink, validate } from '../code/client/uiTree.js';
|
|
18
|
+
import { buildQuickChat, chatLabel, chatPlaceholder, quickChatPlace, sayKey } from '../code/client/quickChatTree.js';
|
|
19
|
+
import { makeQuickChatSurface } from '../code/client/quickChatSurface.js';
|
|
20
|
+
|
|
21
|
+
let passed = 0;
|
|
22
|
+
const test = async (name, fn) => {
|
|
23
|
+
try {await fn();} catch (error) {error.message = `${name}: ${error.message}`; throw error;}
|
|
24
|
+
passed += 1;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// say.js's REACTIONS and a town's phrases (`makeSay().phrases()`), as the
|
|
28
|
+
// hub system hands them to `setSay`; the chat parts it builds.
|
|
29
|
+
const REACTIONS = ['👍', '😂', '❤️', '😮', '👋', '🎉'];
|
|
30
|
+
const TOWN = [['here', 'Over here!'], ['play', "Let's play…"], ['wait', 'Wait for me'], ['yes', 'Yes!'], ['no', 'Not now']];
|
|
31
|
+
const GAME = [['here', 'Over here!'], ['wait', 'Wait for me'], ['gg', 'Good game!'], ['again', 'Again?']];
|
|
32
|
+
const CHAT_ON = { input: true, note: 'Chat reaches amy, bo' };
|
|
33
|
+
const CHAT_OFF = { input: false, note: 'Chat is for players who follow each other.' };
|
|
34
|
+
const CUES_ON = { input: true, note: 'Chat reaches amy', placeholder: 'To your follows…', label: 'Message · only players you follow each other with' };
|
|
35
|
+
const CUES_OFF = { input: false, note: 'Typed chat is for friends who follow each other.', placeholder: 'Friends only', label: 'Typed chat is for friends who follow each other.' };
|
|
36
|
+
const SAY = { reactions: REACTIONS, phrases: TOWN, chat: CHAT_ON };
|
|
37
|
+
const FEED = [{ text: 'You: Over here!', id: null }, { text: 'amy: hi all', id: 'm1', userId: 'u1' }, { text: 'bo: hey', id: 'm2' }];
|
|
38
|
+
|
|
39
|
+
const VIEWS = {
|
|
40
|
+
portrait: { landscape: false, safeInsets: false, lift: 0, slot: null },
|
|
41
|
+
landscape: { landscape: true, safeInsets: false, lift: 0, slot: null },
|
|
42
|
+
};
|
|
43
|
+
const MORE_VIEWS = [
|
|
44
|
+
{ landscape: false, safeInsets: true, lift: 40, slot: null },
|
|
45
|
+
{ landscape: true, safeInsets: true, lift: 0, slot: null },
|
|
46
|
+
{ landscape: true, safeInsets: false, lift: 0, slot: { right: 12, bottom: 72, width: 44 } },
|
|
47
|
+
{ landscape: false, safeInsets: true, lift: 40, slot: { right: 12, bottom: 34, width: 52 } },
|
|
48
|
+
];
|
|
49
|
+
const FIELD = { value: '', ver: 0, focus: 0 };
|
|
50
|
+
const feedOf = (over = {}) => ({ lines: FEED, moderation: false, hidden: false, confirming: [], reported: [], ...over });
|
|
51
|
+
const stateOf = (view, over = {}) => ({ view, say: SAY, open: true, covered: false, field: FIELD, feed: feedOf(), ...over });
|
|
52
|
+
|
|
53
|
+
function at(tree, path) {
|
|
54
|
+
let node = tree;
|
|
55
|
+
for (const key of path.split('/').slice(1)) {
|
|
56
|
+
node = node?.c?.find((child) => child.k === key);
|
|
57
|
+
}
|
|
58
|
+
return node ?? null;
|
|
59
|
+
}
|
|
60
|
+
function find(tree, k) {
|
|
61
|
+
if (!tree) {return null;}
|
|
62
|
+
if (tree.k === k) {return tree;}
|
|
63
|
+
for (const child of tree.c ?? []) {
|
|
64
|
+
const hit = find(child, k);
|
|
65
|
+
if (hit) {return hit;}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const words = (node) => node?.text ?? node?.c?.find((child) => child.t === 'text' && !child.k)?.text;
|
|
70
|
+
const ON = () => ({ toggle() {}, close() {}, react() {}, phrase() {}, input() {}, submit() {}, send() {}, focus() {}, blur() {}, ask() {}, report() {}, block() {}, unask() {} });
|
|
71
|
+
|
|
72
|
+
function makeHost(view = VIEWS.portrait) {
|
|
73
|
+
resetUiTrees();
|
|
74
|
+
const host = { roots: [], said: [], chips: 0, opens: [], reports: [], blocks: [], view };
|
|
75
|
+
setUiTreeSink((name, wire, handlers) => {host.roots.push({ name, wire, handlers });}, { dom: false });
|
|
76
|
+
host.surface = makeQuickChatSurface({
|
|
77
|
+
view: () => host.view,
|
|
78
|
+
onSay: (what) => host.said.push(what),
|
|
79
|
+
onChip: () => {host.chips += 1;},
|
|
80
|
+
onOpen: (open) => host.opens.push(open),
|
|
81
|
+
onReport: (line) => host.reports.push(line.id),
|
|
82
|
+
onBlock: (line) => host.blocks.push(line.id),
|
|
83
|
+
});
|
|
84
|
+
host.last = () => host.roots.filter((r) => r.name === 'quickchat').at(-1) ?? null;
|
|
85
|
+
host.wire = () => host.last()?.wire ?? null;
|
|
86
|
+
host.ids = () => [...(host.last()?.handlers.keys() ?? [])];
|
|
87
|
+
host.event = (id, payload = {}) => dispatchUiEvent('quickchat', id, payload);
|
|
88
|
+
host.field = () => find(host.wire(), 'message');
|
|
89
|
+
host.type = (text) => host.event('quickchat/card/line/message#input', { text, base: host.field().ver, composing: false });
|
|
90
|
+
return host;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await test('trees validate: closed, open, chat on, off and absent, cues, covered, the feed, portrait and landscape', () => {
|
|
94
|
+
for (const view of [...Object.values(VIEWS), ...MORE_VIEWS]) {
|
|
95
|
+
const states = [
|
|
96
|
+
stateOf(view, { say: null, open: false, feed: feedOf({ lines: [] }) }),
|
|
97
|
+
stateOf(view, { open: false }),
|
|
98
|
+
stateOf(view),
|
|
99
|
+
stateOf(view, { say: { ...SAY, chat: CHAT_OFF } }),
|
|
100
|
+
stateOf(view, { say: { ...SAY, chat: null } }),
|
|
101
|
+
stateOf(view, { say: { ...SAY, phrases: GAME, chat: CUES_ON } }),
|
|
102
|
+
stateOf(view, { say: { ...SAY, chat: CUES_OFF } }),
|
|
103
|
+
stateOf(view, { covered: true }),
|
|
104
|
+
stateOf(view, { feed: feedOf({ confirming: ['m1', 'm2'], moderation: true }) }),
|
|
105
|
+
stateOf(view, { feed: feedOf({ reported: ['m1'], hidden: false }) }),
|
|
106
|
+
stateOf(view, { feed: feedOf({ hidden: true }) }),
|
|
107
|
+
];
|
|
108
|
+
for (const state of states) {
|
|
109
|
+
assert.deepEqual(validate(buildQuickChat(state, ON()), 'quickchat'), [], JSON.stringify(state));
|
|
110
|
+
assert.deepEqual(validate(buildQuickChat(state), 'quickchat'), []);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await test('bytes and binding ids do not move across rebuilds with fresh closures', () => {
|
|
116
|
+
for (const view of [...Object.values(VIEWS), ...MORE_VIEWS]) {
|
|
117
|
+
for (const state of [stateOf(view), stateOf(view, { feed: feedOf({ confirming: ['m1'], moderation: true }) }), stateOf(view, { open: false })]) {
|
|
118
|
+
const fresh = (n) => Object.fromEntries(Object.keys(ON()).map((name) => [name, () => n]));
|
|
119
|
+
const one = serialize(buildQuickChat(state, fresh(1)), 'quickchat');
|
|
120
|
+
const two = serialize(buildQuickChat(state, fresh(2)), 'quickchat');
|
|
121
|
+
assert.equal(one.json, two.json);
|
|
122
|
+
assert.deepEqual([...one.handlers.keys()], [...two.handlers.keys()]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const ids = [...serialize(buildQuickChat(stateOf(VIEWS.portrait), ON()), 'quickchat').handlers.keys()];
|
|
126
|
+
assert.deepEqual(ids, [
|
|
127
|
+
'quickchat#cancel',
|
|
128
|
+
'quickchat/feed/m:m1#tap', 'quickchat/feed/m:m2#tap',
|
|
129
|
+
'quickchat/button#tap',
|
|
130
|
+
...REACTIONS.map((_, r) => `quickchat/card/reactions/r${r}#tap`),
|
|
131
|
+
...TOWN.map(([id]) => `quickchat/card/phrases/p:${id}#tap`),
|
|
132
|
+
'quickchat/card/line/message#input', 'quickchat/card/line/message#submit', 'quickchat/card/line/message#cancel', 'quickchat/card/line/message#focus', 'quickchat/card/line/message#blur',
|
|
133
|
+
'quickchat/card/line/send#tap',
|
|
134
|
+
]);
|
|
135
|
+
// A shut card binds no cancel; typed chat off binds no field or Send.
|
|
136
|
+
const shut = [...serialize(buildQuickChat(stateOf(VIEWS.portrait, { open: false }), ON()), 'quickchat').handlers.keys()];
|
|
137
|
+
assert.equal(shut.includes('quickchat#cancel'), false);
|
|
138
|
+
const off = [...serialize(buildQuickChat(stateOf(VIEWS.portrait, { say: { ...SAY, chat: CHAT_OFF } }), ON()), 'quickchat').handlers.keys()];
|
|
139
|
+
assert.equal(off.some((id) => id.includes('/line/')), false);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
await test('the DOM\'s words, labels, sizes and places, portrait and landscape', () => {
|
|
143
|
+
const portrait = buildQuickChat(stateOf(VIEWS.portrait));
|
|
144
|
+
const button = at(portrait, 'quickchat/button');
|
|
145
|
+
assert.deepEqual([button.label, words(button), button.s.w, button.s.h, button.s.radius, button.s.size, button.s.bg], ['Quick chat', '💬', 52, 52, 26, 22, 'copy']);
|
|
146
|
+
assert.deepEqual(button.at, { anchor: 'bottomRight', right: 20, bottom: [206, 196] });
|
|
147
|
+
const card = at(portrait, 'quickchat/card');
|
|
148
|
+
assert.equal(card.t, 'column');
|
|
149
|
+
assert.deepEqual(card.at, { anchor: 'bottomRight', right: 80, bottom: [146, 136], ime: true });
|
|
150
|
+
assert.deepEqual(card.s.w, [{ vw: 70 }, { px: 236 }]);
|
|
151
|
+
assert.equal(card.s.maxH, undefined);
|
|
152
|
+
assert.deepEqual([card.s.pad, card.s.gap, card.s.radius, card.s.bg, card.s.shadow], [8, 6, 14, 'card', 'card']);
|
|
153
|
+
assert.deepEqual(at(portrait, 'quickchat/card/reactions').c.map((b) => [b.label, words(b), b.s.w]), REACTIONS.map((e) => [`React ${e}`, e, 34]));
|
|
154
|
+
assert.deepEqual(at(portrait, 'quickchat/card/phrases').c.map((b) => [b.k, words(b), b.s.weight]), TOWN.map(([id, w]) => [`p:${id}`, w, 600]));
|
|
155
|
+
assert.equal(at(portrait, 'quickchat/card/note').text, 'Chat reaches amy, bo');
|
|
156
|
+
const field = at(portrait, 'quickchat/card/line/message');
|
|
157
|
+
assert.deepEqual([field.ph, field.label, field.max, field.maxUnit, field.enter, field.disabled, field.name], ['Message…', undefined, 200, 'utf16', 'send', false, 'message']);
|
|
158
|
+
assert.equal(words(at(portrait, 'quickchat/card/line/send')), 'Send');
|
|
159
|
+
assert.equal(at(portrait, 'quickchat/card/line').s.opacity, 1);
|
|
160
|
+
// Feed: bottom left, a plain line, two reportable lines.
|
|
161
|
+
const feed = at(portrait, 'quickchat/feed');
|
|
162
|
+
assert.deepEqual(feed.at, { anchor: 'bottomLeft', left: 10, bottom: [70, 60] });
|
|
163
|
+
assert.deepEqual(feed.c.map((n) => [n.t, n.k, words(n)]), [['text', 'l0', 'You: Over here!'], ['button', 'm:m1', 'amy: hi all'], ['button', 'm:m2', 'bo: hey']]);
|
|
164
|
+
|
|
165
|
+
// Landscape: a 44 px button; the card scrolls under its height cap.
|
|
166
|
+
const landscape = buildQuickChat(stateOf(VIEWS.landscape));
|
|
167
|
+
assert.deepEqual([at(landscape, 'quickchat/button').s.w, at(landscape, 'quickchat/button').at.right], [44, 18]);
|
|
168
|
+
const lcard = at(landscape, 'quickchat/card');
|
|
169
|
+
assert.deepEqual([lcard.t, lcard.axis, lcard.at.right], ['scroll', 'y', 68]);
|
|
170
|
+
assert.deepEqual(lcard.s.maxH, [{ dvh: 100, px: -24, safe: 'tb' }]);
|
|
171
|
+
// A host's rail slot: the button in it, the card left of the action lane.
|
|
172
|
+
const slotted = buildQuickChat(stateOf(MORE_VIEWS[2]));
|
|
173
|
+
assert.deepEqual(at(slotted, 'quickchat/button').at, { anchor: 'bottomRight', right: 12, bottom: 72 });
|
|
174
|
+
assert.deepEqual(at(slotted, 'quickchat/card').at, { anchor: 'bottomRight', right: 184, bottom: 72, ime: true });
|
|
175
|
+
assert.deepEqual(at(slotted, 'quickchat/card').s.maxH, [{ dvh: 100, px: -84, safe: 't' }], 'the measured slot already clears the bottom safe area');
|
|
176
|
+
assert.equal(quickChatPlace({ landscape: true, slot: { right: 200, bottom: 10, width: 44 } }).card.right, 250);
|
|
177
|
+
assert.equal(quickChatPlace({ landscape: false, slot: { right: 200, bottom: 10, width: 44 } }).button.right, 20, 'a slot is a landscape rail\'s');
|
|
178
|
+
// Safe edges and the lock's lift.
|
|
179
|
+
const safe = buildQuickChat(stateOf(MORE_VIEWS[0]));
|
|
180
|
+
assert.deepEqual(at(safe, 'quickchat/button').at, { anchor: 'bottomRight', right: [20, 0], bottom: [246, 236] });
|
|
181
|
+
assert.deepEqual(at(safe, 'quickchat/card').at, { anchor: 'bottomRight', right: [80, 0], bottom: [186, 176], ime: true });
|
|
182
|
+
assert.deepEqual(at(safe, 'quickchat/feed').at.left, [10, 0]);
|
|
183
|
+
// Upright in a safe-inset place, the host's box for the button in the
|
|
184
|
+
// safe layout's corner column: the button stands there exactly (the box
|
|
185
|
+
// already clears the safe area and the lift); the card keeps its own
|
|
186
|
+
// corner spot, which the safe layout only moves clear of the controls.
|
|
187
|
+
const column = MORE_VIEWS[3];
|
|
188
|
+
const stacked = buildQuickChat(stateOf(column));
|
|
189
|
+
assert.deepEqual(at(stacked, 'quickchat/button').at, { anchor: 'bottomRight', right: 12, bottom: 34 });
|
|
190
|
+
assert.deepEqual(at(stacked, 'quickchat/card').at, at(safe, 'quickchat/card').at);
|
|
191
|
+
assert.equal(at(stacked, 'quickchat/card').t, 'column');
|
|
192
|
+
assert.equal(at(stacked, 'quickchat/card').s.maxH, undefined);
|
|
193
|
+
assert.deepEqual(at(stacked, 'quickchat/button').s, at(safe, 'quickchat/button').s, 'the same 52 px button');
|
|
194
|
+
// Without a slot it is the corner spot; turned, a slot is still the rail's.
|
|
195
|
+
assert.equal(serialize(buildQuickChat(stateOf({ ...column, slot: null }))).json, serialize(safe).json);
|
|
196
|
+
assert.deepEqual(quickChatPlace({ landscape: true, safeInsets: true, slot: { right: 12, bottom: 72, width: 44 } }).card.right, 184);
|
|
197
|
+
// Turned in a safe-inset place, the host's box already clears the safe
|
|
198
|
+
// area: its bottom is taken as it is, not lifted by the inset again.
|
|
199
|
+
const turnedSafe = quickChatPlace({ landscape: true, safeInsets: true, slot: { right: 12, bottom: 42, width: 44 } });
|
|
200
|
+
assert.equal(turnedSafe.button.bottom, 42);
|
|
201
|
+
assert.equal(turnedSafe.card.bottom, 42);
|
|
202
|
+
assert.equal(quickChatPlace({ landscape: true, safeInsets: false, slot: { right: 12, bottom: 42, width: 44 } }).button.bottom, 42, 'a measured box is taken as it is in any place');
|
|
203
|
+
|
|
204
|
+
// Cues: the field's own words and label; chat off greys the line.
|
|
205
|
+
const cues = buildQuickChat(stateOf(VIEWS.portrait, { say: { ...SAY, chat: CUES_OFF } }));
|
|
206
|
+
const off = at(cues, 'quickchat/card/line/message');
|
|
207
|
+
assert.deepEqual([off.ph, off.label, off.disabled, off.on], ['Friends only', CUES_OFF.label, true, undefined]);
|
|
208
|
+
assert.equal(at(cues, 'quickchat/card/line').s.opacity, 0.5);
|
|
209
|
+
assert.equal(at(cues, 'quickchat/card/line/send').disabled, true);
|
|
210
|
+
assert.deepEqual([chatPlaceholder(CHAT_ON), chatLabel(CHAT_ON), chatLabel({ placeholder: 'P' })], ['Message…', undefined, 'P']);
|
|
211
|
+
// No chat part: no note, no field.
|
|
212
|
+
const none = buildQuickChat(stateOf(VIEWS.portrait, { say: { ...SAY, chat: null } }));
|
|
213
|
+
assert.deepEqual(at(none, 'quickchat/card').c.map((n) => n.k), ['reactions', 'phrases']);
|
|
214
|
+
// Shut, covered, absent.
|
|
215
|
+
assert.equal(at(buildQuickChat(stateOf(VIEWS.portrait, { open: false })), 'quickchat/card'), null);
|
|
216
|
+
const covered = buildQuickChat(stateOf(VIEWS.portrait, { covered: true }));
|
|
217
|
+
assert.deepEqual([at(covered, 'quickchat/button').s.hidden, at(covered, 'quickchat/button').on, at(covered, 'quickchat/card')], [true, undefined, null]);
|
|
218
|
+
assert.deepEqual(buildQuickChat(stateOf(VIEWS.portrait, { say: null, feed: feedOf({ lines: [] }) })).c, undefined);
|
|
219
|
+
// Confirming a line, with and without moderation.
|
|
220
|
+
const asking = buildQuickChat(stateOf(VIEWS.portrait, { feed: feedOf({ confirming: ['m1', 'm2'], moderation: true }) }));
|
|
221
|
+
assert.deepEqual(find(asking, 'm:m1').c.map((n) => [n.k, words(n)]), [['ask', 'Report this message?'], ['report', 'Report'], ['block', 'Report & block'], ['cancel', 'Cancel']]);
|
|
222
|
+
assert.deepEqual(find(asking, 'm:m2').c.map((n) => n.k), ['ask', 'report', 'cancel'], 'a line naming no user offers no block');
|
|
223
|
+
const plain = buildQuickChat(stateOf(VIEWS.portrait, { feed: feedOf({ confirming: ['m1'] }) }));
|
|
224
|
+
assert.deepEqual(find(plain, 'm:m1').c.map((n) => n.k), ['ask', 'report', 'cancel']);
|
|
225
|
+
assert.equal(at(buildQuickChat(stateOf(VIEWS.portrait, { feed: feedOf({ hidden: true }) })), 'quickchat/feed'), null);
|
|
226
|
+
assert.deepEqual(at(buildQuickChat(stateOf(VIEWS.portrait, { feed: feedOf({ reported: ['m1'] }) })), 'quickchat/feed').c.map((n) => n.k), ['l0', 'm:m2']);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
await test('the words and sizes are chrome.js\'s', () => {
|
|
230
|
+
const chrome = readFileSync(new URL('../code/client/chrome.js', import.meta.url), 'utf8');
|
|
231
|
+
for (const piece of [
|
|
232
|
+
"sayButton.setAttribute('aria-label', 'Quick chat')", "sayButton.textContent = '💬'", "width: 'min(70vw, 236px)'",
|
|
233
|
+
"button.setAttribute('aria-label', `React ${emoji}`)", "input.maxLength = 200", "chat.placeholder ?? 'Message…'",
|
|
234
|
+
"'Report this message?'", "'Report & block'", "right: edge('right', 80), bottom: 'max(146px, calc(env(safe-area-inset-bottom) + 136px))'",
|
|
235
|
+
"right: edge('right', 20), bottom: 'max(206px, calc(env(safe-area-inset-bottom) + 196px))'", "{ right: edge('right', 68), maxHeight: 'calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))', overflowY: 'auto' }",
|
|
236
|
+
"left: edge('left', 10), bottom: 'max(70px, calc(env(safe-area-inset-bottom) + 60px))', maxWidth: '62vw'",
|
|
237
|
+
"const key = `${say.reactions.join('')}|${say.phrases.map(([id]) => id).join(',')}|${chat ? (chat.input ? 1 : 0) : '-'}`;",
|
|
238
|
+
]) {
|
|
239
|
+
assert(chrome.includes(piece), piece);
|
|
240
|
+
}
|
|
241
|
+
assert.equal(sayKey(SAY), `${REACTIONS.join('')}|here,play,wait,yes,no|1`);
|
|
242
|
+
assert.equal(sayKey({ ...SAY, chat: null }), `${REACTIONS.join('')}|here,play,wait,yes,no|-`);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
await test('events: the button opens and shuts the card; Back shuts it; a reaction and a phrase say { r } and { p }', () => {
|
|
246
|
+
for (const view of Object.values(VIEWS)) {
|
|
247
|
+
const host = makeHost(view);
|
|
248
|
+
assert.equal(host.wire().c, undefined, 'nothing to offer, nothing drawn');
|
|
249
|
+
host.surface.setSay(SAY);
|
|
250
|
+
assert.equal(at(host.wire(), 'quickchat/card'), null);
|
|
251
|
+
assert.equal(host.event('quickchat/button#tap'), true);
|
|
252
|
+
assert.equal(host.surface.isOpen(), true);
|
|
253
|
+
assert.notEqual(at(host.wire(), 'quickchat/card'), null);
|
|
254
|
+
host.event('quickchat/button#tap');
|
|
255
|
+
assert.equal(host.surface.isOpen(), false);
|
|
256
|
+
assert.equal(host.event('quickchat#cancel'), false, 'a shut card binds no cancel');
|
|
257
|
+
host.event('quickchat/button#tap');
|
|
258
|
+
assert.equal(host.event('quickchat#cancel'), true);
|
|
259
|
+
assert.equal(host.surface.isOpen(), false);
|
|
260
|
+
// A reaction: the card shuts, the chip sounds, { r } is said.
|
|
261
|
+
host.event('quickchat/button#tap');
|
|
262
|
+
host.event('quickchat/card/reactions/r4#tap');
|
|
263
|
+
assert.equal(host.surface.isOpen(), false);
|
|
264
|
+
// A phrase: "Let's play…" says { p: 'play' }; the place adds the door
|
|
265
|
+
// the speaker stands by to what it tells everyone (`hub-said`).
|
|
266
|
+
host.event('quickchat/button#tap');
|
|
267
|
+
host.event('quickchat/card/phrases/p:play#tap');
|
|
268
|
+
assert.equal(host.event('quickchat/card/phrases/p:here#tap'), false, 'the shut card\'s buttons are gone');
|
|
269
|
+
assert.deepEqual(host.said, [{ r: 4 }, { p: 'play' }]);
|
|
270
|
+
assert.equal(host.chips, 2);
|
|
271
|
+
assert.deepEqual(host.opens, [true, false, true, false, true, false, true, false]);
|
|
272
|
+
// A game's phrases.
|
|
273
|
+
host.surface.setSay({ ...SAY, phrases: GAME });
|
|
274
|
+
host.event('quickchat/button#tap');
|
|
275
|
+
assert.equal(host.event('quickchat/card/phrases/p:play#tap'), false);
|
|
276
|
+
host.event('quickchat/card/phrases/p:gg#tap');
|
|
277
|
+
assert.deepEqual(host.said.at(-1), { p: 'gg' });
|
|
278
|
+
// Nothing offered: the button goes and an open card shuts.
|
|
279
|
+
host.event('quickchat/button#tap');
|
|
280
|
+
host.surface.setSay(null);
|
|
281
|
+
assert.equal(host.surface.isOpen(), false);
|
|
282
|
+
assert.equal(at(host.wire(), 'quickchat/button'), null);
|
|
283
|
+
host.surface.dispose();
|
|
284
|
+
assert.equal(host.wire(), null);
|
|
285
|
+
resetUiTrees();
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
await test('events: a typed line is trimmed and said as { text }; late, empty and cancelled ones are not', () => {
|
|
290
|
+
for (const view of Object.values(VIEWS)) {
|
|
291
|
+
const host = makeHost(view);
|
|
292
|
+
host.surface.setSay(SAY);
|
|
293
|
+
host.event('quickchat/button#tap');
|
|
294
|
+
host.event('quickchat/card/line/message#focus');
|
|
295
|
+
assert.equal(host.surface.chatFocused(), true);
|
|
296
|
+
// Enter with only spaces: nothing.
|
|
297
|
+
host.type(' ');
|
|
298
|
+
host.event('quickchat/card/line/message#submit', { text: ' ', base: host.field().ver });
|
|
299
|
+
assert.equal(host.surface.isOpen(), true);
|
|
300
|
+
// A submit from before a reset (an older version) is dropped.
|
|
301
|
+
host.event('quickchat/card/line/message#submit', { text: 'old', base: host.field().ver - 1 });
|
|
302
|
+
host.event('quickchat/card/line/message#submit', { text: 'no version' });
|
|
303
|
+
assert.deepEqual(host.said, []);
|
|
304
|
+
// Enter: trimmed, the field emptied (its version moves) and blurred, the card shut.
|
|
305
|
+
const ver = host.field().ver;
|
|
306
|
+
host.type(' hello there ');
|
|
307
|
+
assert.equal(host.event('quickchat/card/line/message#submit', { text: ' hello there ', base: ver }), true);
|
|
308
|
+
assert.deepEqual(host.said, [{ text: 'hello there' }]);
|
|
309
|
+
assert.equal(host.surface.isOpen(), false);
|
|
310
|
+
assert.equal(host.surface.chatFocused(), false);
|
|
311
|
+
assert.equal(host.chips, 0, 'a typed line is not a chip');
|
|
312
|
+
// Send: the words as typed.
|
|
313
|
+
host.event('quickchat/button#tap');
|
|
314
|
+
// Sent (a new version), then opened (another).
|
|
315
|
+
assert.deepEqual([host.field().value, host.field().ver], ['', ver + 2]);
|
|
316
|
+
assert(host.field().focus < 0, 'the field was blurred');
|
|
317
|
+
host.type('second');
|
|
318
|
+
host.event('quickchat/card/line/send#tap');
|
|
319
|
+
assert.deepEqual(host.said.at(-1), { text: 'second' });
|
|
320
|
+
// Esc in the field shuts the card; what was typed is there again on reopen.
|
|
321
|
+
host.event('quickchat/button#tap');
|
|
322
|
+
host.type('half a thought');
|
|
323
|
+
host.event('quickchat/card/line/message#cancel');
|
|
324
|
+
assert.equal(host.surface.isOpen(), false);
|
|
325
|
+
host.event('quickchat/button#tap');
|
|
326
|
+
assert.equal(host.field().value, 'half a thought');
|
|
327
|
+
// New phrases rebuild the card: the typed line goes (a new version).
|
|
328
|
+
const before = host.field().ver;
|
|
329
|
+
host.surface.setSay({ ...SAY, phrases: GAME });
|
|
330
|
+
assert.deepEqual([host.field().value, host.field().ver], ['', before + 1]);
|
|
331
|
+
host.event('quickchat/card/line/send#tap');
|
|
332
|
+
// A new note only (whom chat reaches) keeps it.
|
|
333
|
+
host.type('kept');
|
|
334
|
+
host.surface.setSay({ ...SAY, phrases: GAME, chat: { ...CHAT_ON, note: 'Chat reaches amy' } });
|
|
335
|
+
assert.equal(at(host.wire(), 'quickchat/card/note').text, 'Chat reaches amy');
|
|
336
|
+
assert.equal(host.field().ver, before + 1);
|
|
337
|
+
host.event('quickchat/card/line/send#tap');
|
|
338
|
+
assert.deepEqual(host.said, [{ text: 'hello there' }, { text: 'second' }, { text: 'kept' }]);
|
|
339
|
+
host.surface.dispose();
|
|
340
|
+
resetUiTrees();
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
await test('events: a reopened card takes no submit or input queued from an earlier opening', () => {
|
|
345
|
+
for (const view of Object.values(VIEWS)) {
|
|
346
|
+
const host = makeHost(view);
|
|
347
|
+
host.surface.setSay(SAY);
|
|
348
|
+
host.event('quickchat/button#tap');
|
|
349
|
+
const first = host.field().ver;
|
|
350
|
+
host.type('old words');
|
|
351
|
+
host.event('quickchat/card/line/message#cancel');
|
|
352
|
+
host.event('quickchat/button#tap');
|
|
353
|
+
// Opening again: a new version, the draft kept.
|
|
354
|
+
assert.deepEqual([host.field().value, host.field().ver], ['old words', first + 1]);
|
|
355
|
+
host.type('old words, then more');
|
|
356
|
+
// A submit and an input from the first opening land late: dropped.
|
|
357
|
+
assert.equal(host.event('quickchat/card/line/message#submit', { text: 'old words', base: first }), true);
|
|
358
|
+
host.event('quickchat/card/line/message#input', { text: 'stale', base: first });
|
|
359
|
+
assert.deepEqual(host.said, []);
|
|
360
|
+
assert.equal(host.surface.isOpen(), true);
|
|
361
|
+
assert.equal(host.field().ver, first + 1, 'the draft was not cleared');
|
|
362
|
+
host.event('quickchat/card/line/send#tap');
|
|
363
|
+
assert.deepEqual(host.said, [{ text: 'old words, then more' }]);
|
|
364
|
+
host.surface.dispose();
|
|
365
|
+
resetUiTrees();
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
await test('events: a card hidden and offered again with new phrases or chat empties the field; the same offer keeps it', () => {
|
|
370
|
+
for (const view of Object.values(VIEWS)) {
|
|
371
|
+
const host = makeHost(view);
|
|
372
|
+
host.surface.setSay(SAY);
|
|
373
|
+
host.event('quickchat/button#tap');
|
|
374
|
+
host.type('kept across a hide');
|
|
375
|
+
// Hidden, then the same card: the draft is still there.
|
|
376
|
+
host.surface.setSay(null);
|
|
377
|
+
host.surface.setSay(SAY);
|
|
378
|
+
host.event('quickchat/button#tap');
|
|
379
|
+
assert.equal(host.field().value, 'kept across a hide');
|
|
380
|
+
// Hidden, then new phrases: the DOM's rebuilt card has an empty field.
|
|
381
|
+
const ver = host.field().ver;
|
|
382
|
+
host.surface.setSay(null);
|
|
383
|
+
host.surface.setSay({ ...SAY, phrases: GAME });
|
|
384
|
+
assert.deepEqual([host.field()?.value ?? null, host.surface.isOpen()], [null, false]);
|
|
385
|
+
host.event('quickchat/button#tap');
|
|
386
|
+
assert.equal(host.field().value, '');
|
|
387
|
+
assert(host.field().ver > ver + 1, 'a new version for the new card');
|
|
388
|
+
assert.equal(host.event('quickchat/card/line/send#tap'), true);
|
|
389
|
+
assert.deepEqual(host.said, [], 'nothing typed, nothing said');
|
|
390
|
+
// Hidden, then chat no longer usable: emptied too.
|
|
391
|
+
host.type('typed before chat went');
|
|
392
|
+
host.surface.setSay(null);
|
|
393
|
+
host.surface.setSay({ ...SAY, phrases: GAME, chat: CHAT_OFF });
|
|
394
|
+
host.surface.setSay({ ...SAY, phrases: GAME });
|
|
395
|
+
host.event('quickchat/button#tap');
|
|
396
|
+
assert.equal(host.field().value, '');
|
|
397
|
+
host.surface.dispose();
|
|
398
|
+
resetUiTrees();
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
await test('events: typed chat off takes nothing, the field still shown with why', () => {
|
|
403
|
+
for (const view of Object.values(VIEWS)) {
|
|
404
|
+
const host = makeHost(view);
|
|
405
|
+
host.surface.setSay({ ...SAY, chat: CUES_OFF });
|
|
406
|
+
host.event('quickchat/button#tap');
|
|
407
|
+
assert.equal(host.field().disabled, true);
|
|
408
|
+
assert.equal(host.field().ph, 'Friends only');
|
|
409
|
+
assert.equal(host.event('quickchat/card/line/message#submit', { text: 'hi', base: host.field().ver }), false);
|
|
410
|
+
assert.equal(host.event('quickchat/card/line/send#tap'), false);
|
|
411
|
+
// Chat coming on rebuilds the card with a live field.
|
|
412
|
+
host.surface.setSay({ ...SAY, chat: CUES_ON });
|
|
413
|
+
assert.equal(host.field().disabled, false);
|
|
414
|
+
assert.equal(host.field().label, CUES_ON.label);
|
|
415
|
+
host.type('now it works');
|
|
416
|
+
host.event('quickchat/card/line/send#tap');
|
|
417
|
+
assert.deepEqual(host.said, [{ text: 'now it works' }]);
|
|
418
|
+
host.surface.dispose();
|
|
419
|
+
resetUiTrees();
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
await test('events: a feed line asks to be reported; Report; Report & block only with moderation on', () => {
|
|
424
|
+
for (const view of Object.values(VIEWS)) {
|
|
425
|
+
const host = makeHost(view);
|
|
426
|
+
host.surface.setFeed(FEED);
|
|
427
|
+
// Moderation off.
|
|
428
|
+
assert.equal(host.event('quickchat/feed/l0#tap'), false, 'a line of no message takes no tap');
|
|
429
|
+
host.event('quickchat/feed/m:m1#tap');
|
|
430
|
+
assert.deepEqual(find(host.wire(), 'm:m1').c.map((n) => n.k), ['ask', 'report', 'cancel']);
|
|
431
|
+
assert.equal(host.event('quickchat/feed/m:m1/block#tap'), false);
|
|
432
|
+
// Cancel: the feed as it was.
|
|
433
|
+
host.event('quickchat/feed/m:m1/cancel#tap');
|
|
434
|
+
assert.equal(find(host.wire(), 'm:m1').t, 'button');
|
|
435
|
+
// Report: the line goes, the host reports it.
|
|
436
|
+
host.event('quickchat/feed/m:m1#tap');
|
|
437
|
+
host.event('quickchat/feed/m:m1/report#tap');
|
|
438
|
+
assert.deepEqual(host.reports, ['m1']);
|
|
439
|
+
assert.equal(find(host.wire(), 'm:m1'), null);
|
|
440
|
+
// Moderation on: the feed is drawn afresh (the reported line is back
|
|
441
|
+
// while it is still in the feed, as the DOM's rebuild brings it back).
|
|
442
|
+
host.surface.setChatModeration(true);
|
|
443
|
+
host.event('quickchat/feed/m:m1#tap');
|
|
444
|
+
host.event('quickchat/feed/m:m1/block#tap');
|
|
445
|
+
assert.deepEqual(host.blocks, ['m1']);
|
|
446
|
+
host.event('quickchat/feed/m:m2#tap');
|
|
447
|
+
assert.equal(find(find(host.wire(), 'm:m2'), 'block'), null, 'a line naming no user offers no block');
|
|
448
|
+
// The blocked user's lines leave the feed (the hub system's hideUser).
|
|
449
|
+
host.surface.setFeed(FEED.filter((line) => line.userId !== 'u1'));
|
|
450
|
+
assert.deepEqual(at(host.wire(), 'quickchat/feed').c.map((n) => n.k), ['l0', 'm:m2']);
|
|
451
|
+
assert.equal(find(host.wire(), 'm:m2').t, 'button', 'a changed feed asks nothing');
|
|
452
|
+
// Moderation off again: no block.
|
|
453
|
+
host.surface.setFeed(FEED);
|
|
454
|
+
host.surface.setChatModeration(false);
|
|
455
|
+
host.event('quickchat/feed/m:m1#tap');
|
|
456
|
+
assert.equal(host.event('quickchat/feed/m:m1/block#tap'), false);
|
|
457
|
+
assert.deepEqual(host.blocks, ['m1']);
|
|
458
|
+
// A Doors or People list empties the feed.
|
|
459
|
+
host.surface.cover({ lists: true });
|
|
460
|
+
assert.equal(at(host.wire(), 'quickchat/feed'), null);
|
|
461
|
+
host.surface.cover({ lists: false });
|
|
462
|
+
assert.equal(find(host.wire(), 'm:m1').t, 'button');
|
|
463
|
+
host.surface.dispose();
|
|
464
|
+
resetUiTrees();
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
await test('the Character sheet hides the button and shuts the card', () => {
|
|
469
|
+
const host = makeHost();
|
|
470
|
+
host.surface.setSay(SAY);
|
|
471
|
+
host.event('quickchat/button#tap');
|
|
472
|
+
host.surface.cover({ picker: true });
|
|
473
|
+
assert.equal(host.surface.isOpen(), false);
|
|
474
|
+
assert.equal(at(host.wire(), 'quickchat/button').s.hidden, true);
|
|
475
|
+
assert.equal(host.event('quickchat/button#tap'), false);
|
|
476
|
+
host.surface.setOpen(true);
|
|
477
|
+
assert.equal(host.surface.isOpen(), false);
|
|
478
|
+
host.surface.cover({ picker: false });
|
|
479
|
+
assert.equal(at(host.wire(), 'quickchat/button').s.hidden, false);
|
|
480
|
+
host.event('quickchat/button#tap');
|
|
481
|
+
assert.equal(host.surface.isOpen(), true);
|
|
482
|
+
assert.deepEqual(host.opens, [true, false, true]);
|
|
483
|
+
// A turn re-lays the button out; nothing else changes.
|
|
484
|
+
host.view = VIEWS.landscape;
|
|
485
|
+
host.surface.render();
|
|
486
|
+
assert.equal(at(host.wire(), 'quickchat/card').t, 'scroll');
|
|
487
|
+
const count = host.roots.length;
|
|
488
|
+
host.surface.render();
|
|
489
|
+
assert.equal(host.roots.length, count, 'an unchanged stage sends nothing');
|
|
490
|
+
host.surface.dispose();
|
|
491
|
+
resetUiTrees();
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
await test('the surface loads and runs in a process that never had a DOM', () => {
|
|
495
|
+
const probe = `
|
|
496
|
+
if (globalThis.document || globalThis.window) throw new Error('a DOM');
|
|
497
|
+
const { setUiTreeSink, dispatchUiEvent } = await import(${JSON.stringify(new URL('../code/client/uiTree.js', import.meta.url).href)});
|
|
498
|
+
const { makeQuickChatSurface } = await import(${JSON.stringify(new URL('../code/client/quickChatSurface.js', import.meta.url).href)});
|
|
499
|
+
const seen = [];
|
|
500
|
+
setUiTreeSink((name, wire) => seen.push(name + ':' + (wire ? (wire.c ?? []).length : null)), { dom: false });
|
|
501
|
+
const surface = makeQuickChatSurface({ view: () => ({ landscape: true }), onSay: (what) => seen.push(JSON.stringify(what)) });
|
|
502
|
+
surface.setSay(${JSON.stringify(SAY)});
|
|
503
|
+
dispatchUiEvent('quickchat', 'quickchat/button#tap', null);
|
|
504
|
+
dispatchUiEvent('quickchat', 'quickchat/card/reactions/r0#tap', null);
|
|
505
|
+
surface.dispose();
|
|
506
|
+
console.log(seen.join(' '));
|
|
507
|
+
`;
|
|
508
|
+
assert.equal(execFileSync(process.execPath, ['--input-type=module', '-e', probe], { encoding: 'utf8' }).trim(), 'quickchat:0 quickchat:1 quickchat:2 quickchat:1 {"r":0} quickchat:null');
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
console.log(`quick chat surface: ${passed} checks passed`);
|