castle-web-cli 0.4.233 → 0.4.234

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 (381) 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 +260 -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 +50 -4
  39. package/kits/base/sdk/multiplayer.d.ts +7 -1
  40. package/kits/base/sdk/multiplayer.js +140 -40
  41. package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
  42. package/kits/base/sdk/party.d.ts +23 -0
  43. package/kits/base/sdk/party.js +91 -0
  44. package/kits/base/sdk/reconnectBudget.d.ts +23 -0
  45. package/kits/base/sdk/reconnectBudget.js +96 -0
  46. package/kits/base/sdk/save.d.ts +38 -1
  47. package/kits/base/sdk/save.js +79 -6
  48. package/kits/base/sdk/server/hub.d.ts +31 -1
  49. package/kits/base/sdk/server/hub.js +50 -3
  50. package/kits/base/sdk/server/platformHandle.d.ts +13 -1
  51. package/kits/base/sdk/server/storage.d.ts +4 -0
  52. package/kits/base/sdk/server/storage.js +19 -3
  53. package/kits/base/sdk/server/wrapper.d.ts +7 -1
  54. package/kits/base/sdk/server/wrapper.js +10 -1
  55. package/kits/base/sdk/social.d.ts +9 -0
  56. package/kits/base/sdk/social.js +5 -0
  57. package/kits/hub-game/CLAUDE.md +123 -3
  58. package/kits/hub-game/README.md +63 -0
  59. package/kits/hub-game/castle.json +5 -5
  60. package/kits/hub-game/code/client/act.js +312 -0
  61. package/kits/hub-game/code/client/actionLayout.js +147 -0
  62. package/kits/hub-game/code/client/actionOverflow.js +556 -0
  63. package/kits/hub-game/code/client/arrivalCamera.js +50 -0
  64. package/kits/hub-game/code/client/askSlot.js +117 -0
  65. package/kits/hub-game/code/client/avatar.js +4 -2
  66. package/kits/hub-game/code/client/avatarShare.js +2 -0
  67. package/kits/hub-game/code/client/backVisibility.js +13 -0
  68. package/kits/hub-game/code/client/ballot.js +15 -10
  69. package/kits/hub-game/code/client/build.js +16 -0
  70. package/kits/hub-game/code/client/chat.js +41 -5
  71. package/kits/hub-game/code/client/chatModeration.js +5 -0
  72. package/kits/hub-game/code/client/chrome.js +1148 -258
  73. package/kits/hub-game/code/client/crowdNames.js +241 -0
  74. package/kits/hub-game/code/client/decor.js +10 -4
  75. package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
  76. package/kits/hub-game/code/client/doorErrors.js +39 -0
  77. package/kits/hub-game/code/client/fall.js +18 -0
  78. package/kits/hub-game/code/client/farAvatars.js +233 -0
  79. package/kits/hub-game/code/client/firstJoin.js +9 -2
  80. package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
  81. package/kits/hub-game/code/client/frameBatch.js +5 -0
  82. package/kits/hub-game/code/client/grab.js +31 -11
  83. package/kits/hub-game/code/client/hookLayer.js +87 -8
  84. package/kits/hub-game/code/client/hudCopy.js +51 -0
  85. package/kits/hub-game/code/client/hudRate.js +20 -0
  86. package/kits/hub-game/code/client/idle.js +14 -2
  87. package/kits/hub-game/code/client/invites.js +231 -0
  88. package/kits/hub-game/code/client/joinError.js +9 -0
  89. package/kits/hub-game/code/client/labelsNear.js +31 -2
  90. package/kits/hub-game/code/client/landscapeLayout.js +17 -0
  91. package/kits/hub-game/code/client/layoutCache.js +264 -0
  92. package/kits/hub-game/code/client/loadTelemetry.js +20 -0
  93. package/kits/hub-game/code/client/loadingCover.js +148 -0
  94. package/kits/hub-game/code/client/loadingEntry.js +8 -0
  95. package/kits/hub-game/code/client/menuRows.js +43 -0
  96. package/kits/hub-game/code/client/modelReady.js +7 -0
  97. package/kits/hub-game/code/client/padCueArrival.js +23 -0
  98. package/kits/hub-game/code/client/padCues.js +112 -0
  99. package/kits/hub-game/code/client/padOccupancy.js +88 -0
  100. package/kits/hub-game/code/client/padReadability.js +26 -0
  101. package/kits/hub-game/code/client/padRings.js +69 -0
  102. package/kits/hub-game/code/client/pushVisit.js +14 -0
  103. package/kits/hub-game/code/client/quality.js +205 -0
  104. package/kits/hub-game/code/client/qualityEntry.js +55 -0
  105. package/kits/hub-game/code/client/safeLayout.js +338 -0
  106. package/kits/hub-game/code/client/safeStyle.js +42 -0
  107. package/kits/hub-game/code/client/say.js +12 -3
  108. package/kits/hub-game/code/client/shot.js +64 -10
  109. package/kits/hub-game/code/client/shotFit.js +56 -0
  110. package/kits/hub-game/code/client/signIn.js +28 -0
  111. package/kits/hub-game/code/client/state.js +53 -0
  112. package/kits/hub-game/code/client/talk.js +209 -45
  113. package/kits/hub-game/code/client/tiers.js +68 -66
  114. package/kits/hub-game/code/client/together.js +7 -2
  115. package/kits/hub-game/code/client/weakestLookBake.js +92 -0
  116. package/kits/hub-game/code/client/weakestTier.js +295 -0
  117. package/kits/hub-game/code/client/worldLabels.js +241 -0
  118. package/kits/hub-game/code/client/yours.js +10 -9
  119. package/kits/hub-game/code/npcDisplayText.js +55 -0
  120. package/kits/hub-game/code/server/act.js +124 -0
  121. package/kits/hub-game/code/server/actions.js +6 -1
  122. package/kits/hub-game/code/server/actors.js +2 -1
  123. package/kits/hub-game/code/server/analytics.js +83 -0
  124. package/kits/hub-game/code/server/anonymousEntry.js +49 -0
  125. package/kits/hub-game/code/server/arrivalPose.js +36 -0
  126. package/kits/hub-game/code/server/companion.js +28 -3
  127. package/kits/hub-game/code/server/doorAnalytics.js +52 -0
  128. package/kits/hub-game/code/server/earned.js +22 -5
  129. package/kits/hub-game/code/server/frameBatch.js +183 -0
  130. package/kits/hub-game/code/server/friendsAmong.js +49 -9
  131. package/kits/hub-game/code/server/history.js +2 -0
  132. package/kits/hub-game/code/server/hub.js +1306 -95
  133. package/kits/hub-game/code/server/idle.js +30 -1
  134. package/kits/hub-game/code/server/index.js +26 -4
  135. package/kits/hub-game/code/server/invites.js +19 -0
  136. package/kits/hub-game/code/server/labels.js +9 -1
  137. package/kits/hub-game/code/server/loadAbandon.js +106 -0
  138. package/kits/hub-game/code/server/manifest.js +211 -3
  139. package/kits/hub-game/code/server/menu.js +31 -3
  140. package/kits/hub-game/code/server/npcs.js +226 -64
  141. package/kits/hub-game/code/server/observe.js +408 -0
  142. package/kits/hub-game/code/server/padOccupancy.js +85 -0
  143. package/kits/hub-game/code/server/players.js +9 -1
  144. package/kits/hub-game/code/server/resumePose.js +152 -0
  145. package/kits/hub-game/code/server/say.js +1 -1
  146. package/kits/hub-game/code/server/standing.js +4 -5
  147. package/kits/hub-game/code/server/storageLimit.js +187 -0
  148. package/kits/hub-game/code/server/vis.js +67 -5
  149. package/kits/hub-game/code/shared/act.js +35 -0
  150. package/kits/hub-game/code/shared/danceIdle.js +28 -0
  151. package/kits/hub-game/code/shared/loadStages.js +12 -0
  152. package/kits/hub-game/code/shared/quality.js +74 -0
  153. package/kits/hub-game/code/shared/say.js +2 -0
  154. package/kits/hub-game/code/shared/shot.js +35 -1
  155. package/kits/hub-game/code/systems/hub.js +970 -169
  156. package/kits/hub-game/docs/analytics.md +279 -0
  157. package/kits/hub-game/docs/contract.md +1257 -42
  158. package/kits/hub-game/docs/home-pieces.md +9 -2
  159. package/kits/hub-game/docs/observed-progress.md +252 -0
  160. package/kits/hub-game/main.jsx +2 -0
  161. package/kits/hub-game/package-lock.json +10 -3
  162. package/kits/hub-game/package.json +6 -3
  163. package/kits/hub-game/play/player.js +142 -0
  164. package/kits/hub-game/play/registry.js +47 -0
  165. package/kits/hub-game/play.jsx +37 -0
  166. package/kits/hub-game/scripts/check.mjs +39 -5
  167. package/kits/hub-game/scripts/companion-follower-wire.json +1 -1
  168. package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +11 -0
  169. package/kits/hub-game/scripts/fixtures/decor-keyless.json +5 -5
  170. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +3 -0
  171. package/kits/hub-game/scripts/fixtures/fake-dom.mjs +19 -3
  172. package/kits/hub-game/scripts/fixtures/interest-legacy.json +3 -3
  173. package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -1
  174. package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
  175. package/kits/hub-game/scripts/test-act-client.mjs +186 -0
  176. package/kits/hub-game/scripts/test-act.mjs +171 -0
  177. package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
  178. package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
  179. package/kits/hub-game/scripts/test-actions-client.mjs +367 -2
  180. package/kits/hub-game/scripts/test-actors.mjs +20 -7
  181. package/kits/hub-game/scripts/test-analytics.mjs +76 -0
  182. package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
  183. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
  184. package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
  185. package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
  186. package/kits/hub-game/scripts/test-avatar-wire.mjs +49 -10
  187. package/kits/hub-game/scripts/test-avatar.mjs +44 -0
  188. package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
  189. package/kits/hub-game/scripts/test-ballot.mjs +11 -4
  190. package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
  191. package/kits/hub-game/scripts/test-build.mjs +20 -2
  192. package/kits/hub-game/scripts/test-chat.mjs +206 -5
  193. package/kits/hub-game/scripts/test-companion-chat.mjs +20 -2
  194. package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
  195. package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
  196. package/kits/hub-game/scripts/test-decor-client.mjs +45 -4
  197. package/kits/hub-game/scripts/test-decor.mjs +7 -0
  198. package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
  199. package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
  200. package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
  201. package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
  202. package/kits/hub-game/scripts/test-earned.mjs +33 -3
  203. package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
  204. package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
  205. package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
  206. package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
  207. package/kits/hub-game/scripts/test-grab-orbit.mjs +47 -4
  208. package/kits/hub-game/scripts/test-high-only.mjs +170 -0
  209. package/kits/hub-game/scripts/test-hub-ops.mjs +321 -2
  210. package/kits/hub-game/scripts/test-hub-trip.mjs +879 -11
  211. package/kits/hub-game/scripts/test-hud-clear.mjs +162 -59
  212. package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
  213. package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
  214. package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
  215. package/kits/hub-game/scripts/test-idle.mjs +66 -0
  216. package/kits/hub-game/scripts/test-interest-cells.mjs +20 -0
  217. package/kits/hub-game/scripts/test-interest.mjs +15 -0
  218. package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
  219. package/kits/hub-game/scripts/test-invites.mjs +109 -0
  220. package/kits/hub-game/scripts/test-labels.mjs +71 -3
  221. package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
  222. package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
  223. package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
  224. package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
  225. package/kits/hub-game/scripts/test-manifest.mjs +265 -0
  226. package/kits/hub-game/scripts/test-menu-client.mjs +105 -0
  227. package/kits/hub-game/scripts/test-menu.mjs +23 -0
  228. package/kits/hub-game/scripts/test-npcs.mjs +819 -10
  229. package/kits/hub-game/scripts/test-observed.mjs +745 -0
  230. package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
  231. package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
  232. package/kits/hub-game/scripts/test-picker.mjs +234 -7
  233. package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
  234. package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
  235. package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
  236. package/kits/hub-game/scripts/test-quality.mjs +385 -0
  237. package/kits/hub-game/scripts/test-rehello.mjs +699 -5
  238. package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
  239. package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
  240. package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
  241. package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
  242. package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
  243. package/kits/hub-game/scripts/test-say.mjs +1 -1
  244. package/kits/hub-game/scripts/test-shot.mjs +145 -0
  245. package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
  246. package/kits/hub-game/scripts/test-soundscape.mjs +22 -17
  247. package/kits/hub-game/scripts/test-standing.mjs +35 -2
  248. package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
  249. package/kits/hub-game/scripts/test-stuck.mjs +5 -4
  250. package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
  251. package/kits/hub-game/scripts/test-tiers-render.mjs +86 -13
  252. package/kits/hub-game/scripts/test-tiers.mjs +7 -8
  253. package/kits/hub-game/scripts/test-vis.mjs +433 -6
  254. package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
  255. package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
  256. package/kits/hub-game/scripts/test-yours-chrome.mjs +50 -6
  257. package/kits/hub-game/scripts/test-yours.mjs +39 -8
  258. package/kits/multiplayer-3d/castle.json +5 -5
  259. package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
  260. package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
  261. package/kits/multiplayer-3d/code/systems/multiplayer.js +369 -30
  262. package/kits/multiplayer-3d/package-lock.json +8 -1
  263. package/kits/multiplayer-3d/package.json +2 -1
  264. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
  265. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
  266. package/kits/physics-2d/CLAUDE.md +10 -1
  267. package/kits/physics-2d/castle.json +2 -2
  268. package/kits/physics-2d/engine/frozenActors.js +233 -0
  269. package/kits/physics-2d/engine/scene.js +87 -5
  270. package/kits/physics-2d/eslint.config.js +1 -1
  271. package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
  272. package/kits/physics-2d/play/behaviors/Camera.js +40 -0
  273. package/kits/physics-2d/play/behaviors/Collider.js +122 -0
  274. package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
  275. package/kits/physics-2d/play/behaviors/Goal.js +46 -0
  276. package/kits/physics-2d/play/behaviors/Joints.js +126 -0
  277. package/kits/physics-2d/play/behaviors/Layout.js +71 -0
  278. package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
  279. package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
  280. package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
  281. package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
  282. package/kits/physics-2d/play/behaviors/Style.js +209 -0
  283. package/kits/physics-2d/play/behaviors/Text.js +85 -0
  284. package/kits/physics-2d/play/behaviors/Video.js +93 -0
  285. package/kits/physics-3d/CLAUDE.md +25 -1651
  286. package/kits/physics-3d/behaviors/Body.jsx +3 -0
  287. package/kits/physics-3d/behaviors/Model.jsx +3 -0
  288. package/kits/physics-3d/behaviors/Player.jsx +35 -18
  289. package/kits/physics-3d/behaviors/Shape.jsx +3 -0
  290. package/kits/physics-3d/behaviors/Solid.jsx +3 -0
  291. package/kits/physics-3d/behaviors/Transform.jsx +3 -0
  292. package/kits/physics-3d/castle.json +3 -3
  293. package/kits/physics-3d/docs/engine-camera.md +542 -0
  294. package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
  295. package/kits/physics-3d/docs/engine-load.md +149 -0
  296. package/kits/physics-3d/docs/engine-look.md +114 -0
  297. package/kits/physics-3d/docs/engine-shadows.md +372 -0
  298. package/kits/physics-3d/docs/engine-skip-work.md +187 -0
  299. package/kits/physics-3d/docs/engine-sky.md +198 -0
  300. package/kits/physics-3d/docs/engine-static-actors.md +226 -0
  301. package/kits/physics-3d/docs/engine-view.md +37 -0
  302. package/kits/physics-3d/docs/pxmodel-format.md +1 -1
  303. package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
  304. package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -333
  305. package/kits/physics-3d/engine3d/actornode.js +1 -0
  306. package/kits/physics-3d/engine3d/branches.js +3 -13
  307. package/kits/physics-3d/engine3d/cage.js +2 -7
  308. package/kits/physics-3d/engine3d/cageops.js +2 -17
  309. package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
  310. package/kits/physics-3d/engine3d/framecap.js +4 -1
  311. package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
  312. package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
  313. package/kits/physics-3d/engine3d/gait.js +8 -0
  314. package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
  315. package/kits/physics-3d/engine3d/look.js +7 -0
  316. package/kits/physics-3d/engine3d/modelFiles.js +3 -17
  317. package/kits/physics-3d/engine3d/modelMath.js +49 -0
  318. package/kits/physics-3d/engine3d/modelready.js +16 -0
  319. package/kits/physics-3d/engine3d/motion.js +3 -3
  320. package/kits/physics-3d/engine3d/nearshadows.js +77 -10
  321. package/kits/physics-3d/engine3d/orbitinput.js +59 -25
  322. package/kits/physics-3d/engine3d/partgeometry.js +1 -16
  323. package/kits/physics-3d/engine3d/paths.js +1 -9
  324. package/kits/physics-3d/engine3d/playTimings.js +50 -0
  325. package/kits/physics-3d/engine3d/playerRun.js +372 -0
  326. package/kits/physics-3d/engine3d/pxmodel.js +3 -3
  327. package/kits/physics-3d/engine3d/rapier.js +27 -0
  328. package/kits/physics-3d/engine3d/scatter.js +1 -11
  329. package/kits/physics-3d/engine3d/shadowfade.js +23 -15
  330. package/kits/physics-3d/engine3d/sky.js +1 -1
  331. package/kits/physics-3d/engine3d/squarefirst.js +177 -0
  332. package/kits/physics-3d/engine3d/stillshadows.js +399 -0
  333. package/kits/physics-3d/engine3d/sweep.js +1 -25
  334. package/kits/physics-3d/engine3d/world3d.js +468 -18
  335. package/kits/physics-3d/eslint.config.js +2 -1
  336. package/kits/physics-3d/main.jsx +6 -3
  337. package/kits/physics-3d/package-lock.json +7 -0
  338. package/kits/physics-3d/package.json +5 -1
  339. package/kits/physics-3d/play/behaviors/Body.js +31 -0
  340. package/kits/physics-3d/play/behaviors/Door.js +37 -0
  341. package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
  342. package/kits/physics-3d/play/behaviors/Model.js +23 -0
  343. package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
  344. package/kits/physics-3d/play/behaviors/Player.js +1204 -0
  345. package/kits/physics-3d/play/behaviors/Shape.js +47 -0
  346. package/kits/physics-3d/play/behaviors/Solid.js +16 -0
  347. package/kits/physics-3d/play/behaviors/Transform.js +29 -0
  348. package/kits/physics-3d/pnpm-lock.yaml +8 -0
  349. package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
  350. package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
  351. package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
  352. package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
  353. package/kits/physics-3d/scripts/test-camera-orbit.mjs +52 -4
  354. package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
  355. package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
  356. package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +6 -3
  357. package/kits/physics-3d/scripts/test-frame-cap.mjs +1 -1
  358. package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
  359. package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
  360. package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
  361. package/kits/physics-3d/scripts/test-look-bake.mjs +1 -1
  362. package/kits/physics-3d/scripts/test-near-shadows.mjs +2 -2
  363. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +88 -7
  364. package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +40 -3
  365. package/kits/physics-3d/scripts/test-orbit-shot.mjs +75 -1
  366. package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
  367. package/kits/physics-3d/scripts/test-sky.mjs +1 -1
  368. package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
  369. package/kits/physics-3d/scripts/test-static-actors.mjs +3 -1
  370. package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
  371. package/kits/physics-3d/scripts/test-static-scenery.mjs +5 -2
  372. package/kits/physics-3d/scripts/test-steady-hover.mjs +5 -2
  373. package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
  374. package/kits/physics-3d/systems/physics3d.js +37 -4
  375. package/kits/real-time/castle.json +2 -2
  376. package/kits/real-time/code/client/connection.js +33 -10
  377. package/kits/real-time/code/client/gameHooks.js +2 -0
  378. package/kits/real-time/code/client/joinOverlay.js +9 -4
  379. package/kits/real-time/code/server/session.js +6 -4
  380. package/kits/real-time/package-lock.json +1 -1
  381. package/package.json +2 -2
@@ -6,7 +6,9 @@
6
6
  // own, no `Portal.open`, and the scene budgets. Curation is the rest.
7
7
 
8
8
  import fs from 'node:fs';
9
+ import { actorReferences, classify, skippableDecor } from '../code/shared/quality.js';
9
10
  import path from 'node:path';
11
+ import { actProblem, interaction } from '../code/shared/act.js';
10
12
  import { MAIN_PLACE, readManifest, readNpcTurnsAtOnce } from '../code/server/manifest.js';
11
13
  import { SPIN_COMPONENT, spinProblem } from '../code/shared/spin.js';
12
14
  import { EARNED_SHAPES, drawnFor } from '../code/client/earned.js';
@@ -23,8 +25,9 @@ const SERVER_MAIN = `imports/${KIT_ALIAS}/code/server/index.js`;
23
25
  const ALLOWED_CODE = [/^scripts\//, /^[^/]+\.config\.(js|mjs|cjs)$/];
24
26
  // `forks/` is NOT skipped: a fork replaces kit code in the client bundle.
25
27
  const SKIP_DIRS = new Set(['imports', 'node_modules', '.castle', 'dist', '.git']);
26
- // The one script a hub game's page may load.
28
+ // The default entry, and the v1.120 entry requiring hub.playOnlyEntry=true.
27
29
  const KIT_ENTRY = new Set([`/imports/${KIT_ALIAS}/main.jsx`, `./imports/${KIT_ALIAS}/main.jsx`, `imports/${KIT_ALIAS}/main.jsx`]);
30
+ const PLAY_ENTRY = new Set([`/imports/${KIT_ALIAS}/play.jsx`, `./imports/${KIT_ALIAS}/play.jsx`, `imports/${KIT_ALIAS}/play.jsx`]);
28
31
  const CODE_FILE = /\.(js|jsx|mjs|cjs|ts|tsx)$/;
29
32
 
30
33
  // A place's sounds (v1.6, `idle.sounds`) are bundled into the deck's page,
@@ -60,13 +63,15 @@ export default async function check({ deckDir, self = false }) {
60
63
  const scripts = [...html.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];
61
64
  const ok =
62
65
  scripts.length === 1 &&
63
- KIT_ENTRY.has(scriptSrc(scripts[0][1])) &&
66
+ (KIT_ENTRY.has(scriptSrc(scripts[0][1])) ||
67
+ (castleJson.hub?.playOnlyEntry === true && PLAY_ENTRY.has(scriptSrc(scripts[0][1])))) &&
64
68
  !scripts[0][2].trim() &&
65
69
  !/<script\b/i.test(html.replace(scripts[0][0], '')) &&
66
70
  !/\son[a-z]+\s*=/i.test(html) &&
67
71
  !/<(iframe|object|embed|link\b[^>]*rel=["']?(modulepreload|import))/i.test(html);
68
72
  if (!ok) {
69
- errors.push(`index.html must load the kit's entry (/imports/${KIT_ALIAS}/main.jsx) and nothing else that runs.`);
73
+ const entry = castleJson.hub?.playOnlyEntry === true ? 'main.jsx or play.jsx' : 'main.jsx';
74
+ errors.push(`index.html must load the kit's entry (/imports/${KIT_ALIAS}/${entry}) and nothing else that runs.`);
70
75
  }
71
76
  for (const file of walk(deckDir)) {
72
77
  const rel = file.split(path.sep).join('/');
@@ -91,8 +96,12 @@ export default async function check({ deckDir, self = false }) {
91
96
  }
92
97
 
93
98
  if (manifest) {
99
+ let qualityRefs;
100
+ if (manifest.quality) {
101
+ qualityRefs = actorReferences([...walk(deckDir)].filter((file) => CODE_FILE.test(file) && /^(code\/(server|client)|client)\//.test(file)).map((file) => readText(path.join(deckDir, file)) ?? ''));
102
+ }
94
103
  for (const [id, place] of Object.entries(manifest.places)) {
95
- checkScene(deckDir, id, place, errors, warnings);
104
+ checkScene(deckDir, id, place, errors, warnings, manifest.quality, qualityRefs);
96
105
  checkDeckDoors(deckDir, castleJson, place, errors);
97
106
  if (place.sign?.model && !fs.existsSync(path.join(deckDir, place.sign.model))) {
98
107
  errors.push(`${where(id)}.sign.model names ${place.sign.model}, which this deck does not have.`);
@@ -184,7 +193,7 @@ export const installDeckFonts = [${installers}];
184
193
  return candidates.includes(text);
185
194
  }
186
195
 
187
- function checkScene(deckDir, id, place, errors, warnings) {
196
+ function checkScene(deckDir, id, place, errors, warnings, quality, qualityRefs) {
188
197
  const file = path.join(deckDir, place.scene);
189
198
  const text = readText(file);
190
199
  if (text === null) {
@@ -214,6 +223,17 @@ function checkScene(deckDir, id, place, errors, warnings) {
214
223
  errors.push(`${where(id)}.decor.grid.origin must name an actor with a finite Transform in ${place.scene}.`);
215
224
  }
216
225
  }
226
+ if (quality) {
227
+ if (!actors.some((actor) => actor.decor === true)) warnings.push(`${place.scene}: hub.quality.low.spawned has no decor: true templates; the cap has no effect.`);
228
+ if (quality.low.decor === 'skip') {
229
+ for (const actor of actors) {
230
+ if (skippableDecor(actor, mergedComponents(deckDir, actor)) && (qualityRefs.ids.has(actor.id) || qualityRefs.templates.has(actor.id))) {
231
+ errors.push(`${place.scene}: hub.quality.low.decor: script names decor actor "${actor.id}" by id; mark it tier: "keep".`);
232
+ }
233
+ }
234
+ }
235
+ }
236
+ const actIds = new Set();
217
237
  // Movable seats are refused; decor may author a kinematic spawn template.
218
238
  for (const actor of actors) {
219
239
  const type = actor?.components?.Body?.type;
@@ -222,9 +242,23 @@ function checkScene(deckDir, id, place, errors, warnings) {
222
242
  }
223
243
  // Authored seat and display props include the blueprint, as in the engine.
224
244
  const components = mergedComponents(deckDir, actor);
245
+ if (quality && actor.decor === true && classify(components) !== 'decor') {
246
+ errors.push(`${place.scene}: actor "${actor.id}": decor: true templates must have only Transform/Shape/Model and no collider.`);
247
+ }
225
248
  if (components?.HubNpc) {
226
249
  readNpcTurnsAtOnce(components.HubNpc.turnsAtOnce, 1, `${place.scene}: actor "${actor.id}": HubNpc.turnsAtOnce`, errors);
227
250
  }
251
+ if (place.act === true) {
252
+ if (Object.hasOwn(components, 'HubAct')) {
253
+ const problem = actProblem(components.HubAct);
254
+ if (problem) {errors.push(`${place.scene}: actor "${actor.id}": ${problem}.`);}
255
+ }
256
+ const act = interaction({ ...actor, components }, place);
257
+ if (act) {
258
+ if (actIds.has(act.id)) {errors.push(`${place.scene}: duplicate HubAct id "${act.id}".`);}
259
+ actIds.add(act.id);
260
+ }
261
+ }
228
262
  const seat = components?.HubSeat;
229
263
  if (seat) {
230
264
  if (typeof seat !== 'object' || Array.isArray(seat)) {
@@ -1 +1 @@
1
- {"sent":[["p1",{"k":"hub-arrived","facing":0}],["p2",{"k":"hub-arrived","facing":0}],["p1",{"k":"hub-companion","c":{"look":"bird","say":"Follow me"},"n":1}],["p1",{"k":"hub-npc","npc":"companion:p1","open":false,"why":"far"}]],"states":[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"companion":true,"result":null,"fallY":null},"hubAv":{"p1":0,"p2":0},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hubAv":{"p1":0,"p2":0},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawnTemplates":{},"spawned":{}},{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"companion":true,"result":null,"fallY":null},"hubAv":{"p1":0,"p2":0},"hubGlow":["p1"],"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hubGlow":["p1"]},{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"companion":true,"result":null,"fallY":null},"hubAv":{"p1":0,"p2":0},"hubGlow":["p1"],"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},null]}
1
+ {"sent":[["p1",{"k":"hub-arrived","facing":0}],["p2",{"k":"hub-arrived","facing":0}],["p1",{"k":"hub-companion","c":{"look":"bird","say":"Follow me"},"n":1}],["p1",{"k":"hub-npc","npc":"companion:p1","open":false,"why":"far"}]],"states":[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"companion":true,"result":null,"fallY":-20},"hubAv":{"p1":0,"p2":0},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hubAv":{"p1":0,"p2":0},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawnTemplates":{},"spawned":{}},{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"companion":true,"result":null,"fallY":-20},"hubAv":{"p1":0,"p2":0},"hubGlow":["p1"],"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hubGlow":["p1"]},{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"companion":true,"result":null,"fallY":-20},"hubAv":{"p1":0,"p2":0},"hubGlow":["p1"],"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},null]}
@@ -1,4 +1,12 @@
1
1
  [
2
+ [
3
+ "beginLayoutFrame",
4
+ null
5
+ ],
6
+ [
7
+ "layoutCompanion",
8
+ null
9
+ ],
2
10
  [
3
11
  "idle",
4
12
  true
@@ -117,5 +125,8 @@
117
125
  [
118
126
  "setToast",
119
127
  ""
128
+ ],
129
+ [
130
+ "endLayoutFrame"
120
131
  ]
121
132
  ]
@@ -105,7 +105,7 @@
105
105
  "controller": "walk",
106
106
  "maxDurationSec": null,
107
107
  "result": null,
108
- "fallY": null
108
+ "fallY": -20
109
109
  },
110
110
  "hubAv": {
111
111
  "p1": 0,
@@ -163,7 +163,7 @@
163
163
  "controller": "walk",
164
164
  "maxDurationSec": null,
165
165
  "result": null,
166
- "fallY": null
166
+ "fallY": -20
167
167
  },
168
168
  "hubAv": {
169
169
  "p1": 0,
@@ -192,7 +192,7 @@
192
192
  "controller": "walk",
193
193
  "maxDurationSec": null,
194
194
  "result": null,
195
- "fallY": null
195
+ "fallY": -20
196
196
  },
197
197
  "hubAv": {
198
198
  "p1": 0,
@@ -239,7 +239,7 @@
239
239
  "controller": "walk",
240
240
  "maxDurationSec": null,
241
241
  "result": null,
242
- "fallY": null
242
+ "fallY": -20
243
243
  },
244
244
  "hubAv": {
245
245
  "p1": 0,
@@ -270,7 +270,7 @@
270
270
  "controller": "walk",
271
271
  "maxDurationSec": null,
272
272
  "result": null,
273
- "fallY": null
273
+ "fallY": -20
274
274
  },
275
275
  "hubAv": {
276
276
  "p1": 0,
@@ -21,3 +21,6 @@ export const releaseModel = (cache, key, dispose) => {
21
21
  };
22
22
  export const bakingLater = (queue, owner, build) => build();
23
23
  export const makeLookBake = () => ({});
24
+
25
+ // The opted-in hub policy orders the real engine queue even in UI fixtures.
26
+ export { orderLookBake } from '../../../physics-3d/engine3d/lookbake.js';
@@ -3,6 +3,20 @@
3
3
  // `view` is { viewW, viewH }. `sizeOf(node)`, when given, is the layout of a
4
4
  // node with no `size` of its own: `{ w, h }` from its text and styles, or
5
5
  // nothing for the stand-in's one 24 px line.
6
+ class FakeDOMRect {
7
+ #box;
8
+ constructor({ left, right, top, bottom }) {this.#box = { left, right, top, bottom };}
9
+ get left() {return this.#box.left;}
10
+ get right() {return this.#box.right;}
11
+ get top() {return this.#box.top;}
12
+ get bottom() {return this.#box.bottom;}
13
+ get width() {return this.right - this.left;}
14
+ get height() {return this.bottom - this.top;}
15
+ get x() {return this.left;}
16
+ get y() {return this.top;}
17
+ }
18
+ export const domRect = (box) => new FakeDOMRect(box);
19
+
6
20
  export function fakeDom(view, sizeOf = null) {
7
21
  const log = [];
8
22
  let ids = 0;
@@ -18,6 +32,7 @@ export function fakeDom(view, sizeOf = null) {
18
32
  parent: null,
19
33
  dataset: {},
20
34
  attrs: {},
35
+ handlers: {},
21
36
  rect: null,
22
37
  size: null,
23
38
  style: new Proxy(styles, {
@@ -65,8 +80,8 @@ export function fakeDom(view, sizeOf = null) {
65
80
  log.push(`${id} emptied`);
66
81
  kids.forEach((kid) => self.appendChild(kid));
67
82
  },
68
- addEventListener() {},
69
- removeEventListener() {},
83
+ addEventListener(type, fn) { self.handlers[type] = fn; },
84
+ removeEventListener(type, fn) { if (self.handlers[type] === fn) delete self.handlers[type]; },
70
85
  setAttribute(key, value) {
71
86
  self.attrs[key] = String(value);
72
87
  },
@@ -93,7 +108,8 @@ export function fakeDom(view, sizeOf = null) {
93
108
  },
94
109
  getBoundingClientRect() {
95
110
  const r = self.rect ?? { left: 0, right: 0, top: 0, bottom: 0 };
96
- return { ...r, width: r.right - r.left, height: r.bottom - r.top };
111
+ const [dx, dy] = (styles.translate || '0 0').split(' ').map(Number.parseFloat);
112
+ return domRect({ left: r.left + dx, right: r.right + dx, top: r.top + dy, bottom: r.bottom + dy });
97
113
  },
98
114
  };
99
115
  made.push(self);
@@ -64,7 +64,7 @@
64
64
  "controller": "walk",
65
65
  "maxDurationSec": null,
66
66
  "result": null,
67
- "fallY": null
67
+ "fallY": -20
68
68
  },
69
69
  "hubAv": {},
70
70
  "hud": null,
@@ -148,7 +148,7 @@
148
148
  "controller": "walk",
149
149
  "maxDurationSec": null,
150
150
  "result": null,
151
- "fallY": null
151
+ "fallY": -20
152
152
  },
153
153
  "hubAv": {},
154
154
  "hud": null,
@@ -232,7 +232,7 @@
232
232
  "controller": "walk",
233
233
  "maxDurationSec": null,
234
234
  "result": null,
235
- "fallY": null
235
+ "fallY": -20
236
236
  },
237
237
  "hubAv": {},
238
238
  "hud": null,
@@ -1 +1 @@
1
- [[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":null},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawnTemplates":{},"spawned":{}},[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":null},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},null,[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":null},"hubAv":{},"hud":null,"hidden":["trophy-0"],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hidden":["trophy-0"]},[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":null},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hidden":[]},[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":null},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},null,[]]]
1
+ [[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":-20},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawnTemplates":{},"spawned":{}},[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":-20},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},null,[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":-20},"hubAv":{},"hud":null,"hidden":["trophy-0"],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hidden":["trophy-0"]},[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":-20},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},{"hidden":[]},[]],[{"hubPlace":{"contract":1,"id":"main","title":"Town","scene":"scenes/main.scene","controller":"walk","maxDurationSec":null,"result":null,"fallY":-20},"hubAv":{},"hud":null,"hidden":[],"held":[],"labels":{},"tints":{},"marks":{},"hubDoors":[],"spawned":{},"spawnTemplates":{}},null,[]]]
@@ -0,0 +1,46 @@
1
+ export function poseStorage() {
2
+ const rows = new Map();
3
+ const revisions = new Map();
4
+ let serial = 0;
5
+ return {
6
+ rows,
7
+ async snapshot({ prefix }) {
8
+ return {
9
+ access: 'test-access',
10
+ targets: [
11
+ {
12
+ revision: revisions.get(prefix) ?? null,
13
+ rows: Object.fromEntries([...rows].filter(([key]) => key.startsWith(prefix))),
14
+ },
15
+ ],
16
+ };
17
+ },
18
+ async transaction({ changes }) {
19
+ const { prefix, expectedRevision, replace } = changes[0];
20
+ if ((revisions.get(prefix) ?? null) !== expectedRevision) {
21
+ throw new Error('SAVE_CONFLICT');
22
+ }
23
+ for (const key of rows.keys()) {
24
+ if (key.startsWith(prefix)) {
25
+ rows.delete(key);
26
+ }
27
+ }
28
+ for (const [key, value] of Object.entries(replace)) {
29
+ rows.set(key, structuredClone(value));
30
+ }
31
+ const revision = String(++serial);
32
+ revisions.set(prefix, revision);
33
+ return { revisions: [{ revision }] };
34
+ },
35
+ async list({ prefix, limit, cursor }) {
36
+ const all = [...rows]
37
+ .filter(([key]) => key.startsWith(prefix) && (!cursor || key > cursor))
38
+ .sort(([a], [b]) => a.localeCompare(b));
39
+ const page = all.slice(0, limit);
40
+ return {
41
+ entries: page.map(([key, value]) => ({ key, value })),
42
+ cursor: all.length > limit ? page.at(-1)[0] : null,
43
+ };
44
+ },
45
+ };
46
+ }
@@ -0,0 +1,186 @@
1
+ import assert from 'node:assert/strict';
2
+ import { fakeDom } from './fixtures/fake-dom.mjs';
3
+ import { hub, clear } from '../code/client/state.js';
4
+ import { fitTalk, makeAct, placeBox } from '../code/client/act.js';
5
+
6
+ for (const hint of [false, true]) {
7
+ for (const width of [120, 251]) {
8
+ const verb = 'Talk to Mabel of the Lantern Makers and the Quiet Harbour Watch';
9
+ const text = fitTalk(verb, hint, width, text => Array.from(text).length * 7);
10
+ assert(text.split('\n').length <= 2);
11
+ assert(text.split('\n').every(line => Array.from(line).length * 7 <= width));
12
+ const words = text.replace(/ · E$/, '').replace('…', '').split(/\s+/);
13
+ assert(words.every(word => verb.split(' ').includes(word)), 'ellipsis follows whole words');
14
+ assert.equal(text.endsWith(' · E'), hint);
15
+ }
16
+ }
17
+ assert.equal(fitTalk('Talk to Rowan', false, 251, text => text.length * 7), 'Talk to Rowan');
18
+ assert.equal(fitTalk(`Talk to ${'Longname'.repeat(30)}`, false, 251, text => text.length * 7), 'Talk to…');
19
+ const wide = text => Array.from(text).reduce((sum, char) => sum + (char === 'W' ? 14 : char === '…' ? 16 : 7), 0);
20
+ assert.equal(fitTalk(`Talk to ${'W'.repeat(13)} ${'W'.repeat(17)} a`, false, 251, wide), 'Talk to…', 'remeasure line one after dropping a near-width second line');
21
+ assert.equal(fitTalk('Talk to Rowan', true, 10, text => text.length * 7), '', 'never overflow when even the omission hint cannot fit');
22
+
23
+ const view = { viewW: 844, viewH: 390 }, dom = fakeDom(view);
24
+ const create = document.createElement;
25
+ document.createElement = tag => {
26
+ const node = create(tag);
27
+ if (tag === 'canvas') {node.getContext = () => ({ measureText: text => ({ width: text.length * 7 }) });}
28
+ node.getBoundingClientRect = () => {
29
+ if (node.style.display === 'none') {return { left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0 };}
30
+ let left = parseFloat(node.style.left) || 0, top = parseFloat(node.style.top) || 0;
31
+ for (let parent = node.parent; parent; parent = parent.parent) {
32
+ left += parseFloat(parent.style.left) || 0; top += parseFloat(parent.style.top) || 0;
33
+ }
34
+ const width = parseFloat(node.style.width) || node.textContent.length * 7 + 28;
35
+ const height = parseFloat(node.style.height) || 44;
36
+ return { left, right: left + width, top, bottom: top + height, width, height };
37
+ };
38
+ return node;
39
+ };
40
+ let now = 0;
41
+ globalThis.performance = { now: () => now };
42
+ globalThis.innerWidth = 844; globalThis.innerHeight = 390;
43
+ globalThis.getComputedStyle = () => ({ paddingLeft: '20px', paddingRight: '20px', paddingTop: '8px', paddingBottom: '8px' });
44
+ globalThis.matchMedia = () => ({ matches: true });
45
+ const handlers = new Map();
46
+ globalThis.addEventListener = (type, fn) => handlers.set(type, fn);
47
+ document.addEventListener = (type, fn) => handlers.set(type, fn);
48
+ const event = (code = null) => ({ code, pointerId: 1, preventDefault() {}, stopPropagation() {}, stopImmediatePropagation() {}, target: {} });
49
+ const actors = [
50
+ { id: 'one', components: { HubAct: { id: 'one', verb: 'Play', reach: 4, hold: false }, Transform: { x: 1, y: 1, z: 0 } } },
51
+ { id: 'two', components: { HubAct: { id: 'two', verb: 'Buy', reach: 4, hold: true }, Transform: { x: 2, y: 1, z: 0 } } },
52
+ ];
53
+ const sent = [], mp = { net: { selfId: () => 'p', send: data => sent.push(data) } };
54
+ const local = { components: { Transform: { x: 0, y: 1, z: 0 } } };
55
+ const original = () => false;
56
+ const scene = { getActors: () => actors, getActor: id => actors.find(a => a.id === id), moveInput: { consumeJump: original },
57
+ three: { camera: { position: { clone: () => ({ set() {return this;}, project() {return { x: 0, y: 0, z: 0 };} }) } } } };
58
+ const mode = [], root = document.createElement('div');
59
+ const surfaces = new Map();
60
+ let rail;
61
+ const chrome = {
62
+ interactionRoot: () => root, interactionObstacles: () => [], setActMode: value => mode.push(value),
63
+ interactionRail(pair, act, jump) {rail = pair; if (pair) {surfaces.set('act-pair', { node: pair, report: [act, jump] });} else {surfaces.delete('act-pair');}},
64
+ layoutInteractionRail() {if (rail) {Object.assign(rail.style, { left: `${innerWidth - 28 - 134}px`, top: `${innerHeight - 112}px` });}},
65
+ safeSurface(id, node, kind, placement) {if (node) {surfaces.set(id, { node, kind, placement });} else {surfaces.delete(id);}},
66
+ };
67
+ hub.place = { id: 'main', act: true }; hub.prompts = actors.map(a => ({ id: a.id, verb: a.components.HubAct.verb, hold: a.components.HubAct.hold }));
68
+ const ui = makeAct(chrome, { perform() {} }, { prepare() {} });
69
+ const frame = (can = true) => ui.frame(scene, mp, local, can);
70
+ const node = kind => dom.made.find(n => n.dataset.hubAct === kind);
71
+ const prompts = () => dom.made.filter(n => n.dataset.hubAct === 'prompt' && n.parent?.parent === root);
72
+ frame();
73
+ assert.deepEqual(mode, [true]);
74
+ assert.deepEqual(surfaces.get('act-pair').report.map(n => n.dataset.hubAct), ['act', 'jump']);
75
+ assert(surfaces.has('act-prompt:one'));
76
+ assert(!surfaces.has('root'), 'viewport root is not a report box');
77
+ assert.equal(prompts()[0].textContent, 'Play', 'fine pointer alone is not keyboard input');
78
+ handlers.get('keydown')(event('KeyW')); frame();
79
+ assert.equal(prompts()[0].textContent, 'Play · E', 'hardware game key enables hint');
80
+ handlers.get('pointerdown')({ ...event(), pointerType: 'touch' }); frame();
81
+ assert.equal(prompts()[0].textContent, 'Play', 'touch input shows the verb alone');
82
+ handlers.get('keydown')({ ...event('Enter'), target: { tagName: 'INPUT' } }); frame();
83
+ assert.equal(prompts()[0].textContent, 'Play', 'text/soft keyboard entry does not enable hints');
84
+ handlers.get('keydown')({ ...event('KeyW'), isComposing: true }); frame();
85
+ assert.equal(prompts()[0].textContent, 'Play', 'composing input does not enable hints');
86
+ globalThis.matchMedia = () => ({ matches: false });
87
+ handlers.get('keydown')(event('Tab')); frame();
88
+ assert.equal(prompts()[0].textContent, 'Play · E', 'keyboard on a coarse-pointer device still gets hints');
89
+ for (const pointerType of ['touch', 'pen', 'mouse']) {
90
+ handlers.get('pointerdown')({ ...event(), pointerType }); frame();
91
+ assert.equal(prompts()[0].textContent, 'Play', `${pointerType} input clears keyboard hint`);
92
+ }
93
+
94
+ assert.equal(prompts()[0].style.opacity, '1'); assert.equal(Number(prompts()[1].style.opacity), 0.55);
95
+ handlers.get('keydown')(event('KeyE')); assert.equal(sent.at(-1).id, 'one');
96
+ const nonce = sent.at(-1).n;
97
+ node('act').handlers.click({ ...event(), detail: 0 }); assert.equal(sent.at(-1).id, 'one');
98
+ for (const code of ['Space', 'Enter']) {
99
+ const before = sent.length; node('act').handlers.keydown(event(code)); node('act').handlers.keyup(event(code)); node('act').handlers.click({ ...event(code), detail: 0 });
100
+ assert.equal(sent.length, before + 1, 'native keyboard click dispatches once');
101
+ }
102
+ const afterClick = sent.length;
103
+ handlers.get('keydown')({ ...event('KeyE'), repeat: true }); assert.equal(sent.length, afterClick);
104
+ local.components.Transform.x = 2; frame();
105
+ assert.equal(prompts()[1].style.opacity, '1', 'nearest changes locally with no new server set');
106
+ handlers.get('keydown')(event('Space')); assert.equal(sent.at(-1).k, 'hub-act-hold');
107
+ now = 200; handlers.get('keyup')(event('Space')); assert.equal(sent.at(-1).down, false);
108
+ now = 1000; frame(); assert.equal(sent.filter(m => m.k === 'hub-act').length, 4, 'early release never buys');
109
+ handlers.get('keydown')(event('KeyE')); now = 1499; frame();
110
+ assert.equal(sent.at(-1).k, 'hub-act-hold', 'client does not spend the server latency allowance');
111
+ now = 1500; frame();
112
+ assert.equal(sent.at(-1).k, 'hub-act'); assert.equal(sent.at(-1).id, 'two'); assert(sent.at(-1).n > nonce);
113
+ const count = sent.length; now = 3000; frame(); assert.equal(sent.length, count, 'completed hold does not repeat');
114
+ handlers.get('keydown')(event('KeyE')); now = 3500; handlers.get('keyup')(event('KeyE'));
115
+ assert.equal(sent.at(-1).k, 'hub-act', 'elapsed keyboard hold completes before the next frame');
116
+ const buy = prompts().find(n => n._actItem.id === 'two');
117
+ buy.handlers.pointerdown(event()); now = 4000; buy.handlers.pointerup(event());
118
+ assert.equal(sent.at(-1).k, 'hub-act', 'elapsed pointer hold completes before the next frame');
119
+ buy.handlers.pointerdown(event()); now = 4500; buy.handlers.pointercancel(event());
120
+ assert.equal(sent.at(-1).down, false, 'pointer cancellation still voids an elapsed hold');
121
+ // A dim prompt remains tappable and selects itself.
122
+ const first = prompts().find(n => n._actItem.id === 'one'); first.handlers.pointerdown(event()); assert.equal(sent.at(-1).id, 'one');
123
+ handlers.get('keydown')(event('KeyE')); frame(false); assert.equal(sent.at(-1).down, false, 'panel/trip cancels');
124
+ frame(); handlers.get('keydown')(event('KeyE')); handlers.get('blur')(); assert.equal(sent.at(-1).down, false);
125
+ hub.prompts = []; frame(); const previous = sent.length;
126
+ handlers.get('keydown')(event('Space')); assert.equal(sent.length, previous, 'Space without prompts stays engine jump');
127
+ node('jump').handlers.pointerdown(event()); assert.equal(scene.moveInput.consumeJump(), true); assert.equal(scene.moveInput.consumeJump(), false);
128
+ for (const [w, h] of [[844, 390], [390, 844], [1280, 720], [352, 526]]) {
129
+ globalThis.innerWidth = w; globalThis.innerHeight = h; frame();
130
+ for (const n of [node('act'), node('jump')]) {
131
+ const r = n.getBoundingClientRect(); assert(r.left >= 20 && r.right <= w - 20 && r.top >= 8 && r.bottom <= h - 8);
132
+ }
133
+ }
134
+ assert.equal(placeBox(500, 44, { x: 100, y: 100 }, { left: 20, right: 332, top: 8, bottom: 518 }, []), null, 'oversized boxes never clip');
135
+ const bounds = { left: 20, right: 824, top: 8, bottom: 382 };
136
+ const box = placeBox(100, 44, { x: 800, y: 20 }, bounds, [{ left: 760, right: 844, top: 8, bottom: 64 }]);
137
+ assert(box.left >= 20 && box.right <= 824 && box.top >= 70);
138
+ ui.dispose(); assert.equal(scene.moveInput.consumeJump, original); assert.deepEqual(mode, [true, false]); assert.equal(surfaces.size, 0, 'dispose removes every registered Act surface');
139
+ hub.prompts = [{ id: 'old' }]; clear(); assert(!Object.hasOwn(hub, 'prompts'));
140
+
141
+ // Harbour stall 0: a loose ball nearer than the counter does not take Act;
142
+ // a keeper behind the player never puts its pill on the avatar.
143
+ globalThis.innerWidth = 844; globalThis.innerHeight = 390;
144
+ const stall = [
145
+ { id: 'trade', components: { HubAct: { id: 'trade', verb: 'Trade', reach: 4, hold: true }, Transform: { x: 2.5, y: 1, z: 0 } } },
146
+ { id: 'ball', components: { Body: { type: 'dynamic' }, Transform: { x: 0.6, y: 1, z: 0 } } },
147
+ { id: 'clem', components: { HubNpc: { name: 'Clem' }, Transform: { x: 0, y: 1, z: -1 } } },
148
+ ];
149
+ // Everything projects onto the middle of the screen, where the avatar is.
150
+ const avatar = { left: 380, right: 464, top: 150, bottom: 300 };
151
+ const stallScene = { ...scene, getActors: () => stall, getActor: id => stall.find(a => a.id === id) };
152
+ const stallUi = makeAct({ ...chrome, worldAvatar: () => avatar }, { perform() {} }, { prepare() {} });
153
+ hub.place = { id: 'main', act: true, grab: true };
154
+ hub.prompts = [{ id: 'trade', verb: 'Trade', hold: true }, { id: 'ball', verb: 'Grab', hold: false }, { id: 'clem', verb: 'Talk to Clem', hold: false }];
155
+ local.components.Transform.x = 0;
156
+ stallUi.frame(stallScene, mp, local, true);
157
+ const shown = prompts().filter(n => stall.some(a => a.id === n._actItem?.id) && n.style.display !== 'none');
158
+ const byId = id => shown.find(n => n._actItem.id === id);
159
+ assert.equal(byId('trade').style.opacity, '1', 'an authored counter verb outranks a nearer Grab');
160
+ assert.equal(Number(byId('ball').style.opacity), 0.55);
161
+ assert.equal(Number(byId('clem').style.opacity), 0.55, 'and outranks a nearer Talk');
162
+ const crosses = (a, b) => a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;
163
+ for (const n of shown) {assert(!crosses(n.getBoundingClientRect(), avatar), `${n._actItem.verb} stays off the avatar`);}
164
+ for (const a of shown) {for (const b of shown) {if (a !== b) {assert(!crosses(a.getBoundingClientRect(), b.getBoundingClientRect()), 'pills do not overlap');}}}
165
+ assert(byId('clem'), 'the secondary Talk pill is still offered');
166
+ local.components.Transform.x = 0.6; stallUi.frame(stallScene, mp, local, true);
167
+ assert.equal(byId('trade').style.opacity, '1', 'standing on the ball still leaves Trade focused');
168
+ stallUi.dispose();
169
+ // A HUD band above the avatar: the pill cannot lift there, and it stays
170
+ // inside the safe-area bounds (20px insets + 8) rather than a bare 8px margin.
171
+ const hud = document.createElement('div');
172
+ Object.assign(hud.style, { left: '300px', top: '8px', width: '260px', height: '132px' }); root.appendChild(hud);
173
+ const before = new Set(prompts());
174
+ const hudUi = makeAct({ ...chrome, worldAvatar: () => avatar, interactionObstacles: () => [hud] }, { perform() {} }, { prepare() {} });
175
+ hudUi.frame(stallScene, mp, local, true);
176
+ const hudRect = hud.getBoundingClientRect();
177
+ const hudShown = prompts().filter(n => !before.has(n) && n.style.display !== 'none');
178
+ assert.equal(hudShown.length, 3, 'every pill still finds a clear place');
179
+ for (const n of hudShown) {
180
+ const r = n.getBoundingClientRect();
181
+ assert(!crosses(r, avatar), `${n._actItem.verb} stays off the avatar beside the HUD`);
182
+ assert(!crosses(r, hudRect), `${n._actItem.verb} stays off the HUD`);
183
+ assert(r.left >= 28 && r.right <= 816 && r.top >= 16 && r.bottom <= 374, `${n._actItem.verb} stays inside the safe bounds`);
184
+ }
185
+ hudUi.dispose(); hud.remove(); clear();
186
+ console.log('Act client: counter verbs first, pills off the avatar, nearest, tappable dim prompt, keys, hold cancel/completion, Jump, insets and cleanup passed');