partycles 1.1.5 → 1.2.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.
Files changed (139) hide show
  1. package/README.md +107 -10
  2. package/dist/index.d.mts +149 -0
  3. package/dist/index.d.ts +149 -5
  4. package/dist/index.js +48 -1487
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +55 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +20 -9
  9. package/dist/animations/animations/aurora.d.ts +0 -8
  10. package/dist/animations/animations/aurora.d.ts.map +0 -1
  11. package/dist/animations/animations/balloons.d.ts +0 -8
  12. package/dist/animations/animations/balloons.d.ts.map +0 -1
  13. package/dist/animations/animations/bubbles.d.ts +0 -8
  14. package/dist/animations/animations/bubbles.d.ts.map +0 -1
  15. package/dist/animations/animations/coins.d.ts +0 -10
  16. package/dist/animations/animations/coins.d.ts.map +0 -1
  17. package/dist/animations/animations/confetti.d.ts +0 -8
  18. package/dist/animations/animations/confetti.d.ts.map +0 -1
  19. package/dist/animations/animations/crystals.d.ts +0 -8
  20. package/dist/animations/animations/crystals.d.ts.map +0 -1
  21. package/dist/animations/animations/emoji.d.ts +0 -19
  22. package/dist/animations/animations/emoji.d.ts.map +0 -1
  23. package/dist/animations/animations/fireflies.d.ts +0 -8
  24. package/dist/animations/animations/fireflies.d.ts.map +0 -1
  25. package/dist/animations/animations/fireworks.d.ts +0 -8
  26. package/dist/animations/animations/fireworks.d.ts.map +0 -1
  27. package/dist/animations/animations/galaxy.d.ts +0 -8
  28. package/dist/animations/animations/galaxy.d.ts.map +0 -1
  29. package/dist/animations/animations/glitch.d.ts +0 -8
  30. package/dist/animations/animations/glitch.d.ts.map +0 -1
  31. package/dist/animations/animations/hearts.d.ts +0 -10
  32. package/dist/animations/animations/hearts.d.ts.map +0 -1
  33. package/dist/animations/animations/index.d.ts +0 -13
  34. package/dist/animations/animations/index.d.ts.map +0 -1
  35. package/dist/animations/animations/leaves.d.ts +0 -8
  36. package/dist/animations/animations/leaves.d.ts.map +0 -1
  37. package/dist/animations/animations/magicdust.d.ts +0 -8
  38. package/dist/animations/animations/magicdust.d.ts.map +0 -1
  39. package/dist/animations/animations/paint.d.ts +0 -8
  40. package/dist/animations/animations/paint.d.ts.map +0 -1
  41. package/dist/animations/animations/petals.d.ts +0 -8
  42. package/dist/animations/animations/petals.d.ts.map +0 -1
  43. package/dist/animations/animations/snow.d.ts +0 -8
  44. package/dist/animations/animations/snow.d.ts.map +0 -1
  45. package/dist/animations/animations/sparkles.d.ts +0 -8
  46. package/dist/animations/animations/sparkles.d.ts.map +0 -1
  47. package/dist/animations/animations/stars.d.ts +0 -8
  48. package/dist/animations/animations/stars.d.ts.map +0 -1
  49. package/dist/animations/aurora.d.ts +0 -8
  50. package/dist/animations/aurora.d.ts.map +0 -1
  51. package/dist/animations/balloons.d.ts +0 -8
  52. package/dist/animations/balloons.d.ts.map +0 -1
  53. package/dist/animations/bubbles.d.ts +0 -8
  54. package/dist/animations/bubbles.d.ts.map +0 -1
  55. package/dist/animations/bubbles.esm.js +0 -53
  56. package/dist/animations/bubbles.esm.js.map +0 -1
  57. package/dist/animations/bubbles.js +0 -56
  58. package/dist/animations/bubbles.js.map +0 -1
  59. package/dist/animations/coins.d.ts +0 -10
  60. package/dist/animations/coins.d.ts.map +0 -1
  61. package/dist/animations/confetti.d.ts +0 -8
  62. package/dist/animations/confetti.d.ts.map +0 -1
  63. package/dist/animations/confetti.esm.js +0 -67
  64. package/dist/animations/confetti.esm.js.map +0 -1
  65. package/dist/animations/confetti.js +0 -70
  66. package/dist/animations/confetti.js.map +0 -1
  67. package/dist/animations/crystals.d.ts +0 -8
  68. package/dist/animations/crystals.d.ts.map +0 -1
  69. package/dist/animations/emoji.d.ts +0 -19
  70. package/dist/animations/emoji.d.ts.map +0 -1
  71. package/dist/animations/emoji.esm.js +0 -58
  72. package/dist/animations/emoji.esm.js.map +0 -1
  73. package/dist/animations/emoji.js +0 -62
  74. package/dist/animations/emoji.js.map +0 -1
  75. package/dist/animations/fireflies.d.ts +0 -8
  76. package/dist/animations/fireflies.d.ts.map +0 -1
  77. package/dist/animations/fireworks.d.ts +0 -8
  78. package/dist/animations/fireworks.d.ts.map +0 -1
  79. package/dist/animations/fireworks.esm.js +0 -64
  80. package/dist/animations/fireworks.esm.js.map +0 -1
  81. package/dist/animations/fireworks.js +0 -67
  82. package/dist/animations/fireworks.js.map +0 -1
  83. package/dist/animations/galaxy.d.ts +0 -8
  84. package/dist/animations/galaxy.d.ts.map +0 -1
  85. package/dist/animations/glitch.d.ts +0 -8
  86. package/dist/animations/glitch.d.ts.map +0 -1
  87. package/dist/animations/hearts.d.ts +0 -10
  88. package/dist/animations/hearts.d.ts.map +0 -1
  89. package/dist/animations/hearts.esm.js +0 -50
  90. package/dist/animations/hearts.esm.js.map +0 -1
  91. package/dist/animations/hearts.js +0 -53
  92. package/dist/animations/hearts.js.map +0 -1
  93. package/dist/animations/index.d.ts +0 -5
  94. package/dist/animations/index.d.ts.map +0 -1
  95. package/dist/animations/leaves.d.ts +0 -8
  96. package/dist/animations/leaves.d.ts.map +0 -1
  97. package/dist/animations/magicdust.d.ts +0 -8
  98. package/dist/animations/magicdust.d.ts.map +0 -1
  99. package/dist/animations/mobileOptimizations.d.ts +0 -6
  100. package/dist/animations/mobileOptimizations.d.ts.map +0 -1
  101. package/dist/animations/paint.d.ts +0 -8
  102. package/dist/animations/paint.d.ts.map +0 -1
  103. package/dist/animations/petals.d.ts +0 -8
  104. package/dist/animations/petals.d.ts.map +0 -1
  105. package/dist/animations/snow.d.ts +0 -8
  106. package/dist/animations/snow.d.ts.map +0 -1
  107. package/dist/animations/snow.esm.js +0 -50
  108. package/dist/animations/snow.esm.js.map +0 -1
  109. package/dist/animations/snow.js +0 -53
  110. package/dist/animations/snow.js.map +0 -1
  111. package/dist/animations/sparkles.d.ts +0 -8
  112. package/dist/animations/sparkles.d.ts.map +0 -1
  113. package/dist/animations/sparkles.esm.js +0 -42
  114. package/dist/animations/sparkles.esm.js.map +0 -1
  115. package/dist/animations/sparkles.js +0 -45
  116. package/dist/animations/sparkles.js.map +0 -1
  117. package/dist/animations/stars.d.ts +0 -8
  118. package/dist/animations/stars.d.ts.map +0 -1
  119. package/dist/animations/stars.esm.js +0 -42
  120. package/dist/animations/stars.esm.js.map +0 -1
  121. package/dist/animations/stars.js +0 -45
  122. package/dist/animations/stars.js.map +0 -1
  123. package/dist/animations/types.d.ts +0 -42
  124. package/dist/animations/types.d.ts.map +0 -1
  125. package/dist/animations/useReward.d.ts +0 -8
  126. package/dist/animations/useReward.d.ts.map +0 -1
  127. package/dist/animations/utils.d.ts +0 -7
  128. package/dist/animations/utils.d.ts.map +0 -1
  129. package/dist/index.d.ts.map +0 -1
  130. package/dist/index.esm.js +0 -1489
  131. package/dist/index.esm.js.map +0 -1
  132. package/dist/mobileOptimizations.d.ts +0 -6
  133. package/dist/mobileOptimizations.d.ts.map +0 -1
  134. package/dist/types.d.ts +0 -42
  135. package/dist/types.d.ts.map +0 -1
  136. package/dist/useReward.d.ts +0 -8
  137. package/dist/useReward.d.ts.map +0 -1
  138. package/dist/utils.d.ts +0 -7
  139. package/dist/utils.d.ts.map +0 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@ A lightweight, performant React library for adding delightful animation effects
12
12
  ## ✨ Features
13
13
 
14
14
  - 🎯 **Simple API** - Just one hook to rule them all
15
- - 🎨 **19 Beautiful Animations** - Confetti, sparkles, hearts, stars, fireworks, bubbles, snow, emoji, coins, petals, aurora, fireflies, paint, balloons, galaxy, glitch, magicdust, crystals, and leaves
15
+ - 🎨 **20 Beautiful Animations** - Confetti, sparkles, hearts, stars, fireworks, bubbles, snow, emoji, coins, petals, aurora, fireflies, paint, balloons, galaxy, glitch, magicdust, crystals, leaves, and mortar
16
16
  - 📦 **Tiny Bundle** - Zero dependencies, optimized for performance
17
17
  - 🚀 **Performant** - Optimized animations using requestAnimationFrame
18
18
  - 🎮 **Full Control** - Customize colors, particle count, physics, and more
@@ -33,13 +33,15 @@ pnpm add partycles
33
33
  ## 🚀 Quick Start
34
34
 
35
35
  ```tsx
36
+ import { useRef } from 'react';
36
37
  import { useReward } from 'partycles';
37
38
 
38
39
  function App() {
39
- const { reward, isAnimating } = useReward('rewardId', 'confetti');
40
+ const buttonRef = useRef<HTMLButtonElement>(null);
41
+ const { reward, isAnimating } = useReward(buttonRef, 'confetti');
40
42
 
41
43
  return (
42
- <button id="rewardId" onClick={reward} disabled={isAnimating}>
44
+ <button ref={buttonRef} onClick={reward} disabled={isAnimating}>
43
45
  Click me for a surprise! 🎉
44
46
  </button>
45
47
  );
@@ -48,31 +50,50 @@ function App() {
48
50
 
49
51
  That's it! No configuration needed - it just works. 🎊
50
52
 
53
+ ### Using String IDs (Legacy)
54
+
55
+ For backward compatibility, you can still use element IDs:
56
+
57
+ ```tsx
58
+ const { reward, isAnimating } = useReward('my-button', 'confetti');
59
+
60
+ <button id="my-button" onClick={reward}>
61
+ Click me! 🎉
62
+ </button>
63
+ ```
64
+
51
65
  ## 🤔 Why Partycles?
52
66
 
53
67
  - **Zero Dependencies** - No bloat, just pure React code
54
68
  - **One Hook** - Simple `useReward` hook handles everything
55
- - **19 Animations** - From confetti to magical effects, we've got you covered
69
+ - **20 Animations** - From confetti to explosive effects, we've got you covered
56
70
  - **Fully Typed** - Great TypeScript support out of the box
57
71
  - **Customizable** - Tweak colors, physics, particle count, and more
58
72
  - **Performant** - Optimized animations that won't slow down your app
59
73
 
60
74
  ## 📖 API Reference
61
75
 
62
- ### `useReward(elementId, animationType, config?)`
76
+ ### `useReward(targetRef, animationType, config?)` (Recommended)
77
+ ### `useReward(elementId, animationType, config?)` (Legacy)
63
78
 
64
79
  The main hook for creating reward animations.
65
80
 
66
81
  #### Parameters
67
82
 
68
- - `elementId` (string): The ID of the element to animate from
69
- - `animationType` (string): One of: `'confetti'`, `'sparkles'`, `'hearts'`, `'stars'`, `'fireworks'`, `'bubbles'`, `'snow'`, `'emoji'`, `'coins'`, `'petals'`, `'aurora'`, `'fireflies'`, `'paint'`, `'balloons'`, `'galaxy'`, `'glitch'`, `'magicdust'`, `'crystals'`, `'leaves'`
83
+ - `targetRef` (RefObject<HTMLElement>): A React ref to the element to animate from (recommended)
84
+ - `elementId` (string): The ID of the element to animate from (legacy, for backward compatibility)
85
+ - `animationType` (string): One of: `'confetti'`, `'sparkles'`, `'hearts'`, `'stars'`, `'fireworks'`, `'bubbles'`, `'snow'`, `'emoji'`, `'coins'`, `'petals'`, `'aurora'`, `'fireflies'`, `'paint'`, `'balloons'`, `'galaxy'`, `'glitch'`, `'magicdust'`, `'crystals'`, `'leaves'`, `'mortar'`
70
86
  - `config` (optional): Animation configuration object
71
87
 
72
88
  #### Returns
73
89
 
74
- - `reward` (function): Triggers the animation
90
+ - `reward` (function): Triggers the animation, returns a Promise that resolves when complete
75
91
  - `isAnimating` (boolean): Whether the animation is currently running
92
+ - `pause` (function): Pauses the current animation
93
+ - `resume` (function): Resumes a paused animation
94
+ - `replay` (function): Stops current animation and starts a new one
95
+ - `isPaused` (boolean): Whether the animation is currently paused
96
+ - `targetRef` (RefObject<HTMLElement>): The ref object (only returned when using ref-based API)
76
97
 
77
98
  ### Configuration Options
78
99
 
@@ -109,7 +130,8 @@ interface AnimationConfig {
109
130
  Classic celebration effect with colorful paper pieces.
110
131
 
111
132
  ```tsx
112
- const { reward } = useReward('buttonId', 'confetti', {
133
+ const buttonRef = useRef<HTMLButtonElement>(null);
134
+ const { reward } = useReward(buttonRef, 'confetti', {
113
135
  particleCount: 30,
114
136
  spread: 60,
115
137
  colors: ['#ff0000', '#00ff00', '#0000ff'],
@@ -313,8 +335,72 @@ const { reward } = useReward('buttonId', 'leaves', {
313
335
  });
314
336
  ```
315
337
 
338
+ ### Mortar 💥
339
+ Explosive mortar-style bursts with galaxy-like explosions.
340
+
341
+ ```tsx
342
+ const { reward } = useReward('buttonId', 'mortar', {
343
+ particleCount: 2,
344
+ spread: 45,
345
+ physics: { gravity: 0.35 }
346
+ });
347
+ ```
348
+
316
349
  ## 💡 Examples
317
350
 
351
+ ### Animation Controls
352
+
353
+ Control your animations with pause, resume, and replay:
354
+
355
+ ```tsx
356
+ import { useRef } from 'react';
357
+ import { useReward } from 'partycles';
358
+
359
+ function ControlledAnimation() {
360
+ const buttonRef = useRef<HTMLButtonElement>(null);
361
+ const { reward, isAnimating, pause, resume, replay, isPaused } = useReward(
362
+ buttonRef,
363
+ 'confetti',
364
+ { particleCount: 50 }
365
+ );
366
+
367
+ return (
368
+ <div>
369
+ <button ref={buttonRef} onClick={reward}>
370
+ Start Animation
371
+ </button>
372
+
373
+ <button onClick={pause} disabled={!isAnimating || isPaused}>
374
+ Pause
375
+ </button>
376
+
377
+ <button onClick={resume} disabled={!isAnimating || !isPaused}>
378
+ Resume
379
+ </button>
380
+
381
+ <button onClick={replay}>
382
+ Replay
383
+ </button>
384
+
385
+ <p>Status: {isAnimating ? (isPaused ? 'Paused' : 'Playing') : 'Idle'}</p>
386
+ </div>
387
+ );
388
+ }
389
+ ```
390
+
391
+ ### Promise-based Completion
392
+
393
+ Chain actions after animations complete:
394
+
395
+ ```tsx
396
+ const { reward } = useReward(buttonRef, 'confetti');
397
+
398
+ const handleSuccess = async () => {
399
+ await reward(); // Wait for animation to complete
400
+ console.log('Animation finished!');
401
+ // Navigate, show message, etc.
402
+ };
403
+
318
404
  ### Form Submission Success
319
405
  ```tsx
320
406
  function ContactForm() {
@@ -529,7 +615,18 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
529
615
 
530
616
  ## 📈 Changelog
531
617
 
532
- ### v1.1.3 (Latest)
618
+ ### v1.2.1 (Latest)
619
+ - 🎆 Added new `mortar` animation with galaxy-style explosions
620
+ - 🐛 Fixed particle rendering issues with dynamic particle creation
621
+ - 🎨 Updated emoji assignments for better consistency (fireflies: 🌟, coins: 💰)
622
+ - ⚡ Optimized mortar explosion performance for mobile devices
623
+ - 🔧 Improved animation manager to handle particles created during updates
624
+
625
+ ### v1.1.5
626
+ - ✨ Added optional enhanced effects (flutter, twinkle, pulse, spin3D, wobble, windDrift)
627
+ - 📱 Improved mobile performance with automatic optimizations
628
+
629
+ ### v1.1.3
533
630
  - 🚀 Added automatic mobile performance optimizations
534
631
  - 🐛 Fixed Safari compatibility issues
535
632
  - 📦 Streamlined bundle size by removing 7 animations
@@ -0,0 +1,149 @@
1
+ import { RefObject } from 'react';
2
+
3
+ interface Particle {
4
+ id: string;
5
+ x: number;
6
+ y: number;
7
+ vx: number;
8
+ vy: number;
9
+ life: number;
10
+ opacity: number;
11
+ size: number;
12
+ rotation: number;
13
+ color: string;
14
+ element?: React.ReactNode | string;
15
+ config?: AnimationConfig;
16
+ }
17
+ interface AnimationConfig {
18
+ particleCount?: number;
19
+ spread?: number;
20
+ startVelocity?: number;
21
+ decay?: number;
22
+ lifetime?: number;
23
+ colors?: string[];
24
+ elementSize?: number;
25
+ duration?: number;
26
+ physics?: {
27
+ gravity?: number;
28
+ wind?: number;
29
+ friction?: number;
30
+ };
31
+ effects?: {
32
+ flutter?: boolean;
33
+ twinkle?: boolean;
34
+ pulse?: boolean;
35
+ spin3D?: boolean;
36
+ wobble?: boolean;
37
+ windDrift?: boolean;
38
+ };
39
+ }
40
+ type AnimationType = 'confetti' | 'sparkles' | 'fireworks' | 'hearts' | 'stars' | 'bubbles' | 'snow' | 'emoji' | 'coins' | 'petals' | 'aurora' | 'fireflies' | 'paint' | 'balloons' | 'galaxy' | 'leaves' | 'glitch' | 'magicdust' | 'crystals' | 'mortar';
41
+ interface UseRewardConfig extends AnimationConfig {
42
+ animationType: AnimationType;
43
+ }
44
+ interface AnimationControls {
45
+ pause: () => void;
46
+ resume: () => void;
47
+ replay: () => Promise<void>;
48
+ isPaused: boolean;
49
+ }
50
+
51
+ interface UseRewardReturn extends AnimationControls {
52
+ reward: () => Promise<void>;
53
+ isAnimating: boolean;
54
+ targetRef?: RefObject<HTMLElement>;
55
+ }
56
+ declare function useReward(elementId: string, animationType: AnimationType, config?: AnimationConfig): UseRewardReturn;
57
+ declare function useReward(targetRef: RefObject<HTMLElement>, animationType: AnimationType, config?: AnimationConfig): UseRewardReturn;
58
+
59
+ declare const emojiPresets: {
60
+ celebration: string[];
61
+ love: string[];
62
+ happy: string[];
63
+ nature: string[];
64
+ food: string[];
65
+ default: string[];
66
+ };
67
+
68
+ declare const isMobileDevice: () => boolean;
69
+ declare const optimizeConfigForMobile: (config: AnimationConfig) => AnimationConfig;
70
+
71
+ interface PooledParticle extends Particle {
72
+ _pooled?: boolean;
73
+ }
74
+ declare class ParticlePool {
75
+ private pool;
76
+ private maxSize;
77
+ private created;
78
+ constructor(maxSize?: number);
79
+ acquire(): PooledParticle;
80
+ release(particle: PooledParticle): void;
81
+ releaseAll(particles: PooledParticle[]): void;
82
+ clear(): void;
83
+ getStats(): {
84
+ poolSize: number;
85
+ totalCreated: number;
86
+ maxSize: number;
87
+ };
88
+ }
89
+ declare const particlePool: ParticlePool;
90
+
91
+ interface AnimationInstance {
92
+ id: string;
93
+ particles: Particle[];
94
+ containerElement: HTMLDivElement;
95
+ renderFunction: (particle: Particle) => React.ReactNode;
96
+ updateCallback?: (particles: Particle[]) => void;
97
+ onComplete?: () => void;
98
+ physics: {
99
+ gravity: number;
100
+ friction: number;
101
+ wind: number;
102
+ };
103
+ animationType: string;
104
+ config?: {
105
+ effects?: {
106
+ flutter?: boolean;
107
+ windDrift?: boolean;
108
+ wobble?: boolean;
109
+ twinkle?: boolean;
110
+ };
111
+ };
112
+ frameCount: number;
113
+ isPaused?: boolean;
114
+ pausedAt?: number;
115
+ }
116
+ declare class AnimationManager {
117
+ private animations;
118
+ private rafId;
119
+ private isRunning;
120
+ private lastFrameTime;
121
+ private frameInterval;
122
+ private frameCount;
123
+ private fpsUpdateInterval;
124
+ private lastFpsUpdate;
125
+ private currentFps;
126
+ constructor();
127
+ addAnimation(animation: AnimationInstance): void;
128
+ removeAnimation(id: string): void;
129
+ private start;
130
+ private stop;
131
+ private update;
132
+ private applyEffects;
133
+ private handleMortarExplosion;
134
+ private updateOpacity;
135
+ getStats(): {
136
+ activeAnimations: number;
137
+ currentFps: number;
138
+ isRunning: boolean;
139
+ totalParticles: number;
140
+ };
141
+ setTargetFPS(fps: number): void;
142
+ pauseAnimation(id: string): void;
143
+ resumeAnimation(id: string): void;
144
+ isAnimationPaused(id: string): boolean;
145
+ getAnimation(id: string): AnimationInstance | undefined;
146
+ }
147
+ declare const animationManager: AnimationManager;
148
+
149
+ export { type AnimationConfig, type AnimationType, type UseRewardConfig, animationManager, emojiPresets, isMobileDevice, optimizeConfigForMobile, particlePool, useReward };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,149 @@
1
- export { useReward } from './useReward';
2
- export type { AnimationType, AnimationConfig, UseRewardConfig } from './types';
3
- export { emojiPresets } from './animations/emoji';
4
- export { isMobileDevice, optimizeConfigForMobile } from './mobileOptimizations';
5
- //# sourceMappingURL=index.d.ts.map
1
+ import { RefObject } from 'react';
2
+
3
+ interface Particle {
4
+ id: string;
5
+ x: number;
6
+ y: number;
7
+ vx: number;
8
+ vy: number;
9
+ life: number;
10
+ opacity: number;
11
+ size: number;
12
+ rotation: number;
13
+ color: string;
14
+ element?: React.ReactNode | string;
15
+ config?: AnimationConfig;
16
+ }
17
+ interface AnimationConfig {
18
+ particleCount?: number;
19
+ spread?: number;
20
+ startVelocity?: number;
21
+ decay?: number;
22
+ lifetime?: number;
23
+ colors?: string[];
24
+ elementSize?: number;
25
+ duration?: number;
26
+ physics?: {
27
+ gravity?: number;
28
+ wind?: number;
29
+ friction?: number;
30
+ };
31
+ effects?: {
32
+ flutter?: boolean;
33
+ twinkle?: boolean;
34
+ pulse?: boolean;
35
+ spin3D?: boolean;
36
+ wobble?: boolean;
37
+ windDrift?: boolean;
38
+ };
39
+ }
40
+ type AnimationType = 'confetti' | 'sparkles' | 'fireworks' | 'hearts' | 'stars' | 'bubbles' | 'snow' | 'emoji' | 'coins' | 'petals' | 'aurora' | 'fireflies' | 'paint' | 'balloons' | 'galaxy' | 'leaves' | 'glitch' | 'magicdust' | 'crystals' | 'mortar';
41
+ interface UseRewardConfig extends AnimationConfig {
42
+ animationType: AnimationType;
43
+ }
44
+ interface AnimationControls {
45
+ pause: () => void;
46
+ resume: () => void;
47
+ replay: () => Promise<void>;
48
+ isPaused: boolean;
49
+ }
50
+
51
+ interface UseRewardReturn extends AnimationControls {
52
+ reward: () => Promise<void>;
53
+ isAnimating: boolean;
54
+ targetRef?: RefObject<HTMLElement>;
55
+ }
56
+ declare function useReward(elementId: string, animationType: AnimationType, config?: AnimationConfig): UseRewardReturn;
57
+ declare function useReward(targetRef: RefObject<HTMLElement>, animationType: AnimationType, config?: AnimationConfig): UseRewardReturn;
58
+
59
+ declare const emojiPresets: {
60
+ celebration: string[];
61
+ love: string[];
62
+ happy: string[];
63
+ nature: string[];
64
+ food: string[];
65
+ default: string[];
66
+ };
67
+
68
+ declare const isMobileDevice: () => boolean;
69
+ declare const optimizeConfigForMobile: (config: AnimationConfig) => AnimationConfig;
70
+
71
+ interface PooledParticle extends Particle {
72
+ _pooled?: boolean;
73
+ }
74
+ declare class ParticlePool {
75
+ private pool;
76
+ private maxSize;
77
+ private created;
78
+ constructor(maxSize?: number);
79
+ acquire(): PooledParticle;
80
+ release(particle: PooledParticle): void;
81
+ releaseAll(particles: PooledParticle[]): void;
82
+ clear(): void;
83
+ getStats(): {
84
+ poolSize: number;
85
+ totalCreated: number;
86
+ maxSize: number;
87
+ };
88
+ }
89
+ declare const particlePool: ParticlePool;
90
+
91
+ interface AnimationInstance {
92
+ id: string;
93
+ particles: Particle[];
94
+ containerElement: HTMLDivElement;
95
+ renderFunction: (particle: Particle) => React.ReactNode;
96
+ updateCallback?: (particles: Particle[]) => void;
97
+ onComplete?: () => void;
98
+ physics: {
99
+ gravity: number;
100
+ friction: number;
101
+ wind: number;
102
+ };
103
+ animationType: string;
104
+ config?: {
105
+ effects?: {
106
+ flutter?: boolean;
107
+ windDrift?: boolean;
108
+ wobble?: boolean;
109
+ twinkle?: boolean;
110
+ };
111
+ };
112
+ frameCount: number;
113
+ isPaused?: boolean;
114
+ pausedAt?: number;
115
+ }
116
+ declare class AnimationManager {
117
+ private animations;
118
+ private rafId;
119
+ private isRunning;
120
+ private lastFrameTime;
121
+ private frameInterval;
122
+ private frameCount;
123
+ private fpsUpdateInterval;
124
+ private lastFpsUpdate;
125
+ private currentFps;
126
+ constructor();
127
+ addAnimation(animation: AnimationInstance): void;
128
+ removeAnimation(id: string): void;
129
+ private start;
130
+ private stop;
131
+ private update;
132
+ private applyEffects;
133
+ private handleMortarExplosion;
134
+ private updateOpacity;
135
+ getStats(): {
136
+ activeAnimations: number;
137
+ currentFps: number;
138
+ isRunning: boolean;
139
+ totalParticles: number;
140
+ };
141
+ setTargetFPS(fps: number): void;
142
+ pauseAnimation(id: string): void;
143
+ resumeAnimation(id: string): void;
144
+ isAnimationPaused(id: string): boolean;
145
+ getAnimation(id: string): AnimationInstance | undefined;
146
+ }
147
+ declare const animationManager: AnimationManager;
148
+
149
+ export { type AnimationConfig, type AnimationType, type UseRewardConfig, animationManager, emojiPresets, isMobileDevice, optimizeConfigForMobile, particlePool, useReward };