@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
@@ -0,0 +1,363 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/arcade/url.ts
21
+ var url_exports = {};
22
+ __export(url_exports, {
23
+ appendRuntimeQueryParams: () => appendRuntimeQueryParams,
24
+ arcadeSurfaceRuntimeUrlParams: () => arcadeSurfaceRuntimeUrlParams,
25
+ buildArcadeControllerRuntimeUrl: () => buildArcadeControllerRuntimeUrl,
26
+ buildArcadeGameIframeSrc: () => buildArcadeGameIframeSrc,
27
+ getRuntimeUrlOrigin: () => getRuntimeUrlOrigin,
28
+ normalizeRuntimeUrl: () => normalizeRuntimeUrl,
29
+ urlBuilder: () => urlBuilder
30
+ });
31
+ module.exports = __toCommonJS(url_exports);
32
+ var import_runtime_topology = require("@air-jam/runtime-topology");
33
+
34
+ // src/protocol/url-policy.ts
35
+ var import_zod = require("zod");
36
+ var ALLOWED_RUNTIME_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
37
+ var parseRuntimeUrl = (value) => {
38
+ try {
39
+ const parsed = new URL(value);
40
+ if (!ALLOWED_RUNTIME_PROTOCOLS.has(parsed.protocol)) {
41
+ return null;
42
+ }
43
+ if (parsed.username || parsed.password) {
44
+ return null;
45
+ }
46
+ return parsed;
47
+ } catch {
48
+ return null;
49
+ }
50
+ };
51
+ var normalizeRuntimeUrl = (value) => {
52
+ const parsed = parseRuntimeUrl(value);
53
+ return parsed ? parsed.toString() : null;
54
+ };
55
+ var getRuntimeUrlOrigin = (value) => {
56
+ const parsed = parseRuntimeUrl(value);
57
+ return parsed ? parsed.origin : null;
58
+ };
59
+ var runtimeUrlSchema = import_zod.z.string().trim().min(1).refine((value) => parseRuntimeUrl(value) !== null, {
60
+ message: "URL must be a valid http(s) URL without embedded credentials."
61
+ });
62
+ var appendRuntimeQueryParams = (baseUrl, params) => {
63
+ const parsed = parseRuntimeUrl(baseUrl);
64
+ if (!parsed) {
65
+ return null;
66
+ }
67
+ for (const [key, value] of Object.entries(params)) {
68
+ if (value === void 0 || value === null || value === "") {
69
+ continue;
70
+ }
71
+ parsed.searchParams.set(key, value);
72
+ }
73
+ return parsed.toString();
74
+ };
75
+
76
+ // src/runtime/arcade-runtime-url.ts
77
+ var AIRJAM_STORE_DOMAIN_URL_PARAM = "aj_store_domain";
78
+ var clampStoreDomain = (value) => value.length > 128 ? value.slice(0, 128) : value;
79
+ var embeddedReplicatedStoreDomainFromArcadeIdentity = (identity) => {
80
+ if (identity.kind === "game") {
81
+ const gameKey = identity.gameId ?? "_";
82
+ return clampStoreDomain(`aj.embedded.game:${identity.epoch}:${gameKey}`);
83
+ }
84
+ return clampStoreDomain(`aj.embedded.browser:${identity.epoch}`);
85
+ };
86
+ var arcadeSurfaceRuntimeUrlParams = (identity) => ({
87
+ aj_arcade_epoch: String(identity.epoch),
88
+ aj_arcade_kind: identity.kind,
89
+ ...identity.gameId != null ? { aj_arcade_game_id: identity.gameId } : {},
90
+ [AIRJAM_STORE_DOMAIN_URL_PARAM]: embeddedReplicatedStoreDomainFromArcadeIdentity(identity)
91
+ });
92
+
93
+ // src/runtime/arcade-surface-identity.ts
94
+ var import_zod2 = require("zod");
95
+ var arcadeSurfaceRuntimeIdentitySchema = import_zod2.z.object({
96
+ epoch: import_zod2.z.number().int().nonnegative(),
97
+ kind: import_zod2.z.enum(["browser", "game"]),
98
+ gameId: import_zod2.z.string().nullable()
99
+ }).strict();
100
+
101
+ // src/constants.ts
102
+ var DEFAULT_SERVER_PORT = 4e3;
103
+ var CONTROLLER_PATH = "/controller";
104
+
105
+ // src/utils/network-ip.ts
106
+ var isVirtualNetwork = (ip) => {
107
+ if (ip.startsWith("192.168.64.") || ip.startsWith("192.168.65.")) {
108
+ return true;
109
+ }
110
+ if (ip.startsWith("172.17.")) {
111
+ return true;
112
+ }
113
+ if (ip.startsWith("172.18.") || ip.startsWith("172.19.")) {
114
+ return true;
115
+ }
116
+ if (ip.startsWith("169.254.")) {
117
+ return true;
118
+ }
119
+ return false;
120
+ };
121
+ var scoreIp = (ip) => {
122
+ if (ip.startsWith("192.168.")) {
123
+ const parts = ip.split(".");
124
+ const thirdOctet = parseInt(parts[2] || "0", 10);
125
+ if (thirdOctet < 64) {
126
+ return 100 - thirdOctet;
127
+ }
128
+ return 10;
129
+ }
130
+ if (ip.startsWith("10.")) {
131
+ return 50;
132
+ }
133
+ if (/^172\.(1[6-9]|2[0-9]|3[01])\./.test(ip)) {
134
+ return 30;
135
+ }
136
+ return 0;
137
+ };
138
+ var getLocalNetworkIp = () => {
139
+ return new Promise((resolve) => {
140
+ if (typeof window === "undefined" || typeof RTCPeerConnection === "undefined") {
141
+ resolve(null);
142
+ return;
143
+ }
144
+ const pc = new RTCPeerConnection({
145
+ iceServers: [{ urls: "stun:stun.l.google.com:19302" }]
146
+ });
147
+ const candidates = [];
148
+ let candidateGatheringComplete = false;
149
+ const resolveOnce = (ip) => {
150
+ pc.close();
151
+ resolve(ip);
152
+ };
153
+ const timeout = setTimeout(() => {
154
+ if (candidateGatheringComplete) {
155
+ pickBestCandidate();
156
+ } else {
157
+ setTimeout(() => {
158
+ pickBestCandidate();
159
+ }, 500);
160
+ }
161
+ }, 3e3);
162
+ const pickBestCandidate = () => {
163
+ if (candidates.length === 0) {
164
+ resolveOnce(null);
165
+ return;
166
+ }
167
+ candidates.sort((a, b) => b.score - a.score);
168
+ const best = candidates[0];
169
+ clearTimeout(timeout);
170
+ resolveOnce(best.ip);
171
+ };
172
+ pc.onicecandidate = (event) => {
173
+ if (event.candidate) {
174
+ const candidate = event.candidate.candidate;
175
+ const match = candidate.match(/([0-9]{1,3}(\.[0-9]{1,3}){3})/);
176
+ if (match) {
177
+ const ip = match[1];
178
+ if (ip === "127.0.0.1") {
179
+ return;
180
+ }
181
+ const isPrivate = ip.startsWith("192.168.") || ip.startsWith("10.") || /^172\.(1[6-9]|2[0-9]|3[01])\./.test(ip);
182
+ if (isPrivate && !isVirtualNetwork(ip)) {
183
+ const score = scoreIp(ip);
184
+ candidates.push({ ip, score });
185
+ }
186
+ }
187
+ } else {
188
+ candidateGatheringComplete = true;
189
+ setTimeout(() => {
190
+ pickBestCandidate();
191
+ }, 200);
192
+ }
193
+ };
194
+ pc.createDataChannel("");
195
+ pc.createOffer().then((offer) => pc.setLocalDescription(offer)).catch(() => {
196
+ clearTimeout(timeout);
197
+ resolveOnce(null);
198
+ });
199
+ });
200
+ };
201
+
202
+ // src/utils/url-builder.ts
203
+ var UrlBuilder = class {
204
+ cachedLocalIp = null;
205
+ ipDetectionPromise = null;
206
+ /**
207
+ * Get the local network IP address with caching.
208
+ * First call triggers detection, subsequent calls return cached value.
209
+ */
210
+ async getLocalIp() {
211
+ if (this.cachedLocalIp !== null) {
212
+ return this.cachedLocalIp;
213
+ }
214
+ if (this.ipDetectionPromise !== null) {
215
+ return this.ipDetectionPromise;
216
+ }
217
+ this.ipDetectionPromise = getLocalNetworkIp().then((ip) => {
218
+ this.cachedLocalIp = ip;
219
+ this.ipDetectionPromise = null;
220
+ return ip;
221
+ });
222
+ return this.ipDetectionPromise;
223
+ }
224
+ /**
225
+ * Clear the cached IP address.
226
+ * Useful for testing or when network changes are detected.
227
+ */
228
+ clearCache() {
229
+ this.cachedLocalIp = null;
230
+ this.ipDetectionPromise = null;
231
+ }
232
+ /**
233
+ * Normalize a URL for mobile access.
234
+ * Replaces localhost with the local network IP.
235
+ */
236
+ async normalizeForMobile(url) {
237
+ if (typeof window === "undefined") return url;
238
+ try {
239
+ const urlObj = new URL(url);
240
+ if (urlObj.hostname === "localhost" || urlObj.hostname === "127.0.0.1") {
241
+ const localIp = await this.getLocalIp();
242
+ if (localIp) {
243
+ urlObj.hostname = localIp;
244
+ return urlObj.toString();
245
+ }
246
+ urlObj.hostname = window.location.hostname;
247
+ return urlObj.toString();
248
+ }
249
+ return url;
250
+ } catch {
251
+ return url;
252
+ }
253
+ }
254
+ /**
255
+ * Build a controller URL with room code.
256
+ * Controller is always at {baseUrl}/controller (standardized convention).
257
+ * Automatically uses local IP when running on localhost.
258
+ */
259
+ async buildControllerUrl(roomId, options) {
260
+ const path = CONTROLLER_PATH;
261
+ if (options?.host) {
262
+ const url2 = new URL(path, this.normalizeOrigin(options.host));
263
+ url2.searchParams.set("room", roomId);
264
+ if (options.capabilityToken) {
265
+ url2.searchParams.set("aj_controller_cap", options.capabilityToken);
266
+ }
267
+ return url2.toString();
268
+ }
269
+ let base;
270
+ if (typeof window === "undefined") {
271
+ base = `http://localhost:${DEFAULT_SERVER_PORT}`;
272
+ } else {
273
+ const currentUrl = new URL(window.location.href);
274
+ if (!this.isLocalhost(currentUrl.hostname)) {
275
+ base = currentUrl.origin;
276
+ } else {
277
+ const localIp = await this.getLocalIp();
278
+ if (localIp) {
279
+ const port = currentUrl.port;
280
+ base = port ? `http://${localIp}:${port}` : `http://${localIp}`;
281
+ } else {
282
+ base = currentUrl.origin;
283
+ }
284
+ }
285
+ }
286
+ const url = new URL(path, base);
287
+ url.searchParams.set("room", roomId);
288
+ if (options?.capabilityToken) {
289
+ url.searchParams.set("aj_controller_cap", options.capabilityToken);
290
+ }
291
+ return url.toString();
292
+ }
293
+ /**
294
+ * Resolve the server URL.
295
+ * Uses explicit URL if provided, otherwise infers from window location.
296
+ */
297
+ resolveServerUrl(explicit) {
298
+ if (explicit) {
299
+ return this.normalizeOrigin(explicit);
300
+ }
301
+ if (typeof window !== "undefined") {
302
+ const url = new URL(window.location.href);
303
+ url.port = String(DEFAULT_SERVER_PORT);
304
+ return url.origin;
305
+ }
306
+ return `http://localhost:${DEFAULT_SERVER_PORT}`;
307
+ }
308
+ /**
309
+ * Check if a hostname is localhost.
310
+ */
311
+ isLocalhost(hostname) {
312
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
313
+ }
314
+ /**
315
+ * Normalize an origin string to ensure it has a protocol.
316
+ */
317
+ normalizeOrigin(origin) {
318
+ if (!origin.includes("://")) {
319
+ return `http://${origin}`;
320
+ }
321
+ return origin;
322
+ }
323
+ };
324
+ var urlBuilder = new UrlBuilder();
325
+
326
+ // src/arcade/url.ts
327
+ var buildArcadeGameIframeSrc = ({
328
+ normalizedUrl,
329
+ roomId,
330
+ launchCapability,
331
+ joinUrl,
332
+ topology,
333
+ arcadeSurface
334
+ }) => appendRuntimeQueryParams(normalizedUrl, {
335
+ aj_room: roomId,
336
+ aj_cap: launchCapability.token,
337
+ aj_cap_exp: String(launchCapability.expiresAt),
338
+ aj_join_url: joinUrl,
339
+ ...(0, import_runtime_topology.runtimeTopologyToQueryParams)(topology),
340
+ ...arcadeSurfaceRuntimeUrlParams(arcadeSurface)
341
+ });
342
+ var buildArcadeControllerRuntimeUrl = (normalizedUrl) => {
343
+ try {
344
+ const runtimeUrl = new URL(normalizedUrl);
345
+ const trimmedPath = runtimeUrl.pathname !== "/" && runtimeUrl.pathname.endsWith("/") ? runtimeUrl.pathname.slice(0, -1) : runtimeUrl.pathname;
346
+ const pathSegments = trimmedPath.split("/").filter(Boolean);
347
+ const controllerPath = trimmedPath === "/" || pathSegments.length <= 1 ? "/controller" : `${trimmedPath}/controller`;
348
+ return new URL(controllerPath, runtimeUrl.origin).toString();
349
+ } catch {
350
+ return null;
351
+ }
352
+ };
353
+ // Annotate the CommonJS export names for ESM import in node:
354
+ 0 && (module.exports = {
355
+ appendRuntimeQueryParams,
356
+ arcadeSurfaceRuntimeUrlParams,
357
+ buildArcadeControllerRuntimeUrl,
358
+ buildArcadeGameIframeSrc,
359
+ getRuntimeUrlOrigin,
360
+ normalizeRuntimeUrl,
361
+ urlBuilder
362
+ });
363
+ //# sourceMappingURL=url.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/arcade/url.ts","../../src/protocol/url-policy.ts","../../src/runtime/arcade-runtime-url.ts","../../src/runtime/arcade-surface-identity.ts","../../src/constants.ts","../../src/utils/network-ip.ts","../../src/utils/url-builder.ts"],"sourcesContent":["import type { ResolvedAirJamRuntimeTopology } from \"@air-jam/runtime-topology\";\nimport { runtimeTopologyToQueryParams } from \"@air-jam/runtime-topology\";\nimport type { ChildHostCapability } from \"../protocol\";\nimport {\n appendRuntimeQueryParams,\n getRuntimeUrlOrigin,\n normalizeRuntimeUrl,\n} from \"../protocol/url-policy\";\nimport {\n arcadeSurfaceRuntimeUrlParams,\n type ArcadeSurfaceRuntimeIdentity,\n} from \"./surface\";\nexport { urlBuilder } from \"../utils/url-builder\";\nexport { arcadeSurfaceRuntimeUrlParams } from \"./surface\";\nexport { appendRuntimeQueryParams, getRuntimeUrlOrigin, normalizeRuntimeUrl };\n\nexport const buildArcadeGameIframeSrc = ({\n normalizedUrl,\n roomId,\n launchCapability,\n joinUrl,\n topology,\n arcadeSurface,\n}: {\n normalizedUrl: string;\n roomId: string;\n launchCapability: ChildHostCapability;\n joinUrl?: string | null;\n topology: ResolvedAirJamRuntimeTopology;\n arcadeSurface: ArcadeSurfaceRuntimeIdentity;\n}): string | null =>\n appendRuntimeQueryParams(normalizedUrl, {\n aj_room: roomId,\n aj_cap: launchCapability.token,\n aj_cap_exp: String(launchCapability.expiresAt),\n aj_join_url: joinUrl,\n ...runtimeTopologyToQueryParams(topology),\n ...arcadeSurfaceRuntimeUrlParams(arcadeSurface),\n });\n\nexport const buildArcadeControllerRuntimeUrl = (\n normalizedUrl: string,\n): string | null => {\n try {\n const runtimeUrl = new URL(normalizedUrl);\n const trimmedPath =\n runtimeUrl.pathname !== \"/\" && runtimeUrl.pathname.endsWith(\"/\")\n ? runtimeUrl.pathname.slice(0, -1)\n : runtimeUrl.pathname;\n const pathSegments = trimmedPath.split(\"/\").filter(Boolean);\n const controllerPath =\n trimmedPath === \"/\" || pathSegments.length <= 1\n ? \"/controller\"\n : `${trimmedPath}/controller`;\n\n return new URL(controllerPath, runtimeUrl.origin).toString();\n } catch {\n return null;\n }\n};\n","import { z } from \"zod\";\n\nconst ALLOWED_RUNTIME_PROTOCOLS = new Set([\"http:\", \"https:\"]);\n\nconst parseRuntimeUrl = (value: string): URL | null => {\n try {\n const parsed = new URL(value);\n if (!ALLOWED_RUNTIME_PROTOCOLS.has(parsed.protocol)) {\n return null;\n }\n if (parsed.username || parsed.password) {\n return null;\n }\n return parsed;\n } catch {\n return null;\n }\n};\n\nexport const normalizeRuntimeUrl = (value: string): string | null => {\n const parsed = parseRuntimeUrl(value);\n return parsed ? parsed.toString() : null;\n};\n\nexport const getRuntimeUrlOrigin = (value: string): string | null => {\n const parsed = parseRuntimeUrl(value);\n return parsed ? parsed.origin : null;\n};\n\nexport const runtimeUrlSchema = z\n .string()\n .trim()\n .min(1)\n .refine((value) => parseRuntimeUrl(value) !== null, {\n message: \"URL must be a valid http(s) URL without embedded credentials.\",\n });\n\nexport const appendRuntimeQueryParams = (\n baseUrl: string,\n params: Record<string, string | null | undefined>,\n): string | null => {\n const parsed = parseRuntimeUrl(baseUrl);\n if (!parsed) {\n return null;\n }\n\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null || value === \"\") {\n continue;\n }\n parsed.searchParams.set(key, value);\n }\n\n return parsed.toString();\n};\n\nexport const isTrustedRuntimeMessageOrigin = (\n runtimeUrl: string,\n messageOrigin: string,\n): boolean => {\n const runtimeOrigin = getRuntimeUrlOrigin(runtimeUrl);\n return runtimeOrigin !== null && runtimeOrigin === messageOrigin;\n};\n","import { AIR_JAM_DEFAULT_STORE_DOMAIN } from \"../store/air-jam-store-domain-constants\";\nimport type { ArcadeSurfaceRuntimeIdentity } from \"./arcade-surface-identity\";\n\n/**\n * Query param for the canonical replicated store domain in embedded runtimes.\n * When set, {@link resolveImplicitReplicatedStoreDomainFromSearchParams} prefers it over derivation from `aj_arcade_*`.\n */\nexport const AIRJAM_STORE_DOMAIN_URL_PARAM = \"aj_store_domain\";\n\nconst clampStoreDomain = (value: string): string =>\n value.length > 128 ? value.slice(0, 128) : value;\n\n/**\n * Stable replicated store domain for an embedded Arcade surface identity (epoch-bound).\n * Used for host/controller `createAirJamStore` in iframes so shell `default` and prior runs do not collide.\n */\nexport const embeddedReplicatedStoreDomainFromArcadeIdentity = (\n identity: ArcadeSurfaceRuntimeIdentity,\n): string => {\n if (identity.kind === \"game\") {\n const gameKey = identity.gameId ?? \"_\";\n return clampStoreDomain(`aj.embedded.game:${identity.epoch}:${gameKey}`);\n }\n return clampStoreDomain(`aj.embedded.browser:${identity.epoch}`);\n};\n\n/**\n * Query params used to pass {@link ArcadeSurfaceRuntimeIdentity} and replicated store domain into embedded iframes.\n */\nexport const arcadeSurfaceRuntimeUrlParams = (\n identity: ArcadeSurfaceRuntimeIdentity,\n): Record<string, string> => ({\n aj_arcade_epoch: String(identity.epoch),\n aj_arcade_kind: identity.kind,\n ...(identity.gameId != null ? { aj_arcade_game_id: identity.gameId } : {}),\n [AIRJAM_STORE_DOMAIN_URL_PARAM]:\n embeddedReplicatedStoreDomainFromArcadeIdentity(identity),\n});\n\nexport const parseOptionalArcadeSurfaceFromSearchParams = (\n params: URLSearchParams,\n): ArcadeSurfaceRuntimeIdentity | undefined => {\n const epochStr = params.get(\"aj_arcade_epoch\");\n const kind = params.get(\"aj_arcade_kind\");\n if (epochStr === null || (kind !== \"browser\" && kind !== \"game\")) {\n return undefined;\n }\n\n const epoch = Number(epochStr);\n if (!Number.isFinite(epoch) || epoch < 0 || !Number.isInteger(epoch)) {\n return undefined;\n }\n\n const gameIdRaw = params.get(\"aj_arcade_game_id\");\n const gameId =\n kind === \"browser\"\n ? null\n : gameIdRaw && gameIdRaw.length > 0\n ? gameIdRaw\n : null;\n\n return { epoch, kind, gameId };\n};\n\n/**\n * Resolves the implicit networked store domain from the current URL (embedded) or {@link AIR_JAM_DEFAULT_STORE_DOMAIN}.\n * Prefer {@link AIRJAM_STORE_DOMAIN_URL_PARAM} when present; otherwise derive from `aj_arcade_*` when valid.\n */\nexport const resolveImplicitReplicatedStoreDomainFromSearchParams = (\n params: URLSearchParams,\n): string => {\n const explicit = params.get(AIRJAM_STORE_DOMAIN_URL_PARAM)?.trim();\n if (explicit && explicit.length > 0) {\n return clampStoreDomain(explicit);\n }\n\n const surface = parseOptionalArcadeSurfaceFromSearchParams(params);\n if (surface) {\n return embeddedReplicatedStoreDomainFromArcadeIdentity(surface);\n }\n\n return AIR_JAM_DEFAULT_STORE_DOMAIN;\n};\n\n/**\n * Browser-only resolver for implicit store domain (SSR-safe: returns default without `window`).\n */\nexport const resolveImplicitReplicatedStoreDomainFromWindow = (): string => {\n if (typeof window === \"undefined\") {\n return AIR_JAM_DEFAULT_STORE_DOMAIN;\n }\n return resolveImplicitReplicatedStoreDomainFromSearchParams(\n new URLSearchParams(window.location.search),\n );\n};\n","import { z } from \"zod\";\n\n/**\n * Minimum Arcade surface identity for embedded runtime bridge attach (see docs/systems/arcade-surface-contract.md).\n */\nexport const arcadeSurfaceRuntimeIdentitySchema = z\n .object({\n epoch: z.number().int().nonnegative(),\n kind: z.enum([\"browser\", \"game\"]),\n gameId: z.string().nullable(),\n })\n .strict();\n\nexport type ArcadeSurfaceRuntimeIdentity = z.infer<\n typeof arcadeSurfaceRuntimeIdentitySchema\n>;\n","/**\n * Core Air Jam constants used across the SDK\n */\n\n/**\n * Default server port for Air Jam server\n */\nexport const DEFAULT_SERVER_PORT = 4000;\n\n/**\n * Standard path for controller endpoints.\n * All Air Jam games use this convention - controller is always at {baseUrl}/controller\n */\nexport const CONTROLLER_PATH = \"/controller\";\n\n/**\n * Input debounce time in milliseconds\n * Used to prevent rapid input events from overwhelming the system\n */\nexport const INPUT_DEBOUNCE_MS = 200;\n\n/**\n * Toggle debounce time in milliseconds\n * Used for game state toggles to prevent accidental double-toggles\n */\nexport const TOGGLE_DEBOUNCE_MS = 300;\n\n/**\n * Socket.IO configuration\n */\nexport const SOCKET_CONFIG = {\n /**\n * Ping interval in milliseconds\n */\n PING_INTERVAL: 2000,\n\n /**\n * Ping timeout in milliseconds\n */\n PING_TIMEOUT: 5000,\n} as const;\n\n/**\n * Maximum players allowed in a room by default\n */\nexport const DEFAULT_MAX_PLAYERS = 8;\n","/**\n * Checks if an IP is from a virtual network interface (Docker, VMs, etc.)\n */\nconst isVirtualNetwork = (ip: string): boolean => {\n // Docker Desktop on Mac uses 192.168.64.x and 192.168.65.x\n if (ip.startsWith(\"192.168.64.\") || ip.startsWith(\"192.168.65.\")) {\n return true;\n }\n // Docker default bridge network\n if (ip.startsWith(\"172.17.\")) {\n return true;\n }\n // Other common virtual network ranges\n if (ip.startsWith(\"172.18.\") || ip.startsWith(\"172.19.\")) {\n return true;\n }\n // Link-local addresses\n if (ip.startsWith(\"169.254.\")) {\n return true;\n }\n return false;\n};\n\n/**\n * Scores an IP address to determine preference.\n * Higher score = more preferred.\n */\nconst scoreIp = (ip: string): number => {\n // Prefer 192.168.0.x - 192.168.63.x (common home network ranges, excluding virtual networks)\n if (ip.startsWith(\"192.168.\")) {\n const parts = ip.split(\".\");\n const thirdOctet = parseInt(parts[2] || \"0\", 10);\n // Prefer lower third octets (0-63) as they're more likely to be real networks\n if (thirdOctet < 64) {\n return 100 - thirdOctet; // Higher score for lower numbers\n }\n // 64+ are often virtual, but we'll still consider them if nothing else\n return 10;\n }\n // Prefer 10.x.x.x networks\n if (ip.startsWith(\"10.\")) {\n return 50;\n }\n // 172.16-31.x.x networks (but not 172.17.x.x which is Docker)\n if (/^172\\.(1[6-9]|2[0-9]|3[01])\\./.test(ip)) {\n return 30;\n }\n return 0;\n};\n\n/**\n * Gets the local network IP address using WebRTC.\n * Filters out virtual network interfaces and prefers real network IPs.\n * Returns null if unable to determine the IP.\n */\nexport const getLocalNetworkIp = (): Promise<string | null> => {\n return new Promise((resolve) => {\n // If not in browser, return null\n if (\n typeof window === \"undefined\" ||\n typeof RTCPeerConnection === \"undefined\"\n ) {\n resolve(null);\n return;\n }\n\n const pc = new RTCPeerConnection({\n iceServers: [{ urls: \"stun:stun.l.google.com:19302\" }],\n });\n\n const candidates: Array<{ ip: string; score: number }> = [];\n let candidateGatheringComplete = false;\n\n const resolveOnce = (ip: string | null) => {\n pc.close();\n resolve(ip);\n };\n\n // Timeout after 3 seconds\n const timeout = setTimeout(() => {\n if (candidateGatheringComplete) {\n pickBestCandidate();\n } else {\n // Wait a bit more for candidates to arrive\n setTimeout(() => {\n pickBestCandidate();\n }, 500);\n }\n }, 3000);\n\n const pickBestCandidate = () => {\n if (candidates.length === 0) {\n resolveOnce(null);\n return;\n }\n\n // Sort by score (highest first), then pick the best one\n candidates.sort((a, b) => b.score - a.score);\n const best = candidates[0];\n clearTimeout(timeout);\n resolveOnce(best.ip);\n };\n\n pc.onicecandidate = (event) => {\n if (event.candidate) {\n const candidate = event.candidate.candidate;\n const match = candidate.match(/([0-9]{1,3}(\\.[0-9]{1,3}){3})/);\n if (match) {\n const ip = match[1];\n // Filter out localhost\n if (ip === \"127.0.0.1\") {\n return;\n }\n\n // Check if it's a private network IP\n const isPrivate =\n ip.startsWith(\"192.168.\") ||\n ip.startsWith(\"10.\") ||\n /^172\\.(1[6-9]|2[0-9]|3[01])\\./.test(ip);\n\n if (isPrivate && !isVirtualNetwork(ip)) {\n const score = scoreIp(ip);\n candidates.push({ ip, score });\n }\n }\n } else {\n // No more candidates - gathering is complete\n candidateGatheringComplete = true;\n // Give it a moment for any last candidates to arrive, then pick the best\n setTimeout(() => {\n pickBestCandidate();\n }, 200);\n }\n };\n\n // Create a data channel to trigger candidate gathering\n pc.createDataChannel(\"\");\n pc.createOffer()\n .then((offer) => pc.setLocalDescription(offer))\n .catch(() => {\n clearTimeout(timeout);\n resolveOnce(null);\n });\n });\n};\n","import { CONTROLLER_PATH, DEFAULT_SERVER_PORT } from \"../constants\";\nimport type { RoomCode } from \"../protocol\";\nimport { getLocalNetworkIp } from \"./network-ip\";\n\n/**\n * Centralized URL builder service for Air Jam.\n * Handles IP detection, URL normalization, and construction of all URL types.\n */\nclass UrlBuilder {\n private cachedLocalIp: string | null = null;\n private ipDetectionPromise: Promise<string | null> | null = null;\n\n /**\n * Get the local network IP address with caching.\n * First call triggers detection, subsequent calls return cached value.\n */\n async getLocalIp(): Promise<string | null> {\n // Return cached value if available\n if (this.cachedLocalIp !== null) {\n return this.cachedLocalIp;\n }\n\n // If detection is already in progress, wait for it\n if (this.ipDetectionPromise !== null) {\n return this.ipDetectionPromise;\n }\n\n // Start IP detection\n this.ipDetectionPromise = getLocalNetworkIp().then((ip) => {\n this.cachedLocalIp = ip;\n this.ipDetectionPromise = null;\n return ip;\n });\n\n return this.ipDetectionPromise;\n }\n\n /**\n * Clear the cached IP address.\n * Useful for testing or when network changes are detected.\n */\n clearCache(): void {\n this.cachedLocalIp = null;\n this.ipDetectionPromise = null;\n }\n\n /**\n * Normalize a URL for mobile access.\n * Replaces localhost with the local network IP.\n */\n async normalizeForMobile(url: string): Promise<string> {\n if (typeof window === \"undefined\") return url;\n\n try {\n const urlObj = new URL(url);\n\n // If URL uses localhost, replace with local network IP\n if (urlObj.hostname === \"localhost\" || urlObj.hostname === \"127.0.0.1\") {\n const localIp = await this.getLocalIp();\n\n if (localIp) {\n urlObj.hostname = localIp;\n return urlObj.toString();\n }\n\n // Fallback to current hostname if IP detection fails\n urlObj.hostname = window.location.hostname;\n return urlObj.toString();\n }\n\n return url;\n } catch {\n return url;\n }\n }\n\n /**\n * Build a controller URL with room code.\n * Controller is always at {baseUrl}/controller (standardized convention).\n * Automatically uses local IP when running on localhost.\n */\n async buildControllerUrl(\n roomId: RoomCode,\n options?: {\n host?: string;\n capabilityToken?: string;\n },\n ): Promise<string> {\n const path = CONTROLLER_PATH;\n\n // If explicit host is provided, use it\n if (options?.host) {\n const url = new URL(path, this.normalizeOrigin(options.host));\n url.searchParams.set(\"room\", roomId);\n if (options.capabilityToken) {\n url.searchParams.set(\"aj_controller_cap\", options.capabilityToken);\n }\n return url.toString();\n }\n\n // Determine base URL\n let base: string;\n if (typeof window === \"undefined\") {\n base = `http://localhost:${DEFAULT_SERVER_PORT}`;\n } else {\n const currentUrl = new URL(window.location.href);\n\n // If not localhost, use the current origin\n if (!this.isLocalhost(currentUrl.hostname)) {\n base = currentUrl.origin;\n } else {\n // If localhost, try to get the local network IP\n const localIp = await this.getLocalIp();\n if (localIp) {\n // Preserve the port from the current URL\n const port = currentUrl.port;\n base = port ? `http://${localIp}:${port}` : `http://${localIp}`;\n } else {\n // Fallback to localhost if we can't determine the IP\n base = currentUrl.origin;\n }\n }\n }\n\n const url = new URL(path, base);\n url.searchParams.set(\"room\", roomId);\n if (options?.capabilityToken) {\n url.searchParams.set(\"aj_controller_cap\", options.capabilityToken);\n }\n return url.toString();\n }\n\n /**\n * Resolve the server URL.\n * Uses explicit URL if provided, otherwise infers from window location.\n */\n resolveServerUrl(explicit?: string): string {\n if (explicit) {\n return this.normalizeOrigin(explicit);\n }\n\n if (typeof window !== \"undefined\") {\n const url = new URL(window.location.href);\n url.port = String(DEFAULT_SERVER_PORT);\n return url.origin;\n }\n\n return `http://localhost:${DEFAULT_SERVER_PORT}`;\n }\n\n /**\n * Check if a hostname is localhost.\n */\n private isLocalhost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n }\n\n /**\n * Normalize an origin string to ensure it has a protocol.\n */\n private normalizeOrigin(origin: string): string {\n if (!origin.includes(\"://\")) {\n return `http://${origin}`;\n }\n return origin;\n }\n}\n\n// Export singleton instance\nexport const urlBuilder = new UrlBuilder();\n\n// Export class for testing/advanced usage\nexport { UrlBuilder };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA6C;;;ACD7C,iBAAkB;AAElB,IAAM,4BAA4B,oBAAI,IAAI,CAAC,SAAS,QAAQ,CAAC;AAE7D,IAAM,kBAAkB,CAAC,UAA8B;AACrD,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,KAAK;AAC5B,QAAI,CAAC,0BAA0B,IAAI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A;AAAA;AAAA,EAKQ,YAAY,UAA2B;AAC7C,WACE,aAAa,eACb,aAAa,eACb,aAAa;AAAA,EAEjB;AAAA;AAAA;AAAA;AAAA,EAKQ,gBAAgB,QAAwB;AAC9C,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,aAAO,UAAU,MAAM;AAAA,IACzB;AACA,WAAO;AAAA,EACT;AACF;AAGO,IAAM,aAAa,IAAI,WAAW;;;AN7JlC,IAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAQE,yBAAyB,eAAe;AAAA,EACtC,SAAS;AAAA,EACT,QAAQ,iBAAiB;AAAA,EACzB,YAAY,OAAO,iBAAiB,SAAS;AAAA,EAC7C,aAAa;AAAA,EACb,OAAG,sDAA6B,QAAQ;AAAA,EACxC,GAAG,8BAA8B,aAAa;AAChD,CAAC;AAEI,IAAM,kCAAkC,CAC7C,kBACkB;AAClB,MAAI;AACF,UAAM,aAAa,IAAI,IAAI,aAAa;AACxC,UAAM,cACJ,WAAW,aAAa,OAAO,WAAW,SAAS,SAAS,GAAG,IAC3D,WAAW,SAAS,MAAM,GAAG,EAAE,IAC/B,WAAW;AACjB,UAAM,eAAe,YAAY,MAAM,GAAG,EAAE,OAAO,OAAO;AAC1D,UAAM,iBACJ,gBAAgB,OAAO,aAAa,UAAU,IAC1C,gBACA,GAAG,WAAW;AAEpB,WAAO,IAAI,IAAI,gBAAgB,WAAW,MAAM,EAAE,SAAS;AAAA,EAC7D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["import_zod","url"]}
@@ -0,0 +1,68 @@
1
+ import { ResolvedAirJamRuntimeTopology } from '@air-jam/runtime-topology';
2
+ import { C as ChildHostCapability } from '../host-8hmq_Sgc.cjs';
3
+ export { a as appendRuntimeQueryParams, g as getRuntimeUrlOrigin, n as normalizeRuntimeUrl } from '../url-policy-C89zxgw9.cjs';
4
+ import { A as ArcadeSurfaceRuntimeIdentity } from '../arcade-surface-identity-CQxDpn_w.cjs';
5
+ export { a as arcadeSurfaceRuntimeUrlParams } from '../arcade-runtime-url-BW-MUAOY.cjs';
6
+ import { R as RoomCode } from '../controller-Bod8YYr1.cjs';
7
+ import 'zod';
8
+ import '../notices-NyDM5Mtz.cjs';
9
+ import '../platform-settings-cuor3i11.cjs';
10
+
11
+ /**
12
+ * Centralized URL builder service for Air Jam.
13
+ * Handles IP detection, URL normalization, and construction of all URL types.
14
+ */
15
+ declare class UrlBuilder {
16
+ private cachedLocalIp;
17
+ private ipDetectionPromise;
18
+ /**
19
+ * Get the local network IP address with caching.
20
+ * First call triggers detection, subsequent calls return cached value.
21
+ */
22
+ getLocalIp(): Promise<string | null>;
23
+ /**
24
+ * Clear the cached IP address.
25
+ * Useful for testing or when network changes are detected.
26
+ */
27
+ clearCache(): void;
28
+ /**
29
+ * Normalize a URL for mobile access.
30
+ * Replaces localhost with the local network IP.
31
+ */
32
+ normalizeForMobile(url: string): Promise<string>;
33
+ /**
34
+ * Build a controller URL with room code.
35
+ * Controller is always at {baseUrl}/controller (standardized convention).
36
+ * Automatically uses local IP when running on localhost.
37
+ */
38
+ buildControllerUrl(roomId: RoomCode, options?: {
39
+ host?: string;
40
+ capabilityToken?: string;
41
+ }): Promise<string>;
42
+ /**
43
+ * Resolve the server URL.
44
+ * Uses explicit URL if provided, otherwise infers from window location.
45
+ */
46
+ resolveServerUrl(explicit?: string): string;
47
+ /**
48
+ * Check if a hostname is localhost.
49
+ */
50
+ private isLocalhost;
51
+ /**
52
+ * Normalize an origin string to ensure it has a protocol.
53
+ */
54
+ private normalizeOrigin;
55
+ }
56
+ declare const urlBuilder: UrlBuilder;
57
+
58
+ declare const buildArcadeGameIframeSrc: ({ normalizedUrl, roomId, launchCapability, joinUrl, topology, arcadeSurface, }: {
59
+ normalizedUrl: string;
60
+ roomId: string;
61
+ launchCapability: ChildHostCapability;
62
+ joinUrl?: string | null;
63
+ topology: ResolvedAirJamRuntimeTopology;
64
+ arcadeSurface: ArcadeSurfaceRuntimeIdentity;
65
+ }) => string | null;
66
+ declare const buildArcadeControllerRuntimeUrl: (normalizedUrl: string) => string | null;
67
+
68
+ export { buildArcadeControllerRuntimeUrl, buildArcadeGameIframeSrc, urlBuilder };
@@ -0,0 +1,68 @@
1
+ import { ResolvedAirJamRuntimeTopology } from '@air-jam/runtime-topology';
2
+ import { C as ChildHostCapability } from '../host-Cw-N6e-5.js';
3
+ export { a as appendRuntimeQueryParams, g as getRuntimeUrlOrigin, n as normalizeRuntimeUrl } from '../url-policy-C89zxgw9.js';
4
+ import { A as ArcadeSurfaceRuntimeIdentity } from '../arcade-surface-identity-CQxDpn_w.js';
5
+ export { a as arcadeSurfaceRuntimeUrlParams } from '../arcade-runtime-url-l8qj01Pg.js';
6
+ import { R as RoomCode } from '../controller-DxVchfiA.js';
7
+ import 'zod';
8
+ import '../notices-CnGaaS8B.js';
9
+ import '../platform-settings-cuor3i11.js';
10
+
11
+ /**
12
+ * Centralized URL builder service for Air Jam.
13
+ * Handles IP detection, URL normalization, and construction of all URL types.
14
+ */
15
+ declare class UrlBuilder {
16
+ private cachedLocalIp;
17
+ private ipDetectionPromise;
18
+ /**
19
+ * Get the local network IP address with caching.
20
+ * First call triggers detection, subsequent calls return cached value.
21
+ */
22
+ getLocalIp(): Promise<string | null>;
23
+ /**
24
+ * Clear the cached IP address.
25
+ * Useful for testing or when network changes are detected.
26
+ */
27
+ clearCache(): void;
28
+ /**
29
+ * Normalize a URL for mobile access.
30
+ * Replaces localhost with the local network IP.
31
+ */
32
+ normalizeForMobile(url: string): Promise<string>;
33
+ /**
34
+ * Build a controller URL with room code.
35
+ * Controller is always at {baseUrl}/controller (standardized convention).
36
+ * Automatically uses local IP when running on localhost.
37
+ */
38
+ buildControllerUrl(roomId: RoomCode, options?: {
39
+ host?: string;
40
+ capabilityToken?: string;
41
+ }): Promise<string>;
42
+ /**
43
+ * Resolve the server URL.
44
+ * Uses explicit URL if provided, otherwise infers from window location.
45
+ */
46
+ resolveServerUrl(explicit?: string): string;
47
+ /**
48
+ * Check if a hostname is localhost.
49
+ */
50
+ private isLocalhost;
51
+ /**
52
+ * Normalize an origin string to ensure it has a protocol.
53
+ */
54
+ private normalizeOrigin;
55
+ }
56
+ declare const urlBuilder: UrlBuilder;
57
+
58
+ declare const buildArcadeGameIframeSrc: ({ normalizedUrl, roomId, launchCapability, joinUrl, topology, arcadeSurface, }: {
59
+ normalizedUrl: string;
60
+ roomId: string;
61
+ launchCapability: ChildHostCapability;
62
+ joinUrl?: string | null;
63
+ topology: ResolvedAirJamRuntimeTopology;
64
+ arcadeSurface: ArcadeSurfaceRuntimeIdentity;
65
+ }) => string | null;
66
+ declare const buildArcadeControllerRuntimeUrl: (normalizedUrl: string) => string | null;
67
+
68
+ export { buildArcadeControllerRuntimeUrl, buildArcadeGameIframeSrc, urlBuilder };
@@ -0,0 +1,28 @@
1
+ import {
2
+ buildArcadeControllerRuntimeUrl,
3
+ buildArcadeGameIframeSrc
4
+ } from "../chunk-2J65FXEP.js";
5
+ import "../chunk-ZTQ5SP4H.js";
6
+ import {
7
+ urlBuilder
8
+ } from "../chunk-YXHH3MQT.js";
9
+ import "../chunk-X24K52DG.js";
10
+ import "../chunk-W2VK36RO.js";
11
+ import {
12
+ arcadeSurfaceRuntimeUrlParams
13
+ } from "../chunk-BE6Z4SIT.js";
14
+ import {
15
+ appendRuntimeQueryParams,
16
+ getRuntimeUrlOrigin,
17
+ normalizeRuntimeUrl
18
+ } from "../chunk-3USU7GY2.js";
19
+ export {
20
+ appendRuntimeQueryParams,
21
+ arcadeSurfaceRuntimeUrlParams,
22
+ buildArcadeControllerRuntimeUrl,
23
+ buildArcadeGameIframeSrc,
24
+ getRuntimeUrlOrigin,
25
+ normalizeRuntimeUrl,
26
+ urlBuilder
27
+ };
28
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,28 @@
1
+ import { A as ArcadeSurfaceRuntimeIdentity } from './arcade-surface-identity-CQxDpn_w.cjs';
2
+
3
+ /**
4
+ * Query param for the canonical replicated store domain in embedded runtimes.
5
+ * When set, {@link resolveImplicitReplicatedStoreDomainFromSearchParams} prefers it over derivation from `aj_arcade_*`.
6
+ */
7
+ declare const AIRJAM_STORE_DOMAIN_URL_PARAM = "aj_store_domain";
8
+ /**
9
+ * Stable replicated store domain for an embedded Arcade surface identity (epoch-bound).
10
+ * Used for host/controller `createAirJamStore` in iframes so shell `default` and prior runs do not collide.
11
+ */
12
+ declare const embeddedReplicatedStoreDomainFromArcadeIdentity: (identity: ArcadeSurfaceRuntimeIdentity) => string;
13
+ /**
14
+ * Query params used to pass {@link ArcadeSurfaceRuntimeIdentity} and replicated store domain into embedded iframes.
15
+ */
16
+ declare const arcadeSurfaceRuntimeUrlParams: (identity: ArcadeSurfaceRuntimeIdentity) => Record<string, string>;
17
+ declare const parseOptionalArcadeSurfaceFromSearchParams: (params: URLSearchParams) => ArcadeSurfaceRuntimeIdentity | undefined;
18
+ /**
19
+ * Resolves the implicit networked store domain from the current URL (embedded) or {@link AIR_JAM_DEFAULT_STORE_DOMAIN}.
20
+ * Prefer {@link AIRJAM_STORE_DOMAIN_URL_PARAM} when present; otherwise derive from `aj_arcade_*` when valid.
21
+ */
22
+ declare const resolveImplicitReplicatedStoreDomainFromSearchParams: (params: URLSearchParams) => string;
23
+ /**
24
+ * Browser-only resolver for implicit store domain (SSR-safe: returns default without `window`).
25
+ */
26
+ declare const resolveImplicitReplicatedStoreDomainFromWindow: () => string;
27
+
28
+ export { AIRJAM_STORE_DOMAIN_URL_PARAM as A, arcadeSurfaceRuntimeUrlParams as a, resolveImplicitReplicatedStoreDomainFromWindow as b, embeddedReplicatedStoreDomainFromArcadeIdentity as e, parseOptionalArcadeSurfaceFromSearchParams as p, resolveImplicitReplicatedStoreDomainFromSearchParams as r };
@@ -0,0 +1,28 @@
1
+ import { A as ArcadeSurfaceRuntimeIdentity } from './arcade-surface-identity-CQxDpn_w.js';
2
+
3
+ /**
4
+ * Query param for the canonical replicated store domain in embedded runtimes.
5
+ * When set, {@link resolveImplicitReplicatedStoreDomainFromSearchParams} prefers it over derivation from `aj_arcade_*`.
6
+ */
7
+ declare const AIRJAM_STORE_DOMAIN_URL_PARAM = "aj_store_domain";
8
+ /**
9
+ * Stable replicated store domain for an embedded Arcade surface identity (epoch-bound).
10
+ * Used for host/controller `createAirJamStore` in iframes so shell `default` and prior runs do not collide.
11
+ */
12
+ declare const embeddedReplicatedStoreDomainFromArcadeIdentity: (identity: ArcadeSurfaceRuntimeIdentity) => string;
13
+ /**
14
+ * Query params used to pass {@link ArcadeSurfaceRuntimeIdentity} and replicated store domain into embedded iframes.
15
+ */
16
+ declare const arcadeSurfaceRuntimeUrlParams: (identity: ArcadeSurfaceRuntimeIdentity) => Record<string, string>;
17
+ declare const parseOptionalArcadeSurfaceFromSearchParams: (params: URLSearchParams) => ArcadeSurfaceRuntimeIdentity | undefined;
18
+ /**
19
+ * Resolves the implicit networked store domain from the current URL (embedded) or {@link AIR_JAM_DEFAULT_STORE_DOMAIN}.
20
+ * Prefer {@link AIRJAM_STORE_DOMAIN_URL_PARAM} when present; otherwise derive from `aj_arcade_*` when valid.
21
+ */
22
+ declare const resolveImplicitReplicatedStoreDomainFromSearchParams: (params: URLSearchParams) => string;
23
+ /**
24
+ * Browser-only resolver for implicit store domain (SSR-safe: returns default without `window`).
25
+ */
26
+ declare const resolveImplicitReplicatedStoreDomainFromWindow: () => string;
27
+
28
+ export { AIRJAM_STORE_DOMAIN_URL_PARAM as A, arcadeSurfaceRuntimeUrlParams as a, resolveImplicitReplicatedStoreDomainFromWindow as b, embeddedReplicatedStoreDomainFromArcadeIdentity as e, parseOptionalArcadeSurfaceFromSearchParams as p, resolveImplicitReplicatedStoreDomainFromSearchParams as r };
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Minimum Arcade surface identity for embedded runtime bridge attach (see docs/systems/arcade-surface-contract.md).
5
+ */
6
+ declare const arcadeSurfaceRuntimeIdentitySchema: z.ZodObject<{
7
+ epoch: z.ZodNumber;
8
+ kind: z.ZodEnum<{
9
+ browser: "browser";
10
+ game: "game";
11
+ }>;
12
+ gameId: z.ZodNullable<z.ZodString>;
13
+ }, z.core.$strict>;
14
+ type ArcadeSurfaceRuntimeIdentity = z.infer<typeof arcadeSurfaceRuntimeIdentitySchema>;
15
+
16
+ export { type ArcadeSurfaceRuntimeIdentity as A, arcadeSurfaceRuntimeIdentitySchema as a };