@air-jam/sdk 0.9.1 → 0.9.3

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 (247) hide show
  1. package/README.md +25 -45
  2. package/dist/{agent-tooling-BSMGBix9.d.cts → agent-contract-CD2QnbBJ.d.cts} +1 -1
  3. package/dist/{agent-tooling-BSMGBix9.d.ts → agent-contract-CD2QnbBJ.d.ts} +1 -1
  4. package/dist/agent-tooling.cjs +139 -0
  5. package/dist/agent-tooling.cjs.map +1 -1
  6. package/dist/agent-tooling.d.cts +25 -1
  7. package/dist/agent-tooling.d.ts +25 -1
  8. package/dist/agent-tooling.js +138 -0
  9. package/dist/agent-tooling.js.map +1 -1
  10. package/dist/air-jam-context-BlLPvCup.d.cts +175 -0
  11. package/dist/air-jam-context-DTsxF-tP.d.ts +175 -0
  12. package/dist/arcade/bridge/controller.cjs +214 -194
  13. package/dist/arcade/bridge/controller.cjs.map +1 -1
  14. package/dist/arcade/bridge/controller.d.cts +2 -2
  15. package/dist/arcade/bridge/controller.d.ts +2 -2
  16. package/dist/arcade/bridge/controller.js +6 -4
  17. package/dist/arcade/bridge/host.cjs +1 -1
  18. package/dist/arcade/bridge/host.cjs.map +1 -1
  19. package/dist/arcade/bridge/host.d.cts +3 -3
  20. package/dist/arcade/bridge/host.d.ts +3 -3
  21. package/dist/arcade/bridge/host.js +4 -3
  22. package/dist/arcade/bridge/iframe.cjs +1 -1
  23. package/dist/arcade/bridge/iframe.cjs.map +1 -1
  24. package/dist/arcade/bridge/iframe.d.cts +2 -2
  25. package/dist/arcade/bridge/iframe.d.ts +2 -2
  26. package/dist/arcade/bridge/iframe.js +4 -4
  27. package/dist/arcade/bridge.cjs +251 -231
  28. package/dist/arcade/bridge.cjs.map +1 -1
  29. package/dist/arcade/bridge.d.cts +4 -4
  30. package/dist/arcade/bridge.d.ts +4 -4
  31. package/dist/arcade/bridge.js +9 -7
  32. package/dist/arcade/host.cjs +145 -122
  33. package/dist/arcade/host.cjs.map +1 -1
  34. package/dist/arcade/host.d.cts +5 -4
  35. package/dist/arcade/host.d.ts +5 -4
  36. package/dist/arcade/host.js +6 -5
  37. package/dist/arcade/runtime.cjs +6499 -0
  38. package/dist/arcade/runtime.cjs.map +1 -0
  39. package/dist/arcade/runtime.d.cts +22 -0
  40. package/dist/arcade/runtime.d.ts +22 -0
  41. package/dist/arcade/runtime.js +32 -0
  42. package/dist/arcade/runtime.js.map +1 -0
  43. package/dist/arcade/surface.cjs +9 -0
  44. package/dist/arcade/surface.cjs.map +1 -1
  45. package/dist/arcade/surface.d.cts +6 -1
  46. package/dist/arcade/surface.d.ts +6 -1
  47. package/dist/arcade/surface.js +6 -2
  48. package/dist/arcade/url.d.cts +4 -4
  49. package/dist/arcade/url.d.ts +4 -4
  50. package/dist/arcade/url.js +5 -5
  51. package/dist/arcade.cjs +322 -292
  52. package/dist/arcade.cjs.map +1 -1
  53. package/dist/arcade.d.cts +6 -6
  54. package/dist/arcade.d.ts +6 -6
  55. package/dist/arcade.js +35 -29
  56. package/dist/{chunk-CEJ5RFSG.js → chunk-2SZ2YYGJ.js} +8 -16
  57. package/dist/chunk-2SZ2YYGJ.js.map +1 -0
  58. package/dist/{chunk-VKBMZHMQ.js → chunk-32RSSFSF.js} +10 -12
  59. package/dist/chunk-32RSSFSF.js.map +1 -0
  60. package/dist/chunk-3YMUAKPU.js +10 -0
  61. package/dist/chunk-3YMUAKPU.js.map +1 -0
  62. package/dist/chunk-56DM2KEW.js +14 -0
  63. package/dist/chunk-56DM2KEW.js.map +1 -0
  64. package/dist/chunk-CM53YLT5.js +59 -0
  65. package/dist/chunk-CM53YLT5.js.map +1 -0
  66. package/dist/{chunk-JEHV5C2X.js → chunk-CV3PBXPT.js} +3 -3
  67. package/dist/chunk-D4VDEVTZ.js +80 -0
  68. package/dist/chunk-D4VDEVTZ.js.map +1 -0
  69. package/dist/{chunk-W3YA5BWR.js → chunk-FUA6EMSJ.js} +24 -60
  70. package/dist/chunk-FUA6EMSJ.js.map +1 -0
  71. package/dist/chunk-GMLU7RI5.js +70 -0
  72. package/dist/chunk-GMLU7RI5.js.map +1 -0
  73. package/dist/{chunk-NCL6WJCL.js → chunk-IG6GZZSS.js} +32 -1
  74. package/dist/chunk-IG6GZZSS.js.map +1 -0
  75. package/dist/{chunk-EDRQIOCV.js → chunk-ITMQSBTH.js} +3 -2
  76. package/dist/chunk-ITMQSBTH.js.map +1 -0
  77. package/dist/{chunk-32NYL7XI.js → chunk-J5MCII33.js} +189 -108
  78. package/dist/chunk-J5MCII33.js.map +1 -0
  79. package/dist/{chunk-ZLPL2R3R.js → chunk-K4OZ54UD.js} +7 -34
  80. package/dist/chunk-K4OZ54UD.js.map +1 -0
  81. package/dist/{chunk-KXAFI5OP.js → chunk-LIHEEAVE.js} +9 -11
  82. package/dist/chunk-LIHEEAVE.js.map +1 -0
  83. package/dist/{chunk-FAT2KJ3K.js → chunk-MIMPMB7O.js} +2 -2
  84. package/dist/{chunk-NUJBMV3O.js → chunk-O6X7FJ6N.js} +29 -32
  85. package/dist/chunk-O6X7FJ6N.js.map +1 -0
  86. package/dist/chunk-PSUYTD2L.js +16 -0
  87. package/dist/chunk-PSUYTD2L.js.map +1 -0
  88. package/dist/{chunk-7UXSWCZZ.js → chunk-QO4KFUEI.js} +2 -2
  89. package/dist/chunk-QTLYZADF.js +125 -0
  90. package/dist/chunk-QTLYZADF.js.map +1 -0
  91. package/dist/chunk-TTQDHKXL.js +3017 -0
  92. package/dist/chunk-TTQDHKXL.js.map +1 -0
  93. package/dist/chunk-UCPY7UJC.js +8 -0
  94. package/dist/chunk-UCPY7UJC.js.map +1 -0
  95. package/dist/{chunk-JO2HR5PV.js → chunk-UPV6YWT5.js} +4 -4
  96. package/dist/chunk-X35LLCWV.js +65 -0
  97. package/dist/chunk-X35LLCWV.js.map +1 -0
  98. package/dist/{controller-DxVchfiA.d.ts → controller-PZEM_1cH.d.ts} +6 -2
  99. package/dist/{controller-Bod8YYr1.d.cts → controller-vj82tKm4.d.cts} +6 -2
  100. package/dist/{dev-log-events-CVAM29hx.d.cts → dev-log-events-BCJKmygo.d.cts} +0 -3
  101. package/dist/{dev-log-events-CVAM29hx.d.ts → dev-log-events-BCJKmygo.d.ts} +0 -3
  102. package/dist/{host-8hmq_Sgc.d.cts → host-B9pRy0Aa.d.cts} +20 -7
  103. package/dist/{host-Cw-N6e-5.d.ts → host-DylGsX7p.d.ts} +20 -7
  104. package/dist/index.cjs +4275 -3813
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.cts +40 -642
  107. package/dist/index.d.ts +40 -642
  108. package/dist/index.js +1032 -3658
  109. package/dist/index.js.map +1 -1
  110. package/dist/metadata.cjs.map +1 -1
  111. package/dist/metadata.d.cts +2 -3
  112. package/dist/metadata.d.ts +2 -3
  113. package/dist/metadata.js.map +1 -1
  114. package/dist/{notices-CnGaaS8B.d.ts → notices-C4bao3oi.d.ts} +1 -1
  115. package/dist/{notices-NyDM5Mtz.d.cts → notices-DNdOjwtj.d.cts} +1 -1
  116. package/dist/platform-machine.cjs +115 -15
  117. package/dist/platform-machine.cjs.map +1 -1
  118. package/dist/platform-machine.d.cts +1338 -65
  119. package/dist/platform-machine.d.ts +1338 -65
  120. package/dist/platform-machine.js +88 -15
  121. package/dist/platform-machine.js.map +1 -1
  122. package/dist/{platform-settings-cuor3i11.d.cts → platform-settings-DUWs4JTy.d.cts} +1 -1
  123. package/dist/{platform-settings-cuor3i11.d.ts → platform-settings-DUWs4JTy.d.ts} +1 -1
  124. package/dist/preview.cjs +301 -253
  125. package/dist/preview.cjs.map +1 -1
  126. package/dist/preview.d.cts +6 -4
  127. package/dist/preview.d.ts +6 -4
  128. package/dist/preview.js +31 -21
  129. package/dist/preview.js.map +1 -1
  130. package/dist/protocol.cjs +282 -167
  131. package/dist/protocol.cjs.map +1 -1
  132. package/dist/protocol.d.cts +74 -21
  133. package/dist/protocol.d.ts +74 -21
  134. package/dist/protocol.js +28 -10
  135. package/dist/release.cjs +37 -0
  136. package/dist/release.cjs.map +1 -1
  137. package/dist/release.d.cts +27 -1
  138. package/dist/release.d.ts +27 -1
  139. package/dist/release.js +13 -1
  140. package/dist/runtime-control.cjs +46 -0
  141. package/dist/runtime-control.cjs.map +1 -0
  142. package/dist/runtime-control.d.cts +17 -0
  143. package/dist/runtime-control.d.ts +17 -0
  144. package/dist/runtime-control.js +8 -0
  145. package/dist/runtime-control.js.map +1 -0
  146. package/dist/runtime-inspection.cjs +655 -0
  147. package/dist/runtime-inspection.cjs.map +1 -0
  148. package/dist/runtime-inspection.d.cts +47 -0
  149. package/dist/runtime-inspection.d.ts +47 -0
  150. package/dist/runtime-inspection.js +30 -0
  151. package/dist/runtime-inspection.js.map +1 -0
  152. package/dist/runtime-reporting-pe-eryVz.d.cts +27 -0
  153. package/dist/runtime-reporting-pe-eryVz.d.ts +27 -0
  154. package/dist/signals-ZHftIKuc.d.cts +33 -0
  155. package/dist/signals-ZHftIKuc.d.ts +33 -0
  156. package/dist/{standard-match-phase-BucA5dYo.d.ts → standard-match-phase-BzSgBYFg.d.ts} +2 -2
  157. package/dist/{standard-match-phase-U2ra8J-0.d.cts → standard-match-phase-CvJUW8Oe.d.cts} +2 -2
  158. package/dist/{sync-B6QsNrXz.d.cts → sync-xtPfWhif.d.cts} +1 -45
  159. package/dist/{sync-B6QsNrXz.d.ts → sync-xtPfWhif.d.ts} +1 -45
  160. package/dist/ui.cjs +689 -629
  161. package/dist/ui.cjs.map +1 -1
  162. package/dist/ui.d.cts +14 -4
  163. package/dist/ui.d.ts +14 -4
  164. package/dist/ui.js +117 -35
  165. package/dist/ui.js.map +1 -1
  166. package/dist/use-air-jam-host-COLy8t4s.d.ts +403 -0
  167. package/dist/use-air-jam-host-DM-ybB3C.d.cts +403 -0
  168. package/package.json +55 -21
  169. package/src/agent/agent-contract-conformance.ts +201 -0
  170. package/src/agent-tooling.ts +5 -0
  171. package/src/arcade/runtime.ts +6 -0
  172. package/src/arcade/surface.ts +1 -0
  173. package/src/components/join-qr-overlay.tsx +115 -31
  174. package/src/context/air-jam-context.tsx +8 -8
  175. package/src/context/socket-manager.ts +0 -7
  176. package/src/dev/browser-log-sink.ts +12 -15
  177. package/src/events.ts +0 -5
  178. package/src/hooks/internal/use-controller-runtime-api.ts +110 -21
  179. package/src/hooks/internal/use-host-runtime-api.ts +306 -49
  180. package/src/hooks/use-air-jam-controller.ts +9 -9
  181. package/src/hooks/use-air-jam-host.ts +7 -7
  182. package/src/hooks/use-get-input.ts +1 -1
  183. package/src/hooks/use-host-arcade-restore.ts +6 -1
  184. package/src/hooks/use-host-audio-mute-preference.ts +99 -0
  185. package/src/index.ts +6 -21
  186. package/src/metadata/manifest.ts +2 -3
  187. package/src/platform-machine.ts +109 -12
  188. package/src/preview/workspace.tsx +48 -29
  189. package/src/protocol/arcade-platform-actions.ts +19 -1
  190. package/src/protocol/controller.ts +8 -2
  191. package/src/protocol/dev-log-events.ts +0 -3
  192. package/src/protocol/host-grant.ts +58 -140
  193. package/src/protocol/host.ts +21 -9
  194. package/src/protocol/runtime-reporting.ts +32 -0
  195. package/src/protocol/signed-envelope.ts +176 -0
  196. package/src/protocol/socket-events.ts +8 -10
  197. package/src/protocol/sync.ts +0 -16
  198. package/src/protocol.ts +2 -0
  199. package/src/release.ts +32 -0
  200. package/src/runtime/admission-retry.ts +62 -0
  201. package/src/runtime/air-jam-config.ts +6 -16
  202. package/src/runtime/air-jam-error-boundary.tsx +46 -2
  203. package/src/runtime/bridge-envelope-args.ts +21 -0
  204. package/src/runtime/connected-runtime-error-boundary.tsx +31 -0
  205. package/src/runtime/contracts/control.ts +107 -59
  206. package/src/runtime/controller-bridge.ts +12 -24
  207. package/src/runtime/controller-identity.ts +55 -27
  208. package/src/runtime/controller-realtime-client.ts +8 -47
  209. package/src/runtime/create-air-jam-app.tsx +21 -13
  210. package/src/runtime/host-bridge.ts +16 -24
  211. package/src/runtime/local-reference-game-identity.ts +13 -0
  212. package/src/runtime/runtime-session-params.ts +4 -64
  213. package/src/runtime-control.ts +3 -8
  214. package/src/settings/platform-settings-runtime.tsx +1 -6
  215. package/src/settings/platform-settings.ts +7 -38
  216. package/src/state/connection-store.ts +13 -6
  217. package/src/store/create-air-jam-store.ts +59 -7
  218. package/src/utils/ids.ts +32 -5
  219. package/dist/capabilities.cjs +0 -39
  220. package/dist/capabilities.cjs.map +0 -1
  221. package/dist/capabilities.d.cts +0 -31
  222. package/dist/capabilities.d.ts +0 -31
  223. package/dist/capabilities.js +0 -12
  224. package/dist/capabilities.js.map +0 -1
  225. package/dist/chunk-32NYL7XI.js.map +0 -1
  226. package/dist/chunk-CABEUV65.js +0 -184
  227. package/dist/chunk-CABEUV65.js.map +0 -1
  228. package/dist/chunk-CEJ5RFSG.js.map +0 -1
  229. package/dist/chunk-EDRQIOCV.js.map +0 -1
  230. package/dist/chunk-KXAFI5OP.js.map +0 -1
  231. package/dist/chunk-NCL6WJCL.js.map +0 -1
  232. package/dist/chunk-NUJBMV3O.js.map +0 -1
  233. package/dist/chunk-VKBMZHMQ.js.map +0 -1
  234. package/dist/chunk-W3YA5BWR.js.map +0 -1
  235. package/dist/chunk-ZLPL2R3R.js.map +0 -1
  236. package/dist/chunk-ZTQ5SP4H.js +0 -9
  237. package/dist/chunk-ZTQ5SP4H.js.map +0 -1
  238. package/src/capabilities/manifest.ts +0 -71
  239. package/src/capabilities.ts +0 -12
  240. package/src/hooks/internal/use-runtime-control-contract.ts +0 -15
  241. package/src/hooks/internal/use-runtime-observability-contract.ts +0 -24
  242. package/src/runtime/contracts/observability.ts +0 -94
  243. package/src/runtime-observability.ts +0 -9
  244. /package/dist/{chunk-JEHV5C2X.js.map → chunk-CV3PBXPT.js.map} +0 -0
  245. /package/dist/{chunk-FAT2KJ3K.js.map → chunk-MIMPMB7O.js.map} +0 -0
  246. /package/dist/{chunk-7UXSWCZZ.js.map → chunk-QO4KFUEI.js.map} +0 -0
  247. /package/dist/{chunk-JO2HR5PV.js.map → chunk-UPV6YWT5.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/agent/agent-contract-conformance.ts"],"sourcesContent":["import {\n describeAirJamAgentAction,\n resolveAirJamAgentActionPayload,\n type AnyAirJamAgentContract,\n} from \"./agent-contract.js\";\n\nexport type AirJamAgentContractConformanceIssue = {\n code:\n | \"store-domain-mismatch\"\n | \"missing-store-actions\"\n | \"missing-target-action\"\n | \"invalid-action-metadata\"\n | \"payload-parse-failed\"\n | \"snapshot-failed\"\n | \"snapshot-not-json\";\n path: string;\n message: string;\n};\n\nexport type AirJamAgentContractConformanceReport = {\n schemaVersion: 1;\n gameId: string;\n ok: boolean;\n storeDomains: string[];\n actionNames: string[];\n issues: AirJamAgentContractConformanceIssue[];\n};\n\ntype InspectAirJamAgentContractConformanceOptions = {\n gameId: string;\n contract: AnyAirJamAgentContract;\n stores: Record<string, object>;\n controllerId?: string | null;\n};\n\nconst representativePayload = (\n kind: ReturnType<typeof describeAirJamAgentAction>[\"payload\"][\"kind\"],\n allowedValues?: string[],\n): unknown => {\n switch (kind) {\n case \"none\":\n return undefined;\n case \"boolean\":\n return true;\n case \"number\":\n return 1;\n case \"string\":\n return \"conformance\";\n case \"enum\":\n return allowedValues?.[0];\n case \"json\":\n return {};\n }\n};\n\nconst inspectJsonValue = (\n value: unknown,\n path: string,\n seen: Set<object>,\n issues: AirJamAgentContractConformanceIssue[],\n): void => {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n ) {\n return;\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n issues.push({\n code: \"snapshot-not-json\",\n path,\n message: \"Snapshot numbers must be finite.\",\n });\n }\n return;\n }\n if (typeof value !== \"object\") {\n issues.push({\n code: \"snapshot-not-json\",\n path,\n message: `Snapshot value has unsupported type ${typeof value}.`,\n });\n return;\n }\n if (seen.has(value)) {\n issues.push({\n code: \"snapshot-not-json\",\n path,\n message: \"Snapshot contains a circular reference.\",\n });\n return;\n }\n\n seen.add(value);\n if (Array.isArray(value)) {\n value.forEach((entry, index) =>\n inspectJsonValue(entry, `${path}[${index}]`, seen, issues),\n );\n } else {\n for (const [key, entry] of Object.entries(value)) {\n inspectJsonValue(entry, `${path}.${key}`, seen, issues);\n }\n }\n seen.delete(value);\n};\n\nexport const inspectAirJamAgentContractConformance = async ({\n gameId,\n contract,\n stores,\n controllerId = \"conformance-controller\",\n}: InspectAirJamAgentContractConformanceOptions): Promise<AirJamAgentContractConformanceReport> => {\n const issues: AirJamAgentContractConformanceIssue[] = [];\n const storeDomains = Object.keys(contract.stores).sort();\n const runtimeStoreDomains = Object.keys(stores).sort();\n const actionNames = Object.keys(contract.actions).sort();\n\n if (JSON.stringify(storeDomains) !== JSON.stringify(runtimeStoreDomains)) {\n issues.push({\n code: \"store-domain-mismatch\",\n path: \"stores\",\n message: `Declared domains [${storeDomains.join(\", \")}] do not match runtime domains [${runtimeStoreDomains.join(\", \")}].`,\n });\n }\n\n for (const [actionName, action] of Object.entries(contract.actions)) {\n const targetDomain = action.target.storeDomain ?? \"default\";\n const runtimeStore = stores[targetDomain] as\n | { actions?: Record<string, unknown> }\n | undefined;\n if (!runtimeStore?.actions || typeof runtimeStore.actions !== \"object\") {\n issues.push({\n code: \"missing-store-actions\",\n path: `actions.${actionName}.target`,\n message: `Runtime store \"${targetDomain}\" does not expose an actions object.`,\n });\n } else if (\n typeof runtimeStore.actions[action.target.actionName] !== \"function\"\n ) {\n issues.push({\n code: \"missing-target-action\",\n path: `actions.${actionName}.target`,\n message: `Runtime store \"${targetDomain}\" does not expose action \"${action.target.actionName}\".`,\n });\n }\n\n const metadata = describeAirJamAgentAction(action);\n if (\n !metadata.description?.trim() ||\n !metadata.resultDescription?.trim() ||\n (metadata.payload.kind === \"enum\" &&\n !metadata.payload.allowedValues?.length)\n ) {\n issues.push({\n code: \"invalid-action-metadata\",\n path: `actions.${actionName}`,\n message:\n \"Every semantic action must describe its intent, expected result, and enum values when applicable.\",\n });\n }\n\n try {\n resolveAirJamAgentActionPayload(\n action,\n representativePayload(\n metadata.payload.kind,\n metadata.payload.allowedValues,\n ),\n { gameId, actionName, contractKind: \"conformance\" },\n );\n } catch (error) {\n issues.push({\n code: \"payload-parse-failed\",\n path: `actions.${actionName}.input`,\n message: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n try {\n const snapshot = await contract.projectSnapshot({ controllerId, stores });\n inspectJsonValue(snapshot, \"snapshot\", new Set(), issues);\n } catch (error) {\n issues.push({\n code: \"snapshot-failed\",\n path: \"snapshot\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n\n return {\n schemaVersion: 1,\n gameId,\n ok: issues.length === 0,\n storeDomains,\n actionNames,\n issues,\n };\n};\n"],"mappings":";;;;;;;;;;AAmCA,IAAM,wBAAwB,CAC5B,MACA,kBACY;AACZ,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,gBAAgB,CAAC;AAAA,IAC1B,KAAK;AACH,aAAO,CAAC;AAAA,EACZ;AACF;AAEA,IAAM,mBAAmB,CACvB,OACA,MACA,MACA,WACS;AACT,MACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA;AAAA,EACF;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN;AAAA,QACA,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AACA;AAAA,EACF;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,KAAK;AAAA,MACV,MAAM;AAAA,MACN;AAAA,MACA,SAAS,uCAAuC,OAAO,KAAK;AAAA,IAC9D,CAAC;AACD;AAAA,EACF;AACA,MAAI,KAAK,IAAI,KAAK,GAAG;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;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,175 @@
1
+ import { ReactNode } from 'react';
2
+ import { z } from 'zod';
3
+ import { H as HostSessionKind } from './host-B9pRy0Aa.cjs';
4
+ import { RuntimeTopologyInput, ResolvedAirJamRuntimeTopology, SurfaceRole } from './runtime-topology.cjs';
5
+
6
+ /**
7
+ * @module InputManager
8
+ * @description Internal input runtime used by host hooks.
9
+ *
10
+ * Public API terms:
11
+ * - `pulse`: consume-on-read, tap-safe behavior (default for booleans)
12
+ * - `hold`: keep last active vector until a new active value arrives
13
+ * - `latest`: read current value as-is (default for vectors and other fields)
14
+ *
15
+ * @internal This class is not exported publicly. Use hooks to access input.
16
+ */
17
+
18
+ /**
19
+ * Configuration for input handling with optional validation and per-field behavior.
20
+ *
21
+ * Provided to `HostSessionProvider` to enable typed and behavior-aware input reads.
22
+ *
23
+ * @template TSchema - Zod schema type for input validation
24
+ *
25
+ * @example Basic schema validation
26
+ * ```ts
27
+ * const config: InputConfig = {
28
+ * schema: z.object({
29
+ * vector: z.object({ x: z.number(), y: z.number() }),
30
+ * action: z.boolean(),
31
+ * }),
32
+ * };
33
+ * ```
34
+ *
35
+ * @example With custom behavior overrides
36
+ * ```ts
37
+ * const config: InputConfig = {
38
+ * schema: gameInputSchema,
39
+ * behavior: {
40
+ * pulse: ["action", "ability"], // consume-on-read
41
+ * latest: ["aim"], // read latest value
42
+ * hold: ["menuVector"], // keep last non-zero vector
43
+ * },
44
+ * };
45
+ * ```
46
+ */
47
+ interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
48
+ /**
49
+ * Zod schema for input validation and type inference.
50
+ *
51
+ * When provided:
52
+ * - Incoming input is validated against the schema
53
+ * - Invalid input returns `undefined` (with console warning)
54
+ * - Return type is inferred from the schema
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * schema: z.object({
59
+ * vector: z.object({ x: z.number(), y: z.number() }),
60
+ * action: z.boolean(),
61
+ * ability: z.boolean(),
62
+ * timestamp: z.number(),
63
+ * })
64
+ * ```
65
+ */
66
+ schema?: TSchema;
67
+ behavior?: {
68
+ /**
69
+ * Consume-on-read behavior. Useful for tap-safe buttons and one-shot vectors.
70
+ *
71
+ * Defaults: booleans use `pulse` even without explicit config.
72
+ */
73
+ pulse?: string[];
74
+ /**
75
+ * Sticky behavior. For vectors, keeps the last non-zero direction until
76
+ * another non-zero direction arrives.
77
+ */
78
+ hold?: string[];
79
+ /**
80
+ * Stateless behavior. Returns the latest raw value.
81
+ *
82
+ * Defaults: vectors and non-boolean fields use `latest`.
83
+ */
84
+ latest?: string[];
85
+ };
86
+ }
87
+
88
+ /**
89
+ * Props for the AirJamProvider component.
90
+ *
91
+ * @template TSchema - Zod schema type for input validation (inferred from input.schema)
92
+ *
93
+ * @example Minimal configuration (uses environment variables)
94
+ * ```tsx
95
+ * <HostSessionProvider>
96
+ * <App />
97
+ * </HostSessionProvider>
98
+ * ```
99
+ *
100
+ * @example Full configuration
101
+ * ```tsx
102
+ * <HostSessionProvider
103
+ * topology={myTopology}
104
+ * appId="your-app-id"
105
+ * hostGrantEndpoint="/api/airjam/host-grant"
106
+ * maxPlayers={4}
107
+ * input={{
108
+ * schema: myInputSchema,
109
+ * behavior: { pulse: ["fire"], latest: ["move"] },
110
+ * }}
111
+ * >
112
+ * <App />
113
+ * </HostSessionProvider>
114
+ * ```
115
+ */
116
+ interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
117
+ /** React children to render within the provider */
118
+ children: ReactNode;
119
+ /** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
120
+ topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
121
+ /** Internal surface-role hint used while resolving topology. */
122
+ surfaceRole?: SurfaceRole;
123
+ /**
124
+ * App ID for production bootstrap identity.
125
+ * Falls back to VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID
126
+ * when not provided directly.
127
+ */
128
+ appId?: string;
129
+ /**
130
+ * Optional endpoint that returns a short-lived signed host grant for stronger production bootstrap.
131
+ * When provided, the host runtime fetches a grant automatically before `host:bootstrap`.
132
+ */
133
+ hostGrantEndpoint?: string;
134
+ /**
135
+ * Maximum number of players allowed in a room.
136
+ * @default 8
137
+ */
138
+ maxPlayers?: number;
139
+ /**
140
+ * Declares whether this host provider owns a standalone game room or a system shell room.
141
+ * Standalone games should use `"game"`; Arcade shell hosts should use `"system"`.
142
+ * @default "game"
143
+ */
144
+ hostSessionKind?: HostSessionKind;
145
+ /**
146
+ * Enable environment-variable fallback resolution for config fields.
147
+ * Set to false to require explicit `topology` / `appId` / `hostGrantEndpoint`.
148
+ * @default true
149
+ */
150
+ resolveEnv?: boolean;
151
+ /**
152
+ * Input handling configuration including Zod schema validation and field behavior.
153
+ * When provided, enables typed input with tap-safe defaults:
154
+ * - booleans => `pulse`
155
+ * - vectors => `latest`
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * input={{
160
+ * schema: z.object({
161
+ * vector: z.object({ x: z.number(), y: z.number() }),
162
+ * action: z.boolean(),
163
+ * ability: z.boolean(),
164
+ * }),
165
+ * behavior: {
166
+ * pulse: ["action", "ability"], // consume-on-read actions
167
+ * latest: ["vector"], // continuous movement
168
+ * },
169
+ * }}
170
+ * ```
171
+ */
172
+ input?: InputConfig<TSchema>;
173
+ }
174
+
175
+ export type { AirJamProviderProps as A };
@@ -0,0 +1,175 @@
1
+ import { ReactNode } from 'react';
2
+ import { z } from 'zod';
3
+ import { H as HostSessionKind } from './host-DylGsX7p.js';
4
+ import { RuntimeTopologyInput, ResolvedAirJamRuntimeTopology, SurfaceRole } from './runtime-topology.js';
5
+
6
+ /**
7
+ * @module InputManager
8
+ * @description Internal input runtime used by host hooks.
9
+ *
10
+ * Public API terms:
11
+ * - `pulse`: consume-on-read, tap-safe behavior (default for booleans)
12
+ * - `hold`: keep last active vector until a new active value arrives
13
+ * - `latest`: read current value as-is (default for vectors and other fields)
14
+ *
15
+ * @internal This class is not exported publicly. Use hooks to access input.
16
+ */
17
+
18
+ /**
19
+ * Configuration for input handling with optional validation and per-field behavior.
20
+ *
21
+ * Provided to `HostSessionProvider` to enable typed and behavior-aware input reads.
22
+ *
23
+ * @template TSchema - Zod schema type for input validation
24
+ *
25
+ * @example Basic schema validation
26
+ * ```ts
27
+ * const config: InputConfig = {
28
+ * schema: z.object({
29
+ * vector: z.object({ x: z.number(), y: z.number() }),
30
+ * action: z.boolean(),
31
+ * }),
32
+ * };
33
+ * ```
34
+ *
35
+ * @example With custom behavior overrides
36
+ * ```ts
37
+ * const config: InputConfig = {
38
+ * schema: gameInputSchema,
39
+ * behavior: {
40
+ * pulse: ["action", "ability"], // consume-on-read
41
+ * latest: ["aim"], // read latest value
42
+ * hold: ["menuVector"], // keep last non-zero vector
43
+ * },
44
+ * };
45
+ * ```
46
+ */
47
+ interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
48
+ /**
49
+ * Zod schema for input validation and type inference.
50
+ *
51
+ * When provided:
52
+ * - Incoming input is validated against the schema
53
+ * - Invalid input returns `undefined` (with console warning)
54
+ * - Return type is inferred from the schema
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * schema: z.object({
59
+ * vector: z.object({ x: z.number(), y: z.number() }),
60
+ * action: z.boolean(),
61
+ * ability: z.boolean(),
62
+ * timestamp: z.number(),
63
+ * })
64
+ * ```
65
+ */
66
+ schema?: TSchema;
67
+ behavior?: {
68
+ /**
69
+ * Consume-on-read behavior. Useful for tap-safe buttons and one-shot vectors.
70
+ *
71
+ * Defaults: booleans use `pulse` even without explicit config.
72
+ */
73
+ pulse?: string[];
74
+ /**
75
+ * Sticky behavior. For vectors, keeps the last non-zero direction until
76
+ * another non-zero direction arrives.
77
+ */
78
+ hold?: string[];
79
+ /**
80
+ * Stateless behavior. Returns the latest raw value.
81
+ *
82
+ * Defaults: vectors and non-boolean fields use `latest`.
83
+ */
84
+ latest?: string[];
85
+ };
86
+ }
87
+
88
+ /**
89
+ * Props for the AirJamProvider component.
90
+ *
91
+ * @template TSchema - Zod schema type for input validation (inferred from input.schema)
92
+ *
93
+ * @example Minimal configuration (uses environment variables)
94
+ * ```tsx
95
+ * <HostSessionProvider>
96
+ * <App />
97
+ * </HostSessionProvider>
98
+ * ```
99
+ *
100
+ * @example Full configuration
101
+ * ```tsx
102
+ * <HostSessionProvider
103
+ * topology={myTopology}
104
+ * appId="your-app-id"
105
+ * hostGrantEndpoint="/api/airjam/host-grant"
106
+ * maxPlayers={4}
107
+ * input={{
108
+ * schema: myInputSchema,
109
+ * behavior: { pulse: ["fire"], latest: ["move"] },
110
+ * }}
111
+ * >
112
+ * <App />
113
+ * </HostSessionProvider>
114
+ * ```
115
+ */
116
+ interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
117
+ /** React children to render within the provider */
118
+ children: ReactNode;
119
+ /** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
120
+ topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
121
+ /** Internal surface-role hint used while resolving topology. */
122
+ surfaceRole?: SurfaceRole;
123
+ /**
124
+ * App ID for production bootstrap identity.
125
+ * Falls back to VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID
126
+ * when not provided directly.
127
+ */
128
+ appId?: string;
129
+ /**
130
+ * Optional endpoint that returns a short-lived signed host grant for stronger production bootstrap.
131
+ * When provided, the host runtime fetches a grant automatically before `host:bootstrap`.
132
+ */
133
+ hostGrantEndpoint?: string;
134
+ /**
135
+ * Maximum number of players allowed in a room.
136
+ * @default 8
137
+ */
138
+ maxPlayers?: number;
139
+ /**
140
+ * Declares whether this host provider owns a standalone game room or a system shell room.
141
+ * Standalone games should use `"game"`; Arcade shell hosts should use `"system"`.
142
+ * @default "game"
143
+ */
144
+ hostSessionKind?: HostSessionKind;
145
+ /**
146
+ * Enable environment-variable fallback resolution for config fields.
147
+ * Set to false to require explicit `topology` / `appId` / `hostGrantEndpoint`.
148
+ * @default true
149
+ */
150
+ resolveEnv?: boolean;
151
+ /**
152
+ * Input handling configuration including Zod schema validation and field behavior.
153
+ * When provided, enables typed input with tap-safe defaults:
154
+ * - booleans => `pulse`
155
+ * - vectors => `latest`
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * input={{
160
+ * schema: z.object({
161
+ * vector: z.object({ x: z.number(), y: z.number() }),
162
+ * action: z.boolean(),
163
+ * ability: z.boolean(),
164
+ * }),
165
+ * behavior: {
166
+ * pulse: ["action", "ability"], // consume-on-read actions
167
+ * latest: ["vector"], // continuous movement
168
+ * },
169
+ * }}
170
+ * ```
171
+ */
172
+ input?: InputConfig<TSchema>;
173
+ }
174
+
175
+ export type { AirJamProviderProps as A };