castle-web-cli 0.4.239 → 0.4.241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +163 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +6 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +2 -0
  19. package/dist/platformDoc.js +3 -2
  20. package/dist/playPagePolicy.js +5 -1
  21. package/dist/resetLeaderboards.d.ts +8 -1
  22. package/dist/resetLeaderboards.js +43 -8
  23. package/dist/roomLogs.d.ts +1 -0
  24. package/dist/roomLogs.js +30 -6
  25. package/dist/save-deck.d.ts +32 -2
  26. package/dist/save-deck.js +240 -39
  27. package/kits/base/CLAUDE.md +1 -1
  28. package/kits/base/castle.json +1 -1
  29. package/kits/base/sdk/README.md +174 -6
  30. package/kits/base/sdk/analytics.d.ts +8 -0
  31. package/kits/base/sdk/analytics.js +92 -0
  32. package/kits/base/sdk/castle.d.ts +5 -1
  33. package/kits/base/sdk/castle.js +2 -0
  34. package/kits/base/sdk/commands.d.ts +48 -0
  35. package/kits/base/sdk/commands.js +1 -0
  36. package/kits/base/sdk/debugConsole.d.ts +17 -0
  37. package/kits/base/sdk/debugConsole.js +154 -0
  38. package/kits/base/sdk/experiments.js +24 -1
  39. package/kits/base/sdk/hostRetry.d.ts +7 -0
  40. package/kits/base/sdk/hostRetry.js +57 -0
  41. package/kits/base/sdk/hub.d.ts +20 -2
  42. package/kits/base/sdk/hub.js +99 -13
  43. package/kits/base/sdk/multiplayer.d.ts +2 -0
  44. package/kits/base/sdk/multiplayer.js +168 -26
  45. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  46. package/kits/base/sdk/reconnectBudget.js +41 -1
  47. package/kits/base/sdk/runtime.js +36 -19
  48. package/kits/base/sdk/server/hub.d.ts +19 -0
  49. package/kits/base/sdk/server/hub.js +12 -0
  50. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  51. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  52. package/kits/base/sdk/server/wrapper.js +26 -1
  53. package/kits/base/sdk/transport.d.ts +2 -1
  54. package/kits/base/sdk/transport.js +35 -0
  55. package/kits/hub-game/CLAUDE.md +66 -19
  56. package/kits/hub-game/code/client/act.js +9 -6
  57. package/kits/hub-game/code/client/actCore.js +26 -6
  58. package/kits/hub-game/code/client/actGateLog.js +36 -0
  59. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  60. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  61. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  62. package/kits/hub-game/code/client/askSurface.js +85 -0
  63. package/kits/hub-game/code/client/askTree.js +51 -0
  64. package/kits/hub-game/code/client/attention.js +31 -6
  65. package/kits/hub-game/code/client/ballot.js +42 -5
  66. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  67. package/kits/hub-game/code/client/ballotTree.js +180 -0
  68. package/kits/hub-game/code/client/catchingUp.js +19 -0
  69. package/kits/hub-game/code/client/celebrate.js +66 -0
  70. package/kits/hub-game/code/client/chrome.js +481 -57
  71. package/kits/hub-game/code/client/companion.js +93 -23
  72. package/kits/hub-game/code/client/companionDress.js +1 -1
  73. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  74. package/kits/hub-game/code/client/cornerTree.js +83 -0
  75. package/kits/hub-game/code/client/decor.js +20 -11
  76. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  77. package/kits/hub-game/code/client/disguise.js +23 -0
  78. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  79. package/kits/hub-game/code/client/dockSurface.js +206 -0
  80. package/kits/hub-game/code/client/dockTree.js +232 -0
  81. package/kits/hub-game/code/client/earned.js +29 -0
  82. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  83. package/kits/hub-game/code/client/emoteTree.js +264 -0
  84. package/kits/hub-game/code/client/farAvatars.js +4 -3
  85. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  86. package/kits/hub-game/code/client/grab.js +121 -50
  87. package/kits/hub-game/code/client/holdShow.js +19 -0
  88. package/kits/hub-game/code/client/hookLayer.js +96 -12
  89. package/kits/hub-game/code/client/hubControls.js +7 -1
  90. package/kits/hub-game/code/client/hudSurface.js +11 -3
  91. package/kits/hub-game/code/client/hudTree.js +7 -4
  92. package/kits/hub-game/code/client/idle.js +21 -3
  93. package/kits/hub-game/code/client/invites.js +24 -3
  94. package/kits/hub-game/code/client/keys.js +15 -0
  95. package/kits/hub-game/code/client/labelsNear.js +8 -1
  96. package/kits/hub-game/code/client/layoutCache.js +57 -8
  97. package/kits/hub-game/code/client/loadingCover.js +53 -4
  98. package/kits/hub-game/code/client/menuIcons.js +15 -0
  99. package/kits/hub-game/code/client/menuSurface.js +102 -0
  100. package/kits/hub-game/code/client/menuTree.js +135 -0
  101. package/kits/hub-game/code/client/modelLook.js +41 -0
  102. package/kits/hub-game/code/client/padCues.js +11 -7
  103. package/kits/hub-game/code/client/padReadability.js +3 -3
  104. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  105. package/kits/hub-game/code/client/pickerTree.js +163 -0
  106. package/kits/hub-game/code/client/pushVisit.js +4 -2
  107. package/kits/hub-game/code/client/quality.js +188 -29
  108. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  109. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  110. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  111. package/kits/hub-game/code/client/rehello.js +75 -0
  112. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  113. package/kits/hub-game/code/client/replay.js +118 -0
  114. package/kits/hub-game/code/client/role.js +3 -0
  115. package/kits/hub-game/code/client/safeLayout.js +441 -56
  116. package/kits/hub-game/code/client/safeStyle.js +13 -10
  117. package/kits/hub-game/code/client/say.js +2 -0
  118. package/kits/hub-game/code/client/soundSurface.js +77 -0
  119. package/kits/hub-game/code/client/soundTree.js +74 -0
  120. package/kits/hub-game/code/client/soundscape.js +12 -9
  121. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  122. package/kits/hub-game/code/client/state.js +67 -1
  123. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  124. package/kits/hub-game/code/client/stuckTree.js +67 -0
  125. package/kits/hub-game/code/client/talk.js +42 -12
  126. package/kits/hub-game/code/client/talkTree.js +4 -2
  127. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  128. package/kits/hub-game/code/client/textAskTree.js +67 -0
  129. package/kits/hub-game/code/client/tiers.js +252 -27
  130. package/kits/hub-game/code/client/together.js +4 -1
  131. package/kits/hub-game/code/client/uiDom.js +86 -8
  132. package/kits/hub-game/code/client/uiTree.js +33 -4
  133. package/kits/hub-game/code/client/vehicle.js +72 -51
  134. package/kits/hub-game/code/client/weakestTier.js +75 -31
  135. package/kits/hub-game/code/client/wear.js +159 -5
  136. package/kits/hub-game/code/client/worldLabels.js +205 -25
  137. package/kits/hub-game/code/companionSpec.js +4 -2
  138. package/kits/hub-game/code/server/act.js +3 -0
  139. package/kits/hub-game/code/server/actGate.js +83 -0
  140. package/kits/hub-game/code/server/actions.js +71 -15
  141. package/kits/hub-game/code/server/actors.js +20 -5
  142. package/kits/hub-game/code/server/analytics.js +35 -3
  143. package/kits/hub-game/code/server/ask.js +39 -3
  144. package/kits/hub-game/code/server/ballot.js +167 -4
  145. package/kits/hub-game/code/server/celebrate.js +64 -0
  146. package/kits/hub-game/code/server/companion.js +17 -2
  147. package/kits/hub-game/code/server/decor.js +11 -2
  148. package/kits/hub-game/code/server/disguise.js +63 -0
  149. package/kits/hub-game/code/server/earned.js +6 -2
  150. package/kits/hub-game/code/server/friendBests.js +13 -4
  151. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  152. package/kits/hub-game/code/server/grab.js +12 -2
  153. package/kits/hub-game/code/server/heldOffers.js +142 -0
  154. package/kits/hub-game/code/server/holdShow.js +98 -0
  155. package/kits/hub-game/code/server/hub.js +991 -72
  156. package/kits/hub-game/code/server/idle.js +110 -9
  157. package/kits/hub-game/code/server/index.js +9 -0
  158. package/kits/hub-game/code/server/labels.js +13 -3
  159. package/kits/hub-game/code/server/manifest.js +94 -6
  160. package/kits/hub-game/code/server/menu.js +26 -3
  161. package/kits/hub-game/code/server/npcs.js +55 -9
  162. package/kits/hub-game/code/server/observe.js +67 -6
  163. package/kits/hub-game/code/server/players.js +14 -2
  164. package/kits/hub-game/code/server/replay.js +135 -0
  165. package/kits/hub-game/code/server/standing.js +7 -3
  166. package/kits/hub-game/code/server/storageLimit.js +4 -1
  167. package/kits/hub-game/code/server/townDay.js +74 -0
  168. package/kits/hub-game/code/server/vehicle.js +3 -0
  169. package/kits/hub-game/code/server/vis.js +26 -4
  170. package/kits/hub-game/code/server/wallet.js +677 -0
  171. package/kits/hub-game/code/server/wear.js +13 -3
  172. package/kits/hub-game/code/server/writerLease.js +191 -0
  173. package/kits/hub-game/code/shared/act.js +1 -1
  174. package/kits/hub-game/code/shared/expression.js +6 -0
  175. package/kits/hub-game/code/shared/replay.js +37 -0
  176. package/kits/hub-game/code/systems/hub.js +429 -55
  177. package/kits/hub-game/docs/analytics.md +16 -2
  178. package/kits/hub-game/docs/contract.md +956 -101
  179. package/kits/hub-game/docs/home-pieces.md +5 -6
  180. package/kits/hub-game/docs/observed-progress.md +49 -1
  181. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  182. package/kits/hub-game/index.html +1 -0
  183. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  184. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  185. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  186. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  187. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  188. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  189. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  190. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  207. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  208. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  209. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  210. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  211. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  212. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  213. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  214. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  215. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  216. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  217. package/kits/hub-game/package-lock.json +3 -3
  218. package/kits/hub-game/package.json +4 -3
  219. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  220. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  221. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  222. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  223. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  224. package/kits/hub-game/scripts/pack.mjs +89 -23
  225. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  226. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  227. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  228. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  229. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  230. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  231. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  232. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  233. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  234. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  235. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  236. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  237. package/kits/hub-game/scripts/test-analytics.mjs +79 -0
  238. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  239. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  240. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  241. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  242. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  243. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  244. package/kits/hub-game/scripts/test-ballot.mjs +421 -4
  245. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  246. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  247. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  248. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  249. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  250. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  251. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  252. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  253. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  254. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  255. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  256. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  257. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  258. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  259. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  260. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  261. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  262. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  263. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  264. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  265. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  266. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  267. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  268. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  269. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  270. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  271. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  272. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  273. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  274. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  275. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  276. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  277. package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
  278. package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
  279. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  280. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  281. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  282. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  283. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  284. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  285. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  286. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  287. package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
  288. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  289. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  290. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  291. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  292. package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
  293. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  294. package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
  295. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  296. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  297. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  298. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  299. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  300. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  301. package/kits/hub-game/scripts/test-rehello.mjs +242 -3
  302. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  303. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  304. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  305. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  306. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  307. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  308. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  309. package/kits/hub-game/scripts/test-role-client.mjs +2 -1
  310. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  311. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  312. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  313. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  314. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  315. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  316. package/kits/hub-game/scripts/test-standing.mjs +135 -2
  317. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  318. package/kits/hub-game/scripts/test-stuck.mjs +36 -1
  319. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  320. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  321. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  322. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  323. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  324. package/kits/hub-game/scripts/test-together.mjs +11 -0
  325. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  326. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  327. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  328. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  329. package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
  330. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  331. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  332. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  333. package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
  334. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  335. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  336. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  337. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  338. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  339. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
  340. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
  341. package/kits/multiplayer-3d/castle.json +5 -5
  342. package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
  343. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  344. package/kits/multiplayer-3d/code/server/world.js +19 -4
  345. package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
  346. package/kits/multiplayer-3d/package-lock.json +1 -1
  347. package/kits/multiplayer-3d/package.json +2 -1
  348. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  349. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  350. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  351. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
  352. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  353. package/kits/physics-2d/castle.json +2 -2
  354. package/kits/physics-2d/engine/scene.js +10 -2
  355. package/kits/physics-3d/CLAUDE.md +14 -0
  356. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  357. package/kits/physics-3d/castle.json +3 -3
  358. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  359. package/kits/physics-3d/docs/engine-player.md +76 -0
  360. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  361. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  362. package/kits/physics-3d/engine3d/gait.js +16 -8
  363. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  364. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  365. package/kits/physics-3d/engine3d/look.js +110 -17
  366. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  367. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  368. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  369. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  370. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  371. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  372. package/kits/physics-3d/engine3d/optimize.js +20 -9
  373. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  374. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  375. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  376. package/kits/physics-3d/engine3d/world3d.js +211 -17
  377. package/kits/physics-3d/package-lock.json +1 -1
  378. package/kits/physics-3d/package.json +2 -1
  379. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  380. package/kits/physics-3d/scripts/render.mjs +56 -8
  381. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  382. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  383. package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
  384. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  385. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  386. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  387. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  388. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  389. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  390. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  391. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  392. package/kits/physics-3d/systems/physics3d.js +59 -2
  393. package/kits/real-time/castle.json +2 -2
  394. package/kits/real-time/code/client/connection.js +3 -0
  395. package/package.json +2 -2
  396. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -0,0 +1,23 @@
1
+ // Per-viewer disguise selection and bounded wire, contract v1.196.
2
+ import { hub } from './state.js';
3
+
4
+ export function disguiseMap(rows) {
5
+ const out = new Map();
6
+ if (!Array.isArray(rows)) {return out;}
7
+ for (const row of rows.slice(0, 256)) {
8
+ if (!Array.isArray(row) || row.length !== 3) {continue;}
9
+ const [id, look, to] = row;
10
+ if (typeof id !== 'string' || (look !== null && typeof look !== 'string') ||
11
+ (to !== null && (!Array.isArray(to) || to.length > 256 || Array.from(to).some(v => typeof v !== 'string')))) {continue;}
12
+ out.set(id, { look, to: to === null ? null : [...new Set(to)].sort() });
13
+ }
14
+ return out;
15
+ }
16
+ export function disguisedFor(viewerId, playerId) {
17
+ const value = hub.disguises.get(playerId);
18
+ return Boolean(value && viewerId !== playerId && (value.to === null || value.to.includes(viewerId)));
19
+ }
20
+ export const disguiseTags = disguisedFor;
21
+ export function disguiseBody(viewerId, playerId) {
22
+ return Boolean(hub.disguises.get(playerId)?.look && disguisedFor(viewerId, playerId));
23
+ }
@@ -0,0 +1,87 @@
1
+ // Per-player Model ownership and reversible render hides, contract v1.196.
2
+ import { drawInstances } from '@imports/castle.physics-3d/engine3d/optimize';
3
+ import { hub } from './state.js';
4
+ import { disguiseTags } from './disguise.js';
5
+ import { modelLook } from './modelLook.js';
6
+ import { actorFor } from './riders.js';
7
+ import { hideVisible, restoreVisible } from './renderVisibility.js';
8
+
9
+ export function makeDisguise() {
10
+ const drawn = new Map(), hidden = new Map();
11
+ let root = null, previous = null, before = null, world = null, off = new Set();
12
+ const refresh = () => {
13
+ for (const instances of world?.instances?.values() ?? []) {drawInstances(instances, world.camera);}
14
+ };
15
+ function clear() {
16
+ restoreVisible(hidden);
17
+ if (off.size) {refresh(); off.clear();}
18
+ for (const entry of drawn.values()) {entry.release();}
19
+ drawn.clear();
20
+ if (root?.onBeforeRender === before) {root.onBeforeRender = previous;}
21
+ root = null; before = null; previous = null; world = null;
22
+ }
23
+ function draw(scene, local) {
24
+ restoreVisible(hidden);
25
+ world = scene.three;
26
+ const nextOff = new Set();
27
+ const self = scene.multiplayer?.net?.selfId?.();
28
+ for (const [id, entry] of drawn) {
29
+ const value = hub.disguises.get(id);
30
+ const node = scene.three?.nodes?.get(actorFor(scene, local, id)?.id)?.node;
31
+ if (!value?.look || !(id === self || disguiseTags(self, id)) || entry.look !== value.look || entry.node !== node || entry.world !== scene.three) {
32
+ entry.release(); drawn.delete(id);
33
+ }
34
+ }
35
+ for (const [id, value] of hub.disguises) {
36
+ const applies = disguiseTags(self, id);
37
+ const node = scene.three?.nodes?.get(actorFor(scene, local, id)?.id)?.node;
38
+ if (value.look && (applies || id === self) && node) {
39
+ if (!drawn.has(id)) {
40
+ const look = modelLook(scene, value.look);
41
+ if (look) {
42
+ look.group.name = 'hub:disguise'; node.add(look.group);
43
+ look.group.updateWorldMatrix(true, true);
44
+ drawn.set(id, { ...look, node, look: value.look, world: scene.three });
45
+ }
46
+ }
47
+ const group = drawn.get(id)?.group;
48
+ for (const child of node.children) {
49
+ // Self keeps wearables and every other decoration, only the model changes.
50
+ const model = child.userData?.modelParts || child === node.children[0];
51
+ if (child !== group && (applies || model)) {hideVisible(hidden, child); nextOff.add(child);}
52
+ }
53
+ }
54
+ if (applies) {
55
+ const material = scene.multiplayer?.avatars?.tags?.get(id)?.sprite?.material;
56
+ if (material) {hideVisible(hidden, material);}
57
+ }
58
+ }
59
+ // Shared avatar instances are gathered before onBeforeRender, outside the node.
60
+ if (off.size !== nextOff.size || [...off].some(child => !nextOff.has(child))) {refresh();}
61
+ off = nextOff;
62
+ }
63
+ return {
64
+ draw(scene, local) {
65
+ const next = scene.three?.scene;
66
+ if (!hub.disguises.size) {clear(); return;}
67
+ if (root !== next) {clear();}
68
+ draw(scene, local);
69
+ if (next && root !== next) {
70
+ root = next; previous = root.onBeforeRender;
71
+ const prior = previous;
72
+ const render = function (...args) {
73
+ prior?.apply(this, args);
74
+ if (root === next && before === render) {
75
+ if (!hub.disguises.size) {clear();}
76
+ else {draw(scene, scene.actorWith?.('Player') ?? local);}
77
+ } else if (this.onBeforeRender === render) {
78
+ // Cleared while another hook (the Low cull) was over it: unhook on top again.
79
+ this.onBeforeRender = prior;
80
+ }
81
+ };
82
+ before = render; root.onBeforeRender = render;
83
+ }
84
+ },
85
+ clear,
86
+ };
87
+ }
@@ -0,0 +1,206 @@
1
+ // The dock surface: the navigation dock (`dockTree.js`) with the behaviour
2
+ // `chrome.js` gives it in the DOM -- one list open at a time, Go closing the
3
+ // Doors list, a person's action closing People, Report behind a confirm --
4
+ // published as the `dock` UI tree root. No DOM and no window: a native host
5
+ // gives it the doors, the people and the companion as the chrome is given
6
+ // them and draws the root from the UI tree sink. The web chrome does not use
7
+ // it yet; it still draws its own DOM.
8
+ //
9
+ // makeDockSurface({ view, onJumpDoor, onHeart, onPerson, onReport,
10
+ // onLeaveParty, onChip, onChange, draw }):
11
+ // view() the stage: { landscape, desktop, safeInsets, w };
12
+ // onJumpDoor(door) Go on a door (after the list shuts);
13
+ // onHeart(doorId) a door's heart;
14
+ // onPerson(person, actionId) a person's action other than Report;
15
+ // onReport(person) Report confirmed;
16
+ // onLeaveParty() Leave party;
17
+ // onChip() a door's Go (a sound);
18
+ // onChange(open) the open list changed: 'doors', 'people' or null (the
19
+ // chrome syncs the HUD prompt, which the Doors list
20
+ // covers, and hides what may not sit over a list);
21
+ // draw(tree) called with each root built (only when it changed).
22
+ import { publishUiRoot } from './uiTree.js';
23
+ import { buildDock } from './dockTree.js';
24
+
25
+ const doorsKeyOf = (doors) => (doors ? JSON.stringify([
26
+ doors.goText,
27
+ doors.list.map((d) => [d.id, d.title ?? '', Boolean(d.featured), Boolean(d.solo), d.need ?? '']),
28
+ doors.stuck ? doors.stuck.where : null,
29
+ doors.yours ? [doors.yours.rows, doors.yours.hearts ?? null] : null,
30
+ ]) : '');
31
+ // The DOM rebuilds the rows (and forgets a row's "more" and confirm) when
32
+ // this changes; a `where` alone moves without a rebuild.
33
+ const peopleKeyOf = (people) => (people ? `${people.party ?? ''}#${people.list.map((p) => `${p.key}:${p.username ?? ''}:${p.mark ?? ''}:${(p.actions ?? []).map((a) => a.text).join(',')}:${p.door ?? ''}:${p.where ? 1 : 0}`).join('|')}` : '');
34
+
35
+ export function makeDockSurface({
36
+ view = () => ({}),
37
+ onJumpDoor = () => {},
38
+ onHeart = () => {},
39
+ onPerson = () => {},
40
+ onReport = () => {},
41
+ onLeaveParty = () => {},
42
+ onChip = null,
43
+ onChange = () => {},
44
+ draw = null,
45
+ } = {}) {
46
+ const state = { view: {}, widths: null, hidden: false, open: null, doors: null, people: null, rows: {}, companion: null, badgeBlocked: false };
47
+ let stuckPick = () => {};
48
+ let companionOpen = () => {};
49
+ let peopleKey = '';
50
+ let disposed = false;
51
+
52
+ function setOpen(next) {
53
+ if (state.open === next) {return;}
54
+ state.open = next;
55
+ render();
56
+ onChange(next);
57
+ }
58
+ const closeDoors = () => {if (state.open === 'doors') {setOpen(null);}};
59
+ const closePeople = () => {if (state.open === 'people') {setOpen(null);}};
60
+
61
+ const on = {
62
+ doors: () => setOpen(state.open === 'doors' ? null : 'doors'),
63
+ people: () => setOpen(state.open === 'people' ? null : 'people'),
64
+ go: (door) => {
65
+ closeDoors();
66
+ onChip?.();
67
+ onJumpDoor(door);
68
+ },
69
+ stuck: () => {
70
+ closeDoors();
71
+ stuckPick();
72
+ },
73
+ heart: (doorId) => onHeart(doorId),
74
+ action: (person, id) => {
75
+ if (id === 'report') {
76
+ state.rows[person.key] = { ...state.rows[person.key], confirming: true };
77
+ render();
78
+ return;
79
+ }
80
+ closePeople();
81
+ onPerson(person, id);
82
+ },
83
+ report: (person) => {
84
+ state.rows[person.key] = { ...state.rows[person.key], confirming: false };
85
+ closePeople();
86
+ render();
87
+ onReport(person);
88
+ },
89
+ confirm: (key, confirming) => {
90
+ state.rows[key] = { ...state.rows[key], confirming: Boolean(confirming) };
91
+ render();
92
+ },
93
+ more: (key) => {
94
+ state.rows[key] = { ...state.rows[key], more: !state.rows[key]?.more };
95
+ render();
96
+ },
97
+ leaveParty: () => onLeaveParty(),
98
+ companion: () => companionOpen?.(),
99
+ close: () => setOpen(null),
100
+ };
101
+
102
+ let key = '';
103
+ function render() {
104
+ if (disposed) {return;}
105
+ const stage = view() ?? {};
106
+ state.view = { landscape: Boolean(stage.landscape), desktop: Boolean(stage.desktop), safeInsets: Boolean(stage.safeInsets), w: Number(stage.w) || 0 };
107
+ const where = state.people ? state.people.list.map((p) => p.where ?? '').join('\u0001') : '';
108
+ const next = JSON.stringify([
109
+ state.view, state.widths, state.hidden, state.open, doorsKeyOf(state.doors), peopleKey, where, state.rows,
110
+ state.companion, state.badgeBlocked,
111
+ ]);
112
+ if (next === key) {return;}
113
+ key = next;
114
+ const tree = buildDock(state, on);
115
+ publishUiRoot('dock', tree);
116
+ draw?.(tree);
117
+ }
118
+
119
+ render();
120
+ return {
121
+ state,
122
+ // A turned or resized stage.
123
+ render,
124
+ // chrome `setDoors`: `doors` [{ id, title, featured, solo, need }] or null
125
+ // for no Doors button; `goText` each Go's word ("Go together" in a
126
+ // party); `stuck` { where, onPick } for a "Stuck?" row, or null; `yours`
127
+ // { rows: [{ door, title, line }], hearts } for the player's own games.
128
+ setDoors(doors, goText = 'Go', stuck = null, yours = null) {
129
+ const show = Array.isArray(doors) && doors.length > 0;
130
+ if (!show) {
131
+ state.doors = null;
132
+ if (state.open === 'doors') {setOpen(null);}
133
+ render();
134
+ return;
135
+ }
136
+ if (stuck) {stuckPick = stuck.onPick ?? (() => {});}
137
+ state.doors = {
138
+ list: doors.map((d) => ({ id: d.id, title: d.title, featured: d.featured, solo: d.solo, need: d.need })),
139
+ goText,
140
+ stuck: stuck ? { where: stuck.where } : null,
141
+ yours: yours ? { rows: (yours.rows ?? []).map((r) => ({ door: r.door, title: r.title, line: r.line })), hearts: yours.hearts ?? null } : null,
142
+ };
143
+ render();
144
+ },
145
+ // chrome `setPeople`: the People list's rows, [{ key, playerId, userId,
146
+ // username, mark, where, actions }], or null for no People button;
147
+ // `party` the line over them for a player in a party.
148
+ setPeople(people, party = null) {
149
+ const show = Array.isArray(people) && people.length > 0;
150
+ if (!show) {
151
+ state.people = null;
152
+ peopleKey = '';
153
+ state.rows = {};
154
+ if (state.open === 'people') {setOpen(null);}
155
+ render();
156
+ return;
157
+ }
158
+ state.people = { list: people.map((p) => ({ ...p })), party };
159
+ const nextKey = peopleKeyOf(state.people);
160
+ if (nextKey !== peopleKey) {
161
+ peopleKey = nextKey;
162
+ state.rows = {};
163
+ }
164
+ render();
165
+ },
166
+ // chrome `setCompanionBadge`: the badge, its companion's name, and what a
167
+ // press opens.
168
+ setCompanionBadge(show, name, onOpen) {
169
+ companionOpen = show ? onOpen : () => {};
170
+ state.companion = show ? { name: String(name ?? '') } : null;
171
+ render();
172
+ },
173
+ // Talk, the picker, quick chat or the emotes are open: the badge hides.
174
+ setBadgeBlocked(blocked) {
175
+ state.badgeBlocked = Boolean(blocked);
176
+ render();
177
+ },
178
+ // The buttons' measured widths ({ doors, people, companion }, CSS px,
179
+ // from the host's `report` boxes), or null to estimate them: where the
180
+ // dock's line wraps.
181
+ setButtonWidths(widths) {
182
+ state.widths = widths ? Object.fromEntries(['doors', 'people', 'companion'].filter((k) => Number.isFinite(widths[k])).map((k) => [k, widths[k]])) : null;
183
+ render();
184
+ },
185
+ // A compact avatar picker covers the dock.
186
+ setHidden(hidden) {
187
+ state.hidden = Boolean(hidden);
188
+ render();
189
+ },
190
+ closeDoors,
191
+ closePeople,
192
+ // Back / Escape: shuts the open list; false when none was open.
193
+ cancel() {
194
+ if (!state.open) {return false;}
195
+ setOpen(null);
196
+ return true;
197
+ },
198
+ doorsOpen: () => state.open === 'doors',
199
+ peopleOpen: () => state.open === 'people',
200
+ dispose() {
201
+ if (disposed) {return;}
202
+ disposed = true;
203
+ publishUiRoot('dock', null);
204
+ },
205
+ };
206
+ }
@@ -0,0 +1,232 @@
1
+ // The navigation dock as a UI tree (schema v0): the town's Doors and People
2
+ // buttons, the companion badge, and the one list that opens from them (the
3
+ // doors with Go, a "Stuck?" row and the player's own games; everyone here
4
+ // with their actions, Report behind a confirm, and the party line). It draws
5
+ // what `chrome.js` draws in the DOM for the dock, with the same words,
6
+ // labels and states. Pure: no DOM, no window; the web chrome still draws its
7
+ // own DOM.
8
+ //
9
+ // state = {
10
+ // view: { landscape, desktop, safeInsets, w (view width, CSS px) };
11
+ // widths: null | { doors, people, companion }: the buttons' measured
12
+ // widths (a host's `report` boxes); estimated from their words
13
+ // without;
14
+ // hidden: the dock is hidden (a compact avatar picker is open over it);
15
+ // open: null | 'doors' | 'people';
16
+ // doors: null | { list: [{ id, title, featured, solo, need }], goText,
17
+ // stuck: null | { where }, yours: null | { rows: [{ door, title,
18
+ // line }], hearts: null | [doorId] } };
19
+ // people: null | { list: [{ key, playerId, username, mark, where,
20
+ // actions: [{ id, text }] }], party: null | string };
21
+ // rows: { [person.key]: { more, confirming } }, a row's own state;
22
+ // companion: null | { name };
23
+ // badgeBlocked: something else is open (talk, the picker, quick chat, the
24
+ // emotes): the badge hides, as it does while a list is open;
25
+ // }
26
+ // on = { doors(), people(), go(door), stuck(), heart(doorId),
27
+ // action(person, actionId), report(person), confirm(key, on), more(key),
28
+ // leaveParty(), companion(), close() }.
29
+ import { h } from './uiTree.js';
30
+
31
+ // The dock's chip buttons and the lists' small buttons (`smallButton`).
32
+ const CHIP = { pad: [8, 14], radius: 18, border: { w: 1, c: 'line40' }, bg: 'chip', color: '#fff' };
33
+ const small = (primary) => ({
34
+ pad: [5, 12], radius: 12, border: primary ? 'none' : { w: 1, c: 'line35' }, bg: primary ? 'gold' : 'transparent',
35
+ color: primary ? 'onGold' : '#fff', font: 'ui', size: 13, weight: 700, lh: 'normal',
36
+ });
37
+ // A one-pixel line where the DOM draws a top or bottom border.
38
+ const rule = (key) => h('spacer', { key, style: { h: 1, bg: 'rgba(255,255,255,0.18)' } });
39
+ const ONE_LINE = { lines: 1 };
40
+ const edge = (safeInsets, px) => (safeInsets ? [px, 0] : px);
41
+ const GAP = 6;
42
+
43
+ // A chip button's width from its words at the dock's 15 px semibold (an
44
+ // estimate; a host's measured width wins), and the badge's fixed 44.
45
+ const chipWidth = (words) => Math.ceil(30 + 8.6 * [...words].length);
46
+ // The room the buttons have on one line: the DOM's max-width.
47
+ export const dockLineRoom = (view) => (view?.landscape ? Math.min(0.24 * view.w, 160) : view.w - 130);
48
+
49
+ // The shown buttons in lines, as `flex-wrap` fills them: in order, a new
50
+ // line when the next does not fit. The DOM wraps them in reverse
51
+ // (`wrap-reverse`), so the first line is drawn lowest: on a narrow phone
52
+ // People sits above Doors. One line when the view's width is unknown.
53
+ export function dockLines(buttons, view) {
54
+ const room = Number.isFinite(view?.w) && view.w > 0 ? dockLineRoom(view) : Infinity;
55
+ const lines = [];
56
+ let width = 0;
57
+ for (const button of buttons) {
58
+ const line = lines.at(-1);
59
+ if (line && width + GAP + button.w <= room) {
60
+ line.push(button.key);
61
+ width += GAP + button.w;
62
+ } else {
63
+ lines.push([button.key]);
64
+ width = button.w;
65
+ }
66
+ }
67
+ return lines;
68
+ }
69
+
70
+ // The People button's words: everyone in this place, the player too.
71
+ export const peopleLabel = (list) => `People · ${list.filter((p) => p.playerId).length + 1}`;
72
+ // How many of the player's own games the Doors list shows.
73
+ export const yourRowCount = (desktop) => (desktop ? 5 : 3);
74
+
75
+ function doorsList(state, on) {
76
+ const doors = state.doors;
77
+ const yours = doors.yours ?? null;
78
+ const yourRows = yours?.rows?.slice(0, yourRowCount(state.view?.desktop)) ?? [];
79
+ const hearts = yours?.hearts ?? null;
80
+ const goText = doors.goText ?? 'Go';
81
+ const kids = [];
82
+ if (doors.stuck) {
83
+ const where = String(doors.stuck.where ?? '');
84
+ kids.push(h('column', { key: 'stuck', hub: 'stuck-row' },
85
+ h('row', { key: 'row', style: { align: 'center', gap: 8, pad: [0, 0, 6, 0] } },
86
+ h('column', { key: 'words', style: { flex: 1, minW: 0 } },
87
+ h('text', { key: 'title', text: 'Stuck?', style: ONE_LINE }),
88
+ h('text', { key: 'where', text: where, style: { size: 11, weight: 500, opacity: 0.7, ...ONE_LINE } })),
89
+ h('button', { key: 'go', fire: 'down', label: `Stuck? ${where}`, style: { ...small(false), flex: '0 0 auto' }, on: { tap: on.stuck } }, 'Go')),
90
+ rule('rule')));
91
+ }
92
+ if (yourRows.length) {
93
+ kids.push(h('text', { key: 'yours', text: 'Your games', style: { size: 13, opacity: 0.8 } }));
94
+ }
95
+ // Keys by door id; a door listed twice in one section takes `~2`, `~3`.
96
+ const seen = new Map();
97
+ const keyFor = (prefix, id) => {
98
+ const base = `${prefix}:${id}`;
99
+ const n = (seen.get(base) ?? 0) + 1;
100
+ seen.set(base, n);
101
+ return n === 1 ? base : `${base}~${n}`;
102
+ };
103
+ const listed = [
104
+ ...yourRows.map((r) => ({ door: { ...doors.list.find((d) => d.id === r.door), title: r.title, line: r.line, yours: true }, key: keyFor('y', r.door) })),
105
+ ...doors.list.map((door) => ({ door, key: keyFor('d', door.id) })),
106
+ ];
107
+ listed.forEach(({ door, key }, index) => {
108
+ if (index === yourRows.length && yourRows.length) {
109
+ kids.push(h('column', { key: 'all' }, rule('rule'), h('text', { key: 'title', text: 'All doors', style: { size: 13, opacity: 0.8, pad: [8, 0, 0, 0] } })));
110
+ }
111
+ const takes = door.yours ? door.line : door.solo ? 'solo' : door.need ? `needs ${door.need}` : '';
112
+ const hearted = Boolean(hearts?.includes(door.id));
113
+ kids.push(h('row', { key, style: { align: 'center', gap: 8 } },
114
+ h('column', { key: 'words', style: { flex: 1, minW: 0 } },
115
+ h('text', { key: 'name', text: `${door.featured && !door.yours ? '★ ' : ''}${door.title ?? door.id}`, style: ONE_LINE }),
116
+ takes ? h('text', { key: 'takes', text: String(takes), style: { size: 11, weight: 500, opacity: 0.7, ...(door.yours ? ONE_LINE : {}) } }) : null),
117
+ hearts ? h('button', {
118
+ key: 'heart', fire: 'down', label: hearted ? 'Remove heart' : 'Heart this game', pressed: hearted,
119
+ style: { ...small(false), flex: '0 0 auto' }, on: { tap: () => on.heart?.(door.id) },
120
+ }, hearted ? '♥' : '♡') : null,
121
+ // A party cannot go together through a door that takes one player.
122
+ h('button', { key: 'go', fire: 'down', style: { ...small(true), flex: '0 0 auto' }, on: { tap: () => on.go?.(door) } }, door.solo ? 'Go' : goText)));
123
+ });
124
+ return kids;
125
+ }
126
+
127
+ function personRow(person, row, on) {
128
+ const who = person.username ?? 'this player';
129
+ const confirming = Boolean(row?.confirming);
130
+ const [first, ...rest] = person.actions ?? [];
131
+ const act = (action, primary) => h('button', {
132
+ key: `a:${action.id}`, fire: 'down', style: small(primary),
133
+ on: { tap: () => on.action?.(person, action.id) },
134
+ }, action.text);
135
+ const buttons = confirming
136
+ ? [
137
+ h('button', { key: 'report', fire: 'down', style: small(true), on: { tap: () => on.report?.(person) } }, 'Report'),
138
+ h('button', { key: 'cancel', fire: 'down', style: small(false), on: { tap: () => on.confirm?.(person.key, false) } }, 'Cancel'),
139
+ ]
140
+ : [
141
+ first ? act(first, first.id !== 'report' && first.id !== 'find') : null,
142
+ rest.length ? h('button', {
143
+ key: 'more', fire: 'down', label: `More for ${who}`,
144
+ style: { ...small(false), pad: [5, 8] }, on: { tap: () => on.more?.(person.key) },
145
+ }, '⋯') : null,
146
+ ];
147
+ return h('column', { key: `p:${person.key}`, style: { gap: 4 } },
148
+ h('row', { key: 'row', style: { align: 'center', gap: 8 } },
149
+ h('column', { key: 'words', style: { flex: 1, minW: 0 } },
150
+ h('text', { key: 'name', text: confirming ? `Report ${who}?` : `${person.mark ?? ''}${who}`, style: ONE_LINE }),
151
+ !confirming && person.where ? h('text', { key: 'where', text: String(person.where), style: { size: 12, weight: 500, opacity: 0.75, ...ONE_LINE } }) : null),
152
+ buttons),
153
+ !confirming && row?.more && rest.length
154
+ ? h('row', { key: 'more', style: { justify: 'end', gap: 6 } }, rest.map((action) => act(action, false)))
155
+ : null);
156
+ }
157
+
158
+ function peopleList(state, on) {
159
+ const people = state.people;
160
+ const kids = [];
161
+ if (people.party) {
162
+ kids.push(h('column', { key: 'party' },
163
+ h('row', { key: 'row', style: { align: 'center', gap: 8, pad: [0, 0, 4, 0] } },
164
+ h('text', { key: 'line', text: String(people.party), style: { flex: 1, size: 12, opacity: 0.8 } }),
165
+ h('button', { key: 'leave', fire: 'down', style: small(false), on: { tap: on.leaveParty } }, 'Leave party')),
166
+ rule('rule')));
167
+ }
168
+ for (const person of people.list) {
169
+ kids.push(personRow(person, state.rows?.[person.key], on));
170
+ }
171
+ return kids;
172
+ }
173
+
174
+ export function buildDock(state, on = {}) {
175
+ const view = state.view ?? {};
176
+ const landscape = Boolean(view.landscape);
177
+ const doorsShown = Boolean(state.doors?.list?.length);
178
+ const peopleShown = Boolean(state.people?.list?.length);
179
+ const open = state.open === 'doors' && doorsShown ? 'doors' : state.open === 'people' && peopleShown ? 'people' : null;
180
+ const companion = state.companion ?? null;
181
+
182
+ const nodes = [
183
+ h('button', { key: 'doors', fire: 'down', report: true, style: { ...CHIP, gone: !doorsShown }, on: { tap: on.doors } }, 'Doors'),
184
+ h('button', { key: 'people', fire: 'down', report: true, style: { ...CHIP, gone: !peopleShown }, on: { tap: on.people } },
185
+ peopleShown ? peopleLabel(state.people.list) : 'People'),
186
+ companion ? h('button', {
187
+ key: 'companion', fire: 'down', label: `Chat with ${companion.name ?? ''}`, report: true,
188
+ style: { w: 44, h: 44, flex: '0 0 44px', box: 'border', pad: 8, radius: 22, border: { w: 1, c: 'line40' }, bg: 'chip', gone: Boolean(open || state.badgeBlocked) },
189
+ on: { tap: on.companion },
190
+ }, h('icon', { key: 'glyph', name: 'companion', style: { w: 26, h: 26 } })) : null,
191
+ ].filter(Boolean);
192
+ const peopleWords = peopleShown ? peopleLabel(state.people.list) : 'People';
193
+ const widths = state.widths ?? {};
194
+ const shown = nodes.filter((node) => !node.s.gone).map((node) => ({
195
+ key: node.k,
196
+ w: Number.isFinite(widths[node.k]) ? widths[node.k] : node.k === 'companion' ? 44 : chipWidth(node.k === 'doors' ? 'Doors' : peopleWords),
197
+ }));
198
+ const lines = dockLines(shown, view);
199
+ const maxW = landscape ? [{ vw: 24 }, { px: 160 }] : [{ vw: 100, px: -130 }];
200
+ // One line: a row. Wrapped: a column of rows, the first line at the
201
+ // bottom (wrap-reverse); the hidden buttons stay in the first line's row
202
+ // so their keys keep their place.
203
+ const buttons = lines.length <= 1
204
+ ? h('row', { key: 'buttons', style: { align: 'start', gap: GAP, maxW } }, nodes)
205
+ : h('column', { key: 'buttons', style: { align: 'start', gap: GAP, maxW } },
206
+ lines.map((_, i) => lines.length - 1 - i).map((index) => h('row', { key: `l${index}`, style: { align: 'end', gap: GAP } },
207
+ nodes.filter((node) => (index === 0 ? !lines.slice(1).some((line) => line.includes(node.k)) : lines[index].includes(node.k))))));
208
+
209
+ // The open list sits just above the dock (beside it on a phone held
210
+ // upright; under it, at the top, on its side), however tall the dock is.
211
+ const list = open ? h('scroll', {
212
+ key: open, axis: 'y',
213
+ style: {
214
+ w: [{ vw: 80 }, { px: 260 }], box: 'border', pad: 8, radius: 12, bg: 'card', shadow: 'card', hit: 'auto',
215
+ ...(landscape ? { minH: 0, flex: '0 1 auto' } : { maxH: [{ vh: 40 }] }),
216
+ },
217
+ }, h('column', { key: 'body', style: { gap: 6, pad: [0, 0, 8, 0] } }, open === 'doors' ? doorsList(state, on) : peopleList(state, on))) : null;
218
+
219
+ return h('stack', {
220
+ key: 'dock',
221
+ style: { font: 'ui', size: 15, weight: 600, lh: 1.3, color: '#fff' },
222
+ // Back shuts an open list; with none open, the root binds no cancel.
223
+ on: { cancel: open ? on.close : undefined },
224
+ },
225
+ h('column', {
226
+ key: 'dock',
227
+ at: landscape
228
+ ? { anchor: 'topLeft', top: [68, 56], left: edge(view.safeInsets, 10) }
229
+ : { anchor: 'bottomLeft', bottom: [10, 0], left: edge(view.safeInsets, 10) },
230
+ style: { gap: 6, align: 'start', hit: 'none', hidden: Boolean(state.hidden), ...(landscape ? { maxH: [{ dvh: 100, px: -80, safe: 'tb' }] } : {}) },
231
+ }, landscape ? [buttons, list] : [list, buttons]));
232
+ }
@@ -65,6 +65,35 @@ export const BADGE_GLOW_R = 0.32;
65
65
  // And held things this much bigger, about their grip.
66
66
  export const HELD_SCALE = 1.2;
67
67
 
68
+ // On a phone-size viewport (its shorter side at most PHONE_VIEW_PX) a badge
69
+ // further than BADGE_GROW_FROM_M from the camera is drawn bigger in step with
70
+ // its distance, so it is never smaller on screen than it is that far away,
71
+ // up to BADGE_GROW_MAX times: a gold dot at a street's length reads as its
72
+ // shape. Pins and the rest keep their size, and so does every badge on a
73
+ // larger screen. Nothing is drawn more: the same badge, scaled.
74
+ export const PHONE_VIEW_PX = 540;
75
+ export const BADGE_GROW_FROM_M = 10;
76
+ export const BADGE_GROW_MAX = 2.5;
77
+ // A badged player first seen within SPARKLE_NEAR_M of this player gets one
78
+ // brief sparkle on the badge, SPARKLE_MS long, never again in that place;
79
+ // not drawn on the Low tier (still counted as seen there).
80
+ export const SPARKLE_NEAR_M = 20;
81
+ export const SPARKLE_MS = 900;
82
+
83
+ // Whether a viewport `w` by `h` CSS pixels is phone-size.
84
+ export function phoneView(w, h) {
85
+ const short = Math.min(Number(w) || 0, Number(h) || 0);
86
+ return short > 0 && short <= PHONE_VIEW_PX;
87
+ }
88
+
89
+ // How much bigger a badge `distance` metres from the camera is drawn.
90
+ export function badgeGrow(distance, phone) {
91
+ if (!phone || !(distance > BADGE_GROW_FROM_M)) {
92
+ return 1;
93
+ }
94
+ return Math.min(BADGE_GROW_MAX, distance / BADGE_GROW_FROM_M);
95
+ }
96
+
68
97
  // Where an earned item sits on an avatar this kit has no fit for (`avatar.js`
69
98
  // `earnedFit` gives null): a body about toon's.
70
99
  const DEFAULT_FIT = {