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
|
@@ -51,6 +51,10 @@ const REACTIONS = {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
const TALK_RANGE_M = 3.5;
|
|
54
|
+
// A Talk prompt offered beside a body that has since walked on stays good
|
|
55
|
+
// this long: the press is checked against where the body stood, so a player
|
|
56
|
+
// who pressed as it set off is answered, not refused as 'far'.
|
|
57
|
+
const OFFER_GRACE_MS = 1500;
|
|
54
58
|
// A speaker who walks this far from the body has left the conversation.
|
|
55
59
|
const LEAVE_RANGE_M = 8;
|
|
56
60
|
const WALK_MPS = 2.6;
|
|
@@ -173,6 +177,8 @@ export function makeNpcs(h) {
|
|
|
173
177
|
followDone: new Set(),
|
|
174
178
|
// { x, z, stopAt, then } while the place has it walking somewhere
|
|
175
179
|
walk: null,
|
|
180
|
+
// [{ t, x, z }] where a moving body stood, for OFFER_GRACE_MS
|
|
181
|
+
trail: [],
|
|
176
182
|
// a one-off facing target while idle
|
|
177
183
|
faceTo: null,
|
|
178
184
|
// admitted turns' times, the per-minute budget's window
|
|
@@ -498,7 +504,10 @@ function say(h, npc, text, { to, ttlMs = SPEECH_MS, about } = {}) {
|
|
|
498
504
|
|
|
499
505
|
function react(h, n, playerId, emote) {
|
|
500
506
|
const aliases = { sleep: 'wave', eat: 'wave', cry: 'wave', laugh: 'cheer', point: 'wave' };
|
|
501
|
-
|
|
507
|
+
// v1.174: a place's yawn is answered with a wave at any idle.emotes place,
|
|
508
|
+
// unless it is an expression place's declared role of that id.
|
|
509
|
+
const placeAlias = emote === 'yawn' && !h.place?.idle?.expression?.roleEmotes?.some((role) => role.id === emote) ? 'wave' : null;
|
|
510
|
+
const reaction = Object.hasOwn(REACTIONS, emote) ? emote : h.place?.idle?.expression && Object.hasOwn(aliases, emote) ? aliases[emote] : placeAlias;
|
|
502
511
|
const player = h.sim?.players.get(playerId);
|
|
503
512
|
const entry = h.players?.get(playerId);
|
|
504
513
|
const now = h.sim?.timeMs ?? 0;
|
|
@@ -573,6 +582,20 @@ function syncHookResult(h, name, result) {
|
|
|
573
582
|
return result;
|
|
574
583
|
}
|
|
575
584
|
|
|
585
|
+
// How far a player's press reaches this body: its distance now when within
|
|
586
|
+
// talk range, else the distance now when the player stood within talk range of
|
|
587
|
+
// where the body was in the last OFFER_GRACE_MS, else null (out of reach).
|
|
588
|
+
function reachOf(h, npc, playerId) {
|
|
589
|
+
const d = distanceTo(h, npc, playerId);
|
|
590
|
+
if (d <= npc.talkRange) {
|
|
591
|
+
return d;
|
|
592
|
+
}
|
|
593
|
+
const player = h.sim?.players.get(playerId)?.at;
|
|
594
|
+
const since = h.sim.timeMs - OFFER_GRACE_MS;
|
|
595
|
+
const offered = player && npc.trail?.some((p) => p.t >= since && Math.hypot(player.x - p.x, player.z - p.z) <= npc.talkRange);
|
|
596
|
+
return offered ? d : null;
|
|
597
|
+
}
|
|
598
|
+
|
|
576
599
|
function distanceTo(h, npc, playerId) {
|
|
577
600
|
if (npc.owner) {
|
|
578
601
|
return 0;
|
|
@@ -621,7 +644,8 @@ function childAsks(h, npc, playerId) {
|
|
|
621
644
|
function open(h, n, playerId, npcId) {
|
|
622
645
|
const npc = h.place.companionChat && typeof npcId === 'string' && npcId.startsWith('companion:')
|
|
623
646
|
? virtualForOpen(h, n, playerId, npcId) : n.bodies.get(npcId);
|
|
624
|
-
|
|
647
|
+
const reach = npc ? reachOf(h, npc, playerId) : null;
|
|
648
|
+
if (reach === null) {
|
|
625
649
|
h.ctx.send(playerId, { k: 'hub-npc', npc: npcId, open: false, why: 'far' });
|
|
626
650
|
return;
|
|
627
651
|
}
|
|
@@ -630,7 +654,9 @@ function open(h, n, playerId, npcId) {
|
|
|
630
654
|
line(h, n, npc, playerId, 'busy');
|
|
631
655
|
return;
|
|
632
656
|
}
|
|
633
|
-
const talking = { playerId, at: h.sim.timeMs, conversation: ++npc.conversation, accountKey: metKey(h, playerId), body: h.sim.players.get(playerId), said: false
|
|
657
|
+
const talking = { playerId, at: h.sim.timeMs, conversation: ++npc.conversation, accountKey: metKey(h, playerId), body: h.sim.players.get(playerId), said: false,
|
|
658
|
+
// Opened inside the grace: turns allow the distance it opened at.
|
|
659
|
+
...(reach > npc.talkRange ? { reach } : {}) };
|
|
634
660
|
let state = speakerState(npc, playerId);
|
|
635
661
|
if (npc.speakers && !state?.talking) {
|
|
636
662
|
// Reopening a closed slot goes to the back, retaining its in-flight turn.
|
|
@@ -654,6 +680,12 @@ function open(h, n, playerId, npcId) {
|
|
|
654
680
|
const taps = mind && under13(h, playerId) && placed?.authored ? placed.asks : null;
|
|
655
681
|
const child = taps ? null : bundled;
|
|
656
682
|
state.taps = taps;
|
|
683
|
+
// v1.175: any other speaker may tap those asks, answered by the place, while
|
|
684
|
+
// their client cannot type to the mind (its inspect pending or refused).
|
|
685
|
+
// v1.153: a child with bundle chips gets the three canned lines instead,
|
|
686
|
+
// which the place answers as it does where there is no mind.
|
|
687
|
+
const fallback = mind && !taps ? placed?.authored ? placed.asks : child ? [...CHILD_ASKS] : null : null;
|
|
688
|
+
state.fallback = fallback;
|
|
657
689
|
// v1.46: a mind speaks first even where the place gives it no words.
|
|
658
690
|
let opening = child
|
|
659
691
|
? { text: `Tap a question to talk with ${npc.name.split(',')[0].trim()}.` }
|
|
@@ -682,6 +714,7 @@ function open(h, n, playerId, npcId) {
|
|
|
682
714
|
hearRange: 0,
|
|
683
715
|
disclosure: 'participants',
|
|
684
716
|
...(child ? { choices: child.map(({ id, label }) => ({ id, label })) } : taps ? { choices: [...taps], authoredChoices: true } : choicesOnly(h, playerId) ? { choices: [...CHILD_ASKS] } : {}),
|
|
717
|
+
...(fallback ? { fallbackChoices: [...fallback] } : {}),
|
|
685
718
|
// A mind's under-13 speaker, by the trusted identity alone and in every
|
|
686
719
|
// place: their own panel may say why typing is off. Only to them.
|
|
687
720
|
...(mind && under13(h, playerId) ? { ageOff: true } : {}),
|
|
@@ -729,6 +762,7 @@ function clearTalk(npc, playerId) {
|
|
|
729
762
|
state.opening = null;
|
|
730
763
|
state.notes = null;
|
|
731
764
|
state.taps = null;
|
|
765
|
+
state.fallback = null;
|
|
732
766
|
}
|
|
733
767
|
|
|
734
768
|
// v1.47: copies of a greeting in the conversation belong to its account/body too.
|
|
@@ -1019,8 +1053,9 @@ function logOperation(why, conversation) {
|
|
|
1019
1053
|
|
|
1020
1054
|
// The place's authored words for this moment (`npcLine`), or the kit's.
|
|
1021
1055
|
function line(h, n, npc, playerId, why, text, op, rid, conversation, fallback = why) {
|
|
1022
|
-
// v1.148: authored taps lead bundle chips, so their answers are said
|
|
1023
|
-
|
|
1056
|
+
// v1.148: authored taps lead bundle chips, so their answers are said, as
|
|
1057
|
+
// are v1.153 fallback taps'.
|
|
1058
|
+
if (childAsks(h, npc, playerId) && !(why === 'authored' && (speakerState(npc, playerId)?.taps || speakerState(npc, playerId)?.fallback))) {return;}
|
|
1024
1059
|
let said = null;
|
|
1025
1060
|
try {
|
|
1026
1061
|
said = h.hooks.npcLine?.(h.ctx, h.ctx.npc(npc.id), playerId, { why, text: text ?? null, ...(conversation !== undefined ? { conversation } : {}) }) ?? null;
|
|
@@ -1076,8 +1111,10 @@ function authoredSay(h, n, playerId, npcId, text, rid) {
|
|
|
1076
1111
|
return;
|
|
1077
1112
|
}
|
|
1078
1113
|
const now = h.sim.timeMs;
|
|
1079
|
-
// v1.148: a mind hears here only its under-13 speaker's authored taps
|
|
1080
|
-
|
|
1114
|
+
// v1.148: a mind hears here only its under-13 speaker's authored taps, and
|
|
1115
|
+
// v1.175 anyone else's fallback taps of that open.
|
|
1116
|
+
const state = hasMind(h, npc) ? speakerState(npc, playerId) : null;
|
|
1117
|
+
const taps = state?.taps ?? state?.fallback ?? null;
|
|
1081
1118
|
if (now - (n.saidAt.get(playerId) ?? -Infinity) < SAY_GAP_MS || (hasMind(h, npc) && !taps?.includes(text.trim()))) {
|
|
1082
1119
|
return;
|
|
1083
1120
|
}
|
|
@@ -1096,7 +1133,10 @@ function authoredSay(h, n, playerId, npcId, text, rid) {
|
|
|
1096
1133
|
metNow(h, n, npc, playerId);
|
|
1097
1134
|
// v1.46: echo only this send's short request id, when its client gave one.
|
|
1098
1135
|
const requestId = typeof rid === 'string' && rid.length <= 64 ? rid : null;
|
|
1099
|
-
line
|
|
1136
|
+
// v1.153: a child's canned line the place does not answer still gets the
|
|
1137
|
+
// kit's refused line, never silence.
|
|
1138
|
+
const child = !state?.taps && state?.fallback && childAsks(h, npc, playerId);
|
|
1139
|
+
line(h, n, npc, playerId, 'authored', text.slice(0, INPUT_MAX), undefined, requestId, talking.conversation, child ? 'refused' : 'authored');
|
|
1100
1140
|
}
|
|
1101
1141
|
|
|
1102
1142
|
// A turn the host granted: the kit admits it only for the player this body is
|
|
@@ -1126,7 +1166,7 @@ async function admitTurn(h, n, turn) {
|
|
|
1126
1166
|
return;
|
|
1127
1167
|
}
|
|
1128
1168
|
const talking = conversationOf(h, npc, speaker);
|
|
1129
|
-
if (!talking || distanceTo(h, npc, speaker) > npc.talkRange + 1) {
|
|
1169
|
+
if (!talking || distanceTo(h, npc, speaker) > Math.max(npc.talkRange, talking.reach ?? 0) + 1) {
|
|
1130
1170
|
turn.reject('HUB_NPC_NOT_TALKING');
|
|
1131
1171
|
return;
|
|
1132
1172
|
}
|
|
@@ -1616,6 +1656,12 @@ function moveBody(h, n, npc, dt) {
|
|
|
1616
1656
|
faceToward(npc, target);
|
|
1617
1657
|
}
|
|
1618
1658
|
if (next) {
|
|
1659
|
+
const p = npc.body.translation();
|
|
1660
|
+
const trail = (npc.trail ??= []);
|
|
1661
|
+
while (trail.length && trail[0].t < now - OFFER_GRACE_MS) {
|
|
1662
|
+
trail.shift();
|
|
1663
|
+
}
|
|
1664
|
+
trail.push({ t: now, x: p.x, z: p.z });
|
|
1619
1665
|
npc.body.setNextKinematicTranslation(next);
|
|
1620
1666
|
}
|
|
1621
1667
|
npc.body.setNextKinematicRotation({ x: 0, y: Math.sin(npc.yaw / 2), z: 0, w: Math.cos(npc.yaw / 2) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Observed progress (contract v1.141, `docs/observed-progress.md
|
|
2
|
-
// kit has seen a player walk, for a door that scores from where players stand.
|
|
1
|
+
// Observed progress (contract v1.141, `docs/observed-progress.md`; v1.165
|
|
2
|
+
// drivers): where the kit has seen a player walk or drive, for a door that scores from where players stand.
|
|
3
3
|
//
|
|
4
4
|
// A connected player's body is a kinematic capsule the server sets from the
|
|
5
5
|
// client's last accepted report, so the body is never evidence on its own.
|
|
@@ -75,14 +75,46 @@ function bodyAt(entry) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// The allowance for one player, m/s: the scene Player's speed times their own
|
|
78
|
-
// `hub.tune` speed, times the tolerance.
|
|
79
|
-
|
|
78
|
+
// `hub.tune` speed, times the tolerance. A driver (v1.165, the vehicle preset)
|
|
79
|
+
// gets their car's instead, `max(speed, reverse)` times the same tolerance:
|
|
80
|
+
// the speed `setPose`'s clamp already follows (`vehicle.js` `clamp`), with
|
|
81
|
+
// `hub.tune` kept for getting out, as the clamp keeps it. A rider is a walker
|
|
82
|
+
// here: the kit places them on their seat every tick, and each placement is a
|
|
83
|
+
// reset, so riding earns nothing.
|
|
84
|
+
export function allowanceOf(h, playerId) {
|
|
85
|
+
const car = h.cars?.get(playerId);
|
|
86
|
+
if (car) {
|
|
87
|
+
return Math.max(car.speed, car.reverse) * TOLERANCE;
|
|
88
|
+
}
|
|
80
89
|
const props = h.actors?.find((a) => a.components?.Player)?.components.Player;
|
|
81
90
|
const base = Number.isFinite(props?.speed) && props.speed > 0 ? props.speed : DEFAULT_SPEED;
|
|
82
91
|
const tuned = h.tunes?.get(playerId)?.speed;
|
|
83
92
|
return base * (Number.isFinite(tuned) && tuned > 0 ? tuned : 1) * TOLERANCE;
|
|
84
93
|
}
|
|
85
94
|
|
|
95
|
+
// v1.165: which driving state a player is in, for the allowance transition:
|
|
96
|
+
// null on foot (or riding), else the car's own allowance numbers. Only a
|
|
97
|
+
// change of this (getting in, getting out, a respray to other numbers) is a
|
|
98
|
+
// transition; a walker's `hub.tune` change is not, and keeps v1.141's rule.
|
|
99
|
+
function driveKey(h, playerId) {
|
|
100
|
+
const car = h.cars?.get(playerId);
|
|
101
|
+
return car ? `${car.speed}:${car.reverse}` : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// v1.165: whether a player rides in someone's car. A rider's pose is the
|
|
105
|
+
// kit's seat placement every tick, which is no evidence of their own
|
|
106
|
+
// movement, so riding never earns (`observe`).
|
|
107
|
+
function riding(h, playerId) {
|
|
108
|
+
for (const car of h.cars?.values() ?? []) {
|
|
109
|
+
for (const rider of Object.values(car.riders ?? {})) {
|
|
110
|
+
if (rider === playerId) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
86
118
|
// --- state -------------------------------------------------------------------
|
|
87
119
|
|
|
88
120
|
// The first call that needs it starts observation: every current body is
|
|
@@ -136,6 +168,8 @@ function resetRecord(h, playerId, entry, at = bodyAt(entry)) {
|
|
|
136
168
|
travel: 0,
|
|
137
169
|
since: h.sim?.timeMs ?? 0,
|
|
138
170
|
speed: allowanceOf(h, playerId),
|
|
171
|
+
// v1.165: the driving state the allowance was last taken in (`driveKey`)
|
|
172
|
+
drive: driveKey(h, playerId),
|
|
139
173
|
// Signed walking credit, metres (`observe`): filled by the allowance,
|
|
140
174
|
// capped, spent by every step taken, and negative while a jump is owed.
|
|
141
175
|
credit: 0,
|
|
@@ -213,13 +247,40 @@ export function pass(h) {
|
|
|
213
247
|
// walking slower than the allowance or by standing, never discarded.
|
|
214
248
|
function observe(h, playerId, rec, at, elapsed) {
|
|
215
249
|
const obs = h.observe;
|
|
216
|
-
|
|
217
|
-
|
|
250
|
+
const speed = allowanceOf(h, playerId);
|
|
251
|
+
// v1.165: a change of driving state since the last pass (getting into a
|
|
252
|
+
// car, getting out, a respray to other numbers) fills this tick's credit at
|
|
253
|
+
// the lower of the two allowances, since either may have been in force for
|
|
254
|
+
// any part of it, and the credit is held to the new cap at once. Nothing is
|
|
255
|
+
// reset: a driver who gets in keeps their stations, and only a getting-out
|
|
256
|
+
// placement resets. A walker's tune change is no transition: its tick
|
|
257
|
+
// fills at the new allowance, as before v1.165.
|
|
258
|
+
const drive = driveKey(h, playerId);
|
|
259
|
+
const fill = drive === rec.drive ? speed : Math.min(speed, rec.speed);
|
|
260
|
+
rec.drive = drive;
|
|
261
|
+
rec.speed = speed;
|
|
262
|
+
rec.credit = Math.min(CREDIT_S * speed + CREDIT_SLACK, rec.credit + fill * elapsed);
|
|
218
263
|
rec.funded = false;
|
|
219
264
|
if (!finitePoint(at) || !inBounds(at)) {
|
|
220
265
|
reject(rec);
|
|
221
266
|
return;
|
|
222
267
|
}
|
|
268
|
+
if (riding(h, playerId)) {
|
|
269
|
+
// A rider (v1.165): the body is where the kit seated it, adopted as the
|
|
270
|
+
// observed position but never funded, so riding earns no travel and
|
|
271
|
+
// enters no station, however slowly the car moves (a seat placement
|
|
272
|
+
// within PLACE_SAME_M is no reset). The credit starts from nothing when
|
|
273
|
+
// they get out, as after any placement.
|
|
274
|
+
if (flat(at, rec.at) > EPS) {
|
|
275
|
+
rec.movedAt = obs.clock;
|
|
276
|
+
}
|
|
277
|
+
rec.at = at;
|
|
278
|
+
rec.ok = true;
|
|
279
|
+
rec.credit = 0;
|
|
280
|
+
rec.step = { x: 0, y: 0, z: 0 };
|
|
281
|
+
clearPairs(rec);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
223
284
|
const d = flat(at, rec.at);
|
|
224
285
|
// Unreachable from where the player last moved at the allowance: rejected,
|
|
225
286
|
// and nothing is spent. Standing still does not renew `movedAt`: a server
|
|
@@ -17,7 +17,14 @@ export function hubPlayers(hub) {
|
|
|
17
17
|
return {
|
|
18
18
|
...Players,
|
|
19
19
|
setPose(sim, playerId, message) {
|
|
20
|
-
if (hub.allowPlayerPose?.(playerId)
|
|
20
|
+
if (hub.allowPlayerPose?.(playerId) === false) {return;}
|
|
21
|
+
// A report from before a `hub.placeAt` reached the client moves nothing
|
|
22
|
+
// (hub.js `stalePose`); the state block it carries is still the client's.
|
|
23
|
+
if (hub.stalePose?.(sim, playerId, readPoint(message?.p)) === true) {
|
|
24
|
+
if (message?.s !== undefined) {Players.setState(sim, playerId, message.s);}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
Players.setPose(sim, playerId, message);
|
|
21
28
|
},
|
|
22
29
|
addPlayer(sim, playerId, pose) {
|
|
23
30
|
const result = Players.addPlayer(sim, playerId, pose);
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Lazy, private, server-authoritative traces. Never a snapshot or actor field.
|
|
2
|
+
import { warnOnce } from './actors.js';
|
|
3
|
+
import { cleanTrace } from '../shared/replay.js';
|
|
4
|
+
|
|
5
|
+
const now = h => h.sim?.timeMs ?? 0;
|
|
6
|
+
function fence(h, id) {
|
|
7
|
+
const p = h.players.get(id), roster = h.session?.players.find(p => p.playerId === id);
|
|
8
|
+
const body = h.sim?.players.get(id);
|
|
9
|
+
if (!p?.hello || !p.arrived || p.ended || !roster || !body || h.replayDeparting?.has(id) || h.resumeDeparting?.has(id) || h.replayClosed) {return null;}
|
|
10
|
+
return { userId: roster.userId ?? null, anonymous: Boolean(roster.isAnonymous), arrival: p.arrivedAt, body };
|
|
11
|
+
}
|
|
12
|
+
function matches(a, b) {
|
|
13
|
+
return a && b && a.userId === b.userId && a.anonymous === b.anonymous && a.arrival === b.arrival && a.body === b.body;
|
|
14
|
+
}
|
|
15
|
+
function refuse(h, reason) {
|
|
16
|
+
warnOnce(h, `replay:${reason}`, `hub replay: ${reason}`);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
function pose(body) {
|
|
20
|
+
const values = [body.at?.x, body.at?.y, body.at?.z];
|
|
21
|
+
if (!values.every(n => Number.isFinite(n) && Math.abs(n * 100) <= 100000) || !Number.isFinite(body.facing)) {return null;}
|
|
22
|
+
const yaw = Math.round((body.facing % (2 * Math.PI)) * 180 / Math.PI);
|
|
23
|
+
return [...values.map(n => Math.round(n * 100) || 0), ((yaw + 540) % 360) - 180];
|
|
24
|
+
}
|
|
25
|
+
function decimate(r) {
|
|
26
|
+
if (r.poses.length < 768) {return;}
|
|
27
|
+
r.poses = r.poses.filter((_, i) => Math.floor(i / 4) % 2 === 0);
|
|
28
|
+
r.step = Math.min(8000, r.step * 2);
|
|
29
|
+
}
|
|
30
|
+
export function record(h, id, op) {
|
|
31
|
+
if (op === 'cancel') {h.recordings?.delete(id); return true;}
|
|
32
|
+
if (op === 'stop') {
|
|
33
|
+
const r = h.recordings?.get(id);
|
|
34
|
+
h.recordings?.delete(id);
|
|
35
|
+
if (!r || !matches(r.fence, fence(h, id))) {return null;}
|
|
36
|
+
const elapsed = now(h) - r.start, ms = Math.round(elapsed), p = pose(r.fence.body);
|
|
37
|
+
if (!p || ms <= 0 || elapsed > 600000) {return null;}
|
|
38
|
+
if (ms === r.last) {r.poses.splice(-4, 4, ...p);}
|
|
39
|
+
else {decimate(r); r.poses.push(...p);}
|
|
40
|
+
return cleanTrace({ v: 1, step: r.step, ms, poses: r.poses });
|
|
41
|
+
}
|
|
42
|
+
if (op !== 'start') {return refuse(h, 'record expects start, stop or cancel');}
|
|
43
|
+
// Replacing a recording also discards it when the new start is refused.
|
|
44
|
+
h.recordings?.delete(id);
|
|
45
|
+
const owner = fence(h, id), p = owner && pose(owner.body);
|
|
46
|
+
if (!owner || !p || (h.recordings?.size ?? 0) >= 8) {return refuse(h, 'record requires a connected arrived body (at most eight)');}
|
|
47
|
+
(h.recordings ??= new Map()).set(id, { fence: owner, start: now(h), step: 250, last: 0, poses: p });
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
export function cleanReplay(h, spec) {
|
|
51
|
+
if (!spec || typeof spec !== 'object' || Array.isArray(spec) || Object.keys(spec).some(k => !['trace', 'look', 'label', 'color', 'offsetMs'].includes(k))) {return null;}
|
|
52
|
+
const trace = cleanTrace(spec.trace);
|
|
53
|
+
if (!trace) {return null;}
|
|
54
|
+
const out = { trace };
|
|
55
|
+
if (spec.look !== undefined) {
|
|
56
|
+
if (typeof spec.look !== 'string' || !h.actors.some(a => a.id === spec.look && a.components?.Model)) {return null;}
|
|
57
|
+
out.look = spec.look;
|
|
58
|
+
}
|
|
59
|
+
if (spec.label !== undefined) {
|
|
60
|
+
if (typeof spec.label !== 'string' || /[\p{Cc}\u2028\u2029]/u.test(spec.label)) {return null;}
|
|
61
|
+
out.label = spec.label.trim();
|
|
62
|
+
if (!out.label || [...out.label].length > 24) {return null;}
|
|
63
|
+
}
|
|
64
|
+
if (spec.color !== undefined) {
|
|
65
|
+
if (typeof spec.color !== 'string' || !/^#[0-9a-f]{6}$/i.test(spec.color)) {return null;}
|
|
66
|
+
out.color = spec.color.toLowerCase();
|
|
67
|
+
}
|
|
68
|
+
if (spec.offsetMs !== undefined) {
|
|
69
|
+
if (!Number.isSafeInteger(spec.offsetMs) || spec.offsetMs < 0 || spec.offsetMs > trace.ms) {return null;}
|
|
70
|
+
out.offsetMs = spec.offsetMs;
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
export function replay(h, id, slot, spec) {
|
|
75
|
+
const owner = fence(h, id);
|
|
76
|
+
if (!owner || (slot !== 0 && slot !== 1)) {return refuse(h, 'replay requires a present viewer and slot 0 or 1');}
|
|
77
|
+
const clean = spec === null ? null : cleanReplay(h, spec);
|
|
78
|
+
if (spec !== null && !clean) {return refuse(h, 'invalid replay spec');}
|
|
79
|
+
const time = now(h);
|
|
80
|
+
// Clearing is never budgeted, and an empty slot has nothing to clear.
|
|
81
|
+
if (!clean && !h.replays?.get(id)?.has(slot)) {return true;}
|
|
82
|
+
if (clean) {
|
|
83
|
+
const recent = (h.replayRates?.get(id) ?? []).filter(t => time - t < 1000);
|
|
84
|
+
if (recent.length >= 4) {return refuse(h, 'at most four replay calls per viewer per second');}
|
|
85
|
+
(h.replayRates ??= new Map()).set(id, [...recent, time]);
|
|
86
|
+
}
|
|
87
|
+
if (clean) {
|
|
88
|
+
h.replays ??= new Map();
|
|
89
|
+
if (!h.replays.has(id)) {h.replays.set(id, new Map());}
|
|
90
|
+
h.replays.get(id).set(slot, { fence: owner, until: time + clean.trace.ms - (clean.offsetMs ?? 0) + 3000 });
|
|
91
|
+
} else {
|
|
92
|
+
h.replays?.get(id)?.delete(slot);
|
|
93
|
+
if (h.replays?.get(id)?.size === 0) {h.replays.delete(id);}
|
|
94
|
+
}
|
|
95
|
+
h.session.send(id, { k: 'hub-replay', slot, replay: clean });
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
// Lifecycle clears bypass the call budget. No retained RESEND state exists.
|
|
99
|
+
export function forget(h, id) {
|
|
100
|
+
h.recordings?.delete(id);
|
|
101
|
+
for (const slot of h.replays?.get(id)?.keys() ?? []) {
|
|
102
|
+
if (h.session?.players.some(p => p.playerId === id)) {h.session.send(id, { k: 'hub-replay', slot, replay: null });}
|
|
103
|
+
}
|
|
104
|
+
h.replays?.delete(id);
|
|
105
|
+
h.replayRates?.delete(id);
|
|
106
|
+
}
|
|
107
|
+
export function tick(h) {
|
|
108
|
+
for (const [id, r] of h.recordings ?? []) {
|
|
109
|
+
const owner = fence(h, id), elapsed = now(h) - r.start;
|
|
110
|
+
if (!matches(r.fence, owner) || elapsed > 600000 || !pose(owner.body)) {h.recordings.delete(id); continue;}
|
|
111
|
+
// Sample only authoritative state on a kit tick, on the current grid.
|
|
112
|
+
while (elapsed >= r.poses.length / 4 * r.step) {
|
|
113
|
+
decimate(r);
|
|
114
|
+
if (elapsed < r.poses.length / 4 * r.step) {break;}
|
|
115
|
+
r.last = r.poses.length / 4 * r.step;
|
|
116
|
+
r.poses.push(...pose(owner.body));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const [id, slots] of h.replays ?? []) {
|
|
120
|
+
for (const [slot, entry] of slots) {
|
|
121
|
+
if (!matches(entry.fence, fence(h, id)) || now(h) > entry.until) {
|
|
122
|
+
if (h.session?.players.some(p => p.playerId === id)) {h.session.send(id, { k: 'hub-replay', slot, replay: null });}
|
|
123
|
+
slots.delete(slot);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!slots.size) {h.replays.delete(id);}
|
|
127
|
+
}
|
|
128
|
+
for (const [id, calls] of h.replayRates ?? []) {
|
|
129
|
+
if (!fence(h, id) || calls.every(t => now(h) - t >= 1000)) {h.replayRates.delete(id);}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function end(h) {
|
|
133
|
+
for (const id of new Set([...(h.recordings?.keys() ?? []), ...(h.replays?.keys() ?? [])])) {forget(h, id);}
|
|
134
|
+
h.replayRates?.clear();
|
|
135
|
+
}
|
|
@@ -18,7 +18,10 @@ const LIMITED = new Set(['storage', 'hub', 'characters', 'world']);
|
|
|
18
18
|
// held across it could wait on the queue it is holding.
|
|
19
19
|
const PASS = new Set(['track', 'catchUp']);
|
|
20
20
|
// A save bucket's verbs are plain functions returning the save API's promise.
|
|
21
|
-
|
|
21
|
+
// The root's gated verbs and reset-generation read (v1.185 `hub.wallet`) are
|
|
22
|
+
// requests too, however a host builds them; a refused one was not forwarded,
|
|
23
|
+
// so sending the identical request again is safe.
|
|
24
|
+
const SAVE_VERBS = new Set(['snapshot', 'transaction', 'claim', 'initialize', 'operation', 'conditionalWrite', 'recentOperations', 'resetGeneration']);
|
|
22
25
|
// The SDK splits writes into requests sent one after another past 32 keys or a
|
|
23
26
|
// 316 KiB frame; a retry replays only a write that fits one request (a read may
|
|
24
27
|
// always be read again).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// The Town's day, contract v1.200 (§14). The Town turns its day at midnight in
|
|
2
|
+
// America/Los_Angeles (hub-town daily.js); a game that asks the hub for its day
|
|
3
|
+
// turns with it instead of at 00:00 UTC. A day is the LA calendar date counted in
|
|
4
|
+
// days since 1970-01-01, the same scale as Math.floor(ms / 86400000), so a game's
|
|
5
|
+
// weekday and week arithmetic over day numbers is unchanged. No host calls.
|
|
6
|
+
|
|
7
|
+
export const TOWN_TIME_ZONE = 'America/Los_Angeles';
|
|
8
|
+
const DAY_MS = 86400000;
|
|
9
|
+
|
|
10
|
+
let parts = null;
|
|
11
|
+
function formatter() {
|
|
12
|
+
if (parts === null) {
|
|
13
|
+
try {
|
|
14
|
+
parts = new Intl.DateTimeFormat('en-US', {
|
|
15
|
+
timeZone: TOWN_TIME_ZONE, hourCycle: 'h23', era: 'short',
|
|
16
|
+
year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric',
|
|
17
|
+
});
|
|
18
|
+
} catch {
|
|
19
|
+
// No zone data: the Town's daily.js falls back to the UTC date, and so do we.
|
|
20
|
+
parts = false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return parts;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// The LA wall clock at `ms`, as if it were UTC; NaN past the Date range. Built
|
|
27
|
+
// with setUTCFullYear, which, unlike Date.UTC, keeps years 0-99 and BC years.
|
|
28
|
+
function wall(ms) {
|
|
29
|
+
const f = formatter();
|
|
30
|
+
if (!f) { return ms; }
|
|
31
|
+
const o = {};
|
|
32
|
+
try {
|
|
33
|
+
for (const { type, value } of f.formatToParts(new Date(ms))) { o[type] = type === 'era' ? value : Number(value); }
|
|
34
|
+
} catch {
|
|
35
|
+
return NaN;
|
|
36
|
+
}
|
|
37
|
+
const at = new Date(0);
|
|
38
|
+
at.setUTCFullYear(o.era === 'BC' ? 1 - o.year : o.year, o.month - 1, o.day);
|
|
39
|
+
at.setUTCHours(o.hour, o.minute, o.second, ((ms % 1000) + 1000) % 1000);
|
|
40
|
+
return at.getTime();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function nowOf(nowMs) {
|
|
44
|
+
return nowMs === undefined ? Date.now() : nowMs;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The Town's day number at `nowMs` (default now); NaN for a time that is not a
|
|
48
|
+
// finite number of milliseconds or whose LA date is outside the Date range.
|
|
49
|
+
export function townDay(nowMs) {
|
|
50
|
+
const ms = nowOf(nowMs);
|
|
51
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms) || Math.abs(ms) > 8.64e15) { return NaN; }
|
|
52
|
+
return Math.floor(wall(ms) / DAY_MS);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The epoch milliseconds at which the Town's day `day` begins (its LA midnight);
|
|
56
|
+
// NaN for a day that is not an integer or whose midnight is outside the Date range.
|
|
57
|
+
export function townDayStart(day) {
|
|
58
|
+
if (!Number.isSafeInteger(day) || Math.abs(day) >= 1e8) { return NaN; }
|
|
59
|
+
let at = day * DAY_MS;
|
|
60
|
+
// Two passes settle the zone's offset; DST changes at 02:00, so midnight
|
|
61
|
+
// always exists and is unique.
|
|
62
|
+
for (let i = 0; i < 2; i++) { at = day * DAY_MS - (wall(at) - at); }
|
|
63
|
+
return at;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// A stored day number read on the day the game switches from the UTC day to
|
|
67
|
+
// the Town's: a day after today (a UTC day that already turned) is today, so a
|
|
68
|
+
// streak or daily neither breaks nor counts twice. Days already on the Town's
|
|
69
|
+
// day are never after today, so the conversion is safe to apply on every read.
|
|
70
|
+
export function townDayFrom(stored, nowMs) {
|
|
71
|
+
if (!Number.isSafeInteger(stored)) { return stored; }
|
|
72
|
+
const today = townDay(nowMs);
|
|
73
|
+
return Number.isNaN(today) ? stored : Math.min(stored, today);
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The cauldron host refuses a hubTrack while two are in flight per session, and
|
|
2
|
+
// a refused row is lost. Every server row goes through here: two in flight per
|
|
3
|
+
// session, the rest wait in order, and past the bound a row is refused at once
|
|
4
|
+
// so a runaway deck cannot grow memory.
|
|
5
|
+
export const TRACK_IN_FLIGHT = 2;
|
|
6
|
+
export const TRACK_QUEUE_MAX = 256;
|
|
7
|
+
const queues = new WeakMap();
|
|
8
|
+
// Whether the row was sent or queued; false when the host has no track.
|
|
9
|
+
export function send(session, playerId, event) {
|
|
10
|
+
if (typeof session?.hub?.track !== 'function') {return false;}
|
|
11
|
+
let q = queues.get(session);
|
|
12
|
+
if (!q) {queues.set(session, q = { inFlight: 0, waiting: [] });}
|
|
13
|
+
if (q.inFlight < TRACK_IN_FLIGHT) {return start(session, q, playerId, event);}
|
|
14
|
+
if (q.waiting.length >= TRACK_QUEUE_MAX) {return false;}
|
|
15
|
+
q.waiting.push([playerId, event]);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
function start(session, q, playerId, event) {
|
|
19
|
+
let pending;
|
|
20
|
+
try { pending = session.hub.track(playerId, event); } catch { return false; }
|
|
21
|
+
if (typeof pending?.then !== 'function') {return pending !== undefined && pending !== false;}
|
|
22
|
+
q.inFlight += 1;
|
|
23
|
+
const done = () => {
|
|
24
|
+
q.inFlight -= 1;
|
|
25
|
+
while (q.inFlight < TRACK_IN_FLIGHT && q.waiting.length > 0) {start(session, q, ...q.waiting.shift());}
|
|
26
|
+
};
|
|
27
|
+
pending.then(done, done);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Car ownership and passenger holds, contract v1.160. No actor or pose stream.
|
|
2
2
|
import { stilled } from './grab.js';
|
|
3
|
+
import { disguised } from './disguise.js';
|
|
3
4
|
import { BOUNDS, warnOnce } from './actors.js';
|
|
4
5
|
import { MAX_CARS, parseCar, seatPose } from '../shared/car.js';
|
|
5
6
|
|
|
@@ -50,6 +51,7 @@ export function ride(h, id, driver, seat, placeAt) {
|
|
|
50
51
|
return true;
|
|
51
52
|
}
|
|
52
53
|
const car = h.cars?.get(driver), body = h.sim?.players.get(id), pose = poseOf(h, driver);
|
|
54
|
+
if (disguised(h, id)) {return refuse(h, 'ride requires a player without a disguise');}
|
|
53
55
|
if (!present(h, id) || !present(h, driver) || !car || !Number.isInteger(seat) || seat < 1 || seat >= car.seats.length || car.riders[seat] || h.held.has(id) || vehicle(h, id) || !pose || Math.hypot(body.at.x - pose.at.x, body.at.y - pose.at.y, body.at.z - pose.at.z) > 6) {
|
|
54
56
|
return refuse(h, 'ride requires a free seat, an unheld walker and a present driver within 6 m');
|
|
55
57
|
}
|
|
@@ -81,6 +83,7 @@ export function drive(h, id, spec, at, placeAt) {
|
|
|
81
83
|
if (hold && body) {hold.at = { ...body.at }; hold.facing = body.facing;}
|
|
82
84
|
return true;
|
|
83
85
|
}
|
|
86
|
+
if (disguised(h, id)) {return refuse(h, 'drive requires a player without a disguise');}
|
|
84
87
|
const car = parseCar(spec), old = h.cars?.get(id);
|
|
85
88
|
if (!present(h, id) || h.held.has(id) || riding(h, id)) {return refuse(h, 'drive requires an arrived unheld player outside a trip');}
|
|
86
89
|
if (!car || !h.actors.some(a => a.id === car.look && a.components?.Model)) {return refuse(h, 'car requires a scene Model look and a valid spec');}
|
|
@@ -29,6 +29,9 @@ export function heldAway(h, playerId) {
|
|
|
29
29
|
}
|
|
30
30
|
const holds = (h, id) => connected(h, id) || retainedAway(h, id) || heldAway(h, id);
|
|
31
31
|
|
|
32
|
+
// v1.184: a viewer's override is `true` (hidden), `false` (shown) or
|
|
33
|
+
// `'solid'` (hidden, but its collider stays where it is on that viewer's
|
|
34
|
+
// client). Every server reader treats `'solid'` as hidden.
|
|
32
35
|
export function set(h, actorId, options, hidden) {
|
|
33
36
|
const op = hidden ? 'hide' : 'show';
|
|
34
37
|
if (!isActor(h, actorId)) {
|
|
@@ -37,12 +40,18 @@ export function set(h, actorId, options, hidden) {
|
|
|
37
40
|
}
|
|
38
41
|
let targets;
|
|
39
42
|
let clear;
|
|
43
|
+
let solid;
|
|
40
44
|
try {
|
|
41
45
|
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
42
46
|
throw Error('invalid options');
|
|
43
47
|
}
|
|
44
|
-
const { to, clear: drop } = options;
|
|
45
|
-
if (!Array.isArray(to) || (drop !== undefined && typeof drop !== 'boolean')
|
|
48
|
+
const { to, clear: drop, solid: keep } = options;
|
|
49
|
+
if (!Array.isArray(to) || (drop !== undefined && typeof drop !== 'boolean') ||
|
|
50
|
+
(keep !== undefined && typeof keep !== 'boolean')) {
|
|
51
|
+
throw Error('invalid options');
|
|
52
|
+
}
|
|
53
|
+
// `solid` only describes a hide: show refuses `solid: true`.
|
|
54
|
+
if (keep === true && !hidden) {
|
|
46
55
|
throw Error('invalid options');
|
|
47
56
|
}
|
|
48
57
|
const ids = [...to];
|
|
@@ -51,8 +60,11 @@ export function set(h, actorId, options, hidden) {
|
|
|
51
60
|
}
|
|
52
61
|
targets = [...new Set(ids)].filter((id) => connected(h, id) || heldAway(h, id));
|
|
53
62
|
clear = drop === true;
|
|
63
|
+
solid = keep === true;
|
|
54
64
|
} catch {
|
|
55
|
-
warnOnce(h, `vis:${op}:options`,
|
|
65
|
+
warnOnce(h, `vis:${op}:options`, hidden
|
|
66
|
+
? 'hub.hide: visibility options need { to: [playerIds], clear?: boolean, solid?: boolean }'
|
|
67
|
+
: 'hub.show: visibility options need { to: [playerIds], clear?: boolean }');
|
|
56
68
|
return false;
|
|
57
69
|
}
|
|
58
70
|
// Preflight every viewer so a refused call changes nothing, even when one
|
|
@@ -76,7 +88,8 @@ export function set(h, actorId, options, hidden) {
|
|
|
76
88
|
if (!h.visMe.has(id)) {
|
|
77
89
|
h.visMe.set(id, new Map());
|
|
78
90
|
}
|
|
79
|
-
|
|
91
|
+
// Clearing drops the override whole, solid or not.
|
|
92
|
+
h.visMe.get(id).set(actorId, solid ? 'solid' : hidden);
|
|
80
93
|
}
|
|
81
94
|
}
|
|
82
95
|
return true;
|
|
@@ -86,11 +99,20 @@ function sendOne(h, playerId, fresh = false) {
|
|
|
86
99
|
const mine = h.visMe?.get(playerId);
|
|
87
100
|
const hide = [];
|
|
88
101
|
const show = [];
|
|
102
|
+
const solid = [];
|
|
89
103
|
for (const [id, hidden] of mine ?? []) {
|
|
90
104
|
(hidden ? hide : show).push(id);
|
|
105
|
+
if (hidden === 'solid') {
|
|
106
|
+
solid.push(id);
|
|
107
|
+
}
|
|
91
108
|
}
|
|
92
109
|
// Canonical ordering avoids messages when only insertion order changed.
|
|
93
110
|
const out = { k: 'hub-vis', hide: hide.sort(), show: show.sort() };
|
|
111
|
+
// v1.184: named only when used, so a place that never passes solid sends
|
|
112
|
+
// the same bytes as before.
|
|
113
|
+
if (solid.length > 0) {
|
|
114
|
+
out.solid = solid.sort();
|
|
115
|
+
}
|
|
94
116
|
const json = JSON.stringify(out);
|
|
95
117
|
const last = h.sentVisMe?.get(playerId);
|
|
96
118
|
if ((fresh && mine?.size) || (last !== json && (mine?.size || last))) {
|