castle-web-cli 0.4.238 → 0.4.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +218 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +22 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +9 -0
  19. package/dist/platformDoc.js +4 -2
  20. package/dist/playPagePolicy.d.ts +1 -0
  21. package/dist/playPagePolicy.js +12 -3
  22. package/dist/resetLeaderboards.d.ts +8 -1
  23. package/dist/resetLeaderboards.js +43 -8
  24. package/dist/roomLogs.d.ts +39 -0
  25. package/dist/roomLogs.js +166 -0
  26. package/dist/save-deck.d.ts +32 -2
  27. package/dist/save-deck.js +240 -39
  28. package/kits/base/CLAUDE.md +2 -1
  29. package/kits/base/castle.json +1 -1
  30. package/kits/base/sdk/README.md +240 -8
  31. package/kits/base/sdk/analytics.d.ts +8 -0
  32. package/kits/base/sdk/analytics.js +92 -0
  33. package/kits/base/sdk/castle.d.ts +8 -2
  34. package/kits/base/sdk/castle.js +3 -0
  35. package/kits/base/sdk/commands.d.ts +79 -0
  36. package/kits/base/sdk/commands.js +1 -0
  37. package/kits/base/sdk/debugConsole.d.ts +17 -0
  38. package/kits/base/sdk/debugConsole.js +154 -0
  39. package/kits/base/sdk/experiments.js +24 -1
  40. package/kits/base/sdk/hostRetry.d.ts +7 -0
  41. package/kits/base/sdk/hostRetry.js +57 -0
  42. package/kits/base/sdk/hub.d.ts +20 -2
  43. package/kits/base/sdk/hub.js +99 -13
  44. package/kits/base/sdk/multiplayer.d.ts +2 -0
  45. package/kits/base/sdk/multiplayer.js +198 -26
  46. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  47. package/kits/base/sdk/reconnectBudget.js +41 -1
  48. package/kits/base/sdk/rooms.d.ts +11 -0
  49. package/kits/base/sdk/rooms.js +22 -0
  50. package/kits/base/sdk/runtime.js +36 -19
  51. package/kits/base/sdk/server/hub.d.ts +19 -0
  52. package/kits/base/sdk/server/hub.js +12 -0
  53. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  54. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  55. package/kits/base/sdk/server/wrapper.js +26 -1
  56. package/kits/base/sdk/store.d.ts +8 -2
  57. package/kits/base/sdk/store.js +5 -1
  58. package/kits/base/sdk/transport.d.ts +2 -1
  59. package/kits/base/sdk/transport.js +35 -0
  60. package/kits/hub-game/CLAUDE.md +66 -19
  61. package/kits/hub-game/castle.json +4 -4
  62. package/kits/hub-game/code/client/act.js +9 -6
  63. package/kits/hub-game/code/client/actCore.js +26 -6
  64. package/kits/hub-game/code/client/actGateLog.js +36 -0
  65. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  66. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  67. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  68. package/kits/hub-game/code/client/askSurface.js +85 -0
  69. package/kits/hub-game/code/client/askTree.js +51 -0
  70. package/kits/hub-game/code/client/attention.js +31 -6
  71. package/kits/hub-game/code/client/ballot.js +42 -5
  72. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  73. package/kits/hub-game/code/client/ballotTree.js +180 -0
  74. package/kits/hub-game/code/client/catchingUp.js +19 -0
  75. package/kits/hub-game/code/client/celebrate.js +66 -0
  76. package/kits/hub-game/code/client/chrome.js +474 -53
  77. package/kits/hub-game/code/client/companion.js +93 -23
  78. package/kits/hub-game/code/client/companionDress.js +1 -1
  79. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  80. package/kits/hub-game/code/client/cornerTree.js +83 -0
  81. package/kits/hub-game/code/client/decor.js +20 -11
  82. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  83. package/kits/hub-game/code/client/disguise.js +23 -0
  84. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  85. package/kits/hub-game/code/client/dockSurface.js +206 -0
  86. package/kits/hub-game/code/client/dockTree.js +232 -0
  87. package/kits/hub-game/code/client/earned.js +29 -0
  88. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  89. package/kits/hub-game/code/client/emoteTree.js +264 -0
  90. package/kits/hub-game/code/client/farAvatars.js +4 -3
  91. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  92. package/kits/hub-game/code/client/grab.js +121 -50
  93. package/kits/hub-game/code/client/holdShow.js +19 -0
  94. package/kits/hub-game/code/client/hookLayer.js +96 -12
  95. package/kits/hub-game/code/client/hubControls.js +7 -1
  96. package/kits/hub-game/code/client/hudSurface.js +11 -3
  97. package/kits/hub-game/code/client/hudTree.js +7 -4
  98. package/kits/hub-game/code/client/idle.js +21 -3
  99. package/kits/hub-game/code/client/invites.js +24 -3
  100. package/kits/hub-game/code/client/keys.js +15 -0
  101. package/kits/hub-game/code/client/labelsNear.js +8 -1
  102. package/kits/hub-game/code/client/layoutCache.js +57 -8
  103. package/kits/hub-game/code/client/loadingCover.js +53 -4
  104. package/kits/hub-game/code/client/menuIcons.js +15 -0
  105. package/kits/hub-game/code/client/menuRows.js +8 -2
  106. package/kits/hub-game/code/client/menuSurface.js +102 -0
  107. package/kits/hub-game/code/client/menuTree.js +135 -0
  108. package/kits/hub-game/code/client/modelLook.js +41 -0
  109. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  110. package/kits/hub-game/code/client/pickerTree.js +163 -0
  111. package/kits/hub-game/code/client/pushVisit.js +4 -2
  112. package/kits/hub-game/code/client/quality.js +188 -29
  113. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  114. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  115. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  116. package/kits/hub-game/code/client/rehello.js +75 -0
  117. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  118. package/kits/hub-game/code/client/replay.js +118 -0
  119. package/kits/hub-game/code/client/role.js +3 -0
  120. package/kits/hub-game/code/client/safeLayout.js +441 -56
  121. package/kits/hub-game/code/client/safeStyle.js +13 -10
  122. package/kits/hub-game/code/client/say.js +2 -0
  123. package/kits/hub-game/code/client/soundSurface.js +77 -0
  124. package/kits/hub-game/code/client/soundTree.js +74 -0
  125. package/kits/hub-game/code/client/soundscape.js +12 -9
  126. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  127. package/kits/hub-game/code/client/state.js +67 -1
  128. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  129. package/kits/hub-game/code/client/stuckTree.js +67 -0
  130. package/kits/hub-game/code/client/talk.js +42 -12
  131. package/kits/hub-game/code/client/talkTree.js +4 -2
  132. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  133. package/kits/hub-game/code/client/textAskTree.js +67 -0
  134. package/kits/hub-game/code/client/tiers.js +252 -27
  135. package/kits/hub-game/code/client/together.js +4 -1
  136. package/kits/hub-game/code/client/uiDom.js +86 -8
  137. package/kits/hub-game/code/client/uiTree.js +33 -4
  138. package/kits/hub-game/code/client/vehicle.js +75 -52
  139. package/kits/hub-game/code/client/weakestTier.js +75 -31
  140. package/kits/hub-game/code/client/wear.js +159 -5
  141. package/kits/hub-game/code/client/worldLabels.js +215 -26
  142. package/kits/hub-game/code/companionSpec.js +4 -2
  143. package/kits/hub-game/code/server/act.js +3 -0
  144. package/kits/hub-game/code/server/actGate.js +83 -0
  145. package/kits/hub-game/code/server/actions.js +71 -15
  146. package/kits/hub-game/code/server/actors.js +20 -5
  147. package/kits/hub-game/code/server/analytics.js +40 -15
  148. package/kits/hub-game/code/server/ask.js +39 -3
  149. package/kits/hub-game/code/server/ballot.js +167 -4
  150. package/kits/hub-game/code/server/celebrate.js +64 -0
  151. package/kits/hub-game/code/server/companion.js +17 -2
  152. package/kits/hub-game/code/server/decor.js +11 -2
  153. package/kits/hub-game/code/server/disguise.js +63 -0
  154. package/kits/hub-game/code/server/doorAnalytics.js +2 -5
  155. package/kits/hub-game/code/server/earned.js +6 -2
  156. package/kits/hub-game/code/server/friendBests.js +13 -4
  157. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  158. package/kits/hub-game/code/server/grab.js +12 -2
  159. package/kits/hub-game/code/server/heldOffers.js +142 -0
  160. package/kits/hub-game/code/server/holdShow.js +98 -0
  161. package/kits/hub-game/code/server/hub.js +854 -45
  162. package/kits/hub-game/code/server/idle.js +110 -9
  163. package/kits/hub-game/code/server/index.js +9 -0
  164. package/kits/hub-game/code/server/labels.js +13 -3
  165. package/kits/hub-game/code/server/loadAbandon.js +2 -5
  166. package/kits/hub-game/code/server/manifest.js +94 -6
  167. package/kits/hub-game/code/server/menu.js +26 -3
  168. package/kits/hub-game/code/server/npcs.js +55 -9
  169. package/kits/hub-game/code/server/observe.js +67 -6
  170. package/kits/hub-game/code/server/players.js +8 -1
  171. package/kits/hub-game/code/server/replay.js +135 -0
  172. package/kits/hub-game/code/server/storageLimit.js +4 -1
  173. package/kits/hub-game/code/server/townDay.js +74 -0
  174. package/kits/hub-game/code/server/trackQueue.js +29 -0
  175. package/kits/hub-game/code/server/vehicle.js +3 -0
  176. package/kits/hub-game/code/server/vis.js +26 -4
  177. package/kits/hub-game/code/server/wallet.js +677 -0
  178. package/kits/hub-game/code/server/wear.js +13 -3
  179. package/kits/hub-game/code/server/writerLease.js +191 -0
  180. package/kits/hub-game/code/shared/act.js +1 -1
  181. package/kits/hub-game/code/shared/expression.js +6 -0
  182. package/kits/hub-game/code/shared/replay.js +37 -0
  183. package/kits/hub-game/code/systems/hub.js +437 -57
  184. package/kits/hub-game/docs/analytics.md +20 -3
  185. package/kits/hub-game/docs/contract.md +942 -99
  186. package/kits/hub-game/docs/home-pieces.md +5 -6
  187. package/kits/hub-game/docs/observed-progress.md +49 -1
  188. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  189. package/kits/hub-game/index.html +1 -0
  190. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  207. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  208. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  209. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  210. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  211. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  212. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  213. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  214. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  215. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  216. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  217. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  218. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  219. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  220. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  221. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  222. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  223. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  224. package/kits/hub-game/package-lock.json +3 -3
  225. package/kits/hub-game/package.json +4 -3
  226. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  227. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  228. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  229. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  230. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  231. package/kits/hub-game/scripts/pack.mjs +89 -23
  232. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  233. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  234. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  235. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  236. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  237. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  238. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  239. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  240. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  241. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  242. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  243. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  244. package/kits/hub-game/scripts/test-analytics.mjs +80 -1
  245. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  246. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  247. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  248. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  249. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  250. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  251. package/kits/hub-game/scripts/test-ballot.mjs +420 -3
  252. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  253. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  254. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  255. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  256. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  257. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  258. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  259. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  260. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  261. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  262. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  263. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  264. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  265. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  266. package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
  267. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  268. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  269. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  270. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  271. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  272. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  273. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  274. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  275. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  276. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  277. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  278. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  279. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  280. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  281. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  282. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  283. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  284. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  285. package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
  286. package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
  287. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  288. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  289. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  290. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  291. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  292. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  293. package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
  294. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  295. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  296. package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
  297. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  298. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  299. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  300. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  301. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  302. package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
  303. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  304. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  305. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  306. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  307. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  308. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  309. package/kits/hub-game/scripts/test-rehello.mjs +237 -0
  310. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  311. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  312. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  313. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  314. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  315. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  316. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  317. package/kits/hub-game/scripts/test-resync.mjs +13 -0
  318. package/kits/hub-game/scripts/test-role-client.mjs +10 -3
  319. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  320. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  321. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  322. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  323. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  324. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  325. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  326. package/kits/hub-game/scripts/test-stuck.mjs +31 -0
  327. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  328. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  329. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  330. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  331. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  332. package/kits/hub-game/scripts/test-together.mjs +11 -0
  333. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  334. package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
  335. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  336. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  337. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  338. package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
  339. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  340. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  341. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  342. package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
  343. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  344. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  345. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  346. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  347. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  348. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
  349. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
  350. package/kits/multiplayer-3d/castle.json +5 -5
  351. package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
  352. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  353. package/kits/multiplayer-3d/code/server/world.js +19 -4
  354. package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
  355. package/kits/multiplayer-3d/package-lock.json +1 -1
  356. package/kits/multiplayer-3d/package.json +2 -1
  357. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  358. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  359. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  360. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
  361. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  362. package/kits/physics-2d/castle.json +2 -2
  363. package/kits/physics-2d/engine/scene.js +10 -2
  364. package/kits/physics-3d/CLAUDE.md +14 -0
  365. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  366. package/kits/physics-3d/castle.json +3 -3
  367. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  368. package/kits/physics-3d/docs/engine-player.md +76 -0
  369. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  370. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  371. package/kits/physics-3d/engine3d/gait.js +16 -8
  372. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  373. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  374. package/kits/physics-3d/engine3d/look.js +110 -17
  375. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  376. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  377. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  378. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  379. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  380. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  381. package/kits/physics-3d/engine3d/optimize.js +20 -9
  382. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  383. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  384. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  385. package/kits/physics-3d/engine3d/world3d.js +211 -17
  386. package/kits/physics-3d/package-lock.json +1 -1
  387. package/kits/physics-3d/package.json +2 -1
  388. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  389. package/kits/physics-3d/scripts/render.mjs +56 -8
  390. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  391. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  392. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  393. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  394. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  395. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  396. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  397. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  398. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  399. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  400. package/kits/physics-3d/systems/physics3d.js +51 -2
  401. package/kits/real-time/castle.json +2 -2
  402. package/kits/real-time/code/client/connection.js +3 -0
  403. package/package.json +2 -2
  404. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -0,0 +1,90 @@
1
+ // The Town's day (v1.200): LA calendar days on the UTC day-number scale, LA
2
+ // midnights across both DST changes, and the switch-day conversion.
3
+ import assert from 'node:assert/strict';
4
+ import { TOWN_TIME_ZONE, townDay, townDayFrom, townDayStart } from '../code/server/townDay.js';
5
+
6
+ const DAY = 86400000;
7
+ const utcDay = (ms) => Math.floor(ms / DAY);
8
+ const la = (iso) => {
9
+ const [y, m, d] = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Los_Angeles' }).format(new Date(iso)).split('-').map(Number);
10
+ return Date.UTC(y, m - 1, d) / DAY;
11
+ };
12
+
13
+ assert.equal(TOWN_TIME_ZONE, 'America/Los_Angeles', 'the zone of hub-town daily.js');
14
+
15
+ // Before 00:00 UTC both reckonings agree; from 00:00 UTC to LA midnight the UTC
16
+ // day is one ahead.
17
+ const pdt = Date.parse('2026-10-26T06:59:59.999Z'); // 23:59:59.999 PDT, Oct 25
18
+ assert.equal(townDay(pdt), la('2026-10-26T06:59:59.999Z'));
19
+ assert.equal(townDay(pdt), utcDay(Date.parse('2026-10-25T12:00:00Z')));
20
+ assert.equal(townDay(pdt + 1), townDay(pdt) + 1, 'turns at 00:00 PDT');
21
+ assert.equal(townDay(Date.parse('2026-10-25T23:59:59Z')), utcDay(Date.parse('2026-10-25T23:59:59Z')));
22
+ assert.equal(townDay(Date.parse('2026-10-26T00:00:00Z')), utcDay(Date.parse('2026-10-26T00:00:00Z')) - 1);
23
+ const pst = Date.parse('2026-12-01T08:00:00Z'); // 00:00 PST
24
+ assert.equal(townDay(pst), townDay(pst - 1) + 1, 'turns at 00:00 PST');
25
+ assert.equal(townDay(pst), utcDay(pst));
26
+
27
+ // Weekday arithmetic over day numbers names the LA weekday.
28
+ assert.equal(new Date(townDay(Date.parse('2026-10-26T03:00:00Z')) * DAY).getUTCDay(), 0, 'Sunday evening in LA');
29
+
30
+ // Every LA midnight in a year, through both DST changes, is where the day turns.
31
+ for (let day = utcDay(Date.parse('2026-01-01T00:00:00Z')); day < utcDay(Date.parse('2027-01-02T00:00:00Z')); day++) {
32
+ const start = townDayStart(day);
33
+ assert.equal(townDay(start), day, `day ${day} starts at its own midnight`);
34
+ assert.equal(townDay(start - 1), day - 1, `the millisecond before day ${day} is the day before`);
35
+ assert.ok([7, 8].includes((start - day * DAY) / 3600000), `day ${day} starts at 07:00 or 08:00 UTC`);
36
+ }
37
+ assert.equal(townDayStart(utcDay(Date.parse('2026-03-08T12:00:00Z'))), Date.parse('2026-03-08T08:00:00Z'), 'spring-forward day starts in PST');
38
+ assert.equal(townDayStart(utcDay(Date.parse('2026-11-01T12:00:00Z'))), Date.parse('2026-11-01T07:00:00Z'), 'fall-back day starts in PDT');
39
+ assert.equal(townDayStart(utcDay(Date.parse('2026-11-01T12:00:00Z')) + 1) - townDayStart(utcDay(Date.parse('2026-11-01T12:00:00Z'))), 25 * 3600000, 'the fall-back day is 25 hours');
40
+
41
+ // The default clock is Date.now.
42
+ const realNow = Date.now;
43
+ Date.now = () => pdt;
44
+ try {
45
+ assert.equal(townDay(), townDay(pdt));
46
+ assert.equal(townDayFrom(townDay(pdt) + 1), townDay(pdt));
47
+ } finally {
48
+ Date.now = realNow;
49
+ }
50
+
51
+ // The switch day. A play at instant p stored its UTC day u(p); the Town's day
52
+ // at p was u(p) or u(p) - 1. Read on the Town's day t:
53
+ const now = Date.parse('2026-10-26T03:00:00Z'); // 20:00 PDT Oct 25, UTC day already Oct 26
54
+ const t = townDay(now);
55
+ assert.equal(utcDay(now), t + 1);
56
+ assert.equal(townDayFrom(t + 1, now), t, 'a UTC day ahead of the Town is today: no second claim');
57
+ assert.equal(townDayFrom(t, now), t, 'today stays today');
58
+ assert.equal(townDayFrom(t - 1, now), t - 1, 'yesterday stays yesterday: the streak holds');
59
+ assert.equal(townDayFrom(t - 5, now), t - 5);
60
+ // Converting twice changes nothing.
61
+ for (const d of [t + 1, t, t - 1]) { assert.equal(townDayFrom(townDayFrom(d, now), now), townDayFrom(d, now)); }
62
+ // Non-day values pass through.
63
+ for (const v of [null, undefined, -1.5, '20000', NaN]) { assert.equal(townDayFrom(v, now), v); }
64
+
65
+ // Bad input.
66
+ for (const v of [NaN, Infinity, '1', null, 9e15]) { assert.ok(Number.isNaN(townDay(v)), String(v)); }
67
+ for (const v of [1.5, NaN, '1', null, 1e9, 1e8]) { assert.ok(Number.isNaN(townDayStart(v)), String(v)); }
68
+
69
+ // Far dates: years 0-99 and BC keep their own year, and the range ends in NaN, not a throw.
70
+ const oracle = (ms) => {
71
+ const f = new Intl.DateTimeFormat('en-US', { timeZone: 'America/Los_Angeles', era: 'short', year: 'numeric', month: 'numeric', day: 'numeric' });
72
+ const o = Object.fromEntries(f.formatToParts(new Date(ms)).map(({ type, value }) => [type, value]));
73
+ const d = new Date(0);
74
+ d.setUTCFullYear(o.era === 'BC' ? 1 - Number(o.year) : Number(o.year), Number(o.month) - 1, Number(o.day));
75
+ return Math.floor(d.getTime() / DAY);
76
+ };
77
+ for (const iso of ['0099-12-31T12:00:00Z', '0001-01-01T12:00:00Z', '-000500-06-15T12:00:00Z', '1900-01-01T12:00:00Z']) {
78
+ const ms = Date.parse(iso);
79
+ assert.equal(townDay(ms), oracle(ms), iso);
80
+ assert.equal(townDay(townDayStart(townDay(ms))), townDay(ms), `${iso} round-trips`);
81
+ }
82
+ for (const day of [-1000000, 99999999, -99999999]) {
83
+ const start = townDayStart(day);
84
+ assert.ok(Number.isNaN(start) || townDay(start) === day, `day ${day}`);
85
+ }
86
+ for (const day of [100000000, -100000000]) { assert.ok(Number.isNaN(townDayStart(day)), `day ${day}`); }
87
+ assert.doesNotThrow(() => townDay(8.64e15));
88
+ assert.doesNotThrow(() => townDay(-8.64e15));
89
+
90
+ console.log('town day: ok');
@@ -0,0 +1,64 @@
1
+ import assert from 'node:assert/strict';
2
+ import * as A from '../code/server/analytics.js';
3
+ import * as D from '../code/server/doorAnalytics.js';
4
+ import { TRACK_IN_FLIGHT, TRACK_QUEUE_MAX } from '../code/server/trackQueue.js';
5
+ // The host refuses a hubTrack while two are in flight per session, the way
6
+ // cauldron host-agent's storage broker does, and answers on a later turn.
7
+ function host() {
8
+ const recorded = [], refused = [], answers = [];
9
+ let inFlight = 0;
10
+ const session = { players: [{ playerId: 'p' }], hub: { track(playerId, event) {
11
+ if (inFlight >= 2) { refused.push(event); return Promise.resolve(false); }
12
+ inFlight += 1;
13
+ return new Promise((resolve) => answers.push(() => { inFlight -= 1; recorded.push(event); resolve(true); }));
14
+ } } };
15
+ const settle = async () => { while (answers.length) { answers.shift()(); await new Promise((r) => setImmediate(r)); } };
16
+ return { session, recorded, refused, settle, inFlight: () => inFlight };
17
+ }
18
+ const handle = (session) => ({ place: { analytics: true }, manifest: {}, sim: { timeMs: 0 }, session,
19
+ players: new Map([['p', { arrived: true }]]), analytics: A.create() });
20
+ {
21
+ // A purchase in one tick: token_spent plus a pulse's start and outcome.
22
+ const s = host(), h = handle(s.session);
23
+ assert.equal(A.track(h, 'p', 'token_spent', { subject: 8, value: 3 }), true);
24
+ assert.equal(A.track(h, 'p', 'activity_start', { subject: 8 }), true);
25
+ assert.equal(A.track(h, 'p', 'outcome', { subject: 8, result: 1 }), true);
26
+ assert.equal(D.track(h, 'p', 'door_progress', { value: 1, result: 1 }), true);
27
+ assert.equal(s.inFlight(), TRACK_IN_FLIGHT, 'never more than the host allows in flight');
28
+ await s.settle();
29
+ assert.deepEqual(s.refused, [], 'the host refuses nothing');
30
+ assert.deepEqual(s.recorded.map((e) => e.kind), [20, 5, 7, 30], 'every row arrives, in order');
31
+ }
32
+ {
33
+ // A runaway deck cannot grow memory: past the bound, rows are refused at once.
34
+ const s = host(), h = handle(s.session);
35
+ let accepted = 0;
36
+ for (let i = 0; i < TRACK_IN_FLIGHT + TRACK_QUEUE_MAX + 50; i++) {if (A.track(h, 'p', 'outcome', { value: i })) {accepted++;}}
37
+ assert.equal(accepted, TRACK_IN_FLIGHT + TRACK_QUEUE_MAX);
38
+ await s.settle();
39
+ assert.equal(s.recorded.length, accepted);
40
+ assert.deepEqual(s.refused, []);
41
+ assert.deepEqual(s.recorded.map((e) => e.value), [...Array(accepted).keys()]);
42
+ }
43
+ {
44
+ // Each session has its own two slots; a scene change does not share a queue.
45
+ const a = host(), b = host(), h = handle(a.session);
46
+ for (let i = 0; i < 3; i++) {A.track(h, 'p', 'outcome');}
47
+ h.session = b.session;
48
+ for (let i = 0; i < 3; i++) {A.track(h, 'p', 'outcome');}
49
+ assert.equal(a.inFlight(), 2); assert.equal(b.inFlight(), 2);
50
+ await a.settle(); await b.settle();
51
+ assert.equal(a.recorded.length, 3); assert.equal(b.recorded.length, 3);
52
+ }
53
+ {
54
+ // A refused or thrown send frees its slot; an old host without track records nothing.
55
+ let n = 0;
56
+ const session = { hub: { track: () => (++n % 2 ? Promise.reject(new Error('down')) : (() => { throw new Error('sync'); })()) } };
57
+ const h = handle(session);
58
+ for (let i = 0; i < 6; i++) {A.track(h, 'p', 'outcome');}
59
+ await new Promise((r) => setImmediate(r));
60
+ assert(n >= 4, 'rejections free their slots');
61
+ assert.equal(A.track(handle({ hub: {} }), 'p', 'outcome'), false);
62
+ assert.equal(A.track(handle(null), 'p', 'outcome'), false);
63
+ }
64
+ console.log('track queue ok');
@@ -774,6 +774,45 @@ await test('a rejoin sends nothing new where no private try-on was ever sent', a
774
774
  }
775
775
  });
776
776
 
777
+ const wornAlone = (log) => log.filter((e) => e[0] === 'send' && JSON.parse(e[2]).k === 'hub-wear').map((e) => [e[1], JSON.parse(e[2]).hubWear]);
778
+
779
+ await test('a reload in a hidden pair is sent its private wearables again, as it is its try-ons', async () => {
780
+ // p1 and p2 hide each other: p1's saved halo reaches p1 and p3 only through
781
+ // `hub-wear`, which a reloaded page has lost.
782
+ const r = room(here.layer, { hides: p1p2 });
783
+ for (const id of ['p1', 'p2', 'p3']) {
784
+ r.enter(id);
785
+ }
786
+ await r.tick();
787
+ await flush();
788
+ await r.tick();
789
+ r.delta();
790
+ assert.deepEqual(wornAlone(r.log.splice(0)).filter(([to]) => to !== 'p2'), [
791
+ ['p1', { p1: halo }],
792
+ ['p3', { p1: halo }],
793
+ ]);
794
+ // p1 reloads on the same id: its own halo comes back on the next tick.
795
+ r.exit('p1');
796
+ await r.tick();
797
+ r.body('p1');
798
+ r.hello('p1');
799
+ await r.tick();
800
+ await flush();
801
+ await r.tick();
802
+ r.join();
803
+ r.delta();
804
+ assert.deepEqual(wornAlone(r.log).filter(([to]) => to === 'p1'), [['p1', { p1: halo }]]);
805
+ assert.deepEqual(client(here, 'p1').feed(r.log.splice(0)), { p1: halo });
806
+ // A fresh page with nothing private to see is told the empty map once.
807
+ r.hello('p2');
808
+ await r.tick();
809
+ assert.deepEqual(wornAlone(r.log.splice(0)), [['p2', {}]]);
810
+ // A hello that is only an avatar change is the same page: nothing again.
811
+ r.hello('p1', { again: true });
812
+ await r.tick();
813
+ assert.deepEqual(wornAlone(r.log.splice(0)), []);
814
+ });
815
+
777
816
  await test('a try-on made before the player’s hello goes when they do: none comes back with their id, and the place’s end leaves none', async () => {
778
817
  const r = room(here.layer);
779
818
  r.enter('p2');
@@ -1,6 +1,7 @@
1
1
  // The UI tree's DOM renderer in a real browser: rebuilding a root keeps a
2
2
  // focused field's caret and selection, keeps a log's scroll position, and
3
- // applies the talk log's scroll rules from measured layout.
3
+ // applies the talk log's scroll rules from measured layout; a slider under a
4
+ // real pointer and keyboard releases once per hold.
4
5
  import assert from 'node:assert/strict';
5
6
  import { readFile } from 'node:fs/promises';
6
7
  import { fileURLToPath } from 'node:url';
@@ -92,5 +93,51 @@ try {
92
93
  assert.equal(result.cleared, '', 'a version bump writes the value');
93
94
  assert(result.refollowVisible, 'chips re-apply a followed reply\'s alignment');
94
95
  assert(result.disposed, 'dispose takes out every node and the dots\' style');
95
- console.log('UI tree DOM: focus, selection, scroll keeping and scroll rules passed');
96
+ // The slider (v1.198) under a real pointer and keyboard: one release per
97
+ // hold, moved or not, and the game's value again once it is let go.
98
+ await page.evaluate(async () => {
99
+ const { h } = await import('/kits/hub-game/code/client/uiTree.js');
100
+ const { mountUiTree } = await import('/kits/hub-game/code/client/uiDom.js');
101
+ const box = document.createElement('div');
102
+ box.style.cssText = 'position:fixed;left:0;top:0;width:200px;height:40px';
103
+ document.body.append(box);
104
+ const ui = mountUiTree(box);
105
+ window.sliderEvents = [];
106
+ window.drawSlider = (value) => ui.render(h('stack', { key: 'r' }, h('row', { key: 'row', style: { w: 200, h: 40, align: 'center' } },
107
+ h('slider', { key: 's', value, min: 0, max: 100, step: 1, style: { flex: 1, minW: 0, h: 28 },
108
+ on: { input: (e) => window.sliderEvents.push(['input', e.value]), release: (e) => window.sliderEvents.push(['release', e.value]) } }))));
109
+ window.drawSlider(50);
110
+ window.sliderEl = ui.nodeFor('r/row/s');
111
+ });
112
+ const rect = await page.evaluate(() => {const r = window.sliderEl.getBoundingClientRect(); return { x: r.x, y: r.y, w: r.width, h: r.height };});
113
+ const midY = rect.y + rect.h / 2;
114
+ const at = (v) => rect.x + 8 + (rect.w - 16) * v / 100;
115
+ const read = () => page.evaluate(() => ({ events: window.sliderEvents.splice(0), value: window.sliderEl.value, focused: document.activeElement === window.sliderEl }));
116
+ // A press on the thumb that does not move it.
117
+ await page.mouse.move(at(50), midY);
118
+ await page.mouse.down();
119
+ await page.mouse.up();
120
+ const still = await read();
121
+ assert.deepEqual(still.events.filter(([e]) => e === 'release').length, 1, `a still press is let go: ${JSON.stringify(still)}`);
122
+ assert(!still.focused, 'let go: not focused');
123
+ await page.evaluate(() => window.drawSlider(30));
124
+ assert.equal((await read()).value, '30', 'the game\'s value again after a still press');
125
+ // A drag, let go off the slider.
126
+ await page.mouse.move(at(30), midY);
127
+ await page.mouse.down();
128
+ await page.mouse.move(at(80), midY, { steps: 5 });
129
+ await page.evaluate(() => window.drawSlider(10));
130
+ const held = await read();
131
+ assert(held.events.some(([e]) => e === 'input') && !held.events.some(([e]) => e === 'release'), `inputs while held: ${JSON.stringify(held)}`);
132
+ assert.notEqual(held.value, '10', 'held: the player\'s value');
133
+ await page.mouse.move(at(80), 300);
134
+ await page.mouse.up();
135
+ const dragged = await read();
136
+ assert.equal(dragged.events.filter(([e]) => e === 'release').length, 1, `one release for a drag: ${JSON.stringify(dragged)}`);
137
+ // The keyboard: focus, an arrow, one release.
138
+ await page.evaluate(() => window.sliderEl.focus());
139
+ await page.keyboard.press('ArrowRight');
140
+ const keyed = await read();
141
+ assert.equal(keyed.events.filter(([e]) => e === 'release').length, 1, `one release for a key: ${JSON.stringify(keyed)}`);
142
+ console.log('UI tree DOM: focus, selection, scroll keeping, scroll rules and the slider passed');
96
143
  } finally {await browser.close();}
@@ -67,6 +67,22 @@ await test('Len, edges and styles: the strings the chrome writes', () => {
67
67
  assert.equal(cssFor(h('column', { style: { gap: 4 } }, h('text', { text: 'a' })), 'stack').display, 'flex');
68
68
  });
69
69
 
70
+ await test('v1.167: a pad side edge, aspect and the glow preset; trees without them keep their bytes', () => {
71
+ // A pad with an edge value is written as four sides, each on its own inset.
72
+ assert.equal(cssFor(h('column', { style: { pad: [12, 12, [12, 0], 12] } }), 'stack').padding, '12px 12px max(12px, env(safe-area-inset-bottom)) 12px');
73
+ assert.equal(cssFor(h('column', { style: { pad: [[8, 4], 10] } }), 'stack').padding, 'max(8px, calc(env(safe-area-inset-top) + 4px)) 10px max(8px, calc(env(safe-area-inset-bottom) + 4px)) 10px');
74
+ assert.equal(cssFor(h('column', { style: { pad: [6, 8] } }), 'stack').padding, '6px 8px');
75
+ assert.equal(cssFor(h('column', { style: { pad: 12 } }), 'stack').padding, '12px');
76
+ // The two-line clip counts an edge side at its min.
77
+ assert.equal(cssFor(h('text', { style: { size: 13, lh: 1.3, pad: [[4, 0], 8, 4, 8], lines: 2, ellipsis: false } }), 'column').maxHeight, '41.8px');
78
+ assert.equal(cssFor(h('button', { style: { aspect: 1 } }), 'grid').aspectRatio, '1');
79
+ assert.equal(cssFor(h('button', { style: { aspect: 0 } }), 'grid').aspectRatio, undefined);
80
+ assert.equal(cssFor(h('button', { style: { shadow: 'glow' } }), 'grid').boxShadow, '0 0 0 3px rgba(255,216,74,0.5)');
81
+ assert.deepEqual(validate(h('column', { key: 'r', style: { aspect: 1.5, pad: [1, 2, [3, 4], 5], shadow: 'glow' } })), []);
82
+ const before = JSON.stringify(serialize(h('column', { key: 'r', style: { pad: [12, 12, 12, 12], shadow: 'card' } }, h('text', { text: 'a' }))).wire);
83
+ assert.equal(before, '{"t":"column","k":"r","s":{"pad":[12,12,12,12],"shadow":"card"},"c":[{"t":"text","text":"a"}]}');
84
+ });
85
+
70
86
  // The stand-in DOM, with focus and blur counted.
71
87
  function stage(view = { viewW: 390, viewH: 844 }) {
72
88
  const dom = fakeDom(view);
@@ -217,6 +233,18 @@ await test('builders: every HUD and talk variant is a valid tree, and stable byt
217
233
  }
218
234
  const pair = serialize(buildActPair({ show: true, enabled: true, on: pairOn }), 'hud');
219
235
  assert.deepEqual([...pair.handlers.keys()], ['hud/act#press', 'hud/act#release', 'hud/act#cancel', 'hud/jump#tap']);
236
+ // v1.204: catching up, Act says so, dimmed but pressable even with nothing
237
+ // in reach, so a press can be refused with a line; Jump is untouched.
238
+ for (const enabled of [false, true]) {
239
+ const caught = buildActPair({ show: true, enabled, catching: true, on: pairOn });
240
+ assert.deepEqual(validate(caught), []);
241
+ const [act, jump] = caught.c;
242
+ assert.equal(act.c[0].text, 'Catching up');
243
+ assert.equal(act.disabled, false);
244
+ assert.equal(act.s.opacity, 0.5);
245
+ assert.deepEqual(jump, buildActPair({ show: true, enabled, on: pairOn }).c[1]);
246
+ }
247
+ assert.equal(serialize(buildActPair({ show: true, enabled: true, on: pairOn })).json, serialize(buildActPair({ show: true, enabled: true, catching: false, on: pairOn })).json, 'no change when not catching');
220
248
  const talks = [];
221
249
  for (const mind of [false, true]) {
222
250
  const view = makeTalkView();
@@ -17,7 +17,7 @@ register(`data:text/javascript,${encodeURIComponent(`
17
17
  }
18
18
  }
19
19
  `)}`);
20
- const { makeVehicle, pinRiders, tintPaint } = await import('../code/client/vehicle.js');
20
+ const { makeVehicle, pinRiders, tintPaint, placedHeading, PLACED_TURN } = await import('../code/client/vehicle.js');
21
21
  const { parseCar, vehicleOf } = await import('../code/shared/car.js');
22
22
  const { hub, clear } = await import('../code/client/state.js');
23
23
  const { makeIdle, SEAT_DROP_M } = await import('../code/client/idle.js');
@@ -104,10 +104,52 @@ const near = (a, b) => assert.ok(Math.abs(a - b) < 1e-8, `${a} ≈ ${b}`);
104
104
  // Both Player camera/control branches call the same generic seam.
105
105
  let calls = 0; scene.playerDrive = { step() {calls++;} }; scene.cameraControl = 'orbit';
106
106
  new Player(local.components.Player).update(local, scene, 0.1); assert.equal(calls, 1);
107
+ // A look swap while driving keeps the speed; a dynamics change does not.
108
+ const drive = () => {impulses.length = 0; new Player(local.components.Player).update(local, scene, 0.1); return Math.max(...impulses.map(v => v.z));};
109
+ v.clear(); scene.physics3d.setVelocity(local, { x: 0, y: 0, z: 0 });
110
+ hub.cars = { me: car() }; v.frame(scene, local, hub.cars); drive(); drive(); const third = drive();
111
+ hub.cars = { me: { ...hub.cars.me, look: 'car-lit', color: '#0000ff' } }; v.frame(scene, local, hub.cars);
112
+ assert.ok(drive() > third, 'a look swap keeps accelerating from the current speed');
113
+ hub.cars = { me: { ...hub.cars.me, speed: 20 } }; v.frame(scene, local, hub.cars);
114
+ const fresh = drive(); hub.cars = { me: car() }; v.clear(); v.frame(scene, local, hub.cars);
115
+ near(fresh, drive());
107
116
  // Restore only a seam we own; another system's replacement stays installed.
108
117
  v.clear(); assert.equal(scene.playerDrive.step instanceof Function, true);
109
118
  delete scene.cameraControl; scene.playerDrive = previous; v.frame(scene, local, hub.cars); v.frame(scene, local, {}); assert.equal(scene.playerDrive, previous);
110
119
  }
120
+ {
121
+ // Under the orbit key the Player's camDistance/camHeight do not move the
122
+ // camera: the driver is chased from the car's cam, the orbit zoom untouched.
123
+ const { scene, local } = boot(), v = makeVehicle();
124
+ scene.cameraControl = 'orbit';
125
+ hub.cars = { me: { ...car(), cam: { distance: 12, height: 8 } } };
126
+ v.frame(scene, local, hub.cars);
127
+ assert.equal(local.components.Player.camDistance, 9, 'no Player camera write under orbit');
128
+ assert.equal(local.components.Player.camHeight, 7);
129
+ v.camera(scene, local, hub.cars);
130
+ const cam = scene.three.camera.position;
131
+ near(cam.x, 1); near(cam.y, 1 + 8); near(cam.z, 2 - 12);
132
+ // The heading turns 90 degrees: the chase eases toward it, never jumps.
133
+ local.components.Transform.rotationY = 90;
134
+ await new Promise(resolve => setTimeout(resolve, 50));
135
+ v.camera(scene, local, hub.cars);
136
+ const behind = Math.atan2(-(cam.x - 1), -(cam.z - 2));
137
+ assert.ok(behind > 0 && behind < Math.PI / 2, `eased part way: ${behind}`);
138
+ // Without the car's cam: 1.4x the orbit's own walking distance and height.
139
+ v.clear(); local.components.Transform.rotationY = 0;
140
+ scene.cameraOrbit = { range: 5, pitch: 0.3 };
141
+ hub.cars = { me: car() }; v.frame(scene, local, hub.cars); v.camera(scene, local, hub.cars);
142
+ near(cam.z, 2 - 5 * Math.cos(0.3) * 1.4); near(cam.y, 1 + (5 * Math.sin(0.3) + 0.438) * 1.4);
143
+ // A moment shot owns the camera while it lasts.
144
+ cam.set(0, 0, 0); scene.orbitShot = { look: { x: 0, y: 0, z: 0 }, distance: 3, pitch: 10, yaw: 0 };
145
+ v.camera(scene, local, hub.cars); assert.deepEqual(cam.toArray(), [0, 0, 0]);
146
+ delete scene.orbitShot;
147
+ // A follow-camera place leaves the driver to the Player behavior, as before.
148
+ v.clear(); delete scene.cameraControl; cam.set(0, 0, 0);
149
+ v.frame(scene, local, hub.cars); v.camera(scene, local, hub.cars);
150
+ assert.deepEqual(cam.toArray(), [0, 0, 0]);
151
+ v.clear(); hub.cars = {};
152
+ }
111
153
  {
112
154
  const { scene, local, driver, placements, impulses } = boot(), v = makeVehicle();
113
155
  hub.cars = { driver: { ...car(), riders: { 1: 'me' } } };
@@ -123,6 +165,40 @@ const near = (a, b) => assert.ok(Math.abs(a - b) < 1e-8, `${a} ≈ ${b}`);
123
165
  hub.cars = {}; idle.draw(scene, local); near(scene.three.nodes.get('local').node.children[0].position.y, -0.7);
124
166
  v.frame(scene, local, hub.cars); assert.equal(scene.playerDrive, undefined); idle.release();
125
167
  }
168
+ {
169
+ // v1.165 fix: a server placement with a facing sets a driver's heading,
170
+ // from rest. Walked in at 228.65 deg, put on the grid facing 90 deg (held),
171
+ // then reset to the centre-line facing 90 while driving at 200 deg.
172
+ const DEG = Math.PI / 180;
173
+ const { scene, local, impulses } = boot(), v = makeVehicle();
174
+ local.components.Transform.rotationY = 228.65;
175
+ hub.cars = { me: car() };
176
+ v.frame(scene, local, hub.cars);
177
+ const step = () => {impulses.length = 0; scene.playerDrive.step(local, scene.physics3d, { keys: scene.keys, stick: scene.moveInput, grounded: true }, 0.1);};
178
+ hub.held.add('me');
179
+ hub.selfClamp = { x: 1, y: 1, z: 2, facing: 90 * DEG, at: performance.now() };
180
+ step();
181
+ near(local.components.Transform.rotationY, 90);
182
+ assert.equal(hub.selfClamp, null, 'taken once');
183
+ hub.held.clear();
184
+ step(); step();
185
+ const push = impulses.at(-1);
186
+ assert.ok(push.x > 0 && Math.abs(push.z) < 1e-6, `GO drives along +x: ${JSON.stringify(push)}`);
187
+ local.components.Transform.rotationY = 200;
188
+ hub.selfClamp = { x: 1, y: 1, z: 2, facing: 90 * DEG, at: performance.now() };
189
+ step();
190
+ near(local.components.Transform.rotationY, 90);
191
+ const after = impulses.at(-1);
192
+ assert.ok(after.x >= 0 && after.x < push.x + 1e-9, 'from rest after the reset');
193
+ // An ordinary refused move (a few degrees, a small step) keeps the car's
194
+ // own heading and speed; a stale clamp is ignored.
195
+ const before = { speed: 9, heading: 1 };
196
+ assert.equal(placedHeading({ x: 0, z: 0, facing: 1 + PLACED_TURN / 2, at: 0 }, before, { at: { x: 0.3, z: 0 }, now: 10 }), null);
197
+ assert.deepEqual(placedHeading({ x: 0, z: 0, facing: 1 + PLACED_TURN / 2, at: 0 }, before, { at: { x: 3, z: 0 }, now: 10 }), { speed: 0, heading: 1 + PLACED_TURN / 2 });
198
+ assert.equal(placedHeading({ x: 0, z: 0, facing: 3, at: 0 }, before, { now: 5000 }), null);
199
+ assert.deepEqual(placedHeading({ x: 0, z: 0, facing: 1, at: 0 }, before, { held: true, now: 10 }), { speed: 0, heading: 1 });
200
+ v.clear();
201
+ }
126
202
  {
127
203
  // Execute the actual kit hooks without the Vite-only module bootstrap.
128
204
  const source = fs.readFileSync(new URL('../code/client/hookLayer.js', import.meta.url), 'utf8');
@@ -764,6 +764,151 @@ test('drawing re-applies both transitions from merged changes, including Models
764
764
  assert.equal(drawing.stash.size, 0);
765
765
  });
766
766
 
767
+ test('v1.184 solid: only a private hide takes it; bad values are refused atomically, warning once', () => {
768
+ const r = boot();
769
+ r.hub.hide('trophy-0', { to: ['p1'] });
770
+ r.step();
771
+ const before = JSON.stringify(r.server.join());
772
+ for (const solid of [1, 'yes', null, {}]) {
773
+ assert.equal(r.hub.hide('trophy-1', { to: ['p1', 'p2'], solid }), false);
774
+ assert.equal(r.hub.hide('trophy-0', { to: ['p1'], solid }), false, 'an existing override is not replaced');
775
+ }
776
+ assert.equal(r.hub.show('trophy-1', { to: ['p1'], solid: true }), false, 'show refuses solid: true');
777
+ assert.equal(r.hub.show('trophy-1', { to: ['p1'], solid: 'x' }), false);
778
+ assert.equal(warnings.filter((msg) => msg.includes('hub.hide: visibility options')).length, 1);
779
+ assert.equal(warnings.filter((msg) => msg.includes('hub.show: visibility options')).length, 1);
780
+ r.step();
781
+ assert.equal(visibility(r).length, 1, 'refusals changed nothing');
782
+ assert.deepEqual(visibility(r)[0][1], { k: 'hub-vis', hide: ['trophy-0'], show: [] });
783
+ assert.equal(JSON.stringify(r.server.join()), before);
784
+ assert.equal(r.hub.show('trophy-1', { to: ['p1'], solid: false }), true, 'solid: false on show changes nothing');
785
+ r.step();
786
+ assert.deepEqual(visibility(r).at(-1)[1], { k: 'hub-vis', hide: ['trophy-0'], show: ['trophy-1'] });
787
+ });
788
+
789
+ test('v1.184 solid: hub-vis names solid ids only when used; replacement, clear and fresh join', () => {
790
+ const r = boot();
791
+ r.hello('p1');
792
+ r.hello('p2');
793
+ assert.equal(r.hub.hide('trophy-2', { to: ['p1'], solid: true }), true);
794
+ assert.equal(r.hub.hide('trophy-1', { to: ['p1', 'p2'], solid: true }), true);
795
+ assert.equal(r.hub.hide('trophy-0', { to: ['p1'], solid: false }), true);
796
+ r.step();
797
+ assert.deepEqual(visibility(r), [
798
+ ['p1', { k: 'hub-vis', hide: ['trophy-0', 'trophy-1', 'trophy-2'], show: [], solid: ['trophy-1', 'trophy-2'] }],
799
+ ['p2', { k: 'hub-vis', hide: ['trophy-1'], show: [], solid: ['trophy-1'] }],
800
+ ]);
801
+ assert.deepEqual(r.enabled, [], 'server bodies are untouched');
802
+ assert.ok(r.hub.hide('trophy-1', { to: ['p1'], solid: true }));
803
+ r.step();
804
+ assert.equal(visibility(r).length, 2, 'an equal solid map sends nothing');
805
+ r.sent.length = 0;
806
+ r.hello('p1');
807
+ assert.deepEqual(visibility(r), [['p1', { k: 'hub-vis', hide: ['trophy-0', 'trophy-1', 'trophy-2'], show: [], solid: ['trophy-1', 'trophy-2'] }]],
808
+ 'a fresh join replays solid');
809
+ // A plain hide replaces a solid one; clear drops it, solid: true or not.
810
+ r.hub.hide('trophy-2', { to: ['p1'] });
811
+ assert.equal(r.hub.hide('trophy-1', { to: ['p1'], clear: true, solid: true }), true);
812
+ r.step();
813
+ assert.deepEqual(visibility(r).at(-1), ['p1', { k: 'hub-vis', hide: ['trophy-0', 'trophy-2'], show: [] }]);
814
+ assert.ok(!('solid' in visibility(r).at(-1)[1]), 'no solid key once none is solid');
815
+ });
816
+
817
+ test('v1.184 solid: a place that never passes solid sends byte-identical hub-vis', () => {
818
+ const plain = boot(), explicit = boot();
819
+ for (const r of [plain, explicit]) {
820
+ r.hello('p1');
821
+ r.hub.hide('trophy-0', { to: ['p1'], ...(r === explicit ? { solid: false } : {}) });
822
+ r.hub.show('trophy-1', { to: ['p1'] });
823
+ r.step();
824
+ }
825
+ assert.equal(JSON.stringify(explicit.sent), JSON.stringify(plain.sent));
826
+ assert.equal(JSON.stringify(visibility(plain)), JSON.stringify([['p1', { k: 'hub-vis', hide: ['trophy-0'], show: ['trophy-1'] }]]));
827
+ });
828
+
829
+ test('v1.184 solid: retained resumeVisibility return carries solid', () => {
830
+ const r = boot(
831
+ { result: { score: { unit: 's', better: 'lower' } }, resume: { keep: true }, resumeVisibility: true },
832
+ { resume(ctx, { playerId }) { ctx.hide('trophy-3', { to: [playerId], solid: true }); } },
833
+ );
834
+ arrive(r);
835
+ r.hub.hide('trophy-3', { to: ['p1'], solid: true });
836
+ r.step();
837
+ r.session.players = r.session.players.filter((player) => player.playerId !== 'p1');
838
+ r.step();
839
+ r.session.players.push(r.players[0]);
840
+ const from = r.sent.length;
841
+ r.hello('p1', { resume: true });
842
+ r.step();
843
+ const returning = r.sent.slice(from).filter(([id, msg]) => id === 'p1' && msg.k === 'hub-vis').map(([, msg]) => msg);
844
+ assert.deepEqual(returning, [{ k: 'hub-vis', hide: ['trophy-3'], show: [], solid: ['trophy-3'] }]);
845
+ });
846
+
847
+ test('v1.184 solid: client keeps a solid-hidden actor in place, collider and all, drawing nothing of it', () => {
848
+ const source = readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
849
+ const method = source.slice(source.indexOf(' applyVisibility(scene) {'), source.indexOf('\n // Copies the place spawned'));
850
+ const apply = new Function('Hub', 'HIDE_DROP_M', `return ({${method}}).applyVisibility;`)(State, 10000);
851
+ const wall = structuredClone(actors[1]);
852
+ const rig = { visible: true }, off = { visible: false };
853
+ const node = { visible: true, children: [rig, off] };
854
+ const touches = [];
855
+ const scene = {
856
+ getActor: (id) => id === wall.id ? wall : null,
857
+ touch: (id) => touches.push(id),
858
+ three: { nodes: new Map([[wall.id, { node }]]) },
859
+ };
860
+ const drawing = { stash: new Map() };
861
+ const frame = () => apply.call(drawing, scene);
862
+ const vis = (msg) => hook.message({}, { k: 'hub-vis', show: [], ...msg });
863
+ vis({ hide: [wall.id], solid: [wall.id] });
864
+ assert.deepEqual([...State.hub.hidden], [wall.id], 'every other reader still sees it hidden');
865
+ frame(); frame();
866
+ assert.equal(wall.components.Transform.y, 3, 'the Transform, and so the collider, stays put');
867
+ assert.equal(rig.visible, false, 'its children are drawn hidden');
868
+ assert.equal(node.visible, true, 'the node flag is left to the tier and quality levers');
869
+ assert.deepEqual(touches, []);
870
+ // Solid -> plain private hide: drawn again, then dropped as before.
871
+ vis({ hide: [wall.id] });
872
+ frame();
873
+ assert.equal(rig.visible, true);
874
+ assert.equal(off.visible, false, 'a child already off stays off');
875
+ assert.equal(wall.components.Transform.y, -9997);
876
+ // Plain -> solid: lifted back up and drawn hidden in place.
877
+ vis({ hide: [wall.id], solid: [wall.id] });
878
+ frame();
879
+ assert.equal(wall.components.Transform.y, 3);
880
+ assert.equal(rig.visible, false);
881
+ // A rebuilt node gives the old one's children their flag back and hides the new one's.
882
+ const rebuiltRig = { visible: true };
883
+ const rebuilt = { visible: true, children: [rebuiltRig] };
884
+ scene.three.nodes.set(wall.id, { node: rebuilt });
885
+ frame();
886
+ assert.equal(rig.visible, true);
887
+ assert.equal(rebuiltRig.visible, false);
888
+ // A shared hide disables the body on the server: the client drops it.
889
+ hook.state({}, { hidden: [wall.id] });
890
+ assert.equal(State.hub.hiddenSolid.size, 0);
891
+ frame();
892
+ assert.equal(rebuiltRig.visible, true);
893
+ assert.equal(wall.components.Transform.y, -9997);
894
+ hook.state({}, { hidden: [] });
895
+ vis({ hide: [wall.id], solid: [wall.id] });
896
+ frame();
897
+ // Cleared: shown, in place.
898
+ vis({ hide: [] });
899
+ frame(); frame();
900
+ assert.equal(rebuiltRig.visible, true);
901
+ assert.equal(rebuilt.visible, true);
902
+ assert.equal(wall.components.Transform.y, 3);
903
+ assert.equal(drawing.stash.size, 0);
904
+ // A solid id outside the private hide list means nothing.
905
+ vis({ hide: [], solid: [wall.id] });
906
+ assert.equal(State.hub.hidden.size, 0);
907
+ assert.equal(State.hub.hiddenSolid.size, 0);
908
+ State.clear();
909
+ assert.equal(State.hub.solidMe.size, 0);
910
+ });
911
+
767
912
  console.warn = warn;
768
913
  console.log = log;
769
914
  State.clear();