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,343 @@
|
|
|
1
|
+
// Per-viewer actor visibility (contract v1.62), real server and client hooks.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { register } from 'node:module';
|
|
5
|
+
|
|
6
|
+
const sceneStub = 'export const readScene = () => globalThis.__hubTestActors ?? [];';
|
|
7
|
+
const avatarsStub = 'export function dropMissing() {}';
|
|
8
|
+
register(
|
|
9
|
+
`data:text/javascript,${encodeURIComponent(`
|
|
10
|
+
import { readFile } from 'node:fs/promises';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
const stubs = {
|
|
13
|
+
'@imports/castle.multiplayer-3d/code/server/sceneBodies.js': 'data:text/javascript,${encodeURIComponent(sceneStub)}',
|
|
14
|
+
'@imports/castle.multiplayer-3d/code/client/avatars.js': 'data:text/javascript,${encodeURIComponent(avatarsStub)}',
|
|
15
|
+
'castle-web-sdk': ${JSON.stringify(new URL('./fixtures/sdk-stub.mjs', import.meta.url).href)},
|
|
16
|
+
};
|
|
17
|
+
export async function resolve(specifier, context, next) {
|
|
18
|
+
if (['pxmodel', 'optimize', 'look', 'lookbake'].some((m) => specifier === '@imports/castle.physics-3d/engine3d/' + m)) return { url: ${JSON.stringify(new URL('./fixtures/engine-models-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
19
|
+
if (specifier === '@imports/castle.physics-3d/engine3d/orbitlens.js') return { url: ${JSON.stringify(new URL('../../physics-3d/engine3d/orbitlens.js', import.meta.url).href)}, shortCircuit: true };
|
|
20
|
+
if (stubs[specifier]) {
|
|
21
|
+
return { url: stubs[specifier], shortCircuit: true };
|
|
22
|
+
}
|
|
23
|
+
return next(specifier, context);
|
|
24
|
+
}
|
|
25
|
+
// The hook layer reads the deck's castle.json through the bundler.
|
|
26
|
+
export async function load(url, context, next) {
|
|
27
|
+
if (url.endsWith('/code/client/hookLayer.js')) {
|
|
28
|
+
const source = await readFile(fileURLToPath(url), 'utf8');
|
|
29
|
+
return { format: 'module', source: source.replaceAll('import.meta.glob(', '(() => ({}))('), shortCircuit: true };
|
|
30
|
+
}
|
|
31
|
+
return next(url, context);
|
|
32
|
+
}
|
|
33
|
+
`)}`,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const { layer } = await import('../code/server/hub.js');
|
|
37
|
+
const hook = (await import('../code/client/hookLayer.js')).default;
|
|
38
|
+
const State = await import('../code/client/state.js');
|
|
39
|
+
const Vis = await import('../code/server/vis.js');
|
|
40
|
+
const { CONTRACT_VERSION } = await import('../code/server/manifest.js');
|
|
41
|
+
|
|
42
|
+
const actors = [
|
|
43
|
+
{ id: 'spawn', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } },
|
|
44
|
+
...Array.from({ length: 257 }, (_, i) => ({ id: `trophy-${i}`, components: {
|
|
45
|
+
Transform: { x: 2, y: 3, z: 4 }, Model: { file: 'models/trophy.pxmodel' },
|
|
46
|
+
} })),
|
|
47
|
+
];
|
|
48
|
+
function boot() {
|
|
49
|
+
const sent = [], enabled = [];
|
|
50
|
+
const players = [{ playerId: 'p1' }, { playerId: 'p2' }];
|
|
51
|
+
const session = { sessionId: 'test', players, send: (id, msg) => sent.push([id, msg]), broadcast: (msg) => sent.push(['all', msg]) };
|
|
52
|
+
const world = { timeMs: 0, scenePath: 'scenes/main.scene',
|
|
53
|
+
players: new Map(players.map(({ playerId }) => [playerId, { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } }])),
|
|
54
|
+
bodies: new Map([['trophy-0', { setEnabled: (value) => enabled.push(value) }]]) };
|
|
55
|
+
let hub;
|
|
56
|
+
globalThis.__hubTestActors = actors;
|
|
57
|
+
const server = layer({ server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Town' } }, { ready(ctx) { hub = ctx; } }, {}, () => true);
|
|
58
|
+
server.sceneFor(session);
|
|
59
|
+
server.ready(world);
|
|
60
|
+
const step = () => { server.place(world); server.step(world); };
|
|
61
|
+
const hello = (id, extra = {}) => server.message(session, { playerId: id }, { k: 'hub-hello', avatar: 0, ...extra });
|
|
62
|
+
return { sent, enabled, players, session, world, server, hub, step, hello };
|
|
63
|
+
}
|
|
64
|
+
const visibility = (r) => r.sent.filter(([, msg]) => msg.k === 'hub-vis');
|
|
65
|
+
const warnings = [];
|
|
66
|
+
const warn = console.warn, log = console.log;
|
|
67
|
+
console.warn = (...args) => warnings.push(args.join(' '));
|
|
68
|
+
console.log = () => {};
|
|
69
|
+
let passed = 0;
|
|
70
|
+
function test(name, fn) {
|
|
71
|
+
try {
|
|
72
|
+
State.clear();
|
|
73
|
+
warnings.length = 0;
|
|
74
|
+
fn();
|
|
75
|
+
passed += 1;
|
|
76
|
+
log(`ok: ${name}`);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.warn = warn;
|
|
79
|
+
console.log = log;
|
|
80
|
+
console.error(`FAIL: ${name}`);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Captured from the pre-v1.62 server, including the order of every wire key.
|
|
86
|
+
function sharedWire(r) {
|
|
87
|
+
const out = [];
|
|
88
|
+
const capture = () => out.push([r.server.join(), r.server.delta(), r.sent.splice(0)]);
|
|
89
|
+
capture();
|
|
90
|
+
r.step(); capture();
|
|
91
|
+
assert.equal(r.hub.hide('trophy-0'), undefined);
|
|
92
|
+
r.step(); capture();
|
|
93
|
+
assert.equal(r.hub.show('trophy-0'), undefined);
|
|
94
|
+
r.step(); capture();
|
|
95
|
+
r.step(); capture();
|
|
96
|
+
return JSON.stringify(out);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
test('shared-only snapshots, deltas and messages are byte-identical to v1.61', () => {
|
|
100
|
+
assert.equal(CONTRACT_VERSION, 1, 'optional v1.62 keeps the manifest/wire major');
|
|
101
|
+
const r = boot();
|
|
102
|
+
const wire = sharedWire(r);
|
|
103
|
+
assert.equal(wire, readFileSync(new URL('./fixtures/vis-shared-wire.json', import.meta.url), 'utf8').trim());
|
|
104
|
+
assert.ok(!wire.includes('hub-vis'));
|
|
105
|
+
assert.deepEqual(r.enabled, [false, true]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('private overrides reach only named connected viewers, without shared changes', () => {
|
|
109
|
+
const r = boot();
|
|
110
|
+
const before = JSON.stringify(r.server.join());
|
|
111
|
+
assert.equal(r.hub.hide('trophy-0', { to: ['p1', 'missing', 'p1'] }), true);
|
|
112
|
+
assert.equal(r.hub.show('trophy-1', { to: ['p1'] }), true);
|
|
113
|
+
r.step();
|
|
114
|
+
assert.deepEqual(visibility(r), [['p1', { k: 'hub-vis', hide: ['trophy-0'], show: ['trophy-1'] }]]);
|
|
115
|
+
assert.equal(JSON.stringify(r.server.join()), before);
|
|
116
|
+
assert.deepEqual(r.enabled, [], 'private visibility does not toggle bodies');
|
|
117
|
+
const count = visibility(r).length;
|
|
118
|
+
r.step();
|
|
119
|
+
r.hub.hide('trophy-0', { to: ['p1'] });
|
|
120
|
+
r.step();
|
|
121
|
+
assert.equal(visibility(r).length, count, 'equal override sets are suppressed');
|
|
122
|
+
r.session.players = [r.players[1]];
|
|
123
|
+
assert.equal(r.hub.hide('trophy-2', { to: ['p1'] }), true);
|
|
124
|
+
r.step();
|
|
125
|
+
assert.equal(visibility(r).length, count, 'disconnected viewers are ignored, even with a stale sim body');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('private calls leave snapshot and delta bytes identical to the shared-only place', () => {
|
|
129
|
+
const shared = boot(), privateView = boot();
|
|
130
|
+
for (const op of ['hide', 'show', 'hide']) {
|
|
131
|
+
shared.hub[op]('trophy-0');
|
|
132
|
+
privateView.hub[op]('trophy-0');
|
|
133
|
+
privateView.hub.show('trophy-0', { to: ['p1'] });
|
|
134
|
+
privateView.hub.hide('trophy-1', { to: ['p2'] });
|
|
135
|
+
shared.step(); privateView.step();
|
|
136
|
+
assert.equal(JSON.stringify(privateView.server.join()), JSON.stringify(shared.server.join()));
|
|
137
|
+
assert.equal(JSON.stringify(privateView.server.delta()), JSON.stringify(shared.server.delta()));
|
|
138
|
+
assert.deepEqual(privateView.sent.filter(([, msg]) => msg.k !== 'hub-vis'), shared.sent);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('clear via either operation restores the current shared state and sends one empty set', () => {
|
|
143
|
+
for (const op of ['hide', 'show']) {
|
|
144
|
+
const r = boot();
|
|
145
|
+
r.hub.hide('trophy-0');
|
|
146
|
+
r.hub.show('trophy-0', { to: ['p1'] });
|
|
147
|
+
r.hub.hide('trophy-1', { to: ['p1'] });
|
|
148
|
+
r.step();
|
|
149
|
+
for (const [, msg] of visibility(r)) { hook.message({}, msg); }
|
|
150
|
+
hook.state({}, { hidden: r.server.join().hidden });
|
|
151
|
+
assert.deepEqual([...State.hub.hidden], ['trophy-1']);
|
|
152
|
+
assert.equal(r.hub[op]('trophy-0', { to: ['p1'], clear: true }), true);
|
|
153
|
+
r.step();
|
|
154
|
+
hook.message({}, visibility(r).at(-1)[1]);
|
|
155
|
+
assert.deepEqual([...State.hub.hidden].sort(), ['trophy-0', 'trophy-1']);
|
|
156
|
+
r.hub[op]('trophy-1', { to: ['p1'], clear: true });
|
|
157
|
+
r.step();
|
|
158
|
+
assert.deepEqual(visibility(r).at(-1), ['p1', { k: 'hub-vis', hide: [], show: [] }]);
|
|
159
|
+
hook.message({}, visibility(r).at(-1)[1]);
|
|
160
|
+
assert.deepEqual([...State.hub.hidden], ['trophy-0']);
|
|
161
|
+
const count = visibility(r).length;
|
|
162
|
+
r.hub[op]('trophy-1', { to: ['p1'], clear: true });
|
|
163
|
+
r.step();
|
|
164
|
+
assert.equal(visibility(r).length, count);
|
|
165
|
+
State.clear();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('fresh hello replays overrides, avatar-only hello does not, unused/cleared joins send nothing', () => {
|
|
170
|
+
const r = boot();
|
|
171
|
+
r.hello('p1');
|
|
172
|
+
assert.deepEqual(visibility(r), []);
|
|
173
|
+
r.hub.hide('trophy-0', { to: ['p1'] });
|
|
174
|
+
r.step();
|
|
175
|
+
r.sent.length = 0;
|
|
176
|
+
r.hello('p2');
|
|
177
|
+
r.hello('p1', { again: true });
|
|
178
|
+
assert.deepEqual(visibility(r), []);
|
|
179
|
+
r.hello('p1');
|
|
180
|
+
assert.deepEqual(visibility(r), [['p1', { k: 'hub-vis', hide: ['trophy-0'], show: [] }]]);
|
|
181
|
+
r.step();
|
|
182
|
+
assert.equal(visibility(r).length, 1, 'replay also updates the send cache');
|
|
183
|
+
r.hub.show('trophy-0', { to: ['p1'], clear: true });
|
|
184
|
+
r.step();
|
|
185
|
+
r.sent.length = 0;
|
|
186
|
+
r.hello('p1');
|
|
187
|
+
r.step();
|
|
188
|
+
assert.deepEqual(visibility(r), []);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('departure drops overrides, even ones created before hello; another viewer keeps theirs', () => {
|
|
192
|
+
for (const saidHello of [false, true]) {
|
|
193
|
+
const r = boot();
|
|
194
|
+
if (saidHello) { r.hello('p1'); }
|
|
195
|
+
r.hub.hide('trophy-0', { to: ['p1', 'p2'] });
|
|
196
|
+
r.step();
|
|
197
|
+
r.sent.length = 0;
|
|
198
|
+
r.session.players = [r.players[1]];
|
|
199
|
+
r.world.players.delete('p1');
|
|
200
|
+
r.step();
|
|
201
|
+
assert.deepEqual(visibility(r), []);
|
|
202
|
+
r.session.players = r.players;
|
|
203
|
+
r.world.players.set('p1', { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } });
|
|
204
|
+
r.hello('p1');
|
|
205
|
+
r.step();
|
|
206
|
+
assert.deepEqual(visibility(r), []);
|
|
207
|
+
r.hello('p2');
|
|
208
|
+
assert.deepEqual(visibility(r), [['p2', { k: 'hub-vis', hide: ['trophy-0'], show: [] }]]);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('invalid actors and malformed options warn once per kind and change nothing', () => {
|
|
213
|
+
const r = boot();
|
|
214
|
+
r.hub.hide('trophy-0', { to: ['p1'] });
|
|
215
|
+
r.step();
|
|
216
|
+
const before = JSON.stringify(r.server.join());
|
|
217
|
+
for (const op of ['hide', 'show']) {
|
|
218
|
+
for (const actor of ['missing', null, 42, {}]) {
|
|
219
|
+
assert.equal(r.hub[op](actor, { to: ['p1'] }), false);
|
|
220
|
+
}
|
|
221
|
+
for (const options of [null, false, [], {}, { to: 'p1' }, { to: ['p1', 42] }, { to: ['p1'], clear: 1 },
|
|
222
|
+
Object.defineProperty({}, 'to', { get() { throw Error('bad getter'); } })]) {
|
|
223
|
+
assert.equal(r.hub[op]('trophy-1', options), false);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
assert.equal(warnings.filter((msg) => msg.includes('not an actor')).length, 2);
|
|
227
|
+
assert.equal(warnings.filter((msg) => msg.includes('visibility options')).length, 2);
|
|
228
|
+
r.step();
|
|
229
|
+
assert.equal(visibility(r).length, 1);
|
|
230
|
+
assert.equal(JSON.stringify(r.server.join()), before);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test('256 per viewer; refusal is atomic, replacement/clear works, other viewer has their own cap', () => {
|
|
234
|
+
const r = boot();
|
|
235
|
+
for (let i = 0; i < 256; i += 1) {
|
|
236
|
+
assert.equal(r.hub.hide(`trophy-${i}`, { to: ['p1'] }), true);
|
|
237
|
+
}
|
|
238
|
+
r.step();
|
|
239
|
+
assert.equal(visibility(r).at(-1)[1].hide.length, 256);
|
|
240
|
+
assert.equal(r.hub.hide('trophy-256', { to: ['p2', 'p1'] }), false);
|
|
241
|
+
assert.equal(r.hub.show('trophy-256', { to: ['p1'] }), false);
|
|
242
|
+
r.step();
|
|
243
|
+
assert.equal(visibility(r).length, 1, 'failed multi-recipient call did not change p2');
|
|
244
|
+
assert.equal(warnings.filter((msg) => msg.includes('at most 256')).length, 1);
|
|
245
|
+
assert.equal(r.hub.show('trophy-0', { to: ['p1'] }), true);
|
|
246
|
+
assert.equal(r.hub.show('trophy-0', { to: ['p1'], clear: true }), true);
|
|
247
|
+
assert.equal(r.hub.hide('trophy-256', { to: ['p1', 'p2'] }), true);
|
|
248
|
+
r.step();
|
|
249
|
+
assert.deepEqual(visibility(r).at(-1), ['p2', { k: 'hub-vis', hide: ['trophy-256'], show: [] }]);
|
|
250
|
+
assert.equal(visibility(r).at(-2)[1].hide.length, 256);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('unchanged effective override set sends nothing, including clear/reinsert ordering', () => {
|
|
254
|
+
const r = boot();
|
|
255
|
+
r.hub.hide('trophy-1', { to: ['p1'] });
|
|
256
|
+
r.hub.hide('trophy-0', { to: ['p1'] });
|
|
257
|
+
r.step();
|
|
258
|
+
r.hub.show('trophy-1', { to: ['p1'], clear: true });
|
|
259
|
+
r.hub.hide('trophy-1', { to: ['p1'] });
|
|
260
|
+
r.step();
|
|
261
|
+
assert.equal(visibility(r).length, 1);
|
|
262
|
+
const h = { actors, spawned: new Map(), session: r.session };
|
|
263
|
+
Vis.joinedAfresh(h, 'p1');
|
|
264
|
+
Vis.prune(h); Vis.send(h); Vis.forget(h, 'p1');
|
|
265
|
+
assert.deepEqual(Object.keys(h), ['actors', 'spawned', 'session'], 'unused place allocates no visibility maps');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test('a despawned copy drops its private overrides and frees the slot', () => {
|
|
269
|
+
actors.push({ id: 'crate', components: { Transform: { x: 1, y: 0.5, z: 1 }, Shape: { kind: 'box', width: 1, height: 1, depth: 1, color: '#888888' } } });
|
|
270
|
+
let r, id;
|
|
271
|
+
try {
|
|
272
|
+
r = boot();
|
|
273
|
+
id = r.hub.spawn('crate', { x: 1, y: 0.5, z: 2 });
|
|
274
|
+
} finally {
|
|
275
|
+
actors.pop();
|
|
276
|
+
}
|
|
277
|
+
assert.equal(typeof id, 'string', `spawned a copy (${JSON.stringify(id)}; ${warnings.join(' | ')})`);
|
|
278
|
+
assert.equal(r.hub.hide(id, { to: ['p1'] }), true);
|
|
279
|
+
r.step();
|
|
280
|
+
assert.deepEqual(visibility(r).at(-1), ['p1', { k: 'hub-vis', hide: [id], show: [] }]);
|
|
281
|
+
r.hub.despawn(id);
|
|
282
|
+
r.step();
|
|
283
|
+
assert.deepEqual(visibility(r).at(-1), ['p1', { k: 'hub-vis', hide: [], show: [] }]);
|
|
284
|
+
for (let i = 0; i < 256; i += 1) {
|
|
285
|
+
assert.equal(r.hub.hide(`trophy-${i}`, { to: ['p1'] }), true, 'the despawned copy holds no slot');
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('real client state merges shared hidden with private show/hide in either arrival order', () => {
|
|
290
|
+
for (const privateFirst of [false, true]) {
|
|
291
|
+
State.clear();
|
|
292
|
+
const shared = () => hook.state({}, { hidden: ['trophy-0'] });
|
|
293
|
+
const privateView = () => hook.message({}, { k: 'hub-vis', hide: ['trophy-1'], show: ['trophy-0'] });
|
|
294
|
+
if (privateFirst) { privateView(); shared(); } else { shared(); privateView(); }
|
|
295
|
+
assert.deepEqual([...State.hub.hidden], ['trophy-1']);
|
|
296
|
+
hook.state({}, { hidden: [] });
|
|
297
|
+
assert.deepEqual([...State.hub.hidden], ['trophy-1']);
|
|
298
|
+
hook.state({}, { hidden: ['trophy-0', 'trophy-2'] });
|
|
299
|
+
assert.deepEqual([...State.hub.hidden].sort(), ['trophy-1', 'trophy-2']);
|
|
300
|
+
State.clear();
|
|
301
|
+
for (const key of ['hidden', 'hiddenAll', 'hiddenMe', 'shownMe']) { assert.equal(State.hub[key].size, 0); }
|
|
302
|
+
hook.state({}, { hidden: ['trophy-0'] });
|
|
303
|
+
assert.deepEqual([...State.hub.hidden], ['trophy-0'], 'scene/place/leave reset retains no show override');
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test('drawing re-applies both transitions from merged changes, including Models and static actors', () => {
|
|
308
|
+
// Extract the production method, as the lifecycle tests do, avoiding the
|
|
309
|
+
// full UI runtime. The same method runs both each frame and after behaviors.
|
|
310
|
+
const source = readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
311
|
+
const method = source.slice(source.indexOf(' applyVisibility(scene) {'), source.indexOf('\n // Copies the place spawned'));
|
|
312
|
+
const apply = new Function('Hub', 'HIDE_DROP_M', `return ({${method}}).applyVisibility;`)(State, 10000);
|
|
313
|
+
const actor = structuredClone(actors[1]);
|
|
314
|
+
const touches = [];
|
|
315
|
+
const scene = { getActor: (id) => id === actor.id ? actor : null, touch: (id) => touches.push(id) };
|
|
316
|
+
const drawing = { stash: new Map() };
|
|
317
|
+
const frame = () => apply.call(drawing, scene);
|
|
318
|
+
hook.state({}, { hidden: [actor.id] });
|
|
319
|
+
frame(); frame();
|
|
320
|
+
assert.equal(actor.components.Transform.y, -9997);
|
|
321
|
+
hook.message({}, { k: 'hub-vis', hide: [], show: [actor.id] });
|
|
322
|
+
frame(); frame();
|
|
323
|
+
assert.equal(actor.components.Transform.y, 3);
|
|
324
|
+
hook.message({}, { k: 'hub-vis', hide: [], show: [] });
|
|
325
|
+
frame();
|
|
326
|
+
assert.equal(actor.components.Transform.y, -9997);
|
|
327
|
+
hook.state({}, { hidden: [] });
|
|
328
|
+
frame();
|
|
329
|
+
assert.equal(actor.components.Transform.y, 3);
|
|
330
|
+
hook.message({}, { k: 'hub-vis', hide: [actor.id], show: [] });
|
|
331
|
+
frame();
|
|
332
|
+
assert.equal(actor.components.Transform.y, -9997);
|
|
333
|
+
hook.message({}, { k: 'hub-vis', hide: [], show: [] });
|
|
334
|
+
frame();
|
|
335
|
+
assert.equal(actor.components.Transform.y, 3);
|
|
336
|
+
assert.equal(touches.length, 6, 'each transition touches the static actor, repeated frames do not');
|
|
337
|
+
assert.equal(drawing.stash.size, 0);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
console.warn = warn;
|
|
341
|
+
console.log = log;
|
|
342
|
+
State.clear();
|
|
343
|
+
console.log(`test-vis: ${passed} passed`);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// v1.91: visibility crosses the real client helper / layer message boundary.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { register } from 'node:module';
|
|
4
|
+
|
|
5
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
6
|
+
export async function resolve(specifier, context, next) {
|
|
7
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/server/sceneBodies.js') return { url: 'data:text/javascript,export const readScene = () => globalThis.__hubTestActors;', shortCircuit: true };
|
|
8
|
+
if (context.parentURL?.includes('/kits/base/sdk/') && specifier.startsWith('.') && !specifier.endsWith('.js')) return next(specifier + '.js', context);
|
|
9
|
+
return next(specifier, context);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
`)}`);
|
|
13
|
+
const { layer } = await import('../code/server/hub.js');
|
|
14
|
+
const Manifest = await import('../code/server/manifest.js');
|
|
15
|
+
const actors = [
|
|
16
|
+
{ id: 'player', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } },
|
|
17
|
+
{ id: 'floor', components: { Transform: { x: 0, y: 0, z: 0 } } },
|
|
18
|
+
];
|
|
19
|
+
const players = [
|
|
20
|
+
{ playerId: 'p1', userId: '101', username: 'Ada', isAnonymous: false },
|
|
21
|
+
{ playerId: 'p2', userId: '102', username: 'Bo', isAnonymous: false },
|
|
22
|
+
];
|
|
23
|
+
const json = (keys = {}) => ({ server: { maxPlayers: 8 }, hub: { contract: 1, title: 'House', ...keys } });
|
|
24
|
+
function boot(keys = {}, options = {}) {
|
|
25
|
+
const sent = [], ops = [], arrivals = [];
|
|
26
|
+
let hub;
|
|
27
|
+
const hooks = { ready(ctx) { hub = ctx; }, arrive(ctx, group) { arrivals.push([ctx.owner ?? null, group.map((p) => p.playerId)]); }, action(ctx, id, actionId) { ops.push([id, actionId]); }, ...(options.hooks ?? {}) };
|
|
28
|
+
const bodies = [];
|
|
29
|
+
const engine = {
|
|
30
|
+
createBody(sim, actor, at) {
|
|
31
|
+
const rb = { at: { ...at }, setEnabled() {}, setNextKinematicTranslation(at) { this.at = { ...at }; }, setNextKinematicRotation() {} };
|
|
32
|
+
bodies.push([actor.id, rb]);
|
|
33
|
+
return rb;
|
|
34
|
+
},
|
|
35
|
+
removeActor(sim, id) { sim.bodies.delete(id); sim.objects.delete(id); },
|
|
36
|
+
};
|
|
37
|
+
globalThis.__hubTestActors = structuredClone(actors);
|
|
38
|
+
const server = layer(json(keys), hooks, {}, () => true, () => null, null, engine);
|
|
39
|
+
const session = { sessionId: options.sessionId ?? 'dev', players: [...players], hub: options.platform ?? null, send(id, msg) { sent.push([id, structuredClone(msg)]); }, broadcast(msg) { sent.push(['all', structuredClone(msg)]); } };
|
|
40
|
+
const world = { timeMs: 0, scenePath: 'scenes/main.scene', objects: new Map(), bodies: new Map(), players: new Map(players.map((p) => [p.playerId, { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } }])) };
|
|
41
|
+
server.sceneFor(session);
|
|
42
|
+
server.ready(world);
|
|
43
|
+
const say = (id, data) => server.message(session, { playerId: id }, data);
|
|
44
|
+
if (options.hello !== false) {
|
|
45
|
+
for (const id of options.order ?? ['p1', 'p2']) {
|
|
46
|
+
say(id, { k: 'hub-hello', avatar: 0, party: 2 });
|
|
47
|
+
}
|
|
48
|
+
server.place(world);
|
|
49
|
+
}
|
|
50
|
+
const tick = (ms = 50) => { world.timeMs += ms; server.place(world); server.step(world, []); };
|
|
51
|
+
return { server, session, world, hub, sent, ops, say, tick, bodies, arrivals, hooks };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { makeVisibility } = await import('../code/client/visibility.js');
|
|
55
|
+
for (const named of [false, true]) {
|
|
56
|
+
for (const value of [true, false, null, 1, 'true', {}]) {
|
|
57
|
+
const keys = named ? { places: { porch: { title: 'Porch', scene: 'scenes/porch.scene', visibility: value } } } : { visibility: value };
|
|
58
|
+
const read = Manifest.readManifest(json(keys));
|
|
59
|
+
assert.equal(read.errors.some((e) => e.includes('.visibility')), value !== true);
|
|
60
|
+
if (value === true) assert.equal(Manifest.publicPlace(named ? 'porch' : 'main', read.manifest.places[named ? 'porch' : 'main']).visibility, true);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const old = Manifest.readManifest(json()).manifest.places.main;
|
|
64
|
+
assert(!Object.hasOwn(old, 'visibility'));
|
|
65
|
+
assert(!Object.hasOwn(Manifest.publicPlace('main', old), 'visibility'));
|
|
66
|
+
const doc = new EventTarget();
|
|
67
|
+
doc.visibilityState = 'visible';
|
|
68
|
+
let at = 1000;
|
|
69
|
+
const received = [];
|
|
70
|
+
const r = boot({ visibility: true }, { hooks: { visibility(hub, info) { received.push(info); } } });
|
|
71
|
+
const net = { send: (data) => r.say('p1', data) };
|
|
72
|
+
const client = makeVisibility(doc, () => ++at);
|
|
73
|
+
client.sync(net, 'main', true);
|
|
74
|
+
assert.deepEqual(received, [{ playerId: 'p1', visible: true, at: 1001 }]);
|
|
75
|
+
for (const visible of [false, false, true, true]) {
|
|
76
|
+
doc.visibilityState = visible ? 'visible' : 'hidden';
|
|
77
|
+
doc.dispatchEvent(new Event('visibilitychange'));
|
|
78
|
+
}
|
|
79
|
+
assert.deepEqual(received, [{ playerId: 'p1', visible: true, at: 1001 }, { playerId: 'p1', visible: false, at: 1002 }, { playerId: 'p1', visible: true, at: 1003 }]);
|
|
80
|
+
// No other player can be named, malformed and stale events do nothing.
|
|
81
|
+
r.say('p1', { k: 'hub-visibility', playerId: 'p2', visible: false, at: 1004 });
|
|
82
|
+
assert.equal(received.at(-1).playerId, 'p1');
|
|
83
|
+
for (const data of [{ visible: true, at: NaN }, { visible: 1, at: 1004 }, { visible: true, at: -1 }, { visible: true, at: 999 }]) r.say('p1', { k: 'hub-visibility', ...data });
|
|
84
|
+
r.say('stranger', { k: 'hub-visibility', visible: false, at: 1005 });
|
|
85
|
+
assert.equal(received.length, 4);
|
|
86
|
+
let earlyCalls = 0;
|
|
87
|
+
const beforeHello = boot({ visibility: true }, { hello: false, hooks: { visibility() { earlyCalls++; } } });
|
|
88
|
+
beforeHello.say('p1', { k: 'hub-visibility', visible: false, at: 1005 });
|
|
89
|
+
assert.equal(earlyCalls, 0);
|
|
90
|
+
beforeHello.say('p1', { k: 'hub-hello', avatar: 0, party: 1 });
|
|
91
|
+
beforeHello.say('p1', { k: 'hub-visibility', visible: false, at: 1006 });
|
|
92
|
+
assert.equal(earlyCalls, 0, 'queued until deck arrival');
|
|
93
|
+
beforeHello.tick();
|
|
94
|
+
assert.equal(earlyCalls, 1, 'initial hidden delivered after arrival');
|
|
95
|
+
beforeHello.tick(); assert.equal(earlyCalls, 1);
|
|
96
|
+
// Retained re-hello still works; the next visible transition reaches the hook.
|
|
97
|
+
r.say('p1', { k: 'hub-hello', avatar: 0, resume: true }); r.tick();
|
|
98
|
+
r.say('p1', { k: 'hub-visibility', visible: true, at: 1006 });
|
|
99
|
+
assert.equal(received.at(-1).visible, true);
|
|
100
|
+
client.sync(net, 'door', false);
|
|
101
|
+
doc.visibilityState = 'hidden'; doc.dispatchEvent(new Event('visibilitychange'));
|
|
102
|
+
assert.equal(received.length, 5, 'off removes the listener');
|
|
103
|
+
// Absent flag: no DOM reads/listeners or extra fields/messages, even with hook.
|
|
104
|
+
const noDom = new Proxy({}, { get() { throw Error('absent must not touch document'); } });
|
|
105
|
+
makeVisibility(noDom).sync(net, 'main', false);
|
|
106
|
+
const off = boot({}, { hooks: { visibility() { throw Error('absent must not dispatch hook'); } } });
|
|
107
|
+
off.say('p1', { k: 'hub-visibility', visible: false, at: 1007 });
|
|
108
|
+
assert.deepEqual(off.sent, boot().sent, 'no opt-in: original wire bytes');
|
|
109
|
+
// Changes while disconnected are coalesced and sent once on the next sync.
|
|
110
|
+
let closed = true;
|
|
111
|
+
const deferred = [];
|
|
112
|
+
const recovering = makeVisibility(doc, () => ++at);
|
|
113
|
+
const recoveringNet = { closed: () => closed, send: (data) => deferred.push(data) };
|
|
114
|
+
recovering.sync(recoveringNet, 'main', true);
|
|
115
|
+
doc.dispatchEvent(new Event('visibilitychange')); assert.equal(deferred.length, 0);
|
|
116
|
+
closed = false; recovering.sync(recoveringNet, 'main', true);
|
|
117
|
+
recovering.sync(recoveringNet, 'main', true); assert.equal(deferred.length, 1);
|
|
118
|
+
assert.equal(deferred[0].visible, false);
|
|
119
|
+
recovering.sync(null, null, false);
|
|
120
|
+
// A visible remount reports visible even though its predecessor was hidden.
|
|
121
|
+
const mounted = [];
|
|
122
|
+
const remount = boot({ visibility: true }, { hooks: { visibility(hub, info) { mounted.push(info.visible); } } });
|
|
123
|
+
const remountNet = { send: data => remount.say('p1', data) };
|
|
124
|
+
const hiddenDoc = new EventTarget(); hiddenDoc.visibilityState = 'hidden';
|
|
125
|
+
const firstClient = makeVisibility(hiddenDoc, () => ++at);
|
|
126
|
+
firstClient.sync(remountNet, 'main', true); firstClient.sync(null, null, false);
|
|
127
|
+
const shownDoc = new EventTarget(); shownDoc.visibilityState = 'visible';
|
|
128
|
+
const secondClient = makeVisibility(shownDoc, () => ++at);
|
|
129
|
+
secondClient.sync(remountNet, 'main', true);
|
|
130
|
+
assert.deepEqual(mounted, [false, true]);
|
|
131
|
+
secondClient.sync(null, null, false);
|
|
132
|
+
shownDoc.visibilityState = 'hidden'; shownDoc.dispatchEvent(new Event('visibilitychange'));
|
|
133
|
+
assert.deepEqual(mounted, [false, true], 'disposed listener cannot send to its old net');
|
|
134
|
+
console.log('test-visibility: ok');
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { makeYours } from '../code/client/yours.js';
|
|
3
|
+
import { makeChrome } from '../code/client/chrome.js';
|
|
4
|
+
// Same DOM stand-in used by the kit's focused HUD tests, with tap handlers.
|
|
5
|
+
function fakeDom(view) {
|
|
6
|
+
const log = [];
|
|
7
|
+
let ids = 0;
|
|
8
|
+
const made = [];
|
|
9
|
+
function node(tag) {
|
|
10
|
+
const id = `${tag}#${(ids += 1)}`;
|
|
11
|
+
const styles = {};
|
|
12
|
+
let text = '';
|
|
13
|
+
const self = {
|
|
14
|
+
id,
|
|
15
|
+
tag,
|
|
16
|
+
children: [],
|
|
17
|
+
parent: null,
|
|
18
|
+
dataset: {},
|
|
19
|
+
attrs: {},
|
|
20
|
+
rect: null,
|
|
21
|
+
size: null,
|
|
22
|
+
style: new Proxy(styles, {
|
|
23
|
+
get: (target, key) => target[key] ?? '',
|
|
24
|
+
set(target, key, value) {
|
|
25
|
+
target[key] = String(value);
|
|
26
|
+
log.push(`${id} style.${String(key)}=${value}`);
|
|
27
|
+
return true;
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
styles,
|
|
31
|
+
get textContent() {
|
|
32
|
+
return text;
|
|
33
|
+
},
|
|
34
|
+
set textContent(value) {
|
|
35
|
+
text = String(value);
|
|
36
|
+
log.push(`${id} text=${text}`);
|
|
37
|
+
},
|
|
38
|
+
appendChild(child) {
|
|
39
|
+
child.parent = self;
|
|
40
|
+
self.children.push(child);
|
|
41
|
+
log.push(`${id} +${child.id}`);
|
|
42
|
+
return child;
|
|
43
|
+
},
|
|
44
|
+
append(...kids) {
|
|
45
|
+
kids.forEach((kid) => self.appendChild(kid));
|
|
46
|
+
},
|
|
47
|
+
insertBefore(child, before) {
|
|
48
|
+
if (child.parent) {
|
|
49
|
+
child.parent.children = child.parent.children.filter((c) => c !== child);
|
|
50
|
+
}
|
|
51
|
+
child.parent = self;
|
|
52
|
+
const at = self.children.indexOf(before);
|
|
53
|
+
self.children.splice(at < 0 ? self.children.length : at, 0, child);
|
|
54
|
+
return child;
|
|
55
|
+
},
|
|
56
|
+
remove() {
|
|
57
|
+
if (self.parent) {
|
|
58
|
+
self.parent.children = self.parent.children.filter((c) => c !== self);
|
|
59
|
+
log.push(`${id} removed`);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
replaceChildren(...kids) {
|
|
63
|
+
self.children = [];
|
|
64
|
+
log.push(`${id} emptied`);
|
|
65
|
+
kids.forEach((kid) => self.appendChild(kid));
|
|
66
|
+
},
|
|
67
|
+
handlers: {},
|
|
68
|
+
addEventListener(type, fn) { self.handlers[type] = fn; },
|
|
69
|
+
removeEventListener() {},
|
|
70
|
+
setAttribute(key, value) {
|
|
71
|
+
self.attrs[key] = String(value);
|
|
72
|
+
},
|
|
73
|
+
getAttribute: (key) => self.attrs[key] ?? null,
|
|
74
|
+
focus() {},
|
|
75
|
+
blur() {},
|
|
76
|
+
// A stand-in layout: 7 px a character and 20 of padding, one 24 px line.
|
|
77
|
+
get offsetWidth() {
|
|
78
|
+
log.push(`${id} read`);
|
|
79
|
+
return (typeof self.size === 'function' ? self.size(self) : self.size)?.w ?? text.length * 7 + 20;
|
|
80
|
+
},
|
|
81
|
+
get offsetHeight() {
|
|
82
|
+
log.push(`${id} read`);
|
|
83
|
+
return (typeof self.size === 'function' ? self.size(self) : self.size)?.h ?? 24;
|
|
84
|
+
},
|
|
85
|
+
get offsetLeft() {
|
|
86
|
+
return parseFloat(styles.left) || 0;
|
|
87
|
+
},
|
|
88
|
+
get clientWidth() {
|
|
89
|
+
return self.client ?? self.offsetWidth;
|
|
90
|
+
},
|
|
91
|
+
get scrollWidth() {
|
|
92
|
+
return self.scroll ?? self.offsetWidth;
|
|
93
|
+
},
|
|
94
|
+
getBoundingClientRect() {
|
|
95
|
+
const r = self.rect ?? { left: 0, right: 0, top: 0, bottom: 0 };
|
|
96
|
+
return { ...r, width: r.right - r.left, height: r.bottom - r.top };
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
made.push(self);
|
|
100
|
+
return self;
|
|
101
|
+
}
|
|
102
|
+
const body = node('body');
|
|
103
|
+
globalThis.document = { body, createElement: node, activeElement: null };
|
|
104
|
+
globalThis.window = { innerWidth: view.viewW, innerHeight: view.viewH };
|
|
105
|
+
globalThis.innerWidth = view.viewW;
|
|
106
|
+
return { log, body, made };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const doors = Array.from({ length: 6 }, (_, i) => ({ id: `d${i}`, title: `Game ${i}`, solo: i === 1, featured: i === 2 }));
|
|
110
|
+
const yesterday = new Date();
|
|
111
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
112
|
+
const state = { rows: doors.slice(0, 5).map((d) => ({ door: d.id, title: d.title, line: 'Best 5 points', lastAt: yesterday.getTime(), hearted: false })), hearts: [] };
|
|
113
|
+
const yours = makeYours({}, { getCurrent: async () => ({ userId: '1' }) }, () => {});
|
|
114
|
+
yours.frame(true, state, 0);
|
|
115
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
116
|
+
const rows = yours.rows(state, doors);
|
|
117
|
+
const taps = [];
|
|
118
|
+
const text = (node) => [node.textContent, ...node.children.map(text)].filter(Boolean).join('|');
|
|
119
|
+
for (const wide of [false, true]) {
|
|
120
|
+
globalThis.matchMedia = () => ({ matches: wide, addEventListener() {}, removeEventListener() {} });
|
|
121
|
+
const dom = fakeDom({ viewW: wide ? 1000 : 360, viewH: 800 });
|
|
122
|
+
const chrome = makeChrome({ avatarCount: 4, onHeart: (door) => taps.push(['heart', door]), onJumpDoor: (door) => taps.push(['go', door.id]), onAsk: (ask, yes) => taps.push(['ask', ask.door, yes]) });
|
|
123
|
+
const root = dom.body.children[0];
|
|
124
|
+
chrome.setDoors(doors, 'Go together');
|
|
125
|
+
const keyless = text(root);
|
|
126
|
+
assert.ok(!keyless.includes('Your games') && !keyless.includes('♡') && !keyless.includes('♥'));
|
|
127
|
+
chrome.setDoors(doors, 'Go together', null, null);
|
|
128
|
+
assert.equal(text(root), keyless, 'absent option retains chrome');
|
|
129
|
+
chrome.setDoors(doors, 'Go together', null, { rows, hearts: ['d0'] });
|
|
130
|
+
const all = text(root);
|
|
131
|
+
assert.match(all, /Your games/);
|
|
132
|
+
assert.match(all, /All doors/);
|
|
133
|
+
assert.ok(all.indexOf('Your games') < all.indexOf('All doors'));
|
|
134
|
+
assert.equal(all.split('Best 5 points · yesterday').length - 1, wide ? 5 : 3);
|
|
135
|
+
assert.match(all, /★ Game 2/, 'featured stays a star');
|
|
136
|
+
const attached = (node) => node === root || Boolean(node.parent && node.parent.children.includes(node) && attached(node.parent));
|
|
137
|
+
const lines = dom.made.filter((node) => attached(node) && node.textContent === 'Best 5 points · yesterday');
|
|
138
|
+
assert.equal(lines.length, wide ? 5 : 3);
|
|
139
|
+
for (const line of lines) {
|
|
140
|
+
assert.equal(line.styles.textOverflow, 'ellipsis', 'complete formatted row line ellipsizes');
|
|
141
|
+
assert.equal(line.styles.overflow, 'hidden');
|
|
142
|
+
assert.equal(line.styles.whiteSpace, 'nowrap');
|
|
143
|
+
assert.equal(line.parent.styles.minWidth, '0');
|
|
144
|
+
}
|
|
145
|
+
const buttons = dom.made.filter((node) => attached(node) && node.tag === 'button');
|
|
146
|
+
const heart = buttons.find((node) => node.attrs['aria-label'] === 'Remove heart');
|
|
147
|
+
heart.handlers.pointerdown({ stopPropagation() {} });
|
|
148
|
+
assert.deepEqual(taps.at(-1), ['heart', 'd0']);
|
|
149
|
+
const together = buttons.find((node) => node.textContent === 'Go together');
|
|
150
|
+
together.handlers.pointerdown({ stopPropagation() {} });
|
|
151
|
+
assert.deepEqual(taps.at(-1), ['go', 'd0']);
|
|
152
|
+
assert.ok(buttons.some((node) => node.textContent === 'Go'), 'solo remains Go');
|
|
153
|
+
chrome.setAsk({ key: 'yours:1', kind: 'yours', door: 'd0', text: '♥ Game 0', line: 'Best 5 points · yesterday', heart: false, yes: 'Go', no: 'Not now' });
|
|
154
|
+
const card = root.children.find((node) => node.styles.width === 'min(94vw, 420px)');
|
|
155
|
+
assert.ok(card);
|
|
156
|
+
assert.ok(card.children[0].children.some((node) => node.textContent === 'Best 5 points · yesterday' && node.styles.textOverflow === 'ellipsis'));
|
|
157
|
+
card.children.find((node) => node.textContent === '♡').handlers.pointerdown({ stopPropagation() {} });
|
|
158
|
+
assert.deepEqual(taps.at(-1), ['heart', 'd0']);
|
|
159
|
+
card.children.find((node) => node.textContent === 'Go').handlers.pointerdown({ stopPropagation() {} });
|
|
160
|
+
assert.deepEqual(taps.at(-1), ['ask', 'd0', true]);
|
|
161
|
+
chrome.setAsk({ key: 'invite:1', text: 'bo invited you', yes: 'Join', no: 'No thanks' });
|
|
162
|
+
assert.equal(card.styles.width, 'min(86vw, 320px)');
|
|
163
|
+
assert.equal(card.children[0].textContent, 'bo invited you', 'legacy ask markup');
|
|
164
|
+
chrome.dispose();
|
|
165
|
+
}
|
|
166
|
+
console.log('hub-game yours chrome: keyless, narrow 3/wide 5, divider, featured, party/solo Go, heart taps, phone chip passed');
|