@air-jam/sdk 0.9.2 → 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-Q4UALQO4.js → chunk-2SZ2YYGJ.js} +8 -16
- package/dist/chunk-2SZ2YYGJ.js.map +1 -0
- package/dist/{chunk-KOB73SPD.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-DY67S3LR.js → chunk-CV3PBXPT.js} +3 -3
- package/dist/chunk-D4VDEVTZ.js +80 -0
- package/dist/chunk-D4VDEVTZ.js.map +1 -0
- package/dist/{chunk-E5PVHEAX.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-6CMB356F.js → chunk-LIHEEAVE.js} +9 -11
- package/dist/chunk-LIHEEAVE.js.map +1 -0
- package/dist/{chunk-7OTQTT6H.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-M4DKOI42.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 +4260 -3870
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -649
- package/dist/index.d.ts +40 -649
- package/dist/index.js +1030 -3727
- 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 +593 -610
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +3 -3
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +16 -11
- 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/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/index.ts +6 -25
- 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-6CMB356F.js.map +0 -1
- package/dist/chunk-CVYR5RJT.js +0 -184
- package/dist/chunk-CVYR5RJT.js.map +0 -1
- package/dist/chunk-E5PVHEAX.js.map +0 -1
- package/dist/chunk-EDRQIOCV.js.map +0 -1
- package/dist/chunk-KOB73SPD.js.map +0 -1
- package/dist/chunk-NCL6WJCL.js.map +0 -1
- package/dist/chunk-NUJBMV3O.js.map +0 -1
- package/dist/chunk-Q4UALQO4.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-DY67S3LR.js.map → chunk-CV3PBXPT.js.map} +0 -0
- /package/dist/{chunk-7OTQTT6H.js.map → chunk-MIMPMB7O.js.map} +0 -0
- /package/dist/{chunk-M4DKOI42.js.map → chunk-QO4KFUEI.js.map} +0 -0
- /package/dist/{chunk-JO2HR5PV.js.map → chunk-UPV6YWT5.js.map} +0 -0
package/dist/index.d.cts
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.cjs';
|
|
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-CvJUW8Oe.cjs';
|
|
5
|
+
import { a as AirJamHostOptions, A as AirJamControllerOptions } from './use-air-jam-host-DM-ybB3C.cjs';
|
|
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-DM-ybB3C.cjs';
|
|
7
|
+
import { b as ConnectionStatus, t as ControllerInputPayload, P as PlayerProfile, R as RoomCode } from './controller-vj82tKm4.cjs';
|
|
8
|
+
export { d as ControllerOrientation, j as ControllerStatePayload, h as ControllerUpdatePlayerProfileAck, g as PlayerProfilePatch, e as RunMode, c as RuntimeState } from './controller-vj82tKm4.cjs';
|
|
9
|
+
import { T as ToastSignalPayload, H as HapticSignalPayload } from './signals-ZHftIKuc.cjs';
|
|
10
|
+
export { S as SignalPayload, b as SignalType } from './signals-ZHftIKuc.cjs';
|
|
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.cjs';
|
|
15
|
-
import { AirJamGameCapabilityManifest } from './capabilities.cjs';
|
|
12
|
+
import { e as AirJamActionActorRole, A as AirJamActionInvocationResult, g as AirJamActionPayload } from './sync-xtPfWhif.cjs';
|
|
13
|
+
export { i as AirJamActionAccepted, j as AirJamActionRejected } from './sync-xtPfWhif.cjs';
|
|
14
|
+
import { R as RuntimeErrorReport } from './runtime-reporting-pe-eryVz.cjs';
|
|
15
|
+
import { o as AirJamAgentContract } from './agent-contract-CD2QnbBJ.cjs';
|
|
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.cjs';
|
|
17
|
+
import { A as AirJamProviderProps } from './air-jam-context-BlLPvCup.cjs';
|
|
16
18
|
import { AirJamGameMetadata } from './metadata.cjs';
|
|
19
|
+
import { H as HostSessionKind } from './host-B9pRy0Aa.cjs';
|
|
20
|
+
import { RuntimeTopologyInput, ResolvedAirJamRuntimeTopology, SurfaceRole } from './runtime-topology.cjs';
|
|
17
21
|
import { StateCreator } from 'zustand';
|
|
18
22
|
import { StoreApi } from 'zustand/vanilla';
|
|
23
|
+
import './realtime-client-Cu8yVJFw.cjs';
|
|
24
|
+
import './notices-DNdOjwtj.cjs';
|
|
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;
|
|
@@ -605,13 +223,6 @@ interface HostTickOptions {
|
|
|
605
223
|
*/
|
|
606
224
|
declare const useHostTick: (options: HostTickOptions) => void;
|
|
607
225
|
|
|
608
|
-
interface HostAudioMutePreference {
|
|
609
|
-
muted: boolean;
|
|
610
|
-
setMuted: (muted: boolean) => void;
|
|
611
|
-
toggleMuted: () => void;
|
|
612
|
-
}
|
|
613
|
-
declare const useHostAudioMutePreference: (scope: string, defaultMuted?: boolean) => HostAudioMutePreference;
|
|
614
|
-
|
|
615
226
|
declare const useInputWriter: () => ((input: ControllerInputPayload) => boolean);
|
|
616
227
|
|
|
617
228
|
declare const usePlayers: () => PlayerProfile[];
|
|
@@ -735,231 +346,6 @@ interface SendSignalFn {
|
|
|
735
346
|
*/
|
|
736
347
|
declare const useSendSignal: () => SendSignalFn;
|
|
737
348
|
|
|
738
|
-
type HostInspectionApi = Pick<AirJamHostApi, "roomId" | "joinUrl" | "joinUrlStatus" | "connectionStatus" | "players" | "controllers" | "lastError" | "mode" | "runtimeState">;
|
|
739
|
-
type ControllerInspectionApi = Pick<AirJamControllerApi, "roomId" | "controllerId" | "connectionStatus" | "lastError" | "runtimeState" | "controllerOrientation" | "roomSettings" | "stateMessage" | "players" | "selfPlayer">;
|
|
740
|
-
interface HostRuntimeInspectionContract {
|
|
741
|
-
role: "host";
|
|
742
|
-
roomId: RoomCode;
|
|
743
|
-
joinUrl: string;
|
|
744
|
-
joinUrlStatus: JoinUrlStatus;
|
|
745
|
-
connectionStatus: ConnectionStatus;
|
|
746
|
-
players: readonly PlayerProfile[];
|
|
747
|
-
controllers: readonly ControllerPresenceNotice[];
|
|
748
|
-
lastError?: string;
|
|
749
|
-
mode: RunMode;
|
|
750
|
-
runtimeState: RuntimeState;
|
|
751
|
-
}
|
|
752
|
-
interface ControllerRuntimeInspectionContract {
|
|
753
|
-
role: "controller";
|
|
754
|
-
roomId: RoomCode | null;
|
|
755
|
-
controllerId: string | null;
|
|
756
|
-
connectionStatus: ConnectionStatus;
|
|
757
|
-
players: readonly PlayerProfile[];
|
|
758
|
-
selfPlayer: PlayerProfile | null;
|
|
759
|
-
lastError?: string;
|
|
760
|
-
runtimeState: RuntimeState;
|
|
761
|
-
controllerOrientation: ControllerOrientation;
|
|
762
|
-
stateMessage?: string;
|
|
763
|
-
roomSettings: ControllerInspectionApi["roomSettings"];
|
|
764
|
-
}
|
|
765
|
-
type RuntimeInspectionContract = HostRuntimeInspectionContract | ControllerRuntimeInspectionContract;
|
|
766
|
-
declare const AIR_JAM_RUNTIME_INSPECTION_KEY = "__airJamRuntimeInspection";
|
|
767
|
-
declare const createHostRuntimeInspectionContract: (api: HostInspectionApi) => HostRuntimeInspectionContract;
|
|
768
|
-
declare const createControllerRuntimeInspectionContract: (api: ControllerInspectionApi) => ControllerRuntimeInspectionContract;
|
|
769
|
-
declare const readRuntimeInspectionContract: (target: object) => RuntimeInspectionContract | null;
|
|
770
|
-
declare const publishRuntimeInspectionContract: (target: object, contract: RuntimeInspectionContract | null) => void;
|
|
771
|
-
|
|
772
|
-
declare const useHostRuntimeInspectionContract: () => HostRuntimeInspectionContract;
|
|
773
|
-
declare const useControllerRuntimeInspectionContract: () => ControllerRuntimeInspectionContract;
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* @module InputManager
|
|
777
|
-
* @description Internal input runtime used by host hooks.
|
|
778
|
-
*
|
|
779
|
-
* Public API terms:
|
|
780
|
-
* - `pulse`: consume-on-read, tap-safe behavior (default for booleans)
|
|
781
|
-
* - `hold`: keep last active vector until a new active value arrives
|
|
782
|
-
* - `latest`: read current value as-is (default for vectors and other fields)
|
|
783
|
-
*
|
|
784
|
-
* @internal This class is not exported publicly. Use hooks to access input.
|
|
785
|
-
*/
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* Configuration for input handling with optional validation and per-field behavior.
|
|
789
|
-
*
|
|
790
|
-
* Provided to `HostSessionProvider` to enable typed and behavior-aware input reads.
|
|
791
|
-
*
|
|
792
|
-
* @template TSchema - Zod schema type for input validation
|
|
793
|
-
*
|
|
794
|
-
* @example Basic schema validation
|
|
795
|
-
* ```ts
|
|
796
|
-
* const config: InputConfig = {
|
|
797
|
-
* schema: z.object({
|
|
798
|
-
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
799
|
-
* action: z.boolean(),
|
|
800
|
-
* }),
|
|
801
|
-
* };
|
|
802
|
-
* ```
|
|
803
|
-
*
|
|
804
|
-
* @example With custom behavior overrides
|
|
805
|
-
* ```ts
|
|
806
|
-
* const config: InputConfig = {
|
|
807
|
-
* schema: gameInputSchema,
|
|
808
|
-
* behavior: {
|
|
809
|
-
* pulse: ["action", "ability"], // consume-on-read
|
|
810
|
-
* latest: ["aim"], // read latest value
|
|
811
|
-
* hold: ["menuVector"], // keep last non-zero vector
|
|
812
|
-
* },
|
|
813
|
-
* };
|
|
814
|
-
* ```
|
|
815
|
-
*/
|
|
816
|
-
interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
817
|
-
/**
|
|
818
|
-
* Zod schema for input validation and type inference.
|
|
819
|
-
*
|
|
820
|
-
* When provided:
|
|
821
|
-
* - Incoming input is validated against the schema
|
|
822
|
-
* - Invalid input returns `undefined` (with console warning)
|
|
823
|
-
* - Return type is inferred from the schema
|
|
824
|
-
*
|
|
825
|
-
* @example
|
|
826
|
-
* ```ts
|
|
827
|
-
* schema: z.object({
|
|
828
|
-
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
829
|
-
* action: z.boolean(),
|
|
830
|
-
* ability: z.boolean(),
|
|
831
|
-
* timestamp: z.number(),
|
|
832
|
-
* })
|
|
833
|
-
* ```
|
|
834
|
-
*/
|
|
835
|
-
schema?: TSchema;
|
|
836
|
-
behavior?: {
|
|
837
|
-
/**
|
|
838
|
-
* Consume-on-read behavior. Useful for tap-safe buttons and one-shot vectors.
|
|
839
|
-
*
|
|
840
|
-
* Defaults: booleans use `pulse` even without explicit config.
|
|
841
|
-
*/
|
|
842
|
-
pulse?: string[];
|
|
843
|
-
/**
|
|
844
|
-
* Sticky behavior. For vectors, keeps the last non-zero direction until
|
|
845
|
-
* another non-zero direction arrives.
|
|
846
|
-
*/
|
|
847
|
-
hold?: string[];
|
|
848
|
-
/**
|
|
849
|
-
* Stateless behavior. Returns the latest raw value.
|
|
850
|
-
*
|
|
851
|
-
* Defaults: vectors and non-boolean fields use `latest`.
|
|
852
|
-
*/
|
|
853
|
-
latest?: string[];
|
|
854
|
-
};
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
interface ResolveAirJamConfigInput {
|
|
858
|
-
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
859
|
-
surfaceRole?: SurfaceRole;
|
|
860
|
-
appId?: string;
|
|
861
|
-
hostGrantEndpoint?: string;
|
|
862
|
-
maxPlayers?: number;
|
|
863
|
-
hostSessionKind?: HostSessionKind;
|
|
864
|
-
resolveEnv?: boolean;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
/**
|
|
868
|
-
* Props for the AirJamProvider component.
|
|
869
|
-
*
|
|
870
|
-
* @template TSchema - Zod schema type for input validation (inferred from input.schema)
|
|
871
|
-
*
|
|
872
|
-
* @example Minimal configuration (uses environment variables)
|
|
873
|
-
* ```tsx
|
|
874
|
-
* <HostSessionProvider>
|
|
875
|
-
* <App />
|
|
876
|
-
* </HostSessionProvider>
|
|
877
|
-
* ```
|
|
878
|
-
*
|
|
879
|
-
* @example Full configuration
|
|
880
|
-
* ```tsx
|
|
881
|
-
* <HostSessionProvider
|
|
882
|
-
* topology={myTopology}
|
|
883
|
-
* appId="your-app-id"
|
|
884
|
-
* hostGrantEndpoint="/api/airjam/host-grant"
|
|
885
|
-
* maxPlayers={4}
|
|
886
|
-
* input={{
|
|
887
|
-
* schema: myInputSchema,
|
|
888
|
-
* behavior: { pulse: ["fire"], latest: ["move"] },
|
|
889
|
-
* }}
|
|
890
|
-
* >
|
|
891
|
-
* <App />
|
|
892
|
-
* </HostSessionProvider>
|
|
893
|
-
* ```
|
|
894
|
-
*/
|
|
895
|
-
interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
896
|
-
/** React children to render within the provider */
|
|
897
|
-
children: ReactNode;
|
|
898
|
-
/** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
|
|
899
|
-
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
900
|
-
/** Internal surface-role hint when normalizing legacy endpoint props into topology. */
|
|
901
|
-
surfaceRole?: SurfaceRole;
|
|
902
|
-
/**
|
|
903
|
-
* App ID for production bootstrap identity.
|
|
904
|
-
* Falls back to VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID
|
|
905
|
-
* when not provided directly.
|
|
906
|
-
*/
|
|
907
|
-
appId?: string;
|
|
908
|
-
/**
|
|
909
|
-
* Optional endpoint that returns a short-lived signed host grant for stronger production bootstrap.
|
|
910
|
-
* When provided, the host runtime fetches a grant automatically before `host:bootstrap`.
|
|
911
|
-
*/
|
|
912
|
-
hostGrantEndpoint?: string;
|
|
913
|
-
/**
|
|
914
|
-
* Maximum number of players allowed in a room.
|
|
915
|
-
* @default 8
|
|
916
|
-
*/
|
|
917
|
-
maxPlayers?: number;
|
|
918
|
-
/**
|
|
919
|
-
* Declares whether this host provider owns a standalone game room or a system shell room.
|
|
920
|
-
* Standalone games should use `"game"`; Arcade shell hosts should use `"system"`.
|
|
921
|
-
* @default "game"
|
|
922
|
-
*/
|
|
923
|
-
hostSessionKind?: HostSessionKind;
|
|
924
|
-
/**
|
|
925
|
-
* Enable environment-variable fallback resolution for config fields.
|
|
926
|
-
* Set to false to require explicit `topology` / `appId` / `hostGrantEndpoint`.
|
|
927
|
-
* @default true
|
|
928
|
-
*/
|
|
929
|
-
resolveEnv?: boolean;
|
|
930
|
-
/**
|
|
931
|
-
* Input handling configuration including Zod schema validation and field behavior.
|
|
932
|
-
* When provided, enables typed input with tap-safe defaults:
|
|
933
|
-
* - booleans => `pulse`
|
|
934
|
-
* - vectors => `latest`
|
|
935
|
-
*
|
|
936
|
-
* @example
|
|
937
|
-
* ```ts
|
|
938
|
-
* input={{
|
|
939
|
-
* schema: z.object({
|
|
940
|
-
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
941
|
-
* action: z.boolean(),
|
|
942
|
-
* ability: z.boolean(),
|
|
943
|
-
* }),
|
|
944
|
-
* behavior: {
|
|
945
|
-
* pulse: ["action", "ability"], // consume-on-read actions
|
|
946
|
-
* latest: ["vector"], // continuous movement
|
|
947
|
-
* },
|
|
948
|
-
* }}
|
|
949
|
-
* ```
|
|
950
|
-
*/
|
|
951
|
-
input?: InputConfig<TSchema>;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
type AirJamHostRuntimeProps<TSchema extends z.ZodSchema = z.ZodSchema> = AirJamProviderProps<TSchema> & AirJamHostOptions & {
|
|
955
|
-
children: ReactNode;
|
|
956
|
-
};
|
|
957
|
-
type AirJamControllerRuntimeProps = AirJamProviderProps & AirJamControllerOptions & {
|
|
958
|
-
children: ReactNode;
|
|
959
|
-
};
|
|
960
|
-
declare const AirJamHostRuntime: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, roomId, onPlayerJoin, onPlayerLeave, ...providerProps }: AirJamHostRuntimeProps<TSchema>) => JSX.Element;
|
|
961
|
-
declare const AirJamControllerRuntime: ({ children, roomId, nickname, avatarId, controllerId, capabilityToken, onState, ...providerProps }: AirJamControllerRuntimeProps) => JSX.Element;
|
|
962
|
-
|
|
963
349
|
type AirJamRuntimeRole = "host" | "controller";
|
|
964
350
|
interface AirJamRuntimeErrorContext {
|
|
965
351
|
role: AirJamRuntimeRole;
|
|
@@ -976,6 +362,7 @@ type AirJamErrorFallbackRenderer = (props: AirJamErrorFallbackRenderProps) => JS
|
|
|
976
362
|
interface AirJamErrorBoundaryProps extends AirJamRuntimeErrorContext {
|
|
977
363
|
children: ReactNode;
|
|
978
364
|
renderFallback?: AirJamErrorFallbackRenderer;
|
|
365
|
+
reportError?: (report: RuntimeErrorReport) => void;
|
|
979
366
|
onError?: (error: Error, errorInfo: ErrorInfo, context: AirJamRuntimeErrorContext) => void;
|
|
980
367
|
}
|
|
981
368
|
interface AirJamErrorBoundaryState {
|
|
@@ -990,6 +377,16 @@ declare class AirJamErrorBoundary extends Component<AirJamErrorBoundaryProps, Ai
|
|
|
990
377
|
render(): JSX.Element;
|
|
991
378
|
}
|
|
992
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
|
+
|
|
993
390
|
type HostSessionProps<TSchema extends z.ZodSchema> = Omit<AirJamProviderProps<TSchema>, "children">;
|
|
994
391
|
type ControllerSessionProps = Omit<AirJamProviderProps, "children" | "input">;
|
|
995
392
|
interface AirJamRuntimeErrorBoundaryOptions {
|
|
@@ -1008,11 +405,6 @@ interface CreateAirJamAppOptions<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
1008
405
|
* Defaults to "/controller".
|
|
1009
406
|
*/
|
|
1010
407
|
controllerPath?: string;
|
|
1011
|
-
/**
|
|
1012
|
-
* Experimental capability metadata for future agent-facing control,
|
|
1013
|
-
* inspection, and evaluation workflows.
|
|
1014
|
-
*/
|
|
1015
|
-
capabilities?: AirJamGameCapabilityManifest;
|
|
1016
408
|
/**
|
|
1017
409
|
* Optional semantic agent contract published by the app.
|
|
1018
410
|
*/
|
|
@@ -1037,7 +429,6 @@ interface AirJamApp<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
1037
429
|
runtime: ResolveAirJamConfigInput;
|
|
1038
430
|
metadata?: AirJamGameMetadata;
|
|
1039
431
|
controllerPath: string;
|
|
1040
|
-
capabilities?: AirJamGameCapabilityManifest;
|
|
1041
432
|
agent?: AirJamAgentContract;
|
|
1042
433
|
}
|
|
1043
434
|
type ViteEnvSource = Record<string, unknown> | undefined;
|
|
@@ -1047,7 +438,7 @@ declare const env: {
|
|
|
1047
438
|
readonly next: () => ResolveAirJamConfigInput;
|
|
1048
439
|
readonly explicit: (runtime: Omit<ResolveAirJamConfigInput, "resolveEnv">) => ResolveAirJamConfigInput;
|
|
1049
440
|
};
|
|
1050
|
-
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>;
|
|
1051
442
|
|
|
1052
443
|
declare const resolveAirJamBrowserRouterBasename: () => string;
|
|
1053
444
|
|
|
@@ -1160,4 +551,4 @@ interface ElementWithFullscreen extends HTMLElement {
|
|
|
1160
551
|
msRequestFullscreen?: () => Promise<void>;
|
|
1161
552
|
}
|
|
1162
553
|
|
|
1163
|
-
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 };
|