react-native-games 1.1.0 → 1.3.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 (419) hide show
  1. package/README.md +101 -30
  2. package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -167
  3. package/lib/module/games/balloon-blaster/BalloonBlaster.js.map +1 -1
  4. package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js +1 -182
  5. package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js.map +1 -1
  6. package/lib/module/games/balloon-blaster/BalloonBlasterService.js +1 -318
  7. package/lib/module/games/balloon-blaster/BalloonBlasterStore.js +1 -183
  8. package/lib/module/games/balloon-blaster/components/BalloonComponent.js +1 -237
  9. package/lib/module/games/balloon-blaster/components/GameArea.js +1 -156
  10. package/lib/module/games/balloon-blaster/components/GameBackground.js +1 -476
  11. package/lib/module/games/balloon-blaster/components/ScoreBoard.js +1 -112
  12. package/lib/module/games/balloon-blaster/components/ScoreBoard.js.map +1 -1
  13. package/lib/module/games/balloon-blaster/components/index.js +1 -7
  14. package/lib/module/games/bike-racing/BikeRacing.js +1 -0
  15. package/lib/module/games/bike-racing/BikeRacing.js.map +1 -0
  16. package/lib/module/games/bike-racing/BikeRacingConstants.js +1 -0
  17. package/lib/module/games/bike-racing/BikeRacingConstants.js.map +1 -0
  18. package/lib/module/games/bike-racing/BikeRacingService.js +1 -0
  19. package/lib/module/games/bike-racing/BikeRacingService.js.map +1 -0
  20. package/lib/module/games/bike-racing/BikeRacingStore.js +1 -0
  21. package/lib/module/games/bike-racing/BikeRacingStore.js.map +1 -0
  22. package/lib/module/games/bike-racing/components/BikeComponent.js +1 -0
  23. package/lib/module/games/bike-racing/components/BikeComponent.js.map +1 -0
  24. package/lib/module/games/bike-racing/components/GameBackground.js +1 -0
  25. package/lib/module/games/bike-racing/components/GameBackground.js.map +1 -0
  26. package/lib/module/games/bike-racing/components/ScoreBoard.js +1 -0
  27. package/lib/module/games/bike-racing/components/ScoreBoard.js.map +1 -0
  28. package/lib/module/games/bike-racing/components/index.js +1 -0
  29. package/lib/module/games/bike-racing/components/index.js.map +1 -0
  30. package/lib/module/games/bike-racing/index.js +1 -0
  31. package/lib/module/games/bike-racing/index.js.map +1 -0
  32. package/lib/module/games/block-blast/BlockBlast.js +1 -0
  33. package/lib/module/games/block-blast/BlockBlast.js.map +1 -0
  34. package/lib/module/games/block-blast/BlockBlastConstants.js +1 -0
  35. package/lib/module/games/block-blast/BlockBlastConstants.js.map +1 -0
  36. package/lib/module/games/block-blast/BlockBlastService.js +1 -0
  37. package/lib/module/games/block-blast/BlockBlastService.js.map +1 -0
  38. package/lib/module/games/block-blast/BlockBlastStore.js +1 -0
  39. package/lib/module/games/block-blast/BlockBlastStore.js.map +1 -0
  40. package/lib/module/games/block-blast/components/BlockPieceComponent.js +1 -0
  41. package/lib/module/games/block-blast/components/BlockPieceComponent.js.map +1 -0
  42. package/lib/module/games/block-blast/components/GameArea.js +1 -0
  43. package/lib/module/games/block-blast/components/GameArea.js.map +1 -0
  44. package/lib/module/games/block-blast/components/GameBackground.js +1 -0
  45. package/lib/module/games/block-blast/components/GameBackground.js.map +1 -0
  46. package/lib/module/games/block-blast/components/GridComponent.js +1 -0
  47. package/lib/module/games/block-blast/components/GridComponent.js.map +1 -0
  48. package/lib/module/games/block-blast/components/ScoreBoard.js +1 -0
  49. package/lib/module/games/block-blast/components/ScoreBoard.js.map +1 -0
  50. package/lib/module/games/block-blast/components/index.js +1 -0
  51. package/lib/module/games/block-blast/components/index.js.map +1 -0
  52. package/lib/module/games/block-blast/index.js +1 -0
  53. package/lib/module/games/block-blast/index.js.map +1 -0
  54. package/lib/module/games/bubble-shooter/BubbleShooter.js +1 -0
  55. package/lib/module/games/bubble-shooter/BubbleShooter.js.map +1 -0
  56. package/lib/module/games/bubble-shooter/BubbleShooterConstants.js +1 -0
  57. package/lib/module/games/bubble-shooter/BubbleShooterConstants.js.map +1 -0
  58. package/lib/module/games/bubble-shooter/BubbleShooterService.js +1 -0
  59. package/lib/module/games/bubble-shooter/BubbleShooterService.js.map +1 -0
  60. package/lib/module/games/bubble-shooter/BubbleShooterStore.js +1 -0
  61. package/lib/module/games/bubble-shooter/BubbleShooterStore.js.map +1 -0
  62. package/lib/module/games/bubble-shooter/components/GameArea.js +1 -0
  63. package/lib/module/games/bubble-shooter/components/GameArea.js.map +1 -0
  64. package/lib/module/games/bubble-shooter/components/GameBackground.js +1 -0
  65. package/lib/module/games/bubble-shooter/components/GameBackground.js.map +1 -0
  66. package/lib/module/games/bubble-shooter/components/ScoreBoard.js +1 -0
  67. package/lib/module/games/bubble-shooter/components/ScoreBoard.js.map +1 -0
  68. package/lib/module/games/bubble-shooter/components/index.js +1 -0
  69. package/lib/module/games/bubble-shooter/components/index.js.map +1 -0
  70. package/lib/module/games/bubble-shooter/index.js +1 -0
  71. package/lib/module/games/bubble-shooter/index.js.map +1 -0
  72. package/lib/module/games/candy-crush/CandyCrush.js +1 -131
  73. package/lib/module/games/candy-crush/CandyCrush.js.map +1 -1
  74. package/lib/module/games/candy-crush/CandyCrushConstants.js +1 -125
  75. package/lib/module/games/candy-crush/CandyCrushConstants.js.map +1 -1
  76. package/lib/module/games/candy-crush/CandyCrushService.js +1 -370
  77. package/lib/module/games/candy-crush/CandyCrushStore.js +1 -303
  78. package/lib/module/games/candy-crush/components/CandyItem.js +1 -191
  79. package/lib/module/games/candy-crush/components/GameBackground.js +1 -85
  80. package/lib/module/games/candy-crush/components/GameGrid.js +1 -314
  81. package/lib/module/games/candy-crush/components/ScoreBoard.js +1 -79
  82. package/lib/module/games/candy-crush/components/index.js +1 -7
  83. package/lib/module/games/candy-crush/index.js +1 -6
  84. package/lib/module/games/car-racing/CarRacing.js +1 -0
  85. package/lib/module/games/car-racing/CarRacing.js.map +1 -0
  86. package/lib/module/games/car-racing/CarRacingConstants.js +1 -0
  87. package/lib/module/games/car-racing/CarRacingConstants.js.map +1 -0
  88. package/lib/module/games/car-racing/CarRacingService.js +1 -0
  89. package/lib/module/games/car-racing/CarRacingService.js.map +1 -0
  90. package/lib/module/games/car-racing/CarRacingStore.js +1 -0
  91. package/lib/module/games/car-racing/CarRacingStore.js.map +1 -0
  92. package/lib/module/games/car-racing/components/CarComponent.js +1 -0
  93. package/lib/module/games/car-racing/components/CarComponent.js.map +1 -0
  94. package/lib/module/games/car-racing/components/GameBackground.js +1 -0
  95. package/lib/module/games/car-racing/components/GameBackground.js.map +1 -0
  96. package/lib/module/games/car-racing/components/ScoreBoard.js +1 -0
  97. package/lib/module/games/car-racing/components/ScoreBoard.js.map +1 -0
  98. package/lib/module/games/car-racing/components/index.js +1 -0
  99. package/lib/module/games/car-racing/components/index.js.map +1 -0
  100. package/lib/module/games/colors-sort/ColorsSort.js +1 -143
  101. package/lib/module/games/colors-sort/ColorsSort.js.map +1 -1
  102. package/lib/module/games/colors-sort/ColorsSortConstants.js +1 -72
  103. package/lib/module/games/colors-sort/ColorsSortConstants.js.map +1 -1
  104. package/lib/module/games/colors-sort/ColorsSortService.js +1 -255
  105. package/lib/module/games/colors-sort/ColorsSortStore.js +1 -257
  106. package/lib/module/games/colors-sort/ColorsSortStore.js.map +1 -1
  107. package/lib/module/games/colors-sort/components/ColorContainer.js +1 -140
  108. package/lib/module/games/colors-sort/components/GameBackground.js +1 -135
  109. package/lib/module/games/colors-sort/components/ScoreBoard.js +1 -70
  110. package/lib/module/games/colors-sort/components/index.js +1 -6
  111. package/lib/module/games/dino-jump/DinoJump.js +1 -209
  112. package/lib/module/games/dino-jump/DinoJump.js.map +1 -1
  113. package/lib/module/games/dino-jump/DinoJumpConstants.js +1 -189
  114. package/lib/module/games/dino-jump/DinoJumpConstants.js.map +1 -1
  115. package/lib/module/games/dino-jump/DinoJumpService.js +1 -270
  116. package/lib/module/games/dino-jump/DinoJumpStore.js +1 -381
  117. package/lib/module/games/dino-jump/components/DinoSprite.js +1 -418
  118. package/lib/module/games/dino-jump/components/DinoSprite.js.map +1 -1
  119. package/lib/module/games/dino-jump/components/GameArea.js +1 -68
  120. package/lib/module/games/dino-jump/components/GameBackground.js +1 -444
  121. package/lib/module/games/dino-jump/components/ObstacleSprite.js +1 -306
  122. package/lib/module/games/dino-jump/components/ScoreBoard.js +1 -105
  123. package/lib/module/games/dino-jump/components/ScoreBoard.js.map +1 -1
  124. package/lib/module/games/dino-jump/components/StarSprite.js +1 -45
  125. package/lib/module/games/dino-jump/components/index.js +1 -9
  126. package/lib/module/games/flappy-bird/FlappyBird.js +1 -126
  127. package/lib/module/games/flappy-bird/FlappyBird.js.map +1 -1
  128. package/lib/module/games/flappy-bird/FlappyBirdConstants.js +1 -90
  129. package/lib/module/games/flappy-bird/FlappyBirdConstants.js.map +1 -1
  130. package/lib/module/games/flappy-bird/FlappyBirdStore.js +1 -300
  131. package/lib/module/games/flappy-bird/components/Bird.js +1 -87
  132. package/lib/module/games/flappy-bird/components/GameArea.js +1 -87
  133. package/lib/module/games/flappy-bird/components/GameBackground.js +1 -79
  134. package/lib/module/games/flappy-bird/components/Pipes.js +1 -172
  135. package/lib/module/games/flappy-bird/components/ScoreBoard.js +1 -73
  136. package/lib/module/games/flappy-bird/components/index.js +1 -8
  137. package/lib/module/games/fruit-merger/FruitMerger.js +1 -120
  138. package/lib/module/games/fruit-merger/FruitMerger.js.map +1 -1
  139. package/lib/module/games/fruit-merger/FruitMergerConstants.js +1 -119
  140. package/lib/module/games/fruit-merger/FruitMergerConstants.js.map +1 -1
  141. package/lib/module/games/fruit-merger/FruitMergerService.js +1 -13
  142. package/lib/module/games/fruit-merger/FruitMergerStore.js +1 -315
  143. package/lib/module/games/fruit-merger/components/FruitItem.js +1 -102
  144. package/lib/module/games/fruit-merger/components/GameArea.js +1 -103
  145. package/lib/module/games/fruit-merger/components/GameBackground.js +1 -498
  146. package/lib/module/games/fruit-merger/components/ScoreBoard.js +1 -58
  147. package/lib/module/games/fruit-merger/components/index.js +1 -7
  148. package/lib/module/games/fruit-ninja/FruitNinja.js +1 -134
  149. package/lib/module/games/fruit-ninja/FruitNinja.js.map +1 -1
  150. package/lib/module/games/fruit-ninja/FruitNinjaConstants.js +1 -148
  151. package/lib/module/games/fruit-ninja/FruitNinjaConstants.js.map +1 -1
  152. package/lib/module/games/fruit-ninja/FruitNinjaService.js +1 -311
  153. package/lib/module/games/fruit-ninja/FruitNinjaStore.js +1 -191
  154. package/lib/module/games/fruit-ninja/FruitNinjaStore.js.map +1 -1
  155. package/lib/module/games/fruit-ninja/components/FruitComponent.js +1 -99
  156. package/lib/module/games/fruit-ninja/components/GameArea.js +1 -215
  157. package/lib/module/games/fruit-ninja/components/GameBackground.js +1 -1267
  158. package/lib/module/games/fruit-ninja/components/ScoreBoard.js +1 -92
  159. package/lib/module/games/fruit-ninja/components/ScoreBoard.js.map +1 -1
  160. package/lib/module/games/fruit-ninja/components/index.js +1 -7
  161. package/lib/module/games/game-2048/Game2048.js +1 -149
  162. package/lib/module/games/game-2048/Game2048.js.map +1 -1
  163. package/lib/module/games/game-2048/Game2048Constants.js +1 -263
  164. package/lib/module/games/game-2048/Game2048Constants.js.map +1 -1
  165. package/lib/module/games/game-2048/Game2048Service.js +1 -457
  166. package/lib/module/games/game-2048/Game2048Store.js +1 -236
  167. package/lib/module/games/game-2048/components/GameBackground.js +1 -247
  168. package/lib/module/games/game-2048/components/GameGrid.js +1 -139
  169. package/lib/module/games/game-2048/components/GameTile.js +1 -72
  170. package/lib/module/games/game-2048/components/ScoreBoard.js +1 -52
  171. package/lib/module/games/game-2048/components/index.js +1 -7
  172. package/lib/module/games/maze-runner/MazeRunner.js +1 -267
  173. package/lib/module/games/maze-runner/MazeRunner.js.map +1 -1
  174. package/lib/module/games/maze-runner/MazeRunnerConstants.js +1 -100
  175. package/lib/module/games/maze-runner/MazeRunnerConstants.js.map +1 -1
  176. package/lib/module/games/maze-runner/MazeRunnerService.js +1 -586
  177. package/lib/module/games/maze-runner/components/EnhancedBallComponent.js +1 -150
  178. package/lib/module/games/maze-runner/components/EnhancedGameArea.js +1 -370
  179. package/lib/module/games/maze-runner/components/GameBackground.js +1 -175
  180. package/lib/module/games/maze-runner/components/ScoreBoard.js +1 -61
  181. package/lib/module/games/maze-runner/components/SkiaPipeComponent.js +1 -209
  182. package/lib/module/games/maze-runner/components/StaticGameBackground.js +1 -169
  183. package/lib/module/games/maze-runner/components/WallComponent.js +1 -91
  184. package/lib/module/games/maze-runner/components/index.js +1 -8
  185. package/lib/module/games/perfect-circle/PerfectCircle.js +1 -0
  186. package/lib/module/games/perfect-circle/PerfectCircle.js.map +1 -0
  187. package/lib/module/games/perfect-circle/PerfectCircleConstants.js +1 -0
  188. package/lib/module/games/perfect-circle/PerfectCircleConstants.js.map +1 -0
  189. package/lib/module/games/perfect-circle/PerfectCircleService.js +1 -0
  190. package/lib/module/games/perfect-circle/PerfectCircleService.js.map +1 -0
  191. package/lib/module/games/perfect-circle/PerfectCircleStore.js +1 -0
  192. package/lib/module/games/perfect-circle/PerfectCircleStore.js.map +1 -0
  193. package/lib/module/games/perfect-circle/components/DrawingCanvas.js +1 -0
  194. package/lib/module/games/perfect-circle/components/DrawingCanvas.js.map +1 -0
  195. package/lib/module/games/perfect-circle/components/GameBackground.js +1 -0
  196. package/lib/module/games/perfect-circle/components/GameBackground.js.map +1 -0
  197. package/lib/module/games/perfect-circle/components/ScoreBoard.js +1 -0
  198. package/lib/module/games/perfect-circle/components/ScoreBoard.js.map +1 -0
  199. package/lib/module/games/perfect-circle/index.js +1 -0
  200. package/lib/module/games/perfect-circle/index.js.map +1 -0
  201. package/lib/module/games/popit-fidget/PopitFidget.js +1 -285
  202. package/lib/module/games/popit-fidget/PopitFidget.js.map +1 -1
  203. package/lib/module/games/popit-fidget/PopitFidgetConstants.js +1 -113
  204. package/lib/module/games/popit-fidget/PopitFidgetConstants.js.map +1 -1
  205. package/lib/module/games/popit-fidget/PopitFidgetService.js +1 -132
  206. package/lib/module/games/popit-fidget/PopitFidgetStore.js +1 -125
  207. package/lib/module/games/popit-fidget/components/BubbleComponent.js +1 -198
  208. package/lib/module/games/popit-fidget/components/FidgetGrid.js +1 -165
  209. package/lib/module/games/popit-fidget/components/GameBackground.js +1 -177
  210. package/lib/module/games/popit-fidget/components/ScoreBoard.js +1 -61
  211. package/lib/module/games/popit-fidget/components/index.js +1 -7
  212. package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -159
  213. package/lib/module/games/sliding-numbers/SlidingNumbers.js.map +1 -1
  214. package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js +1 -207
  215. package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js.map +1 -1
  216. package/lib/module/games/sliding-numbers/SlidingNumbersService.js +1 -248
  217. package/lib/module/games/sliding-numbers/SlidingNumbersStore.js +1 -274
  218. package/lib/module/games/sliding-numbers/components/GameBackground.js +1 -259
  219. package/lib/module/games/sliding-numbers/components/NumbersGrid.js +1 -174
  220. package/lib/module/games/sliding-numbers/components/NumbersTile.js +1 -116
  221. package/lib/module/games/sliding-numbers/components/ScoreBoard.js +1 -64
  222. package/lib/module/games/sliding-numbers/components/index.js +1 -7
  223. package/lib/module/games/snake/Snake.js +1 -189
  224. package/lib/module/games/snake/Snake.js.map +1 -1
  225. package/lib/module/games/snake/SnakeConstants.js +1 -138
  226. package/lib/module/games/snake/SnakeConstants.js.map +1 -1
  227. package/lib/module/games/snake/SnakeService.js +1 -148
  228. package/lib/module/games/snake/SnakeStore.js +1 -182
  229. package/lib/module/games/snake/SnakeStore.js.map +1 -1
  230. package/lib/module/games/snake/components/GameBackground.js +1 -221
  231. package/lib/module/games/snake/components/GameGrid.js +1 -153
  232. package/lib/module/games/snake/components/ScoreBoard.js +1 -51
  233. package/lib/module/games/snake/components/ScoreBoard.js.map +1 -1
  234. package/lib/module/games/snake/components/index.js +1 -6
  235. package/lib/module/games/snake/index.js +1 -6
  236. package/lib/module/games/space-fighter/SpaceFighter.js +1 -165
  237. package/lib/module/games/space-fighter/SpaceFighter.js.map +1 -1
  238. package/lib/module/games/space-fighter/SpaceFighterConstants.js +1 -108
  239. package/lib/module/games/space-fighter/SpaceFighterConstants.js.map +1 -1
  240. package/lib/module/games/space-fighter/SpaceFighterService.js +1 -326
  241. package/lib/module/games/space-fighter/SpaceFighterStore.js +1 -209
  242. package/lib/module/games/space-fighter/components/AsteroidComponent.js +1 -113
  243. package/lib/module/games/space-fighter/components/GameArea.js +1 -289
  244. package/lib/module/games/space-fighter/components/GameBackground.js +1 -239
  245. package/lib/module/games/space-fighter/components/ScoreBoard.js +1 -136
  246. package/lib/module/games/space-fighter/components/Spacecraft3D.js +1 -202
  247. package/lib/module/games/space-fighter/components/SpacecraftPath.js +1 -52
  248. package/lib/module/games/space-fighter/components/index.js +1 -9
  249. package/lib/module/games/whack-a-mole/WhackAMole.js +1 -270
  250. package/lib/module/games/whack-a-mole/WhackAMole.js.map +1 -1
  251. package/lib/module/games/whack-a-mole/WhackAMoleConstants.js +1 -115
  252. package/lib/module/games/whack-a-mole/WhackAMoleConstants.js.map +1 -1
  253. package/lib/module/games/whack-a-mole/WhackAMoleService.js +1 -120
  254. package/lib/module/games/whack-a-mole/WhackAMoleStore.js +1 -172
  255. package/lib/module/games/whack-a-mole/components/GameBackground.js +1 -477
  256. package/lib/module/games/whack-a-mole/components/GameGrid.js +1 -97
  257. package/lib/module/games/whack-a-mole/components/GameHole.js +1 -196
  258. package/lib/module/games/whack-a-mole/components/MoleCharacter.js +1 -241
  259. package/lib/module/games/whack-a-mole/components/ScoreBoard.js +1 -67
  260. package/lib/module/games/whack-a-mole/components/ScoreBoard.js.map +1 -1
  261. package/lib/module/games/whack-a-mole/components/index.js +1 -8
  262. package/lib/module/helpers/AnimationFrame.js +1 -120
  263. package/lib/module/helpers/AnimationTracker.js +1 -89
  264. package/lib/module/helpers/ErrorHandler.js +1 -269
  265. package/lib/module/helpers/GameControlButton.js +1 -219
  266. package/lib/module/helpers/GameOverModal.js +1 -144
  267. package/lib/module/helpers/GameOverModal.js.map +1 -1
  268. package/lib/module/helpers/GameSettingsModal.js +1 -287
  269. package/lib/module/helpers/GameSettingsModal.js.map +1 -1
  270. package/lib/module/helpers/ParticleBlast.js +1 -134
  271. package/lib/module/helpers/ScoreBoardContainer.js +1 -34
  272. package/lib/module/helpers/ScoreBoardContainer.js.map +1 -1
  273. package/lib/module/helpers/index.js +1 -12
  274. package/lib/module/index.js +1 -22
  275. package/lib/module/index.js.map +1 -1
  276. package/lib/module/services/GamesConstants.js +1 -178
  277. package/lib/module/services/GamesConstants.js.map +1 -1
  278. package/lib/module/services/GamesService.js +1 -112
  279. package/lib/module/services/GamesService.js.map +1 -1
  280. package/lib/module/services/HapticsService.js +1 -77
  281. package/lib/module/services/ScoringService.js +1 -0
  282. package/lib/module/services/ScoringService.js.map +1 -0
  283. package/lib/module/services/SoundsService.js +1 -302
  284. package/lib/module/services/SoundsService.js.map +1 -1
  285. package/lib/module/services/UtilsService.js +1 -32
  286. package/lib/module/services/UtilsService.js.map +1 -1
  287. package/lib/typescript/src/games/balloon-blaster/BalloonBlaster.d.ts.map +1 -1
  288. package/lib/typescript/src/games/balloon-blaster/BalloonBlasterConstants.d.ts +1 -1
  289. package/lib/typescript/src/games/balloon-blaster/components/ScoreBoard.d.ts.map +1 -1
  290. package/lib/typescript/src/games/bike-racing/BikeRacing.d.ts +4 -0
  291. package/lib/typescript/src/games/bike-racing/BikeRacing.d.ts.map +1 -0
  292. package/lib/typescript/src/games/bike-racing/BikeRacingConstants.d.ts +76 -0
  293. package/lib/typescript/src/games/bike-racing/BikeRacingConstants.d.ts.map +1 -0
  294. package/lib/typescript/src/games/bike-racing/BikeRacingService.d.ts +22 -0
  295. package/lib/typescript/src/games/bike-racing/BikeRacingService.d.ts.map +1 -0
  296. package/lib/typescript/src/games/bike-racing/BikeRacingStore.d.ts +72 -0
  297. package/lib/typescript/src/games/bike-racing/BikeRacingStore.d.ts.map +1 -0
  298. package/lib/typescript/src/games/bike-racing/components/BikeComponent.d.ts +12 -0
  299. package/lib/typescript/src/games/bike-racing/components/BikeComponent.d.ts.map +1 -0
  300. package/lib/typescript/src/games/bike-racing/components/GameBackground.d.ts +9 -0
  301. package/lib/typescript/src/games/bike-racing/components/GameBackground.d.ts.map +1 -0
  302. package/lib/typescript/src/games/bike-racing/components/ScoreBoard.d.ts +7 -0
  303. package/lib/typescript/src/games/bike-racing/components/ScoreBoard.d.ts.map +1 -0
  304. package/lib/typescript/src/games/bike-racing/components/index.d.ts +4 -0
  305. package/lib/typescript/src/games/bike-racing/components/index.d.ts.map +1 -0
  306. package/lib/typescript/src/games/bike-racing/index.d.ts +5 -0
  307. package/lib/typescript/src/games/bike-racing/index.d.ts.map +1 -0
  308. package/lib/typescript/src/games/block-blast/BlockBlast.d.ts +4 -0
  309. package/lib/typescript/src/games/block-blast/BlockBlast.d.ts.map +1 -0
  310. package/lib/typescript/src/games/block-blast/BlockBlastConstants.d.ts +82 -0
  311. package/lib/typescript/src/games/block-blast/BlockBlastConstants.d.ts.map +1 -0
  312. package/lib/typescript/src/games/block-blast/BlockBlastService.d.ts +17 -0
  313. package/lib/typescript/src/games/block-blast/BlockBlastService.d.ts.map +1 -0
  314. package/lib/typescript/src/games/block-blast/BlockBlastStore.d.ts +62 -0
  315. package/lib/typescript/src/games/block-blast/BlockBlastStore.d.ts.map +1 -0
  316. package/lib/typescript/src/games/block-blast/components/BlockPieceComponent.d.ts +14 -0
  317. package/lib/typescript/src/games/block-blast/components/BlockPieceComponent.d.ts.map +1 -0
  318. package/lib/typescript/src/games/block-blast/components/GameArea.d.ts +12 -0
  319. package/lib/typescript/src/games/block-blast/components/GameArea.d.ts.map +1 -0
  320. package/lib/typescript/src/games/block-blast/components/GameBackground.d.ts +7 -0
  321. package/lib/typescript/src/games/block-blast/components/GameBackground.d.ts.map +1 -0
  322. package/lib/typescript/src/games/block-blast/components/GridComponent.d.ts +17 -0
  323. package/lib/typescript/src/games/block-blast/components/GridComponent.d.ts.map +1 -0
  324. package/lib/typescript/src/games/block-blast/components/ScoreBoard.d.ts +7 -0
  325. package/lib/typescript/src/games/block-blast/components/ScoreBoard.d.ts.map +1 -0
  326. package/lib/typescript/src/games/block-blast/components/index.d.ts +6 -0
  327. package/lib/typescript/src/games/block-blast/components/index.d.ts.map +1 -0
  328. package/lib/typescript/src/games/block-blast/index.d.ts +5 -0
  329. package/lib/typescript/src/games/block-blast/index.d.ts.map +1 -0
  330. package/lib/typescript/src/games/bubble-shooter/BubbleShooter.d.ts +4 -0
  331. package/lib/typescript/src/games/bubble-shooter/BubbleShooter.d.ts.map +1 -0
  332. package/lib/typescript/src/games/bubble-shooter/BubbleShooterConstants.d.ts +61 -0
  333. package/lib/typescript/src/games/bubble-shooter/BubbleShooterConstants.d.ts.map +1 -0
  334. package/lib/typescript/src/games/bubble-shooter/BubbleShooterService.d.ts +26 -0
  335. package/lib/typescript/src/games/bubble-shooter/BubbleShooterService.d.ts.map +1 -0
  336. package/lib/typescript/src/games/bubble-shooter/BubbleShooterStore.d.ts +62 -0
  337. package/lib/typescript/src/games/bubble-shooter/BubbleShooterStore.d.ts.map +1 -0
  338. package/lib/typescript/src/games/bubble-shooter/components/GameArea.d.ts +9 -0
  339. package/lib/typescript/src/games/bubble-shooter/components/GameArea.d.ts.map +1 -0
  340. package/lib/typescript/src/games/bubble-shooter/components/GameBackground.d.ts +8 -0
  341. package/lib/typescript/src/games/bubble-shooter/components/GameBackground.d.ts.map +1 -0
  342. package/lib/typescript/src/games/bubble-shooter/components/ScoreBoard.d.ts +7 -0
  343. package/lib/typescript/src/games/bubble-shooter/components/ScoreBoard.d.ts.map +1 -0
  344. package/lib/typescript/src/games/bubble-shooter/components/index.d.ts +4 -0
  345. package/lib/typescript/src/games/bubble-shooter/components/index.d.ts.map +1 -0
  346. package/lib/typescript/src/games/bubble-shooter/index.d.ts +3 -0
  347. package/lib/typescript/src/games/bubble-shooter/index.d.ts.map +1 -0
  348. package/lib/typescript/src/games/candy-crush/CandyCrush.d.ts.map +1 -1
  349. package/lib/typescript/src/games/candy-crush/CandyCrushConstants.d.ts +7 -7
  350. package/lib/typescript/src/games/car-racing/CarRacing.d.ts +4 -0
  351. package/lib/typescript/src/games/car-racing/CarRacing.d.ts.map +1 -0
  352. package/lib/typescript/src/games/car-racing/CarRacingConstants.d.ts +76 -0
  353. package/lib/typescript/src/games/car-racing/CarRacingConstants.d.ts.map +1 -0
  354. package/lib/typescript/src/games/car-racing/CarRacingService.d.ts +22 -0
  355. package/lib/typescript/src/games/car-racing/CarRacingService.d.ts.map +1 -0
  356. package/lib/typescript/src/games/car-racing/CarRacingStore.d.ts +72 -0
  357. package/lib/typescript/src/games/car-racing/CarRacingStore.d.ts.map +1 -0
  358. package/lib/typescript/src/games/car-racing/components/CarComponent.d.ts +13 -0
  359. package/lib/typescript/src/games/car-racing/components/CarComponent.d.ts.map +1 -0
  360. package/lib/typescript/src/games/car-racing/components/GameBackground.d.ts +9 -0
  361. package/lib/typescript/src/games/car-racing/components/GameBackground.d.ts.map +1 -0
  362. package/lib/typescript/src/games/car-racing/components/ScoreBoard.d.ts +7 -0
  363. package/lib/typescript/src/games/car-racing/components/ScoreBoard.d.ts.map +1 -0
  364. package/lib/typescript/src/games/car-racing/components/index.d.ts +4 -0
  365. package/lib/typescript/src/games/car-racing/components/index.d.ts.map +1 -0
  366. package/lib/typescript/src/games/colors-sort/ColorsSort.d.ts.map +1 -1
  367. package/lib/typescript/src/games/colors-sort/ColorsSortStore.d.ts.map +1 -1
  368. package/lib/typescript/src/games/dino-jump/DinoJump.d.ts.map +1 -1
  369. package/lib/typescript/src/games/dino-jump/components/DinoSprite.d.ts.map +1 -1
  370. package/lib/typescript/src/games/flappy-bird/FlappyBird.d.ts.map +1 -1
  371. package/lib/typescript/src/games/flappy-bird/FlappyBirdConstants.d.ts.map +1 -1
  372. package/lib/typescript/src/games/fruit-merger/FruitMerger.d.ts.map +1 -1
  373. package/lib/typescript/src/games/fruit-merger/FruitMergerConstants.d.ts.map +1 -1
  374. package/lib/typescript/src/games/fruit-ninja/FruitNinja.d.ts.map +1 -1
  375. package/lib/typescript/src/games/fruit-ninja/components/ScoreBoard.d.ts.map +1 -1
  376. package/lib/typescript/src/games/game-2048/Game2048.d.ts.map +1 -1
  377. package/lib/typescript/src/games/maze-runner/MazeRunner.d.ts.map +1 -1
  378. package/lib/typescript/src/games/perfect-circle/PerfectCircle.d.ts +4 -0
  379. package/lib/typescript/src/games/perfect-circle/PerfectCircle.d.ts.map +1 -0
  380. package/lib/typescript/src/games/perfect-circle/PerfectCircleConstants.d.ts +81 -0
  381. package/lib/typescript/src/games/perfect-circle/PerfectCircleConstants.d.ts.map +1 -0
  382. package/lib/typescript/src/games/perfect-circle/PerfectCircleService.d.ts +14 -0
  383. package/lib/typescript/src/games/perfect-circle/PerfectCircleService.d.ts.map +1 -0
  384. package/lib/typescript/src/games/perfect-circle/PerfectCircleStore.d.ts +40 -0
  385. package/lib/typescript/src/games/perfect-circle/PerfectCircleStore.d.ts.map +1 -0
  386. package/lib/typescript/src/games/perfect-circle/components/DrawingCanvas.d.ts +9 -0
  387. package/lib/typescript/src/games/perfect-circle/components/DrawingCanvas.d.ts.map +1 -0
  388. package/lib/typescript/src/games/perfect-circle/components/GameBackground.d.ts +8 -0
  389. package/lib/typescript/src/games/perfect-circle/components/GameBackground.d.ts.map +1 -0
  390. package/lib/typescript/src/games/perfect-circle/components/ScoreBoard.d.ts +7 -0
  391. package/lib/typescript/src/games/perfect-circle/components/ScoreBoard.d.ts.map +1 -0
  392. package/lib/typescript/src/games/perfect-circle/index.d.ts +3 -0
  393. package/lib/typescript/src/games/perfect-circle/index.d.ts.map +1 -0
  394. package/lib/typescript/src/games/popit-fidget/PopitFidget.d.ts.map +1 -1
  395. package/lib/typescript/src/games/sliding-numbers/SlidingNumbers.d.ts.map +1 -1
  396. package/lib/typescript/src/games/snake/Snake.d.ts.map +1 -1
  397. package/lib/typescript/src/games/snake/SnakeStore.d.ts +4 -0
  398. package/lib/typescript/src/games/snake/SnakeStore.d.ts.map +1 -1
  399. package/lib/typescript/src/games/snake/components/ScoreBoard.d.ts.map +1 -1
  400. package/lib/typescript/src/games/space-fighter/SpaceFighter.d.ts.map +1 -1
  401. package/lib/typescript/src/games/whack-a-mole/WhackAMole.d.ts.map +1 -1
  402. package/lib/typescript/src/games/whack-a-mole/WhackAMoleConstants.d.ts +1 -1
  403. package/lib/typescript/src/games/whack-a-mole/components/ScoreBoard.d.ts.map +1 -1
  404. package/lib/typescript/src/helpers/GameOverModal.d.ts +3 -0
  405. package/lib/typescript/src/helpers/GameOverModal.d.ts.map +1 -1
  406. package/lib/typescript/src/helpers/ScoreBoardContainer.d.ts.map +1 -1
  407. package/lib/typescript/src/index.d.ts +6 -1
  408. package/lib/typescript/src/index.d.ts.map +1 -1
  409. package/lib/typescript/src/services/GamesConstants.d.ts +57 -7
  410. package/lib/typescript/src/services/GamesConstants.d.ts.map +1 -1
  411. package/lib/typescript/src/services/GamesService.d.ts +2 -1
  412. package/lib/typescript/src/services/GamesService.d.ts.map +1 -1
  413. package/lib/typescript/src/services/ScoringService.d.ts +2 -0
  414. package/lib/typescript/src/services/ScoringService.d.ts.map +1 -0
  415. package/lib/typescript/src/services/SoundsService.d.ts +88 -0
  416. package/lib/typescript/src/services/SoundsService.d.ts.map +1 -1
  417. package/lib/typescript/src/services/UtilsService.d.ts +12 -1
  418. package/lib/typescript/src/services/UtilsService.d.ts.map +1 -1
  419. package/package.json +2 -2
@@ -1,120 +1 @@
1
- "use strict";
2
-
3
- import { useEffect, useRef } from 'react';
4
-
5
- /**
6
- * Optimized animation frame utility for smooth game object cleanup and updates
7
- * Uses requestAnimationFrame instead of setInterval for better performance
8
- */
9
- export class AnimationFrameManager {
10
- animationId = null;
11
- isRunning = false;
12
- lastTime = 0;
13
- constructor(callback, interval = 100) {
14
- this.callback = callback;
15
- this.interval = interval;
16
- }
17
-
18
- /**
19
- * Start the animation frame loop
20
- */
21
- start() {
22
- if (this.isRunning) return;
23
- this.isRunning = true;
24
- this.lastTime = performance.now();
25
- this.loop();
26
- }
27
-
28
- /**
29
- * Stop the animation frame loop
30
- */
31
- stop() {
32
- if (this.animationId) {
33
- cancelAnimationFrame(this.animationId);
34
- this.animationId = null;
35
- }
36
- this.isRunning = false;
37
- }
38
-
39
- /**
40
- * Internal animation frame loop
41
- */
42
- loop = () => {
43
- if (!this.isRunning) return;
44
- const currentTime = performance.now();
45
- const deltaTime = currentTime - this.lastTime;
46
- if (deltaTime >= this.interval) {
47
- this.callback();
48
- this.lastTime = currentTime;
49
- }
50
- this.animationId = requestAnimationFrame(this.loop);
51
- };
52
-
53
- /**
54
- * Update the callback function
55
- */
56
- updateCallback(callback) {
57
- this.callback = callback;
58
- }
59
-
60
- /**
61
- * Update the interval
62
- */
63
- updateInterval(interval) {
64
- this.interval = interval;
65
- }
66
- }
67
-
68
- /**
69
- * React hook for using optimized animation frame cleanup
70
- */
71
- export function useAnimationFrame(callback, interval = 100, dependencies = []) {
72
- const managerRef = useRef(null);
73
- useEffect(() => {
74
- // Create or update the manager
75
- if (!managerRef.current) {
76
- managerRef.current = new AnimationFrameManager(callback, interval);
77
- } else {
78
- managerRef.current.updateCallback(callback);
79
- managerRef.current.updateInterval(interval);
80
- }
81
-
82
- // Start the animation frame loop
83
- managerRef.current.start();
84
-
85
- // Cleanup on unmount or dependency change
86
- return () => {
87
- if (managerRef.current) {
88
- managerRef.current.stop();
89
- }
90
- };
91
- }, dependencies);
92
-
93
- // Cleanup on unmount
94
- useEffect(() => {
95
- return () => {
96
- if (managerRef.current) {
97
- managerRef.current.stop();
98
- }
99
- };
100
- }, []);
101
- }
102
-
103
- /**
104
- * React hook for creating a reusable animation frame manager
105
- */
106
- export function useAnimationFrameManager(interval = 100) {
107
- const managerRef = useRef(null);
108
- if (!managerRef.current) {
109
- managerRef.current = new AnimationFrameManager(() => {}, interval);
110
- }
111
- useEffect(() => {
112
- return () => {
113
- if (managerRef.current) {
114
- managerRef.current.stop();
115
- }
116
- };
117
- }, []);
118
- return managerRef.current;
119
- }
120
- //# sourceMappingURL=AnimationFrame.js.map
1
+ "use strict";import{useEffect,useRef}from 'react';export class AnimationFrameManager{animationId = null;isRunning = false;lastTime = 0;constructor(callback,interval = 100){this.callback = callback;this.interval = interval;}start(){if(this.isRunning)return;this.isRunning = true;this.lastTime = performance.now();this.loop();}stop(){if(this.animationId){cancelAnimationFrame(this.animationId);this.animationId = null;}this.isRunning = false;}loop =()=>{if(!this.isRunning)return;const currentTime = performance.now();const deltaTime = currentTime - this.lastTime;if(deltaTime >= this.interval){this.callback();this.lastTime = currentTime;}this.animationId = requestAnimationFrame(this.loop);};updateCallback(callback){this.callback = callback;}updateInterval(interval){this.interval = interval;}}export function useAnimationFrame(callback,interval = 100,dependencies = []){const managerRef = useRef(null);useEffect(()=>{if(!managerRef.current){managerRef.current = new AnimationFrameManager(callback,interval);}else{managerRef.current.updateCallback(callback);managerRef.current.updateInterval(interval);}managerRef.current.start();return()=>{if(managerRef.current){managerRef.current.stop();}};},dependencies);useEffect(()=>{return()=>{if(managerRef.current){managerRef.current.stop();}};},[]);}export function useAnimationFrameManager(interval = 100){const managerRef = useRef(null);if(!managerRef.current){managerRef.current = new AnimationFrameManager(()=>{},interval);}useEffect(()=>{return()=>{if(managerRef.current){managerRef.current.stop();}};},[]);return managerRef.current;}
@@ -1,89 +1 @@
1
- "use strict";
2
-
3
- import { useRef } from 'react';
4
-
5
- /**
6
- * Animation state interface for tracking game object animations
7
- */
8
-
9
- /**
10
- * Default animation state values
11
- */
12
- export const DEFAULT_ANIMATION_STATE = {
13
- scale: 1,
14
- opacity: 1,
15
- rotation: 0,
16
- translateX: 0,
17
- translateY: 0
18
- };
19
-
20
- /**
21
- * Animation tracker class for managing game object animations
22
- * Extends Map to maintain compatibility with existing game services
23
- */
24
- export class AnimationTracker extends Map {
25
- constructor() {
26
- super();
27
- }
28
-
29
- /**
30
- * Override set to merge with default animation state
31
- */
32
- set(id, state) {
33
- const currentState = super.get(id) || {
34
- ...DEFAULT_ANIMATION_STATE
35
- };
36
- const newState = {
37
- ...currentState,
38
- ...state
39
- };
40
- super.set(id, newState);
41
- return this;
42
- }
43
-
44
- /**
45
- * Initialize animation for object if it doesn't exist
46
- */
47
- initialize(id, initialState) {
48
- if (!this.has(id)) {
49
- const state = {
50
- ...DEFAULT_ANIMATION_STATE,
51
- ...initialState
52
- };
53
- super.set(id, state);
54
- return state;
55
- }
56
- return this.get(id);
57
- }
58
-
59
- /**
60
- * Update multiple objects at once
61
- */
62
- updateBatch(updates) {
63
- updates.forEach(({
64
- id,
65
- state
66
- }) => {
67
- this.set(id, state);
68
- });
69
- }
70
- }
71
-
72
- /**
73
- * React hook for creating and managing animation trackers
74
- */
75
- export function useAnimationTracker() {
76
- return useRef(new AnimationTracker()).current;
77
- }
78
-
79
- /**
80
- * React hook for creating multiple animation trackers
81
- */
82
- export function useAnimationTrackers(trackerNames) {
83
- const trackers = useRef(trackerNames.reduce((acc, name) => {
84
- acc[name] = new AnimationTracker();
85
- return acc;
86
- }, {})).current;
87
- return trackers;
88
- }
89
- //# sourceMappingURL=AnimationTracker.js.map
1
+ "use strict";import{useRef}from 'react';export const DEFAULT_ANIMATION_STATE ={scale:1,opacity:1,rotation:0,translateX:0,translateY:0};export class AnimationTracker extends Map{constructor(){super();}set(id,state){const currentState = super.get(id)||{...DEFAULT_ANIMATION_STATE};const newState ={...currentState,...state};super.set(id,newState);return this;}initialize(id,initialState){if(!this.has(id)){const state ={...DEFAULT_ANIMATION_STATE,...initialState};super.set(id,state);return state;}return this.get(id);}updateBatch(updates){updates.forEach(({id,state})=>{this.set(id,state);});}}export function useAnimationTracker(){return useRef(new AnimationTracker()).current;}export function useAnimationTrackers(trackerNames){const trackers = useRef(trackerNames.reduce((acc,name)=>{acc[name] = new AnimationTracker();return acc;},{})).current;return trackers;}
@@ -1,269 +1 @@
1
- "use strict";
2
-
3
- import { useCallback, useRef } from 'react';
4
-
5
- /**
6
- * Error types for game-specific error handling
7
- */
8
- export let GameErrorType = /*#__PURE__*/function (GameErrorType) {
9
- GameErrorType["INITIALIZATION_ERROR"] = "INITIALIZATION_ERROR";
10
- GameErrorType["ANIMATION_ERROR"] = "ANIMATION_ERROR";
11
- GameErrorType["STORAGE_ERROR"] = "STORAGE_ERROR";
12
- GameErrorType["SOUND_ERROR"] = "SOUND_ERROR";
13
- GameErrorType["HAPTIC_ERROR"] = "HAPTIC_ERROR";
14
- GameErrorType["GESTURE_ERROR"] = "GESTURE_ERROR";
15
- GameErrorType["PERFORMANCE_ERROR"] = "PERFORMANCE_ERROR";
16
- GameErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
17
- GameErrorType["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
18
- return GameErrorType;
19
- }({});
20
-
21
- /**
22
- * Game error interface
23
- */
24
-
25
- /**
26
- * Error handler configuration
27
- */
28
-
29
- /**
30
- * Default error handler configuration
31
- */
32
- export const DEFAULT_ERROR_CONFIG = {
33
- enableLogging: __DEV__,
34
- enableConsoleOutput: __DEV__,
35
- maxErrorHistory: 50,
36
- enableCrashRecovery: true
37
- };
38
-
39
- /**
40
- * Game error handler class
41
- */
42
- export class GameErrorHandler {
43
- errorHistory = [];
44
- errorCounts = new Map();
45
- constructor(config = {}) {
46
- this.config = {
47
- ...DEFAULT_ERROR_CONFIG,
48
- ...config
49
- };
50
- }
51
-
52
- /**
53
- * Handle a game error
54
- */
55
- handleError(type, message, gameId, context) {
56
- const error = {
57
- type,
58
- message,
59
- gameId,
60
- timestamp: Date.now(),
61
- stack: new Error().stack,
62
- context
63
- };
64
-
65
- // Add to error history
66
- this.errorHistory.push(error);
67
- if (this.errorHistory.length > this.config.maxErrorHistory) {
68
- this.errorHistory.shift();
69
- }
70
-
71
- // Update error counts
72
- const currentCount = this.errorCounts.get(type) || 0;
73
- this.errorCounts.set(type, currentCount + 1);
74
-
75
- // Log error if enabled
76
- if (this.config.enableLogging && this.config.enableConsoleOutput) {
77
- this.logError(error);
78
- }
79
-
80
- // Call custom error handler if provided
81
- if (this.config.onError) {
82
- try {
83
- this.config.onError(error);
84
- } catch (handlerError) {
85
- console.error('Error in custom error handler:', handlerError);
86
- }
87
- }
88
- }
89
-
90
- /**
91
- * Wrap a function with error handling
92
- */
93
- wrapFunction(fn, errorType, gameId) {
94
- return (...args) => {
95
- try {
96
- const result = fn(...args);
97
-
98
- // Handle async functions
99
- if (result && typeof result.catch === 'function') {
100
- return result.catch(error => {
101
- this.handleError(errorType, error.message || 'Async function error', gameId, {
102
- functionName: fn.name,
103
- args
104
- });
105
- throw error;
106
- });
107
- }
108
- return result;
109
- } catch (error) {
110
- this.handleError(errorType, error instanceof Error ? error.message : 'Unknown error', gameId, {
111
- functionName: fn.name,
112
- args
113
- });
114
- throw error;
115
- }
116
- };
117
- }
118
-
119
- /**
120
- * Safe execution with error recovery
121
- */
122
- safeExecute(fn, fallback, errorType, gameId) {
123
- try {
124
- return fn();
125
- } catch (error) {
126
- this.handleError(errorType, error instanceof Error ? error.message : 'Safe execution failed', gameId, {
127
- fallback
128
- });
129
- return fallback;
130
- }
131
- }
132
-
133
- /**
134
- * Safe async execution with error recovery
135
- */
136
- async safeExecuteAsync(fn, fallback, errorType, gameId) {
137
- try {
138
- return await fn();
139
- } catch (error) {
140
- this.handleError(errorType, error instanceof Error ? error.message : 'Safe async execution failed', gameId, {
141
- fallback
142
- });
143
- return fallback;
144
- }
145
- }
146
-
147
- /**
148
- * Get error statistics
149
- */
150
- getErrorStats() {
151
- const errorsByType = {};
152
- for (const [type, count] of this.errorCounts.entries()) {
153
- errorsByType[type] = count;
154
- }
155
- return {
156
- totalErrors: this.errorHistory.length,
157
- errorsByType,
158
- recentErrors: this.errorHistory.slice(-10)
159
- };
160
- }
161
-
162
- /**
163
- * Clear error history
164
- */
165
- clearHistory() {
166
- this.errorHistory = [];
167
- this.errorCounts.clear();
168
- }
169
-
170
- /**
171
- * Update configuration
172
- */
173
- updateConfig(config) {
174
- this.config = {
175
- ...this.config,
176
- ...config
177
- };
178
- }
179
-
180
- /**
181
- * Log error to console
182
- */
183
- logError(error) {
184
- const prefix = error.gameId ? `[${error.gameId}]` : '[Game]';
185
- console.error(`${prefix} ${error.type}: ${error.message}`, {
186
- timestamp: new Date(error.timestamp).toISOString(),
187
- context: error.context,
188
- stack: error.stack
189
- });
190
- }
191
- }
192
-
193
- /**
194
- * Global error handler instance
195
- */
196
- export const globalErrorHandler = new GameErrorHandler();
197
-
198
- /**
199
- * React hook for error handling in game components
200
- */
201
- export function useGameErrorHandler(gameId, config = {}) {
202
- const handlerRef = useRef(null);
203
-
204
- // Initialize handler
205
- if (!handlerRef.current) {
206
- handlerRef.current = new GameErrorHandler(config);
207
- }
208
- const handleError = useCallback((type, message, context) => {
209
- handlerRef.current?.handleError(type, message, gameId, context);
210
- }, [gameId]);
211
- const wrapFunction = useCallback((fn, errorType) => {
212
- return handlerRef.current?.wrapFunction(fn, errorType, gameId) || fn;
213
- }, [gameId]);
214
- const safeExecute = useCallback((fn, fallback, errorType) => {
215
- return handlerRef.current?.safeExecute(fn, fallback, errorType, gameId) || fallback;
216
- }, [gameId]);
217
- const safeExecuteAsync = useCallback((fn, fallback, errorType) => {
218
- return handlerRef.current?.safeExecuteAsync(fn, fallback, errorType, gameId) || Promise.resolve(fallback);
219
- }, [gameId]);
220
- return {
221
- handleError,
222
- wrapFunction,
223
- safeExecute,
224
- safeExecuteAsync,
225
- errorStats: handlerRef.current?.getErrorStats() || {
226
- totalErrors: 0,
227
- errorsByType: {},
228
- recentErrors: []
229
- }
230
- };
231
- }
232
-
233
- /**
234
- * Error boundary utility for wrapping functions with error handling
235
- */
236
- export function withErrorHandling(fn, gameId, errorType = GameErrorType.UNKNOWN_ERROR) {
237
- return globalErrorHandler.wrapFunction(fn, errorType, gameId);
238
- }
239
-
240
- /**
241
- * Utility functions for common error scenarios
242
- */
243
- export const ErrorUtils = {
244
- /**
245
- * Handle animation errors safely
246
- */
247
- safeAnimate: (animationFn, gameId, fallback) => {
248
- globalErrorHandler.safeExecute(animationFn, fallback ? fallback() : undefined, GameErrorType.ANIMATION_ERROR, gameId);
249
- },
250
- /**
251
- * Handle sound errors safely
252
- */
253
- safePlaySound: (soundFn, gameId) => {
254
- globalErrorHandler.safeExecute(soundFn, undefined, GameErrorType.SOUND_ERROR, gameId);
255
- },
256
- /**
257
- * Handle haptic errors safely
258
- */
259
- safeHaptic: (hapticFn, gameId) => {
260
- globalErrorHandler.safeExecute(hapticFn, undefined, GameErrorType.HAPTIC_ERROR, gameId);
261
- },
262
- /**
263
- * Handle gesture errors safely
264
- */
265
- safeGesture: (gestureFn, gameId) => {
266
- globalErrorHandler.safeExecute(gestureFn, undefined, GameErrorType.GESTURE_ERROR, gameId);
267
- }
268
- };
269
- //# sourceMappingURL=ErrorHandler.js.map
1
+ "use strict";import{useCallback,useRef}from 'react';export let GameErrorType = function(GameErrorType){GameErrorType["INITIALIZATION_ERROR"] = "INITIALIZATION_ERROR";GameErrorType["ANIMATION_ERROR"] = "ANIMATION_ERROR";GameErrorType["STORAGE_ERROR"] = "STORAGE_ERROR";GameErrorType["SOUND_ERROR"] = "SOUND_ERROR";GameErrorType["HAPTIC_ERROR"] = "HAPTIC_ERROR";GameErrorType["GESTURE_ERROR"] = "GESTURE_ERROR";GameErrorType["PERFORMANCE_ERROR"] = "PERFORMANCE_ERROR";GameErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";GameErrorType["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";return GameErrorType;}({});export const DEFAULT_ERROR_CONFIG ={enableLogging:__DEV__,enableConsoleOutput:__DEV__,maxErrorHistory:50,enableCrashRecovery:true};export class GameErrorHandler{errorHistory = [];errorCounts = new Map();constructor(config ={}){this.config ={...DEFAULT_ERROR_CONFIG,...config};}handleError(type,message,gameId,context){const error ={type,message,gameId,timestamp:Date.now(),stack:new Error().stack,context};this.errorHistory.push(error);if(this.errorHistory.length > this.config.maxErrorHistory){this.errorHistory.shift();}const currentCount = this.errorCounts.get(type)|| 0;this.errorCounts.set(type,currentCount + 1);if(this.config.enableLogging && this.config.enableConsoleOutput){this.logError(error);}if(this.config.onError){try{this.config.onError(error);}catch(handlerError){console.error('Error in custom error handler:',handlerError);}}}wrapFunction(fn,errorType,gameId){return(...args)=>{try{const result = fn(...args);if(result && typeof result.catch === 'function'){return result.catch(error =>{this.handleError(errorType,error.message || 'Async function error',gameId,{functionName:fn.name,args});throw error;});}return result;}catch(error){this.handleError(errorType,error instanceof Error ? error.message:'Unknown error',gameId,{functionName:fn.name,args});throw error;}};}safeExecute(fn,fallback,errorType,gameId){try{return fn();}catch(error){this.handleError(errorType,error instanceof Error ? error.message:'Safe execution failed',gameId,{fallback});return fallback;}}async safeExecuteAsync(fn,fallback,errorType,gameId){try{return await fn();}catch(error){this.handleError(errorType,error instanceof Error ? error.message:'Safe async execution failed',gameId,{fallback});return fallback;}}getErrorStats(){const errorsByType ={};for(const [type,count] of this.errorCounts.entries()){errorsByType[type] = count;}return{totalErrors:this.errorHistory.length,errorsByType,recentErrors:this.errorHistory.slice(-10)};}clearHistory(){this.errorHistory = [];this.errorCounts.clear();}updateConfig(config){this.config ={...this.config,...config};}logError(error){const prefix = error.gameId ? `[${error.gameId}]`:'[Game]';console.error(`${prefix}${error.type}:${error.message}`,{timestamp:new Date(error.timestamp).toISOString(),context:error.context,stack:error.stack});}}export const globalErrorHandler = new GameErrorHandler();export function useGameErrorHandler(gameId,config ={}){const handlerRef = useRef(null);if(!handlerRef.current){handlerRef.current = new GameErrorHandler(config);}const handleError = useCallback((type,message,context)=>{handlerRef.current?.handleError(type,message,gameId,context);},[gameId]);const wrapFunction = useCallback((fn,errorType)=>{return handlerRef.current?.wrapFunction(fn,errorType,gameId)|| fn;},[gameId]);const safeExecute = useCallback((fn,fallback,errorType)=>{return handlerRef.current?.safeExecute(fn,fallback,errorType,gameId)|| fallback;},[gameId]);const safeExecuteAsync = useCallback((fn,fallback,errorType)=>{return handlerRef.current?.safeExecuteAsync(fn,fallback,errorType,gameId)|| Promise.resolve(fallback);},[gameId]);return{handleError,wrapFunction,safeExecute,safeExecuteAsync,errorStats:handlerRef.current?.getErrorStats()||{totalErrors:0,errorsByType:{},recentErrors:[]}};}export function withErrorHandling(fn,gameId,errorType = GameErrorType.UNKNOWN_ERROR){return globalErrorHandler.wrapFunction(fn,errorType,gameId);}export const ErrorUtils ={safeAnimate:(animationFn,gameId,fallback)=>{globalErrorHandler.safeExecute(animationFn,fallback ? fallback():undefined,GameErrorType.ANIMATION_ERROR,gameId);},safePlaySound:(soundFn,gameId)=>{globalErrorHandler.safeExecute(soundFn,undefined,GameErrorType.SOUND_ERROR,gameId);},safeHaptic:(hapticFn,gameId)=>{globalErrorHandler.safeExecute(hapticFn,undefined,GameErrorType.HAPTIC_ERROR,gameId);},safeGesture:(gestureFn,gameId)=>{globalErrorHandler.safeExecute(gestureFn,undefined,GameErrorType.GESTURE_ERROR,gameId);}};