@air-jam/sdk 0.9.1 → 0.9.3
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 +25 -45
- package/dist/{agent-tooling-BSMGBix9.d.cts → agent-contract-CD2QnbBJ.d.cts} +1 -1
- package/dist/{agent-tooling-BSMGBix9.d.ts → agent-contract-CD2QnbBJ.d.ts} +1 -1
- package/dist/agent-tooling.cjs +139 -0
- package/dist/agent-tooling.cjs.map +1 -1
- package/dist/agent-tooling.d.cts +25 -1
- package/dist/agent-tooling.d.ts +25 -1
- package/dist/agent-tooling.js +138 -0
- package/dist/agent-tooling.js.map +1 -1
- package/dist/air-jam-context-BlLPvCup.d.cts +175 -0
- package/dist/air-jam-context-DTsxF-tP.d.ts +175 -0
- package/dist/arcade/bridge/controller.cjs +214 -194
- package/dist/arcade/bridge/controller.cjs.map +1 -1
- package/dist/arcade/bridge/controller.d.cts +2 -2
- package/dist/arcade/bridge/controller.d.ts +2 -2
- package/dist/arcade/bridge/controller.js +6 -4
- package/dist/arcade/bridge/host.cjs +1 -1
- package/dist/arcade/bridge/host.cjs.map +1 -1
- package/dist/arcade/bridge/host.d.cts +3 -3
- package/dist/arcade/bridge/host.d.ts +3 -3
- package/dist/arcade/bridge/host.js +4 -3
- package/dist/arcade/bridge/iframe.cjs +1 -1
- package/dist/arcade/bridge/iframe.cjs.map +1 -1
- package/dist/arcade/bridge/iframe.d.cts +2 -2
- package/dist/arcade/bridge/iframe.d.ts +2 -2
- package/dist/arcade/bridge/iframe.js +4 -4
- package/dist/arcade/bridge.cjs +251 -231
- package/dist/arcade/bridge.cjs.map +1 -1
- package/dist/arcade/bridge.d.cts +4 -4
- package/dist/arcade/bridge.d.ts +4 -4
- package/dist/arcade/bridge.js +9 -7
- package/dist/arcade/host.cjs +145 -122
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.d.cts +5 -4
- package/dist/arcade/host.d.ts +5 -4
- package/dist/arcade/host.js +6 -5
- package/dist/arcade/runtime.cjs +6499 -0
- package/dist/arcade/runtime.cjs.map +1 -0
- package/dist/arcade/runtime.d.cts +22 -0
- package/dist/arcade/runtime.d.ts +22 -0
- package/dist/arcade/runtime.js +32 -0
- package/dist/arcade/runtime.js.map +1 -0
- package/dist/arcade/surface.cjs +9 -0
- package/dist/arcade/surface.cjs.map +1 -1
- package/dist/arcade/surface.d.cts +6 -1
- package/dist/arcade/surface.d.ts +6 -1
- package/dist/arcade/surface.js +6 -2
- package/dist/arcade/url.d.cts +4 -4
- package/dist/arcade/url.d.ts +4 -4
- package/dist/arcade/url.js +5 -5
- package/dist/arcade.cjs +322 -292
- package/dist/arcade.cjs.map +1 -1
- package/dist/arcade.d.cts +6 -6
- package/dist/arcade.d.ts +6 -6
- package/dist/arcade.js +35 -29
- package/dist/{chunk-CEJ5RFSG.js → chunk-2SZ2YYGJ.js} +8 -16
- package/dist/chunk-2SZ2YYGJ.js.map +1 -0
- package/dist/{chunk-VKBMZHMQ.js → chunk-32RSSFSF.js} +10 -12
- package/dist/chunk-32RSSFSF.js.map +1 -0
- package/dist/chunk-3YMUAKPU.js +10 -0
- package/dist/chunk-3YMUAKPU.js.map +1 -0
- package/dist/chunk-56DM2KEW.js +14 -0
- package/dist/chunk-56DM2KEW.js.map +1 -0
- package/dist/chunk-CM53YLT5.js +59 -0
- package/dist/chunk-CM53YLT5.js.map +1 -0
- package/dist/{chunk-JEHV5C2X.js → chunk-CV3PBXPT.js} +3 -3
- package/dist/chunk-D4VDEVTZ.js +80 -0
- package/dist/chunk-D4VDEVTZ.js.map +1 -0
- package/dist/{chunk-W3YA5BWR.js → chunk-FUA6EMSJ.js} +24 -60
- package/dist/chunk-FUA6EMSJ.js.map +1 -0
- package/dist/chunk-GMLU7RI5.js +70 -0
- package/dist/chunk-GMLU7RI5.js.map +1 -0
- package/dist/{chunk-NCL6WJCL.js → chunk-IG6GZZSS.js} +32 -1
- package/dist/chunk-IG6GZZSS.js.map +1 -0
- package/dist/{chunk-EDRQIOCV.js → chunk-ITMQSBTH.js} +3 -2
- package/dist/chunk-ITMQSBTH.js.map +1 -0
- package/dist/{chunk-32NYL7XI.js → chunk-J5MCII33.js} +189 -108
- package/dist/chunk-J5MCII33.js.map +1 -0
- package/dist/{chunk-ZLPL2R3R.js → chunk-K4OZ54UD.js} +7 -34
- package/dist/chunk-K4OZ54UD.js.map +1 -0
- package/dist/{chunk-KXAFI5OP.js → chunk-LIHEEAVE.js} +9 -11
- package/dist/chunk-LIHEEAVE.js.map +1 -0
- package/dist/{chunk-FAT2KJ3K.js → chunk-MIMPMB7O.js} +2 -2
- package/dist/{chunk-NUJBMV3O.js → chunk-O6X7FJ6N.js} +29 -32
- package/dist/chunk-O6X7FJ6N.js.map +1 -0
- package/dist/chunk-PSUYTD2L.js +16 -0
- package/dist/chunk-PSUYTD2L.js.map +1 -0
- package/dist/{chunk-7UXSWCZZ.js → chunk-QO4KFUEI.js} +2 -2
- package/dist/chunk-QTLYZADF.js +125 -0
- package/dist/chunk-QTLYZADF.js.map +1 -0
- package/dist/chunk-TTQDHKXL.js +3017 -0
- package/dist/chunk-TTQDHKXL.js.map +1 -0
- package/dist/chunk-UCPY7UJC.js +8 -0
- package/dist/chunk-UCPY7UJC.js.map +1 -0
- package/dist/{chunk-JO2HR5PV.js → chunk-UPV6YWT5.js} +4 -4
- package/dist/chunk-X35LLCWV.js +65 -0
- package/dist/chunk-X35LLCWV.js.map +1 -0
- package/dist/{controller-DxVchfiA.d.ts → controller-PZEM_1cH.d.ts} +6 -2
- package/dist/{controller-Bod8YYr1.d.cts → controller-vj82tKm4.d.cts} +6 -2
- package/dist/{dev-log-events-CVAM29hx.d.cts → dev-log-events-BCJKmygo.d.cts} +0 -3
- package/dist/{dev-log-events-CVAM29hx.d.ts → dev-log-events-BCJKmygo.d.ts} +0 -3
- package/dist/{host-8hmq_Sgc.d.cts → host-B9pRy0Aa.d.cts} +20 -7
- package/dist/{host-Cw-N6e-5.d.ts → host-DylGsX7p.d.ts} +20 -7
- package/dist/index.cjs +4275 -3813
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -642
- package/dist/index.d.ts +40 -642
- package/dist/index.js +1032 -3658
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +2 -3
- package/dist/metadata.d.ts +2 -3
- package/dist/metadata.js.map +1 -1
- package/dist/{notices-CnGaaS8B.d.ts → notices-C4bao3oi.d.ts} +1 -1
- package/dist/{notices-NyDM5Mtz.d.cts → notices-DNdOjwtj.d.cts} +1 -1
- package/dist/platform-machine.cjs +115 -15
- package/dist/platform-machine.cjs.map +1 -1
- package/dist/platform-machine.d.cts +1338 -65
- package/dist/platform-machine.d.ts +1338 -65
- package/dist/platform-machine.js +88 -15
- package/dist/platform-machine.js.map +1 -1
- package/dist/{platform-settings-cuor3i11.d.cts → platform-settings-DUWs4JTy.d.cts} +1 -1
- package/dist/{platform-settings-cuor3i11.d.ts → platform-settings-DUWs4JTy.d.ts} +1 -1
- package/dist/preview.cjs +301 -253
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +6 -4
- package/dist/preview.d.ts +6 -4
- package/dist/preview.js +31 -21
- package/dist/preview.js.map +1 -1
- package/dist/protocol.cjs +282 -167
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +74 -21
- package/dist/protocol.d.ts +74 -21
- package/dist/protocol.js +28 -10
- package/dist/release.cjs +37 -0
- package/dist/release.cjs.map +1 -1
- package/dist/release.d.cts +27 -1
- package/dist/release.d.ts +27 -1
- package/dist/release.js +13 -1
- package/dist/runtime-control.cjs +46 -0
- package/dist/runtime-control.cjs.map +1 -0
- package/dist/runtime-control.d.cts +17 -0
- package/dist/runtime-control.d.ts +17 -0
- package/dist/runtime-control.js +8 -0
- package/dist/runtime-control.js.map +1 -0
- package/dist/runtime-inspection.cjs +655 -0
- package/dist/runtime-inspection.cjs.map +1 -0
- package/dist/runtime-inspection.d.cts +47 -0
- package/dist/runtime-inspection.d.ts +47 -0
- package/dist/runtime-inspection.js +30 -0
- package/dist/runtime-inspection.js.map +1 -0
- package/dist/runtime-reporting-pe-eryVz.d.cts +27 -0
- package/dist/runtime-reporting-pe-eryVz.d.ts +27 -0
- package/dist/signals-ZHftIKuc.d.cts +33 -0
- package/dist/signals-ZHftIKuc.d.ts +33 -0
- package/dist/{standard-match-phase-BucA5dYo.d.ts → standard-match-phase-BzSgBYFg.d.ts} +2 -2
- package/dist/{standard-match-phase-U2ra8J-0.d.cts → standard-match-phase-CvJUW8Oe.d.cts} +2 -2
- package/dist/{sync-B6QsNrXz.d.cts → sync-xtPfWhif.d.cts} +1 -45
- package/dist/{sync-B6QsNrXz.d.ts → sync-xtPfWhif.d.ts} +1 -45
- package/dist/ui.cjs +689 -629
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +14 -4
- package/dist/ui.d.ts +14 -4
- package/dist/ui.js +117 -35
- package/dist/ui.js.map +1 -1
- package/dist/use-air-jam-host-COLy8t4s.d.ts +403 -0
- package/dist/use-air-jam-host-DM-ybB3C.d.cts +403 -0
- package/package.json +55 -21
- package/src/agent/agent-contract-conformance.ts +201 -0
- package/src/agent-tooling.ts +5 -0
- package/src/arcade/runtime.ts +6 -0
- package/src/arcade/surface.ts +1 -0
- package/src/components/join-qr-overlay.tsx +115 -31
- package/src/context/air-jam-context.tsx +8 -8
- package/src/context/socket-manager.ts +0 -7
- package/src/dev/browser-log-sink.ts +12 -15
- package/src/events.ts +0 -5
- package/src/hooks/internal/use-controller-runtime-api.ts +110 -21
- package/src/hooks/internal/use-host-runtime-api.ts +306 -49
- package/src/hooks/use-air-jam-controller.ts +9 -9
- package/src/hooks/use-air-jam-host.ts +7 -7
- package/src/hooks/use-get-input.ts +1 -1
- package/src/hooks/use-host-arcade-restore.ts +6 -1
- package/src/hooks/use-host-audio-mute-preference.ts +99 -0
- package/src/index.ts +6 -21
- package/src/metadata/manifest.ts +2 -3
- package/src/platform-machine.ts +109 -12
- package/src/preview/workspace.tsx +48 -29
- package/src/protocol/arcade-platform-actions.ts +19 -1
- package/src/protocol/controller.ts +8 -2
- package/src/protocol/dev-log-events.ts +0 -3
- package/src/protocol/host-grant.ts +58 -140
- package/src/protocol/host.ts +21 -9
- package/src/protocol/runtime-reporting.ts +32 -0
- package/src/protocol/signed-envelope.ts +176 -0
- package/src/protocol/socket-events.ts +8 -10
- package/src/protocol/sync.ts +0 -16
- package/src/protocol.ts +2 -0
- package/src/release.ts +32 -0
- package/src/runtime/admission-retry.ts +62 -0
- package/src/runtime/air-jam-config.ts +6 -16
- package/src/runtime/air-jam-error-boundary.tsx +46 -2
- package/src/runtime/bridge-envelope-args.ts +21 -0
- package/src/runtime/connected-runtime-error-boundary.tsx +31 -0
- package/src/runtime/contracts/control.ts +107 -59
- package/src/runtime/controller-bridge.ts +12 -24
- package/src/runtime/controller-identity.ts +55 -27
- package/src/runtime/controller-realtime-client.ts +8 -47
- package/src/runtime/create-air-jam-app.tsx +21 -13
- package/src/runtime/host-bridge.ts +16 -24
- package/src/runtime/local-reference-game-identity.ts +13 -0
- package/src/runtime/runtime-session-params.ts +4 -64
- package/src/runtime-control.ts +3 -8
- package/src/settings/platform-settings-runtime.tsx +1 -6
- package/src/settings/platform-settings.ts +7 -38
- package/src/state/connection-store.ts +13 -6
- package/src/store/create-air-jam-store.ts +59 -7
- package/src/utils/ids.ts +32 -5
- package/dist/capabilities.cjs +0 -39
- package/dist/capabilities.cjs.map +0 -1
- package/dist/capabilities.d.cts +0 -31
- package/dist/capabilities.d.ts +0 -31
- package/dist/capabilities.js +0 -12
- package/dist/capabilities.js.map +0 -1
- package/dist/chunk-32NYL7XI.js.map +0 -1
- package/dist/chunk-CABEUV65.js +0 -184
- package/dist/chunk-CABEUV65.js.map +0 -1
- package/dist/chunk-CEJ5RFSG.js.map +0 -1
- package/dist/chunk-EDRQIOCV.js.map +0 -1
- package/dist/chunk-KXAFI5OP.js.map +0 -1
- package/dist/chunk-NCL6WJCL.js.map +0 -1
- package/dist/chunk-NUJBMV3O.js.map +0 -1
- package/dist/chunk-VKBMZHMQ.js.map +0 -1
- package/dist/chunk-W3YA5BWR.js.map +0 -1
- package/dist/chunk-ZLPL2R3R.js.map +0 -1
- package/dist/chunk-ZTQ5SP4H.js +0 -9
- package/dist/chunk-ZTQ5SP4H.js.map +0 -1
- package/src/capabilities/manifest.ts +0 -71
- package/src/capabilities.ts +0 -12
- package/src/hooks/internal/use-runtime-control-contract.ts +0 -15
- package/src/hooks/internal/use-runtime-observability-contract.ts +0 -24
- package/src/runtime/contracts/observability.ts +0 -94
- package/src/runtime-observability.ts +0 -9
- /package/dist/{chunk-JEHV5C2X.js.map → chunk-CV3PBXPT.js.map} +0 -0
- /package/dist/{chunk-FAT2KJ3K.js.map → chunk-MIMPMB7O.js.map} +0 -0
- /package/dist/{chunk-7UXSWCZZ.js.map → chunk-QO4KFUEI.js.map} +0 -0
- /package/dist/{chunk-JO2HR5PV.js.map → chunk-UPV6YWT5.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode,
|
|
3
|
-
export { d as DEFAULT_PLATFORM_SETTINGS, D as DEFAULT_ROOM_PLATFORM_SETTINGS,
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { ReactNode, Component, JSX, ErrorInfo, MutableRefObject } from 'react';
|
|
3
|
+
export { d as DEFAULT_PLATFORM_SETTINGS, D as DEFAULT_ROOM_PLATFORM_SETTINGS, e as PartialRoomPlatformSettingsPatch, f as PlatformAccessibilitySettings, b as PlatformAudioSettings, h as PlatformFeedbackSettings, i as PlatformPreviewControllerSettings, j as PlatformSettings, P as PlatformSettingsPersistence, a as PlatformSettingsSnapshot, R as RoomPlatformSettingsSnapshot, g as getEffectiveAudioVolume, m as mergeRoomPlatformSettingsSnapshot, t as toRoomPlatformSettingsSnapshot } from './platform-settings-DUWs4JTy.js';
|
|
4
|
+
export { d as PlatformAudioSettingsApi, P as PlatformSettingsBoundary, e as PlatformSettingsBoundaryProps, f as PlatformSettingsOwnerApi, a as PlatformSettingsRuntime, g as PlatformSettingsRuntimeProps, S as ShellMatchPhase, k as StandardMatchPhase, i as isActiveMatchPhase, h as isEndedMatchPhase, j as isStandardMatchPhase, s as standardMatchPhases, t as toShellMatchPhase, u as useInheritedPlatformSettings, b as usePlatformAudioSettings, c as usePlatformSettings } from './standard-match-phase-BzSgBYFg.js';
|
|
5
|
+
import { a as AirJamHostOptions, A as AirJamControllerOptions } from './use-air-jam-host-COLy8t4s.js';
|
|
6
|
+
export { b as AirJamControllerApi, d as AirJamControllerState, c as AirJamHostApi, f as AirJamHostState, J as JoinUrlStatus, u as useAirJamController, e as useAirJamHost } from './use-air-jam-host-COLy8t4s.js';
|
|
7
|
+
import { b as ConnectionStatus, t as ControllerInputPayload, P as PlayerProfile, R as RoomCode } from './controller-PZEM_1cH.js';
|
|
8
|
+
export { d as ControllerOrientation, j as ControllerStatePayload, h as ControllerUpdatePlayerProfileAck, g as PlayerProfilePatch, e as RunMode, c as RuntimeState } from './controller-PZEM_1cH.js';
|
|
9
|
+
import { T as ToastSignalPayload, H as HapticSignalPayload } from './signals-ZHftIKuc.js';
|
|
10
|
+
export { S as SignalPayload, b as SignalType } from './signals-ZHftIKuc.js';
|
|
7
11
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { A as
|
|
14
|
-
export { j as AirJamAgentActionContract, b as AirJamAgentActionCustomOptions, c as AirJamAgentActionOptions, d as AirJamAgentActionPayloadKind, e as AirJamAgentActionPayloadMetadata, k as AirJamAgentActionTarget, l as AirJamAgentContractActionOptions, m as AirJamAgentContractPayloadKind, n as AirJamAgentContractPayloadMetadata, o as AirJamAgentJsonObject, p as AirJamAgentResolvedActionContract, q as AirJamAgentSnapshotContext, r as AirJamAgentStoreDeclaration, s as AirJamAgentStoreDeclarations, t as AirJamAgentStores, u as AnyAirJamAgentContract, I as InferAirJamAgentActionInputPayload, v as InferAirJamAgentStores, f as agentAction, a as agentActionInput, g as agentStore, h as defineAirJamAgentContract, i as defineAirJamAgentStores } from './agent-tooling-BSMGBix9.js';
|
|
15
|
-
import { AirJamGameCapabilityManifest } from './capabilities.js';
|
|
12
|
+
import { e as AirJamActionActorRole, A as AirJamActionInvocationResult, g as AirJamActionPayload } from './sync-xtPfWhif.js';
|
|
13
|
+
export { i as AirJamActionAccepted, j as AirJamActionRejected } from './sync-xtPfWhif.js';
|
|
14
|
+
import { R as RuntimeErrorReport } from './runtime-reporting-pe-eryVz.js';
|
|
15
|
+
import { o as AirJamAgentContract } from './agent-contract-CD2QnbBJ.js';
|
|
16
|
+
export { n as AirJamAgentActionContract, k as AirJamAgentActionCustomOptions, g as AirJamAgentActionOptions, i as AirJamAgentActionPayloadKind, j as AirJamAgentActionPayloadMetadata, v as AirJamAgentActionTarget, w as AirJamAgentContractActionOptions, x as AirJamAgentContractPayloadKind, y as AirJamAgentContractPayloadMetadata, z as AirJamAgentJsonObject, B as AirJamAgentResolvedActionContract, C as AirJamAgentSnapshotContext, D as AirJamAgentStoreDeclaration, E as AirJamAgentStoreDeclarations, F as AirJamAgentStores, A as AnyAirJamAgentContract, I as InferAirJamAgentActionInputPayload, G as InferAirJamAgentStores, q as agentAction, p as agentActionInput, s as agentStore, t as defineAirJamAgentContract, u as defineAirJamAgentStores } from './agent-contract-CD2QnbBJ.js';
|
|
17
|
+
import { A as AirJamProviderProps } from './air-jam-context-DTsxF-tP.js';
|
|
16
18
|
import { AirJamGameMetadata } from './metadata.js';
|
|
19
|
+
import { H as HostSessionKind } from './host-DylGsX7p.js';
|
|
20
|
+
import { RuntimeTopologyInput, ResolvedAirJamRuntimeTopology, SurfaceRole } from './runtime-topology.js';
|
|
17
21
|
import { StateCreator } from 'zustand';
|
|
18
22
|
import { StoreApi } from 'zustand/vanilla';
|
|
23
|
+
import './realtime-client-Cu8yVJFw.js';
|
|
24
|
+
import './notices-C4bao3oi.js';
|
|
19
25
|
|
|
20
26
|
type SoundCategory = "music" | "sfx";
|
|
21
27
|
interface SoundConfig {
|
|
@@ -87,401 +93,6 @@ type AirJamDiagnosticListener = (diagnostic: AirJamDiagnostic) => void;
|
|
|
87
93
|
declare const onAirJamDiagnostic: (listener: AirJamDiagnosticListener) => (() => void);
|
|
88
94
|
declare const setAirJamDiagnosticsEnabled: (enabled: boolean) => void;
|
|
89
95
|
|
|
90
|
-
/**
|
|
91
|
-
* Options for configuring the controller runtime boundary.
|
|
92
|
-
*
|
|
93
|
-
* @example Basic runtime boundary usage (room from URL)
|
|
94
|
-
* ```tsx
|
|
95
|
-
* // URL: https://yourgame.com/controller?room=ABCD
|
|
96
|
-
* <AirJamControllerRuntime>
|
|
97
|
-
* <ControllerView />
|
|
98
|
-
* </AirJamControllerRuntime>
|
|
99
|
-
* ```
|
|
100
|
-
*
|
|
101
|
-
* @example With nickname
|
|
102
|
-
* ```tsx
|
|
103
|
-
* <AirJamControllerRuntime
|
|
104
|
-
* nickname={playerName}
|
|
105
|
-
* onState={(state) => {
|
|
106
|
-
* if (state.runtimeState === "playing") startGame();
|
|
107
|
-
* }}
|
|
108
|
-
* >
|
|
109
|
-
* <ControllerView />
|
|
110
|
-
* </AirJamControllerRuntime>
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
interface AirJamControllerOptions {
|
|
114
|
-
/**
|
|
115
|
-
* Room ID (4-character code) to join.
|
|
116
|
-
* Can also be provided via URL query parameter: `?room=XXXX`
|
|
117
|
-
* The URL parameter takes precedence if both are provided.
|
|
118
|
-
*/
|
|
119
|
-
roomId?: string;
|
|
120
|
-
/**
|
|
121
|
-
* Player nickname to display in the game.
|
|
122
|
-
* If not provided, the server assigns a random label.
|
|
123
|
-
*/
|
|
124
|
-
nickname?: string;
|
|
125
|
-
/**
|
|
126
|
-
* Preset avatar id sent on join (optional).
|
|
127
|
-
*/
|
|
128
|
-
avatarId?: string;
|
|
129
|
-
/**
|
|
130
|
-
* Controller ID for this instance.
|
|
131
|
-
* Auto-generated if not provided. Persists across reconnects.
|
|
132
|
-
*/
|
|
133
|
-
controllerId?: string;
|
|
134
|
-
/**
|
|
135
|
-
* Optional privileged controller capability token.
|
|
136
|
-
* Undefined falls back to `aj_controller_cap` from the URL; null explicitly disables URL token use.
|
|
137
|
-
*/
|
|
138
|
-
capabilityToken?: string | null;
|
|
139
|
-
/**
|
|
140
|
-
* Called when the host sends a state update (game state, messages, etc.)
|
|
141
|
-
*/
|
|
142
|
-
onState?: (state: ControllerStatePayload) => void;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Return type of useAirJamController hook.
|
|
146
|
-
*
|
|
147
|
-
* Provides state and functions for a mobile/web controller interface.
|
|
148
|
-
*/
|
|
149
|
-
interface AirJamControllerApi {
|
|
150
|
-
/** Room code this controller is connected to (or attempting to join) */
|
|
151
|
-
roomId: RoomCode | null;
|
|
152
|
-
/** This controller's unique ID */
|
|
153
|
-
controllerId: string | null;
|
|
154
|
-
/** Current connection status */
|
|
155
|
-
connectionStatus: ConnectionStatus;
|
|
156
|
-
/** Last error message, if any */
|
|
157
|
-
lastError?: string;
|
|
158
|
-
/** Current game state (paused or playing) */
|
|
159
|
-
runtimeState: RuntimeState;
|
|
160
|
-
/** Intended controller presentation orientation for the active game UI. */
|
|
161
|
-
controllerOrientation: ControllerOrientation;
|
|
162
|
-
/** Optional message from the host (e.g., "Get Ready!") */
|
|
163
|
-
stateMessage?: string;
|
|
164
|
-
/** Current host-owned room settings mirrored onto the controller. */
|
|
165
|
-
roomSettings: ControllerRoomSettingsState;
|
|
166
|
-
/**
|
|
167
|
-
* Send a system command to the host.
|
|
168
|
-
*
|
|
169
|
-
* @example Pause or resume
|
|
170
|
-
* ```ts
|
|
171
|
-
* controller.sendSystemCommand("pause");
|
|
172
|
-
* controller.sendSystemCommand("resume");
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
sendSystemCommand: (command: "exit" | "pause" | "resume") => void;
|
|
176
|
-
/**
|
|
177
|
-
* Update the player nickname (local draft for next join).
|
|
178
|
-
*/
|
|
179
|
-
setNickname: (value: string) => void;
|
|
180
|
-
/**
|
|
181
|
-
* Update preset avatar id (local draft for next join).
|
|
182
|
-
*/
|
|
183
|
-
setAvatarId: (value: string) => void;
|
|
184
|
-
/**
|
|
185
|
-
* Patch display name and/or avatar on the server without reconnecting.
|
|
186
|
-
* In Arcade (embedded iframe), updates are forwarded through the controller bridge; the room
|
|
187
|
-
* still learns the new name via `server:playerUpdated` (ack payload is not round-tripped).
|
|
188
|
-
*/
|
|
189
|
-
updatePlayerProfile: (patch: PlayerProfilePatch) => Promise<ControllerUpdatePlayerProfileAck>;
|
|
190
|
-
/** Explicitly leave the current room and release the controller binding. */
|
|
191
|
-
leave: () => Promise<ControllerLeaveAck>;
|
|
192
|
-
/** Force reconnection to the room */
|
|
193
|
-
reconnect: () => void;
|
|
194
|
-
/** List of all connected players in the room */
|
|
195
|
-
players: PlayerProfile[];
|
|
196
|
-
/** This controller's current player profile when known. */
|
|
197
|
-
selfPlayer: PlayerProfile | null;
|
|
198
|
-
/** Realtime client for controller events (socket-backed standalone, bridge-backed in arcade embeds) */
|
|
199
|
-
socket: AirJamRealtimeClient | null;
|
|
200
|
-
}
|
|
201
|
-
interface AirJamControllerState {
|
|
202
|
-
roomId: RoomCode | null;
|
|
203
|
-
controllerId: string | null;
|
|
204
|
-
connectionStatus: ConnectionStatus;
|
|
205
|
-
lastError?: string;
|
|
206
|
-
runtimeState: RuntimeState;
|
|
207
|
-
controllerOrientation: ControllerOrientation;
|
|
208
|
-
stateMessage?: string;
|
|
209
|
-
roomSettings: ControllerRoomSettingsState;
|
|
210
|
-
players: PlayerProfile[];
|
|
211
|
-
selfPlayer: PlayerProfile | null;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Read the mounted controller runtime API.
|
|
215
|
-
*
|
|
216
|
-
* Use this inside `AirJamControllerRuntime` or another explicit controller runtime
|
|
217
|
-
* boundary such as `airjam.Controller`. Runtime ownership is mounted once at the
|
|
218
|
-
* boundary; child code reads from that runtime through this hook.
|
|
219
|
-
*
|
|
220
|
-
* **Typical usage flow:**
|
|
221
|
-
* 1. Player scans QR code on game screen
|
|
222
|
-
* 2. Opens controller URL with ?room=XXXX parameter
|
|
223
|
-
* 3. Controller auto-connects to the game session
|
|
224
|
-
* 4. Player uses joystick/buttons to send input
|
|
225
|
-
* 5. Receives haptic feedback on game events
|
|
226
|
-
*
|
|
227
|
-
* @returns Controller API with state and functions
|
|
228
|
-
*
|
|
229
|
-
* @example Basic controller setup
|
|
230
|
-
* ```tsx
|
|
231
|
-
* const ControllerView = () => {
|
|
232
|
-
* const controller = useAirJamController();
|
|
233
|
-
*
|
|
234
|
-
* if (controller.connectionStatus !== "connected") {
|
|
235
|
-
* return <div>Connecting to room {controller.roomId}...</div>;
|
|
236
|
-
* }
|
|
237
|
-
*
|
|
238
|
-
* return (
|
|
239
|
-
* <div>
|
|
240
|
-
* <p>Connected: {controller.controllerId}</p>
|
|
241
|
-
* <p>Game: {controller.runtimeState}</p>
|
|
242
|
-
* </div>
|
|
243
|
-
* );
|
|
244
|
-
* };
|
|
245
|
-
* ```
|
|
246
|
-
*
|
|
247
|
-
* @example With state callback
|
|
248
|
-
* ```tsx
|
|
249
|
-
* <AirJamControllerRuntime
|
|
250
|
-
* onState={(state) => {
|
|
251
|
-
* if (state.message) {
|
|
252
|
-
* showNotification(state.message);
|
|
253
|
-
* }
|
|
254
|
-
* }}
|
|
255
|
-
* >
|
|
256
|
-
* <ControllerView />
|
|
257
|
-
* </AirJamControllerRuntime>
|
|
258
|
-
* ```
|
|
259
|
-
*/
|
|
260
|
-
declare function useAirJamController(): AirJamControllerApi;
|
|
261
|
-
declare function useAirJamController<TSelected>(selector: (state: AirJamControllerState) => TSelected): TSelected;
|
|
262
|
-
|
|
263
|
-
type JoinUrlStatus = "loading" | "ready" | "unavailable";
|
|
264
|
-
/**
|
|
265
|
-
* Options for configuring the host runtime boundary.
|
|
266
|
-
*
|
|
267
|
-
* @example Runtime boundary usage with callbacks
|
|
268
|
-
* ```tsx
|
|
269
|
-
* <AirJamHostRuntime
|
|
270
|
-
* onPlayerJoin={(player) => {
|
|
271
|
-
* console.log(`${player.label} joined!`);
|
|
272
|
-
* spawnPlayerShip(player.id);
|
|
273
|
-
* }}
|
|
274
|
-
* onPlayerLeave={(controllerId) => {
|
|
275
|
-
* console.log(`Player ${controllerId} left`);
|
|
276
|
-
* removePlayerShip(controllerId);
|
|
277
|
-
* }}
|
|
278
|
-
* >
|
|
279
|
-
* <HostView />
|
|
280
|
-
* </AirJamHostRuntime>
|
|
281
|
-
* ```
|
|
282
|
-
*
|
|
283
|
-
* @example With custom room ID
|
|
284
|
-
* ```tsx
|
|
285
|
-
* <AirJamHostRuntime roomId="GAME1">
|
|
286
|
-
* <HostView />
|
|
287
|
-
* </AirJamHostRuntime>
|
|
288
|
-
* ```
|
|
289
|
-
*/
|
|
290
|
-
interface AirJamHostOptions {
|
|
291
|
-
/**
|
|
292
|
-
* Room ID (4-character code) to use for this session.
|
|
293
|
-
* If not provided, a random room code will be generated.
|
|
294
|
-
* Can also be set via URL query parameter: `?room=XXXX`
|
|
295
|
-
*/
|
|
296
|
-
roomId?: string;
|
|
297
|
-
/**
|
|
298
|
-
* Called when a player successfully joins the room.
|
|
299
|
-
* Use this to spawn player entities, update UI, etc.
|
|
300
|
-
*/
|
|
301
|
-
onPlayerJoin?: (player: PlayerProfile) => void;
|
|
302
|
-
/**
|
|
303
|
-
* Called when a player leaves the room (disconnects or exits).
|
|
304
|
-
* Use this to remove player entities, handle cleanup.
|
|
305
|
-
*/
|
|
306
|
-
onPlayerLeave?: (controllerId: string) => void;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Return type of useAirJamHost hook.
|
|
310
|
-
*
|
|
311
|
-
* Provides all the state and functions needed to run a multiplayer game session.
|
|
312
|
-
*
|
|
313
|
-
* @template TSchema - Zod schema type for input (inferred from provider)
|
|
314
|
-
*/
|
|
315
|
-
interface AirJamHostApi<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
316
|
-
/** The room code for this session (e.g., "ABCD") */
|
|
317
|
-
roomId: RoomCode;
|
|
318
|
-
/** Full URL for controllers to join (display as QR code) */
|
|
319
|
-
joinUrl: string;
|
|
320
|
-
/** Whether the join URL is still being resolved, ready to render, or unavailable */
|
|
321
|
-
joinUrlStatus: JoinUrlStatus;
|
|
322
|
-
/** Current connection status to the server */
|
|
323
|
-
connectionStatus: ConnectionStatus;
|
|
324
|
-
/** List of currently connected players */
|
|
325
|
-
players: PlayerProfile[];
|
|
326
|
-
/** Full controller-session roster for the current room, including source and lease state. */
|
|
327
|
-
controllers: ControllerPresenceNotice[];
|
|
328
|
-
/** Last error message, if any */
|
|
329
|
-
lastError?: string;
|
|
330
|
-
/** Current run mode (standalone, arcade, platform) */
|
|
331
|
-
mode: RunMode;
|
|
332
|
-
/** Current runtime pause/play state */
|
|
333
|
-
runtimeState: RuntimeState;
|
|
334
|
-
/** Pause the runtime for every connected surface. */
|
|
335
|
-
pauseRuntime: () => void;
|
|
336
|
-
/** Resume the runtime for every connected surface. */
|
|
337
|
-
resumeRuntime: () => void;
|
|
338
|
-
/** Set the runtime pause/play state explicitly. */
|
|
339
|
-
setRuntimeState: (state: RuntimeState) => void;
|
|
340
|
-
/**
|
|
341
|
-
* Send state update to all connected controllers.
|
|
342
|
-
* Use for syncing game state, messages, etc.
|
|
343
|
-
*/
|
|
344
|
-
sendState: (state: ControllerStatePayload) => boolean;
|
|
345
|
-
/**
|
|
346
|
-
* Send a signal (haptic feedback or toast) to controllers.
|
|
347
|
-
*
|
|
348
|
-
* @example Send haptic to specific player
|
|
349
|
-
* ```ts
|
|
350
|
-
* host.sendSignal("HAPTIC", { pattern: "heavy" }, playerId);
|
|
351
|
-
* ```
|
|
352
|
-
*
|
|
353
|
-
* @example Send toast to all players
|
|
354
|
-
* ```ts
|
|
355
|
-
* host.sendSignal("TOAST", {
|
|
356
|
-
* title: "Round Start!",
|
|
357
|
-
* message: "Game begins in 3 seconds",
|
|
358
|
-
* });
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
sendSignal: {
|
|
362
|
-
(type: "HAPTIC", payload: HapticSignalPayload, targetId?: string): void;
|
|
363
|
-
(type: "TOAST", payload: ToastSignalPayload, targetId?: string): void;
|
|
364
|
-
};
|
|
365
|
-
/** Reconnect to the server */
|
|
366
|
-
reconnect: () => void;
|
|
367
|
-
/** Remove one controller from the room immediately. */
|
|
368
|
-
removeController: (controllerId: string) => Promise<HostControllerActionAck>;
|
|
369
|
-
/** Tear down the current room and create a fresh empty room for this host. */
|
|
370
|
-
resetRoom: () => Promise<HostRegistrationAck>;
|
|
371
|
-
/** Realtime client for host events (socket-backed standalone, bridge-backed in arcade embeds) */
|
|
372
|
-
socket: AirJamRealtimeClient;
|
|
373
|
-
/**
|
|
374
|
-
* Get the latest input from a specific controller.
|
|
375
|
-
*
|
|
376
|
-
* Returns validated, typed input based on the schema provided to the session provider.
|
|
377
|
-
* Input behavior defaults are tap-safe booleans (`pulse`) and latest vectors (`latest`),
|
|
378
|
-
* with optional per-field overrides.
|
|
379
|
-
*
|
|
380
|
-
* @example In a game loop
|
|
381
|
-
* ```ts
|
|
382
|
-
* useFrame(() => {
|
|
383
|
-
* players.forEach((player) => {
|
|
384
|
-
* const input = host.getInput(player.id);
|
|
385
|
-
* if (input?.action) {
|
|
386
|
-
* fireWeapon(player.id);
|
|
387
|
-
* }
|
|
388
|
-
* movePlayer(player.id, input?.vector ?? { x: 0, y: 0 });
|
|
389
|
-
* });
|
|
390
|
-
* });
|
|
391
|
-
* ```
|
|
392
|
-
*/
|
|
393
|
-
getInput: (controllerId: string) => z.infer<TSchema> | undefined;
|
|
394
|
-
}
|
|
395
|
-
interface AirJamHostState {
|
|
396
|
-
roomId: RoomCode | null;
|
|
397
|
-
connectionStatus: ConnectionStatus;
|
|
398
|
-
players: PlayerProfile[];
|
|
399
|
-
controllers: ControllerPresenceNotice[];
|
|
400
|
-
lastError?: string;
|
|
401
|
-
mode: RunMode;
|
|
402
|
-
runtimeState: RuntimeState;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Read the mounted host runtime API.
|
|
406
|
-
*
|
|
407
|
-
* Use this inside `AirJamHostRuntime` or another explicit host runtime boundary
|
|
408
|
-
* such as `airjam.Host`. Runtime ownership is mounted once at the boundary; child
|
|
409
|
-
* code reads from that runtime through this hook.
|
|
410
|
-
*
|
|
411
|
-
* This hook is runtime-aware:
|
|
412
|
-
* - standalone: creates/reconnects host rooms directly
|
|
413
|
-
* - arcade iframe runtime: auto-detects `aj_room` + `aj_cap` and bridges through the platform-owned host session
|
|
414
|
-
*
|
|
415
|
-
* This hook no longer creates host runtime side effects.
|
|
416
|
-
*
|
|
417
|
-
* **Features:**
|
|
418
|
-
* - Automatic room creation and management
|
|
419
|
-
* - Real-time player join/leave events
|
|
420
|
-
* - Typed input with validation and behavior defaults
|
|
421
|
-
* - Haptic feedback and toast notifications
|
|
422
|
-
* - Runtime state synchronization
|
|
423
|
-
*
|
|
424
|
-
* @template TSchema - Zod schema for input validation (from provider)
|
|
425
|
-
* @returns API object with state and functions
|
|
426
|
-
*
|
|
427
|
-
* @example Basic usage
|
|
428
|
-
* ```tsx
|
|
429
|
-
* const HostView = () => {
|
|
430
|
-
* const host = useAirJamHost();
|
|
431
|
-
*
|
|
432
|
-
* return (
|
|
433
|
-
* <div>
|
|
434
|
-
* <h1>Room: {host.roomId}</h1>
|
|
435
|
-
* <QRCode value={host.joinUrl} />
|
|
436
|
-
* <p>Players: {host.players.length}</p>
|
|
437
|
-
* <button
|
|
438
|
-
* onClick={
|
|
439
|
-
* host.runtimeState === "playing"
|
|
440
|
-
* ? host.pauseRuntime
|
|
441
|
-
* : host.resumeRuntime
|
|
442
|
-
* }
|
|
443
|
-
* >
|
|
444
|
-
* {host.runtimeState === "playing" ? "Pause" : "Resume"}
|
|
445
|
-
* </button>
|
|
446
|
-
* </div>
|
|
447
|
-
* );
|
|
448
|
-
* };
|
|
449
|
-
* ```
|
|
450
|
-
*
|
|
451
|
-
* @example Reading input in a game loop
|
|
452
|
-
* ```tsx
|
|
453
|
-
* const GameScene = () => {
|
|
454
|
-
* const host = useAirJamHost();
|
|
455
|
-
*
|
|
456
|
-
* useFrame(() => {
|
|
457
|
-
* host.players.forEach((player) => {
|
|
458
|
-
* const input = host.getInput(player.id);
|
|
459
|
-
* if (!input) return;
|
|
460
|
-
*
|
|
461
|
-
* // Move player based on joystick
|
|
462
|
-
* movePlayer(player.id, input.vector);
|
|
463
|
-
*
|
|
464
|
-
* // Handle button press (tap-safe pulse default)
|
|
465
|
-
* if (input.action) {
|
|
466
|
-
* playerShoot(player.id);
|
|
467
|
-
* }
|
|
468
|
-
* });
|
|
469
|
-
* });
|
|
470
|
-
*
|
|
471
|
-
* return <GameCanvas />;
|
|
472
|
-
* };
|
|
473
|
-
* ```
|
|
474
|
-
*
|
|
475
|
-
* @example Sending haptic feedback
|
|
476
|
-
* ```tsx
|
|
477
|
-
* const handleHit = (playerId: string) => {
|
|
478
|
-
* host.sendSignal("HAPTIC", { pattern: "heavy" }, playerId);
|
|
479
|
-
* };
|
|
480
|
-
* ```
|
|
481
|
-
*/
|
|
482
|
-
declare function useAirJamHost<TSchema extends z.ZodSchema = z.ZodSchema>(): AirJamHostApi<TSchema>;
|
|
483
|
-
declare function useAirJamHost<TSelected>(selector: (state: AirJamHostState) => TSelected): TSelected;
|
|
484
|
-
|
|
485
96
|
declare const useConnectionStatus: () => ConnectionStatus;
|
|
486
97
|
|
|
487
98
|
interface ControllerTickInfo {
|
|
@@ -524,7 +135,7 @@ declare const useControllerToasts: (options?: UseControllerToastsOptions) => {
|
|
|
524
135
|
* to host session state, so it won't cause re-renders when connection state changes.
|
|
525
136
|
*
|
|
526
137
|
* **Requirements:**
|
|
527
|
-
* - Must be used within `
|
|
138
|
+
* - Must be used within `airjam.Host` or the underlying scoped host runtime
|
|
528
139
|
* - Input configuration must be provided to the provider
|
|
529
140
|
*
|
|
530
141
|
* @template TSchema - Zod schema type for input (from provider)
|
|
@@ -574,6 +185,13 @@ declare const useControllerToasts: (options?: UseControllerToastsOptions) => {
|
|
|
574
185
|
*/
|
|
575
186
|
declare const useGetInput: <TSchema extends z.ZodSchema = z.ZodSchema>() => ((controllerId: string) => z.infer<TSchema> | undefined);
|
|
576
187
|
|
|
188
|
+
interface HostAudioMutePreference {
|
|
189
|
+
muted: boolean;
|
|
190
|
+
setMuted: (muted: boolean) => void;
|
|
191
|
+
toggleMuted: () => void;
|
|
192
|
+
}
|
|
193
|
+
declare const useHostAudioMutePreference: (scope: string, defaultMuted?: boolean) => HostAudioMutePreference;
|
|
194
|
+
|
|
577
195
|
interface HostTickInfo {
|
|
578
196
|
now: number;
|
|
579
197
|
deltaMs: number;
|
|
@@ -728,231 +346,6 @@ interface SendSignalFn {
|
|
|
728
346
|
*/
|
|
729
347
|
declare const useSendSignal: () => SendSignalFn;
|
|
730
348
|
|
|
731
|
-
type HostInspectionApi = Pick<AirJamHostApi, "roomId" | "joinUrl" | "joinUrlStatus" | "connectionStatus" | "players" | "controllers" | "lastError" | "mode" | "runtimeState">;
|
|
732
|
-
type ControllerInspectionApi = Pick<AirJamControllerApi, "roomId" | "controllerId" | "connectionStatus" | "lastError" | "runtimeState" | "controllerOrientation" | "roomSettings" | "stateMessage" | "players" | "selfPlayer">;
|
|
733
|
-
interface HostRuntimeInspectionContract {
|
|
734
|
-
role: "host";
|
|
735
|
-
roomId: RoomCode;
|
|
736
|
-
joinUrl: string;
|
|
737
|
-
joinUrlStatus: JoinUrlStatus;
|
|
738
|
-
connectionStatus: ConnectionStatus;
|
|
739
|
-
players: readonly PlayerProfile[];
|
|
740
|
-
controllers: readonly ControllerPresenceNotice[];
|
|
741
|
-
lastError?: string;
|
|
742
|
-
mode: RunMode;
|
|
743
|
-
runtimeState: RuntimeState;
|
|
744
|
-
}
|
|
745
|
-
interface ControllerRuntimeInspectionContract {
|
|
746
|
-
role: "controller";
|
|
747
|
-
roomId: RoomCode | null;
|
|
748
|
-
controllerId: string | null;
|
|
749
|
-
connectionStatus: ConnectionStatus;
|
|
750
|
-
players: readonly PlayerProfile[];
|
|
751
|
-
selfPlayer: PlayerProfile | null;
|
|
752
|
-
lastError?: string;
|
|
753
|
-
runtimeState: RuntimeState;
|
|
754
|
-
controllerOrientation: ControllerOrientation;
|
|
755
|
-
stateMessage?: string;
|
|
756
|
-
roomSettings: ControllerInspectionApi["roomSettings"];
|
|
757
|
-
}
|
|
758
|
-
type RuntimeInspectionContract = HostRuntimeInspectionContract | ControllerRuntimeInspectionContract;
|
|
759
|
-
declare const AIR_JAM_RUNTIME_INSPECTION_KEY = "__airJamRuntimeInspection";
|
|
760
|
-
declare const createHostRuntimeInspectionContract: (api: HostInspectionApi) => HostRuntimeInspectionContract;
|
|
761
|
-
declare const createControllerRuntimeInspectionContract: (api: ControllerInspectionApi) => ControllerRuntimeInspectionContract;
|
|
762
|
-
declare const readRuntimeInspectionContract: (target: object) => RuntimeInspectionContract | null;
|
|
763
|
-
declare const publishRuntimeInspectionContract: (target: object, contract: RuntimeInspectionContract | null) => void;
|
|
764
|
-
|
|
765
|
-
declare const useHostRuntimeInspectionContract: () => HostRuntimeInspectionContract;
|
|
766
|
-
declare const useControllerRuntimeInspectionContract: () => ControllerRuntimeInspectionContract;
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* @module InputManager
|
|
770
|
-
* @description Internal input runtime used by host hooks.
|
|
771
|
-
*
|
|
772
|
-
* Public API terms:
|
|
773
|
-
* - `pulse`: consume-on-read, tap-safe behavior (default for booleans)
|
|
774
|
-
* - `hold`: keep last active vector until a new active value arrives
|
|
775
|
-
* - `latest`: read current value as-is (default for vectors and other fields)
|
|
776
|
-
*
|
|
777
|
-
* @internal This class is not exported publicly. Use hooks to access input.
|
|
778
|
-
*/
|
|
779
|
-
|
|
780
|
-
/**
|
|
781
|
-
* Configuration for input handling with optional validation and per-field behavior.
|
|
782
|
-
*
|
|
783
|
-
* Provided to `HostSessionProvider` to enable typed and behavior-aware input reads.
|
|
784
|
-
*
|
|
785
|
-
* @template TSchema - Zod schema type for input validation
|
|
786
|
-
*
|
|
787
|
-
* @example Basic schema validation
|
|
788
|
-
* ```ts
|
|
789
|
-
* const config: InputConfig = {
|
|
790
|
-
* schema: z.object({
|
|
791
|
-
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
792
|
-
* action: z.boolean(),
|
|
793
|
-
* }),
|
|
794
|
-
* };
|
|
795
|
-
* ```
|
|
796
|
-
*
|
|
797
|
-
* @example With custom behavior overrides
|
|
798
|
-
* ```ts
|
|
799
|
-
* const config: InputConfig = {
|
|
800
|
-
* schema: gameInputSchema,
|
|
801
|
-
* behavior: {
|
|
802
|
-
* pulse: ["action", "ability"], // consume-on-read
|
|
803
|
-
* latest: ["aim"], // read latest value
|
|
804
|
-
* hold: ["menuVector"], // keep last non-zero vector
|
|
805
|
-
* },
|
|
806
|
-
* };
|
|
807
|
-
* ```
|
|
808
|
-
*/
|
|
809
|
-
interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
810
|
-
/**
|
|
811
|
-
* Zod schema for input validation and type inference.
|
|
812
|
-
*
|
|
813
|
-
* When provided:
|
|
814
|
-
* - Incoming input is validated against the schema
|
|
815
|
-
* - Invalid input returns `undefined` (with console warning)
|
|
816
|
-
* - Return type is inferred from the schema
|
|
817
|
-
*
|
|
818
|
-
* @example
|
|
819
|
-
* ```ts
|
|
820
|
-
* schema: z.object({
|
|
821
|
-
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
822
|
-
* action: z.boolean(),
|
|
823
|
-
* ability: z.boolean(),
|
|
824
|
-
* timestamp: z.number(),
|
|
825
|
-
* })
|
|
826
|
-
* ```
|
|
827
|
-
*/
|
|
828
|
-
schema?: TSchema;
|
|
829
|
-
behavior?: {
|
|
830
|
-
/**
|
|
831
|
-
* Consume-on-read behavior. Useful for tap-safe buttons and one-shot vectors.
|
|
832
|
-
*
|
|
833
|
-
* Defaults: booleans use `pulse` even without explicit config.
|
|
834
|
-
*/
|
|
835
|
-
pulse?: string[];
|
|
836
|
-
/**
|
|
837
|
-
* Sticky behavior. For vectors, keeps the last non-zero direction until
|
|
838
|
-
* another non-zero direction arrives.
|
|
839
|
-
*/
|
|
840
|
-
hold?: string[];
|
|
841
|
-
/**
|
|
842
|
-
* Stateless behavior. Returns the latest raw value.
|
|
843
|
-
*
|
|
844
|
-
* Defaults: vectors and non-boolean fields use `latest`.
|
|
845
|
-
*/
|
|
846
|
-
latest?: string[];
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
interface ResolveAirJamConfigInput {
|
|
851
|
-
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
852
|
-
surfaceRole?: SurfaceRole;
|
|
853
|
-
appId?: string;
|
|
854
|
-
hostGrantEndpoint?: string;
|
|
855
|
-
maxPlayers?: number;
|
|
856
|
-
hostSessionKind?: HostSessionKind;
|
|
857
|
-
resolveEnv?: boolean;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* Props for the AirJamProvider component.
|
|
862
|
-
*
|
|
863
|
-
* @template TSchema - Zod schema type for input validation (inferred from input.schema)
|
|
864
|
-
*
|
|
865
|
-
* @example Minimal configuration (uses environment variables)
|
|
866
|
-
* ```tsx
|
|
867
|
-
* <HostSessionProvider>
|
|
868
|
-
* <App />
|
|
869
|
-
* </HostSessionProvider>
|
|
870
|
-
* ```
|
|
871
|
-
*
|
|
872
|
-
* @example Full configuration
|
|
873
|
-
* ```tsx
|
|
874
|
-
* <HostSessionProvider
|
|
875
|
-
* topology={myTopology}
|
|
876
|
-
* appId="your-app-id"
|
|
877
|
-
* hostGrantEndpoint="/api/airjam/host-grant"
|
|
878
|
-
* maxPlayers={4}
|
|
879
|
-
* input={{
|
|
880
|
-
* schema: myInputSchema,
|
|
881
|
-
* behavior: { pulse: ["fire"], latest: ["move"] },
|
|
882
|
-
* }}
|
|
883
|
-
* >
|
|
884
|
-
* <App />
|
|
885
|
-
* </HostSessionProvider>
|
|
886
|
-
* ```
|
|
887
|
-
*/
|
|
888
|
-
interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
889
|
-
/** React children to render within the provider */
|
|
890
|
-
children: ReactNode;
|
|
891
|
-
/** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
|
|
892
|
-
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
893
|
-
/** Internal surface-role hint when normalizing legacy endpoint props into topology. */
|
|
894
|
-
surfaceRole?: SurfaceRole;
|
|
895
|
-
/**
|
|
896
|
-
* App ID for production bootstrap identity.
|
|
897
|
-
* Falls back to VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID
|
|
898
|
-
* when not provided directly.
|
|
899
|
-
*/
|
|
900
|
-
appId?: string;
|
|
901
|
-
/**
|
|
902
|
-
* Optional endpoint that returns a short-lived signed host grant for stronger production bootstrap.
|
|
903
|
-
* When provided, the host runtime fetches a grant automatically before `host:bootstrap`.
|
|
904
|
-
*/
|
|
905
|
-
hostGrantEndpoint?: string;
|
|
906
|
-
/**
|
|
907
|
-
* Maximum number of players allowed in a room.
|
|
908
|
-
* @default 8
|
|
909
|
-
*/
|
|
910
|
-
maxPlayers?: number;
|
|
911
|
-
/**
|
|
912
|
-
* Declares whether this host provider owns a standalone game room or a system shell room.
|
|
913
|
-
* Standalone games should use `"game"`; Arcade shell hosts should use `"system"`.
|
|
914
|
-
* @default "game"
|
|
915
|
-
*/
|
|
916
|
-
hostSessionKind?: HostSessionKind;
|
|
917
|
-
/**
|
|
918
|
-
* Enable environment-variable fallback resolution for config fields.
|
|
919
|
-
* Set to false to require explicit `topology` / `appId` / `hostGrantEndpoint`.
|
|
920
|
-
* @default true
|
|
921
|
-
*/
|
|
922
|
-
resolveEnv?: boolean;
|
|
923
|
-
/**
|
|
924
|
-
* Input handling configuration including Zod schema validation and field behavior.
|
|
925
|
-
* When provided, enables typed input with tap-safe defaults:
|
|
926
|
-
* - booleans => `pulse`
|
|
927
|
-
* - vectors => `latest`
|
|
928
|
-
*
|
|
929
|
-
* @example
|
|
930
|
-
* ```ts
|
|
931
|
-
* input={{
|
|
932
|
-
* schema: z.object({
|
|
933
|
-
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
934
|
-
* action: z.boolean(),
|
|
935
|
-
* ability: z.boolean(),
|
|
936
|
-
* }),
|
|
937
|
-
* behavior: {
|
|
938
|
-
* pulse: ["action", "ability"], // consume-on-read actions
|
|
939
|
-
* latest: ["vector"], // continuous movement
|
|
940
|
-
* },
|
|
941
|
-
* }}
|
|
942
|
-
* ```
|
|
943
|
-
*/
|
|
944
|
-
input?: InputConfig<TSchema>;
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
type AirJamHostRuntimeProps<TSchema extends z.ZodSchema = z.ZodSchema> = AirJamProviderProps<TSchema> & AirJamHostOptions & {
|
|
948
|
-
children: ReactNode;
|
|
949
|
-
};
|
|
950
|
-
type AirJamControllerRuntimeProps = AirJamProviderProps & AirJamControllerOptions & {
|
|
951
|
-
children: ReactNode;
|
|
952
|
-
};
|
|
953
|
-
declare const AirJamHostRuntime: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, roomId, onPlayerJoin, onPlayerLeave, ...providerProps }: AirJamHostRuntimeProps<TSchema>) => JSX.Element;
|
|
954
|
-
declare const AirJamControllerRuntime: ({ children, roomId, nickname, avatarId, controllerId, capabilityToken, onState, ...providerProps }: AirJamControllerRuntimeProps) => JSX.Element;
|
|
955
|
-
|
|
956
349
|
type AirJamRuntimeRole = "host" | "controller";
|
|
957
350
|
interface AirJamRuntimeErrorContext {
|
|
958
351
|
role: AirJamRuntimeRole;
|
|
@@ -969,6 +362,7 @@ type AirJamErrorFallbackRenderer = (props: AirJamErrorFallbackRenderProps) => JS
|
|
|
969
362
|
interface AirJamErrorBoundaryProps extends AirJamRuntimeErrorContext {
|
|
970
363
|
children: ReactNode;
|
|
971
364
|
renderFallback?: AirJamErrorFallbackRenderer;
|
|
365
|
+
reportError?: (report: RuntimeErrorReport) => void;
|
|
972
366
|
onError?: (error: Error, errorInfo: ErrorInfo, context: AirJamRuntimeErrorContext) => void;
|
|
973
367
|
}
|
|
974
368
|
interface AirJamErrorBoundaryState {
|
|
@@ -983,6 +377,16 @@ declare class AirJamErrorBoundary extends Component<AirJamErrorBoundaryProps, Ai
|
|
|
983
377
|
render(): JSX.Element;
|
|
984
378
|
}
|
|
985
379
|
|
|
380
|
+
interface ResolveAirJamConfigInput {
|
|
381
|
+
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
382
|
+
surfaceRole?: SurfaceRole;
|
|
383
|
+
appId?: string;
|
|
384
|
+
hostGrantEndpoint?: string;
|
|
385
|
+
maxPlayers?: number;
|
|
386
|
+
hostSessionKind?: HostSessionKind;
|
|
387
|
+
resolveEnv?: boolean;
|
|
388
|
+
}
|
|
389
|
+
|
|
986
390
|
type HostSessionProps<TSchema extends z.ZodSchema> = Omit<AirJamProviderProps<TSchema>, "children">;
|
|
987
391
|
type ControllerSessionProps = Omit<AirJamProviderProps, "children" | "input">;
|
|
988
392
|
interface AirJamRuntimeErrorBoundaryOptions {
|
|
@@ -1001,11 +405,6 @@ interface CreateAirJamAppOptions<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
1001
405
|
* Defaults to "/controller".
|
|
1002
406
|
*/
|
|
1003
407
|
controllerPath?: string;
|
|
1004
|
-
/**
|
|
1005
|
-
* Experimental capability metadata for future agent-facing control,
|
|
1006
|
-
* inspection, and evaluation workflows.
|
|
1007
|
-
*/
|
|
1008
|
-
capabilities?: AirJamGameCapabilityManifest;
|
|
1009
408
|
/**
|
|
1010
409
|
* Optional semantic agent contract published by the app.
|
|
1011
410
|
*/
|
|
@@ -1030,7 +429,6 @@ interface AirJamApp<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
1030
429
|
runtime: ResolveAirJamConfigInput;
|
|
1031
430
|
metadata?: AirJamGameMetadata;
|
|
1032
431
|
controllerPath: string;
|
|
1033
|
-
capabilities?: AirJamGameCapabilityManifest;
|
|
1034
432
|
agent?: AirJamAgentContract;
|
|
1035
433
|
}
|
|
1036
434
|
type ViteEnvSource = Record<string, unknown> | undefined;
|
|
@@ -1040,7 +438,7 @@ declare const env: {
|
|
|
1040
438
|
readonly next: () => ResolveAirJamConfigInput;
|
|
1041
439
|
readonly explicit: (runtime: Omit<ResolveAirJamConfigInput, "resolveEnv">) => ResolveAirJamConfigInput;
|
|
1042
440
|
};
|
|
1043
|
-
declare const createAirJamApp: <TSchema extends z.ZodSchema = z.ZodSchema>({ runtime, metadata, controllerPath: requestedControllerPath,
|
|
441
|
+
declare const createAirJamApp: <TSchema extends z.ZodSchema = z.ZodSchema>({ runtime, metadata, controllerPath: requestedControllerPath, agent, input, errorBoundary, }?: CreateAirJamAppOptions<TSchema>) => AirJamApp<TSchema>;
|
|
1044
442
|
|
|
1045
443
|
declare const resolveAirJamBrowserRouterBasename: () => string;
|
|
1046
444
|
|
|
@@ -1153,4 +551,4 @@ interface ElementWithFullscreen extends HTMLElement {
|
|
|
1153
551
|
msRequestFullscreen?: () => Promise<void>;
|
|
1154
552
|
}
|
|
1155
553
|
|
|
1156
|
-
export {
|
|
554
|
+
export { type AirJamActionAcceptance, type AirJamActionContext, AirJamActionInvocationResult, type AirJamActionRejection, AirJamAgentContract, type AirJamApp, type AirJamAppErrorBoundaryOptions, AirJamControllerOptions, type AirJamDiagnostic, type AirJamDiagnosticCode, type AirJamDiagnosticSeverity, AirJamErrorBoundary, type AirJamErrorBoundaryProps, type AirJamErrorFallbackRenderProps, type AirJamErrorFallbackRenderer, type AirJamHostActionEvent, type AirJamHostActionListener, type AirJamHostActionSubscriptionOptions, AirJamHostOptions, type AirJamRuntimeErrorBoundaryOptions, type AirJamRuntimeRole, type AirJamSyncedStoreHook, type AudioHandle, AudioRuntime, type AudioRuntimeControls, type AudioRuntimeProps, type AudioRuntimeStatus, type AudioVolumeCategory, ConnectionStatus, type ControllerTickInfo, type ControllerTickOptions, type ControllerToast, type CreateAirJamAppOptions, type CreateAirJamStoreOptions, type DocumentWithFullscreen, type ElementWithFullscreen, HapticSignalPayload, type HostAudioMutePreference, type HostFrameInfo, type HostTickInfo, type HostTickOptions, MusicPlaylist, type MusicPlaylistProps, type PlayOptions, PlayerProfile, RoomCode, type RoomState, type SendSignalFn, type SoundCategory, type SoundConfig, type SoundManifest, ToastSignalPayload, type UseControllerToastsOptions, acceptAirJamAction, createAirJamApp, createAirJamStore, env, onAirJamDiagnostic, rejectAirJamAction, resolveAirJamBrowserRouterBasename, setAirJamDiagnosticsEnabled, useAudio, useAudioCategoryVolume, useAudioRuntimeControls, useAudioRuntimeStatus, useConnectionStatus, useControllerTick, useControllerToasts, useGetInput, useHostAudioMutePreference, useHostTick, useInputWriter, useMusicVolume, usePlayers, useRoom, useSendSignal };
|