castle-web-cli 0.4.239 → 0.4.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +163 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +6 -3
- package/dist/init.js +24 -2
- package/dist/platformDoc.js +2 -1
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +473 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +72 -51
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +205 -25
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +35 -3
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +851 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +427 -54
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +79 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-role-client.mjs +2 -1
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs';
|
|
2
3
|
import { register } from 'node:module';
|
|
3
4
|
import * as A from '../code/server/analytics.js';
|
|
4
5
|
import * as DoorAnalytics from '../code/server/doorAnalytics.js';
|
|
@@ -168,3 +169,81 @@ DoorAnalytics.arrive({ place: { result: {} }, players: new Map([['p', { arrived:
|
|
|
168
169
|
session: { hub: { track: (id, event) => { doorEvents.push(event); return true; } } } }, [{ playerId: 'p', device }]);
|
|
169
170
|
assert.deepEqual(doorEvents, [{ kind: DoorAnalytics.EVENTS.round_start, value: 1, result: 0 }], 'door round value remains group size');
|
|
170
171
|
console.log('arrival device values, deferred first visits, hello validation and old clients: passed');
|
|
172
|
+
|
|
173
|
+
// The first room (experiments/hub-nux) on its own manifest: one player, no
|
|
174
|
+
// result, out by `hub.end` (its way back). That end is the visit's
|
|
175
|
+
// session_end, sent while the player is still connected; the way back may hold
|
|
176
|
+
// the connection open for minutes, and its eventual drop and leave add nothing.
|
|
177
|
+
{
|
|
178
|
+
const room = JSON.parse(fs.readFileSync(new URL('../../../experiments/hub-nux/castle.json', import.meta.url), 'utf8'));
|
|
179
|
+
assert.equal(room.hub.analytics, true);
|
|
180
|
+
assert(!room.hub.result, 'the room has no result');
|
|
181
|
+
const realNow = Date.now, realLog = console.log;
|
|
182
|
+
let wall = 0;
|
|
183
|
+
Date.now = () => wall;
|
|
184
|
+
console.log = () => {};
|
|
185
|
+
try {
|
|
186
|
+
const run = async () => {
|
|
187
|
+
const rows = [], sent = [];
|
|
188
|
+
let ctx;
|
|
189
|
+
const session = { sessionId: 's-room', players: [{ playerId: 'p', userId: '101', username: 'Ada', isAnonymous: false }],
|
|
190
|
+
send: (id, message) => sent.push(message), broadcast() {},
|
|
191
|
+
hub: { place: 'main', title: room.hub.title, result: null, arrival: () => ({ fromDeckId: 'TOWN' }),
|
|
192
|
+
async readResults() { return { players: {}, boards: {} }; },
|
|
193
|
+
track: (id, event) => { rows.push({ at: sim.timeMs, connected: session.players.some((p) => p.playerId === id), ...event }); return true; } } };
|
|
194
|
+
const server = layer({ server: room.server, hub: room.hub, characterBundle: room.characterBundle }, { ready: (hub) => { ctx = hub; } }, {}, () => true, () => null);
|
|
195
|
+
server.sceneFor(session);
|
|
196
|
+
const sim = { timeMs: 0, scenePath: 'scenes/main.scene', bodies: new Map(),
|
|
197
|
+
players: new Map([['p', { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } }]]) };
|
|
198
|
+
server.ready(sim);
|
|
199
|
+
server.message(session, { playerId: 'p' }, { k: 'hub-hello', avatar: 1, party: 1 });
|
|
200
|
+
const tick = (ms) => { wall += ms; sim.timeMs += ms; server.place(sim); };
|
|
201
|
+
for (let i = 0; i < 5; i++) {tick(20); await new Promise((resolve) => setImmediate(resolve));}
|
|
202
|
+
assert.deepEqual(rows.map((r) => r.kind), [A.EVENTS.arrive]);
|
|
203
|
+
tick(12000);
|
|
204
|
+
ctx.end(['p']);
|
|
205
|
+
assert(sent.some((m) => m.k === 'hub-end'), 'the way back is sent');
|
|
206
|
+
const end = rows.filter((r) => r.kind === A.EVENTS.session_end);
|
|
207
|
+
assert.equal(end.length, 1, 'the end is the session_end');
|
|
208
|
+
assert.deepEqual(end[0], { at: sim.timeMs, connected: true, kind: A.EVENTS.session_end, subject: 0, value: sim.timeMs - rows[0].at, result: A.END.left, flags: 0 });
|
|
209
|
+
assert(end[0].value >= 12000, 'the connected time up to the end');
|
|
210
|
+
// Minutes on the way back with the connection open, then the drop.
|
|
211
|
+
for (let i = 0; i < 180; i++) {tick(1000);}
|
|
212
|
+
session.players = [];
|
|
213
|
+
for (let i = 0; i < 60; i++) {tick(1000);}
|
|
214
|
+
sim.players.delete('p');
|
|
215
|
+
tick(1000);
|
|
216
|
+
return { rows };
|
|
217
|
+
};
|
|
218
|
+
const { rows } = await run();
|
|
219
|
+
assert.equal(rows.filter((r) => r.kind === A.EVENTS.session_end).length, 1, 'the drop after the end reports nothing more');
|
|
220
|
+
// Unit: a stay after the end continues the visit as a new segment.
|
|
221
|
+
const h = { place: { analytics: true }, manifest: {}, sim: { timeMs: 0, players: new Map() }, players: new Map([['p', { arrived: true }]]),
|
|
222
|
+
analytics: A.create(), session: { players: [{ playerId: 'p' }], hub: { track: (id, event) => { stayRows.push(event); return true; } } } };
|
|
223
|
+
const stayRows = [];
|
|
224
|
+
A.arrive(h, [{ playerId: 'p', userId: '101' }]);
|
|
225
|
+
h.sim.timeMs = 5000; A.ended(h, 'p'); A.ended(h, 'p');
|
|
226
|
+
h.sim.timeMs = 6000; A.stayed(h, 'p');
|
|
227
|
+
h.sim.timeMs = 9000; A.leave(h, 'p');
|
|
228
|
+
assert.deepEqual(stayRows.filter((e) => e.kind === A.EVENTS.session_end).map((e) => [e.value, e.result]),
|
|
229
|
+
[[5000, A.END.left], [3000, A.END.continued]], 'one row per segment; a stay continues');
|
|
230
|
+
// A resume that arrives still ended by its door (the visit was let go at
|
|
231
|
+
// the drop) counts nothing until its stay, and that is a continuation.
|
|
232
|
+
stayRows.length = 0;
|
|
233
|
+
h.players.set('p', { arrived: true, ended: true });
|
|
234
|
+
h.sim.timeMs = 20000; A.arrive(h, [{ playerId: 'p', userId: '101' }]);
|
|
235
|
+
h.sim.timeMs = 32000; A.stayed(h, 'p');
|
|
236
|
+
h.sim.timeMs = 35000; A.leave(h, 'p');
|
|
237
|
+
assert.deepEqual(stayRows.filter((e) => e.kind === A.EVENTS.session_end).map((e) => [e.value, e.result]),
|
|
238
|
+
[[3000, A.END.continued]], 'an ended resume reports only what follows its stay');
|
|
239
|
+
stayRows.length = 0;
|
|
240
|
+
h.players.set('p', { arrived: true, ended: true });
|
|
241
|
+
h.sim.timeMs = 40000; A.arrive(h, [{ playerId: 'p', userId: '101' }]);
|
|
242
|
+
h.sim.timeMs = 45000; A.leave(h, 'p');
|
|
243
|
+
assert.equal(stayRows.filter((e) => e.kind === A.EVENTS.session_end).length, 0, 'an ended resume that leaves adds no row');
|
|
244
|
+
} finally {
|
|
245
|
+
Date.now = realNow;
|
|
246
|
+
console.log = realLog;
|
|
247
|
+
}
|
|
248
|
+
console.log('first room: hub.end reports session_end while connected, once: passed');
|
|
249
|
+
}
|
|
@@ -97,19 +97,18 @@ export default { ...authored,
|
|
|
97
97
|
const a = await connect(`${base}?nonce=${server.mintNonce({userId:'101',username:'Ada',isAnonymous:false})}`);
|
|
98
98
|
const hello = await a.wait(f => f.t === 'hello');
|
|
99
99
|
a.send({ k: 'hub-hello', avatar: 0, party: 1 });
|
|
100
|
-
await
|
|
100
|
+
await arrived(a);
|
|
101
101
|
const initial = await query(a, 'state');
|
|
102
102
|
assert.deepEqual(initial.events, [['arrive', hello.playerId]], 'real hub admitted and arrived');
|
|
103
103
|
if (resultPlace) assert.equal((await query(a, 'report')).accepted, true);
|
|
104
104
|
await query(a, 'move');
|
|
105
|
-
await
|
|
106
|
-
let before = await query(a, 'state');
|
|
105
|
+
let before = await until(a, 'state', {}, s => Math.hypot(s.pose.x - initial.pose.x, s.pose.z - initial.pose.z) > 2);
|
|
107
106
|
assert.ok(Math.hypot(before.pose.x - initial.pose.x, before.pose.z - initial.pose.z) > 2, 'fixture actually moved away from arrival');
|
|
108
107
|
const b = await connect(`${base}?nonce=${server.mintNonce({userId:'102',username:'Bo',isAnonymous:false})}`);
|
|
109
108
|
await b.wait(f => f.t === 'hello');
|
|
110
109
|
b.send({ k: 'hub-hello', avatar: 0, party: 1 });
|
|
111
|
-
await
|
|
112
|
-
if (door) { const prep = await query(b, 'prepare', { id: hello.playerId }); if (door === 'fishing') a.send({ k: 'hub-sit', seat: prep.authored.seat });
|
|
110
|
+
await arrived(b);
|
|
111
|
+
if (door) { const prep = await query(b, 'prepare', { id: hello.playerId }); if (door === 'fishing') a.send({ k: 'hub-sit', seat: prep.authored.seat }); before = await until(a, 'state', { id: hello.playerId }, s => door !== 'fishing' || s.authored.cast === true); if (door === 'fishing') assert.equal(before.authored.cast, true, 'real seat interaction starts a cast'); }
|
|
113
112
|
if (resultPlace) await query(b, 'advance', { ms: 15000 });
|
|
114
113
|
if (leavingLine) await query(a, 'line');
|
|
115
114
|
let returned;
|
|
@@ -120,8 +119,8 @@ export default { ...authored,
|
|
|
120
119
|
a.socket.close();
|
|
121
120
|
await new Promise(resolve => a.socket.once('close', resolve));
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
const absent = await
|
|
122
|
+
// The leave reaches the server's child on its own schedule: poll for it.
|
|
123
|
+
const absent = await until(b, 'state', { id: hello.playerId }, s => s.events.some(e => e[0] === 'leave' && e[1] === hello.playerId));
|
|
125
124
|
assert.equal(absent.events.filter(e => e[0] === 'leave' && e[1] === hello.playerId).length, 1, 'authored immediate leave fires');
|
|
126
125
|
assert.ok(!absent.departedRoster.includes(hello.playerId), 'authored leave sees only authenticated live roster');
|
|
127
126
|
if (!fast) assert.ok(!absent.roster.some(p => p.playerId === hello.playerId), 'absent player is not live');
|
|
@@ -151,7 +150,7 @@ export default { ...authored,
|
|
|
151
150
|
assert.equal((await returned.wait(f => f.t === 'hello')).playerId, hello.playerId);
|
|
152
151
|
}
|
|
153
152
|
returned.send({ k: 'hub-hello', avatar: 0, party: 1, ...(plain ? {} : { resume: true }) });
|
|
154
|
-
await
|
|
153
|
+
await arrived(returned);
|
|
155
154
|
const after = await query(returned, 'state');
|
|
156
155
|
assert.equal(after.events.filter(e => e[0] === 'arrive' && e[1] === hello.playerId).length, 2, 'authored arrive fires again');
|
|
157
156
|
assert.ok(Math.hypot(after.pose.x - before.pose.x, after.pose.z - before.pose.z) < 0.01, 'pose restored across ordinary leave/arrive');
|
|
@@ -170,6 +169,24 @@ export default { ...authored,
|
|
|
170
169
|
await server?.shutdown();
|
|
171
170
|
await rm(dir, { recursive: true, force: true });
|
|
172
171
|
}
|
|
172
|
+
// The kit's own arrival signal, sent once the place's arrive hook has run and
|
|
173
|
+
// the pose is placed. A fixed sleep raced it under load: a message before the
|
|
174
|
+
// first simulation tick is dropped, one before arrivals() sees no arrive yet.
|
|
175
|
+
// A join that never arrives still fails here, on the frame timeout.
|
|
176
|
+
function arrived(client) {
|
|
177
|
+
return client.wait(f => f.t === 'm' && f.d?.k === 'hub-arrived');
|
|
178
|
+
}
|
|
179
|
+
// Asks again until `done` holds or the deadline passes, then returns the last
|
|
180
|
+
// answer, so the caller's assertion still decides (and fails) on it.
|
|
181
|
+
async function until(client, test, extra, done, ms = 10000) {
|
|
182
|
+
const deadline = Date.now() + ms;
|
|
183
|
+
let answer = await query(client, test, extra);
|
|
184
|
+
while (!done(answer) && Date.now() < deadline) {
|
|
185
|
+
await sleep(50);
|
|
186
|
+
answer = await query(client, test, extra);
|
|
187
|
+
}
|
|
188
|
+
return answer;
|
|
189
|
+
}
|
|
173
190
|
async function query(client, test, extra = {}) {
|
|
174
191
|
client.send({ test, ...extra });
|
|
175
192
|
return (await client.wait(f => f.t === 'm' && f.d?.test === test)).d;
|
|
@@ -194,6 +194,15 @@ test('OK and Enter send exact answer once, wipe field/remove listeners and never
|
|
|
194
194
|
const count = r.dom.made.length; r.draw(); assert.equal(r.dom.made.length, count); assert(!r.chrome.textAskOpen()); r.chrome.dispose();
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
|
+
test('v1.204: an answer refused while catching up keeps the card and its text', () => {
|
|
198
|
+
const r = rig(); let refuse = true;
|
|
199
|
+
r.chrome.setTextAsk(spec, (id, n, text) => { if (refuse) return false; r.sent.push({ k: 'hub-answer', id, n, text }); return true; }, (open) => r.locks.push(open));
|
|
200
|
+
const input = r.input(); r.type('Rex'); tap(find(r.dom, 'OK'));
|
|
201
|
+
assert.deepEqual(r.sent, []); assert(r.chrome.textAskOpen()); assert.equal(input.value, 'Rex');
|
|
202
|
+
refuse = false; tap(find(r.dom, 'OK'));
|
|
203
|
+
assert.deepEqual(r.sent, [{ k: 'hub-answer', id: spec.id, n: 1, text: 'Rex' }]); assert(!r.chrome.textAskOpen());
|
|
204
|
+
r.chrome.dispose();
|
|
205
|
+
});
|
|
197
206
|
test('client and server share validation; whitespace, refused characters and oversized raw fields cannot send', () => {
|
|
198
207
|
const r = rig(); r.draw(); const input = r.input(), ok = find(r.dom, 'OK');
|
|
199
208
|
const chars = [...Array.from({ length: 32 }, (_, i) => i), ...Array.from({ length: 33 }, (_, i) => 0x7f + i), 0x061c, 0x200b, 0x200c, 0x200d, 0x200e, 0x200f, 0x202a, 0x202b, 0x202c, 0x202d, 0x202e, ...Array.from({ length: 10 }, (_, i) => 0x2060 + i), 0xfeff];
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// The question card surface (`code/client/askSurface.js`) and its tree
|
|
2
|
+
// (`askTree.js`): the card as the `ask` UI tree root, with no DOM, for a
|
|
3
|
+
// native host. Checks that the trees validate for every kind; that bytes and
|
|
4
|
+
// binding ids do not move across rebuilds with fresh closures; that the
|
|
5
|
+
// words, widths, buttons and heart are the DOM card's (chrome.js drawn into
|
|
6
|
+
// a fake DOM); and that each answer reaches `onAsk` with the card it was
|
|
7
|
+
// drawn for, hides the card until it is given again, and that an away page
|
|
8
|
+
// draws nothing.
|
|
9
|
+
import assert from 'node:assert/strict';
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
11
|
+
import { register } from 'node:module';
|
|
12
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
13
|
+
export async function resolve(specifier, context, next) {
|
|
14
|
+
if (specifier === 'castle-web-sdk') return { url: ${JSON.stringify(new URL('./fixtures/sdk-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
15
|
+
return next(specifier, context);
|
|
16
|
+
}
|
|
17
|
+
`)}`);
|
|
18
|
+
const { dispatchUiEvent, resetUiTrees, serialize, setUiTreeSink, validate } = await import('../code/client/uiTree.js');
|
|
19
|
+
const { askWidth, buildAsk } = await import('../code/client/askTree.js');
|
|
20
|
+
const { makeAskSurface } = await import('../code/client/askSurface.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 ASKS = {
|
|
29
|
+
go: { key: 'go:7', kind: 'go', id: 7, text: 'ada wants to go to Rooftop Race', yes: 'Go', no: 'Stay' },
|
|
30
|
+
invite: { key: 'invite:p2', kind: 'invite', from: 'p2', text: 'bo invites you to a party', yes: 'Join', no: 'No thanks' },
|
|
31
|
+
play: { key: 'play:race', kind: 'play', door: 'race', text: "Let's play Rooftop Race", yes: 'Play', no: 'Not now' },
|
|
32
|
+
again: { key: 'again:race:123', kind: 'again', door: 'race', text: 'Play Rooftop Race again?', yes: 'Again', no: 'Done' },
|
|
33
|
+
yours: { key: 'yours:golf', kind: 'yours', door: 'golf', text: 'Your Mini Golf has 3 new plays and a very long title', line: 'Last played by amy · 2 hearts', yes: 'Go', no: 'Later', heart: false },
|
|
34
|
+
};
|
|
35
|
+
const noop = { answer() {}, heart() {} };
|
|
36
|
+
function find(tree, k) {
|
|
37
|
+
if (!tree) {return null;}
|
|
38
|
+
if (tree.k === k) {return tree;}
|
|
39
|
+
for (const child of tree.c ?? []) {
|
|
40
|
+
const hit = find(child, k);
|
|
41
|
+
if (hit) {return hit;}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const words = (node) => node?.text ?? node?.c?.find((child) => child.t === 'text' && !child.k)?.text;
|
|
46
|
+
|
|
47
|
+
await test('trees validate for every kind, shown and hidden', () => {
|
|
48
|
+
for (const ask of [...Object.values(ASKS), { ...ASKS.yours, heart: true }, { ...ASKS.yours, heart: undefined }, null]) {
|
|
49
|
+
for (const shown of [true, false]) {
|
|
50
|
+
assert.deepEqual(validate(buildAsk({ ask, shown }, noop), 'ask'), []);
|
|
51
|
+
assert.deepEqual(validate(buildAsk({ ask, shown }), 'ask'), []);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await test('bytes and binding ids do not move across rebuilds with fresh closures', () => {
|
|
57
|
+
for (const ask of Object.values(ASKS)) {
|
|
58
|
+
const one = serialize(buildAsk({ ask, shown: true }, { answer: () => 1, heart: () => 1 }), 'ask');
|
|
59
|
+
const two = serialize(buildAsk({ ask: structuredClone(ask), shown: true }, { answer: () => 2, heart: () => 2 }), 'ask');
|
|
60
|
+
assert.equal(one.json, two.json);
|
|
61
|
+
assert.deepEqual([...one.handlers.keys()], [...two.handlers.keys()]);
|
|
62
|
+
}
|
|
63
|
+
assert.deepEqual([...serialize(buildAsk({ ask: ASKS.go, shown: true }, noop), 'ask').handlers.keys()], ['ask/card/yes#tap', 'ask/card/no#tap']);
|
|
64
|
+
assert.deepEqual([...serialize(buildAsk({ ask: ASKS.yours, shown: true }, noop), 'ask').handlers.keys()], ['ask/card/heart#tap', 'ask/card/yes#tap', 'ask/card/no#tap']);
|
|
65
|
+
assert.equal(serialize(buildAsk({ ask: null, shown: false }, noop), 'ask').json, '{"t":"stack","k":"ask","s":{"font":"ui","size":15,"weight":600,"lh":1.3,"color":"#fff"}}');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await test('the card is the DOM\'s: top-centred under the HUD, its width, words, buttons and heart', async () => {
|
|
69
|
+
for (const ask of Object.values(ASKS)) {
|
|
70
|
+
const card = find(buildAsk({ ask, shown: true }, noop), 'card');
|
|
71
|
+
assert.deepEqual(card.at, { anchor: 'top', top: [92, 80] });
|
|
72
|
+
assert.deepEqual(card.s.w, ask.kind === 'yours' ? [{ vw: 94 }, { px: 420 }] : [{ vw: 86 }, { px: 320 }]);
|
|
73
|
+
assert.deepEqual(card.s.w, askWidth(ask));
|
|
74
|
+
assert.deepEqual([card.s.pad, card.s.gap, card.s.radius, card.s.bg, card.s.size, card.s.hit], [[8, 10], 8, 12, 'rgba(20,16,12,0.9)', 14, 'auto']);
|
|
75
|
+
assert.deepEqual([words(find(card, 'yes')), words(find(card, 'no'))], [ask.yes, ask.no]);
|
|
76
|
+
assert.deepEqual([find(card, 'yes').s.bg, find(card, 'no').s.bg], ['gold', 'transparent'], 'Yes is the primary button');
|
|
77
|
+
assert.deepEqual([find(card, 'yes').fire, find(card, 'no').fire], ['down', 'down'], 'answered on the press, as the DOM');
|
|
78
|
+
assert.equal(find(card, 'text').text, ask.text);
|
|
79
|
+
}
|
|
80
|
+
const yours = find(buildAsk({ ask: ASKS.yours, shown: true }, noop), 'card');
|
|
81
|
+
assert.deepEqual(yours.c.map((c) => c.k), ['words', 'heart', 'yes', 'no']);
|
|
82
|
+
assert.deepEqual([find(yours, 'text').s.lines, find(yours, 'line').s.lines, find(yours, 'line').s.size, find(yours, 'line').text], [1, 1, 11, ASKS.yours.line]);
|
|
83
|
+
assert.deepEqual([find(yours, 'heart').label, find(yours, 'heart').pressed, words(find(yours, 'heart'))], ['Heart this game', false, '♡']);
|
|
84
|
+
const hearted = find(buildAsk({ ask: { ...ASKS.yours, heart: true }, shown: true }, noop), 'heart');
|
|
85
|
+
assert.deepEqual([hearted.label, hearted.pressed, words(hearted)], ['Remove heart', true, '♥']);
|
|
86
|
+
assert.equal(find(buildAsk({ ask: { ...ASKS.yours, heart: undefined }, shown: true }, noop), 'heart'), null);
|
|
87
|
+
assert.equal(find(buildAsk({ ask: { ...ASKS.go, heart: true }, shown: true }, noop), 'heart'), null, 'hearts only on your games');
|
|
88
|
+
// chrome.js's own card, drawn into a fake DOM, has the same words in the
|
|
89
|
+
// same order.
|
|
90
|
+
const dom = await chromeAsk();
|
|
91
|
+
for (const ask of [ASKS.invite, ASKS.yours]) {
|
|
92
|
+
dom.chrome.setAsk(ask);
|
|
93
|
+
const card = find(buildAsk({ ask, shown: true }, noop), 'card');
|
|
94
|
+
const flat = (node) => (node.t === 'text' ? [node.text] : node.c?.length === 1 && node.c[0].t === 'text' && !node.c[0].k ? [node.c[0].text] : (node.c ?? []).flatMap(flat));
|
|
95
|
+
assert.deepEqual(flat(card), dom.texts(), ask.kind);
|
|
96
|
+
assert.equal(dom.card.style.width, ask.kind === 'yours' ? 'min(94vw, 420px)' : 'min(86vw, 320px)');
|
|
97
|
+
}
|
|
98
|
+
dom.chrome.dispose();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// chrome.js with a fake DOM: its ask card's words, in order.
|
|
102
|
+
async function chromeAsk() {
|
|
103
|
+
const made = [];
|
|
104
|
+
const node = (tag) => {
|
|
105
|
+
const self = {
|
|
106
|
+
tag, children: [], parent: null, dataset: {}, attrs: {}, textContent: '', innerHTML: '',
|
|
107
|
+
appendChild(child) {child.parent = self; self.children.push(child); return child;},
|
|
108
|
+
insertBefore(child) {child.parent = self; self.children.push(child); return child;},
|
|
109
|
+
remove() {}, contains: () => false, replaceChildren() {self.children = [];},
|
|
110
|
+
addEventListener() {}, removeEventListener() {}, setAttribute(k, v) {self.attrs[k] = String(v);}, getAttribute: (k) => self.attrs[k] ?? null,
|
|
111
|
+
focus() {}, blur() {}, getBoundingClientRect: () => ({ left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0 }),
|
|
112
|
+
offsetWidth: 100, offsetHeight: 40, offsetLeft: 0, offsetTop: 0, style: {},
|
|
113
|
+
};
|
|
114
|
+
made.push(self);
|
|
115
|
+
return self;
|
|
116
|
+
};
|
|
117
|
+
globalThis.document = { body: node('body'), createElement: node, activeElement: null, visibilityState: 'visible' };
|
|
118
|
+
globalThis.window = { innerWidth: 390, innerHeight: 844 };
|
|
119
|
+
globalThis.requestAnimationFrame ??= () => 0;
|
|
120
|
+
globalThis.cancelAnimationFrame ??= () => {};
|
|
121
|
+
const { makeChrome } = await import('../code/client/chrome.js');
|
|
122
|
+
const chrome = makeChrome({ onBack() {}, onAvatar() {}, avatarCount: 4 });
|
|
123
|
+
const card = made.find((n) => n.style.top === 'max(92px, calc(env(safe-area-inset-top) + 80px))');
|
|
124
|
+
const all = (n) => [n, ...n.children.flatMap(all)];
|
|
125
|
+
return { chrome, card, texts: () => all(card).filter((n) => n !== card && n.textContent && !n.children.length).map((n) => n.textContent) };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
await test('events: an answer goes to onAsk with the card drawn and hides it until given again; the heart; away', () => {
|
|
129
|
+
resetUiTrees();
|
|
130
|
+
const roots = [];
|
|
131
|
+
setUiTreeSink((name, wire) => roots.push({ name, wire }), { dom: false });
|
|
132
|
+
const calls = [];
|
|
133
|
+
const surface = makeAskSurface({ onAsk: (ask, yes) => calls.push(['ask', ask, yes]), onHeart: (door, ask) => calls.push(['heart', door, ask]) });
|
|
134
|
+
const wire = () => roots.filter((r) => r.name === 'ask').at(-1)?.wire ?? null;
|
|
135
|
+
const tap = (id) => dispatchUiEvent('ask', id, {});
|
|
136
|
+
// Each kind's answer reaches onAsk with the very card it was drawn for.
|
|
137
|
+
for (const [kind, yes] of [['go', true], ['go', false], ['invite', true], ['invite', false], ['play', true], ['again', false], ['yours', true]]) {
|
|
138
|
+
surface.set(ASKS[kind]);
|
|
139
|
+
assert.equal(surface.shown(), true);
|
|
140
|
+
assert.equal(tap(`ask/card/${yes ? 'yes' : 'no'}#tap`), true);
|
|
141
|
+
assert.equal(surface.shown(), false, 'the card hides on the answer');
|
|
142
|
+
assert.equal(wire().c, undefined);
|
|
143
|
+
assert.equal(tap('ask/card/yes#tap'), false, 'a hidden card takes nothing');
|
|
144
|
+
assert.deepEqual(calls.pop(), ['ask', ASKS[kind], yes]);
|
|
145
|
+
}
|
|
146
|
+
// Given again (the driver had not cleared it yet): drawn again.
|
|
147
|
+
surface.set(ASKS.go);
|
|
148
|
+
assert.equal(surface.shown(), true);
|
|
149
|
+
// The heart, with the card it was drawn for.
|
|
150
|
+
surface.set(ASKS.yours);
|
|
151
|
+
tap('ask/card/heart#tap');
|
|
152
|
+
assert.deepEqual(calls.pop(), ['heart', 'golf', ASKS.yours]);
|
|
153
|
+
assert.equal(surface.shown(), true, 'the heart leaves the card up');
|
|
154
|
+
// Away: hidden at once, not showable; back draws it on the next set.
|
|
155
|
+
surface.setAway(true);
|
|
156
|
+
assert.equal(surface.shown(), false);
|
|
157
|
+
assert.equal(surface.showable(), false);
|
|
158
|
+
surface.set(ASKS.yours);
|
|
159
|
+
assert.equal(wire().c, undefined, 'nothing drawn while away');
|
|
160
|
+
surface.setAway(false);
|
|
161
|
+
assert.equal(surface.shown(), false);
|
|
162
|
+
surface.set(ASKS.yours);
|
|
163
|
+
assert.equal(surface.shown(), true);
|
|
164
|
+
surface.set(null);
|
|
165
|
+
assert.equal(wire().c, undefined);
|
|
166
|
+
assert.deepEqual(calls, []);
|
|
167
|
+
surface.dispose();
|
|
168
|
+
assert.equal(wire(), null);
|
|
169
|
+
resetUiTrees();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await test('the surface loads and runs in a process that never had a DOM', () => {
|
|
173
|
+
const probe = `
|
|
174
|
+
if (globalThis.document || globalThis.window) throw new Error('a DOM');
|
|
175
|
+
const { setUiTreeSink, dispatchUiEvent } = await import(${JSON.stringify(new URL('../code/client/uiTree.js', import.meta.url).href)});
|
|
176
|
+
const { makeAskSurface } = await import(${JSON.stringify(new URL('../code/client/askSurface.js', import.meta.url).href)});
|
|
177
|
+
const seen = [];
|
|
178
|
+
setUiTreeSink((name, wire) => seen.push(name + ':' + (wire ? (wire.c ?? []).length : null)), { dom: false });
|
|
179
|
+
const surface = makeAskSurface({ onAsk: (ask, yes) => seen.push(ask.key + '=' + yes) });
|
|
180
|
+
surface.set(${JSON.stringify(ASKS.invite)});
|
|
181
|
+
dispatchUiEvent('ask', 'ask/card/no#tap', {});
|
|
182
|
+
surface.dispose();
|
|
183
|
+
console.log(seen.join(' '));
|
|
184
|
+
`;
|
|
185
|
+
assert.equal(execFileSync(process.execPath, ['--input-type=module', '-e', probe], { encoding: 'utf8' }).trim(), 'ask:0 ask:1 ask:0 invite:p2=false ask:null');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
console.log(`ask surface: ${passed} checks passed`);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// other players' names near the player only. `npm run check` runs this.
|
|
4
4
|
|
|
5
5
|
import assert from 'node:assert/strict';
|
|
6
|
-
import { attend, fadeNames, makeAttention, nameOpacity, NAME_SCALE } from '../code/client/attention.js';
|
|
6
|
+
import { attend, behind, fadeNames, makeAttention, nameOpacity, NAME_SCALE } from '../code/client/attention.js';
|
|
7
7
|
|
|
8
8
|
// Fifteen statues round a fountain, the player at the arrival spot 8 m out: none.
|
|
9
9
|
const ring = Array.from({ length: 15 }, (_, i) => ({ id: `plinth-${i}`, d: 8 + i * 0.3, speech: false }));
|
|
@@ -110,3 +110,45 @@ fadeNames(mp, { x: 0, z: 0 }, true, touched);
|
|
|
110
110
|
assert.equal(tags.get('p-near').sprite.scale.x, 0.5 * NAME_SCALE);
|
|
111
111
|
|
|
112
112
|
console.log('attention: all passed');
|
|
113
|
+
|
|
114
|
+
// The Weekend Cup statues at yaw 120 (Oct 17, local-proof/yaw120): from the
|
|
115
|
+
// arrival (0, 9) the three stand in a line, so a straight walk to #1 or #3
|
|
116
|
+
// passes the one in front and stops about as near it. The plate passed lies
|
|
117
|
+
// behind the player and gives way to the one walked to.
|
|
118
|
+
{
|
|
119
|
+
const statues = { 'statue-1': [-4.33, 2.5], 'statue-2': [-3.03, 4.752], 'statue-3': [-5.63, 0.248] };
|
|
120
|
+
const walk = (to, steps) => {
|
|
121
|
+
const at = makeAttention();
|
|
122
|
+
const [tx, tz] = statues[to];
|
|
123
|
+
const facing = Math.atan2(tx - 0, tz - 9);
|
|
124
|
+
let picked = null;
|
|
125
|
+
for (let i = 0; i <= steps.length - 1; i++) {
|
|
126
|
+
const from = steps[i];
|
|
127
|
+
const candidates = Object.entries(statues).map(([id, [x, z]]) => ({ id, d: Math.hypot(x - from.x, z - from.z), speech: false, behind: behind(from, facing, x, z) }));
|
|
128
|
+
attend(at, candidates, 1000 + i * 16);
|
|
129
|
+
picked = at.plate;
|
|
130
|
+
}
|
|
131
|
+
return picked;
|
|
132
|
+
};
|
|
133
|
+
const line = (to, stop) => {
|
|
134
|
+
const [tx, tz] = statues[to];
|
|
135
|
+
return Array.from({ length: 40 }, (_, i) => ({ x: (stop.x * i) / 39 + 0 * (1 - i / 39), z: 9 + ((stop.z - 9) * i) / 39 })).filter(({ x, z }) => Math.hypot(tx - x, tz - z) > 0);
|
|
136
|
+
};
|
|
137
|
+
assert.equal(walk('statue-1', line('statue-1', { x: -3.56, z: 3.53 })), 'statue-1', 'arrival to #1 picks #1, not #2 passed on the way');
|
|
138
|
+
assert.equal(walk('statue-3', line('statue-3', { x: -4.87, z: 1.43 })), 'statue-3', 'arrival to #3 picks #3, not #1 passed on the way');
|
|
139
|
+
assert.equal(walk('statue-2', line('statue-2', { x: -2.29, z: 5.8 })), 'statue-2', 'the first statue on the line still shows');
|
|
140
|
+
// No facing (a native host, a missing player), or a plate stood on: no bearing.
|
|
141
|
+
assert.equal(behind({ x: 0, z: 0 }, undefined, 0, -2), false);
|
|
142
|
+
assert.equal(behind({ x: 0, z: 0 }, 0, 0, -0.5), false, 'a plate under the player is not behind');
|
|
143
|
+
assert.equal(behind({ x: 0, z: 0 }, 0, 0, -2), true);
|
|
144
|
+
assert.equal(behind({ x: 0, z: 0 }, 0, 2, 0), false, 'one beside the player is not behind');
|
|
145
|
+
// Two statues side by side, both ahead: the old hysteresis holds.
|
|
146
|
+
const at = makeAttention();
|
|
147
|
+
attend(at, [{ id: 'a', d: 2, speech: false, behind: false }, { id: 'b', d: 2.4, speech: false, behind: false }], 0);
|
|
148
|
+
attend(at, [{ id: 'a', d: 2.3, speech: false, behind: false }, { id: 'b', d: 2.0, speech: false, behind: false }], 16);
|
|
149
|
+
assert.equal(at.plate, 'a', 'a near tie ahead keeps the plate shown');
|
|
150
|
+
// An NPC's line is chosen by distance alone, whichever side it calls from.
|
|
151
|
+
const talk = makeAttention();
|
|
152
|
+
attend(talk, [{ id: 'behind', d: 2, speech: true, behind: true }, { id: 'ahead', d: 5, speech: true, behind: false }], 0);
|
|
153
|
+
assert.equal(talk.speech, 'behind', 'the nearer NPC line shows, even behind the player');
|
|
154
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The choice sheet in a real browser at phone portrait sizes: a sheet with
|
|
2
|
+
// more below its fold says so, and picking a face keeps the faces in view.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { chromium } from 'playwright-core';
|
|
7
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
8
|
+
const root = new URL('../../../', import.meta.url);
|
|
9
|
+
const lines = JSON.parse(await readFile(new URL('experiments/hub-sneaks/castle.json', root), 'utf8')).hub.ballot.lines;
|
|
10
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
11
|
+
try {
|
|
12
|
+
for (const [width, height] of [[412, 870], [360, 740]]) {
|
|
13
|
+
const context = await browser.newContext({ viewport: { width, height }, isMobile: true, hasTouch: true });
|
|
14
|
+
const page = await context.newPage();
|
|
15
|
+
await page.route('http://ballot.test/**', async route => {
|
|
16
|
+
const pathname = new URL(route.request().url()).pathname;
|
|
17
|
+
if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: '<meta name="viewport" content="width=device-width"><body style="margin:0"></body>' });
|
|
18
|
+
const url = new URL(`.${pathname}`, root);
|
|
19
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
20
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
21
|
+
});
|
|
22
|
+
await page.goto('http://ballot.test/');
|
|
23
|
+
await logRenderer(page, 'ballot sheet');
|
|
24
|
+
const result = await page.evaluate(async (lines) => {
|
|
25
|
+
const { makeBallot } = await import('/kits/hub-game/code/client/ballot.js');
|
|
26
|
+
const ids = Array.from({ length: 8 }, (_, i) => `p${i}`);
|
|
27
|
+
const card = {
|
|
28
|
+
v: 'v1', mode: 'talk', title: 'Meeting · talk', until: 60000, options: [], lines: lines.map(l => l.id),
|
|
29
|
+
text: 'By the well: #2 found #5 tagged out by a Sneak. Tap a face, then a line.',
|
|
30
|
+
faces: ids.map((id, i) => ({ id, note: `#${i + 1}` })),
|
|
31
|
+
who: Object.fromEntries(ids.map((id, i) => [id, { name: `player_${i}`, avatar: i % 6 }])),
|
|
32
|
+
feed: [{ from: 'p1', to: 'p3', line: lines[0].id }, { from: 'p2', line: lines[1].id }],
|
|
33
|
+
};
|
|
34
|
+
const ballot = makeBallot({ send: () => {} });
|
|
35
|
+
ballot.frame(card, lines, 'p0', 0, 0);
|
|
36
|
+
const sheet = ballot.surface();
|
|
37
|
+
const masked = () => getComputedStyle(sheet).maskImage !== 'none';
|
|
38
|
+
const view = sheet.getBoundingClientRect();
|
|
39
|
+
const inView = (node) => { const r = node.getBoundingClientRect(); return r.top >= view.top - 1 && r.bottom <= view.bottom + 1; };
|
|
40
|
+
const scrolls = sheet.scrollHeight > sheet.clientHeight + 8;
|
|
41
|
+
const cueAtTop = masked();
|
|
42
|
+
sheet.scrollTop = sheet.scrollHeight;
|
|
43
|
+
sheet.dispatchEvent(new Event('scroll'));
|
|
44
|
+
const cueAtEnd = masked();
|
|
45
|
+
sheet.scrollTop = 0;
|
|
46
|
+
const faces = [...sheet.querySelectorAll('button[aria-pressed]')];
|
|
47
|
+
faces[2].click();
|
|
48
|
+
ballot.frame(card, lines, 'p0', 0, 0);
|
|
49
|
+
const picked = sheet.querySelector('button[aria-pressed="true"]');
|
|
50
|
+
const chip = [...sheet.querySelectorAll('button:not([aria-pressed])')][0];
|
|
51
|
+
const pickedInView = inView(picked), chipInView = inView(chip);
|
|
52
|
+
sheet.scrollTop = 0;
|
|
53
|
+
ballot.frame(card, lines, 'p0', 0, 0);
|
|
54
|
+
window.turned = () => { ballot.frame(card, lines, 'p0', 0, 0); return getComputedStyle(sheet).maskImage; };
|
|
55
|
+
return { scrolls, cueAtTop, cueAtEnd, pickedInView, chipInView };
|
|
56
|
+
}, lines);
|
|
57
|
+
// Turned on its side, the columns scroll: the sheet keeps no portrait fade.
|
|
58
|
+
await page.setViewportSize({ width: height, height: width });
|
|
59
|
+
result.landscapeMask = await page.evaluate(() => window.turned());
|
|
60
|
+
assert.ok(result.scrolls, `${width}x${height}: the Sneaks card scrolls`);
|
|
61
|
+
assert.ok(result.cueAtTop, `${width}x${height}: more below is cued`);
|
|
62
|
+
assert.ok(!result.cueAtEnd, `${width}x${height}: no cue at the end`);
|
|
63
|
+
assert.ok(result.pickedInView, `${width}x${height}: the picked face stays in view`);
|
|
64
|
+
assert.ok(result.chipInView, `${width}x${height}: the first line chip comes into view`);
|
|
65
|
+
assert.equal(result.landscapeMask, 'none', `${width}x${height}: no portrait fade on the sheet in landscape`);
|
|
66
|
+
await context.close();
|
|
67
|
+
}
|
|
68
|
+
console.log('ballot sheet dom: passed');
|
|
69
|
+
} finally {
|
|
70
|
+
await browser.close();
|
|
71
|
+
}
|