castle-web-cli 0.4.239 → 0.4.241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) 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 +163 -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 +6 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +2 -0
  19. package/dist/platformDoc.js +3 -2
  20. package/dist/playPagePolicy.js +5 -1
  21. package/dist/resetLeaderboards.d.ts +8 -1
  22. package/dist/resetLeaderboards.js +43 -8
  23. package/dist/roomLogs.d.ts +1 -0
  24. package/dist/roomLogs.js +30 -6
  25. package/dist/save-deck.d.ts +32 -2
  26. package/dist/save-deck.js +240 -39
  27. package/kits/base/CLAUDE.md +1 -1
  28. package/kits/base/castle.json +1 -1
  29. package/kits/base/sdk/README.md +174 -6
  30. package/kits/base/sdk/analytics.d.ts +8 -0
  31. package/kits/base/sdk/analytics.js +92 -0
  32. package/kits/base/sdk/castle.d.ts +5 -1
  33. package/kits/base/sdk/castle.js +2 -0
  34. package/kits/base/sdk/commands.d.ts +48 -0
  35. package/kits/base/sdk/commands.js +1 -0
  36. package/kits/base/sdk/debugConsole.d.ts +17 -0
  37. package/kits/base/sdk/debugConsole.js +154 -0
  38. package/kits/base/sdk/experiments.js +24 -1
  39. package/kits/base/sdk/hostRetry.d.ts +7 -0
  40. package/kits/base/sdk/hostRetry.js +57 -0
  41. package/kits/base/sdk/hub.d.ts +20 -2
  42. package/kits/base/sdk/hub.js +99 -13
  43. package/kits/base/sdk/multiplayer.d.ts +2 -0
  44. package/kits/base/sdk/multiplayer.js +168 -26
  45. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  46. package/kits/base/sdk/reconnectBudget.js +41 -1
  47. package/kits/base/sdk/runtime.js +36 -19
  48. package/kits/base/sdk/server/hub.d.ts +19 -0
  49. package/kits/base/sdk/server/hub.js +12 -0
  50. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  51. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  52. package/kits/base/sdk/server/wrapper.js +26 -1
  53. package/kits/base/sdk/transport.d.ts +2 -1
  54. package/kits/base/sdk/transport.js +35 -0
  55. package/kits/hub-game/CLAUDE.md +66 -19
  56. package/kits/hub-game/code/client/act.js +9 -6
  57. package/kits/hub-game/code/client/actCore.js +26 -6
  58. package/kits/hub-game/code/client/actGateLog.js +36 -0
  59. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  60. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  61. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  62. package/kits/hub-game/code/client/askSurface.js +85 -0
  63. package/kits/hub-game/code/client/askTree.js +51 -0
  64. package/kits/hub-game/code/client/attention.js +31 -6
  65. package/kits/hub-game/code/client/ballot.js +42 -5
  66. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  67. package/kits/hub-game/code/client/ballotTree.js +180 -0
  68. package/kits/hub-game/code/client/catchingUp.js +19 -0
  69. package/kits/hub-game/code/client/celebrate.js +66 -0
  70. package/kits/hub-game/code/client/chrome.js +481 -57
  71. package/kits/hub-game/code/client/companion.js +93 -23
  72. package/kits/hub-game/code/client/companionDress.js +1 -1
  73. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  74. package/kits/hub-game/code/client/cornerTree.js +83 -0
  75. package/kits/hub-game/code/client/decor.js +20 -11
  76. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  77. package/kits/hub-game/code/client/disguise.js +23 -0
  78. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  79. package/kits/hub-game/code/client/dockSurface.js +206 -0
  80. package/kits/hub-game/code/client/dockTree.js +232 -0
  81. package/kits/hub-game/code/client/earned.js +29 -0
  82. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  83. package/kits/hub-game/code/client/emoteTree.js +264 -0
  84. package/kits/hub-game/code/client/farAvatars.js +4 -3
  85. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  86. package/kits/hub-game/code/client/grab.js +121 -50
  87. package/kits/hub-game/code/client/holdShow.js +19 -0
  88. package/kits/hub-game/code/client/hookLayer.js +96 -12
  89. package/kits/hub-game/code/client/hubControls.js +7 -1
  90. package/kits/hub-game/code/client/hudSurface.js +11 -3
  91. package/kits/hub-game/code/client/hudTree.js +7 -4
  92. package/kits/hub-game/code/client/idle.js +21 -3
  93. package/kits/hub-game/code/client/invites.js +24 -3
  94. package/kits/hub-game/code/client/keys.js +15 -0
  95. package/kits/hub-game/code/client/labelsNear.js +8 -1
  96. package/kits/hub-game/code/client/layoutCache.js +57 -8
  97. package/kits/hub-game/code/client/loadingCover.js +53 -4
  98. package/kits/hub-game/code/client/menuIcons.js +15 -0
  99. package/kits/hub-game/code/client/menuSurface.js +102 -0
  100. package/kits/hub-game/code/client/menuTree.js +135 -0
  101. package/kits/hub-game/code/client/modelLook.js +41 -0
  102. package/kits/hub-game/code/client/padCues.js +11 -7
  103. package/kits/hub-game/code/client/padReadability.js +3 -3
  104. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  105. package/kits/hub-game/code/client/pickerTree.js +163 -0
  106. package/kits/hub-game/code/client/pushVisit.js +4 -2
  107. package/kits/hub-game/code/client/quality.js +188 -29
  108. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  109. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  110. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  111. package/kits/hub-game/code/client/rehello.js +75 -0
  112. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  113. package/kits/hub-game/code/client/replay.js +118 -0
  114. package/kits/hub-game/code/client/role.js +3 -0
  115. package/kits/hub-game/code/client/safeLayout.js +441 -56
  116. package/kits/hub-game/code/client/safeStyle.js +13 -10
  117. package/kits/hub-game/code/client/say.js +2 -0
  118. package/kits/hub-game/code/client/soundSurface.js +77 -0
  119. package/kits/hub-game/code/client/soundTree.js +74 -0
  120. package/kits/hub-game/code/client/soundscape.js +12 -9
  121. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  122. package/kits/hub-game/code/client/state.js +67 -1
  123. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  124. package/kits/hub-game/code/client/stuckTree.js +67 -0
  125. package/kits/hub-game/code/client/talk.js +42 -12
  126. package/kits/hub-game/code/client/talkTree.js +4 -2
  127. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  128. package/kits/hub-game/code/client/textAskTree.js +67 -0
  129. package/kits/hub-game/code/client/tiers.js +252 -27
  130. package/kits/hub-game/code/client/together.js +4 -1
  131. package/kits/hub-game/code/client/uiDom.js +86 -8
  132. package/kits/hub-game/code/client/uiTree.js +33 -4
  133. package/kits/hub-game/code/client/vehicle.js +72 -51
  134. package/kits/hub-game/code/client/weakestTier.js +75 -31
  135. package/kits/hub-game/code/client/wear.js +159 -5
  136. package/kits/hub-game/code/client/worldLabels.js +205 -25
  137. package/kits/hub-game/code/companionSpec.js +4 -2
  138. package/kits/hub-game/code/server/act.js +3 -0
  139. package/kits/hub-game/code/server/actGate.js +83 -0
  140. package/kits/hub-game/code/server/actions.js +71 -15
  141. package/kits/hub-game/code/server/actors.js +20 -5
  142. package/kits/hub-game/code/server/analytics.js +35 -3
  143. package/kits/hub-game/code/server/ask.js +39 -3
  144. package/kits/hub-game/code/server/ballot.js +167 -4
  145. package/kits/hub-game/code/server/celebrate.js +64 -0
  146. package/kits/hub-game/code/server/companion.js +17 -2
  147. package/kits/hub-game/code/server/decor.js +11 -2
  148. package/kits/hub-game/code/server/disguise.js +63 -0
  149. package/kits/hub-game/code/server/earned.js +6 -2
  150. package/kits/hub-game/code/server/friendBests.js +13 -4
  151. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  152. package/kits/hub-game/code/server/grab.js +12 -2
  153. package/kits/hub-game/code/server/heldOffers.js +142 -0
  154. package/kits/hub-game/code/server/holdShow.js +98 -0
  155. package/kits/hub-game/code/server/hub.js +991 -72
  156. package/kits/hub-game/code/server/idle.js +110 -9
  157. package/kits/hub-game/code/server/index.js +9 -0
  158. package/kits/hub-game/code/server/labels.js +13 -3
  159. package/kits/hub-game/code/server/manifest.js +94 -6
  160. package/kits/hub-game/code/server/menu.js +26 -3
  161. package/kits/hub-game/code/server/npcs.js +55 -9
  162. package/kits/hub-game/code/server/observe.js +67 -6
  163. package/kits/hub-game/code/server/players.js +14 -2
  164. package/kits/hub-game/code/server/replay.js +135 -0
  165. package/kits/hub-game/code/server/standing.js +7 -3
  166. package/kits/hub-game/code/server/storageLimit.js +4 -1
  167. package/kits/hub-game/code/server/townDay.js +74 -0
  168. package/kits/hub-game/code/server/vehicle.js +3 -0
  169. package/kits/hub-game/code/server/vis.js +26 -4
  170. package/kits/hub-game/code/server/wallet.js +677 -0
  171. package/kits/hub-game/code/server/wear.js +13 -3
  172. package/kits/hub-game/code/server/writerLease.js +191 -0
  173. package/kits/hub-game/code/shared/act.js +1 -1
  174. package/kits/hub-game/code/shared/expression.js +6 -0
  175. package/kits/hub-game/code/shared/replay.js +37 -0
  176. package/kits/hub-game/code/systems/hub.js +429 -55
  177. package/kits/hub-game/docs/analytics.md +16 -2
  178. package/kits/hub-game/docs/contract.md +956 -101
  179. package/kits/hub-game/docs/home-pieces.md +5 -6
  180. package/kits/hub-game/docs/observed-progress.md +49 -1
  181. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  182. package/kits/hub-game/index.html +1 -0
  183. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  184. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  185. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  186. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  187. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  188. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  189. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  190. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  207. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  208. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  209. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  210. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  211. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  212. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  213. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  214. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  215. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  216. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  217. package/kits/hub-game/package-lock.json +3 -3
  218. package/kits/hub-game/package.json +4 -3
  219. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  220. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  221. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  222. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  223. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  224. package/kits/hub-game/scripts/pack.mjs +89 -23
  225. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  226. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  227. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  228. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  229. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  230. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  231. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  232. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  233. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  234. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  235. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  236. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  237. package/kits/hub-game/scripts/test-analytics.mjs +79 -0
  238. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  239. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  240. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  241. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  242. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  243. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  244. package/kits/hub-game/scripts/test-ballot.mjs +421 -4
  245. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  246. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  247. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  248. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  249. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  250. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  251. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  252. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  253. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  254. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  255. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  256. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  257. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  258. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  259. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  260. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  261. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  262. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  263. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  264. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  265. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  266. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  267. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  268. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  269. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  270. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  271. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  272. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  273. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  274. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  275. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  276. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  277. package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
  278. package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
  279. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  280. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  281. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  282. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  283. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  284. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  285. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  286. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  287. package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
  288. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  289. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  290. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  291. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  292. package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
  293. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  294. package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
  295. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  296. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  297. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  298. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  299. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  300. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  301. package/kits/hub-game/scripts/test-rehello.mjs +242 -3
  302. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  303. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  304. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  305. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  306. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  307. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  308. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  309. package/kits/hub-game/scripts/test-role-client.mjs +2 -1
  310. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  311. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  312. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  313. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  314. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  315. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  316. package/kits/hub-game/scripts/test-standing.mjs +135 -2
  317. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  318. package/kits/hub-game/scripts/test-stuck.mjs +36 -1
  319. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  320. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  321. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  322. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  323. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  324. package/kits/hub-game/scripts/test-together.mjs +11 -0
  325. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  326. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  327. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  328. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  329. package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
  330. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  331. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  332. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  333. package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
  334. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  335. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  336. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  337. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  338. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  339. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
  340. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
  341. package/kits/multiplayer-3d/castle.json +5 -5
  342. package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
  343. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  344. package/kits/multiplayer-3d/code/server/world.js +19 -4
  345. package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
  346. package/kits/multiplayer-3d/package-lock.json +1 -1
  347. package/kits/multiplayer-3d/package.json +2 -1
  348. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  349. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  350. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  351. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
  352. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  353. package/kits/physics-2d/castle.json +2 -2
  354. package/kits/physics-2d/engine/scene.js +10 -2
  355. package/kits/physics-3d/CLAUDE.md +14 -0
  356. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  357. package/kits/physics-3d/castle.json +3 -3
  358. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  359. package/kits/physics-3d/docs/engine-player.md +76 -0
  360. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  361. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  362. package/kits/physics-3d/engine3d/gait.js +16 -8
  363. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  364. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  365. package/kits/physics-3d/engine3d/look.js +110 -17
  366. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  367. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  368. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  369. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  370. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  371. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  372. package/kits/physics-3d/engine3d/optimize.js +20 -9
  373. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  374. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  375. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  376. package/kits/physics-3d/engine3d/world3d.js +211 -17
  377. package/kits/physics-3d/package-lock.json +1 -1
  378. package/kits/physics-3d/package.json +2 -1
  379. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  380. package/kits/physics-3d/scripts/render.mjs +56 -8
  381. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  382. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  383. package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
  384. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  385. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  386. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  387. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  388. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  389. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  390. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  391. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  392. package/kits/physics-3d/systems/physics3d.js +59 -2
  393. package/kits/real-time/castle.json +2 -2
  394. package/kits/real-time/code/client/connection.js +3 -0
  395. package/package.json +2 -2
  396. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -37,8 +37,10 @@ const RISE_M = 2;
37
37
  // Objects wider than this (metres from centre to edge) are not offered.
38
38
  const MAX_EXTENT = 2;
39
39
  // How fast a held object follows its hold point: a pickup eases in rather
40
- // than jumping, so each owner report stays far inside the server's limit on
41
- // how far an owned object may move between reports.
40
+ // than jumping. The speed alone does not keep the ease-in inside the server's
41
+ // limit on how far an owned object may move between reports (reports bunched
42
+ // by the network get no time at all), so the ease-in is also bounded by what
43
+ // the server has acknowledged, as the aimed throw's swing is (`ease`).
42
44
  const CARRY_SPEED = 20;
43
45
  // A throw's upward part, as a share of its speed.
44
46
  const THROW_UP = 0.25;
@@ -93,18 +95,19 @@ export const KEEP_TELL_MS = 1000;
93
95
  // never lost. The server judges a throw from the pose it last heard.
94
96
  export const AIM_WAIT_MS = 150;
95
97
  export const AIM_GIVE_UP_MS = 2000;
96
- // How far (metres, in a straight line) the swing may put the held object
97
- // from anywhere the server's body for it may be. multiplayer-3d checks each
98
- // owned-object report against where its kinematic body is when the report
99
- // arrives: no farther than MAX_OBJECT_SPEED (40 m/s) times the server time
100
- // since the last report, plus MOVE_SLACK (0.6 m); a report past that takes
101
- // the object away and ends the hold. Reports bunched by the network between
102
- // two physics steps get no time at all, only the 0.6 m, and the body moves
103
- // only at a step, to the newest report applied before it. So the swing never
104
- // counts on time, and puts the object within this of every position this
105
- // client has reported since the one the body is sure to have reached (see
106
- // `reach`): wherever among them the body is, the next report is inside the
107
- // bound. The report carries exactly where the swing put the object (the
98
+ // How far (metres, in a straight line) the swing, and the pickup's ease-in
99
+ // (`ease`), may put the held object from anywhere the server's body for it
100
+ // may be. multiplayer-3d checks each owned-object report against where its
101
+ // kinematic body is when the report arrives: no farther than MAX_OBJECT_SPEED
102
+ // (40 m/s) times the server time since the last report, plus MOVE_SLACK
103
+ // (0.6 m); a report past that takes the object away and ends the hold.
104
+ // Reports bunched by the network between two physics steps get no time at
105
+ // all, only the 0.6 m, and the body moves only at a step, to the newest
106
+ // report applied before it. So the swing and the ease-in never count on
107
+ // time, and put the object within this of every position this client has
108
+ // reported since the one the body is sure to have reached (see `reach`):
109
+ // wherever among them the body is, the next report is inside the bound. The
110
+ // report carries exactly where the swing or the ease-in put the object (the
108
111
  // client's physics runs before this system, the report after it); the rest
109
112
  // of the 0.6 m is margin.
110
113
  export const AIM_SLACK_M = 0.5;
@@ -117,9 +120,12 @@ const AIM_FACE_RAD = 1 * DEG;
117
120
  // height, and how far it hovers.
118
121
  const PLAYER = { radius: 0.35, height: 1.4, hover: 0.15 };
119
122
 
120
- export function makeGrab(chrome) {
123
+ // `refuse` (v1.204) is true, having said why, when a press must wait on the
124
+ // server's progress read.
125
+ export function makeGrab(chrome, refuse = () => false) {
121
126
  const t = {
122
127
  chrome,
128
+ refuse,
123
129
  held: null,
124
130
  net: null,
125
131
  pressed: false,
@@ -153,6 +159,8 @@ export function makeGrab(chrome) {
153
159
  return {
154
160
  frame: (scene, mp, local, idle, pauseCarry = false) => frame(t, scene, mp, local, idle, pauseCarry),
155
161
  holding: () => t.held?.id ?? null,
162
+ // For tests: how many reports of the hold are kept (`listen`).
163
+ trailLength: () => t.held?.sent?.trail.length ?? 0,
156
164
  perform(id, scene, mp, local, op, onThrow) {
157
165
  const body = scene.physics3d?.bodyOf(id), actor = scene.getActor(id);
158
166
  if (!body || !actor || !mp.own?.mine?.has(id)) {return false;}
@@ -164,8 +172,8 @@ export function makeGrab(chrome) {
164
172
  else {throwHeld(t, scene, body, local, config, { send() {} }, performance.now());}
165
173
  } else if (op === 'grab' && !t.held) {
166
174
  const at = body.translation(), size = sizeOf(actor.components.Shape);
167
- t.held = { id, ...size, at: { ...at } };
168
- carry(t, scene, body, local, config, 0);
175
+ t.held = { id, ...size, at: { ...at }, ease: { last: performance.now() + AIM_GIVE_UP_MS } };
176
+ ease(t, scene, mp, body, local, config, 0, performance.now());
169
177
  }
170
178
  return true;
171
179
  },
@@ -178,8 +186,11 @@ function frame(t, scene, mp, local, idle, pauseCarry) {
178
186
  const dt = Math.min(0.1, Math.max(0, (now - (t.lastAt || now)) / 1000));
179
187
  t.lastAt = now;
180
188
  // A press counts in the frame it lands in, and only for what is offered then.
181
- const pressed = t.pressed;
189
+ const pressed = t.pressed && !t.refuse();
182
190
  t.pressed = false;
191
+ // v1.204: nothing is grabbed while the server reads progress, a press
192
+ // queued before it included.
193
+ if (hub.catching != null) {t.waiting = null;}
183
194
  const events = hub.grabEvents.splice(0);
184
195
  const net = mp.net ?? null;
185
196
  if (net !== t.net) {
@@ -216,11 +227,10 @@ function frame(t, scene, mp, local, idle, pauseCarry) {
216
227
  t.held = null;
217
228
  } else {
218
229
  if (paused) {delete t.held.aim; delete t.held.actThrow;}
219
- if (scene.cameraControl === 'orbit') {
220
- // What this client has told the server of the hold, for a throw's
221
- // swing to keep inside (`reach`); it changes nothing here.
222
- listen(t.held, mp);
223
- }
230
+ // What this client has told the server of the hold, for the pickup's
231
+ // ease-in and a throw's swing to keep inside (`reach`); it changes
232
+ // nothing here.
233
+ listen(t.held, mp);
224
234
  if (t.held.aim) {
225
235
  aimFrame(t, scene, mp, body, local, config, net, now, dt);
226
236
  } else if (can && pressed && scene.cameraControl === 'orbit') {
@@ -228,7 +238,7 @@ function frame(t, scene, mp, local, idle, pauseCarry) {
228
238
  } else if (can && pressed) {
229
239
  throwHeld(t, scene, body, local, config, net, now);
230
240
  } else {
231
- carry(t, scene, body, local, config, dt);
241
+ ease(t, scene, mp, body, local, config, dt, now);
232
242
  if (config.keepHeld === true) {
233
243
  // v1.25: the server keeps a held object this client's only while it
234
244
  // hears the hold goes on.
@@ -239,7 +249,7 @@ function frame(t, scene, mp, local, idle, pauseCarry) {
239
249
  }
240
250
  }
241
251
  }
242
- if (t.held && scene.cameraControl === 'orbit') {
252
+ if (t.held) {
243
253
  // Where the body is now is what the multiplayer kit's report, after
244
254
  // this system, packs if one goes out this frame (`listen`).
245
255
  put(t.held, body);
@@ -270,9 +280,10 @@ function frame(t, scene, mp, local, idle, pauseCarry) {
270
280
  extent: target.extent,
271
281
  half: target.half,
272
282
  at: { x: at.x, y: at.y, z: at.z },
283
+ ease: { last: now + AIM_GIVE_UP_MS },
273
284
  };
274
285
  net.send({ k: 'hub-grab', actor: target.id, op: 'grab' });
275
- carry(t, scene, phys.bodyOf(target.id), local, config, dt);
286
+ ease(t, scene, mp, phys.bodyOf(target.id), local, config, dt, now);
276
287
  t.chrome.grabPrompt?.('Throw');
277
288
  return;
278
289
  }
@@ -322,9 +333,10 @@ function steadyFrame(t, scene, mp, local, config, net, active, pressed, now, dt)
322
333
  extent: ready.extent,
323
334
  half: ready.half,
324
335
  at: { x: at.x, y: at.y, z: at.z },
336
+ ease: { last: now + AIM_GIVE_UP_MS },
325
337
  };
326
338
  net.send({ k: 'hub-grab', actor: ready.id, op: 'grab' });
327
- carry(t, scene, body, local, config, dt);
339
+ ease(t, scene, mp, body, local, config, dt, now);
328
340
  t.chrome.grabPrompt?.('Throw');
329
341
  }
330
342
 
@@ -469,6 +481,50 @@ function carry(
469
481
  return k === 1;
470
482
  }
471
483
 
484
+ // A held object's carry while the pickup eases in: from where it lay to its
485
+ // hold point, which may be metres at the carry speed, it goes only as fast as
486
+ // the server hears it, as the aimed throw's swing does (AIM_SLACK_M, below):
487
+ // never more than AIM_SLACK_M, in a straight line, from any position this
488
+ // client has reported since the one the server's body is sure to have reached
489
+ // (`reach`), at rest where it is put, and not at all while no such report is
490
+ // known (the frame of the grab itself among them). The ease-in is over, for
491
+ // the rest of the hold, once the object first gets to the hold point, or
492
+ // AIM_GIVE_UP_MS after the grab (a player who walks off faster than the bound
493
+ // lets it follow is never left with the object stuck behind them); from then
494
+ // on, and throughout with a multiplayer kit without acknowledgements or
495
+ // report numbers, it is the plain carry at the carry speed.
496
+ function ease(t, scene, mp, body, local, config, dt, now) {
497
+ const held = t.held;
498
+ const places = held.ease && now < held.ease.last ? reach(held, mp) : null;
499
+ if (places === null) {
500
+ if (carry(t, scene, body, local, config, dt)) {
501
+ delete held.ease;
502
+ }
503
+ return;
504
+ }
505
+ const to = holdPoint(local, config, held);
506
+ const full = CARRY_SPEED * dt;
507
+ let most = 0;
508
+ if (places !== false) {
509
+ const from = held.at;
510
+ const d = Math.hypot(to.x - from.x, to.y - from.y, to.z - from.z);
511
+ // Where `carry` puts it going at most m.
512
+ most = farthest(places, full, (m) => {
513
+ const k = d > m && d > 0 ? m / d : 1;
514
+ return {
515
+ x: from.x + (to.x - from.x) * k,
516
+ y: from.y + (to.y - from.y) * k,
517
+ z: from.z + (to.z - from.z) * k,
518
+ };
519
+ });
520
+ }
521
+ if (carry(t, scene, body, local, config, dt, to, most)) {
522
+ delete held.ease;
523
+ }
524
+ // Reported at rest where it is put, as the swing is.
525
+ body.setLinvel({ x: 0, y: 0, z: 0 }, true);
526
+ }
527
+
472
528
  // Let go along the player's facing at `throwSpeed`, a little upward (or
473
529
  // along `f`, radians, for an aimed throw).
474
530
  function throwHeld(
@@ -610,23 +666,7 @@ function swing(t, scene, mp, body, local, config, dt) {
610
666
  if (places === false) {
611
667
  most = 0;
612
668
  } else if (places !== null) {
613
- const fits = (p) =>
614
- places.every((q) => Math.hypot(p.x - q.x, p.y - q.y, p.z - q.z) <= AIM_SLACK_M);
615
- if (!fits(step(full).next)) {
616
- // The farthest that fits, to well under a millimetre; none, when even a
617
- // little way does not (the object stays where it was last reported).
618
- let lo = 0;
619
- let hi = full;
620
- for (let i = 0; i < 24; i += 1) {
621
- const mid = (lo + hi) / 2;
622
- if (fits(step(mid).next)) {
623
- lo = mid;
624
- } else {
625
- hi = mid;
626
- }
627
- }
628
- most = lo;
629
- }
669
+ most = farthest(places, full, (m) => step(m).next);
630
670
  }
631
671
  const { a, to } = step(most);
632
672
  aim.a = a;
@@ -639,11 +679,36 @@ function swing(t, scene, mp, body, local, config, dt) {
639
679
  return reached && aim.a === aim.f;
640
680
  }
641
681
 
682
+ // How far, up to `full` metres, a held object may go this frame and stay
683
+ // within AIM_SLACK_M of every one of `places`, where `next(most)` is where
684
+ // going at most `most` puts it: the whole way when that fits, else the
685
+ // farthest that fits, to well under a millimetre; none, when even a little
686
+ // way does not (the object stays where it was last reported). The pickup's
687
+ // ease-in and the throw's swing alike.
688
+ function farthest(places, full, next) {
689
+ const fits = (p) =>
690
+ places.every((q) => Math.hypot(p.x - q.x, p.y - q.y, p.z - q.z) <= AIM_SLACK_M);
691
+ if (fits(next(full))) {
692
+ return full;
693
+ }
694
+ let lo = 0;
695
+ let hi = full;
696
+ for (let i = 0; i < 24; i += 1) {
697
+ const mid = (lo + hi) / 2;
698
+ if (fits(next(mid))) {
699
+ lo = mid;
700
+ } else {
701
+ hi = mid;
702
+ }
703
+ }
704
+ return lo;
705
+ }
706
+
642
707
  // What this client has told the server about a held object, kept frame by
643
- // frame under the orbit key while it is held: `trail`, `[report number,
644
- // position]` for each movement report since the hold began (carry and swing
645
- // alike), known from report number `from` on; and `sure`, the newest report
646
- // the server's body is sure to have reached (`reach`). The position is the one
708
+ // frame while it is held: `trail`, `[report number, position]` for each
709
+ // movement report since the hold began (ease-in, carry and swing alike),
710
+ // known from report number `from` on; and `sure`, the newest report the
711
+ // server's body is sure to have reached (`reach`). The position is the one
647
712
  // the report carried: the body where this system left it the frame the report
648
713
  // went out (`put`), which the multiplayer kit reads straight after, before the
649
714
  // next frame's physics moves it on at its velocity. Never the body read back a
@@ -690,6 +755,12 @@ function listen(held, mp) {
690
755
  ) {
691
756
  sent.sure = Math.max(sent.sure, ack[1]);
692
757
  }
758
+ // Reports before the one the body is sure to have reached are behind it for
759
+ // good: dropped here, every frame, so a long hold keeps only the few in
760
+ // flight, whether or not anything reads them (`reach`).
761
+ while (sent.trail.length > 0 && sent.trail[0][0] < sent.sure) {
762
+ sent.trail.shift();
763
+ }
693
764
  }
694
765
 
695
766
  // The body of a held object where this system leaves it this frame: the
@@ -704,8 +775,8 @@ function put(held, body) {
704
775
  // Every place the server's body for a held object may be when the next
705
776
  // report reaches it: the reported positions from the newest one it is sure to
706
777
  // have reached on. null when the multiplayer kit gives no acknowledgements
707
- // or report numbers (the swing is unbounded, as before them); false when no
708
- // such report is known yet.
778
+ // or report numbers (the swing and the ease-in are unbounded, as before
779
+ // them); false when no such report is known yet.
709
780
  //
710
781
  // An acknowledgement alone is not a body moved. multiplayer-3d applies a
711
782
  // report as it arrives (its kinematic target, stamped with the simulation
@@ -0,0 +1,19 @@
1
+ // Pure catalogue, shared with the server. Flowers never occupy Earned.
2
+ export const HOLD_SHOW_SHAPES = Object.freeze(['daisy', 'tulip', 'sunflower', 'rose', 'moonflower']);
3
+ export const holdShowFile = (shape, square = false) => `models/hold-show/${square ? 'square/' : ''}${shape}.pxmodel`;
4
+ export function holdShowLook(item, fit = null) {
5
+ if (!HOLD_SHOW_SHAPES.includes(item?.shape) || typeof item?.color !== 'string' || item.color.length !== 7 || !/^#[0-9a-f]{6}$/i.test(item.color)) { return null; }
6
+ const [x, y, z] = fit?.hand ?? [-0.33, 0.34, 0.01];
7
+ return { shape: item.shape, file: holdShowFile(item.shape, fit?.square === true), color: item.color.toLowerCase(),
8
+ position: [x, Math.round((y - 0.7) * 1000) / 1000, z], yaw: 0, tilt: 0, scale: [1.2, 1.2, 1.2] };
9
+ }
10
+ export function holdShowMap(wire) {
11
+ return new Map(Object.entries(wire ?? {}).filter(([, v]) => Array.isArray(v) && v.length === 2 && holdShowLook({ shape: v[0], color: v[1] }))
12
+ .map(([id, [shape, color]]) => [id, { shape, color }]));
13
+ }
14
+ export function holdShowVisible(shows, roles, self, grabbing) {
15
+ return new Map([...shows].filter(([id]) => !roles.get(id)?.tool && !(id === self && grabbing)));
16
+ }
17
+ export function holdShowEarned(earned, shows) {
18
+ return shows.size ? new Map([...earned].filter(([id, item]) => item?.class !== 'held' || !shows.has(id))) : earned;
19
+ }
@@ -5,18 +5,20 @@
5
5
  // draws it.
6
6
 
7
7
  import * as castleSdk from 'castle-web-sdk';
8
+ import * as Celebrate from './celebrate.js';
8
9
  import * as Avatars from '@imports/castle.multiplayer-3d/code/client/avatars.js';
9
10
  import * as Avatar from './avatar.js';
10
11
  import * as AvatarCap from './avatarCap.js';
11
12
  import { mergeDictionary } from './interestCap.js';
12
13
  import * as Cabinets from './cabinets.js';
13
14
  import { firstJoinFor } from './firstJoin.js';
14
- import { deck, earnedNow, hub, localArrival, mergeHidden, receiveParty, rolesNow, wearingNow } from './state.js';
15
+ import { deck, earnedNow, hub, holdShowsNow, idleNow, localArrival, mergeHidden, receiveParty, replayCleanup, rolesNow, wearingNow } from './state.js';
15
16
  import { clearShot, receiveShot } from './shot.js';
16
17
  import * as Ballot from './ballot.js';
18
+ import { holdShowMap } from './holdShow.js';
17
19
  import * as Rehello from './rehello.js';
18
20
  import { guestName } from './signIn.js';
19
- import { sanitise, ownStamp } from './companion.js';
21
+ import { sanitise, ownStamp, chirpMap } from './companion.js';
20
22
  import { buildStamp } from './build.js';
21
23
  import { unpackFrame } from './frameBatch.js';
22
24
  import { setFpsTelemetry } from './fpsTelemetry.js';
@@ -25,6 +27,7 @@ import { readQuality } from '../shared/quality.js';
25
27
  import { noteQualityInteraction } from './quality.js';
26
28
  import { parseCar, vehicleOf } from '../shared/car.js';
27
29
  import { pinRiders } from './riders.js';
30
+ import { disguiseMap } from './disguise.js';
28
31
  import { readDanceIdle } from '../shared/danceIdle.js';
29
32
 
30
33
  // Root-anchored: the deck's own castle.json once this kit is imported.
@@ -111,6 +114,15 @@ let drawnStyle = null;
111
114
  // Everyone's avatars with this player's own over them. A player whose avatar
112
115
  // changed is dropped and respawns in the new one.
113
116
  // A `hubAv2` block (v1.51) as a map, or an empty one for anything else.
117
+ // The camera turns to look along a facing the place chose (a jump, v1.190's
118
+ // turnCamera hold). Under the engine's orbit camera key the facing is asked for.
119
+ function turnTo(scene, facing) {
120
+ (scene.persistent ??= {}).camAngle = Math.PI - facing;
121
+ if (scene.cameraControl === 'orbit') {
122
+ scene.faceRequest = facing;
123
+ }
124
+ }
125
+
114
126
  function realAvatars(block) {
115
127
  return new Map(Object.entries(block && typeof block === 'object' ? block : {}));
116
128
  }
@@ -189,6 +201,11 @@ function stuckAnswer(msg) {
189
201
  return { spot: msg.spot === true, to: typeof msg.to === 'string' && msg.to ? msg.to.slice(0, 40) : null };
190
202
  }
191
203
 
204
+ // A `hub-idle` block: a plain object, or none.
205
+ function idleMap(value) {
206
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
207
+ }
208
+
192
209
  function wearMap(value) {
193
210
  return new Map(Object.entries(value && typeof value === 'object' ? value : {}));
194
211
  }
@@ -279,11 +296,18 @@ const hooks = {
279
296
  case 'hub-invite':
280
297
  if (hub.place?.invite === true) {hub.commands.push({ k: 'hub-invite', ...(msg.share === true ? { share: true } : {}) });}
281
298
  break;
299
+ case 'hub-stayed':
300
+ // v1.169: the place's answer to a numbered hub-stay.
301
+ if (Number.isSafeInteger(msg.end)) {hub.commands.push(msg);}
302
+ break;
282
303
  case 'hub-go':
283
304
  case 'hub-end':
284
305
  case 'hub-result':
285
306
  if (msg.k !== 'hub-result') {
307
+ Celebrate.clear();
286
308
  clearShot();
309
+ // v1.169: whether it overlapped an absence is known only now.
310
+ Rehello.noteArrival(msg, scene.multiplayer);
287
311
  }
288
312
  hub.commands.push(msg);
289
313
  break;
@@ -296,18 +320,21 @@ const hooks = {
296
320
  case 'hub-hud':
297
321
  hub.hudMe = msg.hud ?? null;
298
322
  break;
323
+ case 'hub-progress':
324
+ // v1.204: kept from the first `true` until a `false`.
325
+ hub.catching = msg.catching === true ? (hub.catching ?? performance.now()) : null;
326
+ break;
299
327
  case 'hub-arrived':
300
328
  hub.arrivedFacing = typeof msg.facing === 'number' ? msg.facing : 0;
301
329
  break;
330
+ case 'hub-hold-face':
331
+ // v1.190: a hold with turnCamera, and its release, turn this player's
332
+ // avatar to the held facing exactly as a jump does.
333
+ if (Number.isFinite(msg.facing)) {turnTo(scene, msg.facing);}
334
+ break;
302
335
  case 'hub-jumped':
303
336
  // A jump to a door: the camera turns to look at it.
304
- if (typeof msg.facing === 'number') {
305
- (scene.persistent ??= {}).camAngle = Math.PI - msg.facing;
306
- // Under the engine's orbit camera key the facing is asked for.
307
- if (scene.cameraControl === 'orbit') {
308
- scene.faceRequest = msg.facing;
309
- }
310
- }
337
+ if (typeof msg.facing === 'number') {turnTo(scene, msg.facing);}
311
338
  // Beside a player: the hub system says whom (a start next to a friend).
312
339
  if (typeof msg.to === 'string') {
313
340
  hub.jumpedTo = msg.to;
@@ -361,10 +388,25 @@ const hooks = {
361
388
  hub.avatarColorsMe = realAvatars(msg.hubAvC);
362
389
  setAvatars(netSystem?.scene ?? scene, netSystem?.system ?? null);
363
390
  break;
391
+ case 'hub-idle':
392
+ // v1.183: seats, emotes and holds of players in a hidden pair this
393
+ // player may see, whole each time, laid over the shared fields.
394
+ hub.seatedMe = idleMap(msg.hubSeated);
395
+ hub.emotesMe = idleMap(msg.hubEmotes);
396
+ hub.heldMe = new Set(Array.isArray(msg.held) ? msg.held.filter((id) => typeof id === 'string') : []);
397
+ idleNow();
398
+ break;
364
399
  case 'hub-wear':
365
400
  hub.wearMe = wearMap(msg.hubWear);
366
401
  setWearing();
367
402
  break;
403
+ case 'hub-replay':
404
+ replayCleanup.receive(scene, msg.slot, msg.replay);
405
+ break;
406
+ case 'hub-hold-show':
407
+ hub.holdShowMe = holdShowMap(msg.hubHoldShow);
408
+ hub.holdShows = holdShowsNow();
409
+ break;
368
410
  case 'hub-role':
369
411
  hub.roleMe = wearMap(msg.hubRole);
370
412
  hub.roles = rolesNow();
@@ -389,6 +431,7 @@ const hooks = {
389
431
  case 'hub-vis':
390
432
  hub.hiddenMe = new Set(Array.isArray(msg.hide) ? msg.hide : []);
391
433
  hub.shownMe = new Set(Array.isArray(msg.show) ? msg.show : []);
434
+ hub.solidMe = new Set(Array.isArray(msg.solid) ? msg.solid : []);
392
435
  mergeHidden();
393
436
  break;
394
437
  case 'hub-npc':
@@ -413,6 +456,11 @@ const hooks = {
413
456
  hub.soundEvents.push(msg);
414
457
  }
415
458
  break;
459
+ case 'celebrate':
460
+ if (!Celebrate.receive(scene, msg)) {break;}
461
+ // Its chime is the token cue, under the cue message's own gates.
462
+ msg = { k: 'hub-cue', cue: 'token' };
463
+ // falls through
416
464
  case 'hub-cue':
417
465
  // Independent of audio mute/gesture gates; private transport only.
418
466
  if (hub.place?.companion === true && hub.companion?.c && ownStamp(msg)) {
@@ -449,6 +497,17 @@ const hooks = {
449
497
  )) {
450
498
  hub.arrivalPlaced = true;
451
499
  }
500
+ // v1.165 fix: this client's own clamped row carries the server's facing,
501
+ // which multiplayer does not apply to the local player; a driver's car
502
+ // takes it when the clamp is a placement (vehicle.js `placedHeading`).
503
+ for (const row of msg.ps ?? []) {
504
+ if (row?.[0] === system?.net?.selfId?.() && Boolean(row[5]) && Number.isFinite(row[4])) {
505
+ hub.selfClamp = { x: row[1], y: row[2], z: row[3], facing: row[4], at: performance.now() };
506
+ }
507
+ }
508
+ // v1.163: every admission's WORLD starts with no ghosts, hello or not;
509
+ // the server holds none for a connection it has not sent them on.
510
+ if (msg.k === 'w' && msg.again !== 1) {replayCleanup.clear();}
452
511
  if (msg.hubPlace) {
453
512
  setFpsTelemetry(system?.net, msg.hubPlace.fpsTelemetry);
454
513
  setLoadTelemetry(system?.net, msg.hubPlace.loadTelemetry);
@@ -478,6 +537,7 @@ const hooks = {
478
537
  if (hub.place.companion !== true) {
479
538
  delete hub.companion;
480
539
  delete hub.glow;
540
+ delete hub.chirp;
481
541
  }
482
542
  if (hub.place.ask !== true && Object.hasOwn(hub, 'ask')) {
483
543
  hub.askClose?.();
@@ -551,6 +611,11 @@ const hooks = {
551
611
  } else if (msg.hubPlace) {
552
612
  delete hub.glow;
553
613
  }
614
+ if (Array.isArray(msg.hubChirp)) {
615
+ hub.chirp = chirpMap(msg.hubChirp);
616
+ } else if (msg.hubPlace) {
617
+ delete hub.chirp;
618
+ }
554
619
  }
555
620
  if (msg.hubWear) {
556
621
  hub.wearAll = wearMap(msg.hubWear);
@@ -573,6 +638,13 @@ const hooks = {
573
638
  hub.tryAll = new Map();
574
639
  setWearing();
575
640
  }
641
+ if (msg.hubHoldShow && typeof msg.hubHoldShow === 'object') {
642
+ hub.holdShowAll = holdShowMap(msg.hubHoldShow);
643
+ hub.holdShows = holdShowsNow();
644
+ } else if (msg.hubPlace && hub.holdShowAll.size > 0) {
645
+ hub.holdShowAll.clear();
646
+ hub.holdShows = holdShowsNow();
647
+ }
576
648
  // v1.157: snapshots clear only the shared block, as hubTry does.
577
649
  if (msg.hubRole && typeof msg.hubRole === 'object') {
578
650
  hub.roleAll = wearMap(msg.hubRole);
@@ -606,11 +678,15 @@ const hooks = {
606
678
  if (msg.spawnTemplates) {
607
679
  hub.spawnTemplates = msg.spawnTemplates;
608
680
  }
681
+ if (Array.isArray(msg.hubDecorTpl)) {
682
+ hub.decorTemplates = new Set(msg.hubDecorTpl.filter((id) => typeof id === 'string'));
683
+ }
609
684
  if (msg.spawned) {
610
685
  hub.spawned = msg.spawned;
611
686
  }
612
687
  if (msg.held) {
613
- hub.held = new Set(msg.held);
688
+ hub.heldAll = new Set(msg.held);
689
+ idleNow();
614
690
  }
615
691
  if (msg.labels) {
616
692
  hub.labels = msg.labels;
@@ -629,16 +705,20 @@ const hooks = {
629
705
  }));
630
706
  }
631
707
  else if (msg.hubPlace) {hub.cars = {};}
708
+ if (Object.hasOwn(msg, 'hubDisguise')) {hub.disguises = disguiseMap(msg.hubDisguise);}
709
+ else if (msg.hubPlace) {hub.disguises.clear();}
632
710
  // v1.6: only a place that turns idle play on sends these.
633
711
  if (msg.hubEmotes && typeof msg.hubEmotes === 'object') {
634
- hub.emotes = msg.hubEmotes;
712
+ hub.emotesAll = msg.hubEmotes;
713
+ idleNow();
635
714
  }
636
715
  // v1.47: only a place where an NPC has emoted sends this.
637
716
  if (msg.hubNpcEmotes && typeof msg.hubNpcEmotes === 'object') {
638
717
  hub.npcEmotes = msg.hubNpcEmotes;
639
718
  }
640
719
  if (msg.hubSeated && typeof msg.hubSeated === 'object') {
641
- hub.seated = msg.hubSeated;
720
+ hub.seatedAll = msg.hubSeated;
721
+ idleNow();
642
722
  }
643
723
  if (msg.hubSounds && typeof msg.hubSounds === 'object') {
644
724
  hub.sounds = msg.hubSounds;
@@ -665,9 +745,13 @@ const hooks = {
665
745
  },
666
746
 
667
747
  reset() {
748
+ Celebrate.clear();
749
+ replayCleanup.clear();
668
750
  clearShot();
669
751
  },
670
752
  dispose() {
753
+ Celebrate.clear();
754
+ replayCleanup.clear();
671
755
  clearShot();
672
756
  },
673
757
  };
@@ -34,6 +34,11 @@ export function personAction(net, person, action, { together, say, jump, jumpTo,
34
34
  // player's own House, as the pad would have.
35
35
  jump(net, { k: 'hub-house-visit', door: person.door, owner: person.owner });
36
36
  say(`Going to ${person.username ?? 'your friend'}'s House`);
37
+ } else if (action === 'door' && person.door && person.playerId && doors.find((d) => d.id === person.door)?.solo === true) {
38
+ // Someone here at a door that takes one player cannot be gone to: its
39
+ // pad would send this player into a game of their own (`together.rows`
40
+ // offers no Go there; this is the backstop for a host's own rows).
41
+ return false;
37
42
  } else if (action === 'door' && person.door) {
38
43
  jump(net, { k: 'hub-door-jump', door: person.door });
39
44
  // A friend inside the game is said to be; someone standing at the door
@@ -101,7 +106,8 @@ export function backControl({ away, idle, pendingEnd, hostTrail, place, ticket,
101
106
 
102
107
  // What a user's Back (the kit's control or the host's) does: it first closes
103
108
  // the action overflow, then the place menu; in a game it quits the door
104
- // (`hub-door-quit`) and goes back; anywhere else it goes back.
109
+ // (`hub-door-quit`) and goes back; anywhere else it ends the visit
110
+ // (`hub-back`, v1.173) and goes back.
105
111
  // Returns 'overflow' | 'menu' | 'quit' | 'back'.
106
112
  export function backPress({ overflowOpen, menuOpen, inGame }) {
107
113
  if (overflowOpen) {
@@ -34,7 +34,7 @@ export function hudInputs(hub, simNow) {
34
34
  export function makeHudSurface({ landscape = false, safeInsets = false, onBack = () => {}, promptBlocked = () => false, draw = null } = {}) {
35
35
  const state = {
36
36
  view: { landscape: Boolean(landscape), safeInsets },
37
- back: { show: false, label: 'Town' },
37
+ back: { show: false, label: 'Town', low: false },
38
38
  hud: { show: false, title: '', big: '', clock: null, prompt: '', promptShown: false },
39
39
  toast: { text: '', wrap: false },
40
40
  actPair: null,
@@ -55,7 +55,7 @@ export function makeHudSurface({ landscape = false, safeInsets = false, onBack =
55
55
  function render() {
56
56
  const { view, back: b, hud: d, toast: t, actPair: p } = state;
57
57
  const big = d.clock ? `clock:${d.clock.gen}` : d.big;
58
- const next = [view.landscape, b.show, b.label, d.show, d.title, big, d.prompt, d.promptShown, t.text, t.wrap, p ? `${p.show}${p.enabled}` : ''].join('\u0001');
58
+ const next = [view.landscape, b.show, b.label, b.low, d.show, d.title, big, d.prompt, d.promptShown, t.text, t.wrap, p ? `${p.show}${p.enabled}` : ''].join('\u0001');
59
59
  if (next === key) {return;}
60
60
  key = next;
61
61
  const tree = buildHud(state);
@@ -101,9 +101,17 @@ export function makeHudSurface({ landscape = false, safeInsets = false, onBack =
101
101
  state.view.landscape = Boolean(on);
102
102
  render();
103
103
  },
104
- showBack(show, label = 'Back') {
104
+ // Whether Back stands low (v1.186), re-read as the stage turns.
105
+ setBackLow(low) {
106
+ state.back.low = Boolean(low);
107
+ render();
108
+ },
109
+ // `low` (v1.186): the control stands at the bottom centre, out of the
110
+ // reserved Back corner.
111
+ showBack(show, label = 'Back', low = false) {
105
112
  state.back.show = Boolean(show);
106
113
  state.back.label = label;
114
+ state.back.low = Boolean(low);
107
115
  render();
108
116
  },
109
117
  // Said every frame: the root is rebuilt only when its words change, so a
@@ -26,6 +26,9 @@ const edge = (safeInsets, px) => (safeInsets ? [px, 0] : px);
26
26
  export function buildActPair(pair, safeInsets = false) {
27
27
  const show = Boolean(pair?.show);
28
28
  const enabled = Boolean(pair?.enabled);
29
+ // v1.204: catching up, Act stays pressable (a press is refused with a
30
+ // line) but dimmed, and says why on two short lines.
31
+ const catching = Boolean(pair?.catching);
29
32
  const on = pair?.on ?? {};
30
33
  const button = { h: 48, w: 64, minH: 44, pad: 8, radius: 22, border: { w: 2, c: 'rgba(255,255,255,.55)' }, bg: 'rgba(20,16,12,.88)', color: '#fff', font: 'ui', size: 14, weight: 700, lh: 'normal', box: 'border', wrap: 'none', gone: !show };
31
34
  return h('stack', {
@@ -34,11 +37,11 @@ export function buildActPair(pair, safeInsets = false) {
34
37
  style: { w: 134, h: 48, hit: 'none', gone: !show },
35
38
  },
36
39
  h('button', {
37
- key: 'act', data: { hubAct: 'act' }, disabled: !enabled,
40
+ key: 'act', data: { hubAct: 'act' }, disabled: !enabled && !catching,
38
41
  at: { anchor: 'topLeft', top: 0, left: 70 },
39
- style: { ...button, opacity: enabled ? 1 : 0.5 },
42
+ style: catching ? { ...button, opacity: 0.5, pad: 4, size: 11, lh: 1.1, wrap: 'word' } : { ...button, opacity: enabled ? 1 : 0.5 },
40
43
  on: { press: on.press, release: on.release, cancel: on.cancel },
41
- }, 'Act'),
44
+ }, catching ? 'Catching up' : 'Act'),
42
45
  h('button', {
43
46
  key: 'jump', data: { hubAct: 'jump' }, fire: 'down', keepFocus: true,
44
47
  at: { anchor: 'topLeft', top: 0, left: 0 },
@@ -61,7 +64,7 @@ export function buildHud(state) {
61
64
  return h('stack', { key: 'hud', style: { font: 'ui', size: 15, weight: 600, lh: 1.3, color: '#fff' } },
62
65
  h('button', {
63
66
  key: 'back', fire: 'down',
64
- at: { anchor: 'topLeft', top: [12, 0], left: edge(safeInsets, landscape ? 76 : 12) },
67
+ at: back.low ? { anchor: 'bottom', bottom: [12, 6] } : { anchor: 'topLeft', top: [12, 0], left: edge(safeInsets, landscape ? 76 : 12) },
65
68
  style: { pad: [9, 16, 9, 12], radius: 22, border: { w: 1, c: 'line35' }, bg: 'chip', color: '#fff', gone: !back.show },
66
69
  on: { tap: state.on?.back },
67
70
  }, `‹ ${back.label ?? 'Back'}`),