castle-web-cli 0.4.238 → 0.4.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +218 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +22 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +4 -2
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +12 -3
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +2 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +240 -8
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +8 -2
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +79 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +198 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/castle.json +4 -4
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +474 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +75 -52
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +215 -26
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +40 -15
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +854 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +437 -57
- package/kits/hub-game/docs/analytics.md +20 -3
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +80 -1
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-resync.mjs +13 -0
- package/kits/hub-game/scripts/test-role-client.mjs +10 -3
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
package/dist/castle-host/host.js
CHANGED
|
@@ -32,6 +32,8 @@ const COMMAND_NAMES = [
|
|
|
32
32
|
"user.getCurrent",
|
|
33
33
|
"user.get",
|
|
34
34
|
"experiments.get",
|
|
35
|
+
"experiments.exposed",
|
|
36
|
+
"analytics.event",
|
|
35
37
|
"time.getServerTime",
|
|
36
38
|
"pass.has",
|
|
37
39
|
"avatar.get",
|
|
@@ -57,11 +59,14 @@ const COMMAND_NAMES = [
|
|
|
57
59
|
"hub.friends",
|
|
58
60
|
"hub.invite",
|
|
59
61
|
"hub.canInvite",
|
|
62
|
+
"hub.inviteAvailable",
|
|
60
63
|
"hub.inviteArrival",
|
|
61
64
|
"hub.undoInvite",
|
|
62
65
|
"hub.hearts",
|
|
63
66
|
"hub.setHearts",
|
|
64
67
|
"hub.signIn",
|
|
68
|
+
"hub.pushPermission",
|
|
69
|
+
"hub.pushDestination",
|
|
65
70
|
"hub.jump",
|
|
66
71
|
"hub.report",
|
|
67
72
|
"hub.chat",
|
|
@@ -99,6 +104,7 @@ const COMMAND_NAMES = [
|
|
|
99
104
|
"cauldronStorage.boardTop",
|
|
100
105
|
"cauldronStorage.boardGet",
|
|
101
106
|
"cauldronStorage.usage",
|
|
107
|
+
"rooms.list",
|
|
102
108
|
"lifecycle.restoreState",
|
|
103
109
|
"localCache.get",
|
|
104
110
|
"localCache.set",
|
|
@@ -180,10 +186,15 @@ export async function executeCommand(ctx, command, params, capabilities, options
|
|
|
180
186
|
try {
|
|
181
187
|
const data = await dispatchCommand(ctx, command, (params ?? {}), capabilities, options);
|
|
182
188
|
capabilities.hub?.assertActive?.();
|
|
183
|
-
|
|
189
|
+
// A join the deck gave up on is not the connection it holds.
|
|
190
|
+
if (!options.signal?.aborted)
|
|
191
|
+
noteAcquiredSession(ctx, command, data, capabilities, acquisition);
|
|
184
192
|
return { ok: true, data };
|
|
185
193
|
}
|
|
186
194
|
catch (error) {
|
|
195
|
+
// Availability is a read-only capability probe, including a retired visit.
|
|
196
|
+
if (command === "hub.inviteAvailable")
|
|
197
|
+
return { ok: true, data: { status: "unavailable" } };
|
|
187
198
|
return { ok: false, error: toSerializedError(error, command) };
|
|
188
199
|
}
|
|
189
200
|
}
|
|
@@ -215,6 +226,7 @@ const HUB_VISIT_COMMANDS = new Set([
|
|
|
215
226
|
"hub.friends",
|
|
216
227
|
"hub.invite",
|
|
217
228
|
"hub.canInvite",
|
|
229
|
+
"hub.inviteAvailable",
|
|
218
230
|
"hub.inviteArrival",
|
|
219
231
|
"hub.undoInvite",
|
|
220
232
|
"hub.jump",
|
|
@@ -228,6 +240,15 @@ const HUB_VISIT_COMMANDS = new Set([
|
|
|
228
240
|
function isHubVisitCommand(command) {
|
|
229
241
|
return HUB_VISIT_COMMANDS.has(command);
|
|
230
242
|
}
|
|
243
|
+
function runHubPushCommand(ctx, command, params, caps, signal) {
|
|
244
|
+
if (Reflect.ownKeys(params).length !== 0 ||
|
|
245
|
+
!ctx.deckId || !ctx.sessionId || !ctx.userId || ctx.isAnonymous) {
|
|
246
|
+
return Promise.resolve({ status: "unavailable" });
|
|
247
|
+
}
|
|
248
|
+
return command === "hub.pushPermission"
|
|
249
|
+
? caps.hubPushPermission?.(ctx, signal) ?? Promise.resolve({ status: "unavailable" })
|
|
250
|
+
: caps.hubPushDestination?.(ctx, signal) ?? Promise.resolve({ status: "unavailable" });
|
|
251
|
+
}
|
|
231
252
|
function runCommand(ctx, command, params, caps, options) {
|
|
232
253
|
if (command === "multiplayer.getSession" && caps.getMultiplayerSession) {
|
|
233
254
|
return caps.getMultiplayerSession(multiplayerSessionRequest(params), ctx);
|
|
@@ -245,6 +266,9 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
245
266
|
? caps.hubSignIn(reason, ctx, options.signal)
|
|
246
267
|
: Promise.resolve({ status: "unavailable" });
|
|
247
268
|
}
|
|
269
|
+
if (command === "hub.pushPermission" || command === "hub.pushDestination") {
|
|
270
|
+
return runHubPushCommand(ctx, command, params, caps, options.signal);
|
|
271
|
+
}
|
|
248
272
|
if (isPlatformCommand(command)) {
|
|
249
273
|
return runPlatformCommand(ctx, command, params, caps);
|
|
250
274
|
}
|
|
@@ -278,6 +302,10 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
278
302
|
return userGet(params, gql);
|
|
279
303
|
case "experiments.get":
|
|
280
304
|
return Promise.resolve(experimentsGet(ctx));
|
|
305
|
+
case "experiments.exposed":
|
|
306
|
+
return experimentsExposed(ctx, params, gql);
|
|
307
|
+
case "analytics.event":
|
|
308
|
+
return analyticsEvent(ctx, params, gql);
|
|
281
309
|
case "time.getServerTime":
|
|
282
310
|
return timeGetServerTime(gql);
|
|
283
311
|
case "pass.has":
|
|
@@ -339,6 +367,8 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
339
367
|
return cauldronStorageBoardGet(ctx, params, gql);
|
|
340
368
|
case "cauldronStorage.usage":
|
|
341
369
|
return cauldronStorageUsage(ctx, gql);
|
|
370
|
+
case "rooms.list":
|
|
371
|
+
return roomsList(ctx, gql);
|
|
342
372
|
// Platform commands are handled above; listed here to keep the switch
|
|
343
373
|
// exhaustive over CommandName.
|
|
344
374
|
case "pass.offer":
|
|
@@ -419,16 +449,31 @@ async function multiplayerGetSession(ctx, params, caps) {
|
|
|
419
449
|
const mode = request.mode === "public" && ctx.partyId && !hintedSessionId && !inviteHint
|
|
420
450
|
? "party"
|
|
421
451
|
: request.mode;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
452
|
+
let data;
|
|
453
|
+
try {
|
|
454
|
+
data = await graphql(caps.graphqlFetch, inviteHint ? CAULDRON_INVITE_SESSION_QUERY : CAULDRON_MULTIPLAYER_SESSION_QUERY, {
|
|
455
|
+
deckId,
|
|
456
|
+
mode,
|
|
457
|
+
key: request.key ?? null,
|
|
458
|
+
sessionId: request.mode === "public" ? hintedSessionId : null,
|
|
459
|
+
partyId: inviteHint ? null : ctx.partyId ?? null,
|
|
460
|
+
...(inviteHint ? { hubInviteToken: inviteHint.token, env: inviteHint.env } : {}),
|
|
461
|
+
}, "multiplayer.getSession");
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
// Ghost refuses a signed-out player; the deck gets the documented
|
|
465
|
+
// single-player connection instead. ctx.userId cannot decide this: a host
|
|
466
|
+
// may leave it null for an anonymous account whose credentials ghost accepts.
|
|
467
|
+
if (error instanceof HostCommandError && error.code === "LOGIN_REQUIRED") {
|
|
468
|
+
return signedOutSoloSession();
|
|
469
|
+
}
|
|
470
|
+
throw error;
|
|
471
|
+
}
|
|
430
472
|
return multiplayerSessionResult(data.getCauldronMultiplayerSession);
|
|
431
473
|
}
|
|
474
|
+
function signedOutSoloSession() {
|
|
475
|
+
return { status: "solo", url: null, nonce: null, sessionId: null, soloReason: "unavailable" };
|
|
476
|
+
}
|
|
432
477
|
const MULTIPLAYER_SESSION_ID_MAX_LENGTH = 256;
|
|
433
478
|
function multiplayerHintedSessionId(ctx, deckId) {
|
|
434
479
|
const hint = ctx.joinHint;
|
|
@@ -1353,6 +1398,58 @@ function experimentsGet(ctx) {
|
|
|
1353
1398
|
variants: Object.fromEntries(Object.entries(source).filter((entry) => typeof entry[1] === "string")),
|
|
1354
1399
|
};
|
|
1355
1400
|
}
|
|
1401
|
+
const EXPERIMENT_EXPOSURE_MUTATION = `mutation LogDeckExperimentExposure($deckId: ID!, $experiment: String!, $variant: String!) {
|
|
1402
|
+
logDeckExperimentExposure(deckId: $deckId, experiment: $experiment, variant: $variant)
|
|
1403
|
+
}`;
|
|
1404
|
+
// The deck read a variant for the first time. Only an arm this host handed the
|
|
1405
|
+
// deck (experimentVariants, the same context experiments.get answers from) is
|
|
1406
|
+
// reported, so a deck cannot claim another; Castle's server checks it again.
|
|
1407
|
+
async function experimentsExposed(ctx, params, gql) {
|
|
1408
|
+
const name = asString(params.name, "name", "experiments.exposed");
|
|
1409
|
+
const variant = asString(params.variant, "variant", "experiments.exposed");
|
|
1410
|
+
const handed = experimentsGet(ctx).variants;
|
|
1411
|
+
if (!ctx.deckId || !Object.hasOwn(handed, name) || handed[name] !== variant) {
|
|
1412
|
+
return { recorded: false };
|
|
1413
|
+
}
|
|
1414
|
+
const data = await graphql(gql, EXPERIMENT_EXPOSURE_MUTATION, { deckId: ctx.deckId, experiment: name, variant }, "experiments.exposed");
|
|
1415
|
+
return { recorded: data?.logDeckExperimentExposure === true };
|
|
1416
|
+
}
|
|
1417
|
+
const ANALYTICS_EVENT_MUTATION = `mutation LogDeckAnalyticsEvent($deckId: ID!, $name: String!, $properties: Json) {
|
|
1418
|
+
logDeckAnalyticsEvent(deckId: $deckId, name: $name, properties: $properties)
|
|
1419
|
+
}`;
|
|
1420
|
+
// The deck's own rule for a name or a property key (sdk/src/analytics.ts holds
|
|
1421
|
+
// the same one; Castle's server checks it a third time).
|
|
1422
|
+
const ANALYTICS_TOKEN = /^[A-Za-z0-9][A-Za-z0-9 _.:/-]*$/;
|
|
1423
|
+
// A deck's named event, for its creator analytics. The deck is never trusted
|
|
1424
|
+
// with its own id: the event goes to this host's deck, and only when there is
|
|
1425
|
+
// one. Castle's server decides whether the name is registered and drops it if
|
|
1426
|
+
// not, so `recorded` can be false for a well-formed event.
|
|
1427
|
+
async function analyticsEvent(ctx, params, gql) {
|
|
1428
|
+
const name = asString(params.name, "name", "analytics.event").trim();
|
|
1429
|
+
if (name.length > 64 || !ANALYTICS_TOKEN.test(name)) {
|
|
1430
|
+
throw new HostCommandError("INVALID_ARGUMENT", "analytics.event name is not a valid event name.", "analytics.event");
|
|
1431
|
+
}
|
|
1432
|
+
const raw = params.properties ?? {};
|
|
1433
|
+
const proto = typeof raw === "object" && raw !== null ? Object.getPrototypeOf(raw) : undefined;
|
|
1434
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
1435
|
+
throw new HostCommandError("INVALID_ARGUMENT", "analytics.event properties must be a plain object.", "analytics.event");
|
|
1436
|
+
}
|
|
1437
|
+
const properties = {};
|
|
1438
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
1439
|
+
const ok = key.length <= 32 && ANALYTICS_TOKEN.test(key) && typeof value === "number" && Number.isFinite(value);
|
|
1440
|
+
if (!ok) {
|
|
1441
|
+
throw new HostCommandError("INVALID_ARGUMENT", `analytics.event property ${JSON.stringify(key)} is not valid.`, "analytics.event");
|
|
1442
|
+
}
|
|
1443
|
+
properties[key] = value;
|
|
1444
|
+
}
|
|
1445
|
+
if (Object.keys(properties).length > 5) {
|
|
1446
|
+
throw new HostCommandError("INVALID_ARGUMENT", "analytics.event takes at most five properties.", "analytics.event");
|
|
1447
|
+
}
|
|
1448
|
+
if (!ctx.deckId)
|
|
1449
|
+
return { recorded: false };
|
|
1450
|
+
const data = await graphql(gql, ANALYTICS_EVENT_MUTATION, { deckId: ctx.deckId, name, properties }, "analytics.event");
|
|
1451
|
+
return { recorded: data?.logDeckAnalyticsEvent === true };
|
|
1452
|
+
}
|
|
1356
1453
|
// One user's public profile, or null when there is no such user. The photo and
|
|
1357
1454
|
// frame are fetched here and handed over as data: urls, since a deck's CSP
|
|
1358
1455
|
// allows no image host and the host is outside it.
|
|
@@ -2396,6 +2493,45 @@ async function cauldronStorageUsage(ctx, gql) {
|
|
|
2396
2493
|
const data = await graphql(gql, CAULDRON_STORAGE_USAGE_QUERY, { deckId }, "cauldronStorage.usage");
|
|
2397
2494
|
return { usage: data.cauldronStorageUsage };
|
|
2398
2495
|
}
|
|
2496
|
+
async function roomsList(ctx, gql) {
|
|
2497
|
+
const deckId = requireDeckId(ctx, "rooms.list");
|
|
2498
|
+
const data = await graphql(gql, ROOMS_LIST_QUERY, { deckId }, "rooms.list");
|
|
2499
|
+
// Ghost answers null to anyone but the deck's owner, a Castle admin or a
|
|
2500
|
+
// member of the presence gate, and for a deck the player cannot see.
|
|
2501
|
+
const presence = data.cauldronDeckPresence;
|
|
2502
|
+
if (typeof presence !== "object" || presence === null)
|
|
2503
|
+
return null;
|
|
2504
|
+
const record = presence;
|
|
2505
|
+
const rooms = Array.isArray(record.routes) ? record.routes.flatMap(publicRoomSummary) : [];
|
|
2506
|
+
const total = record.total;
|
|
2507
|
+
return {
|
|
2508
|
+
total: isCount(total) ? total : rooms.reduce((sum, room) => sum + room.players, 0),
|
|
2509
|
+
rooms,
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2512
|
+
function publicRoomSummary(raw) {
|
|
2513
|
+
if (typeof raw !== "object" || raw === null)
|
|
2514
|
+
return [];
|
|
2515
|
+
const record = raw;
|
|
2516
|
+
const sessionId = asOptionalString(record.sessionId);
|
|
2517
|
+
const { players, maxPlayers } = record;
|
|
2518
|
+
if (!sessionId || !isCount(players) || !isCount(maxPlayers))
|
|
2519
|
+
return [];
|
|
2520
|
+
const routeId = asOptionalString(record.routeId);
|
|
2521
|
+
const slot = asOptionalString(record.slot);
|
|
2522
|
+
return [
|
|
2523
|
+
{
|
|
2524
|
+
sessionId,
|
|
2525
|
+
...(routeId ? { routeId } : {}),
|
|
2526
|
+
...(slot ? { slot } : {}),
|
|
2527
|
+
players,
|
|
2528
|
+
maxPlayers,
|
|
2529
|
+
},
|
|
2530
|
+
];
|
|
2531
|
+
}
|
|
2532
|
+
function isCount(value) {
|
|
2533
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
2534
|
+
}
|
|
2399
2535
|
const CHARACTER_OPERATION_FIELDS = `
|
|
2400
2536
|
operationId
|
|
2401
2537
|
characterId
|
|
@@ -2997,11 +3133,24 @@ const CAULDRON_STORAGE_BOARD_TOP_QUERY = `
|
|
|
2997
3133
|
}
|
|
2998
3134
|
}
|
|
2999
3135
|
`;
|
|
3136
|
+
const ROOMS_LIST_QUERY = `
|
|
3137
|
+
query CastleRoomsList($deckId: ID!) {
|
|
3138
|
+
cauldronDeckPresence(deckId: $deckId) {
|
|
3139
|
+
total
|
|
3140
|
+
routes { sessionId routeId slot players maxPlayers }
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
`;
|
|
3000
3144
|
const CAULDRON_STORAGE_USAGE_QUERY = `
|
|
3001
3145
|
query CastleCauldronStorageUsage($deckId: ID!) {
|
|
3002
3146
|
cauldronStorageUsage(deckId: $deckId) {
|
|
3003
3147
|
player { keyCount keyLimit byteCount byteLimit }
|
|
3004
3148
|
shared { keyCount keyLimit byteCount byteLimit }
|
|
3149
|
+
rate {
|
|
3150
|
+
callerClass
|
|
3151
|
+
caller { opsUsed opsLimit bytesUsed bytesLimit }
|
|
3152
|
+
deck { opsUsed opsLimit bytesUsed bytesLimit }
|
|
3153
|
+
}
|
|
3005
3154
|
}
|
|
3006
3155
|
}
|
|
3007
3156
|
`;
|
|
@@ -3372,6 +3521,30 @@ export function hubGoEnvelope(go) {
|
|
|
3372
3521
|
},
|
|
3373
3522
|
};
|
|
3374
3523
|
}
|
|
3524
|
+
// The deck's word that a Go this host sent (hubGoEnvelope) ended without the
|
|
3525
|
+
// player going through the door (SDK `Hub.goFailed`, one-way, the WebView's
|
|
3526
|
+
// message channel): `why` is "refused" (Hub.go gave no handoff), "content"
|
|
3527
|
+
// (the destination's content would not load) or "join" (the join was never
|
|
3528
|
+
// committed). A host that acquired the door from its own session may acquire
|
|
3529
|
+
// it again there and post a fresh Go. Null for any other message.
|
|
3530
|
+
export function hubGoFailedFrom(message) {
|
|
3531
|
+
if (typeof message !== "object" || message === null)
|
|
3532
|
+
return null;
|
|
3533
|
+
const record = message;
|
|
3534
|
+
if (record.castleSdk !== 1)
|
|
3535
|
+
return null;
|
|
3536
|
+
const event = record.hub;
|
|
3537
|
+
if (typeof event !== "object" || event === null || event.type !== "goFailed")
|
|
3538
|
+
return null;
|
|
3539
|
+
const { doorId, owner, why } = event;
|
|
3540
|
+
if (typeof doorId !== "string" || doorId.length === 0 || doorId.length > 128)
|
|
3541
|
+
return null;
|
|
3542
|
+
if (owner !== undefined && (typeof owner !== "string" || !/^[1-9]\d{0,9}$/.test(owner)))
|
|
3543
|
+
return null;
|
|
3544
|
+
if (why !== "refused" && why !== "content" && why !== "join")
|
|
3545
|
+
return null;
|
|
3546
|
+
return { doorId, owner: owner ?? null, why };
|
|
3547
|
+
}
|
|
3375
3548
|
// Ghost's source check reads the session's heartbeat roster, which can lag an
|
|
3376
3549
|
// arrival by up to 15 s: a door used in that window answers `forbidden`.
|
|
3377
3550
|
const HUB_ROSTER_LAG_MS = 16_000;
|
|
@@ -3420,6 +3593,9 @@ const CAULDRON_OWNER_GO_MUTATION = CAULDRON_HUB_GO_MUTATION
|
|
|
3420
3593
|
const CAULDRON_HUB_BACK_MUTATION = `mutation CastleHubBack($fromDeckId: ID!, $partyId: ID, $env: String) {
|
|
3421
3594
|
acquireCauldronHubReturn(fromDeckId: $fromDeckId, partyId: $partyId, env: $env) { ${HUB_HANDOFF_FIELDS} }
|
|
3422
3595
|
}`;
|
|
3596
|
+
const CAULDRON_HUB_INVITE_AVAILABLE_QUERY = `query CastleHubInviteAvailable {
|
|
3597
|
+
me { featureGates }
|
|
3598
|
+
}`;
|
|
3423
3599
|
const CAULDRON_HUB_FRIENDS_QUERY = `query CastleHubFriends($deckId: ID!, $sessionId: ID, $env: String) {
|
|
3424
3600
|
cauldronHubFriends(deckId: $deckId, sessionId: $sessionId, env: $env, behindDoors: true) { userId username here door home ownerUserId }
|
|
3425
3601
|
}`;
|
|
@@ -3511,6 +3687,7 @@ export function createGhostHubVisit(options) {
|
|
|
3511
3687
|
? { status: "ok", canInvite: true, userId: String(userId) }
|
|
3512
3688
|
: { status: "ok", canInvite: options.invite === true });
|
|
3513
3689
|
},
|
|
3690
|
+
inviteAvailable: (ctx) => visit.inviteAvailable(ctx),
|
|
3514
3691
|
inviteArrival: (_ctx, signal) => visit.inviteArrival(signal),
|
|
3515
3692
|
undoInvite: (userId) => visit.undoInvite(userId),
|
|
3516
3693
|
inviteJoinHint: (ctx) => {
|
|
@@ -3617,6 +3794,8 @@ class GhostHubVisitImpl {
|
|
|
3617
3794
|
session = null;
|
|
3618
3795
|
sessionAcquisitions = 0;
|
|
3619
3796
|
acceptedSessionAcquisition = 0;
|
|
3797
|
+
// The last acquisition started before the player arrived where they stand.
|
|
3798
|
+
placeFence = 0;
|
|
3620
3799
|
chatSenders = new Map();
|
|
3621
3800
|
chatBlockPending = null;
|
|
3622
3801
|
chatBlockNextAt = 0;
|
|
@@ -3664,14 +3843,16 @@ class GhostHubVisitImpl {
|
|
|
3664
3843
|
// so an earlier join that answers after a later one (ghost placed it in another
|
|
3665
3844
|
// shard) must not replace its session as the door source, or the player stands
|
|
3666
3845
|
// in one session while every door names the other. A later join that failed
|
|
3667
|
-
// replaces nothing: the deck keeps its earlier connection then.
|
|
3846
|
+
// replaces nothing: the deck keeps its earlier connection then. A join
|
|
3847
|
+
// started before the last arrival belongs to a place the player left, even
|
|
3848
|
+
// when they have come back to it: the arrival named the session.
|
|
3668
3849
|
sessionAcquisitionStarted() {
|
|
3669
3850
|
return ++this.sessionAcquisitions;
|
|
3670
3851
|
}
|
|
3671
3852
|
sessionAcquired(sessionId, acquisition) {
|
|
3672
3853
|
this.assertActive();
|
|
3673
3854
|
if (acquisition !== undefined) {
|
|
3674
|
-
if (acquisition < this.acceptedSessionAcquisition)
|
|
3855
|
+
if (acquisition <= this.placeFence || acquisition < this.acceptedSessionAcquisition)
|
|
3675
3856
|
return;
|
|
3676
3857
|
this.acceptedSessionAcquisition = acquisition;
|
|
3677
3858
|
}
|
|
@@ -3701,6 +3882,29 @@ class GhostHubVisitImpl {
|
|
|
3701
3882
|
const raw = Array.isArray(data.cauldronHubFriends) ? data.cauldronHubFriends : [];
|
|
3702
3883
|
return { status: "ok", friends: raw.flatMap(publicHubFriend) };
|
|
3703
3884
|
}
|
|
3885
|
+
async inviteAvailable(ctx) {
|
|
3886
|
+
try {
|
|
3887
|
+
this.assertActive();
|
|
3888
|
+
const userId = ctx.userId;
|
|
3889
|
+
const authenticated = () => ctx.userId === userId && !!userId && ctx.isAnonymous !== true &&
|
|
3890
|
+
!ctx.username?.toLowerCase().startsWith("anonymous-user-");
|
|
3891
|
+
if (!authenticated() || this.options.invite !== true)
|
|
3892
|
+
return { status: "unavailable" };
|
|
3893
|
+
const source = this.session, contextSession = ctx.sessionId;
|
|
3894
|
+
const data = await graphql(this.gql, CAULDRON_HUB_INVITE_AVAILABLE_QUERY, {}, "hub.inviteAvailable");
|
|
3895
|
+
this.assertActive();
|
|
3896
|
+
if (this.session !== source || ctx.sessionId !== contextSession || !authenticated())
|
|
3897
|
+
return { status: "unavailable" };
|
|
3898
|
+
const gates = data.me?.featureGates;
|
|
3899
|
+
if (!gates || typeof gates !== "object" || Array.isArray(gates))
|
|
3900
|
+
return { status: "unavailable" };
|
|
3901
|
+
const available = gates.cauldron_hub_invites;
|
|
3902
|
+
return typeof available === "boolean" ? { status: "ok", available: available === true } : { status: "unavailable" };
|
|
3903
|
+
}
|
|
3904
|
+
catch {
|
|
3905
|
+
return { status: "unavailable" };
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3704
3908
|
async invite(crew, signal) {
|
|
3705
3909
|
this.assertActive(signal);
|
|
3706
3910
|
const source = this.session;
|
|
@@ -4084,6 +4288,7 @@ class GhostHubVisitImpl {
|
|
|
4084
4288
|
this.placeKind = trip.classic ? "classic" : "place";
|
|
4085
4289
|
this.arrivalDoorId = trip.arrivalDoorId;
|
|
4086
4290
|
this.chatBlockPending?.abort();
|
|
4291
|
+
this.placeFence = this.sessionAcquisitions;
|
|
4087
4292
|
this.session = trip.sessionId ? { sessionId: trip.sessionId, at: this.now() } : null;
|
|
4088
4293
|
}
|
|
4089
4294
|
changed() {
|
|
@@ -4342,6 +4547,8 @@ function runHubCommand(ctx, command, params, caps, signal) {
|
|
|
4342
4547
|
return hub?.invite ? hub.invite(params.crew === true, ctx, signal) : Promise.resolve({ status: "unavailable" });
|
|
4343
4548
|
case "hub.canInvite":
|
|
4344
4549
|
return hub?.canInvite ? hub.canInvite(ctx) : Promise.resolve({ status: "unavailable", canInvite: false });
|
|
4550
|
+
case "hub.inviteAvailable":
|
|
4551
|
+
return hub?.inviteAvailable ? hub.inviteAvailable(ctx) : Promise.resolve({ status: "unavailable" });
|
|
4345
4552
|
case "hub.inviteArrival":
|
|
4346
4553
|
return hub?.inviteArrival ? hub.inviteArrival(ctx, signal) : Promise.resolve({ status: "unavailable" });
|
|
4347
4554
|
case "hub.undoInvite":
|
package/dist/castleJson.d.ts
CHANGED
|
@@ -59,7 +59,17 @@ export interface ExperimentConfig {
|
|
|
59
59
|
variants: string[];
|
|
60
60
|
weights?: number[];
|
|
61
61
|
winner?: string;
|
|
62
|
+
audience?: ExperimentAudience;
|
|
62
63
|
}
|
|
64
|
+
export interface ExperimentAudience {
|
|
65
|
+
countries?: string[];
|
|
66
|
+
platforms?: ('web' | 'ios' | 'android')[];
|
|
67
|
+
players?: 'new' | 'returning';
|
|
68
|
+
}
|
|
69
|
+
export declare const EXPERIMENT_AUDIENCE_PLATFORMS: string[];
|
|
70
|
+
export declare const EXPERIMENT_AUDIENCE_PLAYERS: string[];
|
|
71
|
+
export declare const EXPERIMENT_AUDIENCE_COUNTRY: RegExp;
|
|
72
|
+
export declare const EXPERIMENT_AUDIENCE_COUNTRIES_CAP = 300;
|
|
63
73
|
export declare const EXPERIMENTS_CAP = 8;
|
|
64
74
|
export declare const EXPERIMENT_VARIANTS_MIN = 2;
|
|
65
75
|
export declare const EXPERIMENT_VARIANTS_CAP = 8;
|
package/dist/castleJson.js
CHANGED
|
@@ -47,6 +47,11 @@ export function resolveBundleChunks(castleJson, flag = false) {
|
|
|
47
47
|
}
|
|
48
48
|
return flag || block?.chunks === 'classic';
|
|
49
49
|
}
|
|
50
|
+
export const EXPERIMENT_AUDIENCE_PLATFORMS = ['web', 'ios', 'android'];
|
|
51
|
+
export const EXPERIMENT_AUDIENCE_PLAYERS = ['new', 'returning'];
|
|
52
|
+
export const EXPERIMENT_AUDIENCE_COUNTRY = /^[A-Z]{2}$/;
|
|
53
|
+
// Matches ghost-server's limit.
|
|
54
|
+
export const EXPERIMENT_AUDIENCE_COUNTRIES_CAP = 300;
|
|
50
55
|
export const EXPERIMENTS_CAP = 8;
|
|
51
56
|
export const EXPERIMENT_VARIANTS_MIN = 2;
|
|
52
57
|
export const EXPERIMENT_VARIANTS_CAP = 8;
|
|
@@ -86,9 +91,9 @@ export function validateExperiments(value) {
|
|
|
86
91
|
function validateExperiment(name, value) {
|
|
87
92
|
if (!isPlainObject(value))
|
|
88
93
|
throw invalidExperiment(name, 'must be an object');
|
|
89
|
-
const unknown = Object.keys(value).find((key) => key !== 'variants' && key !== 'weights' && key !== 'winner');
|
|
94
|
+
const unknown = Object.keys(value).find((key) => key !== 'variants' && key !== 'weights' && key !== 'winner' && key !== 'audience');
|
|
90
95
|
if (unknown !== undefined) {
|
|
91
|
-
throw invalidExperiment(name, `has an unknown key "${unknown}" (use variants, weights, winner)`);
|
|
96
|
+
throw invalidExperiment(name, `has an unknown key "${unknown}" (use variants, weights, winner, audience)`);
|
|
92
97
|
}
|
|
93
98
|
const variants = value.variants;
|
|
94
99
|
if (!Array.isArray(variants) ||
|
|
@@ -119,12 +124,51 @@ function validateExperiment(name, value) {
|
|
|
119
124
|
if (value.winner !== undefined && (winner === undefined || !variants.includes(winner))) {
|
|
120
125
|
throw invalidExperiment(name, `winner ${JSON.stringify(value.winner)} must be one of its variants`);
|
|
121
126
|
}
|
|
127
|
+
const audience = validateAudience(name, value.audience);
|
|
122
128
|
return {
|
|
123
129
|
variants: [...variants],
|
|
124
130
|
...(weights === undefined ? {} : { weights: [...weights] }),
|
|
125
131
|
...(winner === undefined ? {} : { winner }),
|
|
132
|
+
...(audience === undefined ? {} : { audience }),
|
|
126
133
|
};
|
|
127
134
|
}
|
|
135
|
+
// The same rules ghost-server applies (src/utils/deckExperimentAudience.ts).
|
|
136
|
+
function validateAudience(name, value) {
|
|
137
|
+
if (value === undefined || value === null)
|
|
138
|
+
return undefined;
|
|
139
|
+
if (!isPlainObject(value))
|
|
140
|
+
throw invalidExperiment(name, 'audience must be an object');
|
|
141
|
+
const unknown = Object.keys(value).find((key) => key !== 'countries' && key !== 'platforms' && key !== 'players');
|
|
142
|
+
if (unknown !== undefined) {
|
|
143
|
+
throw invalidExperiment(name, `audience has an unknown key "${unknown}" (use countries, platforms, players)`);
|
|
144
|
+
}
|
|
145
|
+
const audience = {};
|
|
146
|
+
const { countries, platforms, players } = value;
|
|
147
|
+
if (countries !== undefined && countries !== null) {
|
|
148
|
+
if (!Array.isArray(countries) ||
|
|
149
|
+
countries.length === 0 ||
|
|
150
|
+
countries.length > EXPERIMENT_AUDIENCE_COUNTRIES_CAP ||
|
|
151
|
+
!countries.every((c) => typeof c === 'string' && EXPERIMENT_AUDIENCE_COUNTRY.test(c))) {
|
|
152
|
+
throw invalidExperiment(name, 'audience.countries must be a list of two-letter country codes in capitals, like ["US", "CA"]');
|
|
153
|
+
}
|
|
154
|
+
audience.countries = [...countries];
|
|
155
|
+
}
|
|
156
|
+
if (platforms !== undefined && platforms !== null) {
|
|
157
|
+
if (!Array.isArray(platforms) ||
|
|
158
|
+
platforms.length === 0 ||
|
|
159
|
+
!platforms.every((p) => EXPERIMENT_AUDIENCE_PLATFORMS.includes(p))) {
|
|
160
|
+
throw invalidExperiment(name, `audience.platforms must be a list of ${EXPERIMENT_AUDIENCE_PLATFORMS.join(', ')}`);
|
|
161
|
+
}
|
|
162
|
+
audience.platforms = [...platforms];
|
|
163
|
+
}
|
|
164
|
+
if (players !== undefined && players !== null) {
|
|
165
|
+
if (typeof players !== 'string' || !EXPERIMENT_AUDIENCE_PLAYERS.includes(players)) {
|
|
166
|
+
throw invalidExperiment(name, `audience.players must be one of ${EXPERIMENT_AUDIENCE_PLAYERS.join(', ')}`);
|
|
167
|
+
}
|
|
168
|
+
audience.players = players;
|
|
169
|
+
}
|
|
170
|
+
return Object.keys(audience).length > 0 ? audience : undefined;
|
|
171
|
+
}
|
|
128
172
|
function invalidExperiment(name, message) {
|
|
129
173
|
return new Error(`experiments.${name} ${message}.`);
|
|
130
174
|
}
|
package/dist/check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import { bundleProject, bundleProjectChunked } from './bundle.js';
|
|
3
|
+
import { bundleProject, bundleProjectChunked, ExternalMedia } from './bundle.js';
|
|
4
4
|
import { isSandboxEnv } from './cloudGit.js';
|
|
5
5
|
import { readCastleJson, resolveBundleChunks, resolveServerConfig, validateExperiments } from './castleJson.js';
|
|
6
6
|
import { importChecksFailedMessage, runImportChecks } from './importCheckHook.js';
|
|
@@ -34,7 +34,10 @@ export async function check(dir, opts = {}) {
|
|
|
34
34
|
console.error('Checking anyway (cloud sandbox).');
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
|
-
|
|
37
|
+
// Media is named by its CDN URL, as save-deck names it: the bundle is
|
|
38
|
+
// thrown away here, and inlining a 30 MB WAV as base64 just to discard it
|
|
39
|
+
// costs a sandbox over a gigabyte. Nothing is uploaded.
|
|
40
|
+
await bundleProject(deckDir, { externalMedia: new ExternalMedia() });
|
|
38
41
|
console.log('Bundle OK.');
|
|
39
42
|
// A deck that publishes chunks (castle.json `bundle.chunks`) is checked the way it saves.
|
|
40
43
|
if (resolveBundleChunks(readCastleJson(deckDir))) {
|
package/dist/devSessionServer.js
CHANGED
|
@@ -9,7 +9,7 @@ import { WebSocketServer, WebSocket } from 'ws';
|
|
|
9
9
|
import { readCastleJson, resolveServerConfig } from './castleJson.js';
|
|
10
10
|
import { OutboundFrameMeter } from './devSessionFrameBudget.js';
|
|
11
11
|
import { SAVE_VERBS } from './devSaveStorage.js';
|
|
12
|
-
import { runDevSave, runDevStorageOperation } from './devSessionStorage.js';
|
|
12
|
+
import { REFUSAL_HOLD_MS, runDevSave, runDevStorageOperation } from './devSessionStorage.js';
|
|
13
13
|
import { rawDataToString } from './rawData.js';
|
|
14
14
|
import { bundleServerModule } from './serverBundle.js';
|
|
15
15
|
import { devDeckCastleJsons, devDeckSessionKey } from './contentPack.js';
|
|
@@ -607,6 +607,9 @@ class DevSessionImpl {
|
|
|
607
607
|
const result = SAVE_VERBS.has(op)
|
|
608
608
|
? runDevSave(this.projectDir, this.sessionId, op, args)
|
|
609
609
|
: await runDevStorageOperation(deckId, op, args, this.connectedPlayers().map((player) => player.userId));
|
|
610
|
+
if (!result.ok && typeof result.error?.heldUntil === 'number') {
|
|
611
|
+
this.log('error', `storage refused: ${result.error.message} (${result.error.code}). Serve answers this deck's storage calls with that refusal for the next ${REFUSAL_HOLD_MS / 60_000} minutes instead of asking the API again.`);
|
|
612
|
+
}
|
|
610
613
|
// The child may have restarted while this was out; its replacement never asked, so
|
|
611
614
|
// there is nobody to tell.
|
|
612
615
|
if (this.platformSocket !== socket)
|
|
@@ -8,6 +8,7 @@ export interface DevStorageResult {
|
|
|
8
8
|
[detail: string]: unknown;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
+
export declare const REFUSAL_HOLD_MS: number;
|
|
11
12
|
/** A session server's save. Its args are what the platform's storage route takes. */
|
|
12
13
|
export declare function runDevSave(projectDir: string, sessionId: string, op: string, args: Record<string, unknown>): DevStorageResult;
|
|
13
14
|
/**
|
|
@@ -4,6 +4,18 @@ import { DevSaveStorage } from './devSaveStorage.js';
|
|
|
4
4
|
// The platform's reply allowance for one storage call: its byte-rate window.
|
|
5
5
|
const SERVER_REPLY_BYTES = 2 * 1024 * 1024;
|
|
6
6
|
const CLIENT_REPLY_BYTES = 512 * 1024;
|
|
7
|
+
// A refusal that won't change while serve runs: the author is not the deck's creator,
|
|
8
|
+
// the deck is gone, its storage is off, or the CLI is signed out. A session server that
|
|
9
|
+
// retries its saves would otherwise ask again forever (one did, against a published
|
|
10
|
+
// deck, at ~40 calls a minute for over a week), so serve answers that deck's later calls
|
|
11
|
+
// itself and asks the API again only once the hold has run out.
|
|
12
|
+
export const REFUSAL_HOLD_MS = 5 * 60 * 1000;
|
|
13
|
+
const NOT_CREATOR = 'only the deck creator can act as its session server';
|
|
14
|
+
// The deck's kill switch. The playthrough rollout gate shares its code but not the
|
|
15
|
+
// deck's other storage, so it is not held.
|
|
16
|
+
const DECK_DISABLED = 'storage is disabled for this deck';
|
|
17
|
+
const DECK_REFUSALS = new Set(['DECK_NOT_FOUND', 'LOGIN_REQUIRED']);
|
|
18
|
+
const refusals = new Map();
|
|
7
19
|
const saveStores = new Map();
|
|
8
20
|
function saveStoreFor(projectDir) {
|
|
9
21
|
let store = saveStores.get(projectDir);
|
|
@@ -460,6 +472,11 @@ export async function runDevStorageOperation(deckId, op, args, connectedUserIds
|
|
|
460
472
|
(typeof args.subject !== 'string' || !connectedUserIds.includes(args.subject))) {
|
|
461
473
|
return failure('CAULDRON_CHARACTER_UNAVAILABLE', 'the target player is not connected to this session');
|
|
462
474
|
}
|
|
475
|
+
const asServer = operation.query.includes('asServer: true');
|
|
476
|
+
const held = refusals.get(deckId);
|
|
477
|
+
if (held && Date.now() < held.until && (asServer || !held.serverOnly)) {
|
|
478
|
+
return { ok: false, error: { ...held.error, held: true } };
|
|
479
|
+
}
|
|
463
480
|
try {
|
|
464
481
|
const variables = op === 'characterEvaluateInformation'
|
|
465
482
|
? {
|
|
@@ -502,15 +519,23 @@ export async function runDevStorageOperation(deckId, op, args, connectedUserIds
|
|
|
502
519
|
const error = response.errors?.[0];
|
|
503
520
|
if (error) {
|
|
504
521
|
const code = error.extensions?.code;
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
code: typeof code === 'string' ? code : 'CAULDRON_STORAGE_UNAVAILABLE',
|
|
510
|
-
message: error.message ?? 'storage request failed',
|
|
511
|
-
},
|
|
522
|
+
const refused = {
|
|
523
|
+
...error.extensions,
|
|
524
|
+
code: typeof code === 'string' ? code : 'CAULDRON_STORAGE_UNAVAILABLE',
|
|
525
|
+
message: error.message ?? 'storage request failed',
|
|
512
526
|
};
|
|
527
|
+
const notCreator = refused.code === 'CAULDRON_STORAGE_FORBIDDEN' && refused.message === NOT_CREATOR;
|
|
528
|
+
const deckDisabled = refused.code === 'CAULDRON_STORAGE_DISABLED' && refused.message === DECK_DISABLED;
|
|
529
|
+
if (notCreator || deckDisabled || DECK_REFUSALS.has(refused.code)) {
|
|
530
|
+
const until = Date.now() + REFUSAL_HOLD_MS;
|
|
531
|
+
refusals.set(deckId, { until, serverOnly: notCreator, error: refused });
|
|
532
|
+
return { ok: false, error: { ...refused, heldUntil: until } };
|
|
533
|
+
}
|
|
534
|
+
return { ok: false, error: refused };
|
|
513
535
|
}
|
|
536
|
+
// A call the hold covered got through, so whatever was refusing it has changed.
|
|
537
|
+
if (held && (asServer || !held.serverOnly))
|
|
538
|
+
refusals.delete(deckId);
|
|
514
539
|
const value = response.data?.[operation.field] ?? null;
|
|
515
540
|
return {
|
|
516
541
|
ok: true,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
// The imports a deck holds, in the order a kit's say should be heard: a kit
|
|
4
|
+
// before every kit it imports. A 3D deck imports castle.physics-2d alongside
|
|
5
|
+
// castle.physics-3d, and physics-3d is built on it, so walking the folder
|
|
6
|
+
// alphabetically let the 2D kit greet a 3D deck with "real 2D physics" and a
|
|
7
|
+
// file it does not have. `preferred` (the entry kit first) breaks ties.
|
|
8
|
+
export function mostSpecificFirst(preferred, importsOf) {
|
|
9
|
+
const remaining = [...preferred];
|
|
10
|
+
const ordered = [];
|
|
11
|
+
while (remaining.length > 0) {
|
|
12
|
+
const next = remaining.find((alias) => !remaining.some((other) => other !== alias && importsOf(other).includes(alias))) ?? remaining[0];
|
|
13
|
+
ordered.push(next);
|
|
14
|
+
remaining.splice(remaining.indexOf(next), 1);
|
|
15
|
+
}
|
|
16
|
+
return ordered;
|
|
17
|
+
}
|
|
18
|
+
// The aliases an imported kit itself declares, read off its castle.json in the
|
|
19
|
+
// deck's imports folder. Unreadable means none.
|
|
20
|
+
export function declaredImports(importDir) {
|
|
21
|
+
try {
|
|
22
|
+
const config = JSON.parse(fs.readFileSync(path.join(importDir, 'castle.json'), 'utf8'));
|
|
23
|
+
const imports = config?.imports;
|
|
24
|
+
return imports && typeof imports === 'object' && !Array.isArray(imports) ? Object.keys(imports) : [];
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
}
|