@uselingu/react-native-sdk 0.1.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 +279 -0
- package/lib/commonjs/components/LinguChat.js +283 -0
- package/lib/commonjs/components/LinguChat.js.map +1 -0
- package/lib/commonjs/components/LinguWebView.js +203 -0
- package/lib/commonjs/components/LinguWebView.js.map +1 -0
- package/lib/commonjs/components/MessageBubble.js +91 -0
- package/lib/commonjs/components/MessageBubble.js.map +1 -0
- package/lib/commonjs/components/NativeChatUI.js +192 -0
- package/lib/commonjs/components/NativeChatUI.js.map +1 -0
- package/lib/commonjs/components/TypingIndicator.js +92 -0
- package/lib/commonjs/components/TypingIndicator.js.map +1 -0
- package/lib/commonjs/context/LinguProvider.js +47 -0
- package/lib/commonjs/context/LinguProvider.js.map +1 -0
- package/lib/commonjs/context/index.js +17 -0
- package/lib/commonjs/context/index.js.map +1 -0
- package/lib/commonjs/hooks/useLinguChat.js +295 -0
- package/lib/commonjs/hooks/useLinguChat.js.map +1 -0
- package/lib/commonjs/index.js +129 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/services/LinguAPI.js +196 -0
- package/lib/commonjs/services/LinguAPI.js.map +1 -0
- package/lib/commonjs/services/SessionManager.js +131 -0
- package/lib/commonjs/services/SessionManager.js.map +1 -0
- package/lib/commonjs/services/StorageManager.js +116 -0
- package/lib/commonjs/services/StorageManager.js.map +1 -0
- package/lib/commonjs/theme/ThemeProvider.js +49 -0
- package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
- package/lib/commonjs/theme/index.js +28 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/theme/theme.js +150 -0
- package/lib/commonjs/theme/theme.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/animations.js +118 -0
- package/lib/commonjs/utils/animations.js.map +1 -0
- package/lib/commonjs/utils/formatters.js +89 -0
- package/lib/commonjs/utils/formatters.js.map +1 -0
- package/lib/commonjs/utils/index.js +28 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/components/LinguChat.js +277 -0
- package/lib/module/components/LinguChat.js.map +1 -0
- package/lib/module/components/LinguWebView.js +195 -0
- package/lib/module/components/LinguWebView.js.map +1 -0
- package/lib/module/components/MessageBubble.js +83 -0
- package/lib/module/components/MessageBubble.js.map +1 -0
- package/lib/module/components/NativeChatUI.js +184 -0
- package/lib/module/components/NativeChatUI.js.map +1 -0
- package/lib/module/components/TypingIndicator.js +84 -0
- package/lib/module/components/TypingIndicator.js.map +1 -0
- package/lib/module/context/LinguProvider.js +38 -0
- package/lib/module/context/LinguProvider.js.map +1 -0
- package/lib/module/context/index.js +6 -0
- package/lib/module/context/index.js.map +1 -0
- package/lib/module/hooks/useLinguChat.js +288 -0
- package/lib/module/hooks/useLinguChat.js.map +1 -0
- package/lib/module/index.js +30 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/services/LinguAPI.js +190 -0
- package/lib/module/services/LinguAPI.js.map +1 -0
- package/lib/module/services/SessionManager.js +124 -0
- package/lib/module/services/SessionManager.js.map +1 -0
- package/lib/module/services/StorageManager.js +108 -0
- package/lib/module/services/StorageManager.js.map +1 -0
- package/lib/module/theme/ThemeProvider.js +40 -0
- package/lib/module/theme/ThemeProvider.js.map +1 -0
- package/lib/module/theme/index.js +7 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/theme.js +142 -0
- package/lib/module/theme/theme.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/animations.js +106 -0
- package/lib/module/utils/animations.js.map +1 -0
- package/lib/module/utils/formatters.js +78 -0
- package/lib/module/utils/formatters.js.map +1 -0
- package/lib/module/utils/index.js +7 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/components/LinguChat.d.ts +18 -0
- package/lib/typescript/components/LinguChat.d.ts.map +1 -0
- package/lib/typescript/components/LinguWebView.d.ts +16 -0
- package/lib/typescript/components/LinguWebView.d.ts.map +1 -0
- package/lib/typescript/components/MessageBubble.d.ts +13 -0
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -0
- package/lib/typescript/components/NativeChatUI.d.ts +16 -0
- package/lib/typescript/components/NativeChatUI.d.ts.map +1 -0
- package/lib/typescript/components/TypingIndicator.d.ts +7 -0
- package/lib/typescript/components/TypingIndicator.d.ts.map +1 -0
- package/lib/typescript/context/LinguProvider.d.ts +32 -0
- package/lib/typescript/context/LinguProvider.d.ts.map +1 -0
- package/lib/typescript/context/index.d.ts +5 -0
- package/lib/typescript/context/index.d.ts.map +1 -0
- package/lib/typescript/hooks/useLinguChat.d.ts +18 -0
- package/lib/typescript/hooks/useLinguChat.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +19 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/services/LinguAPI.d.ts +39 -0
- package/lib/typescript/services/LinguAPI.d.ts.map +1 -0
- package/lib/typescript/services/SessionManager.d.ts +46 -0
- package/lib/typescript/services/SessionManager.d.ts.map +1 -0
- package/lib/typescript/services/StorageManager.d.ts +36 -0
- package/lib/typescript/services/StorageManager.d.ts.map +1 -0
- package/lib/typescript/theme/ThemeProvider.d.ts +23 -0
- package/lib/typescript/theme/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/theme/index.d.ts +6 -0
- package/lib/typescript/theme/index.d.ts.map +1 -0
- package/lib/typescript/theme/theme.d.ts +130 -0
- package/lib/typescript/theme/theme.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +50 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/utils/animations.d.ts +34 -0
- package/lib/typescript/utils/animations.d.ts.map +1 -0
- package/lib/typescript/utils/formatters.d.ts +25 -0
- package/lib/typescript/utils/formatters.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +6 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/package.json +98 -0
- package/src/components/LinguChat.tsx +309 -0
- package/src/components/LinguWebView.tsx +216 -0
- package/src/components/MessageBubble.tsx +120 -0
- package/src/components/NativeChatUI.tsx +247 -0
- package/src/components/TypingIndicator.tsx +84 -0
- package/src/context/LinguProvider.tsx +53 -0
- package/src/context/index.ts +5 -0
- package/src/hooks/useLinguChat.ts +314 -0
- package/src/index.ts +43 -0
- package/src/services/LinguAPI.ts +214 -0
- package/src/services/SessionManager.ts +131 -0
- package/src/services/StorageManager.ts +111 -0
- package/src/theme/ThemeProvider.tsx +58 -0
- package/src/theme/index.ts +6 -0
- package/src/theme/theme.ts +254 -0
- package/src/types/index.ts +59 -0
- package/src/utils/animations.ts +141 -0
- package/src/utils/formatters.ts +80 -0
- package/src/utils/index.ts +6 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultTypography = exports.defaultSpacing = exports.defaultShadows = exports.defaultBorderRadius = exports.defaultAnimations = exports.createThemeColors = exports.createTheme = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Theme Configuration
|
|
9
|
+
* Centralized design tokens for the SDK
|
|
10
|
+
* Colors are sourced from backend widget config
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Default typography (constant across themes)
|
|
14
|
+
const defaultTypography = exports.defaultTypography = {
|
|
15
|
+
fontSizes: {
|
|
16
|
+
xs: 12,
|
|
17
|
+
sm: 14,
|
|
18
|
+
base: 15,
|
|
19
|
+
lg: 16,
|
|
20
|
+
xl: 18,
|
|
21
|
+
'2xl': 20,
|
|
22
|
+
'3xl': 24
|
|
23
|
+
},
|
|
24
|
+
fontWeights: {
|
|
25
|
+
normal: '400',
|
|
26
|
+
medium: '500',
|
|
27
|
+
semibold: '600',
|
|
28
|
+
bold: '700'
|
|
29
|
+
},
|
|
30
|
+
lineHeights: {
|
|
31
|
+
tight: 1.2,
|
|
32
|
+
normal: 1.5,
|
|
33
|
+
relaxed: 1.75
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Default spacing (constant across themes)
|
|
38
|
+
const defaultSpacing = exports.defaultSpacing = {
|
|
39
|
+
xs: 4,
|
|
40
|
+
sm: 8,
|
|
41
|
+
md: 12,
|
|
42
|
+
lg: 16,
|
|
43
|
+
xl: 20,
|
|
44
|
+
'2xl': 24,
|
|
45
|
+
'3xl': 32
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Default border radius (constant across themes)
|
|
49
|
+
const defaultBorderRadius = exports.defaultBorderRadius = {
|
|
50
|
+
sm: 4,
|
|
51
|
+
md: 8,
|
|
52
|
+
lg: 12,
|
|
53
|
+
xl: 16,
|
|
54
|
+
full: 9999
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Default shadows (constant across themes)
|
|
58
|
+
const defaultShadows = exports.defaultShadows = {
|
|
59
|
+
sm: {
|
|
60
|
+
shadowColor: '#000',
|
|
61
|
+
shadowOffset: {
|
|
62
|
+
width: 0,
|
|
63
|
+
height: 1
|
|
64
|
+
},
|
|
65
|
+
shadowOpacity: 0.1,
|
|
66
|
+
shadowRadius: 2,
|
|
67
|
+
elevation: 2
|
|
68
|
+
},
|
|
69
|
+
md: {
|
|
70
|
+
shadowColor: '#000',
|
|
71
|
+
shadowOffset: {
|
|
72
|
+
width: 0,
|
|
73
|
+
height: 2
|
|
74
|
+
},
|
|
75
|
+
shadowOpacity: 0.15,
|
|
76
|
+
shadowRadius: 4,
|
|
77
|
+
elevation: 4
|
|
78
|
+
},
|
|
79
|
+
lg: {
|
|
80
|
+
shadowColor: '#000',
|
|
81
|
+
shadowOffset: {
|
|
82
|
+
width: 0,
|
|
83
|
+
height: 4
|
|
84
|
+
},
|
|
85
|
+
shadowOpacity: 0.2,
|
|
86
|
+
shadowRadius: 8,
|
|
87
|
+
elevation: 8
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Default animation durations (constant across themes)
|
|
92
|
+
const defaultAnimations = exports.defaultAnimations = {
|
|
93
|
+
fast: 150,
|
|
94
|
+
normal: 300,
|
|
95
|
+
slow: 500
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Create theme colors from backend widget config
|
|
100
|
+
*/
|
|
101
|
+
const createThemeColors = (primaryColor, backgroundColor, textColor, theme = 'light') => {
|
|
102
|
+
const isLight = theme === 'light';
|
|
103
|
+
return {
|
|
104
|
+
primary: primaryColor,
|
|
105
|
+
background: backgroundColor,
|
|
106
|
+
text: textColor,
|
|
107
|
+
// Semantic colors
|
|
108
|
+
userBubble: primaryColor,
|
|
109
|
+
botBubble: isLight ? '#ffffff' : '#2d3748',
|
|
110
|
+
userText: '#ffffff',
|
|
111
|
+
botText: isLight ? '#1f2937' : '#f9fafb',
|
|
112
|
+
inputBackground: isLight ? '#f9fafb' : '#2d3748',
|
|
113
|
+
inputBorder: isLight ? '#e5e7eb' : '#4a5568',
|
|
114
|
+
inputText: isLight ? '#1f2937' : '#f9fafb',
|
|
115
|
+
headerBackground: primaryColor,
|
|
116
|
+
headerText: '#ffffff',
|
|
117
|
+
errorBackground: '#fef2f2',
|
|
118
|
+
errorText: '#991b1b',
|
|
119
|
+
badge: '#ef4444',
|
|
120
|
+
loadingIndicator: primaryColor,
|
|
121
|
+
// Neutral colors
|
|
122
|
+
gray50: '#f9fafb',
|
|
123
|
+
gray100: '#f3f4f6',
|
|
124
|
+
gray200: '#e5e7eb',
|
|
125
|
+
gray300: '#d1d5db',
|
|
126
|
+
gray400: '#9ca3af',
|
|
127
|
+
gray500: '#6b7280',
|
|
128
|
+
gray600: '#4b5563',
|
|
129
|
+
gray700: '#374151',
|
|
130
|
+
gray800: '#1f2937',
|
|
131
|
+
gray900: '#111827'
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Create complete theme from backend widget config
|
|
137
|
+
*/
|
|
138
|
+
exports.createThemeColors = createThemeColors;
|
|
139
|
+
const createTheme = (primaryColor = '#4ade80', backgroundColor = '#ffffff', textColor = '#1f2937', themeMode = 'light') => {
|
|
140
|
+
return {
|
|
141
|
+
colors: createThemeColors(primaryColor, backgroundColor, textColor, themeMode),
|
|
142
|
+
typography: defaultTypography,
|
|
143
|
+
spacing: defaultSpacing,
|
|
144
|
+
borderRadius: defaultBorderRadius,
|
|
145
|
+
shadows: defaultShadows,
|
|
146
|
+
animations: defaultAnimations
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
exports.createTheme = createTheme;
|
|
150
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultTypography","exports","fontSizes","xs","sm","base","lg","xl","fontWeights","normal","medium","semibold","bold","lineHeights","tight","relaxed","defaultSpacing","md","defaultBorderRadius","full","defaultShadows","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","defaultAnimations","fast","slow","createThemeColors","primaryColor","backgroundColor","textColor","theme","isLight","primary","background","text","userBubble","botBubble","userText","botText","inputBackground","inputBorder","inputText","headerBackground","headerText","errorBackground","errorText","badge","loadingIndicator","gray50","gray100","gray200","gray300","gray400","gray500","gray600","gray700","gray800","gray900","createTheme","themeMode","colors","typography","spacing","borderRadius","shadows","animations"],"sources":["theme.ts"],"sourcesContent":["/**\n * Theme Configuration\n * Centralized design tokens for the SDK\n * Colors are sourced from backend widget config\n */\n\nexport interface ThemeColors {\n primary: string;\n background: string;\n text: string;\n // Semantic colors\n userBubble: string;\n botBubble: string;\n userText: string;\n botText: string;\n inputBackground: string;\n inputBorder: string;\n inputText: string;\n headerBackground: string;\n headerText: string;\n errorBackground: string;\n errorText: string;\n badge: string;\n loadingIndicator: string;\n // Neutral colors\n gray50: string;\n gray100: string;\n gray200: string;\n gray300: string;\n gray400: string;\n gray500: string;\n gray600: string;\n gray700: string;\n gray800: string;\n gray900: string;\n}\n\nexport interface Typography {\n fontSizes: {\n xs: number;\n sm: number;\n base: number;\n lg: number;\n xl: number;\n '2xl': number;\n '3xl': number;\n };\n fontWeights: {\n normal: '400';\n medium: '500';\n semibold: '600';\n bold: '700';\n };\n lineHeights: {\n tight: number;\n normal: number;\n relaxed: number;\n };\n}\n\nexport interface Spacing {\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n '2xl': number;\n '3xl': number;\n}\n\nexport interface BorderRadius {\n sm: number;\n md: number;\n lg: number;\n xl: number;\n full: number;\n}\n\nexport interface Shadows {\n sm: {\n shadowColor: string;\n shadowOffset: { width: number; height: number };\n shadowOpacity: number;\n shadowRadius: number;\n elevation: number;\n };\n md: {\n shadowColor: string;\n shadowOffset: { width: number; height: number };\n shadowOpacity: number;\n shadowRadius: number;\n elevation: number;\n };\n lg: {\n shadowColor: string;\n shadowOffset: { width: number; height: number };\n shadowOpacity: number;\n shadowRadius: number;\n elevation: number;\n };\n}\n\nexport interface AnimationDurations {\n fast: number;\n normal: number;\n slow: number;\n}\n\nexport interface Theme {\n colors: ThemeColors;\n typography: Typography;\n spacing: Spacing;\n borderRadius: BorderRadius;\n shadows: Shadows;\n animations: AnimationDurations;\n}\n\n// Default typography (constant across themes)\nexport const defaultTypography: Typography = {\n fontSizes: {\n xs: 12,\n sm: 14,\n base: 15,\n lg: 16,\n xl: 18,\n '2xl': 20,\n '3xl': 24,\n },\n fontWeights: {\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n },\n lineHeights: {\n tight: 1.2,\n normal: 1.5,\n relaxed: 1.75,\n },\n};\n\n// Default spacing (constant across themes)\nexport const defaultSpacing: Spacing = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 16,\n xl: 20,\n '2xl': 24,\n '3xl': 32,\n};\n\n// Default border radius (constant across themes)\nexport const defaultBorderRadius: BorderRadius = {\n sm: 4,\n md: 8,\n lg: 12,\n xl: 16,\n full: 9999,\n};\n\n// Default shadows (constant across themes)\nexport const defaultShadows: Shadows = {\n sm: {\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 1 },\n shadowOpacity: 0.1,\n shadowRadius: 2,\n elevation: 2,\n },\n md: {\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 2 },\n shadowOpacity: 0.15,\n shadowRadius: 4,\n elevation: 4,\n },\n lg: {\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 4 },\n shadowOpacity: 0.2,\n shadowRadius: 8,\n elevation: 8,\n },\n};\n\n// Default animation durations (constant across themes)\nexport const defaultAnimations: AnimationDurations = {\n fast: 150,\n normal: 300,\n slow: 500,\n};\n\n/**\n * Create theme colors from backend widget config\n */\nexport const createThemeColors = (\n primaryColor: string,\n backgroundColor: string,\n textColor: string,\n theme: 'light' | 'dark' = 'light'\n): ThemeColors => {\n const isLight = theme === 'light';\n\n return {\n primary: primaryColor,\n background: backgroundColor,\n text: textColor,\n // Semantic colors\n userBubble: primaryColor,\n botBubble: isLight ? '#ffffff' : '#2d3748',\n userText: '#ffffff',\n botText: isLight ? '#1f2937' : '#f9fafb',\n inputBackground: isLight ? '#f9fafb' : '#2d3748',\n inputBorder: isLight ? '#e5e7eb' : '#4a5568',\n inputText: isLight ? '#1f2937' : '#f9fafb',\n headerBackground: primaryColor,\n headerText: '#ffffff',\n errorBackground: '#fef2f2',\n errorText: '#991b1b',\n badge: '#ef4444',\n loadingIndicator: primaryColor,\n // Neutral colors\n gray50: '#f9fafb',\n gray100: '#f3f4f6',\n gray200: '#e5e7eb',\n gray300: '#d1d5db',\n gray400: '#9ca3af',\n gray500: '#6b7280',\n gray600: '#4b5563',\n gray700: '#374151',\n gray800: '#1f2937',\n gray900: '#111827',\n };\n};\n\n/**\n * Create complete theme from backend widget config\n */\nexport const createTheme = (\n primaryColor: string = '#4ade80',\n backgroundColor: string = '#ffffff',\n textColor: string = '#1f2937',\n themeMode: 'light' | 'dark' = 'light'\n): Theme => {\n return {\n colors: createThemeColors(primaryColor, backgroundColor, textColor, themeMode),\n typography: defaultTypography,\n spacing: defaultSpacing,\n borderRadius: defaultBorderRadius,\n shadows: defaultShadows,\n animations: defaultAnimations,\n };\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;;AAiHA;AACO,MAAMA,iBAA6B,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EAC1CE,SAAS,EAAE;IACRC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,IAAI,EAAE,EAAE;IACRC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACN,KAAK,EAAE,EAAE;IACT,KAAK,EAAE;EACV,CAAC;EACDC,WAAW,EAAE;IACVC,MAAM,EAAE,KAAK;IACbC,MAAM,EAAE,KAAK;IACbC,QAAQ,EAAE,KAAK;IACfC,IAAI,EAAE;EACT,CAAC;EACDC,WAAW,EAAE;IACVC,KAAK,EAAE,GAAG;IACVL,MAAM,EAAE,GAAG;IACXM,OAAO,EAAE;EACZ;AACH,CAAC;;AAED;AACO,MAAMC,cAAuB,GAAAf,OAAA,CAAAe,cAAA,GAAG;EACpCb,EAAE,EAAE,CAAC;EACLC,EAAE,EAAE,CAAC;EACLa,EAAE,EAAE,EAAE;EACNX,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACN,KAAK,EAAE,EAAE;EACT,KAAK,EAAE;AACV,CAAC;;AAED;AACO,MAAMW,mBAAiC,GAAAjB,OAAA,CAAAiB,mBAAA,GAAG;EAC9Cd,EAAE,EAAE,CAAC;EACLa,EAAE,EAAE,CAAC;EACLX,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNY,IAAI,EAAE;AACT,CAAC;;AAED;AACO,MAAMC,cAAuB,GAAAnB,OAAA,CAAAmB,cAAA,GAAG;EACpChB,EAAE,EAAE;IACDiB,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE;MAAEC,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;IACrC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AE,SAAS;IACrBC,eAAe,EAAE,SAAS;IAC1BC,SAAS,EAAE,SAAS;IACpBC,KAAK,EAAE,SAAS;IAChBC,gBAAgB,EAAEpB,YAAY;IAC9B;IACAqB,MAAM,EAAE,SAAS;IACjBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE;EACZ,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AAFA7D,OAAA,CAAA8B,iBAAA,GAAAA,iBAAA;AAGO,MAAMgC,WAAW,GAAGA,CACxB/B,YAAoB,GAAG,SAAS,EAChCC,eAAuB,GAAG,SAAS,EACnCC,SAAiB,GAAG,SAAS,EAC7B8B,SAA2B,GAAG,OAAO,KAC5B;EACT,OAAO;IACJC,MAAM,EAAElC,iBAAiB,CAACC,YAAY,EAAEC,eAAe,EAAEC,SAAS,EAAE8B,SAAS,CAAC;IAC9EE,UAAU,EAAElE,iBAAiB;IAC7BmE,OAAO,EAAEnD,cAAc;IACvBoD,YAAY,EAAElD,mBAAmB;IACjCmD,OAAO,EAAEjD,cAAc;IACvBkD,UAAU,EAAE1C;EACf,CAAC;AACJ,CAAC;AAAC3B,OAAA,CAAA8D,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["/**\n * Core types for Lingu React Native SDK\n */\n\nexport interface LinguConfig {\n apiKey: string;\n baseURL?: string;\n autoOpen?: boolean;\n onSessionStart?: (sessionId: string) => void;\n onSessionEnd?: (sessionId: string) => void;\n onMessageSent?: (message: string) => void;\n onMessageReceived?: (message: string) => void;\n}\n\nexport type ChatPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n\nexport type ThemeMode = 'light' | 'dark' | 'system';\n\nexport type MessageSender = 'user' | 'bot';\n\nexport interface Message {\n id: string;\n text: string;\n sender: MessageSender;\n timestamp: Date;\n}\n\nexport interface WidgetConfig {\n widgetPosition: ChatPosition;\n widgetSize: 'small' | 'medium' | 'large';\n theme: ThemeMode;\n primaryColor: string;\n backgroundColor: string;\n textColor: string;\n brandName?: string;\n brandLogo?: string;\n greetingMessage: string;\n}\n\nexport interface SessionData {\n sessionId: string;\n startedAt: Date;\n lastActivity: Date;\n}\n\nexport interface ApiResponse<T> {\n success: boolean;\n data: T;\n error?: string;\n}\n\nexport interface ChatResponse {\n message: string;\n context?: any[];\n}\n\nexport interface SessionResponse {\n sessionId: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.typingDotAnimation = exports.slideUp = exports.scaleIn = exports.pulse = exports.messageEntrance = exports.fadeOut = exports.fadeIn = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* Animation Utilities
|
|
10
|
+
* Reusable animation functions for SDK components
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Fade in animation
|
|
15
|
+
*/
|
|
16
|
+
const fadeIn = (animatedValue, duration = 300, toValue = 1) => {
|
|
17
|
+
return _reactNative.Animated.timing(animatedValue, {
|
|
18
|
+
toValue,
|
|
19
|
+
duration,
|
|
20
|
+
easing: _reactNative.Easing.out(_reactNative.Easing.ease),
|
|
21
|
+
useNativeDriver: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Fade out animation
|
|
27
|
+
*/
|
|
28
|
+
exports.fadeIn = fadeIn;
|
|
29
|
+
const fadeOut = (animatedValue, duration = 300, toValue = 0) => {
|
|
30
|
+
return _reactNative.Animated.timing(animatedValue, {
|
|
31
|
+
toValue,
|
|
32
|
+
duration,
|
|
33
|
+
easing: _reactNative.Easing.in(_reactNative.Easing.ease),
|
|
34
|
+
useNativeDriver: true
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Slide up animation (for messages)
|
|
40
|
+
*/
|
|
41
|
+
exports.fadeOut = fadeOut;
|
|
42
|
+
const slideUp = (animatedValue, duration = 300) => {
|
|
43
|
+
return _reactNative.Animated.timing(animatedValue, {
|
|
44
|
+
toValue: 0,
|
|
45
|
+
duration,
|
|
46
|
+
easing: _reactNative.Easing.out(_reactNative.Easing.cubic),
|
|
47
|
+
useNativeDriver: true
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Scale animation (for FAB entrance)
|
|
53
|
+
*/
|
|
54
|
+
exports.slideUp = slideUp;
|
|
55
|
+
const scaleIn = animatedValue => {
|
|
56
|
+
return _reactNative.Animated.spring(animatedValue, {
|
|
57
|
+
toValue: 1,
|
|
58
|
+
friction: 8,
|
|
59
|
+
tension: 40,
|
|
60
|
+
useNativeDriver: true
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Pulse animation (for unread badge on FAB)
|
|
66
|
+
*/
|
|
67
|
+
exports.scaleIn = scaleIn;
|
|
68
|
+
const pulse = animatedValue => {
|
|
69
|
+
return _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(animatedValue, {
|
|
70
|
+
toValue: 1.2,
|
|
71
|
+
duration: 500,
|
|
72
|
+
easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
|
|
73
|
+
useNativeDriver: true
|
|
74
|
+
}), _reactNative.Animated.timing(animatedValue, {
|
|
75
|
+
toValue: 1,
|
|
76
|
+
duration: 500,
|
|
77
|
+
easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
|
|
78
|
+
useNativeDriver: true
|
|
79
|
+
})]));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Typing indicator animation (for the dots)
|
|
84
|
+
*/
|
|
85
|
+
exports.pulse = pulse;
|
|
86
|
+
const typingDotAnimation = (animatedValue, delay = 0) => {
|
|
87
|
+
return _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.delay(delay), _reactNative.Animated.timing(animatedValue, {
|
|
88
|
+
toValue: -8,
|
|
89
|
+
duration: 400,
|
|
90
|
+
easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
|
|
91
|
+
useNativeDriver: true
|
|
92
|
+
}), _reactNative.Animated.timing(animatedValue, {
|
|
93
|
+
toValue: 0,
|
|
94
|
+
duration: 400,
|
|
95
|
+
easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
|
|
96
|
+
useNativeDriver: true
|
|
97
|
+
})]));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Message entrance animation (slide up + fade in)
|
|
102
|
+
*/
|
|
103
|
+
exports.typingDotAnimation = typingDotAnimation;
|
|
104
|
+
const messageEntrance = (translateY, opacity, duration = 300) => {
|
|
105
|
+
return _reactNative.Animated.parallel([_reactNative.Animated.timing(translateY, {
|
|
106
|
+
toValue: 0,
|
|
107
|
+
duration,
|
|
108
|
+
easing: _reactNative.Easing.out(_reactNative.Easing.cubic),
|
|
109
|
+
useNativeDriver: true
|
|
110
|
+
}), _reactNative.Animated.timing(opacity, {
|
|
111
|
+
toValue: 1,
|
|
112
|
+
duration,
|
|
113
|
+
easing: _reactNative.Easing.out(_reactNative.Easing.ease),
|
|
114
|
+
useNativeDriver: true
|
|
115
|
+
})]);
|
|
116
|
+
};
|
|
117
|
+
exports.messageEntrance = messageEntrance;
|
|
118
|
+
//# sourceMappingURL=animations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","fadeIn","animatedValue","duration","toValue","Animated","timing","easing","Easing","out","ease","useNativeDriver","exports","fadeOut","in","slideUp","cubic","scaleIn","spring","friction","tension","pulse","loop","sequence","inOut","typingDotAnimation","delay","messageEntrance","translateY","opacity","parallel"],"sources":["animations.ts"],"sourcesContent":["/**\n * Animation Utilities\n * Reusable animation functions for SDK components\n */\n\nimport { Animated, Easing } from 'react-native';\n\n/**\n * Fade in animation\n */\nexport const fadeIn = (\n animatedValue: Animated.Value,\n duration: number = 300,\n toValue: number = 1\n): Animated.CompositeAnimation => {\n return Animated.timing(animatedValue, {\n toValue,\n duration,\n easing: Easing.out(Easing.ease),\n useNativeDriver: true,\n });\n};\n\n/**\n * Fade out animation\n */\nexport const fadeOut = (\n animatedValue: Animated.Value,\n duration: number = 300,\n toValue: number = 0\n): Animated.CompositeAnimation => {\n return Animated.timing(animatedValue, {\n toValue,\n duration,\n easing: Easing.in(Easing.ease),\n useNativeDriver: true,\n });\n};\n\n/**\n * Slide up animation (for messages)\n */\nexport const slideUp = (\n animatedValue: Animated.Value,\n duration: number = 300\n): Animated.CompositeAnimation => {\n return Animated.timing(animatedValue, {\n toValue: 0,\n duration,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n });\n};\n\n/**\n * Scale animation (for FAB entrance)\n */\nexport const scaleIn = (\n animatedValue: Animated.Value\n): Animated.CompositeAnimation => {\n return Animated.spring(animatedValue, {\n toValue: 1,\n friction: 8,\n tension: 40,\n useNativeDriver: true,\n });\n};\n\n/**\n * Pulse animation (for unread badge on FAB)\n */\nexport const pulse = (\n animatedValue: Animated.Value\n): Animated.CompositeAnimation => {\n return Animated.loop(\n Animated.sequence([\n Animated.timing(animatedValue, {\n toValue: 1.2,\n duration: 500,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(animatedValue, {\n toValue: 1,\n duration: 500,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ])\n );\n};\n\n/**\n * Typing indicator animation (for the dots)\n */\nexport const typingDotAnimation = (\n animatedValue: Animated.Value,\n delay: number = 0\n): Animated.CompositeAnimation => {\n return Animated.loop(\n Animated.sequence([\n Animated.delay(delay),\n Animated.timing(animatedValue, {\n toValue: -8,\n duration: 400,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(animatedValue, {\n toValue: 0,\n duration: 400,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ])\n );\n};\n\n/**\n * Message entrance animation (slide up + fade in)\n */\nexport const messageEntrance = (\n translateY: Animated.Value,\n opacity: Animated.Value,\n duration: number = 300\n): Animated.CompositeAnimation => {\n return Animated.parallel([\n Animated.timing(translateY, {\n toValue: 0,\n duration,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }),\n Animated.timing(opacity, {\n toValue: 1,\n duration,\n easing: Easing.out(Easing.ease),\n useNativeDriver: true,\n }),\n ]);\n};\n"],"mappings":";;;;;;AAKA,IAAAA,YAAA,GAAAC,OAAA;AALA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,CACnBC,aAA6B,EAC7BC,QAAgB,GAAG,GAAG,EACtBC,OAAe,GAAG,CAAC,KACY;EAC/B,OAAOC,qBAAQ,CAACC,MAAM,CAACJ,aAAa,EAAE;IACnCE,OAAO;IACPD,QAAQ;IACRI,MAAM,EAAEC,mBAAM,CAACC,GAAG,CAACD,mBAAM,CAACE,IAAI,CAAC;IAC/BC,eAAe,EAAE;EACpB,CAAC,CAAC;AACL,CAAC;;AAED;AACA;AACA;AAFAC,OAAA,CAAAX,MAAA,GAAAA,MAAA;AAGO,MAAMY,OAAO,GAAGA,CACpBX,aAA6B,EAC7BC,QAAgB,GAAG,GAAG,EACtBC,OAAe,GAAG,CAAC,KACY;EAC/B,OAAOC,qBAAQ,CAACC,MAAM,CAACJ,aAAa,EAAE;IACnCE,OAAO;IACPD,QAAQ;IACRI,MAAM,EAAEC,mBAAM,CAACM,EAAE,CA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VD,QAAQ;IACRI,MAAM,EAAEC,mBAAM,CAACC,GAAG,CAACD,mBAAM,CAACE,IAAI,CAAC;IAC/BC,eAAe,EAAE;EACpB,CAAC,CAAC,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAe,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.truncate = exports.isLightColor = exports.getContrastingColor = exports.formatTime = exports.formatRelativeTime = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Formatting Utilities
|
|
9
|
+
* Helper functions for formatting data in the SDK
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Format a date to relative time (e.g., "just now", "2m ago", "1h ago")
|
|
14
|
+
*/
|
|
15
|
+
const formatRelativeTime = date => {
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
|
18
|
+
if (diffInSeconds < 10) {
|
|
19
|
+
return 'just now';
|
|
20
|
+
}
|
|
21
|
+
if (diffInSeconds < 60) {
|
|
22
|
+
return `${diffInSeconds}s ago`;
|
|
23
|
+
}
|
|
24
|
+
const diffInMinutes = Math.floor(diffInSeconds / 60);
|
|
25
|
+
if (diffInMinutes < 60) {
|
|
26
|
+
return `${diffInMinutes}m ago`;
|
|
27
|
+
}
|
|
28
|
+
const diffInHours = Math.floor(diffInMinutes / 60);
|
|
29
|
+
if (diffInHours < 24) {
|
|
30
|
+
return `${diffInHours}h ago`;
|
|
31
|
+
}
|
|
32
|
+
const diffInDays = Math.floor(diffInHours / 24);
|
|
33
|
+
if (diffInDays < 7) {
|
|
34
|
+
return `${diffInDays}d ago`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// For dates older than a week, show the actual date
|
|
38
|
+
return date.toLocaleDateString();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Format time for display (e.g., "2:30 PM")
|
|
43
|
+
*/
|
|
44
|
+
exports.formatRelativeTime = formatRelativeTime;
|
|
45
|
+
const formatTime = date => {
|
|
46
|
+
return date.toLocaleTimeString([], {
|
|
47
|
+
hour: '2-digit',
|
|
48
|
+
minute: '2-digit'
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Truncate text with ellipsis
|
|
54
|
+
*/
|
|
55
|
+
exports.formatTime = formatTime;
|
|
56
|
+
const truncate = (text, maxLength) => {
|
|
57
|
+
if (text.length <= maxLength) {
|
|
58
|
+
return text;
|
|
59
|
+
}
|
|
60
|
+
return text.substring(0, maxLength - 3) + '...';
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Check if a color is light or dark (for text contrast)
|
|
65
|
+
*/
|
|
66
|
+
exports.truncate = truncate;
|
|
67
|
+
const isLightColor = color => {
|
|
68
|
+
// Remove # if present
|
|
69
|
+
const hex = color.replace('#', '');
|
|
70
|
+
|
|
71
|
+
// Convert to RGB
|
|
72
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
73
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
74
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
75
|
+
|
|
76
|
+
// Calculate luminance
|
|
77
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
78
|
+
return luminance > 0.5;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get contrasting text color for a background
|
|
83
|
+
*/
|
|
84
|
+
exports.isLightColor = isLightColor;
|
|
85
|
+
const getContrastingColor = backgroundColor => {
|
|
86
|
+
return isLightColor(backgroundColor) ? '#000000' : '#ffffff';
|
|
87
|
+
};
|
|
88
|
+
exports.getContrastingColor = getContrastingColor;
|
|
89
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatRelativeTime","date","now","Date","diffInSeconds","Math","floor","getTime","diffInMinutes","diffInHours","diffInDays","toLocaleDateString","exports","formatTime","toLocaleTimeString","hour","minute","truncate","text","maxLength","length","substring","isLightColor","color","hex","replace","r","parseInt","g","b","luminance","getContrastingColor","backgroundColor"],"sources":["formatters.ts"],"sourcesContent":["/**\n * Formatting Utilities\n * Helper functions for formatting data in the SDK\n */\n\n/**\n * Format a date to relative time (e.g., \"just now\", \"2m ago\", \"1h ago\")\n */\nexport const formatRelativeTime = (date: Date): string => {\n const now = new Date();\n const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);\n\n if (diffInSeconds < 10) {\n return 'just now';\n }\n\n if (diffInSeconds < 60) {\n return `${diffInSeconds}s ago`;\n }\n\n const diffInMinutes = Math.floor(diffInSeconds / 60);\n if (diffInMinutes < 60) {\n return `${diffInMinutes}m ago`;\n }\n\n const diffInHours = Math.floor(diffInMinutes / 60);\n if (diffInHours < 24) {\n return `${diffInHours}h ago`;\n }\n\n const diffInDays = Math.floor(diffInHours / 24);\n if (diffInDays < 7) {\n return `${diffInDays}d ago`;\n }\n\n // For dates older than a week, show the actual date\n return date.toLocaleDateString();\n};\n\n/**\n * Format time for display (e.g., \"2:30 PM\")\n */\nexport const formatTime = (date: Date): string => {\n return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });\n};\n\n/**\n * Truncate text with ellipsis\n */\nexport const truncate = (text: string, maxLength: number): string => {\n if (text.length <= maxLength) {\n return text;\n }\n return text.substring(0, maxLength - 3) + '...';\n};\n\n/**\n * Check if a color is light or dark (for text contrast)\n */\nexport const isLightColor = (color: string): boolean => {\n // Remove # if present\n const hex = color.replace('#', '');\n\n // Convert to RGB\n const r = parseInt(hex.substring(0, 2), 16);\n const g = parseInt(hex.substring(2, 4), 16);\n const b = parseInt(hex.substring(4, 6), 16);\n\n // Calculate luminance\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n\n return luminance > 0.5;\n};\n\n/**\n * Get contrasting text color for a background\n */\nexport const getContrastingColor = (backgroundColor: string): string => {\n return isLightColor(backgroundColor) ? '#000000' : '#ffffff';\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAIC,IAAU,IAAa;EACvD,MAAMC,GAAG,GAAG,IAAIC,IAAI,CAAC,CAAC;EACtB,MAAMC,aAAa,GAAGC,IAAI,CAACC,KAAK,CAAC,CAACJ,GAAG,CAACK,OAAO,CAAC,CAAC,GAAGN,IAAI,CAACM,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC;EAEzE,IAAIH,aAAa,GAAG,EAAE,EAAE;IACrB,OAAO,UAAU;EACpB;EAEA,IAAIA,aAAa,GAAG,EAAE,EAAE;IACrB,OAAO,GAAGA,aAAa,OAAO;EACjC;EAEA,MAAMI,aAAa,GAAGH,IAAI,CAACC,KAAK,CAACF,aAAa,GAAG,EAAE,CAAC;EACpD,IAAII,aAAa,GAAG,EAAE,EAAE;IACrB,OAAO,GAAGA,aAAa,OAAO;EACjC;EAEA,MAAMC,WAAW,GAAGJ,IAAI,CAACC,KAAK,CAACE,aAAa,GAAG,EAAE,CAAC;EAClD,IAAIC,WAAW,GAAG,EAAE,EAAE;IACnB,OAAO,GAAGA,WAAW,OAAO;EAC/B;EAEA,MAAMC,UAAU,GAAGL,IAAI,CAACC,KAAK,CAACG,WAAW,GAAG,EAAE,CAAC;EAC/C,IAAIC,UAAU,GAAG,CAAC,EAAE;IACjB,OAAO,GAAGA,UAAU,OAAO;EAC9B;;EAEA;EACA,OAAOT,IAAI,CAACU,kBAAkB,CAAC,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AAFAC,OAAA,CAAAZ,kBAAA,GAAAA,kBAAA;AAGO,MAAMa,UAAU,GAAIZ,IAAU,IAAa;EAC/C,OAAOA,IAAI,CAACa,kBAAkB,CAAC,E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mB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _animations = require("./animations");
|
|
7
|
+
Object.keys(_animations).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _animations[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _animations[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _formatters = require("./formatters");
|
|
18
|
+
Object.keys(_formatters).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _formatters[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _formatters[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_animations","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_formatters"],"sources":["index.ts"],"sourcesContent":["/**\n * Utilities exports\n */\n\nexport * from './animations';\nexport * from './formatters';\n"],"mappings":";;;;;AAIA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|