react-native-games 1.1.0 → 1.2.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 +58 -7
- package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -167
- package/lib/module/games/balloon-blaster/BalloonBlaster.js.map +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js +1 -182
- package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js.map +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterService.js +1 -318
- package/lib/module/games/balloon-blaster/BalloonBlasterStore.js +1 -183
- package/lib/module/games/balloon-blaster/components/BalloonComponent.js +1 -237
- package/lib/module/games/balloon-blaster/components/GameArea.js +1 -156
- package/lib/module/games/balloon-blaster/components/GameBackground.js +1 -476
- package/lib/module/games/balloon-blaster/components/ScoreBoard.js +1 -112
- package/lib/module/games/balloon-blaster/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/balloon-blaster/components/index.js +1 -7
- package/lib/module/games/candy-crush/CandyCrush.js +1 -131
- package/lib/module/games/candy-crush/CandyCrush.js.map +1 -1
- package/lib/module/games/candy-crush/CandyCrushConstants.js +1 -125
- package/lib/module/games/candy-crush/CandyCrushConstants.js.map +1 -1
- package/lib/module/games/candy-crush/CandyCrushService.js +1 -370
- package/lib/module/games/candy-crush/CandyCrushStore.js +1 -303
- package/lib/module/games/candy-crush/components/CandyItem.js +1 -191
- package/lib/module/games/candy-crush/components/GameBackground.js +1 -85
- package/lib/module/games/candy-crush/components/GameGrid.js +1 -314
- package/lib/module/games/candy-crush/components/ScoreBoard.js +1 -79
- package/lib/module/games/candy-crush/components/index.js +1 -7
- package/lib/module/games/candy-crush/index.js +1 -6
- package/lib/module/games/colors-sort/ColorsSort.js +1 -143
- package/lib/module/games/colors-sort/ColorsSort.js.map +1 -1
- package/lib/module/games/colors-sort/ColorsSortConstants.js +1 -72
- package/lib/module/games/colors-sort/ColorsSortConstants.js.map +1 -1
- package/lib/module/games/colors-sort/ColorsSortService.js +1 -255
- package/lib/module/games/colors-sort/ColorsSortStore.js +1 -257
- package/lib/module/games/colors-sort/ColorsSortStore.js.map +1 -1
- package/lib/module/games/colors-sort/components/ColorContainer.js +1 -140
- package/lib/module/games/colors-sort/components/GameBackground.js +1 -135
- package/lib/module/games/colors-sort/components/ScoreBoard.js +1 -70
- package/lib/module/games/colors-sort/components/index.js +1 -6
- package/lib/module/games/dino-jump/DinoJump.js +1 -209
- package/lib/module/games/dino-jump/DinoJump.js.map +1 -1
- package/lib/module/games/dino-jump/DinoJumpConstants.js +1 -189
- package/lib/module/games/dino-jump/DinoJumpConstants.js.map +1 -1
- package/lib/module/games/dino-jump/DinoJumpService.js +1 -270
- package/lib/module/games/dino-jump/DinoJumpStore.js +1 -381
- package/lib/module/games/dino-jump/components/DinoSprite.js +1 -418
- package/lib/module/games/dino-jump/components/DinoSprite.js.map +1 -1
- package/lib/module/games/dino-jump/components/GameArea.js +1 -68
- package/lib/module/games/dino-jump/components/GameBackground.js +1 -444
- package/lib/module/games/dino-jump/components/ObstacleSprite.js +1 -306
- package/lib/module/games/dino-jump/components/ScoreBoard.js +1 -105
- package/lib/module/games/dino-jump/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/dino-jump/components/StarSprite.js +1 -45
- package/lib/module/games/dino-jump/components/index.js +1 -9
- package/lib/module/games/flappy-bird/FlappyBird.js +1 -126
- package/lib/module/games/flappy-bird/FlappyBird.js.map +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js +1 -90
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js.map +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdStore.js +1 -300
- package/lib/module/games/flappy-bird/components/Bird.js +1 -87
- package/lib/module/games/flappy-bird/components/GameArea.js +1 -87
- package/lib/module/games/flappy-bird/components/GameBackground.js +1 -79
- package/lib/module/games/flappy-bird/components/Pipes.js +1 -172
- package/lib/module/games/flappy-bird/components/ScoreBoard.js +1 -73
- package/lib/module/games/flappy-bird/components/index.js +1 -8
- package/lib/module/games/fruit-merger/FruitMerger.js +1 -120
- package/lib/module/games/fruit-merger/FruitMerger.js.map +1 -1
- package/lib/module/games/fruit-merger/FruitMergerConstants.js +1 -119
- package/lib/module/games/fruit-merger/FruitMergerConstants.js.map +1 -1
- package/lib/module/games/fruit-merger/FruitMergerService.js +1 -13
- package/lib/module/games/fruit-merger/FruitMergerStore.js +1 -315
- package/lib/module/games/fruit-merger/components/FruitItem.js +1 -102
- package/lib/module/games/fruit-merger/components/GameArea.js +1 -103
- package/lib/module/games/fruit-merger/components/GameBackground.js +1 -498
- package/lib/module/games/fruit-merger/components/ScoreBoard.js +1 -58
- package/lib/module/games/fruit-merger/components/index.js +1 -7
- package/lib/module/games/fruit-ninja/FruitNinja.js +1 -134
- package/lib/module/games/fruit-ninja/FruitNinja.js.map +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaConstants.js +1 -148
- package/lib/module/games/fruit-ninja/FruitNinjaConstants.js.map +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaService.js +1 -311
- package/lib/module/games/fruit-ninja/FruitNinjaStore.js +1 -191
- package/lib/module/games/fruit-ninja/FruitNinjaStore.js.map +1 -1
- package/lib/module/games/fruit-ninja/components/FruitComponent.js +1 -99
- package/lib/module/games/fruit-ninja/components/GameArea.js +1 -215
- package/lib/module/games/fruit-ninja/components/GameBackground.js +1 -1267
- package/lib/module/games/fruit-ninja/components/ScoreBoard.js +1 -92
- package/lib/module/games/fruit-ninja/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/fruit-ninja/components/index.js +1 -7
- package/lib/module/games/game-2048/Game2048.js +1 -149
- package/lib/module/games/game-2048/Game2048.js.map +1 -1
- package/lib/module/games/game-2048/Game2048Constants.js +1 -263
- package/lib/module/games/game-2048/Game2048Constants.js.map +1 -1
- package/lib/module/games/game-2048/Game2048Service.js +1 -457
- package/lib/module/games/game-2048/Game2048Store.js +1 -236
- package/lib/module/games/game-2048/components/GameBackground.js +1 -247
- package/lib/module/games/game-2048/components/GameGrid.js +1 -139
- package/lib/module/games/game-2048/components/GameTile.js +1 -72
- package/lib/module/games/game-2048/components/ScoreBoard.js +1 -52
- package/lib/module/games/game-2048/components/index.js +1 -7
- package/lib/module/games/maze-runner/MazeRunner.js +1 -267
- package/lib/module/games/maze-runner/MazeRunner.js.map +1 -1
- package/lib/module/games/maze-runner/MazeRunnerConstants.js +1 -100
- package/lib/module/games/maze-runner/MazeRunnerConstants.js.map +1 -1
- package/lib/module/games/maze-runner/MazeRunnerService.js +1 -586
- package/lib/module/games/maze-runner/components/EnhancedBallComponent.js +1 -150
- package/lib/module/games/maze-runner/components/EnhancedGameArea.js +1 -370
- package/lib/module/games/maze-runner/components/GameBackground.js +1 -175
- package/lib/module/games/maze-runner/components/ScoreBoard.js +1 -61
- package/lib/module/games/maze-runner/components/SkiaPipeComponent.js +1 -209
- package/lib/module/games/maze-runner/components/StaticGameBackground.js +1 -169
- package/lib/module/games/maze-runner/components/WallComponent.js +1 -91
- package/lib/module/games/maze-runner/components/index.js +1 -8
- package/lib/module/games/popit-fidget/PopitFidget.js +1 -285
- package/lib/module/games/popit-fidget/PopitFidget.js.map +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetConstants.js +1 -113
- package/lib/module/games/popit-fidget/PopitFidgetConstants.js.map +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetService.js +1 -132
- package/lib/module/games/popit-fidget/PopitFidgetStore.js +1 -125
- package/lib/module/games/popit-fidget/components/BubbleComponent.js +1 -198
- package/lib/module/games/popit-fidget/components/FidgetGrid.js +1 -165
- package/lib/module/games/popit-fidget/components/GameBackground.js +1 -177
- package/lib/module/games/popit-fidget/components/ScoreBoard.js +1 -61
- package/lib/module/games/popit-fidget/components/index.js +1 -7
- package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -159
- package/lib/module/games/sliding-numbers/SlidingNumbers.js.map +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js +1 -207
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js.map +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersService.js +1 -248
- package/lib/module/games/sliding-numbers/SlidingNumbersStore.js +1 -274
- package/lib/module/games/sliding-numbers/components/GameBackground.js +1 -259
- package/lib/module/games/sliding-numbers/components/NumbersGrid.js +1 -174
- package/lib/module/games/sliding-numbers/components/NumbersTile.js +1 -116
- package/lib/module/games/sliding-numbers/components/ScoreBoard.js +1 -64
- package/lib/module/games/sliding-numbers/components/index.js +1 -7
- package/lib/module/games/snake/Snake.js +1 -189
- package/lib/module/games/snake/Snake.js.map +1 -1
- package/lib/module/games/snake/SnakeConstants.js +1 -138
- package/lib/module/games/snake/SnakeConstants.js.map +1 -1
- package/lib/module/games/snake/SnakeService.js +1 -148
- package/lib/module/games/snake/SnakeStore.js +1 -182
- package/lib/module/games/snake/components/GameBackground.js +1 -221
- package/lib/module/games/snake/components/GameGrid.js +1 -153
- package/lib/module/games/snake/components/ScoreBoard.js +1 -51
- package/lib/module/games/snake/components/index.js +1 -6
- package/lib/module/games/snake/index.js +1 -6
- package/lib/module/games/space-fighter/SpaceFighter.js +1 -165
- package/lib/module/games/space-fighter/SpaceFighter.js.map +1 -1
- package/lib/module/games/space-fighter/SpaceFighterConstants.js +1 -108
- package/lib/module/games/space-fighter/SpaceFighterConstants.js.map +1 -1
- package/lib/module/games/space-fighter/SpaceFighterService.js +1 -326
- package/lib/module/games/space-fighter/SpaceFighterStore.js +1 -209
- package/lib/module/games/space-fighter/components/AsteroidComponent.js +1 -113
- package/lib/module/games/space-fighter/components/GameArea.js +1 -289
- package/lib/module/games/space-fighter/components/GameBackground.js +1 -239
- package/lib/module/games/space-fighter/components/ScoreBoard.js +1 -136
- package/lib/module/games/space-fighter/components/Spacecraft3D.js +1 -202
- package/lib/module/games/space-fighter/components/SpacecraftPath.js +1 -52
- package/lib/module/games/space-fighter/components/index.js +1 -9
- package/lib/module/games/whack-a-mole/WhackAMole.js +1 -270
- package/lib/module/games/whack-a-mole/WhackAMole.js.map +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleConstants.js +1 -115
- package/lib/module/games/whack-a-mole/WhackAMoleConstants.js.map +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleService.js +1 -120
- package/lib/module/games/whack-a-mole/WhackAMoleStore.js +1 -172
- package/lib/module/games/whack-a-mole/components/GameBackground.js +1 -477
- package/lib/module/games/whack-a-mole/components/GameGrid.js +1 -97
- package/lib/module/games/whack-a-mole/components/GameHole.js +1 -196
- package/lib/module/games/whack-a-mole/components/MoleCharacter.js +1 -241
- package/lib/module/games/whack-a-mole/components/ScoreBoard.js +1 -67
- package/lib/module/games/whack-a-mole/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/whack-a-mole/components/index.js +1 -8
- package/lib/module/helpers/AnimationFrame.js +1 -120
- package/lib/module/helpers/AnimationTracker.js +1 -89
- package/lib/module/helpers/ErrorHandler.js +1 -269
- package/lib/module/helpers/GameControlButton.js +1 -219
- package/lib/module/helpers/GameOverModal.js +1 -144
- package/lib/module/helpers/GameOverModal.js.map +1 -1
- package/lib/module/helpers/GameSettingsModal.js +1 -287
- package/lib/module/helpers/ParticleBlast.js +1 -134
- package/lib/module/helpers/ScoreBoardContainer.js +1 -34
- package/lib/module/helpers/index.js +1 -12
- package/lib/module/index.js +1 -22
- package/lib/module/services/GamesConstants.js +1 -178
- package/lib/module/services/GamesService.js +1 -112
- package/lib/module/services/GamesService.js.map +1 -1
- package/lib/module/services/HapticsService.js +1 -77
- package/lib/module/services/SoundsService.js +1 -302
- package/lib/module/services/UtilsService.js +1 -32
- package/lib/typescript/src/games/balloon-blaster/BalloonBlaster.d.ts.map +1 -1
- package/lib/typescript/src/games/balloon-blaster/BalloonBlasterConstants.d.ts +1 -1
- package/lib/typescript/src/games/balloon-blaster/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/games/candy-crush/CandyCrushConstants.d.ts +7 -7
- package/lib/typescript/src/games/colors-sort/ColorsSort.d.ts.map +1 -1
- package/lib/typescript/src/games/colors-sort/ColorsSortStore.d.ts.map +1 -1
- package/lib/typescript/src/games/dino-jump/DinoJump.d.ts.map +1 -1
- package/lib/typescript/src/games/dino-jump/components/DinoSprite.d.ts.map +1 -1
- package/lib/typescript/src/games/flappy-bird/FlappyBird.d.ts.map +1 -1
- package/lib/typescript/src/games/flappy-bird/FlappyBirdConstants.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-merger/FruitMerger.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-merger/FruitMergerConstants.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-ninja/FruitNinja.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-ninja/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/games/game-2048/Game2048.d.ts.map +1 -1
- package/lib/typescript/src/games/maze-runner/MazeRunner.d.ts.map +1 -1
- package/lib/typescript/src/games/popit-fidget/PopitFidget.d.ts.map +1 -1
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbers.d.ts.map +1 -1
- package/lib/typescript/src/games/space-fighter/SpaceFighter.d.ts.map +1 -1
- package/lib/typescript/src/games/whack-a-mole/WhackAMole.d.ts.map +1 -1
- package/lib/typescript/src/games/whack-a-mole/WhackAMoleConstants.d.ts +1 -1
- package/lib/typescript/src/games/whack-a-mole/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/helpers/GameOverModal.d.ts +3 -0
- package/lib/typescript/src/helpers/GameOverModal.d.ts.map +1 -1
- package/lib/typescript/src/services/GamesConstants.d.ts +7 -7
- package/package.json +2 -2
|
@@ -1,306 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { View, StyleSheet } from 'react-native';
|
|
5
|
-
import { useObstacles } from "../DinoJumpStore.js";
|
|
6
|
-
import { DINO_JUMP_COLORS } from "../DinoJumpConstants.js";
|
|
7
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
-
const SingleObstacle = /*#__PURE__*/React.memo(({
|
|
9
|
-
obstacle
|
|
10
|
-
}) => {
|
|
11
|
-
// Safety check
|
|
12
|
-
if (!obstacle || typeof obstacle.x !== 'number' || typeof obstacle.y !== 'number') {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Memoize render functions to avoid recreating on every render
|
|
17
|
-
const renderCactusSmall = React.useMemo(() => /*#__PURE__*/_jsxs(View, {
|
|
18
|
-
style: [styles.obstacleContainer, {
|
|
19
|
-
left: obstacle.x,
|
|
20
|
-
top: obstacle.y,
|
|
21
|
-
width: obstacle.width,
|
|
22
|
-
height: obstacle.height
|
|
23
|
-
}],
|
|
24
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
25
|
-
style: [styles.cactusBody, {
|
|
26
|
-
width: obstacle.width,
|
|
27
|
-
height: obstacle.height,
|
|
28
|
-
backgroundColor: DINO_JUMP_COLORS.OBSTACLE_PRIMARY
|
|
29
|
-
}]
|
|
30
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
31
|
-
style: [styles.cactusSpike, {
|
|
32
|
-
left: 2,
|
|
33
|
-
top: 6,
|
|
34
|
-
width: 3,
|
|
35
|
-
height: 3
|
|
36
|
-
}]
|
|
37
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
38
|
-
style: [styles.cactusSpike, {
|
|
39
|
-
right: 2,
|
|
40
|
-
top: 10,
|
|
41
|
-
width: 3,
|
|
42
|
-
height: 3
|
|
43
|
-
}]
|
|
44
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
45
|
-
style: [styles.cactusSpike, {
|
|
46
|
-
left: obstacle.width / 2 - 1,
|
|
47
|
-
top: 15,
|
|
48
|
-
width: 3,
|
|
49
|
-
height: 3
|
|
50
|
-
}]
|
|
51
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
52
|
-
style: [styles.cactusPlantedBase, {
|
|
53
|
-
left: obstacle.width / 4,
|
|
54
|
-
bottom: -6,
|
|
55
|
-
width: obstacle.width / 2,
|
|
56
|
-
height: 8,
|
|
57
|
-
backgroundColor: '#654321',
|
|
58
|
-
// Brown dirt color
|
|
59
|
-
borderRadius: 4
|
|
60
|
-
}]
|
|
61
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
62
|
-
style: [styles.cactusRoot, {
|
|
63
|
-
left: obstacle.width / 3,
|
|
64
|
-
bottom: -4,
|
|
65
|
-
width: obstacle.width / 3,
|
|
66
|
-
height: 4,
|
|
67
|
-
backgroundColor: DINO_JUMP_COLORS.OBSTACLE_PRIMARY
|
|
68
|
-
}]
|
|
69
|
-
})]
|
|
70
|
-
}), [obstacle.x, obstacle.y, obstacle.width, obstacle.height]);
|
|
71
|
-
const renderCactusLarge = React.useMemo(() => /*#__PURE__*/_jsxs(View, {
|
|
72
|
-
style: [styles.obstacleContainer, {
|
|
73
|
-
left: obstacle.x,
|
|
74
|
-
top: obstacle.y,
|
|
75
|
-
width: obstacle.width,
|
|
76
|
-
height: obstacle.height
|
|
77
|
-
}],
|
|
78
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
79
|
-
style: [styles.cactusBody, {
|
|
80
|
-
width: obstacle.width,
|
|
81
|
-
height: obstacle.height,
|
|
82
|
-
backgroundColor: DINO_JUMP_COLORS.OBSTACLE_PRIMARY
|
|
83
|
-
}]
|
|
84
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
85
|
-
style: [styles.cactusArm, {
|
|
86
|
-
left: -6,
|
|
87
|
-
top: 15,
|
|
88
|
-
width: 8,
|
|
89
|
-
height: 15,
|
|
90
|
-
backgroundColor: DINO_JUMP_COLORS.OBSTACLE_SECONDARY
|
|
91
|
-
}]
|
|
92
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
93
|
-
style: [styles.cactusArm, {
|
|
94
|
-
right: -2,
|
|
95
|
-
top: 10,
|
|
96
|
-
width: 8,
|
|
97
|
-
height: 20,
|
|
98
|
-
backgroundColor: DINO_JUMP_COLORS.OBSTACLE_SECONDARY
|
|
99
|
-
}]
|
|
100
|
-
}), Array.from({
|
|
101
|
-
length: 6
|
|
102
|
-
}, (_, i) => /*#__PURE__*/_jsx(View, {
|
|
103
|
-
style: [styles.cactusSpike, {
|
|
104
|
-
left: 2 + i % 3 * 7,
|
|
105
|
-
top: 8 + Math.floor(i / 3) * 15
|
|
106
|
-
}]
|
|
107
|
-
}, i)), /*#__PURE__*/_jsx(View, {
|
|
108
|
-
style: [styles.cactusPlantedBase, {
|
|
109
|
-
left: obstacle.width / 4,
|
|
110
|
-
bottom: -8,
|
|
111
|
-
width: obstacle.width / 2,
|
|
112
|
-
height: 10,
|
|
113
|
-
backgroundColor: '#654321',
|
|
114
|
-
// Brown dirt color
|
|
115
|
-
borderRadius: 5
|
|
116
|
-
}]
|
|
117
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
118
|
-
style: [styles.cactusRoot, {
|
|
119
|
-
left: obstacle.width / 3,
|
|
120
|
-
bottom: -5,
|
|
121
|
-
width: obstacle.width / 3,
|
|
122
|
-
height: 5,
|
|
123
|
-
backgroundColor: DINO_JUMP_COLORS.OBSTACLE_PRIMARY
|
|
124
|
-
}]
|
|
125
|
-
})]
|
|
126
|
-
}), [obstacle.x, obstacle.y, obstacle.width, obstacle.height]);
|
|
127
|
-
const renderBird = React.useMemo(() => /*#__PURE__*/_jsxs(View, {
|
|
128
|
-
style: [styles.obstacleContainer, {
|
|
129
|
-
left: obstacle.x,
|
|
130
|
-
top: obstacle.y,
|
|
131
|
-
width: obstacle.width,
|
|
132
|
-
height: obstacle.height
|
|
133
|
-
}],
|
|
134
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
135
|
-
style: [styles.birdBody, {
|
|
136
|
-
left: 10,
|
|
137
|
-
top: 15,
|
|
138
|
-
width: 20,
|
|
139
|
-
height: 10
|
|
140
|
-
}]
|
|
141
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
142
|
-
style: [styles.birdHead, {
|
|
143
|
-
left: 29,
|
|
144
|
-
top: 12
|
|
145
|
-
}]
|
|
146
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
147
|
-
style: [styles.birdBeak, {
|
|
148
|
-
left: 40,
|
|
149
|
-
top: 17
|
|
150
|
-
}]
|
|
151
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
152
|
-
style: [styles.birdWing, {
|
|
153
|
-
left: 5,
|
|
154
|
-
top: 10,
|
|
155
|
-
width: 15,
|
|
156
|
-
height: 6
|
|
157
|
-
}]
|
|
158
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
159
|
-
style: [styles.birdWing, {
|
|
160
|
-
left: 15,
|
|
161
|
-
top: 8,
|
|
162
|
-
width: 15,
|
|
163
|
-
height: 6
|
|
164
|
-
}]
|
|
165
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
166
|
-
style: [styles.birdTail, {
|
|
167
|
-
left: 0,
|
|
168
|
-
top: 18
|
|
169
|
-
}]
|
|
170
|
-
})]
|
|
171
|
-
}), [obstacle.x, obstacle.y, obstacle.width, obstacle.height]);
|
|
172
|
-
switch (obstacle.type) {
|
|
173
|
-
case 'cactus_small':
|
|
174
|
-
return renderCactusSmall;
|
|
175
|
-
case 'cactus_large':
|
|
176
|
-
return renderCactusLarge;
|
|
177
|
-
case 'bird':
|
|
178
|
-
return renderBird;
|
|
179
|
-
default:
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
}, (prevProps, nextProps) => {
|
|
183
|
-
// Custom comparison: only re-render if obstacle position or type changes
|
|
184
|
-
return prevProps.obstacle.x === nextProps.obstacle.x && prevProps.obstacle.y === nextProps.obstacle.y && prevProps.obstacle.type === nextProps.obstacle.type && prevProps.obstacle.id === nextProps.obstacle.id;
|
|
185
|
-
});
|
|
186
|
-
export const ObstacleSprite = /*#__PURE__*/React.memo(() => {
|
|
187
|
-
const obstacles = useObstacles();
|
|
188
|
-
|
|
189
|
-
// Memoize visible obstacles to prevent infinite re-renders
|
|
190
|
-
const visibleObstacles = React.useMemo(() => {
|
|
191
|
-
if (!Array.isArray(obstacles) || obstacles.length === 0) {
|
|
192
|
-
return [];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Limit obstacles to prevent layout issues and only show visible ones
|
|
196
|
-
return obstacles.filter(obstacle => obstacle && obstacle.x > -100 && obstacle.x < 500).slice(0, 5);
|
|
197
|
-
}, [obstacles]);
|
|
198
|
-
|
|
199
|
-
// Early return if no visible obstacles
|
|
200
|
-
if (visibleObstacles.length === 0) {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
204
|
-
children: visibleObstacles.map(obstacle => /*#__PURE__*/_jsx(SingleObstacle, {
|
|
205
|
-
obstacle: obstacle
|
|
206
|
-
}, obstacle.id))
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
const styles = StyleSheet.create({
|
|
210
|
-
obstacleContainer: {
|
|
211
|
-
position: 'absolute',
|
|
212
|
-
// Enhanced shadow for better depth
|
|
213
|
-
shadowColor: '#000',
|
|
214
|
-
shadowOffset: {
|
|
215
|
-
width: 0,
|
|
216
|
-
height: 2
|
|
217
|
-
},
|
|
218
|
-
shadowOpacity: 0.25,
|
|
219
|
-
shadowRadius: 3,
|
|
220
|
-
elevation: 4
|
|
221
|
-
},
|
|
222
|
-
cactusBody: {
|
|
223
|
-
borderRadius: 6,
|
|
224
|
-
borderWidth: 1,
|
|
225
|
-
borderColor: DINO_JUMP_COLORS.OBSTACLE_OUTLINE
|
|
226
|
-
// Subtle gradient effect with border
|
|
227
|
-
},
|
|
228
|
-
cactusArm: {
|
|
229
|
-
position: 'absolute',
|
|
230
|
-
borderRadius: 4,
|
|
231
|
-
borderWidth: 1,
|
|
232
|
-
borderColor: DINO_JUMP_COLORS.OBSTACLE_OUTLINE
|
|
233
|
-
},
|
|
234
|
-
cactusSpike: {
|
|
235
|
-
position: 'absolute',
|
|
236
|
-
width: 2,
|
|
237
|
-
height: 2,
|
|
238
|
-
borderRadius: 1,
|
|
239
|
-
backgroundColor: DINO_JUMP_COLORS.OBSTACLE_OUTLINE
|
|
240
|
-
},
|
|
241
|
-
cactusBase: {
|
|
242
|
-
position: 'absolute',
|
|
243
|
-
borderRadius: 2,
|
|
244
|
-
borderWidth: 1,
|
|
245
|
-
borderColor: DINO_JUMP_COLORS.OBSTACLE_OUTLINE
|
|
246
|
-
},
|
|
247
|
-
cactusPlantedBase: {
|
|
248
|
-
position: 'absolute',
|
|
249
|
-
borderWidth: 1,
|
|
250
|
-
borderColor: '#4a2c1a',
|
|
251
|
-
shadowColor: '#000',
|
|
252
|
-
shadowOffset: {
|
|
253
|
-
width: 0,
|
|
254
|
-
height: 1
|
|
255
|
-
},
|
|
256
|
-
shadowOpacity: 0.3,
|
|
257
|
-
shadowRadius: 2,
|
|
258
|
-
elevation: 2
|
|
259
|
-
},
|
|
260
|
-
cactusRoot: {
|
|
261
|
-
position: 'absolute',
|
|
262
|
-
borderRadius: 2
|
|
263
|
-
},
|
|
264
|
-
birdBody: {
|
|
265
|
-
position: 'absolute',
|
|
266
|
-
backgroundColor: '#8B4513',
|
|
267
|
-
borderRadius: 5,
|
|
268
|
-
borderWidth: 1,
|
|
269
|
-
borderColor: '#654321'
|
|
270
|
-
},
|
|
271
|
-
birdHead: {
|
|
272
|
-
position: 'absolute',
|
|
273
|
-
width: 12,
|
|
274
|
-
height: 12,
|
|
275
|
-
backgroundColor: '#8B4513',
|
|
276
|
-
borderRadius: 6,
|
|
277
|
-
borderWidth: 1,
|
|
278
|
-
borderColor: '#654321'
|
|
279
|
-
},
|
|
280
|
-
birdBeak: {
|
|
281
|
-
position: 'absolute',
|
|
282
|
-
width: 4,
|
|
283
|
-
height: 2,
|
|
284
|
-
backgroundColor: '#FFD700',
|
|
285
|
-
borderRadius: 1
|
|
286
|
-
},
|
|
287
|
-
birdWing: {
|
|
288
|
-
position: 'absolute',
|
|
289
|
-
backgroundColor: '#A0522D',
|
|
290
|
-
borderRadius: 3,
|
|
291
|
-
borderWidth: 1,
|
|
292
|
-
borderColor: '#654321'
|
|
293
|
-
},
|
|
294
|
-
birdTail: {
|
|
295
|
-
position: 'absolute',
|
|
296
|
-
width: 12,
|
|
297
|
-
height: 4,
|
|
298
|
-
backgroundColor: '#8B4513',
|
|
299
|
-
borderRadius: 2,
|
|
300
|
-
borderWidth: 1,
|
|
301
|
-
borderColor: '#654321'
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
SingleObstacle.displayName = 'SingleObstacle';
|
|
305
|
-
ObstacleSprite.displayName = 'ObstacleSprite';
|
|
306
|
-
//# sourceMappingURL=ObstacleSprite.js.map
|
|
1
|
+
"use strict";import React from 'react';import{View,StyleSheet}from 'react-native';import{useObstacles}from "../DinoJumpStore.js";import{DINO_JUMP_COLORS}from "../DinoJumpConstants.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from "react/jsx-runtime";const SingleObstacle = React.memo(({obstacle})=>{if(!obstacle || typeof obstacle.x !== 'number' || typeof obstacle.y !== 'number'){return null;}const renderCactusSmall = React.useMemo(()=> _jsxs(View,{style:[styles.obstacleContainer,{left:obstacle.x,top:obstacle.y,width:obstacle.width,height:obstacle.height}],children:[_jsx(View,{style:[styles.cactusBody,{width:obstacle.width,height:obstacle.height,backgroundColor:DINO_JUMP_COLORS.OBSTACLE_PRIMARY}]}),_jsx(View,{style:[styles.cactusSpike,{left:2,top:6,width:3,height:3}]}),_jsx(View,{style:[styles.cactusSpike,{right:2,top:10,width:3,height:3}]}),_jsx(View,{style:[styles.cactusSpike,{left:obstacle.width / 2 - 1,top:15,width:3,height:3}]}),_jsx(View,{style:[styles.cactusPlantedBase,{left:obstacle.width / 4,bottom:-6,width:obstacle.width / 2,height:8,backgroundColor:'#654321',borderRadius:4}]}),_jsx(View,{style:[styles.cactusRoot,{left:obstacle.width / 3,bottom:-4,width:obstacle.width / 3,height:4,backgroundColor:DINO_JUMP_COLORS.OBSTACLE_PRIMARY}]})]}),[obstacle.x,obstacle.y,obstacle.width,obstacle.height]);const renderCactusLarge = React.useMemo(()=> _jsxs(View,{style:[styles.obstacleContainer,{left:obstacle.x,top:obstacle.y,width:obstacle.width,height:obstacle.height}],children:[_jsx(View,{style:[styles.cactusBody,{width:obstacle.width,height:obstacle.height,backgroundColor:DINO_JUMP_COLORS.OBSTACLE_PRIMARY}]}),_jsx(View,{style:[styles.cactusArm,{left:-6,top:15,width:8,height:15,backgroundColor:DINO_JUMP_COLORS.OBSTACLE_SECONDARY}]}),_jsx(View,{style:[styles.cactusArm,{right:-2,top:10,width:8,height:20,backgroundColor:DINO_JUMP_COLORS.OBSTACLE_SECONDARY}]}),Array.from({length:6},(_,i)=> _jsx(View,{style:[styles.cactusSpike,{left:2 + i % 3 * 7,top:8 + Math.floor(i / 3)* 15}]},i)),_jsx(View,{style:[styles.cactusPlantedBase,{left:obstacle.width / 4,bottom:-8,width:obstacle.width / 2,height:10,backgroundColor:'#654321',borderRadius:5}]}),_jsx(View,{style:[styles.cactusRoot,{left:obstacle.width / 3,bottom:-5,width:obstacle.width / 3,height:5,backgroundColor:DINO_JUMP_COLORS.OBSTACLE_PRIMARY}]})]}),[obstacle.x,obstacle.y,obstacle.width,obstacle.height]);const renderBird = React.useMemo(()=> _jsxs(View,{style:[styles.obstacleContainer,{left:obstacle.x,top:obstacle.y,width:obstacle.width,height:obstacle.height}],children:[_jsx(View,{style:[styles.birdBody,{left:10,top:15,width:20,height:10}]}),_jsx(View,{style:[styles.birdHead,{left:29,top:12}]}),_jsx(View,{style:[styles.birdBeak,{left:40,top:17}]}),_jsx(View,{style:[styles.birdWing,{left:5,top:10,width:15,height:6}]}),_jsx(View,{style:[styles.birdWing,{left:15,top:8,width:15,height:6}]}),_jsx(View,{style:[styles.birdTail,{left:0,top:18}]})]}),[obstacle.x,obstacle.y,obstacle.width,obstacle.height]);switch(obstacle.type){case 'cactus_small':return renderCactusSmall;case 'cactus_large':return renderCactusLarge;case 'bird':return renderBird;default:return null;}},(prevProps,nextProps)=>{return prevProps.obstacle.x === nextProps.obstacle.x && prevProps.obstacle.y === nextProps.obstacle.y && prevProps.obstacle.type === nextProps.obstacle.type && prevProps.obstacle.id === nextProps.obstacle.id;});export const ObstacleSprite = React.memo(()=>{const obstacles = useObstacles();const visibleObstacles = React.useMemo(()=>{if(!Array.isArray(obstacles)|| obstacles.length === 0){return [];}return obstacles.filter(obstacle => obstacle && obstacle.x > -100 && obstacle.x < 500).slice(0,5);},[obstacles]);if(visibleObstacles.length === 0){return null;}return _jsx(_Fragment,{children:visibleObstacles.map(obstacle => _jsx(SingleObstacle,{obstacle:obstacle},obstacle.id))});});const styles = StyleSheet.create({obstacleContainer:{position:'absolute',shadowColor:'#000',shadowOffset:{width:0,height:2},shadowOpacity:0.25,shadowRadius:3,elevation:4},cactusBody:{borderRadius:6,borderWidth:1,borderColor:DINO_JUMP_COLORS.OBSTACLE_OUTLINE},cactusArm:{position:'absolute',borderRadius:4,borderWidth:1,borderColor:DINO_JUMP_COLORS.OBSTACLE_OUTLINE},cactusSpike:{position:'absolute',width:2,height:2,borderRadius:1,backgroundColor:DINO_JUMP_COLORS.OBSTACLE_OUTLINE},cactusBase:{position:'absolute',borderRadius:2,borderWidth:1,borderColor:DINO_JUMP_COLORS.OBSTACLE_OUTLINE},cactusPlantedBase:{position:'absolute',borderWidth:1,borderColor:'#4a2c1a',shadowColor:'#000',shadowOffset:{width:0,height:1},shadowOpacity:0.3,shadowRadius:2,elevation:2},cactusRoot:{position:'absolute',borderRadius:2},birdBody:{position:'absolute',backgroundColor:'#8B4513',borderRadius:5,borderWidth:1,borderColor:'#654321'},birdHead:{position:'absolute',width:12,height:12,backgroundColor:'#8B4513',borderRadius:6,borderWidth:1,borderColor:'#654321'},birdBeak:{position:'absolute',width:4,height:2,backgroundColor:'#FFD700',borderRadius:1},birdWing:{position:'absolute',backgroundColor:'#A0522D',borderRadius:3,borderWidth:1,borderColor:'#654321'},birdTail:{position:'absolute',width:12,height:4,backgroundColor:'#8B4513',borderRadius:2,borderWidth:1,borderColor:'#654321'}});SingleObstacle.displayName = 'SingleObstacle';ObstacleSprite.displayName = 'ObstacleSprite';
|
|
@@ -1,105 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import { View, Text, StyleSheet } from 'react-native';
|
|
5
|
-
import { useScore, useTimeLeft, useLives } from "../DinoJumpStore.js";
|
|
6
|
-
import { DinoJumpService } from "../DinoJumpService.js";
|
|
7
|
-
import { ScoreBoardContainer } from "../../../helpers/index.js";
|
|
8
|
-
import { DINO_JUMP_COLORS } from "../DinoJumpConstants.js";
|
|
9
|
-
|
|
10
|
-
// Memoize gameService outside component to avoid recreation
|
|
11
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
const gameService = new DinoJumpService();
|
|
13
|
-
export const ScoreBoard = /*#__PURE__*/React.memo(({
|
|
14
|
-
offset = 0
|
|
15
|
-
}) => {
|
|
16
|
-
const score = useScore();
|
|
17
|
-
const timeLeft = useTimeLeft();
|
|
18
|
-
const lives = useLives();
|
|
19
|
-
const formattedTime = useMemo(() => gameService.formatTime(timeLeft), [timeLeft]);
|
|
20
|
-
|
|
21
|
-
// Generate hearts display: red for remaining lives, black for lost lives
|
|
22
|
-
const heartsDisplay = useMemo(() => {
|
|
23
|
-
const maxLives = 3; // Max lives increased to 5 (can collect stars for extra lives)
|
|
24
|
-
const currentLives = Math.max(0, Math.min(lives, maxLives)); // Clamp between 0 and maxLives
|
|
25
|
-
const lostLives = Math.max(0, maxLives - currentLives); // Ensure non-negative
|
|
26
|
-
|
|
27
|
-
const redHearts = '❤️'.repeat(currentLives); // Remaining lives
|
|
28
|
-
const blackHearts = '🖤'.repeat(lostLives); // Lost lives
|
|
29
|
-
return redHearts + blackHearts;
|
|
30
|
-
}, [lives]);
|
|
31
|
-
return /*#__PURE__*/_jsx(ScoreBoardContainer, {
|
|
32
|
-
offset: offset,
|
|
33
|
-
backgroundColor: "rgba(255, 99, 71, 0.4)",
|
|
34
|
-
borderColor: "rgba(255, 99, 71, 0.4)",
|
|
35
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
36
|
-
style: styles.scoreBoard,
|
|
37
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
38
|
-
style: styles.scoreSection,
|
|
39
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
40
|
-
style: styles.scoreLabel,
|
|
41
|
-
children: "Score"
|
|
42
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
43
|
-
style: styles.scoreValue,
|
|
44
|
-
children: score.toLocaleString()
|
|
45
|
-
})]
|
|
46
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
47
|
-
style: styles.scoreSection,
|
|
48
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
49
|
-
style: styles.scoreLabel,
|
|
50
|
-
children: "Time"
|
|
51
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
52
|
-
style: [styles.timeValue, {
|
|
53
|
-
color: timeLeft < 60 ? '#ef4444' : DINO_JUMP_COLORS.SCORE_TEXT
|
|
54
|
-
}],
|
|
55
|
-
children: formattedTime
|
|
56
|
-
})]
|
|
57
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
58
|
-
style: styles.scoreSection,
|
|
59
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
60
|
-
style: styles.scoreLabel,
|
|
61
|
-
children: "Lives"
|
|
62
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
63
|
-
style: styles.livesValue,
|
|
64
|
-
numberOfLines: 1,
|
|
65
|
-
children: heartsDisplay
|
|
66
|
-
})]
|
|
67
|
-
})]
|
|
68
|
-
})
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
const styles = StyleSheet.create({
|
|
72
|
-
scoreBoard: {
|
|
73
|
-
flexDirection: 'row',
|
|
74
|
-
justifyContent: 'space-between',
|
|
75
|
-
alignItems: 'center'
|
|
76
|
-
},
|
|
77
|
-
scoreSection: {
|
|
78
|
-
alignItems: 'center',
|
|
79
|
-
flex: 1
|
|
80
|
-
},
|
|
81
|
-
scoreLabel: {
|
|
82
|
-
fontSize: 18,
|
|
83
|
-
fontWeight: 'bold',
|
|
84
|
-
color: '#ffffff',
|
|
85
|
-
// White label
|
|
86
|
-
marginBottom: 4,
|
|
87
|
-
letterSpacing: 0.5
|
|
88
|
-
},
|
|
89
|
-
scoreValue: {
|
|
90
|
-
fontSize: 30,
|
|
91
|
-
fontWeight: 'bold',
|
|
92
|
-
color: '#ffffff' // White for score
|
|
93
|
-
},
|
|
94
|
-
timeValue: {
|
|
95
|
-
fontSize: 30,
|
|
96
|
-
fontWeight: 'bold'
|
|
97
|
-
// Color is set dynamically in the component
|
|
98
|
-
},
|
|
99
|
-
livesValue: {
|
|
100
|
-
fontSize: 20,
|
|
101
|
-
fontWeight: 'bold'
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
ScoreBoard.displayName = 'ScoreBoard';
|
|
105
|
-
//# sourceMappingURL=ScoreBoard.js.map
|
|
1
|
+
"use strict";import React,{useMemo}from 'react';import{View,Text,StyleSheet}from 'react-native';import{useScore,useTimeLeft,useLives}from "../DinoJumpStore.js";import{DinoJumpService}from "../DinoJumpService.js";import{ScoreBoardContainer}from "../../../helpers/index.js";import{DINO_JUMP_COLORS}from "../DinoJumpConstants.js";import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";const gameService = new DinoJumpService();export const ScoreBoard = React.memo(({offset = 0})=>{const score = useScore();const timeLeft = useTimeLeft();const lives = useLives();const formattedTime = useMemo(()=> gameService.formatTime(timeLeft),[timeLeft]);const heartsDisplay = useMemo(()=>{const maxLives = 3;const currentLives = Math.max(0,Math.min(lives,maxLives));const lostLives = Math.max(0,maxLives - currentLives);const redHearts = '❤️'.repeat(currentLives);const blackHearts = '🖤'.repeat(lostLives);return redHearts + blackHearts;},[lives]);return _jsx(ScoreBoardContainer,{offset:offset,backgroundColor:"rgba(255,99,71,0.4)",borderColor:"rgba(255,99,71,0.4)",children:_jsxs(View,{style:styles.scoreBoard,children:[_jsxs(View,{style:styles.scoreSection,children:[_jsx(Text,{style:styles.scoreLabel,children:"Score"}),_jsx(Text,{style:styles.scoreValue,children:score.toLocaleString()})]}),_jsxs(View,{style:styles.scoreSection,children:[_jsx(Text,{style:styles.scoreLabel,children:"Time"}),_jsx(Text,{style:[styles.timeValue,{color:timeLeft < 60 ? '#ef4444':DINO_JUMP_COLORS.SCORE_TEXT}],children:formattedTime})]}),_jsxs(View,{style:styles.scoreSection,children:[_jsx(Text,{style:styles.scoreLabel,children:"Lives"}),_jsx(Text,{style:styles.livesValue,numberOfLines:1,children:heartsDisplay})]})]})});});const styles = StyleSheet.create({scoreBoard:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},scoreSection:{alignItems:'center',flex:1},scoreLabel:{fontSize:16,fontWeight:'bold',color:'#ffffff',marginBottom:4,letterSpacing:0.5},scoreValue:{fontSize:25,fontWeight:'bold',color:'#ffffff'},timeValue:{fontSize:25,fontWeight:'bold',color:'#ffffff'},livesValue:{fontSize:25,fontWeight:'bold'}});ScoreBoard.displayName = 'ScoreBoard';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","View","Text","StyleSheet","useScore","useTimeLeft","useLives","DinoJumpService","ScoreBoardContainer","DINO_JUMP_COLORS","jsx","_jsx","jsxs","_jsxs","gameService","ScoreBoard","memo","offset","score","timeLeft","lives","formattedTime","formatTime","heartsDisplay","maxLives","currentLives","Math","max","min","lostLives","redHearts","repeat","blackHearts","backgroundColor","borderColor","children","style","styles","scoreBoard","scoreSection","scoreLabel","scoreValue","toLocaleString","timeValue","color","SCORE_TEXT","livesValue","numberOfLines","create","flexDirection","justifyContent","alignItems","flex","fontSize","fontWeight","marginBottom","letterSpacing","displayName"],"sourceRoot":"../../../../../src","sources":["games/dino-jump/components/ScoreBoard.tsx"],"mappings":";;AAAA,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T,IAAI;UAACkC,KAAK,EAAEC,MAAM,CAACS,UAAW;UAACC,aAAa,EAAE,CAAE;UAAAZ,QAAA,EAAEZ;QAAa,CAAO,CAAC;MAAA,CACpE,CAAC;IAAA,CACH;EAAC,CACc,CAAC;AAE1B,CAAC,CAAC;AAEF,MAAMc,MAAM,GAAGlC,UAAU,CAAC6C,MAAM,CAAC;EAC/BV,UAAU,EAAE;IACVW,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,eAAe;IAC/BC,UAAU,EAAE;EACd,CAAC;EACDZ,YAAY,EAAE;IACZY,UAAU,EAAE,QAAQ;IACpBC,IAAI,EAAE;EACR,CAAC;EACDZ,UAAU,EAAE;IACVa,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBV,KAAK,EAAE,SAAS;IAAE;IAClBW,YAAY,EAAE,CAAC;IACfC,aAAa,EAAE;EACjB,CAAC;EACDf,UAAU,EAAE;IACVY,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBV,KAAK,EAAE,SAAS,CAAE;EACpB,CAAC;EACDD,SAAS,EAAE;IACTU,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"names":["React","useMemo","View","Text","StyleSheet","useScore","useTimeLeft","useLives","DinoJumpService","ScoreBoardContainer","DINO_JUMP_COLORS","jsx","_jsx","jsxs","_jsxs","gameService","ScoreBoard","memo","offset","score","timeLeft","lives","formattedTime","formatTime","heartsDisplay","maxLives","currentLives","Math","max","min","lostLives","redHearts","repeat","blackHearts","backgroundColor","borderColor","children","style","styles","scoreBoard","scoreSection","scoreLabel","scoreValue","toLocaleString","timeValue","color","SCORE_TEXT","livesValue","numberOfLines","create","flexDirection","justifyContent","alignItems","flex","fontSize","fontWeight","marginBottom","letterSpacing","displayName"],"sourceRoot":"../../../../../src","sources":["games/dino-jump/components/ScoreBoard.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;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,UAAW;UAACC,aAAa,EAAE,CAAE;UAAAZ,QAAA,EAAEZ;QAAa,CAAO,CAAC;MAAA,CACpE,CAAC;IAAA,CACH;EAAC,CACc,CAAC;AAE1B,CAAC,CAAC;AAEF,MAAMc,MAAM,GAAGlC,UAAU,CAAC6C,MAAM,CAAC;EAC/BV,UAAU,EAAE;IACVW,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,eAAe;IAC/BC,UAAU,EAAE;EACd,CAAC;EACDZ,YAAY,EAAE;IACZY,UAAU,EAAE,QAAQ;IACpBC,IAAI,EAAE;EACR,CAAC;EACDZ,UAAU,EAAE;IACVa,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBV,KAAK,EAAE,SAAS;IAAE;IAClBW,YAAY,EAAE,CAAC;IACfC,aAAa,EAAE;EACjB,CAAC;EACDf,UAAU,EAAE;IACVY,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBV,KAAK,EAAE,SAAS,CAAE;EACpB,CAAC;EACDD,SAAS,EAAE;IACTU,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBV,KAAK,EAAE;IACP;EACF,CAAC;EACDE,UAAU,EAAE;IACVO,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEFvC,UAAU,CAAC0C,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -1,45 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { View, Text, StyleSheet } from 'react-native';
|
|
5
|
-
import { useStars } from "../DinoJumpStore.js";
|
|
6
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
-
// Memoized single star component
|
|
8
|
-
const SingleStar = /*#__PURE__*/React.memo(({
|
|
9
|
-
star
|
|
10
|
-
}) => /*#__PURE__*/_jsx(View, {
|
|
11
|
-
style: [styles.starContainer, {
|
|
12
|
-
left: star.x,
|
|
13
|
-
top: star.y,
|
|
14
|
-
width: star.width,
|
|
15
|
-
height: star.height
|
|
16
|
-
}],
|
|
17
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
18
|
-
style: styles.mushroom,
|
|
19
|
-
children: "\uD83C\uDF44"
|
|
20
|
-
})
|
|
21
|
-
}), (prev, next) => prev.star.id === next.star.id && prev.star.x === next.star.x);
|
|
22
|
-
export const StarSprite = /*#__PURE__*/React.memo(() => {
|
|
23
|
-
const stars = useStars();
|
|
24
|
-
if (!stars || stars.length === 0) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
28
|
-
children: stars.map(star => /*#__PURE__*/_jsx(SingleStar, {
|
|
29
|
-
star: star
|
|
30
|
-
}, star.id))
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
const styles = StyleSheet.create({
|
|
34
|
-
starContainer: {
|
|
35
|
-
position: 'absolute',
|
|
36
|
-
justifyContent: 'center',
|
|
37
|
-
alignItems: 'center'
|
|
38
|
-
},
|
|
39
|
-
mushroom: {
|
|
40
|
-
fontSize: 40,
|
|
41
|
-
lineHeight: 40
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
StarSprite.displayName = 'StarSprite';
|
|
45
|
-
//# sourceMappingURL=StarSprite.js.map
|
|
1
|
+
"use strict";import React from 'react';import{View,Text,StyleSheet}from 'react-native';import{useStars}from "../DinoJumpStore.js";import{jsx as _jsx,Fragment as _Fragment}from "react/jsx-runtime";const SingleStar = React.memo(({star})=> _jsx(View,{style:[styles.starContainer,{left:star.x,top:star.y,width:star.width,height:star.height}],children:_jsx(Text,{style:styles.mushroom,children:"\uD83C\uDF44"})}),(prev,next)=> prev.star.id === next.star.id && prev.star.x === next.star.x);export const StarSprite = React.memo(()=>{const stars = useStars();if(!stars || stars.length === 0){return null;}return _jsx(_Fragment,{children:stars.map(star => _jsx(SingleStar,{star:star},star.id))});});const styles = StyleSheet.create({starContainer:{position:'absolute',justifyContent:'center',alignItems:'center'},mushroom:{fontSize:40,lineHeight:40}});StarSprite.displayName = 'StarSprite';
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
export { GameBackground } from "./GameBackground.js";
|
|
4
|
-
export { GameArea } from "./GameArea.js";
|
|
5
|
-
export { DinoSprite } from "./DinoSprite.js";
|
|
6
|
-
export { ObstacleSprite } from "./ObstacleSprite.js";
|
|
7
|
-
export { StarSprite } from "./StarSprite.js";
|
|
8
|
-
export { ScoreBoard } from "./ScoreBoard.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";export{GameBackground}from "./GameBackground.js";export{GameArea}from "./GameArea.js";export{DinoSprite}from "./DinoSprite.js";export{ObstacleSprite}from "./ObstacleSprite.js";export{StarSprite}from "./StarSprite.js";export{ScoreBoard}from "./ScoreBoard.js";
|
|
@@ -1,126 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useCallback, useMemo, useRef } from 'react';
|
|
4
|
-
import { View, StyleSheet } from 'react-native';
|
|
5
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
6
|
-
import { useFlappyBirdStore } from "./FlappyBirdStore.js";
|
|
7
|
-
import { ScoreBoard, GameArea, GameBackground } from "./components/index.js";
|
|
8
|
-
import { GameControlButton, GameOverModal } from "../../helpers/index.js";
|
|
9
|
-
import { GameSettingsModal } from "../../helpers/index.js";
|
|
10
|
-
import { FLAPPY_BIRD_COLORS } from "./FlappyBirdConstants.js";
|
|
11
|
-
import { GAME_IDS, DEFAULT_GAME_SETTINGS } from "../../services/UtilsService.js";
|
|
12
|
-
import { playSound, GAME_SOUNDS } from "../../services/SoundsService.js";
|
|
13
|
-
import { playHaptic, HapticType } from "../../services/HapticsService.js";
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const formatTime = seconds => {
|
|
16
|
-
const mins = Math.floor(seconds / 60);
|
|
17
|
-
const secs = seconds % 60;
|
|
18
|
-
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
|
19
|
-
};
|
|
20
|
-
export const FlappyBird = /*#__PURE__*/React.memo(({
|
|
21
|
-
settings = DEFAULT_GAME_SETTINGS,
|
|
22
|
-
onSettingsChange
|
|
23
|
-
}) => {
|
|
24
|
-
// Only subscribe to non-animation state (CRITICAL: prevents 60fps re-renders)
|
|
25
|
-
const isPlaying = useFlappyBirdStore(state => state.isPlaying);
|
|
26
|
-
const isGameOver = useFlappyBirdStore(state => state.isGameOver);
|
|
27
|
-
const survivalTime = useFlappyBirdStore(state => state.survivalTime);
|
|
28
|
-
const initializeGame = useFlappyBirdStore(state => state.initializeGame);
|
|
29
|
-
const startGame = useFlappyBirdStore(state => state.startGame);
|
|
30
|
-
const stopGame = useFlappyBirdStore(state => state.stopGame);
|
|
31
|
-
const resetGame = useFlappyBirdStore(state => state.resetGame);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
initializeGame();
|
|
34
|
-
return () => {
|
|
35
|
-
stopGame();
|
|
36
|
-
};
|
|
37
|
-
}, [initializeGame, stopGame]);
|
|
38
|
-
const prevGameOverRef = useRef(false);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (isGameOver && !prevGameOverRef.current) {
|
|
41
|
-
playSound(GAME_SOUNDS.FLAPPY_BIRD.HIT, settings.enableSounds);
|
|
42
|
-
playHaptic(HapticType.HEAVY, settings.enableHaptics);
|
|
43
|
-
}
|
|
44
|
-
prevGameOverRef.current = isGameOver;
|
|
45
|
-
}, [isGameOver, settings.enableSounds, settings.enableHaptics]);
|
|
46
|
-
const handleStartGame = useCallback(() => {
|
|
47
|
-
initializeGame();
|
|
48
|
-
startGame(settings);
|
|
49
|
-
playSound(GAME_SOUNDS.FLAPPY_BIRD.START, settings.enableSounds);
|
|
50
|
-
playHaptic(HapticType.MEDIUM, settings.enableHaptics);
|
|
51
|
-
}, [initializeGame, startGame, settings]);
|
|
52
|
-
const handleStopGame = useCallback(() => {
|
|
53
|
-
stopGame();
|
|
54
|
-
}, [stopGame]);
|
|
55
|
-
const handleResetGame = useCallback(() => {
|
|
56
|
-
resetGame();
|
|
57
|
-
initializeGame();
|
|
58
|
-
}, [resetGame, initializeGame]);
|
|
59
|
-
|
|
60
|
-
// Memoize modal props to prevent unnecessary re-renders
|
|
61
|
-
const gameOverModalProps = useMemo(() => ({
|
|
62
|
-
isVisible: isGameOver,
|
|
63
|
-
score: survivalTime,
|
|
64
|
-
onPlayAgain: handleResetGame,
|
|
65
|
-
buttonText: "Fly Again!",
|
|
66
|
-
primaryColor: FLAPPY_BIRD_COLORS.GAME_OVER_BG,
|
|
67
|
-
borderColor: FLAPPY_BIRD_COLORS.BUTTON_PRIMARY,
|
|
68
|
-
buttonColor: FLAPPY_BIRD_COLORS.BUTTON_PRIMARY,
|
|
69
|
-
buttonBorderColor: FLAPPY_BIRD_COLORS.BUTTON_SECONDARY,
|
|
70
|
-
scoreLabel: "Survival Time",
|
|
71
|
-
scoreFormatter: formatTime
|
|
72
|
-
}), [isGameOver, survivalTime, handleResetGame]);
|
|
73
|
-
const gameSettingsModalProps = useMemo(() => ({
|
|
74
|
-
gameId: GAME_IDS.FLAPPY_BIRD,
|
|
75
|
-
settings,
|
|
76
|
-
onSettingsChange
|
|
77
|
-
}), [settings, onSettingsChange]);
|
|
78
|
-
|
|
79
|
-
// Get offset from settings
|
|
80
|
-
const offset = settings?.offset ?? 0;
|
|
81
|
-
|
|
82
|
-
// Memoize GameControlButton props to prevent re-renders (CRITICAL)
|
|
83
|
-
const gameControlButtonProps = useMemo(() => ({
|
|
84
|
-
isPlaying,
|
|
85
|
-
gameOver: isGameOver,
|
|
86
|
-
onStartGame: handleStartGame,
|
|
87
|
-
onStopGame: handleStopGame,
|
|
88
|
-
startButtonText: "START FLYING",
|
|
89
|
-
stopButtonText: "STOP GAME",
|
|
90
|
-
startButtonSubtext: "Tap to flap!",
|
|
91
|
-
startButtonColor: FLAPPY_BIRD_COLORS.BUTTON_PRIMARY,
|
|
92
|
-
startButtonBorderColor: FLAPPY_BIRD_COLORS.BUTTON_SECONDARY
|
|
93
|
-
}), [isPlaying, isGameOver, handleStartGame, handleStopGame]);
|
|
94
|
-
return /*#__PURE__*/_jsx(View, {
|
|
95
|
-
style: styles.root,
|
|
96
|
-
children: /*#__PURE__*/_jsx(GestureHandlerRootView, {
|
|
97
|
-
children: /*#__PURE__*/_jsx(GameBackground, {
|
|
98
|
-
offset: offset,
|
|
99
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
100
|
-
style: styles.container,
|
|
101
|
-
children: [/*#__PURE__*/_jsx(GameArea, {
|
|
102
|
-
settings: settings
|
|
103
|
-
}), /*#__PURE__*/_jsx(ScoreBoard, {
|
|
104
|
-
offset: offset
|
|
105
|
-
}), /*#__PURE__*/_jsx(GameControlButton, {
|
|
106
|
-
...gameControlButtonProps
|
|
107
|
-
}), /*#__PURE__*/_jsx(GameOverModal, {
|
|
108
|
-
...gameOverModalProps
|
|
109
|
-
}), /*#__PURE__*/_jsx(GameSettingsModal, {
|
|
110
|
-
...gameSettingsModalProps
|
|
111
|
-
})]
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
const styles = StyleSheet.create({
|
|
118
|
-
root: {
|
|
119
|
-
flex: 1
|
|
120
|
-
},
|
|
121
|
-
container: {
|
|
122
|
-
flex: 1
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
FlappyBird.displayName = 'FlappyBird';
|
|
126
|
-
//# sourceMappingURL=FlappyBird.js.map
|
|
1
|
+
"use strict";import React,{useEffect,useCallback,useMemo,useRef}from 'react';import{View,StyleSheet}from 'react-native';import{GestureHandlerRootView}from 'react-native-gesture-handler';import{useFlappyBirdStore}from "./FlappyBirdStore.js";import{ScoreBoard,GameArea,GameBackground}from "./components/index.js";import{GameControlButton,GameOverModal}from "../../helpers/index.js";import{GameSettingsModal}from "../../helpers/index.js";import{FLAPPY_BIRD_COLORS}from "./FlappyBirdConstants.js";import{GAME_IDS,DEFAULT_GAME_SETTINGS}from "../../services/UtilsService.js";import{playSound,GAME_SOUNDS}from "../../services/SoundsService.js";import{playHaptic,HapticType}from "../../services/HapticsService.js";import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";const formatTime = seconds =>{const mins = Math.floor(seconds / 60);const secs = seconds % 60;return `${mins.toString().padStart(2,'0')}:${secs.toString().padStart(2,'0')}`;};export const FlappyBird = React.memo(({settings = DEFAULT_GAME_SETTINGS,onSettingsChange})=>{const isPlaying = useFlappyBirdStore(state => state.isPlaying);const isGameOver = useFlappyBirdStore(state => state.isGameOver);const survivalTime = useFlappyBirdStore(state => state.survivalTime);const initializeGame = useFlappyBirdStore(state => state.initializeGame);const startGame = useFlappyBirdStore(state => state.startGame);const stopGame = useFlappyBirdStore(state => state.stopGame);const resetGame = useFlappyBirdStore(state => state.resetGame);useEffect(()=>{initializeGame();return()=>{stopGame();};},[initializeGame,stopGame]);const prevGameOverRef = useRef(false);useEffect(()=>{if(isGameOver && !prevGameOverRef.current){playSound(GAME_SOUNDS.FLAPPY_BIRD.HIT,settings.enableSounds);playHaptic(HapticType.HEAVY,settings.enableHaptics);}prevGameOverRef.current = isGameOver;},[isGameOver,settings.enableSounds,settings.enableHaptics]);const handleStartGame = useCallback(()=>{initializeGame();startGame(settings);playSound(GAME_SOUNDS.FLAPPY_BIRD.START,settings.enableSounds);playHaptic(HapticType.MEDIUM,settings.enableHaptics);},[initializeGame,startGame,settings]);const handleStopGame = useCallback(()=>{stopGame();},[stopGame]);const handleResetGame = useCallback(()=>{resetGame();initializeGame();},[resetGame,initializeGame]);const gameOverModalProps = useMemo(()=>({isVisible:isGameOver,score:survivalTime,onPlayAgain:handleResetGame,buttonText:"Fly Again!",primaryColor:"rgba(92,184,92,0.5)",borderColor:"rgba(92,184,92,0.5)",buttonColor:"#ffffff",buttonBorderColor:"#ffffff",buttonTextColor:"#5CB85C",scoreLabel:"Survival Time",scoreFormatter:formatTime}),[isGameOver,survivalTime,handleResetGame]);const gameSettingsModalProps = useMemo(()=>({gameId:GAME_IDS.FLAPPY_BIRD,settings,onSettingsChange}),[settings,onSettingsChange]);const offset = settings?.offset ?? 0;const gameControlButtonProps = useMemo(()=>({isPlaying,gameOver:isGameOver,onStartGame:handleStartGame,onStopGame:handleStopGame,startButtonText:"START FLYING",stopButtonText:"STOP GAME",startButtonSubtext:"Tap to flap!",startButtonColor:FLAPPY_BIRD_COLORS.BUTTON_PRIMARY,startButtonBorderColor:FLAPPY_BIRD_COLORS.BUTTON_SECONDARY}),[isPlaying,isGameOver,handleStartGame,handleStopGame]);return _jsx(View,{style:styles.root,children:_jsx(GestureHandlerRootView,{children:_jsx(GameBackground,{offset:offset,children:_jsxs(View,{style:styles.container,children:[_jsx(GameArea,{settings:settings}),_jsx(ScoreBoard,{offset:offset}),_jsx(GameControlButton,{...gameControlButtonProps}),_jsx(GameOverModal,{...gameOverModalProps}),_jsx(GameSettingsModal,{...gameSettingsModalProps})]})})})});});const styles = StyleSheet.create({root:{flex:1},container:{flex:1}});FlappyBird.displayName = 'FlappyBird';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useCallback","useMemo","useRef","View","StyleSheet","GestureHandlerRootView","useFlappyBirdStore","ScoreBoard","GameArea","GameBackground","GameControlButton","GameOverModal","GameSettingsModal","FLAPPY_BIRD_COLORS","GAME_IDS","DEFAULT_GAME_SETTINGS","playSound","GAME_SOUNDS","playHaptic","HapticType","jsx","_jsx","jsxs","_jsxs","formatTime","seconds","mins","Math","floor","secs","toString","padStart","FlappyBird","memo","settings","onSettingsChange","isPlaying","state","isGameOver","survivalTime","initializeGame","startGame","stopGame","resetGame","prevGameOverRef","current","FLAPPY_BIRD","HIT","enableSounds","HEAVY","enableHaptics","handleStartGame","START","MEDIUM","handleStopGame","handleResetGame","gameOverModalProps","isVisible","score","onPlayAgain","buttonText","primaryColor","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useCallback","useMemo","useRef","View","StyleSheet","GestureHandlerRootView","useFlappyBirdStore","ScoreBoard","GameArea","GameBackground","GameControlButton","GameOverModal","GameSettingsModal","FLAPPY_BIRD_COLORS","GAME_IDS","DEFAULT_GAME_SETTINGS","playSound","GAME_SOUNDS","playHaptic","HapticType","jsx","_jsx","jsxs","_jsxs","formatTime","seconds","mins","Math","floor","secs","toString","padStart","FlappyBird","memo","settings","onSettingsChange","isPlaying","state","isGameOver","survivalTime","initializeGame","startGame","stopGame","resetGame","prevGameOverRef","current","FLAPPY_BIRD","HIT","enableSounds","HEAVY","enableHaptics","handleStartGame","START","MEDIUM","handleStopGame","handleResetGame","gameOverModalProps","isVisible","score","onPlayAgain","buttonText","primaryColor","borderColor","buttonColor","buttonBorderColor","buttonTextColor","scoreLabel","scoreFormatter","gameSettingsModalProps","gameId","offset","gameControlButtonProps","gameOver","onStartGame","onStopGame","startButtonText","stopButtonText","startButtonSubtext","startButtonColor","BUTTON_PRIMARY","startButtonBorderColor","BUTTON_SECONDARY","style","styles","root","children","container","create","flex","displayName"],"sourceRoot":"../../../../src","sources":["games/flappy-bird/FlappyBird.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACtE,SAASC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAC/C,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAASC,kBAAkB,QAAQ,sBAAmB;AACtD,SAASC,UAAU,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,uBAAc;AACnE,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,wBAAe;AAChE,SAASC,iBAAiB,QAAQ,wBAAe;AACjD,SAASC,kBAAkB,QAAQ,0BAAuB;AAC1D,SAASC,QAAQ,EAAkBC,qBAAqB,QAA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