@oxyhq/services 6.9.4 → 6.9.5

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 (71) hide show
  1. package/lib/commonjs/ui/client.js +0 -7
  2. package/lib/commonjs/ui/client.js.map +1 -1
  3. package/lib/commonjs/ui/components/feedback/FormInput.js.map +1 -1
  4. package/lib/commonjs/ui/components/icon/OxyIcon.js.map +1 -1
  5. package/lib/commonjs/ui/components/types.js +4 -0
  6. package/lib/commonjs/ui/screens/AppInfoScreen.js +66 -60
  7. package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
  8. package/lib/commonjs/ui/screens/FileManagementScreen.js +139 -79
  9. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  10. package/lib/commonjs/ui/screens/SessionManagementScreen.js +39 -29
  11. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  12. package/lib/module/ui/client.js +0 -1
  13. package/lib/module/ui/client.js.map +1 -1
  14. package/lib/module/ui/components/feedback/FormInput.js.map +1 -1
  15. package/lib/module/ui/components/icon/OxyIcon.js.map +1 -1
  16. package/lib/module/ui/components/types.js +2 -0
  17. package/lib/module/ui/screens/AppInfoScreen.js +66 -60
  18. package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
  19. package/lib/module/ui/screens/FileManagementScreen.js +139 -79
  20. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  21. package/lib/module/ui/screens/SessionManagementScreen.js +39 -29
  22. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  23. package/lib/typescript/commonjs/ui/client.d.ts +0 -1
  24. package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
  25. package/lib/typescript/commonjs/ui/components/types.d.ts +18 -17
  26. package/lib/typescript/commonjs/ui/components/types.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/ui/screens/AppInfoScreen.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/ui/screens/FileManagementScreen.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/ui/screens/SessionManagementScreen.d.ts.map +1 -1
  30. package/lib/typescript/module/ui/client.d.ts +0 -1
  31. package/lib/typescript/module/ui/client.d.ts.map +1 -1
  32. package/lib/typescript/module/ui/components/types.d.ts +18 -17
  33. package/lib/typescript/module/ui/components/types.d.ts.map +1 -1
  34. package/lib/typescript/module/ui/screens/AppInfoScreen.d.ts.map +1 -1
  35. package/lib/typescript/module/ui/screens/FileManagementScreen.d.ts.map +1 -1
  36. package/lib/typescript/module/ui/screens/SessionManagementScreen.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/ui/client.ts +0 -1
  39. package/src/ui/components/feedback/FormInput.tsx +1 -1
  40. package/src/ui/components/icon/OxyIcon.tsx +1 -1
  41. package/src/ui/components/types.tsx +19 -17
  42. package/src/ui/screens/AppInfoScreen.tsx +63 -61
  43. package/src/ui/screens/FileManagementScreen.tsx +130 -121
  44. package/src/ui/screens/SessionManagementScreen.tsx +30 -28
  45. package/lib/commonjs/ui/components/AnimationExample.js +0 -213
  46. package/lib/commonjs/ui/components/AnimationExample.js.map +0 -1
  47. package/lib/commonjs/ui/components/ErrorBoundary.js +0 -145
  48. package/lib/commonjs/ui/components/ErrorBoundary.js.map +0 -1
  49. package/lib/commonjs/ui/components/WebOxyProvider.js +0 -106
  50. package/lib/commonjs/ui/components/WebOxyProvider.js.map +0 -1
  51. package/lib/module/ui/components/AnimationExample.js +0 -209
  52. package/lib/module/ui/components/AnimationExample.js.map +0 -1
  53. package/lib/module/ui/components/ErrorBoundary.js +0 -139
  54. package/lib/module/ui/components/ErrorBoundary.js.map +0 -1
  55. package/lib/module/ui/components/WebOxyProvider.js +0 -102
  56. package/lib/module/ui/components/WebOxyProvider.js.map +0 -1
  57. package/lib/typescript/commonjs/ui/components/AnimationExample.d.ts +0 -4
  58. package/lib/typescript/commonjs/ui/components/AnimationExample.d.ts.map +0 -1
  59. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts +0 -31
  60. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts.map +0 -1
  61. package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts +0 -52
  62. package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts.map +0 -1
  63. package/lib/typescript/module/ui/components/AnimationExample.d.ts +0 -4
  64. package/lib/typescript/module/ui/components/AnimationExample.d.ts.map +0 -1
  65. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts +0 -31
  66. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts.map +0 -1
  67. package/lib/typescript/module/ui/components/WebOxyProvider.d.ts +0 -52
  68. package/lib/typescript/module/ui/components/WebOxyProvider.d.ts.map +0 -1
  69. package/src/ui/components/AnimationExample.tsx +0 -195
  70. package/src/ui/components/ErrorBoundary.tsx +0 -154
  71. package/src/ui/components/WebOxyProvider.tsx +0 -117
@@ -1,52 +0,0 @@
1
- /**
2
- * WebOxyProvider - Lightweight provider for pure React/Next.js apps
3
- *
4
- * Use this provider for web apps that DON'T use Expo/React Native.
5
- * For Expo apps (native + web), use `OxyProvider` instead - it works on all platforms.
6
- *
7
- * Features:
8
- * - Automatic cross-domain SSO via FedCM (Chrome 108+, Safari 16.4+, Edge 108+)
9
- * - No React Native dependencies
10
- * - Session management
11
- * - All useOxy/useAuth functionality
12
- *
13
- * Usage:
14
- * ```tsx
15
- * // For pure React/Next.js apps (no Expo):
16
- * import { WebOxyProvider, useAuth } from '@oxyhq/services';
17
- *
18
- * function App() {
19
- * return (
20
- * <WebOxyProvider baseURL="https://api.oxy.so">
21
- * <YourApp />
22
- * </WebOxyProvider>
23
- * );
24
- * }
25
- *
26
- * // For Expo apps (native + web), use OxyProvider instead:
27
- * import { OxyProvider, useAuth } from '@oxyhq/services';
28
- * ```
29
- */
30
- import { type FC, type ReactNode } from 'react';
31
- import { createQueryClient } from '../hooks/queryClient';
32
- export interface WebOxyProviderProps {
33
- children: ReactNode;
34
- baseURL: string;
35
- authWebUrl?: string;
36
- onAuthStateChange?: (user: any) => void;
37
- storageKeyPrefix?: string;
38
- queryClient?: ReturnType<typeof createQueryClient>;
39
- }
40
- /**
41
- * OxyProvider for web applications
42
- *
43
- * Features:
44
- * - Automatic cross-domain SSO via FedCM (browser-native identity API)
45
- * - Works across different TLDs (alia.onl, mention.earth, homiio.com, etc.)
46
- * - Session persistence in localStorage
47
- * - TanStack Query for data fetching
48
- * - No React Native dependencies
49
- */
50
- declare const WebOxyProvider: FC<WebOxyProviderProps>;
51
- export default WebOxyProvider;
52
- //# sourceMappingURL=WebOxyProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebOxyProvider.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/WebOxyProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAA+B,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CACpD;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA2D3C,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,4 +0,0 @@
1
- import type React from 'react';
2
- declare const AnimationExample: React.FC;
3
- export default AnimationExample;
4
- //# sourceMappingURL=AnimationExample.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AnimationExample.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/AnimationExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EA6G7B,CAAC;AAqEF,eAAe,gBAAgB,CAAC"}
@@ -1,31 +0,0 @@
1
- import React, { Component, type ErrorInfo, type ReactNode } from 'react';
2
- interface Props {
3
- children: ReactNode;
4
- fallback?: ReactNode;
5
- onError?: (error: Error, errorInfo: ErrorInfo) => void;
6
- }
7
- interface State {
8
- hasError: boolean;
9
- error: Error | null;
10
- errorInfo: ErrorInfo | null;
11
- }
12
- /**
13
- * Error Boundary Component
14
- *
15
- * Catches JavaScript errors anywhere in the child component tree,
16
- * logs those errors, and displays a fallback UI instead of crashing.
17
- *
18
- * Usage:
19
- * <ErrorBoundary>
20
- * <YourComponent />
21
- * </ErrorBoundary>
22
- */
23
- export declare class ErrorBoundary extends Component<Props, State> {
24
- constructor(props: Props);
25
- static getDerivedStateFromError(error: Error): Partial<State>;
26
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
27
- handleReset: () => void;
28
- render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
29
- }
30
- export default ErrorBoundary;
31
- //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzE,UAAU,KAAK;IACX,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CAC1D;AAED,UAAU,KAAK;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBAC1C,KAAK,EAAE,KAAK;IASxB,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ7D,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAkBpD,WAAW,aAMT;IAEF,MAAM;CAiCT;AAiDD,eAAe,aAAa,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * WebOxyProvider - Lightweight provider for pure React/Next.js apps
3
- *
4
- * Use this provider for web apps that DON'T use Expo/React Native.
5
- * For Expo apps (native + web), use `OxyProvider` instead - it works on all platforms.
6
- *
7
- * Features:
8
- * - Automatic cross-domain SSO via FedCM (Chrome 108+, Safari 16.4+, Edge 108+)
9
- * - No React Native dependencies
10
- * - Session management
11
- * - All useOxy/useAuth functionality
12
- *
13
- * Usage:
14
- * ```tsx
15
- * // For pure React/Next.js apps (no Expo):
16
- * import { WebOxyProvider, useAuth } from '@oxyhq/services';
17
- *
18
- * function App() {
19
- * return (
20
- * <WebOxyProvider baseURL="https://api.oxy.so">
21
- * <YourApp />
22
- * </WebOxyProvider>
23
- * );
24
- * }
25
- *
26
- * // For Expo apps (native + web), use OxyProvider instead:
27
- * import { OxyProvider, useAuth } from '@oxyhq/services';
28
- * ```
29
- */
30
- import { type FC, type ReactNode } from 'react';
31
- import { createQueryClient } from '../hooks/queryClient';
32
- export interface WebOxyProviderProps {
33
- children: ReactNode;
34
- baseURL: string;
35
- authWebUrl?: string;
36
- onAuthStateChange?: (user: any) => void;
37
- storageKeyPrefix?: string;
38
- queryClient?: ReturnType<typeof createQueryClient>;
39
- }
40
- /**
41
- * OxyProvider for web applications
42
- *
43
- * Features:
44
- * - Automatic cross-domain SSO via FedCM (browser-native identity API)
45
- * - Works across different TLDs (alia.onl, mention.earth, homiio.com, etc.)
46
- * - Session persistence in localStorage
47
- * - TanStack Query for data fetching
48
- * - No React Native dependencies
49
- */
50
- declare const WebOxyProvider: FC<WebOxyProviderProps>;
51
- export default WebOxyProvider;
52
- //# sourceMappingURL=WebOxyProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebOxyProvider.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/WebOxyProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAA+B,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CACpD;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA2D3C,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,195 +0,0 @@
1
- import type React from 'react';
2
- import { useState } from 'react';
3
- import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
4
- import Animated, {
5
- useSharedValue,
6
- useAnimatedStyle,
7
- withTiming,
8
- withSpring,
9
- withSequence,
10
- withDelay,
11
- interpolateColor,
12
- runOnJS,
13
- Easing,
14
- } from 'react-native-reanimated';
15
-
16
- // Example component showcasing improved Reanimated usage
17
- const AnimationExample: React.FC = () => {
18
- const [currentStep, setCurrentStep] = useState(0);
19
-
20
- // Shared values for better performance
21
- const opacity = useSharedValue(1);
22
- const scale = useSharedValue(1);
23
- const translateX = useSharedValue(0);
24
- const rotation = useSharedValue(0);
25
- const progress = useSharedValue(0);
26
- const colorProgress = useSharedValue(0);
27
-
28
- // Animated styles with proper interpolation
29
- const animatedStyle = useAnimatedStyle(() => {
30
- return {
31
- opacity: opacity.value,
32
- transform: [
33
- { scale: scale.value },
34
- { translateX: translateX.value },
35
- { rotate: `${rotation.value}deg` },
36
- ],
37
- };
38
- });
39
-
40
- const progressStyle = useAnimatedStyle(() => {
41
- return {
42
- width: `${progress.value * 100}%`,
43
- backgroundColor: interpolateColor(
44
- colorProgress.value,
45
- [0, 1],
46
- ['#3498db', '#e74c3c']
47
- ),
48
- };
49
- });
50
-
51
- const backgroundStyle = useAnimatedStyle(() => {
52
- return {
53
- backgroundColor: interpolateColor(
54
- colorProgress.value,
55
- [0, 1],
56
- ['#ecf0f1', '#f39c12']
57
- ),
58
- };
59
- });
60
-
61
- // Complex animation sequence
62
- const animateSequence = () => {
63
- 'worklet';
64
-
65
- // Staggered animations for smooth transitions
66
- opacity.value = withTiming(0.5, { duration: 200 });
67
- scale.value = withSpring(0.8, { damping: 15, stiffness: 150 });
68
-
69
- // Delayed follow-up animations
70
- translateX.value = withDelay(
71
- 100,
72
- withSpring(50, { damping: 20, stiffness: 100 }, (finished) => {
73
- if (finished) {
74
- translateX.value = withSpring(0, { damping: 15, stiffness: 150 });
75
- }
76
- })
77
- );
78
-
79
- // Sequential animations
80
- rotation.value = withSequence(
81
- withTiming(10, { duration: 150 }),
82
- withTiming(-10, { duration: 150 }),
83
- withTiming(0, { duration: 150 })
84
- );
85
-
86
- // Progress animation with easing
87
- progress.value = withTiming(1, {
88
- duration: 1000,
89
- easing: Easing.out(Easing.exp)
90
- }, (finished) => {
91
- if (finished) {
92
- runOnJS(setCurrentStep)(currentStep + 1);
93
- }
94
- });
95
-
96
- // Color transition
97
- colorProgress.value = withTiming(1, { duration: 800 });
98
-
99
- // Reset animations
100
- setTimeout(() => {
101
- opacity.value = withSpring(1);
102
- scale.value = withSpring(1);
103
- progress.value = withTiming(0, { duration: 500 });
104
- colorProgress.value = withTiming(0, { duration: 500 });
105
- }, 1500);
106
- };
107
-
108
- return (
109
- <Animated.View style={[styles.container, backgroundStyle]}>
110
- <Text style={styles.title}>Advanced Reanimated Example</Text>
111
- <Text style={styles.subtitle}>Step: {currentStep}</Text>
112
-
113
- <Animated.View style={[styles.box, animatedStyle]}>
114
- <Text style={styles.boxText}>Animated Box</Text>
115
- </Animated.View>
116
-
117
- <View style={styles.progressContainer}>
118
- <Animated.View style={[styles.progressBar, progressStyle]} />
119
- </View>
120
-
121
- <TouchableOpacity style={styles.button} onPress={animateSequence}>
122
- <Text style={styles.buttonText}>Animate Sequence</Text>
123
- </TouchableOpacity>
124
- </Animated.View>
125
- );
126
- };
127
-
128
- const styles = StyleSheet.create({
129
- container: {
130
- flex: 1,
131
- justifyContent: 'center',
132
- alignItems: 'center',
133
- padding: 20,
134
- },
135
- title: {
136
- fontSize: 24,
137
- fontWeight: 'bold',
138
- marginBottom: 10,
139
- color: '#2c3e50',
140
- },
141
- subtitle: {
142
- fontSize: 16,
143
- marginBottom: 30,
144
- color: '#7f8c8d',
145
- },
146
- box: {
147
- width: 150,
148
- height: 150,
149
- backgroundColor: '#3498db',
150
- borderRadius: 20,
151
- justifyContent: 'center',
152
- alignItems: 'center',
153
- marginBottom: 30,
154
- shadowColor: '#000',
155
- shadowOffset: { width: 0, height: 4 },
156
- shadowOpacity: 0.3,
157
- shadowRadius: 8,
158
- elevation: 8,
159
- },
160
- boxText: {
161
- color: 'white',
162
- fontSize: 16,
163
- fontWeight: 'bold',
164
- },
165
- progressContainer: {
166
- width: '100%',
167
- height: 10,
168
- backgroundColor: '#ecf0f1',
169
- borderRadius: 5,
170
- marginBottom: 30,
171
- overflow: 'hidden',
172
- },
173
- progressBar: {
174
- height: '100%',
175
- borderRadius: 5,
176
- },
177
- button: {
178
- backgroundColor: '#e74c3c',
179
- paddingHorizontal: 30,
180
- paddingVertical: 15,
181
- borderRadius: 25,
182
- shadowColor: '#000',
183
- shadowOffset: { width: 0, height: 2 },
184
- shadowOpacity: 0.2,
185
- shadowRadius: 4,
186
- elevation: 4,
187
- },
188
- buttonText: {
189
- color: 'white',
190
- fontSize: 16,
191
- fontWeight: 'bold',
192
- },
193
- });
194
-
195
- export default AnimationExample;
@@ -1,154 +0,0 @@
1
- import React, { Component, type ErrorInfo, type ReactNode } from 'react';
2
- import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
3
-
4
- interface Props {
5
- children: ReactNode;
6
- fallback?: ReactNode;
7
- onError?: (error: Error, errorInfo: ErrorInfo) => void;
8
- }
9
-
10
- interface State {
11
- hasError: boolean;
12
- error: Error | null;
13
- errorInfo: ErrorInfo | null;
14
- }
15
-
16
- /**
17
- * Error Boundary Component
18
- *
19
- * Catches JavaScript errors anywhere in the child component tree,
20
- * logs those errors, and displays a fallback UI instead of crashing.
21
- *
22
- * Usage:
23
- * <ErrorBoundary>
24
- * <YourComponent />
25
- * </ErrorBoundary>
26
- */
27
- export class ErrorBoundary extends Component<Props, State> {
28
- constructor(props: Props) {
29
- super(props);
30
- this.state = {
31
- hasError: false,
32
- error: null,
33
- errorInfo: null,
34
- };
35
- }
36
-
37
- static getDerivedStateFromError(error: Error): Partial<State> {
38
- // Update state so the next render will show the fallback UI
39
- return {
40
- hasError: true,
41
- error,
42
- };
43
- }
44
-
45
- componentDidCatch(error: Error, errorInfo: ErrorInfo) {
46
- // Log error to console in development
47
- if (__DEV__) {
48
- console.error('ErrorBoundary caught an error:', error, errorInfo);
49
- }
50
-
51
- // Call optional error handler
52
- if (this.props.onError) {
53
- this.props.onError(error, errorInfo);
54
- }
55
-
56
- // Update state with error info
57
- this.setState({
58
- error,
59
- errorInfo,
60
- });
61
- }
62
-
63
- handleReset = () => {
64
- this.setState({
65
- hasError: false,
66
- error: null,
67
- errorInfo: null,
68
- });
69
- };
70
-
71
- render() {
72
- if (this.state.hasError) {
73
- // Use custom fallback if provided
74
- if (this.props.fallback) {
75
- return this.props.fallback;
76
- }
77
-
78
- // Default fallback UI
79
- return (
80
- <View style={styles.container}>
81
- <View style={styles.errorContainer}>
82
- <Text style={styles.errorTitle}>Something went wrong</Text>
83
- <Text style={styles.errorMessage}>
84
- {this.state.error?.message || 'An unexpected error occurred'}
85
- </Text>
86
- {__DEV__ && this.state.errorInfo && (
87
- <Text style={styles.errorDetails}>
88
- {this.state.errorInfo.componentStack}
89
- </Text>
90
- )}
91
- <TouchableOpacity
92
- style={styles.resetButton}
93
- onPress={this.handleReset}
94
- >
95
- <Text style={styles.resetButtonText}>Try Again</Text>
96
- </TouchableOpacity>
97
- </View>
98
- </View>
99
- );
100
- }
101
-
102
- return this.props.children;
103
- }
104
- }
105
-
106
- const styles = StyleSheet.create({
107
- container: {
108
- flex: 1,
109
- justifyContent: 'center',
110
- alignItems: 'center',
111
- padding: 20,
112
- backgroundColor: '#fff',
113
- },
114
- errorContainer: {
115
- maxWidth: 400,
116
- width: '100%',
117
- padding: 20,
118
- borderRadius: 8,
119
- backgroundColor: '#f5f5f5',
120
- borderWidth: 1,
121
- borderColor: '#e0e0e0',
122
- },
123
- errorTitle: {
124
- fontSize: 20,
125
- fontWeight: 'bold',
126
- marginBottom: 10,
127
- color: '#d32f2f',
128
- },
129
- errorMessage: {
130
- fontSize: 14,
131
- marginBottom: 15,
132
- color: '#666',
133
- },
134
- errorDetails: {
135
- fontSize: 12,
136
- marginBottom: 15,
137
- color: '#999',
138
- fontFamily: 'monospace',
139
- },
140
- resetButton: {
141
- backgroundColor: '#007AFF',
142
- padding: 12,
143
- borderRadius: 6,
144
- alignItems: 'center',
145
- },
146
- resetButtonText: {
147
- color: '#fff',
148
- fontSize: 16,
149
- fontWeight: '600',
150
- },
151
- });
152
-
153
- export default ErrorBoundary;
154
-
@@ -1,117 +0,0 @@
1
- /**
2
- * WebOxyProvider - Lightweight provider for pure React/Next.js apps
3
- *
4
- * Use this provider for web apps that DON'T use Expo/React Native.
5
- * For Expo apps (native + web), use `OxyProvider` instead - it works on all platforms.
6
- *
7
- * Features:
8
- * - Automatic cross-domain SSO via FedCM (Chrome 108+, Safari 16.4+, Edge 108+)
9
- * - No React Native dependencies
10
- * - Session management
11
- * - All useOxy/useAuth functionality
12
- *
13
- * Usage:
14
- * ```tsx
15
- * // For pure React/Next.js apps (no Expo):
16
- * import { WebOxyProvider, useAuth } from '@oxyhq/services';
17
- *
18
- * function App() {
19
- * return (
20
- * <WebOxyProvider baseURL="https://api.oxy.so">
21
- * <YourApp />
22
- * </WebOxyProvider>
23
- * );
24
- * }
25
- *
26
- * // For Expo apps (native + web), use OxyProvider instead:
27
- * import { OxyProvider, useAuth } from '@oxyhq/services';
28
- * ```
29
- */
30
-
31
- import { useEffect, useRef, useState, type FC, type ReactNode } from 'react';
32
- import { OxyContextProvider } from '../context/OxyContext';
33
- import { QueryClientProvider } from '@tanstack/react-query';
34
- import { createQueryClient } from '../hooks/queryClient';
35
- import { createPlatformStorage, type StorageInterface } from '../utils/storageHelpers';
36
-
37
- export interface WebOxyProviderProps {
38
- children: ReactNode;
39
- baseURL: string;
40
- authWebUrl?: string;
41
- onAuthStateChange?: (user: any) => void;
42
- storageKeyPrefix?: string;
43
- queryClient?: ReturnType<typeof createQueryClient>;
44
- }
45
-
46
- /**
47
- * OxyProvider for web applications
48
- *
49
- * Features:
50
- * - Automatic cross-domain SSO via FedCM (browser-native identity API)
51
- * - Works across different TLDs (alia.onl, mention.earth, homiio.com, etc.)
52
- * - Session persistence in localStorage
53
- * - TanStack Query for data fetching
54
- * - No React Native dependencies
55
- */
56
- const WebOxyProvider: FC<WebOxyProviderProps> = ({
57
- children,
58
- baseURL,
59
- authWebUrl,
60
- onAuthStateChange,
61
- storageKeyPrefix,
62
- queryClient: providedQueryClient,
63
- }) => {
64
- const storageRef = useRef<StorageInterface | null>(null);
65
- const queryClientRef = useRef<ReturnType<typeof createQueryClient> | null>(null);
66
- const [queryClient, setQueryClient] = useState<ReturnType<typeof createQueryClient> | null>(null);
67
-
68
- useEffect(() => {
69
- if (providedQueryClient) {
70
- queryClientRef.current = providedQueryClient;
71
- setQueryClient(providedQueryClient);
72
- return;
73
- }
74
-
75
- let mounted = true;
76
- createPlatformStorage()
77
- .then((storage) => {
78
- if (mounted && !queryClientRef.current) {
79
- storageRef.current = storage;
80
- const client = createQueryClient(storage);
81
- queryClientRef.current = client;
82
- setQueryClient(client);
83
- }
84
- })
85
- .catch(() => {
86
- if (mounted && !queryClientRef.current) {
87
- const client = createQueryClient(null);
88
- queryClientRef.current = client;
89
- setQueryClient(client);
90
- }
91
- });
92
-
93
- return () => {
94
- mounted = false;
95
- };
96
- }, [providedQueryClient]);
97
-
98
- // Wait for query client to be ready
99
- if (!queryClient) {
100
- return null;
101
- }
102
-
103
- return (
104
- <QueryClientProvider client={queryClient}>
105
- <OxyContextProvider
106
- baseURL={baseURL}
107
- authWebUrl={authWebUrl}
108
- storageKeyPrefix={storageKeyPrefix}
109
- onAuthStateChange={onAuthStateChange}
110
- >
111
- {children}
112
- </OxyContextProvider>
113
- </QueryClientProvider>
114
- );
115
- };
116
-
117
- export default WebOxyProvider;