@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.
Files changed (135) hide show
  1. package/README.md +279 -0
  2. package/lib/commonjs/components/LinguChat.js +283 -0
  3. package/lib/commonjs/components/LinguChat.js.map +1 -0
  4. package/lib/commonjs/components/LinguWebView.js +203 -0
  5. package/lib/commonjs/components/LinguWebView.js.map +1 -0
  6. package/lib/commonjs/components/MessageBubble.js +91 -0
  7. package/lib/commonjs/components/MessageBubble.js.map +1 -0
  8. package/lib/commonjs/components/NativeChatUI.js +192 -0
  9. package/lib/commonjs/components/NativeChatUI.js.map +1 -0
  10. package/lib/commonjs/components/TypingIndicator.js +92 -0
  11. package/lib/commonjs/components/TypingIndicator.js.map +1 -0
  12. package/lib/commonjs/context/LinguProvider.js +47 -0
  13. package/lib/commonjs/context/LinguProvider.js.map +1 -0
  14. package/lib/commonjs/context/index.js +17 -0
  15. package/lib/commonjs/context/index.js.map +1 -0
  16. package/lib/commonjs/hooks/useLinguChat.js +295 -0
  17. package/lib/commonjs/hooks/useLinguChat.js.map +1 -0
  18. package/lib/commonjs/index.js +129 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/services/LinguAPI.js +196 -0
  21. package/lib/commonjs/services/LinguAPI.js.map +1 -0
  22. package/lib/commonjs/services/SessionManager.js +131 -0
  23. package/lib/commonjs/services/SessionManager.js.map +1 -0
  24. package/lib/commonjs/services/StorageManager.js +116 -0
  25. package/lib/commonjs/services/StorageManager.js.map +1 -0
  26. package/lib/commonjs/theme/ThemeProvider.js +49 -0
  27. package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
  28. package/lib/commonjs/theme/index.js +28 -0
  29. package/lib/commonjs/theme/index.js.map +1 -0
  30. package/lib/commonjs/theme/theme.js +150 -0
  31. package/lib/commonjs/theme/theme.js.map +1 -0
  32. package/lib/commonjs/types/index.js +2 -0
  33. package/lib/commonjs/types/index.js.map +1 -0
  34. package/lib/commonjs/utils/animations.js +118 -0
  35. package/lib/commonjs/utils/animations.js.map +1 -0
  36. package/lib/commonjs/utils/formatters.js +89 -0
  37. package/lib/commonjs/utils/formatters.js.map +1 -0
  38. package/lib/commonjs/utils/index.js +28 -0
  39. package/lib/commonjs/utils/index.js.map +1 -0
  40. package/lib/module/components/LinguChat.js +277 -0
  41. package/lib/module/components/LinguChat.js.map +1 -0
  42. package/lib/module/components/LinguWebView.js +195 -0
  43. package/lib/module/components/LinguWebView.js.map +1 -0
  44. package/lib/module/components/MessageBubble.js +83 -0
  45. package/lib/module/components/MessageBubble.js.map +1 -0
  46. package/lib/module/components/NativeChatUI.js +184 -0
  47. package/lib/module/components/NativeChatUI.js.map +1 -0
  48. package/lib/module/components/TypingIndicator.js +84 -0
  49. package/lib/module/components/TypingIndicator.js.map +1 -0
  50. package/lib/module/context/LinguProvider.js +38 -0
  51. package/lib/module/context/LinguProvider.js.map +1 -0
  52. package/lib/module/context/index.js +6 -0
  53. package/lib/module/context/index.js.map +1 -0
  54. package/lib/module/hooks/useLinguChat.js +288 -0
  55. package/lib/module/hooks/useLinguChat.js.map +1 -0
  56. package/lib/module/index.js +30 -0
  57. package/lib/module/index.js.map +1 -0
  58. package/lib/module/services/LinguAPI.js +190 -0
  59. package/lib/module/services/LinguAPI.js.map +1 -0
  60. package/lib/module/services/SessionManager.js +124 -0
  61. package/lib/module/services/SessionManager.js.map +1 -0
  62. package/lib/module/services/StorageManager.js +108 -0
  63. package/lib/module/services/StorageManager.js.map +1 -0
  64. package/lib/module/theme/ThemeProvider.js +40 -0
  65. package/lib/module/theme/ThemeProvider.js.map +1 -0
  66. package/lib/module/theme/index.js +7 -0
  67. package/lib/module/theme/index.js.map +1 -0
  68. package/lib/module/theme/theme.js +142 -0
  69. package/lib/module/theme/theme.js.map +1 -0
  70. package/lib/module/types/index.js +2 -0
  71. package/lib/module/types/index.js.map +1 -0
  72. package/lib/module/utils/animations.js +106 -0
  73. package/lib/module/utils/animations.js.map +1 -0
  74. package/lib/module/utils/formatters.js +78 -0
  75. package/lib/module/utils/formatters.js.map +1 -0
  76. package/lib/module/utils/index.js +7 -0
  77. package/lib/module/utils/index.js.map +1 -0
  78. package/lib/typescript/components/LinguChat.d.ts +18 -0
  79. package/lib/typescript/components/LinguChat.d.ts.map +1 -0
  80. package/lib/typescript/components/LinguWebView.d.ts +16 -0
  81. package/lib/typescript/components/LinguWebView.d.ts.map +1 -0
  82. package/lib/typescript/components/MessageBubble.d.ts +13 -0
  83. package/lib/typescript/components/MessageBubble.d.ts.map +1 -0
  84. package/lib/typescript/components/NativeChatUI.d.ts +16 -0
  85. package/lib/typescript/components/NativeChatUI.d.ts.map +1 -0
  86. package/lib/typescript/components/TypingIndicator.d.ts +7 -0
  87. package/lib/typescript/components/TypingIndicator.d.ts.map +1 -0
  88. package/lib/typescript/context/LinguProvider.d.ts +32 -0
  89. package/lib/typescript/context/LinguProvider.d.ts.map +1 -0
  90. package/lib/typescript/context/index.d.ts +5 -0
  91. package/lib/typescript/context/index.d.ts.map +1 -0
  92. package/lib/typescript/hooks/useLinguChat.d.ts +18 -0
  93. package/lib/typescript/hooks/useLinguChat.d.ts.map +1 -0
  94. package/lib/typescript/index.d.ts +19 -0
  95. package/lib/typescript/index.d.ts.map +1 -0
  96. package/lib/typescript/services/LinguAPI.d.ts +39 -0
  97. package/lib/typescript/services/LinguAPI.d.ts.map +1 -0
  98. package/lib/typescript/services/SessionManager.d.ts +46 -0
  99. package/lib/typescript/services/SessionManager.d.ts.map +1 -0
  100. package/lib/typescript/services/StorageManager.d.ts +36 -0
  101. package/lib/typescript/services/StorageManager.d.ts.map +1 -0
  102. package/lib/typescript/theme/ThemeProvider.d.ts +23 -0
  103. package/lib/typescript/theme/ThemeProvider.d.ts.map +1 -0
  104. package/lib/typescript/theme/index.d.ts +6 -0
  105. package/lib/typescript/theme/index.d.ts.map +1 -0
  106. package/lib/typescript/theme/theme.d.ts +130 -0
  107. package/lib/typescript/theme/theme.d.ts.map +1 -0
  108. package/lib/typescript/types/index.d.ts +50 -0
  109. package/lib/typescript/types/index.d.ts.map +1 -0
  110. package/lib/typescript/utils/animations.d.ts +34 -0
  111. package/lib/typescript/utils/animations.d.ts.map +1 -0
  112. package/lib/typescript/utils/formatters.d.ts +25 -0
  113. package/lib/typescript/utils/formatters.d.ts.map +1 -0
  114. package/lib/typescript/utils/index.d.ts +6 -0
  115. package/lib/typescript/utils/index.d.ts.map +1 -0
  116. package/package.json +98 -0
  117. package/src/components/LinguChat.tsx +309 -0
  118. package/src/components/LinguWebView.tsx +216 -0
  119. package/src/components/MessageBubble.tsx +120 -0
  120. package/src/components/NativeChatUI.tsx +247 -0
  121. package/src/components/TypingIndicator.tsx +84 -0
  122. package/src/context/LinguProvider.tsx +53 -0
  123. package/src/context/index.ts +5 -0
  124. package/src/hooks/useLinguChat.ts +314 -0
  125. package/src/index.ts +43 -0
  126. package/src/services/LinguAPI.ts +214 -0
  127. package/src/services/SessionManager.ts +131 -0
  128. package/src/services/StorageManager.ts +111 -0
  129. package/src/theme/ThemeProvider.tsx +58 -0
  130. package/src/theme/index.ts +6 -0
  131. package/src/theme/theme.ts +254 -0
  132. package/src/types/index.ts +59 -0
  133. package/src/utils/animations.ts +141 -0
  134. package/src/utils/formatters.ts +80 -0
  135. package/src/utils/index.ts +6 -0
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Session Manager
3
+ * Handles session lifecycle, heartbeat, and cleanup
4
+ */
5
+ import { LinguAPI } from './LinguAPI';
6
+ export declare class SessionManager {
7
+ private api;
8
+ private sessionId;
9
+ private heartbeatInterval;
10
+ private heartbeatIntervalMs;
11
+ private onSessionStart?;
12
+ private onSessionEnd?;
13
+ constructor(api: LinguAPI, callbacks?: {
14
+ onSessionStart?: (sessionId: string) => void;
15
+ onSessionEnd?: (sessionId: string) => void;
16
+ });
17
+ /**
18
+ * Start a new session
19
+ */
20
+ start(): Promise<string>;
21
+ /**
22
+ * End the current session
23
+ */
24
+ end(): Promise<void>;
25
+ /**
26
+ * Start sending heartbeats to keep session alive
27
+ */
28
+ private startHeartbeat;
29
+ /**
30
+ * Stop sending heartbeats
31
+ */
32
+ private stopHeartbeat;
33
+ /**
34
+ * Get the current session ID
35
+ */
36
+ getSessionId(): string | null;
37
+ /**
38
+ * Check if a session is active
39
+ */
40
+ isActive(): boolean;
41
+ /**
42
+ * Cleanup on unmount
43
+ */
44
+ cleanup(): void;
45
+ }
46
+ //# sourceMappingURL=SessionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionManager.d.ts","sourceRoot":"","sources":["../../../src/services/SessionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,cAAc;IACxB,OAAO,CAAC,GAAG,CAAW;IACtB,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,iBAAiB,CAA+B;IACxD,OAAO,CAAC,mBAAmB,CAAiB;IAE5C,OAAO,CAAC,cAAc,CAAC,CAA8B;IACrD,OAAO,CAAC,YAAY,CAAC,CAA8B;gBAGhD,GAAG,EAAE,QAAQ,EACb,SAAS,CAAC,EAAE;QACT,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;QAC7C,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;KAC7C;IAOJ;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAuB9B;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB1B;;OAEG;IACH,OAAO,CAAC,cAAc;IActB;;OAEG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI;IAI7B;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,OAAO,IAAI,IAAI;CAQjB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Storage Manager
3
+ * Handles message persistence using AsyncStorage
4
+ */
5
+ import type { Message } from '../types';
6
+ export declare class StorageManager {
7
+ /**
8
+ * Save messages for a session
9
+ */
10
+ static saveMessages(sessionId: string, messages: Message[]): Promise<void>;
11
+ /**
12
+ * Load messages for a session
13
+ */
14
+ static loadMessages(sessionId: string): Promise<Message[]>;
15
+ /**
16
+ * Clear messages for a session
17
+ */
18
+ static clearMessages(sessionId: string): Promise<void>;
19
+ /**
20
+ * Get all stored session IDs
21
+ */
22
+ static getAllSessionIds(): Promise<string[]>;
23
+ /**
24
+ * Save current session ID
25
+ */
26
+ static saveCurrentSessionId(sessionId: string): Promise<void>;
27
+ /**
28
+ * Get current session ID
29
+ */
30
+ static getCurrentSessionId(): Promise<string | null>;
31
+ /**
32
+ * Clear all chat data
33
+ */
34
+ static clearAll(): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=StorageManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageManager.d.ts","sourceRoot":"","sources":["../../../src/services/StorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxC,qBAAa,cAAc;IACxB;;OAEG;WACU,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWhF;;OAEG;WACU,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBhE;;OAEG;WACU,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D;;OAEG;WACU,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAYlD;;OAEG;WACU,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnE;;OAEG;WACU,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAS1D;;OAEG;WACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CASxC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Theme Provider
3
+ * Provides theme context to all child components
4
+ * Theme is derived from backend widget configuration
5
+ */
6
+ import React, { ReactNode } from 'react';
7
+ import { Theme } from './theme';
8
+ import type { WidgetConfig } from '../types';
9
+ interface ThemeContextValue {
10
+ theme: Theme;
11
+ config: WidgetConfig | null;
12
+ }
13
+ interface ThemeProviderProps {
14
+ config: WidgetConfig | null;
15
+ children: ReactNode;
16
+ }
17
+ export declare const ThemeProvider: React.FC<ThemeProviderProps>;
18
+ /**
19
+ * Hook to access theme context
20
+ */
21
+ export declare const useTheme: () => ThemeContextValue;
22
+ export {};
23
+ //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,EAAsC,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAe,KAAK,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,UAAU,iBAAiB;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B;AAID,UAAU,kBAAkB;IACzB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAwBtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAO,iBAM3B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Theme exports
3
+ */
4
+ export * from './theme';
5
+ export * from './ThemeProvider';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Theme Configuration
3
+ * Centralized design tokens for the SDK
4
+ * Colors are sourced from backend widget config
5
+ */
6
+ export interface ThemeColors {
7
+ primary: string;
8
+ background: string;
9
+ text: string;
10
+ userBubble: string;
11
+ botBubble: string;
12
+ userText: string;
13
+ botText: string;
14
+ inputBackground: string;
15
+ inputBorder: string;
16
+ inputText: string;
17
+ headerBackground: string;
18
+ headerText: string;
19
+ errorBackground: string;
20
+ errorText: string;
21
+ badge: string;
22
+ loadingIndicator: string;
23
+ gray50: string;
24
+ gray100: string;
25
+ gray200: string;
26
+ gray300: string;
27
+ gray400: string;
28
+ gray500: string;
29
+ gray600: string;
30
+ gray700: string;
31
+ gray800: string;
32
+ gray900: string;
33
+ }
34
+ export interface Typography {
35
+ fontSizes: {
36
+ xs: number;
37
+ sm: number;
38
+ base: number;
39
+ lg: number;
40
+ xl: number;
41
+ '2xl': number;
42
+ '3xl': number;
43
+ };
44
+ fontWeights: {
45
+ normal: '400';
46
+ medium: '500';
47
+ semibold: '600';
48
+ bold: '700';
49
+ };
50
+ lineHeights: {
51
+ tight: number;
52
+ normal: number;
53
+ relaxed: number;
54
+ };
55
+ }
56
+ export interface Spacing {
57
+ xs: number;
58
+ sm: number;
59
+ md: number;
60
+ lg: number;
61
+ xl: number;
62
+ '2xl': number;
63
+ '3xl': number;
64
+ }
65
+ export interface BorderRadius {
66
+ sm: number;
67
+ md: number;
68
+ lg: number;
69
+ xl: number;
70
+ full: number;
71
+ }
72
+ export interface Shadows {
73
+ sm: {
74
+ shadowColor: string;
75
+ shadowOffset: {
76
+ width: number;
77
+ height: number;
78
+ };
79
+ shadowOpacity: number;
80
+ shadowRadius: number;
81
+ elevation: number;
82
+ };
83
+ md: {
84
+ shadowColor: string;
85
+ shadowOffset: {
86
+ width: number;
87
+ height: number;
88
+ };
89
+ shadowOpacity: number;
90
+ shadowRadius: number;
91
+ elevation: number;
92
+ };
93
+ lg: {
94
+ shadowColor: string;
95
+ shadowOffset: {
96
+ width: number;
97
+ height: number;
98
+ };
99
+ shadowOpacity: number;
100
+ shadowRadius: number;
101
+ elevation: number;
102
+ };
103
+ }
104
+ export interface AnimationDurations {
105
+ fast: number;
106
+ normal: number;
107
+ slow: number;
108
+ }
109
+ export interface Theme {
110
+ colors: ThemeColors;
111
+ typography: Typography;
112
+ spacing: Spacing;
113
+ borderRadius: BorderRadius;
114
+ shadows: Shadows;
115
+ animations: AnimationDurations;
116
+ }
117
+ export declare const defaultTypography: Typography;
118
+ export declare const defaultSpacing: Spacing;
119
+ export declare const defaultBorderRadius: BorderRadius;
120
+ export declare const defaultShadows: Shadows;
121
+ export declare const defaultAnimations: AnimationDurations;
122
+ /**
123
+ * Create theme colors from backend widget config
124
+ */
125
+ export declare const createThemeColors: (primaryColor: string, backgroundColor: string, textColor: string, theme?: "light" | "dark") => ThemeColors;
126
+ /**
127
+ * Create complete theme from backend widget config
128
+ */
129
+ export declare const createTheme: (primaryColor?: string, backgroundColor?: string, textColor?: string, themeMode?: "light" | "dark") => Theme;
130
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,W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E,YAAY,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,kBAAkB,CAAC;CACjC;AAGD,eAAO,MAAM,iBAAiB,EAAE,UAqB/B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,OAQ5B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,YAMjC,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,OAsB5B,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,kBAI/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,iBACb,MAAM,mBACH,MAAM,aACZ,MAAM,UACV,OAAO,GAAG,MAAM,KACvB,WAiCF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,kBACP,MAAM,oBACH,MAAM,cACZ,MAAM,cACN,OAAO,GAAG,MAAM,KAC3B,KASF,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Core types for Lingu React Native SDK
3
+ */
4
+ export interface LinguConfig {
5
+ apiKey: string;
6
+ baseURL?: string;
7
+ autoOpen?: boolean;
8
+ onSessionStart?: (sessionId: string) => void;
9
+ onSessionEnd?: (sessionId: string) => void;
10
+ onMessageSent?: (message: string) => void;
11
+ onMessageReceived?: (message: string) => void;
12
+ }
13
+ export type ChatPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
14
+ export type ThemeMode = 'light' | 'dark' | 'system';
15
+ export type MessageSender = 'user' | 'bot';
16
+ export interface Message {
17
+ id: string;
18
+ text: string;
19
+ sender: MessageSender;
20
+ timestamp: Date;
21
+ }
22
+ export interface WidgetConfig {
23
+ widgetPosition: ChatPosition;
24
+ widgetSize: 'small' | 'medium' | 'large';
25
+ theme: ThemeMode;
26
+ primaryColor: string;
27
+ backgroundColor: string;
28
+ textColor: string;
29
+ brandName?: string;
30
+ brandLogo?: string;
31
+ greetingMessage: string;
32
+ }
33
+ export interface SessionData {
34
+ sessionId: string;
35
+ startedAt: Date;
36
+ lastActivity: Date;
37
+ }
38
+ export interface ApiResponse<T> {
39
+ success: boolean;
40
+ data: T;
41
+ error?: string;
42
+ }
43
+ export interface ChatResponse {
44
+ message: string;
45
+ context?: any[];
46
+ }
47
+ export interface SessionResponse {
48
+ sessionId: string;
49
+ }
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAED,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAC;AAErF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,CAAC;AAE3C,MAAM,WAAW,OAAO;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC1B,cAAc,EAAE,YAAY,CAAC;IAC7B,UAAU,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzC,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC7B,SAAS,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Animation Utilities
3
+ * Reusable animation functions for SDK components
4
+ */
5
+ import { Animated } from 'react-native';
6
+ /**
7
+ * Fade in animation
8
+ */
9
+ export declare const fadeIn: (animatedValue: Animated.Value, duration?: number, toValue?: number) => Animated.CompositeAnimation;
10
+ /**
11
+ * Fade out animation
12
+ */
13
+ export declare const fadeOut: (animatedValue: Animated.Value, duration?: number, toValue?: number) => Animated.CompositeAnimation;
14
+ /**
15
+ * Slide up animation (for messages)
16
+ */
17
+ export declare const slideUp: (animatedValue: Animated.Value, duration?: number) => Animated.CompositeAnimation;
18
+ /**
19
+ * Scale animation (for FAB entrance)
20
+ */
21
+ export declare const scaleIn: (animatedValue: Animated.Value) => Animated.CompositeAnimation;
22
+ /**
23
+ * Pulse animation (for unread badge on FAB)
24
+ */
25
+ export declare const pulse: (animatedValue: Animated.Value) => Animated.CompositeAnimation;
26
+ /**
27
+ * Typing indicator animation (for the dots)
28
+ */
29
+ export declare const typingDotAnimation: (animatedValue: Animated.Value, delay?: number) => Animated.CompositeAnimation;
30
+ /**
31
+ * Message entrance animation (slide up + fade in)
32
+ */
33
+ export declare const messageEntrance: (translateY: Animated.Value, opacity: Animated.Value, duration?: number) => Animated.CompositeAnimation;
34
+ //# sourceMappingURL=animations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../../src/utils/animations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAU,MAAM,cAAc,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,MAAM,kBACD,QAAQ,CAAC,KAAK,aACnB,MAAM,YACP,MAAM,KACf,QAAQ,CAAC,kBAOX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,kBACF,QAAQ,CAAC,KAAK,aACnB,MAAM,YACP,MAAM,KACf,QAAQ,CAAC,kBAOX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,kBACF,QAAQ,CAAC,KAAK,aACnB,MAAM,KAChB,QAAQ,CAAC,kBAOX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,kBACF,QAAQ,CAAC,KAAK,KAC7B,QAAQ,CAAC,kBAOX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,kBACA,QAAQ,CAAC,KAAK,KAC7B,QAAQ,CAAC,kBAiBX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBACb,QAAQ,CAAC,KAAK,UACtB,MAAM,KACb,QAAQ,CAAC,kBAkBX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,eACb,QAAQ,CAAC,KAAK,WACjB,QAAQ,CAAC,KAAK,aACb,MAAM,KAChB,QAAQ,CAAC,kBAeX,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Formatting Utilities
3
+ * Helper functions for formatting data in the SDK
4
+ */
5
+ /**
6
+ * Format a date to relative time (e.g., "just now", "2m ago", "1h ago")
7
+ */
8
+ export declare const formatRelativeTime: (date: Date) => string;
9
+ /**
10
+ * Format time for display (e.g., "2:30 PM")
11
+ */
12
+ export declare const formatTime: (date: Date) => string;
13
+ /**
14
+ * Truncate text with ellipsis
15
+ */
16
+ export declare const truncate: (text: string, maxLength: number) => string;
17
+ /**
18
+ * Check if a color is light or dark (for text contrast)
19
+ */
20
+ export declare const isLightColor: (color: string) => boolean;
21
+ /**
22
+ * Get contrasting text color for a background
23
+ */
24
+ export declare const getContrastingColor: (backgroundColor: string) => string;
25
+ //# sourceMappingURL=formatters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,SAAU,IAAI,KAAG,MA6B/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,SAAU,IAAI,KAAG,MAEvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAU,MAAM,aAAa,MAAM,KAAG,MAK1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,OAa5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,oBAAqB,MAAM,KAAG,MAE7D,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utilities exports
3
+ */
4
+ export * from './animations';
5
+ export * from './formatters';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@uselingu/react-native-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Lingu AI Chat SDK for React Native - Hybrid approach with WebView UI and native API",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "types": "lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index.ts",
9
+ "source": "src/index.ts",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "!**/__tests__",
14
+ "!**/__fixtures__",
15
+ "!**/__mocks__",
16
+ "android",
17
+ "ios"
18
+ ],
19
+ "scripts": {
20
+ "typescript": "tsc --noEmit",
21
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
22
+ "format": "prettier --write \"**/*.{js,ts,tsx,json,md}\"",
23
+ "prepare": "bob build",
24
+ "test": "jest",
25
+ "example": "cd example && npm run ios"
26
+ },
27
+ "keywords": [
28
+ "react-native",
29
+ "chat",
30
+ "ai",
31
+ "lingu",
32
+ "customer-support",
33
+ "chatbot",
34
+ "widget"
35
+ ],
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/yourusername/lingu.git",
39
+ "directory": "packages/react-native-sdk"
40
+ },
41
+ "author": "Lingu Team <support@uselingu.app>",
42
+ "license": "MIT",
43
+ "bugs": {
44
+ "url": "https://github.com/yourusername/lingu/issues"
45
+ },
46
+ "homepage": "https://uselingu.app",
47
+ "publishConfig": {
48
+ "registry": "https://registry.npmjs.org/"
49
+ },
50
+ "peerDependencies": {
51
+ "react": "*",
52
+ "react-native": "*"
53
+ },
54
+ "dependencies": {
55
+ "@react-native-async-storage/async-storage": "^1.21.0",
56
+ "axios": "^1.6.5"
57
+ },
58
+ "devDependencies": {
59
+ "@react-native-community/bob": "^0.17.1",
60
+ "@types/jest": "^29.5.11",
61
+ "@types/react": "^18.2.48",
62
+ "@types/react-native": "^0.72.8",
63
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
64
+ "@typescript-eslint/parser": "^6.19.0",
65
+ "eslint": "^8.56.0",
66
+ "eslint-config-prettier": "^9.1.0",
67
+ "eslint-plugin-react": "^7.33.2",
68
+ "eslint-plugin-react-hooks": "^4.6.0",
69
+ "jest": "^29.7.0",
70
+ "prettier": "^3.2.4",
71
+ "react": "^18.2.0",
72
+ "react-native": "^0.73.2",
73
+ "react-native-webview": "^13.6.4",
74
+ "typescript": "^5.3.3"
75
+ },
76
+ "react-native-builder-bob": {
77
+ "source": "src",
78
+ "output": "lib",
79
+ "targets": [
80
+ "commonjs",
81
+ "module",
82
+ "typescript"
83
+ ]
84
+ },
85
+ "@react-native-community/bob": {
86
+ "source": "src",
87
+ "output": "lib",
88
+ "targets": [
89
+ "commonjs",
90
+ "module",
91
+ "typescript"
92
+ ]
93
+ },
94
+ "eslintIgnore": [
95
+ "node_modules/",
96
+ "lib/"
97
+ ]
98
+ }