@air-jam/sdk 0.1.1 → 0.1.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/dist/{chunk-7M5D3Y3L.js → chunk-B5DURUWT.js} +11 -3
- package/dist/chunk-B5DURUWT.js.map +1 -0
- package/dist/index.cjs +1733 -1783
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -66
- package/dist/index.d.ts +23 -66
- package/dist/index.js +1722 -1779
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +10 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +19 -1
- package/dist/protocol.d.ts +19 -1
- package/dist/protocol.js +1 -1
- package/package.json +4 -1
- package/src/AirJamClient.ts +1 -552
- package/src/audio/audio-manager.ts +12 -1
- package/src/audio/volume-store.ts +47 -0
- package/src/components/controller-shell.tsx +201 -177
- package/src/components/{air-jam-overlay.tsx → host-shell.tsx} +59 -51
- package/src/components/qr-scanner-dialog.tsx +2 -2
- package/src/constants.ts +3 -2
- package/src/context/air-jam-context.tsx +3 -14
- package/src/hooks/use-air-jam-controller.ts +1 -1
- package/src/hooks/use-air-jam-host.ts +94 -49
- package/src/hooks/use-air-jam-shell.ts +36 -0
- package/src/index.ts +1 -3
- package/src/internal/input-manager.ts +28 -14
- package/src/protocol.ts +28 -0
- package/src/store/create-air-jam-store.ts +69 -7
- package/src/utils/url-builder.ts +3 -3
- package/dist/chunk-7M5D3Y3L.js.map +0 -1
- package/src/components/air-jam-debug.tsx +0 -77
- package/src/components/debug-state-dialog.tsx +0 -83
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import * as React$1 from 'react';
|
|
|
3
3
|
import { ReactNode, JSX } from 'react';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { ControllerInputEvent, ConnectionRole, ConnectionStatus, RunMode, GameState, PlayerProfile, ServerToClientEvents, ClientToServerEvents, ControllerStatePayload, RoomCode, ControllerInputPayload, HapticSignalPayload, ToastSignalPayload } from './protocol.cjs';
|
|
6
|
-
export { AIRJAM_PROXY_PREFIX, AirJamActionRpcPayload, AirJamProxyMessage, AirJamStateSyncPayload, ClientLoadUiPayload, ControllerActionRpcPayload, ControllerJoinAck, ControllerJoinPayload, ControllerJoinedNotice, ControllerLeavePayload, ControllerLeftNotice, ControllerStateMessage, ControllerSystemPayload, ControllerWelcomePayload, ErrorCode, HostJoinAsChildPayload, HostLeftNotice, HostRegisterSystemPayload, HostRegistrationAck, HostRegistrationPayload, HostStateSyncPayload, InterServerEvents, PlaySoundEventPayload, PlaySoundPayload, ProxyInputMessage, ProxyMessageBase, ProxyReadyMessage, ProxyStateMessage, RoomReadyNotice, ServerErrorPayload, SignalPayload, SignalType, SocketData, SystemLaunchGameAck, SystemLaunchGamePayload, controllerInputSchema, controllerJoinSchema, controllerLeaveSchema, controllerStateSchema, controllerSystemSchema, hostJoinAsChildSchema, hostRegisterSystemSchema, hostRegistrationSchema, roomCodeSchema, systemLaunchGameSchema } from './protocol.cjs';
|
|
6
|
+
export { AIRJAM_PROXY_PREFIX, AirJamActionRpcPayload, AirJamProxyMessage, AirJamStateSyncPayload, ClientLoadUiPayload, ControllerActionRpcPayload, ControllerJoinAck, ControllerJoinPayload, ControllerJoinedNotice, ControllerLeavePayload, ControllerLeftNotice, ControllerStateMessage, ControllerSystemPayload, ControllerWelcomePayload, ErrorCode, HostCreateRoomPayload, HostJoinAsChildPayload, HostLeftNotice, HostReconnectPayload, HostRegisterSystemPayload, HostRegistrationAck, HostRegistrationPayload, HostStateSyncPayload, InterServerEvents, PlaySoundEventPayload, PlaySoundPayload, ProxyInputMessage, ProxyMessageBase, ProxyReadyMessage, ProxyStateMessage, RoomReadyNotice, ServerErrorPayload, SignalPayload, SignalType, SocketData, SystemLaunchGameAck, SystemLaunchGamePayload, controllerInputSchema, controllerJoinSchema, controllerLeaveSchema, controllerStateSchema, controllerSystemSchema, hostCreateRoomSchema, hostJoinAsChildSchema, hostReconnectSchema, hostRegisterSystemSchema, hostRegistrationSchema, roomCodeSchema, systemLaunchGameSchema } from './protocol.cjs';
|
|
7
7
|
import * as zustand from 'zustand';
|
|
8
8
|
import { StoreApi, StateCreator } from 'zustand';
|
|
9
9
|
import { Socket } from 'socket.io-client';
|
|
@@ -162,8 +162,7 @@ declare class InputManager<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
162
162
|
private inputBuffer;
|
|
163
163
|
private latchState;
|
|
164
164
|
private config;
|
|
165
|
-
|
|
166
|
-
constructor(config?: InputConfig<TSchema>, roomId?: string);
|
|
165
|
+
constructor(config?: InputConfig<TSchema>);
|
|
167
166
|
/**
|
|
168
167
|
* Handles incoming input events from the socket.
|
|
169
168
|
* Should be called when 'server:input' event is received.
|
|
@@ -179,10 +178,6 @@ declare class InputManager<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
179
178
|
* Clears input state for a controller (e.g., when player leaves).
|
|
180
179
|
*/
|
|
181
180
|
clearInput(controllerId: string): void;
|
|
182
|
-
/**
|
|
183
|
-
* Updates the room ID filter.
|
|
184
|
-
*/
|
|
185
|
-
setRoomId(roomId: string | undefined): void;
|
|
186
181
|
/**
|
|
187
182
|
* Internal method to apply latching logic.
|
|
188
183
|
*/
|
|
@@ -267,8 +262,6 @@ interface AirJamConfig {
|
|
|
267
262
|
serverUrl?: string;
|
|
268
263
|
/** API key for production authentication */
|
|
269
264
|
apiKey?: string;
|
|
270
|
-
/** Path for controller page (default: /joypad) */
|
|
271
|
-
controllerPath: string;
|
|
272
265
|
/** Maximum players allowed in a room */
|
|
273
266
|
maxPlayers: number;
|
|
274
267
|
/** Public host for controller URLs (optional) */
|
|
@@ -291,7 +284,6 @@ interface AirJamConfig {
|
|
|
291
284
|
* <AirJamProvider
|
|
292
285
|
* serverUrl="wss://your-server.com"
|
|
293
286
|
* apiKey="your-api-key"
|
|
294
|
-
* controllerPath="/controller"
|
|
295
287
|
* maxPlayers={4}
|
|
296
288
|
* input={{
|
|
297
289
|
* schema: myInputSchema,
|
|
@@ -315,12 +307,6 @@ interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
315
307
|
* Falls back to VITE_AIR_JAM_API_KEY or NEXT_PUBLIC_AIR_JAM_API_KEY environment variables.
|
|
316
308
|
*/
|
|
317
309
|
apiKey?: string;
|
|
318
|
-
/**
|
|
319
|
-
* URL path for the controller page on your app.
|
|
320
|
-
* Controllers will be directed to this path with ?room=XXXX query parameter.
|
|
321
|
-
* @default "/joypad"
|
|
322
|
-
*/
|
|
323
|
-
controllerPath?: string;
|
|
324
310
|
/**
|
|
325
311
|
* Maximum number of players allowed in a room.
|
|
326
312
|
* @default 8
|
|
@@ -390,7 +376,7 @@ declare const AirJamContext: React$1.Context<AirJamContextValue | null>;
|
|
|
390
376
|
* <AirJamProvider>
|
|
391
377
|
* <Routes>
|
|
392
378
|
* <Route path="/" element={<HostView />} />
|
|
393
|
-
* <Route path="/
|
|
379
|
+
* <Route path="/controller" element={<ControllerView />} />
|
|
394
380
|
* </Routes>
|
|
395
381
|
* </AirJamProvider>
|
|
396
382
|
* );
|
|
@@ -423,7 +409,7 @@ declare const AirJamContext: React$1.Context<AirJamContextValue | null>;
|
|
|
423
409
|
* );
|
|
424
410
|
* ```
|
|
425
411
|
*/
|
|
426
|
-
declare const AirJamProvider: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, serverUrl, apiKey,
|
|
412
|
+
declare const AirJamProvider: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, serverUrl, apiKey, maxPlayers, publicHost, input, }: AirJamProviderProps<TSchema>) => react_jsx_runtime.JSX.Element;
|
|
427
413
|
/**
|
|
428
414
|
* Access the raw AirJam context value.
|
|
429
415
|
*
|
|
@@ -536,7 +522,12 @@ declare class AudioManager<T extends string = string> {
|
|
|
536
522
|
getCategory(soundId: string): SoundCategory;
|
|
537
523
|
setSocket(socket: Socket<ServerToClientEvents, ClientToServerEvents> | null, roomId?: string): void;
|
|
538
524
|
/**
|
|
539
|
-
*
|
|
525
|
+
* Resume audio context if suspended. This is automatically called by play(),
|
|
526
|
+
* so you typically don't need to call this manually.
|
|
527
|
+
*
|
|
528
|
+
* Note: Due to browser autoplay policies, audio context starts suspended
|
|
529
|
+
* and can only be resumed in response to a user gesture. The useAudio hook
|
|
530
|
+
* handles this automatically, and play() also calls init() internally.
|
|
540
531
|
*/
|
|
541
532
|
init(): void;
|
|
542
533
|
/**
|
|
@@ -599,54 +590,19 @@ interface VolumeSettings {
|
|
|
599
590
|
}
|
|
600
591
|
declare const useVolumeStore: zustand.UseBoundStore<zustand.StoreApi<VolumeSettings>>;
|
|
601
592
|
|
|
602
|
-
interface AirJamDebugProps {
|
|
603
|
-
state: unknown;
|
|
604
|
-
title?: string;
|
|
605
|
-
updateInterval?: number;
|
|
606
|
-
className?: string;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* A debug component that displays state in a dialog.
|
|
610
|
-
* Place this component anywhere in your React tree and pass the state you want to debug.
|
|
611
|
-
*
|
|
612
|
-
* @example
|
|
613
|
-
* ```tsx
|
|
614
|
-
* const { phase, scores } = useGameStore((state) => state);
|
|
615
|
-
*
|
|
616
|
-
* return (
|
|
617
|
-
* <div>
|
|
618
|
-
* <AirJamDebug state={{ phase, scores }} />
|
|
619
|
-
* {/* Your game UI *\/}
|
|
620
|
-
* </div>
|
|
621
|
-
* );
|
|
622
|
-
* ```
|
|
623
|
-
*/
|
|
624
|
-
declare const AirJamDebug: ({ state, title, updateInterval, className, }: AirJamDebugProps) => JSX.Element;
|
|
625
|
-
|
|
626
|
-
declare const AirJamOverlay: () => JSX.Element | null;
|
|
627
|
-
|
|
628
|
-
type OrientationRequirement = "portrait" | "landscape" | "any";
|
|
629
593
|
interface ControllerShellProps {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
requiredOrientation?: OrientationRequirement;
|
|
594
|
+
/** Optional forced orientation. If not set, no orientation enforcement is applied. */
|
|
595
|
+
forceOrientation?: "portrait" | "landscape";
|
|
633
596
|
children: ReactNode;
|
|
634
|
-
|
|
635
|
-
onTogglePlayPause?: () => void;
|
|
636
|
-
onReconnect?: (roomCode: string) => void;
|
|
637
|
-
onRefresh?: () => void;
|
|
597
|
+
/** Optional custom actions to display in the header */
|
|
638
598
|
customActions?: ReactNode;
|
|
639
599
|
}
|
|
640
|
-
declare const ControllerShell: ({
|
|
600
|
+
declare const ControllerShell: ({ forceOrientation, children, customActions, }: ControllerShellProps) => JSX.Element;
|
|
641
601
|
|
|
642
|
-
interface
|
|
643
|
-
|
|
644
|
-
onClose: () => void;
|
|
645
|
-
getState: () => unknown;
|
|
646
|
-
title?: string;
|
|
647
|
-
updateInterval?: number;
|
|
602
|
+
interface HostShellProps {
|
|
603
|
+
children: ReactNode;
|
|
648
604
|
}
|
|
649
|
-
declare const
|
|
605
|
+
declare const HostShell: ({ children }: HostShellProps) => JSX.Element;
|
|
650
606
|
|
|
651
607
|
interface PlayerAvatarProps {
|
|
652
608
|
player: PlayerProfile;
|
|
@@ -679,9 +635,10 @@ declare function VolumeControls({ className, compact }: VolumeControlsProps): re
|
|
|
679
635
|
*/
|
|
680
636
|
declare const DEFAULT_SERVER_PORT = 4000;
|
|
681
637
|
/**
|
|
682
|
-
*
|
|
638
|
+
* Standard path for controller endpoints.
|
|
639
|
+
* All Air Jam games use this convention - controller is always at {baseUrl}/controller
|
|
683
640
|
*/
|
|
684
|
-
declare const
|
|
641
|
+
declare const CONTROLLER_PATH = "/controller";
|
|
685
642
|
/**
|
|
686
643
|
* Input debounce time in milliseconds
|
|
687
644
|
* Used to prevent rapid input events from overwhelming the system
|
|
@@ -935,7 +892,7 @@ declare const Events: {
|
|
|
935
892
|
*
|
|
936
893
|
* @example Basic usage (room from URL)
|
|
937
894
|
* ```tsx
|
|
938
|
-
* // URL: https://yourgame.com/
|
|
895
|
+
* // URL: https://yourgame.com/controller?room=ABCD
|
|
939
896
|
* const controller = useAirJamController();
|
|
940
897
|
* // Automatically joins room ABCD
|
|
941
898
|
* ```
|
|
@@ -1568,10 +1525,10 @@ declare class UrlBuilder {
|
|
|
1568
1525
|
normalizeForMobile(url: string): Promise<string>;
|
|
1569
1526
|
/**
|
|
1570
1527
|
* Build a controller URL with room code.
|
|
1528
|
+
* Controller is always at {baseUrl}/controller (standardized convention).
|
|
1571
1529
|
* Automatically uses local IP when running on localhost.
|
|
1572
1530
|
*/
|
|
1573
1531
|
buildControllerUrl(roomId: RoomCode, options?: {
|
|
1574
|
-
path?: string;
|
|
1575
1532
|
host?: string;
|
|
1576
1533
|
}): Promise<string>;
|
|
1577
1534
|
/**
|
|
@@ -1590,4 +1547,4 @@ declare class UrlBuilder {
|
|
|
1590
1547
|
}
|
|
1591
1548
|
declare const urlBuilder: UrlBuilder;
|
|
1592
1549
|
|
|
1593
|
-
export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions,
|
|
1550
|
+
export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions, type AirJamHostApi, type AirJamHostOptions, AirJamProvider, type AirJamProviderProps, type AirJamShellApi, type AirJamSocket, AudioManager, AudioProvider, Button, CONTROLLER_PATH, ChildEvents, ClientEvents, ClientToServerEvents, ConnectionRole, ConnectionStatus, ControllerEvents, ControllerInputEvent, ControllerInputPayload, ControllerShell, ControllerStatePayload, DEFAULT_MAX_PLAYERS, DEFAULT_SERVER_PORT, Events, GameState, HapticSignalPayload, HostEvents, HostShell, INPUT_DEBOUNCE_MS, type PlayOptions, PlayerAvatar, PlayerProfile, RoomCode, RunMode, SOCKET_CONFIG, type SendSignalFn, ServerEvents, ServerToClientEvents, Slider, SocketManager, type SoundCategory, type SoundConfig, type SoundManifest, SystemEvents, TOGGLE_DEBOUNCE_MS, ToastSignalPayload, UrlBuilder, VolumeControls, buttonVariants, createAirJamStore, createAudioManager, detectSoundCategory, generateControllerId, generateRoomCode, getLocalNetworkIp, urlBuilder, useAirJamConfig, useAirJamContext, useAirJamController, useAirJamHost, useAirJamShell, useAirJamSocket, useAirJamState, useAudio, useAudioLegacy, useAudioManager, useGetInput, useSendSignal, useVolumeStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as React$1 from 'react';
|
|
|
3
3
|
import { ReactNode, JSX } from 'react';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { ControllerInputEvent, ConnectionRole, ConnectionStatus, RunMode, GameState, PlayerProfile, ServerToClientEvents, ClientToServerEvents, ControllerStatePayload, RoomCode, ControllerInputPayload, HapticSignalPayload, ToastSignalPayload } from './protocol.js';
|
|
6
|
-
export { AIRJAM_PROXY_PREFIX, AirJamActionRpcPayload, AirJamProxyMessage, AirJamStateSyncPayload, ClientLoadUiPayload, ControllerActionRpcPayload, ControllerJoinAck, ControllerJoinPayload, ControllerJoinedNotice, ControllerLeavePayload, ControllerLeftNotice, ControllerStateMessage, ControllerSystemPayload, ControllerWelcomePayload, ErrorCode, HostJoinAsChildPayload, HostLeftNotice, HostRegisterSystemPayload, HostRegistrationAck, HostRegistrationPayload, HostStateSyncPayload, InterServerEvents, PlaySoundEventPayload, PlaySoundPayload, ProxyInputMessage, ProxyMessageBase, ProxyReadyMessage, ProxyStateMessage, RoomReadyNotice, ServerErrorPayload, SignalPayload, SignalType, SocketData, SystemLaunchGameAck, SystemLaunchGamePayload, controllerInputSchema, controllerJoinSchema, controllerLeaveSchema, controllerStateSchema, controllerSystemSchema, hostJoinAsChildSchema, hostRegisterSystemSchema, hostRegistrationSchema, roomCodeSchema, systemLaunchGameSchema } from './protocol.js';
|
|
6
|
+
export { AIRJAM_PROXY_PREFIX, AirJamActionRpcPayload, AirJamProxyMessage, AirJamStateSyncPayload, ClientLoadUiPayload, ControllerActionRpcPayload, ControllerJoinAck, ControllerJoinPayload, ControllerJoinedNotice, ControllerLeavePayload, ControllerLeftNotice, ControllerStateMessage, ControllerSystemPayload, ControllerWelcomePayload, ErrorCode, HostCreateRoomPayload, HostJoinAsChildPayload, HostLeftNotice, HostReconnectPayload, HostRegisterSystemPayload, HostRegistrationAck, HostRegistrationPayload, HostStateSyncPayload, InterServerEvents, PlaySoundEventPayload, PlaySoundPayload, ProxyInputMessage, ProxyMessageBase, ProxyReadyMessage, ProxyStateMessage, RoomReadyNotice, ServerErrorPayload, SignalPayload, SignalType, SocketData, SystemLaunchGameAck, SystemLaunchGamePayload, controllerInputSchema, controllerJoinSchema, controllerLeaveSchema, controllerStateSchema, controllerSystemSchema, hostCreateRoomSchema, hostJoinAsChildSchema, hostReconnectSchema, hostRegisterSystemSchema, hostRegistrationSchema, roomCodeSchema, systemLaunchGameSchema } from './protocol.js';
|
|
7
7
|
import * as zustand from 'zustand';
|
|
8
8
|
import { StoreApi, StateCreator } from 'zustand';
|
|
9
9
|
import { Socket } from 'socket.io-client';
|
|
@@ -162,8 +162,7 @@ declare class InputManager<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
162
162
|
private inputBuffer;
|
|
163
163
|
private latchState;
|
|
164
164
|
private config;
|
|
165
|
-
|
|
166
|
-
constructor(config?: InputConfig<TSchema>, roomId?: string);
|
|
165
|
+
constructor(config?: InputConfig<TSchema>);
|
|
167
166
|
/**
|
|
168
167
|
* Handles incoming input events from the socket.
|
|
169
168
|
* Should be called when 'server:input' event is received.
|
|
@@ -179,10 +178,6 @@ declare class InputManager<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
179
178
|
* Clears input state for a controller (e.g., when player leaves).
|
|
180
179
|
*/
|
|
181
180
|
clearInput(controllerId: string): void;
|
|
182
|
-
/**
|
|
183
|
-
* Updates the room ID filter.
|
|
184
|
-
*/
|
|
185
|
-
setRoomId(roomId: string | undefined): void;
|
|
186
181
|
/**
|
|
187
182
|
* Internal method to apply latching logic.
|
|
188
183
|
*/
|
|
@@ -267,8 +262,6 @@ interface AirJamConfig {
|
|
|
267
262
|
serverUrl?: string;
|
|
268
263
|
/** API key for production authentication */
|
|
269
264
|
apiKey?: string;
|
|
270
|
-
/** Path for controller page (default: /joypad) */
|
|
271
|
-
controllerPath: string;
|
|
272
265
|
/** Maximum players allowed in a room */
|
|
273
266
|
maxPlayers: number;
|
|
274
267
|
/** Public host for controller URLs (optional) */
|
|
@@ -291,7 +284,6 @@ interface AirJamConfig {
|
|
|
291
284
|
* <AirJamProvider
|
|
292
285
|
* serverUrl="wss://your-server.com"
|
|
293
286
|
* apiKey="your-api-key"
|
|
294
|
-
* controllerPath="/controller"
|
|
295
287
|
* maxPlayers={4}
|
|
296
288
|
* input={{
|
|
297
289
|
* schema: myInputSchema,
|
|
@@ -315,12 +307,6 @@ interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
|
315
307
|
* Falls back to VITE_AIR_JAM_API_KEY or NEXT_PUBLIC_AIR_JAM_API_KEY environment variables.
|
|
316
308
|
*/
|
|
317
309
|
apiKey?: string;
|
|
318
|
-
/**
|
|
319
|
-
* URL path for the controller page on your app.
|
|
320
|
-
* Controllers will be directed to this path with ?room=XXXX query parameter.
|
|
321
|
-
* @default "/joypad"
|
|
322
|
-
*/
|
|
323
|
-
controllerPath?: string;
|
|
324
310
|
/**
|
|
325
311
|
* Maximum number of players allowed in a room.
|
|
326
312
|
* @default 8
|
|
@@ -390,7 +376,7 @@ declare const AirJamContext: React$1.Context<AirJamContextValue | null>;
|
|
|
390
376
|
* <AirJamProvider>
|
|
391
377
|
* <Routes>
|
|
392
378
|
* <Route path="/" element={<HostView />} />
|
|
393
|
-
* <Route path="/
|
|
379
|
+
* <Route path="/controller" element={<ControllerView />} />
|
|
394
380
|
* </Routes>
|
|
395
381
|
* </AirJamProvider>
|
|
396
382
|
* );
|
|
@@ -423,7 +409,7 @@ declare const AirJamContext: React$1.Context<AirJamContextValue | null>;
|
|
|
423
409
|
* );
|
|
424
410
|
* ```
|
|
425
411
|
*/
|
|
426
|
-
declare const AirJamProvider: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, serverUrl, apiKey,
|
|
412
|
+
declare const AirJamProvider: <TSchema extends z.ZodSchema = z.ZodSchema>({ children, serverUrl, apiKey, maxPlayers, publicHost, input, }: AirJamProviderProps<TSchema>) => react_jsx_runtime.JSX.Element;
|
|
427
413
|
/**
|
|
428
414
|
* Access the raw AirJam context value.
|
|
429
415
|
*
|
|
@@ -536,7 +522,12 @@ declare class AudioManager<T extends string = string> {
|
|
|
536
522
|
getCategory(soundId: string): SoundCategory;
|
|
537
523
|
setSocket(socket: Socket<ServerToClientEvents, ClientToServerEvents> | null, roomId?: string): void;
|
|
538
524
|
/**
|
|
539
|
-
*
|
|
525
|
+
* Resume audio context if suspended. This is automatically called by play(),
|
|
526
|
+
* so you typically don't need to call this manually.
|
|
527
|
+
*
|
|
528
|
+
* Note: Due to browser autoplay policies, audio context starts suspended
|
|
529
|
+
* and can only be resumed in response to a user gesture. The useAudio hook
|
|
530
|
+
* handles this automatically, and play() also calls init() internally.
|
|
540
531
|
*/
|
|
541
532
|
init(): void;
|
|
542
533
|
/**
|
|
@@ -599,54 +590,19 @@ interface VolumeSettings {
|
|
|
599
590
|
}
|
|
600
591
|
declare const useVolumeStore: zustand.UseBoundStore<zustand.StoreApi<VolumeSettings>>;
|
|
601
592
|
|
|
602
|
-
interface AirJamDebugProps {
|
|
603
|
-
state: unknown;
|
|
604
|
-
title?: string;
|
|
605
|
-
updateInterval?: number;
|
|
606
|
-
className?: string;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* A debug component that displays state in a dialog.
|
|
610
|
-
* Place this component anywhere in your React tree and pass the state you want to debug.
|
|
611
|
-
*
|
|
612
|
-
* @example
|
|
613
|
-
* ```tsx
|
|
614
|
-
* const { phase, scores } = useGameStore((state) => state);
|
|
615
|
-
*
|
|
616
|
-
* return (
|
|
617
|
-
* <div>
|
|
618
|
-
* <AirJamDebug state={{ phase, scores }} />
|
|
619
|
-
* {/* Your game UI *\/}
|
|
620
|
-
* </div>
|
|
621
|
-
* );
|
|
622
|
-
* ```
|
|
623
|
-
*/
|
|
624
|
-
declare const AirJamDebug: ({ state, title, updateInterval, className, }: AirJamDebugProps) => JSX.Element;
|
|
625
|
-
|
|
626
|
-
declare const AirJamOverlay: () => JSX.Element | null;
|
|
627
|
-
|
|
628
|
-
type OrientationRequirement = "portrait" | "landscape" | "any";
|
|
629
593
|
interface ControllerShellProps {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
requiredOrientation?: OrientationRequirement;
|
|
594
|
+
/** Optional forced orientation. If not set, no orientation enforcement is applied. */
|
|
595
|
+
forceOrientation?: "portrait" | "landscape";
|
|
633
596
|
children: ReactNode;
|
|
634
|
-
|
|
635
|
-
onTogglePlayPause?: () => void;
|
|
636
|
-
onReconnect?: (roomCode: string) => void;
|
|
637
|
-
onRefresh?: () => void;
|
|
597
|
+
/** Optional custom actions to display in the header */
|
|
638
598
|
customActions?: ReactNode;
|
|
639
599
|
}
|
|
640
|
-
declare const ControllerShell: ({
|
|
600
|
+
declare const ControllerShell: ({ forceOrientation, children, customActions, }: ControllerShellProps) => JSX.Element;
|
|
641
601
|
|
|
642
|
-
interface
|
|
643
|
-
|
|
644
|
-
onClose: () => void;
|
|
645
|
-
getState: () => unknown;
|
|
646
|
-
title?: string;
|
|
647
|
-
updateInterval?: number;
|
|
602
|
+
interface HostShellProps {
|
|
603
|
+
children: ReactNode;
|
|
648
604
|
}
|
|
649
|
-
declare const
|
|
605
|
+
declare const HostShell: ({ children }: HostShellProps) => JSX.Element;
|
|
650
606
|
|
|
651
607
|
interface PlayerAvatarProps {
|
|
652
608
|
player: PlayerProfile;
|
|
@@ -679,9 +635,10 @@ declare function VolumeControls({ className, compact }: VolumeControlsProps): re
|
|
|
679
635
|
*/
|
|
680
636
|
declare const DEFAULT_SERVER_PORT = 4000;
|
|
681
637
|
/**
|
|
682
|
-
*
|
|
638
|
+
* Standard path for controller endpoints.
|
|
639
|
+
* All Air Jam games use this convention - controller is always at {baseUrl}/controller
|
|
683
640
|
*/
|
|
684
|
-
declare const
|
|
641
|
+
declare const CONTROLLER_PATH = "/controller";
|
|
685
642
|
/**
|
|
686
643
|
* Input debounce time in milliseconds
|
|
687
644
|
* Used to prevent rapid input events from overwhelming the system
|
|
@@ -935,7 +892,7 @@ declare const Events: {
|
|
|
935
892
|
*
|
|
936
893
|
* @example Basic usage (room from URL)
|
|
937
894
|
* ```tsx
|
|
938
|
-
* // URL: https://yourgame.com/
|
|
895
|
+
* // URL: https://yourgame.com/controller?room=ABCD
|
|
939
896
|
* const controller = useAirJamController();
|
|
940
897
|
* // Automatically joins room ABCD
|
|
941
898
|
* ```
|
|
@@ -1568,10 +1525,10 @@ declare class UrlBuilder {
|
|
|
1568
1525
|
normalizeForMobile(url: string): Promise<string>;
|
|
1569
1526
|
/**
|
|
1570
1527
|
* Build a controller URL with room code.
|
|
1528
|
+
* Controller is always at {baseUrl}/controller (standardized convention).
|
|
1571
1529
|
* Automatically uses local IP when running on localhost.
|
|
1572
1530
|
*/
|
|
1573
1531
|
buildControllerUrl(roomId: RoomCode, options?: {
|
|
1574
|
-
path?: string;
|
|
1575
1532
|
host?: string;
|
|
1576
1533
|
}): Promise<string>;
|
|
1577
1534
|
/**
|
|
@@ -1590,4 +1547,4 @@ declare class UrlBuilder {
|
|
|
1590
1547
|
}
|
|
1591
1548
|
declare const urlBuilder: UrlBuilder;
|
|
1592
1549
|
|
|
1593
|
-
export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions,
|
|
1550
|
+
export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions, type AirJamHostApi, type AirJamHostOptions, AirJamProvider, type AirJamProviderProps, type AirJamShellApi, type AirJamSocket, AudioManager, AudioProvider, Button, CONTROLLER_PATH, ChildEvents, ClientEvents, ClientToServerEvents, ConnectionRole, ConnectionStatus, ControllerEvents, ControllerInputEvent, ControllerInputPayload, ControllerShell, ControllerStatePayload, DEFAULT_MAX_PLAYERS, DEFAULT_SERVER_PORT, Events, GameState, HapticSignalPayload, HostEvents, HostShell, INPUT_DEBOUNCE_MS, type PlayOptions, PlayerAvatar, PlayerProfile, RoomCode, RunMode, SOCKET_CONFIG, type SendSignalFn, ServerEvents, ServerToClientEvents, Slider, SocketManager, type SoundCategory, type SoundConfig, type SoundManifest, SystemEvents, TOGGLE_DEBOUNCE_MS, ToastSignalPayload, UrlBuilder, VolumeControls, buttonVariants, createAirJamStore, createAudioManager, detectSoundCategory, generateControllerId, generateRoomCode, getLocalNetworkIp, urlBuilder, useAirJamConfig, useAirJamContext, useAirJamController, useAirJamHost, useAirJamShell, useAirJamSocket, useAirJamState, useAudio, useAudioLegacy, useAudioManager, useGetInput, useSendSignal, useVolumeStore };
|