castle-web-cli 0.4.239 → 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 (386) 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/platformDoc.js +2 -1
  18. package/dist/playPagePolicy.js +5 -1
  19. package/dist/resetLeaderboards.d.ts +8 -1
  20. package/dist/resetLeaderboards.js +43 -8
  21. package/dist/save-deck.d.ts +32 -2
  22. package/dist/save-deck.js +240 -39
  23. package/kits/base/CLAUDE.md +1 -1
  24. package/kits/base/castle.json +1 -1
  25. package/kits/base/sdk/README.md +174 -6
  26. package/kits/base/sdk/analytics.d.ts +8 -0
  27. package/kits/base/sdk/analytics.js +92 -0
  28. package/kits/base/sdk/castle.d.ts +5 -1
  29. package/kits/base/sdk/castle.js +2 -0
  30. package/kits/base/sdk/commands.d.ts +48 -0
  31. package/kits/base/sdk/commands.js +1 -0
  32. package/kits/base/sdk/debugConsole.d.ts +17 -0
  33. package/kits/base/sdk/debugConsole.js +154 -0
  34. package/kits/base/sdk/experiments.js +24 -1
  35. package/kits/base/sdk/hostRetry.d.ts +7 -0
  36. package/kits/base/sdk/hostRetry.js +57 -0
  37. package/kits/base/sdk/hub.d.ts +20 -2
  38. package/kits/base/sdk/hub.js +99 -13
  39. package/kits/base/sdk/multiplayer.d.ts +2 -0
  40. package/kits/base/sdk/multiplayer.js +168 -26
  41. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  42. package/kits/base/sdk/reconnectBudget.js +41 -1
  43. package/kits/base/sdk/runtime.js +36 -19
  44. package/kits/base/sdk/server/hub.d.ts +19 -0
  45. package/kits/base/sdk/server/hub.js +12 -0
  46. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  47. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  48. package/kits/base/sdk/server/wrapper.js +26 -1
  49. package/kits/base/sdk/transport.d.ts +2 -1
  50. package/kits/base/sdk/transport.js +35 -0
  51. package/kits/hub-game/CLAUDE.md +66 -19
  52. package/kits/hub-game/code/client/act.js +9 -6
  53. package/kits/hub-game/code/client/actCore.js +26 -6
  54. package/kits/hub-game/code/client/actGateLog.js +36 -0
  55. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  56. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  57. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  58. package/kits/hub-game/code/client/askSurface.js +85 -0
  59. package/kits/hub-game/code/client/askTree.js +51 -0
  60. package/kits/hub-game/code/client/attention.js +31 -6
  61. package/kits/hub-game/code/client/ballot.js +42 -5
  62. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  63. package/kits/hub-game/code/client/ballotTree.js +180 -0
  64. package/kits/hub-game/code/client/catchingUp.js +19 -0
  65. package/kits/hub-game/code/client/celebrate.js +66 -0
  66. package/kits/hub-game/code/client/chrome.js +473 -53
  67. package/kits/hub-game/code/client/companion.js +93 -23
  68. package/kits/hub-game/code/client/companionDress.js +1 -1
  69. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  70. package/kits/hub-game/code/client/cornerTree.js +83 -0
  71. package/kits/hub-game/code/client/decor.js +20 -11
  72. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  73. package/kits/hub-game/code/client/disguise.js +23 -0
  74. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  75. package/kits/hub-game/code/client/dockSurface.js +206 -0
  76. package/kits/hub-game/code/client/dockTree.js +232 -0
  77. package/kits/hub-game/code/client/earned.js +29 -0
  78. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  79. package/kits/hub-game/code/client/emoteTree.js +264 -0
  80. package/kits/hub-game/code/client/farAvatars.js +4 -3
  81. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  82. package/kits/hub-game/code/client/grab.js +121 -50
  83. package/kits/hub-game/code/client/holdShow.js +19 -0
  84. package/kits/hub-game/code/client/hookLayer.js +96 -12
  85. package/kits/hub-game/code/client/hubControls.js +7 -1
  86. package/kits/hub-game/code/client/hudSurface.js +11 -3
  87. package/kits/hub-game/code/client/hudTree.js +7 -4
  88. package/kits/hub-game/code/client/idle.js +21 -3
  89. package/kits/hub-game/code/client/invites.js +24 -3
  90. package/kits/hub-game/code/client/keys.js +15 -0
  91. package/kits/hub-game/code/client/labelsNear.js +8 -1
  92. package/kits/hub-game/code/client/layoutCache.js +57 -8
  93. package/kits/hub-game/code/client/loadingCover.js +53 -4
  94. package/kits/hub-game/code/client/menuIcons.js +15 -0
  95. package/kits/hub-game/code/client/menuSurface.js +102 -0
  96. package/kits/hub-game/code/client/menuTree.js +135 -0
  97. package/kits/hub-game/code/client/modelLook.js +41 -0
  98. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  99. package/kits/hub-game/code/client/pickerTree.js +163 -0
  100. package/kits/hub-game/code/client/pushVisit.js +4 -2
  101. package/kits/hub-game/code/client/quality.js +188 -29
  102. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  103. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  104. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  105. package/kits/hub-game/code/client/rehello.js +75 -0
  106. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  107. package/kits/hub-game/code/client/replay.js +118 -0
  108. package/kits/hub-game/code/client/role.js +3 -0
  109. package/kits/hub-game/code/client/safeLayout.js +441 -56
  110. package/kits/hub-game/code/client/safeStyle.js +13 -10
  111. package/kits/hub-game/code/client/say.js +2 -0
  112. package/kits/hub-game/code/client/soundSurface.js +77 -0
  113. package/kits/hub-game/code/client/soundTree.js +74 -0
  114. package/kits/hub-game/code/client/soundscape.js +12 -9
  115. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  116. package/kits/hub-game/code/client/state.js +67 -1
  117. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  118. package/kits/hub-game/code/client/stuckTree.js +67 -0
  119. package/kits/hub-game/code/client/talk.js +42 -12
  120. package/kits/hub-game/code/client/talkTree.js +4 -2
  121. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  122. package/kits/hub-game/code/client/textAskTree.js +67 -0
  123. package/kits/hub-game/code/client/tiers.js +252 -27
  124. package/kits/hub-game/code/client/together.js +4 -1
  125. package/kits/hub-game/code/client/uiDom.js +86 -8
  126. package/kits/hub-game/code/client/uiTree.js +33 -4
  127. package/kits/hub-game/code/client/vehicle.js +72 -51
  128. package/kits/hub-game/code/client/weakestTier.js +75 -31
  129. package/kits/hub-game/code/client/wear.js +159 -5
  130. package/kits/hub-game/code/client/worldLabels.js +205 -25
  131. package/kits/hub-game/code/companionSpec.js +4 -2
  132. package/kits/hub-game/code/server/act.js +3 -0
  133. package/kits/hub-game/code/server/actGate.js +83 -0
  134. package/kits/hub-game/code/server/actions.js +71 -15
  135. package/kits/hub-game/code/server/actors.js +20 -5
  136. package/kits/hub-game/code/server/analytics.js +35 -3
  137. package/kits/hub-game/code/server/ask.js +39 -3
  138. package/kits/hub-game/code/server/ballot.js +167 -4
  139. package/kits/hub-game/code/server/celebrate.js +64 -0
  140. package/kits/hub-game/code/server/companion.js +17 -2
  141. package/kits/hub-game/code/server/decor.js +11 -2
  142. package/kits/hub-game/code/server/disguise.js +63 -0
  143. package/kits/hub-game/code/server/earned.js +6 -2
  144. package/kits/hub-game/code/server/friendBests.js +13 -4
  145. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  146. package/kits/hub-game/code/server/grab.js +12 -2
  147. package/kits/hub-game/code/server/heldOffers.js +142 -0
  148. package/kits/hub-game/code/server/holdShow.js +98 -0
  149. package/kits/hub-game/code/server/hub.js +851 -45
  150. package/kits/hub-game/code/server/idle.js +110 -9
  151. package/kits/hub-game/code/server/index.js +9 -0
  152. package/kits/hub-game/code/server/labels.js +13 -3
  153. package/kits/hub-game/code/server/manifest.js +94 -6
  154. package/kits/hub-game/code/server/menu.js +26 -3
  155. package/kits/hub-game/code/server/npcs.js +55 -9
  156. package/kits/hub-game/code/server/observe.js +67 -6
  157. package/kits/hub-game/code/server/players.js +8 -1
  158. package/kits/hub-game/code/server/replay.js +135 -0
  159. package/kits/hub-game/code/server/storageLimit.js +4 -1
  160. package/kits/hub-game/code/server/townDay.js +74 -0
  161. package/kits/hub-game/code/server/vehicle.js +3 -0
  162. package/kits/hub-game/code/server/vis.js +26 -4
  163. package/kits/hub-game/code/server/wallet.js +677 -0
  164. package/kits/hub-game/code/server/wear.js +13 -3
  165. package/kits/hub-game/code/server/writerLease.js +191 -0
  166. package/kits/hub-game/code/shared/act.js +1 -1
  167. package/kits/hub-game/code/shared/expression.js +6 -0
  168. package/kits/hub-game/code/shared/replay.js +37 -0
  169. package/kits/hub-game/code/systems/hub.js +427 -54
  170. package/kits/hub-game/docs/analytics.md +16 -2
  171. package/kits/hub-game/docs/contract.md +942 -99
  172. package/kits/hub-game/docs/home-pieces.md +5 -6
  173. package/kits/hub-game/docs/observed-progress.md +49 -1
  174. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  175. package/kits/hub-game/index.html +1 -0
  176. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  177. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  178. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  179. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  180. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  181. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  182. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  183. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  184. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  185. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  186. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  187. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  188. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  189. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  190. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  200. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  201. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  202. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  203. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  204. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  205. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  206. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  207. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  208. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  209. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  210. package/kits/hub-game/package-lock.json +3 -3
  211. package/kits/hub-game/package.json +4 -3
  212. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  213. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  214. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  215. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  216. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  217. package/kits/hub-game/scripts/pack.mjs +89 -23
  218. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  219. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  220. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  221. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  222. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  223. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  224. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  225. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  226. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  227. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  228. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  229. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  230. package/kits/hub-game/scripts/test-analytics.mjs +79 -0
  231. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  232. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  233. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  234. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  235. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  236. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  237. package/kits/hub-game/scripts/test-ballot.mjs +420 -3
  238. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  239. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  240. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  241. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  242. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  243. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  244. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  245. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  246. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  247. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  248. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  249. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  250. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  251. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  252. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  253. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  254. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  255. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  256. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  257. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  258. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  259. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  260. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  261. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  262. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  263. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  264. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  265. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  266. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  267. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  268. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  269. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  270. package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
  271. package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
  272. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  273. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  274. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  275. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  276. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  277. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  278. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  279. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  280. package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
  281. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  282. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  283. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  284. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  285. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  286. package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
  287. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  288. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  289. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  290. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  291. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  292. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  293. package/kits/hub-game/scripts/test-rehello.mjs +237 -0
  294. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  295. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  296. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  297. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  298. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  299. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  300. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  301. package/kits/hub-game/scripts/test-role-client.mjs +2 -1
  302. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  303. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  304. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  305. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  306. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  307. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  308. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  309. package/kits/hub-game/scripts/test-stuck.mjs +31 -0
  310. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  311. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  312. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  313. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  314. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  315. package/kits/hub-game/scripts/test-together.mjs +11 -0
  316. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  317. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  318. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  319. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  320. package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
  321. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  322. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  323. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  324. package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
  325. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  326. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  327. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  328. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  329. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  330. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
  331. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
  332. package/kits/multiplayer-3d/castle.json +5 -5
  333. package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
  334. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  335. package/kits/multiplayer-3d/code/server/world.js +19 -4
  336. package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
  337. package/kits/multiplayer-3d/package-lock.json +1 -1
  338. package/kits/multiplayer-3d/package.json +2 -1
  339. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  340. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  341. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  342. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
  343. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  344. package/kits/physics-2d/castle.json +2 -2
  345. package/kits/physics-2d/engine/scene.js +10 -2
  346. package/kits/physics-3d/CLAUDE.md +14 -0
  347. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  348. package/kits/physics-3d/castle.json +3 -3
  349. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  350. package/kits/physics-3d/docs/engine-player.md +76 -0
  351. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  352. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  353. package/kits/physics-3d/engine3d/gait.js +16 -8
  354. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  355. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  356. package/kits/physics-3d/engine3d/look.js +110 -17
  357. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  358. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  359. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  360. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  361. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  362. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  363. package/kits/physics-3d/engine3d/optimize.js +20 -9
  364. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  365. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  366. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  367. package/kits/physics-3d/engine3d/world3d.js +211 -17
  368. package/kits/physics-3d/package-lock.json +1 -1
  369. package/kits/physics-3d/package.json +2 -1
  370. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  371. package/kits/physics-3d/scripts/render.mjs +56 -8
  372. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  373. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  374. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  375. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  376. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  377. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  378. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  379. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  380. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  381. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  382. package/kits/physics-3d/systems/physics3d.js +51 -2
  383. package/kits/real-time/castle.json +2 -2
  384. package/kits/real-time/code/client/connection.js +3 -0
  385. package/package.json +2 -2
  386. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -87,6 +87,9 @@ globalThis.__tripHub = {
87
87
  calls.push(['cancel']);
88
88
  return { status: 'ok' };
89
89
  },
90
+ goFailed: (go, why) => {
91
+ calls.push(['goFailed', go, why]);
92
+ },
90
93
  onBack: (listener) => {
91
94
  calls.push(['onBack']);
92
95
  answers.backListener = listener;
@@ -109,6 +112,7 @@ const ShotClient = await import('../code/client/shot.js');
109
112
  const { receiveShot } = ShotClient;
110
113
  const clearShot = () => ShotClient.clearShot();
111
114
  const { makeTogether } = await import('../code/client/together.js');
115
+ const { makeInvites } = await import('../code/client/invites.js');
112
116
 
113
117
  const tick = () => new Promise((resolve) => setTimeout(resolve, 0));
114
118
  const flush = async () => {
@@ -579,6 +583,52 @@ await test('v1.154: a door used long after the arrival keeps the 15 s limit', as
579
583
  assert.equal(trip.shut, 'it took too long');
580
584
  });
581
585
 
586
+ // Oct 7: a player on a pad whose door ghost refused was sent through it again
587
+ // every ~1.4 s. A pad trip that ends `forbidden` -- the SDK's last answer once
588
+ // its own retries through the roster window are spent -- says `hub-shut` for
589
+ // that door once, so the place keeps the pad from firing it for this player
590
+ // until they step off (code/server/hub.js `doorShut`, test-hub-ops.mjs), and
591
+ // the kit never asks the door again itself.
592
+ await test('v1.154: a pad trip refused forbidden after the roster window says hub-shut once and asks no more', async () => {
593
+ const { system, scene } = setup();
594
+ const mp = mpStub(scene);
595
+ scene.multiplayer.net = { send: (m) => calls.push(['send', structuredClone(m)]) };
596
+ let release;
597
+ const go = globalThis.__tripHub.go;
598
+ globalThis.__tripHub.go = (doorId) => {
599
+ calls.push(['go', doorId]);
600
+ return new Promise((resolve) => (release = resolve));
601
+ };
602
+ try {
603
+ system.arrivedAt = 0;
604
+ system.placedLast = true;
605
+ system.goHub(scene, { k: 'hub-go', door: 'race', pad: 'race.1', key: null, title: 'Foot Race', party: 1 });
606
+ await flush();
607
+ system.trip.startedAt = 1000;
608
+ // Under the cover through the SDK's 14 s of `forbidden`: nothing said yet.
609
+ for (let now = 1000; now <= 15_000; now += 500) {
610
+ system.stepTrip(scene, mp, null, now);
611
+ }
612
+ assert.equal(system.trip.shut, undefined);
613
+ release({ status: 'forbidden' });
614
+ await flush();
615
+ let now = 15_000;
616
+ while (system.trip && now < 30_000) {
617
+ now += 100;
618
+ system.stepTrip(scene, mp, null, now);
619
+ }
620
+ assert.equal(system.trip, null, 'the cover lifted on the place');
621
+ await flush();
622
+ const sent = calls.filter(([kind]) => kind === 'send').map(([, m]) => m);
623
+ assert.deepEqual(sent.filter((m) => m.k === 'hub-shut'), [{ k: 'hub-shut', door: 'race' }], 'exactly one hub-shut, for this door');
624
+ assert.equal(calls.filter(([kind]) => kind === 'go').length, 1, 'the door is never asked again by the kit');
625
+ assert.equal(mp.switched.length, 0, 'nothing joined');
626
+ assert.equal(scene.persistent.hubTickets.length, 0, 'the way back it pushed is forgotten');
627
+ } finally {
628
+ globalThis.__tripHub.go = go;
629
+ }
630
+ });
631
+
582
632
  await test('v1.154: an arrival is placed() rising; unplaced reads as arriving now', async () => {
583
633
  const { system } = setup();
584
634
  let placed = false;
@@ -617,6 +667,44 @@ await test('the way back from a hub trip is Hub.back', async () => {
617
667
  assert.equal(trip.target.arrive.returning, true);
618
668
  });
619
669
 
670
+ // v1.173: the player's own Back out of a place without `result` tells the
671
+ // place first (`hub-back`), so the visit ends there; a game's Back says
672
+ // `hub-door-quit` instead, and automatic backs say nothing.
673
+ await test('a Back press in a place without result says hub-back before Hub.back; quit and automatic backs do not', async () => {
674
+ const sends = (list) => list.filter(([kind]) => kind === 'send').map(([, m]) => m.k);
675
+ const press = async (place, how) => {
676
+ const { system, scene } = setup();
677
+ scene.multiplayer.net = { send: (m) => calls.push(['send', structuredClone(m)]) };
678
+ HubState.hub.place = place;
679
+ scene.persistent.hubTickets.push({ hub: true, scene: 'scenes/main.scene', content: null, join: { mode: 'public' }, door: 'race', title: 'Town' });
680
+ answers.back = handoff({ bundleHash: 'town', contentUrl: 'https://cdn/town.json' });
681
+ how(system, scene);
682
+ await flush();
683
+ const seen = calls.slice();
684
+ HubState.clear();
685
+ return seen;
686
+ };
687
+ const town = { id: 'main', title: 'Town', result: null };
688
+ const own = await press(town, (system, scene) => system.backFromControl(scene));
689
+ assert.deepEqual(own.slice(0, 2), [['send', { k: 'hub-back' }], ['back']], 'hub-back, exactly that, then Hub.back');
690
+ assert.deepEqual(sends(own), ['hub-back'], 'said once');
691
+ const host = await press(town, (system, scene) => { system.backFromControl(scene); system.backFromControl(scene); });
692
+ assert.deepEqual(sends(host), ['hub-back'], 'a second press while the way back is under way says nothing');
693
+ assert.equal(host.filter(([kind]) => kind === 'back').length, 1);
694
+ const game = await press({ id: 'race', title: 'Race', result: { score: { unit: 's' } } }, (system, scene) => system.backFromControl(scene));
695
+ assert.deepEqual(game.slice(0, 2), [['send', { k: 'hub-door-quit' }], ['back']], 'a game quits the door instead');
696
+ assert.equal(sends(game).includes('hub-back'), false);
697
+ const automatic = await press(town, (system, scene) => system.back(scene));
698
+ assert.deepEqual(sends(automatic), [], 'an automatic back (a game end, an ended place, a failed door) says nothing');
699
+ assert.deepEqual(automatic[0], ['back']);
700
+ const menu = await press(town, (system, scene) => {
701
+ system.chrome.menuOpen = () => true;
702
+ system.chrome.cancelMenu = () => calls.push(['cancelMenu']);
703
+ system.backFromControl(scene);
704
+ });
705
+ assert.deepEqual(menu, [['cancelMenu']], 'a Back that closes the menu neither travels nor ends the visit');
706
+ });
707
+
620
708
  await test("a way back into the deck's own place from a pack that is its own content keeps that content", async () => {
621
709
  const { system, scene } = setup();
622
710
  scene.ownContent = { files: { 'scenes/main.scene': 'town' } };
@@ -1914,6 +2002,12 @@ await test('People: a game lists who may be reported, only where the host runs t
1914
2002
  // Anyone standing at a door can be gone to, as Doors > Go would.
1915
2003
  HubState.hub.whereAt.p2 = { x: 1, z: 1, where: 'on the Foot Race pad', door: 'race', on: true };
1916
2004
  assert.deepEqual(ids(system.people(scene, false).find((row) => row.playerId === 'p2')), 'door,invite,find,report');
2005
+ // Not at a door that takes one player: its pad would send this player into
2006
+ // a game of their own (their own House), not to bo. Find still points the way.
2007
+ HubState.hub.doors = [{ id: 'race', title: 'Foot Race' }, { id: 'house', title: 'House', solo: true }];
2008
+ HubState.hub.whereAt.p2 = { x: 1, z: 1, where: 'on the House pad', door: 'house', on: true };
2009
+ assert.deepEqual(ids(system.people(scene, false).find((row) => row.playerId === 'p2')), 'invite,find,report');
2010
+ HubState.hub.doors = [{ id: 'race', title: 'Foot Race' }];
1917
2011
  delete HubState.hub.whereAt.p2;
1918
2012
 
1919
2013
  // Join: beside a friend here, to the door of a friend's game. Invite asks.
@@ -3266,6 +3360,31 @@ await test('a returned Your games card starts at the authoritative town pose and
3266
3360
  }
3267
3361
  });
3268
3362
 
3363
+ await test('a fresh player id on the greeted net holds the loading cover until its arrival is placed', () => {
3364
+ HubState.clear();
3365
+ const { system, scene } = setup();
3366
+ cueChrome(system);
3367
+ system.talk.reset = () => {};
3368
+ system.scene = scene;
3369
+ townNet(scene, new Map(), {});
3370
+ const mp = scene.multiplayer;
3371
+ system.helloNet = mp.net;
3372
+ HubState.hub.arrivedFacing = 0;
3373
+ HubState.hub.arrivalPlaced = true;
3374
+ assert.equal(system.coverArriving(mp), false, 'the first arrival is not held this way');
3375
+ // A 180 s drop: the SDK re-acquired the session on the same net.
3376
+ system.newIdentity();
3377
+ assert.equal(system.coverArriving(mp), true, 'the spawn the new session placed the body at is not the restored pose');
3378
+ HookLayer.message(scene, { k: 'hub-arrived', facing: 0 });
3379
+ assert.equal(system.coverArriving(mp), true, 'hub-arrived comes before the state block with the clamp');
3380
+ HookLayer.state(scene, { ps: [['me', ...packPlayer({ x: -3.6, y: 0.7, z: 7.9 }, 0, true)]] }, { net: mp.net });
3381
+ assert.equal(system.coverArriving(mp), false, 'the restored pose has reached the client');
3382
+ system.newIdentity();
3383
+ const tripNet = { ...mp.net };
3384
+ assert.equal(system.coverArriving({ ...mp, net: tripNet }), false, 'another net (a trip) is not this rejoin');
3385
+ HubState.clear();
3386
+ });
3387
+
3269
3388
  await test('a timed-out or lost return waits for a later authoritative placement', () => {
3270
3389
  const oldYours = HubState.deck.yourGames;
3271
3390
  try {
@@ -3600,7 +3719,7 @@ await test('scene invite rail: town, House, game; opt-out and stale picks remain
3600
3719
  HubState.hub.place = { title: result ? 'Door' : 'House or town', result, invite: true };
3601
3720
  let draw, opens = [];
3602
3721
  system.chrome.showPicker = (...args) => { draw = args; };
3603
- system.invites = { canInvite: () => true, open: (share) => opens.push(share) };
3722
+ system.invites = { canInvite: () => true, inviteAvailable: () => true, open: (share) => opens.push(share) };
3604
3723
  for (const marker of [undefined, false, 'true', true]) {
3605
3724
  scene.data.engine.hubInviteRail = marker;
3606
3725
  system.drawChrome(scene, null, performance.now());
@@ -3611,12 +3730,12 @@ await test('scene invite rail: town, House, game; opt-out and stale picks remain
3611
3730
  draw[3].onPick();
3612
3731
  assert.deepEqual(opens, [true]);
3613
3732
  const stale = draw[3].onPick;
3614
- // A guest is over 13 like anyone else: the host's canInvite answer decides.
3733
+ // The roster's guest marker cannot override the trusted host answers.
3615
3734
  HubState.hub.guests = new Set(['me']);
3616
3735
  system.drawChrome(scene, null, performance.now());
3617
- assert.notEqual(draw[3], undefined, 'a guest the host can invite sees the invite entry');
3736
+ assert.notEqual(draw[3], undefined, 'host availability decides even when the roster marks this player as a guest');
3618
3737
  draw[3].onPick();
3619
- assert.deepEqual(opens, [true, true], 'a guest the host can invite can open it');
3738
+ assert.deepEqual(opens, [true, true], 'the host-approved row opens the existing share flow');
3620
3739
  opens.pop();
3621
3740
  delete HubState.hub.guests;
3622
3741
  system.invites.canInvite = () => false;
@@ -3693,6 +3812,72 @@ await test("a host's Go is never acquired again from this session after an early
3693
3812
  system.stepTrip(scene, mp, null, 5000); await flush();
3694
3813
  assert.equal(calls.filter(c => c[0] === 'go').length, 1);
3695
3814
  });
3815
+ // v1.171: a host's Go that fails before the host commits its join is reported
3816
+ // to the host (Hub.goFailed), once, so the host can acquire the door again
3817
+ // from its own session. A pad's own go never is.
3818
+ const goFailedCalls = () => calls.filter(c => c[0] === 'goFailed');
3819
+ await test("a host's Go whose join is never committed tells the host once, and the player stays", async () => {
3820
+ const { system, scene } = setup(); const mp = mpStub(scene);
3821
+ answers.go = handoff(); system.goHub(scene, { door: 'race', title: 'Foot Race', host: true });
3822
+ await toSwitch(system, scene, mp);
3823
+ system.trip.target.acquiredAt = 0;
3824
+ mp.state = 'failed'; mp.joinFailure = { code: 'MULTIPLAYER_CONNECTION_FAILED', closeCode: 4404 };
3825
+ system.stepTrip(scene, mp, null, 1500);
3826
+ assert.deepEqual(goFailedCalls(), [['goFailed', { doorId: 'race', owner: null }, 'join']]);
3827
+ assert.equal(system.trip.target.join.mode, 'public');
3828
+ assert.equal(scene.persistent.hubTickets.length, 0);
3829
+ for (const t of [1600, 5000, 20000]) {system.stepTrip(scene, mp, null, t);}
3830
+ await flush();
3831
+ assert.equal(goFailedCalls().length, 1);
3832
+ assert.equal(calls.filter(c => c[0] === 'go').length, 1);
3833
+ });
3834
+ await test("a host's Go the host refuses is reported as refused", async () => {
3835
+ const { system, scene } = setup();
3836
+ answers.go = { status: 'forbidden', url: null, nonce: null };
3837
+ system.goHub(scene, { door: 'race', title: 'Foot Race', host: true });
3838
+ await flush();
3839
+ assert.equal(system.contentReady(scene, system.trip, 0), false);
3840
+ assert.equal(system.trip.shut, 'forbidden');
3841
+ assert.deepEqual(goFailedCalls(), [['goFailed', { doorId: 'race', owner: null }, 'refused']]);
3842
+ });
3843
+ await test("a host's Go to a friend's House whose pack fails is reported as content, with its owner", async () => {
3844
+ const { system, scene } = setup();
3845
+ answers.go = handoff(); answers.loadPackError = 'hash mismatch';
3846
+ system.goHub(scene, { door: 'house', title: 'Amy', owner: '42', host: true });
3847
+ await flush();
3848
+ assert.equal(system.contentReady(scene, system.trip, 0), false);
3849
+ assert.deepEqual(goFailedCalls(), [['goFailed', { doorId: 'house', owner: '42' }, 'content']]);
3850
+ });
3851
+ await test("a host's Go the host committed is not reported, even if its session is then lost", async () => {
3852
+ const { system, scene } = setup(); const mp = mpStub(scene);
3853
+ answers.go = handoff(); system.goHub(scene, { door: 'race', title: 'Foot Race', host: true });
3854
+ await toSwitch(system, scene, mp);
3855
+ mp.state = 'joined'; system.stepTrip(scene, mp, null, 1);
3856
+ assert.equal(system.trip.phase, 'loading');
3857
+ mp.state = 'lost'; system.stepTrip(scene, mp, null, 2);
3858
+ assert.equal(goFailedCalls().length, 0);
3859
+ });
3860
+ await test("a pad's own failed go is never reported to the host", async () => {
3861
+ const { system, scene } = setup(); const mp = mpStub(scene);
3862
+ answers.go = handoff(); system.goHub(scene, { door: 'race', title: 'Foot Race' });
3863
+ await toSwitch(system, scene, mp);
3864
+ mp.state = 'failed'; mp.joinFailure = { code: 'MULTIPLAYER_CONNECTION_FAILED', closeCode: 4401 };
3865
+ system.stepTrip(scene, mp, null, 1);
3866
+ assert.equal(goFailedCalls().length, 0);
3867
+ });
3868
+ await test("an SDK without Hub.goFailed fails a host's Go as before", async () => {
3869
+ const { system, scene } = setup(); const mp = mpStub(scene);
3870
+ const goFailed = globalThis.__tripHub.goFailed;
3871
+ delete globalThis.__tripHub.goFailed;
3872
+ try {
3873
+ answers.go = handoff(); system.goHub(scene, { door: 'race', title: 'Foot Race', host: true });
3874
+ await toSwitch(system, scene, mp);
3875
+ mp.state = 'failed'; system.stepTrip(scene, mp, null, 1);
3876
+ assert.equal(system.trip.target.join.mode, 'public');
3877
+ } finally {
3878
+ globalThis.__tripHub.goFailed = goFailed;
3879
+ }
3880
+ });
3696
3881
  console.log(`hub trips with retry: ${n} tests passed`);
3697
3882
 
3698
3883
  for (const failure of ['refused', 'pack', 'timeout']) {
@@ -3715,3 +3900,54 @@ for (const failure of ['refused', 'pack', 'timeout']) {
3715
3900
  });
3716
3901
  }
3717
3902
  console.log(`hub trips with retry failures: ${n} tests passed`);
3903
+
3904
+ await test('v1.188 Character invite row waits for viewer availability and fences stale picks', async () => {
3905
+ for (const answer of [{ status: 'ok', available: true }, { status: 'ok', available: false }, { status: 'unavailable' }, new Error('old host')]) {
3906
+ const { system, scene } = setup(); cueChrome(system);
3907
+ const ids = { me: '101' }; townNet(scene, new Map(), ids);
3908
+ const net = scene.multiplayer.net;
3909
+ system.scene = scene;
3910
+ scene.data = { engine: {} };
3911
+ HubState.hub.place = { title: 'Town', result: null, invite: true };
3912
+ let resolve, reject, reads = 0, draw; const opens = [];
3913
+ const pending = new Promise((yes, no) => { resolve = yes; reject = no; });
3914
+ const invites = makeInvites({
3915
+ canInvite: async () => ({ status: 'ok', canInvite: true, userId: ids.me }),
3916
+ inviteAvailable: () => { reads++; return pending; },
3917
+ }, () => {}, () => {});
3918
+ system.invites = invites;
3919
+ invites.open = (share) => opens.push(share);
3920
+ system.chrome.showPicker = (...args) => { draw = args; };
3921
+ const render = () => system.drawPanelControls(scene, performance.now(), HubState.hub.place, true, false, true, true);
3922
+ for (const marker of [undefined, false, 'true']) {
3923
+ scene.data.engine.hubInviteRail = marker; render(); await flush();
3924
+ assert.equal(draw[3], undefined);
3925
+ assert.equal(reads, 0, 'absent or inexact marker never asks');
3926
+ }
3927
+ scene.data.engine.hubInviteRail = true;
3928
+ render(); await flush(); render(); await flush(); render();
3929
+ assert.equal(reads, 1);
3930
+ assert.equal(draw[3], undefined, 'pending availability hides the row');
3931
+ if (answer instanceof Error) reject(answer); else resolve(answer);
3932
+ await flush(); render(); await flush(); render();
3933
+ const shown = answer?.status === 'ok' && answer.available === true;
3934
+ assert.equal(draw[3] !== undefined, shown);
3935
+ assert.equal(reads, 1, 'false, unavailable and errors never retry');
3936
+ if (shown) {
3937
+ const pick = draw[3].onPick;
3938
+ pick(); assert.deepEqual(opens, [true], 'uses the existing share intent');
3939
+ system.scene = {}; pick(); system.scene = scene;
3940
+ scene.multiplayer.net = { ...net }; pick(); scene.multiplayer.net = net;
3941
+ const data = scene.data; scene.data = { ...data }; pick(); scene.data = data;
3942
+ ids.me = '102'; pick();
3943
+ // A new identity can become eligible, but cannot reuse the old menu pick.
3944
+ render(); await flush(); render(); await flush(); render();
3945
+ assert.notEqual(draw[3], undefined);
3946
+ pick(); assert.deepEqual(opens, [true], 'stale account pick stays fenced even after a fresh true read');
3947
+ draw[3].onPick(); assert.deepEqual(opens, [true, true]);
3948
+ }
3949
+ invites.dispose(); HubState.clear();
3950
+ }
3951
+ });
3952
+
3953
+ console.log('hub trips: v1.188 Character invite availability and stale picks passed');
@@ -269,6 +269,21 @@ function rig(view = PHONE) {
269
269
  return { ...dom, chrome, root, hud, hudTitle, hudBig, hudText, labels, pointers, cabinet };
270
270
  }
271
271
 
272
+ test('v1.204: the catching-up dim marker comes and goes, and dispose clears it', () => {
273
+ const r = rig();
274
+ const marked = document.documentElement ?? r.root;
275
+ const before = r.root.children.length;
276
+ r.chrome.setCatching(false);
277
+ assert.equal(r.root.children.length, before, 'no rule is made until one is needed');
278
+ r.chrome.setCatching(true);
279
+ assert.equal(marked.dataset.hubCatching, '');
280
+ r.chrome.setCatching(false);
281
+ assert.equal(marked.dataset.hubCatching, undefined);
282
+ r.chrome.setCatching(true);
283
+ r.chrome.dispose();
284
+ assert.equal(marked.dataset.hubCatching, undefined);
285
+ });
286
+
272
287
  test('v1.52: the cover line is smaller, centred and phone-wrappable, and absent without text', () => {
273
288
  const r = rig();
274
289
  const cover = r.root.children[0];
@@ -854,6 +869,74 @@ test('asked, then not, with no HUD drawn: put back at once, and written to as ne
854
869
  n += 1;
855
870
  }
856
871
 
872
+ // The Act/Jump pair and a shown Character button are in that column too: an
873
+ // edge chip left on the pair was pushed by the safe layout onto chat below.
874
+ {
875
+ const r = rig();
876
+ const chipOf = (text) => r.pointers.children.find((c) => c.children[1].textContent === text);
877
+ const edgeX = window.innerWidth - 4;
878
+ const pair = document.createElement('div'), act = document.createElement('button'), jump = document.createElement('button');
879
+ pair.append(act); pair.append(jump); r.root.append(pair);
880
+ pair.rect = { left: window.innerWidth - 148, right: window.innerWidth - 14, top: 500, bottom: 548 };
881
+ r.chrome.interactionRail(pair, act, jump);
882
+ r.chrome.setPointers([{ id: 'a', x: edgeX, y: 524, text: 'house', angle: 0 }, { id: 'b', x: edgeX, y: 300, text: 'well', angle: 0 }]);
883
+ assert.equal(parseFloat(chipOf('house').styles.left), pair.rect.left - 6 - 10, 'beside the pair, not on it');
884
+ assert.equal(parseFloat(chipOf('well').styles.left), window.innerWidth - 10 - 6, 'a chip clear of the pair stays at the edge');
885
+ pair.style.display = 'none';
886
+ r.chrome.setPointers([{ id: 'a', x: edgeX, y: 524, text: 'house', angle: 0 }]);
887
+ assert.equal(parseFloat(chipOf('house').styles.left), window.innerWidth - 10 - 6, 'a hidden pair is not in the way');
888
+ // The Character button, only while the picker is shown.
889
+ const character = r.made.find((c) => c.tag === 'button' && c.textContent === 'Character');
890
+ character.rect = { left: window.innerWidth - 110, right: window.innerWidth - 10, top: 700, bottom: 736 };
891
+ r.chrome.setPointers([{ id: 'a', x: edgeX, y: 718, text: 'house', angle: 0 }]);
892
+ assert.equal(parseFloat(chipOf('house').styles.left), window.innerWidth - 10 - 6, 'no picker shown: at the edge');
893
+ r.chrome.showPicker(true, 0);
894
+ r.chrome.setPointers([{ id: 'a', x: edgeX, y: 718, text: 'house', angle: 0 }]);
895
+ assert.equal(parseFloat(chipOf('house').styles.left), character.rect.left - 6 - 10, 'beside the Character button');
896
+ n += 1;
897
+ }
898
+
899
+ // The Sit / Stand button too, only while it is shown: low in the middle, where
900
+ // a chip on the bottom edge lies, its place in the column the chrome draws.
901
+ {
902
+ const r = rig();
903
+ const chipOf = (text) => r.pointers.children.find((c) => c.children[1].textContent === text);
904
+ r.chrome.sitPrompt('Sit');
905
+ const sit = r.made.find((c) => c.tag === 'button' && c.textContent === 'Sit');
906
+ assert.ok(sit, 'the Sit button');
907
+ r.chrome.sitPrompt(null);
908
+ const mid = window.innerWidth / 2;
909
+ sit.rect = { left: mid - 40, right: mid + 40, top: 600, bottom: 640 };
910
+ r.chrome.setPointers([{ id: 'a', x: mid, y: 620, text: 'house', angle: Math.PI / 2 }]);
911
+ assert.equal(parseFloat(chipOf('house').styles.left), mid, 'no Sit shown: where it was');
912
+ r.chrome.sitPrompt('Sit');
913
+ r.chrome.setPointers([{ id: 'a', x: mid, y: 620, text: 'house', angle: Math.PI / 2 }, { id: 'b', x: mid, y: 300, text: 'well', angle: Math.PI / 2 }]);
914
+ assert.equal(parseFloat(chipOf('house').styles.left), sit.rect.left - 6 - 10, 'beside Sit, not on it');
915
+ assert.equal(parseFloat(chipOf('well').styles.left), mid, 'a chip clear of Sit stays where it was');
916
+ // A chip on a column button, clear of Sit, is placed as with no Sit shown:
917
+ // Sit does not join the column's leftmost edge.
918
+ const say = r.made.find((c) => c.attrs['aria-label'] === 'Quick chat');
919
+ r.chrome.setSay({ reactions: ['👋'], phrases: [] });
920
+ say.rect = { left: 288, right: 340, top: 500, bottom: 552 };
921
+ const edgeX = window.innerWidth - 4;
922
+ r.chrome.setPointers([{ id: 'a', x: edgeX, y: 526, text: 'house', angle: 0 }]);
923
+ assert.equal(parseFloat(chipOf('house').styles.left), 272, 'beside chat, Sit shown');
924
+ r.chrome.sitPrompt(null);
925
+ r.chrome.setPointers([{ id: 'a', x: edgeX, y: 526, text: 'house', angle: 0 }]);
926
+ assert.equal(parseFloat(chipOf('house').styles.left), 272, 'beside chat, no Sit');
927
+ r.chrome.setPointers([{ id: 'a', x: mid, y: 620, text: 'house', angle: Math.PI / 2 }]);
928
+ assert.equal(parseFloat(chipOf('house').styles.left), mid, 'a hidden Sit is not in the way');
929
+ // A move off Sit that would land on a column button takes the next place:
930
+ // chat just left of Sit, so the chip goes over Sit instead.
931
+ r.chrome.sitPrompt('Sit');
932
+ say.rect = { left: mid - 70, right: mid - 44, top: 600, bottom: 640 };
933
+ chipOf('house').size = { w: 20, h: 18 };
934
+ r.chrome.setPointers([{ id: 'a', x: mid, y: 620, text: 'house', angle: Math.PI / 2 }]);
935
+ assert.equal(parseFloat(chipOf('house').styles.left), mid, 'not moved left onto chat');
936
+ assert.equal(parseFloat(chipOf('house').styles.top), sit.rect.top - 6 - 9, 'over Sit');
937
+ n += 1;
938
+ }
939
+
857
940
  // v1.35: the NPC talk panel. A reply is scrolled to its first word, the
858
941
  // player's own line to the end of the log, and a player who has scrolled up to
859
942
  // read is left where they are. The log has no layout here, so its numbers are
@@ -19,6 +19,7 @@ import { syncUiTreeTime } from '../code/client/uiTree.js';
19
19
  import { hudInputs } from '../code/client/hudSurface.js';
20
20
  import { backControl } from '../code/client/hubControls.js';
21
21
  import { roleItems } from '../code/client/role.js';
22
+ import * as Celebrate from '../code/client/celebrate.js';
22
23
 
23
24
  const inputEvents = ['pointerdown', 'pointerup', 'touchstart', 'touchend', 'keydown', 'keyup'];
24
25
  function inputTarget() {
@@ -84,7 +85,7 @@ const dependencies = { Hub, makeHudRate, askPadsAt, attend, goalAt, worldLabelFo
84
85
  Avatar: { current: scene => scene.persistent.avatar, colorsAvailable: () => false, style: () => 'toon',
85
86
  currentColor: () => 0, top: () => 1.5, drawn: () => 0 },
86
87
  Cabinets: { nearest: () => null }, kitBackNeeded: () => false, backControl,
87
- loadingCover: null, clearShot() {}, syncUiTreeTime, hudInputs, roleItems,
88
+ loadingCover: null, clearShot() {}, syncUiTreeTime, hudInputs, roleItems, Celebrate,
88
89
  };
89
90
  const Harness = new Function(...Object.keys(dependencies), `${constants}\n${project}
90
91
  return class { ${['drawChrome', 'drawPanelControls', 'drawNearPrompt', 'dispose'].map(method).join('\n')} };`
@@ -863,6 +863,64 @@ test('seats: a sitter who jumps to a door gets up first', () => {
863
863
  assert.ok(world.players.get('p1').at.z < -10);
864
864
  });
865
865
 
866
+ test('hub.sitOn: the place seats a player at any distance, with no budget and no sit hook', () => {
867
+ const calls = [];
868
+ const { h, hub, say, tick, world } = boot({ hooks: { sit: (x, ...args) => calls.push(args) } });
869
+ assert.equal(hub.sitOn('p1', 'far-bench'), true);
870
+ assert.deepEqual(calls, []);
871
+ assert.equal(hub.seat('p1'), 'far-bench');
872
+ assert.deepEqual(world.players.get('p1').at, { x: 20, y: 0.5 + Idle.SIT_BODY, z: 0 });
873
+ assert.deepEqual(h.join().hubSeated, { p1: 'far-bench' });
874
+ assert.deepEqual(h.join().held, ['p1']);
875
+ // A sitter moves seat, past the client's 3/s budget.
876
+ for (const seat of ['bench-a', 'bench-b', 'stool', 'bench-a']) {
877
+ assert.equal(hub.sitOn('p1', seat), true);
878
+ }
879
+ assert.equal(hub.seat('p1'), 'bench-a');
880
+ assert.deepEqual(h.join().hubSeated, { p1: 'bench-a' });
881
+ // A seat is a hold as any other: the hold keeps them there, Stand gets them up.
882
+ world.players.get('p1').at = { x: 3, y: 1, z: 0 };
883
+ tick();
884
+ assert.equal(world.players.get('p1').at.x, 1);
885
+ say('p1', { k: 'hub-stand' });
886
+ assert.equal(hub.seat('p1'), null);
887
+ assert.deepEqual(h.join().held, []);
888
+ // null stands a sitter; false when they were not sitting.
889
+ assert.equal(hub.sitOn('p2', 'stool'), true);
890
+ assert.equal(hub.sitOn('p2', null), true);
891
+ assert.equal(hub.seat('p2'), null);
892
+ assert.equal(hub.sitOn('p2', null), false);
893
+ });
894
+
895
+ test('hub.sitOn: refuses a taken seat, a non-seat, a hidden or moving seat, a held or absent player', () => {
896
+ const { hub, world } = boot();
897
+ assert.equal(hub.sitOn('p1', 'bench-a'), true);
898
+ assert.equal(hub.sitOn('p2', 'bench-a'), false);
899
+ for (const seat of ['jukebox', 'cart', 'nope', { id: 'stool' }, undefined]) {
900
+ assert.equal(hub.sitOn('p2', seat), false);
901
+ }
902
+ hub.hide('bench-b');
903
+ assert.equal(hub.sitOn('p2', 'bench-b'), false);
904
+ hub.hold('p2');
905
+ assert.equal(hub.sitOn('p2', 'stool'), false);
906
+ assert.equal(hub.sitOn('p2', null), false);
907
+ hub.release('p2');
908
+ assert.equal(hub.sitOn('ghost', 'stool'), false);
909
+ world.players.delete('p2');
910
+ assert.equal(hub.sitOn('p2', 'stool'), false);
911
+ assert.equal(hub.seat('p2'), null);
912
+ });
913
+
914
+ test('hub.sitOn: a place without seats is refused and nothing is sent', () => {
915
+ const { h, hub, world } = boot({ idle: { emotes: true } });
916
+ const before = world.players.get('p1').at;
917
+ assert.equal(hub.sitOn('p1', 'bench-a'), false);
918
+ assert.equal(hub.seat('p1'), null);
919
+ assert.deepEqual(world.players.get('p1').at, before);
920
+ assert.equal('hubSeated' in h.join(), false);
921
+ assert.equal(boot({ idle: undefined }).hub.sitOn('p1', 'bench-a'), false);
922
+ });
923
+
866
924
  // --- sounds -------------------------------------------------------------------
867
925
 
868
926
  test('a loop is latched at its actor until stopped; one-shots are broadcast', () => {
@@ -956,6 +1014,108 @@ test('v1.158: NPC replies reuse original motions and keep the new request id for
956
1014
  } finally { globalThis.__hubTestActors = actors; }
957
1015
  });
958
1016
 
1017
+ // --- v1.174 place-only yawn ------------------------------------------------------
1018
+
1019
+ test('v1.174: hub.emote plays yawn at any idle.emotes place for everyone; a client request and the hook never see it', () => {
1020
+ for (const idle of [{ emotes: true }, { emotes: true, seats: true, sounds: SOUNDS }, expressionIdle]) {
1021
+ let asked = 0;
1022
+ const r = boot({ idle, hooks: { emote: () => { asked++; return true; } } });
1023
+ r.h.delta();
1024
+ r.say('p1', { k: 'hub-emote', id: 'yawn' });
1025
+ assert.equal(asked, 0, 'a refused request does not reach the hook');
1026
+ assert.equal(r.h.delta(), null, 'a client yawn is refused');
1027
+ assert.deepEqual(r.h.join().hubEmotes, {});
1028
+ assert.equal(r.hub.emote('p1', 'yawn'), true);
1029
+ assert.deepEqual(r.h.delta().hubEmotes, { p1: { id: 'yawn', at: 0, until: 3000 } });
1030
+ assert.equal(asked, 0, 'the place call skips the hook');
1031
+ assert.equal(r.hub.emote('p1', 'yawn'), true, 'no rate on the place call');
1032
+ r.world.timeMs = 3000;
1033
+ assert.deepEqual(r.h.delta().hubEmotes, {});
1034
+ }
1035
+ for (const idle of [{ seats: true }, undefined]) {
1036
+ const r = boot({ idle });
1037
+ assert.equal(r.hub.emote('p1', 'yawn'), false);
1038
+ assert.equal('hubEmotes' in r.h.join(), false);
1039
+ }
1040
+ });
1041
+
1042
+ test('v1.174: a declared role named yawn keeps its own definition and grants', () => {
1043
+ const role = { ...ROLE, id: 'yawn', ms: 1500 };
1044
+ const r = boot({ idle: { emotes: true, expression: { roleEmotes: [role] } } });
1045
+ r.say('p1', { k: 'hub-emote', id: 'yawn' });
1046
+ assert.deepEqual(r.h.join().hubEmotes, {});
1047
+ r.hub.emotesFor('p1', ['yawn']);
1048
+ r.say('p1', { k: 'hub-emote', id: 'yawn' });
1049
+ assert.deepEqual(r.h.join().hubEmotes.p1, { id: 'yawn', at: 0, until: 1500 });
1050
+ clearClient();
1051
+ try {
1052
+ clientHub.place = { idle: { emotes: true, expression: { roleEmotes: [role] } } };
1053
+ assert.equal(ClientIdle.emoteDefinition('yawn'), role);
1054
+ } finally { clearClient(); }
1055
+ });
1056
+
1057
+ const { EMOTE_MOTIONS } = await import('../code/shared/expression.js');
1058
+ const { ACTION_VOICES } = await import('../code/client/soundscapeCues.js');
1059
+ test('v1.174: the picker and the wheel stay as they were; yawn is no role motion', () => {
1060
+ assert.deepEqual(ClientIdle.EMOTES.map(([id]) => id), ['wave', 'dance', 'cheer', 'bow', 'spin']);
1061
+ const choices = ClientIdle.expressionChoices(expressionIdle.expression, [ROLE.id]);
1062
+ assert.deepEqual(choices.basics.map(([id]) => id), ['wave', 'sit', 'sleep', 'eat', 'dance', 'cry', 'laugh', 'point']);
1063
+ assert.deepEqual(choices.more.map(([id]) => id), ['cheer', 'bow', 'spin', ROLE.id]);
1064
+ assert.equal(EMOTE_MOTIONS.includes('yawn'), false);
1065
+ const errors = Manifest.readManifest({ hub: { contract: 1, title: 'T', idle: { emotes: true, expression: { roleEmotes: [{ ...ROLE, motion: 'yawn' }] } } } }).errors;
1066
+ assert.ok(errors.some((e) => /motion must be a kit motion/.test(e)), errors.join('; '));
1067
+ assert.deepEqual(Manifest.readManifest({ hub: { contract: 1, title: 'T', idle: { emotes: true, expression: { roleEmotes: [{ ...ROLE, id: 'yawn' }] } } } }).errors, [], 'a role may still be named yawn');
1068
+ assert.equal(ACTION_VOICES.yawn, ACTION_VOICES.bow, 'yawn reuses an existing cue');
1069
+ });
1070
+
1071
+ test('v1.174: yawn stretches back, then droops forward and aside, and ends at rest', () => {
1072
+ clearClient();
1073
+ try {
1074
+ clientHub.place = { idle: { emotes: true } };
1075
+ assert.deepEqual(ClientIdle.emoteDefinition('yawn'), { emoji: '🥱', ms: 3000, motion: 'yawn' });
1076
+ } finally { clearClient(); }
1077
+ for (const u of [0, 1]) {
1078
+ assert.ok(Object.values(ClientIdle.emotePose('yawn', u, 3 * u)).every((v) => Math.abs(v) < 1e-9), `rest at ${u}`);
1079
+ }
1080
+ const stretch = ClientIdle.emotePose('yawn', 0.2, 0.6);
1081
+ assert.ok(stretch.y > 0.03 && stretch.rx < -0.15, 'up with the head back');
1082
+ const doze = ClientIdle.emotePose('yawn', 0.7, 2.1);
1083
+ assert.ok(doze.y < -0.03 && doze.rx > 0.1 && doze.rz > 0.05, 'sagging forward and aside');
1084
+ });
1085
+
1086
+ test('v1.174: an emote id a client does not know draws nothing and throws nothing', () => {
1087
+ clearClient();
1088
+ const rig = new Group(); rig.position.y = 2;
1089
+ const actor = { id: 'remote', components: { Transform: { x: 3, y: 0.85, z: 10 } } };
1090
+ const scene = { multiplayer: { net: { selfId: () => 'self' }, avatars: { actors: new Map([['guest', 'remote']]) } },
1091
+ getActor: () => actor, three: { nodes: new Map([['remote', { node: { children: [rig] } }]]) } };
1092
+ const idle = ClientIdle.makeIdle({});
1093
+ try {
1094
+ for (const place of [{ idle: { emotes: true } }, { idle: expressionIdle }]) {
1095
+ clientHub.place = place; clientHub.lastT = 1000; clientHub.lastTAt = performance.now();
1096
+ clientHub.emotes = { guest: { id: 'not-a-kit-emote', at: 0, until: 3000 } };
1097
+ idle.draw(scene, null);
1098
+ assert.equal(rig.position.y, 2); assert.equal(rig.rotation.x, 0); assert.equal(rig.rotation.z, 0);
1099
+ assert.deepEqual(idle.labels(scene, null, null, null, (_cam, x, y) => ({ x, y })), []);
1100
+ }
1101
+ } finally { idle.dispose(); clearClient(); }
1102
+ });
1103
+
1104
+ test('v1.174: an NPC answers a place yawn with a wave; the hook hears yawn', () => {
1105
+ const actors = globalThis.__hubTestActors;
1106
+ try {
1107
+ for (const idle of [{ emotes: true }, expressionIdle]) {
1108
+ globalThis.__hubTestActors = [...actors, { id: 'greeter', components: { HubNpc: {}, Transform: { x: 0, y: 1, z: 1 }, Body: { type: 'kinematic' } } }];
1109
+ const body = { translation: () => ({ x: 0, y: 1, z: 1 }), setNextKinematicRotation() {}, setNextKinematicTranslation() {} };
1110
+ const heard = [];
1111
+ const r = boot({ idle, bodies: [['greeter', body]], hooks: { npcReact: (_hub, _npc, _player, request) => { heard.push(request.emote); return { line: null }; } } });
1112
+ assert.equal(r.hub.emote('p1', 'yawn'), true);
1113
+ assert.equal(r.h.join().hubNpcEmotes.greeter.id, 'wave');
1114
+ assert.deepEqual(heard, ['yawn']);
1115
+ }
1116
+ } finally { globalThis.__hubTestActors = actors; }
1117
+ });
1118
+
959
1119
  test('every emote starts and ends at rest, and moves between', () => {
960
1120
  for (const [id] of ClientIdle.EMOTES) {
961
1121
  const seconds = Idle.EMOTES[id] / 1000;
@@ -469,3 +469,56 @@ for (const copiedOk of [true, false]) {
469
469
  registered.dispose(); assert.equal(layouts.at(-1), null);
470
470
  console.log('invite dialog layout registration and cleanup passed');
471
471
  }
472
+
473
+ // v1.188 availability is separate from canInvite's periodic/share-time checks.
474
+ for (const answer of [
475
+ { status: 'ok', available: true }, { status: 'ok', available: false },
476
+ { status: 'unavailable' }, { status: 'ok', available: 'true' }, null, new Error('old host'),
477
+ ]) {
478
+ const gate = deferred(); let reads = 0, clock = 0;
479
+ const available = makeInvites({ inviteAvailable: () => { reads++; return gate.promise; } }, () => {}, () => {}, () => clock);
480
+ const net = { ...identityNet }, scene = { data: { engine: {} }, multiplayer: { net } };
481
+ assert.equal(available.inviteAvailable(scene, net), false);
482
+ await flush(); assert.equal(reads, 0, 'absent marker makes no request');
483
+ scene.data.engine.hubInviteRail = true;
484
+ for (let i = 0; i < 3; i++) assert.equal(available.inviteAvailable(scene, net), false, 'pending stays hidden');
485
+ await flush(); assert.equal(reads, 1);
486
+ if (answer instanceof Error) gate.reject(answer); else gate.resolve(answer);
487
+ await flush();
488
+ const expected = answer?.status === 'ok' && answer.available === true;
489
+ assert.equal(available.inviteAvailable(scene, net), expected);
490
+ clock = 1000000;
491
+ assert.equal(available.inviteAvailable(scene, net), expected);
492
+ await flush(); assert.equal(reads, 1, 'no retries or periodic refresh, including false/unavailable/error');
493
+ const newNet = { ...net }; scene.multiplayer.net = newNet;
494
+ available.inviteAvailable(scene, newNet); await flush(); assert.equal(reads, 2, 'new connection asks once');
495
+ const nextScene = { data: scene.data, multiplayer: { net: newNet } };
496
+ available.inviteAvailable(nextScene, newNet); await flush(); assert.equal(reads, 3, 'new scene asks once');
497
+ newNet.userId = () => '102';
498
+ available.inviteAvailable(nextScene, newNet); await flush(); assert.equal(reads, 4, 'new identity asks once');
499
+ available.dispose();
500
+ }
501
+ for (const change of ['scene', 'inactiveScene', 'data', 'connection', 'account', 'player', 'closed', 'reset', 'dispose']) {
502
+ const gate = deferred(); let reads = 0;
503
+ const available = makeInvites({ inviteAvailable: () => { reads++; return reads === 1 ? gate.promise : new Promise(() => {}); } }, () => {}, () => {});
504
+ let net = { ...identityNet }, scene = { data: { engine: { hubInviteRail: true } }, multiplayer: { net } };
505
+ let active = true;
506
+ available.inviteAvailable(scene, net, () => active); await flush();
507
+ if (change === 'inactiveScene') active = false;
508
+ if (change === 'scene') scene = { ...scene };
509
+ if (change === 'data') scene.data = { engine: { hubInviteRail: true } };
510
+ if (change === 'connection') { net = { ...net }; scene.multiplayer.net = net; }
511
+ if (change === 'account') net.userId = () => '102';
512
+ if (change === 'player') net.selfId = () => 'other';
513
+ if (change === 'closed') net.closed = () => true;
514
+ if (change === 'reset') available.reset();
515
+ if (change === 'dispose') available.dispose();
516
+ // A changed scene starts a fresh read before the previous promise settles.
517
+ if (change === 'scene') available.inviteAvailable(scene, net);
518
+ gate.resolve({ status: 'ok', available: true }); await flush();
519
+ active = true;
520
+ if (change === 'scene') assert.equal(reads, 2);
521
+ assert.equal(available.inviteAvailable(scene, net), false, `stale ${change} answer cannot enable the row`);
522
+ available.dispose();
523
+ }
524
+ console.log('invite availability: marker-only, exact true, one attempt per lifetime, no retries and stale promise fences passed');