@air-jam/sdk 0.9.2 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -242
- package/dist/actions-D4eh6Xaa.d.cts +72 -0
- package/dist/actions-D4eh6Xaa.d.ts +72 -0
- package/dist/{agent-tooling-BSMGBix9.d.cts → agent-contract-DfLm4Mf-.d.ts} +3 -19
- package/dist/{agent-tooling-BSMGBix9.d.ts → agent-contract-TINzp-5Y.d.cts} +3 -19
- package/dist/agent-tooling.cjs +270 -42
- package/dist/agent-tooling.cjs.map +1 -1
- package/dist/agent-tooling.d.cts +117 -2
- package/dist/agent-tooling.d.ts +117 -2
- package/dist/agent-tooling.js +150 -11
- package/dist/agent-tooling.js.map +1 -1
- package/dist/air-jam-context-BCVCWiaT.d.ts +410 -0
- package/dist/air-jam-context-DavligpM.d.cts +410 -0
- package/dist/arcade/bridge/controller.cjs +872 -582
- package/dist/arcade/bridge/controller.cjs.map +1 -1
- package/dist/arcade/bridge/controller.d.cts +28 -76
- package/dist/arcade/bridge/controller.d.ts +28 -76
- package/dist/arcade/bridge/controller.js +27 -26
- package/dist/arcade/bridge/controller.js.map +1 -1
- package/dist/arcade/bridge/host.cjs +1017 -252
- package/dist/arcade/bridge/host.cjs.map +1 -1
- package/dist/arcade/bridge/host.d.cts +6 -72
- package/dist/arcade/bridge/host.d.ts +6 -72
- package/dist/arcade/bridge/host.js +19 -21
- package/dist/arcade/bridge/host.js.map +1 -1
- package/dist/arcade/bridge/iframe.cjs +3 -31
- package/dist/arcade/bridge/iframe.cjs.map +1 -1
- package/dist/arcade/bridge/iframe.d.cts +4 -46
- package/dist/arcade/bridge/iframe.d.ts +4 -46
- package/dist/arcade/bridge/iframe.js +6 -18
- package/dist/arcade/bridge/iframe.js.map +1 -1
- package/dist/arcade/host.cjs +0 -479
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.d.cts +1 -18
- package/dist/arcade/host.d.ts +1 -18
- package/dist/arcade/host.js +0 -13
- package/dist/arcade/host.js.map +1 -1
- package/dist/arcade/runtime.cjs +12163 -0
- package/dist/arcade/runtime.cjs.map +1 -0
- package/dist/arcade/runtime.d.cts +54 -0
- package/dist/arcade/runtime.d.ts +54 -0
- package/dist/arcade/runtime.js +45 -0
- package/dist/arcade/runtime.js.map +1 -0
- package/dist/arcade/surface.cjs +12 -35
- package/dist/arcade/surface.cjs.map +1 -1
- package/dist/arcade/surface.d.cts +19 -2
- package/dist/arcade/surface.d.ts +19 -2
- package/dist/arcade/surface.js +12 -14
- package/dist/arcade/surface.js.map +1 -1
- package/dist/arcade/url.cjs +45 -283
- package/dist/arcade/url.cjs.map +1 -1
- package/dist/arcade/url.d.cts +3 -56
- package/dist/arcade/url.d.ts +3 -56
- package/dist/arcade/url.js +33 -16
- package/dist/arcade/url.js.map +1 -1
- package/dist/chunk-24NZZOIO.js +700 -0
- package/dist/chunk-24NZZOIO.js.map +1 -0
- package/dist/chunk-27QLKLZL.js +469 -0
- package/dist/chunk-27QLKLZL.js.map +1 -0
- package/dist/{chunk-UWJOIVON.js → chunk-2H2FGF3H.js} +3 -6
- package/dist/chunk-2H2FGF3H.js.map +1 -0
- package/dist/chunk-2QZADUGA.js +188 -0
- package/dist/chunk-2QZADUGA.js.map +1 -0
- package/dist/chunk-3LDQCQL2.js +307 -0
- package/dist/chunk-3LDQCQL2.js.map +1 -0
- package/dist/chunk-3M7656SU.js +389 -0
- package/dist/chunk-3M7656SU.js.map +1 -0
- package/dist/{chunk-ZLPL2R3R.js → chunk-5CRZFIN6.js} +2 -82
- package/dist/chunk-5CRZFIN6.js.map +1 -0
- package/dist/chunk-5TVVPBQI.js +7 -0
- package/dist/chunk-5TVVPBQI.js.map +1 -0
- package/dist/chunk-6Y3F6Y2K.js +343 -0
- package/dist/chunk-6Y3F6Y2K.js.map +1 -0
- package/dist/{chunk-EVZJA6RN.js → chunk-6ZJUA63D.js} +183 -2
- package/dist/chunk-6ZJUA63D.js.map +1 -0
- package/dist/chunk-A6EOGRRG.js +49 -0
- package/dist/chunk-A6EOGRRG.js.map +1 -0
- package/dist/chunk-BEM77SVQ.js +57 -0
- package/dist/chunk-BEM77SVQ.js.map +1 -0
- package/dist/chunk-C5722GTG.js +176 -0
- package/dist/chunk-C5722GTG.js.map +1 -0
- package/dist/{chunk-DY67S3LR.js → chunk-C5GS2GMK.js} +99 -105
- package/dist/chunk-C5GS2GMK.js.map +1 -0
- package/dist/chunk-CDL7LYZH.js +19 -0
- package/dist/chunk-CDL7LYZH.js.map +1 -0
- package/dist/chunk-DA3TE4OP.js +16 -0
- package/dist/chunk-DA3TE4OP.js.map +1 -0
- package/dist/chunk-DBF7NJ3S.js +72 -0
- package/dist/chunk-DBF7NJ3S.js.map +1 -0
- package/dist/chunk-DHFKL3DI.js +2477 -0
- package/dist/chunk-DHFKL3DI.js.map +1 -0
- package/dist/chunk-DRBPVG47.js +89 -0
- package/dist/chunk-DRBPVG47.js.map +1 -0
- package/dist/{chunk-7OTQTT6H.js → chunk-EG25EXSA.js} +24 -3
- package/dist/chunk-EG25EXSA.js.map +1 -0
- package/dist/chunk-FCG42U7D.js +131 -0
- package/dist/chunk-FCG42U7D.js.map +1 -0
- package/dist/chunk-FJ4J2BEC.js +26 -0
- package/dist/chunk-FJ4J2BEC.js.map +1 -0
- package/dist/chunk-H4DEVMTO.js +221 -0
- package/dist/chunk-H4DEVMTO.js.map +1 -0
- package/dist/chunk-I6TSHJF7.js +63 -0
- package/dist/chunk-I6TSHJF7.js.map +1 -0
- package/dist/{chunk-NCL6WJCL.js → chunk-JCGTL77W.js} +32 -1
- package/dist/chunk-JCGTL77W.js.map +1 -0
- package/dist/chunk-JJVCBUYM.js +98 -0
- package/dist/chunk-JJVCBUYM.js.map +1 -0
- package/dist/chunk-K6BJJJJM.js +138 -0
- package/dist/chunk-K6BJJJJM.js.map +1 -0
- package/dist/chunk-KSYN4I5Y.js +50 -0
- package/dist/chunk-KSYN4I5Y.js.map +1 -0
- package/dist/chunk-KUGROY5S.js +265 -0
- package/dist/chunk-KUGROY5S.js.map +1 -0
- package/dist/chunk-LX6CTPDW.js +16 -0
- package/dist/chunk-LX6CTPDW.js.map +1 -0
- package/dist/{chunk-BE6Z4SIT.js → chunk-M5553I2G.js} +2 -11
- package/dist/chunk-M5553I2G.js.map +1 -0
- package/dist/{chunk-X24K52DG.js → chunk-MD25536W.js} +1 -1
- package/dist/chunk-MD25536W.js.map +1 -0
- package/dist/{chunk-3USU7GY2.js → chunk-MJAWAHLT.js} +1 -1
- package/dist/chunk-MJAWAHLT.js.map +1 -0
- package/dist/chunk-OAXCFPZ7.js +14 -0
- package/dist/chunk-OAXCFPZ7.js.map +1 -0
- package/dist/chunk-QHBRHYMV.js +81 -0
- package/dist/chunk-QHBRHYMV.js.map +1 -0
- package/dist/chunk-QTNYGAZ7.js +45 -0
- package/dist/chunk-QTNYGAZ7.js.map +1 -0
- package/dist/chunk-S3TN7Y7L.js +921 -0
- package/dist/chunk-S3TN7Y7L.js.map +1 -0
- package/dist/chunk-SMKD4JY3.js +129 -0
- package/dist/chunk-SMKD4JY3.js.map +1 -0
- package/dist/{chunk-NUJBMV3O.js → chunk-TFW4NJW2.js} +619 -646
- package/dist/chunk-TFW4NJW2.js.map +1 -0
- package/dist/chunk-UBBP2UY3.js +83 -0
- package/dist/chunk-UBBP2UY3.js.map +1 -0
- package/dist/chunk-URVBMQCK.js +802 -0
- package/dist/chunk-URVBMQCK.js.map +1 -0
- package/dist/chunk-VGX2274F.js +1995 -0
- package/dist/chunk-VGX2274F.js.map +1 -0
- package/dist/chunk-WAFGYJZN.js +1513 -0
- package/dist/chunk-WAFGYJZN.js.map +1 -0
- package/dist/chunk-WGHNGQUS.js +78 -0
- package/dist/chunk-WGHNGQUS.js.map +1 -0
- package/dist/chunk-XLY44PXZ.js +46 -0
- package/dist/chunk-XLY44PXZ.js.map +1 -0
- package/dist/connection-store-BYpQ50W2.d.ts +41 -0
- package/dist/connection-store-D6QqzXU1.d.cts +41 -0
- package/dist/control-Bv8dWjyp.d.ts +1400 -0
- package/dist/control-CNzybWMd.d.cts +1400 -0
- package/dist/controller-0CVO1t_3.d.cts +26 -0
- package/dist/controller-agent-vOiuK7T6.d.cts +130 -0
- package/dist/controller-agent-vOiuK7T6.d.ts +130 -0
- package/dist/controller-bridge.cjs +992 -0
- package/dist/controller-bridge.cjs.map +1 -0
- package/dist/controller-bridge.d.cts +52 -0
- package/dist/controller-bridge.d.ts +52 -0
- package/dist/controller-bridge.js +23 -0
- package/dist/controller-bridge.js.map +1 -0
- package/dist/controller-capture-2GKKGHJ2.js +8 -0
- package/dist/controller-capture-2GKKGHJ2.js.map +1 -0
- package/dist/controller-h9M2Nngd.d.ts +26 -0
- package/dist/controller-press-EWWIMVXP.js +231 -0
- package/dist/controller-press-EWWIMVXP.js.map +1 -0
- package/dist/core-BAO0pHrJ.d.cts +15 -0
- package/dist/core-BAO0pHrJ.d.ts +15 -0
- package/dist/core.cjs +5931 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +232 -0
- package/dist/core.d.ts +232 -0
- package/dist/core.js +906 -0
- package/dist/core.js.map +1 -0
- package/dist/dev-events-BffobOfb.d.ts +31 -0
- package/dist/dev-events-Ct7QEgKb.d.cts +31 -0
- package/dist/dev-log-events-B1_B3guZ.d.cts +47 -0
- package/dist/dev-log-events-B1_B3guZ.d.ts +47 -0
- package/dist/frames-D-xKuODS.d.cts +686 -0
- package/dist/frames-D-xKuODS.d.ts +686 -0
- package/dist/game-Db58JNk3.d.cts +77 -0
- package/dist/game-bySEy-QO.d.ts +77 -0
- package/dist/host-runtime-BuLhGQx5.d.ts +399 -0
- package/dist/host-runtime-_06jpW5v.d.cts +399 -0
- package/dist/index.cjs +12406 -8020
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -973
- package/dist/index.d.ts +106 -973
- package/dist/index.js +451 -4637
- package/dist/index.js.map +1 -1
- package/dist/input-Xvs80gqG.d.cts +92 -0
- package/dist/input-Xvs80gqG.d.ts +92 -0
- package/dist/input-bindings-BaEFrgRb.d.cts +129 -0
- package/dist/input-bindings-BgsJRLPm.d.ts +129 -0
- package/dist/leased-control-BEg4JuXA.d.cts +158 -0
- package/dist/leased-control-BEg4JuXA.d.ts +158 -0
- package/dist/metadata.cjs +3 -9
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +6 -17
- package/dist/metadata.d.ts +6 -17
- package/dist/metadata.js +8 -76
- package/dist/metadata.js.map +1 -1
- package/dist/phone-room-session-Ca6rlxJr.d.ts +439 -0
- package/dist/phone-room-session-DkPR-K6e.d.cts +439 -0
- package/dist/platform-machine.cjs +248 -18
- package/dist/platform-machine.cjs.map +1 -1
- package/dist/platform-machine.d.cts +1867 -96
- package/dist/platform-machine.d.ts +1867 -96
- package/dist/platform-machine.js +206 -18
- package/dist/platform-machine.js.map +1 -1
- package/dist/{platform-settings-cuor3i11.d.cts → platform-settings-Yb0fQ1dl.d.cts} +1 -3
- package/dist/{platform-settings-cuor3i11.d.ts → platform-settings-Yb0fQ1dl.d.ts} +1 -3
- package/dist/prefabs.cjs +134 -3
- package/dist/prefabs.cjs.map +1 -1
- package/dist/prefabs.d.cts +23 -47
- package/dist/prefabs.d.ts +23 -47
- package/dist/prefabs.js +23 -4
- package/dist/prefabs.js.map +1 -1
- package/dist/preview.cjs +2269 -774
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +195 -38
- package/dist/preview.d.ts +195 -38
- package/dist/preview.js +494 -260
- package/dist/preview.js.map +1 -1
- package/dist/protocol.cjs +705 -396
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +49 -100
- package/dist/protocol.d.ts +49 -100
- package/dist/protocol.js +56 -75
- package/dist/protocol.js.map +1 -1
- package/dist/release.cjs +37 -0
- package/dist/release.cjs.map +1 -1
- package/dist/release.d.cts +29 -3
- package/dist/release.d.ts +29 -3
- package/dist/release.js +13 -1
- package/dist/release.js.map +1 -1
- package/dist/replay-input-log-BvX4As2f.d.ts +31 -0
- package/dist/replay-input-log-Vcl0VDIy.d.cts +31 -0
- package/dist/room-protocol.cjs +794 -0
- package/dist/room-protocol.cjs.map +1 -0
- package/dist/room-protocol.d.cts +63 -0
- package/dist/room-protocol.d.ts +63 -0
- package/dist/room-protocol.js +143 -0
- package/dist/room-protocol.js.map +1 -0
- package/dist/room-session.cjs +2336 -0
- package/dist/room-session.cjs.map +1 -0
- package/dist/room-session.d.cts +77 -0
- package/dist/room-session.d.ts +77 -0
- package/dist/room-session.js +103 -0
- package/dist/room-session.js.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.cjs +207 -0
- package/dist/runtime/prefab-inspection-bridge.cjs.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.d.cts +156 -0
- package/dist/runtime/prefab-inspection-bridge.d.ts +156 -0
- package/dist/runtime/prefab-inspection-bridge.js +22 -0
- package/dist/runtime/prefab-inspection-bridge.js.map +1 -0
- package/dist/runtime-control.cjs +2150 -0
- package/dist/runtime-control.cjs.map +1 -0
- package/dist/runtime-control.d.cts +985 -0
- package/dist/runtime-control.d.ts +985 -0
- package/dist/runtime-control.js +268 -0
- package/dist/runtime-control.js.map +1 -0
- package/dist/runtime-inspection.cjs +1319 -0
- package/dist/runtime-inspection.cjs.map +1 -0
- package/dist/runtime-inspection.d.cts +555 -0
- package/dist/runtime-inspection.d.ts +555 -0
- package/dist/runtime-inspection.js +29 -0
- package/dist/runtime-inspection.js.map +1 -0
- package/dist/runtime-reporting-K_ZXpubu.d.cts +43 -0
- package/dist/runtime-reporting-K_ZXpubu.d.ts +43 -0
- package/dist/runtime-topology.cjs +2 -5
- package/dist/runtime-topology.cjs.map +1 -1
- package/dist/runtime-topology.d.cts +1 -1
- package/dist/runtime-topology.d.ts +1 -1
- package/dist/runtime-topology.js +1 -1
- package/dist/runtime-topology.js.map +1 -1
- package/dist/scoped-connector-CiiWu06D.d.ts +66 -0
- package/dist/scoped-connector-D7252pn0.d.cts +66 -0
- package/dist/sdk-channels-S6j6AH8v.d.cts +103 -0
- package/dist/sdk-channels-S6j6AH8v.d.ts +103 -0
- package/dist/simulation-BfRnC4rg.d.ts +782 -0
- package/dist/simulation-BwZx2pgt.d.cts +782 -0
- package/dist/{standard-match-phase-BucA5dYo.d.ts → standard-match-phase-D4N-AU0d.d.cts} +3 -13
- package/dist/{standard-match-phase-U2ra8J-0.d.cts → standard-match-phase-abt8ZjCh.d.ts} +3 -13
- package/dist/transport-CWF29jU6.d.cts +173 -0
- package/dist/transport-CWF29jU6.d.ts +173 -0
- package/dist/types-p28maMEo.d.cts +102 -0
- package/dist/types-p28maMEo.d.ts +102 -0
- package/dist/ui.cjs +2324 -1051
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +75 -17
- package/dist/ui.d.ts +75 -17
- package/dist/ui.js +555 -389
- package/dist/ui.js.map +1 -1
- package/package.json +88 -37
- package/src/agent/agent-action.ts +0 -39
- package/src/agent/agent-contract-conformance.ts +208 -0
- package/src/agent/agent-contract.ts +2 -4
- package/src/agent/agent-evaluator.ts +95 -0
- package/src/agent/capture-canvas.ts +79 -0
- package/src/agent/host-canvas-capture.ts +189 -0
- package/src/agent-tooling.ts +8 -18
- package/src/arcade/bridge/controller.ts +8 -11
- package/src/arcade/bridge/host.ts +6 -11
- package/src/arcade/bridge/iframe.ts +1 -50
- package/src/arcade/host.ts +0 -1
- package/src/arcade/runtime.ts +6 -0
- package/src/arcade/surface.ts +6 -1
- package/src/arcade/url.ts +2 -9
- package/src/audio/audio-manager.ts +23 -47
- package/src/audio/hooks.tsx +59 -72
- package/src/components/controller-player-name-field.tsx +2 -2
- package/src/components/controller-primary-action.tsx +1 -1
- package/src/components/controls.tsx +398 -0
- package/src/components/gamepad-layout.tsx +69 -0
- package/src/components/join-url-controls.tsx +5 -1
- package/src/components/lifecycle-action-group.tsx +1 -1
- package/src/components/player-avatar.tsx +50 -3
- package/src/components/room-qr-code.tsx +36 -77
- package/src/components/stage-capture-surface.tsx +91 -0
- package/src/components/surface-viewport.tsx +16 -3
- package/src/components/ui/button.tsx +1 -1
- package/src/constants.ts +0 -15
- package/src/context/air-jam-context.tsx +64 -195
- package/src/context/session-providers.tsx +13 -10
- package/src/controller-bridge.ts +7 -0
- package/src/core/assets.ts +48 -0
- package/src/core/config.ts +70 -0
- package/src/core/connection-store.ts +77 -0
- package/src/core/controller-input.ts +147 -0
- package/src/core/controller-runtime.ts +427 -0
- package/src/core/dev-events.ts +18 -0
- package/src/core/environment.ts +132 -0
- package/src/core/game-description.ts +44 -0
- package/src/core/game.ts +130 -0
- package/src/core/host-input.ts +207 -0
- package/src/core/host-runtime.ts +988 -0
- package/src/core/hosted-rooms.ts +26 -0
- package/src/core/input-bindings.ts +180 -0
- package/src/core/input-log.ts +144 -0
- package/src/core/input.ts +228 -0
- package/src/core/local-input.ts +319 -0
- package/src/core/replay-input-log.ts +298 -0
- package/src/core/replicated-store.ts +1178 -0
- package/src/core/room-action-ack.ts +43 -0
- package/src/core/settings.ts +202 -0
- package/src/core/simulation.ts +307 -0
- package/src/core/theme.ts +33 -0
- package/src/core.ts +162 -0
- package/src/dev/browser-log-sink.ts +47 -27
- package/src/diagnostics.ts +5 -6
- package/src/hooks/internal/use-controller-runtime-api.ts +58 -836
- package/src/hooks/internal/use-host-runtime-api.ts +98 -1013
- package/src/hooks/internal/use-runtime-inspection-contract.ts +14 -2
- package/src/hooks/use-air-jam-controller.ts +41 -62
- package/src/hooks/use-air-jam-host.ts +66 -107
- package/src/hooks/use-air-jam-settings.ts +27 -0
- package/src/hooks/use-controller-toasts.ts +16 -19
- package/src/hooks/use-host-agent-capture.ts +31 -0
- package/src/hooks/use-lifecycle-action-group-model.ts +1 -1
- package/src/hooks/use-send-signal.ts +23 -156
- package/src/hooks/use-simulation.ts +83 -0
- package/src/index.ts +26 -106
- package/src/lifecycle/index.ts +0 -4
- package/src/lifecycle/standard-match-phase.ts +1 -22
- package/src/metadata/manifest.ts +8 -20
- package/src/metadata.ts +1 -1
- package/src/platform-machine.ts +236 -15
- package/src/prefabs/types.ts +91 -20
- package/src/prefabs/view.ts +82 -0
- package/src/prefabs.ts +19 -0
- package/src/preview/host-workspace.tsx +4 -9
- package/src/preview/identity.ts +31 -23
- package/src/preview/layout.ts +5 -1
- package/src/preview/manager.ts +205 -78
- package/src/preview/messages.ts +47 -0
- package/src/preview/ownership.ts +6 -1
- package/src/preview/url.ts +46 -23
- package/src/preview/window.tsx +26 -69
- package/src/preview/workspace-local-seats.ts +166 -0
- package/src/preview/workspace.tsx +137 -66
- package/src/preview.ts +27 -15
- package/src/protocol/actions.ts +58 -0
- package/src/protocol/arcade-platform-actions.ts +20 -16
- package/src/protocol/controller.ts +15 -169
- package/src/protocol/core.ts +8 -15
- package/src/protocol/dev-log-events.ts +5 -84
- package/src/protocol/leased-control.ts +177 -0
- package/src/protocol/room/addressing.ts +35 -0
- package/src/protocol/room/close-codes.ts +33 -0
- package/src/protocol/room/frames.ts +343 -0
- package/src/protocol/room/input-codec.ts +182 -0
- package/src/protocol/room/limits.ts +58 -0
- package/src/protocol/room/patch.ts +135 -0
- package/src/protocol/room/sdk-channels.ts +81 -0
- package/src/protocol/room/seat-id.ts +31 -0
- package/src/protocol/room/transport.ts +63 -0
- package/src/protocol/room/weight.ts +58 -0
- package/src/protocol/runtime-reporting.ts +78 -0
- package/src/protocol/signed-envelope.ts +176 -0
- package/src/protocol.ts +4 -7
- package/src/qrcode.d.ts +3 -13
- package/src/release.ts +32 -0
- package/src/room-protocol.ts +10 -0
- package/src/room-session/browser-wake-events.ts +14 -0
- package/src/room-session/channel-state.ts +293 -0
- package/src/room-session/clock.ts +24 -0
- package/src/room-session/host-room-session.ts +379 -0
- package/src/room-session/input-lane.ts +125 -0
- package/src/room-session/listeners.ts +22 -0
- package/src/room-session/loopback-link.ts +58 -0
- package/src/room-session/phone-room-session.ts +368 -0
- package/src/room-session/port-link.ts +116 -0
- package/src/room-session/room-key.ts +9 -0
- package/src/room-session/roster.ts +23 -0
- package/src/room-session/scoped-connector.ts +577 -0
- package/src/room-session/session-link.ts +306 -0
- package/src/room-session/web-socket-link.ts +57 -0
- package/src/room-session.ts +12 -0
- package/src/runtime/air-jam-config.ts +53 -51
- package/src/runtime/air-jam-error-boundary.tsx +52 -2
- package/src/runtime/arcade-runtime-url.ts +8 -9
- package/src/runtime/browser-controller-environment.ts +116 -0
- package/src/runtime/browser-host-environment.ts +137 -0
- package/src/runtime/browser-replay.ts +211 -0
- package/src/runtime/browser-room.ts +41 -0
- package/src/runtime/connected-runtime-error-boundary.tsx +58 -0
- package/src/runtime/contracts/agent-control.ts +195 -0
- package/src/runtime/contracts/clip.ts +169 -0
- package/src/runtime/contracts/control.ts +744 -59
- package/src/runtime/contracts/controller-agent.ts +130 -0
- package/src/runtime/contracts/input-log.ts +38 -0
- package/src/runtime/contracts/inspection.ts +25 -22
- package/src/runtime/contracts/observation.ts +186 -0
- package/src/runtime/contracts/runtime-identity.ts +43 -0
- package/src/runtime/contracts/timeline.ts +59 -0
- package/src/runtime/controller-agent-bridge.ts +152 -0
- package/src/runtime/controller-bridge-context.ts +29 -0
- package/src/runtime/controller-capture.ts +50 -0
- package/src/runtime/controller-identity.ts +54 -115
- package/src/runtime/controller-presentation.ts +47 -17
- package/src/runtime/controller-press.ts +271 -0
- package/src/runtime/create-air-jam-app.tsx +120 -83
- package/src/runtime/dev-runtime-events.ts +6 -18
- package/src/runtime/embedded-parent.ts +22 -0
- package/src/runtime/embedded-runtime-adapters.ts +10 -9
- package/src/runtime/host-agent-bridge.ts +127 -0
- package/src/runtime/host-capture-boundary.tsx +92 -0
- package/src/runtime/host-capture-context.ts +7 -0
- package/src/runtime/host-clip-reader.ts +93 -0
- package/src/runtime/host-clip-recorder.ts +342 -0
- package/src/runtime/host-input-log-reader.ts +120 -0
- package/src/runtime/host-observation.ts +207 -0
- package/src/runtime/host-pace.ts +36 -0
- package/src/runtime/host-runtime-fault.ts +51 -0
- package/src/runtime/host-timeline.ts +152 -0
- package/src/runtime/local-players.tsx +96 -0
- package/src/runtime/local-reference-game-identity.ts +13 -0
- package/src/runtime/local-seats.ts +612 -0
- package/src/runtime/participant-control.ts +162 -0
- package/src/runtime/prefab-inspection-bridge.ts +174 -0
- package/src/runtime/prefab-inspection-clock.ts +12 -0
- package/src/runtime/prefab-inspection-context.ts +20 -0
- package/src/runtime/prefab-inspection-runtime.tsx +328 -0
- package/src/runtime/preview-inspection-bridge.ts +130 -0
- package/src/runtime/replay-runtime.tsx +101 -0
- package/src/runtime/room-bridge.ts +110 -0
- package/src/runtime/runtime-owner-contexts.tsx +9 -0
- package/src/runtime/runtime-session-params.ts +23 -86
- package/src/runtime/session-runtimes.tsx +231 -64
- package/src/runtime/stage-capture.ts +25 -0
- package/src/runtime-control.ts +44 -8
- package/src/runtime-inspection.ts +14 -7
- package/src/runtime-topology.ts +7 -8
- package/src/settings/platform-settings-runtime.tsx +48 -8
- package/src/settings/platform-settings.ts +0 -96
- package/src/store/use-air-jam-store.ts +73 -0
- package/src/ui.ts +3 -3
- package/src/utils/is-rpc-serializable.ts +11 -19
- package/src/utils/url-builder.ts +0 -7
- package/dist/arcade/bridge.cjs +0 -1067
- package/dist/arcade/bridge.cjs.map +0 -1
- package/dist/arcade/bridge.d.cts +0 -11
- package/dist/arcade/bridge.d.ts +0 -11
- package/dist/arcade/bridge.js +0 -76
- package/dist/arcade/bridge.js.map +0 -1
- package/dist/arcade-runtime-url-BW-MUAOY.d.cts +0 -28
- package/dist/arcade-runtime-url-l8qj01Pg.d.ts +0 -28
- package/dist/arcade.cjs +0 -1737
- package/dist/arcade.cjs.map +0 -1
- package/dist/arcade.d.cts +0 -18
- package/dist/arcade.d.ts +0 -18
- package/dist/arcade.js +0 -123
- package/dist/arcade.js.map +0 -1
- package/dist/capabilities.cjs +0 -39
- package/dist/capabilities.cjs.map +0 -1
- package/dist/capabilities.d.cts +0 -31
- package/dist/capabilities.d.ts +0 -31
- package/dist/capabilities.js +0 -12
- package/dist/capabilities.js.map +0 -1
- package/dist/chunk-32NYL7XI.js +0 -539
- package/dist/chunk-32NYL7XI.js.map +0 -1
- package/dist/chunk-3USU7GY2.js.map +0 -1
- package/dist/chunk-6CMB356F.js +0 -193
- package/dist/chunk-6CMB356F.js.map +0 -1
- package/dist/chunk-7OTQTT6H.js.map +0 -1
- package/dist/chunk-BE6Z4SIT.js.map +0 -1
- package/dist/chunk-CVYR5RJT.js +0 -184
- package/dist/chunk-CVYR5RJT.js.map +0 -1
- package/dist/chunk-DY67S3LR.js.map +0 -1
- package/dist/chunk-E5PVHEAX.js +0 -126
- package/dist/chunk-E5PVHEAX.js.map +0 -1
- package/dist/chunk-EDRQIOCV.js +0 -25
- package/dist/chunk-EDRQIOCV.js.map +0 -1
- package/dist/chunk-EVZJA6RN.js.map +0 -1
- package/dist/chunk-IKKDONQL.js +0 -1
- package/dist/chunk-IKKDONQL.js.map +0 -1
- package/dist/chunk-JO2HR5PV.js +0 -43
- package/dist/chunk-JO2HR5PV.js.map +0 -1
- package/dist/chunk-JTF47B56.js +0 -1
- package/dist/chunk-JTF47B56.js.map +0 -1
- package/dist/chunk-KOB73SPD.js +0 -216
- package/dist/chunk-KOB73SPD.js.map +0 -1
- package/dist/chunk-LIXPF4P6.js +0 -22
- package/dist/chunk-LIXPF4P6.js.map +0 -1
- package/dist/chunk-M4DKOI42.js +0 -32
- package/dist/chunk-M4DKOI42.js.map +0 -1
- package/dist/chunk-MPDMJIX5.js +0 -1
- package/dist/chunk-MPDMJIX5.js.map +0 -1
- package/dist/chunk-NCL6WJCL.js.map +0 -1
- package/dist/chunk-NUJBMV3O.js.map +0 -1
- package/dist/chunk-Q4UALQO4.js +0 -288
- package/dist/chunk-Q4UALQO4.js.map +0 -1
- package/dist/chunk-TGRTEWYV.js +0 -195
- package/dist/chunk-TGRTEWYV.js.map +0 -1
- package/dist/chunk-UWJOIVON.js.map +0 -1
- package/dist/chunk-W2VK36RO.js +0 -11
- package/dist/chunk-W2VK36RO.js.map +0 -1
- package/dist/chunk-X24K52DG.js.map +0 -1
- package/dist/chunk-YXHH3MQT.js +0 -230
- package/dist/chunk-YXHH3MQT.js.map +0 -1
- package/dist/chunk-ZLPL2R3R.js.map +0 -1
- package/dist/chunk-ZTQ5SP4H.js +0 -9
- package/dist/chunk-ZTQ5SP4H.js.map +0 -1
- package/dist/controller-Bod8YYr1.d.cts +0 -172
- package/dist/controller-DxVchfiA.d.ts +0 -172
- package/dist/dev-log-events-CVAM29hx.d.cts +0 -123
- package/dist/dev-log-events-CVAM29hx.d.ts +0 -123
- package/dist/handshake-CC_LrK5g.d.cts +0 -31
- package/dist/handshake-CC_LrK5g.d.ts +0 -31
- package/dist/host-8hmq_Sgc.d.cts +0 -109
- package/dist/host-Cw-N6e-5.d.ts +0 -109
- package/dist/notices-CnGaaS8B.d.ts +0 -38
- package/dist/notices-NyDM5Mtz.d.cts +0 -38
- package/dist/realtime-client-Cu8yVJFw.d.cts +0 -15
- package/dist/realtime-client-Cu8yVJFw.d.ts +0 -15
- package/dist/sync-B6QsNrXz.d.cts +0 -125
- package/dist/sync-B6QsNrXz.d.ts +0 -125
- package/src/arcade/bridge.ts +0 -3
- package/src/arcade.ts +0 -4
- package/src/capabilities/manifest.ts +0 -71
- package/src/capabilities.ts +0 -12
- package/src/context/socket-manager.ts +0 -79
- package/src/events.ts +0 -124
- package/src/hooks/internal/use-runtime-control-contract.ts +0 -15
- package/src/hooks/internal/use-runtime-observability-contract.ts +0 -24
- package/src/hooks/use-connection-status.ts +0 -8
- package/src/hooks/use-controller-tick.ts +0 -65
- package/src/hooks/use-get-input.ts +0 -100
- package/src/hooks/use-host-arcade-restore.ts +0 -30
- package/src/hooks/use-host-tick.ts +0 -171
- package/src/hooks/use-input-writer.ts +0 -83
- package/src/hooks/use-players.ts +0 -12
- package/src/internal/input-manager.ts +0 -356
- package/src/protocol/errors.ts +0 -21
- package/src/protocol/host-grant.ts +0 -185
- package/src/protocol/host.ts +0 -138
- package/src/protocol/notices.ts +0 -43
- package/src/protocol/signals.ts +0 -38
- package/src/protocol/socket-events.ts +0 -154
- package/src/protocol/sync.ts +0 -121
- package/src/runtime/contracts/observability.ts +0 -94
- package/src/runtime/controller-bridge.ts +0 -451
- package/src/runtime/controller-realtime-client.ts +0 -591
- package/src/runtime/host-bridge.ts +0 -388
- package/src/runtime/host-realtime-client.ts +0 -550
- package/src/runtime/realtime-client.ts +0 -20
- package/src/runtime/validate-arcade-bridge-attach.ts +0 -14
- package/src/runtime-observability.ts +0 -9
- package/src/state/connection-store.ts +0 -152
- package/src/store/create-air-jam-store.ts +0 -1141
- package/src/store/index.ts +0 -1
- package/src/utils/ids.ts +0 -31
package/dist/preview.cjs
CHANGED
|
@@ -30,51 +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
|
-
// src/runtime-topology.ts
|
|
53
|
-
var LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
54
|
-
"standalone-dev",
|
|
55
|
-
"standalone-secure",
|
|
56
|
-
"arcade-live",
|
|
57
|
-
"arcade-built"
|
|
58
|
-
]);
|
|
59
|
-
var assertString = (value, fieldName) => {
|
|
60
|
-
if (typeof value !== "string") {
|
|
61
|
-
throw new Error(`Runtime topology field "${fieldName}" must be a string.`);
|
|
62
|
-
}
|
|
63
|
-
const normalized = value.trim();
|
|
64
|
-
if (!normalized) {
|
|
65
|
-
throw new Error(`Runtime topology field "${fieldName}" cannot be empty.`);
|
|
66
|
-
}
|
|
67
|
-
return normalized;
|
|
68
|
-
};
|
|
69
|
-
var isLocalDevControlSurfaceRuntimeMode = (runtimeMode) => LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES.has(
|
|
70
|
-
assertString(runtimeMode, "runtimeMode")
|
|
71
|
-
);
|
|
72
|
-
|
|
73
57
|
// src/context/air-jam-context.tsx
|
|
74
58
|
var import_react = require("react");
|
|
75
|
-
var
|
|
59
|
+
var import_zustand = require("zustand");
|
|
76
60
|
var import_shallow = require("zustand/react/shallow");
|
|
77
61
|
|
|
62
|
+
// src/core/connection-store.ts
|
|
63
|
+
var import_vanilla = require("zustand/vanilla");
|
|
64
|
+
|
|
78
65
|
// src/diagnostics.ts
|
|
79
66
|
var listeners = /* @__PURE__ */ new Set();
|
|
80
67
|
var lastEmissionByKey = /* @__PURE__ */ new Map();
|
|
@@ -131,83 +118,91 @@ var createAirJamDiagnosticError = (code, message, details) => {
|
|
|
131
118
|
return error;
|
|
132
119
|
};
|
|
133
120
|
|
|
134
|
-
// src/protocol/
|
|
135
|
-
var import_zod2 = require("zod");
|
|
136
|
-
|
|
137
|
-
// src/protocol/core.ts
|
|
121
|
+
// src/protocol/actions.ts
|
|
138
122
|
var import_zod = require("zod");
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
input: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown())
|
|
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()
|
|
146
129
|
});
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
roomSettings: import_zod2.z.object({
|
|
155
|
-
audio: import_zod2.z.object({
|
|
156
|
-
masterVolume: import_zod2.z.number().min(0).max(1),
|
|
157
|
-
musicVolume: import_zod2.z.number().min(0).max(1),
|
|
158
|
-
sfxVolume: import_zod2.z.number().min(0).max(1)
|
|
159
|
-
}),
|
|
160
|
-
previewControllers: import_zod2.z.object({
|
|
161
|
-
activeOpacity: import_zod2.z.number().min(0).max(1)
|
|
162
|
-
})
|
|
163
|
-
}).optional(),
|
|
164
|
-
runtimeState: import_zod2.z.enum(["paused", "playing"]).optional(),
|
|
165
|
-
stateVersion: import_zod2.z.number().int().nonnegative().optional()
|
|
166
|
-
})
|
|
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()
|
|
167
137
|
});
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
* Stable local controller device identity used as a reconnect hint.
|
|
173
|
-
* Older clients may omit this and fall back to controllerId-only behavior.
|
|
174
|
-
*/
|
|
175
|
-
deviceId: import_zod2.z.string().min(8).max(128).optional(),
|
|
176
|
-
nickname: import_zod2.z.string().trim().min(1).max(24).optional(),
|
|
177
|
-
/** Preset avatar key (platform-defined); optional at join. */
|
|
178
|
-
avatarId: import_zod2.z.string().trim().min(1).max(48).optional(),
|
|
179
|
-
capabilityToken: import_zod2.z.string().min(1).optional()
|
|
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")
|
|
180
142
|
});
|
|
181
|
-
var
|
|
182
|
-
|
|
183
|
-
|
|
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();
|
|
155
|
+
var arcadeBrowserNavigatePayloadSchema = arcadeBrowserConfirmPayloadSchema.extend({
|
|
156
|
+
direction: import_zod2.z.enum(["up", "down", "left", "right"])
|
|
184
157
|
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
158
|
+
|
|
159
|
+
// src/protocol/controller.ts
|
|
160
|
+
var import_zod3 = require("zod");
|
|
161
|
+
|
|
162
|
+
// src/settings/platform-settings.ts
|
|
163
|
+
var DEFAULT_PLATFORM_SETTINGS = {
|
|
164
|
+
audio: {
|
|
165
|
+
masterVolume: 1,
|
|
166
|
+
musicVolume: 0.8,
|
|
167
|
+
sfxVolume: 1
|
|
168
|
+
},
|
|
169
|
+
accessibility: {
|
|
170
|
+
reducedMotion: false,
|
|
171
|
+
highContrast: false
|
|
172
|
+
},
|
|
173
|
+
feedback: {
|
|
174
|
+
hapticsEnabled: true
|
|
175
|
+
},
|
|
176
|
+
previewControllers: {
|
|
177
|
+
activeOpacity: 1
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
var DEFAULT_ROOM_PLATFORM_SETTINGS = {
|
|
181
|
+
audio: DEFAULT_PLATFORM_SETTINGS.audio,
|
|
182
|
+
previewControllers: DEFAULT_PLATFORM_SETTINGS.previewControllers
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/protocol/controller.ts
|
|
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()
|
|
188
191
|
});
|
|
189
|
-
var playerProfilePatchSchema =
|
|
190
|
-
label:
|
|
191
|
-
avatarId:
|
|
192
|
+
var playerProfilePatchSchema = import_zod3.z.object({
|
|
193
|
+
label: import_zod3.z.string().trim().min(1).max(24).optional(),
|
|
194
|
+
avatarId: import_zod3.z.string().trim().min(1).max(48).optional()
|
|
192
195
|
}).strict();
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
"system",
|
|
203
|
-
"play_sound",
|
|
204
|
-
"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"
|
|
205
205
|
]);
|
|
206
|
-
var controllerPrivilegedCapabilitySchema = import_zod2.z.object({
|
|
207
|
-
token: import_zod2.z.string().min(1),
|
|
208
|
-
expiresAt: import_zod2.z.number().int().positive(),
|
|
209
|
-
grants: import_zod2.z.array(controllerPrivilegedGrantSchema).min(1)
|
|
210
|
-
});
|
|
211
206
|
|
|
212
207
|
// src/protocol/dev-log-events.ts
|
|
213
208
|
var AIRJAM_DEV_LOG_EVENTS = {
|
|
@@ -215,19 +210,9 @@ var AIRJAM_DEV_LOG_EVENTS = {
|
|
|
215
210
|
started: "server.started",
|
|
216
211
|
startupFailed: "server.startup.failed"
|
|
217
212
|
},
|
|
218
|
-
socket: {
|
|
219
|
-
connected: "socket.connected",
|
|
220
|
-
disconnected: "socket.disconnected"
|
|
221
|
-
},
|
|
222
213
|
auth: {
|
|
223
214
|
modeDisabled: "auth.mode.disabled",
|
|
224
|
-
modeMasterKey: "auth.mode.master_key"
|
|
225
|
-
modeDatabaseAndHostGrant: "auth.mode.database_and_host_grant",
|
|
226
|
-
modeDatabase: "auth.mode.database",
|
|
227
|
-
modeHostGrantOnly: "auth.mode.host_grant_only",
|
|
228
|
-
backendMissing: "auth.backend.missing",
|
|
229
|
-
appIdLastUsedAtUpdateFailed: "auth.app_id_last_used_at_update.failed",
|
|
230
|
-
appIdVerificationDatabaseError: "auth.app_id_verification.database_error"
|
|
215
|
+
modeMasterKey: "auth.mode.master_key"
|
|
231
216
|
},
|
|
232
217
|
browser: {
|
|
233
218
|
logSessionStarted: "browser.log_session.started",
|
|
@@ -243,84 +228,18 @@ var AIRJAM_DEV_LOG_EVENTS = {
|
|
|
243
228
|
providerUnmounted: "runtime.provider.unmounted",
|
|
244
229
|
windowBeforeUnload: "runtime.window.beforeunload",
|
|
245
230
|
windowPageHide: "runtime.window.pagehide",
|
|
246
|
-
|
|
247
|
-
socketDisconnected: "runtime.socket.disconnected",
|
|
248
|
-
socketConnectError: "runtime.socket.connect_error",
|
|
249
|
-
hostCreateRoomRequested: "runtime.host.create_room.requested",
|
|
250
|
-
hostReconnectRequested: "runtime.host.reconnect.requested",
|
|
251
|
-
hostReconnectRetryScheduled: "runtime.host.reconnect.retry_scheduled",
|
|
231
|
+
roomStatus: "runtime.room.status",
|
|
252
232
|
hostResetRoomRequested: "runtime.host.reset_room.requested",
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
233
|
+
clipCaptureFailed: "runtime.host.clip_capture_failed",
|
|
234
|
+
hostFrameFault: "runtime.host.frame_fault",
|
|
235
|
+
errorReport: "runtime.error_report",
|
|
256
236
|
phaseTransition: "runtime.phase.transition",
|
|
257
|
-
stateVersionReceived: "runtime.state_version.received",
|
|
258
|
-
invariantViolation: "runtime.invariant.violation",
|
|
259
237
|
embeddedBridgeRequested: "runtime.embedded_bridge.requested",
|
|
260
|
-
embeddedBridgeAttached: "runtime.embedded_bridge.attached",
|
|
261
238
|
embeddedBridgeRejected: "runtime.embedded_bridge.rejected",
|
|
262
|
-
embeddedBridgeClosed: "runtime.embedded_bridge.closed",
|
|
263
239
|
browserLogSinkFailure: "runtime.browser_log_sink.failure"
|
|
264
240
|
},
|
|
265
241
|
host: {
|
|
266
|
-
|
|
267
|
-
bootstrapVerified: "host.bootstrap.verified",
|
|
268
|
-
bootstrapRejected: "host.bootstrap.rejected",
|
|
269
|
-
disconnectPendingRoomClose: "host.disconnect.pending_room_close",
|
|
270
|
-
disconnectRoomClosed: "host.disconnect.room_closed",
|
|
271
|
-
registerSystemAccepted: "host.register_system.accepted",
|
|
272
|
-
registerSystemRejected: "host.register_system.rejected",
|
|
273
|
-
createRoomAccepted: "host.create_room.accepted",
|
|
274
|
-
createRoomRejected: "host.create_room.rejected",
|
|
275
|
-
reconnectAccepted: "host.reconnect.accepted",
|
|
276
|
-
reconnectRejected: "host.reconnect.rejected",
|
|
277
|
-
resetRoomAccepted: "host.reset_room.accepted",
|
|
278
|
-
resetRoomRejected: "host.reset_room.rejected",
|
|
279
|
-
systemAccepted: "host.system.accepted",
|
|
280
|
-
systemRejected: "host.system.rejected",
|
|
281
|
-
stateRejected: "host.state.rejected",
|
|
282
|
-
signalRejected: "host.signal.rejected",
|
|
283
|
-
playSoundRejected: "host.play_sound.rejected",
|
|
284
|
-
stateBroadcastSummary: "host.state_broadcast.summary",
|
|
285
|
-
reconnectStateReconcile: "host.reconnect.state_reconcile",
|
|
286
|
-
stateSyncSummary: "host.state_sync.summary",
|
|
287
|
-
stateSyncRejected: "host.state_sync.rejected"
|
|
288
|
-
},
|
|
289
|
-
controller: {
|
|
290
|
-
joinAccepted: "controller.join.accepted",
|
|
291
|
-
joinRejected: "controller.join.rejected",
|
|
292
|
-
resumeAccepted: "controller.resume.accepted",
|
|
293
|
-
disconnectPendingResume: "controller.disconnect.pending_resume",
|
|
294
|
-
disconnectLeaseExpired: "controller.disconnect.lease_expired",
|
|
295
|
-
disconnectApplied: "controller.disconnect.applied",
|
|
296
|
-
profileUpdateAccepted: "controller.profile_update.accepted",
|
|
297
|
-
profileUpdateRejected: "controller.profile_update.rejected",
|
|
298
|
-
leaveAccepted: "controller.leave.accepted",
|
|
299
|
-
leaveRejected: "controller.leave.rejected",
|
|
300
|
-
inputSummary: "controller.input.summary",
|
|
301
|
-
inputDroppedSummary: "controller.input_dropped.summary",
|
|
302
|
-
inputRejected: "controller.input.rejected",
|
|
303
|
-
systemAccepted: "controller.system.accepted",
|
|
304
|
-
systemRejected: "controller.system.rejected",
|
|
305
|
-
playSoundRejected: "controller.play_sound.rejected",
|
|
306
|
-
actionRpcSummary: "controller.action_rpc.summary",
|
|
307
|
-
actionRpcRejected: "controller.action_rpc.rejected"
|
|
308
|
-
},
|
|
309
|
-
system: {
|
|
310
|
-
launchGameAccepted: "system.launch_game.accepted",
|
|
311
|
-
launchGameRejected: "system.launch_game.rejected",
|
|
312
|
-
closeGameAccepted: "system.close_game.accepted",
|
|
313
|
-
closeGameRejected: "system.close_game.rejected"
|
|
314
|
-
},
|
|
315
|
-
childHost: {
|
|
316
|
-
joinAccepted: "child_host.join.accepted",
|
|
317
|
-
joinRejected: "child_host.join.rejected",
|
|
318
|
-
disconnectPendingSystemFocus: "child_host.disconnect.pending_system_focus",
|
|
319
|
-
disconnectSystemFocusRestored: "child_host.disconnect.system_focus_restored"
|
|
320
|
-
},
|
|
321
|
-
embeddedGame: {
|
|
322
|
-
activateAccepted: "embedded_game.activate.accepted",
|
|
323
|
-
activateRejected: "embedded_game.activate.rejected"
|
|
242
|
+
stateRestoreDiscarded: "host.state_restore.discarded"
|
|
324
243
|
}
|
|
325
244
|
};
|
|
326
245
|
var AIRJAM_BROWSER_LOG_EVENT_BY_SOURCE = {
|
|
@@ -331,92 +250,522 @@ var AIRJAM_BROWSER_LOG_EVENT_BY_SOURCE = {
|
|
|
331
250
|
runtime: AIRJAM_DEV_LOG_EVENTS.browser.runtime
|
|
332
251
|
};
|
|
333
252
|
|
|
334
|
-
// src/protocol/
|
|
335
|
-
var
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
|
306
|
+
});
|
|
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."
|
|
340
330
|
});
|
|
341
|
-
var
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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()
|
|
345
338
|
});
|
|
346
|
-
var
|
|
347
|
-
|
|
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)
|
|
348
352
|
});
|
|
349
|
-
var
|
|
350
|
-
|
|
351
|
-
|
|
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()
|
|
352
363
|
});
|
|
353
|
-
var
|
|
354
|
-
|
|
355
|
-
|
|
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()
|
|
356
445
|
});
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
|
|
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()
|
|
360
452
|
});
|
|
361
|
-
var
|
|
362
|
-
|
|
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
|
|
363
572
|
});
|
|
364
|
-
var
|
|
365
|
-
|
|
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()
|
|
366
577
|
});
|
|
367
|
-
var
|
|
368
|
-
|
|
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()
|
|
369
582
|
});
|
|
370
|
-
var
|
|
371
|
-
|
|
372
|
-
|
|
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()
|
|
373
587
|
});
|
|
374
588
|
|
|
375
|
-
// src/
|
|
376
|
-
var
|
|
377
|
-
var
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
iat: import_zod4.z.number().int().positive().optional(),
|
|
383
|
-
scopes: import_zod4.z.array(hostGrantScopeSchema).min(1).default(["host:bootstrap"]),
|
|
384
|
-
origins: import_zod4.z.array(import_zod4.z.string().min(1)).optional()
|
|
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)
|
|
385
596
|
});
|
|
386
|
-
var
|
|
387
|
-
|
|
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;
|
|
388
602
|
|
|
389
|
-
// src/protocol/
|
|
390
|
-
var
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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)
|
|
398
651
|
}).strict();
|
|
399
|
-
var
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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()
|
|
404
658
|
}).strict();
|
|
405
|
-
var
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
|
411
668
|
}).strict();
|
|
412
|
-
var
|
|
669
|
+
var controllerLeasedControlSchema = leasedControlRequestSchema.extend({
|
|
413
670
|
roomId: roomCodeSchema,
|
|
414
|
-
|
|
415
|
-
|
|
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(),
|
|
730
|
+
roomId: roomCodeSchema,
|
|
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()
|
|
416
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();
|
|
417
766
|
|
|
418
767
|
// src/protocol/url-policy.ts
|
|
419
|
-
var
|
|
768
|
+
var import_zod13 = require("zod");
|
|
420
769
|
var ALLOWED_RUNTIME_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
421
770
|
var parseRuntimeUrl = (value) => {
|
|
422
771
|
try {
|
|
@@ -440,7 +789,7 @@ var getRuntimeUrlOrigin = (value) => {
|
|
|
440
789
|
const parsed = parseRuntimeUrl(value);
|
|
441
790
|
return parsed ? parsed.origin : null;
|
|
442
791
|
};
|
|
443
|
-
var runtimeUrlSchema =
|
|
792
|
+
var runtimeUrlSchema = import_zod13.z.string().trim().min(1).refine((value) => parseRuntimeUrl(value) !== null, {
|
|
444
793
|
message: "URL must be a valid http(s) URL without embedded credentials."
|
|
445
794
|
});
|
|
446
795
|
var appendRuntimeQueryParams = (baseUrl, params) => {
|
|
@@ -457,34 +806,682 @@ var appendRuntimeQueryParams = (baseUrl, params) => {
|
|
|
457
806
|
return parsed.toString();
|
|
458
807
|
};
|
|
459
808
|
|
|
460
|
-
// src/
|
|
461
|
-
var
|
|
809
|
+
// src/runtime-topology.ts
|
|
810
|
+
var LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
811
|
+
"standalone-dev",
|
|
812
|
+
"standalone-secure",
|
|
813
|
+
"arcade-live",
|
|
814
|
+
"arcade-built"
|
|
815
|
+
]);
|
|
816
|
+
var assertString = (value, fieldName) => {
|
|
817
|
+
if (typeof value !== "string") {
|
|
818
|
+
throw new Error(`Runtime topology field "${fieldName}" must be a string.`);
|
|
819
|
+
}
|
|
820
|
+
const normalized = value.trim();
|
|
821
|
+
if (!normalized) {
|
|
822
|
+
throw new Error(`Runtime topology field "${fieldName}" cannot be empty.`);
|
|
823
|
+
}
|
|
824
|
+
return normalized;
|
|
825
|
+
};
|
|
826
|
+
var isLocalDevControlSurfaceRuntimeMode = (runtimeMode) => LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES.has(
|
|
827
|
+
assertString(runtimeMode, "runtimeMode")
|
|
828
|
+
);
|
|
462
829
|
|
|
463
|
-
// src/
|
|
464
|
-
var
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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);
|
|
479
951
|
}
|
|
480
952
|
};
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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();
|
|
1190
|
+
|
|
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()
|
|
484
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
|
+
});
|
|
485
1419
|
|
|
486
|
-
// src/
|
|
487
|
-
var
|
|
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
|
+
]);
|
|
488
1485
|
|
|
489
1486
|
// src/context/air-jam-context.tsx
|
|
490
1487
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -505,7 +1502,7 @@ var useAirJamConfig = () => {
|
|
|
505
1502
|
|
|
506
1503
|
// src/hooks/use-air-jam-host.ts
|
|
507
1504
|
var import_react4 = require("react");
|
|
508
|
-
var
|
|
1505
|
+
var import_zustand2 = require("zustand");
|
|
509
1506
|
var import_shallow2 = require("zustand/react/shallow");
|
|
510
1507
|
|
|
511
1508
|
// src/context/session-scope.ts
|
|
@@ -534,23 +1531,26 @@ var useAssertSessionScope = (expectedScope, hookName) => {
|
|
|
534
1531
|
|
|
535
1532
|
// src/runtime/runtime-owner-contexts.tsx
|
|
536
1533
|
var import_react3 = require("react");
|
|
1534
|
+
var fixedControllerOrientationContext = (0, import_react3.createContext)(void 0);
|
|
537
1535
|
var hostRuntimeContext = (0, import_react3.createContext)(null);
|
|
538
1536
|
var controllerRuntimeContext = (0, import_react3.createContext)(null);
|
|
1537
|
+
var declaredStoresContext = (0, import_react3.createContext)(null);
|
|
539
1538
|
|
|
540
1539
|
// src/hooks/use-air-jam-host.ts
|
|
541
1540
|
var toHostState = (state) => ({
|
|
542
1541
|
roomId: state.roomId,
|
|
543
1542
|
connectionStatus: state.connectionStatus,
|
|
544
1543
|
players: state.players,
|
|
545
|
-
controllers: state.controllerSessions,
|
|
546
1544
|
lastError: state.lastError,
|
|
1545
|
+
queuePosition: state.queuePosition,
|
|
547
1546
|
mode: state.mode,
|
|
548
|
-
runtimeState: state.runtimeState
|
|
1547
|
+
runtimeState: state.runtimeState,
|
|
1548
|
+
controllerOrientation: state.controllerOrientation
|
|
549
1549
|
});
|
|
550
1550
|
function useAirJamHost(selector) {
|
|
551
1551
|
useAssertSessionScope("host", "useAirJamHost");
|
|
552
1552
|
const { store } = useAirJamContext();
|
|
553
|
-
const selectedState = (0,
|
|
1553
|
+
const selectedState = (0, import_zustand2.useStore)(
|
|
554
1554
|
store,
|
|
555
1555
|
(0, import_shallow2.useShallow)((state) => {
|
|
556
1556
|
const hostState = toHostState(state);
|
|
@@ -563,7 +1563,7 @@ function useAirJamHost(selector) {
|
|
|
563
1563
|
if (!runtime) {
|
|
564
1564
|
throw createAirJamDiagnosticError(
|
|
565
1565
|
"AJ_SCOPE_MISMATCH",
|
|
566
|
-
"useAirJamHost requires a mounted host runtime boundary. Wrap the host tree with <
|
|
1566
|
+
"useAirJamHost requires a mounted host runtime boundary. Wrap the host tree with <airjam.Host> before reading host state.",
|
|
567
1567
|
{
|
|
568
1568
|
hookName: "useAirJamHost",
|
|
569
1569
|
expectedScope: "host",
|
|
@@ -584,23 +1584,23 @@ function useAirJamHost(selector) {
|
|
|
584
1584
|
var import_react5 = require("react");
|
|
585
1585
|
|
|
586
1586
|
// src/runtime/iframe-bridge.ts
|
|
587
|
-
var
|
|
1587
|
+
var import_zod27 = require("zod");
|
|
588
1588
|
|
|
589
1589
|
// src/contracts/v2/bridge.ts
|
|
590
|
-
var
|
|
591
|
-
var roomCodeSchema2 =
|
|
1590
|
+
var import_zod25 = require("zod");
|
|
1591
|
+
var roomCodeSchema2 = import_zod25.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, {
|
|
592
1592
|
message: "room code must contain only A-Z or 0-9"
|
|
593
1593
|
});
|
|
594
|
-
var
|
|
595
|
-
var
|
|
596
|
-
id:
|
|
597
|
-
label:
|
|
598
|
-
color:
|
|
599
|
-
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()
|
|
600
1600
|
}).strict();
|
|
601
|
-
var inputFrameEntrySchema =
|
|
602
|
-
controllerId:
|
|
603
|
-
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())
|
|
604
1604
|
}).strict();
|
|
605
1605
|
var V2_BRIDGE_PARENT_TO_GAME_TYPES = [
|
|
606
1606
|
"BOOTSTRAP",
|
|
@@ -623,89 +1623,89 @@ var allMessageTypes = [
|
|
|
623
1623
|
...V2_BRIDGE_GAME_TO_PARENT_TYPES
|
|
624
1624
|
];
|
|
625
1625
|
var knownBridgeMessageTypeSet = new Set(allMessageTypes);
|
|
626
|
-
var bootstrapMessageSchema =
|
|
627
|
-
type:
|
|
628
|
-
payload:
|
|
1626
|
+
var bootstrapMessageSchema = import_zod25.z.object({
|
|
1627
|
+
type: import_zod25.z.literal("BOOTSTRAP"),
|
|
1628
|
+
payload: import_zod25.z.object({
|
|
629
1629
|
roomId: roomCodeSchema2,
|
|
630
|
-
players:
|
|
631
|
-
state:
|
|
632
|
-
runtimeState:
|
|
633
|
-
message:
|
|
1630
|
+
players: import_zod25.z.array(playerProfileSchema2),
|
|
1631
|
+
state: import_zod25.z.object({
|
|
1632
|
+
runtimeState: runtimeStateSchema2,
|
|
1633
|
+
message: import_zod25.z.string().optional()
|
|
634
1634
|
}).strict(),
|
|
635
|
-
capabilities:
|
|
1635
|
+
capabilities: import_zod25.z.record(import_zod25.z.string(), import_zod25.z.boolean()).default({})
|
|
636
1636
|
}).strict()
|
|
637
1637
|
}).strict();
|
|
638
|
-
var playersUpdateMessageSchema =
|
|
639
|
-
type:
|
|
640
|
-
payload:
|
|
641
|
-
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)
|
|
642
1642
|
}).strict()
|
|
643
1643
|
}).strict();
|
|
644
|
-
var runtimeStateUpdateMessageSchema =
|
|
645
|
-
type:
|
|
646
|
-
payload:
|
|
647
|
-
runtimeState:
|
|
648
|
-
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()
|
|
649
1649
|
}).strict()
|
|
650
1650
|
}).strict();
|
|
651
|
-
var inputFrameMessageSchema =
|
|
652
|
-
type:
|
|
653
|
-
payload:
|
|
654
|
-
frameId:
|
|
655
|
-
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)
|
|
656
1656
|
}).strict()
|
|
657
1657
|
}).strict();
|
|
658
|
-
var pauseMessageSchema =
|
|
659
|
-
type:
|
|
660
|
-
payload:
|
|
661
|
-
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()
|
|
662
1662
|
}).strict()
|
|
663
1663
|
}).strict();
|
|
664
|
-
var resumeMessageSchema =
|
|
665
|
-
type:
|
|
666
|
-
payload:
|
|
1664
|
+
var resumeMessageSchema = import_zod25.z.object({
|
|
1665
|
+
type: import_zod25.z.literal("RESUME"),
|
|
1666
|
+
payload: import_zod25.z.object({}).strict()
|
|
667
1667
|
}).strict();
|
|
668
|
-
var shutdownMessageSchema =
|
|
669
|
-
type:
|
|
670
|
-
payload:
|
|
671
|
-
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)
|
|
672
1672
|
}).strict()
|
|
673
1673
|
}).strict();
|
|
674
|
-
var readyMessageSchema =
|
|
675
|
-
type:
|
|
676
|
-
payload:
|
|
677
|
-
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()
|
|
678
1678
|
}).strict()
|
|
679
1679
|
}).strict();
|
|
680
|
-
var statePatchMessageSchema =
|
|
681
|
-
type:
|
|
682
|
-
payload:
|
|
683
|
-
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())
|
|
684
1684
|
}).strict()
|
|
685
1685
|
}).strict();
|
|
686
|
-
var signalMessageSchema =
|
|
687
|
-
type:
|
|
688
|
-
payload:
|
|
689
|
-
signalType:
|
|
690
|
-
targetId:
|
|
691
|
-
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())
|
|
692
1692
|
}).strict()
|
|
693
1693
|
}).strict();
|
|
694
|
-
var errorMessageSchema =
|
|
695
|
-
type:
|
|
696
|
-
payload:
|
|
697
|
-
code:
|
|
698
|
-
message:
|
|
699
|
-
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()
|
|
700
1700
|
}).strict()
|
|
701
1701
|
}).strict();
|
|
702
|
-
var metricsMessageSchema =
|
|
703
|
-
type:
|
|
704
|
-
payload:
|
|
705
|
-
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())
|
|
706
1706
|
}).strict()
|
|
707
1707
|
}).strict();
|
|
708
|
-
var v2BridgeParentToGameMessageSchema =
|
|
1708
|
+
var v2BridgeParentToGameMessageSchema = import_zod25.z.union([
|
|
709
1709
|
bootstrapMessageSchema,
|
|
710
1710
|
playersUpdateMessageSchema,
|
|
711
1711
|
runtimeStateUpdateMessageSchema,
|
|
@@ -714,24 +1714,24 @@ var v2BridgeParentToGameMessageSchema = import_zod7.z.union([
|
|
|
714
1714
|
resumeMessageSchema,
|
|
715
1715
|
shutdownMessageSchema
|
|
716
1716
|
]);
|
|
717
|
-
var v2BridgeGameToParentMessageSchema =
|
|
1717
|
+
var v2BridgeGameToParentMessageSchema = import_zod25.z.union([
|
|
718
1718
|
readyMessageSchema,
|
|
719
1719
|
statePatchMessageSchema,
|
|
720
1720
|
signalMessageSchema,
|
|
721
1721
|
errorMessageSchema,
|
|
722
1722
|
metricsMessageSchema
|
|
723
1723
|
]);
|
|
724
|
-
var v2BridgeMessageSchema =
|
|
1724
|
+
var v2BridgeMessageSchema = import_zod25.z.union([
|
|
725
1725
|
v2BridgeParentToGameMessageSchema,
|
|
726
1726
|
v2BridgeGameToParentMessageSchema
|
|
727
1727
|
]);
|
|
728
1728
|
|
|
729
1729
|
// src/contracts/v2/handshake.ts
|
|
730
|
-
var
|
|
1730
|
+
var import_zod26 = require("zod");
|
|
731
1731
|
var AIR_JAM_PROTOCOL_V2 = "2";
|
|
732
1732
|
var semanticVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
733
|
-
var v2ProtocolVersionSchema =
|
|
734
|
-
var runtimeKindSchema =
|
|
1733
|
+
var v2ProtocolVersionSchema = import_zod26.z.literal(AIR_JAM_PROTOCOL_V2);
|
|
1734
|
+
var runtimeKindSchema = import_zod26.z.enum([
|
|
735
1735
|
"standalone-host",
|
|
736
1736
|
"standalone-controller",
|
|
737
1737
|
"arcade-runtime",
|
|
@@ -741,12 +1741,12 @@ var runtimeKindSchema = import_zod8.z.enum([
|
|
|
741
1741
|
"arcade-controller-runtime",
|
|
742
1742
|
"arcade-controller-iframe"
|
|
743
1743
|
]);
|
|
744
|
-
var capabilityFlagsSchema =
|
|
745
|
-
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(
|
|
746
1746
|
semanticVersionPattern,
|
|
747
1747
|
"sdkVersion must use semantic version format (for example 1.2.3)"
|
|
748
1748
|
);
|
|
749
|
-
var v2HandshakeSchema =
|
|
1749
|
+
var v2HandshakeSchema = import_zod26.z.object({
|
|
750
1750
|
protocolVersion: v2ProtocolVersionSchema,
|
|
751
1751
|
sdkVersion: sdkVersionSchema,
|
|
752
1752
|
runtimeKind: runtimeKindSchema,
|
|
@@ -757,38 +1757,38 @@ var v2HandshakeSchema = import_zod8.z.object({
|
|
|
757
1757
|
var AIRJAM_BRIDGE_INIT = "AIRJAM_BRIDGE_INIT";
|
|
758
1758
|
var AIRJAM_SETTINGS_SYNC = "AIRJAM_SETTINGS_SYNC";
|
|
759
1759
|
var AIRJAM_SETTINGS_READY = "AIRJAM_SETTINGS_READY";
|
|
760
|
-
var airJamSettingsSyncSchema =
|
|
761
|
-
type:
|
|
762
|
-
payload:
|
|
763
|
-
settings:
|
|
764
|
-
audio:
|
|
765
|
-
masterVolume:
|
|
766
|
-
musicVolume:
|
|
767
|
-
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()
|
|
768
1768
|
}).strict(),
|
|
769
|
-
accessibility:
|
|
770
|
-
reducedMotion:
|
|
771
|
-
highContrast:
|
|
1769
|
+
accessibility: import_zod27.z.object({
|
|
1770
|
+
reducedMotion: import_zod27.z.boolean(),
|
|
1771
|
+
highContrast: import_zod27.z.boolean()
|
|
772
1772
|
}).strict(),
|
|
773
|
-
feedback:
|
|
774
|
-
hapticsEnabled:
|
|
1773
|
+
feedback: import_zod27.z.object({
|
|
1774
|
+
hapticsEnabled: import_zod27.z.boolean()
|
|
775
1775
|
}).strict(),
|
|
776
|
-
previewControllers:
|
|
777
|
-
activeOpacity:
|
|
1776
|
+
previewControllers: import_zod27.z.object({
|
|
1777
|
+
activeOpacity: import_zod27.z.number()
|
|
778
1778
|
}).strict()
|
|
779
1779
|
}).strict()
|
|
780
1780
|
}).strict()
|
|
781
1781
|
}).strict();
|
|
782
|
-
var airJamBridgeInitSchema =
|
|
783
|
-
type:
|
|
784
|
-
payload:
|
|
1782
|
+
var airJamBridgeInitSchema = import_zod27.z.object({
|
|
1783
|
+
type: import_zod27.z.literal(AIRJAM_BRIDGE_INIT),
|
|
1784
|
+
payload: import_zod27.z.object({
|
|
785
1785
|
handshake: v2HandshakeSchema
|
|
786
1786
|
}).strict()
|
|
787
1787
|
}).strict();
|
|
788
|
-
var airJamSettingsReadySchema =
|
|
789
|
-
type:
|
|
790
|
-
payload:
|
|
791
|
-
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)
|
|
792
1792
|
}).strict()
|
|
793
1793
|
}).strict();
|
|
794
1794
|
|
|
@@ -865,6 +1865,7 @@ var isEmbeddedArcadeRuntimeSearchParams = (searchParams) => parseOptionalArcadeS
|
|
|
865
1865
|
var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
866
1866
|
enabled = "auto",
|
|
867
1867
|
topology,
|
|
1868
|
+
isEmbeddedRuntime = typeof window !== "undefined" && window.parent !== window,
|
|
868
1869
|
isDevelopmentRuntime = readDevelopmentRuntime(),
|
|
869
1870
|
searchParams
|
|
870
1871
|
} = {}) => {
|
|
@@ -872,12 +1873,12 @@ var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
|
872
1873
|
return enabled;
|
|
873
1874
|
}
|
|
874
1875
|
const localDevControlSurfacesEnabled = topology != null ? isLocalDevControlSurfaceRuntimeMode(topology.runtimeMode) : isDevelopmentRuntime;
|
|
875
|
-
return localDevControlSurfacesEnabled && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
1876
|
+
return localDevControlSurfacesEnabled && !topology?.embedded && !isEmbeddedRuntime && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
876
1877
|
};
|
|
877
1878
|
|
|
878
1879
|
// src/preview/workspace.tsx
|
|
879
1880
|
var import_lucide_react2 = require("lucide-react");
|
|
880
|
-
var
|
|
1881
|
+
var import_react10 = require("react");
|
|
881
1882
|
var import_react_dom = require("react-dom");
|
|
882
1883
|
|
|
883
1884
|
// src/components/shell-classes.ts
|
|
@@ -914,27 +1915,350 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
914
1915
|
variant: "default",
|
|
915
1916
|
size: "default"
|
|
916
1917
|
}
|
|
917
|
-
}
|
|
918
|
-
);
|
|
919
|
-
function Button({
|
|
920
|
-
className,
|
|
921
|
-
variant,
|
|
922
|
-
size,
|
|
923
|
-
asChild = false,
|
|
924
|
-
...props
|
|
925
|
-
}) {
|
|
926
|
-
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
927
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
928
|
-
Comp,
|
|
929
|
-
{
|
|
930
|
-
"data-slot": "button",
|
|
931
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
932
|
-
...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);
|
|
933
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
|
|
934
2155
|
);
|
|
935
|
-
|
|
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
|
+
};
|
|
936
2259
|
|
|
937
2260
|
// src/preview/layout.ts
|
|
2261
|
+
var getPreviewHostViewportSize = () => SURFACE_VIEWPORT_REFERENCE_SIZES.host.landscape;
|
|
938
2262
|
var PREVIEW_WORKSPACE_Z_INDEX = 2147483e3;
|
|
939
2263
|
var PREVIEW_WINDOW_TITLEBAR_HEIGHT = 38;
|
|
940
2264
|
var PREVIEW_WINDOW_RESIZE_EDGE_HIT_SIZE = 12;
|
|
@@ -1062,56 +2386,34 @@ var getResizedPreviewBounds = (bounds, handle, deltaX, deltaY) => {
|
|
|
1062
2386
|
};
|
|
1063
2387
|
|
|
1064
2388
|
// src/preview/manager.ts
|
|
1065
|
-
var
|
|
1066
|
-
|
|
1067
|
-
// src/utils/ids.ts
|
|
1068
|
-
var alphabet = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
1069
|
-
var generateControllerId = () => {
|
|
1070
|
-
const stamp = Math.floor(Date.now() % 1e5).toString().padStart(5, "0");
|
|
1071
|
-
const random = alphabet[Math.floor(Math.random() * alphabet.length)];
|
|
1072
|
-
return `C${random}${stamp}`;
|
|
1073
|
-
};
|
|
2389
|
+
var import_react7 = require("react");
|
|
1074
2390
|
|
|
1075
|
-
// src/preview/
|
|
1076
|
-
var
|
|
1077
|
-
var
|
|
1078
|
-
var
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
return null;
|
|
1102
|
-
}
|
|
1103
|
-
return normalizePreviewDeviceId(
|
|
1104
|
-
params.get(AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM)
|
|
1105
|
-
);
|
|
1106
|
-
};
|
|
1107
|
-
var readPreviewControllerDeviceIdFromLocation = () => {
|
|
1108
|
-
if (typeof window === "undefined") {
|
|
1109
|
-
return null;
|
|
1110
|
-
}
|
|
1111
|
-
return readPreviewControllerDeviceIdFromSearchParams(
|
|
1112
|
-
new URLSearchParams(window.location.search)
|
|
1113
|
-
);
|
|
1114
|
-
};
|
|
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
|
+
}
|
|
1115
2417
|
|
|
1116
2418
|
// src/preview/url.ts
|
|
1117
2419
|
var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
@@ -1122,10 +2424,12 @@ var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
|
1122
2424
|
};
|
|
1123
2425
|
var buildPreviewControllerUrl = ({
|
|
1124
2426
|
joinUrl,
|
|
1125
|
-
controllerId,
|
|
1126
2427
|
previewDeviceId,
|
|
1127
2428
|
allowedOrigins,
|
|
1128
|
-
embedOrigin
|
|
2429
|
+
embedOrigin,
|
|
2430
|
+
parentOrigin,
|
|
2431
|
+
localSeat,
|
|
2432
|
+
capture
|
|
1129
2433
|
}) => {
|
|
1130
2434
|
const normalizedJoinUrl = normalizeRuntimeUrl(joinUrl);
|
|
1131
2435
|
if (!normalizedJoinUrl) {
|
|
@@ -1144,41 +2448,49 @@ var buildPreviewControllerUrl = ({
|
|
|
1144
2448
|
if (!normalizedEmbedOrigin) {
|
|
1145
2449
|
return null;
|
|
1146
2450
|
}
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
2451
|
+
const { pathname, search, hash } = new URL(normalizedJoinUrl);
|
|
2452
|
+
return new URL(
|
|
2453
|
+
`${pathname}${search}${hash}`,
|
|
2454
|
+
normalizedEmbedOrigin
|
|
2455
|
+
).toString();
|
|
1152
2456
|
})();
|
|
1153
2457
|
if (!previewBaseUrl) {
|
|
1154
2458
|
return null;
|
|
1155
2459
|
}
|
|
2460
|
+
const normalizedParentOrigin = parentOrigin ? getRuntimeUrlOrigin(parentOrigin) : null;
|
|
2461
|
+
if (parentOrigin && !normalizedParentOrigin) {
|
|
2462
|
+
return null;
|
|
2463
|
+
}
|
|
1156
2464
|
return appendRuntimeQueryParams(previewBaseUrl, {
|
|
1157
|
-
controllerId,
|
|
1158
2465
|
[AIR_JAM_PREVIEW_FLAG_QUERY_PARAM]: "1",
|
|
1159
|
-
[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
|
|
1160
2470
|
});
|
|
1161
2471
|
};
|
|
1162
2472
|
var createPreviewControllerLaunch = ({
|
|
1163
2473
|
joinUrl,
|
|
1164
2474
|
allowedOrigins,
|
|
1165
|
-
embedOrigin
|
|
2475
|
+
embedOrigin,
|
|
2476
|
+
parentOrigin,
|
|
2477
|
+
localSeat,
|
|
2478
|
+
capture
|
|
1166
2479
|
}) => {
|
|
1167
|
-
const
|
|
2480
|
+
const deviceId = createPreviewControllerDeviceId();
|
|
1168
2481
|
const url = buildPreviewControllerUrl({
|
|
1169
2482
|
joinUrl,
|
|
1170
|
-
|
|
1171
|
-
previewDeviceId: identity.deviceId,
|
|
2483
|
+
previewDeviceId: deviceId,
|
|
1172
2484
|
allowedOrigins,
|
|
1173
|
-
embedOrigin
|
|
2485
|
+
embedOrigin,
|
|
2486
|
+
parentOrigin,
|
|
2487
|
+
localSeat,
|
|
2488
|
+
capture
|
|
1174
2489
|
});
|
|
1175
2490
|
if (!url) {
|
|
1176
2491
|
return null;
|
|
1177
2492
|
}
|
|
1178
|
-
return {
|
|
1179
|
-
...identity,
|
|
1180
|
-
url
|
|
1181
|
-
};
|
|
2493
|
+
return { deviceId, url };
|
|
1182
2494
|
};
|
|
1183
2495
|
|
|
1184
2496
|
// src/preview/manager.ts
|
|
@@ -1186,6 +2498,7 @@ var DEFAULT_VIEWPORT_WIDTH = 1440;
|
|
|
1186
2498
|
var DEFAULT_VIEWPORT_HEIGHT = 900;
|
|
1187
2499
|
var PREVIEW_WINDOW_MARGIN = 24;
|
|
1188
2500
|
var PREVIEW_WINDOW_CASCADE_OFFSET = 28;
|
|
2501
|
+
var PREVIEW_WINDOW_DOCK_GAP = 12;
|
|
1189
2502
|
var DEFAULT_PREVIEW_CONTROLLER_ORIENTATION = "portrait";
|
|
1190
2503
|
var getViewportSize = () => {
|
|
1191
2504
|
if (typeof window === "undefined") {
|
|
@@ -1292,27 +2605,55 @@ var clampBounds = (orientation, bounds, options = {}, currentBounds) => {
|
|
|
1292
2605
|
height
|
|
1293
2606
|
};
|
|
1294
2607
|
};
|
|
1295
|
-
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) => {
|
|
1296
2613
|
const viewport = getViewportSize();
|
|
1297
|
-
|
|
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(
|
|
1298
2632
|
orientation,
|
|
1299
|
-
|
|
2633
|
+
PREVIEW_CONTROLLER_MIN_SCALE
|
|
1300
2634
|
);
|
|
1301
|
-
const
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
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
|
|
1311
2656
|
);
|
|
1312
|
-
return {
|
|
1313
|
-
x: anchored.x,
|
|
1314
|
-
y: anchored.y
|
|
1315
|
-
};
|
|
1316
2657
|
};
|
|
1317
2658
|
var getNextTopSessionId = (sessions) => sessions.filter((session) => !session.minimized).sort((left, right) => right.zIndex - left.zIndex)[0]?.id ?? null;
|
|
1318
2659
|
var activateSession = (sessions, id, nextZIndex) => sessions.map(
|
|
@@ -1331,21 +2672,55 @@ var normalizeActiveSession = (sessions) => {
|
|
|
1331
2672
|
}));
|
|
1332
2673
|
};
|
|
1333
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
|
+
};
|
|
1334
2708
|
var usePreviewControllerManager = ({
|
|
1335
2709
|
joinUrl,
|
|
1336
2710
|
enabled = true,
|
|
1337
2711
|
maxControllers = 2,
|
|
1338
2712
|
allowedOrigins,
|
|
1339
|
-
embedOrigin
|
|
2713
|
+
embedOrigin,
|
|
2714
|
+
fixedControllerOrientation = null
|
|
1340
2715
|
}) => {
|
|
1341
|
-
const [sessions, setSessions] = (0,
|
|
1342
|
-
const nextSessionIdRef = (0,
|
|
1343
|
-
const nextOrdinalRef = (0,
|
|
1344
|
-
const nextZIndexRef = (0,
|
|
1345
|
-
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)(
|
|
1346
2721
|
getJoinRoomIdentity(joinUrl)
|
|
1347
2722
|
);
|
|
1348
|
-
(0,
|
|
2723
|
+
(0, import_react7.useEffect)(() => {
|
|
1349
2724
|
const nextJoinRoom = getJoinRoomIdentity(joinUrl);
|
|
1350
2725
|
const previousJoinRoom = previousJoinRoomRef.current;
|
|
1351
2726
|
if (!enabled || previousJoinRoom !== null && nextJoinRoom !== null && previousJoinRoom !== nextJoinRoom) {
|
|
@@ -1357,71 +2732,83 @@ var usePreviewControllerManager = ({
|
|
|
1357
2732
|
previousJoinRoomRef.current = nextJoinRoom;
|
|
1358
2733
|
}, [enabled, joinUrl]);
|
|
1359
2734
|
const canSpawn = enabled && typeof joinUrl === "string" && joinUrl.trim().length > 0 && sessions.length < maxControllers;
|
|
1360
|
-
const spawnPreviewController = (0,
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
let nextSession = null;
|
|
1365
|
-
setSessions((current) => {
|
|
1366
|
-
if (current.length >= maxControllers) {
|
|
1367
|
-
return current;
|
|
2735
|
+
const spawnPreviewController = (0, import_react7.useCallback)(
|
|
2736
|
+
(options) => {
|
|
2737
|
+
if (!enabled || !joinUrl) {
|
|
2738
|
+
return null;
|
|
1368
2739
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
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
|
+
];
|
|
1373
2788
|
});
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
nextSession = {
|
|
1387
|
-
id: sessionId,
|
|
1388
|
-
ordinal,
|
|
1389
|
-
label: `Preview ${ordinal}`,
|
|
1390
|
-
controllerId: launch.controllerId,
|
|
1391
|
-
deviceId: launch.deviceId,
|
|
1392
|
-
url: launch.url,
|
|
1393
|
-
surfaceState: "loading",
|
|
1394
|
-
orientation,
|
|
1395
|
-
minimized: false,
|
|
1396
|
-
active: true,
|
|
1397
|
-
x: position.x,
|
|
1398
|
-
y: position.y,
|
|
1399
|
-
width: defaultBounds.width,
|
|
1400
|
-
height: defaultBounds.height,
|
|
1401
|
-
viewportWidth: defaultBounds.viewportWidth,
|
|
1402
|
-
viewportHeight: defaultBounds.viewportHeight,
|
|
1403
|
-
displayScale: defaultBounds.displayScale,
|
|
1404
|
-
zIndex
|
|
1405
|
-
};
|
|
1406
|
-
return [
|
|
1407
|
-
...current.map((session) => ({ ...session, active: false })),
|
|
1408
|
-
nextSession
|
|
1409
|
-
];
|
|
1410
|
-
});
|
|
1411
|
-
return nextSession;
|
|
1412
|
-
}, [allowedOrigins, embedOrigin, enabled, joinUrl, maxControllers]);
|
|
1413
|
-
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) => {
|
|
1414
2801
|
setSessions(
|
|
1415
2802
|
(current) => normalizeActiveSession(current.filter((session) => session.id !== id))
|
|
1416
2803
|
);
|
|
1417
2804
|
}, []);
|
|
1418
|
-
const clearPreviewControllers = (0,
|
|
2805
|
+
const clearPreviewControllers = (0, import_react7.useCallback)(() => {
|
|
1419
2806
|
setSessions([]);
|
|
1420
2807
|
nextSessionIdRef.current = 1;
|
|
1421
2808
|
nextOrdinalRef.current = 1;
|
|
1422
2809
|
nextZIndexRef.current = 1;
|
|
1423
2810
|
}, []);
|
|
1424
|
-
const minimizePreviewController = (0,
|
|
2811
|
+
const minimizePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1425
2812
|
setSessions(
|
|
1426
2813
|
(current) => normalizeActiveSession(
|
|
1427
2814
|
current.map(
|
|
@@ -1430,15 +2817,15 @@ var usePreviewControllerManager = ({
|
|
|
1430
2817
|
)
|
|
1431
2818
|
);
|
|
1432
2819
|
}, []);
|
|
1433
|
-
const focusPreviewController = (0,
|
|
2820
|
+
const focusPreviewController = (0, import_react7.useCallback)((id) => {
|
|
1434
2821
|
const nextZIndex = nextZIndexRef.current++;
|
|
1435
2822
|
setSessions((current) => activateSession(current, id, nextZIndex));
|
|
1436
2823
|
}, []);
|
|
1437
|
-
const restorePreviewController = (0,
|
|
2824
|
+
const restorePreviewController = (0, import_react7.useCallback)((id) => {
|
|
1438
2825
|
const nextZIndex = nextZIndexRef.current++;
|
|
1439
2826
|
setSessions((current) => activateSession(current, id, nextZIndex));
|
|
1440
2827
|
}, []);
|
|
1441
|
-
const setPreviewControllerPosition = (0,
|
|
2828
|
+
const setPreviewControllerPosition = (0, import_react7.useCallback)(
|
|
1442
2829
|
(id, x, y) => {
|
|
1443
2830
|
setSessions(
|
|
1444
2831
|
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
@@ -1462,7 +2849,7 @@ var usePreviewControllerManager = ({
|
|
|
1462
2849
|
},
|
|
1463
2850
|
[]
|
|
1464
2851
|
);
|
|
1465
|
-
const setPreviewControllerBounds = (0,
|
|
2852
|
+
const setPreviewControllerBounds = (0, import_react7.useCallback)(
|
|
1466
2853
|
(id, bounds, options = {}) => {
|
|
1467
2854
|
setSessions(
|
|
1468
2855
|
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
@@ -1494,48 +2881,43 @@ var usePreviewControllerManager = ({
|
|
|
1494
2881
|
},
|
|
1495
2882
|
[]
|
|
1496
2883
|
);
|
|
1497
|
-
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;
|
|
1498
2901
|
setSessions(
|
|
1499
|
-
(current) =>
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
}
|
|
1503
|
-
const nextOrientation = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
1504
|
-
const centerX = session.x + session.width / 2;
|
|
1505
|
-
const centerY = session.y + session.height / 2;
|
|
1506
|
-
const nextWindowBounds = getPreviewWindowBounds(
|
|
1507
|
-
nextOrientation,
|
|
1508
|
-
session.displayScale
|
|
1509
|
-
);
|
|
1510
|
-
const nextBounds = clampBounds(
|
|
1511
|
-
nextOrientation,
|
|
1512
|
-
{
|
|
1513
|
-
x: centerX - nextWindowBounds.width / 2,
|
|
1514
|
-
y: centerY - nextWindowBounds.height / 2,
|
|
1515
|
-
width: nextWindowBounds.width,
|
|
1516
|
-
height: nextWindowBounds.height
|
|
1517
|
-
},
|
|
1518
|
-
{}
|
|
1519
|
-
);
|
|
1520
|
-
const clampedWindowBounds = getPreviewWindowBounds(
|
|
1521
|
-
nextOrientation,
|
|
1522
|
-
getPreviewControllerScaleForBounds(nextOrientation, nextBounds)
|
|
1523
|
-
);
|
|
1524
|
-
return {
|
|
1525
|
-
...session,
|
|
1526
|
-
orientation: nextOrientation,
|
|
1527
|
-
x: nextBounds.x,
|
|
1528
|
-
y: nextBounds.y,
|
|
1529
|
-
width: clampedWindowBounds.width,
|
|
1530
|
-
height: clampedWindowBounds.height,
|
|
1531
|
-
viewportWidth: clampedWindowBounds.viewportWidth,
|
|
1532
|
-
viewportHeight: clampedWindowBounds.viewportHeight,
|
|
1533
|
-
displayScale: clampedWindowBounds.displayScale
|
|
1534
|
-
};
|
|
1535
|
-
})
|
|
2902
|
+
(current) => current.map(
|
|
2903
|
+
(session) => session.orientation === fixedControllerOrientation ? session : orientSession(session, fixedControllerOrientation)
|
|
2904
|
+
)
|
|
1536
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);
|
|
1537
2919
|
}, []);
|
|
1538
|
-
const markPreviewControllerReady = (0,
|
|
2920
|
+
const markPreviewControllerReady = (0, import_react7.useCallback)((id) => {
|
|
1539
2921
|
setSessions(
|
|
1540
2922
|
(current) => mapSessionsAndNormalizeActive(
|
|
1541
2923
|
current,
|
|
@@ -1543,7 +2925,7 @@ var usePreviewControllerManager = ({
|
|
|
1543
2925
|
)
|
|
1544
2926
|
);
|
|
1545
2927
|
}, []);
|
|
1546
|
-
const markPreviewControllerFailed = (0,
|
|
2928
|
+
const markPreviewControllerFailed = (0, import_react7.useCallback)((id) => {
|
|
1547
2929
|
setSessions(
|
|
1548
2930
|
(current) => mapSessionsAndNormalizeActive(
|
|
1549
2931
|
current,
|
|
@@ -1570,12 +2952,12 @@ var usePreviewControllerManager = ({
|
|
|
1570
2952
|
|
|
1571
2953
|
// src/preview/window.tsx
|
|
1572
2954
|
var import_lucide_react = require("lucide-react");
|
|
1573
|
-
var
|
|
2955
|
+
var import_react8 = require("react");
|
|
1574
2956
|
|
|
1575
2957
|
// src/components/ui/slider.tsx
|
|
1576
2958
|
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"), 1);
|
|
1577
2959
|
var React = __toESM(require("react"), 1);
|
|
1578
|
-
var
|
|
2960
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1579
2961
|
function Slider({
|
|
1580
2962
|
className,
|
|
1581
2963
|
defaultValue,
|
|
@@ -1588,7 +2970,7 @@ function Slider({
|
|
|
1588
2970
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1589
2971
|
[value, defaultValue, min, max]
|
|
1590
2972
|
);
|
|
1591
|
-
return /* @__PURE__ */ (0,
|
|
2973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1592
2974
|
SliderPrimitive.Root,
|
|
1593
2975
|
{
|
|
1594
2976
|
"data-slot": "slider",
|
|
@@ -1602,14 +2984,14 @@ function Slider({
|
|
|
1602
2984
|
),
|
|
1603
2985
|
...props,
|
|
1604
2986
|
children: [
|
|
1605
|
-
/* @__PURE__ */ (0,
|
|
2987
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1606
2988
|
SliderPrimitive.Track,
|
|
1607
2989
|
{
|
|
1608
2990
|
"data-slot": "slider-track",
|
|
1609
2991
|
className: cn(
|
|
1610
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"
|
|
1611
2993
|
),
|
|
1612
|
-
children: /* @__PURE__ */ (0,
|
|
2994
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1613
2995
|
SliderPrimitive.Range,
|
|
1614
2996
|
{
|
|
1615
2997
|
"data-slot": "slider-range",
|
|
@@ -1620,7 +3002,7 @@ function Slider({
|
|
|
1620
3002
|
)
|
|
1621
3003
|
}
|
|
1622
3004
|
),
|
|
1623
|
-
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0,
|
|
3005
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1624
3006
|
SliderPrimitive.Thumb,
|
|
1625
3007
|
{
|
|
1626
3008
|
"data-slot": "slider-thumb",
|
|
@@ -1633,54 +3015,9 @@ function Slider({
|
|
|
1633
3015
|
);
|
|
1634
3016
|
}
|
|
1635
3017
|
|
|
1636
|
-
// src/preview/messages.ts
|
|
1637
|
-
var AIR_JAM_PREVIEW_CLOSE_REQUEST = "airjam.preview.close.request";
|
|
1638
|
-
var AIR_JAM_PREVIEW_CLOSE_RESULT = "airjam.preview.close.result";
|
|
1639
|
-
var isPreviewCloseResultMessage = (value) => typeof value === "object" && value !== null && value.type === AIR_JAM_PREVIEW_CLOSE_RESULT && typeof value.ok === "boolean";
|
|
1640
|
-
|
|
1641
3018
|
// src/preview/window.tsx
|
|
1642
|
-
var
|
|
3019
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1643
3020
|
var PREVIEW_WINDOW_SETTINGS_SHELF_HEIGHT = 52;
|
|
1644
|
-
var PREVIEW_CLOSE_TIMEOUT_MS = 1e3;
|
|
1645
|
-
var requestPreviewControllerClose = async (iframe, sessionUrl) => {
|
|
1646
|
-
const frameWindow = iframe?.contentWindow;
|
|
1647
|
-
if (!frameWindow) {
|
|
1648
|
-
return;
|
|
1649
|
-
}
|
|
1650
|
-
const targetOrigin = new URL(sessionUrl).origin;
|
|
1651
|
-
await new Promise((resolve) => {
|
|
1652
|
-
let settled = false;
|
|
1653
|
-
const timeout = window.setTimeout(() => {
|
|
1654
|
-
cleanup();
|
|
1655
|
-
resolve();
|
|
1656
|
-
}, PREVIEW_CLOSE_TIMEOUT_MS);
|
|
1657
|
-
const handleMessage = (event) => {
|
|
1658
|
-
if (event.source !== frameWindow || event.origin !== targetOrigin) {
|
|
1659
|
-
return;
|
|
1660
|
-
}
|
|
1661
|
-
if (!isPreviewCloseResultMessage(event.data)) {
|
|
1662
|
-
return;
|
|
1663
|
-
}
|
|
1664
|
-
cleanup();
|
|
1665
|
-
resolve();
|
|
1666
|
-
};
|
|
1667
|
-
const cleanup = () => {
|
|
1668
|
-
if (settled) {
|
|
1669
|
-
return;
|
|
1670
|
-
}
|
|
1671
|
-
settled = true;
|
|
1672
|
-
window.clearTimeout(timeout);
|
|
1673
|
-
window.removeEventListener("message", handleMessage);
|
|
1674
|
-
};
|
|
1675
|
-
window.addEventListener("message", handleMessage);
|
|
1676
|
-
frameWindow.postMessage(
|
|
1677
|
-
{
|
|
1678
|
-
type: AIR_JAM_PREVIEW_CLOSE_REQUEST
|
|
1679
|
-
},
|
|
1680
|
-
targetOrigin
|
|
1681
|
-
);
|
|
1682
|
-
});
|
|
1683
|
-
};
|
|
1684
3021
|
var previewControllerWindowStateLabel = {
|
|
1685
3022
|
loading: "Loading",
|
|
1686
3023
|
ready: "Ready",
|
|
@@ -1770,8 +3107,10 @@ var RESIZE_HANDLES = [
|
|
|
1770
3107
|
];
|
|
1771
3108
|
var PreviewControllerWindow = ({
|
|
1772
3109
|
session,
|
|
3110
|
+
frameRef,
|
|
1773
3111
|
activeOpacity,
|
|
1774
3112
|
highContrast = false,
|
|
3113
|
+
fixedControllerOrientation = null,
|
|
1775
3114
|
dragging = false,
|
|
1776
3115
|
onFocus,
|
|
1777
3116
|
onMinimize,
|
|
@@ -1790,9 +3129,9 @@ var PreviewControllerWindow = ({
|
|
|
1790
3129
|
onResizePointerCancel,
|
|
1791
3130
|
resizing = false
|
|
1792
3131
|
}) => {
|
|
1793
|
-
const [windowHovered, setWindowHovered] = (0,
|
|
1794
|
-
const [settingsOpen, setSettingsOpen] = (0,
|
|
1795
|
-
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);
|
|
1796
3135
|
const isVisible = dragging || resizing || windowHovered;
|
|
1797
3136
|
const windowOpacity = isVisible ? activeOpacity : Math.min(activeOpacity, 0.62);
|
|
1798
3137
|
const settingsShelfHeight = settingsOpen && onActiveOpacityChange ? PREVIEW_WINDOW_SETTINGS_SHELF_HEIGHT : 0;
|
|
@@ -1802,10 +3141,11 @@ var PreviewControllerWindow = ({
|
|
|
1802
3141
|
);
|
|
1803
3142
|
const nextOrientationLabel = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
1804
3143
|
const statusToneClassName = session.surfaceState === "failed" ? "bg-amber-300" : session.surfaceState === "ready" ? "bg-emerald-300" : "bg-white/45";
|
|
1805
|
-
return /* @__PURE__ */ (0,
|
|
3144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1806
3145
|
"div",
|
|
1807
3146
|
{
|
|
1808
3147
|
className: "absolute",
|
|
3148
|
+
hidden: session.minimized,
|
|
1809
3149
|
style: {
|
|
1810
3150
|
left: session.x,
|
|
1811
3151
|
top: session.y,
|
|
@@ -1817,7 +3157,7 @@ var PreviewControllerWindow = ({
|
|
|
1817
3157
|
onPointerEnter: () => setWindowHovered(true),
|
|
1818
3158
|
onPointerLeave: () => setWindowHovered(false),
|
|
1819
3159
|
children: [
|
|
1820
|
-
/* @__PURE__ */ (0,
|
|
3160
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1821
3161
|
"section",
|
|
1822
3162
|
{
|
|
1823
3163
|
className: cn(
|
|
@@ -1833,7 +3173,7 @@ var PreviewControllerWindow = ({
|
|
|
1833
3173
|
pointerEvents: "auto"
|
|
1834
3174
|
},
|
|
1835
3175
|
children: [
|
|
1836
|
-
/* @__PURE__ */ (0,
|
|
3176
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1837
3177
|
"div",
|
|
1838
3178
|
{
|
|
1839
3179
|
className: "flex h-9 items-center gap-2 border-b border-white/8 px-2.5",
|
|
@@ -1847,10 +3187,10 @@ var PreviewControllerWindow = ({
|
|
|
1847
3187
|
onPointerUp: onTitlePointerUp,
|
|
1848
3188
|
onPointerCancel: onTitlePointerCancel,
|
|
1849
3189
|
children: [
|
|
1850
|
-
/* @__PURE__ */ (0,
|
|
1851
|
-
/* @__PURE__ */ (0,
|
|
1852
|
-
/* @__PURE__ */ (0,
|
|
1853
|
-
/* @__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)(
|
|
1854
3194
|
"span",
|
|
1855
3195
|
{
|
|
1856
3196
|
className: cn(
|
|
@@ -1861,8 +3201,8 @@ var PreviewControllerWindow = ({
|
|
|
1861
3201
|
}
|
|
1862
3202
|
)
|
|
1863
3203
|
] }),
|
|
1864
|
-
/* @__PURE__ */ (0,
|
|
1865
|
-
/* @__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)(
|
|
1866
3206
|
Button,
|
|
1867
3207
|
{
|
|
1868
3208
|
type: "button",
|
|
@@ -1874,10 +3214,10 @@ var PreviewControllerWindow = ({
|
|
|
1874
3214
|
onClick: onRotate,
|
|
1875
3215
|
"aria-label": `Rotate ${session.label} to ${nextOrientationLabel}`,
|
|
1876
3216
|
title: `Rotate to ${nextOrientationLabel}`,
|
|
1877
|
-
children: /* @__PURE__ */ (0,
|
|
3217
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.TabletSmartphone, { className: "h-3.5 w-3.5" })
|
|
1878
3218
|
}
|
|
1879
3219
|
),
|
|
1880
|
-
onActiveOpacityChange ? /* @__PURE__ */ (0,
|
|
3220
|
+
onActiveOpacityChange ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1881
3221
|
Button,
|
|
1882
3222
|
{
|
|
1883
3223
|
type: "button",
|
|
@@ -1892,10 +3232,10 @@ var PreviewControllerWindow = ({
|
|
|
1892
3232
|
onClick: () => setSettingsOpen((current) => !current),
|
|
1893
3233
|
"aria-label": `Adjust ${session.label} opacity`,
|
|
1894
3234
|
title: `Adjust opacity (${Math.round(activeOpacity * 100)}%)`,
|
|
1895
|
-
children: /* @__PURE__ */ (0,
|
|
3235
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.SlidersHorizontal, { className: "h-3.5 w-3.5" })
|
|
1896
3236
|
}
|
|
1897
3237
|
) : null,
|
|
1898
|
-
/* @__PURE__ */ (0,
|
|
3238
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1899
3239
|
Button,
|
|
1900
3240
|
{
|
|
1901
3241
|
type: "button",
|
|
@@ -1907,10 +3247,10 @@ var PreviewControllerWindow = ({
|
|
|
1907
3247
|
onClick: onMinimize,
|
|
1908
3248
|
"aria-label": `Minimize ${session.label}`,
|
|
1909
3249
|
title: "Minimize controller",
|
|
1910
|
-
children: /* @__PURE__ */ (0,
|
|
3250
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Minus, { className: "h-3.5 w-3.5" })
|
|
1911
3251
|
}
|
|
1912
3252
|
),
|
|
1913
|
-
/* @__PURE__ */ (0,
|
|
3253
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1914
3254
|
Button,
|
|
1915
3255
|
{
|
|
1916
3256
|
type: "button",
|
|
@@ -1927,27 +3267,27 @@ var PreviewControllerWindow = ({
|
|
|
1927
3267
|
},
|
|
1928
3268
|
"aria-label": `Close ${session.label}`,
|
|
1929
3269
|
title: "Close controller",
|
|
1930
|
-
children: /* @__PURE__ */ (0,
|
|
3270
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.X, { className: "h-3.5 w-3.5" })
|
|
1931
3271
|
}
|
|
1932
3272
|
)
|
|
1933
3273
|
] })
|
|
1934
3274
|
]
|
|
1935
3275
|
}
|
|
1936
3276
|
),
|
|
1937
|
-
settingsOpen && onActiveOpacityChange ? /* @__PURE__ */ (0,
|
|
3277
|
+
settingsOpen && onActiveOpacityChange ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1938
3278
|
"div",
|
|
1939
3279
|
{
|
|
1940
3280
|
className: "border-b border-white/8 bg-black/72 px-3 py-2.5 backdrop-blur-sm",
|
|
1941
3281
|
onPointerDown: (event) => event.stopPropagation(),
|
|
1942
3282
|
children: [
|
|
1943
|
-
/* @__PURE__ */ (0,
|
|
1944
|
-
/* @__PURE__ */ (0,
|
|
1945
|
-
/* @__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: [
|
|
1946
3286
|
Math.round(activeOpacity * 100),
|
|
1947
3287
|
"%"
|
|
1948
3288
|
] })
|
|
1949
3289
|
] }),
|
|
1950
|
-
/* @__PURE__ */ (0,
|
|
3290
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1951
3291
|
Slider,
|
|
1952
3292
|
{
|
|
1953
3293
|
value: [activeOpacity * 100],
|
|
@@ -1961,7 +3301,7 @@ var PreviewControllerWindow = ({
|
|
|
1961
3301
|
]
|
|
1962
3302
|
}
|
|
1963
3303
|
) : null,
|
|
1964
|
-
/* @__PURE__ */ (0,
|
|
3304
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1965
3305
|
"div",
|
|
1966
3306
|
{
|
|
1967
3307
|
className: "relative",
|
|
@@ -1970,7 +3310,7 @@ var PreviewControllerWindow = ({
|
|
|
1970
3310
|
onFocus();
|
|
1971
3311
|
}
|
|
1972
3312
|
},
|
|
1973
|
-
children: /* @__PURE__ */ (0,
|
|
3313
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1974
3314
|
"div",
|
|
1975
3315
|
{
|
|
1976
3316
|
className: "relative overflow-hidden bg-black",
|
|
@@ -1979,7 +3319,7 @@ var PreviewControllerWindow = ({
|
|
|
1979
3319
|
height: contentHeight
|
|
1980
3320
|
},
|
|
1981
3321
|
children: [
|
|
1982
|
-
/* @__PURE__ */ (0,
|
|
3322
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1983
3323
|
"div",
|
|
1984
3324
|
{
|
|
1985
3325
|
className: "origin-top-left",
|
|
@@ -1989,10 +3329,13 @@ var PreviewControllerWindow = ({
|
|
|
1989
3329
|
transform: `scale(${session.displayScale})`,
|
|
1990
3330
|
transformOrigin: "top left"
|
|
1991
3331
|
},
|
|
1992
|
-
children: /* @__PURE__ */ (0,
|
|
3332
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1993
3333
|
"iframe",
|
|
1994
3334
|
{
|
|
1995
|
-
ref:
|
|
3335
|
+
ref: (frame) => {
|
|
3336
|
+
iframeRef.current = frame;
|
|
3337
|
+
frameRef?.(frame);
|
|
3338
|
+
},
|
|
1996
3339
|
src: session.url,
|
|
1997
3340
|
title: `${session.label} controller`,
|
|
1998
3341
|
"data-testid": `preview-controller-frame-${session.ordinal}`,
|
|
@@ -2009,14 +3352,14 @@ var PreviewControllerWindow = ({
|
|
|
2009
3352
|
)
|
|
2010
3353
|
}
|
|
2011
3354
|
),
|
|
2012
|
-
session.surfaceState === "loading" ? /* @__PURE__ */ (0,
|
|
2013
|
-
/* @__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" }),
|
|
2014
3357
|
"Loading"
|
|
2015
3358
|
] }) }) : null,
|
|
2016
|
-
session.surfaceState === "failed" ? /* @__PURE__ */ (0,
|
|
2017
|
-
/* @__PURE__ */ (0,
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2019
|
-
/* @__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." })
|
|
2020
3363
|
] }) }) : null
|
|
2021
3364
|
]
|
|
2022
3365
|
}
|
|
@@ -2026,7 +3369,7 @@ var PreviewControllerWindow = ({
|
|
|
2026
3369
|
]
|
|
2027
3370
|
}
|
|
2028
3371
|
),
|
|
2029
|
-
RESIZE_HANDLES.map(({ handle, cursor, style }) => /* @__PURE__ */ (0,
|
|
3372
|
+
RESIZE_HANDLES.map(({ handle, cursor, style }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2030
3373
|
"div",
|
|
2031
3374
|
{
|
|
2032
3375
|
"data-testid": `preview-controller-resize-${handle}-${session.ordinal}`,
|
|
@@ -2050,8 +3393,127 @@ var PreviewControllerWindow = ({
|
|
|
2050
3393
|
);
|
|
2051
3394
|
};
|
|
2052
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
|
+
|
|
2053
3514
|
// src/preview/workspace.tsx
|
|
2054
|
-
var
|
|
3515
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3516
|
+
var rosterSourceOf = (kind) => kind === "agent" ? "virtual" : kind;
|
|
2055
3517
|
var getControllerSourceLabel = (source) => {
|
|
2056
3518
|
if (source === "virtual") {
|
|
2057
3519
|
return "Agent";
|
|
@@ -2069,8 +3531,9 @@ var getControllerSourceIcon = (source) => {
|
|
|
2069
3531
|
};
|
|
2070
3532
|
var PreviewControllerWorkspace = ({
|
|
2071
3533
|
joinUrl,
|
|
3534
|
+
fixedControllerOrientation: requestedFixedOrientation,
|
|
2072
3535
|
embedOrigin,
|
|
2073
|
-
|
|
3536
|
+
players = [],
|
|
2074
3537
|
onRemoveController,
|
|
2075
3538
|
onResetRoom,
|
|
2076
3539
|
enabled = false,
|
|
@@ -2080,15 +3543,22 @@ var PreviewControllerWorkspace = ({
|
|
|
2080
3543
|
dockAccessory,
|
|
2081
3544
|
maxControllers = 2,
|
|
2082
3545
|
launcherLabel = "Controllers",
|
|
2083
|
-
|
|
3546
|
+
launcherVariant = "full",
|
|
3547
|
+
showLauncherWhenIdle = true,
|
|
3548
|
+
waitingLabel = "Waiting for room",
|
|
3549
|
+
localPlayers = true,
|
|
3550
|
+
localPlayersGame = null
|
|
2084
3551
|
}) => {
|
|
2085
|
-
const
|
|
2086
|
-
const
|
|
2087
|
-
const [
|
|
2088
|
-
const [
|
|
2089
|
-
const [
|
|
2090
|
-
const [
|
|
2091
|
-
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);
|
|
2092
3562
|
const resolvedEmbedOrigin = embedOrigin ?? (typeof window !== "undefined" ? window.location.origin : null);
|
|
2093
3563
|
const {
|
|
2094
3564
|
sessions,
|
|
@@ -2105,22 +3575,41 @@ var PreviewControllerWorkspace = ({
|
|
|
2105
3575
|
markPreviewControllerReady,
|
|
2106
3576
|
markPreviewControllerFailed
|
|
2107
3577
|
} = usePreviewControllerManager({
|
|
3578
|
+
fixedControllerOrientation: fixedOrientation,
|
|
2108
3579
|
joinUrl,
|
|
2109
3580
|
embedOrigin: resolvedEmbedOrigin,
|
|
2110
3581
|
enabled,
|
|
2111
3582
|
maxControllers
|
|
2112
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);
|
|
2113
3602
|
const platformSettings = useResolvedPlatformSettingsSnapshot();
|
|
2114
3603
|
const activeOpacity = platformSettings.previewControllers.activeOpacity;
|
|
2115
|
-
const sortedSessions = (0,
|
|
3604
|
+
const sortedSessions = (0, import_react10.useMemo)(
|
|
2116
3605
|
() => [...sessions].sort((left, right) => left.ordinal - right.ordinal),
|
|
2117
3606
|
[sessions]
|
|
2118
3607
|
);
|
|
2119
|
-
(0,
|
|
3608
|
+
(0, import_react10.useEffect)(() => {
|
|
2120
3609
|
setMounted(true);
|
|
2121
3610
|
return () => setMounted(false);
|
|
2122
3611
|
}, []);
|
|
2123
|
-
(0,
|
|
3612
|
+
(0, import_react10.useEffect)(() => {
|
|
2124
3613
|
if (!launcherOpen || typeof document === "undefined") {
|
|
2125
3614
|
return;
|
|
2126
3615
|
}
|
|
@@ -2146,43 +3635,40 @@ var PreviewControllerWorkspace = ({
|
|
|
2146
3635
|
document.removeEventListener("keydown", handleKeyDown);
|
|
2147
3636
|
};
|
|
2148
3637
|
}, [launcherOpen]);
|
|
2149
|
-
const minimizedSessions = (0,
|
|
3638
|
+
const minimizedSessions = (0, import_react10.useMemo)(
|
|
2150
3639
|
() => sessions.filter((session) => session.minimized).sort((left, right) => left.ordinal - right.ordinal),
|
|
2151
3640
|
[sessions]
|
|
2152
3641
|
);
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2155
|
-
[
|
|
2156
|
-
|
|
2157
|
-
const sortedControllers = (0, import_react8.useMemo)(
|
|
2158
|
-
() => [...controllers].sort(
|
|
2159
|
-
(left, right) => left.controllerId.localeCompare(right.controllerId)
|
|
2160
|
-
),
|
|
2161
|
-
[controllers]
|
|
3642
|
+
const launcherVisible = showLauncherWhenIdle || launcherOpen || sessions.length > 0;
|
|
3643
|
+
const sortedControllers = (0, import_react10.useMemo)(
|
|
3644
|
+
() => [...players].sort((left, right) => left.id.localeCompare(right.id)),
|
|
3645
|
+
[players]
|
|
2162
3646
|
);
|
|
2163
|
-
const controllerRoster = (0,
|
|
2164
|
-
const
|
|
2165
|
-
sortedSessions.
|
|
3647
|
+
const controllerRoster = (0, import_react10.useMemo)(() => {
|
|
3648
|
+
const sessionsBySeat = new Map(
|
|
3649
|
+
sortedSessions.flatMap(
|
|
3650
|
+
(session) => session.seat ? [[session.seat, session]] : []
|
|
3651
|
+
)
|
|
2166
3652
|
);
|
|
2167
3653
|
const controllerItems = sortedControllers.map((controller) => {
|
|
2168
|
-
const session =
|
|
3654
|
+
const session = sessionsBySeat.get(controller.id) ?? null;
|
|
2169
3655
|
return {
|
|
2170
|
-
id: controller.
|
|
2171
|
-
controllerId: controller.
|
|
2172
|
-
label: controller.
|
|
2173
|
-
source: controller.
|
|
3656
|
+
id: controller.id,
|
|
3657
|
+
controllerId: controller.id,
|
|
3658
|
+
label: controller.label,
|
|
3659
|
+
source: rosterSourceOf(controller.kind),
|
|
2174
3660
|
connected: controller.connected,
|
|
2175
|
-
resumable:
|
|
3661
|
+
resumable: !controller.connected,
|
|
2176
3662
|
session,
|
|
2177
3663
|
controller
|
|
2178
3664
|
};
|
|
2179
3665
|
});
|
|
2180
|
-
const
|
|
2181
|
-
sortedControllers.map((controller) => controller.
|
|
3666
|
+
const seatIds = new Set(
|
|
3667
|
+
sortedControllers.map((controller) => controller.id)
|
|
2182
3668
|
);
|
|
2183
|
-
const pendingPreviewItems = sortedSessions.filter((session) => !
|
|
3669
|
+
const pendingPreviewItems = sortedSessions.filter((session) => !session.seat || !seatIds.has(session.seat)).map((session) => ({
|
|
2184
3670
|
id: session.id,
|
|
2185
|
-
controllerId: session.
|
|
3671
|
+
controllerId: session.seat ?? session.id,
|
|
2186
3672
|
label: session.label,
|
|
2187
3673
|
source: "preview",
|
|
2188
3674
|
connected: session.surfaceState === "ready",
|
|
@@ -2206,16 +3692,21 @@ var PreviewControllerWorkspace = ({
|
|
|
2206
3692
|
return null;
|
|
2207
3693
|
}
|
|
2208
3694
|
return (0, import_react_dom.createPortal)(
|
|
2209
|
-
/* @__PURE__ */ (0,
|
|
3695
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2210
3696
|
"div",
|
|
2211
3697
|
{
|
|
2212
3698
|
className: "fixed inset-0",
|
|
2213
3699
|
style: { zIndex: PREVIEW_WORKSPACE_Z_INDEX, pointerEvents: "none" },
|
|
2214
3700
|
children: [
|
|
2215
|
-
|
|
3701
|
+
sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2216
3702
|
PreviewControllerWindow,
|
|
2217
3703
|
{
|
|
3704
|
+
fixedControllerOrientation: fixedOrientation,
|
|
2218
3705
|
session,
|
|
3706
|
+
frameRef: (frame) => {
|
|
3707
|
+
if (frame) frames.set(session.id, frame);
|
|
3708
|
+
else frames.delete(session.id);
|
|
3709
|
+
},
|
|
2219
3710
|
activeOpacity,
|
|
2220
3711
|
highContrast,
|
|
2221
3712
|
dragging: dragState?.id === session.id,
|
|
@@ -2334,7 +3825,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2334
3825
|
},
|
|
2335
3826
|
session.id
|
|
2336
3827
|
)),
|
|
2337
|
-
/* @__PURE__ */ (0,
|
|
3828
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2338
3829
|
"div",
|
|
2339
3830
|
{
|
|
2340
3831
|
ref: dockRef,
|
|
@@ -2344,38 +3835,42 @@ var PreviewControllerWorkspace = ({
|
|
|
2344
3835
|
),
|
|
2345
3836
|
style: { pointerEvents: "none" },
|
|
2346
3837
|
children: [
|
|
2347
|
-
/* @__PURE__ */ (0,
|
|
3838
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2348
3839
|
"div",
|
|
2349
3840
|
{
|
|
3841
|
+
ref: dockRowRef,
|
|
2350
3842
|
className: "flex items-start justify-end gap-2",
|
|
2351
3843
|
style: { pointerEvents: "auto" },
|
|
2352
3844
|
children: [
|
|
2353
3845
|
dockAccessory,
|
|
2354
|
-
/* @__PURE__ */ (0,
|
|
3846
|
+
launcherVisible ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2355
3847
|
Button,
|
|
2356
3848
|
{
|
|
2357
3849
|
type: "button",
|
|
2358
3850
|
variant: "ghost",
|
|
2359
|
-
size: "sm",
|
|
3851
|
+
size: launcherVariant === "compact" ? "icon-sm" : "sm",
|
|
2360
3852
|
className: cn(
|
|
2361
|
-
"rounded-full border border-white/25 bg-black/35
|
|
3853
|
+
"relative rounded-full border border-white/25 bg-black/35 text-white backdrop-blur-sm hover:bg-black/55 disabled:border-white/10 disabled:bg-black/25 disabled:text-white/40",
|
|
3854
|
+
launcherVariant === "compact" ? "h-9 w-9 p-0" : "gap-2 px-3"
|
|
2362
3855
|
),
|
|
2363
3856
|
"aria-expanded": launcherOpen,
|
|
2364
|
-
"aria-label": launcherOpen ?
|
|
3857
|
+
"aria-label": launcherOpen ? `Hide ${launcherLabel.toLowerCase()}` : `Show ${launcherLabel.toLowerCase()}`,
|
|
2365
3858
|
title: !joinUrl ? waitingLabel : launcherLabel,
|
|
2366
3859
|
onClick: () => setLauncherOpen((current) => !current),
|
|
2367
3860
|
children: [
|
|
2368
|
-
/* @__PURE__ */ (0,
|
|
2369
|
-
/* @__PURE__ */ (0,
|
|
2370
|
-
|
|
2371
|
-
|
|
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
|
|
2372
3867
|
]
|
|
2373
3868
|
}
|
|
2374
|
-
)
|
|
3869
|
+
) : null
|
|
2375
3870
|
]
|
|
2376
3871
|
}
|
|
2377
3872
|
),
|
|
2378
|
-
launcherOpen ? /* @__PURE__ */ (0,
|
|
3873
|
+
launcherOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2379
3874
|
"section",
|
|
2380
3875
|
{
|
|
2381
3876
|
className: cn(
|
|
@@ -2384,15 +3879,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2384
3879
|
highContrast && "border-white/30"
|
|
2385
3880
|
),
|
|
2386
3881
|
style: { pointerEvents: "auto" },
|
|
2387
|
-
children: /* @__PURE__ */ (0,
|
|
2388
|
-
controllerRoster.length > 0 || onResetRoom ? /* @__PURE__ */ (0,
|
|
2389
|
-
/* @__PURE__ */ (0,
|
|
2390
|
-
/* @__PURE__ */ (0,
|
|
2391
|
-
/* @__PURE__ */ (0,
|
|
2392
|
-
/* @__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` })
|
|
2393
3888
|
] }),
|
|
2394
|
-
/* @__PURE__ */ (0,
|
|
2395
|
-
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)(
|
|
2396
3891
|
Button,
|
|
2397
3892
|
{
|
|
2398
3893
|
type: "button",
|
|
@@ -2411,7 +3906,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2411
3906
|
children: "Reset room"
|
|
2412
3907
|
}
|
|
2413
3908
|
) : null,
|
|
2414
|
-
sessions.length > 0 ? /* @__PURE__ */ (0,
|
|
3909
|
+
sessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2415
3910
|
Button,
|
|
2416
3911
|
{
|
|
2417
3912
|
type: "button",
|
|
@@ -2420,15 +3915,15 @@ var PreviewControllerWorkspace = ({
|
|
|
2420
3915
|
className: "h-7 w-7 rounded-full text-white/72 hover:bg-white/8 hover:text-white",
|
|
2421
3916
|
onClick: () => clearPreviewControllers(),
|
|
2422
3917
|
title: "Close all preview controllers",
|
|
2423
|
-
children: /* @__PURE__ */ (0,
|
|
3918
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
2424
3919
|
}
|
|
2425
3920
|
) : null
|
|
2426
3921
|
] })
|
|
2427
3922
|
] }),
|
|
2428
|
-
/* @__PURE__ */ (0,
|
|
3923
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-2", children: controllerRoster.map((item) => {
|
|
2429
3924
|
const SourceIcon = getControllerSourceIcon(item.source);
|
|
2430
3925
|
const previewSession = item.session;
|
|
2431
|
-
return /* @__PURE__ */ (0,
|
|
3926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2432
3927
|
"div",
|
|
2433
3928
|
{
|
|
2434
3929
|
"data-airjam-controller-row": true,
|
|
@@ -2439,10 +3934,10 @@ var PreviewControllerWorkspace = ({
|
|
|
2439
3934
|
shellInsetPanelClassName
|
|
2440
3935
|
),
|
|
2441
3936
|
children: [
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
2443
|
-
/* @__PURE__ */ (0,
|
|
2444
|
-
/* @__PURE__ */ (0,
|
|
2445
|
-
/* @__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)(
|
|
2446
3941
|
"span",
|
|
2447
3942
|
{
|
|
2448
3943
|
"data-airjam-controller-source-badge": true,
|
|
@@ -2450,7 +3945,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2450
3945
|
children: getControllerSourceLabel(item.source)
|
|
2451
3946
|
}
|
|
2452
3947
|
),
|
|
2453
|
-
/* @__PURE__ */ (0,
|
|
3948
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2454
3949
|
"span",
|
|
2455
3950
|
{
|
|
2456
3951
|
className: cn(
|
|
@@ -2460,10 +3955,10 @@ var PreviewControllerWorkspace = ({
|
|
|
2460
3955
|
title: item.session?.minimized ? "Minimized" : item.session ? item.session.surfaceState === "ready" ? "Visible" : previewControllerWindowStateLabel[item.session.surfaceState] : item.connected ? "Connected" : "Disconnected"
|
|
2461
3956
|
}
|
|
2462
3957
|
),
|
|
2463
|
-
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
|
|
2464
3959
|
] }) }),
|
|
2465
|
-
/* @__PURE__ */ (0,
|
|
2466
|
-
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)(
|
|
2467
3962
|
Button,
|
|
2468
3963
|
{
|
|
2469
3964
|
type: "button",
|
|
@@ -2477,35 +3972,35 @@ var PreviewControllerWorkspace = ({
|
|
|
2477
3972
|
children: "Restore"
|
|
2478
3973
|
}
|
|
2479
3974
|
) : null,
|
|
2480
|
-
item.controller && onRemoveController ? /* @__PURE__ */ (0,
|
|
3975
|
+
item.controller && onRemoveController ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2481
3976
|
Button,
|
|
2482
3977
|
{
|
|
2483
3978
|
type: "button",
|
|
2484
3979
|
variant: "ghost",
|
|
2485
3980
|
size: "sm",
|
|
2486
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",
|
|
2487
|
-
disabled: removingControllerId === item.controller.
|
|
3982
|
+
disabled: removingControllerId === item.controller.id,
|
|
2488
3983
|
onClick: async () => {
|
|
2489
3984
|
if (!item.controller) {
|
|
2490
3985
|
return;
|
|
2491
3986
|
}
|
|
2492
3987
|
try {
|
|
2493
3988
|
setRemovingControllerId(
|
|
2494
|
-
item.controller.
|
|
3989
|
+
item.controller.id
|
|
2495
3990
|
);
|
|
2496
3991
|
await onRemoveController(
|
|
2497
|
-
item.controller.
|
|
3992
|
+
item.controller.id
|
|
2498
3993
|
);
|
|
2499
3994
|
} finally {
|
|
2500
3995
|
setRemovingControllerId(
|
|
2501
|
-
(current) => current === item.controller?.
|
|
3996
|
+
(current) => current === item.controller?.id ? null : current
|
|
2502
3997
|
);
|
|
2503
3998
|
}
|
|
2504
3999
|
},
|
|
2505
4000
|
children: "Kick"
|
|
2506
4001
|
}
|
|
2507
4002
|
) : null,
|
|
2508
|
-
previewSession ? /* @__PURE__ */ (0,
|
|
4003
|
+
previewSession ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2509
4004
|
Button,
|
|
2510
4005
|
{
|
|
2511
4006
|
type: "button",
|
|
@@ -2514,7 +4009,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2514
4009
|
className: "h-7 w-7 rounded-full text-white/68 hover:bg-white/8 hover:text-white",
|
|
2515
4010
|
onClick: () => removePreviewController(previewSession.id),
|
|
2516
4011
|
title: `Close ${item.label}`,
|
|
2517
|
-
children: /* @__PURE__ */ (0,
|
|
4012
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
2518
4013
|
}
|
|
2519
4014
|
) : null
|
|
2520
4015
|
] })
|
|
@@ -2523,13 +4018,13 @@ var PreviewControllerWorkspace = ({
|
|
|
2523
4018
|
item.id
|
|
2524
4019
|
);
|
|
2525
4020
|
}) }),
|
|
2526
|
-
/* @__PURE__ */ (0,
|
|
2527
|
-
] }) : /* @__PURE__ */ (0,
|
|
2528
|
-
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: [
|
|
2529
4024
|
minimizedSessions.length,
|
|
2530
4025
|
" minimized"
|
|
2531
4026
|
] }) : null,
|
|
2532
|
-
/* @__PURE__ */ (0,
|
|
4027
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2533
4028
|
Button,
|
|
2534
4029
|
{
|
|
2535
4030
|
type: "button",
|
|
@@ -2543,7 +4038,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2543
4038
|
spawnPreviewController();
|
|
2544
4039
|
},
|
|
2545
4040
|
children: [
|
|
2546
|
-
/* @__PURE__ */ (0,
|
|
4041
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
|
|
2547
4042
|
!joinUrl ? waitingLabel : "Add controller"
|
|
2548
4043
|
]
|
|
2549
4044
|
}
|
|
@@ -2562,7 +4057,7 @@ var PreviewControllerWorkspace = ({
|
|
|
2562
4057
|
};
|
|
2563
4058
|
|
|
2564
4059
|
// src/preview/host-workspace.tsx
|
|
2565
|
-
var
|
|
4060
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2566
4061
|
var HostPreviewControllerWorkspace = ({
|
|
2567
4062
|
enabled = "auto",
|
|
2568
4063
|
className,
|
|
@@ -2576,20 +4071,15 @@ var HostPreviewControllerWorkspace = ({
|
|
|
2576
4071
|
topology: config.topology
|
|
2577
4072
|
});
|
|
2578
4073
|
const joinUrl = host.joinUrlStatus === "ready" && host.joinUrl ? host.joinUrl : null;
|
|
2579
|
-
const handleResetRoom =
|
|
2580
|
-
|
|
2581
|
-
if (!ack.ok || typeof window === "undefined") {
|
|
2582
|
-
return ack;
|
|
2583
|
-
}
|
|
2584
|
-
window.location.reload();
|
|
2585
|
-
return ack;
|
|
4074
|
+
const handleResetRoom = () => {
|
|
4075
|
+
void host.resetRoom().then(() => window.location.reload());
|
|
2586
4076
|
};
|
|
2587
|
-
return /* @__PURE__ */ (0,
|
|
4077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2588
4078
|
PreviewControllerWorkspace,
|
|
2589
4079
|
{
|
|
2590
4080
|
enabled: resolvedEnabled,
|
|
2591
4081
|
joinUrl,
|
|
2592
|
-
|
|
4082
|
+
players: host.players,
|
|
2593
4083
|
onRemoveController: host.removeController,
|
|
2594
4084
|
onResetRoom: handleResetRoom,
|
|
2595
4085
|
onActiveOpacityChange: (activeOpacity) => platformSettingsOwner?.updatePreviewControllers({ activeOpacity }),
|
|
@@ -2600,21 +4090,26 @@ var HostPreviewControllerWorkspace = ({
|
|
|
2600
4090
|
};
|
|
2601
4091
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2602
4092
|
0 && (module.exports = {
|
|
2603
|
-
|
|
2604
|
-
AIR_JAM_PREVIEW_FLAG_QUERY_PARAM,
|
|
4093
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM,
|
|
2605
4094
|
HostPreviewControllerWorkspace,
|
|
2606
4095
|
PreviewControllerWindow,
|
|
2607
4096
|
PreviewControllerWorkspace,
|
|
2608
4097
|
buildPreviewControllerUrl,
|
|
2609
|
-
createPreviewControllerIdentity,
|
|
2610
4098
|
createPreviewControllerLaunch,
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
4099
|
+
getPreviewControllerViewportSize,
|
|
4100
|
+
getPreviewHostViewportSize,
|
|
4101
|
+
isLocalSeatReadyMessage,
|
|
4102
|
+
isLocalSeatRelayedMessage,
|
|
4103
|
+
isPreviewSeatMessage,
|
|
4104
|
+
localInputOperationSchema,
|
|
4105
|
+
localSeatMessages,
|
|
4106
|
+
localSeatQuerySchema,
|
|
4107
|
+
localSeatRelaySchema,
|
|
4108
|
+
localSeatRequestSchema,
|
|
2616
4109
|
readPreviewControllerDeviceIdFromSearchParams,
|
|
2617
|
-
|
|
4110
|
+
relayLocalSeatInput,
|
|
4111
|
+
requestPreviewControllerClose,
|
|
4112
|
+
sendLocalSeatOperation,
|
|
2618
4113
|
usePreviewControllerManager
|
|
2619
4114
|
});
|
|
2620
4115
|
//# sourceMappingURL=preview.cjs.map
|