castle-web-cli 0.4.239 → 0.4.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +163 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +6 -3
  16. package/dist/init.js +24 -2
  17. package/dist/platformDoc.js +2 -1
  18. package/dist/playPagePolicy.js +5 -1
  19. package/dist/resetLeaderboards.d.ts +8 -1
  20. package/dist/resetLeaderboards.js +43 -8
  21. package/dist/save-deck.d.ts +32 -2
  22. package/dist/save-deck.js +240 -39
  23. package/kits/base/CLAUDE.md +1 -1
  24. package/kits/base/castle.json +1 -1
  25. package/kits/base/sdk/README.md +174 -6
  26. package/kits/base/sdk/analytics.d.ts +8 -0
  27. package/kits/base/sdk/analytics.js +92 -0
  28. package/kits/base/sdk/castle.d.ts +5 -1
  29. package/kits/base/sdk/castle.js +2 -0
  30. package/kits/base/sdk/commands.d.ts +48 -0
  31. package/kits/base/sdk/commands.js +1 -0
  32. package/kits/base/sdk/debugConsole.d.ts +17 -0
  33. package/kits/base/sdk/debugConsole.js +154 -0
  34. package/kits/base/sdk/experiments.js +24 -1
  35. package/kits/base/sdk/hostRetry.d.ts +7 -0
  36. package/kits/base/sdk/hostRetry.js +57 -0
  37. package/kits/base/sdk/hub.d.ts +20 -2
  38. package/kits/base/sdk/hub.js +99 -13
  39. package/kits/base/sdk/multiplayer.d.ts +2 -0
  40. package/kits/base/sdk/multiplayer.js +168 -26
  41. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  42. package/kits/base/sdk/reconnectBudget.js +41 -1
  43. package/kits/base/sdk/runtime.js +36 -19
  44. package/kits/base/sdk/server/hub.d.ts +19 -0
  45. package/kits/base/sdk/server/hub.js +12 -0
  46. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  47. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  48. package/kits/base/sdk/server/wrapper.js +26 -1
  49. package/kits/base/sdk/transport.d.ts +2 -1
  50. package/kits/base/sdk/transport.js +35 -0
  51. package/kits/hub-game/CLAUDE.md +66 -19
  52. package/kits/hub-game/code/client/act.js +9 -6
  53. package/kits/hub-game/code/client/actCore.js +26 -6
  54. package/kits/hub-game/code/client/actGateLog.js +36 -0
  55. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  56. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  57. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  58. package/kits/hub-game/code/client/askSurface.js +85 -0
  59. package/kits/hub-game/code/client/askTree.js +51 -0
  60. package/kits/hub-game/code/client/attention.js +31 -6
  61. package/kits/hub-game/code/client/ballot.js +42 -5
  62. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  63. package/kits/hub-game/code/client/ballotTree.js +180 -0
  64. package/kits/hub-game/code/client/catchingUp.js +19 -0
  65. package/kits/hub-game/code/client/celebrate.js +66 -0
  66. package/kits/hub-game/code/client/chrome.js +473 -53
  67. package/kits/hub-game/code/client/companion.js +93 -23
  68. package/kits/hub-game/code/client/companionDress.js +1 -1
  69. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  70. package/kits/hub-game/code/client/cornerTree.js +83 -0
  71. package/kits/hub-game/code/client/decor.js +20 -11
  72. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  73. package/kits/hub-game/code/client/disguise.js +23 -0
  74. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  75. package/kits/hub-game/code/client/dockSurface.js +206 -0
  76. package/kits/hub-game/code/client/dockTree.js +232 -0
  77. package/kits/hub-game/code/client/earned.js +29 -0
  78. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  79. package/kits/hub-game/code/client/emoteTree.js +264 -0
  80. package/kits/hub-game/code/client/farAvatars.js +4 -3
  81. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  82. package/kits/hub-game/code/client/grab.js +121 -50
  83. package/kits/hub-game/code/client/holdShow.js +19 -0
  84. package/kits/hub-game/code/client/hookLayer.js +96 -12
  85. package/kits/hub-game/code/client/hubControls.js +7 -1
  86. package/kits/hub-game/code/client/hudSurface.js +11 -3
  87. package/kits/hub-game/code/client/hudTree.js +7 -4
  88. package/kits/hub-game/code/client/idle.js +21 -3
  89. package/kits/hub-game/code/client/invites.js +24 -3
  90. package/kits/hub-game/code/client/keys.js +15 -0
  91. package/kits/hub-game/code/client/labelsNear.js +8 -1
  92. package/kits/hub-game/code/client/layoutCache.js +57 -8
  93. package/kits/hub-game/code/client/loadingCover.js +53 -4
  94. package/kits/hub-game/code/client/menuIcons.js +15 -0
  95. package/kits/hub-game/code/client/menuSurface.js +102 -0
  96. package/kits/hub-game/code/client/menuTree.js +135 -0
  97. package/kits/hub-game/code/client/modelLook.js +41 -0
  98. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  99. package/kits/hub-game/code/client/pickerTree.js +163 -0
  100. package/kits/hub-game/code/client/pushVisit.js +4 -2
  101. package/kits/hub-game/code/client/quality.js +188 -29
  102. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  103. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  104. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  105. package/kits/hub-game/code/client/rehello.js +75 -0
  106. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  107. package/kits/hub-game/code/client/replay.js +118 -0
  108. package/kits/hub-game/code/client/role.js +3 -0
  109. package/kits/hub-game/code/client/safeLayout.js +441 -56
  110. package/kits/hub-game/code/client/safeStyle.js +13 -10
  111. package/kits/hub-game/code/client/say.js +2 -0
  112. package/kits/hub-game/code/client/soundSurface.js +77 -0
  113. package/kits/hub-game/code/client/soundTree.js +74 -0
  114. package/kits/hub-game/code/client/soundscape.js +12 -9
  115. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  116. package/kits/hub-game/code/client/state.js +67 -1
  117. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  118. package/kits/hub-game/code/client/stuckTree.js +67 -0
  119. package/kits/hub-game/code/client/talk.js +42 -12
  120. package/kits/hub-game/code/client/talkTree.js +4 -2
  121. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  122. package/kits/hub-game/code/client/textAskTree.js +67 -0
  123. package/kits/hub-game/code/client/tiers.js +252 -27
  124. package/kits/hub-game/code/client/together.js +4 -1
  125. package/kits/hub-game/code/client/uiDom.js +86 -8
  126. package/kits/hub-game/code/client/uiTree.js +33 -4
  127. package/kits/hub-game/code/client/vehicle.js +72 -51
  128. package/kits/hub-game/code/client/weakestTier.js +75 -31
  129. package/kits/hub-game/code/client/wear.js +159 -5
  130. package/kits/hub-game/code/client/worldLabels.js +205 -25
  131. package/kits/hub-game/code/companionSpec.js +4 -2
  132. package/kits/hub-game/code/server/act.js +3 -0
  133. package/kits/hub-game/code/server/actGate.js +83 -0
  134. package/kits/hub-game/code/server/actions.js +71 -15
  135. package/kits/hub-game/code/server/actors.js +20 -5
  136. package/kits/hub-game/code/server/analytics.js +35 -3
  137. package/kits/hub-game/code/server/ask.js +39 -3
  138. package/kits/hub-game/code/server/ballot.js +167 -4
  139. package/kits/hub-game/code/server/celebrate.js +64 -0
  140. package/kits/hub-game/code/server/companion.js +17 -2
  141. package/kits/hub-game/code/server/decor.js +11 -2
  142. package/kits/hub-game/code/server/disguise.js +63 -0
  143. package/kits/hub-game/code/server/earned.js +6 -2
  144. package/kits/hub-game/code/server/friendBests.js +13 -4
  145. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  146. package/kits/hub-game/code/server/grab.js +12 -2
  147. package/kits/hub-game/code/server/heldOffers.js +142 -0
  148. package/kits/hub-game/code/server/holdShow.js +98 -0
  149. package/kits/hub-game/code/server/hub.js +851 -45
  150. package/kits/hub-game/code/server/idle.js +110 -9
  151. package/kits/hub-game/code/server/index.js +9 -0
  152. package/kits/hub-game/code/server/labels.js +13 -3
  153. package/kits/hub-game/code/server/manifest.js +94 -6
  154. package/kits/hub-game/code/server/menu.js +26 -3
  155. package/kits/hub-game/code/server/npcs.js +55 -9
  156. package/kits/hub-game/code/server/observe.js +67 -6
  157. package/kits/hub-game/code/server/players.js +8 -1
  158. package/kits/hub-game/code/server/replay.js +135 -0
  159. package/kits/hub-game/code/server/storageLimit.js +4 -1
  160. package/kits/hub-game/code/server/townDay.js +74 -0
  161. package/kits/hub-game/code/server/vehicle.js +3 -0
  162. package/kits/hub-game/code/server/vis.js +26 -4
  163. package/kits/hub-game/code/server/wallet.js +677 -0
  164. package/kits/hub-game/code/server/wear.js +13 -3
  165. package/kits/hub-game/code/server/writerLease.js +191 -0
  166. package/kits/hub-game/code/shared/act.js +1 -1
  167. package/kits/hub-game/code/shared/expression.js +6 -0
  168. package/kits/hub-game/code/shared/replay.js +37 -0
  169. package/kits/hub-game/code/systems/hub.js +427 -54
  170. package/kits/hub-game/docs/analytics.md +16 -2
  171. package/kits/hub-game/docs/contract.md +942 -99
  172. package/kits/hub-game/docs/home-pieces.md +5 -6
  173. package/kits/hub-game/docs/observed-progress.md +49 -1
  174. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  175. package/kits/hub-game/index.html +1 -0
  176. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  177. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  178. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  179. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  180. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  181. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  182. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  183. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  184. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  185. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  186. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  187. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  188. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  189. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  190. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  200. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  201. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  202. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  203. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  204. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  205. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  206. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  207. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  208. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  209. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  210. package/kits/hub-game/package-lock.json +3 -3
  211. package/kits/hub-game/package.json +4 -3
  212. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  213. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  214. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  215. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  216. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  217. package/kits/hub-game/scripts/pack.mjs +89 -23
  218. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  219. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  220. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  221. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  222. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  223. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  224. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  225. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  226. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  227. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  228. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  229. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  230. package/kits/hub-game/scripts/test-analytics.mjs +79 -0
  231. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  232. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  233. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  234. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  235. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  236. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  237. package/kits/hub-game/scripts/test-ballot.mjs +420 -3
  238. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  239. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  240. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  241. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  242. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  243. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  244. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  245. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  246. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  247. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  248. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  249. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  250. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  251. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  252. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  253. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  254. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  255. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  256. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  257. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  258. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  259. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  260. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  261. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  262. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  263. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  264. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  265. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  266. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  267. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  268. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  269. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  270. package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
  271. package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
  272. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  273. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  274. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  275. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  276. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  277. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  278. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  279. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  280. package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
  281. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  282. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  283. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  284. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  285. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  286. package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
  287. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  288. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  289. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  290. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  291. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  292. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  293. package/kits/hub-game/scripts/test-rehello.mjs +237 -0
  294. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  295. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  296. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  297. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  298. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  299. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  300. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  301. package/kits/hub-game/scripts/test-role-client.mjs +2 -1
  302. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  303. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  304. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  305. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  306. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  307. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  308. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  309. package/kits/hub-game/scripts/test-stuck.mjs +31 -0
  310. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  311. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  312. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  313. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  314. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  315. package/kits/hub-game/scripts/test-together.mjs +11 -0
  316. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  317. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  318. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  319. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  320. package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
  321. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  322. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  323. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  324. package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
  325. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  326. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  327. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  328. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  329. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  330. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
  331. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
  332. package/kits/multiplayer-3d/castle.json +5 -5
  333. package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
  334. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  335. package/kits/multiplayer-3d/code/server/world.js +19 -4
  336. package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
  337. package/kits/multiplayer-3d/package-lock.json +1 -1
  338. package/kits/multiplayer-3d/package.json +2 -1
  339. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  340. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  341. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  342. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
  343. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  344. package/kits/physics-2d/castle.json +2 -2
  345. package/kits/physics-2d/engine/scene.js +10 -2
  346. package/kits/physics-3d/CLAUDE.md +14 -0
  347. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  348. package/kits/physics-3d/castle.json +3 -3
  349. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  350. package/kits/physics-3d/docs/engine-player.md +76 -0
  351. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  352. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  353. package/kits/physics-3d/engine3d/gait.js +16 -8
  354. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  355. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  356. package/kits/physics-3d/engine3d/look.js +110 -17
  357. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  358. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  359. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  360. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  361. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  362. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  363. package/kits/physics-3d/engine3d/optimize.js +20 -9
  364. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  365. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  366. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  367. package/kits/physics-3d/engine3d/world3d.js +211 -17
  368. package/kits/physics-3d/package-lock.json +1 -1
  369. package/kits/physics-3d/package.json +2 -1
  370. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  371. package/kits/physics-3d/scripts/render.mjs +56 -8
  372. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  373. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  374. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  375. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  376. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  377. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  378. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  379. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  380. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  381. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  382. package/kits/physics-3d/systems/physics3d.js +51 -2
  383. package/kits/real-time/castle.json +2 -2
  384. package/kits/real-time/code/client/connection.js +3 -0
  385. package/package.json +2 -2
  386. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -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
@@ -247,6 +291,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
247
291
  return true;
248
292
  }
249
293
 
294
+ let winRibbons = null;
250
295
  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
296
 
252
297
  // The HUD root's toast, drawn over the ribbon (its layer was always here).
@@ -257,8 +302,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
257
302
  const toastStart = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '0', width: '0', height: '0', visibility: 'hidden' }, root);
258
303
  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
304
  let toastChoiceBlocked = false;
305
+ // No row of the view is clear of the controls: the toast is not drawn
306
+ // until one is, by the rule the caption lanes carry.
307
+ let toastNoRow = false;
260
308
  function syncToastVisibility() {
261
- const visibility = toastChoiceBlocked || pickerOpen ? 'hidden' : '';
309
+ const visibility = toastChoiceBlocked || toastNoRow || pickerOpen ? 'hidden' : '';
262
310
  if (toast.style.visibility !== visibility) {toast.style.visibility = visibility;}
263
311
  }
264
312
 
@@ -299,6 +347,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
299
347
  companionLockVisibility = null;
300
348
  }
301
349
  let pickerFitKey = '', pickerCompact = false;
350
+ // The dock is out of sight under the compact picker strip, and where it
351
+ // was raised (`raiseDock`) while the Sound card stands beside its button
352
+ // over it (with safeInsets, while the card is open).
353
+ let dockHigh = false, soundAside = false, soundOpen = false;
354
+ const syncDockVisibility = () => {dock.style.visibility = pickerCompact && pickerOpen || dockHigh && (soundAside || safeInsets && soundOpen) ? 'hidden' : '';};
302
355
  // The card is a sheet fitted to the viewport: over the right-side lane above
303
356
  // the button, or, on a phone on its side with no room there for the whole
304
357
  // sheet, one strip of whole tiles along the bottom with its own Close. Open,
@@ -336,7 +389,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
336
389
  Object.assign(button.style, { scrollSnapAlign: compact ? 'start' : '', scrollSnapStop: compact ? 'always' : '', touchAction: compact ? 'pan-x' : 'pan-y' });
337
390
  }
338
391
  pickerToggle.style.visibility = compact && pickerOpen ? 'hidden' : '';
339
- dock.style.visibility = compact && pickerOpen ? 'hidden' : '';
392
+ syncDockVisibility();
340
393
  if (compact && pickerOpen && companionLock) {
341
394
  if (companionLockVisibility === null) {companionLockVisibility = companionLock.style.visibility ?? '';}
342
395
  companionLock.style.visibility = 'hidden';
@@ -470,6 +523,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
470
523
  // Talking to an NPC: a button when one is near, and a panel while a
471
524
  // conversation is open. Keys typed here are the panel's, not the game's.
472
525
  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);
526
+ talkButton.setAttribute('data-hub', 'talk-button');
473
527
  overPicker.push(talkButton);
474
528
  talkButton.addEventListener('pointerdown', (event) => {
475
529
  event.stopPropagation();
@@ -484,11 +538,37 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
484
538
  // A desktop keyboard (a fine pointer and no touch) gets the field focused
485
539
  // as it appears; a phone keeps its keyboard down until a tap.
486
540
  const autoFocusField = () => Boolean(globalThis.matchMedia?.('(pointer: fine)').matches && !(globalThis.navigator?.maxTouchPoints > 0));
541
+ // A field focused that way does not take the movement keys until the player
542
+ // types in it or points at it (the first visit's greeter opens on arrival,
543
+ // and nobody is held): while it is empty, W, A, S, D, the arrows and Space
544
+ // go on to the game, unentered, and the field is not typing. Any other key
545
+ // is the field's, as before.
546
+ let fieldWalks = false;
547
+ let autoArm = false;
548
+ const autoFocusTalk = () => {
549
+ autoArm = autoFocusField();
550
+ return autoArm;
551
+ };
552
+ const fieldWalking = (input) => fieldWalks && input.value === '';
553
+ const passWalkKey = (input, event) => {
554
+ if (input !== panelInput()) {return false;}
555
+ if (walkRelease(event)) {return true;}
556
+ if (event.type !== 'keydown' || !fieldWalking(input) || !walkKey(event)) {return false;}
557
+ event.preventDefault?.();
558
+ return true;
559
+ };
487
560
  const talkDom = mountUiTree(root, {
488
561
  measure: geometry,
562
+ passKey: passWalkKey,
489
563
  created(path, node) {
490
564
  if (path === 'talk/panel/log') {geometry.register(node, { scroll: true });}
491
565
  else if (path === 'talk/panel' || path === 'talk/panel/asks' || path.startsWith('talk/panel/log/l')) {geometry.register(node);}
566
+ else if (path === 'talk/panel/form/say') {
567
+ node.addEventListener('focus', () => {fieldWalks = autoArm;});
568
+ for (const type of ['input', 'pointerdown', 'blur']) {
569
+ node.addEventListener(type, () => {fieldWalks = false;});
570
+ }
571
+ }
492
572
  },
493
573
  removed: (path, node) => geometry.unregister(node),
494
574
  });
@@ -507,7 +587,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
507
587
  const panelInput = () => talkDom.nodeFor('talk/panel/form/say');
508
588
  const talkSurface = makeTalkSurface({
509
589
  view: () => ({ landscape: landscapeViewport(), desktop: desktop(), w: geometry.view().w, safeInsets }),
510
- autoFocus: autoFocusField,
590
+ autoFocus: autoFocusTalk,
511
591
  onChip,
512
592
  draftNow: () => (uiTreeDomEnabled() && panelInput() ? panelInput().value : talkSurface.state.field.value),
513
593
  afterChange(what) {
@@ -526,9 +606,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
526
606
  },
527
607
  draw(tree) {
528
608
  if (uiTreeDomEnabled() || !talkDom.nodeFor('talk/panel')) {talkDom.render(tree);}
609
+ autoArm = false;
529
610
  },
530
611
  });
531
612
  const panel = talkDom.nodeFor('talk/panel');
613
+ panel.setAttribute?.('data-hub', 'talk-panel');
532
614
  const panelAsks = () => talkDom.nodeFor('talk/panel/asks');
533
615
 
534
616
  function syncHudPrompt() {
@@ -548,6 +630,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
548
630
  let grabHandler = () => {};
549
631
  let hornHandler = null;
550
632
  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);
633
+ grabButton.setAttribute('data-hub', 'grab-button');
551
634
  grabButton.addEventListener('pointerdown', (event) => {
552
635
  event.stopPropagation();
553
636
  event.preventDefault();
@@ -579,6 +662,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
579
662
  event.stopPropagation();
580
663
  event.preventDefault();
581
664
  setEmotesOpen(!emotesOpen);
665
+ // safeLayout places an opened card now, not on its next pass: until then
666
+ // it stands where the portrait corner puts it, off a small view's edge.
667
+ if (emotesOpen && safeInsets) {safeLayout?.flush();}
582
668
  });
583
669
  emoteButton.addEventListener('click', (event) => {
584
670
  if (expressionEmotes && event.detail === 0) { setEmotesOpen(!emotesOpen); }
@@ -608,6 +694,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
608
694
  event.preventDefault();
609
695
  setSayOpen(!sayOpen);
610
696
  setEmotesOpen(false);
697
+ if (sayOpen && safeInsets) {safeLayout?.flush();}
611
698
  });
612
699
  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
700
  let feedKey = '';
@@ -621,10 +708,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
621
708
 
622
709
  // Bottom left: the town's Doors, then People, side by side -- or People
623
710
  // 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);
711
+ // Never narrower than its widest button (a 179px view's max width is 49px).
712
+ 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
713
  // A list opens just above the dock, however tall the dock is.
626
714
  const aboveDock = (list) => {
627
- if (landscapeViewport()) {
715
+ if (landscapeViewport() || dockHigh) {
628
716
  list.style.bottom = '';
629
717
  const top = `max(68px, env(safe-area-inset-top) + 56px) + ${geometry.size(dock).h + 6}px`;
630
718
  list.style.top = `calc(${top})`;
@@ -856,7 +944,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
856
944
  const wide = desktop() && !landscapeViewport();
857
945
  const width = geometry.size(toast).w;
858
946
  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);
947
+ 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
948
  if (stuckSpot) {
861
949
  rects.push(stuckSpot);
862
950
  }
@@ -868,6 +956,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
868
956
  const left = (geometry.view().w - width) / 2;
869
957
  const blocked = choices && left < choices.right && left + width > choices.left && top < choices.bottom && top + height > choices.top;
870
958
  toastChoiceBlocked = Boolean(blocked);
959
+ toastNoRow = rects.some((r) => left < r.right && left + width > r.left && top < r.bottom && top + height > r.top);
871
960
  syncToastVisibility();
872
961
  const nextTop = wide ? '' : `${band.top}px`;
873
962
  const nextBottom = wide ? `${band.bottom}px` : '';
@@ -949,6 +1038,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
949
1038
  event.preventDefault();
950
1039
  made.open = !made.open;
951
1040
  card.style.display = made.open ? 'flex' : 'none';
1041
+ soundOpen = made.open;
1042
+ syncDockVisibility();
952
1043
  layoutLandscapeRail();
953
1044
  });
954
1045
  mute.addEventListener('pointerdown', (event) => {
@@ -985,6 +1076,85 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
985
1076
  hudClearKey = '';
986
1077
  hudClearPending.clear();
987
1078
  }
1079
+ // The HUD's lane in a small view (a game on castle.xyz in a short desktop
1080
+ // window draws a 179x250 view): the centred HUD would lie under the
1081
+ // right-edge controls (Quick chat, Emote, Grab, Sound), which a short view
1082
+ // stacks up to the top. It is laid out instead in the lane left of them,
1083
+ // right of a Back at the top, and its big line is drawn on one line at the
1084
+ // size that fits there. Only the frame's snapshot is read: when the HUD's
1085
+ // words, the view or those controls change it goes back to its centred
1086
+ // place, and the next frame lays it out again from there; one that has
1087
+ // grown taller onto another control is narrowed again the same way.
1088
+ // Nothing is written where the centred HUD is clear. `hub.safeInsets`
1089
+ // lays the HUD out itself (`safeLayout.js`).
1090
+ let hudLaneKey = '';
1091
+ let hudLaneWritten = null;
1092
+ const HUD_LANE_BIG = ['whiteSpace', 'overflow', 'textOverflow', 'fontSize', 'maxWidth'];
1093
+ function restoreHudLane() {
1094
+ if (!hudLaneWritten) {return;}
1095
+ hud.style.maxWidth = hudLaneWritten.maxWidth;
1096
+ hud.style.translate = '';
1097
+ // A clear HUD (v1.26) owns its big line's styles; they are put back only
1098
+ // where this wrote them.
1099
+ for (const key of HUD_LANE_BIG) {
1100
+ if (hudLaneWritten.big[key] !== undefined && hudBig.style[key] === hudLaneWritten.wrote[key]) {hudBig.style[key] = hudLaneWritten.big[key];}
1101
+ }
1102
+ hudLaneWritten = null;
1103
+ }
1104
+ function writeHudBig(key, value) {
1105
+ if (hudBig.style[key] === value) {return;}
1106
+ if (!(key in hudLaneWritten.big)) {hudLaneWritten.big[key] = hudBig.style[key];}
1107
+ hudBig.style[key] = value;
1108
+ hudLaneWritten.wrote[key] = hudBig.style[key];
1109
+ }
1110
+ function layoutHudLane() {
1111
+ if (safeInsets) {return;}
1112
+ const shown = hud.style.display !== 'none' && hud.isConnected !== false;
1113
+ const view = geometry.view();
1114
+ const column = [sayButton, emoteButton, grabButton, sound?.button]
1115
+ .filter((node) => node && node.style.display !== 'none').map((node) => geometry.rect(node)).filter((box) => box.width > 0 && box.height > 0);
1116
+ const backBox = back.style.display !== 'none' ? geometry.rect(back) : null;
1117
+ const key = shown ? [hudTitle.textContent, hudBig.textContent.length, view.w, view.h,
1118
+ ...[...column, ...(backBox ? [backBox] : [])].flatMap((box) => [box.left, box.top, box.right, box.bottom])].join('\u0001') : '';
1119
+ if (key !== hudLaneKey) {
1120
+ hudLaneKey = key;
1121
+ restoreHudLane();
1122
+ return;
1123
+ }
1124
+ if (!shown) {return;}
1125
+ const drawn = geometry.rect(hud);
1126
+ const hits = drawn.width > 0 ? column.filter((other) => overlaps(drawn, other)) : [];
1127
+ if (hits.length) {
1128
+ const left = backBox && backBox.width > 0 && backBox.top < drawn.bottom && backBox.left < view.w / 2 ? backBox.right + 8 : 8;
1129
+ const width = Math.min(...hits.map((other) => other.left)) - 8 - left;
1130
+ if (width >= HUD_LANE_MIN && (!hudLaneWritten || width < hudLaneWritten.width)) {
1131
+ hudLaneWritten ??= { maxWidth: hud.style.maxWidth, big: {}, wrote: {} };
1132
+ hudLaneWritten.width = width;
1133
+ hud.style.maxWidth = `${width}px`;
1134
+ // The HUD is centred on the view; centre it on the lane instead.
1135
+ hud.style.translate = `${Math.round(left + width / 2 - view.w / 2)}px 0px`;
1136
+ if (!hudClear) {
1137
+ writeHudBig('whiteSpace', 'nowrap');
1138
+ writeHudBig('overflow', 'hidden');
1139
+ writeHudBig('textOverflow', 'ellipsis');
1140
+ }
1141
+ }
1142
+ }
1143
+ if (!hudLaneWritten || !hudBig.textContent) {return;}
1144
+ // The clear HUD's one-line big line keeps to the lane; either way the
1145
+ // line is drawn at the size that fits it, from the frame's measure.
1146
+ if (hudClear && hudBig.style.maxWidth.endsWith('px') && Number.parseFloat(hudBig.style.maxWidth) > hudLaneWritten.width) {
1147
+ writeHudBig('maxWidth', `${hudLaneWritten.width}px`);
1148
+ }
1149
+ if (!hudClear) {
1150
+ const fit = geometry.fit(hudBig);
1151
+ if (fit.text === hudBig.textContent && (fit.fontSize === hudBig.style.fontSize || !hudBig.style.fontSize)) {
1152
+ const base = Number.parseFloat(fit.fontSize) || 56;
1153
+ const px = fitPx(base, fit.client, fit.scroll);
1154
+ if (px < base) {writeHudBig('fontSize', `${px}px`);}
1155
+ }
1156
+ }
1157
+ }
988
1158
  function layoutHudClear(big, text) {
989
1159
  hudClearDrawn = true;
990
1160
  const backShown = back.style.display !== 'none';
@@ -1053,6 +1223,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1053
1223
  }
1054
1224
  const moves = [];
1055
1225
  for (const [group, entries] of groups) {
1226
+ // The world layout already placed pointers clear of the HUD, the prompt
1227
+ // and every control; moving one again here lifts it onto a control.
1228
+ if (worldLayout && group === 'pointers') {continue;}
1056
1229
  for (const [node, x, y, anchor] of entries) {
1057
1230
  // One since hidden or taken away is left alone.
1058
1231
  if (!node || node.style.display === 'none' || !Number.isFinite(x) || !Number.isFinite(y)) {
@@ -1113,46 +1286,153 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1113
1286
  const menuCovered = new Set();
1114
1287
  const railNodes = [picker, grabButton, emoteButton, sayButton, sitButton, talkButton, nearButton];
1115
1288
  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;
1289
+ // A portrait view too short for the corner column (a game on castle.xyz in
1290
+ // a short desktop window, 219x290): Quick chat and Emote, placed from the
1291
+ // bottom, reach up onto Sound and the native corner. The corner's buttons
1292
+ // take the rail there instead, wrapping into another column under the
1293
+ // ceiling; the centred pills stay where portrait puts them. A taller view
1294
+ // gets the portrait corner back as it was.
1295
+ let portraitRail = false;
1296
+ // A short portrait rail with no room beside the Doors dock (179x250)
1297
+ // moves the dock to its landscape place, under the host's corner.
1298
+ function raiseDock(on) {
1299
+ if (on === dockHigh) {return;}
1300
+ dockHigh = on;
1301
+ 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))' });
1302
+ for (const list of [doorsList, peopleList]) {aboveDock(list);}
1303
+ syncDockVisibility();
1304
+ }
1305
+ // The dock's buttons as they stand at the bottom left, wherever it is now
1306
+ // (a wide label overflows the dock's own box). `dockFloor` is where the
1307
+ // dock's bottom edge stands lowered, safe-area inset included.
1308
+ const dockFloor = el('div', { position: 'absolute', bottom: 'max(10px, env(safe-area-inset-bottom))', left: '0', width: '0', height: '0', visibility: 'hidden' }, root);
1309
+ function dockAtBottom() {
1310
+ const boxes = [...dock.children].map(shownRect).filter(Boolean);
1311
+ if (!boxes.length || pickerCompact && pickerOpen) {return null;}
1312
+ 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)) };
1313
+ const drop = dockHigh ? geometry.rect(dockFloor).bottom - box.bottom : 0;
1314
+ return { ...box, top: box.top + drop, bottom: box.bottom + drop };
1315
+ }
1316
+ const portraitPills = new Set([sitButton, talkButton, nearButton]);
1317
+ const railCeiling = (card = shownRect(sound?.card)) => Math.max(
1318
+ safeInsets ? 108 + (safeLayout?.view().insets.top ?? 0) : Math.max(64, Math.min(geometry.view().h - 44, 76)),
1319
+ shownRect(sound?.button)?.bottom + 6 || 0,
1320
+ card?.bottom + 6 || 0,
1321
+ );
1322
+ const shortPortrait = () => geometry.view().h - PORTRAIT_COLUMN_TOP - lockLift < railCeiling();
1323
+ function restorePortraitCorner() {
1324
+ picker.style.right = edge('right', 10);
1325
+ grabButton.style.right = edge('right', 14);
1326
+ for (const node of [emoteButton, sayButton]) {node.style.right = edge('right', 20);}
1327
+ for (const card of [emoteRow, sayCard]) {Object.assign(card.style, { right: edge('right', 80), maxHeight: '', overflowY: '', maxWidth: '', boxSizing: '', overflowX: '' });}
1328
+ for (const [node, bottom] of cornerBottoms) {node.style.bottom = lockLift ? `calc(${bottom} + ${lockLift}px)` : bottom;}
1329
+ if (actRail) {Object.assign(actRail.style, { right: edge('right', 14), bottom: 'max(60px, calc(env(safe-area-inset-bottom) + 50px))' });}
1330
+ soundBeside(false);
1331
+ raiseDock(false);
1332
+ }
1333
+ // An open Sound card the short portrait rail cannot fit under (179x250
1334
+ // with Shift lock) opens left of its button instead, level with its top
1335
+ // and fitted to the room there.
1336
+ function soundBeside(on) {
1337
+ if (!sound || on === soundAside) {return;}
1338
+ soundAside = on;
1339
+ syncDockVisibility();
1340
+ Object.assign(sound.card.style, on
1341
+ ? { top: soundTop, right: edge('right', 58), width: 'min(208px, calc(100vw - 66px))' }
1342
+ : { top: `calc(${soundTop} + 46px)`, right: edge('right', 12), width: 'min(70vw, 208px)' });
1343
+ }
1344
+ // The rail's columns, bottom up and wrapping leftwards under `ceiling`.
1345
+ // Shift lock lifts a column only where it stands under it: a short
1346
+ // portrait view's wrapped column left of the lock starts at the bottom.
1347
+ // A button that would stand on `navigation` (the Doors dock's box) stands
1348
+ // above it instead.
1349
+ // `fits` is false where a column rises over the ceiling or leaves the view.
1350
+ function layRail(ceiling, navigation = null) {
1351
+ const view = geometry.view();
1352
+ const lock = !landscape && lockLift ? shownRect(companionLock) : null;
1353
+ const lifted = 10 + lockLift;
1354
+ let base = lifted;
1355
+ let bottom = base;
1123
1356
  let right = 12;
1124
1357
  let columnWidth = 0;
1125
1358
  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
- );
1359
+ placed.fits = true;
1360
+ const clearOfDock = (node, at) => {
1361
+ const left = view.w - right - geometry.size(node).w;
1362
+ const top = view.h - at - railHeight(node);
1363
+ return navigation && navigation.right + 6 > left && top < navigation.bottom + 6 && view.h - at > navigation.top - 6
1364
+ ? view.h - navigation.top + 6 : at;
1365
+ };
1131
1366
  for (const node of railNodes) {
1132
- if (node.style.display === 'none' || node.style.visibility === 'hidden') {
1367
+ if (node.style.display === 'none' || node.style.visibility === 'hidden' || !landscape && portraitPills.has(node)) {
1133
1368
  continue;
1134
1369
  }
1135
1370
  const height = railHeight(node);
1136
- if (bottom > baseBottom && geometry.view().h - bottom - height < ceiling) {
1371
+ if (bottom > base && view.h - clearOfDock(node, bottom) - height < ceiling) {
1137
1372
  right += columnWidth + 6;
1138
- bottom = baseBottom;
1373
+ base = lock && lock.left >= view.w - right + 6 ? 10 : lifted;
1374
+ bottom = base;
1139
1375
  columnWidth = 0;
1140
1376
  }
1377
+ bottom = clearOfDock(node, bottom);
1141
1378
  node.style.right = safeInsets ? `calc(max(12px, env(safe-area-inset-right)) + ${right - 12}px)` : `${right}px`;
1142
1379
  node.style.bottom = `max(${bottom}px, calc(env(safe-area-inset-bottom) + ${Math.max(0, bottom - 10)}px))`;
1143
1380
  const width = geometry.size(node).w;
1144
1381
  placed.set(node, { right, bottom, width });
1382
+ if (view.h - bottom - height < ceiling || view.w - right - width < 6) {placed.fits = false;}
1145
1383
  columnWidth = Math.max(columnWidth, width);
1146
1384
  bottom += height + 6;
1147
1385
  }
1386
+ return placed;
1387
+ }
1388
+ function layoutLandscapeRail() {
1389
+ if (safeInsets) {return;}
1390
+ if (!landscape) {
1391
+ // The card's own place is not what makes a view short.
1392
+ soundBeside(false);
1393
+ if (!shortPortrait()) {
1394
+ if (portraitRail) {
1395
+ portraitRail = false;
1396
+ restorePortraitCorner();
1397
+ }
1398
+ return;
1399
+ }
1400
+ portraitRail = true;
1401
+ }
1402
+ // A short portrait rail keeps clear of the Doors dock at the bottom
1403
+ // left; one with no room for that moves the dock under the host's
1404
+ // corner. A rail that then ends up under the Sound card or off the left
1405
+ // edge is laid again with the card beside its button.
1406
+ const navigation = landscape ? null : dockAtBottom();
1407
+ if (!landscape) {raiseDock(Boolean(navigation) && !layRail(railCeiling(null), navigation).fits && layRail(railCeiling(null)).fits);}
1408
+ let placed = layRail(railCeiling(), dockHigh ? null : navigation);
1409
+ const card = shownRect(sound?.card);
1410
+ if (!landscape && card && !placed.fits) {
1411
+ soundBeside(true);
1412
+ const button = shownRect(sound.button);
1413
+ const h = card.bottom - card.top;
1414
+ placed = layRail(railCeiling({ bottom: Math.max(button.bottom, button.top + h) }), dockHigh ? null : navigation);
1415
+ }
1148
1416
  // Open pickers sit immediately left of the button that owns them, even
1149
1417
  // when the dense rail wrapped that button into its second column.
1150
1418
  for (const [card, button] of [[emoteRow, emoteButton], [sayCard, sayButton]]) {
1151
1419
  const at = placed.get(button);
1152
1420
  if (!at) {continue;}
1153
1421
  // 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`;
1422
+ // round button beside a 160px text action; a short portrait view has
1423
+ // no such lane and no room for one.
1424
+ const cardRight = landscape ? Math.max(184, at.right + at.width + 6) : at.right + at.width + 6;
1425
+ card.style.right = safeInsets ? `calc(max(12px, env(safe-area-inset-right)) + ${cardRight - 12}px)` : `${cardRight}px`;
1426
+ // A short portrait view fits the card on the side of its button with
1427
+ // more room (right of it, over the first column, when the button is in
1428
+ // a wrapped one), never over the button itself; it scrolls there.
1429
+ if (!landscape) {
1430
+ const viewW = geometry.view().w;
1431
+ const leftRoom = viewW - cardRight - 8, rightRoom = at.right - 14;
1432
+ const onRight = rightRoom > leftRoom;
1433
+ card.style.right = `${onRight ? 8 : cardRight}px`;
1434
+ Object.assign(card.style, { boxSizing: 'border-box', maxWidth: `${Math.max(0, onRight ? rightRoom : leftRoom)}px`, overflowX: 'auto' });
1435
+ }
1156
1436
  card.style.bottom = button.style.bottom;
1157
1437
  card.style.maxHeight = `calc(100dvh - ${at.bottom + 12}px - env(safe-area-inset-top) - env(safe-area-inset-bottom))`;
1158
1438
  card.style.overflowY = 'auto';
@@ -1173,12 +1453,19 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1173
1453
  const next = landscapeViewport();
1174
1454
  if (!force && next === landscape) {
1175
1455
  for (const list of [doorsList, peopleList]) {aboveDock(list);}
1176
- if (next) {layoutLandscapeRail();}
1456
+ layoutLandscapeRail();
1177
1457
  return;
1178
1458
  }
1179
1459
  landscape = next;
1460
+ if (portraitRail) {
1461
+ portraitRail = false;
1462
+ restorePortraitCorner();
1463
+ }
1464
+ dockHigh = false;
1465
+ syncDockVisibility();
1180
1466
  // Back clears the native exit corner; the HUD and toast narrow.
1181
1467
  hudSurface.setLandscape(landscape);
1468
+ hudSurface.setBackLow(backLow(shownBack.label));
1182
1469
  Object.assign(dock.style, landscape
1183
1470
  ? { top: 'max(68px, calc(env(safe-area-inset-top) + 56px))', bottom: '', maxWidth: 'min(24vw, 160px)' }
1184
1471
  : { top: '', bottom: 'max(10px, env(safe-area-inset-bottom))', maxWidth: 'calc(100vw - 130px)' });
@@ -1214,6 +1501,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1214
1501
  sitButton.style.bottom = 'max(112px, calc(env(safe-area-inset-bottom) + 102px))';
1215
1502
  talkButton.style.bottom = 'max(64px, calc(env(safe-area-inset-bottom) + 54px))';
1216
1503
  nearButton.style.bottom = 'max(160px, calc(env(safe-area-inset-bottom) + 150px))';
1504
+ portraitRail = false;
1217
1505
  }
1218
1506
  layoutPanel();
1219
1507
  layoutLandscapeRail();
@@ -1226,6 +1514,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1226
1514
  // of the untouched baseline, while an initially-landscape view is laid out.
1227
1515
  if (landscape) {
1228
1516
  applyViewportLayout(true);
1517
+ } else {
1518
+ layoutLandscapeRail();
1229
1519
  }
1230
1520
 
1231
1521
  // v1.75: only allocated for an opted-in prompt. The field is the only
@@ -1283,8 +1573,14 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1283
1573
  ...[...extraSurfaces.values()].filter((item) => item.kind === 'control').map((item) => item.node),
1284
1574
  ].filter((node) => node?.dataset);
1285
1575
  }
1576
+ // A host drawing its own covering sheet (the native UI tree menu) asks for
1577
+ // the same mask with `coverControls(true)`; the rule then sits in a style
1578
+ // element of its own, since no DOM sheet is open to carry it.
1579
+ let hostCover = null;
1580
+ // v1.204: the rule `setCatching` dims with, once one is needed.
1581
+ let catchingCss = null;
1286
1582
  function coverControls() {
1287
- if (!placeMenu?.covers) {return;}
1583
+ if (!placeMenu?.covers && !hostCover) {return;}
1288
1584
  for (const node of menuCoveredNodes()) {
1289
1585
  if (menuCovered.has(node) && node.dataset.hubMenuCovered !== undefined) {continue;}
1290
1586
  node.dataset.hubMenuCovered = '';
@@ -1292,10 +1588,29 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1292
1588
  }
1293
1589
  }
1294
1590
  function uncoverControls() {
1295
- if (!menuCovered.size) {return;}
1591
+ if (hostCover || !menuCovered.size) {return;}
1296
1592
  for (const node of menuCovered) {delete node.dataset.hubMenuCovered;}
1297
1593
  menuCovered.clear();
1298
1594
  }
1595
+ // A tile label's longest word ("Firefighter") shrinks to the tile's width
1596
+ // instead of breaking mid-word. Each word is measured once at 12px in the
1597
+ // sheet's own font; the tile is an inline-size container, so the font
1598
+ // follows the tile through a resize. Without container units the
1599
+ // assignment is dropped and 12px stays.
1600
+ function fitTileLabels(sheet, labels) {
1601
+ // All probes go in before any read and every label is written after the
1602
+ // last, so opening a sheet costs one layout, not one per tile.
1603
+ const probes = labels.map(({ word }) => {
1604
+ const probe = el('span', { position: 'absolute', visibility: 'hidden', whiteSpace: 'nowrap', fontSize: '12px' }, sheet);
1605
+ probe.textContent = word;
1606
+ return probe;
1607
+ });
1608
+ const widths = probes.map((probe, i) => probe.offsetWidth || [...labels[i].word].length * 7.5);
1609
+ for (const probe of probes) {probe.remove();}
1610
+ labels.forEach(({ label }, i) => {
1611
+ label.style.fontSize = `clamp(8px, calc(100cqi * ${(11.6 / Math.max(1, widths[i])).toFixed(4)}), 12px)`;
1612
+ });
1613
+ }
1299
1614
  function setMenu(offer, handler, onOpen) {
1300
1615
  if (!offer) { closeMenu(); return; }
1301
1616
  if (placeMenu && offer.n <= placeMenu.n) {return;}
@@ -1313,10 +1628,13 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1313
1628
  placeMenu.covers = rows && !Object.hasOwn(spec, 'face');
1314
1629
  if (Object.hasOwn(spec, 'face')) {placeMenu.face = spec.face;}
1315
1630
  const height = Object.hasOwn(spec, 'face') ? 40 : 55;
1631
+ // A short view keeps a row of choices: never under SHORT_PX (menuTree.js), short of the view.
1632
+ const floor = Object.hasOwn(spec, 'face') ? SHORT_FACE_PX : SHORT_PX;
1633
+ const cap = (unit) => (rows && !Object.hasOwn(spec, 'face') ? `calc(100${unit} - 24px)` : `min(max(${height}${unit}, ${floor}px), calc(100${unit} - 24px))`);
1316
1634
  const listeners = new AbortController(), signal = listeners.signal, timers = new Set();
1317
1635
  // The same column, padding, corners and shadow as the Doors/chat panels.
1318
1636
  // 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);
1637
+ 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
1638
  sheet.className = 'hub-menu-sheet';
1321
1639
  sheet.dataset.hub = 'menu';
1322
1640
  sheet.setAttribute('role', 'dialog');
@@ -1330,7 +1648,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1330
1648
  @media (prefers-reduced-motion: reduce) { .hub-menu-tile:not(:disabled):active, .hub-menu-tile.is-pressed { transform: none; } }
1331
1649
  @media (max-width: 600px) { .hub-menu-grid { grid-template-columns: repeat(4, minmax(64px, 1fr)) !important; } }
1332
1650
  @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; } }
1651
+ @supports (height: 1dvh) { .hub-menu-sheet { max-height: ${cap('dvh')} !important; } }
1334
1652
  ` + (placeMenu.covers ? ` ${MENU_COVERED_RULE}\n ` : '');
1335
1653
  for (const type of ['pointerdown', 'pointermove', 'pointerup', 'mousedown', 'wheel', 'contextmenu', 'keydown', 'keyup']) {
1336
1654
  sheet.addEventListener(type, (event) => event.stopPropagation(), { signal });
@@ -1360,12 +1678,13 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1360
1678
  drawMenuRows({ el, sheet, scroll, spec, signal, pick: (id) => { if (placeMenu?.sheet) { handler(id, offer.n); } } });
1361
1679
  }
1362
1680
  if (!rows) {
1681
+ const labels = [];
1363
1682
  for (const section of spec.sections) {
1364
1683
  el('div', { fontSize: '13px', margin: '8px 0', color: 'var(--castle-text-secondary, #fff)' }, scroll).textContent = section.title;
1365
1684
  const grid = el('div', { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(64px, 1fr))', gap: '8px' }, scroll);
1366
1685
  grid.className = 'hub-menu-grid';
1367
1686
  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);
1687
+ 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
1688
  tile.className = 'hub-menu-tile'; tile.type = 'button'; tile.disabled = spec.readOnly === true;
1370
1689
  tile.dataset.id = item.id;
1371
1690
  tile.setAttribute('aria-label', item.label);
@@ -1382,7 +1701,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1382
1701
  swatch.style.maskRepeat = swatch.style.webkitMaskRepeat = 'no-repeat';
1383
1702
  }
1384
1703
  swatch.setAttribute('aria-hidden', 'true');
1385
- el('span', { fontSize: '12px', lineHeight: '1.15', maxHeight: '2.3em', overflow: 'hidden' }, tile).textContent = item.label;
1704
+ const label = el('span', { fontSize: '12px', lineHeight: '1.15', maxHeight: '2.3em', overflow: 'hidden' }, tile);
1705
+ label.textContent = item.label;
1706
+ labels.push({ label, word: String(item.label ?? '').split(/\s+/).reduce((a, b) => ([...b].length > [...a].length ? b : a), '') });
1386
1707
  if (!tile.disabled) {
1387
1708
  tile.addEventListener('pointerdown', (event) => event.preventDefault(), { signal });
1388
1709
  tile.addEventListener('click', () => {
@@ -1396,6 +1717,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1396
1717
  }
1397
1718
  }
1398
1719
  }
1720
+ fitTileLabels(sheet, labels);
1399
1721
  }
1400
1722
  Object.assign(placeMenu, { sheet, css, listeners, timers, onOpen, cancel });
1401
1723
  coverControls();
@@ -1450,7 +1772,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1450
1772
  // Setters late in the frame may have queued HUD clearance; place it by
1451
1773
  // this frame's snapshot before the snapshot ends.
1452
1774
  flushHudClear();
1453
- if (placeMenu?.sheet) {coverControls();}
1775
+ if (placeMenu?.sheet || hostCover) {coverControls();}
1454
1776
  geometry.endFrame();
1455
1777
  for (const [key, node] of labelMeasures) {
1456
1778
  if (!usedLabelMeasures.has(key)) {node.remove(); labelMeasures.delete(key);}
@@ -1480,6 +1802,22 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1480
1802
  interactionRoot: () => root,
1481
1803
  // The Act/Jump pair's state and handlers (`act.js`), for the HUD root a
1482
1804
  // native host draws; the page's pair is drawn by `act.js` itself.
1805
+ // v1.204: dims the controls whose presses wait on a progress read (the
1806
+ // place's menu, text ask and action rail); the presses are refused by
1807
+ // their handlers. The Act pair dims itself (`act.js`).
1808
+ setCatching(on) {
1809
+ // Made at the first need, so a player who never catches up has the
1810
+ // chrome's layers exactly as before.
1811
+ if (on && !catchingCss) {
1812
+ catchingCss = el('style', {}, root);
1813
+ catchingCss.textContent = ['menu', 'text-ask', 'action-rail', 'decor', 'ballot', 'talk-button', 'talk-panel', 'grab-button']
1814
+ .map((hub) => `[data-hub-catching] [data-hub="${hub}"]`).join(', ') + ' { opacity: .5; }';
1815
+ }
1816
+ // On the document: the ballot sheet and decor layer live outside root.
1817
+ const marked = document.documentElement ?? root;
1818
+ if (on && marked.dataset.hubCatching === undefined) {marked.dataset.hubCatching = '';}
1819
+ else if (!on && marked.dataset.hubCatching !== undefined) {delete marked.dataset.hubCatching;}
1820
+ },
1483
1821
  setActPair(state) {
1484
1822
  hudSurface.setActPair(state);
1485
1823
  },
@@ -1495,7 +1833,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1495
1833
  },
1496
1834
  layoutInteractionRail() {
1497
1835
  if (!actRail) {return;}
1498
- if (landscape) {layoutLandscapeRail();}
1836
+ if (landscape || portraitRail) {layoutLandscapeRail();}
1499
1837
  else {Object.assign(actRail.style, { left: '', right: edge('right', 14), top: '', bottom: 'max(60px, calc(env(safe-area-inset-bottom) + 50px))' });}
1500
1838
  },
1501
1839
  setActMode: value => {
@@ -1509,7 +1847,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1509
1847
  worldLabelsDefault = on;
1510
1848
  // The root town retains its explicit near selection; its selected text
1511
1849
  // still needs the same final HUD/control/avatar clearance as doors.
1512
- worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry);
1850
+ worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry, (node) => safeLayout?.heldAct?.(node) ?? null);
1513
1851
  },
1514
1852
  // An avatar crossing the camera's near plane has no reliable screen box
1515
1853
  // (and may be hidden by the renderer's first-person view).
@@ -1522,9 +1860,21 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1522
1860
  },
1523
1861
  worldAvatar: () => worldAvatar,
1524
1862
  setWorldViewport: (area) => {worldViewport = area;},
1525
- beginWorldLabels: () => worldLayout?.begin(),
1863
+ beginWorldLabels: () => worldLayout?.begin(true),
1526
1864
  flushWorldLabels: () => worldLayout?.flush(),
1527
1865
  setMenu, clearMenu,
1866
+ coverControls(on) {
1867
+ if (!on === !hostCover) {return;}
1868
+ if (on) {
1869
+ hostCover = el('style', {}, root);
1870
+ hostCover.textContent = MENU_COVERED_RULE;
1871
+ coverControls();
1872
+ } else {
1873
+ hostCover.remove();
1874
+ hostCover = null;
1875
+ if (!placeMenu?.covers || !placeMenu.sheet) {uncoverControls();}
1876
+ }
1877
+ },
1528
1878
  cancelMenu: () => placeMenu?.cancel?.(),
1529
1879
  menuOpen: () => !!placeMenu?.sheet,
1530
1880
  menuFace: () => placeMenu?.sheet ? placeMenu.face : undefined,
@@ -1558,6 +1908,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1558
1908
  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
1909
  card.setAttribute('role', 'dialog');
1560
1910
  card.setAttribute('aria-label', spec.title);
1911
+ card.dataset.hub = 'text-ask';
1561
1912
  const place = () => {
1562
1913
  const view = window.visualViewport;
1563
1914
  // Stay in the visible viewport as the phone keyboard rises.
@@ -1605,8 +1956,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1605
1956
  return;
1606
1957
  }
1607
1958
  const text = cancelled ? null : input.value;
1959
+ // v1.204: an answer refused while catching up keeps the card and its text.
1960
+ if (handler(spec.id, spec.n, text) === false) {return;}
1608
1961
  closeTextAsk();
1609
- handler(spec.id, spec.n, text);
1610
1962
  };
1611
1963
  ok.addEventListener('click', () => answer(false), { signal });
1612
1964
  cancel.addEventListener('click', () => answer(true), { signal });
@@ -1647,7 +1999,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1647
1999
  }
1648
2000
  },
1649
2001
  showBack(show, label = 'Back') {
1650
- hudSurface.showBack(show, label);
2002
+ shownBack = { show, label };
2003
+ hudSurface.showBack(show, label, backLow(label));
1651
2004
  },
1652
2005
  setActions(items, handler, canAct, n, overflow = false, onOverflowOpen = () => {}) {
1653
2006
  if (safeInsets) {overflow = true;}
@@ -1671,6 +2024,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1671
2024
  root,
1672
2025
  ...(safeInsets ? { edgeMax: true, readSafeInsets: () => safeLayout.view().insets } : {}),
1673
2026
  obstacles: actionOverflowObstacles,
2027
+ // A prompt or act prompt the safe layout moved off a control (or
2028
+ // hid) is an obstacle at the place it held, so the rail settles
2029
+ // exactly as before.
2030
+ held: (node) => (node === hudText ? safeLayout?.heldPrompt?.() : safeLayout?.heldAct?.(node)) ?? null,
2031
+ transient: () => [[hudText, toast, stats, feed, ribbon], [hud]],
1674
2032
  reserved: ({ w, h, safe }) => [
1675
2033
  // The native exit target lives outside this document's DOM.
1676
2034
  { left: safe.left, right: safe.left + 64, top: safe.top, bottom: safe.top + 56 },
@@ -1690,7 +2048,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1690
2048
  });
1691
2049
  }
1692
2050
  syncActionSurfaces();
1693
- actionOverflow.set(items, handler, canAct, n);
2051
+ // Offers yield to open panels and sound their cue, as the legacy chips did.
2052
+ const onAction = (id, offerN) => {onChip?.(); handler?.(id, offerN);};
2053
+ actionOverflow.set(items, onAction, canAct && !pickerOpen && !sayOpen && !emotesOpen && !peopleOpen && !doorsOpen && !talkOpen, n);
1694
2054
  syncOverflowSources();
1695
2055
  return;
1696
2056
  }
@@ -1839,6 +2199,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1839
2199
  if (hudClear) {
1840
2200
  layoutHudClear(big, spec.text ?? '');
1841
2201
  }
2202
+ layoutHudLane();
1842
2203
  if (import.meta.env?.DEV) {
1843
2204
  warnHudCopy(hudTitle, 'subtitle');
1844
2205
  warnHudCopy(hudText, 'prompt', 1);
@@ -1889,7 +2250,11 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1889
2250
  node.textContent = text;
1890
2251
  labelMeasures.set(key, node);
1891
2252
  }
1892
- return geometry.size(node);
2253
+ // The drawn box, fractions included: the label is centred on its own
2254
+ // fractional width, so the whole-pixel `offsetWidth` placed it up to
2255
+ // half a pixel off (270 for 270.47). A node with no box keeps it.
2256
+ const drawn = geometry.dimensions(node);
2257
+ return drawn.w > 0 && drawn.h > 0 ? drawn : geometry.size(node);
1893
2258
  },
1894
2259
  // A owns only this lazy, noninteractive caption. The projected surface
1895
2260
  // participates in the shared registry but is placed last, yielding to
@@ -2031,8 +2396,12 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2031
2396
  let bands = null;
2032
2397
  // An emote put on its head: id -> the bottom it was put at.
2033
2398
  const emoteAt = new Map();
2399
+ clampLabels.clear();
2400
+ npcSpeech.clear();
2034
2401
  for (const item of items) {
2035
2402
  seen.add(item.id);
2403
+ if (item.box && !item.speech) {clampLabels.add(item.id);}
2404
+ if (item.speech && item.npc) {npcSpeech.add(item.id);}
2036
2405
  let node = labelNodes.get(item.id);
2037
2406
  if (!node) {
2038
2407
  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 +2550,21 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2181
2550
  // A board the player asked for is read whole, wherever they stand by it.
2182
2551
  cabinet.style.opacity = String(open ? 1 : item.opacity);
2183
2552
  },
2553
+ setWinRibbons(items) {
2554
+ if (!winRibbons && !items.length) {return;}
2555
+ winRibbons ??= [];
2556
+ while (winRibbons.length < Math.min(8, items.length)) {
2557
+ 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));
2558
+ }
2559
+ for (let i = 0; i < winRibbons.length; i++) {
2560
+ const node = winRibbons[i], item = items[i];
2561
+ node.style.display = item ? 'block' : 'none';
2562
+ if (!item) {continue;}
2563
+ node.style.left = `${item.x}px`; node.style.top = `${item.y}px`;
2564
+ node.textContent = item.text;
2565
+ }
2566
+ if (hudClear) {keepClearOfHud('win-ribbons', items.slice(0, winRibbons.length).map((item, i) => [winRibbons[i], item.x, item.y, 'bottom', item.text]));}
2567
+ },
2184
2568
  setRibbon(pos, text) {
2185
2569
  if (!pos) {
2186
2570
  ribbon.style.display = 'none';
@@ -2522,6 +2906,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2522
2906
  layoutLandscapeRail();
2523
2907
  } else {
2524
2908
  for (const [node, bottom] of cornerBottoms) {node.style.bottom = lift ? `calc(${bottom} + ${lift}px)` : bottom;}
2909
+ layoutLandscapeRail();
2525
2910
  }
2526
2911
  fitPicker(true);
2527
2912
  },
@@ -2565,8 +2950,10 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2565
2950
  this.companionTalkButton.style.left = `${screen.x}px`;
2566
2951
  this.companionTalkButton.style.top = `${screen.y}px`;
2567
2952
  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);
2953
+ // Never over a control: a tap there is the control's. The overflow
2954
+ // rail (and its sheet) is one too, so a follower walking under the
2955
+ // town counter's chips never takes their taps.
2956
+ const controls = [picker, grabButton, emoteButton, sayButton, talkButton, sitButton, sound?.button, back, hud, hudText, askCard, actionChips, ...(actionOverflow?.surfaces?.() ?? [])].map(shownRect).filter(Boolean);
2570
2957
  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
2958
  this.companionTalkButton.style.display = covers ? 'none' : 'block';
2572
2959
  },
@@ -2595,7 +2982,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2595
2982
  talkWaiting: talkSurface.talkWaiting,
2596
2983
  talkFocused() {
2597
2984
  const input = panelInput();
2598
- return uiTreeDomEnabled() && input ? document.activeElement === input : talkSurface.talkFocused();
2985
+ return uiTreeDomEnabled() && input ? document.activeElement === input && !fieldWalking(input) : talkSurface.talkFocused();
2599
2986
  },
2600
2987
  // `doors` is [{ id, title }] to offer, or null for none; `goText` is the
2601
2988
  // word on each one's button ("Go", or "Go together" in a party). `stuck`
@@ -2723,10 +3110,18 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2723
3110
  const seen = new Set();
2724
3111
  // The round buttons an edge chip is kept beside, never under (v1.38: a
2725
3112
  // 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)
3113
+ // Read once a call, and only when there is an edge chip. The Act/Jump
3114
+ // pair and a shown Character button stand in that column too: a chip
3115
+ // left on the pair was pushed down by the safe layout onto chat. A
3116
+ // shown Sit / Stand button (low in the middle, where a chip on the
3117
+ // bottom edge lies, or in the landscape rail) is kept off apart, after
3118
+ // the column: a chip that does not touch it is placed as before.
3119
+ const character = picker.style.display !== 'none' && pickerToggle.style.visibility !== 'hidden' ? pickerToggle : null;
3120
+ const anyEdge = items.some((item) => item.angle !== null && item.angle !== undefined);
3121
+ const buttons = anyEdge
3122
+ ? [sayButton, emoteButton, grabButton, sound?.button, actRail, character].map(shownRect).filter(Boolean)
2729
3123
  : [];
3124
+ const sit = anyEdge ? shownRect(sitButton) : null;
2730
3125
  for (const item of items) {
2731
3126
  seen.add(item.id);
2732
3127
  let node = pointerNodes.get(item.id);
@@ -2775,6 +3170,25 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2775
3170
  }
2776
3171
  }
2777
3172
  }
3173
+ if (edge && sit) {
3174
+ // Off Sit by the column's rule for Sit alone: to its left, else over
3175
+ // it, else under it. Each place is taken only when it is clear of
3176
+ // every column button too (the same overlap test as above), so the
3177
+ // move never lands on one; with none clear the chip keeps the
3178
+ // column's place.
3179
+ const tall = size.h / 2;
3180
+ const on = (r, cx, cy) => cx + half > r.left - 4 && cx - half < r.right + 4 && cy + tall > r.top && cy - tall < r.bottom;
3181
+ if (on(sit, x, y)) {
3182
+ const left = sit.left - 6 - half, over = sit.top - 6 - tall;
3183
+ const places = [
3184
+ ...(left >= half + 6 ? [[left, y]] : []),
3185
+ ...(over >= tall + 6 ? [[x, over]] : []),
3186
+ [x, sit.bottom + 6 + tall],
3187
+ ];
3188
+ const clear = places.find(([cx, cy]) => !buttons.some((r) => on(r, cx, cy)));
3189
+ if (clear) {[x, y] = clear;}
3190
+ }
3191
+ }
2778
3192
  if (node.chip.style.left !== `${x}px`) {node.chip.style.left = `${x}px`;}
2779
3193
  if (node.chip.style.top !== `${y}px`) {node.chip.style.top = `${y}px`;}
2780
3194
  node.y = y;
@@ -2908,8 +3322,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2908
3322
  sound.key = key;
2909
3323
  sound.muted = muted;
2910
3324
  if (!show) {
2911
- sound.open = false;
3325
+ sound.open = soundOpen = false;
2912
3326
  sound.card.style.display = 'none';
3327
+ syncDockVisibility();
2913
3328
  }
2914
3329
  sound.button.style.display = show ? 'block' : 'none';
2915
3330
  // Under the frame-rate readout where that is up (`?hubstats`).
@@ -2937,9 +3352,12 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2937
3352
  }
2938
3353
  },
2939
3354
  dispose() {
3355
+ // v1.204: the dim marker is on the document, outside root.
3356
+ if (catchingCss) {delete (document.documentElement ?? root).dataset.hubCatching;}
2940
3357
  api.clearPadContext();
2941
3358
  emoteWheel?.dispose();
2942
3359
  askLifecycle.abort();
3360
+ if (hostCover) {api.coverControls(false);}
2943
3361
  if (placeMenu) {clearMenu();}
2944
3362
  if (textAsk) {
2945
3363
  clearTextAsk();
@@ -2981,14 +3399,15 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2981
3399
  { ...surface('character-card', pickerCard, 'card'), pinned: pickerCompact },
2982
3400
  { ...surface('grab', grabButton), stack: 2 }, { ...surface('emote', emoteButton), stack: 1 }, { ...surface('quick-chat', sayButton), stack: 0 },
2983
3401
  ...(emoteWheel ? [surface('emote-wheel', emoteWheel.node, 'card')] : []),
2984
- surface('emotes', emoteRow, 'card'), surface('quick-chat-card', sayCard, 'card'),
3402
+ { ...surface('emotes', emoteRow, 'card'), beside: emoteButton }, { ...surface('quick-chat-card', sayCard, 'card'), beside: sayButton },
2985
3403
  { ...surface('sit', sitButton), stack: 6 }, { ...surface('talk', talkButton), stack: 7 }, { ...surface('near', nearButton), stack: 8 },
2986
3404
  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: () => [
3405
+ // The stacked column keeps clear of the dock, or raises it (`clearOfStack`).
3406
+ { ...surface('navigation', dock, 'control', false, { left: 10, bottom: 10 }), clearOfStack: { atBottom: () => !landscape, raised: () => dockHigh, raise: raiseDock }, reportNodes: () => [
2988
3407
  { id: 'doors', kind: 'control', node: doorsButton }, { id: 'people', kind: 'control', node: peopleButton },
2989
3408
  { id: 'companion-badge', kind: 'control', node: companionBadge },
2990
3409
  ] },
2991
- surface('sound', sound?.button, 'control', false, { right: 12, top: 64 }), surface('sound-card', sound?.card, 'card'),
3410
+ surface('sound', sound?.button, 'control', false, { right: 12, top: 64 }), { ...surface('sound-card', sound?.card, 'card'), beside: sound?.button, offControls: true },
2992
3411
  surface('actions', actionChips), surface('ask-card', askCard, 'card'),
2993
3412
  surface('menu', placeMenu?.sheet, 'card'), surface('text-ask', textAsk?.card, 'card'),
2994
3413
  surface('toast', toast, 'toast', true, { top: 12 }), surface('ribbon', ribbon, 'ribbon', true),
@@ -2996,8 +3415,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2996
3415
  surface('stats', stats, 'text', true, { right: 8, top: 8 }), surface('stuck', stuckChip, 'pointer', true),
2997
3416
  ...[...labelNodes].map(([id, node]) => ({ ...surface(`label:${id}`, node, 'label', true),
2998
3417
  // 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 })),
3418
+ // the viewer's own included; both are drawn over the viewer's body anyway. So is
3419
+ // an NPC's line, Chirp's included, said from the viewer's shoulder.
3420
+ ignoreObstacle: id.startsWith('role:') || id.startsWith('mark:') || npcSpeech.has(id) ? worldAvatar : null, clamp: clampLabels.has(id), edge: npcSpeech.has(id) })),
3001
3421
  ...[...pointerNodes].map(([id, item]) => surface(`pointer:${id}`, item.chip, 'pointer', true)),
3002
3422
  ...externalEntries().map(([id, item]) => ({ ...surface(id, item.node, item.kind, item.kind === 'text'), ...item.placement, ...(id === 'engine-shift-lock' ? { stack: 4 } : {}) })),
3003
3423
  ...(actionOverflow?.surfaces?.() ?? []).map((node, i) => surface(`action-overflow:${i}`, node, 'control')),
@@ -3014,7 +3434,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
3014
3434
  for (const child of entry.reportNodes?.() ?? []) {geometry.register(child.node);}
3015
3435
  }
3016
3436
  if (worldLabelsDefault) {
3017
- worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry);
3437
+ worldLayout = makeWorldLayout(surfaces, worldView, worldObstacles, geometry, (node) => safeLayout?.heldAct?.(node) ?? null);
3018
3438
  }
3019
3439
  if (safeInsets) {
3020
3440
  safeLayout = makeSafeLayout({ root, hud: () => hud, entries: surfaces, onLayout: () => {