castle-web-cli 0.4.232 → 0.4.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +51 -3
- package/dist/castleJson.d.ts +4 -2
- package/dist/castleJson.js +2 -0
- package/dist/check.d.ts +3 -1
- package/dist/check.js +11 -1
- package/dist/devSessionStorage.js +47 -1
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +5 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +5 -0
- package/dist/save-deck.js +37 -4
- package/dist/serve.js +3 -0
- package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +79 -2
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +1 -1
- package/kits/base/sdk/commands.d.ts +14 -0
- package/kits/base/sdk/hub.d.ts +6 -2
- package/kits/base/sdk/hub.js +13 -0
- package/kits/base/sdk/multiplayer.js +17 -1
- package/kits/base/sdk/save.js +2 -1
- package/kits/base/sdk/server/hub.d.ts +87 -0
- package/kits/base/sdk/server/hub.js +70 -0
- package/kits/base/sdk/server/platformHandle.d.ts +31 -1
- package/kits/base/sdk/server/storage.d.ts +13 -0
- package/kits/base/sdk/server/storage.js +46 -0
- package/kits/base/sdk/server/wrapper.d.ts +36 -5
- package/kits/base/sdk/server/wrapper.js +83 -8
- package/kits/hub-game/CLAUDE.md +329 -11
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +309 -35
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +251 -0
- package/kits/hub-game/code/client/ballot.js +467 -0
- package/kits/hub-game/code/client/build.js +22 -0
- package/kits/hub-game/code/client/chrome.js +1144 -50
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/decor.js +509 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/grab.js +339 -20
- package/kits/hub-game/code/client/hookLayer.js +299 -13
- package/kits/hub-game/code/client/idle.js +163 -22
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +205 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/shot.js +92 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +109 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +538 -47
- package/kits/hub-game/code/client/tiers.js +516 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +32 -0
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/yours.js +199 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/actions.js +133 -0
- package/kits/hub-game/code/server/actors.js +9 -1
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +82 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/earned.js +461 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +232 -0
- package/kits/hub-game/code/server/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1254 -50
- package/kits/hub-game/code/server/idle.js +30 -11
- package/kits/hub-game/code/server/index.js +2 -2
- package/kits/hub-game/code/server/labels.js +28 -2
- package/kits/hub-game/code/server/manifest.js +378 -7
- package/kits/hub-game/code/server/menu.js +133 -0
- package/kits/hub-game/code/server/npcs.js +830 -80
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +22 -0
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +124 -0
- package/kits/hub-game/code/server/vis.js +113 -0
- package/kits/hub-game/code/server/wear.js +12 -0
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/shot.js +19 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +845 -95
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2244 -61
- package/kits/hub-game/docs/home-pieces.md +64 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +2 -0
- package/kits/hub-game/package.json +2 -1
- package/kits/hub-game/scripts/check.mjs +78 -11
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -17
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
- package/kits/hub-game/scripts/test-avatar.mjs +540 -7
- package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
- package/kits/hub-game/scripts/test-build.mjs +31 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +662 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
- package/kits/hub-game/scripts/test-decor.mjs +457 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1194 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +716 -2
- package/kits/hub-game/scripts/test-hud-clear.mjs +328 -4
- package/kits/hub-game/scripts/test-idle.mjs +361 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +596 -0
- package/kits/hub-game/scripts/test-manifest.mjs +207 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
- package/kits/hub-game/scripts/test-menu.mjs +296 -0
- package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-picker.mjs +314 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-shot.mjs +756 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +416 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
- package/kits/hub-game/scripts/test-tiers.mjs +477 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- package/kits/hub-game/scripts/test-vis.mjs +343 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
- package/kits/hub-game/scripts/test-yours.mjs +372 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/physics-2d/CLAUDE.md +9 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +253 -1
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +1169 -30
- package/kits/physics-3d/behaviors/Player.jsx +629 -72
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +8 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +69 -13
- package/kits/physics-3d/engine3d/actornode.js +86 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +96 -0
- package/kits/physics-3d/engine3d/gait.js +118 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +507 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +37 -19
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +487 -9
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/shadowfade.js +882 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +796 -69
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2563 -80
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +8 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +2 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +383 -6
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +97 -19
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -33,6 +33,8 @@ register(
|
|
|
33
33
|
'castle-web-sdk': ${JSON.stringify(new URL('./fixtures/sdk-stub.mjs', import.meta.url).href)},
|
|
34
34
|
};
|
|
35
35
|
export async function resolve(specifier, context, next) {
|
|
36
|
+
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 };
|
|
37
|
+
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 };
|
|
36
38
|
if (stubs[specifier]) {
|
|
37
39
|
return { url: stubs[specifier], shortCircuit: true };
|
|
38
40
|
}
|
|
@@ -42,7 +44,7 @@ register(
|
|
|
42
44
|
export async function load(url, context, next) {
|
|
43
45
|
if (url.endsWith('/code/client/hookLayer.js')) {
|
|
44
46
|
const source = await readFile(fileURLToPath(url), 'utf8');
|
|
45
|
-
return { format: 'module', source: source.
|
|
47
|
+
return { format: 'module', source: source.replaceAll('import.meta.glob(', '(() => ({}))('), shortCircuit: true };
|
|
46
48
|
}
|
|
47
49
|
return next(url, context);
|
|
48
50
|
}
|
|
@@ -62,6 +64,7 @@ const here = await kit(path.join(import.meta.dirname, '..'));
|
|
|
62
64
|
const baseline = process.env.HUB_TRY_BASELINE ? await kit(path.resolve(process.env.HUB_TRY_BASELINE)) : null;
|
|
63
65
|
const Wear = await import('../code/server/wear.js');
|
|
64
66
|
const { makeWear } = await import('../code/client/wear.js');
|
|
67
|
+
const THREE = await import('three');
|
|
65
68
|
const { HATS } = await import('../code/client/hats.js');
|
|
66
69
|
|
|
67
70
|
globalThis.__hubTestActors = [
|
|
@@ -586,33 +589,29 @@ await test('the client draws the try-on instead of the saved wearable, and the s
|
|
|
586
589
|
// p1 owns a halo and has a straw hat tried on; p2 owns nothing and has a witch's.
|
|
587
590
|
assert.deepEqual(c.feed(used.log.slice(0, halfway + 1)), { p1: straw, p2: witch });
|
|
588
591
|
assert.deepEqual(Object.fromEntries(c.hub.wearAll), { p1: halo }, 'the saved map is the server’s, unchanged');
|
|
589
|
-
// What is drawn: the hat
|
|
590
|
-
const
|
|
591
|
-
const
|
|
592
|
-
['me-body', local],
|
|
593
|
-
['body-p1', { id: 'body-p1', components: { Transform: { x: 3, y: 1, z: 0, rotationY: 0 } } }],
|
|
594
|
-
]);
|
|
592
|
+
// What is drawn: the hat over p1, under p1's avatar's node, not the halo.
|
|
593
|
+
const nodes = new Map(['me-body', 'body-p1'].map((id) => [id, { node: new THREE.Group() }]));
|
|
594
|
+
const local = { id: 'me-body' };
|
|
595
595
|
const scene = {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
despawnActor: (id) => actors.delete(id),
|
|
596
|
+
files: { 'imports/castle.hub-game/models/hats/straw.pxmodel': '{}' },
|
|
597
|
+
three: { nodes },
|
|
598
|
+
multiplayer: { net: { selfId: () => 'p3' }, avatars: { actors: new Map([['p1', 'body-p1']]) } },
|
|
600
599
|
};
|
|
601
600
|
const fit = null;
|
|
602
601
|
const wear = makeWear();
|
|
603
|
-
const worn = () =>
|
|
602
|
+
const worn = () => nodes.get('body-p1').node.children.map((child) => child.name);
|
|
603
|
+
const ringColor = () => `#${nodes.get('body-p1').node.children[0]?.children[0]?.children[0]?.material?.color?.getHexString()}`;
|
|
604
604
|
wear.frame(scene, local, c.hub.wearing, () => 1.66, 0, () => fit);
|
|
605
|
-
|
|
606
|
-
assert.ok(hat.length >= 1 && hat.every((shape) => shape.emissive === undefined), 'a matte hat, no glow');
|
|
607
|
-
assert.equal(hat[0].color, straw.color);
|
|
605
|
+
assert.deepEqual(worn(), ['wear:hat'], 'the hat, not the halo');
|
|
608
606
|
// The same client with the saved look alone, for what a halo is drawn as.
|
|
609
607
|
const plain = makeWear();
|
|
610
|
-
|
|
611
|
-
|
|
608
|
+
wear.clear();
|
|
609
|
+
assert.deepEqual(worn(), []);
|
|
612
610
|
plain.frame(scene, local, new Map([['p1', halo]]), () => 1.66, 0, () => fit);
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
assert.equal(
|
|
611
|
+
assert.deepEqual(worn(), ['wear:halo']);
|
|
612
|
+
const haloColor = ringColor();
|
|
613
|
+
assert.equal(haloColor, halo.color);
|
|
614
|
+
plain.clear();
|
|
616
615
|
// The rest of the visit: p1's comes off (nothing saved by then but what the
|
|
617
616
|
// place saved since), p2 leaves, the place ends.
|
|
618
617
|
const end = c.feed(used.log.slice(halfway + 1));
|
|
@@ -626,12 +625,13 @@ await test('the client draws the try-on instead of the saved wearable, and the s
|
|
|
626
625
|
const again = client(here, 'p3');
|
|
627
626
|
again.feed(s.log.splice(0));
|
|
628
627
|
wear.frame(scene, local, again.hub.wearing, () => 1.66, 16, () => fit);
|
|
629
|
-
assert.
|
|
628
|
+
assert.deepEqual(worn(), ['wear:hat']);
|
|
630
629
|
s.hub().tryOn('p1', null);
|
|
631
630
|
s.delta();
|
|
632
631
|
again.feed(s.log.splice(0));
|
|
633
632
|
wear.frame(scene, local, again.hub.wearing, () => 1.66, 32, () => fit);
|
|
634
|
-
assert.
|
|
633
|
+
assert.deepEqual(worn(), ['wear:halo']);
|
|
634
|
+
assert.equal(ringColor(), haloColor);
|
|
635
635
|
});
|
|
636
636
|
|
|
637
637
|
await test('leaving the place clears the overlay on the client: none in the town, none in the next place', async () => {
|
|
@@ -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');
|