castle-web-cli 0.4.239 → 0.4.241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +163 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +6 -3
  16. package/dist/init.js +24 -2
  17. package/dist/multiplayerDoc.d.ts +1 -1
  18. package/dist/multiplayerDoc.js +2 -0
  19. package/dist/platformDoc.js +3 -2
  20. package/dist/playPagePolicy.js +5 -1
  21. package/dist/resetLeaderboards.d.ts +8 -1
  22. package/dist/resetLeaderboards.js +43 -8
  23. package/dist/roomLogs.d.ts +1 -0
  24. package/dist/roomLogs.js +30 -6
  25. package/dist/save-deck.d.ts +32 -2
  26. package/dist/save-deck.js +240 -39
  27. package/kits/base/CLAUDE.md +1 -1
  28. package/kits/base/castle.json +1 -1
  29. package/kits/base/sdk/README.md +174 -6
  30. package/kits/base/sdk/analytics.d.ts +8 -0
  31. package/kits/base/sdk/analytics.js +92 -0
  32. package/kits/base/sdk/castle.d.ts +5 -1
  33. package/kits/base/sdk/castle.js +2 -0
  34. package/kits/base/sdk/commands.d.ts +48 -0
  35. package/kits/base/sdk/commands.js +1 -0
  36. package/kits/base/sdk/debugConsole.d.ts +17 -0
  37. package/kits/base/sdk/debugConsole.js +154 -0
  38. package/kits/base/sdk/experiments.js +24 -1
  39. package/kits/base/sdk/hostRetry.d.ts +7 -0
  40. package/kits/base/sdk/hostRetry.js +57 -0
  41. package/kits/base/sdk/hub.d.ts +20 -2
  42. package/kits/base/sdk/hub.js +99 -13
  43. package/kits/base/sdk/multiplayer.d.ts +2 -0
  44. package/kits/base/sdk/multiplayer.js +168 -26
  45. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  46. package/kits/base/sdk/reconnectBudget.js +41 -1
  47. package/kits/base/sdk/runtime.js +36 -19
  48. package/kits/base/sdk/server/hub.d.ts +19 -0
  49. package/kits/base/sdk/server/hub.js +12 -0
  50. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  51. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  52. package/kits/base/sdk/server/wrapper.js +26 -1
  53. package/kits/base/sdk/transport.d.ts +2 -1
  54. package/kits/base/sdk/transport.js +35 -0
  55. package/kits/hub-game/CLAUDE.md +66 -19
  56. package/kits/hub-game/code/client/act.js +9 -6
  57. package/kits/hub-game/code/client/actCore.js +26 -6
  58. package/kits/hub-game/code/client/actGateLog.js +36 -0
  59. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  60. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  61. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  62. package/kits/hub-game/code/client/askSurface.js +85 -0
  63. package/kits/hub-game/code/client/askTree.js +51 -0
  64. package/kits/hub-game/code/client/attention.js +31 -6
  65. package/kits/hub-game/code/client/ballot.js +42 -5
  66. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  67. package/kits/hub-game/code/client/ballotTree.js +180 -0
  68. package/kits/hub-game/code/client/catchingUp.js +19 -0
  69. package/kits/hub-game/code/client/celebrate.js +66 -0
  70. package/kits/hub-game/code/client/chrome.js +481 -57
  71. package/kits/hub-game/code/client/companion.js +93 -23
  72. package/kits/hub-game/code/client/companionDress.js +1 -1
  73. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  74. package/kits/hub-game/code/client/cornerTree.js +83 -0
  75. package/kits/hub-game/code/client/decor.js +20 -11
  76. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  77. package/kits/hub-game/code/client/disguise.js +23 -0
  78. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  79. package/kits/hub-game/code/client/dockSurface.js +206 -0
  80. package/kits/hub-game/code/client/dockTree.js +232 -0
  81. package/kits/hub-game/code/client/earned.js +29 -0
  82. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  83. package/kits/hub-game/code/client/emoteTree.js +264 -0
  84. package/kits/hub-game/code/client/farAvatars.js +4 -3
  85. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  86. package/kits/hub-game/code/client/grab.js +121 -50
  87. package/kits/hub-game/code/client/holdShow.js +19 -0
  88. package/kits/hub-game/code/client/hookLayer.js +96 -12
  89. package/kits/hub-game/code/client/hubControls.js +7 -1
  90. package/kits/hub-game/code/client/hudSurface.js +11 -3
  91. package/kits/hub-game/code/client/hudTree.js +7 -4
  92. package/kits/hub-game/code/client/idle.js +21 -3
  93. package/kits/hub-game/code/client/invites.js +24 -3
  94. package/kits/hub-game/code/client/keys.js +15 -0
  95. package/kits/hub-game/code/client/labelsNear.js +8 -1
  96. package/kits/hub-game/code/client/layoutCache.js +57 -8
  97. package/kits/hub-game/code/client/loadingCover.js +53 -4
  98. package/kits/hub-game/code/client/menuIcons.js +15 -0
  99. package/kits/hub-game/code/client/menuSurface.js +102 -0
  100. package/kits/hub-game/code/client/menuTree.js +135 -0
  101. package/kits/hub-game/code/client/modelLook.js +41 -0
  102. package/kits/hub-game/code/client/padCues.js +11 -7
  103. package/kits/hub-game/code/client/padReadability.js +3 -3
  104. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  105. package/kits/hub-game/code/client/pickerTree.js +163 -0
  106. package/kits/hub-game/code/client/pushVisit.js +4 -2
  107. package/kits/hub-game/code/client/quality.js +188 -29
  108. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  109. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  110. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  111. package/kits/hub-game/code/client/rehello.js +75 -0
  112. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  113. package/kits/hub-game/code/client/replay.js +118 -0
  114. package/kits/hub-game/code/client/role.js +3 -0
  115. package/kits/hub-game/code/client/safeLayout.js +441 -56
  116. package/kits/hub-game/code/client/safeStyle.js +13 -10
  117. package/kits/hub-game/code/client/say.js +2 -0
  118. package/kits/hub-game/code/client/soundSurface.js +77 -0
  119. package/kits/hub-game/code/client/soundTree.js +74 -0
  120. package/kits/hub-game/code/client/soundscape.js +12 -9
  121. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  122. package/kits/hub-game/code/client/state.js +67 -1
  123. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  124. package/kits/hub-game/code/client/stuckTree.js +67 -0
  125. package/kits/hub-game/code/client/talk.js +42 -12
  126. package/kits/hub-game/code/client/talkTree.js +4 -2
  127. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  128. package/kits/hub-game/code/client/textAskTree.js +67 -0
  129. package/kits/hub-game/code/client/tiers.js +252 -27
  130. package/kits/hub-game/code/client/together.js +4 -1
  131. package/kits/hub-game/code/client/uiDom.js +86 -8
  132. package/kits/hub-game/code/client/uiTree.js +33 -4
  133. package/kits/hub-game/code/client/vehicle.js +72 -51
  134. package/kits/hub-game/code/client/weakestTier.js +75 -31
  135. package/kits/hub-game/code/client/wear.js +159 -5
  136. package/kits/hub-game/code/client/worldLabels.js +205 -25
  137. package/kits/hub-game/code/companionSpec.js +4 -2
  138. package/kits/hub-game/code/server/act.js +3 -0
  139. package/kits/hub-game/code/server/actGate.js +83 -0
  140. package/kits/hub-game/code/server/actions.js +71 -15
  141. package/kits/hub-game/code/server/actors.js +20 -5
  142. package/kits/hub-game/code/server/analytics.js +35 -3
  143. package/kits/hub-game/code/server/ask.js +39 -3
  144. package/kits/hub-game/code/server/ballot.js +167 -4
  145. package/kits/hub-game/code/server/celebrate.js +64 -0
  146. package/kits/hub-game/code/server/companion.js +17 -2
  147. package/kits/hub-game/code/server/decor.js +11 -2
  148. package/kits/hub-game/code/server/disguise.js +63 -0
  149. package/kits/hub-game/code/server/earned.js +6 -2
  150. package/kits/hub-game/code/server/friendBests.js +13 -4
  151. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  152. package/kits/hub-game/code/server/grab.js +12 -2
  153. package/kits/hub-game/code/server/heldOffers.js +142 -0
  154. package/kits/hub-game/code/server/holdShow.js +98 -0
  155. package/kits/hub-game/code/server/hub.js +991 -72
  156. package/kits/hub-game/code/server/idle.js +110 -9
  157. package/kits/hub-game/code/server/index.js +9 -0
  158. package/kits/hub-game/code/server/labels.js +13 -3
  159. package/kits/hub-game/code/server/manifest.js +94 -6
  160. package/kits/hub-game/code/server/menu.js +26 -3
  161. package/kits/hub-game/code/server/npcs.js +55 -9
  162. package/kits/hub-game/code/server/observe.js +67 -6
  163. package/kits/hub-game/code/server/players.js +14 -2
  164. package/kits/hub-game/code/server/replay.js +135 -0
  165. package/kits/hub-game/code/server/standing.js +7 -3
  166. package/kits/hub-game/code/server/storageLimit.js +4 -1
  167. package/kits/hub-game/code/server/townDay.js +74 -0
  168. package/kits/hub-game/code/server/vehicle.js +3 -0
  169. package/kits/hub-game/code/server/vis.js +26 -4
  170. package/kits/hub-game/code/server/wallet.js +677 -0
  171. package/kits/hub-game/code/server/wear.js +13 -3
  172. package/kits/hub-game/code/server/writerLease.js +191 -0
  173. package/kits/hub-game/code/shared/act.js +1 -1
  174. package/kits/hub-game/code/shared/expression.js +6 -0
  175. package/kits/hub-game/code/shared/replay.js +37 -0
  176. package/kits/hub-game/code/systems/hub.js +429 -55
  177. package/kits/hub-game/docs/analytics.md +16 -2
  178. package/kits/hub-game/docs/contract.md +956 -101
  179. package/kits/hub-game/docs/home-pieces.md +5 -6
  180. package/kits/hub-game/docs/observed-progress.md +49 -1
  181. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  182. package/kits/hub-game/index.html +1 -0
  183. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  184. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  185. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  186. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  187. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  188. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  189. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  190. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  200. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  201. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  202. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  203. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  204. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  205. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  206. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  207. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  208. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  209. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  210. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  211. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  212. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  213. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  214. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  215. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  216. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  217. package/kits/hub-game/package-lock.json +3 -3
  218. package/kits/hub-game/package.json +4 -3
  219. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  220. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  221. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  222. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  223. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  224. package/kits/hub-game/scripts/pack.mjs +89 -23
  225. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  226. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  227. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  228. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  229. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  230. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  231. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  232. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  233. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  234. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  235. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  236. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  237. package/kits/hub-game/scripts/test-analytics.mjs +79 -0
  238. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  239. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  240. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  241. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  242. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  243. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  244. package/kits/hub-game/scripts/test-ballot.mjs +421 -4
  245. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  246. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  247. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  248. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  249. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  250. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  251. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  252. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  253. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  254. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  255. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  256. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  257. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  258. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  259. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  260. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  261. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  262. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  263. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  264. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  265. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  266. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  267. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  268. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  269. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  270. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  271. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  272. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  273. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  274. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  275. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  276. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  277. package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
  278. package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
  279. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  280. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  281. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  282. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  283. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  284. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  285. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  286. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  287. package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
  288. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  289. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  290. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  291. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  292. package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
  293. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  294. package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
  295. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  296. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  297. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  298. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  299. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  300. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  301. package/kits/hub-game/scripts/test-rehello.mjs +242 -3
  302. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  303. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  304. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  305. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  306. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  307. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  308. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  309. package/kits/hub-game/scripts/test-role-client.mjs +2 -1
  310. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  311. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  312. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  313. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  314. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  315. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  316. package/kits/hub-game/scripts/test-standing.mjs +135 -2
  317. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  318. package/kits/hub-game/scripts/test-stuck.mjs +36 -1
  319. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  320. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  321. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  322. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  323. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  324. package/kits/hub-game/scripts/test-together.mjs +11 -0
  325. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  326. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  327. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  328. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  329. package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
  330. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  331. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  332. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  333. package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
  334. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  335. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  336. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  337. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  338. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  339. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
  340. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
  341. package/kits/multiplayer-3d/castle.json +5 -5
  342. package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
  343. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  344. package/kits/multiplayer-3d/code/server/world.js +19 -4
  345. package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
  346. package/kits/multiplayer-3d/package-lock.json +1 -1
  347. package/kits/multiplayer-3d/package.json +2 -1
  348. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  349. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  350. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  351. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
  352. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  353. package/kits/physics-2d/castle.json +2 -2
  354. package/kits/physics-2d/engine/scene.js +10 -2
  355. package/kits/physics-3d/CLAUDE.md +14 -0
  356. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  357. package/kits/physics-3d/castle.json +3 -3
  358. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  359. package/kits/physics-3d/docs/engine-player.md +76 -0
  360. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  361. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  362. package/kits/physics-3d/engine3d/gait.js +16 -8
  363. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  364. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  365. package/kits/physics-3d/engine3d/look.js +110 -17
  366. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  367. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  368. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  369. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  370. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  371. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  372. package/kits/physics-3d/engine3d/optimize.js +20 -9
  373. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  374. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  375. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  376. package/kits/physics-3d/engine3d/world3d.js +211 -17
  377. package/kits/physics-3d/package-lock.json +1 -1
  378. package/kits/physics-3d/package.json +2 -1
  379. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  380. package/kits/physics-3d/scripts/render.mjs +56 -8
  381. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  382. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  383. package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
  384. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  385. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  386. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  387. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  388. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  389. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  390. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  391. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  392. package/kits/physics-3d/systems/physics3d.js +59 -2
  393. package/kits/real-time/castle.json +2 -2
  394. package/kits/real-time/code/client/connection.js +3 -0
  395. package/package.json +2 -2
  396. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -185,6 +185,45 @@ await test('a player out of range cannot open one', async () => {
185
185
  assert.equal(w.sent.at(-1).why, 'far');
186
186
  });
187
187
 
188
+ await test('a press within 1.5 s of the prompt is answered though the body has walked on', async () => {
189
+ // The body sets off at 2.6 m/s from beside a player 3 m away; the press
190
+ // lands after it has left talk range (about 4.3 m), but within the grace.
191
+ const w = world({ turnsAtOnce: 3 });
192
+ w.at('a', 0, 3);
193
+ w.npcs.handle('greeter').walkTo({ x: 0, z: -20 });
194
+ for (let i = 0; i < 5; i++) w.tick(100);
195
+ assert.ok(Math.hypot(w.greeter().p.x, w.greeter().p.z - 3) > 3.5, 'out of talk range at the press');
196
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
197
+ assert.equal(w.sent.at(-1).open, true);
198
+ assert.deepEqual(w.npcs.handle('greeter').talkingWith, ['a']);
199
+ // A turn at the distance it opened at is admitted, not refused as far.
200
+ w.npcs.handle('greeter').stop();
201
+ const t = turn({ speaker: 'a' });
202
+ await w.npcs.onTurn(t);
203
+ assert.equal(t.rejected, null);
204
+ assert.equal(t.sent, 1);
205
+ });
206
+
207
+ await test('a press after the grace, or from a player never in range, is still far', async () => {
208
+ const w = world({ turnsAtOnce: 3 });
209
+ w.at('a', 0, 3);
210
+ w.at('b', 0, 8);
211
+ w.npcs.handle('greeter').walkTo({ x: 0, z: -20 });
212
+ for (let i = 0; i < 5; i++) w.tick(100);
213
+ w.npcs.message({ playerId: 'b' }, { k: 'hub-npc-open', npc: 'greeter' });
214
+ assert.equal(w.sent.at(-1).open, false, 'b never had the prompt');
215
+ assert.equal(w.sent.at(-1).why, 'far');
216
+ for (let i = 0; i < 15; i++) w.tick(100);
217
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
218
+ assert.equal(w.sent.at(-1).open, false, 'the prompt went more than 1.5 s ago');
219
+ assert.equal(w.sent.at(-1).why, 'far');
220
+ // A body standing still answers within talk range only, as before.
221
+ const still = world();
222
+ still.at('a', 0, 3.6);
223
+ still.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
224
+ assert.equal(still.sent.at(-1).why, 'far');
225
+ });
226
+
188
227
  await test('without a mind the place answers, and no turn is admitted', async () => {
189
228
  const w = world({ mind: false });
190
229
  w.at('a', 0, 2);
@@ -2447,6 +2486,62 @@ await test('v1.148: a mind with authored taps hears only those taps, and refuses
2447
2486
  assert.deepEqual(w.lines.filter((l) => l.why === 'authored').map((l) => l.text), ["I'll look myself"]);
2448
2487
  });
2449
2488
 
2489
+ await test('v1.175: a mind\'s authored asks are fallback taps for any other speaker; the place answers them and mind turns still go', async () => {
2490
+ for (const stamp of [{ under13: false }, {}]) {
2491
+ const w = world();
2492
+ w.h.hooks.npcOpening = () => WELCOME;
2493
+ w.h.session.players = [{ playerId: 'a', userId: '101', ...stamp }];
2494
+ w.at('a', 0, 2);
2495
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
2496
+ const opened = w.sent.find((m) => m.k === 'hub-npc' && m.open);
2497
+ assert.deepEqual(opened.fallbackChoices, WELCOME.asks);
2498
+ assert.equal(Object.hasOwn(opened, 'choices'), false, 'typing is not replaced by choices');
2499
+ assert.equal(Object.hasOwn(opened, 'authoredChoices'), false);
2500
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: 'tell me a secret', rid: 'r1' });
2501
+ assert.equal(w.lines.filter((l) => l.why === 'authored').length, 0, 'free text is dropped');
2502
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: ' Show me around ', rid: 'r2' });
2503
+ assert.deepEqual(w.lines.filter((l) => l.why === 'authored').map((l) => l.text), ['Show me around']);
2504
+ assert.ok(w.sent.some((m) => m.k === 'hub-npc-line' && m.why === 'authored' && m.rid === 'r2'));
2505
+ const t = turn({ speaker: 'a', input: 'hello' });
2506
+ await w.npcs.onTurn(t);
2507
+ assert.equal(t.sent, 1, 'an inspected speaker still talks to the mind');
2508
+ }
2509
+ const { authored: _authored, ...plain } = WELCOME;
2510
+ for (const [opening, kid, mind] of [[plain, false, true], [WELCOME, true, true], [WELCOME, false, false]]) {
2511
+ const w = world({ mind });
2512
+ w.h.hooks.npcOpening = () => opening;
2513
+ w.h.session.players = [{ playerId: 'a', userId: '101', under13: kid }];
2514
+ w.at('a', 0, 2);
2515
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
2516
+ const opened = w.sent.find((m) => m.k === 'hub-npc' && m.open);
2517
+ assert.equal(Object.hasOwn(opened, 'fallbackChoices'), false, `no fallback: authored ${opening.authored}, kid ${kid}, mind ${mind}`);
2518
+ }
2519
+ });
2520
+
2521
+ await test('v1.175: a refused inspect shows an adult the authored asks, answered by the place; typing still waits', () => withLogs(() => talkRig({ opening: WELCOME, inspectFailures: [characterRefusal()] }, async (r) => {
2522
+ r.frame();
2523
+ assert.equal(r.typing(), false);
2524
+ assert.deepEqual(r.offered(), WELCOME.asks);
2525
+ assert.equal(r.hint() ?? null, null);
2526
+ r.choose('Show me around'); r.frame(); await r.settle();
2527
+ assert.equal(r.requests.length, 0, 'no mind turn');
2528
+ assert.ok(r.wire.some((m) => m.k === 'hub-npc-say' && m.text === 'Show me around'));
2529
+ assert.ok(r.w.lines.some((l) => l.why === 'authored' && l.text === 'Show me around'), 'the place heard the tap');
2530
+ assert.ok(r.lines.some(([who, text]) => who === 'them' && text === 'line:authored'), 'the place answered');
2531
+ assert.deepEqual(r.offered(), ["I'll look myself"]);
2532
+ assert.equal(r.typing(), false);
2533
+ })));
2534
+
2535
+ await test('v1.175: once the inspect succeeds, authored asks are mind turns as before', () => withLogs(() => talkRig({ opening: WELCOME }, async (r) => {
2536
+ r.frame();
2537
+ assert.equal(r.typing(), true);
2538
+ assert.deepEqual(r.offered(), WELCOME.asks);
2539
+ r.choose('Show me around'); r.frame(); await r.settle();
2540
+ assert.equal(r.requests.length, 1, 'a mind turn');
2541
+ assert.ok(r.requests[0].input.endsWith('Show me around'));
2542
+ assert.ok(!r.wire.some((m) => m.k === 'hub-npc-say'));
2543
+ })));
2544
+
2450
2545
  const LEGACY_CHILD_ASKS = ['What can I do here?', 'Tell me about yourself.', 'Where should I go next?'];
2451
2546
 
2452
2547
  await test('v1.150: under13Choices authored taps lead bundle and legacy choices, without a mind turn', async () => {
@@ -2485,6 +2580,39 @@ await test('v1.150: under13Choices authored taps lead bundle and legacy choices,
2485
2580
  }));
2486
2581
  });
2487
2582
 
2583
+ await test('v1.153: a child whose inspect is refused at a mind with bundle chips taps the canned lines, answered by the place', async () => {
2584
+ await withLogs(() => talkRig({ kid: true, childAsks: bundleAsks.greeter, inspectFailures: [characterRefusal()] }, async (r) => {
2585
+ r.frame();
2586
+ const open = r.w.sent.find((m) => m.k === 'hub-npc' && m.open);
2587
+ assert.deepEqual(open.choices, bundleAsks.greeter.map(({ id, label }) => ({ id, label })));
2588
+ assert.deepEqual(open.fallbackChoices, LEGACY_CHILD_ASKS);
2589
+ assert.equal(r.typing(), false);
2590
+ assert.deepEqual(r.offered(), LEGACY_CHILD_ASKS, 'not an empty row');
2591
+ r.choose(LEGACY_CHILD_ASKS[0]); r.frame(); await r.settle();
2592
+ assert.equal(r.requests.length, 0, 'no mind turn');
2593
+ assert.ok(r.w.lines.some((l) => l.why === 'authored' && l.text === LEGACY_CHILD_ASKS[0]), 'the place heard the tap');
2594
+ assert.ok(r.lines.some(([who, text]) => who === 'them' && text === 'line:authored'), 'the place answered');
2595
+ assert.deepEqual(r.offered(), LEGACY_CHILD_ASKS, 'and may be asked again');
2596
+ }));
2597
+ // A place with no line for it: the kit's refused line, never silence.
2598
+ const w = world({ childAsks: bundleAsks.greeter });
2599
+ w.h.hooks.npcLine = () => null;
2600
+ w.h.session.players = [{ playerId: 'a', userId: '101', under13: true }];
2601
+ w.at('a', 0, 2);
2602
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
2603
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: 'free words', rid: 'c1' });
2604
+ w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: LEGACY_CHILD_ASKS[1], rid: 'c2' });
2605
+ assert.deepEqual(w.sent.filter((m) => m.k === 'hub-npc-line').map(({ text, why, rid }) => ({ text, why, rid })), [{ text: 'Rowan smiles and nods.', why: 'authored', rid: 'c2' }]);
2606
+ // Bundle chip turns are still admitted; an inspected child gets the chips.
2607
+ const t = turn({ speaker: 'a', input: `choice:${bundleAsks.greeter[0].id}` });
2608
+ await w.npcs.onTurn(t);
2609
+ assert.equal(t.sent, 1);
2610
+ await withLogs(() => talkRig({ kid: true, childAsks: bundleAsks.greeter }, async (r) => {
2611
+ r.frame();
2612
+ assert.deepEqual(r.offered(), bundleAsks.greeter.map(({ id, label }) => ({ id, label })));
2613
+ }));
2614
+ });
2615
+
2488
2616
  await test('v1.150: under13Choices mind-less NPC keeps only the three legacy choices', async () => {
2489
2617
  const w = world({ mind: false });
2490
2618
  w.h.place.under13Choices = true;
@@ -44,6 +44,8 @@ const spawn = { id: 'spawn', components: {
44
44
  Player: {}, Transform: { x: 0, y: 1, z: 0 },
45
45
  Shape: { kind: 'capsule', height: 1.4, radius: 0.35 },
46
46
  } };
47
+ // v1.165: a car look, for the driving cases.
48
+ const kart = { id: 'kart', components: { Model: { file: 'kart.pxmodel' }, Transform: { x: -50, y: 0, z: -50 } } };
47
49
  const door = { id: 'door', components: {
48
50
  HubDoor: { id: 'race', to: 'race' }, Transform: { x: 30, y: 1, z: 0 },
49
51
  } };
@@ -59,19 +61,21 @@ async function test(name, fn) {
59
61
 
60
62
  // A town with one player, arrived and settled, ticked by hand. `hooks` are the
61
63
  // place's own; `ctx` is its `hub`.
62
- async function boot({ hooks = {}, use = true, hub = {} } = {}) {
63
- globalThis.__observedActors = [spawn, door];
64
+ async function boot({ hooks = {}, use = true, hub = {}, others = [] } = {}) {
65
+ globalThis.__observedActors = [spawn, door, kart];
64
66
  const sim = await World.createSimulation();
65
67
  Players.addPlayer(sim, 'p1');
68
+ for (const id of others) {Players.addPlayer(sim, id);}
66
69
  const clock = { wall: 1_000_000 };
67
70
  const engine = { createBody: World.createBody, removeActor: World.removeActor, maxSpeed: () => 12, wallNow: () => clock.wall };
68
71
  let ctx;
69
72
  const h = layer({ ...config, hub: { ...config.hub, ...hub } }, { ...hooks, ready(hub) { ctx = hub; hooks.ready?.(hub); } }, {}, () => true, () => ({}), null, engine);
70
- const session = { sessionId: 'dev:observed', players: [{ playerId: 'p1', userId: '101', username: 'ada', isAnonymous: false }], send() {}, broadcast() {} };
73
+ const session = { sessionId: 'dev:observed', players: [{ playerId: 'p1', userId: '101', username: 'ada', isAnonymous: false }, ...others.map((id, i) => ({ playerId: id, userId: `${102 + i}`, username: `u${i}`, isAnonymous: false }))], send() {}, broadcast() {} };
71
74
  h.sceneFor(session);
72
75
  h.ready(sim);
73
76
  const b = { sim, h, session, ctx, clock, entry: () => sim.players.get('p1'), origin: null };
74
77
  h.message(session, { playerId: 'p1' }, { k: 'hub-hello', avatar: 1 });
78
+ for (const id of others) {h.message(session, { playerId: id }, { k: 'hub-hello', avatar: 1 });}
75
79
  tick(b);
76
80
  if (use) {
77
81
  // Observation starts here: a reset where the body stands, from now.
@@ -79,6 +83,7 @@ async function boot({ hooks = {}, use = true, hub = {} } = {}) {
79
83
  }
80
84
  // The client agrees with where the arrival put it, which ends the settle.
81
85
  report(b, here(b));
86
+ for (const id of others) {report(b, { ...sim.players.get(id).at }, id);}
82
87
  tick(b);
83
88
  return b;
84
89
  }
@@ -742,4 +747,167 @@ await test('a tuned player gets their own allowance; an absent tick adds nothing
742
747
  assert.ok(b.ctx.dwell('p1', 'goal').ms > ms);
743
748
  }));
744
749
 
750
+
751
+ // --- v1.165: drivers ------------------------------------------------------------
752
+
753
+ const car = (speed = 12, extra = {}) => ({ look: 'kart', speed, reverse: 4, ...extra });
754
+
755
+ await test('v1.165: a driver\'s allowance is their car\'s; 12 m/s driving is funded, enters and earns travel', () => withBoot({}, (b) => {
756
+ assert.equal(b.ctx.observed('p1').speed, 6 * 1.25, 'walking: the walker\'s');
757
+ assert.equal(b.ctx.drive('p1', car(12)), true);
758
+ tick(b);
759
+ assert.equal(b.ctx.observed('p1').speed, 12 * 1.25, 'driving: max(speed, reverse) x 1.25');
760
+ b.ctx.station('goal', station(40, 5));
761
+ stand(b, 500);
762
+ for (const every of [50, 100, 200]) {
763
+ const oks = [];
764
+ const travel0 = b.ctx.observed('p1').travel;
765
+ const from = here(b);
766
+ walk(b, { x: from.x > 20 ? 0 : 40, y: from.y, z: 0 }, { speed: 12, every, after: 300, each: () => oks.push(b.ctx.observed('p1').ok) });
767
+ assert.ok(oks.every(Boolean), `ok throughout at ${every} ms`);
768
+ const credited = b.ctx.observed('p1').travel - travel0;
769
+ assert.ok(credited > 39, `credited ${credited} of 40 m at ${every} ms`);
770
+ }
771
+ walk(b, { x: 30, y: here(b).y, z: 0 }, { speed: 12 });
772
+ walk(b, { x: 40, y: here(b).y, z: 0 }, { speed: 12, after: 300 });
773
+ assert.equal(b.ctx.dwell('p1', 'goal').entered, true, 'a car enters a station');
774
+ // A tune does not move a driver's allowance; it applies on getting out.
775
+ b.ctx.tune('p1', { speed: 2 });
776
+ tick(b);
777
+ assert.equal(b.ctx.observed('p1').speed, 12 * 1.25);
778
+ // The car's larger of speed and reverse.
779
+ b.ctx.drive('p1', { look: 'kart', speed: 3, reverse: 5 });
780
+ tick(b);
781
+ assert.equal(b.ctx.observed('p1').speed, 5 * 1.25);
782
+ }));
783
+
784
+ await test('v1.165: a driver\'s credit is capped at the car\'s: stuffing past it never enters', () => withBoot({}, (b) => {
785
+ b.ctx.drive('p1', car(12));
786
+ const start = here(b);
787
+ b.ctx.station('goal', station(start.x + 10, 1.5));
788
+ stand(b, 2000);
789
+ // 17 in-bound reports in one tick: 10.2 m, beyond the 6.3 m cap.
790
+ for (let i = 1; i <= 17; i += 1) {
791
+ report(b, { x: start.x + 0.6 * i, y: start.y, z: start.z });
792
+ }
793
+ assert.ok(here(b).x - start.x > 10, 'setPose took them');
794
+ const travel = b.ctx.observed('p1').travel;
795
+ tick(b);
796
+ assert.equal(b.ctx.dwell('p1', 'goal').entered, false);
797
+ assert.equal(b.ctx.observed('p1').travel, travel, 'unfunded: no travel');
798
+ assert.equal(b.ctx.observed('p1').ok, true, 'adopted, not rejected');
799
+ }));
800
+
801
+ await test('v1.165: getting in carries no more than the walker\'s credit, and the switch tick fills at the walker\'s rate', () => withBoot({}, (b) => {
802
+ stand(b, 2000);
803
+ const start = here(b);
804
+ const travel = b.ctx.observed('p1').travel;
805
+ assert.equal(b.ctx.drive('p1', car(12)), true);
806
+ // The walker's full credit (3.3 m) plus one 50 ms tick at the walker's
807
+ // 7.5 m/s (0.375 m) is 3.675 m. The car's rate would make it 3.75 m.
808
+ const d = 3.72;
809
+ for (let i = 1; i <= 7; i += 1) {
810
+ report(b, { x: start.x + (d * i) / 7, y: start.y, z: start.z });
811
+ }
812
+ tick(b);
813
+ const o = b.ctx.observed('p1');
814
+ assert.equal(o.speed, 15);
815
+ assert.equal(o.ok, true);
816
+ assert.equal(o.travel, travel, 'unfunded: the switch bought no credit');
817
+ assert.ok(Math.abs(o.at.x - (start.x + d)) < 1e-6, 'adopted');
818
+ }));
819
+
820
+ await test('v1.165: getting out is a reset and puts the walker\'s allowance back', () => withBoot({}, (b) => {
821
+ b.ctx.drive('p1', car(12));
822
+ stand(b, 1000);
823
+ walk(b, { x: 20, y: here(b).y, z: 0 }, { speed: 12 });
824
+ stand(b, 1000);
825
+ assert.ok(b.ctx.observed('p1').travel > 19);
826
+ assert.equal(b.ctx.drive('p1', null), true);
827
+ assert.equal(b.ctx.observed('p1').ok, false, 'the get-out placement invalidates at once');
828
+ tick(b);
829
+ const o = b.ctx.observed('p1');
830
+ assert.equal(o.ok, true);
831
+ assert.equal(o.travel, 0);
832
+ assert.equal(o.speed, 6 * 1.25);
833
+ // Car speed on foot now outruns the credit and never enters.
834
+ report(b, here(b));
835
+ b.ctx.station('goal', station(here(b).x - 20, 1.5));
836
+ stand(b, 1000);
837
+ let entered = false;
838
+ walk(b, { x: here(b).x - 20, y: here(b).y, z: here(b).z }, { speed: 12, every: 100, after: 300, each: () => { entered ||= b.ctx.dwell('p1', 'goal').entered; } });
839
+ assert.equal(entered, false);
840
+ }));
841
+
842
+ await test('v1.165: a rider is placed on their seat each tick and earns nothing from riding', async () => {
843
+ const reads = [];
844
+ await withBoot({ others: ['p2'], hooks: { step(hub) { if (hub.vehicle('p2')) {reads.push({ o: hub.observed('p2'), d: hub.dwell('p2', 'goal') });} } } }, (b) => {
845
+ const p2 = () => b.sim.players.get('p2');
846
+ assert.ok(flat(p2().at, here(b)) <= 6, 'the arrival row puts them near');
847
+ assert.equal(b.ctx.drive('p1', car(12, { seats: [[0, 0, 0], [0, 0, -1]] })), true);
848
+ assert.equal(b.ctx.ride('p2', 'p1', 1), true);
849
+ b.ctx.station('goal', station(30, 4));
850
+ stand(b, 500);
851
+ walk(b, { x: 30, y: here(b).y, z: 0 }, { speed: 12, every: 100, after: 1000 });
852
+ assert.ok(flat(p2().at, { x: 30, y: 0, z: 0 }) < 4, `carried into the station: ${JSON.stringify(p2().at)}`);
853
+ assert.equal(b.ctx.dwell('p1', 'goal').entered, true, 'the driver enters');
854
+ assert.ok(reads.length > 20);
855
+ for (const { o, d } of reads) {
856
+ assert.equal(o.travel, 0, 'no travel from riding');
857
+ assert.equal(o.speed, 6 * 1.25, 'a rider keeps the walker allowance');
858
+ assert.equal(d.entered, false, 'riding enters nothing');
859
+ assert.equal(d.ms, 0);
860
+ }
861
+ assert.ok(reads.slice(-5).every(({ o }) => o.ok), 'read in step, a rider is not rejected');
862
+ // Out, then walking in on foot enters.
863
+ assert.equal(b.ctx.ride('p2', null), true);
864
+ tick(b);
865
+ report(b, { ...p2().at }, 'p2');
866
+ tick(b);
867
+ assert.equal(b.ctx.observed('p2').ok, true);
868
+ assert.equal(b.ctx.observed('p2').travel, 0);
869
+ });
870
+ });
871
+
872
+
873
+ await test('v1.165: a passenger of a slow car (0.5 m/s, 50 ms ticks) earns no travel and enters nothing', async () => {
874
+ const reads = [];
875
+ await withBoot({ others: ['p2'], hooks: { step(hub) { if (hub.vehicle('p2')) {reads.push({ o: hub.observed('p2'), d: hub.dwell('p2', 'goal') });} } } }, (b) => {
876
+ const p2 = () => b.sim.players.get('p2');
877
+ assert.equal(b.ctx.drive('p1', car(12, { seats: [[0, 0, 0], [0, 0, -1]] })), true);
878
+ assert.equal(b.ctx.ride('p2', 'p1', 1), true);
879
+ stand(b, 500);
880
+ // A station the rider starts outside of and is carried into, slowly.
881
+ const seat = { ...p2().at };
882
+ b.ctx.station('goal', { at: { x: seat.x + 3, y: 1, z: seat.z }, radius: 1 });
883
+ stand(b, 200);
884
+ const from = here(b);
885
+ walk(b, { x: from.x + 4, y: from.y, z: from.z }, { speed: 0.5, every: 50, after: 1000 });
886
+ assert.ok(p2().at.x - seat.x > 3.5, `carried through the station: ${p2().at.x - seat.x}`);
887
+ const seen = reads.filter((r) => r.d);
888
+ assert.ok(seen.length > 100);
889
+ assert.ok(seen.some((r) => r.d.inside), 'the rider was inside the station');
890
+ for (const { o, d } of seen) {
891
+ assert.equal(o.travel, 0, 'no travel from riding');
892
+ assert.equal(d.entered, false, 'riding enters nothing');
893
+ assert.equal(d.ms, 0);
894
+ assert.equal(o.ok, true);
895
+ }
896
+ });
897
+ });
898
+
899
+ await test('v1.165: a walker’s tune change is no transition: a doubled tune with no credit funds 0.6 m in 50 ms, as before', () => withBoot({}, (b) => {
900
+ const at = here(b);
901
+ b.ctx.placeAt('p1', { x: at.x + 2, y: at.y, z: at.z });
902
+ tick(b);
903
+ report(b, here(b));
904
+ b.ctx.tune('p1', { speed: 2 });
905
+ const travel = b.ctx.observed('p1').travel;
906
+ report(b, { x: here(b).x + 0.6, y: at.y, z: at.z });
907
+ tick(b);
908
+ const o = b.ctx.observed('p1');
909
+ assert.equal(o.speed, 6 * 2 * 1.25);
910
+ assert.ok(Math.abs(o.travel - travel - 0.6) < 1e-6, `funded at the new allowance: ${o.travel - travel}`);
911
+ }));
912
+
745
913
  console.log(`test-observed: ${n} passed`);
@@ -428,4 +428,170 @@ await test('the town mounts a pack with its sounds as data: URLs, and a place pl
428
428
  });
429
429
 
430
430
  fs.rmSync(soundRoot, { recursive: true, force: true });
431
+
432
+ // --- symlinked imports ----------------------------------------------------------
433
+
434
+ // A town save once packed 309 of its 326 models: its imports root was a symlink
435
+ // and the walk skipped it, so the player's and the hats' models were missing
436
+ // while every hash of what was copied matched. A link is followed, and what
437
+ // cannot be followed refuses the pack.
438
+ const linkRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-links-test-'));
439
+ const deck = path.join(linkRoot, 'deck');
440
+ const kits = path.join(linkRoot, 'kits');
441
+ const put = (dir, rel, value) => {
442
+ const file = path.join(dir, rel);
443
+ fs.mkdirSync(path.dirname(file), { recursive: true });
444
+ fs.writeFileSync(
445
+ file,
446
+ typeof value === 'string' || Buffer.isBuffer(value) ? value : JSON.stringify(value),
447
+ );
448
+ };
449
+ const player = { parts: [{ kind: 'model', src: 'models/player-arm.pxmodel' }] };
450
+ const hat = { parts: [{ art: { front: 'imports/castle.hub-game/drawings/hats/cap.png' } }] };
451
+ const capPng = Buffer.from([0x89, 0x50, 0x4e, 0x47, 9, 9]);
452
+ put(deck, 'castle.json', {
453
+ server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
454
+ imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
455
+ hub: { contract: 1, title: 'Linked', controller: 'walk', result: { outcomes: ['win', 'lose'] } },
456
+ });
457
+ put(deck, 'scenes/main.scene', {
458
+ actors: [
459
+ {
460
+ id: 'me',
461
+ components: { Model: { file: '@imports/castle.physics-3d/models/player.pxmodel' } },
462
+ },
463
+ {
464
+ id: 'cap',
465
+ components: { Model: { file: '@imports/castle.hub-game/models/hats/cap.pxmodel' } },
466
+ },
467
+ ],
468
+ });
469
+ // The whole imports root is a link to a folder outside the deck...
470
+ put(kits, 'imports/castle.physics-3d/models/player.pxmodel', player);
471
+ put(kits, 'imports/castle.physics-3d/models/player-arm.pxmodel', { parts: [] });
472
+ // ...and inside it, one import is itself a link to a kit checkout elsewhere,
473
+ // with a node_modules of its own that is never walked.
474
+ put(kits, 'hub-game/models/hats/cap.pxmodel', hat);
475
+ put(kits, 'hub-game/drawings/hats/cap.png', capPng);
476
+ fs.mkdirSync(path.join(kits, 'hub-game/node_modules/x'), { recursive: true });
477
+ fs.symlinkSync(
478
+ path.join(linkRoot, 'nowhere'),
479
+ path.join(kits, 'hub-game/node_modules/x/dangling.pxmodel'),
480
+ );
481
+ fs.symlinkSync(path.join(kits, 'hub-game'), path.join(kits, 'imports/castle.hub-game'));
482
+ fs.symlinkSync(path.join(kits, 'imports'), path.join(deck, 'imports'));
483
+
484
+ const linked = await pack({ deckDir: deck, outFile: path.join(linkRoot, 'out.json') });
485
+
486
+ await test('a pack follows a symlinked imports root and a symlinked import, and carries the models behind them', () => {
487
+ assert.deepEqual(linked.errors, []);
488
+ const out = JSON.parse(fs.readFileSync(path.join(linkRoot, 'out.json'), 'utf8'));
489
+ assert.deepEqual(validatePack(out).errors, []);
490
+ // Present, by name, with the bytes behind the link: not just consistent hashes.
491
+ assert.deepEqual(Object.keys(out.files).sort(), [
492
+ 'imports/castle.hub-game/models/hats/cap.pxmodel',
493
+ 'imports/castle.physics-3d/models/player-arm.pxmodel',
494
+ 'imports/castle.physics-3d/models/player.pxmodel',
495
+ 'scenes/main.scene',
496
+ ]);
497
+ assert.deepEqual(
498
+ JSON.parse(out.files['imports/castle.physics-3d/models/player.pxmodel'].text),
499
+ player,
500
+ );
501
+ assert.deepEqual(
502
+ JSON.parse(out.files['imports/castle.hub-game/models/hats/cap.pxmodel'].text),
503
+ hat,
504
+ );
505
+ assert.deepEqual(Object.keys(out.media), ['imports/castle.hub-game/drawings/hats/cap.png']);
506
+ assert.equal(
507
+ out.media['imports/castle.hub-game/drawings/hats/cap.png'].base64,
508
+ capPng.toString('base64'),
509
+ );
510
+ });
511
+
512
+ await test('a dangling symlink in the deck refuses the pack, naming it', async () => {
513
+ fs.symlinkSync(
514
+ path.join(linkRoot, 'gone'),
515
+ path.join(kits, 'imports/castle.physics-3d/models/gone.pxmodel'),
516
+ );
517
+ const refused = await pack({ deckDir: deck, outFile: path.join(linkRoot, 'refused.json') });
518
+ assert.equal(refused.errors.length, 1);
519
+ assert.match(
520
+ refused.errors[0],
521
+ /imports\/castle\.physics-3d\/models\/gone\.pxmodel is a symlink that does not resolve/,
522
+ );
523
+ assert.ok(!fs.existsSync(path.join(linkRoot, 'refused.json')));
524
+ fs.unlinkSync(path.join(kits, 'imports/castle.physics-3d/models/gone.pxmodel'));
525
+ });
526
+
527
+ await test('a symlink loop refuses the pack, naming it', async () => {
528
+ fs.symlinkSync(path.join(kits, 'imports'), path.join(kits, 'hub-game/models/loop'));
529
+ const refused = await pack({ deckDir: deck, outFile: path.join(linkRoot, 'refused.json') });
530
+ assert.equal(refused.errors.length, 1);
531
+ assert.match(refused.errors[0], /imports\/castle\.hub-game\/models\/loop is a symlink loop/);
532
+ fs.unlinkSync(path.join(kits, 'hub-game/models/loop'));
533
+ });
534
+
535
+ fs.rmSync(linkRoot, { recursive: true, force: true });
536
+
537
+ await test('a deck with no links packs a referenced file under its own node_modules or .git folder', async () => {
538
+ const plain = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-plain-test-'));
539
+ put(plain, 'castle.json', {
540
+ server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
541
+ imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
542
+ hub: { contract: 1, title: 'Plain', controller: 'walk', result: { outcomes: ['win', 'lose'] } },
543
+ });
544
+ put(plain, 'scenes/main.scene', { actors: [{ id: 'a', components: { Model: { file: 'models/base.pxmodel' } } }] });
545
+ put(plain, 'models/base.pxmodel', { parts: [{ src: 'models/node_modules/hat.pxmodel' }, { src: 'models/.git/cap.pxmodel' }] });
546
+ put(plain, 'models/node_modules/hat.pxmodel', { parts: [] });
547
+ put(plain, 'models/.git/cap.pxmodel', { parts: [] });
548
+ const result = await pack({ deckDir: plain, outFile: path.join(plain, 'out.json') });
549
+ assert.deepEqual(result.errors, []);
550
+ const out = JSON.parse(fs.readFileSync(path.join(plain, 'out.json'), 'utf8'));
551
+ assert.deepEqual(Object.keys(out.files).sort(), ['models/.git/cap.pxmodel', 'models/base.pxmodel', 'models/node_modules/hat.pxmodel', 'scenes/main.scene']);
552
+ fs.rmSync(plain, { recursive: true, force: true });
553
+ });
554
+
555
+ await test('a reference into a linked import\'s node_modules refuses the pack, naming it', async () => {
556
+ const linkedDeck = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-linked-nm-test-'));
557
+ put(linkedDeck, 'deck/castle.json', {
558
+ server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
559
+ imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
560
+ hub: { contract: 1, title: 'Linked', controller: 'walk', result: { outcomes: ['win', 'lose'] } },
561
+ });
562
+ put(linkedDeck, 'deck/scenes/main.scene', {
563
+ actors: [{ id: 'a', components: { Model: { file: '@imports/castle.hub-game/node_modules/x/hat.pxmodel' } } }],
564
+ });
565
+ put(linkedDeck, 'kit/node_modules/x/hat.pxmodel', { parts: [] });
566
+ fs.mkdirSync(path.join(linkedDeck, 'deck/imports'));
567
+ fs.symlinkSync(path.join(linkedDeck, 'kit'), path.join(linkedDeck, 'deck/imports/castle.hub-game'));
568
+ const refused = await pack({ deckDir: path.join(linkedDeck, 'deck'), outFile: path.join(linkedDeck, 'out.json') });
569
+ assert.equal(refused.errors.length, 1);
570
+ assert.match(refused.errors[0], /scenes\/main\.scene names imports\/castle\.hub-game\/node_modules\/x\/hat\.pxmodel/);
571
+ assert.ok(!fs.existsSync(path.join(linkedDeck, 'out.json')));
572
+ fs.rmSync(linkedDeck, { recursive: true, force: true });
573
+ });
574
+
575
+ await test('a manifest root inside a linked folder\'s node_modules refuses the pack, naming it', async () => {
576
+ const signDeck = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-sign-nm-test-'));
577
+ put(signDeck, 'deck/castle.json', {
578
+ server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
579
+ imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
580
+ hub: {
581
+ contract: 1,
582
+ title: 'Sign',
583
+ controller: 'walk',
584
+ result: { outcomes: ['win', 'lose'] },
585
+ sign: { model: 'models/node_modules/sign.pxmodel' },
586
+ },
587
+ });
588
+ put(signDeck, 'deck/scenes/main.scene', { actors: [] });
589
+ put(signDeck, 'kit/node_modules/sign.pxmodel', { parts: [] });
590
+ fs.symlinkSync(path.join(signDeck, 'kit'), path.join(signDeck, 'deck/models'));
591
+ const refused = await pack({ deckDir: path.join(signDeck, 'deck'), outFile: path.join(signDeck, 'out.json') });
592
+ assert.equal(refused.errors.length, 1, refused.errors.join('; '));
593
+ assert.match(refused.errors[0], /castle\.json hub names models\/node_modules\/sign\.pxmodel, inside models\/node_modules/);
594
+ assert.ok(!fs.existsSync(path.join(signDeck, 'out.json')));
595
+ fs.rmSync(signDeck, { recursive: true, force: true });
596
+ });
431
597
  console.log(`${passed} pack tests passed.`);
@@ -80,6 +80,22 @@ assert.equal(padContextText({ cue: named, on: true }).secondary, '');
80
80
  assert.equal(padContextText({ cue: { ...named, door: false }, on: false }).secondary, '');
81
81
  assert.equal(padContextText({ cue: { ...named, title: undefined }, on: true }), null);
82
82
  assert.equal(padContextText(null), null);
83
+ // v1.217: a guest at a cabinet's pad is told to sign in, near it or on it.
84
+ const cabDoor = actor('cab-actor', { HubDoor: { id: 'cab', title: 'Daily Chicken', kind: 'cabinet' } });
85
+ const cabPad = actor('cab-pad', { Transform: { x: 0, y: 0.1, z: 0 }, HubPad: { door: 'cab', radius: 0.85 } });
86
+ const [cabCue] = cues([cabPad, cabDoor]);
87
+ assert.equal(cabCue.cabinet, true);
88
+ assert.equal(cabCue.title, 'Daily Chicken');
89
+ assert.equal(cues([a, door])[0].cabinet, false, 'an ordinary door is not a cabinet');
90
+ assert.equal(padContextText({ cue: cabCue, on: false }).secondary, 'Step on to join', 'a signed-in player is invited as before');
91
+ assert.equal(padContextText({ cue: cabCue, on: false }, true).secondary, 'Sign in to play');
92
+ assert.equal(padContextText({ cue: cabCue, on: true }, true).secondary, 'Sign in to play');
93
+ assert.equal(padContextText({ cue: named, on: false }, true).secondary, 'Step on to join', 'a guest at an ordinary door is invited as before');
94
+ const kindTracker = makePadCueTracker();
95
+ assert.equal(kindTracker.frame([cabPad, cabDoor], new Set(), body(0)).cue.cabinet, true);
96
+ cabDoor.components.HubDoor.kind = undefined;
97
+ assert.equal(kindTracker.frame([cabPad, cabDoor], new Set(), body(0)).cue.cabinet, false, 'a door kind edit is seen without a new actor');
98
+ cabDoor.components.HubDoor.kind = 'cabinet';
83
99
 
84
100
  // Actual enable gate: even accessing options would create client resources.
85
101
  const forbidden = new Proxy({}, { get() {throw new Error('disabled path touched a resource');} });
@@ -251,6 +267,29 @@ chrome.safeSurface('invite-dialog', panel, 'card');
251
267
  chrome.setPadContext(text);
252
268
  assert.equal(caption.style.visibility, 'hidden', 'any registered open panel hides the caption');
253
269
  chrome.safeSurface('invite-dialog', null);
270
+ // v1.217: an open cabinet board hides the caption and is opaque; the chip
271
+ // does neither.
272
+ {
273
+ const cab = dom.made.find((n) => n.dataset.hub === 'cabinet');
274
+ cab.size = { w: 204, h: 275 };
275
+ const item = { id: 'cab', rev: 1, card: { title: 'Batting day', label: 'Daily kills', top: [{ username: 'bo', score: 12 }] }, x: 300, y: 300, opacity: 1 };
276
+ chrome.setCabinet(item, () => null);
277
+ assert.equal(cab.dataset.drawn, 'chip');
278
+ chrome.setPadContext(text);
279
+ assert.equal(caption.style.visibility, '', 'a chip leaves the caption alone');
280
+ assert.equal(cab.style.background, 'rgba(18,14,24,0.92)', 'the chip keeps its paint');
281
+ cab.handlers.pointerdown({ stopPropagation() {} });
282
+ chrome.setCabinet(item, () => null);
283
+ assert.equal(cab.dataset.drawn, 'board');
284
+ chrome.setPadContext(text);
285
+ assert.equal(caption.style.visibility, 'hidden', 'an open board hides the plate');
286
+ assert.equal(cab.style.background, 'rgb(18,14,24)', 'an open board is opaque: no label shows through');
287
+ cab.handlers.pointerdown({ stopPropagation() {} });
288
+ chrome.setCabinet(item, () => null);
289
+ chrome.setPadContext(text);
290
+ assert.equal(caption.style.visibility, '', 'closing the board brings the plate back');
291
+ chrome.setCabinet(null, () => null);
292
+ }
254
293
  // Exact phone viewports use the shared final-rectangle placement, including
255
294
  // action rails, joystick space, HUD and both host-reserved corners.
256
295
  const overlaps = (a, b) => a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;