@air-jam/sdk 0.9.3 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -205
- package/dist/actions-D4eh6Xaa.d.cts +72 -0
- package/dist/actions-D4eh6Xaa.d.ts +72 -0
- package/dist/{agent-contract-CD2QnbBJ.d.cts → agent-contract-BMvCMvhE.d.ts} +3 -19
- package/dist/{agent-contract-CD2QnbBJ.d.ts → agent-contract-DtYf3ici.d.cts} +3 -19
- package/dist/agent-tooling.cjs +135 -46
- package/dist/agent-tooling.cjs.map +1 -1
- package/dist/agent-tooling.d.cts +96 -5
- package/dist/agent-tooling.d.ts +96 -5
- package/dist/agent-tooling.js +15 -14
- package/dist/agent-tooling.js.map +1 -1
- package/dist/{use-air-jam-host-COLy8t4s.d.ts → air-jam-context-B1fQvyYY.d.ts} +121 -114
- package/dist/{use-air-jam-host-DM-ybB3C.d.cts → air-jam-context-BKg_ujpd.d.cts} +121 -114
- package/dist/arcade/bridge/controller.cjs +873 -603
- package/dist/arcade/bridge/controller.cjs.map +1 -1
- package/dist/arcade/bridge/controller.d.cts +28 -76
- package/dist/arcade/bridge/controller.d.ts +28 -76
- package/dist/arcade/bridge/controller.js +27 -28
- package/dist/arcade/bridge/controller.js.map +1 -1
- package/dist/arcade/bridge/host.cjs +1017 -252
- package/dist/arcade/bridge/host.cjs.map +1 -1
- package/dist/arcade/bridge/host.d.cts +6 -72
- package/dist/arcade/bridge/host.d.ts +6 -72
- package/dist/arcade/bridge/host.js +19 -22
- package/dist/arcade/bridge/host.js.map +1 -1
- package/dist/arcade/bridge/iframe.cjs +3 -31
- package/dist/arcade/bridge/iframe.cjs.map +1 -1
- package/dist/arcade/bridge/iframe.d.cts +4 -46
- package/dist/arcade/bridge/iframe.d.ts +4 -46
- package/dist/arcade/bridge/iframe.js +6 -18
- package/dist/arcade/bridge/iframe.js.map +1 -1
- package/dist/arcade/host.cjs +0 -502
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.d.cts +1 -19
- package/dist/arcade/host.d.ts +1 -19
- package/dist/arcade/host.js +0 -14
- package/dist/arcade/host.js.map +1 -1
- package/dist/arcade/runtime.cjs +10373 -4688
- package/dist/arcade/runtime.cjs.map +1 -1
- package/dist/arcade/runtime.d.cts +45 -13
- package/dist/arcade/runtime.d.ts +45 -13
- package/dist/arcade/runtime.js +37 -24
- package/dist/arcade/runtime.js.map +1 -1
- package/dist/arcade/surface.cjs +3 -35
- package/dist/arcade/surface.cjs.map +1 -1
- package/dist/arcade/surface.d.cts +14 -2
- package/dist/arcade/surface.d.ts +14 -2
- package/dist/arcade/surface.js +7 -13
- package/dist/arcade/surface.js.map +1 -1
- package/dist/arcade/url.cjs +45 -283
- package/dist/arcade/url.cjs.map +1 -1
- package/dist/arcade/url.d.cts +3 -56
- package/dist/arcade/url.d.ts +3 -56
- package/dist/arcade/url.js +33 -16
- package/dist/arcade/url.js.map +1 -1
- package/dist/chunk-24NZZOIO.js +700 -0
- package/dist/chunk-24NZZOIO.js.map +1 -0
- package/dist/chunk-27QLKLZL.js +469 -0
- package/dist/chunk-27QLKLZL.js.map +1 -0
- package/dist/{chunk-UWJOIVON.js → chunk-2H2FGF3H.js} +3 -6
- package/dist/chunk-2H2FGF3H.js.map +1 -0
- package/dist/chunk-3LDQCQL2.js +307 -0
- package/dist/chunk-3LDQCQL2.js.map +1 -0
- package/dist/chunk-3M7656SU.js +389 -0
- package/dist/chunk-3M7656SU.js.map +1 -0
- package/dist/{chunk-K4OZ54UD.js → chunk-5CRZFIN6.js} +2 -55
- package/dist/chunk-5CRZFIN6.js.map +1 -0
- package/dist/chunk-5L3O3G5K.js +802 -0
- package/dist/chunk-5L3O3G5K.js.map +1 -0
- package/dist/{chunk-O6X7FJ6N.js → chunk-6PLOJMJD.js} +619 -643
- package/dist/chunk-6PLOJMJD.js.map +1 -0
- package/dist/{chunk-EVZJA6RN.js → chunk-6ZJUA63D.js} +183 -2
- package/dist/chunk-6ZJUA63D.js.map +1 -0
- package/dist/chunk-A6EOGRRG.js +49 -0
- package/dist/chunk-A6EOGRRG.js.map +1 -0
- package/dist/chunk-AXG6FA2H.js +366 -0
- package/dist/chunk-AXG6FA2H.js.map +1 -0
- package/dist/chunk-BEM77SVQ.js +57 -0
- package/dist/chunk-BEM77SVQ.js.map +1 -0
- package/dist/chunk-BQHGPXXN.js +1995 -0
- package/dist/chunk-BQHGPXXN.js.map +1 -0
- package/dist/chunk-C5722GTG.js +176 -0
- package/dist/chunk-C5722GTG.js.map +1 -0
- package/dist/{chunk-CV3PBXPT.js → chunk-C5GS2GMK.js} +99 -105
- package/dist/chunk-C5GS2GMK.js.map +1 -0
- package/dist/chunk-CDL7LYZH.js +19 -0
- package/dist/chunk-CDL7LYZH.js.map +1 -0
- package/dist/{chunk-PSUYTD2L.js → chunk-DA3TE4OP.js} +1 -1
- package/dist/chunk-DA3TE4OP.js.map +1 -0
- package/dist/chunk-DBF7NJ3S.js +72 -0
- package/dist/chunk-DBF7NJ3S.js.map +1 -0
- package/dist/chunk-DRBPVG47.js +89 -0
- package/dist/chunk-DRBPVG47.js.map +1 -0
- package/dist/chunk-FCG42U7D.js +131 -0
- package/dist/chunk-FCG42U7D.js.map +1 -0
- package/dist/chunk-FJ4J2BEC.js +26 -0
- package/dist/chunk-FJ4J2BEC.js.map +1 -0
- package/dist/chunk-H4DEVMTO.js +221 -0
- package/dist/chunk-H4DEVMTO.js.map +1 -0
- package/dist/chunk-ISQZ7F3N.js +83 -0
- package/dist/chunk-ISQZ7F3N.js.map +1 -0
- package/dist/{chunk-IG6GZZSS.js → chunk-JCGTL77W.js} +1 -1
- package/dist/chunk-JCGTL77W.js.map +1 -0
- package/dist/chunk-JJVCBUYM.js +98 -0
- package/dist/chunk-JJVCBUYM.js.map +1 -0
- package/dist/chunk-K6BJJJJM.js +138 -0
- package/dist/chunk-K6BJJJJM.js.map +1 -0
- package/dist/{chunk-MIMPMB7O.js → chunk-KGY4PV2A.js} +24 -3
- package/dist/chunk-KGY4PV2A.js.map +1 -0
- package/dist/chunk-KKRLHT2M.js +2477 -0
- package/dist/chunk-KKRLHT2M.js.map +1 -0
- package/dist/chunk-KSYN4I5Y.js +50 -0
- package/dist/chunk-KSYN4I5Y.js.map +1 -0
- package/dist/chunk-KUGROY5S.js +265 -0
- package/dist/chunk-KUGROY5S.js.map +1 -0
- package/dist/chunk-LX6CTPDW.js +16 -0
- package/dist/chunk-LX6CTPDW.js.map +1 -0
- package/dist/{chunk-BE6Z4SIT.js → chunk-M5553I2G.js} +2 -11
- package/dist/chunk-M5553I2G.js.map +1 -0
- package/dist/{chunk-X24K52DG.js → chunk-MD25536W.js} +1 -1
- package/dist/chunk-MD25536W.js.map +1 -0
- package/dist/{chunk-3USU7GY2.js → chunk-MJAWAHLT.js} +1 -1
- package/dist/chunk-MJAWAHLT.js.map +1 -0
- package/dist/chunk-NBA7UIWG.js +921 -0
- package/dist/chunk-NBA7UIWG.js.map +1 -0
- package/dist/chunk-OAXCFPZ7.js +14 -0
- package/dist/chunk-OAXCFPZ7.js.map +1 -0
- package/dist/{chunk-D4VDEVTZ.js → chunk-QHBRHYMV.js} +18 -17
- package/dist/chunk-QHBRHYMV.js.map +1 -0
- package/dist/chunk-QTNYGAZ7.js +45 -0
- package/dist/chunk-QTNYGAZ7.js.map +1 -0
- package/dist/chunk-UC24OG4X.js +129 -0
- package/dist/chunk-UC24OG4X.js.map +1 -0
- package/dist/chunk-VN2PX2I3.js +188 -0
- package/dist/chunk-VN2PX2I3.js.map +1 -0
- package/dist/chunk-WAFGYJZN.js +1513 -0
- package/dist/chunk-WAFGYJZN.js.map +1 -0
- package/dist/chunk-WGHNGQUS.js +78 -0
- package/dist/chunk-WGHNGQUS.js.map +1 -0
- package/dist/{chunk-X35LLCWV.js → chunk-X5HZBQ6K.js} +6 -8
- package/dist/chunk-X5HZBQ6K.js.map +1 -0
- package/dist/chunk-XLY44PXZ.js +46 -0
- package/dist/chunk-XLY44PXZ.js.map +1 -0
- package/dist/chunk-YXHAWWVU.js +7 -0
- package/dist/chunk-YXHAWWVU.js.map +1 -0
- package/dist/connection-store-CqW-E7ma.d.cts +41 -0
- package/dist/connection-store-ffHWMrMe.d.ts +41 -0
- package/dist/control-Bv8dWjyp.d.ts +1400 -0
- package/dist/control-CNzybWMd.d.cts +1400 -0
- package/dist/controller-ClW0R8mZ.d.cts +26 -0
- package/dist/controller-DRKCa7uQ.d.ts +26 -0
- package/dist/controller-agent-vOiuK7T6.d.cts +130 -0
- package/dist/controller-agent-vOiuK7T6.d.ts +130 -0
- package/dist/controller-bridge.cjs +992 -0
- package/dist/controller-bridge.cjs.map +1 -0
- package/dist/controller-bridge.d.cts +52 -0
- package/dist/controller-bridge.d.ts +52 -0
- package/dist/controller-bridge.js +23 -0
- package/dist/controller-bridge.js.map +1 -0
- package/dist/controller-capture-2GKKGHJ2.js +8 -0
- package/dist/controller-capture-2GKKGHJ2.js.map +1 -0
- package/dist/controller-press-EWWIMVXP.js +231 -0
- package/dist/controller-press-EWWIMVXP.js.map +1 -0
- package/dist/core-BAO0pHrJ.d.cts +15 -0
- package/dist/core-BAO0pHrJ.d.ts +15 -0
- package/dist/core.cjs +5956 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +250 -0
- package/dist/core.d.ts +250 -0
- package/dist/core.js +910 -0
- package/dist/core.js.map +1 -0
- package/dist/dev-events-BffobOfb.d.ts +31 -0
- package/dist/dev-events-Ct7QEgKb.d.cts +31 -0
- package/dist/dev-log-events-B1_B3guZ.d.cts +47 -0
- package/dist/dev-log-events-B1_B3guZ.d.ts +47 -0
- package/dist/frames-D-xKuODS.d.cts +686 -0
- package/dist/frames-D-xKuODS.d.ts +686 -0
- package/dist/game-5n-dh5np.d.cts +77 -0
- package/dist/game-RYb97BN8.d.ts +77 -0
- package/dist/host-runtime-BRtUidEJ.d.cts +399 -0
- package/dist/host-runtime-RrO4pCXI.d.ts +399 -0
- package/dist/index.cjs +11571 -7554
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -358
- package/dist/index.d.ts +100 -358
- package/dist/index.js +414 -1903
- package/dist/index.js.map +1 -1
- package/dist/input-D7FNeehb.d.cts +92 -0
- package/dist/input-D7FNeehb.d.ts +92 -0
- package/dist/input-bindings-686sTen7.d.ts +129 -0
- package/dist/input-bindings-BRac-P0e.d.cts +129 -0
- package/dist/leased-control-BEg4JuXA.d.cts +158 -0
- package/dist/leased-control-BEg4JuXA.d.ts +158 -0
- package/dist/metadata.cjs +3 -9
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +6 -16
- package/dist/metadata.d.ts +6 -16
- package/dist/metadata.js +8 -76
- package/dist/metadata.js.map +1 -1
- package/dist/phone-room-session-Byomkt92.d.cts +439 -0
- package/dist/phone-room-session-D9C8cSxS.d.ts +439 -0
- package/dist/platform-machine.cjs +133 -3
- package/dist/platform-machine.cjs.map +1 -1
- package/dist/platform-machine.d.cts +525 -27
- package/dist/platform-machine.d.ts +525 -27
- package/dist/platform-machine.js +119 -4
- package/dist/platform-machine.js.map +1 -1
- package/dist/{platform-settings-DUWs4JTy.d.cts → platform-settings-Yb0fQ1dl.d.cts} +1 -3
- package/dist/{platform-settings-DUWs4JTy.d.ts → platform-settings-Yb0fQ1dl.d.ts} +1 -3
- package/dist/prefabs.cjs +134 -3
- package/dist/prefabs.cjs.map +1 -1
- package/dist/prefabs.d.cts +23 -47
- package/dist/prefabs.d.ts +23 -47
- package/dist/prefabs.js +23 -4
- package/dist/prefabs.js.map +1 -1
- package/dist/preview.cjs +2199 -767
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +193 -38
- package/dist/preview.d.ts +193 -38
- package/dist/preview.js +478 -254
- package/dist/preview.js.map +1 -1
- package/dist/protocol.cjs +585 -391
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +13 -117
- package/dist/protocol.d.ts +13 -117
- package/dist/protocol.js +43 -80
- package/dist/protocol.js.map +1 -1
- package/dist/release.cjs.map +1 -1
- package/dist/release.d.cts +2 -2
- package/dist/release.d.ts +2 -2
- package/dist/release.js +1 -1
- package/dist/release.js.map +1 -1
- package/dist/replay-input-log-D0NpnA3P.d.ts +31 -0
- package/dist/replay-input-log-bg0g-PCz.d.cts +31 -0
- package/dist/room-protocol.cjs +794 -0
- package/dist/room-protocol.cjs.map +1 -0
- package/dist/room-protocol.d.cts +63 -0
- package/dist/room-protocol.d.ts +63 -0
- package/dist/room-protocol.js +143 -0
- package/dist/room-protocol.js.map +1 -0
- package/dist/room-session.cjs +2336 -0
- package/dist/room-session.cjs.map +1 -0
- package/dist/room-session.d.cts +77 -0
- package/dist/room-session.d.ts +77 -0
- package/dist/room-session.js +103 -0
- package/dist/room-session.js.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.cjs +207 -0
- package/dist/runtime/prefab-inspection-bridge.cjs.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.d.cts +156 -0
- package/dist/runtime/prefab-inspection-bridge.d.ts +156 -0
- package/dist/runtime/prefab-inspection-bridge.js +22 -0
- package/dist/runtime/prefab-inspection-bridge.js.map +1 -0
- package/dist/runtime-control.cjs +2133 -8
- package/dist/runtime-control.cjs.map +1 -1
- package/dist/runtime-control.d.cts +980 -12
- package/dist/runtime-control.d.ts +980 -12
- package/dist/runtime-control.js +264 -4
- package/dist/runtime-control.js.map +1 -1
- package/dist/runtime-inspection.cjs +1222 -558
- package/dist/runtime-inspection.cjs.map +1 -1
- package/dist/runtime-inspection.d.cts +530 -22
- package/dist/runtime-inspection.d.ts +530 -22
- package/dist/runtime-inspection.js +21 -22
- package/dist/runtime-inspection.js.map +1 -1
- package/dist/runtime-reporting-K_ZXpubu.d.cts +43 -0
- package/dist/runtime-reporting-K_ZXpubu.d.ts +43 -0
- package/dist/runtime-topology.cjs +2 -5
- package/dist/runtime-topology.cjs.map +1 -1
- package/dist/runtime-topology.d.cts +1 -1
- package/dist/runtime-topology.d.ts +1 -1
- package/dist/runtime-topology.js +1 -1
- package/dist/runtime-topology.js.map +1 -1
- package/dist/scoped-connector-DEOZvCCG.d.cts +66 -0
- package/dist/scoped-connector-nTHACYTl.d.ts +66 -0
- package/dist/sdk-channels-S6j6AH8v.d.cts +103 -0
- package/dist/sdk-channels-S6j6AH8v.d.ts +103 -0
- package/dist/simulation-DL9j-ghn.d.ts +782 -0
- package/dist/simulation-HmgsvF5H.d.cts +782 -0
- package/dist/{standard-match-phase-BzSgBYFg.d.ts → standard-match-phase-D4N-AU0d.d.cts} +3 -13
- package/dist/{standard-match-phase-CvJUW8Oe.d.cts → standard-match-phase-abt8ZjCh.d.ts} +3 -13
- package/dist/transport-CWF29jU6.d.cts +173 -0
- package/dist/transport-CWF29jU6.d.ts +173 -0
- package/dist/types-p28maMEo.d.cts +102 -0
- package/dist/types-p28maMEo.d.ts +102 -0
- package/dist/ui.cjs +2167 -892
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +75 -17
- package/dist/ui.d.ts +75 -17
- package/dist/ui.js +554 -393
- package/dist/ui.js.map +1 -1
- package/package.json +38 -21
- package/src/agent/agent-action.ts +0 -39
- package/src/agent/agent-contract-conformance.ts +8 -1
- package/src/agent/agent-contract.ts +2 -4
- package/src/agent/agent-evaluator.ts +95 -0
- package/src/agent/capture-canvas.ts +79 -0
- package/src/agent/host-canvas-capture.ts +189 -0
- package/src/agent-tooling.ts +5 -20
- package/src/arcade/bridge/controller.ts +8 -11
- package/src/arcade/bridge/host.ts +6 -11
- package/src/arcade/bridge/iframe.ts +1 -50
- package/src/arcade/host.ts +0 -1
- package/src/arcade/surface.ts +5 -1
- package/src/arcade/url.ts +2 -9
- package/src/audio/audio-manager.ts +23 -47
- package/src/audio/hooks.tsx +59 -72
- package/src/components/controller-player-name-field.tsx +2 -2
- package/src/components/controller-primary-action.tsx +1 -1
- package/src/components/controls.tsx +398 -0
- package/src/components/gamepad-layout.tsx +69 -0
- package/src/components/join-url-controls.tsx +5 -1
- package/src/components/lifecycle-action-group.tsx +1 -1
- package/src/components/player-avatar.tsx +50 -3
- package/src/components/room-qr-code.tsx +36 -77
- package/src/components/stage-capture-surface.tsx +91 -0
- package/src/components/surface-viewport.tsx +16 -3
- package/src/components/ui/button.tsx +1 -1
- package/src/constants.ts +0 -15
- package/src/context/air-jam-context.tsx +56 -187
- package/src/context/session-providers.tsx +13 -10
- package/src/controller-bridge.ts +7 -0
- package/src/core/assets.ts +48 -0
- package/src/core/config.ts +70 -0
- package/src/core/connection-store.ts +77 -0
- package/src/core/controller-input.ts +147 -0
- package/src/core/controller-runtime.ts +427 -0
- package/src/core/dev-events.ts +18 -0
- package/src/core/environment.ts +132 -0
- package/src/core/game-description.ts +44 -0
- package/src/core/game.ts +130 -0
- package/src/core/host-input.ts +207 -0
- package/src/core/host-runtime.ts +988 -0
- package/src/core/hosted-rooms.ts +65 -0
- package/src/core/input-bindings.ts +180 -0
- package/src/core/input-log.ts +144 -0
- package/src/core/input.ts +228 -0
- package/src/core/local-input.ts +319 -0
- package/src/core/replay-input-log.ts +298 -0
- package/src/core/replicated-store.ts +1178 -0
- package/src/core/room-action-ack.ts +43 -0
- package/src/core/settings.ts +202 -0
- package/src/core/simulation.ts +307 -0
- package/src/core/theme.ts +33 -0
- package/src/core.ts +167 -0
- package/src/dev/browser-log-sink.ts +35 -12
- package/src/diagnostics.ts +5 -6
- package/src/hooks/internal/use-controller-runtime-api.ts +58 -925
- package/src/hooks/internal/use-host-runtime-api.ts +98 -1270
- package/src/hooks/internal/use-runtime-inspection-contract.ts +14 -2
- package/src/hooks/use-air-jam-controller.ts +32 -53
- package/src/hooks/use-air-jam-host.ts +59 -100
- package/src/hooks/use-air-jam-settings.ts +27 -0
- package/src/hooks/use-controller-toasts.ts +16 -19
- package/src/hooks/use-host-agent-capture.ts +31 -0
- package/src/hooks/use-lifecycle-action-group-model.ts +1 -1
- package/src/hooks/use-send-signal.ts +23 -156
- package/src/hooks/use-simulation.ts +83 -0
- package/src/index.ts +24 -85
- package/src/lifecycle/index.ts +0 -4
- package/src/lifecycle/standard-match-phase.ts +1 -22
- package/src/metadata/manifest.ts +8 -19
- package/src/metadata.ts +1 -1
- package/src/platform-machine.ts +127 -3
- package/src/prefabs/types.ts +91 -20
- package/src/prefabs/view.ts +82 -0
- package/src/prefabs.ts +19 -0
- package/src/preview/host-workspace.tsx +4 -9
- package/src/preview/identity.ts +31 -23
- package/src/preview/layout.ts +5 -1
- package/src/preview/manager.ts +205 -78
- package/src/preview/messages.ts +47 -0
- package/src/preview/ownership.ts +6 -1
- package/src/preview/url.ts +46 -23
- package/src/preview/window.tsx +26 -69
- package/src/preview/workspace-local-seats.ts +166 -0
- package/src/preview/workspace.tsx +89 -37
- package/src/preview.ts +27 -15
- package/src/protocol/actions.ts +58 -0
- package/src/protocol/arcade-platform-actions.ts +2 -16
- package/src/protocol/controller.ts +14 -174
- package/src/protocol/core.ts +8 -15
- package/src/protocol/dev-log-events.ts +5 -81
- package/src/protocol/leased-control.ts +177 -0
- package/src/protocol/room/addressing.ts +35 -0
- package/src/protocol/room/close-codes.ts +33 -0
- package/src/protocol/room/frames.ts +343 -0
- package/src/protocol/room/input-codec.ts +182 -0
- package/src/protocol/room/limits.ts +58 -0
- package/src/protocol/room/patch.ts +135 -0
- package/src/protocol/room/sdk-channels.ts +81 -0
- package/src/protocol/room/seat-id.ts +31 -0
- package/src/protocol/room/transport.ts +63 -0
- package/src/protocol/room/weight.ts +58 -0
- package/src/protocol/runtime-reporting.ts +56 -10
- package/src/protocol.ts +2 -7
- package/src/qrcode.d.ts +3 -13
- package/src/room-protocol.ts +10 -0
- package/src/room-session/browser-wake-events.ts +14 -0
- package/src/room-session/channel-state.ts +293 -0
- package/src/room-session/clock.ts +24 -0
- package/src/room-session/host-room-session.ts +379 -0
- package/src/room-session/input-lane.ts +125 -0
- package/src/room-session/listeners.ts +22 -0
- package/src/room-session/loopback-link.ts +58 -0
- package/src/room-session/phone-room-session.ts +368 -0
- package/src/room-session/port-link.ts +116 -0
- package/src/room-session/room-key.ts +9 -0
- package/src/room-session/roster.ts +23 -0
- package/src/room-session/scoped-connector.ts +577 -0
- package/src/room-session/session-link.ts +306 -0
- package/src/room-session/web-socket-link.ts +57 -0
- package/src/room-session.ts +12 -0
- package/src/runtime/air-jam-config.ts +49 -37
- package/src/runtime/air-jam-error-boundary.tsx +9 -3
- package/src/runtime/arcade-runtime-url.ts +8 -9
- package/src/runtime/browser-controller-environment.ts +116 -0
- package/src/runtime/browser-host-environment.ts +137 -0
- package/src/runtime/browser-replay.ts +211 -0
- package/src/runtime/browser-room.ts +41 -0
- package/src/runtime/connected-runtime-error-boundary.tsx +35 -8
- package/src/runtime/contracts/agent-control.ts +195 -0
- package/src/runtime/contracts/clip.ts +169 -0
- package/src/runtime/contracts/control.ts +653 -16
- package/src/runtime/contracts/controller-agent.ts +130 -0
- package/src/runtime/contracts/input-log.ts +38 -0
- package/src/runtime/contracts/inspection.ts +25 -22
- package/src/runtime/contracts/observation.ts +186 -0
- package/src/runtime/contracts/runtime-identity.ts +43 -0
- package/src/runtime/contracts/timeline.ts +59 -0
- package/src/runtime/controller-agent-bridge.ts +152 -0
- package/src/runtime/controller-bridge-context.ts +29 -0
- package/src/runtime/controller-capture.ts +50 -0
- package/src/runtime/controller-identity.ts +53 -142
- package/src/runtime/controller-presentation.ts +47 -17
- package/src/runtime/controller-press.ts +271 -0
- package/src/runtime/create-air-jam-app.tsx +103 -74
- package/src/runtime/dev-runtime-events.ts +6 -18
- package/src/runtime/embedded-parent.ts +22 -0
- package/src/runtime/embedded-runtime-adapters.ts +10 -9
- package/src/runtime/host-agent-bridge.ts +127 -0
- package/src/runtime/host-capture-boundary.tsx +92 -0
- package/src/runtime/host-capture-context.ts +7 -0
- package/src/runtime/host-clip-reader.ts +93 -0
- package/src/runtime/host-clip-recorder.ts +342 -0
- package/src/runtime/host-input-log-reader.ts +120 -0
- package/src/runtime/host-observation.ts +207 -0
- package/src/runtime/host-pace.ts +36 -0
- package/src/runtime/host-runtime-fault.ts +51 -0
- package/src/runtime/host-timeline.ts +152 -0
- package/src/runtime/local-players.tsx +96 -0
- package/src/runtime/local-seats.ts +612 -0
- package/src/runtime/participant-control.ts +162 -0
- package/src/runtime/prefab-inspection-bridge.ts +174 -0
- package/src/runtime/prefab-inspection-clock.ts +12 -0
- package/src/runtime/prefab-inspection-context.ts +20 -0
- package/src/runtime/prefab-inspection-runtime.tsx +328 -0
- package/src/runtime/preview-inspection-bridge.ts +130 -0
- package/src/runtime/replay-runtime.tsx +101 -0
- package/src/runtime/room-bridge.ts +110 -0
- package/src/runtime/runtime-owner-contexts.tsx +9 -0
- package/src/runtime/runtime-session-params.ts +20 -23
- package/src/runtime/session-runtimes.tsx +231 -64
- package/src/runtime/stage-capture.ts +25 -0
- package/src/runtime-control.ts +41 -0
- package/src/runtime-inspection.ts +14 -7
- package/src/runtime-topology.ts +7 -8
- package/src/settings/platform-settings-runtime.tsx +47 -2
- package/src/settings/platform-settings.ts +0 -65
- package/src/store/use-air-jam-store.ts +73 -0
- package/src/ui.ts +3 -3
- package/src/utils/is-rpc-serializable.ts +11 -19
- package/src/utils/url-builder.ts +0 -7
- package/dist/air-jam-context-BlLPvCup.d.cts +0 -175
- package/dist/air-jam-context-DTsxF-tP.d.ts +0 -175
- package/dist/arcade/bridge.cjs +0 -1087
- package/dist/arcade/bridge.cjs.map +0 -1
- package/dist/arcade/bridge.d.cts +0 -11
- package/dist/arcade/bridge.d.ts +0 -11
- package/dist/arcade/bridge.js +0 -78
- package/dist/arcade/bridge.js.map +0 -1
- package/dist/arcade-runtime-url-BW-MUAOY.d.cts +0 -28
- package/dist/arcade-runtime-url-l8qj01Pg.d.ts +0 -28
- package/dist/arcade.cjs +0 -1767
- package/dist/arcade.cjs.map +0 -1
- package/dist/arcade.d.cts +0 -18
- package/dist/arcade.d.ts +0 -18
- package/dist/arcade.js +0 -129
- package/dist/arcade.js.map +0 -1
- package/dist/chunk-2SZ2YYGJ.js +0 -280
- package/dist/chunk-2SZ2YYGJ.js.map +0 -1
- package/dist/chunk-32RSSFSF.js +0 -214
- package/dist/chunk-32RSSFSF.js.map +0 -1
- package/dist/chunk-3USU7GY2.js.map +0 -1
- package/dist/chunk-3YMUAKPU.js +0 -10
- package/dist/chunk-3YMUAKPU.js.map +0 -1
- package/dist/chunk-56DM2KEW.js +0 -14
- package/dist/chunk-56DM2KEW.js.map +0 -1
- package/dist/chunk-BE6Z4SIT.js.map +0 -1
- package/dist/chunk-CM53YLT5.js +0 -59
- package/dist/chunk-CM53YLT5.js.map +0 -1
- package/dist/chunk-CV3PBXPT.js.map +0 -1
- package/dist/chunk-D4VDEVTZ.js.map +0 -1
- package/dist/chunk-EVZJA6RN.js.map +0 -1
- package/dist/chunk-FUA6EMSJ.js +0 -90
- package/dist/chunk-FUA6EMSJ.js.map +0 -1
- package/dist/chunk-GMLU7RI5.js +0 -70
- package/dist/chunk-GMLU7RI5.js.map +0 -1
- package/dist/chunk-IG6GZZSS.js.map +0 -1
- package/dist/chunk-IKKDONQL.js +0 -1
- package/dist/chunk-IKKDONQL.js.map +0 -1
- package/dist/chunk-ITMQSBTH.js +0 -26
- package/dist/chunk-ITMQSBTH.js.map +0 -1
- package/dist/chunk-J5MCII33.js +0 -620
- package/dist/chunk-J5MCII33.js.map +0 -1
- package/dist/chunk-JTF47B56.js +0 -1
- package/dist/chunk-JTF47B56.js.map +0 -1
- package/dist/chunk-K4OZ54UD.js.map +0 -1
- package/dist/chunk-LIHEEAVE.js +0 -191
- package/dist/chunk-LIHEEAVE.js.map +0 -1
- package/dist/chunk-LIXPF4P6.js +0 -22
- package/dist/chunk-LIXPF4P6.js.map +0 -1
- package/dist/chunk-MIMPMB7O.js.map +0 -1
- package/dist/chunk-MPDMJIX5.js +0 -1
- package/dist/chunk-MPDMJIX5.js.map +0 -1
- package/dist/chunk-O6X7FJ6N.js.map +0 -1
- package/dist/chunk-PSUYTD2L.js.map +0 -1
- package/dist/chunk-QO4KFUEI.js +0 -32
- package/dist/chunk-QO4KFUEI.js.map +0 -1
- package/dist/chunk-QTLYZADF.js +0 -125
- package/dist/chunk-QTLYZADF.js.map +0 -1
- package/dist/chunk-TGRTEWYV.js +0 -195
- package/dist/chunk-TGRTEWYV.js.map +0 -1
- package/dist/chunk-TTQDHKXL.js +0 -3017
- package/dist/chunk-TTQDHKXL.js.map +0 -1
- package/dist/chunk-UCPY7UJC.js +0 -8
- package/dist/chunk-UCPY7UJC.js.map +0 -1
- package/dist/chunk-UPV6YWT5.js +0 -43
- package/dist/chunk-UPV6YWT5.js.map +0 -1
- package/dist/chunk-UWJOIVON.js.map +0 -1
- package/dist/chunk-W2VK36RO.js +0 -11
- package/dist/chunk-W2VK36RO.js.map +0 -1
- package/dist/chunk-X24K52DG.js.map +0 -1
- package/dist/chunk-X35LLCWV.js.map +0 -1
- package/dist/chunk-YXHH3MQT.js +0 -230
- package/dist/chunk-YXHH3MQT.js.map +0 -1
- package/dist/controller-PZEM_1cH.d.ts +0 -176
- package/dist/controller-vj82tKm4.d.cts +0 -176
- package/dist/dev-log-events-BCJKmygo.d.cts +0 -120
- package/dist/dev-log-events-BCJKmygo.d.ts +0 -120
- package/dist/handshake-CC_LrK5g.d.cts +0 -31
- package/dist/handshake-CC_LrK5g.d.ts +0 -31
- package/dist/host-B9pRy0Aa.d.cts +0 -122
- package/dist/host-DylGsX7p.d.ts +0 -122
- package/dist/notices-C4bao3oi.d.ts +0 -38
- package/dist/notices-DNdOjwtj.d.cts +0 -38
- package/dist/realtime-client-Cu8yVJFw.d.cts +0 -15
- package/dist/realtime-client-Cu8yVJFw.d.ts +0 -15
- package/dist/runtime-reporting-pe-eryVz.d.cts +0 -27
- package/dist/runtime-reporting-pe-eryVz.d.ts +0 -27
- package/dist/signals-ZHftIKuc.d.cts +0 -33
- package/dist/signals-ZHftIKuc.d.ts +0 -33
- package/dist/sync-xtPfWhif.d.cts +0 -81
- package/dist/sync-xtPfWhif.d.ts +0 -81
- package/src/arcade/bridge.ts +0 -3
- package/src/arcade.ts +0 -4
- package/src/context/socket-manager.ts +0 -72
- package/src/events.ts +0 -119
- package/src/hooks/use-connection-status.ts +0 -8
- package/src/hooks/use-controller-tick.ts +0 -65
- package/src/hooks/use-get-input.ts +0 -100
- package/src/hooks/use-host-arcade-restore.ts +0 -35
- package/src/hooks/use-host-tick.ts +0 -171
- package/src/hooks/use-input-writer.ts +0 -83
- package/src/hooks/use-players.ts +0 -12
- package/src/internal/input-manager.ts +0 -356
- package/src/protocol/errors.ts +0 -21
- package/src/protocol/host-grant.ts +0 -103
- package/src/protocol/host.ts +0 -150
- package/src/protocol/notices.ts +0 -43
- package/src/protocol/signals.ts +0 -38
- package/src/protocol/socket-events.ts +0 -152
- package/src/protocol/sync.ts +0 -105
- package/src/runtime/admission-retry.ts +0 -62
- package/src/runtime/bridge-envelope-args.ts +0 -21
- package/src/runtime/controller-bridge.ts +0 -439
- package/src/runtime/controller-realtime-client.ts +0 -552
- package/src/runtime/host-bridge.ts +0 -380
- package/src/runtime/host-realtime-client.ts +0 -550
- package/src/runtime/realtime-client.ts +0 -20
- package/src/runtime/validate-arcade-bridge-attach.ts +0 -14
- package/src/state/connection-store.ts +0 -159
- package/src/store/create-air-jam-store.ts +0 -1193
- package/src/store/index.ts +0 -1
- package/src/utils/ids.ts +0 -58
package/dist/preview.cjs
CHANGED
|
@@ -30,30 +30,38 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/preview.ts
|
|
31
31
|
var preview_exports = {};
|
|
32
32
|
__export(preview_exports, {
|
|
33
|
-
|
|
34
|
-
AIR_JAM_PREVIEW_FLAG_QUERY_PARAM: () => AIR_JAM_PREVIEW_FLAG_QUERY_PARAM,
|
|
33
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM: () => AIR_JAM_LOCAL_SEAT_QUERY_PARAM,
|
|
35
34
|
HostPreviewControllerWorkspace: () => HostPreviewControllerWorkspace,
|
|
36
35
|
PreviewControllerWindow: () => PreviewControllerWindow,
|
|
37
36
|
PreviewControllerWorkspace: () => PreviewControllerWorkspace,
|
|
38
37
|
buildPreviewControllerUrl: () => buildPreviewControllerUrl,
|
|
39
|
-
createPreviewControllerIdentity: () => createPreviewControllerIdentity,
|
|
40
38
|
createPreviewControllerLaunch: () => createPreviewControllerLaunch,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
getPreviewControllerViewportSize: () => getPreviewControllerViewportSize,
|
|
40
|
+
getPreviewHostViewportSize: () => getPreviewHostViewportSize,
|
|
41
|
+
isLocalSeatReadyMessage: () => isLocalSeatReadyMessage,
|
|
42
|
+
isLocalSeatRelayedMessage: () => isLocalSeatRelayedMessage,
|
|
43
|
+
isPreviewSeatMessage: () => isPreviewSeatMessage,
|
|
44
|
+
localInputOperationSchema: () => localInputOperationSchema,
|
|
45
|
+
localSeatMessages: () => localSeatMessages,
|
|
46
|
+
localSeatQuerySchema: () => localSeatQuerySchema,
|
|
47
|
+
localSeatRelaySchema: () => localSeatRelaySchema,
|
|
48
|
+
localSeatRequestSchema: () => localSeatRequestSchema,
|
|
46
49
|
readPreviewControllerDeviceIdFromSearchParams: () => readPreviewControllerDeviceIdFromSearchParams,
|
|
47
|
-
|
|
50
|
+
relayLocalSeatInput: () => relayLocalSeatInput,
|
|
51
|
+
requestPreviewControllerClose: () => requestPreviewControllerClose,
|
|
52
|
+
sendLocalSeatOperation: () => sendLocalSeatOperation,
|
|
48
53
|
usePreviewControllerManager: () => usePreviewControllerManager
|
|
49
54
|
});
|
|
50
55
|
module.exports = __toCommonJS(preview_exports);
|
|
51
56
|
|
|
52
57
|
// src/context/air-jam-context.tsx
|
|
53
58
|
var import_react = require("react");
|
|
54
|
-
var
|
|
59
|
+
var import_zustand = require("zustand");
|
|
55
60
|
var import_shallow = require("zustand/react/shallow");
|
|
56
61
|
|
|
62
|
+
// src/core/connection-store.ts
|
|
63
|
+
var import_vanilla = require("zustand/vanilla");
|
|
64
|
+
|
|
57
65
|
// src/diagnostics.ts
|
|
58
66
|
var listeners = /* @__PURE__ */ new Set();
|
|
59
67
|
var lastEmissionByKey = /* @__PURE__ */ new Map();
|
|
@@ -110,20 +118,47 @@ var createAirJamDiagnosticError = (code, message, details) => {
|
|
|
110
118
|
return error;
|
|
111
119
|
};
|
|
112
120
|
|
|
113
|
-
// src/protocol/
|
|
121
|
+
// src/protocol/actions.ts
|
|
114
122
|
var import_zod = require("zod");
|
|
115
|
-
var
|
|
123
|
+
var airJamActionPayloadSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.unknown());
|
|
124
|
+
var airJamActionAcceptedSchema = import_zod.z.object({
|
|
125
|
+
ok: import_zod.z.literal(true),
|
|
126
|
+
status: import_zod.z.literal("accepted"),
|
|
127
|
+
source: import_zod.z.enum(["client", "host"]),
|
|
128
|
+
result: import_zod.z.unknown().optional()
|
|
129
|
+
});
|
|
130
|
+
var airJamActionRejectedSchema = import_zod.z.object({
|
|
131
|
+
ok: import_zod.z.literal(false),
|
|
132
|
+
status: import_zod.z.literal("rejected"),
|
|
133
|
+
source: import_zod.z.enum(["client", "server", "host"]),
|
|
134
|
+
reason: import_zod.z.string(),
|
|
135
|
+
message: import_zod.z.string(),
|
|
136
|
+
details: airJamActionPayloadSchema.optional()
|
|
137
|
+
});
|
|
138
|
+
var airJamActionUnconfirmedSchema = import_zod.z.object({
|
|
139
|
+
ok: import_zod.z.literal(false),
|
|
140
|
+
status: import_zod.z.literal("unconfirmed"),
|
|
141
|
+
source: import_zod.z.literal("client")
|
|
142
|
+
});
|
|
143
|
+
var airJamActionInvocationResultSchema = import_zod.z.discriminatedUnion(
|
|
144
|
+
"status",
|
|
145
|
+
[
|
|
146
|
+
airJamActionAcceptedSchema,
|
|
147
|
+
airJamActionRejectedSchema,
|
|
148
|
+
airJamActionUnconfirmedSchema
|
|
149
|
+
]
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// src/protocol/arcade-platform-actions.ts
|
|
153
|
+
var import_zod2 = require("zod");
|
|
154
|
+
var arcadeBrowserConfirmPayloadSchema = import_zod2.z.object({ epoch: import_zod2.z.number().int().positive().safe() }).strict();
|
|
116
155
|
var arcadeBrowserNavigatePayloadSchema = arcadeBrowserConfirmPayloadSchema.extend({
|
|
117
|
-
direction:
|
|
156
|
+
direction: import_zod2.z.enum(["up", "down", "left", "right"])
|
|
118
157
|
});
|
|
119
158
|
|
|
120
159
|
// src/protocol/controller.ts
|
|
121
160
|
var import_zod3 = require("zod");
|
|
122
161
|
|
|
123
|
-
// src/protocol/core.ts
|
|
124
|
-
var import_zod2 = require("zod");
|
|
125
|
-
var roomCodeSchema = import_zod2.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, { message: "room code must contain only A-Z or 0-9" });
|
|
126
|
-
|
|
127
162
|
// src/settings/platform-settings.ts
|
|
128
163
|
var DEFAULT_PLATFORM_SETTINGS = {
|
|
129
164
|
audio: {
|
|
@@ -148,76 +183,26 @@ var DEFAULT_ROOM_PLATFORM_SETTINGS = {
|
|
|
148
183
|
};
|
|
149
184
|
|
|
150
185
|
// src/protocol/controller.ts
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
var controllerOrientationSchema = import_zod3.z.enum(["portrait", "landscape"]);
|
|
157
|
-
var controllerSourceSchema = import_zod3.z.enum(["phone", "preview", "virtual"]);
|
|
158
|
-
var controllerStateSchema = import_zod3.z.object({
|
|
159
|
-
roomId: roomCodeSchema,
|
|
160
|
-
state: import_zod3.z.object({
|
|
161
|
-
orientation: controllerOrientationSchema.optional(),
|
|
162
|
-
message: import_zod3.z.string().optional(),
|
|
163
|
-
roomSettings: import_zod3.z.object({
|
|
164
|
-
audio: import_zod3.z.object({
|
|
165
|
-
masterVolume: import_zod3.z.number().min(0).max(1),
|
|
166
|
-
musicVolume: import_zod3.z.number().min(0).max(1),
|
|
167
|
-
sfxVolume: import_zod3.z.number().min(0).max(1)
|
|
168
|
-
}),
|
|
169
|
-
previewControllers: import_zod3.z.object({
|
|
170
|
-
activeOpacity: import_zod3.z.number().min(0).max(1)
|
|
171
|
-
})
|
|
172
|
-
}).optional(),
|
|
173
|
-
runtimeState: import_zod3.z.enum(["paused", "playing"]).optional(),
|
|
174
|
-
stateVersion: import_zod3.z.number().int().nonnegative().optional()
|
|
175
|
-
})
|
|
176
|
-
});
|
|
177
|
-
var controllerJoinSchema = import_zod3.z.object({
|
|
178
|
-
roomId: roomCodeSchema,
|
|
179
|
-
controllerId: import_zod3.z.string().min(3),
|
|
180
|
-
/**
|
|
181
|
-
* Local device/source hint, never authority to resume a controller slot.
|
|
182
|
-
*/
|
|
183
|
-
deviceId: import_zod3.z.string().min(8).max(128).optional(),
|
|
184
|
-
nickname: import_zod3.z.string().trim().min(1).max(24).optional(),
|
|
185
|
-
/** Preset avatar key (platform-defined); optional at join. */
|
|
186
|
-
avatarId: import_zod3.z.string().trim().min(1).max(48).optional(),
|
|
187
|
-
capabilityToken: import_zod3.z.string().min(1).optional(),
|
|
188
|
-
/** Private server-issued proof required to resume an existing controller. */
|
|
189
|
-
resumeCapabilityToken: import_zod3.z.string().min(1).max(128).optional()
|
|
190
|
-
});
|
|
191
|
-
var controllerLeaveSchema = import_zod3.z.object({
|
|
192
|
-
roomId: roomCodeSchema,
|
|
193
|
-
controllerId: import_zod3.z.string().min(3)
|
|
194
|
-
});
|
|
195
|
-
var controllerSystemSchema = import_zod3.z.object({
|
|
196
|
-
roomId: roomCodeSchema,
|
|
197
|
-
command: import_zod3.z.enum(["exit", "pause", "resume"])
|
|
186
|
+
var playerProfileSchema = import_zod3.z.object({
|
|
187
|
+
id: import_zod3.z.string(),
|
|
188
|
+
label: import_zod3.z.string(),
|
|
189
|
+
color: import_zod3.z.string().optional(),
|
|
190
|
+
avatarId: import_zod3.z.string().optional()
|
|
198
191
|
});
|
|
199
192
|
var playerProfilePatchSchema = import_zod3.z.object({
|
|
200
193
|
label: import_zod3.z.string().trim().min(1).max(24).optional(),
|
|
201
194
|
avatarId: import_zod3.z.string().trim().min(1).max(48).optional()
|
|
202
195
|
}).strict();
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
"system",
|
|
213
|
-
"play_sound",
|
|
214
|
-
"action_rpc"
|
|
196
|
+
|
|
197
|
+
// src/protocol/core.ts
|
|
198
|
+
var import_zod4 = require("zod");
|
|
199
|
+
var connectionStatusSchema = import_zod4.z.enum([
|
|
200
|
+
"idle",
|
|
201
|
+
"connecting",
|
|
202
|
+
"connected",
|
|
203
|
+
"disconnected",
|
|
204
|
+
"reconnecting"
|
|
215
205
|
]);
|
|
216
|
-
var controllerPrivilegedCapabilitySchema = import_zod3.z.object({
|
|
217
|
-
token: import_zod3.z.string().min(1),
|
|
218
|
-
expiresAt: import_zod3.z.number().int().positive(),
|
|
219
|
-
grants: import_zod3.z.array(controllerPrivilegedGrantSchema).min(1)
|
|
220
|
-
});
|
|
221
206
|
|
|
222
207
|
// src/protocol/dev-log-events.ts
|
|
223
208
|
var AIRJAM_DEV_LOG_EVENTS = {
|
|
@@ -225,18 +210,9 @@ var AIRJAM_DEV_LOG_EVENTS = {
|
|
|
225
210
|
started: "server.started",
|
|
226
211
|
startupFailed: "server.startup.failed"
|
|
227
212
|
},
|
|
228
|
-
socket: {
|
|
229
|
-
connected: "socket.connected",
|
|
230
|
-
disconnected: "socket.disconnected"
|
|
231
|
-
},
|
|
232
213
|
auth: {
|
|
233
214
|
modeDisabled: "auth.mode.disabled",
|
|
234
|
-
modeMasterKey: "auth.mode.master_key"
|
|
235
|
-
modeDatabaseAndHostGrant: "auth.mode.database_and_host_grant",
|
|
236
|
-
modeDatabase: "auth.mode.database",
|
|
237
|
-
backendMissing: "auth.backend.missing",
|
|
238
|
-
appIdLastUsedAtUpdateFailed: "auth.app_id_last_used_at_update.failed",
|
|
239
|
-
appIdVerificationDatabaseError: "auth.app_id_verification.database_error"
|
|
215
|
+
modeMasterKey: "auth.mode.master_key"
|
|
240
216
|
},
|
|
241
217
|
browser: {
|
|
242
218
|
logSessionStarted: "browser.log_session.started",
|
|
@@ -252,82 +228,18 @@ var AIRJAM_DEV_LOG_EVENTS = {
|
|
|
252
228
|
providerUnmounted: "runtime.provider.unmounted",
|
|
253
229
|
windowBeforeUnload: "runtime.window.beforeunload",
|
|
254
230
|
windowPageHide: "runtime.window.pagehide",
|
|
255
|
-
|
|
256
|
-
socketDisconnected: "runtime.socket.disconnected",
|
|
257
|
-
socketConnectError: "runtime.socket.connect_error",
|
|
258
|
-
hostCreateRoomRequested: "runtime.host.create_room.requested",
|
|
259
|
-
hostReconnectRequested: "runtime.host.reconnect.requested",
|
|
260
|
-
hostReconnectRetryScheduled: "runtime.host.reconnect.retry_scheduled",
|
|
231
|
+
roomStatus: "runtime.room.status",
|
|
261
232
|
hostResetRoomRequested: "runtime.host.reset_room.requested",
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
233
|
+
clipCaptureFailed: "runtime.host.clip_capture_failed",
|
|
234
|
+
hostFrameFault: "runtime.host.frame_fault",
|
|
235
|
+
errorReport: "runtime.error_report",
|
|
265
236
|
phaseTransition: "runtime.phase.transition",
|
|
266
|
-
stateVersionReceived: "runtime.state_version.received",
|
|
267
|
-
invariantViolation: "runtime.invariant.violation",
|
|
268
237
|
embeddedBridgeRequested: "runtime.embedded_bridge.requested",
|
|
269
|
-
embeddedBridgeAttached: "runtime.embedded_bridge.attached",
|
|
270
238
|
embeddedBridgeRejected: "runtime.embedded_bridge.rejected",
|
|
271
|
-
embeddedBridgeClosed: "runtime.embedded_bridge.closed",
|
|
272
239
|
browserLogSinkFailure: "runtime.browser_log_sink.failure"
|
|
273
240
|
},
|
|
274
241
|
host: {
|
|
275
|
-
|
|
276
|
-
bootstrapVerified: "host.bootstrap.verified",
|
|
277
|
-
bootstrapRejected: "host.bootstrap.rejected",
|
|
278
|
-
disconnectPendingRoomClose: "host.disconnect.pending_room_close",
|
|
279
|
-
disconnectRoomClosed: "host.disconnect.room_closed",
|
|
280
|
-
createRoomAccepted: "host.create_room.accepted",
|
|
281
|
-
createRoomRejected: "host.create_room.rejected",
|
|
282
|
-
reconnectAccepted: "host.reconnect.accepted",
|
|
283
|
-
reconnectRejected: "host.reconnect.rejected",
|
|
284
|
-
resetRoomAccepted: "host.reset_room.accepted",
|
|
285
|
-
resetRoomRejected: "host.reset_room.rejected",
|
|
286
|
-
systemAccepted: "host.system.accepted",
|
|
287
|
-
systemRejected: "host.system.rejected",
|
|
288
|
-
stateRejected: "host.state.rejected",
|
|
289
|
-
signalRejected: "host.signal.rejected",
|
|
290
|
-
playSoundRejected: "host.play_sound.rejected",
|
|
291
|
-
stateBroadcastSummary: "host.state_broadcast.summary",
|
|
292
|
-
reconnectStateReconcile: "host.reconnect.state_reconcile",
|
|
293
|
-
stateSyncSummary: "host.state_sync.summary",
|
|
294
|
-
stateSyncRejected: "host.state_sync.rejected"
|
|
295
|
-
},
|
|
296
|
-
controller: {
|
|
297
|
-
joinAccepted: "controller.join.accepted",
|
|
298
|
-
joinRejected: "controller.join.rejected",
|
|
299
|
-
resumeAccepted: "controller.resume.accepted",
|
|
300
|
-
disconnectPendingResume: "controller.disconnect.pending_resume",
|
|
301
|
-
disconnectLeaseExpired: "controller.disconnect.lease_expired",
|
|
302
|
-
disconnectApplied: "controller.disconnect.applied",
|
|
303
|
-
profileUpdateAccepted: "controller.profile_update.accepted",
|
|
304
|
-
profileUpdateRejected: "controller.profile_update.rejected",
|
|
305
|
-
leaveAccepted: "controller.leave.accepted",
|
|
306
|
-
leaveRejected: "controller.leave.rejected",
|
|
307
|
-
inputSummary: "controller.input.summary",
|
|
308
|
-
inputDroppedSummary: "controller.input_dropped.summary",
|
|
309
|
-
inputRejected: "controller.input.rejected",
|
|
310
|
-
systemAccepted: "controller.system.accepted",
|
|
311
|
-
systemRejected: "controller.system.rejected",
|
|
312
|
-
playSoundRejected: "controller.play_sound.rejected",
|
|
313
|
-
actionRpcSummary: "controller.action_rpc.summary",
|
|
314
|
-
actionRpcRejected: "controller.action_rpc.rejected"
|
|
315
|
-
},
|
|
316
|
-
system: {
|
|
317
|
-
launchGameAccepted: "system.launch_game.accepted",
|
|
318
|
-
launchGameRejected: "system.launch_game.rejected",
|
|
319
|
-
closeGameAccepted: "system.close_game.accepted",
|
|
320
|
-
closeGameRejected: "system.close_game.rejected"
|
|
321
|
-
},
|
|
322
|
-
childHost: {
|
|
323
|
-
joinAccepted: "child_host.join.accepted",
|
|
324
|
-
joinRejected: "child_host.join.rejected",
|
|
325
|
-
disconnectPendingSystemFocus: "child_host.disconnect.pending_system_focus",
|
|
326
|
-
disconnectSystemFocusRestored: "child_host.disconnect.system_focus_restored"
|
|
327
|
-
},
|
|
328
|
-
embeddedGame: {
|
|
329
|
-
activateAccepted: "embedded_game.activate.accepted",
|
|
330
|
-
activateRejected: "embedded_game.activate.rejected"
|
|
242
|
+
stateRestoreDiscarded: "host.state_restore.discarded"
|
|
331
243
|
}
|
|
332
244
|
};
|
|
333
245
|
var AIRJAM_BROWSER_LOG_EVENT_BY_SOURCE = {
|
|
@@ -338,109 +250,499 @@ var AIRJAM_BROWSER_LOG_EVENT_BY_SOURCE = {
|
|
|
338
250
|
runtime: AIRJAM_DEV_LOG_EVENTS.browser.runtime
|
|
339
251
|
};
|
|
340
252
|
|
|
341
|
-
// src/protocol/
|
|
342
|
-
var
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
253
|
+
// src/protocol/leased-control.ts
|
|
254
|
+
var import_zod11 = require("zod");
|
|
255
|
+
|
|
256
|
+
// src/protocol/room/addressing.ts
|
|
257
|
+
var import_zod5 = require("zod");
|
|
258
|
+
var roomCodeSchema = import_zod5.z.string().regex(/^[A-Z0-9]{4,8}$/);
|
|
259
|
+
|
|
260
|
+
// src/protocol/room/frames.ts
|
|
261
|
+
var import_zod8 = require("zod");
|
|
262
|
+
|
|
263
|
+
// src/protocol/room/limits.ts
|
|
264
|
+
var import_zod6 = require("zod");
|
|
265
|
+
var MAXIMUM_ROOM_SEATS = 16;
|
|
266
|
+
var count = import_zod6.z.number().int().positive();
|
|
267
|
+
var duration = import_zod6.z.number().int().nonnegative();
|
|
268
|
+
var roomLimitsShape = {
|
|
269
|
+
seats: count.max(MAXIMUM_ROOM_SEATS),
|
|
270
|
+
channels: count,
|
|
271
|
+
/** How often a phone may send its controls; phones coalesce to it. */
|
|
272
|
+
inputIntervalMs: count,
|
|
273
|
+
/** One phone's whole control state; a host input record states its length in one byte. */
|
|
274
|
+
inputBytes: count.max(255),
|
|
275
|
+
inputsPerSecond: count,
|
|
276
|
+
/** The most a channel's document, or any one state frame, may weigh. */
|
|
277
|
+
stateBytes: count,
|
|
278
|
+
statesPerSecond: count,
|
|
279
|
+
/** The most any other text frame may weigh. */
|
|
280
|
+
frameBytes: count,
|
|
281
|
+
/** Text frames other than state, per connection. */
|
|
282
|
+
framesPerSecond: count,
|
|
283
|
+
/** Frames that do not parse, within one second, before the connection is closed. */
|
|
284
|
+
strikesPerSecond: count,
|
|
285
|
+
seatHoldMs: duration,
|
|
286
|
+
/** How long the room waits for its host, as it opens and after the host's connection ends. */
|
|
287
|
+
hostGraceMs: count,
|
|
288
|
+
maximumAgeMs: count
|
|
289
|
+
};
|
|
290
|
+
var roomLimitsSchema = import_zod6.z.strictObject(roomLimitsShape);
|
|
291
|
+
var roomLimitsWireSchema = import_zod6.z.object(roomLimitsShape);
|
|
292
|
+
var DEFAULT_ROOM_LIMITS = Object.freeze({
|
|
293
|
+
seats: MAXIMUM_ROOM_SEATS,
|
|
294
|
+
channels: 8,
|
|
295
|
+
inputIntervalMs: 16,
|
|
296
|
+
inputBytes: 64,
|
|
297
|
+
inputsPerSecond: 120,
|
|
298
|
+
stateBytes: 65536,
|
|
299
|
+
statesPerSecond: 60,
|
|
300
|
+
frameBytes: 8192,
|
|
301
|
+
framesPerSecond: 60,
|
|
302
|
+
strikesPerSecond: 64,
|
|
303
|
+
seatHoldMs: 12e4,
|
|
304
|
+
hostGraceMs: 6e4,
|
|
305
|
+
maximumAgeMs: 24 * 60 * 60 * 1e3
|
|
347
306
|
});
|
|
348
|
-
|
|
349
|
-
|
|
307
|
+
|
|
308
|
+
// src/protocol/room/patch.ts
|
|
309
|
+
var isPlainObject = (value) => {
|
|
310
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
311
|
+
return false;
|
|
312
|
+
const prototype = Object.getPrototypeOf(value);
|
|
313
|
+
return prototype === Object.prototype || prototype === null;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// src/protocol/room/seat-id.ts
|
|
317
|
+
var import_zod7 = require("zod");
|
|
318
|
+
var seatIdSchema = import_zod7.z.string().regex(/^p[1-9][0-9]{0,4}$/);
|
|
319
|
+
|
|
320
|
+
// src/protocol/room/frames.ts
|
|
321
|
+
var MAXIMUM_FRAME_DEPTH = 32;
|
|
322
|
+
var keySchema = import_zod8.z.string().min(16).max(128);
|
|
323
|
+
var instanceSchema = import_zod8.z.string().min(1).max(64);
|
|
324
|
+
var channelSchema = import_zod8.z.string().min(1).max(128);
|
|
325
|
+
var revisionSchema = import_zod8.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
326
|
+
var requestIdSchema = import_zod8.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
327
|
+
var featuresSchema = import_zod8.z.array(import_zod8.z.string().min(1).max(64)).max(32);
|
|
328
|
+
var documentSchema = import_zod8.z.custom(isPlainObject, {
|
|
329
|
+
message: "A state document is a plain JSON object."
|
|
350
330
|
});
|
|
351
|
-
var
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
331
|
+
var pathSchema = import_zod8.z.array(import_zod8.z.string()).min(1).max(32);
|
|
332
|
+
var seatKindSchema = import_zod8.z.enum(["phone", "preview", "agent"]);
|
|
333
|
+
var seatProfileSchema = import_zod8.z.object({
|
|
334
|
+
label: import_zod8.z.string().trim().min(1).max(24).optional(),
|
|
335
|
+
avatarId: import_zod8.z.string().trim().min(1).max(48).optional(),
|
|
336
|
+
/** Shown instead of the label while a local seat plays through this phone. */
|
|
337
|
+
localSeatLabel: import_zod8.z.string().trim().min(1).max(32).optional()
|
|
355
338
|
});
|
|
356
|
-
var
|
|
357
|
-
|
|
358
|
-
|
|
339
|
+
var helloFields = {
|
|
340
|
+
type: import_zod8.z.literal("hello"),
|
|
341
|
+
key: keySchema,
|
|
342
|
+
instance: instanceSchema.optional(),
|
|
343
|
+
sdk: import_zod8.z.string().min(1).max(64),
|
|
344
|
+
features: featuresSchema.optional()
|
|
345
|
+
};
|
|
346
|
+
var hostHelloSchema = import_zod8.z.object({
|
|
347
|
+
...helloFields,
|
|
348
|
+
/** Opaque to the room; the gate reads it before the room opens. */
|
|
349
|
+
credential: import_zod8.z.string().min(1).max(8192).optional(),
|
|
350
|
+
/** How many players the game takes; the room admits no more. */
|
|
351
|
+
seats: import_zod8.z.number().int().min(1).max(MAXIMUM_ROOM_SEATS)
|
|
359
352
|
});
|
|
360
|
-
var
|
|
361
|
-
|
|
362
|
-
|
|
353
|
+
var phoneHelloSchema = import_zod8.z.object({
|
|
354
|
+
...helloFields,
|
|
355
|
+
kind: seatKindSchema,
|
|
356
|
+
profile: seatProfileSchema.optional(),
|
|
357
|
+
/**
|
|
358
|
+
* The page this phone runs in, the same across its reconnects. A seat
|
|
359
|
+
* resumed from another page (a reload, or another tab taking it over)
|
|
360
|
+
* starts its controls afresh, so the host takes a new input baseline.
|
|
361
|
+
*/
|
|
362
|
+
page: import_zod8.z.string().min(1).max(64).optional()
|
|
363
363
|
});
|
|
364
|
-
var
|
|
365
|
-
|
|
366
|
-
|
|
364
|
+
var statePatchFields = {
|
|
365
|
+
type: import_zod8.z.literal("state"),
|
|
366
|
+
channel: channelSchema,
|
|
367
|
+
revision: revisionSchema,
|
|
368
|
+
base: revisionSchema,
|
|
369
|
+
set: import_zod8.z.array(import_zod8.z.tuple([pathSchema, import_zod8.z.unknown()])).default([]),
|
|
370
|
+
unset: import_zod8.z.array(pathSchema).default([])
|
|
371
|
+
};
|
|
372
|
+
var stateDocumentFields = {
|
|
373
|
+
type: import_zod8.z.literal("state"),
|
|
374
|
+
channel: channelSchema,
|
|
375
|
+
revision: revisionSchema,
|
|
376
|
+
document: documentSchema
|
|
377
|
+
};
|
|
378
|
+
var hostStateFrameSchema = import_zod8.z.union([
|
|
379
|
+
import_zod8.z.object({
|
|
380
|
+
...stateDocumentFields,
|
|
381
|
+
/** The store's shape, so a reloading host knows whether to take its state back. */
|
|
382
|
+
fingerprint: import_zod8.z.string().min(1).max(256).optional(),
|
|
383
|
+
/** A top-level field keyed by seat whose entries only their own seat sees. */
|
|
384
|
+
private: import_zod8.z.string().min(1).max(128).optional()
|
|
385
|
+
}),
|
|
386
|
+
import_zod8.z.object(statePatchFields).refine(
|
|
387
|
+
(frame) => frame.revision > frame.base,
|
|
388
|
+
"A patch produces a later revision than its base."
|
|
389
|
+
)
|
|
390
|
+
]);
|
|
391
|
+
var hostToRoomFrameSchemas = {
|
|
392
|
+
state: hostStateFrameSchema,
|
|
393
|
+
response: import_zod8.z.object({
|
|
394
|
+
type: import_zod8.z.literal("response"),
|
|
395
|
+
seat: seatIdSchema,
|
|
396
|
+
id: requestIdSchema,
|
|
397
|
+
result: import_zod8.z.unknown().optional()
|
|
398
|
+
}),
|
|
399
|
+
signal: import_zod8.z.object({
|
|
400
|
+
type: import_zod8.z.literal("signal"),
|
|
401
|
+
seat: seatIdSchema.optional(),
|
|
402
|
+
kind: import_zod8.z.string().min(1).max(64),
|
|
403
|
+
payload: import_zod8.z.unknown().optional()
|
|
404
|
+
}),
|
|
405
|
+
room: import_zod8.z.object({
|
|
406
|
+
type: import_zod8.z.literal("room"),
|
|
407
|
+
seats: import_zod8.z.number().int().min(1).max(MAXIMUM_ROOM_SEATS).optional(),
|
|
408
|
+
locked: import_zod8.z.boolean().optional()
|
|
409
|
+
}),
|
|
410
|
+
remove: import_zod8.z.object({ type: import_zod8.z.literal("remove"), seat: seatIdSchema }),
|
|
411
|
+
drop: import_zod8.z.object({ type: import_zod8.z.literal("drop"), channel: channelSchema }),
|
|
412
|
+
activity: import_zod8.z.object({
|
|
413
|
+
type: import_zod8.z.literal("activity"),
|
|
414
|
+
activity: import_zod8.z.string().min(1).max(128).nullable()
|
|
415
|
+
}),
|
|
416
|
+
end: import_zod8.z.object({ type: import_zod8.z.literal("end") })
|
|
417
|
+
};
|
|
418
|
+
var phoneToRoomFrameSchemas = {
|
|
419
|
+
request: import_zod8.z.object({
|
|
420
|
+
type: import_zod8.z.literal("request"),
|
|
421
|
+
id: requestIdSchema,
|
|
422
|
+
channel: channelSchema,
|
|
423
|
+
name: import_zod8.z.string().min(1).max(128),
|
|
424
|
+
payload: import_zod8.z.unknown().optional()
|
|
425
|
+
}),
|
|
426
|
+
profile: import_zod8.z.object({
|
|
427
|
+
type: import_zod8.z.literal("profile"),
|
|
428
|
+
label: seatProfileSchema.shape.label,
|
|
429
|
+
avatarId: seatProfileSchema.shape.avatarId
|
|
430
|
+
}).refine(
|
|
431
|
+
(frame) => frame.label !== void 0 || frame.avatarId !== void 0,
|
|
432
|
+
"A profile change names a label or an avatar."
|
|
433
|
+
),
|
|
434
|
+
leave: import_zod8.z.object({ type: import_zod8.z.literal("leave") }),
|
|
435
|
+
/** This seat's controls start again from zero, as a newly loaded controller frame's do. */
|
|
436
|
+
baseline: import_zod8.z.object({ type: import_zod8.z.literal("baseline") })
|
|
437
|
+
};
|
|
438
|
+
var seatViewSchema = import_zod8.z.object({
|
|
439
|
+
id: seatIdSchema,
|
|
440
|
+
label: import_zod8.z.string(),
|
|
441
|
+
color: import_zod8.z.string(),
|
|
442
|
+
avatarId: import_zod8.z.string().optional(),
|
|
443
|
+
kind: seatKindSchema,
|
|
444
|
+
connected: import_zod8.z.boolean()
|
|
367
445
|
});
|
|
368
|
-
var
|
|
369
|
-
|
|
446
|
+
var channelCopySchema = import_zod8.z.object({
|
|
447
|
+
channel: channelSchema,
|
|
448
|
+
revision: revisionSchema,
|
|
449
|
+
document: documentSchema,
|
|
450
|
+
fingerprint: import_zod8.z.string().optional(),
|
|
451
|
+
private: import_zod8.z.string().optional()
|
|
370
452
|
});
|
|
371
|
-
var
|
|
372
|
-
|
|
373
|
-
|
|
453
|
+
var welcomeFields = {
|
|
454
|
+
type: import_zod8.z.literal("welcome"),
|
|
455
|
+
code: import_zod8.z.string(),
|
|
456
|
+
instance: instanceSchema,
|
|
457
|
+
seats: import_zod8.z.array(seatViewSchema),
|
|
458
|
+
channels: import_zod8.z.array(channelCopySchema),
|
|
459
|
+
limits: roomLimitsWireSchema,
|
|
460
|
+
features: featuresSchema
|
|
461
|
+
};
|
|
462
|
+
var roomStateFrameSchema = import_zod8.z.union([
|
|
463
|
+
import_zod8.z.object(stateDocumentFields),
|
|
464
|
+
import_zod8.z.object(statePatchFields)
|
|
465
|
+
]);
|
|
466
|
+
var roomToHostFrameSchemas = {
|
|
467
|
+
welcome: import_zod8.z.object({
|
|
468
|
+
...welcomeFields,
|
|
469
|
+
/** Seats the room admits, and whether it admits new players at all. */
|
|
470
|
+
seatsWanted: import_zod8.z.number().int().min(1).max(MAXIMUM_ROOM_SEATS),
|
|
471
|
+
locked: import_zod8.z.boolean(),
|
|
472
|
+
activity: import_zod8.z.string().nullable()
|
|
473
|
+
}),
|
|
474
|
+
wait: import_zod8.z.object({
|
|
475
|
+
type: import_zod8.z.literal("wait"),
|
|
476
|
+
position: import_zod8.z.number().int().positive()
|
|
477
|
+
}),
|
|
478
|
+
seat: import_zod8.z.object({
|
|
479
|
+
type: import_zod8.z.literal("seat"),
|
|
480
|
+
seat: seatViewSchema,
|
|
481
|
+
/** The seat's controls restart from a new page: decode them afresh. */
|
|
482
|
+
inputBaseline: import_zod8.z.literal(true).optional()
|
|
483
|
+
}),
|
|
484
|
+
left: import_zod8.z.object({ type: import_zod8.z.literal("left"), seat: seatIdSchema }),
|
|
485
|
+
need: import_zod8.z.object({ type: import_zod8.z.literal("need"), channel: channelSchema }),
|
|
486
|
+
request: import_zod8.z.object({
|
|
487
|
+
type: import_zod8.z.literal("request"),
|
|
488
|
+
seat: seatIdSchema,
|
|
489
|
+
id: requestIdSchema,
|
|
490
|
+
channel: channelSchema,
|
|
491
|
+
name: import_zod8.z.string(),
|
|
492
|
+
payload: import_zod8.z.unknown().optional()
|
|
493
|
+
})
|
|
494
|
+
};
|
|
495
|
+
var roomToPhoneFrameSchemas = {
|
|
496
|
+
welcome: import_zod8.z.object({
|
|
497
|
+
...welcomeFields,
|
|
498
|
+
seat: seatIdSchema,
|
|
499
|
+
host: import_zod8.z.boolean()
|
|
500
|
+
}),
|
|
501
|
+
seat: roomToHostFrameSchemas.seat,
|
|
502
|
+
left: roomToHostFrameSchemas.left,
|
|
503
|
+
host: import_zod8.z.object({ type: import_zod8.z.literal("host"), present: import_zod8.z.boolean() }),
|
|
504
|
+
state: roomStateFrameSchema,
|
|
505
|
+
drop: hostToRoomFrameSchemas.drop,
|
|
506
|
+
// The refusal comes first: a result may be absent, so the other branch
|
|
507
|
+
// would accept a refusal and strip what it says.
|
|
508
|
+
response: import_zod8.z.union([
|
|
509
|
+
import_zod8.z.object({
|
|
510
|
+
type: import_zod8.z.literal("response"),
|
|
511
|
+
id: requestIdSchema,
|
|
512
|
+
/** The room answered itself because no host could. */
|
|
513
|
+
refused: import_zod8.z.literal("host-away")
|
|
514
|
+
}),
|
|
515
|
+
import_zod8.z.object({
|
|
516
|
+
type: import_zod8.z.literal("response"),
|
|
517
|
+
id: requestIdSchema,
|
|
518
|
+
result: import_zod8.z.unknown().optional()
|
|
519
|
+
})
|
|
520
|
+
]),
|
|
521
|
+
signal: import_zod8.z.object({
|
|
522
|
+
type: import_zod8.z.literal("signal"),
|
|
523
|
+
kind: import_zod8.z.string(),
|
|
524
|
+
payload: import_zod8.z.unknown().optional()
|
|
525
|
+
})
|
|
526
|
+
};
|
|
527
|
+
var nestsWithin = (value, depth) => {
|
|
528
|
+
if (typeof value !== "object" || value === null) return true;
|
|
529
|
+
if (depth === 0) return false;
|
|
530
|
+
for (const child of Object.values(value))
|
|
531
|
+
if (!nestsWithin(child, depth - 1)) return false;
|
|
532
|
+
return true;
|
|
533
|
+
};
|
|
534
|
+
var TOO_DEEP = /* @__PURE__ */ Symbol("too deep");
|
|
535
|
+
var parseJson = (text) => {
|
|
536
|
+
let value;
|
|
537
|
+
try {
|
|
538
|
+
value = JSON.parse(text);
|
|
539
|
+
} catch {
|
|
540
|
+
return void 0;
|
|
541
|
+
}
|
|
542
|
+
return nestsWithin(value, MAXIMUM_FRAME_DEPTH) ? value : TOO_DEEP;
|
|
543
|
+
};
|
|
544
|
+
var readType = (value) => isPlainObject(value) && typeof value.type === "string" ? value.type : null;
|
|
545
|
+
var createFrameParser = (schemas) => (text) => {
|
|
546
|
+
const value = parseJson(text);
|
|
547
|
+
if (value === TOO_DEEP) return { status: "too-deep" };
|
|
548
|
+
const type = readType(value);
|
|
549
|
+
if (type === null) return { status: "invalid" };
|
|
550
|
+
if (!Object.hasOwn(schemas, type)) return { status: "unknown" };
|
|
551
|
+
const parsed = schemas[type].safeParse(value);
|
|
552
|
+
return parsed.success ? { status: "frame", frame: parsed.data } : { status: "invalid" };
|
|
553
|
+
};
|
|
554
|
+
var parseHostToRoomFrame = createFrameParser(hostToRoomFrameSchemas);
|
|
555
|
+
var parsePhoneToRoomFrame = createFrameParser(phoneToRoomFrameSchemas);
|
|
556
|
+
var parseRoomToHostFrame = createFrameParser(roomToHostFrameSchemas);
|
|
557
|
+
var parseRoomToPhoneFrame = createFrameParser(roomToPhoneFrameSchemas);
|
|
558
|
+
var createHelloParser = (schema) => (text) => {
|
|
559
|
+
const parsed = schema.safeParse(parseJson(text));
|
|
560
|
+
return parsed.success ? parsed.data : null;
|
|
561
|
+
};
|
|
562
|
+
var parseHostHello = createHelloParser(hostHelloSchema);
|
|
563
|
+
var parsePhoneHello = createHelloParser(phoneHelloSchema);
|
|
564
|
+
|
|
565
|
+
// src/protocol/room/sdk-channels.ts
|
|
566
|
+
var import_zod9 = require("zod");
|
|
567
|
+
var runtimeStateSchema = import_zod9.z.enum(["paused", "playing"]);
|
|
568
|
+
var controllerOrientationSchema = import_zod9.z.enum(["portrait", "landscape"]);
|
|
569
|
+
var presentationDocumentSchema = import_zod9.z.object({
|
|
570
|
+
runtimeState: runtimeStateSchema,
|
|
571
|
+
orientation: controllerOrientationSchema
|
|
374
572
|
});
|
|
375
|
-
var
|
|
376
|
-
|
|
573
|
+
var presentationRequestSchema = import_zod9.z.enum(["pause", "resume"]);
|
|
574
|
+
var hapticSignalPayloadSchema = import_zod9.z.object({
|
|
575
|
+
pattern: import_zod9.z.enum(["light", "medium", "heavy", "success", "failure", "custom"]),
|
|
576
|
+
sequence: import_zod9.z.union([import_zod9.z.number().nonnegative(), import_zod9.z.array(import_zod9.z.number().nonnegative())]).optional()
|
|
377
577
|
});
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
|
|
578
|
+
var toastSignalPayloadSchema = import_zod9.z.object({
|
|
579
|
+
message: import_zod9.z.string(),
|
|
580
|
+
color: import_zod9.z.string().optional(),
|
|
581
|
+
duration: import_zod9.z.number().nonnegative().optional()
|
|
582
|
+
});
|
|
583
|
+
var soundSignalPayloadSchema = import_zod9.z.object({
|
|
584
|
+
soundId: import_zod9.z.string().min(1),
|
|
585
|
+
volume: import_zod9.z.number().min(0).max(1).optional(),
|
|
586
|
+
loop: import_zod9.z.boolean().optional()
|
|
381
587
|
});
|
|
382
588
|
|
|
383
|
-
// src/
|
|
384
|
-
var
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
589
|
+
// src/runtime/contracts/runtime-identity.ts
|
|
590
|
+
var import_zod10 = require("zod");
|
|
591
|
+
var hostRuntimeIdentitySchema = import_zod10.z.object({
|
|
592
|
+
documentId: import_zod10.z.string().min(1).max(128),
|
|
593
|
+
roomId: roomCodeSchema,
|
|
594
|
+
contractId: import_zod10.z.string().min(1),
|
|
595
|
+
runtimeId: import_zod10.z.string().min(1)
|
|
596
|
+
});
|
|
597
|
+
var hostObservationIdentitySchema = hostRuntimeIdentitySchema.extend({
|
|
598
|
+
surfaceId: import_zod10.z.string().min(1).nullable(),
|
|
599
|
+
participantId: import_zod10.z.string().min(1).nullable().default(null)
|
|
600
|
+
});
|
|
601
|
+
var identityKeys = hostObservationIdentitySchema.keyof().options;
|
|
389
602
|
|
|
390
|
-
// src/protocol/
|
|
391
|
-
var
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
603
|
+
// src/protocol/leased-control.ts
|
|
604
|
+
var jsonValueSchema = import_zod11.z.unknown().refine(
|
|
605
|
+
(input) => {
|
|
606
|
+
const pending = [
|
|
607
|
+
{ value: input, depth: 0 }
|
|
608
|
+
];
|
|
609
|
+
for (const current of pending) {
|
|
610
|
+
if (current.depth > 32) return false;
|
|
611
|
+
if (current.value && typeof current.value === "object") {
|
|
612
|
+
for (const value of Object.values(current.value)) {
|
|
613
|
+
if (pending.length >= 4096) return false;
|
|
614
|
+
pending.push({ value, depth: current.depth + 1 });
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return true;
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
error: "Participant JSON exceeds its depth or node budget.",
|
|
622
|
+
abort: true
|
|
623
|
+
}
|
|
624
|
+
).pipe(import_zod11.z.json());
|
|
625
|
+
var PARTICIPANT_INPUT_SCHEMA_BYTES = 32e3;
|
|
626
|
+
var participantInputSchemaDescriptionSchema = import_zod11.z.discriminatedUnion(
|
|
627
|
+
"status",
|
|
628
|
+
[
|
|
629
|
+
import_zod11.z.object({
|
|
630
|
+
status: import_zod11.z.literal("available"),
|
|
631
|
+
schema: import_zod11.z.record(import_zod11.z.string(), jsonValueSchema).refine(
|
|
632
|
+
(schema) => new TextEncoder().encode(JSON.stringify(schema)).byteLength <= PARTICIPANT_INPUT_SCHEMA_BYTES,
|
|
633
|
+
"Input JSON Schema exceeds its byte budget."
|
|
634
|
+
)
|
|
635
|
+
}).strict(),
|
|
636
|
+
import_zod11.z.object({
|
|
637
|
+
status: import_zod11.z.literal("unavailable"),
|
|
638
|
+
reason: import_zod11.z.enum(["not-configured", "not-representable"])
|
|
639
|
+
}).strict()
|
|
640
|
+
]
|
|
641
|
+
);
|
|
642
|
+
var leaseSequenceSchema = import_zod11.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
643
|
+
var deadlineMs = import_zod11.z.number().nonnegative().max(Number.MAX_SAFE_INTEGER).describe(
|
|
644
|
+
"Admission deadline in the observed host's monotonic clock. Derive it from observation.clock.startedAtMs; never use the caller's clock."
|
|
645
|
+
);
|
|
646
|
+
var participantInputOperationSchema = import_zod11.z.object({
|
|
647
|
+
kind: import_zod11.z.literal("input"),
|
|
648
|
+
deadlineMs,
|
|
649
|
+
input: import_zod11.z.record(import_zod11.z.string(), jsonValueSchema),
|
|
650
|
+
ttlMs: import_zod11.z.number().int().min(50).max(2e3)
|
|
403
651
|
}).strict();
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
reportId: import_zod6.z.string().uuid(),
|
|
411
|
-
roomId: roomCodeSchema,
|
|
412
|
-
role: import_zod6.z.enum(["host", "controller"]),
|
|
413
|
-
code: import_zod6.z.literal("AJ_RUNTIME_RENDER_CRASH"),
|
|
414
|
-
errorName: import_zod6.z.string().trim().min(1).max(80).regex(/^[A-Za-z][A-Za-z0-9._-]*$/u),
|
|
415
|
-
digest: import_zod6.z.string().regex(/^[a-f0-9]{8}$/u),
|
|
416
|
-
occurredAt: import_zod6.z.string().datetime()
|
|
652
|
+
var participantReleaseOperationSchema = import_zod11.z.object({ kind: import_zod11.z.literal("release") }).strict();
|
|
653
|
+
var participantActionOperationSchema = import_zod11.z.object({
|
|
654
|
+
kind: import_zod11.z.literal("action"),
|
|
655
|
+
deadlineMs,
|
|
656
|
+
actionId: import_zod11.z.string().min(1).max(128),
|
|
657
|
+
input: jsonValueSchema.optional()
|
|
417
658
|
}).strict();
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
var
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
storeDomain: import_zod7.z.string().trim().min(1).max(128)
|
|
659
|
+
var operationSchema = import_zod11.z.discriminatedUnion("kind", [
|
|
660
|
+
participantInputOperationSchema,
|
|
661
|
+
participantReleaseOperationSchema,
|
|
662
|
+
participantActionOperationSchema
|
|
663
|
+
]);
|
|
664
|
+
var leasedControlRequestSchema = import_zod11.z.object({
|
|
665
|
+
lease: import_zod11.z.object({ id: import_zod11.z.uuid(), sequence: leaseSequenceSchema }).strict(),
|
|
666
|
+
expected: hostObservationIdentitySchema.strict(),
|
|
667
|
+
operation: operationSchema
|
|
428
668
|
}).strict();
|
|
429
|
-
var
|
|
669
|
+
var controllerLeasedControlSchema = leasedControlRequestSchema.extend({
|
|
430
670
|
roomId: roomCodeSchema,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
var
|
|
671
|
+
controllerId: import_zod11.z.string().min(1).max(128)
|
|
672
|
+
}).strict().refine(
|
|
673
|
+
(value) => value.roomId === value.expected.roomId,
|
|
674
|
+
"Participant control must target the observed room."
|
|
675
|
+
);
|
|
676
|
+
var controllerLeasedControlAckSchema = import_zod11.z.discriminatedUnion("status", [
|
|
677
|
+
import_zod11.z.object({
|
|
678
|
+
status: import_zod11.z.literal("applied"),
|
|
679
|
+
leaseId: import_zod11.z.uuid(),
|
|
680
|
+
sequence: leaseSequenceSchema,
|
|
681
|
+
replayed: import_zod11.z.boolean(),
|
|
682
|
+
operation: import_zod11.z.discriminatedUnion("kind", [
|
|
683
|
+
import_zod11.z.object({ kind: import_zod11.z.literal("input") }).strict(),
|
|
684
|
+
import_zod11.z.object({ kind: import_zod11.z.literal("release") }).strict(),
|
|
685
|
+
import_zod11.z.object({
|
|
686
|
+
kind: import_zod11.z.literal("action"),
|
|
687
|
+
result: airJamActionInvocationResultSchema
|
|
688
|
+
}).strict()
|
|
689
|
+
])
|
|
690
|
+
}).strict(),
|
|
691
|
+
import_zod11.z.object({
|
|
692
|
+
status: import_zod11.z.literal("rejected"),
|
|
693
|
+
reason: import_zod11.z.enum([
|
|
694
|
+
"invalid_request",
|
|
695
|
+
"rate_limited",
|
|
696
|
+
"invalid_input",
|
|
697
|
+
"invalid_action",
|
|
698
|
+
"invalid_action_lane",
|
|
699
|
+
"room_not_found",
|
|
700
|
+
"unauthorized",
|
|
701
|
+
"active_host_missing",
|
|
702
|
+
"busy",
|
|
703
|
+
"stale_identity",
|
|
704
|
+
"stale_decision",
|
|
705
|
+
"invalid_deadline",
|
|
706
|
+
"lease_conflict",
|
|
707
|
+
"stale_sequence",
|
|
708
|
+
"sequence_conflict",
|
|
709
|
+
"unsupported"
|
|
710
|
+
])
|
|
711
|
+
}).strict(),
|
|
712
|
+
import_zod11.z.object({
|
|
713
|
+
status: import_zod11.z.literal("unconfirmed"),
|
|
714
|
+
reason: import_zod11.z.enum([
|
|
715
|
+
"host_ack_unavailable",
|
|
716
|
+
"transport_ack_unavailable",
|
|
717
|
+
"runtime_replaced",
|
|
718
|
+
"invalid_acknowledgement",
|
|
719
|
+
"runtime_unavailable"
|
|
720
|
+
])
|
|
721
|
+
}).strict()
|
|
722
|
+
]);
|
|
723
|
+
|
|
724
|
+
// src/protocol/runtime-reporting.ts
|
|
725
|
+
var import_zod12 = require("zod");
|
|
726
|
+
var AIRJAM_RUNTIME_ERROR_REPORT_CONTRACT_VERSION = 2;
|
|
727
|
+
var runtimeErrorReportSchema = import_zod12.z.object({
|
|
728
|
+
contractVersion: import_zod12.z.literal(AIRJAM_RUNTIME_ERROR_REPORT_CONTRACT_VERSION),
|
|
729
|
+
reportId: import_zod12.z.uuid(),
|
|
437
730
|
roomId: roomCodeSchema,
|
|
438
|
-
|
|
439
|
-
|
|
731
|
+
instance: import_zod12.z.string().min(1).max(64),
|
|
732
|
+
role: import_zod12.z.enum(["host", "controller"]),
|
|
733
|
+
seat: seatIdSchema.optional(),
|
|
734
|
+
code: import_zod12.z.literal("AJ_RUNTIME_RENDER_CRASH"),
|
|
735
|
+
errorName: import_zod12.z.string().trim().min(1).max(80).regex(/^[A-Za-z][A-Za-z0-9._-]*$/u),
|
|
736
|
+
digest: import_zod12.z.string().regex(/^[a-f0-9]{8}$/u),
|
|
737
|
+
occurredAt: import_zod12.z.iso.datetime()
|
|
440
738
|
}).strict();
|
|
441
739
|
|
|
740
|
+
// src/protocol/signed-envelope.ts
|
|
741
|
+
var encoder = new TextEncoder();
|
|
742
|
+
var decoder = new TextDecoder();
|
|
743
|
+
|
|
442
744
|
// src/protocol/url-policy.ts
|
|
443
|
-
var
|
|
745
|
+
var import_zod13 = require("zod");
|
|
444
746
|
var ALLOWED_RUNTIME_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
445
747
|
var parseRuntimeUrl = (value) => {
|
|
446
748
|
try {
|
|
@@ -464,7 +766,7 @@ var getRuntimeUrlOrigin = (value) => {
|
|
|
464
766
|
const parsed = parseRuntimeUrl(value);
|
|
465
767
|
return parsed ? parsed.origin : null;
|
|
466
768
|
};
|
|
467
|
-
var runtimeUrlSchema =
|
|
769
|
+
var runtimeUrlSchema = import_zod13.z.string().trim().min(1).refine((value) => parseRuntimeUrl(value) !== null, {
|
|
468
770
|
message: "URL must be a valid http(s) URL without embedded credentials."
|
|
469
771
|
});
|
|
470
772
|
var appendRuntimeQueryParams = (baseUrl, params) => {
|
|
@@ -502,11 +804,669 @@ var isLocalDevControlSurfaceRuntimeMode = (runtimeMode) => LOCAL_DEV_CONTROL_SUR
|
|
|
502
804
|
assertString(runtimeMode, "runtimeMode")
|
|
503
805
|
);
|
|
504
806
|
|
|
505
|
-
// src/
|
|
506
|
-
var
|
|
807
|
+
// src/core/hosted-rooms.ts
|
|
808
|
+
var AIR_JAM_HOSTED_ENVIRONMENTS = [
|
|
809
|
+
{
|
|
810
|
+
name: "production",
|
|
811
|
+
roomsOrigin: "https://rooms.airjam.io",
|
|
812
|
+
platformOrigin: "https://airjam.io"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
name: "beta",
|
|
816
|
+
roomsOrigin: "https://rooms.beta.airjam.io",
|
|
817
|
+
platformOrigin: "https://beta.airjam.io"
|
|
818
|
+
}
|
|
819
|
+
];
|
|
820
|
+
var AIR_JAM_HOSTED_ROOMS_ORIGIN = AIR_JAM_HOSTED_ENVIRONMENTS[0].roomsOrigin;
|
|
821
|
+
|
|
822
|
+
// src/runtime/browser-replay.ts
|
|
823
|
+
var import_zod24 = require("zod");
|
|
824
|
+
|
|
825
|
+
// src/core/input-log.ts
|
|
826
|
+
var import_zod15 = require("zod");
|
|
827
|
+
|
|
828
|
+
// src/core/settings.ts
|
|
829
|
+
var import_zod14 = require("zod");
|
|
830
|
+
var common = {
|
|
831
|
+
live: import_zod14.z.boolean().default(false),
|
|
832
|
+
description: import_zod14.z.string().min(1).optional()
|
|
833
|
+
};
|
|
834
|
+
var numberSettingSchema = import_zod14.z.object({
|
|
835
|
+
kind: import_zod14.z.literal("number"),
|
|
836
|
+
default: import_zod14.z.number().finite(),
|
|
837
|
+
min: import_zod14.z.number().finite(),
|
|
838
|
+
max: import_zod14.z.number().finite(),
|
|
839
|
+
step: import_zod14.z.number().finite().positive().optional(),
|
|
840
|
+
...common
|
|
841
|
+
}).strict();
|
|
842
|
+
var booleanSettingSchema = import_zod14.z.object({
|
|
843
|
+
kind: import_zod14.z.literal("boolean"),
|
|
844
|
+
default: import_zod14.z.boolean(),
|
|
845
|
+
...common
|
|
846
|
+
}).strict();
|
|
847
|
+
var choiceSettingSchema = import_zod14.z.object({
|
|
848
|
+
kind: import_zod14.z.literal("choice"),
|
|
849
|
+
options: import_zod14.z.array(import_zod14.z.string().min(1)).nonempty(),
|
|
850
|
+
default: import_zod14.z.string(),
|
|
851
|
+
...common
|
|
852
|
+
}).strict();
|
|
853
|
+
var airJamSettingSchema = import_zod14.z.discriminatedUnion("kind", [
|
|
854
|
+
numberSettingSchema,
|
|
855
|
+
booleanSettingSchema,
|
|
856
|
+
choiceSettingSchema
|
|
857
|
+
]);
|
|
858
|
+
var airJamSettingsValuesSchema = import_zod14.z.record(
|
|
859
|
+
import_zod14.z.string(),
|
|
860
|
+
import_zod14.z.union([import_zod14.z.number().finite(), import_zod14.z.boolean(), import_zod14.z.string()])
|
|
861
|
+
);
|
|
862
|
+
|
|
863
|
+
// src/core/input-log.ts
|
|
864
|
+
var AIR_JAM_INPUT_LOG_EVENTS = [
|
|
865
|
+
"seat",
|
|
866
|
+
"left",
|
|
867
|
+
"input",
|
|
868
|
+
"runtime",
|
|
869
|
+
"action",
|
|
870
|
+
"settings"
|
|
871
|
+
];
|
|
872
|
+
var inputLogEntrySchema = import_zod15.z.object({
|
|
873
|
+
/** The step the event reached the game before. */
|
|
874
|
+
tick: import_zod15.z.number().int().positive(),
|
|
875
|
+
event: import_zod15.z.enum(AIR_JAM_INPUT_LOG_EVENTS),
|
|
876
|
+
payload: import_zod15.z.record(import_zod15.z.string(), import_zod15.z.unknown())
|
|
877
|
+
}).strict();
|
|
878
|
+
var airJamInputLogSchema = import_zod15.z.object({
|
|
879
|
+
version: import_zod15.z.literal(3),
|
|
880
|
+
settings: airJamSettingsValuesSchema,
|
|
881
|
+
seed: import_zod15.z.number().int().min(0).max(4294967295),
|
|
882
|
+
stepMs: import_zod15.z.number().positive(),
|
|
883
|
+
/** Steps the recorded host took. */
|
|
884
|
+
ticks: import_zod15.z.number().int().nonnegative(),
|
|
885
|
+
/** The store domain of stores that declare none, so actions find their store again. */
|
|
886
|
+
storeDomain: import_zod15.z.string().min(1),
|
|
887
|
+
entries: import_zod15.z.array(inputLogEntrySchema)
|
|
888
|
+
}).strict();
|
|
889
|
+
var AIR_JAM_INPUT_LOG_MAX_GAME_MS = 30 * 60 * 1e3;
|
|
890
|
+
var AIR_JAM_INPUT_LOG_MAX_ENTRY_BYTES = 16 * 1024 * 1024;
|
|
891
|
+
|
|
892
|
+
// src/core/replay-input-log.ts
|
|
893
|
+
var import_zod23 = require("zod");
|
|
894
|
+
|
|
895
|
+
// src/runtime/contracts/control.ts
|
|
896
|
+
var import_nanoid2 = require("nanoid");
|
|
897
|
+
var import_zod22 = require("zod");
|
|
898
|
+
|
|
899
|
+
// src/agent/agent-evaluator.ts
|
|
900
|
+
var import_zod16 = require("zod");
|
|
901
|
+
|
|
902
|
+
// src/utils/is-rpc-serializable.ts
|
|
903
|
+
var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
904
|
+
if (value === null || value === void 0) {
|
|
905
|
+
return true;
|
|
906
|
+
}
|
|
907
|
+
const valueType = typeof value;
|
|
908
|
+
if (valueType === "string" || valueType === "boolean") {
|
|
909
|
+
return true;
|
|
910
|
+
}
|
|
911
|
+
if (valueType === "number") {
|
|
912
|
+
return Number.isFinite(value);
|
|
913
|
+
}
|
|
914
|
+
if (valueType === "function" || valueType === "symbol" || valueType === "bigint") {
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
if (valueType !== "object") {
|
|
918
|
+
return false;
|
|
919
|
+
}
|
|
920
|
+
const objectValue = value;
|
|
921
|
+
if (seen.has(objectValue)) {
|
|
922
|
+
return false;
|
|
923
|
+
}
|
|
924
|
+
seen.add(objectValue);
|
|
925
|
+
try {
|
|
926
|
+
if (objectValue instanceof Date) return true;
|
|
927
|
+
if (Array.isArray(objectValue))
|
|
928
|
+
return objectValue.every((entry) => isRpcSerializable(entry, seen));
|
|
929
|
+
const prototype = Object.getPrototypeOf(objectValue);
|
|
930
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
931
|
+
return Object.values(objectValue).every(
|
|
932
|
+
(entry) => isRpcSerializable(entry, seen)
|
|
933
|
+
);
|
|
934
|
+
} finally {
|
|
935
|
+
seen.delete(objectValue);
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
// src/agent/agent-evaluator.ts
|
|
940
|
+
var agentActionDescriptorSchema = import_zod16.z.object({
|
|
941
|
+
actionId: import_zod16.z.string().min(1),
|
|
942
|
+
target: import_zod16.z.object({
|
|
943
|
+
kind: import_zod16.z.enum(["participant", "host"]),
|
|
944
|
+
actionName: import_zod16.z.string().min(1),
|
|
945
|
+
storeDomain: import_zod16.z.string().min(1)
|
|
946
|
+
}),
|
|
947
|
+
description: import_zod16.z.string().nullable(),
|
|
948
|
+
availability: import_zod16.z.string().nullable(),
|
|
949
|
+
payload: import_zod16.z.object({
|
|
950
|
+
kind: import_zod16.z.enum(["none", "boolean", "number", "string", "enum", "json"]),
|
|
951
|
+
description: import_zod16.z.string().nullable(),
|
|
952
|
+
allowedValues: import_zod16.z.array(import_zod16.z.string()).optional()
|
|
953
|
+
}),
|
|
954
|
+
resultDescription: import_zod16.z.string().nullable()
|
|
955
|
+
});
|
|
956
|
+
var agentContractDescriptionSchema = import_zod16.z.object({
|
|
957
|
+
snapshotStoreDomains: import_zod16.z.array(import_zod16.z.string().min(1)),
|
|
958
|
+
snapshotDescription: import_zod16.z.string().nullable(),
|
|
959
|
+
actions: import_zod16.z.array(agentActionDescriptorSchema)
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
// src/runtime/host-observation.ts
|
|
963
|
+
var import_nanoid = require("nanoid");
|
|
964
|
+
|
|
965
|
+
// src/runtime/contracts/observation.ts
|
|
966
|
+
var import_zod17 = require("zod");
|
|
967
|
+
var HOST_OBSERVATION_IMAGE_BYTES = 64e4;
|
|
968
|
+
var jsonObject = import_zod17.z.record(import_zod17.z.string(), import_zod17.z.unknown()).refine(
|
|
969
|
+
(value) => isRpcSerializable(value) && new TextEncoder().encode(JSON.stringify(value)).byteLength <= 128e3,
|
|
970
|
+
{
|
|
971
|
+
message: "Observations require serializable JSON within the 128 KB state budget."
|
|
972
|
+
}
|
|
973
|
+
);
|
|
974
|
+
var hostObservationRequestSchema = import_zod17.z.object({
|
|
975
|
+
roomId: roomCodeSchema,
|
|
976
|
+
controllerId: import_zod17.z.string().min(1).max(128).nullable(),
|
|
977
|
+
scope: import_zod17.z.enum(["player", "diagnostic"]),
|
|
978
|
+
includeImage: import_zod17.z.boolean(),
|
|
979
|
+
expected: hostObservationIdentitySchema.optional()
|
|
980
|
+
}).strict();
|
|
981
|
+
var hostObservationImageSchema = import_zod17.z.object({
|
|
982
|
+
mimeType: import_zod17.z.enum(["image/jpeg", "image/png", "image/webp"]),
|
|
983
|
+
data: import_zod17.z.string().min(4).max(Math.ceil(HOST_OBSERVATION_IMAGE_BYTES / 3) * 4).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(
|
|
984
|
+
(value) => value.length % 4 === 0 && value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0) <= HOST_OBSERVATION_IMAGE_BYTES,
|
|
985
|
+
"Observation image exceeds its byte budget or is invalid base64."
|
|
986
|
+
),
|
|
987
|
+
width: import_zod17.z.number().int().positive().max(4096),
|
|
988
|
+
height: import_zod17.z.number().int().positive().max(4096),
|
|
989
|
+
coverage: import_zod17.z.enum(["render-surface", "host-document", "controller-view"])
|
|
990
|
+
}).strict();
|
|
991
|
+
var storeRevision = import_zod17.z.object({
|
|
992
|
+
storeDomain: import_zod17.z.string().min(1),
|
|
993
|
+
revision: import_zod17.z.number().int().nonnegative()
|
|
994
|
+
});
|
|
995
|
+
var hostRuntimeFaultSchema = import_zod17.z.object({
|
|
996
|
+
name: import_zod17.z.string().max(128),
|
|
997
|
+
message: import_zod17.z.string().max(2048),
|
|
998
|
+
source: import_zod17.z.object({
|
|
999
|
+
file: import_zod17.z.string().max(2048),
|
|
1000
|
+
line: import_zod17.z.number().int().positive(),
|
|
1001
|
+
column: import_zod17.z.number().int().positive()
|
|
1002
|
+
}).strict().nullable(),
|
|
1003
|
+
stack: import_zod17.z.string().max(8192)
|
|
1004
|
+
}).strict();
|
|
1005
|
+
var hostObservationPresentationSchema = import_zod17.z.object({
|
|
1006
|
+
runtimeState: runtimeStateSchema,
|
|
1007
|
+
connectionStatus: connectionStatusSchema,
|
|
1008
|
+
fault: hostRuntimeFaultSchema.nullable().optional()
|
|
1009
|
+
}).strict();
|
|
1010
|
+
var hostObservationClockSchema = import_zod17.z.object({
|
|
1011
|
+
startedAtMs: import_zod17.z.number().nonnegative(),
|
|
1012
|
+
finishedAtMs: import_zod17.z.number().nonnegative()
|
|
1013
|
+
}).strict().refine(
|
|
1014
|
+
(value) => value.finishedAtMs >= value.startedAtMs,
|
|
1015
|
+
"The host clock must advance monotonically."
|
|
1016
|
+
);
|
|
1017
|
+
var hostObservationSchema = import_zod17.z.object({
|
|
1018
|
+
version: import_zod17.z.literal(1),
|
|
1019
|
+
id: import_zod17.z.string().min(1),
|
|
1020
|
+
identity: hostObservationIdentitySchema,
|
|
1021
|
+
sequence: import_zod17.z.number().int().positive(),
|
|
1022
|
+
scope: import_zod17.z.enum(["player", "diagnostic"]),
|
|
1023
|
+
controllerId: import_zod17.z.string().nullable(),
|
|
1024
|
+
host: import_zod17.z.object({
|
|
1025
|
+
before: hostObservationPresentationSchema.nullable(),
|
|
1026
|
+
after: hostObservationPresentationSchema.nullable()
|
|
1027
|
+
}).optional(),
|
|
1028
|
+
actions: import_zod17.z.array(agentActionDescriptorSchema).optional(),
|
|
1029
|
+
capabilities: import_zod17.z.object({
|
|
1030
|
+
participantControl: import_zod17.z.object({
|
|
1031
|
+
input: import_zod17.z.literal(1).optional(),
|
|
1032
|
+
inputSchema: participantInputSchemaDescriptionSchema.optional(),
|
|
1033
|
+
actions: import_zod17.z.literal(1).optional()
|
|
1034
|
+
}).optional()
|
|
1035
|
+
}).optional(),
|
|
1036
|
+
capturedAt: import_zod17.z.iso.datetime(),
|
|
1037
|
+
clock: hostObservationClockSchema.optional(),
|
|
1038
|
+
/** The page's slowest fixed-step simulation against real time, since it started. */
|
|
1039
|
+
pace: import_zod17.z.object({
|
|
1040
|
+
frames: import_zod17.z.number().int().nonnegative(),
|
|
1041
|
+
wallMs: import_zod17.z.number().nonnegative(),
|
|
1042
|
+
simulatedMs: import_zod17.z.number().nonnegative()
|
|
1043
|
+
}).strict().optional(),
|
|
1044
|
+
durationMs: import_zod17.z.number().nonnegative(),
|
|
1045
|
+
snapshot: jsonObject,
|
|
1046
|
+
runtime: jsonObject.nullable(),
|
|
1047
|
+
ticks: import_zod17.z.object({
|
|
1048
|
+
before: import_zod17.z.number().int().nonnegative().nullable(),
|
|
1049
|
+
after: import_zod17.z.number().int().nonnegative().nullable()
|
|
1050
|
+
}),
|
|
1051
|
+
stores: import_zod17.z.object({
|
|
1052
|
+
before: import_zod17.z.array(storeRevision),
|
|
1053
|
+
after: import_zod17.z.array(storeRevision)
|
|
1054
|
+
}),
|
|
1055
|
+
visual: import_zod17.z.discriminatedUnion("status", [
|
|
1056
|
+
import_zod17.z.object({
|
|
1057
|
+
status: import_zod17.z.literal("captured"),
|
|
1058
|
+
image: hostObservationImageSchema
|
|
1059
|
+
}),
|
|
1060
|
+
import_zod17.z.object({
|
|
1061
|
+
status: import_zod17.z.literal("unavailable"),
|
|
1062
|
+
reason: import_zod17.z.enum([
|
|
1063
|
+
"not-requested",
|
|
1064
|
+
"unsupported",
|
|
1065
|
+
"surface-unavailable",
|
|
1066
|
+
"timeout"
|
|
1067
|
+
]),
|
|
1068
|
+
detail: import_zod17.z.string().max(1024).optional()
|
|
1069
|
+
})
|
|
1070
|
+
])
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
// src/runtime/contracts/agent-control.ts
|
|
1074
|
+
var import_zod21 = require("zod");
|
|
1075
|
+
|
|
1076
|
+
// src/runtime/contracts/clip.ts
|
|
1077
|
+
var import_zod18 = require("zod");
|
|
1078
|
+
var CLIP_MIN_FRAME_INTERVAL_MS = 33;
|
|
1079
|
+
var clipFrameIntervalSchema = import_zod18.z.number().int().min(CLIP_MIN_FRAME_INTERVAL_MS);
|
|
1080
|
+
var CLIP_MAX_DURATION_MS = 15e3;
|
|
1081
|
+
var CLIP_MAX_FRAMES = Math.ceil(
|
|
1082
|
+
CLIP_MAX_DURATION_MS / CLIP_MIN_FRAME_INTERVAL_MS
|
|
1083
|
+
);
|
|
1084
|
+
var CLIP_MAX_BYTES = 4 * 1024 * 1024;
|
|
1085
|
+
var CLIP_FRAME_MAX_BYTES = 160 * 1024;
|
|
1086
|
+
var CLIP_PAGE_BASE64_CHARS = 768 * 1024;
|
|
1087
|
+
var CLIP_RECORDING_LIFETIME_MS = 6e5;
|
|
1088
|
+
var CLIP_VIDEO_MAX_BYTES = 32 * 1024 * 1024;
|
|
1089
|
+
var clipNotCapturedReasonSchema = import_zod18.z.enum([
|
|
1090
|
+
"busy",
|
|
1091
|
+
"unsupported",
|
|
1092
|
+
"surface-unavailable",
|
|
1093
|
+
"capture-failed",
|
|
1094
|
+
"runtime-replaced",
|
|
1095
|
+
"host-unavailable",
|
|
1096
|
+
"headless"
|
|
1097
|
+
]);
|
|
1098
|
+
var clipImageBytes = (data) => data.length / 4 * 3 - (data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0);
|
|
1099
|
+
var clipFrameSchema = import_zod18.z.object({
|
|
1100
|
+
index: import_zod18.z.number().int().nonnegative(),
|
|
1101
|
+
atMs: import_zod18.z.number().nonnegative().max(CLIP_RECORDING_LIFETIME_MS),
|
|
1102
|
+
width: import_zod18.z.number().int().positive().max(1280),
|
|
1103
|
+
height: import_zod18.z.number().int().positive().max(1280),
|
|
1104
|
+
mimeType: import_zod18.z.literal("image/jpeg"),
|
|
1105
|
+
data: import_zod18.z.string().min(4).max(Math.ceil(CLIP_FRAME_MAX_BYTES / 3) * 4).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(
|
|
1106
|
+
(data) => data.length % 4 === 0 && clipImageBytes(data) <= CLIP_FRAME_MAX_BYTES,
|
|
1107
|
+
"Clip frame exceeds its byte budget or is invalid base64."
|
|
1108
|
+
)
|
|
1109
|
+
}).strict();
|
|
1110
|
+
var clipMetadata = {
|
|
1111
|
+
clipId: import_zod18.z.string().min(1).max(128),
|
|
1112
|
+
identity: hostObservationIdentitySchema,
|
|
1113
|
+
startedAt: import_zod18.z.iso.datetime(),
|
|
1114
|
+
frameIntervalMs: clipFrameIntervalSchema,
|
|
1115
|
+
// Offsets and duration refer to the original recording, even after old frames drop.
|
|
1116
|
+
durationMs: import_zod18.z.number().nonnegative().max(CLIP_RECORDING_LIFETIME_MS),
|
|
1117
|
+
droppedFrames: import_zod18.z.number().int().nonnegative(),
|
|
1118
|
+
skippedFrames: import_zod18.z.number().int().nonnegative()
|
|
1119
|
+
};
|
|
1120
|
+
var clipArtifactSchema = import_zod18.z.object({
|
|
1121
|
+
version: import_zod18.z.literal(1),
|
|
1122
|
+
...clipMetadata,
|
|
1123
|
+
frames: import_zod18.z.array(clipFrameSchema).min(1).max(CLIP_MAX_FRAMES)
|
|
1124
|
+
}).strict().superRefine((clip, ctx) => {
|
|
1125
|
+
const frames = clip.frames;
|
|
1126
|
+
if (frames.length > Math.ceil(CLIP_MAX_DURATION_MS / clip.frameIntervalMs))
|
|
1127
|
+
ctx.addIssue({
|
|
1128
|
+
code: "custom",
|
|
1129
|
+
message: "Clip exceeds its cadence frame budget."
|
|
1130
|
+
});
|
|
1131
|
+
if (frames.reduce((sum, frame) => sum + clipImageBytes(frame.data), 0) > CLIP_MAX_BYTES)
|
|
1132
|
+
ctx.addIssue({
|
|
1133
|
+
code: "custom",
|
|
1134
|
+
message: "Clip exceeds its image byte budget."
|
|
1135
|
+
});
|
|
1136
|
+
if (frames.some(
|
|
1137
|
+
(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)
|
|
1138
|
+
))
|
|
1139
|
+
ctx.addIssue({
|
|
1140
|
+
code: "custom",
|
|
1141
|
+
message: "Clip frames must be ordered within the kept time window."
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
1144
|
+
var clipNativeCaptureSchema = import_zod18.z.object({
|
|
1145
|
+
drawsAttempted: import_zod18.z.number().int().nonnegative(),
|
|
1146
|
+
drawsMade: import_zod18.z.number().int().nonnegative()
|
|
1147
|
+
}).strict();
|
|
1148
|
+
var clipVideoPageSchema = import_zod18.z.object({
|
|
1149
|
+
mimeType: import_zod18.z.string().min(1).max(128),
|
|
1150
|
+
width: import_zod18.z.number().int().positive().max(1280),
|
|
1151
|
+
height: import_zod18.z.number().int().positive().max(1280),
|
|
1152
|
+
chunks: import_zod18.z.array(
|
|
1153
|
+
import_zod18.z.string().min(4).max(CLIP_PAGE_BASE64_CHARS).regex(
|
|
1154
|
+
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/
|
|
1155
|
+
)
|
|
1156
|
+
).max(1),
|
|
1157
|
+
nextChunk: import_zod18.z.number().int().nonnegative().nullable()
|
|
1158
|
+
}).strict();
|
|
1159
|
+
var clipReadSchema = import_zod18.z.object({
|
|
1160
|
+
...clipMetadata,
|
|
1161
|
+
state: import_zod18.z.enum(["recording", "stopped"]),
|
|
1162
|
+
// Native encoded frames are counted after stop by the video consumer.
|
|
1163
|
+
nativeCapture: clipNativeCaptureSchema.optional(),
|
|
1164
|
+
droppedFrames: clipMetadata.droppedFrames.nullable(),
|
|
1165
|
+
skippedFrames: clipMetadata.skippedFrames.nullable(),
|
|
1166
|
+
frameCount: import_zod18.z.number().int().nonnegative().max(Math.ceil(CLIP_RECORDING_LIFETIME_MS / CLIP_MIN_FRAME_INTERVAL_MS)).nullable(),
|
|
1167
|
+
notCaptured: clipNotCapturedReasonSchema.nullable(),
|
|
1168
|
+
frames: import_zod18.z.array(clipFrameSchema).max(CLIP_MAX_FRAMES).refine(
|
|
1169
|
+
(frames) => frames.reduce((sum, frame) => sum + frame.data.length, 0) <= CLIP_PAGE_BASE64_CHARS,
|
|
1170
|
+
"Clip page exceeds its transfer budget."
|
|
1171
|
+
),
|
|
1172
|
+
nextFrame: import_zod18.z.number().int().nonnegative().nullable(),
|
|
1173
|
+
video: clipVideoPageSchema.optional()
|
|
1174
|
+
}).strict();
|
|
507
1175
|
|
|
508
|
-
// src/
|
|
509
|
-
var
|
|
1176
|
+
// src/runtime/contracts/input-log.ts
|
|
1177
|
+
var import_zod19 = require("zod");
|
|
1178
|
+
var INPUT_LOG_PAGE_BYTES = 512 * 1024;
|
|
1179
|
+
var inputLogCutSchema = import_zod19.z.object({
|
|
1180
|
+
ticks: import_zod19.z.number().int().nonnegative(),
|
|
1181
|
+
entryCount: import_zod19.z.number().int().nonnegative()
|
|
1182
|
+
}).strict();
|
|
1183
|
+
var hostInputLogPageSchema = import_zod19.z.object({
|
|
1184
|
+
identity: hostObservationIdentitySchema,
|
|
1185
|
+
observation: hostObservationSchema.optional(),
|
|
1186
|
+
header: airJamInputLogSchema.omit({ entries: true }),
|
|
1187
|
+
entryCount: import_zod19.z.number().int().nonnegative(),
|
|
1188
|
+
full: import_zod19.z.boolean(),
|
|
1189
|
+
entries: airJamInputLogSchema.shape.entries,
|
|
1190
|
+
nextEntry: import_zod19.z.number().int().nonnegative().nullable()
|
|
1191
|
+
}).strict();
|
|
1192
|
+
var inputLogNotReplayableReasonSchema = import_zod19.z.enum([
|
|
1193
|
+
"no-simulation",
|
|
1194
|
+
"loading",
|
|
1195
|
+
"runtime-replaced",
|
|
1196
|
+
"host-unavailable"
|
|
1197
|
+
]);
|
|
1198
|
+
|
|
1199
|
+
// src/runtime/contracts/timeline.ts
|
|
1200
|
+
var import_zod20 = require("zod");
|
|
1201
|
+
var facts = {
|
|
1202
|
+
id: import_zod20.z.string().min(1),
|
|
1203
|
+
tick: import_zod20.z.number().int().nonnegative(),
|
|
1204
|
+
/** Epoch milliseconds, unlike the simulation's game clock. */
|
|
1205
|
+
at: import_zod20.z.number().nonnegative()
|
|
1206
|
+
};
|
|
1207
|
+
var hostTimelineEntrySchema = import_zod20.z.discriminatedUnion("kind", [
|
|
1208
|
+
import_zod20.z.object({
|
|
1209
|
+
...facts,
|
|
1210
|
+
kind: import_zod20.z.enum(["join", "drop", "leave", "name"]),
|
|
1211
|
+
controllerId: import_zod20.z.string(),
|
|
1212
|
+
name: import_zod20.z.string().optional(),
|
|
1213
|
+
previousName: import_zod20.z.string().optional()
|
|
1214
|
+
}),
|
|
1215
|
+
import_zod20.z.object({
|
|
1216
|
+
...facts,
|
|
1217
|
+
kind: import_zod20.z.literal("state"),
|
|
1218
|
+
state: import_zod20.z.enum(["paused", "playing"])
|
|
1219
|
+
}),
|
|
1220
|
+
import_zod20.z.object({
|
|
1221
|
+
...facts,
|
|
1222
|
+
kind: import_zod20.z.literal("settings"),
|
|
1223
|
+
values: airJamSettingsValuesSchema,
|
|
1224
|
+
previousValues: airJamSettingsValuesSchema
|
|
1225
|
+
}),
|
|
1226
|
+
import_zod20.z.object({
|
|
1227
|
+
...facts,
|
|
1228
|
+
kind: import_zod20.z.literal("moment"),
|
|
1229
|
+
text: import_zod20.z.string().min(1).max(240)
|
|
1230
|
+
})
|
|
1231
|
+
]);
|
|
1232
|
+
var hostTimelinePaceSchema = import_zod20.z.object({
|
|
1233
|
+
/** End of the five-second sampling window, in epoch milliseconds. */
|
|
1234
|
+
at: import_zod20.z.number().nonnegative(),
|
|
1235
|
+
fps: import_zod20.z.number().nonnegative(),
|
|
1236
|
+
speed: import_zod20.z.number().nonnegative()
|
|
1237
|
+
});
|
|
1238
|
+
var hostTimelineSchema = import_zod20.z.discriminatedUnion("status", [
|
|
1239
|
+
import_zod20.z.object({
|
|
1240
|
+
status: import_zod20.z.literal("available"),
|
|
1241
|
+
identity: hostObservationIdentitySchema,
|
|
1242
|
+
startedAt: import_zod20.z.number().nonnegative(),
|
|
1243
|
+
stepMs: import_zod20.z.number().positive(),
|
|
1244
|
+
entries: import_zod20.z.array(hostTimelineEntrySchema),
|
|
1245
|
+
pace: import_zod20.z.array(hostTimelinePaceSchema).max(360)
|
|
1246
|
+
}),
|
|
1247
|
+
import_zod20.z.object({
|
|
1248
|
+
status: import_zod20.z.literal("unavailable"),
|
|
1249
|
+
identity: hostObservationIdentitySchema,
|
|
1250
|
+
reason: import_zod20.z.enum(["no-simulation", "simulation-loading"])
|
|
1251
|
+
})
|
|
1252
|
+
]);
|
|
1253
|
+
|
|
1254
|
+
// src/runtime/contracts/agent-control.ts
|
|
1255
|
+
var identity = import_zod21.z.object({
|
|
1256
|
+
roomId: roomCodeSchema,
|
|
1257
|
+
controllerId: import_zod21.z.string().min(1)
|
|
1258
|
+
});
|
|
1259
|
+
var actionRequest = identity.extend({
|
|
1260
|
+
contractId: import_zod21.z.string().min(1),
|
|
1261
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1262
|
+
actionId: import_zod21.z.string().min(1),
|
|
1263
|
+
payload: import_zod21.z.unknown().refine(
|
|
1264
|
+
(value) => isRpcSerializable(value),
|
|
1265
|
+
"Agent input must be serializable JSON data."
|
|
1266
|
+
).optional()
|
|
1267
|
+
});
|
|
1268
|
+
var hostAgentRequestSchema = import_zod21.z.discriminatedUnion("operation", [
|
|
1269
|
+
/** The room's instance and every seat in it, with what kind of device holds each. */
|
|
1270
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("seats"), roomId: roomCodeSchema }).strict(),
|
|
1271
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("timeline-read"), roomId: roomCodeSchema }).strict(),
|
|
1272
|
+
import_zod21.z.object({
|
|
1273
|
+
operation: import_zod21.z.literal("input-log-read"),
|
|
1274
|
+
roomId: roomCodeSchema,
|
|
1275
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1276
|
+
cut: inputLogCutSchema.nullable(),
|
|
1277
|
+
observe: hostObservationRequestSchema.pick({ controllerId: true, scope: true }).optional(),
|
|
1278
|
+
fromEntry: import_zod21.z.number().int().nonnegative()
|
|
1279
|
+
}).strict(),
|
|
1280
|
+
hostObservationRequestSchema.extend({ operation: import_zod21.z.literal("observe") }).strict(),
|
|
1281
|
+
identity.extend({
|
|
1282
|
+
operation: import_zod21.z.literal("read"),
|
|
1283
|
+
controllerId: import_zod21.z.string().min(1).nullable()
|
|
1284
|
+
}).strict(),
|
|
1285
|
+
import_zod21.z.object({
|
|
1286
|
+
operation: import_zod21.z.literal("settings-read"),
|
|
1287
|
+
roomId: roomCodeSchema,
|
|
1288
|
+
runtimeId: import_zod21.z.string().min(1)
|
|
1289
|
+
}).strict(),
|
|
1290
|
+
import_zod21.z.object({
|
|
1291
|
+
operation: import_zod21.z.literal("settings-update"),
|
|
1292
|
+
roomId: roomCodeSchema,
|
|
1293
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1294
|
+
patch: airJamSettingsValuesSchema,
|
|
1295
|
+
expectedRevision: import_zod21.z.number().int().nonnegative()
|
|
1296
|
+
}).strict(),
|
|
1297
|
+
actionRequest.extend({ operation: import_zod21.z.literal("resolve") }).strict(),
|
|
1298
|
+
actionRequest.extend({ operation: import_zod21.z.literal("invoke-host") }).strict(),
|
|
1299
|
+
import_zod21.z.object({
|
|
1300
|
+
operation: import_zod21.z.literal("clip-start"),
|
|
1301
|
+
delivery: import_zod21.z.enum(["pages", "video"]).optional(),
|
|
1302
|
+
frameIntervalMs: clipFrameIntervalSchema.optional(),
|
|
1303
|
+
roomId: roomCodeSchema,
|
|
1304
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1305
|
+
clipId: import_zod21.z.string().min(1).max(128)
|
|
1306
|
+
}).strict(),
|
|
1307
|
+
import_zod21.z.object({
|
|
1308
|
+
operation: import_zod21.z.literal("clip-read"),
|
|
1309
|
+
roomId: roomCodeSchema,
|
|
1310
|
+
clipId: import_zod21.z.string().min(1).max(128),
|
|
1311
|
+
stop: import_zod21.z.boolean(),
|
|
1312
|
+
fromChunk: import_zod21.z.number().int().nonnegative().optional(),
|
|
1313
|
+
fromFrame: import_zod21.z.number().int().nonnegative()
|
|
1314
|
+
}).strict()
|
|
1315
|
+
]);
|
|
1316
|
+
var hostAgentSnapshotSchema = agentContractDescriptionSchema.extend({
|
|
1317
|
+
contractId: import_zod21.z.string().min(1),
|
|
1318
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1319
|
+
snapshot: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()),
|
|
1320
|
+
rawStores: import_zod21.z.array(
|
|
1321
|
+
import_zod21.z.object({
|
|
1322
|
+
storeDomain: import_zod21.z.string().min(1),
|
|
1323
|
+
data: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()),
|
|
1324
|
+
revision: import_zod21.z.number().int().nonnegative(),
|
|
1325
|
+
updatedAt: import_zod21.z.string()
|
|
1326
|
+
})
|
|
1327
|
+
),
|
|
1328
|
+
storeDomainBindings: import_zod21.z.array(
|
|
1329
|
+
import_zod21.z.object({
|
|
1330
|
+
contractStoreDomain: import_zod21.z.string(),
|
|
1331
|
+
runtimeStoreDomain: import_zod21.z.string()
|
|
1332
|
+
})
|
|
1333
|
+
)
|
|
1334
|
+
});
|
|
1335
|
+
var hostAgentResponseSchema = import_zod21.z.discriminatedUnion("operation", [
|
|
1336
|
+
import_zod21.z.object({
|
|
1337
|
+
operation: import_zod21.z.literal("seats"),
|
|
1338
|
+
instance: import_zod21.z.string().min(1),
|
|
1339
|
+
seats: import_zod21.z.array(seatViewSchema)
|
|
1340
|
+
}).strict(),
|
|
1341
|
+
import_zod21.z.object({
|
|
1342
|
+
operation: import_zod21.z.literal("timeline-read"),
|
|
1343
|
+
timeline: hostTimelineSchema
|
|
1344
|
+
}).strict(),
|
|
1345
|
+
import_zod21.z.object({
|
|
1346
|
+
operation: import_zod21.z.literal("input-log-read"),
|
|
1347
|
+
page: hostInputLogPageSchema
|
|
1348
|
+
}).strict(),
|
|
1349
|
+
import_zod21.z.object({
|
|
1350
|
+
operation: import_zod21.z.literal("clip-start"),
|
|
1351
|
+
clipId: import_zod21.z.string().min(1).max(128),
|
|
1352
|
+
startedAt: import_zod21.z.iso.datetime()
|
|
1353
|
+
}).strict(),
|
|
1354
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("clip-read"), clip: clipReadSchema }).strict(),
|
|
1355
|
+
import_zod21.z.object({
|
|
1356
|
+
operation: import_zod21.z.enum(["settings-read", "settings-update"]),
|
|
1357
|
+
values: airJamSettingsValuesSchema,
|
|
1358
|
+
revision: import_zod21.z.number().int().nonnegative()
|
|
1359
|
+
}),
|
|
1360
|
+
import_zod21.z.object({
|
|
1361
|
+
operation: import_zod21.z.literal("observe"),
|
|
1362
|
+
observation: hostObservationSchema
|
|
1363
|
+
}),
|
|
1364
|
+
import_zod21.z.object({
|
|
1365
|
+
operation: import_zod21.z.literal("read"),
|
|
1366
|
+
snapshot: hostAgentSnapshotSchema.nullable()
|
|
1367
|
+
}),
|
|
1368
|
+
import_zod21.z.object({
|
|
1369
|
+
operation: import_zod21.z.enum(["resolve", "invoke-host"]),
|
|
1370
|
+
target: import_zod21.z.object({
|
|
1371
|
+
kind: import_zod21.z.enum(["participant", "host"]),
|
|
1372
|
+
actionName: import_zod21.z.string(),
|
|
1373
|
+
storeDomain: import_zod21.z.string()
|
|
1374
|
+
}),
|
|
1375
|
+
payload: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()).optional(),
|
|
1376
|
+
acknowledgement: airJamActionInvocationResultSchema.optional()
|
|
1377
|
+
})
|
|
1378
|
+
]);
|
|
1379
|
+
var hostAgentRequestMessageSchema = import_zod21.z.object({
|
|
1380
|
+
type: import_zod21.z.literal("AIRJAM_HOST_AGENT"),
|
|
1381
|
+
requestId: import_zod21.z.string().min(1).max(128),
|
|
1382
|
+
request: hostAgentRequestSchema
|
|
1383
|
+
}).strict();
|
|
1384
|
+
var hostAgentResultMessageSchema = import_zod21.z.object({
|
|
1385
|
+
type: import_zod21.z.literal("AIRJAM_HOST_AGENT_RESULT"),
|
|
1386
|
+
requestId: hostAgentRequestMessageSchema.shape.requestId,
|
|
1387
|
+
result: import_zod21.z.discriminatedUnion("ok", [
|
|
1388
|
+
import_zod21.z.object({ ok: import_zod21.z.literal(true), response: hostAgentResponseSchema }),
|
|
1389
|
+
import_zod21.z.object({ ok: import_zod21.z.literal(false), error: import_zod21.z.string().min(1).max(1024) })
|
|
1390
|
+
])
|
|
1391
|
+
}).strict();
|
|
1392
|
+
|
|
1393
|
+
// src/runtime/contracts/control.ts
|
|
1394
|
+
var hostRuntimeActionRequestSchema = import_zod22.z.object({
|
|
1395
|
+
roomId: roomCodeSchema,
|
|
1396
|
+
storeDomain: import_zod22.z.string().trim().min(1).max(128),
|
|
1397
|
+
actionName: import_zod22.z.string().trim().min(1).max(128),
|
|
1398
|
+
payload: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.unknown()).optional()
|
|
1399
|
+
}).strict();
|
|
1400
|
+
var hostStateEpochSchema = import_zod22.z.object({
|
|
1401
|
+
storeDomain: import_zod22.z.string().min(1).max(128),
|
|
1402
|
+
epoch: import_zod22.z.string().min(1).max(128)
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
// src/core/replay-input-log.ts
|
|
1406
|
+
var settingsLogEventSchema = import_zod23.z.object({
|
|
1407
|
+
patch: airJamSettingsValuesSchema,
|
|
1408
|
+
revision: import_zod23.z.number().int().positive()
|
|
1409
|
+
}).strict();
|
|
1410
|
+
var seatLogEventSchema = import_zod23.z.object({ seat: seatViewSchema });
|
|
1411
|
+
var leftLogEventSchema = import_zod23.z.object({ seat: import_zod23.z.string() });
|
|
1412
|
+
var inputLogEventSchema = import_zod23.z.object({
|
|
1413
|
+
seat: import_zod23.z.string(),
|
|
1414
|
+
input: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.unknown())
|
|
1415
|
+
});
|
|
1416
|
+
var runtimeLogEventSchema = import_zod23.z.object({ runtimeState: runtimeStateSchema });
|
|
1417
|
+
var actionLogEventSchema = import_zod23.z.object({
|
|
1418
|
+
actionName: import_zod23.z.string(),
|
|
1419
|
+
payload: import_zod23.z.unknown().optional(),
|
|
1420
|
+
storeDomain: import_zod23.z.string(),
|
|
1421
|
+
actor: import_zod23.z.object({
|
|
1422
|
+
id: import_zod23.z.string(),
|
|
1423
|
+
role: import_zod23.z.enum(["host", "controller"])
|
|
1424
|
+
})
|
|
1425
|
+
});
|
|
1426
|
+
|
|
1427
|
+
// src/runtime/browser-replay.ts
|
|
1428
|
+
var whole = import_zod24.z.number().int().nonnegative();
|
|
1429
|
+
var replayAdvanceSchema = import_zod24.z.union([
|
|
1430
|
+
import_zod24.z.object({ steps: whole }).strict(),
|
|
1431
|
+
import_zod24.z.object({ ms: import_zod24.z.number().finite().nonnegative() }).strict(),
|
|
1432
|
+
import_zod24.z.object({ toTick: whole }).strict()
|
|
1433
|
+
]);
|
|
1434
|
+
var replayRequestSchema = import_zod24.z.discriminatedUnion("operation", [
|
|
1435
|
+
import_zod24.z.object({
|
|
1436
|
+
operation: import_zod24.z.literal("open"),
|
|
1437
|
+
log: airJamInputLogSchema,
|
|
1438
|
+
observe: hostObservationRequestSchema.pick({ scope: true, controllerId: true }).optional()
|
|
1439
|
+
}).strict(),
|
|
1440
|
+
import_zod24.z.object({ operation: import_zod24.z.literal("advance"), by: replayAdvanceSchema }).strict(),
|
|
1441
|
+
import_zod24.z.object({
|
|
1442
|
+
operation: import_zod24.z.literal("read"),
|
|
1443
|
+
/** Capture the paused frame on this explicit read; open and advance omit images. */
|
|
1444
|
+
includeImage: import_zod24.z.boolean().optional()
|
|
1445
|
+
}).strict()
|
|
1446
|
+
]);
|
|
1447
|
+
var replayReadSchema = import_zod24.z.object({
|
|
1448
|
+
tick: whole,
|
|
1449
|
+
ticks: whole,
|
|
1450
|
+
done: import_zod24.z.boolean(),
|
|
1451
|
+
stepMs: import_zod24.z.number().positive(),
|
|
1452
|
+
observation: hostObservationSchema
|
|
1453
|
+
}).strict();
|
|
1454
|
+
var replayRequestMessageSchema = import_zod24.z.object({
|
|
1455
|
+
type: import_zod24.z.literal("AIRJAM_REPLAY"),
|
|
1456
|
+
requestId: import_zod24.z.string().min(1),
|
|
1457
|
+
request: replayRequestSchema
|
|
1458
|
+
}).strict();
|
|
1459
|
+
var replayMessageSchema = import_zod24.z.discriminatedUnion("type", [
|
|
1460
|
+
import_zod24.z.object({ type: import_zod24.z.literal("AIRJAM_REPLAY_READY") }).strict(),
|
|
1461
|
+
import_zod24.z.object({
|
|
1462
|
+
type: import_zod24.z.literal("AIRJAM_REPLAY_RESULT"),
|
|
1463
|
+
requestId: import_zod24.z.string().min(1),
|
|
1464
|
+
result: import_zod24.z.discriminatedUnion("ok", [
|
|
1465
|
+
import_zod24.z.object({ ok: import_zod24.z.literal(true), response: replayReadSchema }).strict(),
|
|
1466
|
+
import_zod24.z.object({ ok: import_zod24.z.literal(false), error: import_zod24.z.string() }).strict()
|
|
1467
|
+
])
|
|
1468
|
+
}).strict()
|
|
1469
|
+
]);
|
|
510
1470
|
|
|
511
1471
|
// src/context/air-jam-context.tsx
|
|
512
1472
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -527,7 +1487,7 @@ var useAirJamConfig = () => {
|
|
|
527
1487
|
|
|
528
1488
|
// src/hooks/use-air-jam-host.ts
|
|
529
1489
|
var import_react4 = require("react");
|
|
530
|
-
var
|
|
1490
|
+
var import_zustand2 = require("zustand");
|
|
531
1491
|
var import_shallow2 = require("zustand/react/shallow");
|
|
532
1492
|
|
|
533
1493
|
// src/context/session-scope.ts
|
|
@@ -556,23 +1516,26 @@ var useAssertSessionScope = (expectedScope, hookName) => {
|
|
|
556
1516
|
|
|
557
1517
|
// src/runtime/runtime-owner-contexts.tsx
|
|
558
1518
|
var import_react3 = require("react");
|
|
1519
|
+
var fixedControllerOrientationContext = (0, import_react3.createContext)(void 0);
|
|
559
1520
|
var hostRuntimeContext = (0, import_react3.createContext)(null);
|
|
560
1521
|
var controllerRuntimeContext = (0, import_react3.createContext)(null);
|
|
1522
|
+
var declaredStoresContext = (0, import_react3.createContext)(null);
|
|
561
1523
|
|
|
562
1524
|
// src/hooks/use-air-jam-host.ts
|
|
563
1525
|
var toHostState = (state) => ({
|
|
564
1526
|
roomId: state.roomId,
|
|
565
1527
|
connectionStatus: state.connectionStatus,
|
|
566
1528
|
players: state.players,
|
|
567
|
-
controllers: state.controllerSessions,
|
|
568
1529
|
lastError: state.lastError,
|
|
1530
|
+
queuePosition: state.queuePosition,
|
|
569
1531
|
mode: state.mode,
|
|
570
|
-
runtimeState: state.runtimeState
|
|
1532
|
+
runtimeState: state.runtimeState,
|
|
1533
|
+
controllerOrientation: state.controllerOrientation
|
|
571
1534
|
});
|
|
572
1535
|
function useAirJamHost(selector) {
|
|
573
1536
|
useAssertSessionScope("host", "useAirJamHost");
|
|
574
1537
|
const { store } = useAirJamContext();
|
|
575
|
-
const selectedState = (0,
|
|
1538
|
+
const selectedState = (0, import_zustand2.useStore)(
|
|
576
1539
|
store,
|
|
577
1540
|
(0, import_shallow2.useShallow)((state) => {
|
|
578
1541
|
const hostState = toHostState(state);
|
|
@@ -606,23 +1569,23 @@ function useAirJamHost(selector) {
|
|
|
606
1569
|
var import_react5 = require("react");
|
|
607
1570
|
|
|
608
1571
|
// src/runtime/iframe-bridge.ts
|
|
609
|
-
var
|
|
1572
|
+
var import_zod27 = require("zod");
|
|
610
1573
|
|
|
611
1574
|
// src/contracts/v2/bridge.ts
|
|
612
|
-
var
|
|
613
|
-
var roomCodeSchema2 =
|
|
1575
|
+
var import_zod25 = require("zod");
|
|
1576
|
+
var roomCodeSchema2 = import_zod25.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, {
|
|
614
1577
|
message: "room code must contain only A-Z or 0-9"
|
|
615
1578
|
});
|
|
616
|
-
var
|
|
617
|
-
var
|
|
618
|
-
id:
|
|
619
|
-
label:
|
|
620
|
-
color:
|
|
621
|
-
avatarId:
|
|
1579
|
+
var runtimeStateSchema2 = import_zod25.z.enum(["paused", "playing"]);
|
|
1580
|
+
var playerProfileSchema2 = import_zod25.z.object({
|
|
1581
|
+
id: import_zod25.z.string().min(1),
|
|
1582
|
+
label: import_zod25.z.string().min(1),
|
|
1583
|
+
color: import_zod25.z.string().optional(),
|
|
1584
|
+
avatarId: import_zod25.z.string().optional()
|
|
622
1585
|
}).strict();
|
|
623
|
-
var inputFrameEntrySchema =
|
|
624
|
-
controllerId:
|
|
625
|
-
input:
|
|
1586
|
+
var inputFrameEntrySchema = import_zod25.z.object({
|
|
1587
|
+
controllerId: import_zod25.z.string().min(1),
|
|
1588
|
+
input: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown())
|
|
626
1589
|
}).strict();
|
|
627
1590
|
var V2_BRIDGE_PARENT_TO_GAME_TYPES = [
|
|
628
1591
|
"BOOTSTRAP",
|
|
@@ -645,89 +1608,89 @@ var allMessageTypes = [
|
|
|
645
1608
|
...V2_BRIDGE_GAME_TO_PARENT_TYPES
|
|
646
1609
|
];
|
|
647
1610
|
var knownBridgeMessageTypeSet = new Set(allMessageTypes);
|
|
648
|
-
var bootstrapMessageSchema =
|
|
649
|
-
type:
|
|
650
|
-
payload:
|
|
1611
|
+
var bootstrapMessageSchema = import_zod25.z.object({
|
|
1612
|
+
type: import_zod25.z.literal("BOOTSTRAP"),
|
|
1613
|
+
payload: import_zod25.z.object({
|
|
651
1614
|
roomId: roomCodeSchema2,
|
|
652
|
-
players:
|
|
653
|
-
state:
|
|
654
|
-
runtimeState:
|
|
655
|
-
message:
|
|
1615
|
+
players: import_zod25.z.array(playerProfileSchema2),
|
|
1616
|
+
state: import_zod25.z.object({
|
|
1617
|
+
runtimeState: runtimeStateSchema2,
|
|
1618
|
+
message: import_zod25.z.string().optional()
|
|
656
1619
|
}).strict(),
|
|
657
|
-
capabilities:
|
|
1620
|
+
capabilities: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.boolean()).default({})
|
|
658
1621
|
}).strict()
|
|
659
1622
|
}).strict();
|
|
660
|
-
var playersUpdateMessageSchema =
|
|
661
|
-
type:
|
|
662
|
-
payload:
|
|
663
|
-
players:
|
|
1623
|
+
var playersUpdateMessageSchema = import_zod25.z.object({
|
|
1624
|
+
type: import_zod25.z.literal("PLAYERS_UPDATE"),
|
|
1625
|
+
payload: import_zod25.z.object({
|
|
1626
|
+
players: import_zod25.z.array(playerProfileSchema2)
|
|
664
1627
|
}).strict()
|
|
665
1628
|
}).strict();
|
|
666
|
-
var runtimeStateUpdateMessageSchema =
|
|
667
|
-
type:
|
|
668
|
-
payload:
|
|
669
|
-
runtimeState:
|
|
670
|
-
message:
|
|
1629
|
+
var runtimeStateUpdateMessageSchema = import_zod25.z.object({
|
|
1630
|
+
type: import_zod25.z.literal("RUNTIME_STATE_UPDATE"),
|
|
1631
|
+
payload: import_zod25.z.object({
|
|
1632
|
+
runtimeState: runtimeStateSchema2,
|
|
1633
|
+
message: import_zod25.z.string().optional()
|
|
671
1634
|
}).strict()
|
|
672
1635
|
}).strict();
|
|
673
|
-
var inputFrameMessageSchema =
|
|
674
|
-
type:
|
|
675
|
-
payload:
|
|
676
|
-
frameId:
|
|
677
|
-
inputs:
|
|
1636
|
+
var inputFrameMessageSchema = import_zod25.z.object({
|
|
1637
|
+
type: import_zod25.z.literal("INPUT_FRAME"),
|
|
1638
|
+
payload: import_zod25.z.object({
|
|
1639
|
+
frameId: import_zod25.z.number().int().nonnegative(),
|
|
1640
|
+
inputs: import_zod25.z.array(inputFrameEntrySchema)
|
|
678
1641
|
}).strict()
|
|
679
1642
|
}).strict();
|
|
680
|
-
var pauseMessageSchema =
|
|
681
|
-
type:
|
|
682
|
-
payload:
|
|
683
|
-
reason:
|
|
1643
|
+
var pauseMessageSchema = import_zod25.z.object({
|
|
1644
|
+
type: import_zod25.z.literal("PAUSE"),
|
|
1645
|
+
payload: import_zod25.z.object({
|
|
1646
|
+
reason: import_zod25.z.string().optional()
|
|
684
1647
|
}).strict()
|
|
685
1648
|
}).strict();
|
|
686
|
-
var resumeMessageSchema =
|
|
687
|
-
type:
|
|
688
|
-
payload:
|
|
1649
|
+
var resumeMessageSchema = import_zod25.z.object({
|
|
1650
|
+
type: import_zod25.z.literal("RESUME"),
|
|
1651
|
+
payload: import_zod25.z.object({}).strict()
|
|
689
1652
|
}).strict();
|
|
690
|
-
var shutdownMessageSchema =
|
|
691
|
-
type:
|
|
692
|
-
payload:
|
|
693
|
-
reason:
|
|
1653
|
+
var shutdownMessageSchema = import_zod25.z.object({
|
|
1654
|
+
type: import_zod25.z.literal("SHUTDOWN"),
|
|
1655
|
+
payload: import_zod25.z.object({
|
|
1656
|
+
reason: import_zod25.z.string().min(1)
|
|
694
1657
|
}).strict()
|
|
695
1658
|
}).strict();
|
|
696
|
-
var readyMessageSchema =
|
|
697
|
-
type:
|
|
698
|
-
payload:
|
|
699
|
-
readyAtMs:
|
|
1659
|
+
var readyMessageSchema = import_zod25.z.object({
|
|
1660
|
+
type: import_zod25.z.literal("READY"),
|
|
1661
|
+
payload: import_zod25.z.object({
|
|
1662
|
+
readyAtMs: import_zod25.z.number().int().nonnegative()
|
|
700
1663
|
}).strict()
|
|
701
1664
|
}).strict();
|
|
702
|
-
var statePatchMessageSchema =
|
|
703
|
-
type:
|
|
704
|
-
payload:
|
|
705
|
-
patch:
|
|
1665
|
+
var statePatchMessageSchema = import_zod25.z.object({
|
|
1666
|
+
type: import_zod25.z.literal("STATE_PATCH"),
|
|
1667
|
+
payload: import_zod25.z.object({
|
|
1668
|
+
patch: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown())
|
|
706
1669
|
}).strict()
|
|
707
1670
|
}).strict();
|
|
708
|
-
var signalMessageSchema =
|
|
709
|
-
type:
|
|
710
|
-
payload:
|
|
711
|
-
signalType:
|
|
712
|
-
targetId:
|
|
713
|
-
data:
|
|
1671
|
+
var signalMessageSchema = import_zod25.z.object({
|
|
1672
|
+
type: import_zod25.z.literal("SIGNAL"),
|
|
1673
|
+
payload: import_zod25.z.object({
|
|
1674
|
+
signalType: import_zod25.z.string().min(1),
|
|
1675
|
+
targetId: import_zod25.z.string().min(1).optional(),
|
|
1676
|
+
data: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown())
|
|
714
1677
|
}).strict()
|
|
715
1678
|
}).strict();
|
|
716
|
-
var errorMessageSchema =
|
|
717
|
-
type:
|
|
718
|
-
payload:
|
|
719
|
-
code:
|
|
720
|
-
message:
|
|
721
|
-
details:
|
|
1679
|
+
var errorMessageSchema = import_zod25.z.object({
|
|
1680
|
+
type: import_zod25.z.literal("ERROR"),
|
|
1681
|
+
payload: import_zod25.z.object({
|
|
1682
|
+
code: import_zod25.z.string().min(1),
|
|
1683
|
+
message: import_zod25.z.string().min(1),
|
|
1684
|
+
details: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown()).optional()
|
|
722
1685
|
}).strict()
|
|
723
1686
|
}).strict();
|
|
724
|
-
var metricsMessageSchema =
|
|
725
|
-
type:
|
|
726
|
-
payload:
|
|
727
|
-
values:
|
|
1687
|
+
var metricsMessageSchema = import_zod25.z.object({
|
|
1688
|
+
type: import_zod25.z.literal("METRICS"),
|
|
1689
|
+
payload: import_zod25.z.object({
|
|
1690
|
+
values: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.number())
|
|
728
1691
|
}).strict()
|
|
729
1692
|
}).strict();
|
|
730
|
-
var v2BridgeParentToGameMessageSchema =
|
|
1693
|
+
var v2BridgeParentToGameMessageSchema = import_zod25.z.union([
|
|
731
1694
|
bootstrapMessageSchema,
|
|
732
1695
|
playersUpdateMessageSchema,
|
|
733
1696
|
runtimeStateUpdateMessageSchema,
|
|
@@ -736,24 +1699,24 @@ var v2BridgeParentToGameMessageSchema = import_zod9.z.union([
|
|
|
736
1699
|
resumeMessageSchema,
|
|
737
1700
|
shutdownMessageSchema
|
|
738
1701
|
]);
|
|
739
|
-
var v2BridgeGameToParentMessageSchema =
|
|
1702
|
+
var v2BridgeGameToParentMessageSchema = import_zod25.z.union([
|
|
740
1703
|
readyMessageSchema,
|
|
741
1704
|
statePatchMessageSchema,
|
|
742
1705
|
signalMessageSchema,
|
|
743
1706
|
errorMessageSchema,
|
|
744
1707
|
metricsMessageSchema
|
|
745
1708
|
]);
|
|
746
|
-
var v2BridgeMessageSchema =
|
|
1709
|
+
var v2BridgeMessageSchema = import_zod25.z.union([
|
|
747
1710
|
v2BridgeParentToGameMessageSchema,
|
|
748
1711
|
v2BridgeGameToParentMessageSchema
|
|
749
1712
|
]);
|
|
750
1713
|
|
|
751
1714
|
// src/contracts/v2/handshake.ts
|
|
752
|
-
var
|
|
1715
|
+
var import_zod26 = require("zod");
|
|
753
1716
|
var AIR_JAM_PROTOCOL_V2 = "2";
|
|
754
1717
|
var semanticVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
755
|
-
var v2ProtocolVersionSchema =
|
|
756
|
-
var runtimeKindSchema =
|
|
1718
|
+
var v2ProtocolVersionSchema = import_zod26.z.literal(AIR_JAM_PROTOCOL_V2);
|
|
1719
|
+
var runtimeKindSchema = import_zod26.z.enum([
|
|
757
1720
|
"standalone-host",
|
|
758
1721
|
"standalone-controller",
|
|
759
1722
|
"arcade-runtime",
|
|
@@ -763,12 +1726,12 @@ var runtimeKindSchema = import_zod10.z.enum([
|
|
|
763
1726
|
"arcade-controller-runtime",
|
|
764
1727
|
"arcade-controller-iframe"
|
|
765
1728
|
]);
|
|
766
|
-
var capabilityFlagsSchema =
|
|
767
|
-
var sdkVersionSchema =
|
|
1729
|
+
var capabilityFlagsSchema = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.boolean());
|
|
1730
|
+
var sdkVersionSchema = import_zod26.z.string().regex(
|
|
768
1731
|
semanticVersionPattern,
|
|
769
1732
|
"sdkVersion must use semantic version format (for example 1.2.3)"
|
|
770
1733
|
);
|
|
771
|
-
var v2HandshakeSchema =
|
|
1734
|
+
var v2HandshakeSchema = import_zod26.z.object({
|
|
772
1735
|
protocolVersion: v2ProtocolVersionSchema,
|
|
773
1736
|
sdkVersion: sdkVersionSchema,
|
|
774
1737
|
runtimeKind: runtimeKindSchema,
|
|
@@ -779,38 +1742,38 @@ var v2HandshakeSchema = import_zod10.z.object({
|
|
|
779
1742
|
var AIRJAM_BRIDGE_INIT = "AIRJAM_BRIDGE_INIT";
|
|
780
1743
|
var AIRJAM_SETTINGS_SYNC = "AIRJAM_SETTINGS_SYNC";
|
|
781
1744
|
var AIRJAM_SETTINGS_READY = "AIRJAM_SETTINGS_READY";
|
|
782
|
-
var airJamSettingsSyncSchema =
|
|
783
|
-
type:
|
|
784
|
-
payload:
|
|
785
|
-
settings:
|
|
786
|
-
audio:
|
|
787
|
-
masterVolume:
|
|
788
|
-
musicVolume:
|
|
789
|
-
sfxVolume:
|
|
1745
|
+
var airJamSettingsSyncSchema = import_zod27.z.object({
|
|
1746
|
+
type: import_zod27.z.literal(AIRJAM_SETTINGS_SYNC),
|
|
1747
|
+
payload: import_zod27.z.object({
|
|
1748
|
+
settings: import_zod27.z.object({
|
|
1749
|
+
audio: import_zod27.z.object({
|
|
1750
|
+
masterVolume: import_zod27.z.number(),
|
|
1751
|
+
musicVolume: import_zod27.z.number(),
|
|
1752
|
+
sfxVolume: import_zod27.z.number()
|
|
790
1753
|
}).strict(),
|
|
791
|
-
accessibility:
|
|
792
|
-
reducedMotion:
|
|
793
|
-
highContrast:
|
|
1754
|
+
accessibility: import_zod27.z.object({
|
|
1755
|
+
reducedMotion: import_zod27.z.boolean(),
|
|
1756
|
+
highContrast: import_zod27.z.boolean()
|
|
794
1757
|
}).strict(),
|
|
795
|
-
feedback:
|
|
796
|
-
hapticsEnabled:
|
|
1758
|
+
feedback: import_zod27.z.object({
|
|
1759
|
+
hapticsEnabled: import_zod27.z.boolean()
|
|
797
1760
|
}).strict(),
|
|
798
|
-
previewControllers:
|
|
799
|
-
activeOpacity:
|
|
1761
|
+
previewControllers: import_zod27.z.object({
|
|
1762
|
+
activeOpacity: import_zod27.z.number()
|
|
800
1763
|
}).strict()
|
|
801
1764
|
}).strict()
|
|
802
1765
|
}).strict()
|
|
803
1766
|
}).strict();
|
|
804
|
-
var airJamBridgeInitSchema =
|
|
805
|
-
type:
|
|
806
|
-
payload:
|
|
1767
|
+
var airJamBridgeInitSchema = import_zod27.z.object({
|
|
1768
|
+
type: import_zod27.z.literal(AIRJAM_BRIDGE_INIT),
|
|
1769
|
+
payload: import_zod27.z.object({
|
|
807
1770
|
handshake: v2HandshakeSchema
|
|
808
1771
|
}).strict()
|
|
809
1772
|
}).strict();
|
|
810
|
-
var airJamSettingsReadySchema =
|
|
811
|
-
type:
|
|
812
|
-
payload:
|
|
813
|
-
ready:
|
|
1773
|
+
var airJamSettingsReadySchema = import_zod27.z.object({
|
|
1774
|
+
type: import_zod27.z.literal(AIRJAM_SETTINGS_READY),
|
|
1775
|
+
payload: import_zod27.z.object({
|
|
1776
|
+
ready: import_zod27.z.literal(true)
|
|
814
1777
|
}).strict()
|
|
815
1778
|
}).strict();
|
|
816
1779
|
|
|
@@ -887,6 +1850,7 @@ var isEmbeddedArcadeRuntimeSearchParams = (searchParams) => parseOptionalArcadeS
|
|
|
887
1850
|
var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
888
1851
|
enabled = "auto",
|
|
889
1852
|
topology,
|
|
1853
|
+
isEmbeddedRuntime = typeof window !== "undefined" && window.parent !== window,
|
|
890
1854
|
isDevelopmentRuntime = readDevelopmentRuntime(),
|
|
891
1855
|
searchParams
|
|
892
1856
|
} = {}) => {
|
|
@@ -894,12 +1858,12 @@ var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
|
894
1858
|
return enabled;
|
|
895
1859
|
}
|
|
896
1860
|
const localDevControlSurfacesEnabled = topology != null ? isLocalDevControlSurfaceRuntimeMode(topology.runtimeMode) : isDevelopmentRuntime;
|
|
897
|
-
return localDevControlSurfacesEnabled && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
1861
|
+
return localDevControlSurfacesEnabled && !topology?.embedded && !isEmbeddedRuntime && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
898
1862
|
};
|
|
899
1863
|
|
|
900
1864
|
// src/preview/workspace.tsx
|
|
901
1865
|
var import_lucide_react2 = require("lucide-react");
|
|
902
|
-
var
|
|
1866
|
+
var import_react10 = require("react");
|
|
903
1867
|
var import_react_dom = require("react-dom");
|
|
904
1868
|
|
|
905
1869
|
// src/components/shell-classes.ts
|
|
@@ -936,27 +1900,350 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
936
1900
|
variant: "default",
|
|
937
1901
|
size: "default"
|
|
938
1902
|
}
|
|
939
|
-
}
|
|
940
|
-
);
|
|
941
|
-
function Button({
|
|
942
|
-
className,
|
|
943
|
-
variant,
|
|
944
|
-
size,
|
|
945
|
-
asChild = false,
|
|
946
|
-
...props
|
|
947
|
-
}) {
|
|
948
|
-
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
949
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
950
|
-
Comp,
|
|
951
|
-
{
|
|
952
|
-
"data-slot": "button",
|
|
953
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
954
|
-
...props
|
|
1903
|
+
}
|
|
1904
|
+
);
|
|
1905
|
+
function Button({
|
|
1906
|
+
className,
|
|
1907
|
+
variant,
|
|
1908
|
+
size,
|
|
1909
|
+
asChild = false,
|
|
1910
|
+
...props
|
|
1911
|
+
}) {
|
|
1912
|
+
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
1913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1914
|
+
Comp,
|
|
1915
|
+
{
|
|
1916
|
+
"data-slot": "button",
|
|
1917
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
1918
|
+
...props
|
|
1919
|
+
}
|
|
1920
|
+
);
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
// src/runtime/local-players.tsx
|
|
1924
|
+
var import_react6 = require("react");
|
|
1925
|
+
|
|
1926
|
+
// src/runtime/local-seats.ts
|
|
1927
|
+
var import_zod31 = require("zod");
|
|
1928
|
+
|
|
1929
|
+
// src/core/local-input.ts
|
|
1930
|
+
var import_zod28 = require("zod");
|
|
1931
|
+
var localInputOperationSchema = import_zod28.z.discriminatedUnion("op", [
|
|
1932
|
+
import_zod28.z.object({
|
|
1933
|
+
op: import_zod28.z.literal("press"),
|
|
1934
|
+
control: import_zod28.z.string(),
|
|
1935
|
+
hold: import_zod28.z.number().int()
|
|
1936
|
+
}).strict(),
|
|
1937
|
+
import_zod28.z.object({
|
|
1938
|
+
op: import_zod28.z.literal("hold"),
|
|
1939
|
+
control: import_zod28.z.string(),
|
|
1940
|
+
value: import_zod28.z.number().min(-1).max(1),
|
|
1941
|
+
hold: import_zod28.z.number().int()
|
|
1942
|
+
}).strict(),
|
|
1943
|
+
import_zod28.z.object({ op: import_zod28.z.literal("release"), hold: import_zod28.z.number().int() }).strict(),
|
|
1944
|
+
import_zod28.z.object({
|
|
1945
|
+
op: import_zod28.z.literal("set"),
|
|
1946
|
+
control: import_zod28.z.string(),
|
|
1947
|
+
value: import_zod28.z.union([
|
|
1948
|
+
import_zod28.z.number().min(-1).max(1),
|
|
1949
|
+
import_zod28.z.object({
|
|
1950
|
+
x: import_zod28.z.number().min(-1).max(1),
|
|
1951
|
+
y: import_zod28.z.number().min(-1).max(1)
|
|
1952
|
+
}).strict()
|
|
1953
|
+
])
|
|
1954
|
+
}).strict(),
|
|
1955
|
+
import_zod28.z.object({ op: import_zod28.z.literal("release-all") }).strict()
|
|
1956
|
+
]);
|
|
1957
|
+
|
|
1958
|
+
// src/preview/identity.ts
|
|
1959
|
+
var AIR_JAM_PREVIEW_FLAG_QUERY_PARAM = "aj_preview";
|
|
1960
|
+
var AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM = "aj_preview_device";
|
|
1961
|
+
var AIR_JAM_PREVIEW_PARENT_QUERY_PARAM = "aj_preview_parent";
|
|
1962
|
+
var AIR_JAM_PREVIEW_CAPTURE_QUERY_PARAM = "aj_preview_capture";
|
|
1963
|
+
var createPreviewControllerDeviceId = () => `pd_${crypto.randomUUID()}`;
|
|
1964
|
+
var normalizePreviewDeviceId = (value) => {
|
|
1965
|
+
if (!value) {
|
|
1966
|
+
return null;
|
|
1967
|
+
}
|
|
1968
|
+
const normalized = value.trim();
|
|
1969
|
+
return normalized.length >= 8 ? normalized : null;
|
|
1970
|
+
};
|
|
1971
|
+
var isPreviewControllerSearchParams = (params) => {
|
|
1972
|
+
const flag = params.get(AIR_JAM_PREVIEW_FLAG_QUERY_PARAM);
|
|
1973
|
+
return flag === "1" || flag === "true";
|
|
1974
|
+
};
|
|
1975
|
+
var readPreviewControllerDeviceIdFromSearchParams = (params) => {
|
|
1976
|
+
if (!isPreviewControllerSearchParams(params)) {
|
|
1977
|
+
return null;
|
|
1978
|
+
}
|
|
1979
|
+
return normalizePreviewDeviceId(
|
|
1980
|
+
params.get(AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM)
|
|
1981
|
+
);
|
|
1982
|
+
};
|
|
1983
|
+
var readPreviewControllerDeviceIdFromLocation = () => {
|
|
1984
|
+
if (typeof window === "undefined") {
|
|
1985
|
+
return null;
|
|
1986
|
+
}
|
|
1987
|
+
return readPreviewControllerDeviceIdFromSearchParams(
|
|
1988
|
+
new URLSearchParams(window.location.search)
|
|
1989
|
+
);
|
|
1990
|
+
};
|
|
1991
|
+
var readPreviewControllerParent = () => {
|
|
1992
|
+
if (typeof window === "undefined" || window.parent === window || readPreviewControllerDeviceIdFromLocation() === null) {
|
|
1993
|
+
return null;
|
|
1994
|
+
}
|
|
1995
|
+
const declared = new URLSearchParams(window.location.search).get(
|
|
1996
|
+
AIR_JAM_PREVIEW_PARENT_QUERY_PARAM
|
|
1997
|
+
);
|
|
1998
|
+
return {
|
|
1999
|
+
window: window.parent,
|
|
2000
|
+
origin: declared ? new URL(declared).origin : window.location.origin
|
|
2001
|
+
};
|
|
2002
|
+
};
|
|
2003
|
+
|
|
2004
|
+
// src/runtime/controller-bridge-context.ts
|
|
2005
|
+
var import_zod30 = require("zod");
|
|
2006
|
+
|
|
2007
|
+
// src/runtime/arcade-surface-identity.ts
|
|
2008
|
+
var import_zod29 = require("zod");
|
|
2009
|
+
var arcadeSurfaceRuntimeIdentitySchema = import_zod29.z.object({
|
|
2010
|
+
epoch: import_zod29.z.number().int().nonnegative(),
|
|
2011
|
+
kind: import_zod29.z.enum(["browser", "game"]),
|
|
2012
|
+
gameId: import_zod29.z.string().nullable()
|
|
2013
|
+
}).strict();
|
|
2014
|
+
|
|
2015
|
+
// src/runtime/controller-bridge-context.ts
|
|
2016
|
+
var controllerBridgeContextSchema = import_zod30.z.union([
|
|
2017
|
+
import_zod30.z.object({ arcadeSurface: arcadeSurfaceRuntimeIdentitySchema }).strict(),
|
|
2018
|
+
import_zod30.z.object({ harnessSessionId: import_zod30.z.uuid() }).strict()
|
|
2019
|
+
]);
|
|
2020
|
+
|
|
2021
|
+
// src/runtime/local-seats.ts
|
|
2022
|
+
var AIR_JAM_LOCAL_SEAT_QUERY_PARAM = "airjamLocalSeat";
|
|
2023
|
+
var seatSchema = import_zod31.z.object({
|
|
2024
|
+
key: import_zod31.z.string().min(1).max(32),
|
|
2025
|
+
label: import_zod31.z.string().min(1).max(32)
|
|
2026
|
+
}).strict();
|
|
2027
|
+
var seatMessage = (type) => import_zod31.z.object({ type: import_zod31.z.literal(type), seat: import_zod31.z.string() }).strict();
|
|
2028
|
+
var phoneReadySchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.ready") }).strict();
|
|
2029
|
+
var phoneInputSchema = import_zod31.z.object({
|
|
2030
|
+
type: import_zod31.z.literal("airjam.local-seat.input"),
|
|
2031
|
+
operation: localInputOperationSchema
|
|
2032
|
+
}).strict();
|
|
2033
|
+
var localSeatKeyboardSchema = import_zod31.z.object({
|
|
2034
|
+
type: import_zod31.z.literal("airjam.local-seat.keyboard"),
|
|
2035
|
+
event: import_zod31.z.discriminatedUnion("kind", [
|
|
2036
|
+
import_zod31.z.object({
|
|
2037
|
+
kind: import_zod31.z.literal("keydown"),
|
|
2038
|
+
code: import_zod31.z.string(),
|
|
2039
|
+
repeat: import_zod31.z.boolean()
|
|
2040
|
+
}).strict(),
|
|
2041
|
+
import_zod31.z.object({ kind: import_zod31.z.literal("keyup"), code: import_zod31.z.string() }).strict(),
|
|
2042
|
+
import_zod31.z.object({ kind: import_zod31.z.literal("blur") }).strict()
|
|
2043
|
+
])
|
|
2044
|
+
}).strict();
|
|
2045
|
+
var availableSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.available") }).strict();
|
|
2046
|
+
var unavailableSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.unavailable") }).strict();
|
|
2047
|
+
var openedSchema = seatMessage("airjam.local-seat.opened");
|
|
2048
|
+
var refusedSchema = seatMessage("airjam.local-seat.refused");
|
|
2049
|
+
var closedSchema = seatMessage("airjam.local-seat.closed");
|
|
2050
|
+
var localSeatRequestSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.request"), seat: seatSchema }).strict();
|
|
2051
|
+
var localSeatQuerySchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.query") }).strict();
|
|
2052
|
+
var relayedSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.relayed") }).strict();
|
|
2053
|
+
var isLocalSeatRelayedMessage = (data) => relayedSchema.safeParse(data).success;
|
|
2054
|
+
var localSeatRelaySchema = import_zod31.z.object({
|
|
2055
|
+
type: import_zod31.z.literal("airjam.local-seat.input"),
|
|
2056
|
+
seat: import_zod31.z.string(),
|
|
2057
|
+
operation: localInputOperationSchema
|
|
2058
|
+
}).strict();
|
|
2059
|
+
var sendLocalSeatOperation = (frame, origin, operation) => frame.postMessage({ type: "airjam.local-seat.input", operation }, origin);
|
|
2060
|
+
var isLocalSeatReadyMessage = (data) => phoneReadySchema.safeParse(data).success;
|
|
2061
|
+
var localSeatMessages = {
|
|
2062
|
+
available: () => ({ type: "airjam.local-seat.available" }),
|
|
2063
|
+
unavailable: () => ({ type: "airjam.local-seat.unavailable" }),
|
|
2064
|
+
opened: (seat) => ({ type: "airjam.local-seat.opened", seat }),
|
|
2065
|
+
refused: (seat) => ({ type: "airjam.local-seat.refused", seat }),
|
|
2066
|
+
closed: (seat) => ({ type: "airjam.local-seat.closed", seat })
|
|
2067
|
+
};
|
|
2068
|
+
var serveLocalSeats = (game) => {
|
|
2069
|
+
let provider = null;
|
|
2070
|
+
let stopKeyboard;
|
|
2071
|
+
const opened = /* @__PURE__ */ new Map();
|
|
2072
|
+
const opening = /* @__PURE__ */ new Map();
|
|
2073
|
+
const post = (message) => game.window()?.postMessage(message, game.origin);
|
|
2074
|
+
const close = (key, seat) => {
|
|
2075
|
+
if (opened.get(key) !== seat) return;
|
|
2076
|
+
seat.send({ op: "release-all" });
|
|
2077
|
+
opened.delete(key);
|
|
2078
|
+
post(localSeatMessages.closed(key));
|
|
2079
|
+
};
|
|
2080
|
+
const open = (seat) => {
|
|
2081
|
+
if (opened.has(seat.key)) return post(localSeatMessages.opened(seat.key));
|
|
2082
|
+
if (opening.has(seat.key)) return;
|
|
2083
|
+
if (!provider) return post(localSeatMessages.refused(seat.key));
|
|
2084
|
+
const request = {};
|
|
2085
|
+
opening.set(seat.key, request);
|
|
2086
|
+
void provider.open(seat).then((result) => {
|
|
2087
|
+
if (opening.get(seat.key) !== request) return;
|
|
2088
|
+
opening.delete(seat.key);
|
|
2089
|
+
if (!result) return post(localSeatMessages.refused(seat.key));
|
|
2090
|
+
opened.set(seat.key, result);
|
|
2091
|
+
post(localSeatMessages.opened(seat.key));
|
|
2092
|
+
void result.closed.then(() => close(seat.key, result));
|
|
2093
|
+
});
|
|
2094
|
+
};
|
|
2095
|
+
const receive = (event) => {
|
|
2096
|
+
if (event.origin !== game.origin || event.source !== game.window()) return;
|
|
2097
|
+
if (localSeatQuerySchema.safeParse(event.data).success) {
|
|
2098
|
+
if (provider) post(localSeatMessages.available());
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
const request = localSeatRequestSchema.safeParse(event.data);
|
|
2102
|
+
if (request.success) return open(request.data.seat);
|
|
2103
|
+
const relay = localSeatRelaySchema.safeParse(event.data);
|
|
2104
|
+
if (relay.success) opened.get(relay.data.seat)?.send(relay.data.operation);
|
|
2105
|
+
};
|
|
2106
|
+
window.addEventListener("message", receive);
|
|
2107
|
+
const provide = (next) => {
|
|
2108
|
+
if (next === provider) return;
|
|
2109
|
+
const wasAvailable = provider !== null;
|
|
2110
|
+
stopKeyboard?.();
|
|
2111
|
+
provider = next;
|
|
2112
|
+
stopKeyboard = next?.subscribeKeyboard?.(post);
|
|
2113
|
+
for (const key of opening.keys()) post(localSeatMessages.refused(key));
|
|
2114
|
+
opening.clear();
|
|
2115
|
+
for (const [key, seat] of opened) close(key, seat);
|
|
2116
|
+
if (wasAvailable) post(localSeatMessages.unavailable());
|
|
2117
|
+
if (next) post(localSeatMessages.available());
|
|
2118
|
+
};
|
|
2119
|
+
return {
|
|
2120
|
+
provide,
|
|
2121
|
+
stop() {
|
|
2122
|
+
provide(null);
|
|
2123
|
+
window.removeEventListener("message", receive);
|
|
955
2124
|
}
|
|
2125
|
+
};
|
|
2126
|
+
};
|
|
2127
|
+
var isEditable = (target) => target instanceof HTMLElement && (target.isContentEditable || target.closest(
|
|
2128
|
+
"input, select, textarea, [contenteditable]:not([contenteditable=false])"
|
|
2129
|
+
) !== null);
|
|
2130
|
+
var readLocalSeatLabel = () => typeof window === "undefined" ? null : new URLSearchParams(window.location.search).get(
|
|
2131
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM
|
|
2132
|
+
);
|
|
2133
|
+
var localSeatPhoneParent = () => readLocalSeatLabel() === null ? null : readPreviewControllerParent();
|
|
2134
|
+
var relayPhoneKeyboard = (parent) => {
|
|
2135
|
+
const page = window;
|
|
2136
|
+
const held = /* @__PURE__ */ new Set();
|
|
2137
|
+
const send = (event) => parent.window.postMessage(
|
|
2138
|
+
{ type: "airjam.local-seat.keyboard", event },
|
|
2139
|
+
parent.origin
|
|
956
2140
|
);
|
|
957
|
-
|
|
2141
|
+
const keydown = (event) => {
|
|
2142
|
+
if (isEditable(event.target)) return;
|
|
2143
|
+
held.add(event.code);
|
|
2144
|
+
send({ kind: "keydown", code: event.code, repeat: event.repeat });
|
|
2145
|
+
};
|
|
2146
|
+
const keyup = (event) => {
|
|
2147
|
+
if (held.delete(event.code)) send({ kind: "keyup", code: event.code });
|
|
2148
|
+
};
|
|
2149
|
+
const release = () => {
|
|
2150
|
+
if (held.size === 0) return;
|
|
2151
|
+
held.clear();
|
|
2152
|
+
send({ kind: "blur" });
|
|
2153
|
+
};
|
|
2154
|
+
page.addEventListener("keydown", keydown);
|
|
2155
|
+
page.addEventListener("keyup", keyup);
|
|
2156
|
+
page.addEventListener("blur", release);
|
|
2157
|
+
return () => {
|
|
2158
|
+
page.removeEventListener("keydown", keydown);
|
|
2159
|
+
page.removeEventListener("keyup", keyup);
|
|
2160
|
+
page.removeEventListener("blur", release);
|
|
2161
|
+
release();
|
|
2162
|
+
};
|
|
2163
|
+
};
|
|
2164
|
+
var relayLocalSeatInput = (frame) => {
|
|
2165
|
+
const parent = localSeatPhoneParent();
|
|
2166
|
+
if (!parent) return () => {
|
|
2167
|
+
};
|
|
2168
|
+
const stopKeyboard = relayPhoneKeyboard(parent);
|
|
2169
|
+
const onMessage = (event) => {
|
|
2170
|
+
const game = frame.window();
|
|
2171
|
+
if (!game) return;
|
|
2172
|
+
if (event.source === parent.window && event.origin === parent.origin) {
|
|
2173
|
+
const message = phoneInputSchema.safeParse(event.data);
|
|
2174
|
+
if (message.success) game.postMessage(message.data, frame.origin);
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
if (event.source !== game || event.origin !== frame.origin) return;
|
|
2178
|
+
if (isLocalSeatReadyMessage(event.data))
|
|
2179
|
+
parent.window.postMessage(
|
|
2180
|
+
{ type: "airjam.local-seat.ready" },
|
|
2181
|
+
parent.origin
|
|
2182
|
+
);
|
|
2183
|
+
const keyboard = localSeatKeyboardSchema.safeParse(event.data);
|
|
2184
|
+
if (keyboard.success)
|
|
2185
|
+
parent.window.postMessage(keyboard.data, parent.origin);
|
|
2186
|
+
};
|
|
2187
|
+
window.addEventListener("message", onMessage);
|
|
2188
|
+
return () => {
|
|
2189
|
+
window.removeEventListener("message", onMessage);
|
|
2190
|
+
stopKeyboard();
|
|
2191
|
+
};
|
|
2192
|
+
};
|
|
2193
|
+
|
|
2194
|
+
// src/runtime/local-players.tsx
|
|
2195
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2196
|
+
var localSeatRegistry = (0, import_react6.createContext)(null);
|
|
2197
|
+
var useProvideLocalSeats = (provider) => {
|
|
2198
|
+
const register = (0, import_react6.useContext)(localSeatRegistry);
|
|
2199
|
+
(0, import_react6.useEffect)(() => {
|
|
2200
|
+
if (!register || !provider) return;
|
|
2201
|
+
register(provider);
|
|
2202
|
+
return () => register(null);
|
|
2203
|
+
}, [register, provider]);
|
|
2204
|
+
};
|
|
2205
|
+
var useServeLocalSeats = (game, provider) => {
|
|
2206
|
+
const server = (0, import_react6.useRef)(null);
|
|
2207
|
+
(0, import_react6.useEffect)(() => {
|
|
2208
|
+
if (!game) return;
|
|
2209
|
+
const served = serveLocalSeats(game);
|
|
2210
|
+
server.current = served;
|
|
2211
|
+
return () => {
|
|
2212
|
+
served.stop();
|
|
2213
|
+
server.current = null;
|
|
2214
|
+
};
|
|
2215
|
+
}, [game]);
|
|
2216
|
+
(0, import_react6.useEffect)(() => server.current?.provide(provider), [game, provider]);
|
|
2217
|
+
};
|
|
2218
|
+
|
|
2219
|
+
// src/components/surface-viewport-layout.ts
|
|
2220
|
+
var CONTROLLER_REFERENCE_SIZE = {
|
|
2221
|
+
portrait: {
|
|
2222
|
+
width: 412,
|
|
2223
|
+
height: 915
|
|
2224
|
+
},
|
|
2225
|
+
landscape: {
|
|
2226
|
+
width: 915,
|
|
2227
|
+
height: 412
|
|
2228
|
+
}
|
|
2229
|
+
};
|
|
2230
|
+
var HOST_REFERENCE_SIZE = {
|
|
2231
|
+
portrait: {
|
|
2232
|
+
width: 900,
|
|
2233
|
+
height: 1600
|
|
2234
|
+
},
|
|
2235
|
+
landscape: {
|
|
2236
|
+
width: 1600,
|
|
2237
|
+
height: 900
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
var SURFACE_VIEWPORT_REFERENCE_SIZES = {
|
|
2241
|
+
controller: CONTROLLER_REFERENCE_SIZE,
|
|
2242
|
+
host: HOST_REFERENCE_SIZE
|
|
2243
|
+
};
|
|
958
2244
|
|
|
959
2245
|
// src/preview/layout.ts
|
|
2246
|
+
var getPreviewHostViewportSize = () => SURFACE_VIEWPORT_REFERENCE_SIZES.host.landscape;
|
|
960
2247
|
var PREVIEW_WORKSPACE_Z_INDEX = 2147483e3;
|
|
961
2248
|
var PREVIEW_WINDOW_TITLEBAR_HEIGHT = 38;
|
|
962
2249
|
var PREVIEW_WINDOW_RESIZE_EDGE_HIT_SIZE = 12;
|
|
@@ -1084,76 +2371,34 @@ var getResizedPreviewBounds = (bounds, handle, deltaX, deltaY) => {
|
|
|
1084
2371
|
};
|
|
1085
2372
|
|
|
1086
2373
|
// src/preview/manager.ts
|
|
1087
|
-
var
|
|
1088
|
-
|
|
1089
|
-
// src/utils/ids.ts
|
|
1090
|
-
var alphabet = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
1091
|
-
var CONTROLLER_ID_RANDOM_LENGTH = 20;
|
|
1092
|
-
var fallbackControllerSequence = 0;
|
|
1093
|
-
var generateRandomAlphabetValue = (length) => {
|
|
1094
|
-
const values = new Uint32Array(length);
|
|
1095
|
-
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
1096
|
-
crypto.getRandomValues(values);
|
|
1097
|
-
return Array.from(
|
|
1098
|
-
values,
|
|
1099
|
-
(value) => alphabet[value % alphabet.length]
|
|
1100
|
-
).join("");
|
|
1101
|
-
}
|
|
1102
|
-
return Array.from(
|
|
1103
|
-
{ length },
|
|
1104
|
-
() => alphabet[Math.floor(Math.random() * alphabet.length)]
|
|
1105
|
-
).join("");
|
|
1106
|
-
};
|
|
1107
|
-
var generateControllerId = () => {
|
|
1108
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
1109
|
-
return `C${crypto.randomUUID().replaceAll("-", "")}`;
|
|
1110
|
-
}
|
|
1111
|
-
const sequence = fallbackControllerSequence++;
|
|
1112
|
-
return `C${Date.now().toString(36)}${sequence.toString(36)}${generateRandomAlphabetValue(
|
|
1113
|
-
CONTROLLER_ID_RANDOM_LENGTH
|
|
1114
|
-
)}`;
|
|
1115
|
-
};
|
|
2374
|
+
var import_react7 = require("react");
|
|
1116
2375
|
|
|
1117
|
-
// src/preview/
|
|
1118
|
-
var
|
|
1119
|
-
var
|
|
1120
|
-
var
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
};
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
return null;
|
|
1144
|
-
}
|
|
1145
|
-
return normalizePreviewDeviceId(
|
|
1146
|
-
params.get(AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM)
|
|
1147
|
-
);
|
|
1148
|
-
};
|
|
1149
|
-
var readPreviewControllerDeviceIdFromLocation = () => {
|
|
1150
|
-
if (typeof window === "undefined") {
|
|
1151
|
-
return null;
|
|
1152
|
-
}
|
|
1153
|
-
return readPreviewControllerDeviceIdFromSearchParams(
|
|
1154
|
-
new URLSearchParams(window.location.search)
|
|
1155
|
-
);
|
|
1156
|
-
};
|
|
2376
|
+
// src/preview/messages.ts
|
|
2377
|
+
var AIR_JAM_PREVIEW_CLOSE_REQUEST = "airjam.preview.close.request";
|
|
2378
|
+
var AIR_JAM_PREVIEW_CLOSE_RESULT = "airjam.preview.close.result";
|
|
2379
|
+
var AIR_JAM_PREVIEW_SEAT = "airjam.preview.seat";
|
|
2380
|
+
var isPreviewSeatMessage = (value) => typeof value === "object" && value !== null && value.type === AIR_JAM_PREVIEW_SEAT && typeof value.deviceId === "string" && (typeof value.seat === "string" || value.seat === null);
|
|
2381
|
+
var isPreviewCloseResultMessage = (value) => typeof value === "object" && value !== null && value.type === AIR_JAM_PREVIEW_CLOSE_RESULT && typeof value.ok === "boolean";
|
|
2382
|
+
async function requestPreviewControllerClose(iframe, sessionUrl) {
|
|
2383
|
+
const frameWindow = iframe?.contentWindow;
|
|
2384
|
+
if (!frameWindow) return false;
|
|
2385
|
+
const origin = new URL(sessionUrl).origin;
|
|
2386
|
+
return new Promise((resolve) => {
|
|
2387
|
+
const finish = (closed) => {
|
|
2388
|
+
window.clearTimeout(timeout);
|
|
2389
|
+
window.removeEventListener("message", onMessage);
|
|
2390
|
+
resolve(closed);
|
|
2391
|
+
};
|
|
2392
|
+
const onMessage = (event) => {
|
|
2393
|
+
if (event.source !== frameWindow || event.origin !== origin || !isPreviewCloseResultMessage(event.data))
|
|
2394
|
+
return;
|
|
2395
|
+
finish(event.data.ok);
|
|
2396
|
+
};
|
|
2397
|
+
const timeout = window.setTimeout(() => finish(false), 1e3);
|
|
2398
|
+
window.addEventListener("message", onMessage);
|
|
2399
|
+
frameWindow.postMessage({ type: AIR_JAM_PREVIEW_CLOSE_REQUEST }, origin);
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
1157
2402
|
|
|
1158
2403
|
// src/preview/url.ts
|
|
1159
2404
|
var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
@@ -1164,10 +2409,12 @@ var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
|
1164
2409
|
};
|
|
1165
2410
|
var buildPreviewControllerUrl = ({
|
|
1166
2411
|
joinUrl,
|
|
1167
|
-
controllerId,
|
|
1168
2412
|
previewDeviceId,
|
|
1169
2413
|
allowedOrigins,
|
|
1170
|
-
embedOrigin
|
|
2414
|
+
embedOrigin,
|
|
2415
|
+
parentOrigin,
|
|
2416
|
+
localSeat,
|
|
2417
|
+
capture
|
|
1171
2418
|
}) => {
|
|
1172
2419
|
const normalizedJoinUrl = normalizeRuntimeUrl(joinUrl);
|
|
1173
2420
|
if (!normalizedJoinUrl) {
|
|
@@ -1186,41 +2433,49 @@ var buildPreviewControllerUrl = ({
|
|
|
1186
2433
|
if (!normalizedEmbedOrigin) {
|
|
1187
2434
|
return null;
|
|
1188
2435
|
}
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
2436
|
+
const { pathname, search, hash } = new URL(normalizedJoinUrl);
|
|
2437
|
+
return new URL(
|
|
2438
|
+
`${pathname}${search}${hash}`,
|
|
2439
|
+
normalizedEmbedOrigin
|
|
2440
|
+
).toString();
|
|
1194
2441
|
})();
|
|
1195
2442
|
if (!previewBaseUrl) {
|
|
1196
2443
|
return null;
|
|
1197
2444
|
}
|
|
2445
|
+
const normalizedParentOrigin = parentOrigin ? getRuntimeUrlOrigin(parentOrigin) : null;
|
|
2446
|
+
if (parentOrigin && !normalizedParentOrigin) {
|
|
2447
|
+
return null;
|
|
2448
|
+
}
|
|
1198
2449
|
return appendRuntimeQueryParams(previewBaseUrl, {
|
|
1199
|
-
controllerId,
|
|
1200
2450
|
[AIR_JAM_PREVIEW_FLAG_QUERY_PARAM]: "1",
|
|
1201
|
-
[AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM]: previewDeviceId
|
|
2451
|
+
[AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM]: previewDeviceId,
|
|
2452
|
+
[AIR_JAM_PREVIEW_PARENT_QUERY_PARAM]: normalizedParentOrigin,
|
|
2453
|
+
[AIR_JAM_LOCAL_SEAT_QUERY_PARAM]: localSeat,
|
|
2454
|
+
[AIR_JAM_PREVIEW_CAPTURE_QUERY_PARAM]: capture ? "1" : null
|
|
1202
2455
|
});
|
|
1203
2456
|
};
|
|
1204
2457
|
var createPreviewControllerLaunch = ({
|
|
1205
2458
|
joinUrl,
|
|
1206
2459
|
allowedOrigins,
|
|
1207
|
-
embedOrigin
|
|
2460
|
+
embedOrigin,
|
|
2461
|
+
parentOrigin,
|
|
2462
|
+
localSeat,
|
|
2463
|
+
capture
|
|
1208
2464
|
}) => {
|
|
1209
|
-
const
|
|
2465
|
+
const deviceId = createPreviewControllerDeviceId();
|
|
1210
2466
|
const url = buildPreviewControllerUrl({
|
|
1211
2467
|
joinUrl,
|
|
1212
|
-
|
|
1213
|
-
previewDeviceId: identity.deviceId,
|
|
2468
|
+
previewDeviceId: deviceId,
|
|
1214
2469
|
allowedOrigins,
|
|
1215
|
-
embedOrigin
|
|
2470
|
+
embedOrigin,
|
|
2471
|
+
parentOrigin,
|
|
2472
|
+
localSeat,
|
|
2473
|
+
capture
|
|
1216
2474
|
});
|
|
1217
2475
|
if (!url) {
|
|
1218
2476
|
return null;
|
|
1219
2477
|
}
|
|
1220
|
-
return {
|
|
1221
|
-
...identity,
|
|
1222
|
-
url
|
|
1223
|
-
};
|
|
2478
|
+
return { deviceId, url };
|
|
1224
2479
|
};
|
|
1225
2480
|
|
|
1226
2481
|
// src/preview/manager.ts
|
|
@@ -1228,6 +2483,7 @@ var DEFAULT_VIEWPORT_WIDTH = 1440;
|
|
|
1228
2483
|
var DEFAULT_VIEWPORT_HEIGHT = 900;
|
|
1229
2484
|
var PREVIEW_WINDOW_MARGIN = 24;
|
|
1230
2485
|
var PREVIEW_WINDOW_CASCADE_OFFSET = 28;
|
|
2486
|
+
var PREVIEW_WINDOW_DOCK_GAP = 12;
|
|
1231
2487
|
var DEFAULT_PREVIEW_CONTROLLER_ORIENTATION = "portrait";
|
|
1232
2488
|
var getViewportSize = () => {
|
|
1233
2489
|
if (typeof window === "undefined") {
|
|
@@ -1334,27 +2590,55 @@ var clampBounds = (orientation, bounds, options = {}, currentBounds) => {
|
|
|
1334
2590
|
height
|
|
1335
2591
|
};
|
|
1336
2592
|
};
|
|
1337
|
-
var
|
|
2593
|
+
var overlap = (start, size, otherStart, otherSize) => Math.max(
|
|
2594
|
+
0,
|
|
2595
|
+
Math.min(start + size, otherStart + otherSize) - Math.max(start, otherStart)
|
|
2596
|
+
);
|
|
2597
|
+
var getInitialWindowBounds = (sessions, orientation, seat) => {
|
|
1338
2598
|
const viewport = getViewportSize();
|
|
1339
|
-
|
|
2599
|
+
if (!seat) {
|
|
2600
|
+
const bounds2 = getPreviewWindowBounds(
|
|
2601
|
+
orientation,
|
|
2602
|
+
DEFAULT_PREVIEW_CONTROLLER_SCALE
|
|
2603
|
+
);
|
|
2604
|
+
const offset = Math.min(sessions.length, 3) * PREVIEW_WINDOW_CASCADE_OFFSET;
|
|
2605
|
+
return {
|
|
2606
|
+
...bounds2,
|
|
2607
|
+
...clampPosition(
|
|
2608
|
+
orientation,
|
|
2609
|
+
(viewport.width - bounds2.width) / 2 + offset,
|
|
2610
|
+
(viewport.height - bounds2.height) / 2 + offset,
|
|
2611
|
+
bounds2.width,
|
|
2612
|
+
bounds2.height
|
|
2613
|
+
)
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
const bounds = getPreviewWindowBounds(
|
|
1340
2617
|
orientation,
|
|
1341
|
-
|
|
2618
|
+
PREVIEW_CONTROLLER_MIN_SCALE
|
|
1342
2619
|
);
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
2620
|
+
const dock = seat.dock ?? { right: viewport.width, top: viewport.height };
|
|
2621
|
+
const place = (index) => ({
|
|
2622
|
+
...bounds,
|
|
2623
|
+
...clampPosition(
|
|
2624
|
+
orientation,
|
|
2625
|
+
index % 2 === 0 ? dock.right - bounds.width : viewport.width - dock.right,
|
|
2626
|
+
dock.top - (bounds.height + PREVIEW_WINDOW_DOCK_GAP) * (Math.floor(index / 2) + 1),
|
|
2627
|
+
bounds.width,
|
|
2628
|
+
bounds.height
|
|
2629
|
+
)
|
|
2630
|
+
});
|
|
2631
|
+
const seatPhones = sessions.filter((session) => session.localSeat);
|
|
2632
|
+
const coveredArea = (candidate) => seatPhones.reduce(
|
|
2633
|
+
(area, phone) => area + overlap(candidate.x, candidate.width, phone.x, phone.width) * overlap(candidate.y, candidate.height, phone.y, phone.height),
|
|
2634
|
+
0
|
|
2635
|
+
);
|
|
2636
|
+
return Array.from(
|
|
2637
|
+
{ length: seatPhones.length + 1 },
|
|
2638
|
+
(_, index) => place(index)
|
|
2639
|
+
).reduce(
|
|
2640
|
+
(best, candidate) => coveredArea(candidate) < coveredArea(best) ? candidate : best
|
|
1353
2641
|
);
|
|
1354
|
-
return {
|
|
1355
|
-
x: anchored.x,
|
|
1356
|
-
y: anchored.y
|
|
1357
|
-
};
|
|
1358
2642
|
};
|
|
1359
2643
|
var getNextTopSessionId = (sessions) => sessions.filter((session) => !session.minimized).sort((left, right) => right.zIndex - left.zIndex)[0]?.id ?? null;
|
|
1360
2644
|
var activateSession = (sessions, id, nextZIndex) => sessions.map(
|
|
@@ -1373,21 +2657,55 @@ var normalizeActiveSession = (sessions) => {
|
|
|
1373
2657
|
}));
|
|
1374
2658
|
};
|
|
1375
2659
|
var mapSessionsAndNormalizeActive = (sessions, mapSession) => normalizeActiveSession(sessions.map(mapSession));
|
|
2660
|
+
var orientSession = (session, nextOrientation) => {
|
|
2661
|
+
const centerX = session.x + session.width / 2;
|
|
2662
|
+
const centerY = session.y + session.height / 2;
|
|
2663
|
+
const nextWindowBounds = getPreviewWindowBounds(
|
|
2664
|
+
nextOrientation,
|
|
2665
|
+
session.displayScale
|
|
2666
|
+
);
|
|
2667
|
+
const nextBounds = clampBounds(
|
|
2668
|
+
nextOrientation,
|
|
2669
|
+
{
|
|
2670
|
+
x: centerX - nextWindowBounds.width / 2,
|
|
2671
|
+
y: centerY - nextWindowBounds.height / 2,
|
|
2672
|
+
width: nextWindowBounds.width,
|
|
2673
|
+
height: nextWindowBounds.height
|
|
2674
|
+
},
|
|
2675
|
+
{}
|
|
2676
|
+
);
|
|
2677
|
+
const clampedWindowBounds = getPreviewWindowBounds(
|
|
2678
|
+
nextOrientation,
|
|
2679
|
+
getPreviewControllerScaleForBounds(nextOrientation, nextBounds)
|
|
2680
|
+
);
|
|
2681
|
+
return {
|
|
2682
|
+
...session,
|
|
2683
|
+
orientation: nextOrientation,
|
|
2684
|
+
x: nextBounds.x,
|
|
2685
|
+
y: nextBounds.y,
|
|
2686
|
+
width: clampedWindowBounds.width,
|
|
2687
|
+
height: clampedWindowBounds.height,
|
|
2688
|
+
viewportWidth: clampedWindowBounds.viewportWidth,
|
|
2689
|
+
viewportHeight: clampedWindowBounds.viewportHeight,
|
|
2690
|
+
displayScale: clampedWindowBounds.displayScale
|
|
2691
|
+
};
|
|
2692
|
+
};
|
|
1376
2693
|
var usePreviewControllerManager = ({
|
|
1377
2694
|
joinUrl,
|
|
1378
2695
|
enabled = true,
|
|
1379
2696
|
maxControllers = 2,
|
|
1380
2697
|
allowedOrigins,
|
|
1381
|
-
embedOrigin
|
|
2698
|
+
embedOrigin,
|
|
2699
|
+
fixedControllerOrientation = null
|
|
1382
2700
|
}) => {
|
|
1383
|
-
const [sessions, setSessions] = (0,
|
|
1384
|
-
const nextSessionIdRef = (0,
|
|
1385
|
-
const nextOrdinalRef = (0,
|
|
1386
|
-
const nextZIndexRef = (0,
|
|
1387
|
-
const previousJoinRoomRef = (0,
|
|
2701
|
+
const [sessions, setSessions] = (0, import_react7.useState)([]);
|
|
2702
|
+
const nextSessionIdRef = (0, import_react7.useRef)(1);
|
|
2703
|
+
const nextOrdinalRef = (0, import_react7.useRef)(1);
|
|
2704
|
+
const nextZIndexRef = (0, import_react7.useRef)(1);
|
|
2705
|
+
const previousJoinRoomRef = (0, import_react7.useRef)(
|
|
1388
2706
|
getJoinRoomIdentity(joinUrl)
|
|
1389
2707
|
);
|
|
1390
|
-
(0,
|
|
2708
|
+
(0, import_react7.useEffect)(() => {
|
|
1391
2709
|
const nextJoinRoom = getJoinRoomIdentity(joinUrl);
|
|
1392
2710
|
const previousJoinRoom = previousJoinRoomRef.current;
|
|
1393
2711
|
if (!enabled || previousJoinRoom !== null && nextJoinRoom !== null && previousJoinRoom !== nextJoinRoom) {
|
|
@@ -1399,71 +2717,83 @@ var usePreviewControllerManager = ({
|
|
|
1399
2717
|
previousJoinRoomRef.current = nextJoinRoom;
|
|
1400
2718
|
}, [enabled, joinUrl]);
|
|
1401
2719
|
const canSpawn = enabled && typeof joinUrl === "string" && joinUrl.trim().length > 0 && sessions.length < maxControllers;
|
|
1402
|
-
const spawnPreviewController = (0,
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
let nextSession = null;
|
|
1407
|
-
setSessions((current) => {
|
|
1408
|
-
if (current.length >= maxControllers) {
|
|
1409
|
-
return current;
|
|
2720
|
+
const spawnPreviewController = (0, import_react7.useCallback)(
|
|
2721
|
+
(options) => {
|
|
2722
|
+
if (!enabled || !joinUrl) {
|
|
2723
|
+
return null;
|
|
1410
2724
|
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
2725
|
+
let nextSession = null;
|
|
2726
|
+
setSessions((current) => {
|
|
2727
|
+
if (current.length >= maxControllers) {
|
|
2728
|
+
return current;
|
|
2729
|
+
}
|
|
2730
|
+
const launch = createPreviewControllerLaunch({
|
|
2731
|
+
joinUrl,
|
|
2732
|
+
allowedOrigins,
|
|
2733
|
+
embedOrigin,
|
|
2734
|
+
localSeat: options?.localSeat?.label
|
|
2735
|
+
});
|
|
2736
|
+
if (!launch) {
|
|
2737
|
+
return current;
|
|
2738
|
+
}
|
|
2739
|
+
const ordinal = nextOrdinalRef.current++;
|
|
2740
|
+
const zIndex = nextZIndexRef.current++;
|
|
2741
|
+
const sessionId = `preview_session_${nextSessionIdRef.current++}`;
|
|
2742
|
+
const orientation = fixedControllerOrientation ?? DEFAULT_PREVIEW_CONTROLLER_ORIENTATION;
|
|
2743
|
+
const bounds = getInitialWindowBounds(
|
|
2744
|
+
current,
|
|
2745
|
+
orientation,
|
|
2746
|
+
options?.localSeat ? { dock: options.dock } : null
|
|
2747
|
+
);
|
|
2748
|
+
nextSession = {
|
|
2749
|
+
id: sessionId,
|
|
2750
|
+
ordinal,
|
|
2751
|
+
label: options?.localSeat?.label ?? `Preview ${ordinal}`,
|
|
2752
|
+
localSeat: options?.localSeat ?? null,
|
|
2753
|
+
seat: null,
|
|
2754
|
+
deviceId: launch.deviceId,
|
|
2755
|
+
url: launch.url,
|
|
2756
|
+
surfaceState: "loading",
|
|
2757
|
+
orientation,
|
|
2758
|
+
minimized: false,
|
|
2759
|
+
active: true,
|
|
2760
|
+
x: bounds.x,
|
|
2761
|
+
y: bounds.y,
|
|
2762
|
+
width: bounds.width,
|
|
2763
|
+
height: bounds.height,
|
|
2764
|
+
viewportWidth: bounds.viewportWidth,
|
|
2765
|
+
viewportHeight: bounds.viewportHeight,
|
|
2766
|
+
displayScale: bounds.displayScale,
|
|
2767
|
+
zIndex
|
|
2768
|
+
};
|
|
2769
|
+
return [
|
|
2770
|
+
...current.map((session) => ({ ...session, active: false })),
|
|
2771
|
+
nextSession
|
|
2772
|
+
];
|
|
1415
2773
|
});
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
nextSession = {
|
|
1429
|
-
id: sessionId,
|
|
1430
|
-
ordinal,
|
|
1431
|
-
label: `Preview ${ordinal}`,
|
|
1432
|
-
controllerId: launch.controllerId,
|
|
1433
|
-
deviceId: launch.deviceId,
|
|
1434
|
-
url: launch.url,
|
|
1435
|
-
surfaceState: "loading",
|
|
1436
|
-
orientation,
|
|
1437
|
-
minimized: false,
|
|
1438
|
-
active: true,
|
|
1439
|
-
x: position.x,
|
|
1440
|
-
y: position.y,
|
|
1441
|
-
width: defaultBounds.width,
|
|
1442
|
-
height: defaultBounds.height,
|
|
1443
|
-
viewportWidth: defaultBounds.viewportWidth,
|
|
1444
|
-
viewportHeight: defaultBounds.viewportHeight,
|
|
1445
|
-
displayScale: defaultBounds.displayScale,
|
|
1446
|
-
zIndex
|
|
1447
|
-
};
|
|
1448
|
-
return [
|
|
1449
|
-
...current.map((session) => ({ ...session, active: false })),
|
|
1450
|
-
nextSession
|
|
1451
|
-
];
|
|
1452
|
-
});
|
|
1453
|
-
return nextSession;
|
|
1454
|
-
}, [allowedOrigins, embedOrigin, enabled, joinUrl, maxControllers]);
|
|
1455
|
-
const removePreviewController = (0, import_react6.useCallback)((id) => {
|
|
2774
|
+
return nextSession;
|
|
2775
|
+
},
|
|
2776
|
+
[
|
|
2777
|
+
allowedOrigins,
|
|
2778
|
+
embedOrigin,
|
|
2779
|
+
enabled,
|
|
2780
|
+
joinUrl,
|
|
2781
|
+
maxControllers,
|
|
2782
|
+
fixedControllerOrientation
|
|
2783
|
+
]
|
|
2784
|
+
);
|
|
2785
|
+
const removePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1456
2786
|
setSessions(
|
|
1457
2787
|
(current) => normalizeActiveSession(current.filter((session) => session.id !== id))
|
|
1458
2788
|
);
|
|
1459
2789
|
}, []);
|
|
1460
|
-
const clearPreviewControllers = (0,
|
|
2790
|
+
const clearPreviewControllers = (0, import_react7.useCallback)(() => {
|
|
1461
2791
|
setSessions([]);
|
|
1462
2792
|
nextSessionIdRef.current = 1;
|
|
1463
2793
|
nextOrdinalRef.current = 1;
|
|
1464
2794
|
nextZIndexRef.current = 1;
|
|
1465
2795
|
}, []);
|
|
1466
|
-
const minimizePreviewController = (0,
|
|
2796
|
+
const minimizePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1467
2797
|
setSessions(
|
|
1468
2798
|
(current) => normalizeActiveSession(
|
|
1469
2799
|
current.map(
|
|
@@ -1472,15 +2802,15 @@ var usePreviewControllerManager = ({
|
|
|
1472
2802
|
)
|
|
1473
2803
|
);
|
|
1474
2804
|
}, []);
|
|
1475
|
-
const focusPreviewController = (0,
|
|
2805
|
+
const focusPreviewController = (0, import_react7.useCallback)((id) => {
|
|
1476
2806
|
const nextZIndex = nextZIndexRef.current++;
|
|
1477
2807
|
setSessions((current) => activateSession(current, id, nextZIndex));
|
|
1478
2808
|
}, []);
|
|
1479
|
-
const restorePreviewController = (0,
|
|
2809
|
+
const restorePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1480
2810
|
const nextZIndex = nextZIndexRef.current++;
|
|
1481
2811
|
setSessions((current) => activateSession(current, id, nextZIndex));
|
|
1482
2812
|
}, []);
|
|
1483
|
-
const setPreviewControllerPosition = (0,
|
|
2813
|
+
const setPreviewControllerPosition = (0, import_react7.useCallback)(
|
|
1484
2814
|
(id, x, y) => {
|
|
1485
2815
|
setSessions(
|
|
1486
2816
|
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
@@ -1504,7 +2834,7 @@ var usePreviewControllerManager = ({
|
|
|
1504
2834
|
},
|
|
1505
2835
|
[]
|
|
1506
2836
|
);
|
|
1507
|
-
const setPreviewControllerBounds = (0,
|
|
2837
|
+
const setPreviewControllerBounds = (0, import_react7.useCallback)(
|
|
1508
2838
|
(id, bounds, options = {}) => {
|
|
1509
2839
|
setSessions(
|
|
1510
2840
|
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
@@ -1536,48 +2866,43 @@ var usePreviewControllerManager = ({
|
|
|
1536
2866
|
},
|
|
1537
2867
|
[]
|
|
1538
2868
|
);
|
|
1539
|
-
const rotatePreviewController = (0,
|
|
2869
|
+
const rotatePreviewController = (0, import_react7.useCallback)(
|
|
2870
|
+
(id) => {
|
|
2871
|
+
if (fixedControllerOrientation) return;
|
|
2872
|
+
setSessions(
|
|
2873
|
+
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
2874
|
+
if (session.id !== id) {
|
|
2875
|
+
return session;
|
|
2876
|
+
}
|
|
2877
|
+
const nextOrientation = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
2878
|
+
return orientSession(session, nextOrientation);
|
|
2879
|
+
})
|
|
2880
|
+
);
|
|
2881
|
+
},
|
|
2882
|
+
[fixedControllerOrientation]
|
|
2883
|
+
);
|
|
2884
|
+
(0, import_react7.useEffect)(() => {
|
|
2885
|
+
if (!fixedControllerOrientation) return;
|
|
1540
2886
|
setSessions(
|
|
1541
|
-
(current) =>
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
}
|
|
1545
|
-
const nextOrientation = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
1546
|
-
const centerX = session.x + session.width / 2;
|
|
1547
|
-
const centerY = session.y + session.height / 2;
|
|
1548
|
-
const nextWindowBounds = getPreviewWindowBounds(
|
|
1549
|
-
nextOrientation,
|
|
1550
|
-
session.displayScale
|
|
1551
|
-
);
|
|
1552
|
-
const nextBounds = clampBounds(
|
|
1553
|
-
nextOrientation,
|
|
1554
|
-
{
|
|
1555
|
-
x: centerX - nextWindowBounds.width / 2,
|
|
1556
|
-
y: centerY - nextWindowBounds.height / 2,
|
|
1557
|
-
width: nextWindowBounds.width,
|
|
1558
|
-
height: nextWindowBounds.height
|
|
1559
|
-
},
|
|
1560
|
-
{}
|
|
1561
|
-
);
|
|
1562
|
-
const clampedWindowBounds = getPreviewWindowBounds(
|
|
1563
|
-
nextOrientation,
|
|
1564
|
-
getPreviewControllerScaleForBounds(nextOrientation, nextBounds)
|
|
1565
|
-
);
|
|
1566
|
-
return {
|
|
1567
|
-
...session,
|
|
1568
|
-
orientation: nextOrientation,
|
|
1569
|
-
x: nextBounds.x,
|
|
1570
|
-
y: nextBounds.y,
|
|
1571
|
-
width: clampedWindowBounds.width,
|
|
1572
|
-
height: clampedWindowBounds.height,
|
|
1573
|
-
viewportWidth: clampedWindowBounds.viewportWidth,
|
|
1574
|
-
viewportHeight: clampedWindowBounds.viewportHeight,
|
|
1575
|
-
displayScale: clampedWindowBounds.displayScale
|
|
1576
|
-
};
|
|
1577
|
-
})
|
|
2887
|
+
(current) => current.map(
|
|
2888
|
+
(session) => session.orientation === fixedControllerOrientation ? session : orientSession(session, fixedControllerOrientation)
|
|
2889
|
+
)
|
|
1578
2890
|
);
|
|
2891
|
+
}, [fixedControllerOrientation]);
|
|
2892
|
+
(0, import_react7.useEffect)(() => {
|
|
2893
|
+
const onMessage = (event) => {
|
|
2894
|
+
if (!isPreviewSeatMessage(event.data)) return;
|
|
2895
|
+
const { deviceId, seat } = event.data;
|
|
2896
|
+
setSessions(
|
|
2897
|
+
(current) => current.map(
|
|
2898
|
+
(session) => session.deviceId === deviceId && new URL(session.url).origin === event.origin && session.seat !== seat ? { ...session, seat } : session
|
|
2899
|
+
)
|
|
2900
|
+
);
|
|
2901
|
+
};
|
|
2902
|
+
window.addEventListener("message", onMessage);
|
|
2903
|
+
return () => window.removeEventListener("message", onMessage);
|
|
1579
2904
|
}, []);
|
|
1580
|
-
const markPreviewControllerReady = (0,
|
|
2905
|
+
const markPreviewControllerReady = (0, import_react7.useCallback)((id) => {
|
|
1581
2906
|
setSessions(
|
|
1582
2907
|
(current) => mapSessionsAndNormalizeActive(
|
|
1583
2908
|
current,
|
|
@@ -1585,7 +2910,7 @@ var usePreviewControllerManager = ({
|
|
|
1585
2910
|
)
|
|
1586
2911
|
);
|
|
1587
2912
|
}, []);
|
|
1588
|
-
const markPreviewControllerFailed = (0,
|
|
2913
|
+
const markPreviewControllerFailed = (0, import_react7.useCallback)((id) => {
|
|
1589
2914
|
setSessions(
|
|
1590
2915
|
(current) => mapSessionsAndNormalizeActive(
|
|
1591
2916
|
current,
|
|
@@ -1612,12 +2937,12 @@ var usePreviewControllerManager = ({
|
|
|
1612
2937
|
|
|
1613
2938
|
// src/preview/window.tsx
|
|
1614
2939
|
var import_lucide_react = require("lucide-react");
|
|
1615
|
-
var
|
|
2940
|
+
var import_react8 = require("react");
|
|
1616
2941
|
|
|
1617
2942
|
// src/components/ui/slider.tsx
|
|
1618
2943
|
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"), 1);
|
|
1619
2944
|
var React = __toESM(require("react"), 1);
|
|
1620
|
-
var
|
|
2945
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1621
2946
|
function Slider({
|
|
1622
2947
|
className,
|
|
1623
2948
|
defaultValue,
|
|
@@ -1630,7 +2955,7 @@ function Slider({
|
|
|
1630
2955
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1631
2956
|
[value, defaultValue, min, max]
|
|
1632
2957
|
);
|
|
1633
|
-
return /* @__PURE__ */ (0,
|
|
2958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1634
2959
|
SliderPrimitive.Root,
|
|
1635
2960
|
{
|
|
1636
2961
|
"data-slot": "slider",
|
|
@@ -1644,14 +2969,14 @@ function Slider({
|
|
|
1644
2969
|
),
|
|
1645
2970
|
...props,
|
|
1646
2971
|
children: [
|
|
1647
|
-
/* @__PURE__ */ (0,
|
|
2972
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1648
2973
|
SliderPrimitive.Track,
|
|
1649
2974
|
{
|
|
1650
2975
|
"data-slot": "slider-track",
|
|
1651
2976
|
className: cn(
|
|
1652
2977
|
"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"
|
|
1653
2978
|
),
|
|
1654
|
-
children: /* @__PURE__ */ (0,
|
|
2979
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1655
2980
|
SliderPrimitive.Range,
|
|
1656
2981
|
{
|
|
1657
2982
|
"data-slot": "slider-range",
|
|
@@ -1662,7 +2987,7 @@ function Slider({
|
|
|
1662
2987
|
)
|
|
1663
2988
|
}
|
|
1664
2989
|
),
|
|
1665
|
-
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0,
|
|
2990
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1666
2991
|
SliderPrimitive.Thumb,
|
|
1667
2992
|
{
|
|
1668
2993
|
"data-slot": "slider-thumb",
|
|
@@ -1675,54 +3000,9 @@ function Slider({
|
|
|
1675
3000
|
);
|
|
1676
3001
|
}
|
|
1677
3002
|
|
|
1678
|
-
// src/preview/messages.ts
|
|
1679
|
-
var AIR_JAM_PREVIEW_CLOSE_REQUEST = "airjam.preview.close.request";
|
|
1680
|
-
var AIR_JAM_PREVIEW_CLOSE_RESULT = "airjam.preview.close.result";
|
|
1681
|
-
var isPreviewCloseResultMessage = (value) => typeof value === "object" && value !== null && value.type === AIR_JAM_PREVIEW_CLOSE_RESULT && typeof value.ok === "boolean";
|
|
1682
|
-
|
|
1683
3003
|
// src/preview/window.tsx
|
|
1684
|
-
var
|
|
3004
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1685
3005
|
var PREVIEW_WINDOW_SETTINGS_SHELF_HEIGHT = 52;
|
|
1686
|
-
var PREVIEW_CLOSE_TIMEOUT_MS = 1e3;
|
|
1687
|
-
var requestPreviewControllerClose = async (iframe, sessionUrl) => {
|
|
1688
|
-
const frameWindow = iframe?.contentWindow;
|
|
1689
|
-
if (!frameWindow) {
|
|
1690
|
-
return;
|
|
1691
|
-
}
|
|
1692
|
-
const targetOrigin = new URL(sessionUrl).origin;
|
|
1693
|
-
await new Promise((resolve) => {
|
|
1694
|
-
let settled = false;
|
|
1695
|
-
const timeout = window.setTimeout(() => {
|
|
1696
|
-
cleanup();
|
|
1697
|
-
resolve();
|
|
1698
|
-
}, PREVIEW_CLOSE_TIMEOUT_MS);
|
|
1699
|
-
const handleMessage = (event) => {
|
|
1700
|
-
if (event.source !== frameWindow || event.origin !== targetOrigin) {
|
|
1701
|
-
return;
|
|
1702
|
-
}
|
|
1703
|
-
if (!isPreviewCloseResultMessage(event.data)) {
|
|
1704
|
-
return;
|
|
1705
|
-
}
|
|
1706
|
-
cleanup();
|
|
1707
|
-
resolve();
|
|
1708
|
-
};
|
|
1709
|
-
const cleanup = () => {
|
|
1710
|
-
if (settled) {
|
|
1711
|
-
return;
|
|
1712
|
-
}
|
|
1713
|
-
settled = true;
|
|
1714
|
-
window.clearTimeout(timeout);
|
|
1715
|
-
window.removeEventListener("message", handleMessage);
|
|
1716
|
-
};
|
|
1717
|
-
window.addEventListener("message", handleMessage);
|
|
1718
|
-
frameWindow.postMessage(
|
|
1719
|
-
{
|
|
1720
|
-
type: AIR_JAM_PREVIEW_CLOSE_REQUEST
|
|
1721
|
-
},
|
|
1722
|
-
targetOrigin
|
|
1723
|
-
);
|
|
1724
|
-
});
|
|
1725
|
-
};
|
|
1726
3006
|
var previewControllerWindowStateLabel = {
|
|
1727
3007
|
loading: "Loading",
|
|
1728
3008
|
ready: "Ready",
|
|
@@ -1812,8 +3092,10 @@ var RESIZE_HANDLES = [
|
|
|
1812
3092
|
];
|
|
1813
3093
|
var PreviewControllerWindow = ({
|
|
1814
3094
|
session,
|
|
3095
|
+
frameRef,
|
|
1815
3096
|
activeOpacity,
|
|
1816
3097
|
highContrast = false,
|
|
3098
|
+
fixedControllerOrientation = null,
|
|
1817
3099
|
dragging = false,
|
|
1818
3100
|
onFocus,
|
|
1819
3101
|
onMinimize,
|
|
@@ -1832,9 +3114,9 @@ var PreviewControllerWindow = ({
|
|
|
1832
3114
|
onResizePointerCancel,
|
|
1833
3115
|
resizing = false
|
|
1834
3116
|
}) => {
|
|
1835
|
-
const [windowHovered, setWindowHovered] = (0,
|
|
1836
|
-
const [settingsOpen, setSettingsOpen] = (0,
|
|
1837
|
-
const iframeRef = (0,
|
|
3117
|
+
const [windowHovered, setWindowHovered] = (0, import_react8.useState)(false);
|
|
3118
|
+
const [settingsOpen, setSettingsOpen] = (0, import_react8.useState)(false);
|
|
3119
|
+
const iframeRef = (0, import_react8.useRef)(null);
|
|
1838
3120
|
const isVisible = dragging || resizing || windowHovered;
|
|
1839
3121
|
const windowOpacity = isVisible ? activeOpacity : Math.min(activeOpacity, 0.62);
|
|
1840
3122
|
const settingsShelfHeight = settingsOpen && onActiveOpacityChange ? PREVIEW_WINDOW_SETTINGS_SHELF_HEIGHT : 0;
|
|
@@ -1844,10 +3126,11 @@ var PreviewControllerWindow = ({
|
|
|
1844
3126
|
);
|
|
1845
3127
|
const nextOrientationLabel = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
1846
3128
|
const statusToneClassName = session.surfaceState === "failed" ? "bg-amber-300" : session.surfaceState === "ready" ? "bg-emerald-300" : "bg-white/45";
|
|
1847
|
-
return /* @__PURE__ */ (0,
|
|
3129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1848
3130
|
"div",
|
|
1849
3131
|
{
|
|
1850
3132
|
className: "absolute",
|
|
3133
|
+
hidden: session.minimized,
|
|
1851
3134
|
style: {
|
|
1852
3135
|
left: session.x,
|
|
1853
3136
|
top: session.y,
|
|
@@ -1859,7 +3142,7 @@ var PreviewControllerWindow = ({
|
|
|
1859
3142
|
onPointerEnter: () => setWindowHovered(true),
|
|
1860
3143
|
onPointerLeave: () => setWindowHovered(false),
|
|
1861
3144
|
children: [
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
3145
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1863
3146
|
"section",
|
|
1864
3147
|
{
|
|
1865
3148
|
className: cn(
|
|
@@ -1875,7 +3158,7 @@ var PreviewControllerWindow = ({
|
|
|
1875
3158
|
pointerEvents: "auto"
|
|
1876
3159
|
},
|
|
1877
3160
|
children: [
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1879
3162
|
"div",
|
|
1880
3163
|
{
|
|
1881
3164
|
className: "flex h-9 items-center gap-2 border-b border-white/8 px-2.5",
|
|
@@ -1889,10 +3172,10 @@ var PreviewControllerWindow = ({
|
|
|
1889
3172
|
onPointerUp: onTitlePointerUp,
|
|
1890
3173
|
onPointerCancel: onTitlePointerCancel,
|
|
1891
3174
|
children: [
|
|
1892
|
-
/* @__PURE__ */ (0,
|
|
1893
|
-
/* @__PURE__ */ (0,
|
|
1894
|
-
/* @__PURE__ */ (0,
|
|
1895
|
-
/* @__PURE__ */ (0,
|
|
3175
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
3176
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex h-5 w-5 items-center justify-center rounded-full border border-white/10 bg-white/[0.05]", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.MonitorSmartphone, { className: "h-3 w-3 text-white/80" }) }),
|
|
3177
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "truncate text-[12px] leading-none font-semibold text-white/92", children: session.label }) }),
|
|
3178
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1896
3179
|
"span",
|
|
1897
3180
|
{
|
|
1898
3181
|
className: cn(
|
|
@@ -1903,8 +3186,8 @@ var PreviewControllerWindow = ({
|
|
|
1903
3186
|
}
|
|
1904
3187
|
)
|
|
1905
3188
|
] }),
|
|
1906
|
-
/* @__PURE__ */ (0,
|
|
1907
|
-
/* @__PURE__ */ (0,
|
|
3189
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3190
|
+
!fixedControllerOrientation && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1908
3191
|
Button,
|
|
1909
3192
|
{
|
|
1910
3193
|
type: "button",
|
|
@@ -1916,10 +3199,10 @@ var PreviewControllerWindow = ({
|
|
|
1916
3199
|
onClick: onRotate,
|
|
1917
3200
|
"aria-label": `Rotate ${session.label} to ${nextOrientationLabel}`,
|
|
1918
3201
|
title: `Rotate to ${nextOrientationLabel}`,
|
|
1919
|
-
children: /* @__PURE__ */ (0,
|
|
3202
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.TabletSmartphone, { className: "h-3.5 w-3.5" })
|
|
1920
3203
|
}
|
|
1921
3204
|
),
|
|
1922
|
-
onActiveOpacityChange ? /* @__PURE__ */ (0,
|
|
3205
|
+
onActiveOpacityChange ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1923
3206
|
Button,
|
|
1924
3207
|
{
|
|
1925
3208
|
type: "button",
|
|
@@ -1934,10 +3217,10 @@ var PreviewControllerWindow = ({
|
|
|
1934
3217
|
onClick: () => setSettingsOpen((current) => !current),
|
|
1935
3218
|
"aria-label": `Adjust ${session.label} opacity`,
|
|
1936
3219
|
title: `Adjust opacity (${Math.round(activeOpacity * 100)}%)`,
|
|
1937
|
-
children: /* @__PURE__ */ (0,
|
|
3220
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.SlidersHorizontal, { className: "h-3.5 w-3.5" })
|
|
1938
3221
|
}
|
|
1939
3222
|
) : null,
|
|
1940
|
-
/* @__PURE__ */ (0,
|
|
3223
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1941
3224
|
Button,
|
|
1942
3225
|
{
|
|
1943
3226
|
type: "button",
|
|
@@ -1949,10 +3232,10 @@ var PreviewControllerWindow = ({
|
|
|
1949
3232
|
onClick: onMinimize,
|
|
1950
3233
|
"aria-label": `Minimize ${session.label}`,
|
|
1951
3234
|
title: "Minimize controller",
|
|
1952
|
-
children: /* @__PURE__ */ (0,
|
|
3235
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Minus, { className: "h-3.5 w-3.5" })
|
|
1953
3236
|
}
|
|
1954
3237
|
),
|
|
1955
|
-
/* @__PURE__ */ (0,
|
|
3238
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1956
3239
|
Button,
|
|
1957
3240
|
{
|
|
1958
3241
|
type: "button",
|
|
@@ -1969,27 +3252,27 @@ var PreviewControllerWindow = ({
|
|
|
1969
3252
|
},
|
|
1970
3253
|
"aria-label": `Close ${session.label}`,
|
|
1971
3254
|
title: "Close controller",
|
|
1972
|
-
children: /* @__PURE__ */ (0,
|
|
3255
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.X, { className: "h-3.5 w-3.5" })
|
|
1973
3256
|
}
|
|
1974
3257
|
)
|
|
1975
3258
|
] })
|
|
1976
3259
|
]
|
|
1977
3260
|
}
|
|
1978
3261
|
),
|
|
1979
|
-
settingsOpen && onActiveOpacityChange ? /* @__PURE__ */ (0,
|
|
3262
|
+
settingsOpen && onActiveOpacityChange ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1980
3263
|
"div",
|
|
1981
3264
|
{
|
|
1982
3265
|
className: "border-b border-white/8 bg-black/72 px-3 py-2.5 backdrop-blur-sm",
|
|
1983
3266
|
onPointerDown: (event) => event.stopPropagation(),
|
|
1984
3267
|
children: [
|
|
1985
|
-
/* @__PURE__ */ (0,
|
|
1986
|
-
/* @__PURE__ */ (0,
|
|
1987
|
-
/* @__PURE__ */ (0,
|
|
3268
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mb-2 flex items-center justify-between gap-3", children: [
|
|
3269
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-[11px] font-semibold tracking-[0.16em] text-slate-300 uppercase", children: "Opacity" }),
|
|
3270
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "font-mono text-[11px] text-slate-400", children: [
|
|
1988
3271
|
Math.round(activeOpacity * 100),
|
|
1989
3272
|
"%"
|
|
1990
3273
|
] })
|
|
1991
3274
|
] }),
|
|
1992
|
-
/* @__PURE__ */ (0,
|
|
3275
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1993
3276
|
Slider,
|
|
1994
3277
|
{
|
|
1995
3278
|
value: [activeOpacity * 100],
|
|
@@ -2003,7 +3286,7 @@ var PreviewControllerWindow = ({
|
|
|
2003
3286
|
]
|
|
2004
3287
|
}
|
|
2005
3288
|
) : null,
|
|
2006
|
-
/* @__PURE__ */ (0,
|
|
3289
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2007
3290
|
"div",
|
|
2008
3291
|
{
|
|
2009
3292
|
className: "relative",
|
|
@@ -2012,7 +3295,7 @@ var PreviewControllerWindow = ({
|
|
|
2012
3295
|
onFocus();
|
|
2013
3296
|
}
|
|
2014
3297
|
},
|
|
2015
|
-
children: /* @__PURE__ */ (0,
|
|
3298
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2016
3299
|
"div",
|
|
2017
3300
|
{
|
|
2018
3301
|
className: "relative overflow-hidden bg-black",
|
|
@@ -2021,7 +3304,7 @@ var PreviewControllerWindow = ({
|
|
|
2021
3304
|
height: contentHeight
|
|
2022
3305
|
},
|
|
2023
3306
|
children: [
|
|
2024
|
-
/* @__PURE__ */ (0,
|
|
3307
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2025
3308
|
"div",
|
|
2026
3309
|
{
|
|
2027
3310
|
className: "origin-top-left",
|
|
@@ -2031,10 +3314,13 @@ var PreviewControllerWindow = ({
|
|
|
2031
3314
|
transform: `scale(${session.displayScale})`,
|
|
2032
3315
|
transformOrigin: "top left"
|
|
2033
3316
|
},
|
|
2034
|
-
children: /* @__PURE__ */ (0,
|
|
3317
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2035
3318
|
"iframe",
|
|
2036
3319
|
{
|
|
2037
|
-
ref:
|
|
3320
|
+
ref: (frame) => {
|
|
3321
|
+
iframeRef.current = frame;
|
|
3322
|
+
frameRef?.(frame);
|
|
3323
|
+
},
|
|
2038
3324
|
src: session.url,
|
|
2039
3325
|
title: `${session.label} controller`,
|
|
2040
3326
|
"data-testid": `preview-controller-frame-${session.ordinal}`,
|
|
@@ -2051,14 +3337,14 @@ var PreviewControllerWindow = ({
|
|
|
2051
3337
|
)
|
|
2052
3338
|
}
|
|
2053
3339
|
),
|
|
2054
|
-
session.surfaceState === "loading" ? /* @__PURE__ */ (0,
|
|
2055
|
-
/* @__PURE__ */ (0,
|
|
3340
|
+
session.surfaceState === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center bg-black/34 backdrop-blur-[1px]", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2 rounded-full border border-white/10 bg-black/70 px-3 py-1.5 text-[11px] text-slate-200 shadow-lg", children: [
|
|
3341
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Loader2, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
2056
3342
|
"Loading"
|
|
2057
3343
|
] }) }) : null,
|
|
2058
|
-
session.surfaceState === "failed" ? /* @__PURE__ */ (0,
|
|
2059
|
-
/* @__PURE__ */ (0,
|
|
2060
|
-
/* @__PURE__ */ (0,
|
|
2061
|
-
/* @__PURE__ */ (0,
|
|
3344
|
+
session.surfaceState === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "absolute inset-0 flex items-center justify-center bg-black/84 px-5 text-center backdrop-blur-[2px]", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "max-w-[14rem] space-y-2.5", children: [
|
|
3345
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mx-auto flex h-8 w-8 items-center justify-center rounded-full border border-amber-400/22 bg-amber-400/8 text-amber-200", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.TriangleAlert, { className: "h-3.5 w-3.5" }) }),
|
|
3346
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-sm font-semibold text-white", children: "Controller did not load" }),
|
|
3347
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-[11px] leading-5 text-slate-300", children: "Close it and open a fresh controller once the route is ready again." })
|
|
2062
3348
|
] }) }) : null
|
|
2063
3349
|
]
|
|
2064
3350
|
}
|
|
@@ -2068,7 +3354,7 @@ var PreviewControllerWindow = ({
|
|
|
2068
3354
|
]
|
|
2069
3355
|
}
|
|
2070
3356
|
),
|
|
2071
|
-
RESIZE_HANDLES.map(({ handle, cursor, style }) => /* @__PURE__ */ (0,
|
|
3357
|
+
RESIZE_HANDLES.map(({ handle, cursor, style }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2072
3358
|
"div",
|
|
2073
3359
|
{
|
|
2074
3360
|
"data-testid": `preview-controller-resize-${handle}-${session.ordinal}`,
|
|
@@ -2092,8 +3378,127 @@ var PreviewControllerWindow = ({
|
|
|
2092
3378
|
);
|
|
2093
3379
|
};
|
|
2094
3380
|
|
|
3381
|
+
// src/preview/workspace-local-seats.ts
|
|
3382
|
+
var import_react9 = require("react");
|
|
3383
|
+
var useWorkspaceLocalSeats = ({
|
|
3384
|
+
enabled,
|
|
3385
|
+
sessions,
|
|
3386
|
+
canSpawn,
|
|
3387
|
+
spawn,
|
|
3388
|
+
remove,
|
|
3389
|
+
frames
|
|
3390
|
+
}) => {
|
|
3391
|
+
const keyboardListener = (0, import_react9.useRef)(void 0);
|
|
3392
|
+
const requests = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
|
|
3393
|
+
const closings = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
|
|
3394
|
+
const [requested, setRequested] = (0, import_react9.useState)(0);
|
|
3395
|
+
const provider = (0, import_react9.useMemo)(
|
|
3396
|
+
() => enabled ? {
|
|
3397
|
+
subscribeKeyboard: (receive) => {
|
|
3398
|
+
keyboardListener.current = receive;
|
|
3399
|
+
return () => {
|
|
3400
|
+
keyboardListener.current = void 0;
|
|
3401
|
+
};
|
|
3402
|
+
},
|
|
3403
|
+
open: (seat) => new Promise((resolve) => {
|
|
3404
|
+
requests.current.set(seat.key, {
|
|
3405
|
+
seat,
|
|
3406
|
+
resolve,
|
|
3407
|
+
spawned: false
|
|
3408
|
+
});
|
|
3409
|
+
setRequested((count2) => count2 + 1);
|
|
3410
|
+
})
|
|
3411
|
+
} : null,
|
|
3412
|
+
[enabled]
|
|
3413
|
+
);
|
|
3414
|
+
const ready = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
|
|
3415
|
+
const openSeat = (0, import_react9.useCallback)(
|
|
3416
|
+
(key, request, session) => {
|
|
3417
|
+
const origin = new URL(session.url).origin;
|
|
3418
|
+
requests.current.delete(key);
|
|
3419
|
+
closings.current.get(session.id)?.();
|
|
3420
|
+
request.resolve({
|
|
3421
|
+
send: (operation) => {
|
|
3422
|
+
const target = frames.get(session.id)?.contentWindow;
|
|
3423
|
+
if (target) sendLocalSeatOperation(target, origin, operation);
|
|
3424
|
+
},
|
|
3425
|
+
closed: new Promise((close) => closings.current.set(session.id, close))
|
|
3426
|
+
});
|
|
3427
|
+
},
|
|
3428
|
+
[frames]
|
|
3429
|
+
);
|
|
3430
|
+
(0, import_react9.useEffect)(() => {
|
|
3431
|
+
let spawned = false;
|
|
3432
|
+
for (const [key, request] of requests.current) {
|
|
3433
|
+
const session = sessions.find(
|
|
3434
|
+
(candidate) => candidate.localSeat?.key === key
|
|
3435
|
+
);
|
|
3436
|
+
if (session) {
|
|
3437
|
+
if (ready.current.has(session.id)) openSeat(key, request, session);
|
|
3438
|
+
continue;
|
|
3439
|
+
}
|
|
3440
|
+
if (request.spawned || !canSpawn) {
|
|
3441
|
+
requests.current.delete(key);
|
|
3442
|
+
request.resolve(null);
|
|
3443
|
+
continue;
|
|
3444
|
+
}
|
|
3445
|
+
requests.current.set(key, { ...request, spawned: true });
|
|
3446
|
+
spawned = true;
|
|
3447
|
+
spawn({ localSeat: request.seat });
|
|
3448
|
+
}
|
|
3449
|
+
if (spawned) setRequested((count2) => count2 + 1);
|
|
3450
|
+
for (const sessionId of ready.current)
|
|
3451
|
+
if (!sessions.some((session) => session.id === sessionId))
|
|
3452
|
+
ready.current.delete(sessionId);
|
|
3453
|
+
for (const [sessionId, close] of closings.current)
|
|
3454
|
+
if (!sessions.some((session) => session.id === sessionId)) {
|
|
3455
|
+
closings.current.delete(sessionId);
|
|
3456
|
+
close();
|
|
3457
|
+
}
|
|
3458
|
+
}, [requested, sessions, canSpawn, spawn, openSeat]);
|
|
3459
|
+
const leaving = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
|
|
3460
|
+
(0, import_react9.useEffect)(() => {
|
|
3461
|
+
if (enabled) return;
|
|
3462
|
+
for (const session of sessions) {
|
|
3463
|
+
if (!session.localSeat || leaving.current.has(session.id)) continue;
|
|
3464
|
+
leaving.current.add(session.id);
|
|
3465
|
+
void requestPreviewControllerClose(
|
|
3466
|
+
frames.get(session.id) ?? null,
|
|
3467
|
+
session.url
|
|
3468
|
+
).finally(() => {
|
|
3469
|
+
leaving.current.delete(session.id);
|
|
3470
|
+
remove(session.id);
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
}, [enabled, sessions, frames, remove]);
|
|
3474
|
+
(0, import_react9.useEffect)(() => {
|
|
3475
|
+
const onMessage = (event) => {
|
|
3476
|
+
if (!provider) return;
|
|
3477
|
+
const session = sessions.find(
|
|
3478
|
+
(candidate) => candidate.localSeat && frames.get(candidate.id)?.contentWindow === event.source
|
|
3479
|
+
);
|
|
3480
|
+
if (!session?.localSeat || event.origin !== new URL(session.url).origin)
|
|
3481
|
+
return;
|
|
3482
|
+
const keyboard = localSeatKeyboardSchema.safeParse(event.data);
|
|
3483
|
+
if (keyboard.success) {
|
|
3484
|
+
keyboardListener.current?.(keyboard.data);
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
if (!isLocalSeatReadyMessage(event.data)) return;
|
|
3488
|
+
ready.current.add(session.id);
|
|
3489
|
+
const key = session.localSeat.key;
|
|
3490
|
+
const request = requests.current.get(key);
|
|
3491
|
+
if (request) openSeat(key, request, session);
|
|
3492
|
+
};
|
|
3493
|
+
window.addEventListener("message", onMessage);
|
|
3494
|
+
return () => window.removeEventListener("message", onMessage);
|
|
3495
|
+
}, [sessions, frames, openSeat, provider]);
|
|
3496
|
+
return provider;
|
|
3497
|
+
};
|
|
3498
|
+
|
|
2095
3499
|
// src/preview/workspace.tsx
|
|
2096
|
-
var
|
|
3500
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3501
|
+
var rosterSourceOf = (kind) => kind === "agent" ? "virtual" : kind;
|
|
2097
3502
|
var getControllerSourceLabel = (source) => {
|
|
2098
3503
|
if (source === "virtual") {
|
|
2099
3504
|
return "Agent";
|
|
@@ -2111,8 +3516,9 @@ var getControllerSourceIcon = (source) => {
|
|
|
2111
3516
|
};
|
|
2112
3517
|
var PreviewControllerWorkspace = ({
|
|
2113
3518
|
joinUrl,
|
|
3519
|
+
fixedControllerOrientation: requestedFixedOrientation,
|
|
2114
3520
|
embedOrigin,
|
|
2115
|
-
|
|
3521
|
+
players = [],
|
|
2116
3522
|
onRemoveController,
|
|
2117
3523
|
onResetRoom,
|
|
2118
3524
|
enabled = false,
|
|
@@ -2124,15 +3530,20 @@ var PreviewControllerWorkspace = ({
|
|
|
2124
3530
|
launcherLabel = "Controllers",
|
|
2125
3531
|
launcherVariant = "full",
|
|
2126
3532
|
showLauncherWhenIdle = true,
|
|
2127
|
-
waitingLabel = "Waiting for room"
|
|
3533
|
+
waitingLabel = "Waiting for room",
|
|
3534
|
+
localPlayers = true,
|
|
3535
|
+
localPlayersGame = null
|
|
2128
3536
|
}) => {
|
|
2129
|
-
const
|
|
2130
|
-
const
|
|
2131
|
-
const [
|
|
2132
|
-
const [
|
|
2133
|
-
const [
|
|
2134
|
-
const [
|
|
2135
|
-
const
|
|
3537
|
+
const declaredOrientation = (0, import_react10.useContext)(fixedControllerOrientationContext);
|
|
3538
|
+
const fixedOrientation = requestedFixedOrientation ?? declaredOrientation ?? null;
|
|
3539
|
+
const [mounted, setMounted] = (0, import_react10.useState)(false);
|
|
3540
|
+
const [dragState, setDragState] = (0, import_react10.useState)(null);
|
|
3541
|
+
const [resizeState, setResizeState] = (0, import_react10.useState)(null);
|
|
3542
|
+
const [launcherOpen, setLauncherOpen] = (0, import_react10.useState)(false);
|
|
3543
|
+
const [removingControllerId, setRemovingControllerId] = (0, import_react10.useState)(null);
|
|
3544
|
+
const [resettingRoom, setResettingRoom] = (0, import_react10.useState)(false);
|
|
3545
|
+
const dockRef = (0, import_react10.useRef)(null);
|
|
3546
|
+
const dockRowRef = (0, import_react10.useRef)(null);
|
|
2136
3547
|
const resolvedEmbedOrigin = embedOrigin ?? (typeof window !== "undefined" ? window.location.origin : null);
|
|
2137
3548
|
const {
|
|
2138
3549
|
sessions,
|
|
@@ -2149,22 +3560,41 @@ var PreviewControllerWorkspace = ({
|
|
|
2149
3560
|
markPreviewControllerReady,
|
|
2150
3561
|
markPreviewControllerFailed
|
|
2151
3562
|
} = usePreviewControllerManager({
|
|
3563
|
+
fixedControllerOrientation: fixedOrientation,
|
|
2152
3564
|
joinUrl,
|
|
2153
3565
|
embedOrigin: resolvedEmbedOrigin,
|
|
2154
3566
|
enabled,
|
|
2155
3567
|
maxControllers
|
|
2156
3568
|
});
|
|
3569
|
+
const [frames] = (0, import_react10.useState)(() => /* @__PURE__ */ new Map());
|
|
3570
|
+
const spawnSeatPhone = (0, import_react10.useCallback)(
|
|
3571
|
+
(options) => spawnPreviewController({
|
|
3572
|
+
...options,
|
|
3573
|
+
dock: dockRowRef.current?.getBoundingClientRect()
|
|
3574
|
+
}),
|
|
3575
|
+
[spawnPreviewController]
|
|
3576
|
+
);
|
|
3577
|
+
const localSeats = useWorkspaceLocalSeats({
|
|
3578
|
+
enabled: enabled && localPlayers,
|
|
3579
|
+
sessions,
|
|
3580
|
+
canSpawn,
|
|
3581
|
+
spawn: spawnSeatPhone,
|
|
3582
|
+
remove: removePreviewController,
|
|
3583
|
+
frames
|
|
3584
|
+
});
|
|
3585
|
+
useProvideLocalSeats(localPlayersGame ? null : localSeats);
|
|
3586
|
+
useServeLocalSeats(localPlayersGame, localSeats);
|
|
2157
3587
|
const platformSettings = useResolvedPlatformSettingsSnapshot();
|
|
2158
3588
|
const activeOpacity = platformSettings.previewControllers.activeOpacity;
|
|
2159
|
-
const sortedSessions = (0,
|
|
3589
|
+
const sortedSessions = (0, import_react10.useMemo)(
|
|
2160
3590
|
() => [...sessions].sort((left, right) => left.ordinal - right.ordinal),
|
|
2161
3591
|
[sessions]
|
|
2162
3592
|
);
|
|
2163
|
-
(0,
|
|
3593
|
+
(0, import_react10.useEffect)(() => {
|
|
2164
3594
|
setMounted(true);
|
|
2165
3595
|
return () => setMounted(false);
|
|
2166
3596
|
}, []);
|
|
2167
|
-
(0,
|
|
3597
|
+
(0, import_react10.useEffect)(() => {
|
|
2168
3598
|
if (!launcherOpen || typeof document === "undefined") {
|
|
2169
3599
|
return;
|
|
2170
3600
|
}
|
|
@@ -2190,44 +3620,40 @@ var PreviewControllerWorkspace = ({
|
|
|
2190
3620
|
document.removeEventListener("keydown", handleKeyDown);
|
|
2191
3621
|
};
|
|
2192
3622
|
}, [launcherOpen]);
|
|
2193
|
-
const minimizedSessions = (0,
|
|
3623
|
+
const minimizedSessions = (0, import_react10.useMemo)(
|
|
2194
3624
|
() => sessions.filter((session) => session.minimized).sort((left, right) => left.ordinal - right.ordinal),
|
|
2195
3625
|
[sessions]
|
|
2196
3626
|
);
|
|
2197
|
-
const openSessions = (0, import_react8.useMemo)(
|
|
2198
|
-
() => sessions.filter((session) => !session.minimized),
|
|
2199
|
-
[sessions]
|
|
2200
|
-
);
|
|
2201
3627
|
const launcherVisible = showLauncherWhenIdle || launcherOpen || sessions.length > 0;
|
|
2202
|
-
const sortedControllers = (0,
|
|
2203
|
-
() => [...
|
|
2204
|
-
|
|
2205
|
-
),
|
|
2206
|
-
[controllers]
|
|
3628
|
+
const sortedControllers = (0, import_react10.useMemo)(
|
|
3629
|
+
() => [...players].sort((left, right) => left.id.localeCompare(right.id)),
|
|
3630
|
+
[players]
|
|
2207
3631
|
);
|
|
2208
|
-
const controllerRoster = (0,
|
|
2209
|
-
const
|
|
2210
|
-
sortedSessions.
|
|
3632
|
+
const controllerRoster = (0, import_react10.useMemo)(() => {
|
|
3633
|
+
const sessionsBySeat = new Map(
|
|
3634
|
+
sortedSessions.flatMap(
|
|
3635
|
+
(session) => session.seat ? [[session.seat, session]] : []
|
|
3636
|
+
)
|
|
2211
3637
|
);
|
|
2212
3638
|
const controllerItems = sortedControllers.map((controller) => {
|
|
2213
|
-
const session =
|
|
3639
|
+
const session = sessionsBySeat.get(controller.id) ?? null;
|
|
2214
3640
|
return {
|
|
2215
|
-
id: controller.
|
|
2216
|
-
controllerId: controller.
|
|
2217
|
-
label: controller.
|
|
2218
|
-
source: controller.
|
|
3641
|
+
id: controller.id,
|
|
3642
|
+
controllerId: controller.id,
|
|
3643
|
+
label: controller.label,
|
|
3644
|
+
source: rosterSourceOf(controller.kind),
|
|
2219
3645
|
connected: controller.connected,
|
|
2220
|
-
resumable:
|
|
3646
|
+
resumable: !controller.connected,
|
|
2221
3647
|
session,
|
|
2222
3648
|
controller
|
|
2223
3649
|
};
|
|
2224
3650
|
});
|
|
2225
|
-
const
|
|
2226
|
-
sortedControllers.map((controller) => controller.
|
|
3651
|
+
const seatIds = new Set(
|
|
3652
|
+
sortedControllers.map((controller) => controller.id)
|
|
2227
3653
|
);
|
|
2228
|
-
const pendingPreviewItems = sortedSessions.filter((session) => !
|
|
3654
|
+
const pendingPreviewItems = sortedSessions.filter((session) => !session.seat || !seatIds.has(session.seat)).map((session) => ({
|
|
2229
3655
|
id: session.id,
|
|
2230
|
-
controllerId: session.
|
|
3656
|
+
controllerId: session.seat ?? session.id,
|
|
2231
3657
|
label: session.label,
|
|
2232
3658
|
source: "preview",
|
|
2233
3659
|
connected: session.surfaceState === "ready",
|
|
@@ -2251,16 +3677,21 @@ var PreviewControllerWorkspace = ({
|
|
|
2251
3677
|
return null;
|
|
2252
3678
|
}
|
|
2253
3679
|
return (0, import_react_dom.createPortal)(
|
|
2254
|
-
/* @__PURE__ */ (0,
|
|
3680
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2255
3681
|
"div",
|
|
2256
3682
|
{
|
|
2257
3683
|
className: "fixed inset-0",
|
|
2258
3684
|
style: { zIndex: PREVIEW_WORKSPACE_Z_INDEX, pointerEvents: "none" },
|
|
2259
3685
|
children: [
|
|
2260
|
-
|
|
3686
|
+
sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2261
3687
|
PreviewControllerWindow,
|
|
2262
3688
|
{
|
|
3689
|
+
fixedControllerOrientation: fixedOrientation,
|
|
2263
3690
|
session,
|
|
3691
|
+
frameRef: (frame) => {
|
|
3692
|
+
if (frame) frames.set(session.id, frame);
|
|
3693
|
+
else frames.delete(session.id);
|
|
3694
|
+
},
|
|
2264
3695
|
activeOpacity,
|
|
2265
3696
|
highContrast,
|
|
2266
3697
|
dragging: dragState?.id === session.id,
|
|
@@ -2379,7 +3810,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2379
3810
|
},
|
|
2380
3811
|
session.id
|
|
2381
3812
|
)),
|
|
2382
|
-
/* @__PURE__ */ (0,
|
|
3813
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2383
3814
|
"div",
|
|
2384
3815
|
{
|
|
2385
3816
|
ref: dockRef,
|
|
@@ -2389,14 +3820,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2389
3820
|
),
|
|
2390
3821
|
style: { pointerEvents: "none" },
|
|
2391
3822
|
children: [
|
|
2392
|
-
/* @__PURE__ */ (0,
|
|
3823
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2393
3824
|
"div",
|
|
2394
3825
|
{
|
|
3826
|
+
ref: dockRowRef,
|
|
2395
3827
|
className: "flex items-start justify-end gap-2",
|
|
2396
3828
|
style: { pointerEvents: "auto" },
|
|
2397
3829
|
children: [
|
|
2398
3830
|
dockAccessory,
|
|
2399
|
-
launcherVisible ? /* @__PURE__ */ (0,
|
|
3831
|
+
launcherVisible ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2400
3832
|
Button,
|
|
2401
3833
|
{
|
|
2402
3834
|
type: "button",
|
|
@@ -2411,19 +3843,19 @@ var PreviewControllerWorkspace = ({
|
|
|
2411
3843
|
title: !joinUrl ? waitingLabel : launcherLabel,
|
|
2412
3844
|
onClick: () => setLauncherOpen((current) => !current),
|
|
2413
3845
|
children: [
|
|
2414
|
-
/* @__PURE__ */ (0,
|
|
2415
|
-
launcherVariant === "full" ? /* @__PURE__ */ (0,
|
|
2416
|
-
/* @__PURE__ */ (0,
|
|
2417
|
-
sessions.length > 0 ? /* @__PURE__ */ (0,
|
|
2418
|
-
launcherOpen ? /* @__PURE__ */ (0,
|
|
2419
|
-
] }) : sessions.length > 0 ? /* @__PURE__ */ (0,
|
|
3846
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.MonitorSmartphone, { className: "h-4 w-4" }),
|
|
3847
|
+
launcherVariant === "full" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3848
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-[11px] font-semibold tracking-[0.16em] uppercase", children: launcherLabel }),
|
|
3849
|
+
sessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rounded-full border border-white/12 bg-white/6 px-1.5 py-0.5 text-[10px] leading-none font-semibold text-white/88", children: sessions.length }) : null,
|
|
3850
|
+
launcherOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.ChevronUp, { className: "h-4 w-4 text-white/60" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.ChevronDown, { className: "h-4 w-4 text-white/60" })
|
|
3851
|
+
] }) : sessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full border border-white/25 bg-slate-950 px-1 text-[9px] leading-none font-semibold text-white", children: sessions.length }) : null
|
|
2420
3852
|
]
|
|
2421
3853
|
}
|
|
2422
3854
|
) : null
|
|
2423
3855
|
]
|
|
2424
3856
|
}
|
|
2425
3857
|
),
|
|
2426
|
-
launcherOpen ? /* @__PURE__ */ (0,
|
|
3858
|
+
launcherOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2427
3859
|
"section",
|
|
2428
3860
|
{
|
|
2429
3861
|
className: cn(
|
|
@@ -2432,15 +3864,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2432
3864
|
highContrast && "border-white/30"
|
|
2433
3865
|
),
|
|
2434
3866
|
style: { pointerEvents: "auto" },
|
|
2435
|
-
children: /* @__PURE__ */ (0,
|
|
2436
|
-
controllerRoster.length > 0 || onResetRoom ? /* @__PURE__ */ (0,
|
|
2437
|
-
/* @__PURE__ */ (0,
|
|
2438
|
-
/* @__PURE__ */ (0,
|
|
2439
|
-
/* @__PURE__ */ (0,
|
|
2440
|
-
/* @__PURE__ */ (0,
|
|
3867
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-4", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-4", children: [
|
|
3868
|
+
controllerRoster.length > 0 || onResetRoom ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-3", children: [
|
|
3869
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-start justify-between gap-3", children: [
|
|
3870
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "min-w-0", children: [
|
|
3871
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] font-semibold tracking-[0.18em] text-white/54 uppercase", children: "Controllers" }),
|
|
3872
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "mt-2 text-sm text-white/86", children: controllerRoster.length === 0 ? "No controllers yet" : `${controllerRoster.length} controller${controllerRoster.length === 1 ? "" : "s"} connected` })
|
|
2441
3873
|
] }),
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
2443
|
-
onResetRoom ? /* @__PURE__ */ (0,
|
|
3874
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex shrink-0 items-center gap-1.5", children: [
|
|
3875
|
+
onResetRoom ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2444
3876
|
Button,
|
|
2445
3877
|
{
|
|
2446
3878
|
type: "button",
|
|
@@ -2459,7 +3891,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2459
3891
|
children: "Reset room"
|
|
2460
3892
|
}
|
|
2461
3893
|
) : null,
|
|
2462
|
-
sessions.length > 0 ? /* @__PURE__ */ (0,
|
|
3894
|
+
sessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2463
3895
|
Button,
|
|
2464
3896
|
{
|
|
2465
3897
|
type: "button",
|
|
@@ -2468,15 +3900,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2468
3900
|
className: "h-7 w-7 rounded-full text-white/72 hover:bg-white/8 hover:text-white",
|
|
2469
3901
|
onClick: () => clearPreviewControllers(),
|
|
2470
3902
|
title: "Close all preview controllers",
|
|
2471
|
-
children: /* @__PURE__ */ (0,
|
|
3903
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
2472
3904
|
}
|
|
2473
3905
|
) : null
|
|
2474
3906
|
] })
|
|
2475
3907
|
] }),
|
|
2476
|
-
/* @__PURE__ */ (0,
|
|
3908
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-2", children: controllerRoster.map((item) => {
|
|
2477
3909
|
const SourceIcon = getControllerSourceIcon(item.source);
|
|
2478
3910
|
const previewSession = item.session;
|
|
2479
|
-
return /* @__PURE__ */ (0,
|
|
3911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2480
3912
|
"div",
|
|
2481
3913
|
{
|
|
2482
3914
|
"data-airjam-controller-row": true,
|
|
@@ -2487,10 +3919,10 @@ var PreviewControllerWorkspace = ({
|
|
|
2487
3919
|
shellInsetPanelClassName
|
|
2488
3920
|
),
|
|
2489
3921
|
children: [
|
|
2490
|
-
/* @__PURE__ */ (0,
|
|
2491
|
-
/* @__PURE__ */ (0,
|
|
2492
|
-
/* @__PURE__ */ (0,
|
|
2493
|
-
/* @__PURE__ */ (0,
|
|
3922
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-white/10 bg-white/5 text-white/70", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SourceIcon, { className: "h-4 w-4" }) }),
|
|
3923
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3924
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate text-sm font-semibold text-white/92", children: item.label }),
|
|
3925
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2494
3926
|
"span",
|
|
2495
3927
|
{
|
|
2496
3928
|
"data-airjam-controller-source-badge": true,
|
|
@@ -2498,7 +3930,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2498
3930
|
children: getControllerSourceLabel(item.source)
|
|
2499
3931
|
}
|
|
2500
3932
|
),
|
|
2501
|
-
/* @__PURE__ */ (0,
|
|
3933
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2502
3934
|
"span",
|
|
2503
3935
|
{
|
|
2504
3936
|
className: cn(
|
|
@@ -2508,10 +3940,10 @@ var PreviewControllerWorkspace = ({
|
|
|
2508
3940
|
title: item.session?.minimized ? "Minimized" : item.session ? item.session.surfaceState === "ready" ? "Visible" : previewControllerWindowStateLabel[item.session.surfaceState] : item.connected ? "Connected" : "Disconnected"
|
|
2509
3941
|
}
|
|
2510
3942
|
),
|
|
2511
|
-
item.resumable ? /* @__PURE__ */ (0,
|
|
3943
|
+
item.resumable ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rounded-full border border-white/10 bg-white/5 px-1.5 py-0.5 text-[9px] leading-none font-semibold tracking-[0.12em] text-white/55 uppercase", children: "Resume" }) : null
|
|
2512
3944
|
] }) }),
|
|
2513
|
-
/* @__PURE__ */ (0,
|
|
2514
|
-
previewSession?.minimized ? /* @__PURE__ */ (0,
|
|
3945
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3946
|
+
previewSession?.minimized ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2515
3947
|
Button,
|
|
2516
3948
|
{
|
|
2517
3949
|
type: "button",
|
|
@@ -2525,35 +3957,35 @@ var PreviewControllerWorkspace = ({
|
|
|
2525
3957
|
children: "Restore"
|
|
2526
3958
|
}
|
|
2527
3959
|
) : null,
|
|
2528
|
-
item.controller && onRemoveController ? /* @__PURE__ */ (0,
|
|
3960
|
+
item.controller && onRemoveController ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2529
3961
|
Button,
|
|
2530
3962
|
{
|
|
2531
3963
|
type: "button",
|
|
2532
3964
|
variant: "ghost",
|
|
2533
3965
|
size: "sm",
|
|
2534
3966
|
className: "h-7 rounded-full px-3 text-[10px] text-rose-200 hover:bg-rose-400/10 hover:text-rose-100 disabled:text-white/35",
|
|
2535
|
-
disabled: removingControllerId === item.controller.
|
|
3967
|
+
disabled: removingControllerId === item.controller.id,
|
|
2536
3968
|
onClick: async () => {
|
|
2537
3969
|
if (!item.controller) {
|
|
2538
3970
|
return;
|
|
2539
3971
|
}
|
|
2540
3972
|
try {
|
|
2541
3973
|
setRemovingControllerId(
|
|
2542
|
-
item.controller.
|
|
3974
|
+
item.controller.id
|
|
2543
3975
|
);
|
|
2544
3976
|
await onRemoveController(
|
|
2545
|
-
item.controller.
|
|
3977
|
+
item.controller.id
|
|
2546
3978
|
);
|
|
2547
3979
|
} finally {
|
|
2548
3980
|
setRemovingControllerId(
|
|
2549
|
-
(current) => current === item.controller?.
|
|
3981
|
+
(current) => current === item.controller?.id ? null : current
|
|
2550
3982
|
);
|
|
2551
3983
|
}
|
|
2552
3984
|
},
|
|
2553
3985
|
children: "Kick"
|
|
2554
3986
|
}
|
|
2555
3987
|
) : null,
|
|
2556
|
-
previewSession ? /* @__PURE__ */ (0,
|
|
3988
|
+
previewSession ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2557
3989
|
Button,
|
|
2558
3990
|
{
|
|
2559
3991
|
type: "button",
|
|
@@ -2562,7 +3994,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2562
3994
|
className: "h-7 w-7 rounded-full text-white/68 hover:bg-white/8 hover:text-white",
|
|
2563
3995
|
onClick: () => removePreviewController(previewSession.id),
|
|
2564
3996
|
title: `Close ${item.label}`,
|
|
2565
|
-
children: /* @__PURE__ */ (0,
|
|
3997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
2566
3998
|
}
|
|
2567
3999
|
) : null
|
|
2568
4000
|
] })
|
|
@@ -2571,13 +4003,13 @@ var PreviewControllerWorkspace = ({
|
|
|
2571
4003
|
item.id
|
|
2572
4004
|
);
|
|
2573
4005
|
}) }),
|
|
2574
|
-
/* @__PURE__ */ (0,
|
|
2575
|
-
] }) : /* @__PURE__ */ (0,
|
|
2576
|
-
minimizedSessions.length > 0 ? /* @__PURE__ */ (0,
|
|
4006
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "h-px bg-white/10" })
|
|
4007
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: cn("px-4 py-4", shellInsetPanelClassName), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-sm leading-6 text-white/58", children: "Open a controller preview here to test the host flow without using a phone." }) }),
|
|
4008
|
+
minimizedSessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { className: "text-[11px] tracking-[0.14em] text-white/46 uppercase", children: [
|
|
2577
4009
|
minimizedSessions.length,
|
|
2578
4010
|
" minimized"
|
|
2579
4011
|
] }) : null,
|
|
2580
|
-
/* @__PURE__ */ (0,
|
|
4012
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2581
4013
|
Button,
|
|
2582
4014
|
{
|
|
2583
4015
|
type: "button",
|
|
@@ -2591,7 +4023,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2591
4023
|
spawnPreviewController();
|
|
2592
4024
|
},
|
|
2593
4025
|
children: [
|
|
2594
|
-
/* @__PURE__ */ (0,
|
|
4026
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
|
|
2595
4027
|
!joinUrl ? waitingLabel : "Add controller"
|
|
2596
4028
|
]
|
|
2597
4029
|
}
|
|
@@ -2610,7 +4042,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2610
4042
|
};
|
|
2611
4043
|
|
|
2612
4044
|
// src/preview/host-workspace.tsx
|
|
2613
|
-
var
|
|
4045
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2614
4046
|
var HostPreviewControllerWorkspace = ({
|
|
2615
4047
|
enabled = "auto",
|
|
2616
4048
|
className,
|
|
@@ -2624,20 +4056,15 @@ var HostPreviewControllerWorkspace = ({
|
|
|
2624
4056
|
topology: config.topology
|
|
2625
4057
|
});
|
|
2626
4058
|
const joinUrl = host.joinUrlStatus === "ready" && host.joinUrl ? host.joinUrl : null;
|
|
2627
|
-
const handleResetRoom =
|
|
2628
|
-
|
|
2629
|
-
if (!ack.ok || typeof window === "undefined") {
|
|
2630
|
-
return ack;
|
|
2631
|
-
}
|
|
2632
|
-
window.location.reload();
|
|
2633
|
-
return ack;
|
|
4059
|
+
const handleResetRoom = () => {
|
|
4060
|
+
void host.resetRoom().then(() => window.location.reload());
|
|
2634
4061
|
};
|
|
2635
|
-
return /* @__PURE__ */ (0,
|
|
4062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2636
4063
|
PreviewControllerWorkspace,
|
|
2637
4064
|
{
|
|
2638
4065
|
enabled: resolvedEnabled,
|
|
2639
4066
|
joinUrl,
|
|
2640
|
-
|
|
4067
|
+
players: host.players,
|
|
2641
4068
|
onRemoveController: host.removeController,
|
|
2642
4069
|
onResetRoom: handleResetRoom,
|
|
2643
4070
|
onActiveOpacityChange: (activeOpacity) => platformSettingsOwner?.updatePreviewControllers({ activeOpacity }),
|
|
@@ -2648,21 +4075,26 @@ var HostPreviewControllerWorkspace = ({
|
|
|
2648
4075
|
};
|
|
2649
4076
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2650
4077
|
0 && (module.exports = {
|
|
2651
|
-
|
|
2652
|
-
AIR_JAM_PREVIEW_FLAG_QUERY_PARAM,
|
|
4078
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM,
|
|
2653
4079
|
HostPreviewControllerWorkspace,
|
|
2654
4080
|
PreviewControllerWindow,
|
|
2655
4081
|
PreviewControllerWorkspace,
|
|
2656
4082
|
buildPreviewControllerUrl,
|
|
2657
|
-
createPreviewControllerIdentity,
|
|
2658
4083
|
createPreviewControllerLaunch,
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
4084
|
+
getPreviewControllerViewportSize,
|
|
4085
|
+
getPreviewHostViewportSize,
|
|
4086
|
+
isLocalSeatReadyMessage,
|
|
4087
|
+
isLocalSeatRelayedMessage,
|
|
4088
|
+
isPreviewSeatMessage,
|
|
4089
|
+
localInputOperationSchema,
|
|
4090
|
+
localSeatMessages,
|
|
4091
|
+
localSeatQuerySchema,
|
|
4092
|
+
localSeatRelaySchema,
|
|
4093
|
+
localSeatRequestSchema,
|
|
2664
4094
|
readPreviewControllerDeviceIdFromSearchParams,
|
|
2665
|
-
|
|
4095
|
+
relayLocalSeatInput,
|
|
4096
|
+
requestPreviewControllerClose,
|
|
4097
|
+
sendLocalSeatOperation,
|
|
2666
4098
|
usePreviewControllerManager
|
|
2667
4099
|
});
|
|
2668
4100
|
//# sourceMappingURL=preview.cjs.map
|