@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,25 @@
|
|
|
1
|
+
const AIR_JAM_LOCAL_GAME_PROXY_BASE_WINDOW_KEY =
|
|
2
|
+
"__AIRJAM_LOCAL_GAME_PROXY_BASE__";
|
|
3
|
+
|
|
4
|
+
const normalizeBase = (value: string): string => {
|
|
5
|
+
if (!value || value === "/") {
|
|
6
|
+
return "/";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
|
|
10
|
+
return withLeadingSlash.endsWith("/")
|
|
11
|
+
? withLeadingSlash.slice(0, -1)
|
|
12
|
+
: withLeadingSlash;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const resolveAirJamBrowserRouterBasename = (): string => {
|
|
16
|
+
if (typeof window === "undefined") {
|
|
17
|
+
return "/";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const rawBase = Reflect.get(window, AIR_JAM_LOCAL_GAME_PROXY_BASE_WINDOW_KEY);
|
|
21
|
+
|
|
22
|
+
return typeof rawBase === "string" && rawBase.trim()
|
|
23
|
+
? normalizeBase(rawBase.trim())
|
|
24
|
+
: "/";
|
|
25
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { ResolvedAirJamRuntimeTopology } from "@air-jam/runtime-topology";
|
|
2
|
+
import {
|
|
3
|
+
parseRuntimeTopologyFromSearchParams,
|
|
4
|
+
resolveRuntimeTopology,
|
|
5
|
+
} from "@air-jam/runtime-topology";
|
|
6
|
+
import type { PlayerProfile } from "../protocol";
|
|
7
|
+
import { normalizeRuntimeUrl } from "../protocol/url-policy";
|
|
8
|
+
import { parseOptionalArcadeSurfaceFromSearchParams } from "./arcade-runtime-url";
|
|
9
|
+
import type { ArcadeSurfaceRuntimeIdentity } from "./arcade-surface-identity";
|
|
10
|
+
|
|
11
|
+
export interface ChildHostRuntimeParams {
|
|
12
|
+
room: string;
|
|
13
|
+
capabilityToken: string;
|
|
14
|
+
capabilityExpiresAt?: number;
|
|
15
|
+
joinUrl?: string;
|
|
16
|
+
topology: ResolvedAirJamRuntimeTopology;
|
|
17
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface EmbeddedControllerRuntimeParams {
|
|
21
|
+
room: string;
|
|
22
|
+
controllerId: string;
|
|
23
|
+
topology: ResolvedAirJamRuntimeTopology;
|
|
24
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
25
|
+
playerProfile?: {
|
|
26
|
+
label?: PlayerProfile["label"];
|
|
27
|
+
avatarId?: PlayerProfile["avatarId"];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const parseOrigin = (value: string | null | undefined): string | null => {
|
|
32
|
+
if (!value) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
return new URL(value).origin;
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const resolveLegacyEmbeddedTopology = ({
|
|
44
|
+
surfaceRole,
|
|
45
|
+
joinUrl,
|
|
46
|
+
}: {
|
|
47
|
+
surfaceRole: "host" | "controller";
|
|
48
|
+
joinUrl?: string;
|
|
49
|
+
}): ResolvedAirJamRuntimeTopology | null => {
|
|
50
|
+
if (typeof window === "undefined") {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const appOrigin = window.location.origin;
|
|
55
|
+
const joinUrlOrigin = parseOrigin(joinUrl);
|
|
56
|
+
const referrerOrigin = parseOrigin(document.referrer);
|
|
57
|
+
const embedParentOrigin = joinUrlOrigin ?? referrerOrigin ?? appOrigin;
|
|
58
|
+
const publicHost = joinUrlOrigin ?? appOrigin;
|
|
59
|
+
const secureTransport =
|
|
60
|
+
appOrigin.startsWith("https://") &&
|
|
61
|
+
publicHost.startsWith("https://") &&
|
|
62
|
+
embedParentOrigin.startsWith("https://");
|
|
63
|
+
|
|
64
|
+
return resolveRuntimeTopology({
|
|
65
|
+
runtimeMode: "arcade-live",
|
|
66
|
+
surfaceRole,
|
|
67
|
+
appOrigin,
|
|
68
|
+
backendOrigin: appOrigin,
|
|
69
|
+
socketOrigin: appOrigin,
|
|
70
|
+
publicHost,
|
|
71
|
+
assetBasePath: "/",
|
|
72
|
+
secureTransport,
|
|
73
|
+
embedded: true,
|
|
74
|
+
embedParentOrigin,
|
|
75
|
+
proxyStrategy: "none",
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const readChildHostRuntimeParams = (): ChildHostRuntimeParams | null => {
|
|
80
|
+
if (typeof window === "undefined") {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const params = new URLSearchParams(window.location.search);
|
|
85
|
+
const room = params.get("aj_room");
|
|
86
|
+
const capabilityToken = params.get("aj_cap");
|
|
87
|
+
if (!room || !capabilityToken) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const rawCapabilityExpiresAt = params.get("aj_cap_exp");
|
|
92
|
+
const parsedCapabilityExpiresAt = rawCapabilityExpiresAt
|
|
93
|
+
? Number(rawCapabilityExpiresAt)
|
|
94
|
+
: NaN;
|
|
95
|
+
|
|
96
|
+
const joinUrl = params.get("aj_join_url");
|
|
97
|
+
const normalizedJoinUrl = joinUrl ? normalizeRuntimeUrl(joinUrl) : null;
|
|
98
|
+
const topology =
|
|
99
|
+
parseRuntimeTopologyFromSearchParams(params) ??
|
|
100
|
+
resolveLegacyEmbeddedTopology({
|
|
101
|
+
surfaceRole: "host",
|
|
102
|
+
joinUrl: normalizedJoinUrl ?? undefined,
|
|
103
|
+
});
|
|
104
|
+
if (!topology) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const arcadeSurface = parseOptionalArcadeSurfaceFromSearchParams(params);
|
|
109
|
+
if (!arcadeSurface) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
room,
|
|
115
|
+
capabilityToken,
|
|
116
|
+
capabilityExpiresAt: Number.isFinite(parsedCapabilityExpiresAt)
|
|
117
|
+
? parsedCapabilityExpiresAt
|
|
118
|
+
: undefined,
|
|
119
|
+
joinUrl: normalizedJoinUrl ?? undefined,
|
|
120
|
+
topology,
|
|
121
|
+
arcadeSurface,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const readEmbeddedControllerRuntimeParams =
|
|
126
|
+
(): EmbeddedControllerRuntimeParams | null => {
|
|
127
|
+
if (typeof window === "undefined") {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const params = new URLSearchParams(window.location.search);
|
|
132
|
+
const room = params.get("aj_room");
|
|
133
|
+
const controllerId = params.get("aj_controller_id");
|
|
134
|
+
if (!room || !controllerId) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const topology =
|
|
139
|
+
parseRuntimeTopologyFromSearchParams(params) ??
|
|
140
|
+
resolveLegacyEmbeddedTopology({
|
|
141
|
+
surfaceRole: "controller",
|
|
142
|
+
});
|
|
143
|
+
if (!topology) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const arcadeSurface = parseOptionalArcadeSurfaceFromSearchParams(params);
|
|
148
|
+
if (!arcadeSurface) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const rawLabel = params.get("aj_player_label")?.trim();
|
|
153
|
+
const rawAvatarId = params.get("aj_player_avatar")?.trim();
|
|
154
|
+
const playerProfile =
|
|
155
|
+
rawLabel || rawAvatarId
|
|
156
|
+
? {
|
|
157
|
+
...(rawLabel ? { label: rawLabel } : {}),
|
|
158
|
+
...(rawAvatarId ? { avatarId: rawAvatarId } : {}),
|
|
159
|
+
}
|
|
160
|
+
: undefined;
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
room,
|
|
164
|
+
controllerId,
|
|
165
|
+
topology,
|
|
166
|
+
arcadeSurface,
|
|
167
|
+
...(playerProfile ? { playerProfile } : {}),
|
|
168
|
+
};
|
|
169
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import type { z } from "zod";
|
|
4
|
+
import {
|
|
5
|
+
ControllerSessionProvider,
|
|
6
|
+
HostSessionProvider,
|
|
7
|
+
type AirJamProviderProps,
|
|
8
|
+
} from "../context/session-providers";
|
|
9
|
+
import { useControllerRuntimeApi } from "../hooks/internal/use-controller-runtime-api";
|
|
10
|
+
import { useHostRuntimeApi } from "../hooks/internal/use-host-runtime-api";
|
|
11
|
+
import type { AirJamControllerOptions } from "../hooks/use-air-jam-controller";
|
|
12
|
+
import type { AirJamHostOptions } from "../hooks/use-air-jam-host";
|
|
13
|
+
import {
|
|
14
|
+
useControllerRuntimeInspectionContract,
|
|
15
|
+
useHostRuntimeInspectionContract,
|
|
16
|
+
} from "../runtime-inspection";
|
|
17
|
+
import { PlatformSettingsBoundary } from "../settings/platform-settings-runtime";
|
|
18
|
+
import {
|
|
19
|
+
publishRuntimeInspectionContract,
|
|
20
|
+
readRuntimeInspectionContract,
|
|
21
|
+
} from "./contracts/inspection";
|
|
22
|
+
import {
|
|
23
|
+
controllerRuntimeContext,
|
|
24
|
+
hostRuntimeContext,
|
|
25
|
+
} from "./runtime-owner-contexts";
|
|
26
|
+
|
|
27
|
+
export type AirJamHostRuntimeProps<TSchema extends z.ZodSchema = z.ZodSchema> =
|
|
28
|
+
AirJamProviderProps<TSchema> &
|
|
29
|
+
AirJamHostOptions & {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type AirJamControllerRuntimeProps = AirJamProviderProps &
|
|
34
|
+
AirJamControllerOptions & {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const HostRuntimeInspectionPublisher = (): null => {
|
|
39
|
+
const inspection = useHostRuntimeInspectionContract();
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (typeof window === "undefined") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
publishRuntimeInspectionContract(window, inspection);
|
|
47
|
+
return () => {
|
|
48
|
+
if (readRuntimeInspectionContract(window)?.role === "host") {
|
|
49
|
+
publishRuntimeInspectionContract(window, null);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}, [inspection]);
|
|
53
|
+
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const ControllerRuntimeInspectionPublisher = (): null => {
|
|
58
|
+
const inspection = useControllerRuntimeInspectionContract();
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (typeof window === "undefined") {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
publishRuntimeInspectionContract(window, inspection);
|
|
66
|
+
return () => {
|
|
67
|
+
if (readRuntimeInspectionContract(window)?.role === "controller") {
|
|
68
|
+
publishRuntimeInspectionContract(window, null);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [inspection]);
|
|
72
|
+
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const HostRuntimeOwner = <TSchema extends z.ZodSchema = z.ZodSchema>({
|
|
77
|
+
children,
|
|
78
|
+
roomId,
|
|
79
|
+
onPlayerJoin,
|
|
80
|
+
onPlayerLeave,
|
|
81
|
+
}: Pick<
|
|
82
|
+
AirJamHostRuntimeProps<TSchema>,
|
|
83
|
+
"children" | "roomId" | "onPlayerJoin" | "onPlayerLeave"
|
|
84
|
+
>): JSX.Element => {
|
|
85
|
+
const runtime = useHostRuntimeApi<TSchema>(
|
|
86
|
+
{
|
|
87
|
+
roomId,
|
|
88
|
+
onPlayerJoin,
|
|
89
|
+
onPlayerLeave,
|
|
90
|
+
},
|
|
91
|
+
"AirJamHostRuntime",
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<hostRuntimeContext.Provider value={runtime}>
|
|
96
|
+
<HostRuntimeInspectionPublisher />
|
|
97
|
+
{children}
|
|
98
|
+
</hostRuntimeContext.Provider>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const ControllerRuntimeOwner = ({
|
|
103
|
+
children,
|
|
104
|
+
roomId,
|
|
105
|
+
nickname,
|
|
106
|
+
avatarId,
|
|
107
|
+
controllerId,
|
|
108
|
+
capabilityToken,
|
|
109
|
+
onState,
|
|
110
|
+
}: Pick<
|
|
111
|
+
AirJamControllerRuntimeProps,
|
|
112
|
+
| "children"
|
|
113
|
+
| "roomId"
|
|
114
|
+
| "nickname"
|
|
115
|
+
| "avatarId"
|
|
116
|
+
| "controllerId"
|
|
117
|
+
| "capabilityToken"
|
|
118
|
+
| "onState"
|
|
119
|
+
>): JSX.Element => {
|
|
120
|
+
const runtime = useControllerRuntimeApi(
|
|
121
|
+
{
|
|
122
|
+
roomId,
|
|
123
|
+
nickname,
|
|
124
|
+
avatarId,
|
|
125
|
+
controllerId,
|
|
126
|
+
capabilityToken,
|
|
127
|
+
onState,
|
|
128
|
+
},
|
|
129
|
+
"AirJamControllerRuntime",
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<controllerRuntimeContext.Provider value={runtime}>
|
|
134
|
+
<ControllerRuntimeInspectionPublisher />
|
|
135
|
+
{children}
|
|
136
|
+
</controllerRuntimeContext.Provider>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const AirJamHostRuntime = <TSchema extends z.ZodSchema = z.ZodSchema>({
|
|
141
|
+
children,
|
|
142
|
+
roomId,
|
|
143
|
+
onPlayerJoin,
|
|
144
|
+
onPlayerLeave,
|
|
145
|
+
...providerProps
|
|
146
|
+
}: AirJamHostRuntimeProps<TSchema>): JSX.Element => {
|
|
147
|
+
return (
|
|
148
|
+
<HostSessionProvider<TSchema> {...providerProps}>
|
|
149
|
+
<PlatformSettingsBoundary>
|
|
150
|
+
<HostRuntimeOwner<TSchema>
|
|
151
|
+
roomId={roomId}
|
|
152
|
+
onPlayerJoin={onPlayerJoin}
|
|
153
|
+
onPlayerLeave={onPlayerLeave}
|
|
154
|
+
>
|
|
155
|
+
{children}
|
|
156
|
+
</HostRuntimeOwner>
|
|
157
|
+
</PlatformSettingsBoundary>
|
|
158
|
+
</HostSessionProvider>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const AirJamControllerRuntime = ({
|
|
163
|
+
children,
|
|
164
|
+
roomId,
|
|
165
|
+
nickname,
|
|
166
|
+
avatarId,
|
|
167
|
+
controllerId,
|
|
168
|
+
capabilityToken,
|
|
169
|
+
onState,
|
|
170
|
+
...providerProps
|
|
171
|
+
}: AirJamControllerRuntimeProps): JSX.Element => {
|
|
172
|
+
return (
|
|
173
|
+
<ControllerSessionProvider {...providerProps}>
|
|
174
|
+
<PlatformSettingsBoundary>
|
|
175
|
+
<ControllerRuntimeOwner
|
|
176
|
+
roomId={roomId}
|
|
177
|
+
nickname={nickname}
|
|
178
|
+
avatarId={avatarId}
|
|
179
|
+
controllerId={controllerId}
|
|
180
|
+
capabilityToken={capabilityToken}
|
|
181
|
+
onState={onState}
|
|
182
|
+
>
|
|
183
|
+
{children}
|
|
184
|
+
</ControllerRuntimeOwner>
|
|
185
|
+
</PlatformSettingsBoundary>
|
|
186
|
+
</ControllerSessionProvider>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ArcadeSurfaceRuntimeIdentity } from "./arcade-surface-identity";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validates an embedded bridge attach against monotonic Arcade surface epochs.
|
|
5
|
+
*/
|
|
6
|
+
export const validateArcadeBridgeAttachEpoch = (
|
|
7
|
+
lastEpoch: number | null,
|
|
8
|
+
identity: ArcadeSurfaceRuntimeIdentity,
|
|
9
|
+
): { ok: true; nextLast: number | null } | { ok: false } => {
|
|
10
|
+
if (lastEpoch !== null && identity.epoch < lastEpoch) {
|
|
11
|
+
return { ok: false };
|
|
12
|
+
}
|
|
13
|
+
return { ok: true, nextLast: identity.epoch };
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {
|
|
2
|
+
useControllerRuntimeControlContract,
|
|
3
|
+
useHostRuntimeControlContract,
|
|
4
|
+
} from "./hooks/internal/use-runtime-control-contract";
|
|
5
|
+
export {
|
|
6
|
+
createControllerRuntimeControlContract,
|
|
7
|
+
createHostRuntimeControlContract,
|
|
8
|
+
type ControllerRuntimeControlContract,
|
|
9
|
+
type HostRuntimeControlContract,
|
|
10
|
+
} from "./runtime/contracts/control";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
useControllerRuntimeInspectionContract,
|
|
3
|
+
useHostRuntimeInspectionContract,
|
|
4
|
+
} from "./hooks/internal/use-runtime-inspection-contract";
|
|
5
|
+
export {
|
|
6
|
+
AIR_JAM_RUNTIME_INSPECTION_KEY,
|
|
7
|
+
createControllerRuntimeInspectionContract,
|
|
8
|
+
createHostRuntimeInspectionContract,
|
|
9
|
+
publishRuntimeInspectionContract,
|
|
10
|
+
readRuntimeInspectionContract,
|
|
11
|
+
type ControllerRuntimeInspectionContract,
|
|
12
|
+
type HostRuntimeInspectionContract,
|
|
13
|
+
type RuntimeInspectionContract,
|
|
14
|
+
} from "./runtime/contracts/inspection";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { useRuntimeObservabilitySubscription } from "./hooks/internal/use-runtime-observability-contract";
|
|
2
|
+
export {
|
|
3
|
+
createRuntimeObservabilityEvent,
|
|
4
|
+
matchesRuntimeObservabilityFilter,
|
|
5
|
+
subscribeToRuntimeObservability,
|
|
6
|
+
type RuntimeObservabilityEvent,
|
|
7
|
+
type RuntimeObservabilityEventHandler,
|
|
8
|
+
type RuntimeObservabilityFilter,
|
|
9
|
+
} from "./runtime/contracts/observability";
|