@air-jam/sdk 0.1.0 → 0.1.2

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.
Files changed (37) hide show
  1. package/dist/{chunk-XSXI3RIS.js → chunk-B5DURUWT.js} +11 -3
  2. package/dist/chunk-B5DURUWT.js.map +1 -0
  3. package/dist/index.cjs +2346 -1931
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +97 -41
  6. package/dist/index.d.ts +97 -41
  7. package/dist/index.js +2401 -2001
  8. package/dist/index.js.map +1 -1
  9. package/dist/protocol.cjs +10 -0
  10. package/dist/protocol.cjs.map +1 -1
  11. package/dist/protocol.d.cts +42 -1
  12. package/dist/protocol.d.ts +42 -1
  13. package/dist/protocol.js +1 -1
  14. package/package.json +5 -1
  15. package/src/AirJamClient.ts +1 -552
  16. package/src/audio/audio-manager.ts +12 -1
  17. package/src/audio/volume-store.ts +47 -0
  18. package/src/components/air-jam-debug.tsx +77 -0
  19. package/src/components/air-jam-overlay.tsx +243 -186
  20. package/src/components/controller-shell.tsx +174 -182
  21. package/src/components/debug-state-dialog.tsx +83 -0
  22. package/src/components/player-avatar.tsx +64 -0
  23. package/src/components/qr-scanner-dialog.tsx +2 -2
  24. package/src/components/ui/button.tsx +1 -1
  25. package/src/components/ui/dialog.tsx +122 -0
  26. package/src/constants.ts +3 -2
  27. package/src/context/air-jam-context.tsx +3 -14
  28. package/src/hooks/use-air-jam-controller.ts +1 -1
  29. package/src/hooks/use-air-jam-host.ts +94 -49
  30. package/src/hooks/use-air-jam-shell.ts +36 -0
  31. package/src/index.ts +6 -0
  32. package/src/internal/input-manager.ts +28 -14
  33. package/src/protocol.ts +55 -0
  34. package/src/store/create-air-jam-store.ts +274 -0
  35. package/src/store/index.ts +1 -0
  36. package/src/utils/url-builder.ts +3 -3
  37. package/dist/chunk-XSXI3RIS.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -3,9 +3,9 @@ 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, AirJamProxyMessage, ClientLoadUiPayload, ControllerJoinAck, ControllerJoinPayload, ControllerJoinedNotice, ControllerLeavePayload, ControllerLeftNotice, ControllerStateMessage, ControllerSystemPayload, ControllerWelcomePayload, ErrorCode, HostJoinAsChildPayload, HostLeftNotice, HostRegisterSystemPayload, HostRegistrationAck, HostRegistrationPayload, 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
- import { StoreApi } from 'zustand';
8
+ import { StoreApi, StateCreator } from 'zustand';
9
9
  import { Socket } from 'socket.io-client';
10
10
  import * as class_variance_authority_types from 'class-variance-authority/types';
11
11
  import { VariantProps } from 'class-variance-authority';
@@ -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
- private roomId?;
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
  */
@@ -219,7 +214,7 @@ interface AirJamStore {
219
214
  * Factory function to create a new AirJamStore instance.
220
215
  * Each AirJamProvider creates its own store for multi-instance support.
221
216
  */
222
- declare const createAirJamStore: () => StoreApi<AirJamStore>;
217
+ declare const createAirJamStore$1: () => StoreApi<AirJamStore>;
223
218
 
224
219
  type AirJamSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
225
220
  /**
@@ -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
@@ -356,7 +342,7 @@ interface AirJamContextValue {
356
342
  /** Resolved configuration with env fallbacks */
357
343
  config: AirJamConfig;
358
344
  /** Context-bound Zustand store */
359
- store: ReturnType<typeof createAirJamStore>;
345
+ store: ReturnType<typeof createAirJamStore$1>;
360
346
  /** Socket manager for this provider instance */
361
347
  socketManager: SocketManager;
362
348
  /** Get socket for a specific role */
@@ -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="/joypad" element={<ControllerView />} />
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, controllerPath, maxPlayers, publicHost, input, }: AirJamProviderProps<TSchema>) => react_jsx_runtime.JSX.Element;
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
- * Initialize audio context (must be called on user interaction)
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,23 +590,37 @@ interface VolumeSettings {
599
590
  }
600
591
  declare const useVolumeStore: zustand.UseBoundStore<zustand.StoreApi<VolumeSettings>>;
601
592
 
602
- interface AirJamOverlayProps {
603
- roomId: string;
604
- joinUrl: string;
605
- connectionStatus: ConnectionStatus;
606
- players: PlayerProfile[];
607
- lastError?: string;
608
- gameState: GameState;
609
- onTogglePlayPause?: () => void;
610
- isChildMode?: boolean;
593
+ interface AirJamDebugProps {
594
+ state: unknown;
595
+ title?: string;
596
+ updateInterval?: number;
597
+ className?: string;
611
598
  }
612
- declare const AirJamOverlay: ({ roomId, joinUrl, connectionStatus, players, lastError, gameState, onTogglePlayPause, isChildMode, }: AirJamOverlayProps) => JSX.Element | null;
599
+ /**
600
+ * A debug component that displays state in a dialog.
601
+ * Place this component anywhere in your React tree and pass the state you want to debug.
602
+ *
603
+ * @example
604
+ * ```tsx
605
+ * const { phase, scores } = useGameStore((state) => state);
606
+ *
607
+ * return (
608
+ * <div>
609
+ * <AirJamDebug state={{ phase, scores }} />
610
+ * {/* Your game UI *\/}
611
+ * </div>
612
+ * );
613
+ * ```
614
+ */
615
+ declare const AirJamDebug: ({ state, title, updateInterval, className, }: AirJamDebugProps) => JSX.Element;
616
+
617
+ declare const AirJamOverlay: () => JSX.Element | null;
613
618
 
614
- type OrientationRequirement = "portrait" | "landscape" | "any";
615
619
  interface ControllerShellProps {
616
620
  roomId?: string | null;
617
621
  connectionStatus: ConnectionStatus;
618
- requiredOrientation?: OrientationRequirement;
622
+ /** Optional forced orientation. If not set, no orientation enforcement is applied. */
623
+ forceOrientation?: "portrait" | "landscape";
619
624
  children: ReactNode;
620
625
  gameState?: "paused" | "playing";
621
626
  onTogglePlayPause?: () => void;
@@ -623,10 +628,26 @@ interface ControllerShellProps {
623
628
  onRefresh?: () => void;
624
629
  customActions?: ReactNode;
625
630
  }
626
- declare const ControllerShell: ({ roomId, connectionStatus, requiredOrientation, children, gameState, onTogglePlayPause, onReconnect, onRefresh, customActions, }: ControllerShellProps) => JSX.Element;
631
+ declare const ControllerShell: ({ roomId, connectionStatus, forceOrientation, children, gameState, onTogglePlayPause, onReconnect, onRefresh, customActions, }: ControllerShellProps) => JSX.Element;
632
+
633
+ interface DebugStateDialogProps {
634
+ isOpen: boolean;
635
+ onClose: () => void;
636
+ getState: () => unknown;
637
+ title?: string;
638
+ updateInterval?: number;
639
+ }
640
+ declare const DebugStateDialog: ({ isOpen, onClose, getState, title, updateInterval, }: DebugStateDialogProps) => JSX.Element;
641
+
642
+ interface PlayerAvatarProps {
643
+ player: PlayerProfile;
644
+ size?: "sm" | "md" | "lg";
645
+ className?: string;
646
+ }
647
+ declare const PlayerAvatar: ({ player, size, className, }: PlayerAvatarProps) => JSX.Element;
627
648
 
628
649
  declare const buttonVariants: (props?: ({
629
- variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
650
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
630
651
  size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
631
652
  } & class_variance_authority_types.ClassProp) | undefined) => string;
632
653
  declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
@@ -649,9 +670,10 @@ declare function VolumeControls({ className, compact }: VolumeControlsProps): re
649
670
  */
650
671
  declare const DEFAULT_SERVER_PORT = 4000;
651
672
  /**
652
- * Default path for controller endpoints
673
+ * Standard path for controller endpoints.
674
+ * All Air Jam games use this convention - controller is always at {baseUrl}/controller
653
675
  */
654
- declare const DEFAULT_CONTROLLER_PATH = "/joypad";
676
+ declare const CONTROLLER_PATH = "/controller";
655
677
  /**
656
678
  * Input debounce time in milliseconds
657
679
  * Used to prevent rapid input events from overwhelming the system
@@ -905,7 +927,7 @@ declare const Events: {
905
927
  *
906
928
  * @example Basic usage (room from URL)
907
929
  * ```tsx
908
- * // URL: https://yourgame.com/joypad?room=ABCD
930
+ * // URL: https://yourgame.com/controller?room=ABCD
909
931
  * const controller = useAirJamController();
910
932
  * // Automatically joins room ABCD
911
933
  * ```
@@ -1470,6 +1492,40 @@ interface SendSignalFn {
1470
1492
  */
1471
1493
  declare const useSendSignal: () => SendSignalFn;
1472
1494
 
1495
+ /**
1496
+ * Creates a networked Zustand store that automatically syncs state between host and controllers.
1497
+ *
1498
+ * The store pattern works as follows:
1499
+ * - Host: Stores state locally and broadcasts changes to all controllers
1500
+ * - Controller: Sends action RPCs to host, receives state updates from host
1501
+ *
1502
+ * @example
1503
+ * ```ts
1504
+ * interface GameState {
1505
+ * phase: "lobby" | "playing" | "gameover";
1506
+ * scores: { team1: number; team2: number };
1507
+ * actions: {
1508
+ * setPhase: (phase: "lobby" | "playing") => void;
1509
+ * scorePoint: (team: "team1" | "team2") => void;
1510
+ * };
1511
+ * }
1512
+ *
1513
+ * export const useGameStore = createAirJamStore<GameState>((set) => ({
1514
+ * phase: "lobby",
1515
+ * scores: { team1: 0, team2: 0 },
1516
+ * actions: {
1517
+ * setPhase: (phase) => set({ phase }),
1518
+ * scorePoint: (team) => set((state) => ({
1519
+ * scores: { ...state.scores, [team]: state.scores[team] + 1 }
1520
+ * })),
1521
+ * },
1522
+ * }));
1523
+ * ```
1524
+ */
1525
+ declare function createAirJamStore<T extends {
1526
+ actions: Record<string, (...args: any[]) => any>;
1527
+ }>(initializer: StateCreator<T>): <U>(selector?: (state: T) => U) => U;
1528
+
1473
1529
  declare const generateRoomCode: () => string;
1474
1530
  declare const generateControllerId: () => string;
1475
1531
 
@@ -1504,10 +1560,10 @@ declare class UrlBuilder {
1504
1560
  normalizeForMobile(url: string): Promise<string>;
1505
1561
  /**
1506
1562
  * Build a controller URL with room code.
1563
+ * Controller is always at {baseUrl}/controller (standardized convention).
1507
1564
  * Automatically uses local IP when running on localhost.
1508
1565
  */
1509
1566
  buildControllerUrl(roomId: RoomCode, options?: {
1510
- path?: string;
1511
1567
  host?: string;
1512
1568
  }): Promise<string>;
1513
1569
  /**
@@ -1526,4 +1582,4 @@ declare class UrlBuilder {
1526
1582
  }
1527
1583
  declare const urlBuilder: UrlBuilder;
1528
1584
 
1529
- export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions, type AirJamHostApi, type AirJamHostOptions, AirJamOverlay, AirJamProvider, type AirJamProviderProps, type AirJamShellApi, type AirJamSocket, AudioManager, AudioProvider, Button, ChildEvents, ClientEvents, ClientToServerEvents, ConnectionRole, ConnectionStatus, ControllerEvents, ControllerInputEvent, ControllerInputPayload, ControllerShell, ControllerStatePayload, DEFAULT_CONTROLLER_PATH, DEFAULT_MAX_PLAYERS, DEFAULT_SERVER_PORT, Events, GameState, HapticSignalPayload, HostEvents, INPUT_DEBOUNCE_MS, type PlayOptions, 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, createAudioManager, detectSoundCategory, generateControllerId, generateRoomCode, getLocalNetworkIp, urlBuilder, useAirJamConfig, useAirJamContext, useAirJamController, useAirJamHost, useAirJamShell, useAirJamSocket, useAirJamState, useAudio, useAudioLegacy, useAudioManager, useGetInput, useSendSignal, useVolumeStore };
1585
+ export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions, AirJamDebug, type AirJamHostApi, type AirJamHostOptions, AirJamOverlay, 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, DebugStateDialog, Events, GameState, HapticSignalPayload, HostEvents, 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,9 +3,9 @@ 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, AirJamProxyMessage, ClientLoadUiPayload, ControllerJoinAck, ControllerJoinPayload, ControllerJoinedNotice, ControllerLeavePayload, ControllerLeftNotice, ControllerStateMessage, ControllerSystemPayload, ControllerWelcomePayload, ErrorCode, HostJoinAsChildPayload, HostLeftNotice, HostRegisterSystemPayload, HostRegistrationAck, HostRegistrationPayload, 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
- import { StoreApi } from 'zustand';
8
+ import { StoreApi, StateCreator } from 'zustand';
9
9
  import { Socket } from 'socket.io-client';
10
10
  import * as class_variance_authority_types from 'class-variance-authority/types';
11
11
  import { VariantProps } from 'class-variance-authority';
@@ -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
- private roomId?;
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
  */
@@ -219,7 +214,7 @@ interface AirJamStore {
219
214
  * Factory function to create a new AirJamStore instance.
220
215
  * Each AirJamProvider creates its own store for multi-instance support.
221
216
  */
222
- declare const createAirJamStore: () => StoreApi<AirJamStore>;
217
+ declare const createAirJamStore$1: () => StoreApi<AirJamStore>;
223
218
 
224
219
  type AirJamSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
225
220
  /**
@@ -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
@@ -356,7 +342,7 @@ interface AirJamContextValue {
356
342
  /** Resolved configuration with env fallbacks */
357
343
  config: AirJamConfig;
358
344
  /** Context-bound Zustand store */
359
- store: ReturnType<typeof createAirJamStore>;
345
+ store: ReturnType<typeof createAirJamStore$1>;
360
346
  /** Socket manager for this provider instance */
361
347
  socketManager: SocketManager;
362
348
  /** Get socket for a specific role */
@@ -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="/joypad" element={<ControllerView />} />
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, controllerPath, maxPlayers, publicHost, input, }: AirJamProviderProps<TSchema>) => react_jsx_runtime.JSX.Element;
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
- * Initialize audio context (must be called on user interaction)
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,23 +590,37 @@ interface VolumeSettings {
599
590
  }
600
591
  declare const useVolumeStore: zustand.UseBoundStore<zustand.StoreApi<VolumeSettings>>;
601
592
 
602
- interface AirJamOverlayProps {
603
- roomId: string;
604
- joinUrl: string;
605
- connectionStatus: ConnectionStatus;
606
- players: PlayerProfile[];
607
- lastError?: string;
608
- gameState: GameState;
609
- onTogglePlayPause?: () => void;
610
- isChildMode?: boolean;
593
+ interface AirJamDebugProps {
594
+ state: unknown;
595
+ title?: string;
596
+ updateInterval?: number;
597
+ className?: string;
611
598
  }
612
- declare const AirJamOverlay: ({ roomId, joinUrl, connectionStatus, players, lastError, gameState, onTogglePlayPause, isChildMode, }: AirJamOverlayProps) => JSX.Element | null;
599
+ /**
600
+ * A debug component that displays state in a dialog.
601
+ * Place this component anywhere in your React tree and pass the state you want to debug.
602
+ *
603
+ * @example
604
+ * ```tsx
605
+ * const { phase, scores } = useGameStore((state) => state);
606
+ *
607
+ * return (
608
+ * <div>
609
+ * <AirJamDebug state={{ phase, scores }} />
610
+ * {/* Your game UI *\/}
611
+ * </div>
612
+ * );
613
+ * ```
614
+ */
615
+ declare const AirJamDebug: ({ state, title, updateInterval, className, }: AirJamDebugProps) => JSX.Element;
616
+
617
+ declare const AirJamOverlay: () => JSX.Element | null;
613
618
 
614
- type OrientationRequirement = "portrait" | "landscape" | "any";
615
619
  interface ControllerShellProps {
616
620
  roomId?: string | null;
617
621
  connectionStatus: ConnectionStatus;
618
- requiredOrientation?: OrientationRequirement;
622
+ /** Optional forced orientation. If not set, no orientation enforcement is applied. */
623
+ forceOrientation?: "portrait" | "landscape";
619
624
  children: ReactNode;
620
625
  gameState?: "paused" | "playing";
621
626
  onTogglePlayPause?: () => void;
@@ -623,10 +628,26 @@ interface ControllerShellProps {
623
628
  onRefresh?: () => void;
624
629
  customActions?: ReactNode;
625
630
  }
626
- declare const ControllerShell: ({ roomId, connectionStatus, requiredOrientation, children, gameState, onTogglePlayPause, onReconnect, onRefresh, customActions, }: ControllerShellProps) => JSX.Element;
631
+ declare const ControllerShell: ({ roomId, connectionStatus, forceOrientation, children, gameState, onTogglePlayPause, onReconnect, onRefresh, customActions, }: ControllerShellProps) => JSX.Element;
632
+
633
+ interface DebugStateDialogProps {
634
+ isOpen: boolean;
635
+ onClose: () => void;
636
+ getState: () => unknown;
637
+ title?: string;
638
+ updateInterval?: number;
639
+ }
640
+ declare const DebugStateDialog: ({ isOpen, onClose, getState, title, updateInterval, }: DebugStateDialogProps) => JSX.Element;
641
+
642
+ interface PlayerAvatarProps {
643
+ player: PlayerProfile;
644
+ size?: "sm" | "md" | "lg";
645
+ className?: string;
646
+ }
647
+ declare const PlayerAvatar: ({ player, size, className, }: PlayerAvatarProps) => JSX.Element;
627
648
 
628
649
  declare const buttonVariants: (props?: ({
629
- variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
650
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
630
651
  size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
631
652
  } & class_variance_authority_types.ClassProp) | undefined) => string;
632
653
  declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
@@ -649,9 +670,10 @@ declare function VolumeControls({ className, compact }: VolumeControlsProps): re
649
670
  */
650
671
  declare const DEFAULT_SERVER_PORT = 4000;
651
672
  /**
652
- * Default path for controller endpoints
673
+ * Standard path for controller endpoints.
674
+ * All Air Jam games use this convention - controller is always at {baseUrl}/controller
653
675
  */
654
- declare const DEFAULT_CONTROLLER_PATH = "/joypad";
676
+ declare const CONTROLLER_PATH = "/controller";
655
677
  /**
656
678
  * Input debounce time in milliseconds
657
679
  * Used to prevent rapid input events from overwhelming the system
@@ -905,7 +927,7 @@ declare const Events: {
905
927
  *
906
928
  * @example Basic usage (room from URL)
907
929
  * ```tsx
908
- * // URL: https://yourgame.com/joypad?room=ABCD
930
+ * // URL: https://yourgame.com/controller?room=ABCD
909
931
  * const controller = useAirJamController();
910
932
  * // Automatically joins room ABCD
911
933
  * ```
@@ -1470,6 +1492,40 @@ interface SendSignalFn {
1470
1492
  */
1471
1493
  declare const useSendSignal: () => SendSignalFn;
1472
1494
 
1495
+ /**
1496
+ * Creates a networked Zustand store that automatically syncs state between host and controllers.
1497
+ *
1498
+ * The store pattern works as follows:
1499
+ * - Host: Stores state locally and broadcasts changes to all controllers
1500
+ * - Controller: Sends action RPCs to host, receives state updates from host
1501
+ *
1502
+ * @example
1503
+ * ```ts
1504
+ * interface GameState {
1505
+ * phase: "lobby" | "playing" | "gameover";
1506
+ * scores: { team1: number; team2: number };
1507
+ * actions: {
1508
+ * setPhase: (phase: "lobby" | "playing") => void;
1509
+ * scorePoint: (team: "team1" | "team2") => void;
1510
+ * };
1511
+ * }
1512
+ *
1513
+ * export const useGameStore = createAirJamStore<GameState>((set) => ({
1514
+ * phase: "lobby",
1515
+ * scores: { team1: 0, team2: 0 },
1516
+ * actions: {
1517
+ * setPhase: (phase) => set({ phase }),
1518
+ * scorePoint: (team) => set((state) => ({
1519
+ * scores: { ...state.scores, [team]: state.scores[team] + 1 }
1520
+ * })),
1521
+ * },
1522
+ * }));
1523
+ * ```
1524
+ */
1525
+ declare function createAirJamStore<T extends {
1526
+ actions: Record<string, (...args: any[]) => any>;
1527
+ }>(initializer: StateCreator<T>): <U>(selector?: (state: T) => U) => U;
1528
+
1473
1529
  declare const generateRoomCode: () => string;
1474
1530
  declare const generateControllerId: () => string;
1475
1531
 
@@ -1504,10 +1560,10 @@ declare class UrlBuilder {
1504
1560
  normalizeForMobile(url: string): Promise<string>;
1505
1561
  /**
1506
1562
  * Build a controller URL with room code.
1563
+ * Controller is always at {baseUrl}/controller (standardized convention).
1507
1564
  * Automatically uses local IP when running on localhost.
1508
1565
  */
1509
1566
  buildControllerUrl(roomId: RoomCode, options?: {
1510
- path?: string;
1511
1567
  host?: string;
1512
1568
  }): Promise<string>;
1513
1569
  /**
@@ -1526,4 +1582,4 @@ declare class UrlBuilder {
1526
1582
  }
1527
1583
  declare const urlBuilder: UrlBuilder;
1528
1584
 
1529
- export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions, type AirJamHostApi, type AirJamHostOptions, AirJamOverlay, AirJamProvider, type AirJamProviderProps, type AirJamShellApi, type AirJamSocket, AudioManager, AudioProvider, Button, ChildEvents, ClientEvents, ClientToServerEvents, ConnectionRole, ConnectionStatus, ControllerEvents, ControllerInputEvent, ControllerInputPayload, ControllerShell, ControllerStatePayload, DEFAULT_CONTROLLER_PATH, DEFAULT_MAX_PLAYERS, DEFAULT_SERVER_PORT, Events, GameState, HapticSignalPayload, HostEvents, INPUT_DEBOUNCE_MS, type PlayOptions, 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, createAudioManager, detectSoundCategory, generateControllerId, generateRoomCode, getLocalNetworkIp, urlBuilder, useAirJamConfig, useAirJamContext, useAirJamController, useAirJamHost, useAirJamShell, useAirJamSocket, useAirJamState, useAudio, useAudioLegacy, useAudioManager, useGetInput, useSendSignal, useVolumeStore };
1585
+ export { type AirJamConfig, AirJamContext, type AirJamContextValue, type AirJamControllerApi, type AirJamControllerOptions, AirJamDebug, type AirJamHostApi, type AirJamHostOptions, AirJamOverlay, 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, DebugStateDialog, Events, GameState, HapticSignalPayload, HostEvents, 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 };