react-achievements 3.9.3 → 4.0.0

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 (52) hide show
  1. package/README.md +148 -101
  2. package/dist/headless.cjs +317 -0
  3. package/dist/headless.cjs.map +1 -0
  4. package/dist/headless.d.ts +176 -0
  5. package/dist/headless.esm.js +222 -0
  6. package/dist/headless.esm.js.map +1 -0
  7. package/dist/index.cjs +839 -881
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +163 -153
  10. package/dist/index.esm.js +835 -883
  11. package/dist/index.esm.js.map +1 -1
  12. package/dist/web.cjs +1416 -0
  13. package/dist/web.cjs.map +1 -0
  14. package/dist/web.d.ts +534 -0
  15. package/dist/web.esm.js +1306 -0
  16. package/dist/web.esm.js.map +1 -0
  17. package/package.json +13 -28
  18. package/dist/types/__mocks__/confetti-wrapper.d.ts +0 -5
  19. package/dist/types/__mocks__/react-confetti.d.ts +0 -3
  20. package/dist/types/__mocks__/react-toastify.d.ts +0 -13
  21. package/dist/types/core/components/BadgesButton.d.ts +0 -25
  22. package/dist/types/core/components/BadgesButtonWithModal.d.ts +0 -53
  23. package/dist/types/core/components/BadgesModal.d.ts +0 -14
  24. package/dist/types/core/components/ConfettiWrapper.d.ts +0 -6
  25. package/dist/types/core/errors/AchievementErrors.d.ts +0 -55
  26. package/dist/types/core/hooks/useWindowSize.d.ts +0 -16
  27. package/dist/types/core/icons/defaultIcons.d.ts +0 -8
  28. package/dist/types/core/storage/AsyncStorageAdapter.d.ts +0 -48
  29. package/dist/types/core/storage/IndexedDBStorage.d.ts +0 -29
  30. package/dist/types/core/storage/LocalStorage.d.ts +0 -16
  31. package/dist/types/core/storage/MemoryStorage.d.ts +0 -11
  32. package/dist/types/core/storage/OfflineQueueStorage.d.ts +0 -42
  33. package/dist/types/core/storage/RestApiStorage.d.ts +0 -20
  34. package/dist/types/core/styles/defaultStyles.d.ts +0 -2
  35. package/dist/types/core/types.d.ts +0 -115
  36. package/dist/types/core/ui/BuiltInConfetti.d.ts +0 -7
  37. package/dist/types/core/ui/BuiltInModal.d.ts +0 -7
  38. package/dist/types/core/ui/BuiltInNotification.d.ts +0 -7
  39. package/dist/types/core/ui/LegacyWrappers.d.ts +0 -21
  40. package/dist/types/core/ui/interfaces.d.ts +0 -127
  41. package/dist/types/core/ui/legacyDetector.d.ts +0 -40
  42. package/dist/types/core/ui/themes.d.ts +0 -14
  43. package/dist/types/core/utils/configNormalizer.d.ts +0 -3
  44. package/dist/types/core/utils/dataExport.d.ts +0 -34
  45. package/dist/types/core/utils/dataImport.d.ts +0 -50
  46. package/dist/types/hooks/useAchievementEngine.d.ts +0 -36
  47. package/dist/types/hooks/useAchievements.d.ts +0 -1
  48. package/dist/types/hooks/useSimpleAchievements.d.ts +0 -63
  49. package/dist/types/index.d.ts +0 -36
  50. package/dist/types/providers/AchievementProvider.d.ts +0 -47
  51. package/dist/types/setupTests.d.ts +0 -1
  52. package/dist/types/utils/achievementHelpers.d.ts +0 -135
@@ -1,115 +0,0 @@
1
- export type AchievementMetricValue = number | string | boolean | Date | null | undefined;
2
- export type AchievementMetricArrayValue = AchievementMetricValue | AchievementMetricValue[];
3
- export declare const isDate: (value: any) => value is Date;
4
- export interface AchievementMetrics {
5
- [key: string]: AchievementMetricValue[];
6
- }
7
- export interface AchievementDetails {
8
- achievementId: string;
9
- achievementTitle: string;
10
- achievementDescription: string;
11
- achievementIconKey?: string;
12
- }
13
- export interface AchievementWithStatus extends AchievementDetails {
14
- isUnlocked: boolean;
15
- }
16
- export interface AchievementCondition {
17
- isConditionMet: (value: AchievementMetricArrayValue, state: AchievementState) => boolean;
18
- achievementDetails: AchievementDetails | AchievementWithStatus;
19
- }
20
- export interface AchievementConfiguration {
21
- [key: string]: AchievementCondition[];
22
- }
23
- export interface SimpleAchievementDetails {
24
- title: string;
25
- description?: string;
26
- icon?: string;
27
- }
28
- export interface CustomAchievementDetails extends SimpleAchievementDetails {
29
- condition: (metrics: Record<string, any>) => boolean;
30
- }
31
- export interface SimpleAchievementConfig {
32
- [metric: string]: {
33
- [threshold: string]: SimpleAchievementDetails | CustomAchievementDetails;
34
- };
35
- }
36
- export type AchievementConfigurationType = AchievementConfiguration | SimpleAchievementConfig;
37
- export interface InitialAchievementMetrics {
38
- [key: string]: AchievementMetricValue;
39
- }
40
- export interface AchievementState {
41
- metrics: AchievementMetrics;
42
- unlockedAchievements: string[];
43
- }
44
- export interface AchievementStorage {
45
- getMetrics(): AchievementMetrics;
46
- setMetrics(metrics: AchievementMetrics): void;
47
- getUnlockedAchievements(): string[];
48
- setUnlockedAchievements(achievements: string[]): void;
49
- clear(): void;
50
- }
51
- export interface AsyncAchievementStorage {
52
- getMetrics(): Promise<AchievementMetrics>;
53
- setMetrics(metrics: AchievementMetrics): Promise<void>;
54
- getUnlockedAchievements(): Promise<string[]>;
55
- setUnlockedAchievements(achievements: string[]): Promise<void>;
56
- clear(): Promise<void>;
57
- }
58
- export type AnyAchievementStorage = AchievementStorage | AsyncAchievementStorage;
59
- export declare function isAsyncStorage(storage: AnyAchievementStorage): storage is AsyncAchievementStorage;
60
- /**
61
- * @deprecated This type is outdated and will be removed in v4.0.0.
62
- * Use AchievementContextType from 'react-achievements' instead.
63
- *
64
- * This legacy interface does not include the 'engine' property.
65
- *
66
- * @example
67
- * ```typescript
68
- * // Old (deprecated)
69
- * import { AchievementContextValue } from 'react-achievements';
70
- *
71
- * // New (recommended)
72
- * import { AchievementContextType } from 'react-achievements';
73
- * ```
74
- */
75
- export interface AchievementContextValue {
76
- updateMetrics: (metrics: AchievementMetrics | ((prev: AchievementMetrics) => AchievementMetrics)) => void;
77
- unlockedAchievements: string[];
78
- resetStorage: () => void;
79
- }
80
- export interface StylesProps {
81
- badgesButton?: React.CSSProperties;
82
- badgesModal?: {
83
- overlay?: React.CSSProperties;
84
- content?: React.CSSProperties;
85
- header?: React.CSSProperties;
86
- closeButton?: React.CSSProperties;
87
- achievementList?: React.CSSProperties;
88
- achievementItem?: React.CSSProperties;
89
- achievementTitle?: React.CSSProperties;
90
- achievementDescription?: React.CSSProperties;
91
- achievementIcon?: React.CSSProperties;
92
- lockIcon?: React.CSSProperties;
93
- lockedAchievementItem?: React.CSSProperties;
94
- };
95
- }
96
- export interface AchievementProviderProps {
97
- children: React.ReactNode;
98
- config: AchievementConfiguration;
99
- initialState?: InitialAchievementMetrics & {
100
- previouslyAwardedAchievements?: string[];
101
- };
102
- storageKey?: string;
103
- badgesButtonPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
104
- styles?: Partial<StylesProps>;
105
- icons?: Record<string, string>;
106
- storage?: AchievementStorage;
107
- onAchievementUnlocked?: (achievement: AchievementDetails) => void;
108
- }
109
- export declare enum StorageType {
110
- Local = "local",// Synchronous localStorage
111
- Memory = "memory",// Synchronous in-memory storage
112
- IndexedDB = "indexeddb",// Asynchronous IndexedDB storage
113
- RestAPI = "restapi"
114
- }
115
- export type { NotificationProps, NotificationComponent, ModalProps, ModalComponent, ConfettiProps, ConfettiComponent, NotificationPosition, ThemeConfig, UIConfig, } from './ui/interfaces';
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { ConfettiProps } from './interfaces';
3
- /**
4
- * Built-in confetti component
5
- * Lightweight CSS-based confetti animation
6
- */
7
- export declare const BuiltInConfetti: React.FC<ConfettiProps>;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { ModalProps } from './interfaces';
3
- /**
4
- * Built-in modal component
5
- * Modern, theme-aware achievement modal with smooth animations
6
- */
7
- export declare const BuiltInModal: React.FC<ModalProps>;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { NotificationProps } from './interfaces';
3
- /**
4
- * Built-in notification component
5
- * Modern, theme-aware achievement notification with smooth animations
6
- */
7
- export declare const BuiltInNotification: React.FC<NotificationProps>;
@@ -1,21 +0,0 @@
1
- /**
2
- * Legacy library wrappers for backwards compatibility
3
- * Wraps external UI libraries to match our component interfaces
4
- */
5
- import type { NotificationComponent, ModalComponent, ConfettiComponent } from './interfaces';
6
- import { LegacyLibraries } from './legacyDetector';
7
- /**
8
- * Wrapper for react-toastify toast notifications
9
- * Falls back to built-in notification if not available
10
- */
11
- export declare const createLegacyToastNotification: (libraries: LegacyLibraries) => NotificationComponent;
12
- /**
13
- * Wrapper for react-modal Modal component
14
- * Falls back to built-in modal if not available
15
- */
16
- export declare const createLegacyModalWrapper: (libraries: LegacyLibraries) => ModalComponent;
17
- /**
18
- * Wrapper for react-confetti Confetti component
19
- * Falls back to built-in confetti if not available
20
- */
21
- export declare const createLegacyConfettiWrapper: (libraries: LegacyLibraries) => ConfettiComponent;
@@ -1,127 +0,0 @@
1
- import React from 'react';
2
- import { AchievementWithStatus } from '../types';
3
- /**
4
- * Notification component interface
5
- * Displays achievement unlock notifications
6
- */
7
- export interface NotificationProps {
8
- achievement: AchievementWithStatus;
9
- onClose?: () => void;
10
- duration?: number;
11
- position?: NotificationPosition;
12
- theme?: string;
13
- icons?: Record<string, string>;
14
- }
15
- export type NotificationComponent = React.FC<NotificationProps>;
16
- /**
17
- * Modal component interface
18
- * Displays list of achievements (locked/unlocked)
19
- */
20
- export interface ModalProps {
21
- isOpen: boolean;
22
- onClose: () => void;
23
- achievements: AchievementWithStatus[];
24
- icons?: Record<string, string>;
25
- theme?: string;
26
- }
27
- export type ModalComponent = React.FC<ModalProps>;
28
- /**
29
- * Confetti component interface
30
- * Displays celebration animation
31
- */
32
- export interface ConfettiProps {
33
- show: boolean;
34
- duration?: number;
35
- particleCount?: number;
36
- colors?: string[];
37
- }
38
- export type ConfettiComponent = React.FC<ConfettiProps>;
39
- /**
40
- * Notification positioning options
41
- */
42
- export type NotificationPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
43
- /**
44
- * Theme configuration interface
45
- * Defines styling for all UI components
46
- */
47
- export interface ThemeConfig {
48
- name: string;
49
- notification: {
50
- background: string;
51
- textColor: string;
52
- accentColor: string;
53
- borderRadius: string;
54
- boxShadow: string;
55
- fontSize?: {
56
- header?: string;
57
- title?: string;
58
- description?: string;
59
- };
60
- };
61
- modal: {
62
- overlayColor: string;
63
- background: string;
64
- textColor: string;
65
- accentColor: string;
66
- borderRadius: string;
67
- headerFontSize?: string;
68
- achievementCardBorderRadius?: string;
69
- achievementLayout?: 'horizontal' | 'badge';
70
- };
71
- confetti: {
72
- colors: string[];
73
- particleCount: number;
74
- shapes?: ('circle' | 'square')[];
75
- };
76
- }
77
- /**
78
- * UI Configuration for AchievementProvider
79
- * Allows customization of all UI components
80
- */
81
- export interface UIConfig {
82
- /**
83
- * Custom notification component
84
- * If not provided, uses built-in or legacy component based on detection
85
- */
86
- NotificationComponent?: NotificationComponent;
87
- /**
88
- * Custom modal component
89
- * If not provided, uses built-in or legacy component based on detection
90
- */
91
- ModalComponent?: ModalComponent;
92
- /**
93
- * Custom confetti component
94
- * If not provided, uses built-in or legacy component based on detection
95
- */
96
- ConfettiComponent?: ConfettiComponent;
97
- /**
98
- * Theme to use (built-in name or registered custom theme name)
99
- * Built-in themes: 'modern' (default), 'minimal', 'gamified'
100
- */
101
- theme?: string;
102
- /**
103
- * Direct theme configuration override
104
- * Takes precedence over theme name
105
- */
106
- customTheme?: ThemeConfig;
107
- /**
108
- * Notification positioning
109
- * @default 'top-center'
110
- */
111
- notificationPosition?: NotificationPosition;
112
- /**
113
- * Enable/disable notifications
114
- * @default true
115
- */
116
- enableNotifications?: boolean;
117
- /**
118
- * Enable/disable confetti animations
119
- * @default true
120
- */
121
- enableConfetti?: boolean;
122
- /**
123
- * Enable/disable modal
124
- * @default true
125
- */
126
- enableModal?: boolean;
127
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * Legacy UI library detection system
3
- * Attempts to dynamically import external UI libraries
4
- * Shows deprecation warnings when detected
5
- */
6
- export interface LegacyLibraries {
7
- toast?: any;
8
- ToastContainer?: any;
9
- Modal?: any;
10
- Confetti?: any;
11
- useWindowSize?: any;
12
- }
13
- /**
14
- * Attempts to dynamically import legacy UI libraries
15
- * Uses try/catch to gracefully handle missing dependencies
16
- * Caches result to avoid multiple import attempts
17
- *
18
- * @returns Promise resolving to LegacyLibraries object
19
- */
20
- export declare function detectLegacyLibraries(): Promise<LegacyLibraries>;
21
- /**
22
- * Synchronous check if libraries are already loaded
23
- * Does not trigger detection if not already attempted
24
- *
25
- * @returns Boolean indicating if legacy libraries were detected
26
- */
27
- export declare function hasLegacyLibraries(): boolean;
28
- /**
29
- * Get cached legacy libraries without re-detection
30
- * Returns null if detection hasn't been attempted yet
31
- *
32
- * @returns Cached LegacyLibraries or null
33
- */
34
- export declare function getCachedLegacyLibraries(): LegacyLibraries | null;
35
- /**
36
- * Reset detection state (useful for testing)
37
- *
38
- * @internal
39
- */
40
- export declare function resetDetection(): void;
@@ -1,14 +0,0 @@
1
- import { ThemeConfig } from './interfaces';
2
- /**
3
- * Built-in theme presets
4
- */
5
- export declare const builtInThemes: Record<string, ThemeConfig>;
6
- /**
7
- * Retrieve a theme by name (internal use only)
8
- * Only checks built-in themes
9
- *
10
- * @param name - Theme name (built-in only)
11
- * @returns Theme configuration or undefined if not found
12
- * @internal
13
- */
14
- export declare function getTheme(name: string): ThemeConfig | undefined;
@@ -1,3 +0,0 @@
1
- import { AchievementConfiguration, SimpleAchievementConfig, AchievementConfigurationType } from '../types';
2
- export declare function isSimpleConfig(config: AchievementConfigurationType): config is SimpleAchievementConfig;
3
- export declare function normalizeAchievements(config: AchievementConfigurationType): AchievementConfiguration;
@@ -1,34 +0,0 @@
1
- import { AchievementMetrics } from '../types';
2
- /**
3
- * Structure of exported achievement data
4
- */
5
- export interface ExportedData {
6
- version: string;
7
- timestamp: number;
8
- metrics: AchievementMetrics;
9
- unlockedAchievements: string[];
10
- configHash?: string;
11
- }
12
- /**
13
- * Exports achievement data to a JSON string
14
- *
15
- * @param metrics - Current achievement metrics
16
- * @param unlocked - Array of unlocked achievement IDs
17
- * @param configHash - Optional hash of achievement configuration for validation
18
- * @returns JSON string containing all achievement data
19
- *
20
- * @example
21
- * ```typescript
22
- * const json = exportAchievementData(_metrics, ['score_100', 'level_5']);
23
- * // Save json to file or send to server
24
- * ```
25
- */
26
- export declare function exportAchievementData(metrics: AchievementMetrics, unlocked: string[], configHash?: string): string;
27
- /**
28
- * Creates a simple hash of the achievement configuration
29
- * Used to validate that imported data matches the current configuration
30
- *
31
- * @param config - Achievement configuration object
32
- * @returns Simple hash string
33
- */
34
- export declare function createConfigHash(config: any): string;
@@ -1,50 +0,0 @@
1
- import { AchievementMetrics } from '../types';
2
- /**
3
- * Options for importing achievement data
4
- */
5
- export interface ImportOptions {
6
- /** Strategy for merging imported data with existing data */
7
- mergeStrategy?: 'replace' | 'merge' | 'preserve';
8
- /** Whether to validate the imported data */
9
- validate?: boolean;
10
- /** Optional config hash to validate against */
11
- expectedConfigHash?: string;
12
- }
13
- /**
14
- * Result of an import operation
15
- */
16
- export interface ImportResult {
17
- success: boolean;
18
- imported: {
19
- metrics: number;
20
- achievements: number;
21
- };
22
- errors?: string[];
23
- warnings?: string[];
24
- }
25
- /**
26
- * Imports achievement data from a JSON string
27
- *
28
- * @param jsonString - JSON string containing exported achievement data
29
- * @param currentMetrics - Current metrics state
30
- * @param currentUnlocked - Current unlocked achievements
31
- * @param options - Import options
32
- * @returns Import result with success status and any errors
33
- *
34
- * @example
35
- * ```typescript
36
- * const result = importAchievementData(
37
- * jsonString,
38
- * currentMetrics,
39
- * currentUnlocked,
40
- * { mergeStrategy: 'merge', validate: true }
41
- * );
42
- *
43
- * if (result.success) {
44
- * console.log(`Imported ${result.imported.achievements} achievements`);
45
- * } else {
46
- * console.error('Import failed:', result.errors);
47
- * }
48
- * ```
49
- */
50
- export declare function importAchievementData(jsonString: string, currentMetrics: AchievementMetrics, currentUnlocked: string[], options?: ImportOptions): ImportResult;
@@ -1,36 +0,0 @@
1
- import type { AchievementEngine } from 'achievements-engine';
2
- /**
3
- * Hook to access the injected AchievementEngine instance (NEW event-based pattern)
4
- *
5
- * IMPORTANT: This hook only works when Provider has an externally created engine injected via the `engine` prop.
6
- * Do NOT use this hook with the old `achievements` prop pattern - use `useAchievements()` instead.
7
- *
8
- * @example
9
- * ```tsx
10
- * // Create engine outside React
11
- * import { AchievementEngine } from 'achievements-engine';
12
- *
13
- * const myEngine = new AchievementEngine({
14
- * achievements: config,
15
- * eventMapping: { 'userScored': 'score', 'levelUp': 'level' },
16
- * storage: 'local'
17
- * });
18
- *
19
- * // Inject into Provider
20
- * <AchievementProvider engine={myEngine}>
21
- * <App />
22
- * </AchievementProvider>
23
- *
24
- * function App() {
25
- * const engine = useAchievementEngine();
26
- * engine.emit('userScored', 100);
27
- * engine.emit('levelUp', 5);
28
- * }
29
- * ```
30
- *
31
- * @returns AchievementEngine instance
32
- * @throws Error if used with old achievements prop pattern
33
- * @throws Error if used outside AchievementProvider
34
- * @since 3.8.0
35
- */
36
- export declare const useAchievementEngine: () => AchievementEngine;
@@ -1 +0,0 @@
1
- export declare const useAchievements: () => import("../providers/AchievementProvider").AchievementContextType;
@@ -1,63 +0,0 @@
1
- /**
2
- * A simplified hook for achievement tracking.
3
- * Provides an easier API for common use cases while maintaining access to advanced features.
4
- */
5
- export declare const useSimpleAchievements: () => {
6
- /**
7
- * Track a metric value for achievements
8
- * @param metric - The metric name (e.g., 'score', 'level')
9
- * @param value - The metric value
10
- */
11
- track: (metric: string, value: any) => void;
12
- /**
13
- * Increment a numeric metric by a specified amount
14
- * @param metric - The metric name (e.g., 'buttonClicks', 'score')
15
- * @param amount - The amount to increment by (defaults to 1)
16
- */
17
- increment: (metric: string, amount?: number) => void;
18
- /**
19
- * Track multiple metrics at once
20
- * @param metrics - Object with metric names as keys and values
21
- */
22
- trackMultiple: (metrics: Record<string, any>) => void;
23
- /**
24
- * Array of unlocked achievement IDs
25
- */
26
- unlocked: string[];
27
- /**
28
- * All available achievements
29
- */
30
- all: Record<string, any>;
31
- /**
32
- * Number of unlocked achievements
33
- */
34
- unlockedCount: number;
35
- /**
36
- * Reset all achievement progress
37
- */
38
- reset: () => void;
39
- /**
40
- * Get current state (advanced usage)
41
- */
42
- getState: () => {
43
- metrics: Record<string, any>;
44
- unlocked: string[];
45
- };
46
- /**
47
- * Export achievement data to JSON string
48
- * @returns JSON string containing all achievement data
49
- */
50
- exportData: () => string;
51
- /**
52
- * Import achievement data from JSON string
53
- * @param jsonString - JSON string containing exported achievement data
54
- * @param options - Import options (merge strategy, validation)
55
- * @returns Import result with success status and any errors
56
- */
57
- importData: (jsonString: string, options?: import("achievements-engine").ImportOptions) => import("achievements-engine").ImportResult;
58
- /**
59
- * Get all achievements with their unlock status
60
- * @returns Array of achievements with isUnlocked boolean property
61
- */
62
- getAllAchievements: () => import("achievements-engine").AchievementWithStatus[];
63
- };
@@ -1,36 +0,0 @@
1
- export type { AchievementMetrics, AchievementConfiguration, AchievementConfigurationType, SimpleAchievementConfig, SimpleAchievementDetails, CustomAchievementDetails, AchievementDetails, AchievementWithStatus, AchievementCondition, AchievementMetricValue, AchievementMetricArrayValue, InitialAchievementMetrics, AchievementState, AchievementStorage, AsyncAchievementStorage, AnyAchievementStorage, AchievementContextValue, // @deprecated - use AchievementContextType instead
2
- StylesProps, AchievementProviderProps, } from './core/types';
3
- export type { AchievementContextType, } from './providers/AchievementProvider';
4
- export { isAsyncStorage } from './core/types';
5
- export { LocalStorage, MemoryStorage, IndexedDBStorage, RestApiStorage, AsyncStorageAdapter, OfflineQueueStorage, StorageType } from 'achievements-engine';
6
- export type { RestApiStorageConfig } from 'achievements-engine';
7
- export { BadgesButton } from './core/components/BadgesButton';
8
- export { BadgesModal } from './core/components/BadgesModal';
9
- export { BadgesButtonWithModal } from './core/components/BadgesButtonWithModal';
10
- export { ConfettiWrapper } from './core/components/ConfettiWrapper';
11
- export { AchievementProvider, AchievementContext } from './providers/AchievementProvider';
12
- export { useAchievements } from './hooks/useAchievements';
13
- export { useSimpleAchievements } from './hooks/useSimpleAchievements';
14
- export { useAchievementEngine } from './hooks/useAchievementEngine';
15
- export { defaultStyles } from './core/styles/defaultStyles';
16
- export { defaultAchievementIcons } from './core/icons/defaultIcons';
17
- export { normalizeAchievements, isSimpleConfig, exportAchievementData, createConfigHash, importAchievementData } from 'achievements-engine';
18
- export type { ImportOptions, ImportResult, ExportedData } from 'achievements-engine';
19
- /**
20
- * Achievement Builder Utilities
21
- *
22
- * These utilities are re-exported from achievements-engine for backwards compatibility.
23
- * They provide a convenient builder API for creating achievement configurations.
24
- *
25
- * @see https://github.com/dave-b-b/achievements-engine for full documentation
26
- */
27
- export { AchievementBuilder, type AwardDetails, } from 'achievements-engine';
28
- export { AchievementError, StorageQuotaError, ImportValidationError, StorageError, ConfigurationError, SyncError, isAchievementError, isRecoverableError } from 'achievements-engine';
29
- export { BuiltInNotification } from './core/ui/BuiltInNotification';
30
- export { BuiltInModal } from './core/ui/BuiltInModal';
31
- export { BuiltInConfetti } from './core/ui/BuiltInConfetti';
32
- export type { NotificationComponent, NotificationProps, ModalComponent, ModalProps, ConfettiComponent, ConfettiProps, NotificationPosition, ThemeConfig, UIConfig, } from './core/types';
33
- export { useWindowSize } from './core/hooks/useWindowSize';
34
- export { AchievementEngine } from 'achievements-engine';
35
- export type { AchievementEngineApi } from 'achievements-engine';
36
- export type { EngineConfig, EngineEvent, AchievementUnlockedEvent, MetricUpdatedEvent, StateChangedEvent, ErrorEvent, EventMapping, MetricUpdater, UnsubscribeFn, } from 'achievements-engine';
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
- import { AchievementEngine, AchievementError } from 'achievements-engine';
3
- import type { AchievementConfigurationType, AchievementStorage, AsyncAchievementStorage, StorageType, AchievementWithStatus, EventMapping, ImportOptions, ImportResult, RestApiStorageConfig } from 'achievements-engine';
4
- import { UIConfig } from '../core/types';
5
- export interface AchievementContextType {
6
- update: (metrics: Record<string, any>) => void;
7
- achievements: {
8
- unlocked: string[];
9
- all: Record<string, any>;
10
- };
11
- reset: () => void;
12
- getState: () => {
13
- metrics: Record<string, any>;
14
- unlocked: string[];
15
- };
16
- exportData: () => string;
17
- importData: (jsonString: string, options?: ImportOptions) => ImportResult;
18
- getAllAchievements: () => AchievementWithStatus[];
19
- engine: AchievementEngine;
20
- _isLegacyPattern: boolean;
21
- }
22
- export declare const AchievementContext: React.Context<AchievementContextType | undefined>;
23
- interface AchievementProviderProps {
24
- achievements?: AchievementConfigurationType;
25
- storage?: AchievementStorage | AsyncAchievementStorage | StorageType;
26
- restApiConfig?: RestApiStorageConfig;
27
- eventMapping?: EventMapping;
28
- engine?: AchievementEngine;
29
- children: React.ReactNode;
30
- icons?: Record<string, string>;
31
- onError?: (error: AchievementError) => void;
32
- /**
33
- * UI configuration for notifications, modal, and confetti
34
- * NEW in v3.6.0
35
- */
36
- ui?: UIConfig;
37
- /**
38
- * Force use of built-in UI components (opt-in for v3.x)
39
- * Set to true to skip legacy library detection and use built-in UI
40
- * In v4.0.0, this will become the default behavior
41
- * NEW in v3.6.0
42
- * @default false
43
- */
44
- useBuiltInUI?: boolean;
45
- }
46
- export declare const AchievementProvider: React.FC<AchievementProviderProps>;
47
- export {};
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';