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
package/dist/castle-host/host.js
CHANGED
|
@@ -41,12 +41,27 @@ const COMMAND_NAMES = [
|
|
|
41
41
|
"portal.open",
|
|
42
42
|
"portal.prefetch",
|
|
43
43
|
"portal.info",
|
|
44
|
+
"social.friends",
|
|
45
|
+
"social.presence",
|
|
46
|
+
"party.current",
|
|
47
|
+
"party.create",
|
|
48
|
+
"party.invite",
|
|
49
|
+
"party.respond",
|
|
50
|
+
"party.members",
|
|
51
|
+
"party.leave",
|
|
52
|
+
"party.messages",
|
|
53
|
+
"party.say",
|
|
44
54
|
"hub.go",
|
|
45
55
|
"hub.back",
|
|
46
56
|
"hub.doors",
|
|
47
57
|
"hub.friends",
|
|
58
|
+
"hub.invite",
|
|
59
|
+
"hub.canInvite",
|
|
60
|
+
"hub.inviteArrival",
|
|
61
|
+
"hub.undoInvite",
|
|
48
62
|
"hub.hearts",
|
|
49
63
|
"hub.setHearts",
|
|
64
|
+
"hub.signIn",
|
|
50
65
|
"hub.jump",
|
|
51
66
|
"hub.report",
|
|
52
67
|
"hub.chat",
|
|
@@ -73,6 +88,8 @@ const COMMAND_NAMES = [
|
|
|
73
88
|
"cauldronStorage.transaction",
|
|
74
89
|
"cauldronStorage.claim",
|
|
75
90
|
"cauldronStorage.initialize",
|
|
91
|
+
"cauldronStorage.conditionalWrite",
|
|
92
|
+
"cauldronStorage.recentOperations",
|
|
76
93
|
"cauldronStorage.get",
|
|
77
94
|
"cauldronStorage.set",
|
|
78
95
|
"cauldronStorage.delete",
|
|
@@ -155,7 +172,8 @@ export async function executeCommand(ctx, command, params, capabilities, options
|
|
|
155
172
|
};
|
|
156
173
|
}
|
|
157
174
|
try {
|
|
158
|
-
const data = await
|
|
175
|
+
const data = await dispatchCommand(ctx, command, (params ?? {}), capabilities, options);
|
|
176
|
+
capabilities.hub?.assertActive?.();
|
|
159
177
|
noteAcquiredSession(ctx, command, data, capabilities);
|
|
160
178
|
return { ok: true, data };
|
|
161
179
|
}
|
|
@@ -163,6 +181,12 @@ export async function executeCommand(ctx, command, params, capabilities, options
|
|
|
163
181
|
return { ok: false, error: toSerializedError(error, command) };
|
|
164
182
|
}
|
|
165
183
|
}
|
|
184
|
+
function dispatchCommand(ctx, command, params, caps, options) {
|
|
185
|
+
if (isTrustedDataCommand(command)) {
|
|
186
|
+
return runTrustedDataCommand(ctx, command, params, caps.graphqlFetch);
|
|
187
|
+
}
|
|
188
|
+
return runCommand(ctx, command, params, caps, options);
|
|
189
|
+
}
|
|
166
190
|
// A door's source is the session the deck last acquired in its place.
|
|
167
191
|
function noteAcquiredSession(ctx, command, data, caps) {
|
|
168
192
|
if (!caps.hub?.sessionAcquired ||
|
|
@@ -174,6 +198,26 @@ function noteAcquiredSession(ctx, command, data, caps) {
|
|
|
174
198
|
caps.hub.sessionAcquired(result.sessionId, ctx);
|
|
175
199
|
}
|
|
176
200
|
}
|
|
201
|
+
const HUB_VISIT_COMMANDS = new Set([
|
|
202
|
+
"hub.go",
|
|
203
|
+
"hub.back",
|
|
204
|
+
"hub.doors",
|
|
205
|
+
"hub.friends",
|
|
206
|
+
"hub.invite",
|
|
207
|
+
"hub.canInvite",
|
|
208
|
+
"hub.inviteArrival",
|
|
209
|
+
"hub.undoInvite",
|
|
210
|
+
"hub.jump",
|
|
211
|
+
"hub.report",
|
|
212
|
+
"hub.chat",
|
|
213
|
+
"hub.say",
|
|
214
|
+
"hub.reportChat",
|
|
215
|
+
"hub.commit",
|
|
216
|
+
"hub.cancel",
|
|
217
|
+
]);
|
|
218
|
+
function isHubVisitCommand(command) {
|
|
219
|
+
return HUB_VISIT_COMMANDS.has(command);
|
|
220
|
+
}
|
|
177
221
|
function runCommand(ctx, command, params, caps, options) {
|
|
178
222
|
if (command === "multiplayer.getSession" && caps.getMultiplayerSession) {
|
|
179
223
|
return caps.getMultiplayerSession(multiplayerSessionRequest(params), ctx);
|
|
@@ -185,9 +229,17 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
185
229
|
}
|
|
186
230
|
return caps.joinMultiplayerDestination(request, ctx, options.signal);
|
|
187
231
|
}
|
|
232
|
+
if (command === "hub.signIn") {
|
|
233
|
+
const reason = asBoundedText(params.reason, "reason", command, 200, 512);
|
|
234
|
+
return caps.hubSignIn
|
|
235
|
+
? caps.hubSignIn(reason, ctx, options.signal)
|
|
236
|
+
: Promise.resolve({ status: "unavailable" });
|
|
237
|
+
}
|
|
188
238
|
if (isPlatformCommand(command)) {
|
|
189
239
|
return runPlatformCommand(ctx, command, params, caps);
|
|
190
240
|
}
|
|
241
|
+
if (isHubVisitCommand(command))
|
|
242
|
+
return runHubCommand(ctx, command, params, caps, options.signal);
|
|
191
243
|
const gql = caps.graphqlFetch;
|
|
192
244
|
switch (command) {
|
|
193
245
|
case "agent.chat":
|
|
@@ -216,21 +268,6 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
216
268
|
return userGet(params, gql);
|
|
217
269
|
case "experiments.get":
|
|
218
270
|
return Promise.resolve(experimentsGet(ctx));
|
|
219
|
-
case "portal.info":
|
|
220
|
-
return portalInfo(params, gql);
|
|
221
|
-
// Dormant `unavailable` on a host without `caps.hub`.
|
|
222
|
-
case "hub.go":
|
|
223
|
-
case "hub.back":
|
|
224
|
-
case "hub.doors":
|
|
225
|
-
case "hub.friends":
|
|
226
|
-
case "hub.jump":
|
|
227
|
-
case "hub.report":
|
|
228
|
-
case "hub.chat":
|
|
229
|
-
case "hub.say":
|
|
230
|
-
case "hub.reportChat":
|
|
231
|
-
case "hub.commit":
|
|
232
|
-
case "hub.cancel":
|
|
233
|
-
return runHubCommand(ctx, command, params, caps, options.signal);
|
|
234
271
|
case "time.getServerTime":
|
|
235
272
|
return timeGetServerTime(gql);
|
|
236
273
|
case "pass.has":
|
|
@@ -271,6 +308,8 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
271
308
|
case "cauldronStorage.transaction":
|
|
272
309
|
case "cauldronStorage.claim":
|
|
273
310
|
case "cauldronStorage.initialize":
|
|
311
|
+
case "cauldronStorage.conditionalWrite":
|
|
312
|
+
case "cauldronStorage.recentOperations":
|
|
274
313
|
return cauldronSave(ctx, command, params, gql);
|
|
275
314
|
case "cauldronStorage.get":
|
|
276
315
|
return cauldronStorageGet(ctx, params, gql);
|
|
@@ -301,23 +340,56 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
301
340
|
return runPlatformCommand(ctx, command, params, caps);
|
|
302
341
|
}
|
|
303
342
|
}
|
|
343
|
+
function isTrustedDataCommand(command) {
|
|
344
|
+
return (command === "portal.info" || command.startsWith("social.") || command.startsWith("party."));
|
|
345
|
+
}
|
|
346
|
+
function runTrustedDataCommand(ctx, command, params, gql) {
|
|
347
|
+
switch (command) {
|
|
348
|
+
case "portal.info":
|
|
349
|
+
return portalInfo(params, gql);
|
|
350
|
+
case "social.friends":
|
|
351
|
+
return socialFriends(gql);
|
|
352
|
+
case "social.presence":
|
|
353
|
+
return socialPresence(ctx, gql);
|
|
354
|
+
case "party.current":
|
|
355
|
+
return partyCurrent(ctx, gql);
|
|
356
|
+
case "party.create":
|
|
357
|
+
return partyCreate(ctx, params, gql);
|
|
358
|
+
case "party.invite":
|
|
359
|
+
return partyInvite(params, gql);
|
|
360
|
+
case "party.respond":
|
|
361
|
+
return partyRespond(params, gql);
|
|
362
|
+
case "party.members":
|
|
363
|
+
return partyMembers(params, gql);
|
|
364
|
+
case "party.leave":
|
|
365
|
+
return partyLeave(params, gql);
|
|
366
|
+
case "party.messages":
|
|
367
|
+
return partyMessages(params, gql);
|
|
368
|
+
case "party.say":
|
|
369
|
+
return partySay(params, gql);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
304
372
|
async function multiplayerGetSession(ctx, params, caps) {
|
|
305
373
|
const request = multiplayerSessionRequest(params);
|
|
306
374
|
const deckId = requireDeckId(ctx, "multiplayer.getSession");
|
|
307
375
|
const hintedSessionId = multiplayerHintedSessionId(ctx, deckId);
|
|
376
|
+
if (request.mode === "public")
|
|
377
|
+
await caps.hub?.prepareInvite?.(ctx);
|
|
378
|
+
const inviteHint = request.mode === "public" ? caps.hub?.inviteJoinHint?.(ctx) : null;
|
|
308
379
|
// Which shared session a play belongs to is the host's call, not the deck's,
|
|
309
380
|
// the way `shared.cpp` reads the party off the engine rather than the scene.
|
|
310
381
|
// A play that arrived through a party stays inside it unless trusted host
|
|
311
382
|
// chrome is sending this public join to the room where a friend is playing.
|
|
312
|
-
const mode = request.mode === "public" && ctx.partyId && !hintedSessionId
|
|
383
|
+
const mode = request.mode === "public" && ctx.partyId && !hintedSessionId && !inviteHint
|
|
313
384
|
? "party"
|
|
314
385
|
: request.mode;
|
|
315
|
-
const data = await graphql(caps.graphqlFetch, CAULDRON_MULTIPLAYER_SESSION_QUERY, {
|
|
386
|
+
const data = await graphql(caps.graphqlFetch, inviteHint ? CAULDRON_INVITE_SESSION_QUERY : CAULDRON_MULTIPLAYER_SESSION_QUERY, {
|
|
316
387
|
deckId,
|
|
317
388
|
mode,
|
|
318
389
|
key: request.key ?? null,
|
|
319
390
|
sessionId: request.mode === "public" ? hintedSessionId : null,
|
|
320
|
-
partyId: ctx.partyId ?? null,
|
|
391
|
+
partyId: inviteHint ? null : ctx.partyId ?? null,
|
|
392
|
+
...(inviteHint ? { hubInviteToken: inviteHint.token, env: inviteHint.env } : {}),
|
|
321
393
|
}, "multiplayer.getSession");
|
|
322
394
|
return multiplayerSessionResult(data.getCauldronMultiplayerSession);
|
|
323
395
|
}
|
|
@@ -2673,6 +2745,10 @@ const CAULDRON_MULTIPLAYER_SESSION_QUERY = `
|
|
|
2673
2745
|
}
|
|
2674
2746
|
}
|
|
2675
2747
|
`;
|
|
2748
|
+
// Keep the default query byte-for-byte unchanged for hosts without invite opt-in.
|
|
2749
|
+
const CAULDRON_INVITE_SESSION_QUERY = CAULDRON_MULTIPLAYER_SESSION_QUERY
|
|
2750
|
+
.replace("$partyId: ID", "$partyId: ID\n $hubInviteToken: String\n $env: String")
|
|
2751
|
+
.replace("partyId: $partyId", "partyId: $partyId\n hubInviteToken: $hubInviteToken\n env: $env");
|
|
2676
2752
|
const CAULDRON_MULTIPLAYER_DESTINATION_DESCRIPTION_QUERY = `
|
|
2677
2753
|
query CastleCauldronMultiplayerDestinationDescription($deckId: ID!, $routeId: String!) {
|
|
2678
2754
|
describeCauldronMultiplayerDestination(deckId: $deckId, routeId: $routeId) {
|
|
@@ -2705,6 +2781,18 @@ const CAULDRON_MULTIPLAYER_DESTINATION_SESSION_QUERY = `
|
|
|
2705
2781
|
`;
|
|
2706
2782
|
const CLIENT_SAVE_REQUEST_MAX_BYTES = 512 * 1024;
|
|
2707
2783
|
const CAULDRON_SAVE_DOCUMENTS = {
|
|
2784
|
+
"cauldronStorage.conditionalWrite": {
|
|
2785
|
+
field: "cauldronStorageConditionalWrite",
|
|
2786
|
+
query: `mutation CastleCauldronStorageConditionalWrite($deckId: ID!, $input: Json!) {
|
|
2787
|
+
cauldronStorageConditionalWrite(deckId: $deckId, input: $input)
|
|
2788
|
+
}`,
|
|
2789
|
+
},
|
|
2790
|
+
"cauldronStorage.recentOperations": {
|
|
2791
|
+
field: "cauldronStorageRecentOperations",
|
|
2792
|
+
query: `query CastleCauldronStorageRecentOperations($deckId: ID!, $input: Json!) {
|
|
2793
|
+
cauldronStorageRecentOperations(deckId: $deckId, input: $input)
|
|
2794
|
+
}`,
|
|
2795
|
+
},
|
|
2708
2796
|
"cauldronStorage.snapshot": {
|
|
2709
2797
|
field: "cauldronStorageSnapshot",
|
|
2710
2798
|
query: `
|
|
@@ -2890,6 +2978,342 @@ const CAULDRON_STORAGE_BOARD_GET_QUERY = `
|
|
|
2890
2978
|
}
|
|
2891
2979
|
}
|
|
2892
2980
|
`;
|
|
2981
|
+
// ---------------------------------------------------------------------------
|
|
2982
|
+
// Social friends, same-deck presence, and Castle parties. These are ordinary
|
|
2983
|
+
// host data commands: the host's GraphQL transport supplies the signed-in
|
|
2984
|
+
// player, while trusted HostContext supplies the current deck and launch party.
|
|
2985
|
+
const SOCIAL_FRIENDS_QUERY = `query CastleSocialFriends {
|
|
2986
|
+
cauldronMutualFriends(limit: 20) {
|
|
2987
|
+
userId
|
|
2988
|
+
username
|
|
2989
|
+
photo { smallAvatarUrl }
|
|
2990
|
+
}
|
|
2991
|
+
}`;
|
|
2992
|
+
const SOCIAL_PRESENCE_QUERY = `query CastleSocialPresence($deckId: ID!) {
|
|
2993
|
+
deck(deckId: $deckId) {
|
|
2994
|
+
friendsPlaying {
|
|
2995
|
+
userId
|
|
2996
|
+
username
|
|
2997
|
+
photo { smallAvatarUrl }
|
|
2998
|
+
nowPlaying { deckId sessionId routeId slot updatedAt }
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
}`;
|
|
3002
|
+
const PARTY_SUMMARY_FIELDS = `
|
|
3003
|
+
partyId
|
|
3004
|
+
name
|
|
3005
|
+
status
|
|
3006
|
+
chatChannel { hasUnreadMessages }
|
|
3007
|
+
`;
|
|
3008
|
+
const PARTY_CURRENT_QUERY = `query CastlePartyCurrent($partyId: ID!) {
|
|
3009
|
+
party(partyId: $partyId) { ${PARTY_SUMMARY_FIELDS} }
|
|
3010
|
+
}`;
|
|
3011
|
+
const PARTY_CREATE_MUTATION = `mutation CastlePartyCreate($userIds: [ID]!) {
|
|
3012
|
+
createParty(userIds: $userIds) { ${PARTY_SUMMARY_FIELDS} }
|
|
3013
|
+
}`;
|
|
3014
|
+
const PARTY_INVITE_MUTATION = `mutation CastlePartyInvite($partyId: ID!, $userIds: [ID]!) {
|
|
3015
|
+
inviteToParty(partyId: $partyId, userIds: $userIds)
|
|
3016
|
+
}`;
|
|
3017
|
+
const PARTY_ACCEPT_MUTATION = `mutation CastlePartyAccept($partyId: ID!) {
|
|
3018
|
+
acceptPartyInvite(partyId: $partyId)
|
|
3019
|
+
}`;
|
|
3020
|
+
const PARTY_REJECT_MUTATION = `mutation CastlePartyReject($partyId: ID!) {
|
|
3021
|
+
rejectPartyInvite(partyId: $partyId)
|
|
3022
|
+
}`;
|
|
3023
|
+
const PARTY_MEMBERS_QUERY = `query CastlePartyMembers($partyId: ID!) {
|
|
3024
|
+
usersForParty(partyId: $partyId) {
|
|
3025
|
+
user { userId username photo { smallAvatarUrl } }
|
|
3026
|
+
status
|
|
3027
|
+
role
|
|
3028
|
+
}
|
|
3029
|
+
}`;
|
|
3030
|
+
const PARTY_LEAVE_MUTATION = `mutation CastlePartyLeave($partyId: ID!) {
|
|
3031
|
+
leaveParty(partyId: $partyId)
|
|
3032
|
+
}`;
|
|
3033
|
+
const PARTY_MESSAGES_QUERY = `query CastlePartyMessages(
|
|
3034
|
+
$chatChannelId: ID!
|
|
3035
|
+
$paginateToken: String
|
|
3036
|
+
) {
|
|
3037
|
+
chatMessages(chatChannelId: $chatChannelId, limit: 20, paginateToken: $paginateToken) {
|
|
3038
|
+
chatMessages {
|
|
3039
|
+
chatMessageId
|
|
3040
|
+
fromUserId
|
|
3041
|
+
fromUser { username }
|
|
3042
|
+
body
|
|
3043
|
+
createdTime
|
|
3044
|
+
}
|
|
3045
|
+
paginateToken
|
|
3046
|
+
}
|
|
3047
|
+
}`;
|
|
3048
|
+
const PARTY_SAY_MUTATION = `mutation CastlePartySay($chatChannelId: ID!, $message: String!) {
|
|
3049
|
+
sendChatMessage(chatChannelId: $chatChannelId, message: $message) {
|
|
3050
|
+
chatMessageId
|
|
3051
|
+
fromUserId
|
|
3052
|
+
fromUser { username }
|
|
3053
|
+
body
|
|
3054
|
+
createdTime
|
|
3055
|
+
}
|
|
3056
|
+
}`;
|
|
3057
|
+
const SOCIAL_FRIENDS_MAX = 20;
|
|
3058
|
+
const PARTY_USERS_MAX = 32;
|
|
3059
|
+
const PARTY_MESSAGES_MAX = 20;
|
|
3060
|
+
const PARTY_ID_MAX = 128;
|
|
3061
|
+
const PARTY_CURSOR_MAX = 512;
|
|
3062
|
+
const PARTY_TEXT_MAX = 1_000;
|
|
3063
|
+
const PARTY_BODY_MAX_BYTES = 64 * 1024;
|
|
3064
|
+
const PARTY_STATUSES = new Set([
|
|
3065
|
+
"invited",
|
|
3066
|
+
"joined",
|
|
3067
|
+
"rejected",
|
|
3068
|
+
"left",
|
|
3069
|
+
"party_closed",
|
|
3070
|
+
"banned",
|
|
3071
|
+
]);
|
|
3072
|
+
const PARTY_ROLES = new Set(["member", "host", "owner"]);
|
|
3073
|
+
async function socialFriends(gql) {
|
|
3074
|
+
const data = await graphql(gql, SOCIAL_FRIENDS_QUERY, {}, "social.friends");
|
|
3075
|
+
const rows = Array.isArray(data.cauldronMutualFriends) ? data.cauldronMutualFriends : [];
|
|
3076
|
+
return rows.flatMap(publicSocialFriend).slice(0, SOCIAL_FRIENDS_MAX);
|
|
3077
|
+
}
|
|
3078
|
+
async function socialPresence(ctx, gql) {
|
|
3079
|
+
// Unsaved decks and a gated/null field have no observable presence. Older
|
|
3080
|
+
// GraphQL surfaces and transport failures also fail closed, but a coded
|
|
3081
|
+
// Castle refusal (LOGIN_REQUIRED, permission codes, and so on) remains a
|
|
3082
|
+
// CastleError with its server code.
|
|
3083
|
+
if (!ctx.deckId)
|
|
3084
|
+
return [];
|
|
3085
|
+
try {
|
|
3086
|
+
const data = await graphql(gql, SOCIAL_PRESENCE_QUERY, { deckId: ctx.deckId }, "social.presence");
|
|
3087
|
+
const rows = Array.isArray(data.deck?.friendsPlaying) ? data.deck.friendsPlaying : [];
|
|
3088
|
+
return rows
|
|
3089
|
+
.flatMap((row) => publicSocialPresence(row, ctx.deckId))
|
|
3090
|
+
.slice(0, SOCIAL_FRIENDS_MAX);
|
|
3091
|
+
}
|
|
3092
|
+
catch (error) {
|
|
3093
|
+
if (error instanceof HostCommandError &&
|
|
3094
|
+
error.code !== "GRAPHQL_ERROR" &&
|
|
3095
|
+
error.code !== "GRAPHQL_NO_DATA") {
|
|
3096
|
+
throw error;
|
|
3097
|
+
}
|
|
3098
|
+
return [];
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
async function partyCurrent(ctx, gql) {
|
|
3102
|
+
if (!ctx.partyId)
|
|
3103
|
+
return null;
|
|
3104
|
+
const data = await graphql(gql, PARTY_CURRENT_QUERY, { partyId: ctx.partyId }, "party.current");
|
|
3105
|
+
return publicPartySummary(data.party);
|
|
3106
|
+
}
|
|
3107
|
+
async function partyCreate(ctx, params, gql) {
|
|
3108
|
+
const currentUserId = requireUserId(ctx, "party.create");
|
|
3109
|
+
const requested = partyUserIds(params.userIds, "party.create").filter((userId) => userId !== currentUserId);
|
|
3110
|
+
if (requested.length >= PARTY_USERS_MAX) {
|
|
3111
|
+
throw invalidPartyArgument("party.create", `requires room for the signed-in player within ${PARTY_USERS_MAX} user ids.`);
|
|
3112
|
+
}
|
|
3113
|
+
// Deliberately no initialDeckId: creating a party does not retarget the play's
|
|
3114
|
+
// trusted ctx.partyId, which Multiplayer.join({ mode: "party" }) still uses.
|
|
3115
|
+
const userIds = [...requested, currentUserId];
|
|
3116
|
+
const data = await graphql(gql, PARTY_CREATE_MUTATION, { userIds }, "party.create");
|
|
3117
|
+
return requirePartySummary(data.createParty, "party.create");
|
|
3118
|
+
}
|
|
3119
|
+
async function partyInvite(params, gql) {
|
|
3120
|
+
const partyId = partyIdParam(params.partyId, "party.invite");
|
|
3121
|
+
const userIds = partyUserIds(params.userIds, "party.invite");
|
|
3122
|
+
await graphql(gql, PARTY_INVITE_MUTATION, { partyId, userIds }, "party.invite");
|
|
3123
|
+
return { ok: true };
|
|
3124
|
+
}
|
|
3125
|
+
async function partyRespond(params, gql) {
|
|
3126
|
+
const partyId = partyIdParam(params.partyId, "party.respond");
|
|
3127
|
+
if (typeof params.accept !== "boolean") {
|
|
3128
|
+
throw invalidPartyArgument("party.respond", "requires accept to be a boolean.");
|
|
3129
|
+
}
|
|
3130
|
+
await graphql(gql, params.accept ? PARTY_ACCEPT_MUTATION : PARTY_REJECT_MUTATION, { partyId }, "party.respond");
|
|
3131
|
+
return { ok: true };
|
|
3132
|
+
}
|
|
3133
|
+
async function partyMembers(params, gql) {
|
|
3134
|
+
const partyId = partyIdParam(params.partyId, "party.members");
|
|
3135
|
+
const data = await graphql(gql, PARTY_MEMBERS_QUERY, { partyId }, "party.members");
|
|
3136
|
+
const rows = Array.isArray(data.usersForParty) ? data.usersForParty : [];
|
|
3137
|
+
return rows.flatMap(publicPartyMember).slice(0, PARTY_USERS_MAX);
|
|
3138
|
+
}
|
|
3139
|
+
async function partyLeave(params, gql) {
|
|
3140
|
+
const partyId = partyIdParam(params.partyId, "party.leave");
|
|
3141
|
+
await graphql(gql, PARTY_LEAVE_MUTATION, { partyId }, "party.leave");
|
|
3142
|
+
return { ok: true };
|
|
3143
|
+
}
|
|
3144
|
+
async function partyMessages(params, gql) {
|
|
3145
|
+
const partyId = partyIdParam(params.partyId, "party.messages");
|
|
3146
|
+
const paginateToken = optionalBoundedPartyText(params.cursor, "cursor", "party.messages", PARTY_CURSOR_MAX);
|
|
3147
|
+
const data = await graphql(gql, PARTY_MESSAGES_QUERY, { chatChannelId: `party-${partyId}`, paginateToken }, "party.messages");
|
|
3148
|
+
const rows = Array.isArray(data.chatMessages?.chatMessages)
|
|
3149
|
+
? data.chatMessages.chatMessages
|
|
3150
|
+
: [];
|
|
3151
|
+
return {
|
|
3152
|
+
messages: rows.flatMap(publicPartyMessage).slice(0, PARTY_MESSAGES_MAX),
|
|
3153
|
+
cursor: asOptionalString(data.chatMessages?.paginateToken),
|
|
3154
|
+
};
|
|
3155
|
+
}
|
|
3156
|
+
async function partySay(params, gql) {
|
|
3157
|
+
const partyId = partyIdParam(params.partyId, "party.say");
|
|
3158
|
+
const text = asString(params.text, "text", "party.say").trim().slice(0, PARTY_TEXT_MAX);
|
|
3159
|
+
if (!text)
|
|
3160
|
+
throw invalidPartyArgument("party.say", "requires non-empty text.");
|
|
3161
|
+
const data = await graphql(gql, PARTY_SAY_MUTATION, { chatChannelId: `party-${partyId}`, message: text }, "party.say");
|
|
3162
|
+
const message = publicPartyMessage(data.sendChatMessage)[0];
|
|
3163
|
+
if (!message) {
|
|
3164
|
+
throw new HostCommandError("GRAPHQL_INVALID_RESPONSE", "Castle returned an invalid party message.", "party.say");
|
|
3165
|
+
}
|
|
3166
|
+
return message;
|
|
3167
|
+
}
|
|
3168
|
+
function publicSocialFriend(raw) {
|
|
3169
|
+
if (typeof raw !== "object" || raw === null)
|
|
3170
|
+
return [];
|
|
3171
|
+
const record = raw;
|
|
3172
|
+
const userId = asOptionalString(record.userId);
|
|
3173
|
+
const username = asOptionalString(record.username);
|
|
3174
|
+
if (!userId || !username)
|
|
3175
|
+
return [];
|
|
3176
|
+
const photo = record.photo;
|
|
3177
|
+
const photoUrl = asOptionalString(photo?.smallAvatarUrl);
|
|
3178
|
+
return [{ userId, username, ...(photoUrl ? { photoUrl } : {}) }];
|
|
3179
|
+
}
|
|
3180
|
+
function publicSocialPresence(raw, deckId) {
|
|
3181
|
+
const friend = publicSocialFriend(raw)[0];
|
|
3182
|
+
if (!friend || typeof raw !== "object" || raw === null)
|
|
3183
|
+
return [];
|
|
3184
|
+
const nowPlaying = raw.nowPlaying;
|
|
3185
|
+
if (typeof nowPlaying !== "object" || nowPlaying === null)
|
|
3186
|
+
return [];
|
|
3187
|
+
const presence = nowPlaying;
|
|
3188
|
+
const presenceDeckId = asOptionalString(presence.deckId);
|
|
3189
|
+
const sessionId = asOptionalString(presence.sessionId);
|
|
3190
|
+
const updatedAt = asOptionalString(presence.updatedAt);
|
|
3191
|
+
if (presenceDeckId !== deckId || !sessionId || !updatedAt)
|
|
3192
|
+
return [];
|
|
3193
|
+
const routeId = asOptionalString(presence.routeId);
|
|
3194
|
+
const slot = asOptionalString(presence.slot);
|
|
3195
|
+
return [
|
|
3196
|
+
{
|
|
3197
|
+
...friend,
|
|
3198
|
+
sessionId,
|
|
3199
|
+
...(routeId ? { routeId } : {}),
|
|
3200
|
+
...(slot ? { slot } : {}),
|
|
3201
|
+
updatedAt,
|
|
3202
|
+
},
|
|
3203
|
+
];
|
|
3204
|
+
}
|
|
3205
|
+
function publicPartySummary(raw) {
|
|
3206
|
+
if (typeof raw !== "object" || raw === null)
|
|
3207
|
+
return null;
|
|
3208
|
+
const record = raw;
|
|
3209
|
+
const partyId = asOptionalString(record.partyId);
|
|
3210
|
+
const name = asOptionalString(record.name);
|
|
3211
|
+
const status = partyStatus(record.status);
|
|
3212
|
+
if (!partyId || !name || !status)
|
|
3213
|
+
return null;
|
|
3214
|
+
const chatChannel = record.chatChannel;
|
|
3215
|
+
return {
|
|
3216
|
+
partyId,
|
|
3217
|
+
name,
|
|
3218
|
+
status,
|
|
3219
|
+
hasUnreadMessages: chatChannel?.hasUnreadMessages === true,
|
|
3220
|
+
};
|
|
3221
|
+
}
|
|
3222
|
+
function requirePartySummary(raw, command) {
|
|
3223
|
+
const summary = publicPartySummary(raw);
|
|
3224
|
+
if (summary)
|
|
3225
|
+
return summary;
|
|
3226
|
+
throw new HostCommandError("GRAPHQL_INVALID_RESPONSE", "Castle returned an invalid party.", command);
|
|
3227
|
+
}
|
|
3228
|
+
function publicPartyMember(raw) {
|
|
3229
|
+
if (typeof raw !== "object" || raw === null)
|
|
3230
|
+
return [];
|
|
3231
|
+
const record = raw;
|
|
3232
|
+
const friend = publicSocialFriend(record.user)[0];
|
|
3233
|
+
const status = partyStatus(record.status);
|
|
3234
|
+
const role = typeof record.role === "string" && PARTY_ROLES.has(record.role)
|
|
3235
|
+
? record.role
|
|
3236
|
+
: null;
|
|
3237
|
+
return friend && status && role ? [{ ...friend, status, role }] : [];
|
|
3238
|
+
}
|
|
3239
|
+
function publicPartyMessage(raw) {
|
|
3240
|
+
if (typeof raw !== "object" || raw === null)
|
|
3241
|
+
return [];
|
|
3242
|
+
const record = raw;
|
|
3243
|
+
const id = asOptionalString(record.chatMessageId);
|
|
3244
|
+
const fromUserId = asOptionalString(record.fromUserId);
|
|
3245
|
+
const createdAt = asOptionalString(record.createdTime);
|
|
3246
|
+
const body = publicPartyBody(record.body);
|
|
3247
|
+
if (!id || !fromUserId || !createdAt || body === undefined)
|
|
3248
|
+
return [];
|
|
3249
|
+
const fromUser = record.fromUser;
|
|
3250
|
+
return [
|
|
3251
|
+
{
|
|
3252
|
+
id,
|
|
3253
|
+
fromUserId,
|
|
3254
|
+
fromUsername: asOptionalString(fromUser?.username),
|
|
3255
|
+
body,
|
|
3256
|
+
text: plainPartyText(body),
|
|
3257
|
+
createdAt,
|
|
3258
|
+
},
|
|
3259
|
+
];
|
|
3260
|
+
}
|
|
3261
|
+
function publicPartyBody(raw) {
|
|
3262
|
+
try {
|
|
3263
|
+
const encoded = JSON.stringify(raw);
|
|
3264
|
+
if (encoded === undefined ||
|
|
3265
|
+
new TextEncoder().encode(encoded).length > PARTY_BODY_MAX_BYTES) {
|
|
3266
|
+
return undefined;
|
|
3267
|
+
}
|
|
3268
|
+
return JSON.parse(encoded);
|
|
3269
|
+
}
|
|
3270
|
+
catch {
|
|
3271
|
+
return undefined;
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
function plainPartyText(body) {
|
|
3275
|
+
if (typeof body !== "object" || body === null || Array.isArray(body))
|
|
3276
|
+
return null;
|
|
3277
|
+
const message = body.message;
|
|
3278
|
+
if (!Array.isArray(message) || message.length === 0)
|
|
3279
|
+
return null;
|
|
3280
|
+
const pieces = [];
|
|
3281
|
+
for (const part of message) {
|
|
3282
|
+
if (typeof part !== "object" || part === null || Array.isArray(part))
|
|
3283
|
+
return null;
|
|
3284
|
+
const keys = Object.keys(part);
|
|
3285
|
+
if (keys.length !== 1 || keys[0] !== "text" || typeof part.text !== "string")
|
|
3286
|
+
return null;
|
|
3287
|
+
pieces.push(part.text);
|
|
3288
|
+
}
|
|
3289
|
+
return pieces.join("");
|
|
3290
|
+
}
|
|
3291
|
+
function partyStatus(raw) {
|
|
3292
|
+
return typeof raw === "string" && PARTY_STATUSES.has(raw)
|
|
3293
|
+
? raw
|
|
3294
|
+
: null;
|
|
3295
|
+
}
|
|
3296
|
+
function partyIdParam(raw, command) {
|
|
3297
|
+
return boundedPartyText(raw, "partyId", command, PARTY_ID_MAX);
|
|
3298
|
+
}
|
|
3299
|
+
function partyUserIds(raw, command) {
|
|
3300
|
+
if (!Array.isArray(raw) || raw.length > PARTY_USERS_MAX) {
|
|
3301
|
+
throw invalidPartyArgument(command, `requires at most ${PARTY_USERS_MAX} user ids.`);
|
|
3302
|
+
}
|
|
3303
|
+
const ids = raw.map((value) => boundedPartyText(value, "userId", command, PARTY_ID_MAX));
|
|
3304
|
+
return [...new Set(ids)];
|
|
3305
|
+
}
|
|
3306
|
+
function boundedPartyText(raw, field, command, max) {
|
|
3307
|
+
return asBoundedText(raw, field, command, max, max * 4);
|
|
3308
|
+
}
|
|
3309
|
+
function optionalBoundedPartyText(raw, field, command, max) {
|
|
3310
|
+
if (raw === undefined || raw === null)
|
|
3311
|
+
return null;
|
|
3312
|
+
return boundedPartyText(raw, field, command, max);
|
|
3313
|
+
}
|
|
3314
|
+
function invalidPartyArgument(command, detail) {
|
|
3315
|
+
return new HostCommandError("INVALID_ARGUMENT", `Castle command ${command} ${detail}`, command);
|
|
3316
|
+
}
|
|
2893
3317
|
// What a host posts to the deck (web: postMessage to the iframe; mobile:
|
|
2894
3318
|
// window.__castleSdkHost.receive) when the player presses its Back control.
|
|
2895
3319
|
export function hubBackEnvelope() {
|
|
@@ -2914,6 +3338,7 @@ const HUB_CLASSIC_COMMIT_DEADLINE_MS = 20_000;
|
|
|
2914
3338
|
const HUB_CLASSIC_ANSWER_DEADLINE_MS = 28_000;
|
|
2915
3339
|
const HUB_DOOR_ID_PATTERN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
2916
3340
|
const HUB_USER_ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
3341
|
+
const HUB_OWNER_ID_PATTERN = /^[1-9]\d{0,9}$/;
|
|
2917
3342
|
const HUB_HANDOFF_FIELDS = "status kind deckId url nonce sessionId bundleHash contentUrl transitionId arrivalDoorId";
|
|
2918
3343
|
const CAULDRON_HUB_DOORS_QUERY = `query CastleHubDoors($deckId: ID!, $env: String) {
|
|
2919
3344
|
cauldronHubDoors(deckId: $deckId, env: $env) {
|
|
@@ -2931,11 +3356,19 @@ const CAULDRON_HUB_DOORS_QUERY = `query CastleHubDoors($deckId: ID!, $env: Strin
|
|
|
2931
3356
|
const CAULDRON_HUB_GO_MUTATION = `mutation CastleHubGo($fromDeckId: ID!, $fromSessionId: ID!, $doorId: String!, $partyId: ID, $env: String) {
|
|
2932
3357
|
acquireCauldronHubDoor(fromDeckId: $fromDeckId, fromSessionId: $fromSessionId, doorId: $doorId, partyId: $partyId, env: $env) { ${HUB_HANDOFF_FIELDS} }
|
|
2933
3358
|
}`;
|
|
3359
|
+
const CAULDRON_INVITE_GO_MUTATION = CAULDRON_HUB_GO_MUTATION
|
|
3360
|
+
.replace("$env: String)", "$env: String, $ownerUserId: ID, $hubInviteToken: String)")
|
|
3361
|
+
.replace("env: $env)", "env: $env, ownerUserId: $ownerUserId, hubInviteToken: $hubInviteToken)");
|
|
3362
|
+
// A friend's House from the People list: ghost checks the follow and that the
|
|
3363
|
+
// owner is home (ownerVisitRequiredAsync).
|
|
3364
|
+
const CAULDRON_OWNER_GO_MUTATION = CAULDRON_HUB_GO_MUTATION
|
|
3365
|
+
.replace("$env: String)", "$env: String, $ownerUserId: ID)")
|
|
3366
|
+
.replace("env: $env)", "env: $env, ownerUserId: $ownerUserId)");
|
|
2934
3367
|
const CAULDRON_HUB_BACK_MUTATION = `mutation CastleHubBack($fromDeckId: ID!, $partyId: ID, $env: String) {
|
|
2935
3368
|
acquireCauldronHubReturn(fromDeckId: $fromDeckId, partyId: $partyId, env: $env) { ${HUB_HANDOFF_FIELDS} }
|
|
2936
3369
|
}`;
|
|
2937
3370
|
const CAULDRON_HUB_FRIENDS_QUERY = `query CastleHubFriends($deckId: ID!, $sessionId: ID, $env: String) {
|
|
2938
|
-
cauldronHubFriends(deckId: $deckId, sessionId: $sessionId, env: $env, behindDoors: true) { userId username here door }
|
|
3371
|
+
cauldronHubFriends(deckId: $deckId, sessionId: $sessionId, env: $env, behindDoors: true) { userId username here door home ownerUserId }
|
|
2939
3372
|
}`;
|
|
2940
3373
|
const CAULDRON_HUB_JUMP_MUTATION = `mutation CastleHubJump($fromDeckId: ID!, $fromSessionId: ID!, $friendUserId: ID!, $partyId: ID, $env: String) {
|
|
2941
3374
|
acquireCauldronHubFriend(fromDeckId: $fromDeckId, fromSessionId: $fromSessionId, friendUserId: $friendUserId, partyId: $partyId, env: $env) { ${HUB_HANDOFF_FIELDS} }
|
|
@@ -2956,6 +3389,8 @@ const CAULDRON_HUB_SAY_MUTATION = `mutation CastleHubSay($deckId: ID!, $sessionI
|
|
|
2956
3389
|
const CAULDRON_HUB_REPORT_CHAT_MUTATION = `mutation CastleHubReportChat($deckId: ID!, $sessionId: ID!, $messageId: ID!, $env: String) {
|
|
2957
3390
|
reportCauldronHubChatMessage(deckId: $deckId, sessionId: $sessionId, messageId: $messageId, env: $env)
|
|
2958
3391
|
}`;
|
|
3392
|
+
const CAULDRON_HUB_REPORT_AND_BLOCK_CHAT_MUTATION = CAULDRON_HUB_REPORT_CHAT_MUTATION
|
|
3393
|
+
.replace("env: $env)", "env: $env, block: true)");
|
|
2959
3394
|
// Ghost's own limits, held here too so a wrong answer cannot flood a deck.
|
|
2960
3395
|
const HUB_CHAT_TEXT_MAX = 200;
|
|
2961
3396
|
const HUB_CHAT_MESSAGES_MAX = 50;
|
|
@@ -3001,15 +3436,40 @@ function defaultHubSleep(ms, signal) {
|
|
|
3001
3436
|
export function createGhostHubVisit(options) {
|
|
3002
3437
|
const visit = new GhostHubVisitImpl(options);
|
|
3003
3438
|
return {
|
|
3004
|
-
|
|
3439
|
+
dispose: () => visit.dispose(),
|
|
3440
|
+
assertActive: () => visit.assertActive(),
|
|
3441
|
+
allowInvites: (userId) => {
|
|
3442
|
+
visit.assertActive();
|
|
3443
|
+
if (options.invite === true || options.inviteToken || !userId)
|
|
3444
|
+
return;
|
|
3445
|
+
options.invite = true;
|
|
3446
|
+
options.inviteUserId = userId;
|
|
3447
|
+
},
|
|
3448
|
+
go: (doorId, ctx, signal, ownerUserId) => visit.go(doorId, ctx, signal, ownerUserId),
|
|
3005
3449
|
back: (ctx, signal) => visit.back(ctx, signal),
|
|
3006
3450
|
doors: () => visit.doors(),
|
|
3007
3451
|
friends: () => visit.friends(),
|
|
3452
|
+
prepareInvite: (ctx) => visit.prepareInvite(ctx),
|
|
3453
|
+
invite: (crew, _ctx, signal) => visit.invite(crew, signal),
|
|
3454
|
+
canInvite: (ctx) => {
|
|
3455
|
+
visit.assertActive();
|
|
3456
|
+
const userId = options.invite === true ? options.inviteUserId ?? ctx.userId : null;
|
|
3457
|
+
return Promise.resolve(userId
|
|
3458
|
+
? { status: "ok", canInvite: true, userId: String(userId) }
|
|
3459
|
+
: { status: "ok", canInvite: options.invite === true });
|
|
3460
|
+
},
|
|
3461
|
+
inviteArrival: (_ctx, signal) => visit.inviteArrival(signal),
|
|
3462
|
+
undoInvite: (userId) => visit.undoInvite(userId),
|
|
3463
|
+
inviteJoinHint: (ctx) => {
|
|
3464
|
+
visit.assertActive();
|
|
3465
|
+
return options.invite === true && ctx.deckId === options.homeDeckId && options.inviteToken
|
|
3466
|
+
? { token: options.inviteToken, env: options.env ?? null } : null;
|
|
3467
|
+
},
|
|
3008
3468
|
jump: (userId, ctx, signal) => visit.jump(userId, ctx, signal),
|
|
3009
3469
|
report: (userId, reason) => visit.report(userId, reason),
|
|
3010
3470
|
chat: (after) => visit.chat(after),
|
|
3011
3471
|
say: (text) => visit.say(text),
|
|
3012
|
-
reportChat: (messageId) => visit.reportChat(messageId),
|
|
3472
|
+
reportChat: (messageId, _ctx, block, confirmBlock, signal) => visit.reportChat(messageId, block, confirmBlock, signal),
|
|
3013
3473
|
commit: (nonce) => visit.commit(nonce),
|
|
3014
3474
|
cancel: (nonce) => visit.cancel(nonce),
|
|
3015
3475
|
sessionAcquired: (sessionId) => visit.sessionAcquired(sessionId),
|
|
@@ -3017,12 +3477,81 @@ export function createGhostHubVisit(options) {
|
|
|
3017
3477
|
state: () => visit.state(),
|
|
3018
3478
|
};
|
|
3019
3479
|
}
|
|
3480
|
+
const HUB_INVITE_TOKEN = /^[A-Za-z0-9_-]{43}$/;
|
|
3481
|
+
export function hubInviteTokenFromUri(uri) {
|
|
3482
|
+
if (!uri)
|
|
3483
|
+
return null;
|
|
3484
|
+
try {
|
|
3485
|
+
const url = new URL(uri);
|
|
3486
|
+
if (url.protocol !== "https:" || !["castle.xyz", "www.castle.xyz"].includes(url.hostname) || !url.pathname.startsWith("/d/"))
|
|
3487
|
+
return null;
|
|
3488
|
+
const token = url.searchParams.get("hubInvite");
|
|
3489
|
+
return token === null ? null : HUB_INVITE_TOKEN.test(token) && url.searchParams.getAll("hubInvite").length === 1 ? token : "invalid";
|
|
3490
|
+
}
|
|
3491
|
+
catch {
|
|
3492
|
+
return null;
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
const HUB_INVITE_CREATE = `mutation CastleHubInvite($deckId: ID!, $sourceDeckId: ID, $sessionId: ID!, $cap: Int, $env: String) {
|
|
3496
|
+
createCauldronHubInvite(deckId: $deckId, sourceDeckId: $sourceDeckId, sessionId: $sessionId, cap: $cap, env: $env)
|
|
3497
|
+
}`;
|
|
3498
|
+
const HUB_INVITE_RESOLVE = `mutation CastleHubInviteResolve($token: String!, $env: String) {
|
|
3499
|
+
resolveCauldronHubInvite(token: $token, env: $env)
|
|
3500
|
+
}`;
|
|
3501
|
+
const HUB_INVITE_COMPLETE = `mutation CastleHubInviteArrival($token: String!, $deckId: ID, $sessionId: ID!, $env: String) {
|
|
3502
|
+
completeCauldronHubInvite(token: $token, deckId: $deckId, sessionId: $sessionId, env: $env)
|
|
3503
|
+
}`;
|
|
3504
|
+
const HUB_INVITE_UNDO = `mutation CastleHubInviteUndo($token: String!, $userId: ID!, $env: String) {
|
|
3505
|
+
undoCauldronHubInvitePair(token: $token, userId: $userId, env: $env)
|
|
3506
|
+
}`;
|
|
3507
|
+
/** Resolve only in the signed-in trusted host, before the first multiplayer join. */
|
|
3508
|
+
export async function resolveGhostHubInvite(options) {
|
|
3509
|
+
if (!HUB_INVITE_TOKEN.test(options.token))
|
|
3510
|
+
return { status: "unavailable" };
|
|
3511
|
+
const data = await graphql(options.graphqlFetch, HUB_INVITE_RESOLVE, { token: options.token, env: options.env ?? null }, "hub.inviteArrival");
|
|
3512
|
+
const arrival = publicInviteArrival(data.resolveCauldronHubInvite);
|
|
3513
|
+
if (arrival.destination?.hub.townDeckId !== options.townDeckId)
|
|
3514
|
+
return { status: "unavailable" };
|
|
3515
|
+
const house = data.resolveCauldronHubInvite?.house;
|
|
3516
|
+
const run = data.resolveCauldronHubInvite?.run;
|
|
3517
|
+
return { ...arrival, ...(!house && typeof run?.doorId === "string" && HUB_DOOR_ID_PATTERN.test(run.doorId)
|
|
3518
|
+
? { run: { doorId: run.doorId } } : {}), ...(typeof house?.doorId === "string" && HUB_DOOR_ID_PATTERN.test(house.doorId) &&
|
|
3519
|
+
typeof house.ownerUserId === "string" && house.ownerUserId === arrival.destination.hub.target.id
|
|
3520
|
+
? { house: { doorId: house.doorId, ownerUserId: house.ownerUserId } } : {}) };
|
|
3521
|
+
}
|
|
3522
|
+
function publicInviteArrival(value) {
|
|
3523
|
+
const raw = value;
|
|
3524
|
+
const hub = raw?.destination?.hub;
|
|
3525
|
+
if (raw?.status !== "ok" || hub?.version !== 1 || typeof hub.townDeckId !== "string" ||
|
|
3526
|
+
hub.target?.kind !== "player" || !/^[1-9]\d{0,9}$/.test(hub.target.id))
|
|
3527
|
+
return { status: "unavailable" };
|
|
3528
|
+
const friends = Array.isArray(raw.friends) ? raw.friends.slice(0, 5).flatMap((friend) => {
|
|
3529
|
+
const f = friend;
|
|
3530
|
+
return typeof f?.userId === "string" && /^[1-9]\d{0,9}$/.test(f.userId) && typeof f.username === "string"
|
|
3531
|
+
? [{ userId: f.userId, username: f.username.slice(0, 64) }] : [];
|
|
3532
|
+
}) : [];
|
|
3533
|
+
return { status: "ok", destination: { hub: { version: 1, townDeckId: hub.townDeckId, target: { kind: "player", id: hub.target.id } } }, friends };
|
|
3534
|
+
}
|
|
3020
3535
|
// Every operation that reads or moves the visit runs one at a time, in the
|
|
3021
3536
|
// order the deck asked, so a slow acquisition or commit can never land on top of
|
|
3022
3537
|
// a newer one. Only a cancel reaches past the queue, to stop an acquisition
|
|
3023
3538
|
// still in flight (one waiting out the roster lag can take 15 s).
|
|
3539
|
+
// Ghost's own answer about this link or this account. Anything else (a lost
|
|
3540
|
+
// response, a failed gate lookup, a server error) may pass, so it is retried.
|
|
3541
|
+
function definitiveInviteRefusal(error) {
|
|
3542
|
+
if (!(error instanceof HostCommandError))
|
|
3543
|
+
return false;
|
|
3544
|
+
const code = error.code;
|
|
3545
|
+
return (code.startsWith("CAULDRON_HUB_INVITE_") && code !== "CAULDRON_HUB_INVITE_NOT_IN_SESSION") ||
|
|
3546
|
+
code === "CAULDRON_HUB_FORBIDDEN" || code === "ACCOUNT_REQUIRED" || code === "LOGIN_REQUIRED";
|
|
3547
|
+
}
|
|
3024
3548
|
class GhostHubVisitImpl {
|
|
3025
3549
|
options;
|
|
3550
|
+
disposed = false;
|
|
3551
|
+
invitePreparation = null;
|
|
3552
|
+
inviteFailures = 0;
|
|
3553
|
+
inviteRetryAt = 0;
|
|
3554
|
+
inviteDestinationVisited = false;
|
|
3026
3555
|
place;
|
|
3027
3556
|
gql;
|
|
3028
3557
|
env;
|
|
@@ -3032,6 +3561,9 @@ class GhostHubVisitImpl {
|
|
|
3032
3561
|
arrivalDoorId = null;
|
|
3033
3562
|
placeKind = "place";
|
|
3034
3563
|
session = null;
|
|
3564
|
+
chatSenders = new Map();
|
|
3565
|
+
chatBlockPending = null;
|
|
3566
|
+
chatBlockNextAt = 0;
|
|
3035
3567
|
pending = null;
|
|
3036
3568
|
queue = Promise.resolve();
|
|
3037
3569
|
inFlight = new Set();
|
|
@@ -3040,12 +3572,26 @@ class GhostHubVisitImpl {
|
|
|
3040
3572
|
rows = null;
|
|
3041
3573
|
constructor(options) {
|
|
3042
3574
|
this.options = options;
|
|
3043
|
-
this.gql =
|
|
3575
|
+
this.gql = async (query, variables) => {
|
|
3576
|
+
this.assertActive();
|
|
3577
|
+
const result = await options.graphqlFetch(query, variables);
|
|
3578
|
+
this.assertActive();
|
|
3579
|
+
return result;
|
|
3580
|
+
};
|
|
3044
3581
|
this.env = options.env ?? null;
|
|
3045
3582
|
this.now = options.now ?? (() => Date.now());
|
|
3046
3583
|
this.sleep = options.sleep ?? defaultHubSleep;
|
|
3047
3584
|
this.place = options.homeDeckId;
|
|
3048
3585
|
}
|
|
3586
|
+
assertActive(signal) {
|
|
3587
|
+
if (this.disposed || signal?.aborted)
|
|
3588
|
+
throw new HostCommandError("CANCELLED", "This hub visit ended.", "hub.inviteArrival");
|
|
3589
|
+
}
|
|
3590
|
+
dispose() {
|
|
3591
|
+
this.disposed = true;
|
|
3592
|
+
for (const controller of this.inFlight)
|
|
3593
|
+
controller.abort();
|
|
3594
|
+
}
|
|
3049
3595
|
state() {
|
|
3050
3596
|
const pending = this.pending;
|
|
3051
3597
|
return {
|
|
@@ -3059,13 +3605,16 @@ class GhostHubVisitImpl {
|
|
|
3059
3605
|
};
|
|
3060
3606
|
}
|
|
3061
3607
|
sessionAcquired(sessionId) {
|
|
3608
|
+
this.assertActive();
|
|
3609
|
+
this.chatBlockPending?.abort();
|
|
3610
|
+
this.chatSenders.clear();
|
|
3062
3611
|
this.session = { sessionId, at: this.now() };
|
|
3063
3612
|
}
|
|
3064
|
-
go(doorId, ctx, signal) {
|
|
3613
|
+
go(doorId, ctx, signal, ownerUserId) {
|
|
3065
3614
|
if (!HUB_DOOR_ID_PATTERN.test(doorId))
|
|
3066
3615
|
return Promise.resolve(hubFailure("not_found"));
|
|
3067
3616
|
const asked = this.now();
|
|
3068
|
-
return this.acquisition(signal, (abort) => this.goNow(doorId, ctx, abort, asked));
|
|
3617
|
+
return this.acquisition(signal, (abort) => this.goNow(doorId, ctx, abort, asked, ownerUserId));
|
|
3069
3618
|
}
|
|
3070
3619
|
back(ctx, signal) {
|
|
3071
3620
|
return this.acquisition(signal, (abort) => this.backNow(ctx, abort));
|
|
@@ -3083,6 +3632,121 @@ class GhostHubVisitImpl {
|
|
|
3083
3632
|
const raw = Array.isArray(data.cauldronHubFriends) ? data.cauldronHubFriends : [];
|
|
3084
3633
|
return { status: "ok", friends: raw.flatMap(publicHubFriend) };
|
|
3085
3634
|
}
|
|
3635
|
+
async invite(crew, signal) {
|
|
3636
|
+
this.assertActive(signal);
|
|
3637
|
+
const source = this.session;
|
|
3638
|
+
if (this.options.invite !== true || !source)
|
|
3639
|
+
return { status: "unavailable" };
|
|
3640
|
+
const started = this.now();
|
|
3641
|
+
let data;
|
|
3642
|
+
for (;;) {
|
|
3643
|
+
this.assertActive(signal);
|
|
3644
|
+
if (this.session !== source)
|
|
3645
|
+
return { status: "unavailable" };
|
|
3646
|
+
try {
|
|
3647
|
+
data = await graphql(this.gql, HUB_INVITE_CREATE, { deckId: this.options.homeDeckId, sourceDeckId: this.place, sessionId: source.sessionId, cap: crew ? 5 : 1, env: this.env }, "hub.invite");
|
|
3648
|
+
break;
|
|
3649
|
+
}
|
|
3650
|
+
catch (error) {
|
|
3651
|
+
if (!(error instanceof HostCommandError) || error.code !== "CAULDRON_HUB_INVITE_NOT_IN_SESSION" ||
|
|
3652
|
+
this.session !== source || this.now() - started >= HUB_ROSTER_LAG_MS)
|
|
3653
|
+
throw error;
|
|
3654
|
+
await this.sleep(HUB_FORBIDDEN_RETRY_MS, signal);
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
if (this.session !== source)
|
|
3658
|
+
return { status: "unavailable" };
|
|
3659
|
+
const raw = data.createCauldronHubInvite;
|
|
3660
|
+
if (raw?.status !== "ok" || typeof raw.url !== "string" || !raw.url.startsWith("https://castle.xyz/d/") ||
|
|
3661
|
+
typeof raw.expiresAt !== "string")
|
|
3662
|
+
return { status: "unavailable" };
|
|
3663
|
+
this.assertActive(signal);
|
|
3664
|
+
try {
|
|
3665
|
+
await this.options.onInviteLink?.(raw.url);
|
|
3666
|
+
}
|
|
3667
|
+
catch { /* Dismissing share keeps the link usable. */ }
|
|
3668
|
+
return { status: "ok", url: raw.url, expiresAt: raw.expiresAt };
|
|
3669
|
+
}
|
|
3670
|
+
prepareInvite(ctx) {
|
|
3671
|
+
this.assertActive();
|
|
3672
|
+
if (this.options.invite !== true || !this.options.inviteToken || ctx.deckId !== this.options.homeDeckId)
|
|
3673
|
+
return Promise.resolve();
|
|
3674
|
+
// A guest arrives like any over-13 player; ghost decides. Only a player with no
|
|
3675
|
+
// Castle account (the dev serve's) cannot carry an invite.
|
|
3676
|
+
if (!(this.options.inviteUserId ?? ctx.userId)) {
|
|
3677
|
+
this.dropInvite();
|
|
3678
|
+
return Promise.resolve();
|
|
3679
|
+
}
|
|
3680
|
+
return this.invitePreparation ??= (async () => {
|
|
3681
|
+
const wait = this.inviteRetryAt - this.now();
|
|
3682
|
+
if (wait > 0) {
|
|
3683
|
+
await this.sleep(wait);
|
|
3684
|
+
this.assertActive();
|
|
3685
|
+
}
|
|
3686
|
+
const resolved = await resolveGhostHubInvite({ graphqlFetch: this.gql, token: this.options.inviteToken, townDeckId: this.options.homeDeckId, env: this.env });
|
|
3687
|
+
if (resolved.status !== "ok") {
|
|
3688
|
+
this.dropInvite();
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
this.options.inviteHouse = resolved.house;
|
|
3692
|
+
this.options.inviteRun = resolved.run;
|
|
3693
|
+
})().catch((error) => {
|
|
3694
|
+
this.assertActive();
|
|
3695
|
+
if (error instanceof HostCommandError && error.code === "CANCELLED") {
|
|
3696
|
+
this.invitePreparation = null;
|
|
3697
|
+
throw error;
|
|
3698
|
+
}
|
|
3699
|
+
if (definitiveInviteRefusal(error) || ++this.inviteFailures >= 5) {
|
|
3700
|
+
this.dropInvite();
|
|
3701
|
+
return;
|
|
3702
|
+
}
|
|
3703
|
+
this.inviteRetryAt = this.now() + 1_000 * 2 ** (this.inviteFailures - 1);
|
|
3704
|
+
this.invitePreparation = null;
|
|
3705
|
+
throw error;
|
|
3706
|
+
});
|
|
3707
|
+
}
|
|
3708
|
+
dropInvite() {
|
|
3709
|
+
this.options.inviteToken = undefined;
|
|
3710
|
+
this.options.inviteHouse = undefined;
|
|
3711
|
+
this.options.inviteRun = undefined;
|
|
3712
|
+
}
|
|
3713
|
+
async inviteArrival(signal) {
|
|
3714
|
+
this.assertActive(signal);
|
|
3715
|
+
const token = this.options.inviteToken;
|
|
3716
|
+
const source = this.session;
|
|
3717
|
+
if (this.options.invite !== true || !token || !HUB_INVITE_TOKEN.test(token) || !source)
|
|
3718
|
+
return { status: "unavailable" };
|
|
3719
|
+
const inviteDoor = this.options.inviteHouse?.doorId ?? this.options.inviteRun?.doorId;
|
|
3720
|
+
if (inviteDoor && !this.inviteDestinationVisited && this.place === this.options.homeDeckId) {
|
|
3721
|
+
return { status: "route", doorId: inviteDoor };
|
|
3722
|
+
}
|
|
3723
|
+
const started = this.now();
|
|
3724
|
+
for (;;) {
|
|
3725
|
+
this.assertActive(signal);
|
|
3726
|
+
try {
|
|
3727
|
+
const data = await graphql(this.gql, HUB_INVITE_COMPLETE, { token, deckId: this.place, sessionId: source.sessionId, env: this.env }, "hub.inviteArrival");
|
|
3728
|
+
if (this.session !== source)
|
|
3729
|
+
return { status: "unavailable" };
|
|
3730
|
+
const result = publicInviteArrival(data.completeCauldronHubInvite);
|
|
3731
|
+
if (result.status === "ok" && this.place !== this.options.homeDeckId)
|
|
3732
|
+
this.inviteDestinationVisited = true;
|
|
3733
|
+
return result;
|
|
3734
|
+
}
|
|
3735
|
+
catch (error) {
|
|
3736
|
+
if (!(error instanceof HostCommandError) || error.code !== "CAULDRON_HUB_INVITE_NOT_IN_SESSION" ||
|
|
3737
|
+
this.session !== source || this.now() - started >= HUB_ROSTER_LAG_MS)
|
|
3738
|
+
throw error;
|
|
3739
|
+
await this.sleep(HUB_FORBIDDEN_RETRY_MS, signal);
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
async undoInvite(userId) {
|
|
3744
|
+
const token = this.options.inviteToken;
|
|
3745
|
+
if (this.options.invite !== true || !token || !HUB_INVITE_TOKEN.test(token) || !/^[1-9]\d{0,9}$/.test(userId))
|
|
3746
|
+
return { status: "unavailable" };
|
|
3747
|
+
const data = await graphql(this.gql, HUB_INVITE_UNDO, { token, userId, env: this.env }, "hub.undoInvite");
|
|
3748
|
+
return { status: data.undoCauldronHubInvitePair?.status === "ok" ? "ok" : "unavailable" };
|
|
3749
|
+
}
|
|
3086
3750
|
jump(userId, ctx, signal) {
|
|
3087
3751
|
if (!HUB_USER_ID_PATTERN.test(userId))
|
|
3088
3752
|
return Promise.resolve(hubFailure("not_found"));
|
|
@@ -3110,7 +3774,16 @@ class GhostHubVisitImpl {
|
|
|
3110
3774
|
after: after && after.length <= HUB_CHAT_TOKEN_MAX ? after : null,
|
|
3111
3775
|
env: this.env,
|
|
3112
3776
|
}, "hub.chat");
|
|
3113
|
-
|
|
3777
|
+
const result = publicHubChat(data.cauldronHubChat);
|
|
3778
|
+
if (this.session === session && result.status === "ok") {
|
|
3779
|
+
for (const message of result.messages) {
|
|
3780
|
+
this.chatSenders.set(message.id, { session, target: { userId: message.fromUserId, username: message.fromUsername } });
|
|
3781
|
+
}
|
|
3782
|
+
// Bound identities retained across cursor polls for this session.
|
|
3783
|
+
while (this.chatSenders.size > 200)
|
|
3784
|
+
this.chatSenders.delete(this.chatSenders.keys().next().value);
|
|
3785
|
+
}
|
|
3786
|
+
return result;
|
|
3114
3787
|
}
|
|
3115
3788
|
async say(text) {
|
|
3116
3789
|
const session = this.session;
|
|
@@ -3122,12 +3795,70 @@ class GhostHubVisitImpl {
|
|
|
3122
3795
|
const data = await graphql(this.gql, CAULDRON_HUB_SAY_MUTATION, { deckId: this.place, sessionId: session.sessionId, text: said, env: this.env }, "hub.say");
|
|
3123
3796
|
return publicHubSay(data.sendCauldronHubChat);
|
|
3124
3797
|
}
|
|
3125
|
-
async reportChat(messageId) {
|
|
3798
|
+
async reportChat(messageId, block = false, confirmBlock, signal) {
|
|
3126
3799
|
const session = this.session;
|
|
3127
|
-
|
|
3800
|
+
const place = this.place;
|
|
3801
|
+
if (!session || messageId.length > HUB_CHAT_TOKEN_MAX || signal?.aborted)
|
|
3128
3802
|
return { status: "unavailable" };
|
|
3129
|
-
|
|
3130
|
-
|
|
3803
|
+
if (block) {
|
|
3804
|
+
const entry = this.chatSenders.get(messageId);
|
|
3805
|
+
const target = entry?.session === session ? entry.target : null;
|
|
3806
|
+
// A deck can request a block, but only trusted host UI can authorize it.
|
|
3807
|
+
// No UI or no host-read identity retains the old report-only behavior.
|
|
3808
|
+
block = false;
|
|
3809
|
+
if (target && confirmBlock) {
|
|
3810
|
+
if (this.chatBlockPending)
|
|
3811
|
+
return { status: "unavailable" };
|
|
3812
|
+
if (this.now() >= this.chatBlockNextAt) {
|
|
3813
|
+
this.chatBlockNextAt = this.now() + 60_000;
|
|
3814
|
+
block = await this.confirmChatBlock(target, confirmBlock, signal);
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
if (this.disposed || signal?.aborted || this.session !== session || this.place !== place)
|
|
3818
|
+
return { status: "unavailable" };
|
|
3819
|
+
}
|
|
3820
|
+
const report = () => graphql(this.gql, block ? CAULDRON_HUB_REPORT_AND_BLOCK_CHAT_MUTATION : CAULDRON_HUB_REPORT_CHAT_MUTATION, { deckId: place, sessionId: session.sessionId, messageId, env: this.env }, "hub.reportChat");
|
|
3821
|
+
let data;
|
|
3822
|
+
try {
|
|
3823
|
+
data = await report();
|
|
3824
|
+
}
|
|
3825
|
+
catch (error) {
|
|
3826
|
+
// A host can arrive before Ghost's additive schema deploy. Preserve the
|
|
3827
|
+
// report against that schema; an unaccepted block is never confirmed.
|
|
3828
|
+
if (!block || !(error instanceof Error) || !/Unknown argument ["']?block["']?/i.test(error.message))
|
|
3829
|
+
throw error;
|
|
3830
|
+
if (this.disposed || signal?.aborted || this.session !== session || this.place !== place)
|
|
3831
|
+
return { status: "unavailable" };
|
|
3832
|
+
block = false;
|
|
3833
|
+
data = await report();
|
|
3834
|
+
}
|
|
3835
|
+
return data.reportCauldronHubChatMessage === true
|
|
3836
|
+
? { status: "ok", ...(block ? { blocked: true } : {}) }
|
|
3837
|
+
: { status: "unavailable" };
|
|
3838
|
+
}
|
|
3839
|
+
async confirmChatBlock(target, confirm, signal) {
|
|
3840
|
+
const controller = new AbortController();
|
|
3841
|
+
const forward = () => controller.abort();
|
|
3842
|
+
this.chatBlockPending = controller;
|
|
3843
|
+
this.inFlight.add(controller);
|
|
3844
|
+
signal?.addEventListener("abort", forward, { once: true });
|
|
3845
|
+
try {
|
|
3846
|
+
return await new Promise((resolve) => {
|
|
3847
|
+
controller.signal.addEventListener("abort", () => resolve(false), { once: true });
|
|
3848
|
+
if (signal?.aborted)
|
|
3849
|
+
controller.abort();
|
|
3850
|
+
if (!controller.signal.aborted) {
|
|
3851
|
+
Promise.resolve().then(() => controller.signal.aborted ? false : confirm({ ...target }, controller.signal))
|
|
3852
|
+
.then((accepted) => resolve(accepted === true), () => resolve(false));
|
|
3853
|
+
}
|
|
3854
|
+
});
|
|
3855
|
+
}
|
|
3856
|
+
finally {
|
|
3857
|
+
signal?.removeEventListener("abort", forward);
|
|
3858
|
+
this.inFlight.delete(controller);
|
|
3859
|
+
if (this.chatBlockPending === controller)
|
|
3860
|
+
this.chatBlockPending = null;
|
|
3861
|
+
}
|
|
3131
3862
|
}
|
|
3132
3863
|
commit(nonce) {
|
|
3133
3864
|
return this.serial(() => this.commitNow(nonce));
|
|
@@ -3156,19 +3887,25 @@ class GhostHubVisitImpl {
|
|
|
3156
3887
|
signal?.removeEventListener("abort", forward);
|
|
3157
3888
|
});
|
|
3158
3889
|
}
|
|
3159
|
-
async goNow(doorId, ctx, signal, asked) {
|
|
3890
|
+
async goNow(doorId, ctx, signal, asked, ownerUserId) {
|
|
3160
3891
|
for (;;) {
|
|
3161
3892
|
if (signal.aborted)
|
|
3162
3893
|
return hubFailure("cancelled");
|
|
3163
3894
|
const source = this.session;
|
|
3164
3895
|
if (!source)
|
|
3165
3896
|
return hubFailure("forbidden");
|
|
3166
|
-
const
|
|
3897
|
+
const invitedRoute = this.options.invite === true && this.options.inviteToken &&
|
|
3898
|
+
(this.options.inviteHouse?.doorId ?? this.options.inviteRun?.doorId) === doorId &&
|
|
3899
|
+
this.place === this.options.homeDeckId;
|
|
3900
|
+
const data = await graphql(this.gql, invitedRoute ? CAULDRON_INVITE_GO_MUTATION : ownerUserId ? CAULDRON_OWNER_GO_MUTATION : CAULDRON_HUB_GO_MUTATION, {
|
|
3167
3901
|
fromDeckId: this.place,
|
|
3168
3902
|
fromSessionId: source.sessionId,
|
|
3169
3903
|
doorId,
|
|
3170
3904
|
partyId: ctx.partyId ?? null,
|
|
3171
3905
|
env: this.env,
|
|
3906
|
+
...(invitedRoute ? { hubInviteToken: this.options.inviteToken,
|
|
3907
|
+
...(this.options.inviteHouse ? { ownerUserId: this.options.inviteHouse.ownerUserId } : {}) }
|
|
3908
|
+
: ownerUserId ? { ownerUserId } : {}),
|
|
3172
3909
|
}, "hub.go");
|
|
3173
3910
|
const raw = data.acquireCauldronHubDoor;
|
|
3174
3911
|
// Just arrived: ghost has not seen this player in the session yet.
|
|
@@ -3277,6 +4014,7 @@ class GhostHubVisitImpl {
|
|
|
3277
4014
|
this.place = trip.toDeckId;
|
|
3278
4015
|
this.placeKind = trip.classic ? "classic" : "place";
|
|
3279
4016
|
this.arrivalDoorId = trip.arrivalDoorId;
|
|
4017
|
+
this.chatBlockPending?.abort();
|
|
3280
4018
|
this.session = trip.sessionId ? { sessionId: trip.sessionId, at: this.now() } : null;
|
|
3281
4019
|
}
|
|
3282
4020
|
changed() {
|
|
@@ -3449,13 +4187,18 @@ function publicHubFriend(raw) {
|
|
|
3449
4187
|
if (!userId)
|
|
3450
4188
|
return [];
|
|
3451
4189
|
// A door is one of this place's own ids, or nothing.
|
|
3452
|
-
const
|
|
4190
|
+
const named = asOptionalString(record.door);
|
|
4191
|
+
const door = named && HUB_DOOR_ID_PATTERN.test(named) ? named : null;
|
|
4192
|
+
// A friend at home in their House behind that door: the owner to visit.
|
|
4193
|
+
const owner = asOptionalString(record.ownerUserId);
|
|
4194
|
+
const home = door && record.home === true && owner && HUB_OWNER_ID_PATTERN.test(owner);
|
|
3453
4195
|
return [
|
|
3454
4196
|
{
|
|
3455
4197
|
userId,
|
|
3456
4198
|
username: asOptionalString(record.username),
|
|
3457
4199
|
here: record.here === true,
|
|
3458
|
-
door
|
|
4200
|
+
door,
|
|
4201
|
+
...(home ? { home: true, ownerUserId: owner } : {}),
|
|
3459
4202
|
},
|
|
3460
4203
|
];
|
|
3461
4204
|
}
|
|
@@ -3510,7 +4253,11 @@ function runHubCommand(ctx, command, params, caps, signal) {
|
|
|
3510
4253
|
switch (command) {
|
|
3511
4254
|
case "hub.go": {
|
|
3512
4255
|
const doorId = asString(params.doorId, "doorId", command);
|
|
3513
|
-
|
|
4256
|
+
// A House owner to visit; anything but a user id is ignored, as hosts
|
|
4257
|
+
// before it ignored the field, and the player's own House is acquired.
|
|
4258
|
+
const owner = asOptionalString(params.ownerUserId);
|
|
4259
|
+
const ownerUserId = owner && HUB_OWNER_ID_PATTERN.test(owner) ? owner : undefined;
|
|
4260
|
+
return hub ? hub.go(doorId, ctx, signal, ownerUserId) : Promise.resolve(unavailableHubHandoff());
|
|
3514
4261
|
}
|
|
3515
4262
|
case "hub.back":
|
|
3516
4263
|
return hub ? hub.back(ctx, signal) : Promise.resolve(unavailableHubHandoff());
|
|
@@ -3520,6 +4267,16 @@ function runHubCommand(ctx, command, params, caps, signal) {
|
|
|
3520
4267
|
return hub?.friends
|
|
3521
4268
|
? hub.friends(ctx)
|
|
3522
4269
|
: Promise.resolve({ status: "unavailable", friends: null });
|
|
4270
|
+
case "hub.invite":
|
|
4271
|
+
if (params.crew !== undefined && typeof params.crew !== "boolean")
|
|
4272
|
+
throw invalidPartyArgument("hub.invite", "requires a boolean crew option.");
|
|
4273
|
+
return hub?.invite ? hub.invite(params.crew === true, ctx, signal) : Promise.resolve({ status: "unavailable" });
|
|
4274
|
+
case "hub.canInvite":
|
|
4275
|
+
return hub?.canInvite ? hub.canInvite(ctx) : Promise.resolve({ status: "unavailable", canInvite: false });
|
|
4276
|
+
case "hub.inviteArrival":
|
|
4277
|
+
return hub?.inviteArrival ? hub.inviteArrival(ctx, signal) : Promise.resolve({ status: "unavailable" });
|
|
4278
|
+
case "hub.undoInvite":
|
|
4279
|
+
return hub?.undoInvite ? hub.undoInvite(asString(params.userId, "userId", command), ctx) : Promise.resolve({ status: "unavailable" });
|
|
3523
4280
|
case "hub.jump": {
|
|
3524
4281
|
const userId = asString(params.userId, "userId", command);
|
|
3525
4282
|
return hub?.jump ? hub.jump(userId, ctx, signal) : Promise.resolve(unavailableHubHandoff());
|
|
@@ -3542,7 +4299,7 @@ function runHubCommand(ctx, command, params, caps, signal) {
|
|
|
3542
4299
|
case "hub.reportChat": {
|
|
3543
4300
|
const messageId = asString(params.messageId, "messageId", command);
|
|
3544
4301
|
return hub?.reportChat
|
|
3545
|
-
? hub.reportChat(messageId, ctx)
|
|
4302
|
+
? hub.reportChat(messageId, ctx, params.block === true && !!caps.confirmHubChatBlock, caps.confirmHubChatBlock ? (target, abort) => caps.confirmHubChatBlock(target, ctx, abort) : undefined, signal)
|
|
3546
4303
|
: Promise.resolve({ status: "unavailable" });
|
|
3547
4304
|
}
|
|
3548
4305
|
case "hub.commit": {
|