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
@@ -1,14 +1,20 @@
1
1
  // A player Castle has barred from the hub (CastleError CAULDRON_HUB_BANNED)
2
2
  // is not joined again by multiplayer-3d's join loop: neither after a first
3
3
  // join refused that way nor after a connection whose recovery was refused that
4
- // way. Any other failure is retried as it always was, which is what ordinary
5
- // decks see. A hub join whose connection closes before the session placed the
4
+ // way. Invite refusals are also final; other failures retry with backoff.
5
+ // A hub join whose connection closes before the session placed the
6
6
  // player reads 'lost'; no other join ever does. Everything multiplayer.js
7
7
  // imports but the join loop is stubbed.
8
8
  // `npm run check` runs it; it needs nothing installed.
9
9
 
10
10
  import assert from 'node:assert/strict';
11
11
  import { register } from 'node:module';
12
+ import { makeLoadingCover } from '../code/client/loadingCover.js';
13
+ import { BANNED_TEXT, joinErrorText } from '../code/client/joinError.js';
14
+
15
+ let pageMs = 1000;
16
+ const realPerformance = globalThis.performance;
17
+ Object.defineProperty(globalThis, 'performance', { value: { now: () => pageMs }, configurable: true });
12
18
 
13
19
  const noop = (names) => names.map((name) => `export const ${name} = () => ({ actors: new Map() });`).join(' ');
14
20
  const realTime = new URL('../../real-time/code/client/', import.meta.url).href;
@@ -67,37 +73,136 @@ console.log = () => {};
67
73
 
68
74
  let n = 0;
69
75
 
70
- // A first join refused as barred: not asked again, no overlay, joinError says so.
71
- {
76
+ // Terminal refusals stop joining and release both covers after a world draw.
77
+ for (const code of ['CAULDRON_HUB_BANNED', 'CAULDRON_HUB_INVITE_FORBIDDEN', 'CAULDRON_HUB_INVITE_EXPIRED',
78
+ 'CAULDRON_HUB_INVITE_EXHAUSTED', 'CAULDRON_HUB_INVITE_INVALID']) {
72
79
  const system = make();
73
80
  attempts = 0;
74
- answer = () => Promise.reject(castleError('CAULDRON_HUB_BANNED'));
81
+ answer = () => Promise.reject(castleError(code));
75
82
  for (let i = 0; i < 5; i += 1) {
76
83
  system.afterBehaviors(scene, 0.016);
77
84
  await flush();
85
+ pageMs += 60000;
78
86
  }
79
87
  assert.equal(attempts, 1);
80
- assert.equal(system.joinError, 'CAULDRON_HUB_BANNED');
88
+ assert.equal(system.joinError, code);
89
+ assert.equal(system.joinFailed, true);
90
+ assert.equal(system.joiningOverlayWanted(), false);
91
+ assert.equal(joinErrorText(code), code === 'CAULDRON_HUB_BANNED' ? BANNED_TEXT : 'This invite is unavailable.');
92
+ system.away(pageMs);
81
93
  assert.equal(system.joiningOverlayWanted(), false);
94
+
95
+ const element = () => ({
96
+ children: [], attrs: {}, setAttribute(k, v) { this.attrs[k] = v; }, removeAttribute(k) { delete this.attrs[k]; },
97
+ append(...children) { for (const child of children) { child.remove(); child.parent = this; this.children.push(child); } },
98
+ remove() { if (this.parent) this.parent.children = this.parent.children.filter(child => child !== this); this.parent = null; },
99
+ });
100
+ const doc = { head: element(), body: element(), documentElement: element(), createElement: element,
101
+ addEventListener() {}, removeEventListener() {} };
102
+ const cover = makeLoadingCover({ enabled: true, title: 'Town', document: doc });
103
+ const renderer = { info: { render: { frame: 0 } }, getContext: () => ({ isContextLost: () => false }) };
104
+ const composer = { render() { renderer.info.render.frame++; } };
105
+ // joinError alone is terminal, even if a stale transport still says reconnecting.
106
+ const coverScene = { three: { renderer, composer }, multiplayer: {
107
+ joinError: code, net: { status: () => ({ state: 'reconnecting' }) },
108
+ } };
109
+ cover.sync(coverScene);
110
+ assert.ok('data-hub-loading' in doc.documentElement.attrs);
111
+ composer.render();
112
+ assert.equal('data-hub-loading' in doc.documentElement.attrs, false);
113
+ assert.equal(doc.body.children.length, 0);
114
+ cover.sync(coverScene);
115
+ assert.equal('data-hub-loading' in doc.documentElement.attrs, false, 'terminal refusal cannot restore the spinner');
116
+ cover.dispose();
82
117
  n += 1;
83
118
  }
84
119
 
85
- // Any other failure is asked again, as before (an ordinary deck's join).
86
- {
120
+ // Transient public failures retry at the deadline while frames keep stepping,
121
+ // stop after three attempts, and reset their count only after placement.
122
+ for (const code of ['MULTIPLAYER_UNAVAILABLE', 'CAULDRON_HUB_INVITE_NOT_IN_SESSION']) {
87
123
  const system = make();
88
124
  attempts = 0;
89
- answer = () => Promise.reject(castleError('MULTIPLAYER_UNAVAILABLE'));
90
- for (let i = 0; i < 5; i += 1) {
125
+ answer = () => Promise.reject(castleError(code));
126
+ assert.equal(joinErrorText(code), null);
127
+ // A frame gap over STALL_MS now clears backoff as a visible return. These
128
+ // checks exercise ordinary backoff, so the page must keep stepping.
129
+ const advance = async (ms) => {
130
+ const until = pageMs + ms;
131
+ while (pageMs < until) {
132
+ pageMs = Math.min(until, pageMs + 250);
133
+ system.afterBehaviors(scene, 0.016);
134
+ await flush();
135
+ }
136
+ };
137
+ system.afterBehaviors(scene, 0.016);
138
+ await flush();
139
+ for (const delay of [1000, 2000]) {
140
+ const before = attempts;
141
+ for (let i = 0; i < 5; i++) {
142
+ system.afterBehaviors(scene, 0.016);
143
+ await flush();
144
+ }
145
+ assert.equal(attempts, before, 'frames cannot bypass backoff');
146
+ await advance(delay - 1);
147
+ assert.equal(attempts, before);
148
+ pageMs++;
91
149
  system.afterBehaviors(scene, 0.016);
92
150
  await flush();
151
+ assert.equal(attempts, before + 1);
93
152
  }
94
- assert.ok(attempts > 1);
95
153
  assert.equal(system.joinError, null);
154
+ assert.equal(system.joinFailed, true, 'three transient failures need an explicit retry');
155
+ assert.equal(system.joinFailures, 3);
156
+ await advance(30000);
157
+ const net = {
158
+ close() {},
159
+ status: () => ({ state: 'connected', solo: false }),
160
+ selfId: () => 'self',
161
+ drain: () => [{ k: 'w', t: pageMs, localMs: pageMs, ps: [], os: [], own: [] }],
162
+ };
163
+ answer = () => Promise.resolve(net);
164
+ await system.start(scene);
165
+ assert.equal(attempts, 3, 'network recovery alone cannot restart a given-up join');
166
+ assert.equal(system.net, null);
167
+
168
+ // A fresh session still permits an immediate attempt and clears backoff.
169
+ system.reset = () => {};
170
+ system.switchSession(scene, { mode: 'public' });
171
+ assert.equal(system.joinFailures, 0);
172
+ assert.equal(system.joinRetryAt, 0);
173
+ answer = () => Promise.reject(castleError(code));
174
+ const before = attempts;
175
+ await system.start(scene);
176
+ assert.equal(attempts, before + 1, 'switchSession permits an immediate first attempt');
177
+ pageMs += 1000;
178
+ answer = () => Promise.resolve(net);
179
+ await system.start(scene);
180
+ assert.equal(system.net, net, 'a fresh join recovers when the network returns');
181
+ assert.equal(system.joinFailures, 1, 'connecting alone does not reset failures');
182
+ assert.equal(system.joinRetryAt, 0);
183
+ system.net = null;
184
+ system.starting = false;
185
+ answer = () => Promise.reject(castleError(code));
186
+ await system.start(scene);
187
+ assert.equal(system.joinRetryAt - pageMs, 2000, 'an unplaced connection retains the next backoff');
188
+
189
+ pageMs += 2000;
190
+ answer = () => Promise.resolve(net);
191
+ await system.start(scene);
192
+ assert.equal(system.joinFailures, 2, 'a second unplaced connection still retains both failures');
193
+ system.receive(scene);
194
+ assert.equal(system.joined, true);
195
+ assert.equal(system.joinFailures, 0, 'placement resets consecutive failures');
196
+ system.net = null;
197
+ system.starting = false;
198
+ answer = () => Promise.reject(castleError(code));
199
+ await system.start(scene);
200
+ assert.equal(system.joinRetryAt - pageMs, 1000, 'placement resets the next backoff');
96
201
  n += 1;
97
202
  }
98
203
 
99
204
  // A connection closed because its recovery was refused as barred: not joined again.
100
- for (const [closeCode, rejoins] of [['CAULDRON_HUB_BANNED', false], ['MULTIPLAYER_CONNECTION_LOST', true], [null, true]]) {
205
+ for (const [closeCode, rejoins] of [['CAULDRON_HUB_BANNED', false], ['CAULDRON_HUB_INVITE_FORBIDDEN', false], ['MULTIPLAYER_CONNECTION_LOST', true], [null, true]]) {
101
206
  const system = make();
102
207
  attempts = 0;
103
208
  let closed = false;
@@ -114,12 +219,13 @@ for (const [closeCode, rejoins] of [['CAULDRON_HUB_BANNED', false], ['MULTIPLAYE
114
219
  closed = true;
115
220
  system.reset = () => {};
116
221
  system.afterBehaviors(scene, 0.016);
222
+ if (rejoins) { pageMs += 1000; } // pre-placement closes now count as a failed attempt
117
223
  for (let i = 0; i < 3; i += 1) {
118
224
  system.afterBehaviors(scene, 0.016);
119
225
  await flush();
120
226
  }
121
227
  assert.equal(attempts > 1, rejoins, `closed on ${closeCode}`);
122
- assert.equal(system.joinError, rejoins ? null : 'CAULDRON_HUB_BANNED');
228
+ assert.equal(system.joinError, rejoins ? null : closeCode);
123
229
  n += 1;
124
230
  }
125
231
 
@@ -152,6 +258,7 @@ for (const [target, placedFirst, state, rejoins] of [
152
258
  closed = true;
153
259
  system.afterBehaviors(scene, 0.016);
154
260
  assert.equal(system.joinState(), state, `${target.mode} placed=${placedFirst}`);
261
+ if (rejoins) { pageMs += 1000; } // pre-placement closes now count as a failed attempt
155
262
  for (let i = 0; i < 3; i += 1) {
156
263
  system.afterBehaviors(scene, 0.016);
157
264
  await flush();
@@ -191,4 +298,5 @@ for (const [target, placedFirst, state, rejoins] of [
191
298
  }
192
299
 
193
300
  console.log = log;
301
+ Object.defineProperty(globalThis, 'performance', { value: realPerformance, configurable: true });
194
302
  console.log(`test-ban-join: ${n} ok`);
@@ -2,7 +2,7 @@
2
2
  // The build stamp QA reads off the page as `__hub.build`.
3
3
  import assert from 'node:assert/strict';
4
4
  import fs from 'node:fs';
5
- import { buildStamp } from '../code/client/build.js';
5
+ import { buildStamp, showBuildStamp } from '../code/client/build.js';
6
6
 
7
7
  const sha = '0123456789abcdef0123456789abcdef01234567';
8
8
  const savedAt = '2026-10-07T20:00:00Z';
@@ -25,7 +25,25 @@ for (const bad of [undefined, null, 'x', 7, [], {}, { sha }, { savedAt }, { sha:
25
25
 
26
26
  // A deck without the file keeps the handle it had: no `build` key at all.
27
27
  const read = (file) => fs.readFileSync(new URL(`../code/${file}`, import.meta.url), 'utf8');
28
- assert.match(read('systems/hub.js'), /globalThis\.__hub = \{ scene, system: this, state: Hub\.hub, \.\.\.\(Hub\.deck\.build \? \{ build: Hub\.deck\.build \} : \{\}\) \};/);
28
+ assert.match(read('systems/hub.js'), /globalThis\.__hub = \{ scene, system: this, state: Hub\.hub, \.\.\.\(Hub\.deck\.build \? \{ build: Hub\.deck\.build, serverBuild \} : \{\}\) \};/);
29
29
  assert.match(read('client/hookLayer.js'), /deck\.build = buildStamp\(Object\.values\(import\.meta\.glob\('\/build\.json', \{ eager: true, import: 'default' \}\)\)\[0\]\);/);
30
30
  assert.match(read('client/state.js'), /\n {2}build: null,\n/);
31
31
  console.log('test-build: ok');
32
+
33
+ // No stamp does not create a node; a stamped deck reuses its hidden evidence.
34
+ const nodes = new Map();
35
+ const doc = {
36
+ body: { appendChild(node) { nodes.set(node.id, node); } },
37
+ getElementById(id) { return nodes.get(id); },
38
+ createElement() { return {}; },
39
+ };
40
+ showBuildStamp(null, doc);
41
+ assert.equal(nodes.size, 0);
42
+ showBuildStamp(buildStamp({ sha, savedAt }), doc);
43
+ const node = nodes.get('hub-build-stamp');
44
+ assert.equal(node.hidden, true);
45
+ assert.equal(node.type, 'application/json');
46
+ assert.deepEqual(JSON.parse(node.textContent), { sha, savedAt });
47
+ showBuildStamp(buildStamp({ sha, savedAt, bundle: 'b-18' }), doc);
48
+ assert.equal(nodes.size, 1);
49
+ assert.equal(JSON.parse(node.textContent).bundle, 'b-18');
@@ -127,9 +127,11 @@ let n = 0;
127
127
  n += 1;
128
128
  }
129
129
 
130
- // v1.46: NPC chips return after a reply, and a refused inspect is retried.
130
+ // v1.46: NPC chips return after a reply, and a refused inspect is retried
131
+ // once its backoff has passed.
131
132
  {
132
- const { makeTalk } = await import('../code/client/talk.js');
133
+ const { makeTalk, READ_RETRY_MS } = await import('../code/client/talk.js');
134
+ const backoffs = [];
133
135
  const { hub } = await import('../code/client/state.js');
134
136
  const polls = [];
135
137
  const later = globalThis.setTimeout;
@@ -138,6 +140,11 @@ let n = 0;
138
140
  let clock = 0;
139
141
  Object.defineProperty(performance, 'now', { configurable: true, value: () => clock });
140
142
  globalThis.setTimeout = (fn, ms, ...args) => {
143
+ if (ms === READ_RETRY_MS) {
144
+ const timer = { fn, cancelled: false };
145
+ backoffs.push(timer);
146
+ return timer;
147
+ }
141
148
  if (ms !== 1200) {
142
149
  return later(fn, ms, ...args);
143
150
  }
@@ -237,7 +244,11 @@ let n = 0;
237
244
  assert.equal(canType, false);
238
245
  handlers.end();
239
246
  open();
240
- assert.equal(inspections, 2, 'a refusal is retried on the next open');
247
+ assert.equal(inspections, 1, 'a refusal holds the next read back');
248
+ handlers.end();
249
+ backoffs.shift().fn();
250
+ open();
251
+ assert.equal(inspections, 2, 'and is retried on an open after its backoff');
241
252
  inspectResolve({ participantId: 'p-a' });
242
253
  await settle();
243
254
  assert.equal(canType, true);
@@ -476,7 +487,10 @@ let n = 0;
476
487
 
477
488
  // v1.47: the Chat prompt reads ahead, but never retries a refusal each frame.
478
489
  {
479
- const { makeTalk } = await import('../code/client/talk.js');
490
+ const { makeTalk, READ_RETRY_MS } = await import('../code/client/talk.js');
491
+ const later = globalThis.setTimeout;
492
+ const backoffs = [];
493
+ globalThis.setTimeout = (fn, ms, ...args) => (ms === READ_RETRY_MS ? backoffs.push(fn) : later(fn, ms, ...args));
480
494
  const { hub } = await import('../code/client/state.js');
481
495
  const settle = () => new Promise((resolve) => setImmediate(resolve));
482
496
  let handlers;
@@ -522,7 +536,11 @@ let n = 0;
522
536
  frame();
523
537
  assert.equal(inspections, 1, 'a refused approach is not polled');
524
538
  open();
525
- assert.equal(inspections, 2, 'the next open retries');
539
+ assert.equal(inspections, 1, 'nor read again on an open inside its backoff');
540
+ handlers.end();
541
+ backoffs.shift()();
542
+ open();
543
+ assert.equal(inspections, 2, 'an open after it retries');
526
544
  inspectResolve({ participantId: 'p-a' });
527
545
  await settle();
528
546
  assert.equal(canType, true);
@@ -541,6 +559,7 @@ let n = 0;
541
559
  assert.equal(canType, true, 'a completed approach read permits typing at once');
542
560
  handlers.end();
543
561
  hub.npcEvents.length = 0;
562
+ globalThis.setTimeout = later;
544
563
  n += 1;
545
564
  }
546
565
 
@@ -592,6 +611,8 @@ let n = 0;
592
611
  handlers.send('hello?');
593
612
  assert.equal(turns, 0, 'nothing is sent from a closed panel');
594
613
  open();
614
+ // The new session registers its player before it may type.
615
+ await settle();
595
616
  refuse = 'HUB_NPC_NOT_TALKING';
596
617
  handlers.send('are you there?');
597
618
  await settle();
@@ -669,6 +690,101 @@ let n = 0;
669
690
  }
670
691
  }
671
692
 
693
+ // The real chrome: an under-13 speaker's plain line sits under the talk
694
+ // panel's log (the opening), above the field, until it is taken away or the
695
+ // panel closes; the say card's field takes a part's words and gives them back
696
+ // in place, and a part that names none reads 'Message…'.
697
+ {
698
+ const { makeChrome } = await import('../code/client/chrome.js');
699
+ const { under13Talk } = await import('../code/client/talk.js');
700
+ // Fixture words for a chat part that names its own.
701
+ const PART = 'Friends only';
702
+ const oldDocument = globalThis.document;
703
+ const nodes = [];
704
+ const element = (tag) => {
705
+ const node = {
706
+ tag, style: {}, dataset: {}, children: [], textContent: '', parentNode: null, attributes: new Map(),
707
+ scrollHeight: 0, scrollTop: 0, clientHeight: 0, offsetTop: 0,
708
+ get childElementCount() { return this.children.length; },
709
+ get isConnected() { return Boolean(this.parentNode); },
710
+ appendChild(child) { child.remove(); child.parentNode = this; this.children.push(child); return child; },
711
+ insertBefore(child, before) {
712
+ child.remove();
713
+ child.parentNode = this;
714
+ const index = this.children.indexOf(before);
715
+ this.children.splice(index < 0 ? this.children.length : index, 0, child);
716
+ },
717
+ replaceChildren() { this.children = []; },
718
+ remove() { if (this.parentNode) { this.parentNode.children = this.parentNode.children.filter((child) => child !== this); this.parentNode = null; } },
719
+ addEventListener() {}, removeEventListener() {}, focus() {}, blur() {},
720
+ setAttribute(name, value) { this.attributes.set(name, String(value)); },
721
+ removeAttribute(name) { this.attributes.delete(name); },
722
+ getAttribute(name) { return this.attributes.get(name) ?? null; },
723
+ };
724
+ nodes.push(node);
725
+ return node;
726
+ };
727
+ globalThis.document = { body: element('body'), createElement: element, activeElement: null };
728
+ let chrome;
729
+ try {
730
+ chrome = makeChrome({ onBack() {}, onAvatar() {}, avatarCount: 4 });
731
+ const words = under13Talk('Rowan');
732
+ const shown = () => nodes.filter((node) => node.textContent === words && node.parentNode);
733
+ chrome.talkHint(words);
734
+ assert.equal(shown().length, 0, 'nothing while no panel is open');
735
+ chrome.openTalk('Rowan, the baker', { mind: true, canType: false });
736
+ chrome.talkLine('them', 'Hi there.');
737
+ const opening = nodes.find((node) => node.textContent === 'Hi there.');
738
+ chrome.talkHint(words);
739
+ const [hint] = shown();
740
+ assert.ok(hint, 'shown');
741
+ const panel = opening.parentNode.parentNode;
742
+ const form = nodes.find((node) => node.name === 'say').parentNode;
743
+ assert.equal(hint.parentNode, panel);
744
+ const order = panel.children;
745
+ assert.ok(order.indexOf(opening.parentNode) < order.indexOf(hint) && order.indexOf(hint) < order.indexOf(form), 'under the opening, above the field');
746
+ assert.equal(hint.children.length, 0, 'plain words: no button or chip');
747
+ assert.notEqual(hint.tag, 'button');
748
+ chrome.talkHint(words);
749
+ assert.equal(shown().length, 1, 'the same words again change nothing');
750
+ assert.equal(shown()[0], hint);
751
+ chrome.talkHint(null);
752
+ assert.equal(shown().length, 0, 'null takes it away');
753
+ chrome.talkHint(words);
754
+ chrome.closeTalk();
755
+ assert.equal(shown().length, 0, 'closing takes it away');
756
+ chrome.openTalk('Rowan', { mind: true, canType: false });
757
+ assert.equal(shown().length, 0, 'a new panel starts without it');
758
+ chrome.closeTalk();
759
+
760
+ // The say card's field: built with a part's words, then given back.
761
+ const say = (chat) => chrome.setSay({ reactions: [], phrases: [], chat });
762
+ say({ input: false, note: PART, placeholder: PART, label: PART });
763
+ const field = () => nodes.findLast((node) => node.name === 'message');
764
+ assert.equal(field().placeholder, PART);
765
+ assert.equal(field().disabled, true);
766
+ assert.equal(field().getAttribute('aria-label'), PART);
767
+ assert.ok(nodes.some((node) => node.parentNode && node.textContent === PART), 'the note');
768
+ const built = field();
769
+ say({ input: false, note: "Chat isn't available on this account" });
770
+ assert.equal(field(), built, 'rewritten in place');
771
+ assert.equal(built.placeholder, 'Message…', 'a part that names none reads Message…');
772
+ assert.equal(built.getAttribute('aria-label'), null);
773
+ say({ input: false, note: PART, placeholder: PART, label: PART });
774
+ assert.equal(field(), built);
775
+ assert.equal(built.placeholder, PART, 'and back, in place');
776
+ assert.equal(built.getAttribute('aria-label'), PART);
777
+ n += 1;
778
+ } finally {
779
+ chrome?.dispose();
780
+ if (oldDocument === undefined) {
781
+ delete globalThis.document;
782
+ } else {
783
+ globalThis.document = oldDocument;
784
+ }
785
+ }
786
+ }
787
+
672
788
  // v1.76: approach consumes private greeting hooks, without opening a panel.
673
789
  {
674
790
  const { makeTalk } = await import('../code/client/talk.js');
@@ -790,3 +906,88 @@ console.log(`test-chat: ${n} passed`);
790
906
  hub.npcEvents.push({ k: 'hub-npc-preferred', npc: null }); frame();
791
907
  assert.equal(prompt, 'Vela');
792
908
  }
909
+
910
+ // Marker-gated report and block: old hosts never confirm it; confirmed blocks
911
+ // clear waiting messages and discard polls already in flight.
912
+ {
913
+ const { chatModerationEnabled } = await import('../code/client/chatModeration.js');
914
+ const scene = (value) => ({ getActor: (id) => id === 'hub-chat-moderation' ? { components: { HubChatModeration: value } } : null });
915
+ assert.equal(chatModerationEnabled(scene({ v: 1 })), true);
916
+ for (const value of [null, {}, { v: 2 }, { v: 1, extra: true }]) assert.equal(chatModerationEnabled(scene(value)), false);
917
+ assert.equal(chatModerationEnabled({}), false);
918
+ let poll;
919
+ let result = { status: 'ok' };
920
+ const calls = [];
921
+ globalThis.__chatHub = {
922
+ chat: () => new Promise((resolve) => { poll = resolve; }), say() {},
923
+ reportChat: async (...args) => { calls.push(args); return result; },
924
+ };
925
+ const c = makeChat();
926
+ c.peers = ['102', '103'];
927
+ c.incoming.push({ fromUserId: '102', text: 'waiting' });
928
+ let ok;
929
+ c.reportAndBlock('m1', '102', (value) => { ok = value; }); await flush();
930
+ assert.equal(ok, false, 'report-only hosts do not confirm a block');
931
+ assert.equal(c.incoming.length, 1);
932
+ c.frame(true, 1000);
933
+ result = { status: 'ok', blocked: true };
934
+ c.reportAndBlock('m1', '102', (value) => { ok = value; }); await flush();
935
+ assert.equal(ok, true);
936
+ assert.deepEqual(calls.at(-1), ['m1', { block: true }]);
937
+ assert.deepEqual(c.incoming, []);
938
+ assert.deepEqual(c.peers, ['103']);
939
+ poll({ status: 'ok', peers: [], messages: [{ fromUserId: '102', text: 'in flight' }], cursor: 'c' }); await flush();
940
+ assert.deepEqual(c.incoming, [], 'a poll started before the block cannot restore messages');
941
+ const { makeSay } = await import('../code/client/say.js');
942
+ const say = makeSay();
943
+ say.chat(1, 'p2', 'bo', { id: 'm1', fromUserId: '102', text: 'hide me' }, 6000);
944
+ say.chat(1, 'p3', 'other', { id: 'm2', fromUserId: '103', text: 'keep me' }, 6000);
945
+ say.hideUser('102');
946
+ assert.deepEqual(say.feed(), [{ id: 'm2', userId: '103', text: 'other: keep me' }]);
947
+ const labels = say.labels({ multiplayer: { avatars: { actors: new Map([['p2','a2'],['p3','a3']]) } }, getActor: () => ({ components: { Transform: { x: 0, y: 0, z: 0 } } }) }, null, null, null, () => ({ x: 1, y: 1 }), 'me');
948
+ assert.deepEqual(labels.map((l) => l.text), ['keep me']);
949
+ }
950
+
951
+ // Exercise the actual chrome event handlers: the marker controls the new
952
+ // action, and clicking it carries the original line without choosing a target.
953
+ {
954
+ const { makeChrome } = await import('../code/client/chrome.js');
955
+ const previous = globalThis.document;
956
+ const nodes = [];
957
+ const element = () => {
958
+ const node = {
959
+ style: {}, dataset: {}, children: [], textContent: '', parentNode: null, handlers: new Map(),
960
+ get childElementCount() { return this.children.length; },
961
+ appendChild(child) { child.parentNode = this; this.children.push(child); return child; },
962
+ insertBefore(child, before) { child.remove(); child.parentNode = this; const at = this.children.indexOf(before); this.children.splice(at < 0 ? this.children.length : at, 0, child); },
963
+ replaceChildren() { this.children = []; },
964
+ remove() { if (this.parentNode) this.parentNode.children = this.parentNode.children.filter((c) => c !== this); },
965
+ addEventListener(type, fn) { this.handlers.set(type, fn); }, removeEventListener() {}, setAttribute() {}, focus() {}, blur() {},
966
+ };
967
+ nodes.push(node);
968
+ return node;
969
+ };
970
+ globalThis.document = { body: element(), createElement: element, activeElement: null };
971
+ const blocked = [];
972
+ let chrome;
973
+ const tap = (node) => node.handlers.get('pointerdown')({ stopPropagation() {} });
974
+ try {
975
+ chrome = makeChrome({ onBack() {}, onAvatar() {}, avatarCount: 4, onBlockChat: (line) => blocked.push(line) });
976
+ const line = { text: 'bo: hello', id: 'm1', userId: '102' };
977
+ chrome.setChatModeration(false);
978
+ chrome.setFeed([line]);
979
+ tap(nodes.findLast((node) => node.textContent === line.text));
980
+ assert.equal(nodes.some((node) => node.textContent === 'Report & block'), false);
981
+ chrome.setChatModeration(true);
982
+ chrome.setFeed([line]);
983
+ tap(nodes.findLast((node) => node.textContent === line.text));
984
+ const button = nodes.findLast((node) => node.textContent === 'Report & block');
985
+ assert.ok(button);
986
+ tap(button);
987
+ assert.deepEqual(blocked, [line]);
988
+ assert.equal(button.parentNode.style.flexWrap, 'wrap', 'controls wrap on narrow screens');
989
+ } finally {
990
+ chrome?.dispose();
991
+ if (previous === undefined) delete globalThis.document; else globalThis.document = previous;
992
+ }
993
+ }
@@ -147,11 +147,13 @@ await test('idle/gone end; leave/prune drop record, met, turns and in-flight adm
147
147
  await r.npcs.onRead(read('p1', { type: 'status', operationId: 'late' }, { status: 'completed', response: secret('late') })); assert.equal(r.sent.length, count);
148
148
  r.message('p1', 'hub-npc-open'); r.h.sim.players.delete('p1'); r.tick(); assert.equal(r.npcs.handle('companion:p1'), null); assert.equal(r.sent.at(-1)[1].why, 'left'); r.privateOnly();
149
149
  });
150
- function hubRig(companion = declaration, implementation = layer, mind = true) {
150
+ function hubRig(companion = declaration, implementation = layer, mind = true, childAsks) {
151
151
  const sent = []; let hub;
152
152
  globalThis.__companionChatActors = [{ id: 'player', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } }];
153
153
  const hooks = { ready(ctx) { hub = ctx; }, npcOpening(_ctx, _npc, id) { return secret('opening', id); }, npcLine(_ctx, _npc, id, info) { return secret(info.why, id); } };
154
- const server = implementation(json(companion), hooks, {}, () => true, () => null, null, { createBody() { return { setEnabled() {}, setNextKinematicTranslation() {}, setNextKinematicRotation() {} }; } });
154
+ const config = json(companion);
155
+ if (childAsks) {config.characterBundle = { ...bundle, characters: [{ id: 'companion', childAsks }] };}
156
+ const server = implementation(config, hooks, {}, () => true, () => null, null, { createBody() { return { setEnabled() {}, setNextKinematicTranslation() {}, setNextKinematicRotation() {} }; } });
155
157
  const session = { sessionId: 'dev', players: [...players], characters: mind ? {} : null, send(id, msg) { sent.push([id, structuredClone(msg)]); }, broadcast(msg) { sent.push(['all', structuredClone(msg)]); } };
156
158
  const world = { timeMs: 0, scenePath: 'scenes/main.scene', objects: new Map(), bodies: new Map(), players: new Map(players.map((p) => [p.playerId, { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } }])) };
157
159
  server.sceneFor(session); server.ready(world);
@@ -183,6 +185,22 @@ await test('real hub mind open, pending refusal and host status reply send only
183
185
  assert(r.sent.some(([, msg]) => msg.text === secret('busy'))); assert(r.sent.some(([, msg]) => msg.text === secret('budget')));
184
186
  for (const state of [r.server.join(), r.server.delta()]) assert(!JSON.stringify(state).includes('private:'));
185
187
  });
188
+ await test('v1.142: real hub reads published childAsks without projecting prompts', async () => {
189
+ const asks = Object.fromEntries(JSON.parse(readFileSync(new URL('../../../experiments/hub-town/castle.json', import.meta.url), 'utf8')).characterBundle.characters.filter((c) => c.childAsks).map((c) => [c.id, c.childAsks])).greeter;
190
+ const r = hubRig(declaration, layer, true, asks);
191
+ r.session.players = r.session.players.map((p) => ({ ...p, under13: p.playerId === 'p1' }));
192
+ r.hub.companion('p1', { look: 'bird' }); r.tick();
193
+ r.say('p1', { k: 'hub-npc-open', npc: 'companion:p1' });
194
+ const opened = r.sent.find(([id, msg]) => id === 'p1' && msg.open === true)[1];
195
+ assert.deepEqual(opened.choices, asks.map(({ id, label }) => ({ id, label })));
196
+ assert.equal(opened.opening.text, 'Tap a question to talk with Chirp.');
197
+ const t = turn('p1', 'child', { input: 'choice:hi' });
198
+ await r.server.worldCharacters.onWorldCharacterTurn(r.session, t);
199
+ assert(t.sent); assert.equal(t.args, undefined);
200
+ for (const state of [r.server.join(), r.server.delta(), r.sent]) {
201
+ assert(!JSON.stringify(state).includes(asks[0].prompt));
202
+ }
203
+ });
186
204
  await test('follower-only true is byte-identical to the captured wire before this task', () => {
187
205
  const trace = (implementation, dress) => {
188
206
  const r = hubRig(true, implementation); const states = [r.server.join(), r.server.delta()];