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.
- package/README.md +148 -101
- package/dist/headless.cjs +317 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.ts +176 -0
- package/dist/headless.esm.js +222 -0
- package/dist/headless.esm.js.map +1 -0
- package/dist/index.cjs +839 -881
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +163 -153
- package/dist/index.esm.js +835 -883
- package/dist/index.esm.js.map +1 -1
- package/dist/web.cjs +1416 -0
- package/dist/web.cjs.map +1 -0
- package/dist/web.d.ts +534 -0
- package/dist/web.esm.js +1306 -0
- package/dist/web.esm.js.map +1 -0
- package/package.json +13 -28
- package/dist/types/__mocks__/confetti-wrapper.d.ts +0 -5
- package/dist/types/__mocks__/react-confetti.d.ts +0 -3
- package/dist/types/__mocks__/react-toastify.d.ts +0 -13
- package/dist/types/core/components/BadgesButton.d.ts +0 -25
- package/dist/types/core/components/BadgesButtonWithModal.d.ts +0 -53
- package/dist/types/core/components/BadgesModal.d.ts +0 -14
- package/dist/types/core/components/ConfettiWrapper.d.ts +0 -6
- package/dist/types/core/errors/AchievementErrors.d.ts +0 -55
- package/dist/types/core/hooks/useWindowSize.d.ts +0 -16
- package/dist/types/core/icons/defaultIcons.d.ts +0 -8
- package/dist/types/core/storage/AsyncStorageAdapter.d.ts +0 -48
- package/dist/types/core/storage/IndexedDBStorage.d.ts +0 -29
- package/dist/types/core/storage/LocalStorage.d.ts +0 -16
- package/dist/types/core/storage/MemoryStorage.d.ts +0 -11
- package/dist/types/core/storage/OfflineQueueStorage.d.ts +0 -42
- package/dist/types/core/storage/RestApiStorage.d.ts +0 -20
- package/dist/types/core/styles/defaultStyles.d.ts +0 -2
- package/dist/types/core/types.d.ts +0 -115
- package/dist/types/core/ui/BuiltInConfetti.d.ts +0 -7
- package/dist/types/core/ui/BuiltInModal.d.ts +0 -7
- package/dist/types/core/ui/BuiltInNotification.d.ts +0 -7
- package/dist/types/core/ui/LegacyWrappers.d.ts +0 -21
- package/dist/types/core/ui/interfaces.d.ts +0 -127
- package/dist/types/core/ui/legacyDetector.d.ts +0 -40
- package/dist/types/core/ui/themes.d.ts +0 -14
- package/dist/types/core/utils/configNormalizer.d.ts +0 -3
- package/dist/types/core/utils/dataExport.d.ts +0 -34
- package/dist/types/core/utils/dataImport.d.ts +0 -50
- package/dist/types/hooks/useAchievementEngine.d.ts +0 -36
- package/dist/types/hooks/useAchievements.d.ts +0 -1
- package/dist/types/hooks/useSimpleAchievements.d.ts +0 -63
- package/dist/types/index.d.ts +0 -36
- package/dist/types/providers/AchievementProvider.d.ts +0 -47
- package/dist/types/setupTests.d.ts +0 -1
- package/dist/types/utils/achievementHelpers.d.ts +0 -135
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
2
|
import * as achievements_engine from 'achievements-engine';
|
|
3
|
-
import {
|
|
3
|
+
import { AchievementWithStatus as AchievementWithStatus$1, ImportOptions, ImportResult, AchievementEngine, AchievementConfigurationType as AchievementConfigurationType$1, AchievementStorage as AchievementStorage$1, AsyncAchievementStorage as AsyncAchievementStorage$1, StorageType, RestApiStorageConfig, EventMapping, AchievementError } from 'achievements-engine';
|
|
4
4
|
export { AchievementBuilder, AchievementEngine, AchievementEngineApi, AchievementError, AchievementUnlockedEvent, AsyncStorageAdapter, AwardDetails, ConfigurationError, EngineConfig, EngineEvent, ErrorEvent, EventMapping, ExportedData, ImportOptions, ImportResult, ImportValidationError, IndexedDBStorage, LocalStorage, MemoryStorage, MetricUpdatedEvent, MetricUpdater, OfflineQueueStorage, RestApiStorage, RestApiStorageConfig, StateChangedEvent, StorageError, StorageQuotaError, StorageType, SyncError, UnsubscribeFn, createConfigHash, exportAchievementData, importAchievementData, isAchievementError, isRecoverableError, isSimpleConfig, normalizeAchievements } from 'achievements-engine';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -14,6 +14,12 @@ interface NotificationProps {
|
|
|
14
14
|
position?: NotificationPosition;
|
|
15
15
|
theme?: string;
|
|
16
16
|
icons?: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Position in the active notification stack.
|
|
19
|
+
* Built-in notifications use this to avoid overlap when multiple
|
|
20
|
+
* achievements unlock from the same update.
|
|
21
|
+
*/
|
|
22
|
+
stackIndex?: number;
|
|
17
23
|
}
|
|
18
24
|
type NotificationComponent = React$1.FC<NotificationProps>;
|
|
19
25
|
/**
|
|
@@ -84,29 +90,24 @@ interface ThemeConfig {
|
|
|
84
90
|
interface UIConfig {
|
|
85
91
|
/**
|
|
86
92
|
* Custom notification component
|
|
87
|
-
* If not provided, uses built-in
|
|
93
|
+
* If not provided, uses the built-in notification component.
|
|
88
94
|
*/
|
|
89
95
|
NotificationComponent?: NotificationComponent;
|
|
90
96
|
/**
|
|
91
|
-
* Custom modal component
|
|
92
|
-
* If not provided, uses built-in
|
|
97
|
+
* Custom modal component used by AchievementsWidget and AchievementsModal.
|
|
98
|
+
* If not provided, uses the built-in AchievementsModal implementation.
|
|
93
99
|
*/
|
|
94
100
|
ModalComponent?: ModalComponent;
|
|
95
101
|
/**
|
|
96
102
|
* Custom confetti component
|
|
97
|
-
* If not provided, uses built-in
|
|
103
|
+
* If not provided, uses the built-in confetti component.
|
|
98
104
|
*/
|
|
99
105
|
ConfettiComponent?: ConfettiComponent;
|
|
100
106
|
/**
|
|
101
|
-
*
|
|
107
|
+
* Built-in theme name.
|
|
102
108
|
* Built-in themes: 'modern' (default), 'minimal', 'gamified'
|
|
103
109
|
*/
|
|
104
110
|
theme?: string;
|
|
105
|
-
/**
|
|
106
|
-
* Direct theme configuration override
|
|
107
|
-
* Takes precedence over theme name
|
|
108
|
-
*/
|
|
109
|
-
customTheme?: ThemeConfig;
|
|
110
111
|
/**
|
|
111
112
|
* Notification positioning
|
|
112
113
|
* @default 'top-center'
|
|
@@ -122,11 +123,6 @@ interface UIConfig {
|
|
|
122
123
|
* @default true
|
|
123
124
|
*/
|
|
124
125
|
enableConfetti?: boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Enable/disable modal
|
|
127
|
-
* @default true
|
|
128
|
-
*/
|
|
129
|
-
enableModal?: boolean;
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
type AchievementMetricValue = number | string | boolean | Date | null | undefined;
|
|
@@ -188,7 +184,7 @@ interface AsyncAchievementStorage {
|
|
|
188
184
|
type AnyAchievementStorage = AchievementStorage | AsyncAchievementStorage;
|
|
189
185
|
declare function isAsyncStorage(storage: AnyAchievementStorage): storage is AsyncAchievementStorage;
|
|
190
186
|
/**
|
|
191
|
-
* @deprecated This type is outdated and will be removed in
|
|
187
|
+
* @deprecated This type is outdated and will be removed in 4.2.
|
|
192
188
|
* Use AchievementContextType from 'react-achievements' instead.
|
|
193
189
|
*
|
|
194
190
|
* This legacy interface does not include the 'engine' property.
|
|
@@ -222,26 +218,22 @@ interface StylesProps {
|
|
|
222
218
|
lockIcon?: React.CSSProperties;
|
|
223
219
|
lockedAchievementItem?: React.CSSProperties;
|
|
224
220
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
221
|
+
levelProgress?: {
|
|
222
|
+
container?: React.CSSProperties;
|
|
223
|
+
header?: React.CSSProperties;
|
|
224
|
+
levelLabel?: React.CSSProperties;
|
|
225
|
+
valueText?: React.CSSProperties;
|
|
226
|
+
progressTrack?: React.CSSProperties;
|
|
227
|
+
progressBar?: React.CSSProperties;
|
|
228
|
+
progressText?: React.CSSProperties;
|
|
231
229
|
};
|
|
232
|
-
storageKey?: string;
|
|
233
|
-
badgesButtonPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
234
|
-
styles?: Partial<StylesProps>;
|
|
235
|
-
icons?: Record<string, string>;
|
|
236
|
-
storage?: AchievementStorage;
|
|
237
|
-
onAchievementUnlocked?: (achievement: AchievementDetails) => void;
|
|
238
230
|
}
|
|
239
231
|
|
|
240
232
|
interface AchievementContextType {
|
|
241
233
|
update: (metrics: Record<string, any>) => void;
|
|
242
234
|
achievements: {
|
|
243
235
|
unlocked: string[];
|
|
244
|
-
all: Record<string,
|
|
236
|
+
all: Record<string, AchievementWithStatus$1>;
|
|
245
237
|
};
|
|
246
238
|
reset: () => void;
|
|
247
239
|
getState: () => {
|
|
@@ -252,6 +244,11 @@ interface AchievementContextType {
|
|
|
252
244
|
importData: (jsonString: string, options?: ImportOptions) => ImportResult;
|
|
253
245
|
getAllAchievements: () => AchievementWithStatus$1[];
|
|
254
246
|
engine: AchievementEngine;
|
|
247
|
+
icons: Record<string, string>;
|
|
248
|
+
/**
|
|
249
|
+
* @deprecated Use provider props or the presence of an injected engine directly.
|
|
250
|
+
* This compatibility flag will be removed in 4.2.
|
|
251
|
+
*/
|
|
255
252
|
_isLegacyPattern: boolean;
|
|
256
253
|
}
|
|
257
254
|
declare const AchievementContext: React$1.Context<AchievementContextType | undefined>;
|
|
@@ -265,20 +262,80 @@ interface AchievementProviderProps {
|
|
|
265
262
|
icons?: Record<string, string>;
|
|
266
263
|
onError?: (error: AchievementError) => void;
|
|
267
264
|
/**
|
|
268
|
-
* UI
|
|
269
|
-
*
|
|
270
|
-
*/
|
|
271
|
-
ui?: UIConfig;
|
|
272
|
-
/**
|
|
273
|
-
* Force use of built-in UI components (opt-in for v3.x)
|
|
274
|
-
* Set to true to skip legacy library detection and use built-in UI
|
|
275
|
-
* In v4.0.0, this will become the default behavior
|
|
276
|
-
* NEW in v3.6.0
|
|
277
|
-
* @default false
|
|
265
|
+
* @deprecated Built-in UI is the default in the web provider. This prop is a
|
|
266
|
+
* no-op and will be removed in 4.2.
|
|
278
267
|
*/
|
|
279
268
|
useBuiltInUI?: boolean;
|
|
280
269
|
}
|
|
281
|
-
declare const AchievementProvider: React$1.FC<AchievementProviderProps>;
|
|
270
|
+
declare const AchievementProvider$1: React$1.FC<AchievementProviderProps>;
|
|
271
|
+
|
|
272
|
+
interface AchievementsListRenderItemProps {
|
|
273
|
+
achievement: AchievementWithStatus;
|
|
274
|
+
isLocked: boolean;
|
|
275
|
+
icon: string;
|
|
276
|
+
index: number;
|
|
277
|
+
}
|
|
278
|
+
interface AchievementsListProps {
|
|
279
|
+
achievements?: AchievementWithStatus[];
|
|
280
|
+
showLocked?: boolean;
|
|
281
|
+
showUnlockConditions?: boolean;
|
|
282
|
+
icons?: Record<string, string>;
|
|
283
|
+
styles?: StylesProps['badgesModal'];
|
|
284
|
+
emptyState?: React$1.ReactNode;
|
|
285
|
+
className?: string;
|
|
286
|
+
renderAchievement?: (props: AchievementsListRenderItemProps) => React$1.ReactNode;
|
|
287
|
+
}
|
|
288
|
+
declare const AchievementsList: React$1.FC<AchievementsListProps>;
|
|
289
|
+
|
|
290
|
+
type AchievementsWidgetPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
291
|
+
type AchievementsWidgetPlacement = 'fixed' | 'inline';
|
|
292
|
+
interface AchievementsWidgetTriggerButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
293
|
+
'data-placement': AchievementsWidgetPlacement;
|
|
294
|
+
'data-testid': string;
|
|
295
|
+
}
|
|
296
|
+
interface AchievementsWidgetTriggerProps {
|
|
297
|
+
open: () => void;
|
|
298
|
+
label: string;
|
|
299
|
+
unlockedCount: number;
|
|
300
|
+
totalCount: number;
|
|
301
|
+
unlockedAchievements: AchievementWithStatus[];
|
|
302
|
+
allAchievements: AchievementWithStatus[];
|
|
303
|
+
buttonProps: AchievementsWidgetTriggerButtonProps;
|
|
304
|
+
}
|
|
305
|
+
interface AchievementsWidgetProps {
|
|
306
|
+
position?: AchievementsWidgetPosition;
|
|
307
|
+
placement?: AchievementsWidgetPlacement;
|
|
308
|
+
showAllAchievements?: boolean;
|
|
309
|
+
showUnlockConditions?: boolean;
|
|
310
|
+
showCount?: boolean;
|
|
311
|
+
icons?: Record<string, string>;
|
|
312
|
+
theme?: string;
|
|
313
|
+
label?: string;
|
|
314
|
+
icon?: React$1.ReactNode;
|
|
315
|
+
triggerClassName?: string;
|
|
316
|
+
renderTrigger?: (props: AchievementsWidgetTriggerProps) => React$1.ReactNode;
|
|
317
|
+
buttonStyles?: React$1.CSSProperties;
|
|
318
|
+
modalStyles?: StylesProps['badgesModal'];
|
|
319
|
+
modalTitle?: React$1.ReactNode;
|
|
320
|
+
emptyState?: React$1.ReactNode;
|
|
321
|
+
renderAchievement?: AchievementsListProps['renderAchievement'];
|
|
322
|
+
}
|
|
323
|
+
declare const AchievementsWidget: React$1.FC<AchievementsWidgetProps>;
|
|
324
|
+
|
|
325
|
+
interface AchievementsModalProps {
|
|
326
|
+
isOpen: boolean;
|
|
327
|
+
onClose: () => void;
|
|
328
|
+
achievements?: AchievementWithStatus[];
|
|
329
|
+
title?: React$1.ReactNode;
|
|
330
|
+
styles?: StylesProps['badgesModal'];
|
|
331
|
+
icons?: Record<string, string>;
|
|
332
|
+
showLocked?: boolean;
|
|
333
|
+
showUnlockConditions?: boolean;
|
|
334
|
+
emptyState?: React$1.ReactNode;
|
|
335
|
+
renderAchievement?: AchievementsListProps['renderAchievement'];
|
|
336
|
+
theme?: string;
|
|
337
|
+
}
|
|
338
|
+
declare const AchievementsModal: React$1.FC<AchievementsModalProps>;
|
|
282
339
|
|
|
283
340
|
interface BadgesButtonProps {
|
|
284
341
|
onClick: () => void;
|
|
@@ -302,6 +359,10 @@ interface BadgesButtonProps {
|
|
|
302
359
|
*/
|
|
303
360
|
theme?: string;
|
|
304
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* @deprecated Use `AchievementsWidget` for new integrations. This v3
|
|
364
|
+
* compatibility wrapper will be removed in 4.2.
|
|
365
|
+
*/
|
|
305
366
|
declare const BadgesButton: React$1.FC<BadgesButtonProps>;
|
|
306
367
|
|
|
307
368
|
interface BadgesModalProps {
|
|
@@ -314,6 +375,11 @@ interface BadgesModalProps {
|
|
|
314
375
|
showUnlockConditions?: boolean;
|
|
315
376
|
allAchievements?: AchievementWithStatus[];
|
|
316
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* @deprecated Use `AchievementsModal`, `AchievementsWidget`, or
|
|
380
|
+
* `AchievementsList` for new integrations. This v3 compatibility wrapper will
|
|
381
|
+
* be removed in 4.2.
|
|
382
|
+
*/
|
|
317
383
|
declare const BadgesModal: React$1.FC<BadgesModalProps>;
|
|
318
384
|
|
|
319
385
|
interface BadgesButtonWithModalProps {
|
|
@@ -329,149 +395,93 @@ interface BadgesButtonWithModalProps {
|
|
|
329
395
|
modalStyles?: StylesProps['badgesModal'];
|
|
330
396
|
}
|
|
331
397
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* This component manages the modal state internally, providing a simplified API
|
|
335
|
-
* for the common use case of displaying achievements.
|
|
336
|
-
*
|
|
337
|
-
* For advanced use cases requiring custom state management or multiple triggers,
|
|
338
|
-
* use BadgesButton and BadgesModal separately.
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* ```tsx
|
|
342
|
-
* // Simple usage
|
|
343
|
-
* <BadgesButtonWithModal
|
|
344
|
-
* unlockedAchievements={achievements.unlocked}
|
|
345
|
-
* />
|
|
346
|
-
*
|
|
347
|
-
* // Show all achievements (locked + unlocked)
|
|
348
|
-
* <BadgesButtonWithModal
|
|
349
|
-
* unlockedAchievements={achievements.unlocked}
|
|
350
|
-
* showAllAchievements={true}
|
|
351
|
-
* allAchievements={getAllAchievements()}
|
|
352
|
-
* showUnlockConditions={true}
|
|
353
|
-
* />
|
|
354
|
-
*
|
|
355
|
-
* // Customize position and theme
|
|
356
|
-
* <BadgesButtonWithModal
|
|
357
|
-
* unlockedAchievements={achievements.unlocked}
|
|
358
|
-
* position="top-right"
|
|
359
|
-
* theme="gamified"
|
|
360
|
-
* />
|
|
361
|
-
*
|
|
362
|
-
* // Inline mode for navigation
|
|
363
|
-
* <BadgesButtonWithModal
|
|
364
|
-
* unlockedAchievements={achievements.unlocked}
|
|
365
|
-
* placement="inline"
|
|
366
|
-
* />
|
|
367
|
-
* ```
|
|
398
|
+
* @deprecated Use `AchievementsWidget` for new integrations. This v3
|
|
399
|
+
* compatibility wrapper will be removed in 4.2.
|
|
368
400
|
*/
|
|
369
401
|
declare const BadgesButtonWithModal: React$1.FC<BadgesButtonWithModalProps>;
|
|
370
402
|
|
|
371
403
|
interface ConfettiWrapperProps {
|
|
372
404
|
show: boolean;
|
|
373
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* @deprecated Use the provider `ui.ConfettiComponent` option or the built-in
|
|
408
|
+
* confetti default. This v3 compatibility wrapper will be removed in 4.2.
|
|
409
|
+
*/
|
|
374
410
|
declare const ConfettiWrapper: React$1.FC<ConfettiWrapperProps>;
|
|
375
411
|
|
|
412
|
+
interface LevelProgressProps {
|
|
413
|
+
level: number | string;
|
|
414
|
+
currentXP: number;
|
|
415
|
+
nextLevelXP: number;
|
|
416
|
+
label?: string;
|
|
417
|
+
valueLabel?: string;
|
|
418
|
+
showValues?: boolean;
|
|
419
|
+
showPercent?: boolean;
|
|
420
|
+
theme?: string;
|
|
421
|
+
styles?: StylesProps['levelProgress'];
|
|
422
|
+
className?: string;
|
|
423
|
+
}
|
|
424
|
+
declare const LevelProgress: React$1.FC<LevelProgressProps>;
|
|
425
|
+
|
|
426
|
+
interface WebAchievementProviderProps extends AchievementProviderProps {
|
|
427
|
+
icons?: Record<string, string>;
|
|
428
|
+
ui?: UIConfig;
|
|
429
|
+
/**
|
|
430
|
+
* @deprecated Built-in UI is the default in v4. This prop is a no-op and will
|
|
431
|
+
* be removed in 4.2.
|
|
432
|
+
*/
|
|
433
|
+
useBuiltInUI?: boolean;
|
|
434
|
+
}
|
|
435
|
+
declare const AchievementProvider: React$1.FC<WebAchievementProviderProps>;
|
|
436
|
+
|
|
376
437
|
declare const useAchievements: () => AchievementContextType;
|
|
377
438
|
|
|
378
439
|
/**
|
|
379
440
|
* A simplified hook for achievement tracking.
|
|
380
|
-
* Provides
|
|
441
|
+
* Provides the v4 happy path for direct metric updates plus explicit state names.
|
|
381
442
|
*/
|
|
382
443
|
declare const useSimpleAchievements: () => {
|
|
383
|
-
/**
|
|
384
|
-
* Track a metric value for achievements
|
|
385
|
-
* @param metric - The metric name (e.g., 'score', 'level')
|
|
386
|
-
* @param value - The metric value
|
|
387
|
-
*/
|
|
388
444
|
track: (metric: string, value: any) => void;
|
|
389
|
-
/**
|
|
390
|
-
* Increment a numeric metric by a specified amount
|
|
391
|
-
* @param metric - The metric name (e.g., 'buttonClicks', 'score')
|
|
392
|
-
* @param amount - The amount to increment by (defaults to 1)
|
|
393
|
-
*/
|
|
394
445
|
increment: (metric: string, amount?: number) => void;
|
|
395
|
-
/**
|
|
396
|
-
* Track multiple metrics at once
|
|
397
|
-
* @param metrics - Object with metric names as keys and values
|
|
398
|
-
*/
|
|
399
446
|
trackMultiple: (metrics: Record<string, any>) => void;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
unlocked: string[];
|
|
404
|
-
/**
|
|
405
|
-
* All available achievements
|
|
406
|
-
*/
|
|
407
|
-
all: Record<string, any>;
|
|
408
|
-
/**
|
|
409
|
-
* Number of unlocked achievements
|
|
410
|
-
*/
|
|
447
|
+
unlockedIds: string[];
|
|
448
|
+
unlockedAchievements: achievements_engine.AchievementWithStatus[];
|
|
449
|
+
allAchievements: achievements_engine.AchievementWithStatus[];
|
|
411
450
|
unlockedCount: number;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
*/
|
|
451
|
+
totalCount: number;
|
|
452
|
+
metrics: Record<string, any>;
|
|
415
453
|
reset: () => void;
|
|
416
|
-
/**
|
|
417
|
-
* Get current state (advanced usage)
|
|
418
|
-
*/
|
|
419
454
|
getState: () => {
|
|
420
455
|
metrics: Record<string, any>;
|
|
421
456
|
unlocked: string[];
|
|
422
457
|
};
|
|
423
|
-
/**
|
|
424
|
-
* Export achievement data to JSON string
|
|
425
|
-
* @returns JSON string containing all achievement data
|
|
426
|
-
*/
|
|
427
458
|
exportData: () => string;
|
|
459
|
+
importData: (jsonString: string, options?: achievements_engine.ImportOptions) => achievements_engine.ImportResult;
|
|
460
|
+
getAllAchievements: () => achievements_engine.AchievementWithStatus[];
|
|
428
461
|
/**
|
|
429
|
-
*
|
|
430
|
-
* @param jsonString - JSON string containing exported achievement data
|
|
431
|
-
* @param options - Import options (merge strategy, validation)
|
|
432
|
-
* @returns Import result with success status and any errors
|
|
462
|
+
* @deprecated Use `unlockedIds` instead. This alias will be removed in 4.2.
|
|
433
463
|
*/
|
|
434
|
-
|
|
464
|
+
unlocked: string[];
|
|
435
465
|
/**
|
|
436
|
-
*
|
|
437
|
-
* @returns Array of achievements with isUnlocked boolean property
|
|
466
|
+
* @deprecated Use `allAchievements` instead. This alias will be removed in 4.2.
|
|
438
467
|
*/
|
|
439
|
-
|
|
468
|
+
all: achievements_engine.AchievementWithStatus[];
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
declare const useAchievementState: () => {
|
|
472
|
+
unlockedIds: string[];
|
|
473
|
+
unlockedAchievements: achievements_engine.AchievementWithStatus[];
|
|
474
|
+
allAchievements: achievements_engine.AchievementWithStatus[];
|
|
475
|
+
unlockedCount: number;
|
|
476
|
+
totalCount: number;
|
|
477
|
+
metrics: Record<string, any>;
|
|
440
478
|
};
|
|
441
479
|
|
|
442
480
|
/**
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
* IMPORTANT: This hook only works when Provider has an externally created engine injected via the `engine` prop.
|
|
446
|
-
* Do NOT use this hook with the old `achievements` prop pattern - use `useAchievements()` instead.
|
|
447
|
-
*
|
|
448
|
-
* @example
|
|
449
|
-
* ```tsx
|
|
450
|
-
* // Create engine outside React
|
|
451
|
-
* import { AchievementEngine } from 'achievements-engine';
|
|
452
|
-
*
|
|
453
|
-
* const myEngine = new AchievementEngine({
|
|
454
|
-
* achievements: config,
|
|
455
|
-
* eventMapping: { 'userScored': 'score', 'levelUp': 'level' },
|
|
456
|
-
* storage: 'local'
|
|
457
|
-
* });
|
|
458
|
-
*
|
|
459
|
-
* // Inject into Provider
|
|
460
|
-
* <AchievementProvider engine={myEngine}>
|
|
461
|
-
* <App />
|
|
462
|
-
* </AchievementProvider>
|
|
463
|
-
*
|
|
464
|
-
* function App() {
|
|
465
|
-
* const engine = useAchievementEngine();
|
|
466
|
-
* engine.emit('userScored', 100);
|
|
467
|
-
* engine.emit('levelUp', 5);
|
|
468
|
-
* }
|
|
469
|
-
* ```
|
|
481
|
+
* Access the active AchievementEngine instance.
|
|
470
482
|
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @throws Error if used outside AchievementProvider
|
|
474
|
-
* @since 3.8.0
|
|
483
|
+
* In v4 this works with both provider-created engines (`achievements` prop) and
|
|
484
|
+
* injected engines (`engine` prop).
|
|
475
485
|
*/
|
|
476
486
|
declare const useAchievementEngine: () => AchievementEngine;
|
|
477
487
|
|
|
@@ -521,4 +531,4 @@ declare function useWindowSize(): {
|
|
|
521
531
|
height: number;
|
|
522
532
|
};
|
|
523
533
|
|
|
524
|
-
export { AchievementCondition, AchievementConfiguration, AchievementConfigurationType, AchievementContext, AchievementContextType, AchievementContextValue, AchievementDetails, AchievementMetricArrayValue, AchievementMetricValue, AchievementMetrics, AchievementProvider,
|
|
534
|
+
export { AchievementCondition, AchievementConfiguration, AchievementConfigurationType, AchievementContext, AchievementContextType, AchievementContextValue, AchievementDetails, AchievementMetricArrayValue, AchievementMetricValue, AchievementMetrics, AchievementProvider, WebAchievementProviderProps as AchievementProviderProps, AchievementState, AchievementStorage, AchievementWithStatus, AchievementsList, AchievementsListProps, AchievementsListRenderItemProps, AchievementsModal, AchievementsModalProps, AchievementsWidget, AchievementsWidgetPlacement, AchievementsWidgetPosition, AchievementsWidgetProps, AchievementsWidgetTriggerButtonProps, AchievementsWidgetTriggerProps, AnyAchievementStorage, AsyncAchievementStorage, BadgesButton, BadgesButtonWithModal, BadgesModal, BuiltInConfetti, BuiltInModal, BuiltInNotification, ConfettiComponent, ConfettiProps, ConfettiWrapper, CustomAchievementDetails, AchievementProvider$1 as HeadlessAchievementProvider, InitialAchievementMetrics, LevelProgress, ModalComponent, ModalProps, NotificationComponent, NotificationPosition, NotificationProps, SimpleAchievementConfig, SimpleAchievementDetails, StylesProps, ThemeConfig, UIConfig, defaultAchievementIcons, defaultStyles, isAsyncStorage, useAchievementEngine, useAchievementState, useAchievements, useSimpleAchievements, useWindowSize };
|