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
@@ -55,10 +55,17 @@ and so the kit check stays quiet. Each still counts toward its deck's cap of 6.
55
55
  ## Pets
56
56
 
57
57
  Pet species use `pet-<species>` and count toward the separate cap of 16 pet
58
- items per deck. Nestlings (#1020) claims `pet-<species>` rows here when it
59
- declares them. The resident dog is given by nobody. `pet-walk-*` pieces above
58
+ items per deck. Nestlings (#1020) claims its seven `pet-<species>` rows here.
59
+ The resident dog is given by nobody. `pet-walk-*` pieces above
60
60
  are furniture recording the house pet's stage, never pet species.
61
61
 
62
62
  | id | class | giving game |
63
63
  | --- | --- | --- |
64
64
  | `pet-dog` | pet | the house's own, never declared by a game |
65
+ | `pet-bristlebean` | pet | Nestlings Meadow |
66
+ | `pet-puddleplum` | pet | Nestlings Meadow |
67
+ | `pet-tumbletuft` | pet | Nestlings Meadow |
68
+ | `pet-kitesnout` | pet | Nestlings Meadow |
69
+ | `pet-pebblepip` | pet | Nestlings Meadow |
70
+ | `pet-moonmottle` | pet | Nestlings Meadow |
71
+ | `pet-crownwhisk` | pet | Nestlings Meadow |
@@ -0,0 +1,252 @@
1
+ # Observed progress (v1.141): design
2
+
3
+ A door that scores from where players walk asks the kit, not the body.
4
+
5
+ ## The problem
6
+
7
+ A connected player's server body is a kinematic-position-based capsule.
8
+ Each physics step sets it from `player.at`, the last client report that
9
+ `multiplayer-3d`'s `setPose` accepted (`world.js` `step`). A kinematic body is never
10
+ pushed by contacts, so after the step `body.translation()` is exactly `player.at`.
11
+ No server signal about a player's position is independent of the client.
12
+ Door code that compares "target" with "body" is comparing a value with itself.
13
+
14
+ What the server can still check is whether the reported motion is motion a real player
15
+ could make. Today three things let a report do what walking can't:
16
+
17
+ 1. **Per-report slack.** `setPose` allows `maxSpeed × elapsed + MOVE_SLACK`, with a
18
+ 12 m/s maximum and 0.6 m of slack, and it applies that allowance to every report.
19
+ Several reports in one tick get 0.6 m each, which is far beyond the scene's 6 m/s
20
+ walk speed. A "bounded MOVE" can therefore reach a station 6 m away in a fraction
21
+ of a second.
22
+ 2. **Walls.** A kinematic capsule passes through fixed geometry, so the reported path
23
+ can cross a wall.
24
+ 3. **Placements.** The kit puts a body on a spot when a player arrives, jumps, gets
25
+ unstuck, is caught after a fall, is held or settled, or when a deck calls
26
+ `hub.placeAt`. None of these involve walking.
27
+
28
+ ## The rule
29
+
30
+ The kit observes every body **once per tick, after physics and before any authored
31
+ hook in `step`**. The only position a door scores from is the kit's observed
32
+ position.
33
+
34
+ `player.at` and `hub.players()[i].at` are inputs. A door may draw from them, but they
35
+ are never evidence.
36
+
37
+ ## API (`hub`, v1.141)
38
+
39
+ - `hub.observed(playerId)` → `null`, or
40
+ `{ at, step, ok, travel, since, speed }`:
41
+ - `at`: the last admitted post-step position.
42
+ - `step`: the admitted displacement this tick. It is zero when the tick was rejected
43
+ or the player stood still.
44
+ - `ok`: whether this tick's body was admitted.
45
+ - `travel`: horizontal metres admitted since the last reset.
46
+ - `since`: the sim time of the last reset.
47
+ - `speed`: the limit applied, in m/s.
48
+
49
+ Values are copies.
50
+ - `hub.station(id, { at: { x, y, z }, radius, height = 2 })` declares a station: a
51
+ vertical cylinder centred on `at`. `hub.station(id, null)` removes it. Declaring a
52
+ station with the same id and the same shape is a no-op. Changing its shape zeroes
53
+ every player's dwell at that station.
54
+ - `hub.dwell(playerId, id)` → `{ inside, entered, ms }`, or `null`:
55
+ - `inside` uses the observed position, with hysteresis: a player is in from
56
+ `radius` and out beyond `radius + 0.25 m`.
57
+ - `entered` means the player walked out beyond the exit radius and then back
58
+ within `radius` by admitted steps (Stations, below).
59
+ - `ms` is how long the player has been continuously entered on admitted, present
60
+ ticks.
61
+
62
+ A door fires its effect when `ms` reaches its own threshold.
63
+
64
+ Observation is lazy. A place starts it the first time it calls `hub.observed` or
65
+ `hub.station`, so a town that never calls either keeps no state. At that point every
66
+ current body is reset.
67
+
68
+ ## Admission (per tick, per player)
69
+
70
+ Let `d` be the horizontal displacement from `at` to this tick's body position.
71
+
72
+ - **Allowance.** `allowance` is the scene's `Player.speed` (6 if unset) times the
73
+ player's `hub.tune` speed factor, times a 1.25 tolerance.
74
+ - **One credit clock.** Elapsed time comes from a single monotonic clock `C`, the
75
+ larger of the sim's total and the wall clock's total since observation started.
76
+ A tick moves `C` by at most its own sim delta plus 1 s. The wall clock covers a
77
+ server stall, because real-time caps the sim delta at 250 ms. Taking the larger
78
+ *total* rather than adding up each tick's larger delta means tick quantisation is
79
+ never counted twice. A tick's elapsed time is `C_now − C_prev`. Dwell `ms` counts
80
+ sim time only (see Stations).
81
+ - **Reachability.** Every step must first be reachable from the last point where
82
+ `at` moved: `d <= allowance × (C − lastMovedAt) + 0.5 m`, finite, and inside the
83
+ world bounds. Anything else is **rejected**: nothing is spent, `at` stays put,
84
+ `ok` is false, `step` is zero, every station goes to `unknown` and `ms` to 0.
85
+ Later ticks test again from the held `at`.
86
+ - **One signed credit.** Each player has one credit, in metres. It works like a
87
+ token bucket that is allowed to go negative. Each tick,
88
+ `credit = min(credit + allowance × elapsed, CAP)`, where
89
+ `CAP = 0.4 s × allowance + 0.3 m` (3.3 m at the default speed). A reset or a
90
+ placement sets it to 0. Every reachable step **always** spends: `credit -= d`,
91
+ and `at` becomes the body.
92
+ - If `credit >= -1e-6` after spending, the step is **funded**. It is credited as
93
+ `travel`, it reports `step`, it may set a station `out` or `in`, and dwell
94
+ accrues while the player is `in`.
95
+ - Otherwise the step is **unfunded**, which is what a resync means now. `ok` is
96
+ true, `step` reads zero, no travel is credited, every station goes to
97
+ `unknown`, and `ms` goes to 0.
98
+ - **What the credit does.** Slack is never per report, so stuffing reports into one
99
+ tick buys nothing beyond the credit. A jump pushes the credit negative. It is paid
100
+ back by walking slower than the allowance or by standing, never by forgiving it,
101
+ and a walker who never stops recovers. After a 1 s server stall, a 6 m/s walker
102
+ owes about 2.7 m and pays 1.5 m/s back: their steps are funded again about 1.8 s
103
+ later. The comparison uses a 1e-6 epsilon, never a wire quantisation, which was
104
+ Rainbarrel's ULP false retirement.
105
+
106
+ The vertical axis is not checked.
107
+
108
+ **The invariant:** at any funded observation, the displacement since the last reset
109
+ is at most `allowance × (C − C_reset) + CAP + 1e-6`. No allowance is counted twice,
110
+ and nothing gets stuck. It follows that:
111
+
112
+ - credited `travel` comes only from funded steps, within the same bound;
113
+ - entering a station needs a funded observation beyond the exit band, then a funded
114
+ one within `radius`;
115
+ - the only head start is the credit held before a jump, at most `CAP`, which saves at
116
+ most about 0.45 s over a walker at 1.25×;
117
+ - an unfunded step can move `at` a long way, but it earns nothing. Its distance has
118
+ to be paid back in time before anything is entered, and idling before a jump buys
119
+ only the cap.
120
+
121
+ ## Stations
122
+
123
+ Each (player, station) pair has a state of `unknown`, `out` or `in`, plus `ms`.
124
+
125
+ - Only a funded observation moves a station's state. An unfunded or rejected
126
+ position sets neither `out` nor `in`.
127
+ - A funded observation beyond `radius + 0.25 m` sets `out`.
128
+ - Once `out`, a funded observation within `radius` sets `in`. `in` means
129
+ entered. Ordinary walking through the hysteresis band in
130
+ many small steps enters.
131
+ - `in` holds until a funded observation is beyond `radius + 0.25 m`, which sets `out`.
132
+ - `ms` grows by the tick's **sim** delta (game time, not the credit clock) while the
133
+ state is `in`, `ok` is true and the player is present in
134
+ `session.players`. Absent ticks add nothing and zero nothing.
135
+ - A reset, an unfunded step or a rejection sets every station's state to `unknown` and `ms` to
136
+ 0. From `unknown`, an observation within the exit radius stays `unknown`: the player
137
+ must walk out and back in.
138
+
139
+ `hub.dwell` reports `inside` (whether the observed position is within the hysteresis
140
+ radius), `entered` (whether the state is `in`) and `ms`.
141
+
142
+ ## Resets
143
+
144
+ A reset sets `at` to the body position, zeroes `travel`, `step` and the credit,
145
+ sets `since` to now, and sets every station's state to `unknown`.
146
+
147
+ - **Placements.** These are every `moveBody`: arrival (§5), a `hub.go` group
148
+ placement, a jump to a door or a friend, `hub.goto`, unstuck, a fall catch,
149
+ `hub.placeAt`, `hub.hold`, hold and settle enforcement, sit and act placements, and
150
+ a retained return. A placement that moves the body more than 5 cm horizontally from
151
+ `at` invalidates the player **synchronously**, inside `moveBody`: scoring state is
152
+ cleared, and `hub.observed().ok` and `hub.dwell` read false or zero at once, even
153
+ inside a resume hook in the same tick. The kit records the placement's
154
+ **destination**. The next observe pass resets `at` to that destination, not to
155
+ wherever reports took the body afterwards, with no credit and
156
+ `lastMovedAt` set to now. In the same pass it then admits the move from the
157
+ destination to this tick's body as usual. Reports stuffed between a placement and
158
+ the pass are therefore admitted from the placement or rejected. They never become
159
+ the trusted origin. When several placements land before a pass, the last one wins.
160
+
161
+ A placement onto the same spot does not reset. That covers a retained return that
162
+ puts an unchanged body back where it was (`hub.js` retained-return path) and hold
163
+ enforcement that undoes a drift. Neither of these moves a player anywhere.
164
+ - **Bodies.** A new sim entry or a new body object for the same id, and the first
165
+ observation of a body. This also covers the spawn-height adjustment in `players.js`.
166
+ When the player leaves the sim, their record is deleted.
167
+
168
+ A **retained resume on the same body** is not a reset. Dwell did not advance while
169
+ the player was absent, and nothing restarts. This was Cedar v2's failure: a return
170
+ must not restart a grace period.
171
+
172
+ ## Details the build settled
173
+
174
+ The kit's `code/server/observe.js` implements this. Where the text above left room,
175
+ it does the following:
176
+
177
+ - **The reach clock.** `lastMovedAt` is the credit-clock time when `at` last moved:
178
+ a funded or unfunded step, or a reset. Standing still does not renew it, because a
179
+ server that hears nothing can't tell a player standing still from a stalled
180
+ connection. So an unfunded step after standing still can move `at` by up to
181
+ `allowance` × the time stood. It also drives the credit that far negative, so the
182
+ player waits about that long again before entering anything. The credit and the
183
+ reach test use the credit clock. Dwell `ms` uses sim time.
184
+ - **Rounding.** A funded displacement under 1e-6 m is the capsule's float32
185
+ rounding. It is admitted, but it doesn't count as travel or as movement.
186
+ - **An unfunded step's `step`** is zero. Only funded steps report a displacement
187
+ or add travel.
188
+ - **A reset's `ok`** is true. The kit put the body there, and stations still start
189
+ `unknown`.
190
+ - **Height** gates entering and `inside`: the observed `y` must be within
191
+ `height / 2` of the station's `at.y`. Leaving is horizontal only, beyond
192
+ `radius + 0.25 m`. Leaving also zeroes `ms`.
193
+ - **Synchronous invalidation.** A placement more than 5 cm from `at` makes
194
+ `hub.dwell` read `{ inside: false, entered: false, ms: 0 }` until the next pass
195
+ adopts the new spot.
196
+ - **Validation.** A station id is 1 to 64 letters, digits, `_`, `.`, `:` or `-`.
197
+ A place may declare at most 64 stations. `radius` and `height` must be above 0
198
+ and at most 200 m, and coordinates must be finite and within ±1,000,000. A bad
199
+ call warns once and returns false. `hub.station` returns true when the call
200
+ takes.
201
+
202
+ ## What it does not claim (v1)
203
+
204
+ - It cannot tell a scripted client from a person.
205
+ - **It does not check walls or walkability.** A kinematic capsule's chord sweep falsely
206
+ rejects curved walks at 150 to 200 ms report cadence. Unchecked flight or resync
207
+ across walls would also defeat a sweep, and proving walkability needs a path search.
208
+ A door must not depend on walls to make one route longer than another. The dot doors
209
+ have open floors. A walled-route check is a separate follow-up.
210
+ - Moving platforms that carry players faster than 0.25× the walk speed resync, and
211
+ resyncing loses dwell.
212
+
213
+ ## Rookery, Loom and the deferred jobs
214
+
215
+ **Rookery** (P1 at `game.js:25`) and **Loom** drop their `motion.js` and their
216
+ target-against-body comparisons:
217
+
218
+ - Stations become `hub.station`.
219
+ - The "at a station" test becomes `hub.dwell(...).entered && ms >= N`.
220
+ - Gating on contribution uses `hub.observed(id).travel`.
221
+ - Grace windows, leases and "safe pose" all go: placement resets cover them.
222
+
223
+ **Cedar** (placement grace against ordinary motion), **Harbor** (settling and grace)
224
+ and **Willow** (pending-lease aging on invalid samples) all reduce to the reset and
225
+ reject rules above.
226
+
227
+ **Ripple** and **Windrose** are about who owns visit termination, not motion, so this
228
+ API does not cover them.
229
+
230
+ ## Tests (kit, real Rapier)
231
+
232
+ All of these run against a small open scene, using `multiplayer-3d`'s
233
+ real `world`, `players.setPose` and the hub layer's `place` and `step`.
234
+
235
+ 1. Walking at 6 m/s and at 4 m/s, with reports every 50, 100, 150 and 200 ms and a
236
+ three-report burst after a 300 ms stall, reaches the station. `entered` is set,
237
+ `ms` grows, and `ok` holds throughout.
238
+ 2. Bounded MOVE stuffing: many in-bound reports per tick toward a station 6 m away
239
+ after 2 s idle. Either the step is rejected, or it resyncs as unentered: `entered`
240
+ is never set by the jump. Walking in afterwards needs the out-then-in transition.
241
+ 3. Reports at 12 m/s, inside `setPose`'s own clamp, outrun the credit: they go unfunded or
242
+ are rejected, earn no travel and never enter.
243
+ 4. Hysteresis: 4 m/s with 50 ms reports enters (the case Sol named).
244
+ 5. `hub.placeAt` onto a station, an arrival, and a jump: each is a reset, with the
245
+ player inside, not entered and `ms` at 0. Stepping out and back in enters.
246
+ 6. A retained resume on the same body is not a reset, including the retained-return
247
+ `moveBody` onto the same spot. A replacement body is a reset. A placement inside
248
+ a resume hook invalidates `hub.dwell` in that same tick.
249
+ 7. A 3 s network stall followed by a burst resyncs: `ok` is true, nothing is entered,
250
+ and no travel is credited for the gap. A 1 s server stall, with sim time capped,
251
+ followed by legitimate reports is admitted or resynced, never rejected.
252
+ 8. A place that never calls the API keeps no observation state.
@@ -3,4 +3,6 @@
3
3
  // editors; the hub's client half arrives on its own -- `code/systems/hub.js`
4
4
  // through the engine's system registry, `code/client/hookLayer.js` through
5
5
  // `castle.real-time`'s client hooks.
6
+ import './code/client/loadingEntry.js';
7
+ import './code/client/qualityEntry.js';
6
8
  import '@imports/castle.multiplayer-3d/main.jsx';
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hub-game",
3
- "version": "1.87.0",
3
+ "version": "1.99.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "hub-game",
9
- "version": "1.87.0",
9
+ "version": "1.99.0",
10
10
  "dependencies": {
11
11
  "@codemirror/commands": "^6.10.3",
12
12
  "@codemirror/lang-javascript": "^6.2.5",
@@ -22,6 +22,7 @@
22
22
  "@lezer/highlight": "^1.2.3",
23
23
  "castle-web-fonts": "^1.0.0",
24
24
  "codemirror": "^6.0.2",
25
+ "fflate": "^0.8.3",
25
26
  "matter-js": "^0.20.0",
26
27
  "react": "^19.2.4",
27
28
  "react-dom": "^19.2.4",
@@ -33,7 +34,7 @@
33
34
  },
34
35
  "../../sdk": {
35
36
  "name": "castle-web-sdk",
36
- "version": "0.4.45",
37
+ "version": "0.4.49",
37
38
  "dev": true,
38
39
  "devDependencies": {
39
40
  "eslint": "^9.0.0",
@@ -306,6 +307,12 @@
306
307
  "integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",
307
308
  "license": "MIT"
308
309
  },
310
+ "node_modules/fflate": {
311
+ "version": "0.8.3",
312
+ "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz",
313
+ "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==",
314
+ "license": "MIT"
315
+ },
309
316
  "node_modules/matter-js": {
310
317
  "version": "0.20.0",
311
318
  "resolved": "https://registry.npmjs.org/matter-js/-/matter-js-0.20.0.tgz",
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "hub-game",
3
- "version": "1.90.0",
3
+ "version": "1.99.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "check": "eslint . && node scripts/test-manifest.mjs && node scripts/test-build.mjs && node scripts/test-decor.mjs && node scripts/test-actions.mjs && node scripts/test-actions-client.mjs && node scripts/test-ask.mjs && node scripts/test-ask-client.mjs && node scripts/test-menu.mjs && node scripts/test-menu-client.mjs && node scripts/test-companion.mjs && node scripts/test-companion-chat.mjs && node scripts/test-companion-client.mjs && node scripts/test-visibility.mjs && node scripts/test-rehello.mjs && node scripts/test-decor-client.mjs && node scripts/test-yours.mjs && node scripts/test-yours-chrome.mjs && node scripts/test-npcs.mjs && node scripts/test-avatar.mjs && node scripts/test-avatar-colors.mjs && node scripts/test-avatar-models.mjs && node scripts/test-avatar-wire.mjs && node scripts/test-avatar-share.mjs && node scripts/test-avatar-cap.mjs && node scripts/test-picker.mjs && node scripts/test-friend-bests.mjs && node scripts/test-hub-ops.mjs && node scripts/test-hub-leaving.mjs && node scripts/test-standing.mjs && node scripts/test-actors.mjs && node scripts/test-grab.mjs && node scripts/test-grab-client.mjs && node scripts/test-grab-orbit.mjs && node scripts/test-idle.mjs && node scripts/test-emote-bubble.mjs && node scripts/test-shot.mjs && node scripts/test-vis.mjs && node scripts/test-keys.mjs && node scripts/test-attention.mjs && node scripts/test-hub-trip.mjs && node scripts/test-pack.mjs && node scripts/test-interest.mjs && node scripts/test-relations-among.mjs && node scripts/test-relations-refresh.mjs && node scripts/test-cells.mjs && node scripts/test-interest-cells.mjs && node scripts/test-interest-cap.mjs && node scripts/test-object-entry.mjs && node scripts/test-interest-client.mjs && node scripts/test-blocks.mjs && node scripts/test-ban-join.mjs && node scripts/test-door.mjs && node scripts/test-door-jump.mjs && node scripts/test-together.mjs && node scripts/test-party.mjs && node scripts/test-say.mjs && node scripts/test-ballot.mjs && node scripts/test-chat.mjs && node scripts/test-no-forms.mjs && node scripts/test-classic.mjs && node scripts/test-actor-budget.mjs && node scripts/test-tiers.mjs && node scripts/test-tiers-render.mjs && node scripts/test-tier-cells.mjs && node scripts/test-hats.mjs && node scripts/test-try-on.mjs && node scripts/test-earned.mjs && node scripts/test-earned-client.mjs && node scripts/test-spin.mjs && node scripts/test-hud-clear.mjs && node scripts/test-labels.mjs && node scripts/test-stuck.mjs && node scripts/test-toast-band.mjs && node scripts/test-soundscape.mjs && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
8
- "format": "prettier --write \"code/**/*.js\" \"scripts/**/*.mjs\" castle.json package.json"
7
+ "precheck": "node scripts/test-back-visibility.mjs && node scripts/test-landscape-layout.mjs && node scripts/test-safe-layout.mjs && node scripts/test-action-observers.mjs && node scripts/test-crowd-names.mjs && node scripts/test-default-environment.mjs && node scripts/test-default-environment-root.mjs",
8
+ "check": "eslint . && npm run test:anonymous-entry && node scripts/test-manifest.mjs && node scripts/test-push-visit.mjs && node scripts/test-act.mjs && node scripts/test-act-client.mjs && node scripts/test-loading-cover.mjs && node scripts/test-frame-batch.mjs && node scripts/test-invites.mjs && node scripts/test-invites-client.mjs && node scripts/test-analytics.mjs && node scripts/test-door-analytics.mjs && node scripts/test-fps-telemetry.mjs && node scripts/test-load-abandon.mjs && node scripts/test-build.mjs && node scripts/test-decor.mjs && node scripts/test-actions.mjs && node scripts/test-resume-action-order.mjs && node scripts/test-actions-client.mjs && node scripts/test-action-layout.mjs && node scripts/test-ask-slot.mjs && node scripts/test-placement-cache.mjs && node scripts/test-ask.mjs && node scripts/test-ask-client.mjs && node scripts/test-menu.mjs && node scripts/test-menu-client.mjs && node scripts/test-companion.mjs && node scripts/test-companion-chat.mjs && node scripts/test-companion-client.mjs && node scripts/test-visibility.mjs && node scripts/test-rehello.mjs && node scripts/test-resume-pose.mjs && node scripts/test-resume-held.mjs && node scripts/test-arrival-pose.mjs && node scripts/test-arrival-pose-server.mjs && node scripts/test-arrival-pose-server.mjs clinic && node scripts/test-arrival-pose-server.mjs cove && node scripts/test-arrival-pose-server.mjs fishing && node scripts/test-arrival-pose-server.mjs plot && node scripts/test-arrival-pose-server.mjs runway && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs clinic && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs cove && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs fishing && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs plot && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs runway && POSE_REPLACE=1 POSE_PLAIN=1 POSE_RESULT=1 node scripts/test-arrival-pose-server.mjs && POSE_LINE=1 node scripts/test-arrival-pose-server.mjs && node scripts/test-progress-reset.mjs && node scripts/test-decor-client.mjs && node scripts/test-yours.mjs && node scripts/test-yours-chrome.mjs && node scripts/test-npcs.mjs && node scripts/test-avatar.mjs && node scripts/test-avatar-colors.mjs && node scripts/test-avatar-models.mjs && node scripts/test-avatar-wire.mjs && node scripts/test-avatar-share.mjs && node scripts/test-far-avatars.mjs && node scripts/test-avatar-cap.mjs && node scripts/test-picker.mjs && node scripts/test-friend-bests.mjs && node scripts/test-hub-ops.mjs && node scripts/test-storage-limit.mjs && node scripts/test-hub-leaving.mjs && node scripts/test-standing.mjs && node scripts/test-observed.mjs && node scripts/test-actors.mjs && node scripts/test-grab.mjs && node scripts/test-grab-client.mjs && node scripts/test-grab-orbit.mjs && node scripts/test-idle.mjs && node scripts/test-emote-bubble.mjs && node scripts/test-shot.mjs && node scripts/test-vis.mjs && node scripts/test-keys.mjs && node scripts/test-attention.mjs && node scripts/test-hub-trip.mjs && node scripts/test-pack.mjs && node scripts/test-interest.mjs && node scripts/test-relations-among.mjs && node scripts/test-relations-refresh.mjs && node scripts/test-fresh-friends.mjs && node scripts/test-cells.mjs && node scripts/test-interest-cells.mjs && node scripts/test-interest-cap.mjs && node scripts/test-object-entry.mjs && node scripts/test-interest-client.mjs && node scripts/test-blocks.mjs && node scripts/test-ban-join.mjs && node scripts/test-door.mjs && node scripts/test-door-jump.mjs && node scripts/test-together.mjs && node scripts/test-party.mjs && node scripts/test-say.mjs && node scripts/test-ballot.mjs && node scripts/test-chat.mjs && node scripts/test-no-forms.mjs && node scripts/test-classic.mjs && node scripts/test-actor-budget.mjs && node scripts/test-quality.mjs && node scripts/test-high-only.mjs && node scripts/test-tiers.mjs && node scripts/test-tiers-render.mjs && node scripts/test-tier-cells.mjs && node scripts/test-hats.mjs && node scripts/test-try-on.mjs && node scripts/test-earned.mjs && node scripts/test-earned-client.mjs && node scripts/test-spin.mjs && node scripts/test-hud-clear.mjs && node scripts/test-labels.mjs && node scripts/test-world-labels.mjs && node scripts/test-pad-occupancy.mjs && node scripts/test-pad-cues.mjs && node scripts/test-stuck.mjs && node scripts/test-toast-band.mjs && node scripts/test-soundscape.mjs && node scripts/test-weakest-tier.mjs && node scripts/test-hud-rate.mjs && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
9
+ "format": "prettier --write \"code/**/*.js\" \"scripts/**/*.mjs\" castle.json package.json",
10
+ "test:anonymous-entry": "node scripts/test-signin-client.mjs && node scripts/test-anonymous-entry.mjs"
9
11
  },
10
12
  "dependencies": {
11
13
  "@codemirror/commands": "^6.10.3",
@@ -22,6 +24,7 @@
22
24
  "@lezer/highlight": "^1.2.3",
23
25
  "castle-web-fonts": "^1.0.0",
24
26
  "codemirror": "^6.0.2",
27
+ "fflate": "^0.8.3",
25
28
  "matter-js": "^0.20.0",
26
29
  "react": "^19.2.4",
27
30
  "react-dom": "^19.2.4",
@@ -0,0 +1,142 @@
1
+ import { loadingCover } from '../code/client/loadingCover.js';
2
+
3
+ function style(element, rules) {
4
+ for (const [name, value] of Object.entries(rules))
5
+ element.style[name] = typeof value === 'number' ? value + 'px' : value;
6
+ return element;
7
+ }
8
+ function errorOverlay(error, restart) {
9
+ const cover = style(document.createElement('div'), {
10
+ position: 'absolute',
11
+ inset: 0,
12
+ padding: '20px 22px',
13
+ background: 'rgba(20, 8, 8, 0.94)',
14
+ color: '#ffd9dc',
15
+ font: "13px/1.5 'SFMono-Regular', Consolas, monospace",
16
+ overflow: 'auto',
17
+ });
18
+ cover.style.zIndex = '2147483000';
19
+ const header = style(document.createElement('div'), {
20
+ display: 'flex',
21
+ gap: 10,
22
+ alignItems: 'center',
23
+ marginBottom: 12,
24
+ });
25
+ const title = document.createElement('span');
26
+ title.textContent = 'Play error';
27
+ Object.assign(title.style, { fontSize: '15px', fontWeight: '700', color: '#ff6b74' });
28
+ const button = document.createElement('button');
29
+ button.type = 'button';
30
+ button.textContent = 'Restart';
31
+ Object.assign(button.style, {
32
+ marginLeft: 'auto',
33
+ padding: '4px 12px',
34
+ border: '1px solid #a02828',
35
+ borderRadius: '4px',
36
+ background: '#a02828',
37
+ color: '#fff',
38
+ font: 'inherit',
39
+ cursor: 'pointer',
40
+ });
41
+ button.addEventListener('click', restart);
42
+ header.append(title, button);
43
+ const message = document.createElement('div');
44
+ message.textContent = `${error?.name ?? 'Error'}: ${error?.message ?? String(error)}`;
45
+ Object.assign(message.style, { color: '#fff', fontWeight: '600' });
46
+ cover.append(header, message);
47
+ if (typeof error?.stack === 'string') {
48
+ const stack = document.createElement('pre');
49
+ stack.textContent = error.stack;
50
+ Object.assign(stack.style, { whiteSpace: 'pre-wrap', color: '#e79aa0', fontSize: '12px' });
51
+ cover.append(stack);
52
+ }
53
+ return cover;
54
+ }
55
+
56
+ export function startPlayer({
57
+ onStage,
58
+ files,
59
+ parseJsonFile,
60
+ collectAssets,
61
+ behaviorClasses,
62
+ mountScene3D,
63
+ hudStyles,
64
+ ready,
65
+ }) {
66
+ const root = document.getElementById('root');
67
+ if (!root) throw new Error('Missing root element');
68
+ const requested = new URLSearchParams(location.search).get('scene');
69
+ const scenePath = requested && files[requested] !== undefined ? requested : 'scenes/main.scene';
70
+ const wrapper = style(document.createElement('div'), {
71
+ position: 'fixed',
72
+ inset: 0,
73
+ background: '#000',
74
+ });
75
+ const canvas = style(document.createElement('canvas'), {
76
+ width: '100%',
77
+ height: '100%',
78
+ display: 'block',
79
+ outline: 'none',
80
+ touchAction: 'none',
81
+ userSelect: 'none',
82
+ WebkitUserSelect: 'none',
83
+ WebkitTouchCallout: 'none',
84
+ });
85
+ canvas.tabIndex = 0;
86
+ const score = style(document.createElement('div'), hudStyles.score),
87
+ look = style(document.createElement('div'), hudStyles.look);
88
+ score.dataset.engineHud = 'score';
89
+ look.dataset.engineHud = 'look';
90
+ wrapper.append(canvas, score, look);
91
+ root.replaceChildren(wrapper);
92
+ let stop, overlay, sceneData, sprites;
93
+ function showError(error) {
94
+ loadingCover?.fail();
95
+ console.error(error);
96
+ overlay?.remove();
97
+ overlay = errorOverlay(error, () => {
98
+ stop?.();
99
+ stop = undefined;
100
+ start();
101
+ });
102
+ wrapper.append(overlay);
103
+ }
104
+ function start() {
105
+ overlay?.remove();
106
+ overlay = null;
107
+ try {
108
+ if (!sceneData) {
109
+ sceneData = parseJsonFile(scenePath, files[scenePath] ?? '').value;
110
+ if (!sceneData) {
111
+ wrapper.remove();
112
+ return;
113
+ }
114
+ }
115
+ if (!sprites) {
116
+ onStage?.('assets:start');
117
+ sprites = collectAssets(files).sprites;
118
+ onStage?.('assets:collected');
119
+ onStage?.assets(sprites);
120
+ }
121
+ stop = mountScene3D({
122
+ canvas,
123
+ sceneData,
124
+ sprites,
125
+ files,
126
+ behaviorClasses,
127
+ scenePath,
128
+ hudRefs: { score: { current: score }, look: { current: look } },
129
+ onStage,
130
+ onFirstFrame: ready,
131
+ onLoopError: showError,
132
+ });
133
+ } catch (error) {
134
+ showError(error);
135
+ }
136
+ }
137
+ start();
138
+ return () => {
139
+ stop?.();
140
+ wrapper.remove();
141
+ };
142
+ }
@@ -0,0 +1,47 @@
1
+ // Runtime variants replace only the official inspectors. Other imports and
2
+ // deck behaviors retain the original registry's precedence and exports.
3
+ // One brace glob limits discovery to the official kits while preserving
4
+ // Vite production expansion (separate literal dotted alias globs are empty).
5
+ const runtimeModules = import.meta.glob('/imports/castle.physics-{2d,3d}/play/behaviors/**/*.js', {
6
+ eager: true,
7
+ });
8
+ const runtime = Object.fromEntries(
9
+ Object.entries(runtimeModules).filter(
10
+ ([key]) =>
11
+ key.startsWith('/imports/castle.physics-2d/play/behaviors/') ||
12
+ key.startsWith('/imports/castle.physics-3d/play/behaviors/'),
13
+ ),
14
+ );
15
+ const ordinary = import.meta.glob(
16
+ [
17
+ '/imports/*/behaviors/**/*.jsx',
18
+ '!/imports/castle.physics-2d/behaviors/**',
19
+ '!/imports/castle.physics-3d/behaviors/**',
20
+ ],
21
+ { eager: true },
22
+ );
23
+ const imported = Object.fromEntries(
24
+ Object.entries({ ...ordinary, ...runtime })
25
+ .map(([key, value]) => [
26
+ key.replace('/play/behaviors/', '/behaviors/').replace(/\.js$/, '.jsx'),
27
+ value,
28
+ ])
29
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),
30
+ );
31
+ const modules = {
32
+ ...imported,
33
+ ...import.meta.glob('/imports/*/code/behaviors/**/*.jsx', { eager: true }),
34
+ ...import.meta.glob('/behaviors/**/*.jsx', { eager: true }),
35
+ ...import.meta.glob('/code/behaviors/**/*.jsx', { eager: true }),
36
+ };
37
+ const found = new Map();
38
+ for (const module of Object.values(modules))
39
+ for (const value of Object.values(module)) {
40
+ if (typeof value === 'function' && typeof value.behaviorName === 'string')
41
+ found.set(value.behaviorName, value);
42
+ }
43
+ export const playBehaviorClasses = [...found.values()].sort((a, b) => {
44
+ if (a.behaviorName === 'Layout') return -1;
45
+ if (b.behaviorName === 'Layout') return 1;
46
+ return a.behaviorName.localeCompare(b.behaviorName);
47
+ });
@@ -0,0 +1,37 @@
1
+ // Explicit opt-in entry. The Development-only editor route is removed from saved
2
+ // bundles; the ordinary main.jsx remains the default entry for every deck.
3
+ import './code/client/loadingEntry.js';
4
+ import './code/client/qualityEntry.js';
5
+ import { isEdit, setup, Lifecycle } from 'castle-web-sdk';
6
+ import { parseJsonFile } from '@imports/castle.physics-2d/engine/files';
7
+ import { collectAssets } from '@imports/castle.physics-2d/engine/assets';
8
+ import { initialFiles3D } from '@imports/castle.physics-3d/engine3d/initialModelFiles';
9
+ import { mountScene3D, hudStyles } from '@imports/castle.physics-3d/engine3d/playerRun';
10
+ import { setWalkGait } from '@imports/castle.physics-3d/engine3d/gait';
11
+ import '@imports/castle.physics-2d/play/behaviors/Layout.js';
12
+ import { makePlayTimings } from '@imports/castle.physics-3d/engine3d/playTimings';
13
+ import { playBehaviorClasses } from './play/registry';
14
+ import { startPlayer } from './play/player';
15
+
16
+ const config =
17
+ Object.values(import.meta.glob('/castle.json', { eager: true, import: 'default' }))[0] ?? {};
18
+ if (import.meta.env.MODE === 'development' && isEdit()) {
19
+ await import('@imports/castle.multiplayer-3d/main.jsx');
20
+ } else {
21
+ if (config.hub?.playOnlyEntry !== true)
22
+ throw new Error('The hub play entry requires castle.json hub.playOnlyEntry=true');
23
+ setWalkGait(config.gait === 'model' ? 'model' : 'fixed');
24
+ document.body.dataset.castleScreenshotTarget = 'viewport';
25
+ setup();
26
+ const onStage = makePlayTimings(config.hub.loadTimings === true);
27
+ startPlayer({
28
+ onStage,
29
+ files: initialFiles3D,
30
+ parseJsonFile,
31
+ collectAssets,
32
+ behaviorClasses: playBehaviorClasses,
33
+ mountScene3D,
34
+ hudStyles,
35
+ ready: Lifecycle.ready,
36
+ });
37
+ }