castle-web-cli 0.4.239 → 0.4.241
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 +163 -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 +6 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +2 -0
- package/dist/platformDoc.js +3 -2
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +1 -0
- package/dist/roomLogs.js +30 -6
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -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 +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- 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/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/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 +481 -57
- 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/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/padCues.js +11 -7
- package/kits/hub-game/code/client/padReadability.js +3 -3
- 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 +72 -51
- 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 +205 -25
- 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 +35 -3
- 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/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 +991 -72
- 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/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 +14 -2
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/standing.js +7 -3
- 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/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 +429 -55
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +956 -101
- 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 +79 -0
- 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 +421 -4
- 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-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 +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- 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-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- 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-pad-cues.mjs +39 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +648 -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 +242 -3
- 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-role-client.mjs +2 -1
- 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-standing.mjs +135 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +36 -1
- 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-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 +68 -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 +340 -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 +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +66 -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 +108 -18
- 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 +417 -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-coaxial-escape.mjs +176 -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 +59 -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",
|
|
@@ -181,10 +186,15 @@ export async function executeCommand(ctx, command, params, capabilities, options
|
|
|
181
186
|
try {
|
|
182
187
|
const data = await dispatchCommand(ctx, command, (params ?? {}), capabilities, options);
|
|
183
188
|
capabilities.hub?.assertActive?.();
|
|
184
|
-
|
|
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);
|
|
185
192
|
return { ok: true, data };
|
|
186
193
|
}
|
|
187
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" } };
|
|
188
198
|
return { ok: false, error: toSerializedError(error, command) };
|
|
189
199
|
}
|
|
190
200
|
}
|
|
@@ -216,6 +226,7 @@ const HUB_VISIT_COMMANDS = new Set([
|
|
|
216
226
|
"hub.friends",
|
|
217
227
|
"hub.invite",
|
|
218
228
|
"hub.canInvite",
|
|
229
|
+
"hub.inviteAvailable",
|
|
219
230
|
"hub.inviteArrival",
|
|
220
231
|
"hub.undoInvite",
|
|
221
232
|
"hub.jump",
|
|
@@ -229,6 +240,15 @@ const HUB_VISIT_COMMANDS = new Set([
|
|
|
229
240
|
function isHubVisitCommand(command) {
|
|
230
241
|
return HUB_VISIT_COMMANDS.has(command);
|
|
231
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
|
+
}
|
|
232
252
|
function runCommand(ctx, command, params, caps, options) {
|
|
233
253
|
if (command === "multiplayer.getSession" && caps.getMultiplayerSession) {
|
|
234
254
|
return caps.getMultiplayerSession(multiplayerSessionRequest(params), ctx);
|
|
@@ -246,6 +266,9 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
246
266
|
? caps.hubSignIn(reason, ctx, options.signal)
|
|
247
267
|
: Promise.resolve({ status: "unavailable" });
|
|
248
268
|
}
|
|
269
|
+
if (command === "hub.pushPermission" || command === "hub.pushDestination") {
|
|
270
|
+
return runHubPushCommand(ctx, command, params, caps, options.signal);
|
|
271
|
+
}
|
|
249
272
|
if (isPlatformCommand(command)) {
|
|
250
273
|
return runPlatformCommand(ctx, command, params, caps);
|
|
251
274
|
}
|
|
@@ -279,6 +302,10 @@ function runCommand(ctx, command, params, caps, options) {
|
|
|
279
302
|
return userGet(params, gql);
|
|
280
303
|
case "experiments.get":
|
|
281
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);
|
|
282
309
|
case "time.getServerTime":
|
|
283
310
|
return timeGetServerTime(gql);
|
|
284
311
|
case "pass.has":
|
|
@@ -422,16 +449,31 @@ async function multiplayerGetSession(ctx, params, caps) {
|
|
|
422
449
|
const mode = request.mode === "public" && ctx.partyId && !hintedSessionId && !inviteHint
|
|
423
450
|
? "party"
|
|
424
451
|
: request.mode;
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
+
}
|
|
433
472
|
return multiplayerSessionResult(data.getCauldronMultiplayerSession);
|
|
434
473
|
}
|
|
474
|
+
function signedOutSoloSession() {
|
|
475
|
+
return { status: "solo", url: null, nonce: null, sessionId: null, soloReason: "unavailable" };
|
|
476
|
+
}
|
|
435
477
|
const MULTIPLAYER_SESSION_ID_MAX_LENGTH = 256;
|
|
436
478
|
function multiplayerHintedSessionId(ctx, deckId) {
|
|
437
479
|
const hint = ctx.joinHint;
|
|
@@ -1356,6 +1398,58 @@ function experimentsGet(ctx) {
|
|
|
1356
1398
|
variants: Object.fromEntries(Object.entries(source).filter((entry) => typeof entry[1] === "string")),
|
|
1357
1399
|
};
|
|
1358
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
|
+
}
|
|
1359
1453
|
// One user's public profile, or null when there is no such user. The photo and
|
|
1360
1454
|
// frame are fetched here and handed over as data: urls, since a deck's CSP
|
|
1361
1455
|
// allows no image host and the host is outside it.
|
|
@@ -3427,6 +3521,30 @@ export function hubGoEnvelope(go) {
|
|
|
3427
3521
|
},
|
|
3428
3522
|
};
|
|
3429
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
|
+
}
|
|
3430
3548
|
// Ghost's source check reads the session's heartbeat roster, which can lag an
|
|
3431
3549
|
// arrival by up to 15 s: a door used in that window answers `forbidden`.
|
|
3432
3550
|
const HUB_ROSTER_LAG_MS = 16_000;
|
|
@@ -3475,6 +3593,9 @@ const CAULDRON_OWNER_GO_MUTATION = CAULDRON_HUB_GO_MUTATION
|
|
|
3475
3593
|
const CAULDRON_HUB_BACK_MUTATION = `mutation CastleHubBack($fromDeckId: ID!, $partyId: ID, $env: String) {
|
|
3476
3594
|
acquireCauldronHubReturn(fromDeckId: $fromDeckId, partyId: $partyId, env: $env) { ${HUB_HANDOFF_FIELDS} }
|
|
3477
3595
|
}`;
|
|
3596
|
+
const CAULDRON_HUB_INVITE_AVAILABLE_QUERY = `query CastleHubInviteAvailable {
|
|
3597
|
+
me { featureGates }
|
|
3598
|
+
}`;
|
|
3478
3599
|
const CAULDRON_HUB_FRIENDS_QUERY = `query CastleHubFriends($deckId: ID!, $sessionId: ID, $env: String) {
|
|
3479
3600
|
cauldronHubFriends(deckId: $deckId, sessionId: $sessionId, env: $env, behindDoors: true) { userId username here door home ownerUserId }
|
|
3480
3601
|
}`;
|
|
@@ -3566,6 +3687,7 @@ export function createGhostHubVisit(options) {
|
|
|
3566
3687
|
? { status: "ok", canInvite: true, userId: String(userId) }
|
|
3567
3688
|
: { status: "ok", canInvite: options.invite === true });
|
|
3568
3689
|
},
|
|
3690
|
+
inviteAvailable: (ctx) => visit.inviteAvailable(ctx),
|
|
3569
3691
|
inviteArrival: (_ctx, signal) => visit.inviteArrival(signal),
|
|
3570
3692
|
undoInvite: (userId) => visit.undoInvite(userId),
|
|
3571
3693
|
inviteJoinHint: (ctx) => {
|
|
@@ -3672,6 +3794,8 @@ class GhostHubVisitImpl {
|
|
|
3672
3794
|
session = null;
|
|
3673
3795
|
sessionAcquisitions = 0;
|
|
3674
3796
|
acceptedSessionAcquisition = 0;
|
|
3797
|
+
// The last acquisition started before the player arrived where they stand.
|
|
3798
|
+
placeFence = 0;
|
|
3675
3799
|
chatSenders = new Map();
|
|
3676
3800
|
chatBlockPending = null;
|
|
3677
3801
|
chatBlockNextAt = 0;
|
|
@@ -3719,14 +3843,16 @@ class GhostHubVisitImpl {
|
|
|
3719
3843
|
// so an earlier join that answers after a later one (ghost placed it in another
|
|
3720
3844
|
// shard) must not replace its session as the door source, or the player stands
|
|
3721
3845
|
// in one session while every door names the other. A later join that failed
|
|
3722
|
-
// 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.
|
|
3723
3849
|
sessionAcquisitionStarted() {
|
|
3724
3850
|
return ++this.sessionAcquisitions;
|
|
3725
3851
|
}
|
|
3726
3852
|
sessionAcquired(sessionId, acquisition) {
|
|
3727
3853
|
this.assertActive();
|
|
3728
3854
|
if (acquisition !== undefined) {
|
|
3729
|
-
if (acquisition < this.acceptedSessionAcquisition)
|
|
3855
|
+
if (acquisition <= this.placeFence || acquisition < this.acceptedSessionAcquisition)
|
|
3730
3856
|
return;
|
|
3731
3857
|
this.acceptedSessionAcquisition = acquisition;
|
|
3732
3858
|
}
|
|
@@ -3756,6 +3882,29 @@ class GhostHubVisitImpl {
|
|
|
3756
3882
|
const raw = Array.isArray(data.cauldronHubFriends) ? data.cauldronHubFriends : [];
|
|
3757
3883
|
return { status: "ok", friends: raw.flatMap(publicHubFriend) };
|
|
3758
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
|
+
}
|
|
3759
3908
|
async invite(crew, signal) {
|
|
3760
3909
|
this.assertActive(signal);
|
|
3761
3910
|
const source = this.session;
|
|
@@ -4139,6 +4288,7 @@ class GhostHubVisitImpl {
|
|
|
4139
4288
|
this.placeKind = trip.classic ? "classic" : "place";
|
|
4140
4289
|
this.arrivalDoorId = trip.arrivalDoorId;
|
|
4141
4290
|
this.chatBlockPending?.abort();
|
|
4291
|
+
this.placeFence = this.sessionAcquisitions;
|
|
4142
4292
|
this.session = trip.sessionId ? { sessionId: trip.sessionId, at: this.now() } : null;
|
|
4143
4293
|
}
|
|
4144
4294
|
changed() {
|
|
@@ -4397,6 +4547,8 @@ function runHubCommand(ctx, command, params, caps, signal) {
|
|
|
4397
4547
|
return hub?.invite ? hub.invite(params.crew === true, ctx, signal) : Promise.resolve({ status: "unavailable" });
|
|
4398
4548
|
case "hub.canInvite":
|
|
4399
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" });
|
|
4400
4552
|
case "hub.inviteArrival":
|
|
4401
4553
|
return hub?.inviteArrival ? hub.inviteArrival(ctx, signal) : Promise.resolve({ status: "unavailable" });
|
|
4402
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
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -106,16 +106,19 @@ async function askTerminal(question) {
|
|
|
106
106
|
terminal.close();
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
// `castle-web reset-leaderboards [dir] [--deck-id ID] [--yes]`.
|
|
109
|
+
// `castle-web reset-leaderboards [dir] [--deck-id ID] [--yes] [--undo]`.
|
|
110
110
|
async function resetLeaderboardsCommand() {
|
|
111
111
|
const deckDir = path.resolve(findPositionalDir());
|
|
112
112
|
await resetLeaderboards({
|
|
113
113
|
deckId: getFlagValue('--deck-id') ?? readCastleJson(deckDir)?.deckId,
|
|
114
114
|
yes: hasFlag('--yes'),
|
|
115
|
+
undo: hasFlag('--undo'),
|
|
115
116
|
}, {
|
|
116
117
|
signedIn: !!config.getToken(),
|
|
117
118
|
deckTitle: async (deckId) => (await api.deckMeta(deckId))?.title ?? null,
|
|
118
|
-
|
|
119
|
+
resetDeckLeaderboards: api.resetCauldronDeckLeaderboards,
|
|
120
|
+
undoDeckLeaderboardsReset: api.undoCauldronDeckLeaderboardsReset,
|
|
121
|
+
clearClassicLeaderboards: api.clearDeckLeaderboards,
|
|
119
122
|
interactive: !!process.stdin.isTTY,
|
|
120
123
|
confirm: askTerminal,
|
|
121
124
|
log: (line) => console.log(line),
|
|
@@ -193,7 +196,7 @@ function usage() {
|
|
|
193
196
|
castle-web source-status <dir> [--adopt] [--notify] [--json] (whether the deck's saved copy is newer than this folder)
|
|
194
197
|
castle-web list-decks [dir] [--kind mine|saved|kits] (decks this one could import; ids are what add-import takes)
|
|
195
198
|
castle-web logs [dir] [--deck ID] [--room ROOM] [--rooms] [--json] [--staging] (a published deck's multiplayer room: state, end reason, exit code, out-of-memory kill and its last server log lines; no --room means the newest room; --rooms lists recent rooms; creator only)
|
|
196
|
-
castle-web reset-leaderboards [dir] [--deck-id ID] [--yes] (clears every leaderboard on the deck,
|
|
199
|
+
castle-web reset-leaderboards [dir] [--deck-id ID] [--yes] [--undo] (clears every leaderboard on the deck, saved data kept; creator only; --undo puts the scores back for a day; --yes skips the prompt)
|
|
197
200
|
castle-web add-import <deckId|url|kit> [dir] [--as ALIAS] (adds another deck, or a kit this CLI ships, as a read-only dependency in imports/)
|
|
198
201
|
castle-web fork-import-file <imports/...> [dir] (this deck's own version of one imported file)
|
|
199
202
|
castle-web revert-import-file <imports/...> [dir]
|
package/dist/init.js
CHANGED
|
@@ -64,7 +64,7 @@ const BARE_SCAFFOLDS = [
|
|
|
64
64
|
// Registry version of castle-web-sdk to inject when scaffolding from a
|
|
65
65
|
// globally-installed castle-web (not from inside the workspace). Bumped
|
|
66
66
|
// alongside cli/sdk version bumps.
|
|
67
|
-
const PUBLISHED_SDK_VERSION = '0.4.
|
|
67
|
+
const PUBLISHED_SDK_VERSION = '0.4.55';
|
|
68
68
|
// Range, not a pin: `castle-web-fonts` is its own package precisely so a tenth
|
|
69
69
|
// face can ship without a cli release, and a caret range means an existing
|
|
70
70
|
// deck's next install picks it up. Nothing here has to move when it does.
|
|
@@ -265,6 +265,28 @@ export function getCliVersion() {
|
|
|
265
265
|
const pkg = readJsonFile(path.join(getKitsDir(), '..', 'package.json'));
|
|
266
266
|
return typeof pkg?.version === 'string' ? pkg.version : '0.0.0';
|
|
267
267
|
}
|
|
268
|
+
// The castle-display the kit's own page declares, as a tag for the deck's page,
|
|
269
|
+
// or '' when it declares none. The host reads the tag from the deck's
|
|
270
|
+
// index.html, never the import's, so a kit that plays full-screen has to hand
|
|
271
|
+
// its declaration on or every deck made from it plays as a card.
|
|
272
|
+
function kitDisplayMeta(projectDir, alias) {
|
|
273
|
+
let html;
|
|
274
|
+
try {
|
|
275
|
+
html = fs.readFileSync(path.join(projectDir, IMPORTS_DIR, alias, 'index.html'), 'utf8');
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return '';
|
|
279
|
+
}
|
|
280
|
+
for (const tag of html.match(/<meta\b[^>]*>/gi) ?? []) {
|
|
281
|
+
if (!/\bname\s*=\s*["']castle-display["']/i.test(tag))
|
|
282
|
+
continue;
|
|
283
|
+
const content = tag.match(/\bcontent\s*=\s*(["'])(.*?)\1/i)?.[2];
|
|
284
|
+
if (!content || /["<>&]/.test(content))
|
|
285
|
+
return '';
|
|
286
|
+
return `\n <meta name="castle-display" content="${content}" />`;
|
|
287
|
+
}
|
|
288
|
+
return '';
|
|
289
|
+
}
|
|
268
290
|
// The deck's entry point is the KIT's -- the deck has no engine code of its own
|
|
269
291
|
// -- so index.html points into the import. Everything the kit's main.jsx imports
|
|
270
292
|
// is relative to itself, so it needs no rewriting to run from there.
|
|
@@ -272,7 +294,7 @@ function writeDeckIndexHtml(projectDir, alias, title, mainFile) {
|
|
|
272
294
|
fs.writeFileSync(path.join(projectDir, 'index.html'), `<!doctype html>
|
|
273
295
|
<html>
|
|
274
296
|
<head>
|
|
275
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"
|
|
297
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />${kitDisplayMeta(projectDir, alias)}
|
|
276
298
|
<meta name="color-scheme" content="dark" />
|
|
277
299
|
<title>${title}</title>
|
|
278
300
|
<!-- Declare the dark scheme before the JS-imported CSS loads, so the frame
|