castle-web-cli 0.4.233 → 0.4.235

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 (383) hide show
  1. package/dist/api.d.ts +11 -0
  2. package/dist/api.js +43 -0
  3. package/dist/bundle.d.ts +64 -0
  4. package/dist/bundle.js +558 -2
  5. package/dist/castle-host/host.d.ts +17 -2
  6. package/dist/castle-host/host.js +793 -36
  7. package/dist/castleJson.d.ts +20 -1
  8. package/dist/castleJson.js +44 -2
  9. package/dist/check.js +9 -2
  10. package/dist/chunkLoader.d.ts +3 -0
  11. package/dist/chunkLoader.js +111 -0
  12. package/dist/devParty.d.ts +26 -0
  13. package/dist/devParty.js +231 -0
  14. package/dist/devSaveStorage.js +4 -0
  15. package/dist/devSessionStorage.js +3 -1
  16. package/dist/devSocial.d.ts +24 -0
  17. package/dist/devSocial.js +70 -0
  18. package/dist/ide.d.ts +2 -0
  19. package/dist/ide.js +119 -15
  20. package/dist/index.js +8 -2
  21. package/dist/init.js +1 -1
  22. package/dist/save-deck.d.ts +20 -1
  23. package/dist/save-deck.js +141 -5
  24. package/dist/serve.js +29 -11
  25. package/dist/shell/assets/{index-BjOxR-lW.js → index-DulbYIJm.js} +97 -97
  26. package/dist/shell/index.html +1 -1
  27. package/dist/vitePlugins.d.ts +2 -1
  28. package/dist/vitePlugins.js +13 -0
  29. package/kits/base/castle.json +1 -1
  30. package/kits/base/sdk/README.md +266 -3
  31. package/kits/base/sdk/castle.d.ts +7 -3
  32. package/kits/base/sdk/castle.js +2 -0
  33. package/kits/base/sdk/commands.d.ts +162 -1
  34. package/kits/base/sdk/commands.js +3 -0
  35. package/kits/base/sdk/display.d.ts +3 -0
  36. package/kits/base/sdk/display.js +9 -3
  37. package/kits/base/sdk/hub.d.ts +33 -6
  38. package/kits/base/sdk/hub.js +68 -5
  39. package/kits/base/sdk/hubRejoin.d.ts +4 -0
  40. package/kits/base/sdk/hubRejoin.js +15 -0
  41. package/kits/base/sdk/multiplayer.d.ts +7 -1
  42. package/kits/base/sdk/multiplayer.js +147 -40
  43. package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
  44. package/kits/base/sdk/party.d.ts +23 -0
  45. package/kits/base/sdk/party.js +91 -0
  46. package/kits/base/sdk/reconnectBudget.d.ts +23 -0
  47. package/kits/base/sdk/reconnectBudget.js +96 -0
  48. package/kits/base/sdk/save.d.ts +38 -1
  49. package/kits/base/sdk/save.js +79 -6
  50. package/kits/base/sdk/server/hub.d.ts +31 -1
  51. package/kits/base/sdk/server/hub.js +50 -3
  52. package/kits/base/sdk/server/platformHandle.d.ts +13 -1
  53. package/kits/base/sdk/server/storage.d.ts +4 -0
  54. package/kits/base/sdk/server/storage.js +19 -3
  55. package/kits/base/sdk/server/wrapper.d.ts +7 -1
  56. package/kits/base/sdk/server/wrapper.js +10 -1
  57. package/kits/base/sdk/social.d.ts +9 -0
  58. package/kits/base/sdk/social.js +5 -0
  59. package/kits/hub-game/CLAUDE.md +123 -3
  60. package/kits/hub-game/README.md +63 -0
  61. package/kits/hub-game/castle.json +5 -5
  62. package/kits/hub-game/code/client/act.js +312 -0
  63. package/kits/hub-game/code/client/actionLayout.js +147 -0
  64. package/kits/hub-game/code/client/actionOverflow.js +556 -0
  65. package/kits/hub-game/code/client/arrivalCamera.js +50 -0
  66. package/kits/hub-game/code/client/askSlot.js +117 -0
  67. package/kits/hub-game/code/client/avatar.js +4 -2
  68. package/kits/hub-game/code/client/avatarShare.js +2 -0
  69. package/kits/hub-game/code/client/backVisibility.js +13 -0
  70. package/kits/hub-game/code/client/ballot.js +15 -10
  71. package/kits/hub-game/code/client/build.js +16 -0
  72. package/kits/hub-game/code/client/chat.js +41 -5
  73. package/kits/hub-game/code/client/chatModeration.js +5 -0
  74. package/kits/hub-game/code/client/chrome.js +1148 -258
  75. package/kits/hub-game/code/client/crowdNames.js +241 -0
  76. package/kits/hub-game/code/client/decor.js +10 -4
  77. package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
  78. package/kits/hub-game/code/client/doorErrors.js +39 -0
  79. package/kits/hub-game/code/client/fall.js +18 -0
  80. package/kits/hub-game/code/client/farAvatars.js +233 -0
  81. package/kits/hub-game/code/client/firstJoin.js +9 -2
  82. package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
  83. package/kits/hub-game/code/client/frameBatch.js +5 -0
  84. package/kits/hub-game/code/client/grab.js +31 -11
  85. package/kits/hub-game/code/client/hookLayer.js +87 -8
  86. package/kits/hub-game/code/client/hudCopy.js +51 -0
  87. package/kits/hub-game/code/client/hudRate.js +20 -0
  88. package/kits/hub-game/code/client/idle.js +14 -2
  89. package/kits/hub-game/code/client/invites.js +231 -0
  90. package/kits/hub-game/code/client/joinError.js +9 -0
  91. package/kits/hub-game/code/client/labelsNear.js +31 -2
  92. package/kits/hub-game/code/client/landscapeLayout.js +17 -0
  93. package/kits/hub-game/code/client/layoutCache.js +264 -0
  94. package/kits/hub-game/code/client/loadTelemetry.js +20 -0
  95. package/kits/hub-game/code/client/loadingCover.js +148 -0
  96. package/kits/hub-game/code/client/loadingEntry.js +8 -0
  97. package/kits/hub-game/code/client/menuRows.js +43 -0
  98. package/kits/hub-game/code/client/modelReady.js +7 -0
  99. package/kits/hub-game/code/client/padCueArrival.js +23 -0
  100. package/kits/hub-game/code/client/padCues.js +112 -0
  101. package/kits/hub-game/code/client/padOccupancy.js +88 -0
  102. package/kits/hub-game/code/client/padReadability.js +26 -0
  103. package/kits/hub-game/code/client/padRings.js +69 -0
  104. package/kits/hub-game/code/client/pushVisit.js +14 -0
  105. package/kits/hub-game/code/client/quality.js +205 -0
  106. package/kits/hub-game/code/client/qualityEntry.js +55 -0
  107. package/kits/hub-game/code/client/safeLayout.js +338 -0
  108. package/kits/hub-game/code/client/safeStyle.js +42 -0
  109. package/kits/hub-game/code/client/say.js +12 -3
  110. package/kits/hub-game/code/client/shot.js +64 -10
  111. package/kits/hub-game/code/client/shotFit.js +56 -0
  112. package/kits/hub-game/code/client/signIn.js +28 -0
  113. package/kits/hub-game/code/client/state.js +53 -0
  114. package/kits/hub-game/code/client/talk.js +209 -45
  115. package/kits/hub-game/code/client/tiers.js +68 -66
  116. package/kits/hub-game/code/client/together.js +7 -2
  117. package/kits/hub-game/code/client/weakestLookBake.js +92 -0
  118. package/kits/hub-game/code/client/weakestTier.js +295 -0
  119. package/kits/hub-game/code/client/worldLabels.js +241 -0
  120. package/kits/hub-game/code/client/yours.js +10 -9
  121. package/kits/hub-game/code/npcDisplayText.js +55 -0
  122. package/kits/hub-game/code/server/act.js +124 -0
  123. package/kits/hub-game/code/server/actions.js +6 -1
  124. package/kits/hub-game/code/server/actors.js +2 -1
  125. package/kits/hub-game/code/server/analytics.js +83 -0
  126. package/kits/hub-game/code/server/anonymousEntry.js +49 -0
  127. package/kits/hub-game/code/server/arrivalPose.js +36 -0
  128. package/kits/hub-game/code/server/companion.js +28 -3
  129. package/kits/hub-game/code/server/doorAnalytics.js +52 -0
  130. package/kits/hub-game/code/server/earned.js +22 -5
  131. package/kits/hub-game/code/server/frameBatch.js +183 -0
  132. package/kits/hub-game/code/server/friendsAmong.js +49 -9
  133. package/kits/hub-game/code/server/history.js +2 -0
  134. package/kits/hub-game/code/server/hub.js +1306 -95
  135. package/kits/hub-game/code/server/idle.js +30 -1
  136. package/kits/hub-game/code/server/index.js +26 -4
  137. package/kits/hub-game/code/server/invites.js +19 -0
  138. package/kits/hub-game/code/server/labels.js +9 -1
  139. package/kits/hub-game/code/server/loadAbandon.js +106 -0
  140. package/kits/hub-game/code/server/manifest.js +211 -3
  141. package/kits/hub-game/code/server/menu.js +31 -3
  142. package/kits/hub-game/code/server/npcs.js +226 -64
  143. package/kits/hub-game/code/server/observe.js +408 -0
  144. package/kits/hub-game/code/server/padOccupancy.js +85 -0
  145. package/kits/hub-game/code/server/players.js +9 -1
  146. package/kits/hub-game/code/server/resumePose.js +152 -0
  147. package/kits/hub-game/code/server/say.js +1 -1
  148. package/kits/hub-game/code/server/standing.js +4 -5
  149. package/kits/hub-game/code/server/storageLimit.js +187 -0
  150. package/kits/hub-game/code/server/vis.js +67 -5
  151. package/kits/hub-game/code/shared/act.js +35 -0
  152. package/kits/hub-game/code/shared/danceIdle.js +28 -0
  153. package/kits/hub-game/code/shared/loadStages.js +12 -0
  154. package/kits/hub-game/code/shared/quality.js +74 -0
  155. package/kits/hub-game/code/shared/say.js +2 -0
  156. package/kits/hub-game/code/shared/shot.js +35 -1
  157. package/kits/hub-game/code/systems/hub.js +970 -169
  158. package/kits/hub-game/docs/analytics.md +279 -0
  159. package/kits/hub-game/docs/contract.md +1259 -42
  160. package/kits/hub-game/docs/home-pieces.md +9 -2
  161. package/kits/hub-game/docs/observed-progress.md +252 -0
  162. package/kits/hub-game/main.jsx +2 -0
  163. package/kits/hub-game/package-lock.json +10 -3
  164. package/kits/hub-game/package.json +6 -3
  165. package/kits/hub-game/play/player.js +142 -0
  166. package/kits/hub-game/play/registry.js +47 -0
  167. package/kits/hub-game/play.jsx +37 -0
  168. package/kits/hub-game/scripts/check.mjs +39 -5
  169. package/kits/hub-game/scripts/companion-follower-wire.json +1 -1
  170. package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +11 -0
  171. package/kits/hub-game/scripts/fixtures/decor-keyless.json +5 -5
  172. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +3 -0
  173. package/kits/hub-game/scripts/fixtures/fake-dom.mjs +19 -3
  174. package/kits/hub-game/scripts/fixtures/interest-legacy.json +3 -3
  175. package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -1
  176. package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
  177. package/kits/hub-game/scripts/test-act-client.mjs +186 -0
  178. package/kits/hub-game/scripts/test-act.mjs +171 -0
  179. package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
  180. package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
  181. package/kits/hub-game/scripts/test-actions-client.mjs +367 -2
  182. package/kits/hub-game/scripts/test-actors.mjs +20 -7
  183. package/kits/hub-game/scripts/test-analytics.mjs +76 -0
  184. package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
  185. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
  186. package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
  187. package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
  188. package/kits/hub-game/scripts/test-avatar-wire.mjs +49 -10
  189. package/kits/hub-game/scripts/test-avatar.mjs +44 -0
  190. package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
  191. package/kits/hub-game/scripts/test-ballot.mjs +11 -4
  192. package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
  193. package/kits/hub-game/scripts/test-build.mjs +20 -2
  194. package/kits/hub-game/scripts/test-chat.mjs +206 -5
  195. package/kits/hub-game/scripts/test-companion-chat.mjs +20 -2
  196. package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
  197. package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
  198. package/kits/hub-game/scripts/test-decor-client.mjs +45 -4
  199. package/kits/hub-game/scripts/test-decor.mjs +7 -0
  200. package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
  201. package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
  202. package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
  203. package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
  204. package/kits/hub-game/scripts/test-earned.mjs +33 -3
  205. package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
  206. package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
  207. package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
  208. package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
  209. package/kits/hub-game/scripts/test-grab-orbit.mjs +47 -4
  210. package/kits/hub-game/scripts/test-high-only.mjs +170 -0
  211. package/kits/hub-game/scripts/test-hub-ops.mjs +321 -2
  212. package/kits/hub-game/scripts/test-hub-trip.mjs +879 -11
  213. package/kits/hub-game/scripts/test-hud-clear.mjs +162 -59
  214. package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
  215. package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
  216. package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
  217. package/kits/hub-game/scripts/test-idle.mjs +66 -0
  218. package/kits/hub-game/scripts/test-interest-cells.mjs +20 -0
  219. package/kits/hub-game/scripts/test-interest.mjs +15 -0
  220. package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
  221. package/kits/hub-game/scripts/test-invites.mjs +109 -0
  222. package/kits/hub-game/scripts/test-labels.mjs +71 -3
  223. package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
  224. package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
  225. package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
  226. package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
  227. package/kits/hub-game/scripts/test-manifest.mjs +265 -0
  228. package/kits/hub-game/scripts/test-menu-client.mjs +105 -0
  229. package/kits/hub-game/scripts/test-menu.mjs +23 -0
  230. package/kits/hub-game/scripts/test-npcs.mjs +917 -10
  231. package/kits/hub-game/scripts/test-observed.mjs +745 -0
  232. package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
  233. package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
  234. package/kits/hub-game/scripts/test-picker.mjs +234 -7
  235. package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
  236. package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
  237. package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
  238. package/kits/hub-game/scripts/test-quality.mjs +385 -0
  239. package/kits/hub-game/scripts/test-rehello.mjs +699 -5
  240. package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
  241. package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
  242. package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
  243. package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
  244. package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
  245. package/kits/hub-game/scripts/test-say.mjs +1 -1
  246. package/kits/hub-game/scripts/test-shot.mjs +145 -0
  247. package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
  248. package/kits/hub-game/scripts/test-soundscape.mjs +22 -17
  249. package/kits/hub-game/scripts/test-standing.mjs +35 -2
  250. package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
  251. package/kits/hub-game/scripts/test-stuck.mjs +5 -4
  252. package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
  253. package/kits/hub-game/scripts/test-tiers-render.mjs +86 -13
  254. package/kits/hub-game/scripts/test-tiers.mjs +7 -8
  255. package/kits/hub-game/scripts/test-vis.mjs +433 -6
  256. package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
  257. package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
  258. package/kits/hub-game/scripts/test-yours-chrome.mjs +50 -6
  259. package/kits/hub-game/scripts/test-yours.mjs +39 -8
  260. package/kits/multiplayer-3d/castle.json +5 -5
  261. package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
  262. package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
  263. package/kits/multiplayer-3d/code/systems/multiplayer.js +369 -30
  264. package/kits/multiplayer-3d/package-lock.json +8 -1
  265. package/kits/multiplayer-3d/package.json +2 -1
  266. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
  267. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
  268. package/kits/physics-2d/CLAUDE.md +10 -1
  269. package/kits/physics-2d/castle.json +2 -2
  270. package/kits/physics-2d/engine/frozenActors.js +233 -0
  271. package/kits/physics-2d/engine/scene.js +87 -5
  272. package/kits/physics-2d/eslint.config.js +1 -1
  273. package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
  274. package/kits/physics-2d/play/behaviors/Camera.js +40 -0
  275. package/kits/physics-2d/play/behaviors/Collider.js +122 -0
  276. package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
  277. package/kits/physics-2d/play/behaviors/Goal.js +46 -0
  278. package/kits/physics-2d/play/behaviors/Joints.js +126 -0
  279. package/kits/physics-2d/play/behaviors/Layout.js +71 -0
  280. package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
  281. package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
  282. package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
  283. package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
  284. package/kits/physics-2d/play/behaviors/Style.js +209 -0
  285. package/kits/physics-2d/play/behaviors/Text.js +85 -0
  286. package/kits/physics-2d/play/behaviors/Video.js +93 -0
  287. package/kits/physics-3d/CLAUDE.md +25 -1651
  288. package/kits/physics-3d/behaviors/Body.jsx +3 -0
  289. package/kits/physics-3d/behaviors/Model.jsx +3 -0
  290. package/kits/physics-3d/behaviors/Player.jsx +35 -18
  291. package/kits/physics-3d/behaviors/Shape.jsx +3 -0
  292. package/kits/physics-3d/behaviors/Solid.jsx +3 -0
  293. package/kits/physics-3d/behaviors/Transform.jsx +3 -0
  294. package/kits/physics-3d/castle.json +3 -3
  295. package/kits/physics-3d/docs/engine-camera.md +542 -0
  296. package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
  297. package/kits/physics-3d/docs/engine-load.md +149 -0
  298. package/kits/physics-3d/docs/engine-look.md +114 -0
  299. package/kits/physics-3d/docs/engine-shadows.md +372 -0
  300. package/kits/physics-3d/docs/engine-skip-work.md +187 -0
  301. package/kits/physics-3d/docs/engine-sky.md +198 -0
  302. package/kits/physics-3d/docs/engine-static-actors.md +226 -0
  303. package/kits/physics-3d/docs/engine-view.md +37 -0
  304. package/kits/physics-3d/docs/pxmodel-format.md +1 -1
  305. package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
  306. package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -333
  307. package/kits/physics-3d/engine3d/actornode.js +1 -0
  308. package/kits/physics-3d/engine3d/branches.js +3 -13
  309. package/kits/physics-3d/engine3d/cage.js +2 -7
  310. package/kits/physics-3d/engine3d/cageops.js +2 -17
  311. package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
  312. package/kits/physics-3d/engine3d/framecap.js +4 -1
  313. package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
  314. package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
  315. package/kits/physics-3d/engine3d/gait.js +8 -0
  316. package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
  317. package/kits/physics-3d/engine3d/look.js +7 -0
  318. package/kits/physics-3d/engine3d/modelFiles.js +3 -17
  319. package/kits/physics-3d/engine3d/modelMath.js +49 -0
  320. package/kits/physics-3d/engine3d/modelready.js +16 -0
  321. package/kits/physics-3d/engine3d/motion.js +3 -3
  322. package/kits/physics-3d/engine3d/nearshadows.js +77 -10
  323. package/kits/physics-3d/engine3d/orbitinput.js +59 -25
  324. package/kits/physics-3d/engine3d/partgeometry.js +1 -16
  325. package/kits/physics-3d/engine3d/paths.js +1 -9
  326. package/kits/physics-3d/engine3d/playTimings.js +50 -0
  327. package/kits/physics-3d/engine3d/playerRun.js +372 -0
  328. package/kits/physics-3d/engine3d/pxmodel.js +3 -3
  329. package/kits/physics-3d/engine3d/rapier.js +27 -0
  330. package/kits/physics-3d/engine3d/scatter.js +1 -11
  331. package/kits/physics-3d/engine3d/shadowfade.js +23 -15
  332. package/kits/physics-3d/engine3d/sky.js +1 -1
  333. package/kits/physics-3d/engine3d/squarefirst.js +177 -0
  334. package/kits/physics-3d/engine3d/stillshadows.js +399 -0
  335. package/kits/physics-3d/engine3d/sweep.js +1 -25
  336. package/kits/physics-3d/engine3d/world3d.js +468 -18
  337. package/kits/physics-3d/eslint.config.js +2 -1
  338. package/kits/physics-3d/main.jsx +6 -3
  339. package/kits/physics-3d/package-lock.json +7 -0
  340. package/kits/physics-3d/package.json +5 -1
  341. package/kits/physics-3d/play/behaviors/Body.js +31 -0
  342. package/kits/physics-3d/play/behaviors/Door.js +37 -0
  343. package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
  344. package/kits/physics-3d/play/behaviors/Model.js +23 -0
  345. package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
  346. package/kits/physics-3d/play/behaviors/Player.js +1204 -0
  347. package/kits/physics-3d/play/behaviors/Shape.js +47 -0
  348. package/kits/physics-3d/play/behaviors/Solid.js +16 -0
  349. package/kits/physics-3d/play/behaviors/Transform.js +29 -0
  350. package/kits/physics-3d/pnpm-lock.yaml +8 -0
  351. package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
  352. package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
  353. package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
  354. package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
  355. package/kits/physics-3d/scripts/test-camera-orbit.mjs +52 -4
  356. package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
  357. package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
  358. package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +6 -3
  359. package/kits/physics-3d/scripts/test-frame-cap.mjs +1 -1
  360. package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
  361. package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
  362. package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
  363. package/kits/physics-3d/scripts/test-look-bake.mjs +1 -1
  364. package/kits/physics-3d/scripts/test-near-shadows.mjs +2 -2
  365. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +88 -7
  366. package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +40 -3
  367. package/kits/physics-3d/scripts/test-orbit-shot.mjs +75 -1
  368. package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
  369. package/kits/physics-3d/scripts/test-sky.mjs +1 -1
  370. package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
  371. package/kits/physics-3d/scripts/test-static-actors.mjs +3 -1
  372. package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
  373. package/kits/physics-3d/scripts/test-static-scenery.mjs +5 -2
  374. package/kits/physics-3d/scripts/test-steady-hover.mjs +5 -2
  375. package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
  376. package/kits/physics-3d/systems/physics3d.js +37 -4
  377. package/kits/real-time/castle.json +2 -2
  378. package/kits/real-time/code/client/connection.js +33 -10
  379. package/kits/real-time/code/client/gameHooks.js +2 -0
  380. package/kits/real-time/code/client/joinOverlay.js +9 -4
  381. package/kits/real-time/code/server/session.js +6 -4
  382. package/kits/real-time/package-lock.json +1 -1
  383. package/package.json +2 -2
@@ -0,0 +1,196 @@
1
+ // Real transport -> SDK wrapper -> real-time -> Rapier -> hub lifecycle boundary.
2
+ import assert from 'node:assert/strict';
3
+ import { cp, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { WebSocket } from 'ws';
7
+ import { startDevSessionServer } from '../../../cli/dist/devSessionServer.js';
8
+
9
+ const root = fileURLToPath(new URL('../../../', import.meta.url));
10
+ const scratch = path.join(root, '.castle');
11
+ await mkdir(scratch, { recursive: true });
12
+ const dir = await mkdtemp(path.join(scratch, 'arrival-pose-'));
13
+ const door = process.argv[2] ?? null;
14
+ const fast = process.env.POSE_REPLACE === '1';
15
+ const plain = process.env.POSE_PLAIN === '1';
16
+ const resultPlace = process.env.POSE_RESULT === '1';
17
+ const leavingLine = process.env.POSE_LINE === '1';
18
+ const logs = [];
19
+ const sockets = [];
20
+ let server;
21
+ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
22
+ try {
23
+ await mkdir(path.join(dir, 'imports'), { recursive: true });
24
+ for (const kit of ['base', 'hub-game', 'real-time', 'multiplayer-3d', 'physics-3d', 'physics-2d']) {
25
+ await cp(path.join(root, 'kits', kit), path.join(dir, 'imports', `castle.${kit}`), {
26
+ recursive: true,
27
+ filter: source => !['node_modules', 'imports', '.castle'].includes(path.basename(source)),
28
+ });
29
+ }
30
+ await symlink(path.join(root, 'kits/hub-game/node_modules'), path.join(dir, 'node_modules'));
31
+ await mkdir(path.join(dir, 'code/server'), { recursive: true });
32
+ await mkdir(path.join(dir, 'scenes'), { recursive: true });
33
+ await writeFile(path.join(dir, 'package.json'), JSON.stringify({ type: 'module', private: true }));
34
+ const config = door ? JSON.parse(await readFile(path.join(root, `experiments/hub-${door}/castle.json`), 'utf8')) : {
35
+ hub: { contract: 1, title: 'Pose boundary' },
36
+ };
37
+ delete config.deckId; delete config.cardId;
38
+ config.server = { main: 'imports/castle.hub-game/code/server/index.js', tickRate: 20, maxPlayers: 8 };
39
+ config.hub.resumeArrivalPose = true;
40
+ if (resultPlace) { config.hub.result = { outcomes: ['win', 'lose'], score: { unit: 'points', better: 'higher', min: 0, max: 10 } }; config.hub.maxDurationSec = 30; }
41
+ if (config.hub.result) config.hub.resume = true;
42
+ await writeFile(path.join(dir, 'castle.json'), JSON.stringify(config));
43
+ if (door) {
44
+ await cp(path.join(root, `experiments/hub-${door}/scenes`), path.join(dir, 'scenes'), { recursive: true });
45
+ await cp(path.join(root, `experiments/hub-${door}/code`), path.join(dir, 'code'), { recursive: true });
46
+ let source = await readFile(path.join(dir, 'code/server/game.js'), 'utf8');
47
+ if (['clinic', 'cove'].includes(door)) source += '\nexport const testState = state; export const testGoal = countGoal;\n';
48
+ if (door === 'runway') source += '\nexport const testState = state;\n';
49
+ if (door === 'plot') source = source.replace(' return hooks;', ' hooks.inspect = () => state; return hooks;').replace(' arrive(...args)', ' inspect() { return game?.inspect?.(); },\n arrive(...args)');
50
+ await writeFile(path.join(dir, 'code/server/authored.js'), source);
51
+ } else {
52
+ await writeFile(path.join(dir, 'scenes/main.scene'), JSON.stringify({ actors: [
53
+ { id: 'player', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } },
54
+ ] }));
55
+ }
56
+ await writeFile(path.join(dir, 'code/server/game.js'), `
57
+ ${door ? "import authored, * as mod from './authored.js';" : 'const authored = {}, mod = {};'}
58
+ const events = [], saved = new Map(); let departure = null, departedRoster = null;
59
+ const state = () => mod.testState ?? authored.inspect?.();
60
+ export default { ...authored,
61
+ arrive(h, group) { authored.arrive?.(h, group); for (const p of group) events.push(['arrive', p.playerId]); },
62
+ leave(h, id, who) { events.push(['leave', id]); const result = authored.leave?.(h, id, who); departedRoster = h.players().map(p => p.playerId); const s = state(); departure = s ? { connected: s.players.get(id)?.connected, cast: s.casts?.has(id), suspended: s.casts?.get(id)?.suspendedAt } : null; return result; },
63
+ message(h, p, d) {
64
+ if (!d?.test) return authored.message?.(h, p, d);
65
+ const s = state();
66
+ if (d.test === 'line') h.leaving(p.playerId, 'Next visit: bring a friend');
67
+ if (d.test === 'report') { h.send(p.playerId, { test: d.test, accepted: h.result(p.playerId, { outcome: 'win', score: 1 }) }); return; }
68
+ if (d.test === 'advance') h.sim.timeMs += d.ms;
69
+ if (d.test === 'prepare') {
70
+ const id = d.id, departed = s?.players.get(id); saved.set(id, departed);
71
+ if (mod.testGoal) {
72
+ for (const q of s.players.values()) q.loaded = true;
73
+ s.goal.done = s.goal.need - 1;
74
+ }
75
+ if ('${door}' === 'fishing') { const seat = [...s.seats.values()].find(q => !q.relay); h.placeAt(id, { x: seat.t.x, y: 1, z: seat.t.z }, 0); }
76
+ if ('${door}' === 'runway') { s.phase = 'show'; s.order = [id, p.playerId]; s.turn = 0; s.phaseAt = h.now; }
77
+ }
78
+ if (d.test === 'goal') {
79
+ const q = saved.get(d.id), coins = q.save.coins;
80
+ mod.testGoal(h, '${door}' === 'clinic' ? [] : null);
81
+ h.send(p.playerId, { test: d.test, coins, afterCoins: q.save.coins }); return;
82
+ }
83
+ if (d.test === 'move') {
84
+ h.placeAt(p.playerId, { x: 6, y: 1, z: 8 }, 40);
85
+ }
86
+ h.send(p.playerId, { test: d.test, events, departedRoster, roster: h.players(), now: h.now,
87
+ pose: h.sim.players.get(p.playerId)?.at, facing: h.sim.players.get(p.playerId)?.facing,
88
+ authored: s ? { departure, seat: s.seats ? [...s.seats.values()].find(q => !q.relay)?.id : null, ids: [...s.players.keys()], connected: s.players.get(d.id)?.connected,
89
+ cast: s.casts?.has(d.id), suspended: s.casts?.get(d.id)?.suspendedAt,
90
+ grace: s.grace ? [...s.grace.values()].map(g => g.until) : null, turn: s.turn,
91
+ departedWalked: saved.get(d.id)?.walked } : null });
92
+ },
93
+ };
94
+ `);
95
+ server = await startDevSessionServer({ projectDir: dir, log: (level, message) => logs.push(`${level}: ${message}`) });
96
+ const base = `ws://127.0.0.1:${server.port}/__castle/mp`;
97
+ const a = await connect(`${base}?nonce=${server.mintNonce({userId:'101',username:'Ada',isAnonymous:false})}`);
98
+ const hello = await a.wait(f => f.t === 'hello');
99
+ a.send({ k: 'hub-hello', avatar: 0, party: 1 });
100
+ await sleep(300);
101
+ const initial = await query(a, 'state');
102
+ assert.deepEqual(initial.events, [['arrive', hello.playerId]], 'real hub admitted and arrived');
103
+ if (resultPlace) assert.equal((await query(a, 'report')).accepted, true);
104
+ await query(a, 'move');
105
+ await sleep(150);
106
+ let before = await query(a, 'state');
107
+ assert.ok(Math.hypot(before.pose.x - initial.pose.x, before.pose.z - initial.pose.z) > 2, 'fixture actually moved away from arrival');
108
+ const b = await connect(`${base}?nonce=${server.mintNonce({userId:'102',username:'Bo',isAnonymous:false})}`);
109
+ await b.wait(f => f.t === 'hello');
110
+ b.send({ k: 'hub-hello', avatar: 0, party: 1 });
111
+ await sleep(300);
112
+ if (door) { const prep = await query(b, 'prepare', { id: hello.playerId }); if (door === 'fishing') a.send({ k: 'hub-sit', seat: prep.authored.seat }); await sleep(150); before = await query(a, 'state', { id: hello.playerId }); if (door === 'fishing') assert.equal(before.authored.cast, true, 'real seat interaction starts a cast'); }
113
+ if (resultPlace) await query(b, 'advance', { ms: 15000 });
114
+ if (leavingLine) await query(a, 'line');
115
+ let returned;
116
+ if (fast) {
117
+ returned = await connect(`${base}?reconnect=${hello.reconnectToken}`);
118
+ assert.equal((await returned.wait(f => f.t === 'hello')).playerId, hello.playerId);
119
+ } else {
120
+ a.socket.close();
121
+ await new Promise(resolve => a.socket.once('close', resolve));
122
+ }
123
+ await sleep(300);
124
+ const absent = await query(b, 'state', { id: hello.playerId });
125
+ assert.equal(absent.events.filter(e => e[0] === 'leave' && e[1] === hello.playerId).length, 1, 'authored immediate leave fires');
126
+ assert.ok(!absent.departedRoster.includes(hello.playerId), 'authored leave sees only authenticated live roster');
127
+ if (!fast) assert.ok(!absent.roster.some(p => p.playerId === hello.playerId), 'absent player is not live');
128
+ if (['clinic', 'cove', 'plot', 'runway'].includes(door)) {
129
+ assert.ok(!absent.authored.ids.includes(hello.playerId), `${door}: authored roster drops disconnected player`);
130
+ }
131
+ if (['clinic', 'cove'].includes(door)) {
132
+ const goal = await query(b, 'goal', { id: hello.playerId });
133
+ assert.equal(goal.afterCoins, goal.coins, `${door}: absent player receives no shared goal award`);
134
+ }
135
+ if (door === 'fishing') {
136
+ const castState = fast ? absent.authored.departure : absent.authored;
137
+ assert.equal(castState.connected, false);
138
+ assert.equal(castState.cast, true, 'existing cast is suspended, not cancelled');
139
+ assert.ok(Number.isFinite(castState.suspended));
140
+ }
141
+ if (door === 'plot') {
142
+ assert.equal(absent.authored.grace.length, 1, 'authored grace starts immediately');
143
+ assert.ok(absent.authored.grace[0] - absent.now <= 60000, 'kit adds no time to authored grace');
144
+ }
145
+ if (door === 'runway') {
146
+ assert.equal(absent.authored.turn, 1, 'absent walker does not block next turn');
147
+ assert.equal(absent.authored.departedWalked, false, 'absent walker is not credited a walk');
148
+ }
149
+ if (!returned) {
150
+ returned = await connect(`${base}?reconnect=${hello.reconnectToken}`);
151
+ assert.equal((await returned.wait(f => f.t === 'hello')).playerId, hello.playerId);
152
+ }
153
+ returned.send({ k: 'hub-hello', avatar: 0, party: 1, ...(plain ? {} : { resume: true }) });
154
+ await sleep(300);
155
+ const after = await query(returned, 'state');
156
+ assert.equal(after.events.filter(e => e[0] === 'arrive' && e[1] === hello.playerId).length, 2, 'authored arrive fires again');
157
+ assert.ok(Math.hypot(after.pose.x - before.pose.x, after.pose.z - before.pose.z) < 0.01, 'pose restored across ordinary leave/arrive');
158
+ assert.equal(after.facing, before.facing, 'facing restored');
159
+ if (resultPlace) {
160
+ assert.equal((await query(returned, 'report')).accepted, false, 'one result survives plain same-id replacement');
161
+ await query(b, 'advance', { ms: 16000 });
162
+ await returned.wait(f => f.t === 'm' && f.d?.k === 'hub-end' && f.d.why === 'time');
163
+ }
164
+ console.log(`test-arrival-pose-server ${door ?? 'fixture'}: real socket lifecycle, authored negatives and pose passed`);
165
+ } catch (error) {
166
+ console.error(logs.join('\n'));
167
+ throw error;
168
+ } finally {
169
+ for (const socket of sockets) socket.terminate();
170
+ await server?.shutdown();
171
+ await rm(dir, { recursive: true, force: true });
172
+ }
173
+ async function query(client, test, extra = {}) {
174
+ client.send({ test, ...extra });
175
+ return (await client.wait(f => f.t === 'm' && f.d?.test === test)).d;
176
+ }
177
+ async function connect(url) {
178
+ const socket = new WebSocket(url);
179
+ sockets.push(socket);
180
+ const frames = [];
181
+ socket.on('message', (data, binary) => { if (!binary) frames.push(JSON.parse(data)); });
182
+ await new Promise((resolve, reject) => { socket.once('open', resolve); socket.once('error', reject); });
183
+ return {
184
+ socket,
185
+ send: d => socket.send(JSON.stringify({ t: 'm', d })),
186
+ async wait(predicate) {
187
+ const deadline = Date.now() + 10000;
188
+ while (Date.now() < deadline) {
189
+ const index = frames.findIndex(predicate);
190
+ if (index >= 0) return frames.splice(index, 1)[0];
191
+ await sleep(20);
192
+ }
193
+ throw Error('multiplayer frame timed out');
194
+ },
195
+ };
196
+ }
@@ -0,0 +1,24 @@
1
+ import assert from 'node:assert/strict';
2
+ import { create, TTL_MS } from '../code/server/arrivalPose.js';
3
+ const pose = { at: { x: 3, y: 1, z: 7 }, facing: 0.4 };
4
+ for (const elapsed of [TTL_MS - 1, TTL_MS]) {
5
+ const cache = create(); cache.remember('p', '101', pose, 0); cache.leave('p', '101', true, 10);
6
+ assert.deepEqual(cache.take('p', '101', 10 + elapsed), elapsed < TTL_MS ? pose : null);
7
+ assert.equal(cache.take('p', '101', 10 + elapsed), null, 'consumed once');
8
+ }
9
+ for (const operation of [c => c.clear('p'), c => c.shutdown(), c => c.leave('p', '101', false, 10)]) {
10
+ const cache = create(); cache.remember('p', '101', pose, 0); cache.leave('p', '101', true, 10); operation(cache);
11
+ assert.equal(cache.take('p', '101', 20), null, 'travel, shutdown and ineligible departure clear');
12
+ }
13
+ const cache = create(); cache.remember('p', '101', pose, 0); cache.leave('p', '101', true, 10);
14
+ assert.equal(cache.take('p', '102', 20), null, 'identity change consumes without restoring');
15
+ cache.remember('p', null, pose, 20); cache.leave('p', null, true, 30);
16
+ assert.equal(cache.take('p', null, 40), null, 'anonymous never restores');
17
+ cache.remember('p', '101', { ...pose, facing: NaN }, 40); cache.leave('p', '101', true, 50);
18
+ assert.equal(cache.take('p', '101', 60), null, 'invalid pose never restores');
19
+ console.log('arrival-pose: expiry, identity, one-use and departure fences passed');
20
+
21
+ const capped = create();
22
+ for (let i = 0; i < 129; i++) { capped.remember(String(i), '101', pose, 0); capped.leave(String(i), '101', true, 1); }
23
+ assert.equal(capped.take('0', '101', 2), null, 'bounded cache evicts oldest');
24
+ assert.deepEqual(capped.take('128', '101', 2), pose);
@@ -0,0 +1,85 @@
1
+ // v1.125 shared ask-slot lease: first display, exact timer/distance bounds,
2
+ // pad entry, redraw identity and reconnect replay. Pure client lifecycle; no
3
+ // server message is emitted by expiry.
4
+ import assert from 'node:assert/strict';
5
+ import { ASK_SLOT_DISTANCE_M, ASK_SLOT_MS, askSlotKey, makeAskSlot, padsAt } from '../code/client/askSlot.js';
6
+
7
+ const ask = (key = 'invite:p2', kind = 'invite') => ({ key, kind, text: 'Come along?', yes: 'Go', no: 'Not now' });
8
+
9
+ {
10
+ const slot = makeAskSlot();
11
+ // Waiting/suppression before a card reaches chrome spends no lease.
12
+ slot.frame({ x: 0, z: 0 }, new Set(), 20_000);
13
+ assert.equal(slot.display(ask(), { x: 0, z: 0 }, new Set(), 25_000)?.key, 'invite:p2');
14
+ assert.equal(slot.accepts(ask(), { x: 0, z: 0 }, new Set(), 25_000 + ASK_SLOT_MS - 1), true);
15
+ assert.equal(slot.accepts(ask(), { x: 0, z: 0 }, new Set(), 25_000 + ASK_SLOT_MS), false, 'expires at exactly 12 seconds');
16
+ }
17
+
18
+ {
19
+ const slot = makeAskSlot();
20
+ slot.display(ask('go:7', 'go'), { x: 4, z: -2 }, new Set(), 0);
21
+ assert.equal(slot.accepts(ask('go:7', 'go'), { x: 4 + ASK_SLOT_DISTANCE_M - 0.001, z: -2 }, new Set(), 1), true);
22
+ assert.equal(slot.accepts(ask('go:7', 'go'), { x: 4, z: -2 + ASK_SLOT_DISTANCE_M }, new Set(), 2), false, 'exactly 3 m retires the proposal');
23
+ }
24
+
25
+ {
26
+ const slot = makeAskSlot();
27
+ const card = ask('play:p2:race:1', 'play');
28
+ slot.display(card, { x: 0, z: 0 }, new Set(['return-pad']), 0);
29
+ assert.equal(slot.accepts(card, { x: 0, z: 0 }, new Set(['return-pad']), 1), true, 'already standing on a pad is not an entry');
30
+ assert.equal(slot.accepts(card, { x: 0, z: 0 }, new Set(), 2), true, 'stepping off keeps the card');
31
+ assert.equal(slot.accepts(card, { x: 0, z: 0 }, new Set(['return-pad']), 3), false, 'stepping back onto any pad retires it');
32
+ }
33
+
34
+ {
35
+ const slot = makeAskSlot();
36
+ const before = { ...ask('yours:4:race:a:old:false:false', 'yours'), slotKey: 'yours:4:return:1' };
37
+ const redrawn = { ...ask('yours:4:tiles:a,b:new:true:true', 'yours'), slotKey: 'yours:4:return:1' };
38
+ assert.equal(askSlotKey(before), askSlotKey(redrawn));
39
+ slot.display(before, { x: 0, z: 0 }, new Set(), 100);
40
+ assert.equal(slot.display(redrawn, { x: 0, z: 0 }, new Set(), 100 + ASK_SLOT_MS - 1), redrawn, 'heart/line/party redraw keeps the first lease');
41
+ assert.equal(slot.display(redrawn, { x: 0, z: 0 }, new Set(), 100 + ASK_SLOT_MS), null);
42
+ }
43
+
44
+ {
45
+ const slot = makeAskSlot();
46
+ const lower = ask('again:race:1', 'again');
47
+ const higher = ask('invite:p2', 'invite');
48
+ slot.display(lower, { x: 0, z: 0 }, new Set(), 0);
49
+ slot.display(higher, { x: 0, z: 0 }, new Set(), 2_000);
50
+ assert.equal(slot.display(lower, { x: 0, z: 0 }, new Set(), 11_999), lower, 'priority fallthrough does not restart its lease');
51
+ assert.equal(slot.display(lower, { x: 0, z: 0 }, new Set(), 12_000), null);
52
+ // A 30-second connection drop can replay the same server ask, but the
53
+ // client record survives and refuses to resurrect it.
54
+ slot.frame({ x: 0, z: 0 }, new Set(), 30_000);
55
+ assert.equal(slot.display(higher, { x: 0, z: 0 }, new Set(), 32_000), null);
56
+ slot.clear();
57
+ assert.equal(slot.display(higher, { x: 0, z: 0 }, new Set(), 32_001), higher, 'a genuinely new session gets a new lease');
58
+ }
59
+
60
+ {
61
+ const slot = makeAskSlot();
62
+ const yours = ask('yours:8:race:a:line:false:false', 'yours');
63
+ slot.display(yours, { x: 0, z: 0 }, new Set(), 0);
64
+ slot.frame({ x: 0, z: 0 }, new Set(), ASK_SLOT_MS);
65
+ for (let i = 0; i < 40; i += 1) {
66
+ slot.display(ask(`play:p${i}:race:${i}`, 'play'), { x: 0, z: 0 }, new Set(), ASK_SLOT_MS + i + 1);
67
+ slot.display({ ...ask(`invite:p${i}:${i}`, 'invite'), slotKey: `invite:${i}` }, { x: 0, z: 0 }, new Set(), ASK_SLOT_MS + i + 1);
68
+ }
69
+ assert.equal(slot.display(yours, { x: 0, z: 0 }, new Set(), 20_000), null, 'many later occurrences cannot evict and revive an expired lower-priority kind');
70
+ }
71
+
72
+ {
73
+ const actors = [
74
+ { id: 'small', components: { Transform: { x: 1, z: 2 }, Shape: { radius: 0.5 }, HubPad: { door: 'race' } } },
75
+ { id: 'default', components: { Transform: { x: 10, z: 10 }, HubPad: { door: 'cabinet' } } },
76
+ { id: 'not-a-pad', components: { Transform: { x: 1, z: 2 }, Shape: { radius: 10 } } },
77
+ ];
78
+ const scene = { getActors: () => actors };
79
+ assert.deepEqual([...padsAt(scene, { x: 1.5, z: 2 })], ['small'], 'pad edge is included');
80
+ assert.deepEqual([...padsAt(scene, { x: 1.5, z: 2 }, new Set(['small']))], [], 'a pad hidden from this player is not enterable');
81
+ assert.deepEqual([...padsAt(scene, { x: 12.299, z: 10 })], ['default'], 'all HubPads use the server default radius, including cabinets');
82
+ assert.deepEqual([...padsAt(scene, { x: 12.301, z: 10 })], []);
83
+ }
84
+
85
+ console.log('hub-game ask slot: first display, 12 s, exact 3 m, pad entry, redraws and 30 s reconnect passed');
@@ -3,14 +3,14 @@
3
3
  // twelve after them always has something to draw: a player who wears 4-15 is
4
4
  // listed there as `avatar % 4`, and what they really wear is in `hubAv2`,
5
5
  // which a v1.51 client prefers and an older one ignores. `hubAv2` is there
6
- // only while someone wears one: a place where nobody does writes what it
7
- // wrote before v1.51, byte for byte.
6
+ // only while someone wears one: a place where nobody does writes the same
7
+ // avatar fields it wrote before v1.51.
8
8
  //
9
9
  // The server is the kit's layer on a fake session and the client the kit's
10
10
  // real hook layer, as test-try-on.mjs runs them. `story` is a visit in which
11
11
  // everyone wears one of the first four; what the place writes in it is held
12
- // to `BEFORE_V144`, the sha256 of what the kit wrote at the commit before
13
- // v1.51 (25ce4d8b). `HUB_AV_BASELINE=<dir>` points at another copy of this
12
+ // to `BEFORE_V144`. It differs from the pre-v1.51 bytes only where later
13
+ // place-wide defaults intentionally changed. `HUB_AV_BASELINE=<dir>` points at another copy of this
14
14
  // kit (`git archive <commit> kits/hub-game/code | tar -x -C <dir>`, then the
15
15
  // path to `kits/hub-game` in it): the story is run on that copy's server too,
16
16
  // compared byte for byte, and its hash printed. `npm run check` runs this
@@ -79,13 +79,16 @@ const Avatar = await import(at(KIT, 'code/client/avatar.js'));
79
79
  const Avatars = await import('@imports/castle.multiplayer-3d/code/client/avatars.js');
80
80
  const baseline = process.env.HUB_AV_BASELINE ? (await import(at(path.resolve(process.env.HUB_AV_BASELINE), 'code/server/hub.js'))).layer : null;
81
81
 
82
- // What the kit wrote in `story` at 25ce4d8b, the commit before v1.51.
83
- const BEFORE_V144 = '2d09e59c8685d74fcb30d924f6176179be3260e946b15fda2a46a79a5dce5201';
82
+ // The established avatar story with the current effective place defaults.
83
+ // The only change since the original pre-v1.51 bytes is `fallY: -20` in each
84
+ // full place snapshot; avatar snapshots, deltas and messages remain unchanged.
85
+ const BEFORE_V144 = 'e04247fb8fce74895e8c40063804cbe15791b316f9057aad681d94cf1ef758e4';
84
86
 
85
87
  globalThis.__hubTestActors = [{ id: 'spawn', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } }];
86
88
  const castleJson = { server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Town' } };
87
89
  const sceneExists = () => true;
88
90
  const flush = () => new Promise((resolve) => setImmediate(resolve));
91
+ const withCurrentFallDefault = (value) => value.replaceAll('"fallY":null', '"fallY":-20');
89
92
 
90
93
  const ROSTER = [
91
94
  { playerId: 'p1', userId: '101', username: 'ada', isAnonymous: false },
@@ -250,7 +253,8 @@ await test('nobody past the first four: every byte the place writes is what it w
250
253
  assert.deepEqual(text(await story(layer, { old: true })), text(same), 'the story is the same every run');
251
254
  if (baseline) {
252
255
  const before = await story(baseline, { old: true });
253
- assert.equal(text(same), text(before), 'this kit and the baseline write the same bytes');
256
+ assert.equal(text(same), withCurrentFallDefault(text(before)),
257
+ 'this kit and the baseline differ only by the current effective fall default');
254
258
  info(`hub-game avatar wire: the baseline writes ${Buffer.byteLength(text(before))} bytes, sha256 ${sha(before)}`);
255
259
  }
256
260
  assert.equal(sha(same), BEFORE_V144, 'the place writes other bytes than it did before v1.51');
@@ -281,13 +285,13 @@ async function colorlessStory(make) {
281
285
  return logs;
282
286
  }
283
287
 
284
- await test('all sixteen avatars without colours keep the preceding snapshots and deltas byte-for-byte', async () => {
288
+ await test('all sixteen avatars without colours keep the preceding avatar snapshots and deltas byte-for-byte', async () => {
285
289
  const now = await colorlessStory(layer);
286
290
  assert.ok(!text(now).includes('hubAvC'));
287
- assert.equal(sha(now), '50541156b37a2f5e6f0fb8d657c4be5e4a4738db31ec169c61dbba3e98d70c43');
291
+ assert.equal(sha(now), '7bd9e1419c0b59c233ef3e5159c9aba94230ebc7dfc280b161f58aa8a91a0e15');
288
292
  if (baseline) {
289
293
  const before = await colorlessStory(baseline);
290
- assert.equal(text(now), text(before));
294
+ assert.equal(text(now), withCurrentFallDefault(text(before)));
291
295
  info(`hub-game colourless wire baseline: sha256 ${sha(before)}`);
292
296
  }
293
297
  });
@@ -481,6 +485,22 @@ await test('a late ghost answer cannot put a queued colour onto another characte
481
485
  }
482
486
  });
483
487
 
488
+ await test('two replacement hellos keep one in-flight avatar and colour capture', async () => {
489
+ let release;
490
+ const waiting = new Promise((resolve) => { release = resolve; });
491
+ const r = room(layer, { ghost: { 101: 2 }, ghostColors: { 101: 1 }, readWait: () => waiting, avatarColors: true });
492
+ r.enter('p1', 2);
493
+ await r.tick();
494
+ r.hello('p1', 9, { again: true, color: 4 });
495
+ r.hello('p1', 9, { again: true, color: 4 });
496
+ assert.deepEqual((await r.tick()).hubAv2, { p1: 9 });
497
+ release();
498
+ await flush();
499
+ await r.tick();
500
+ assert.deepEqual(r.join().hubAv2, { p1: 9 });
501
+ assert.deepEqual(r.join().hubAvC, { p1: 4 });
502
+ });
503
+
484
504
  await test('colours in blocked pairs use private whole blocks and clear on a colour-only change', async () => {
485
505
  const r = room(layer, { hides: (x, y) => [x, y].sort().join() === 'p1,p2', ghost: { 101: 9, 102: 2, 103: 6 }, ghostColors: { 101: 3, 102: 4, 103: 2 }, avatarColors: true });
486
506
  r.enter('p1', 9);
@@ -750,4 +770,23 @@ await test('client colour-only changes redraw, whole snapshots clear, and shared
750
770
 
751
771
  console.log = info;
752
772
  console.warn = warn;
773
+ // Guest labels merge the public and viewer-only lists just like avatar maps.
774
+ {
775
+ State.clear();
776
+ const scene = { files: null };
777
+ hookLayer.state(scene, { hubPlace: { id: 'main', anonymousEntry: true }, hubAv: { p1: 0 }, hubGuests: ['p1'] }, null);
778
+ hookLayer.message(scene, { k: 'hub-av', hubAv: { p2: 0 }, hubGuests: ['p2'] });
779
+ assert.deepEqual([...State.hub.guests].sort(), ['p1', 'p2']);
780
+ assert.equal(hookLayer.avatar('p1', 'Ada').username, 'Guest · Ada');
781
+ hookLayer.state(scene, { hubGuests: [] }, null);
782
+ assert.deepEqual([...State.hub.guests], ['p2']);
783
+ hookLayer.message(scene, { k: 'hub-av', hubAv: {}, hubGuests: [] });
784
+ assert.equal(State.hub.guests.size, 0);
785
+ hookLayer.state(scene, { hubPlace: { id: 'main' } }, null);
786
+ assert.equal(State.hub.guests, undefined);
787
+ assert.equal(State.hub.guestsAll, undefined);
788
+ assert.equal(State.hub.guestsMe, undefined);
789
+ n += 1;
790
+ }
791
+
753
792
  console.log(`hub-game avatar wire: ${n} tests passed`);
@@ -169,6 +169,50 @@ await test('transport read failures retry once per runtime and write a pick afte
169
169
  } finally { console.warn = warn; Avatar.resetPlatformForTests(null); }
170
170
  });
171
171
 
172
+ await test('the default clock retries under browser timers that need a bare call', async () => {
173
+ // Browsers throw "Illegal invocation" when setTimeout is called with `this`
174
+ // set to another object; Node does not, so model that here.
175
+ const { setTimeout: realSet, clearTimeout: realClear } = globalThis;
176
+ const queued = new Map();
177
+ let id = 0;
178
+ function strict(self) {
179
+ if (self !== undefined && self !== globalThis) { throw new TypeError('Illegal invocation'); }
180
+ }
181
+ globalThis.setTimeout = function (fn, ms) {
182
+ strict(this);
183
+ if (ms < 1000) { return realSet(fn, ms); }
184
+ queued.set(++id, fn);
185
+ return id;
186
+ };
187
+ globalThis.clearTimeout = function (key) {
188
+ strict(this);
189
+ if (!queued.delete(key)) { realClear(key); }
190
+ };
191
+ const h = host();
192
+ const scene = { persistent: { hubAvatar: 1 } };
193
+ const warn = console.warn;
194
+ console.warn = () => {};
195
+ try {
196
+ Avatar.resetPlatformForTests(h.api);
197
+ Avatar.load(scene);
198
+ await h.fail({ code: 'CASTLE_HOST_UNAVAILABLE' });
199
+ assert.equal(queued.size, 1, 'a retry is scheduled');
200
+ const [[key, retry]] = queued;
201
+ queued.delete(key);
202
+ retry();
203
+ assert.deepEqual(h.inFlight(), [['get']]);
204
+ await h.reply(ok(2, false));
205
+ assert.equal(Avatar.diagnostics().state, 'ready');
206
+ assert.equal(Avatar.diagnostics().retries, 1);
207
+ assert.equal(Avatar.current(scene), 2);
208
+ } finally {
209
+ console.warn = warn;
210
+ Avatar.resetPlatformForTests(null);
211
+ globalThis.setTimeout = realSet;
212
+ globalThis.clearTimeout = realClear;
213
+ }
214
+ });
215
+
172
216
  await test('read retry budget keeps the pick on give-up', async () => {
173
217
  const clock = fakeClock();
174
218
  const scene = { persistent: { hubAvatar: 1 } };
@@ -0,0 +1,82 @@
1
+ import assert from 'node:assert/strict';
2
+ import { readFileSync } from 'node:fs';
3
+ import { kitBackNeeded } from '../code/client/backVisibility.js';
4
+
5
+ // Exercise the real drawChrome decision, including House visits with no local ticket.
6
+ const source = readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
7
+ const start = source.indexOf(' drawChrome(scene, local, now) {');
8
+ const backCall = source.indexOf(' chrome.showBack(', start);
9
+ const backEnd = source.indexOf('\n );', backCall);
10
+ assert.ok(backCall > start && backEnd > backCall);
11
+ const body = source.slice(
12
+ start + ' drawChrome(scene, local, now) {'.length,
13
+ backEnd + '\n );'.length,
14
+ );
15
+ const draw = new Function('scene', 'Hub', 'kitBackNeeded', body);
16
+ const android = 'Mozilla/5.0 (Linux; Android 12) AppleWebKit/537.36';
17
+ const ios = 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)';
18
+ const desktop = 'Mozilla/5.0 (Macintosh; Intel Mac OS X)';
19
+ let cases = 0;
20
+ for (const ua of [android, ios, desktop]) {
21
+ for (const landscape of [false, true]) {
22
+ for (const embed of [
23
+ undefined,
24
+ { host: 'mobile' },
25
+ { host: 'mobile', hubBackInLandscape: true },
26
+ ]) {
27
+ for (const depth of [0, 1, 2]) {
28
+ for (const game of [null, false, true]) {
29
+ for (const ticket of [false, true]) {
30
+ for (const phase of [null, 'opening', 'away']) {
31
+ for (const pendingEnd of [null, {}]) {
32
+ const view = {
33
+ innerWidth: landscape ? 740 : 360,
34
+ innerHeight: landscape ? 360 : 740,
35
+ CastleEmbed: embed,
36
+ navigator: { userAgent: ua },
37
+ };
38
+ globalThis.window = view;
39
+ const scene = {
40
+ persistent: { hubDepth: depth, hubTickets: ticket ? [{ title: 'Town' }] : [] },
41
+ };
42
+ let shown;
43
+ const system = {
44
+ chrome: {
45
+ showBack: (...args) => {
46
+ shown = args;
47
+ },
48
+ },
49
+ trip: phase ? { phase } : null,
50
+ pendingEnd,
51
+ };
52
+ draw.call(
53
+ system,
54
+ scene,
55
+ { hub: { place: game === null ? null : { result: game } } },
56
+ kitBackNeeded,
57
+ );
58
+ const fallback =
59
+ ua === android &&
60
+ landscape &&
61
+ embed?.host === 'mobile' &&
62
+ embed.hubBackInLandscape !== true;
63
+ const expected =
64
+ (phase === 'away' || (!phase && pendingEnd === null)) &&
65
+ (depth > 0 ? fallback && game !== null : Boolean(game) || ticket);
66
+ assert.equal(
67
+ shown[0],
68
+ expected,
69
+ JSON.stringify({ ua, landscape, embed, depth, game, ticket, phase, pendingEnd }),
70
+ );
71
+ if (fallback && depth > 0 && !ticket) assert.equal(shown[1], 'Back');
72
+ cases++;
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ delete globalThis.window;
82
+ console.log(`Back visibility: ${cases} host/place/transition cases passed`);
@@ -531,18 +531,25 @@ const FACES = [{ playerId: 'p1' }, { playerId: 'p2', note: 'on the bench' }, { p
531
531
  'this.ballot.dispose();',
532
532
  'this.ballot = null;',
533
533
  'this.carded = false;',
534
- 'this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded, this.sceneKey);',
535
- "this.chrome.setActions(Hub.hub.actions?.items ?? null, (id, n) => mp.net?.send({ k: 'hub-action', id, n }), !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput, Hub.hub.actions?.n);",
534
+ 'this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.actionInput, this.sceneKey);',
535
+ 'this.act.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput && !this.askInput && !this.menuInput && !this.carded);',
536
+ '}, !this.signIn.pending() && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput,',
536
537
  'if (this.ballot) {',
537
538
  'const box = this.carded ? this.chrome.hudClearBox?.() : null;',
538
539
  'this.ballot.frame(this.carded ? cardFor(mp.net ?? null) : null, Hub.hub.place?.ballot?.lines ?? [], mp.net?.selfId?.() ?? null, Hub.simNow(), box ? box.bottom : 0);',
540
+ "this.chrome.safeSurface?.('ballot', this.ballot?.surface?.());",
539
541
  // A new player id on the same net drops a held card (only one held).
540
542
  'if (ballotHeld) {',
541
543
  'forgetBallot();',
542
- "chrome.showPicker(idle && place !== null && !inGame && !this.talk.talking() && !this.carded, Avatar.current(scene), { available: Avatar.colorsAvailable(), style: Avatar.style(), color: Avatar.currentColor(scene), files: scene.files, model: Avatar.colorsAvailable() && Avatar.style() === 'toon' ? Avatar.model(scene.files, Avatar.current(scene), 'toon') : null });",
544
+ 'const eligible = !this.trip && place && !place.result && this.pendingEnd === null && !this.talk?.talking?.() && !this.carded &&',
543
545
  'const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking() && !this.carded;',
544
- 'chrome.setFeed?.(idle && place !== null && !this.carded ? this.say.feed() : []);',
546
+ 'place?.id, this.trip?.phase, this.pendingEnd !== null, this.carded, this.decor?.opened() === true,',
547
+ 'if (panels) {chrome.setFeed?.(idle && place !== null && !this.carded ? this.say.feed() : []);}',
545
548
  'const canTalk = cam && idle && this.pendingEnd === null && !this.talk.talking() && this.decor?.opened() !== true && !this.carded;',
549
+ 'const pickerFree = idle && place !== null && !this.talk.talking() && !this.carded;',
550
+ 'scene.data?.engine?.hubInviteRail !== true || Hub.hub.place !== place || Boolean(place.result) || this.talk.talking() || this.carded ||',
551
+ // Optional pad readability only reads the card state to hide its caption.
552
+ 'this.carded || this.decor?.opened() === true);',
546
553
  'if (this.ballot) {',
547
554
  'this.ballot.dispose();',
548
555
  'this.ballot = null;',