@air-jam/sdk 0.9.3 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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-DfLm4Mf-.d.ts} +3 -19
- package/dist/{agent-contract-CD2QnbBJ.d.ts → agent-contract-TINzp-5Y.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-BCVCWiaT.d.ts} +121 -114
- package/dist/{use-air-jam-host-DM-ybB3C.d.cts → air-jam-context-DavligpM.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 +10354 -4690
- 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-2QZADUGA.js +188 -0
- package/dist/chunk-2QZADUGA.js.map +1 -0
- package/dist/chunk-3LDQCQL2.js +307 -0
- package/dist/chunk-3LDQCQL2.js.map +1 -0
- package/dist/chunk-3M7656SU.js +389 -0
- package/dist/chunk-3M7656SU.js.map +1 -0
- package/dist/{chunk-K4OZ54UD.js → chunk-5CRZFIN6.js} +2 -55
- package/dist/chunk-5CRZFIN6.js.map +1 -0
- package/dist/chunk-5TVVPBQI.js +7 -0
- package/dist/chunk-5TVVPBQI.js.map +1 -0
- package/dist/chunk-6Y3F6Y2K.js +343 -0
- package/dist/chunk-6Y3F6Y2K.js.map +1 -0
- package/dist/{chunk-EVZJA6RN.js → chunk-6ZJUA63D.js} +183 -2
- package/dist/chunk-6ZJUA63D.js.map +1 -0
- package/dist/chunk-A6EOGRRG.js +49 -0
- package/dist/chunk-A6EOGRRG.js.map +1 -0
- package/dist/chunk-BEM77SVQ.js +57 -0
- package/dist/chunk-BEM77SVQ.js.map +1 -0
- package/dist/chunk-C5722GTG.js +176 -0
- package/dist/chunk-C5722GTG.js.map +1 -0
- package/dist/{chunk-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-DHFKL3DI.js +2477 -0
- package/dist/chunk-DHFKL3DI.js.map +1 -0
- package/dist/chunk-DRBPVG47.js +89 -0
- package/dist/chunk-DRBPVG47.js.map +1 -0
- package/dist/{chunk-MIMPMB7O.js → chunk-EG25EXSA.js} +24 -3
- package/dist/chunk-EG25EXSA.js.map +1 -0
- package/dist/chunk-FCG42U7D.js +131 -0
- package/dist/chunk-FCG42U7D.js.map +1 -0
- package/dist/chunk-FJ4J2BEC.js +26 -0
- package/dist/chunk-FJ4J2BEC.js.map +1 -0
- package/dist/chunk-H4DEVMTO.js +221 -0
- package/dist/chunk-H4DEVMTO.js.map +1 -0
- package/dist/{chunk-X35LLCWV.js → chunk-I6TSHJF7.js} +6 -8
- package/dist/chunk-I6TSHJF7.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-KSYN4I5Y.js +50 -0
- package/dist/chunk-KSYN4I5Y.js.map +1 -0
- package/dist/chunk-KUGROY5S.js +265 -0
- package/dist/chunk-KUGROY5S.js.map +1 -0
- package/dist/chunk-LX6CTPDW.js +16 -0
- package/dist/chunk-LX6CTPDW.js.map +1 -0
- package/dist/{chunk-BE6Z4SIT.js → chunk-M5553I2G.js} +2 -11
- package/dist/chunk-M5553I2G.js.map +1 -0
- package/dist/{chunk-X24K52DG.js → chunk-MD25536W.js} +1 -1
- package/dist/chunk-MD25536W.js.map +1 -0
- package/dist/{chunk-3USU7GY2.js → chunk-MJAWAHLT.js} +1 -1
- package/dist/chunk-MJAWAHLT.js.map +1 -0
- package/dist/chunk-OAXCFPZ7.js +14 -0
- package/dist/chunk-OAXCFPZ7.js.map +1 -0
- package/dist/{chunk-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-S3TN7Y7L.js +921 -0
- package/dist/chunk-S3TN7Y7L.js.map +1 -0
- package/dist/chunk-SMKD4JY3.js +129 -0
- package/dist/chunk-SMKD4JY3.js.map +1 -0
- package/dist/{chunk-O6X7FJ6N.js → chunk-TFW4NJW2.js} +619 -643
- package/dist/chunk-TFW4NJW2.js.map +1 -0
- package/dist/chunk-UBBP2UY3.js +83 -0
- package/dist/chunk-UBBP2UY3.js.map +1 -0
- package/dist/chunk-URVBMQCK.js +802 -0
- package/dist/chunk-URVBMQCK.js.map +1 -0
- package/dist/chunk-VGX2274F.js +1995 -0
- package/dist/chunk-VGX2274F.js.map +1 -0
- package/dist/chunk-WAFGYJZN.js +1513 -0
- package/dist/chunk-WAFGYJZN.js.map +1 -0
- package/dist/chunk-WGHNGQUS.js +78 -0
- package/dist/chunk-WGHNGQUS.js.map +1 -0
- package/dist/chunk-XLY44PXZ.js +46 -0
- package/dist/chunk-XLY44PXZ.js.map +1 -0
- package/dist/connection-store-BYpQ50W2.d.ts +41 -0
- package/dist/connection-store-D6QqzXU1.d.cts +41 -0
- package/dist/control-Bv8dWjyp.d.ts +1400 -0
- package/dist/control-CNzybWMd.d.cts +1400 -0
- package/dist/controller-0CVO1t_3.d.cts +26 -0
- package/dist/controller-agent-vOiuK7T6.d.cts +130 -0
- package/dist/controller-agent-vOiuK7T6.d.ts +130 -0
- package/dist/controller-bridge.cjs +992 -0
- package/dist/controller-bridge.cjs.map +1 -0
- package/dist/controller-bridge.d.cts +52 -0
- package/dist/controller-bridge.d.ts +52 -0
- package/dist/controller-bridge.js +23 -0
- package/dist/controller-bridge.js.map +1 -0
- package/dist/controller-capture-2GKKGHJ2.js +8 -0
- package/dist/controller-capture-2GKKGHJ2.js.map +1 -0
- package/dist/controller-h9M2Nngd.d.ts +26 -0
- package/dist/controller-press-EWWIMVXP.js +231 -0
- package/dist/controller-press-EWWIMVXP.js.map +1 -0
- package/dist/core-BAO0pHrJ.d.cts +15 -0
- package/dist/core-BAO0pHrJ.d.ts +15 -0
- package/dist/core.cjs +5931 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +232 -0
- package/dist/core.d.ts +232 -0
- package/dist/core.js +906 -0
- package/dist/core.js.map +1 -0
- package/dist/dev-events-BffobOfb.d.ts +31 -0
- package/dist/dev-events-Ct7QEgKb.d.cts +31 -0
- package/dist/dev-log-events-B1_B3guZ.d.cts +47 -0
- package/dist/dev-log-events-B1_B3guZ.d.ts +47 -0
- package/dist/frames-D-xKuODS.d.cts +686 -0
- package/dist/frames-D-xKuODS.d.ts +686 -0
- package/dist/game-Db58JNk3.d.cts +77 -0
- package/dist/game-bySEy-QO.d.ts +77 -0
- package/dist/host-runtime-BuLhGQx5.d.ts +399 -0
- package/dist/host-runtime-_06jpW5v.d.cts +399 -0
- package/dist/index.cjs +11580 -7584
- 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-Xvs80gqG.d.cts +92 -0
- package/dist/input-Xvs80gqG.d.ts +92 -0
- package/dist/input-bindings-BaEFrgRb.d.cts +129 -0
- package/dist/input-bindings-BgsJRLPm.d.ts +129 -0
- package/dist/leased-control-BEg4JuXA.d.cts +158 -0
- package/dist/leased-control-BEg4JuXA.d.ts +158 -0
- package/dist/metadata.cjs +3 -9
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +6 -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-Ca6rlxJr.d.ts +439 -0
- package/dist/phone-room-session-DkPR-K6e.d.cts +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 +2214 -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-BvX4As2f.d.ts +31 -0
- package/dist/replay-input-log-Vcl0VDIy.d.cts +31 -0
- package/dist/room-protocol.cjs +794 -0
- package/dist/room-protocol.cjs.map +1 -0
- package/dist/room-protocol.d.cts +63 -0
- package/dist/room-protocol.d.ts +63 -0
- package/dist/room-protocol.js +143 -0
- package/dist/room-protocol.js.map +1 -0
- package/dist/room-session.cjs +2336 -0
- package/dist/room-session.cjs.map +1 -0
- package/dist/room-session.d.cts +77 -0
- package/dist/room-session.d.ts +77 -0
- package/dist/room-session.js +103 -0
- package/dist/room-session.js.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.cjs +207 -0
- package/dist/runtime/prefab-inspection-bridge.cjs.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.d.cts +156 -0
- package/dist/runtime/prefab-inspection-bridge.d.ts +156 -0
- package/dist/runtime/prefab-inspection-bridge.js +22 -0
- package/dist/runtime/prefab-inspection-bridge.js.map +1 -0
- package/dist/runtime-control.cjs +2112 -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-CiiWu06D.d.ts +66 -0
- package/dist/scoped-connector-D7252pn0.d.cts +66 -0
- package/dist/sdk-channels-S6j6AH8v.d.cts +103 -0
- package/dist/sdk-channels-S6j6AH8v.d.ts +103 -0
- package/dist/simulation-BfRnC4rg.d.ts +782 -0
- package/dist/simulation-BwZx2pgt.d.cts +782 -0
- package/dist/{standard-match-phase-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 +2182 -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 +26 -0
- package/src/core/input-bindings.ts +180 -0
- package/src/core/input-log.ts +144 -0
- package/src/core/input.ts +228 -0
- package/src/core/local-input.ts +319 -0
- package/src/core/replay-input-log.ts +298 -0
- package/src/core/replicated-store.ts +1178 -0
- package/src/core/room-action-ack.ts +43 -0
- package/src/core/settings.ts +202 -0
- package/src/core/simulation.ts +307 -0
- package/src/core/theme.ts +33 -0
- package/src/core.ts +162 -0
- package/src/dev/browser-log-sink.ts +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,522 @@ 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();
|
|
739
|
+
var RUNTIME_ERROR_REPORT_RETRY_DELAYS_MS = [1e3, 2e3, 4e3];
|
|
740
|
+
var createRuntimeErrorReporter = ({
|
|
741
|
+
endpoint,
|
|
742
|
+
credentials
|
|
743
|
+
}) => {
|
|
744
|
+
return (report) => {
|
|
745
|
+
const body = JSON.stringify(report);
|
|
746
|
+
const send = async (retries) => {
|
|
747
|
+
const response = await fetch(endpoint, {
|
|
748
|
+
method: "POST",
|
|
749
|
+
headers: { "content-type": "application/json" },
|
|
750
|
+
body,
|
|
751
|
+
credentials,
|
|
752
|
+
keepalive: true
|
|
753
|
+
}).catch(() => null);
|
|
754
|
+
const [delay, ...later] = retries;
|
|
755
|
+
if (response?.status !== 404 || delay === void 0) return;
|
|
756
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
757
|
+
await send(later);
|
|
758
|
+
};
|
|
759
|
+
void send(RUNTIME_ERROR_REPORT_RETRY_DELAYS_MS);
|
|
760
|
+
};
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// src/protocol/signed-envelope.ts
|
|
764
|
+
var encoder = new TextEncoder();
|
|
765
|
+
var decoder = new TextDecoder();
|
|
441
766
|
|
|
442
767
|
// src/protocol/url-policy.ts
|
|
443
|
-
var
|
|
768
|
+
var import_zod13 = require("zod");
|
|
444
769
|
var ALLOWED_RUNTIME_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
445
770
|
var parseRuntimeUrl = (value) => {
|
|
446
771
|
try {
|
|
@@ -464,7 +789,7 @@ var getRuntimeUrlOrigin = (value) => {
|
|
|
464
789
|
const parsed = parseRuntimeUrl(value);
|
|
465
790
|
return parsed ? parsed.origin : null;
|
|
466
791
|
};
|
|
467
|
-
var runtimeUrlSchema =
|
|
792
|
+
var runtimeUrlSchema = import_zod13.z.string().trim().min(1).refine((value) => parseRuntimeUrl(value) !== null, {
|
|
468
793
|
message: "URL must be a valid http(s) URL without embedded credentials."
|
|
469
794
|
});
|
|
470
795
|
var appendRuntimeQueryParams = (baseUrl, params) => {
|
|
@@ -502,11 +827,661 @@ var isLocalDevControlSurfaceRuntimeMode = (runtimeMode) => LOCAL_DEV_CONTROL_SUR
|
|
|
502
827
|
assertString(runtimeMode, "runtimeMode")
|
|
503
828
|
);
|
|
504
829
|
|
|
505
|
-
// src/
|
|
506
|
-
var
|
|
830
|
+
// src/core/hosted-rooms.ts
|
|
831
|
+
var AIR_JAM_HOSTED_RUNTIME_ERRORS_ENDPOINT = "https://airjam.io/api/airjam/runtime-errors";
|
|
832
|
+
var hostedRuntimeErrorReporter = createRuntimeErrorReporter({
|
|
833
|
+
endpoint: AIR_JAM_HOSTED_RUNTIME_ERRORS_ENDPOINT,
|
|
834
|
+
credentials: "omit"
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
// src/runtime/browser-replay.ts
|
|
838
|
+
var import_zod24 = require("zod");
|
|
839
|
+
|
|
840
|
+
// src/core/input-log.ts
|
|
841
|
+
var import_zod15 = require("zod");
|
|
842
|
+
|
|
843
|
+
// src/core/settings.ts
|
|
844
|
+
var import_zod14 = require("zod");
|
|
845
|
+
var common = {
|
|
846
|
+
live: import_zod14.z.boolean().default(false),
|
|
847
|
+
description: import_zod14.z.string().min(1).optional()
|
|
848
|
+
};
|
|
849
|
+
var numberSettingSchema = import_zod14.z.object({
|
|
850
|
+
kind: import_zod14.z.literal("number"),
|
|
851
|
+
default: import_zod14.z.number().finite(),
|
|
852
|
+
min: import_zod14.z.number().finite(),
|
|
853
|
+
max: import_zod14.z.number().finite(),
|
|
854
|
+
step: import_zod14.z.number().finite().positive().optional(),
|
|
855
|
+
...common
|
|
856
|
+
}).strict();
|
|
857
|
+
var booleanSettingSchema = import_zod14.z.object({
|
|
858
|
+
kind: import_zod14.z.literal("boolean"),
|
|
859
|
+
default: import_zod14.z.boolean(),
|
|
860
|
+
...common
|
|
861
|
+
}).strict();
|
|
862
|
+
var choiceSettingSchema = import_zod14.z.object({
|
|
863
|
+
kind: import_zod14.z.literal("choice"),
|
|
864
|
+
options: import_zod14.z.array(import_zod14.z.string().min(1)).nonempty(),
|
|
865
|
+
default: import_zod14.z.string(),
|
|
866
|
+
...common
|
|
867
|
+
}).strict();
|
|
868
|
+
var airJamSettingSchema = import_zod14.z.discriminatedUnion("kind", [
|
|
869
|
+
numberSettingSchema,
|
|
870
|
+
booleanSettingSchema,
|
|
871
|
+
choiceSettingSchema
|
|
872
|
+
]);
|
|
873
|
+
var airJamSettingsValuesSchema = import_zod14.z.record(
|
|
874
|
+
import_zod14.z.string(),
|
|
875
|
+
import_zod14.z.union([import_zod14.z.number().finite(), import_zod14.z.boolean(), import_zod14.z.string()])
|
|
876
|
+
);
|
|
877
|
+
|
|
878
|
+
// src/core/input-log.ts
|
|
879
|
+
var AIR_JAM_INPUT_LOG_EVENTS = [
|
|
880
|
+
"seat",
|
|
881
|
+
"left",
|
|
882
|
+
"input",
|
|
883
|
+
"runtime",
|
|
884
|
+
"action",
|
|
885
|
+
"settings"
|
|
886
|
+
];
|
|
887
|
+
var inputLogEntrySchema = import_zod15.z.object({
|
|
888
|
+
/** The step the event reached the game before. */
|
|
889
|
+
tick: import_zod15.z.number().int().positive(),
|
|
890
|
+
event: import_zod15.z.enum(AIR_JAM_INPUT_LOG_EVENTS),
|
|
891
|
+
payload: import_zod15.z.record(import_zod15.z.string(), import_zod15.z.unknown())
|
|
892
|
+
}).strict();
|
|
893
|
+
var airJamInputLogSchema = import_zod15.z.object({
|
|
894
|
+
version: import_zod15.z.literal(3),
|
|
895
|
+
settings: airJamSettingsValuesSchema,
|
|
896
|
+
seed: import_zod15.z.number().int().min(0).max(4294967295),
|
|
897
|
+
stepMs: import_zod15.z.number().positive(),
|
|
898
|
+
/** Steps the recorded host took. */
|
|
899
|
+
ticks: import_zod15.z.number().int().nonnegative(),
|
|
900
|
+
/** The store domain of stores that declare none, so actions find their store again. */
|
|
901
|
+
storeDomain: import_zod15.z.string().min(1),
|
|
902
|
+
entries: import_zod15.z.array(inputLogEntrySchema)
|
|
903
|
+
}).strict();
|
|
904
|
+
var AIR_JAM_INPUT_LOG_MAX_GAME_MS = 30 * 60 * 1e3;
|
|
905
|
+
var AIR_JAM_INPUT_LOG_MAX_ENTRY_BYTES = 16 * 1024 * 1024;
|
|
906
|
+
|
|
907
|
+
// src/core/replay-input-log.ts
|
|
908
|
+
var import_zod23 = require("zod");
|
|
909
|
+
|
|
910
|
+
// src/runtime/contracts/control.ts
|
|
911
|
+
var import_nanoid2 = require("nanoid");
|
|
912
|
+
var import_zod22 = require("zod");
|
|
913
|
+
|
|
914
|
+
// src/agent/agent-evaluator.ts
|
|
915
|
+
var import_zod16 = require("zod");
|
|
916
|
+
|
|
917
|
+
// src/utils/is-rpc-serializable.ts
|
|
918
|
+
var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
919
|
+
if (value === null || value === void 0) {
|
|
920
|
+
return true;
|
|
921
|
+
}
|
|
922
|
+
const valueType = typeof value;
|
|
923
|
+
if (valueType === "string" || valueType === "boolean") {
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
926
|
+
if (valueType === "number") {
|
|
927
|
+
return Number.isFinite(value);
|
|
928
|
+
}
|
|
929
|
+
if (valueType === "function" || valueType === "symbol" || valueType === "bigint") {
|
|
930
|
+
return false;
|
|
931
|
+
}
|
|
932
|
+
if (valueType !== "object") {
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
const objectValue = value;
|
|
936
|
+
if (seen.has(objectValue)) {
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
939
|
+
seen.add(objectValue);
|
|
940
|
+
try {
|
|
941
|
+
if (objectValue instanceof Date) return true;
|
|
942
|
+
if (Array.isArray(objectValue))
|
|
943
|
+
return objectValue.every((entry) => isRpcSerializable(entry, seen));
|
|
944
|
+
const prototype = Object.getPrototypeOf(objectValue);
|
|
945
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
946
|
+
return Object.values(objectValue).every(
|
|
947
|
+
(entry) => isRpcSerializable(entry, seen)
|
|
948
|
+
);
|
|
949
|
+
} finally {
|
|
950
|
+
seen.delete(objectValue);
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// src/agent/agent-evaluator.ts
|
|
955
|
+
var agentActionDescriptorSchema = import_zod16.z.object({
|
|
956
|
+
actionId: import_zod16.z.string().min(1),
|
|
957
|
+
target: import_zod16.z.object({
|
|
958
|
+
kind: import_zod16.z.enum(["participant", "host"]),
|
|
959
|
+
actionName: import_zod16.z.string().min(1),
|
|
960
|
+
storeDomain: import_zod16.z.string().min(1)
|
|
961
|
+
}),
|
|
962
|
+
description: import_zod16.z.string().nullable(),
|
|
963
|
+
availability: import_zod16.z.string().nullable(),
|
|
964
|
+
payload: import_zod16.z.object({
|
|
965
|
+
kind: import_zod16.z.enum(["none", "boolean", "number", "string", "enum", "json"]),
|
|
966
|
+
description: import_zod16.z.string().nullable(),
|
|
967
|
+
allowedValues: import_zod16.z.array(import_zod16.z.string()).optional()
|
|
968
|
+
}),
|
|
969
|
+
resultDescription: import_zod16.z.string().nullable()
|
|
970
|
+
});
|
|
971
|
+
var agentContractDescriptionSchema = import_zod16.z.object({
|
|
972
|
+
snapshotStoreDomains: import_zod16.z.array(import_zod16.z.string().min(1)),
|
|
973
|
+
snapshotDescription: import_zod16.z.string().nullable(),
|
|
974
|
+
actions: import_zod16.z.array(agentActionDescriptorSchema)
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
// src/runtime/host-observation.ts
|
|
978
|
+
var import_nanoid = require("nanoid");
|
|
979
|
+
|
|
980
|
+
// src/runtime/contracts/observation.ts
|
|
981
|
+
var import_zod17 = require("zod");
|
|
982
|
+
var HOST_OBSERVATION_IMAGE_BYTES = 64e4;
|
|
983
|
+
var jsonObject = import_zod17.z.record(import_zod17.z.string(), import_zod17.z.unknown()).refine(
|
|
984
|
+
(value) => isRpcSerializable(value) && new TextEncoder().encode(JSON.stringify(value)).byteLength <= 128e3,
|
|
985
|
+
{
|
|
986
|
+
message: "Observations require serializable JSON within the 128 KB state budget."
|
|
987
|
+
}
|
|
988
|
+
);
|
|
989
|
+
var hostObservationRequestSchema = import_zod17.z.object({
|
|
990
|
+
roomId: roomCodeSchema,
|
|
991
|
+
controllerId: import_zod17.z.string().min(1).max(128).nullable(),
|
|
992
|
+
scope: import_zod17.z.enum(["player", "diagnostic"]),
|
|
993
|
+
includeImage: import_zod17.z.boolean(),
|
|
994
|
+
expected: hostObservationIdentitySchema.optional()
|
|
995
|
+
}).strict();
|
|
996
|
+
var hostObservationImageSchema = import_zod17.z.object({
|
|
997
|
+
mimeType: import_zod17.z.enum(["image/jpeg", "image/png", "image/webp"]),
|
|
998
|
+
data: import_zod17.z.string().min(4).max(Math.ceil(HOST_OBSERVATION_IMAGE_BYTES / 3) * 4).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(
|
|
999
|
+
(value) => value.length % 4 === 0 && value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0) <= HOST_OBSERVATION_IMAGE_BYTES,
|
|
1000
|
+
"Observation image exceeds its byte budget or is invalid base64."
|
|
1001
|
+
),
|
|
1002
|
+
width: import_zod17.z.number().int().positive().max(4096),
|
|
1003
|
+
height: import_zod17.z.number().int().positive().max(4096),
|
|
1004
|
+
coverage: import_zod17.z.enum(["render-surface", "host-document", "controller-view"])
|
|
1005
|
+
}).strict();
|
|
1006
|
+
var storeRevision = import_zod17.z.object({
|
|
1007
|
+
storeDomain: import_zod17.z.string().min(1),
|
|
1008
|
+
revision: import_zod17.z.number().int().nonnegative()
|
|
1009
|
+
});
|
|
1010
|
+
var hostRuntimeFaultSchema = import_zod17.z.object({
|
|
1011
|
+
name: import_zod17.z.string().max(128),
|
|
1012
|
+
message: import_zod17.z.string().max(2048),
|
|
1013
|
+
source: import_zod17.z.object({
|
|
1014
|
+
file: import_zod17.z.string().max(2048),
|
|
1015
|
+
line: import_zod17.z.number().int().positive(),
|
|
1016
|
+
column: import_zod17.z.number().int().positive()
|
|
1017
|
+
}).strict().nullable(),
|
|
1018
|
+
stack: import_zod17.z.string().max(8192)
|
|
1019
|
+
}).strict();
|
|
1020
|
+
var hostObservationPresentationSchema = import_zod17.z.object({
|
|
1021
|
+
runtimeState: runtimeStateSchema,
|
|
1022
|
+
connectionStatus: connectionStatusSchema,
|
|
1023
|
+
fault: hostRuntimeFaultSchema.nullable().optional()
|
|
1024
|
+
}).strict();
|
|
1025
|
+
var hostObservationClockSchema = import_zod17.z.object({
|
|
1026
|
+
startedAtMs: import_zod17.z.number().nonnegative(),
|
|
1027
|
+
finishedAtMs: import_zod17.z.number().nonnegative()
|
|
1028
|
+
}).strict().refine(
|
|
1029
|
+
(value) => value.finishedAtMs >= value.startedAtMs,
|
|
1030
|
+
"The host clock must advance monotonically."
|
|
1031
|
+
);
|
|
1032
|
+
var hostObservationSchema = import_zod17.z.object({
|
|
1033
|
+
version: import_zod17.z.literal(1),
|
|
1034
|
+
id: import_zod17.z.string().min(1),
|
|
1035
|
+
identity: hostObservationIdentitySchema,
|
|
1036
|
+
sequence: import_zod17.z.number().int().positive(),
|
|
1037
|
+
scope: import_zod17.z.enum(["player", "diagnostic"]),
|
|
1038
|
+
controllerId: import_zod17.z.string().nullable(),
|
|
1039
|
+
host: import_zod17.z.object({
|
|
1040
|
+
before: hostObservationPresentationSchema.nullable(),
|
|
1041
|
+
after: hostObservationPresentationSchema.nullable()
|
|
1042
|
+
}).optional(),
|
|
1043
|
+
actions: import_zod17.z.array(agentActionDescriptorSchema).optional(),
|
|
1044
|
+
capabilities: import_zod17.z.object({
|
|
1045
|
+
participantControl: import_zod17.z.object({
|
|
1046
|
+
input: import_zod17.z.literal(1).optional(),
|
|
1047
|
+
inputSchema: participantInputSchemaDescriptionSchema.optional(),
|
|
1048
|
+
actions: import_zod17.z.literal(1).optional()
|
|
1049
|
+
}).optional()
|
|
1050
|
+
}).optional(),
|
|
1051
|
+
capturedAt: import_zod17.z.iso.datetime(),
|
|
1052
|
+
clock: hostObservationClockSchema.optional(),
|
|
1053
|
+
/** The page's slowest fixed-step simulation against real time, since it started. */
|
|
1054
|
+
pace: import_zod17.z.object({
|
|
1055
|
+
frames: import_zod17.z.number().int().nonnegative(),
|
|
1056
|
+
wallMs: import_zod17.z.number().nonnegative(),
|
|
1057
|
+
simulatedMs: import_zod17.z.number().nonnegative()
|
|
1058
|
+
}).strict().optional(),
|
|
1059
|
+
durationMs: import_zod17.z.number().nonnegative(),
|
|
1060
|
+
snapshot: jsonObject,
|
|
1061
|
+
runtime: jsonObject.nullable(),
|
|
1062
|
+
ticks: import_zod17.z.object({
|
|
1063
|
+
before: import_zod17.z.number().int().nonnegative().nullable(),
|
|
1064
|
+
after: import_zod17.z.number().int().nonnegative().nullable()
|
|
1065
|
+
}),
|
|
1066
|
+
stores: import_zod17.z.object({
|
|
1067
|
+
before: import_zod17.z.array(storeRevision),
|
|
1068
|
+
after: import_zod17.z.array(storeRevision)
|
|
1069
|
+
}),
|
|
1070
|
+
visual: import_zod17.z.discriminatedUnion("status", [
|
|
1071
|
+
import_zod17.z.object({
|
|
1072
|
+
status: import_zod17.z.literal("captured"),
|
|
1073
|
+
image: hostObservationImageSchema
|
|
1074
|
+
}),
|
|
1075
|
+
import_zod17.z.object({
|
|
1076
|
+
status: import_zod17.z.literal("unavailable"),
|
|
1077
|
+
reason: import_zod17.z.enum([
|
|
1078
|
+
"not-requested",
|
|
1079
|
+
"unsupported",
|
|
1080
|
+
"surface-unavailable",
|
|
1081
|
+
"timeout"
|
|
1082
|
+
]),
|
|
1083
|
+
detail: import_zod17.z.string().max(1024).optional()
|
|
1084
|
+
})
|
|
1085
|
+
])
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
// src/runtime/contracts/agent-control.ts
|
|
1089
|
+
var import_zod21 = require("zod");
|
|
1090
|
+
|
|
1091
|
+
// src/runtime/contracts/clip.ts
|
|
1092
|
+
var import_zod18 = require("zod");
|
|
1093
|
+
var CLIP_MIN_FRAME_INTERVAL_MS = 33;
|
|
1094
|
+
var clipFrameIntervalSchema = import_zod18.z.number().int().min(CLIP_MIN_FRAME_INTERVAL_MS);
|
|
1095
|
+
var CLIP_MAX_DURATION_MS = 15e3;
|
|
1096
|
+
var CLIP_MAX_FRAMES = Math.ceil(
|
|
1097
|
+
CLIP_MAX_DURATION_MS / CLIP_MIN_FRAME_INTERVAL_MS
|
|
1098
|
+
);
|
|
1099
|
+
var CLIP_MAX_BYTES = 4 * 1024 * 1024;
|
|
1100
|
+
var CLIP_FRAME_MAX_BYTES = 160 * 1024;
|
|
1101
|
+
var CLIP_PAGE_BASE64_CHARS = 768 * 1024;
|
|
1102
|
+
var CLIP_RECORDING_LIFETIME_MS = 6e5;
|
|
1103
|
+
var CLIP_VIDEO_MAX_BYTES = 32 * 1024 * 1024;
|
|
1104
|
+
var clipNotCapturedReasonSchema = import_zod18.z.enum([
|
|
1105
|
+
"busy",
|
|
1106
|
+
"unsupported",
|
|
1107
|
+
"surface-unavailable",
|
|
1108
|
+
"capture-failed",
|
|
1109
|
+
"runtime-replaced",
|
|
1110
|
+
"host-unavailable",
|
|
1111
|
+
"headless"
|
|
1112
|
+
]);
|
|
1113
|
+
var clipImageBytes = (data) => data.length / 4 * 3 - (data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0);
|
|
1114
|
+
var clipFrameSchema = import_zod18.z.object({
|
|
1115
|
+
index: import_zod18.z.number().int().nonnegative(),
|
|
1116
|
+
atMs: import_zod18.z.number().nonnegative().max(CLIP_RECORDING_LIFETIME_MS),
|
|
1117
|
+
width: import_zod18.z.number().int().positive().max(1280),
|
|
1118
|
+
height: import_zod18.z.number().int().positive().max(1280),
|
|
1119
|
+
mimeType: import_zod18.z.literal("image/jpeg"),
|
|
1120
|
+
data: import_zod18.z.string().min(4).max(Math.ceil(CLIP_FRAME_MAX_BYTES / 3) * 4).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(
|
|
1121
|
+
(data) => data.length % 4 === 0 && clipImageBytes(data) <= CLIP_FRAME_MAX_BYTES,
|
|
1122
|
+
"Clip frame exceeds its byte budget or is invalid base64."
|
|
1123
|
+
)
|
|
1124
|
+
}).strict();
|
|
1125
|
+
var clipMetadata = {
|
|
1126
|
+
clipId: import_zod18.z.string().min(1).max(128),
|
|
1127
|
+
identity: hostObservationIdentitySchema,
|
|
1128
|
+
startedAt: import_zod18.z.iso.datetime(),
|
|
1129
|
+
frameIntervalMs: clipFrameIntervalSchema,
|
|
1130
|
+
// Offsets and duration refer to the original recording, even after old frames drop.
|
|
1131
|
+
durationMs: import_zod18.z.number().nonnegative().max(CLIP_RECORDING_LIFETIME_MS),
|
|
1132
|
+
droppedFrames: import_zod18.z.number().int().nonnegative(),
|
|
1133
|
+
skippedFrames: import_zod18.z.number().int().nonnegative()
|
|
1134
|
+
};
|
|
1135
|
+
var clipArtifactSchema = import_zod18.z.object({
|
|
1136
|
+
version: import_zod18.z.literal(1),
|
|
1137
|
+
...clipMetadata,
|
|
1138
|
+
frames: import_zod18.z.array(clipFrameSchema).min(1).max(CLIP_MAX_FRAMES)
|
|
1139
|
+
}).strict().superRefine((clip, ctx) => {
|
|
1140
|
+
const frames = clip.frames;
|
|
1141
|
+
if (frames.length > Math.ceil(CLIP_MAX_DURATION_MS / clip.frameIntervalMs))
|
|
1142
|
+
ctx.addIssue({
|
|
1143
|
+
code: "custom",
|
|
1144
|
+
message: "Clip exceeds its cadence frame budget."
|
|
1145
|
+
});
|
|
1146
|
+
if (frames.reduce((sum, frame) => sum + clipImageBytes(frame.data), 0) > CLIP_MAX_BYTES)
|
|
1147
|
+
ctx.addIssue({
|
|
1148
|
+
code: "custom",
|
|
1149
|
+
message: "Clip exceeds its image byte budget."
|
|
1150
|
+
});
|
|
1151
|
+
if (frames.some(
|
|
1152
|
+
(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)
|
|
1153
|
+
))
|
|
1154
|
+
ctx.addIssue({
|
|
1155
|
+
code: "custom",
|
|
1156
|
+
message: "Clip frames must be ordered within the kept time window."
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
var clipNativeCaptureSchema = import_zod18.z.object({
|
|
1160
|
+
drawsAttempted: import_zod18.z.number().int().nonnegative(),
|
|
1161
|
+
drawsMade: import_zod18.z.number().int().nonnegative()
|
|
1162
|
+
}).strict();
|
|
1163
|
+
var clipVideoPageSchema = import_zod18.z.object({
|
|
1164
|
+
mimeType: import_zod18.z.string().min(1).max(128),
|
|
1165
|
+
width: import_zod18.z.number().int().positive().max(1280),
|
|
1166
|
+
height: import_zod18.z.number().int().positive().max(1280),
|
|
1167
|
+
chunks: import_zod18.z.array(
|
|
1168
|
+
import_zod18.z.string().min(4).max(CLIP_PAGE_BASE64_CHARS).regex(
|
|
1169
|
+
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/
|
|
1170
|
+
)
|
|
1171
|
+
).max(1),
|
|
1172
|
+
nextChunk: import_zod18.z.number().int().nonnegative().nullable()
|
|
1173
|
+
}).strict();
|
|
1174
|
+
var clipReadSchema = import_zod18.z.object({
|
|
1175
|
+
...clipMetadata,
|
|
1176
|
+
state: import_zod18.z.enum(["recording", "stopped"]),
|
|
1177
|
+
// Native encoded frames are counted after stop by the video consumer.
|
|
1178
|
+
nativeCapture: clipNativeCaptureSchema.optional(),
|
|
1179
|
+
droppedFrames: clipMetadata.droppedFrames.nullable(),
|
|
1180
|
+
skippedFrames: clipMetadata.skippedFrames.nullable(),
|
|
1181
|
+
frameCount: import_zod18.z.number().int().nonnegative().max(Math.ceil(CLIP_RECORDING_LIFETIME_MS / CLIP_MIN_FRAME_INTERVAL_MS)).nullable(),
|
|
1182
|
+
notCaptured: clipNotCapturedReasonSchema.nullable(),
|
|
1183
|
+
frames: import_zod18.z.array(clipFrameSchema).max(CLIP_MAX_FRAMES).refine(
|
|
1184
|
+
(frames) => frames.reduce((sum, frame) => sum + frame.data.length, 0) <= CLIP_PAGE_BASE64_CHARS,
|
|
1185
|
+
"Clip page exceeds its transfer budget."
|
|
1186
|
+
),
|
|
1187
|
+
nextFrame: import_zod18.z.number().int().nonnegative().nullable(),
|
|
1188
|
+
video: clipVideoPageSchema.optional()
|
|
1189
|
+
}).strict();
|
|
507
1190
|
|
|
508
|
-
// src/
|
|
509
|
-
var
|
|
1191
|
+
// src/runtime/contracts/input-log.ts
|
|
1192
|
+
var import_zod19 = require("zod");
|
|
1193
|
+
var INPUT_LOG_PAGE_BYTES = 512 * 1024;
|
|
1194
|
+
var inputLogCutSchema = import_zod19.z.object({
|
|
1195
|
+
ticks: import_zod19.z.number().int().nonnegative(),
|
|
1196
|
+
entryCount: import_zod19.z.number().int().nonnegative()
|
|
1197
|
+
}).strict();
|
|
1198
|
+
var hostInputLogPageSchema = import_zod19.z.object({
|
|
1199
|
+
identity: hostObservationIdentitySchema,
|
|
1200
|
+
observation: hostObservationSchema.optional(),
|
|
1201
|
+
header: airJamInputLogSchema.omit({ entries: true }),
|
|
1202
|
+
entryCount: import_zod19.z.number().int().nonnegative(),
|
|
1203
|
+
full: import_zod19.z.boolean(),
|
|
1204
|
+
entries: airJamInputLogSchema.shape.entries,
|
|
1205
|
+
nextEntry: import_zod19.z.number().int().nonnegative().nullable()
|
|
1206
|
+
}).strict();
|
|
1207
|
+
var inputLogNotReplayableReasonSchema = import_zod19.z.enum([
|
|
1208
|
+
"no-simulation",
|
|
1209
|
+
"loading",
|
|
1210
|
+
"runtime-replaced",
|
|
1211
|
+
"host-unavailable"
|
|
1212
|
+
]);
|
|
1213
|
+
|
|
1214
|
+
// src/runtime/contracts/timeline.ts
|
|
1215
|
+
var import_zod20 = require("zod");
|
|
1216
|
+
var facts = {
|
|
1217
|
+
id: import_zod20.z.string().min(1),
|
|
1218
|
+
tick: import_zod20.z.number().int().nonnegative(),
|
|
1219
|
+
/** Epoch milliseconds, unlike the simulation's game clock. */
|
|
1220
|
+
at: import_zod20.z.number().nonnegative()
|
|
1221
|
+
};
|
|
1222
|
+
var hostTimelineEntrySchema = import_zod20.z.discriminatedUnion("kind", [
|
|
1223
|
+
import_zod20.z.object({
|
|
1224
|
+
...facts,
|
|
1225
|
+
kind: import_zod20.z.enum(["join", "drop", "leave", "name"]),
|
|
1226
|
+
controllerId: import_zod20.z.string(),
|
|
1227
|
+
name: import_zod20.z.string().optional(),
|
|
1228
|
+
previousName: import_zod20.z.string().optional()
|
|
1229
|
+
}),
|
|
1230
|
+
import_zod20.z.object({
|
|
1231
|
+
...facts,
|
|
1232
|
+
kind: import_zod20.z.literal("state"),
|
|
1233
|
+
state: import_zod20.z.enum(["paused", "playing"])
|
|
1234
|
+
}),
|
|
1235
|
+
import_zod20.z.object({
|
|
1236
|
+
...facts,
|
|
1237
|
+
kind: import_zod20.z.literal("settings"),
|
|
1238
|
+
values: airJamSettingsValuesSchema,
|
|
1239
|
+
previousValues: airJamSettingsValuesSchema
|
|
1240
|
+
}),
|
|
1241
|
+
import_zod20.z.object({
|
|
1242
|
+
...facts,
|
|
1243
|
+
kind: import_zod20.z.literal("moment"),
|
|
1244
|
+
text: import_zod20.z.string().min(1).max(240)
|
|
1245
|
+
})
|
|
1246
|
+
]);
|
|
1247
|
+
var hostTimelinePaceSchema = import_zod20.z.object({
|
|
1248
|
+
/** End of the five-second sampling window, in epoch milliseconds. */
|
|
1249
|
+
at: import_zod20.z.number().nonnegative(),
|
|
1250
|
+
fps: import_zod20.z.number().nonnegative(),
|
|
1251
|
+
speed: import_zod20.z.number().nonnegative()
|
|
1252
|
+
});
|
|
1253
|
+
var hostTimelineSchema = import_zod20.z.discriminatedUnion("status", [
|
|
1254
|
+
import_zod20.z.object({
|
|
1255
|
+
status: import_zod20.z.literal("available"),
|
|
1256
|
+
identity: hostObservationIdentitySchema,
|
|
1257
|
+
startedAt: import_zod20.z.number().nonnegative(),
|
|
1258
|
+
stepMs: import_zod20.z.number().positive(),
|
|
1259
|
+
entries: import_zod20.z.array(hostTimelineEntrySchema),
|
|
1260
|
+
pace: import_zod20.z.array(hostTimelinePaceSchema).max(360)
|
|
1261
|
+
}),
|
|
1262
|
+
import_zod20.z.object({
|
|
1263
|
+
status: import_zod20.z.literal("unavailable"),
|
|
1264
|
+
identity: hostObservationIdentitySchema,
|
|
1265
|
+
reason: import_zod20.z.enum(["no-simulation", "simulation-loading"])
|
|
1266
|
+
})
|
|
1267
|
+
]);
|
|
1268
|
+
|
|
1269
|
+
// src/runtime/contracts/agent-control.ts
|
|
1270
|
+
var identity = import_zod21.z.object({
|
|
1271
|
+
roomId: roomCodeSchema,
|
|
1272
|
+
controllerId: import_zod21.z.string().min(1)
|
|
1273
|
+
});
|
|
1274
|
+
var actionRequest = identity.extend({
|
|
1275
|
+
contractId: import_zod21.z.string().min(1),
|
|
1276
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1277
|
+
actionId: import_zod21.z.string().min(1),
|
|
1278
|
+
payload: import_zod21.z.unknown().refine(
|
|
1279
|
+
(value) => isRpcSerializable(value),
|
|
1280
|
+
"Agent input must be serializable JSON data."
|
|
1281
|
+
).optional()
|
|
1282
|
+
});
|
|
1283
|
+
var hostAgentRequestSchema = import_zod21.z.discriminatedUnion("operation", [
|
|
1284
|
+
/** The room's instance and every seat in it, with what kind of device holds each. */
|
|
1285
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("seats"), roomId: roomCodeSchema }).strict(),
|
|
1286
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("timeline-read"), roomId: roomCodeSchema }).strict(),
|
|
1287
|
+
import_zod21.z.object({
|
|
1288
|
+
operation: import_zod21.z.literal("input-log-read"),
|
|
1289
|
+
roomId: roomCodeSchema,
|
|
1290
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1291
|
+
cut: inputLogCutSchema.nullable(),
|
|
1292
|
+
observe: hostObservationRequestSchema.pick({ controllerId: true, scope: true }).optional(),
|
|
1293
|
+
fromEntry: import_zod21.z.number().int().nonnegative()
|
|
1294
|
+
}).strict(),
|
|
1295
|
+
hostObservationRequestSchema.extend({ operation: import_zod21.z.literal("observe") }).strict(),
|
|
1296
|
+
identity.extend({
|
|
1297
|
+
operation: import_zod21.z.literal("read"),
|
|
1298
|
+
controllerId: import_zod21.z.string().min(1).nullable()
|
|
1299
|
+
}).strict(),
|
|
1300
|
+
import_zod21.z.object({
|
|
1301
|
+
operation: import_zod21.z.literal("settings-read"),
|
|
1302
|
+
roomId: roomCodeSchema,
|
|
1303
|
+
runtimeId: import_zod21.z.string().min(1)
|
|
1304
|
+
}).strict(),
|
|
1305
|
+
import_zod21.z.object({
|
|
1306
|
+
operation: import_zod21.z.literal("settings-update"),
|
|
1307
|
+
roomId: roomCodeSchema,
|
|
1308
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1309
|
+
patch: airJamSettingsValuesSchema,
|
|
1310
|
+
expectedRevision: import_zod21.z.number().int().nonnegative()
|
|
1311
|
+
}).strict(),
|
|
1312
|
+
actionRequest.extend({ operation: import_zod21.z.literal("resolve") }).strict(),
|
|
1313
|
+
actionRequest.extend({ operation: import_zod21.z.literal("invoke-host") }).strict(),
|
|
1314
|
+
import_zod21.z.object({
|
|
1315
|
+
operation: import_zod21.z.literal("clip-start"),
|
|
1316
|
+
delivery: import_zod21.z.enum(["pages", "video"]).optional(),
|
|
1317
|
+
frameIntervalMs: clipFrameIntervalSchema.optional(),
|
|
1318
|
+
roomId: roomCodeSchema,
|
|
1319
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1320
|
+
clipId: import_zod21.z.string().min(1).max(128)
|
|
1321
|
+
}).strict(),
|
|
1322
|
+
import_zod21.z.object({
|
|
1323
|
+
operation: import_zod21.z.literal("clip-read"),
|
|
1324
|
+
roomId: roomCodeSchema,
|
|
1325
|
+
clipId: import_zod21.z.string().min(1).max(128),
|
|
1326
|
+
stop: import_zod21.z.boolean(),
|
|
1327
|
+
fromChunk: import_zod21.z.number().int().nonnegative().optional(),
|
|
1328
|
+
fromFrame: import_zod21.z.number().int().nonnegative()
|
|
1329
|
+
}).strict()
|
|
1330
|
+
]);
|
|
1331
|
+
var hostAgentSnapshotSchema = agentContractDescriptionSchema.extend({
|
|
1332
|
+
contractId: import_zod21.z.string().min(1),
|
|
1333
|
+
runtimeId: import_zod21.z.string().min(1),
|
|
1334
|
+
snapshot: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()),
|
|
1335
|
+
rawStores: import_zod21.z.array(
|
|
1336
|
+
import_zod21.z.object({
|
|
1337
|
+
storeDomain: import_zod21.z.string().min(1),
|
|
1338
|
+
data: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()),
|
|
1339
|
+
revision: import_zod21.z.number().int().nonnegative(),
|
|
1340
|
+
updatedAt: import_zod21.z.string()
|
|
1341
|
+
})
|
|
1342
|
+
),
|
|
1343
|
+
storeDomainBindings: import_zod21.z.array(
|
|
1344
|
+
import_zod21.z.object({
|
|
1345
|
+
contractStoreDomain: import_zod21.z.string(),
|
|
1346
|
+
runtimeStoreDomain: import_zod21.z.string()
|
|
1347
|
+
})
|
|
1348
|
+
)
|
|
1349
|
+
});
|
|
1350
|
+
var hostAgentResponseSchema = import_zod21.z.discriminatedUnion("operation", [
|
|
1351
|
+
import_zod21.z.object({
|
|
1352
|
+
operation: import_zod21.z.literal("seats"),
|
|
1353
|
+
instance: import_zod21.z.string().min(1),
|
|
1354
|
+
seats: import_zod21.z.array(seatViewSchema)
|
|
1355
|
+
}).strict(),
|
|
1356
|
+
import_zod21.z.object({
|
|
1357
|
+
operation: import_zod21.z.literal("timeline-read"),
|
|
1358
|
+
timeline: hostTimelineSchema
|
|
1359
|
+
}).strict(),
|
|
1360
|
+
import_zod21.z.object({
|
|
1361
|
+
operation: import_zod21.z.literal("input-log-read"),
|
|
1362
|
+
page: hostInputLogPageSchema
|
|
1363
|
+
}).strict(),
|
|
1364
|
+
import_zod21.z.object({
|
|
1365
|
+
operation: import_zod21.z.literal("clip-start"),
|
|
1366
|
+
clipId: import_zod21.z.string().min(1).max(128),
|
|
1367
|
+
startedAt: import_zod21.z.iso.datetime()
|
|
1368
|
+
}).strict(),
|
|
1369
|
+
import_zod21.z.object({ operation: import_zod21.z.literal("clip-read"), clip: clipReadSchema }).strict(),
|
|
1370
|
+
import_zod21.z.object({
|
|
1371
|
+
operation: import_zod21.z.enum(["settings-read", "settings-update"]),
|
|
1372
|
+
values: airJamSettingsValuesSchema,
|
|
1373
|
+
revision: import_zod21.z.number().int().nonnegative()
|
|
1374
|
+
}),
|
|
1375
|
+
import_zod21.z.object({
|
|
1376
|
+
operation: import_zod21.z.literal("observe"),
|
|
1377
|
+
observation: hostObservationSchema
|
|
1378
|
+
}),
|
|
1379
|
+
import_zod21.z.object({
|
|
1380
|
+
operation: import_zod21.z.literal("read"),
|
|
1381
|
+
snapshot: hostAgentSnapshotSchema.nullable()
|
|
1382
|
+
}),
|
|
1383
|
+
import_zod21.z.object({
|
|
1384
|
+
operation: import_zod21.z.enum(["resolve", "invoke-host"]),
|
|
1385
|
+
target: import_zod21.z.object({
|
|
1386
|
+
kind: import_zod21.z.enum(["participant", "host"]),
|
|
1387
|
+
actionName: import_zod21.z.string(),
|
|
1388
|
+
storeDomain: import_zod21.z.string()
|
|
1389
|
+
}),
|
|
1390
|
+
payload: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()).optional(),
|
|
1391
|
+
acknowledgement: airJamActionInvocationResultSchema.optional()
|
|
1392
|
+
})
|
|
1393
|
+
]);
|
|
1394
|
+
var hostAgentRequestMessageSchema = import_zod21.z.object({
|
|
1395
|
+
type: import_zod21.z.literal("AIRJAM_HOST_AGENT"),
|
|
1396
|
+
requestId: import_zod21.z.string().min(1).max(128),
|
|
1397
|
+
request: hostAgentRequestSchema
|
|
1398
|
+
}).strict();
|
|
1399
|
+
var hostAgentResultMessageSchema = import_zod21.z.object({
|
|
1400
|
+
type: import_zod21.z.literal("AIRJAM_HOST_AGENT_RESULT"),
|
|
1401
|
+
requestId: hostAgentRequestMessageSchema.shape.requestId,
|
|
1402
|
+
result: import_zod21.z.discriminatedUnion("ok", [
|
|
1403
|
+
import_zod21.z.object({ ok: import_zod21.z.literal(true), response: hostAgentResponseSchema }),
|
|
1404
|
+
import_zod21.z.object({ ok: import_zod21.z.literal(false), error: import_zod21.z.string().min(1).max(1024) })
|
|
1405
|
+
])
|
|
1406
|
+
}).strict();
|
|
1407
|
+
|
|
1408
|
+
// src/runtime/contracts/control.ts
|
|
1409
|
+
var hostRuntimeActionRequestSchema = import_zod22.z.object({
|
|
1410
|
+
roomId: roomCodeSchema,
|
|
1411
|
+
storeDomain: import_zod22.z.string().trim().min(1).max(128),
|
|
1412
|
+
actionName: import_zod22.z.string().trim().min(1).max(128),
|
|
1413
|
+
payload: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.unknown()).optional()
|
|
1414
|
+
}).strict();
|
|
1415
|
+
var hostStateEpochSchema = import_zod22.z.object({
|
|
1416
|
+
storeDomain: import_zod22.z.string().min(1).max(128),
|
|
1417
|
+
epoch: import_zod22.z.string().min(1).max(128)
|
|
1418
|
+
});
|
|
1419
|
+
|
|
1420
|
+
// src/core/replay-input-log.ts
|
|
1421
|
+
var settingsLogEventSchema = import_zod23.z.object({
|
|
1422
|
+
patch: airJamSettingsValuesSchema,
|
|
1423
|
+
revision: import_zod23.z.number().int().positive()
|
|
1424
|
+
}).strict();
|
|
1425
|
+
var seatLogEventSchema = import_zod23.z.object({ seat: seatViewSchema });
|
|
1426
|
+
var leftLogEventSchema = import_zod23.z.object({ seat: import_zod23.z.string() });
|
|
1427
|
+
var inputLogEventSchema = import_zod23.z.object({
|
|
1428
|
+
seat: import_zod23.z.string(),
|
|
1429
|
+
input: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.unknown())
|
|
1430
|
+
});
|
|
1431
|
+
var runtimeLogEventSchema = import_zod23.z.object({ runtimeState: runtimeStateSchema });
|
|
1432
|
+
var actionLogEventSchema = import_zod23.z.object({
|
|
1433
|
+
actionName: import_zod23.z.string(),
|
|
1434
|
+
payload: import_zod23.z.unknown().optional(),
|
|
1435
|
+
storeDomain: import_zod23.z.string(),
|
|
1436
|
+
actor: import_zod23.z.object({
|
|
1437
|
+
id: import_zod23.z.string(),
|
|
1438
|
+
role: import_zod23.z.enum(["host", "controller"])
|
|
1439
|
+
})
|
|
1440
|
+
});
|
|
1441
|
+
|
|
1442
|
+
// src/runtime/browser-replay.ts
|
|
1443
|
+
var whole = import_zod24.z.number().int().nonnegative();
|
|
1444
|
+
var replayAdvanceSchema = import_zod24.z.union([
|
|
1445
|
+
import_zod24.z.object({ steps: whole }).strict(),
|
|
1446
|
+
import_zod24.z.object({ ms: import_zod24.z.number().finite().nonnegative() }).strict(),
|
|
1447
|
+
import_zod24.z.object({ toTick: whole }).strict()
|
|
1448
|
+
]);
|
|
1449
|
+
var replayRequestSchema = import_zod24.z.discriminatedUnion("operation", [
|
|
1450
|
+
import_zod24.z.object({
|
|
1451
|
+
operation: import_zod24.z.literal("open"),
|
|
1452
|
+
log: airJamInputLogSchema,
|
|
1453
|
+
observe: hostObservationRequestSchema.pick({ scope: true, controllerId: true }).optional()
|
|
1454
|
+
}).strict(),
|
|
1455
|
+
import_zod24.z.object({ operation: import_zod24.z.literal("advance"), by: replayAdvanceSchema }).strict(),
|
|
1456
|
+
import_zod24.z.object({
|
|
1457
|
+
operation: import_zod24.z.literal("read"),
|
|
1458
|
+
/** Capture the paused frame on this explicit read; open and advance omit images. */
|
|
1459
|
+
includeImage: import_zod24.z.boolean().optional()
|
|
1460
|
+
}).strict()
|
|
1461
|
+
]);
|
|
1462
|
+
var replayReadSchema = import_zod24.z.object({
|
|
1463
|
+
tick: whole,
|
|
1464
|
+
ticks: whole,
|
|
1465
|
+
done: import_zod24.z.boolean(),
|
|
1466
|
+
stepMs: import_zod24.z.number().positive(),
|
|
1467
|
+
observation: hostObservationSchema
|
|
1468
|
+
}).strict();
|
|
1469
|
+
var replayRequestMessageSchema = import_zod24.z.object({
|
|
1470
|
+
type: import_zod24.z.literal("AIRJAM_REPLAY"),
|
|
1471
|
+
requestId: import_zod24.z.string().min(1),
|
|
1472
|
+
request: replayRequestSchema
|
|
1473
|
+
}).strict();
|
|
1474
|
+
var replayMessageSchema = import_zod24.z.discriminatedUnion("type", [
|
|
1475
|
+
import_zod24.z.object({ type: import_zod24.z.literal("AIRJAM_REPLAY_READY") }).strict(),
|
|
1476
|
+
import_zod24.z.object({
|
|
1477
|
+
type: import_zod24.z.literal("AIRJAM_REPLAY_RESULT"),
|
|
1478
|
+
requestId: import_zod24.z.string().min(1),
|
|
1479
|
+
result: import_zod24.z.discriminatedUnion("ok", [
|
|
1480
|
+
import_zod24.z.object({ ok: import_zod24.z.literal(true), response: replayReadSchema }).strict(),
|
|
1481
|
+
import_zod24.z.object({ ok: import_zod24.z.literal(false), error: import_zod24.z.string() }).strict()
|
|
1482
|
+
])
|
|
1483
|
+
}).strict()
|
|
1484
|
+
]);
|
|
510
1485
|
|
|
511
1486
|
// src/context/air-jam-context.tsx
|
|
512
1487
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -527,7 +1502,7 @@ var useAirJamConfig = () => {
|
|
|
527
1502
|
|
|
528
1503
|
// src/hooks/use-air-jam-host.ts
|
|
529
1504
|
var import_react4 = require("react");
|
|
530
|
-
var
|
|
1505
|
+
var import_zustand2 = require("zustand");
|
|
531
1506
|
var import_shallow2 = require("zustand/react/shallow");
|
|
532
1507
|
|
|
533
1508
|
// src/context/session-scope.ts
|
|
@@ -556,23 +1531,26 @@ var useAssertSessionScope = (expectedScope, hookName) => {
|
|
|
556
1531
|
|
|
557
1532
|
// src/runtime/runtime-owner-contexts.tsx
|
|
558
1533
|
var import_react3 = require("react");
|
|
1534
|
+
var fixedControllerOrientationContext = (0, import_react3.createContext)(void 0);
|
|
559
1535
|
var hostRuntimeContext = (0, import_react3.createContext)(null);
|
|
560
1536
|
var controllerRuntimeContext = (0, import_react3.createContext)(null);
|
|
1537
|
+
var declaredStoresContext = (0, import_react3.createContext)(null);
|
|
561
1538
|
|
|
562
1539
|
// src/hooks/use-air-jam-host.ts
|
|
563
1540
|
var toHostState = (state) => ({
|
|
564
1541
|
roomId: state.roomId,
|
|
565
1542
|
connectionStatus: state.connectionStatus,
|
|
566
1543
|
players: state.players,
|
|
567
|
-
controllers: state.controllerSessions,
|
|
568
1544
|
lastError: state.lastError,
|
|
1545
|
+
queuePosition: state.queuePosition,
|
|
569
1546
|
mode: state.mode,
|
|
570
|
-
runtimeState: state.runtimeState
|
|
1547
|
+
runtimeState: state.runtimeState,
|
|
1548
|
+
controllerOrientation: state.controllerOrientation
|
|
571
1549
|
});
|
|
572
1550
|
function useAirJamHost(selector) {
|
|
573
1551
|
useAssertSessionScope("host", "useAirJamHost");
|
|
574
1552
|
const { store } = useAirJamContext();
|
|
575
|
-
const selectedState = (0,
|
|
1553
|
+
const selectedState = (0, import_zustand2.useStore)(
|
|
576
1554
|
store,
|
|
577
1555
|
(0, import_shallow2.useShallow)((state) => {
|
|
578
1556
|
const hostState = toHostState(state);
|
|
@@ -606,23 +1584,23 @@ function useAirJamHost(selector) {
|
|
|
606
1584
|
var import_react5 = require("react");
|
|
607
1585
|
|
|
608
1586
|
// src/runtime/iframe-bridge.ts
|
|
609
|
-
var
|
|
1587
|
+
var import_zod27 = require("zod");
|
|
610
1588
|
|
|
611
1589
|
// src/contracts/v2/bridge.ts
|
|
612
|
-
var
|
|
613
|
-
var roomCodeSchema2 =
|
|
1590
|
+
var import_zod25 = require("zod");
|
|
1591
|
+
var roomCodeSchema2 = import_zod25.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, {
|
|
614
1592
|
message: "room code must contain only A-Z or 0-9"
|
|
615
1593
|
});
|
|
616
|
-
var
|
|
617
|
-
var
|
|
618
|
-
id:
|
|
619
|
-
label:
|
|
620
|
-
color:
|
|
621
|
-
avatarId:
|
|
1594
|
+
var runtimeStateSchema2 = import_zod25.z.enum(["paused", "playing"]);
|
|
1595
|
+
var playerProfileSchema2 = import_zod25.z.object({
|
|
1596
|
+
id: import_zod25.z.string().min(1),
|
|
1597
|
+
label: import_zod25.z.string().min(1),
|
|
1598
|
+
color: import_zod25.z.string().optional(),
|
|
1599
|
+
avatarId: import_zod25.z.string().optional()
|
|
622
1600
|
}).strict();
|
|
623
|
-
var inputFrameEntrySchema =
|
|
624
|
-
controllerId:
|
|
625
|
-
input:
|
|
1601
|
+
var inputFrameEntrySchema = import_zod25.z.object({
|
|
1602
|
+
controllerId: import_zod25.z.string().min(1),
|
|
1603
|
+
input: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown())
|
|
626
1604
|
}).strict();
|
|
627
1605
|
var V2_BRIDGE_PARENT_TO_GAME_TYPES = [
|
|
628
1606
|
"BOOTSTRAP",
|
|
@@ -645,89 +1623,89 @@ var allMessageTypes = [
|
|
|
645
1623
|
...V2_BRIDGE_GAME_TO_PARENT_TYPES
|
|
646
1624
|
];
|
|
647
1625
|
var knownBridgeMessageTypeSet = new Set(allMessageTypes);
|
|
648
|
-
var bootstrapMessageSchema =
|
|
649
|
-
type:
|
|
650
|
-
payload:
|
|
1626
|
+
var bootstrapMessageSchema = import_zod25.z.object({
|
|
1627
|
+
type: import_zod25.z.literal("BOOTSTRAP"),
|
|
1628
|
+
payload: import_zod25.z.object({
|
|
651
1629
|
roomId: roomCodeSchema2,
|
|
652
|
-
players:
|
|
653
|
-
state:
|
|
654
|
-
runtimeState:
|
|
655
|
-
message:
|
|
1630
|
+
players: import_zod25.z.array(playerProfileSchema2),
|
|
1631
|
+
state: import_zod25.z.object({
|
|
1632
|
+
runtimeState: runtimeStateSchema2,
|
|
1633
|
+
message: import_zod25.z.string().optional()
|
|
656
1634
|
}).strict(),
|
|
657
|
-
capabilities:
|
|
1635
|
+
capabilities: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.boolean()).default({})
|
|
658
1636
|
}).strict()
|
|
659
1637
|
}).strict();
|
|
660
|
-
var playersUpdateMessageSchema =
|
|
661
|
-
type:
|
|
662
|
-
payload:
|
|
663
|
-
players:
|
|
1638
|
+
var playersUpdateMessageSchema = import_zod25.z.object({
|
|
1639
|
+
type: import_zod25.z.literal("PLAYERS_UPDATE"),
|
|
1640
|
+
payload: import_zod25.z.object({
|
|
1641
|
+
players: import_zod25.z.array(playerProfileSchema2)
|
|
664
1642
|
}).strict()
|
|
665
1643
|
}).strict();
|
|
666
|
-
var runtimeStateUpdateMessageSchema =
|
|
667
|
-
type:
|
|
668
|
-
payload:
|
|
669
|
-
runtimeState:
|
|
670
|
-
message:
|
|
1644
|
+
var runtimeStateUpdateMessageSchema = import_zod25.z.object({
|
|
1645
|
+
type: import_zod25.z.literal("RUNTIME_STATE_UPDATE"),
|
|
1646
|
+
payload: import_zod25.z.object({
|
|
1647
|
+
runtimeState: runtimeStateSchema2,
|
|
1648
|
+
message: import_zod25.z.string().optional()
|
|
671
1649
|
}).strict()
|
|
672
1650
|
}).strict();
|
|
673
|
-
var inputFrameMessageSchema =
|
|
674
|
-
type:
|
|
675
|
-
payload:
|
|
676
|
-
frameId:
|
|
677
|
-
inputs:
|
|
1651
|
+
var inputFrameMessageSchema = import_zod25.z.object({
|
|
1652
|
+
type: import_zod25.z.literal("INPUT_FRAME"),
|
|
1653
|
+
payload: import_zod25.z.object({
|
|
1654
|
+
frameId: import_zod25.z.number().int().nonnegative(),
|
|
1655
|
+
inputs: import_zod25.z.array(inputFrameEntrySchema)
|
|
678
1656
|
}).strict()
|
|
679
1657
|
}).strict();
|
|
680
|
-
var pauseMessageSchema =
|
|
681
|
-
type:
|
|
682
|
-
payload:
|
|
683
|
-
reason:
|
|
1658
|
+
var pauseMessageSchema = import_zod25.z.object({
|
|
1659
|
+
type: import_zod25.z.literal("PAUSE"),
|
|
1660
|
+
payload: import_zod25.z.object({
|
|
1661
|
+
reason: import_zod25.z.string().optional()
|
|
684
1662
|
}).strict()
|
|
685
1663
|
}).strict();
|
|
686
|
-
var resumeMessageSchema =
|
|
687
|
-
type:
|
|
688
|
-
payload:
|
|
1664
|
+
var resumeMessageSchema = import_zod25.z.object({
|
|
1665
|
+
type: import_zod25.z.literal("RESUME"),
|
|
1666
|
+
payload: import_zod25.z.object({}).strict()
|
|
689
1667
|
}).strict();
|
|
690
|
-
var shutdownMessageSchema =
|
|
691
|
-
type:
|
|
692
|
-
payload:
|
|
693
|
-
reason:
|
|
1668
|
+
var shutdownMessageSchema = import_zod25.z.object({
|
|
1669
|
+
type: import_zod25.z.literal("SHUTDOWN"),
|
|
1670
|
+
payload: import_zod25.z.object({
|
|
1671
|
+
reason: import_zod25.z.string().min(1)
|
|
694
1672
|
}).strict()
|
|
695
1673
|
}).strict();
|
|
696
|
-
var readyMessageSchema =
|
|
697
|
-
type:
|
|
698
|
-
payload:
|
|
699
|
-
readyAtMs:
|
|
1674
|
+
var readyMessageSchema = import_zod25.z.object({
|
|
1675
|
+
type: import_zod25.z.literal("READY"),
|
|
1676
|
+
payload: import_zod25.z.object({
|
|
1677
|
+
readyAtMs: import_zod25.z.number().int().nonnegative()
|
|
700
1678
|
}).strict()
|
|
701
1679
|
}).strict();
|
|
702
|
-
var statePatchMessageSchema =
|
|
703
|
-
type:
|
|
704
|
-
payload:
|
|
705
|
-
patch:
|
|
1680
|
+
var statePatchMessageSchema = import_zod25.z.object({
|
|
1681
|
+
type: import_zod25.z.literal("STATE_PATCH"),
|
|
1682
|
+
payload: import_zod25.z.object({
|
|
1683
|
+
patch: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown())
|
|
706
1684
|
}).strict()
|
|
707
1685
|
}).strict();
|
|
708
|
-
var signalMessageSchema =
|
|
709
|
-
type:
|
|
710
|
-
payload:
|
|
711
|
-
signalType:
|
|
712
|
-
targetId:
|
|
713
|
-
data:
|
|
1686
|
+
var signalMessageSchema = import_zod25.z.object({
|
|
1687
|
+
type: import_zod25.z.literal("SIGNAL"),
|
|
1688
|
+
payload: import_zod25.z.object({
|
|
1689
|
+
signalType: import_zod25.z.string().min(1),
|
|
1690
|
+
targetId: import_zod25.z.string().min(1).optional(),
|
|
1691
|
+
data: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown())
|
|
714
1692
|
}).strict()
|
|
715
1693
|
}).strict();
|
|
716
|
-
var errorMessageSchema =
|
|
717
|
-
type:
|
|
718
|
-
payload:
|
|
719
|
-
code:
|
|
720
|
-
message:
|
|
721
|
-
details:
|
|
1694
|
+
var errorMessageSchema = import_zod25.z.object({
|
|
1695
|
+
type: import_zod25.z.literal("ERROR"),
|
|
1696
|
+
payload: import_zod25.z.object({
|
|
1697
|
+
code: import_zod25.z.string().min(1),
|
|
1698
|
+
message: import_zod25.z.string().min(1),
|
|
1699
|
+
details: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.unknown()).optional()
|
|
722
1700
|
}).strict()
|
|
723
1701
|
}).strict();
|
|
724
|
-
var metricsMessageSchema =
|
|
725
|
-
type:
|
|
726
|
-
payload:
|
|
727
|
-
values:
|
|
1702
|
+
var metricsMessageSchema = import_zod25.z.object({
|
|
1703
|
+
type: import_zod25.z.literal("METRICS"),
|
|
1704
|
+
payload: import_zod25.z.object({
|
|
1705
|
+
values: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.number())
|
|
728
1706
|
}).strict()
|
|
729
1707
|
}).strict();
|
|
730
|
-
var v2BridgeParentToGameMessageSchema =
|
|
1708
|
+
var v2BridgeParentToGameMessageSchema = import_zod25.z.union([
|
|
731
1709
|
bootstrapMessageSchema,
|
|
732
1710
|
playersUpdateMessageSchema,
|
|
733
1711
|
runtimeStateUpdateMessageSchema,
|
|
@@ -736,24 +1714,24 @@ var v2BridgeParentToGameMessageSchema = import_zod9.z.union([
|
|
|
736
1714
|
resumeMessageSchema,
|
|
737
1715
|
shutdownMessageSchema
|
|
738
1716
|
]);
|
|
739
|
-
var v2BridgeGameToParentMessageSchema =
|
|
1717
|
+
var v2BridgeGameToParentMessageSchema = import_zod25.z.union([
|
|
740
1718
|
readyMessageSchema,
|
|
741
1719
|
statePatchMessageSchema,
|
|
742
1720
|
signalMessageSchema,
|
|
743
1721
|
errorMessageSchema,
|
|
744
1722
|
metricsMessageSchema
|
|
745
1723
|
]);
|
|
746
|
-
var v2BridgeMessageSchema =
|
|
1724
|
+
var v2BridgeMessageSchema = import_zod25.z.union([
|
|
747
1725
|
v2BridgeParentToGameMessageSchema,
|
|
748
1726
|
v2BridgeGameToParentMessageSchema
|
|
749
1727
|
]);
|
|
750
1728
|
|
|
751
1729
|
// src/contracts/v2/handshake.ts
|
|
752
|
-
var
|
|
1730
|
+
var import_zod26 = require("zod");
|
|
753
1731
|
var AIR_JAM_PROTOCOL_V2 = "2";
|
|
754
1732
|
var semanticVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
755
|
-
var v2ProtocolVersionSchema =
|
|
756
|
-
var runtimeKindSchema =
|
|
1733
|
+
var v2ProtocolVersionSchema = import_zod26.z.literal(AIR_JAM_PROTOCOL_V2);
|
|
1734
|
+
var runtimeKindSchema = import_zod26.z.enum([
|
|
757
1735
|
"standalone-host",
|
|
758
1736
|
"standalone-controller",
|
|
759
1737
|
"arcade-runtime",
|
|
@@ -763,12 +1741,12 @@ var runtimeKindSchema = import_zod10.z.enum([
|
|
|
763
1741
|
"arcade-controller-runtime",
|
|
764
1742
|
"arcade-controller-iframe"
|
|
765
1743
|
]);
|
|
766
|
-
var capabilityFlagsSchema =
|
|
767
|
-
var sdkVersionSchema =
|
|
1744
|
+
var capabilityFlagsSchema = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.boolean());
|
|
1745
|
+
var sdkVersionSchema = import_zod26.z.string().regex(
|
|
768
1746
|
semanticVersionPattern,
|
|
769
1747
|
"sdkVersion must use semantic version format (for example 1.2.3)"
|
|
770
1748
|
);
|
|
771
|
-
var v2HandshakeSchema =
|
|
1749
|
+
var v2HandshakeSchema = import_zod26.z.object({
|
|
772
1750
|
protocolVersion: v2ProtocolVersionSchema,
|
|
773
1751
|
sdkVersion: sdkVersionSchema,
|
|
774
1752
|
runtimeKind: runtimeKindSchema,
|
|
@@ -779,38 +1757,38 @@ var v2HandshakeSchema = import_zod10.z.object({
|
|
|
779
1757
|
var AIRJAM_BRIDGE_INIT = "AIRJAM_BRIDGE_INIT";
|
|
780
1758
|
var AIRJAM_SETTINGS_SYNC = "AIRJAM_SETTINGS_SYNC";
|
|
781
1759
|
var AIRJAM_SETTINGS_READY = "AIRJAM_SETTINGS_READY";
|
|
782
|
-
var airJamSettingsSyncSchema =
|
|
783
|
-
type:
|
|
784
|
-
payload:
|
|
785
|
-
settings:
|
|
786
|
-
audio:
|
|
787
|
-
masterVolume:
|
|
788
|
-
musicVolume:
|
|
789
|
-
sfxVolume:
|
|
1760
|
+
var airJamSettingsSyncSchema = import_zod27.z.object({
|
|
1761
|
+
type: import_zod27.z.literal(AIRJAM_SETTINGS_SYNC),
|
|
1762
|
+
payload: import_zod27.z.object({
|
|
1763
|
+
settings: import_zod27.z.object({
|
|
1764
|
+
audio: import_zod27.z.object({
|
|
1765
|
+
masterVolume: import_zod27.z.number(),
|
|
1766
|
+
musicVolume: import_zod27.z.number(),
|
|
1767
|
+
sfxVolume: import_zod27.z.number()
|
|
790
1768
|
}).strict(),
|
|
791
|
-
accessibility:
|
|
792
|
-
reducedMotion:
|
|
793
|
-
highContrast:
|
|
1769
|
+
accessibility: import_zod27.z.object({
|
|
1770
|
+
reducedMotion: import_zod27.z.boolean(),
|
|
1771
|
+
highContrast: import_zod27.z.boolean()
|
|
794
1772
|
}).strict(),
|
|
795
|
-
feedback:
|
|
796
|
-
hapticsEnabled:
|
|
1773
|
+
feedback: import_zod27.z.object({
|
|
1774
|
+
hapticsEnabled: import_zod27.z.boolean()
|
|
797
1775
|
}).strict(),
|
|
798
|
-
previewControllers:
|
|
799
|
-
activeOpacity:
|
|
1776
|
+
previewControllers: import_zod27.z.object({
|
|
1777
|
+
activeOpacity: import_zod27.z.number()
|
|
800
1778
|
}).strict()
|
|
801
1779
|
}).strict()
|
|
802
1780
|
}).strict()
|
|
803
1781
|
}).strict();
|
|
804
|
-
var airJamBridgeInitSchema =
|
|
805
|
-
type:
|
|
806
|
-
payload:
|
|
1782
|
+
var airJamBridgeInitSchema = import_zod27.z.object({
|
|
1783
|
+
type: import_zod27.z.literal(AIRJAM_BRIDGE_INIT),
|
|
1784
|
+
payload: import_zod27.z.object({
|
|
807
1785
|
handshake: v2HandshakeSchema
|
|
808
1786
|
}).strict()
|
|
809
1787
|
}).strict();
|
|
810
|
-
var airJamSettingsReadySchema =
|
|
811
|
-
type:
|
|
812
|
-
payload:
|
|
813
|
-
ready:
|
|
1788
|
+
var airJamSettingsReadySchema = import_zod27.z.object({
|
|
1789
|
+
type: import_zod27.z.literal(AIRJAM_SETTINGS_READY),
|
|
1790
|
+
payload: import_zod27.z.object({
|
|
1791
|
+
ready: import_zod27.z.literal(true)
|
|
814
1792
|
}).strict()
|
|
815
1793
|
}).strict();
|
|
816
1794
|
|
|
@@ -887,6 +1865,7 @@ var isEmbeddedArcadeRuntimeSearchParams = (searchParams) => parseOptionalArcadeS
|
|
|
887
1865
|
var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
888
1866
|
enabled = "auto",
|
|
889
1867
|
topology,
|
|
1868
|
+
isEmbeddedRuntime = typeof window !== "undefined" && window.parent !== window,
|
|
890
1869
|
isDevelopmentRuntime = readDevelopmentRuntime(),
|
|
891
1870
|
searchParams
|
|
892
1871
|
} = {}) => {
|
|
@@ -894,12 +1873,12 @@ var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
|
894
1873
|
return enabled;
|
|
895
1874
|
}
|
|
896
1875
|
const localDevControlSurfacesEnabled = topology != null ? isLocalDevControlSurfaceRuntimeMode(topology.runtimeMode) : isDevelopmentRuntime;
|
|
897
|
-
return localDevControlSurfacesEnabled && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
1876
|
+
return localDevControlSurfacesEnabled && !topology?.embedded && !isEmbeddedRuntime && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
898
1877
|
};
|
|
899
1878
|
|
|
900
1879
|
// src/preview/workspace.tsx
|
|
901
1880
|
var import_lucide_react2 = require("lucide-react");
|
|
902
|
-
var
|
|
1881
|
+
var import_react10 = require("react");
|
|
903
1882
|
var import_react_dom = require("react-dom");
|
|
904
1883
|
|
|
905
1884
|
// src/components/shell-classes.ts
|
|
@@ -936,27 +1915,350 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
936
1915
|
variant: "default",
|
|
937
1916
|
size: "default"
|
|
938
1917
|
}
|
|
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
|
|
1918
|
+
}
|
|
1919
|
+
);
|
|
1920
|
+
function Button({
|
|
1921
|
+
className,
|
|
1922
|
+
variant,
|
|
1923
|
+
size,
|
|
1924
|
+
asChild = false,
|
|
1925
|
+
...props
|
|
1926
|
+
}) {
|
|
1927
|
+
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
1928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1929
|
+
Comp,
|
|
1930
|
+
{
|
|
1931
|
+
"data-slot": "button",
|
|
1932
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
1933
|
+
...props
|
|
1934
|
+
}
|
|
1935
|
+
);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
// src/runtime/local-players.tsx
|
|
1939
|
+
var import_react6 = require("react");
|
|
1940
|
+
|
|
1941
|
+
// src/runtime/local-seats.ts
|
|
1942
|
+
var import_zod31 = require("zod");
|
|
1943
|
+
|
|
1944
|
+
// src/core/local-input.ts
|
|
1945
|
+
var import_zod28 = require("zod");
|
|
1946
|
+
var localInputOperationSchema = import_zod28.z.discriminatedUnion("op", [
|
|
1947
|
+
import_zod28.z.object({
|
|
1948
|
+
op: import_zod28.z.literal("press"),
|
|
1949
|
+
control: import_zod28.z.string(),
|
|
1950
|
+
hold: import_zod28.z.number().int()
|
|
1951
|
+
}).strict(),
|
|
1952
|
+
import_zod28.z.object({
|
|
1953
|
+
op: import_zod28.z.literal("hold"),
|
|
1954
|
+
control: import_zod28.z.string(),
|
|
1955
|
+
value: import_zod28.z.number().min(-1).max(1),
|
|
1956
|
+
hold: import_zod28.z.number().int()
|
|
1957
|
+
}).strict(),
|
|
1958
|
+
import_zod28.z.object({ op: import_zod28.z.literal("release"), hold: import_zod28.z.number().int() }).strict(),
|
|
1959
|
+
import_zod28.z.object({
|
|
1960
|
+
op: import_zod28.z.literal("set"),
|
|
1961
|
+
control: import_zod28.z.string(),
|
|
1962
|
+
value: import_zod28.z.union([
|
|
1963
|
+
import_zod28.z.number().min(-1).max(1),
|
|
1964
|
+
import_zod28.z.object({
|
|
1965
|
+
x: import_zod28.z.number().min(-1).max(1),
|
|
1966
|
+
y: import_zod28.z.number().min(-1).max(1)
|
|
1967
|
+
}).strict()
|
|
1968
|
+
])
|
|
1969
|
+
}).strict(),
|
|
1970
|
+
import_zod28.z.object({ op: import_zod28.z.literal("release-all") }).strict()
|
|
1971
|
+
]);
|
|
1972
|
+
|
|
1973
|
+
// src/preview/identity.ts
|
|
1974
|
+
var AIR_JAM_PREVIEW_FLAG_QUERY_PARAM = "aj_preview";
|
|
1975
|
+
var AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM = "aj_preview_device";
|
|
1976
|
+
var AIR_JAM_PREVIEW_PARENT_QUERY_PARAM = "aj_preview_parent";
|
|
1977
|
+
var AIR_JAM_PREVIEW_CAPTURE_QUERY_PARAM = "aj_preview_capture";
|
|
1978
|
+
var createPreviewControllerDeviceId = () => `pd_${crypto.randomUUID()}`;
|
|
1979
|
+
var normalizePreviewDeviceId = (value) => {
|
|
1980
|
+
if (!value) {
|
|
1981
|
+
return null;
|
|
1982
|
+
}
|
|
1983
|
+
const normalized = value.trim();
|
|
1984
|
+
return normalized.length >= 8 ? normalized : null;
|
|
1985
|
+
};
|
|
1986
|
+
var isPreviewControllerSearchParams = (params) => {
|
|
1987
|
+
const flag = params.get(AIR_JAM_PREVIEW_FLAG_QUERY_PARAM);
|
|
1988
|
+
return flag === "1" || flag === "true";
|
|
1989
|
+
};
|
|
1990
|
+
var readPreviewControllerDeviceIdFromSearchParams = (params) => {
|
|
1991
|
+
if (!isPreviewControllerSearchParams(params)) {
|
|
1992
|
+
return null;
|
|
1993
|
+
}
|
|
1994
|
+
return normalizePreviewDeviceId(
|
|
1995
|
+
params.get(AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM)
|
|
1996
|
+
);
|
|
1997
|
+
};
|
|
1998
|
+
var readPreviewControllerDeviceIdFromLocation = () => {
|
|
1999
|
+
if (typeof window === "undefined") {
|
|
2000
|
+
return null;
|
|
2001
|
+
}
|
|
2002
|
+
return readPreviewControllerDeviceIdFromSearchParams(
|
|
2003
|
+
new URLSearchParams(window.location.search)
|
|
2004
|
+
);
|
|
2005
|
+
};
|
|
2006
|
+
var readPreviewControllerParent = () => {
|
|
2007
|
+
if (typeof window === "undefined" || window.parent === window || readPreviewControllerDeviceIdFromLocation() === null) {
|
|
2008
|
+
return null;
|
|
2009
|
+
}
|
|
2010
|
+
const declared = new URLSearchParams(window.location.search).get(
|
|
2011
|
+
AIR_JAM_PREVIEW_PARENT_QUERY_PARAM
|
|
2012
|
+
);
|
|
2013
|
+
return {
|
|
2014
|
+
window: window.parent,
|
|
2015
|
+
origin: declared ? new URL(declared).origin : window.location.origin
|
|
2016
|
+
};
|
|
2017
|
+
};
|
|
2018
|
+
|
|
2019
|
+
// src/runtime/controller-bridge-context.ts
|
|
2020
|
+
var import_zod30 = require("zod");
|
|
2021
|
+
|
|
2022
|
+
// src/runtime/arcade-surface-identity.ts
|
|
2023
|
+
var import_zod29 = require("zod");
|
|
2024
|
+
var arcadeSurfaceRuntimeIdentitySchema = import_zod29.z.object({
|
|
2025
|
+
epoch: import_zod29.z.number().int().nonnegative(),
|
|
2026
|
+
kind: import_zod29.z.enum(["browser", "game"]),
|
|
2027
|
+
gameId: import_zod29.z.string().nullable()
|
|
2028
|
+
}).strict();
|
|
2029
|
+
|
|
2030
|
+
// src/runtime/controller-bridge-context.ts
|
|
2031
|
+
var controllerBridgeContextSchema = import_zod30.z.union([
|
|
2032
|
+
import_zod30.z.object({ arcadeSurface: arcadeSurfaceRuntimeIdentitySchema }).strict(),
|
|
2033
|
+
import_zod30.z.object({ harnessSessionId: import_zod30.z.uuid() }).strict()
|
|
2034
|
+
]);
|
|
2035
|
+
|
|
2036
|
+
// src/runtime/local-seats.ts
|
|
2037
|
+
var AIR_JAM_LOCAL_SEAT_QUERY_PARAM = "airjamLocalSeat";
|
|
2038
|
+
var seatSchema = import_zod31.z.object({
|
|
2039
|
+
key: import_zod31.z.string().min(1).max(32),
|
|
2040
|
+
label: import_zod31.z.string().min(1).max(32)
|
|
2041
|
+
}).strict();
|
|
2042
|
+
var seatMessage = (type) => import_zod31.z.object({ type: import_zod31.z.literal(type), seat: import_zod31.z.string() }).strict();
|
|
2043
|
+
var phoneReadySchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.ready") }).strict();
|
|
2044
|
+
var phoneInputSchema = import_zod31.z.object({
|
|
2045
|
+
type: import_zod31.z.literal("airjam.local-seat.input"),
|
|
2046
|
+
operation: localInputOperationSchema
|
|
2047
|
+
}).strict();
|
|
2048
|
+
var localSeatKeyboardSchema = import_zod31.z.object({
|
|
2049
|
+
type: import_zod31.z.literal("airjam.local-seat.keyboard"),
|
|
2050
|
+
event: import_zod31.z.discriminatedUnion("kind", [
|
|
2051
|
+
import_zod31.z.object({
|
|
2052
|
+
kind: import_zod31.z.literal("keydown"),
|
|
2053
|
+
code: import_zod31.z.string(),
|
|
2054
|
+
repeat: import_zod31.z.boolean()
|
|
2055
|
+
}).strict(),
|
|
2056
|
+
import_zod31.z.object({ kind: import_zod31.z.literal("keyup"), code: import_zod31.z.string() }).strict(),
|
|
2057
|
+
import_zod31.z.object({ kind: import_zod31.z.literal("blur") }).strict()
|
|
2058
|
+
])
|
|
2059
|
+
}).strict();
|
|
2060
|
+
var availableSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.available") }).strict();
|
|
2061
|
+
var unavailableSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.unavailable") }).strict();
|
|
2062
|
+
var openedSchema = seatMessage("airjam.local-seat.opened");
|
|
2063
|
+
var refusedSchema = seatMessage("airjam.local-seat.refused");
|
|
2064
|
+
var closedSchema = seatMessage("airjam.local-seat.closed");
|
|
2065
|
+
var localSeatRequestSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.request"), seat: seatSchema }).strict();
|
|
2066
|
+
var localSeatQuerySchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.query") }).strict();
|
|
2067
|
+
var relayedSchema = import_zod31.z.object({ type: import_zod31.z.literal("airjam.local-seat.relayed") }).strict();
|
|
2068
|
+
var isLocalSeatRelayedMessage = (data) => relayedSchema.safeParse(data).success;
|
|
2069
|
+
var localSeatRelaySchema = import_zod31.z.object({
|
|
2070
|
+
type: import_zod31.z.literal("airjam.local-seat.input"),
|
|
2071
|
+
seat: import_zod31.z.string(),
|
|
2072
|
+
operation: localInputOperationSchema
|
|
2073
|
+
}).strict();
|
|
2074
|
+
var sendLocalSeatOperation = (frame, origin, operation) => frame.postMessage({ type: "airjam.local-seat.input", operation }, origin);
|
|
2075
|
+
var isLocalSeatReadyMessage = (data) => phoneReadySchema.safeParse(data).success;
|
|
2076
|
+
var localSeatMessages = {
|
|
2077
|
+
available: () => ({ type: "airjam.local-seat.available" }),
|
|
2078
|
+
unavailable: () => ({ type: "airjam.local-seat.unavailable" }),
|
|
2079
|
+
opened: (seat) => ({ type: "airjam.local-seat.opened", seat }),
|
|
2080
|
+
refused: (seat) => ({ type: "airjam.local-seat.refused", seat }),
|
|
2081
|
+
closed: (seat) => ({ type: "airjam.local-seat.closed", seat })
|
|
2082
|
+
};
|
|
2083
|
+
var serveLocalSeats = (game) => {
|
|
2084
|
+
let provider = null;
|
|
2085
|
+
let stopKeyboard;
|
|
2086
|
+
const opened = /* @__PURE__ */ new Map();
|
|
2087
|
+
const opening = /* @__PURE__ */ new Map();
|
|
2088
|
+
const post = (message) => game.window()?.postMessage(message, game.origin);
|
|
2089
|
+
const close = (key, seat) => {
|
|
2090
|
+
if (opened.get(key) !== seat) return;
|
|
2091
|
+
seat.send({ op: "release-all" });
|
|
2092
|
+
opened.delete(key);
|
|
2093
|
+
post(localSeatMessages.closed(key));
|
|
2094
|
+
};
|
|
2095
|
+
const open = (seat) => {
|
|
2096
|
+
if (opened.has(seat.key)) return post(localSeatMessages.opened(seat.key));
|
|
2097
|
+
if (opening.has(seat.key)) return;
|
|
2098
|
+
if (!provider) return post(localSeatMessages.refused(seat.key));
|
|
2099
|
+
const request = {};
|
|
2100
|
+
opening.set(seat.key, request);
|
|
2101
|
+
void provider.open(seat).then((result) => {
|
|
2102
|
+
if (opening.get(seat.key) !== request) return;
|
|
2103
|
+
opening.delete(seat.key);
|
|
2104
|
+
if (!result) return post(localSeatMessages.refused(seat.key));
|
|
2105
|
+
opened.set(seat.key, result);
|
|
2106
|
+
post(localSeatMessages.opened(seat.key));
|
|
2107
|
+
void result.closed.then(() => close(seat.key, result));
|
|
2108
|
+
});
|
|
2109
|
+
};
|
|
2110
|
+
const receive = (event) => {
|
|
2111
|
+
if (event.origin !== game.origin || event.source !== game.window()) return;
|
|
2112
|
+
if (localSeatQuerySchema.safeParse(event.data).success) {
|
|
2113
|
+
if (provider) post(localSeatMessages.available());
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
const request = localSeatRequestSchema.safeParse(event.data);
|
|
2117
|
+
if (request.success) return open(request.data.seat);
|
|
2118
|
+
const relay = localSeatRelaySchema.safeParse(event.data);
|
|
2119
|
+
if (relay.success) opened.get(relay.data.seat)?.send(relay.data.operation);
|
|
2120
|
+
};
|
|
2121
|
+
window.addEventListener("message", receive);
|
|
2122
|
+
const provide = (next) => {
|
|
2123
|
+
if (next === provider) return;
|
|
2124
|
+
const wasAvailable = provider !== null;
|
|
2125
|
+
stopKeyboard?.();
|
|
2126
|
+
provider = next;
|
|
2127
|
+
stopKeyboard = next?.subscribeKeyboard?.(post);
|
|
2128
|
+
for (const key of opening.keys()) post(localSeatMessages.refused(key));
|
|
2129
|
+
opening.clear();
|
|
2130
|
+
for (const [key, seat] of opened) close(key, seat);
|
|
2131
|
+
if (wasAvailable) post(localSeatMessages.unavailable());
|
|
2132
|
+
if (next) post(localSeatMessages.available());
|
|
2133
|
+
};
|
|
2134
|
+
return {
|
|
2135
|
+
provide,
|
|
2136
|
+
stop() {
|
|
2137
|
+
provide(null);
|
|
2138
|
+
window.removeEventListener("message", receive);
|
|
955
2139
|
}
|
|
2140
|
+
};
|
|
2141
|
+
};
|
|
2142
|
+
var isEditable = (target) => target instanceof HTMLElement && (target.isContentEditable || target.closest(
|
|
2143
|
+
"input, select, textarea, [contenteditable]:not([contenteditable=false])"
|
|
2144
|
+
) !== null);
|
|
2145
|
+
var readLocalSeatLabel = () => typeof window === "undefined" ? null : new URLSearchParams(window.location.search).get(
|
|
2146
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM
|
|
2147
|
+
);
|
|
2148
|
+
var localSeatPhoneParent = () => readLocalSeatLabel() === null ? null : readPreviewControllerParent();
|
|
2149
|
+
var relayPhoneKeyboard = (parent) => {
|
|
2150
|
+
const page = window;
|
|
2151
|
+
const held = /* @__PURE__ */ new Set();
|
|
2152
|
+
const send = (event) => parent.window.postMessage(
|
|
2153
|
+
{ type: "airjam.local-seat.keyboard", event },
|
|
2154
|
+
parent.origin
|
|
956
2155
|
);
|
|
957
|
-
|
|
2156
|
+
const keydown = (event) => {
|
|
2157
|
+
if (isEditable(event.target)) return;
|
|
2158
|
+
held.add(event.code);
|
|
2159
|
+
send({ kind: "keydown", code: event.code, repeat: event.repeat });
|
|
2160
|
+
};
|
|
2161
|
+
const keyup = (event) => {
|
|
2162
|
+
if (held.delete(event.code)) send({ kind: "keyup", code: event.code });
|
|
2163
|
+
};
|
|
2164
|
+
const release = () => {
|
|
2165
|
+
if (held.size === 0) return;
|
|
2166
|
+
held.clear();
|
|
2167
|
+
send({ kind: "blur" });
|
|
2168
|
+
};
|
|
2169
|
+
page.addEventListener("keydown", keydown);
|
|
2170
|
+
page.addEventListener("keyup", keyup);
|
|
2171
|
+
page.addEventListener("blur", release);
|
|
2172
|
+
return () => {
|
|
2173
|
+
page.removeEventListener("keydown", keydown);
|
|
2174
|
+
page.removeEventListener("keyup", keyup);
|
|
2175
|
+
page.removeEventListener("blur", release);
|
|
2176
|
+
release();
|
|
2177
|
+
};
|
|
2178
|
+
};
|
|
2179
|
+
var relayLocalSeatInput = (frame) => {
|
|
2180
|
+
const parent = localSeatPhoneParent();
|
|
2181
|
+
if (!parent) return () => {
|
|
2182
|
+
};
|
|
2183
|
+
const stopKeyboard = relayPhoneKeyboard(parent);
|
|
2184
|
+
const onMessage = (event) => {
|
|
2185
|
+
const game = frame.window();
|
|
2186
|
+
if (!game) return;
|
|
2187
|
+
if (event.source === parent.window && event.origin === parent.origin) {
|
|
2188
|
+
const message = phoneInputSchema.safeParse(event.data);
|
|
2189
|
+
if (message.success) game.postMessage(message.data, frame.origin);
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2192
|
+
if (event.source !== game || event.origin !== frame.origin) return;
|
|
2193
|
+
if (isLocalSeatReadyMessage(event.data))
|
|
2194
|
+
parent.window.postMessage(
|
|
2195
|
+
{ type: "airjam.local-seat.ready" },
|
|
2196
|
+
parent.origin
|
|
2197
|
+
);
|
|
2198
|
+
const keyboard = localSeatKeyboardSchema.safeParse(event.data);
|
|
2199
|
+
if (keyboard.success)
|
|
2200
|
+
parent.window.postMessage(keyboard.data, parent.origin);
|
|
2201
|
+
};
|
|
2202
|
+
window.addEventListener("message", onMessage);
|
|
2203
|
+
return () => {
|
|
2204
|
+
window.removeEventListener("message", onMessage);
|
|
2205
|
+
stopKeyboard();
|
|
2206
|
+
};
|
|
2207
|
+
};
|
|
2208
|
+
|
|
2209
|
+
// src/runtime/local-players.tsx
|
|
2210
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2211
|
+
var localSeatRegistry = (0, import_react6.createContext)(null);
|
|
2212
|
+
var useProvideLocalSeats = (provider) => {
|
|
2213
|
+
const register = (0, import_react6.useContext)(localSeatRegistry);
|
|
2214
|
+
(0, import_react6.useEffect)(() => {
|
|
2215
|
+
if (!register || !provider) return;
|
|
2216
|
+
register(provider);
|
|
2217
|
+
return () => register(null);
|
|
2218
|
+
}, [register, provider]);
|
|
2219
|
+
};
|
|
2220
|
+
var useServeLocalSeats = (game, provider) => {
|
|
2221
|
+
const server = (0, import_react6.useRef)(null);
|
|
2222
|
+
(0, import_react6.useEffect)(() => {
|
|
2223
|
+
if (!game) return;
|
|
2224
|
+
const served = serveLocalSeats(game);
|
|
2225
|
+
server.current = served;
|
|
2226
|
+
return () => {
|
|
2227
|
+
served.stop();
|
|
2228
|
+
server.current = null;
|
|
2229
|
+
};
|
|
2230
|
+
}, [game]);
|
|
2231
|
+
(0, import_react6.useEffect)(() => server.current?.provide(provider), [game, provider]);
|
|
2232
|
+
};
|
|
2233
|
+
|
|
2234
|
+
// src/components/surface-viewport-layout.ts
|
|
2235
|
+
var CONTROLLER_REFERENCE_SIZE = {
|
|
2236
|
+
portrait: {
|
|
2237
|
+
width: 412,
|
|
2238
|
+
height: 915
|
|
2239
|
+
},
|
|
2240
|
+
landscape: {
|
|
2241
|
+
width: 915,
|
|
2242
|
+
height: 412
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
var HOST_REFERENCE_SIZE = {
|
|
2246
|
+
portrait: {
|
|
2247
|
+
width: 900,
|
|
2248
|
+
height: 1600
|
|
2249
|
+
},
|
|
2250
|
+
landscape: {
|
|
2251
|
+
width: 1600,
|
|
2252
|
+
height: 900
|
|
2253
|
+
}
|
|
2254
|
+
};
|
|
2255
|
+
var SURFACE_VIEWPORT_REFERENCE_SIZES = {
|
|
2256
|
+
controller: CONTROLLER_REFERENCE_SIZE,
|
|
2257
|
+
host: HOST_REFERENCE_SIZE
|
|
2258
|
+
};
|
|
958
2259
|
|
|
959
2260
|
// src/preview/layout.ts
|
|
2261
|
+
var getPreviewHostViewportSize = () => SURFACE_VIEWPORT_REFERENCE_SIZES.host.landscape;
|
|
960
2262
|
var PREVIEW_WORKSPACE_Z_INDEX = 2147483e3;
|
|
961
2263
|
var PREVIEW_WINDOW_TITLEBAR_HEIGHT = 38;
|
|
962
2264
|
var PREVIEW_WINDOW_RESIZE_EDGE_HIT_SIZE = 12;
|
|
@@ -1084,76 +2386,34 @@ var getResizedPreviewBounds = (bounds, handle, deltaX, deltaY) => {
|
|
|
1084
2386
|
};
|
|
1085
2387
|
|
|
1086
2388
|
// 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
|
-
};
|
|
2389
|
+
var import_react7 = require("react");
|
|
1116
2390
|
|
|
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
|
-
};
|
|
2391
|
+
// src/preview/messages.ts
|
|
2392
|
+
var AIR_JAM_PREVIEW_CLOSE_REQUEST = "airjam.preview.close.request";
|
|
2393
|
+
var AIR_JAM_PREVIEW_CLOSE_RESULT = "airjam.preview.close.result";
|
|
2394
|
+
var AIR_JAM_PREVIEW_SEAT = "airjam.preview.seat";
|
|
2395
|
+
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);
|
|
2396
|
+
var isPreviewCloseResultMessage = (value) => typeof value === "object" && value !== null && value.type === AIR_JAM_PREVIEW_CLOSE_RESULT && typeof value.ok === "boolean";
|
|
2397
|
+
async function requestPreviewControllerClose(iframe, sessionUrl) {
|
|
2398
|
+
const frameWindow = iframe?.contentWindow;
|
|
2399
|
+
if (!frameWindow) return false;
|
|
2400
|
+
const origin = new URL(sessionUrl).origin;
|
|
2401
|
+
return new Promise((resolve) => {
|
|
2402
|
+
const finish = (closed) => {
|
|
2403
|
+
window.clearTimeout(timeout);
|
|
2404
|
+
window.removeEventListener("message", onMessage);
|
|
2405
|
+
resolve(closed);
|
|
2406
|
+
};
|
|
2407
|
+
const onMessage = (event) => {
|
|
2408
|
+
if (event.source !== frameWindow || event.origin !== origin || !isPreviewCloseResultMessage(event.data))
|
|
2409
|
+
return;
|
|
2410
|
+
finish(event.data.ok);
|
|
2411
|
+
};
|
|
2412
|
+
const timeout = window.setTimeout(() => finish(false), 1e3);
|
|
2413
|
+
window.addEventListener("message", onMessage);
|
|
2414
|
+
frameWindow.postMessage({ type: AIR_JAM_PREVIEW_CLOSE_REQUEST }, origin);
|
|
2415
|
+
});
|
|
2416
|
+
}
|
|
1157
2417
|
|
|
1158
2418
|
// src/preview/url.ts
|
|
1159
2419
|
var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
@@ -1164,10 +2424,12 @@ var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
|
1164
2424
|
};
|
|
1165
2425
|
var buildPreviewControllerUrl = ({
|
|
1166
2426
|
joinUrl,
|
|
1167
|
-
controllerId,
|
|
1168
2427
|
previewDeviceId,
|
|
1169
2428
|
allowedOrigins,
|
|
1170
|
-
embedOrigin
|
|
2429
|
+
embedOrigin,
|
|
2430
|
+
parentOrigin,
|
|
2431
|
+
localSeat,
|
|
2432
|
+
capture
|
|
1171
2433
|
}) => {
|
|
1172
2434
|
const normalizedJoinUrl = normalizeRuntimeUrl(joinUrl);
|
|
1173
2435
|
if (!normalizedJoinUrl) {
|
|
@@ -1186,41 +2448,49 @@ var buildPreviewControllerUrl = ({
|
|
|
1186
2448
|
if (!normalizedEmbedOrigin) {
|
|
1187
2449
|
return null;
|
|
1188
2450
|
}
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
2451
|
+
const { pathname, search, hash } = new URL(normalizedJoinUrl);
|
|
2452
|
+
return new URL(
|
|
2453
|
+
`${pathname}${search}${hash}`,
|
|
2454
|
+
normalizedEmbedOrigin
|
|
2455
|
+
).toString();
|
|
1194
2456
|
})();
|
|
1195
2457
|
if (!previewBaseUrl) {
|
|
1196
2458
|
return null;
|
|
1197
2459
|
}
|
|
2460
|
+
const normalizedParentOrigin = parentOrigin ? getRuntimeUrlOrigin(parentOrigin) : null;
|
|
2461
|
+
if (parentOrigin && !normalizedParentOrigin) {
|
|
2462
|
+
return null;
|
|
2463
|
+
}
|
|
1198
2464
|
return appendRuntimeQueryParams(previewBaseUrl, {
|
|
1199
|
-
controllerId,
|
|
1200
2465
|
[AIR_JAM_PREVIEW_FLAG_QUERY_PARAM]: "1",
|
|
1201
|
-
[AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM]: previewDeviceId
|
|
2466
|
+
[AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM]: previewDeviceId,
|
|
2467
|
+
[AIR_JAM_PREVIEW_PARENT_QUERY_PARAM]: normalizedParentOrigin,
|
|
2468
|
+
[AIR_JAM_LOCAL_SEAT_QUERY_PARAM]: localSeat,
|
|
2469
|
+
[AIR_JAM_PREVIEW_CAPTURE_QUERY_PARAM]: capture ? "1" : null
|
|
1202
2470
|
});
|
|
1203
2471
|
};
|
|
1204
2472
|
var createPreviewControllerLaunch = ({
|
|
1205
2473
|
joinUrl,
|
|
1206
2474
|
allowedOrigins,
|
|
1207
|
-
embedOrigin
|
|
2475
|
+
embedOrigin,
|
|
2476
|
+
parentOrigin,
|
|
2477
|
+
localSeat,
|
|
2478
|
+
capture
|
|
1208
2479
|
}) => {
|
|
1209
|
-
const
|
|
2480
|
+
const deviceId = createPreviewControllerDeviceId();
|
|
1210
2481
|
const url = buildPreviewControllerUrl({
|
|
1211
2482
|
joinUrl,
|
|
1212
|
-
|
|
1213
|
-
previewDeviceId: identity.deviceId,
|
|
2483
|
+
previewDeviceId: deviceId,
|
|
1214
2484
|
allowedOrigins,
|
|
1215
|
-
embedOrigin
|
|
2485
|
+
embedOrigin,
|
|
2486
|
+
parentOrigin,
|
|
2487
|
+
localSeat,
|
|
2488
|
+
capture
|
|
1216
2489
|
});
|
|
1217
2490
|
if (!url) {
|
|
1218
2491
|
return null;
|
|
1219
2492
|
}
|
|
1220
|
-
return {
|
|
1221
|
-
...identity,
|
|
1222
|
-
url
|
|
1223
|
-
};
|
|
2493
|
+
return { deviceId, url };
|
|
1224
2494
|
};
|
|
1225
2495
|
|
|
1226
2496
|
// src/preview/manager.ts
|
|
@@ -1228,6 +2498,7 @@ var DEFAULT_VIEWPORT_WIDTH = 1440;
|
|
|
1228
2498
|
var DEFAULT_VIEWPORT_HEIGHT = 900;
|
|
1229
2499
|
var PREVIEW_WINDOW_MARGIN = 24;
|
|
1230
2500
|
var PREVIEW_WINDOW_CASCADE_OFFSET = 28;
|
|
2501
|
+
var PREVIEW_WINDOW_DOCK_GAP = 12;
|
|
1231
2502
|
var DEFAULT_PREVIEW_CONTROLLER_ORIENTATION = "portrait";
|
|
1232
2503
|
var getViewportSize = () => {
|
|
1233
2504
|
if (typeof window === "undefined") {
|
|
@@ -1334,27 +2605,55 @@ var clampBounds = (orientation, bounds, options = {}, currentBounds) => {
|
|
|
1334
2605
|
height
|
|
1335
2606
|
};
|
|
1336
2607
|
};
|
|
1337
|
-
var
|
|
2608
|
+
var overlap = (start, size, otherStart, otherSize) => Math.max(
|
|
2609
|
+
0,
|
|
2610
|
+
Math.min(start + size, otherStart + otherSize) - Math.max(start, otherStart)
|
|
2611
|
+
);
|
|
2612
|
+
var getInitialWindowBounds = (sessions, orientation, seat) => {
|
|
1338
2613
|
const viewport = getViewportSize();
|
|
1339
|
-
|
|
2614
|
+
if (!seat) {
|
|
2615
|
+
const bounds2 = getPreviewWindowBounds(
|
|
2616
|
+
orientation,
|
|
2617
|
+
DEFAULT_PREVIEW_CONTROLLER_SCALE
|
|
2618
|
+
);
|
|
2619
|
+
const offset = Math.min(sessions.length, 3) * PREVIEW_WINDOW_CASCADE_OFFSET;
|
|
2620
|
+
return {
|
|
2621
|
+
...bounds2,
|
|
2622
|
+
...clampPosition(
|
|
2623
|
+
orientation,
|
|
2624
|
+
(viewport.width - bounds2.width) / 2 + offset,
|
|
2625
|
+
(viewport.height - bounds2.height) / 2 + offset,
|
|
2626
|
+
bounds2.width,
|
|
2627
|
+
bounds2.height
|
|
2628
|
+
)
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
const bounds = getPreviewWindowBounds(
|
|
1340
2632
|
orientation,
|
|
1341
|
-
|
|
2633
|
+
PREVIEW_CONTROLLER_MIN_SCALE
|
|
1342
2634
|
);
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
2635
|
+
const dock = seat.dock ?? { right: viewport.width, top: viewport.height };
|
|
2636
|
+
const place = (index) => ({
|
|
2637
|
+
...bounds,
|
|
2638
|
+
...clampPosition(
|
|
2639
|
+
orientation,
|
|
2640
|
+
index % 2 === 0 ? dock.right - bounds.width : viewport.width - dock.right,
|
|
2641
|
+
dock.top - (bounds.height + PREVIEW_WINDOW_DOCK_GAP) * (Math.floor(index / 2) + 1),
|
|
2642
|
+
bounds.width,
|
|
2643
|
+
bounds.height
|
|
2644
|
+
)
|
|
2645
|
+
});
|
|
2646
|
+
const seatPhones = sessions.filter((session) => session.localSeat);
|
|
2647
|
+
const coveredArea = (candidate) => seatPhones.reduce(
|
|
2648
|
+
(area, phone) => area + overlap(candidate.x, candidate.width, phone.x, phone.width) * overlap(candidate.y, candidate.height, phone.y, phone.height),
|
|
2649
|
+
0
|
|
2650
|
+
);
|
|
2651
|
+
return Array.from(
|
|
2652
|
+
{ length: seatPhones.length + 1 },
|
|
2653
|
+
(_, index) => place(index)
|
|
2654
|
+
).reduce(
|
|
2655
|
+
(best, candidate) => coveredArea(candidate) < coveredArea(best) ? candidate : best
|
|
1353
2656
|
);
|
|
1354
|
-
return {
|
|
1355
|
-
x: anchored.x,
|
|
1356
|
-
y: anchored.y
|
|
1357
|
-
};
|
|
1358
2657
|
};
|
|
1359
2658
|
var getNextTopSessionId = (sessions) => sessions.filter((session) => !session.minimized).sort((left, right) => right.zIndex - left.zIndex)[0]?.id ?? null;
|
|
1360
2659
|
var activateSession = (sessions, id, nextZIndex) => sessions.map(
|
|
@@ -1373,21 +2672,55 @@ var normalizeActiveSession = (sessions) => {
|
|
|
1373
2672
|
}));
|
|
1374
2673
|
};
|
|
1375
2674
|
var mapSessionsAndNormalizeActive = (sessions, mapSession) => normalizeActiveSession(sessions.map(mapSession));
|
|
2675
|
+
var orientSession = (session, nextOrientation) => {
|
|
2676
|
+
const centerX = session.x + session.width / 2;
|
|
2677
|
+
const centerY = session.y + session.height / 2;
|
|
2678
|
+
const nextWindowBounds = getPreviewWindowBounds(
|
|
2679
|
+
nextOrientation,
|
|
2680
|
+
session.displayScale
|
|
2681
|
+
);
|
|
2682
|
+
const nextBounds = clampBounds(
|
|
2683
|
+
nextOrientation,
|
|
2684
|
+
{
|
|
2685
|
+
x: centerX - nextWindowBounds.width / 2,
|
|
2686
|
+
y: centerY - nextWindowBounds.height / 2,
|
|
2687
|
+
width: nextWindowBounds.width,
|
|
2688
|
+
height: nextWindowBounds.height
|
|
2689
|
+
},
|
|
2690
|
+
{}
|
|
2691
|
+
);
|
|
2692
|
+
const clampedWindowBounds = getPreviewWindowBounds(
|
|
2693
|
+
nextOrientation,
|
|
2694
|
+
getPreviewControllerScaleForBounds(nextOrientation, nextBounds)
|
|
2695
|
+
);
|
|
2696
|
+
return {
|
|
2697
|
+
...session,
|
|
2698
|
+
orientation: nextOrientation,
|
|
2699
|
+
x: nextBounds.x,
|
|
2700
|
+
y: nextBounds.y,
|
|
2701
|
+
width: clampedWindowBounds.width,
|
|
2702
|
+
height: clampedWindowBounds.height,
|
|
2703
|
+
viewportWidth: clampedWindowBounds.viewportWidth,
|
|
2704
|
+
viewportHeight: clampedWindowBounds.viewportHeight,
|
|
2705
|
+
displayScale: clampedWindowBounds.displayScale
|
|
2706
|
+
};
|
|
2707
|
+
};
|
|
1376
2708
|
var usePreviewControllerManager = ({
|
|
1377
2709
|
joinUrl,
|
|
1378
2710
|
enabled = true,
|
|
1379
2711
|
maxControllers = 2,
|
|
1380
2712
|
allowedOrigins,
|
|
1381
|
-
embedOrigin
|
|
2713
|
+
embedOrigin,
|
|
2714
|
+
fixedControllerOrientation = null
|
|
1382
2715
|
}) => {
|
|
1383
|
-
const [sessions, setSessions] = (0,
|
|
1384
|
-
const nextSessionIdRef = (0,
|
|
1385
|
-
const nextOrdinalRef = (0,
|
|
1386
|
-
const nextZIndexRef = (0,
|
|
1387
|
-
const previousJoinRoomRef = (0,
|
|
2716
|
+
const [sessions, setSessions] = (0, import_react7.useState)([]);
|
|
2717
|
+
const nextSessionIdRef = (0, import_react7.useRef)(1);
|
|
2718
|
+
const nextOrdinalRef = (0, import_react7.useRef)(1);
|
|
2719
|
+
const nextZIndexRef = (0, import_react7.useRef)(1);
|
|
2720
|
+
const previousJoinRoomRef = (0, import_react7.useRef)(
|
|
1388
2721
|
getJoinRoomIdentity(joinUrl)
|
|
1389
2722
|
);
|
|
1390
|
-
(0,
|
|
2723
|
+
(0, import_react7.useEffect)(() => {
|
|
1391
2724
|
const nextJoinRoom = getJoinRoomIdentity(joinUrl);
|
|
1392
2725
|
const previousJoinRoom = previousJoinRoomRef.current;
|
|
1393
2726
|
if (!enabled || previousJoinRoom !== null && nextJoinRoom !== null && previousJoinRoom !== nextJoinRoom) {
|
|
@@ -1399,71 +2732,83 @@ var usePreviewControllerManager = ({
|
|
|
1399
2732
|
previousJoinRoomRef.current = nextJoinRoom;
|
|
1400
2733
|
}, [enabled, joinUrl]);
|
|
1401
2734
|
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;
|
|
2735
|
+
const spawnPreviewController = (0, import_react7.useCallback)(
|
|
2736
|
+
(options) => {
|
|
2737
|
+
if (!enabled || !joinUrl) {
|
|
2738
|
+
return null;
|
|
1410
2739
|
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
2740
|
+
let nextSession = null;
|
|
2741
|
+
setSessions((current) => {
|
|
2742
|
+
if (current.length >= maxControllers) {
|
|
2743
|
+
return current;
|
|
2744
|
+
}
|
|
2745
|
+
const launch = createPreviewControllerLaunch({
|
|
2746
|
+
joinUrl,
|
|
2747
|
+
allowedOrigins,
|
|
2748
|
+
embedOrigin,
|
|
2749
|
+
localSeat: options?.localSeat?.label
|
|
2750
|
+
});
|
|
2751
|
+
if (!launch) {
|
|
2752
|
+
return current;
|
|
2753
|
+
}
|
|
2754
|
+
const ordinal = nextOrdinalRef.current++;
|
|
2755
|
+
const zIndex = nextZIndexRef.current++;
|
|
2756
|
+
const sessionId = `preview_session_${nextSessionIdRef.current++}`;
|
|
2757
|
+
const orientation = fixedControllerOrientation ?? DEFAULT_PREVIEW_CONTROLLER_ORIENTATION;
|
|
2758
|
+
const bounds = getInitialWindowBounds(
|
|
2759
|
+
current,
|
|
2760
|
+
orientation,
|
|
2761
|
+
options?.localSeat ? { dock: options.dock } : null
|
|
2762
|
+
);
|
|
2763
|
+
nextSession = {
|
|
2764
|
+
id: sessionId,
|
|
2765
|
+
ordinal,
|
|
2766
|
+
label: options?.localSeat?.label ?? `Preview ${ordinal}`,
|
|
2767
|
+
localSeat: options?.localSeat ?? null,
|
|
2768
|
+
seat: null,
|
|
2769
|
+
deviceId: launch.deviceId,
|
|
2770
|
+
url: launch.url,
|
|
2771
|
+
surfaceState: "loading",
|
|
2772
|
+
orientation,
|
|
2773
|
+
minimized: false,
|
|
2774
|
+
active: true,
|
|
2775
|
+
x: bounds.x,
|
|
2776
|
+
y: bounds.y,
|
|
2777
|
+
width: bounds.width,
|
|
2778
|
+
height: bounds.height,
|
|
2779
|
+
viewportWidth: bounds.viewportWidth,
|
|
2780
|
+
viewportHeight: bounds.viewportHeight,
|
|
2781
|
+
displayScale: bounds.displayScale,
|
|
2782
|
+
zIndex
|
|
2783
|
+
};
|
|
2784
|
+
return [
|
|
2785
|
+
...current.map((session) => ({ ...session, active: false })),
|
|
2786
|
+
nextSession
|
|
2787
|
+
];
|
|
1415
2788
|
});
|
|
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) => {
|
|
2789
|
+
return nextSession;
|
|
2790
|
+
},
|
|
2791
|
+
[
|
|
2792
|
+
allowedOrigins,
|
|
2793
|
+
embedOrigin,
|
|
2794
|
+
enabled,
|
|
2795
|
+
joinUrl,
|
|
2796
|
+
maxControllers,
|
|
2797
|
+
fixedControllerOrientation
|
|
2798
|
+
]
|
|
2799
|
+
);
|
|
2800
|
+
const removePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1456
2801
|
setSessions(
|
|
1457
2802
|
(current) => normalizeActiveSession(current.filter((session) => session.id !== id))
|
|
1458
2803
|
);
|
|
1459
2804
|
}, []);
|
|
1460
|
-
const clearPreviewControllers = (0,
|
|
2805
|
+
const clearPreviewControllers = (0, import_react7.useCallback)(() => {
|
|
1461
2806
|
setSessions([]);
|
|
1462
2807
|
nextSessionIdRef.current = 1;
|
|
1463
2808
|
nextOrdinalRef.current = 1;
|
|
1464
2809
|
nextZIndexRef.current = 1;
|
|
1465
2810
|
}, []);
|
|
1466
|
-
const minimizePreviewController = (0,
|
|
2811
|
+
const minimizePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1467
2812
|
setSessions(
|
|
1468
2813
|
(current) => normalizeActiveSession(
|
|
1469
2814
|
current.map(
|
|
@@ -1472,15 +2817,15 @@ var usePreviewControllerManager = ({
|
|
|
1472
2817
|
)
|
|
1473
2818
|
);
|
|
1474
2819
|
}, []);
|
|
1475
|
-
const focusPreviewController = (0,
|
|
2820
|
+
const focusPreviewController = (0, import_react7.useCallback)((id) => {
|
|
1476
2821
|
const nextZIndex = nextZIndexRef.current++;
|
|
1477
2822
|
setSessions((current) => activateSession(current, id, nextZIndex));
|
|
1478
2823
|
}, []);
|
|
1479
|
-
const restorePreviewController = (0,
|
|
2824
|
+
const restorePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1480
2825
|
const nextZIndex = nextZIndexRef.current++;
|
|
1481
2826
|
setSessions((current) => activateSession(current, id, nextZIndex));
|
|
1482
2827
|
}, []);
|
|
1483
|
-
const setPreviewControllerPosition = (0,
|
|
2828
|
+
const setPreviewControllerPosition = (0, import_react7.useCallback)(
|
|
1484
2829
|
(id, x, y) => {
|
|
1485
2830
|
setSessions(
|
|
1486
2831
|
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
@@ -1504,7 +2849,7 @@ var usePreviewControllerManager = ({
|
|
|
1504
2849
|
},
|
|
1505
2850
|
[]
|
|
1506
2851
|
);
|
|
1507
|
-
const setPreviewControllerBounds = (0,
|
|
2852
|
+
const setPreviewControllerBounds = (0, import_react7.useCallback)(
|
|
1508
2853
|
(id, bounds, options = {}) => {
|
|
1509
2854
|
setSessions(
|
|
1510
2855
|
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
@@ -1536,48 +2881,43 @@ var usePreviewControllerManager = ({
|
|
|
1536
2881
|
},
|
|
1537
2882
|
[]
|
|
1538
2883
|
);
|
|
1539
|
-
const rotatePreviewController = (0,
|
|
2884
|
+
const rotatePreviewController = (0, import_react7.useCallback)(
|
|
2885
|
+
(id) => {
|
|
2886
|
+
if (fixedControllerOrientation) return;
|
|
2887
|
+
setSessions(
|
|
2888
|
+
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
2889
|
+
if (session.id !== id) {
|
|
2890
|
+
return session;
|
|
2891
|
+
}
|
|
2892
|
+
const nextOrientation = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
2893
|
+
return orientSession(session, nextOrientation);
|
|
2894
|
+
})
|
|
2895
|
+
);
|
|
2896
|
+
},
|
|
2897
|
+
[fixedControllerOrientation]
|
|
2898
|
+
);
|
|
2899
|
+
(0, import_react7.useEffect)(() => {
|
|
2900
|
+
if (!fixedControllerOrientation) return;
|
|
1540
2901
|
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
|
-
})
|
|
2902
|
+
(current) => current.map(
|
|
2903
|
+
(session) => session.orientation === fixedControllerOrientation ? session : orientSession(session, fixedControllerOrientation)
|
|
2904
|
+
)
|
|
1578
2905
|
);
|
|
2906
|
+
}, [fixedControllerOrientation]);
|
|
2907
|
+
(0, import_react7.useEffect)(() => {
|
|
2908
|
+
const onMessage = (event) => {
|
|
2909
|
+
if (!isPreviewSeatMessage(event.data)) return;
|
|
2910
|
+
const { deviceId, seat } = event.data;
|
|
2911
|
+
setSessions(
|
|
2912
|
+
(current) => current.map(
|
|
2913
|
+
(session) => session.deviceId === deviceId && new URL(session.url).origin === event.origin && session.seat !== seat ? { ...session, seat } : session
|
|
2914
|
+
)
|
|
2915
|
+
);
|
|
2916
|
+
};
|
|
2917
|
+
window.addEventListener("message", onMessage);
|
|
2918
|
+
return () => window.removeEventListener("message", onMessage);
|
|
1579
2919
|
}, []);
|
|
1580
|
-
const markPreviewControllerReady = (0,
|
|
2920
|
+
const markPreviewControllerReady = (0, import_react7.useCallback)((id) => {
|
|
1581
2921
|
setSessions(
|
|
1582
2922
|
(current) => mapSessionsAndNormalizeActive(
|
|
1583
2923
|
current,
|
|
@@ -1585,7 +2925,7 @@ var usePreviewControllerManager = ({
|
|
|
1585
2925
|
)
|
|
1586
2926
|
);
|
|
1587
2927
|
}, []);
|
|
1588
|
-
const markPreviewControllerFailed = (0,
|
|
2928
|
+
const markPreviewControllerFailed = (0, import_react7.useCallback)((id) => {
|
|
1589
2929
|
setSessions(
|
|
1590
2930
|
(current) => mapSessionsAndNormalizeActive(
|
|
1591
2931
|
current,
|
|
@@ -1612,12 +2952,12 @@ var usePreviewControllerManager = ({
|
|
|
1612
2952
|
|
|
1613
2953
|
// src/preview/window.tsx
|
|
1614
2954
|
var import_lucide_react = require("lucide-react");
|
|
1615
|
-
var
|
|
2955
|
+
var import_react8 = require("react");
|
|
1616
2956
|
|
|
1617
2957
|
// src/components/ui/slider.tsx
|
|
1618
2958
|
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"), 1);
|
|
1619
2959
|
var React = __toESM(require("react"), 1);
|
|
1620
|
-
var
|
|
2960
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1621
2961
|
function Slider({
|
|
1622
2962
|
className,
|
|
1623
2963
|
defaultValue,
|
|
@@ -1630,7 +2970,7 @@ function Slider({
|
|
|
1630
2970
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1631
2971
|
[value, defaultValue, min, max]
|
|
1632
2972
|
);
|
|
1633
|
-
return /* @__PURE__ */ (0,
|
|
2973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1634
2974
|
SliderPrimitive.Root,
|
|
1635
2975
|
{
|
|
1636
2976
|
"data-slot": "slider",
|
|
@@ -1644,14 +2984,14 @@ function Slider({
|
|
|
1644
2984
|
),
|
|
1645
2985
|
...props,
|
|
1646
2986
|
children: [
|
|
1647
|
-
/* @__PURE__ */ (0,
|
|
2987
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1648
2988
|
SliderPrimitive.Track,
|
|
1649
2989
|
{
|
|
1650
2990
|
"data-slot": "slider-track",
|
|
1651
2991
|
className: cn(
|
|
1652
2992
|
"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
2993
|
),
|
|
1654
|
-
children: /* @__PURE__ */ (0,
|
|
2994
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1655
2995
|
SliderPrimitive.Range,
|
|
1656
2996
|
{
|
|
1657
2997
|
"data-slot": "slider-range",
|
|
@@ -1662,7 +3002,7 @@ function Slider({
|
|
|
1662
3002
|
)
|
|
1663
3003
|
}
|
|
1664
3004
|
),
|
|
1665
|
-
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0,
|
|
3005
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1666
3006
|
SliderPrimitive.Thumb,
|
|
1667
3007
|
{
|
|
1668
3008
|
"data-slot": "slider-thumb",
|
|
@@ -1675,54 +3015,9 @@ function Slider({
|
|
|
1675
3015
|
);
|
|
1676
3016
|
}
|
|
1677
3017
|
|
|
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
3018
|
// src/preview/window.tsx
|
|
1684
|
-
var
|
|
3019
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1685
3020
|
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
3021
|
var previewControllerWindowStateLabel = {
|
|
1727
3022
|
loading: "Loading",
|
|
1728
3023
|
ready: "Ready",
|
|
@@ -1812,8 +3107,10 @@ var RESIZE_HANDLES = [
|
|
|
1812
3107
|
];
|
|
1813
3108
|
var PreviewControllerWindow = ({
|
|
1814
3109
|
session,
|
|
3110
|
+
frameRef,
|
|
1815
3111
|
activeOpacity,
|
|
1816
3112
|
highContrast = false,
|
|
3113
|
+
fixedControllerOrientation = null,
|
|
1817
3114
|
dragging = false,
|
|
1818
3115
|
onFocus,
|
|
1819
3116
|
onMinimize,
|
|
@@ -1832,9 +3129,9 @@ var PreviewControllerWindow = ({
|
|
|
1832
3129
|
onResizePointerCancel,
|
|
1833
3130
|
resizing = false
|
|
1834
3131
|
}) => {
|
|
1835
|
-
const [windowHovered, setWindowHovered] = (0,
|
|
1836
|
-
const [settingsOpen, setSettingsOpen] = (0,
|
|
1837
|
-
const iframeRef = (0,
|
|
3132
|
+
const [windowHovered, setWindowHovered] = (0, import_react8.useState)(false);
|
|
3133
|
+
const [settingsOpen, setSettingsOpen] = (0, import_react8.useState)(false);
|
|
3134
|
+
const iframeRef = (0, import_react8.useRef)(null);
|
|
1838
3135
|
const isVisible = dragging || resizing || windowHovered;
|
|
1839
3136
|
const windowOpacity = isVisible ? activeOpacity : Math.min(activeOpacity, 0.62);
|
|
1840
3137
|
const settingsShelfHeight = settingsOpen && onActiveOpacityChange ? PREVIEW_WINDOW_SETTINGS_SHELF_HEIGHT : 0;
|
|
@@ -1844,10 +3141,11 @@ var PreviewControllerWindow = ({
|
|
|
1844
3141
|
);
|
|
1845
3142
|
const nextOrientationLabel = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
1846
3143
|
const statusToneClassName = session.surfaceState === "failed" ? "bg-amber-300" : session.surfaceState === "ready" ? "bg-emerald-300" : "bg-white/45";
|
|
1847
|
-
return /* @__PURE__ */ (0,
|
|
3144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1848
3145
|
"div",
|
|
1849
3146
|
{
|
|
1850
3147
|
className: "absolute",
|
|
3148
|
+
hidden: session.minimized,
|
|
1851
3149
|
style: {
|
|
1852
3150
|
left: session.x,
|
|
1853
3151
|
top: session.y,
|
|
@@ -1859,7 +3157,7 @@ var PreviewControllerWindow = ({
|
|
|
1859
3157
|
onPointerEnter: () => setWindowHovered(true),
|
|
1860
3158
|
onPointerLeave: () => setWindowHovered(false),
|
|
1861
3159
|
children: [
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
3160
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1863
3161
|
"section",
|
|
1864
3162
|
{
|
|
1865
3163
|
className: cn(
|
|
@@ -1875,7 +3173,7 @@ var PreviewControllerWindow = ({
|
|
|
1875
3173
|
pointerEvents: "auto"
|
|
1876
3174
|
},
|
|
1877
3175
|
children: [
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
3176
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1879
3177
|
"div",
|
|
1880
3178
|
{
|
|
1881
3179
|
className: "flex h-9 items-center gap-2 border-b border-white/8 px-2.5",
|
|
@@ -1889,10 +3187,10 @@ var PreviewControllerWindow = ({
|
|
|
1889
3187
|
onPointerUp: onTitlePointerUp,
|
|
1890
3188
|
onPointerCancel: onTitlePointerCancel,
|
|
1891
3189
|
children: [
|
|
1892
|
-
/* @__PURE__ */ (0,
|
|
1893
|
-
/* @__PURE__ */ (0,
|
|
1894
|
-
/* @__PURE__ */ (0,
|
|
1895
|
-
/* @__PURE__ */ (0,
|
|
3190
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
3191
|
+
/* @__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" }) }),
|
|
3192
|
+
/* @__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 }) }),
|
|
3193
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1896
3194
|
"span",
|
|
1897
3195
|
{
|
|
1898
3196
|
className: cn(
|
|
@@ -1903,8 +3201,8 @@ var PreviewControllerWindow = ({
|
|
|
1903
3201
|
}
|
|
1904
3202
|
)
|
|
1905
3203
|
] }),
|
|
1906
|
-
/* @__PURE__ */ (0,
|
|
1907
|
-
/* @__PURE__ */ (0,
|
|
3204
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3205
|
+
!fixedControllerOrientation && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1908
3206
|
Button,
|
|
1909
3207
|
{
|
|
1910
3208
|
type: "button",
|
|
@@ -1916,10 +3214,10 @@ var PreviewControllerWindow = ({
|
|
|
1916
3214
|
onClick: onRotate,
|
|
1917
3215
|
"aria-label": `Rotate ${session.label} to ${nextOrientationLabel}`,
|
|
1918
3216
|
title: `Rotate to ${nextOrientationLabel}`,
|
|
1919
|
-
children: /* @__PURE__ */ (0,
|
|
3217
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.TabletSmartphone, { className: "h-3.5 w-3.5" })
|
|
1920
3218
|
}
|
|
1921
3219
|
),
|
|
1922
|
-
onActiveOpacityChange ? /* @__PURE__ */ (0,
|
|
3220
|
+
onActiveOpacityChange ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1923
3221
|
Button,
|
|
1924
3222
|
{
|
|
1925
3223
|
type: "button",
|
|
@@ -1934,10 +3232,10 @@ var PreviewControllerWindow = ({
|
|
|
1934
3232
|
onClick: () => setSettingsOpen((current) => !current),
|
|
1935
3233
|
"aria-label": `Adjust ${session.label} opacity`,
|
|
1936
3234
|
title: `Adjust opacity (${Math.round(activeOpacity * 100)}%)`,
|
|
1937
|
-
children: /* @__PURE__ */ (0,
|
|
3235
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.SlidersHorizontal, { className: "h-3.5 w-3.5" })
|
|
1938
3236
|
}
|
|
1939
3237
|
) : null,
|
|
1940
|
-
/* @__PURE__ */ (0,
|
|
3238
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1941
3239
|
Button,
|
|
1942
3240
|
{
|
|
1943
3241
|
type: "button",
|
|
@@ -1949,10 +3247,10 @@ var PreviewControllerWindow = ({
|
|
|
1949
3247
|
onClick: onMinimize,
|
|
1950
3248
|
"aria-label": `Minimize ${session.label}`,
|
|
1951
3249
|
title: "Minimize controller",
|
|
1952
|
-
children: /* @__PURE__ */ (0,
|
|
3250
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Minus, { className: "h-3.5 w-3.5" })
|
|
1953
3251
|
}
|
|
1954
3252
|
),
|
|
1955
|
-
/* @__PURE__ */ (0,
|
|
3253
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1956
3254
|
Button,
|
|
1957
3255
|
{
|
|
1958
3256
|
type: "button",
|
|
@@ -1969,27 +3267,27 @@ var PreviewControllerWindow = ({
|
|
|
1969
3267
|
},
|
|
1970
3268
|
"aria-label": `Close ${session.label}`,
|
|
1971
3269
|
title: "Close controller",
|
|
1972
|
-
children: /* @__PURE__ */ (0,
|
|
3270
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.X, { className: "h-3.5 w-3.5" })
|
|
1973
3271
|
}
|
|
1974
3272
|
)
|
|
1975
3273
|
] })
|
|
1976
3274
|
]
|
|
1977
3275
|
}
|
|
1978
3276
|
),
|
|
1979
|
-
settingsOpen && onActiveOpacityChange ? /* @__PURE__ */ (0,
|
|
3277
|
+
settingsOpen && onActiveOpacityChange ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1980
3278
|
"div",
|
|
1981
3279
|
{
|
|
1982
3280
|
className: "border-b border-white/8 bg-black/72 px-3 py-2.5 backdrop-blur-sm",
|
|
1983
3281
|
onPointerDown: (event) => event.stopPropagation(),
|
|
1984
3282
|
children: [
|
|
1985
|
-
/* @__PURE__ */ (0,
|
|
1986
|
-
/* @__PURE__ */ (0,
|
|
1987
|
-
/* @__PURE__ */ (0,
|
|
3283
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mb-2 flex items-center justify-between gap-3", children: [
|
|
3284
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-[11px] font-semibold tracking-[0.16em] text-slate-300 uppercase", children: "Opacity" }),
|
|
3285
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "font-mono text-[11px] text-slate-400", children: [
|
|
1988
3286
|
Math.round(activeOpacity * 100),
|
|
1989
3287
|
"%"
|
|
1990
3288
|
] })
|
|
1991
3289
|
] }),
|
|
1992
|
-
/* @__PURE__ */ (0,
|
|
3290
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1993
3291
|
Slider,
|
|
1994
3292
|
{
|
|
1995
3293
|
value: [activeOpacity * 100],
|
|
@@ -2003,7 +3301,7 @@ var PreviewControllerWindow = ({
|
|
|
2003
3301
|
]
|
|
2004
3302
|
}
|
|
2005
3303
|
) : null,
|
|
2006
|
-
/* @__PURE__ */ (0,
|
|
3304
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2007
3305
|
"div",
|
|
2008
3306
|
{
|
|
2009
3307
|
className: "relative",
|
|
@@ -2012,7 +3310,7 @@ var PreviewControllerWindow = ({
|
|
|
2012
3310
|
onFocus();
|
|
2013
3311
|
}
|
|
2014
3312
|
},
|
|
2015
|
-
children: /* @__PURE__ */ (0,
|
|
3313
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2016
3314
|
"div",
|
|
2017
3315
|
{
|
|
2018
3316
|
className: "relative overflow-hidden bg-black",
|
|
@@ -2021,7 +3319,7 @@ var PreviewControllerWindow = ({
|
|
|
2021
3319
|
height: contentHeight
|
|
2022
3320
|
},
|
|
2023
3321
|
children: [
|
|
2024
|
-
/* @__PURE__ */ (0,
|
|
3322
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2025
3323
|
"div",
|
|
2026
3324
|
{
|
|
2027
3325
|
className: "origin-top-left",
|
|
@@ -2031,10 +3329,13 @@ var PreviewControllerWindow = ({
|
|
|
2031
3329
|
transform: `scale(${session.displayScale})`,
|
|
2032
3330
|
transformOrigin: "top left"
|
|
2033
3331
|
},
|
|
2034
|
-
children: /* @__PURE__ */ (0,
|
|
3332
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2035
3333
|
"iframe",
|
|
2036
3334
|
{
|
|
2037
|
-
ref:
|
|
3335
|
+
ref: (frame) => {
|
|
3336
|
+
iframeRef.current = frame;
|
|
3337
|
+
frameRef?.(frame);
|
|
3338
|
+
},
|
|
2038
3339
|
src: session.url,
|
|
2039
3340
|
title: `${session.label} controller`,
|
|
2040
3341
|
"data-testid": `preview-controller-frame-${session.ordinal}`,
|
|
@@ -2051,14 +3352,14 @@ var PreviewControllerWindow = ({
|
|
|
2051
3352
|
)
|
|
2052
3353
|
}
|
|
2053
3354
|
),
|
|
2054
|
-
session.surfaceState === "loading" ? /* @__PURE__ */ (0,
|
|
2055
|
-
/* @__PURE__ */ (0,
|
|
3355
|
+
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: [
|
|
3356
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Loader2, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
2056
3357
|
"Loading"
|
|
2057
3358
|
] }) }) : null,
|
|
2058
|
-
session.surfaceState === "failed" ? /* @__PURE__ */ (0,
|
|
2059
|
-
/* @__PURE__ */ (0,
|
|
2060
|
-
/* @__PURE__ */ (0,
|
|
2061
|
-
/* @__PURE__ */ (0,
|
|
3359
|
+
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: [
|
|
3360
|
+
/* @__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" }) }),
|
|
3361
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-sm font-semibold text-white", children: "Controller did not load" }),
|
|
3362
|
+
/* @__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
3363
|
] }) }) : null
|
|
2063
3364
|
]
|
|
2064
3365
|
}
|
|
@@ -2068,7 +3369,7 @@ var PreviewControllerWindow = ({
|
|
|
2068
3369
|
]
|
|
2069
3370
|
}
|
|
2070
3371
|
),
|
|
2071
|
-
RESIZE_HANDLES.map(({ handle, cursor, style }) => /* @__PURE__ */ (0,
|
|
3372
|
+
RESIZE_HANDLES.map(({ handle, cursor, style }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2072
3373
|
"div",
|
|
2073
3374
|
{
|
|
2074
3375
|
"data-testid": `preview-controller-resize-${handle}-${session.ordinal}`,
|
|
@@ -2092,8 +3393,127 @@ var PreviewControllerWindow = ({
|
|
|
2092
3393
|
);
|
|
2093
3394
|
};
|
|
2094
3395
|
|
|
3396
|
+
// src/preview/workspace-local-seats.ts
|
|
3397
|
+
var import_react9 = require("react");
|
|
3398
|
+
var useWorkspaceLocalSeats = ({
|
|
3399
|
+
enabled,
|
|
3400
|
+
sessions,
|
|
3401
|
+
canSpawn,
|
|
3402
|
+
spawn,
|
|
3403
|
+
remove,
|
|
3404
|
+
frames
|
|
3405
|
+
}) => {
|
|
3406
|
+
const keyboardListener = (0, import_react9.useRef)(void 0);
|
|
3407
|
+
const requests = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
|
|
3408
|
+
const closings = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
|
|
3409
|
+
const [requested, setRequested] = (0, import_react9.useState)(0);
|
|
3410
|
+
const provider = (0, import_react9.useMemo)(
|
|
3411
|
+
() => enabled ? {
|
|
3412
|
+
subscribeKeyboard: (receive) => {
|
|
3413
|
+
keyboardListener.current = receive;
|
|
3414
|
+
return () => {
|
|
3415
|
+
keyboardListener.current = void 0;
|
|
3416
|
+
};
|
|
3417
|
+
},
|
|
3418
|
+
open: (seat) => new Promise((resolve) => {
|
|
3419
|
+
requests.current.set(seat.key, {
|
|
3420
|
+
seat,
|
|
3421
|
+
resolve,
|
|
3422
|
+
spawned: false
|
|
3423
|
+
});
|
|
3424
|
+
setRequested((count2) => count2 + 1);
|
|
3425
|
+
})
|
|
3426
|
+
} : null,
|
|
3427
|
+
[enabled]
|
|
3428
|
+
);
|
|
3429
|
+
const ready = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
|
|
3430
|
+
const openSeat = (0, import_react9.useCallback)(
|
|
3431
|
+
(key, request, session) => {
|
|
3432
|
+
const origin = new URL(session.url).origin;
|
|
3433
|
+
requests.current.delete(key);
|
|
3434
|
+
closings.current.get(session.id)?.();
|
|
3435
|
+
request.resolve({
|
|
3436
|
+
send: (operation) => {
|
|
3437
|
+
const target = frames.get(session.id)?.contentWindow;
|
|
3438
|
+
if (target) sendLocalSeatOperation(target, origin, operation);
|
|
3439
|
+
},
|
|
3440
|
+
closed: new Promise((close) => closings.current.set(session.id, close))
|
|
3441
|
+
});
|
|
3442
|
+
},
|
|
3443
|
+
[frames]
|
|
3444
|
+
);
|
|
3445
|
+
(0, import_react9.useEffect)(() => {
|
|
3446
|
+
let spawned = false;
|
|
3447
|
+
for (const [key, request] of requests.current) {
|
|
3448
|
+
const session = sessions.find(
|
|
3449
|
+
(candidate) => candidate.localSeat?.key === key
|
|
3450
|
+
);
|
|
3451
|
+
if (session) {
|
|
3452
|
+
if (ready.current.has(session.id)) openSeat(key, request, session);
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
if (request.spawned || !canSpawn) {
|
|
3456
|
+
requests.current.delete(key);
|
|
3457
|
+
request.resolve(null);
|
|
3458
|
+
continue;
|
|
3459
|
+
}
|
|
3460
|
+
requests.current.set(key, { ...request, spawned: true });
|
|
3461
|
+
spawned = true;
|
|
3462
|
+
spawn({ localSeat: request.seat });
|
|
3463
|
+
}
|
|
3464
|
+
if (spawned) setRequested((count2) => count2 + 1);
|
|
3465
|
+
for (const sessionId of ready.current)
|
|
3466
|
+
if (!sessions.some((session) => session.id === sessionId))
|
|
3467
|
+
ready.current.delete(sessionId);
|
|
3468
|
+
for (const [sessionId, close] of closings.current)
|
|
3469
|
+
if (!sessions.some((session) => session.id === sessionId)) {
|
|
3470
|
+
closings.current.delete(sessionId);
|
|
3471
|
+
close();
|
|
3472
|
+
}
|
|
3473
|
+
}, [requested, sessions, canSpawn, spawn, openSeat]);
|
|
3474
|
+
const leaving = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
|
|
3475
|
+
(0, import_react9.useEffect)(() => {
|
|
3476
|
+
if (enabled) return;
|
|
3477
|
+
for (const session of sessions) {
|
|
3478
|
+
if (!session.localSeat || leaving.current.has(session.id)) continue;
|
|
3479
|
+
leaving.current.add(session.id);
|
|
3480
|
+
void requestPreviewControllerClose(
|
|
3481
|
+
frames.get(session.id) ?? null,
|
|
3482
|
+
session.url
|
|
3483
|
+
).finally(() => {
|
|
3484
|
+
leaving.current.delete(session.id);
|
|
3485
|
+
remove(session.id);
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
}, [enabled, sessions, frames, remove]);
|
|
3489
|
+
(0, import_react9.useEffect)(() => {
|
|
3490
|
+
const onMessage = (event) => {
|
|
3491
|
+
if (!provider) return;
|
|
3492
|
+
const session = sessions.find(
|
|
3493
|
+
(candidate) => candidate.localSeat && frames.get(candidate.id)?.contentWindow === event.source
|
|
3494
|
+
);
|
|
3495
|
+
if (!session?.localSeat || event.origin !== new URL(session.url).origin)
|
|
3496
|
+
return;
|
|
3497
|
+
const keyboard = localSeatKeyboardSchema.safeParse(event.data);
|
|
3498
|
+
if (keyboard.success) {
|
|
3499
|
+
keyboardListener.current?.(keyboard.data);
|
|
3500
|
+
return;
|
|
3501
|
+
}
|
|
3502
|
+
if (!isLocalSeatReadyMessage(event.data)) return;
|
|
3503
|
+
ready.current.add(session.id);
|
|
3504
|
+
const key = session.localSeat.key;
|
|
3505
|
+
const request = requests.current.get(key);
|
|
3506
|
+
if (request) openSeat(key, request, session);
|
|
3507
|
+
};
|
|
3508
|
+
window.addEventListener("message", onMessage);
|
|
3509
|
+
return () => window.removeEventListener("message", onMessage);
|
|
3510
|
+
}, [sessions, frames, openSeat, provider]);
|
|
3511
|
+
return provider;
|
|
3512
|
+
};
|
|
3513
|
+
|
|
2095
3514
|
// src/preview/workspace.tsx
|
|
2096
|
-
var
|
|
3515
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3516
|
+
var rosterSourceOf = (kind) => kind === "agent" ? "virtual" : kind;
|
|
2097
3517
|
var getControllerSourceLabel = (source) => {
|
|
2098
3518
|
if (source === "virtual") {
|
|
2099
3519
|
return "Agent";
|
|
@@ -2111,8 +3531,9 @@ var getControllerSourceIcon = (source) => {
|
|
|
2111
3531
|
};
|
|
2112
3532
|
var PreviewControllerWorkspace = ({
|
|
2113
3533
|
joinUrl,
|
|
3534
|
+
fixedControllerOrientation: requestedFixedOrientation,
|
|
2114
3535
|
embedOrigin,
|
|
2115
|
-
|
|
3536
|
+
players = [],
|
|
2116
3537
|
onRemoveController,
|
|
2117
3538
|
onResetRoom,
|
|
2118
3539
|
enabled = false,
|
|
@@ -2124,15 +3545,20 @@ var PreviewControllerWorkspace = ({
|
|
|
2124
3545
|
launcherLabel = "Controllers",
|
|
2125
3546
|
launcherVariant = "full",
|
|
2126
3547
|
showLauncherWhenIdle = true,
|
|
2127
|
-
waitingLabel = "Waiting for room"
|
|
3548
|
+
waitingLabel = "Waiting for room",
|
|
3549
|
+
localPlayers = true,
|
|
3550
|
+
localPlayersGame = null
|
|
2128
3551
|
}) => {
|
|
2129
|
-
const
|
|
2130
|
-
const
|
|
2131
|
-
const [
|
|
2132
|
-
const [
|
|
2133
|
-
const [
|
|
2134
|
-
const [
|
|
2135
|
-
const
|
|
3552
|
+
const declaredOrientation = (0, import_react10.useContext)(fixedControllerOrientationContext);
|
|
3553
|
+
const fixedOrientation = requestedFixedOrientation ?? declaredOrientation ?? null;
|
|
3554
|
+
const [mounted, setMounted] = (0, import_react10.useState)(false);
|
|
3555
|
+
const [dragState, setDragState] = (0, import_react10.useState)(null);
|
|
3556
|
+
const [resizeState, setResizeState] = (0, import_react10.useState)(null);
|
|
3557
|
+
const [launcherOpen, setLauncherOpen] = (0, import_react10.useState)(false);
|
|
3558
|
+
const [removingControllerId, setRemovingControllerId] = (0, import_react10.useState)(null);
|
|
3559
|
+
const [resettingRoom, setResettingRoom] = (0, import_react10.useState)(false);
|
|
3560
|
+
const dockRef = (0, import_react10.useRef)(null);
|
|
3561
|
+
const dockRowRef = (0, import_react10.useRef)(null);
|
|
2136
3562
|
const resolvedEmbedOrigin = embedOrigin ?? (typeof window !== "undefined" ? window.location.origin : null);
|
|
2137
3563
|
const {
|
|
2138
3564
|
sessions,
|
|
@@ -2149,22 +3575,41 @@ var PreviewControllerWorkspace = ({
|
|
|
2149
3575
|
markPreviewControllerReady,
|
|
2150
3576
|
markPreviewControllerFailed
|
|
2151
3577
|
} = usePreviewControllerManager({
|
|
3578
|
+
fixedControllerOrientation: fixedOrientation,
|
|
2152
3579
|
joinUrl,
|
|
2153
3580
|
embedOrigin: resolvedEmbedOrigin,
|
|
2154
3581
|
enabled,
|
|
2155
3582
|
maxControllers
|
|
2156
3583
|
});
|
|
3584
|
+
const [frames] = (0, import_react10.useState)(() => /* @__PURE__ */ new Map());
|
|
3585
|
+
const spawnSeatPhone = (0, import_react10.useCallback)(
|
|
3586
|
+
(options) => spawnPreviewController({
|
|
3587
|
+
...options,
|
|
3588
|
+
dock: dockRowRef.current?.getBoundingClientRect()
|
|
3589
|
+
}),
|
|
3590
|
+
[spawnPreviewController]
|
|
3591
|
+
);
|
|
3592
|
+
const localSeats = useWorkspaceLocalSeats({
|
|
3593
|
+
enabled: enabled && localPlayers,
|
|
3594
|
+
sessions,
|
|
3595
|
+
canSpawn,
|
|
3596
|
+
spawn: spawnSeatPhone,
|
|
3597
|
+
remove: removePreviewController,
|
|
3598
|
+
frames
|
|
3599
|
+
});
|
|
3600
|
+
useProvideLocalSeats(localPlayersGame ? null : localSeats);
|
|
3601
|
+
useServeLocalSeats(localPlayersGame, localSeats);
|
|
2157
3602
|
const platformSettings = useResolvedPlatformSettingsSnapshot();
|
|
2158
3603
|
const activeOpacity = platformSettings.previewControllers.activeOpacity;
|
|
2159
|
-
const sortedSessions = (0,
|
|
3604
|
+
const sortedSessions = (0, import_react10.useMemo)(
|
|
2160
3605
|
() => [...sessions].sort((left, right) => left.ordinal - right.ordinal),
|
|
2161
3606
|
[sessions]
|
|
2162
3607
|
);
|
|
2163
|
-
(0,
|
|
3608
|
+
(0, import_react10.useEffect)(() => {
|
|
2164
3609
|
setMounted(true);
|
|
2165
3610
|
return () => setMounted(false);
|
|
2166
3611
|
}, []);
|
|
2167
|
-
(0,
|
|
3612
|
+
(0, import_react10.useEffect)(() => {
|
|
2168
3613
|
if (!launcherOpen || typeof document === "undefined") {
|
|
2169
3614
|
return;
|
|
2170
3615
|
}
|
|
@@ -2190,44 +3635,40 @@ var PreviewControllerWorkspace = ({
|
|
|
2190
3635
|
document.removeEventListener("keydown", handleKeyDown);
|
|
2191
3636
|
};
|
|
2192
3637
|
}, [launcherOpen]);
|
|
2193
|
-
const minimizedSessions = (0,
|
|
3638
|
+
const minimizedSessions = (0, import_react10.useMemo)(
|
|
2194
3639
|
() => sessions.filter((session) => session.minimized).sort((left, right) => left.ordinal - right.ordinal),
|
|
2195
3640
|
[sessions]
|
|
2196
3641
|
);
|
|
2197
|
-
const openSessions = (0, import_react8.useMemo)(
|
|
2198
|
-
() => sessions.filter((session) => !session.minimized),
|
|
2199
|
-
[sessions]
|
|
2200
|
-
);
|
|
2201
3642
|
const launcherVisible = showLauncherWhenIdle || launcherOpen || sessions.length > 0;
|
|
2202
|
-
const sortedControllers = (0,
|
|
2203
|
-
() => [...
|
|
2204
|
-
|
|
2205
|
-
),
|
|
2206
|
-
[controllers]
|
|
3643
|
+
const sortedControllers = (0, import_react10.useMemo)(
|
|
3644
|
+
() => [...players].sort((left, right) => left.id.localeCompare(right.id)),
|
|
3645
|
+
[players]
|
|
2207
3646
|
);
|
|
2208
|
-
const controllerRoster = (0,
|
|
2209
|
-
const
|
|
2210
|
-
sortedSessions.
|
|
3647
|
+
const controllerRoster = (0, import_react10.useMemo)(() => {
|
|
3648
|
+
const sessionsBySeat = new Map(
|
|
3649
|
+
sortedSessions.flatMap(
|
|
3650
|
+
(session) => session.seat ? [[session.seat, session]] : []
|
|
3651
|
+
)
|
|
2211
3652
|
);
|
|
2212
3653
|
const controllerItems = sortedControllers.map((controller) => {
|
|
2213
|
-
const session =
|
|
3654
|
+
const session = sessionsBySeat.get(controller.id) ?? null;
|
|
2214
3655
|
return {
|
|
2215
|
-
id: controller.
|
|
2216
|
-
controllerId: controller.
|
|
2217
|
-
label: controller.
|
|
2218
|
-
source: controller.
|
|
3656
|
+
id: controller.id,
|
|
3657
|
+
controllerId: controller.id,
|
|
3658
|
+
label: controller.label,
|
|
3659
|
+
source: rosterSourceOf(controller.kind),
|
|
2219
3660
|
connected: controller.connected,
|
|
2220
|
-
resumable:
|
|
3661
|
+
resumable: !controller.connected,
|
|
2221
3662
|
session,
|
|
2222
3663
|
controller
|
|
2223
3664
|
};
|
|
2224
3665
|
});
|
|
2225
|
-
const
|
|
2226
|
-
sortedControllers.map((controller) => controller.
|
|
3666
|
+
const seatIds = new Set(
|
|
3667
|
+
sortedControllers.map((controller) => controller.id)
|
|
2227
3668
|
);
|
|
2228
|
-
const pendingPreviewItems = sortedSessions.filter((session) => !
|
|
3669
|
+
const pendingPreviewItems = sortedSessions.filter((session) => !session.seat || !seatIds.has(session.seat)).map((session) => ({
|
|
2229
3670
|
id: session.id,
|
|
2230
|
-
controllerId: session.
|
|
3671
|
+
controllerId: session.seat ?? session.id,
|
|
2231
3672
|
label: session.label,
|
|
2232
3673
|
source: "preview",
|
|
2233
3674
|
connected: session.surfaceState === "ready",
|
|
@@ -2251,16 +3692,21 @@ var PreviewControllerWorkspace = ({
|
|
|
2251
3692
|
return null;
|
|
2252
3693
|
}
|
|
2253
3694
|
return (0, import_react_dom.createPortal)(
|
|
2254
|
-
/* @__PURE__ */ (0,
|
|
3695
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2255
3696
|
"div",
|
|
2256
3697
|
{
|
|
2257
3698
|
className: "fixed inset-0",
|
|
2258
3699
|
style: { zIndex: PREVIEW_WORKSPACE_Z_INDEX, pointerEvents: "none" },
|
|
2259
3700
|
children: [
|
|
2260
|
-
|
|
3701
|
+
sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2261
3702
|
PreviewControllerWindow,
|
|
2262
3703
|
{
|
|
3704
|
+
fixedControllerOrientation: fixedOrientation,
|
|
2263
3705
|
session,
|
|
3706
|
+
frameRef: (frame) => {
|
|
3707
|
+
if (frame) frames.set(session.id, frame);
|
|
3708
|
+
else frames.delete(session.id);
|
|
3709
|
+
},
|
|
2264
3710
|
activeOpacity,
|
|
2265
3711
|
highContrast,
|
|
2266
3712
|
dragging: dragState?.id === session.id,
|
|
@@ -2379,7 +3825,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2379
3825
|
},
|
|
2380
3826
|
session.id
|
|
2381
3827
|
)),
|
|
2382
|
-
/* @__PURE__ */ (0,
|
|
3828
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2383
3829
|
"div",
|
|
2384
3830
|
{
|
|
2385
3831
|
ref: dockRef,
|
|
@@ -2389,14 +3835,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2389
3835
|
),
|
|
2390
3836
|
style: { pointerEvents: "none" },
|
|
2391
3837
|
children: [
|
|
2392
|
-
/* @__PURE__ */ (0,
|
|
3838
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2393
3839
|
"div",
|
|
2394
3840
|
{
|
|
3841
|
+
ref: dockRowRef,
|
|
2395
3842
|
className: "flex items-start justify-end gap-2",
|
|
2396
3843
|
style: { pointerEvents: "auto" },
|
|
2397
3844
|
children: [
|
|
2398
3845
|
dockAccessory,
|
|
2399
|
-
launcherVisible ? /* @__PURE__ */ (0,
|
|
3846
|
+
launcherVisible ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2400
3847
|
Button,
|
|
2401
3848
|
{
|
|
2402
3849
|
type: "button",
|
|
@@ -2411,19 +3858,19 @@ var PreviewControllerWorkspace = ({
|
|
|
2411
3858
|
title: !joinUrl ? waitingLabel : launcherLabel,
|
|
2412
3859
|
onClick: () => setLauncherOpen((current) => !current),
|
|
2413
3860
|
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,
|
|
3861
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.MonitorSmartphone, { className: "h-4 w-4" }),
|
|
3862
|
+
launcherVariant === "full" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3863
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-[11px] font-semibold tracking-[0.16em] uppercase", children: launcherLabel }),
|
|
3864
|
+
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,
|
|
3865
|
+
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" })
|
|
3866
|
+
] }) : 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
3867
|
]
|
|
2421
3868
|
}
|
|
2422
3869
|
) : null
|
|
2423
3870
|
]
|
|
2424
3871
|
}
|
|
2425
3872
|
),
|
|
2426
|
-
launcherOpen ? /* @__PURE__ */ (0,
|
|
3873
|
+
launcherOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2427
3874
|
"section",
|
|
2428
3875
|
{
|
|
2429
3876
|
className: cn(
|
|
@@ -2432,15 +3879,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2432
3879
|
highContrast && "border-white/30"
|
|
2433
3880
|
),
|
|
2434
3881
|
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,
|
|
3882
|
+
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: [
|
|
3883
|
+
controllerRoster.length > 0 || onResetRoom ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-3", children: [
|
|
3884
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-start justify-between gap-3", children: [
|
|
3885
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "min-w-0", children: [
|
|
3886
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] font-semibold tracking-[0.18em] text-white/54 uppercase", children: "Controllers" }),
|
|
3887
|
+
/* @__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
3888
|
] }),
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
2443
|
-
onResetRoom ? /* @__PURE__ */ (0,
|
|
3889
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex shrink-0 items-center gap-1.5", children: [
|
|
3890
|
+
onResetRoom ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2444
3891
|
Button,
|
|
2445
3892
|
{
|
|
2446
3893
|
type: "button",
|
|
@@ -2459,7 +3906,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2459
3906
|
children: "Reset room"
|
|
2460
3907
|
}
|
|
2461
3908
|
) : null,
|
|
2462
|
-
sessions.length > 0 ? /* @__PURE__ */ (0,
|
|
3909
|
+
sessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2463
3910
|
Button,
|
|
2464
3911
|
{
|
|
2465
3912
|
type: "button",
|
|
@@ -2468,15 +3915,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2468
3915
|
className: "h-7 w-7 rounded-full text-white/72 hover:bg-white/8 hover:text-white",
|
|
2469
3916
|
onClick: () => clearPreviewControllers(),
|
|
2470
3917
|
title: "Close all preview controllers",
|
|
2471
|
-
children: /* @__PURE__ */ (0,
|
|
3918
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
2472
3919
|
}
|
|
2473
3920
|
) : null
|
|
2474
3921
|
] })
|
|
2475
3922
|
] }),
|
|
2476
|
-
/* @__PURE__ */ (0,
|
|
3923
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-2", children: controllerRoster.map((item) => {
|
|
2477
3924
|
const SourceIcon = getControllerSourceIcon(item.source);
|
|
2478
3925
|
const previewSession = item.session;
|
|
2479
|
-
return /* @__PURE__ */ (0,
|
|
3926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2480
3927
|
"div",
|
|
2481
3928
|
{
|
|
2482
3929
|
"data-airjam-controller-row": true,
|
|
@@ -2487,10 +3934,10 @@ var PreviewControllerWorkspace = ({
|
|
|
2487
3934
|
shellInsetPanelClassName
|
|
2488
3935
|
),
|
|
2489
3936
|
children: [
|
|
2490
|
-
/* @__PURE__ */ (0,
|
|
2491
|
-
/* @__PURE__ */ (0,
|
|
2492
|
-
/* @__PURE__ */ (0,
|
|
2493
|
-
/* @__PURE__ */ (0,
|
|
3937
|
+
/* @__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" }) }),
|
|
3938
|
+
/* @__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: [
|
|
3939
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate text-sm font-semibold text-white/92", children: item.label }),
|
|
3940
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2494
3941
|
"span",
|
|
2495
3942
|
{
|
|
2496
3943
|
"data-airjam-controller-source-badge": true,
|
|
@@ -2498,7 +3945,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2498
3945
|
children: getControllerSourceLabel(item.source)
|
|
2499
3946
|
}
|
|
2500
3947
|
),
|
|
2501
|
-
/* @__PURE__ */ (0,
|
|
3948
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2502
3949
|
"span",
|
|
2503
3950
|
{
|
|
2504
3951
|
className: cn(
|
|
@@ -2508,10 +3955,10 @@ var PreviewControllerWorkspace = ({
|
|
|
2508
3955
|
title: item.session?.minimized ? "Minimized" : item.session ? item.session.surfaceState === "ready" ? "Visible" : previewControllerWindowStateLabel[item.session.surfaceState] : item.connected ? "Connected" : "Disconnected"
|
|
2509
3956
|
}
|
|
2510
3957
|
),
|
|
2511
|
-
item.resumable ? /* @__PURE__ */ (0,
|
|
3958
|
+
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
3959
|
] }) }),
|
|
2513
|
-
/* @__PURE__ */ (0,
|
|
2514
|
-
previewSession?.minimized ? /* @__PURE__ */ (0,
|
|
3960
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3961
|
+
previewSession?.minimized ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2515
3962
|
Button,
|
|
2516
3963
|
{
|
|
2517
3964
|
type: "button",
|
|
@@ -2525,35 +3972,35 @@ var PreviewControllerWorkspace = ({
|
|
|
2525
3972
|
children: "Restore"
|
|
2526
3973
|
}
|
|
2527
3974
|
) : null,
|
|
2528
|
-
item.controller && onRemoveController ? /* @__PURE__ */ (0,
|
|
3975
|
+
item.controller && onRemoveController ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2529
3976
|
Button,
|
|
2530
3977
|
{
|
|
2531
3978
|
type: "button",
|
|
2532
3979
|
variant: "ghost",
|
|
2533
3980
|
size: "sm",
|
|
2534
3981
|
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.
|
|
3982
|
+
disabled: removingControllerId === item.controller.id,
|
|
2536
3983
|
onClick: async () => {
|
|
2537
3984
|
if (!item.controller) {
|
|
2538
3985
|
return;
|
|
2539
3986
|
}
|
|
2540
3987
|
try {
|
|
2541
3988
|
setRemovingControllerId(
|
|
2542
|
-
item.controller.
|
|
3989
|
+
item.controller.id
|
|
2543
3990
|
);
|
|
2544
3991
|
await onRemoveController(
|
|
2545
|
-
item.controller.
|
|
3992
|
+
item.controller.id
|
|
2546
3993
|
);
|
|
2547
3994
|
} finally {
|
|
2548
3995
|
setRemovingControllerId(
|
|
2549
|
-
(current) => current === item.controller?.
|
|
3996
|
+
(current) => current === item.controller?.id ? null : current
|
|
2550
3997
|
);
|
|
2551
3998
|
}
|
|
2552
3999
|
},
|
|
2553
4000
|
children: "Kick"
|
|
2554
4001
|
}
|
|
2555
4002
|
) : null,
|
|
2556
|
-
previewSession ? /* @__PURE__ */ (0,
|
|
4003
|
+
previewSession ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2557
4004
|
Button,
|
|
2558
4005
|
{
|
|
2559
4006
|
type: "button",
|
|
@@ -2562,7 +4009,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2562
4009
|
className: "h-7 w-7 rounded-full text-white/68 hover:bg-white/8 hover:text-white",
|
|
2563
4010
|
onClick: () => removePreviewController(previewSession.id),
|
|
2564
4011
|
title: `Close ${item.label}`,
|
|
2565
|
-
children: /* @__PURE__ */ (0,
|
|
4012
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
2566
4013
|
}
|
|
2567
4014
|
) : null
|
|
2568
4015
|
] })
|
|
@@ -2571,13 +4018,13 @@ var PreviewControllerWorkspace = ({
|
|
|
2571
4018
|
item.id
|
|
2572
4019
|
);
|
|
2573
4020
|
}) }),
|
|
2574
|
-
/* @__PURE__ */ (0,
|
|
2575
|
-
] }) : /* @__PURE__ */ (0,
|
|
2576
|
-
minimizedSessions.length > 0 ? /* @__PURE__ */ (0,
|
|
4021
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "h-px bg-white/10" })
|
|
4022
|
+
] }) : /* @__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." }) }),
|
|
4023
|
+
minimizedSessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { className: "text-[11px] tracking-[0.14em] text-white/46 uppercase", children: [
|
|
2577
4024
|
minimizedSessions.length,
|
|
2578
4025
|
" minimized"
|
|
2579
4026
|
] }) : null,
|
|
2580
|
-
/* @__PURE__ */ (0,
|
|
4027
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2581
4028
|
Button,
|
|
2582
4029
|
{
|
|
2583
4030
|
type: "button",
|
|
@@ -2591,7 +4038,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2591
4038
|
spawnPreviewController();
|
|
2592
4039
|
},
|
|
2593
4040
|
children: [
|
|
2594
|
-
/* @__PURE__ */ (0,
|
|
4041
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
|
|
2595
4042
|
!joinUrl ? waitingLabel : "Add controller"
|
|
2596
4043
|
]
|
|
2597
4044
|
}
|
|
@@ -2610,7 +4057,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2610
4057
|
};
|
|
2611
4058
|
|
|
2612
4059
|
// src/preview/host-workspace.tsx
|
|
2613
|
-
var
|
|
4060
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2614
4061
|
var HostPreviewControllerWorkspace = ({
|
|
2615
4062
|
enabled = "auto",
|
|
2616
4063
|
className,
|
|
@@ -2624,20 +4071,15 @@ var HostPreviewControllerWorkspace = ({
|
|
|
2624
4071
|
topology: config.topology
|
|
2625
4072
|
});
|
|
2626
4073
|
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;
|
|
4074
|
+
const handleResetRoom = () => {
|
|
4075
|
+
void host.resetRoom().then(() => window.location.reload());
|
|
2634
4076
|
};
|
|
2635
|
-
return /* @__PURE__ */ (0,
|
|
4077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2636
4078
|
PreviewControllerWorkspace,
|
|
2637
4079
|
{
|
|
2638
4080
|
enabled: resolvedEnabled,
|
|
2639
4081
|
joinUrl,
|
|
2640
|
-
|
|
4082
|
+
players: host.players,
|
|
2641
4083
|
onRemoveController: host.removeController,
|
|
2642
4084
|
onResetRoom: handleResetRoom,
|
|
2643
4085
|
onActiveOpacityChange: (activeOpacity) => platformSettingsOwner?.updatePreviewControllers({ activeOpacity }),
|
|
@@ -2648,21 +4090,26 @@ var HostPreviewControllerWorkspace = ({
|
|
|
2648
4090
|
};
|
|
2649
4091
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2650
4092
|
0 && (module.exports = {
|
|
2651
|
-
|
|
2652
|
-
AIR_JAM_PREVIEW_FLAG_QUERY_PARAM,
|
|
4093
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM,
|
|
2653
4094
|
HostPreviewControllerWorkspace,
|
|
2654
4095
|
PreviewControllerWindow,
|
|
2655
4096
|
PreviewControllerWorkspace,
|
|
2656
4097
|
buildPreviewControllerUrl,
|
|
2657
|
-
createPreviewControllerIdentity,
|
|
2658
4098
|
createPreviewControllerLaunch,
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
4099
|
+
getPreviewControllerViewportSize,
|
|
4100
|
+
getPreviewHostViewportSize,
|
|
4101
|
+
isLocalSeatReadyMessage,
|
|
4102
|
+
isLocalSeatRelayedMessage,
|
|
4103
|
+
isPreviewSeatMessage,
|
|
4104
|
+
localInputOperationSchema,
|
|
4105
|
+
localSeatMessages,
|
|
4106
|
+
localSeatQuerySchema,
|
|
4107
|
+
localSeatRelaySchema,
|
|
4108
|
+
localSeatRequestSchema,
|
|
2664
4109
|
readPreviewControllerDeviceIdFromSearchParams,
|
|
2665
|
-
|
|
4110
|
+
relayLocalSeatInput,
|
|
4111
|
+
requestPreviewControllerClose,
|
|
4112
|
+
sendLocalSeatOperation,
|
|
2666
4113
|
usePreviewControllerManager
|
|
2667
4114
|
});
|
|
2668
4115
|
//# sourceMappingURL=preview.cjs.map
|