@umituz/react-native-mascot 1.3.6 → 1.3.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-mascot",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "Interactive mascot system for React Native apps - Customizable animated characters with Lottie and SVG support, mood system, and easy integration",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"lottie-react-native": "^7.3.4"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@umituz/react-native-animation": "^1.3
|
|
56
|
-
"@umituz/react-native-design-system": "
|
|
55
|
+
"@umituz/react-native-animation": "^1.4.3",
|
|
56
|
+
"@umituz/react-native-design-system": "4.29.3",
|
|
57
57
|
"expo": ">=54.0.0",
|
|
58
58
|
"react": ">=19.0.0",
|
|
59
59
|
"react-native": "*",
|
|
@@ -25,7 +25,7 @@ const SVGMascotComponent = memo<SVGMascotProps>(({ mascot, size }) => {
|
|
|
25
25
|
<circle cx="35" cy="40" r="5" fill="#000" />
|
|
26
26
|
<circle cx="65" cy="40" r="5" fill="#000" />
|
|
27
27
|
{/* Mouth based on mood */}
|
|
28
|
-
<
|
|
28
|
+
<MoodExpression mood={mascot.personality.mood} />
|
|
29
29
|
</Svg>
|
|
30
30
|
);
|
|
31
31
|
});
|
|
@@ -35,11 +35,11 @@ SVGMascotComponent.displayName = 'SVGMascot';
|
|
|
35
35
|
export const SVGMascot = SVGMascotComponent;
|
|
36
36
|
|
|
37
37
|
// Mood-based mouth component
|
|
38
|
-
interface
|
|
38
|
+
interface MoodExpressionProps {
|
|
39
39
|
mood: string;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const MoodExpressionComponent = memo<MoodExpressionProps>(({ mood }) => {
|
|
43
43
|
switch (mood) {
|
|
44
44
|
case 'happy':
|
|
45
45
|
case 'excited':
|
|
@@ -56,6 +56,6 @@ const MoodMoodComponent = memo<MoodMoodProps>(({ mood }) => {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
MoodExpressionComponent.displayName = 'MoodExpression';
|
|
60
60
|
|
|
61
|
-
const
|
|
61
|
+
const MoodExpression = memo(MoodExpressionComponent);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Thin wrapper that provides MascotService to components
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { createContext, useContext, ReactNode } from 'react';
|
|
6
|
+
import React, { createContext, useContext, ReactNode, useEffect } from 'react';
|
|
7
7
|
import type { Mascot } from '../../domain/entities/Mascot';
|
|
8
8
|
import type { MascotConfig } from '../../domain/types/MascotTypes';
|
|
9
9
|
import type { MascotService, MascotTemplate } from '../../application/services/MascotService';
|
|
@@ -33,11 +33,13 @@ export const MascotProvider: React.FC<MascotProviderProps> = ({
|
|
|
33
33
|
const service = container.getMascotService();
|
|
34
34
|
|
|
35
35
|
// Auto-initialize if config or template provided
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (initialConfig) {
|
|
38
|
+
service.initialize(initialConfig);
|
|
39
|
+
} else if (template) {
|
|
40
|
+
service.fromTemplate(template);
|
|
41
|
+
}
|
|
42
|
+
}, [initialConfig, template, service]);
|
|
41
43
|
|
|
42
44
|
const value: MascotContextValue = {
|
|
43
45
|
mascot: service.mascot,
|
|
@@ -137,7 +137,7 @@ export function useMascotState(options: UseMascotStateOptions = {}): UseMascotSt
|
|
|
137
137
|
try {
|
|
138
138
|
manager.transitionTo(newState);
|
|
139
139
|
} catch (error) {
|
|
140
|
-
|
|
140
|
+
// Invalid state transition - allow the transition anyway for flexibility
|
|
141
141
|
setState(newState);
|
|
142
142
|
onStateChangeRef.current?.(state, newState);
|
|
143
143
|
}
|