@air-jam/sdk 0.1.3 → 0.9.0
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/LICENSE +21 -0
- package/README.md +627 -57
- package/dist/agent-tooling-BSMGBix9.d.cts +123 -0
- package/dist/agent-tooling-BSMGBix9.d.ts +123 -0
- package/dist/agent-tooling.cjs +83 -0
- package/dist/agent-tooling.cjs.map +1 -0
- package/dist/agent-tooling.d.cts +2 -0
- package/dist/agent-tooling.d.ts +2 -0
- package/dist/agent-tooling.js +17 -0
- package/dist/agent-tooling.js.map +1 -0
- package/dist/arcade/bridge/controller.cjs +749 -0
- package/dist/arcade/bridge/controller.cjs.map +1 -0
- package/dist/arcade/bridge/controller.d.cts +85 -0
- package/dist/arcade/bridge/controller.d.ts +85 -0
- package/dist/arcade/bridge/controller.js +33 -0
- package/dist/arcade/bridge/controller.js.map +1 -0
- package/dist/arcade/bridge/host.cjs +421 -0
- package/dist/arcade/bridge/host.cjs.map +1 -0
- package/dist/arcade/bridge/host.d.cts +73 -0
- package/dist/arcade/bridge/host.d.ts +73 -0
- package/dist/arcade/bridge/host.js +25 -0
- package/dist/arcade/bridge/host.js.map +1 -0
- package/dist/arcade/bridge/iframe.cjs +453 -0
- package/dist/arcade/bridge/iframe.cjs.map +1 -0
- package/dist/arcade/bridge/iframe.d.cts +80 -0
- package/dist/arcade/bridge/iframe.d.ts +80 -0
- package/dist/arcade/bridge/iframe.js +28 -0
- package/dist/arcade/bridge/iframe.js.map +1 -0
- package/dist/arcade/bridge.cjs +1067 -0
- package/dist/arcade/bridge.cjs.map +1 -0
- package/dist/arcade/bridge.d.cts +11 -0
- package/dist/arcade/bridge.d.ts +11 -0
- package/dist/arcade/bridge.js +76 -0
- package/dist/arcade/bridge.js.map +1 -0
- package/dist/arcade/host.cjs +488 -0
- package/dist/arcade/host.cjs.map +1 -0
- package/dist/arcade/host.d.cts +19 -0
- package/dist/arcade/host.d.ts +19 -0
- package/dist/arcade/host.js +13 -0
- package/dist/arcade/host.js.map +1 -0
- package/dist/arcade/surface.cjs +113 -0
- package/dist/arcade/surface.cjs.map +1 -0
- package/dist/arcade/surface.d.cts +14 -0
- package/dist/arcade/surface.d.ts +14 -0
- package/dist/arcade/surface.js +27 -0
- package/dist/arcade/surface.js.map +1 -0
- package/dist/arcade/url.cjs +363 -0
- package/dist/arcade/url.cjs.map +1 -0
- package/dist/arcade/url.d.cts +68 -0
- package/dist/arcade/url.d.ts +68 -0
- package/dist/arcade/url.js +28 -0
- package/dist/arcade/url.js.map +1 -0
- package/dist/arcade-runtime-url-BW-MUAOY.d.cts +28 -0
- package/dist/arcade-runtime-url-l8qj01Pg.d.ts +28 -0
- package/dist/arcade-surface-identity-CQxDpn_w.d.cts +16 -0
- package/dist/arcade-surface-identity-CQxDpn_w.d.ts +16 -0
- package/dist/arcade.cjs +1565 -0
- package/dist/arcade.cjs.map +1 -0
- package/dist/arcade.d.cts +18 -0
- package/dist/arcade.d.ts +18 -0
- package/dist/arcade.js +122 -0
- package/dist/arcade.js.map +1 -0
- package/dist/capabilities.cjs +39 -0
- package/dist/capabilities.cjs.map +1 -0
- package/dist/capabilities.d.cts +31 -0
- package/dist/capabilities.d.ts +31 -0
- package/dist/capabilities.js +12 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chunk-2432OL7L.js +193 -0
- package/dist/chunk-2432OL7L.js.map +1 -0
- package/dist/chunk-2J65FXEP.js +41 -0
- package/dist/chunk-2J65FXEP.js.map +1 -0
- package/dist/chunk-32NYL7XI.js +539 -0
- package/dist/chunk-32NYL7XI.js.map +1 -0
- package/dist/chunk-3USU7GY2.js +54 -0
- package/dist/chunk-3USU7GY2.js.map +1 -0
- package/dist/chunk-BE6Z4SIT.js +65 -0
- package/dist/chunk-BE6Z4SIT.js.map +1 -0
- package/dist/chunk-CQUG24WX.js +249 -0
- package/dist/chunk-CQUG24WX.js.map +1 -0
- package/dist/chunk-D3X4MN4U.js +288 -0
- package/dist/chunk-D3X4MN4U.js.map +1 -0
- package/dist/chunk-EVZJA6RN.js +140 -0
- package/dist/chunk-EVZJA6RN.js.map +1 -0
- package/dist/chunk-HFWRZVZ3.js +1438 -0
- package/dist/chunk-HFWRZVZ3.js.map +1 -0
- package/dist/chunk-IKKDONQL.js +1 -0
- package/dist/chunk-IKKDONQL.js.map +1 -0
- package/dist/chunk-JTF47B56.js +1 -0
- package/dist/chunk-JTF47B56.js.map +1 -0
- package/dist/chunk-LIXPF4P6.js +22 -0
- package/dist/chunk-LIXPF4P6.js.map +1 -0
- package/dist/chunk-MKBASO6X.js +216 -0
- package/dist/chunk-MKBASO6X.js.map +1 -0
- package/dist/chunk-MPDMJIX5.js +1 -0
- package/dist/chunk-MPDMJIX5.js.map +1 -0
- package/dist/chunk-NCL6WJCL.js +91 -0
- package/dist/chunk-NCL6WJCL.js.map +1 -0
- package/dist/chunk-NU5W6VAV.js +126 -0
- package/dist/chunk-NU5W6VAV.js.map +1 -0
- package/dist/chunk-TGRTEWYV.js +195 -0
- package/dist/chunk-TGRTEWYV.js.map +1 -0
- package/dist/chunk-VDRNNGHX.js +184 -0
- package/dist/chunk-VDRNNGHX.js.map +1 -0
- package/dist/chunk-VN5LDWVN.js +32 -0
- package/dist/chunk-VN5LDWVN.js.map +1 -0
- package/dist/chunk-W2VK36RO.js +11 -0
- package/dist/chunk-W2VK36RO.js.map +1 -0
- package/dist/chunk-X24K52DG.js +12 -0
- package/dist/chunk-X24K52DG.js.map +1 -0
- package/dist/chunk-XLUWV45V.js +25 -0
- package/dist/chunk-XLUWV45V.js.map +1 -0
- package/dist/chunk-Y4RAPKKB.js +238 -0
- package/dist/chunk-Y4RAPKKB.js.map +1 -0
- package/dist/chunk-YXHH3MQT.js +230 -0
- package/dist/chunk-YXHH3MQT.js.map +1 -0
- package/dist/chunk-ZLPL2R3R.js +183 -0
- package/dist/chunk-ZLPL2R3R.js.map +1 -0
- package/dist/chunk-ZTQ5SP4H.js +9 -0
- package/dist/chunk-ZTQ5SP4H.js.map +1 -0
- package/dist/controller-Bod8YYr1.d.cts +172 -0
- package/dist/controller-DxVchfiA.d.ts +172 -0
- package/dist/dev-log-events-CVAM29hx.d.cts +123 -0
- package/dist/dev-log-events-CVAM29hx.d.ts +123 -0
- package/dist/handshake-CC_LrK5g.d.cts +31 -0
- package/dist/handshake-CC_LrK5g.d.ts +31 -0
- package/dist/host-8hmq_Sgc.d.cts +109 -0
- package/dist/host-Cw-N6e-5.d.ts +109 -0
- package/dist/index.cjs +8512 -3518
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +676 -1070
- package/dist/index.d.ts +676 -1070
- package/dist/index.js +4892 -3188
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs +114 -0
- package/dist/metadata.cjs.map +1 -0
- package/dist/metadata.d.cts +95 -0
- package/dist/metadata.d.ts +95 -0
- package/dist/metadata.js +83 -0
- package/dist/metadata.js.map +1 -0
- package/dist/notices-CnGaaS8B.d.ts +38 -0
- package/dist/notices-NyDM5Mtz.d.cts +38 -0
- package/dist/platform-machine.cjs +425 -0
- package/dist/platform-machine.cjs.map +1 -0
- package/dist/platform-machine.d.cts +1183 -0
- package/dist/platform-machine.d.ts +1183 -0
- package/dist/platform-machine.js +309 -0
- package/dist/platform-machine.js.map +1 -0
- package/dist/platform-settings-cuor3i11.d.cts +48 -0
- package/dist/platform-settings-cuor3i11.d.ts +48 -0
- package/dist/prefabs.cjs +36 -0
- package/dist/prefabs.cjs.map +1 -0
- package/dist/prefabs.d.cts +49 -0
- package/dist/prefabs.d.ts +49 -0
- package/dist/prefabs.js +8 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/preview.cjs +2609 -0
- package/dist/preview.cjs.map +1 -0
- package/dist/preview.d.cts +155 -0
- package/dist/preview.d.ts +155 -0
- package/dist/preview.js +1671 -0
- package/dist/preview.js.map +1 -0
- package/dist/protocol.cjs +621 -54
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +76 -240
- package/dist/protocol.d.ts +76 -240
- package/dist/protocol.js +100 -2
- package/dist/protocol.js.map +1 -1
- package/dist/realtime-client-Cu8yVJFw.d.cts +15 -0
- package/dist/realtime-client-Cu8yVJFw.d.ts +15 -0
- package/dist/release.cjs +143 -0
- package/dist/release.cjs.map +1 -0
- package/dist/release.d.cts +64 -0
- package/dist/release.d.ts +64 -0
- package/dist/release.js +43 -0
- package/dist/release.js.map +1 -0
- package/dist/standard-match-phase-BucA5dYo.d.ts +44 -0
- package/dist/standard-match-phase-U2ra8J-0.d.cts +44 -0
- package/dist/sync-B6QsNrXz.d.cts +125 -0
- package/dist/sync-B6QsNrXz.d.ts +125 -0
- package/dist/ui.cjs +2827 -0
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +320 -0
- package/dist/ui.d.ts +320 -0
- package/dist/ui.js +1718 -0
- package/dist/ui.js.map +1 -0
- package/dist/url-policy-C89zxgw9.d.cts +9 -0
- package/dist/url-policy-C89zxgw9.d.ts +9 -0
- package/package.json +154 -13
- package/src/agent/agent-action.ts +304 -0
- package/src/agent/agent-contract.ts +180 -0
- package/src/agent-tooling.ts +20 -0
- package/src/arcade/bridge/controller.ts +15 -0
- package/src/arcade/bridge/host.ts +12 -0
- package/src/arcade/bridge/iframe.ts +61 -0
- package/src/arcade/bridge.ts +3 -0
- package/src/arcade/host.ts +1 -0
- package/src/arcade/surface.ts +4 -0
- package/src/arcade/url.ts +60 -0
- package/src/arcade.ts +4 -0
- package/src/audio/audio-manager.ts +162 -171
- package/src/audio/hooks.tsx +218 -97
- package/src/audio/index.ts +1 -1
- package/src/audio/music.tsx +139 -0
- package/src/capabilities/manifest.ts +71 -0
- package/src/capabilities.ts +12 -0
- package/src/components/connection-status-pill.tsx +55 -0
- package/src/components/controller-player-name-field.tsx +119 -0
- package/src/components/controller-primary-action.tsx +58 -0
- package/src/components/host-mute-button.tsx +49 -0
- package/src/components/join-qr-overlay.tsx +133 -0
- package/src/components/join-url-action-buttons.tsx +95 -0
- package/src/components/join-url-controls.tsx +58 -0
- package/src/components/join-url-field.tsx +52 -0
- package/src/components/lifecycle-action-group.tsx +129 -0
- package/src/components/player-avatar-strip.tsx +65 -0
- package/src/components/player-avatar.tsx +42 -14
- package/src/components/room-qr-code.tsx +125 -0
- package/src/components/runtime-shell-header.tsx +37 -0
- package/src/components/shell-classes.ts +19 -0
- package/src/components/surface-orientation-layout.ts +60 -0
- package/src/components/surface-viewport-layout.ts +268 -0
- package/src/components/surface-viewport.tsx +314 -0
- package/src/components/ui/button.tsx +4 -6
- package/src/components/ui/slider.tsx +1 -1
- package/src/components/volume-controls.tsx +65 -6
- package/src/context/air-jam-context.tsx +209 -141
- package/src/context/index.ts +2 -2
- package/src/context/session-providers.tsx +77 -0
- package/src/context/session-scope.ts +64 -0
- package/src/context/socket-manager.ts +6 -25
- package/src/contracts/v2/bridge.ts +261 -0
- package/src/contracts/v2/handshake.ts +40 -0
- package/src/contracts/v2/index.ts +2 -0
- package/src/dev/browser-log-sink.ts +912 -0
- package/src/diagnostics.ts +128 -0
- package/src/events.ts +7 -34
- package/src/hooks/internal/use-controller-runtime-api.ts +875 -0
- package/src/hooks/internal/use-host-runtime-api.ts +1051 -0
- package/src/hooks/internal/use-runtime-control-contract.ts +15 -0
- package/src/hooks/internal/use-runtime-inspection-contract.ts +16 -0
- package/src/hooks/internal/use-runtime-observability-contract.ts +24 -0
- package/src/hooks/use-air-jam-controller.ts +155 -475
- package/src/hooks/use-air-jam-host.ts +156 -485
- package/src/hooks/use-connection-status.ts +8 -0
- package/src/hooks/use-controller-lifecycle-intents.ts +27 -0
- package/src/hooks/use-controller-lifecycle-permissions.ts +36 -0
- package/src/hooks/use-controller-shell-status.ts +40 -0
- package/src/hooks/use-controller-tick.ts +65 -0
- package/src/hooks/use-controller-toasts.ts +116 -0
- package/src/hooks/use-get-input.ts +8 -5
- package/src/hooks/use-host-arcade-restore.ts +30 -0
- package/src/hooks/use-host-join-controls.ts +152 -0
- package/src/hooks/use-host-tick.ts +171 -0
- package/src/hooks/use-input-writer.ts +83 -0
- package/src/hooks/use-lifecycle-action-group-model.ts +98 -0
- package/src/hooks/use-players.ts +12 -0
- package/src/hooks/use-room.ts +22 -0
- package/src/hooks/use-send-signal.ts +6 -2
- package/src/index.ts +205 -31
- package/src/internal/input-manager.ts +195 -215
- package/src/lifecycle/index.ts +9 -0
- package/src/lifecycle/standard-match-phase.ts +32 -0
- package/src/metadata/manifest.ts +152 -0
- package/src/metadata.ts +12 -0
- package/src/platform-machine.ts +475 -0
- package/src/prefabs/types.ts +82 -0
- package/src/prefabs.ts +12 -0
- package/src/preview/host-workspace.tsx +59 -0
- package/src/preview/identity.ts +66 -0
- package/src/preview/layout.ts +223 -0
- package/src/preview/manager.ts +577 -0
- package/src/preview/messages.ts +26 -0
- package/src/preview/ownership.ts +81 -0
- package/src/preview/url.ts +117 -0
- package/src/preview/window.tsx +490 -0
- package/src/preview/workspace.tsx +678 -0
- package/src/preview.ts +42 -0
- package/src/protocol/arcade-platform-actions.ts +29 -0
- package/src/protocol/controller.ts +187 -0
- package/src/protocol/core.ts +23 -0
- package/src/protocol/dev-log-events.ts +222 -0
- package/src/protocol/errors.ts +21 -0
- package/src/protocol/host-grant.ts +185 -0
- package/src/protocol/host.ts +138 -0
- package/src/protocol/notices.ts +43 -0
- package/src/protocol/signals.ts +38 -0
- package/src/protocol/socket-events.ts +154 -0
- package/src/protocol/sync.ts +121 -0
- package/src/protocol/url-policy.ts +63 -0
- package/src/protocol.ts +12 -386
- package/src/qrcode.d.ts +16 -0
- package/src/release.ts +99 -0
- package/src/runtime/air-jam-config.ts +287 -0
- package/src/runtime/air-jam-error-boundary.tsx +672 -0
- package/src/runtime/arcade-bridge-request-surface.ts +15 -0
- package/src/runtime/arcade-runtime-url.ts +95 -0
- package/src/runtime/arcade-surface-identity.ts +16 -0
- package/src/runtime/contracts/control.ts +68 -0
- package/src/runtime/contracts/inspection.ts +165 -0
- package/src/runtime/contracts/observability.ts +94 -0
- package/src/runtime/controller-bridge.ts +451 -0
- package/src/runtime/controller-identity.ts +132 -0
- package/src/runtime/controller-presentation.ts +24 -0
- package/src/runtime/controller-realtime-client.ts +591 -0
- package/src/runtime/create-air-jam-app.tsx +260 -0
- package/src/runtime/dev-runtime-events.ts +36 -0
- package/src/runtime/embedded-runtime-adapters.ts +68 -0
- package/src/runtime/host-bridge.ts +388 -0
- package/src/runtime/host-realtime-client.ts +550 -0
- package/src/runtime/iframe-bridge.ts +135 -0
- package/src/runtime/realtime-client.ts +20 -0
- package/src/runtime/router-basename.ts +25 -0
- package/src/runtime/runtime-owner-contexts.tsx +4 -0
- package/src/runtime/runtime-session-params.ts +169 -0
- package/src/runtime/sdk-version.ts +6 -0
- package/src/runtime/session-runtimes.tsx +188 -0
- package/src/runtime/validate-arcade-bridge-attach.ts +14 -0
- package/src/runtime-control.ts +10 -0
- package/src/runtime-inspection.ts +14 -0
- package/src/runtime-observability.ts +9 -0
- package/src/settings/platform-settings-bridge.ts +336 -0
- package/src/settings/platform-settings-runtime.tsx +387 -0
- package/src/settings/platform-settings.ts +288 -0
- package/src/state/connection-store.ts +80 -12
- package/src/store/air-jam-store-domain-constants.ts +4 -0
- package/src/store/create-air-jam-store.ts +1094 -227
- package/src/styles.css +4 -38
- package/src/ui.ts +29 -0
- package/src/utils/is-rpc-serializable.ts +56 -0
- package/src/utils/player-avatar-url.ts +48 -0
- package/src/utils/url-builder.ts +7 -0
- package/dist/.tsbuildinfo +0 -1
- package/dist/chunk-B5DURUWT.js +0 -80
- package/dist/chunk-B5DURUWT.js.map +0 -1
- package/src/AirJamClient.ts +0 -224
- package/src/audio/volume-store.ts +0 -124
- package/src/components/controller-shell.tsx +0 -346
- package/src/components/host-shell.tsx +0 -521
- package/src/components/qr-scanner-dialog.tsx +0 -373
- package/src/components/ui/alert.tsx +0 -66
- package/src/components/ui/avatar.tsx +0 -46
- package/src/components/ui/badge.tsx +0 -47
- package/src/components/ui/card.tsx +0 -92
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/tabs.tsx +0 -64
- package/src/hooks/use-air-jam-shell.ts +0 -379
- package/src/hooks/use-fullscreen.ts +0 -108
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { v2HandshakeSchema, type V2Handshake } from "../contracts/v2";
|
|
3
|
+
import type {
|
|
4
|
+
AirJamActionRpcPayload,
|
|
5
|
+
AirJamStateSyncRequestPayload,
|
|
6
|
+
ControllerInputEvent,
|
|
7
|
+
ControllerJoinedNotice,
|
|
8
|
+
ControllerLeftNotice,
|
|
9
|
+
ControllerStateMessage,
|
|
10
|
+
ControllerSystemPayload,
|
|
11
|
+
HostLeftNotice,
|
|
12
|
+
HostStateSyncPayload,
|
|
13
|
+
PlaySoundEventPayload,
|
|
14
|
+
PlaySoundPayload,
|
|
15
|
+
RoomCode,
|
|
16
|
+
ServerErrorPayload,
|
|
17
|
+
SignalPayload,
|
|
18
|
+
} from "../protocol";
|
|
19
|
+
import type { PlayerUpdatedNotice } from "../protocol/notices";
|
|
20
|
+
import {
|
|
21
|
+
arcadeSurfaceRuntimeIdentitySchema,
|
|
22
|
+
type ArcadeSurfaceRuntimeIdentity,
|
|
23
|
+
} from "./arcade-surface-identity";
|
|
24
|
+
import { createBridgeHandshake } from "./iframe-bridge";
|
|
25
|
+
import { AIR_JAM_SDK_VERSION } from "./sdk-version";
|
|
26
|
+
|
|
27
|
+
export const AIRJAM_HOST_BRIDGE_REQUEST = "AIRJAM_HOST_BRIDGE_REQUEST" as const;
|
|
28
|
+
export const AIRJAM_HOST_BRIDGE_ATTACH = "AIRJAM_HOST_BRIDGE_ATTACH" as const;
|
|
29
|
+
export const AIRJAM_HOST_BRIDGE_EVENT = "AIRJAM_HOST_BRIDGE_EVENT" as const;
|
|
30
|
+
export const AIRJAM_HOST_BRIDGE_EMIT = "AIRJAM_HOST_BRIDGE_EMIT" as const;
|
|
31
|
+
export const AIRJAM_HOST_BRIDGE_CLOSE = "AIRJAM_HOST_BRIDGE_CLOSE" as const;
|
|
32
|
+
export const AIRJAM_HOST_BRIDGE_RESPONSE =
|
|
33
|
+
"AIRJAM_HOST_BRIDGE_RESPONSE" as const;
|
|
34
|
+
|
|
35
|
+
export const hostBridgeClientEvents = [
|
|
36
|
+
"host:state",
|
|
37
|
+
"host:signal",
|
|
38
|
+
"host:play_sound",
|
|
39
|
+
"host:system",
|
|
40
|
+
"host:state_sync",
|
|
41
|
+
] as const;
|
|
42
|
+
|
|
43
|
+
export const hostBridgeServerEvents = [
|
|
44
|
+
"connect",
|
|
45
|
+
"disconnect",
|
|
46
|
+
"airjam:state_sync_request",
|
|
47
|
+
"server:controllerJoined",
|
|
48
|
+
"server:controllerLeft",
|
|
49
|
+
"server:playerUpdated",
|
|
50
|
+
"server:input",
|
|
51
|
+
"server:error",
|
|
52
|
+
"server:state",
|
|
53
|
+
"server:hostLeft",
|
|
54
|
+
"server:playSound",
|
|
55
|
+
"airjam:action_rpc",
|
|
56
|
+
"server:closeChild",
|
|
57
|
+
] as const;
|
|
58
|
+
|
|
59
|
+
export type HostBridgeClientEventName = (typeof hostBridgeClientEvents)[number];
|
|
60
|
+
export type HostBridgeServerEventName = (typeof hostBridgeServerEvents)[number];
|
|
61
|
+
|
|
62
|
+
export type HostBridgeClientEventArgs = {
|
|
63
|
+
"host:state": [payload: ControllerStateMessage];
|
|
64
|
+
"host:signal": [payload: SignalPayload];
|
|
65
|
+
"host:play_sound": [payload: PlaySoundEventPayload];
|
|
66
|
+
"host:system": [payload: ControllerSystemPayload];
|
|
67
|
+
"host:state_sync": [payload: HostStateSyncPayload];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type HostBridgeServerEventArgs = {
|
|
71
|
+
connect: [];
|
|
72
|
+
disconnect: [reason?: string];
|
|
73
|
+
"airjam:state_sync_request": [payload: AirJamStateSyncRequestPayload];
|
|
74
|
+
"server:controllerJoined": [payload: ControllerJoinedNotice];
|
|
75
|
+
"server:controllerLeft": [payload: ControllerLeftNotice];
|
|
76
|
+
"server:playerUpdated": [payload: PlayerUpdatedNotice];
|
|
77
|
+
"server:input": [payload: ControllerInputEvent];
|
|
78
|
+
"server:error": [payload: ServerErrorPayload];
|
|
79
|
+
"server:state": [payload: ControllerStateMessage];
|
|
80
|
+
"server:hostLeft": [payload: HostLeftNotice];
|
|
81
|
+
"server:playSound": [payload: PlaySoundPayload];
|
|
82
|
+
"airjam:action_rpc": [
|
|
83
|
+
payload: AirJamActionRpcPayload,
|
|
84
|
+
callback?: (ack: unknown) => void,
|
|
85
|
+
];
|
|
86
|
+
"server:closeChild": [];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export interface HostBridgeSnapshot {
|
|
90
|
+
roomId: RoomCode;
|
|
91
|
+
capabilityToken: string;
|
|
92
|
+
connected: boolean;
|
|
93
|
+
socketId?: string;
|
|
94
|
+
players: ControllerJoinedNotice[];
|
|
95
|
+
state?: ControllerStateMessage["state"];
|
|
96
|
+
/** The platform shell's active game surface identity for this embedded host runtime. */
|
|
97
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface HostBridgeRequestMessage {
|
|
101
|
+
type: typeof AIRJAM_HOST_BRIDGE_REQUEST;
|
|
102
|
+
payload: {
|
|
103
|
+
handshake: V2Handshake;
|
|
104
|
+
roomId: RoomCode;
|
|
105
|
+
capabilityToken: string;
|
|
106
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface HostBridgeAttachMessage {
|
|
111
|
+
type: typeof AIRJAM_HOST_BRIDGE_ATTACH;
|
|
112
|
+
payload: {
|
|
113
|
+
handshake: V2Handshake;
|
|
114
|
+
snapshot: HostBridgeSnapshot;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface HostBridgeEventMessage {
|
|
119
|
+
type: typeof AIRJAM_HOST_BRIDGE_EVENT;
|
|
120
|
+
payload: {
|
|
121
|
+
event: HostBridgeServerEventName;
|
|
122
|
+
args: unknown[];
|
|
123
|
+
requestId?: string;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface HostBridgeEmitMessage {
|
|
128
|
+
type: typeof AIRJAM_HOST_BRIDGE_EMIT;
|
|
129
|
+
payload: {
|
|
130
|
+
event: HostBridgeClientEventName;
|
|
131
|
+
args: unknown[];
|
|
132
|
+
requestId?: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface HostBridgeResponseMessage {
|
|
137
|
+
type: typeof AIRJAM_HOST_BRIDGE_RESPONSE;
|
|
138
|
+
payload: {
|
|
139
|
+
requestId: string;
|
|
140
|
+
ack: unknown;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface HostBridgeCloseMessage {
|
|
145
|
+
type: typeof AIRJAM_HOST_BRIDGE_CLOSE;
|
|
146
|
+
payload: {
|
|
147
|
+
reason?: string;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const hostBridgeRequestSchema = z
|
|
152
|
+
.object({
|
|
153
|
+
type: z.literal(AIRJAM_HOST_BRIDGE_REQUEST),
|
|
154
|
+
payload: z
|
|
155
|
+
.object({
|
|
156
|
+
handshake: v2HandshakeSchema,
|
|
157
|
+
roomId: z.string().min(1),
|
|
158
|
+
capabilityToken: z.string().min(1),
|
|
159
|
+
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema,
|
|
160
|
+
})
|
|
161
|
+
.strict(),
|
|
162
|
+
})
|
|
163
|
+
.strict();
|
|
164
|
+
|
|
165
|
+
const hostBridgeAttachSchema = z
|
|
166
|
+
.object({
|
|
167
|
+
type: z.literal(AIRJAM_HOST_BRIDGE_ATTACH),
|
|
168
|
+
payload: z
|
|
169
|
+
.object({
|
|
170
|
+
handshake: v2HandshakeSchema,
|
|
171
|
+
snapshot: z
|
|
172
|
+
.object({
|
|
173
|
+
roomId: z.string().min(1),
|
|
174
|
+
capabilityToken: z.string().min(1),
|
|
175
|
+
connected: z.boolean(),
|
|
176
|
+
socketId: z.string().optional(),
|
|
177
|
+
players: z.array(z.unknown()),
|
|
178
|
+
state: z.unknown().optional(),
|
|
179
|
+
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema,
|
|
180
|
+
})
|
|
181
|
+
.strict(),
|
|
182
|
+
})
|
|
183
|
+
.strict(),
|
|
184
|
+
})
|
|
185
|
+
.strict();
|
|
186
|
+
|
|
187
|
+
const hostBridgeEventSchema = z
|
|
188
|
+
.object({
|
|
189
|
+
type: z.literal(AIRJAM_HOST_BRIDGE_EVENT),
|
|
190
|
+
payload: z
|
|
191
|
+
.object({
|
|
192
|
+
event: z.enum(hostBridgeServerEvents),
|
|
193
|
+
args: z.array(z.unknown()),
|
|
194
|
+
requestId: z.string().min(1).optional(),
|
|
195
|
+
})
|
|
196
|
+
.strict(),
|
|
197
|
+
})
|
|
198
|
+
.strict();
|
|
199
|
+
|
|
200
|
+
const hostBridgeEmitSchema = z
|
|
201
|
+
.object({
|
|
202
|
+
type: z.literal(AIRJAM_HOST_BRIDGE_EMIT),
|
|
203
|
+
payload: z
|
|
204
|
+
.object({
|
|
205
|
+
event: z.enum(hostBridgeClientEvents),
|
|
206
|
+
args: z.array(z.unknown()),
|
|
207
|
+
requestId: z.string().min(1).optional(),
|
|
208
|
+
})
|
|
209
|
+
.strict(),
|
|
210
|
+
})
|
|
211
|
+
.strict();
|
|
212
|
+
|
|
213
|
+
const hostBridgeResponseSchema = z
|
|
214
|
+
.object({
|
|
215
|
+
type: z.literal(AIRJAM_HOST_BRIDGE_RESPONSE),
|
|
216
|
+
payload: z
|
|
217
|
+
.object({
|
|
218
|
+
requestId: z.string().min(1),
|
|
219
|
+
ack: z.unknown(),
|
|
220
|
+
})
|
|
221
|
+
.strict(),
|
|
222
|
+
})
|
|
223
|
+
.strict();
|
|
224
|
+
|
|
225
|
+
const hostBridgeCloseSchema = z
|
|
226
|
+
.object({
|
|
227
|
+
type: z.literal(AIRJAM_HOST_BRIDGE_CLOSE),
|
|
228
|
+
payload: z
|
|
229
|
+
.object({
|
|
230
|
+
reason: z.string().optional(),
|
|
231
|
+
})
|
|
232
|
+
.strict(),
|
|
233
|
+
})
|
|
234
|
+
.strict();
|
|
235
|
+
|
|
236
|
+
export const createHostBridgeRequestMessage = (payload: {
|
|
237
|
+
roomId: RoomCode;
|
|
238
|
+
capabilityToken: string;
|
|
239
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
240
|
+
}): HostBridgeRequestMessage => ({
|
|
241
|
+
type: AIRJAM_HOST_BRIDGE_REQUEST,
|
|
242
|
+
payload: {
|
|
243
|
+
handshake: createBridgeHandshake({
|
|
244
|
+
sdkVersion: AIR_JAM_SDK_VERSION,
|
|
245
|
+
runtimeKind: "arcade-host-iframe",
|
|
246
|
+
capabilityFlags: {
|
|
247
|
+
hostBridge: true,
|
|
248
|
+
},
|
|
249
|
+
}),
|
|
250
|
+
roomId: payload.roomId,
|
|
251
|
+
capabilityToken: payload.capabilityToken,
|
|
252
|
+
arcadeSurface: payload.arcadeSurface,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
export const createHostBridgeAttachMessage = (
|
|
257
|
+
snapshot: HostBridgeSnapshot,
|
|
258
|
+
): HostBridgeAttachMessage => ({
|
|
259
|
+
type: AIRJAM_HOST_BRIDGE_ATTACH,
|
|
260
|
+
payload: {
|
|
261
|
+
handshake: createBridgeHandshake({
|
|
262
|
+
sdkVersion: AIR_JAM_SDK_VERSION,
|
|
263
|
+
runtimeKind: "arcade-host-runtime",
|
|
264
|
+
capabilityFlags: {
|
|
265
|
+
hostBridge: true,
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
snapshot,
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const splitHostBridgeArgs = (
|
|
273
|
+
args: unknown[],
|
|
274
|
+
): {
|
|
275
|
+
eventArgs: unknown[];
|
|
276
|
+
requestId?: string;
|
|
277
|
+
} => {
|
|
278
|
+
const maybeOptions = args[args.length - 1] as
|
|
279
|
+
| { requestId?: string }
|
|
280
|
+
| undefined;
|
|
281
|
+
const hasOptions =
|
|
282
|
+
typeof maybeOptions === "object" &&
|
|
283
|
+
maybeOptions !== null &&
|
|
284
|
+
"requestId" in maybeOptions;
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
eventArgs: hasOptions ? args.slice(0, -1) : args,
|
|
288
|
+
...(hasOptions && maybeOptions.requestId
|
|
289
|
+
? { requestId: maybeOptions.requestId }
|
|
290
|
+
: {}),
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export const createHostBridgeEventMessage = <
|
|
295
|
+
TEvent extends HostBridgeServerEventName,
|
|
296
|
+
>(
|
|
297
|
+
event: TEvent,
|
|
298
|
+
...args: [...HostBridgeServerEventArgs[TEvent], { requestId?: string }?]
|
|
299
|
+
): HostBridgeEventMessage => {
|
|
300
|
+
const { eventArgs, requestId } = splitHostBridgeArgs(args as unknown[]);
|
|
301
|
+
return {
|
|
302
|
+
type: AIRJAM_HOST_BRIDGE_EVENT,
|
|
303
|
+
payload: {
|
|
304
|
+
event,
|
|
305
|
+
args: eventArgs,
|
|
306
|
+
...(requestId ? { requestId } : {}),
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export const createHostBridgeEmitMessage = <
|
|
312
|
+
TEvent extends HostBridgeClientEventName,
|
|
313
|
+
>(
|
|
314
|
+
event: TEvent,
|
|
315
|
+
...args: [...HostBridgeClientEventArgs[TEvent], { requestId?: string }?]
|
|
316
|
+
): HostBridgeEmitMessage => {
|
|
317
|
+
const { eventArgs, requestId } = splitHostBridgeArgs(args as unknown[]);
|
|
318
|
+
return {
|
|
319
|
+
type: AIRJAM_HOST_BRIDGE_EMIT,
|
|
320
|
+
payload: {
|
|
321
|
+
event,
|
|
322
|
+
args: eventArgs,
|
|
323
|
+
...(requestId ? { requestId } : {}),
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export const createHostBridgeResponseMessage = (
|
|
329
|
+
requestId: string,
|
|
330
|
+
ack: unknown,
|
|
331
|
+
): HostBridgeResponseMessage => ({
|
|
332
|
+
type: AIRJAM_HOST_BRIDGE_RESPONSE,
|
|
333
|
+
payload: {
|
|
334
|
+
requestId,
|
|
335
|
+
ack,
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
export const createHostBridgeCloseMessage = (
|
|
340
|
+
reason?: string,
|
|
341
|
+
): HostBridgeCloseMessage => ({
|
|
342
|
+
type: AIRJAM_HOST_BRIDGE_CLOSE,
|
|
343
|
+
payload: {
|
|
344
|
+
reason,
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
export const parseHostBridgeRequestMessage = (
|
|
349
|
+
value: unknown,
|
|
350
|
+
): HostBridgeRequestMessage | null => {
|
|
351
|
+
const result = hostBridgeRequestSchema.safeParse(value);
|
|
352
|
+
return result.success ? (result.data as HostBridgeRequestMessage) : null;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export const parseHostBridgeAttachMessage = (
|
|
356
|
+
value: unknown,
|
|
357
|
+
): HostBridgeAttachMessage | null => {
|
|
358
|
+
const result = hostBridgeAttachSchema.safeParse(value);
|
|
359
|
+
return result.success ? (result.data as HostBridgeAttachMessage) : null;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
export const parseHostBridgeEventMessage = (
|
|
363
|
+
value: unknown,
|
|
364
|
+
): HostBridgeEventMessage | null => {
|
|
365
|
+
const result = hostBridgeEventSchema.safeParse(value);
|
|
366
|
+
return result.success ? (result.data as HostBridgeEventMessage) : null;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
export const parseHostBridgeEmitMessage = (
|
|
370
|
+
value: unknown,
|
|
371
|
+
): HostBridgeEmitMessage | null => {
|
|
372
|
+
const result = hostBridgeEmitSchema.safeParse(value);
|
|
373
|
+
return result.success ? (result.data as HostBridgeEmitMessage) : null;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export const parseHostBridgeResponseMessage = (
|
|
377
|
+
value: unknown,
|
|
378
|
+
): HostBridgeResponseMessage | null => {
|
|
379
|
+
const result = hostBridgeResponseSchema.safeParse(value);
|
|
380
|
+
return result.success ? (result.data as HostBridgeResponseMessage) : null;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export const parseHostBridgeCloseMessage = (
|
|
384
|
+
value: unknown,
|
|
385
|
+
): HostBridgeCloseMessage | null => {
|
|
386
|
+
const result = hostBridgeCloseSchema.safeParse(value);
|
|
387
|
+
return result.success ? (result.data as HostBridgeCloseMessage) : null;
|
|
388
|
+
};
|