castle-web-cli 0.4.232 → 0.4.234
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/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +18 -2
- package/dist/castle-host/host.js +844 -39
- package/dist/castleJson.d.ts +23 -2
- package/dist/castleJson.js +46 -2
- package/dist/check.d.ts +3 -1
- package/dist/check.js +20 -3
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +50 -2
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- 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 +11 -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 +25 -1
- package/dist/save-deck.js +178 -9
- package/dist/serve.js +32 -11
- package/dist/shell/assets/{index-D2tWM896.js → index-DulbYIJm.js} +97 -97
- 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/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +339 -5
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +176 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +37 -6
- package/kits/base/sdk/hub.js +63 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +148 -32
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +81 -7
- package/kits/base/sdk/server/hub.d.ts +117 -0
- package/kits/base/sdk/server/hub.js +119 -2
- package/kits/base/sdk/server/platformHandle.d.ts +43 -1
- package/kits/base/sdk/server/storage.d.ts +17 -0
- package/kits/base/sdk/server/storage.js +65 -3
- package/kits/base/sdk/server/wrapper.d.ts +43 -6
- package/kits/base/sdk/server/wrapper.js +93 -9
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +451 -13
- package/kits/hub-game/README.md +63 -0
- 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/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +311 -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 +253 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +472 -0
- package/kits/hub-game/code/client/build.js +38 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +2144 -160
- 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/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +515 -0
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -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/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +368 -29
- package/kits/hub-game/code/client/hookLayer.js +385 -20
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +177 -24
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +234 -0
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -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/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +146 -0
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -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 +162 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +714 -59
- package/kits/hub-game/code/client/tiers.js +543 -52
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +39 -2
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +200 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +138 -0
- package/kits/hub-game/code/server/actors.js +11 -2
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- 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 +107 -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/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +478 -0
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +272 -0
- package/kits/hub-game/code/server/history.js +7 -0
- package/kits/hub-game/code/server/hub.js +2510 -95
- package/kits/hub-game/code/server/idle.js +60 -12
- package/kits/hub-game/code/server/index.js +28 -6
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +36 -2
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +586 -7
- package/kits/hub-game/code/server/menu.js +161 -0
- package/kits/hub-game/code/server/npcs.js +1025 -113
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +30 -0
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +123 -0
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +175 -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/act.js +35 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +53 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1753 -202
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +3475 -77
- package/kits/hub-game/docs/home-pieces.md +71 -0
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -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 +10 -1
- package/kits/hub-game/package.json +6 -2
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +117 -16
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +132 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +26 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +123 -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/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +853 -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 +38 -23
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -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 +792 -0
- package/kits/hub-game/scripts/test-avatar.mjs +584 -7
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +1008 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +49 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +863 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +216 -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-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +344 -0
- package/kits/hub-game/scripts/test-decor.mjs +464 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1224 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +961 -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-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +758 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1594 -12
- package/kits/hub-game/scripts/test-hud-clear.mjs +484 -57
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +427 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +513 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +664 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +472 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +585 -0
- package/kits/hub-game/scripts/test-menu.mjs +319 -0
- package/kits/hub-game/scripts/test-npcs.mjs +2528 -13
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +541 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1733 -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-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +901 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5437 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +449 -0
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1904 -0
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +412 -0
- package/kits/hub-game/scripts/test-tiers.mjs +476 -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 +770 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +210 -0
- package/kits/hub-game/scripts/test-yours.mjs +403 -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/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- 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 +443 -34
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +3 -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-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +19 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +337 -3
- 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/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +42 -529
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +661 -87
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +9 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -277
- package/kits/physics-3d/engine3d/actornode.js +87 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -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 +99 -0
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +126 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +514 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +106 -21
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +522 -10
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +890 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- 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 +1253 -76
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +10 -2
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2613 -82
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +2 -2
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +438 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -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 +5 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +2001 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +582 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +657 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -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-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +10 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2174 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +7 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +419 -9
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +102 -22
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// v1.125 shared ask-slot lease: first display, exact timer/distance bounds,
|
|
2
|
+
// pad entry, redraw identity and reconnect replay. Pure client lifecycle; no
|
|
3
|
+
// server message is emitted by expiry.
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import { ASK_SLOT_DISTANCE_M, ASK_SLOT_MS, askSlotKey, makeAskSlot, padsAt } from '../code/client/askSlot.js';
|
|
6
|
+
|
|
7
|
+
const ask = (key = 'invite:p2', kind = 'invite') => ({ key, kind, text: 'Come along?', yes: 'Go', no: 'Not now' });
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
const slot = makeAskSlot();
|
|
11
|
+
// Waiting/suppression before a card reaches chrome spends no lease.
|
|
12
|
+
slot.frame({ x: 0, z: 0 }, new Set(), 20_000);
|
|
13
|
+
assert.equal(slot.display(ask(), { x: 0, z: 0 }, new Set(), 25_000)?.key, 'invite:p2');
|
|
14
|
+
assert.equal(slot.accepts(ask(), { x: 0, z: 0 }, new Set(), 25_000 + ASK_SLOT_MS - 1), true);
|
|
15
|
+
assert.equal(slot.accepts(ask(), { x: 0, z: 0 }, new Set(), 25_000 + ASK_SLOT_MS), false, 'expires at exactly 12 seconds');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
const slot = makeAskSlot();
|
|
20
|
+
slot.display(ask('go:7', 'go'), { x: 4, z: -2 }, new Set(), 0);
|
|
21
|
+
assert.equal(slot.accepts(ask('go:7', 'go'), { x: 4 + ASK_SLOT_DISTANCE_M - 0.001, z: -2 }, new Set(), 1), true);
|
|
22
|
+
assert.equal(slot.accepts(ask('go:7', 'go'), { x: 4, z: -2 + ASK_SLOT_DISTANCE_M }, new Set(), 2), false, 'exactly 3 m retires the proposal');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
const slot = makeAskSlot();
|
|
27
|
+
const card = ask('play:p2:race:1', 'play');
|
|
28
|
+
slot.display(card, { x: 0, z: 0 }, new Set(['return-pad']), 0);
|
|
29
|
+
assert.equal(slot.accepts(card, { x: 0, z: 0 }, new Set(['return-pad']), 1), true, 'already standing on a pad is not an entry');
|
|
30
|
+
assert.equal(slot.accepts(card, { x: 0, z: 0 }, new Set(), 2), true, 'stepping off keeps the card');
|
|
31
|
+
assert.equal(slot.accepts(card, { x: 0, z: 0 }, new Set(['return-pad']), 3), false, 'stepping back onto any pad retires it');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
const slot = makeAskSlot();
|
|
36
|
+
const before = { ...ask('yours:4:race:a:old:false:false', 'yours'), slotKey: 'yours:4:return:1' };
|
|
37
|
+
const redrawn = { ...ask('yours:4:tiles:a,b:new:true:true', 'yours'), slotKey: 'yours:4:return:1' };
|
|
38
|
+
assert.equal(askSlotKey(before), askSlotKey(redrawn));
|
|
39
|
+
slot.display(before, { x: 0, z: 0 }, new Set(), 100);
|
|
40
|
+
assert.equal(slot.display(redrawn, { x: 0, z: 0 }, new Set(), 100 + ASK_SLOT_MS - 1), redrawn, 'heart/line/party redraw keeps the first lease');
|
|
41
|
+
assert.equal(slot.display(redrawn, { x: 0, z: 0 }, new Set(), 100 + ASK_SLOT_MS), null);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
const slot = makeAskSlot();
|
|
46
|
+
const lower = ask('again:race:1', 'again');
|
|
47
|
+
const higher = ask('invite:p2', 'invite');
|
|
48
|
+
slot.display(lower, { x: 0, z: 0 }, new Set(), 0);
|
|
49
|
+
slot.display(higher, { x: 0, z: 0 }, new Set(), 2_000);
|
|
50
|
+
assert.equal(slot.display(lower, { x: 0, z: 0 }, new Set(), 11_999), lower, 'priority fallthrough does not restart its lease');
|
|
51
|
+
assert.equal(slot.display(lower, { x: 0, z: 0 }, new Set(), 12_000), null);
|
|
52
|
+
// A 30-second connection drop can replay the same server ask, but the
|
|
53
|
+
// client record survives and refuses to resurrect it.
|
|
54
|
+
slot.frame({ x: 0, z: 0 }, new Set(), 30_000);
|
|
55
|
+
assert.equal(slot.display(higher, { x: 0, z: 0 }, new Set(), 32_000), null);
|
|
56
|
+
slot.clear();
|
|
57
|
+
assert.equal(slot.display(higher, { x: 0, z: 0 }, new Set(), 32_001), higher, 'a genuinely new session gets a new lease');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
{
|
|
61
|
+
const slot = makeAskSlot();
|
|
62
|
+
const yours = ask('yours:8:race:a:line:false:false', 'yours');
|
|
63
|
+
slot.display(yours, { x: 0, z: 0 }, new Set(), 0);
|
|
64
|
+
slot.frame({ x: 0, z: 0 }, new Set(), ASK_SLOT_MS);
|
|
65
|
+
for (let i = 0; i < 40; i += 1) {
|
|
66
|
+
slot.display(ask(`play:p${i}:race:${i}`, 'play'), { x: 0, z: 0 }, new Set(), ASK_SLOT_MS + i + 1);
|
|
67
|
+
slot.display({ ...ask(`invite:p${i}:${i}`, 'invite'), slotKey: `invite:${i}` }, { x: 0, z: 0 }, new Set(), ASK_SLOT_MS + i + 1);
|
|
68
|
+
}
|
|
69
|
+
assert.equal(slot.display(yours, { x: 0, z: 0 }, new Set(), 20_000), null, 'many later occurrences cannot evict and revive an expired lower-priority kind');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
{
|
|
73
|
+
const actors = [
|
|
74
|
+
{ id: 'small', components: { Transform: { x: 1, z: 2 }, Shape: { radius: 0.5 }, HubPad: { door: 'race' } } },
|
|
75
|
+
{ id: 'default', components: { Transform: { x: 10, z: 10 }, HubPad: { door: 'cabinet' } } },
|
|
76
|
+
{ id: 'not-a-pad', components: { Transform: { x: 1, z: 2 }, Shape: { radius: 10 } } },
|
|
77
|
+
];
|
|
78
|
+
const scene = { getActors: () => actors };
|
|
79
|
+
assert.deepEqual([...padsAt(scene, { x: 1.5, z: 2 })], ['small'], 'pad edge is included');
|
|
80
|
+
assert.deepEqual([...padsAt(scene, { x: 1.5, z: 2 }, new Set(['small']))], [], 'a pad hidden from this player is not enterable');
|
|
81
|
+
assert.deepEqual([...padsAt(scene, { x: 12.299, z: 10 })], ['default'], 'all HubPads use the server default radius, including cabinets');
|
|
82
|
+
assert.deepEqual([...padsAt(scene, { x: 12.301, z: 10 })], []);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log('hub-game ask slot: first display, 12 s, exact 3 m, pad entry, redraws and 30 s reconnect passed');
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// v1.75 private prompts: real hub hooks, exact wire, privacy and eligibility.
|
|
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)]); }, answer(ctx, id, askId, text) { ops.push([id, askId, text]); }, ...(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 Ask = await import('../code/server/ask.js');
|
|
58
|
+
const spec = { id: 'pet-name', title: 'Only you will see this name', max: 16 };
|
|
59
|
+
const wire = (r) => r.sent.filter(([, msg]) => msg.k === 'hub-ask');
|
|
60
|
+
const offer = (r, playerId = 'p1') => wire(r).findLast(([id]) => id === playerId)?.[1];
|
|
61
|
+
const answer = (r, text = 'Rex', playerId = 'p1', prompt = offer(r, playerId)) => r.say(playerId, { k: 'hub-answer', id: prompt?.id, n: prompt?.n, text });
|
|
62
|
+
let passed = 0;
|
|
63
|
+
async function test(name, fn) { await fn(); passed += 1; console.log(`ok: ${name}`); }
|
|
64
|
+
|
|
65
|
+
await test('manifest: main and named places accept only true or an absent key', async () => {
|
|
66
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-ask-'));
|
|
67
|
+
try {
|
|
68
|
+
fs.mkdirSync(path.join(dir, 'scenes'));
|
|
69
|
+
fs.writeFileSync(path.join(dir, 'scenes/main.scene'), JSON.stringify({ actors }));
|
|
70
|
+
for (const named of [false, true]) {
|
|
71
|
+
for (const value of [true, false, null, 0, 1, '', 'true', [], {}, undefined]) {
|
|
72
|
+
const keys = named ? { places: { porch: { title: 'Porch', scene: 'scenes/main.scene', ask: value } } } : { ask: value };
|
|
73
|
+
const read = Manifest.readManifest(json(keys));
|
|
74
|
+
assert.equal(read.errors.some((e) => e.includes('.ask')), value !== true);
|
|
75
|
+
fs.writeFileSync(path.join(dir, 'castle.json'), JSON.stringify({ ...json(keys), server: { main: 'code/server/index.js', maxPlayers: 8 } }));
|
|
76
|
+
const published = await check({ deckDir: dir, self: true });
|
|
77
|
+
assert.equal(published.errors.some((e) => e.includes('.ask')), value !== true && value !== undefined);
|
|
78
|
+
if (value === true) assert.equal(read.manifest.places[named ? 'porch' : 'main'].ask, true);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const plain = Manifest.readManifest(json()).manifest.places.main;
|
|
82
|
+
assert(!Object.hasOwn(plain, 'ask')); assert(!Object.hasOwn(Manifest.publicPlace('main', plain), 'ask'));
|
|
83
|
+
} finally { fs.rmSync(dir, { recursive: true }); }
|
|
84
|
+
});
|
|
85
|
+
await test('atomic validation, own keys, copied single reads and Unicode code points', () => {
|
|
86
|
+
const r = boot({ ask: true });
|
|
87
|
+
r.hub.ask('p1', spec); r.tick(250); const before = offer(r);
|
|
88
|
+
const invalid = [undefined, false, [], 'x', {}, { ...spec, id: 'A' }, { ...spec, id: 'pet-name\n' }, { ...spec, id: 'a'.repeat(25) }, { ...spec, title: '' }, { ...spec, title: ' ' }, { ...spec, title: '😀'.repeat(33) }, ...[0, 33, 1.5, '16', NaN, Infinity].map((max) => ({ ...spec, max })), { ...spec, extra: 1 }, { ...spec, [Symbol('extra')]: 1 }, Object.create(spec), new Date()];
|
|
89
|
+
invalid.push(Object.defineProperty({ ...spec }, 'hidden', { value: 1 }));
|
|
90
|
+
for (const cp of [...Array.from({ length: 32 }, (_, i) => i), ...Array.from({ length: 33 }, (_, i) => 0x7f + i), 0x061c, 0x200b, 0x200c, 0x200d, 0x200e, 0x200f, 0x202a, 0x202b, 0x202c, 0x202d, 0x202e, ...Array.from({ length: 10 }, (_, i) => 0x2060 + i), 0xfeff]) invalid.push({ ...spec, title: `a${String.fromCodePoint(cp)}b` });
|
|
91
|
+
for (const bad of invalid) assert.throws(() => r.hub.ask('p1', bad), TypeError);
|
|
92
|
+
assert.throws(() => r.hub.ask(null, spec), TypeError); r.tick(250); assert.deepEqual(offer(r), before);
|
|
93
|
+
const reads = { id: 0, title: 0, max: 0 }, getters = {};
|
|
94
|
+
for (const key of Object.keys(reads)) Object.defineProperty(getters, key, { get() { reads[key] += 1; return reads[key] === 1 ? spec[key] : null; } });
|
|
95
|
+
r.hub.ask('p2', getters); r.tick(250); assert.deepEqual(reads, { id: 1, title: 1, max: 1 });
|
|
96
|
+
const copy = { ...spec, title: '😀'.repeat(32), max: 32 };
|
|
97
|
+
r.hub.ask('p1', copy); copy.title = 'mutated'; r.tick(250); assert.equal(offer(r).title, '😀'.repeat(32));
|
|
98
|
+
assert.equal(r.hub.ask('p1', Object.assign(Object.create(null), { ...spec, title: '😀'.repeat(32), max: 32 })), true);
|
|
99
|
+
assert.equal(r.hub.ask('unknown', spec), false);
|
|
100
|
+
assert.throws(() => r.hub.ask('unknown', {}), TypeError);
|
|
101
|
+
});
|
|
102
|
+
await test('not-arrived, disconnected and place-only API; arrive may already ask', () => {
|
|
103
|
+
const r = boot({ ask: true }, { hello: false });
|
|
104
|
+
assert.equal(r.hub.ask('p1', spec), false); answer(r); assert.deepEqual(r.ops, []);
|
|
105
|
+
let ok; boot({ ask: true }, { hooks: { arrive(ctx, group) { ok = ctx.ask(group[0].playerId, spec); } } }); assert.equal(ok, true);
|
|
106
|
+
const named = boot({ ask: true, places: { porch: { title: 'Porch', scene: 'scenes/porch.scene' } } });
|
|
107
|
+
const captured = named.hub.ask; named.session.place = 'porch'; named.server.sceneFor(named.session);
|
|
108
|
+
assert.equal(named.hub.ask, undefined); assert.throws(() => captured('p1', spec), TypeError);
|
|
109
|
+
r.session.players = []; assert.equal(r.hub.ask('p1', spec), false);
|
|
110
|
+
});
|
|
111
|
+
await test('coalesced private offers, same-spec suppression, session versions and safe overflow', () => {
|
|
112
|
+
const r = boot({ ask: true }); r.sent.length = 0;
|
|
113
|
+
for (let i = 0; i < 10000; i++) r.hub.ask('p1', { ...spec, title: String(i) });
|
|
114
|
+
assert.deepEqual(wire(r), []); r.tick(250);
|
|
115
|
+
assert.deepEqual(wire(r), [['p1', { k: 'hub-ask', ...spec, title: '9999', n: 10000 }]]);
|
|
116
|
+
r.hub.ask('p1', { ...spec, title: '9999' }); r.tick(250); assert.equal(wire(r).length, 1);
|
|
117
|
+
const old = offer(r);
|
|
118
|
+
r.hub.ask('p1', spec); r.hub.ask('p1', { ...spec, title: '9999' }); r.tick(250); assert.equal(wire(r).length, 2, 'equal content with advanced n is delivered');
|
|
119
|
+
assert.equal(offer(r).n, 10002); answer(r, 'Rex', 'p1', old); assert.deepEqual(r.ops, [], 'changed-back prompt still invalidates old answer');
|
|
120
|
+
r.say('p1', { k: 'hub-hello', resume: true }); assert.equal(offer(r).n, 10002);
|
|
121
|
+
r.hub.ask('p2', spec); r.tick(250); assert.equal(offer(r, 'p2').n, 10003);
|
|
122
|
+
const times = []; const send = r.session.send;
|
|
123
|
+
r.session.send = (id, msg) => { if (msg.k === 'hub-ask') times.push(r.world.timeMs); send(id, msg); };
|
|
124
|
+
for (let i = 0; i < 100; i++) { r.hub.ask('p1', { ...spec, title: String(i) }); r.tick(10); }
|
|
125
|
+
assert.equal(times.length, 4); assert(times.slice(1).every((at, i) => at - times[i] >= 250));
|
|
126
|
+
const h = { place: { ask: true }, session: { players: [{ playerId: 'p' }] }, sim: { players: new Map([['p', {}]]) }, players: new Map([['p', { arrived: true }]]), askSeq: Number.MAX_SAFE_INTEGER };
|
|
127
|
+
assert.throws(() => Ask.set(h, 'p', spec), TypeError); assert(!Object.hasOwn(h, 'askMe'));
|
|
128
|
+
});
|
|
129
|
+
await test('accept once, exact unnormalised text, consume before hook and coalesce close; no text in wire/state', () => {
|
|
130
|
+
let consumed;
|
|
131
|
+
const r = boot({ ask: true }, { hooks: { answer(ctx, id, promptId, text) { r.ops.push([id, promptId, text]); answer(r, text); consumed = r.ops.length === 1; } } });
|
|
132
|
+
r.hub.ask('p1', spec); r.tick(250); const prompt = offer(r), text = ' Réx ';
|
|
133
|
+
answer(r, text); answer(r, text, 'p1', prompt);
|
|
134
|
+
assert(consumed); assert.deepEqual(r.ops, [['p1', spec.id, text]]);
|
|
135
|
+
assert.deepEqual(offer(r), prompt, 'close waits for ordinary delivery budget');
|
|
136
|
+
r.tick(250); assert.deepEqual(offer(r), { k: 'hub-ask', id: null, n: prompt.n + 1 });
|
|
137
|
+
assert(!JSON.stringify([r.sent, r.server.join(), r.server.delta()]).includes(text));
|
|
138
|
+
r.tick(500); r.hub.ask('p1', spec); r.tick(250); answer(r, null);
|
|
139
|
+
assert.deepEqual(r.ops.at(-1), ['p1', spec.id, null]);
|
|
140
|
+
});
|
|
141
|
+
await test('accepted answer closes share the four/s tick delivery budget', () => {
|
|
142
|
+
const r = boot({ ask: true }); r.sent.length = 0;
|
|
143
|
+
for (let i = 0; i < 4; i++) {
|
|
144
|
+
r.hub.ask('p1', spec); r.tick(250); const count = wire(r).length;
|
|
145
|
+
answer(r); assert.equal(wire(r).length, count, 'no immediate over-budget close');
|
|
146
|
+
r.tick(249); assert.equal(wire(r).length, count);
|
|
147
|
+
r.tick(1); assert.equal(wire(r).length, count + 1); assert.equal(offer(r).id, null);
|
|
148
|
+
}
|
|
149
|
+
assert.equal(r.ops.length, 4);
|
|
150
|
+
});
|
|
151
|
+
await test('unsent, changed, closed and another player answers are dropped', () => {
|
|
152
|
+
const r = boot({ ask: true }); r.hub.ask('p1', spec);
|
|
153
|
+
answer(r, 'Rex', 'p1', { id: spec.id, n: 1 }); assert.deepEqual(r.ops, []);
|
|
154
|
+
r.tick(250); const old = offer(r); answer(r, 'Rex', 'p2', old); assert.deepEqual(r.ops, []);
|
|
155
|
+
r.hub.ask('p1', { ...spec, title: 'New title' });
|
|
156
|
+
answer(r, 'Rex', 'p1', old); answer(r, 'Rex', 'p1', { ...old, n: old.n + 1 }); assert.deepEqual(r.ops, []);
|
|
157
|
+
r.tick(2000); r.tick(250); answer(r); assert.equal(r.ops.length, 1);
|
|
158
|
+
r.tick(2000); r.hub.ask('p1', spec); r.tick(250); const closing = offer(r); r.hub.ask('p1', null); answer(r, 'Rex', 'p1', closing); assert.equal(r.ops.length, 1);
|
|
159
|
+
});
|
|
160
|
+
await test('refused text on the current prompt consumes as cancel, never passes text or echoes it', () => {
|
|
161
|
+
const r = boot({ ask: true });
|
|
162
|
+
const bad = ['', ' ', 'x'.repeat(65), 'x'.repeat(17), '😀'.repeat(17), 'R\nex', 'R\u061cex', 'R\u200bex', 'R\u200cex', 'R\u200dex', 'R\u202eex', 'R\u2068ex', 'R\ufeffex', 7, {}, []];
|
|
163
|
+
for (const text of bad) {
|
|
164
|
+
r.hub.ask('p1', spec); r.tick(500); const prompt = offer(r), before = r.ops.length;
|
|
165
|
+
answer(r, text); assert.deepEqual(r.ops.at(-1), ['p1', spec.id, null]); assert.equal(r.ops.length, before + 1);
|
|
166
|
+
answer(r, 'Duplicate', 'p1', prompt); assert.equal(r.ops.length, before + 1);
|
|
167
|
+
r.tick(250); assert.deepEqual(offer(r), { k: 'hub-ask', id: null, n: prompt.n + 1 });
|
|
168
|
+
}
|
|
169
|
+
assert(r.ops.every(([, , text]) => text === null));
|
|
170
|
+
assert(!JSON.stringify([r.sent, r.server.join(), r.server.delta()]).includes('R\u061cex'));
|
|
171
|
+
});
|
|
172
|
+
await test('malformed and stale envelopes drop, spend tokens and leave the prompt unchanged', () => {
|
|
173
|
+
const r = boot({ ask: true }); r.hub.ask('p1', spec); r.tick(250);
|
|
174
|
+
for (const n of [undefined, null, true, '1', 1.5, NaN, Infinity, Number.MAX_SAFE_INTEGER + 1]) { r.tick(500); answer(r, 'Rex', 'p1', { ...offer(r), n }); }
|
|
175
|
+
r.tick(2000);
|
|
176
|
+
for (const extra of [{ extra: 1 }, { [Symbol('extra')]: 1 }]) r.say('p1', { k: 'hub-answer', id: spec.id, n: offer(r).n, text: 'Rex', ...extra });
|
|
177
|
+
r.say('p1', { k: 'hub-answer', id: spec.id, n: offer(r).n });
|
|
178
|
+
answer(r, 'x'.repeat(1000000), 'p1', { ...offer(r), n: -1 });
|
|
179
|
+
answer(r); assert.deepEqual(r.ops, [], 'four invalid attempts exhaust burst');
|
|
180
|
+
r.tick(499); answer(r); assert.deepEqual(r.ops, []); r.tick(1); answer(r); assert.equal(r.ops.length, 1);
|
|
181
|
+
const h = { place: { ask: true }, session: { players: [{ playerId: 'p' }], send() {} }, sim: { timeMs: 0, players: new Map([['p', {}]]) }, players: new Map([['p', { arrived: true }]]), ctx: {}, hooks: {} };
|
|
182
|
+
Ask.set(h, 'p', spec); Ask.prune(h); Ask.message(h, 'p', { k: 'hub-answer', id: spec.id, n: 1, text: 'SecretRex' });
|
|
183
|
+
assert(!JSON.stringify(h).includes('SecretRex')); assert(!JSON.stringify([...h.askMe.values()]).includes('SecretRex'));
|
|
184
|
+
});
|
|
185
|
+
await test('answer/cancel then immediate reopening of the same spec delivers its new version', () => {
|
|
186
|
+
for (const text of ['Rex', null]) {
|
|
187
|
+
const r = boot({ ask: true }, { hooks: { answer(ctx, playerId, promptId, text) { r.ops.push([playerId, promptId, text]); ctx.ask(playerId, spec); } } });
|
|
188
|
+
r.hub.ask('p1', spec); r.tick(250); const old = offer(r), count = wire(r).length;
|
|
189
|
+
answer(r, text); assert.equal(wire(r).length, count); r.tick(250);
|
|
190
|
+
assert.deepEqual(offer(r), { k: 'hub-ask', ...spec, n: old.n + 2 });
|
|
191
|
+
answer(r, 'Old', 'p1', old); assert.equal(r.ops.length, 1);
|
|
192
|
+
answer(r, 'Fresh'); assert.equal(r.ops.length, 2); assert.equal(r.ops.at(-1)[2], 'Fresh');
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
await test('throwing getters/Proxies are silent, contained and spend budget; wide envelopes reject before key arrays or fields', () => {
|
|
196
|
+
const calls = [], h = { place: { ask: true }, session: { players: [{ playerId: 'p' }], send() {} }, sim: { timeMs: 0, players: new Map([['p', {}]]) }, players: new Map([['p', { arrived: true }]]), ctx: {}, hooks: { answer(...args) { calls.push(args); } } };
|
|
197
|
+
Ask.set(h, 'p', spec); Ask.prune(h);
|
|
198
|
+
const wire = { k: 'hub-answer', id: spec.id, n: 1, text: 'SecretRex' }, warn = console.warn, warnings = [];
|
|
199
|
+
console.warn = (...args) => warnings.push(args);
|
|
200
|
+
try {
|
|
201
|
+
const invalid = ['k', 'id', 'n', 'text'].map((key) => Object.defineProperty({ ...wire }, key, { get() { throw new Error('SecretRex'); } }));
|
|
202
|
+
invalid.push(new Proxy(wire, { getPrototypeOf() { throw new Error('SecretRex'); } }), new Proxy(wire, { ownKeys() { throw new Error('SecretRex'); } }), new Proxy(wire, { getOwnPropertyDescriptor() { throw new Error('SecretRex'); } }));
|
|
203
|
+
const revoked = Proxy.revocable(wire, {}); revoked.revoke(); invalid.push(revoked.proxy);
|
|
204
|
+
for (const msg of invalid) { h.sim.timeMs += 500; assert.doesNotThrow(() => Ask.message(h, 'p', msg)); }
|
|
205
|
+
assert.deepEqual(calls, []); assert.deepEqual(warnings, []); assert.equal(h.askMe.get('p').spec.id, spec.id);
|
|
206
|
+
h.sim.timeMs += 2000;
|
|
207
|
+
for (let i = 0; i < 4; i++) Ask.message(h, 'p', invalid[0]); Ask.message(h, 'p', wire); assert.deepEqual(calls, []);
|
|
208
|
+
h.sim.timeMs += 500;
|
|
209
|
+
let reads = 0;
|
|
210
|
+
const wide = { ...wire }; Object.defineProperty(wide, 'k', { enumerable: true, get() { reads++; return 'hub-answer'; } });
|
|
211
|
+
for (let i = 0; i < 10000; i++) wide[`extra${i}`] = true;
|
|
212
|
+
const ownKeys = Reflect.ownKeys; let reflected = false;
|
|
213
|
+
Reflect.ownKeys = (value) => { if (value === wide) reflected = true; return ownKeys(value); };
|
|
214
|
+
try { Ask.message(h, 'p', wide); } finally { Reflect.ownKeys = ownKeys; }
|
|
215
|
+
assert.equal(reads, 0); assert.equal(reflected, false);
|
|
216
|
+
h.sim.timeMs += 500;
|
|
217
|
+
const nonplain = Object.assign(Object.create({ inherited: true }), wire);
|
|
218
|
+
const hostile = new Proxy(nonplain, { ownKeys() { throw new Error('should not enumerate'); } });
|
|
219
|
+
assert.doesNotThrow(() => Ask.message(h, 'p', hostile)); assert.deepEqual(calls, []);
|
|
220
|
+
h.sim.timeMs += 500; Ask.message(h, 'p', wire); assert.equal(calls[0][3], 'SecretRex');
|
|
221
|
+
} finally { console.warn = warn; }
|
|
222
|
+
});
|
|
223
|
+
await test('flooding budget is per player and refills two/s, malformed attempts included', () => {
|
|
224
|
+
const r = boot({ ask: true }); r.hub.ask('p1', spec); r.hub.ask('p2', spec); r.tick(250);
|
|
225
|
+
for (let i = 0; i < 100; i++) r.say('p1', { k: 'hub-answer' });
|
|
226
|
+
answer(r); assert.deepEqual(r.ops, []); answer(r, 'Bo', 'p2'); assert.deepEqual(r.ops, [['p2', spec.id, 'Bo']]);
|
|
227
|
+
r.tick(500); answer(r); assert.equal(r.ops.length, 2);
|
|
228
|
+
});
|
|
229
|
+
await test('throw and rejection contained and logged once without text or error details', async () => {
|
|
230
|
+
const warnings = [], warn = console.warn, secret = 'SecretRex'; console.warn = (...args) => warnings.push(args.join(' '));
|
|
231
|
+
try {
|
|
232
|
+
let calls = 0;
|
|
233
|
+
const r = boot({ ask: true }, { hooks: { answer() { calls += 1; if (calls === 1) throw new Error(secret); return Promise.reject(new Error(secret)); } } });
|
|
234
|
+
for (let i = 0; i < 2; i++) { r.hub.ask('p1', spec); r.tick(500); answer(r, secret); r.tick(250); }
|
|
235
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
236
|
+
assert.equal(calls, 2); assert.deepEqual(warnings, ['[hub] answer hook failed']); assert(!JSON.stringify(r.sent).includes(secret));
|
|
237
|
+
} finally { console.warn = warn; }
|
|
238
|
+
});
|
|
239
|
+
await test('fresh hello replay once, null replay, forget on leave, never reuse session versions', () => {
|
|
240
|
+
const r = boot({ ask: true }); r.hub.ask('p1', spec); r.tick(250); const old = offer(r).n;
|
|
241
|
+
r.sent.length = 0; r.say('p1', { k: 'hub-hello', resume: true }); r.tick(250);
|
|
242
|
+
assert.deepEqual(wire(r), [['p1', { k: 'hub-ask', ...spec, n: old }]]);
|
|
243
|
+
r.sent.length = 0; r.say('p1', { k: 'hub-hello', again: true }); assert.deepEqual(wire(r), []);
|
|
244
|
+
r.hub.ask('p1', null); r.say('p1', { k: 'hub-hello', resume: true }); r.tick(250); assert.deepEqual(offer(r), { k: 'hub-ask', id: null, n: old + 1 });
|
|
245
|
+
r.hub.ask('p1', spec); r.tick(250); const n = offer(r).n, body = r.world.players.get('p1');
|
|
246
|
+
r.session.players = [players[1]]; r.world.players.delete('p1'); r.tick(); assert.equal(r.hub.ask('p1', spec), false);
|
|
247
|
+
r.session.players.push(players[0]); r.world.players.set('p1', body); r.sent.length = 0;
|
|
248
|
+
r.say('p1', { k: 'hub-hello', resume: true }); r.tick(); assert.deepEqual(offer(r), { k: 'hub-ask', id: null, n: 0 });
|
|
249
|
+
r.hub.ask('p1', spec); r.tick(250); assert.equal(offer(r).n, n + 1); answer(r, 'Rex', 'p1', { id: spec.id, n }); assert.deepEqual(r.ops, []);
|
|
250
|
+
});
|
|
251
|
+
await test('absent key: no API, hook lookup, private state, snapshot/delta key or extra wire; traces identical', () => {
|
|
252
|
+
function trace(inject) {
|
|
253
|
+
const r = boot(); Object.defineProperty(r.hooks, 'answer', { get() { throw new Error('keyless hook lookup'); } });
|
|
254
|
+
assert.equal(r.hub.ask, undefined); assert(!Object.hasOwn(r.hub, 'ask'));
|
|
255
|
+
const snapshots = [JSON.stringify(r.server.join())], deltas = [];
|
|
256
|
+
for (let i = 0; i < 4; i++) {
|
|
257
|
+
if (inject) r.say('p1', { k: 'hub-answer', id: spec.id, n: 1, text: 'PrivateRex' });
|
|
258
|
+
r.tick(250); snapshots.push(JSON.stringify(r.server.join())); deltas.push(JSON.stringify(r.server.delta()));
|
|
259
|
+
}
|
|
260
|
+
assert.deepEqual(wire(r), []); assert.deepEqual(r.ops, []);
|
|
261
|
+
assert(!JSON.stringify([r.sent, snapshots, deltas]).includes('PrivateRex'));
|
|
262
|
+
assert(snapshots.every((s) => !s.includes('"ask"'))); assert(deltas.every((s) => !s?.includes('"ask"')));
|
|
263
|
+
return JSON.stringify([r.sent, snapshots, deltas]);
|
|
264
|
+
}
|
|
265
|
+
assert.equal(trace(true), trace(false));
|
|
266
|
+
const h = { place: {}, session: { players: [{ playerId: 'p' }] }, sim: { players: new Map([['p', {}]]) } }, keys = Reflect.ownKeys(h);
|
|
267
|
+
Ask.message(h, 'p', { k: 'hub-answer', text: 'Rex' }); assert.deepEqual(Reflect.ownKeys(h), keys);
|
|
268
|
+
});
|
|
269
|
+
console.log(`${passed} ask tests passed`);
|
|
@@ -77,7 +77,8 @@ const tags = new Map([
|
|
|
77
77
|
const mp = { avatars: { tags } };
|
|
78
78
|
const touched = new WeakMap();
|
|
79
79
|
fadeNames(mp, { x: 0, z: 0 }, true, touched);
|
|
80
|
-
assert.equal(tags.get('self').sprite.visible,
|
|
80
|
+
assert.equal(tags.get('self').sprite.visible, false, 'no own name tag in a hub place');
|
|
81
|
+
assert.equal(tags.get('self').sprite.scale.x, 1, 'the hidden own tag is not resized');
|
|
81
82
|
assert.equal(tags.get('p-near').sprite.visible, true);
|
|
82
83
|
assert.equal(tags.get('p-far').sprite.visible, false);
|
|
83
84
|
assert.equal(tags.get('p-near').sprite.scale.x, NAME_SCALE);
|
|
@@ -94,6 +95,14 @@ assert.equal(tags.get('p-far').sprite.visible, true);
|
|
|
94
95
|
assert.equal(tags.get('p-far').sprite.material.opacity, 1);
|
|
95
96
|
assert.equal(tags.get('p-near').sprite.scale.x, 0.5, 'a shrunk tag the multiplayer kit did not resize is put back');
|
|
96
97
|
assert.equal(tags.get('self').sprite.scale.y, 0.2);
|
|
98
|
+
assert.equal(tags.get('self').sprite.visible, true, 'out of every place the own tag is back');
|
|
99
|
+
// A place that is not the town (a house, a door game, a result): still no own tag,
|
|
100
|
+
// and other players' tags are left as the multiplayer kit drew them.
|
|
101
|
+
fadeNames(mp, { x: 0, z: 0 }, false, touched, true);
|
|
102
|
+
assert.equal(tags.get('self').sprite.visible, false);
|
|
103
|
+
assert.equal(tags.get('p-far').sprite.visible, true);
|
|
104
|
+
fadeNames(mp, { x: 0, z: 0 }, false, touched, false);
|
|
105
|
+
assert.equal(tags.get('self').sprite.visible, true);
|
|
97
106
|
// Town, out, town again with no resize between: shrunk once, not twice.
|
|
98
107
|
fadeNames(mp, { x: 0, z: 0 }, true, touched);
|
|
99
108
|
fadeNames(mp, { x: 0, z: 0 }, false, touched);
|