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
@@ -27,6 +27,7 @@ const State = await import('../code/client/state.js');
27
27
  const hook = (await import('../code/client/hookLayer.js')).default;
28
28
  const { installSystem } = await import('../code/systems/hub.js');
29
29
  const { makeChrome } = await import('../code/client/chrome.js');
30
+ const { makeSignIn } = await import('../code/client/signIn.js');
30
31
  function fakeDom(view) {
31
32
  const log = [];
32
33
  let ids = 0;
@@ -66,6 +67,10 @@ function fakeDom(view) {
66
67
  log.push(`${id} text=${text}`);
67
68
  },
68
69
  appendChild(child) {
70
+ if (child.parent) {
71
+ if (document.activeElement === child) {document.activeElement = document.body;}
72
+ child.parent.children = child.parent.children.filter((c) => c !== child);
73
+ }
69
74
  child.parent = self;
70
75
  self.children.push(child);
71
76
  log.push(`${id} +${child.id}`);
@@ -87,6 +92,7 @@ function fakeDom(view) {
87
92
  if (self.parent) {
88
93
  self.parent.children = self.parent.children.filter((c) => c !== self);
89
94
  log.push(`${id} removed`);
95
+ self.parent = null;
90
96
  }
91
97
  },
92
98
  replaceChildren(...kids) {
@@ -164,6 +170,7 @@ const find = (dom, text) => dom.made.findLast((node) => node.textContent === tex
164
170
  const tap = (node) => node.handlers.click?.({ stopPropagation() {} });
165
171
  let passed = 0;
166
172
  function test(name, fn) { fn(); passed += 1; console.log(`ok: ${name}`); }
173
+ async function testAsync(name, fn) { await fn(); passed += 1; console.log(`ok: ${name}`); }
167
174
  function rig(width = 360, height = 780) {
168
175
  const dom = fakeDom({ viewW: width, viewH: height }), sent = [];
169
176
  const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {} });
@@ -363,6 +370,27 @@ test('640 x 300 fallback clears the measured left edge of the round column', ()
363
370
  assert(chip.getBoundingClientRect().right <= speech.rect.left - 12);
364
371
  r.chrome.dispose();
365
372
  });
373
+ test('640 x 300 fallback remeasures wrapping in its narrower candidate on the first frame', () => {
374
+ const r = rig(640, 300), wide = [{ id: 'wide', label: 'W'.repeat(73) }];
375
+ r.draw(wide);
376
+ const chip = find(r.dom, wide[0].label);
377
+ assert.equal(chip.getBoundingClientRect().width, 551);
378
+ r.chrome.setHud({ title: 'Town' }, null);
379
+ const hud = find(r.dom, 'Town').parent;
380
+ hud.rect = { left: 12, right: 400, top: 12, bottom: 100 };
381
+ r.chrome.setEmotes([['wave', '👋']]);
382
+ const emote = r.dom.made.find((node) => node.attrs['aria-label'] === 'Emote');
383
+ emote.rect = { left: 500, right: 552, top: 100, bottom: 152 };
384
+ r.controls = [hud, emote];
385
+ for (let frame = 0; frame < 8; frame += 1) {
386
+ r.chrome.beginLayoutFrame();
387
+ r.draw(wide);
388
+ assert.equal(assertClearChips(r, wide).length, 1, `frame ${frame}: the wrapped action is visible immediately`);
389
+ assert.deepEqual(chip.getBoundingClientRect(), { left: 12, right: 488, top: 224, bottom: 288, width: 476, height: 64 });
390
+ r.chrome.endLayoutFrame();
391
+ }
392
+ r.chrome.dispose();
393
+ });
366
394
  test('640 x 300 trimming retries the right column when Start alone clears HUD and decor', () => {
367
395
  const r = rig(640, 300);
368
396
  r.chrome.setHud({ title: 'Harvest' }, null); r.chrome.showPicker(true, 0); r.chrome.setEmotes([['wave', '👋']]);
@@ -436,11 +464,134 @@ test('pointer presses leave no focus; focused chips contain Space/Enter down/up
436
464
  assert.deepEqual(r.sent, [{ k: 'hub-action', id: 'start', n: 1 }]);
437
465
  r.chrome.dispose();
438
466
  });
467
+ await testAsync('opt-in overflow keeps all offers in one reusable sheet, current by id and version', async () => {
468
+ const r = rig(509, 218), opened = [];
469
+ r.chrome.showBack(true);
470
+ const back = find(r.dom, '‹ Back');
471
+ // Leave only one launcher-sized slot at the right edge. The measured rail
472
+ // must not trim an offer merely because no direct row clears this obstacle.
473
+ back.rect = { left: 0, right: 380, top: 0, bottom: 218 };
474
+ const long = [
475
+ { id: 'reset', label: 'Reset ball right now' },
476
+ { id: 'practice', label: 'Start practice together' },
477
+ { id: 'watch', label: 'Watch from the rail' },
478
+ ];
479
+ const draw = (value = long, n = 41) => r.chrome.setActions(value, (id, version) => r.sent.push({ id, n: version }), true, n, true, (open) => opened.push(open));
480
+ draw();
481
+ const launcher = find(r.dom, 'Actions (3)');
482
+ assert(launcher); assert.equal(launcher.style.display, 'block'); assert.equal(launcher.tabIndex, 0);
483
+ tap(launcher);
484
+ const backdrop = r.dom.made.find((node) => node.dataset.hub === 'action-backdrop');
485
+ assert.equal(backdrop.style.background, '#14100c', 'open actions fully obscure underlying HUD and world labels');
486
+ const sheet = r.dom.made.find((node) => node.dataset.hub === 'action-sheet');
487
+ assert(sheet); assert.equal(r.chrome.actionOverflowOpen(), true); assert.equal(launcher.tabIndex, -1);
488
+ const original = find(r.dom, 'Start practice together');
489
+ assert.equal(original.parent, sheet);
490
+ original.focus();
491
+ const changed = [
492
+ { id: 'reset', label: 'Reset again' },
493
+ { id: 'practice', label: 'Continue practice' },
494
+ { id: 'leave', label: 'Leave' },
495
+ ];
496
+ tap(original);
497
+ draw(changed, 42);
498
+ assert.deepEqual(r.sent, [{ id: 'practice', n: 41 }]);
499
+ assert.equal(find(r.dom, 'Continue practice'), original, 'offer node is reused by id');
500
+ assert.equal(document.activeElement, original, 'focus stays on a retained id');
501
+ await new Promise((resolve) => setTimeout(resolve, 100));
502
+ assert.equal(r.chrome.actionOverflowOpen(), true, 'an old pressed timer cannot close a changed sheet');
503
+ tap(original); tap(original);
504
+ assert.deepEqual(r.sent.at(-1), { id: 'practice', n: 42 });
505
+ assert.equal(r.sent.length, 2, 'double activation while pressed dispatches once');
506
+ await new Promise((resolve) => setTimeout(resolve, 100));
507
+ assert.equal(r.chrome.actionOverflowOpen(), false);
508
+ assert.deepEqual(opened, [true, false]);
509
+ r.chrome.dispose();
510
+ });
511
+ test('sheet close relays out after an obstacle clears and restores absolute offer placement', () => {
512
+ const r = rig(509, 218);
513
+ r.chrome.showBack(true);
514
+ const back = find(r.dom, '‹ Back');
515
+ back.rect = { left: 0, right: 380, top: 0, bottom: 218 };
516
+ const offered = [
517
+ { id: 'a', label: 'A' },
518
+ { id: 'b', label: 'B' },
519
+ { id: 'c', label: 'C' },
520
+ ];
521
+ r.chrome.setActions(offered, () => {}, true, 4, true);
522
+ tap(find(r.dom, 'Actions (3)'));
523
+ back.rect = null;
524
+ r.chrome.cancelActionOverflow();
525
+ const rail = r.dom.made.find((node) => node.dataset.hub === 'action-rail');
526
+ const shown = offered.map(({ id }) => rail.children.find((node) => node.dataset.actionId === id));
527
+ assert(shown.every((button) => button.style.display === 'block'));
528
+ assert(shown.every((button) => button.style.position === 'absolute'));
529
+ r.chrome.dispose();
530
+ });
531
+ test('retained rail offers follow changed server order without replacing or blurring them', () => {
532
+ const r = rig(844, 390);
533
+ r.chrome.showBack(true);
534
+ const back = find(r.dom, '‹ Back');
535
+ back.rect = { left: 0, right: 64, top: 0, bottom: 56 };
536
+ const offered = [
537
+ { id: 'a', label: 'Alpha' },
538
+ { id: 'b', label: 'Beta' },
539
+ { id: 'c', label: 'Gamma' },
540
+ ];
541
+ r.chrome.setActions(offered, () => {}, true, 5, true);
542
+ const rail = r.dom.made.find((node) => node.dataset.hub === 'action-rail');
543
+ const beta = rail.children.find((node) => node.dataset.actionId === 'b');
544
+ beta.focus();
545
+ r.chrome.setActions([...offered].reverse(), () => {}, true, 6, true);
546
+ assert.deepEqual(rail.children.filter((node) => node.dataset.actionId).map((node) => node.dataset.actionId), ['c', 'b', 'a']);
547
+ assert.equal(rail.children.find((node) => node.dataset.actionId === 'b'), beta);
548
+ assert.equal(document.activeElement, beta);
549
+ r.chrome.setActions([offered[2], offered[0]], () => {}, true, 7, true);
550
+ assert.equal(document.activeElement, back, 'a removed focused offer restores a safe current control');
551
+ r.chrome.dispose();
552
+ });
553
+ test('empty overflow offer closes the sheet, removes its nodes and restores a safe control', () => {
554
+ const r = rig(509, 218), opened = [];
555
+ r.chrome.showBack(true);
556
+ const back = find(r.dom, '‹ Back'); back.rect = { left: 0, right: 380, top: 0, bottom: 218 };
557
+ const offered = [
558
+ { id: 'left', label: 'Shoot left side' },
559
+ { id: 'right', label: 'Shoot right side' },
560
+ { id: 'reset', label: 'Reset the ball' },
561
+ ];
562
+ r.chrome.setActions(offered, () => {}, true, 7, true, (open) => opened.push(open));
563
+ tap(find(r.dom, 'Actions (3)'));
564
+ assert.equal(r.chrome.actionOverflowOpen(), true);
565
+ r.chrome.setActions([], () => {}, true, 8, true, (open) => opened.push(open));
566
+ assert.equal(r.chrome.actionOverflowOpen(), false);
567
+ assert.equal(r.dom.made.findLast((node) => node.dataset.hub === 'action-backdrop').parent, null);
568
+ assert.equal(document.activeElement, back);
569
+ assert.deepEqual(opened, [true, false]);
570
+ r.chrome.dispose();
571
+ });
572
+ test('omitted and false overflow markers produce identical legacy action DOM', () => {
573
+ const snapshot = (flag) => {
574
+ const r = rig(352, 526);
575
+ if (flag === undefined) {r.chrome.setActions(items, () => {}, true, 9);}
576
+ else {r.chrome.setActions(items, () => {}, true, 9, flag);}
577
+ const created = r.dom.made.slice(-4).map((node) => ({
578
+ tag: node.tag,
579
+ text: node.textContent,
580
+ styles: { ...node.styles },
581
+ tabIndex: node.tabIndex,
582
+ handlers: Object.keys(node.handlers).sort(),
583
+ hub: node.dataset.hub ?? null,
584
+ }));
585
+ r.chrome.dispose();
586
+ return created;
587
+ };
588
+ assert.deepEqual(snapshot(), snapshot(false));
589
+ });
439
590
  test('frame wiring only draws in opted-in places and clears once on keyless travel', () => {
440
591
  State.clear(); fakeDom({ viewW: 360, viewH: 780 });
441
592
  let system; installSystem({ registerSystem(value) { system = value; } });
442
593
  const calls = [], sent = [];
443
- system.chrome = new Proxy({ peopleOpen: () => false, chatFocused: () => false }, { get(target, name) { return target[name] ?? ((...args) => calls.push([name, ...args])); } });
594
+ system.chrome = new Proxy({ peopleOpen: () => false, chatFocused: () => false, padOccupancyControls: () => [] }, { get(target, name) { return target[name] ?? ((...args) => calls.push([name, ...args])); } });
444
595
  system.talk = { frame() {}, talking: () => false, typing: () => false, talkingWith: () => null };
445
596
  system.idle = { frame() {}, draw() {}, labels: () => [] };
446
597
  system.grab = { frame() {} }; system.sound = { frame() {} }; system.sayHooked = true;
@@ -453,6 +604,30 @@ test('frame wiring only draws in opted-in places and clears once on keyless trav
453
604
  system.afterBehaviors(scene, 0.05);
454
605
  assert(!calls.some(([name]) => name === 'setActions' || name === 'clearActions'), 'buffered offers do not draw before WORLD');
455
606
  assert(!Object.hasOwn(system, 'actionsDrawn'));
607
+ system.fadeNames(scene);
608
+ assert(!Object.hasOwn(system, 'crowdNamesHeld') && !Object.hasOwn(system, 'crowdFrame') && !Object.hasOwn(system, 'crowdHidden'), 'absent crowd flag allocates no collision or ranking state');
609
+ scene.data = { engine: { hubCrowdNames: false } };
610
+ system.fadeNames(scene);
611
+ assert(!Object.hasOwn(system, 'crowdNamesHeld') && !Object.hasOwn(system, 'crowdFrame') && !Object.hasOwn(system, 'crowdHidden'), 'false crowd flag stays the absent path');
612
+ let cameraUpdates = 0;
613
+ const camera = {
614
+ parent: null,
615
+ matrixWorldAutoUpdate: true,
616
+ updateMatrixWorld() {
617
+ assert(!Object.hasOwn(system, 'crowdFrame'), 'E updates the root camera before capturing shared projection geometry');
618
+ cameraUpdates += 1;
619
+ },
620
+ };
621
+ scene.three = { camera };
622
+ scene.data.engine.hubCrowdNames = true;
623
+ system.afterBehaviors(scene, 0.05);
624
+ assert.equal(cameraUpdates, 1, 'E mirrors the renderer root-camera update once');
625
+ assert.equal(system.crowdFrame.camera, camera, 'the synchronized camera is captured for the late pass');
626
+ scene.data.engine.hubCrowdNames = false;
627
+ system.afterBehaviors(scene, 0.05);
628
+ assert.equal(cameraUpdates, 1, 'OFF does no camera synchronization work');
629
+ system.fadeNames(scene);
630
+ delete scene.three;
456
631
  hook.state({}, { hubPlace: { id: 'main', title: 'Town', scene: 'scenes/main.scene', result: null } });
457
632
  assert(!Object.hasOwn(State.hub, 'actions'));
458
633
  system.afterBehaviors(scene, 0.05);
@@ -462,14 +637,171 @@ test('frame wiring only draws in opted-in places and clears once on keyless trav
462
637
  system.afterBehaviors(scene, 0.05);
463
638
  const draw = calls.findLast(([name]) => name === 'setActions');
464
639
  assert.deepEqual(draw[1], items); assert.equal(draw[3], true);
465
- assert.equal(draw[4], 1);
640
+ assert.equal(draw[4], 1); assert.equal(draw[5], true, 'portrait uses compact overflow without an authored flag');
641
+ window.innerWidth = 844; window.innerHeight = 390;
642
+ system.afterBehaviors(scene, 0.05);
643
+ assert.equal(calls.findLast(([name]) => name === 'setActions')[5], false, 'landscape retains the authored overflow choice');
466
644
  draw[2]('start', draw[4]); assert.deepEqual(sent, [{ k: 'hub-action', id: 'start', n: 1 }]);
645
+ scene.data = { engine: { hubActionOverflow: true } };
646
+ system.afterBehaviors(scene, 0.05);
647
+ const opted = calls.findLast(([name]) => name === 'setActions');
648
+ assert.equal(opted[5], true);
649
+ opted[6](true); assert(system.actionInput);
650
+ let travelled = 0;
651
+ system.chrome.actionOverflowOpen = () => true;
652
+ system.chrome.cancelActionOverflow = () => opted[6](false);
653
+ system.back = () => {travelled += 1;};
654
+ system.backFromControl(scene);
655
+ assert(!system.actionInput, 'platform Back releases the held controls when it dismisses actions');
656
+ assert.equal(travelled, 0, 'platform Back is consumed by the action sheet');
467
657
  hook.state({}, { hubPlace: { id: 'main' } }); system.afterBehaviors(scene, 0.05);
468
658
  assert.equal(calls.filter(([name]) => name === 'clearActions').length, 1);
469
659
  system.afterBehaviors(scene, 0.05);
470
660
  assert.equal(calls.filter(([name]) => name === 'clearActions').length, 1);
471
661
  assert(!Object.hasOwn(system, 'actionsDrawn'));
472
662
  });
663
+ test('opted-in late crowd pass uses current renderer eligibility and restores OFF', () => {
664
+ State.clear();
665
+ State.hub.place = { id: 'main', result: null };
666
+ for (const id of ['a', 'b', 'c']) {State.hub.avatars.set(id, 0);}
667
+ let system; installSystem({ registerSystem(value) { system = value; } });
668
+ const labels = [];
669
+ let ordinaryLabelWrites = 0;
670
+ system.chrome = {
671
+ crowdNameLabelBoxes: () => [],
672
+ measureLabel: (text) => ({ w: text.length * 7 + 20, h: 24 }),
673
+ setLabels: (items) => {ordinaryLabelWrites += 1; labels.splice(0, labels.length, ...items);},
674
+ setCrowdNameSummary: (item) => {
675
+ const ordinary = labels.filter((label) => label.id !== 'crowd:summary');
676
+ labels.splice(0, labels.length, ...ordinary, ...(item ? [item] : []));
677
+ },
678
+ };
679
+ const view = { w: 844, h: 390 };
680
+ const camera = {
681
+ matrixWorld: { elements: [1, 0, 0, 0, 0, 1, 0, 0] },
682
+ position: {
683
+ clone() {
684
+ return {
685
+ set(x, y, z) {this.x = x; this.y = y; this.z = z; return this;},
686
+ project() {
687
+ this.x = ((100 + this.x * 200) / view.w) * 2 - 1;
688
+ this.y = 1 - ((330 - this.y * 120) / view.h) * 2;
689
+ this.z = 0;
690
+ return this;
691
+ },
692
+ };
693
+ },
694
+ },
695
+ };
696
+ const sprite = (x) => ({
697
+ position: { x, y: 2, z: 0 },
698
+ scale: { x: 0.3, y: 0.16 },
699
+ material: { opacity: 1 },
700
+ visible: true,
701
+ });
702
+ const tags = new Map(['c', 'b', 'a'].map((id, index) => [id, { sprite: sprite((2 - index) * 0.4) }]));
703
+ const actors = new Map(['a', 'b', 'c'].map((id) => [id, `actor:${id}`]));
704
+ const transforms = new Map([['a', 0], ['b', 0.4], ['c', 0.8]].map(([id, x]) => [`actor:${id}`, { x, y: 0, z: 0 }]));
705
+ const roster = new Map([['a', 'same'], ['b', 'same'], ['c', 'same']]);
706
+ let netState = 'connected';
707
+ const net = { others: () => roster, userId: (id) => `u${id}`, status: () => netState === null ? undefined : { state: netState } };
708
+ const local = { components: { Transform: { x: 0, y: 0, z: 0 } } };
709
+ const scene = {
710
+ data: { engine: { hubCrowdNames: true } },
711
+ multiplayer: { net, avatars: { tags, actors } },
712
+ three: { camera },
713
+ actorWith: () => local,
714
+ getActor: (id) => ({ components: { Transform: transforms.get(id) } }),
715
+ };
716
+ system.friendsAll = [{ userId: 'uc' }];
717
+ system.helloMark = { selfId: 'self', again: 0 };
718
+ system.crowdFrame = { scene, data: scene.data, net, camera, local: local.components.Transform, own: null, controls: [], view, labels: [] };
719
+ system.fadeNames(scene);
720
+ assert.equal(tags.get('c').sprite.visible, true, 'current friend has first priority');
721
+ assert.equal([...tags.values()].filter((tag) => tag.sprite.visible).length, 2);
722
+ const eScale = system.crowdNameScales.get(tags.get('a').sprite);
723
+ assert.ok(eScale && eScale.scaledY > eScale.y, 'E raises a too-small projected font before collision');
724
+ assert.ok(Math.abs(eScale.scaledY * 120 * 44 / 68 - 15) < 1e-9, 'the final projected font meets the 15 CSS pixel floor');
725
+ assert.equal(labels.at(-1).text, '+1 more');
726
+ assert.equal(ordinaryLabelWrites, 0, 'late crowd pass does not reset already-cleared ordinary labels');
727
+ const firstVisit = system.crowdNamesHeld.state;
728
+ system.helloMark = { selfId: 'self', again: 1 };
729
+ system.fadeNames(scene);
730
+ assert.notEqual(system.crowdNamesHeld.state, firstVisit, 'same-net WORLD reconnect clears late-pass history');
731
+ State.hub.avatars.delete('c');
732
+ system.fadeNames(scene);
733
+ assert.equal(tags.get('c').sprite.visible, false, 'renderer eligibility revocation is immediate and not counted');
734
+ assert.equal(labels.find((item) => item.id === 'crowd:summary')?.text, '+1 more', 'summary counts only the still-eligible suppressed candidate');
735
+ State.hub.avatars.set('c', 0);
736
+ const originalData = scene.data;
737
+ const originalMultiplayer = scene.multiplayer;
738
+ const validFrame = () => ({ scene, data: scene.data, net: scene.multiplayer.net, camera: scene.three.camera, local: local.components.Transform, own: null, controls: [], view, labels: [] });
739
+ const prerequisiteCases = [
740
+ ['multiplayer missing', () => {scene.multiplayer = null;}],
741
+ ['net missing', () => {scene.multiplayer.net = null;}],
742
+ ['camera missing', () => {scene.three.camera = null;}],
743
+ ['fresh frame with camera missing', () => {scene.three.camera = null; system.crowdFrame = validFrame();}],
744
+ ['frame scene mismatch', () => {system.crowdFrame = { ...validFrame(), scene: {} };}],
745
+ ['frame absent', () => {delete system.crowdFrame;}],
746
+ ['reconnecting net with retained roster', () => {netState = 'reconnecting';}],
747
+ ['unknown net status', () => {netState = 'mystery';}],
748
+ ['unavailable net status', () => {netState = null;}],
749
+ ['same-scene data replacement', () => {scene.data = { engine: { hubCrowdNames: true } };}],
750
+ ['same-scene net replacement', () => {scene.multiplayer.net = { ...net, status: () => ({ state: 'connected' }) };}],
751
+ ['same-scene camera replacement', () => {scene.three.camera = { ...camera };}],
752
+ ];
753
+ for (const [name, invalidate] of prerequisiteCases) {
754
+ netState = 'connected';
755
+ scene.data = originalData;
756
+ scene.multiplayer = originalMultiplayer;
757
+ scene.multiplayer.net = net;
758
+ scene.three.camera = camera;
759
+ system.crowdFrame = validFrame();
760
+ system.fadeNames(scene);
761
+ const visit = system.crowdNamesHeld.state;
762
+ const scales = [...system.crowdNameScales.entries()];
763
+ assert(labels.some((item) => item.id === 'crowd:summary'), `${name}: fixture begins with a populated summary`);
764
+ invalidate();
765
+ system.fadeNames(scene);
766
+ assert(!labels.some((item) => item.id === 'crowd:summary'), `${name}: stale summary is destroyed`);
767
+ assert([...tags.values()].every((tag) => !tag.sprite.visible), `${name}: no nonself name is exposed`);
768
+ assert(!Object.hasOwn(system, 'crowdNamesHeld'), `${name}: visit ranking is reset`);
769
+ assert(!Object.hasOwn(system, 'crowdFrame'), `${name}: stale frame provenance is discarded`);
770
+ assert(!Object.hasOwn(system, 'crowdNameScales'), `${name}: E leaves no scale override`);
771
+ assert(!Object.hasOwn(system, 'crowdSprites'), `${name}: prior sprite ownership moves into the hidden recovery set`);
772
+ for (const [scaledSprite, scale] of scales) {
773
+ assert.equal(scaledSprite.scale.x, scale.x, `${name}: ordinary x scale is restored`);
774
+ assert.equal(scaledSprite.scale.y, scale.y, `${name}: ordinary y scale is restored`);
775
+ }
776
+ netState = 'connected';
777
+ scene.data = originalData;
778
+ scene.multiplayer = originalMultiplayer;
779
+ scene.multiplayer.net = net;
780
+ scene.three.camera = camera;
781
+ system.crowdFrame = validFrame();
782
+ system.fadeNames(scene);
783
+ assert.notEqual(system.crowdNamesHeld.state, visit, `${name}: authorized recovery starts a fresh visit state`);
784
+ assert([...tags.values()].some((tag) => tag.sprite.visible), `${name}: authorized names recover`);
785
+ assert(labels.some((item) => item.id === 'crowd:summary'), `${name}: current eligible summary recovers`);
786
+ }
787
+ scene.data.engine.hubCrowdNames = false;
788
+ system.fadeNames(scene);
789
+ assert.equal(tags.get('a').sprite.scale.x, eScale.x, 'OFF restores the exact ordinary scale E replaced');
790
+ assert.equal(tags.get('a').sprite.scale.y, eScale.y, 'OFF restores both scale axes');
791
+ assert([...tags.values()].every((tag) => tag.sprite.visible), 'OFF restores only E-suppressed sprites through the baseline pass');
792
+ assert(!Object.hasOwn(system, 'crowdNamesHeld') && !Object.hasOwn(system, 'crowdFrame') && !Object.hasOwn(system, 'crowdHidden'));
793
+ assert(!Object.hasOwn(system, 'crowdNameScales'));
794
+ const rendererResized = { scale: { x: 9, y: 10 } };
795
+ system.crowdNameScales = new Map([[rendererResized, { x: 1, y: 2, scaledX: 3, scaledY: 4 }]]);
796
+ system.restoreCrowdNameScales();
797
+ assert.deepEqual(rendererResized.scale, { x: 9, y: 10 }, 'restoration never overwrites a newer multiplayer scale');
798
+ scene.data.engine.hubCrowdNames = true;
799
+ system.crowdFrame = { ...validFrame(), view: { w: 509, h: 218 } };
800
+ system.fadeNames(scene);
801
+ assert(!Object.hasOwn(system, 'crowdNameScales'), 'the tiny layout suppresses individuals without scale overrides');
802
+ scene.data.engine.hubCrowdNames = false;
803
+ system.fadeNames(scene);
804
+ });
473
805
  test('rehello drops stale chips, identity clear drops them, avatar hello keeps them', () => {
474
806
  let system; installSystem({ registerSystem(value) { system = value; } });
475
807
  State.clear(); State.hub.place = { actions: true }; State.hub.actions = { items, n: 1 };
@@ -485,4 +817,37 @@ test('rehello drops stale chips, identity clear drops them, avatar hello keeps t
485
817
  State.clear(); assert(!Object.hasOwn(State.hub, 'actions'));
486
818
  system.sendHello(scene, mp, net, 0, {}); assert(!Object.hasOwn(State.hub, 'actions'));
487
819
  });
820
+ for (const status of ['signedIn', 'dismissed', 'unavailable', 'UNKNOWN_COMMAND']) {
821
+ State.clear(); fakeDom({ viewW: 360, viewH: 780 });
822
+ let system; installSystem({ registerSystem(value) { system = value; } });
823
+ const calls = [], sent = [], requests = [];
824
+ system.chrome = new Proxy({ peopleOpen: () => false, chatFocused: () => false }, { get(target, name) { return target[name] ?? ((...args) => calls.push([name, ...args])); } });
825
+ system.talk = { frame() {}, talking: () => false, typing: () => false, talkingWith: () => null };
826
+ system.idle = { frame() {}, draw() {}, labels: () => [] };
827
+ system.grab = { frame() {} }; system.sound = { frame() {} }; system.sayHooked = true;
828
+ system.together.frame = () => {};
829
+ for (const method of ['keepResident', 'wearAvatar', 'applyTune', 'watchSession', 'sayHello', 'followPlace', 'holdFall', 'turnSpinners', 'applySpawns', 'applyTints', 'registerInterest', 'applyVisibility', 'applyWear', 'adoptLate', 'runCommands', 'askFriends', 'stepEnd', 'faceArrival', 'measure']) system[method] = () => {};
830
+ system.sceneKey = 'main';
831
+ const scene = { sceneKey: 'main', currentScenePath: 'scenes/main.scene', multiplayer: { net: { selfId: () => 'p1', send: (msg) => sent.push(msg) } }, actorWith: () => null, persistent: { hubTickets: [], hubAvatar: 0 }, getActors: () => [] };
832
+ const identity = system.helloNet = scene.multiplayer.net;
833
+ system.signIn = makeSignIn({ api: { signIn: async (params) => {
834
+ requests.push(params);
835
+ if (status === 'UNKNOWN_COMMAND') throw Object.assign(new Error('Unknown command'), { code: status });
836
+ return { status };
837
+ } }, signedIn: () => { system.helloNet = null; } });
838
+ State.hub.place = { id: 'main', anonymousEntry: true };
839
+ State.hub.hudMe = { title: 'Practice', text: 'Sign in to keep your progress' };
840
+ system.afterBehaviors(scene, 0.05);
841
+ const draw = calls.findLast(([name]) => name === 'setActions');
842
+ assert.equal(draw[1][0].id, 'signin');
843
+ draw[2]('signin', draw[4]);
844
+ await new Promise((resolve) => setImmediate(resolve));
845
+ assert.deepEqual(requests, [{ reason: 'Sign in to keep your progress' }]);
846
+ assert.deepEqual(sent, [], 'native sign-in chip never sends a forged server action');
847
+ assert.equal(system.helloNet, status === 'signedIn' ? null : identity);
848
+ system.afterBehaviors(scene, 0.05);
849
+ if (status === 'UNKNOWN_COMMAND' || status === 'unavailable') assert.equal(calls.findLast(([name]) => name === 'setActions')[1], null);
850
+ passed += 1;
851
+ console.log(`ok: real system sign-in chip handles ${status}`);
852
+ }
488
853
  console.log(`${passed} action client tests passed`);
@@ -229,12 +229,13 @@ test('mark: a coloured tag over a player who is here, for everyone, until cleare
229
229
  assert.equal(hub.mark('p1', null), false);
230
230
  });
231
231
 
232
- test('a scene with no ground catches a fallen player at the arrival, after the game may', () => {
232
+ test('every scene catches a fallen player at the arrival, after the game may', () => {
233
233
  const falls = [];
234
234
  for (const [label, sceneGround, fallHook, fallY] of [
235
+ ['implicit ground', () => null, null, undefined],
235
236
  ['no ground', () => ({ none: true }), null, undefined],
236
237
  ['fallY', () => null, null, 3],
237
- ['the game places them', () => ({ none: true }), (hub, id) => hub.placeAt(id, { x: 7, y: 2, z: 7 }), undefined],
238
+ ['the game places them', () => null, (hub, id) => hub.placeAt(id, { x: 7, y: 2, z: 7 }), undefined],
238
239
  ]) {
239
240
  const json = { server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Pits', ...(fallY === undefined ? {} : { fallY }) } };
240
241
  const hooks = fallHook ? { fall: (hub, id) => (falls.push(id), fallHook(hub, id)) } : {};
@@ -256,12 +257,17 @@ test('a scene with no ground catches a fallen player at the arrival, after the g
256
257
  } else {
257
258
  assert.deepEqual([body.at.x, body.at.z], [0, 0], label);
258
259
  // v1.48: implicit ground proves standing height; no support keeps the drop.
259
- assert.equal(body.at.y, label === 'fallY' ? 0.76 : 1.2, label);
260
+ assert.equal(body.at.y, label === 'no ground' ? 1.2 : 0.76, label);
260
261
  }
261
262
  }
262
263
  assert.deepEqual(falls, ['p1']);
263
- // A scene with its ground and no fallY never catches anyone.
264
- const h = layer(castleJson, {}, {}, sceneExists, () => null);
264
+ });
265
+
266
+ test('a place hold below the default fall line is not caught', () => {
267
+ let hub = null;
268
+ let falls = 0;
269
+ const json = { server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Low hold' } };
270
+ const h = layer(json, { ready: (ctx) => (hub = ctx), fall: () => (falls += 1) }, {}, sceneExists, () => null);
265
271
  const session = { sessionId: 's-1', players: [{ playerId: 'p1', username: 'ada' }], hub: null, send() {}, broadcast() {} };
266
272
  h.sceneFor(session);
267
273
  const body = { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } };
@@ -269,9 +275,16 @@ test('a scene with no ground catches a fallen player at the arrival, after the g
269
275
  h.ready(world);
270
276
  h.message(session, { playerId: 'p1' }, { k: 'hub-hello', avatar: 0 });
271
277
  h.place(world);
272
- body.at = { x: 4, y: -25, z: 4 };
278
+ hub.hold('p1', { x: 4, y: -24, z: 5 });
279
+ h.place(world);
280
+ assert.deepEqual(body.at, { x: 4, y: -24, z: 5 });
281
+ assert.equal(falls, 0);
282
+
283
+ hub.release('p1');
273
284
  h.place(world);
274
- assert.equal(body.at.y, -25);
285
+ assert.deepEqual([body.at.x, body.at.z], [0, 0]);
286
+ assert.equal(body.at.y, 0.76);
287
+ assert.equal(falls, 1, 'the same low pose is caught after release');
275
288
  });
276
289
 
277
290
  test("a dev deck door reads the destination's castle.json, its props only without one", () => {
@@ -0,0 +1,76 @@
1
+ import assert from 'node:assert/strict';
2
+ import * as A from '../code/server/analytics.js';
3
+ import { readManifest, publicPlace } from '../code/server/manifest.js';
4
+ import * as Town from '../../../experiments/hub-town/code/server/analytics.js';
5
+ const castle = (hub = {}) => ({ hub: { contract: 1, title: 'Town', ...hub } });
6
+ const old = readManifest(castle()).manifest.places.main;
7
+ assert(!Object.hasOwn(old, 'analytics'));
8
+ const on = readManifest(castle({ analytics: true })).manifest.places.main;
9
+ assert.equal(on.analytics, true);
10
+ assert.deepEqual(publicPlace('main', on), publicPlace('main', old), 'analytics must not add client wire fields');
11
+ for (const analytics of [false, 1, 'true', {}, null]) assert(readManifest(castle({ analytics })).errors.some((e) => e.includes('.analytics')));
12
+ const v111 = readManifest(castle({ analytics: true, analyticsV111: true })).manifest.places.main;
13
+ assert.equal(v111.analyticsV111, true);
14
+ assert.deepEqual(publicPlace('main', v111), publicPlace('main', old), 'v1.111 analytics must not add client wire fields');
15
+ assert(readManifest(castle({ analyticsV111: true })).errors.some((e) => e.includes('requires analytics')));
16
+ for (const analyticsV111 of [false, 1, 'true', {}, null]) assert(readManifest(castle({ analytics: true, analyticsV111 })).errors.some((e) => e.includes('.analyticsV111')));
17
+ const calls = [];
18
+ const h = { place: { analytics: true }, manifest: {}, sim: { timeMs: 0 }, players: new Map([['p', { arrived: true }]]),
19
+ session: { hub: { track: (id, event) => { calls.push([id, event]); return Promise.resolve(true); } } }, analytics: A.create() };
20
+ A.arrive(h, [{ playerId: 'p', userId: '42' }]);
21
+ assert.equal(calls.at(-1)[1].kind, A.EVENTS.arrive);
22
+ for (const props of [{ text: 'private words' }, { subject: 'another user' }, { value: null }, { value: -1 }, { value: NaN }]) assert.equal(A.track(h, 'p', 'outcome', props), false);
23
+ for (const event of ['invite_sent', 'invite_opened', 'invite_joined', 'arrival_source', 'join_failed']) assert.equal(A.track(h, 'p', event), false, `${event} is platform-owned`);
24
+ assert.equal(A.track(h, 'stranger', 'outcome'), false);
25
+ h.sim.timeMs = 1000; A.leave(h, 'p'); A.leave(h, 'p');
26
+ assert.equal(calls.filter(([, e]) => e.kind === A.EVENTS.session_end).length, 1);
27
+ h.sim.timeMs = 31000; A.arrive(h, [{ playerId: 'p', userId: '42' }]);
28
+ assert.equal(calls.at(-1)[1].kind, A.EVENTS.reconnect);
29
+ h.sim.timeMs = 32000; A.leave(h, 'p');
30
+ A.arrive(h, [{ playerId: 'p', userId: '42', from: 'race' }]);
31
+ assert.equal(calls.at(-1)[1].kind, A.EVENTS.arrive, 'door returns are town arrivals');
32
+ h.manifest.house = {}; A.arrive(h, [{ playerId: 'p', userId: '43' }]);
33
+ assert.equal(calls.at(-1)[1].kind, A.EVENTS.house_visit, 'house entry must not be a town arrival');
34
+ const before = calls.length; h.place.analytics = undefined;
35
+ assert.equal(A.track(h, 'p', 'arrive'), false); assert.equal(calls.length, before);
36
+ // Town spans start only on accepted interactions; durations exclude the inactivity tail.
37
+ const events = [], town = { now: 0, track: (id, event, props) => events.push([id, event, props]) };
38
+ Town.pulse(town, 'p', 2); town.now = 5000; Town.pulse(town, 'p', 2, 2, 3);
39
+ town.now = 35001; Town.tick(town);
40
+ assert.deepEqual(events.map(([, event]) => event), ['activity_start', 'outcome', 'outcome', 'activity_end']);
41
+ assert.equal(events.at(-1)[2].value, 5000);
42
+ Town.leave(town, 'p'); assert.equal(events.length, 4);
43
+ console.log('hub analytics opt-in, privacy, lifecycle and engagement spans: passed');
44
+
45
+ const casts = [], fisher = { now: 0, track: (id, event) => casts.push(event) };
46
+ Town.touch(fisher, 'p', 4);
47
+ assert.deepEqual(casts, ['activity_start'], 'a cast begins fishing without inventing a catch');
48
+
49
+ const fpsConfig = { buildSha: 'a'.repeat(40), scene: 'scenes/main.scene' };
50
+ const fpsPlace = readManifest(castle({ analytics: true, fpsTelemetry: fpsConfig }));
51
+ assert.deepEqual(fpsPlace.errors, []);
52
+ assert.deepEqual(fpsPlace.manifest.places.main.fpsTelemetry, fpsConfig);
53
+ assert.deepEqual(publicPlace('main', fpsPlace.manifest.places.main), { ...publicPlace('main', on), fpsTelemetry: fpsConfig });
54
+ assert.equal(Object.hasOwn(publicPlace('main', old), 'fpsTelemetry'), false, 'absent opt-in adds no wire field');
55
+ for (const fpsTelemetry of [true, {}, { ...fpsConfig, buildSha: 'abc' }, { ...fpsConfig, scene: 'other.scene' }, { ...fpsConfig, text: 'hi' }]) {
56
+ assert(readManifest(castle({ analytics: true, fpsTelemetry })).errors.some((e) => e.includes('.fpsTelemetry')));
57
+ }
58
+ assert(readManifest(castle({ fpsTelemetry: fpsConfig })).errors.some((e) => e.includes('.fpsTelemetry')));
59
+
60
+ {
61
+ const events = [];
62
+ const h = { firstVisit: { live: ['home', 'door'] }, place: { analytics: true }, manifest: {}, sim: { timeMs: 0 },
63
+ players: new Map([['p', { arrived: true }]]), analytics: A.create(),
64
+ session: { hub: { track: (id, event) => { events.push(event); return true; } } } };
65
+ A.arrive(h, [{ playerId: 'p', userId: '42' }]);
66
+ assert.equal(events.length, 0, 'arrival waits for storage assignment');
67
+ assert.equal(A.firstVisitArrived(h, 'p', 4), false);
68
+ assert.equal(A.firstVisitArrived(h, 'p', 2), true);
69
+ assert.equal(A.firstVisitArrived(h, 'p', 1), false, 'arrival emits once');
70
+ assert.deepEqual(events, [{ kind: 1, subject: 0, value: 0, result: 1, flags: 2 }]);
71
+ A.arrive(h, [{ playerId: 'p', userId: '42', from: 'game' }]);
72
+ A.firstVisitArrived(h, 'p', 2);
73
+ assert.equal(events.at(-1).flags, 2, 'door return carries sticky variant');
74
+ A.leave(h, 'p'); A.arrive(h, [{ playerId: 'p', userId: '42' }]);
75
+ assert.equal(events.at(-1).kind, 10, 'short reconnect stays reconnect');
76
+ }
@@ -0,0 +1,28 @@
1
+ import assert from 'node:assert/strict';
2
+ import { makeAnonymousEntry } from '../code/server/anonymousEntry.js';
3
+
4
+ const guest = { playerId: 'g1', userId: '101', isAnonymous: true };
5
+ const signed = { playerId: 'p2', userId: '101', isAnonymous: false };
6
+ const pose = { x: 8, y: 1, z: 12, facing: 1.25 };
7
+ for (const pause of [30_000, 180_000]) {
8
+ const entry = makeAnonymousEntry();
9
+ entry.remember(guest, pose, 7, 11, 0);
10
+ assert.equal(entry.take({ ...signed, userId: '102' }, pause), null, 'existing-account login never merges another identity');
11
+ assert.equal(entry.take(guest, pause), null, 'guest reconnect does not consume sign-up state');
12
+ assert.deepEqual(entry.take(signed, pause), { userId: '101', playerId: 'g1', pose, avatar: 7, color: 11, until: 600_000, guestKey: 'g:g1', userKey: 'u:101' });
13
+ assert.equal(entry.take(signed, pause), null, 'one-time carry');
14
+ }
15
+ const expired = makeAnonymousEntry({ ttlMs: 30_000 });
16
+ expired.remember(guest, pose, 2, 4, 0);
17
+ assert.equal(expired.take(signed, 30_001), null);
18
+ const bounded = makeAnonymousEntry({ max: 1 });
19
+ bounded.remember(guest, pose, 2, 4, 0);
20
+ bounded.remember({ ...guest, userId: '102', playerId: 'g2' }, pose, 3, 5, 1);
21
+ assert.equal(bounded.take(signed, 2), null);
22
+ assert.equal(bounded.take({ ...signed, userId: '102' }, 2).avatar, 3);
23
+ const immutable = makeAnonymousEntry();
24
+ const moving = { ...pose };
25
+ immutable.remember(guest, moving, 1, 6, 0);
26
+ moving.x = 100;
27
+ assert.equal(immutable.take(signed, 1).pose.x, 8);
28
+ console.log('ok: sign-up continuity at 30s/3min, trusted identity, expiry, bounds, copy isolation');