@air-jam/sdk 0.9.2 → 1.0.0-beta.1
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 +185 -242
- package/dist/actions-D4eh6Xaa.d.cts +72 -0
- package/dist/actions-D4eh6Xaa.d.ts +72 -0
- package/dist/{agent-tooling-BSMGBix9.d.cts → agent-contract-DfLm4Mf-.d.ts} +3 -19
- package/dist/{agent-tooling-BSMGBix9.d.ts → agent-contract-TINzp-5Y.d.cts} +3 -19
- package/dist/agent-tooling.cjs +270 -42
- package/dist/agent-tooling.cjs.map +1 -1
- package/dist/agent-tooling.d.cts +117 -2
- package/dist/agent-tooling.d.ts +117 -2
- package/dist/agent-tooling.js +150 -11
- package/dist/agent-tooling.js.map +1 -1
- package/dist/air-jam-context-BCVCWiaT.d.ts +410 -0
- package/dist/air-jam-context-DavligpM.d.cts +410 -0
- package/dist/arcade/bridge/controller.cjs +872 -582
- 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 -26
- 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 -21
- 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 -479
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.d.cts +1 -18
- package/dist/arcade/host.d.ts +1 -18
- package/dist/arcade/host.js +0 -13
- package/dist/arcade/host.js.map +1 -1
- package/dist/arcade/runtime.cjs +12163 -0
- package/dist/arcade/runtime.cjs.map +1 -0
- package/dist/arcade/runtime.d.cts +54 -0
- package/dist/arcade/runtime.d.ts +54 -0
- package/dist/arcade/runtime.js +45 -0
- package/dist/arcade/runtime.js.map +1 -0
- package/dist/arcade/surface.cjs +12 -35
- package/dist/arcade/surface.cjs.map +1 -1
- package/dist/arcade/surface.d.cts +19 -2
- package/dist/arcade/surface.d.ts +19 -2
- package/dist/arcade/surface.js +12 -14
- 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-2QZADUGA.js +188 -0
- package/dist/chunk-2QZADUGA.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-ZLPL2R3R.js → chunk-5CRZFIN6.js} +2 -82
- package/dist/chunk-5CRZFIN6.js.map +1 -0
- package/dist/chunk-5TVVPBQI.js +7 -0
- package/dist/chunk-5TVVPBQI.js.map +1 -0
- package/dist/chunk-6Y3F6Y2K.js +343 -0
- package/dist/chunk-6Y3F6Y2K.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-BEM77SVQ.js +57 -0
- package/dist/chunk-BEM77SVQ.js.map +1 -0
- package/dist/chunk-C5722GTG.js +176 -0
- package/dist/chunk-C5722GTG.js.map +1 -0
- package/dist/{chunk-DY67S3LR.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-DA3TE4OP.js +16 -0
- 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-DHFKL3DI.js +2477 -0
- package/dist/chunk-DHFKL3DI.js.map +1 -0
- package/dist/chunk-DRBPVG47.js +89 -0
- package/dist/chunk-DRBPVG47.js.map +1 -0
- package/dist/{chunk-7OTQTT6H.js → chunk-EG25EXSA.js} +24 -3
- package/dist/chunk-EG25EXSA.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-I6TSHJF7.js +63 -0
- package/dist/chunk-I6TSHJF7.js.map +1 -0
- package/dist/{chunk-NCL6WJCL.js → chunk-JCGTL77W.js} +32 -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-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-OAXCFPZ7.js +14 -0
- package/dist/chunk-OAXCFPZ7.js.map +1 -0
- package/dist/chunk-QHBRHYMV.js +81 -0
- 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-S3TN7Y7L.js +921 -0
- package/dist/chunk-S3TN7Y7L.js.map +1 -0
- package/dist/chunk-SMKD4JY3.js +129 -0
- package/dist/chunk-SMKD4JY3.js.map +1 -0
- package/dist/{chunk-NUJBMV3O.js → chunk-TFW4NJW2.js} +619 -646
- package/dist/chunk-TFW4NJW2.js.map +1 -0
- package/dist/chunk-UBBP2UY3.js +83 -0
- package/dist/chunk-UBBP2UY3.js.map +1 -0
- package/dist/chunk-URVBMQCK.js +802 -0
- package/dist/chunk-URVBMQCK.js.map +1 -0
- package/dist/chunk-VGX2274F.js +1995 -0
- package/dist/chunk-VGX2274F.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-XLY44PXZ.js +46 -0
- package/dist/chunk-XLY44PXZ.js.map +1 -0
- package/dist/connection-store-BYpQ50W2.d.ts +41 -0
- package/dist/connection-store-D6QqzXU1.d.cts +41 -0
- package/dist/control-Bv8dWjyp.d.ts +1400 -0
- package/dist/control-CNzybWMd.d.cts +1400 -0
- package/dist/controller-0CVO1t_3.d.cts +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-h9M2Nngd.d.ts +26 -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 +5931 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +232 -0
- package/dist/core.d.ts +232 -0
- package/dist/core.js +906 -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-Db58JNk3.d.cts +77 -0
- package/dist/game-bySEy-QO.d.ts +77 -0
- package/dist/host-runtime-BuLhGQx5.d.ts +399 -0
- package/dist/host-runtime-_06jpW5v.d.cts +399 -0
- package/dist/index.cjs +12406 -8020
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -973
- package/dist/index.d.ts +106 -973
- package/dist/index.js +451 -4637
- package/dist/index.js.map +1 -1
- package/dist/input-Xvs80gqG.d.cts +92 -0
- package/dist/input-Xvs80gqG.d.ts +92 -0
- package/dist/input-bindings-BaEFrgRb.d.cts +129 -0
- package/dist/input-bindings-BgsJRLPm.d.ts +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 -17
- package/dist/metadata.d.ts +6 -17
- package/dist/metadata.js +8 -76
- package/dist/metadata.js.map +1 -1
- package/dist/phone-room-session-Ca6rlxJr.d.ts +439 -0
- package/dist/phone-room-session-DkPR-K6e.d.cts +439 -0
- package/dist/platform-machine.cjs +248 -18
- package/dist/platform-machine.cjs.map +1 -1
- package/dist/platform-machine.d.cts +1867 -96
- package/dist/platform-machine.d.ts +1867 -96
- package/dist/platform-machine.js +206 -18
- package/dist/platform-machine.js.map +1 -1
- package/dist/{platform-settings-cuor3i11.d.cts → platform-settings-Yb0fQ1dl.d.cts} +1 -3
- package/dist/{platform-settings-cuor3i11.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 +2269 -774
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +195 -38
- package/dist/preview.d.ts +195 -38
- package/dist/preview.js +494 -260
- package/dist/preview.js.map +1 -1
- package/dist/protocol.cjs +705 -396
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +49 -100
- package/dist/protocol.d.ts +49 -100
- package/dist/protocol.js +56 -75
- package/dist/protocol.js.map +1 -1
- package/dist/release.cjs +37 -0
- package/dist/release.cjs.map +1 -1
- package/dist/release.d.cts +29 -3
- package/dist/release.d.ts +29 -3
- package/dist/release.js +13 -1
- package/dist/release.js.map +1 -1
- package/dist/replay-input-log-BvX4As2f.d.ts +31 -0
- package/dist/replay-input-log-Vcl0VDIy.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 +2150 -0
- package/dist/runtime-control.cjs.map +1 -0
- package/dist/runtime-control.d.cts +985 -0
- package/dist/runtime-control.d.ts +985 -0
- package/dist/runtime-control.js +268 -0
- package/dist/runtime-control.js.map +1 -0
- package/dist/runtime-inspection.cjs +1319 -0
- package/dist/runtime-inspection.cjs.map +1 -0
- package/dist/runtime-inspection.d.cts +555 -0
- package/dist/runtime-inspection.d.ts +555 -0
- package/dist/runtime-inspection.js +29 -0
- package/dist/runtime-inspection.js.map +1 -0
- 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-CiiWu06D.d.ts +66 -0
- package/dist/scoped-connector-D7252pn0.d.cts +66 -0
- package/dist/sdk-channels-S6j6AH8v.d.cts +103 -0
- package/dist/sdk-channels-S6j6AH8v.d.ts +103 -0
- package/dist/simulation-BfRnC4rg.d.ts +782 -0
- package/dist/simulation-BwZx2pgt.d.cts +782 -0
- package/dist/{standard-match-phase-BucA5dYo.d.ts → standard-match-phase-D4N-AU0d.d.cts} +3 -13
- package/dist/{standard-match-phase-U2ra8J-0.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 +2324 -1051
- 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 +555 -389
- package/dist/ui.js.map +1 -1
- package/package.json +88 -37
- package/src/agent/agent-action.ts +0 -39
- package/src/agent/agent-contract-conformance.ts +208 -0
- 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 +8 -18
- 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/runtime.ts +6 -0
- package/src/arcade/surface.ts +6 -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 +64 -195
- 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 +26 -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 +162 -0
- package/src/dev/browser-log-sink.ts +47 -27
- package/src/diagnostics.ts +5 -6
- package/src/hooks/internal/use-controller-runtime-api.ts +58 -836
- package/src/hooks/internal/use-host-runtime-api.ts +98 -1013
- package/src/hooks/internal/use-runtime-inspection-contract.ts +14 -2
- package/src/hooks/use-air-jam-controller.ts +41 -62
- package/src/hooks/use-air-jam-host.ts +66 -107
- 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 +26 -106
- package/src/lifecycle/index.ts +0 -4
- package/src/lifecycle/standard-match-phase.ts +1 -22
- package/src/metadata/manifest.ts +8 -20
- package/src/metadata.ts +1 -1
- package/src/platform-machine.ts +236 -15
- 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 +137 -66
- package/src/preview.ts +27 -15
- package/src/protocol/actions.ts +58 -0
- package/src/protocol/arcade-platform-actions.ts +20 -16
- package/src/protocol/controller.ts +15 -169
- package/src/protocol/core.ts +8 -15
- package/src/protocol/dev-log-events.ts +5 -84
- 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 +78 -0
- package/src/protocol/signed-envelope.ts +176 -0
- package/src/protocol.ts +4 -7
- package/src/qrcode.d.ts +3 -13
- package/src/release.ts +32 -0
- 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 +53 -51
- package/src/runtime/air-jam-error-boundary.tsx +52 -2
- 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 +58 -0
- package/src/runtime/contracts/agent-control.ts +195 -0
- package/src/runtime/contracts/clip.ts +169 -0
- package/src/runtime/contracts/control.ts +744 -59
- 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 +54 -115
- package/src/runtime/controller-presentation.ts +47 -17
- package/src/runtime/controller-press.ts +271 -0
- package/src/runtime/create-air-jam-app.tsx +120 -83
- 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-reference-game-identity.ts +13 -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 +23 -86
- package/src/runtime/session-runtimes.tsx +231 -64
- package/src/runtime/stage-capture.ts +25 -0
- package/src/runtime-control.ts +44 -8
- package/src/runtime-inspection.ts +14 -7
- package/src/runtime-topology.ts +7 -8
- package/src/settings/platform-settings-runtime.tsx +48 -8
- package/src/settings/platform-settings.ts +0 -96
- 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/arcade/bridge.cjs +0 -1067
- 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 -76
- 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 -1737
- 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 -123
- package/dist/arcade.js.map +0 -1
- package/dist/capabilities.cjs +0 -39
- package/dist/capabilities.cjs.map +0 -1
- package/dist/capabilities.d.cts +0 -31
- package/dist/capabilities.d.ts +0 -31
- package/dist/capabilities.js +0 -12
- package/dist/capabilities.js.map +0 -1
- package/dist/chunk-32NYL7XI.js +0 -539
- package/dist/chunk-32NYL7XI.js.map +0 -1
- package/dist/chunk-3USU7GY2.js.map +0 -1
- package/dist/chunk-6CMB356F.js +0 -193
- package/dist/chunk-6CMB356F.js.map +0 -1
- package/dist/chunk-7OTQTT6H.js.map +0 -1
- package/dist/chunk-BE6Z4SIT.js.map +0 -1
- package/dist/chunk-CVYR5RJT.js +0 -184
- package/dist/chunk-CVYR5RJT.js.map +0 -1
- package/dist/chunk-DY67S3LR.js.map +0 -1
- package/dist/chunk-E5PVHEAX.js +0 -126
- package/dist/chunk-E5PVHEAX.js.map +0 -1
- package/dist/chunk-EDRQIOCV.js +0 -25
- package/dist/chunk-EDRQIOCV.js.map +0 -1
- package/dist/chunk-EVZJA6RN.js.map +0 -1
- package/dist/chunk-IKKDONQL.js +0 -1
- package/dist/chunk-IKKDONQL.js.map +0 -1
- package/dist/chunk-JO2HR5PV.js +0 -43
- package/dist/chunk-JO2HR5PV.js.map +0 -1
- package/dist/chunk-JTF47B56.js +0 -1
- package/dist/chunk-JTF47B56.js.map +0 -1
- package/dist/chunk-KOB73SPD.js +0 -216
- package/dist/chunk-KOB73SPD.js.map +0 -1
- package/dist/chunk-LIXPF4P6.js +0 -22
- package/dist/chunk-LIXPF4P6.js.map +0 -1
- package/dist/chunk-M4DKOI42.js +0 -32
- package/dist/chunk-M4DKOI42.js.map +0 -1
- package/dist/chunk-MPDMJIX5.js +0 -1
- package/dist/chunk-MPDMJIX5.js.map +0 -1
- package/dist/chunk-NCL6WJCL.js.map +0 -1
- package/dist/chunk-NUJBMV3O.js.map +0 -1
- package/dist/chunk-Q4UALQO4.js +0 -288
- package/dist/chunk-Q4UALQO4.js.map +0 -1
- package/dist/chunk-TGRTEWYV.js +0 -195
- package/dist/chunk-TGRTEWYV.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-YXHH3MQT.js +0 -230
- package/dist/chunk-YXHH3MQT.js.map +0 -1
- package/dist/chunk-ZLPL2R3R.js.map +0 -1
- package/dist/chunk-ZTQ5SP4H.js +0 -9
- package/dist/chunk-ZTQ5SP4H.js.map +0 -1
- package/dist/controller-Bod8YYr1.d.cts +0 -172
- package/dist/controller-DxVchfiA.d.ts +0 -172
- package/dist/dev-log-events-CVAM29hx.d.cts +0 -123
- package/dist/dev-log-events-CVAM29hx.d.ts +0 -123
- package/dist/handshake-CC_LrK5g.d.cts +0 -31
- package/dist/handshake-CC_LrK5g.d.ts +0 -31
- package/dist/host-8hmq_Sgc.d.cts +0 -109
- package/dist/host-Cw-N6e-5.d.ts +0 -109
- package/dist/notices-CnGaaS8B.d.ts +0 -38
- package/dist/notices-NyDM5Mtz.d.cts +0 -38
- package/dist/realtime-client-Cu8yVJFw.d.cts +0 -15
- package/dist/realtime-client-Cu8yVJFw.d.ts +0 -15
- package/dist/sync-B6QsNrXz.d.cts +0 -125
- package/dist/sync-B6QsNrXz.d.ts +0 -125
- package/src/arcade/bridge.ts +0 -3
- package/src/arcade.ts +0 -4
- package/src/capabilities/manifest.ts +0 -71
- package/src/capabilities.ts +0 -12
- package/src/context/socket-manager.ts +0 -79
- package/src/events.ts +0 -124
- package/src/hooks/internal/use-runtime-control-contract.ts +0 -15
- package/src/hooks/internal/use-runtime-observability-contract.ts +0 -24
- 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 -30
- 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 -185
- package/src/protocol/host.ts +0 -138
- package/src/protocol/notices.ts +0 -43
- package/src/protocol/signals.ts +0 -38
- package/src/protocol/socket-events.ts +0 -154
- package/src/protocol/sync.ts +0 -121
- package/src/runtime/contracts/observability.ts +0 -94
- package/src/runtime/controller-bridge.ts +0 -451
- package/src/runtime/controller-realtime-client.ts +0 -591
- package/src/runtime/host-bridge.ts +0 -388
- 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/runtime-observability.ts +0 -9
- package/src/state/connection-store.ts +0 -152
- package/src/store/create-air-jam-store.ts +0 -1141
- package/src/store/index.ts +0 -1
- package/src/utils/ids.ts +0 -31
|
@@ -1,19 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readChildHostRuntimeParams,
|
|
3
|
+
readEmbeddedControllerRuntimeParams
|
|
4
|
+
} from "./chunk-QHBRHYMV.js";
|
|
1
5
|
import {
|
|
2
6
|
AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
3
7
|
AIRJAM_DEV_PROVIDER_MOUNTED,
|
|
4
8
|
AIRJAM_DEV_RUNTIME_EVENT,
|
|
5
|
-
emitAirJamDevRuntimeEvent
|
|
6
|
-
|
|
9
|
+
emitAirJamDevRuntimeEvent,
|
|
10
|
+
initializeInheritedPlatformSettingsBridge
|
|
11
|
+
} from "./chunk-EG25EXSA.js";
|
|
12
|
+
import {
|
|
13
|
+
isAirJamReplayDocument
|
|
14
|
+
} from "./chunk-2QZADUGA.js";
|
|
15
|
+
import {
|
|
16
|
+
embeddedRuntimeParent
|
|
17
|
+
} from "./chunk-LX6CTPDW.js";
|
|
7
18
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
19
|
+
controllerBridgeContext
|
|
20
|
+
} from "./chunk-FJ4J2BEC.js";
|
|
21
|
+
import {
|
|
22
|
+
createAirJamDiagnosticError,
|
|
23
|
+
emitAirJamDiagnostic,
|
|
24
|
+
onAirJamDiagnostic
|
|
25
|
+
} from "./chunk-DBF7NJ3S.js";
|
|
10
26
|
import {
|
|
11
27
|
AIRJAM_DEV_LOG_EVENTS,
|
|
12
28
|
resolveAirJamBrowserConsoleCategory
|
|
13
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-KUGROY5S.js";
|
|
14
30
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
createAirJamConfig,
|
|
32
|
+
createConnectionStore
|
|
33
|
+
} from "./chunk-6Y3F6Y2K.js";
|
|
17
34
|
import {
|
|
18
35
|
isLocalDevControlSurfaceTopology,
|
|
19
36
|
parseRuntimeTopologyFromSearchParams,
|
|
@@ -21,86 +38,508 @@ import {
|
|
|
21
38
|
readRuntimeTopologyFromWindow,
|
|
22
39
|
resolveProjectRuntimeTopology,
|
|
23
40
|
resolveRuntimeTopology
|
|
24
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-2H2FGF3H.js";
|
|
42
|
+
import {
|
|
43
|
+
DEFAULT_PLATFORM_SETTINGS,
|
|
44
|
+
PLATFORM_SETTINGS_STORAGE_KEY,
|
|
45
|
+
getEffectiveAudioVolume,
|
|
46
|
+
mergePlatformSettings,
|
|
47
|
+
normalizePlatformSettings
|
|
48
|
+
} from "./chunk-5CRZFIN6.js";
|
|
49
|
+
import {
|
|
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
|
-
return;
|
|
73
|
+
var readPersistedPlatformSettings = () => {
|
|
74
|
+
if (typeof window === "undefined") {
|
|
75
|
+
return DEFAULT_PLATFORM_SETTINGS;
|
|
45
76
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 {
|
|
85
|
+
}
|
|
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 })
|
|
71
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 })
|
|
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
|
+
);
|
|
72
446
|
};
|
|
73
|
-
var
|
|
74
|
-
|
|
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;
|
|
75
459
|
};
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
460
|
+
var applySurfaceRoleOverride = (topology, surfaceRole) => {
|
|
461
|
+
if (!topology || !surfaceRole || topology.surfaceRole === surfaceRole) {
|
|
462
|
+
return topology;
|
|
463
|
+
}
|
|
464
|
+
return resolveRuntimeTopology({
|
|
465
|
+
...topology,
|
|
466
|
+
surfaceRole
|
|
82
467
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
468
|
+
};
|
|
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
|
|
488
|
+
});
|
|
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;
|
|
@@ -125,24 +564,22 @@ var isDevelopmentRuntime = () => {
|
|
|
125
564
|
};
|
|
126
565
|
var resolveEndpointBase = ({
|
|
127
566
|
backendOrigin,
|
|
128
|
-
serverUrl,
|
|
129
567
|
appOrigin,
|
|
130
568
|
proxyStrategy
|
|
131
569
|
}) => {
|
|
132
570
|
if (proxyStrategy && proxyStrategy !== "none") {
|
|
133
571
|
return (appOrigin ?? resolveDevProxyBaseUrl())?.replace(/\/$/, "") ?? null;
|
|
134
572
|
}
|
|
135
|
-
|
|
136
|
-
if (!explicitOrigin) {
|
|
573
|
+
if (!backendOrigin) {
|
|
137
574
|
return resolveDevProxyBaseUrl();
|
|
138
575
|
}
|
|
139
|
-
if (
|
|
140
|
-
return `http://${
|
|
576
|
+
if (backendOrigin.startsWith("ws://")) {
|
|
577
|
+
return `http://${backendOrigin.slice(5)}`.replace(/\/$/, "");
|
|
141
578
|
}
|
|
142
|
-
if (
|
|
143
|
-
return `https://${
|
|
579
|
+
if (backendOrigin.startsWith("wss://")) {
|
|
580
|
+
return `https://${backendOrigin.slice(6)}`.replace(/\/$/, "");
|
|
144
581
|
}
|
|
145
|
-
return
|
|
582
|
+
return backendOrigin.replace(/\/$/, "");
|
|
146
583
|
};
|
|
147
584
|
var resolveDevProxyBaseUrl = () => {
|
|
148
585
|
if (typeof window === "undefined") {
|
|
@@ -272,11 +709,14 @@ var BrowserLogSinkRuntime = class {
|
|
|
272
709
|
endpoint = null;
|
|
273
710
|
unloadEndpoint = null;
|
|
274
711
|
appId;
|
|
712
|
+
parent = null;
|
|
275
713
|
sessionId = createSessionId();
|
|
276
714
|
queue = [];
|
|
277
715
|
nextSourceSeq = 1;
|
|
278
716
|
flushTimer = null;
|
|
279
717
|
hasReset = false;
|
|
718
|
+
/** Set once the endpoint accepts a batch: later network failures are outages, not misconfiguration. */
|
|
719
|
+
delivered = false;
|
|
280
720
|
originalConsole = /* @__PURE__ */ new Map();
|
|
281
721
|
disposers = [];
|
|
282
722
|
installed = false;
|
|
@@ -285,6 +725,7 @@ var BrowserLogSinkRuntime = class {
|
|
|
285
725
|
this.endpoint = resolveLogEndpoint(options);
|
|
286
726
|
this.unloadEndpoint = resolveUnloadEndpoint(options);
|
|
287
727
|
this.appId = options.appId;
|
|
728
|
+
this.parent = options.topology ? embeddedRuntimeParent(options.topology) : null;
|
|
288
729
|
if (this.endpoint && this.endpoint !== previousEndpoint && this.queue.length > 0 && !this.flushTimer) {
|
|
289
730
|
this.flushTimer = setTimeout(() => {
|
|
290
731
|
void this.flush();
|
|
@@ -315,14 +756,14 @@ var BrowserLogSinkRuntime = class {
|
|
|
315
756
|
};
|
|
316
757
|
const originalError = this.originalConsole.get("error") ?? console.error.bind(console);
|
|
317
758
|
originalError("[AirJam][AJ_BROWSER_LOG_SINK_POST_FAILED]", payload);
|
|
318
|
-
if (
|
|
759
|
+
if (this.parent) {
|
|
319
760
|
try {
|
|
320
|
-
|
|
761
|
+
this.parent.window.postMessage(
|
|
321
762
|
{
|
|
322
763
|
type: AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
323
764
|
payload
|
|
324
765
|
},
|
|
325
|
-
|
|
766
|
+
this.parent.origin
|
|
326
767
|
);
|
|
327
768
|
} catch {
|
|
328
769
|
}
|
|
@@ -655,17 +1096,23 @@ var BrowserLogSinkRuntime = class {
|
|
|
655
1096
|
}
|
|
656
1097
|
this.queue.splice(0, this.queue.length);
|
|
657
1098
|
this.hasReset = true;
|
|
658
|
-
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
|
+
}
|
|
659
1105
|
}
|
|
1106
|
+
/** Sends a batch; only a network outage after earlier delivery is `unreachable`, everything else that fails is reported. */
|
|
660
1107
|
async postPayload(body, useBeacon) {
|
|
661
1108
|
if (!this.endpoint) {
|
|
662
|
-
return;
|
|
1109
|
+
return "failed";
|
|
663
1110
|
}
|
|
664
1111
|
if (useBeacon && typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
665
1112
|
try {
|
|
666
1113
|
const requestBody = typeof Blob === "function" ? new Blob([body], { type: "application/json" }) : body;
|
|
667
1114
|
if (navigator.sendBeacon(this.endpoint, requestBody)) {
|
|
668
|
-
return;
|
|
1115
|
+
return "sent";
|
|
669
1116
|
}
|
|
670
1117
|
} catch {
|
|
671
1118
|
}
|
|
@@ -685,10 +1132,15 @@ var BrowserLogSinkRuntime = class {
|
|
|
685
1132
|
`Browser log sink endpoint returned ${response.status}`,
|
|
686
1133
|
{ status: response.status }
|
|
687
1134
|
);
|
|
1135
|
+
return "failed";
|
|
688
1136
|
}
|
|
1137
|
+
this.delivered = true;
|
|
1138
|
+
return "sent";
|
|
689
1139
|
} catch (error) {
|
|
1140
|
+
if (this.delivered) return "unreachable";
|
|
690
1141
|
const reason = error instanceof Error ? error.message : "Unknown browser log sink transport failure";
|
|
691
1142
|
this.reportTransportFailure(reason);
|
|
1143
|
+
return "failed";
|
|
692
1144
|
}
|
|
693
1145
|
}
|
|
694
1146
|
};
|
|
@@ -697,7 +1149,7 @@ var ensureDevBrowserLogSink = (options) => {
|
|
|
697
1149
|
return;
|
|
698
1150
|
}
|
|
699
1151
|
const globalState = globalThis;
|
|
700
|
-
const autoEnabled = options.topology != null ? isLocalDevControlSurfaceTopology(options.topology) :
|
|
1152
|
+
const autoEnabled = options.topology != null ? isLocalDevControlSurfaceTopology(options.topology) : isDevelopmentRuntime2();
|
|
701
1153
|
if (!autoEnabled) {
|
|
702
1154
|
globalState.__airJamBrowserLogSink__?.dispose?.();
|
|
703
1155
|
delete globalState.__airJamBrowserLogSink__;
|
|
@@ -716,500 +1168,9 @@ var ensureDevBrowserLogSink = (options) => {
|
|
|
716
1168
|
globalState.__airJamBrowserLogSink__.update(options);
|
|
717
1169
|
};
|
|
718
1170
|
|
|
719
|
-
// src/internal/input-manager.ts
|
|
720
|
-
var InputManager = class {
|
|
721
|
-
inputBuffer = /* @__PURE__ */ new Map();
|
|
722
|
-
behaviorState = /* @__PURE__ */ new Map();
|
|
723
|
-
behaviorOverrides = /* @__PURE__ */ new Map();
|
|
724
|
-
config;
|
|
725
|
-
constructor(config = {}) {
|
|
726
|
-
this.config = config;
|
|
727
|
-
this.behaviorOverrides = this.createBehaviorOverrides(config.behavior);
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Handles incoming input events from the socket.
|
|
731
|
-
* Should be called when 'server:input' event is received.
|
|
732
|
-
*/
|
|
733
|
-
handleInput(payload) {
|
|
734
|
-
this.inputBuffer.set(payload.controllerId, payload.input);
|
|
735
|
-
this.captureTransientBehaviors(payload.controllerId, payload.input);
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Gets input for a specific controller.
|
|
739
|
-
* Returns validated and typed input if schema is provided, otherwise raw Record.
|
|
740
|
-
* Applies configured input behavior semantics.
|
|
741
|
-
*/
|
|
742
|
-
getInput(controllerId) {
|
|
743
|
-
const rawInput = this.inputBuffer.get(controllerId);
|
|
744
|
-
if (!rawInput) {
|
|
745
|
-
return void 0;
|
|
746
|
-
}
|
|
747
|
-
let validatedInput = rawInput;
|
|
748
|
-
if (this.config.schema) {
|
|
749
|
-
const result = this.config.schema.safeParse(rawInput);
|
|
750
|
-
if (!result.success) {
|
|
751
|
-
console.warn(
|
|
752
|
-
`[InputManager] Invalid input for controller ${controllerId}:`,
|
|
753
|
-
result.error
|
|
754
|
-
);
|
|
755
|
-
return void 0;
|
|
756
|
-
}
|
|
757
|
-
validatedInput = result.data;
|
|
758
|
-
}
|
|
759
|
-
return this.applyBehaviors(
|
|
760
|
-
controllerId,
|
|
761
|
-
validatedInput
|
|
762
|
-
);
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Clears input state for a controller (e.g., when player leaves).
|
|
766
|
-
*/
|
|
767
|
-
clearInput(controllerId) {
|
|
768
|
-
this.inputBuffer.delete(controllerId);
|
|
769
|
-
this.behaviorState.delete(controllerId);
|
|
770
|
-
}
|
|
771
|
-
getBehaviorState(controllerId) {
|
|
772
|
-
const existing = this.behaviorState.get(controllerId);
|
|
773
|
-
if (existing) {
|
|
774
|
-
return existing;
|
|
775
|
-
}
|
|
776
|
-
const created = {
|
|
777
|
-
pulseBooleans: /* @__PURE__ */ new Set(),
|
|
778
|
-
pulseVectors: /* @__PURE__ */ new Map(),
|
|
779
|
-
holdVectors: /* @__PURE__ */ new Map()
|
|
780
|
-
};
|
|
781
|
-
this.behaviorState.set(controllerId, created);
|
|
782
|
-
return created;
|
|
783
|
-
}
|
|
784
|
-
createBehaviorOverrides(behavior) {
|
|
785
|
-
const overrides = /* @__PURE__ */ new Map();
|
|
786
|
-
const assign = (fields, mode) => {
|
|
787
|
-
for (const field of fields ?? []) {
|
|
788
|
-
const existing = overrides.get(field);
|
|
789
|
-
if (existing && existing !== mode) {
|
|
790
|
-
throw new Error(
|
|
791
|
-
`[InputManager] Field "${field}" is configured for both "${existing}" and "${mode}".`
|
|
792
|
-
);
|
|
793
|
-
}
|
|
794
|
-
overrides.set(field, mode);
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
assign(behavior?.pulse, "pulse");
|
|
798
|
-
assign(behavior?.hold, "hold");
|
|
799
|
-
assign(behavior?.latest, "latest");
|
|
800
|
-
return overrides;
|
|
801
|
-
}
|
|
802
|
-
resolveFieldBehavior(field, value) {
|
|
803
|
-
const override = this.behaviorOverrides.get(field);
|
|
804
|
-
if (override) {
|
|
805
|
-
return override;
|
|
806
|
-
}
|
|
807
|
-
if (typeof value === "boolean") {
|
|
808
|
-
return "pulse";
|
|
809
|
-
}
|
|
810
|
-
if (this.isVectorValue(value)) {
|
|
811
|
-
return "latest";
|
|
812
|
-
}
|
|
813
|
-
return "latest";
|
|
814
|
-
}
|
|
815
|
-
isVectorValue(value) {
|
|
816
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
817
|
-
return false;
|
|
818
|
-
}
|
|
819
|
-
const vector = value;
|
|
820
|
-
return typeof vector.x === "number" && typeof vector.y === "number";
|
|
821
|
-
}
|
|
822
|
-
isActiveVector(vector) {
|
|
823
|
-
return vector.x !== 0 || vector.y !== 0;
|
|
824
|
-
}
|
|
825
|
-
captureTransientBehaviors(controllerId, rawInput) {
|
|
826
|
-
const state = this.getBehaviorState(controllerId);
|
|
827
|
-
for (const [field, value] of Object.entries(rawInput)) {
|
|
828
|
-
const behavior = this.resolveFieldBehavior(field, value);
|
|
829
|
-
if (behavior === "pulse") {
|
|
830
|
-
if (typeof value === "boolean") {
|
|
831
|
-
if (value) {
|
|
832
|
-
state.pulseBooleans.add(field);
|
|
833
|
-
}
|
|
834
|
-
continue;
|
|
835
|
-
}
|
|
836
|
-
if (this.isVectorValue(value) && this.isActiveVector(value)) {
|
|
837
|
-
state.pulseVectors.set(field, value);
|
|
838
|
-
}
|
|
839
|
-
continue;
|
|
840
|
-
}
|
|
841
|
-
if (behavior === "hold" && this.isVectorValue(value)) {
|
|
842
|
-
if (this.isActiveVector(value)) {
|
|
843
|
-
state.holdVectors.set(field, value);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
applyBehaviors(controllerId, validatedInput) {
|
|
849
|
-
const state = this.getBehaviorState(controllerId);
|
|
850
|
-
const output = { ...validatedInput };
|
|
851
|
-
const processedFields = /* @__PURE__ */ new Set();
|
|
852
|
-
for (const [field, value] of Object.entries(validatedInput)) {
|
|
853
|
-
processedFields.add(field);
|
|
854
|
-
const behavior = this.resolveFieldBehavior(field, value);
|
|
855
|
-
if (behavior === "latest") {
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
if (behavior === "pulse") {
|
|
859
|
-
if (typeof value === "boolean") {
|
|
860
|
-
const pending = state.pulseBooleans.has(field);
|
|
861
|
-
output[field] = value === true || pending;
|
|
862
|
-
state.pulseBooleans.delete(field);
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
|
-
if (this.isVectorValue(value)) {
|
|
866
|
-
const pending = state.pulseVectors.get(field);
|
|
867
|
-
if (pending) {
|
|
868
|
-
output[field] = this.isActiveVector(value) ? value : pending;
|
|
869
|
-
state.pulseVectors.delete(field);
|
|
870
|
-
}
|
|
871
|
-
continue;
|
|
872
|
-
}
|
|
873
|
-
continue;
|
|
874
|
-
}
|
|
875
|
-
if (this.isVectorValue(value)) {
|
|
876
|
-
if (this.isActiveVector(value)) {
|
|
877
|
-
state.holdVectors.set(field, value);
|
|
878
|
-
output[field] = value;
|
|
879
|
-
} else {
|
|
880
|
-
output[field] = state.holdVectors.get(field) ?? { x: 0, y: 0 };
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
for (const field of Array.from(state.pulseBooleans)) {
|
|
885
|
-
if (!processedFields.has(field)) {
|
|
886
|
-
output[field] = true;
|
|
887
|
-
state.pulseBooleans.delete(field);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
for (const [field, vector] of Array.from(state.pulseVectors.entries())) {
|
|
891
|
-
if (!processedFields.has(field)) {
|
|
892
|
-
output[field] = vector;
|
|
893
|
-
state.pulseVectors.delete(field);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
return output;
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
|
|
900
|
-
// src/runtime/air-jam-config.ts
|
|
901
|
-
var getNodeEnv = () => {
|
|
902
|
-
const candidate = globalThis.process;
|
|
903
|
-
return candidate?.env;
|
|
904
|
-
};
|
|
905
|
-
var getViteEnv = () => {
|
|
906
|
-
try {
|
|
907
|
-
const meta = import.meta;
|
|
908
|
-
if (meta && typeof meta.env === "object") {
|
|
909
|
-
return meta.env;
|
|
910
|
-
}
|
|
911
|
-
} catch {
|
|
912
|
-
return void 0;
|
|
913
|
-
}
|
|
914
|
-
return void 0;
|
|
915
|
-
};
|
|
916
|
-
var getNodeEnvMode = () => {
|
|
917
|
-
return getNodeEnv()?.NODE_ENV;
|
|
918
|
-
};
|
|
919
|
-
var isDevelopmentRuntime2 = () => {
|
|
920
|
-
const viteEnv = getViteEnv();
|
|
921
|
-
if (typeof viteEnv?.DEV === "boolean") {
|
|
922
|
-
return viteEnv.DEV;
|
|
923
|
-
}
|
|
924
|
-
return getNodeEnvMode() !== "production";
|
|
925
|
-
};
|
|
926
|
-
var getEnvServerUrl = () => {
|
|
927
|
-
const viteEnv = getViteEnv();
|
|
928
|
-
if (viteEnv?.VITE_AIR_JAM_SERVER_URL) {
|
|
929
|
-
return viteEnv.VITE_AIR_JAM_SERVER_URL;
|
|
930
|
-
}
|
|
931
|
-
const nodeEnv = getNodeEnv();
|
|
932
|
-
if (nodeEnv) {
|
|
933
|
-
const nextUrl = nodeEnv.NEXT_PUBLIC_AIR_JAM_SERVER_URL;
|
|
934
|
-
if (nextUrl) {
|
|
935
|
-
return nextUrl;
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
return void 0;
|
|
939
|
-
};
|
|
940
|
-
var getEnvAppId = () => {
|
|
941
|
-
const viteEnv = getViteEnv();
|
|
942
|
-
if (viteEnv?.VITE_AIR_JAM_APP_ID) {
|
|
943
|
-
return viteEnv.VITE_AIR_JAM_APP_ID;
|
|
944
|
-
}
|
|
945
|
-
const nodeEnv = getNodeEnv();
|
|
946
|
-
if (nodeEnv) {
|
|
947
|
-
const nextAppId = nodeEnv.NEXT_PUBLIC_AIR_JAM_APP_ID;
|
|
948
|
-
if (nextAppId) {
|
|
949
|
-
return nextAppId;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
return void 0;
|
|
953
|
-
};
|
|
954
|
-
var getEnvPublicHost = () => {
|
|
955
|
-
const viteEnv = getViteEnv();
|
|
956
|
-
if (viteEnv?.VITE_AIR_JAM_PUBLIC_HOST) {
|
|
957
|
-
return viteEnv.VITE_AIR_JAM_PUBLIC_HOST;
|
|
958
|
-
}
|
|
959
|
-
const nodeEnv = getNodeEnv();
|
|
960
|
-
if (nodeEnv) {
|
|
961
|
-
const nextHost = nodeEnv.NEXT_PUBLIC_AIR_JAM_PUBLIC_HOST;
|
|
962
|
-
if (nextHost) {
|
|
963
|
-
return nextHost;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return void 0;
|
|
967
|
-
};
|
|
968
|
-
var getEnvHostGrantEndpoint = () => {
|
|
969
|
-
const viteEnv = getViteEnv();
|
|
970
|
-
if (viteEnv?.VITE_AIR_JAM_HOST_GRANT_ENDPOINT) {
|
|
971
|
-
return viteEnv.VITE_AIR_JAM_HOST_GRANT_ENDPOINT;
|
|
972
|
-
}
|
|
973
|
-
const nodeEnv = getNodeEnv();
|
|
974
|
-
if (nodeEnv) {
|
|
975
|
-
const nextEndpoint = nodeEnv.NEXT_PUBLIC_AIR_JAM_HOST_GRANT_ENDPOINT;
|
|
976
|
-
if (nextEndpoint) {
|
|
977
|
-
return nextEndpoint;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
return void 0;
|
|
981
|
-
};
|
|
982
|
-
var readRuntimeTopologyFromViteEnv = () => {
|
|
983
|
-
const viteEnv = getViteEnv();
|
|
984
|
-
if (!viteEnv?.VITE_AIR_JAM_RUNTIME_TOPOLOGY) {
|
|
985
|
-
return null;
|
|
986
|
-
}
|
|
987
|
-
return readRuntimeTopologyFromEnv({
|
|
988
|
-
VITE_AIR_JAM_RUNTIME_TOPOLOGY: viteEnv.VITE_AIR_JAM_RUNTIME_TOPOLOGY
|
|
989
|
-
});
|
|
990
|
-
};
|
|
991
|
-
var readRuntimeTopologyFromWindowSearchParams = () => {
|
|
992
|
-
if (typeof window === "undefined") {
|
|
993
|
-
return null;
|
|
994
|
-
}
|
|
995
|
-
return parseRuntimeTopologyFromSearchParams(
|
|
996
|
-
new URLSearchParams(window.location.search)
|
|
997
|
-
);
|
|
998
|
-
};
|
|
999
|
-
var applySurfaceRoleOverride = (topology, surfaceRole) => {
|
|
1000
|
-
if (!topology || !surfaceRole || topology.surfaceRole === surfaceRole) {
|
|
1001
|
-
return topology;
|
|
1002
|
-
}
|
|
1003
|
-
return resolveRuntimeTopology({
|
|
1004
|
-
...topology,
|
|
1005
|
-
surfaceRole
|
|
1006
|
-
});
|
|
1007
|
-
};
|
|
1008
|
-
var resolveProjectTopologyFromEnv = (surfaceRole) => {
|
|
1009
|
-
const effectiveSurfaceRole = surfaceRole ?? "host";
|
|
1010
|
-
if (effectiveSurfaceRole !== "host" && effectiveSurfaceRole !== "controller") {
|
|
1011
|
-
return null;
|
|
1012
|
-
}
|
|
1013
|
-
const explicitPublicHost = getEnvPublicHost();
|
|
1014
|
-
const appOrigin = explicitPublicHost ?? (typeof window !== "undefined" ? window.location.origin : void 0);
|
|
1015
|
-
if (!appOrigin) {
|
|
1016
|
-
return null;
|
|
1017
|
-
}
|
|
1018
|
-
const secureTransport = appOrigin.startsWith("https://");
|
|
1019
|
-
const runtimeMode = isDevelopmentRuntime2() ? secureTransport ? "standalone-secure" : "standalone-dev" : "self-hosted-production";
|
|
1020
|
-
return resolveProjectRuntimeTopology({
|
|
1021
|
-
runtimeMode,
|
|
1022
|
-
surfaceRole: effectiveSurfaceRole,
|
|
1023
|
-
appOrigin,
|
|
1024
|
-
backendOrigin: getEnvServerUrl() ?? appOrigin,
|
|
1025
|
-
publicHost: explicitPublicHost ?? appOrigin,
|
|
1026
|
-
secureTransport
|
|
1027
|
-
});
|
|
1028
|
-
};
|
|
1029
|
-
var resolveAirJamConfig = ({
|
|
1030
|
-
topology,
|
|
1031
|
-
surfaceRole,
|
|
1032
|
-
appId,
|
|
1033
|
-
hostGrantEndpoint,
|
|
1034
|
-
maxPlayers = DEFAULT_MAX_PLAYERS,
|
|
1035
|
-
hostSessionKind = "game",
|
|
1036
|
-
resolveEnv = true
|
|
1037
|
-
}) => {
|
|
1038
|
-
const resolvedTopology = topology ? applySurfaceRoleOverride(resolveRuntimeTopology(topology), surfaceRole) : resolveEnv ? applySurfaceRoleOverride(
|
|
1039
|
-
readRuntimeTopologyFromViteEnv() ?? readRuntimeTopologyFromEnv(getNodeEnv()) ?? readRuntimeTopologyFromWindow(window) ?? readRuntimeTopologyFromWindowSearchParams() ?? resolveProjectTopologyFromEnv(surfaceRole),
|
|
1040
|
-
surfaceRole
|
|
1041
|
-
) : null;
|
|
1042
|
-
if (!resolvedTopology) {
|
|
1043
|
-
throw createAirJamDiagnosticError(
|
|
1044
|
-
"AJ_CONFIG_MISSING_RUNTIME_TOPOLOGY",
|
|
1045
|
-
"Missing runtime topology. Provide `topology` directly, or enable env resolution with a supported project/runtime mode."
|
|
1046
|
-
);
|
|
1047
|
-
}
|
|
1048
|
-
const resolvedAppId = appId ?? getEnvAppId();
|
|
1049
|
-
if (getNodeEnvMode() === "production" && !resolvedAppId) {
|
|
1050
|
-
emitAirJamDiagnostic({
|
|
1051
|
-
code: "AJ_CONFIG_MISSING_APP_ID",
|
|
1052
|
-
severity: "error",
|
|
1053
|
-
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."
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
return {
|
|
1057
|
-
topology: resolvedTopology,
|
|
1058
|
-
appId: resolvedAppId,
|
|
1059
|
-
hostGrantEndpoint: hostGrantEndpoint ?? getEnvHostGrantEndpoint(),
|
|
1060
|
-
maxPlayers,
|
|
1061
|
-
hostSessionKind,
|
|
1062
|
-
serverUrl: resolvedTopology.backendOrigin,
|
|
1063
|
-
publicHost: resolvedTopology.publicHost,
|
|
1064
|
-
backendOrigin: resolvedTopology.backendOrigin,
|
|
1065
|
-
socketOrigin: resolvedTopology.socketOrigin,
|
|
1066
|
-
appOrigin: resolvedTopology.appOrigin,
|
|
1067
|
-
proxyStrategy: resolvedTopology.proxyStrategy
|
|
1068
|
-
};
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
// src/state/connection-store.ts
|
|
1072
|
-
import { create } from "zustand";
|
|
1073
|
-
var createAirJamStore = () => create((set) => ({
|
|
1074
|
-
role: null,
|
|
1075
|
-
roomId: null,
|
|
1076
|
-
controllerId: null,
|
|
1077
|
-
connectionStatus: "idle",
|
|
1078
|
-
mode: "standalone",
|
|
1079
|
-
runtimeState: "playing",
|
|
1080
|
-
controllerOrientation: "portrait",
|
|
1081
|
-
stateMessage: void 0,
|
|
1082
|
-
roomSettings: DEFAULT_ROOM_PLATFORM_SETTINGS,
|
|
1083
|
-
players: [],
|
|
1084
|
-
controllerSessions: [],
|
|
1085
|
-
lastError: void 0,
|
|
1086
|
-
registeredRoomId: null,
|
|
1087
|
-
hostArcadeRestore: {
|
|
1088
|
-
phase: "idle",
|
|
1089
|
-
session: null
|
|
1090
|
-
},
|
|
1091
|
-
setHostArcadeRestore: (next) => set({ hostArcadeRestore: next }),
|
|
1092
|
-
clearHostArcadeRestore: () => set({
|
|
1093
|
-
hostArcadeRestore: {
|
|
1094
|
-
phase: "idle",
|
|
1095
|
-
session: null
|
|
1096
|
-
}
|
|
1097
|
-
}),
|
|
1098
|
-
setRole: (role) => set({ role }),
|
|
1099
|
-
setRoomId: (roomId) => set({ roomId }),
|
|
1100
|
-
setControllerId: (controllerId) => set({ controllerId }),
|
|
1101
|
-
setStatus: (connectionStatus) => set({ connectionStatus }),
|
|
1102
|
-
setMode: (mode) => set({ mode }),
|
|
1103
|
-
setRuntimeState: (runtimeState) => set({ runtimeState }),
|
|
1104
|
-
setControllerOrientation: (controllerOrientation) => set({ controllerOrientation }),
|
|
1105
|
-
setStateMessage: (stateMessage) => set({ stateMessage }),
|
|
1106
|
-
setRoomSettings: (roomSettings) => set({ roomSettings }),
|
|
1107
|
-
setError: (message) => set({ lastError: message }),
|
|
1108
|
-
upsertPlayer: (player) => set((state) => {
|
|
1109
|
-
const existingIndex = state.players.findIndex(
|
|
1110
|
-
(entry) => entry.id === player.id
|
|
1111
|
-
);
|
|
1112
|
-
if (existingIndex >= 0) {
|
|
1113
|
-
const nextPlayers = [...state.players];
|
|
1114
|
-
nextPlayers[existingIndex] = player;
|
|
1115
|
-
return { players: nextPlayers };
|
|
1116
|
-
}
|
|
1117
|
-
return { players: [...state.players, player] };
|
|
1118
|
-
}),
|
|
1119
|
-
removePlayer: (playerId) => set((state) => ({
|
|
1120
|
-
players: state.players.filter((player) => player.id !== playerId)
|
|
1121
|
-
})),
|
|
1122
|
-
resetPlayers: () => set({ players: [] }),
|
|
1123
|
-
upsertControllerSession: (controller) => set((state) => {
|
|
1124
|
-
const existingIndex = state.controllerSessions.findIndex(
|
|
1125
|
-
(entry) => entry.controllerId === controller.controllerId
|
|
1126
|
-
);
|
|
1127
|
-
if (existingIndex >= 0) {
|
|
1128
|
-
const nextSessions = [...state.controllerSessions];
|
|
1129
|
-
nextSessions[existingIndex] = controller;
|
|
1130
|
-
return { controllerSessions: nextSessions };
|
|
1131
|
-
}
|
|
1132
|
-
return {
|
|
1133
|
-
controllerSessions: [...state.controllerSessions, controller]
|
|
1134
|
-
};
|
|
1135
|
-
}),
|
|
1136
|
-
removeControllerSession: (controllerId) => set((state) => ({
|
|
1137
|
-
controllerSessions: state.controllerSessions.filter(
|
|
1138
|
-
(controller) => controller.controllerId !== controllerId
|
|
1139
|
-
)
|
|
1140
|
-
})),
|
|
1141
|
-
resetControllerSessions: () => set({ controllerSessions: [] }),
|
|
1142
|
-
resetRuntimeState: () => set({
|
|
1143
|
-
runtimeState: "playing",
|
|
1144
|
-
controllerOrientation: "portrait",
|
|
1145
|
-
stateMessage: void 0,
|
|
1146
|
-
roomSettings: DEFAULT_ROOM_PLATFORM_SETTINGS
|
|
1147
|
-
}),
|
|
1148
|
-
setRegisteredRoomId: (roomId) => set({ registeredRoomId: roomId })
|
|
1149
|
-
}));
|
|
1150
|
-
|
|
1151
|
-
// src/context/socket-manager.ts
|
|
1152
|
-
import { io } from "socket.io-client";
|
|
1153
|
-
var SocketManager = class {
|
|
1154
|
-
sockets = {};
|
|
1155
|
-
socketOrigin;
|
|
1156
|
-
constructor(socketOrigin) {
|
|
1157
|
-
this.socketOrigin = this.normalizeOrigin(socketOrigin);
|
|
1158
|
-
}
|
|
1159
|
-
/**
|
|
1160
|
-
* Get or create a socket for the specified role.
|
|
1161
|
-
* Sockets are lazily created and cached per role.
|
|
1162
|
-
*/
|
|
1163
|
-
getSocket(role) {
|
|
1164
|
-
const existing = this.sockets[role];
|
|
1165
|
-
if (existing) {
|
|
1166
|
-
return existing;
|
|
1167
|
-
}
|
|
1168
|
-
const socket = io(this.socketOrigin, {
|
|
1169
|
-
autoConnect: false,
|
|
1170
|
-
query: { role }
|
|
1171
|
-
});
|
|
1172
|
-
this.sockets[role] = socket;
|
|
1173
|
-
return socket;
|
|
1174
|
-
}
|
|
1175
|
-
/**
|
|
1176
|
-
* Disconnect a socket by role.
|
|
1177
|
-
* NOTE: We intentionally do NOT delete the socket from cache.
|
|
1178
|
-
* This ensures all hooks using getSocket() get the same instance,
|
|
1179
|
-
* even during React Strict Mode remounts. The socket can be reconnected
|
|
1180
|
-
* by calling socket.connect() again.
|
|
1181
|
-
*/
|
|
1182
|
-
disconnect(role) {
|
|
1183
|
-
const socket = this.sockets[role];
|
|
1184
|
-
if (socket) {
|
|
1185
|
-
socket.disconnect();
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
/**
|
|
1189
|
-
* Disconnect all sockets managed by this instance
|
|
1190
|
-
*/
|
|
1191
|
-
disconnectAll() {
|
|
1192
|
-
for (const role of Object.keys(this.sockets)) {
|
|
1193
|
-
this.disconnect(role);
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Deprecated compatibility alias. Returns the resolved socket origin.
|
|
1198
|
-
*/
|
|
1199
|
-
getServerUrl() {
|
|
1200
|
-
return this.socketOrigin;
|
|
1201
|
-
}
|
|
1202
|
-
normalizeOrigin(origin) {
|
|
1203
|
-
if (!origin.includes("://")) {
|
|
1204
|
-
return `http://${origin}`;
|
|
1205
|
-
}
|
|
1206
|
-
return origin;
|
|
1207
|
-
}
|
|
1208
|
-
};
|
|
1209
|
-
|
|
1210
1171
|
// src/context/air-jam-context.tsx
|
|
1211
|
-
import { jsx } from "react/jsx-runtime";
|
|
1212
|
-
var AirJamContext =
|
|
1172
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1173
|
+
var AirJamContext = createContext3(null);
|
|
1213
1174
|
var AirJamProvider = ({
|
|
1214
1175
|
children,
|
|
1215
1176
|
topology,
|
|
@@ -1217,47 +1178,40 @@ var AirJamProvider = ({
|
|
|
1217
1178
|
appId,
|
|
1218
1179
|
hostGrantEndpoint,
|
|
1219
1180
|
maxPlayers,
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1181
|
+
reportError,
|
|
1182
|
+
presentationChannel,
|
|
1183
|
+
resolveEnv = true
|
|
1223
1184
|
}) => {
|
|
1224
|
-
const config =
|
|
1225
|
-
() => resolveAirJamConfig(
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
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
|
+
),
|
|
1234
1198
|
[
|
|
1235
1199
|
topology,
|
|
1236
1200
|
surfaceRole,
|
|
1237
1201
|
appId,
|
|
1238
1202
|
hostGrantEndpoint,
|
|
1239
1203
|
maxPlayers,
|
|
1240
|
-
|
|
1204
|
+
reportError,
|
|
1205
|
+
presentationChannel,
|
|
1241
1206
|
resolveEnv
|
|
1242
1207
|
]
|
|
1243
1208
|
);
|
|
1244
|
-
const localDevControlSurfacesEnabled =
|
|
1245
|
-
() => isLocalDevControlSurfaceTopology(config.topology),
|
|
1209
|
+
const localDevControlSurfacesEnabled = useMemo2(
|
|
1210
|
+
() => isLocalDevControlSurfaceTopology(config.topology) && !isAirJamReplayDocument(),
|
|
1246
1211
|
[config.topology]
|
|
1247
1212
|
);
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
return null;
|
|
1251
|
-
}
|
|
1252
|
-
return new InputManager(input);
|
|
1253
|
-
}, [input]);
|
|
1254
|
-
const store = useMemo(() => createAirJamStore(), []);
|
|
1255
|
-
const socketManager = useMemo(
|
|
1256
|
-
() => new SocketManager(config.socketOrigin),
|
|
1257
|
-
// Only recreate if socketOrigin changes - intentionally omitting config
|
|
1258
|
-
[config.socketOrigin]
|
|
1259
|
-
);
|
|
1260
|
-
useEffect(() => {
|
|
1213
|
+
const store = useMemo2(() => createConnectionStore(), []);
|
|
1214
|
+
useEffect2(() => {
|
|
1261
1215
|
return () => {
|
|
1262
1216
|
const devWindow = typeof window !== "undefined" ? window : void 0;
|
|
1263
1217
|
if (devWindow && localDevControlSurfacesEnabled) {
|
|
@@ -1278,16 +1232,15 @@ var AirJamProvider = ({
|
|
|
1278
1232
|
} catch {
|
|
1279
1233
|
}
|
|
1280
1234
|
}
|
|
1281
|
-
socketManager.disconnectAll();
|
|
1282
1235
|
};
|
|
1283
1236
|
}, [
|
|
1284
1237
|
config.appId,
|
|
1285
1238
|
config.backendOrigin,
|
|
1286
1239
|
config.socketOrigin,
|
|
1287
|
-
localDevControlSurfacesEnabled
|
|
1288
|
-
socketManager
|
|
1240
|
+
localDevControlSurfacesEnabled
|
|
1289
1241
|
]);
|
|
1290
|
-
|
|
1242
|
+
useEffect2(() => {
|
|
1243
|
+
if (isAirJamReplayDocument()) return;
|
|
1291
1244
|
ensureDevBrowserLogSink({
|
|
1292
1245
|
appOrigin: config.appOrigin,
|
|
1293
1246
|
backendOrigin: config.backendOrigin,
|
|
@@ -1312,8 +1265,9 @@ var AirJamProvider = ({
|
|
|
1312
1265
|
pathname: devWindow.location.pathname
|
|
1313
1266
|
}
|
|
1314
1267
|
});
|
|
1315
|
-
|
|
1316
|
-
|
|
1268
|
+
const parent = embeddedRuntimeParent(config.topology);
|
|
1269
|
+
if (parent) {
|
|
1270
|
+
parent.window.postMessage(
|
|
1317
1271
|
{
|
|
1318
1272
|
type: AIRJAM_DEV_PROVIDER_MOUNTED,
|
|
1319
1273
|
payload: {
|
|
@@ -1325,7 +1279,7 @@ var AirJamProvider = ({
|
|
|
1325
1279
|
pathname: devWindow.location.pathname
|
|
1326
1280
|
}
|
|
1327
1281
|
},
|
|
1328
|
-
|
|
1282
|
+
parent.origin
|
|
1329
1283
|
);
|
|
1330
1284
|
}
|
|
1331
1285
|
} catch {
|
|
@@ -1340,29 +1294,14 @@ var AirJamProvider = ({
|
|
|
1340
1294
|
config.topology,
|
|
1341
1295
|
localDevControlSurfacesEnabled
|
|
1342
1296
|
]);
|
|
1343
|
-
const
|
|
1344
|
-
(
|
|
1345
|
-
[
|
|
1346
|
-
);
|
|
1347
|
-
const disconnectSocket = useCallback(
|
|
1348
|
-
(role) => socketManager.disconnect(role),
|
|
1349
|
-
[socketManager]
|
|
1350
|
-
);
|
|
1351
|
-
const contextValue = useMemo(
|
|
1352
|
-
() => ({
|
|
1353
|
-
config,
|
|
1354
|
-
store,
|
|
1355
|
-
socketManager,
|
|
1356
|
-
getSocket,
|
|
1357
|
-
disconnectSocket,
|
|
1358
|
-
inputManager
|
|
1359
|
-
}),
|
|
1360
|
-
[config, store, socketManager, getSocket, disconnectSocket, inputManager]
|
|
1297
|
+
const contextValue = useMemo2(
|
|
1298
|
+
() => ({ config, store }),
|
|
1299
|
+
[config, store]
|
|
1361
1300
|
);
|
|
1362
|
-
return /* @__PURE__ */
|
|
1301
|
+
return /* @__PURE__ */ jsx2(AirJamContext.Provider, { value: contextValue, children });
|
|
1363
1302
|
};
|
|
1364
1303
|
var useAirJamContext = () => {
|
|
1365
|
-
const context =
|
|
1304
|
+
const context = useContext2(AirJamContext);
|
|
1366
1305
|
if (!context) {
|
|
1367
1306
|
throw createAirJamDiagnosticError(
|
|
1368
1307
|
"AJ_MISSING_SESSION_PROVIDER",
|
|
@@ -1374,17 +1313,13 @@ var useAirJamContext = () => {
|
|
|
1374
1313
|
var useAirJamConfig = () => {
|
|
1375
1314
|
return useAirJamContext().config;
|
|
1376
1315
|
};
|
|
1377
|
-
var useAirJamState = (selector) => {
|
|
1378
|
-
const { store } = useAirJamContext();
|
|
1379
|
-
return useStore(store, useShallow(selector));
|
|
1380
|
-
};
|
|
1381
1316
|
|
|
1382
1317
|
// src/context/session-scope.ts
|
|
1383
|
-
import { createContext as
|
|
1384
|
-
var SessionScopeContext =
|
|
1385
|
-
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);
|
|
1386
1321
|
var useSessionScope = () => {
|
|
1387
|
-
return
|
|
1322
|
+
return useContext3(SessionScopeContext);
|
|
1388
1323
|
};
|
|
1389
1324
|
var useAssertSessionScope = (expectedScope, hookName) => {
|
|
1390
1325
|
const scope = useSessionScope();
|
|
@@ -1403,12 +1338,12 @@ var useAssertSessionScope = (expectedScope, hookName) => {
|
|
|
1403
1338
|
);
|
|
1404
1339
|
};
|
|
1405
1340
|
var useClaimSessionRuntimeOwner = (kind, hookName) => {
|
|
1406
|
-
const registry =
|
|
1341
|
+
const registry = useContext3(RuntimeOwnerRegistryContext);
|
|
1407
1342
|
const tokenRef = useRef(null);
|
|
1408
1343
|
if (!tokenRef.current) {
|
|
1409
1344
|
tokenRef.current = /* @__PURE__ */ Symbol(`${kind}:${hookName}`);
|
|
1410
1345
|
}
|
|
1411
|
-
|
|
1346
|
+
useEffect3(() => {
|
|
1412
1347
|
if (!registry) {
|
|
1413
1348
|
return;
|
|
1414
1349
|
}
|
|
@@ -1416,20 +1351,58 @@ var useClaimSessionRuntimeOwner = (kind, hookName) => {
|
|
|
1416
1351
|
}, [registry, kind, hookName]);
|
|
1417
1352
|
};
|
|
1418
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
|
+
|
|
1419
1380
|
export {
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1381
|
+
fixedControllerOrientationContext,
|
|
1382
|
+
hostRuntimeContext,
|
|
1383
|
+
controllerRuntimeContext,
|
|
1384
|
+
declaredStoresContext,
|
|
1385
|
+
PlatformSettingsRuntime,
|
|
1386
|
+
PlatformSettingsBoundary,
|
|
1387
|
+
usePlatformSettings,
|
|
1388
|
+
useOptionalPlatformSettingsOwnerApi,
|
|
1389
|
+
useInheritedPlatformSettings,
|
|
1390
|
+
usePlatformSettingsRuntimeStatus,
|
|
1391
|
+
usePlatformAudioSettings,
|
|
1392
|
+
useResolvedPlatformSettingsSnapshot,
|
|
1424
1393
|
updateDevBrowserLogContext,
|
|
1394
|
+
resolveEnvironmentRuntimeTopology,
|
|
1395
|
+
resolveAirJamConfig,
|
|
1396
|
+
AirJamContext,
|
|
1425
1397
|
AirJamProvider,
|
|
1426
1398
|
useAirJamContext,
|
|
1427
1399
|
useAirJamConfig,
|
|
1428
|
-
useAirJamState,
|
|
1429
1400
|
SessionScopeContext,
|
|
1430
1401
|
RuntimeOwnerRegistryContext,
|
|
1431
1402
|
useSessionScope,
|
|
1432
1403
|
useAssertSessionScope,
|
|
1433
|
-
useClaimSessionRuntimeOwner
|
|
1404
|
+
useClaimSessionRuntimeOwner,
|
|
1405
|
+
readEmbeddedHostChildSession,
|
|
1406
|
+
readEmbeddedControllerChildSession
|
|
1434
1407
|
};
|
|
1435
|
-
//# sourceMappingURL=chunk-
|
|
1408
|
+
//# sourceMappingURL=chunk-TFW4NJW2.js.map
|