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
@@ -23,19 +23,20 @@ import { toastBand } from './toastBand.js';
23
23
  import { emoteBubbleShift, placeEmoteBubble } from './emoteBubble.js';
24
24
  import { makeActionOverflow } from './actionOverflow.js';
25
25
  import { actionLayout } from './actionLayout.js';
26
- import { guardScrollKeys, takeKeys } from './keys.js';
26
+ import { guardScrollKeys, takeKeys, walkKey, walkRelease } from './keys.js';
27
27
  import { validPrivateText } from '../privateText.js';
28
28
  import { menuIcon } from './menuIcons.js';
29
29
  import { drawMenuRows } from './menuRows.js';
30
30
  import { landscapeViewport, watchViewport } from './landscapeLayout.js';
31
31
  import { loadingCover } from './loadingCover.js';
32
32
 
33
- import { makeSafeLayout } from './safeLayout.js';
33
+ import { makeSafeLayout, overlaps } from './safeLayout.js';
34
34
  import { makeEmoteWheel } from './emoteWheel.js';
35
35
  import { makeWorldLayout } from './worldLabels.js';
36
36
  import { makeLayoutCache, placementCache } from './layoutCache.js';
37
37
  import { BARE_TEXT_SHADOW, publishUiRoot, uiTreeDomEnabled } from './uiTree.js';
38
38
  import { mountUiTree } from './uiDom.js';
39
+ import { SHORT_FACE_PX, SHORT_PX } from './menuTree.js';
39
40
  import { makeHudSurface } from './hudSurface.js';
40
41
  import { makeTalkSurface } from './talkSurface.js';
41
42
 
@@ -52,6 +53,12 @@ function createElement(tag, style, parent = document.body) {
52
53
 
53
54
  // The character picker's grid: four cells across, each a tap target this wide
54
55
  // (and 62 px tall).
56
+ // The narrowest lane the HUD is moved into beside the right-edge controls
57
+ // (`layoutHudLane`); narrower, it stays centred.
58
+ const HUD_LANE_MIN = 72;
59
+ // Quick chat's top above the view's bottom edge in the portrait corner.
60
+ const PORTRAIT_COLUMN_TOP = 258;
61
+ const parseTranslate = (value) => Number.parseFloat(value) || 0;
55
62
  const PICKER_COLUMNS = 4;
56
63
  const PICKER_CELL_PX = 64;
57
64
 
@@ -93,6 +100,23 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
93
100
  const desktop = () => desktopQuery?.matches === true;
94
101
  const root = el('div', { position: 'fixed', inset: '0', pointerEvents: 'none', zIndex: String(Z), font: '600 15px/1.3 system-ui, sans-serif', color: '#fff' });
95
102
  if (loadingCover) { root.setAttribute('data-hub-loading-chrome', ''); }
103
+ // A tap's click is hit-tested where the finger lifts, after pointerdown's
104
+ // handlers ran. A control opened on pointerdown can put another under the
105
+ // finger (in landscape the Character strip opens over its button), and the
106
+ // click then picked the tile there and shut the strip at once. A click
107
+ // counts only on its pointerdown's element, or one inside or around it;
108
+ // keyboard clicks (detail 0) and a pointerdown target since removed pass.
109
+ // Captured on the root, so the deck's own DOM is untouched.
110
+ let lastDown = null;
111
+ root.addEventListener('pointerdown', (event) => {lastDown = { target: event.target, at: performance.now() };}, true);
112
+ root.addEventListener('click', (event) => {
113
+ const down = lastDown;
114
+ lastDown = null;
115
+ if (!down || event.detail === 0 || performance.now() - down.at > 800 || !down.target.isConnected) {return;}
116
+ if (event.target === down.target || event.target.contains(down.target) || down.target.contains(event.target)) {return;}
117
+ event.preventDefault();
118
+ event.stopImmediatePropagation();
119
+ }, true);
96
120
 
97
121
  // The door cover: a dark warm field the door animation fades to, with the
98
122
  // destination named in it. It sits over everything while a scene swaps.
@@ -130,6 +154,19 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
130
154
  },
131
155
  });
132
156
  const back = hudDom.nodeFor('hud/back');
157
+ // v1.186: the Back corner is reserved in every place. Without
158
+ // `hub.safeInsets` the kit's Again stands at 12 px (76 px on a phone on its
159
+ // side) from the left edge, which meets the 64 px reserved box in portrait
160
+ // and wherever the left safe area is over 12 px; there it moves to the
161
+ // bottom centre. Back to a door or town, and safe-inset places, are as before.
162
+ let shownBack = { show: false, label: 'Back' };
163
+ let insetProbe = null;
164
+ const leftInset = () => {
165
+ if (typeof globalThis.getComputedStyle !== 'function') {return 0;}
166
+ insetProbe ??= el('div', { position: 'absolute', visibility: 'hidden', pointerEvents: 'none', paddingLeft: 'env(safe-area-inset-left)' }, root);
167
+ return parseFloat(getComputedStyle(insetProbe).paddingLeft) || 0;
168
+ };
169
+ const backLow = (label) => !safeInsets && label === 'Again' && (!landscape || leftInset() > 12);
133
170
  const hud = hudDom.nodeFor('hud/hud');
134
171
  const hudTitle = hudDom.nodeFor('hud/hud/title');
135
172
  const hudBig = hudDom.nodeFor('hud/hud/big');
@@ -152,6 +189,13 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
152
189
  root.insertBefore(pointers, labels);
153
190
  const pointerNodes = new Map();
154
191
  const labelNodes = new Map();
192
+ // Ids of the world labels that are plates or signs (`setLabels` items with
193
+ // a `box` and no `speech`): the world layout slides these onto the screen
194
+ // and off the player's avatar instead of dropping them.
195
+ const clampLabels = new Set();
196
+ // Ids of the NPC lines (`speech` and `npc`: an NPC's or Chirp's): drawn
197
+ // over the player's own body rather than hidden by it.
198
+ const npcSpeech = new Set();
155
199
 
156
200
  // An arcade cabinet's card (v1.7). By the cabinet it is a chip: the best
157
201
  // score and whose it is (their photo in a circle, their frame drawn over it
@@ -161,7 +205,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
161
205
  // scores. A tap on the board, or walking away, closes it. Over the labels,
162
206
  // so a pad's words never cut through a row; it is never drawn during a
163
207
  // trip, so the door cover needs not hide it.
164
- const cabinet = el('div', { position: 'absolute', display: 'none', transform: 'translate(-50%, -100%)', boxSizing: 'border-box', background: 'rgba(18,14,24,0.92)', border: '1px solid rgba(255,255,255,0.18)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', font: '600 13px/1.25 system-ui, sans-serif', cursor: 'pointer', touchAction: 'manipulation', userSelect: 'none' }, root);
208
+ const CABINET_CHIP_PAINT = 'rgba(18,14,24,0.92)', CABINET_BOARD_PAINT = 'rgb(18,14,24)';
209
+ const cabinet = el('div', { position: 'absolute', display: 'none', transform: 'translate(-50%, -100%)', boxSizing: 'border-box', background: CABINET_CHIP_PAINT, border: '1px solid rgba(255,255,255,0.18)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', font: '600 13px/1.25 system-ui, sans-serif', cursor: 'pointer', touchAction: 'manipulation', userSelect: 'none' }, root);
165
210
  cabinet.dataset.hub = 'cabinet';
166
211
  let cabinetKey = '';
167
212
  // Whose board this player opened, if any: one at a time (`cabinets.js`).
@@ -203,7 +248,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
203
248
  if (!best) {
204
249
  return false;
205
250
  }
206
- Object.assign(cabinet.style, { width: 'auto', padding: '3px 9px 3px 4px', borderRadius: '15px', pointerEvents: 'auto' });
251
+ Object.assign(cabinet.style, { width: 'auto', padding: '3px 9px 3px 4px', borderRadius: '15px', pointerEvents: 'auto', background: CABINET_CHIP_PAINT });
207
252
  cabinet.setAttribute('role', 'button');
208
253
  cabinet.setAttribute('aria-label', `${card.title || 'Arcade'}: show the scores`);
209
254
  const line = el('div', { display: 'flex', alignItems: 'center', gap: '7px', fontSize: '12px', whiteSpace: 'nowrap' }, cabinet);
@@ -216,7 +261,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
216
261
  }
217
262
  function buildCabinetBoard(card, imageOf) {
218
263
  cabinet.replaceChildren();
219
- Object.assign(cabinet.style, { width: '204px', padding: '10px', borderRadius: '12px', pointerEvents: 'auto' });
264
+ // v1.217: opaque, so no plate or area label under it shows through a row.
265
+ Object.assign(cabinet.style, { width: '204px', padding: '10px', borderRadius: '12px', pointerEvents: 'auto', background: CABINET_BOARD_PAINT });
220
266
  cabinet.setAttribute('role', 'button');
221
267
  cabinet.setAttribute('aria-label', `${card.title || 'Arcade'}: hide the scores`);
222
268
  const head = el('div', { display: 'flex', gap: '10px', alignItems: 'center' }, cabinet);
@@ -247,6 +293,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
247
293
  return true;
248
294
  }
249
295
 
296
+ let winRibbons = null;
250
297
  const ribbon = el('div', { position: 'absolute', display: 'none', transform: 'translate(-50%, -100%)', padding: '4px 10px', borderRadius: '6px', background: 'linear-gradient(#f2c94c, #d69e2e)', color: '#3b2600', fontSize: '13px', fontWeight: '800', whiteSpace: 'nowrap', boxShadow: '0 2px 6px rgba(0,0,0,0.4)' }, root);
251
298
 
252
299
  // The HUD root's toast, drawn over the ribbon (its layer was always here).
@@ -257,8 +304,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
257
304
  const toastStart = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '0', width: '0', height: '0', visibility: 'hidden' }, root);
258
305
  const actionBottom = el('div', { position: 'absolute', bottom: 'max(132px, calc(env(safe-area-inset-bottom) + 122px))', left: '0', width: '0', height: '0', visibility: 'hidden' }, root);
259
306
  let toastChoiceBlocked = false;
307
+ // No row of the view is clear of the controls: the toast is not drawn
308
+ // until one is, by the rule the caption lanes carry.
309
+ let toastNoRow = false;
260
310
  function syncToastVisibility() {
261
- const visibility = toastChoiceBlocked || pickerOpen ? 'hidden' : '';
311
+ const visibility = toastChoiceBlocked || toastNoRow || pickerOpen ? 'hidden' : '';
262
312
  if (toast.style.visibility !== visibility) {toast.style.visibility = visibility;}
263
313
  }
264
314
 
@@ -299,6 +349,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
299
349
  companionLockVisibility = null;
300
350
  }
301
351
  let pickerFitKey = '', pickerCompact = false;
352
+ // The dock is out of sight under the compact picker strip, and where it
353
+ // was raised (`raiseDock`) while the Sound card stands beside its button
354
+ // over it (with safeInsets, while the card is open).
355
+ let dockHigh = false, soundAside = false, soundOpen = false;
356
+ const syncDockVisibility = () => {dock.style.visibility = pickerCompact && pickerOpen || dockHigh && (soundAside || safeInsets && soundOpen) ? 'hidden' : '';};
302
357
  // The card is a sheet fitted to the viewport: over the right-side lane above
303
358
  // the button, or, on a phone on its side with no room there for the whole
304
359
  // sheet, one strip of whole tiles along the bottom with its own Close. Open,
@@ -336,7 +391,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
336
391
  Object.assign(button.style, { scrollSnapAlign: compact ? 'start' : '', scrollSnapStop: compact ? 'always' : '', touchAction: compact ? 'pan-x' : 'pan-y' });
337
392
  }
338
393
  pickerToggle.style.visibility = compact && pickerOpen ? 'hidden' : '';
339
- dock.style.visibility = compact && pickerOpen ? 'hidden' : '';
394
+ syncDockVisibility();
340
395
  if (compact && pickerOpen && companionLock) {
341
396
  if (companionLockVisibility === null) {companionLockVisibility = companionLock.style.visibility ?? '';}
342
397
  companionLock.style.visibility = 'hidden';
@@ -470,6 +525,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
470
525
  // Talking to an NPC: a button when one is near, and a panel while a
471
526
  // conversation is open. Keys typed here are the panel's, not the game's.
472
527
  const talkButton = el('button', { position: 'absolute', bottom: 'max(64px, calc(env(safe-area-inset-bottom) + 54px))', left: '50%', transform: 'translateX(-50%)', pointerEvents: 'auto', padding: '10px 18px', borderRadius: '22px', border: '1px solid rgba(255,255,255,0.45)', background: 'rgba(20,16,12,0.8)', color: '#fff', font: 'inherit', display: 'none', cursor: 'pointer' }, root);
528
+ talkButton.setAttribute('data-hub', 'talk-button');
473
529
  overPicker.push(talkButton);
474
530
  talkButton.addEventListener('pointerdown', (event) => {
475
531
  event.stopPropagation();
@@ -484,11 +540,37 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
484
540
  // A desktop keyboard (a fine pointer and no touch) gets the field focused
485
541
  // as it appears; a phone keeps its keyboard down until a tap.
486
542
  const autoFocusField = () => Boolean(globalThis.matchMedia?.('(pointer: fine)').matches && !(globalThis.navigator?.maxTouchPoints > 0));
543
+ // A field focused that way does not take the movement keys until the player
544
+ // types in it or points at it (the first visit's greeter opens on arrival,
545
+ // and nobody is held): while it is empty, W, A, S, D, the arrows and Space
546
+ // go on to the game, unentered, and the field is not typing. Any other key
547
+ // is the field's, as before.
548
+ let fieldWalks = false;
549
+ let autoArm = false;
550
+ const autoFocusTalk = () => {
551
+ autoArm = autoFocusField();
552
+ return autoArm;
553
+ };
554
+ const fieldWalking = (input) => fieldWalks && input.value === '';
555
+ const passWalkKey = (input, event) => {
556
+ if (input !== panelInput()) {return false;}
557
+ if (walkRelease(event)) {return true;}
558
+ if (event.type !== 'keydown' || !fieldWalking(input) || !walkKey(event)) {return false;}
559
+ event.preventDefault?.();
560
+ return true;
561
+ };
487
562
  const talkDom = mountUiTree(root, {
488
563
  measure: geometry,
564
+ passKey: passWalkKey,
489
565
  created(path, node) {
490
566
  if (path === 'talk/panel/log') {geometry.register(node, { scroll: true });}
491
567
  else if (path === 'talk/panel' || path === 'talk/panel/asks' || path.startsWith('talk/panel/log/l')) {geometry.register(node);}
568
+ else if (path === 'talk/panel/form/say') {
569
+ node.addEventListener('focus', () => {fieldWalks = autoArm;});
570
+ for (const type of ['input', 'pointerdown', 'blur']) {
571
+ node.addEventListener(type, () => {fieldWalks = false;});
572
+ }
573
+ }
492
574
  },
493
575
  removed: (path, node) => geometry.unregister(node),
494
576
  });
@@ -507,7 +589,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
507
589
  const panelInput = () => talkDom.nodeFor('talk/panel/form/say');
508
590
  const talkSurface = makeTalkSurface({
509
591
  view: () => ({ landscape: landscapeViewport(), desktop: desktop(), w: geometry.view().w, safeInsets }),
510
- autoFocus: autoFocusField,
592
+ autoFocus: autoFocusTalk,
511
593
  onChip,
512
594
  draftNow: () => (uiTreeDomEnabled() && panelInput() ? panelInput().value : talkSurface.state.field.value),
513
595
  afterChange(what) {
@@ -526,9 +608,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
526
608
  },
527
609
  draw(tree) {
528
610
  if (uiTreeDomEnabled() || !talkDom.nodeFor('talk/panel')) {talkDom.render(tree);}
611
+ autoArm = false;
529
612
  },
530
613
  });
531
614
  const panel = talkDom.nodeFor('talk/panel');
615
+ panel.setAttribute?.('data-hub', 'talk-panel');
532
616
  const panelAsks = () => talkDom.nodeFor('talk/panel/asks');
533
617
 
534
618
  function syncHudPrompt() {
@@ -548,6 +632,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
548
632
  let grabHandler = () => {};
549
633
  let hornHandler = null;
550
634
  const grabButton = el('button', { position: 'absolute', right: edge('right', 14), bottom: 'max(60px, calc(env(safe-area-inset-bottom) + 50px))', width: '76px', height: '76px', borderRadius: '38px', pointerEvents: 'auto', border: '2px solid rgba(255,255,255,0.55)', background: 'rgba(20,16,12,0.78)', color: '#fff', font: '800 16px system-ui, sans-serif', display: 'none', cursor: 'pointer', touchAction: 'manipulation', userSelect: 'none' }, root);
635
+ grabButton.setAttribute('data-hub', 'grab-button');
551
636
  grabButton.addEventListener('pointerdown', (event) => {
552
637
  event.stopPropagation();
553
638
  event.preventDefault();
@@ -579,6 +664,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
579
664
  event.stopPropagation();
580
665
  event.preventDefault();
581
666
  setEmotesOpen(!emotesOpen);
667
+ // safeLayout places an opened card now, not on its next pass: until then
668
+ // it stands where the portrait corner puts it, off a small view's edge.
669
+ if (emotesOpen && safeInsets) {safeLayout?.flush();}
582
670
  });
583
671
  emoteButton.addEventListener('click', (event) => {
584
672
  if (expressionEmotes && event.detail === 0) { setEmotesOpen(!emotesOpen); }
@@ -608,6 +696,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
608
696
  event.preventDefault();
609
697
  setSayOpen(!sayOpen);
610
698
  setEmotesOpen(false);
699
+ if (sayOpen && safeInsets) {safeLayout?.flush();}
611
700
  });
612
701
  const feed = el('div', { position: 'absolute', left: edge('left', 10), bottom: 'max(70px, calc(env(safe-area-inset-bottom) + 60px))', maxWidth: '62vw', display: 'flex', flexDirection: 'column', gap: '2px', font: '500 12px/1.3 system-ui, sans-serif', textShadow: BARE_TEXT_SHADOW, opacity: '0.92' }, root);
613
702
  let feedKey = '';
@@ -621,10 +710,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
621
710
 
622
711
  // Bottom left: the town's Doors, then People, side by side -- or People
623
712
  // above Doors where a narrow screen leaves no room beside the avatar picker.
624
- const dock = el('div', { position: 'absolute', left: edge('left', 10), bottom: 'max(10px, env(safe-area-inset-bottom))', display: 'flex', flexWrap: 'wrap-reverse', alignItems: 'flex-start', gap: '6px', maxWidth: 'calc(100vw - 130px)' }, root);
713
+ // Never narrower than its widest button (a 179px view's max width is 49px).
714
+ const dock = el('div', { position: 'absolute', left: edge('left', 10), bottom: 'max(10px, env(safe-area-inset-bottom))', display: 'flex', flexWrap: 'wrap-reverse', alignItems: 'flex-start', gap: '6px', maxWidth: 'calc(100vw - 130px)', minWidth: 'min-content' }, root);
625
715
  // A list opens just above the dock, however tall the dock is.
626
716
  const aboveDock = (list) => {
627
- if (landscapeViewport()) {
717
+ if (landscapeViewport() || dockHigh) {
628
718
  list.style.bottom = '';
629
719
  const top = `max(68px, env(safe-area-inset-top) + 56px) + ${geometry.size(dock).h + 6}px`;
630
720
  list.style.top = `calc(${top})`;
@@ -856,7 +946,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
856
946
  const wide = desktop() && !landscapeViewport();
857
947
  const width = geometry.size(toast).w;
858
948
  const height = geometry.size(toast).h;
859
- const rects = [hud, hudText, ribbon, askCard, back, sound?.button, sound?.card, stats, talkButton, sitButton, nearButton, panel, dock, doorsList, peopleList, picker, grabButton, emoteButton, emoteRow, sayButton, sayCard].map(shownRect).filter(Boolean);
949
+ const rects = [hud, hudText, ribbon, askCard, back, sound?.button, sound?.card, stats, talkButton, sitButton, nearButton, panel, dock, doorsList, peopleList, picker, grabButton, emoteButton, emoteRow, sayButton, sayCard, actionChips, ...(actionOverflow?.surfaces?.() ?? [])].map(shownRect).filter(Boolean);
860
950
  if (stuckSpot) {
861
951
  rects.push(stuckSpot);
862
952
  }
@@ -868,6 +958,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
868
958
  const left = (geometry.view().w - width) / 2;
869
959
  const blocked = choices && left < choices.right && left + width > choices.left && top < choices.bottom && top + height > choices.top;
870
960
  toastChoiceBlocked = Boolean(blocked);
961
+ toastNoRow = rects.some((r) => left < r.right && left + width > r.left && top < r.bottom && top + height > r.top);
871
962
  syncToastVisibility();
872
963
  const nextTop = wide ? '' : `${band.top}px`;
873
964
  const nextBottom = wide ? `${band.bottom}px` : '';
@@ -949,6 +1040,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
949
1040
  event.preventDefault();
950
1041
  made.open = !made.open;
951
1042
  card.style.display = made.open ? 'flex' : 'none';
1043
+ soundOpen = made.open;
1044
+ syncDockVisibility();
952
1045
  layoutLandscapeRail();
953
1046
  });
954
1047
  mute.addEventListener('pointerdown', (event) => {
@@ -985,6 +1078,85 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
985
1078
  hudClearKey = '';
986
1079
  hudClearPending.clear();
987
1080
  }
1081
+ // The HUD's lane in a small view (a game on castle.xyz in a short desktop
1082
+ // window draws a 179x250 view): the centred HUD would lie under the
1083
+ // right-edge controls (Quick chat, Emote, Grab, Sound), which a short view
1084
+ // stacks up to the top. It is laid out instead in the lane left of them,
1085
+ // right of a Back at the top, and its big line is drawn on one line at the
1086
+ // size that fits there. Only the frame's snapshot is read: when the HUD's
1087
+ // words, the view or those controls change it goes back to its centred
1088
+ // place, and the next frame lays it out again from there; one that has
1089
+ // grown taller onto another control is narrowed again the same way.
1090
+ // Nothing is written where the centred HUD is clear. `hub.safeInsets`
1091
+ // lays the HUD out itself (`safeLayout.js`).
1092
+ let hudLaneKey = '';
1093
+ let hudLaneWritten = null;
1094
+ const HUD_LANE_BIG = ['whiteSpace', 'overflow', 'textOverflow', 'fontSize', 'maxWidth'];
1095
+ function restoreHudLane() {
1096
+ if (!hudLaneWritten) {return;}
1097
+ hud.style.maxWidth = hudLaneWritten.maxWidth;
1098
+ hud.style.translate = '';
1099
+ // A clear HUD (v1.26) owns its big line's styles; they are put back only
1100
+ // where this wrote them.
1101
+ for (const key of HUD_LANE_BIG) {
1102
+ if (hudLaneWritten.big[key] !== undefined && hudBig.style[key] === hudLaneWritten.wrote[key]) {hudBig.style[key] = hudLaneWritten.big[key];}
1103
+ }
1104
+ hudLaneWritten = null;
1105
+ }
1106
+ function writeHudBig(key, value) {
1107
+ if (hudBig.style[key] === value) {return;}
1108
+ if (!(key in hudLaneWritten.big)) {hudLaneWritten.big[key] = hudBig.style[key];}
1109
+ hudBig.style[key] = value;
1110
+ hudLaneWritten.wrote[key] = hudBig.style[key];
1111
+ }
1112
+ function layoutHudLane() {
1113
+ if (safeInsets) {return;}
1114
+ const shown = hud.style.display !== 'none' && hud.isConnected !== false;
1115
+ const view = geometry.view();
1116
+ const column = [sayButton, emoteButton, grabButton, sound?.button]
1117
+ .filter((node) => node && node.style.display !== 'none').map((node) => geometry.rect(node)).filter((box) => box.width > 0 && box.height > 0);
1118
+ const backBox = back.style.display !== 'none' ? geometry.rect(back) : null;
1119
+ const key = shown ? [hudTitle.textContent, hudBig.textContent.length, view.w, view.h,
1120
+ ...[...column, ...(backBox ? [backBox] : [])].flatMap((box) => [box.left, box.top, box.right, box.bottom])].join('\u0001') : '';
1121
+ if (key !== hudLaneKey) {
1122
+ hudLaneKey = key;
1123
+ restoreHudLane();
1124
+ return;
1125
+ }
1126
+ if (!shown) {return;}
1127
+ const drawn = geometry.rect(hud);
1128
+ const hits = drawn.width > 0 ? column.filter((other) => overlaps(drawn, other)) : [];
1129
+ if (hits.length) {
1130
+ const left = backBox && backBox.width > 0 && backBox.top < drawn.bottom && backBox.left < view.w / 2 ? backBox.right + 8 : 8;
1131
+ const width = Math.min(...hits.map((other) => other.left)) - 8 - left;
1132
+ if (width >= HUD_LANE_MIN && (!hudLaneWritten || width < hudLaneWritten.width)) {
1133
+ hudLaneWritten ??= { maxWidth: hud.style.maxWidth, big: {}, wrote: {} };
1134
+ hudLaneWritten.width = width;
1135
+ hud.style.maxWidth = `${width}px`;
1136
+ // The HUD is centred on the view; centre it on the lane instead.
1137
+ hud.style.translate = `${Math.round(left + width / 2 - view.w / 2)}px 0px`;
1138
+ if (!hudClear) {
1139
+ writeHudBig('whiteSpace', 'nowrap');
1140
+ writeHudBig('overflow', 'hidden');
1141
+ writeHudBig('textOverflow', 'ellipsis');
1142
+ }
1143
+ }
1144
+ }
1145
+ if (!hudLaneWritten || !hudBig.textContent) {return;}
1146
+ // The clear HUD's one-line big line keeps to the lane; either way the
1147
+ // line is drawn at the size that fits it, from the frame's measure.
1148
+ if (hudClear && hudBig.style.maxWidth.endsWith('px') && Number.parseFloat(hudBig.style.maxWidth) > hudLaneWritten.width) {
1149
+ writeHudBig('maxWidth', `${hudLaneWritten.width}px`);
1150
+ }
1151
+ if (!hudClear) {
1152
+ const fit = geometry.fit(hudBig);
1153
+ if (fit.text === hudBig.textContent && (fit.fontSize === hudBig.style.fontSize || !hudBig.style.fontSize)) {
1154
+ const base = Number.parseFloat(fit.fontSize) || 56;
1155
+ const px = fitPx(base, fit.client, fit.scroll);
1156
+ if (px < base) {writeHudBig('fontSize', `${px}px`);}
1157
+ }
1158
+ }
1159
+ }
988
1160
  function layoutHudClear(big, text) {
989
1161
  hudClearDrawn = true;
990
1162
  const backShown = back.style.display !== 'none';
@@ -1053,6 +1225,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1053
1225
  }
1054
1226
  const moves = [];
1055
1227
  for (const [group, entries] of groups) {
1228
+ // The world layout already placed pointers clear of the HUD, the prompt
1229
+ // and every control; moving one again here lifts it onto a control.
1230
+ if (worldLayout && group === 'pointers') {continue;}
1056
1231
  for (const [node, x, y, anchor] of entries) {
1057
1232
  // One since hidden or taken away is left alone.
1058
1233
  if (!node || node.style.display === 'none' || !Number.isFinite(x) || !Number.isFinite(y)) {
@@ -1113,46 +1288,153 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1113
1288
  const menuCovered = new Set();
1114
1289
  const railNodes = [picker, grabButton, emoteButton, sayButton, sitButton, talkButton, nearButton];
1115
1290
  const railHeight = (node) => Number.parseFloat(node.style.height) || geometry.size(node).h;
1116
- function layoutLandscapeRail() {
1117
- if (safeInsets) {return;}
1118
- if (!landscape) {
1119
- return;
1120
- }
1121
- const baseBottom = 10 + lockLift;
1122
- let bottom = baseBottom;
1291
+ // A portrait view too short for the corner column (a game on castle.xyz in
1292
+ // a short desktop window, 219x290): Quick chat and Emote, placed from the
1293
+ // bottom, reach up onto Sound and the native corner. The corner's buttons
1294
+ // take the rail there instead, wrapping into another column under the
1295
+ // ceiling; the centred pills stay where portrait puts them. A taller view
1296
+ // gets the portrait corner back as it was.
1297
+ let portraitRail = false;
1298
+ // A short portrait rail with no room beside the Doors dock (179x250)
1299
+ // moves the dock to its landscape place, under the host's corner.
1300
+ function raiseDock(on) {
1301
+ if (on === dockHigh) {return;}
1302
+ dockHigh = on;
1303
+ Object.assign(dock.style, on ? { top: 'max(68px, calc(env(safe-area-inset-top) + 56px))', bottom: '' } : { top: '', bottom: 'max(10px, env(safe-area-inset-bottom))' });
1304
+ for (const list of [doorsList, peopleList]) {aboveDock(list);}
1305
+ syncDockVisibility();
1306
+ }
1307
+ // The dock's buttons as they stand at the bottom left, wherever it is now
1308
+ // (a wide label overflows the dock's own box). `dockFloor` is where the
1309
+ // dock's bottom edge stands lowered, safe-area inset included.
1310
+ const dockFloor = el('div', { position: 'absolute', bottom: 'max(10px, env(safe-area-inset-bottom))', left: '0', width: '0', height: '0', visibility: 'hidden' }, root);
1311
+ function dockAtBottom() {
1312
+ const boxes = [...dock.children].map(shownRect).filter(Boolean);
1313
+ if (!boxes.length || pickerCompact && pickerOpen) {return null;}
1314
+ const box = { left: Math.min(...boxes.map(b => b.left)), right: Math.max(...boxes.map(b => b.right)), top: Math.min(...boxes.map(b => b.top)), bottom: Math.max(...boxes.map(b => b.bottom)) };
1315
+ const drop = dockHigh ? geometry.rect(dockFloor).bottom - box.bottom : 0;
1316
+ return { ...box, top: box.top + drop, bottom: box.bottom + drop };
1317
+ }
1318
+ const portraitPills = new Set([sitButton, talkButton, nearButton]);
1319
+ const railCeiling = (card = shownRect(sound?.card)) => Math.max(
1320
+ safeInsets ? 108 + (safeLayout?.view().insets.top ?? 0) : Math.max(64, Math.min(geometry.view().h - 44, 76)),
1321
+ shownRect(sound?.button)?.bottom + 6 || 0,
1322
+ card?.bottom + 6 || 0,
1323
+ );
1324
+ const shortPortrait = () => geometry.view().h - PORTRAIT_COLUMN_TOP - lockLift < railCeiling();
1325
+ function restorePortraitCorner() {
1326
+ picker.style.right = edge('right', 10);
1327
+ grabButton.style.right = edge('right', 14);
1328
+ for (const node of [emoteButton, sayButton]) {node.style.right = edge('right', 20);}
1329
+ for (const card of [emoteRow, sayCard]) {Object.assign(card.style, { right: edge('right', 80), maxHeight: '', overflowY: '', maxWidth: '', boxSizing: '', overflowX: '' });}
1330
+ for (const [node, bottom] of cornerBottoms) {node.style.bottom = lockLift ? `calc(${bottom} + ${lockLift}px)` : bottom;}
1331
+ if (actRail) {Object.assign(actRail.style, { right: edge('right', 14), bottom: 'max(60px, calc(env(safe-area-inset-bottom) + 50px))' });}
1332
+ soundBeside(false);
1333
+ raiseDock(false);
1334
+ }
1335
+ // An open Sound card the short portrait rail cannot fit under (179x250
1336
+ // with Shift lock) opens left of its button instead, level with its top
1337
+ // and fitted to the room there.
1338
+ function soundBeside(on) {
1339
+ if (!sound || on === soundAside) {return;}
1340
+ soundAside = on;
1341
+ syncDockVisibility();
1342
+ Object.assign(sound.card.style, on
1343
+ ? { top: soundTop, right: edge('right', 58), width: 'min(208px, calc(100vw - 66px))' }
1344
+ : { top: `calc(${soundTop} + 46px)`, right: edge('right', 12), width: 'min(70vw, 208px)' });
1345
+ }
1346
+ // The rail's columns, bottom up and wrapping leftwards under `ceiling`.
1347
+ // Shift lock lifts a column only where it stands under it: a short
1348
+ // portrait view's wrapped column left of the lock starts at the bottom.
1349
+ // A button that would stand on `navigation` (the Doors dock's box) stands
1350
+ // above it instead.
1351
+ // `fits` is false where a column rises over the ceiling or leaves the view.
1352
+ function layRail(ceiling, navigation = null) {
1353
+ const view = geometry.view();
1354
+ const lock = !landscape && lockLift ? shownRect(companionLock) : null;
1355
+ const lifted = 10 + lockLift;
1356
+ let base = lifted;
1357
+ let bottom = base;
1123
1358
  let right = 12;
1124
1359
  let columnWidth = 0;
1125
1360
  const placed = new Map();
1126
- const ceiling = Math.max(
1127
- safeInsets ? 108 + (safeLayout?.view().insets.top ?? 0) : Math.max(64, Math.min(geometry.view().h - 44, 76)),
1128
- shownRect(sound?.button)?.bottom + 6 || 0,
1129
- shownRect(sound?.card)?.bottom + 6 || 0,
1130
- );
1361
+ placed.fits = true;
1362
+ const clearOfDock = (node, at) => {
1363
+ const left = view.w - right - geometry.size(node).w;
1364
+ const top = view.h - at - railHeight(node);
1365
+ return navigation && navigation.right + 6 > left && top < navigation.bottom + 6 && view.h - at > navigation.top - 6
1366
+ ? view.h - navigation.top + 6 : at;
1367
+ };
1131
1368
  for (const node of railNodes) {
1132
- if (node.style.display === 'none' || node.style.visibility === 'hidden') {
1369
+ if (node.style.display === 'none' || node.style.visibility === 'hidden' || !landscape && portraitPills.has(node)) {
1133
1370
  continue;
1134
1371
  }
1135
1372
  const height = railHeight(node);
1136
- if (bottom > baseBottom && geometry.view().h - bottom - height < ceiling) {
1373
+ if (bottom > base && view.h - clearOfDock(node, bottom) - height < ceiling) {
1137
1374
  right += columnWidth + 6;
1138
- bottom = baseBottom;
1375
+ base = lock && lock.left >= view.w - right + 6 ? 10 : lifted;
1376
+ bottom = base;
1139
1377
  columnWidth = 0;
1140
1378
  }
1379
+ bottom = clearOfDock(node, bottom);
1141
1380
  node.style.right = safeInsets ? `calc(max(12px, env(safe-area-inset-right)) + ${right - 12}px)` : `${right}px`;
1142
1381
  node.style.bottom = `max(${bottom}px, calc(env(safe-area-inset-bottom) + ${Math.max(0, bottom - 10)}px))`;
1143
1382
  const width = geometry.size(node).w;
1144
1383
  placed.set(node, { right, bottom, width });
1384
+ if (view.h - bottom - height < ceiling || view.w - right - width < 6) {placed.fits = false;}
1145
1385
  columnWidth = Math.max(columnWidth, width);
1146
1386
  bottom += height + 6;
1147
1387
  }
1388
+ return placed;
1389
+ }
1390
+ function layoutLandscapeRail() {
1391
+ if (safeInsets) {return;}
1392
+ if (!landscape) {
1393
+ // The card's own place is not what makes a view short.
1394
+ soundBeside(false);
1395
+ if (!shortPortrait()) {
1396
+ if (portraitRail) {
1397
+ portraitRail = false;
1398
+ restorePortraitCorner();
1399
+ }
1400
+ return;
1401
+ }
1402
+ portraitRail = true;
1403
+ }
1404
+ // A short portrait rail keeps clear of the Doors dock at the bottom
1405
+ // left; one with no room for that moves the dock under the host's
1406
+ // corner. A rail that then ends up under the Sound card or off the left
1407
+ // edge is laid again with the card beside its button.
1408
+ const navigation = landscape ? null : dockAtBottom();
1409
+ if (!landscape) {raiseDock(Boolean(navigation) && !layRail(railCeiling(null), navigation).fits && layRail(railCeiling(null)).fits);}
1410
+ let placed = layRail(railCeiling(), dockHigh ? null : navigation);
1411
+ const card = shownRect(sound?.card);
1412
+ if (!landscape && card && !placed.fits) {
1413
+ soundBeside(true);
1414
+ const button = shownRect(sound.button);
1415
+ const h = card.bottom - card.top;
1416
+ placed = layRail(railCeiling({ bottom: Math.max(button.bottom, button.top + h) }), dockHigh ? null : navigation);
1417
+ }
1148
1418
  // Open pickers sit immediately left of the button that owns them, even
1149
1419
  // when the dense rail wrapped that button into its second column.
1150
1420
  for (const [card, button] of [[emoteRow, emoteButton], [sayCard, sayButton]]) {
1151
1421
  const at = placed.get(button);
1152
1422
  if (!at) {continue;}
1153
1423
  // Clear the whole action lane even when this card belongs to a narrower
1154
- // round button beside a 160px text action.
1155
- card.style.right = safeInsets ? `calc(max(12px, env(safe-area-inset-right)) + ${Math.max(184, at.right + at.width + 6) - 12}px)` : `${Math.max(184, at.right + at.width + 6)}px`;
1424
+ // round button beside a 160px text action; a short portrait view has
1425
+ // no such lane and no room for one.
1426
+ const cardRight = landscape ? Math.max(184, at.right + at.width + 6) : at.right + at.width + 6;
1427
+ card.style.right = safeInsets ? `calc(max(12px, env(safe-area-inset-right)) + ${cardRight - 12}px)` : `${cardRight}px`;
1428
+ // A short portrait view fits the card on the side of its button with
1429
+ // more room (right of it, over the first column, when the button is in
1430
+ // a wrapped one), never over the button itself; it scrolls there.
1431
+ if (!landscape) {
1432
+ const viewW = geometry.view().w;
1433
+ const leftRoom = viewW - cardRight - 8, rightRoom = at.right - 14;
1434
+ const onRight = rightRoom > leftRoom;
1435
+ card.style.right = `${onRight ? 8 : cardRight}px`;
1436
+ Object.assign(card.style, { boxSizing: 'border-box', maxWidth: `${Math.max(0, onRight ? rightRoom : leftRoom)}px`, overflowX: 'auto' });
1437
+ }
1156
1438
  card.style.bottom = button.style.bottom;
1157
1439
  card.style.maxHeight = `calc(100dvh - ${at.bottom + 12}px - env(safe-area-inset-top) - env(safe-area-inset-bottom))`;
1158
1440
  card.style.overflowY = 'auto';
@@ -1173,12 +1455,19 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1173
1455
  const next = landscapeViewport();
1174
1456
  if (!force && next === landscape) {
1175
1457
  for (const list of [doorsList, peopleList]) {aboveDock(list);}
1176
- if (next) {layoutLandscapeRail();}
1458
+ layoutLandscapeRail();
1177
1459
  return;
1178
1460
  }
1179
1461
  landscape = next;
1462
+ if (portraitRail) {
1463
+ portraitRail = false;
1464
+ restorePortraitCorner();
1465
+ }
1466
+ dockHigh = false;
1467
+ syncDockVisibility();
1180
1468
  // Back clears the native exit corner; the HUD and toast narrow.
1181
1469
  hudSurface.setLandscape(landscape);
1470
+ hudSurface.setBackLow(backLow(shownBack.label));
1182
1471
  Object.assign(dock.style, landscape
1183
1472
  ? { top: 'max(68px, calc(env(safe-area-inset-top) + 56px))', bottom: '', maxWidth: 'min(24vw, 160px)' }
1184
1473
  : { top: '', bottom: 'max(10px, env(safe-area-inset-bottom))', maxWidth: 'calc(100vw - 130px)' });
@@ -1214,6 +1503,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1214
1503
  sitButton.style.bottom = 'max(112px, calc(env(safe-area-inset-bottom) + 102px))';
1215
1504
  talkButton.style.bottom = 'max(64px, calc(env(safe-area-inset-bottom) + 54px))';
1216
1505
  nearButton.style.bottom = 'max(160px, calc(env(safe-area-inset-bottom) + 150px))';
1506
+ portraitRail = false;
1217
1507
  }
1218
1508
  layoutPanel();
1219
1509
  layoutLandscapeRail();
@@ -1226,6 +1516,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1226
1516
  // of the untouched baseline, while an initially-landscape view is laid out.
1227
1517
  if (landscape) {
1228
1518
  applyViewportLayout(true);
1519
+ } else {
1520
+ layoutLandscapeRail();
1229
1521
  }
1230
1522
 
1231
1523
  // v1.75: only allocated for an opted-in prompt. The field is the only
@@ -1283,8 +1575,14 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1283
1575
  ...[...extraSurfaces.values()].filter((item) => item.kind === 'control').map((item) => item.node),
1284
1576
  ].filter((node) => node?.dataset);
1285
1577
  }
1578
+ // A host drawing its own covering sheet (the native UI tree menu) asks for
1579
+ // the same mask with `coverControls(true)`; the rule then sits in a style
1580
+ // element of its own, since no DOM sheet is open to carry it.
1581
+ let hostCover = null;
1582
+ // v1.204: the rule `setCatching` dims with, once one is needed.
1583
+ let catchingCss = null;
1286
1584
  function coverControls() {
1287
- if (!placeMenu?.covers) {return;}
1585
+ if (!placeMenu?.covers && !hostCover) {return;}
1288
1586
  for (const node of menuCoveredNodes()) {
1289
1587
  if (menuCovered.has(node) && node.dataset.hubMenuCovered !== undefined) {continue;}
1290
1588
  node.dataset.hubMenuCovered = '';
@@ -1292,10 +1590,29 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1292
1590
  }
1293
1591
  }
1294
1592
  function uncoverControls() {
1295
- if (!menuCovered.size) {return;}
1593
+ if (hostCover || !menuCovered.size) {return;}
1296
1594
  for (const node of menuCovered) {delete node.dataset.hubMenuCovered;}
1297
1595
  menuCovered.clear();
1298
1596
  }
1597
+ // A tile label's longest word ("Firefighter") shrinks to the tile's width
1598
+ // instead of breaking mid-word. Each word is measured once at 12px in the
1599
+ // sheet's own font; the tile is an inline-size container, so the font
1600
+ // follows the tile through a resize. Without container units the
1601
+ // assignment is dropped and 12px stays.
1602
+ function fitTileLabels(sheet, labels) {
1603
+ // All probes go in before any read and every label is written after the
1604
+ // last, so opening a sheet costs one layout, not one per tile.
1605
+ const probes = labels.map(({ word }) => {
1606
+ const probe = el('span', { position: 'absolute', visibility: 'hidden', whiteSpace: 'nowrap', fontSize: '12px' }, sheet);
1607
+ probe.textContent = word;
1608
+ return probe;
1609
+ });
1610
+ const widths = probes.map((probe, i) => probe.offsetWidth || [...labels[i].word].length * 7.5);
1611
+ for (const probe of probes) {probe.remove();}
1612
+ labels.forEach(({ label }, i) => {
1613
+ label.style.fontSize = `clamp(8px, calc(100cqi * ${(11.6 / Math.max(1, widths[i])).toFixed(4)}), 12px)`;
1614
+ });
1615
+ }
1299
1616
  function setMenu(offer, handler, onOpen) {
1300
1617
  if (!offer) { closeMenu(); return; }
1301
1618
  if (placeMenu && offer.n <= placeMenu.n) {return;}
@@ -1313,10 +1630,13 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1313
1630
  placeMenu.covers = rows && !Object.hasOwn(spec, 'face');
1314
1631
  if (Object.hasOwn(spec, 'face')) {placeMenu.face = spec.face;}
1315
1632
  const height = Object.hasOwn(spec, 'face') ? 40 : 55;
1633
+ // A short view keeps a row of choices: never under SHORT_PX (menuTree.js), short of the view.
1634
+ const floor = Object.hasOwn(spec, 'face') ? SHORT_FACE_PX : SHORT_PX;
1635
+ const cap = (unit) => (rows && !Object.hasOwn(spec, 'face') ? `calc(100${unit} - 24px)` : `min(max(${height}${unit}, ${floor}px), calc(100${unit} - 24px))`);
1316
1636
  const listeners = new AbortController(), signal = listeners.signal, timers = new Set();
1317
1637
  // The same column, padding, corners and shadow as the Doors/chat panels.
1318
1638
  // Token fallbacks use their existing palette when no tokens are installed.
1319
- const sheet = el('div', { position: 'absolute', left: '50%', bottom: '0', transform: 'translateX(-50%)', width: 'min(100%, 720px)', maxHeight: rows && !Object.hasOwn(spec, 'face') ? 'calc(100vh - 24px)' : `${height}vh`, boxSizing: 'border-box', overflow: 'hidden', pointerEvents: 'auto', display: 'flex', flexDirection: 'column', gap: '6px', padding: '12px', paddingBottom: 'max(12px, env(safe-area-inset-bottom))', borderRadius: '12px 12px 0 0', background: 'var(--castle-surface-3, rgba(20,16,12,0.88))', color: 'var(--castle-text-primary, #fff)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', zIndex: '9' }, root);
1639
+ const sheet = el('div', { position: 'absolute', left: '50%', bottom: '0', transform: 'translateX(-50%)', width: 'min(100%, 720px)', maxHeight: cap('vh'), boxSizing: 'border-box', overflow: 'hidden', pointerEvents: 'auto', display: 'flex', flexDirection: 'column', gap: '6px', padding: '12px', paddingBottom: 'max(12px, env(safe-area-inset-bottom))', borderRadius: '12px 12px 0 0', background: 'var(--castle-surface-3, rgba(20,16,12,0.88))', color: 'var(--castle-text-primary, #fff)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', zIndex: '9' }, root);
1320
1640
  sheet.className = 'hub-menu-sheet';
1321
1641
  sheet.dataset.hub = 'menu';
1322
1642
  sheet.setAttribute('role', 'dialog');
@@ -1330,7 +1650,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1330
1650
  @media (prefers-reduced-motion: reduce) { .hub-menu-tile:not(:disabled):active, .hub-menu-tile.is-pressed { transform: none; } }
1331
1651
  @media (max-width: 600px) { .hub-menu-grid { grid-template-columns: repeat(4, minmax(64px, 1fr)) !important; } }
1332
1652
  @media (max-width: 340px) { .hub-menu-grid { grid-template-columns: repeat(3, minmax(64px, 1fr)) !important; } }
1333
- @supports (height: 1dvh) { .hub-menu-sheet { max-height: ${rows && !Object.hasOwn(spec, 'face') ? 'calc(100dvh - 24px)' : `${height}dvh`} !important; } }
1653
+ @supports (height: 1dvh) { .hub-menu-sheet { max-height: ${cap('dvh')} !important; } }
1334
1654
  ` + (placeMenu.covers ? ` ${MENU_COVERED_RULE}\n ` : '');
1335
1655
  for (const type of ['pointerdown', 'pointermove', 'pointerup', 'mousedown', 'wheel', 'contextmenu', 'keydown', 'keyup']) {
1336
1656
  sheet.addEventListener(type, (event) => event.stopPropagation(), { signal });
@@ -1360,12 +1680,13 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1360
1680
  drawMenuRows({ el, sheet, scroll, spec, signal, pick: (id) => { if (placeMenu?.sheet) { handler(id, offer.n); } } });
1361
1681
  }
1362
1682
  if (!rows) {
1683
+ const labels = [];
1363
1684
  for (const section of spec.sections) {
1364
1685
  el('div', { fontSize: '13px', margin: '8px 0', color: 'var(--castle-text-secondary, #fff)' }, scroll).textContent = section.title;
1365
1686
  const grid = el('div', { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(64px, 1fr))', gap: '8px' }, scroll);
1366
1687
  grid.className = 'hub-menu-grid';
1367
1688
  for (const item of section.items) {
1368
- const tile = el('button', { position: 'relative', aspectRatio: '1', minWidth: '64px', minHeight: '64px', padding: '6px', overflow: 'hidden', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: '4px', touchAction: 'manipulation', overflowWrap: 'anywhere' }, grid);
1689
+ const tile = el('button', { position: 'relative', aspectRatio: '1', minWidth: '64px', minHeight: '64px', padding: '6px', overflow: 'hidden', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: '4px', touchAction: 'manipulation', overflowWrap: 'anywhere', containerType: 'inline-size' }, grid);
1369
1690
  tile.className = 'hub-menu-tile'; tile.type = 'button'; tile.disabled = spec.readOnly === true;
1370
1691
  tile.dataset.id = item.id;
1371
1692
  tile.setAttribute('aria-label', item.label);
@@ -1382,7 +1703,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1382
1703
  swatch.style.maskRepeat = swatch.style.webkitMaskRepeat = 'no-repeat';
1383
1704
  }
1384
1705
  swatch.setAttribute('aria-hidden', 'true');
1385
- el('span', { fontSize: '12px', lineHeight: '1.15', maxHeight: '2.3em', overflow: 'hidden' }, tile).textContent = item.label;
1706
+ const label = el('span', { fontSize: '12px', lineHeight: '1.15', maxHeight: '2.3em', overflow: 'hidden' }, tile);
1707
+ label.textContent = item.label;
1708
+ labels.push({ label, word: String(item.label ?? '').split(/\s+/).reduce((a, b) => ([...b].length > [...a].length ? b : a), '') });
1386
1709
  if (!tile.disabled) {
1387
1710
  tile.addEventListener('pointerdown', (event) => event.preventDefault(), { signal });
1388
1711
  tile.addEventListener('click', () => {
@@ -1396,6 +1719,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1396
1719
  }
1397
1720
  }
1398
1721
  }
1722
+ fitTileLabels(sheet, labels);
1399
1723
  }
1400
1724
  Object.assign(placeMenu, { sheet, css, listeners, timers, onOpen, cancel });
1401
1725
  coverControls();
@@ -1450,7 +1774,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1450
1774
  // Setters late in the frame may have queued HUD clearance; place it by
1451
1775
  // this frame's snapshot before the snapshot ends.
1452
1776
  flushHudClear();
1453
- if (placeMenu?.sheet) {coverControls();}
1777
+ if (placeMenu?.sheet || hostCover) {coverControls();}
1454
1778
  geometry.endFrame();
1455
1779
  for (const [key, node] of labelMeasures) {
1456
1780
  if (!usedLabelMeasures.has(key)) {node.remove(); labelMeasures.delete(key);}
@@ -1480,6 +1804,22 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1480
1804
  interactionRoot: () => root,
1481
1805
  // The Act/Jump pair's state and handlers (`act.js`), for the HUD root a
1482
1806
  // native host draws; the page's pair is drawn by `act.js` itself.
1807
+ // v1.204: dims the controls whose presses wait on a progress read (the
1808
+ // place's menu, text ask and action rail); the presses are refused by
1809
+ // their handlers. The Act pair dims itself (`act.js`).
1810
+ setCatching(on) {
1811
+ // Made at the first need, so a player who never catches up has the
1812
+ // chrome's layers exactly as before.
1813
+ if (on && !catchingCss) {
1814
+ catchingCss = el('style', {}, root);
1815
+ catchingCss.textContent = ['menu', 'text-ask', 'action-rail', 'decor', 'ballot', 'talk-button', 'talk-panel', 'grab-button']
1816
+ .map((hub) => `[data-hub-catching] [data-hub="${hub}"]`).join(', ') + ' { opacity: .5; }';
1817
+ }
1818
+ // On the document: the ballot sheet and decor layer live outside root.
1819
+ const marked = document.documentElement ?? root;
1820
+ if (on && marked.dataset.hubCatching === undefined) {marked.dataset.hubCatching = '';}
1821
+ else if (!on && marked.dataset.hubCatching !== undefined) {delete marked.dataset.hubCatching;}
1822
+ },
1483
1823
  setActPair(state) {
1484
1824
  hudSurface.setActPair(state);
1485
1825
  },
@@ -1495,7 +1835,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1495
1835
  },
1496
1836
  layoutInteractionRail() {
1497
1837
  if (!actRail) {return;}
1498
- if (landscape) {layoutLandscapeRail();}
1838
+ if (landscape || portraitRail) {layoutLandscapeRail();}
1499
1839
  else {Object.assign(actRail.style, { left: '', right: edge('right', 14), top: '', bottom: 'max(60px, calc(env(safe-area-inset-bottom) + 50px))' });}
1500
1840
  },
1501
1841
  setActMode: value => {
@@ -1509,7 +1849,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1509
1849
  worldLabelsDefault = on;
1510
1850
  // The root town retains its explicit near selection; its selected text
1511
1851
  // still needs the same final HUD/control/avatar clearance as doors.
1512
- worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry);
1852
+ worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry, (node) => safeLayout?.heldAct?.(node) ?? null);
1513
1853
  },
1514
1854
  // An avatar crossing the camera's near plane has no reliable screen box
1515
1855
  // (and may be hidden by the renderer's first-person view).
@@ -1522,9 +1862,21 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1522
1862
  },
1523
1863
  worldAvatar: () => worldAvatar,
1524
1864
  setWorldViewport: (area) => {worldViewport = area;},
1525
- beginWorldLabels: () => worldLayout?.begin(),
1865
+ beginWorldLabels: () => worldLayout?.begin(true),
1526
1866
  flushWorldLabels: () => worldLayout?.flush(),
1527
1867
  setMenu, clearMenu,
1868
+ coverControls(on) {
1869
+ if (!on === !hostCover) {return;}
1870
+ if (on) {
1871
+ hostCover = el('style', {}, root);
1872
+ hostCover.textContent = MENU_COVERED_RULE;
1873
+ coverControls();
1874
+ } else {
1875
+ hostCover.remove();
1876
+ hostCover = null;
1877
+ if (!placeMenu?.covers || !placeMenu.sheet) {uncoverControls();}
1878
+ }
1879
+ },
1528
1880
  cancelMenu: () => placeMenu?.cancel?.(),
1529
1881
  menuOpen: () => !!placeMenu?.sheet,
1530
1882
  menuFace: () => placeMenu?.sheet ? placeMenu.face : undefined,
@@ -1558,6 +1910,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1558
1910
  const card = el('div', { position: 'fixed', left: '50%', transform: 'translateX(-50%)', width: 'min(90vw, 320px)', boxSizing: 'border-box', pointerEvents: 'auto', display: 'flex', flexDirection: 'column', gap: '10px', padding: '14px', borderRadius: '12px', background: '#17120e', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', fontSize: '14px' }, shield);
1559
1911
  card.setAttribute('role', 'dialog');
1560
1912
  card.setAttribute('aria-label', spec.title);
1913
+ card.dataset.hub = 'text-ask';
1561
1914
  const place = () => {
1562
1915
  const view = window.visualViewport;
1563
1916
  // Stay in the visible viewport as the phone keyboard rises.
@@ -1605,8 +1958,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1605
1958
  return;
1606
1959
  }
1607
1960
  const text = cancelled ? null : input.value;
1961
+ // v1.204: an answer refused while catching up keeps the card and its text.
1962
+ if (handler(spec.id, spec.n, text) === false) {return;}
1608
1963
  closeTextAsk();
1609
- handler(spec.id, spec.n, text);
1610
1964
  };
1611
1965
  ok.addEventListener('click', () => answer(false), { signal });
1612
1966
  cancel.addEventListener('click', () => answer(true), { signal });
@@ -1647,7 +2001,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1647
2001
  }
1648
2002
  },
1649
2003
  showBack(show, label = 'Back') {
1650
- hudSurface.showBack(show, label);
2004
+ shownBack = { show, label };
2005
+ hudSurface.showBack(show, label, backLow(label));
1651
2006
  },
1652
2007
  setActions(items, handler, canAct, n, overflow = false, onOverflowOpen = () => {}) {
1653
2008
  if (safeInsets) {overflow = true;}
@@ -1671,6 +2026,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1671
2026
  root,
1672
2027
  ...(safeInsets ? { edgeMax: true, readSafeInsets: () => safeLayout.view().insets } : {}),
1673
2028
  obstacles: actionOverflowObstacles,
2029
+ // A prompt or act prompt the safe layout moved off a control (or
2030
+ // hid) is an obstacle at the place it held, so the rail settles
2031
+ // exactly as before.
2032
+ held: (node) => (node === hudText ? safeLayout?.heldPrompt?.() : safeLayout?.heldAct?.(node)) ?? null,
2033
+ transient: () => [[hudText, toast, stats, feed, ribbon], [hud]],
1674
2034
  reserved: ({ w, h, safe }) => [
1675
2035
  // The native exit target lives outside this document's DOM.
1676
2036
  { left: safe.left, right: safe.left + 64, top: safe.top, bottom: safe.top + 56 },
@@ -1690,7 +2050,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1690
2050
  });
1691
2051
  }
1692
2052
  syncActionSurfaces();
1693
- actionOverflow.set(items, handler, canAct, n);
2053
+ // Offers yield to open panels and sound their cue, as the legacy chips did.
2054
+ const onAction = (id, offerN) => {onChip?.(); handler?.(id, offerN);};
2055
+ actionOverflow.set(items, onAction, canAct && !pickerOpen && !sayOpen && !emotesOpen && !peopleOpen && !doorsOpen && !talkOpen, n);
1694
2056
  syncOverflowSources();
1695
2057
  return;
1696
2058
  }
@@ -1839,6 +2201,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1839
2201
  if (hudClear) {
1840
2202
  layoutHudClear(big, spec.text ?? '');
1841
2203
  }
2204
+ layoutHudLane();
1842
2205
  if (import.meta.env?.DEV) {
1843
2206
  warnHudCopy(hudTitle, 'subtitle');
1844
2207
  warnHudCopy(hudText, 'prompt', 1);
@@ -1889,7 +2252,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1889
2252
  node.textContent = text;
1890
2253
  labelMeasures.set(key, node);
1891
2254
  }
1892
- return geometry.size(node);
2255
+ // The drawn box, fractions included: the label is centred on its own
2256
+ // fractional width, so the whole-pixel `offsetWidth` placed it up to
2257
+ // half a pixel off (270 for 270.47). A node with no box keeps it.
2258
+ const drawn = geometry.dimensions(node);
2259
+ return drawn.w > 0 && drawn.h > 0 ? drawn : geometry.size(node);
1893
2260
  },
1894
2261
  // A owns only this lazy, noninteractive caption. The projected surface
1895
2262
  // participates in the shared registry but is placed last, yielding to
@@ -1897,7 +2264,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1897
2264
  setPadContext(item) {
1898
2265
  const blocked = pickerOpen || sayOpen || emotesOpen || peopleOpen || doorsOpen || talkOpen ||
1899
2266
  !!textAsk?.card || !!placeMenu?.sheet || sound?.open || actionOverflow?.isOpen?.() ||
1900
- externalEntries().some(([, surface]) => surface.kind === 'card' && shownRect(surface.node));
2267
+ externalEntries().some(([, surface]) => surface.kind === 'card' && shownRect(surface.node)) ||
2268
+ // v1.217: an open cabinet board is read whole; the plate waits under it.
2269
+ (cabinet.style.display !== 'none' && cabinet.dataset.drawn === 'board');
1901
2270
  if (!item || blocked) {
1902
2271
  if (padContext && padContext.node.style.visibility !== 'hidden') {padContext.node.style.visibility = 'hidden';}
1903
2272
  return;
@@ -2031,8 +2400,12 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2031
2400
  let bands = null;
2032
2401
  // An emote put on its head: id -> the bottom it was put at.
2033
2402
  const emoteAt = new Map();
2403
+ clampLabels.clear();
2404
+ npcSpeech.clear();
2034
2405
  for (const item of items) {
2035
2406
  seen.add(item.id);
2407
+ if (item.box && !item.speech) {clampLabels.add(item.id);}
2408
+ if (item.speech && item.npc) {npcSpeech.add(item.id);}
2036
2409
  let node = labelNodes.get(item.id);
2037
2410
  if (!node) {
2038
2411
  node = el('div', { position: 'absolute', transform: 'translate(-50%, -100%)', padding: '4px 10px', borderRadius: '12px', background: 'rgba(15,12,10,0.7)', whiteSpace: 'nowrap', fontSize: '14px' }, labels);
@@ -2181,6 +2554,21 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2181
2554
  // A board the player asked for is read whole, wherever they stand by it.
2182
2555
  cabinet.style.opacity = String(open ? 1 : item.opacity);
2183
2556
  },
2557
+ setWinRibbons(items) {
2558
+ if (!winRibbons && !items.length) {return;}
2559
+ winRibbons ??= [];
2560
+ while (winRibbons.length < Math.min(8, items.length)) {
2561
+ winRibbons.push(el('div', { position: 'absolute', display: 'none', transform: 'translate(-50%, -100%)', padding: '4px 10px', borderRadius: '6px', background: 'linear-gradient(#f2c94c, #d69e2e)', color: '#3b2600', fontSize: '13px', fontWeight: '800', whiteSpace: 'nowrap', boxShadow: '0 2px 6px rgba(0,0,0,0.4)', pointerEvents: 'none' }, root));
2562
+ }
2563
+ for (let i = 0; i < winRibbons.length; i++) {
2564
+ const node = winRibbons[i], item = items[i];
2565
+ node.style.display = item ? 'block' : 'none';
2566
+ if (!item) {continue;}
2567
+ node.style.left = `${item.x}px`; node.style.top = `${item.y}px`;
2568
+ node.textContent = item.text;
2569
+ }
2570
+ if (hudClear) {keepClearOfHud('win-ribbons', items.slice(0, winRibbons.length).map((item, i) => [winRibbons[i], item.x, item.y, 'bottom', item.text]));}
2571
+ },
2184
2572
  setRibbon(pos, text) {
2185
2573
  if (!pos) {
2186
2574
  ribbon.style.display = 'none';
@@ -2522,6 +2910,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2522
2910
  layoutLandscapeRail();
2523
2911
  } else {
2524
2912
  for (const [node, bottom] of cornerBottoms) {node.style.bottom = lift ? `calc(${bottom} + ${lift}px)` : bottom;}
2913
+ layoutLandscapeRail();
2525
2914
  }
2526
2915
  fitPicker(true);
2527
2916
  },
@@ -2565,8 +2954,10 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2565
2954
  this.companionTalkButton.style.left = `${screen.x}px`;
2566
2955
  this.companionTalkButton.style.top = `${screen.y}px`;
2567
2956
  this.companionTalkButton.setAttribute('aria-label', `Chat with ${name}`);
2568
- // Never over a control: a tap there is the control's.
2569
- const controls = [picker, grabButton, emoteButton, sayButton, talkButton, sitButton, sound?.button, back, hud, hudText, askCard, actionChips].map(shownRect).filter(Boolean);
2957
+ // Never over a control: a tap there is the control's. The overflow
2958
+ // rail (and its sheet) is one too, so a follower walking under the
2959
+ // town counter's chips never takes their taps.
2960
+ const controls = [picker, grabButton, emoteButton, sayButton, talkButton, sitButton, sound?.button, back, hud, hudText, askCard, actionChips, ...(actionOverflow?.surfaces?.() ?? [])].map(shownRect).filter(Boolean);
2570
2961
  const covers = controls.some((r) => r.left < screen.x + 22 && r.right > screen.x - 22 && r.top < screen.y + 22 && r.bottom > screen.y - 22);
2571
2962
  this.companionTalkButton.style.display = covers ? 'none' : 'block';
2572
2963
  },
@@ -2595,7 +2986,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2595
2986
  talkWaiting: talkSurface.talkWaiting,
2596
2987
  talkFocused() {
2597
2988
  const input = panelInput();
2598
- return uiTreeDomEnabled() && input ? document.activeElement === input : talkSurface.talkFocused();
2989
+ return uiTreeDomEnabled() && input ? document.activeElement === input && !fieldWalking(input) : talkSurface.talkFocused();
2599
2990
  },
2600
2991
  // `doors` is [{ id, title }] to offer, or null for none; `goText` is the
2601
2992
  // word on each one's button ("Go", or "Go together" in a party). `stuck`
@@ -2723,10 +3114,18 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2723
3114
  const seen = new Set();
2724
3115
  // The round buttons an edge chip is kept beside, never under (v1.38: a
2725
3116
  // chip at the right edge had half its words under the chat button).
2726
- // Read once a call, and only when there is an edge chip.
2727
- const buttons = items.some((item) => item.angle !== null && item.angle !== undefined)
2728
- ? [sayButton, emoteButton, grabButton, sound?.button].map(shownRect).filter(Boolean)
3117
+ // Read once a call, and only when there is an edge chip. The Act/Jump
3118
+ // pair and a shown Character button stand in that column too: a chip
3119
+ // left on the pair was pushed down by the safe layout onto chat. A
3120
+ // shown Sit / Stand button (low in the middle, where a chip on the
3121
+ // bottom edge lies, or in the landscape rail) is kept off apart, after
3122
+ // the column: a chip that does not touch it is placed as before.
3123
+ const character = picker.style.display !== 'none' && pickerToggle.style.visibility !== 'hidden' ? pickerToggle : null;
3124
+ const anyEdge = items.some((item) => item.angle !== null && item.angle !== undefined);
3125
+ const buttons = anyEdge
3126
+ ? [sayButton, emoteButton, grabButton, sound?.button, actRail, character].map(shownRect).filter(Boolean)
2729
3127
  : [];
3128
+ const sit = anyEdge ? shownRect(sitButton) : null;
2730
3129
  for (const item of items) {
2731
3130
  seen.add(item.id);
2732
3131
  let node = pointerNodes.get(item.id);
@@ -2775,6 +3174,25 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2775
3174
  }
2776
3175
  }
2777
3176
  }
3177
+ if (edge && sit) {
3178
+ // Off Sit by the column's rule for Sit alone: to its left, else over
3179
+ // it, else under it. Each place is taken only when it is clear of
3180
+ // every column button too (the same overlap test as above), so the
3181
+ // move never lands on one; with none clear the chip keeps the
3182
+ // column's place.
3183
+ const tall = size.h / 2;
3184
+ const on = (r, cx, cy) => cx + half > r.left - 4 && cx - half < r.right + 4 && cy + tall > r.top && cy - tall < r.bottom;
3185
+ if (on(sit, x, y)) {
3186
+ const left = sit.left - 6 - half, over = sit.top - 6 - tall;
3187
+ const places = [
3188
+ ...(left >= half + 6 ? [[left, y]] : []),
3189
+ ...(over >= tall + 6 ? [[x, over]] : []),
3190
+ [x, sit.bottom + 6 + tall],
3191
+ ];
3192
+ const clear = places.find(([cx, cy]) => !buttons.some((r) => on(r, cx, cy)));
3193
+ if (clear) {[x, y] = clear;}
3194
+ }
3195
+ }
2778
3196
  if (node.chip.style.left !== `${x}px`) {node.chip.style.left = `${x}px`;}
2779
3197
  if (node.chip.style.top !== `${y}px`) {node.chip.style.top = `${y}px`;}
2780
3198
  node.y = y;
@@ -2908,8 +3326,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2908
3326
  sound.key = key;
2909
3327
  sound.muted = muted;
2910
3328
  if (!show) {
2911
- sound.open = false;
3329
+ sound.open = soundOpen = false;
2912
3330
  sound.card.style.display = 'none';
3331
+ syncDockVisibility();
2913
3332
  }
2914
3333
  sound.button.style.display = show ? 'block' : 'none';
2915
3334
  // Under the frame-rate readout where that is up (`?hubstats`).
@@ -2937,9 +3356,12 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2937
3356
  }
2938
3357
  },
2939
3358
  dispose() {
3359
+ // v1.204: the dim marker is on the document, outside root.
3360
+ if (catchingCss) {delete (document.documentElement ?? root).dataset.hubCatching;}
2940
3361
  api.clearPadContext();
2941
3362
  emoteWheel?.dispose();
2942
3363
  askLifecycle.abort();
3364
+ if (hostCover) {api.coverControls(false);}
2943
3365
  if (placeMenu) {clearMenu();}
2944
3366
  if (textAsk) {
2945
3367
  clearTextAsk();
@@ -2981,14 +3403,15 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2981
3403
  { ...surface('character-card', pickerCard, 'card'), pinned: pickerCompact },
2982
3404
  { ...surface('grab', grabButton), stack: 2 }, { ...surface('emote', emoteButton), stack: 1 }, { ...surface('quick-chat', sayButton), stack: 0 },
2983
3405
  ...(emoteWheel ? [surface('emote-wheel', emoteWheel.node, 'card')] : []),
2984
- surface('emotes', emoteRow, 'card'), surface('quick-chat-card', sayCard, 'card'),
3406
+ { ...surface('emotes', emoteRow, 'card'), beside: emoteButton }, { ...surface('quick-chat-card', sayCard, 'card'), beside: sayButton },
2985
3407
  { ...surface('sit', sitButton), stack: 6 }, { ...surface('talk', talkButton), stack: 7 }, { ...surface('near', nearButton), stack: 8 },
2986
3408
  surface('talk-card', panel, 'card'), surface('doors-card', doorsList, 'card'), surface('people-card', peopleList, 'card'),
2987
- { ...surface('navigation', dock, 'control', false, { left: 10, bottom: 10 }), reportNodes: () => [
3409
+ // The stacked column keeps clear of the dock, or raises it (`clearOfStack`).
3410
+ { ...surface('navigation', dock, 'control', false, { left: 10, bottom: 10 }), clearOfStack: { atBottom: () => !landscape, raised: () => dockHigh, raise: raiseDock }, reportNodes: () => [
2988
3411
  { id: 'doors', kind: 'control', node: doorsButton }, { id: 'people', kind: 'control', node: peopleButton },
2989
3412
  { id: 'companion-badge', kind: 'control', node: companionBadge },
2990
3413
  ] },
2991
- surface('sound', sound?.button, 'control', false, { right: 12, top: 64 }), surface('sound-card', sound?.card, 'card'),
3414
+ surface('sound', sound?.button, 'control', false, { right: 12, top: 64 }), { ...surface('sound-card', sound?.card, 'card'), beside: sound?.button, offControls: true },
2992
3415
  surface('actions', actionChips), surface('ask-card', askCard, 'card'),
2993
3416
  surface('menu', placeMenu?.sheet, 'card'), surface('text-ask', textAsk?.card, 'card'),
2994
3417
  surface('toast', toast, 'toast', true, { top: 12 }), surface('ribbon', ribbon, 'ribbon', true),
@@ -2996,8 +3419,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2996
3419
  surface('stats', stats, 'text', true, { right: 8, top: 8 }), surface('stuck', stuckChip, 'pointer', true),
2997
3420
  ...[...labelNodes].map(([id, node]) => ({ ...surface(`label:${id}`, node, 'label', true),
2998
3421
  // A role chip belongs under its name tag, and a place's tag (`hub.mark`) over a head,
2999
- // the viewer's own included; both are drawn over the viewer's body anyway.
3000
- ignoreObstacle: id.startsWith('role:') || id.startsWith('mark:') ? worldAvatar : null })),
3422
+ // the viewer's own included; both are drawn over the viewer's body anyway. So is
3423
+ // an NPC's line, Chirp's included, said from the viewer's shoulder.
3424
+ ignoreObstacle: id.startsWith('role:') || id.startsWith('mark:') || npcSpeech.has(id) ? worldAvatar : null, clamp: clampLabels.has(id), edge: npcSpeech.has(id) })),
3001
3425
  ...[...pointerNodes].map(([id, item]) => surface(`pointer:${id}`, item.chip, 'pointer', true)),
3002
3426
  ...externalEntries().map(([id, item]) => ({ ...surface(id, item.node, item.kind, item.kind === 'text'), ...item.placement, ...(id === 'engine-shift-lock' ? { stack: 4 } : {}) })),
3003
3427
  ...(actionOverflow?.surfaces?.() ?? []).map((node, i) => surface(`action-overflow:${i}`, node, 'control')),
@@ -3014,7 +3438,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
3014
3438
  for (const child of entry.reportNodes?.() ?? []) {geometry.register(child.node);}
3015
3439
  }
3016
3440
  if (worldLabelsDefault) {
3017
- worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry);
3441
+ worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry, (node) => safeLayout?.heldAct?.(node) ?? null);
3018
3442
  }
3019
3443
  if (safeInsets) {
3020
3444
  safeLayout = makeSafeLayout({ root, hud: () => hud, entries: surfaces, onLayout: () => {