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,372 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { rowsFor, send, cleanHearts } from '../code/server/yours.js';
|
|
3
|
+
import { take } from '../code/server/history.js';
|
|
4
|
+
import { makeYours, toggleHeart, relativeDay } from '../code/client/yours.js';
|
|
5
|
+
const flush = () => new Promise((r) => setImmediate(r));
|
|
6
|
+
const doors = Array.from({ length: 8 }, (_, i) => ({ id: `d${i}`, title: `Game ${i}`, to: `deck:game-${i}` }));
|
|
7
|
+
const boards = new Map(doors.map((d, i) => [d.id, { toDeckId: `game-${i}`, unit: 'points' }]));
|
|
8
|
+
const history = {
|
|
9
|
+
recent: [7, 6, 5, 4, 3, 2, 1, 0].map((i) => ({ deckId: `game-${i}`, place: 'main', at: '2026-10-02T12:00:00Z', score: 3 })),
|
|
10
|
+
records: [{ deckId: 'game-1', place: 'main', bestScore: 9, unit: 'ms', lastAt: '2026-10-04T20:00:00Z' }],
|
|
11
|
+
};
|
|
12
|
+
const rows = rowsFor(doors, boards, history, ['gone', 'd1', 'd0']);
|
|
13
|
+
assert.deepEqual(rows.map((r) => r.door), ['d1', 'd0', 'd7', 'd6', 'd5']);
|
|
14
|
+
assert.equal(rows[0].line, 'Best 9 points');
|
|
15
|
+
assert.equal(rows[0].lastAt, Date.parse('2026-10-04T20:00:00Z'));
|
|
16
|
+
assert.equal(rows[1].line, 'Last 3 points');
|
|
17
|
+
assert.equal(rows[1].lastAt, Date.parse('2026-10-02T12:00:00Z'));
|
|
18
|
+
assert.equal(rows[2].hearted, false);
|
|
19
|
+
assert.deepEqual(rowsFor(doors, boards, { recent: [{ deckId: 'elsewhere', place: 'main' }] }, []), []);
|
|
20
|
+
assert.equal(rowsFor(doors, boards, null, ['d2'])[0].line, '');
|
|
21
|
+
assert.equal(rowsFor(doors, boards, { records: [{ deckId: 'game-1', place: 'arena', bestScore: 400 }] }, ['d1'])[0].line, '');
|
|
22
|
+
assert.equal(rowsFor(doors, boards, { recent: [{ deckId: 'game-1', place: 'main', outcome: 'win', at: '2026-10-05T11:00:00Z' }] }, [])[0].line, 'win');
|
|
23
|
+
assert.equal(rowsFor(doors, boards, { recent: [{ deckId: 'game-1', place: 'arena', outcome: 'win', at: '2026-10-05T11:00:00Z' }] }, [])[0].door, 'd1', 'recent play maps by destination deck, including its subplaces');
|
|
24
|
+
assert.deepEqual(cleanHearts(['d1', 'd1', 1, '', 'd2']), ['d1', 'd2']);
|
|
25
|
+
const messages = [];
|
|
26
|
+
const entry = { history, hearts: ['d1'] };
|
|
27
|
+
const h = { manifest: { yourGames: true }, place: {}, boards, players: new Map([['p1', entry], ['guest', { history, hearts: ['d2'] }], ['empty', {}]]), session: { send: (id, msg) => messages.push([id, msg]) } };
|
|
28
|
+
const members = () => new Map([['u1', 'p1'], ['u2', 'empty']]);
|
|
29
|
+
send(h, doors, members);
|
|
30
|
+
assert.equal(messages.length, 1);
|
|
31
|
+
assert.equal(messages[0][0], 'p1');
|
|
32
|
+
assert.equal(messages[0][1].k, 'hub-yours');
|
|
33
|
+
send(h, doors, members);
|
|
34
|
+
assert.equal(messages.length, 1, 'latched');
|
|
35
|
+
entry.hearts = [];
|
|
36
|
+
entry.history = null;
|
|
37
|
+
send(h, doors, members);
|
|
38
|
+
assert.deepEqual(messages.at(-1), ['p1', { k: 'hub-yours', rows: [], hearts: [] }]);
|
|
39
|
+
h.place.result = {};
|
|
40
|
+
entry.hearts = ['d1'];
|
|
41
|
+
send(h, doors, members);
|
|
42
|
+
assert.equal(messages.length, 2, 'no game message');
|
|
43
|
+
h.place = {};
|
|
44
|
+
h.manifest = {};
|
|
45
|
+
send(h, doors, () => { throw new Error('keyless must not read members'); });
|
|
46
|
+
take(h, 'p1', { recent: [], records: [], get hearts() { throw new Error('keyless must not read hearts'); } });
|
|
47
|
+
assert.equal(messages.length, 2);
|
|
48
|
+
h.manifest.yourGames = true;
|
|
49
|
+
take(h, 'p1', { hearts: ['d2'], recent: [], records: [] }, Date.now() + 1);
|
|
50
|
+
assert.deepEqual(entry.hearts, ['d2']);
|
|
51
|
+
|
|
52
|
+
assert.deepEqual(toggleHeart(Array.from({ length: 8 }, (_, i) => `d${i}`), 'new'), ['d1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'new']);
|
|
53
|
+
const writes = [], toasts = [];
|
|
54
|
+
let readCount = 0;
|
|
55
|
+
const api = { hearts: async () => { readCount++; return { status: 'ok', hearts: ['d1'] }; }, setHearts: (ids) => new Promise((resolve, reject) => writes.push({ ids, resolve, reject })) };
|
|
56
|
+
const client = makeYours(api, { getCurrent: async () => ({ userId: '1', isAnonymous: false }) }, (text) => toasts.push(text));
|
|
57
|
+
const state = { rows, hearts: ['d1'] };
|
|
58
|
+
client.frame(false, state, 100);
|
|
59
|
+
assert.equal(readCount, 0, 'no town, no command');
|
|
60
|
+
client.frame(true, state, 100);
|
|
61
|
+
await flush();
|
|
62
|
+
client.frame(true, state, 200);
|
|
63
|
+
assert.equal(readCount, 1, 'one read per visit');
|
|
64
|
+
assert.equal(client.ask(state, doors, ['p2'], 200).yes, 'Go together');
|
|
65
|
+
client.dismiss();
|
|
66
|
+
assert.equal(client.ask(state, doors, [], 300), null, 'once per visit');
|
|
67
|
+
client.returned('d0');
|
|
68
|
+
const solo = doors.map((d) => ({ ...d, solo: d.id === 'd0' }));
|
|
69
|
+
assert.equal(client.ask(state, solo, ['p2'], 300).yes, 'Go');
|
|
70
|
+
assert.equal(client.ask(state, solo, [], 300).heart, false);
|
|
71
|
+
assert.equal(client.ask(state, doors, [], 15301), null, '15s');
|
|
72
|
+
client.toggle('d0');
|
|
73
|
+
client.toggle('d2');
|
|
74
|
+
assert.deepEqual(client.controls().hearts, ['d1', 'd0', 'd2'], 'optimistic');
|
|
75
|
+
await flush();
|
|
76
|
+
assert.deepEqual(writes[0].ids, ['d1', 'd0']);
|
|
77
|
+
client.frame(true, { ...state, hearts: ['server-change'] }, 400);
|
|
78
|
+
assert.deepEqual(client.controls().hearts, ['d1', 'd0', 'd2'], 'snapshot during a write cannot undo queued optimistic hearts');
|
|
79
|
+
writes[0].reject(new Error('down'));
|
|
80
|
+
await flush();
|
|
81
|
+
assert.deepEqual(client.controls().hearts, ['d1', 'd2'], 'only failed toggle rolls back');
|
|
82
|
+
assert.deepEqual(writes[1].ids, ['d1', 'd2'], 'serialized after failure');
|
|
83
|
+
writes[1].resolve({ status: 'ok', hearts: ['d1', 'd2'] });
|
|
84
|
+
await flush();
|
|
85
|
+
assert.equal(toasts.length, 1);
|
|
86
|
+
client.frame(true, { ...state, hearts: ['d1'] }, 500);
|
|
87
|
+
assert.deepEqual(client.controls().hearts, ['d1', 'd2'], 'successful write stays authoritative over a stale snapshot');
|
|
88
|
+
client.frame(true, { ...state, hearts: ['d1', 'd2'] }, 600);
|
|
89
|
+
client.frame(true, { ...state, hearts: ['d0'] }, 700);
|
|
90
|
+
assert.deepEqual(client.controls().hearts, ['d1', 'd2'], 'a matching snapshot does not shorten the freshness window');
|
|
91
|
+
client.clear();
|
|
92
|
+
client.frame(true, state, 1000);
|
|
93
|
+
await flush();
|
|
94
|
+
assert.equal(readCount, 4, 'each toggle and the new visit read again');
|
|
95
|
+
for (const unavailable of [async () => { throw Object.assign(new Error(), { code: 'UNKNOWN_COMMAND' }); }, async () => ({ status: 'unavailable', hearts: [] })]) {
|
|
96
|
+
const old = makeYours({ hearts: unavailable }, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
97
|
+
old.frame(true, state, 0);
|
|
98
|
+
await flush();
|
|
99
|
+
assert.equal(old.controls(), null, 'old/unavailable host hides hearts');
|
|
100
|
+
}
|
|
101
|
+
const guest = makeYours(api, { getCurrent: async () => ({ userId: 'guest', isAnonymous: true }) }, () => {});
|
|
102
|
+
guest.frame(true, state, 0);
|
|
103
|
+
await flush();
|
|
104
|
+
assert.equal(readCount, 4, 'guest never asks hearts');
|
|
105
|
+
assert.equal(guest.ask(state, doors, [], 1), null);
|
|
106
|
+
assert.deepEqual(guest.rows(state, doors), []);
|
|
107
|
+
console.log('hub-game yours: rows, private latch, keyless no-read, visits, guests, old hosts, party/solo, optimistic queue passed');
|
|
108
|
+
|
|
109
|
+
// Late host/read answers must not repaint a newer visit, or hide a newly
|
|
110
|
+
// supported heart behind the ask card's unchanged key.
|
|
111
|
+
{
|
|
112
|
+
let finishRead;
|
|
113
|
+
const late = makeYours({ hearts: () => new Promise((resolve) => { finishRead = resolve; }) }, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
114
|
+
late.returned('d1');
|
|
115
|
+
late.frame(true, state, 100);
|
|
116
|
+
await flush();
|
|
117
|
+
const waiting = late.ask(state, doors, [], 200);
|
|
118
|
+
assert.equal(waiting.heart, undefined);
|
|
119
|
+
finishRead({ status: 'ok', hearts: ['d1'] });
|
|
120
|
+
await flush();
|
|
121
|
+
const ready = late.ask(state, doors, [], 200);
|
|
122
|
+
assert.equal(ready.heart, true);
|
|
123
|
+
assert.notEqual(ready.key, waiting.key, 'heart availability redraws the chip');
|
|
124
|
+
assert.notEqual(ready.key, late.ask(state, doors, ['party'], 200).key, 'party label redraws the chip');
|
|
125
|
+
late.frame(true, { ...state, hearts: ['old'] }, 300);
|
|
126
|
+
assert.deepEqual(late.controls().hearts, ['old'], 'later account snapshot is accepted without a matching confirmation');
|
|
127
|
+
const old = makeYours({ hearts: () => new Promise((resolve) => { finishRead = resolve; }) }, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
128
|
+
old.frame(true, state, 100);
|
|
129
|
+
await flush();
|
|
130
|
+
old.clear();
|
|
131
|
+
finishRead({ status: 'ok', hearts: ['d1'] });
|
|
132
|
+
await flush();
|
|
133
|
+
assert.equal(old.controls(), null, 'old visit read ignored');
|
|
134
|
+
}
|
|
135
|
+
console.log('hub-game yours late answers: host/read race, chip redraw, old visit isolation passed');
|
|
136
|
+
|
|
137
|
+
// Each toggle reads ghost, even when the display still has another tab's old
|
|
138
|
+
// list. Removing, adding and trimming all operate on that fresh list.
|
|
139
|
+
{
|
|
140
|
+
let ghost = ['d1'];
|
|
141
|
+
const calls = [];
|
|
142
|
+
const fresh = makeYours({
|
|
143
|
+
hearts: async () => { calls.push('read'); return { status: 'ok', hearts: [...ghost] }; },
|
|
144
|
+
setHearts: async (ids) => { calls.push([...ids]); ghost = ids; return { status: 'ok', hearts: ids }; },
|
|
145
|
+
}, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
146
|
+
fresh.frame(true, state, 0);
|
|
147
|
+
await flush();
|
|
148
|
+
ghost = ['d2', 'd3']; // Another tab changed ghost without a snapshot here.
|
|
149
|
+
fresh.toggle('d1');
|
|
150
|
+
assert.deepEqual(fresh.controls().hearts, [], 'optimistic display uses confirmed hearts');
|
|
151
|
+
await flush();
|
|
152
|
+
assert.deepEqual(ghost, ['d2', 'd3', 'd1'], 'toggle uses fresh membership and preserves unseen hearts from the other tab');
|
|
153
|
+
ghost = ['d2', 'd4', 'd5'];
|
|
154
|
+
fresh.toggle('d4');
|
|
155
|
+
await flush();
|
|
156
|
+
assert.deepEqual(ghost, ['d2', 'd5'], 'removal also preserves the other tab change');
|
|
157
|
+
ghost = Array.from({ length: 8 }, (_, i) => `d${i}`);
|
|
158
|
+
fresh.toggle('new');
|
|
159
|
+
await flush();
|
|
160
|
+
assert.deepEqual(ghost, ['d1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'new'], 'drop oldest from the fresh list, newest last');
|
|
161
|
+
assert.deepEqual(calls, ['read', 'read', ['d2', 'd3', 'd1'], 'read', ['d2', 'd5'], 'read', ghost], 'every write follows its own fresh read');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// A queued toggle cannot read until the previous write finishes. Its base is
|
|
165
|
+
// a new ghost read, and its optimistic display uses the setHearts response.
|
|
166
|
+
{
|
|
167
|
+
const reads = [], writes = [], toasts = [];
|
|
168
|
+
const queued = makeYours({
|
|
169
|
+
hearts: () => new Promise((resolve, reject) => reads.push({ resolve, reject })),
|
|
170
|
+
setHearts: (ids) => new Promise((resolve, reject) => writes.push({ ids, resolve, reject })),
|
|
171
|
+
}, { getCurrent: async () => ({ userId: '1' }) }, (text) => toasts.push(text));
|
|
172
|
+
queued.frame(true, state, 0);
|
|
173
|
+
await flush();
|
|
174
|
+
reads[0].resolve({ status: 'ok', hearts: ['d1'] });
|
|
175
|
+
await flush();
|
|
176
|
+
queued.toggle('d2');
|
|
177
|
+
queued.toggle('d3');
|
|
178
|
+
assert.equal(reads.length, 2, 'only the first queued toggle starts reading');
|
|
179
|
+
assert.equal(writes.length, 0, 'no write before its read completes');
|
|
180
|
+
queued.frame(true, { ...state, hearts: ['stale'] }, 100);
|
|
181
|
+
assert.deepEqual(queued.controls().hearts, ['d1', 'd2', 'd3'], 'snapshot cannot undo optimism while reading');
|
|
182
|
+
reads[1].resolve({ status: 'ok', hearts: ['d4'] });
|
|
183
|
+
await flush();
|
|
184
|
+
assert.deepEqual(writes[0].ids, ['d4', 'd2']);
|
|
185
|
+
assert.equal(reads.length, 2, 'next toggle still waits for the write');
|
|
186
|
+
writes[0].resolve({ status: 'ok', hearts: ['d4', 'd2', 'confirmed'] });
|
|
187
|
+
await flush();
|
|
188
|
+
assert.deepEqual(queued.controls().hearts, ['d4', 'd2', 'confirmed', 'd3'], 'response confirms the list, with the later toggle optimistic');
|
|
189
|
+
assert.equal(reads.length, 3, 'later toggle starts its own read after the write');
|
|
190
|
+
reads[2].resolve({ status: 'ok', hearts: ['d4', 'd2', 'd5'] });
|
|
191
|
+
await flush();
|
|
192
|
+
assert.deepEqual(writes[1].ids, ['d4', 'd2', 'd5', 'd3'], 'queued toggle preserves a change from another tab between writes');
|
|
193
|
+
writes[1].reject(new Error('down'));
|
|
194
|
+
await flush();
|
|
195
|
+
assert.deepEqual(queued.controls().hearts, ['d4', 'd2', 'confirmed'], 'failed write reverts to the last successful response, not the fresh read');
|
|
196
|
+
assert.deepEqual(toasts, ["Couldn't save that heart."]);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Stale snapshots during and after a write cannot undo its response. Retain
|
|
200
|
+
// the latest ignored snapshot and reconsider it on frames without new data.
|
|
201
|
+
{
|
|
202
|
+
let now = 0;
|
|
203
|
+
let ghost = ['d1'];
|
|
204
|
+
const writes = [], toasts = [];
|
|
205
|
+
const bounded = makeYours({
|
|
206
|
+
hearts: async () => ({ status: 'ok', hearts: [...ghost] }),
|
|
207
|
+
setHearts: (ids) => new Promise((resolve, reject) => writes.push({ ids, resolve, reject })),
|
|
208
|
+
}, { getCurrent: async () => ({ userId: '1' }) }, (text) => toasts.push(text), () => now);
|
|
209
|
+
bounded.frame(true, state, now);
|
|
210
|
+
await flush();
|
|
211
|
+
bounded.toggle('d2');
|
|
212
|
+
await flush();
|
|
213
|
+
const stale = { ...state };
|
|
214
|
+
now = 300000;
|
|
215
|
+
bounded.frame(true, stale, now);
|
|
216
|
+
assert.deepEqual(bounded.controls().hearts, ['d1', 'd2'], 'in-flight write blocks snapshots even without a freshness window');
|
|
217
|
+
ghost = ['d1', 'd2'];
|
|
218
|
+
writes[0].resolve({ status: 'ok', hearts: ghost });
|
|
219
|
+
await flush();
|
|
220
|
+
bounded.frame(true, stale, now);
|
|
221
|
+
assert.deepEqual(bounded.controls().hearts, ghost, 'buffered stale snapshot cannot replace the successful response');
|
|
222
|
+
bounded.frame(true, { ...state }, now);
|
|
223
|
+
assert.deepEqual(bounded.controls().hearts, ghost, 'new stale snapshot is ignored too');
|
|
224
|
+
bounded.frame(true, { ...state, hearts: ghost }, now);
|
|
225
|
+
bounded.frame(true, { ...state }, now);
|
|
226
|
+
assert.deepEqual(bounded.controls().hearts, ghost, 'matching snapshot does not release protection early');
|
|
227
|
+
bounded.toggle('d3');
|
|
228
|
+
await flush();
|
|
229
|
+
assert.deepEqual(writes[1].ids, ['d1', 'd2', 'd3']);
|
|
230
|
+
now = 360000;
|
|
231
|
+
ghost = ['d1', 'd2', 'd3'];
|
|
232
|
+
writes[1].resolve({ status: 'ok', hearts: ghost });
|
|
233
|
+
await flush();
|
|
234
|
+
now = 480000;
|
|
235
|
+
const otherTab = { ...state, hearts: ['d4'] };
|
|
236
|
+
bounded.frame(true, otherTab, now);
|
|
237
|
+
assert.deepEqual(bounded.controls().hearts, ghost, 'each success restarts the three-minute window');
|
|
238
|
+
bounded.toggle('d5');
|
|
239
|
+
await flush();
|
|
240
|
+
now = 510000;
|
|
241
|
+
writes[2].reject(new Error('down'));
|
|
242
|
+
await flush();
|
|
243
|
+
assert.deepEqual(bounded.controls().hearts, ghost, 'failure rolls back without extending the last success window');
|
|
244
|
+
now = 539999;
|
|
245
|
+
bounded.frame(true, otherTab, now);
|
|
246
|
+
assert.deepEqual(bounded.controls().hearts, ghost, 'latest other-tab snapshot stays buffered just before the bound');
|
|
247
|
+
now = 540000;
|
|
248
|
+
bounded.frame(true, null, now);
|
|
249
|
+
assert.deepEqual(bounded.controls().hearts, ['d4'], 'other tab appears at the bound without any new snapshot');
|
|
250
|
+
assert.deepEqual(toasts, ["Couldn't save that heart."]);
|
|
251
|
+
bounded.clear();
|
|
252
|
+
bounded.frame(true, { ...state, hearts: ['d6'] }, now);
|
|
253
|
+
await flush();
|
|
254
|
+
assert.deepEqual(bounded.controls().hearts, ['d6'], 'new visit clears the freshness window and old snapshot');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// A failed fresh read must not write at all, and either API's non-ok answer
|
|
258
|
+
// follows the same rollback path as rejection. Later queued toggles still run.
|
|
259
|
+
for (const failure of ['read-reject', 'read-unavailable', 'write-unavailable']) {
|
|
260
|
+
let readCount = 0;
|
|
261
|
+
const writes = [], toasts = [];
|
|
262
|
+
const failed = makeYours({
|
|
263
|
+
hearts: async () => {
|
|
264
|
+
readCount++;
|
|
265
|
+
if (readCount === 2 && failure === 'read-reject') {
|
|
266
|
+
throw new Error('down');
|
|
267
|
+
}
|
|
268
|
+
return { status: readCount === 2 && failure === 'read-unavailable' ? 'unavailable' : 'ok', hearts: ['d1'] };
|
|
269
|
+
},
|
|
270
|
+
setHearts: async (ids) => { writes.push(ids); return { status: failure === 'write-unavailable' && writes.length === 1 ? 'unavailable' : 'ok', hearts: ids }; },
|
|
271
|
+
}, { getCurrent: async () => ({ userId: '1' }) }, (text) => toasts.push(text));
|
|
272
|
+
failed.frame(true, state, 0);
|
|
273
|
+
await flush();
|
|
274
|
+
failed.toggle('d2');
|
|
275
|
+
await flush();
|
|
276
|
+
assert.deepEqual(failed.controls().hearts, ['d1'], `${failure} reverts to the last confirmed list`);
|
|
277
|
+
assert.equal(writes.length, failure === 'write-unavailable' ? 1 : 0, 'failed read cannot write');
|
|
278
|
+
assert.deepEqual(toasts, ["Couldn't save that heart."]);
|
|
279
|
+
failed.toggle('d3');
|
|
280
|
+
await flush();
|
|
281
|
+
assert.deepEqual(failed.controls().hearts, ['d1', 'd3'], 'later toggle can still save after a failure');
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Clearing a visit while its fresh read is pending must not send a late write.
|
|
285
|
+
{
|
|
286
|
+
const reads = [], writes = [], toasts = [];
|
|
287
|
+
const old = makeYours({
|
|
288
|
+
hearts: () => new Promise((resolve) => reads.push(resolve)),
|
|
289
|
+
setHearts: async (ids) => { writes.push(ids); return { status: 'ok', hearts: ids }; },
|
|
290
|
+
}, { getCurrent: async () => ({ userId: '1' }) }, (text) => toasts.push(text));
|
|
291
|
+
old.frame(true, state, 0);
|
|
292
|
+
await flush();
|
|
293
|
+
reads[0]({ status: 'ok', hearts: ['d1'] });
|
|
294
|
+
await flush();
|
|
295
|
+
old.toggle('d2');
|
|
296
|
+
old.clear();
|
|
297
|
+
old.frame(true, { ...state, hearts: ['d3'] }, 100);
|
|
298
|
+
await flush();
|
|
299
|
+
reads[2]({ status: 'ok', hearts: ['d3'] });
|
|
300
|
+
reads[1]({ status: 'ok', hearts: ['d1'] });
|
|
301
|
+
await flush();
|
|
302
|
+
assert.deepEqual(writes, [], 'old visit read never writes into the new visit');
|
|
303
|
+
assert.deepEqual(old.controls().hearts, ['d3']);
|
|
304
|
+
assert.deepEqual(toasts, []);
|
|
305
|
+
}
|
|
306
|
+
console.log('hub-game yours hearts: fresh read before every write, serialized queue, response confirmation, failure rollback, stale snapshots, buffered snapshot at 3-minute bound, visit isolation passed');
|
|
307
|
+
|
|
308
|
+
// Identity and rows can each take longer than the old 15-second arrival timer.
|
|
309
|
+
{
|
|
310
|
+
let identify;
|
|
311
|
+
const slow = makeYours({ hearts: async () => ({ status: 'ok', hearts: [] }) }, {
|
|
312
|
+
getCurrent: () => new Promise((resolve) => { identify = resolve; }),
|
|
313
|
+
}, () => {});
|
|
314
|
+
slow.frame(true, null, 100);
|
|
315
|
+
assert.equal(slow.ask(null, doors, [], 20100), null);
|
|
316
|
+
identify({ userId: '1' });
|
|
317
|
+
await flush();
|
|
318
|
+
slow.frame(true, null, 20100);
|
|
319
|
+
assert.equal(slow.ask(null, doors, [], 30100), null);
|
|
320
|
+
slow.frame(true, state, 40100);
|
|
321
|
+
assert.equal(slow.ask(state, doors, [], 40100).kind, 'yours');
|
|
322
|
+
assert.equal(slow.ask(state, doors, [], 55099).kind, 'yours', 'full 15 seconds from first display');
|
|
323
|
+
assert.equal(slow.ask(state, doors, [], 55100), null);
|
|
324
|
+
slow.frame(true, { ...state }, 56000);
|
|
325
|
+
assert.equal(slow.ask(state, doors, [], 56000), null, 'new rows do not reoffer');
|
|
326
|
+
|
|
327
|
+
const empty = makeYours({ hearts: async () => ({ status: 'ok', hearts: [] }) }, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
328
|
+
empty.frame(true, null, 0);
|
|
329
|
+
await flush();
|
|
330
|
+
empty.frame(true, null, 60000);
|
|
331
|
+
assert.equal(empty.ask(state, doors, [], 60000), null, 'give up after 60 seconds without data');
|
|
332
|
+
empty.frame(true, state, 61000);
|
|
333
|
+
assert.equal(empty.ask(state, doors, [], 61000), null, 'late rows cannot revive the arrival offer');
|
|
334
|
+
|
|
335
|
+
const blocked = makeYours({}, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
336
|
+
blocked.frame(true, state, 0);
|
|
337
|
+
await flush();
|
|
338
|
+
blocked.frame(true, state, 100);
|
|
339
|
+
// Higher-priority invitations/proposals do not call ask. Ready rows can wait.
|
|
340
|
+
blocked.frame(true, state, 70000);
|
|
341
|
+
assert.equal(blocked.ask(state, doors, [], 70000).kind, 'yours');
|
|
342
|
+
assert.equal(blocked.ask(state, doors, [], 84999).kind, 'yours');
|
|
343
|
+
assert.equal(blocked.ask(state, doors, [], 85000), null);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Local calendar days, including opposite UTC boundaries and DST transitions.
|
|
347
|
+
{
|
|
348
|
+
const originalTZ = process.env.TZ;
|
|
349
|
+
try {
|
|
350
|
+
process.env.TZ = 'Pacific/Honolulu';
|
|
351
|
+
assert.equal(relativeDay(Date.parse('2026-10-05T23:30:00Z'), Date.parse('2026-10-06T01:00:00Z')), 'today', 'same local date across UTC midnight');
|
|
352
|
+
assert.equal(relativeDay(Date.parse('2026-10-05T09:30:00Z'), Date.parse('2026-10-05T10:30:00Z')), 'yesterday', 'local midnight within one UTC day');
|
|
353
|
+
const local = makeYours({}, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
354
|
+
local.frame(true, state, 0);
|
|
355
|
+
await flush();
|
|
356
|
+
const formatted = local.rows(state, doors)[0];
|
|
357
|
+
assert.equal(formatted.line, `Best 9 points · ${relativeDay(rows[0].lastAt)}`);
|
|
358
|
+
assert.equal(local.ask(state, doors, [], 100).line, formatted.line, 'list and arrival chip use the same local wording');
|
|
359
|
+
assert.equal(relativeDay(null), '');
|
|
360
|
+
assert.equal(relativeDay(NaN), '');
|
|
361
|
+
assert.equal(rowsFor(doors, boards, { recent: [{ deckId: 'game-1', at: 'bad' }] }, [])[0].lastAt, null);
|
|
362
|
+
process.env.TZ = 'Asia/Tokyo';
|
|
363
|
+
assert.equal(relativeDay(Date.parse('2026-10-05T14:30:00Z'), Date.parse('2026-10-05T15:30:00Z')), 'yesterday');
|
|
364
|
+
process.env.TZ = 'America/Los_Angeles';
|
|
365
|
+
assert.equal(relativeDay(Date.parse('2026-03-08T08:30:00Z'), Date.parse('2026-03-09T07:30:00Z')), 'yesterday', '23-hour local calendar day');
|
|
366
|
+
assert.equal(relativeDay(Date.parse('2026-11-01T07:30:00Z'), Date.parse('2026-11-03T08:30:00Z')), '2 days ago', '49 hours span two local calendar days');
|
|
367
|
+
} finally {
|
|
368
|
+
if (originalTZ === undefined) delete process.env.TZ;
|
|
369
|
+
else process.env.TZ = originalTZ;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
console.log('hub-game yours regressions: delayed arrival, 60s bound, local calendar and DST passed');
|
|
@@ -127,6 +127,42 @@ because only the browser reads it.
|
|
|
127
127
|
"server": { "main": "imports/castle.multiplayer-3d/code/server/index.js" }
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
### Walk cadence option
|
|
131
|
+
|
|
132
|
+
Top-level `"gait": "model"` in the deck's own `castle.json` enables
|
|
133
|
+
physics-3d's scale-aware gait and remote speed hints from timestamped tracks
|
|
134
|
+
before pose smoothing (players and interpolated objects). Held poses target
|
|
135
|
+
zero; teleports are ignored. Hints are read by physics-3d versions that have
|
|
136
|
+
`engine3d/gait.js`; older physics-3d versions safely ignore them. Multiplayer-3d
|
|
137
|
+
reads the key independently and imports no physics-3d gait module. Without the
|
|
138
|
+
key the existing gait is unchanged.
|
|
139
|
+
|
|
140
|
+
### Ownership option
|
|
141
|
+
|
|
142
|
+
A deck may set `"multiplayer": { "eligibleClaims": true }` at the root of a
|
|
143
|
+
scene file. `code/options.js` checks the active `scene.data` on the client;
|
|
144
|
+
`server/world.js` reads that session's scene through `sceneBodies.sceneOptions`
|
|
145
|
+
and sets `sim.eligibleClaims` for `server/ownership.js`. Scene data already
|
|
146
|
+
travels in hub content packs, so entering this scene from a town enables the
|
|
147
|
+
option without enabling it for the town or other places. Only literal `true`
|
|
148
|
+
enables it; absent or false preserves the existing claims, grants, and wire messages.
|
|
149
|
+
|
|
150
|
+
With this option, client proximity asks include only actors whose resolved
|
|
151
|
+
`Body.type` is `dynamic`. Owned poses and releases still use the full object
|
|
152
|
+
list, including any owned body that no longer passes that filter. The server
|
|
153
|
+
skips unknown ids, unclaimable objects, this player's objects, and objects
|
|
154
|
+
outside reach before spending its eight candidate checks. A contested eligible
|
|
155
|
+
candidate still spends a check, even when the existing takeover rule refuses
|
|
156
|
+
it. Each message scans at most 256 ids: this bounds lookups and reach tests on
|
|
157
|
+
malformed or oversized requests while allowing a dense scene's ineligible
|
|
158
|
+
bodies to be skipped. Ids beyond that scan bound are ignored; repeated oversized lists can still
|
|
159
|
+
starve their tail.
|
|
160
|
+
Reach, nearest-owner priority, grant hold, epochs, and handovers are unchanged.
|
|
161
|
+
Temporary server claimability (such as a hub reset hold) stays server-side;
|
|
162
|
+
a dynamic actor may still be asked for during that hold. No new wire fields.
|
|
163
|
+
|
|
164
|
+
### Deck hooks
|
|
165
|
+
|
|
130
166
|
and then, all optional, all found by root-anchored glob in
|
|
131
167
|
`code/server/gameHooks.js`:
|
|
132
168
|
|
|
@@ -287,6 +323,20 @@ Map())` — and the next `showPlayer` respawns it.
|
|
|
287
323
|
|
|
288
324
|
## The name tags
|
|
289
325
|
|
|
326
|
+
Under the physics-3d orbit camera key only, the local player's `self` sprite
|
|
327
|
+
is registered in `scene.three.ownModelWith` (when that is a Set) and hides
|
|
328
|
+
for the same render as the own avatar when the camera is pressed close
|
|
329
|
+
(within 1 m, shown again past 1.2 m). nameTags.js keeps the set and the
|
|
330
|
+
sprite registered in a private WeakMap, so a replaced sprite or set is
|
|
331
|
+
swapped, disposal deletes the registered one without reading the world, and
|
|
332
|
+
a tag never registered is disposed reading nothing new. The engine restores
|
|
333
|
+
each object it hid only if it is still false and leaves already hidden
|
|
334
|
+
objects alone.
|
|
335
|
+
Without the key nothing is registered and nothing reads the set. Accepted: a
|
|
336
|
+
deck-defined `visible` setter on the sprite that throws on the restore and
|
|
337
|
+
rejects it leaves the sprite hidden; and `showSelf` reads the runtime's own
|
|
338
|
+
`cameraControl` field without the key too (the gate).
|
|
339
|
+
|
|
290
340
|
A `THREE.Sprite`'s apparent size is its world scale over its distance, so a fixed
|
|
291
341
|
scale is right at one distance and wrong everywhere else — the label covered a
|
|
292
342
|
large part of the card whenever a camera got close, which every camera in this
|
|
@@ -7,26 +7,26 @@
|
|
|
7
7
|
"imports": {
|
|
8
8
|
"castle.real-time": {
|
|
9
9
|
"deckId": "xFVr-afOLuUQ",
|
|
10
|
-
"version": "2026-10-
|
|
10
|
+
"version": "2026-10-07T03:43:17.687Z"
|
|
11
11
|
},
|
|
12
12
|
"castle.physics-3d": {
|
|
13
13
|
"deckId": "JH0SclbPVP0y",
|
|
14
|
-
"version": "2026-10-
|
|
14
|
+
"version": "2026-10-08T15:11:19.728Z"
|
|
15
15
|
},
|
|
16
16
|
"castle.physics-2d": {
|
|
17
17
|
"deckId": "ckRZGFW4iPrx",
|
|
18
|
-
"version": "2026-10-
|
|
18
|
+
"version": "2026-10-08T15:09:06.913Z",
|
|
19
19
|
"via": "castle.physics-3d"
|
|
20
20
|
},
|
|
21
21
|
"castle.base": {
|
|
22
22
|
"deckId": "yRcmH4_aYllE",
|
|
23
|
-
"version": "2026-10-
|
|
23
|
+
"version": "2026-10-08T10:40:20.107Z"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"autoUpdateWhenImported": true,
|
|
27
27
|
"deckId": "ZwA_P_-VO-Qh",
|
|
28
28
|
"cardId": "bvRmCzyUpt_a",
|
|
29
|
-
"publishedVersion": "2026-10-
|
|
29
|
+
"publishedVersion": "2026-10-08T15:11:55.914Z",
|
|
30
30
|
"main": "main.jsx",
|
|
31
31
|
"server": {
|
|
32
32
|
"main": "code/server/index.js",
|
|
@@ -230,6 +230,13 @@ function showTag(avatars, scene, key, username, transform, tagHeight) {
|
|
|
230
230
|
avatars.tags.set(key, tag);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
// Under the orbit camera key only, the own tag's sprite follows the own
|
|
234
|
+
// model's hide (physics-3d ownmodel.js); nameTags.js keeps the
|
|
235
|
+
// registration, swaps a replaced sprite and undoes it on disposal.
|
|
236
|
+
if (key === 'self' && scene.cameraControl === 'orbit') {
|
|
237
|
+
NameTags.registerOwnNameTag(tag, scene.three?.ownModelWith);
|
|
238
|
+
}
|
|
239
|
+
|
|
233
240
|
// A label's drawn size follows its distance to the camera (`nameTags.js`).
|
|
234
241
|
NameTags.moveNameTag(tag, transform, scene.three?.camera, tagHeight);
|
|
235
242
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Cadence follows timestamped network motion, before render-pose smoothing.
|
|
2
|
+
// Player poses have no wire velocity. Object samples may supply `velocity`.
|
|
3
|
+
const HOLD_MS = 250;
|
|
4
|
+
const PAUSE_MS = 250;
|
|
5
|
+
const STOP_SPEED = 0.05;
|
|
6
|
+
|
|
7
|
+
// Called once per active system frame. A resumed frame starts a new clock,
|
|
8
|
+
// matching the wall-clock pause reset in easeWalkSpeed.
|
|
9
|
+
export function walkFrameTime(frame, wall = performance.now()) {
|
|
10
|
+
const elapsed = wall - frame.wall;
|
|
11
|
+
frame.wall = wall;
|
|
12
|
+
return Number.isFinite(elapsed) && elapsed >= 0 && elapsed <= PAUSE_MS
|
|
13
|
+
? Math.max(0, Math.min(elapsed / 1000, 0.25)) : 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function segmentSpeed(before, after) {
|
|
17
|
+
if (!before || !after) {return 0;}
|
|
18
|
+
const span = (after.simMs - before.simMs) / 1000;
|
|
19
|
+
const distance = Math.hypot(...[0, 1, 2].map((i) => after.pose[i] - before.pose[i]));
|
|
20
|
+
if (!(span > 0) || !Number.isFinite(span) || !Number.isFinite(distance) || distance > 4) {return 0;}
|
|
21
|
+
const velocity = after.velocity;
|
|
22
|
+
const speed = velocity ? Math.hypot(velocity[0], velocity[2])
|
|
23
|
+
: Math.hypot(after.pose[0] - before.pose[0], after.pose[2] - before.pose[2]) / span;
|
|
24
|
+
return Number.isFinite(speed) ? speed : 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function trackWalkSpeed(track, at) {
|
|
28
|
+
const samples = track.samples;
|
|
29
|
+
if (!Number.isFinite(at) || samples.length < 2 || at <= samples[0].simMs) {return 0;}
|
|
30
|
+
const newest = samples.at(-1);
|
|
31
|
+
if (at > newest.simMs) {
|
|
32
|
+
const over = at - newest.simMs;
|
|
33
|
+
return segmentSpeed(samples.at(-2), newest) * Math.max(0, 1 - over / HOLD_MS);
|
|
34
|
+
}
|
|
35
|
+
// Same newest-first bracketing search as real-time's sampleAt.
|
|
36
|
+
for (let i = samples.length - 1; i > 0; i -= 1) {
|
|
37
|
+
const before = samples[i - 1];
|
|
38
|
+
const after = samples[i];
|
|
39
|
+
if (before.simMs <= at && at <= after.simMs) {
|
|
40
|
+
const span = after.simMs - before.simMs;
|
|
41
|
+
if (!(span > 0)) {return 0;}
|
|
42
|
+
// sampleAt draws linearly within this segment. Smoothing belongs in
|
|
43
|
+
// easeWalkSpeed: previous motion must not animate a stationary segment.
|
|
44
|
+
return segmentSpeed(before, after);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function easeWalkSpeed(speeds, id, track, at, dt, wall = performance.now()) {
|
|
51
|
+
const target = trackWalkSpeed(track, at);
|
|
52
|
+
const previous = speeds.get(id);
|
|
53
|
+
// Frame dt may be capped after a suspension. Use actual wall/render time
|
|
54
|
+
// and track identity so old motion cannot leak into a fresh or held pose.
|
|
55
|
+
const reset = !previous || previous.track !== track
|
|
56
|
+
|| !Number.isFinite(at) || !Number.isFinite(wall)
|
|
57
|
+
|| !Number.isFinite(previous.at) || !Number.isFinite(previous.wall)
|
|
58
|
+
|| at < previous.at || at - previous.at > 500
|
|
59
|
+
|| wall < previous.wall || wall - previous.wall > PAUSE_MS;
|
|
60
|
+
const ease = Number.isFinite(dt) && dt > 0 ? 1 - Math.exp(-dt / 0.1) : 0;
|
|
61
|
+
const eased = reset ? target : previous.speed + (target - previous.speed) * ease;
|
|
62
|
+
const speed = target === 0 && eased < STOP_SPEED ? 0 : eased;
|
|
63
|
+
speeds.set(id, { speed, track, at, wall });
|
|
64
|
+
return speed;
|
|
65
|
+
}
|
|
@@ -63,11 +63,44 @@ export function moveNameTag(tag, transform, camera, heightAbove = HEIGHT_ABOVE)
|
|
|
63
63
|
tag.sprite.scale.set(tag.width * scale, tag.height * scale, 1);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// The own tag's registration with physics-3d's `world.ownModelWith` (orbit
|
|
67
|
+
// camera key only): tag -> { set, sprite }. Kept here, off the tag, so a tag
|
|
68
|
+
// never registered is disposed without reading anything of it.
|
|
69
|
+
const ownRegistered = new WeakMap();
|
|
70
|
+
|
|
71
|
+
// Puts the tag's current sprite in `set` (the world's now), taking out
|
|
72
|
+
// what was registered before if either has changed. Called only under the
|
|
73
|
+
// orbit camera key.
|
|
74
|
+
export function registerOwnNameTag(tag, set) {
|
|
75
|
+
const had = ownRegistered.get(tag);
|
|
76
|
+
if (had && had.sprite === tag.sprite && had.set === set) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (had) {
|
|
80
|
+
had.set.delete(had.sprite);
|
|
81
|
+
ownRegistered.delete(tag);
|
|
82
|
+
}
|
|
83
|
+
if (set instanceof Set) {
|
|
84
|
+
set.add(tag.sprite);
|
|
85
|
+
ownRegistered.set(tag, { set, sprite: tag.sprite });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
66
89
|
// Remove a tag from the three.js scene and release its texture and material.
|
|
67
90
|
export function disposeNameTag(world, tag) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
91
|
+
try {
|
|
92
|
+
world.scene.remove(tag.sprite);
|
|
93
|
+
tag.sprite.material.map.dispose();
|
|
94
|
+
tag.sprite.material.dispose();
|
|
95
|
+
} finally {
|
|
96
|
+
// After the listeners those ran, so one that registered it again is
|
|
97
|
+
// undone too.
|
|
98
|
+
const own = ownRegistered.get(tag);
|
|
99
|
+
if (own) {
|
|
100
|
+
ownRegistered.delete(tag);
|
|
101
|
+
own.set.delete(own.sprite);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
71
104
|
}
|
|
72
105
|
|
|
73
106
|
// A logged-out player's name is `anonymous-user-<uuid>`. Drawn in full it is
|
|
@@ -78,6 +111,28 @@ export function shortName(username) {
|
|
|
78
111
|
return anon ? `anon-${anon[1].replace(/-/g, '').slice(-6)}` : (username ?? 'player');
|
|
79
112
|
}
|
|
80
113
|
|
|
114
|
+
// The tag's rounded plate as a path. CanvasRenderingContext2D.roundRect arrived
|
|
115
|
+
// in Safari 16; iOS 15 has none, and calling it there threw after join. The
|
|
116
|
+
// fallback traces the same outline, clockwise from the top left, with one
|
|
117
|
+
// quarter arc a corner.
|
|
118
|
+
export function platePath(ctx, width, height, radius) {
|
|
119
|
+
if (typeof ctx.roundRect === 'function') {
|
|
120
|
+
ctx.roundRect(0, 0, width, height, radius);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const r = Math.min(radius, width / 2, height / 2);
|
|
124
|
+
ctx.moveTo(r, 0);
|
|
125
|
+
ctx.lineTo(width - r, 0);
|
|
126
|
+
ctx.arc(width - r, r, r, -Math.PI / 2, 0);
|
|
127
|
+
ctx.lineTo(width, height - r);
|
|
128
|
+
ctx.arc(width - r, height - r, r, 0, Math.PI / 2);
|
|
129
|
+
ctx.lineTo(r, height);
|
|
130
|
+
ctx.arc(r, height - r, r, Math.PI / 2, Math.PI);
|
|
131
|
+
ctx.lineTo(0, r);
|
|
132
|
+
ctx.arc(r, r, r, Math.PI, Math.PI * 1.5);
|
|
133
|
+
ctx.closePath();
|
|
134
|
+
}
|
|
135
|
+
|
|
81
136
|
// Rasterize one display name into the canvas used as the sprite texture.
|
|
82
137
|
function drawLabel(text) {
|
|
83
138
|
const canvas = document.createElement('canvas');
|
|
@@ -92,7 +147,7 @@ function drawLabel(text) {
|
|
|
92
147
|
canvas.height = 68;
|
|
93
148
|
ctx.font = font;
|
|
94
149
|
ctx.fillStyle = 'rgba(12,12,16,0.72)';
|
|
95
|
-
ctx
|
|
150
|
+
platePath(ctx, width, 68, 16);
|
|
96
151
|
ctx.fill();
|
|
97
152
|
ctx.fillStyle = '#f2f2f5';
|
|
98
153
|
ctx.textBaseline = 'middle';
|