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.
Files changed (404) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +218 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +22 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +9 -0
  19. package/dist/platformDoc.js +4 -2
  20. package/dist/playPagePolicy.d.ts +1 -0
  21. package/dist/playPagePolicy.js +12 -3
  22. package/dist/resetLeaderboards.d.ts +8 -1
  23. package/dist/resetLeaderboards.js +43 -8
  24. package/dist/roomLogs.d.ts +39 -0
  25. package/dist/roomLogs.js +166 -0
  26. package/dist/save-deck.d.ts +32 -2
  27. package/dist/save-deck.js +240 -39
  28. package/kits/base/CLAUDE.md +2 -1
  29. package/kits/base/castle.json +1 -1
  30. package/kits/base/sdk/README.md +240 -8
  31. package/kits/base/sdk/analytics.d.ts +8 -0
  32. package/kits/base/sdk/analytics.js +92 -0
  33. package/kits/base/sdk/castle.d.ts +8 -2
  34. package/kits/base/sdk/castle.js +3 -0
  35. package/kits/base/sdk/commands.d.ts +79 -0
  36. package/kits/base/sdk/commands.js +1 -0
  37. package/kits/base/sdk/debugConsole.d.ts +17 -0
  38. package/kits/base/sdk/debugConsole.js +154 -0
  39. package/kits/base/sdk/experiments.js +24 -1
  40. package/kits/base/sdk/hostRetry.d.ts +7 -0
  41. package/kits/base/sdk/hostRetry.js +57 -0
  42. package/kits/base/sdk/hub.d.ts +20 -2
  43. package/kits/base/sdk/hub.js +99 -13
  44. package/kits/base/sdk/multiplayer.d.ts +2 -0
  45. package/kits/base/sdk/multiplayer.js +198 -26
  46. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  47. package/kits/base/sdk/reconnectBudget.js +41 -1
  48. package/kits/base/sdk/rooms.d.ts +11 -0
  49. package/kits/base/sdk/rooms.js +22 -0
  50. package/kits/base/sdk/runtime.js +36 -19
  51. package/kits/base/sdk/server/hub.d.ts +19 -0
  52. package/kits/base/sdk/server/hub.js +12 -0
  53. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  54. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  55. package/kits/base/sdk/server/wrapper.js +26 -1
  56. package/kits/base/sdk/store.d.ts +8 -2
  57. package/kits/base/sdk/store.js +5 -1
  58. package/kits/base/sdk/transport.d.ts +2 -1
  59. package/kits/base/sdk/transport.js +35 -0
  60. package/kits/hub-game/CLAUDE.md +66 -19
  61. package/kits/hub-game/castle.json +4 -4
  62. package/kits/hub-game/code/client/act.js +9 -6
  63. package/kits/hub-game/code/client/actCore.js +26 -6
  64. package/kits/hub-game/code/client/actGateLog.js +36 -0
  65. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  66. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  67. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  68. package/kits/hub-game/code/client/askSurface.js +85 -0
  69. package/kits/hub-game/code/client/askTree.js +51 -0
  70. package/kits/hub-game/code/client/attention.js +31 -6
  71. package/kits/hub-game/code/client/ballot.js +42 -5
  72. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  73. package/kits/hub-game/code/client/ballotTree.js +180 -0
  74. package/kits/hub-game/code/client/catchingUp.js +19 -0
  75. package/kits/hub-game/code/client/celebrate.js +66 -0
  76. package/kits/hub-game/code/client/chrome.js +474 -53
  77. package/kits/hub-game/code/client/companion.js +93 -23
  78. package/kits/hub-game/code/client/companionDress.js +1 -1
  79. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  80. package/kits/hub-game/code/client/cornerTree.js +83 -0
  81. package/kits/hub-game/code/client/decor.js +20 -11
  82. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  83. package/kits/hub-game/code/client/disguise.js +23 -0
  84. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  85. package/kits/hub-game/code/client/dockSurface.js +206 -0
  86. package/kits/hub-game/code/client/dockTree.js +232 -0
  87. package/kits/hub-game/code/client/earned.js +29 -0
  88. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  89. package/kits/hub-game/code/client/emoteTree.js +264 -0
  90. package/kits/hub-game/code/client/farAvatars.js +4 -3
  91. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  92. package/kits/hub-game/code/client/grab.js +121 -50
  93. package/kits/hub-game/code/client/holdShow.js +19 -0
  94. package/kits/hub-game/code/client/hookLayer.js +96 -12
  95. package/kits/hub-game/code/client/hubControls.js +7 -1
  96. package/kits/hub-game/code/client/hudSurface.js +11 -3
  97. package/kits/hub-game/code/client/hudTree.js +7 -4
  98. package/kits/hub-game/code/client/idle.js +21 -3
  99. package/kits/hub-game/code/client/invites.js +24 -3
  100. package/kits/hub-game/code/client/keys.js +15 -0
  101. package/kits/hub-game/code/client/labelsNear.js +8 -1
  102. package/kits/hub-game/code/client/layoutCache.js +57 -8
  103. package/kits/hub-game/code/client/loadingCover.js +53 -4
  104. package/kits/hub-game/code/client/menuIcons.js +15 -0
  105. package/kits/hub-game/code/client/menuRows.js +8 -2
  106. package/kits/hub-game/code/client/menuSurface.js +102 -0
  107. package/kits/hub-game/code/client/menuTree.js +135 -0
  108. package/kits/hub-game/code/client/modelLook.js +41 -0
  109. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  110. package/kits/hub-game/code/client/pickerTree.js +163 -0
  111. package/kits/hub-game/code/client/pushVisit.js +4 -2
  112. package/kits/hub-game/code/client/quality.js +188 -29
  113. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  114. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  115. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  116. package/kits/hub-game/code/client/rehello.js +75 -0
  117. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  118. package/kits/hub-game/code/client/replay.js +118 -0
  119. package/kits/hub-game/code/client/role.js +3 -0
  120. package/kits/hub-game/code/client/safeLayout.js +441 -56
  121. package/kits/hub-game/code/client/safeStyle.js +13 -10
  122. package/kits/hub-game/code/client/say.js +2 -0
  123. package/kits/hub-game/code/client/soundSurface.js +77 -0
  124. package/kits/hub-game/code/client/soundTree.js +74 -0
  125. package/kits/hub-game/code/client/soundscape.js +12 -9
  126. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  127. package/kits/hub-game/code/client/state.js +67 -1
  128. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  129. package/kits/hub-game/code/client/stuckTree.js +67 -0
  130. package/kits/hub-game/code/client/talk.js +42 -12
  131. package/kits/hub-game/code/client/talkTree.js +4 -2
  132. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  133. package/kits/hub-game/code/client/textAskTree.js +67 -0
  134. package/kits/hub-game/code/client/tiers.js +252 -27
  135. package/kits/hub-game/code/client/together.js +4 -1
  136. package/kits/hub-game/code/client/uiDom.js +86 -8
  137. package/kits/hub-game/code/client/uiTree.js +33 -4
  138. package/kits/hub-game/code/client/vehicle.js +75 -52
  139. package/kits/hub-game/code/client/weakestTier.js +75 -31
  140. package/kits/hub-game/code/client/wear.js +159 -5
  141. package/kits/hub-game/code/client/worldLabels.js +215 -26
  142. package/kits/hub-game/code/companionSpec.js +4 -2
  143. package/kits/hub-game/code/server/act.js +3 -0
  144. package/kits/hub-game/code/server/actGate.js +83 -0
  145. package/kits/hub-game/code/server/actions.js +71 -15
  146. package/kits/hub-game/code/server/actors.js +20 -5
  147. package/kits/hub-game/code/server/analytics.js +40 -15
  148. package/kits/hub-game/code/server/ask.js +39 -3
  149. package/kits/hub-game/code/server/ballot.js +167 -4
  150. package/kits/hub-game/code/server/celebrate.js +64 -0
  151. package/kits/hub-game/code/server/companion.js +17 -2
  152. package/kits/hub-game/code/server/decor.js +11 -2
  153. package/kits/hub-game/code/server/disguise.js +63 -0
  154. package/kits/hub-game/code/server/doorAnalytics.js +2 -5
  155. package/kits/hub-game/code/server/earned.js +6 -2
  156. package/kits/hub-game/code/server/friendBests.js +13 -4
  157. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  158. package/kits/hub-game/code/server/grab.js +12 -2
  159. package/kits/hub-game/code/server/heldOffers.js +142 -0
  160. package/kits/hub-game/code/server/holdShow.js +98 -0
  161. package/kits/hub-game/code/server/hub.js +854 -45
  162. package/kits/hub-game/code/server/idle.js +110 -9
  163. package/kits/hub-game/code/server/index.js +9 -0
  164. package/kits/hub-game/code/server/labels.js +13 -3
  165. package/kits/hub-game/code/server/loadAbandon.js +2 -5
  166. package/kits/hub-game/code/server/manifest.js +94 -6
  167. package/kits/hub-game/code/server/menu.js +26 -3
  168. package/kits/hub-game/code/server/npcs.js +55 -9
  169. package/kits/hub-game/code/server/observe.js +67 -6
  170. package/kits/hub-game/code/server/players.js +8 -1
  171. package/kits/hub-game/code/server/replay.js +135 -0
  172. package/kits/hub-game/code/server/storageLimit.js +4 -1
  173. package/kits/hub-game/code/server/townDay.js +74 -0
  174. package/kits/hub-game/code/server/trackQueue.js +29 -0
  175. package/kits/hub-game/code/server/vehicle.js +3 -0
  176. package/kits/hub-game/code/server/vis.js +26 -4
  177. package/kits/hub-game/code/server/wallet.js +677 -0
  178. package/kits/hub-game/code/server/wear.js +13 -3
  179. package/kits/hub-game/code/server/writerLease.js +191 -0
  180. package/kits/hub-game/code/shared/act.js +1 -1
  181. package/kits/hub-game/code/shared/expression.js +6 -0
  182. package/kits/hub-game/code/shared/replay.js +37 -0
  183. package/kits/hub-game/code/systems/hub.js +437 -57
  184. package/kits/hub-game/docs/analytics.md +20 -3
  185. package/kits/hub-game/docs/contract.md +942 -99
  186. package/kits/hub-game/docs/home-pieces.md +5 -6
  187. package/kits/hub-game/docs/observed-progress.md +49 -1
  188. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  189. package/kits/hub-game/index.html +1 -0
  190. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  207. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  208. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  209. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  210. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  211. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  212. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  213. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  214. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  215. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  216. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  217. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  218. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  219. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  220. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  221. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  222. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  223. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  224. package/kits/hub-game/package-lock.json +3 -3
  225. package/kits/hub-game/package.json +4 -3
  226. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  227. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  228. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  229. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  230. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  231. package/kits/hub-game/scripts/pack.mjs +89 -23
  232. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  233. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  234. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  235. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  236. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  237. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  238. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  239. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  240. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  241. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  242. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  243. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  244. package/kits/hub-game/scripts/test-analytics.mjs +80 -1
  245. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  246. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  247. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  248. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  249. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  250. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  251. package/kits/hub-game/scripts/test-ballot.mjs +420 -3
  252. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  253. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  254. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  255. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  256. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  257. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  258. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  259. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  260. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  261. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  262. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  263. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  264. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  265. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  266. package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
  267. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  268. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  269. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  270. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  271. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  272. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  273. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  274. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  275. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  276. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  277. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  278. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  279. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  280. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  281. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  282. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  283. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  284. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  285. package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
  286. package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
  287. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  288. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  289. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  290. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  291. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  292. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  293. package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
  294. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  295. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  296. package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
  297. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  298. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  299. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  300. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  301. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  302. package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
  303. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  304. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  305. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  306. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  307. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  308. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  309. package/kits/hub-game/scripts/test-rehello.mjs +237 -0
  310. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  311. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  312. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  313. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  314. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  315. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  316. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  317. package/kits/hub-game/scripts/test-resync.mjs +13 -0
  318. package/kits/hub-game/scripts/test-role-client.mjs +10 -3
  319. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  320. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  321. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  322. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  323. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  324. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  325. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  326. package/kits/hub-game/scripts/test-stuck.mjs +31 -0
  327. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  328. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  329. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  330. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  331. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  332. package/kits/hub-game/scripts/test-together.mjs +11 -0
  333. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  334. package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
  335. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  336. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  337. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  338. package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
  339. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  340. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  341. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  342. package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
  343. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  344. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  345. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  346. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  347. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  348. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
  349. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
  350. package/kits/multiplayer-3d/castle.json +5 -5
  351. package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
  352. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  353. package/kits/multiplayer-3d/code/server/world.js +19 -4
  354. package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
  355. package/kits/multiplayer-3d/package-lock.json +1 -1
  356. package/kits/multiplayer-3d/package.json +2 -1
  357. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  358. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  359. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  360. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
  361. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  362. package/kits/physics-2d/castle.json +2 -2
  363. package/kits/physics-2d/engine/scene.js +10 -2
  364. package/kits/physics-3d/CLAUDE.md +14 -0
  365. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  366. package/kits/physics-3d/castle.json +3 -3
  367. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  368. package/kits/physics-3d/docs/engine-player.md +76 -0
  369. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  370. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  371. package/kits/physics-3d/engine3d/gait.js +16 -8
  372. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  373. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  374. package/kits/physics-3d/engine3d/look.js +110 -17
  375. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  376. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  377. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  378. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  379. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  380. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  381. package/kits/physics-3d/engine3d/optimize.js +20 -9
  382. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  383. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  384. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  385. package/kits/physics-3d/engine3d/world3d.js +211 -17
  386. package/kits/physics-3d/package-lock.json +1 -1
  387. package/kits/physics-3d/package.json +2 -1
  388. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  389. package/kits/physics-3d/scripts/render.mjs +56 -8
  390. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  391. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  392. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  393. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  394. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  395. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  396. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  397. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  398. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  399. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  400. package/kits/physics-3d/systems/physics3d.js +51 -2
  401. package/kits/real-time/castle.json +2 -2
  402. package/kits/real-time/code/client/connection.js +3 -0
  403. package/package.json +2 -2
  404. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -178,6 +178,21 @@ export interface MultiplayerHubResultsRead {
178
178
  players: Record<string, MultiplayerHubPlayerResults>;
179
179
  boards: Record<string, MultiplayerHubBoard>;
180
180
  }
181
+ export type MultiplayerHubPushPreferenceChange = Record<string, never> | {
182
+ enabled: boolean;
183
+ } | {
184
+ declined: true;
185
+ };
186
+ export interface MultiplayerHubPushPreference {
187
+ accepted: true;
188
+ enabled: boolean;
189
+ globalEnabled: boolean;
190
+ /** The player has ever set this place's reminder preference. */
191
+ touched: boolean;
192
+ milestone?: unknown;
193
+ /** Non-null once the player declined or disabled. */
194
+ nextPromptAt: number | null;
195
+ }
181
196
  /**
182
197
  * The hub place this session runs, as ghost pinned it from the deck's published
183
198
  * castle.json `hub` block. `session.hub` is null on a host without hub support
@@ -186,10 +201,14 @@ export interface MultiplayerHubResultsRead {
186
201
  export interface MultiplayerServerHub {
187
202
  /** Present only for an enabled place on a capable runtime. Reports visits; Ghost owns comeback delivery. */
188
203
  readonly push?: {
204
+ /** Absent phase starts a visit; `end` reports its end once, without retry. */
189
205
  visit(playerId: string, visit: {
190
206
  userId: string;
191
207
  timezone: string;
208
+ phase?: "end";
192
209
  }): Promise<boolean>;
210
+ /** Present only on a runtime with preferences. `{}` reads; null when refused or unavailable. */
211
+ preference?(playerId: string, change: MultiplayerHubPushPreferenceChange): Promise<MultiplayerHubPushPreference | null>;
193
212
  };
194
213
  /** Durably appends NPC words to a private platform archive. No read operation. */
195
214
  archiveText(playerId: string, entry: {
@@ -233,10 +233,22 @@ async function pushVisitCall(call, playerId, args) {
233
233
  return false;
234
234
  }
235
235
  }
236
+ async function pushPreferenceCall(call, playerId, args) {
237
+ try {
238
+ const answer = JSON.parse(await call(JSON.stringify({ ...args, playerId })));
239
+ return answer?.accepted === true ? answer : null;
240
+ }
241
+ catch {
242
+ return null;
243
+ }
244
+ }
236
245
  function pushCapability(handle) {
237
246
  if (handle.hub?.push?.version !== 1 || typeof handle.hubPushVisit !== "function")
238
247
  return {};
239
248
  return { push: {
240
249
  visit: (playerId, visit) => pushVisitCall((raw) => handle.hubPushVisit(raw), playerId, visit),
250
+ ...(typeof handle.hubPushPreference === "function"
251
+ ? { preference: (playerId, change) => pushPreferenceCall((raw) => handle.hubPushPreference(raw), playerId, change) }
252
+ : {}),
241
253
  } };
242
254
  }
@@ -100,6 +100,7 @@ export interface PlatformHandle {
100
100
  /** Friends among candidates (hub contract v1.36); older images use storage. */
101
101
  hubFriendsAmong?(argsJson: string): Promise<string>;
102
102
  hubPushVisit?(argsJson: string): Promise<string>;
103
+ hubPushPreference?(argsJson: string): Promise<string>;
103
104
  /** Absent on a runtime older than wearables (contract v1.4). */
104
105
  hubWear?(argsJson: string): Promise<string>;
105
106
  /** Absent on a runtime older than earned items (contract v1.53). */
@@ -8,7 +8,7 @@ export { createSaveCoordinator } from "../saveCoordinator";
8
8
  export type { CoordinatedChange, CoordinatedSave, SaveCoordinator, SaveStatus, } from "../saveCoordinator";
9
9
  export { SaveError } from "../save";
10
10
  export type { SaveApi, SaveBucketApi, SaveBucketRead, SaveChange, SaveCheck, SaveConditionalCheck, SaveConditionalWriteInput, SaveResetFence, SaveClaimed, SaveClaimInput, SaveErrorEnvelope, SaveInitial, SaveInitializeInput, SaveOpened, SaveOperation, SaveReadTarget, SaveReceipt, SaveRecentOperationsInput, SaveRecentOperationsPage, SaveRevision, SaveRows, SaveScope, SaveSelection, SaveSnapshot, SaveTarget, SaveTransactionInput, SaveWriter, } from "../save";
11
- export type { MultiplayerHubArrival, MultiplayerHubBoard, MultiplayerHubOutcome, MultiplayerHubPadUpdateInput, MultiplayerHubPadUpdateResult, MultiplayerHubPlayerResults, MultiplayerHubRecord, MultiplayerHubReportReceipt, MultiplayerHubResultInput, MultiplayerHubResultRow, MultiplayerHubResultShape, MultiplayerHubResultsRead, MultiplayerHubResultsReadInput, MultiplayerHubWearable, MultiplayerHubWearReceipt, MultiplayerHubEarnedClass, MultiplayerHubEarnedItem, MultiplayerHubHomeClass, MultiplayerHubHomeItem, MultiplayerHubUnlockReceipt, MultiplayerHubUnlocksRead, MultiplayerHubWearEarnedReceipt, MultiplayerServerHub, } from "./hub";
11
+ export type { MultiplayerHubArrival, MultiplayerHubBoard, MultiplayerHubOutcome, MultiplayerHubPadUpdateInput, MultiplayerHubPadUpdateResult, MultiplayerHubPlayerResults, MultiplayerHubPushPreference, MultiplayerHubPushPreferenceChange, MultiplayerHubRecord, MultiplayerHubReportReceipt, MultiplayerHubResultInput, MultiplayerHubResultRow, MultiplayerHubResultShape, MultiplayerHubResultsRead, MultiplayerHubResultsReadInput, MultiplayerHubWearable, MultiplayerHubWearReceipt, MultiplayerHubEarnedClass, MultiplayerHubEarnedItem, MultiplayerHubHomeClass, MultiplayerHubHomeItem, MultiplayerHubUnlockReceipt, MultiplayerHubUnlocksRead, MultiplayerHubWearEarnedReceipt, MultiplayerServerHub, } from "./hub";
12
12
  export type { CharacterActionNotice, CharacterGameStateOperation, CharacterGameStateResult, CharacterKnowledgeDeliveryOperation, CharacterKnowledgeDeliveryResult, CharacterKnowledgeSource, CompleteCharacterBeatInput, DeliverCharacterKnowledgeInput, RecordCharacterEventInput, SetCharacterGameStateInput, ShareCharacterClaimInput, ServerStorage, ServerStorageBoard, ServerStorageBoardScore, ServerStorageListEntry, ServerStorageListOptions, ServerStorageListPage, ServerPlaythrough, ServerPlaythroughCharacters, ServerCharacterHistoryOptions, ServerStorageScope, ServerTownStorage, } from "./storage";
13
13
  export interface MultiplayerServerPlayer extends PlayerIdentity {
14
14
  playerId: string;
@@ -210,6 +210,28 @@ async function bootSession(platformHandle, callbacks) {
210
210
  }
211
211
  }
212
212
  function createAuthorSession(platformHandle, players, arrivals, hidden, variants) {
213
+ // Each join's arms -> the names already reported for it, so a rejoin reports
214
+ // again and a leave needs no cleanup.
215
+ const exposed = new WeakMap();
216
+ // The first read of `name` for one join tells the host, which stamps the
217
+ // player and records the exposure (the arm the player was shown) for the deck's
218
+ // analytics. Fire and forget: a host from before exposures refuses the unknown
219
+ // operation, and a report must never change what the deck reads.
220
+ const reportExposure = (player, known, name) => {
221
+ let names = exposed.get(known);
222
+ if (!names)
223
+ exposed.set(known, (names = new Set()));
224
+ if (names.has(name) || typeof platformHandle.storage !== "function")
225
+ return;
226
+ names.add(name);
227
+ const playerId = typeof player === "string" ? player : player.playerId;
228
+ try {
229
+ void Promise.resolve(platformHandle.storage("experimentExposure", JSON.stringify({ playerId, experiment: name, variant: known[name] }))).catch(() => { });
230
+ }
231
+ catch {
232
+ // Same as a refusal.
233
+ }
234
+ };
213
235
  // Lenient about what it is handed: an unknown player is in no experiment.
214
236
  const variantsOf = (player) => variants.get(typeof player === "string"
215
237
  ? player
@@ -241,7 +263,10 @@ function createAuthorSession(platformHandle, players, arrivals, hidden, variants
241
263
  hub,
242
264
  experiment(player, name) {
243
265
  const known = variantsOf(player);
244
- return known && Object.hasOwn(known, name) ? known[name] : null;
266
+ if (!known || !Object.hasOwn(known, name))
267
+ return null;
268
+ reportExposure(player, known, name);
269
+ return known[name];
245
270
  },
246
271
  experiments(player) {
247
272
  return { ...variantsOf(player) };
@@ -1,4 +1,4 @@
1
- import type { StoreAllowance } from "./commands";
1
+ import type { StoreAllowance, StoreRateBudget, StoreRateUsage } from "./commands";
2
2
  import type { Json } from "./types";
3
3
  import { type SaveApi, type SaveBucketApi } from "./save";
4
4
  export interface StoreListOptions {
@@ -54,7 +54,7 @@ export interface StoreBoardApi {
54
54
  /** One player's score, defaulting to the current player. Null if unset. */
55
55
  get(userId?: string): Promise<StoreBoardScore | null>;
56
56
  }
57
- export type { StoreAllowance };
57
+ export type { StoreAllowance, StoreRateBudget, StoreRateUsage };
58
58
  export interface StoreUsage {
59
59
  /**
60
60
  * The current player's own data in this deck: their `Store.me` and
@@ -63,6 +63,12 @@ export interface StoreUsage {
63
63
  player: StoreAllowance;
64
64
  /** `Store.deck`: one allowance shared by every player of the deck. */
65
65
  shared: StoreAllowance;
66
+ /**
67
+ * How much of the current second's call and byte rate limits is spent, for
68
+ * the current player (`caller`) and for every player of the deck together
69
+ * (`deck`). Counts this usage call. Absent when the app is too old to report it.
70
+ */
71
+ rate?: StoreRateUsage;
66
72
  }
67
73
  export interface CastleStoreApi extends SaveApi {
68
74
  /** Shared by everyone playing the deck. */
@@ -309,7 +309,11 @@ async function usage() {
309
309
  // caller.
310
310
  await Promise.all(Array.from(buckets.values(), (bucket) => flushBucket(bucket, false)));
311
311
  const { usage: allowances } = await hostRequest("cauldronStorage.usage", {});
312
- return { player: allowances.player, shared: allowances.shared };
312
+ const result = { player: allowances.player, shared: allowances.shared };
313
+ // An app built before the rate field answers without it.
314
+ if (allowances.rate)
315
+ result.rate = allowances.rate;
316
+ return result;
313
317
  }
314
318
  // Saves skip the write coalescing above: each is one request, sent at once.
315
319
  const saveApi = createSaveApi((verb, input) => hostRequest(`cauldronStorage.${verb}`, input));
@@ -1,4 +1,4 @@
1
- import { type CommandName, type CommandParams, type CommandResult, type HubEvent, type LifecycleEvent, type VoiceEvent } from "./commands";
1
+ import { type CommandName, type CommandParams, type CommandResult, type HubEvent, type HubGoFailedEvent, type LifecycleEvent, type VoiceEvent } from "./commands";
2
2
  type PostChannel = "mobile" | "web";
3
3
  export interface HostStreamOptions {
4
4
  onStream?: (event: unknown) => void;
@@ -19,6 +19,7 @@ declare global {
19
19
  export declare function hostRequest<C extends CommandName>(command: C, params: CommandParams[C], stream?: HostStreamOptions): Promise<CommandResult[C]>;
20
20
  export declare function getCommandChannel(): PostChannel | "local";
21
21
  export declare function hostNotify(event: LifecycleEvent): void;
22
+ export declare function hostNotifyHub(event: HubGoFailedEvent): void;
22
23
  export declare function postUnloadDone(unloadId: string, state?: string): void;
23
24
  export declare function setUnloadHandler(handler: (unloadId: string) => void): void;
24
25
  export declare function setVoiceEventHandler(handler: ((event: VoiceEvent) => void) | null): void;
@@ -26,6 +26,7 @@ const INTERACTIVE_COMMANDS = new Set([
26
26
  "multiplayer.joinDestination",
27
27
  // The host's voice prompt and the browser's microphone permission.
28
28
  "voice.requestJoin",
29
+ "hub.pushPermission",
29
30
  ]);
30
31
  // Request ids carry a per-page prefix so that a host serving several decks at
31
32
  // once can key a cancel by requestId alone.
@@ -78,6 +79,17 @@ export function hostNotify(event) {
78
79
  };
79
80
  sendEnvelope(channel, envelope);
80
81
  }
82
+ // A deck's word to the host about a hub event (Hub.goFailed). One-way like
83
+ // hostNotify; the dev server has no host session to act on it.
84
+ export function hostNotifyHub(event) {
85
+ if (typeof window === "undefined")
86
+ return;
87
+ const channel = resolveChannel();
88
+ if (channel === "local")
89
+ return;
90
+ const envelope = { castleSdk: CASTLE_SDK_PROTOCOL, hub: event };
91
+ sendEnvelope(channel, envelope);
92
+ }
81
93
  // Reply to a host unload request. One-way like hostNotify, but it carries the
82
94
  // handshake's whole point, so it posts even with no state: the host is holding
83
95
  // its teardown open until this arrives or its cap runs out.
@@ -255,6 +267,29 @@ function settle(message) {
255
267
  }
256
268
  forget(message.requestId);
257
269
  entry.resolve(message);
270
+ // Only the mobile destination response for this still-pending SDK command
271
+ // may acknowledge delivery. The native host uses the receipt to consume a
272
+ // reserved push hint; ordinary commands and older hosts keep their bytes.
273
+ const receipt = message.hubPushReceipt;
274
+ const destination = message.data;
275
+ if (entry.channel === "mobile" &&
276
+ entry.command === "hub.pushDestination" &&
277
+ message.ok &&
278
+ typeof destination?.notificationId === "string" &&
279
+ typeof destination?.townDeckId === "string" &&
280
+ typeof receipt === "string" &&
281
+ /^[0-9a-f]{32}$/.test(receipt)) {
282
+ try {
283
+ sendEnvelope("mobile", {
284
+ castleSdk: CASTLE_SDK_PROTOCOL,
285
+ hubPushReceipt: { requestId: message.requestId, token: receipt },
286
+ });
287
+ }
288
+ catch {
289
+ // The response has been accepted, but a missing native bridge leaves
290
+ // the reservation to expire without consuming the destination.
291
+ }
292
+ }
258
293
  }
259
294
  // A throwing onStream is logged, and the stream goes on.
260
295
  function deliverStream(requestId, event) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  A game behind a door in the Cauldron hub town. A hub game is a
4
4
  `castle.multiplayer-3d` deck that meets the **hub contract**
5
- (`docs/contract.md`, latest version 1.158; manifest `hub.contract: 1`): the kit
5
+ (`docs/contract.md`, latest version 1.167; manifest `hub.contract: 1`): the kit
6
6
  draws every player as their platform avatar, brings them in at the arrival
7
7
  together and sends them back out
8
8
  through the door they came in by, and draws the HUD, labels and Back control
@@ -48,9 +48,37 @@ notes messages and the client's refill behavior stay exactly as before.
48
48
  reads the role. `drive(id, null, at?)` gets everyone out; `ride(id, null)`
49
49
  gets one rider out. Holds stop drivers, walk tune returns on exit; retained
50
50
  reconnect keeps cars. Horn must be listed in `idle.sounds`. See contract §6.
51
+ - **Disguise (v1.196).** Server-only `hub.disguise(id, { look?, to? } | null)`
52
+ and `hub.disguised(id)` give a visit-only scene Model disguise for selected
53
+ viewers (default: everyone else), hiding their tags and decorations. Self
54
+ sees the look with everything else unchanged. Without look, hide only
55
+ name/mark/role tags. Refuses held, driving/riding, absent or departing
56
+ players (a null clear is always taken); drive/ride refuse disguised players. Retained resume keeps it;
57
+ leave/trip/end/account change clears it. Deck UI naming players is the
58
+ deck's job. Contract §11; no manifest key.
59
+ - **The Town's day (v1.200).** `hub.townDay(nowMs?)` is the Town's day number
60
+ (LA midnight, hub-town daily.js) on the `Math.floor(ms / 86400000)` scale;
61
+ `hub.townDayStart(day)` its first epoch ms; `hub.townDayFrom(stored, nowMs?)`
62
+ clamps a stored UTC day number to today on the switch. Contract §14; no
63
+ manifest key.
64
+ - **Private ghosts (v1.163).** `hub.record(id, 'start'|'stop'|'cancel')` samples
65
+ server poses (192 max, 10 minutes); stop returns `{ v: 1, step, ms, poses }`
66
+ or null. `hub.replay(viewerId, 0|1, { trace, look?, label?, color?, offsetMs? }|null)`
67
+ draws two non-solid translucent ghosts for that viewer only, never actors or
68
+ snapshot state. Four shown ghosts/s, clears free; no manifest key or storage. Any drop invalidates
69
+ recording and clears replay; resume may reissue with offset. Friend privacy
70
+ is the deck's responsibility via friendBests/friendsAmong. Contract §10/§12.
51
71
  - **A player's progress between visits** goes in `hub.session.storage.deck`
52
72
  under `'<name>:<userId>'`, never user scope, which their own client can
53
73
  write (contract §14).
74
+ - **Coins (v1.185).** Declare `hub.wallet: { name, start? }` and use
75
+ `hub.wallet.read(playerId)` (null while locked), `spend(playerId, { cost,
76
+ add?, data? })`, `earn(playerId, amount, { data? })` and, once per account
77
+ from an old whole save, `seed(playerId, { coins, owned })`; results are
78
+ `{ ok: true, coins }` or `{ ok: false, why }` (`short`, `owned`, `locked`,
79
+ `busy`, `full`, `seeded`). Kept on conditional storage, never a whole-save
80
+ set; locked for signed-in players until the deck's conditional-storage flag
81
+ is on. Guests get a session wallet. Contract §14 "Coins".
54
82
  - What `hub` does: `players()`, `actorsWith(component)` (each with its `t`,
55
83
  `props`, `shape` and `body`), `now`, `placeAt`,
56
84
  `hold` / `release` (keep a player still), `setHud(spec, playerId?)`,
@@ -119,6 +147,9 @@ notes messages and the client's refill behavior stay exactly as before.
119
147
  `decor(hub, playerId, op)` hook: the kit draws the grid, catalogue, ghosts
120
148
  and touch/mouse controls; the deck checks ownership, stock, collisions and
121
149
  saving, then applies spawn/move/despawn/tint and updates the catalogue.
150
+ v1.164 item `action: true` sends a stock-free `pick` without a ghost or
151
+ count chip; locks still apply. Without it, wire bytes, client behavior and
152
+ validation stay identical.
122
153
  Spawned seats work for guests in these places. Contract §10 Decorating;
123
154
  `scripts/test-decor.mjs` and `test-decor-client.mjs`. Absent keys add no wire
124
155
  state, chrome or preview resources.
@@ -128,6 +159,8 @@ notes messages and the client's refill behavior stay exactly as before.
128
159
  disconnected players are ignored; at most 256 actor overrides per player.
129
160
  Private calls return true when taken; invalid actor/options or exceeding the
130
161
  cap warn once and return false without changes. Leaving drops overrides.
162
+ v1.184 `hub.hide(id, { to, solid: true })` draws it hidden for those viewers
163
+ but keeps its collider in place on their clients (a cutaway wall stays solid).
131
164
  A result place with `resume: { keep: true }` may also set
132
165
  `resumeVisibility: true`: for the retained visit's <60 s absence, keep the
133
166
  authenticated viewer's overrides. This requires an exported `resume` hook;
@@ -188,7 +221,13 @@ notes messages and the client's refill behavior stay exactly as before.
188
221
  picked), not on feed/text refreshes; a tap carries it and counts only on
189
222
  the delivered, current version.
190
223
  The card is drawn from who is here now: absent players' faces and feed rows
191
- go, blocks among players here drop theirs and redact present names. Rule B:
224
+ go, blocks among players here drop theirs and redact present names. v1.179
225
+ `ballot: { keepAway: true }` (only in a place that retains dropped visits):
226
+ a retained, dropped player keeps their face (`away: true`, tappable) for
227
+ viewers they were last here with unblocked, under both players' current
228
+ signed-in accounts, drawn from a profile snapshot; every send and tap uses
229
+ the one eligibility rule at the top of the keepAway code in `ballot.js`.
230
+ Rule B:
192
231
  without the key no ballot code runs, client or server (no `hub.ballot`).
193
232
  - **Turning displays** (v1.55): `"HubSpin": { "rate": 45 }` (deg/s, ±720) on a
194
233
  non-solid scene actor with no moving Body turns it on every client; no op.
@@ -199,13 +238,12 @@ notes messages and the client's refill behavior stay exactly as before.
199
238
  - **The HUD** is `{ title, big, text, timer: { since | until } }` in simulation
200
239
  ms (`hub.now`), drawn by the hub. It is the only way the game puts words on
201
240
  screen.
202
- - **Reachable action overflow** is a scene choice: set
203
- `"engine": { "hubActionOverflow": true }` in a scene that may receive three
204
- `hub.actions` offers. The kit measures one row, then at most two rows; where
205
- neither clears the scene's visible controls and touch regions it keeps every
206
- offer behind a keyboard-accessible More/Actions sheet. The sheet dismisses
207
- with Close, Escape or platform Back and holds only local input while open.
208
- Without the scene key, action chips use the legacy stack unchanged.
241
+ - **Action offers** (v1.187) always use the reachable overflow rail: the kit
242
+ measures one row, then at most two rows; where neither clears the scene's
243
+ visible controls and touch regions it keeps every offer behind a
244
+ keyboard-accessible More/Actions sheet. The sheet dismisses with Close,
245
+ Escape or platform Back and holds only local input while open. The old
246
+ `"engine": { "hubActionOverflow": true }` scene key is a no-op.
209
247
  - **Results** are server-only, once per player per visit, checked against
210
248
  `hub.result` in `castle.json`. No free text: the town writes the words. The
211
249
  `outcome` may be left out when a `score` says it all (a time trial).
@@ -273,14 +311,18 @@ notes messages and the client's refill behavior stay exactly as before.
273
311
  reports bunched by the network nor ticks that run no physics step can break
274
312
  the owned-object move bound and take the object away mid-throw; half a turn
275
313
  takes about a second on a good connection, and a swing the server cannot
276
- confirm stalls and throws at the 2 s give-up from where it got. The default
277
- (keyless) carry has no such bound: at the carry speed two of its reports
278
- bunched into one tick can exceed the 0.6 m and lose the object (card
279
- hub-game-grab-the-pickup-ease-in-1-2-m-3-m-hold). The swing adds no exposure
280
- of its own: the carry before the press is that same carry, and the swing
281
- never moves the object anywhere a report could fail (one the carry already
282
- sent too far stalls it, and only a contact push in the client's physics,
283
- which the carry shares, could move it further). The grab offer and the carry still follow
314
+ confirm stalls and throws at the 2 s give-up from where it got. Ordinary
315
+ carry, with or without the key, follows at the carry speed. multiplayer-3d
316
+ checks owned-object reports from the newest accepted target of the current
317
+ grant, including a target the kinematic body has not stepped to yet. Its
318
+ movement budget earns 40 m/s of elapsed simulation time, capped at the 1.5 s ownership timeout
319
+ plus 0.6 m of delivery slack, and each accepted move spends its distance.
320
+ Reports bunched into one tick share that budget, so a normal turning walk
321
+ keeps its carry; a report beyond the remaining budget still returns the
322
+ object to the server and ends the hold. A new grant starts from the body's
323
+ current pose with only the delivery slack. The swing and pickup pacing
324
+ remain conservative and also work with older multiplayer kits that check
325
+ against the stepped body. The grab offer and the carry still follow
284
326
  the character's facing. Without the key a throw is exactly what it was
285
327
  (scripts/test-grab-orbit.mjs holds both).
286
328
  `hub.keepFor(actorId, playerId | null)` (contract v1.27) keeps a loose
@@ -317,6 +359,9 @@ notes messages and the client's refill behavior stay exactly as before.
317
359
  null). `{ roleEmotes: [{ id, emoji, label, motion, ms }] }` declares up to
318
360
  12 role emotes; `hub.emotesFor(playerId, ids | null)` grants them for the
319
361
  visit, privately. Absent expression keeps existing UI and wire bytes (§6).
362
+ v1.174 `hub.emote(playerId, 'yawn')` (any `idle.emotes` place) plays a
363
+ place-only doze for a benched or idle player; no picker offers it and a
364
+ client request for it is refused.
320
365
  - **The soundscape** (contract v1.42, v1.49, v1.50, v1.56, v1.60): `"soundscape": true` in the `hub`
321
366
  block (or `{ babble, steps }`, each on unless `false`; the deck's, not a
322
367
  place's) has the kit make its own sounds, synthesised in the client and
@@ -505,6 +550,7 @@ notes messages and the client's refill behavior stay exactly as before.
505
550
  | `code/server/place.js` | which place a session runs, from the session alone |
506
551
  | `code/server/game.js` | the starter game (Flag Dash), copied into a new deck |
507
552
  | `code/client/hookLayer.js` | the client hooks, layered under the deck's by `castle.real-time` |
553
+ | `code/server/replay.js`, `code/shared/replay.js`, `code/client/replay.js` | v1.163 private recording/fences, bounded trace validation/interpolation, and two translucent scene groups; `scripts/test-replay.mjs` / `test-replay-client.mjs` |
508
554
  | `code/systems/hub.js` | the door trip, Back, joining a friend's layer, the HUD, labels, hidden actors, holds, the ribbon |
509
555
  | `code/client/chrome.js`, `state.js`, `avatar.js`, `firstJoin.js` | the DOM chrome, what the place declared, the avatar seam, the main place's first join (§13) |
510
556
  | `blueprints/avatar-<n>.scene`, `models/avatar-<n>.pxmodel`, `scripts/gen-avatars.mjs`, `code/client/avatarFaces.js` | the sixteen toon avatars (the Castle mascot, Petal, Beat, Star; v1.51: Biscuit, Mochi, Hop, Pip, Ribbit, Ember, Bolt, Gloop, Cap, Toast, Scoop, Zest) and the script that writes their models and the picker's faces; each avatar's height and hat fit are in `avatar.js`, for what is worn over it. A guest with no stored choice may be given any of the sixteen; ghost defaults new accounts from its user-id cutoff on across all sixteen, while an existing account below it that never picked keeps one of the first four. Stored choices stay unchanged (contract §11) |
@@ -513,7 +559,7 @@ notes messages and the client's refill behavior stay exactly as before.
513
559
  | `scripts/check.mjs` | the publish check (`onCheck`) |
514
560
  | `scripts/pack.mjs` | the content pack exporter (`onPack`): the deck's client half as data, for another deck's engine (`docs/content-pack.md`) |
515
561
  | `code/client/pack.js`, `packFormat.js`, `sha256.js` | mounting a pack: fetch, verify, validate, build content |
516
- | `tools/hubScene/` | the save-time HubSceneManifest exporter (castle.json `exports.hubScene`, run by `castle-web export`, and by `save-deck` under `CASTLE_SAVE_EXPORTS=1`): the deck's world built in Node with the CLI's own shipped kits (the loader refuses any other module; a deck's imports/ is read as data only), written into a stage the CLI then moves to `.castle/exports/hubScene/`; glbs are content-addressed in `~/.castle/export-cache/hubScene/shared/` (created exclusively, never overwritten; no GC yet), and the last manifest is reused while its key (CLI version, the shipped kit trees, three, every data file read) holds; `validate-manifest.mjs` checks it, `merge-root.mjs` merges decks into one root for the native host, `test/export-fixture.mjs` is its test. Manifest v1.4 adds `deck` (the hub block's client flags, `code/shared/deckFlags.js`) and `interactables` (HubNpc, HubAct and HubSeat actors as `{ id, components }` with their Transform, and, when the scene opts in to chat Report & block, the component-only `{ id: 'hub-chat-moderation', components: { HubChatModeration: { v: 1 } } }`) for the DOM-less native kit, which applies `deck` with `hookLayer.applyDeck` (`scripts/test-apply-deck.mjs`). v1.6 (`format` and `version` unchanged) adds the deck's sound: each file the hub block's root and places' `idle.sounds` name, read as the page's initialMedia holds it (the deck's own .mp3/.wav/.m4a; others are left out with a source note), is a content-addressed asset mapped by its castle.json path in `audio`; `deck` keeps `soundscape` and the root and places' `idle` at their keys; `interactables` adds the `jukebox` actor (Shape, Lookable, Transform) and every actor carrying a component the soundscape names (`zones`, `steps.paths`, `ambience.spots` keys), whole, with its Transform. v1.7 (`format` and `version` still unchanged) always adds `avatarFits` (16 entries per style after `Avatar.drawn` fallback, earned fit arrays verbatim, `hat` and `top`), `wearModels` (untinted content-addressed glb asset records for every hat, earned and role model, including square variants, also registered in `assets`) and `wearPieces` (anchors, constant scales, main colours to tint and fit-dependent placement notes). Fits are over feet; placement shifts to the avatar origin as in `wear.js`. Ring `scale` is the unchanged height scale; horizontal stretch and all top scaling depend on the fit. Hats retain authored colours; lantern/lighthouse perch on the crown (`wear.js`), while other hats sit at the seat. The shipped client avatar/role/earned/hats modules and model files are already covered by the kits hash. Upload rewrites the embedded wear asset URIs too. Earlier fields match castle-client's live-page exporter (`nativetown/hubscene/tools/export-hub.mjs`) |
562
+ | `tools/hubScene/` | the save-time HubSceneManifest exporter (castle.json `exports.hubScene`, run by `castle-web export`, and by `save-deck` under `CASTLE_SAVE_EXPORTS=1`): the deck's world built in Node with the CLI's own shipped kits (the loader refuses any other module; a deck's imports/ is read as data only), written into a stage the CLI then moves to `.castle/exports/hubScene/`; glbs are content-addressed in `~/.castle/export-cache/hubScene/shared/` (created exclusively, never overwritten; no GC yet), and the last manifest is reused while its key (CLI version, the shipped kit trees, three, every data file read) holds; `validate-manifest.mjs` checks it, `merge-root.mjs` merges decks into one root for the native host, `test/export-fixture.mjs` is its test. Manifest v1.4 adds `deck` (the hub block's client flags, `code/shared/deckFlags.js`) and `interactables` (HubNpc, HubAct and HubSeat actors as `{ id, components }` with their Transform, and, when the scene opts in to chat Report & block, the component-only `{ id: 'hub-chat-moderation', components: { HubChatModeration: { v: 1 } } }`) for the DOM-less native kit, which applies `deck` with `hookLayer.applyDeck` (`scripts/test-apply-deck.mjs`). v1.6 (`format` and `version` unchanged) adds the deck's sound: each file the hub block's root and places' `idle.sounds` name, read as the page's initialMedia holds it (the deck's own .mp3/.wav/.m4a; others are left out with a source note), is a content-addressed asset mapped by its castle.json path in `audio`; `deck` keeps `soundscape` and the root and places' `idle` at their keys; `interactables` adds the `jukebox` actor (Shape, Lookable, Transform) and every actor carrying a component the soundscape names (`zones`, `steps.paths`, `ambience.spots` keys), whole, with its Transform. v1.7 (`format` and `version` still unchanged) always adds `avatarFits` (16 entries per style after `Avatar.drawn` fallback, earned fit arrays verbatim, `hat` and `top`), `wearModels` (untinted content-addressed glb asset records for every hat, earned and role model and, since v1.182, every hold-show flower (`hold-show/<shape>`, `hold-show/square/<shape>`), including square variants, also registered in `assets`) and `wearPieces` (anchors, constant scales, main colours to tint and fit-dependent placement notes; a flower's piece is the right hand at scale 1.2, tinted in its `hubHoldShow` colour; the validator takes flowers as optional, all or nothing). Fits are over feet; placement shifts to the avatar origin as in `wear.js`. Ring `scale` is the unchanged height scale; horizontal stretch and all top scaling depend on the fit. Hats retain authored colours; lantern/lighthouse perch on the crown (`wear.js`), while other hats sit at the seat. The shipped client avatar/role/earned/hats modules and model files are already covered by the kits hash. Upload rewrites the embedded wear asset URIs too. Earlier fields match castle-client's live-page exporter (`nativetown/hubscene/tools/export-hub.mjs`) |
517
563
  | `scripts/test-manifest.mjs`, `test-pack.mjs`, `test-actors.mjs`, `test-idle.mjs`, `test-classic.mjs` | tests over the manifest, results, place resolution, the pack, moved and painted actors, idle play, and cabinets |
518
564
  | `scripts/test-avatar.mjs`, `test-avatar-models.mjs`, `test-picker.mjs` | the avatar seam; the toon models held to the generator and to 1,500 triangles and 8 draw calls (the engine's own count); the character picker |
519
565
  | `code/client/avatarCap.js`, `scripts/test-avatar-cap.mjs` | a limit on different characters drawn at once, by default all sixteen (no stand-ins); with `?hubAvDistinct=N`, at most N (the local player's included): the farthest players past that are drawn as their stand-in (`avatar % 4`), never anyone within 8 m, with hysteresis, respawned through the hook layer's avatar-change path; client display only. `?hubAvDistinct=N` sets the limit (absent or 0 the default) |
@@ -611,7 +657,8 @@ work, caps both renderer and composer pixel ratios at 0.5, and uses the existing
611
657
  far-body merge with twelve nearest full rigs. Leaving the profile restores the
612
658
  previous buffer ratios unless another owner has changed them.
613
659
  Unmapped actors, route anchors and dynamic bodies stay live. Games mounted
614
- through doors use their ordinary tier path. See docs/contract.md for the schema.
660
+ through doors use their ordinary tier path, except that the profile's capped
661
+ buffer ratios hold there too (the town's actors and files are restored). See docs/contract.md for the schema.
615
662
 
616
663
  - **Bounded shots** (v1.119): optional `fit: {min:{x,y,z}, max:{x,y,z}, minDistance}`
617
664
  on hub.shot fits a world box inside the central 90% of the current perspective
@@ -6,15 +6,15 @@
6
6
  "imports": {
7
7
  "castle.multiplayer-3d": {
8
8
  "deckId": "ZwA_P_-VO-Qh",
9
- "version": "2026-10-18T06:47:00.410Z"
9
+ "version": "2026-10-23T12:15:36.617Z"
10
10
  },
11
11
  "castle.real-time": {
12
12
  "deckId": "xFVr-afOLuUQ",
13
- "version": "2026-10-18T06:38:41.691Z"
13
+ "version": "2026-10-23T12:14:35.623Z"
14
14
  },
15
15
  "castle.physics-3d": {
16
16
  "deckId": "JH0SclbPVP0y",
17
- "version": "2026-10-18T06:40:58.918Z",
17
+ "version": "2026-10-23T12:14:42.092Z",
18
18
  "via": "castle.multiplayer-3d"
19
19
  },
20
20
  "castle.physics-2d": {
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "castle.base": {
26
26
  "deckId": "yRcmH4_aYllE",
27
- "version": "2026-10-18T10:34:27.709Z"
27
+ "version": "2026-10-23T12:08:44.010Z"
28
28
  }
29
29
  },
30
30
  "autoUpdateWhenImported": true,
@@ -55,7 +55,8 @@ function el(parent, kind, text) {
55
55
  parent.appendChild(node);
56
56
  return node;
57
57
  }
58
- export function makeAct(chrome, grab, talk) {
58
+ // `refuse` shows the line for a press refused while catching up (v1.204).
59
+ export function makeAct(chrome, grab, talk, refuse = () => {}) {
59
60
  const sharedGeometry = chrome.layoutGeometry?.();
60
61
  const geometry = sharedGeometry ?? makeLayoutCache();
61
62
  const root = document.createElement('div');
@@ -72,6 +73,7 @@ export function makeAct(chrome, grab, talk) {
72
73
  throw: (item, f, done) => grab.perform(item.actor, f.scene, f.mp, f.local, item.op, done),
73
74
  grab: (item, f) => grab.perform(item.actor, f.scene, f.mp, f.local, item.op),
74
75
  talk: item => talk.prepare(item.actor),
76
+ refused: () => refuse(),
75
77
  },
76
78
  });
77
79
  const pairState = { show: false, enabled: false, on: {
@@ -83,7 +85,7 @@ export function makeAct(chrome, grab, talk) {
83
85
  const pairDom = mountUiTree(root);
84
86
  let pairKey = '';
85
87
  function drawPair() {
86
- const key = `${pairState.show}:${pairState.enabled}`;
88
+ const key = `${pairState.show}:${pairState.enabled}:${Boolean(pairState.catching)}`;
87
89
  if (key === pairKey) {return;}
88
90
  pairKey = key;
89
91
  pairDom.render({ t: 'stack', k: 'act', c: [buildActPair(pairState)] });
@@ -176,10 +178,10 @@ export function makeAct(chrome, grab, talk) {
176
178
  }, { capture: true, signal });
177
179
  globalThis.addEventListener?.('blur', core.cancel, { signal });
178
180
  document.addEventListener('visibilitychange', () => {if (document.hidden) {core.cancel();}}, { signal });
179
- function frame(scene, mp, local, can) {
181
+ function frame(scene, mp, local, can, blocked) {
180
182
  const status = mp.net?.status?.();
181
183
  const changed = core.frame({ scene, link: mp, self: mp.net?.selfId?.(), player: local?.components.Transform,
182
- online: !status || status.state === 'connected', actors: () => scene.getActors(), getActor: id => scene.getActor(id), mp, local }, can);
184
+ online: !status || status.state === 'connected', actors: () => scene.getActors(), getActor: id => scene.getActor(id), mp, local }, can, blocked);
183
185
  if (changed) {keyboardInput = false;}
184
186
  if (scene.moveInput && input !== scene.moveInput) {
185
187
  if (input?.consumeJump === consumeJump) {input.consumeJump = originalJump;}
@@ -202,11 +204,12 @@ export function makeAct(chrome, grab, talk) {
202
204
  if (item.op !== 'talk' && node.textContent !== label) {node.textContent = label;}
203
205
  if (node.getAttribute('aria-label') !== item.verb) {node.setAttribute('aria-label', item.verb);}
204
206
  if (node.title !== item.verb) {node.title = item.verb;}
205
- node.style.opacity = item.id === current?.id ? '1' : '.55';
207
+ node.style.opacity = core.catching() ? '.4' : item.id === current?.id ? '1' : '.55';
206
208
  node.style.borderColor = item.id === current?.id ? '#f2c94c' : 'rgba(255,255,255,.55)';
207
209
  const progress = core.progress(item.id);
208
210
  node.style.background = progress ? `linear-gradient(90deg, #806521 ${progress * 100}%, rgba(20,16,12,.88) ${progress * 100}%)` : 'rgba(20,16,12,.88)';
209
211
  }
212
+ delete pairState.catching;
210
213
  Object.assign(pairState, core.pairState());
211
214
  drawPair();
212
215
  chrome.layoutInteractionRail();
@@ -266,7 +269,7 @@ export function makeAct(chrome, grab, talk) {
266
269
  } else {node.style.display = 'none';}
267
270
  }
268
271
  }
269
- return { frame,
272
+ return { frame, gate: core.gate,
270
273
  beginLayoutFrame() {
271
274
  if (!sharedGeometry) {
272
275
  for (const node of chrome.interactionObstacles()) {geometry.register(node);}
@@ -31,11 +31,13 @@
31
31
  // getActor(id) one actor by id, with its Transform
32
32
  // Any other facade field is the host's own, handed back to `effects`; the
33
33
  // core keeps its own copy of the identities, so a host may reuse one facade.
34
+ import { catchingDim } from './catchingUp.js';
34
35
  import { hub as hubState } from './state.js';
35
36
  import { footprintDistance } from './idle.js';
36
37
  import { interaction } from '../shared/act.js';
37
38
 
38
39
  export const HOLD_MS = 500;
40
+ const NONE = Object.freeze([]);
39
41
  // Authored counter verbs (Trade, Stamp, Buy, Play, Sit...) take focus over a
40
42
  // nearby loose body or keeper; distance decides only within a rank.
41
43
  export const rank = item => item.op === 'talk' || item.op === 'grab' ? 1 : 0;
@@ -61,13 +63,22 @@ export function actItems(facade, state, can) {
61
63
 
62
64
  export function makeActCore({ now, send, state = hubState, effects = {}, seq = Date.now() * 1000 }) {
63
65
  let current = null, context = null, press = null, queuedJump = false, items = [];
66
+ // What `gate()` returns, updated in place each frame.
67
+ const gated = { show: false, reasons: NONE };
64
68
  function cancel() {
65
69
  if (press) {send({ k: 'hub-act-hold', id: press.id, n: press.n, down: false }, context.link);}
66
70
  press = null;
67
71
  }
72
+ // v1.204: the server is reading this player's progress and would refuse
73
+ // the press, so it is refused here, visibly, instead.
74
+ function refused() {
75
+ if (state.catching == null) {return false;}
76
+ effects.refused?.();
77
+ return true;
78
+ }
68
79
  function perform(item, n) {
69
80
  const c = context;
70
- if (!c?.can || !item) {return;}
81
+ if (!c?.can || refused() || !item) {return;}
71
82
  // The existing client prediction/denial paths carry grabs and NPC panels.
72
83
  if (item.op === 'throw') {
73
84
  const done = () => send({ k: 'hub-act', id: item.id, n }, c.link);
@@ -83,7 +94,7 @@ export function makeActCore({ now, send, state = hubState, effects = {}, seq = D
83
94
  const done = press; press = null; perform(done.item, done.n);
84
95
  }
85
96
  function start(item, source) {
86
- if (!context?.can || !item || press) {return;}
97
+ if (!context?.can || press || refused() || !item) {return;}
87
98
  const n = ++seq;
88
99
  if (item.hold) {
89
100
  press = { id: item.id, n, at: now(), source, item };
@@ -91,16 +102,21 @@ export function makeActCore({ now, send, state = hubState, effects = {}, seq = D
91
102
  } else {perform(item, n);}
92
103
  }
93
104
  // Returns whether the context changed (another scene, connection, player or
94
- // place), which also drops a host's keyboard-hint state.
95
- function frame(facade, can) {
105
+ // place), which also drops a host's keyboard-hint state. `blocked` names
106
+ // the host's own reasons `can` is false (`actGateLog.js` tokens), if any.
107
+ function frame(facade, can, blocked = NONE) {
96
108
  const self = facade.self;
97
- can = can && (!state.held.has(self) || Object.hasOwn(state.seated, self));
109
+ const held = state.held.has(self) && !Object.hasOwn(state.seated, self);
110
+ can = can && !held;
98
111
  const { scene, link } = facade;
99
112
  const connected = link.net && self && facade.player && facade.online;
100
113
  const changed = Boolean(context && (context.scene !== scene || context.link.net !== link.net ||
101
114
  context.self !== self || context.place !== state.place?.id));
102
115
  if (changed || !can || !connected) {cancel(); queuedJump = false;}
103
116
  context = { facade, scene, link, can: Boolean(can && connected), self, place: state.place?.id };
117
+ gated.show = context.can;
118
+ gated.reasons = context.can ? NONE : [...blocked, ...(held ? ['hold'] : []),
119
+ ...(!link.net || !facade.online ? ['offline'] : !self || !facade.player ? ['nobody'] : [])];
104
120
  items = actItems(facade, state, context.can);
105
121
  current = items[0] ?? null;
106
122
  if (press && !items.some(item => item.id === press.id && item.verb === press.item.verb && item.hold === press.item.hold)) {cancel();}
@@ -121,7 +137,11 @@ export function makeActCore({ now, send, state = hubState, effects = {}, seq = D
121
137
  progress: id => press?.id === id ? Math.min(1, (now() - press.at) / HOLD_MS) : 0,
122
138
  // What the Act/Jump pair shows: shown while acting is allowed, Act
123
139
  // enabled while something is in reach.
124
- pairState: () => ({ show: Boolean(context?.can), enabled: Boolean(current) }),
140
+ // v1.204: `catching` while the progress read has lasted CATCHING_DIM_MS.
141
+ pairState: () => ({ show: Boolean(context?.can), enabled: Boolean(current), ...(catchingDim(state.catching, now()) ? { catching: true } : {}) }),
142
+ catching: () => catchingDim(state.catching, now()),
143
+ // Whether the pair shows, and if not, why (v1.203).
144
+ gate: () => gated,
125
145
  queueJump() {if (context?.can) {queuedJump = true;}},
126
146
  // The movement input's Jump: this pair's queued Jump or the original's.
127
147
  consumeJump(original) {
@@ -0,0 +1,36 @@
1
+ // Act-gate log (v1.203): in a place with `actGateLog` (the deck's
2
+ // `hub.actGateLog`), report each change of whether the Act/Jump pair shows,
3
+ // and why not, to the server, which prints it (`server/actGate.js`).
4
+ //
5
+ // A state is sent once it has held for DEBOUNCE_MS, so a flicker sends
6
+ // nothing, and a steady state sends nothing after its one report. Nothing is
7
+ // sent while offline (the report could not arrive); a new connection or a
8
+ // new admission (`epoch`: the place spec each join sends) reports afresh.
9
+ export const DEBOUNCE_MS = 500;
10
+
11
+ // The reasons a client gives, in a fixed order. `offline` is never sent.
12
+ export function blockedReasons({ trip, pendingEnd, talking, decorating, actionInput, askInput, menuInput, carded }) {
13
+ return [
14
+ ...(trip ? ['trip'] : []), ...(pendingEnd ? ['end'] : []), ...(talking ? ['talk'] : []),
15
+ ...(decorating ? ['decor'] : []), ...(actionInput ? ['action'] : []), ...(askInput ? ['ask'] : []),
16
+ ...(menuInput ? ['menu'] : []), ...(carded ? ['card'] : []),
17
+ ];
18
+ }
19
+
20
+ export function makeActGateLog({ now = () => performance.now() } = {}) {
21
+ let net = null, admission = null, sent = null, pending = null;
22
+ return {
23
+ // `gate` is the act core's `{ show, reasons }`.
24
+ frame(link, gate, epoch = null) {
25
+ if (link !== net || epoch !== admission) {net = link; admission = epoch; sent = null; pending = null;}
26
+ if (!net || gate.reasons.includes('offline')) {sent = null; pending = null; return;}
27
+ const key = gate.show ? 'shown' : gate.reasons.join(',');
28
+ if (key === sent) {pending = null; return;}
29
+ const t = now();
30
+ if (pending?.key !== key) {pending = { key, at: t }; return;}
31
+ if (t - pending.at < DEBOUNCE_MS) {return;}
32
+ pending = null; sent = key;
33
+ net.send?.({ k: 'hub-gate', show: gate.show, reasons: gate.show ? [] : [...gate.reasons] });
34
+ },
35
+ };
36
+ }