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
@@ -1,14 +1,18 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
- import { register } from 'node:module';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { createRequire, register } from 'node:module';
5
6
  import * as THREE from 'three';
6
7
  import { readManifest } from '../code/server/manifest.js';
7
8
  import { actorReferences, QUALITY_RANGES, readQuality } from '../code/shared/quality.js';
8
9
  import { deck, hub, clear as clearState } from '../code/client/state.js';
9
10
  import { makeTiers, MODE_KEY, TIER_KEY } from '../code/client/tiers.js';
10
11
  import { applyPlayerVisibility, capLabels, capWorldLabels, choosePlayers, filterQualityScene, lowQuality, makeQualityVisit,
11
- mindDue, noteQualityInteraction, qualityFor, qualityPlayers, qualitySpawnIds, restoreDecor } from '../code/client/quality.js';
12
+ cullAfterTier, cullBeforeLabels, mindDue, nearerThenId, noteQualityInteraction, qualityFor, qualityPlayers, qualitySpawnIds, qualityTags, lowerLate, restoreDecor, spawnLowQuality, splitTags, withDecorTemplates } from '../code/client/quality.js';
13
+ import { CACHE_PREFIX, makeCachedStorage } from '../code/client/deviceStorage.js';
14
+ import { disguiseTags } from '../code/client/disguise.js';
15
+ import { roleItems } from '../code/client/role.js';
12
16
  import { fps } from '../code/server/analytics.js';
13
17
  import * as labelsNear from '../code/client/labelsNear.js';
14
18
  const { chromeItem, labelBox, near, nearFor } = labelsNear;
@@ -16,7 +20,7 @@ const { chromeItem, labelBox, near, nearFor } = labelsNear;
16
20
  const nearCandidates = labelsNear.nearCandidates;
17
21
  import { relevantLabels } from '../code/client/worldLabels.js';
18
22
  import { makeFpsTelemetry, fpsTelemetryFor, setFpsTelemetry } from '../code/client/fpsTelemetry.js';
19
- import { templatesOf } from '../code/server/actors.js';
23
+ import { doorDecorOf, templatesOf } from '../code/server/actors.js';
20
24
  import check from './check.mjs';
21
25
 
22
26
  // Real engine load/sync. Only Vite discovery is replaced, as in test-tiers-render.
@@ -51,6 +55,11 @@ const { initialFiles } = await import('data:text/javascript,' + encodeURICompone
51
55
  const { SceneRuntime } = await import('../../physics-2d/engine/scene.js');
52
56
  const { syncActors } = await import('../../physics-3d/engine3d/world3d.js');
53
57
  const { installQualityLoad } = await import('../code/client/qualityEntry.js');
58
+ const { canCacheStill } = await import('../../physics-3d/engine3d/stillshadows.js');
59
+ // The engine's own three (this script resolves hub-game's copy): canCacheStill compares against its prototype.
60
+ // Resolved from engine3d, so a kit-local physics-3d/node_modules copy is the one used.
61
+ const engineThreeCjs = createRequire(new URL('../../physics-3d/engine3d/stillshadows.js', import.meta.url)).resolve('three');
62
+ const engineThree = await import(pathToFileURL(path.join(path.dirname(engineThreeCjs), 'three.module.js')).href);
54
63
  let count = 0;
55
64
  async function test(name, fn) { await fn(); count++; console.log(`ok: ${name}`); }
56
65
  const base = { hub: { contract: 1, title: 'Quality', tiers: true }, server: { maxPlayers: 8 } };
@@ -181,6 +190,44 @@ await test('Low→High measured 8 ms admission slices include sync; downgrade re
181
190
  } finally { undo(); }
182
191
  });
183
192
 
193
+ // castle.xyz's sandboxed frame: the Graphics pick or low mark comes from
194
+ // LocalCache after the constructor's first load has already run as High.
195
+ await test('a remembered Low arriving after a High load: the visit ends as if it had loaded Low; a Low found later keeps its actors', async () => {
196
+ const settle = () => new Promise((go) => setTimeout(go, 0));
197
+ const lateLow = (stored) => {
198
+ const cache = { getText: async (key) => stored[key.slice(CACHE_PREFIX.length)] ?? null, set: async () => {}, remove: async () => {} };
199
+ return adapt('auto', { make: () => makeTiers({ storage: makeCachedStorage(() => cache), clock: () => 101, deviceMemory: 8 }) });
200
+ };
201
+ for (const stored of [{ [MODE_KEY]: '"low"' }, { [TIER_KEY]: JSON.stringify({ tier: 'low', at: 100 }) }]) {
202
+ enable(); const highOnly = deck.highOnly; deck.highOnly = true;
203
+ const undo = lateLow(stored);
204
+ try {
205
+ const data = { actors: [...authored.actors, actor('fancy', { Solid: {} }, { tier: 'high' })] };
206
+ const scene = new SceneRuntime(data, [], {}, {}, 'scenes/main.scene'); scene.three = makeWorld(); syncActors(scene.three, scene, {});
207
+ const q = qualityFor(scene);
208
+ assert.equal(q.tiers.current(), 'high', 'loaded before the stored values came');
209
+ assert.ok(scene.actors.has('decor') && scene.actors.has('fancy'));
210
+ lowerLate(scene, q); assert.ok(scene.actors.has('decor'), 'nothing before they arrive');
211
+ await settle();
212
+ assert.equal(q.tiers.current(), 'low');
213
+ lowerLate(scene, q); syncActors(scene.three, scene, {});
214
+ assert.deepEqual(q.skipped.map((a) => a.id).sort(), ['decor', 'fancy']);
215
+ for (const id of ['decor', 'fancy']) { assert.equal(scene.getActor(id), undefined, id); assert.equal(scene.three.nodes.has(id), false, id); }
216
+ for (const a of authored.actors.filter((a) => a.id !== 'decor')) assert.ok(scene.getActor(a.id), a.id);
217
+ lowerLate(scene, q); assert.equal(q.skipped.length, 2, 'once');
218
+ // High by hand brings them back through the existing queue.
219
+ q.tiers.set('high'); while (q.skipped.length) restoreDecor(scene, q, (s) => syncActors(s.three, s, {}));
220
+ assert.ok(scene.getActor('decor') && scene.getActor('fancy'));
221
+ } finally { undo(); deck.highOnly = highOnly; }
222
+ }
223
+ // A Low picked (or judged) while playing is not a late load: nothing is taken out.
224
+ enable(); const undo = adapt('high');
225
+ try {
226
+ const scene = new SceneRuntime(authored, [], {}, {}, 'scenes/main.scene'); const q = qualityFor(scene);
227
+ q.tiers.set('low'); lowerLate(scene, q); assert.ok(scene.actors.has('decor')); assert.equal(q.skipped.length, 0);
228
+ } finally { undo(); }
229
+ });
230
+
184
231
  await test('players: 2 m hysteresis; party, pad, 10 s chat/emote exemptions; retained state and first-frame/new-node cap', () => {
185
232
  const players = [{ id: 'a', distance: 10 }, { id: 'b', distance: 9 }, { id: 'party', distance: 100, exempt: true }];
186
233
  assert.deepEqual([...choosePlayers(players, 1)], ['party', 'b']); assert.deepEqual([...choosePlayers(players, 1, new Set(['a']))], ['party', 'a']);
@@ -203,6 +250,67 @@ await test('players: 2 m hysteresis; party, pad, 10 s chat/emote exemptions; ret
203
250
  q.tiers.set('high'); qualityPlayers(scene, q, 22002); assert.equal(replacement.visible, true);
204
251
  });
205
252
 
253
+ await test('the Low cull hook is installed only while Low culls and gives back the exact previous callback', () => {
254
+ enable({ players: 1 }); clearState();
255
+ const actors = [actor('self', { Transform: { x: 0, z: 0 }, Player: {} }), actor('a', { Transform: { x: 8, z: 0 } }), actor('b', { Transform: { x: 9, z: 0 } })];
256
+ const scene = new SceneRuntime({ actors }, [], {}, {}, 'scene'); scene.three = makeWorld();
257
+ scene.multiplayer = { net: { selfId: () => 'me' }, avatars: { actors: new Map([['me', 'self'], ['a', 'a'], ['b', 'b']]) } };
258
+ const root = scene.three.scene = new engineThree.Scene(), original = root.onBeforeRender;
259
+ const renderer = { shadowMap: { render() {} }, capabilities: {}, renderBufferDirect() {} };
260
+ const q = makeQualityVisit(makeTier('high')()); filterQualityScene(scene, scene.data, q);
261
+ qualityPlayers(scene, q, 0); assert.equal(root.onBeforeRender, original); assert.equal(canCacheStill(renderer, root), true);
262
+ q.tiers.set('low'); qualityPlayers(scene, q, 1); syncActors(scene.three, scene, {});
263
+ assert.notEqual(root.onBeforeRender, original); assert.equal(canCacheStill(renderer, root), false);
264
+ root.onBeforeRender(); assert.equal(scene.three.nodes.get('b').node.visible, false);
265
+ q.tiers.set('high'); qualityPlayers(scene, q, 2);
266
+ assert.equal(root.onBeforeRender, original, 'High gives the original back'); assert.equal(canCacheStill(renderer, root), true);
267
+ assert.equal(scene.three.nodes.get('b').node.visible, true);
268
+ // A callback wrapped over ours (a live disguise) keeps it; ours is inert, and unhooks once on top again.
269
+ let calls = 0;
270
+ const previous = function () {assert.equal(this, root); calls++;};
271
+ root.onBeforeRender = previous;
272
+ q.tiers.set('low'); qualityPlayers(scene, q, 3);
273
+ const ours = root.onBeforeRender, above = function (...args) {ours.apply(this, args);};
274
+ root.onBeforeRender = above;
275
+ q.tiers.set('high'); qualityPlayers(scene, q, 4); assert.equal(root.onBeforeRender, above);
276
+ scene.three.nodes.get('b').node.visible = true; above.call(root);
277
+ assert.equal(calls, 1); assert.equal(scene.three.nodes.get('b').node.visible, true, 'the released hook culls nothing');
278
+ root.onBeforeRender = ours; qualityPlayers(scene, q, 5); root.onBeforeRender();
279
+ assert.equal(calls, 2); assert.equal(root.onBeforeRender, previous, 'given back once on top again');
280
+ q.tiers.set('low'); qualityPlayers(scene, q, 6); assert.notEqual(root.onBeforeRender, previous);
281
+ filterQualityScene(scene, scene.data, q); assert.equal(root.onBeforeRender, previous, 'a new visit gives it back too');
282
+ });
283
+
284
+ await test('v1.162 copies naming a carer are hidden with that carer and restored with them; others always drawn', () => {
285
+ enable({ players: 1 }); clearState();
286
+ const at = (x) => ({ Transform: { x, z: 0 } });
287
+ const copies = { 'pet-b~1': 'b', 'wear-b~2': 'b', 'pet-a~3': 'a', 'pet-party~4': 'party', 'pet-me~5': 'me', 'post~6': undefined };
288
+ const actors = [actor('self', { ...at(0), Player: {} }), actor('a', at(8)), actor('b', at(9)), actor('party', at(80)),
289
+ ...Object.keys(copies).map((id, i) => actor(id, at(2 + i)))];
290
+ const scene = new SceneRuntime({ actors }, [], {}, {}, 'scene'); scene.three = makeWorld();
291
+ scene.multiplayer = { net: { selfId: () => 'me' }, avatars: { actors: new Map([['me', 'self'], ['a', 'a'], ['b', 'b'], ['party', 'party']]) } };
292
+ hub.spawned = Object.fromEntries(Object.entries(copies).map(([id, carer], i) => [id, { from: id.split('~')[0], x: 2 + i, y: 0, z: 0, rotationY: 0, ...(carer ? { carer } : {}) }]));
293
+ const q = makeQualityVisit(makeTier('low')()); filterQualityScene(scene, scene.data, q); hub.party.members = ['party'];
294
+ const shown = () => Object.fromEntries(Object.keys(copies).map((id) => [id, scene.three.nodes.get(id).node.visible]));
295
+ const all = (visible) => Object.fromEntries(Object.keys(copies).map((id) => [id, visible]));
296
+ qualityPlayers(scene, q, 0); syncActors(scene.three, scene, {}); scene.three.scene.onBeforeRender();
297
+ assert.equal(scene.three.nodes.get('b').node.visible, false);
298
+ assert.deepEqual(shown(), { ...all(true), 'pet-b~1': false, 'wear-b~2': false }, 'a culled carer hides pet and wear; drawn, party, own and carer-less copies stay');
299
+ // A copy built after the cap was chosen never flashes.
300
+ hub.spawned['pet-b~7'] = { from: 'pet-b', x: 9, y: 0, z: 0, rotationY: 0, carer: 'b' };
301
+ qualityPlayers(scene, q, 1); scene.spawnActor(actor('pet-b~7', at(9))); syncActors(scene.three, scene, {});
302
+ scene.three.scene.onBeforeRender(); assert.equal(scene.three.nodes.get('pet-b~7').node.visible, false, 'a newly built copy is hidden before its first draw');
303
+ delete hub.spawned['pet-b~7'];
304
+ // An exempt carer (chatted lately) is drawn with their pet; it ends with the exemption.
305
+ noteQualityInteraction(scene, 'b', 2); qualityPlayers(scene, q, 2); assert.deepEqual(shown(), all(true));
306
+ qualityPlayers(scene, q, 10003); assert.equal(shown()['pet-b~1'], false);
307
+ // Uncull: b nearer than a takes the slot; a's pet goes with a.
308
+ scene.getActor('b').components.Transform.x = 3; qualityPlayers(scene, q, 10004);
309
+ assert.deepEqual(shown(), { ...all(true), 'pet-a~3': false });
310
+ q.tiers.set('high'); qualityPlayers(scene, q, 10005); assert.deepEqual(shown(), all(true), 'High hides none');
311
+ hub.spawned = {};
312
+ });
313
+
206
314
  await test('first-frame cap also removes shared model instances and restores them on High', () => {
207
315
  enable({ players: 1 }); clearState(); const undo = adapt('low');
208
316
  try {
@@ -227,6 +335,27 @@ await test('labels: nearest N, zero and party exemption; pointers never enter th
227
335
  assert.deepEqual(capLabels(labels, 0, (a) => a.d, (a) => a.id === 'party').map((a) => a.id), ['party']); assert.deepEqual(capLabels([...labels, ...pointers], 0, (a) => a.d, (a) => a.id === 'party').map((a) => a.id), ['party', 'quest', 'door', 'home']);
228
336
  });
229
337
 
338
+ await test('budgets order nearer first, then id by code unit; no point (Infinity or NaN) sorts last, consistently', () => {
339
+ assert.equal(nearerThenId(1, 2, 'b', 'a'), -1); assert.equal(nearerThenId(2, 2, 'b', 'a'), 1); assert.equal(nearerThenId(2, 2, 'a', 'a'), 0);
340
+ // Code-unit order, not the locale's: uppercase before lowercase, '-' before letters.
341
+ assert.equal(nearerThenId(0, 0, 'B', 'a'), -1); assert.equal(nearerThenId(0, 0, 'role:Z', 'place:a'), 1);
342
+ for (const none of [Infinity, NaN, undefined]) {
343
+ assert.equal(nearerThenId(none, 500, 'a', 'z'), 1); assert.equal(nearerThenId(500, none, 'z', 'a'), -1);
344
+ assert.equal(nearerThenId(none, Infinity, 'b', 'a'), 1); assert.equal(nearerThenId(none, NaN, 'a', 'b'), -1);
345
+ }
346
+ // Ties at the cap pick by id; unplaced items lose to every placed one whatever their ids, and among
347
+ // themselves by id, from any input order (a NaN-returning comparator left this to the engine).
348
+ const items = [{ id: 'place:b', d: Infinity }, { id: 'place:z', d: 3 }, { id: 'place:a', d: NaN }, { id: 'mark:9', d: 3 },
349
+ { id: 'place:c', d: Infinity }, { id: 'Role:1', d: 3 }];
350
+ const want = ['place:z', 'mark:9', 'Role:1', 'place:a'];
351
+ for (let i = 0; i < 6; i++) {
352
+ const turned = [...items.slice(i), ...items.slice(0, i)];
353
+ assert.deepEqual(capLabels(turned, 4, (a) => a.d).map((a) => a.id).sort(), [...want].sort());
354
+ assert.deepEqual(capLabels(turned, 5, (a) => a.d).map((a) => a.id).sort(), [...want, 'place:b'].sort());
355
+ }
356
+ assert.deepEqual([...choosePlayers([{ id: 'n', distance: NaN }, { id: 'b', distance: 4 }, { id: 'a', distance: 4 }], 2)], ['a', 'b']);
357
+ });
358
+
230
359
  // Run the production nearLabels method so exemptions and anchor metadata are
231
360
  // checked at the seam where render ids are generated, after real admission.
232
361
  function nearLabelFixture(placed, actors, { defaults = true, attention = {}, padOccupancy = false } = {}) {
@@ -310,6 +439,148 @@ await test('speech rendering ids rank by actor anchor: a 2 m line beats a 10 m s
310
439
  }
311
440
  });
312
441
 
442
+ // Run hub.js's own Low cap block and mark/role push against a stub frame, so
443
+ // the wiring (not just the helpers) is what the High/no-quality checks compare.
444
+ function tagFrameFixture() {
445
+ const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
446
+ const a = source.indexOf(' if (Hub.deck.quality) {\n const quality = lowQuality(scene);');
447
+ const b = source.indexOf(' worldLabelCount = labels.length;', a);
448
+ const c = source.indexOf(' if (qualityTagItems) {', b);
449
+ const d = source.indexOf(' labels.push(...this.idle', c);
450
+ const m = source.indexOf(' markItems(scene, local, cam, view) {');
451
+ const markItems = source.slice(m, source.indexOf('\n measure(', m)).trim();
452
+ assert.ok(a > 0 && b > a && c > b && d > c && m > 0);
453
+ const project = (_cam, x, y, z) => ({ x: 100 + x * 10, y: 300 - y * 10 + z });
454
+ const make = new Function('Hub', 'lowQuality', 'capWorldLabels', 'qualityTags', 'splitTags', 'cullBeforeLabels', 'qualityFor', 'roleItems', 'project', 'disguiseTags',
455
+ `const owner = { ${markItems} };
456
+ return function (scene, local, lt, cam, view, labels, placed, now) {
457
+ let qualityTagItems = null;
458
+ ${source.slice(a, b).replaceAll('this.markItems', 'owner.markItems')}
459
+ const worldLabelCount = labels.length;
460
+ ${source.slice(c, d).replaceAll('this.markItems', 'owner.markItems')}
461
+ return { labels, worldLabelCount };
462
+ };`);
463
+ return make({ deck, hub }, lowQuality, capWorldLabels, qualityTags, splitTags, cullBeforeLabels, qualityFor, roleItems, project, disguiseTags);
464
+ }
465
+
466
+ await test('v1.168 Low: a culled bystander has no mark or role; marks rank under the labels cap; own exempt; High and no quality unchanged', () => {
467
+ enable({ players: 2, labels: 2 }); clearState();
468
+ const at = (x) => ({ Transform: { x, y: 0, z: 0 } });
469
+ const ids = { me: 'self', a: 'a', b: 'b', c: 'c', party: 'party' };
470
+ const xs = { self: 0, a: 3, b: 9, c: 6, party: 80, sign: 1, far: 5 };
471
+ const actors = new Map(Object.entries(xs).map(([id, x]) => [id, { id, components: at(x) }]));
472
+ const nodes = new Map(Object.values(ids).map((id) => [id, { node: { visible: true, parent: null } }]));
473
+ const scene = { actors, getActor: (id) => actors.get(id), actorWith: () => actors.get('self'), three: { nodes },
474
+ multiplayer: { net: { selfId: () => 'me' }, avatars: { actors: new Map(Object.entries(ids)) } } };
475
+ actors.get('self').components.Player = {};
476
+ const q = makeQualityVisit(makeTier('low')()); filterQualityScene(scene, { actors: [] }, q);
477
+ // Nothing culled yet: the label pass itself must cull this frame. b (9 m)
478
+ // is beyond the two-player cap; party is exempt from it.
479
+ hub.party.members = ['party'];
480
+ assert.equal(q.culled.size, 0);
481
+ for (const id of Object.keys(ids)) {hub.marks[id] = { text: id.toUpperCase(), color: '#ff0000' };}
482
+ for (const id of ['me', 'a', 'b']) {hub.roles.set(id, { label: `Role ${id}`, color: '#00ff00' });}
483
+ const local = actors.get('self');
484
+ const placed = ['sign', 'far'].map((id) => ({ id, at: actors.get(id).components.Transform, label: { text: id }, always: false }));
485
+ const frame = tagFrameFixture();
486
+ const world = () => placed.map(({ id }) => ({ id, x: 0, y: 0, text: id }));
487
+ let clock = 0;
488
+ const run = () => frame(scene, local, local.components.Transform, {}, { w: 1200, h: 600 }, world(), placed, clock += 16);
489
+ const idsOf = (out) => out.labels.map((item) => item.id);
490
+ // labels 2: sign (1 m) and mark:a (3 m, before role:a by id) take the slots;
491
+ // the far sign (5 m) and c's mark (6 m) lose; own and party marks are free.
492
+ let out = run();
493
+ assert.deepEqual(idsOf(out), ['sign', 'mark:me', 'mark:a', 'mark:party', 'role:me']);
494
+ assert.equal(out.worldLabelCount, 1, 'world labels stay first; marks and roles follow them');
495
+ assert.ok(!idsOf(out).some((id) => id.endsWith(':b')), 'culled bystander: no mark, no role');
496
+ assert.ok(q.culled.has('b') && nodes.get('b').node.visible === false, 'culled in the same frame as the labels');
497
+ // The tier system's later pass does not cull again on an unchanged tier
498
+ // (same winners, labels stay in step), but an avatar multiplayer added
499
+ // between the passes, even a nearer one, is hidden until the next frame
500
+ // decides; the incumbents and their labels keep their places.
501
+ const drawn = q.drawn;
502
+ actors.set('d', { id: 'd', components: at(1) }); nodes.set('d', { node: { visible: true, parent: null } });
503
+ scene.multiplayer.avatars.actors.set('d', 'd');
504
+ cullAfterTier(scene, q, clock);
505
+ assert.equal(q.drawn, drawn, 'no second cull this frame');
506
+ assert.ok(q.culled.has('d') && nodes.get('d').node.visible === false, 'a newcomer after the label pass is hidden this frame');
507
+ assert.ok(!q.culled.has('a') && !q.culled.has('c') && nodes.get('a').node.visible === true, 'incumbents keep their places');
508
+ cullAfterTier(scene, q, clock); assert.notEqual(q.drawn, drawn, 'a frame without the label pass culls in the tier system');
509
+ scene.multiplayer.avatars.actors.delete('d'); actors.delete('d'); nodes.delete('d');
510
+ run();
511
+ // Cap winners change: b walks to 2 m, c (6 m) loses its slot; c's mark goes this frame.
512
+ actors.get('b').components.Transform.x = 2;
513
+ out = run();
514
+ assert.ok(q.culled.has('c') && !q.culled.has('b'));
515
+ assert.ok(idsOf(out).includes('mark:b') && !idsOf(out).includes('mark:c'), 'labels follow the new winners at once');
516
+ actors.get('b').components.Transform.x = 9; run(); run();
517
+ assert.ok(q.culled.has('b'));
518
+ deck.quality.low.labels = 0;
519
+ assert.deepEqual(idsOf(run()), ['mark:me', 'mark:party', 'role:me'], 'labels 0: only own and party');
520
+ deck.quality.low.labels = 4;
521
+ assert.deepEqual(idsOf(run()), ['sign', 'far', 'mark:me', 'mark:a', 'mark:party', 'role:me', 'role:a'], 'nearest first: c (6 m) is fifth');
522
+ // A drawn bystander's mark beats a farther world label.
523
+ deck.quality.low.labels = 1; actors.get('sign').components.Transform.x = 4;
524
+ assert.deepEqual(idsOf(run()), ['mark:me', 'mark:a', 'mark:party', 'role:me'], 'mark:a (3 m) beats the sign at 4 m');
525
+ actors.get('sign').components.Transform.x = 1;
526
+ // High and a deck without hub.quality: the exact list as before v1.168.
527
+ const legacy = () => [...world(), ...['me', 'a', 'b', 'c', 'party'].map((id) => `mark:${id}`), ...['me', 'a', 'b'].map((id) => `role:${id}`)];
528
+ const before = legacy();
529
+ // The tier system restores every avatar once the tier moves to High.
530
+ q.tiers.set('high'); cullAfterTier(scene, q, clock);
531
+ out = run(); assert.deepEqual(idsOf(out), before.map((item) => item.id ?? item)); assert.equal(out.worldLabelCount, 2);
532
+ const high = out.labels;
533
+ delete deck.quality; q.tiers.set('low');
534
+ assert.deepEqual(run().labels, high, 'no hub.quality: byte-identical to High');
535
+ // Helpers alone: no tags leaves capWorldLabels exactly as before.
536
+ enable({ labels: 1 });
537
+ const items = world();
538
+ const none = { list: [], of: new Map(), all: [], kept: [], pool: [] };
539
+ assert.deepEqual(capWorldLabels(items, placed, { x: 0, z: 0 }, 1, new Set(), none), capWorldLabels(items, placed, { x: 0, z: 0 }, 1, new Set()));
540
+ q.culled = new Set(['b']);
541
+ const tags = qualityTags(scene, local, [{ id: 'mark:b' }, { id: 'mark:me' }], []);
542
+ assert.deepEqual(tags.list.map((tag) => [tag.item.id, tag.actorId, tag.own]), [['mark:me', 'self', true]]);
543
+ const first = tags.list[0];
544
+ assert.equal(qualityTags(scene, local, [{ id: 'mark:me' }], []), tags, 'the visit reuses its tag buffers');
545
+ assert.equal(tags.list[0], first, 'and its descriptors');
546
+ hub.party.members = []; hub.roles.clear(); clearState();
547
+ });
548
+
549
+ await test('Low: a culled bystander\'s name tag is hidden with its body and restored with it; own tag, High and no quality unchanged', () => {
550
+ enable({ players: 1, labels: 0 }); clearState();
551
+ const at = (x) => ({ Transform: { x, y: 0, z: 0 } });
552
+ const ids = { me: 'self', a: 'a', b: 'b' };
553
+ const actors = new Map(Object.entries({ self: 0, a: 3, b: 9 }).map(([id, x]) => [id, { id, components: at(x) }]));
554
+ actors.get('self').components.Player = {};
555
+ const nodes = new Map(Object.values(ids).map((id) => [id, { node: { visible: true, parent: null } }]));
556
+ const tag = () => ({ sprite: { visible: true, material: { visible: true } } });
557
+ const tags = new Map([['self', tag()], ['a', tag()], ['b', tag()]]);
558
+ const scene = { actors, getActor: (id) => actors.get(id), actorWith: () => actors.get('self'), three: { nodes },
559
+ multiplayer: { net: { selfId: () => 'me' }, avatars: { actors: new Map(Object.entries(ids)), tags } } };
560
+ const q = makeQualityVisit(makeTier('low')()); filterQualityScene(scene, { actors: [] }, q);
561
+ // Drawn: three.js renders a sprite only when it and its material are visible.
562
+ const shown = () => Object.fromEntries([...tags].map(([id, t]) => [id, t.sprite.visible && t.sprite.material.visible]));
563
+ qualityPlayers(scene, q, 0);
564
+ assert.equal(nodes.get('b').node.visible, false);
565
+ assert.deepEqual(shown(), { self: true, a: true, b: false }, 'labels 0 does not touch a drawn body\'s tag');
566
+ // The name passes own sprite.visible: rewriting it after the cull does not
567
+ // draw the tag. A replaced sprite (new text) is hidden at the next pass.
568
+ tags.get('b').sprite.visible = true; assert.equal(shown().b, false);
569
+ tags.set('b', tag()); applyPlayerVisibility(scene, q); assert.equal(shown().b, false, 'a replaced tag is hidden too');
570
+ // Winners change: b walks nearer than a; a's tag goes, b's comes back.
571
+ actors.get('b').components.Transform.x = 0.5; qualityPlayers(scene, q, 1);
572
+ assert.deepEqual(shown(), { self: true, a: false, b: true });
573
+ // A name pass that hides a culled tag after the cull (the town fade, crowd
574
+ // names) keeps it hidden when the cull lets go on High.
575
+ actors.get('b').components.Transform.x = 9; qualityPlayers(scene, q, 2); tags.get('b').sprite.visible = false;
576
+ q.tiers.set('high'); qualityPlayers(scene, q, 3);
577
+ assert.deepEqual(shown(), { self: true, a: true, b: false }, 'High leaves the name passes\' decision');
578
+ tags.get('b').sprite.visible = true;
579
+ delete deck.quality; q.tiers.set('low'); qualityPlayers(scene, q, 4);
580
+ assert.deepEqual(shown(), { self: true, a: true, b: true }, 'no hub.quality: no tag hidden');
581
+ clearState();
582
+ });
583
+
313
584
  await test('spawns: nearest decor only, cap zero, moving into range, gameplay intact, opt-in metadata', () => {
314
585
  const templates = { scenery: { ...actor('t').components, decor: true }, gem: actor('gem', { Pickup: {} }).components };
315
586
  const copies = { far: { from: 'scenery', x: 20, z: 0 }, near: { from: 'scenery', x: 1, z: 0 }, gem: { from: 'gem', x: 100, z: 0 } };
@@ -320,13 +591,44 @@ await test('spawns: nearest decor only, cap zero, moving into range, gameplay in
320
591
  assert.equal(templatesOf(h).t.decor, undefined); h.qualityDecor = new Set(['t']); assert.equal(templatesOf(h).t.decor, true);
321
592
  const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
322
593
  const method = source.slice(source.indexOf(' applySpawns(scene) {'), source.indexOf('\n // Turning displays', source.indexOf(' applySpawns(scene) {')));
323
- const apply = new Function('Hub', 'lowQuality', 'qualitySpawnIds', 'addSpinner', `return function ${method.trim()}`)({ deck, hub }, lowQuality, qualitySpawnIds, () => null);
594
+ const apply = new Function('Hub', 'spawnLowQuality', 'withDecorTemplates', 'qualitySpawnIds', 'addSpinner', `return function ${method.trim()}`)({ deck, hub }, spawnLowQuality, withDecorTemplates, qualitySpawnIds, () => null);
324
595
  enable({ spawned: 1 }); const scene = new SceneRuntime({ actors: [actor('self', { Player: {}, Transform: { x: 0, z: 0 } })] }, [], {}, {}, 'scene');
325
596
  filterQualityScene(scene, scene.data, makeQualityVisit(makeTier('low')())); hub.spawnTemplates = templates; hub.spawned = copies;
326
597
  const owner = { spawnedHere: new Set(), stash: new Map(), tinted: new Map() };
327
598
  apply.call(owner, scene); assert.ok(scene.getActor('gem')); assert.ok(scene.getActor('near')); assert.equal(scene.getActor('far'), undefined);
328
599
  assert.equal(Object.hasOwn(scene.getActor('near').components, 'decor'), false);
329
600
  scene.actorWith('Player').components.Transform.x = 20; apply.call(owner, scene); assert.ok(scene.getActor('far')); assert.equal(scene.getActor('near'), undefined); assert.ok(scene.getActor('gem'));
601
+
602
+ // v1.197: a game behind the Town's door (content) names its decor templates
603
+ // apart; the Town's Low cap counts their copies there too.
604
+ const content = new SceneRuntime({ actors: [actor('self', { Player: {}, Transform: { x: 0, z: 0 } })] }, [], {}, {}, 'scene');
605
+ const low = makeQualityVisit(makeTier('low')()); filterQualityScene(content, content.data, low); content.content = true;
606
+ hub.spawnTemplates = { scenery: actor('scenery').components, gem: templates.gem };
607
+ hub.spawned = { 'scenery~1': { from: 'scenery', x: 0, z: 0 }, 'gem~1': { from: 'gem', x: 0, z: 0 } };
608
+ const run = (cap, decor) => {
609
+ enable({ spawned: cap }); hub.decorTemplates = new Set(decor);
610
+ const own = { spawnedHere: new Set(), stash: new Map(), tinted: new Map() };
611
+ for (const id of Object.keys(hub.spawned)) content.despawnActor?.(id);
612
+ apply.call(own, content);
613
+ return { scenery: Boolean(content.getActor('scenery~1')), gem: Boolean(content.getActor('gem~1')) };
614
+ };
615
+ assert.deepEqual(run(0, ['scenery']), { scenery: false, gem: true });
616
+ assert.deepEqual(run(1, ['scenery']), { scenery: true, gem: true });
617
+ assert.equal(Object.hasOwn(content.getActor('scenery~1').components, 'decor'), false);
618
+ assert.deepEqual(run(0, []), { scenery: true, gem: true }); // nothing named: every copy, as before
619
+ low.tiers = makeTier('high')(); assert.deepEqual(run(0, ['scenery']), { scenery: true, gem: true });
620
+ delete deck.quality; hub.decorTemplates = new Set(['scenery']); assert.equal(spawnLowQuality(content), null); // no Town quality: as before
621
+ assert.equal(withDecorTemplates(hub.spawnTemplates, new Set()), hub.spawnTemplates);
622
+ hub.spawnTemplates = {}; hub.spawned = {}; hub.decorTemplates = new Set();
623
+ });
624
+
625
+ await test('v1.197 server: a deck without quality names its live decor templates apart; one with quality marks them in place', () => {
626
+ const live = (actors) => ({ spawned: new Map([['a~1', { from: 'a' }], ['b~1', { from: 'b' }]]), actors });
627
+ const h = live([actor('a'), actor('b', { Pickup: {} })]);
628
+ assert.deepEqual(doorDecorOf(h), []);
629
+ h.doorDecor = new Set(['a']); assert.deepEqual(doorDecorOf(h), ['a']); assert.equal(templatesOf(h).a.decor, undefined);
630
+ h.spawned.delete('a~1'); assert.deepEqual(doorDecorOf(h), []);
631
+ const q = live([actor('a')]); q.qualityDecor = new Set(['a']); assert.deepEqual(doorDecorOf(q), []); assert.equal(templatesOf(q).a.decor, true);
330
632
  });
331
633
 
332
634
  await test('publish check: literal decor refs refused, spawn templates exempt, no-decor warning only with quality', async () => {
@@ -366,7 +668,7 @@ await test('far minds: cadence with near/talk-range/conversation/High/absent exe
366
668
  q.tiers.set('low'); delete deck.quality; assert.equal(mindDue(scene, npc, me, null, 251), true);
367
669
  });
368
670
 
369
- await test('quality telemetry is deferred: local diagnostics retain it, wire and recorded measurements stay legacy', () => {
671
+ await test('v1.178 quality telemetry: active mode is optional and measurements stay legacy', () => {
370
672
  const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
371
673
  const start = source.indexOf(' measure(scene, mp, now) {');
372
674
  const method = source.slice(start, source.indexOf('\n dispose() {', start));
@@ -377,7 +679,7 @@ await test('quality telemetry is deferred: local diagnostics retain it, wire and
377
679
  const sent = [], net = { send: (message) => sent.push(message) };
378
680
  setFpsTelemetry(net, { scene: 'scene' });
379
681
  const scene = {}, mp = { net, avatars: { actors: new Map([['a', 'body']]) } };
380
- const system = { scenePath: 'scene', fpsTier: 1, stats: false };
682
+ const system = { scenePath: 'scene', fpsTier: 1, fpsQuality: quality ?? undefined, stats: false };
381
683
  measure.call(system, scene, mp, 0); measure.call(system, scene, mp, 1000); system.fpsTelemetry.leave(); system.fpsTelemetry.dispose();
382
684
  return sent[0];
383
685
  };
@@ -386,13 +688,14 @@ await test('quality telemetry is deferred: local diagnostics retain it, wire and
386
688
  for (const quality of ['skip', 'hide']) {
387
689
  const message = record(quality);
388
690
  assert.equal(makeTier('low')().handle.quality, quality, 'quality remains available at __hub.tier.quality');
389
- assert.equal(JSON.stringify(message), JSON.stringify(legacy), 'no unsupported field or measurement repacking');
691
+ const { quality: mode, ...measurements } = message;
692
+ assert.equal(mode, quality);
693
+ assert.equal(JSON.stringify(measurements), JSON.stringify(legacy), 'no measurement repacking');
390
694
  const calls = [], h = { manifest: { quality: {} }, sim: { timeMs: 60000 }, place: { analytics: true, fpsTelemetry: { scene: 'scene' } },
391
695
  players: new Map([['p', { arrived: true }]]), session: { hub: { track: (_id, data) => { calls.push(data); return true; } } } };
392
696
  const session = { players: [{ playerId: 'p' }] };
393
- assert.equal(fps(h, session, session.players[0], { ...message, quality }), false, 'server rejects unsupported quality field');
394
697
  assert.equal(fps(h, session, session.players[0], message), true);
395
- assert.deepEqual(calls[0], { kind: 26, subject: 1, value: message.median * 4096 + message.p10, result: 2, flags: 0 }, 'leave flags for Ghost attribution');
698
+ assert.deepEqual(calls[0], { kind: 26, subject: 1, value: message.median * 4096 + message.p10, result: 2, flags: 0, quality: quality === 'hide' ? 1 : 2 }, 'quality has its own arg; leave flags for Ghost attribution');
396
699
  }
397
700
  });
398
701
  delete deck.quality; clearState(); console.log(`test-quality: ${count} passed`);