@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
@@ -0,0 +1,201 @@
1
+ import {
2
+ describeAirJamAgentAction,
3
+ resolveAirJamAgentActionPayload,
4
+ type AnyAirJamAgentContract,
5
+ } from "./agent-contract.js";
6
+
7
+ export type AirJamAgentContractConformanceIssue = {
8
+ code:
9
+ | "store-domain-mismatch"
10
+ | "missing-store-actions"
11
+ | "missing-target-action"
12
+ | "invalid-action-metadata"
13
+ | "payload-parse-failed"
14
+ | "snapshot-failed"
15
+ | "snapshot-not-json";
16
+ path: string;
17
+ message: string;
18
+ };
19
+
20
+ export type AirJamAgentContractConformanceReport = {
21
+ schemaVersion: 1;
22
+ gameId: string;
23
+ ok: boolean;
24
+ storeDomains: string[];
25
+ actionNames: string[];
26
+ issues: AirJamAgentContractConformanceIssue[];
27
+ };
28
+
29
+ type InspectAirJamAgentContractConformanceOptions = {
30
+ gameId: string;
31
+ contract: AnyAirJamAgentContract;
32
+ stores: Record<string, object>;
33
+ controllerId?: string | null;
34
+ };
35
+
36
+ const representativePayload = (
37
+ kind: ReturnType<typeof describeAirJamAgentAction>["payload"]["kind"],
38
+ allowedValues?: string[],
39
+ ): unknown => {
40
+ switch (kind) {
41
+ case "none":
42
+ return undefined;
43
+ case "boolean":
44
+ return true;
45
+ case "number":
46
+ return 1;
47
+ case "string":
48
+ return "conformance";
49
+ case "enum":
50
+ return allowedValues?.[0];
51
+ case "json":
52
+ return {};
53
+ }
54
+ };
55
+
56
+ const inspectJsonValue = (
57
+ value: unknown,
58
+ path: string,
59
+ seen: Set<object>,
60
+ issues: AirJamAgentContractConformanceIssue[],
61
+ ): void => {
62
+ if (
63
+ value === null ||
64
+ typeof value === "string" ||
65
+ typeof value === "boolean"
66
+ ) {
67
+ return;
68
+ }
69
+ if (typeof value === "number") {
70
+ if (!Number.isFinite(value)) {
71
+ issues.push({
72
+ code: "snapshot-not-json",
73
+ path,
74
+ message: "Snapshot numbers must be finite.",
75
+ });
76
+ }
77
+ return;
78
+ }
79
+ if (typeof value !== "object") {
80
+ issues.push({
81
+ code: "snapshot-not-json",
82
+ path,
83
+ message: `Snapshot value has unsupported type ${typeof value}.`,
84
+ });
85
+ return;
86
+ }
87
+ if (seen.has(value)) {
88
+ issues.push({
89
+ code: "snapshot-not-json",
90
+ path,
91
+ message: "Snapshot contains a circular reference.",
92
+ });
93
+ return;
94
+ }
95
+
96
+ seen.add(value);
97
+ if (Array.isArray(value)) {
98
+ value.forEach((entry, index) =>
99
+ inspectJsonValue(entry, `${path}[${index}]`, seen, issues),
100
+ );
101
+ } else {
102
+ for (const [key, entry] of Object.entries(value)) {
103
+ inspectJsonValue(entry, `${path}.${key}`, seen, issues);
104
+ }
105
+ }
106
+ seen.delete(value);
107
+ };
108
+
109
+ export const inspectAirJamAgentContractConformance = async ({
110
+ gameId,
111
+ contract,
112
+ stores,
113
+ controllerId = "conformance-controller",
114
+ }: InspectAirJamAgentContractConformanceOptions): Promise<AirJamAgentContractConformanceReport> => {
115
+ const issues: AirJamAgentContractConformanceIssue[] = [];
116
+ const storeDomains = Object.keys(contract.stores).sort();
117
+ const runtimeStoreDomains = Object.keys(stores).sort();
118
+ const actionNames = Object.keys(contract.actions).sort();
119
+
120
+ if (JSON.stringify(storeDomains) !== JSON.stringify(runtimeStoreDomains)) {
121
+ issues.push({
122
+ code: "store-domain-mismatch",
123
+ path: "stores",
124
+ message: `Declared domains [${storeDomains.join(", ")}] do not match runtime domains [${runtimeStoreDomains.join(", ")}].`,
125
+ });
126
+ }
127
+
128
+ for (const [actionName, action] of Object.entries(contract.actions)) {
129
+ const targetDomain = action.target.storeDomain ?? "default";
130
+ const runtimeStore = stores[targetDomain] as
131
+ | { actions?: Record<string, unknown> }
132
+ | undefined;
133
+ if (!runtimeStore?.actions || typeof runtimeStore.actions !== "object") {
134
+ issues.push({
135
+ code: "missing-store-actions",
136
+ path: `actions.${actionName}.target`,
137
+ message: `Runtime store "${targetDomain}" does not expose an actions object.`,
138
+ });
139
+ } else if (
140
+ typeof runtimeStore.actions[action.target.actionName] !== "function"
141
+ ) {
142
+ issues.push({
143
+ code: "missing-target-action",
144
+ path: `actions.${actionName}.target`,
145
+ message: `Runtime store "${targetDomain}" does not expose action "${action.target.actionName}".`,
146
+ });
147
+ }
148
+
149
+ const metadata = describeAirJamAgentAction(action);
150
+ if (
151
+ !metadata.description?.trim() ||
152
+ !metadata.resultDescription?.trim() ||
153
+ (metadata.payload.kind === "enum" &&
154
+ !metadata.payload.allowedValues?.length)
155
+ ) {
156
+ issues.push({
157
+ code: "invalid-action-metadata",
158
+ path: `actions.${actionName}`,
159
+ message:
160
+ "Every semantic action must describe its intent, expected result, and enum values when applicable.",
161
+ });
162
+ }
163
+
164
+ try {
165
+ resolveAirJamAgentActionPayload(
166
+ action,
167
+ representativePayload(
168
+ metadata.payload.kind,
169
+ metadata.payload.allowedValues,
170
+ ),
171
+ { gameId, actionName, contractKind: "conformance" },
172
+ );
173
+ } catch (error) {
174
+ issues.push({
175
+ code: "payload-parse-failed",
176
+ path: `actions.${actionName}.input`,
177
+ message: error instanceof Error ? error.message : String(error),
178
+ });
179
+ }
180
+ }
181
+
182
+ try {
183
+ const snapshot = await contract.projectSnapshot({ controllerId, stores });
184
+ inspectJsonValue(snapshot, "snapshot", new Set(), issues);
185
+ } catch (error) {
186
+ issues.push({
187
+ code: "snapshot-failed",
188
+ path: "snapshot",
189
+ message: error instanceof Error ? error.message : String(error),
190
+ });
191
+ }
192
+
193
+ return {
194
+ schemaVersion: 1,
195
+ gameId,
196
+ ok: issues.length === 0,
197
+ storeDomains,
198
+ actionNames,
199
+ issues,
200
+ };
201
+ };
@@ -18,3 +18,8 @@ export {
18
18
  type AirJamAgentActionContract,
19
19
  type AirJamAgentContract,
20
20
  } from "./agent/agent-contract";
21
+ export {
22
+ inspectAirJamAgentContractConformance,
23
+ type AirJamAgentContractConformanceIssue,
24
+ type AirJamAgentContractConformanceReport,
25
+ } from "./agent/agent-contract-conformance";
@@ -0,0 +1,6 @@
1
+ export {
2
+ AirJamControllerRuntime,
3
+ AirJamHostRuntime,
4
+ type AirJamControllerRuntimeProps,
5
+ type AirJamHostRuntimeProps,
6
+ } from "../runtime/session-runtimes";
@@ -1,4 +1,5 @@
1
1
  export * from "../runtime/arcade-bridge-request-surface";
2
2
  export * from "../runtime/arcade-runtime-url";
3
3
  export * from "../runtime/arcade-surface-identity";
4
+ export * from "../runtime/local-reference-game-identity";
4
5
  export { AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN } from "../store/air-jam-store-domain-constants";
@@ -1,39 +1,60 @@
1
- import { useEffect, type JSX, type MouseEvent } from "react";
1
+ import { useEffect, useState, type JSX, type MouseEvent } from "react";
2
+ import { createPortal } from "react-dom";
2
3
  import { cn } from "../utils/cn";
3
4
  import { RoomQrCode } from "./room-qr-code";
4
- import {
5
- shellPanelClassName,
6
- shellUtilityButtonClassName,
7
- } from "./shell-classes";
5
+ import { shellUtilityButtonClassName } from "./shell-classes";
8
6
  import { Button } from "./ui/button";
9
7
 
10
8
  export interface JoinQrOverlayProps {
11
9
  open: boolean;
12
10
  value: string | null | undefined;
11
+ status?: "ready" | "loading" | "unavailable";
13
12
  roomId?: string | null;
14
13
  onClose?: () => void;
15
14
  title?: string;
15
+ roomLabel?: string;
16
16
  description?: string;
17
+ unavailableLabel?: string;
18
+ loadingLabel?: string;
19
+ qrAlt?: string;
20
+ showCloseButton?: boolean;
17
21
  className?: string;
18
22
  panelClassName?: string;
19
23
  qrClassName?: string;
24
+ bodyClassName?: string;
25
+ messageClassName?: string;
26
+ descriptionClassName?: string;
27
+ closeButtonClassName?: string;
20
28
  size?: number;
21
29
  }
22
30
 
23
31
  export const JoinQrOverlay = ({
24
32
  open,
25
33
  value,
34
+ status = "ready",
26
35
  roomId,
27
36
  onClose,
28
- title = "Scan to join",
37
+ title = "Scan QR code to join as a controller",
38
+ roomLabel = "Join room",
29
39
  description = "Scan with your phone to connect as a controller.",
40
+ unavailableLabel = "Join URL unavailable right now.",
41
+ loadingLabel = "Preparing join QR…",
42
+ qrAlt,
43
+ showCloseButton = false,
30
44
  className,
31
45
  panelClassName,
32
46
  qrClassName,
33
- size = 440,
47
+ bodyClassName,
48
+ messageClassName,
49
+ descriptionClassName,
50
+ closeButtonClassName,
51
+ size = 260,
34
52
  }: JoinQrOverlayProps): JSX.Element | null => {
35
53
  const joinUrlValue = value?.trim() ?? "";
36
- const hasJoinUrl = joinUrlValue.length > 0;
54
+ const effectiveStatus =
55
+ status === "ready" && joinUrlValue.length === 0 ? "unavailable" : status;
56
+ const overlaySize = `min(72vw, ${size}px)`;
57
+ const [entered, setEntered] = useState(false);
37
58
 
38
59
  useEffect(() => {
39
60
  if (!open || typeof window === "undefined") {
@@ -52,6 +73,22 @@ export const JoinQrOverlay = ({
52
73
  };
53
74
  }, [onClose, open]);
54
75
 
76
+ useEffect(() => {
77
+ if (!open || typeof window === "undefined") {
78
+ setEntered(false);
79
+ return;
80
+ }
81
+
82
+ setEntered(false);
83
+ const frame = window.requestAnimationFrame(() => {
84
+ setEntered(true);
85
+ });
86
+
87
+ return () => {
88
+ window.cancelAnimationFrame(frame);
89
+ };
90
+ }, [open]);
91
+
55
92
  if (!open) {
56
93
  return null;
57
94
  }
@@ -60,74 +97,121 @@ export const JoinQrOverlay = ({
60
97
  event.stopPropagation();
61
98
  };
62
99
 
63
- return (
100
+ const dialog = (
64
101
  <div
65
102
  role="dialog"
66
103
  aria-modal="true"
67
104
  aria-label={roomId ? `Join room ${roomId}` : title}
68
105
  className={cn(
69
- "absolute inset-0 z-50 flex items-center justify-center bg-black/82 px-6 py-8 backdrop-blur-md",
106
+ "pointer-events-auto fixed inset-0 z-[120] flex cursor-pointer flex-col items-center justify-center bg-black/85 px-6 backdrop-blur-md transition-opacity duration-200 ease-out",
107
+ entered ? "opacity-100" : "opacity-0",
70
108
  className,
71
109
  )}
72
110
  onClick={onClose}
73
111
  >
74
112
  <div
75
113
  className={cn(
76
- "flex w-full max-w-xl flex-col items-center gap-6 px-6 py-7 text-center",
77
- shellPanelClassName,
114
+ "flex cursor-default flex-col items-center gap-6 text-center transition-transform duration-200 ease-out",
115
+ entered ? "translate-y-0" : "-translate-y-4",
78
116
  panelClassName,
79
117
  )}
80
118
  onClick={handlePanelClick}
81
119
  >
82
120
  <div className="space-y-1">
83
- <p className="text-[0.6875rem] font-semibold tracking-[0.22em] text-white/52 uppercase">
84
- {title}
121
+ <p className="text-[11px] tracking-[0.18em] text-slate-400 uppercase">
122
+ {roomLabel}
85
123
  </p>
86
124
  {roomId ? (
87
- <p className="text-3xl font-semibold tracking-[0.12em] text-white uppercase tabular-nums">
125
+ <p className="text-2xl font-semibold tracking-tight text-white tabular-nums">
88
126
  {roomId}
89
127
  </p>
90
128
  ) : null}
91
129
  </div>
92
130
 
93
- {hasJoinUrl ? (
131
+ {effectiveStatus === "loading" ? (
132
+ <div
133
+ className={cn(
134
+ "flex flex-col items-center justify-center gap-3 rounded-lg border border-white/25 bg-white/6 px-5 py-10 text-sm text-white/70 shadow-sm",
135
+ bodyClassName,
136
+ )}
137
+ style={{
138
+ width: overlaySize,
139
+ height: "auto",
140
+ aspectRatio: "1 / 1",
141
+ }}
142
+ >
143
+ <span className="h-8 w-8 animate-spin rounded-full border-2 border-white/15 border-t-white/85" />
144
+ <span>{loadingLabel}</span>
145
+ </div>
146
+ ) : effectiveStatus === "ready" ? (
94
147
  <RoomQrCode
95
148
  value={joinUrlValue}
96
149
  size={size}
97
150
  padding={2}
98
151
  foregroundColor="#111827"
99
152
  backgroundColor="#ffffff"
100
- className={cn("rounded-xl bg-white shadow-sm", qrClassName)}
153
+ className={cn(
154
+ "rounded-lg border border-white/25 bg-white/6 shadow-sm",
155
+ qrClassName,
156
+ )}
101
157
  style={{
102
- width: "min(72vw, 26rem)",
158
+ width: overlaySize,
103
159
  height: "auto",
104
160
  aspectRatio: "1 / 1",
105
161
  }}
106
162
  alt={
107
- roomId
163
+ qrAlt ??
164
+ (roomId
108
165
  ? `QR code to join room ${roomId}`
109
- : "QR code to join as a controller"
166
+ : "QR code to join as a controller")
110
167
  }
111
168
  />
112
169
  ) : (
113
- <div className="flex w-full max-w-[26rem] items-center justify-center rounded-xl border border-white/12 bg-white/6 px-5 py-10 text-sm leading-6 text-white/68">
114
- Join URL unavailable right now.
170
+ <div
171
+ className={cn(
172
+ "flex items-center justify-center rounded-lg border border-white/25 bg-white/6 px-5 py-10 text-sm text-white/70 shadow-sm",
173
+ messageClassName,
174
+ )}
175
+ style={{
176
+ width: overlaySize,
177
+ height: "auto",
178
+ aspectRatio: "1 / 1",
179
+ }}
180
+ >
181
+ {unavailableLabel}
115
182
  </div>
116
183
  )}
117
184
 
118
- <p className="max-w-md text-sm leading-6 text-white/68">
185
+ <p
186
+ className={cn(
187
+ "max-w-xs text-center text-sm text-slate-400",
188
+ descriptionClassName,
189
+ )}
190
+ >
119
191
  {description}
120
192
  </p>
121
193
 
122
- <Button
123
- type="button"
124
- variant="outline"
125
- onClick={onClose}
126
- className={cn("rounded-2xl px-5", shellUtilityButtonClassName)}
127
- >
128
- Close
129
- </Button>
194
+ {showCloseButton ? (
195
+ <Button
196
+ type="button"
197
+ variant="outline"
198
+ onClick={onClose}
199
+ className={cn(
200
+ "rounded-2xl px-5",
201
+ shellUtilityButtonClassName,
202
+ closeButtonClassName,
203
+ )}
204
+ >
205
+ Close
206
+ </Button>
207
+ ) : null}
130
208
  </div>
131
209
  </div>
132
210
  );
211
+
212
+ if (typeof document === "undefined") {
213
+ return dialog;
214
+ }
215
+
216
+ return createPortal(dialog, document.body);
133
217
  };
@@ -42,12 +42,6 @@
42
42
  * );
43
43
  * ```
44
44
  */
45
- import type {
46
- ResolvedAirJamRuntimeTopology,
47
- RuntimeTopologyInput,
48
- SurfaceRole,
49
- } from "../runtime-topology";
50
- import { isLocalDevControlSurfaceTopology } from "../runtime-topology";
51
45
  import {
52
46
  createContext,
53
47
  useCallback,
@@ -65,6 +59,12 @@ import { InputManager, type InputConfig } from "../internal/input-manager";
65
59
  import type { ConnectionRole } from "../protocol";
66
60
  import { AIRJAM_DEV_LOG_EVENTS } from "../protocol";
67
61
  import type { HostSessionKind } from "../protocol/host";
62
+ import type {
63
+ ResolvedAirJamRuntimeTopology,
64
+ RuntimeTopologyInput,
65
+ SurfaceRole,
66
+ } from "../runtime-topology";
67
+ import { isLocalDevControlSurfaceTopology } from "../runtime-topology";
68
68
  import type { AirJamConfig } from "../runtime/air-jam-config";
69
69
  import { resolveAirJamConfig } from "../runtime/air-jam-config";
70
70
  import {
@@ -113,7 +113,7 @@ export interface AirJamProviderProps<
113
113
  children: ReactNode;
114
114
  /** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
115
115
  topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
116
- /** Internal surface-role hint when normalizing legacy endpoint props into topology. */
116
+ /** Internal surface-role hint used while resolving topology. */
117
117
  surfaceRole?: SurfaceRole;
118
118
  /**
119
119
  * App ID for production bootstrap identity.
@@ -478,7 +478,7 @@ export const useAirJamContext = (): AirJamContextValue => {
478
478
  * @example
479
479
  * ```tsx
480
480
  * const config = useAirJamConfig();
481
- * console.log(config.serverUrl, config.maxPlayers);
481
+ * console.log(config.topology.backendOrigin, config.maxPlayers);
482
482
  * ```
483
483
  */
484
484
  export const useAirJamConfig = (): AirJamConfig => {
@@ -63,13 +63,6 @@ export class SocketManager {
63
63
  }
64
64
  }
65
65
 
66
- /**
67
- * Deprecated compatibility alias. Returns the resolved socket origin.
68
- */
69
- getServerUrl(): string {
70
- return this.socketOrigin;
71
- }
72
-
73
66
  private normalizeOrigin(origin: string): string {
74
67
  if (!origin.includes("://")) {
75
68
  return `http://${origin}`;
@@ -1,8 +1,3 @@
1
- import {
2
- isLocalDevControlSurfaceTopology,
3
- type ProxyStrategy,
4
- type ResolvedAirJamRuntimeTopology,
5
- } from "../runtime-topology";
6
1
  import {
7
2
  onAirJamDiagnostic,
8
3
  type AirJamDiagnostic,
@@ -17,6 +12,11 @@ import {
17
12
  AIRJAM_DEV_LOG_EVENTS,
18
13
  resolveAirJamBrowserConsoleCategory,
19
14
  } from "../protocol";
15
+ import {
16
+ isLocalDevControlSurfaceTopology,
17
+ type ProxyStrategy,
18
+ type ResolvedAirJamRuntimeTopology,
19
+ } from "../runtime-topology";
20
20
  import {
21
21
  AIRJAM_DEV_LOG_SINK_FAILURE,
22
22
  AIRJAM_DEV_RUNTIME_EVENT,
@@ -74,7 +74,6 @@ type ConsoleMethodName = "debug" | "info" | "log" | "warn" | "error";
74
74
 
75
75
  interface BrowserLogSinkOptions {
76
76
  backendOrigin?: string;
77
- serverUrl?: string;
78
77
  appOrigin?: string;
79
78
  proxyStrategy?: ProxyStrategy;
80
79
  appId?: string;
@@ -134,30 +133,28 @@ const isDevelopmentRuntime = (): boolean => {
134
133
 
135
134
  const resolveEndpointBase = ({
136
135
  backendOrigin,
137
- serverUrl,
138
136
  appOrigin,
139
137
  proxyStrategy,
140
138
  }: Pick<
141
139
  BrowserLogSinkOptions,
142
- "backendOrigin" | "serverUrl" | "appOrigin" | "proxyStrategy"
140
+ "backendOrigin" | "appOrigin" | "proxyStrategy"
143
141
  >): string | null => {
144
142
  if (proxyStrategy && proxyStrategy !== "none") {
145
143
  return (appOrigin ?? resolveDevProxyBaseUrl())?.replace(/\/$/, "") ?? null;
146
144
  }
147
145
 
148
- const explicitOrigin = backendOrigin ?? serverUrl;
149
- if (!explicitOrigin) {
146
+ if (!backendOrigin) {
150
147
  return resolveDevProxyBaseUrl();
151
148
  }
152
149
 
153
- if (explicitOrigin.startsWith("ws://")) {
154
- return `http://${explicitOrigin.slice(5)}`.replace(/\/$/, "");
150
+ if (backendOrigin.startsWith("ws://")) {
151
+ return `http://${backendOrigin.slice(5)}`.replace(/\/$/, "");
155
152
  }
156
- if (explicitOrigin.startsWith("wss://")) {
157
- return `https://${explicitOrigin.slice(6)}`.replace(/\/$/, "");
153
+ if (backendOrigin.startsWith("wss://")) {
154
+ return `https://${backendOrigin.slice(6)}`.replace(/\/$/, "");
158
155
  }
159
156
 
160
- return explicitOrigin.replace(/\/$/, "");
157
+ return backendOrigin.replace(/\/$/, "");
161
158
  };
162
159
 
163
160
  const resolveDevProxyBaseUrl = (): string | null => {
package/src/events.ts CHANGED
@@ -12,11 +12,6 @@ export const HostEvents = {
12
12
  */
13
13
  BOOTSTRAP: "host:bootstrap",
14
14
 
15
- /**
16
- * Register as the system/arcade master host
17
- */
18
- REGISTER_SYSTEM: "host:registerSystem",
19
-
20
15
  /**
21
16
  * Join as a child host (game launched from arcade)
22
17
  */