@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
package/dist/ui.cjs
CHANGED
|
@@ -31,10 +31,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var ui_exports = {};
|
|
32
32
|
__export(ui_exports, {
|
|
33
33
|
AIRJAM_DEFAULT_AVATAR_SEEDS: () => AIRJAM_DEFAULT_AVATAR_SEEDS,
|
|
34
|
+
AxisButton: () => AxisButton,
|
|
34
35
|
Button: () => Button,
|
|
35
36
|
ConnectionStatusPill: () => ConnectionStatusPill,
|
|
37
|
+
ControlButton: () => ControlButton,
|
|
36
38
|
ControllerPlayerNameField: () => ControllerPlayerNameField,
|
|
37
39
|
ControllerPrimaryAction: () => ControllerPrimaryAction,
|
|
40
|
+
GamepadLayout: () => GamepadLayout,
|
|
38
41
|
HostMuteButton: () => HostMuteButton,
|
|
39
42
|
JoinQrOverlay: () => JoinQrOverlay,
|
|
40
43
|
JoinUrlActionButtons: () => JoinUrlActionButtons,
|
|
@@ -46,12 +49,10 @@ __export(ui_exports, {
|
|
|
46
49
|
RoomQrCode: () => RoomQrCode,
|
|
47
50
|
RuntimeShellHeader: () => RuntimeShellHeader,
|
|
48
51
|
Slider: () => Slider,
|
|
52
|
+
Stick: () => Stick,
|
|
49
53
|
SurfaceViewport: () => SurfaceViewport,
|
|
50
54
|
VolumeControls: () => VolumeControls,
|
|
51
|
-
buttonVariants: () => buttonVariants,
|
|
52
55
|
getDiceBearAdventurerNeutralUrl: () => getDiceBearAdventurerNeutralUrl,
|
|
53
|
-
getPlayerAvatarImageUrl: () => getPlayerAvatarImageUrl,
|
|
54
|
-
resolvePlayerAvatarSeed: () => resolvePlayerAvatarSeed,
|
|
55
56
|
useControllerLifecycleIntents: () => useControllerLifecycleIntents,
|
|
56
57
|
useControllerLifecyclePermissions: () => useControllerLifecyclePermissions,
|
|
57
58
|
useControllerShellStatus: () => useControllerShellStatus,
|
|
@@ -122,9 +123,749 @@ var import_react5 = require("react");
|
|
|
122
123
|
|
|
123
124
|
// src/hooks/use-air-jam-controller.ts
|
|
124
125
|
var import_react4 = require("react");
|
|
125
|
-
var
|
|
126
|
+
var import_zustand2 = require("zustand");
|
|
126
127
|
var import_shallow2 = require("zustand/react/shallow");
|
|
127
128
|
|
|
129
|
+
// src/context/air-jam-context.tsx
|
|
130
|
+
var import_react = require("react");
|
|
131
|
+
var import_zustand = require("zustand");
|
|
132
|
+
var import_shallow = require("zustand/react/shallow");
|
|
133
|
+
|
|
134
|
+
// src/core/connection-store.ts
|
|
135
|
+
var import_vanilla = require("zustand/vanilla");
|
|
136
|
+
|
|
137
|
+
// src/diagnostics.ts
|
|
138
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
139
|
+
var lastEmissionByKey = /* @__PURE__ */ new Map();
|
|
140
|
+
var DIAGNOSTIC_THROTTLE_MS = 1500;
|
|
141
|
+
var diagnosticsEnabledOverride = null;
|
|
142
|
+
var shouldEmitDiagnostics = () => {
|
|
143
|
+
if (diagnosticsEnabledOverride !== null) {
|
|
144
|
+
return diagnosticsEnabledOverride;
|
|
145
|
+
}
|
|
146
|
+
const nodeEnv = globalThis.process?.env?.NODE_ENV;
|
|
147
|
+
if (typeof nodeEnv === "string") {
|
|
148
|
+
return nodeEnv !== "production";
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
};
|
|
152
|
+
var toConsolePrefix = (code) => `[AirJam][${code}]`;
|
|
153
|
+
var emitAirJamDiagnostic = (input) => {
|
|
154
|
+
if (!shouldEmitDiagnostics()) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const now = Date.now();
|
|
158
|
+
const key = `${input.code}|${input.message}`;
|
|
159
|
+
const last = lastEmissionByKey.get(key);
|
|
160
|
+
if (last && now - last < DIAGNOSTIC_THROTTLE_MS) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
lastEmissionByKey.set(key, now);
|
|
164
|
+
const diagnostic = {
|
|
165
|
+
...input,
|
|
166
|
+
timestamp: now
|
|
167
|
+
};
|
|
168
|
+
for (const listener of listeners) {
|
|
169
|
+
listener(diagnostic);
|
|
170
|
+
}
|
|
171
|
+
const logger = input.severity === "error" ? console.error : console.warn;
|
|
172
|
+
if (input.details) {
|
|
173
|
+
logger(`${toConsolePrefix(input.code)} ${input.message}`, input.details);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
logger(`${toConsolePrefix(input.code)} ${input.message}`);
|
|
177
|
+
};
|
|
178
|
+
var createAirJamDiagnosticError = (code, message, details) => {
|
|
179
|
+
emitAirJamDiagnostic({
|
|
180
|
+
code,
|
|
181
|
+
severity: "error",
|
|
182
|
+
message,
|
|
183
|
+
details
|
|
184
|
+
});
|
|
185
|
+
const error = new Error(`${toConsolePrefix(code)} ${message}`);
|
|
186
|
+
Object.defineProperty(error, "code", {
|
|
187
|
+
value: code,
|
|
188
|
+
enumerable: true
|
|
189
|
+
});
|
|
190
|
+
return error;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/protocol/actions.ts
|
|
194
|
+
var import_zod = require("zod");
|
|
195
|
+
var airJamActionPayloadSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.unknown());
|
|
196
|
+
var airJamActionAcceptedSchema = import_zod.z.object({
|
|
197
|
+
ok: import_zod.z.literal(true),
|
|
198
|
+
status: import_zod.z.literal("accepted"),
|
|
199
|
+
source: import_zod.z.enum(["client", "host"]),
|
|
200
|
+
result: import_zod.z.unknown().optional()
|
|
201
|
+
});
|
|
202
|
+
var airJamActionRejectedSchema = import_zod.z.object({
|
|
203
|
+
ok: import_zod.z.literal(false),
|
|
204
|
+
status: import_zod.z.literal("rejected"),
|
|
205
|
+
source: import_zod.z.enum(["client", "server", "host"]),
|
|
206
|
+
reason: import_zod.z.string(),
|
|
207
|
+
message: import_zod.z.string(),
|
|
208
|
+
details: airJamActionPayloadSchema.optional()
|
|
209
|
+
});
|
|
210
|
+
var airJamActionUnconfirmedSchema = import_zod.z.object({
|
|
211
|
+
ok: import_zod.z.literal(false),
|
|
212
|
+
status: import_zod.z.literal("unconfirmed"),
|
|
213
|
+
source: import_zod.z.literal("client")
|
|
214
|
+
});
|
|
215
|
+
var airJamActionInvocationResultSchema = import_zod.z.discriminatedUnion(
|
|
216
|
+
"status",
|
|
217
|
+
[
|
|
218
|
+
airJamActionAcceptedSchema,
|
|
219
|
+
airJamActionRejectedSchema,
|
|
220
|
+
airJamActionUnconfirmedSchema
|
|
221
|
+
]
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
// src/protocol/arcade-platform-actions.ts
|
|
225
|
+
var import_zod2 = require("zod");
|
|
226
|
+
var arcadeBrowserConfirmPayloadSchema = import_zod2.z.object({ epoch: import_zod2.z.number().int().positive().safe() }).strict();
|
|
227
|
+
var arcadeBrowserNavigatePayloadSchema = arcadeBrowserConfirmPayloadSchema.extend({
|
|
228
|
+
direction: import_zod2.z.enum(["up", "down", "left", "right"])
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// src/protocol/controller.ts
|
|
232
|
+
var import_zod3 = require("zod");
|
|
233
|
+
|
|
234
|
+
// src/settings/platform-settings.ts
|
|
235
|
+
var DEFAULT_PLATFORM_SETTINGS = {
|
|
236
|
+
audio: {
|
|
237
|
+
masterVolume: 1,
|
|
238
|
+
musicVolume: 0.8,
|
|
239
|
+
sfxVolume: 1
|
|
240
|
+
},
|
|
241
|
+
accessibility: {
|
|
242
|
+
reducedMotion: false,
|
|
243
|
+
highContrast: false
|
|
244
|
+
},
|
|
245
|
+
feedback: {
|
|
246
|
+
hapticsEnabled: true
|
|
247
|
+
},
|
|
248
|
+
previewControllers: {
|
|
249
|
+
activeOpacity: 1
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var DEFAULT_ROOM_PLATFORM_SETTINGS = {
|
|
253
|
+
audio: DEFAULT_PLATFORM_SETTINGS.audio,
|
|
254
|
+
previewControllers: DEFAULT_PLATFORM_SETTINGS.previewControllers
|
|
255
|
+
};
|
|
256
|
+
var clamp01 = (value) => Math.max(0, Math.min(1, value));
|
|
257
|
+
var getEffectiveAudioVolume = (settings, category) => {
|
|
258
|
+
const categoryVolume = category === "music" ? settings.musicVolume : settings.sfxVolume;
|
|
259
|
+
return clamp01(settings.masterVolume) * clamp01(categoryVolume);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// src/protocol/controller.ts
|
|
263
|
+
var playerProfileSchema = import_zod3.z.object({
|
|
264
|
+
id: import_zod3.z.string(),
|
|
265
|
+
label: import_zod3.z.string(),
|
|
266
|
+
color: import_zod3.z.string().optional(),
|
|
267
|
+
avatarId: import_zod3.z.string().optional()
|
|
268
|
+
});
|
|
269
|
+
var playerProfilePatchSchema = import_zod3.z.object({
|
|
270
|
+
label: import_zod3.z.string().trim().min(1).max(24).optional(),
|
|
271
|
+
avatarId: import_zod3.z.string().trim().min(1).max(48).optional()
|
|
272
|
+
}).strict();
|
|
273
|
+
|
|
274
|
+
// src/protocol/core.ts
|
|
275
|
+
var import_zod4 = require("zod");
|
|
276
|
+
var connectionStatusSchema = import_zod4.z.enum([
|
|
277
|
+
"idle",
|
|
278
|
+
"connecting",
|
|
279
|
+
"connected",
|
|
280
|
+
"disconnected",
|
|
281
|
+
"reconnecting"
|
|
282
|
+
]);
|
|
283
|
+
|
|
284
|
+
// src/protocol/dev-log-events.ts
|
|
285
|
+
var AIRJAM_DEV_LOG_EVENTS = {
|
|
286
|
+
server: {
|
|
287
|
+
started: "server.started",
|
|
288
|
+
startupFailed: "server.startup.failed"
|
|
289
|
+
},
|
|
290
|
+
auth: {
|
|
291
|
+
modeDisabled: "auth.mode.disabled",
|
|
292
|
+
modeMasterKey: "auth.mode.master_key"
|
|
293
|
+
},
|
|
294
|
+
browser: {
|
|
295
|
+
logSessionStarted: "browser.log_session.started",
|
|
296
|
+
logBatchReceived: "browser.log_batch.received",
|
|
297
|
+
console: "browser.console",
|
|
298
|
+
windowError: "browser.window_error",
|
|
299
|
+
unhandledRejection: "browser.unhandled_rejection",
|
|
300
|
+
diagnostic: "browser.diagnostic",
|
|
301
|
+
runtime: "browser.runtime"
|
|
302
|
+
},
|
|
303
|
+
runtime: {
|
|
304
|
+
providerMounted: "runtime.provider.mounted",
|
|
305
|
+
providerUnmounted: "runtime.provider.unmounted",
|
|
306
|
+
windowBeforeUnload: "runtime.window.beforeunload",
|
|
307
|
+
windowPageHide: "runtime.window.pagehide",
|
|
308
|
+
roomStatus: "runtime.room.status",
|
|
309
|
+
hostResetRoomRequested: "runtime.host.reset_room.requested",
|
|
310
|
+
clipCaptureFailed: "runtime.host.clip_capture_failed",
|
|
311
|
+
hostFrameFault: "runtime.host.frame_fault",
|
|
312
|
+
errorReport: "runtime.error_report",
|
|
313
|
+
phaseTransition: "runtime.phase.transition",
|
|
314
|
+
embeddedBridgeRequested: "runtime.embedded_bridge.requested",
|
|
315
|
+
embeddedBridgeRejected: "runtime.embedded_bridge.rejected",
|
|
316
|
+
browserLogSinkFailure: "runtime.browser_log_sink.failure"
|
|
317
|
+
},
|
|
318
|
+
host: {
|
|
319
|
+
stateRestoreDiscarded: "host.state_restore.discarded"
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
var AIRJAM_BROWSER_LOG_EVENT_BY_SOURCE = {
|
|
323
|
+
console: AIRJAM_DEV_LOG_EVENTS.browser.console,
|
|
324
|
+
"window-error": AIRJAM_DEV_LOG_EVENTS.browser.windowError,
|
|
325
|
+
unhandledrejection: AIRJAM_DEV_LOG_EVENTS.browser.unhandledRejection,
|
|
326
|
+
diagnostic: AIRJAM_DEV_LOG_EVENTS.browser.diagnostic,
|
|
327
|
+
runtime: AIRJAM_DEV_LOG_EVENTS.browser.runtime
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/protocol/leased-control.ts
|
|
331
|
+
var import_zod11 = require("zod");
|
|
332
|
+
|
|
333
|
+
// src/protocol/room/addressing.ts
|
|
334
|
+
var import_zod5 = require("zod");
|
|
335
|
+
var roomCodeSchema = import_zod5.z.string().regex(/^[A-Z0-9]{4,8}$/);
|
|
336
|
+
|
|
337
|
+
// src/protocol/room/frames.ts
|
|
338
|
+
var import_zod8 = require("zod");
|
|
339
|
+
|
|
340
|
+
// src/protocol/room/limits.ts
|
|
341
|
+
var import_zod6 = require("zod");
|
|
342
|
+
var MAXIMUM_ROOM_SEATS = 16;
|
|
343
|
+
var count = import_zod6.z.number().int().positive();
|
|
344
|
+
var duration = import_zod6.z.number().int().nonnegative();
|
|
345
|
+
var roomLimitsShape = {
|
|
346
|
+
seats: count.max(MAXIMUM_ROOM_SEATS),
|
|
347
|
+
channels: count,
|
|
348
|
+
/** How often a phone may send its controls; phones coalesce to it. */
|
|
349
|
+
inputIntervalMs: count,
|
|
350
|
+
/** One phone's whole control state; a host input record states its length in one byte. */
|
|
351
|
+
inputBytes: count.max(255),
|
|
352
|
+
inputsPerSecond: count,
|
|
353
|
+
/** The most a channel's document, or any one state frame, may weigh. */
|
|
354
|
+
stateBytes: count,
|
|
355
|
+
statesPerSecond: count,
|
|
356
|
+
/** The most any other text frame may weigh. */
|
|
357
|
+
frameBytes: count,
|
|
358
|
+
/** Text frames other than state, per connection. */
|
|
359
|
+
framesPerSecond: count,
|
|
360
|
+
/** Frames that do not parse, within one second, before the connection is closed. */
|
|
361
|
+
strikesPerSecond: count,
|
|
362
|
+
seatHoldMs: duration,
|
|
363
|
+
/** How long the room waits for its host, as it opens and after the host's connection ends. */
|
|
364
|
+
hostGraceMs: count,
|
|
365
|
+
maximumAgeMs: count
|
|
366
|
+
};
|
|
367
|
+
var roomLimitsSchema = import_zod6.z.strictObject(roomLimitsShape);
|
|
368
|
+
var roomLimitsWireSchema = import_zod6.z.object(roomLimitsShape);
|
|
369
|
+
var DEFAULT_ROOM_LIMITS = Object.freeze({
|
|
370
|
+
seats: MAXIMUM_ROOM_SEATS,
|
|
371
|
+
channels: 8,
|
|
372
|
+
inputIntervalMs: 16,
|
|
373
|
+
inputBytes: 64,
|
|
374
|
+
inputsPerSecond: 120,
|
|
375
|
+
stateBytes: 65536,
|
|
376
|
+
statesPerSecond: 60,
|
|
377
|
+
frameBytes: 8192,
|
|
378
|
+
framesPerSecond: 60,
|
|
379
|
+
strikesPerSecond: 64,
|
|
380
|
+
seatHoldMs: 12e4,
|
|
381
|
+
hostGraceMs: 6e4,
|
|
382
|
+
maximumAgeMs: 24 * 60 * 60 * 1e3
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// src/protocol/room/patch.ts
|
|
386
|
+
var isPlainObject = (value) => {
|
|
387
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
388
|
+
return false;
|
|
389
|
+
const prototype = Object.getPrototypeOf(value);
|
|
390
|
+
return prototype === Object.prototype || prototype === null;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/protocol/room/seat-id.ts
|
|
394
|
+
var import_zod7 = require("zod");
|
|
395
|
+
var seatIdSchema = import_zod7.z.string().regex(/^p[1-9][0-9]{0,4}$/);
|
|
396
|
+
|
|
397
|
+
// src/protocol/room/frames.ts
|
|
398
|
+
var MAXIMUM_FRAME_DEPTH = 32;
|
|
399
|
+
var keySchema = import_zod8.z.string().min(16).max(128);
|
|
400
|
+
var instanceSchema = import_zod8.z.string().min(1).max(64);
|
|
401
|
+
var channelSchema = import_zod8.z.string().min(1).max(128);
|
|
402
|
+
var revisionSchema = import_zod8.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
403
|
+
var requestIdSchema = import_zod8.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
404
|
+
var featuresSchema = import_zod8.z.array(import_zod8.z.string().min(1).max(64)).max(32);
|
|
405
|
+
var documentSchema = import_zod8.z.custom(isPlainObject, {
|
|
406
|
+
message: "A state document is a plain JSON object."
|
|
407
|
+
});
|
|
408
|
+
var pathSchema = import_zod8.z.array(import_zod8.z.string()).min(1).max(32);
|
|
409
|
+
var seatKindSchema = import_zod8.z.enum(["phone", "preview", "agent"]);
|
|
410
|
+
var seatProfileSchema = import_zod8.z.object({
|
|
411
|
+
label: import_zod8.z.string().trim().min(1).max(24).optional(),
|
|
412
|
+
avatarId: import_zod8.z.string().trim().min(1).max(48).optional(),
|
|
413
|
+
/** Shown instead of the label while a local seat plays through this phone. */
|
|
414
|
+
localSeatLabel: import_zod8.z.string().trim().min(1).max(32).optional()
|
|
415
|
+
});
|
|
416
|
+
var helloFields = {
|
|
417
|
+
type: import_zod8.z.literal("hello"),
|
|
418
|
+
key: keySchema,
|
|
419
|
+
instance: instanceSchema.optional(),
|
|
420
|
+
sdk: import_zod8.z.string().min(1).max(64),
|
|
421
|
+
features: featuresSchema.optional()
|
|
422
|
+
};
|
|
423
|
+
var hostHelloSchema = import_zod8.z.object({
|
|
424
|
+
...helloFields,
|
|
425
|
+
/** Opaque to the room; the gate reads it before the room opens. */
|
|
426
|
+
credential: import_zod8.z.string().min(1).max(8192).optional(),
|
|
427
|
+
/** How many players the game takes; the room admits no more. */
|
|
428
|
+
seats: import_zod8.z.number().int().min(1).max(MAXIMUM_ROOM_SEATS)
|
|
429
|
+
});
|
|
430
|
+
var phoneHelloSchema = import_zod8.z.object({
|
|
431
|
+
...helloFields,
|
|
432
|
+
kind: seatKindSchema,
|
|
433
|
+
profile: seatProfileSchema.optional(),
|
|
434
|
+
/**
|
|
435
|
+
* The page this phone runs in, the same across its reconnects. A seat
|
|
436
|
+
* resumed from another page (a reload, or another tab taking it over)
|
|
437
|
+
* starts its controls afresh, so the host takes a new input baseline.
|
|
438
|
+
*/
|
|
439
|
+
page: import_zod8.z.string().min(1).max(64).optional()
|
|
440
|
+
});
|
|
441
|
+
var statePatchFields = {
|
|
442
|
+
type: import_zod8.z.literal("state"),
|
|
443
|
+
channel: channelSchema,
|
|
444
|
+
revision: revisionSchema,
|
|
445
|
+
base: revisionSchema,
|
|
446
|
+
set: import_zod8.z.array(import_zod8.z.tuple([pathSchema, import_zod8.z.unknown()])).default([]),
|
|
447
|
+
unset: import_zod8.z.array(pathSchema).default([])
|
|
448
|
+
};
|
|
449
|
+
var stateDocumentFields = {
|
|
450
|
+
type: import_zod8.z.literal("state"),
|
|
451
|
+
channel: channelSchema,
|
|
452
|
+
revision: revisionSchema,
|
|
453
|
+
document: documentSchema
|
|
454
|
+
};
|
|
455
|
+
var hostStateFrameSchema = import_zod8.z.union([
|
|
456
|
+
import_zod8.z.object({
|
|
457
|
+
...stateDocumentFields,
|
|
458
|
+
/** The store's shape, so a reloading host knows whether to take its state back. */
|
|
459
|
+
fingerprint: import_zod8.z.string().min(1).max(256).optional(),
|
|
460
|
+
/** A top-level field keyed by seat whose entries only their own seat sees. */
|
|
461
|
+
private: import_zod8.z.string().min(1).max(128).optional()
|
|
462
|
+
}),
|
|
463
|
+
import_zod8.z.object(statePatchFields).refine(
|
|
464
|
+
(frame) => frame.revision > frame.base,
|
|
465
|
+
"A patch produces a later revision than its base."
|
|
466
|
+
)
|
|
467
|
+
]);
|
|
468
|
+
var hostToRoomFrameSchemas = {
|
|
469
|
+
state: hostStateFrameSchema,
|
|
470
|
+
response: import_zod8.z.object({
|
|
471
|
+
type: import_zod8.z.literal("response"),
|
|
472
|
+
seat: seatIdSchema,
|
|
473
|
+
id: requestIdSchema,
|
|
474
|
+
result: import_zod8.z.unknown().optional()
|
|
475
|
+
}),
|
|
476
|
+
signal: import_zod8.z.object({
|
|
477
|
+
type: import_zod8.z.literal("signal"),
|
|
478
|
+
seat: seatIdSchema.optional(),
|
|
479
|
+
kind: import_zod8.z.string().min(1).max(64),
|
|
480
|
+
payload: import_zod8.z.unknown().optional()
|
|
481
|
+
}),
|
|
482
|
+
room: import_zod8.z.object({
|
|
483
|
+
type: import_zod8.z.literal("room"),
|
|
484
|
+
seats: import_zod8.z.number().int().min(1).max(MAXIMUM_ROOM_SEATS).optional(),
|
|
485
|
+
locked: import_zod8.z.boolean().optional()
|
|
486
|
+
}),
|
|
487
|
+
remove: import_zod8.z.object({ type: import_zod8.z.literal("remove"), seat: seatIdSchema }),
|
|
488
|
+
drop: import_zod8.z.object({ type: import_zod8.z.literal("drop"), channel: channelSchema }),
|
|
489
|
+
activity: import_zod8.z.object({
|
|
490
|
+
type: import_zod8.z.literal("activity"),
|
|
491
|
+
activity: import_zod8.z.string().min(1).max(128).nullable()
|
|
492
|
+
}),
|
|
493
|
+
end: import_zod8.z.object({ type: import_zod8.z.literal("end") })
|
|
494
|
+
};
|
|
495
|
+
var phoneToRoomFrameSchemas = {
|
|
496
|
+
request: import_zod8.z.object({
|
|
497
|
+
type: import_zod8.z.literal("request"),
|
|
498
|
+
id: requestIdSchema,
|
|
499
|
+
channel: channelSchema,
|
|
500
|
+
name: import_zod8.z.string().min(1).max(128),
|
|
501
|
+
payload: import_zod8.z.unknown().optional()
|
|
502
|
+
}),
|
|
503
|
+
profile: import_zod8.z.object({
|
|
504
|
+
type: import_zod8.z.literal("profile"),
|
|
505
|
+
label: seatProfileSchema.shape.label,
|
|
506
|
+
avatarId: seatProfileSchema.shape.avatarId
|
|
507
|
+
}).refine(
|
|
508
|
+
(frame) => frame.label !== void 0 || frame.avatarId !== void 0,
|
|
509
|
+
"A profile change names a label or an avatar."
|
|
510
|
+
),
|
|
511
|
+
leave: import_zod8.z.object({ type: import_zod8.z.literal("leave") }),
|
|
512
|
+
/** This seat's controls start again from zero, as a newly loaded controller frame's do. */
|
|
513
|
+
baseline: import_zod8.z.object({ type: import_zod8.z.literal("baseline") })
|
|
514
|
+
};
|
|
515
|
+
var seatViewSchema = import_zod8.z.object({
|
|
516
|
+
id: seatIdSchema,
|
|
517
|
+
label: import_zod8.z.string(),
|
|
518
|
+
color: import_zod8.z.string(),
|
|
519
|
+
avatarId: import_zod8.z.string().optional(),
|
|
520
|
+
kind: seatKindSchema,
|
|
521
|
+
connected: import_zod8.z.boolean()
|
|
522
|
+
});
|
|
523
|
+
var channelCopySchema = import_zod8.z.object({
|
|
524
|
+
channel: channelSchema,
|
|
525
|
+
revision: revisionSchema,
|
|
526
|
+
document: documentSchema,
|
|
527
|
+
fingerprint: import_zod8.z.string().optional(),
|
|
528
|
+
private: import_zod8.z.string().optional()
|
|
529
|
+
});
|
|
530
|
+
var welcomeFields = {
|
|
531
|
+
type: import_zod8.z.literal("welcome"),
|
|
532
|
+
code: import_zod8.z.string(),
|
|
533
|
+
instance: instanceSchema,
|
|
534
|
+
seats: import_zod8.z.array(seatViewSchema),
|
|
535
|
+
channels: import_zod8.z.array(channelCopySchema),
|
|
536
|
+
limits: roomLimitsWireSchema,
|
|
537
|
+
features: featuresSchema
|
|
538
|
+
};
|
|
539
|
+
var roomStateFrameSchema = import_zod8.z.union([
|
|
540
|
+
import_zod8.z.object(stateDocumentFields),
|
|
541
|
+
import_zod8.z.object(statePatchFields)
|
|
542
|
+
]);
|
|
543
|
+
var roomToHostFrameSchemas = {
|
|
544
|
+
welcome: import_zod8.z.object({
|
|
545
|
+
...welcomeFields,
|
|
546
|
+
/** Seats the room admits, and whether it admits new players at all. */
|
|
547
|
+
seatsWanted: import_zod8.z.number().int().min(1).max(MAXIMUM_ROOM_SEATS),
|
|
548
|
+
locked: import_zod8.z.boolean(),
|
|
549
|
+
activity: import_zod8.z.string().nullable()
|
|
550
|
+
}),
|
|
551
|
+
wait: import_zod8.z.object({
|
|
552
|
+
type: import_zod8.z.literal("wait"),
|
|
553
|
+
position: import_zod8.z.number().int().positive()
|
|
554
|
+
}),
|
|
555
|
+
seat: import_zod8.z.object({
|
|
556
|
+
type: import_zod8.z.literal("seat"),
|
|
557
|
+
seat: seatViewSchema,
|
|
558
|
+
/** The seat's controls restart from a new page: decode them afresh. */
|
|
559
|
+
inputBaseline: import_zod8.z.literal(true).optional()
|
|
560
|
+
}),
|
|
561
|
+
left: import_zod8.z.object({ type: import_zod8.z.literal("left"), seat: seatIdSchema }),
|
|
562
|
+
need: import_zod8.z.object({ type: import_zod8.z.literal("need"), channel: channelSchema }),
|
|
563
|
+
request: import_zod8.z.object({
|
|
564
|
+
type: import_zod8.z.literal("request"),
|
|
565
|
+
seat: seatIdSchema,
|
|
566
|
+
id: requestIdSchema,
|
|
567
|
+
channel: channelSchema,
|
|
568
|
+
name: import_zod8.z.string(),
|
|
569
|
+
payload: import_zod8.z.unknown().optional()
|
|
570
|
+
})
|
|
571
|
+
};
|
|
572
|
+
var roomToPhoneFrameSchemas = {
|
|
573
|
+
welcome: import_zod8.z.object({
|
|
574
|
+
...welcomeFields,
|
|
575
|
+
seat: seatIdSchema,
|
|
576
|
+
host: import_zod8.z.boolean()
|
|
577
|
+
}),
|
|
578
|
+
seat: roomToHostFrameSchemas.seat,
|
|
579
|
+
left: roomToHostFrameSchemas.left,
|
|
580
|
+
host: import_zod8.z.object({ type: import_zod8.z.literal("host"), present: import_zod8.z.boolean() }),
|
|
581
|
+
state: roomStateFrameSchema,
|
|
582
|
+
drop: hostToRoomFrameSchemas.drop,
|
|
583
|
+
// The refusal comes first: a result may be absent, so the other branch
|
|
584
|
+
// would accept a refusal and strip what it says.
|
|
585
|
+
response: import_zod8.z.union([
|
|
586
|
+
import_zod8.z.object({
|
|
587
|
+
type: import_zod8.z.literal("response"),
|
|
588
|
+
id: requestIdSchema,
|
|
589
|
+
/** The room answered itself because no host could. */
|
|
590
|
+
refused: import_zod8.z.literal("host-away")
|
|
591
|
+
}),
|
|
592
|
+
import_zod8.z.object({
|
|
593
|
+
type: import_zod8.z.literal("response"),
|
|
594
|
+
id: requestIdSchema,
|
|
595
|
+
result: import_zod8.z.unknown().optional()
|
|
596
|
+
})
|
|
597
|
+
]),
|
|
598
|
+
signal: import_zod8.z.object({
|
|
599
|
+
type: import_zod8.z.literal("signal"),
|
|
600
|
+
kind: import_zod8.z.string(),
|
|
601
|
+
payload: import_zod8.z.unknown().optional()
|
|
602
|
+
})
|
|
603
|
+
};
|
|
604
|
+
var nestsWithin = (value, depth) => {
|
|
605
|
+
if (typeof value !== "object" || value === null) return true;
|
|
606
|
+
if (depth === 0) return false;
|
|
607
|
+
for (const child of Object.values(value))
|
|
608
|
+
if (!nestsWithin(child, depth - 1)) return false;
|
|
609
|
+
return true;
|
|
610
|
+
};
|
|
611
|
+
var TOO_DEEP = /* @__PURE__ */ Symbol("too deep");
|
|
612
|
+
var parseJson = (text) => {
|
|
613
|
+
let value;
|
|
614
|
+
try {
|
|
615
|
+
value = JSON.parse(text);
|
|
616
|
+
} catch {
|
|
617
|
+
return void 0;
|
|
618
|
+
}
|
|
619
|
+
return nestsWithin(value, MAXIMUM_FRAME_DEPTH) ? value : TOO_DEEP;
|
|
620
|
+
};
|
|
621
|
+
var readType = (value) => isPlainObject(value) && typeof value.type === "string" ? value.type : null;
|
|
622
|
+
var createFrameParser = (schemas) => (text) => {
|
|
623
|
+
const value = parseJson(text);
|
|
624
|
+
if (value === TOO_DEEP) return { status: "too-deep" };
|
|
625
|
+
const type = readType(value);
|
|
626
|
+
if (type === null) return { status: "invalid" };
|
|
627
|
+
if (!Object.hasOwn(schemas, type)) return { status: "unknown" };
|
|
628
|
+
const parsed = schemas[type].safeParse(value);
|
|
629
|
+
return parsed.success ? { status: "frame", frame: parsed.data } : { status: "invalid" };
|
|
630
|
+
};
|
|
631
|
+
var parseHostToRoomFrame = createFrameParser(hostToRoomFrameSchemas);
|
|
632
|
+
var parsePhoneToRoomFrame = createFrameParser(phoneToRoomFrameSchemas);
|
|
633
|
+
var parseRoomToHostFrame = createFrameParser(roomToHostFrameSchemas);
|
|
634
|
+
var parseRoomToPhoneFrame = createFrameParser(roomToPhoneFrameSchemas);
|
|
635
|
+
var createHelloParser = (schema) => (text) => {
|
|
636
|
+
const parsed = schema.safeParse(parseJson(text));
|
|
637
|
+
return parsed.success ? parsed.data : null;
|
|
638
|
+
};
|
|
639
|
+
var parseHostHello = createHelloParser(hostHelloSchema);
|
|
640
|
+
var parsePhoneHello = createHelloParser(phoneHelloSchema);
|
|
641
|
+
|
|
642
|
+
// src/protocol/room/sdk-channels.ts
|
|
643
|
+
var import_zod9 = require("zod");
|
|
644
|
+
var runtimeStateSchema = import_zod9.z.enum(["paused", "playing"]);
|
|
645
|
+
var controllerOrientationSchema = import_zod9.z.enum(["portrait", "landscape"]);
|
|
646
|
+
var presentationDocumentSchema = import_zod9.z.object({
|
|
647
|
+
runtimeState: runtimeStateSchema,
|
|
648
|
+
orientation: controllerOrientationSchema
|
|
649
|
+
});
|
|
650
|
+
var presentationRequestSchema = import_zod9.z.enum(["pause", "resume"]);
|
|
651
|
+
var hapticSignalPayloadSchema = import_zod9.z.object({
|
|
652
|
+
pattern: import_zod9.z.enum(["light", "medium", "heavy", "success", "failure", "custom"]),
|
|
653
|
+
sequence: import_zod9.z.union([import_zod9.z.number().nonnegative(), import_zod9.z.array(import_zod9.z.number().nonnegative())]).optional()
|
|
654
|
+
});
|
|
655
|
+
var toastSignalPayloadSchema = import_zod9.z.object({
|
|
656
|
+
message: import_zod9.z.string(),
|
|
657
|
+
color: import_zod9.z.string().optional(),
|
|
658
|
+
duration: import_zod9.z.number().nonnegative().optional()
|
|
659
|
+
});
|
|
660
|
+
var soundSignalPayloadSchema = import_zod9.z.object({
|
|
661
|
+
soundId: import_zod9.z.string().min(1),
|
|
662
|
+
volume: import_zod9.z.number().min(0).max(1).optional(),
|
|
663
|
+
loop: import_zod9.z.boolean().optional()
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
// src/runtime/contracts/runtime-identity.ts
|
|
667
|
+
var import_zod10 = require("zod");
|
|
668
|
+
var hostRuntimeIdentitySchema = import_zod10.z.object({
|
|
669
|
+
documentId: import_zod10.z.string().min(1).max(128),
|
|
670
|
+
roomId: roomCodeSchema,
|
|
671
|
+
contractId: import_zod10.z.string().min(1),
|
|
672
|
+
runtimeId: import_zod10.z.string().min(1)
|
|
673
|
+
});
|
|
674
|
+
var hostObservationIdentitySchema = hostRuntimeIdentitySchema.extend({
|
|
675
|
+
surfaceId: import_zod10.z.string().min(1).nullable(),
|
|
676
|
+
participantId: import_zod10.z.string().min(1).nullable().default(null)
|
|
677
|
+
});
|
|
678
|
+
var identityKeys = hostObservationIdentitySchema.keyof().options;
|
|
679
|
+
|
|
680
|
+
// src/protocol/leased-control.ts
|
|
681
|
+
var jsonValueSchema = import_zod11.z.unknown().refine(
|
|
682
|
+
(input) => {
|
|
683
|
+
const pending = [
|
|
684
|
+
{ value: input, depth: 0 }
|
|
685
|
+
];
|
|
686
|
+
for (const current of pending) {
|
|
687
|
+
if (current.depth > 32) return false;
|
|
688
|
+
if (current.value && typeof current.value === "object") {
|
|
689
|
+
for (const value of Object.values(current.value)) {
|
|
690
|
+
if (pending.length >= 4096) return false;
|
|
691
|
+
pending.push({ value, depth: current.depth + 1 });
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return true;
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
error: "Participant JSON exceeds its depth or node budget.",
|
|
699
|
+
abort: true
|
|
700
|
+
}
|
|
701
|
+
).pipe(import_zod11.z.json());
|
|
702
|
+
var PARTICIPANT_INPUT_SCHEMA_BYTES = 32e3;
|
|
703
|
+
var participantInputSchemaDescriptionSchema = import_zod11.z.discriminatedUnion(
|
|
704
|
+
"status",
|
|
705
|
+
[
|
|
706
|
+
import_zod11.z.object({
|
|
707
|
+
status: import_zod11.z.literal("available"),
|
|
708
|
+
schema: import_zod11.z.record(import_zod11.z.string(), jsonValueSchema).refine(
|
|
709
|
+
(schema) => new TextEncoder().encode(JSON.stringify(schema)).byteLength <= PARTICIPANT_INPUT_SCHEMA_BYTES,
|
|
710
|
+
"Input JSON Schema exceeds its byte budget."
|
|
711
|
+
)
|
|
712
|
+
}).strict(),
|
|
713
|
+
import_zod11.z.object({
|
|
714
|
+
status: import_zod11.z.literal("unavailable"),
|
|
715
|
+
reason: import_zod11.z.enum(["not-configured", "not-representable"])
|
|
716
|
+
}).strict()
|
|
717
|
+
]
|
|
718
|
+
);
|
|
719
|
+
var leaseSequenceSchema = import_zod11.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
720
|
+
var deadlineMs = import_zod11.z.number().nonnegative().max(Number.MAX_SAFE_INTEGER).describe(
|
|
721
|
+
"Admission deadline in the observed host's monotonic clock. Derive it from observation.clock.startedAtMs; never use the caller's clock."
|
|
722
|
+
);
|
|
723
|
+
var participantInputOperationSchema = import_zod11.z.object({
|
|
724
|
+
kind: import_zod11.z.literal("input"),
|
|
725
|
+
deadlineMs,
|
|
726
|
+
input: import_zod11.z.record(import_zod11.z.string(), jsonValueSchema),
|
|
727
|
+
ttlMs: import_zod11.z.number().int().min(50).max(2e3)
|
|
728
|
+
}).strict();
|
|
729
|
+
var participantReleaseOperationSchema = import_zod11.z.object({ kind: import_zod11.z.literal("release") }).strict();
|
|
730
|
+
var participantActionOperationSchema = import_zod11.z.object({
|
|
731
|
+
kind: import_zod11.z.literal("action"),
|
|
732
|
+
deadlineMs,
|
|
733
|
+
actionId: import_zod11.z.string().min(1).max(128),
|
|
734
|
+
input: jsonValueSchema.optional()
|
|
735
|
+
}).strict();
|
|
736
|
+
var operationSchema = import_zod11.z.discriminatedUnion("kind", [
|
|
737
|
+
participantInputOperationSchema,
|
|
738
|
+
participantReleaseOperationSchema,
|
|
739
|
+
participantActionOperationSchema
|
|
740
|
+
]);
|
|
741
|
+
var leasedControlRequestSchema = import_zod11.z.object({
|
|
742
|
+
lease: import_zod11.z.object({ id: import_zod11.z.uuid(), sequence: leaseSequenceSchema }).strict(),
|
|
743
|
+
expected: hostObservationIdentitySchema.strict(),
|
|
744
|
+
operation: operationSchema
|
|
745
|
+
}).strict();
|
|
746
|
+
var controllerLeasedControlSchema = leasedControlRequestSchema.extend({
|
|
747
|
+
roomId: roomCodeSchema,
|
|
748
|
+
controllerId: import_zod11.z.string().min(1).max(128)
|
|
749
|
+
}).strict().refine(
|
|
750
|
+
(value) => value.roomId === value.expected.roomId,
|
|
751
|
+
"Participant control must target the observed room."
|
|
752
|
+
);
|
|
753
|
+
var controllerLeasedControlAckSchema = import_zod11.z.discriminatedUnion("status", [
|
|
754
|
+
import_zod11.z.object({
|
|
755
|
+
status: import_zod11.z.literal("applied"),
|
|
756
|
+
leaseId: import_zod11.z.uuid(),
|
|
757
|
+
sequence: leaseSequenceSchema,
|
|
758
|
+
replayed: import_zod11.z.boolean(),
|
|
759
|
+
operation: import_zod11.z.discriminatedUnion("kind", [
|
|
760
|
+
import_zod11.z.object({ kind: import_zod11.z.literal("input") }).strict(),
|
|
761
|
+
import_zod11.z.object({ kind: import_zod11.z.literal("release") }).strict(),
|
|
762
|
+
import_zod11.z.object({
|
|
763
|
+
kind: import_zod11.z.literal("action"),
|
|
764
|
+
result: airJamActionInvocationResultSchema
|
|
765
|
+
}).strict()
|
|
766
|
+
])
|
|
767
|
+
}).strict(),
|
|
768
|
+
import_zod11.z.object({
|
|
769
|
+
status: import_zod11.z.literal("rejected"),
|
|
770
|
+
reason: import_zod11.z.enum([
|
|
771
|
+
"invalid_request",
|
|
772
|
+
"rate_limited",
|
|
773
|
+
"invalid_input",
|
|
774
|
+
"invalid_action",
|
|
775
|
+
"invalid_action_lane",
|
|
776
|
+
"room_not_found",
|
|
777
|
+
"unauthorized",
|
|
778
|
+
"active_host_missing",
|
|
779
|
+
"busy",
|
|
780
|
+
"stale_identity",
|
|
781
|
+
"stale_decision",
|
|
782
|
+
"invalid_deadline",
|
|
783
|
+
"lease_conflict",
|
|
784
|
+
"stale_sequence",
|
|
785
|
+
"sequence_conflict",
|
|
786
|
+
"unsupported"
|
|
787
|
+
])
|
|
788
|
+
}).strict(),
|
|
789
|
+
import_zod11.z.object({
|
|
790
|
+
status: import_zod11.z.literal("unconfirmed"),
|
|
791
|
+
reason: import_zod11.z.enum([
|
|
792
|
+
"host_ack_unavailable",
|
|
793
|
+
"transport_ack_unavailable",
|
|
794
|
+
"runtime_replaced",
|
|
795
|
+
"invalid_acknowledgement",
|
|
796
|
+
"runtime_unavailable"
|
|
797
|
+
])
|
|
798
|
+
}).strict()
|
|
799
|
+
]);
|
|
800
|
+
|
|
801
|
+
// src/protocol/runtime-reporting.ts
|
|
802
|
+
var import_zod12 = require("zod");
|
|
803
|
+
var AIRJAM_RUNTIME_ERROR_REPORT_CONTRACT_VERSION = 2;
|
|
804
|
+
var runtimeErrorReportSchema = import_zod12.z.object({
|
|
805
|
+
contractVersion: import_zod12.z.literal(AIRJAM_RUNTIME_ERROR_REPORT_CONTRACT_VERSION),
|
|
806
|
+
reportId: import_zod12.z.uuid(),
|
|
807
|
+
roomId: roomCodeSchema,
|
|
808
|
+
instance: import_zod12.z.string().min(1).max(64),
|
|
809
|
+
role: import_zod12.z.enum(["host", "controller"]),
|
|
810
|
+
seat: seatIdSchema.optional(),
|
|
811
|
+
code: import_zod12.z.literal("AJ_RUNTIME_RENDER_CRASH"),
|
|
812
|
+
errorName: import_zod12.z.string().trim().min(1).max(80).regex(/^[A-Za-z][A-Za-z0-9._-]*$/u),
|
|
813
|
+
digest: import_zod12.z.string().regex(/^[a-f0-9]{8}$/u),
|
|
814
|
+
occurredAt: import_zod12.z.iso.datetime()
|
|
815
|
+
}).strict();
|
|
816
|
+
var RUNTIME_ERROR_REPORT_RETRY_DELAYS_MS = [1e3, 2e3, 4e3];
|
|
817
|
+
var createRuntimeErrorReporter = ({
|
|
818
|
+
endpoint,
|
|
819
|
+
credentials
|
|
820
|
+
}) => {
|
|
821
|
+
return (report) => {
|
|
822
|
+
const body = JSON.stringify(report);
|
|
823
|
+
const send = async (retries) => {
|
|
824
|
+
const response = await fetch(endpoint, {
|
|
825
|
+
method: "POST",
|
|
826
|
+
headers: { "content-type": "application/json" },
|
|
827
|
+
body,
|
|
828
|
+
credentials,
|
|
829
|
+
keepalive: true
|
|
830
|
+
}).catch(() => null);
|
|
831
|
+
const [delay, ...later] = retries;
|
|
832
|
+
if (response?.status !== 404 || delay === void 0) return;
|
|
833
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
834
|
+
await send(later);
|
|
835
|
+
};
|
|
836
|
+
void send(RUNTIME_ERROR_REPORT_RETRY_DELAYS_MS);
|
|
837
|
+
};
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
// src/protocol/signed-envelope.ts
|
|
841
|
+
var encoder = new TextEncoder();
|
|
842
|
+
var decoder = new TextDecoder();
|
|
843
|
+
|
|
844
|
+
// src/protocol/url-policy.ts
|
|
845
|
+
var import_zod13 = require("zod");
|
|
846
|
+
var ALLOWED_RUNTIME_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
847
|
+
var parseRuntimeUrl = (value) => {
|
|
848
|
+
try {
|
|
849
|
+
const parsed = new URL(value);
|
|
850
|
+
if (!ALLOWED_RUNTIME_PROTOCOLS.has(parsed.protocol)) {
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
853
|
+
if (parsed.username || parsed.password) {
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
856
|
+
return parsed;
|
|
857
|
+
} catch {
|
|
858
|
+
return null;
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
var normalizeRuntimeUrl = (value) => {
|
|
862
|
+
const parsed = parseRuntimeUrl(value);
|
|
863
|
+
return parsed ? parsed.toString() : null;
|
|
864
|
+
};
|
|
865
|
+
var runtimeUrlSchema = import_zod13.z.string().trim().min(1).refine((value) => parseRuntimeUrl(value) !== null, {
|
|
866
|
+
message: "URL must be a valid http(s) URL without embedded credentials."
|
|
867
|
+
});
|
|
868
|
+
|
|
128
869
|
// src/runtime-topology.ts
|
|
129
870
|
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
130
871
|
"standalone-dev",
|
|
@@ -369,405 +1110,673 @@ var parseRuntimeTopologyFromSearchParams = (params) => {
|
|
|
369
1110
|
});
|
|
370
1111
|
};
|
|
371
1112
|
|
|
372
|
-
// src/
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
1113
|
+
// src/runtime/embedded-parent.ts
|
|
1114
|
+
function embeddedRuntimeParent(topology) {
|
|
1115
|
+
if (typeof window === "undefined" || window.parent === window || !topology.embedded)
|
|
1116
|
+
return null;
|
|
1117
|
+
if (!topology.embedParentOrigin)
|
|
1118
|
+
throw new Error("An embedded runtime requires its declared parent origin.");
|
|
1119
|
+
return {
|
|
1120
|
+
window: window.parent,
|
|
1121
|
+
origin: new URL(topology.embedParentOrigin).origin
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
376
1124
|
|
|
377
|
-
// src/
|
|
378
|
-
var
|
|
379
|
-
var
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
1125
|
+
// src/core/hosted-rooms.ts
|
|
1126
|
+
var AIR_JAM_HOSTED_RUNTIME_ERRORS_ENDPOINT = "https://airjam.io/api/airjam/runtime-errors";
|
|
1127
|
+
var hostedRuntimeErrorReporter = createRuntimeErrorReporter({
|
|
1128
|
+
endpoint: AIR_JAM_HOSTED_RUNTIME_ERRORS_ENDPOINT,
|
|
1129
|
+
credentials: "omit"
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
// src/runtime/browser-replay.ts
|
|
1133
|
+
var import_zod24 = require("zod");
|
|
1134
|
+
|
|
1135
|
+
// src/core/input-log.ts
|
|
1136
|
+
var import_zod15 = require("zod");
|
|
1137
|
+
|
|
1138
|
+
// src/core/settings.ts
|
|
1139
|
+
var import_zod14 = require("zod");
|
|
1140
|
+
var common = {
|
|
1141
|
+
live: import_zod14.z.boolean().default(false),
|
|
1142
|
+
description: import_zod14.z.string().min(1).optional()
|
|
1143
|
+
};
|
|
1144
|
+
var numberSettingSchema = import_zod14.z.object({
|
|
1145
|
+
kind: import_zod14.z.literal("number"),
|
|
1146
|
+
default: import_zod14.z.number().finite(),
|
|
1147
|
+
min: import_zod14.z.number().finite(),
|
|
1148
|
+
max: import_zod14.z.number().finite(),
|
|
1149
|
+
step: import_zod14.z.number().finite().positive().optional(),
|
|
1150
|
+
...common
|
|
1151
|
+
}).strict();
|
|
1152
|
+
var booleanSettingSchema = import_zod14.z.object({
|
|
1153
|
+
kind: import_zod14.z.literal("boolean"),
|
|
1154
|
+
default: import_zod14.z.boolean(),
|
|
1155
|
+
...common
|
|
1156
|
+
}).strict();
|
|
1157
|
+
var choiceSettingSchema = import_zod14.z.object({
|
|
1158
|
+
kind: import_zod14.z.literal("choice"),
|
|
1159
|
+
options: import_zod14.z.array(import_zod14.z.string().min(1)).nonempty(),
|
|
1160
|
+
default: import_zod14.z.string(),
|
|
1161
|
+
...common
|
|
1162
|
+
}).strict();
|
|
1163
|
+
var airJamSettingSchema = import_zod14.z.discriminatedUnion("kind", [
|
|
1164
|
+
numberSettingSchema,
|
|
1165
|
+
booleanSettingSchema,
|
|
1166
|
+
choiceSettingSchema
|
|
1167
|
+
]);
|
|
1168
|
+
var airJamSettingsValuesSchema = import_zod14.z.record(
|
|
1169
|
+
import_zod14.z.string(),
|
|
1170
|
+
import_zod14.z.union([import_zod14.z.number().finite(), import_zod14.z.boolean(), import_zod14.z.string()])
|
|
1171
|
+
);
|
|
1172
|
+
|
|
1173
|
+
// src/core/input-log.ts
|
|
1174
|
+
var AIR_JAM_INPUT_LOG_EVENTS = [
|
|
1175
|
+
"seat",
|
|
1176
|
+
"left",
|
|
1177
|
+
"input",
|
|
1178
|
+
"runtime",
|
|
1179
|
+
"action",
|
|
1180
|
+
"settings"
|
|
1181
|
+
];
|
|
1182
|
+
var inputLogEntrySchema = import_zod15.z.object({
|
|
1183
|
+
/** The step the event reached the game before. */
|
|
1184
|
+
tick: import_zod15.z.number().int().positive(),
|
|
1185
|
+
event: import_zod15.z.enum(AIR_JAM_INPUT_LOG_EVENTS),
|
|
1186
|
+
payload: import_zod15.z.record(import_zod15.z.string(), import_zod15.z.unknown())
|
|
1187
|
+
}).strict();
|
|
1188
|
+
var airJamInputLogSchema = import_zod15.z.object({
|
|
1189
|
+
version: import_zod15.z.literal(3),
|
|
1190
|
+
settings: airJamSettingsValuesSchema,
|
|
1191
|
+
seed: import_zod15.z.number().int().min(0).max(4294967295),
|
|
1192
|
+
stepMs: import_zod15.z.number().positive(),
|
|
1193
|
+
/** Steps the recorded host took. */
|
|
1194
|
+
ticks: import_zod15.z.number().int().nonnegative(),
|
|
1195
|
+
/** The store domain of stores that declare none, so actions find their store again. */
|
|
1196
|
+
storeDomain: import_zod15.z.string().min(1),
|
|
1197
|
+
entries: import_zod15.z.array(inputLogEntrySchema)
|
|
1198
|
+
}).strict();
|
|
1199
|
+
var AIR_JAM_INPUT_LOG_MAX_GAME_MS = 30 * 60 * 1e3;
|
|
1200
|
+
var AIR_JAM_INPUT_LOG_MAX_ENTRY_BYTES = 16 * 1024 * 1024;
|
|
1201
|
+
|
|
1202
|
+
// src/core/replay-input-log.ts
|
|
1203
|
+
var import_zod23 = require("zod");
|
|
1204
|
+
|
|
1205
|
+
// src/runtime/contracts/control.ts
|
|
1206
|
+
var import_nanoid2 = require("nanoid");
|
|
1207
|
+
var import_zod22 = require("zod");
|
|
1208
|
+
|
|
1209
|
+
// src/agent/agent-evaluator.ts
|
|
1210
|
+
var import_zod16 = require("zod");
|
|
1211
|
+
|
|
1212
|
+
// src/utils/is-rpc-serializable.ts
|
|
1213
|
+
var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
1214
|
+
if (value === null || value === void 0) {
|
|
1215
|
+
return true;
|
|
385
1216
|
}
|
|
386
|
-
const
|
|
387
|
-
if (
|
|
388
|
-
return
|
|
1217
|
+
const valueType = typeof value;
|
|
1218
|
+
if (valueType === "string" || valueType === "boolean") {
|
|
1219
|
+
return true;
|
|
389
1220
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
var toConsolePrefix = (code) => `[AirJam][${code}]`;
|
|
393
|
-
var emitAirJamDiagnostic = (input) => {
|
|
394
|
-
if (!shouldEmitDiagnostics()) {
|
|
395
|
-
return;
|
|
1221
|
+
if (valueType === "number") {
|
|
1222
|
+
return Number.isFinite(value);
|
|
396
1223
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
const last = lastEmissionByKey.get(key);
|
|
400
|
-
if (last && now - last < DIAGNOSTIC_THROTTLE_MS) {
|
|
401
|
-
return;
|
|
1224
|
+
if (valueType === "function" || valueType === "symbol" || valueType === "bigint") {
|
|
1225
|
+
return false;
|
|
402
1226
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
...input,
|
|
406
|
-
timestamp: now
|
|
407
|
-
};
|
|
408
|
-
for (const listener of listeners) {
|
|
409
|
-
listener(diagnostic);
|
|
1227
|
+
if (valueType !== "object") {
|
|
1228
|
+
return false;
|
|
410
1229
|
}
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
|
|
414
|
-
|
|
1230
|
+
const objectValue = value;
|
|
1231
|
+
if (seen.has(objectValue)) {
|
|
1232
|
+
return false;
|
|
1233
|
+
}
|
|
1234
|
+
seen.add(objectValue);
|
|
1235
|
+
try {
|
|
1236
|
+
if (objectValue instanceof Date) return true;
|
|
1237
|
+
if (Array.isArray(objectValue))
|
|
1238
|
+
return objectValue.every((entry) => isRpcSerializable(entry, seen));
|
|
1239
|
+
const prototype = Object.getPrototypeOf(objectValue);
|
|
1240
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
1241
|
+
return Object.values(objectValue).every(
|
|
1242
|
+
(entry) => isRpcSerializable(entry, seen)
|
|
1243
|
+
);
|
|
1244
|
+
} finally {
|
|
1245
|
+
seen.delete(objectValue);
|
|
415
1246
|
}
|
|
416
|
-
logger(`${toConsolePrefix(input.code)} ${input.message}`);
|
|
417
|
-
};
|
|
418
|
-
var createAirJamDiagnosticError = (code, message, details) => {
|
|
419
|
-
emitAirJamDiagnostic({
|
|
420
|
-
code,
|
|
421
|
-
severity: "error",
|
|
422
|
-
message,
|
|
423
|
-
details
|
|
424
|
-
});
|
|
425
|
-
const error = new Error(`${toConsolePrefix(code)} ${message}`);
|
|
426
|
-
Object.defineProperty(error, "code", {
|
|
427
|
-
value: code,
|
|
428
|
-
enumerable: true
|
|
429
|
-
});
|
|
430
|
-
return error;
|
|
431
1247
|
};
|
|
432
1248
|
|
|
433
|
-
// src/
|
|
434
|
-
var
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
1249
|
+
// src/agent/agent-evaluator.ts
|
|
1250
|
+
var agentActionDescriptorSchema = import_zod16.z.object({
|
|
1251
|
+
actionId: import_zod16.z.string().min(1),
|
|
1252
|
+
target: import_zod16.z.object({
|
|
1253
|
+
kind: import_zod16.z.enum(["participant", "host"]),
|
|
1254
|
+
actionName: import_zod16.z.string().min(1),
|
|
1255
|
+
storeDomain: import_zod16.z.string().min(1)
|
|
1256
|
+
}),
|
|
1257
|
+
description: import_zod16.z.string().nullable(),
|
|
1258
|
+
availability: import_zod16.z.string().nullable(),
|
|
1259
|
+
payload: import_zod16.z.object({
|
|
1260
|
+
kind: import_zod16.z.enum(["none", "boolean", "number", "string", "enum", "json"]),
|
|
1261
|
+
description: import_zod16.z.string().nullable(),
|
|
1262
|
+
allowedValues: import_zod16.z.array(import_zod16.z.string()).optional()
|
|
1263
|
+
}),
|
|
1264
|
+
resultDescription: import_zod16.z.string().nullable()
|
|
445
1265
|
});
|
|
446
|
-
var
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
state: import_zod2.z.object({
|
|
451
|
-
orientation: controllerOrientationSchema.optional(),
|
|
452
|
-
message: import_zod2.z.string().optional(),
|
|
453
|
-
roomSettings: import_zod2.z.object({
|
|
454
|
-
audio: import_zod2.z.object({
|
|
455
|
-
masterVolume: import_zod2.z.number().min(0).max(1),
|
|
456
|
-
musicVolume: import_zod2.z.number().min(0).max(1),
|
|
457
|
-
sfxVolume: import_zod2.z.number().min(0).max(1)
|
|
458
|
-
}),
|
|
459
|
-
previewControllers: import_zod2.z.object({
|
|
460
|
-
activeOpacity: import_zod2.z.number().min(0).max(1)
|
|
461
|
-
})
|
|
462
|
-
}).optional(),
|
|
463
|
-
runtimeState: import_zod2.z.enum(["paused", "playing"]).optional(),
|
|
464
|
-
stateVersion: import_zod2.z.number().int().nonnegative().optional()
|
|
465
|
-
})
|
|
1266
|
+
var agentContractDescriptionSchema = import_zod16.z.object({
|
|
1267
|
+
snapshotStoreDomains: import_zod16.z.array(import_zod16.z.string().min(1)),
|
|
1268
|
+
snapshotDescription: import_zod16.z.string().nullable(),
|
|
1269
|
+
actions: import_zod16.z.array(agentActionDescriptorSchema)
|
|
466
1270
|
});
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
var
|
|
481
|
-
roomId: roomCodeSchema,
|
|
482
|
-
controllerId: import_zod2.z.string().min(3)
|
|
483
|
-
});
|
|
484
|
-
var controllerSystemSchema = import_zod2.z.object({
|
|
1271
|
+
|
|
1272
|
+
// src/runtime/host-observation.ts
|
|
1273
|
+
var import_nanoid = require("nanoid");
|
|
1274
|
+
|
|
1275
|
+
// src/runtime/contracts/observation.ts
|
|
1276
|
+
var import_zod17 = require("zod");
|
|
1277
|
+
var HOST_OBSERVATION_IMAGE_BYTES = 64e4;
|
|
1278
|
+
var jsonObject = import_zod17.z.record(import_zod17.z.string(), import_zod17.z.unknown()).refine(
|
|
1279
|
+
(value) => isRpcSerializable(value) && new TextEncoder().encode(JSON.stringify(value)).byteLength <= 128e3,
|
|
1280
|
+
{
|
|
1281
|
+
message: "Observations require serializable JSON within the 128 KB state budget."
|
|
1282
|
+
}
|
|
1283
|
+
);
|
|
1284
|
+
var hostObservationRequestSchema = import_zod17.z.object({
|
|
485
1285
|
roomId: roomCodeSchema,
|
|
486
|
-
|
|
1286
|
+
controllerId: import_zod17.z.string().min(1).max(128).nullable(),
|
|
1287
|
+
scope: import_zod17.z.enum(["player", "diagnostic"]),
|
|
1288
|
+
includeImage: import_zod17.z.boolean(),
|
|
1289
|
+
expected: hostObservationIdentitySchema.optional()
|
|
1290
|
+
}).strict();
|
|
1291
|
+
var hostObservationImageSchema = import_zod17.z.object({
|
|
1292
|
+
mimeType: import_zod17.z.enum(["image/jpeg", "image/png", "image/webp"]),
|
|
1293
|
+
data: import_zod17.z.string().min(4).max(Math.ceil(HOST_OBSERVATION_IMAGE_BYTES / 3) * 4).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(
|
|
1294
|
+
(value) => value.length % 4 === 0 && value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0) <= HOST_OBSERVATION_IMAGE_BYTES,
|
|
1295
|
+
"Observation image exceeds its byte budget or is invalid base64."
|
|
1296
|
+
),
|
|
1297
|
+
width: import_zod17.z.number().int().positive().max(4096),
|
|
1298
|
+
height: import_zod17.z.number().int().positive().max(4096),
|
|
1299
|
+
coverage: import_zod17.z.enum(["render-surface", "host-document", "controller-view"])
|
|
1300
|
+
}).strict();
|
|
1301
|
+
var storeRevision = import_zod17.z.object({
|
|
1302
|
+
storeDomain: import_zod17.z.string().min(1),
|
|
1303
|
+
revision: import_zod17.z.number().int().nonnegative()
|
|
487
1304
|
});
|
|
488
|
-
var
|
|
489
|
-
|
|
490
|
-
|
|
1305
|
+
var hostRuntimeFaultSchema = import_zod17.z.object({
|
|
1306
|
+
name: import_zod17.z.string().max(128),
|
|
1307
|
+
message: import_zod17.z.string().max(2048),
|
|
1308
|
+
source: import_zod17.z.object({
|
|
1309
|
+
file: import_zod17.z.string().max(2048),
|
|
1310
|
+
line: import_zod17.z.number().int().positive(),
|
|
1311
|
+
column: import_zod17.z.number().int().positive()
|
|
1312
|
+
}).strict().nullable(),
|
|
1313
|
+
stack: import_zod17.z.string().max(8192)
|
|
491
1314
|
}).strict();
|
|
492
|
-
var
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}).
|
|
497
|
-
|
|
498
|
-
|
|
1315
|
+
var hostObservationPresentationSchema = import_zod17.z.object({
|
|
1316
|
+
runtimeState: runtimeStateSchema,
|
|
1317
|
+
connectionStatus: connectionStatusSchema,
|
|
1318
|
+
fault: hostRuntimeFaultSchema.nullable().optional()
|
|
1319
|
+
}).strict();
|
|
1320
|
+
var hostObservationClockSchema = import_zod17.z.object({
|
|
1321
|
+
startedAtMs: import_zod17.z.number().nonnegative(),
|
|
1322
|
+
finishedAtMs: import_zod17.z.number().nonnegative()
|
|
1323
|
+
}).strict().refine(
|
|
1324
|
+
(value) => value.finishedAtMs >= value.startedAtMs,
|
|
1325
|
+
"The host clock must advance monotonically."
|
|
499
1326
|
);
|
|
500
|
-
var
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
1327
|
+
var hostObservationSchema = import_zod17.z.object({
|
|
1328
|
+
version: import_zod17.z.literal(1),
|
|
1329
|
+
id: import_zod17.z.string().min(1),
|
|
1330
|
+
identity: hostObservationIdentitySchema,
|
|
1331
|
+
sequence: import_zod17.z.number().int().positive(),
|
|
1332
|
+
scope: import_zod17.z.enum(["player", "diagnostic"]),
|
|
1333
|
+
controllerId: import_zod17.z.string().nullable(),
|
|
1334
|
+
host: import_zod17.z.object({
|
|
1335
|
+
before: hostObservationPresentationSchema.nullable(),
|
|
1336
|
+
after: hostObservationPresentationSchema.nullable()
|
|
1337
|
+
}).optional(),
|
|
1338
|
+
actions: import_zod17.z.array(agentActionDescriptorSchema).optional(),
|
|
1339
|
+
capabilities: import_zod17.z.object({
|
|
1340
|
+
participantControl: import_zod17.z.object({
|
|
1341
|
+
input: import_zod17.z.literal(1).optional(),
|
|
1342
|
+
inputSchema: participantInputSchemaDescriptionSchema.optional(),
|
|
1343
|
+
actions: import_zod17.z.literal(1).optional()
|
|
1344
|
+
}).optional()
|
|
1345
|
+
}).optional(),
|
|
1346
|
+
capturedAt: import_zod17.z.iso.datetime(),
|
|
1347
|
+
clock: hostObservationClockSchema.optional(),
|
|
1348
|
+
/** The page's slowest fixed-step simulation against real time, since it started. */
|
|
1349
|
+
pace: import_zod17.z.object({
|
|
1350
|
+
frames: import_zod17.z.number().int().nonnegative(),
|
|
1351
|
+
wallMs: import_zod17.z.number().nonnegative(),
|
|
1352
|
+
simulatedMs: import_zod17.z.number().nonnegative()
|
|
1353
|
+
}).strict().optional(),
|
|
1354
|
+
durationMs: import_zod17.z.number().nonnegative(),
|
|
1355
|
+
snapshot: jsonObject,
|
|
1356
|
+
runtime: jsonObject.nullable(),
|
|
1357
|
+
ticks: import_zod17.z.object({
|
|
1358
|
+
before: import_zod17.z.number().int().nonnegative().nullable(),
|
|
1359
|
+
after: import_zod17.z.number().int().nonnegative().nullable()
|
|
1360
|
+
}),
|
|
1361
|
+
stores: import_zod17.z.object({
|
|
1362
|
+
before: import_zod17.z.array(storeRevision),
|
|
1363
|
+
after: import_zod17.z.array(storeRevision)
|
|
1364
|
+
}),
|
|
1365
|
+
visual: import_zod17.z.discriminatedUnion("status", [
|
|
1366
|
+
import_zod17.z.object({
|
|
1367
|
+
status: import_zod17.z.literal("captured"),
|
|
1368
|
+
image: hostObservationImageSchema
|
|
1369
|
+
}),
|
|
1370
|
+
import_zod17.z.object({
|
|
1371
|
+
status: import_zod17.z.literal("unavailable"),
|
|
1372
|
+
reason: import_zod17.z.enum([
|
|
1373
|
+
"not-requested",
|
|
1374
|
+
"unsupported",
|
|
1375
|
+
"surface-unavailable",
|
|
1376
|
+
"timeout"
|
|
1377
|
+
]),
|
|
1378
|
+
detail: import_zod17.z.string().max(1024).optional()
|
|
1379
|
+
})
|
|
1380
|
+
])
|
|
509
1381
|
});
|
|
510
1382
|
|
|
511
|
-
// src/
|
|
512
|
-
var
|
|
513
|
-
server: {
|
|
514
|
-
started: "server.started",
|
|
515
|
-
startupFailed: "server.startup.failed"
|
|
516
|
-
},
|
|
517
|
-
socket: {
|
|
518
|
-
connected: "socket.connected",
|
|
519
|
-
disconnected: "socket.disconnected"
|
|
520
|
-
},
|
|
521
|
-
auth: {
|
|
522
|
-
modeDisabled: "auth.mode.disabled",
|
|
523
|
-
modeMasterKey: "auth.mode.master_key",
|
|
524
|
-
modeDatabaseAndHostGrant: "auth.mode.database_and_host_grant",
|
|
525
|
-
modeDatabase: "auth.mode.database",
|
|
526
|
-
modeHostGrantOnly: "auth.mode.host_grant_only",
|
|
527
|
-
backendMissing: "auth.backend.missing",
|
|
528
|
-
appIdLastUsedAtUpdateFailed: "auth.app_id_last_used_at_update.failed",
|
|
529
|
-
appIdVerificationDatabaseError: "auth.app_id_verification.database_error"
|
|
530
|
-
},
|
|
531
|
-
browser: {
|
|
532
|
-
logSessionStarted: "browser.log_session.started",
|
|
533
|
-
logBatchReceived: "browser.log_batch.received",
|
|
534
|
-
console: "browser.console",
|
|
535
|
-
windowError: "browser.window_error",
|
|
536
|
-
unhandledRejection: "browser.unhandled_rejection",
|
|
537
|
-
diagnostic: "browser.diagnostic",
|
|
538
|
-
runtime: "browser.runtime"
|
|
539
|
-
},
|
|
540
|
-
runtime: {
|
|
541
|
-
providerMounted: "runtime.provider.mounted",
|
|
542
|
-
providerUnmounted: "runtime.provider.unmounted",
|
|
543
|
-
windowBeforeUnload: "runtime.window.beforeunload",
|
|
544
|
-
windowPageHide: "runtime.window.pagehide",
|
|
545
|
-
socketConnected: "runtime.socket.connected",
|
|
546
|
-
socketDisconnected: "runtime.socket.disconnected",
|
|
547
|
-
socketConnectError: "runtime.socket.connect_error",
|
|
548
|
-
hostCreateRoomRequested: "runtime.host.create_room.requested",
|
|
549
|
-
hostReconnectRequested: "runtime.host.reconnect.requested",
|
|
550
|
-
hostReconnectRetryScheduled: "runtime.host.reconnect.retry_scheduled",
|
|
551
|
-
hostResetRoomRequested: "runtime.host.reset_room.requested",
|
|
552
|
-
hostStateReceived: "runtime.host.state.received",
|
|
553
|
-
controllerJoinRequested: "runtime.controller.join.requested",
|
|
554
|
-
controllerStateReceived: "runtime.controller.state.received",
|
|
555
|
-
phaseTransition: "runtime.phase.transition",
|
|
556
|
-
stateVersionReceived: "runtime.state_version.received",
|
|
557
|
-
invariantViolation: "runtime.invariant.violation",
|
|
558
|
-
embeddedBridgeRequested: "runtime.embedded_bridge.requested",
|
|
559
|
-
embeddedBridgeAttached: "runtime.embedded_bridge.attached",
|
|
560
|
-
embeddedBridgeRejected: "runtime.embedded_bridge.rejected",
|
|
561
|
-
embeddedBridgeClosed: "runtime.embedded_bridge.closed",
|
|
562
|
-
browserLogSinkFailure: "runtime.browser_log_sink.failure"
|
|
563
|
-
},
|
|
564
|
-
host: {
|
|
565
|
-
lifecycleRejected: "host.lifecycle.rejected",
|
|
566
|
-
bootstrapVerified: "host.bootstrap.verified",
|
|
567
|
-
bootstrapRejected: "host.bootstrap.rejected",
|
|
568
|
-
disconnectPendingRoomClose: "host.disconnect.pending_room_close",
|
|
569
|
-
disconnectRoomClosed: "host.disconnect.room_closed",
|
|
570
|
-
registerSystemAccepted: "host.register_system.accepted",
|
|
571
|
-
registerSystemRejected: "host.register_system.rejected",
|
|
572
|
-
createRoomAccepted: "host.create_room.accepted",
|
|
573
|
-
createRoomRejected: "host.create_room.rejected",
|
|
574
|
-
reconnectAccepted: "host.reconnect.accepted",
|
|
575
|
-
reconnectRejected: "host.reconnect.rejected",
|
|
576
|
-
resetRoomAccepted: "host.reset_room.accepted",
|
|
577
|
-
resetRoomRejected: "host.reset_room.rejected",
|
|
578
|
-
systemAccepted: "host.system.accepted",
|
|
579
|
-
systemRejected: "host.system.rejected",
|
|
580
|
-
stateRejected: "host.state.rejected",
|
|
581
|
-
signalRejected: "host.signal.rejected",
|
|
582
|
-
playSoundRejected: "host.play_sound.rejected",
|
|
583
|
-
stateBroadcastSummary: "host.state_broadcast.summary",
|
|
584
|
-
reconnectStateReconcile: "host.reconnect.state_reconcile",
|
|
585
|
-
stateSyncSummary: "host.state_sync.summary",
|
|
586
|
-
stateSyncRejected: "host.state_sync.rejected"
|
|
587
|
-
},
|
|
588
|
-
controller: {
|
|
589
|
-
joinAccepted: "controller.join.accepted",
|
|
590
|
-
joinRejected: "controller.join.rejected",
|
|
591
|
-
resumeAccepted: "controller.resume.accepted",
|
|
592
|
-
disconnectPendingResume: "controller.disconnect.pending_resume",
|
|
593
|
-
disconnectLeaseExpired: "controller.disconnect.lease_expired",
|
|
594
|
-
disconnectApplied: "controller.disconnect.applied",
|
|
595
|
-
profileUpdateAccepted: "controller.profile_update.accepted",
|
|
596
|
-
profileUpdateRejected: "controller.profile_update.rejected",
|
|
597
|
-
leaveAccepted: "controller.leave.accepted",
|
|
598
|
-
leaveRejected: "controller.leave.rejected",
|
|
599
|
-
inputSummary: "controller.input.summary",
|
|
600
|
-
inputDroppedSummary: "controller.input_dropped.summary",
|
|
601
|
-
inputRejected: "controller.input.rejected",
|
|
602
|
-
systemAccepted: "controller.system.accepted",
|
|
603
|
-
systemRejected: "controller.system.rejected",
|
|
604
|
-
playSoundRejected: "controller.play_sound.rejected",
|
|
605
|
-
actionRpcSummary: "controller.action_rpc.summary",
|
|
606
|
-
actionRpcRejected: "controller.action_rpc.rejected"
|
|
607
|
-
},
|
|
608
|
-
system: {
|
|
609
|
-
launchGameAccepted: "system.launch_game.accepted",
|
|
610
|
-
launchGameRejected: "system.launch_game.rejected",
|
|
611
|
-
closeGameAccepted: "system.close_game.accepted",
|
|
612
|
-
closeGameRejected: "system.close_game.rejected"
|
|
613
|
-
},
|
|
614
|
-
childHost: {
|
|
615
|
-
joinAccepted: "child_host.join.accepted",
|
|
616
|
-
joinRejected: "child_host.join.rejected",
|
|
617
|
-
disconnectPendingSystemFocus: "child_host.disconnect.pending_system_focus",
|
|
618
|
-
disconnectSystemFocusRestored: "child_host.disconnect.system_focus_restored"
|
|
619
|
-
},
|
|
620
|
-
embeddedGame: {
|
|
621
|
-
activateAccepted: "embedded_game.activate.accepted",
|
|
622
|
-
activateRejected: "embedded_game.activate.rejected"
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
var AIRJAM_BROWSER_LOG_EVENT_BY_SOURCE = {
|
|
626
|
-
console: AIRJAM_DEV_LOG_EVENTS.browser.console,
|
|
627
|
-
"window-error": AIRJAM_DEV_LOG_EVENTS.browser.windowError,
|
|
628
|
-
unhandledrejection: AIRJAM_DEV_LOG_EVENTS.browser.unhandledRejection,
|
|
629
|
-
diagnostic: AIRJAM_DEV_LOG_EVENTS.browser.diagnostic,
|
|
630
|
-
runtime: AIRJAM_DEV_LOG_EVENTS.browser.runtime
|
|
631
|
-
};
|
|
1383
|
+
// src/runtime/contracts/agent-control.ts
|
|
1384
|
+
var import_zod21 = require("zod");
|
|
632
1385
|
|
|
633
|
-
// src/
|
|
634
|
-
var
|
|
635
|
-
var
|
|
636
|
-
var
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
var
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
1386
|
+
// src/runtime/contracts/clip.ts
|
|
1387
|
+
var import_zod18 = require("zod");
|
|
1388
|
+
var CLIP_MIN_FRAME_INTERVAL_MS = 33;
|
|
1389
|
+
var clipFrameIntervalSchema = import_zod18.z.number().int().min(CLIP_MIN_FRAME_INTERVAL_MS);
|
|
1390
|
+
var CLIP_MAX_DURATION_MS = 15e3;
|
|
1391
|
+
var CLIP_MAX_FRAMES = Math.ceil(
|
|
1392
|
+
CLIP_MAX_DURATION_MS / CLIP_MIN_FRAME_INTERVAL_MS
|
|
1393
|
+
);
|
|
1394
|
+
var CLIP_MAX_BYTES = 4 * 1024 * 1024;
|
|
1395
|
+
var CLIP_FRAME_MAX_BYTES = 160 * 1024;
|
|
1396
|
+
var CLIP_PAGE_BASE64_CHARS = 768 * 1024;
|
|
1397
|
+
var CLIP_RECORDING_LIFETIME_MS = 6e5;
|
|
1398
|
+
var CLIP_VIDEO_MAX_BYTES = 32 * 1024 * 1024;
|
|
1399
|
+
var clipNotCapturedReasonSchema = import_zod18.z.enum([
|
|
1400
|
+
"busy",
|
|
1401
|
+
"unsupported",
|
|
1402
|
+
"surface-unavailable",
|
|
1403
|
+
"capture-failed",
|
|
1404
|
+
"runtime-replaced",
|
|
1405
|
+
"host-unavailable",
|
|
1406
|
+
"headless"
|
|
1407
|
+
]);
|
|
1408
|
+
var clipImageBytes = (data) => data.length / 4 * 3 - (data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0);
|
|
1409
|
+
var clipFrameSchema = import_zod18.z.object({
|
|
1410
|
+
index: import_zod18.z.number().int().nonnegative(),
|
|
1411
|
+
atMs: import_zod18.z.number().nonnegative().max(CLIP_RECORDING_LIFETIME_MS),
|
|
1412
|
+
width: import_zod18.z.number().int().positive().max(1280),
|
|
1413
|
+
height: import_zod18.z.number().int().positive().max(1280),
|
|
1414
|
+
mimeType: import_zod18.z.literal("image/jpeg"),
|
|
1415
|
+
data: import_zod18.z.string().min(4).max(Math.ceil(CLIP_FRAME_MAX_BYTES / 3) * 4).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(
|
|
1416
|
+
(data) => data.length % 4 === 0 && clipImageBytes(data) <= CLIP_FRAME_MAX_BYTES,
|
|
1417
|
+
"Clip frame exceeds its byte budget or is invalid base64."
|
|
1418
|
+
)
|
|
1419
|
+
}).strict();
|
|
1420
|
+
var clipMetadata = {
|
|
1421
|
+
clipId: import_zod18.z.string().min(1).max(128),
|
|
1422
|
+
identity: hostObservationIdentitySchema,
|
|
1423
|
+
startedAt: import_zod18.z.iso.datetime(),
|
|
1424
|
+
frameIntervalMs: clipFrameIntervalSchema,
|
|
1425
|
+
// Offsets and duration refer to the original recording, even after old frames drop.
|
|
1426
|
+
durationMs: import_zod18.z.number().nonnegative().max(CLIP_RECORDING_LIFETIME_MS),
|
|
1427
|
+
droppedFrames: import_zod18.z.number().int().nonnegative(),
|
|
1428
|
+
skippedFrames: import_zod18.z.number().int().nonnegative()
|
|
1429
|
+
};
|
|
1430
|
+
var clipArtifactSchema = import_zod18.z.object({
|
|
1431
|
+
version: import_zod18.z.literal(1),
|
|
1432
|
+
...clipMetadata,
|
|
1433
|
+
frames: import_zod18.z.array(clipFrameSchema).min(1).max(CLIP_MAX_FRAMES)
|
|
1434
|
+
}).strict().superRefine((clip, ctx) => {
|
|
1435
|
+
const frames = clip.frames;
|
|
1436
|
+
if (frames.length > Math.ceil(CLIP_MAX_DURATION_MS / clip.frameIntervalMs))
|
|
1437
|
+
ctx.addIssue({
|
|
1438
|
+
code: "custom",
|
|
1439
|
+
message: "Clip exceeds its cadence frame budget."
|
|
1440
|
+
});
|
|
1441
|
+
if (frames.reduce((sum, frame) => sum + clipImageBytes(frame.data), 0) > CLIP_MAX_BYTES)
|
|
1442
|
+
ctx.addIssue({
|
|
1443
|
+
code: "custom",
|
|
1444
|
+
message: "Clip exceeds its image byte budget."
|
|
1445
|
+
});
|
|
1446
|
+
if (frames.some(
|
|
1447
|
+
(frame, i) => frame.atMs > clip.durationMs || frame.atMs < clip.durationMs - CLIP_MAX_DURATION_MS || i > 0 && (frame.atMs <= frames[i - 1].atMs || frame.index !== frames[i - 1].index + 1)
|
|
1448
|
+
))
|
|
1449
|
+
ctx.addIssue({
|
|
1450
|
+
code: "custom",
|
|
1451
|
+
message: "Clip frames must be ordered within the kept time window."
|
|
1452
|
+
});
|
|
651
1453
|
});
|
|
652
|
-
var
|
|
653
|
-
|
|
654
|
-
|
|
1454
|
+
var clipNativeCaptureSchema = import_zod18.z.object({
|
|
1455
|
+
drawsAttempted: import_zod18.z.number().int().nonnegative(),
|
|
1456
|
+
drawsMade: import_zod18.z.number().int().nonnegative()
|
|
1457
|
+
}).strict();
|
|
1458
|
+
var clipVideoPageSchema = import_zod18.z.object({
|
|
1459
|
+
mimeType: import_zod18.z.string().min(1).max(128),
|
|
1460
|
+
width: import_zod18.z.number().int().positive().max(1280),
|
|
1461
|
+
height: import_zod18.z.number().int().positive().max(1280),
|
|
1462
|
+
chunks: import_zod18.z.array(
|
|
1463
|
+
import_zod18.z.string().min(4).max(CLIP_PAGE_BASE64_CHARS).regex(
|
|
1464
|
+
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/
|
|
1465
|
+
)
|
|
1466
|
+
).max(1),
|
|
1467
|
+
nextChunk: import_zod18.z.number().int().nonnegative().nullable()
|
|
1468
|
+
}).strict();
|
|
1469
|
+
var clipReadSchema = import_zod18.z.object({
|
|
1470
|
+
...clipMetadata,
|
|
1471
|
+
state: import_zod18.z.enum(["recording", "stopped"]),
|
|
1472
|
+
// Native encoded frames are counted after stop by the video consumer.
|
|
1473
|
+
nativeCapture: clipNativeCaptureSchema.optional(),
|
|
1474
|
+
droppedFrames: clipMetadata.droppedFrames.nullable(),
|
|
1475
|
+
skippedFrames: clipMetadata.skippedFrames.nullable(),
|
|
1476
|
+
frameCount: import_zod18.z.number().int().nonnegative().max(Math.ceil(CLIP_RECORDING_LIFETIME_MS / CLIP_MIN_FRAME_INTERVAL_MS)).nullable(),
|
|
1477
|
+
notCaptured: clipNotCapturedReasonSchema.nullable(),
|
|
1478
|
+
frames: import_zod18.z.array(clipFrameSchema).max(CLIP_MAX_FRAMES).refine(
|
|
1479
|
+
(frames) => frames.reduce((sum, frame) => sum + frame.data.length, 0) <= CLIP_PAGE_BASE64_CHARS,
|
|
1480
|
+
"Clip page exceeds its transfer budget."
|
|
1481
|
+
),
|
|
1482
|
+
nextFrame: import_zod18.z.number().int().nonnegative().nullable(),
|
|
1483
|
+
video: clipVideoPageSchema.optional()
|
|
1484
|
+
}).strict();
|
|
1485
|
+
|
|
1486
|
+
// src/runtime/contracts/input-log.ts
|
|
1487
|
+
var import_zod19 = require("zod");
|
|
1488
|
+
var INPUT_LOG_PAGE_BYTES = 512 * 1024;
|
|
1489
|
+
var inputLogCutSchema = import_zod19.z.object({
|
|
1490
|
+
ticks: import_zod19.z.number().int().nonnegative(),
|
|
1491
|
+
entryCount: import_zod19.z.number().int().nonnegative()
|
|
1492
|
+
}).strict();
|
|
1493
|
+
var hostInputLogPageSchema = import_zod19.z.object({
|
|
1494
|
+
identity: hostObservationIdentitySchema,
|
|
1495
|
+
observation: hostObservationSchema.optional(),
|
|
1496
|
+
header: airJamInputLogSchema.omit({ entries: true }),
|
|
1497
|
+
entryCount: import_zod19.z.number().int().nonnegative(),
|
|
1498
|
+
full: import_zod19.z.boolean(),
|
|
1499
|
+
entries: airJamInputLogSchema.shape.entries,
|
|
1500
|
+
nextEntry: import_zod19.z.number().int().nonnegative().nullable()
|
|
1501
|
+
}).strict();
|
|
1502
|
+
var inputLogNotReplayableReasonSchema = import_zod19.z.enum([
|
|
1503
|
+
"no-simulation",
|
|
1504
|
+
"loading",
|
|
1505
|
+
"runtime-replaced",
|
|
1506
|
+
"host-unavailable"
|
|
1507
|
+
]);
|
|
1508
|
+
|
|
1509
|
+
// src/runtime/contracts/timeline.ts
|
|
1510
|
+
var import_zod20 = require("zod");
|
|
1511
|
+
var facts = {
|
|
1512
|
+
id: import_zod20.z.string().min(1),
|
|
1513
|
+
tick: import_zod20.z.number().int().nonnegative(),
|
|
1514
|
+
/** Epoch milliseconds, unlike the simulation's game clock. */
|
|
1515
|
+
at: import_zod20.z.number().nonnegative()
|
|
1516
|
+
};
|
|
1517
|
+
var hostTimelineEntrySchema = import_zod20.z.discriminatedUnion("kind", [
|
|
1518
|
+
import_zod20.z.object({
|
|
1519
|
+
...facts,
|
|
1520
|
+
kind: import_zod20.z.enum(["join", "drop", "leave", "name"]),
|
|
1521
|
+
controllerId: import_zod20.z.string(),
|
|
1522
|
+
name: import_zod20.z.string().optional(),
|
|
1523
|
+
previousName: import_zod20.z.string().optional()
|
|
1524
|
+
}),
|
|
1525
|
+
import_zod20.z.object({
|
|
1526
|
+
...facts,
|
|
1527
|
+
kind: import_zod20.z.literal("state"),
|
|
1528
|
+
state: import_zod20.z.enum(["paused", "playing"])
|
|
1529
|
+
}),
|
|
1530
|
+
import_zod20.z.object({
|
|
1531
|
+
...facts,
|
|
1532
|
+
kind: import_zod20.z.literal("settings"),
|
|
1533
|
+
values: airJamSettingsValuesSchema,
|
|
1534
|
+
previousValues: airJamSettingsValuesSchema
|
|
1535
|
+
}),
|
|
1536
|
+
import_zod20.z.object({
|
|
1537
|
+
...facts,
|
|
1538
|
+
kind: import_zod20.z.literal("moment"),
|
|
1539
|
+
text: import_zod20.z.string().min(1).max(240)
|
|
1540
|
+
})
|
|
1541
|
+
]);
|
|
1542
|
+
var hostTimelinePaceSchema = import_zod20.z.object({
|
|
1543
|
+
/** End of the five-second sampling window, in epoch milliseconds. */
|
|
1544
|
+
at: import_zod20.z.number().nonnegative(),
|
|
1545
|
+
fps: import_zod20.z.number().nonnegative(),
|
|
1546
|
+
speed: import_zod20.z.number().nonnegative()
|
|
655
1547
|
});
|
|
656
|
-
var
|
|
1548
|
+
var hostTimelineSchema = import_zod20.z.discriminatedUnion("status", [
|
|
1549
|
+
import_zod20.z.object({
|
|
1550
|
+
status: import_zod20.z.literal("available"),
|
|
1551
|
+
identity: hostObservationIdentitySchema,
|
|
1552
|
+
startedAt: import_zod20.z.number().nonnegative(),
|
|
1553
|
+
stepMs: import_zod20.z.number().positive(),
|
|
1554
|
+
entries: import_zod20.z.array(hostTimelineEntrySchema),
|
|
1555
|
+
pace: import_zod20.z.array(hostTimelinePaceSchema).max(360)
|
|
1556
|
+
}),
|
|
1557
|
+
import_zod20.z.object({
|
|
1558
|
+
status: import_zod20.z.literal("unavailable"),
|
|
1559
|
+
identity: hostObservationIdentitySchema,
|
|
1560
|
+
reason: import_zod20.z.enum(["no-simulation", "simulation-loading"])
|
|
1561
|
+
})
|
|
1562
|
+
]);
|
|
1563
|
+
|
|
1564
|
+
// src/runtime/contracts/agent-control.ts
|
|
1565
|
+
var identity = import_zod21.z.object({
|
|
657
1566
|
roomId: roomCodeSchema,
|
|
658
|
-
|
|
659
|
-
});
|
|
660
|
-
var hostCreateRoomSchema = import_zod3.z.object({
|
|
661
|
-
maxPlayers: import_zod3.z.number().int().min(1).max(16).default(8)
|
|
1567
|
+
controllerId: import_zod21.z.string().min(1)
|
|
662
1568
|
});
|
|
663
|
-
var
|
|
664
|
-
|
|
1569
|
+
var actionRequest = identity.extend({
|
|
1570
|
+
contractId: import_zod21.z.string().min(1),
|
|
1571
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1572
|
+
actionId: import_zod21.z.string().min(1),
|
|
1573
|
+
payload: import_zod21.z.unknown().refine(
|
|
1574
|
+
(value) => isRpcSerializable(value),
|
|
1575
|
+
"Agent input must be serializable JSON data."
|
|
1576
|
+
).optional()
|
|
665
1577
|
});
|
|
666
|
-
var
|
|
667
|
-
|
|
668
|
-
})
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
1578
|
+
var hostAgentRequestSchema = import_zod21.z.discriminatedUnion("operation", [
|
|
1579
|
+
/** The room's instance and every seat in it, with what kind of device holds each. */
|
|
1580
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("seats"), roomId: roomCodeSchema }).strict(),
|
|
1581
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("timeline-read"), roomId: roomCodeSchema }).strict(),
|
|
1582
|
+
import_zod21.z.object({
|
|
1583
|
+
operation: import_zod21.z.literal("input-log-read"),
|
|
1584
|
+
roomId: roomCodeSchema,
|
|
1585
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1586
|
+
cut: inputLogCutSchema.nullable(),
|
|
1587
|
+
observe: hostObservationRequestSchema.pick({ controllerId: true, scope: true }).optional(),
|
|
1588
|
+
fromEntry: import_zod21.z.number().int().nonnegative()
|
|
1589
|
+
}).strict(),
|
|
1590
|
+
hostObservationRequestSchema.extend({ operation: import_zod21.z.literal("observe") }).strict(),
|
|
1591
|
+
identity.extend({
|
|
1592
|
+
operation: import_zod21.z.literal("read"),
|
|
1593
|
+
controllerId: import_zod21.z.string().min(1).nullable()
|
|
1594
|
+
}).strict(),
|
|
1595
|
+
import_zod21.z.object({
|
|
1596
|
+
operation: import_zod21.z.literal("settings-read"),
|
|
1597
|
+
roomId: roomCodeSchema,
|
|
1598
|
+
runtimeId: import_zod21.z.string().min(1)
|
|
1599
|
+
}).strict(),
|
|
1600
|
+
import_zod21.z.object({
|
|
1601
|
+
operation: import_zod21.z.literal("settings-update"),
|
|
1602
|
+
roomId: roomCodeSchema,
|
|
1603
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1604
|
+
patch: airJamSettingsValuesSchema,
|
|
1605
|
+
expectedRevision: import_zod21.z.number().int().nonnegative()
|
|
1606
|
+
}).strict(),
|
|
1607
|
+
actionRequest.extend({ operation: import_zod21.z.literal("resolve") }).strict(),
|
|
1608
|
+
actionRequest.extend({ operation: import_zod21.z.literal("invoke-host") }).strict(),
|
|
1609
|
+
import_zod21.z.object({
|
|
1610
|
+
operation: import_zod21.z.literal("clip-start"),
|
|
1611
|
+
delivery: import_zod21.z.enum(["pages", "video"]).optional(),
|
|
1612
|
+
frameIntervalMs: clipFrameIntervalSchema.optional(),
|
|
1613
|
+
roomId: roomCodeSchema,
|
|
1614
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1615
|
+
clipId: import_zod21.z.string().min(1).max(128)
|
|
1616
|
+
}).strict(),
|
|
1617
|
+
import_zod21.z.object({
|
|
1618
|
+
operation: import_zod21.z.literal("clip-read"),
|
|
1619
|
+
roomId: roomCodeSchema,
|
|
1620
|
+
clipId: import_zod21.z.string().min(1).max(128),
|
|
1621
|
+
stop: import_zod21.z.boolean(),
|
|
1622
|
+
fromChunk: import_zod21.z.number().int().nonnegative().optional(),
|
|
1623
|
+
fromFrame: import_zod21.z.number().int().nonnegative()
|
|
1624
|
+
}).strict()
|
|
1625
|
+
]);
|
|
1626
|
+
var hostAgentSnapshotSchema = agentContractDescriptionSchema.extend({
|
|
1627
|
+
contractId: import_zod21.z.string().min(1),
|
|
1628
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1629
|
+
snapshot: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()),
|
|
1630
|
+
rawStores: import_zod21.z.array(
|
|
1631
|
+
import_zod21.z.object({
|
|
1632
|
+
storeDomain: import_zod21.z.string().min(1),
|
|
1633
|
+
data: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()),
|
|
1634
|
+
revision: import_zod21.z.number().int().nonnegative(),
|
|
1635
|
+
updatedAt: import_zod21.z.string()
|
|
1636
|
+
})
|
|
1637
|
+
),
|
|
1638
|
+
storeDomainBindings: import_zod21.z.array(
|
|
1639
|
+
import_zod21.z.object({
|
|
1640
|
+
contractStoreDomain: import_zod21.z.string(),
|
|
1641
|
+
runtimeStoreDomain: import_zod21.z.string()
|
|
1642
|
+
})
|
|
1643
|
+
)
|
|
684
1644
|
});
|
|
685
|
-
var
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
1645
|
+
var hostAgentResponseSchema = import_zod21.z.discriminatedUnion("operation", [
|
|
1646
|
+
import_zod21.z.object({
|
|
1647
|
+
operation: import_zod21.z.literal("seats"),
|
|
1648
|
+
instance: import_zod21.z.string().min(1),
|
|
1649
|
+
seats: import_zod21.z.array(seatViewSchema)
|
|
1650
|
+
}).strict(),
|
|
1651
|
+
import_zod21.z.object({
|
|
1652
|
+
operation: import_zod21.z.literal("timeline-read"),
|
|
1653
|
+
timeline: hostTimelineSchema
|
|
1654
|
+
}).strict(),
|
|
1655
|
+
import_zod21.z.object({
|
|
1656
|
+
operation: import_zod21.z.literal("input-log-read"),
|
|
1657
|
+
page: hostInputLogPageSchema
|
|
1658
|
+
}).strict(),
|
|
1659
|
+
import_zod21.z.object({
|
|
1660
|
+
operation: import_zod21.z.literal("clip-start"),
|
|
1661
|
+
clipId: import_zod21.z.string().min(1).max(128),
|
|
1662
|
+
startedAt: import_zod21.z.iso.datetime()
|
|
1663
|
+
}).strict(),
|
|
1664
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("clip-read"), clip: clipReadSchema }).strict(),
|
|
1665
|
+
import_zod21.z.object({
|
|
1666
|
+
operation: import_zod21.z.enum(["settings-read", "settings-update"]),
|
|
1667
|
+
values: airJamSettingsValuesSchema,
|
|
1668
|
+
revision: import_zod21.z.number().int().nonnegative()
|
|
1669
|
+
}),
|
|
1670
|
+
import_zod21.z.object({
|
|
1671
|
+
operation: import_zod21.z.literal("observe"),
|
|
1672
|
+
observation: hostObservationSchema
|
|
1673
|
+
}),
|
|
1674
|
+
import_zod21.z.object({
|
|
1675
|
+
operation: import_zod21.z.literal("read"),
|
|
1676
|
+
snapshot: hostAgentSnapshotSchema.nullable()
|
|
1677
|
+
}),
|
|
1678
|
+
import_zod21.z.object({
|
|
1679
|
+
operation: import_zod21.z.enum(["resolve", "invoke-host"]),
|
|
1680
|
+
target: import_zod21.z.object({
|
|
1681
|
+
kind: import_zod21.z.enum(["participant", "host"]),
|
|
1682
|
+
actionName: import_zod21.z.string(),
|
|
1683
|
+
storeDomain: import_zod21.z.string()
|
|
1684
|
+
}),
|
|
1685
|
+
payload: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()).optional(),
|
|
1686
|
+
acknowledgement: airJamActionInvocationResultSchema.optional()
|
|
1687
|
+
})
|
|
1688
|
+
]);
|
|
1689
|
+
var hostAgentRequestMessageSchema = import_zod21.z.object({
|
|
1690
|
+
type: import_zod21.z.literal("AIRJAM_HOST_AGENT"),
|
|
1691
|
+
requestId: import_zod21.z.string().min(1).max(128),
|
|
1692
|
+
request: hostAgentRequestSchema
|
|
703
1693
|
}).strict();
|
|
704
|
-
var
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
1694
|
+
var hostAgentResultMessageSchema = import_zod21.z.object({
|
|
1695
|
+
type: import_zod21.z.literal("AIRJAM_HOST_AGENT_RESULT"),
|
|
1696
|
+
requestId: hostAgentRequestMessageSchema.shape.requestId,
|
|
1697
|
+
result: import_zod21.z.discriminatedUnion("ok", [
|
|
1698
|
+
import_zod21.z.object({ ok: import_zod21.z.literal(true), response: hostAgentResponseSchema }),
|
|
1699
|
+
import_zod21.z.object({ ok: import_zod21.z.literal(false), error: import_zod21.z.string().min(1).max(1024) })
|
|
1700
|
+
])
|
|
710
1701
|
}).strict();
|
|
711
|
-
|
|
1702
|
+
|
|
1703
|
+
// src/runtime/contracts/control.ts
|
|
1704
|
+
var hostRuntimeActionRequestSchema = import_zod22.z.object({
|
|
712
1705
|
roomId: roomCodeSchema,
|
|
713
|
-
storeDomain:
|
|
714
|
-
|
|
1706
|
+
storeDomain: import_zod22.z.string().trim().min(1).max(128),
|
|
1707
|
+
actionName: import_zod22.z.string().trim().min(1).max(128),
|
|
1708
|
+
payload: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.unknown()).optional()
|
|
715
1709
|
}).strict();
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
var ALLOWED_RUNTIME_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
720
|
-
var parseRuntimeUrl = (value) => {
|
|
721
|
-
try {
|
|
722
|
-
const parsed = new URL(value);
|
|
723
|
-
if (!ALLOWED_RUNTIME_PROTOCOLS.has(parsed.protocol)) {
|
|
724
|
-
return null;
|
|
725
|
-
}
|
|
726
|
-
if (parsed.username || parsed.password) {
|
|
727
|
-
return null;
|
|
728
|
-
}
|
|
729
|
-
return parsed;
|
|
730
|
-
} catch {
|
|
731
|
-
return null;
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
var runtimeUrlSchema = import_zod6.z.string().trim().min(1).refine((value) => parseRuntimeUrl(value) !== null, {
|
|
735
|
-
message: "URL must be a valid http(s) URL without embedded credentials."
|
|
1710
|
+
var hostStateEpochSchema = import_zod22.z.object({
|
|
1711
|
+
storeDomain: import_zod22.z.string().min(1).max(128),
|
|
1712
|
+
epoch: import_zod22.z.string().min(1).max(128)
|
|
736
1713
|
});
|
|
737
1714
|
|
|
738
|
-
// src/
|
|
739
|
-
var
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
var DEFAULT_ROOM_PLATFORM_SETTINGS = {
|
|
760
|
-
audio: DEFAULT_PLATFORM_SETTINGS.audio,
|
|
761
|
-
previewControllers: DEFAULT_PLATFORM_SETTINGS.previewControllers
|
|
762
|
-
};
|
|
763
|
-
var clamp01 = (value) => Math.max(0, Math.min(1, value));
|
|
764
|
-
var getEffectiveAudioVolume = (settings, category) => {
|
|
765
|
-
const categoryVolume = category === "music" ? settings.musicVolume : settings.sfxVolume;
|
|
766
|
-
return clamp01(settings.masterVolume) * clamp01(categoryVolume);
|
|
767
|
-
};
|
|
1715
|
+
// src/core/replay-input-log.ts
|
|
1716
|
+
var settingsLogEventSchema = import_zod23.z.object({
|
|
1717
|
+
patch: airJamSettingsValuesSchema,
|
|
1718
|
+
revision: import_zod23.z.number().int().positive()
|
|
1719
|
+
}).strict();
|
|
1720
|
+
var seatLogEventSchema = import_zod23.z.object({ seat: seatViewSchema });
|
|
1721
|
+
var leftLogEventSchema = import_zod23.z.object({ seat: import_zod23.z.string() });
|
|
1722
|
+
var inputLogEventSchema = import_zod23.z.object({
|
|
1723
|
+
seat: import_zod23.z.string(),
|
|
1724
|
+
input: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.unknown())
|
|
1725
|
+
});
|
|
1726
|
+
var runtimeLogEventSchema = import_zod23.z.object({ runtimeState: runtimeStateSchema });
|
|
1727
|
+
var actionLogEventSchema = import_zod23.z.object({
|
|
1728
|
+
actionName: import_zod23.z.string(),
|
|
1729
|
+
payload: import_zod23.z.unknown().optional(),
|
|
1730
|
+
storeDomain: import_zod23.z.string(),
|
|
1731
|
+
actor: import_zod23.z.object({
|
|
1732
|
+
id: import_zod23.z.string(),
|
|
1733
|
+
role: import_zod23.z.enum(["host", "controller"])
|
|
1734
|
+
})
|
|
1735
|
+
});
|
|
768
1736
|
|
|
769
|
-
// src/
|
|
770
|
-
var
|
|
1737
|
+
// src/runtime/browser-replay.ts
|
|
1738
|
+
var whole = import_zod24.z.number().int().nonnegative();
|
|
1739
|
+
var replayAdvanceSchema = import_zod24.z.union([
|
|
1740
|
+
import_zod24.z.object({ steps: whole }).strict(),
|
|
1741
|
+
import_zod24.z.object({ ms: import_zod24.z.number().finite().nonnegative() }).strict(),
|
|
1742
|
+
import_zod24.z.object({ toTick: whole }).strict()
|
|
1743
|
+
]);
|
|
1744
|
+
var replayRequestSchema = import_zod24.z.discriminatedUnion("operation", [
|
|
1745
|
+
import_zod24.z.object({
|
|
1746
|
+
operation: import_zod24.z.literal("open"),
|
|
1747
|
+
log: airJamInputLogSchema,
|
|
1748
|
+
observe: hostObservationRequestSchema.pick({ scope: true, controllerId: true }).optional()
|
|
1749
|
+
}).strict(),
|
|
1750
|
+
import_zod24.z.object({ operation: import_zod24.z.literal("advance"), by: replayAdvanceSchema }).strict(),
|
|
1751
|
+
import_zod24.z.object({
|
|
1752
|
+
operation: import_zod24.z.literal("read"),
|
|
1753
|
+
/** Capture the paused frame on this explicit read; open and advance omit images. */
|
|
1754
|
+
includeImage: import_zod24.z.boolean().optional()
|
|
1755
|
+
}).strict()
|
|
1756
|
+
]);
|
|
1757
|
+
var replayReadSchema = import_zod24.z.object({
|
|
1758
|
+
tick: whole,
|
|
1759
|
+
ticks: whole,
|
|
1760
|
+
done: import_zod24.z.boolean(),
|
|
1761
|
+
stepMs: import_zod24.z.number().positive(),
|
|
1762
|
+
observation: hostObservationSchema
|
|
1763
|
+
}).strict();
|
|
1764
|
+
var replayRequestMessageSchema = import_zod24.z.object({
|
|
1765
|
+
type: import_zod24.z.literal("AIRJAM_REPLAY"),
|
|
1766
|
+
requestId: import_zod24.z.string().min(1),
|
|
1767
|
+
request: replayRequestSchema
|
|
1768
|
+
}).strict();
|
|
1769
|
+
var replayMessageSchema = import_zod24.z.discriminatedUnion("type", [
|
|
1770
|
+
import_zod24.z.object({ type: import_zod24.z.literal("AIRJAM_REPLAY_READY") }).strict(),
|
|
1771
|
+
import_zod24.z.object({
|
|
1772
|
+
type: import_zod24.z.literal("AIRJAM_REPLAY_RESULT"),
|
|
1773
|
+
requestId: import_zod24.z.string().min(1),
|
|
1774
|
+
result: import_zod24.z.discriminatedUnion("ok", [
|
|
1775
|
+
import_zod24.z.object({ ok: import_zod24.z.literal(true), response: replayReadSchema }).strict(),
|
|
1776
|
+
import_zod24.z.object({ ok: import_zod24.z.literal(false), error: import_zod24.z.string() }).strict()
|
|
1777
|
+
])
|
|
1778
|
+
}).strict()
|
|
1779
|
+
]);
|
|
771
1780
|
|
|
772
1781
|
// src/context/air-jam-context.tsx
|
|
773
1782
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -809,8 +1818,10 @@ var useAssertSessionScope = (expectedScope, hookName) => {
|
|
|
809
1818
|
|
|
810
1819
|
// src/runtime/runtime-owner-contexts.tsx
|
|
811
1820
|
var import_react3 = require("react");
|
|
1821
|
+
var fixedControllerOrientationContext = (0, import_react3.createContext)(void 0);
|
|
812
1822
|
var hostRuntimeContext = (0, import_react3.createContext)(null);
|
|
813
1823
|
var controllerRuntimeContext = (0, import_react3.createContext)(null);
|
|
1824
|
+
var declaredStoresContext = (0, import_react3.createContext)(null);
|
|
814
1825
|
|
|
815
1826
|
// src/hooks/use-air-jam-controller.ts
|
|
816
1827
|
var toControllerState = (state) => {
|
|
@@ -822,8 +1833,6 @@ var toControllerState = (state) => {
|
|
|
822
1833
|
lastError: state.lastError,
|
|
823
1834
|
runtimeState: state.runtimeState,
|
|
824
1835
|
controllerOrientation: state.controllerOrientation,
|
|
825
|
-
stateMessage: state.stateMessage,
|
|
826
|
-
roomSettings: state.roomSettings,
|
|
827
1836
|
players: state.players,
|
|
828
1837
|
selfPlayer
|
|
829
1838
|
};
|
|
@@ -831,7 +1840,7 @@ var toControllerState = (state) => {
|
|
|
831
1840
|
function useAirJamController(selector) {
|
|
832
1841
|
useAssertSessionScope("controller", "useAirJamController");
|
|
833
1842
|
const { store } = useAirJamContext();
|
|
834
|
-
const selectedState = (0,
|
|
1843
|
+
const selectedState = (0, import_zustand2.useStore)(
|
|
835
1844
|
store,
|
|
836
1845
|
(0, import_shallow2.useShallow)((state) => {
|
|
837
1846
|
const controllerState = toControllerState(state);
|
|
@@ -844,7 +1853,7 @@ function useAirJamController(selector) {
|
|
|
844
1853
|
if (!runtime) {
|
|
845
1854
|
throw createAirJamDiagnosticError(
|
|
846
1855
|
"AJ_SCOPE_MISMATCH",
|
|
847
|
-
"useAirJamController requires a mounted controller runtime boundary. Wrap the controller tree with <
|
|
1856
|
+
"useAirJamController requires a mounted controller runtime boundary. Wrap the controller tree with <airjam.Controller> before reading controller state.",
|
|
848
1857
|
{
|
|
849
1858
|
hookName: "useAirJamController",
|
|
850
1859
|
expectedScope: "controller",
|
|
@@ -1037,7 +2046,7 @@ var ControllerPrimaryAction = ({
|
|
|
1037
2046
|
children: [
|
|
1038
2047
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "min-w-0", children: [
|
|
1039
2048
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate text-base font-black tracking-[0.12em] uppercase sm:text-lg", children: label }),
|
|
1040
|
-
helper ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-1 text-sm/5 font-medium tracking-normal normal-case opacity-80", children: helper }) : null
|
|
2049
|
+
helper ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-1 text-sm/5 font-medium tracking-normal whitespace-normal normal-case opacity-80", children: helper }) : null
|
|
1041
2050
|
] }),
|
|
1042
2051
|
icon ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "ml-4 flex shrink-0 items-center justify-center", children: icon }) : null
|
|
1043
2052
|
]
|
|
@@ -1045,9 +2054,325 @@ var ControllerPrimaryAction = ({
|
|
|
1045
2054
|
) });
|
|
1046
2055
|
};
|
|
1047
2056
|
|
|
2057
|
+
// src/components/controls.tsx
|
|
2058
|
+
var import_react6 = require("react");
|
|
2059
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2060
|
+
var useControllerInput = () => {
|
|
2061
|
+
const runtime = (0, import_react6.useContext)(
|
|
2062
|
+
controllerRuntimeContext
|
|
2063
|
+
);
|
|
2064
|
+
if (!runtime?.input)
|
|
2065
|
+
throw createAirJamDiagnosticError(
|
|
2066
|
+
"AJ_INPUT_NOT_DECLARED",
|
|
2067
|
+
"Phone controls send declared controls. Declare them with defineAirJamGame({ input }) and render controls inside <airjam.Controller>."
|
|
2068
|
+
);
|
|
2069
|
+
return runtime.input;
|
|
2070
|
+
};
|
|
2071
|
+
var capturePointer = (event) => {
|
|
2072
|
+
try {
|
|
2073
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2074
|
+
} catch {
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
var isPressKey = (event) => event.key === " " || event.key === "Enter";
|
|
2078
|
+
var usePress = (start, disabled, onActiveChange) => {
|
|
2079
|
+
const release = (0, import_react6.useRef)(null);
|
|
2080
|
+
const pointer = (0, import_react6.useRef)(null);
|
|
2081
|
+
const [active, setActive] = (0, import_react6.useState)(false);
|
|
2082
|
+
const onActiveChangeRef = (0, import_react6.useRef)(onActiveChange);
|
|
2083
|
+
(0, import_react6.useEffect)(() => {
|
|
2084
|
+
onActiveChangeRef.current = onActiveChange;
|
|
2085
|
+
});
|
|
2086
|
+
const begin = (0, import_react6.useCallback)(() => {
|
|
2087
|
+
if (release.current) return false;
|
|
2088
|
+
release.current = start();
|
|
2089
|
+
setActive(true);
|
|
2090
|
+
onActiveChangeRef.current?.(true);
|
|
2091
|
+
return true;
|
|
2092
|
+
}, [start]);
|
|
2093
|
+
const end = (0, import_react6.useCallback)(() => {
|
|
2094
|
+
pointer.current = null;
|
|
2095
|
+
if (!release.current) return;
|
|
2096
|
+
release.current();
|
|
2097
|
+
release.current = null;
|
|
2098
|
+
setActive(false);
|
|
2099
|
+
onActiveChangeRef.current?.(false);
|
|
2100
|
+
}, []);
|
|
2101
|
+
(0, import_react6.useEffect)(() => {
|
|
2102
|
+
if (disabled) end();
|
|
2103
|
+
}, [disabled, end]);
|
|
2104
|
+
(0, import_react6.useEffect)(() => end, [end]);
|
|
2105
|
+
const endPointer = (event) => {
|
|
2106
|
+
if (event.pointerId === pointer.current) end();
|
|
2107
|
+
};
|
|
2108
|
+
return {
|
|
2109
|
+
active,
|
|
2110
|
+
handlers: {
|
|
2111
|
+
onPointerDown: (event) => {
|
|
2112
|
+
if (disabled || event.button !== 0 || !begin()) return;
|
|
2113
|
+
event.preventDefault();
|
|
2114
|
+
pointer.current = event.pointerId;
|
|
2115
|
+
capturePointer(event);
|
|
2116
|
+
},
|
|
2117
|
+
onPointerUp: endPointer,
|
|
2118
|
+
onPointerCancel: endPointer,
|
|
2119
|
+
onLostPointerCapture: endPointer,
|
|
2120
|
+
onKeyDown: (event) => {
|
|
2121
|
+
if (disabled || !isPressKey(event)) return;
|
|
2122
|
+
event.preventDefault();
|
|
2123
|
+
if (!event.repeat) begin();
|
|
2124
|
+
},
|
|
2125
|
+
onKeyUp: (event) => {
|
|
2126
|
+
if (!isPressKey(event)) return;
|
|
2127
|
+
event.preventDefault();
|
|
2128
|
+
end();
|
|
2129
|
+
},
|
|
2130
|
+
// Focus leaving ends a key hold; a finger still down keeps its press.
|
|
2131
|
+
onBlur: () => {
|
|
2132
|
+
if (pointer.current === null) end();
|
|
2133
|
+
},
|
|
2134
|
+
onContextMenu: (event) => event.preventDefault()
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
};
|
|
2138
|
+
var ControlButton = ({
|
|
2139
|
+
control,
|
|
2140
|
+
disabled = false,
|
|
2141
|
+
onActiveChange,
|
|
2142
|
+
className,
|
|
2143
|
+
...props
|
|
2144
|
+
}) => {
|
|
2145
|
+
const input = useControllerInput();
|
|
2146
|
+
const press = (0, import_react6.useCallback)(
|
|
2147
|
+
() => input.press(control.name),
|
|
2148
|
+
[input, control.name]
|
|
2149
|
+
);
|
|
2150
|
+
const { active, handlers } = usePress(press, disabled, onActiveChange);
|
|
2151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2152
|
+
"button",
|
|
2153
|
+
{
|
|
2154
|
+
type: "button",
|
|
2155
|
+
...props,
|
|
2156
|
+
...handlers,
|
|
2157
|
+
disabled,
|
|
2158
|
+
"data-active": active,
|
|
2159
|
+
className: cn("touch-none select-none", className)
|
|
2160
|
+
}
|
|
2161
|
+
);
|
|
2162
|
+
};
|
|
2163
|
+
var AxisButton = ({
|
|
2164
|
+
control,
|
|
2165
|
+
value,
|
|
2166
|
+
disabled = false,
|
|
2167
|
+
onActiveChange,
|
|
2168
|
+
className,
|
|
2169
|
+
...props
|
|
2170
|
+
}) => {
|
|
2171
|
+
const input = useControllerInput();
|
|
2172
|
+
const hold = (0, import_react6.useCallback)(
|
|
2173
|
+
() => input.hold(control.name, value),
|
|
2174
|
+
[input, control.name, value]
|
|
2175
|
+
);
|
|
2176
|
+
const { active, handlers } = usePress(hold, disabled, onActiveChange);
|
|
2177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2178
|
+
"button",
|
|
2179
|
+
{
|
|
2180
|
+
type: "button",
|
|
2181
|
+
...props,
|
|
2182
|
+
...handlers,
|
|
2183
|
+
disabled,
|
|
2184
|
+
"data-active": active,
|
|
2185
|
+
className: cn("touch-none select-none", className)
|
|
2186
|
+
}
|
|
2187
|
+
);
|
|
2188
|
+
};
|
|
2189
|
+
var centre = (element) => {
|
|
2190
|
+
const rect = element?.getBoundingClientRect();
|
|
2191
|
+
return rect ? { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 } : null;
|
|
2192
|
+
};
|
|
2193
|
+
var resolveStickPoint = (point, origin, right, bottom) => {
|
|
2194
|
+
const xAxis = { x: right.x - origin.x, y: right.y - origin.y };
|
|
2195
|
+
const yAxis = { x: bottom.x - origin.x, y: bottom.y - origin.y };
|
|
2196
|
+
const determinant = xAxis.x * yAxis.y - xAxis.y * yAxis.x;
|
|
2197
|
+
if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-3)
|
|
2198
|
+
return { x: 0, y: 0 };
|
|
2199
|
+
const offset = { x: point.x - origin.x, y: point.y - origin.y };
|
|
2200
|
+
const across = (offset.x * yAxis.y - offset.y * yAxis.x) / determinant;
|
|
2201
|
+
const down = (xAxis.x * offset.y - xAxis.y * offset.x) / determinant;
|
|
2202
|
+
return { x: 2 * across - 1, y: 2 * down - 1 };
|
|
2203
|
+
};
|
|
2204
|
+
var shapeStick = (vector, directions, deadzone) => {
|
|
2205
|
+
const length = Math.hypot(vector.x, vector.y);
|
|
2206
|
+
if (length <= deadzone) return { x: 0, y: 0 };
|
|
2207
|
+
if (directions === "4-way")
|
|
2208
|
+
return Math.abs(vector.x) > Math.abs(vector.y) ? { x: Math.sign(vector.x), y: 0 } : { x: 0, y: Math.sign(vector.y) };
|
|
2209
|
+
return length > 1 ? { x: vector.x / length, y: vector.y / length } : vector;
|
|
2210
|
+
};
|
|
2211
|
+
var CENTRE = { x: 0, y: 0 };
|
|
2212
|
+
var Stick = ({
|
|
2213
|
+
control,
|
|
2214
|
+
directions = "any",
|
|
2215
|
+
deadzone = 0,
|
|
2216
|
+
disabled = false,
|
|
2217
|
+
knobClassName,
|
|
2218
|
+
knob,
|
|
2219
|
+
children,
|
|
2220
|
+
onActiveChange,
|
|
2221
|
+
className,
|
|
2222
|
+
...props
|
|
2223
|
+
}) => {
|
|
2224
|
+
const fixedOrientation = (0, import_react6.useContext)(fixedControllerOrientationContext);
|
|
2225
|
+
if (fixedOrientation === null)
|
|
2226
|
+
throw new Error(
|
|
2227
|
+
"Stick requires joystick input: declare 'joystick' in inputModalities in airjam.config."
|
|
2228
|
+
);
|
|
2229
|
+
const input = useControllerInput();
|
|
2230
|
+
const origin = (0, import_react6.useRef)(null);
|
|
2231
|
+
const right = (0, import_react6.useRef)(null);
|
|
2232
|
+
const bottom = (0, import_react6.useRef)(null);
|
|
2233
|
+
const pointer = (0, import_react6.useRef)(null);
|
|
2234
|
+
const [active, setActive] = (0, import_react6.useState)(false);
|
|
2235
|
+
const subscribe = (0, import_react6.useCallback)(
|
|
2236
|
+
(listener) => input.subscribe(listener),
|
|
2237
|
+
[input]
|
|
2238
|
+
);
|
|
2239
|
+
const value = (0, import_react6.useSyncExternalStore)(
|
|
2240
|
+
subscribe,
|
|
2241
|
+
() => input.value(control.name),
|
|
2242
|
+
() => CENTRE
|
|
2243
|
+
);
|
|
2244
|
+
const setActiveState = (next) => {
|
|
2245
|
+
setActive(next);
|
|
2246
|
+
onActiveChange?.(next);
|
|
2247
|
+
};
|
|
2248
|
+
const follow = (event) => {
|
|
2249
|
+
const corners = [origin, right, bottom].map(
|
|
2250
|
+
({ current }) => centre(current)
|
|
2251
|
+
);
|
|
2252
|
+
const [topLeft, topRight, bottomLeft] = corners;
|
|
2253
|
+
if (!topLeft || !topRight || !bottomLeft) return;
|
|
2254
|
+
input.set(
|
|
2255
|
+
control.name,
|
|
2256
|
+
shapeStick(
|
|
2257
|
+
resolveStickPoint(
|
|
2258
|
+
{ x: event.clientX, y: event.clientY },
|
|
2259
|
+
topLeft,
|
|
2260
|
+
topRight,
|
|
2261
|
+
bottomLeft
|
|
2262
|
+
),
|
|
2263
|
+
directions,
|
|
2264
|
+
deadzone
|
|
2265
|
+
)
|
|
2266
|
+
);
|
|
2267
|
+
};
|
|
2268
|
+
const end = (event) => {
|
|
2269
|
+
if (event.pointerId !== pointer.current) return;
|
|
2270
|
+
pointer.current = null;
|
|
2271
|
+
input.set(control.name, CENTRE);
|
|
2272
|
+
setActiveState(false);
|
|
2273
|
+
};
|
|
2274
|
+
(0, import_react6.useEffect)(() => {
|
|
2275
|
+
if (!disabled || pointer.current === null) return;
|
|
2276
|
+
pointer.current = null;
|
|
2277
|
+
input.set(control.name, CENTRE);
|
|
2278
|
+
setActive(false);
|
|
2279
|
+
}, [disabled, input, control.name]);
|
|
2280
|
+
const marker = "pointer-events-none absolute size-0";
|
|
2281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2282
|
+
"div",
|
|
2283
|
+
{
|
|
2284
|
+
role: "application",
|
|
2285
|
+
"aria-label": "Joystick",
|
|
2286
|
+
...props,
|
|
2287
|
+
"data-active": active,
|
|
2288
|
+
className: cn("relative touch-none select-none", className),
|
|
2289
|
+
onPointerDown: (event) => {
|
|
2290
|
+
if (disabled || pointer.current !== null || event.button !== 0) return;
|
|
2291
|
+
event.preventDefault();
|
|
2292
|
+
pointer.current = event.pointerId;
|
|
2293
|
+
capturePointer(event);
|
|
2294
|
+
setActiveState(true);
|
|
2295
|
+
follow(event);
|
|
2296
|
+
},
|
|
2297
|
+
onPointerMove: (event) => {
|
|
2298
|
+
if (event.pointerId === pointer.current) follow(event);
|
|
2299
|
+
},
|
|
2300
|
+
onPointerUp: end,
|
|
2301
|
+
onPointerCancel: end,
|
|
2302
|
+
onLostPointerCapture: end,
|
|
2303
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
2304
|
+
children: [
|
|
2305
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref: origin, className: cn(marker, "top-0 left-0") }),
|
|
2306
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref: right, className: cn(marker, "top-0 left-full") }),
|
|
2307
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref: bottom, className: cn(marker, "top-full left-0") }),
|
|
2308
|
+
typeof children === "function" ? children({ value, active }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
2309
|
+
children,
|
|
2310
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2311
|
+
"span",
|
|
2312
|
+
{
|
|
2313
|
+
className: cn(
|
|
2314
|
+
"pointer-events-none absolute top-1/2 left-1/2 flex size-1/3 items-center justify-center rounded-full bg-current/30",
|
|
2315
|
+
!active && "transition-transform duration-150 ease-out",
|
|
2316
|
+
knobClassName
|
|
2317
|
+
),
|
|
2318
|
+
style: {
|
|
2319
|
+
transform: `translate(calc(-50% + ${value.x * 100}%), calc(-50% + ${value.y * 100}%))`
|
|
2320
|
+
},
|
|
2321
|
+
children: knob
|
|
2322
|
+
}
|
|
2323
|
+
)
|
|
2324
|
+
] })
|
|
2325
|
+
]
|
|
2326
|
+
}
|
|
2327
|
+
);
|
|
2328
|
+
};
|
|
2329
|
+
|
|
2330
|
+
// src/components/gamepad-layout.tsx
|
|
2331
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2332
|
+
var layoutStyle = {
|
|
2333
|
+
containerType: "size",
|
|
2334
|
+
"--airjam-thumb-size": "min(62cqh, 27cqw)",
|
|
2335
|
+
"--airjam-thumb-margin": "min(10cqh, 5cqw)"
|
|
2336
|
+
};
|
|
2337
|
+
var zoneStyle = {
|
|
2338
|
+
width: "calc(var(--airjam-thumb-size) + 2 * var(--airjam-thumb-margin))"
|
|
2339
|
+
};
|
|
2340
|
+
var slotStyle = {
|
|
2341
|
+
width: "var(--airjam-thumb-size)",
|
|
2342
|
+
height: "var(--airjam-thumb-size)"
|
|
2343
|
+
};
|
|
2344
|
+
var ThumbZone = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2345
|
+
"div",
|
|
2346
|
+
{
|
|
2347
|
+
className: "flex h-full flex-none items-center justify-center",
|
|
2348
|
+
style: zoneStyle,
|
|
2349
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "grid *:size-full", style: slotStyle, children })
|
|
2350
|
+
}
|
|
2351
|
+
);
|
|
2352
|
+
var GamepadLayout = ({
|
|
2353
|
+
left,
|
|
2354
|
+
right,
|
|
2355
|
+
center,
|
|
2356
|
+
className,
|
|
2357
|
+
style,
|
|
2358
|
+
...props
|
|
2359
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2360
|
+
"div",
|
|
2361
|
+
{
|
|
2362
|
+
...props,
|
|
2363
|
+
className: cn("flex h-full w-full items-center", className),
|
|
2364
|
+
style: { ...layoutStyle, ...style },
|
|
2365
|
+
children: [
|
|
2366
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThumbZone, { children: left }),
|
|
2367
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex h-full min-w-0 flex-1 flex-col items-center justify-center gap-2 text-center", children: center }),
|
|
2368
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThumbZone, { children: right })
|
|
2369
|
+
]
|
|
2370
|
+
}
|
|
2371
|
+
);
|
|
2372
|
+
|
|
1048
2373
|
// src/components/host-mute-button.tsx
|
|
1049
2374
|
var import_lucide_react = require("lucide-react");
|
|
1050
|
-
var
|
|
2375
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1051
2376
|
function HostMuteButton({
|
|
1052
2377
|
muted,
|
|
1053
2378
|
onToggle,
|
|
@@ -1057,7 +2382,7 @@ function HostMuteButton({
|
|
|
1057
2382
|
unmutedLabel = "Mute"
|
|
1058
2383
|
}) {
|
|
1059
2384
|
const label = muted ? mutedLabel : unmutedLabel;
|
|
1060
|
-
return /* @__PURE__ */ (0,
|
|
2385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1061
2386
|
Button,
|
|
1062
2387
|
{
|
|
1063
2388
|
type: "button",
|
|
@@ -1072,8 +2397,8 @@ function HostMuteButton({
|
|
|
1072
2397
|
className
|
|
1073
2398
|
),
|
|
1074
2399
|
children: [
|
|
1075
|
-
muted ? /* @__PURE__ */ (0,
|
|
1076
|
-
/* @__PURE__ */ (0,
|
|
2400
|
+
muted ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react.VolumeX, { className: "size-4" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react.Volume2, { className: "size-4" }),
|
|
2401
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1077
2402
|
"span",
|
|
1078
2403
|
{
|
|
1079
2404
|
className: cn(
|
|
@@ -1089,13 +2414,13 @@ function HostMuteButton({
|
|
|
1089
2414
|
}
|
|
1090
2415
|
|
|
1091
2416
|
// src/components/join-qr-overlay.tsx
|
|
1092
|
-
var
|
|
2417
|
+
var import_react8 = require("react");
|
|
1093
2418
|
var import_react_dom = require("react-dom");
|
|
1094
2419
|
|
|
1095
2420
|
// src/components/room-qr-code.tsx
|
|
1096
2421
|
var import_qrcode = require("qrcode");
|
|
1097
|
-
var
|
|
1098
|
-
var
|
|
2422
|
+
var import_react7 = require("react");
|
|
2423
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1099
2424
|
var RoomQrCode = ({
|
|
1100
2425
|
value,
|
|
1101
2426
|
size = 180,
|
|
@@ -1108,58 +2433,24 @@ var RoomQrCode = ({
|
|
|
1108
2433
|
alt = "Room join QR code"
|
|
1109
2434
|
}) => {
|
|
1110
2435
|
const trimmed = value.trim();
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
void (0, import_qrcode.toDataURL)(trimmed, {
|
|
1123
|
-
width: size,
|
|
1124
|
-
margin: padding,
|
|
1125
|
-
errorCorrectionLevel,
|
|
1126
|
-
color: {
|
|
1127
|
-
dark: foregroundColor,
|
|
1128
|
-
light: backgroundColor
|
|
1129
|
-
}
|
|
1130
|
-
}).then((nextUrl) => {
|
|
1131
|
-
if (!cancelled) {
|
|
1132
|
-
setQrState({
|
|
1133
|
-
key: qrKey,
|
|
1134
|
-
dataUrl: nextUrl,
|
|
1135
|
-
error: false
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
}).catch(() => {
|
|
1139
|
-
if (!cancelled) {
|
|
1140
|
-
setQrState({
|
|
1141
|
-
key: qrKey,
|
|
1142
|
-
dataUrl: null,
|
|
1143
|
-
error: true
|
|
1144
|
-
});
|
|
2436
|
+
const qr = (0, import_react7.useMemo)(() => {
|
|
2437
|
+
if (!trimmed) return null;
|
|
2438
|
+
try {
|
|
2439
|
+
const { modules } = (0, import_qrcode.create)(trimmed, { errorCorrectionLevel });
|
|
2440
|
+
let path = "";
|
|
2441
|
+
for (let row = 0; row < modules.size; row += 1) {
|
|
2442
|
+
for (let column = 0; column < modules.size; column += 1) {
|
|
2443
|
+
if (modules.data[row * modules.size + column]) {
|
|
2444
|
+
path += `M${column},${row}h1v1h-1z`;
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
1145
2447
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
}
|
|
1150
|
-
}, [
|
|
1151
|
-
|
|
1152
|
-
errorCorrectionLevel,
|
|
1153
|
-
foregroundColor,
|
|
1154
|
-
padding,
|
|
1155
|
-
size,
|
|
1156
|
-
qrKey,
|
|
1157
|
-
trimmed
|
|
1158
|
-
]);
|
|
1159
|
-
const imageSrc = trimmed && qrState.key === qrKey && qrState.dataUrl ? qrState.dataUrl : null;
|
|
1160
|
-
const isLoading = !!trimmed && qrState.key !== qrKey;
|
|
1161
|
-
const isUnavailable = !trimmed || qrState.key === qrKey && qrState.error;
|
|
1162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2448
|
+
return { path, size: modules.size };
|
|
2449
|
+
} catch {
|
|
2450
|
+
return null;
|
|
2451
|
+
}
|
|
2452
|
+
}, [trimmed, errorCorrectionLevel]);
|
|
2453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1163
2454
|
"div",
|
|
1164
2455
|
{
|
|
1165
2456
|
className,
|
|
@@ -1170,19 +2461,31 @@ var RoomQrCode = ({
|
|
|
1170
2461
|
},
|
|
1171
2462
|
"aria-live": "polite",
|
|
1172
2463
|
"aria-label": alt,
|
|
1173
|
-
children:
|
|
1174
|
-
"
|
|
2464
|
+
children: qr ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2465
|
+
"svg",
|
|
1175
2466
|
{
|
|
1176
|
-
|
|
1177
|
-
alt,
|
|
2467
|
+
role: "img",
|
|
2468
|
+
"aria-label": alt,
|
|
1178
2469
|
width: size,
|
|
1179
2470
|
height: size,
|
|
1180
|
-
|
|
2471
|
+
viewBox: `${-padding} ${-padding} ${qr.size + padding * 2} ${qr.size + padding * 2}`,
|
|
2472
|
+
shapeRendering: "crispEdges",
|
|
2473
|
+
className: "h-full w-full rounded-md",
|
|
2474
|
+
children: [
|
|
2475
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2476
|
+
"rect",
|
|
2477
|
+
{
|
|
2478
|
+
x: -padding,
|
|
2479
|
+
y: -padding,
|
|
2480
|
+
width: qr.size + padding * 2,
|
|
2481
|
+
height: qr.size + padding * 2,
|
|
2482
|
+
fill: backgroundColor
|
|
2483
|
+
}
|
|
2484
|
+
),
|
|
2485
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: qr.path, fill: foregroundColor })
|
|
2486
|
+
]
|
|
1181
2487
|
}
|
|
1182
|
-
) :
|
|
1183
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "h-5 w-5 animate-spin rounded-full border-2 border-white/20 border-t-white/80" }),
|
|
1184
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Generating QR\u2026" })
|
|
1185
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex h-full w-full items-center justify-center rounded-md bg-black/15 text-xs text-white/70", children: isUnavailable ? "QR unavailable" : "Generating QR\u2026" })
|
|
2488
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex h-full w-full items-center justify-center rounded-md bg-black/15 text-xs text-white/70", children: "QR unavailable" })
|
|
1186
2489
|
}
|
|
1187
2490
|
);
|
|
1188
2491
|
};
|
|
@@ -1195,7 +2498,7 @@ var shellFieldClassName = "h-11 min-w-0 w-full rounded-2xl border border-white/1
|
|
|
1195
2498
|
var shellUtilityButtonClassName = "rounded-2xl border-white/12 bg-white/[0.045] text-white/88 shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] hover:bg-white/[0.085] hover:text-white disabled:border-white/8 disabled:bg-white/[0.03] disabled:text-white/35";
|
|
1196
2499
|
|
|
1197
2500
|
// src/components/join-qr-overlay.tsx
|
|
1198
|
-
var
|
|
2501
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1199
2502
|
var JoinQrOverlay = ({
|
|
1200
2503
|
open,
|
|
1201
2504
|
value,
|
|
@@ -1221,8 +2524,8 @@ var JoinQrOverlay = ({
|
|
|
1221
2524
|
const joinUrlValue = value?.trim() ?? "";
|
|
1222
2525
|
const effectiveStatus = status === "ready" && joinUrlValue.length === 0 ? "unavailable" : status;
|
|
1223
2526
|
const overlaySize = `min(72vw, ${size}px)`;
|
|
1224
|
-
const [entered, setEntered] = (0,
|
|
1225
|
-
(0,
|
|
2527
|
+
const [entered, setEntered] = (0, import_react8.useState)(false);
|
|
2528
|
+
(0, import_react8.useEffect)(() => {
|
|
1226
2529
|
if (!open || typeof window === "undefined") {
|
|
1227
2530
|
return;
|
|
1228
2531
|
}
|
|
@@ -1236,7 +2539,7 @@ var JoinQrOverlay = ({
|
|
|
1236
2539
|
window.removeEventListener("keydown", handleKeyDown);
|
|
1237
2540
|
};
|
|
1238
2541
|
}, [onClose, open]);
|
|
1239
|
-
(0,
|
|
2542
|
+
(0, import_react8.useEffect)(() => {
|
|
1240
2543
|
if (!open || typeof window === "undefined") {
|
|
1241
2544
|
setEntered(false);
|
|
1242
2545
|
return;
|
|
@@ -1255,7 +2558,7 @@ var JoinQrOverlay = ({
|
|
|
1255
2558
|
const handlePanelClick = (event) => {
|
|
1256
2559
|
event.stopPropagation();
|
|
1257
2560
|
};
|
|
1258
|
-
const dialog = /* @__PURE__ */ (0,
|
|
2561
|
+
const dialog = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1259
2562
|
"div",
|
|
1260
2563
|
{
|
|
1261
2564
|
role: "dialog",
|
|
@@ -1267,7 +2570,7 @@ var JoinQrOverlay = ({
|
|
|
1267
2570
|
className
|
|
1268
2571
|
),
|
|
1269
2572
|
onClick: onClose,
|
|
1270
|
-
children: /* @__PURE__ */ (0,
|
|
2573
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1271
2574
|
"div",
|
|
1272
2575
|
{
|
|
1273
2576
|
className: cn(
|
|
@@ -1277,11 +2580,11 @@ var JoinQrOverlay = ({
|
|
|
1277
2580
|
),
|
|
1278
2581
|
onClick: handlePanelClick,
|
|
1279
2582
|
children: [
|
|
1280
|
-
/* @__PURE__ */ (0,
|
|
1281
|
-
/* @__PURE__ */ (0,
|
|
1282
|
-
roomId ? /* @__PURE__ */ (0,
|
|
2583
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "space-y-1", children: [
|
|
2584
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-[11px] tracking-[0.18em] text-slate-400 uppercase", children: roomLabel }),
|
|
2585
|
+
roomId ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-2xl font-semibold tracking-tight text-white tabular-nums", children: roomId }) : null
|
|
1283
2586
|
] }),
|
|
1284
|
-
effectiveStatus === "loading" ? /* @__PURE__ */ (0,
|
|
2587
|
+
effectiveStatus === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1285
2588
|
"div",
|
|
1286
2589
|
{
|
|
1287
2590
|
className: cn(
|
|
@@ -1294,11 +2597,11 @@ var JoinQrOverlay = ({
|
|
|
1294
2597
|
aspectRatio: "1 / 1"
|
|
1295
2598
|
},
|
|
1296
2599
|
children: [
|
|
1297
|
-
/* @__PURE__ */ (0,
|
|
1298
|
-
/* @__PURE__ */ (0,
|
|
2600
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "h-8 w-8 animate-spin rounded-full border-2 border-white/15 border-t-white/85" }),
|
|
2601
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: loadingLabel })
|
|
1299
2602
|
]
|
|
1300
2603
|
}
|
|
1301
|
-
) : effectiveStatus === "ready" ? /* @__PURE__ */ (0,
|
|
2604
|
+
) : effectiveStatus === "ready" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1302
2605
|
RoomQrCode,
|
|
1303
2606
|
{
|
|
1304
2607
|
value: joinUrlValue,
|
|
@@ -1317,7 +2620,7 @@ var JoinQrOverlay = ({
|
|
|
1317
2620
|
},
|
|
1318
2621
|
alt: qrAlt ?? (roomId ? `QR code to join room ${roomId}` : "QR code to join as a controller")
|
|
1319
2622
|
}
|
|
1320
|
-
) : /* @__PURE__ */ (0,
|
|
2623
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1321
2624
|
"div",
|
|
1322
2625
|
{
|
|
1323
2626
|
className: cn(
|
|
@@ -1332,7 +2635,7 @@ var JoinQrOverlay = ({
|
|
|
1332
2635
|
children: unavailableLabel
|
|
1333
2636
|
}
|
|
1334
2637
|
),
|
|
1335
|
-
/* @__PURE__ */ (0,
|
|
2638
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1336
2639
|
"p",
|
|
1337
2640
|
{
|
|
1338
2641
|
className: cn(
|
|
@@ -1342,7 +2645,7 @@ var JoinQrOverlay = ({
|
|
|
1342
2645
|
children: description
|
|
1343
2646
|
}
|
|
1344
2647
|
),
|
|
1345
|
-
showCloseButton ? /* @__PURE__ */ (0,
|
|
2648
|
+
showCloseButton ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1346
2649
|
Button,
|
|
1347
2650
|
{
|
|
1348
2651
|
type: "button",
|
|
@@ -1369,7 +2672,7 @@ var JoinQrOverlay = ({
|
|
|
1369
2672
|
|
|
1370
2673
|
// src/components/join-url-action-buttons.tsx
|
|
1371
2674
|
var import_lucide_react2 = require("lucide-react");
|
|
1372
|
-
var
|
|
2675
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1373
2676
|
var JoinUrlActionButtons = ({
|
|
1374
2677
|
hasValue,
|
|
1375
2678
|
copied = false,
|
|
@@ -1381,7 +2684,7 @@ var JoinUrlActionButtons = ({
|
|
|
1381
2684
|
buttonClassName
|
|
1382
2685
|
}) => {
|
|
1383
2686
|
const showsQrButton = typeof onToggleQr === "function";
|
|
1384
|
-
return /* @__PURE__ */ (0,
|
|
2687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1385
2688
|
"div",
|
|
1386
2689
|
{
|
|
1387
2690
|
className: cn(
|
|
@@ -1390,7 +2693,7 @@ var JoinUrlActionButtons = ({
|
|
|
1390
2693
|
className
|
|
1391
2694
|
),
|
|
1392
2695
|
children: [
|
|
1393
|
-
/* @__PURE__ */ (0,
|
|
2696
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1394
2697
|
Button,
|
|
1395
2698
|
{
|
|
1396
2699
|
type: "button",
|
|
@@ -1405,12 +2708,12 @@ var JoinUrlActionButtons = ({
|
|
|
1405
2708
|
buttonClassName
|
|
1406
2709
|
),
|
|
1407
2710
|
children: [
|
|
1408
|
-
copied ? /* @__PURE__ */ (0,
|
|
1409
|
-
/* @__PURE__ */ (0,
|
|
2711
|
+
copied ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Check, { className: "h-4 w-4", "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Copy, { className: "h-4 w-4", "aria-hidden": true }),
|
|
2712
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate", children: copied ? "Copied" : "Copy" })
|
|
1410
2713
|
]
|
|
1411
2714
|
}
|
|
1412
2715
|
),
|
|
1413
|
-
/* @__PURE__ */ (0,
|
|
2716
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1414
2717
|
Button,
|
|
1415
2718
|
{
|
|
1416
2719
|
type: "button",
|
|
@@ -1425,12 +2728,12 @@ var JoinUrlActionButtons = ({
|
|
|
1425
2728
|
buttonClassName
|
|
1426
2729
|
),
|
|
1427
2730
|
children: [
|
|
1428
|
-
/* @__PURE__ */ (0,
|
|
1429
|
-
/* @__PURE__ */ (0,
|
|
2731
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.ExternalLink, { className: "h-4 w-4", "aria-hidden": true }),
|
|
2732
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate", children: "New tab" })
|
|
1430
2733
|
]
|
|
1431
2734
|
}
|
|
1432
2735
|
),
|
|
1433
|
-
showsQrButton ? /* @__PURE__ */ (0,
|
|
2736
|
+
showsQrButton ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1434
2737
|
Button,
|
|
1435
2738
|
{
|
|
1436
2739
|
type: "button",
|
|
@@ -1446,8 +2749,8 @@ var JoinUrlActionButtons = ({
|
|
|
1446
2749
|
buttonClassName
|
|
1447
2750
|
),
|
|
1448
2751
|
children: [
|
|
1449
|
-
/* @__PURE__ */ (0,
|
|
1450
|
-
/* @__PURE__ */ (0,
|
|
2752
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.QrCode, { className: "h-4 w-4", "aria-hidden": true }),
|
|
2753
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate", children: qrVisible ? "Hide QR" : "QR code" })
|
|
1451
2754
|
]
|
|
1452
2755
|
}
|
|
1453
2756
|
) : null
|
|
@@ -1456,9 +2759,128 @@ var JoinUrlActionButtons = ({
|
|
|
1456
2759
|
);
|
|
1457
2760
|
};
|
|
1458
2761
|
|
|
2762
|
+
// src/runtime/controller-bridge-context.ts
|
|
2763
|
+
var import_zod26 = require("zod");
|
|
2764
|
+
|
|
2765
|
+
// src/runtime/arcade-surface-identity.ts
|
|
2766
|
+
var import_zod25 = require("zod");
|
|
2767
|
+
var arcadeSurfaceRuntimeIdentitySchema = import_zod25.z.object({
|
|
2768
|
+
epoch: import_zod25.z.number().int().nonnegative(),
|
|
2769
|
+
kind: import_zod25.z.enum(["browser", "game"]),
|
|
2770
|
+
gameId: import_zod25.z.string().nullable()
|
|
2771
|
+
}).strict();
|
|
2772
|
+
|
|
2773
|
+
// src/runtime/controller-bridge-context.ts
|
|
2774
|
+
var controllerBridgeContextSchema = import_zod26.z.union([
|
|
2775
|
+
import_zod26.z.object({ arcadeSurface: arcadeSurfaceRuntimeIdentitySchema }).strict(),
|
|
2776
|
+
import_zod26.z.object({ harnessSessionId: import_zod26.z.uuid() }).strict()
|
|
2777
|
+
]);
|
|
2778
|
+
function controllerBridgeContext(context) {
|
|
2779
|
+
return "arcadeSurface" in context ? { arcadeSurface: context.arcadeSurface } : { harnessSessionId: context.harnessSessionId };
|
|
2780
|
+
}
|
|
2781
|
+
function withControllerBridgeContext(shape) {
|
|
2782
|
+
return import_zod26.z.union([
|
|
2783
|
+
import_zod26.z.object({ ...shape, arcadeSurface: arcadeSurfaceRuntimeIdentitySchema }).strict(),
|
|
2784
|
+
import_zod26.z.object({ ...shape, harnessSessionId: import_zod26.z.uuid() }).strict()
|
|
2785
|
+
]);
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
// src/runtime/arcade-runtime-url.ts
|
|
2789
|
+
var parseOptionalArcadeSurfaceFromSearchParams = (params) => {
|
|
2790
|
+
const epochStr = params.get("aj_arcade_epoch");
|
|
2791
|
+
const kind = params.get("aj_arcade_kind");
|
|
2792
|
+
if (epochStr === null || kind !== "browser" && kind !== "game") {
|
|
2793
|
+
return void 0;
|
|
2794
|
+
}
|
|
2795
|
+
const epoch = Number(epochStr);
|
|
2796
|
+
if (!Number.isFinite(epoch) || epoch < 0 || !Number.isInteger(epoch)) {
|
|
2797
|
+
return void 0;
|
|
2798
|
+
}
|
|
2799
|
+
const gameIdRaw = params.get("aj_arcade_game_id");
|
|
2800
|
+
const gameId = kind === "browser" ? null : gameIdRaw && gameIdRaw.length > 0 ? gameIdRaw : null;
|
|
2801
|
+
return { epoch, kind, gameId };
|
|
2802
|
+
};
|
|
2803
|
+
|
|
2804
|
+
// src/runtime/runtime-session-params.ts
|
|
2805
|
+
var readChildHostRuntimeParams = () => {
|
|
2806
|
+
if (typeof window === "undefined") {
|
|
2807
|
+
return null;
|
|
2808
|
+
}
|
|
2809
|
+
const params = new URLSearchParams(window.location.search);
|
|
2810
|
+
const room = params.get("aj_room");
|
|
2811
|
+
if (!room) {
|
|
2812
|
+
return null;
|
|
2813
|
+
}
|
|
2814
|
+
const joinUrl = params.get("aj_join_url");
|
|
2815
|
+
const normalizedJoinUrl = joinUrl ? normalizeRuntimeUrl(joinUrl) : null;
|
|
2816
|
+
const topology = parseRuntimeTopologyFromSearchParams(params);
|
|
2817
|
+
if (!topology) {
|
|
2818
|
+
return null;
|
|
2819
|
+
}
|
|
2820
|
+
const arcadeSurface = parseOptionalArcadeSurfaceFromSearchParams(params);
|
|
2821
|
+
if (!arcadeSurface) {
|
|
2822
|
+
return null;
|
|
2823
|
+
}
|
|
2824
|
+
return {
|
|
2825
|
+
room,
|
|
2826
|
+
joinUrl: normalizedJoinUrl ?? void 0,
|
|
2827
|
+
topology,
|
|
2828
|
+
arcadeSurface
|
|
2829
|
+
};
|
|
2830
|
+
};
|
|
2831
|
+
var readEmbeddedControllerRuntimeParams = () => {
|
|
2832
|
+
if (typeof window === "undefined") {
|
|
2833
|
+
return null;
|
|
2834
|
+
}
|
|
2835
|
+
const params = new URLSearchParams(window.location.search);
|
|
2836
|
+
const room = params.get("aj_room");
|
|
2837
|
+
if (!room) {
|
|
2838
|
+
return null;
|
|
2839
|
+
}
|
|
2840
|
+
const topology = parseRuntimeTopologyFromSearchParams(params);
|
|
2841
|
+
if (!topology) {
|
|
2842
|
+
return null;
|
|
2843
|
+
}
|
|
2844
|
+
const harnessContext = params.has("aj_harness_session") ? controllerBridgeContextSchema.parse({
|
|
2845
|
+
harnessSessionId: params.get("aj_harness_session")
|
|
2846
|
+
}) : null;
|
|
2847
|
+
const context = controllerBridgeContextSchema.safeParse(
|
|
2848
|
+
harnessContext ? harnessContext : { arcadeSurface: parseOptionalArcadeSurfaceFromSearchParams(params) }
|
|
2849
|
+
);
|
|
2850
|
+
if (!context.success) {
|
|
2851
|
+
return null;
|
|
2852
|
+
}
|
|
2853
|
+
const rawLabel = params.get("aj_player_label")?.trim();
|
|
2854
|
+
const rawAvatarId = params.get("aj_player_avatar")?.trim();
|
|
2855
|
+
const playerProfile = rawLabel || rawAvatarId ? {
|
|
2856
|
+
...rawLabel ? { label: rawLabel } : {},
|
|
2857
|
+
...rawAvatarId ? { avatarId: rawAvatarId } : {}
|
|
2858
|
+
} : void 0;
|
|
2859
|
+
return {
|
|
2860
|
+
room,
|
|
2861
|
+
topology,
|
|
2862
|
+
...context.data,
|
|
2863
|
+
...playerProfile ? { playerProfile } : {}
|
|
2864
|
+
};
|
|
2865
|
+
};
|
|
2866
|
+
|
|
2867
|
+
// src/runtime/embedded-runtime-adapters.ts
|
|
2868
|
+
var readEmbeddedHostChildSession = () => {
|
|
2869
|
+
const raw = readChildHostRuntimeParams();
|
|
2870
|
+
if (!raw) {
|
|
2871
|
+
return null;
|
|
2872
|
+
}
|
|
2873
|
+
return {
|
|
2874
|
+
roomId: roomCodeSchema.parse(raw.room.toUpperCase()),
|
|
2875
|
+
joinUrl: raw.joinUrl,
|
|
2876
|
+
topology: raw.topology,
|
|
2877
|
+
arcadeSurface: raw.arcadeSurface
|
|
2878
|
+
};
|
|
2879
|
+
};
|
|
2880
|
+
|
|
1459
2881
|
// src/components/join-url-field.tsx
|
|
1460
|
-
var
|
|
1461
|
-
var
|
|
2882
|
+
var import_react9 = require("react");
|
|
2883
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1462
2884
|
var JoinUrlField = ({
|
|
1463
2885
|
value,
|
|
1464
2886
|
label = "Controller link",
|
|
@@ -1469,11 +2891,11 @@ var JoinUrlField = ({
|
|
|
1469
2891
|
inputName = "airjam-controller-link"
|
|
1470
2892
|
}) => {
|
|
1471
2893
|
const hasValue = Boolean(value && value.trim().length > 0);
|
|
1472
|
-
const generatedInputId = (0,
|
|
2894
|
+
const generatedInputId = (0, import_react9.useId)();
|
|
1473
2895
|
const resolvedInputId = inputId ?? generatedInputId;
|
|
1474
|
-
return /* @__PURE__ */ (0,
|
|
1475
|
-
/* @__PURE__ */ (0,
|
|
1476
|
-
/* @__PURE__ */ (0,
|
|
2896
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: cn("space-y-2.5", className), children: [
|
|
2897
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { className: shellLabelClassName, htmlFor: resolvedInputId, children: label }),
|
|
2898
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1477
2899
|
"input",
|
|
1478
2900
|
{
|
|
1479
2901
|
id: resolvedInputId,
|
|
@@ -1486,12 +2908,12 @@ var JoinUrlField = ({
|
|
|
1486
2908
|
className: cn(shellFieldClassName, inputClassName)
|
|
1487
2909
|
}
|
|
1488
2910
|
),
|
|
1489
|
-
helperText ? /* @__PURE__ */ (0,
|
|
2911
|
+
helperText ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: shellHelperTextClassName, children: helperText }) : null
|
|
1490
2912
|
] });
|
|
1491
2913
|
};
|
|
1492
2914
|
|
|
1493
2915
|
// src/components/join-url-controls.tsx
|
|
1494
|
-
var
|
|
2916
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1495
2917
|
var JoinUrlControls = ({
|
|
1496
2918
|
value,
|
|
1497
2919
|
label = "Controller link",
|
|
@@ -1505,9 +2927,10 @@ var JoinUrlControls = ({
|
|
|
1505
2927
|
inputClassName,
|
|
1506
2928
|
buttonClassName
|
|
1507
2929
|
}) => {
|
|
2930
|
+
if (readEmbeddedHostChildSession()) return null;
|
|
1508
2931
|
const hasValue = Boolean(value && value.trim().length > 0);
|
|
1509
|
-
return /* @__PURE__ */ (0,
|
|
1510
|
-
/* @__PURE__ */ (0,
|
|
2932
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: cn("w-full space-y-3", className), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
2933
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1511
2934
|
JoinUrlField,
|
|
1512
2935
|
{
|
|
1513
2936
|
value,
|
|
@@ -1517,7 +2940,7 @@ var JoinUrlControls = ({
|
|
|
1517
2940
|
inputClassName
|
|
1518
2941
|
}
|
|
1519
2942
|
),
|
|
1520
|
-
/* @__PURE__ */ (0,
|
|
2943
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1521
2944
|
JoinUrlActionButtons,
|
|
1522
2945
|
{
|
|
1523
2946
|
hasValue,
|
|
@@ -1593,7 +3016,7 @@ var useLifecycleActionGroupModel = ({
|
|
|
1593
3016
|
};
|
|
1594
3017
|
|
|
1595
3018
|
// src/components/lifecycle-action-group.tsx
|
|
1596
|
-
var
|
|
3019
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1597
3020
|
var LifecycleActionGroup = ({
|
|
1598
3021
|
phase,
|
|
1599
3022
|
runtimeState,
|
|
@@ -1629,23 +3052,23 @@ var LifecycleActionGroup = ({
|
|
|
1629
3052
|
const renderIcon = (kind, label) => {
|
|
1630
3053
|
switch (kind) {
|
|
1631
3054
|
case "start":
|
|
1632
|
-
return /* @__PURE__ */ (0,
|
|
3055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.Play, { "aria-hidden": true, className: "size-4.5" });
|
|
1633
3056
|
case "pause-toggle":
|
|
1634
|
-
return label.toLowerCase() === "resume" ? /* @__PURE__ */ (0,
|
|
3057
|
+
return label.toLowerCase() === "resume" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.Play, { "aria-hidden": true, className: "size-4.5" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.Pause, { "aria-hidden": true, className: "size-4.5" });
|
|
1635
3058
|
case "restart":
|
|
1636
|
-
return /* @__PURE__ */ (0,
|
|
3059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.RotateCcw, { "aria-hidden": true, className: "size-4.5" });
|
|
1637
3060
|
case "back-to-lobby":
|
|
1638
|
-
return /* @__PURE__ */ (0,
|
|
3061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.House, { "aria-hidden": true, className: "size-4.5" });
|
|
1639
3062
|
}
|
|
1640
3063
|
};
|
|
1641
|
-
return /* @__PURE__ */ (0,
|
|
3064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1642
3065
|
"div",
|
|
1643
3066
|
{
|
|
1644
3067
|
className: cn(
|
|
1645
3068
|
"flex min-w-0 flex-nowrap items-center justify-end gap-1.5 overflow-x-auto",
|
|
1646
3069
|
className
|
|
1647
3070
|
),
|
|
1648
|
-
children: actions.map((action) => /* @__PURE__ */ (0,
|
|
3071
|
+
children: actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1649
3072
|
Button,
|
|
1650
3073
|
{
|
|
1651
3074
|
type: "button",
|
|
@@ -1669,6 +3092,7 @@ var LifecycleActionGroup = ({
|
|
|
1669
3092
|
|
|
1670
3093
|
// src/components/player-avatar.tsx
|
|
1671
3094
|
var import_lucide_react4 = require("lucide-react");
|
|
3095
|
+
var import_react10 = require("react");
|
|
1672
3096
|
|
|
1673
3097
|
// src/utils/player-avatar-url.ts
|
|
1674
3098
|
var DIEBEAR_ADVENTURER_NEUTRAL_SVG_BASE = "https://api.dicebear.com/9.x/adventurer-neutral/svg";
|
|
@@ -1700,7 +3124,7 @@ var getDiceBearAdventurerNeutralUrl = (seed) => `${DIEBEAR_ADVENTURER_NEUTRAL_SV
|
|
|
1700
3124
|
var getPlayerAvatarImageUrl = (player) => getDiceBearAdventurerNeutralUrl(resolvePlayerAvatarSeed(player));
|
|
1701
3125
|
|
|
1702
3126
|
// src/components/player-avatar.tsx
|
|
1703
|
-
var
|
|
3127
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1704
3128
|
var hexToRgba = (hex, opacity) => {
|
|
1705
3129
|
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
1706
3130
|
if (!result) return `rgba(0, 0, 0, ${opacity})`;
|
|
@@ -1715,6 +3139,7 @@ var PlayerAvatar = ({
|
|
|
1715
3139
|
size = "md",
|
|
1716
3140
|
className = ""
|
|
1717
3141
|
}) => {
|
|
3142
|
+
const [failedSrc, setFailedSrc] = (0, import_react10.useState)(null);
|
|
1718
3143
|
const accentColor = player.color || "hsl(var(--border))";
|
|
1719
3144
|
const sizeClasses = {
|
|
1720
3145
|
sm: "h-9 w-9 border-2",
|
|
@@ -1737,7 +3162,7 @@ var PlayerAvatar = ({
|
|
|
1737
3162
|
className
|
|
1738
3163
|
);
|
|
1739
3164
|
if (isBot) {
|
|
1740
|
-
return /* @__PURE__ */ (0,
|
|
3165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1741
3166
|
"div",
|
|
1742
3167
|
{
|
|
1743
3168
|
role: "img",
|
|
@@ -1751,518 +3176,147 @@ var PlayerAvatar = ({
|
|
|
1751
3176
|
color: accentColor,
|
|
1752
3177
|
boxShadow: shadowStyles[size]
|
|
1753
3178
|
},
|
|
1754
|
-
children: /* @__PURE__ */ (0,
|
|
3179
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Bot, { "aria-hidden": "true", className: iconSizeClasses[size] })
|
|
1755
3180
|
}
|
|
1756
3181
|
);
|
|
1757
3182
|
}
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
alt: player.label,
|
|
1763
|
-
className: cn("bg-secondary/30", shellClassName),
|
|
1764
|
-
style: {
|
|
1765
|
-
borderColor: accentColor,
|
|
1766
|
-
boxShadow: shadowStyles[size]
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
);
|
|
1770
|
-
};
|
|
1771
|
-
|
|
1772
|
-
// src/components/player-avatar-strip.tsx
|
|
1773
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1774
|
-
var overflowSizeClasses = {
|
|
1775
|
-
sm: "h-9 w-9 min-h-9 min-w-9 text-[0.625rem]",
|
|
1776
|
-
md: "h-12 w-12 min-h-12 min-w-12 text-[11px]",
|
|
1777
|
-
lg: "h-16 w-16 min-h-16 min-w-16 text-xs"
|
|
1778
|
-
};
|
|
1779
|
-
var PlayerAvatarStrip = ({
|
|
1780
|
-
players,
|
|
1781
|
-
maxVisible = 4,
|
|
1782
|
-
size = "sm",
|
|
1783
|
-
className,
|
|
1784
|
-
avatarClassName = "",
|
|
1785
|
-
overflowBadgeClassName = ""
|
|
1786
|
-
}) => {
|
|
1787
|
-
const visible = players.slice(0, maxVisible);
|
|
1788
|
-
const overflow = Math.max(0, players.length - maxVisible);
|
|
1789
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: cn("flex items-center -space-x-2", className), children: [
|
|
1790
|
-
visible.map((player) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1791
|
-
PlayerAvatar,
|
|
1792
|
-
{
|
|
1793
|
-
player,
|
|
1794
|
-
size,
|
|
1795
|
-
className: avatarClassName
|
|
1796
|
-
},
|
|
1797
|
-
player.id
|
|
1798
|
-
)),
|
|
1799
|
-
overflow > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
3183
|
+
const src = getPlayerAvatarImageUrl(player);
|
|
3184
|
+
if (failedSrc === src) {
|
|
3185
|
+
const initials = playerInitials(player.label);
|
|
3186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1800
3187
|
"div",
|
|
1801
3188
|
{
|
|
3189
|
+
role: "img",
|
|
3190
|
+
"aria-label": player.label,
|
|
1802
3191
|
className: cn(
|
|
1803
|
-
"bg-secondary/
|
|
1804
|
-
|
|
1805
|
-
|
|
3192
|
+
"bg-secondary/40 flex items-center justify-center font-semibold uppercase",
|
|
3193
|
+
initialsSizeClasses[size],
|
|
3194
|
+
shellClassName
|
|
1806
3195
|
),
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
3196
|
+
style: {
|
|
3197
|
+
borderColor: accentColor,
|
|
3198
|
+
color: accentColor,
|
|
3199
|
+
boxShadow: shadowStyles[size]
|
|
3200
|
+
},
|
|
3201
|
+
children: initials ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "aria-hidden": "true", children: initials }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.UserRound, { "aria-hidden": "true", className: iconSizeClasses[size] })
|
|
1812
3202
|
}
|
|
1813
|
-
)
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
children: [
|
|
1834
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "min-w-0 flex-1", children: leftSlot }),
|
|
1835
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex shrink-0 items-center gap-2.5", children: [
|
|
1836
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ConnectionStatusPill, { status: connectionStatus }),
|
|
1837
|
-
rightSlot ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex items-center justify-end", children: rightSlot }) : null
|
|
1838
|
-
] })
|
|
1839
|
-
]
|
|
1840
|
-
}
|
|
1841
|
-
);
|
|
1842
|
-
};
|
|
1843
|
-
|
|
1844
|
-
// src/components/surface-viewport.tsx
|
|
1845
|
-
var import_react9 = require("react");
|
|
1846
|
-
|
|
1847
|
-
// src/runtime/controller-bridge.ts
|
|
1848
|
-
var import_zod11 = require("zod");
|
|
1849
|
-
|
|
1850
|
-
// src/contracts/v2/bridge.ts
|
|
1851
|
-
var import_zod7 = require("zod");
|
|
1852
|
-
var roomCodeSchema2 = import_zod7.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, {
|
|
1853
|
-
message: "room code must contain only A-Z or 0-9"
|
|
1854
|
-
});
|
|
1855
|
-
var runtimeStateSchema = import_zod7.z.enum(["paused", "playing"]);
|
|
1856
|
-
var playerProfileSchema = import_zod7.z.object({
|
|
1857
|
-
id: import_zod7.z.string().min(1),
|
|
1858
|
-
label: import_zod7.z.string().min(1),
|
|
1859
|
-
color: import_zod7.z.string().optional(),
|
|
1860
|
-
avatarId: import_zod7.z.string().optional()
|
|
1861
|
-
}).strict();
|
|
1862
|
-
var inputFrameEntrySchema = import_zod7.z.object({
|
|
1863
|
-
controllerId: import_zod7.z.string().min(1),
|
|
1864
|
-
input: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown())
|
|
1865
|
-
}).strict();
|
|
1866
|
-
var V2_BRIDGE_PARENT_TO_GAME_TYPES = [
|
|
1867
|
-
"BOOTSTRAP",
|
|
1868
|
-
"PLAYERS_UPDATE",
|
|
1869
|
-
"RUNTIME_STATE_UPDATE",
|
|
1870
|
-
"INPUT_FRAME",
|
|
1871
|
-
"PAUSE",
|
|
1872
|
-
"RESUME",
|
|
1873
|
-
"SHUTDOWN"
|
|
1874
|
-
];
|
|
1875
|
-
var V2_BRIDGE_GAME_TO_PARENT_TYPES = [
|
|
1876
|
-
"READY",
|
|
1877
|
-
"STATE_PATCH",
|
|
1878
|
-
"SIGNAL",
|
|
1879
|
-
"ERROR",
|
|
1880
|
-
"METRICS"
|
|
1881
|
-
];
|
|
1882
|
-
var allMessageTypes = [
|
|
1883
|
-
...V2_BRIDGE_PARENT_TO_GAME_TYPES,
|
|
1884
|
-
...V2_BRIDGE_GAME_TO_PARENT_TYPES
|
|
1885
|
-
];
|
|
1886
|
-
var knownBridgeMessageTypeSet = new Set(allMessageTypes);
|
|
1887
|
-
var bootstrapMessageSchema = import_zod7.z.object({
|
|
1888
|
-
type: import_zod7.z.literal("BOOTSTRAP"),
|
|
1889
|
-
payload: import_zod7.z.object({
|
|
1890
|
-
roomId: roomCodeSchema2,
|
|
1891
|
-
players: import_zod7.z.array(playerProfileSchema),
|
|
1892
|
-
state: import_zod7.z.object({
|
|
1893
|
-
runtimeState: runtimeStateSchema,
|
|
1894
|
-
message: import_zod7.z.string().optional()
|
|
1895
|
-
}).strict(),
|
|
1896
|
-
capabilities: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.boolean()).default({})
|
|
1897
|
-
}).strict()
|
|
1898
|
-
}).strict();
|
|
1899
|
-
var playersUpdateMessageSchema = import_zod7.z.object({
|
|
1900
|
-
type: import_zod7.z.literal("PLAYERS_UPDATE"),
|
|
1901
|
-
payload: import_zod7.z.object({
|
|
1902
|
-
players: import_zod7.z.array(playerProfileSchema)
|
|
1903
|
-
}).strict()
|
|
1904
|
-
}).strict();
|
|
1905
|
-
var runtimeStateUpdateMessageSchema = import_zod7.z.object({
|
|
1906
|
-
type: import_zod7.z.literal("RUNTIME_STATE_UPDATE"),
|
|
1907
|
-
payload: import_zod7.z.object({
|
|
1908
|
-
runtimeState: runtimeStateSchema,
|
|
1909
|
-
message: import_zod7.z.string().optional()
|
|
1910
|
-
}).strict()
|
|
1911
|
-
}).strict();
|
|
1912
|
-
var inputFrameMessageSchema = import_zod7.z.object({
|
|
1913
|
-
type: import_zod7.z.literal("INPUT_FRAME"),
|
|
1914
|
-
payload: import_zod7.z.object({
|
|
1915
|
-
frameId: import_zod7.z.number().int().nonnegative(),
|
|
1916
|
-
inputs: import_zod7.z.array(inputFrameEntrySchema)
|
|
1917
|
-
}).strict()
|
|
1918
|
-
}).strict();
|
|
1919
|
-
var pauseMessageSchema = import_zod7.z.object({
|
|
1920
|
-
type: import_zod7.z.literal("PAUSE"),
|
|
1921
|
-
payload: import_zod7.z.object({
|
|
1922
|
-
reason: import_zod7.z.string().optional()
|
|
1923
|
-
}).strict()
|
|
1924
|
-
}).strict();
|
|
1925
|
-
var resumeMessageSchema = import_zod7.z.object({
|
|
1926
|
-
type: import_zod7.z.literal("RESUME"),
|
|
1927
|
-
payload: import_zod7.z.object({}).strict()
|
|
1928
|
-
}).strict();
|
|
1929
|
-
var shutdownMessageSchema = import_zod7.z.object({
|
|
1930
|
-
type: import_zod7.z.literal("SHUTDOWN"),
|
|
1931
|
-
payload: import_zod7.z.object({
|
|
1932
|
-
reason: import_zod7.z.string().min(1)
|
|
1933
|
-
}).strict()
|
|
1934
|
-
}).strict();
|
|
1935
|
-
var readyMessageSchema = import_zod7.z.object({
|
|
1936
|
-
type: import_zod7.z.literal("READY"),
|
|
1937
|
-
payload: import_zod7.z.object({
|
|
1938
|
-
readyAtMs: import_zod7.z.number().int().nonnegative()
|
|
1939
|
-
}).strict()
|
|
1940
|
-
}).strict();
|
|
1941
|
-
var statePatchMessageSchema = import_zod7.z.object({
|
|
1942
|
-
type: import_zod7.z.literal("STATE_PATCH"),
|
|
1943
|
-
payload: import_zod7.z.object({
|
|
1944
|
-
patch: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown())
|
|
1945
|
-
}).strict()
|
|
1946
|
-
}).strict();
|
|
1947
|
-
var signalMessageSchema = import_zod7.z.object({
|
|
1948
|
-
type: import_zod7.z.literal("SIGNAL"),
|
|
1949
|
-
payload: import_zod7.z.object({
|
|
1950
|
-
signalType: import_zod7.z.string().min(1),
|
|
1951
|
-
targetId: import_zod7.z.string().min(1).optional(),
|
|
1952
|
-
data: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown())
|
|
1953
|
-
}).strict()
|
|
1954
|
-
}).strict();
|
|
1955
|
-
var errorMessageSchema = import_zod7.z.object({
|
|
1956
|
-
type: import_zod7.z.literal("ERROR"),
|
|
1957
|
-
payload: import_zod7.z.object({
|
|
1958
|
-
code: import_zod7.z.string().min(1),
|
|
1959
|
-
message: import_zod7.z.string().min(1),
|
|
1960
|
-
details: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown()).optional()
|
|
1961
|
-
}).strict()
|
|
1962
|
-
}).strict();
|
|
1963
|
-
var metricsMessageSchema = import_zod7.z.object({
|
|
1964
|
-
type: import_zod7.z.literal("METRICS"),
|
|
1965
|
-
payload: import_zod7.z.object({
|
|
1966
|
-
values: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.number())
|
|
1967
|
-
}).strict()
|
|
1968
|
-
}).strict();
|
|
1969
|
-
var v2BridgeParentToGameMessageSchema = import_zod7.z.union([
|
|
1970
|
-
bootstrapMessageSchema,
|
|
1971
|
-
playersUpdateMessageSchema,
|
|
1972
|
-
runtimeStateUpdateMessageSchema,
|
|
1973
|
-
inputFrameMessageSchema,
|
|
1974
|
-
pauseMessageSchema,
|
|
1975
|
-
resumeMessageSchema,
|
|
1976
|
-
shutdownMessageSchema
|
|
1977
|
-
]);
|
|
1978
|
-
var v2BridgeGameToParentMessageSchema = import_zod7.z.union([
|
|
1979
|
-
readyMessageSchema,
|
|
1980
|
-
statePatchMessageSchema,
|
|
1981
|
-
signalMessageSchema,
|
|
1982
|
-
errorMessageSchema,
|
|
1983
|
-
metricsMessageSchema
|
|
1984
|
-
]);
|
|
1985
|
-
var v2BridgeMessageSchema = import_zod7.z.union([
|
|
1986
|
-
v2BridgeParentToGameMessageSchema,
|
|
1987
|
-
v2BridgeGameToParentMessageSchema
|
|
1988
|
-
]);
|
|
1989
|
-
|
|
1990
|
-
// src/contracts/v2/handshake.ts
|
|
1991
|
-
var import_zod8 = require("zod");
|
|
1992
|
-
var AIR_JAM_PROTOCOL_V2 = "2";
|
|
1993
|
-
var semanticVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1994
|
-
var v2ProtocolVersionSchema = import_zod8.z.literal(AIR_JAM_PROTOCOL_V2);
|
|
1995
|
-
var runtimeKindSchema = import_zod8.z.enum([
|
|
1996
|
-
"standalone-host",
|
|
1997
|
-
"standalone-controller",
|
|
1998
|
-
"arcade-runtime",
|
|
1999
|
-
"arcade-game-iframe",
|
|
2000
|
-
"arcade-host-runtime",
|
|
2001
|
-
"arcade-host-iframe",
|
|
2002
|
-
"arcade-controller-runtime",
|
|
2003
|
-
"arcade-controller-iframe"
|
|
2004
|
-
]);
|
|
2005
|
-
var capabilityFlagsSchema = import_zod8.z.record(import_zod8.z.string(), import_zod8.z.boolean());
|
|
2006
|
-
var sdkVersionSchema = import_zod8.z.string().regex(
|
|
2007
|
-
semanticVersionPattern,
|
|
2008
|
-
"sdkVersion must use semantic version format (for example 1.2.3)"
|
|
2009
|
-
);
|
|
2010
|
-
var v2HandshakeSchema = import_zod8.z.object({
|
|
2011
|
-
protocolVersion: v2ProtocolVersionSchema,
|
|
2012
|
-
sdkVersion: sdkVersionSchema,
|
|
2013
|
-
runtimeKind: runtimeKindSchema,
|
|
2014
|
-
capabilityFlags: capabilityFlagsSchema.default({})
|
|
2015
|
-
}).strict();
|
|
2016
|
-
|
|
2017
|
-
// src/runtime/arcade-surface-identity.ts
|
|
2018
|
-
var import_zod9 = require("zod");
|
|
2019
|
-
var arcadeSurfaceRuntimeIdentitySchema = import_zod9.z.object({
|
|
2020
|
-
epoch: import_zod9.z.number().int().nonnegative(),
|
|
2021
|
-
kind: import_zod9.z.enum(["browser", "game"]),
|
|
2022
|
-
gameId: import_zod9.z.string().nullable()
|
|
2023
|
-
}).strict();
|
|
2024
|
-
|
|
2025
|
-
// src/runtime/iframe-bridge.ts
|
|
2026
|
-
var import_zod10 = require("zod");
|
|
2027
|
-
var AIRJAM_BRIDGE_INIT = "AIRJAM_BRIDGE_INIT";
|
|
2028
|
-
var AIRJAM_SETTINGS_SYNC = "AIRJAM_SETTINGS_SYNC";
|
|
2029
|
-
var AIRJAM_SETTINGS_READY = "AIRJAM_SETTINGS_READY";
|
|
2030
|
-
var airJamSettingsSyncSchema = import_zod10.z.object({
|
|
2031
|
-
type: import_zod10.z.literal(AIRJAM_SETTINGS_SYNC),
|
|
2032
|
-
payload: import_zod10.z.object({
|
|
2033
|
-
settings: import_zod10.z.object({
|
|
2034
|
-
audio: import_zod10.z.object({
|
|
2035
|
-
masterVolume: import_zod10.z.number(),
|
|
2036
|
-
musicVolume: import_zod10.z.number(),
|
|
2037
|
-
sfxVolume: import_zod10.z.number()
|
|
2038
|
-
}).strict(),
|
|
2039
|
-
accessibility: import_zod10.z.object({
|
|
2040
|
-
reducedMotion: import_zod10.z.boolean(),
|
|
2041
|
-
highContrast: import_zod10.z.boolean()
|
|
2042
|
-
}).strict(),
|
|
2043
|
-
feedback: import_zod10.z.object({
|
|
2044
|
-
hapticsEnabled: import_zod10.z.boolean()
|
|
2045
|
-
}).strict(),
|
|
2046
|
-
previewControllers: import_zod10.z.object({
|
|
2047
|
-
activeOpacity: import_zod10.z.number()
|
|
2048
|
-
}).strict()
|
|
2049
|
-
}).strict()
|
|
2050
|
-
}).strict()
|
|
2051
|
-
}).strict();
|
|
2052
|
-
var airJamBridgeInitSchema = import_zod10.z.object({
|
|
2053
|
-
type: import_zod10.z.literal(AIRJAM_BRIDGE_INIT),
|
|
2054
|
-
payload: import_zod10.z.object({
|
|
2055
|
-
handshake: v2HandshakeSchema
|
|
2056
|
-
}).strict()
|
|
2057
|
-
}).strict();
|
|
2058
|
-
var airJamSettingsReadySchema = import_zod10.z.object({
|
|
2059
|
-
type: import_zod10.z.literal(AIRJAM_SETTINGS_READY),
|
|
2060
|
-
payload: import_zod10.z.object({
|
|
2061
|
-
ready: import_zod10.z.literal(true)
|
|
2062
|
-
}).strict()
|
|
2063
|
-
}).strict();
|
|
2064
|
-
|
|
2065
|
-
// src/runtime/controller-bridge.ts
|
|
2066
|
-
var AIRJAM_CONTROLLER_BRIDGE_REQUEST = "AIRJAM_CONTROLLER_BRIDGE_REQUEST";
|
|
2067
|
-
var AIRJAM_CONTROLLER_BRIDGE_ATTACH = "AIRJAM_CONTROLLER_BRIDGE_ATTACH";
|
|
2068
|
-
var AIRJAM_CONTROLLER_BRIDGE_EVENT = "AIRJAM_CONTROLLER_BRIDGE_EVENT";
|
|
2069
|
-
var AIRJAM_CONTROLLER_BRIDGE_EMIT = "AIRJAM_CONTROLLER_BRIDGE_EMIT";
|
|
2070
|
-
var AIRJAM_CONTROLLER_BRIDGE_CLOSE = "AIRJAM_CONTROLLER_BRIDGE_CLOSE";
|
|
2071
|
-
var AIRJAM_CONTROLLER_PRESENTATION_SYNC = "AIRJAM_CONTROLLER_PRESENTATION_SYNC";
|
|
2072
|
-
var AIRJAM_CONTROLLER_BRIDGE_RESPONSE = "AIRJAM_CONTROLLER_BRIDGE_RESPONSE";
|
|
2073
|
-
var controllerBridgeClientEvents = [
|
|
2074
|
-
"controller:input",
|
|
2075
|
-
"controller:action_rpc",
|
|
2076
|
-
"controller:state_sync_request",
|
|
2077
|
-
"controller:system",
|
|
2078
|
-
"controller:play_sound",
|
|
2079
|
-
"controller:updatePlayerProfile"
|
|
2080
|
-
];
|
|
2081
|
-
var controllerBridgeServerEvents = [
|
|
2082
|
-
"connect",
|
|
2083
|
-
"disconnect",
|
|
2084
|
-
"server:welcome",
|
|
2085
|
-
"server:controllerJoined",
|
|
2086
|
-
"server:controllerLeft",
|
|
2087
|
-
"server:state",
|
|
2088
|
-
"server:hostLeft",
|
|
2089
|
-
"server:error",
|
|
2090
|
-
"server:signal",
|
|
2091
|
-
"server:playSound",
|
|
2092
|
-
"server:playerUpdated",
|
|
2093
|
-
"airjam:state_sync"
|
|
2094
|
-
];
|
|
2095
|
-
var bridgeRequestSchema = import_zod11.z.object({
|
|
2096
|
-
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_REQUEST),
|
|
2097
|
-
payload: import_zod11.z.object({
|
|
2098
|
-
handshake: v2HandshakeSchema,
|
|
2099
|
-
roomId: import_zod11.z.string().min(1),
|
|
2100
|
-
controllerId: import_zod11.z.string().min(1),
|
|
2101
|
-
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema
|
|
2102
|
-
}).strict()
|
|
2103
|
-
}).strict();
|
|
2104
|
-
var bridgeAttachSchema = import_zod11.z.object({
|
|
2105
|
-
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_ATTACH),
|
|
2106
|
-
payload: import_zod11.z.object({
|
|
2107
|
-
handshake: v2HandshakeSchema,
|
|
2108
|
-
snapshot: import_zod11.z.object({
|
|
2109
|
-
roomId: import_zod11.z.string().min(1),
|
|
2110
|
-
controllerId: import_zod11.z.string().min(1),
|
|
2111
|
-
connected: import_zod11.z.boolean(),
|
|
2112
|
-
socketId: import_zod11.z.string().optional(),
|
|
2113
|
-
player: import_zod11.z.unknown().optional(),
|
|
2114
|
-
players: import_zod11.z.array(import_zod11.z.unknown()).optional(),
|
|
2115
|
-
state: import_zod11.z.unknown().optional(),
|
|
2116
|
-
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema
|
|
2117
|
-
}).strict()
|
|
2118
|
-
}).strict()
|
|
2119
|
-
}).strict();
|
|
2120
|
-
var bridgeEventSchema = import_zod11.z.object({
|
|
2121
|
-
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_EVENT),
|
|
2122
|
-
payload: import_zod11.z.object({
|
|
2123
|
-
event: import_zod11.z.enum(controllerBridgeServerEvents),
|
|
2124
|
-
args: import_zod11.z.array(import_zod11.z.unknown()),
|
|
2125
|
-
requestId: import_zod11.z.string().min(1).optional()
|
|
2126
|
-
}).strict()
|
|
2127
|
-
}).strict();
|
|
2128
|
-
var bridgeEmitSchema = import_zod11.z.object({
|
|
2129
|
-
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_EMIT),
|
|
2130
|
-
payload: import_zod11.z.object({
|
|
2131
|
-
event: import_zod11.z.enum(controllerBridgeClientEvents),
|
|
2132
|
-
args: import_zod11.z.array(import_zod11.z.unknown()),
|
|
2133
|
-
requestId: import_zod11.z.string().min(1).optional()
|
|
2134
|
-
}).strict()
|
|
2135
|
-
}).strict();
|
|
2136
|
-
var bridgeResponseSchema = import_zod11.z.object({
|
|
2137
|
-
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_RESPONSE),
|
|
2138
|
-
payload: import_zod11.z.object({
|
|
2139
|
-
requestId: import_zod11.z.string().min(1),
|
|
2140
|
-
ack: import_zod11.z.unknown()
|
|
2141
|
-
}).strict()
|
|
2142
|
-
}).strict();
|
|
2143
|
-
var bridgeCloseSchema = import_zod11.z.object({
|
|
2144
|
-
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_CLOSE),
|
|
2145
|
-
payload: import_zod11.z.object({
|
|
2146
|
-
reason: import_zod11.z.string().optional()
|
|
2147
|
-
}).strict()
|
|
2148
|
-
}).strict();
|
|
2149
|
-
var presentationSyncSchema = import_zod11.z.object({
|
|
2150
|
-
type: import_zod11.z.literal(AIRJAM_CONTROLLER_PRESENTATION_SYNC),
|
|
2151
|
-
payload: import_zod11.z.object({
|
|
2152
|
-
orientation: controllerOrientationSchema,
|
|
2153
|
-
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema
|
|
2154
|
-
}).strict()
|
|
2155
|
-
}).strict();
|
|
2156
|
-
var createControllerPresentationSyncMessage = (payload) => ({
|
|
2157
|
-
type: AIRJAM_CONTROLLER_PRESENTATION_SYNC,
|
|
2158
|
-
payload
|
|
2159
|
-
});
|
|
2160
|
-
|
|
2161
|
-
// src/runtime/arcade-runtime-url.ts
|
|
2162
|
-
var parseOptionalArcadeSurfaceFromSearchParams = (params) => {
|
|
2163
|
-
const epochStr = params.get("aj_arcade_epoch");
|
|
2164
|
-
const kind = params.get("aj_arcade_kind");
|
|
2165
|
-
if (epochStr === null || kind !== "browser" && kind !== "game") {
|
|
2166
|
-
return void 0;
|
|
2167
|
-
}
|
|
2168
|
-
const epoch = Number(epochStr);
|
|
2169
|
-
if (!Number.isFinite(epoch) || epoch < 0 || !Number.isInteger(epoch)) {
|
|
2170
|
-
return void 0;
|
|
2171
|
-
}
|
|
2172
|
-
const gameIdRaw = params.get("aj_arcade_game_id");
|
|
2173
|
-
const gameId = kind === "browser" ? null : gameIdRaw && gameIdRaw.length > 0 ? gameIdRaw : null;
|
|
2174
|
-
return { epoch, kind, gameId };
|
|
3203
|
+
);
|
|
3204
|
+
}
|
|
3205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3206
|
+
"img",
|
|
3207
|
+
{
|
|
3208
|
+
src,
|
|
3209
|
+
alt: player.label,
|
|
3210
|
+
onError: () => setFailedSrc(src),
|
|
3211
|
+
className: cn("bg-secondary/30", shellClassName),
|
|
3212
|
+
style: {
|
|
3213
|
+
borderColor: accentColor,
|
|
3214
|
+
boxShadow: shadowStyles[size]
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
);
|
|
3218
|
+
};
|
|
3219
|
+
var initialsSizeClasses = {
|
|
3220
|
+
sm: "text-xs",
|
|
3221
|
+
md: "text-sm",
|
|
3222
|
+
lg: "text-base"
|
|
2175
3223
|
};
|
|
3224
|
+
var playerInitials = (label) => label.trim().split(/\s+/).filter(Boolean).slice(0, 2).map((word) => Array.from(word)[0] ?? "").join("");
|
|
2176
3225
|
|
|
2177
|
-
// src/
|
|
2178
|
-
var
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
return new URL(value).origin;
|
|
2184
|
-
} catch {
|
|
2185
|
-
return null;
|
|
2186
|
-
}
|
|
3226
|
+
// src/components/player-avatar-strip.tsx
|
|
3227
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3228
|
+
var overflowSizeClasses = {
|
|
3229
|
+
sm: "h-9 w-9 min-h-9 min-w-9 text-[0.625rem]",
|
|
3230
|
+
md: "h-12 w-12 min-h-12 min-w-12 text-[11px]",
|
|
3231
|
+
lg: "h-16 w-16 min-h-16 min-w-16 text-xs"
|
|
2187
3232
|
};
|
|
2188
|
-
var
|
|
2189
|
-
|
|
2190
|
-
|
|
3233
|
+
var PlayerAvatarStrip = ({
|
|
3234
|
+
players,
|
|
3235
|
+
maxVisible = 4,
|
|
3236
|
+
size = "sm",
|
|
3237
|
+
className,
|
|
3238
|
+
avatarClassName = "",
|
|
3239
|
+
overflowBadgeClassName = ""
|
|
2191
3240
|
}) => {
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
3241
|
+
const visible = players.slice(0, maxVisible);
|
|
3242
|
+
const overflow = Math.max(0, players.length - maxVisible);
|
|
3243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: cn("flex items-center -space-x-2", className), children: [
|
|
3244
|
+
visible.map((player) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3245
|
+
PlayerAvatar,
|
|
3246
|
+
{
|
|
3247
|
+
player,
|
|
3248
|
+
size,
|
|
3249
|
+
className: avatarClassName
|
|
3250
|
+
},
|
|
3251
|
+
player.id
|
|
3252
|
+
)),
|
|
3253
|
+
overflow > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3254
|
+
"div",
|
|
3255
|
+
{
|
|
3256
|
+
className: cn(
|
|
3257
|
+
"bg-secondary/50 text-foreground flex shrink-0 items-center justify-center rounded-full border-2 border-[hsl(var(--border))] font-semibold tabular-nums shadow-sm",
|
|
3258
|
+
overflowSizeClasses[size],
|
|
3259
|
+
overflowBadgeClassName
|
|
3260
|
+
),
|
|
3261
|
+
"aria-label": `${overflow} more players`,
|
|
3262
|
+
children: [
|
|
3263
|
+
"+",
|
|
3264
|
+
overflow
|
|
3265
|
+
]
|
|
3266
|
+
}
|
|
3267
|
+
)
|
|
3268
|
+
] });
|
|
2214
3269
|
};
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
return {
|
|
2242
|
-
room,
|
|
2243
|
-
controllerId,
|
|
2244
|
-
topology,
|
|
2245
|
-
arcadeSurface,
|
|
2246
|
-
...playerProfile ? { playerProfile } : {}
|
|
2247
|
-
};
|
|
3270
|
+
|
|
3271
|
+
// src/components/runtime-shell-header.tsx
|
|
3272
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3273
|
+
var RuntimeShellHeader = ({
|
|
3274
|
+
connectionStatus,
|
|
3275
|
+
leftSlot,
|
|
3276
|
+
rightSlot,
|
|
3277
|
+
className
|
|
3278
|
+
}) => {
|
|
3279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3280
|
+
"header",
|
|
3281
|
+
{
|
|
3282
|
+
className: cn(
|
|
3283
|
+
"flex min-h-16 items-center gap-2.5 px-3 py-2.5 sm:px-4",
|
|
3284
|
+
shellHeaderClassName,
|
|
3285
|
+
className
|
|
3286
|
+
),
|
|
3287
|
+
children: [
|
|
3288
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "min-w-0 flex-1", children: leftSlot }),
|
|
3289
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex shrink-0 items-center gap-2.5", children: [
|
|
3290
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ConnectionStatusPill, { status: connectionStatus }),
|
|
3291
|
+
rightSlot ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex items-center justify-end", children: rightSlot }) : null
|
|
3292
|
+
] })
|
|
3293
|
+
]
|
|
3294
|
+
}
|
|
3295
|
+
);
|
|
2248
3296
|
};
|
|
2249
3297
|
|
|
3298
|
+
// src/components/surface-viewport.tsx
|
|
3299
|
+
var import_react11 = require("react");
|
|
3300
|
+
|
|
2250
3301
|
// src/runtime/controller-presentation.ts
|
|
3302
|
+
var import_zod27 = require("zod");
|
|
3303
|
+
var AIRJAM_CONTROLLER_PRESENTATION_SYNC = "AIRJAM_CONTROLLER_PRESENTATION_SYNC";
|
|
3304
|
+
var presentationSyncSchema = import_zod27.z.object({
|
|
3305
|
+
type: import_zod27.z.literal(AIRJAM_CONTROLLER_PRESENTATION_SYNC),
|
|
3306
|
+
payload: withControllerBridgeContext({
|
|
3307
|
+
orientation: controllerOrientationSchema
|
|
3308
|
+
})
|
|
3309
|
+
}).strict();
|
|
2251
3310
|
var publishEmbeddedControllerPresentation = (orientation) => {
|
|
2252
|
-
if (typeof window === "undefined" || window.parent === window) {
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2255
3311
|
const runtimeParams = readEmbeddedControllerRuntimeParams();
|
|
2256
|
-
if (!runtimeParams)
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
runtimeParams.topology.embedParentOrigin ?? "*"
|
|
2265
|
-
);
|
|
3312
|
+
if (!runtimeParams) return;
|
|
3313
|
+
const parent = embeddedRuntimeParent(runtimeParams.topology);
|
|
3314
|
+
if (!parent) return;
|
|
3315
|
+
const message = {
|
|
3316
|
+
type: AIRJAM_CONTROLLER_PRESENTATION_SYNC,
|
|
3317
|
+
payload: { orientation, ...controllerBridgeContext(runtimeParams) }
|
|
3318
|
+
};
|
|
3319
|
+
parent.window.postMessage(message, parent.origin);
|
|
2266
3320
|
};
|
|
2267
3321
|
|
|
2268
3322
|
// src/components/surface-orientation-layout.ts
|
|
@@ -2489,7 +3543,7 @@ var createSurfaceViewportScaleStyle = ({
|
|
|
2489
3543
|
};
|
|
2490
3544
|
|
|
2491
3545
|
// src/components/surface-viewport.tsx
|
|
2492
|
-
var
|
|
3546
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2493
3547
|
var readLayoutViewportSize = () => {
|
|
2494
3548
|
if (typeof window === "undefined") {
|
|
2495
3549
|
return { width: 0, height: 0 };
|
|
@@ -2562,7 +3616,7 @@ var getOrientation = ({
|
|
|
2562
3616
|
};
|
|
2563
3617
|
var SurfaceViewport = ({
|
|
2564
3618
|
children,
|
|
2565
|
-
orientation,
|
|
3619
|
+
orientation: requestedOrientation,
|
|
2566
3620
|
lockOnGesture = true,
|
|
2567
3621
|
className,
|
|
2568
3622
|
contentClassName,
|
|
@@ -2573,10 +3627,17 @@ var SurfaceViewport = ({
|
|
|
2573
3627
|
minScale,
|
|
2574
3628
|
maxScale
|
|
2575
3629
|
}) => {
|
|
2576
|
-
const [viewport, setViewport] = (0, import_react9.useState)(null);
|
|
2577
|
-
const viewportRef = (0, import_react9.useRef)(null);
|
|
2578
3630
|
const sessionScope = useSessionScope();
|
|
2579
|
-
(0,
|
|
3631
|
+
const declaredOrientation = (0, import_react11.useContext)(fixedControllerOrientationContext);
|
|
3632
|
+
const fixedOrientation = sessionScope === "controller" ? declaredOrientation : null;
|
|
3633
|
+
if (fixedOrientation && requestedOrientation && requestedOrientation !== fixedOrientation)
|
|
3634
|
+
throw new Error(
|
|
3635
|
+
"SurfaceViewport orientation conflicts with inputModalities: ['joystick'] in airjam.config: joystick games always use landscape; omit orientation."
|
|
3636
|
+
);
|
|
3637
|
+
const orientation = fixedOrientation ?? requestedOrientation;
|
|
3638
|
+
const [viewport, setViewport] = (0, import_react11.useState)(null);
|
|
3639
|
+
const viewportRef = (0, import_react11.useRef)(null);
|
|
3640
|
+
(0, import_react11.useEffect)(() => {
|
|
2580
3641
|
if (typeof window === "undefined") {
|
|
2581
3642
|
return;
|
|
2582
3643
|
}
|
|
@@ -2598,7 +3659,7 @@ var SurfaceViewport = ({
|
|
|
2598
3659
|
window.removeEventListener("orientationchange", updateViewport);
|
|
2599
3660
|
};
|
|
2600
3661
|
}, []);
|
|
2601
|
-
(0,
|
|
3662
|
+
(0, import_react11.useEffect)(() => {
|
|
2602
3663
|
if (typeof window === "undefined" || !orientation || !lockOnGesture) {
|
|
2603
3664
|
return;
|
|
2604
3665
|
}
|
|
@@ -2622,7 +3683,7 @@ var SurfaceViewport = ({
|
|
|
2622
3683
|
window.removeEventListener("pointerdown", onFirstGesture, true);
|
|
2623
3684
|
};
|
|
2624
3685
|
}, [orientation, lockOnGesture]);
|
|
2625
|
-
(0,
|
|
3686
|
+
(0, import_react11.useEffect)(() => {
|
|
2626
3687
|
if (!orientation || sessionScope !== "controller") {
|
|
2627
3688
|
return;
|
|
2628
3689
|
}
|
|
@@ -2631,11 +3692,11 @@ var SurfaceViewport = ({
|
|
|
2631
3692
|
const currentOrientation = viewport ? getOrientation(viewport) : "portrait";
|
|
2632
3693
|
const effectiveOrientation = orientation ?? currentOrientation;
|
|
2633
3694
|
const needsRotation = orientation ? currentOrientation !== orientation : false;
|
|
2634
|
-
const shellStyle = (0,
|
|
3695
|
+
const shellStyle = (0, import_react11.useMemo)(
|
|
2635
3696
|
() => orientation ? resolveForcedOrientationFrameStyle(orientation, needsRotation) : resolveForcedOrientationFrameStyle(effectiveOrientation, false),
|
|
2636
3697
|
[effectiveOrientation, needsRotation, orientation]
|
|
2637
3698
|
);
|
|
2638
|
-
const availableSize = (0,
|
|
3699
|
+
const availableSize = (0, import_react11.useMemo)(
|
|
2639
3700
|
() => resolveSurfaceViewportAvailableSize({
|
|
2640
3701
|
safeViewportWidth: viewport?.width ?? 0,
|
|
2641
3702
|
safeViewportHeight: viewport?.height ?? 0,
|
|
@@ -2644,7 +3705,7 @@ var SurfaceViewport = ({
|
|
|
2644
3705
|
}),
|
|
2645
3706
|
[needsRotation, orientation, viewport]
|
|
2646
3707
|
);
|
|
2647
|
-
const referenceSize = (0,
|
|
3708
|
+
const referenceSize = (0, import_react11.useMemo)(
|
|
2648
3709
|
() => resolveSurfaceViewportReferenceSize({
|
|
2649
3710
|
sessionScope,
|
|
2650
3711
|
designWidth,
|
|
@@ -2662,7 +3723,7 @@ var SurfaceViewport = ({
|
|
|
2662
3723
|
sessionScope
|
|
2663
3724
|
]
|
|
2664
3725
|
);
|
|
2665
|
-
const scale = (0,
|
|
3726
|
+
const scale = (0, import_react11.useMemo)(() => {
|
|
2666
3727
|
const scaleMode = sessionScope === "controller" ? effectiveOrientation === "portrait" ? "width" : "height" : "fit";
|
|
2667
3728
|
return resolveSurfaceViewportScale({
|
|
2668
3729
|
availableWidth: availableSize.width,
|
|
@@ -2685,7 +3746,7 @@ var SurfaceViewport = ({
|
|
|
2685
3746
|
sessionScope,
|
|
2686
3747
|
uiScaleMultiplier
|
|
2687
3748
|
]);
|
|
2688
|
-
return /* @__PURE__ */ (0,
|
|
3749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2689
3750
|
"div",
|
|
2690
3751
|
{
|
|
2691
3752
|
className: cn("fixed inset-0 overflow-hidden", className),
|
|
@@ -2693,7 +3754,7 @@ var SurfaceViewport = ({
|
|
|
2693
3754
|
...createSurfaceViewportOuterStyle(),
|
|
2694
3755
|
...style
|
|
2695
3756
|
},
|
|
2696
|
-
children: /* @__PURE__ */ (0,
|
|
3757
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: shellStyle, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2697
3758
|
"div",
|
|
2698
3759
|
{
|
|
2699
3760
|
className: cn("h-full w-full overflow-hidden", contentClassName),
|
|
@@ -2703,7 +3764,7 @@ var SurfaceViewport = ({
|
|
|
2703
3764
|
referenceWidth: referenceSize.width,
|
|
2704
3765
|
referenceHeight: referenceSize.height
|
|
2705
3766
|
}),
|
|
2706
|
-
children: /* @__PURE__ */ (0,
|
|
3767
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "h-full w-full", "data-airjam-surface-root": "true", children })
|
|
2707
3768
|
}
|
|
2708
3769
|
) })
|
|
2709
3770
|
}
|
|
@@ -2713,7 +3774,7 @@ var SurfaceViewport = ({
|
|
|
2713
3774
|
// src/components/ui/slider.tsx
|
|
2714
3775
|
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"), 1);
|
|
2715
3776
|
var React = __toESM(require("react"), 1);
|
|
2716
|
-
var
|
|
3777
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2717
3778
|
function Slider({
|
|
2718
3779
|
className,
|
|
2719
3780
|
defaultValue,
|
|
@@ -2726,7 +3787,7 @@ function Slider({
|
|
|
2726
3787
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
2727
3788
|
[value, defaultValue, min, max]
|
|
2728
3789
|
);
|
|
2729
|
-
return /* @__PURE__ */ (0,
|
|
3790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2730
3791
|
SliderPrimitive.Root,
|
|
2731
3792
|
{
|
|
2732
3793
|
"data-slot": "slider",
|
|
@@ -2740,14 +3801,14 @@ function Slider({
|
|
|
2740
3801
|
),
|
|
2741
3802
|
...props,
|
|
2742
3803
|
children: [
|
|
2743
|
-
/* @__PURE__ */ (0,
|
|
3804
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2744
3805
|
SliderPrimitive.Track,
|
|
2745
3806
|
{
|
|
2746
3807
|
"data-slot": "slider-track",
|
|
2747
3808
|
className: cn(
|
|
2748
3809
|
"bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
2749
3810
|
),
|
|
2750
|
-
children: /* @__PURE__ */ (0,
|
|
3811
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2751
3812
|
SliderPrimitive.Range,
|
|
2752
3813
|
{
|
|
2753
3814
|
"data-slot": "slider-range",
|
|
@@ -2758,7 +3819,7 @@ function Slider({
|
|
|
2758
3819
|
)
|
|
2759
3820
|
}
|
|
2760
3821
|
),
|
|
2761
|
-
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0,
|
|
3822
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2762
3823
|
SliderPrimitive.Thumb,
|
|
2763
3824
|
{
|
|
2764
3825
|
"data-slot": "slider-thumb",
|
|
@@ -2775,9 +3836,220 @@ function Slider({
|
|
|
2775
3836
|
var import_lucide_react5 = require("lucide-react");
|
|
2776
3837
|
|
|
2777
3838
|
// src/settings/platform-settings-runtime.tsx
|
|
2778
|
-
var
|
|
2779
|
-
|
|
2780
|
-
|
|
3839
|
+
var import_react12 = require("react");
|
|
3840
|
+
|
|
3841
|
+
// src/runtime/iframe-bridge.ts
|
|
3842
|
+
var import_zod30 = require("zod");
|
|
3843
|
+
|
|
3844
|
+
// src/contracts/v2/bridge.ts
|
|
3845
|
+
var import_zod28 = require("zod");
|
|
3846
|
+
var roomCodeSchema2 = import_zod28.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, {
|
|
3847
|
+
message: "room code must contain only A-Z or 0-9"
|
|
3848
|
+
});
|
|
3849
|
+
var runtimeStateSchema2 = import_zod28.z.enum(["paused", "playing"]);
|
|
3850
|
+
var playerProfileSchema2 = import_zod28.z.object({
|
|
3851
|
+
id: import_zod28.z.string().min(1),
|
|
3852
|
+
label: import_zod28.z.string().min(1),
|
|
3853
|
+
color: import_zod28.z.string().optional(),
|
|
3854
|
+
avatarId: import_zod28.z.string().optional()
|
|
3855
|
+
}).strict();
|
|
3856
|
+
var inputFrameEntrySchema = import_zod28.z.object({
|
|
3857
|
+
controllerId: import_zod28.z.string().min(1),
|
|
3858
|
+
input: import_zod28.z.record(import_zod28.z.string(), import_zod28.z.unknown())
|
|
3859
|
+
}).strict();
|
|
3860
|
+
var V2_BRIDGE_PARENT_TO_GAME_TYPES = [
|
|
3861
|
+
"BOOTSTRAP",
|
|
3862
|
+
"PLAYERS_UPDATE",
|
|
3863
|
+
"RUNTIME_STATE_UPDATE",
|
|
3864
|
+
"INPUT_FRAME",
|
|
3865
|
+
"PAUSE",
|
|
3866
|
+
"RESUME",
|
|
3867
|
+
"SHUTDOWN"
|
|
3868
|
+
];
|
|
3869
|
+
var V2_BRIDGE_GAME_TO_PARENT_TYPES = [
|
|
3870
|
+
"READY",
|
|
3871
|
+
"STATE_PATCH",
|
|
3872
|
+
"SIGNAL",
|
|
3873
|
+
"ERROR",
|
|
3874
|
+
"METRICS"
|
|
3875
|
+
];
|
|
3876
|
+
var allMessageTypes = [
|
|
3877
|
+
...V2_BRIDGE_PARENT_TO_GAME_TYPES,
|
|
3878
|
+
...V2_BRIDGE_GAME_TO_PARENT_TYPES
|
|
3879
|
+
];
|
|
3880
|
+
var knownBridgeMessageTypeSet = new Set(allMessageTypes);
|
|
3881
|
+
var bootstrapMessageSchema = import_zod28.z.object({
|
|
3882
|
+
type: import_zod28.z.literal("BOOTSTRAP"),
|
|
3883
|
+
payload: import_zod28.z.object({
|
|
3884
|
+
roomId: roomCodeSchema2,
|
|
3885
|
+
players: import_zod28.z.array(playerProfileSchema2),
|
|
3886
|
+
state: import_zod28.z.object({
|
|
3887
|
+
runtimeState: runtimeStateSchema2,
|
|
3888
|
+
message: import_zod28.z.string().optional()
|
|
3889
|
+
}).strict(),
|
|
3890
|
+
capabilities: import_zod28.z.record(import_zod28.z.string(), import_zod28.z.boolean()).default({})
|
|
3891
|
+
}).strict()
|
|
3892
|
+
}).strict();
|
|
3893
|
+
var playersUpdateMessageSchema = import_zod28.z.object({
|
|
3894
|
+
type: import_zod28.z.literal("PLAYERS_UPDATE"),
|
|
3895
|
+
payload: import_zod28.z.object({
|
|
3896
|
+
players: import_zod28.z.array(playerProfileSchema2)
|
|
3897
|
+
}).strict()
|
|
3898
|
+
}).strict();
|
|
3899
|
+
var runtimeStateUpdateMessageSchema = import_zod28.z.object({
|
|
3900
|
+
type: import_zod28.z.literal("RUNTIME_STATE_UPDATE"),
|
|
3901
|
+
payload: import_zod28.z.object({
|
|
3902
|
+
runtimeState: runtimeStateSchema2,
|
|
3903
|
+
message: import_zod28.z.string().optional()
|
|
3904
|
+
}).strict()
|
|
3905
|
+
}).strict();
|
|
3906
|
+
var inputFrameMessageSchema = import_zod28.z.object({
|
|
3907
|
+
type: import_zod28.z.literal("INPUT_FRAME"),
|
|
3908
|
+
payload: import_zod28.z.object({
|
|
3909
|
+
frameId: import_zod28.z.number().int().nonnegative(),
|
|
3910
|
+
inputs: import_zod28.z.array(inputFrameEntrySchema)
|
|
3911
|
+
}).strict()
|
|
3912
|
+
}).strict();
|
|
3913
|
+
var pauseMessageSchema = import_zod28.z.object({
|
|
3914
|
+
type: import_zod28.z.literal("PAUSE"),
|
|
3915
|
+
payload: import_zod28.z.object({
|
|
3916
|
+
reason: import_zod28.z.string().optional()
|
|
3917
|
+
}).strict()
|
|
3918
|
+
}).strict();
|
|
3919
|
+
var resumeMessageSchema = import_zod28.z.object({
|
|
3920
|
+
type: import_zod28.z.literal("RESUME"),
|
|
3921
|
+
payload: import_zod28.z.object({}).strict()
|
|
3922
|
+
}).strict();
|
|
3923
|
+
var shutdownMessageSchema = import_zod28.z.object({
|
|
3924
|
+
type: import_zod28.z.literal("SHUTDOWN"),
|
|
3925
|
+
payload: import_zod28.z.object({
|
|
3926
|
+
reason: import_zod28.z.string().min(1)
|
|
3927
|
+
}).strict()
|
|
3928
|
+
}).strict();
|
|
3929
|
+
var readyMessageSchema = import_zod28.z.object({
|
|
3930
|
+
type: import_zod28.z.literal("READY"),
|
|
3931
|
+
payload: import_zod28.z.object({
|
|
3932
|
+
readyAtMs: import_zod28.z.number().int().nonnegative()
|
|
3933
|
+
}).strict()
|
|
3934
|
+
}).strict();
|
|
3935
|
+
var statePatchMessageSchema = import_zod28.z.object({
|
|
3936
|
+
type: import_zod28.z.literal("STATE_PATCH"),
|
|
3937
|
+
payload: import_zod28.z.object({
|
|
3938
|
+
patch: import_zod28.z.record(import_zod28.z.string(), import_zod28.z.unknown())
|
|
3939
|
+
}).strict()
|
|
3940
|
+
}).strict();
|
|
3941
|
+
var signalMessageSchema = import_zod28.z.object({
|
|
3942
|
+
type: import_zod28.z.literal("SIGNAL"),
|
|
3943
|
+
payload: import_zod28.z.object({
|
|
3944
|
+
signalType: import_zod28.z.string().min(1),
|
|
3945
|
+
targetId: import_zod28.z.string().min(1).optional(),
|
|
3946
|
+
data: import_zod28.z.record(import_zod28.z.string(), import_zod28.z.unknown())
|
|
3947
|
+
}).strict()
|
|
3948
|
+
}).strict();
|
|
3949
|
+
var errorMessageSchema = import_zod28.z.object({
|
|
3950
|
+
type: import_zod28.z.literal("ERROR"),
|
|
3951
|
+
payload: import_zod28.z.object({
|
|
3952
|
+
code: import_zod28.z.string().min(1),
|
|
3953
|
+
message: import_zod28.z.string().min(1),
|
|
3954
|
+
details: import_zod28.z.record(import_zod28.z.string(), import_zod28.z.unknown()).optional()
|
|
3955
|
+
}).strict()
|
|
3956
|
+
}).strict();
|
|
3957
|
+
var metricsMessageSchema = import_zod28.z.object({
|
|
3958
|
+
type: import_zod28.z.literal("METRICS"),
|
|
3959
|
+
payload: import_zod28.z.object({
|
|
3960
|
+
values: import_zod28.z.record(import_zod28.z.string(), import_zod28.z.number())
|
|
3961
|
+
}).strict()
|
|
3962
|
+
}).strict();
|
|
3963
|
+
var v2BridgeParentToGameMessageSchema = import_zod28.z.union([
|
|
3964
|
+
bootstrapMessageSchema,
|
|
3965
|
+
playersUpdateMessageSchema,
|
|
3966
|
+
runtimeStateUpdateMessageSchema,
|
|
3967
|
+
inputFrameMessageSchema,
|
|
3968
|
+
pauseMessageSchema,
|
|
3969
|
+
resumeMessageSchema,
|
|
3970
|
+
shutdownMessageSchema
|
|
3971
|
+
]);
|
|
3972
|
+
var v2BridgeGameToParentMessageSchema = import_zod28.z.union([
|
|
3973
|
+
readyMessageSchema,
|
|
3974
|
+
statePatchMessageSchema,
|
|
3975
|
+
signalMessageSchema,
|
|
3976
|
+
errorMessageSchema,
|
|
3977
|
+
metricsMessageSchema
|
|
3978
|
+
]);
|
|
3979
|
+
var v2BridgeMessageSchema = import_zod28.z.union([
|
|
3980
|
+
v2BridgeParentToGameMessageSchema,
|
|
3981
|
+
v2BridgeGameToParentMessageSchema
|
|
3982
|
+
]);
|
|
3983
|
+
|
|
3984
|
+
// src/contracts/v2/handshake.ts
|
|
3985
|
+
var import_zod29 = require("zod");
|
|
3986
|
+
var AIR_JAM_PROTOCOL_V2 = "2";
|
|
3987
|
+
var semanticVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
3988
|
+
var v2ProtocolVersionSchema = import_zod29.z.literal(AIR_JAM_PROTOCOL_V2);
|
|
3989
|
+
var runtimeKindSchema = import_zod29.z.enum([
|
|
3990
|
+
"standalone-host",
|
|
3991
|
+
"standalone-controller",
|
|
3992
|
+
"arcade-runtime",
|
|
3993
|
+
"arcade-game-iframe",
|
|
3994
|
+
"arcade-host-runtime",
|
|
3995
|
+
"arcade-host-iframe",
|
|
3996
|
+
"arcade-controller-runtime",
|
|
3997
|
+
"arcade-controller-iframe"
|
|
3998
|
+
]);
|
|
3999
|
+
var capabilityFlagsSchema = import_zod29.z.record(import_zod29.z.string(), import_zod29.z.boolean());
|
|
4000
|
+
var sdkVersionSchema = import_zod29.z.string().regex(
|
|
4001
|
+
semanticVersionPattern,
|
|
4002
|
+
"sdkVersion must use semantic version format (for example 1.2.3)"
|
|
4003
|
+
);
|
|
4004
|
+
var v2HandshakeSchema = import_zod29.z.object({
|
|
4005
|
+
protocolVersion: v2ProtocolVersionSchema,
|
|
4006
|
+
sdkVersion: sdkVersionSchema,
|
|
4007
|
+
runtimeKind: runtimeKindSchema,
|
|
4008
|
+
capabilityFlags: capabilityFlagsSchema.default({})
|
|
4009
|
+
}).strict();
|
|
4010
|
+
|
|
4011
|
+
// src/runtime/iframe-bridge.ts
|
|
4012
|
+
var AIRJAM_BRIDGE_INIT = "AIRJAM_BRIDGE_INIT";
|
|
4013
|
+
var AIRJAM_SETTINGS_SYNC = "AIRJAM_SETTINGS_SYNC";
|
|
4014
|
+
var AIRJAM_SETTINGS_READY = "AIRJAM_SETTINGS_READY";
|
|
4015
|
+
var airJamSettingsSyncSchema = import_zod30.z.object({
|
|
4016
|
+
type: import_zod30.z.literal(AIRJAM_SETTINGS_SYNC),
|
|
4017
|
+
payload: import_zod30.z.object({
|
|
4018
|
+
settings: import_zod30.z.object({
|
|
4019
|
+
audio: import_zod30.z.object({
|
|
4020
|
+
masterVolume: import_zod30.z.number(),
|
|
4021
|
+
musicVolume: import_zod30.z.number(),
|
|
4022
|
+
sfxVolume: import_zod30.z.number()
|
|
4023
|
+
}).strict(),
|
|
4024
|
+
accessibility: import_zod30.z.object({
|
|
4025
|
+
reducedMotion: import_zod30.z.boolean(),
|
|
4026
|
+
highContrast: import_zod30.z.boolean()
|
|
4027
|
+
}).strict(),
|
|
4028
|
+
feedback: import_zod30.z.object({
|
|
4029
|
+
hapticsEnabled: import_zod30.z.boolean()
|
|
4030
|
+
}).strict(),
|
|
4031
|
+
previewControllers: import_zod30.z.object({
|
|
4032
|
+
activeOpacity: import_zod30.z.number()
|
|
4033
|
+
}).strict()
|
|
4034
|
+
}).strict()
|
|
4035
|
+
}).strict()
|
|
4036
|
+
}).strict();
|
|
4037
|
+
var airJamBridgeInitSchema = import_zod30.z.object({
|
|
4038
|
+
type: import_zod30.z.literal(AIRJAM_BRIDGE_INIT),
|
|
4039
|
+
payload: import_zod30.z.object({
|
|
4040
|
+
handshake: v2HandshakeSchema
|
|
4041
|
+
}).strict()
|
|
4042
|
+
}).strict();
|
|
4043
|
+
var airJamSettingsReadySchema = import_zod30.z.object({
|
|
4044
|
+
type: import_zod30.z.literal(AIRJAM_SETTINGS_READY),
|
|
4045
|
+
payload: import_zod30.z.object({
|
|
4046
|
+
ready: import_zod30.z.literal(true)
|
|
4047
|
+
}).strict()
|
|
4048
|
+
}).strict();
|
|
4049
|
+
|
|
4050
|
+
// src/settings/platform-settings-runtime.tsx
|
|
4051
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4052
|
+
var platformSettingsContext = (0, import_react12.createContext)(null);
|
|
2781
4053
|
var createDefaultContextValue = () => ({
|
|
2782
4054
|
mode: "default",
|
|
2783
4055
|
status: "ready",
|
|
@@ -2794,10 +4066,10 @@ var createDefaultContextValue = () => ({
|
|
|
2794
4066
|
}
|
|
2795
4067
|
});
|
|
2796
4068
|
function usePlatformAudioSettings() {
|
|
2797
|
-
const context = (0,
|
|
4069
|
+
const context = (0, import_react12.useContext)(platformSettingsContext) ?? createDefaultContextValue();
|
|
2798
4070
|
const { audio } = context.settings;
|
|
2799
4071
|
const isReadOnly = context.mode !== "owner";
|
|
2800
|
-
const setAudioSetting = (0,
|
|
4072
|
+
const setAudioSetting = (0, import_react12.useCallback)(
|
|
2801
4073
|
(patch) => {
|
|
2802
4074
|
if (context.mode !== "owner") {
|
|
2803
4075
|
throw new Error(
|
|
@@ -2819,12 +4091,12 @@ function usePlatformAudioSettings() {
|
|
|
2819
4091
|
}
|
|
2820
4092
|
|
|
2821
4093
|
// src/components/volume-controls.tsx
|
|
2822
|
-
var
|
|
4094
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2823
4095
|
function VolumeControls(props) {
|
|
2824
4096
|
if (props.values) {
|
|
2825
|
-
return /* @__PURE__ */ (0,
|
|
4097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ControlledVolumeControls, { ...props });
|
|
2826
4098
|
}
|
|
2827
|
-
return /* @__PURE__ */ (0,
|
|
4099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(OwnedVolumeControls, { ...props });
|
|
2828
4100
|
}
|
|
2829
4101
|
function OwnedVolumeControls({ className, compact }) {
|
|
2830
4102
|
const {
|
|
@@ -2835,7 +4107,7 @@ function OwnedVolumeControls({ className, compact }) {
|
|
|
2835
4107
|
setMusicVolume,
|
|
2836
4108
|
setSfxVolume
|
|
2837
4109
|
} = usePlatformAudioSettings();
|
|
2838
|
-
return /* @__PURE__ */ (0,
|
|
4110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2839
4111
|
ControlledVolumeControls,
|
|
2840
4112
|
{
|
|
2841
4113
|
className,
|
|
@@ -2861,20 +4133,20 @@ function ControlledVolumeControls({
|
|
|
2861
4133
|
throw new Error("ControlledVolumeControls requires values");
|
|
2862
4134
|
}
|
|
2863
4135
|
const { masterVolume, musicVolume, sfxVolume } = values;
|
|
2864
|
-
return /* @__PURE__ */ (0,
|
|
2865
|
-
/* @__PURE__ */ (0,
|
|
2866
|
-
/* @__PURE__ */ (0,
|
|
2867
|
-
/* @__PURE__ */ (0,
|
|
4136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cn("flex flex-col gap-3", compact && "gap-1", className), children: [
|
|
4137
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4138
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react5.Volume2, { className: "text-muted-foreground h-4 w-4" }),
|
|
4139
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-sm font-medium", children: "Volume" })
|
|
2868
4140
|
] }),
|
|
2869
|
-
/* @__PURE__ */ (0,
|
|
2870
|
-
/* @__PURE__ */ (0,
|
|
2871
|
-
/* @__PURE__ */ (0,
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
4141
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-1.5", children: [
|
|
4142
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
4143
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("label", { className: "text-muted-foreground text-xs", children: "Master" }),
|
|
4144
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2873
4145
|
Math.round(masterVolume * 100),
|
|
2874
4146
|
"%"
|
|
2875
4147
|
] })
|
|
2876
4148
|
] }),
|
|
2877
|
-
/* @__PURE__ */ (0,
|
|
4149
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2878
4150
|
Slider,
|
|
2879
4151
|
{
|
|
2880
4152
|
"data-testid": "platform-settings-master-volume",
|
|
@@ -2889,18 +4161,18 @@ function ControlledVolumeControls({
|
|
|
2889
4161
|
}
|
|
2890
4162
|
)
|
|
2891
4163
|
] }),
|
|
2892
|
-
/* @__PURE__ */ (0,
|
|
2893
|
-
/* @__PURE__ */ (0,
|
|
2894
|
-
/* @__PURE__ */ (0,
|
|
2895
|
-
/* @__PURE__ */ (0,
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
4164
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-1.5", children: [
|
|
4165
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
4166
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
4167
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react5.Music, { className: "text-muted-foreground h-3 w-3" }),
|
|
4168
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("label", { className: "text-muted-foreground text-xs", children: "Music" })
|
|
2897
4169
|
] }),
|
|
2898
|
-
/* @__PURE__ */ (0,
|
|
4170
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2899
4171
|
Math.round(musicVolume * 100),
|
|
2900
4172
|
"%"
|
|
2901
4173
|
] })
|
|
2902
4174
|
] }),
|
|
2903
|
-
/* @__PURE__ */ (0,
|
|
4175
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2904
4176
|
Slider,
|
|
2905
4177
|
{
|
|
2906
4178
|
"data-testid": "platform-settings-music-volume",
|
|
@@ -2915,18 +4187,18 @@ function ControlledVolumeControls({
|
|
|
2915
4187
|
}
|
|
2916
4188
|
)
|
|
2917
4189
|
] }),
|
|
2918
|
-
/* @__PURE__ */ (0,
|
|
2919
|
-
/* @__PURE__ */ (0,
|
|
2920
|
-
/* @__PURE__ */ (0,
|
|
2921
|
-
/* @__PURE__ */ (0,
|
|
2922
|
-
/* @__PURE__ */ (0,
|
|
4190
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-1.5", children: [
|
|
4191
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
4192
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
4193
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react5.Headphones, { className: "text-muted-foreground h-3 w-3" }),
|
|
4194
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("label", { className: "text-muted-foreground text-xs", children: "SFX" })
|
|
2923
4195
|
] }),
|
|
2924
|
-
/* @__PURE__ */ (0,
|
|
4196
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2925
4197
|
Math.round(sfxVolume * 100),
|
|
2926
4198
|
"%"
|
|
2927
4199
|
] })
|
|
2928
4200
|
] }),
|
|
2929
|
-
/* @__PURE__ */ (0,
|
|
4201
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2930
4202
|
Slider,
|
|
2931
4203
|
{
|
|
2932
4204
|
"data-testid": "platform-settings-sfx-volume",
|
|
@@ -3002,7 +4274,7 @@ var useControllerShellStatus = ({
|
|
|
3002
4274
|
};
|
|
3003
4275
|
|
|
3004
4276
|
// src/hooks/use-host-join-controls.ts
|
|
3005
|
-
var
|
|
4277
|
+
var import_react13 = require("react");
|
|
3006
4278
|
var copyTextToClipboard = async (text) => {
|
|
3007
4279
|
if (!text) {
|
|
3008
4280
|
return false;
|
|
@@ -3037,17 +4309,17 @@ var useHostJoinControls = ({
|
|
|
3037
4309
|
onStartMatch,
|
|
3038
4310
|
copiedDurationMs = 1800
|
|
3039
4311
|
}) => {
|
|
3040
|
-
const [copied, setCopied] = (0,
|
|
3041
|
-
const [joinQrVisible, setJoinQrVisible] = (0,
|
|
3042
|
-
const resetTimerRef = (0,
|
|
3043
|
-
const joinUrlValue = (0,
|
|
4312
|
+
const [copied, setCopied] = (0, import_react13.useState)(false);
|
|
4313
|
+
const [joinQrVisible, setJoinQrVisible] = (0, import_react13.useState)(false);
|
|
4314
|
+
const resetTimerRef = (0, import_react13.useRef)(null);
|
|
4315
|
+
const joinUrlValue = (0, import_react13.useMemo)(() => joinUrl ?? "", [joinUrl]);
|
|
3044
4316
|
const hasJoinUrl = joinUrlValue.length > 0;
|
|
3045
|
-
(0,
|
|
4317
|
+
(0, import_react13.useEffect)(() => {
|
|
3046
4318
|
if (!hasJoinUrl) {
|
|
3047
4319
|
setJoinQrVisible(false);
|
|
3048
4320
|
}
|
|
3049
4321
|
}, [hasJoinUrl]);
|
|
3050
|
-
const handleCopy = (0,
|
|
4322
|
+
const handleCopy = (0, import_react13.useCallback)(async () => {
|
|
3051
4323
|
if (!joinUrlValue) {
|
|
3052
4324
|
return;
|
|
3053
4325
|
}
|
|
@@ -3064,28 +4336,28 @@ var useHostJoinControls = ({
|
|
|
3064
4336
|
resetTimerRef.current = null;
|
|
3065
4337
|
}, copiedDurationMs);
|
|
3066
4338
|
}, [copiedDurationMs, joinUrlValue]);
|
|
3067
|
-
const handleOpen = (0,
|
|
4339
|
+
const handleOpen = (0, import_react13.useCallback)(() => {
|
|
3068
4340
|
if (!joinUrlValue || typeof window === "undefined") {
|
|
3069
4341
|
return;
|
|
3070
4342
|
}
|
|
3071
4343
|
window.open(joinUrlValue, "_blank", "noopener,noreferrer");
|
|
3072
4344
|
}, [joinUrlValue]);
|
|
3073
|
-
const showJoinQr = (0,
|
|
4345
|
+
const showJoinQr = (0, import_react13.useCallback)(() => {
|
|
3074
4346
|
if (!hasJoinUrl) {
|
|
3075
4347
|
return;
|
|
3076
4348
|
}
|
|
3077
4349
|
setJoinQrVisible(true);
|
|
3078
4350
|
}, [hasJoinUrl]);
|
|
3079
|
-
const hideJoinQr = (0,
|
|
4351
|
+
const hideJoinQr = (0, import_react13.useCallback)(() => {
|
|
3080
4352
|
setJoinQrVisible(false);
|
|
3081
4353
|
}, []);
|
|
3082
|
-
const toggleJoinQr = (0,
|
|
4354
|
+
const toggleJoinQr = (0, import_react13.useCallback)(() => {
|
|
3083
4355
|
if (!hasJoinUrl) {
|
|
3084
4356
|
return;
|
|
3085
4357
|
}
|
|
3086
4358
|
setJoinQrVisible((current) => !current);
|
|
3087
4359
|
}, [hasJoinUrl]);
|
|
3088
|
-
const handleStart = (0,
|
|
4360
|
+
const handleStart = (0, import_react13.useCallback)(() => {
|
|
3089
4361
|
if (!canStartMatch) {
|
|
3090
4362
|
return;
|
|
3091
4363
|
}
|
|
@@ -3108,10 +4380,13 @@ var useHostJoinControls = ({
|
|
|
3108
4380
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3109
4381
|
0 && (module.exports = {
|
|
3110
4382
|
AIRJAM_DEFAULT_AVATAR_SEEDS,
|
|
4383
|
+
AxisButton,
|
|
3111
4384
|
Button,
|
|
3112
4385
|
ConnectionStatusPill,
|
|
4386
|
+
ControlButton,
|
|
3113
4387
|
ControllerPlayerNameField,
|
|
3114
4388
|
ControllerPrimaryAction,
|
|
4389
|
+
GamepadLayout,
|
|
3115
4390
|
HostMuteButton,
|
|
3116
4391
|
JoinQrOverlay,
|
|
3117
4392
|
JoinUrlActionButtons,
|
|
@@ -3123,12 +4398,10 @@ var useHostJoinControls = ({
|
|
|
3123
4398
|
RoomQrCode,
|
|
3124
4399
|
RuntimeShellHeader,
|
|
3125
4400
|
Slider,
|
|
4401
|
+
Stick,
|
|
3126
4402
|
SurfaceViewport,
|
|
3127
4403
|
VolumeControls,
|
|
3128
|
-
buttonVariants,
|
|
3129
4404
|
getDiceBearAdventurerNeutralUrl,
|
|
3130
|
-
getPlayerAvatarImageUrl,
|
|
3131
|
-
resolvePlayerAvatarSeed,
|
|
3132
4405
|
useControllerLifecycleIntents,
|
|
3133
4406
|
useControllerLifecyclePermissions,
|
|
3134
4407
|
useControllerShellStatus,
|