castle-web-cli 0.4.238 → 0.4.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +218 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +22 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +9 -0
  19. package/dist/platformDoc.js +4 -2
  20. package/dist/playPagePolicy.d.ts +1 -0
  21. package/dist/playPagePolicy.js +12 -3
  22. package/dist/resetLeaderboards.d.ts +8 -1
  23. package/dist/resetLeaderboards.js +43 -8
  24. package/dist/roomLogs.d.ts +39 -0
  25. package/dist/roomLogs.js +166 -0
  26. package/dist/save-deck.d.ts +32 -2
  27. package/dist/save-deck.js +240 -39
  28. package/kits/base/CLAUDE.md +2 -1
  29. package/kits/base/castle.json +1 -1
  30. package/kits/base/sdk/README.md +240 -8
  31. package/kits/base/sdk/analytics.d.ts +8 -0
  32. package/kits/base/sdk/analytics.js +92 -0
  33. package/kits/base/sdk/castle.d.ts +8 -2
  34. package/kits/base/sdk/castle.js +3 -0
  35. package/kits/base/sdk/commands.d.ts +79 -0
  36. package/kits/base/sdk/commands.js +1 -0
  37. package/kits/base/sdk/debugConsole.d.ts +17 -0
  38. package/kits/base/sdk/debugConsole.js +154 -0
  39. package/kits/base/sdk/experiments.js +24 -1
  40. package/kits/base/sdk/hostRetry.d.ts +7 -0
  41. package/kits/base/sdk/hostRetry.js +57 -0
  42. package/kits/base/sdk/hub.d.ts +20 -2
  43. package/kits/base/sdk/hub.js +99 -13
  44. package/kits/base/sdk/multiplayer.d.ts +2 -0
  45. package/kits/base/sdk/multiplayer.js +198 -26
  46. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  47. package/kits/base/sdk/reconnectBudget.js +41 -1
  48. package/kits/base/sdk/rooms.d.ts +11 -0
  49. package/kits/base/sdk/rooms.js +22 -0
  50. package/kits/base/sdk/runtime.js +36 -19
  51. package/kits/base/sdk/server/hub.d.ts +19 -0
  52. package/kits/base/sdk/server/hub.js +12 -0
  53. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  54. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  55. package/kits/base/sdk/server/wrapper.js +26 -1
  56. package/kits/base/sdk/store.d.ts +8 -2
  57. package/kits/base/sdk/store.js +5 -1
  58. package/kits/base/sdk/transport.d.ts +2 -1
  59. package/kits/base/sdk/transport.js +35 -0
  60. package/kits/hub-game/CLAUDE.md +66 -19
  61. package/kits/hub-game/castle.json +4 -4
  62. package/kits/hub-game/code/client/act.js +9 -6
  63. package/kits/hub-game/code/client/actCore.js +26 -6
  64. package/kits/hub-game/code/client/actGateLog.js +36 -0
  65. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  66. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  67. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  68. package/kits/hub-game/code/client/askSurface.js +85 -0
  69. package/kits/hub-game/code/client/askTree.js +51 -0
  70. package/kits/hub-game/code/client/attention.js +31 -6
  71. package/kits/hub-game/code/client/ballot.js +42 -5
  72. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  73. package/kits/hub-game/code/client/ballotTree.js +180 -0
  74. package/kits/hub-game/code/client/catchingUp.js +19 -0
  75. package/kits/hub-game/code/client/celebrate.js +66 -0
  76. package/kits/hub-game/code/client/chrome.js +474 -53
  77. package/kits/hub-game/code/client/companion.js +93 -23
  78. package/kits/hub-game/code/client/companionDress.js +1 -1
  79. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  80. package/kits/hub-game/code/client/cornerTree.js +83 -0
  81. package/kits/hub-game/code/client/decor.js +20 -11
  82. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  83. package/kits/hub-game/code/client/disguise.js +23 -0
  84. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  85. package/kits/hub-game/code/client/dockSurface.js +206 -0
  86. package/kits/hub-game/code/client/dockTree.js +232 -0
  87. package/kits/hub-game/code/client/earned.js +29 -0
  88. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  89. package/kits/hub-game/code/client/emoteTree.js +264 -0
  90. package/kits/hub-game/code/client/farAvatars.js +4 -3
  91. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  92. package/kits/hub-game/code/client/grab.js +121 -50
  93. package/kits/hub-game/code/client/holdShow.js +19 -0
  94. package/kits/hub-game/code/client/hookLayer.js +96 -12
  95. package/kits/hub-game/code/client/hubControls.js +7 -1
  96. package/kits/hub-game/code/client/hudSurface.js +11 -3
  97. package/kits/hub-game/code/client/hudTree.js +7 -4
  98. package/kits/hub-game/code/client/idle.js +21 -3
  99. package/kits/hub-game/code/client/invites.js +24 -3
  100. package/kits/hub-game/code/client/keys.js +15 -0
  101. package/kits/hub-game/code/client/labelsNear.js +8 -1
  102. package/kits/hub-game/code/client/layoutCache.js +57 -8
  103. package/kits/hub-game/code/client/loadingCover.js +53 -4
  104. package/kits/hub-game/code/client/menuIcons.js +15 -0
  105. package/kits/hub-game/code/client/menuRows.js +8 -2
  106. package/kits/hub-game/code/client/menuSurface.js +102 -0
  107. package/kits/hub-game/code/client/menuTree.js +135 -0
  108. package/kits/hub-game/code/client/modelLook.js +41 -0
  109. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  110. package/kits/hub-game/code/client/pickerTree.js +163 -0
  111. package/kits/hub-game/code/client/pushVisit.js +4 -2
  112. package/kits/hub-game/code/client/quality.js +188 -29
  113. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  114. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  115. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  116. package/kits/hub-game/code/client/rehello.js +75 -0
  117. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  118. package/kits/hub-game/code/client/replay.js +118 -0
  119. package/kits/hub-game/code/client/role.js +3 -0
  120. package/kits/hub-game/code/client/safeLayout.js +441 -56
  121. package/kits/hub-game/code/client/safeStyle.js +13 -10
  122. package/kits/hub-game/code/client/say.js +2 -0
  123. package/kits/hub-game/code/client/soundSurface.js +77 -0
  124. package/kits/hub-game/code/client/soundTree.js +74 -0
  125. package/kits/hub-game/code/client/soundscape.js +12 -9
  126. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  127. package/kits/hub-game/code/client/state.js +67 -1
  128. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  129. package/kits/hub-game/code/client/stuckTree.js +67 -0
  130. package/kits/hub-game/code/client/talk.js +42 -12
  131. package/kits/hub-game/code/client/talkTree.js +4 -2
  132. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  133. package/kits/hub-game/code/client/textAskTree.js +67 -0
  134. package/kits/hub-game/code/client/tiers.js +252 -27
  135. package/kits/hub-game/code/client/together.js +4 -1
  136. package/kits/hub-game/code/client/uiDom.js +86 -8
  137. package/kits/hub-game/code/client/uiTree.js +33 -4
  138. package/kits/hub-game/code/client/vehicle.js +75 -52
  139. package/kits/hub-game/code/client/weakestTier.js +75 -31
  140. package/kits/hub-game/code/client/wear.js +159 -5
  141. package/kits/hub-game/code/client/worldLabels.js +215 -26
  142. package/kits/hub-game/code/companionSpec.js +4 -2
  143. package/kits/hub-game/code/server/act.js +3 -0
  144. package/kits/hub-game/code/server/actGate.js +83 -0
  145. package/kits/hub-game/code/server/actions.js +71 -15
  146. package/kits/hub-game/code/server/actors.js +20 -5
  147. package/kits/hub-game/code/server/analytics.js +40 -15
  148. package/kits/hub-game/code/server/ask.js +39 -3
  149. package/kits/hub-game/code/server/ballot.js +167 -4
  150. package/kits/hub-game/code/server/celebrate.js +64 -0
  151. package/kits/hub-game/code/server/companion.js +17 -2
  152. package/kits/hub-game/code/server/decor.js +11 -2
  153. package/kits/hub-game/code/server/disguise.js +63 -0
  154. package/kits/hub-game/code/server/doorAnalytics.js +2 -5
  155. package/kits/hub-game/code/server/earned.js +6 -2
  156. package/kits/hub-game/code/server/friendBests.js +13 -4
  157. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  158. package/kits/hub-game/code/server/grab.js +12 -2
  159. package/kits/hub-game/code/server/heldOffers.js +142 -0
  160. package/kits/hub-game/code/server/holdShow.js +98 -0
  161. package/kits/hub-game/code/server/hub.js +854 -45
  162. package/kits/hub-game/code/server/idle.js +110 -9
  163. package/kits/hub-game/code/server/index.js +9 -0
  164. package/kits/hub-game/code/server/labels.js +13 -3
  165. package/kits/hub-game/code/server/loadAbandon.js +2 -5
  166. package/kits/hub-game/code/server/manifest.js +94 -6
  167. package/kits/hub-game/code/server/menu.js +26 -3
  168. package/kits/hub-game/code/server/npcs.js +55 -9
  169. package/kits/hub-game/code/server/observe.js +67 -6
  170. package/kits/hub-game/code/server/players.js +8 -1
  171. package/kits/hub-game/code/server/replay.js +135 -0
  172. package/kits/hub-game/code/server/storageLimit.js +4 -1
  173. package/kits/hub-game/code/server/townDay.js +74 -0
  174. package/kits/hub-game/code/server/trackQueue.js +29 -0
  175. package/kits/hub-game/code/server/vehicle.js +3 -0
  176. package/kits/hub-game/code/server/vis.js +26 -4
  177. package/kits/hub-game/code/server/wallet.js +677 -0
  178. package/kits/hub-game/code/server/wear.js +13 -3
  179. package/kits/hub-game/code/server/writerLease.js +191 -0
  180. package/kits/hub-game/code/shared/act.js +1 -1
  181. package/kits/hub-game/code/shared/expression.js +6 -0
  182. package/kits/hub-game/code/shared/replay.js +37 -0
  183. package/kits/hub-game/code/systems/hub.js +437 -57
  184. package/kits/hub-game/docs/analytics.md +20 -3
  185. package/kits/hub-game/docs/contract.md +942 -99
  186. package/kits/hub-game/docs/home-pieces.md +5 -6
  187. package/kits/hub-game/docs/observed-progress.md +49 -1
  188. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  189. package/kits/hub-game/index.html +1 -0
  190. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  207. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  208. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  209. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  210. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  211. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  212. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  213. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  214. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  215. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  216. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  217. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  218. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  219. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  220. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  221. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  222. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  223. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  224. package/kits/hub-game/package-lock.json +3 -3
  225. package/kits/hub-game/package.json +4 -3
  226. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  227. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  228. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  229. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  230. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  231. package/kits/hub-game/scripts/pack.mjs +89 -23
  232. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  233. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  234. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  235. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  236. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  237. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  238. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  239. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  240. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  241. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  242. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  243. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  244. package/kits/hub-game/scripts/test-analytics.mjs +80 -1
  245. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  246. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  247. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  248. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  249. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  250. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  251. package/kits/hub-game/scripts/test-ballot.mjs +420 -3
  252. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  253. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  254. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  255. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  256. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  257. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  258. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  259. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  260. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  261. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  262. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  263. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  264. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  265. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  266. package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
  267. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  268. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  269. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  270. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  271. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  272. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  273. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  274. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  275. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  276. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  277. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  278. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  279. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  280. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  281. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  282. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  283. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  284. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  285. package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
  286. package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
  287. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  288. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  289. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  290. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  291. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  292. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  293. package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
  294. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  295. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  296. package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
  297. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  298. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  299. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  300. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  301. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  302. package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
  303. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  304. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  305. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  306. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  307. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  308. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  309. package/kits/hub-game/scripts/test-rehello.mjs +237 -0
  310. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  311. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  312. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  313. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  314. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  315. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  316. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  317. package/kits/hub-game/scripts/test-resync.mjs +13 -0
  318. package/kits/hub-game/scripts/test-role-client.mjs +10 -3
  319. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  320. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  321. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  322. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  323. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  324. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  325. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  326. package/kits/hub-game/scripts/test-stuck.mjs +31 -0
  327. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  328. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  329. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  330. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  331. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  332. package/kits/hub-game/scripts/test-together.mjs +11 -0
  333. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  334. package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
  335. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  336. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  337. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  338. package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
  339. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  340. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  341. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  342. package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
  343. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  344. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  345. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  346. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  347. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  348. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
  349. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
  350. package/kits/multiplayer-3d/castle.json +5 -5
  351. package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
  352. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  353. package/kits/multiplayer-3d/code/server/world.js +19 -4
  354. package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
  355. package/kits/multiplayer-3d/package-lock.json +1 -1
  356. package/kits/multiplayer-3d/package.json +2 -1
  357. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  358. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  359. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  360. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
  361. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  362. package/kits/physics-2d/castle.json +2 -2
  363. package/kits/physics-2d/engine/scene.js +10 -2
  364. package/kits/physics-3d/CLAUDE.md +14 -0
  365. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  366. package/kits/physics-3d/castle.json +3 -3
  367. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  368. package/kits/physics-3d/docs/engine-player.md +76 -0
  369. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  370. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  371. package/kits/physics-3d/engine3d/gait.js +16 -8
  372. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  373. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  374. package/kits/physics-3d/engine3d/look.js +110 -17
  375. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  376. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  377. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  378. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  379. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  380. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  381. package/kits/physics-3d/engine3d/optimize.js +20 -9
  382. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  383. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  384. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  385. package/kits/physics-3d/engine3d/world3d.js +211 -17
  386. package/kits/physics-3d/package-lock.json +1 -1
  387. package/kits/physics-3d/package.json +2 -1
  388. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  389. package/kits/physics-3d/scripts/render.mjs +56 -8
  390. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  391. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  392. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  393. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  394. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  395. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  396. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  397. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  398. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  399. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  400. package/kits/physics-3d/systems/physics3d.js +51 -2
  401. package/kits/real-time/castle.json +2 -2
  402. package/kits/real-time/code/client/connection.js +3 -0
  403. package/package.json +2 -2
  404. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -0,0 +1,77 @@
1
+ // The sound control surface: the speaker button and its card (`soundTree.js`)
2
+ // with the behaviour `chrome.js` `soundControl` gives them in the DOM -- a
3
+ // tap on the button opens or closes the card, Mute calls `onMuted(!muted)`,
4
+ // the slider calls `onVolume(0..1)` as it moves, and hiding the button closes
5
+ // the card -- published as the `sound` UI tree root. No DOM and no window: a
6
+ // native host says `soundControl(show, state, handlers)` as it says the
7
+ // chrome's (`overlay_audio.js`), and its handlers stay the soundscape's
8
+ // setters. The web chrome does not use it.
9
+ //
10
+ // makeSoundSurface({ view, draw }):
11
+ // view() the stage: { safeInsets };
12
+ // draw(tree) called with each root built (only when it changed).
13
+ import { publishUiRoot } from './uiTree.js';
14
+ import { buildSound } from './soundTree.js';
15
+
16
+ export function makeSoundSurface({ view = () => ({}), draw = null } = {}) {
17
+ let show = false;
18
+ let open = false;
19
+ let volume = 0;
20
+ let muted = false;
21
+ let below = null;
22
+ let handlers = { onVolume() {}, onMuted() {} };
23
+ let key = '';
24
+ let disposed = false;
25
+
26
+ const on = {
27
+ toggle: () => {
28
+ if (!show) {return;}
29
+ open = !open;
30
+ render();
31
+ },
32
+ mute: () => {if (show && open) {handlers.onMuted?.(!muted);}},
33
+ volume: (value) => {
34
+ if (!show || !open || !Number.isFinite(value)) {return;}
35
+ handlers.onVolume?.(Math.min(1, Math.max(0, value)));
36
+ },
37
+ };
38
+
39
+ function render() {
40
+ if (disposed) {return;}
41
+ const v = view() ?? {};
42
+ const state = { view: { safeInsets: Boolean(v.safeInsets) }, show, open: show && open, volume, muted, below };
43
+ const next = JSON.stringify(state);
44
+ if (next === key) {return;}
45
+ key = next;
46
+ const tree = buildSound(state, on);
47
+ publishUiRoot('sound', tree);
48
+ draw?.(tree);
49
+ }
50
+
51
+ render();
52
+ return {
53
+ // chrome `soundControl`: `show` whether the button is up, `state`
54
+ // `{ volume, muted }` (0 to 1), `handlers` `{ onVolume(0..1),
55
+ // onMuted(bool) }` (kept from the last given).
56
+ soundControl(nextShow, state, nextHandlers) {
57
+ show = Boolean(nextShow);
58
+ if (!show) {open = false;}
59
+ volume = Number.isFinite(state?.volume) ? state.volume : 0;
60
+ muted = state?.muted === true;
61
+ handlers = nextHandlers ?? handlers;
62
+ render();
63
+ },
64
+ // Where the frame-rate readout ends (its bottom + 6, CSS px), or null.
65
+ place(px) {
66
+ below = Number.isFinite(px) ? px : null;
67
+ render();
68
+ },
69
+ isOpen: () => show && open,
70
+ render,
71
+ dispose() {
72
+ if (disposed) {return;}
73
+ disposed = true;
74
+ publishUiRoot('sound', null);
75
+ },
76
+ };
77
+ }
@@ -0,0 +1,74 @@
1
+ // The sound control (a deck with `hub.soundscape`, `soundscape.js`) as a UI
2
+ // tree (schema v0, the slider v1.198): what `chrome.js` `soundControl` draws
3
+ // in the DOM -- a 40 px speaker button top right, under the native camera
4
+ // corner, and under it, while open, the card with Mute and the volume slider.
5
+ // The same words, glyphs, sizes and states. Pure: no DOM, no window; the web
6
+ // chrome still draws its own DOM.
7
+ //
8
+ // state = {
9
+ // view: { safeInsets };
10
+ // show: whether the button is up (never on a trip);
11
+ // open: whether the card is open under it;
12
+ // volume: 0 to 1; muted: boolean;
13
+ // below: null, or where the frame-rate readout ends (CSS px from the top,
14
+ // its bottom + 6): the button keeps under it, as the DOM's
15
+ // max(readout bottom + 6px, its own top);
16
+ // }
17
+ // on = { toggle(), mute(), volume(0..1) }.
18
+ import { h } from './uiTree.js';
19
+
20
+ const ROOT = { font: 'ui', size: 15, weight: 600, lh: 1.3, color: '#fff' };
21
+ // max(64px, the top safe inset + 64px); the card 46 px lower.
22
+ export const SOUND_TOP = [64, 64];
23
+ export const SOUND_CARD_DROP = 46;
24
+ const edge = (safeInsets, px) => (safeInsets ? [px, 0] : px);
25
+
26
+ export const soundPercent = (volume) => Math.round((Number.isFinite(volume) ? volume : 0) * 100);
27
+ // The button's glyph and words: quiet when muted or at 0%.
28
+ export function soundLabel(volume, muted) {
29
+ const percent = soundPercent(volume);
30
+ const quiet = Boolean(muted) || percent === 0;
31
+ return { glyph: quiet ? '🔇' : '🔊', label: quiet ? 'Sound: off' : `Sound: ${percent}%` };
32
+ }
33
+
34
+ export function buildSound(state, on = {}) {
35
+ const view = state?.view ?? {};
36
+ if (!state?.show) {return h('stack', { key: 'sound', style: ROOT });}
37
+ const muted = state.muted === true;
38
+ const percent = soundPercent(state.volume);
39
+ const { glyph, label } = soundLabel(state.volume, muted);
40
+ const below = Number.isFinite(state.below) ? state.below : null;
41
+ const top = below === null ? SOUND_TOP : [Math.max(SOUND_TOP[0], below), SOUND_TOP[1]];
42
+ const right = edge(view.safeInsets, 12);
43
+ return h('stack', { key: 'sound', style: ROOT },
44
+ h('button', {
45
+ key: 'button', hub: 'sound', fire: 'down', label,
46
+ at: { anchor: 'topRight', right, top },
47
+ style: {
48
+ w: 40, h: 40, radius: 20, border: { w: 1, c: 'line40' }, bg: 'chip', color: '#fff',
49
+ font: 'ui', size: 18, weight: 400, lh: 'normal', talign: 'center',
50
+ },
51
+ on: { tap: on.toggle },
52
+ }, glyph),
53
+ h('row', {
54
+ key: 'card', hub: 'sound-card',
55
+ at: { anchor: 'topRight', right, top: [top[0] + SOUND_CARD_DROP, top[1] + SOUND_CARD_DROP] },
56
+ style: {
57
+ box: 'border', w: [{ vw: 70 }, { px: 208 }], align: 'center', gap: 8, pad: [8, 10], radius: 12,
58
+ bg: 'card', shadow: 'card', hit: 'auto', gone: !state.open,
59
+ },
60
+ },
61
+ h('button', {
62
+ key: 'mute', fire: 'down',
63
+ style: {
64
+ flex: 'none', pad: [5, 10], radius: 12, border: { w: 1, c: 'line35' }, color: '#fff',
65
+ font: 'ui', size: 13, weight: 700, lh: 'normal',
66
+ },
67
+ on: { tap: on.mute },
68
+ }, muted ? 'Unmute' : 'Mute'),
69
+ h('slider', {
70
+ key: 'volume', label: 'Volume', value: percent, min: 0, max: 100, step: 1, tint: 'gold',
71
+ style: { flex: 1, minW: 0, h: 28, opacity: muted ? 0.5 : 1 },
72
+ on: { input: on.volume ? (event) => on.volume(Number(event?.value) / 100) : undefined },
73
+ })));
74
+ }
@@ -37,6 +37,7 @@
37
37
 
38
38
  import * as Shared from '@imports/castle.physics-2d/engine/audioContext';
39
39
  import { hub } from './state.js';
40
+ import { deviceStorage } from './deviceStorage.js';
40
41
  import { makeSoundscapeMap, sanitiseSoundscape } from './soundscapeMap.js';
41
42
  import { makeAmbience, BEDS } from './soundscapeAmbience.js';
42
43
  import { makeUi } from './soundscapeUi.js';
@@ -277,14 +278,6 @@ export function stepFrame(s, x, y, z, dt, grounded = null, vy = null) {
277
278
 
278
279
  // --- the control's memory ----------------------------------------------------
279
280
 
280
- function pageStorage() {
281
- try {
282
- return globalThis.localStorage ?? null;
283
- } catch {
284
- return null;
285
- }
286
- }
287
-
288
281
  export function readSettings(storage) {
289
282
  const out = { volume: DEFAULT_VOLUME, muted: false };
290
283
  try {
@@ -362,13 +355,23 @@ const gesturedPages = new WeakSet();
362
355
  // where the player's first gesture is heard, `onHide` is called as the page
363
356
  // is hidden (the hub system quiets the place's own sound files there, which
364
357
  // no frame would get to).
365
- export function makeSoundscape(options, { audio = Shared, storage = pageStorage(), doc = globalThis.document ?? null, win = globalThis.window ?? null, nav = globalThis.navigator ?? null, random = Math.random, onHide = () => {}, isOn = null, loudestLoop = () => 0, cueVoices, createOfflineContext, lowMemory = false } = {}) {
358
+ export function makeSoundscape(options, { audio = Shared, storage = deviceStorage(), doc = globalThis.document ?? null, win = globalThis.window ?? null, nav = globalThis.navigator ?? null, random = Math.random, onHide = () => {}, isOn = null, loudestLoop = () => 0, cueVoices, createOfflineContext, lowMemory = false } = {}) {
366
359
  options = sanitiseSoundscape(options, BEDS, SURFACES);
367
360
  const want = { babble: options?.babble !== false, steps: options?.steps !== false };
368
361
  const map = options?.ambience || typeof options?.steps === 'object' ? makeSoundscapeMap(options, SURFACES) : null;
369
362
  const ambience = options?.ambience ? makeAmbience(options.ambience, { noise: noiseOf, seeded, hash: hashOf, loudestLoop, random, win, createOfflineContext, lowMemory, canBake: () => live() && ctx?.state === 'running' && Number.isFinite(ctx.currentTime) }) : null;
370
363
  let mapScene = null;
371
364
  const settings = readSettings(storage);
365
+ // A storage that fetches its values (`deviceStorage.js` in a frame without
366
+ // localStorage) hands the kept settings over later. They are taken then,
367
+ // unless the player has set the volume or mute since: that write is kept
368
+ // over the fetched one, so the key does not come back adopted.
369
+ storage?.prime?.([SETTINGS_KEY]).then((adopted) => {
370
+ if (!disposed && adopted.has(SETTINGS_KEY)) {
371
+ Object.assign(settings, readSettings(storage));
372
+ apply();
373
+ }
374
+ }, () => {});
372
375
  // The context once it has been asked for, and what hangs off it.
373
376
  let ctx = null;
374
377
  let out = null;
@@ -283,7 +283,7 @@ export const CUE_VOICES = Object.freeze({
283
283
  export const ACTION_VOICES = Object.freeze({
284
284
  wave: emoteWaveB, dance: emoteDanceC, cheer: emoteCheer,
285
285
  bow: emoteBow, spin: emoteSpin, sleep: emoteBow, eat: emoteWaveB,
286
- cry: emoteBow, laugh: emoteCheer, point: emoteWaveB, sit, chat: chatOpen,
286
+ cry: emoteBow, laugh: emoteCheer, point: emoteWaveB, yawn: emoteBow, sit, chat: chatOpen,
287
287
  });
288
288
 
289
289
  function release(nodes) {
@@ -71,6 +71,10 @@ export const hub = {
71
71
  // own (`hub-try`) over it; both empty in a place that never tries one on
72
72
  tryAll: new Map(),
73
73
  tryMe: new Map(),
74
+ // Visit-only flowers (v1.182), shared and per-viewer whole blocks.
75
+ holdShows: new Map(),
76
+ holdShowAll: new Map(),
77
+ holdShowMe: new Map(),
74
78
  // Roles (v1.157), shared and per-viewer whole blocks.
75
79
  roles: new Map(),
76
80
  roleAll: new Map(),
@@ -87,6 +91,9 @@ export const hub = {
87
91
  hudMe: null,
88
92
  // v1.52: this player's line for leaving the current place, or null.
89
93
  leaving: null,
94
+ // v1.204: the page time the server said it began reading this player's
95
+ // progress (`hub-progress`), or null.
96
+ catching: null,
90
97
  friendsWanted: false,
91
98
  // the newest simulation time seen and the page time it arrived
92
99
  lastT: 0,
@@ -95,8 +102,12 @@ export const hub = {
95
102
  hiddenAll: new Set(),
96
103
  hiddenMe: new Set(),
97
104
  shownMe: new Set(),
105
+ // v1.184: the private hides the place named `solid`.
106
+ solidMe: new Set(),
98
107
  // Merged visibility, read unchanged by drawing, pads, idle and soundscape.
99
108
  hidden: new Set(),
109
+ // The hidden actors drawn hidden in place, collider kept (`applyVisibility`).
110
+ hiddenSolid: new Set(),
100
111
  // scene actor id -> '#rrggbb' the place painted it
101
112
  tints: {},
102
113
  // The town's doors a player may jump to (contract §5): [{ id, title }].
@@ -140,11 +151,18 @@ export const hub = {
140
151
  // template id -> its authored components
141
152
  spawned: {},
142
153
  spawnTemplates: {},
154
+ // v1.197: the decor templates a game behind a door named (`hubDecorTpl`)
155
+ decorTemplates: new Set(),
143
156
  // this player's own controller tuning, { speed, jump } multipliers, or null
144
157
  tune: null,
145
158
  cars: {},
146
- // player ids the place is holding still
159
+ disguises: new Map(),
160
+ // player ids the place is holding still: the shared `held` and, v1.183,
161
+ // the players of a hidden pair this player may see (`hub-idle`); `held` is
162
+ // the two together (`idleNow`)
147
163
  held: new Set(),
164
+ heldAll: new Set(),
165
+ heldMe: new Set(),
148
166
  // actor id -> { text, style }, and this player's own over them (an NPC's
149
167
  // reply to this player)
150
168
  labels: {},
@@ -152,6 +170,9 @@ export const hub = {
152
170
  // the facing the place gave this player on arrival, or null until it has,
153
171
  // and whether the camera has been turned to it
154
172
  arrivedFacing: null,
173
+ // v1.165: this client's newest clamped pose row while it matters to a car
174
+ // (`hookLayer` state, vehicle.js `placedHeading`)
175
+ selfClamp: null,
155
176
  // The post-arrival server placement for this client has reached the
156
177
  // multiplayer layer. A returned Your games card waits for this so its
157
178
  // first-display position is the town position, not the scene spawn.
@@ -170,11 +191,18 @@ export const hub = {
170
191
  // emote playing, simulation ms), playerId -> the seat actor they sit on,
171
192
  // actorId -> { file, volume, radius, since } (a loop playing there), and the
172
193
  // one-shot sounds not yet played
194
+ // `emotes` and `seated` are the shared `hubEmotes`/`hubSeated` (`*All`)
195
+ // with, v1.183, the hidden pair this player may see over them (`*Me`,
196
+ // `hub-idle`), merged by `idleNow`.
173
197
  emotes: {},
198
+ emotesAll: {},
199
+ emotesMe: {},
174
200
  roleEmotes: [],
175
201
  // v1.47: actor id -> an NPC's emote, empty until a body reacts.
176
202
  npcEmotes: {},
177
203
  seated: {},
204
+ seatedAll: {},
205
+ seatedMe: {},
178
206
  sounds: {},
179
207
  danceIdle: null,
180
208
  soundEvents: [],
@@ -189,6 +217,10 @@ export const hub = {
189
217
  cabinetsRev: 0,
190
218
  };
191
219
 
220
+ // v1.163: the replay module (loaded by the hub system) fills these in, so
221
+ // the hook layer and its tests never load the renderer.
222
+ export const replayCleanup = { clear() {}, receive() {} };
223
+
192
224
  export function clear() {
193
225
  hub.place = null;
194
226
  delete hub.prompts;
@@ -206,6 +238,7 @@ export function clear() {
206
238
  }
207
239
  delete hub.companion;
208
240
  delete hub.glow;
241
+ delete hub.chirp;
209
242
  clearShot();
210
243
  hub.avatars.clear();
211
244
  hub.avatarsAll.clear();
@@ -222,6 +255,9 @@ export function clear() {
222
255
  hub.wearMe.clear();
223
256
  hub.tryAll.clear();
224
257
  hub.tryMe.clear();
258
+ hub.holdShows.clear();
259
+ hub.holdShowAll.clear();
260
+ hub.holdShowMe.clear();
225
261
  hub.roles.clear();
226
262
  hub.roleAll.clear();
227
263
  hub.roleMe.clear();
@@ -234,11 +270,14 @@ export function clear() {
234
270
  delete hub.guestsMe;
235
271
  hub.hudMe = null;
236
272
  hub.leaving = null;
273
+ hub.catching = null;
237
274
  hub.friendsWanted = false;
238
275
  hub.hidden.clear();
239
276
  hub.hiddenAll.clear();
240
277
  hub.hiddenMe.clear();
241
278
  hub.shownMe.clear();
279
+ hub.solidMe.clear();
280
+ hub.hiddenSolid.clear();
242
281
  hub.tints = {};
243
282
  hub.doors = [];
244
283
  hub.yours = null;
@@ -253,9 +292,14 @@ export function clear() {
253
292
  hub.marks = {};
254
293
  hub.spawned = {};
255
294
  hub.spawnTemplates = {};
295
+ hub.decorTemplates = new Set();
256
296
  hub.tune = null;
257
297
  hub.cars = {};
298
+ hub.disguises.clear();
258
299
  hub.held.clear();
300
+ hub.heldAll.clear();
301
+ hub.heldMe.clear();
302
+ hub.selfClamp = null;
259
303
  hub.labels = {};
260
304
  hub.labelsMe = {};
261
305
  hub.npcEvents.length = 0;
@@ -264,9 +308,13 @@ export function clear() {
264
308
  hub.grabEvents.length = 0;
265
309
  hub.keptFor = new Map();
266
310
  hub.emotes = {};
311
+ hub.emotesAll = {};
312
+ hub.emotesMe = {};
267
313
  hub.roleEmotes = [];
268
314
  hub.npcEmotes = {};
269
315
  hub.seated = {};
316
+ hub.seatedAll = {};
317
+ hub.seatedMe = {};
270
318
  hub.sounds = {};
271
319
  hub.danceIdle = null;
272
320
  hub.soundEvents.length = 0;
@@ -278,6 +326,7 @@ export function clear() {
278
326
  hub.arrivalPlaced = false;
279
327
  hub.faced = false;
280
328
  hub.commands.length = 0;
329
+ replayCleanup.clear();
281
330
  }
282
331
 
283
332
  // What each player is drawn wearing: their own wearable, or the one the place
@@ -287,11 +336,24 @@ export function wearingNow() {
287
336
  return new Map([...hub.wearAll, ...hub.wearMe, ...hub.tryAll, ...hub.tryMe]);
288
337
  }
289
338
 
339
+ // v1.183: who sits, emotes and is held, as every reader sees it: the shared
340
+ // fields, which leave out anyone a block hides from someone here, with what
341
+ // `hub-idle` told this player alone over them. In a place with no blocks the
342
+ // private parts are empty and these are the shared fields as they came.
343
+ export function idleNow() {
344
+ hub.seated = { ...hub.seatedAll, ...hub.seatedMe };
345
+ hub.emotes = { ...hub.emotesAll, ...hub.emotesMe };
346
+ hub.held = new Set([...hub.heldAll, ...hub.heldMe]);
347
+ }
348
+
290
349
  export function mergeHidden() {
291
350
  hub.hidden = new Set([...hub.hiddenAll].filter((id) => !hub.shownMe.has(id)));
292
351
  for (const id of hub.hiddenMe) {
293
352
  hub.hidden.add(id);
294
353
  }
354
+ // A shared hide disables the body on the server, so it still drops the
355
+ // actor, collider and all, whatever the private hide said.
356
+ hub.hiddenSolid = new Set([...hub.solidMe].filter((id) => hub.hiddenMe.has(id) && !hub.hiddenAll.has(id)));
295
357
  }
296
358
 
297
359
  export function receiveParty(msg) {
@@ -343,3 +405,7 @@ export function rolesNow() {
343
405
  }
344
406
  return out;
345
407
  }
408
+
409
+ export function holdShowsNow() {
410
+ return new Map([...hub.holdShowAll, ...hub.holdShowMe]);
411
+ }
@@ -0,0 +1,76 @@
1
+ // The "Stuck?" chip surface: the chip (`stuckTree.js`) with the behaviour
2
+ // `chrome.js` `stuckPrompt` gives it in the DOM -- its words or none, a press
3
+ // calling the handler, hidden while quick chat, the emote row, People, Doors
4
+ // or a talk panel is open -- published as the `stuck` UI tree root. No DOM
5
+ // and no window: a native host says `stuckPrompt(text, handler)` as the hub
6
+ // system says the chrome's (its `offerUnstick`), which also sends
7
+ // `{ k: 'hub-unstick', ask: true }` as the chip first shows in a place with
8
+ // the `unstick` hook; the handler is the hub system's `unstick`, which sends
9
+ // `{ k: 'hub-unstick' }` (at most once in STUCK_EVERY_MS, never on a trip).
10
+ // The web chrome does not use it.
11
+ //
12
+ // Where it is drawn: the host measures the chip (a report node,
13
+ // `stuck/chip`) and the boxes it must clear and gives `place(shift)` from
14
+ // `stuckChipShift(stuckChipSpot(size, view), above, others, viewH)`, as
15
+ // chrome.js `placeStuckChip` does each frame; until it does, the renderer's
16
+ // own `avoid` places it.
17
+ //
18
+ // makeStuckSurface({ draw }):
19
+ // draw(tree) called with each root built (only when it changed).
20
+ import { publishUiRoot } from './uiTree.js';
21
+ import { buildStuck, stuckShown } from './stuckTree.js';
22
+
23
+ export function makeStuckSurface({ draw = null } = {}) {
24
+ let text = null;
25
+ let handler = () => {};
26
+ const open = { say: false, emotes: false, people: false, doors: false, talk: false };
27
+ let shift;
28
+ let key = '';
29
+ let disposed = false;
30
+
31
+ const on = { press: () => {if (stuckShown({ text, open }) && shift !== null) {handler();}} };
32
+
33
+ function render() {
34
+ if (disposed) {return;}
35
+ const state = { text, open: { ...open }, ...(shift !== undefined ? { shift } : {}) };
36
+ const next = JSON.stringify(state);
37
+ if (next === key) {return;}
38
+ key = next;
39
+ const tree = buildStuck(state, on);
40
+ publishUiRoot('stuck', tree);
41
+ draw?.(tree);
42
+ }
43
+
44
+ render();
45
+ return {
46
+ // chrome `stuckPrompt`: the chip's words, or null to hide it; a press
47
+ // calls `handler` (kept from the last words given).
48
+ stuckPrompt(words, onPress) {
49
+ text = words ? String(words) : null;
50
+ if (text) {handler = onPress ?? handler;}
51
+ render();
52
+ },
53
+ // What is open now (any subset): the chip hides under any of them.
54
+ setOpen(next = {}) {
55
+ for (const what of Object.keys(open)) {
56
+ if (Object.hasOwn(next, what)) {open[what] = Boolean(next[what]);}
57
+ }
58
+ render();
59
+ },
60
+ // The host's placement: how far below where it hangs (CSS px), null for
61
+ // no room (not drawn), undefined to give it back to the renderer's avoid.
62
+ place(down) {
63
+ shift = down === null ? null : Number.isFinite(down) ? Math.max(0, down) : undefined;
64
+ render();
65
+ },
66
+ // Whether the chip is asked for and nothing hides it (the host measures
67
+ // and places it, and the toast leaves its spot clear, only then).
68
+ shown: () => stuckShown({ text, open }),
69
+ render,
70
+ dispose() {
71
+ if (disposed) {return;}
72
+ disposed = true;
73
+ publishUiRoot('stuck', null);
74
+ },
75
+ };
76
+ }
@@ -0,0 +1,67 @@
1
+ // The "Stuck?" chip (contract v1.33, a deck with `hub.stuck`) as a UI tree
2
+ // (schema v0): what `chrome.js` `stuckPrompt` draws in the DOM -- one button
3
+ // at the bottom centre, as wide as its words up to the view less 170 px,
4
+ // hidden while quick chat, the emote row, People, Doors or a talk panel is
5
+ // open, and moved down clear of the HUD and a question or not drawn at all
6
+ // (`placeStuckChip`, `stuck.js` `chipShift`). The same words and states.
7
+ // Pure: no DOM, no window; the web chrome still draws its own DOM.
8
+ //
9
+ // state = {
10
+ // text: the chip's words, or null (no chip);
11
+ // open: { say, emotes, people, doors, talk }: what is open;
12
+ // shift: where the host placed it (`stuckChipShift`): a number, how far
13
+ // below where it hangs it is drawn (CSS px, 0 where it hangs), or
14
+ // null (no room: not drawn); absent or undefined, the renderer's
15
+ // own `avoid` places it (below: not the DOM's rule exactly);
16
+ // }
17
+ // on = { press() }: the chip pressed.
18
+ import { h } from './uiTree.js';
19
+ import { chipShift } from './stuck.js';
20
+
21
+ // Where it hangs: max(202px, the bottom safe inset + 192px) up from the
22
+ // view's bottom edge.
23
+ export const STUCK_BOTTOM = [202, 192];
24
+ // The boxes the renderer's `avoid` keeps it off when the host gives no
25
+ // shift: the HUD's pieces, the dock, the quick chat button and feed, the
26
+ // emote button and Sit, the Talk button and the host's own controls.
27
+ export const STUCK_AVOID = ['hud/hud', 'hud/back', 'hud/prompt', 'hud/toast', 'hud/actpair', 'dock/dock', 'quickchat/button', 'quickchat/feed', 'emotes/emote', 'emotes/sit', 'talkprompt/talk', 'controls'];
28
+
29
+ // Whether the chip is asked for and nothing it yields to is open.
30
+ export const stuckShown = (state) => Boolean(state?.text) && !['say', 'emotes', 'people', 'doors', 'talk'].some((what) => state.open?.[what]);
31
+
32
+ // The box where it hangs (CSS px from the view's top left), from its laid-out
33
+ // size and the view: what the toast leaves room for (chrome.js `stuckSpot`)
34
+ // and what `stuckChipShift` moves.
35
+ export function stuckChipSpot(size, view) {
36
+ const bottom = view.h - Math.max(STUCK_BOTTOM[0], (view.insets?.bottom ?? 0) + STUCK_BOTTOM[1]);
37
+ const left = (view.w - size.w) / 2;
38
+ return { left, right: left + size.w, top: bottom - size.h, bottom };
39
+ }
40
+
41
+ // chrome.js `placeStuckChip`: how far down from `spot` it is drawn, clear of
42
+ // `above` (the HUD and a question: it moves to just under them) and of
43
+ // `others` (every other control and card shown: it is not drawn over them),
44
+ // or null where it cannot be drawn. The boxes are CSS px from the top left.
45
+ export const stuckChipShift = (spot, above, others, viewH) => chipShift(spot, above, others, viewH);
46
+
47
+ export function buildStuck(state, on = {}) {
48
+ const root = { key: 'stuck', style: { font: 'ui', size: 15, weight: 600, lh: 1.3, color: '#fff' } };
49
+ if (!state?.text) {return h('stack', root);}
50
+ const placed = state.shift !== undefined;
51
+ const drawn = stuckShown(state) && state.shift !== null;
52
+ const down = placed && Number.isFinite(state.shift) ? state.shift : 0;
53
+ return h('stack', root,
54
+ h('button', {
55
+ key: 'chip', hub: 'stuck', fire: 'down', report: true,
56
+ // Moved down `down` px is the same edge value less `down` on both sides.
57
+ at: placed
58
+ ? { anchor: 'bottom', bottom: [STUCK_BOTTOM[0] - down, STUCK_BOTTOM[1] - down] }
59
+ : { anchor: 'bottom', bottom: STUCK_BOTTOM, avoid: STUCK_AVOID, avoidHide: true },
60
+ style: {
61
+ box: 'border', w: 'wrap', maxW: [{ vw: 100, px: -170 }], pad: [9, 12], radius: 18,
62
+ border: { w: 1, c: 'line45' }, bg: 'toast', color: '#fff', size: 12, weight: 600, lh: 'normal', talign: 'center',
63
+ gone: !drawn,
64
+ },
65
+ on: { tap: drawn ? on.press : undefined },
66
+ }, String(state.text)));
67
+ }