@air-jam/sdk 0.1.4 → 0.9.0

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 (348) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +627 -57
  3. package/dist/agent-tooling-BSMGBix9.d.cts +123 -0
  4. package/dist/agent-tooling-BSMGBix9.d.ts +123 -0
  5. package/dist/agent-tooling.cjs +83 -0
  6. package/dist/agent-tooling.cjs.map +1 -0
  7. package/dist/agent-tooling.d.cts +2 -0
  8. package/dist/agent-tooling.d.ts +2 -0
  9. package/dist/agent-tooling.js +17 -0
  10. package/dist/agent-tooling.js.map +1 -0
  11. package/dist/arcade/bridge/controller.cjs +749 -0
  12. package/dist/arcade/bridge/controller.cjs.map +1 -0
  13. package/dist/arcade/bridge/controller.d.cts +85 -0
  14. package/dist/arcade/bridge/controller.d.ts +85 -0
  15. package/dist/arcade/bridge/controller.js +33 -0
  16. package/dist/arcade/bridge/controller.js.map +1 -0
  17. package/dist/arcade/bridge/host.cjs +421 -0
  18. package/dist/arcade/bridge/host.cjs.map +1 -0
  19. package/dist/arcade/bridge/host.d.cts +73 -0
  20. package/dist/arcade/bridge/host.d.ts +73 -0
  21. package/dist/arcade/bridge/host.js +25 -0
  22. package/dist/arcade/bridge/host.js.map +1 -0
  23. package/dist/arcade/bridge/iframe.cjs +453 -0
  24. package/dist/arcade/bridge/iframe.cjs.map +1 -0
  25. package/dist/arcade/bridge/iframe.d.cts +80 -0
  26. package/dist/arcade/bridge/iframe.d.ts +80 -0
  27. package/dist/arcade/bridge/iframe.js +28 -0
  28. package/dist/arcade/bridge/iframe.js.map +1 -0
  29. package/dist/arcade/bridge.cjs +1067 -0
  30. package/dist/arcade/bridge.cjs.map +1 -0
  31. package/dist/arcade/bridge.d.cts +11 -0
  32. package/dist/arcade/bridge.d.ts +11 -0
  33. package/dist/arcade/bridge.js +76 -0
  34. package/dist/arcade/bridge.js.map +1 -0
  35. package/dist/arcade/host.cjs +488 -0
  36. package/dist/arcade/host.cjs.map +1 -0
  37. package/dist/arcade/host.d.cts +19 -0
  38. package/dist/arcade/host.d.ts +19 -0
  39. package/dist/arcade/host.js +13 -0
  40. package/dist/arcade/host.js.map +1 -0
  41. package/dist/arcade/surface.cjs +113 -0
  42. package/dist/arcade/surface.cjs.map +1 -0
  43. package/dist/arcade/surface.d.cts +14 -0
  44. package/dist/arcade/surface.d.ts +14 -0
  45. package/dist/arcade/surface.js +27 -0
  46. package/dist/arcade/surface.js.map +1 -0
  47. package/dist/arcade/url.cjs +363 -0
  48. package/dist/arcade/url.cjs.map +1 -0
  49. package/dist/arcade/url.d.cts +68 -0
  50. package/dist/arcade/url.d.ts +68 -0
  51. package/dist/arcade/url.js +28 -0
  52. package/dist/arcade/url.js.map +1 -0
  53. package/dist/arcade-runtime-url-BW-MUAOY.d.cts +28 -0
  54. package/dist/arcade-runtime-url-l8qj01Pg.d.ts +28 -0
  55. package/dist/arcade-surface-identity-CQxDpn_w.d.cts +16 -0
  56. package/dist/arcade-surface-identity-CQxDpn_w.d.ts +16 -0
  57. package/dist/arcade.cjs +1565 -0
  58. package/dist/arcade.cjs.map +1 -0
  59. package/dist/arcade.d.cts +18 -0
  60. package/dist/arcade.d.ts +18 -0
  61. package/dist/arcade.js +122 -0
  62. package/dist/arcade.js.map +1 -0
  63. package/dist/capabilities.cjs +39 -0
  64. package/dist/capabilities.cjs.map +1 -0
  65. package/dist/capabilities.d.cts +31 -0
  66. package/dist/capabilities.d.ts +31 -0
  67. package/dist/capabilities.js +12 -0
  68. package/dist/capabilities.js.map +1 -0
  69. package/dist/chunk-2432OL7L.js +193 -0
  70. package/dist/chunk-2432OL7L.js.map +1 -0
  71. package/dist/chunk-2J65FXEP.js +41 -0
  72. package/dist/chunk-2J65FXEP.js.map +1 -0
  73. package/dist/chunk-32NYL7XI.js +539 -0
  74. package/dist/chunk-32NYL7XI.js.map +1 -0
  75. package/dist/chunk-3USU7GY2.js +54 -0
  76. package/dist/chunk-3USU7GY2.js.map +1 -0
  77. package/dist/chunk-BE6Z4SIT.js +65 -0
  78. package/dist/chunk-BE6Z4SIT.js.map +1 -0
  79. package/dist/chunk-CQUG24WX.js +249 -0
  80. package/dist/chunk-CQUG24WX.js.map +1 -0
  81. package/dist/chunk-D3X4MN4U.js +288 -0
  82. package/dist/chunk-D3X4MN4U.js.map +1 -0
  83. package/dist/chunk-EVZJA6RN.js +140 -0
  84. package/dist/chunk-EVZJA6RN.js.map +1 -0
  85. package/dist/chunk-HFWRZVZ3.js +1438 -0
  86. package/dist/chunk-HFWRZVZ3.js.map +1 -0
  87. package/dist/chunk-IKKDONQL.js +1 -0
  88. package/dist/chunk-IKKDONQL.js.map +1 -0
  89. package/dist/chunk-JTF47B56.js +1 -0
  90. package/dist/chunk-JTF47B56.js.map +1 -0
  91. package/dist/chunk-LIXPF4P6.js +22 -0
  92. package/dist/chunk-LIXPF4P6.js.map +1 -0
  93. package/dist/chunk-MKBASO6X.js +216 -0
  94. package/dist/chunk-MKBASO6X.js.map +1 -0
  95. package/dist/chunk-MPDMJIX5.js +1 -0
  96. package/dist/chunk-MPDMJIX5.js.map +1 -0
  97. package/dist/chunk-NCL6WJCL.js +91 -0
  98. package/dist/chunk-NCL6WJCL.js.map +1 -0
  99. package/dist/chunk-NU5W6VAV.js +126 -0
  100. package/dist/chunk-NU5W6VAV.js.map +1 -0
  101. package/dist/chunk-TGRTEWYV.js +195 -0
  102. package/dist/chunk-TGRTEWYV.js.map +1 -0
  103. package/dist/chunk-VDRNNGHX.js +184 -0
  104. package/dist/chunk-VDRNNGHX.js.map +1 -0
  105. package/dist/chunk-VN5LDWVN.js +32 -0
  106. package/dist/chunk-VN5LDWVN.js.map +1 -0
  107. package/dist/chunk-W2VK36RO.js +11 -0
  108. package/dist/chunk-W2VK36RO.js.map +1 -0
  109. package/dist/chunk-X24K52DG.js +12 -0
  110. package/dist/chunk-X24K52DG.js.map +1 -0
  111. package/dist/chunk-XLUWV45V.js +25 -0
  112. package/dist/chunk-XLUWV45V.js.map +1 -0
  113. package/dist/chunk-Y4RAPKKB.js +238 -0
  114. package/dist/chunk-Y4RAPKKB.js.map +1 -0
  115. package/dist/chunk-YXHH3MQT.js +230 -0
  116. package/dist/chunk-YXHH3MQT.js.map +1 -0
  117. package/dist/chunk-ZLPL2R3R.js +183 -0
  118. package/dist/chunk-ZLPL2R3R.js.map +1 -0
  119. package/dist/chunk-ZTQ5SP4H.js +9 -0
  120. package/dist/chunk-ZTQ5SP4H.js.map +1 -0
  121. package/dist/controller-Bod8YYr1.d.cts +172 -0
  122. package/dist/controller-DxVchfiA.d.ts +172 -0
  123. package/dist/dev-log-events-CVAM29hx.d.cts +123 -0
  124. package/dist/dev-log-events-CVAM29hx.d.ts +123 -0
  125. package/dist/handshake-CC_LrK5g.d.cts +31 -0
  126. package/dist/handshake-CC_LrK5g.d.ts +31 -0
  127. package/dist/host-8hmq_Sgc.d.cts +109 -0
  128. package/dist/host-Cw-N6e-5.d.ts +109 -0
  129. package/dist/index.cjs +8507 -3523
  130. package/dist/index.cjs.map +1 -1
  131. package/dist/index.d.cts +676 -1070
  132. package/dist/index.d.ts +676 -1070
  133. package/dist/index.js +4890 -3196
  134. package/dist/index.js.map +1 -1
  135. package/dist/metadata.cjs +114 -0
  136. package/dist/metadata.cjs.map +1 -0
  137. package/dist/metadata.d.cts +95 -0
  138. package/dist/metadata.d.ts +95 -0
  139. package/dist/metadata.js +83 -0
  140. package/dist/metadata.js.map +1 -0
  141. package/dist/notices-CnGaaS8B.d.ts +38 -0
  142. package/dist/notices-NyDM5Mtz.d.cts +38 -0
  143. package/dist/platform-machine.cjs +425 -0
  144. package/dist/platform-machine.cjs.map +1 -0
  145. package/dist/platform-machine.d.cts +1183 -0
  146. package/dist/platform-machine.d.ts +1183 -0
  147. package/dist/platform-machine.js +309 -0
  148. package/dist/platform-machine.js.map +1 -0
  149. package/dist/platform-settings-cuor3i11.d.cts +48 -0
  150. package/dist/platform-settings-cuor3i11.d.ts +48 -0
  151. package/dist/prefabs.cjs +36 -0
  152. package/dist/prefabs.cjs.map +1 -0
  153. package/dist/prefabs.d.cts +49 -0
  154. package/dist/prefabs.d.ts +49 -0
  155. package/dist/prefabs.js +8 -0
  156. package/dist/prefabs.js.map +1 -0
  157. package/dist/preview.cjs +2609 -0
  158. package/dist/preview.cjs.map +1 -0
  159. package/dist/preview.d.cts +155 -0
  160. package/dist/preview.d.ts +155 -0
  161. package/dist/preview.js +1671 -0
  162. package/dist/preview.js.map +1 -0
  163. package/dist/protocol.cjs +621 -54
  164. package/dist/protocol.cjs.map +1 -1
  165. package/dist/protocol.d.cts +76 -240
  166. package/dist/protocol.d.ts +76 -240
  167. package/dist/protocol.js +100 -2
  168. package/dist/protocol.js.map +1 -1
  169. package/dist/realtime-client-Cu8yVJFw.d.cts +15 -0
  170. package/dist/realtime-client-Cu8yVJFw.d.ts +15 -0
  171. package/dist/release.cjs +143 -0
  172. package/dist/release.cjs.map +1 -0
  173. package/dist/release.d.cts +64 -0
  174. package/dist/release.d.ts +64 -0
  175. package/dist/release.js +43 -0
  176. package/dist/release.js.map +1 -0
  177. package/dist/standard-match-phase-BucA5dYo.d.ts +44 -0
  178. package/dist/standard-match-phase-U2ra8J-0.d.cts +44 -0
  179. package/dist/sync-B6QsNrXz.d.cts +125 -0
  180. package/dist/sync-B6QsNrXz.d.ts +125 -0
  181. package/dist/ui.cjs +2827 -0
  182. package/dist/ui.cjs.map +1 -0
  183. package/dist/ui.d.cts +320 -0
  184. package/dist/ui.d.ts +320 -0
  185. package/dist/ui.js +1718 -0
  186. package/dist/ui.js.map +1 -0
  187. package/dist/url-policy-C89zxgw9.d.cts +9 -0
  188. package/dist/url-policy-C89zxgw9.d.ts +9 -0
  189. package/package.json +149 -11
  190. package/src/agent/agent-action.ts +304 -0
  191. package/src/agent/agent-contract.ts +180 -0
  192. package/src/agent-tooling.ts +20 -0
  193. package/src/arcade/bridge/controller.ts +15 -0
  194. package/src/arcade/bridge/host.ts +12 -0
  195. package/src/arcade/bridge/iframe.ts +61 -0
  196. package/src/arcade/bridge.ts +3 -0
  197. package/src/arcade/host.ts +1 -0
  198. package/src/arcade/surface.ts +4 -0
  199. package/src/arcade/url.ts +60 -0
  200. package/src/arcade.ts +4 -0
  201. package/src/audio/audio-manager.ts +162 -171
  202. package/src/audio/hooks.tsx +218 -97
  203. package/src/audio/index.ts +1 -1
  204. package/src/audio/music.tsx +139 -0
  205. package/src/capabilities/manifest.ts +71 -0
  206. package/src/capabilities.ts +12 -0
  207. package/src/components/connection-status-pill.tsx +55 -0
  208. package/src/components/controller-player-name-field.tsx +119 -0
  209. package/src/components/controller-primary-action.tsx +58 -0
  210. package/src/components/host-mute-button.tsx +49 -0
  211. package/src/components/join-qr-overlay.tsx +133 -0
  212. package/src/components/join-url-action-buttons.tsx +95 -0
  213. package/src/components/join-url-controls.tsx +58 -0
  214. package/src/components/join-url-field.tsx +52 -0
  215. package/src/components/lifecycle-action-group.tsx +129 -0
  216. package/src/components/player-avatar-strip.tsx +65 -0
  217. package/src/components/player-avatar.tsx +42 -13
  218. package/src/components/room-qr-code.tsx +125 -0
  219. package/src/components/runtime-shell-header.tsx +37 -0
  220. package/src/components/shell-classes.ts +19 -0
  221. package/src/components/surface-orientation-layout.ts +60 -0
  222. package/src/components/surface-viewport-layout.ts +268 -0
  223. package/src/components/surface-viewport.tsx +314 -0
  224. package/src/components/ui/button.tsx +4 -6
  225. package/src/components/ui/slider.tsx +1 -1
  226. package/src/components/volume-controls.tsx +65 -6
  227. package/src/context/air-jam-context.tsx +209 -161
  228. package/src/context/index.ts +2 -2
  229. package/src/context/session-providers.tsx +77 -0
  230. package/src/context/session-scope.ts +64 -0
  231. package/src/context/socket-manager.ts +6 -24
  232. package/src/contracts/v2/bridge.ts +261 -0
  233. package/src/contracts/v2/handshake.ts +40 -0
  234. package/src/contracts/v2/index.ts +2 -0
  235. package/src/dev/browser-log-sink.ts +912 -0
  236. package/src/diagnostics.ts +128 -0
  237. package/src/events.ts +7 -34
  238. package/src/hooks/internal/use-controller-runtime-api.ts +875 -0
  239. package/src/hooks/internal/use-host-runtime-api.ts +1051 -0
  240. package/src/hooks/internal/use-runtime-control-contract.ts +15 -0
  241. package/src/hooks/internal/use-runtime-inspection-contract.ts +16 -0
  242. package/src/hooks/internal/use-runtime-observability-contract.ts +24 -0
  243. package/src/hooks/use-air-jam-controller.ts +155 -475
  244. package/src/hooks/use-air-jam-host.ts +156 -485
  245. package/src/hooks/use-connection-status.ts +8 -0
  246. package/src/hooks/use-controller-lifecycle-intents.ts +27 -0
  247. package/src/hooks/use-controller-lifecycle-permissions.ts +36 -0
  248. package/src/hooks/use-controller-shell-status.ts +40 -0
  249. package/src/hooks/use-controller-tick.ts +65 -0
  250. package/src/hooks/use-controller-toasts.ts +116 -0
  251. package/src/hooks/use-get-input.ts +8 -5
  252. package/src/hooks/use-host-arcade-restore.ts +30 -0
  253. package/src/hooks/use-host-join-controls.ts +152 -0
  254. package/src/hooks/use-host-tick.ts +171 -0
  255. package/src/hooks/use-input-writer.ts +83 -0
  256. package/src/hooks/use-lifecycle-action-group-model.ts +98 -0
  257. package/src/hooks/use-players.ts +12 -0
  258. package/src/hooks/use-room.ts +22 -0
  259. package/src/hooks/use-send-signal.ts +6 -2
  260. package/src/index.ts +205 -31
  261. package/src/internal/input-manager.ts +195 -215
  262. package/src/lifecycle/index.ts +9 -0
  263. package/src/lifecycle/standard-match-phase.ts +32 -0
  264. package/src/metadata/manifest.ts +152 -0
  265. package/src/metadata.ts +12 -0
  266. package/src/platform-machine.ts +475 -0
  267. package/src/prefabs/types.ts +82 -0
  268. package/src/prefabs.ts +12 -0
  269. package/src/preview/host-workspace.tsx +59 -0
  270. package/src/preview/identity.ts +66 -0
  271. package/src/preview/layout.ts +223 -0
  272. package/src/preview/manager.ts +577 -0
  273. package/src/preview/messages.ts +26 -0
  274. package/src/preview/ownership.ts +81 -0
  275. package/src/preview/url.ts +117 -0
  276. package/src/preview/window.tsx +490 -0
  277. package/src/preview/workspace.tsx +678 -0
  278. package/src/preview.ts +42 -0
  279. package/src/protocol/arcade-platform-actions.ts +29 -0
  280. package/src/protocol/controller.ts +187 -0
  281. package/src/protocol/core.ts +23 -0
  282. package/src/protocol/dev-log-events.ts +222 -0
  283. package/src/protocol/errors.ts +21 -0
  284. package/src/protocol/host-grant.ts +185 -0
  285. package/src/protocol/host.ts +138 -0
  286. package/src/protocol/notices.ts +43 -0
  287. package/src/protocol/signals.ts +38 -0
  288. package/src/protocol/socket-events.ts +154 -0
  289. package/src/protocol/sync.ts +121 -0
  290. package/src/protocol/url-policy.ts +63 -0
  291. package/src/protocol.ts +12 -386
  292. package/src/qrcode.d.ts +16 -0
  293. package/src/release.ts +99 -0
  294. package/src/runtime/air-jam-config.ts +287 -0
  295. package/src/runtime/air-jam-error-boundary.tsx +672 -0
  296. package/src/runtime/arcade-bridge-request-surface.ts +15 -0
  297. package/src/runtime/arcade-runtime-url.ts +95 -0
  298. package/src/runtime/arcade-surface-identity.ts +16 -0
  299. package/src/runtime/contracts/control.ts +68 -0
  300. package/src/runtime/contracts/inspection.ts +165 -0
  301. package/src/runtime/contracts/observability.ts +94 -0
  302. package/src/runtime/controller-bridge.ts +451 -0
  303. package/src/runtime/controller-identity.ts +132 -0
  304. package/src/runtime/controller-presentation.ts +24 -0
  305. package/src/runtime/controller-realtime-client.ts +591 -0
  306. package/src/runtime/create-air-jam-app.tsx +260 -0
  307. package/src/runtime/dev-runtime-events.ts +36 -0
  308. package/src/runtime/embedded-runtime-adapters.ts +68 -0
  309. package/src/runtime/host-bridge.ts +388 -0
  310. package/src/runtime/host-realtime-client.ts +550 -0
  311. package/src/runtime/iframe-bridge.ts +135 -0
  312. package/src/runtime/realtime-client.ts +20 -0
  313. package/src/runtime/router-basename.ts +25 -0
  314. package/src/runtime/runtime-owner-contexts.tsx +4 -0
  315. package/src/runtime/runtime-session-params.ts +169 -0
  316. package/src/runtime/sdk-version.ts +6 -0
  317. package/src/runtime/session-runtimes.tsx +188 -0
  318. package/src/runtime/validate-arcade-bridge-attach.ts +14 -0
  319. package/src/runtime-control.ts +10 -0
  320. package/src/runtime-inspection.ts +14 -0
  321. package/src/runtime-observability.ts +9 -0
  322. package/src/settings/platform-settings-bridge.ts +336 -0
  323. package/src/settings/platform-settings-runtime.tsx +387 -0
  324. package/src/settings/platform-settings.ts +288 -0
  325. package/src/state/connection-store.ts +80 -12
  326. package/src/store/air-jam-store-domain-constants.ts +4 -0
  327. package/src/store/create-air-jam-store.ts +1094 -227
  328. package/src/styles.css +4 -38
  329. package/src/ui.ts +29 -0
  330. package/src/utils/is-rpc-serializable.ts +56 -0
  331. package/src/utils/player-avatar-url.ts +48 -0
  332. package/src/utils/url-builder.ts +7 -0
  333. package/dist/.tsbuildinfo +0 -1
  334. package/dist/chunk-B5DURUWT.js +0 -80
  335. package/dist/chunk-B5DURUWT.js.map +0 -1
  336. package/src/AirJamClient.ts +0 -224
  337. package/src/audio/volume-store.ts +0 -124
  338. package/src/components/controller-shell.tsx +0 -346
  339. package/src/components/host-shell.tsx +0 -520
  340. package/src/components/qr-scanner-dialog.tsx +0 -373
  341. package/src/components/ui/alert.tsx +0 -66
  342. package/src/components/ui/avatar.tsx +0 -46
  343. package/src/components/ui/badge.tsx +0 -47
  344. package/src/components/ui/card.tsx +0 -92
  345. package/src/components/ui/dialog.tsx +0 -122
  346. package/src/components/ui/tabs.tsx +0 -64
  347. package/src/hooks/use-air-jam-shell.ts +0 -379
  348. package/src/hooks/use-fullscreen.ts +0 -108
package/dist/index.d.cts CHANGED
@@ -1,479 +1,21 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React$1 from 'react';
3
- import { ReactNode, JSX } from 'react';
2
+ import { ReactNode, JSX, Component, ErrorInfo, MutableRefObject } from 'react';
3
+ export { d as DEFAULT_PLATFORM_SETTINGS, D as DEFAULT_ROOM_PLATFORM_SETTINGS, i as PartialRoomPlatformSettingsPatch, e as PlatformAccessibilitySettings, b as PlatformAudioSettings, f as PlatformFeedbackSettings, h as PlatformPreviewControllerSettings, j as PlatformSettings, P as PlatformSettingsPersistence, a as PlatformSettingsSnapshot, R as RoomPlatformSettingsSnapshot, g as getEffectiveAudioVolume, m as mergeRoomPlatformSettingsSnapshot, t as toRoomPlatformSettingsSnapshot } from './platform-settings-cuor3i11.cjs';
4
+ export { P as PlatformAudioSettingsApi, a as PlatformSettingsBoundary, e as PlatformSettingsBoundaryProps, f as PlatformSettingsOwnerApi, b as PlatformSettingsRuntime, g as PlatformSettingsRuntimeProps, S as ShellMatchPhase, k as StandardMatchPhase, i as isActiveMatchPhase, h as isEndedMatchPhase, j as isStandardMatchPhase, s as standardMatchPhases, t as toShellMatchPhase, u as useInheritedPlatformSettings, c as usePlatformAudioSettings, d as usePlatformSettings } from './standard-match-phase-U2ra8J-0.cjs';
5
+ import { R as RoomCode, H as ConnectionStatus, J as RuntimeState, o as ControllerOrientation, u as ControllerRoomSettingsState, z as PlayerProfilePatch, f as ControllerUpdatePlayerProfileAck, h as ControllerLeaveAck, P as PlayerProfile, t as ControllerStatePayload, I as RunMode, m as ControllerInputPayload } from './controller-Bod8YYr1.cjs';
6
+ import { A as AirJamRealtimeClient } from './realtime-client-Cu8yVJFw.cjs';
4
7
  import { z } from 'zod';
5
- import { ControllerInputEvent, ConnectionRole, ConnectionStatus, RunMode, GameState, PlayerProfile, ServerToClientEvents, ClientToServerEvents, ControllerStatePayload, RoomCode, ControllerInputPayload, HapticSignalPayload, ToastSignalPayload } from './protocol.cjs';
6
- export { AIRJAM_PROXY_PREFIX, AirJamActionRpcPayload, AirJamProxyMessage, AirJamStateSyncPayload, ClientLoadUiPayload, ControllerActionRpcPayload, ControllerJoinAck, ControllerJoinPayload, ControllerJoinedNotice, ControllerLeavePayload, ControllerLeftNotice, ControllerStateMessage, ControllerSystemPayload, ControllerWelcomePayload, ErrorCode, HostCreateRoomPayload, HostJoinAsChildPayload, HostLeftNotice, HostReconnectPayload, HostRegisterSystemPayload, HostRegistrationAck, HostRegistrationPayload, HostStateSyncPayload, InterServerEvents, PlaySoundEventPayload, PlaySoundPayload, ProxyInputMessage, ProxyMessageBase, ProxyReadyMessage, ProxyStateMessage, RoomReadyNotice, ServerErrorPayload, SignalPayload, SignalType, SocketData, SystemLaunchGameAck, SystemLaunchGamePayload, controllerInputSchema, controllerJoinSchema, controllerLeaveSchema, controllerStateSchema, controllerSystemSchema, hostCreateRoomSchema, hostJoinAsChildSchema, hostReconnectSchema, hostRegisterSystemSchema, hostRegistrationSchema, roomCodeSchema, systemLaunchGameSchema } from './protocol.cjs';
7
- import * as zustand from 'zustand';
8
- import { StoreApi, StateCreator } from 'zustand';
9
- import { Socket } from 'socket.io-client';
10
- import * as class_variance_authority_types from 'class-variance-authority/types';
11
- import { VariantProps } from 'class-variance-authority';
12
- import * as SliderPrimitive from '@radix-ui/react-slider';
13
-
14
- /**
15
- * @module InputManager
16
- * @description Internal class for managing controller input with validation and latching.
17
- *
18
- * The InputManager is created internally by the AirJamProvider when input configuration
19
- * is provided. It handles:
20
- *
21
- * 1. **Input Buffering** - Stores the latest input for each controller
22
- * 2. **Validation** - Validates input against a Zod schema (optional)
23
- * 3. **Latching** - Ensures rapid button presses and stick flicks are never missed
24
- *
25
- * ## What is Latching?
26
- *
27
- * Game loops typically run at 60fps, but network events may arrive between frames.
28
- * Without latching, a quick button tap might be missed if it starts and ends between
29
- * two consecutive `getInput()` calls.
30
- *
31
- * **Latching solves this by:**
32
- * - Boolean fields: Keeping `true` values until consumed
33
- * - Vector fields: Keeping non-zero values for one frame after release
34
- *
35
- * ## Example: Without Latching (Bug)
36
- * ```
37
- * Frame 1: getInput() → action: false
38
- * [Network: action: true arrives, then action: false arrives]
39
- * Frame 2: getInput() → action: false ← Tap missed!
40
- * ```
41
- *
42
- * ## Example: With Latching (Fixed)
43
- * ```
44
- * Frame 1: getInput() → action: false
45
- * [Network: action: true arrives, then action: false arrives]
46
- * Frame 2: getInput() → action: true ← Tap captured!
47
- * Frame 3: getInput() → action: false ← Consumed, resets
48
- * ```
49
- *
50
- * @internal This class is not exported publicly. Use hooks to access input.
51
- */
52
-
53
- /**
54
- * Configuration for input handling with optional validation and latching.
55
- *
56
- * Provided to `AirJamProvider` to enable typed, validated, and latched input.
57
- *
58
- * @template TSchema - Zod schema type for input validation
59
- *
60
- * @example Basic schema validation
61
- * ```ts
62
- * const config: InputConfig = {
63
- * schema: z.object({
64
- * vector: z.object({ x: z.number(), y: z.number() }),
65
- * action: z.boolean(),
66
- * }),
67
- * };
68
- * ```
69
- *
70
- * @example With latching for button and stick
71
- * ```ts
72
- * const config: InputConfig = {
73
- * schema: gameInputSchema,
74
- * latch: {
75
- * booleanFields: ["action", "ability", "jump"],
76
- * vectorFields: ["vector", "aim"],
77
- * },
78
- * };
79
- * ```
80
- */
81
- interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
82
- /**
83
- * Zod schema for input validation and type inference.
84
- *
85
- * When provided:
86
- * - Incoming input is validated against the schema
87
- * - Invalid input returns `undefined` (with console warning)
88
- * - Return type is inferred from the schema
89
- *
90
- * @example
91
- * ```ts
92
- * schema: z.object({
93
- * vector: z.object({ x: z.number(), y: z.number() }),
94
- * action: z.boolean(),
95
- * ability: z.boolean(),
96
- * timestamp: z.number(),
97
- * })
98
- * ```
99
- */
100
- schema?: TSchema;
101
- /**
102
- * Latching configuration to ensure rapid taps and flicks are never missed.
103
- *
104
- * Latching "holds" boolean true values and non-zero vectors until the next
105
- * `getInput()` call, preventing missed inputs between game frames.
106
- */
107
- latch?: {
108
- /**
109
- * Boolean field names that should be latched.
110
- *
111
- * When a boolean field is latched:
112
- * - If it becomes `true`, it stays `true` until consumed by `getInput()`
113
- * - After consumption, it resets to the actual current value
114
- *
115
- * Use for: buttons, triggers, action inputs
116
- *
117
- * @example ["action", "ability", "jump", "fire"]
118
- */
119
- booleanFields?: string[];
120
- /**
121
- * Vector field names that should be latched.
122
- *
123
- * When a vector field is latched:
124
- * - Non-zero vectors are kept for one frame after returning to zero
125
- * - Ensures quick stick flicks register in the game loop
126
- *
127
- * Use for: joysticks, d-pads, directional inputs
128
- *
129
- * @example ["vector", "movement", "aim"]
130
- */
131
- vectorFields?: string[];
132
- };
133
- }
134
- /**
135
- * Internal class that manages input buffering, validation, and latching.
136
- *
137
- * Created automatically by `AirJamProvider` when input configuration is provided.
138
- * Access input via `useGetInput()` or `useAirJamHost().getInput()`.
139
- *
140
- * @template TSchema - Zod schema type for input validation
141
- *
142
- * @internal Not exported publicly. Use hooks to access input.
143
- *
144
- * @example How it's used internally
145
- * ```ts
146
- * // In AirJamProvider
147
- * const inputManager = new InputManager({
148
- * schema: gameInputSchema,
149
- * latch: { booleanFields: ["action"] },
150
- * });
151
- *
152
- * // In useAirJamHost (socket handler)
153
- * socket.on("server:input", (payload) => {
154
- * inputManager.handleInput(payload);
155
- * });
156
- *
157
- * // In game loop (via useGetInput)
158
- * const input = inputManager.getInput(playerId);
159
- * ```
160
- */
161
- declare class InputManager<TSchema extends z.ZodSchema = z.ZodSchema> {
162
- private inputBuffer;
163
- private latchState;
164
- private config;
165
- constructor(config?: InputConfig<TSchema>);
166
- /**
167
- * Handles incoming input events from the socket.
168
- * Should be called when 'server:input' event is received.
169
- */
170
- handleInput(payload: ControllerInputEvent): void;
171
- /**
172
- * Gets input for a specific controller.
173
- * Returns validated and typed input if schema is provided, otherwise raw Record.
174
- * If latching is configured, applies latching logic.
175
- */
176
- getInput(controllerId: string): z.infer<TSchema> | undefined;
177
- /**
178
- * Clears input state for a controller (e.g., when player leaves).
179
- */
180
- clearInput(controllerId: string): void;
181
- /**
182
- * Internal method to apply latching logic.
183
- */
184
- private getLatched;
185
- }
186
-
187
- interface AirJamStore {
188
- role: ConnectionRole | null;
189
- roomId: string | null;
190
- controllerId: string | null;
191
- connectionStatus: ConnectionStatus;
192
- mode: RunMode;
193
- gameState: GameState;
194
- stateMessage?: string;
195
- players: PlayerProfile[];
196
- lastError?: string;
197
- registeredRoomId: string | null;
198
- setRole: (role: ConnectionRole | null) => void;
199
- setRoomId: (roomId: string | null) => void;
200
- setControllerId: (controllerId: string | null) => void;
201
- setStatus: (status: ConnectionStatus) => void;
202
- setMode: (mode: RunMode) => void;
203
- setGameState: (state: GameState) => void;
204
- setStateMessage: (message?: string) => void;
205
- toggleGameState: () => void;
206
- setError: (message?: string) => void;
207
- upsertPlayer: (player: PlayerProfile) => void;
208
- removePlayer: (playerId: string) => void;
209
- resetPlayers: () => void;
210
- resetGameState: () => void;
211
- setRegisteredRoomId: (roomId: string | null) => void;
212
- }
213
- /**
214
- * Factory function to create a new AirJamStore instance.
215
- * Each AirJamProvider creates its own store for multi-instance support.
216
- */
217
- declare const createAirJamStore$1: () => StoreApi<AirJamStore>;
218
-
219
- type AirJamSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
220
- /**
221
- * Manages socket connections per role within a provider instance.
222
- * Unlike the global singleton, each SocketManager is scoped to its provider.
223
- */
224
- declare class SocketManager {
225
- private sockets;
226
- private serverUrl;
227
- constructor(serverUrl?: string);
228
- /**
229
- * Get or create a socket for the specified role.
230
- * Sockets are lazily created and cached per role.
231
- */
232
- getSocket(role: ConnectionRole): AirJamSocket;
233
- /**
234
- * Disconnect a socket by role.
235
- * NOTE: We intentionally do NOT delete the socket from cache.
236
- * This ensures all hooks using getSocket() get the same instance,
237
- * even during React Strict Mode remounts. The socket can be reconnected
238
- * by calling socket.connect() again.
239
- */
240
- disconnect(role: ConnectionRole): void;
241
- /**
242
- * Disconnect all sockets managed by this instance
243
- */
244
- disconnectAll(): void;
245
- /**
246
- * Get the resolved server URL
247
- */
248
- getServerUrl(): string;
249
- /**
250
- * Resolve server URL with fallbacks
251
- */
252
- private resolveServerUrl;
253
- private normalizeOrigin;
254
- }
255
-
256
- /**
257
- * Resolved configuration for the AirJam SDK.
258
- * Created from AirJamProviderProps with environment variable fallbacks applied.
259
- */
260
- interface AirJamConfig {
261
- /** WebSocket server URL. Falls back to env vars or window location */
262
- serverUrl?: string;
263
- /** API key for production authentication */
264
- apiKey?: string;
265
- /** Maximum players allowed in a room */
266
- maxPlayers: number;
267
- /** Public host for controller URLs (optional) */
268
- publicHost?: string;
269
- }
270
- /**
271
- * Props for the AirJamProvider component.
272
- *
273
- * @template TSchema - Zod schema type for input validation (inferred from input.schema)
274
- *
275
- * @example Minimal configuration (uses environment variables)
276
- * ```tsx
277
- * <AirJamProvider>
278
- * <App />
279
- * </AirJamProvider>
280
- * ```
281
- *
282
- * @example Full configuration
283
- * ```tsx
284
- * <AirJamProvider
285
- * serverUrl="wss://your-server.com"
286
- * apiKey="your-api-key"
287
- * maxPlayers={4}
288
- * input={{
289
- * schema: myInputSchema,
290
- * latch: { booleanFields: ["fire"], vectorFields: ["move"] },
291
- * }}
292
- * >
293
- * <App />
294
- * </AirJamProvider>
295
- * ```
296
- */
297
- interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
298
- /** React children to render within the provider */
299
- children: ReactNode;
300
- /**
301
- * WebSocket server URL for AirJam connections.
302
- * Falls back to VITE_AIR_JAM_SERVER_URL or NEXT_PUBLIC_AIR_JAM_SERVER_URL environment variables.
303
- */
304
- serverUrl?: string;
305
- /**
306
- * API key for production authentication.
307
- * Falls back to VITE_AIR_JAM_API_KEY or NEXT_PUBLIC_AIR_JAM_API_KEY environment variables.
308
- */
309
- apiKey?: string;
310
- /**
311
- * Maximum number of players allowed in a room.
312
- * @default 8
313
- */
314
- maxPlayers?: number;
315
- /**
316
- * Public hostname for controller URLs.
317
- * Useful when your app is behind a proxy or has a different public URL.
318
- */
319
- publicHost?: string;
320
- /**
321
- * Input handling configuration including Zod schema validation and latching.
322
- * When provided, enables typed input with automatic validation and latch support.
323
- *
324
- * @example
325
- * ```ts
326
- * input={{
327
- * schema: z.object({
328
- * vector: z.object({ x: z.number(), y: z.number() }),
329
- * action: z.boolean(),
330
- * ability: z.boolean(),
331
- * }),
332
- * latch: {
333
- * booleanFields: ["action", "ability"], // Latch button presses
334
- * vectorFields: ["vector"], // Latch stick flicks
335
- * },
336
- * }}
337
- * ```
338
- */
339
- input?: InputConfig<TSchema>;
340
- }
341
- interface AirJamContextValue {
342
- /** Resolved configuration with env fallbacks */
343
- config: AirJamConfig;
344
- /** Context-bound Zustand store */
345
- store: ReturnType<typeof createAirJamStore$1>;
346
- /** Socket manager for this provider instance */
347
- socketManager: SocketManager;
348
- /** Get socket for a specific role */
349
- getSocket: (role: ConnectionRole) => AirJamSocket;
350
- /** Disconnect socket for a specific role */
351
- disconnectSocket: (role: ConnectionRole) => void;
352
- /** InputManager instance (created from input config if provided) */
353
- inputManager: InputManager | null;
354
- }
355
- declare const AirJamContext: React$1.Context<AirJamContextValue | null>;
356
- /**
357
- * Root provider component for the AirJam SDK.
358
- *
359
- * Wrap your application (or game component tree) with this provider to enable
360
- * AirJam functionality. The provider manages WebSocket connections, global state,
361
- * and input processing.
362
- *
363
- * **Key responsibilities:**
364
- * - Creates and manages WebSocket connections to the AirJam server
365
- * - Provides a Zustand store for connection state (players, game state, etc.)
366
- * - Creates an InputManager for typed input validation and latching
367
- * - Resolves configuration from props and environment variables
368
- *
369
- * @template TSchema - Zod schema for input validation (inferred from props)
370
- *
371
- * @example Basic usage
372
- * ```tsx
373
- * import { AirJamProvider } from "@air-jam/sdk";
374
- *
375
- * export const App = () => (
376
- * <AirJamProvider>
377
- * <Routes>
378
- * <Route path="/" element={<HostView />} />
379
- * <Route path="/controller" element={<ControllerView />} />
380
- * </Routes>
381
- * </AirJamProvider>
382
- * );
383
- * ```
384
- *
385
- * @example With typed input and latching
386
- * ```tsx
387
- * import { AirJamProvider } from "@air-jam/sdk";
388
- * import { z } from "zod";
389
- *
390
- * const gameInputSchema = z.object({
391
- * vector: z.object({ x: z.number(), y: z.number() }),
392
- * action: z.boolean(),
393
- * ability: z.boolean(),
394
- * timestamp: z.number(),
395
- * });
396
- *
397
- * export const App = () => (
398
- * <AirJamProvider
399
- * input={{
400
- * schema: gameInputSchema,
401
- * latch: {
402
- * booleanFields: ["action", "ability"],
403
- * vectorFields: ["vector"],
404
- * },
405
- * }}
406
- * >
407
- * <GameRoutes />
408
- * </AirJamProvider>
409
- * );
410
- * ```
411
- */
412
- declare const AirJamProvider: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, serverUrl, apiKey, maxPlayers, publicHost, input, }: AirJamProviderProps<TSchema>) => react_jsx_runtime.JSX.Element;
413
- /**
414
- * Access the raw AirJam context value.
415
- *
416
- * This is a low-level hook that provides direct access to the context.
417
- * Most applications should use the higher-level hooks instead:
418
- * - `useAirJamHost()` - For host/game functionality
419
- * - `useAirJamController()` - For controller functionality
420
- * - `useGetInput()` - For input access without re-renders
421
- * - `useSendSignal()` - For sending signals without re-renders
422
- *
423
- * @throws Error if used outside of an AirJamProvider
424
- *
425
- * @example
426
- * ```tsx
427
- * const { config, store, inputManager } = useAirJamContext();
428
- * ```
429
- */
430
- declare const useAirJamContext: () => AirJamContextValue;
431
- /**
432
- * Access the resolved AirJam configuration.
433
- *
434
- * Returns the configuration with all environment variable fallbacks resolved.
435
- *
436
- * @example
437
- * ```tsx
438
- * const config = useAirJamConfig();
439
- * console.log(config.serverUrl, config.maxPlayers);
440
- * ```
441
- */
442
- declare const useAirJamConfig: () => AirJamConfig;
443
- /**
444
- * Access AirJam store state with a selector.
445
- *
446
- * Uses Zustand's useShallow for optimal re-render behavior.
447
- * Only re-renders when the selected values actually change.
448
- *
449
- * @param selector - Function to select state from the store
450
- * @returns The selected state value
451
- *
452
- * @example
453
- * ```tsx
454
- * const { players, gameState } = useAirJamState((state) => ({
455
- * players: state.players,
456
- * gameState: state.gameState,
457
- * }));
458
- * ```
459
- */
460
- declare const useAirJamState: <T>(selector: (state: AirJamStore) => T) => T;
461
- /**
462
- * Get a socket instance for the specified role.
463
- *
464
- * Returns the same socket instance across renders (stable reference).
465
- * The socket is managed by the SocketManager and shared across hooks.
466
- *
467
- * @param role - Either "host" or "controller"
468
- * @returns The Socket.IO socket instance
469
- *
470
- * @example
471
- * ```tsx
472
- * const socket = useAirJamSocket("host");
473
- * socket.emit("custom:event", { data: "value" });
474
- * ```
475
- */
476
- declare const useAirJamSocket: (role: ConnectionRole) => AirJamSocket;
8
+ import { h as HostControllerActionAck, c as HostRegistrationAck, n as HostSessionKind } from './host-8hmq_Sgc.cjs';
9
+ import { C as ControllerPresenceNotice } from './notices-NyDM5Mtz.cjs';
10
+ import { h as HapticSignalPayload, T as ToastSignalPayload, i as AirJamActionActorRole, A as AirJamActionInvocationResult, k as AirJamActionPayload } from './sync-B6QsNrXz.cjs';
11
+ export { m as AirJamActionAccepted, n as AirJamActionRejected, S as SignalPayload, g as SignalType } from './sync-B6QsNrXz.cjs';
12
+ import { RuntimeTopologyInput, ResolvedAirJamRuntimeTopology, SurfaceRole } from '@air-jam/runtime-topology';
13
+ import { A as AirJamAgentContract } from './agent-tooling-BSMGBix9.cjs';
14
+ export { j as AirJamAgentActionContract, b as AirJamAgentActionCustomOptions, c as AirJamAgentActionOptions, d as AirJamAgentActionPayloadKind, e as AirJamAgentActionPayloadMetadata, k as AirJamAgentActionTarget, l as AirJamAgentContractActionOptions, m as AirJamAgentContractPayloadKind, n as AirJamAgentContractPayloadMetadata, o as AirJamAgentJsonObject, p as AirJamAgentResolvedActionContract, q as AirJamAgentSnapshotContext, r as AirJamAgentStoreDeclaration, s as AirJamAgentStoreDeclarations, t as AirJamAgentStores, u as AnyAirJamAgentContract, I as InferAirJamAgentActionInputPayload, v as InferAirJamAgentStores, f as agentAction, a as agentActionInput, g as agentStore, h as defineAirJamAgentContract, i as defineAirJamAgentStores } from './agent-tooling-BSMGBix9.cjs';
15
+ import { AirJamGameCapabilityManifest } from './capabilities.cjs';
16
+ import { AirJamGameMetadata } from './metadata.cjs';
17
+ import { StateCreator } from 'zustand';
18
+ import { StoreApi } from 'zustand/vanilla';
477
19
 
478
20
  type SoundCategory = "music" | "sfx";
479
21
  interface SoundConfig {
@@ -487,13 +29,6 @@ interface SoundConfig {
487
29
  category?: SoundCategory;
488
30
  }
489
31
  type SoundManifest = Record<string, SoundConfig>;
490
- /**
491
- * Auto-detect sound category based on config heuristics
492
- * - If explicitly set, use it
493
- * - If loop=true and html5=true, likely music
494
- * - Otherwise, default to sfx
495
- */
496
- declare function detectSoundCategory(config: SoundConfig): SoundCategory;
497
32
  interface PlayOptions {
498
33
  remote?: boolean;
499
34
  target?: string;
@@ -501,410 +36,78 @@ interface PlayOptions {
501
36
  loop?: boolean;
502
37
  sprite?: string;
503
38
  pitch?: number;
39
+ fadeInMs?: number;
40
+ onEnd?: (soundId: number) => void;
504
41
  }
505
- declare class AudioManager<T extends string = string> {
506
- private sounds;
507
- private categories;
508
- private manifest;
509
- private _muted;
510
- private socket;
511
- private roomId;
512
- private activeSoundIds;
513
- private volumeUnsubscribe;
514
- constructor(manifest?: SoundManifest);
515
- /**
516
- * Cleanup method to unsubscribe from volume changes
517
- */
518
- destroy(): void;
519
- /**
520
- * Get the category for a sound (with auto-detection)
521
- */
522
- getCategory(soundId: string): SoundCategory;
523
- setSocket(socket: Socket<ServerToClientEvents, ClientToServerEvents> | null, roomId?: string): void;
524
- /**
525
- * Resume audio context if suspended. This is automatically called by play(),
526
- * so you typically don't need to call this manually.
527
- *
528
- * Note: Due to browser autoplay policies, audio context starts suspended
529
- * and can only be resumed in response to a user gesture. The useAudio hook
530
- * handles this automatically, and play() also calls init() internally.
531
- */
532
- init(): void;
533
- /**
534
- * Check if audio context is ready to play sounds
535
- */
42
+ interface AudioHandle<T extends string = string> {
43
+ init(): Promise<boolean>;
536
44
  isReady(): boolean;
537
- load(manifest: SoundManifest): void;
538
45
  play(id: T, options?: PlayOptions): number | null;
539
- private playLocal;
540
- private playRemote;
541
- private isHost;
542
- /**
543
- * Play a sound at a specific 3D position
544
- */
545
- playSpatial(id: T, pos: {
546
- x: number;
547
- y: number;
548
- z: number;
549
- }, sprite?: string): number | null;
550
46
  stop(id?: T, soundId?: number): void;
551
- volume(vol: number, id?: T, soundId?: number): void;
552
- mute(muted: boolean, id?: T, soundId?: number): void;
553
- isMuted(): boolean;
554
- /**
555
- * Update the listener position for spatial audio
556
- */
557
- setListenerPos(x: number, y: number, z: number): void;
558
- /**
559
- * Update the listener orientation for spatial audio
560
- */
561
- setListenerOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): void;
562
- }
563
- declare const createAudioManager: <T extends string = string>(manifest?: SoundManifest) => AudioManager<T>;
564
-
565
- /**
566
- * Hook to use audio with a sound manifest
567
- * Creates a singleton AudioManager for the manifest and handles socket injection
568
- * @param manifest The sound manifest configuration
569
- * @returns The AudioManager instance with type-safe sound IDs
570
- */
571
- declare function useAudio<M extends SoundManifest>(manifest: M): AudioManager<keyof M & string>;
572
- declare const AudioProvider: ({ children, manager, }: {
573
- children: React.ReactNode;
574
- manager: AudioManager<any>;
575
- }) => react_jsx_runtime.JSX.Element;
576
- declare const useAudioLegacy: <T extends string = string>() => AudioManager<T>;
577
- /**
578
- * Hook to create a stable AudioManager instance
579
- */
580
- declare const useAudioManager: <T extends string = string>(manifest: SoundManifest) => AudioManager<T>;
581
-
582
- interface VolumeSettings {
583
- masterVolume: number;
584
- musicVolume: number;
585
- sfxVolume: number;
586
- setMasterVolume: (volume: number) => void;
587
- setMusicVolume: (volume: number) => void;
588
- setSfxVolume: (volume: number) => void;
589
- getEffectiveVolume: (category: "music" | "sfx") => number;
590
- }
591
- declare const useVolumeStore: zustand.UseBoundStore<zustand.StoreApi<VolumeSettings>>;
592
-
593
- interface ControllerShellProps {
594
- /** Optional forced orientation. If not set, no orientation enforcement is applied. */
595
- forceOrientation?: "portrait" | "landscape";
596
- children: ReactNode;
597
- /** Optional custom actions to display in the header */
598
- customActions?: ReactNode;
599
- }
600
- declare const ControllerShell: ({ forceOrientation, children, customActions, }: ControllerShellProps) => JSX.Element;
601
-
602
- interface HostShellProps {
603
- children: ReactNode;
604
- }
605
- declare const HostShell: ({ children }: HostShellProps) => JSX.Element;
606
-
607
- interface PlayerAvatarProps {
608
- player: PlayerProfile;
609
- size?: "sm" | "md" | "lg";
610
- className?: string;
611
- }
612
- declare const PlayerAvatar: ({ player, size, className, }: PlayerAvatarProps) => JSX.Element;
613
-
614
- declare const buttonVariants: (props?: ({
615
- variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
616
- size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
617
- } & class_variance_authority_types.ClassProp) | undefined) => string;
618
- declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
619
- asChild?: boolean;
620
- }): react_jsx_runtime.JSX.Element;
621
-
622
- declare function Slider({ className, defaultValue, value, min, max, ...props }: React$1.ComponentProps<typeof SliderPrimitive.Root>): react_jsx_runtime.JSX.Element;
623
-
624
- interface VolumeControlsProps {
625
- className?: string;
626
- compact?: boolean;
627
- }
628
- declare function VolumeControls({ className, compact }: VolumeControlsProps): react_jsx_runtime.JSX.Element;
629
-
630
- /**
631
- * Core Air Jam constants used across the SDK
632
- */
633
- /**
634
- * Default server port for Air Jam server
635
- */
636
- declare const DEFAULT_SERVER_PORT = 4000;
637
- /**
638
- * Standard path for controller endpoints.
639
- * All Air Jam games use this convention - controller is always at {baseUrl}/controller
640
- */
641
- declare const CONTROLLER_PATH = "/controller";
642
- /**
643
- * Input debounce time in milliseconds
644
- * Used to prevent rapid input events from overwhelming the system
645
- */
646
- declare const INPUT_DEBOUNCE_MS = 200;
647
- /**
648
- * Toggle debounce time in milliseconds
649
- * Used for game state toggles to prevent accidental double-toggles
650
- */
651
- declare const TOGGLE_DEBOUNCE_MS = 300;
652
- /**
653
- * Socket.IO configuration
654
- */
655
- declare const SOCKET_CONFIG: {
656
- /**
657
- * Ping interval in milliseconds
658
- */
659
- readonly PING_INTERVAL: 2000;
660
- /**
661
- * Ping timeout in milliseconds
662
- */
663
- readonly PING_TIMEOUT: 5000;
664
- };
665
- /**
666
- * Maximum players allowed in a room by default
667
- */
668
- declare const DEFAULT_MAX_PLAYERS = 8;
669
-
670
- /**
671
- * Air Jam Socket.IO event names
672
- * Centralized to ensure consistency and type safety
673
- */
674
- /**
675
- * Host events
676
- */
677
- declare const HostEvents: {
678
- /**
679
- * Register as a master host (standalone mode)
680
- */
681
- readonly REGISTER: "host:register";
682
- /**
683
- * Register as the system/arcade master host
684
- */
685
- readonly REGISTER_SYSTEM: "host:registerSystem";
686
- /**
687
- * Join as a child host (game launched from arcade)
688
- */
689
- readonly JOIN_AS_CHILD: "host:joinAsChild";
690
- };
691
- /**
692
- * Controller events
693
- */
694
- declare const ControllerEvents: {
695
- /**
696
- * Controller joins a room
697
- */
698
- readonly JOIN: "controller:join";
699
- /**
700
- * Controller sends input
701
- */
702
- readonly INPUT: "controller:input";
703
- /**
704
- * Controller leaves a room
705
- */
706
- readonly LEAVE: "controller:leave";
707
- /**
708
- * Controller sends game state update
709
- */
710
- readonly STATE: "controller:state";
711
- /**
712
- * Controller sends system command
713
- */
714
- readonly SYSTEM: "controller:system";
715
- };
716
- /**
717
- * System events (Arcade-specific)
718
- */
719
- declare const SystemEvents: {
720
- /**
721
- * Arcade launches a game
722
- */
723
- readonly LAUNCH_GAME: "system:launchGame";
724
- /**
725
- * Arcade closes a game
726
- */
727
- readonly CLOSE_GAME: "system:closeGame";
728
- };
729
- /**
730
- * Server events (server -> client)
731
- */
732
- declare const ServerEvents: {
733
- /**
734
- * Welcome message with room/controller info
735
- */
736
- readonly WELCOME: "server:welcome";
737
- /**
738
- * Room is ready
739
- */
740
- readonly ROOM_READY: "server:roomReady";
741
- /**
742
- * Controller joined notification
743
- */
744
- readonly CONTROLLER_JOINED: "server:controllerJoined";
745
- /**
746
- * Controller left notification
747
- */
748
- readonly CONTROLLER_LEFT: "server:controllerLeft";
749
- /**
750
- * Host left notification
751
- */
752
- readonly HOST_LEFT: "server:hostLeft";
753
- /**
754
- * Server error
755
- */
756
- readonly ERROR: "server:error";
757
- /**
758
- * Play sound on client
759
- */
760
- readonly PLAY_SOUND: "server:playSound";
761
- };
762
- /**
763
- * Client events (server -> controller shell)
764
- */
765
- declare const ClientEvents: {
766
- /**
767
- * Load a game UI in the controller iframe
768
- */
769
- readonly LOAD_UI: "client:loadUi";
770
- /**
771
- * Unload the game UI from the controller iframe
772
- */
773
- readonly UNLOAD_UI: "client:unloadUi";
774
- /**
775
- * Update game state display
776
- */
777
- readonly STATE: "client:state";
778
- };
779
- /**
780
- * Child events (server -> child host)
781
- */
782
- declare const ChildEvents: {
783
- /**
784
- * Server requests child to close
785
- */
786
- readonly CLOSE: "child:close";
787
- };
788
- /**
789
- * All events combined for easy reference
790
- */
791
- declare const Events: {
792
- readonly Host: {
793
- /**
794
- * Register as a master host (standalone mode)
795
- */
796
- readonly REGISTER: "host:register";
797
- /**
798
- * Register as the system/arcade master host
799
- */
800
- readonly REGISTER_SYSTEM: "host:registerSystem";
801
- /**
802
- * Join as a child host (game launched from arcade)
803
- */
804
- readonly JOIN_AS_CHILD: "host:joinAsChild";
805
- };
806
- readonly Controller: {
807
- /**
808
- * Controller joins a room
809
- */
810
- readonly JOIN: "controller:join";
811
- /**
812
- * Controller sends input
813
- */
814
- readonly INPUT: "controller:input";
815
- /**
816
- * Controller leaves a room
817
- */
818
- readonly LEAVE: "controller:leave";
819
- /**
820
- * Controller sends game state update
821
- */
822
- readonly STATE: "controller:state";
823
- /**
824
- * Controller sends system command
825
- */
826
- readonly SYSTEM: "controller:system";
827
- };
828
- readonly System: {
829
- /**
830
- * Arcade launches a game
831
- */
832
- readonly LAUNCH_GAME: "system:launchGame";
833
- /**
834
- * Arcade closes a game
835
- */
836
- readonly CLOSE_GAME: "system:closeGame";
837
- };
838
- readonly Server: {
839
- /**
840
- * Welcome message with room/controller info
841
- */
842
- readonly WELCOME: "server:welcome";
843
- /**
844
- * Room is ready
845
- */
846
- readonly ROOM_READY: "server:roomReady";
847
- /**
848
- * Controller joined notification
849
- */
850
- readonly CONTROLLER_JOINED: "server:controllerJoined";
851
- /**
852
- * Controller left notification
853
- */
854
- readonly CONTROLLER_LEFT: "server:controllerLeft";
855
- /**
856
- * Host left notification
857
- */
858
- readonly HOST_LEFT: "server:hostLeft";
859
- /**
860
- * Server error
861
- */
862
- readonly ERROR: "server:error";
863
- /**
864
- * Play sound on client
865
- */
866
- readonly PLAY_SOUND: "server:playSound";
867
- };
868
- readonly Client: {
869
- /**
870
- * Load a game UI in the controller iframe
871
- */
872
- readonly LOAD_UI: "client:loadUi";
873
- /**
874
- * Unload the game UI from the controller iframe
875
- */
876
- readonly UNLOAD_UI: "client:unloadUi";
877
- /**
878
- * Update game state display
879
- */
880
- readonly STATE: "client:state";
881
- };
882
- readonly Child: {
883
- /**
884
- * Server requests child to close
885
- */
886
- readonly CLOSE: "child:close";
887
- };
888
- };
47
+ fadeOutAndStop(id: T, soundId: number, durationMs: number): void;
48
+ mute(muted: boolean, id?: T, soundId?: number): void;
49
+ isMuted(): boolean;
50
+ }
51
+
52
+ type AudioRuntimeStatus = "idle" | "blocked" | "ready";
53
+ interface AudioRuntimeControls {
54
+ retry: () => Promise<boolean>;
55
+ }
56
+ interface AudioRuntimeProps<M extends SoundManifest = SoundManifest> {
57
+ manifest: M;
58
+ children: ReactNode;
59
+ }
60
+ declare function AudioRuntime<M extends SoundManifest>({ manifest, children, }: AudioRuntimeProps<M>): react_jsx_runtime.JSX.Element;
61
+ declare function useAudio<T extends string = string>(): AudioHandle<T>;
62
+ declare function useAudioRuntimeStatus(): AudioRuntimeStatus;
63
+ declare function useAudioRuntimeControls(): AudioRuntimeControls;
64
+
65
+ type AudioVolumeCategory = SoundCategory | "master";
66
+ interface MusicPlaylistProps<TTrackId extends string = string> {
67
+ tracks: readonly TTrackId[];
68
+ playing: boolean;
69
+ order?: "sequence" | "shuffle";
70
+ fadeMs?: number;
71
+ startIndex?: number;
72
+ }
73
+ declare function useAudioCategoryVolume(category: AudioVolumeCategory): number;
74
+ declare function useMusicVolume(): number;
75
+ declare function MusicPlaylist<TTrackId extends string = string>({ tracks, playing, order, fadeMs, startIndex, }: MusicPlaylistProps<TTrackId>): null;
76
+
77
+ type AirJamDiagnosticSeverity = "warn" | "error";
78
+ type AirJamDiagnosticCode = "AJ_SCOPE_MISMATCH" | "AJ_DUPLICATE_SESSION_OWNER" | "AJ_MISSING_SESSION_PROVIDER" | "AJ_CONFIG_MISSING_RUNTIME_TOPOLOGY" | "AJ_CONFIG_MISSING_APP_ID" | "AJ_HOST_BOOTSTRAP_FAILED" | "AJ_RUNTIME_RENDER_CRASH" | "AJ_STORE_ACTION_SESSION_NOT_READY" | "AJ_STORE_ACTION_SOCKET_DISCONNECTED" | "AJ_STORE_ACTION_EVENT_PAYLOAD_DROPPED" | "AJ_STORE_ACTION_PAYLOAD_INVALID_SHAPE" | "AJ_STORE_ACTION_PAYLOAD_NOT_SERIALIZABLE" | "AJ_STORE_PLAYER_ACTIONS_HOST_ONLY" | "AJ_STORE_PLAYER_ACTIONS_PLAYER_NOT_CONNECTED" | "AJ_STORE_PLAYER_ACTIONS_INVALID_ACTOR_ID" | "AJ_INPUT_WRITER_INVALID_SHAPE" | "AJ_INPUT_WRITER_NOT_SERIALIZABLE" | "AJ_INPUT_WRITER_SESSION_NOT_READY" | "AJ_INPUT_WRITER_SOCKET_DISCONNECTED" | "AJ_INPUT_WRITER_SCHEMA_INVALID";
79
+ interface AirJamDiagnostic {
80
+ code: AirJamDiagnosticCode;
81
+ severity: AirJamDiagnosticSeverity;
82
+ message: string;
83
+ details?: Record<string, unknown>;
84
+ timestamp: number;
85
+ }
86
+ type AirJamDiagnosticListener = (diagnostic: AirJamDiagnostic) => void;
87
+ declare const onAirJamDiagnostic: (listener: AirJamDiagnosticListener) => (() => void);
88
+ declare const setAirJamDiagnosticsEnabled: (enabled: boolean) => void;
889
89
 
890
90
  /**
891
- * Options for configuring the controller connection.
91
+ * Options for configuring the controller runtime boundary.
892
92
  *
893
- * @example Basic usage (room from URL)
93
+ * @example Basic runtime boundary usage (room from URL)
894
94
  * ```tsx
895
95
  * // URL: https://yourgame.com/controller?room=ABCD
896
- * const controller = useAirJamController();
897
- * // Automatically joins room ABCD
96
+ * <AirJamControllerRuntime>
97
+ * <ControllerView />
98
+ * </AirJamControllerRuntime>
898
99
  * ```
899
100
  *
900
101
  * @example With nickname
901
102
  * ```tsx
902
- * const controller = useAirJamController({
903
- * nickname: playerName,
904
- * onState: (state) => {
905
- * if (state.gameState === "playing") startGame();
906
- * },
907
- * });
103
+ * <AirJamControllerRuntime
104
+ * nickname={playerName}
105
+ * onState={(state) => {
106
+ * if (state.runtimeState === "playing") startGame();
107
+ * }}
108
+ * >
109
+ * <ControllerView />
110
+ * </AirJamControllerRuntime>
908
111
  * ```
909
112
  */
910
113
  interface AirJamControllerOptions {
@@ -919,16 +122,20 @@ interface AirJamControllerOptions {
919
122
  * If not provided, the server assigns a random label.
920
123
  */
921
124
  nickname?: string;
125
+ /**
126
+ * Preset avatar id sent on join (optional).
127
+ */
128
+ avatarId?: string;
922
129
  /**
923
130
  * Controller ID for this instance.
924
131
  * Auto-generated if not provided. Persists across reconnects.
925
132
  */
926
133
  controllerId?: string;
927
134
  /**
928
- * Force connection even in non-standard modes (e.g., iframe).
929
- * @default false
135
+ * Optional privileged controller capability token.
136
+ * Undefined falls back to `aj_controller_cap` from the URL; null explicitly disables URL token use.
930
137
  */
931
- forceConnect?: boolean;
138
+ capabilityToken?: string | null;
932
139
  /**
933
140
  * Called when the host sends a state update (game state, messages, etc.)
934
141
  */
@@ -949,53 +156,66 @@ interface AirJamControllerApi {
949
156
  /** Last error message, if any */
950
157
  lastError?: string;
951
158
  /** Current game state (paused or playing) */
952
- gameState: GameState;
159
+ runtimeState: RuntimeState;
160
+ /** Intended controller presentation orientation for the active game UI. */
161
+ controllerOrientation: ControllerOrientation;
953
162
  /** Optional message from the host (e.g., "Get Ready!") */
954
163
  stateMessage?: string;
955
- /**
956
- * Send input to the host.
957
- *
958
- * @example Sending joystick and button input
959
- * ```ts
960
- * controller.sendInput({
961
- * vector: { x: joystickX, y: joystickY },
962
- * action: isFirePressed,
963
- * ability: isAbilityPressed,
964
- * timestamp: Date.now(),
965
- * });
966
- * ```
967
- */
968
- sendInput: (input: ControllerInputPayload) => boolean;
164
+ /** Current host-owned room settings mirrored onto the controller. */
165
+ roomSettings: ControllerRoomSettingsState;
969
166
  /**
970
167
  * Send a system command to the host.
971
168
  *
972
- * @example Toggle pause
169
+ * @example Pause or resume
973
170
  * ```ts
974
- * controller.sendSystemCommand("toggle_pause");
171
+ * controller.sendSystemCommand("pause");
172
+ * controller.sendSystemCommand("resume");
975
173
  * ```
976
174
  */
977
- sendSystemCommand: (command: "exit" | "ready" | "toggle_pause") => void;
175
+ sendSystemCommand: (command: "exit" | "pause" | "resume") => void;
978
176
  /**
979
- * Update the player nickname.
980
- * Changes take effect on next connection.
177
+ * Update the player nickname (local draft for next join).
981
178
  */
982
179
  setNickname: (value: string) => void;
180
+ /**
181
+ * Update preset avatar id (local draft for next join).
182
+ */
183
+ setAvatarId: (value: string) => void;
184
+ /**
185
+ * Patch display name and/or avatar on the server without reconnecting.
186
+ * In Arcade (embedded iframe), updates are forwarded through the controller bridge; the room
187
+ * still learns the new name via `server:playerUpdated` (ack payload is not round-tripped).
188
+ */
189
+ updatePlayerProfile: (patch: PlayerProfilePatch) => Promise<ControllerUpdatePlayerProfileAck>;
190
+ /** Explicitly leave the current room and release the controller binding. */
191
+ leave: () => Promise<ControllerLeaveAck>;
983
192
  /** Force reconnection to the room */
984
193
  reconnect: () => void;
985
194
  /** List of all connected players in the room */
986
195
  players: PlayerProfile[];
987
- /** Raw Socket.IO socket instance (null if not connected) */
988
- socket: AirJamSocket | null;
196
+ /** This controller's current player profile when known. */
197
+ selfPlayer: PlayerProfile | null;
198
+ /** Realtime client for controller events (socket-backed standalone, bridge-backed in arcade embeds) */
199
+ socket: AirJamRealtimeClient | null;
200
+ }
201
+ interface AirJamControllerState {
202
+ roomId: RoomCode | null;
203
+ controllerId: string | null;
204
+ connectionStatus: ConnectionStatus;
205
+ lastError?: string;
206
+ runtimeState: RuntimeState;
207
+ controllerOrientation: ControllerOrientation;
208
+ stateMessage?: string;
209
+ roomSettings: ControllerRoomSettingsState;
210
+ players: PlayerProfile[];
211
+ selfPlayer: PlayerProfile | null;
989
212
  }
990
213
  /**
991
- * Hook for building mobile/web controllers that connect to AirJam hosts.
214
+ * Read the mounted controller runtime API.
992
215
  *
993
- * This hook handles all the complexity of connecting a mobile controller to a game:
994
- * - Automatic room joining from URL parameters
995
- * - Input sending with validation
996
- * - Haptic feedback on signal receipt (vibration)
997
- * - Game state synchronization
998
- * - Auto-reconnection on disconnect
216
+ * Use this inside `AirJamControllerRuntime` or another explicit controller runtime
217
+ * boundary such as `airjam.Controller`. Runtime ownership is mounted once at the
218
+ * boundary; child code reads from that runtime through this hook.
999
219
  *
1000
220
  * **Typical usage flow:**
1001
221
  * 1. Player scans QR code on game screen
@@ -1004,7 +224,6 @@ interface AirJamControllerApi {
1004
224
  * 4. Player uses joystick/buttons to send input
1005
225
  * 5. Receives haptic feedback on game events
1006
226
  *
1007
- * @param options - Configuration options
1008
227
  * @returns Controller API with state and functions
1009
228
  *
1010
229
  * @example Basic controller setup
@@ -1012,31 +231,14 @@ interface AirJamControllerApi {
1012
231
  * const ControllerView = () => {
1013
232
  * const controller = useAirJamController();
1014
233
  *
1015
- * const handleJoystickMove = (x: number, y: number) => {
1016
- * controller.sendInput({
1017
- * vector: { x, y },
1018
- * action: false,
1019
- * timestamp: Date.now(),
1020
- * });
1021
- * };
1022
- *
1023
- * const handleFirePress = () => {
1024
- * controller.sendInput({
1025
- * vector: { x: 0, y: 0 },
1026
- * action: true,
1027
- * timestamp: Date.now(),
1028
- * });
1029
- * };
1030
- *
1031
234
  * if (controller.connectionStatus !== "connected") {
1032
235
  * return <div>Connecting to room {controller.roomId}...</div>;
1033
236
  * }
1034
237
  *
1035
238
  * return (
1036
239
  * <div>
1037
- * <Joystick onMove={handleJoystickMove} />
1038
- * <FireButton onPress={handleFirePress} />
1039
- * <p>Game: {controller.gameState}</p>
240
+ * <p>Connected: {controller.controllerId}</p>
241
+ * <p>Game: {controller.runtimeState}</p>
1040
242
  * </div>
1041
243
  * );
1042
244
  * };
@@ -1044,40 +246,45 @@ interface AirJamControllerApi {
1044
246
  *
1045
247
  * @example With state callback
1046
248
  * ```tsx
1047
- * const controller = useAirJamController({
1048
- * onState: (state) => {
249
+ * <AirJamControllerRuntime
250
+ * onState={(state) => {
1049
251
  * if (state.message) {
1050
252
  * showNotification(state.message);
1051
253
  * }
1052
- * },
1053
- * });
254
+ * }}
255
+ * >
256
+ * <ControllerView />
257
+ * </AirJamControllerRuntime>
1054
258
  * ```
1055
259
  */
1056
- declare const useAirJamController: (options?: AirJamControllerOptions) => AirJamControllerApi;
260
+ declare function useAirJamController(): AirJamControllerApi;
261
+ declare function useAirJamController<TSelected>(selector: (state: AirJamControllerState) => TSelected): TSelected;
1057
262
 
263
+ type JoinUrlStatus = "loading" | "ready" | "unavailable";
1058
264
  /**
1059
- * Options for configuring the host connection.
265
+ * Options for configuring the host runtime boundary.
1060
266
  *
1061
- * @example Basic usage with callbacks
267
+ * @example Runtime boundary usage with callbacks
1062
268
  * ```tsx
1063
- * const host = useAirJamHost({
1064
- * onPlayerJoin: (player) => {
269
+ * <AirJamHostRuntime
270
+ * onPlayerJoin={(player) => {
1065
271
  * console.log(`${player.label} joined!`);
1066
272
  * spawnPlayerShip(player.id);
1067
- * },
1068
- * onPlayerLeave: (controllerId) => {
273
+ * }}
274
+ * onPlayerLeave={(controllerId) => {
1069
275
  * console.log(`Player ${controllerId} left`);
1070
276
  * removePlayerShip(controllerId);
1071
- * },
1072
- * });
277
+ * }}
278
+ * >
279
+ * <HostView />
280
+ * </AirJamHostRuntime>
1073
281
  * ```
1074
282
  *
1075
283
  * @example With custom room ID
1076
284
  * ```tsx
1077
- * const host = useAirJamHost({
1078
- * roomId: "GAME1", // Custom 4-character room code
1079
- * maxPlayers: 4, // Override provider's maxPlayers
1080
- * });
285
+ * <AirJamHostRuntime roomId="GAME1">
286
+ * <HostView />
287
+ * </AirJamHostRuntime>
1081
288
  * ```
1082
289
  */
1083
290
  interface AirJamHostOptions {
@@ -1097,26 +304,6 @@ interface AirJamHostOptions {
1097
304
  * Use this to remove player entities, handle cleanup.
1098
305
  */
1099
306
  onPlayerLeave?: (controllerId: string) => void;
1100
- /**
1101
- * Called when the child window closes in Arcade mode.
1102
- * Only relevant when running as part of the AirJam Platform.
1103
- */
1104
- onChildClose?: () => void;
1105
- /**
1106
- * Force connection even in non-standard modes.
1107
- * @default true
1108
- */
1109
- forceConnect?: boolean;
1110
- /**
1111
- * Override the API key from provider.
1112
- * Useful for per-game API keys in multi-game setups.
1113
- */
1114
- apiKey?: string;
1115
- /**
1116
- * Override the maximum players from provider.
1117
- * @default 8
1118
- */
1119
- maxPlayers?: number;
1120
307
  }
1121
308
  /**
1122
309
  * Return type of useAirJamHost hook.
@@ -1130,18 +317,26 @@ interface AirJamHostApi<TSchema extends z.ZodSchema = z.ZodSchema> {
1130
317
  roomId: RoomCode;
1131
318
  /** Full URL for controllers to join (display as QR code) */
1132
319
  joinUrl: string;
320
+ /** Whether the join URL is still being resolved, ready to render, or unavailable */
321
+ joinUrlStatus: JoinUrlStatus;
1133
322
  /** Current connection status to the server */
1134
323
  connectionStatus: ConnectionStatus;
1135
324
  /** List of currently connected players */
1136
325
  players: PlayerProfile[];
326
+ /** Full controller-session roster for the current room, including source and lease state. */
327
+ controllers: ControllerPresenceNotice[];
1137
328
  /** Last error message, if any */
1138
329
  lastError?: string;
1139
330
  /** Current run mode (standalone, arcade, platform) */
1140
331
  mode: RunMode;
1141
- /** Current game state (paused or playing) */
1142
- gameState: GameState;
1143
- /** Toggle between paused and playing states */
1144
- toggleGameState: () => void;
332
+ /** Current runtime pause/play state */
333
+ runtimeState: RuntimeState;
334
+ /** Pause the runtime for every connected surface. */
335
+ pauseRuntime: () => void;
336
+ /** Resume the runtime for every connected surface. */
337
+ resumeRuntime: () => void;
338
+ /** Set the runtime pause/play state explicitly. */
339
+ setRuntimeState: (state: RuntimeState) => void;
1145
340
  /**
1146
341
  * Send state update to all connected controllers.
1147
342
  * Use for syncing game state, messages, etc.
@@ -1169,16 +364,18 @@ interface AirJamHostApi<TSchema extends z.ZodSchema = z.ZodSchema> {
1169
364
  };
1170
365
  /** Reconnect to the server */
1171
366
  reconnect: () => void;
1172
- /** Raw Socket.IO socket instance for advanced usage */
1173
- socket: AirJamSocket;
1174
- /** Whether running in child/arcade mode */
1175
- isChildMode: boolean;
367
+ /** Remove one controller from the room immediately. */
368
+ removeController: (controllerId: string) => Promise<HostControllerActionAck>;
369
+ /** Tear down the current room and create a fresh empty room for this host. */
370
+ resetRoom: () => Promise<HostRegistrationAck>;
371
+ /** Realtime client for host events (socket-backed standalone, bridge-backed in arcade embeds) */
372
+ socket: AirJamRealtimeClient;
1176
373
  /**
1177
374
  * Get the latest input from a specific controller.
1178
375
  *
1179
- * Returns validated, typed input based on the schema provided to AirJamProvider.
1180
- * If latching is configured, automatically handles latch logic (button presses
1181
- * and stick flicks are "held" until consumed).
376
+ * Returns validated, typed input based on the schema provided to the session provider.
377
+ * Input behavior defaults are tap-safe booleans (`pulse`) and latest vectors (`latest`),
378
+ * with optional per-field overrides.
1182
379
  *
1183
380
  * @example In a game loop
1184
381
  * ```ts
@@ -1195,38 +392,56 @@ interface AirJamHostApi<TSchema extends z.ZodSchema = z.ZodSchema> {
1195
392
  */
1196
393
  getInput: (controllerId: string) => z.infer<TSchema> | undefined;
1197
394
  }
395
+ interface AirJamHostState {
396
+ roomId: RoomCode | null;
397
+ connectionStatus: ConnectionStatus;
398
+ players: PlayerProfile[];
399
+ controllers: ControllerPresenceNotice[];
400
+ lastError?: string;
401
+ mode: RunMode;
402
+ runtimeState: RuntimeState;
403
+ }
1198
404
  /**
1199
- * Primary hook for host/game functionality.
405
+ * Read the mounted host runtime API.
406
+ *
407
+ * Use this inside `AirJamHostRuntime` or another explicit host runtime boundary
408
+ * such as `airjam.Host`. Runtime ownership is mounted once at the boundary; child
409
+ * code reads from that runtime through this hook.
1200
410
  *
1201
- * Connects to the AirJam server as a host and provides everything needed
1202
- * to manage a multiplayer game session. Must be used within an AirJamProvider.
411
+ * This hook is runtime-aware:
412
+ * - standalone: creates/reconnects host rooms directly
413
+ * - arcade iframe runtime: auto-detects `aj_room` + `aj_cap` and bridges through the platform-owned host session
414
+ *
415
+ * This hook no longer creates host runtime side effects.
1203
416
  *
1204
417
  * **Features:**
1205
418
  * - Automatic room creation and management
1206
419
  * - Real-time player join/leave events
1207
- * - Typed input with validation and latching
420
+ * - Typed input with validation and behavior defaults
1208
421
  * - Haptic feedback and toast notifications
1209
- * - Game state synchronization
422
+ * - Runtime state synchronization
1210
423
  *
1211
424
  * @template TSchema - Zod schema for input validation (from provider)
1212
- * @param options - Configuration options for the host
1213
425
  * @returns API object with state and functions
1214
426
  *
1215
427
  * @example Basic usage
1216
428
  * ```tsx
1217
429
  * const HostView = () => {
1218
- * const host = useAirJamHost({
1219
- * onPlayerJoin: (player) => console.log(`${player.label} joined`),
1220
- * onPlayerLeave: (id) => console.log(`${id} left`),
1221
- * });
430
+ * const host = useAirJamHost();
1222
431
  *
1223
432
  * return (
1224
433
  * <div>
1225
434
  * <h1>Room: {host.roomId}</h1>
1226
435
  * <QRCode value={host.joinUrl} />
1227
436
  * <p>Players: {host.players.length}</p>
1228
- * <button onClick={host.toggleGameState}>
1229
- * {host.gameState === "playing" ? "Pause" : "Play"}
437
+ * <button
438
+ * onClick={
439
+ * host.runtimeState === "playing"
440
+ * ? host.pauseRuntime
441
+ * : host.resumeRuntime
442
+ * }
443
+ * >
444
+ * {host.runtimeState === "playing" ? "Pause" : "Resume"}
1230
445
  * </button>
1231
446
  * </div>
1232
447
  * );
@@ -1246,7 +461,7 @@ interface AirJamHostApi<TSchema extends z.ZodSchema = z.ZodSchema> {
1246
461
  * // Move player based on joystick
1247
462
  * movePlayer(player.id, input.vector);
1248
463
  *
1249
- * // Handle button press (auto-latched)
464
+ * // Handle button press (tap-safe pulse default)
1250
465
  * if (input.action) {
1251
466
  * playerShoot(player.id);
1252
467
  * }
@@ -1264,38 +479,52 @@ interface AirJamHostApi<TSchema extends z.ZodSchema = z.ZodSchema> {
1264
479
  * };
1265
480
  * ```
1266
481
  */
1267
- declare const useAirJamHost: <TSchema extends z.ZodSchema = z.ZodSchema>(options?: AirJamHostOptions) => AirJamHostApi<TSchema>;
482
+ declare function useAirJamHost<TSchema extends z.ZodSchema = z.ZodSchema>(): AirJamHostApi<TSchema>;
483
+ declare function useAirJamHost<TSelected>(selector: (state: AirJamHostState) => TSelected): TSelected;
1268
484
 
1269
- interface AirJamShellOptions {
1270
- /** Room ID to join */
1271
- roomId?: string;
1272
- /** Player nickname */
1273
- nickname?: string;
1274
- /** Controller ID (auto-generated if not provided) */
1275
- controllerId?: string;
485
+ declare const useConnectionStatus: () => ConnectionStatus;
486
+
487
+ interface ControllerTickInfo {
488
+ now: number;
489
+ deltaMs: number;
490
+ deltaSeconds: number;
491
+ tick: number;
1276
492
  }
1277
- interface AirJamShellApi {
1278
- roomId: RoomCode | null;
1279
- controllerId: string | null;
1280
- connectionStatus: ConnectionStatus;
1281
- lastError?: string;
1282
- activeUrl: string | null;
1283
- players: PlayerProfile[];
1284
- gameState: GameState;
1285
- sendInput: (input: ControllerInputPayload) => boolean;
1286
- sendSystemCommand: (command: "exit" | "ready" | "toggle_pause") => void;
493
+ interface ControllerTickOptions {
494
+ enabled?: boolean;
495
+ intervalMs?: number;
496
+ }
497
+ /**
498
+ * Canonical fixed-cadence controller tick helper.
499
+ *
500
+ * Use this to publish controller input at a stable cadence via `useInputWriter`.
501
+ */
502
+ declare const useControllerTick: (callback: (info: ControllerTickInfo) => void, options?: ControllerTickOptions) => void;
503
+
504
+ interface ControllerToast extends ToastSignalPayload {
505
+ id: string;
506
+ receivedAt: number;
507
+ }
508
+ interface UseControllerToastsOptions {
509
+ maxToasts?: number;
510
+ defaultDurationMs?: number;
1287
511
  }
1288
- declare const useAirJamShell: (options?: AirJamShellOptions) => AirJamShellApi;
512
+ declare const useControllerToasts: (options?: UseControllerToastsOptions) => {
513
+ toasts: ControllerToast[];
514
+ latestToast: ControllerToast | null;
515
+ dismissToast: (toastId: string) => void;
516
+ clearToasts: () => void;
517
+ };
1289
518
 
1290
519
  /**
1291
520
  * Lightweight hook for accessing controller input without store subscriptions.
1292
521
  *
1293
522
  * Returns a stable `getInput` function that retrieves the latest input for a
1294
523
  * given controller ID. Unlike `useAirJamHost()`, this hook does NOT subscribe
1295
- * to the store, so it won't cause re-renders when connection state changes.
524
+ * to host session state, so it won't cause re-renders when connection state changes.
1296
525
  *
1297
526
  * **Requirements:**
1298
- * - Must be used within an `AirJamProvider`
527
+ * - Must be used within `AirJamHostRuntime`, `airjam.Host`, or the underlying scoped host runtime
1299
528
  * - Input configuration must be provided to the provider
1300
529
  *
1301
530
  * @template TSchema - Zod schema type for input (from provider)
@@ -1315,7 +544,7 @@ declare const useAirJamShell: (options?: AirJamShellOptions) => AirJamShellApi;
1315
544
  * meshRef.current.position.x += input.vector.x * SPEED;
1316
545
  * meshRef.current.position.y += input.vector.y * SPEED;
1317
546
  *
1318
- * // Fire if action button pressed (auto-latched)
547
+ * // Fire if action button pressed (tap-safe pulse)
1319
548
  * if (input.action) {
1320
549
  * fireLaser();
1321
550
  * }
@@ -1345,6 +574,48 @@ declare const useAirJamShell: (options?: AirJamShellOptions) => AirJamShellApi;
1345
574
  */
1346
575
  declare const useGetInput: <TSchema extends z.ZodSchema = z.ZodSchema>() => ((controllerId: string) => z.infer<TSchema> | undefined);
1347
576
 
577
+ interface HostTickInfo {
578
+ now: number;
579
+ deltaMs: number;
580
+ deltaSeconds: number;
581
+ tick: number;
582
+ }
583
+ interface HostFrameInfo {
584
+ now: number;
585
+ deltaMs: number;
586
+ deltaSeconds: number;
587
+ frame: number;
588
+ fixedStepAlpha: number;
589
+ }
590
+ interface HostTickOptions {
591
+ onTick: (info: HostTickInfo) => void;
592
+ enabled?: boolean;
593
+ mode?: "raf" | "interval" | "fixed";
594
+ intervalMs?: number;
595
+ maxDeltaMs?: number;
596
+ maxStepsPerFrame?: number;
597
+ onFrame?: (info: HostFrameInfo) => void;
598
+ }
599
+ /**
600
+ * Canonical host tick helper.
601
+ *
602
+ * - `mode: "raf"` (default) for render-aligned host loops.
603
+ * - `mode: "interval"` for fixed-cadence host polling loops.
604
+ * - `mode: "fixed"` for deterministic fixed-step host simulation loops.
605
+ */
606
+ declare const useHostTick: (options: HostTickOptions) => void;
607
+
608
+ declare const useInputWriter: () => ((input: ControllerInputPayload) => boolean);
609
+
610
+ declare const usePlayers: () => PlayerProfile[];
611
+
612
+ interface RoomState {
613
+ roomId: RoomCode | null;
614
+ runtimeState: "paused" | "playing";
615
+ mode: "standalone" | "platform";
616
+ }
617
+ declare const useRoom: () => RoomState;
618
+
1348
619
  /**
1349
620
  * Function signature for sending signals to controllers.
1350
621
  *
@@ -1457,94 +728,429 @@ interface SendSignalFn {
1457
728
  */
1458
729
  declare const useSendSignal: () => SendSignalFn;
1459
730
 
731
+ type HostInspectionApi = Pick<AirJamHostApi, "roomId" | "joinUrl" | "joinUrlStatus" | "connectionStatus" | "players" | "controllers" | "lastError" | "mode" | "runtimeState">;
732
+ type ControllerInspectionApi = Pick<AirJamControllerApi, "roomId" | "controllerId" | "connectionStatus" | "lastError" | "runtimeState" | "controllerOrientation" | "roomSettings" | "stateMessage" | "players" | "selfPlayer">;
733
+ interface HostRuntimeInspectionContract {
734
+ role: "host";
735
+ roomId: RoomCode;
736
+ joinUrl: string;
737
+ joinUrlStatus: JoinUrlStatus;
738
+ connectionStatus: ConnectionStatus;
739
+ players: readonly PlayerProfile[];
740
+ controllers: readonly ControllerPresenceNotice[];
741
+ lastError?: string;
742
+ mode: RunMode;
743
+ runtimeState: RuntimeState;
744
+ }
745
+ interface ControllerRuntimeInspectionContract {
746
+ role: "controller";
747
+ roomId: RoomCode | null;
748
+ controllerId: string | null;
749
+ connectionStatus: ConnectionStatus;
750
+ players: readonly PlayerProfile[];
751
+ selfPlayer: PlayerProfile | null;
752
+ lastError?: string;
753
+ runtimeState: RuntimeState;
754
+ controllerOrientation: ControllerOrientation;
755
+ stateMessage?: string;
756
+ roomSettings: ControllerInspectionApi["roomSettings"];
757
+ }
758
+ type RuntimeInspectionContract = HostRuntimeInspectionContract | ControllerRuntimeInspectionContract;
759
+ declare const AIR_JAM_RUNTIME_INSPECTION_KEY = "__airJamRuntimeInspection";
760
+ declare const createHostRuntimeInspectionContract: (api: HostInspectionApi) => HostRuntimeInspectionContract;
761
+ declare const createControllerRuntimeInspectionContract: (api: ControllerInspectionApi) => ControllerRuntimeInspectionContract;
762
+ declare const readRuntimeInspectionContract: (target: object) => RuntimeInspectionContract | null;
763
+ declare const publishRuntimeInspectionContract: (target: object, contract: RuntimeInspectionContract | null) => void;
764
+
765
+ declare const useHostRuntimeInspectionContract: () => HostRuntimeInspectionContract;
766
+ declare const useControllerRuntimeInspectionContract: () => ControllerRuntimeInspectionContract;
767
+
768
+ /**
769
+ * @module InputManager
770
+ * @description Internal input runtime used by host hooks.
771
+ *
772
+ * Public API terms:
773
+ * - `pulse`: consume-on-read, tap-safe behavior (default for booleans)
774
+ * - `hold`: keep last active vector until a new active value arrives
775
+ * - `latest`: read current value as-is (default for vectors and other fields)
776
+ *
777
+ * @internal This class is not exported publicly. Use hooks to access input.
778
+ */
779
+
1460
780
  /**
1461
- * Creates a networked Zustand store that automatically syncs state between host and controllers.
781
+ * Configuration for input handling with optional validation and per-field behavior.
1462
782
  *
1463
- * The store pattern works as follows:
1464
- * - Host: Stores state locally and broadcasts changes to all controllers
1465
- * - Controller: Sends action RPCs to host, receives state updates from host
783
+ * Provided to `HostSessionProvider` to enable typed and behavior-aware input reads.
784
+ *
785
+ * @template TSchema - Zod schema type for input validation
1466
786
  *
1467
- * @example
787
+ * @example Basic schema validation
1468
788
  * ```ts
1469
- * interface GameState {
1470
- * phase: "lobby" | "playing" | "gameover";
1471
- * scores: { team1: number; team2: number };
1472
- * actions: {
1473
- * setPhase: (phase: "lobby" | "playing") => void;
1474
- * scorePoint: (team: "team1" | "team2") => void;
1475
- * };
1476
- * }
789
+ * const config: InputConfig = {
790
+ * schema: z.object({
791
+ * vector: z.object({ x: z.number(), y: z.number() }),
792
+ * action: z.boolean(),
793
+ * }),
794
+ * };
795
+ * ```
1477
796
  *
1478
- * export const useGameStore = createAirJamStore<GameState>((set) => ({
1479
- * phase: "lobby",
1480
- * scores: { team1: 0, team2: 0 },
1481
- * actions: {
1482
- * setPhase: (phase) => set({ phase }),
1483
- * scorePoint: (team) => set((state) => ({
1484
- * scores: { ...state.scores, [team]: state.scores[team] + 1 }
1485
- * })),
797
+ * @example With custom behavior overrides
798
+ * ```ts
799
+ * const config: InputConfig = {
800
+ * schema: gameInputSchema,
801
+ * behavior: {
802
+ * pulse: ["action", "ability"], // consume-on-read
803
+ * latest: ["aim"], // read latest value
804
+ * hold: ["menuVector"], // keep last non-zero vector
1486
805
  * },
1487
- * }));
806
+ * };
1488
807
  * ```
1489
808
  */
1490
- declare function createAirJamStore<T extends {
1491
- actions: Record<string, (...args: any[]) => any>;
1492
- }>(initializer: StateCreator<T>): <U>(selector?: (state: T) => U) => U;
1493
-
1494
- declare const generateRoomCode: () => string;
1495
- declare const generateControllerId: () => string;
809
+ interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
810
+ /**
811
+ * Zod schema for input validation and type inference.
812
+ *
813
+ * When provided:
814
+ * - Incoming input is validated against the schema
815
+ * - Invalid input returns `undefined` (with console warning)
816
+ * - Return type is inferred from the schema
817
+ *
818
+ * @example
819
+ * ```ts
820
+ * schema: z.object({
821
+ * vector: z.object({ x: z.number(), y: z.number() }),
822
+ * action: z.boolean(),
823
+ * ability: z.boolean(),
824
+ * timestamp: z.number(),
825
+ * })
826
+ * ```
827
+ */
828
+ schema?: TSchema;
829
+ behavior?: {
830
+ /**
831
+ * Consume-on-read behavior. Useful for tap-safe buttons and one-shot vectors.
832
+ *
833
+ * Defaults: booleans use `pulse` even without explicit config.
834
+ */
835
+ pulse?: string[];
836
+ /**
837
+ * Sticky behavior. For vectors, keeps the last non-zero direction until
838
+ * another non-zero direction arrives.
839
+ */
840
+ hold?: string[];
841
+ /**
842
+ * Stateless behavior. Returns the latest raw value.
843
+ *
844
+ * Defaults: vectors and non-boolean fields use `latest`.
845
+ */
846
+ latest?: string[];
847
+ };
848
+ }
1496
849
 
1497
- /**
1498
- * Gets the local network IP address using WebRTC.
1499
- * Filters out virtual network interfaces and prefers real network IPs.
1500
- * Returns null if unable to determine the IP.
1501
- */
1502
- declare const getLocalNetworkIp: () => Promise<string | null>;
850
+ interface ResolveAirJamConfigInput {
851
+ topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
852
+ surfaceRole?: SurfaceRole;
853
+ appId?: string;
854
+ hostGrantEndpoint?: string;
855
+ maxPlayers?: number;
856
+ hostSessionKind?: HostSessionKind;
857
+ resolveEnv?: boolean;
858
+ }
1503
859
 
1504
860
  /**
1505
- * Centralized URL builder service for Air Jam.
1506
- * Handles IP detection, URL normalization, and construction of all URL types.
861
+ * Props for the AirJamProvider component.
862
+ *
863
+ * @template TSchema - Zod schema type for input validation (inferred from input.schema)
864
+ *
865
+ * @example Minimal configuration (uses environment variables)
866
+ * ```tsx
867
+ * <HostSessionProvider>
868
+ * <App />
869
+ * </HostSessionProvider>
870
+ * ```
871
+ *
872
+ * @example Full configuration
873
+ * ```tsx
874
+ * <HostSessionProvider
875
+ * topology={myTopology}
876
+ * appId="your-app-id"
877
+ * hostGrantEndpoint="/api/airjam/host-grant"
878
+ * maxPlayers={4}
879
+ * input={{
880
+ * schema: myInputSchema,
881
+ * behavior: { pulse: ["fire"], latest: ["move"] },
882
+ * }}
883
+ * >
884
+ * <App />
885
+ * </HostSessionProvider>
886
+ * ```
1507
887
  */
1508
- declare class UrlBuilder {
1509
- private cachedLocalIp;
1510
- private ipDetectionPromise;
888
+ interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
889
+ /** React children to render within the provider */
890
+ children: ReactNode;
891
+ /** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
892
+ topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
893
+ /** Internal surface-role hint when normalizing legacy endpoint props into topology. */
894
+ surfaceRole?: SurfaceRole;
895
+ /**
896
+ * App ID for production bootstrap identity.
897
+ * Falls back to VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID
898
+ * when not provided directly.
899
+ */
900
+ appId?: string;
901
+ /**
902
+ * Optional endpoint that returns a short-lived signed host grant for stronger production bootstrap.
903
+ * When provided, the host runtime fetches a grant automatically before `host:bootstrap`.
904
+ */
905
+ hostGrantEndpoint?: string;
1511
906
  /**
1512
- * Get the local network IP address with caching.
1513
- * First call triggers detection, subsequent calls return cached value.
907
+ * Maximum number of players allowed in a room.
908
+ * @default 8
1514
909
  */
1515
- getLocalIp(): Promise<string | null>;
910
+ maxPlayers?: number;
1516
911
  /**
1517
- * Clear the cached IP address.
1518
- * Useful for testing or when network changes are detected.
912
+ * Declares whether this host provider owns a standalone game room or a system shell room.
913
+ * Standalone games should use `"game"`; Arcade shell hosts should use `"system"`.
914
+ * @default "game"
1519
915
  */
1520
- clearCache(): void;
916
+ hostSessionKind?: HostSessionKind;
1521
917
  /**
1522
- * Normalize a URL for mobile access.
1523
- * Replaces localhost with the local network IP.
918
+ * Enable environment-variable fallback resolution for config fields.
919
+ * Set to false to require explicit `topology` / `appId` / `hostGrantEndpoint`.
920
+ * @default true
1524
921
  */
1525
- normalizeForMobile(url: string): Promise<string>;
922
+ resolveEnv?: boolean;
1526
923
  /**
1527
- * Build a controller URL with room code.
1528
- * Controller is always at {baseUrl}/controller (standardized convention).
1529
- * Automatically uses local IP when running on localhost.
924
+ * Input handling configuration including Zod schema validation and field behavior.
925
+ * When provided, enables typed input with tap-safe defaults:
926
+ * - booleans => `pulse`
927
+ * - vectors => `latest`
928
+ *
929
+ * @example
930
+ * ```ts
931
+ * input={{
932
+ * schema: z.object({
933
+ * vector: z.object({ x: z.number(), y: z.number() }),
934
+ * action: z.boolean(),
935
+ * ability: z.boolean(),
936
+ * }),
937
+ * behavior: {
938
+ * pulse: ["action", "ability"], // consume-on-read actions
939
+ * latest: ["vector"], // continuous movement
940
+ * },
941
+ * }}
942
+ * ```
1530
943
  */
1531
- buildControllerUrl(roomId: RoomCode, options?: {
1532
- host?: string;
1533
- }): Promise<string>;
944
+ input?: InputConfig<TSchema>;
945
+ }
946
+
947
+ type AirJamHostRuntimeProps<TSchema extends z.ZodSchema = z.ZodSchema> = AirJamProviderProps<TSchema> & AirJamHostOptions & {
948
+ children: ReactNode;
949
+ };
950
+ type AirJamControllerRuntimeProps = AirJamProviderProps & AirJamControllerOptions & {
951
+ children: ReactNode;
952
+ };
953
+ declare const AirJamHostRuntime: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, roomId, onPlayerJoin, onPlayerLeave, ...providerProps }: AirJamHostRuntimeProps<TSchema>) => JSX.Element;
954
+ declare const AirJamControllerRuntime: ({ children, roomId, nickname, avatarId, controllerId, capabilityToken, onState, ...providerProps }: AirJamControllerRuntimeProps) => JSX.Element;
955
+
956
+ type AirJamRuntimeRole = "host" | "controller";
957
+ interface AirJamRuntimeErrorContext {
958
+ role: AirJamRuntimeRole;
959
+ roomId?: string;
960
+ appId?: string;
961
+ }
962
+ interface AirJamErrorFallbackRenderProps extends AirJamRuntimeErrorContext {
963
+ error: Error;
964
+ reset: () => void;
965
+ reload: () => void;
966
+ isEmbedded: boolean;
967
+ }
968
+ type AirJamErrorFallbackRenderer = (props: AirJamErrorFallbackRenderProps) => JSX.Element;
969
+ interface AirJamErrorBoundaryProps extends AirJamRuntimeErrorContext {
970
+ children: ReactNode;
971
+ renderFallback?: AirJamErrorFallbackRenderer;
972
+ onError?: (error: Error, errorInfo: ErrorInfo, context: AirJamRuntimeErrorContext) => void;
973
+ }
974
+ interface AirJamErrorBoundaryState {
975
+ error: Error | null;
976
+ }
977
+ declare class AirJamErrorBoundary extends Component<AirJamErrorBoundaryProps, AirJamErrorBoundaryState> {
978
+ state: AirJamErrorBoundaryState;
979
+ static getDerivedStateFromError(error: unknown): AirJamErrorBoundaryState;
980
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
981
+ private handleReset;
982
+ private handleReload;
983
+ render(): JSX.Element;
984
+ }
985
+
986
+ type HostSessionProps<TSchema extends z.ZodSchema> = Omit<AirJamProviderProps<TSchema>, "children">;
987
+ type ControllerSessionProps = Omit<AirJamProviderProps, "children" | "input">;
988
+ interface AirJamRuntimeErrorBoundaryOptions {
989
+ renderFallback?: AirJamErrorFallbackRenderer;
990
+ onError?: AirJamErrorBoundaryProps["onError"];
991
+ }
992
+ interface AirJamAppErrorBoundaryOptions {
993
+ host?: AirJamRuntimeErrorBoundaryOptions;
994
+ controller?: AirJamRuntimeErrorBoundaryOptions;
995
+ }
996
+ interface CreateAirJamAppOptions<TSchema extends z.ZodSchema = z.ZodSchema> {
997
+ runtime?: ResolveAirJamConfigInput;
998
+ metadata?: AirJamGameMetadata;
1534
999
  /**
1535
- * Resolve the server URL.
1536
- * Uses explicit URL if provided, otherwise infers from window location.
1000
+ * Controller route path relative to the app origin.
1001
+ * Defaults to "/controller".
1537
1002
  */
1538
- resolveServerUrl(explicit?: string): string;
1003
+ controllerPath?: string;
1539
1004
  /**
1540
- * Check if a hostname is localhost.
1005
+ * Experimental capability metadata for future agent-facing control,
1006
+ * inspection, and evaluation workflows.
1541
1007
  */
1542
- private isLocalhost;
1008
+ capabilities?: AirJamGameCapabilityManifest;
1543
1009
  /**
1544
- * Normalize an origin string to ensure it has a protocol.
1010
+ * Optional semantic agent contract published by the app.
1545
1011
  */
1546
- private normalizeOrigin;
1012
+ agent?: AirJamAgentContract;
1013
+ input?: AirJamProviderProps<TSchema>["input"];
1014
+ errorBoundary?: AirJamAppErrorBoundaryOptions;
1015
+ }
1016
+ interface AirJamApp<TSchema extends z.ZodSchema = z.ZodSchema> {
1017
+ Host: (props: AirJamHostOptions & {
1018
+ children: ReactNode;
1019
+ }) => JSX.Element;
1020
+ Controller: (props: AirJamControllerOptions & {
1021
+ children: ReactNode;
1022
+ }) => JSX.Element;
1023
+ paths: {
1024
+ controller: string;
1025
+ };
1026
+ session: {
1027
+ host: HostSessionProps<TSchema>;
1028
+ controller: ControllerSessionProps;
1029
+ };
1030
+ runtime: ResolveAirJamConfigInput;
1031
+ metadata?: AirJamGameMetadata;
1032
+ controllerPath: string;
1033
+ capabilities?: AirJamGameCapabilityManifest;
1034
+ agent?: AirJamAgentContract;
1035
+ }
1036
+ type ViteEnvSource = Record<string, unknown> | undefined;
1037
+ declare const env: {
1038
+ readonly auto: () => ResolveAirJamConfigInput;
1039
+ readonly vite: (viteEnvInput?: ViteEnvSource) => ResolveAirJamConfigInput;
1040
+ readonly next: () => ResolveAirJamConfigInput;
1041
+ readonly explicit: (runtime: Omit<ResolveAirJamConfigInput, "resolveEnv">) => ResolveAirJamConfigInput;
1042
+ };
1043
+ declare const createAirJamApp: <TSchema extends z.ZodSchema = z.ZodSchema>({ runtime, metadata, controllerPath: requestedControllerPath, capabilities, agent, input, errorBoundary, }?: CreateAirJamAppOptions<TSchema>) => AirJamApp<TSchema>;
1044
+
1045
+ declare const resolveAirJamBrowserRouterBasename: () => string;
1046
+
1047
+ interface CreateAirJamStoreOptions {
1048
+ storeDomain?: string;
1049
+ }
1050
+ interface AirJamActionContext {
1051
+ actorId: string;
1052
+ role: AirJamActionActorRole;
1053
+ connectedPlayerIds: string[];
1054
+ }
1055
+ interface AirJamActionRejection {
1056
+ readonly __airJamActionRejection: true;
1057
+ reason: string;
1058
+ message: string;
1059
+ details?: AirJamActionPayload;
1060
+ }
1061
+ interface AirJamActionAcceptance<TResult = unknown> {
1062
+ readonly __airJamActionAcceptance: true;
1063
+ result?: TResult;
1064
+ }
1065
+ type AirJamActionHandler = (ctx: AirJamActionContext, payload: any) => unknown;
1066
+ type AirJamActionMap = Record<string, AirJamActionHandler>;
1067
+ type AirJamActionName<TActions extends AirJamActionMap> = Extract<keyof TActions, string>;
1068
+ type IsValidActionPayloadType<TPayload> = [TPayload] extends [undefined] ? true : TPayload extends readonly unknown[] ? false : TPayload extends object ? true : false;
1069
+ type InvalidActionPayloadKeys<TActions extends AirJamActionMap> = {
1070
+ [K in keyof TActions]: TActions[K] extends (ctx: AirJamActionContext, payload: infer TPayload) => unknown ? IsValidActionPayloadType<TPayload> extends true ? never : K : K;
1071
+ }[keyof TActions];
1072
+ type InvalidActionPayloadKeyNames<TActions extends AirJamActionMap> = Extract<InvalidActionPayloadKeys<TActions>, string>;
1073
+ type AirJamInvalidActionPayloadDiagnostic<TActions extends AirJamActionMap> = {
1074
+ readonly __airJamInvalidActionPayloads__: InvalidActionPayloadKeyNames<TActions>;
1075
+ readonly __airJamActionPayloadRule__: "Networked store action payloads must be omitted or one plain object payload. Unions like T | undefined, arrays, and primitives are not valid payload roots.";
1076
+ };
1077
+ type AirJamNetworkedState<TActions extends AirJamActionMap = AirJamActionMap> = {
1078
+ actions: TActions;
1079
+ };
1080
+ type AirJamActionDispatchMap<TActions extends AirJamActionMap> = {
1081
+ [K in keyof TActions]: TActions[K] extends (ctx: AirJamActionContext, payload: infer TPayload) => infer TResult ? [TPayload] extends [undefined] ? () => Promise<AirJamActionInvocationResult<InferAirJamActionResult<TResult>>> : TPayload extends readonly unknown[] ? never : TPayload extends object ? (payload: TPayload) => Promise<AirJamActionInvocationResult<InferAirJamActionResult<TResult>>> : never : never;
1082
+ };
1083
+ type InferAirJamActionResult<TResult> = TResult extends AirJamActionAcceptance<infer TAccepted> ? TAccepted : TResult extends AirJamActionRejection ? never : TResult;
1084
+ type AirJamHostActionEvent<TActions extends AirJamActionMap = AirJamActionMap, TActionName extends AirJamActionName<TActions> = AirJamActionName<TActions>> = TActionName extends AirJamActionName<TActions> ? TActions[TActionName] extends (ctx: AirJamActionContext, payload: infer TPayload) => infer TResult ? {
1085
+ actionName: TActionName;
1086
+ payload: TPayload;
1087
+ context: AirJamActionContext;
1088
+ acknowledgement: AirJamActionInvocationResult<InferAirJamActionResult<TResult>>;
1089
+ invocationKind: "local" | "rpc";
1090
+ roomId: string | null;
1091
+ storeDomain: string;
1092
+ } : never : never;
1093
+ interface AirJamHostActionSubscriptionOptions<TActions extends AirJamActionMap = AirJamActionMap> {
1094
+ actionNames?: readonly AirJamActionName<TActions>[];
1095
+ includeRejected?: boolean;
1096
+ }
1097
+ type AirJamHostActionListener<TActions extends AirJamActionMap = AirJamActionMap> = (event: AirJamHostActionEvent<TActions>) => void;
1098
+ type AirJamSyncedStoreHook<T extends AirJamNetworkedState> = {
1099
+ <U>(selector?: (state: T) => U): U;
1100
+ useActions: () => AirJamActionDispatchMap<T["actions"]>;
1101
+ asPlayer: (controllerId: string) => AirJamActionDispatchMap<T["actions"]>;
1102
+ getState: () => T;
1103
+ subscribe: StoreApi<T>["subscribe"];
1104
+ subscribeHostActions: (listener: AirJamHostActionListener<T["actions"]>, options?: AirJamHostActionSubscriptionOptions<T["actions"]>) => () => void;
1105
+ useHostActionListener: (listener: AirJamHostActionListener<T["actions"]>, options?: AirJamHostActionSubscriptionOptions<T["actions"]>) => void;
1106
+ useLiveStateRef: () => MutableRefObject<T>;
1107
+ };
1108
+ declare const acceptAirJamAction: <TResult = unknown>(result?: TResult) => AirJamActionAcceptance<TResult>;
1109
+ declare const rejectAirJamAction: (reason: string, message: string, details?: AirJamActionPayload) => AirJamActionRejection;
1110
+ /**
1111
+ * Creates a networked Zustand store that syncs state from host to controllers.
1112
+ *
1113
+ * Host is the source of truth:
1114
+ * - Host broadcasts state updates to all controllers.
1115
+ * - Controllers invoke actions through RPC to host.
1116
+ *
1117
+ * `storeDomain` isolates sync and action RPC so multiple replicated stores can coexist in one room
1118
+ * (e.g. arcade shell vs running game). When omitted, resolves from the runtime URL: explicit
1119
+ * `aj_store_domain`, else embedded Arcade identity (`aj_arcade_*`), else the default domain.
1120
+ */
1121
+ declare function createAirJamStore<T extends AirJamNetworkedState>(initializer: InvalidActionPayloadKeys<T["actions"]> extends never ? StateCreator<T> : StateCreator<T> & AirJamInvalidActionPayloadDiagnostic<T["actions"]>, options?: CreateAirJamStoreOptions): AirJamSyncedStoreHook<T>;
1122
+
1123
+ /**
1124
+ * Browser API type definitions for vendor-prefixed features
1125
+ * These extend standard DOM types to include vendor-specific APIs
1126
+ */
1127
+ /**
1128
+ * Document interface extended with vendor-prefixed fullscreen APIs
1129
+ */
1130
+ interface DocumentWithFullscreen extends Document {
1131
+ /** Webkit fullscreen element */
1132
+ webkitFullscreenElement?: Element;
1133
+ /** Mozilla fullscreen element */
1134
+ mozFullScreenElement?: Element;
1135
+ /** Microsoft fullscreen element */
1136
+ msFullscreenElement?: Element;
1137
+ /** Webkit exit fullscreen method */
1138
+ webkitExitFullscreen?: () => Promise<void>;
1139
+ /** Mozilla exit fullscreen method */
1140
+ mozCancelFullScreen?: () => Promise<void>;
1141
+ /** Microsoft exit fullscreen method */
1142
+ msExitFullscreen?: () => Promise<void>;
1143
+ }
1144
+ /**
1145
+ * HTMLElement interface extended with vendor-prefixed fullscreen request APIs
1146
+ */
1147
+ interface ElementWithFullscreen extends HTMLElement {
1148
+ /** Webkit request fullscreen method */
1149
+ webkitRequestFullscreen?: () => Promise<void>;
1150
+ /** Mozilla request fullscreen method */
1151
+ mozRequestFullScreen?: () => Promise<void>;
1152
+ /** Microsoft request fullscreen method */
1153
+ msRequestFullscreen?: () => Promise<void>;
1547
1154
  }
1548
- declare const urlBuilder: UrlBuilder;
1549
1155
 
1550
- export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions, type AirJamHostApi, type AirJamHostOptions, AirJamProvider, type AirJamProviderProps, type AirJamShellApi, type AirJamSocket, AudioManager, AudioProvider, Button, CONTROLLER_PATH, ChildEvents, ClientEvents, ClientToServerEvents, ConnectionRole, ConnectionStatus, ControllerEvents, ControllerInputEvent, ControllerInputPayload, ControllerShell, ControllerStatePayload, DEFAULT_MAX_PLAYERS, DEFAULT_SERVER_PORT, Events, GameState, HapticSignalPayload, HostEvents, HostShell, INPUT_DEBOUNCE_MS, type PlayOptions, PlayerAvatar, PlayerProfile, RoomCode, RunMode, SOCKET_CONFIG, type SendSignalFn, ServerEvents, ServerToClientEvents, Slider, SocketManager, type SoundCategory, type SoundConfig, type SoundManifest, SystemEvents, TOGGLE_DEBOUNCE_MS, ToastSignalPayload, UrlBuilder, VolumeControls, buttonVariants, createAirJamStore, createAudioManager, detectSoundCategory, generateControllerId, generateRoomCode, getLocalNetworkIp, urlBuilder, useAirJamConfig, useAirJamContext, useAirJamController, useAirJamHost, useAirJamShell, useAirJamSocket, useAirJamState, useAudio, useAudioLegacy, useAudioManager, useGetInput, useSendSignal, useVolumeStore };
1156
+ export { AIR_JAM_RUNTIME_INSPECTION_KEY, type AirJamActionAcceptance, type AirJamActionContext, AirJamActionInvocationResult, type AirJamActionRejection, AirJamAgentContract, type AirJamApp, type AirJamAppErrorBoundaryOptions, type AirJamControllerApi, type AirJamControllerOptions, AirJamControllerRuntime, type AirJamControllerRuntimeProps, type AirJamControllerState, type AirJamDiagnostic, type AirJamDiagnosticCode, type AirJamDiagnosticSeverity, AirJamErrorBoundary, type AirJamErrorBoundaryProps, type AirJamErrorFallbackRenderProps, type AirJamErrorFallbackRenderer, type AirJamHostActionEvent, type AirJamHostActionListener, type AirJamHostActionSubscriptionOptions, type AirJamHostApi, type AirJamHostOptions, AirJamHostRuntime, type AirJamHostRuntimeProps, type AirJamHostState, type AirJamRuntimeErrorBoundaryOptions, type AirJamRuntimeRole, type AirJamSyncedStoreHook, type AudioHandle, AudioRuntime, type AudioRuntimeControls, type AudioRuntimeProps, type AudioRuntimeStatus, type AudioVolumeCategory, ConnectionStatus, ControllerOrientation, type ControllerRuntimeInspectionContract, ControllerStatePayload, type ControllerTickInfo, type ControllerTickOptions, type ControllerToast, ControllerUpdatePlayerProfileAck, type CreateAirJamAppOptions, type CreateAirJamStoreOptions, type DocumentWithFullscreen, type ElementWithFullscreen, HapticSignalPayload, type HostFrameInfo, type HostRuntimeInspectionContract, type HostTickInfo, type HostTickOptions, type JoinUrlStatus, MusicPlaylist, type MusicPlaylistProps, type PlayOptions, PlayerProfile, PlayerProfilePatch, RoomCode, type RoomState, RunMode, type RuntimeInspectionContract, RuntimeState, type SendSignalFn, type SoundCategory, type SoundConfig, type SoundManifest, ToastSignalPayload, type UseControllerToastsOptions, acceptAirJamAction, createAirJamApp, createAirJamStore, createControllerRuntimeInspectionContract, createHostRuntimeInspectionContract, env, onAirJamDiagnostic, publishRuntimeInspectionContract, readRuntimeInspectionContract, rejectAirJamAction, resolveAirJamBrowserRouterBasename, setAirJamDiagnosticsEnabled, useAirJamController, useAirJamHost, useAudio, useAudioCategoryVolume, useAudioRuntimeControls, useAudioRuntimeStatus, useConnectionStatus, useControllerRuntimeInspectionContract, useControllerTick, useControllerToasts, useGetInput, useHostRuntimeInspectionContract, useHostTick, useInputWriter, useMusicVolume, usePlayers, useRoom, useSendSignal };