@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.js
CHANGED
|
@@ -1,47 +1,74 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Button,
|
|
3
|
+
SURFACE_VIEWPORT_REFERENCE_SIZES,
|
|
3
4
|
Slider,
|
|
4
5
|
cn,
|
|
5
6
|
shellInsetPanelClassName,
|
|
6
7
|
shellPanelClassName,
|
|
7
8
|
shellUtilityButtonClassName
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6ZJUA63D.js";
|
|
9
10
|
import {
|
|
10
|
-
|
|
11
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM,
|
|
12
|
+
isLocalSeatReadyMessage,
|
|
13
|
+
isLocalSeatRelayedMessage,
|
|
14
|
+
isPreviewSeatMessage,
|
|
15
|
+
localInputOperationSchema,
|
|
16
|
+
localSeatKeyboardSchema,
|
|
17
|
+
localSeatMessages,
|
|
18
|
+
localSeatQuerySchema,
|
|
19
|
+
localSeatRelaySchema,
|
|
20
|
+
localSeatRequestSchema,
|
|
21
|
+
relayLocalSeatInput,
|
|
22
|
+
requestPreviewControllerClose,
|
|
23
|
+
sendLocalSeatOperation,
|
|
24
|
+
useAirJamHost,
|
|
25
|
+
useProvideLocalSeats,
|
|
26
|
+
useServeLocalSeats
|
|
27
|
+
} from "./chunk-URVBMQCK.js";
|
|
28
|
+
import {
|
|
29
|
+
AIR_JAM_PREVIEW_CAPTURE_QUERY_PARAM,
|
|
11
30
|
AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM,
|
|
12
31
|
AIR_JAM_PREVIEW_FLAG_QUERY_PARAM,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readPreviewControllerDeviceIdFromLocation,
|
|
18
|
-
readPreviewControllerDeviceIdFromSearchParams,
|
|
19
|
-
useAirJamHost
|
|
20
|
-
} from "./chunk-E5PVHEAX.js";
|
|
32
|
+
AIR_JAM_PREVIEW_PARENT_QUERY_PARAM,
|
|
33
|
+
createPreviewControllerDeviceId,
|
|
34
|
+
readPreviewControllerDeviceIdFromSearchParams
|
|
35
|
+
} from "./chunk-BEM77SVQ.js";
|
|
21
36
|
import {
|
|
37
|
+
fixedControllerOrientationContext,
|
|
38
|
+
useAirJamConfig,
|
|
22
39
|
useOptionalPlatformSettingsOwnerApi,
|
|
23
40
|
useResolvedPlatformSettingsSnapshot
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-DY67S3LR.js";
|
|
27
|
-
import {
|
|
28
|
-
useAirJamConfig
|
|
29
|
-
} from "./chunk-NUJBMV3O.js";
|
|
30
|
-
import "./chunk-LIXPF4P6.js";
|
|
31
|
-
import "./chunk-ZLPL2R3R.js";
|
|
32
|
-
import "./chunk-32NYL7XI.js";
|
|
33
|
-
import "./chunk-W2VK36RO.js";
|
|
41
|
+
} from "./chunk-TFW4NJW2.js";
|
|
42
|
+
import "./chunk-QHBRHYMV.js";
|
|
34
43
|
import {
|
|
35
|
-
|
|
36
|
-
} from "./chunk-
|
|
44
|
+
parseOptionalArcadeSurfaceFromSearchParams
|
|
45
|
+
} from "./chunk-M5553I2G.js";
|
|
46
|
+
import "./chunk-EG25EXSA.js";
|
|
47
|
+
import "./chunk-2QZADUGA.js";
|
|
48
|
+
import "./chunk-LX6CTPDW.js";
|
|
49
|
+
import "./chunk-FJ4J2BEC.js";
|
|
50
|
+
import "./chunk-MD25536W.js";
|
|
51
|
+
import "./chunk-C5GS2GMK.js";
|
|
52
|
+
import "./chunk-5TVVPBQI.js";
|
|
53
|
+
import "./chunk-DRBPVG47.js";
|
|
54
|
+
import "./chunk-DBF7NJ3S.js";
|
|
55
|
+
import "./chunk-KUGROY5S.js";
|
|
37
56
|
import {
|
|
38
57
|
appendRuntimeQueryParams,
|
|
39
58
|
getRuntimeUrlOrigin,
|
|
40
59
|
normalizeRuntimeUrl
|
|
41
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-MJAWAHLT.js";
|
|
61
|
+
import "./chunk-6Y3F6Y2K.js";
|
|
62
|
+
import "./chunk-KSYN4I5Y.js";
|
|
63
|
+
import "./chunk-CDL7LYZH.js";
|
|
64
|
+
import "./chunk-WAFGYJZN.js";
|
|
65
|
+
import "./chunk-H4DEVMTO.js";
|
|
42
66
|
import {
|
|
43
|
-
|
|
44
|
-
} from "./chunk-
|
|
67
|
+
isLocalDevControlSurfaceRuntimeMode
|
|
68
|
+
} from "./chunk-2H2FGF3H.js";
|
|
69
|
+
import "./chunk-C5722GTG.js";
|
|
70
|
+
import "./chunk-5CRZFIN6.js";
|
|
71
|
+
import "./chunk-24NZZOIO.js";
|
|
45
72
|
|
|
46
73
|
// src/preview/ownership.ts
|
|
47
74
|
var readDevelopmentRuntime = () => {
|
|
@@ -72,6 +99,7 @@ var isEmbeddedArcadeRuntimeSearchParams = (searchParams) => parseOptionalArcadeS
|
|
|
72
99
|
var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
73
100
|
enabled = "auto",
|
|
74
101
|
topology,
|
|
102
|
+
isEmbeddedRuntime = typeof window !== "undefined" && window.parent !== window,
|
|
75
103
|
isDevelopmentRuntime = readDevelopmentRuntime(),
|
|
76
104
|
searchParams
|
|
77
105
|
} = {}) => {
|
|
@@ -79,7 +107,7 @@ var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
|
79
107
|
return enabled;
|
|
80
108
|
}
|
|
81
109
|
const localDevControlSurfacesEnabled = topology != null ? isLocalDevControlSurfaceRuntimeMode(topology.runtimeMode) : isDevelopmentRuntime;
|
|
82
|
-
return localDevControlSurfacesEnabled && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
110
|
+
return localDevControlSurfacesEnabled && !topology?.embedded && !isEmbeddedRuntime && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
83
111
|
};
|
|
84
112
|
|
|
85
113
|
// src/preview/workspace.tsx
|
|
@@ -92,10 +120,18 @@ import {
|
|
|
92
120
|
Smartphone,
|
|
93
121
|
X as X2
|
|
94
122
|
} from "lucide-react";
|
|
95
|
-
import {
|
|
123
|
+
import {
|
|
124
|
+
useCallback as useCallback3,
|
|
125
|
+
useContext,
|
|
126
|
+
useEffect as useEffect3,
|
|
127
|
+
useMemo as useMemo2,
|
|
128
|
+
useRef as useRef4,
|
|
129
|
+
useState as useState4
|
|
130
|
+
} from "react";
|
|
96
131
|
import { createPortal } from "react-dom";
|
|
97
132
|
|
|
98
133
|
// src/preview/layout.ts
|
|
134
|
+
var getPreviewHostViewportSize = () => SURFACE_VIEWPORT_REFERENCE_SIZES.host.landscape;
|
|
99
135
|
var PREVIEW_WORKSPACE_Z_INDEX = 2147483e3;
|
|
100
136
|
var PREVIEW_WINDOW_TITLEBAR_HEIGHT = 38;
|
|
101
137
|
var PREVIEW_WINDOW_RESIZE_EDGE_HIT_SIZE = 12;
|
|
@@ -234,10 +270,12 @@ var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
|
234
270
|
};
|
|
235
271
|
var buildPreviewControllerUrl = ({
|
|
236
272
|
joinUrl,
|
|
237
|
-
controllerId,
|
|
238
273
|
previewDeviceId,
|
|
239
274
|
allowedOrigins,
|
|
240
|
-
embedOrigin
|
|
275
|
+
embedOrigin,
|
|
276
|
+
parentOrigin,
|
|
277
|
+
localSeat,
|
|
278
|
+
capture
|
|
241
279
|
}) => {
|
|
242
280
|
const normalizedJoinUrl = normalizeRuntimeUrl(joinUrl);
|
|
243
281
|
if (!normalizedJoinUrl) {
|
|
@@ -256,41 +294,49 @@ var buildPreviewControllerUrl = ({
|
|
|
256
294
|
if (!normalizedEmbedOrigin) {
|
|
257
295
|
return null;
|
|
258
296
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
297
|
+
const { pathname, search, hash } = new URL(normalizedJoinUrl);
|
|
298
|
+
return new URL(
|
|
299
|
+
`${pathname}${search}${hash}`,
|
|
300
|
+
normalizedEmbedOrigin
|
|
301
|
+
).toString();
|
|
264
302
|
})();
|
|
265
303
|
if (!previewBaseUrl) {
|
|
266
304
|
return null;
|
|
267
305
|
}
|
|
306
|
+
const normalizedParentOrigin = parentOrigin ? getRuntimeUrlOrigin(parentOrigin) : null;
|
|
307
|
+
if (parentOrigin && !normalizedParentOrigin) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
268
310
|
return appendRuntimeQueryParams(previewBaseUrl, {
|
|
269
|
-
controllerId,
|
|
270
311
|
[AIR_JAM_PREVIEW_FLAG_QUERY_PARAM]: "1",
|
|
271
|
-
[AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM]: previewDeviceId
|
|
312
|
+
[AIR_JAM_PREVIEW_DEVICE_QUERY_PARAM]: previewDeviceId,
|
|
313
|
+
[AIR_JAM_PREVIEW_PARENT_QUERY_PARAM]: normalizedParentOrigin,
|
|
314
|
+
[AIR_JAM_LOCAL_SEAT_QUERY_PARAM]: localSeat,
|
|
315
|
+
[AIR_JAM_PREVIEW_CAPTURE_QUERY_PARAM]: capture ? "1" : null
|
|
272
316
|
});
|
|
273
317
|
};
|
|
274
318
|
var createPreviewControllerLaunch = ({
|
|
275
319
|
joinUrl,
|
|
276
320
|
allowedOrigins,
|
|
277
|
-
embedOrigin
|
|
321
|
+
embedOrigin,
|
|
322
|
+
parentOrigin,
|
|
323
|
+
localSeat,
|
|
324
|
+
capture
|
|
278
325
|
}) => {
|
|
279
|
-
const
|
|
326
|
+
const deviceId = createPreviewControllerDeviceId();
|
|
280
327
|
const url = buildPreviewControllerUrl({
|
|
281
328
|
joinUrl,
|
|
282
|
-
|
|
283
|
-
previewDeviceId: identity.deviceId,
|
|
329
|
+
previewDeviceId: deviceId,
|
|
284
330
|
allowedOrigins,
|
|
285
|
-
embedOrigin
|
|
331
|
+
embedOrigin,
|
|
332
|
+
parentOrigin,
|
|
333
|
+
localSeat,
|
|
334
|
+
capture
|
|
286
335
|
});
|
|
287
336
|
if (!url) {
|
|
288
337
|
return null;
|
|
289
338
|
}
|
|
290
|
-
return {
|
|
291
|
-
...identity,
|
|
292
|
-
url
|
|
293
|
-
};
|
|
339
|
+
return { deviceId, url };
|
|
294
340
|
};
|
|
295
341
|
|
|
296
342
|
// src/preview/manager.ts
|
|
@@ -298,6 +344,7 @@ var DEFAULT_VIEWPORT_WIDTH = 1440;
|
|
|
298
344
|
var DEFAULT_VIEWPORT_HEIGHT = 900;
|
|
299
345
|
var PREVIEW_WINDOW_MARGIN = 24;
|
|
300
346
|
var PREVIEW_WINDOW_CASCADE_OFFSET = 28;
|
|
347
|
+
var PREVIEW_WINDOW_DOCK_GAP = 12;
|
|
301
348
|
var DEFAULT_PREVIEW_CONTROLLER_ORIENTATION = "portrait";
|
|
302
349
|
var getViewportSize = () => {
|
|
303
350
|
if (typeof window === "undefined") {
|
|
@@ -404,27 +451,55 @@ var clampBounds = (orientation, bounds, options = {}, currentBounds) => {
|
|
|
404
451
|
height
|
|
405
452
|
};
|
|
406
453
|
};
|
|
407
|
-
var
|
|
454
|
+
var overlap = (start, size, otherStart, otherSize) => Math.max(
|
|
455
|
+
0,
|
|
456
|
+
Math.min(start + size, otherStart + otherSize) - Math.max(start, otherStart)
|
|
457
|
+
);
|
|
458
|
+
var getInitialWindowBounds = (sessions, orientation, seat) => {
|
|
408
459
|
const viewport = getViewportSize();
|
|
409
|
-
|
|
460
|
+
if (!seat) {
|
|
461
|
+
const bounds2 = getPreviewWindowBounds(
|
|
462
|
+
orientation,
|
|
463
|
+
DEFAULT_PREVIEW_CONTROLLER_SCALE
|
|
464
|
+
);
|
|
465
|
+
const offset = Math.min(sessions.length, 3) * PREVIEW_WINDOW_CASCADE_OFFSET;
|
|
466
|
+
return {
|
|
467
|
+
...bounds2,
|
|
468
|
+
...clampPosition(
|
|
469
|
+
orientation,
|
|
470
|
+
(viewport.width - bounds2.width) / 2 + offset,
|
|
471
|
+
(viewport.height - bounds2.height) / 2 + offset,
|
|
472
|
+
bounds2.width,
|
|
473
|
+
bounds2.height
|
|
474
|
+
)
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const bounds = getPreviewWindowBounds(
|
|
410
478
|
orientation,
|
|
411
|
-
|
|
479
|
+
PREVIEW_CONTROLLER_MIN_SCALE
|
|
412
480
|
);
|
|
413
|
-
const
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
481
|
+
const dock = seat.dock ?? { right: viewport.width, top: viewport.height };
|
|
482
|
+
const place = (index) => ({
|
|
483
|
+
...bounds,
|
|
484
|
+
...clampPosition(
|
|
485
|
+
orientation,
|
|
486
|
+
index % 2 === 0 ? dock.right - bounds.width : viewport.width - dock.right,
|
|
487
|
+
dock.top - (bounds.height + PREVIEW_WINDOW_DOCK_GAP) * (Math.floor(index / 2) + 1),
|
|
488
|
+
bounds.width,
|
|
489
|
+
bounds.height
|
|
490
|
+
)
|
|
491
|
+
});
|
|
492
|
+
const seatPhones = sessions.filter((session) => session.localSeat);
|
|
493
|
+
const coveredArea = (candidate) => seatPhones.reduce(
|
|
494
|
+
(area, phone) => area + overlap(candidate.x, candidate.width, phone.x, phone.width) * overlap(candidate.y, candidate.height, phone.y, phone.height),
|
|
495
|
+
0
|
|
496
|
+
);
|
|
497
|
+
return Array.from(
|
|
498
|
+
{ length: seatPhones.length + 1 },
|
|
499
|
+
(_, index) => place(index)
|
|
500
|
+
).reduce(
|
|
501
|
+
(best, candidate) => coveredArea(candidate) < coveredArea(best) ? candidate : best
|
|
423
502
|
);
|
|
424
|
-
return {
|
|
425
|
-
x: anchored.x,
|
|
426
|
-
y: anchored.y
|
|
427
|
-
};
|
|
428
503
|
};
|
|
429
504
|
var getNextTopSessionId = (sessions) => sessions.filter((session) => !session.minimized).sort((left, right) => right.zIndex - left.zIndex)[0]?.id ?? null;
|
|
430
505
|
var activateSession = (sessions, id, nextZIndex) => sessions.map(
|
|
@@ -443,12 +518,46 @@ var normalizeActiveSession = (sessions) => {
|
|
|
443
518
|
}));
|
|
444
519
|
};
|
|
445
520
|
var mapSessionsAndNormalizeActive = (sessions, mapSession) => normalizeActiveSession(sessions.map(mapSession));
|
|
521
|
+
var orientSession = (session, nextOrientation) => {
|
|
522
|
+
const centerX = session.x + session.width / 2;
|
|
523
|
+
const centerY = session.y + session.height / 2;
|
|
524
|
+
const nextWindowBounds = getPreviewWindowBounds(
|
|
525
|
+
nextOrientation,
|
|
526
|
+
session.displayScale
|
|
527
|
+
);
|
|
528
|
+
const nextBounds = clampBounds(
|
|
529
|
+
nextOrientation,
|
|
530
|
+
{
|
|
531
|
+
x: centerX - nextWindowBounds.width / 2,
|
|
532
|
+
y: centerY - nextWindowBounds.height / 2,
|
|
533
|
+
width: nextWindowBounds.width,
|
|
534
|
+
height: nextWindowBounds.height
|
|
535
|
+
},
|
|
536
|
+
{}
|
|
537
|
+
);
|
|
538
|
+
const clampedWindowBounds = getPreviewWindowBounds(
|
|
539
|
+
nextOrientation,
|
|
540
|
+
getPreviewControllerScaleForBounds(nextOrientation, nextBounds)
|
|
541
|
+
);
|
|
542
|
+
return {
|
|
543
|
+
...session,
|
|
544
|
+
orientation: nextOrientation,
|
|
545
|
+
x: nextBounds.x,
|
|
546
|
+
y: nextBounds.y,
|
|
547
|
+
width: clampedWindowBounds.width,
|
|
548
|
+
height: clampedWindowBounds.height,
|
|
549
|
+
viewportWidth: clampedWindowBounds.viewportWidth,
|
|
550
|
+
viewportHeight: clampedWindowBounds.viewportHeight,
|
|
551
|
+
displayScale: clampedWindowBounds.displayScale
|
|
552
|
+
};
|
|
553
|
+
};
|
|
446
554
|
var usePreviewControllerManager = ({
|
|
447
555
|
joinUrl,
|
|
448
556
|
enabled = true,
|
|
449
557
|
maxControllers = 2,
|
|
450
558
|
allowedOrigins,
|
|
451
|
-
embedOrigin
|
|
559
|
+
embedOrigin,
|
|
560
|
+
fixedControllerOrientation = null
|
|
452
561
|
}) => {
|
|
453
562
|
const [sessions, setSessions] = useState([]);
|
|
454
563
|
const nextSessionIdRef = useRef(1);
|
|
@@ -469,59 +578,71 @@ var usePreviewControllerManager = ({
|
|
|
469
578
|
previousJoinRoomRef.current = nextJoinRoom;
|
|
470
579
|
}, [enabled, joinUrl]);
|
|
471
580
|
const canSpawn = enabled && typeof joinUrl === "string" && joinUrl.trim().length > 0 && sessions.length < maxControllers;
|
|
472
|
-
const spawnPreviewController = useCallback(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
let nextSession = null;
|
|
477
|
-
setSessions((current) => {
|
|
478
|
-
if (current.length >= maxControllers) {
|
|
479
|
-
return current;
|
|
581
|
+
const spawnPreviewController = useCallback(
|
|
582
|
+
(options) => {
|
|
583
|
+
if (!enabled || !joinUrl) {
|
|
584
|
+
return null;
|
|
480
585
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
586
|
+
let nextSession = null;
|
|
587
|
+
setSessions((current) => {
|
|
588
|
+
if (current.length >= maxControllers) {
|
|
589
|
+
return current;
|
|
590
|
+
}
|
|
591
|
+
const launch = createPreviewControllerLaunch({
|
|
592
|
+
joinUrl,
|
|
593
|
+
allowedOrigins,
|
|
594
|
+
embedOrigin,
|
|
595
|
+
localSeat: options?.localSeat?.label
|
|
596
|
+
});
|
|
597
|
+
if (!launch) {
|
|
598
|
+
return current;
|
|
599
|
+
}
|
|
600
|
+
const ordinal = nextOrdinalRef.current++;
|
|
601
|
+
const zIndex = nextZIndexRef.current++;
|
|
602
|
+
const sessionId = `preview_session_${nextSessionIdRef.current++}`;
|
|
603
|
+
const orientation = fixedControllerOrientation ?? DEFAULT_PREVIEW_CONTROLLER_ORIENTATION;
|
|
604
|
+
const bounds = getInitialWindowBounds(
|
|
605
|
+
current,
|
|
606
|
+
orientation,
|
|
607
|
+
options?.localSeat ? { dock: options.dock } : null
|
|
608
|
+
);
|
|
609
|
+
nextSession = {
|
|
610
|
+
id: sessionId,
|
|
611
|
+
ordinal,
|
|
612
|
+
label: options?.localSeat?.label ?? `Preview ${ordinal}`,
|
|
613
|
+
localSeat: options?.localSeat ?? null,
|
|
614
|
+
seat: null,
|
|
615
|
+
deviceId: launch.deviceId,
|
|
616
|
+
url: launch.url,
|
|
617
|
+
surfaceState: "loading",
|
|
618
|
+
orientation,
|
|
619
|
+
minimized: false,
|
|
620
|
+
active: true,
|
|
621
|
+
x: bounds.x,
|
|
622
|
+
y: bounds.y,
|
|
623
|
+
width: bounds.width,
|
|
624
|
+
height: bounds.height,
|
|
625
|
+
viewportWidth: bounds.viewportWidth,
|
|
626
|
+
viewportHeight: bounds.viewportHeight,
|
|
627
|
+
displayScale: bounds.displayScale,
|
|
628
|
+
zIndex
|
|
629
|
+
};
|
|
630
|
+
return [
|
|
631
|
+
...current.map((session) => ({ ...session, active: false })),
|
|
632
|
+
nextSession
|
|
633
|
+
];
|
|
485
634
|
});
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const position = getInitialWindowPosition(current, orientation);
|
|
498
|
-
nextSession = {
|
|
499
|
-
id: sessionId,
|
|
500
|
-
ordinal,
|
|
501
|
-
label: `Preview ${ordinal}`,
|
|
502
|
-
controllerId: launch.controllerId,
|
|
503
|
-
deviceId: launch.deviceId,
|
|
504
|
-
url: launch.url,
|
|
505
|
-
surfaceState: "loading",
|
|
506
|
-
orientation,
|
|
507
|
-
minimized: false,
|
|
508
|
-
active: true,
|
|
509
|
-
x: position.x,
|
|
510
|
-
y: position.y,
|
|
511
|
-
width: defaultBounds.width,
|
|
512
|
-
height: defaultBounds.height,
|
|
513
|
-
viewportWidth: defaultBounds.viewportWidth,
|
|
514
|
-
viewportHeight: defaultBounds.viewportHeight,
|
|
515
|
-
displayScale: defaultBounds.displayScale,
|
|
516
|
-
zIndex
|
|
517
|
-
};
|
|
518
|
-
return [
|
|
519
|
-
...current.map((session) => ({ ...session, active: false })),
|
|
520
|
-
nextSession
|
|
521
|
-
];
|
|
522
|
-
});
|
|
523
|
-
return nextSession;
|
|
524
|
-
}, [allowedOrigins, embedOrigin, enabled, joinUrl, maxControllers]);
|
|
635
|
+
return nextSession;
|
|
636
|
+
},
|
|
637
|
+
[
|
|
638
|
+
allowedOrigins,
|
|
639
|
+
embedOrigin,
|
|
640
|
+
enabled,
|
|
641
|
+
joinUrl,
|
|
642
|
+
maxControllers,
|
|
643
|
+
fixedControllerOrientation
|
|
644
|
+
]
|
|
645
|
+
);
|
|
525
646
|
const removePreviewController = useCallback((id) => {
|
|
526
647
|
setSessions(
|
|
527
648
|
(current) => normalizeActiveSession(current.filter((session) => session.id !== id))
|
|
@@ -606,46 +727,41 @@ var usePreviewControllerManager = ({
|
|
|
606
727
|
},
|
|
607
728
|
[]
|
|
608
729
|
);
|
|
609
|
-
const rotatePreviewController = useCallback(
|
|
730
|
+
const rotatePreviewController = useCallback(
|
|
731
|
+
(id) => {
|
|
732
|
+
if (fixedControllerOrientation) return;
|
|
733
|
+
setSessions(
|
|
734
|
+
(current) => mapSessionsAndNormalizeActive(current, (session) => {
|
|
735
|
+
if (session.id !== id) {
|
|
736
|
+
return session;
|
|
737
|
+
}
|
|
738
|
+
const nextOrientation = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
739
|
+
return orientSession(session, nextOrientation);
|
|
740
|
+
})
|
|
741
|
+
);
|
|
742
|
+
},
|
|
743
|
+
[fixedControllerOrientation]
|
|
744
|
+
);
|
|
745
|
+
useEffect(() => {
|
|
746
|
+
if (!fixedControllerOrientation) return;
|
|
610
747
|
setSessions(
|
|
611
|
-
(current) =>
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
const nextOrientation = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
616
|
-
const centerX = session.x + session.width / 2;
|
|
617
|
-
const centerY = session.y + session.height / 2;
|
|
618
|
-
const nextWindowBounds = getPreviewWindowBounds(
|
|
619
|
-
nextOrientation,
|
|
620
|
-
session.displayScale
|
|
621
|
-
);
|
|
622
|
-
const nextBounds = clampBounds(
|
|
623
|
-
nextOrientation,
|
|
624
|
-
{
|
|
625
|
-
x: centerX - nextWindowBounds.width / 2,
|
|
626
|
-
y: centerY - nextWindowBounds.height / 2,
|
|
627
|
-
width: nextWindowBounds.width,
|
|
628
|
-
height: nextWindowBounds.height
|
|
629
|
-
},
|
|
630
|
-
{}
|
|
631
|
-
);
|
|
632
|
-
const clampedWindowBounds = getPreviewWindowBounds(
|
|
633
|
-
nextOrientation,
|
|
634
|
-
getPreviewControllerScaleForBounds(nextOrientation, nextBounds)
|
|
635
|
-
);
|
|
636
|
-
return {
|
|
637
|
-
...session,
|
|
638
|
-
orientation: nextOrientation,
|
|
639
|
-
x: nextBounds.x,
|
|
640
|
-
y: nextBounds.y,
|
|
641
|
-
width: clampedWindowBounds.width,
|
|
642
|
-
height: clampedWindowBounds.height,
|
|
643
|
-
viewportWidth: clampedWindowBounds.viewportWidth,
|
|
644
|
-
viewportHeight: clampedWindowBounds.viewportHeight,
|
|
645
|
-
displayScale: clampedWindowBounds.displayScale
|
|
646
|
-
};
|
|
647
|
-
})
|
|
748
|
+
(current) => current.map(
|
|
749
|
+
(session) => session.orientation === fixedControllerOrientation ? session : orientSession(session, fixedControllerOrientation)
|
|
750
|
+
)
|
|
648
751
|
);
|
|
752
|
+
}, [fixedControllerOrientation]);
|
|
753
|
+
useEffect(() => {
|
|
754
|
+
const onMessage = (event) => {
|
|
755
|
+
if (!isPreviewSeatMessage(event.data)) return;
|
|
756
|
+
const { deviceId, seat } = event.data;
|
|
757
|
+
setSessions(
|
|
758
|
+
(current) => current.map(
|
|
759
|
+
(session) => session.deviceId === deviceId && new URL(session.url).origin === event.origin && session.seat !== seat ? { ...session, seat } : session
|
|
760
|
+
)
|
|
761
|
+
);
|
|
762
|
+
};
|
|
763
|
+
window.addEventListener("message", onMessage);
|
|
764
|
+
return () => window.removeEventListener("message", onMessage);
|
|
649
765
|
}, []);
|
|
650
766
|
const markPreviewControllerReady = useCallback((id) => {
|
|
651
767
|
setSessions(
|
|
@@ -693,46 +809,6 @@ import {
|
|
|
693
809
|
import { useRef as useRef2, useState as useState2 } from "react";
|
|
694
810
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
695
811
|
var PREVIEW_WINDOW_SETTINGS_SHELF_HEIGHT = 52;
|
|
696
|
-
var PREVIEW_CLOSE_TIMEOUT_MS = 1e3;
|
|
697
|
-
var requestPreviewControllerClose = async (iframe, sessionUrl) => {
|
|
698
|
-
const frameWindow = iframe?.contentWindow;
|
|
699
|
-
if (!frameWindow) {
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
const targetOrigin = new URL(sessionUrl).origin;
|
|
703
|
-
await new Promise((resolve) => {
|
|
704
|
-
let settled = false;
|
|
705
|
-
const timeout = window.setTimeout(() => {
|
|
706
|
-
cleanup();
|
|
707
|
-
resolve();
|
|
708
|
-
}, PREVIEW_CLOSE_TIMEOUT_MS);
|
|
709
|
-
const handleMessage = (event) => {
|
|
710
|
-
if (event.source !== frameWindow || event.origin !== targetOrigin) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
if (!isPreviewCloseResultMessage(event.data)) {
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
cleanup();
|
|
717
|
-
resolve();
|
|
718
|
-
};
|
|
719
|
-
const cleanup = () => {
|
|
720
|
-
if (settled) {
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
settled = true;
|
|
724
|
-
window.clearTimeout(timeout);
|
|
725
|
-
window.removeEventListener("message", handleMessage);
|
|
726
|
-
};
|
|
727
|
-
window.addEventListener("message", handleMessage);
|
|
728
|
-
frameWindow.postMessage(
|
|
729
|
-
{
|
|
730
|
-
type: AIR_JAM_PREVIEW_CLOSE_REQUEST
|
|
731
|
-
},
|
|
732
|
-
targetOrigin
|
|
733
|
-
);
|
|
734
|
-
});
|
|
735
|
-
};
|
|
736
812
|
var previewControllerWindowStateLabel = {
|
|
737
813
|
loading: "Loading",
|
|
738
814
|
ready: "Ready",
|
|
@@ -822,8 +898,10 @@ var RESIZE_HANDLES = [
|
|
|
822
898
|
];
|
|
823
899
|
var PreviewControllerWindow = ({
|
|
824
900
|
session,
|
|
901
|
+
frameRef,
|
|
825
902
|
activeOpacity,
|
|
826
903
|
highContrast = false,
|
|
904
|
+
fixedControllerOrientation = null,
|
|
827
905
|
dragging = false,
|
|
828
906
|
onFocus,
|
|
829
907
|
onMinimize,
|
|
@@ -858,6 +936,7 @@ var PreviewControllerWindow = ({
|
|
|
858
936
|
"div",
|
|
859
937
|
{
|
|
860
938
|
className: "absolute",
|
|
939
|
+
hidden: session.minimized,
|
|
861
940
|
style: {
|
|
862
941
|
left: session.x,
|
|
863
942
|
top: session.y,
|
|
@@ -914,7 +993,7 @@ var PreviewControllerWindow = ({
|
|
|
914
993
|
)
|
|
915
994
|
] }),
|
|
916
995
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
917
|
-
/* @__PURE__ */ jsx(
|
|
996
|
+
!fixedControllerOrientation && /* @__PURE__ */ jsx(
|
|
918
997
|
Button,
|
|
919
998
|
{
|
|
920
999
|
type: "button",
|
|
@@ -1044,7 +1123,10 @@ var PreviewControllerWindow = ({
|
|
|
1044
1123
|
children: /* @__PURE__ */ jsx(
|
|
1045
1124
|
"iframe",
|
|
1046
1125
|
{
|
|
1047
|
-
ref:
|
|
1126
|
+
ref: (frame) => {
|
|
1127
|
+
iframeRef.current = frame;
|
|
1128
|
+
frameRef?.(frame);
|
|
1129
|
+
},
|
|
1048
1130
|
src: session.url,
|
|
1049
1131
|
title: `${session.label} controller`,
|
|
1050
1132
|
"data-testid": `preview-controller-frame-${session.ordinal}`,
|
|
@@ -1102,8 +1184,127 @@ var PreviewControllerWindow = ({
|
|
|
1102
1184
|
);
|
|
1103
1185
|
};
|
|
1104
1186
|
|
|
1187
|
+
// src/preview/workspace-local-seats.ts
|
|
1188
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef3, useState as useState3 } from "react";
|
|
1189
|
+
var useWorkspaceLocalSeats = ({
|
|
1190
|
+
enabled,
|
|
1191
|
+
sessions,
|
|
1192
|
+
canSpawn,
|
|
1193
|
+
spawn,
|
|
1194
|
+
remove,
|
|
1195
|
+
frames
|
|
1196
|
+
}) => {
|
|
1197
|
+
const keyboardListener = useRef3(void 0);
|
|
1198
|
+
const requests = useRef3(/* @__PURE__ */ new Map());
|
|
1199
|
+
const closings = useRef3(/* @__PURE__ */ new Map());
|
|
1200
|
+
const [requested, setRequested] = useState3(0);
|
|
1201
|
+
const provider = useMemo(
|
|
1202
|
+
() => enabled ? {
|
|
1203
|
+
subscribeKeyboard: (receive) => {
|
|
1204
|
+
keyboardListener.current = receive;
|
|
1205
|
+
return () => {
|
|
1206
|
+
keyboardListener.current = void 0;
|
|
1207
|
+
};
|
|
1208
|
+
},
|
|
1209
|
+
open: (seat) => new Promise((resolve) => {
|
|
1210
|
+
requests.current.set(seat.key, {
|
|
1211
|
+
seat,
|
|
1212
|
+
resolve,
|
|
1213
|
+
spawned: false
|
|
1214
|
+
});
|
|
1215
|
+
setRequested((count) => count + 1);
|
|
1216
|
+
})
|
|
1217
|
+
} : null,
|
|
1218
|
+
[enabled]
|
|
1219
|
+
);
|
|
1220
|
+
const ready = useRef3(/* @__PURE__ */ new Set());
|
|
1221
|
+
const openSeat = useCallback2(
|
|
1222
|
+
(key, request, session) => {
|
|
1223
|
+
const origin = new URL(session.url).origin;
|
|
1224
|
+
requests.current.delete(key);
|
|
1225
|
+
closings.current.get(session.id)?.();
|
|
1226
|
+
request.resolve({
|
|
1227
|
+
send: (operation) => {
|
|
1228
|
+
const target = frames.get(session.id)?.contentWindow;
|
|
1229
|
+
if (target) sendLocalSeatOperation(target, origin, operation);
|
|
1230
|
+
},
|
|
1231
|
+
closed: new Promise((close) => closings.current.set(session.id, close))
|
|
1232
|
+
});
|
|
1233
|
+
},
|
|
1234
|
+
[frames]
|
|
1235
|
+
);
|
|
1236
|
+
useEffect2(() => {
|
|
1237
|
+
let spawned = false;
|
|
1238
|
+
for (const [key, request] of requests.current) {
|
|
1239
|
+
const session = sessions.find(
|
|
1240
|
+
(candidate) => candidate.localSeat?.key === key
|
|
1241
|
+
);
|
|
1242
|
+
if (session) {
|
|
1243
|
+
if (ready.current.has(session.id)) openSeat(key, request, session);
|
|
1244
|
+
continue;
|
|
1245
|
+
}
|
|
1246
|
+
if (request.spawned || !canSpawn) {
|
|
1247
|
+
requests.current.delete(key);
|
|
1248
|
+
request.resolve(null);
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
requests.current.set(key, { ...request, spawned: true });
|
|
1252
|
+
spawned = true;
|
|
1253
|
+
spawn({ localSeat: request.seat });
|
|
1254
|
+
}
|
|
1255
|
+
if (spawned) setRequested((count) => count + 1);
|
|
1256
|
+
for (const sessionId of ready.current)
|
|
1257
|
+
if (!sessions.some((session) => session.id === sessionId))
|
|
1258
|
+
ready.current.delete(sessionId);
|
|
1259
|
+
for (const [sessionId, close] of closings.current)
|
|
1260
|
+
if (!sessions.some((session) => session.id === sessionId)) {
|
|
1261
|
+
closings.current.delete(sessionId);
|
|
1262
|
+
close();
|
|
1263
|
+
}
|
|
1264
|
+
}, [requested, sessions, canSpawn, spawn, openSeat]);
|
|
1265
|
+
const leaving = useRef3(/* @__PURE__ */ new Set());
|
|
1266
|
+
useEffect2(() => {
|
|
1267
|
+
if (enabled) return;
|
|
1268
|
+
for (const session of sessions) {
|
|
1269
|
+
if (!session.localSeat || leaving.current.has(session.id)) continue;
|
|
1270
|
+
leaving.current.add(session.id);
|
|
1271
|
+
void requestPreviewControllerClose(
|
|
1272
|
+
frames.get(session.id) ?? null,
|
|
1273
|
+
session.url
|
|
1274
|
+
).finally(() => {
|
|
1275
|
+
leaving.current.delete(session.id);
|
|
1276
|
+
remove(session.id);
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
}, [enabled, sessions, frames, remove]);
|
|
1280
|
+
useEffect2(() => {
|
|
1281
|
+
const onMessage = (event) => {
|
|
1282
|
+
if (!provider) return;
|
|
1283
|
+
const session = sessions.find(
|
|
1284
|
+
(candidate) => candidate.localSeat && frames.get(candidate.id)?.contentWindow === event.source
|
|
1285
|
+
);
|
|
1286
|
+
if (!session?.localSeat || event.origin !== new URL(session.url).origin)
|
|
1287
|
+
return;
|
|
1288
|
+
const keyboard = localSeatKeyboardSchema.safeParse(event.data);
|
|
1289
|
+
if (keyboard.success) {
|
|
1290
|
+
keyboardListener.current?.(keyboard.data);
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
if (!isLocalSeatReadyMessage(event.data)) return;
|
|
1294
|
+
ready.current.add(session.id);
|
|
1295
|
+
const key = session.localSeat.key;
|
|
1296
|
+
const request = requests.current.get(key);
|
|
1297
|
+
if (request) openSeat(key, request, session);
|
|
1298
|
+
};
|
|
1299
|
+
window.addEventListener("message", onMessage);
|
|
1300
|
+
return () => window.removeEventListener("message", onMessage);
|
|
1301
|
+
}, [sessions, frames, openSeat, provider]);
|
|
1302
|
+
return provider;
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1105
1305
|
// src/preview/workspace.tsx
|
|
1106
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1306
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1307
|
+
var rosterSourceOf = (kind) => kind === "agent" ? "virtual" : kind;
|
|
1107
1308
|
var getControllerSourceLabel = (source) => {
|
|
1108
1309
|
if (source === "virtual") {
|
|
1109
1310
|
return "Agent";
|
|
@@ -1121,8 +1322,9 @@ var getControllerSourceIcon = (source) => {
|
|
|
1121
1322
|
};
|
|
1122
1323
|
var PreviewControllerWorkspace = ({
|
|
1123
1324
|
joinUrl,
|
|
1325
|
+
fixedControllerOrientation: requestedFixedOrientation,
|
|
1124
1326
|
embedOrigin,
|
|
1125
|
-
|
|
1327
|
+
players = [],
|
|
1126
1328
|
onRemoveController,
|
|
1127
1329
|
onResetRoom,
|
|
1128
1330
|
enabled = false,
|
|
@@ -1132,15 +1334,22 @@ var PreviewControllerWorkspace = ({
|
|
|
1132
1334
|
dockAccessory,
|
|
1133
1335
|
maxControllers = 2,
|
|
1134
1336
|
launcherLabel = "Controllers",
|
|
1135
|
-
|
|
1337
|
+
launcherVariant = "full",
|
|
1338
|
+
showLauncherWhenIdle = true,
|
|
1339
|
+
waitingLabel = "Waiting for room",
|
|
1340
|
+
localPlayers = true,
|
|
1341
|
+
localPlayersGame = null
|
|
1136
1342
|
}) => {
|
|
1137
|
-
const
|
|
1138
|
-
const
|
|
1139
|
-
const [
|
|
1140
|
-
const [
|
|
1141
|
-
const [
|
|
1142
|
-
const [
|
|
1143
|
-
const
|
|
1343
|
+
const declaredOrientation = useContext(fixedControllerOrientationContext);
|
|
1344
|
+
const fixedOrientation = requestedFixedOrientation ?? declaredOrientation ?? null;
|
|
1345
|
+
const [mounted, setMounted] = useState4(false);
|
|
1346
|
+
const [dragState, setDragState] = useState4(null);
|
|
1347
|
+
const [resizeState, setResizeState] = useState4(null);
|
|
1348
|
+
const [launcherOpen, setLauncherOpen] = useState4(false);
|
|
1349
|
+
const [removingControllerId, setRemovingControllerId] = useState4(null);
|
|
1350
|
+
const [resettingRoom, setResettingRoom] = useState4(false);
|
|
1351
|
+
const dockRef = useRef4(null);
|
|
1352
|
+
const dockRowRef = useRef4(null);
|
|
1144
1353
|
const resolvedEmbedOrigin = embedOrigin ?? (typeof window !== "undefined" ? window.location.origin : null);
|
|
1145
1354
|
const {
|
|
1146
1355
|
sessions,
|
|
@@ -1157,22 +1366,41 @@ var PreviewControllerWorkspace = ({
|
|
|
1157
1366
|
markPreviewControllerReady,
|
|
1158
1367
|
markPreviewControllerFailed
|
|
1159
1368
|
} = usePreviewControllerManager({
|
|
1369
|
+
fixedControllerOrientation: fixedOrientation,
|
|
1160
1370
|
joinUrl,
|
|
1161
1371
|
embedOrigin: resolvedEmbedOrigin,
|
|
1162
1372
|
enabled,
|
|
1163
1373
|
maxControllers
|
|
1164
1374
|
});
|
|
1375
|
+
const [frames] = useState4(() => /* @__PURE__ */ new Map());
|
|
1376
|
+
const spawnSeatPhone = useCallback3(
|
|
1377
|
+
(options) => spawnPreviewController({
|
|
1378
|
+
...options,
|
|
1379
|
+
dock: dockRowRef.current?.getBoundingClientRect()
|
|
1380
|
+
}),
|
|
1381
|
+
[spawnPreviewController]
|
|
1382
|
+
);
|
|
1383
|
+
const localSeats = useWorkspaceLocalSeats({
|
|
1384
|
+
enabled: enabled && localPlayers,
|
|
1385
|
+
sessions,
|
|
1386
|
+
canSpawn,
|
|
1387
|
+
spawn: spawnSeatPhone,
|
|
1388
|
+
remove: removePreviewController,
|
|
1389
|
+
frames
|
|
1390
|
+
});
|
|
1391
|
+
useProvideLocalSeats(localPlayersGame ? null : localSeats);
|
|
1392
|
+
useServeLocalSeats(localPlayersGame, localSeats);
|
|
1165
1393
|
const platformSettings = useResolvedPlatformSettingsSnapshot();
|
|
1166
1394
|
const activeOpacity = platformSettings.previewControllers.activeOpacity;
|
|
1167
|
-
const sortedSessions =
|
|
1395
|
+
const sortedSessions = useMemo2(
|
|
1168
1396
|
() => [...sessions].sort((left, right) => left.ordinal - right.ordinal),
|
|
1169
1397
|
[sessions]
|
|
1170
1398
|
);
|
|
1171
|
-
|
|
1399
|
+
useEffect3(() => {
|
|
1172
1400
|
setMounted(true);
|
|
1173
1401
|
return () => setMounted(false);
|
|
1174
1402
|
}, []);
|
|
1175
|
-
|
|
1403
|
+
useEffect3(() => {
|
|
1176
1404
|
if (!launcherOpen || typeof document === "undefined") {
|
|
1177
1405
|
return;
|
|
1178
1406
|
}
|
|
@@ -1198,43 +1426,40 @@ var PreviewControllerWorkspace = ({
|
|
|
1198
1426
|
document.removeEventListener("keydown", handleKeyDown);
|
|
1199
1427
|
};
|
|
1200
1428
|
}, [launcherOpen]);
|
|
1201
|
-
const minimizedSessions =
|
|
1429
|
+
const minimizedSessions = useMemo2(
|
|
1202
1430
|
() => sessions.filter((session) => session.minimized).sort((left, right) => left.ordinal - right.ordinal),
|
|
1203
1431
|
[sessions]
|
|
1204
1432
|
);
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1207
|
-
[
|
|
1433
|
+
const launcherVisible = showLauncherWhenIdle || launcherOpen || sessions.length > 0;
|
|
1434
|
+
const sortedControllers = useMemo2(
|
|
1435
|
+
() => [...players].sort((left, right) => left.id.localeCompare(right.id)),
|
|
1436
|
+
[players]
|
|
1208
1437
|
);
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
);
|
|
1215
|
-
const controllerRoster = useMemo(() => {
|
|
1216
|
-
const sessionsByControllerId = new Map(
|
|
1217
|
-
sortedSessions.map((session) => [session.controllerId, session])
|
|
1438
|
+
const controllerRoster = useMemo2(() => {
|
|
1439
|
+
const sessionsBySeat = new Map(
|
|
1440
|
+
sortedSessions.flatMap(
|
|
1441
|
+
(session) => session.seat ? [[session.seat, session]] : []
|
|
1442
|
+
)
|
|
1218
1443
|
);
|
|
1219
1444
|
const controllerItems = sortedControllers.map((controller) => {
|
|
1220
|
-
const session =
|
|
1445
|
+
const session = sessionsBySeat.get(controller.id) ?? null;
|
|
1221
1446
|
return {
|
|
1222
|
-
id: controller.
|
|
1223
|
-
controllerId: controller.
|
|
1224
|
-
label: controller.
|
|
1225
|
-
source: controller.
|
|
1447
|
+
id: controller.id,
|
|
1448
|
+
controllerId: controller.id,
|
|
1449
|
+
label: controller.label,
|
|
1450
|
+
source: rosterSourceOf(controller.kind),
|
|
1226
1451
|
connected: controller.connected,
|
|
1227
|
-
resumable:
|
|
1452
|
+
resumable: !controller.connected,
|
|
1228
1453
|
session,
|
|
1229
1454
|
controller
|
|
1230
1455
|
};
|
|
1231
1456
|
});
|
|
1232
|
-
const
|
|
1233
|
-
sortedControllers.map((controller) => controller.
|
|
1457
|
+
const seatIds = new Set(
|
|
1458
|
+
sortedControllers.map((controller) => controller.id)
|
|
1234
1459
|
);
|
|
1235
|
-
const pendingPreviewItems = sortedSessions.filter((session) => !
|
|
1460
|
+
const pendingPreviewItems = sortedSessions.filter((session) => !session.seat || !seatIds.has(session.seat)).map((session) => ({
|
|
1236
1461
|
id: session.id,
|
|
1237
|
-
controllerId: session.
|
|
1462
|
+
controllerId: session.seat ?? session.id,
|
|
1238
1463
|
label: session.label,
|
|
1239
1464
|
source: "preview",
|
|
1240
1465
|
connected: session.surfaceState === "ready",
|
|
@@ -1264,10 +1489,15 @@ var PreviewControllerWorkspace = ({
|
|
|
1264
1489
|
className: "fixed inset-0",
|
|
1265
1490
|
style: { zIndex: PREVIEW_WORKSPACE_Z_INDEX, pointerEvents: "none" },
|
|
1266
1491
|
children: [
|
|
1267
|
-
|
|
1492
|
+
sessions.map((session) => /* @__PURE__ */ jsx2(
|
|
1268
1493
|
PreviewControllerWindow,
|
|
1269
1494
|
{
|
|
1495
|
+
fixedControllerOrientation: fixedOrientation,
|
|
1270
1496
|
session,
|
|
1497
|
+
frameRef: (frame) => {
|
|
1498
|
+
if (frame) frames.set(session.id, frame);
|
|
1499
|
+
else frames.delete(session.id);
|
|
1500
|
+
},
|
|
1271
1501
|
activeOpacity,
|
|
1272
1502
|
highContrast,
|
|
1273
1503
|
dragging: dragState?.id === session.id,
|
|
@@ -1399,31 +1629,35 @@ var PreviewControllerWorkspace = ({
|
|
|
1399
1629
|
/* @__PURE__ */ jsxs2(
|
|
1400
1630
|
"div",
|
|
1401
1631
|
{
|
|
1632
|
+
ref: dockRowRef,
|
|
1402
1633
|
className: "flex items-start justify-end gap-2",
|
|
1403
1634
|
style: { pointerEvents: "auto" },
|
|
1404
1635
|
children: [
|
|
1405
1636
|
dockAccessory,
|
|
1406
|
-
/* @__PURE__ */ jsxs2(
|
|
1637
|
+
launcherVisible ? /* @__PURE__ */ jsxs2(
|
|
1407
1638
|
Button,
|
|
1408
1639
|
{
|
|
1409
1640
|
type: "button",
|
|
1410
1641
|
variant: "ghost",
|
|
1411
|
-
size: "sm",
|
|
1642
|
+
size: launcherVariant === "compact" ? "icon-sm" : "sm",
|
|
1412
1643
|
className: cn(
|
|
1413
|
-
"rounded-full border border-white/25 bg-black/35
|
|
1644
|
+
"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",
|
|
1645
|
+
launcherVariant === "compact" ? "h-9 w-9 p-0" : "gap-2 px-3"
|
|
1414
1646
|
),
|
|
1415
1647
|
"aria-expanded": launcherOpen,
|
|
1416
|
-
"aria-label": launcherOpen ?
|
|
1648
|
+
"aria-label": launcherOpen ? `Hide ${launcherLabel.toLowerCase()}` : `Show ${launcherLabel.toLowerCase()}`,
|
|
1417
1649
|
title: !joinUrl ? waitingLabel : launcherLabel,
|
|
1418
1650
|
onClick: () => setLauncherOpen((current) => !current),
|
|
1419
1651
|
children: [
|
|
1420
1652
|
/* @__PURE__ */ jsx2(MonitorSmartphone2, { className: "h-4 w-4" }),
|
|
1421
|
-
/* @__PURE__ */
|
|
1422
|
-
|
|
1423
|
-
|
|
1653
|
+
launcherVariant === "full" ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1654
|
+
/* @__PURE__ */ jsx2("span", { className: "text-[11px] font-semibold tracking-[0.16em] uppercase", children: launcherLabel }),
|
|
1655
|
+
sessions.length > 0 ? /* @__PURE__ */ jsx2("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,
|
|
1656
|
+
launcherOpen ? /* @__PURE__ */ jsx2(ChevronUp, { className: "h-4 w-4 text-white/60" }) : /* @__PURE__ */ jsx2(ChevronDown, { className: "h-4 w-4 text-white/60" })
|
|
1657
|
+
] }) : sessions.length > 0 ? /* @__PURE__ */ jsx2("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
|
|
1424
1658
|
]
|
|
1425
1659
|
}
|
|
1426
|
-
)
|
|
1660
|
+
) : null
|
|
1427
1661
|
]
|
|
1428
1662
|
}
|
|
1429
1663
|
),
|
|
@@ -1536,21 +1770,21 @@ var PreviewControllerWorkspace = ({
|
|
|
1536
1770
|
variant: "ghost",
|
|
1537
1771
|
size: "sm",
|
|
1538
1772
|
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",
|
|
1539
|
-
disabled: removingControllerId === item.controller.
|
|
1773
|
+
disabled: removingControllerId === item.controller.id,
|
|
1540
1774
|
onClick: async () => {
|
|
1541
1775
|
if (!item.controller) {
|
|
1542
1776
|
return;
|
|
1543
1777
|
}
|
|
1544
1778
|
try {
|
|
1545
1779
|
setRemovingControllerId(
|
|
1546
|
-
item.controller.
|
|
1780
|
+
item.controller.id
|
|
1547
1781
|
);
|
|
1548
1782
|
await onRemoveController(
|
|
1549
|
-
item.controller.
|
|
1783
|
+
item.controller.id
|
|
1550
1784
|
);
|
|
1551
1785
|
} finally {
|
|
1552
1786
|
setRemovingControllerId(
|
|
1553
|
-
(current) => current === item.controller?.
|
|
1787
|
+
(current) => current === item.controller?.id ? null : current
|
|
1554
1788
|
);
|
|
1555
1789
|
}
|
|
1556
1790
|
},
|
|
@@ -1628,20 +1862,15 @@ var HostPreviewControllerWorkspace = ({
|
|
|
1628
1862
|
topology: config.topology
|
|
1629
1863
|
});
|
|
1630
1864
|
const joinUrl = host.joinUrlStatus === "ready" && host.joinUrl ? host.joinUrl : null;
|
|
1631
|
-
const handleResetRoom =
|
|
1632
|
-
|
|
1633
|
-
if (!ack.ok || typeof window === "undefined") {
|
|
1634
|
-
return ack;
|
|
1635
|
-
}
|
|
1636
|
-
window.location.reload();
|
|
1637
|
-
return ack;
|
|
1865
|
+
const handleResetRoom = () => {
|
|
1866
|
+
void host.resetRoom().then(() => window.location.reload());
|
|
1638
1867
|
};
|
|
1639
1868
|
return /* @__PURE__ */ jsx3(
|
|
1640
1869
|
PreviewControllerWorkspace,
|
|
1641
1870
|
{
|
|
1642
1871
|
enabled: resolvedEnabled,
|
|
1643
1872
|
joinUrl,
|
|
1644
|
-
|
|
1873
|
+
players: host.players,
|
|
1645
1874
|
onRemoveController: host.removeController,
|
|
1646
1875
|
onResetRoom: handleResetRoom,
|
|
1647
1876
|
onActiveOpacityChange: (activeOpacity) => platformSettingsOwner?.updatePreviewControllers({ activeOpacity }),
|
|
@@ -1651,21 +1880,26 @@ var HostPreviewControllerWorkspace = ({
|
|
|
1651
1880
|
);
|
|
1652
1881
|
};
|
|
1653
1882
|
export {
|
|
1654
|
-
|
|
1655
|
-
AIR_JAM_PREVIEW_FLAG_QUERY_PARAM,
|
|
1883
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM,
|
|
1656
1884
|
HostPreviewControllerWorkspace,
|
|
1657
1885
|
PreviewControllerWindow,
|
|
1658
1886
|
PreviewControllerWorkspace,
|
|
1659
1887
|
buildPreviewControllerUrl,
|
|
1660
|
-
createPreviewControllerIdentity,
|
|
1661
1888
|
createPreviewControllerLaunch,
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1889
|
+
getPreviewControllerViewportSize,
|
|
1890
|
+
getPreviewHostViewportSize,
|
|
1891
|
+
isLocalSeatReadyMessage,
|
|
1892
|
+
isLocalSeatRelayedMessage,
|
|
1893
|
+
isPreviewSeatMessage,
|
|
1894
|
+
localInputOperationSchema,
|
|
1895
|
+
localSeatMessages,
|
|
1896
|
+
localSeatQuerySchema,
|
|
1897
|
+
localSeatRelaySchema,
|
|
1898
|
+
localSeatRequestSchema,
|
|
1667
1899
|
readPreviewControllerDeviceIdFromSearchParams,
|
|
1668
|
-
|
|
1900
|
+
relayLocalSeatInput,
|
|
1901
|
+
requestPreviewControllerClose,
|
|
1902
|
+
sendLocalSeatOperation,
|
|
1669
1903
|
usePreviewControllerManager
|
|
1670
1904
|
};
|
|
1671
1905
|
//# sourceMappingURL=preview.js.map
|