castle-web-cli 0.4.232 → 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/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 +329 -11
- 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 +309 -35
- 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/chrome.js +1144 -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 +339 -20
- package/kits/hub-game/code/client/hookLayer.js +299 -13
- 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 +109 -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 +516 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +32 -0
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- 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 +9 -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/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1254 -50
- 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 +378 -7
- 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 +2 -2
- package/kits/hub-game/code/server/players.js +22 -0
- 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 +12 -0
- 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 +845 -95
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2244 -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 +662 -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-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- 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 +716 -2
- package/kits/hub-game/scripts/test-hud-clear.mjs +328 -4
- 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 +207 -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-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-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 +477 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- 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 +253 -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 +326 -1
- package/kits/physics-3d/CLAUDE.md +1169 -30
- package/kits/physics-3d/behaviors/Player.jsx +629 -72
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +8 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +69 -13
- 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 +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +487 -9
- 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 +796 -69
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2563 -80
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- 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 +8 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +2 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +383 -6
- 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,467 @@
|
|
|
1
|
+
// The choice card (contract v1.68, `hub.ballot`), the client's half: a
|
|
2
|
+
// bottom sheet of players' faces, the deck's fixed lines and its options,
|
|
3
|
+
// drawn by the kit because a Tier 0 game has no client code. Every word on it
|
|
4
|
+
// is worded here from ids: a username or "You", a line's text from the
|
|
5
|
+
// place's manifest (`hubPlace.ballot.lines`), an option's text from the card.
|
|
6
|
+
// A tap sends the card's version and ids only (`{ k: 'hub-ballot', v, face?,
|
|
7
|
+
// line?, option? }`); nothing a player types is ever carried.
|
|
8
|
+
//
|
|
9
|
+
// Rule B (contract §6, "The choice card"): a place without `ballot` runs none
|
|
10
|
+
// of this. Everything on the client enters through one gate, `gate`, called
|
|
11
|
+
// by the hook layer for a `hub-ballot-card` message and nowhere else:
|
|
12
|
+
// - the place is not known yet (the server's first tick sends a card ahead
|
|
13
|
+
// of the WORLD snapshot): one card is held, pending, with its connection;
|
|
14
|
+
// the WORLD snapshot then keeps it (`settle`) or drops it by the manifest;
|
|
15
|
+
// - the place is known and declares no `ballot`: the message is dropped
|
|
16
|
+
// before anything is made;
|
|
17
|
+
// - otherwise the card is held with its connection.
|
|
18
|
+
// While a card is held, every WORLD snapshot rechecks it (`settle`): one that
|
|
19
|
+
// names a place without `ballot` lets it go, pending or not. `held` is null
|
|
20
|
+
// until the gate holds a card, and everything else here (the hub system's
|
|
21
|
+
// sheet, `cardFor`) runs only while it is not. A card of another connection
|
|
22
|
+
// is dropped the first time it is asked for, and the hub system reads the
|
|
23
|
+
// gate again after that before it makes or draws anything.
|
|
24
|
+
//
|
|
25
|
+
// Ids index only own properties: `own(obj, id)`, never `obj[id]` alone.
|
|
26
|
+
|
|
27
|
+
// `{ net, card, pending }` once the gate has held a card, else null.
|
|
28
|
+
export let held = null;
|
|
29
|
+
|
|
30
|
+
export function gate(place, net, card) {
|
|
31
|
+
if (place && !place.ballot) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
held = { net, card: card && typeof card === 'object' && Array.isArray(card.faces) ? card : null, pending: !place };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// A WORLD snapshot named the place a held card came to: a place without
|
|
38
|
+
// `ballot` lets go of it, pending or not (a recovery that keeps the
|
|
39
|
+
// connection but lands somewhere keyless); one with it keeps it.
|
|
40
|
+
export function settle(place) {
|
|
41
|
+
if (place?.ballot) {
|
|
42
|
+
held.pending = false;
|
|
43
|
+
} else {
|
|
44
|
+
held = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// This connection's card, or null. A card of another connection is let go.
|
|
49
|
+
// A held card goes when its session does (the same net under another player
|
|
50
|
+
// id is another session).
|
|
51
|
+
export function forget() {
|
|
52
|
+
held = null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function cardFor(net) {
|
|
56
|
+
if (held && held.net !== net) {
|
|
57
|
+
held = null;
|
|
58
|
+
}
|
|
59
|
+
return held && !held.pending ? held.card : null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// What a tap sends: the card's version (rule A), an opaque string echoed as
|
|
63
|
+
// it came, and the ids.
|
|
64
|
+
export function tapMessage(card, ids) {
|
|
65
|
+
return { v: card.v, ...ids };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const own = (obj, id) => (obj && typeof obj === 'object' && Object.hasOwn(obj, id) ? obj[id] : undefined);
|
|
69
|
+
|
|
70
|
+
import { AVATAR_FACES } from './avatarFaces.js';
|
|
71
|
+
|
|
72
|
+
const Z = 2147480001;
|
|
73
|
+
const GOLD = '#ffd84a';
|
|
74
|
+
const CHIP_BG = 'rgba(0,0,0,0.6)';
|
|
75
|
+
// A vote sent and not yet locked in by the server may be sent again after this.
|
|
76
|
+
const PENDING_MS = 2500;
|
|
77
|
+
const FEED_SHOWN = 3;
|
|
78
|
+
|
|
79
|
+
// The words of a manifest line, or null.
|
|
80
|
+
export function lineOf(lines, id) {
|
|
81
|
+
return lines.find((line) => line.id === id) ?? null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// A line's words as this viewer reads them: the server's `words` (the line
|
|
85
|
+
// with the name of anyone a block hides from them taken out) over the
|
|
86
|
+
// manifest's.
|
|
87
|
+
export function textOf(card, line) {
|
|
88
|
+
const words = own(card?.words, line.id);
|
|
89
|
+
return typeof words === 'string' ? words : line.text;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// A player on the card, as this viewer reads them.
|
|
93
|
+
export function nameOf(card, playerId, selfId) {
|
|
94
|
+
if (playerId === selfId) {
|
|
95
|
+
return 'You';
|
|
96
|
+
}
|
|
97
|
+
const name = own(own(card?.who, playerId), 'name');
|
|
98
|
+
return typeof name === 'string' ? name : 'someone';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// The card's recent lines, worded from ids, oldest first:
|
|
102
|
+
// "bo → amy: I saw them by the boat", "bo: Not me!".
|
|
103
|
+
export function feedWords(card, lines, selfId) {
|
|
104
|
+
const out = [];
|
|
105
|
+
for (const row of card?.feed ?? []) {
|
|
106
|
+
const line = lineOf(lines, row.line);
|
|
107
|
+
if (!line) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const from = nameOf(card, row.from, selfId);
|
|
111
|
+
const text = textOf(card, line);
|
|
112
|
+
out.push(row.to ? `${from} → ${nameOf(card, row.to, selfId)}: ${text}` : `${from}: ${text}`);
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// What a tap does, as data: `{ sel, send }`, `send` the message's ids (or
|
|
118
|
+
// null). `sel` is `{ face, option, pending }`: what this viewer has picked on
|
|
119
|
+
// the card and not yet sent, and when a vote went out.
|
|
120
|
+
export function tap(card, lines, sel, what, now = 0) {
|
|
121
|
+
const none = { sel, send: null };
|
|
122
|
+
if (!card || card.mode === 'reveal') {
|
|
123
|
+
return none;
|
|
124
|
+
}
|
|
125
|
+
const live = (id) => card.faces.some((face) => face.id === id && !face.off);
|
|
126
|
+
if (card.mode === 'vote') {
|
|
127
|
+
if (card.picked || (sel.pending !== null && now - sel.pending < PENDING_MS)) {
|
|
128
|
+
return none;
|
|
129
|
+
}
|
|
130
|
+
if (what.face !== undefined) {
|
|
131
|
+
return live(what.face) ? { sel: { ...sel, face: sel.face === what.face ? null : what.face, option: null }, send: null } : none;
|
|
132
|
+
}
|
|
133
|
+
if (what.option !== undefined) {
|
|
134
|
+
return { sel: { ...sel, face: null, option: sel.option === what.option ? null : what.option }, send: null };
|
|
135
|
+
}
|
|
136
|
+
if (what.vote) {
|
|
137
|
+
if (sel.face) {
|
|
138
|
+
return { sel: { ...sel, pending: now }, send: { face: sel.face } };
|
|
139
|
+
}
|
|
140
|
+
if (sel.option) {
|
|
141
|
+
return { sel: { ...sel, pending: now }, send: { option: sel.option } };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return none;
|
|
145
|
+
}
|
|
146
|
+
// Talk: a face, then a line about it; a line about oneself at once; an option at once.
|
|
147
|
+
if (what.face !== undefined) {
|
|
148
|
+
return live(what.face) ? { sel: { ...sel, face: sel.face === what.face ? null : what.face }, send: null } : none;
|
|
149
|
+
}
|
|
150
|
+
if (what.option !== undefined) {
|
|
151
|
+
return card.options.some((o) => o.id === what.option) ? { sel: { ...sel, face: null }, send: { option: what.option } } : none;
|
|
152
|
+
}
|
|
153
|
+
if (what.line !== undefined && card.lines.includes(what.line)) {
|
|
154
|
+
const line = lineOf(lines, what.line);
|
|
155
|
+
if (line?.about === 'self') {
|
|
156
|
+
return { sel, send: { line: line.id } };
|
|
157
|
+
}
|
|
158
|
+
if (line?.about === 'face' && sel.face && live(sel.face)) {
|
|
159
|
+
return { sel: { ...sel, face: null }, send: { face: sel.face, line: line.id } };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return none;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// The selection kept only while the card still allows it.
|
|
166
|
+
// A new version (what can be tapped changed: rule A) starts the selection
|
|
167
|
+
// afresh, so a tap the server refused for an old version leaves nothing
|
|
168
|
+
// selected or pending; a refresh of the words alone keeps it.
|
|
169
|
+
export function keepSel(card, sel) {
|
|
170
|
+
if (!card) {
|
|
171
|
+
return { face: null, option: null, pending: null, mode: null, v: null };
|
|
172
|
+
}
|
|
173
|
+
if (sel.mode !== card.mode || sel.v !== card.v) {
|
|
174
|
+
return { face: null, option: null, pending: null, mode: card.mode, v: card.v };
|
|
175
|
+
}
|
|
176
|
+
const face = sel.face && card.faces.some((f) => f.id === sel.face && !f.off) ? sel.face : null;
|
|
177
|
+
const option = sel.option && card.options.some((o) => o.id === sel.option) ? sel.option : null;
|
|
178
|
+
return { face, option, pending: card.picked ? null : sel.pending, mode: card.mode, v: card.v };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// The line under the title that says what to do now.
|
|
182
|
+
export function hintOf(card, lines, sel, selfId) {
|
|
183
|
+
if (card.mode === 'reveal') {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
if (card.mode === 'vote') {
|
|
187
|
+
if (card.picked) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
return sel.face || sel.option ? null : 'Tap a face to vote';
|
|
191
|
+
}
|
|
192
|
+
const offered = card.lines.map((id) => lineOf(lines, id)).filter(Boolean);
|
|
193
|
+
if (sel.face) {
|
|
194
|
+
return `About ${nameOf(card, sel.face, selfId)}:`;
|
|
195
|
+
}
|
|
196
|
+
return offered.some((line) => line.about === 'face') ? 'Tap a face, then what to say' : null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function voteLabel(card, sel, selfId, now) {
|
|
200
|
+
if (card.picked) {
|
|
201
|
+
// `{}`: locked in on a face this viewer is not shown.
|
|
202
|
+
const what = card.picked.face ? nameOf(card, card.picked.face, selfId) : card.picked.option ? card.options.find((o) => o.id === card.picked.option)?.text ?? '' : '';
|
|
203
|
+
return { text: what ? `Locked in: ${what} ✓` : 'Locked in ✓', enabled: false };
|
|
204
|
+
}
|
|
205
|
+
if (sel.pending !== null && now - sel.pending < PENDING_MS) {
|
|
206
|
+
return { text: 'Sending…', enabled: false };
|
|
207
|
+
}
|
|
208
|
+
if (sel.face) {
|
|
209
|
+
return { text: `Vote for ${nameOf(card, sel.face, selfId)}`, enabled: true };
|
|
210
|
+
}
|
|
211
|
+
if (sel.option) {
|
|
212
|
+
return { text: `Vote: ${card.options.find((o) => o.id === sel.option)?.text ?? ''}`, enabled: true };
|
|
213
|
+
}
|
|
214
|
+
return { text: 'Vote', enabled: false };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function clock(seconds) {
|
|
218
|
+
const s = Math.max(0, Math.ceil(seconds));
|
|
219
|
+
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function el(tag, style, parent) {
|
|
223
|
+
const node = document.createElement(tag);
|
|
224
|
+
Object.assign(node.style, style);
|
|
225
|
+
parent?.appendChild(node);
|
|
226
|
+
return node;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// `send(ids)` sends a tap; `onChip()` (optional) is the soundscape's chip tap.
|
|
230
|
+
export function makeBallot({ send, onChip }) {
|
|
231
|
+
let root = null;
|
|
232
|
+
let sheet = null;
|
|
233
|
+
let countdown = null;
|
|
234
|
+
let key = '';
|
|
235
|
+
let sel = { face: null, option: null, pending: null, mode: null, v: null };
|
|
236
|
+
let current = null;
|
|
237
|
+
let lines = [];
|
|
238
|
+
let selfId = null;
|
|
239
|
+
// The face or option the card was last drawn with picked.
|
|
240
|
+
let shownPick = null;
|
|
241
|
+
|
|
242
|
+
function build() {
|
|
243
|
+
root = el('div', { position: 'fixed', left: '0', right: '0', bottom: '0', display: 'flex', justifyContent: 'center', pointerEvents: 'none', zIndex: String(Z) }, document.body);
|
|
244
|
+
root.dataset.hub = 'ballot';
|
|
245
|
+
sheet = el('div', { pointerEvents: 'auto', width: 'min(100%, 560px)', boxSizing: 'border-box', overflowY: 'auto', overscrollBehavior: 'contain', touchAction: 'pan-y', background: 'rgba(16,12,22,0.96)', borderRadius: '18px 18px 0 0', padding: '12px 12px max(12px, env(safe-area-inset-bottom))', boxShadow: '0 -4px 18px rgba(0,0,0,0.45)', font: '600 15px/1.3 system-ui, sans-serif', color: '#fff', display: 'flex', flexDirection: 'column', gap: '10px', userSelect: 'none', webkitUserSelect: 'none' }, root);
|
|
246
|
+
for (const type of ['pointerdown', 'touchstart', 'mousedown', 'wheel']) {
|
|
247
|
+
sheet.addEventListener(type, (event) => event.stopPropagation(), { passive: true });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function press(what) {
|
|
252
|
+
const result = tap(current, lines, sel, what, performance.now());
|
|
253
|
+
sel = result.sel;
|
|
254
|
+
if (result.send) {
|
|
255
|
+
onChip?.();
|
|
256
|
+
send(tapMessage(current, result.send));
|
|
257
|
+
}
|
|
258
|
+
key = '';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function button(parent, style, onTap) {
|
|
262
|
+
const node = el('button', { boxSizing: 'border-box', cursor: 'pointer', touchAction: 'manipulation', font: 'inherit', color: '#fff', ...style }, parent);
|
|
263
|
+
node.type = 'button';
|
|
264
|
+
node.addEventListener('click', (event) => {
|
|
265
|
+
event.stopPropagation();
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
onTap();
|
|
268
|
+
});
|
|
269
|
+
return node;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function chip(parent, text, enabled, onTap, dashed = false) {
|
|
273
|
+
const node = button(parent, { minHeight: '44px', padding: '9px 14px', borderRadius: '22px', border: `1px ${dashed ? 'dashed' : 'solid'} rgba(255,255,255,0.4)`, background: CHIP_BG, font: '600 15px/1.2 system-ui, sans-serif', textAlign: 'left', opacity: enabled ? '1' : '0.4' }, () => {
|
|
274
|
+
if (enabled) {
|
|
275
|
+
onTap();
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
node.textContent = text;
|
|
279
|
+
node.setAttribute('aria-disabled', enabled ? 'false' : 'true');
|
|
280
|
+
return node;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function faceCell(parent, card, face, landscape) {
|
|
284
|
+
const chosen = sel.face === face.id || card.picked?.face === face.id;
|
|
285
|
+
const tappable = card.mode !== 'reveal' && !face.off && !card.picked;
|
|
286
|
+
const node = button(parent, { position: 'relative', minHeight: landscape ? '66px' : '76px', padding: '6px 4px', borderRadius: '14px', border: `2px solid ${chosen ? GOLD : face.mark ?? 'rgba(255,255,255,0.18)'}`, boxShadow: chosen ? `0 0 0 3px rgba(255,216,74,0.5)` : 'none', background: CHIP_BG, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: '2px', minWidth: '0', opacity: face.off ? '0.4' : '1', filter: face.off ? 'grayscale(1)' : 'none', cursor: tappable ? 'pointer' : 'default' }, () => {
|
|
287
|
+
if (tappable) {
|
|
288
|
+
press({ face: face.id });
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
const who = own(card.who, face.id);
|
|
292
|
+
const drawing = Number.isInteger(who?.avatar) ? AVATAR_FACES[who.avatar]?.[1] : null;
|
|
293
|
+
const size = landscape ? 28 : 36;
|
|
294
|
+
if (drawing) {
|
|
295
|
+
el('div', { width: `${size}px`, height: `${size}px`, flex: 'none', pointerEvents: 'none' }, node).innerHTML = `<svg viewBox="0 0 24 24" width="${size}" height="${size}" stroke="#241a2e" stroke-width="1.3" stroke-linejoin="round" stroke-linecap="round" aria-hidden="true">${drawing}</svg>`;
|
|
296
|
+
} else {
|
|
297
|
+
const blank = el('div', { width: `${size}px`, height: `${size}px`, borderRadius: '50%', background: '#4a4458', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '18px', pointerEvents: 'none' }, node);
|
|
298
|
+
blank.textContent = nameOf(card, face.id, null).slice(0, 1).toUpperCase();
|
|
299
|
+
}
|
|
300
|
+
const name = el('div', { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', fontSize: '15px', pointerEvents: 'none' }, node);
|
|
301
|
+
name.textContent = nameOf(card, face.id, selfId);
|
|
302
|
+
if (face.note) {
|
|
303
|
+
const note = el('div', { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', font: '500 15px/1.2 system-ui, sans-serif', opacity: '0.8', pointerEvents: 'none' }, node);
|
|
304
|
+
note.textContent = face.note;
|
|
305
|
+
}
|
|
306
|
+
if (face.mark) {
|
|
307
|
+
el('div', { position: 'absolute', left: '6px', top: '6px', width: '10px', height: '10px', borderRadius: '5px', background: face.mark, pointerEvents: 'none' }, node);
|
|
308
|
+
}
|
|
309
|
+
if (Number.isInteger(face.votes)) {
|
|
310
|
+
const votes = el('div', { position: 'absolute', right: '4px', top: '4px', minWidth: '22px', height: '22px', padding: '0 6px', boxSizing: 'border-box', borderRadius: '11px', background: face.votes > 0 ? GOLD : 'rgba(255,255,255,0.2)', color: face.votes > 0 ? '#2b2118' : '#fff', font: '800 15px/22px system-ui, sans-serif', textAlign: 'center', pointerEvents: 'none' }, node);
|
|
311
|
+
votes.textContent = String(face.votes);
|
|
312
|
+
}
|
|
313
|
+
if (card.picked?.face === face.id) {
|
|
314
|
+
const tick = el('div', { position: 'absolute', left: '4px', bottom: '4px', width: '20px', height: '20px', borderRadius: '10px', background: GOLD, color: '#2b2118', font: '800 13px/20px system-ui, sans-serif', textAlign: 'center', pointerEvents: 'none' }, node);
|
|
315
|
+
tick.textContent = '✓';
|
|
316
|
+
}
|
|
317
|
+
node.setAttribute('aria-label', `${nameOf(card, face.id, selfId)}${face.note ? `, ${face.note}` : ''}${Number.isInteger(face.votes) ? `, ${face.votes} votes` : ''}`);
|
|
318
|
+
node.setAttribute('aria-pressed', chosen ? 'true' : 'false');
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Portrait: one column that scrolls. A phone on its side: the card's words
|
|
322
|
+
// and faces on the left, what to say or vote on the right, each column
|
|
323
|
+
// scrolling on its own, so the chips stay in view whatever the faces do.
|
|
324
|
+
// `focus` (a face was just picked) brings the chips or Vote into view.
|
|
325
|
+
function draw(card, landscape, now, maxH, focus) {
|
|
326
|
+
const scrolls = [...sheet.children].map((child) => child.scrollTop);
|
|
327
|
+
const scroll = sheet.scrollTop;
|
|
328
|
+
sheet.replaceChildren();
|
|
329
|
+
Object.assign(sheet.style, landscape ? { flexDirection: 'row', overflowY: 'hidden', gap: '12px' } : { flexDirection: 'column', overflowY: 'auto', gap: '10px' });
|
|
330
|
+
const column = (flex) => el('div', { flex, minWidth: '0', maxHeight: `${Math.round(maxH - 24)}px`, overflowY: 'auto', overscrollBehavior: 'contain', display: 'flex', flexDirection: 'column', gap: '8px' }, sheet);
|
|
331
|
+
const left = landscape ? column('1 1 56%') : sheet;
|
|
332
|
+
const right = landscape ? column('1 1 44%') : sheet;
|
|
333
|
+
const head = el('div', { display: 'flex', alignItems: 'center', gap: '10px', flex: 'none' }, left);
|
|
334
|
+
const title = el('div', { flex: '1', minWidth: '0', font: '800 17px/1.25 system-ui, sans-serif' }, head);
|
|
335
|
+
title.textContent = card.title ?? '';
|
|
336
|
+
countdown = null;
|
|
337
|
+
if (card.until !== undefined) {
|
|
338
|
+
countdown = el('div', { flex: 'none', padding: '4px 10px', borderRadius: '12px', background: 'rgba(255,255,255,0.14)', font: '800 15px/1.2 system-ui, sans-serif', fontVariantNumeric: 'tabular-nums' }, head);
|
|
339
|
+
}
|
|
340
|
+
if (card.text) {
|
|
341
|
+
el('div', { flex: 'none', font: '500 15px/1.3 system-ui, sans-serif', opacity: '0.9' }, left).textContent = card.text;
|
|
342
|
+
}
|
|
343
|
+
// A short screen keeps fewer of the said lines.
|
|
344
|
+
const said = feedWords(card, lines, selfId).slice(window.innerHeight < 700 && !landscape ? -2 : -FEED_SHOWN);
|
|
345
|
+
if (said.length) {
|
|
346
|
+
const feed = el('div', { flex: 'none', display: 'flex', flexDirection: 'column', gap: '2px', padding: '2px 0 2px 10px', borderLeft: '3px solid rgba(255,255,255,0.25)', font: '500 15px/1.3 system-ui, sans-serif', opacity: '0.88' }, left);
|
|
347
|
+
for (const words of said) {
|
|
348
|
+
el('div', {}, feed).textContent = words;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const hint = hintOf(card, lines, sel, selfId);
|
|
352
|
+
if (hint) {
|
|
353
|
+
el('div', { flex: 'none', font: '600 15px/1.3 system-ui, sans-serif', color: '#e9c48f' }, landscape ? right : left).textContent = hint;
|
|
354
|
+
}
|
|
355
|
+
if (card.faces.length) {
|
|
356
|
+
const grid = el('div', { flex: 'none', display: 'grid', gridTemplateColumns: `repeat(auto-fill, minmax(${landscape ? 70 : 72}px, 1fr))`, gap: '8px' }, left);
|
|
357
|
+
for (const face of card.faces) {
|
|
358
|
+
faceCell(grid, card, face, landscape);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const chips = el('div', { flex: 'none', display: 'flex', flexWrap: 'wrap', gap: '8px' }, right);
|
|
362
|
+
if (card.mode === 'talk') {
|
|
363
|
+
for (const id of card.lines) {
|
|
364
|
+
const line = lineOf(lines, id);
|
|
365
|
+
if (line) {
|
|
366
|
+
chip(chips, textOf(card, line), line.about === 'self' || Boolean(sel.face), () => press({ line: id }));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (card.mode !== 'reveal') {
|
|
371
|
+
for (const option of card.options) {
|
|
372
|
+
const chosen = sel.option === option.id || card.picked?.option === option.id;
|
|
373
|
+
const node = chip(chips, option.text, !card.picked, () => press({ option: option.id }), true);
|
|
374
|
+
if (chosen) {
|
|
375
|
+
Object.assign(node.style, { borderColor: GOLD, borderStyle: 'solid', boxShadow: '0 0 0 3px rgba(255,216,74,0.5)' });
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (!chips.childElementCount) {
|
|
380
|
+
chips.remove();
|
|
381
|
+
}
|
|
382
|
+
let vote = null;
|
|
383
|
+
if (card.mode === 'vote') {
|
|
384
|
+
const label = voteLabel(card, sel, selfId, now);
|
|
385
|
+
vote = button(right, { flex: 'none', minHeight: '48px', width: '100%', borderRadius: '24px', border: 'none', background: card.picked ? 'rgba(255,216,74,0.25)' : GOLD, color: card.picked ? '#fff' : '#2b2118', font: '800 17px/1.2 system-ui, sans-serif', opacity: label.enabled || card.picked ? '1' : '0.45' }, () => {
|
|
386
|
+
if (label.enabled) {
|
|
387
|
+
press({ vote: true });
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
vote.textContent = label.text;
|
|
391
|
+
vote.setAttribute('aria-disabled', label.enabled ? 'false' : 'true');
|
|
392
|
+
}
|
|
393
|
+
if (landscape && !right.childElementCount) {
|
|
394
|
+
right.remove();
|
|
395
|
+
}
|
|
396
|
+
if (landscape) {
|
|
397
|
+
[...sheet.children].forEach((child, i) => {
|
|
398
|
+
child.scrollTop = scrolls[i] ?? 0;
|
|
399
|
+
});
|
|
400
|
+
} else {
|
|
401
|
+
sheet.scrollTop = scroll;
|
|
402
|
+
}
|
|
403
|
+
// What to do next, brought into view once, as a face is picked.
|
|
404
|
+
const next = vote ?? (chips.isConnected ? chips : null);
|
|
405
|
+
if (focus && next) {
|
|
406
|
+
const box = next.parentElement;
|
|
407
|
+
const over = next.offsetTop + next.offsetHeight - (box.scrollTop + box.clientHeight) + 12;
|
|
408
|
+
if (over > 0) {
|
|
409
|
+
box.scrollTop += over;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
// `card` is this player's card (`hub-ballot-card`) or null; `placeLines`
|
|
416
|
+
// the place's manifest lines; `simNow` the simulation time now;
|
|
417
|
+
// `hudBottom` the bottom of a clear HUD's box in CSS px, or 0 (the card
|
|
418
|
+
// stays under it; an ordinary HUD never reaches 40% of the view).
|
|
419
|
+
frame(card, placeLines, self, simNow, hudBottom = 0) {
|
|
420
|
+
current = card;
|
|
421
|
+
if (!card) {
|
|
422
|
+
if (root) {
|
|
423
|
+
root.style.display = 'none';
|
|
424
|
+
}
|
|
425
|
+
sel = keepSel(null, sel);
|
|
426
|
+
key = '';
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (!root) {
|
|
430
|
+
build();
|
|
431
|
+
}
|
|
432
|
+
root.style.display = 'flex';
|
|
433
|
+
lines = Array.isArray(placeLines) ? placeLines : [];
|
|
434
|
+
selfId = self;
|
|
435
|
+
sel = keepSel(card, sel);
|
|
436
|
+
const now = performance.now();
|
|
437
|
+
const w = window.innerWidth;
|
|
438
|
+
const h = window.innerHeight;
|
|
439
|
+
const landscape = w > h && h < 520;
|
|
440
|
+
const maxH = Math.max(160, Math.min(h * 0.6, h - hudBottom - 8));
|
|
441
|
+
sheet.style.maxHeight = `${Math.round(maxH)}px`;
|
|
442
|
+
sheet.style.width = landscape ? 'min(100%, 820px)' : 'min(100%, 560px)';
|
|
443
|
+
const pending = sel.pending !== null && now - sel.pending < PENDING_MS;
|
|
444
|
+
const next = JSON.stringify([card, sel.face, sel.option, pending, lines, selfId, landscape, Math.round(maxH)]);
|
|
445
|
+
if (next !== key) {
|
|
446
|
+
key = next;
|
|
447
|
+
const picked = sel.face ?? sel.option;
|
|
448
|
+
draw(card, landscape, now, maxH, picked !== null && picked !== shownPick);
|
|
449
|
+
shownPick = picked;
|
|
450
|
+
}
|
|
451
|
+
if (countdown) {
|
|
452
|
+
const left = (card.until - simNow) / 1000;
|
|
453
|
+
const text = clock(left);
|
|
454
|
+
if (countdown.textContent !== text) {
|
|
455
|
+
countdown.textContent = text;
|
|
456
|
+
countdown.style.background = left <= 10 ? 'rgba(230,70,70,0.85)' : 'rgba(255,255,255,0.14)';
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
// Whether the card is up (the hub hides what it would cover).
|
|
461
|
+
shown: () => current !== null,
|
|
462
|
+
dispose() {
|
|
463
|
+
root?.remove();
|
|
464
|
+
root = null;
|
|
465
|
+
},
|
|
466
|
+
};
|
|
467
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The build stamp a town's assembly writes beside its castle.json: which git
|
|
2
|
+
// commit the deck was built from, and when. It is for QA to read off the page
|
|
3
|
+
// (`globalThis.__hub.build`; the hook layer reads the file), so a phone leg can tell which save a layer runs.
|
|
4
|
+
// A deck with no build.json, or one that does not read as a stamp, has none.
|
|
5
|
+
|
|
6
|
+
const SHA = /^[0-9a-f]{7,40}$/;
|
|
7
|
+
const text = (value) => (typeof value === 'string' && value.length > 0 && value.length <= 80 ? value : null);
|
|
8
|
+
|
|
9
|
+
// `{ sha, savedAt, bundle?, dirty? }` or null. Only the named fields are kept.
|
|
10
|
+
export function buildStamp(json) {
|
|
11
|
+
if (!json || typeof json !== 'object' || Array.isArray(json)) {return null;}
|
|
12
|
+
if (typeof json.sha !== 'string' || !SHA.test(json.sha)) {return null;}
|
|
13
|
+
const savedAt = text(json.savedAt);
|
|
14
|
+
if (savedAt === null || Number.isNaN(Date.parse(savedAt))) {return null;}
|
|
15
|
+
const bundle = text(json.bundle);
|
|
16
|
+
return Object.freeze({
|
|
17
|
+
sha: json.sha,
|
|
18
|
+
savedAt,
|
|
19
|
+
...(bundle === null ? {} : { bundle }),
|
|
20
|
+
...(json.dirty === true ? { dirty: true } : {}),
|
|
21
|
+
});
|
|
22
|
+
}
|