@air-jam/sdk 0.9.3 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -205
- package/dist/actions-D4eh6Xaa.d.cts +72 -0
- package/dist/actions-D4eh6Xaa.d.ts +72 -0
- package/dist/{agent-contract-CD2QnbBJ.d.cts → agent-contract-DfLm4Mf-.d.ts} +3 -19
- package/dist/{agent-contract-CD2QnbBJ.d.ts → agent-contract-TINzp-5Y.d.cts} +3 -19
- package/dist/agent-tooling.cjs +135 -46
- package/dist/agent-tooling.cjs.map +1 -1
- package/dist/agent-tooling.d.cts +96 -5
- package/dist/agent-tooling.d.ts +96 -5
- package/dist/agent-tooling.js +15 -14
- package/dist/agent-tooling.js.map +1 -1
- package/dist/{use-air-jam-host-COLy8t4s.d.ts → air-jam-context-BCVCWiaT.d.ts} +121 -114
- package/dist/{use-air-jam-host-DM-ybB3C.d.cts → air-jam-context-DavligpM.d.cts} +121 -114
- package/dist/arcade/bridge/controller.cjs +873 -603
- package/dist/arcade/bridge/controller.cjs.map +1 -1
- package/dist/arcade/bridge/controller.d.cts +28 -76
- package/dist/arcade/bridge/controller.d.ts +28 -76
- package/dist/arcade/bridge/controller.js +27 -28
- package/dist/arcade/bridge/controller.js.map +1 -1
- package/dist/arcade/bridge/host.cjs +1017 -252
- package/dist/arcade/bridge/host.cjs.map +1 -1
- package/dist/arcade/bridge/host.d.cts +6 -72
- package/dist/arcade/bridge/host.d.ts +6 -72
- package/dist/arcade/bridge/host.js +19 -22
- package/dist/arcade/bridge/host.js.map +1 -1
- package/dist/arcade/bridge/iframe.cjs +3 -31
- package/dist/arcade/bridge/iframe.cjs.map +1 -1
- package/dist/arcade/bridge/iframe.d.cts +4 -46
- package/dist/arcade/bridge/iframe.d.ts +4 -46
- package/dist/arcade/bridge/iframe.js +6 -18
- package/dist/arcade/bridge/iframe.js.map +1 -1
- package/dist/arcade/host.cjs +0 -502
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.d.cts +1 -19
- package/dist/arcade/host.d.ts +1 -19
- package/dist/arcade/host.js +0 -14
- package/dist/arcade/host.js.map +1 -1
- package/dist/arcade/runtime.cjs +10354 -4690
- package/dist/arcade/runtime.cjs.map +1 -1
- package/dist/arcade/runtime.d.cts +45 -13
- package/dist/arcade/runtime.d.ts +45 -13
- package/dist/arcade/runtime.js +37 -24
- package/dist/arcade/runtime.js.map +1 -1
- package/dist/arcade/surface.cjs +3 -35
- package/dist/arcade/surface.cjs.map +1 -1
- package/dist/arcade/surface.d.cts +14 -2
- package/dist/arcade/surface.d.ts +14 -2
- package/dist/arcade/surface.js +7 -13
- package/dist/arcade/surface.js.map +1 -1
- package/dist/arcade/url.cjs +45 -283
- package/dist/arcade/url.cjs.map +1 -1
- package/dist/arcade/url.d.cts +3 -56
- package/dist/arcade/url.d.ts +3 -56
- package/dist/arcade/url.js +33 -16
- package/dist/arcade/url.js.map +1 -1
- package/dist/chunk-24NZZOIO.js +700 -0
- package/dist/chunk-24NZZOIO.js.map +1 -0
- package/dist/chunk-27QLKLZL.js +469 -0
- package/dist/chunk-27QLKLZL.js.map +1 -0
- package/dist/{chunk-UWJOIVON.js → chunk-2H2FGF3H.js} +3 -6
- package/dist/chunk-2H2FGF3H.js.map +1 -0
- package/dist/chunk-2QZADUGA.js +188 -0
- package/dist/chunk-2QZADUGA.js.map +1 -0
- package/dist/chunk-3LDQCQL2.js +307 -0
- package/dist/chunk-3LDQCQL2.js.map +1 -0
- package/dist/chunk-3M7656SU.js +389 -0
- package/dist/chunk-3M7656SU.js.map +1 -0
- package/dist/{chunk-K4OZ54UD.js → chunk-5CRZFIN6.js} +2 -55
- package/dist/chunk-5CRZFIN6.js.map +1 -0
- package/dist/chunk-5TVVPBQI.js +7 -0
- package/dist/chunk-5TVVPBQI.js.map +1 -0
- package/dist/chunk-6Y3F6Y2K.js +343 -0
- package/dist/chunk-6Y3F6Y2K.js.map +1 -0
- package/dist/{chunk-EVZJA6RN.js → chunk-6ZJUA63D.js} +183 -2
- package/dist/chunk-6ZJUA63D.js.map +1 -0
- package/dist/chunk-A6EOGRRG.js +49 -0
- package/dist/chunk-A6EOGRRG.js.map +1 -0
- package/dist/chunk-BEM77SVQ.js +57 -0
- package/dist/chunk-BEM77SVQ.js.map +1 -0
- package/dist/chunk-C5722GTG.js +176 -0
- package/dist/chunk-C5722GTG.js.map +1 -0
- package/dist/{chunk-CV3PBXPT.js → chunk-C5GS2GMK.js} +99 -105
- package/dist/chunk-C5GS2GMK.js.map +1 -0
- package/dist/chunk-CDL7LYZH.js +19 -0
- package/dist/chunk-CDL7LYZH.js.map +1 -0
- package/dist/{chunk-PSUYTD2L.js → chunk-DA3TE4OP.js} +1 -1
- package/dist/chunk-DA3TE4OP.js.map +1 -0
- package/dist/chunk-DBF7NJ3S.js +72 -0
- package/dist/chunk-DBF7NJ3S.js.map +1 -0
- package/dist/chunk-DHFKL3DI.js +2477 -0
- package/dist/chunk-DHFKL3DI.js.map +1 -0
- package/dist/chunk-DRBPVG47.js +89 -0
- package/dist/chunk-DRBPVG47.js.map +1 -0
- package/dist/{chunk-MIMPMB7O.js → chunk-EG25EXSA.js} +24 -3
- package/dist/chunk-EG25EXSA.js.map +1 -0
- package/dist/chunk-FCG42U7D.js +131 -0
- package/dist/chunk-FCG42U7D.js.map +1 -0
- package/dist/chunk-FJ4J2BEC.js +26 -0
- package/dist/chunk-FJ4J2BEC.js.map +1 -0
- package/dist/chunk-H4DEVMTO.js +221 -0
- package/dist/chunk-H4DEVMTO.js.map +1 -0
- package/dist/{chunk-X35LLCWV.js → chunk-I6TSHJF7.js} +6 -8
- package/dist/chunk-I6TSHJF7.js.map +1 -0
- package/dist/{chunk-IG6GZZSS.js → chunk-JCGTL77W.js} +1 -1
- package/dist/chunk-JCGTL77W.js.map +1 -0
- package/dist/chunk-JJVCBUYM.js +98 -0
- package/dist/chunk-JJVCBUYM.js.map +1 -0
- package/dist/chunk-K6BJJJJM.js +138 -0
- package/dist/chunk-K6BJJJJM.js.map +1 -0
- package/dist/chunk-KSYN4I5Y.js +50 -0
- package/dist/chunk-KSYN4I5Y.js.map +1 -0
- package/dist/chunk-KUGROY5S.js +265 -0
- package/dist/chunk-KUGROY5S.js.map +1 -0
- package/dist/chunk-LX6CTPDW.js +16 -0
- package/dist/chunk-LX6CTPDW.js.map +1 -0
- package/dist/{chunk-BE6Z4SIT.js → chunk-M5553I2G.js} +2 -11
- package/dist/chunk-M5553I2G.js.map +1 -0
- package/dist/{chunk-X24K52DG.js → chunk-MD25536W.js} +1 -1
- package/dist/chunk-MD25536W.js.map +1 -0
- package/dist/{chunk-3USU7GY2.js → chunk-MJAWAHLT.js} +1 -1
- package/dist/chunk-MJAWAHLT.js.map +1 -0
- package/dist/chunk-OAXCFPZ7.js +14 -0
- package/dist/chunk-OAXCFPZ7.js.map +1 -0
- package/dist/{chunk-D4VDEVTZ.js → chunk-QHBRHYMV.js} +18 -17
- package/dist/chunk-QHBRHYMV.js.map +1 -0
- package/dist/chunk-QTNYGAZ7.js +45 -0
- package/dist/chunk-QTNYGAZ7.js.map +1 -0
- package/dist/chunk-S3TN7Y7L.js +921 -0
- package/dist/chunk-S3TN7Y7L.js.map +1 -0
- package/dist/chunk-SMKD4JY3.js +129 -0
- package/dist/chunk-SMKD4JY3.js.map +1 -0
- package/dist/{chunk-O6X7FJ6N.js → chunk-TFW4NJW2.js} +619 -643
- package/dist/chunk-TFW4NJW2.js.map +1 -0
- package/dist/chunk-UBBP2UY3.js +83 -0
- package/dist/chunk-UBBP2UY3.js.map +1 -0
- package/dist/chunk-URVBMQCK.js +802 -0
- package/dist/chunk-URVBMQCK.js.map +1 -0
- package/dist/chunk-VGX2274F.js +1995 -0
- package/dist/chunk-VGX2274F.js.map +1 -0
- package/dist/chunk-WAFGYJZN.js +1513 -0
- package/dist/chunk-WAFGYJZN.js.map +1 -0
- package/dist/chunk-WGHNGQUS.js +78 -0
- package/dist/chunk-WGHNGQUS.js.map +1 -0
- package/dist/chunk-XLY44PXZ.js +46 -0
- package/dist/chunk-XLY44PXZ.js.map +1 -0
- package/dist/connection-store-BYpQ50W2.d.ts +41 -0
- package/dist/connection-store-D6QqzXU1.d.cts +41 -0
- package/dist/control-Bv8dWjyp.d.ts +1400 -0
- package/dist/control-CNzybWMd.d.cts +1400 -0
- package/dist/controller-0CVO1t_3.d.cts +26 -0
- package/dist/controller-agent-vOiuK7T6.d.cts +130 -0
- package/dist/controller-agent-vOiuK7T6.d.ts +130 -0
- package/dist/controller-bridge.cjs +992 -0
- package/dist/controller-bridge.cjs.map +1 -0
- package/dist/controller-bridge.d.cts +52 -0
- package/dist/controller-bridge.d.ts +52 -0
- package/dist/controller-bridge.js +23 -0
- package/dist/controller-bridge.js.map +1 -0
- package/dist/controller-capture-2GKKGHJ2.js +8 -0
- package/dist/controller-capture-2GKKGHJ2.js.map +1 -0
- package/dist/controller-h9M2Nngd.d.ts +26 -0
- package/dist/controller-press-EWWIMVXP.js +231 -0
- package/dist/controller-press-EWWIMVXP.js.map +1 -0
- package/dist/core-BAO0pHrJ.d.cts +15 -0
- package/dist/core-BAO0pHrJ.d.ts +15 -0
- package/dist/core.cjs +5931 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +232 -0
- package/dist/core.d.ts +232 -0
- package/dist/core.js +906 -0
- package/dist/core.js.map +1 -0
- package/dist/dev-events-BffobOfb.d.ts +31 -0
- package/dist/dev-events-Ct7QEgKb.d.cts +31 -0
- package/dist/dev-log-events-B1_B3guZ.d.cts +47 -0
- package/dist/dev-log-events-B1_B3guZ.d.ts +47 -0
- package/dist/frames-D-xKuODS.d.cts +686 -0
- package/dist/frames-D-xKuODS.d.ts +686 -0
- package/dist/game-Db58JNk3.d.cts +77 -0
- package/dist/game-bySEy-QO.d.ts +77 -0
- package/dist/host-runtime-BuLhGQx5.d.ts +399 -0
- package/dist/host-runtime-_06jpW5v.d.cts +399 -0
- package/dist/index.cjs +11580 -7584
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -358
- package/dist/index.d.ts +100 -358
- package/dist/index.js +414 -1903
- package/dist/index.js.map +1 -1
- package/dist/input-Xvs80gqG.d.cts +92 -0
- package/dist/input-Xvs80gqG.d.ts +92 -0
- package/dist/input-bindings-BaEFrgRb.d.cts +129 -0
- package/dist/input-bindings-BgsJRLPm.d.ts +129 -0
- package/dist/leased-control-BEg4JuXA.d.cts +158 -0
- package/dist/leased-control-BEg4JuXA.d.ts +158 -0
- package/dist/metadata.cjs +3 -9
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +6 -16
- package/dist/metadata.d.ts +6 -16
- package/dist/metadata.js +8 -76
- package/dist/metadata.js.map +1 -1
- package/dist/phone-room-session-Ca6rlxJr.d.ts +439 -0
- package/dist/phone-room-session-DkPR-K6e.d.cts +439 -0
- package/dist/platform-machine.cjs +133 -3
- package/dist/platform-machine.cjs.map +1 -1
- package/dist/platform-machine.d.cts +525 -27
- package/dist/platform-machine.d.ts +525 -27
- package/dist/platform-machine.js +119 -4
- package/dist/platform-machine.js.map +1 -1
- package/dist/{platform-settings-DUWs4JTy.d.cts → platform-settings-Yb0fQ1dl.d.cts} +1 -3
- package/dist/{platform-settings-DUWs4JTy.d.ts → platform-settings-Yb0fQ1dl.d.ts} +1 -3
- package/dist/prefabs.cjs +134 -3
- package/dist/prefabs.cjs.map +1 -1
- package/dist/prefabs.d.cts +23 -47
- package/dist/prefabs.d.ts +23 -47
- package/dist/prefabs.js +23 -4
- package/dist/prefabs.js.map +1 -1
- package/dist/preview.cjs +2214 -767
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +193 -38
- package/dist/preview.d.ts +193 -38
- package/dist/preview.js +478 -254
- package/dist/preview.js.map +1 -1
- package/dist/protocol.cjs +585 -391
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +13 -117
- package/dist/protocol.d.ts +13 -117
- package/dist/protocol.js +43 -80
- package/dist/protocol.js.map +1 -1
- package/dist/release.cjs.map +1 -1
- package/dist/release.d.cts +2 -2
- package/dist/release.d.ts +2 -2
- package/dist/release.js +1 -1
- package/dist/release.js.map +1 -1
- package/dist/replay-input-log-BvX4As2f.d.ts +31 -0
- package/dist/replay-input-log-Vcl0VDIy.d.cts +31 -0
- package/dist/room-protocol.cjs +794 -0
- package/dist/room-protocol.cjs.map +1 -0
- package/dist/room-protocol.d.cts +63 -0
- package/dist/room-protocol.d.ts +63 -0
- package/dist/room-protocol.js +143 -0
- package/dist/room-protocol.js.map +1 -0
- package/dist/room-session.cjs +2336 -0
- package/dist/room-session.cjs.map +1 -0
- package/dist/room-session.d.cts +77 -0
- package/dist/room-session.d.ts +77 -0
- package/dist/room-session.js +103 -0
- package/dist/room-session.js.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.cjs +207 -0
- package/dist/runtime/prefab-inspection-bridge.cjs.map +1 -0
- package/dist/runtime/prefab-inspection-bridge.d.cts +156 -0
- package/dist/runtime/prefab-inspection-bridge.d.ts +156 -0
- package/dist/runtime/prefab-inspection-bridge.js +22 -0
- package/dist/runtime/prefab-inspection-bridge.js.map +1 -0
- package/dist/runtime-control.cjs +2112 -8
- package/dist/runtime-control.cjs.map +1 -1
- package/dist/runtime-control.d.cts +980 -12
- package/dist/runtime-control.d.ts +980 -12
- package/dist/runtime-control.js +264 -4
- package/dist/runtime-control.js.map +1 -1
- package/dist/runtime-inspection.cjs +1222 -558
- package/dist/runtime-inspection.cjs.map +1 -1
- package/dist/runtime-inspection.d.cts +530 -22
- package/dist/runtime-inspection.d.ts +530 -22
- package/dist/runtime-inspection.js +21 -22
- package/dist/runtime-inspection.js.map +1 -1
- package/dist/runtime-reporting-K_ZXpubu.d.cts +43 -0
- package/dist/runtime-reporting-K_ZXpubu.d.ts +43 -0
- package/dist/runtime-topology.cjs +2 -5
- package/dist/runtime-topology.cjs.map +1 -1
- package/dist/runtime-topology.d.cts +1 -1
- package/dist/runtime-topology.d.ts +1 -1
- package/dist/runtime-topology.js +1 -1
- package/dist/runtime-topology.js.map +1 -1
- package/dist/scoped-connector-CiiWu06D.d.ts +66 -0
- package/dist/scoped-connector-D7252pn0.d.cts +66 -0
- package/dist/sdk-channels-S6j6AH8v.d.cts +103 -0
- package/dist/sdk-channels-S6j6AH8v.d.ts +103 -0
- package/dist/simulation-BfRnC4rg.d.ts +782 -0
- package/dist/simulation-BwZx2pgt.d.cts +782 -0
- package/dist/{standard-match-phase-BzSgBYFg.d.ts → standard-match-phase-D4N-AU0d.d.cts} +3 -13
- package/dist/{standard-match-phase-CvJUW8Oe.d.cts → standard-match-phase-abt8ZjCh.d.ts} +3 -13
- package/dist/transport-CWF29jU6.d.cts +173 -0
- package/dist/transport-CWF29jU6.d.ts +173 -0
- package/dist/types-p28maMEo.d.cts +102 -0
- package/dist/types-p28maMEo.d.ts +102 -0
- package/dist/ui.cjs +2182 -892
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +75 -17
- package/dist/ui.d.ts +75 -17
- package/dist/ui.js +554 -393
- package/dist/ui.js.map +1 -1
- package/package.json +38 -21
- package/src/agent/agent-action.ts +0 -39
- package/src/agent/agent-contract-conformance.ts +8 -1
- package/src/agent/agent-contract.ts +2 -4
- package/src/agent/agent-evaluator.ts +95 -0
- package/src/agent/capture-canvas.ts +79 -0
- package/src/agent/host-canvas-capture.ts +189 -0
- package/src/agent-tooling.ts +5 -20
- package/src/arcade/bridge/controller.ts +8 -11
- package/src/arcade/bridge/host.ts +6 -11
- package/src/arcade/bridge/iframe.ts +1 -50
- package/src/arcade/host.ts +0 -1
- package/src/arcade/surface.ts +5 -1
- package/src/arcade/url.ts +2 -9
- package/src/audio/audio-manager.ts +23 -47
- package/src/audio/hooks.tsx +59 -72
- package/src/components/controller-player-name-field.tsx +2 -2
- package/src/components/controller-primary-action.tsx +1 -1
- package/src/components/controls.tsx +398 -0
- package/src/components/gamepad-layout.tsx +69 -0
- package/src/components/join-url-controls.tsx +5 -1
- package/src/components/lifecycle-action-group.tsx +1 -1
- package/src/components/player-avatar.tsx +50 -3
- package/src/components/room-qr-code.tsx +36 -77
- package/src/components/stage-capture-surface.tsx +91 -0
- package/src/components/surface-viewport.tsx +16 -3
- package/src/components/ui/button.tsx +1 -1
- package/src/constants.ts +0 -15
- package/src/context/air-jam-context.tsx +56 -187
- package/src/context/session-providers.tsx +13 -10
- package/src/controller-bridge.ts +7 -0
- package/src/core/assets.ts +48 -0
- package/src/core/config.ts +70 -0
- package/src/core/connection-store.ts +77 -0
- package/src/core/controller-input.ts +147 -0
- package/src/core/controller-runtime.ts +427 -0
- package/src/core/dev-events.ts +18 -0
- package/src/core/environment.ts +132 -0
- package/src/core/game-description.ts +44 -0
- package/src/core/game.ts +130 -0
- package/src/core/host-input.ts +207 -0
- package/src/core/host-runtime.ts +988 -0
- package/src/core/hosted-rooms.ts +26 -0
- package/src/core/input-bindings.ts +180 -0
- package/src/core/input-log.ts +144 -0
- package/src/core/input.ts +228 -0
- package/src/core/local-input.ts +319 -0
- package/src/core/replay-input-log.ts +298 -0
- package/src/core/replicated-store.ts +1178 -0
- package/src/core/room-action-ack.ts +43 -0
- package/src/core/settings.ts +202 -0
- package/src/core/simulation.ts +307 -0
- package/src/core/theme.ts +33 -0
- package/src/core.ts +162 -0
- package/src/dev/browser-log-sink.ts +35 -12
- package/src/diagnostics.ts +5 -6
- package/src/hooks/internal/use-controller-runtime-api.ts +58 -925
- package/src/hooks/internal/use-host-runtime-api.ts +98 -1270
- package/src/hooks/internal/use-runtime-inspection-contract.ts +14 -2
- package/src/hooks/use-air-jam-controller.ts +32 -53
- package/src/hooks/use-air-jam-host.ts +59 -100
- package/src/hooks/use-air-jam-settings.ts +27 -0
- package/src/hooks/use-controller-toasts.ts +16 -19
- package/src/hooks/use-host-agent-capture.ts +31 -0
- package/src/hooks/use-lifecycle-action-group-model.ts +1 -1
- package/src/hooks/use-send-signal.ts +23 -156
- package/src/hooks/use-simulation.ts +83 -0
- package/src/index.ts +24 -85
- package/src/lifecycle/index.ts +0 -4
- package/src/lifecycle/standard-match-phase.ts +1 -22
- package/src/metadata/manifest.ts +8 -19
- package/src/metadata.ts +1 -1
- package/src/platform-machine.ts +127 -3
- package/src/prefabs/types.ts +91 -20
- package/src/prefabs/view.ts +82 -0
- package/src/prefabs.ts +19 -0
- package/src/preview/host-workspace.tsx +4 -9
- package/src/preview/identity.ts +31 -23
- package/src/preview/layout.ts +5 -1
- package/src/preview/manager.ts +205 -78
- package/src/preview/messages.ts +47 -0
- package/src/preview/ownership.ts +6 -1
- package/src/preview/url.ts +46 -23
- package/src/preview/window.tsx +26 -69
- package/src/preview/workspace-local-seats.ts +166 -0
- package/src/preview/workspace.tsx +89 -37
- package/src/preview.ts +27 -15
- package/src/protocol/actions.ts +58 -0
- package/src/protocol/arcade-platform-actions.ts +2 -16
- package/src/protocol/controller.ts +14 -174
- package/src/protocol/core.ts +8 -15
- package/src/protocol/dev-log-events.ts +5 -81
- package/src/protocol/leased-control.ts +177 -0
- package/src/protocol/room/addressing.ts +35 -0
- package/src/protocol/room/close-codes.ts +33 -0
- package/src/protocol/room/frames.ts +343 -0
- package/src/protocol/room/input-codec.ts +182 -0
- package/src/protocol/room/limits.ts +58 -0
- package/src/protocol/room/patch.ts +135 -0
- package/src/protocol/room/sdk-channels.ts +81 -0
- package/src/protocol/room/seat-id.ts +31 -0
- package/src/protocol/room/transport.ts +63 -0
- package/src/protocol/room/weight.ts +58 -0
- package/src/protocol/runtime-reporting.ts +56 -10
- package/src/protocol.ts +2 -7
- package/src/qrcode.d.ts +3 -13
- package/src/room-protocol.ts +10 -0
- package/src/room-session/browser-wake-events.ts +14 -0
- package/src/room-session/channel-state.ts +293 -0
- package/src/room-session/clock.ts +24 -0
- package/src/room-session/host-room-session.ts +379 -0
- package/src/room-session/input-lane.ts +125 -0
- package/src/room-session/listeners.ts +22 -0
- package/src/room-session/loopback-link.ts +58 -0
- package/src/room-session/phone-room-session.ts +368 -0
- package/src/room-session/port-link.ts +116 -0
- package/src/room-session/room-key.ts +9 -0
- package/src/room-session/roster.ts +23 -0
- package/src/room-session/scoped-connector.ts +577 -0
- package/src/room-session/session-link.ts +306 -0
- package/src/room-session/web-socket-link.ts +57 -0
- package/src/room-session.ts +12 -0
- package/src/runtime/air-jam-config.ts +49 -37
- package/src/runtime/air-jam-error-boundary.tsx +9 -3
- package/src/runtime/arcade-runtime-url.ts +8 -9
- package/src/runtime/browser-controller-environment.ts +116 -0
- package/src/runtime/browser-host-environment.ts +137 -0
- package/src/runtime/browser-replay.ts +211 -0
- package/src/runtime/browser-room.ts +41 -0
- package/src/runtime/connected-runtime-error-boundary.tsx +35 -8
- package/src/runtime/contracts/agent-control.ts +195 -0
- package/src/runtime/contracts/clip.ts +169 -0
- package/src/runtime/contracts/control.ts +653 -16
- package/src/runtime/contracts/controller-agent.ts +130 -0
- package/src/runtime/contracts/input-log.ts +38 -0
- package/src/runtime/contracts/inspection.ts +25 -22
- package/src/runtime/contracts/observation.ts +186 -0
- package/src/runtime/contracts/runtime-identity.ts +43 -0
- package/src/runtime/contracts/timeline.ts +59 -0
- package/src/runtime/controller-agent-bridge.ts +152 -0
- package/src/runtime/controller-bridge-context.ts +29 -0
- package/src/runtime/controller-capture.ts +50 -0
- package/src/runtime/controller-identity.ts +53 -142
- package/src/runtime/controller-presentation.ts +47 -17
- package/src/runtime/controller-press.ts +271 -0
- package/src/runtime/create-air-jam-app.tsx +103 -74
- package/src/runtime/dev-runtime-events.ts +6 -18
- package/src/runtime/embedded-parent.ts +22 -0
- package/src/runtime/embedded-runtime-adapters.ts +10 -9
- package/src/runtime/host-agent-bridge.ts +127 -0
- package/src/runtime/host-capture-boundary.tsx +92 -0
- package/src/runtime/host-capture-context.ts +7 -0
- package/src/runtime/host-clip-reader.ts +93 -0
- package/src/runtime/host-clip-recorder.ts +342 -0
- package/src/runtime/host-input-log-reader.ts +120 -0
- package/src/runtime/host-observation.ts +207 -0
- package/src/runtime/host-pace.ts +36 -0
- package/src/runtime/host-runtime-fault.ts +51 -0
- package/src/runtime/host-timeline.ts +152 -0
- package/src/runtime/local-players.tsx +96 -0
- package/src/runtime/local-seats.ts +612 -0
- package/src/runtime/participant-control.ts +162 -0
- package/src/runtime/prefab-inspection-bridge.ts +174 -0
- package/src/runtime/prefab-inspection-clock.ts +12 -0
- package/src/runtime/prefab-inspection-context.ts +20 -0
- package/src/runtime/prefab-inspection-runtime.tsx +328 -0
- package/src/runtime/preview-inspection-bridge.ts +130 -0
- package/src/runtime/replay-runtime.tsx +101 -0
- package/src/runtime/room-bridge.ts +110 -0
- package/src/runtime/runtime-owner-contexts.tsx +9 -0
- package/src/runtime/runtime-session-params.ts +20 -23
- package/src/runtime/session-runtimes.tsx +231 -64
- package/src/runtime/stage-capture.ts +25 -0
- package/src/runtime-control.ts +41 -0
- package/src/runtime-inspection.ts +14 -7
- package/src/runtime-topology.ts +7 -8
- package/src/settings/platform-settings-runtime.tsx +47 -2
- package/src/settings/platform-settings.ts +0 -65
- package/src/store/use-air-jam-store.ts +73 -0
- package/src/ui.ts +3 -3
- package/src/utils/is-rpc-serializable.ts +11 -19
- package/src/utils/url-builder.ts +0 -7
- package/dist/air-jam-context-BlLPvCup.d.cts +0 -175
- package/dist/air-jam-context-DTsxF-tP.d.ts +0 -175
- package/dist/arcade/bridge.cjs +0 -1087
- package/dist/arcade/bridge.cjs.map +0 -1
- package/dist/arcade/bridge.d.cts +0 -11
- package/dist/arcade/bridge.d.ts +0 -11
- package/dist/arcade/bridge.js +0 -78
- package/dist/arcade/bridge.js.map +0 -1
- package/dist/arcade-runtime-url-BW-MUAOY.d.cts +0 -28
- package/dist/arcade-runtime-url-l8qj01Pg.d.ts +0 -28
- package/dist/arcade.cjs +0 -1767
- package/dist/arcade.cjs.map +0 -1
- package/dist/arcade.d.cts +0 -18
- package/dist/arcade.d.ts +0 -18
- package/dist/arcade.js +0 -129
- package/dist/arcade.js.map +0 -1
- package/dist/chunk-2SZ2YYGJ.js +0 -280
- package/dist/chunk-2SZ2YYGJ.js.map +0 -1
- package/dist/chunk-32RSSFSF.js +0 -214
- package/dist/chunk-32RSSFSF.js.map +0 -1
- package/dist/chunk-3USU7GY2.js.map +0 -1
- package/dist/chunk-3YMUAKPU.js +0 -10
- package/dist/chunk-3YMUAKPU.js.map +0 -1
- package/dist/chunk-56DM2KEW.js +0 -14
- package/dist/chunk-56DM2KEW.js.map +0 -1
- package/dist/chunk-BE6Z4SIT.js.map +0 -1
- package/dist/chunk-CM53YLT5.js +0 -59
- package/dist/chunk-CM53YLT5.js.map +0 -1
- package/dist/chunk-CV3PBXPT.js.map +0 -1
- package/dist/chunk-D4VDEVTZ.js.map +0 -1
- package/dist/chunk-EVZJA6RN.js.map +0 -1
- package/dist/chunk-FUA6EMSJ.js +0 -90
- package/dist/chunk-FUA6EMSJ.js.map +0 -1
- package/dist/chunk-GMLU7RI5.js +0 -70
- package/dist/chunk-GMLU7RI5.js.map +0 -1
- package/dist/chunk-IG6GZZSS.js.map +0 -1
- package/dist/chunk-IKKDONQL.js +0 -1
- package/dist/chunk-IKKDONQL.js.map +0 -1
- package/dist/chunk-ITMQSBTH.js +0 -26
- package/dist/chunk-ITMQSBTH.js.map +0 -1
- package/dist/chunk-J5MCII33.js +0 -620
- package/dist/chunk-J5MCII33.js.map +0 -1
- package/dist/chunk-JTF47B56.js +0 -1
- package/dist/chunk-JTF47B56.js.map +0 -1
- package/dist/chunk-K4OZ54UD.js.map +0 -1
- package/dist/chunk-LIHEEAVE.js +0 -191
- package/dist/chunk-LIHEEAVE.js.map +0 -1
- package/dist/chunk-LIXPF4P6.js +0 -22
- package/dist/chunk-LIXPF4P6.js.map +0 -1
- package/dist/chunk-MIMPMB7O.js.map +0 -1
- package/dist/chunk-MPDMJIX5.js +0 -1
- package/dist/chunk-MPDMJIX5.js.map +0 -1
- package/dist/chunk-O6X7FJ6N.js.map +0 -1
- package/dist/chunk-PSUYTD2L.js.map +0 -1
- package/dist/chunk-QO4KFUEI.js +0 -32
- package/dist/chunk-QO4KFUEI.js.map +0 -1
- package/dist/chunk-QTLYZADF.js +0 -125
- package/dist/chunk-QTLYZADF.js.map +0 -1
- package/dist/chunk-TGRTEWYV.js +0 -195
- package/dist/chunk-TGRTEWYV.js.map +0 -1
- package/dist/chunk-TTQDHKXL.js +0 -3017
- package/dist/chunk-TTQDHKXL.js.map +0 -1
- package/dist/chunk-UCPY7UJC.js +0 -8
- package/dist/chunk-UCPY7UJC.js.map +0 -1
- package/dist/chunk-UPV6YWT5.js +0 -43
- package/dist/chunk-UPV6YWT5.js.map +0 -1
- package/dist/chunk-UWJOIVON.js.map +0 -1
- package/dist/chunk-W2VK36RO.js +0 -11
- package/dist/chunk-W2VK36RO.js.map +0 -1
- package/dist/chunk-X24K52DG.js.map +0 -1
- package/dist/chunk-X35LLCWV.js.map +0 -1
- package/dist/chunk-YXHH3MQT.js +0 -230
- package/dist/chunk-YXHH3MQT.js.map +0 -1
- package/dist/controller-PZEM_1cH.d.ts +0 -176
- package/dist/controller-vj82tKm4.d.cts +0 -176
- package/dist/dev-log-events-BCJKmygo.d.cts +0 -120
- package/dist/dev-log-events-BCJKmygo.d.ts +0 -120
- package/dist/handshake-CC_LrK5g.d.cts +0 -31
- package/dist/handshake-CC_LrK5g.d.ts +0 -31
- package/dist/host-B9pRy0Aa.d.cts +0 -122
- package/dist/host-DylGsX7p.d.ts +0 -122
- package/dist/notices-C4bao3oi.d.ts +0 -38
- package/dist/notices-DNdOjwtj.d.cts +0 -38
- package/dist/realtime-client-Cu8yVJFw.d.cts +0 -15
- package/dist/realtime-client-Cu8yVJFw.d.ts +0 -15
- package/dist/runtime-reporting-pe-eryVz.d.cts +0 -27
- package/dist/runtime-reporting-pe-eryVz.d.ts +0 -27
- package/dist/signals-ZHftIKuc.d.cts +0 -33
- package/dist/signals-ZHftIKuc.d.ts +0 -33
- package/dist/sync-xtPfWhif.d.cts +0 -81
- package/dist/sync-xtPfWhif.d.ts +0 -81
- package/src/arcade/bridge.ts +0 -3
- package/src/arcade.ts +0 -4
- package/src/context/socket-manager.ts +0 -72
- package/src/events.ts +0 -119
- package/src/hooks/use-connection-status.ts +0 -8
- package/src/hooks/use-controller-tick.ts +0 -65
- package/src/hooks/use-get-input.ts +0 -100
- package/src/hooks/use-host-arcade-restore.ts +0 -35
- package/src/hooks/use-host-tick.ts +0 -171
- package/src/hooks/use-input-writer.ts +0 -83
- package/src/hooks/use-players.ts +0 -12
- package/src/internal/input-manager.ts +0 -356
- package/src/protocol/errors.ts +0 -21
- package/src/protocol/host-grant.ts +0 -103
- package/src/protocol/host.ts +0 -150
- package/src/protocol/notices.ts +0 -43
- package/src/protocol/signals.ts +0 -38
- package/src/protocol/socket-events.ts +0 -152
- package/src/protocol/sync.ts +0 -105
- package/src/runtime/admission-retry.ts +0 -62
- package/src/runtime/bridge-envelope-args.ts +0 -21
- package/src/runtime/controller-bridge.ts +0 -439
- package/src/runtime/controller-realtime-client.ts +0 -552
- package/src/runtime/host-bridge.ts +0 -380
- package/src/runtime/host-realtime-client.ts +0 -550
- package/src/runtime/realtime-client.ts +0 -20
- package/src/runtime/validate-arcade-bridge-attach.ts +0 -14
- package/src/state/connection-store.ts +0 -159
- package/src/store/create-air-jam-store.ts +0 -1193
- package/src/store/index.ts +0 -1
- package/src/utils/ids.ts +0 -58
package/dist/preview.js
CHANGED
|
@@ -1,51 +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
|
-
isPreviewControllerSearchParams,
|
|
16
|
-
normalizePreviewDeviceId,
|
|
17
|
-
readPreviewControllerDeviceIdFromLocation,
|
|
32
|
+
AIR_JAM_PREVIEW_PARENT_QUERY_PARAM,
|
|
33
|
+
createPreviewControllerDeviceId,
|
|
18
34
|
readPreviewControllerDeviceIdFromSearchParams
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import {
|
|
21
|
-
useAirJamHost
|
|
22
|
-
} from "./chunk-CM53YLT5.js";
|
|
35
|
+
} from "./chunk-BEM77SVQ.js";
|
|
23
36
|
import {
|
|
37
|
+
fixedControllerOrientationContext,
|
|
38
|
+
useAirJamConfig,
|
|
24
39
|
useOptionalPlatformSettingsOwnerApi,
|
|
25
40
|
useResolvedPlatformSettingsSnapshot
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import "./chunk-
|
|
41
|
+
} from "./chunk-TFW4NJW2.js";
|
|
42
|
+
import "./chunk-QHBRHYMV.js";
|
|
28
43
|
import {
|
|
29
44
|
parseOptionalArcadeSurfaceFromSearchParams
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
import "./chunk-
|
|
37
|
-
import
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-J5MCII33.js";
|
|
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";
|
|
42
56
|
import {
|
|
43
57
|
appendRuntimeQueryParams,
|
|
44
58
|
getRuntimeUrlOrigin,
|
|
45
59
|
normalizeRuntimeUrl
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
import "./chunk-
|
|
48
|
-
import "./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";
|
|
66
|
+
import {
|
|
67
|
+
isLocalDevControlSurfaceRuntimeMode
|
|
68
|
+
} from "./chunk-2H2FGF3H.js";
|
|
69
|
+
import "./chunk-C5722GTG.js";
|
|
70
|
+
import "./chunk-5CRZFIN6.js";
|
|
71
|
+
import "./chunk-24NZZOIO.js";
|
|
49
72
|
|
|
50
73
|
// src/preview/ownership.ts
|
|
51
74
|
var readDevelopmentRuntime = () => {
|
|
@@ -76,6 +99,7 @@ var isEmbeddedArcadeRuntimeSearchParams = (searchParams) => parseOptionalArcadeS
|
|
|
76
99
|
var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
77
100
|
enabled = "auto",
|
|
78
101
|
topology,
|
|
102
|
+
isEmbeddedRuntime = typeof window !== "undefined" && window.parent !== window,
|
|
79
103
|
isDevelopmentRuntime = readDevelopmentRuntime(),
|
|
80
104
|
searchParams
|
|
81
105
|
} = {}) => {
|
|
@@ -83,7 +107,7 @@ var resolveHostPreviewControllerWorkspaceEnabled = ({
|
|
|
83
107
|
return enabled;
|
|
84
108
|
}
|
|
85
109
|
const localDevControlSurfacesEnabled = topology != null ? isLocalDevControlSurfaceRuntimeMode(topology.runtimeMode) : isDevelopmentRuntime;
|
|
86
|
-
return localDevControlSurfacesEnabled && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
110
|
+
return localDevControlSurfacesEnabled && !topology?.embedded && !isEmbeddedRuntime && !isEmbeddedArcadeRuntimeSearchParams(searchParams);
|
|
87
111
|
};
|
|
88
112
|
|
|
89
113
|
// src/preview/workspace.tsx
|
|
@@ -96,10 +120,18 @@ import {
|
|
|
96
120
|
Smartphone,
|
|
97
121
|
X as X2
|
|
98
122
|
} from "lucide-react";
|
|
99
|
-
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";
|
|
100
131
|
import { createPortal } from "react-dom";
|
|
101
132
|
|
|
102
133
|
// src/preview/layout.ts
|
|
134
|
+
var getPreviewHostViewportSize = () => SURFACE_VIEWPORT_REFERENCE_SIZES.host.landscape;
|
|
103
135
|
var PREVIEW_WORKSPACE_Z_INDEX = 2147483e3;
|
|
104
136
|
var PREVIEW_WINDOW_TITLEBAR_HEIGHT = 38;
|
|
105
137
|
var PREVIEW_WINDOW_RESIZE_EDGE_HIT_SIZE = 12;
|
|
@@ -238,10 +270,12 @@ var normalizeAllowedOrigins = (allowedOrigins) => {
|
|
|
238
270
|
};
|
|
239
271
|
var buildPreviewControllerUrl = ({
|
|
240
272
|
joinUrl,
|
|
241
|
-
controllerId,
|
|
242
273
|
previewDeviceId,
|
|
243
274
|
allowedOrigins,
|
|
244
|
-
embedOrigin
|
|
275
|
+
embedOrigin,
|
|
276
|
+
parentOrigin,
|
|
277
|
+
localSeat,
|
|
278
|
+
capture
|
|
245
279
|
}) => {
|
|
246
280
|
const normalizedJoinUrl = normalizeRuntimeUrl(joinUrl);
|
|
247
281
|
if (!normalizedJoinUrl) {
|
|
@@ -260,41 +294,49 @@ var buildPreviewControllerUrl = ({
|
|
|
260
294
|
if (!normalizedEmbedOrigin) {
|
|
261
295
|
return null;
|
|
262
296
|
}
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
297
|
+
const { pathname, search, hash } = new URL(normalizedJoinUrl);
|
|
298
|
+
return new URL(
|
|
299
|
+
`${pathname}${search}${hash}`,
|
|
300
|
+
normalizedEmbedOrigin
|
|
301
|
+
).toString();
|
|
268
302
|
})();
|
|
269
303
|
if (!previewBaseUrl) {
|
|
270
304
|
return null;
|
|
271
305
|
}
|
|
306
|
+
const normalizedParentOrigin = parentOrigin ? getRuntimeUrlOrigin(parentOrigin) : null;
|
|
307
|
+
if (parentOrigin && !normalizedParentOrigin) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
272
310
|
return appendRuntimeQueryParams(previewBaseUrl, {
|
|
273
|
-
controllerId,
|
|
274
311
|
[AIR_JAM_PREVIEW_FLAG_QUERY_PARAM]: "1",
|
|
275
|
-
[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
|
|
276
316
|
});
|
|
277
317
|
};
|
|
278
318
|
var createPreviewControllerLaunch = ({
|
|
279
319
|
joinUrl,
|
|
280
320
|
allowedOrigins,
|
|
281
|
-
embedOrigin
|
|
321
|
+
embedOrigin,
|
|
322
|
+
parentOrigin,
|
|
323
|
+
localSeat,
|
|
324
|
+
capture
|
|
282
325
|
}) => {
|
|
283
|
-
const
|
|
326
|
+
const deviceId = createPreviewControllerDeviceId();
|
|
284
327
|
const url = buildPreviewControllerUrl({
|
|
285
328
|
joinUrl,
|
|
286
|
-
|
|
287
|
-
previewDeviceId: identity.deviceId,
|
|
329
|
+
previewDeviceId: deviceId,
|
|
288
330
|
allowedOrigins,
|
|
289
|
-
embedOrigin
|
|
331
|
+
embedOrigin,
|
|
332
|
+
parentOrigin,
|
|
333
|
+
localSeat,
|
|
334
|
+
capture
|
|
290
335
|
});
|
|
291
336
|
if (!url) {
|
|
292
337
|
return null;
|
|
293
338
|
}
|
|
294
|
-
return {
|
|
295
|
-
...identity,
|
|
296
|
-
url
|
|
297
|
-
};
|
|
339
|
+
return { deviceId, url };
|
|
298
340
|
};
|
|
299
341
|
|
|
300
342
|
// src/preview/manager.ts
|
|
@@ -302,6 +344,7 @@ var DEFAULT_VIEWPORT_WIDTH = 1440;
|
|
|
302
344
|
var DEFAULT_VIEWPORT_HEIGHT = 900;
|
|
303
345
|
var PREVIEW_WINDOW_MARGIN = 24;
|
|
304
346
|
var PREVIEW_WINDOW_CASCADE_OFFSET = 28;
|
|
347
|
+
var PREVIEW_WINDOW_DOCK_GAP = 12;
|
|
305
348
|
var DEFAULT_PREVIEW_CONTROLLER_ORIENTATION = "portrait";
|
|
306
349
|
var getViewportSize = () => {
|
|
307
350
|
if (typeof window === "undefined") {
|
|
@@ -408,27 +451,55 @@ var clampBounds = (orientation, bounds, options = {}, currentBounds) => {
|
|
|
408
451
|
height
|
|
409
452
|
};
|
|
410
453
|
};
|
|
411
|
-
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) => {
|
|
412
459
|
const viewport = getViewportSize();
|
|
413
|
-
|
|
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(
|
|
414
478
|
orientation,
|
|
415
|
-
|
|
479
|
+
PREVIEW_CONTROLLER_MIN_SCALE
|
|
416
480
|
);
|
|
417
|
-
const
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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
|
|
427
502
|
);
|
|
428
|
-
return {
|
|
429
|
-
x: anchored.x,
|
|
430
|
-
y: anchored.y
|
|
431
|
-
};
|
|
432
503
|
};
|
|
433
504
|
var getNextTopSessionId = (sessions) => sessions.filter((session) => !session.minimized).sort((left, right) => right.zIndex - left.zIndex)[0]?.id ?? null;
|
|
434
505
|
var activateSession = (sessions, id, nextZIndex) => sessions.map(
|
|
@@ -447,12 +518,46 @@ var normalizeActiveSession = (sessions) => {
|
|
|
447
518
|
}));
|
|
448
519
|
};
|
|
449
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
|
+
};
|
|
450
554
|
var usePreviewControllerManager = ({
|
|
451
555
|
joinUrl,
|
|
452
556
|
enabled = true,
|
|
453
557
|
maxControllers = 2,
|
|
454
558
|
allowedOrigins,
|
|
455
|
-
embedOrigin
|
|
559
|
+
embedOrigin,
|
|
560
|
+
fixedControllerOrientation = null
|
|
456
561
|
}) => {
|
|
457
562
|
const [sessions, setSessions] = useState([]);
|
|
458
563
|
const nextSessionIdRef = useRef(1);
|
|
@@ -473,59 +578,71 @@ var usePreviewControllerManager = ({
|
|
|
473
578
|
previousJoinRoomRef.current = nextJoinRoom;
|
|
474
579
|
}, [enabled, joinUrl]);
|
|
475
580
|
const canSpawn = enabled && typeof joinUrl === "string" && joinUrl.trim().length > 0 && sessions.length < maxControllers;
|
|
476
|
-
const spawnPreviewController = useCallback(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
let nextSession = null;
|
|
481
|
-
setSessions((current) => {
|
|
482
|
-
if (current.length >= maxControllers) {
|
|
483
|
-
return current;
|
|
581
|
+
const spawnPreviewController = useCallback(
|
|
582
|
+
(options) => {
|
|
583
|
+
if (!enabled || !joinUrl) {
|
|
584
|
+
return null;
|
|
484
585
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
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
|
+
];
|
|
489
634
|
});
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
const position = getInitialWindowPosition(current, orientation);
|
|
502
|
-
nextSession = {
|
|
503
|
-
id: sessionId,
|
|
504
|
-
ordinal,
|
|
505
|
-
label: `Preview ${ordinal}`,
|
|
506
|
-
controllerId: launch.controllerId,
|
|
507
|
-
deviceId: launch.deviceId,
|
|
508
|
-
url: launch.url,
|
|
509
|
-
surfaceState: "loading",
|
|
510
|
-
orientation,
|
|
511
|
-
minimized: false,
|
|
512
|
-
active: true,
|
|
513
|
-
x: position.x,
|
|
514
|
-
y: position.y,
|
|
515
|
-
width: defaultBounds.width,
|
|
516
|
-
height: defaultBounds.height,
|
|
517
|
-
viewportWidth: defaultBounds.viewportWidth,
|
|
518
|
-
viewportHeight: defaultBounds.viewportHeight,
|
|
519
|
-
displayScale: defaultBounds.displayScale,
|
|
520
|
-
zIndex
|
|
521
|
-
};
|
|
522
|
-
return [
|
|
523
|
-
...current.map((session) => ({ ...session, active: false })),
|
|
524
|
-
nextSession
|
|
525
|
-
];
|
|
526
|
-
});
|
|
527
|
-
return nextSession;
|
|
528
|
-
}, [allowedOrigins, embedOrigin, enabled, joinUrl, maxControllers]);
|
|
635
|
+
return nextSession;
|
|
636
|
+
},
|
|
637
|
+
[
|
|
638
|
+
allowedOrigins,
|
|
639
|
+
embedOrigin,
|
|
640
|
+
enabled,
|
|
641
|
+
joinUrl,
|
|
642
|
+
maxControllers,
|
|
643
|
+
fixedControllerOrientation
|
|
644
|
+
]
|
|
645
|
+
);
|
|
529
646
|
const removePreviewController = useCallback((id) => {
|
|
530
647
|
setSessions(
|
|
531
648
|
(current) => normalizeActiveSession(current.filter((session) => session.id !== id))
|
|
@@ -610,46 +727,41 @@ var usePreviewControllerManager = ({
|
|
|
610
727
|
},
|
|
611
728
|
[]
|
|
612
729
|
);
|
|
613
|
-
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;
|
|
614
747
|
setSessions(
|
|
615
|
-
(current) =>
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
const nextOrientation = session.orientation === "portrait" ? "landscape" : "portrait";
|
|
620
|
-
const centerX = session.x + session.width / 2;
|
|
621
|
-
const centerY = session.y + session.height / 2;
|
|
622
|
-
const nextWindowBounds = getPreviewWindowBounds(
|
|
623
|
-
nextOrientation,
|
|
624
|
-
session.displayScale
|
|
625
|
-
);
|
|
626
|
-
const nextBounds = clampBounds(
|
|
627
|
-
nextOrientation,
|
|
628
|
-
{
|
|
629
|
-
x: centerX - nextWindowBounds.width / 2,
|
|
630
|
-
y: centerY - nextWindowBounds.height / 2,
|
|
631
|
-
width: nextWindowBounds.width,
|
|
632
|
-
height: nextWindowBounds.height
|
|
633
|
-
},
|
|
634
|
-
{}
|
|
635
|
-
);
|
|
636
|
-
const clampedWindowBounds = getPreviewWindowBounds(
|
|
637
|
-
nextOrientation,
|
|
638
|
-
getPreviewControllerScaleForBounds(nextOrientation, nextBounds)
|
|
639
|
-
);
|
|
640
|
-
return {
|
|
641
|
-
...session,
|
|
642
|
-
orientation: nextOrientation,
|
|
643
|
-
x: nextBounds.x,
|
|
644
|
-
y: nextBounds.y,
|
|
645
|
-
width: clampedWindowBounds.width,
|
|
646
|
-
height: clampedWindowBounds.height,
|
|
647
|
-
viewportWidth: clampedWindowBounds.viewportWidth,
|
|
648
|
-
viewportHeight: clampedWindowBounds.viewportHeight,
|
|
649
|
-
displayScale: clampedWindowBounds.displayScale
|
|
650
|
-
};
|
|
651
|
-
})
|
|
748
|
+
(current) => current.map(
|
|
749
|
+
(session) => session.orientation === fixedControllerOrientation ? session : orientSession(session, fixedControllerOrientation)
|
|
750
|
+
)
|
|
652
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);
|
|
653
765
|
}, []);
|
|
654
766
|
const markPreviewControllerReady = useCallback((id) => {
|
|
655
767
|
setSessions(
|
|
@@ -697,46 +809,6 @@ import {
|
|
|
697
809
|
import { useRef as useRef2, useState as useState2 } from "react";
|
|
698
810
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
699
811
|
var PREVIEW_WINDOW_SETTINGS_SHELF_HEIGHT = 52;
|
|
700
|
-
var PREVIEW_CLOSE_TIMEOUT_MS = 1e3;
|
|
701
|
-
var requestPreviewControllerClose = async (iframe, sessionUrl) => {
|
|
702
|
-
const frameWindow = iframe?.contentWindow;
|
|
703
|
-
if (!frameWindow) {
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
const targetOrigin = new URL(sessionUrl).origin;
|
|
707
|
-
await new Promise((resolve) => {
|
|
708
|
-
let settled = false;
|
|
709
|
-
const timeout = window.setTimeout(() => {
|
|
710
|
-
cleanup();
|
|
711
|
-
resolve();
|
|
712
|
-
}, PREVIEW_CLOSE_TIMEOUT_MS);
|
|
713
|
-
const handleMessage = (event) => {
|
|
714
|
-
if (event.source !== frameWindow || event.origin !== targetOrigin) {
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
if (!isPreviewCloseResultMessage(event.data)) {
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
cleanup();
|
|
721
|
-
resolve();
|
|
722
|
-
};
|
|
723
|
-
const cleanup = () => {
|
|
724
|
-
if (settled) {
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
settled = true;
|
|
728
|
-
window.clearTimeout(timeout);
|
|
729
|
-
window.removeEventListener("message", handleMessage);
|
|
730
|
-
};
|
|
731
|
-
window.addEventListener("message", handleMessage);
|
|
732
|
-
frameWindow.postMessage(
|
|
733
|
-
{
|
|
734
|
-
type: AIR_JAM_PREVIEW_CLOSE_REQUEST
|
|
735
|
-
},
|
|
736
|
-
targetOrigin
|
|
737
|
-
);
|
|
738
|
-
});
|
|
739
|
-
};
|
|
740
812
|
var previewControllerWindowStateLabel = {
|
|
741
813
|
loading: "Loading",
|
|
742
814
|
ready: "Ready",
|
|
@@ -826,8 +898,10 @@ var RESIZE_HANDLES = [
|
|
|
826
898
|
];
|
|
827
899
|
var PreviewControllerWindow = ({
|
|
828
900
|
session,
|
|
901
|
+
frameRef,
|
|
829
902
|
activeOpacity,
|
|
830
903
|
highContrast = false,
|
|
904
|
+
fixedControllerOrientation = null,
|
|
831
905
|
dragging = false,
|
|
832
906
|
onFocus,
|
|
833
907
|
onMinimize,
|
|
@@ -862,6 +936,7 @@ var PreviewControllerWindow = ({
|
|
|
862
936
|
"div",
|
|
863
937
|
{
|
|
864
938
|
className: "absolute",
|
|
939
|
+
hidden: session.minimized,
|
|
865
940
|
style: {
|
|
866
941
|
left: session.x,
|
|
867
942
|
top: session.y,
|
|
@@ -918,7 +993,7 @@ var PreviewControllerWindow = ({
|
|
|
918
993
|
)
|
|
919
994
|
] }),
|
|
920
995
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
921
|
-
/* @__PURE__ */ jsx(
|
|
996
|
+
!fixedControllerOrientation && /* @__PURE__ */ jsx(
|
|
922
997
|
Button,
|
|
923
998
|
{
|
|
924
999
|
type: "button",
|
|
@@ -1048,7 +1123,10 @@ var PreviewControllerWindow = ({
|
|
|
1048
1123
|
children: /* @__PURE__ */ jsx(
|
|
1049
1124
|
"iframe",
|
|
1050
1125
|
{
|
|
1051
|
-
ref:
|
|
1126
|
+
ref: (frame) => {
|
|
1127
|
+
iframeRef.current = frame;
|
|
1128
|
+
frameRef?.(frame);
|
|
1129
|
+
},
|
|
1052
1130
|
src: session.url,
|
|
1053
1131
|
title: `${session.label} controller`,
|
|
1054
1132
|
"data-testid": `preview-controller-frame-${session.ordinal}`,
|
|
@@ -1106,8 +1184,127 @@ var PreviewControllerWindow = ({
|
|
|
1106
1184
|
);
|
|
1107
1185
|
};
|
|
1108
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
|
+
|
|
1109
1305
|
// src/preview/workspace.tsx
|
|
1110
1306
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1307
|
+
var rosterSourceOf = (kind) => kind === "agent" ? "virtual" : kind;
|
|
1111
1308
|
var getControllerSourceLabel = (source) => {
|
|
1112
1309
|
if (source === "virtual") {
|
|
1113
1310
|
return "Agent";
|
|
@@ -1125,8 +1322,9 @@ var getControllerSourceIcon = (source) => {
|
|
|
1125
1322
|
};
|
|
1126
1323
|
var PreviewControllerWorkspace = ({
|
|
1127
1324
|
joinUrl,
|
|
1325
|
+
fixedControllerOrientation: requestedFixedOrientation,
|
|
1128
1326
|
embedOrigin,
|
|
1129
|
-
|
|
1327
|
+
players = [],
|
|
1130
1328
|
onRemoveController,
|
|
1131
1329
|
onResetRoom,
|
|
1132
1330
|
enabled = false,
|
|
@@ -1138,15 +1336,20 @@ var PreviewControllerWorkspace = ({
|
|
|
1138
1336
|
launcherLabel = "Controllers",
|
|
1139
1337
|
launcherVariant = "full",
|
|
1140
1338
|
showLauncherWhenIdle = true,
|
|
1141
|
-
waitingLabel = "Waiting for room"
|
|
1339
|
+
waitingLabel = "Waiting for room",
|
|
1340
|
+
localPlayers = true,
|
|
1341
|
+
localPlayersGame = null
|
|
1142
1342
|
}) => {
|
|
1143
|
-
const
|
|
1144
|
-
const
|
|
1145
|
-
const [
|
|
1146
|
-
const [
|
|
1147
|
-
const [
|
|
1148
|
-
const [
|
|
1149
|
-
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);
|
|
1150
1353
|
const resolvedEmbedOrigin = embedOrigin ?? (typeof window !== "undefined" ? window.location.origin : null);
|
|
1151
1354
|
const {
|
|
1152
1355
|
sessions,
|
|
@@ -1163,22 +1366,41 @@ var PreviewControllerWorkspace = ({
|
|
|
1163
1366
|
markPreviewControllerReady,
|
|
1164
1367
|
markPreviewControllerFailed
|
|
1165
1368
|
} = usePreviewControllerManager({
|
|
1369
|
+
fixedControllerOrientation: fixedOrientation,
|
|
1166
1370
|
joinUrl,
|
|
1167
1371
|
embedOrigin: resolvedEmbedOrigin,
|
|
1168
1372
|
enabled,
|
|
1169
1373
|
maxControllers
|
|
1170
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);
|
|
1171
1393
|
const platformSettings = useResolvedPlatformSettingsSnapshot();
|
|
1172
1394
|
const activeOpacity = platformSettings.previewControllers.activeOpacity;
|
|
1173
|
-
const sortedSessions =
|
|
1395
|
+
const sortedSessions = useMemo2(
|
|
1174
1396
|
() => [...sessions].sort((left, right) => left.ordinal - right.ordinal),
|
|
1175
1397
|
[sessions]
|
|
1176
1398
|
);
|
|
1177
|
-
|
|
1399
|
+
useEffect3(() => {
|
|
1178
1400
|
setMounted(true);
|
|
1179
1401
|
return () => setMounted(false);
|
|
1180
1402
|
}, []);
|
|
1181
|
-
|
|
1403
|
+
useEffect3(() => {
|
|
1182
1404
|
if (!launcherOpen || typeof document === "undefined") {
|
|
1183
1405
|
return;
|
|
1184
1406
|
}
|
|
@@ -1204,44 +1426,40 @@ var PreviewControllerWorkspace = ({
|
|
|
1204
1426
|
document.removeEventListener("keydown", handleKeyDown);
|
|
1205
1427
|
};
|
|
1206
1428
|
}, [launcherOpen]);
|
|
1207
|
-
const minimizedSessions =
|
|
1429
|
+
const minimizedSessions = useMemo2(
|
|
1208
1430
|
() => sessions.filter((session) => session.minimized).sort((left, right) => left.ordinal - right.ordinal),
|
|
1209
1431
|
[sessions]
|
|
1210
1432
|
);
|
|
1211
|
-
const openSessions = useMemo(
|
|
1212
|
-
() => sessions.filter((session) => !session.minimized),
|
|
1213
|
-
[sessions]
|
|
1214
|
-
);
|
|
1215
1433
|
const launcherVisible = showLauncherWhenIdle || launcherOpen || sessions.length > 0;
|
|
1216
|
-
const sortedControllers =
|
|
1217
|
-
() => [...
|
|
1218
|
-
|
|
1219
|
-
),
|
|
1220
|
-
[controllers]
|
|
1434
|
+
const sortedControllers = useMemo2(
|
|
1435
|
+
() => [...players].sort((left, right) => left.id.localeCompare(right.id)),
|
|
1436
|
+
[players]
|
|
1221
1437
|
);
|
|
1222
|
-
const controllerRoster =
|
|
1223
|
-
const
|
|
1224
|
-
sortedSessions.
|
|
1438
|
+
const controllerRoster = useMemo2(() => {
|
|
1439
|
+
const sessionsBySeat = new Map(
|
|
1440
|
+
sortedSessions.flatMap(
|
|
1441
|
+
(session) => session.seat ? [[session.seat, session]] : []
|
|
1442
|
+
)
|
|
1225
1443
|
);
|
|
1226
1444
|
const controllerItems = sortedControllers.map((controller) => {
|
|
1227
|
-
const session =
|
|
1445
|
+
const session = sessionsBySeat.get(controller.id) ?? null;
|
|
1228
1446
|
return {
|
|
1229
|
-
id: controller.
|
|
1230
|
-
controllerId: controller.
|
|
1231
|
-
label: controller.
|
|
1232
|
-
source: controller.
|
|
1447
|
+
id: controller.id,
|
|
1448
|
+
controllerId: controller.id,
|
|
1449
|
+
label: controller.label,
|
|
1450
|
+
source: rosterSourceOf(controller.kind),
|
|
1233
1451
|
connected: controller.connected,
|
|
1234
|
-
resumable:
|
|
1452
|
+
resumable: !controller.connected,
|
|
1235
1453
|
session,
|
|
1236
1454
|
controller
|
|
1237
1455
|
};
|
|
1238
1456
|
});
|
|
1239
|
-
const
|
|
1240
|
-
sortedControllers.map((controller) => controller.
|
|
1457
|
+
const seatIds = new Set(
|
|
1458
|
+
sortedControllers.map((controller) => controller.id)
|
|
1241
1459
|
);
|
|
1242
|
-
const pendingPreviewItems = sortedSessions.filter((session) => !
|
|
1460
|
+
const pendingPreviewItems = sortedSessions.filter((session) => !session.seat || !seatIds.has(session.seat)).map((session) => ({
|
|
1243
1461
|
id: session.id,
|
|
1244
|
-
controllerId: session.
|
|
1462
|
+
controllerId: session.seat ?? session.id,
|
|
1245
1463
|
label: session.label,
|
|
1246
1464
|
source: "preview",
|
|
1247
1465
|
connected: session.surfaceState === "ready",
|
|
@@ -1271,10 +1489,15 @@ var PreviewControllerWorkspace = ({
|
|
|
1271
1489
|
className: "fixed inset-0",
|
|
1272
1490
|
style: { zIndex: PREVIEW_WORKSPACE_Z_INDEX, pointerEvents: "none" },
|
|
1273
1491
|
children: [
|
|
1274
|
-
|
|
1492
|
+
sessions.map((session) => /* @__PURE__ */ jsx2(
|
|
1275
1493
|
PreviewControllerWindow,
|
|
1276
1494
|
{
|
|
1495
|
+
fixedControllerOrientation: fixedOrientation,
|
|
1277
1496
|
session,
|
|
1497
|
+
frameRef: (frame) => {
|
|
1498
|
+
if (frame) frames.set(session.id, frame);
|
|
1499
|
+
else frames.delete(session.id);
|
|
1500
|
+
},
|
|
1278
1501
|
activeOpacity,
|
|
1279
1502
|
highContrast,
|
|
1280
1503
|
dragging: dragState?.id === session.id,
|
|
@@ -1406,6 +1629,7 @@ var PreviewControllerWorkspace = ({
|
|
|
1406
1629
|
/* @__PURE__ */ jsxs2(
|
|
1407
1630
|
"div",
|
|
1408
1631
|
{
|
|
1632
|
+
ref: dockRowRef,
|
|
1409
1633
|
className: "flex items-start justify-end gap-2",
|
|
1410
1634
|
style: { pointerEvents: "auto" },
|
|
1411
1635
|
children: [
|
|
@@ -1546,21 +1770,21 @@ var PreviewControllerWorkspace = ({
|
|
|
1546
1770
|
variant: "ghost",
|
|
1547
1771
|
size: "sm",
|
|
1548
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",
|
|
1549
|
-
disabled: removingControllerId === item.controller.
|
|
1773
|
+
disabled: removingControllerId === item.controller.id,
|
|
1550
1774
|
onClick: async () => {
|
|
1551
1775
|
if (!item.controller) {
|
|
1552
1776
|
return;
|
|
1553
1777
|
}
|
|
1554
1778
|
try {
|
|
1555
1779
|
setRemovingControllerId(
|
|
1556
|
-
item.controller.
|
|
1780
|
+
item.controller.id
|
|
1557
1781
|
);
|
|
1558
1782
|
await onRemoveController(
|
|
1559
|
-
item.controller.
|
|
1783
|
+
item.controller.id
|
|
1560
1784
|
);
|
|
1561
1785
|
} finally {
|
|
1562
1786
|
setRemovingControllerId(
|
|
1563
|
-
(current) => current === item.controller?.
|
|
1787
|
+
(current) => current === item.controller?.id ? null : current
|
|
1564
1788
|
);
|
|
1565
1789
|
}
|
|
1566
1790
|
},
|
|
@@ -1638,20 +1862,15 @@ var HostPreviewControllerWorkspace = ({
|
|
|
1638
1862
|
topology: config.topology
|
|
1639
1863
|
});
|
|
1640
1864
|
const joinUrl = host.joinUrlStatus === "ready" && host.joinUrl ? host.joinUrl : null;
|
|
1641
|
-
const handleResetRoom =
|
|
1642
|
-
|
|
1643
|
-
if (!ack.ok || typeof window === "undefined") {
|
|
1644
|
-
return ack;
|
|
1645
|
-
}
|
|
1646
|
-
window.location.reload();
|
|
1647
|
-
return ack;
|
|
1865
|
+
const handleResetRoom = () => {
|
|
1866
|
+
void host.resetRoom().then(() => window.location.reload());
|
|
1648
1867
|
};
|
|
1649
1868
|
return /* @__PURE__ */ jsx3(
|
|
1650
1869
|
PreviewControllerWorkspace,
|
|
1651
1870
|
{
|
|
1652
1871
|
enabled: resolvedEnabled,
|
|
1653
1872
|
joinUrl,
|
|
1654
|
-
|
|
1873
|
+
players: host.players,
|
|
1655
1874
|
onRemoveController: host.removeController,
|
|
1656
1875
|
onResetRoom: handleResetRoom,
|
|
1657
1876
|
onActiveOpacityChange: (activeOpacity) => platformSettingsOwner?.updatePreviewControllers({ activeOpacity }),
|
|
@@ -1661,21 +1880,26 @@ var HostPreviewControllerWorkspace = ({
|
|
|
1661
1880
|
);
|
|
1662
1881
|
};
|
|
1663
1882
|
export {
|
|
1664
|
-
|
|
1665
|
-
AIR_JAM_PREVIEW_FLAG_QUERY_PARAM,
|
|
1883
|
+
AIR_JAM_LOCAL_SEAT_QUERY_PARAM,
|
|
1666
1884
|
HostPreviewControllerWorkspace,
|
|
1667
1885
|
PreviewControllerWindow,
|
|
1668
1886
|
PreviewControllerWorkspace,
|
|
1669
1887
|
buildPreviewControllerUrl,
|
|
1670
|
-
createPreviewControllerIdentity,
|
|
1671
1888
|
createPreviewControllerLaunch,
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1889
|
+
getPreviewControllerViewportSize,
|
|
1890
|
+
getPreviewHostViewportSize,
|
|
1891
|
+
isLocalSeatReadyMessage,
|
|
1892
|
+
isLocalSeatRelayedMessage,
|
|
1893
|
+
isPreviewSeatMessage,
|
|
1894
|
+
localInputOperationSchema,
|
|
1895
|
+
localSeatMessages,
|
|
1896
|
+
localSeatQuerySchema,
|
|
1897
|
+
localSeatRelaySchema,
|
|
1898
|
+
localSeatRequestSchema,
|
|
1677
1899
|
readPreviewControllerDeviceIdFromSearchParams,
|
|
1678
|
-
|
|
1900
|
+
relayLocalSeatInput,
|
|
1901
|
+
requestPreviewControllerClose,
|
|
1902
|
+
sendLocalSeatOperation,
|
|
1679
1903
|
usePreviewControllerManager
|
|
1680
1904
|
};
|
|
1681
1905
|
//# sourceMappingURL=preview.js.map
|