@air-jam/sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-XSXI3RIS.js → chunk-7M5D3Y3L.js} +2 -2
- package/dist/{chunk-XSXI3RIS.js.map → chunk-7M5D3Y3L.js.map} +1 -1
- package/dist/index.cjs +2209 -1893
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -16
- package/dist/index.d.ts +80 -16
- package/dist/index.js +1984 -1673
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +24 -1
- package/dist/protocol.d.ts +24 -1
- package/dist/protocol.js +1 -1
- package/package.json +2 -1
- package/src/components/air-jam-debug.tsx +77 -0
- package/src/components/air-jam-overlay.tsx +243 -186
- package/src/components/controller-shell.tsx +17 -24
- package/src/components/debug-state-dialog.tsx +83 -0
- package/src/components/player-avatar.tsx +64 -0
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/dialog.tsx +122 -0
- package/src/index.ts +6 -0
- package/src/protocol.ts +27 -0
- package/src/store/create-air-jam-store.ts +212 -0
- package/src/store/index.ts +1 -0
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, 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';
|
|
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';
|
|
@@ -219,7 +219,7 @@ interface AirJamStore {
|
|
|
219
219
|
* Factory function to create a new AirJamStore instance.
|
|
220
220
|
* Each AirJamProvider creates its own store for multi-instance support.
|
|
221
221
|
*/
|
|
222
|
-
declare const createAirJamStore: () => StoreApi<AirJamStore>;
|
|
222
|
+
declare const createAirJamStore$1: () => StoreApi<AirJamStore>;
|
|
223
223
|
|
|
224
224
|
type AirJamSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
|
|
225
225
|
/**
|
|
@@ -356,7 +356,7 @@ interface AirJamContextValue {
|
|
|
356
356
|
/** Resolved configuration with env fallbacks */
|
|
357
357
|
config: AirJamConfig;
|
|
358
358
|
/** Context-bound Zustand store */
|
|
359
|
-
store: ReturnType<typeof createAirJamStore>;
|
|
359
|
+
store: ReturnType<typeof createAirJamStore$1>;
|
|
360
360
|
/** Socket manager for this provider instance */
|
|
361
361
|
socketManager: SocketManager;
|
|
362
362
|
/** Get socket for a specific role */
|
|
@@ -599,17 +599,31 @@ interface VolumeSettings {
|
|
|
599
599
|
}
|
|
600
600
|
declare const useVolumeStore: zustand.UseBoundStore<zustand.StoreApi<VolumeSettings>>;
|
|
601
601
|
|
|
602
|
-
interface
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
lastError?: string;
|
|
608
|
-
gameState: GameState;
|
|
609
|
-
onTogglePlayPause?: () => void;
|
|
610
|
-
isChildMode?: boolean;
|
|
602
|
+
interface AirJamDebugProps {
|
|
603
|
+
state: unknown;
|
|
604
|
+
title?: string;
|
|
605
|
+
updateInterval?: number;
|
|
606
|
+
className?: string;
|
|
611
607
|
}
|
|
612
|
-
|
|
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;
|
|
613
627
|
|
|
614
628
|
type OrientationRequirement = "portrait" | "landscape" | "any";
|
|
615
629
|
interface ControllerShellProps {
|
|
@@ -625,8 +639,24 @@ interface ControllerShellProps {
|
|
|
625
639
|
}
|
|
626
640
|
declare const ControllerShell: ({ roomId, connectionStatus, requiredOrientation, children, gameState, onTogglePlayPause, onReconnect, onRefresh, customActions, }: ControllerShellProps) => JSX.Element;
|
|
627
641
|
|
|
642
|
+
interface DebugStateDialogProps {
|
|
643
|
+
isOpen: boolean;
|
|
644
|
+
onClose: () => void;
|
|
645
|
+
getState: () => unknown;
|
|
646
|
+
title?: string;
|
|
647
|
+
updateInterval?: number;
|
|
648
|
+
}
|
|
649
|
+
declare const DebugStateDialog: ({ isOpen, onClose, getState, title, updateInterval, }: DebugStateDialogProps) => JSX.Element;
|
|
650
|
+
|
|
651
|
+
interface PlayerAvatarProps {
|
|
652
|
+
player: PlayerProfile;
|
|
653
|
+
size?: "sm" | "md" | "lg";
|
|
654
|
+
className?: string;
|
|
655
|
+
}
|
|
656
|
+
declare const PlayerAvatar: ({ player, size, className, }: PlayerAvatarProps) => JSX.Element;
|
|
657
|
+
|
|
628
658
|
declare const buttonVariants: (props?: ({
|
|
629
|
-
variant?: "default" | "link" | "destructive" | "
|
|
659
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
630
660
|
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
|
|
631
661
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
632
662
|
declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
@@ -1470,6 +1500,40 @@ interface SendSignalFn {
|
|
|
1470
1500
|
*/
|
|
1471
1501
|
declare const useSendSignal: () => SendSignalFn;
|
|
1472
1502
|
|
|
1503
|
+
/**
|
|
1504
|
+
* Creates a networked Zustand store that automatically syncs state between host and controllers.
|
|
1505
|
+
*
|
|
1506
|
+
* The store pattern works as follows:
|
|
1507
|
+
* - Host: Stores state locally and broadcasts changes to all controllers
|
|
1508
|
+
* - Controller: Sends action RPCs to host, receives state updates from host
|
|
1509
|
+
*
|
|
1510
|
+
* @example
|
|
1511
|
+
* ```ts
|
|
1512
|
+
* interface GameState {
|
|
1513
|
+
* phase: "lobby" | "playing" | "gameover";
|
|
1514
|
+
* scores: { team1: number; team2: number };
|
|
1515
|
+
* actions: {
|
|
1516
|
+
* setPhase: (phase: "lobby" | "playing") => void;
|
|
1517
|
+
* scorePoint: (team: "team1" | "team2") => void;
|
|
1518
|
+
* };
|
|
1519
|
+
* }
|
|
1520
|
+
*
|
|
1521
|
+
* export const useGameStore = createAirJamStore<GameState>((set) => ({
|
|
1522
|
+
* phase: "lobby",
|
|
1523
|
+
* scores: { team1: 0, team2: 0 },
|
|
1524
|
+
* actions: {
|
|
1525
|
+
* setPhase: (phase) => set({ phase }),
|
|
1526
|
+
* scorePoint: (team) => set((state) => ({
|
|
1527
|
+
* scores: { ...state.scores, [team]: state.scores[team] + 1 }
|
|
1528
|
+
* })),
|
|
1529
|
+
* },
|
|
1530
|
+
* }));
|
|
1531
|
+
* ```
|
|
1532
|
+
*/
|
|
1533
|
+
declare function createAirJamStore<T extends {
|
|
1534
|
+
actions: Record<string, (...args: any[]) => any>;
|
|
1535
|
+
}>(initializer: StateCreator<T>): <U>(selector?: (state: T) => U) => U;
|
|
1536
|
+
|
|
1473
1537
|
declare const generateRoomCode: () => string;
|
|
1474
1538
|
declare const generateControllerId: () => string;
|
|
1475
1539
|
|
|
@@ -1526,4 +1590,4 @@ declare class UrlBuilder {
|
|
|
1526
1590
|
}
|
|
1527
1591
|
declare const urlBuilder: UrlBuilder;
|
|
1528
1592
|
|
|
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 };
|
|
1593
|
+
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, ChildEvents, ClientEvents, ClientToServerEvents, ConnectionRole, ConnectionStatus, ControllerEvents, ControllerInputEvent, ControllerInputPayload, ControllerShell, ControllerStatePayload, DEFAULT_CONTROLLER_PATH, 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, 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';
|
|
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';
|
|
@@ -219,7 +219,7 @@ interface AirJamStore {
|
|
|
219
219
|
* Factory function to create a new AirJamStore instance.
|
|
220
220
|
* Each AirJamProvider creates its own store for multi-instance support.
|
|
221
221
|
*/
|
|
222
|
-
declare const createAirJamStore: () => StoreApi<AirJamStore>;
|
|
222
|
+
declare const createAirJamStore$1: () => StoreApi<AirJamStore>;
|
|
223
223
|
|
|
224
224
|
type AirJamSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
|
|
225
225
|
/**
|
|
@@ -356,7 +356,7 @@ interface AirJamContextValue {
|
|
|
356
356
|
/** Resolved configuration with env fallbacks */
|
|
357
357
|
config: AirJamConfig;
|
|
358
358
|
/** Context-bound Zustand store */
|
|
359
|
-
store: ReturnType<typeof createAirJamStore>;
|
|
359
|
+
store: ReturnType<typeof createAirJamStore$1>;
|
|
360
360
|
/** Socket manager for this provider instance */
|
|
361
361
|
socketManager: SocketManager;
|
|
362
362
|
/** Get socket for a specific role */
|
|
@@ -599,17 +599,31 @@ interface VolumeSettings {
|
|
|
599
599
|
}
|
|
600
600
|
declare const useVolumeStore: zustand.UseBoundStore<zustand.StoreApi<VolumeSettings>>;
|
|
601
601
|
|
|
602
|
-
interface
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
lastError?: string;
|
|
608
|
-
gameState: GameState;
|
|
609
|
-
onTogglePlayPause?: () => void;
|
|
610
|
-
isChildMode?: boolean;
|
|
602
|
+
interface AirJamDebugProps {
|
|
603
|
+
state: unknown;
|
|
604
|
+
title?: string;
|
|
605
|
+
updateInterval?: number;
|
|
606
|
+
className?: string;
|
|
611
607
|
}
|
|
612
|
-
|
|
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;
|
|
613
627
|
|
|
614
628
|
type OrientationRequirement = "portrait" | "landscape" | "any";
|
|
615
629
|
interface ControllerShellProps {
|
|
@@ -625,8 +639,24 @@ interface ControllerShellProps {
|
|
|
625
639
|
}
|
|
626
640
|
declare const ControllerShell: ({ roomId, connectionStatus, requiredOrientation, children, gameState, onTogglePlayPause, onReconnect, onRefresh, customActions, }: ControllerShellProps) => JSX.Element;
|
|
627
641
|
|
|
642
|
+
interface DebugStateDialogProps {
|
|
643
|
+
isOpen: boolean;
|
|
644
|
+
onClose: () => void;
|
|
645
|
+
getState: () => unknown;
|
|
646
|
+
title?: string;
|
|
647
|
+
updateInterval?: number;
|
|
648
|
+
}
|
|
649
|
+
declare const DebugStateDialog: ({ isOpen, onClose, getState, title, updateInterval, }: DebugStateDialogProps) => JSX.Element;
|
|
650
|
+
|
|
651
|
+
interface PlayerAvatarProps {
|
|
652
|
+
player: PlayerProfile;
|
|
653
|
+
size?: "sm" | "md" | "lg";
|
|
654
|
+
className?: string;
|
|
655
|
+
}
|
|
656
|
+
declare const PlayerAvatar: ({ player, size, className, }: PlayerAvatarProps) => JSX.Element;
|
|
657
|
+
|
|
628
658
|
declare const buttonVariants: (props?: ({
|
|
629
|
-
variant?: "default" | "link" | "destructive" | "
|
|
659
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
630
660
|
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
|
|
631
661
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
632
662
|
declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
@@ -1470,6 +1500,40 @@ interface SendSignalFn {
|
|
|
1470
1500
|
*/
|
|
1471
1501
|
declare const useSendSignal: () => SendSignalFn;
|
|
1472
1502
|
|
|
1503
|
+
/**
|
|
1504
|
+
* Creates a networked Zustand store that automatically syncs state between host and controllers.
|
|
1505
|
+
*
|
|
1506
|
+
* The store pattern works as follows:
|
|
1507
|
+
* - Host: Stores state locally and broadcasts changes to all controllers
|
|
1508
|
+
* - Controller: Sends action RPCs to host, receives state updates from host
|
|
1509
|
+
*
|
|
1510
|
+
* @example
|
|
1511
|
+
* ```ts
|
|
1512
|
+
* interface GameState {
|
|
1513
|
+
* phase: "lobby" | "playing" | "gameover";
|
|
1514
|
+
* scores: { team1: number; team2: number };
|
|
1515
|
+
* actions: {
|
|
1516
|
+
* setPhase: (phase: "lobby" | "playing") => void;
|
|
1517
|
+
* scorePoint: (team: "team1" | "team2") => void;
|
|
1518
|
+
* };
|
|
1519
|
+
* }
|
|
1520
|
+
*
|
|
1521
|
+
* export const useGameStore = createAirJamStore<GameState>((set) => ({
|
|
1522
|
+
* phase: "lobby",
|
|
1523
|
+
* scores: { team1: 0, team2: 0 },
|
|
1524
|
+
* actions: {
|
|
1525
|
+
* setPhase: (phase) => set({ phase }),
|
|
1526
|
+
* scorePoint: (team) => set((state) => ({
|
|
1527
|
+
* scores: { ...state.scores, [team]: state.scores[team] + 1 }
|
|
1528
|
+
* })),
|
|
1529
|
+
* },
|
|
1530
|
+
* }));
|
|
1531
|
+
* ```
|
|
1532
|
+
*/
|
|
1533
|
+
declare function createAirJamStore<T extends {
|
|
1534
|
+
actions: Record<string, (...args: any[]) => any>;
|
|
1535
|
+
}>(initializer: StateCreator<T>): <U>(selector?: (state: T) => U) => U;
|
|
1536
|
+
|
|
1473
1537
|
declare const generateRoomCode: () => string;
|
|
1474
1538
|
declare const generateControllerId: () => string;
|
|
1475
1539
|
|
|
@@ -1526,4 +1590,4 @@ declare class UrlBuilder {
|
|
|
1526
1590
|
}
|
|
1527
1591
|
declare const urlBuilder: UrlBuilder;
|
|
1528
1592
|
|
|
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 };
|
|
1593
|
+
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, ChildEvents, ClientEvents, ClientToServerEvents, ConnectionRole, ConnectionStatus, ControllerEvents, ControllerInputEvent, ControllerInputPayload, ControllerShell, ControllerStatePayload, DEFAULT_CONTROLLER_PATH, 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 };
|