castle-web-cli 0.4.233 → 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/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 +17 -2
- package/dist/castle-host/host.js +793 -36
- package/dist/castleJson.d.ts +20 -1
- package/dist/castleJson.js +44 -2
- package/dist/check.js +9 -2
- 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 +3 -1
- 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/index.js +8 -2
- package/dist/init.js +1 -1
- package/dist/save-deck.d.ts +20 -1
- package/dist/save-deck.js +141 -5
- package/dist/serve.js +29 -11
- package/dist/shell/assets/{index-BjOxR-lW.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/index.html +1 -1
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +260 -3
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +162 -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 +33 -6
- package/kits/base/sdk/hub.js +50 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +140 -40
- 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 +79 -6
- package/kits/base/sdk/server/hub.d.ts +31 -1
- package/kits/base/sdk/server/hub.js +50 -3
- package/kits/base/sdk/server/platformHandle.d.ts +13 -1
- package/kits/base/sdk/server/storage.d.ts +4 -0
- package/kits/base/sdk/server/storage.js +19 -3
- package/kits/base/sdk/server/wrapper.d.ts +7 -1
- package/kits/base/sdk/server/wrapper.js +10 -1
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +123 -3
- package/kits/hub-game/README.md +63 -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/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/avatar.js +4 -2
- package/kits/hub-game/code/client/avatarShare.js +2 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +15 -10
- package/kits/hub-game/code/client/build.js +16 -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 +1148 -258
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +10 -4
- 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/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 +31 -11
- package/kits/hub-game/code/client/hookLayer.js +87 -8
- 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 +14 -2
- 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/labelsNear.js +31 -2
- 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/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- 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/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 +64 -10
- 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/state.js +53 -0
- package/kits/hub-game/code/client/talk.js +209 -45
- package/kits/hub-game/code/client/tiers.js +68 -66
- package/kits/hub-game/code/client/together.js +7 -2
- 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/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +10 -9
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +6 -1
- package/kits/hub-game/code/server/actors.js +2 -1
- 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/companion.js +28 -3
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +22 -5
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendsAmong.js +49 -9
- package/kits/hub-game/code/server/history.js +2 -0
- package/kits/hub-game/code/server/hub.js +1306 -95
- package/kits/hub-game/code/server/idle.js +30 -1
- package/kits/hub-game/code/server/index.js +26 -4
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +9 -1
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +211 -3
- package/kits/hub-game/code/server/menu.js +31 -3
- package/kits/hub-game/code/server/npcs.js +226 -64
- 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/players.js +9 -1
- 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/standing.js +4 -5
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +67 -5
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -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 +35 -1
- package/kits/hub-game/code/systems/hub.js +970 -169
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/contract.md +1257 -42
- package/kits/hub-game/docs/home-pieces.md +9 -2
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/package-lock.json +10 -3
- package/kits/hub-game/package.json +6 -3
- 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 +39 -5
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -1
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +11 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +5 -5
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +3 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +19 -3
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +3 -3
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -1
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -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 +367 -2
- package/kits/hub-game/scripts/test-actors.mjs +20 -7
- 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-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +49 -10
- package/kits/hub-game/scripts/test-avatar.mjs +44 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +11 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +20 -2
- package/kits/hub-game/scripts/test-chat.mjs +206 -5
- package/kits/hub-game/scripts/test-companion-chat.mjs +20 -2
- 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 +45 -4
- package/kits/hub-game/scripts/test-decor.mjs +7 -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.mjs +33 -3
- 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-grab-orbit.mjs +47 -4
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +321 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +879 -11
- package/kits/hub-game/scripts/test-hud-clear.mjs +162 -59
- 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 +66 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +20 -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-labels.mjs +71 -3
- 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 +265 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +105 -0
- package/kits/hub-game/scripts/test-menu.mjs +23 -0
- package/kits/hub-game/scripts/test-npcs.mjs +819 -10
- package/kits/hub-game/scripts/test-observed.mjs +745 -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 +234 -7
- 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 +699 -5
- 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 +145 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +22 -17
- package/kits/hub-game/scripts/test-standing.mjs +35 -2
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +5 -4
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +86 -13
- package/kits/hub-game/scripts/test-tiers.mjs +7 -8
- package/kits/hub-game/scripts/test-vis.mjs +433 -6
- 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 +50 -6
- package/kits/hub-game/scripts/test-yours.mjs +39 -8
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +369 -30
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +10 -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 +87 -5
- 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-3d/CLAUDE.md +25 -1651
- 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 +35 -18
- 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 +1 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -333
- package/kits/physics-3d/engine3d/actornode.js +1 -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/framecap.js +4 -1
- 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 +8 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/look.js +7 -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 +3 -3
- package/kits/physics-3d/engine3d/nearshadows.js +77 -10
- package/kits/physics-3d/engine3d/orbitinput.js +59 -25
- 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 +3 -3
- 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 +23 -15
- package/kits/physics-3d/engine3d/sky.js +1 -1
- 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/world3d.js +468 -18
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +6 -3
- 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/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +52 -4
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +6 -3
- package/kits/physics-3d/scripts/test-frame-cap.mjs +1 -1
- 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-look-bake.mjs +1 -1
- package/kits/physics-3d/scripts/test-near-shadows.mjs +2 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +88 -7
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +40 -3
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +75 -1
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-sky.mjs +1 -1
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +3 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +5 -2
- package/kits/physics-3d/scripts/test-steady-hover.mjs +5 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/systems/physics3d.js +37 -4
- 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/session.js +6 -4
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// v1.127: private prompt sets and one-shot presses. No state without hub.act.
|
|
2
|
+
import { interaction } from '../shared/act.js';
|
|
3
|
+
import * as Idle from './idle.js';
|
|
4
|
+
import * as Grab from './grab.js';
|
|
5
|
+
|
|
6
|
+
export const HOLD_MS = 500;
|
|
7
|
+
export const HOLD_LATENCY_ALLOWANCE_MS = 150;
|
|
8
|
+
const MAX_HOLD_MS = 2000;
|
|
9
|
+
function available(h, id) {
|
|
10
|
+
const entry = h.players.get(id);
|
|
11
|
+
return entry?.arrived && !entry.ended && !entry.progressReading &&
|
|
12
|
+
h.session?.players.some(p => p.playerId === id) && h.sim.players.has(id) &&
|
|
13
|
+
!h.resumeDeparting?.has(id) && !h.actDeparting?.has(id) && !h.resumePending?.has(id) &&
|
|
14
|
+
(!h.held.has(id) || Boolean(Idle.seat(h, id)));
|
|
15
|
+
}
|
|
16
|
+
function shown(h, id, actor) {
|
|
17
|
+
return !(h.visMe?.get(id)?.get(actor) ?? h.hidden.has(actor));
|
|
18
|
+
}
|
|
19
|
+
function pose(h, actor) {
|
|
20
|
+
return h.sim.objects?.get(actor.id)?.body?.translation() ?? h.sim.bodies?.get(actor.id)?.translation() ??
|
|
21
|
+
h.poses?.get(actor.id) ?? h.spawned?.get(actor.id)?.at ?? actor.components.Transform;
|
|
22
|
+
}
|
|
23
|
+
export function offers(h, id) {
|
|
24
|
+
if (!available(h, id)) {return [];}
|
|
25
|
+
const at = h.sim.players.get(id).at, seated = Idle.seat(h, id), holding = Grab.holding(h, id);
|
|
26
|
+
const out = [], seen = new Set(), duplicate = new Set();
|
|
27
|
+
const actors = [...h.actors, ...[...(h.spawned?.values() ?? [])].map(entry => entry.actor)];
|
|
28
|
+
for (const actor of actors) {
|
|
29
|
+
const item = interaction(actor, h.place, h.spawned?.has(actor.id));
|
|
30
|
+
if (!item) {continue;}
|
|
31
|
+
if (seen.has(item.id)) {duplicate.add(item.id);}
|
|
32
|
+
seen.add(item.id);
|
|
33
|
+
if (!shown(h, id, actor.id) || (seated && actor.id !== seated) || (holding && actor.id !== holding)) {continue;}
|
|
34
|
+
const t = { ...actor.components.Transform, ...pose(h, actor) };
|
|
35
|
+
if (!at || !t || !Number.isFinite(t.x) || !Number.isFinite(t.y) || !Number.isFinite(t.z)) {continue;}
|
|
36
|
+
let distance = Math.hypot(at.x - t.x, at.y - t.y, at.z - t.z);
|
|
37
|
+
if (item.op === 'sit') {
|
|
38
|
+
if (!Idle.seatOf(h, actor.id) || [...h.seated].some(([other, seat]) => other !== id && seat === actor.id)) {continue;}
|
|
39
|
+
distance = Idle.footprintDistance({ ...actor, components: { ...actor.components, Transform: t } }, at);
|
|
40
|
+
if (Math.abs(at.y - t.y) > 3) {continue;}
|
|
41
|
+
if (seated) {item.verb = 'Stand'; item.op = 'stand';}
|
|
42
|
+
}
|
|
43
|
+
if (item.op === 'grab') {
|
|
44
|
+
const object = h.sim.objects?.get(actor.id);
|
|
45
|
+
if (!object?.body || object.owner !== id || (h.keptFor?.has(actor.id) && h.keptFor.get(actor.id) !== id)) {continue;}
|
|
46
|
+
if (holding) {item.verb = 'Throw'; item.op = 'throw'; distance = 0;}
|
|
47
|
+
else if (!object.claimable) {continue;}
|
|
48
|
+
}
|
|
49
|
+
if (distance <= item.reach) {out.push(item);}
|
|
50
|
+
}
|
|
51
|
+
return out.filter(item => !duplicate.has(item.id)).sort((a, b) => a.id.localeCompare(b.id));
|
|
52
|
+
}
|
|
53
|
+
function state(h, id) {
|
|
54
|
+
h.actPlayers ??= new Map();
|
|
55
|
+
if (!h.actPlayers.has(id)) {h.actPlayers.set(id, { json: null, sent: [], last: 0, hold: null });}
|
|
56
|
+
return h.actPlayers.get(id);
|
|
57
|
+
}
|
|
58
|
+
function sync(h, id, replay = false) {
|
|
59
|
+
const s = state(h, id), items = offers(h, id).map(({ id, verb, hold }) => ({ id, verb, hold }));
|
|
60
|
+
const json = JSON.stringify(items);
|
|
61
|
+
if (json !== s.json || replay) {
|
|
62
|
+
s.hold = null;
|
|
63
|
+
s.json = json; s.sent = items;
|
|
64
|
+
h.session.send(id, { k: 'hub-prompts', items });
|
|
65
|
+
}
|
|
66
|
+
return s;
|
|
67
|
+
}
|
|
68
|
+
export function tick(h) {
|
|
69
|
+
if (h.manifest.act !== true) {return;}
|
|
70
|
+
for (const [id] of h.players) {
|
|
71
|
+
if (!h.session?.players.some(p => p.playerId === id)) {forget(h, id); continue;}
|
|
72
|
+
const s = sync(h, id);
|
|
73
|
+
if (s.hold && (h.sim.timeMs - s.hold.at > MAX_HOLD_MS || !offers(h, id).some(item => item.id === s.hold.id))) {s.hold = null;}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function replay(h, id) {
|
|
77
|
+
if (h.manifest.act === true) {h.actDeparting?.delete(id); sync(h, id, true);}
|
|
78
|
+
}
|
|
79
|
+
export function forget(h, id) {h.actPlayers?.delete(id); h.actDeparting?.delete(id);}
|
|
80
|
+
export function message(h, player, data, placeAt) {
|
|
81
|
+
if (h.manifest.act !== true || !available(h, player?.playerId)) {return;}
|
|
82
|
+
const id = player.playerId, s = state(h, id), now = h.sim.timeMs;
|
|
83
|
+
// Cancellation never waits for a rate token: an early release cannot be
|
|
84
|
+
// turned into a completed hold by exhausting the input budget.
|
|
85
|
+
if (data?.k === 'hub-act-hold' && data.down === false && s.hold?.id === data.id && s.hold.n === data.n) {s.hold = null; return;}
|
|
86
|
+
s.budget ??= { tokens: 8, at: now };
|
|
87
|
+
s.budget.tokens = Math.min(8, s.budget.tokens + Math.max(0, now - s.budget.at) * 0.006);
|
|
88
|
+
s.budget.at = now;
|
|
89
|
+
if (s.budget.tokens < 1) {return;}
|
|
90
|
+
s.budget.tokens -= 1;
|
|
91
|
+
const holdWire = data?.k === 'hub-act-hold';
|
|
92
|
+
if (!data || !Object.keys(data).every(key => (holdWire ? ['k', 'id', 'n', 'down'] : ['k', 'id', 'n']).includes(key)) ||
|
|
93
|
+
typeof data.id !== 'string' || !Number.isSafeInteger(data.n) || data.n <= 0) {return;}
|
|
94
|
+
const item = offers(h, id).find(item => item.id === data.id);
|
|
95
|
+
if (!item || !s.sent.some(sent => sent.id === item.id && sent.verb === item.verb && sent.hold === item.hold)) {
|
|
96
|
+
s.hold = null; return;
|
|
97
|
+
}
|
|
98
|
+
if (holdWire) {
|
|
99
|
+
if (typeof data.down !== 'boolean' || !item.hold) {return;}
|
|
100
|
+
if (!data.down) {
|
|
101
|
+
if (s.hold?.id === data.id && s.hold.n === data.n) {s.hold = null;}
|
|
102
|
+
} else if (data.n > s.last) {
|
|
103
|
+
s.last = data.n; s.hold = { id: item.id, n: data.n, at: now };
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (item.hold) {
|
|
108
|
+
const press = s.hold;
|
|
109
|
+
s.hold = null;
|
|
110
|
+
if (!press || press.id !== data.id || press.n !== data.n || now - press.at < HOLD_MS - HOLD_LATENCY_ALLOWANCE_MS || now - press.at > MAX_HOLD_MS) {return;}
|
|
111
|
+
} else {
|
|
112
|
+
if (data.n <= s.last) {return;}
|
|
113
|
+
s.last = data.n;
|
|
114
|
+
}
|
|
115
|
+
// Consume before hooks; even a hook that throws cannot repeat the press.
|
|
116
|
+
if (item.op === 'sit') {Idle.sitMessage(h, placeAt, id, { seat: item.actor });}
|
|
117
|
+
else if (item.op === 'stand') {Idle.standMessage(h, id);}
|
|
118
|
+
else if (item.op === 'grab' || item.op === 'throw') {Grab.message(h, id, { actor: item.actor, op: item.op });}
|
|
119
|
+
else if (item.op === 'talk') {h.npcs.message(player, { k: 'hub-npc-open', npc: item.actor });}
|
|
120
|
+
else {
|
|
121
|
+
try {h.hooks.message?.(h.ctx, player, { k: 'hub-act', id: item.id, n: data.n });}
|
|
122
|
+
catch {console.warn('[hub] Act message hook failed');}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -36,6 +36,11 @@ function arrived(h, playerId) {
|
|
|
36
36
|
const entry = h.players.get(playerId);
|
|
37
37
|
return present(h, playerId) && entry?.arrived && !entry.ended;
|
|
38
38
|
}
|
|
39
|
+
function resumePreparationPending(h, playerId) {
|
|
40
|
+
const entry = h.resumePending?.get(playerId);
|
|
41
|
+
return entry !== undefined && h.players.get(playerId) === entry &&
|
|
42
|
+
h.resumeKept?.get(playerId)?.visibilityResumePending === true;
|
|
43
|
+
}
|
|
39
44
|
function current(h, playerId) {
|
|
40
45
|
return h.actionsMe?.get(playerId) ?? { items: null, n: 0, json: 'null', sentJson: 'null', sentN: 0, sentAt: -Infinity };
|
|
41
46
|
}
|
|
@@ -85,7 +90,7 @@ export function message(h, playerId, data) {
|
|
|
85
90
|
return;
|
|
86
91
|
}
|
|
87
92
|
b.tokens -= 1;
|
|
88
|
-
if (!arrived(h, playerId) || !object(data) || data.k !== 'hub-action' ||
|
|
93
|
+
if (resumePreparationPending(h, playerId) || !arrived(h, playerId) || !object(data) || data.k !== 'hub-action' ||
|
|
89
94
|
!Object.keys(data).every((key) => ['k', 'id', 'n'].includes(key))) {
|
|
90
95
|
return;
|
|
91
96
|
}
|
|
@@ -432,7 +432,8 @@ export function templatesOf(h) {
|
|
|
432
432
|
const out = Object.create(null);
|
|
433
433
|
for (const { from } of h.spawned.values()) {
|
|
434
434
|
if (!Object.hasOwn(out, from)) {
|
|
435
|
-
|
|
435
|
+
const components = h.actors.find((a) => a.id === from)?.components ?? null;
|
|
436
|
+
out[from] = h.qualityDecor?.has(from) && components ? { ...components, decor: true } : components;
|
|
436
437
|
}
|
|
437
438
|
}
|
|
438
439
|
return out;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// v1.93: server only. A place without analytics creates no state or messages.
|
|
2
|
+
export const EVENTS = Object.freeze({ arrive: 1, door_enter: 2, door_exit: 3, game_result: 4,
|
|
3
|
+
activity_start: 5, activity_end: 6, outcome: 7, first_play: 8, pointer_stage: 9,
|
|
4
|
+
reconnect: 10, session_end: 11, furniture_placed: 12, furniture_moved: 13,
|
|
5
|
+
pet_named: 14, guestbook_signed: 15, house_visit: 16, house_time: 17,
|
|
6
|
+
npc_chat_count: 18, token_earned: 19, token_spent: 20, invite_sent: 21,
|
|
7
|
+
invite_opened: 22, invite_joined: 23, arrival_source: 24, join_failed: 25 });
|
|
8
|
+
export const SUBJECTS = Object.freeze({ town: 0, tag: 1, garden: 2, boat: 3, fishing: 4,
|
|
9
|
+
jobs: 5, lanterns: 6, stamps: 7, market: 8, npc: 9, house: 10 });
|
|
10
|
+
export const create = () => ({ visits: new Map(), departed: new Map() });
|
|
11
|
+
export function track(h, playerId, name, props = {}) {
|
|
12
|
+
// v1.111 events are emitted only by Ghost at its committed invite/admission
|
|
13
|
+
// boundaries. Authored server code cannot claim that one happened.
|
|
14
|
+
if (h.place.analytics !== true || !EVENTS[name] || EVENTS[name] >= EVENTS.invite_sent || !h.players.get(playerId)?.arrived) {return false;}
|
|
15
|
+
if (!props || typeof props !== 'object' || Array.isArray(props) || Object.keys(props).some((k) => !['subject', 'value', 'result', 'flags'].includes(k))) {return false;}
|
|
16
|
+
const event = { kind: EVENTS[name] };
|
|
17
|
+
for (const [key, max] of [['subject', 65535], ['value', 2147483647], ['result', 255], ['flags', 3]]) {
|
|
18
|
+
const n = Object.hasOwn(props, key) ? props[key] : 0;
|
|
19
|
+
if (!Number.isSafeInteger(n) || n < 0 || n > max) {return false;}
|
|
20
|
+
event[key] = n;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const pending = h.session?.hub?.track?.(playerId, event);
|
|
24
|
+
if (pending && typeof pending.catch === 'function') {pending.catch(() => {});}
|
|
25
|
+
return pending !== undefined && pending !== false;
|
|
26
|
+
} catch { return false; }
|
|
27
|
+
}
|
|
28
|
+
export function arrive(h, group) {
|
|
29
|
+
const a = h.analytics, now = h.sim.timeMs;
|
|
30
|
+
// Retain at most one short reconnect window per departed account.
|
|
31
|
+
for (const [key, at] of a.departed) {if (now - at > 600000) {a.departed.delete(key);}}
|
|
32
|
+
for (const p of group) {
|
|
33
|
+
const key = p.userId;
|
|
34
|
+
const back = !p.from && key && a.departed.has(key);
|
|
35
|
+
if (key) {a.departed.delete(key);}
|
|
36
|
+
a.visits.set(p.playerId, { at: now, userId: key });
|
|
37
|
+
if (back) {track(h, p.playerId, 'reconnect', { subject: h.manifest.house ? SUBJECTS.house : SUBJECTS.town });}
|
|
38
|
+
else if (h.firstVisit && !h.manifest.house) {a.visits.get(p.playerId).arrival = { subject: SUBJECTS.town, result: p.from ? 2 : 1 };}
|
|
39
|
+
else {track(h, p.playerId, h.manifest.house ? 'house_visit' : 'arrive', { subject: h.manifest.house ? SUBJECTS.house : SUBJECTS.town, result: p.from ? 2 : 1 });}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Resolve the existing arrival once storage has answered, without duplicating it.
|
|
43
|
+
export function firstVisitArrived(h, playerId, flags) {
|
|
44
|
+
if (!Number.isInteger(flags) || flags < 0 || flags > 3) {return false;}
|
|
45
|
+
const visit = h.analytics?.visits.get(playerId);
|
|
46
|
+
if (!visit?.arrival) {return false;}
|
|
47
|
+
const accepted = track(h, playerId, 'arrive', { ...visit.arrival, flags });
|
|
48
|
+
if (accepted) {delete visit.arrival;}
|
|
49
|
+
return accepted;
|
|
50
|
+
}
|
|
51
|
+
export function leave(h, playerId) {
|
|
52
|
+
const a = h.analytics, visit = a.visits.get(playerId);
|
|
53
|
+
if (!visit) {return;}
|
|
54
|
+
if (visit.arrival) {firstVisitArrived(h, playerId, 0);}
|
|
55
|
+
const value = Math.max(0, Math.min(2147483647, Math.round(h.sim.timeMs - visit.at)));
|
|
56
|
+
track(h, playerId, 'session_end', { value, result: 0 });
|
|
57
|
+
if (h.manifest.house) {track(h, playerId, 'house_time', { subject: SUBJECTS.house, value });}
|
|
58
|
+
a.visits.delete(playerId);
|
|
59
|
+
if (visit.userId) {a.departed.set(visit.userId, h.sim.timeMs);}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Browser measurements are untrusted numbers, never identities or event names.
|
|
63
|
+
export function fps(h, session, player, data) {
|
|
64
|
+
const entry = h.players.get(player?.playerId);
|
|
65
|
+
if (h.place?.analytics !== true || !h.place.fpsTelemetry || !entry?.arrived || !session.players.some((p) => p.playerId === player.playerId) ||
|
|
66
|
+
data.scene !== h.place.fpsTelemetry.scene || typeof data.final !== 'boolean' ||
|
|
67
|
+
Object.keys(data).some((key) => !['k', 'scene', 'median', 'p10', 'tier', 'avatars', 'final'].includes(key))) {return false;}
|
|
68
|
+
for (const [key, max] of [['median', 4095], ['p10', 4095], ['tier', 3], ['avatars', 255]]) {
|
|
69
|
+
if (!Number.isInteger(data[key]) || data[key] < 0 || data[key] > max) {return false;}
|
|
70
|
+
}
|
|
71
|
+
if (data.p10 > data.median) {return false;}
|
|
72
|
+
const now = h.sim.timeMs;
|
|
73
|
+
const field = data.final ? 'fpsFinalAt' : 'fpsAt';
|
|
74
|
+
if (entry[field] !== undefined && now - entry[field] < 60000) {return false;}
|
|
75
|
+
entry[field] = now;
|
|
76
|
+
try {
|
|
77
|
+
const pending = h.session?.hub?.track?.(player.playerId, {
|
|
78
|
+
kind: 26, subject: data.tier, value: data.median * 4096 + data.p10, result: data.avatars, flags: 0,
|
|
79
|
+
});
|
|
80
|
+
pending?.catch?.(() => {});
|
|
81
|
+
return pending !== undefined && pending !== false;
|
|
82
|
+
} catch { return false; }
|
|
83
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Layer-local sign-up continuity. Only the trusted roster can join a guest
|
|
2
|
+
// identity to an account. A different account never receives practice state.
|
|
3
|
+
export function makeAnonymousEntry({ ttlMs = 10 * 60_000, max = 500 } = {}) {
|
|
4
|
+
const states = new Map();
|
|
5
|
+
const guests = new Map();
|
|
6
|
+
function trim(now) {
|
|
7
|
+
for (const [key, state] of states) {
|
|
8
|
+
if (now > state.until) {
|
|
9
|
+
states.delete(key);
|
|
10
|
+
if (guests.get(state.userId) === key) {guests.delete(state.userId);}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
while (states.size > max) {
|
|
14
|
+
const key = states.keys().next().value;
|
|
15
|
+
const state = states.get(key);
|
|
16
|
+
states.delete(key);
|
|
17
|
+
if (guests.get(state.userId) === key) {guests.delete(state.userId);}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
remember(player, pose, avatar, color, now) {
|
|
22
|
+
trim(now);
|
|
23
|
+
if (!player?.isAnonymous || !/^\d{1,20}$/.test(String(player.userId ?? '')) || !pose) {return;}
|
|
24
|
+
const key = `g:${player.playerId}`;
|
|
25
|
+
const previous = guests.get(String(player.userId));
|
|
26
|
+
if (previous && previous !== key) {states.delete(previous);}
|
|
27
|
+
states.delete(key);
|
|
28
|
+
states.set(key, { userId: String(player.userId), playerId: player.playerId, pose: { ...pose }, avatar, color, until: now + ttlMs });
|
|
29
|
+
guests.set(String(player.userId), key);
|
|
30
|
+
trim(now);
|
|
31
|
+
},
|
|
32
|
+
take(player, now) {
|
|
33
|
+
trim(now);
|
|
34
|
+
if (!player || player.isAnonymous || !/^\d{1,20}$/.test(String(player.userId ?? ''))) {return null;}
|
|
35
|
+
const userId = String(player.userId);
|
|
36
|
+
const guestKey = guests.get(userId);
|
|
37
|
+
const guest = states.get(guestKey);
|
|
38
|
+
if (!guest) {return null;}
|
|
39
|
+
states.delete(guestKey);
|
|
40
|
+
guests.delete(userId);
|
|
41
|
+
// Copy only the allowed visit state, never wallets, jobs, fish or plots.
|
|
42
|
+
const userKey = `u:${userId}`;
|
|
43
|
+
states.set(userKey, { ...guest, pose: { ...guest.pose } });
|
|
44
|
+
const copy = states.get(userKey);
|
|
45
|
+
states.delete(userKey);
|
|
46
|
+
return { ...copy, guestKey, userKey };
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Session-local pose copies only. Authored visits always leave and arrive.
|
|
2
|
+
export const TTL_MS = 60000;
|
|
3
|
+
const MAX_POSES = 128;
|
|
4
|
+
const valid = pose => pose?.at && [pose.at.x, pose.at.y, pose.at.z, pose.facing].every(Number.isFinite);
|
|
5
|
+
export function create() {
|
|
6
|
+
const poses = new Map();
|
|
7
|
+
const prune = now => {
|
|
8
|
+
for (const [id, pose] of poses) {
|
|
9
|
+
if (now < pose.seenAt || now - (pose.awayAt ?? pose.seenAt) >= TTL_MS) {poses.delete(id);}
|
|
10
|
+
}
|
|
11
|
+
while (poses.size > MAX_POSES) {poses.delete(poses.keys().next().value);}
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
remember(id, userId, body, now = Date.now()) {
|
|
15
|
+
prune(now);
|
|
16
|
+
if (!userId || !valid(body)) {poses.delete(id); return;}
|
|
17
|
+
poses.set(id, { userId, at: { ...body.at }, facing: body.facing, seenAt: now });
|
|
18
|
+
prune(now);
|
|
19
|
+
},
|
|
20
|
+
leave(id, userId, eligible, now = Date.now()) {
|
|
21
|
+
prune(now);
|
|
22
|
+
const pose = poses.get(id);
|
|
23
|
+
if (!eligible || !userId || pose?.userId !== userId) {poses.delete(id); return;}
|
|
24
|
+
pose.awayAt ??= now;
|
|
25
|
+
},
|
|
26
|
+
take(id, userId, now = Date.now()) {
|
|
27
|
+
prune(now);
|
|
28
|
+
const pose = poses.get(id);
|
|
29
|
+
poses.delete(id);
|
|
30
|
+
return userId && pose?.userId === userId && pose.awayAt !== undefined
|
|
31
|
+
? { at: { ...pose.at }, facing: pose.facing } : null;
|
|
32
|
+
},
|
|
33
|
+
clear(id) {poses.delete(id);},
|
|
34
|
+
shutdown() {poses.clear();},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The companion (v1.71): one private follower per arrived player.
|
|
2
2
|
import { check } from '../companionSpec.js';
|
|
3
|
+
import { heldAway } from './vis.js';
|
|
3
4
|
const SEND_EVERY_MS = 250;
|
|
4
5
|
function need(condition, message) {
|
|
5
6
|
if (!condition) {
|
|
@@ -13,6 +14,12 @@ function arrived(h, playerId) {
|
|
|
13
14
|
const entry = h.players.get(playerId);
|
|
14
15
|
return present(h, playerId) && entry?.arrived && !entry.ended;
|
|
15
16
|
}
|
|
17
|
+
// v1.145: a resumePose place keeps an authenticated player's follower while
|
|
18
|
+
// their visit is retained, as it keeps their HUD; nothing is sent until they
|
|
19
|
+
// are back.
|
|
20
|
+
function held(h, playerId) {
|
|
21
|
+
return heldAway(h, playerId) && !h.players.get(playerId)?.ended;
|
|
22
|
+
}
|
|
16
23
|
function current(h, playerId) {
|
|
17
24
|
return h.companionMe?.get(playerId) ?? { c: null, n: 0, json: 'null', sentJson: 'null', sentN: 0, sentAt: -Infinity };
|
|
18
25
|
}
|
|
@@ -33,7 +40,7 @@ export function set(h, playerId, c) {
|
|
|
33
40
|
need(h.place.companion === true, 'this place does not declare companion');
|
|
34
41
|
need(typeof playerId === 'string', 'playerId must be a string');
|
|
35
42
|
const checked = check(c);
|
|
36
|
-
if (!arrived(h, playerId)) {
|
|
43
|
+
if (!arrived(h, playerId) && !held(h, playerId)) {
|
|
37
44
|
return false;
|
|
38
45
|
}
|
|
39
46
|
const state = current(h, playerId), json = JSON.stringify(checked);
|
|
@@ -52,12 +59,28 @@ export function set(h, playerId, c) {
|
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
// Nothing is sent, or kept, for a player the place never gave a companion.
|
|
55
|
-
export function joinedAfresh(h, playerId) {
|
|
62
|
+
export function joinedAfresh(h, playerId, identityUserId = null) {
|
|
56
63
|
const state = h.companionMe?.get(playerId);
|
|
64
|
+
const kept = h.resumeKept?.get(playerId);
|
|
65
|
+
// v1.145: a retained follower goes back only to the account it was for; the
|
|
66
|
+
// client keeps its follower across a same-id reconnect, so clear it.
|
|
67
|
+
if (state && h.place.resumePose === true && typeof kept?.identityUserId === 'string' &&
|
|
68
|
+
kept.identityUserId !== identityUserId) {
|
|
69
|
+
clearRetained(h, playerId);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
57
72
|
if (state) {
|
|
58
73
|
send(h, playerId, state);
|
|
59
74
|
}
|
|
60
75
|
}
|
|
76
|
+
// Drop a held follower; a client that was ever sent one is told to drop it.
|
|
77
|
+
export function clearRetained(h, playerId) {
|
|
78
|
+
const state = h.companionMe?.get(playerId);
|
|
79
|
+
forget(h, playerId);
|
|
80
|
+
if (state && state.sentJson !== 'null') {
|
|
81
|
+
h.session?.send(playerId, { k: 'hub-companion', c: null, n: version(h) });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
61
84
|
export function forget(h, playerId) {
|
|
62
85
|
h.companionMe?.delete(playerId);
|
|
63
86
|
}
|
|
@@ -65,7 +88,9 @@ export function prune(h) {
|
|
|
65
88
|
for (const playerId of h.companionMe?.keys() ?? []) {
|
|
66
89
|
// An ended visit is over for the follower too: nothing of it is replayed.
|
|
67
90
|
if (!present(h, playerId) || h.players.get(playerId)?.ended) {
|
|
68
|
-
|
|
91
|
+
if (!held(h, playerId)) {
|
|
92
|
+
forget(h, playerId);
|
|
93
|
+
}
|
|
69
94
|
continue;
|
|
70
95
|
}
|
|
71
96
|
const state = h.companionMe?.get(playerId);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Numeric door telemetry. Ghost stamps the subject from the committed trip;
|
|
2
|
+
// the client's door id and the authored server's subject are never trusted.
|
|
3
|
+
export const EVENTS = Object.freeze({ round_start: 28, round_end: 29, door_progress: 30, door_error: 31 });
|
|
4
|
+
export const ERROR_INTERVAL_MS = 10000;
|
|
5
|
+
function emit(h, playerId, name, value, result) {
|
|
6
|
+
if (!h.players.get(playerId)?.arrived) {return false;}
|
|
7
|
+
try {
|
|
8
|
+
const pending = h.session?.hub?.track?.(playerId, { kind: EVENTS[name], value, result });
|
|
9
|
+
pending?.catch?.(() => {});
|
|
10
|
+
return pending !== undefined && pending !== false;
|
|
11
|
+
} catch {return false;}
|
|
12
|
+
}
|
|
13
|
+
export function track(h, playerId, name, props = {}) {
|
|
14
|
+
const entry = h.players.get(playerId);
|
|
15
|
+
if (!entry?.arrived || !EVENTS[name] || !props || typeof props !== 'object' || Array.isArray(props) ||
|
|
16
|
+
Object.keys(props).some(k => !['value', 'result'].includes(k))) {return false;}
|
|
17
|
+
const value = props.value ?? 0, result = props.result ?? 0;
|
|
18
|
+
if (!Number.isSafeInteger(value) || value < 0 || value > 2147483647 || !Number.isSafeInteger(result)) {return false;}
|
|
19
|
+
if (name === 'round_start') {
|
|
20
|
+
if (entry.doorRoundAt !== undefined || value < 1 || value > 256 || result !== 0) {return false;}
|
|
21
|
+
entry.doorRoundAt = h.sim.timeMs;
|
|
22
|
+
} else if (name === 'round_end') {
|
|
23
|
+
if (entry.doorRoundAt === undefined || ![1, 2, 3].includes(result)) {return false;}
|
|
24
|
+
const seconds = Math.min(2147483647, Math.max(0, Math.round((h.sim.timeMs - entry.doorRoundAt) / 1000)));
|
|
25
|
+
delete entry.doorRoundAt;
|
|
26
|
+
return emit(h, playerId, name, seconds, result);
|
|
27
|
+
} else if (name === 'door_progress') {
|
|
28
|
+
if (value < 1 || ![1, 2].includes(result)) {return false;}
|
|
29
|
+
} else {
|
|
30
|
+
if (value < 1 || value > 60 || ![1, 2].includes(result)) {return false;}
|
|
31
|
+
const now = Date.now();
|
|
32
|
+
if (now < (entry.doorErrorAfter ?? 0)) {return false;}
|
|
33
|
+
entry.doorErrorAfter = now + ERROR_INTERVAL_MS;
|
|
34
|
+
}
|
|
35
|
+
return emit(h, playerId, name, value, result);
|
|
36
|
+
}
|
|
37
|
+
export function arrive(h, group) {
|
|
38
|
+
if (!h.place.result || h.place.analyticsRounds === 'authored') {return;}
|
|
39
|
+
// Count actually admitted group members rather than the client's claimed party.
|
|
40
|
+
for (const { playerId } of group) {track(h, playerId, 'round_start', { value: group.length });}
|
|
41
|
+
}
|
|
42
|
+
export function finish(h, playerId, result = 1) {
|
|
43
|
+
return track(h, playerId, 'round_end', { result });
|
|
44
|
+
}
|
|
45
|
+
export function message(h, playerId, data) {
|
|
46
|
+
if (!data || Object.keys(data).some(k => !['k', 'result'].includes(k))) {return false;}
|
|
47
|
+
if (data.k === 'hub-door-quit') {return finish(h, playerId, 2);}
|
|
48
|
+
if (data.k === 'hub-door-error') {
|
|
49
|
+
return track(h, playerId, 'door_error', { value: 1, result: data.result });
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
@@ -158,6 +158,18 @@ function here(h, playerId) {
|
|
|
158
158
|
return typeof playerId === 'string' && (h.players.has(playerId) || h.sim?.players.has(playerId));
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
// A host receipt belongs to the session and signed-in account that started
|
|
162
|
+
// the request. Ghost may persist an old account's operation after that socket
|
|
163
|
+
// is replaced; its shown item and notices must never be applied to the new
|
|
164
|
+
// account reusing the player id.
|
|
165
|
+
function sameAccount(h, playerId, userId, session) {
|
|
166
|
+
if (h.session !== session || !here(h, playerId)) { return false; }
|
|
167
|
+
const roster = session?.players?.find((player) => player.playerId === playerId);
|
|
168
|
+
if (!roster || roster.isAnonymous === true || String(roster.userId) !== String(userId)) { return false; }
|
|
169
|
+
const known = h.players.get(playerId);
|
|
170
|
+
return !known || String(known.userId) === String(userId);
|
|
171
|
+
}
|
|
172
|
+
|
|
161
173
|
function show(h, playerId, item) {
|
|
162
174
|
if (isHome(item)) {
|
|
163
175
|
return;
|
|
@@ -190,17 +202,19 @@ export function unlock(h, playerId, itemId, { platform, userId, declared, deckId
|
|
|
190
202
|
return Promise.resolve(null);
|
|
191
203
|
}
|
|
192
204
|
if (platform && userId && typeof platform.unlock === 'function') {
|
|
205
|
+
const session = h.session;
|
|
193
206
|
const earnedRev = h.earnedRev.get(playerId) ?? 0;
|
|
194
207
|
return platform.unlock(playerId, itemId).then(
|
|
195
208
|
(answer) => {
|
|
209
|
+
const current = sameAccount(h, playerId, userId, session);
|
|
196
210
|
// Ghost answers with what the player shows, never the home item given.
|
|
197
211
|
const given = (declared ?? []).find((d) => d.id === itemId);
|
|
198
|
-
if (isHome(given) &&
|
|
212
|
+
if (isHome(given) && current) {
|
|
199
213
|
homeUnlock(h, playerId, { deckId, ...given }, answer?.isNew === true);
|
|
200
214
|
}
|
|
201
215
|
const earned = cleanEarned(answer?.earned);
|
|
202
216
|
// A later applied choice wins over this receipt's older shown item.
|
|
203
|
-
if (earned && !isHome(earned) &&
|
|
217
|
+
if (earned && !isHome(earned) && current && (h.earnedRev.get(playerId) ?? 0) === earnedRev) {
|
|
204
218
|
show(h, playerId, earned);
|
|
205
219
|
applied(h, playerId);
|
|
206
220
|
}
|
|
@@ -210,7 +224,8 @@ export function unlock(h, playerId, itemId, { platform, userId, declared, deckId
|
|
|
210
224
|
refused(err);
|
|
211
225
|
// A host whose runtime cannot keep unlocks: this session's, as on the
|
|
212
226
|
// dev serve.
|
|
213
|
-
return err?.code === UNAVAILABLE &&
|
|
227
|
+
return err?.code === UNAVAILABLE && sameAccount(h, playerId, userId, session)
|
|
228
|
+
? sessionUnlock(h, playerId, itemId, declared, deckId) : null;
|
|
214
229
|
},
|
|
215
230
|
);
|
|
216
231
|
}
|
|
@@ -288,6 +303,7 @@ export function wearEarned(h, playerId, choice, { platform, userId, deckId, decl
|
|
|
288
303
|
return Promise.resolve(null);
|
|
289
304
|
}
|
|
290
305
|
if (platform && userId && typeof platform.wearEarned === 'function') {
|
|
306
|
+
const session = h.session;
|
|
291
307
|
return platform.wearEarned(playerId, pick && { deckId: pick.deckId, id: pick.id }).then(
|
|
292
308
|
(answer) => {
|
|
293
309
|
const earned = cleanEarned(answer?.earned);
|
|
@@ -295,7 +311,7 @@ export function wearEarned(h, playerId, choice, { platform, userId, deckId, decl
|
|
|
295
311
|
refused({ code: 'CAULDRON_HUB_EARNED_NOT_WEARABLE', message: 'home items are never worn' });
|
|
296
312
|
return null;
|
|
297
313
|
}
|
|
298
|
-
if (
|
|
314
|
+
if (sameAccount(h, playerId, userId, session)) {
|
|
299
315
|
show(h, playerId, earned);
|
|
300
316
|
applied(h, playerId);
|
|
301
317
|
}
|
|
@@ -303,7 +319,8 @@ export function wearEarned(h, playerId, choice, { platform, userId, deckId, decl
|
|
|
303
319
|
},
|
|
304
320
|
(err) => {
|
|
305
321
|
refused(err);
|
|
306
|
-
return err?.code === UNAVAILABLE &&
|
|
322
|
+
return err?.code === UNAVAILABLE && sameAccount(h, playerId, userId, session)
|
|
323
|
+
? sessionChoice(h, playerId, pick, declared, deckId) : null;
|
|
307
324
|
},
|
|
308
325
|
);
|
|
309
326
|
}
|