questro
Version:
A lightweight, modular gamification library for React with unique visual components. Features combo meters, daily challenges, achievement toasts, and progress rings. Add points, badges, quests, leaderboards, levels/XP, streaks, and notifications with zero
130 lines (123 loc) • 4.28 kB
text/typescript
import { b as Entity, a as EntityId, E as EventEmitter, S as StorageAdapter } from '../types-B4P_iNGe.mjs';
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode, CSSProperties } from 'react';
interface ComboAction extends Entity {
userId: EntityId;
action: string;
timestamp: number;
}
interface ComboState {
userId: EntityId;
currentCombo: number;
maxCombo: number;
multiplier: number;
lastActionTime: number;
actions: ComboAction[];
isActive: boolean;
}
interface ComboConfig {
userId: EntityId;
timeWindow?: number;
multiplierIncrement?: number;
maxMultiplier?: number;
minComboForMultiplier?: number;
onComboBreak?: (combo: number, multiplier: number) => void;
onComboMilestone?: (combo: number, multiplier: number) => void;
}
type ComboEvents = {
comboIncreased: {
combo: number;
multiplier: number;
};
comboBroken: {
combo: number;
multiplier: number;
};
comboMilestone: {
combo: number;
multiplier: number;
milestone: number;
};
multiplierChanged: {
oldMultiplier: number;
newMultiplier: number;
};
[key: string]: unknown;
};
interface ComboService {
getCurrentCombo(): number;
getMaxCombo(): number;
getMultiplier(): number;
isActive(): boolean;
addAction(action: string): ComboAction;
reset(): void;
checkTimeout(): boolean;
events: EventEmitter<ComboEvents>;
toJSON(): ComboState;
}
declare class ComboServiceImpl implements ComboService {
private state;
private config;
readonly events: EventEmitter<ComboEvents>;
private timeoutId?;
constructor(config: ComboConfig);
getCurrentCombo(): number;
getMaxCombo(): number;
getMultiplier(): number;
isActive(): boolean;
addAction(action: string): ComboAction;
checkTimeout(): boolean;
reset(): void;
private breakCombo;
private setupTimeout;
toJSON(): ComboState;
static fromJSON(config: ComboConfig, state: ComboState): ComboServiceImpl;
}
interface ComboProviderProps {
children: ReactNode;
config: ComboConfig;
storage?: StorageAdapter<ComboState>;
storageKey?: string;
}
declare function ComboProvider({ children, config, storage, storageKey, }: ComboProviderProps): react_jsx_runtime.JSX.Element | null;
declare function useComboContext(): ComboService;
interface UseComboReturn {
combo: number;
maxCombo: number;
multiplier: number;
isActive: boolean;
timeRemaining: number;
addAction: (action: string) => ComboAction;
reset: () => void;
}
declare function useCombo(): UseComboReturn;
interface ComboMeterProps {
combo: number;
multiplier: number;
isActive: boolean;
timeRemaining: number;
maxTime?: number;
showMultiplier?: boolean;
style?: CSSProperties;
className?: string;
}
declare function ComboMeter({ combo, multiplier, isActive, timeRemaining, maxTime, showMultiplier, style, className, }: ComboMeterProps): react_jsx_runtime.JSX.Element;
interface ComboDisplayProps {
combo: number;
maxCombo: number;
multiplier: number;
children?: ReactNode;
style?: CSSProperties;
className?: string;
}
declare function ComboDisplay({ combo, maxCombo, multiplier, children, style, className, }: ComboDisplayProps): react_jsx_runtime.JSX.Element;
interface ComboPopupProps {
combo: number;
multiplier: number;
show: boolean;
style?: CSSProperties;
className?: string;
}
declare function ComboPopup({ combo, multiplier, show, style, className }: ComboPopupProps): react_jsx_runtime.JSX.Element | null;
declare const comboStyles = "\n@keyframes comboPulse {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.2); }\n}\n\n@keyframes comboPopup {\n 0% { \n transform: translate(-50%, -50%) scale(0);\n opacity: 0;\n }\n 50% { \n transform: translate(-50%, -50%) scale(1.1);\n }\n 100% { \n transform: translate(-50%, -50%) scale(1);\n opacity: 1;\n }\n}\n";
export { type ComboAction, type ComboConfig, ComboDisplay, type ComboEvents, ComboMeter, ComboPopup, ComboProvider, type ComboService, ComboServiceImpl, type ComboState, comboStyles, useCombo, useComboContext };