@air-jam/sdk 0.1.4 → 0.9.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/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 +481 -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 +14 -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 +544 -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 +29 -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 +1737 -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 +123 -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-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-7UXSWCZZ.js +32 -0
- package/dist/chunk-7UXSWCZZ.js.map +1 -0
- package/dist/chunk-BE6Z4SIT.js +65 -0
- package/dist/chunk-BE6Z4SIT.js.map +1 -0
- package/dist/chunk-CABEUV65.js +184 -0
- package/dist/chunk-CABEUV65.js.map +1 -0
- package/dist/chunk-CEJ5RFSG.js +288 -0
- package/dist/chunk-CEJ5RFSG.js.map +1 -0
- package/dist/chunk-EDRQIOCV.js +25 -0
- package/dist/chunk-EDRQIOCV.js.map +1 -0
- package/dist/chunk-EVZJA6RN.js +140 -0
- package/dist/chunk-EVZJA6RN.js.map +1 -0
- package/dist/chunk-FAT2KJ3K.js +238 -0
- package/dist/chunk-FAT2KJ3K.js.map +1 -0
- package/dist/chunk-IKKDONQL.js +1 -0
- package/dist/chunk-IKKDONQL.js.map +1 -0
- package/dist/chunk-JEHV5C2X.js +249 -0
- package/dist/chunk-JEHV5C2X.js.map +1 -0
- package/dist/chunk-JO2HR5PV.js +43 -0
- package/dist/chunk-JO2HR5PV.js.map +1 -0
- package/dist/chunk-JTF47B56.js +1 -0
- package/dist/chunk-JTF47B56.js.map +1 -0
- package/dist/chunk-KXAFI5OP.js +193 -0
- package/dist/chunk-KXAFI5OP.js.map +1 -0
- package/dist/chunk-LIXPF4P6.js +22 -0
- package/dist/chunk-LIXPF4P6.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-NUJBMV3O.js +1435 -0
- package/dist/chunk-NUJBMV3O.js.map +1 -0
- package/dist/chunk-TGRTEWYV.js +195 -0
- package/dist/chunk-TGRTEWYV.js.map +1 -0
- package/dist/chunk-UWJOIVON.js +369 -0
- package/dist/chunk-UWJOIVON.js.map +1 -0
- package/dist/chunk-VKBMZHMQ.js +216 -0
- package/dist/chunk-VKBMZHMQ.js.map +1 -0
- package/dist/chunk-W2VK36RO.js +11 -0
- package/dist/chunk-W2VK36RO.js.map +1 -0
- package/dist/chunk-W3YA5BWR.js +126 -0
- package/dist/chunk-W3YA5BWR.js.map +1 -0
- package/dist/chunk-X24K52DG.js +12 -0
- package/dist/chunk-X24K52DG.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 +8730 -3426
- 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 -3196
- 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 +2620 -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/runtime-topology.cjs +405 -0
- package/dist/runtime-topology.cjs.map +1 -0
- package/dist/runtime-topology.d.cts +59 -0
- package/dist/runtime-topology.d.ts +59 -0
- package/dist/runtime-topology.js +31 -0
- package/dist/runtime-topology.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 +3061 -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 +1719 -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 +155 -10
- 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 -13
- 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 -161
- 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 -24
- 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/runtime-topology.ts +569 -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 -520
- 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,260 @@
|
|
|
1
|
+
import type { ResolvedAirJamRuntimeTopology } from "../runtime-topology";
|
|
2
|
+
import { resolveProjectRuntimeTopology } from "../runtime-topology";
|
|
3
|
+
import type { JSX, ReactNode } from "react";
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
import type { AirJamAgentContract } from "../agent/agent-contract";
|
|
6
|
+
import type { AirJamGameCapabilityManifest } from "../capabilities/manifest";
|
|
7
|
+
import { CONTROLLER_PATH } from "../constants";
|
|
8
|
+
import { type AirJamProviderProps } from "../context/session-providers";
|
|
9
|
+
import type { AirJamControllerOptions } from "../hooks/use-air-jam-controller";
|
|
10
|
+
import type { AirJamHostOptions } from "../hooks/use-air-jam-host";
|
|
11
|
+
import type { AirJamGameMetadata } from "../metadata/manifest";
|
|
12
|
+
import { type ResolveAirJamConfigInput } from "./air-jam-config";
|
|
13
|
+
import {
|
|
14
|
+
AirJamErrorBoundary,
|
|
15
|
+
type AirJamErrorBoundaryProps,
|
|
16
|
+
type AirJamErrorFallbackRenderer,
|
|
17
|
+
} from "./air-jam-error-boundary";
|
|
18
|
+
import { AirJamControllerRuntime, AirJamHostRuntime } from "./session-runtimes";
|
|
19
|
+
|
|
20
|
+
type HostSessionProps<TSchema extends z.ZodSchema> = Omit<
|
|
21
|
+
AirJamProviderProps<TSchema>,
|
|
22
|
+
"children"
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
type ControllerSessionProps = Omit<AirJamProviderProps, "children" | "input">;
|
|
26
|
+
|
|
27
|
+
export interface AirJamRuntimeErrorBoundaryOptions {
|
|
28
|
+
renderFallback?: AirJamErrorFallbackRenderer;
|
|
29
|
+
onError?: AirJamErrorBoundaryProps["onError"];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface AirJamAppErrorBoundaryOptions {
|
|
33
|
+
host?: AirJamRuntimeErrorBoundaryOptions;
|
|
34
|
+
controller?: AirJamRuntimeErrorBoundaryOptions;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CreateAirJamAppOptions<
|
|
38
|
+
TSchema extends z.ZodSchema = z.ZodSchema,
|
|
39
|
+
> {
|
|
40
|
+
runtime?: ResolveAirJamConfigInput;
|
|
41
|
+
metadata?: AirJamGameMetadata;
|
|
42
|
+
/**
|
|
43
|
+
* Controller route path relative to the app origin.
|
|
44
|
+
* Defaults to "/controller".
|
|
45
|
+
*/
|
|
46
|
+
controllerPath?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Experimental capability metadata for future agent-facing control,
|
|
49
|
+
* inspection, and evaluation workflows.
|
|
50
|
+
*/
|
|
51
|
+
capabilities?: AirJamGameCapabilityManifest;
|
|
52
|
+
/**
|
|
53
|
+
* Optional semantic agent contract published by the app.
|
|
54
|
+
*/
|
|
55
|
+
agent?: AirJamAgentContract;
|
|
56
|
+
input?: AirJamProviderProps<TSchema>["input"];
|
|
57
|
+
errorBoundary?: AirJamAppErrorBoundaryOptions;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface AirJamApp<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
61
|
+
Host: (props: AirJamHostOptions & { children: ReactNode }) => JSX.Element;
|
|
62
|
+
Controller: (
|
|
63
|
+
props: AirJamControllerOptions & { children: ReactNode },
|
|
64
|
+
) => JSX.Element;
|
|
65
|
+
paths: {
|
|
66
|
+
controller: string;
|
|
67
|
+
};
|
|
68
|
+
session: {
|
|
69
|
+
host: HostSessionProps<TSchema>;
|
|
70
|
+
controller: ControllerSessionProps;
|
|
71
|
+
};
|
|
72
|
+
runtime: ResolveAirJamConfigInput;
|
|
73
|
+
metadata?: AirJamGameMetadata;
|
|
74
|
+
controllerPath: string;
|
|
75
|
+
capabilities?: AirJamGameCapabilityManifest;
|
|
76
|
+
agent?: AirJamAgentContract;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const resolveControllerPath = (controllerPath?: string): string => {
|
|
80
|
+
const normalized = controllerPath ?? CONTROLLER_PATH;
|
|
81
|
+
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export interface ViteEnvLike {
|
|
85
|
+
DEV?: boolean;
|
|
86
|
+
VITE_AIR_JAM_RUNTIME_TOPOLOGY?: string;
|
|
87
|
+
VITE_AIR_JAM_SERVER_URL?: string;
|
|
88
|
+
VITE_AIR_JAM_APP_ID?: string;
|
|
89
|
+
VITE_AIR_JAM_HOST_GRANT_ENDPOINT?: string;
|
|
90
|
+
VITE_AIR_JAM_PUBLIC_HOST?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type ViteEnvSource = Record<string, unknown> | undefined;
|
|
94
|
+
|
|
95
|
+
const toViteEnvLike = (source?: ViteEnvSource): ViteEnvLike | undefined => {
|
|
96
|
+
if (!source) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const readString = (key: keyof ViteEnvLike): string | undefined => {
|
|
101
|
+
const value = source[key];
|
|
102
|
+
return typeof value === "string" ? value : undefined;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
DEV: source.DEV === true,
|
|
107
|
+
VITE_AIR_JAM_RUNTIME_TOPOLOGY: readString("VITE_AIR_JAM_RUNTIME_TOPOLOGY"),
|
|
108
|
+
VITE_AIR_JAM_SERVER_URL: readString("VITE_AIR_JAM_SERVER_URL"),
|
|
109
|
+
VITE_AIR_JAM_APP_ID: readString("VITE_AIR_JAM_APP_ID"),
|
|
110
|
+
VITE_AIR_JAM_HOST_GRANT_ENDPOINT: readString(
|
|
111
|
+
"VITE_AIR_JAM_HOST_GRANT_ENDPOINT",
|
|
112
|
+
),
|
|
113
|
+
VITE_AIR_JAM_PUBLIC_HOST: readString("VITE_AIR_JAM_PUBLIC_HOST"),
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const readViteEnv = (): ViteEnvLike | null => {
|
|
118
|
+
try {
|
|
119
|
+
const candidate = import.meta as ImportMeta & { env?: ViteEnvLike };
|
|
120
|
+
if (candidate && typeof candidate.env === "object") {
|
|
121
|
+
return candidate.env;
|
|
122
|
+
}
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const env = {
|
|
130
|
+
auto: (): ResolveAirJamConfigInput => ({
|
|
131
|
+
resolveEnv: true,
|
|
132
|
+
}),
|
|
133
|
+
vite: (viteEnvInput?: ViteEnvSource): ResolveAirJamConfigInput => {
|
|
134
|
+
const viteEnv = toViteEnvLike(viteEnvInput) ?? readViteEnv();
|
|
135
|
+
const explicitTopology = viteEnv?.VITE_AIR_JAM_RUNTIME_TOPOLOGY
|
|
136
|
+
? (JSON.parse(
|
|
137
|
+
viteEnv.VITE_AIR_JAM_RUNTIME_TOPOLOGY,
|
|
138
|
+
) as ResolvedAirJamRuntimeTopology)
|
|
139
|
+
: null;
|
|
140
|
+
const projectTopology =
|
|
141
|
+
!explicitTopology && viteEnv?.VITE_AIR_JAM_PUBLIC_HOST
|
|
142
|
+
? resolveProjectRuntimeTopology({
|
|
143
|
+
runtimeMode: viteEnv.DEV
|
|
144
|
+
? viteEnv.VITE_AIR_JAM_PUBLIC_HOST.startsWith("https://")
|
|
145
|
+
? "standalone-secure"
|
|
146
|
+
: "standalone-dev"
|
|
147
|
+
: "self-hosted-production",
|
|
148
|
+
surfaceRole: "host",
|
|
149
|
+
appOrigin: viteEnv.VITE_AIR_JAM_PUBLIC_HOST,
|
|
150
|
+
backendOrigin:
|
|
151
|
+
viteEnv.VITE_AIR_JAM_SERVER_URL ||
|
|
152
|
+
viteEnv.VITE_AIR_JAM_PUBLIC_HOST,
|
|
153
|
+
publicHost: viteEnv.VITE_AIR_JAM_PUBLIC_HOST,
|
|
154
|
+
secureTransport:
|
|
155
|
+
viteEnv.VITE_AIR_JAM_PUBLIC_HOST.startsWith("https://"),
|
|
156
|
+
})
|
|
157
|
+
: null;
|
|
158
|
+
return {
|
|
159
|
+
...(explicitTopology || projectTopology
|
|
160
|
+
? { topology: explicitTopology ?? projectTopology ?? undefined }
|
|
161
|
+
: {}),
|
|
162
|
+
appId: viteEnv?.VITE_AIR_JAM_APP_ID,
|
|
163
|
+
hostGrantEndpoint: viteEnv?.VITE_AIR_JAM_HOST_GRANT_ENDPOINT,
|
|
164
|
+
resolveEnv: explicitTopology || projectTopology ? false : true,
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
next: (): ResolveAirJamConfigInput => ({
|
|
168
|
+
resolveEnv: true,
|
|
169
|
+
}),
|
|
170
|
+
explicit: (
|
|
171
|
+
runtime: Omit<ResolveAirJamConfigInput, "resolveEnv">,
|
|
172
|
+
): ResolveAirJamConfigInput => ({
|
|
173
|
+
...runtime,
|
|
174
|
+
resolveEnv: false,
|
|
175
|
+
}),
|
|
176
|
+
} as const;
|
|
177
|
+
|
|
178
|
+
export const createAirJamApp = <TSchema extends z.ZodSchema = z.ZodSchema>({
|
|
179
|
+
runtime = {},
|
|
180
|
+
metadata,
|
|
181
|
+
controllerPath: requestedControllerPath,
|
|
182
|
+
capabilities,
|
|
183
|
+
agent,
|
|
184
|
+
input,
|
|
185
|
+
errorBoundary,
|
|
186
|
+
}: CreateAirJamAppOptions<TSchema> = {}): AirJamApp<TSchema> => {
|
|
187
|
+
const controllerPath = resolveControllerPath(requestedControllerPath);
|
|
188
|
+
|
|
189
|
+
const hostSession: HostSessionProps<TSchema> = input
|
|
190
|
+
? {
|
|
191
|
+
...runtime,
|
|
192
|
+
hostSessionKind: runtime.hostSessionKind ?? "game",
|
|
193
|
+
input,
|
|
194
|
+
}
|
|
195
|
+
: {
|
|
196
|
+
...runtime,
|
|
197
|
+
hostSessionKind: runtime.hostSessionKind ?? "game",
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const controllerSession: ControllerSessionProps = {
|
|
201
|
+
...runtime,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const Host = ({
|
|
205
|
+
children,
|
|
206
|
+
...runtimeOptions
|
|
207
|
+
}: AirJamHostOptions & { children: ReactNode }): JSX.Element => {
|
|
208
|
+
const hostErrorBoundary = errorBoundary?.host;
|
|
209
|
+
return (
|
|
210
|
+
<AirJamErrorBoundary
|
|
211
|
+
role="host"
|
|
212
|
+
roomId={runtimeOptions.roomId}
|
|
213
|
+
appId={hostSession.appId}
|
|
214
|
+
renderFallback={hostErrorBoundary?.renderFallback}
|
|
215
|
+
onError={hostErrorBoundary?.onError}
|
|
216
|
+
>
|
|
217
|
+
<AirJamHostRuntime<TSchema> {...hostSession} {...runtimeOptions}>
|
|
218
|
+
{children}
|
|
219
|
+
</AirJamHostRuntime>
|
|
220
|
+
</AirJamErrorBoundary>
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const Controller = ({
|
|
225
|
+
children,
|
|
226
|
+
...runtimeOptions
|
|
227
|
+
}: AirJamControllerOptions & { children: ReactNode }): JSX.Element => {
|
|
228
|
+
const controllerErrorBoundary = errorBoundary?.controller;
|
|
229
|
+
return (
|
|
230
|
+
<AirJamErrorBoundary
|
|
231
|
+
role="controller"
|
|
232
|
+
roomId={runtimeOptions.roomId}
|
|
233
|
+
appId={controllerSession.appId}
|
|
234
|
+
renderFallback={controllerErrorBoundary?.renderFallback}
|
|
235
|
+
onError={controllerErrorBoundary?.onError}
|
|
236
|
+
>
|
|
237
|
+
<AirJamControllerRuntime {...controllerSession} {...runtimeOptions}>
|
|
238
|
+
{children}
|
|
239
|
+
</AirJamControllerRuntime>
|
|
240
|
+
</AirJamErrorBoundary>
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
Host,
|
|
246
|
+
Controller,
|
|
247
|
+
paths: {
|
|
248
|
+
controller: controllerPath,
|
|
249
|
+
},
|
|
250
|
+
session: {
|
|
251
|
+
host: hostSession,
|
|
252
|
+
controller: controllerSession,
|
|
253
|
+
},
|
|
254
|
+
runtime,
|
|
255
|
+
metadata,
|
|
256
|
+
controllerPath,
|
|
257
|
+
capabilities,
|
|
258
|
+
agent,
|
|
259
|
+
};
|
|
260
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RuntimeKind } from "../contracts/v2";
|
|
2
|
+
import type { AirJamDevLogEventName } from "../protocol";
|
|
3
|
+
|
|
4
|
+
export const AIRJAM_DEV_LOG_SINK_FAILURE = "AIRJAM_DEV_LOG_SINK_FAILURE";
|
|
5
|
+
export const AIRJAM_DEV_PROVIDER_MOUNTED = "AIRJAM_DEV_PROVIDER_MOUNTED";
|
|
6
|
+
export const AIRJAM_DEV_RUNTIME_EVENT = "AIRJAM_DEV_RUNTIME_EVENT";
|
|
7
|
+
|
|
8
|
+
export type AirJamDevRuntimeLogLevel = "info" | "warn" | "error";
|
|
9
|
+
|
|
10
|
+
export interface AirJamDevRuntimeEventDetail {
|
|
11
|
+
event: AirJamDevLogEventName;
|
|
12
|
+
message: string;
|
|
13
|
+
level?: AirJamDevRuntimeLogLevel;
|
|
14
|
+
code?: string;
|
|
15
|
+
role?: "host" | "controller";
|
|
16
|
+
traceId?: string;
|
|
17
|
+
roomId?: string;
|
|
18
|
+
controllerId?: string;
|
|
19
|
+
runtimeEpoch?: number;
|
|
20
|
+
runtimeKind?: RuntimeKind;
|
|
21
|
+
data?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const emitAirJamDevRuntimeEvent = (
|
|
25
|
+
detail: AirJamDevRuntimeEventDetail,
|
|
26
|
+
): void => {
|
|
27
|
+
if (typeof window === "undefined" || typeof CustomEvent === "undefined") {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
window.dispatchEvent(
|
|
32
|
+
new CustomEvent<AirJamDevRuntimeEventDetail>(AIRJAM_DEV_RUNTIME_EVENT, {
|
|
33
|
+
detail,
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ResolvedAirJamRuntimeTopology } from "../runtime-topology";
|
|
2
|
+
import type { RoomCode } from "../protocol";
|
|
3
|
+
import { roomCodeSchema } from "../protocol";
|
|
4
|
+
import type { ArcadeSurfaceRuntimeIdentity } from "./arcade-surface-identity";
|
|
5
|
+
import {
|
|
6
|
+
readChildHostRuntimeParams,
|
|
7
|
+
readEmbeddedControllerRuntimeParams,
|
|
8
|
+
} from "./runtime-session-params";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Embedded host session for a game running inside the platform shell iframe (`aj_room`, `aj_cap`, …).
|
|
12
|
+
* Standalone hosts do not produce this snapshot — they use normal room create/reconnect flow.
|
|
13
|
+
*/
|
|
14
|
+
export type EmbeddedHostChildSession = {
|
|
15
|
+
roomId: RoomCode;
|
|
16
|
+
joinUrl?: string;
|
|
17
|
+
topology: ResolvedAirJamRuntimeTopology;
|
|
18
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Embedded controller session for the secondary controller iframe (`aj_room`, `aj_controller_id`, …).
|
|
23
|
+
*/
|
|
24
|
+
export type EmbeddedControllerChildSession = {
|
|
25
|
+
roomId: RoomCode;
|
|
26
|
+
controllerId: string;
|
|
27
|
+
topology: ResolvedAirJamRuntimeTopology;
|
|
28
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
29
|
+
playerProfile?: {
|
|
30
|
+
label?: string;
|
|
31
|
+
avatarId?: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Reads and validates embedded host bootstrap from the current window URL, or `null` if not embedded.
|
|
37
|
+
*/
|
|
38
|
+
export const readEmbeddedHostChildSession =
|
|
39
|
+
(): EmbeddedHostChildSession | null => {
|
|
40
|
+
const raw = readChildHostRuntimeParams();
|
|
41
|
+
if (!raw) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
roomId: roomCodeSchema.parse(raw.room.toUpperCase()),
|
|
46
|
+
joinUrl: raw.joinUrl,
|
|
47
|
+
topology: raw.topology,
|
|
48
|
+
arcadeSurface: raw.arcadeSurface,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Reads and validates embedded controller bootstrap from the current window URL, or `null` if not embedded.
|
|
54
|
+
*/
|
|
55
|
+
export const readEmbeddedControllerChildSession =
|
|
56
|
+
(): EmbeddedControllerChildSession | null => {
|
|
57
|
+
const raw = readEmbeddedControllerRuntimeParams();
|
|
58
|
+
if (!raw) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
roomId: roomCodeSchema.parse(raw.room.toUpperCase()),
|
|
63
|
+
controllerId: raw.controllerId,
|
|
64
|
+
topology: raw.topology,
|
|
65
|
+
arcadeSurface: raw.arcadeSurface,
|
|
66
|
+
...(raw.playerProfile ? { playerProfile: raw.playerProfile } : {}),
|
|
67
|
+
};
|
|
68
|
+
};
|