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,298 @@
|
|
|
1
|
+
// v1.74 action chips: real hub hooks, private offers and current-id routing.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { register } from 'node:module';
|
|
7
|
+
|
|
8
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
9
|
+
export async function resolve(specifier, context, next) {
|
|
10
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/server/sceneBodies.js') return { url: 'data:text/javascript,export const readScene = () => globalThis.__hubTestActors;', shortCircuit: true };
|
|
11
|
+
if (context.parentURL?.includes('/kits/base/sdk/') && specifier.startsWith('.') && !specifier.endsWith('.js')) return next(specifier + '.js', context);
|
|
12
|
+
return next(specifier, context);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
`)}`);
|
|
16
|
+
const { layer } = await import('../code/server/hub.js');
|
|
17
|
+
const Manifest = await import('../code/server/manifest.js');
|
|
18
|
+
const check = (await import('./check.mjs')).default;
|
|
19
|
+
const actors = [
|
|
20
|
+
{ id: 'player', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } },
|
|
21
|
+
{ id: 'floor', components: { Transform: { x: 0, y: 0, z: 0 } } },
|
|
22
|
+
];
|
|
23
|
+
const players = [
|
|
24
|
+
{ playerId: 'p1', userId: '101', username: 'Ada', isAnonymous: false },
|
|
25
|
+
{ playerId: 'p2', userId: '102', username: 'Bo', isAnonymous: false },
|
|
26
|
+
];
|
|
27
|
+
const json = (keys = {}) => ({ server: { maxPlayers: 8 }, hub: { contract: 1, title: 'House', ...keys } });
|
|
28
|
+
function boot(keys = {}, options = {}) {
|
|
29
|
+
const sent = [], ops = [], arrivals = [];
|
|
30
|
+
let hub;
|
|
31
|
+
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 ?? {}) };
|
|
32
|
+
const bodies = [];
|
|
33
|
+
const engine = {
|
|
34
|
+
createBody(sim, actor, at) {
|
|
35
|
+
const rb = { at: { ...at }, setEnabled() {}, setNextKinematicTranslation(at) { this.at = { ...at }; }, setNextKinematicRotation() {} };
|
|
36
|
+
bodies.push([actor.id, rb]);
|
|
37
|
+
return rb;
|
|
38
|
+
},
|
|
39
|
+
removeActor(sim, id) { sim.bodies.delete(id); sim.objects.delete(id); },
|
|
40
|
+
};
|
|
41
|
+
globalThis.__hubTestActors = structuredClone(actors);
|
|
42
|
+
const server = layer(json(keys), hooks, {}, () => true, () => null, null, engine);
|
|
43
|
+
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)]); } };
|
|
44
|
+
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() {} } }])) };
|
|
45
|
+
server.sceneFor(session);
|
|
46
|
+
server.ready(world);
|
|
47
|
+
const say = (id, data) => server.message(session, { playerId: id }, data);
|
|
48
|
+
if (options.hello !== false) {
|
|
49
|
+
for (const id of options.order ?? ['p1', 'p2']) {
|
|
50
|
+
say(id, { k: 'hub-hello', avatar: 0, party: 2 });
|
|
51
|
+
}
|
|
52
|
+
server.place(world);
|
|
53
|
+
}
|
|
54
|
+
const tick = (ms = 50) => { world.timeMs += ms; server.place(world); server.step(world, []); };
|
|
55
|
+
return { server, session, world, hub, sent, ops, say, tick, bodies, arrivals, hooks };
|
|
56
|
+
}
|
|
57
|
+
const items = [{ id: 'start', label: 'Start' }, { id: 'sit_down', label: 'Sit down' }];
|
|
58
|
+
const wire = (r) => r.sent.filter(([, msg]) => msg.k === 'hub-actions');
|
|
59
|
+
let passed = 0;
|
|
60
|
+
async function test(name, fn) { await fn(); passed += 1; console.log(`ok: ${name}`); }
|
|
61
|
+
|
|
62
|
+
await test('manifest and publish check: true or absent only, main and named places', async () => {
|
|
63
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-actions-'));
|
|
64
|
+
try {
|
|
65
|
+
fs.mkdirSync(path.join(dir, 'scenes'));
|
|
66
|
+
fs.writeFileSync(path.join(dir, 'scenes/main.scene'), JSON.stringify({ actors }));
|
|
67
|
+
for (const named of [false, true]) {
|
|
68
|
+
for (const value of [true, false, null, 0, 1, '', 'true', [], {}, undefined]) {
|
|
69
|
+
const keys = named ? { places: { porch: { title: 'Porch', scene: 'scenes/main.scene', actions: value } } } : { actions: value };
|
|
70
|
+
const read = Manifest.readManifest(json(keys));
|
|
71
|
+
const valid = value === true;
|
|
72
|
+
assert.equal(read.errors.some((e) => e.includes('.actions')), !valid, `read ${named}:${String(value)}`);
|
|
73
|
+
fs.writeFileSync(path.join(dir, 'castle.json'), JSON.stringify({ ...json(keys), server: { main: 'code/server/index.js', maxPlayers: 8 } }));
|
|
74
|
+
const published = await check({ deckDir: dir, self: true });
|
|
75
|
+
assert.equal(published.errors.some((e) => e.includes('.actions')), value !== true && value !== undefined);
|
|
76
|
+
if (value === true) {
|
|
77
|
+
assert.equal(read.manifest.places[named ? 'porch' : 'main'].actions, true);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const r = Manifest.readManifest(json()).manifest;
|
|
82
|
+
assert(!Object.hasOwn(r.places.main, 'actions'));
|
|
83
|
+
assert(!Object.hasOwn(Manifest.publicPlace('main', r.places.main), 'actions'));
|
|
84
|
+
} finally {
|
|
85
|
+
fs.rmSync(dir, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
await test('actions are place-only and a call from arrive is already eligible', () => {
|
|
89
|
+
const keys = { actions: true, places: { porch: { title: 'Porch', scene: 'scenes/porch.scene' } } };
|
|
90
|
+
const r = boot(keys);
|
|
91
|
+
assert.equal(typeof r.hub.actions, 'function');
|
|
92
|
+
const captured = r.hub.actions;
|
|
93
|
+
r.session.place = 'porch'; r.server.sceneFor(r.session);
|
|
94
|
+
assert(!Object.hasOwn(r.hub, 'actions'));
|
|
95
|
+
r.say('p1', { k: 'hub-action', id: 'start' }); assert.deepEqual(r.ops, []);
|
|
96
|
+
assert.throws(() => captured('p1', items), TypeError);
|
|
97
|
+
let applied;
|
|
98
|
+
boot({ actions: true }, { hooks: { arrive(ctx, group) { applied = ctx.actions(group[0].playerId, items); } } });
|
|
99
|
+
assert.equal(applied, true);
|
|
100
|
+
});
|
|
101
|
+
const offer = (r, playerId = 'p1') => wire(r).findLast(([id]) => id === playerId)?.[1];
|
|
102
|
+
const press = (r, playerId = 'p1', id = 'start') => r.say(playerId, { k: 'hub-action', id, n: offer(r, playerId)?.n });
|
|
103
|
+
|
|
104
|
+
await test('validation is atomic; private copies, clear and same-list suppression', () => {
|
|
105
|
+
const r = boot({ actions: true });
|
|
106
|
+
assert.equal(r.hub.actions('p1', [{ id: 'a'.repeat(24), label: 'x'.repeat(16) }, { id: 'b_1-2', label: 'B' }, { id: 'c', label: 'C' }]), true);
|
|
107
|
+
assert.equal(r.hub.actions('p1', items), true);
|
|
108
|
+
r.tick(250);
|
|
109
|
+
assert.deepEqual(wire(r).at(-1), ['p1', { k: 'hub-actions', items, n: 2 }]);
|
|
110
|
+
const count = wire(r).length;
|
|
111
|
+
assert.equal(r.hub.actions('p1', structuredClone(items)), true);
|
|
112
|
+
r.tick(250); assert.equal(wire(r).length, count);
|
|
113
|
+
for (const invalid of [undefined, false, {}, 'start', [null], [,], [{ id: 'A', label: 'Go' }], [{ id: '1start', label: 'Go' }], [{ id: 'start!', label: 'Go' }], [{ id: 'start\n', label: 'Go' }], [{ id: 'a'.repeat(25), label: 'Go' }], [{ id: 'start', label: '' }], [{ id: 'start', label: 'x'.repeat(17) }], [{ id: 'start', label: 1 }], [{ id: 'start', label: 'Go', extra: true }], [items[0], items[0]], [...items, items[0], items[0]]]) {
|
|
114
|
+
assert.throws(() => r.hub.actions('p1', invalid), TypeError);
|
|
115
|
+
assert.equal(wire(r).length, count);
|
|
116
|
+
}
|
|
117
|
+
assert.throws(() => r.hub.actions(null, items), TypeError);
|
|
118
|
+
assert.equal(r.hub.actions('missing', items), false);
|
|
119
|
+
assert.throws(() => r.hub.actions('missing', [{}]), TypeError);
|
|
120
|
+
const copy = structuredClone(items);
|
|
121
|
+
r.hub.actions('p2', copy); copy[0].id = 'mutated'; r.tick(250); press(r, 'p2');
|
|
122
|
+
assert.deepEqual(r.ops, [['p2', 'start']]);
|
|
123
|
+
r.hub.actions('p1', []); r.tick(250);
|
|
124
|
+
assert.deepEqual(wire(r).at(-1), ['p1', { k: 'hub-actions', items: null, n: 4 }]);
|
|
125
|
+
const clearCount = wire(r).length;
|
|
126
|
+
r.hub.actions('p1', null); r.hub.actions('p1', []); r.tick(250);
|
|
127
|
+
assert.equal(wire(r).length, clearCount);
|
|
128
|
+
assert(!Object.hasOwn(r.server.join(), 'actions'));
|
|
129
|
+
assert(!Object.hasOwn(r.server.delta() ?? {}, 'actions'));
|
|
130
|
+
});
|
|
131
|
+
await test('plain own-property records: getter values read exactly once, then validated and copied', () => {
|
|
132
|
+
const r = boot({ actions: true });
|
|
133
|
+
let ids = 0, labels = 0;
|
|
134
|
+
const item = {
|
|
135
|
+
get id() { ids += 1; return ids === 1 ? 'start' : 'x'.repeat(1000000); },
|
|
136
|
+
get label() { labels += 1; return labels === 1 ? 'Start' : 'x'.repeat(1000000); },
|
|
137
|
+
};
|
|
138
|
+
r.hub.actions('p1', [item]); r.tick(250);
|
|
139
|
+
assert.equal(ids, 1); assert.equal(labels, 1);
|
|
140
|
+
assert.deepEqual(offer(r), { k: 'hub-actions', items: [items[0]], n: 1 });
|
|
141
|
+
class Item { constructor() { this.id = 'start'; this.label = 'Start'; } }
|
|
142
|
+
const missing = { label: 'Start' };
|
|
143
|
+
const unknown = Object.defineProperty({ ...items[0] }, 'extra', { value: true });
|
|
144
|
+
for (const bad of [new Item(), new Date(), Object.create(items[0]), missing, unknown, { ...items[0], [Symbol('extra')]: true }, []]) {
|
|
145
|
+
assert.throws(() => r.hub.actions('p1', [bad]), TypeError);
|
|
146
|
+
}
|
|
147
|
+
// Plain records with a null prototype have their own fields too.
|
|
148
|
+
r.hub.actions('p1', [Object.assign(Object.create(null), items[0])]);
|
|
149
|
+
r.tick(250); assert.equal(offer(r).n, 1);
|
|
150
|
+
});
|
|
151
|
+
await test('labels count code points, reject whitespace-only, every C0/C1 and listed direction character', () => {
|
|
152
|
+
const r = boot({ actions: true });
|
|
153
|
+
const label = '😀'.repeat(16);
|
|
154
|
+
r.hub.actions('p1', [{ id: 'start', label }]); r.tick(250);
|
|
155
|
+
assert.equal(offer(r).items[0].label, label);
|
|
156
|
+
for (const bad of ['😀'.repeat(17), '', ' ', '\t\n', '\u00a0\u2003', ...Array.from({ length: 32 }, (_, i) => `a${String.fromCodePoint(i)}b`), ...Array.from({ length: 33 }, (_, i) => `a${String.fromCodePoint(0x7f + i)}b`), ...[0x202a, 0x202b, 0x202c, 0x202d, 0x202e, 0x2066, 0x2067, 0x2068, 0x2069, 0x200e, 0x200f].map((cp) => `a${String.fromCodePoint(cp)}b`)]) {
|
|
157
|
+
assert.throws(() => r.hub.actions('p1', [{ id: 'start', label: bad }]), TypeError);
|
|
158
|
+
}
|
|
159
|
+
r.tick(250); assert.equal(offer(r).n, 1);
|
|
160
|
+
});
|
|
161
|
+
await test('routing: current version and offered id for arrived connected senders only', () => {
|
|
162
|
+
const r = boot({ actions: true });
|
|
163
|
+
r.hub.actions('p1', items); r.hub.actions('p2', [{ id: 'other', label: 'Other' }]); r.tick(250);
|
|
164
|
+
press(r); press(r, 'p1', 'other');
|
|
165
|
+
for (const msg of [{}, { id: 1 }, { id: null }, { id: [] }, { id: 'start', extra: 1 }]) r.say('p1', { k: 'hub-action', n: offer(r).n, ...msg });
|
|
166
|
+
assert.deepEqual(r.ops, [['p1', 'start']]);
|
|
167
|
+
r.tick(2000);
|
|
168
|
+
r.hub.actions('p1', [{ id: 'new', label: 'New' }]);
|
|
169
|
+
press(r); r.tick(250); press(r, 'p1', 'new');
|
|
170
|
+
r.hub.actions('p1', null); press(r, 'p1', 'new');
|
|
171
|
+
assert.deepEqual(r.ops, [['p1', 'start'], ['p1', 'new']]);
|
|
172
|
+
r.hub.actions('p2', items); r.tick(250); r.session.players = [players[0]];
|
|
173
|
+
press(r, 'p2'); assert.equal(r.ops.length, 2);
|
|
174
|
+
const unarrived = boot({ actions: true }, { hello: false });
|
|
175
|
+
assert.equal(unarrived.hub.actions('p1', items), false);
|
|
176
|
+
unarrived.say('p1', { k: 'hub-action', id: 'start', n: 1 }); assert.deepEqual(unarrived.ops, []);
|
|
177
|
+
});
|
|
178
|
+
await test('reused ids and null/re-offer reject stale versions, including before the next send', () => {
|
|
179
|
+
const r = boot({ actions: true }); r.hub.actions('p1', [items[0]]); r.tick(250);
|
|
180
|
+
const old = offer(r).n;
|
|
181
|
+
r.hub.actions('p1', [{ id: 'start', label: 'Start again' }]);
|
|
182
|
+
r.say('p1', { k: 'hub-action', id: 'start', n: old }); assert.deepEqual(r.ops, []);
|
|
183
|
+
r.tick(250); assert.equal(offer(r).n, old + 1); press(r);
|
|
184
|
+
r.hub.actions('p1', null); r.hub.actions('p1', [items[0]]);
|
|
185
|
+
r.say('p1', { k: 'hub-action', id: 'start', n: old }); assert.equal(r.ops.length, 1);
|
|
186
|
+
r.tick(250); assert.equal(offer(r).n, old + 3); press(r); assert.equal(r.ops.length, 2);
|
|
187
|
+
});
|
|
188
|
+
await test('press version is required and must be a safe integer', () => {
|
|
189
|
+
const r = boot({ actions: true }); r.hub.actions('p1', items); r.tick(250);
|
|
190
|
+
for (const n of [undefined, null, true, '1', 1.5, NaN, Infinity, Number.MAX_SAFE_INTEGER + 1]) {
|
|
191
|
+
r.say('p1', { k: 'hub-action', id: 'start', n });
|
|
192
|
+
}
|
|
193
|
+
assert.deepEqual(r.ops, []); r.tick(1000); press(r); assert.equal(r.ops.length, 1);
|
|
194
|
+
});
|
|
195
|
+
await test('10,000 recorded changes coalesce; four sends/s per player, newest wins and sent-list equality suppresses', () => {
|
|
196
|
+
const r = boot({ actions: true }); r.sent.length = 0;
|
|
197
|
+
const a = [{ id: 'start', label: 'A' }], b = [{ id: 'start', label: 'B' }];
|
|
198
|
+
for (let i = 0; i < 10000; i++) r.hub.actions('p1', i % 2 ? b : a);
|
|
199
|
+
assert.deepEqual(wire(r), []);
|
|
200
|
+
r.tick(250); assert.deepEqual(wire(r), [['p1', { k: 'hub-actions', items: b, n: 10000 }]]);
|
|
201
|
+
for (let i = 0; i < 10000; i++) r.hub.actions('p1', i % 2 ? b : a);
|
|
202
|
+
r.tick(250); assert.equal(wire(r).length, 1, 'equal last-sent list is suppressed despite intermediate recordings');
|
|
203
|
+
// Back at the list the player was sent, its version stands: what they see can be pressed.
|
|
204
|
+
press(r); assert.deepEqual(r.ops, [['p1', 'start']]); r.ops.length = 0;
|
|
205
|
+
r.hub.actions('p1', a); r.hub.actions('p2', a); r.tick(0);
|
|
206
|
+
assert.equal(wire(r).length, 3, 'budgets are per player');
|
|
207
|
+
for (let i = 0; i < 4; i++) {
|
|
208
|
+
r.hub.actions('p1', i % 2 ? a : b);
|
|
209
|
+
r.tick(249); const before = wire(r).length;
|
|
210
|
+
r.tick(1); assert.equal(wire(r).length, before + 1);
|
|
211
|
+
}
|
|
212
|
+
const times = [];
|
|
213
|
+
const original = r.session.send;
|
|
214
|
+
r.session.send = (id, msg) => { if (msg.k === 'hub-actions') times.push(r.world.timeMs); original(id, msg); };
|
|
215
|
+
for (let i = 0; i < 100; i++) { r.hub.actions('p1', [{ id: 'start', label: String(i) }]); r.tick(10); }
|
|
216
|
+
assert.equal(times.length, 4); assert(times.slice(1).every((at, i) => at - times[i] >= 250));
|
|
217
|
+
});
|
|
218
|
+
await test('rate limit: eight burst, six/s, per player, invalid and refused presses spend tokens', () => {
|
|
219
|
+
const r = boot({ actions: true }); r.hub.actions('p1', items); r.hub.actions('p2', items); r.tick(250);
|
|
220
|
+
for (let i = 0; i < 10; i++) press(r);
|
|
221
|
+
assert.equal(r.ops.length, 8);
|
|
222
|
+
press(r, 'p2'); assert.equal(r.ops.length, 9);
|
|
223
|
+
r.tick(500);
|
|
224
|
+
for (let i = 0; i < 5; i++) press(r);
|
|
225
|
+
assert.equal(r.ops.length, 12);
|
|
226
|
+
r.tick(2000);
|
|
227
|
+
for (let i = 0; i < 8; i++) r.say('p1', { k: 'hub-action', id: 'start', n: offer(r).n, extra: 1 });
|
|
228
|
+
press(r); assert.equal(r.ops.length, 12);
|
|
229
|
+
let calls = 0;
|
|
230
|
+
const refused = boot({ actions: true }, { hooks: { action() { calls += 1; return false; } } });
|
|
231
|
+
refused.hub.actions('p1', items); refused.tick(250);
|
|
232
|
+
for (let i = 0; i < 9; i++) press(refused);
|
|
233
|
+
assert.equal(calls, 8);
|
|
234
|
+
});
|
|
235
|
+
await test('hook throws and rejections are contained and logged once', async () => {
|
|
236
|
+
const warnings = [], warn = console.warn;
|
|
237
|
+
console.warn = (text) => warnings.push(text);
|
|
238
|
+
try {
|
|
239
|
+
let calls = 0;
|
|
240
|
+
const r = boot({ actions: true }, { hooks: { action() { calls += 1; if (calls === 1) throw new Error('sync'); return Promise.reject(new Error('async')); } } });
|
|
241
|
+
r.hub.actions('p1', items); r.tick(250); press(r); press(r);
|
|
242
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
243
|
+
assert.equal(calls, 2);
|
|
244
|
+
assert.equal(warnings.filter((text) => text.includes('action hook failed')).length, 1);
|
|
245
|
+
} finally { console.warn = warn; }
|
|
246
|
+
});
|
|
247
|
+
await test('async hooks run concurrently and continue after departure', async () => {
|
|
248
|
+
const pending = [], completed = [];
|
|
249
|
+
const r = boot({ actions: true }, { hooks: { action(ctx, playerId) { return new Promise((resolve) => pending.push(() => { completed.push(playerId); resolve(); })); } } });
|
|
250
|
+
r.hub.actions('p1', items); r.tick(250); press(r); press(r);
|
|
251
|
+
assert.equal(pending.length, 2, 'not serialised');
|
|
252
|
+
r.session.players = [players[1]]; r.world.players.delete('p1'); r.tick();
|
|
253
|
+
pending.forEach((finish) => finish()); await new Promise((resolve) => setImmediate(resolve));
|
|
254
|
+
assert.deepEqual(completed, ['p1', 'p1'], 'not cancelled');
|
|
255
|
+
});
|
|
256
|
+
await test('fresh hello replays current offer once with current n; leave clears offers and avoids version reuse', () => {
|
|
257
|
+
const r = boot({ actions: true }); r.hub.actions('p1', items); r.tick(250);
|
|
258
|
+
r.sent.length = 0; r.say('p1', { k: 'hub-hello', resume: true }); r.tick(250);
|
|
259
|
+
assert.deepEqual(wire(r), [['p1', { k: 'hub-actions', items, n: 1 }]]);
|
|
260
|
+
r.sent.length = 0; r.say('p1', { k: 'hub-hello', again: true }); assert.deepEqual(wire(r), []);
|
|
261
|
+
r.hub.actions('p1', null); r.sent.length = 0;
|
|
262
|
+
r.say('p1', { k: 'hub-hello', resume: true }); r.tick(250);
|
|
263
|
+
assert.deepEqual(wire(r), [['p1', { k: 'hub-actions', items: null, n: 2 }]]);
|
|
264
|
+
r.hub.actions('p1', items); r.tick(250); const old = offer(r).n;
|
|
265
|
+
const body = r.world.players.get('p1');
|
|
266
|
+
r.session.players = [players[1]]; r.world.players.delete('p1'); r.tick();
|
|
267
|
+
assert.equal(r.hub.actions('p1', items), false);
|
|
268
|
+
r.session.players.push(players[0]); r.world.players.set('p1', body); r.sent.length = 0;
|
|
269
|
+
r.say('p1', { k: 'hub-hello', resume: true }); r.tick();
|
|
270
|
+
assert.deepEqual(wire(r), [['p1', { k: 'hub-actions', items: null, n: 0 }]]);
|
|
271
|
+
r.hub.actions('p1', items); r.tick(250);
|
|
272
|
+
// The session's one counter: never a version an earlier offer had.
|
|
273
|
+
assert.equal(offer(r).n, old + 1);
|
|
274
|
+
r.say('p1', { k: 'hub-action', id: 'start', n: old }); assert.deepEqual(r.ops, []);
|
|
275
|
+
press(r); assert.deepEqual(r.ops, [['p1', 'start']]);
|
|
276
|
+
});
|
|
277
|
+
await test('keyless place: no API or action lookup, no extra manifest, snapshot, delta or wire', () => {
|
|
278
|
+
const r = boot();
|
|
279
|
+
Object.defineProperty(r.hooks, 'action', { get() { throw new Error('keyless action lookup'); } });
|
|
280
|
+
assert(!Object.hasOwn(r.hub, 'actions'));
|
|
281
|
+
const before = JSON.stringify(r.server.join());
|
|
282
|
+
r.say('p1', { k: 'hub-action', id: 'start', n: 1 }); r.tick();
|
|
283
|
+
assert.equal(JSON.stringify(r.server.join()), before);
|
|
284
|
+
assert.deepEqual(wire(r), []); assert.deepEqual(r.ops, []);
|
|
285
|
+
});
|
|
286
|
+
await test('an offer recorded and not yet sent cannot be pressed; invisible and bidi characters are refused', () => {
|
|
287
|
+
const r = boot({ actions: true });
|
|
288
|
+
r.hub.actions('p1', [{ id: 'choose', label: 'Take apple' }]); r.tick(250);
|
|
289
|
+
const sent = offer(r).n;
|
|
290
|
+
r.hub.actions('p1', [{ id: 'choose', label: 'Buy bomb' }]);
|
|
291
|
+
for (let n = sent; n <= sent + 3; n++) r.say('p1', { k: 'hub-action', id: 'choose', n });
|
|
292
|
+
assert.deepEqual(r.ops, []);
|
|
293
|
+
r.tick(250); press(r, 'p1', 'choose'); assert.deepEqual(r.ops, [['p1', 'choose']]);
|
|
294
|
+
for (const label of ['\u061c', 'a\u200bb', '\u2060', 'x\ufeff', '\u202eevil', '\u2068x']) {
|
|
295
|
+
assert.throws(() => r.hub.actions('p1', [{ id: 'blank', label }]), TypeError);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
console.log(`${passed} action tests passed`);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { actorUpdateDt } from '../../physics-2d/engine/updateBudget.js';
|
|
3
|
+
import { makeActorBudget } from '../code/client/actorBudget.js';
|
|
4
|
+
const a = { id: 'npc', runtime: {}, components: { HubNpc: {}, Transform: { x: 20, z: 0 } } };
|
|
5
|
+
const node = { userData: {} };
|
|
6
|
+
const scene = {
|
|
7
|
+
actorWith: () => ({ components: { Transform: { x: 0, z: 0 } } }),
|
|
8
|
+
getActors: () => [a],
|
|
9
|
+
three: { nodes: new Map([[a.id, { node }]]) },
|
|
10
|
+
};
|
|
11
|
+
const budget = makeActorBudget();
|
|
12
|
+
assert.equal(actorUpdateDt(a, 0.016), 0.016);
|
|
13
|
+
budget(scene, true, 0);
|
|
14
|
+
assert.equal(a.runtime.updateEvery, 0.1);
|
|
15
|
+
assert.equal(node.userData.animationEvery, 0.1);
|
|
16
|
+
assert.equal(actorUpdateDt(a, 0.02), 0.02);
|
|
17
|
+
for (let i = 0; i < 4; i++) assert.equal(actorUpdateDt(a, 0.02), null);
|
|
18
|
+
assert.equal(actorUpdateDt(a, 0.02), 0.1);
|
|
19
|
+
a.components.Transform.x = 5;
|
|
20
|
+
budget(scene, true, 201);
|
|
21
|
+
assert.equal(a.runtime.updateEvery, undefined);
|
|
22
|
+
assert.equal(node.userData.animationEvery, undefined);
|
|
23
|
+
assert.equal(actorUpdateDt(a, 0.02), 0.02);
|
|
24
|
+
a.components.Transform.x = 20;
|
|
25
|
+
budget(scene, true, 402);
|
|
26
|
+
budget(scene, false, 403);
|
|
27
|
+
assert.equal(a.runtime.updateEvery, undefined);
|
|
28
|
+
assert.equal(actorUpdateDt(a, 0.02), 0.02);
|
|
29
|
+
scene.multiplayer = { avatars: { actors: new Map([['other', 'npc']]) } };
|
|
30
|
+
budget(scene, true, 604);
|
|
31
|
+
assert.equal(a.runtime.updateEvery, undefined);
|
|
32
|
+
console.log(
|
|
33
|
+
'actor budget: cadence, accumulated dt, near wake, High restore, avatar exemption passed',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Restoration and rate changes deliver every second already accumulated.
|
|
37
|
+
for (const next of [undefined, 0.2]) {
|
|
38
|
+
const actor = { runtime: { updateEvery: 0.1 } };
|
|
39
|
+
let delivered = 0;
|
|
40
|
+
for (let i = 0; i < 5; i++) delivered += actorUpdateDt(actor, 0.02) ?? 0;
|
|
41
|
+
actor.runtime.updateEvery = next;
|
|
42
|
+
delivered += actorUpdateDt(actor, 0.02) ?? 0;
|
|
43
|
+
assert.ok(Math.abs(delivered - 0.12) < 1e-9);
|
|
44
|
+
}
|
|
@@ -11,6 +11,8 @@ const sceneStub = 'export const readScene = () => globalThis.__hubTestActors ??
|
|
|
11
11
|
register(
|
|
12
12
|
`data:text/javascript,${encodeURIComponent(`
|
|
13
13
|
export async function resolve(specifier, context, next) {
|
|
14
|
+
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 };
|
|
15
|
+
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 };
|
|
14
16
|
if (specifier === '@imports/castle.multiplayer-3d/code/server/sceneBodies.js') {
|
|
15
17
|
return { url: 'data:text/javascript,${encodeURIComponent(sceneStub)}', shortCircuit: true };
|
|
16
18
|
}
|
|
@@ -20,7 +22,7 @@ register(
|
|
|
20
22
|
);
|
|
21
23
|
const { layer } = await import('../code/server/hub.js');
|
|
22
24
|
const Actors = await import('../code/server/actors.js');
|
|
23
|
-
const {
|
|
25
|
+
const { look } = await import('../code/client/wear.js');
|
|
24
26
|
const Wear = await import('../code/server/wear.js');
|
|
25
27
|
|
|
26
28
|
const box = { kind: 'box', width: 4, height: 0.5, depth: 2, color: '#808080' };
|
|
@@ -253,7 +255,8 @@ test('a scene with no ground catches a fallen player at the arrival, after the g
|
|
|
253
255
|
assert.deepEqual(body.at, { x: 7, y: 2, z: 7 }, label);
|
|
254
256
|
} else {
|
|
255
257
|
assert.deepEqual([body.at.x, body.at.z], [0, 0], label);
|
|
256
|
-
|
|
258
|
+
// v1.48: implicit ground proves standing height; no support keeps the drop.
|
|
259
|
+
assert.equal(body.at.y, label === 'fallY' ? 0.76 : 1.2, label);
|
|
257
260
|
}
|
|
258
261
|
}
|
|
259
262
|
assert.deepEqual(falls, ['p1']);
|
|
@@ -609,25 +612,24 @@ test('wear: a wearable on a player who is here, latched for everyone, until clea
|
|
|
609
612
|
assert.equal(hub.wear('p1', null), false);
|
|
610
613
|
});
|
|
611
614
|
|
|
612
|
-
test('wear: a wearable is drawn as
|
|
613
|
-
assert.equal(
|
|
614
|
-
assert.equal(
|
|
615
|
-
assert.equal(
|
|
616
|
-
assert.equal(
|
|
617
|
-
assert.equal(
|
|
618
|
-
assert.equal(
|
|
619
|
-
const small =
|
|
620
|
-
const big =
|
|
621
|
-
assert.ok(big.radius > small.radius && big.
|
|
622
|
-
assert.equal(big.
|
|
623
|
-
assert.equal(big.solid, false);
|
|
615
|
+
test('wear: a wearable is drawn as the kinds the kit knows', () => {
|
|
616
|
+
assert.equal(look({ kind: 'halo', color: '#ffd700', rarity: 0 }).kind, 'halo');
|
|
617
|
+
assert.equal(look({ kind: 'aura', color: '#ffd700', rarity: 9 }).kind, 'aura');
|
|
618
|
+
assert.equal(look({ kind: 'orbit', color: '#ffd700', rarity: 0 }).n, 1);
|
|
619
|
+
assert.equal(look({ kind: 'orbit', color: '#ffd700', rarity: 9 }).n, 4);
|
|
620
|
+
assert.equal(look({ kind: 'crown', color: '#ffd700', rarity: 1 }), null);
|
|
621
|
+
assert.equal(look({ kind: 'halo', color: 'javascript:', rarity: 1 }), null);
|
|
622
|
+
const small = look({ kind: 'halo', color: '#ffd700', rarity: 0 });
|
|
623
|
+
const big = look({ kind: 'halo', color: '#FFD700', rarity: 99 });
|
|
624
|
+
assert.ok(big.radius > small.radius && big.glow > small.glow);
|
|
625
|
+
assert.equal(big.color, '#ffd700');
|
|
624
626
|
// A halo and an orbit sit over the avatar's own top; an aura stays at its feet.
|
|
625
|
-
const y = (kind, top) =>
|
|
627
|
+
const y = (kind, top) => look({ kind, color: '#ffd700', rarity: 0 }, top).y;
|
|
626
628
|
assert.ok(Math.abs(y('halo', 1.3) - (y('halo', 1.7) - 0.4)) < 1e-9);
|
|
627
629
|
assert.ok(Math.abs(y('orbit', 1.3) - (y('orbit', 1.7) - 0.4)) < 1e-9 && y('orbit', 1.3) < y('halo', 1.3));
|
|
628
630
|
assert.equal(y('aura', 1.3), y('aura', 1.7));
|
|
629
|
-
// An avatar this kit does not know wears them
|
|
630
|
-
assert.ok(Math.abs(y('halo') - 1.
|
|
631
|
+
// An avatar this kit does not know wears them over a usual height.
|
|
632
|
+
assert.ok(Math.abs(y('halo') - 1.11) < 1e-9 && Math.abs(y('orbit') - 0.95) < 1e-9);
|
|
631
633
|
});
|
|
632
634
|
|
|
633
635
|
test('wear: a block hides a wearable as it hides the avatar, sent alone to who may see it', () => {
|