@air-jam/sdk 0.9.3 → 1.0.0-beta.2
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.
- package/README.md +168 -205
- package/dist/actions-D4eh6Xaa.d.cts +72 -0
- package/dist/actions-D4eh6Xaa.d.ts +72 -0
- package/dist/{agent-contract-CD2QnbBJ.d.cts → agent-contract-BMvCMvhE.d.ts} +3 -19
- package/dist/{agent-contract-CD2QnbBJ.d.ts → agent-contract-DtYf3ici.d.cts} +3 -19
- package/dist/agent-tooling.cjs +135 -46
- package/dist/agent-tooling.cjs.map +1 -1
- package/dist/agent-tooling.d.cts +96 -5
- package/dist/agent-tooling.d.ts +96 -5
- package/dist/agent-tooling.js +15 -14
- package/dist/agent-tooling.js.map +1 -1
- package/dist/{use-air-jam-host-COLy8t4s.d.ts → air-jam-context-B1fQvyYY.d.ts} +121 -114
- package/dist/{use-air-jam-host-DM-ybB3C.d.cts → air-jam-context-BKg_ujpd.d.cts} +121 -114
- package/dist/arcade/bridge/controller.cjs +873 -603
- package/dist/arcade/bridge/controller.cjs.map +1 -1
- package/dist/arcade/bridge/controller.d.cts +28 -76
- package/dist/arcade/bridge/controller.d.ts +28 -76
- package/dist/arcade/bridge/controller.js +27 -28
- package/dist/arcade/bridge/controller.js.map +1 -1
- package/dist/arcade/bridge/host.cjs +1017 -252
- package/dist/arcade/bridge/host.cjs.map +1 -1
- package/dist/arcade/bridge/host.d.cts +6 -72
- package/dist/arcade/bridge/host.d.ts +6 -72
- package/dist/arcade/bridge/host.js +19 -22
- package/dist/arcade/bridge/host.js.map +1 -1
- package/dist/arcade/bridge/iframe.cjs +3 -31
- package/dist/arcade/bridge/iframe.cjs.map +1 -1
- package/dist/arcade/bridge/iframe.d.cts +4 -46
- package/dist/arcade/bridge/iframe.d.ts +4 -46
- package/dist/arcade/bridge/iframe.js +6 -18
- package/dist/arcade/bridge/iframe.js.map +1 -1
- package/dist/arcade/host.cjs +0 -502
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.d.cts +1 -19
- package/dist/arcade/host.d.ts +1 -19
- package/dist/arcade/host.js +0 -14
- package/dist/arcade/host.js.map +1 -1
- package/dist/arcade/runtime.cjs +10373 -4688
- package/dist/arcade/runtime.cjs.map +1 -1
- package/dist/arcade/runtime.d.cts +45 -13
- package/dist/arcade/runtime.d.ts +45 -13
- package/dist/arcade/runtime.js +37 -24
- package/dist/arcade/runtime.js.map +1 -1
- package/dist/arcade/surface.cjs +3 -35
- package/dist/arcade/surface.cjs.map +1 -1
- package/dist/arcade/surface.d.cts +14 -2
- package/dist/arcade/surface.d.ts +14 -2
- package/dist/arcade/surface.js +7 -13
- package/dist/arcade/surface.js.map +1 -1
- package/dist/arcade/url.cjs +45 -283
- package/dist/arcade/url.cjs.map +1 -1
- package/dist/arcade/url.d.cts +3 -56
- package/dist/arcade/url.d.ts +3 -56
- package/dist/arcade/url.js +33 -16
- package/dist/arcade/url.js.map +1 -1
- package/dist/chunk-24NZZOIO.js +700 -0
- package/dist/chunk-24NZZOIO.js.map +1 -0
- package/dist/chunk-27QLKLZL.js +469 -0
- package/dist/chunk-27QLKLZL.js.map +1 -0
- package/dist/{chunk-UWJOIVON.js → chunk-2H2FGF3H.js} +3 -6
- package/dist/chunk-2H2FGF3H.js.map +1 -0
- package/dist/chunk-3LDQCQL2.js +307 -0
- package/dist/chunk-3LDQCQL2.js.map +1 -0
- package/dist/chunk-3M7656SU.js +389 -0
- package/dist/chunk-3M7656SU.js.map +1 -0
- package/dist/{chunk-K4OZ54UD.js → chunk-5CRZFIN6.js} +2 -55
- package/dist/chunk-5CRZFIN6.js.map +1 -0
- package/dist/chunk-5L3O3G5K.js +802 -0
- package/dist/chunk-5L3O3G5K.js.map +1 -0
- package/dist/{chunk-O6X7FJ6N.js → chunk-6PLOJMJD.js} +619 -643
- package/dist/chunk-6PLOJMJD.js.map +1 -0
- package/dist/{chunk-EVZJA6RN.js → chunk-6ZJUA63D.js} +183 -2
- package/dist/chunk-6ZJUA63D.js.map +1 -0
- package/dist/chunk-A6EOGRRG.js +49 -0
- package/dist/chunk-A6EOGRRG.js.map +1 -0
- package/dist/chunk-AXG6FA2H.js +366 -0
- package/dist/chunk-AXG6FA2H.js.map +1 -0
- package/dist/chunk-BEM77SVQ.js +57 -0
- package/dist/chunk-BEM77SVQ.js.map +1 -0
- package/dist/chunk-BQHGPXXN.js +1995 -0
- package/dist/chunk-BQHGPXXN.js.map +1 -0
- package/dist/chunk-C5722GTG.js +176 -0
- package/dist/chunk-C5722GTG.js.map +1 -0
- package/dist/{chunk-CV3PBXPT.js → chunk-C5GS2GMK.js} +99 -105
- package/dist/chunk-C5GS2GMK.js.map +1 -0
- package/dist/chunk-CDL7LYZH.js +19 -0
- package/dist/chunk-CDL7LYZH.js.map +1 -0
- package/dist/{chunk-PSUYTD2L.js → chunk-DA3TE4OP.js} +1 -1
- package/dist/chunk-DA3TE4OP.js.map +1 -0
- package/dist/chunk-DBF7NJ3S.js +72 -0
- package/dist/chunk-DBF7NJ3S.js.map +1 -0
- package/dist/chunk-DRBPVG47.js +89 -0
- package/dist/chunk-DRBPVG47.js.map +1 -0
- package/dist/chunk-FCG42U7D.js +131 -0
- package/dist/chunk-FCG42U7D.js.map +1 -0
- package/dist/chunk-FJ4J2BEC.js +26 -0
- package/dist/chunk-FJ4J2BEC.js.map +1 -0
- package/dist/chunk-H4DEVMTO.js +221 -0
- package/dist/chunk-H4DEVMTO.js.map +1 -0
- package/dist/chunk-ISQZ7F3N.js +83 -0
- package/dist/chunk-ISQZ7F3N.js.map +1 -0
- package/dist/{chunk-IG6GZZSS.js → chunk-JCGTL77W.js} +1 -1
- package/dist/chunk-JCGTL77W.js.map +1 -0
- package/dist/chunk-JJVCBUYM.js +98 -0
- package/dist/chunk-JJVCBUYM.js.map +1 -0
- package/dist/chunk-K6BJJJJM.js +138 -0
- package/dist/chunk-K6BJJJJM.js.map +1 -0
- package/dist/{chunk-MIMPMB7O.js → chunk-KGY4PV2A.js} +24 -3
- package/dist/chunk-KGY4PV2A.js.map +1 -0
- package/dist/chunk-KKRLHT2M.js +2477 -0
- package/dist/chunk-KKRLHT2M.js.map +1 -0
- package/dist/chunk-KSYN4I5Y.js +50 -0
- package/dist/chunk-KSYN4I5Y.js.map +1 -0
- package/dist/chunk-KUGROY5S.js +265 -0
- package/dist/chunk-KUGROY5S.js.map +1 -0
- package/dist/chunk-LX6CTPDW.js +16 -0
- package/dist/chunk-LX6CTPDW.js.map +1 -0
- package/dist/{chunk-BE6Z4SIT.js → chunk-M5553I2G.js} +2 -11
- package/dist/chunk-M5553I2G.js.map +1 -0
- package/dist/{chunk-X24K52DG.js → chunk-MD25536W.js} +1 -1
- package/dist/chunk-MD25536W.js.map +1 -0
- package/dist/{chunk-3USU7GY2.js → chunk-MJAWAHLT.js} +1 -1
- package/dist/chunk-MJAWAHLT.js.map +1 -0
- package/dist/chunk-NBA7UIWG.js +921 -0
- package/dist/chunk-NBA7UIWG.js.map +1 -0
- package/dist/chunk-OAXCFPZ7.js +14 -0
- package/dist/chunk-OAXCFPZ7.js.map +1 -0
- package/dist/{chunk-D4VDEVTZ.js → chunk-QHBRHYMV.js} +18 -17
- package/dist/chunk-QHBRHYMV.js.map +1 -0
- package/dist/chunk-QTNYGAZ7.js +45 -0
- package/dist/chunk-QTNYGAZ7.js.map +1 -0
- package/dist/chunk-UC24OG4X.js +129 -0
- package/dist/chunk-UC24OG4X.js.map +1 -0
- package/dist/chunk-VN2PX2I3.js +188 -0
- package/dist/chunk-VN2PX2I3.js.map +1 -0
- package/dist/chunk-WAFGYJZN.js +1513 -0
- package/dist/chunk-WAFGYJZN.js.map +1 -0
- package/dist/chunk-WGHNGQUS.js +78 -0
- package/dist/chunk-WGHNGQUS.js.map +1 -0
- package/dist/{chunk-X35LLCWV.js → chunk-X5HZBQ6K.js} +6 -8
- package/dist/chunk-X5HZBQ6K.js.map +1 -0
- package/dist/chunk-XLY44PXZ.js +46 -0
- package/dist/chunk-XLY44PXZ.js.map +1 -0
- package/dist/chunk-YXHAWWVU.js +7 -0
- package/dist/chunk-YXHAWWVU.js.map +1 -0
- package/dist/connection-store-CqW-E7ma.d.cts +41 -0
- package/dist/connection-store-ffHWMrMe.d.ts +41 -0
- package/dist/control-Bv8dWjyp.d.ts +1400 -0
- package/dist/control-CNzybWMd.d.cts +1400 -0
- package/dist/controller-ClW0R8mZ.d.cts +26 -0
- package/dist/controller-DRKCa7uQ.d.ts +26 -0
- package/dist/controller-agent-vOiuK7T6.d.cts +130 -0
- package/dist/controller-agent-vOiuK7T6.d.ts +130 -0
- package/dist/controller-bridge.cjs +992 -0
- package/dist/controller-bridge.cjs.map +1 -0
- package/dist/controller-bridge.d.cts +52 -0
- package/dist/controller-bridge.d.ts +52 -0
- package/dist/controller-bridge.js +23 -0
- package/dist/controller-bridge.js.map +1 -0
- package/dist/controller-capture-2GKKGHJ2.js +8 -0
- package/dist/controller-capture-2GKKGHJ2.js.map +1 -0
- package/dist/controller-press-EWWIMVXP.js +231 -0
- package/dist/controller-press-EWWIMVXP.js.map +1 -0
- package/dist/core-BAO0pHrJ.d.cts +15 -0
- package/dist/core-BAO0pHrJ.d.ts +15 -0
- package/dist/core.cjs +5956 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +250 -0
- package/dist/core.d.ts +250 -0
- package/dist/core.js +910 -0
- package/dist/core.js.map +1 -0
- package/dist/dev-events-BffobOfb.d.ts +31 -0
- package/dist/dev-events-Ct7QEgKb.d.cts +31 -0
- package/dist/dev-log-events-B1_B3guZ.d.cts +47 -0
- package/dist/dev-log-events-B1_B3guZ.d.ts +47 -0
- package/dist/frames-D-xKuODS.d.cts +686 -0
- package/dist/frames-D-xKuODS.d.ts +686 -0
- package/dist/game-5n-dh5np.d.cts +77 -0
- package/dist/game-RYb97BN8.d.ts +77 -0
- package/dist/host-runtime-BRtUidEJ.d.cts +399 -0
- package/dist/host-runtime-RrO4pCXI.d.ts +399 -0
- package/dist/index.cjs +11571 -7554
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -358
- package/dist/index.d.ts +100 -358
- package/dist/index.js +414 -1903
- package/dist/index.js.map +1 -1
- package/dist/input-D7FNeehb.d.cts +92 -0
- package/dist/input-D7FNeehb.d.ts +92 -0
- package/dist/input-bindings-686sTen7.d.ts +129 -0
- package/dist/input-bindings-BRac-P0e.d.cts +129 -0
- package/dist/leased-control-BEg4JuXA.d.cts +158 -0
- package/dist/leased-control-BEg4JuXA.d.ts +158 -0
- package/dist/metadata.cjs +3 -9
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +6 -16
- package/dist/metadata.d.ts +6 -16
- package/dist/metadata.js +8 -76
- package/dist/metadata.js.map +1 -1
- package/dist/phone-room-session-Byomkt92.d.cts +439 -0
- package/dist/phone-room-session-D9C8cSxS.d.ts +439 -0
- package/dist/platform-machine.cjs +133 -3
- package/dist/platform-machine.cjs.map +1 -1
- package/dist/platform-machine.d.cts +525 -27
- package/dist/platform-machine.d.ts +525 -27
- package/dist/platform-machine.js +119 -4
- package/dist/platform-machine.js.map +1 -1
- package/dist/{platform-settings-DUWs4JTy.d.cts → platform-settings-Yb0fQ1dl.d.cts} +1 -3
- package/dist/{platform-settings-DUWs4JTy.d.ts → platform-settings-Yb0fQ1dl.d.ts} +1 -3
- package/dist/prefabs.cjs +134 -3
- package/dist/prefabs.cjs.map +1 -1
- package/dist/prefabs.d.cts +23 -47
- package/dist/prefabs.d.ts +23 -47
- package/dist/prefabs.js +23 -4
- package/dist/prefabs.js.map +1 -1
- package/dist/preview.cjs +2199 -767
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +193 -38
- package/dist/preview.d.ts +193 -38
- package/dist/preview.js +478 -254
- package/dist/preview.js.map +1 -1
- package/dist/protocol.cjs +585 -391
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +13 -117
- package/dist/protocol.d.ts +13 -117
- package/dist/protocol.js +43 -80
- package/dist/protocol.js.map +1 -1
- package/dist/release.cjs.map +1 -1
- package/dist/release.d.cts +2 -2
- package/dist/release.d.ts +2 -2
- package/dist/release.js +1 -1
- package/dist/release.js.map +1 -1
- package/dist/replay-input-log-D0NpnA3P.d.ts +31 -0
- package/dist/replay-input-log-bg0g-PCz.d.cts +31 -0
- package/dist/room-protocol.cjs +794 -0
- package/dist/room-protocol.cjs.map +1 -0
- package/dist/room-protocol.d.cts +63 -0
- package/dist/room-protocol.d.ts +63 -0
- package/dist/room-protocol.js +143 -0
- package/dist/room-protocol.js.map +1 -0
- package/dist/room-session.cjs +2336 -0
- package/dist/room-session.cjs.map +1 -0
- package/dist/room-session.d.cts +77 -0
- package/dist/room-session.d.ts +77 -0
- package/dist/room-session.js +103 -0
- package/dist/room-session.js.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.cjs +207 -0
- package/dist/runtime/prefab-inspection-bridge.cjs.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.d.cts +156 -0
- package/dist/runtime/prefab-inspection-bridge.d.ts +156 -0
- package/dist/runtime/prefab-inspection-bridge.js +22 -0
- package/dist/runtime/prefab-inspection-bridge.js.map +1 -0
- package/dist/runtime-control.cjs +2133 -8
- package/dist/runtime-control.cjs.map +1 -1
- package/dist/runtime-control.d.cts +980 -12
- package/dist/runtime-control.d.ts +980 -12
- package/dist/runtime-control.js +264 -4
- package/dist/runtime-control.js.map +1 -1
- package/dist/runtime-inspection.cjs +1222 -558
- package/dist/runtime-inspection.cjs.map +1 -1
- package/dist/runtime-inspection.d.cts +530 -22
- package/dist/runtime-inspection.d.ts +530 -22
- package/dist/runtime-inspection.js +21 -22
- package/dist/runtime-inspection.js.map +1 -1
- package/dist/runtime-reporting-K_ZXpubu.d.cts +43 -0
- package/dist/runtime-reporting-K_ZXpubu.d.ts +43 -0
- package/dist/runtime-topology.cjs +2 -5
- package/dist/runtime-topology.cjs.map +1 -1
- package/dist/runtime-topology.d.cts +1 -1
- package/dist/runtime-topology.d.ts +1 -1
- package/dist/runtime-topology.js +1 -1
- package/dist/runtime-topology.js.map +1 -1
- package/dist/scoped-connector-DEOZvCCG.d.cts +66 -0
- package/dist/scoped-connector-nTHACYTl.d.ts +66 -0
- package/dist/sdk-channels-S6j6AH8v.d.cts +103 -0
- package/dist/sdk-channels-S6j6AH8v.d.ts +103 -0
- package/dist/simulation-DL9j-ghn.d.ts +782 -0
- package/dist/simulation-HmgsvF5H.d.cts +782 -0
- package/dist/{standard-match-phase-BzSgBYFg.d.ts → standard-match-phase-D4N-AU0d.d.cts} +3 -13
- package/dist/{standard-match-phase-CvJUW8Oe.d.cts → standard-match-phase-abt8ZjCh.d.ts} +3 -13
- package/dist/transport-CWF29jU6.d.cts +173 -0
- package/dist/transport-CWF29jU6.d.ts +173 -0
- package/dist/types-p28maMEo.d.cts +102 -0
- package/dist/types-p28maMEo.d.ts +102 -0
- package/dist/ui.cjs +2167 -892
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +75 -17
- package/dist/ui.d.ts +75 -17
- package/dist/ui.js +554 -393
- package/dist/ui.js.map +1 -1
- package/package.json +38 -21
- package/src/agent/agent-action.ts +0 -39
- package/src/agent/agent-contract-conformance.ts +8 -1
- package/src/agent/agent-contract.ts +2 -4
- package/src/agent/agent-evaluator.ts +95 -0
- package/src/agent/capture-canvas.ts +79 -0
- package/src/agent/host-canvas-capture.ts +189 -0
- package/src/agent-tooling.ts +5 -20
- package/src/arcade/bridge/controller.ts +8 -11
- package/src/arcade/bridge/host.ts +6 -11
- package/src/arcade/bridge/iframe.ts +1 -50
- package/src/arcade/host.ts +0 -1
- package/src/arcade/surface.ts +5 -1
- package/src/arcade/url.ts +2 -9
- package/src/audio/audio-manager.ts +23 -47
- package/src/audio/hooks.tsx +59 -72
- package/src/components/controller-player-name-field.tsx +2 -2
- package/src/components/controller-primary-action.tsx +1 -1
- package/src/components/controls.tsx +398 -0
- package/src/components/gamepad-layout.tsx +69 -0
- package/src/components/join-url-controls.tsx +5 -1
- package/src/components/lifecycle-action-group.tsx +1 -1
- package/src/components/player-avatar.tsx +50 -3
- package/src/components/room-qr-code.tsx +36 -77
- package/src/components/stage-capture-surface.tsx +91 -0
- package/src/components/surface-viewport.tsx +16 -3
- package/src/components/ui/button.tsx +1 -1
- package/src/constants.ts +0 -15
- package/src/context/air-jam-context.tsx +56 -187
- package/src/context/session-providers.tsx +13 -10
- package/src/controller-bridge.ts +7 -0
- package/src/core/assets.ts +48 -0
- package/src/core/config.ts +70 -0
- package/src/core/connection-store.ts +77 -0
- package/src/core/controller-input.ts +147 -0
- package/src/core/controller-runtime.ts +427 -0
- package/src/core/dev-events.ts +18 -0
- package/src/core/environment.ts +132 -0
- package/src/core/game-description.ts +44 -0
- package/src/core/game.ts +130 -0
- package/src/core/host-input.ts +207 -0
- package/src/core/host-runtime.ts +988 -0
- package/src/core/hosted-rooms.ts +65 -0
- package/src/core/input-bindings.ts +180 -0
- package/src/core/input-log.ts +144 -0
- package/src/core/input.ts +228 -0
- package/src/core/local-input.ts +319 -0
- package/src/core/replay-input-log.ts +298 -0
- package/src/core/replicated-store.ts +1178 -0
- package/src/core/room-action-ack.ts +43 -0
- package/src/core/settings.ts +202 -0
- package/src/core/simulation.ts +307 -0
- package/src/core/theme.ts +33 -0
- package/src/core.ts +167 -0
- package/src/dev/browser-log-sink.ts +35 -12
- package/src/diagnostics.ts +5 -6
- package/src/hooks/internal/use-controller-runtime-api.ts +58 -925
- package/src/hooks/internal/use-host-runtime-api.ts +98 -1270
- package/src/hooks/internal/use-runtime-inspection-contract.ts +14 -2
- package/src/hooks/use-air-jam-controller.ts +32 -53
- package/src/hooks/use-air-jam-host.ts +59 -100
- package/src/hooks/use-air-jam-settings.ts +27 -0
- package/src/hooks/use-controller-toasts.ts +16 -19
- package/src/hooks/use-host-agent-capture.ts +31 -0
- package/src/hooks/use-lifecycle-action-group-model.ts +1 -1
- package/src/hooks/use-send-signal.ts +23 -156
- package/src/hooks/use-simulation.ts +83 -0
- package/src/index.ts +24 -85
- package/src/lifecycle/index.ts +0 -4
- package/src/lifecycle/standard-match-phase.ts +1 -22
- package/src/metadata/manifest.ts +8 -19
- package/src/metadata.ts +1 -1
- package/src/platform-machine.ts +127 -3
- package/src/prefabs/types.ts +91 -20
- package/src/prefabs/view.ts +82 -0
- package/src/prefabs.ts +19 -0
- package/src/preview/host-workspace.tsx +4 -9
- package/src/preview/identity.ts +31 -23
- package/src/preview/layout.ts +5 -1
- package/src/preview/manager.ts +205 -78
- package/src/preview/messages.ts +47 -0
- package/src/preview/ownership.ts +6 -1
- package/src/preview/url.ts +46 -23
- package/src/preview/window.tsx +26 -69
- package/src/preview/workspace-local-seats.ts +166 -0
- package/src/preview/workspace.tsx +89 -37
- package/src/preview.ts +27 -15
- package/src/protocol/actions.ts +58 -0
- package/src/protocol/arcade-platform-actions.ts +2 -16
- package/src/protocol/controller.ts +14 -174
- package/src/protocol/core.ts +8 -15
- package/src/protocol/dev-log-events.ts +5 -81
- package/src/protocol/leased-control.ts +177 -0
- package/src/protocol/room/addressing.ts +35 -0
- package/src/protocol/room/close-codes.ts +33 -0
- package/src/protocol/room/frames.ts +343 -0
- package/src/protocol/room/input-codec.ts +182 -0
- package/src/protocol/room/limits.ts +58 -0
- package/src/protocol/room/patch.ts +135 -0
- package/src/protocol/room/sdk-channels.ts +81 -0
- package/src/protocol/room/seat-id.ts +31 -0
- package/src/protocol/room/transport.ts +63 -0
- package/src/protocol/room/weight.ts +58 -0
- package/src/protocol/runtime-reporting.ts +56 -10
- package/src/protocol.ts +2 -7
- package/src/qrcode.d.ts +3 -13
- package/src/room-protocol.ts +10 -0
- package/src/room-session/browser-wake-events.ts +14 -0
- package/src/room-session/channel-state.ts +293 -0
- package/src/room-session/clock.ts +24 -0
- package/src/room-session/host-room-session.ts +379 -0
- package/src/room-session/input-lane.ts +125 -0
- package/src/room-session/listeners.ts +22 -0
- package/src/room-session/loopback-link.ts +58 -0
- package/src/room-session/phone-room-session.ts +368 -0
- package/src/room-session/port-link.ts +116 -0
- package/src/room-session/room-key.ts +9 -0
- package/src/room-session/roster.ts +23 -0
- package/src/room-session/scoped-connector.ts +577 -0
- package/src/room-session/session-link.ts +306 -0
- package/src/room-session/web-socket-link.ts +57 -0
- package/src/room-session.ts +12 -0
- package/src/runtime/air-jam-config.ts +49 -37
- package/src/runtime/air-jam-error-boundary.tsx +9 -3
- package/src/runtime/arcade-runtime-url.ts +8 -9
- package/src/runtime/browser-controller-environment.ts +116 -0
- package/src/runtime/browser-host-environment.ts +137 -0
- package/src/runtime/browser-replay.ts +211 -0
- package/src/runtime/browser-room.ts +41 -0
- package/src/runtime/connected-runtime-error-boundary.tsx +35 -8
- package/src/runtime/contracts/agent-control.ts +195 -0
- package/src/runtime/contracts/clip.ts +169 -0
- package/src/runtime/contracts/control.ts +653 -16
- package/src/runtime/contracts/controller-agent.ts +130 -0
- package/src/runtime/contracts/input-log.ts +38 -0
- package/src/runtime/contracts/inspection.ts +25 -22
- package/src/runtime/contracts/observation.ts +186 -0
- package/src/runtime/contracts/runtime-identity.ts +43 -0
- package/src/runtime/contracts/timeline.ts +59 -0
- package/src/runtime/controller-agent-bridge.ts +152 -0
- package/src/runtime/controller-bridge-context.ts +29 -0
- package/src/runtime/controller-capture.ts +50 -0
- package/src/runtime/controller-identity.ts +53 -142
- package/src/runtime/controller-presentation.ts +47 -17
- package/src/runtime/controller-press.ts +271 -0
- package/src/runtime/create-air-jam-app.tsx +103 -74
- package/src/runtime/dev-runtime-events.ts +6 -18
- package/src/runtime/embedded-parent.ts +22 -0
- package/src/runtime/embedded-runtime-adapters.ts +10 -9
- package/src/runtime/host-agent-bridge.ts +127 -0
- package/src/runtime/host-capture-boundary.tsx +92 -0
- package/src/runtime/host-capture-context.ts +7 -0
- package/src/runtime/host-clip-reader.ts +93 -0
- package/src/runtime/host-clip-recorder.ts +342 -0
- package/src/runtime/host-input-log-reader.ts +120 -0
- package/src/runtime/host-observation.ts +207 -0
- package/src/runtime/host-pace.ts +36 -0
- package/src/runtime/host-runtime-fault.ts +51 -0
- package/src/runtime/host-timeline.ts +152 -0
- package/src/runtime/local-players.tsx +96 -0
- package/src/runtime/local-seats.ts +612 -0
- package/src/runtime/participant-control.ts +162 -0
- package/src/runtime/prefab-inspection-bridge.ts +174 -0
- package/src/runtime/prefab-inspection-clock.ts +12 -0
- package/src/runtime/prefab-inspection-context.ts +20 -0
- package/src/runtime/prefab-inspection-runtime.tsx +328 -0
- package/src/runtime/preview-inspection-bridge.ts +130 -0
- package/src/runtime/replay-runtime.tsx +101 -0
- package/src/runtime/room-bridge.ts +110 -0
- package/src/runtime/runtime-owner-contexts.tsx +9 -0
- package/src/runtime/runtime-session-params.ts +20 -23
- package/src/runtime/session-runtimes.tsx +231 -64
- package/src/runtime/stage-capture.ts +25 -0
- package/src/runtime-control.ts +41 -0
- package/src/runtime-inspection.ts +14 -7
- package/src/runtime-topology.ts +7 -8
- package/src/settings/platform-settings-runtime.tsx +47 -2
- package/src/settings/platform-settings.ts +0 -65
- package/src/store/use-air-jam-store.ts +73 -0
- package/src/ui.ts +3 -3
- package/src/utils/is-rpc-serializable.ts +11 -19
- package/src/utils/url-builder.ts +0 -7
- package/dist/air-jam-context-BlLPvCup.d.cts +0 -175
- package/dist/air-jam-context-DTsxF-tP.d.ts +0 -175
- package/dist/arcade/bridge.cjs +0 -1087
- package/dist/arcade/bridge.cjs.map +0 -1
- package/dist/arcade/bridge.d.cts +0 -11
- package/dist/arcade/bridge.d.ts +0 -11
- package/dist/arcade/bridge.js +0 -78
- package/dist/arcade/bridge.js.map +0 -1
- package/dist/arcade-runtime-url-BW-MUAOY.d.cts +0 -28
- package/dist/arcade-runtime-url-l8qj01Pg.d.ts +0 -28
- package/dist/arcade.cjs +0 -1767
- package/dist/arcade.cjs.map +0 -1
- package/dist/arcade.d.cts +0 -18
- package/dist/arcade.d.ts +0 -18
- package/dist/arcade.js +0 -129
- package/dist/arcade.js.map +0 -1
- package/dist/chunk-2SZ2YYGJ.js +0 -280
- package/dist/chunk-2SZ2YYGJ.js.map +0 -1
- package/dist/chunk-32RSSFSF.js +0 -214
- package/dist/chunk-32RSSFSF.js.map +0 -1
- package/dist/chunk-3USU7GY2.js.map +0 -1
- package/dist/chunk-3YMUAKPU.js +0 -10
- package/dist/chunk-3YMUAKPU.js.map +0 -1
- package/dist/chunk-56DM2KEW.js +0 -14
- package/dist/chunk-56DM2KEW.js.map +0 -1
- package/dist/chunk-BE6Z4SIT.js.map +0 -1
- package/dist/chunk-CM53YLT5.js +0 -59
- package/dist/chunk-CM53YLT5.js.map +0 -1
- package/dist/chunk-CV3PBXPT.js.map +0 -1
- package/dist/chunk-D4VDEVTZ.js.map +0 -1
- package/dist/chunk-EVZJA6RN.js.map +0 -1
- package/dist/chunk-FUA6EMSJ.js +0 -90
- package/dist/chunk-FUA6EMSJ.js.map +0 -1
- package/dist/chunk-GMLU7RI5.js +0 -70
- package/dist/chunk-GMLU7RI5.js.map +0 -1
- package/dist/chunk-IG6GZZSS.js.map +0 -1
- package/dist/chunk-IKKDONQL.js +0 -1
- package/dist/chunk-IKKDONQL.js.map +0 -1
- package/dist/chunk-ITMQSBTH.js +0 -26
- package/dist/chunk-ITMQSBTH.js.map +0 -1
- package/dist/chunk-J5MCII33.js +0 -620
- package/dist/chunk-J5MCII33.js.map +0 -1
- package/dist/chunk-JTF47B56.js +0 -1
- package/dist/chunk-JTF47B56.js.map +0 -1
- package/dist/chunk-K4OZ54UD.js.map +0 -1
- package/dist/chunk-LIHEEAVE.js +0 -191
- package/dist/chunk-LIHEEAVE.js.map +0 -1
- package/dist/chunk-LIXPF4P6.js +0 -22
- package/dist/chunk-LIXPF4P6.js.map +0 -1
- package/dist/chunk-MIMPMB7O.js.map +0 -1
- package/dist/chunk-MPDMJIX5.js +0 -1
- package/dist/chunk-MPDMJIX5.js.map +0 -1
- package/dist/chunk-O6X7FJ6N.js.map +0 -1
- package/dist/chunk-PSUYTD2L.js.map +0 -1
- package/dist/chunk-QO4KFUEI.js +0 -32
- package/dist/chunk-QO4KFUEI.js.map +0 -1
- package/dist/chunk-QTLYZADF.js +0 -125
- package/dist/chunk-QTLYZADF.js.map +0 -1
- package/dist/chunk-TGRTEWYV.js +0 -195
- package/dist/chunk-TGRTEWYV.js.map +0 -1
- package/dist/chunk-TTQDHKXL.js +0 -3017
- package/dist/chunk-TTQDHKXL.js.map +0 -1
- package/dist/chunk-UCPY7UJC.js +0 -8
- package/dist/chunk-UCPY7UJC.js.map +0 -1
- package/dist/chunk-UPV6YWT5.js +0 -43
- package/dist/chunk-UPV6YWT5.js.map +0 -1
- package/dist/chunk-UWJOIVON.js.map +0 -1
- package/dist/chunk-W2VK36RO.js +0 -11
- package/dist/chunk-W2VK36RO.js.map +0 -1
- package/dist/chunk-X24K52DG.js.map +0 -1
- package/dist/chunk-X35LLCWV.js.map +0 -1
- package/dist/chunk-YXHH3MQT.js +0 -230
- package/dist/chunk-YXHH3MQT.js.map +0 -1
- package/dist/controller-PZEM_1cH.d.ts +0 -176
- package/dist/controller-vj82tKm4.d.cts +0 -176
- package/dist/dev-log-events-BCJKmygo.d.cts +0 -120
- package/dist/dev-log-events-BCJKmygo.d.ts +0 -120
- package/dist/handshake-CC_LrK5g.d.cts +0 -31
- package/dist/handshake-CC_LrK5g.d.ts +0 -31
- package/dist/host-B9pRy0Aa.d.cts +0 -122
- package/dist/host-DylGsX7p.d.ts +0 -122
- package/dist/notices-C4bao3oi.d.ts +0 -38
- package/dist/notices-DNdOjwtj.d.cts +0 -38
- package/dist/realtime-client-Cu8yVJFw.d.cts +0 -15
- package/dist/realtime-client-Cu8yVJFw.d.ts +0 -15
- package/dist/runtime-reporting-pe-eryVz.d.cts +0 -27
- package/dist/runtime-reporting-pe-eryVz.d.ts +0 -27
- package/dist/signals-ZHftIKuc.d.cts +0 -33
- package/dist/signals-ZHftIKuc.d.ts +0 -33
- package/dist/sync-xtPfWhif.d.cts +0 -81
- package/dist/sync-xtPfWhif.d.ts +0 -81
- package/src/arcade/bridge.ts +0 -3
- package/src/arcade.ts +0 -4
- package/src/context/socket-manager.ts +0 -72
- package/src/events.ts +0 -119
- package/src/hooks/use-connection-status.ts +0 -8
- package/src/hooks/use-controller-tick.ts +0 -65
- package/src/hooks/use-get-input.ts +0 -100
- package/src/hooks/use-host-arcade-restore.ts +0 -35
- package/src/hooks/use-host-tick.ts +0 -171
- package/src/hooks/use-input-writer.ts +0 -83
- package/src/hooks/use-players.ts +0 -12
- package/src/internal/input-manager.ts +0 -356
- package/src/protocol/errors.ts +0 -21
- package/src/protocol/host-grant.ts +0 -103
- package/src/protocol/host.ts +0 -150
- package/src/protocol/notices.ts +0 -43
- package/src/protocol/signals.ts +0 -38
- package/src/protocol/socket-events.ts +0 -152
- package/src/protocol/sync.ts +0 -105
- package/src/runtime/admission-retry.ts +0 -62
- package/src/runtime/bridge-envelope-args.ts +0 -21
- package/src/runtime/controller-bridge.ts +0 -439
- package/src/runtime/controller-realtime-client.ts +0 -552
- package/src/runtime/host-bridge.ts +0 -380
- package/src/runtime/host-realtime-client.ts +0 -550
- package/src/runtime/realtime-client.ts +0 -20
- package/src/runtime/validate-arcade-bridge-attach.ts +0 -14
- package/src/state/connection-store.ts +0 -159
- package/src/store/create-air-jam-store.ts +0 -1193
- package/src/store/index.ts +0 -1
- package/src/utils/ids.ts +0 -58
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
readChildHostRuntimeParams,
|
|
3
|
+
readEmbeddedControllerRuntimeParams
|
|
4
|
+
} from "./chunk-QHBRHYMV.js";
|
|
5
|
+
import {
|
|
6
|
+
AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
7
|
+
AIRJAM_DEV_PROVIDER_MOUNTED,
|
|
8
|
+
AIRJAM_DEV_RUNTIME_EVENT,
|
|
9
|
+
emitAirJamDevRuntimeEvent,
|
|
10
|
+
initializeInheritedPlatformSettingsBridge
|
|
11
|
+
} from "./chunk-KGY4PV2A.js";
|
|
12
|
+
import {
|
|
13
|
+
isAirJamReplayDocument
|
|
14
|
+
} from "./chunk-VN2PX2I3.js";
|
|
15
|
+
import {
|
|
16
|
+
embeddedRuntimeParent
|
|
17
|
+
} from "./chunk-LX6CTPDW.js";
|
|
18
|
+
import {
|
|
19
|
+
controllerBridgeContext
|
|
20
|
+
} from "./chunk-FJ4J2BEC.js";
|
|
21
|
+
import {
|
|
22
|
+
createAirJamDiagnosticError,
|
|
23
|
+
emitAirJamDiagnostic,
|
|
24
|
+
onAirJamDiagnostic
|
|
25
|
+
} from "./chunk-DBF7NJ3S.js";
|
|
26
|
+
import {
|
|
27
|
+
AIRJAM_DEV_LOG_EVENTS,
|
|
28
|
+
resolveAirJamBrowserConsoleCategory
|
|
29
|
+
} from "./chunk-KUGROY5S.js";
|
|
30
|
+
import {
|
|
31
|
+
createAirJamConfig,
|
|
32
|
+
createConnectionStore
|
|
33
|
+
} from "./chunk-AXG6FA2H.js";
|
|
4
34
|
import {
|
|
5
35
|
isLocalDevControlSurfaceTopology,
|
|
6
36
|
parseRuntimeTopologyFromSearchParams,
|
|
@@ -8,99 +38,508 @@ import {
|
|
|
8
38
|
readRuntimeTopologyFromWindow,
|
|
9
39
|
resolveProjectRuntimeTopology,
|
|
10
40
|
resolveRuntimeTopology
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
14
|
-
AIRJAM_DEV_PROVIDER_MOUNTED,
|
|
15
|
-
AIRJAM_DEV_RUNTIME_EVENT,
|
|
16
|
-
emitAirJamDevRuntimeEvent
|
|
17
|
-
} from "./chunk-LIXPF4P6.js";
|
|
41
|
+
} from "./chunk-2H2FGF3H.js";
|
|
18
42
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
DEFAULT_PLATFORM_SETTINGS,
|
|
44
|
+
PLATFORM_SETTINGS_STORAGE_KEY,
|
|
45
|
+
getEffectiveAudioVolume,
|
|
46
|
+
mergePlatformSettings,
|
|
47
|
+
normalizePlatformSettings
|
|
48
|
+
} from "./chunk-5CRZFIN6.js";
|
|
22
49
|
import {
|
|
23
|
-
|
|
24
|
-
} from "./chunk-
|
|
50
|
+
roomCodeSchema
|
|
51
|
+
} from "./chunk-24NZZOIO.js";
|
|
25
52
|
|
|
26
|
-
// src/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
53
|
+
// src/settings/platform-settings-runtime.tsx
|
|
54
|
+
import {
|
|
55
|
+
createContext,
|
|
56
|
+
useCallback,
|
|
57
|
+
useContext,
|
|
58
|
+
useEffect,
|
|
59
|
+
useMemo,
|
|
60
|
+
useState
|
|
61
|
+
} from "react";
|
|
62
|
+
import { jsx } from "react/jsx-runtime";
|
|
63
|
+
var tryParseJson = (raw) => {
|
|
64
|
+
if (!raw) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(raw);
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
40
72
|
};
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
73
|
+
var readPersistedPlatformSettings = () => {
|
|
74
|
+
if (typeof window === "undefined") {
|
|
75
|
+
return DEFAULT_PLATFORM_SETTINGS;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const current = tryParseJson(
|
|
79
|
+
window.localStorage.getItem(PLATFORM_SETTINGS_STORAGE_KEY)
|
|
80
|
+
);
|
|
81
|
+
if (current) {
|
|
82
|
+
return normalizePlatformSettings(current);
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
45
85
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
86
|
+
return DEFAULT_PLATFORM_SETTINGS;
|
|
87
|
+
};
|
|
88
|
+
var persistPlatformSettings = (snapshot) => {
|
|
89
|
+
if (typeof window === "undefined") {
|
|
50
90
|
return;
|
|
51
91
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
listener(diagnostic);
|
|
92
|
+
try {
|
|
93
|
+
window.localStorage.setItem(
|
|
94
|
+
PLATFORM_SETTINGS_STORAGE_KEY,
|
|
95
|
+
JSON.stringify(snapshot)
|
|
96
|
+
);
|
|
97
|
+
} catch {
|
|
59
98
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
99
|
+
};
|
|
100
|
+
var platformSettingsContext = createContext(null);
|
|
101
|
+
var getInitialMode = (persistence) => {
|
|
102
|
+
if (typeof window === "undefined") {
|
|
103
|
+
return persistence === "local" ? "owner" : "default";
|
|
104
|
+
}
|
|
105
|
+
if (window.parent !== window) {
|
|
106
|
+
return "inherited";
|
|
64
107
|
}
|
|
65
|
-
|
|
108
|
+
return persistence === "local" ? "owner" : "default";
|
|
66
109
|
};
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
110
|
+
var createDefaultContextValue = () => ({
|
|
111
|
+
mode: "default",
|
|
112
|
+
status: "ready",
|
|
113
|
+
settings: DEFAULT_PLATFORM_SETTINGS,
|
|
114
|
+
setSettings: () => {
|
|
115
|
+
throw new Error(
|
|
116
|
+
'Platform settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
117
|
+
);
|
|
118
|
+
},
|
|
119
|
+
updateSettings: () => {
|
|
120
|
+
throw new Error(
|
|
121
|
+
'Platform settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
function PlatformSettingsRuntime({
|
|
126
|
+
children,
|
|
127
|
+
persistence = "none"
|
|
128
|
+
}) {
|
|
129
|
+
const mode = getInitialMode(persistence);
|
|
130
|
+
const [settings, setSettingsState] = useState(
|
|
131
|
+
() => mode === "owner" ? readPersistedPlatformSettings() : DEFAULT_PLATFORM_SETTINGS
|
|
132
|
+
);
|
|
133
|
+
const [status, setStatus] = useState(
|
|
134
|
+
() => mode === "inherited" ? "waiting" : "ready"
|
|
135
|
+
);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (mode === "owner") {
|
|
138
|
+
setStatus("ready");
|
|
139
|
+
setSettingsState(readPersistedPlatformSettings());
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
setSettingsState(DEFAULT_PLATFORM_SETTINGS);
|
|
143
|
+
setStatus(mode === "inherited" ? "waiting" : "ready");
|
|
144
|
+
}, [mode]);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (mode !== "owner") {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
persistPlatformSettings(settings);
|
|
150
|
+
}, [mode, settings]);
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (mode !== "owner" || typeof window === "undefined") {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const handleStorage = (event) => {
|
|
156
|
+
if (event.storageArea !== window.localStorage) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (event.key !== null && event.key !== PLATFORM_SETTINGS_STORAGE_KEY) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
setSettingsState(readPersistedPlatformSettings());
|
|
163
|
+
};
|
|
164
|
+
window.addEventListener("storage", handleStorage);
|
|
165
|
+
return () => {
|
|
166
|
+
window.removeEventListener("storage", handleStorage);
|
|
167
|
+
};
|
|
168
|
+
}, [mode]);
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (mode !== "inherited") {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
return initializeInheritedPlatformSettingsBridge({
|
|
174
|
+
applySettings: (nextSettings) => {
|
|
175
|
+
setSettingsState(nextSettings);
|
|
176
|
+
setStatus("ready");
|
|
177
|
+
},
|
|
178
|
+
onBridgeUnavailable: () => {
|
|
179
|
+
setStatus("ready");
|
|
180
|
+
},
|
|
181
|
+
onBridgeAttached: (origin) => {
|
|
182
|
+
emitAirJamDevRuntimeEvent({
|
|
183
|
+
event: AIRJAM_DEV_LOG_EVENTS.browser.runtime,
|
|
184
|
+
message: "Embedded runtime bound platform settings bridge port",
|
|
185
|
+
level: "info",
|
|
186
|
+
data: {
|
|
187
|
+
origin,
|
|
188
|
+
state: "waiting_ready",
|
|
189
|
+
transport: "bridge_port"
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
onSettingsReadyRequested: (trustedParentOrigin) => {
|
|
194
|
+
emitAirJamDevRuntimeEvent({
|
|
195
|
+
event: AIRJAM_DEV_LOG_EVENTS.browser.runtime,
|
|
196
|
+
message: "Embedded runtime requested initial platform settings from parent",
|
|
197
|
+
level: "info",
|
|
198
|
+
data: {
|
|
199
|
+
trustedParentOrigin,
|
|
200
|
+
state: "waiting_ready"
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
onSnapshotApplied: (transport, settings2) => {
|
|
205
|
+
emitAirJamDevRuntimeEvent({
|
|
206
|
+
event: AIRJAM_DEV_LOG_EVENTS.browser.runtime,
|
|
207
|
+
message: "Embedded runtime applied platform settings snapshot",
|
|
208
|
+
level: "info",
|
|
209
|
+
data: {
|
|
210
|
+
transport,
|
|
211
|
+
state: "ready",
|
|
212
|
+
settings: settings2
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}, [mode]);
|
|
218
|
+
const setSettings = useCallback(
|
|
219
|
+
(next) => {
|
|
220
|
+
if (mode !== "owner") {
|
|
221
|
+
throw new Error(
|
|
222
|
+
'Platform settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
setSettingsState(
|
|
226
|
+
(current) => typeof next === "function" ? next(current) : next
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
[mode]
|
|
230
|
+
);
|
|
231
|
+
const updateSettings = useCallback(
|
|
232
|
+
(patch) => {
|
|
233
|
+
if (mode !== "owner") {
|
|
234
|
+
throw new Error(
|
|
235
|
+
'Platform settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
setSettingsState((current) => mergePlatformSettings(current, patch));
|
|
239
|
+
},
|
|
240
|
+
[mode]
|
|
241
|
+
);
|
|
242
|
+
const value = useMemo(
|
|
243
|
+
() => ({
|
|
244
|
+
mode,
|
|
245
|
+
status,
|
|
246
|
+
settings,
|
|
247
|
+
setSettings,
|
|
248
|
+
updateSettings
|
|
249
|
+
}),
|
|
250
|
+
[mode, settings, setSettings, status, updateSettings]
|
|
251
|
+
);
|
|
252
|
+
return /* @__PURE__ */ jsx(platformSettingsContext.Provider, { value, children });
|
|
253
|
+
}
|
|
254
|
+
function PlatformSettingsBoundary({
|
|
255
|
+
children,
|
|
256
|
+
persistence = "local"
|
|
257
|
+
}) {
|
|
258
|
+
const existingContext = useContext(platformSettingsContext);
|
|
259
|
+
if (existingContext) {
|
|
260
|
+
return children;
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ jsx(PlatformSettingsRuntime, { persistence, children });
|
|
263
|
+
}
|
|
264
|
+
function usePlatformSettings() {
|
|
265
|
+
const context = useContext(platformSettingsContext);
|
|
266
|
+
if (!context) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
"usePlatformSettings must be used within a PlatformSettingsRuntime"
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
if (context.mode !== "owner") {
|
|
272
|
+
throw new Error(
|
|
273
|
+
'usePlatformSettings can only be used in a platform-owned settings runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell.'
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
settings: context.settings,
|
|
278
|
+
setSettings: context.setSettings,
|
|
279
|
+
updateSettings: context.updateSettings,
|
|
280
|
+
updateAudio: (patch) => context.updateSettings({ audio: patch }),
|
|
281
|
+
updateAccessibility: (patch) => context.updateSettings({ accessibility: patch }),
|
|
282
|
+
updateFeedback: (patch) => context.updateSettings({ feedback: patch }),
|
|
283
|
+
updatePreviewControllers: (patch) => context.updateSettings({ previewControllers: patch })
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function useOptionalPlatformSettingsOwnerApi() {
|
|
287
|
+
const context = useContext(platformSettingsContext);
|
|
288
|
+
if (!context || context.mode !== "owner") {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
settings: context.settings,
|
|
293
|
+
setSettings: context.setSettings,
|
|
294
|
+
updateSettings: context.updateSettings,
|
|
295
|
+
updateAudio: (patch) => context.updateSettings({ audio: patch }),
|
|
296
|
+
updateAccessibility: (patch) => context.updateSettings({ accessibility: patch }),
|
|
297
|
+
updateFeedback: (patch) => context.updateSettings({ feedback: patch }),
|
|
298
|
+
updatePreviewControllers: (patch) => context.updateSettings({ previewControllers: patch })
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function useInheritedPlatformSettings() {
|
|
302
|
+
const context = useContext(platformSettingsContext);
|
|
303
|
+
if (!context) {
|
|
304
|
+
throw new Error(
|
|
305
|
+
"useInheritedPlatformSettings must be used within a PlatformSettingsRuntime"
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
return context.settings;
|
|
309
|
+
}
|
|
310
|
+
function usePlatformSettingsRuntimeStatus() {
|
|
311
|
+
return useContext(platformSettingsContext)?.status ?? "ready";
|
|
312
|
+
}
|
|
313
|
+
function usePlatformAudioSettings() {
|
|
314
|
+
const context = useContext(platformSettingsContext) ?? createDefaultContextValue();
|
|
315
|
+
const { audio } = context.settings;
|
|
316
|
+
const isReadOnly = context.mode !== "owner";
|
|
317
|
+
const setAudioSetting = useCallback(
|
|
318
|
+
(patch) => {
|
|
319
|
+
if (context.mode !== "owner") {
|
|
320
|
+
throw new Error(
|
|
321
|
+
'Platform audio settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
context.updateSettings({ audio: patch });
|
|
325
|
+
},
|
|
326
|
+
[context]
|
|
327
|
+
);
|
|
328
|
+
return {
|
|
329
|
+
...audio,
|
|
330
|
+
isReadOnly,
|
|
331
|
+
getEffectiveVolume: (category) => getEffectiveAudioVolume(audio, category),
|
|
332
|
+
setMasterVolume: (volume) => setAudioSetting({ masterVolume: volume }),
|
|
333
|
+
setMusicVolume: (volume) => setAudioSetting({ musicVolume: volume }),
|
|
334
|
+
setSfxVolume: (volume) => setAudioSetting({ sfxVolume: volume })
|
|
71
335
|
};
|
|
336
|
+
}
|
|
337
|
+
function useResolvedPlatformSettingsSnapshot() {
|
|
338
|
+
return useContext(platformSettingsContext)?.settings ?? DEFAULT_PLATFORM_SETTINGS;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/runtime/runtime-owner-contexts.tsx
|
|
342
|
+
import { createContext as createContext2 } from "react";
|
|
343
|
+
var fixedControllerOrientationContext = createContext2(void 0);
|
|
344
|
+
var hostRuntimeContext = createContext2(null);
|
|
345
|
+
var controllerRuntimeContext = createContext2(null);
|
|
346
|
+
var declaredStoresContext = createContext2(null);
|
|
347
|
+
|
|
348
|
+
// src/runtime/air-jam-config.ts
|
|
349
|
+
var getNodeEnv = () => {
|
|
350
|
+
const candidate = globalThis.process;
|
|
351
|
+
return candidate?.env;
|
|
352
|
+
};
|
|
353
|
+
var getViteEnv = () => {
|
|
354
|
+
try {
|
|
355
|
+
const meta = import.meta;
|
|
356
|
+
if (meta && typeof meta.env === "object") {
|
|
357
|
+
return meta.env;
|
|
358
|
+
}
|
|
359
|
+
} catch {
|
|
360
|
+
return void 0;
|
|
361
|
+
}
|
|
362
|
+
return void 0;
|
|
363
|
+
};
|
|
364
|
+
var getNodeEnvMode = () => {
|
|
365
|
+
return getNodeEnv()?.NODE_ENV;
|
|
366
|
+
};
|
|
367
|
+
var isDevelopmentRuntime = () => {
|
|
368
|
+
const viteEnv = getViteEnv();
|
|
369
|
+
if (typeof viteEnv?.DEV === "boolean") {
|
|
370
|
+
return viteEnv.DEV;
|
|
371
|
+
}
|
|
372
|
+
return getNodeEnvMode() !== "production";
|
|
373
|
+
};
|
|
374
|
+
var getEnvServerUrl = () => {
|
|
375
|
+
const viteEnv = getViteEnv();
|
|
376
|
+
if (viteEnv?.VITE_AIR_JAM_SERVER_URL) {
|
|
377
|
+
return viteEnv.VITE_AIR_JAM_SERVER_URL;
|
|
378
|
+
}
|
|
379
|
+
const nodeEnv = getNodeEnv();
|
|
380
|
+
if (nodeEnv) {
|
|
381
|
+
const nextUrl = nodeEnv.NEXT_PUBLIC_AIR_JAM_SERVER_URL;
|
|
382
|
+
if (nextUrl) {
|
|
383
|
+
return nextUrl;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return void 0;
|
|
387
|
+
};
|
|
388
|
+
var getEnvAppId = () => {
|
|
389
|
+
const viteEnv = getViteEnv();
|
|
390
|
+
if (viteEnv?.VITE_AIR_JAM_APP_ID) {
|
|
391
|
+
return viteEnv.VITE_AIR_JAM_APP_ID;
|
|
392
|
+
}
|
|
393
|
+
const nodeEnv = getNodeEnv();
|
|
394
|
+
if (nodeEnv) {
|
|
395
|
+
const nextAppId = nodeEnv.NEXT_PUBLIC_AIR_JAM_APP_ID;
|
|
396
|
+
if (nextAppId) {
|
|
397
|
+
return nextAppId;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return void 0;
|
|
401
|
+
};
|
|
402
|
+
var getEnvPublicHost = () => {
|
|
403
|
+
const viteEnv = getViteEnv();
|
|
404
|
+
if (viteEnv?.VITE_AIR_JAM_PUBLIC_HOST) {
|
|
405
|
+
return viteEnv.VITE_AIR_JAM_PUBLIC_HOST;
|
|
406
|
+
}
|
|
407
|
+
const nodeEnv = getNodeEnv();
|
|
408
|
+
if (nodeEnv) {
|
|
409
|
+
const nextHost = nodeEnv.NEXT_PUBLIC_AIR_JAM_PUBLIC_HOST;
|
|
410
|
+
if (nextHost) {
|
|
411
|
+
return nextHost;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return void 0;
|
|
415
|
+
};
|
|
416
|
+
var getEnvHostGrantEndpoint = () => {
|
|
417
|
+
const viteEnv = getViteEnv();
|
|
418
|
+
if (viteEnv?.VITE_AIR_JAM_HOST_GRANT_ENDPOINT) {
|
|
419
|
+
return viteEnv.VITE_AIR_JAM_HOST_GRANT_ENDPOINT;
|
|
420
|
+
}
|
|
421
|
+
const nodeEnv = getNodeEnv();
|
|
422
|
+
if (nodeEnv) {
|
|
423
|
+
const nextEndpoint = nodeEnv.NEXT_PUBLIC_AIR_JAM_HOST_GRANT_ENDPOINT;
|
|
424
|
+
if (nextEndpoint) {
|
|
425
|
+
return nextEndpoint;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return void 0;
|
|
429
|
+
};
|
|
430
|
+
var readRuntimeTopologyFromViteEnv = () => {
|
|
431
|
+
const viteEnv = getViteEnv();
|
|
432
|
+
if (!viteEnv?.VITE_AIR_JAM_RUNTIME_TOPOLOGY) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
return readRuntimeTopologyFromEnv({
|
|
436
|
+
VITE_AIR_JAM_RUNTIME_TOPOLOGY: viteEnv.VITE_AIR_JAM_RUNTIME_TOPOLOGY
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
var readRuntimeTopologyFromWindowSearchParams = () => {
|
|
440
|
+
if (typeof window === "undefined") {
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
return parseRuntimeTopologyFromSearchParams(
|
|
444
|
+
new URLSearchParams(window.location.search)
|
|
445
|
+
);
|
|
446
|
+
};
|
|
447
|
+
var resolveEnvironmentRuntimeTopology = (defaults, development) => {
|
|
448
|
+
const bootstrap = readRuntimeTopologyFromWindow();
|
|
449
|
+
if (bootstrap) return bootstrap;
|
|
450
|
+
if (development && (!defaults || isLocalDevControlSurfaceTopology(defaults))) {
|
|
451
|
+
const surface = readRuntimeTopologyFromWindowSearchParams();
|
|
452
|
+
if (surface && !isLocalDevControlSurfaceTopology(surface))
|
|
453
|
+
throw new Error(
|
|
454
|
+
"Development surface topology must use a local development mode."
|
|
455
|
+
);
|
|
456
|
+
if (surface) return surface;
|
|
457
|
+
}
|
|
458
|
+
return defaults;
|
|
72
459
|
};
|
|
73
|
-
var
|
|
74
|
-
|
|
460
|
+
var applySurfaceRoleOverride = (topology, surfaceRole) => {
|
|
461
|
+
if (!topology || !surfaceRole || topology.surfaceRole === surfaceRole) {
|
|
462
|
+
return topology;
|
|
463
|
+
}
|
|
464
|
+
return resolveRuntimeTopology({
|
|
465
|
+
...topology,
|
|
466
|
+
surfaceRole
|
|
467
|
+
});
|
|
75
468
|
};
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
469
|
+
var resolveProjectTopologyFromEnv = (surfaceRole) => {
|
|
470
|
+
const effectiveSurfaceRole = surfaceRole ?? "host";
|
|
471
|
+
if (effectiveSurfaceRole !== "host" && effectiveSurfaceRole !== "controller") {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
const explicitPublicHost = getEnvPublicHost();
|
|
475
|
+
const appOrigin = explicitPublicHost ?? (typeof window !== "undefined" ? window.location.origin : void 0);
|
|
476
|
+
if (!appOrigin) {
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
const secureTransport = appOrigin.startsWith("https://");
|
|
480
|
+
const runtimeMode = isDevelopmentRuntime() ? secureTransport ? "standalone-secure" : "standalone-dev" : "self-hosted-production";
|
|
481
|
+
return resolveProjectRuntimeTopology({
|
|
482
|
+
runtimeMode,
|
|
483
|
+
surfaceRole: effectiveSurfaceRole,
|
|
484
|
+
appOrigin,
|
|
485
|
+
backendOrigin: getEnvServerUrl() ?? appOrigin,
|
|
486
|
+
publicHost: explicitPublicHost ?? appOrigin,
|
|
487
|
+
secureTransport
|
|
82
488
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
489
|
+
};
|
|
490
|
+
var resolveAirJamConfig = ({
|
|
491
|
+
topology,
|
|
492
|
+
surfaceRole,
|
|
493
|
+
appId,
|
|
494
|
+
hostGrantEndpoint,
|
|
495
|
+
reportError,
|
|
496
|
+
presentationChannel,
|
|
497
|
+
resolveEnv = true
|
|
498
|
+
}, maxPlayers) => {
|
|
499
|
+
const resolvedTopology = topology ? applySurfaceRoleOverride(resolveRuntimeTopology(topology), surfaceRole) : resolveEnv ? applySurfaceRoleOverride(
|
|
500
|
+
resolveEnvironmentRuntimeTopology(
|
|
501
|
+
readRuntimeTopologyFromViteEnv() ?? readRuntimeTopologyFromEnv(getNodeEnv()) ?? resolveProjectTopologyFromEnv(surfaceRole),
|
|
502
|
+
isDevelopmentRuntime()
|
|
503
|
+
),
|
|
504
|
+
surfaceRole
|
|
505
|
+
) : null;
|
|
506
|
+
if (!resolvedTopology) {
|
|
507
|
+
throw createAirJamDiagnosticError(
|
|
508
|
+
"AJ_CONFIG_MISSING_RUNTIME_TOPOLOGY",
|
|
509
|
+
"Missing runtime topology. Provide `topology` directly, or enable env resolution with a supported project/runtime mode."
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
const resolvedAppId = appId ?? getEnvAppId();
|
|
513
|
+
if (getNodeEnvMode() === "production" && !resolvedAppId) {
|
|
514
|
+
emitAirJamDiagnostic({
|
|
515
|
+
code: "AJ_CONFIG_MISSING_APP_ID",
|
|
516
|
+
severity: "error",
|
|
517
|
+
message: "Missing app ID in production. Set VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID, or pass `appId` to the session provider."
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
return createAirJamConfig({
|
|
521
|
+
topology: resolvedTopology,
|
|
522
|
+
appId: resolvedAppId,
|
|
523
|
+
hostGrantEndpoint: hostGrantEndpoint ?? getEnvHostGrantEndpoint(),
|
|
524
|
+
reportError,
|
|
525
|
+
presentationChannel,
|
|
526
|
+
maxPlayers
|
|
87
527
|
});
|
|
88
|
-
return error;
|
|
89
528
|
};
|
|
90
529
|
|
|
91
530
|
// src/context/air-jam-context.tsx
|
|
92
531
|
import {
|
|
93
|
-
createContext,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
useMemo
|
|
532
|
+
createContext as createContext3,
|
|
533
|
+
useContext as useContext2,
|
|
534
|
+
useEffect as useEffect2,
|
|
535
|
+
useMemo as useMemo2
|
|
98
536
|
} from "react";
|
|
99
537
|
import { useStore } from "zustand";
|
|
100
538
|
import { useShallow } from "zustand/react/shallow";
|
|
101
539
|
|
|
102
540
|
// src/dev/browser-log-sink.ts
|
|
103
541
|
var FLUSH_INTERVAL_MS = 200;
|
|
542
|
+
var OUTAGE_RETRY_MS = 2e3;
|
|
104
543
|
var CONSOLE_REPEAT_COALESCE_WINDOW_MS = 1e3;
|
|
105
544
|
var resolveNodeEnvMode = () => {
|
|
106
545
|
return globalThis.process?.env?.NODE_ENV;
|
|
@@ -116,7 +555,7 @@ var resolveImportMetaDev = () => {
|
|
|
116
555
|
}
|
|
117
556
|
return void 0;
|
|
118
557
|
};
|
|
119
|
-
var
|
|
558
|
+
var isDevelopmentRuntime2 = () => {
|
|
120
559
|
const importMetaDev = resolveImportMetaDev();
|
|
121
560
|
if (typeof importMetaDev === "boolean") {
|
|
122
561
|
return importMetaDev;
|
|
@@ -270,11 +709,14 @@ var BrowserLogSinkRuntime = class {
|
|
|
270
709
|
endpoint = null;
|
|
271
710
|
unloadEndpoint = null;
|
|
272
711
|
appId;
|
|
712
|
+
parent = null;
|
|
273
713
|
sessionId = createSessionId();
|
|
274
714
|
queue = [];
|
|
275
715
|
nextSourceSeq = 1;
|
|
276
716
|
flushTimer = null;
|
|
277
717
|
hasReset = false;
|
|
718
|
+
/** Set once the endpoint accepts a batch: later network failures are outages, not misconfiguration. */
|
|
719
|
+
delivered = false;
|
|
278
720
|
originalConsole = /* @__PURE__ */ new Map();
|
|
279
721
|
disposers = [];
|
|
280
722
|
installed = false;
|
|
@@ -283,6 +725,7 @@ var BrowserLogSinkRuntime = class {
|
|
|
283
725
|
this.endpoint = resolveLogEndpoint(options);
|
|
284
726
|
this.unloadEndpoint = resolveUnloadEndpoint(options);
|
|
285
727
|
this.appId = options.appId;
|
|
728
|
+
this.parent = options.topology ? embeddedRuntimeParent(options.topology) : null;
|
|
286
729
|
if (this.endpoint && this.endpoint !== previousEndpoint && this.queue.length > 0 && !this.flushTimer) {
|
|
287
730
|
this.flushTimer = setTimeout(() => {
|
|
288
731
|
void this.flush();
|
|
@@ -313,14 +756,14 @@ var BrowserLogSinkRuntime = class {
|
|
|
313
756
|
};
|
|
314
757
|
const originalError = this.originalConsole.get("error") ?? console.error.bind(console);
|
|
315
758
|
originalError("[AirJam][AJ_BROWSER_LOG_SINK_POST_FAILED]", payload);
|
|
316
|
-
if (
|
|
759
|
+
if (this.parent) {
|
|
317
760
|
try {
|
|
318
|
-
|
|
761
|
+
this.parent.window.postMessage(
|
|
319
762
|
{
|
|
320
763
|
type: AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
321
764
|
payload
|
|
322
765
|
},
|
|
323
|
-
|
|
766
|
+
this.parent.origin
|
|
324
767
|
);
|
|
325
768
|
} catch {
|
|
326
769
|
}
|
|
@@ -653,17 +1096,23 @@ var BrowserLogSinkRuntime = class {
|
|
|
653
1096
|
}
|
|
654
1097
|
this.queue.splice(0, this.queue.length);
|
|
655
1098
|
this.hasReset = true;
|
|
656
|
-
await this.postPayload(body, useBeacon)
|
|
1099
|
+
if (await this.postPayload(body, useBeacon) === "unreachable") {
|
|
1100
|
+
this.queue.unshift(...entries);
|
|
1101
|
+
this.flushTimer ??= setTimeout(() => {
|
|
1102
|
+
void this.flush();
|
|
1103
|
+
}, OUTAGE_RETRY_MS);
|
|
1104
|
+
}
|
|
657
1105
|
}
|
|
1106
|
+
/** Sends a batch; only a network outage after earlier delivery is `unreachable`, everything else that fails is reported. */
|
|
658
1107
|
async postPayload(body, useBeacon) {
|
|
659
1108
|
if (!this.endpoint) {
|
|
660
|
-
return;
|
|
1109
|
+
return "failed";
|
|
661
1110
|
}
|
|
662
1111
|
if (useBeacon && typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
663
1112
|
try {
|
|
664
1113
|
const requestBody = typeof Blob === "function" ? new Blob([body], { type: "application/json" }) : body;
|
|
665
1114
|
if (navigator.sendBeacon(this.endpoint, requestBody)) {
|
|
666
|
-
return;
|
|
1115
|
+
return "sent";
|
|
667
1116
|
}
|
|
668
1117
|
} catch {
|
|
669
1118
|
}
|
|
@@ -683,10 +1132,15 @@ var BrowserLogSinkRuntime = class {
|
|
|
683
1132
|
`Browser log sink endpoint returned ${response.status}`,
|
|
684
1133
|
{ status: response.status }
|
|
685
1134
|
);
|
|
1135
|
+
return "failed";
|
|
686
1136
|
}
|
|
1137
|
+
this.delivered = true;
|
|
1138
|
+
return "sent";
|
|
687
1139
|
} catch (error) {
|
|
1140
|
+
if (this.delivered) return "unreachable";
|
|
688
1141
|
const reason = error instanceof Error ? error.message : "Unknown browser log sink transport failure";
|
|
689
1142
|
this.reportTransportFailure(reason);
|
|
1143
|
+
return "failed";
|
|
690
1144
|
}
|
|
691
1145
|
}
|
|
692
1146
|
};
|
|
@@ -695,7 +1149,7 @@ var ensureDevBrowserLogSink = (options) => {
|
|
|
695
1149
|
return;
|
|
696
1150
|
}
|
|
697
1151
|
const globalState = globalThis;
|
|
698
|
-
const autoEnabled = options.topology != null ? isLocalDevControlSurfaceTopology(options.topology) :
|
|
1152
|
+
const autoEnabled = options.topology != null ? isLocalDevControlSurfaceTopology(options.topology) : isDevelopmentRuntime2();
|
|
699
1153
|
if (!autoEnabled) {
|
|
700
1154
|
globalState.__airJamBrowserLogSink__?.dispose?.();
|
|
701
1155
|
delete globalState.__airJamBrowserLogSink__;
|
|
@@ -714,494 +1168,9 @@ var ensureDevBrowserLogSink = (options) => {
|
|
|
714
1168
|
globalState.__airJamBrowserLogSink__.update(options);
|
|
715
1169
|
};
|
|
716
1170
|
|
|
717
|
-
// src/internal/input-manager.ts
|
|
718
|
-
var InputManager = class {
|
|
719
|
-
inputBuffer = /* @__PURE__ */ new Map();
|
|
720
|
-
behaviorState = /* @__PURE__ */ new Map();
|
|
721
|
-
behaviorOverrides = /* @__PURE__ */ new Map();
|
|
722
|
-
config;
|
|
723
|
-
constructor(config = {}) {
|
|
724
|
-
this.config = config;
|
|
725
|
-
this.behaviorOverrides = this.createBehaviorOverrides(config.behavior);
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* Handles incoming input events from the socket.
|
|
729
|
-
* Should be called when 'server:input' event is received.
|
|
730
|
-
*/
|
|
731
|
-
handleInput(payload) {
|
|
732
|
-
this.inputBuffer.set(payload.controllerId, payload.input);
|
|
733
|
-
this.captureTransientBehaviors(payload.controllerId, payload.input);
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Gets input for a specific controller.
|
|
737
|
-
* Returns validated and typed input if schema is provided, otherwise raw Record.
|
|
738
|
-
* Applies configured input behavior semantics.
|
|
739
|
-
*/
|
|
740
|
-
getInput(controllerId) {
|
|
741
|
-
const rawInput = this.inputBuffer.get(controllerId);
|
|
742
|
-
if (!rawInput) {
|
|
743
|
-
return void 0;
|
|
744
|
-
}
|
|
745
|
-
let validatedInput = rawInput;
|
|
746
|
-
if (this.config.schema) {
|
|
747
|
-
const result = this.config.schema.safeParse(rawInput);
|
|
748
|
-
if (!result.success) {
|
|
749
|
-
console.warn(
|
|
750
|
-
`[InputManager] Invalid input for controller ${controllerId}:`,
|
|
751
|
-
result.error
|
|
752
|
-
);
|
|
753
|
-
return void 0;
|
|
754
|
-
}
|
|
755
|
-
validatedInput = result.data;
|
|
756
|
-
}
|
|
757
|
-
return this.applyBehaviors(
|
|
758
|
-
controllerId,
|
|
759
|
-
validatedInput
|
|
760
|
-
);
|
|
761
|
-
}
|
|
762
|
-
/**
|
|
763
|
-
* Clears input state for a controller (e.g., when player leaves).
|
|
764
|
-
*/
|
|
765
|
-
clearInput(controllerId) {
|
|
766
|
-
this.inputBuffer.delete(controllerId);
|
|
767
|
-
this.behaviorState.delete(controllerId);
|
|
768
|
-
}
|
|
769
|
-
getBehaviorState(controllerId) {
|
|
770
|
-
const existing = this.behaviorState.get(controllerId);
|
|
771
|
-
if (existing) {
|
|
772
|
-
return existing;
|
|
773
|
-
}
|
|
774
|
-
const created = {
|
|
775
|
-
pulseBooleans: /* @__PURE__ */ new Set(),
|
|
776
|
-
pulseVectors: /* @__PURE__ */ new Map(),
|
|
777
|
-
holdVectors: /* @__PURE__ */ new Map()
|
|
778
|
-
};
|
|
779
|
-
this.behaviorState.set(controllerId, created);
|
|
780
|
-
return created;
|
|
781
|
-
}
|
|
782
|
-
createBehaviorOverrides(behavior) {
|
|
783
|
-
const overrides = /* @__PURE__ */ new Map();
|
|
784
|
-
const assign = (fields, mode) => {
|
|
785
|
-
for (const field of fields ?? []) {
|
|
786
|
-
const existing = overrides.get(field);
|
|
787
|
-
if (existing && existing !== mode) {
|
|
788
|
-
throw new Error(
|
|
789
|
-
`[InputManager] Field "${field}" is configured for both "${existing}" and "${mode}".`
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
overrides.set(field, mode);
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
|
-
assign(behavior?.pulse, "pulse");
|
|
796
|
-
assign(behavior?.hold, "hold");
|
|
797
|
-
assign(behavior?.latest, "latest");
|
|
798
|
-
return overrides;
|
|
799
|
-
}
|
|
800
|
-
resolveFieldBehavior(field, value) {
|
|
801
|
-
const override = this.behaviorOverrides.get(field);
|
|
802
|
-
if (override) {
|
|
803
|
-
return override;
|
|
804
|
-
}
|
|
805
|
-
if (typeof value === "boolean") {
|
|
806
|
-
return "pulse";
|
|
807
|
-
}
|
|
808
|
-
if (this.isVectorValue(value)) {
|
|
809
|
-
return "latest";
|
|
810
|
-
}
|
|
811
|
-
return "latest";
|
|
812
|
-
}
|
|
813
|
-
isVectorValue(value) {
|
|
814
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
815
|
-
return false;
|
|
816
|
-
}
|
|
817
|
-
const vector = value;
|
|
818
|
-
return typeof vector.x === "number" && typeof vector.y === "number";
|
|
819
|
-
}
|
|
820
|
-
isActiveVector(vector) {
|
|
821
|
-
return vector.x !== 0 || vector.y !== 0;
|
|
822
|
-
}
|
|
823
|
-
captureTransientBehaviors(controllerId, rawInput) {
|
|
824
|
-
const state = this.getBehaviorState(controllerId);
|
|
825
|
-
for (const [field, value] of Object.entries(rawInput)) {
|
|
826
|
-
const behavior = this.resolveFieldBehavior(field, value);
|
|
827
|
-
if (behavior === "pulse") {
|
|
828
|
-
if (typeof value === "boolean") {
|
|
829
|
-
if (value) {
|
|
830
|
-
state.pulseBooleans.add(field);
|
|
831
|
-
}
|
|
832
|
-
continue;
|
|
833
|
-
}
|
|
834
|
-
if (this.isVectorValue(value) && this.isActiveVector(value)) {
|
|
835
|
-
state.pulseVectors.set(field, value);
|
|
836
|
-
}
|
|
837
|
-
continue;
|
|
838
|
-
}
|
|
839
|
-
if (behavior === "hold" && this.isVectorValue(value)) {
|
|
840
|
-
if (this.isActiveVector(value)) {
|
|
841
|
-
state.holdVectors.set(field, value);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
applyBehaviors(controllerId, validatedInput) {
|
|
847
|
-
const state = this.getBehaviorState(controllerId);
|
|
848
|
-
const output = { ...validatedInput };
|
|
849
|
-
const processedFields = /* @__PURE__ */ new Set();
|
|
850
|
-
for (const [field, value] of Object.entries(validatedInput)) {
|
|
851
|
-
processedFields.add(field);
|
|
852
|
-
const behavior = this.resolveFieldBehavior(field, value);
|
|
853
|
-
if (behavior === "latest") {
|
|
854
|
-
continue;
|
|
855
|
-
}
|
|
856
|
-
if (behavior === "pulse") {
|
|
857
|
-
if (typeof value === "boolean") {
|
|
858
|
-
const pending = state.pulseBooleans.has(field);
|
|
859
|
-
output[field] = value === true || pending;
|
|
860
|
-
state.pulseBooleans.delete(field);
|
|
861
|
-
continue;
|
|
862
|
-
}
|
|
863
|
-
if (this.isVectorValue(value)) {
|
|
864
|
-
const pending = state.pulseVectors.get(field);
|
|
865
|
-
if (pending) {
|
|
866
|
-
output[field] = this.isActiveVector(value) ? value : pending;
|
|
867
|
-
state.pulseVectors.delete(field);
|
|
868
|
-
}
|
|
869
|
-
continue;
|
|
870
|
-
}
|
|
871
|
-
continue;
|
|
872
|
-
}
|
|
873
|
-
if (this.isVectorValue(value)) {
|
|
874
|
-
if (this.isActiveVector(value)) {
|
|
875
|
-
state.holdVectors.set(field, value);
|
|
876
|
-
output[field] = value;
|
|
877
|
-
} else {
|
|
878
|
-
output[field] = state.holdVectors.get(field) ?? { x: 0, y: 0 };
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
for (const field of Array.from(state.pulseBooleans)) {
|
|
883
|
-
if (!processedFields.has(field)) {
|
|
884
|
-
output[field] = true;
|
|
885
|
-
state.pulseBooleans.delete(field);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
for (const [field, vector] of Array.from(state.pulseVectors.entries())) {
|
|
889
|
-
if (!processedFields.has(field)) {
|
|
890
|
-
output[field] = vector;
|
|
891
|
-
state.pulseVectors.delete(field);
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
return output;
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
|
|
898
|
-
// src/runtime/air-jam-config.ts
|
|
899
|
-
var getNodeEnv = () => {
|
|
900
|
-
const candidate = globalThis.process;
|
|
901
|
-
return candidate?.env;
|
|
902
|
-
};
|
|
903
|
-
var getViteEnv = () => {
|
|
904
|
-
try {
|
|
905
|
-
const meta = import.meta;
|
|
906
|
-
if (meta && typeof meta.env === "object") {
|
|
907
|
-
return meta.env;
|
|
908
|
-
}
|
|
909
|
-
} catch {
|
|
910
|
-
return void 0;
|
|
911
|
-
}
|
|
912
|
-
return void 0;
|
|
913
|
-
};
|
|
914
|
-
var getNodeEnvMode = () => {
|
|
915
|
-
return getNodeEnv()?.NODE_ENV;
|
|
916
|
-
};
|
|
917
|
-
var isDevelopmentRuntime2 = () => {
|
|
918
|
-
const viteEnv = getViteEnv();
|
|
919
|
-
if (typeof viteEnv?.DEV === "boolean") {
|
|
920
|
-
return viteEnv.DEV;
|
|
921
|
-
}
|
|
922
|
-
return getNodeEnvMode() !== "production";
|
|
923
|
-
};
|
|
924
|
-
var getEnvServerUrl = () => {
|
|
925
|
-
const viteEnv = getViteEnv();
|
|
926
|
-
if (viteEnv?.VITE_AIR_JAM_SERVER_URL) {
|
|
927
|
-
return viteEnv.VITE_AIR_JAM_SERVER_URL;
|
|
928
|
-
}
|
|
929
|
-
const nodeEnv = getNodeEnv();
|
|
930
|
-
if (nodeEnv) {
|
|
931
|
-
const nextUrl = nodeEnv.NEXT_PUBLIC_AIR_JAM_SERVER_URL;
|
|
932
|
-
if (nextUrl) {
|
|
933
|
-
return nextUrl;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
return void 0;
|
|
937
|
-
};
|
|
938
|
-
var getEnvAppId = () => {
|
|
939
|
-
const viteEnv = getViteEnv();
|
|
940
|
-
if (viteEnv?.VITE_AIR_JAM_APP_ID) {
|
|
941
|
-
return viteEnv.VITE_AIR_JAM_APP_ID;
|
|
942
|
-
}
|
|
943
|
-
const nodeEnv = getNodeEnv();
|
|
944
|
-
if (nodeEnv) {
|
|
945
|
-
const nextAppId = nodeEnv.NEXT_PUBLIC_AIR_JAM_APP_ID;
|
|
946
|
-
if (nextAppId) {
|
|
947
|
-
return nextAppId;
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
return void 0;
|
|
951
|
-
};
|
|
952
|
-
var getEnvPublicHost = () => {
|
|
953
|
-
const viteEnv = getViteEnv();
|
|
954
|
-
if (viteEnv?.VITE_AIR_JAM_PUBLIC_HOST) {
|
|
955
|
-
return viteEnv.VITE_AIR_JAM_PUBLIC_HOST;
|
|
956
|
-
}
|
|
957
|
-
const nodeEnv = getNodeEnv();
|
|
958
|
-
if (nodeEnv) {
|
|
959
|
-
const nextHost = nodeEnv.NEXT_PUBLIC_AIR_JAM_PUBLIC_HOST;
|
|
960
|
-
if (nextHost) {
|
|
961
|
-
return nextHost;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
return void 0;
|
|
965
|
-
};
|
|
966
|
-
var getEnvHostGrantEndpoint = () => {
|
|
967
|
-
const viteEnv = getViteEnv();
|
|
968
|
-
if (viteEnv?.VITE_AIR_JAM_HOST_GRANT_ENDPOINT) {
|
|
969
|
-
return viteEnv.VITE_AIR_JAM_HOST_GRANT_ENDPOINT;
|
|
970
|
-
}
|
|
971
|
-
const nodeEnv = getNodeEnv();
|
|
972
|
-
if (nodeEnv) {
|
|
973
|
-
const nextEndpoint = nodeEnv.NEXT_PUBLIC_AIR_JAM_HOST_GRANT_ENDPOINT;
|
|
974
|
-
if (nextEndpoint) {
|
|
975
|
-
return nextEndpoint;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
return void 0;
|
|
979
|
-
};
|
|
980
|
-
var readRuntimeTopologyFromViteEnv = () => {
|
|
981
|
-
const viteEnv = getViteEnv();
|
|
982
|
-
if (!viteEnv?.VITE_AIR_JAM_RUNTIME_TOPOLOGY) {
|
|
983
|
-
return null;
|
|
984
|
-
}
|
|
985
|
-
return readRuntimeTopologyFromEnv({
|
|
986
|
-
VITE_AIR_JAM_RUNTIME_TOPOLOGY: viteEnv.VITE_AIR_JAM_RUNTIME_TOPOLOGY
|
|
987
|
-
});
|
|
988
|
-
};
|
|
989
|
-
var readRuntimeTopologyFromWindowSearchParams = () => {
|
|
990
|
-
if (typeof window === "undefined") {
|
|
991
|
-
return null;
|
|
992
|
-
}
|
|
993
|
-
return parseRuntimeTopologyFromSearchParams(
|
|
994
|
-
new URLSearchParams(window.location.search)
|
|
995
|
-
);
|
|
996
|
-
};
|
|
997
|
-
var applySurfaceRoleOverride = (topology, surfaceRole) => {
|
|
998
|
-
if (!topology || !surfaceRole || topology.surfaceRole === surfaceRole) {
|
|
999
|
-
return topology;
|
|
1000
|
-
}
|
|
1001
|
-
return resolveRuntimeTopology({
|
|
1002
|
-
...topology,
|
|
1003
|
-
surfaceRole
|
|
1004
|
-
});
|
|
1005
|
-
};
|
|
1006
|
-
var resolveProjectTopologyFromEnv = (surfaceRole) => {
|
|
1007
|
-
const effectiveSurfaceRole = surfaceRole ?? "host";
|
|
1008
|
-
if (effectiveSurfaceRole !== "host" && effectiveSurfaceRole !== "controller") {
|
|
1009
|
-
return null;
|
|
1010
|
-
}
|
|
1011
|
-
const explicitPublicHost = getEnvPublicHost();
|
|
1012
|
-
const appOrigin = explicitPublicHost ?? (typeof window !== "undefined" ? window.location.origin : void 0);
|
|
1013
|
-
if (!appOrigin) {
|
|
1014
|
-
return null;
|
|
1015
|
-
}
|
|
1016
|
-
const secureTransport = appOrigin.startsWith("https://");
|
|
1017
|
-
const runtimeMode = isDevelopmentRuntime2() ? secureTransport ? "standalone-secure" : "standalone-dev" : "self-hosted-production";
|
|
1018
|
-
return resolveProjectRuntimeTopology({
|
|
1019
|
-
runtimeMode,
|
|
1020
|
-
surfaceRole: effectiveSurfaceRole,
|
|
1021
|
-
appOrigin,
|
|
1022
|
-
backendOrigin: getEnvServerUrl() ?? appOrigin,
|
|
1023
|
-
publicHost: explicitPublicHost ?? appOrigin,
|
|
1024
|
-
secureTransport
|
|
1025
|
-
});
|
|
1026
|
-
};
|
|
1027
|
-
var resolveAirJamConfig = ({
|
|
1028
|
-
topology,
|
|
1029
|
-
surfaceRole,
|
|
1030
|
-
appId,
|
|
1031
|
-
hostGrantEndpoint,
|
|
1032
|
-
maxPlayers = DEFAULT_MAX_PLAYERS,
|
|
1033
|
-
hostSessionKind = "game",
|
|
1034
|
-
resolveEnv = true
|
|
1035
|
-
}) => {
|
|
1036
|
-
const resolvedTopology = topology ? applySurfaceRoleOverride(resolveRuntimeTopology(topology), surfaceRole) : resolveEnv ? applySurfaceRoleOverride(
|
|
1037
|
-
readRuntimeTopologyFromViteEnv() ?? readRuntimeTopologyFromEnv(getNodeEnv()) ?? readRuntimeTopologyFromWindow(window) ?? readRuntimeTopologyFromWindowSearchParams() ?? resolveProjectTopologyFromEnv(surfaceRole),
|
|
1038
|
-
surfaceRole
|
|
1039
|
-
) : null;
|
|
1040
|
-
if (!resolvedTopology) {
|
|
1041
|
-
throw createAirJamDiagnosticError(
|
|
1042
|
-
"AJ_CONFIG_MISSING_RUNTIME_TOPOLOGY",
|
|
1043
|
-
"Missing runtime topology. Provide `topology` directly, or enable env resolution with a supported project/runtime mode."
|
|
1044
|
-
);
|
|
1045
|
-
}
|
|
1046
|
-
const resolvedAppId = appId ?? getEnvAppId();
|
|
1047
|
-
if (getNodeEnvMode() === "production" && !resolvedAppId) {
|
|
1048
|
-
emitAirJamDiagnostic({
|
|
1049
|
-
code: "AJ_CONFIG_MISSING_APP_ID",
|
|
1050
|
-
severity: "error",
|
|
1051
|
-
message: "Missing app ID in production. Set VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID, or pass `appId` to the session provider."
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
return {
|
|
1055
|
-
topology: resolvedTopology,
|
|
1056
|
-
appId: resolvedAppId,
|
|
1057
|
-
hostGrantEndpoint: hostGrantEndpoint ?? getEnvHostGrantEndpoint(),
|
|
1058
|
-
maxPlayers,
|
|
1059
|
-
hostSessionKind,
|
|
1060
|
-
backendOrigin: resolvedTopology.backendOrigin,
|
|
1061
|
-
socketOrigin: resolvedTopology.socketOrigin,
|
|
1062
|
-
appOrigin: resolvedTopology.appOrigin,
|
|
1063
|
-
proxyStrategy: resolvedTopology.proxyStrategy
|
|
1064
|
-
};
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
// src/state/connection-store.ts
|
|
1068
|
-
import { create } from "zustand";
|
|
1069
|
-
var createAirJamStore = () => create((set) => ({
|
|
1070
|
-
role: null,
|
|
1071
|
-
roomId: null,
|
|
1072
|
-
controllerId: null,
|
|
1073
|
-
connectionStatus: "idle",
|
|
1074
|
-
mode: "standalone",
|
|
1075
|
-
runtimeState: "playing",
|
|
1076
|
-
controllerOrientation: "portrait",
|
|
1077
|
-
stateMessage: void 0,
|
|
1078
|
-
roomSettings: DEFAULT_ROOM_PLATFORM_SETTINGS,
|
|
1079
|
-
players: [],
|
|
1080
|
-
controllerSessions: [],
|
|
1081
|
-
lastError: void 0,
|
|
1082
|
-
registeredRoomId: null,
|
|
1083
|
-
hostArcadeRestore: {
|
|
1084
|
-
phase: "idle",
|
|
1085
|
-
session: null,
|
|
1086
|
-
surfaceCheckpoint: null
|
|
1087
|
-
},
|
|
1088
|
-
setHostArcadeRestore: (next) => set({ hostArcadeRestore: next }),
|
|
1089
|
-
clearHostArcadeRestore: () => set({
|
|
1090
|
-
hostArcadeRestore: {
|
|
1091
|
-
phase: "idle",
|
|
1092
|
-
session: null,
|
|
1093
|
-
surfaceCheckpoint: null
|
|
1094
|
-
}
|
|
1095
|
-
}),
|
|
1096
|
-
setRole: (role) => set({ role }),
|
|
1097
|
-
setRoomId: (roomId) => set({ roomId }),
|
|
1098
|
-
setControllerId: (controllerId) => set({ controllerId }),
|
|
1099
|
-
setStatus: (connectionStatus) => set({ connectionStatus }),
|
|
1100
|
-
setMode: (mode) => set({ mode }),
|
|
1101
|
-
setRuntimeState: (runtimeState) => set({ runtimeState }),
|
|
1102
|
-
setControllerOrientation: (controllerOrientation) => set({ controllerOrientation }),
|
|
1103
|
-
setStateMessage: (stateMessage) => set({ stateMessage }),
|
|
1104
|
-
setRoomSettings: (roomSettings) => set({ roomSettings }),
|
|
1105
|
-
setError: (message) => set({ lastError: message }),
|
|
1106
|
-
upsertPlayer: (player) => set((state) => {
|
|
1107
|
-
const existingIndex = state.players.findIndex(
|
|
1108
|
-
(entry) => entry.id === player.id
|
|
1109
|
-
);
|
|
1110
|
-
if (existingIndex >= 0) {
|
|
1111
|
-
const nextPlayers = [...state.players];
|
|
1112
|
-
nextPlayers[existingIndex] = player;
|
|
1113
|
-
return { players: nextPlayers };
|
|
1114
|
-
}
|
|
1115
|
-
return { players: [...state.players, player] };
|
|
1116
|
-
}),
|
|
1117
|
-
removePlayer: (playerId) => set((state) => ({
|
|
1118
|
-
players: state.players.filter((player) => player.id !== playerId)
|
|
1119
|
-
})),
|
|
1120
|
-
resetPlayers: () => set({ players: [] }),
|
|
1121
|
-
upsertControllerSession: (controller) => set((state) => {
|
|
1122
|
-
const existingIndex = state.controllerSessions.findIndex(
|
|
1123
|
-
(entry) => entry.controllerId === controller.controllerId
|
|
1124
|
-
);
|
|
1125
|
-
if (existingIndex >= 0) {
|
|
1126
|
-
const nextSessions = [...state.controllerSessions];
|
|
1127
|
-
nextSessions[existingIndex] = controller;
|
|
1128
|
-
return { controllerSessions: nextSessions };
|
|
1129
|
-
}
|
|
1130
|
-
return {
|
|
1131
|
-
controllerSessions: [...state.controllerSessions, controller]
|
|
1132
|
-
};
|
|
1133
|
-
}),
|
|
1134
|
-
removeControllerSession: (controllerId) => set((state) => ({
|
|
1135
|
-
controllerSessions: state.controllerSessions.filter(
|
|
1136
|
-
(controller) => controller.controllerId !== controllerId
|
|
1137
|
-
)
|
|
1138
|
-
})),
|
|
1139
|
-
resetControllerSessions: () => set({ controllerSessions: [] }),
|
|
1140
|
-
resetRuntimeState: () => set({
|
|
1141
|
-
runtimeState: "playing",
|
|
1142
|
-
controllerOrientation: "portrait",
|
|
1143
|
-
stateMessage: void 0,
|
|
1144
|
-
roomSettings: DEFAULT_ROOM_PLATFORM_SETTINGS
|
|
1145
|
-
}),
|
|
1146
|
-
setRegisteredRoomId: (roomId) => set({ registeredRoomId: roomId })
|
|
1147
|
-
}));
|
|
1148
|
-
|
|
1149
|
-
// src/context/socket-manager.ts
|
|
1150
|
-
import { io } from "socket.io-client";
|
|
1151
|
-
var SocketManager = class {
|
|
1152
|
-
sockets = {};
|
|
1153
|
-
socketOrigin;
|
|
1154
|
-
constructor(socketOrigin) {
|
|
1155
|
-
this.socketOrigin = this.normalizeOrigin(socketOrigin);
|
|
1156
|
-
}
|
|
1157
|
-
/**
|
|
1158
|
-
* Get or create a socket for the specified role.
|
|
1159
|
-
* Sockets are lazily created and cached per role.
|
|
1160
|
-
*/
|
|
1161
|
-
getSocket(role) {
|
|
1162
|
-
const existing = this.sockets[role];
|
|
1163
|
-
if (existing) {
|
|
1164
|
-
return existing;
|
|
1165
|
-
}
|
|
1166
|
-
const socket = io(this.socketOrigin, {
|
|
1167
|
-
autoConnect: false,
|
|
1168
|
-
query: { role }
|
|
1169
|
-
});
|
|
1170
|
-
this.sockets[role] = socket;
|
|
1171
|
-
return socket;
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Disconnect a socket by role.
|
|
1175
|
-
* NOTE: We intentionally do NOT delete the socket from cache.
|
|
1176
|
-
* This ensures all hooks using getSocket() get the same instance,
|
|
1177
|
-
* even during React Strict Mode remounts. The socket can be reconnected
|
|
1178
|
-
* by calling socket.connect() again.
|
|
1179
|
-
*/
|
|
1180
|
-
disconnect(role) {
|
|
1181
|
-
const socket = this.sockets[role];
|
|
1182
|
-
if (socket) {
|
|
1183
|
-
socket.disconnect();
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
/**
|
|
1187
|
-
* Disconnect all sockets managed by this instance
|
|
1188
|
-
*/
|
|
1189
|
-
disconnectAll() {
|
|
1190
|
-
for (const role of Object.keys(this.sockets)) {
|
|
1191
|
-
this.disconnect(role);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
normalizeOrigin(origin) {
|
|
1195
|
-
if (!origin.includes("://")) {
|
|
1196
|
-
return `http://${origin}`;
|
|
1197
|
-
}
|
|
1198
|
-
return origin;
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
|
|
1202
1171
|
// src/context/air-jam-context.tsx
|
|
1203
|
-
import { jsx } from "react/jsx-runtime";
|
|
1204
|
-
var AirJamContext =
|
|
1172
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1173
|
+
var AirJamContext = createContext3(null);
|
|
1205
1174
|
var AirJamProvider = ({
|
|
1206
1175
|
children,
|
|
1207
1176
|
topology,
|
|
@@ -1209,47 +1178,40 @@ var AirJamProvider = ({
|
|
|
1209
1178
|
appId,
|
|
1210
1179
|
hostGrantEndpoint,
|
|
1211
1180
|
maxPlayers,
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1181
|
+
reportError,
|
|
1182
|
+
presentationChannel,
|
|
1183
|
+
resolveEnv = true
|
|
1215
1184
|
}) => {
|
|
1216
|
-
const config =
|
|
1217
|
-
() => resolveAirJamConfig(
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1185
|
+
const config = useMemo2(
|
|
1186
|
+
() => resolveAirJamConfig(
|
|
1187
|
+
{
|
|
1188
|
+
topology,
|
|
1189
|
+
surfaceRole,
|
|
1190
|
+
appId,
|
|
1191
|
+
hostGrantEndpoint,
|
|
1192
|
+
reportError,
|
|
1193
|
+
presentationChannel,
|
|
1194
|
+
resolveEnv
|
|
1195
|
+
},
|
|
1196
|
+
maxPlayers
|
|
1197
|
+
),
|
|
1226
1198
|
[
|
|
1227
1199
|
topology,
|
|
1228
1200
|
surfaceRole,
|
|
1229
1201
|
appId,
|
|
1230
1202
|
hostGrantEndpoint,
|
|
1231
1203
|
maxPlayers,
|
|
1232
|
-
|
|
1204
|
+
reportError,
|
|
1205
|
+
presentationChannel,
|
|
1233
1206
|
resolveEnv
|
|
1234
1207
|
]
|
|
1235
1208
|
);
|
|
1236
|
-
const localDevControlSurfacesEnabled =
|
|
1237
|
-
() => isLocalDevControlSurfaceTopology(config.topology),
|
|
1209
|
+
const localDevControlSurfacesEnabled = useMemo2(
|
|
1210
|
+
() => isLocalDevControlSurfaceTopology(config.topology) && !isAirJamReplayDocument(),
|
|
1238
1211
|
[config.topology]
|
|
1239
1212
|
);
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
return null;
|
|
1243
|
-
}
|
|
1244
|
-
return new InputManager(input);
|
|
1245
|
-
}, [input]);
|
|
1246
|
-
const store = useMemo(() => createAirJamStore(), []);
|
|
1247
|
-
const socketManager = useMemo(
|
|
1248
|
-
() => new SocketManager(config.socketOrigin),
|
|
1249
|
-
// Only recreate if socketOrigin changes - intentionally omitting config
|
|
1250
|
-
[config.socketOrigin]
|
|
1251
|
-
);
|
|
1252
|
-
useEffect(() => {
|
|
1213
|
+
const store = useMemo2(() => createConnectionStore(), []);
|
|
1214
|
+
useEffect2(() => {
|
|
1253
1215
|
return () => {
|
|
1254
1216
|
const devWindow = typeof window !== "undefined" ? window : void 0;
|
|
1255
1217
|
if (devWindow && localDevControlSurfacesEnabled) {
|
|
@@ -1270,16 +1232,15 @@ var AirJamProvider = ({
|
|
|
1270
1232
|
} catch {
|
|
1271
1233
|
}
|
|
1272
1234
|
}
|
|
1273
|
-
socketManager.disconnectAll();
|
|
1274
1235
|
};
|
|
1275
1236
|
}, [
|
|
1276
1237
|
config.appId,
|
|
1277
1238
|
config.backendOrigin,
|
|
1278
1239
|
config.socketOrigin,
|
|
1279
|
-
localDevControlSurfacesEnabled
|
|
1280
|
-
socketManager
|
|
1240
|
+
localDevControlSurfacesEnabled
|
|
1281
1241
|
]);
|
|
1282
|
-
|
|
1242
|
+
useEffect2(() => {
|
|
1243
|
+
if (isAirJamReplayDocument()) return;
|
|
1283
1244
|
ensureDevBrowserLogSink({
|
|
1284
1245
|
appOrigin: config.appOrigin,
|
|
1285
1246
|
backendOrigin: config.backendOrigin,
|
|
@@ -1304,8 +1265,9 @@ var AirJamProvider = ({
|
|
|
1304
1265
|
pathname: devWindow.location.pathname
|
|
1305
1266
|
}
|
|
1306
1267
|
});
|
|
1307
|
-
|
|
1308
|
-
|
|
1268
|
+
const parent = embeddedRuntimeParent(config.topology);
|
|
1269
|
+
if (parent) {
|
|
1270
|
+
parent.window.postMessage(
|
|
1309
1271
|
{
|
|
1310
1272
|
type: AIRJAM_DEV_PROVIDER_MOUNTED,
|
|
1311
1273
|
payload: {
|
|
@@ -1317,7 +1279,7 @@ var AirJamProvider = ({
|
|
|
1317
1279
|
pathname: devWindow.location.pathname
|
|
1318
1280
|
}
|
|
1319
1281
|
},
|
|
1320
|
-
|
|
1282
|
+
parent.origin
|
|
1321
1283
|
);
|
|
1322
1284
|
}
|
|
1323
1285
|
} catch {
|
|
@@ -1332,29 +1294,14 @@ var AirJamProvider = ({
|
|
|
1332
1294
|
config.topology,
|
|
1333
1295
|
localDevControlSurfacesEnabled
|
|
1334
1296
|
]);
|
|
1335
|
-
const
|
|
1336
|
-
(
|
|
1337
|
-
[
|
|
1338
|
-
);
|
|
1339
|
-
const disconnectSocket = useCallback(
|
|
1340
|
-
(role) => socketManager.disconnect(role),
|
|
1341
|
-
[socketManager]
|
|
1342
|
-
);
|
|
1343
|
-
const contextValue = useMemo(
|
|
1344
|
-
() => ({
|
|
1345
|
-
config,
|
|
1346
|
-
store,
|
|
1347
|
-
socketManager,
|
|
1348
|
-
getSocket,
|
|
1349
|
-
disconnectSocket,
|
|
1350
|
-
inputManager
|
|
1351
|
-
}),
|
|
1352
|
-
[config, store, socketManager, getSocket, disconnectSocket, inputManager]
|
|
1297
|
+
const contextValue = useMemo2(
|
|
1298
|
+
() => ({ config, store }),
|
|
1299
|
+
[config, store]
|
|
1353
1300
|
);
|
|
1354
|
-
return /* @__PURE__ */
|
|
1301
|
+
return /* @__PURE__ */ jsx2(AirJamContext.Provider, { value: contextValue, children });
|
|
1355
1302
|
};
|
|
1356
1303
|
var useAirJamContext = () => {
|
|
1357
|
-
const context =
|
|
1304
|
+
const context = useContext2(AirJamContext);
|
|
1358
1305
|
if (!context) {
|
|
1359
1306
|
throw createAirJamDiagnosticError(
|
|
1360
1307
|
"AJ_MISSING_SESSION_PROVIDER",
|
|
@@ -1366,21 +1313,13 @@ var useAirJamContext = () => {
|
|
|
1366
1313
|
var useAirJamConfig = () => {
|
|
1367
1314
|
return useAirJamContext().config;
|
|
1368
1315
|
};
|
|
1369
|
-
var useAirJamState = (selector) => {
|
|
1370
|
-
const { store } = useAirJamContext();
|
|
1371
|
-
return useStore(store, useShallow(selector));
|
|
1372
|
-
};
|
|
1373
|
-
var useAirJamSocket = (role) => {
|
|
1374
|
-
const { getSocket } = useAirJamContext();
|
|
1375
|
-
return useMemo(() => getSocket(role), [getSocket, role]);
|
|
1376
|
-
};
|
|
1377
1316
|
|
|
1378
1317
|
// src/context/session-scope.ts
|
|
1379
|
-
import { createContext as
|
|
1380
|
-
var SessionScopeContext =
|
|
1381
|
-
var RuntimeOwnerRegistryContext =
|
|
1318
|
+
import { createContext as createContext4, useContext as useContext3, useEffect as useEffect3, useRef } from "react";
|
|
1319
|
+
var SessionScopeContext = createContext4("unscoped");
|
|
1320
|
+
var RuntimeOwnerRegistryContext = createContext4(null);
|
|
1382
1321
|
var useSessionScope = () => {
|
|
1383
|
-
return
|
|
1322
|
+
return useContext3(SessionScopeContext);
|
|
1384
1323
|
};
|
|
1385
1324
|
var useAssertSessionScope = (expectedScope, hookName) => {
|
|
1386
1325
|
const scope = useSessionScope();
|
|
@@ -1399,12 +1338,12 @@ var useAssertSessionScope = (expectedScope, hookName) => {
|
|
|
1399
1338
|
);
|
|
1400
1339
|
};
|
|
1401
1340
|
var useClaimSessionRuntimeOwner = (kind, hookName) => {
|
|
1402
|
-
const registry =
|
|
1341
|
+
const registry = useContext3(RuntimeOwnerRegistryContext);
|
|
1403
1342
|
const tokenRef = useRef(null);
|
|
1404
1343
|
if (!tokenRef.current) {
|
|
1405
1344
|
tokenRef.current = /* @__PURE__ */ Symbol(`${kind}:${hookName}`);
|
|
1406
1345
|
}
|
|
1407
|
-
|
|
1346
|
+
useEffect3(() => {
|
|
1408
1347
|
if (!registry) {
|
|
1409
1348
|
return;
|
|
1410
1349
|
}
|
|
@@ -1412,21 +1351,58 @@ var useClaimSessionRuntimeOwner = (kind, hookName) => {
|
|
|
1412
1351
|
}, [registry, kind, hookName]);
|
|
1413
1352
|
};
|
|
1414
1353
|
|
|
1354
|
+
// src/runtime/embedded-runtime-adapters.ts
|
|
1355
|
+
var readEmbeddedHostChildSession = () => {
|
|
1356
|
+
const raw = readChildHostRuntimeParams();
|
|
1357
|
+
if (!raw) {
|
|
1358
|
+
return null;
|
|
1359
|
+
}
|
|
1360
|
+
return {
|
|
1361
|
+
roomId: roomCodeSchema.parse(raw.room.toUpperCase()),
|
|
1362
|
+
joinUrl: raw.joinUrl,
|
|
1363
|
+
topology: raw.topology,
|
|
1364
|
+
arcadeSurface: raw.arcadeSurface
|
|
1365
|
+
};
|
|
1366
|
+
};
|
|
1367
|
+
var readEmbeddedControllerChildSession = () => {
|
|
1368
|
+
const raw = readEmbeddedControllerRuntimeParams();
|
|
1369
|
+
if (!raw) {
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
return {
|
|
1373
|
+
roomId: roomCodeSchema.parse(raw.room.toUpperCase()),
|
|
1374
|
+
topology: raw.topology,
|
|
1375
|
+
...controllerBridgeContext(raw),
|
|
1376
|
+
...raw.playerProfile ? { playerProfile: raw.playerProfile } : {}
|
|
1377
|
+
};
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1415
1380
|
export {
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1381
|
+
fixedControllerOrientationContext,
|
|
1382
|
+
hostRuntimeContext,
|
|
1383
|
+
controllerRuntimeContext,
|
|
1384
|
+
declaredStoresContext,
|
|
1385
|
+
PlatformSettingsRuntime,
|
|
1386
|
+
PlatformSettingsBoundary,
|
|
1387
|
+
usePlatformSettings,
|
|
1388
|
+
useOptionalPlatformSettingsOwnerApi,
|
|
1389
|
+
useInheritedPlatformSettings,
|
|
1390
|
+
usePlatformSettingsRuntimeStatus,
|
|
1391
|
+
usePlatformAudioSettings,
|
|
1392
|
+
useResolvedPlatformSettingsSnapshot,
|
|
1420
1393
|
updateDevBrowserLogContext,
|
|
1394
|
+
resolveEnvironmentRuntimeTopology,
|
|
1395
|
+
resolveAirJamConfig,
|
|
1396
|
+
AirJamContext,
|
|
1421
1397
|
AirJamProvider,
|
|
1422
1398
|
useAirJamContext,
|
|
1423
1399
|
useAirJamConfig,
|
|
1424
|
-
useAirJamState,
|
|
1425
|
-
useAirJamSocket,
|
|
1426
1400
|
SessionScopeContext,
|
|
1427
1401
|
RuntimeOwnerRegistryContext,
|
|
1428
1402
|
useSessionScope,
|
|
1429
1403
|
useAssertSessionScope,
|
|
1430
|
-
useClaimSessionRuntimeOwner
|
|
1404
|
+
useClaimSessionRuntimeOwner,
|
|
1405
|
+
readEmbeddedHostChildSession,
|
|
1406
|
+
readEmbeddedControllerChildSession
|
|
1431
1407
|
};
|
|
1432
|
-
//# sourceMappingURL=chunk-
|
|
1408
|
+
//# sourceMappingURL=chunk-6PLOJMJD.js.map
|