castle-web-cli 0.4.231 → 0.4.233
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-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +51 -3
- package/dist/castleJson.d.ts +4 -2
- package/dist/castleJson.js +2 -0
- package/dist/check.d.ts +3 -1
- package/dist/check.js +11 -1
- package/dist/devSessionStorage.js +47 -1
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +5 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +5 -0
- package/dist/save-deck.js +37 -4
- package/dist/serve.js +3 -0
- package/dist/serverBundle.js +5 -3
- package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +79 -2
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +1 -1
- package/kits/base/sdk/commands.d.ts +14 -0
- package/kits/base/sdk/hub.d.ts +6 -2
- package/kits/base/sdk/hub.js +13 -0
- package/kits/base/sdk/multiplayer.js +17 -1
- package/kits/base/sdk/save.js +2 -1
- package/kits/base/sdk/server/hub.d.ts +87 -0
- package/kits/base/sdk/server/hub.js +70 -0
- package/kits/base/sdk/server/platformHandle.d.ts +31 -1
- package/kits/base/sdk/server/storage.d.ts +13 -0
- package/kits/base/sdk/server/storage.js +46 -0
- package/kits/base/sdk/server/wrapper.d.ts +36 -5
- package/kits/base/sdk/server/wrapper.js +83 -8
- package/kits/hub-game/CLAUDE.md +352 -12
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +345 -32
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +251 -0
- package/kits/hub-game/code/client/ballot.js +467 -0
- package/kits/hub-game/code/client/build.js +22 -0
- package/kits/hub-game/code/client/chat.js +12 -0
- package/kits/hub-game/code/client/chrome.js +1334 -50
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/decor.js +509 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/grab.js +363 -20
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +328 -15
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/idle.js +163 -22
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +205 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/shot.js +92 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +131 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +538 -47
- package/kits/hub-game/code/client/tiers.js +541 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +98 -1
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +470 -97
- package/kits/hub-game/code/client/yours.js +199 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/actions.js +133 -0
- package/kits/hub-game/code/server/actors.js +14 -1
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +82 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/earned.js +461 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +232 -0
- package/kits/hub-game/code/server/grab.js +296 -11
- package/kits/hub-game/code/server/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1317 -52
- package/kits/hub-game/code/server/idle.js +30 -11
- package/kits/hub-game/code/server/index.js +2 -2
- package/kits/hub-game/code/server/labels.js +28 -2
- package/kits/hub-game/code/server/manifest.js +424 -8
- package/kits/hub-game/code/server/menu.js +133 -0
- package/kits/hub-game/code/server/npcs.js +830 -80
- package/kits/hub-game/code/server/party.js +13 -2
- package/kits/hub-game/code/server/players.js +22 -0
- package/kits/hub-game/code/server/say.js +8 -2
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +124 -0
- package/kits/hub-game/code/server/vis.js +113 -0
- package/kits/hub-game/code/server/wear.js +128 -11
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/shot.js +19 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1083 -85
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2440 -61
- package/kits/hub-game/docs/home-pieces.md +64 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +2 -0
- package/kits/hub-game/package.json +2 -1
- package/kits/hub-game/scripts/check.mjs +78 -11
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -17
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
- package/kits/hub-game/scripts/test-avatar.mjs +540 -7
- package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
- package/kits/hub-game/scripts/test-build.mjs +31 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +694 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
- package/kits/hub-game/scripts/test-decor.mjs +457 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1194 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +186 -3
- package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +864 -3
- package/kits/hub-game/scripts/test-hats.mjs +483 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1228 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +1000 -0
- package/kits/hub-game/scripts/test-idle.mjs +361 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +596 -0
- package/kits/hub-game/scripts/test-manifest.mjs +282 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
- package/kits/hub-game/scripts/test-menu.mjs +296 -0
- package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-party.mjs +22 -1
- package/kits/hub-game/scripts/test-picker.mjs +314 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-shot.mjs +756 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +416 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
- package/kits/hub-game/scripts/test-tiers.mjs +666 -3
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/hub-game/scripts/test-vis.mjs +343 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
- package/kits/hub-game/scripts/test-yours.mjs +372 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/physics-2d/CLAUDE.md +9 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +288 -1
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +370 -1
- package/kits/physics-3d/CLAUDE.md +1391 -0
- package/kits/physics-3d/behaviors/Player.jsx +921 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +12 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +98 -10
- package/kits/physics-3d/engine3d/actornode.js +86 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +96 -0
- package/kits/physics-3d/engine3d/gait.js +118 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +507 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +37 -19
- package/kits/physics-3d/engine3d/optimize.js +58 -5
- package/kits/physics-3d/engine3d/orbitinput.js +755 -0
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/shadowfade.js +882 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +870 -87
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
- package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +12 -2
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +4588 -0
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +13 -1
- package/kits/physics-3d/scripts/test-static-passes.mjs +1 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +635 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +474 -12
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +97 -19
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Exercise the real multiplayer receive/render methods without a browser.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { register } from 'node:module';
|
|
4
|
+
const kits = new URL('../../', import.meta.url).href;
|
|
5
|
+
const stubs = {
|
|
6
|
+
'../client/avatars.js': 'export const makeAvatars=()=>({leaving:new Map()});',
|
|
7
|
+
'../client/steer.js': 'export const makeState=()=>({});',
|
|
8
|
+
'../client/poses.js': `export const same=(a,b)=>a.every((v,i)=>v===b[i]); export const far=()=>false; export const advance=(a,b,f)=>a.forEach((v,i)=>a[i]=v+(b[i]-v)*f); export const blend=(a,b,t)=>a.map((v,i)=>v+(b[i]-v)*t); export const applyPose=(t,p)=>{t.x=p[0];};`,
|
|
9
|
+
'@imports/castle.real-time/code/client/connection.js': 'export const connectSession=()=>{};',
|
|
10
|
+
'@imports/castle.real-time/code/client/soloBadge.js':
|
|
11
|
+
'export const showSoloBadge=()=>{}; export const updateSoloBadge=()=>{};',
|
|
12
|
+
'@imports/castle.real-time/code/client/joinOverlay.js': 'export const showJoinOverlay=()=>{};',
|
|
13
|
+
'@imports/castle.real-time/code/client/gameHooks.js': 'export const game={};',
|
|
14
|
+
};
|
|
15
|
+
register(
|
|
16
|
+
`data:text/javascript,${encodeURIComponent(`
|
|
17
|
+
import {readFile} from 'node:fs/promises';
|
|
18
|
+
const stubs=${JSON.stringify(stubs)};
|
|
19
|
+
export async function resolve(s,c,n){
|
|
20
|
+
if(c.parentURL?.endsWith('/systems/multiplayer.js') && stubs[s]) return {url:'data:text/javascript,'+encodeURIComponent(stubs[s]),shortCircuit:true};
|
|
21
|
+
if(s.startsWith('@imports/castle.real-time/')) s=${JSON.stringify(kits)}+'real-time/'+s.slice('@imports/castle.real-time/'.length);
|
|
22
|
+
return n(s,c);
|
|
23
|
+
}
|
|
24
|
+
export async function load(u,c,n){
|
|
25
|
+
if(u.endsWith('/systems/multiplayer.js')) return {format:'module',source:(await readFile(new URL(u),'utf8')).replace(/import.meta.glob\\([^)]*\\)/g,'({})'),shortCircuit:true};
|
|
26
|
+
return n(u,c);
|
|
27
|
+
}
|
|
28
|
+
`)}`,
|
|
29
|
+
);
|
|
30
|
+
const { installSystem } = await import('../../multiplayer-3d/code/systems/multiplayer.js');
|
|
31
|
+
const system = installSystem({ registerSystem() {} });
|
|
32
|
+
let messages = [];
|
|
33
|
+
system.net = { selfId: () => 'self', drain: () => messages.splice(0) };
|
|
34
|
+
const scene = {};
|
|
35
|
+
function receive(x, extra = {}) {
|
|
36
|
+
messages.push({
|
|
37
|
+
k: 's',
|
|
38
|
+
t: x * 100,
|
|
39
|
+
localMs: x * 100,
|
|
40
|
+
ps: [],
|
|
41
|
+
os: [['ball', x, 0, 0, 0, 0, 0, 1, 0]],
|
|
42
|
+
own: [],
|
|
43
|
+
...extra,
|
|
44
|
+
});
|
|
45
|
+
system.receive(scene);
|
|
46
|
+
}
|
|
47
|
+
receive(1);
|
|
48
|
+
system.shown.set('ball', [1, 0, 0, 0, 0, 0, 1]);
|
|
49
|
+
system.written.set('ball', [1, 0, 0, 0, 0, 0, 1]);
|
|
50
|
+
system.live.set('ball', {});
|
|
51
|
+
receive(2, { oin: ['ball'] });
|
|
52
|
+
assert.equal(system.objects.get('ball').samples.length, 1);
|
|
53
|
+
assert.ok(!system.shown.has('ball') && !system.live.has('ball') && !system.written.has('ball'));
|
|
54
|
+
const actor = { components: { Transform: { x: 1 } } };
|
|
55
|
+
system.drawInterpolated('ball', system.objects.get('ball'), actor, null, 200, 1 / 60);
|
|
56
|
+
assert.equal(actor.components.Transform.x, 2, 'even a small re-entry snaps rather than smooths');
|
|
57
|
+
receive(3);
|
|
58
|
+
assert.equal(
|
|
59
|
+
system.objects.get('ball').samples.length,
|
|
60
|
+
2,
|
|
61
|
+
'absent oin keeps ordinary interpolation',
|
|
62
|
+
);
|
|
63
|
+
assert.equal(system.shown.get('ball')[0], 2);
|
|
64
|
+
// A new object reusing the id comes back at epoch 0 after a handover at 7.
|
|
65
|
+
system.handed.set('ball', { velocity: [0, 0, 0, 0, 0, 0], epoch: 7, asleep: false, simMs: 0 });
|
|
66
|
+
system.own.mine.add('ball');
|
|
67
|
+
receive(4, { oin: ['ball'] });
|
|
68
|
+
assert.ok(!system.handed.has('ball'), 'an entry under an older epoch drops the stale handover');
|
|
69
|
+
assert.ok(!system.own.mine.has('ball'), 'and the old object no longer counts as held here');
|
|
70
|
+
assert.equal(system.objects.get('ball').samples.length, 1, 'and its entry row is sampled');
|
|
71
|
+
system.handed.set('ball', { velocity: [0, 0, 0, 0, 0, 0], epoch: 0, asleep: false, simMs: 0 });
|
|
72
|
+
receive(5, { oin: ['ball'] });
|
|
73
|
+
assert.ok(system.handed.has('ball'), 'a current handover is kept');
|
|
74
|
+
console.log(
|
|
75
|
+
'test-object-entry: oin clears interpolation/steering/smoothing and snaps; absent oin unchanged',
|
|
76
|
+
);
|
|
@@ -391,6 +391,10 @@ await test('the town mounts a pack with its sounds as data: URLs, and a place pl
|
|
|
391
391
|
[`${kit}drawings/pixel/kai-face.sprite`]: '{"frames":[]}',
|
|
392
392
|
[`${kit}blueprints/bean/avatar-3.scene`]: blueprint('models/bean/avatar-3.pxmodel'),
|
|
393
393
|
[`${kit}models/bean/avatar-3.pxmodel`]: '{"parts":[]}',
|
|
394
|
+
// v1.53: the earned items are the town's too.
|
|
395
|
+
[`${kit}models/earned/badge-round.pxmodel`]: '{"parts":[]}',
|
|
396
|
+
[`${kit}models/earned/held-2.pxmodel`]: '{"parts":[]}',
|
|
397
|
+
[`${kit}models/earned/square/belt-plain.pxmodel`]: '{"parts":[]}',
|
|
394
398
|
[`${kit}blueprints/bean/statue.scene`]: blueprint('models/statue.pxmodel'),
|
|
395
399
|
[`${kit}models/statue.pxmodel`]: '{"parts":[]}',
|
|
396
400
|
'scenes/town.scene': '{"actors":[]}',
|
|
@@ -403,6 +407,9 @@ await test('the town mounts a pack with its sounds as data: URLs, and a place pl
|
|
|
403
407
|
.filter((path) => !/statue|town/.test(path))
|
|
404
408
|
.sort(),
|
|
405
409
|
);
|
|
410
|
+
// v1.53: the engine's earned models are laid over the pack, as its hats are.
|
|
411
|
+
assert.equal(content.files[`${kit}models/earned/badge-round.pxmodel`], '{"parts":[]}');
|
|
412
|
+
assert.ok(!content.carried.files.includes(`${kit}models/earned/badge-round.pxmodel`));
|
|
406
413
|
assert.equal(content.audio['sounds/horn.wav'], `data:audio/wav;base64,${loud.audio['sounds/horn.wav'].base64}`);
|
|
407
414
|
assert.equal(content.audio['sounds/beep.mp3'], `data:audio/mpeg;base64,${loud.audio['sounds/beep.mp3'].base64}`);
|
|
408
415
|
const listed = loud.places.main.idle.sounds;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// installed.
|
|
7
7
|
|
|
8
8
|
import assert from 'node:assert/strict';
|
|
9
|
-
import { padPoint } from '../code/server/party.js';
|
|
9
|
+
import { padPoint, proposalDoor } from '../code/server/party.js';
|
|
10
10
|
import { register } from 'node:module';
|
|
11
11
|
|
|
12
12
|
const sceneStub = 'export const readScene = () => globalThis.__hubTestActors ?? [];';
|
|
@@ -366,4 +366,25 @@ let n = 0;
|
|
|
366
366
|
n += 1;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
// Cues (contract v1.23): the door of a player's live proposal, for "Let's
|
|
370
|
+
// play…" -- the proposer's and each member still asked, nobody else's, and
|
|
371
|
+
// not once it is answered or has run out.
|
|
372
|
+
{
|
|
373
|
+
const now = Date.now();
|
|
374
|
+
const h = {
|
|
375
|
+
players: new Map([['p1', { userId: '101' }], ['p2', { userId: '102' }], ['p3', { userId: '103' }], ['g4', { userId: null }]]),
|
|
376
|
+
party: {
|
|
377
|
+
of: new Map([['u:101', 'party-1'], ['u:102', 'party-1'], ['u:103', 'party-1'], ['p:g4', 'party-2']]),
|
|
378
|
+
proposals: new Map(),
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
const doors = () => ['p1', 'p2', 'p3', 'g4', 'nobody'].map((id) => proposalDoor(h, id));
|
|
382
|
+
assert.deepEqual(doors(), [null, null, null, null, null], 'no proposal');
|
|
383
|
+
h.party.proposals.set('party-1', { id: 1, door: 'race', by: 'p1', until: now + 45000, asked: new Set(['p2']) });
|
|
384
|
+
assert.deepEqual(doors(), ['race', 'race', null, null, null], 'the proposer and the member still asked');
|
|
385
|
+
h.party.proposals.get('party-1').until = now - 1;
|
|
386
|
+
assert.deepEqual(doors(), [null, null, null, null, null], 'run out');
|
|
387
|
+
n += 1;
|
|
388
|
+
}
|
|
389
|
+
|
|
369
390
|
console.log(`test-party: ${n} passed`);
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// The character picker (code/client/chrome.js, contract §11, v1.51): closed it
|
|
2
|
+
// is the one "Character" button it always was; open it is a grid of the kit's
|
|
3
|
+
// characters, four across, each a named, pictured cell big enough to tap, the
|
|
4
|
+
// one worn marked, in a card that scrolls inside itself rather than leave the
|
|
5
|
+
// screen. Run over a stand-in DOM that keeps what the chrome writes.
|
|
6
|
+
// `npm run check` runs this.
|
|
7
|
+
|
|
8
|
+
import assert from 'node:assert/strict';
|
|
9
|
+
import { register } from 'node:module';
|
|
10
|
+
|
|
11
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
12
|
+
export async function resolve(specifier, context, next) {
|
|
13
|
+
if (specifier === 'castle-web-sdk') {
|
|
14
|
+
return { url: ${JSON.stringify(new URL('./fixtures/sdk-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
15
|
+
}
|
|
16
|
+
return next(specifier, context);
|
|
17
|
+
}
|
|
18
|
+
`)}`);
|
|
19
|
+
const Avatar = await import('../code/client/avatar.js');
|
|
20
|
+
const { deck } = await import('../code/client/state.js');
|
|
21
|
+
|
|
22
|
+
function fakeDom(view) {
|
|
23
|
+
const made = [];
|
|
24
|
+
function node(tag) {
|
|
25
|
+
const listeners = {};
|
|
26
|
+
const self = {
|
|
27
|
+
tag,
|
|
28
|
+
children: [],
|
|
29
|
+
parent: null,
|
|
30
|
+
dataset: {},
|
|
31
|
+
attrs: {},
|
|
32
|
+
style: {},
|
|
33
|
+
// Every value a style was given, in order.
|
|
34
|
+
wrote: [],
|
|
35
|
+
textContent: '',
|
|
36
|
+
innerHTML: '',
|
|
37
|
+
appendChild(child) {
|
|
38
|
+
child.parent = self;
|
|
39
|
+
self.children.push(child);
|
|
40
|
+
return child;
|
|
41
|
+
},
|
|
42
|
+
insertBefore(child, before) {
|
|
43
|
+
child.parent = self;
|
|
44
|
+
const at = self.children.indexOf(before);
|
|
45
|
+
self.children.splice(at < 0 ? self.children.length : at, 0, child);
|
|
46
|
+
return child;
|
|
47
|
+
},
|
|
48
|
+
remove() {},
|
|
49
|
+
replaceChildren() {
|
|
50
|
+
self.children = [];
|
|
51
|
+
},
|
|
52
|
+
addEventListener: (type, fn) => (listeners[type] = fn),
|
|
53
|
+
removeEventListener() {},
|
|
54
|
+
setAttribute: (key, value) => (self.attrs[key] = String(value)),
|
|
55
|
+
getAttribute: (key) => self.attrs[key] ?? null,
|
|
56
|
+
fire: (type) => listeners[type]?.({ stopPropagation() {}, preventDefault() {} }),
|
|
57
|
+
hears: (type) => typeof listeners[type] === 'function',
|
|
58
|
+
focus() {},
|
|
59
|
+
blur() {},
|
|
60
|
+
getBoundingClientRect: () => ({ left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0 }),
|
|
61
|
+
offsetWidth: 100,
|
|
62
|
+
offsetHeight: 40,
|
|
63
|
+
offsetLeft: 0,
|
|
64
|
+
offsetTop: 0,
|
|
65
|
+
};
|
|
66
|
+
self.style = new Proxy(
|
|
67
|
+
{},
|
|
68
|
+
{
|
|
69
|
+
set(target, key, value) {
|
|
70
|
+
target[key] = String(value);
|
|
71
|
+
self.wrote.push([key, String(value)]);
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
made.push(self);
|
|
77
|
+
return self;
|
|
78
|
+
}
|
|
79
|
+
const body = node('body');
|
|
80
|
+
globalThis.document = { body, createElement: node, activeElement: null };
|
|
81
|
+
globalThis.window = { innerWidth: view.w, innerHeight: view.h };
|
|
82
|
+
return { made };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { makeChrome } = await import('../code/client/chrome.js');
|
|
86
|
+
const { AVATAR_FACES } = await import('../code/client/avatarFaces.js');
|
|
87
|
+
|
|
88
|
+
function rig({ view = { w: 360, h: 640 }, avatarCount = 16 } = {}) {
|
|
89
|
+
const dom = fakeDom(view);
|
|
90
|
+
const picked = [];
|
|
91
|
+
const colors = [];
|
|
92
|
+
const chrome = makeChrome({ onBack() {}, onAvatar: (i) => picked.push(i), onColor: (c) => colors.push(c), avatarCount });
|
|
93
|
+
const toggle = dom.made.find((c) => c.tag === 'button' && c.textContent === 'Character');
|
|
94
|
+
const picker = toggle.parent;
|
|
95
|
+
const card = picker.children[0];
|
|
96
|
+
const [heading, grid] = card.children;
|
|
97
|
+
return { dom, chrome, picked, colors, toggle, picker, card, heading, grid, cells: grid.children };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let n = 0;
|
|
101
|
+
function test(name, fn) {
|
|
102
|
+
fn();
|
|
103
|
+
n += 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const NAMES = ['Castle', 'Petal', 'Beat', 'Star', 'Biscuit', 'Mochi', 'Hop', 'Pip', 'Ribbit', 'Ember', 'Bolt', 'Gloop', 'Cap', 'Toast', 'Scoop', 'Zest'];
|
|
107
|
+
const px = (value) => parseFloat(value);
|
|
108
|
+
|
|
109
|
+
for (const marker of [undefined, true]) {
|
|
110
|
+
const scene = { persistent: {} };
|
|
111
|
+
Avatar.resetPlatformForTests({
|
|
112
|
+
...(marker === true ? { colors: true } : {}),
|
|
113
|
+
get: async () => ({ status: 'ok', avatar: 2, color: 3 }),
|
|
114
|
+
});
|
|
115
|
+
Avatar.load(scene);
|
|
116
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
117
|
+
test(`platform picker requires the SDK colour marker (${marker})`, () => {
|
|
118
|
+
const r = rig();
|
|
119
|
+
r.chrome.showPicker(true, 2, {
|
|
120
|
+
style: 'toon', available: Avatar.colorsAvailable(), color: Avatar.currentColor(scene),
|
|
121
|
+
files: { 'models/avatar-2.pxmodel': JSON.stringify({ parts: [{ id: 'torso', color: '#123456' }] }) },
|
|
122
|
+
model: 'models/avatar-2.pxmodel',
|
|
123
|
+
});
|
|
124
|
+
const dots = r.dom.made.filter((el) => el.attrs['aria-label']?.startsWith('Colour:'));
|
|
125
|
+
assert.equal(dots.length, marker === true ? 6 : 0);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
test('stand-in picker has no colour row without opt-in and offers one with opt-in', () => {
|
|
130
|
+
Avatar.resetPlatformForTests(null);
|
|
131
|
+
const scene = { persistent: { hubAvatar: 2, hubAvatarColor: 3 } };
|
|
132
|
+
Avatar.load(scene);
|
|
133
|
+
const r = rig();
|
|
134
|
+
const options = {
|
|
135
|
+
style: 'toon',
|
|
136
|
+
files: { 'models/avatar-2.pxmodel': JSON.stringify({ parts: [{ id: 'torso', color: '#123456' }] }) },
|
|
137
|
+
model: 'models/avatar-2.pxmodel',
|
|
138
|
+
};
|
|
139
|
+
try {
|
|
140
|
+
for (const avatarColors of [undefined, false]) {
|
|
141
|
+
if (avatarColors === undefined) { delete deck.avatarColors; }
|
|
142
|
+
else { deck.avatarColors = avatarColors; }
|
|
143
|
+
r.chrome.showPicker(true, 2, { ...options, available: Avatar.colorsAvailable(), color: Avatar.currentColor(scene) });
|
|
144
|
+
assert.equal(r.dom.made.some((el) => el.attrs['aria-label']?.startsWith('Colour:')), false);
|
|
145
|
+
}
|
|
146
|
+
deck.avatarColors = true;
|
|
147
|
+
r.chrome.showPicker(true, 2, { ...options, available: Avatar.colorsAvailable(), color: Avatar.currentColor(scene) });
|
|
148
|
+
const dots = r.dom.made.filter((el) => el.attrs['aria-label']?.startsWith('Colour:'));
|
|
149
|
+
assert.equal(dots.length, 6);
|
|
150
|
+
assert.equal(dots[3].attrs['aria-pressed'], 'true');
|
|
151
|
+
} finally {
|
|
152
|
+
delete deck.avatarColors;
|
|
153
|
+
Avatar.resetPlatformForTests(null);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('colour dots are dormant, toon-only, filled from the palette and marked, with click picks', () => {
|
|
158
|
+
const r = rig();
|
|
159
|
+
const files = { 'models/avatar-2.pxmodel': JSON.stringify({ parts: [{ id: 'torso', color: '#123456' }] }) };
|
|
160
|
+
const options = { available: true, style: 'toon', color: 3, files, model: 'models/avatar-2.pxmodel' };
|
|
161
|
+
r.chrome.showPicker(true, 2);
|
|
162
|
+
assert.equal(r.dom.made.some((el) => el.attrs['aria-label']?.startsWith('Colour:')), false);
|
|
163
|
+
r.chrome.showPicker(true, 2, { ...options, available: false });
|
|
164
|
+
r.chrome.showPicker(true, 2, { ...options, style: 'bean' });
|
|
165
|
+
assert.equal(r.dom.made.some((el) => el.attrs['aria-label']?.startsWith('Colour:')), false);
|
|
166
|
+
r.chrome.showPicker(true, 2, options);
|
|
167
|
+
const dots = r.dom.made.filter((el) => el.attrs['aria-label']?.startsWith('Colour:'));
|
|
168
|
+
assert.equal(dots.length, 6);
|
|
169
|
+
assert.equal(r.card.children[2], dots[0].parent, 'under the character grid');
|
|
170
|
+
assert.deepEqual(dots.map((dot) => dot.style.background), ['#123456', '#d8343f', '#2a9a4a', '#6a35c8', '#3a3644', '#e0a400']);
|
|
171
|
+
assert.equal(dots[3].style.borderColor, '#f2c94c');
|
|
172
|
+
assert.equal(dots[3].attrs['aria-pressed'], 'true');
|
|
173
|
+
dots[4].fire('pointerdown');
|
|
174
|
+
assert.deepEqual(r.colors, []);
|
|
175
|
+
assert.equal(dots[4].hears('pointerdown'), false);
|
|
176
|
+
dots[4].fire('click');
|
|
177
|
+
assert.deepEqual(r.colors, [4]);
|
|
178
|
+
r.cells[1].fire('click');
|
|
179
|
+
const nextFiles = { 'models/avatar-1.pxmodel': JSON.stringify({ parts: [{ id: 'petals', color: '#abcdef' }] }) };
|
|
180
|
+
r.chrome.showPicker(true, 1, { ...options, color: 0, files: nextFiles, model: 'models/avatar-1.pxmodel' });
|
|
181
|
+
assert.equal(dots[0].style.borderColor, '#f2c94c');
|
|
182
|
+
r.chrome.showPicker(true, 1, { ...options, color: 15, files: nextFiles, model: 'models/avatar-1.pxmodel' });
|
|
183
|
+
assert.equal(dots[0].attrs['aria-pressed'], 'true', 'an unknown colour draws and marks zero');
|
|
184
|
+
assert.equal(dots[3].attrs['aria-pressed'], 'false');
|
|
185
|
+
r.chrome.showPicker(true, 1, { ...options, style: 'pixel' });
|
|
186
|
+
assert.equal(dots[0].parent.style.display, 'none');
|
|
187
|
+
r.chrome.showPicker(true, 99, options);
|
|
188
|
+
assert.equal(dots[0].parent.style.display, 'none');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('closed, it is the one button it was, where it was', () => {
|
|
192
|
+
const r = rig();
|
|
193
|
+
// The styles the picker and its button had before v1.51, value for value.
|
|
194
|
+
assert.deepEqual({ ...r.picker.style }, { position: 'absolute', right: '10px', bottom: 'max(10px, env(safe-area-inset-bottom))', display: 'none', flexDirection: 'column', alignItems: 'flex-end', gap: '6px', pointerEvents: 'auto' });
|
|
195
|
+
assert.deepEqual({ ...r.toggle.style }, { padding: '8px 14px', borderRadius: '18px', border: '1px solid rgba(255,255,255,0.4)', background: 'rgba(20,16,12,0.72)', color: '#fff', font: 'inherit', cursor: 'pointer' });
|
|
196
|
+
assert.deepEqual(r.picker.children, [r.card, r.toggle]);
|
|
197
|
+
assert.equal(r.card.style.display, 'none');
|
|
198
|
+
r.chrome.showPicker(true, 2);
|
|
199
|
+
assert.equal(r.picker.style.display, 'flex');
|
|
200
|
+
assert.equal(r.card.style.display, 'none', 'shown, the card stays shut until the button is pressed');
|
|
201
|
+
r.chrome.showPicker(false, 2);
|
|
202
|
+
assert.equal(r.picker.style.display, 'none');
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('open: sixteen named, pictured cells, four across, each big enough to tap', () => {
|
|
206
|
+
const r = rig();
|
|
207
|
+
r.chrome.showPicker(true, 0);
|
|
208
|
+
r.toggle.fire('pointerdown');
|
|
209
|
+
assert.equal(r.card.style.display, 'flex');
|
|
210
|
+
assert.equal(r.heading.textContent, 'Your character');
|
|
211
|
+
assert.equal(r.grid.style.display, 'grid');
|
|
212
|
+
assert.equal(r.grid.style.gridTemplateColumns, 'repeat(4, 64px)');
|
|
213
|
+
assert.equal(r.cells.length, 16);
|
|
214
|
+
r.cells.forEach((cell, i) => {
|
|
215
|
+
assert.equal(cell.tag, 'button');
|
|
216
|
+
assert.equal(cell.attrs['aria-label'], `Character: ${NAMES[i]}`);
|
|
217
|
+
assert.ok(px(cell.style.width) >= 44 && px(cell.style.minHeight) >= 44, `cell ${i} is ${cell.style.width} by ${cell.style.minHeight}`);
|
|
218
|
+
const [face, name] = cell.children;
|
|
219
|
+
assert.equal(name.textContent, NAMES[i]);
|
|
220
|
+
assert.ok(face.innerHTML.startsWith('<svg viewBox="0 0 24 24"') && face.innerHTML.includes(AVATAR_FACES[i][1]) && face.innerHTML.endsWith('</svg>'), `cell ${i} face`);
|
|
221
|
+
assert.ok(face.innerHTML.includes('aria-hidden="true"'));
|
|
222
|
+
});
|
|
223
|
+
// The card on a 360 px phone: four cells, three gaps, its padding, 10 px from the right edge.
|
|
224
|
+
const width = 4 * 64 + 3 * px(r.grid.style.gap) + 2 * px(r.card.style.padding);
|
|
225
|
+
assert.ok(width + 10 <= 360 - 10, `the card is ${width} px wide`);
|
|
226
|
+
assert.equal(r.card.style.maxWidth, 'calc(100vw - 20px)');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('the card keeps to the screen: no taller than what is over the button, and it scrolls inside', () => {
|
|
230
|
+
const r = rig();
|
|
231
|
+
assert.equal(r.card.style.overflowY, 'auto');
|
|
232
|
+
assert.equal(r.card.style.boxSizing, 'border-box');
|
|
233
|
+
// `vh` first, then `dvh` for a browser that has it; both leave the button, its margins and the safe areas.
|
|
234
|
+
assert.deepEqual(
|
|
235
|
+
r.card.wrote.filter(([key]) => key === 'maxHeight').map(([, value]) => value),
|
|
236
|
+
['calc(100vh - 76px - env(safe-area-inset-top) - env(safe-area-inset-bottom))', 'calc(100dvh - 76px - env(safe-area-inset-top) - env(safe-area-inset-bottom))'],
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test('a phone on its side lays the grid eight across, two rows', () => {
|
|
241
|
+
for (const [view, columns] of [[{ w: 800, h: 360 }, 8], [{ w: 667, h: 375 }, 8], [{ w: 590, h: 320 }, 8], [{ w: 568, h: 320 }, 4], [{ w: 480, h: 320 }, 4], [{ w: 360, h: 640 }, 4], [{ w: 1280, h: 720 }, 4]]) {
|
|
242
|
+
const r = rig({ view });
|
|
243
|
+
r.chrome.showPicker(true, 0);
|
|
244
|
+
r.toggle.fire('pointerdown');
|
|
245
|
+
assert.equal(r.grid.style.gridTemplateColumns, `repeat(${columns}, 64px)`, JSON.stringify(view));
|
|
246
|
+
if (columns === 8) {
|
|
247
|
+
assert.ok(8 * 64 + 7 * 6 + 16 + 20 <= view.w, JSON.stringify(view));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test('the one worn is marked, and only when it changes is anything written', () => {
|
|
253
|
+
const r = rig();
|
|
254
|
+
r.chrome.showPicker(true, 9);
|
|
255
|
+
r.cells.forEach((cell, i) => {
|
|
256
|
+
assert.equal(cell.attrs['aria-pressed'], String(i === 9));
|
|
257
|
+
assert.equal(cell.style.borderColor, i === 9 ? '#f2c94c' : 'rgba(255,255,255,0.4)');
|
|
258
|
+
});
|
|
259
|
+
const wrote = r.cells.map((cell) => cell.wrote.length);
|
|
260
|
+
for (let frame = 0; frame < 3; frame += 1) {
|
|
261
|
+
r.chrome.showPicker(true, 9);
|
|
262
|
+
}
|
|
263
|
+
assert.deepEqual(r.cells.map((cell) => cell.wrote.length), wrote, 'the same frame again writes no style');
|
|
264
|
+
r.chrome.showPicker(true, 3);
|
|
265
|
+
assert.deepEqual(r.cells.map((cell) => cell.attrs['aria-pressed'] === 'true').indexOf(true), 3);
|
|
266
|
+
assert.equal(r.cells.filter((cell) => cell.style.borderColor === '#f2c94c').length, 1);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test('a cell is picked on a click, never on the press that may be a scroll', () => {
|
|
270
|
+
const r = rig();
|
|
271
|
+
r.chrome.showPicker(true, 0);
|
|
272
|
+
r.toggle.fire('pointerdown');
|
|
273
|
+
r.cells[12].fire('pointerdown');
|
|
274
|
+
assert.deepEqual(r.picked, []);
|
|
275
|
+
assert.equal(r.cells[12].hears('pointerdown'), false);
|
|
276
|
+
r.cells[12].fire('click');
|
|
277
|
+
assert.deepEqual(r.picked, [12]);
|
|
278
|
+
assert.equal(r.card.style.display, 'none', 'a pick shuts the card');
|
|
279
|
+
// The button opens and shuts it.
|
|
280
|
+
r.toggle.fire('pointerdown');
|
|
281
|
+
assert.equal(r.card.style.display, 'flex');
|
|
282
|
+
r.toggle.fire('pointerdown');
|
|
283
|
+
assert.equal(r.card.style.display, 'none');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test('as many cells as the kit says: four for four, and a number for a character with no face here', () => {
|
|
287
|
+
const four = rig({ avatarCount: 4 });
|
|
288
|
+
assert.deepEqual(four.cells.map((cell) => cell.attrs['aria-label']), NAMES.slice(0, 4).map((name) => `Character: ${name}`));
|
|
289
|
+
const more = rig({ avatarCount: 18 });
|
|
290
|
+
assert.equal(more.cells.length, 18);
|
|
291
|
+
assert.equal(more.cells[17].attrs['aria-label'], 'Character 18');
|
|
292
|
+
assert.equal(more.cells[17].children.length, 1);
|
|
293
|
+
assert.equal(more.cells[17].children[0].textContent, '18');
|
|
294
|
+
more.cells[17].fire('click');
|
|
295
|
+
assert.deepEqual(more.picked, [17]);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
// The companion town alone lifts its corner stack for the engine's lock.
|
|
300
|
+
test('companion layout reserves displayed Shift lock height and restores touch layout', () => {
|
|
301
|
+
const r = rig();
|
|
302
|
+
const original = r.picker.style.bottom;
|
|
303
|
+
const lock = { style: { display: 'block' }, getBoundingClientRect: () => ({ left: 300, right: 344, top: 580, bottom: 624, width: 44, height: 44 }) };
|
|
304
|
+
const parent = { querySelector(selector) { assert.equal(selector, 'button[aria-label^="Shift lock"]'); return lock; } };
|
|
305
|
+
r.chrome.layoutCompanion(parent);
|
|
306
|
+
assert.equal(r.picker.style.bottom, `calc(${original} + 52px)`);
|
|
307
|
+
assert(r.card.style.maxHeight.includes('- 128px'));
|
|
308
|
+
lock.style.display = 'none'; r.chrome.layoutCompanion(parent);
|
|
309
|
+
assert.equal(r.picker.style.bottom, original);
|
|
310
|
+
r.chrome.layoutCompanion(null); assert.equal(r.picker.style.bottom, original);
|
|
311
|
+
r.chrome.dispose();
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
console.log(`hub-game picker: ${n} tests passed`);
|