@oxyhq/services 5.13.21 → 5.13.23

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 (67) hide show
  1. package/lib/commonjs/core/OxyServices.base.js +34 -21
  2. package/lib/commonjs/core/OxyServices.base.js.map +1 -1
  3. package/lib/commonjs/ui/components/ErrorBoundary.js +145 -0
  4. package/lib/commonjs/ui/components/ErrorBoundary.js.map +1 -0
  5. package/lib/commonjs/ui/navigation/OxyRouter.js +83 -30
  6. package/lib/commonjs/ui/navigation/OxyRouter.js.map +1 -1
  7. package/lib/commonjs/ui/screens/AccountCenterScreen.js +19 -14
  8. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  9. package/lib/commonjs/ui/screens/SessionManagementScreen.js +90 -77
  10. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  11. package/lib/commonjs/ui/screens/SignInScreen.js +1 -1
  12. package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
  13. package/lib/module/core/OxyServices.base.js +34 -21
  14. package/lib/module/core/OxyServices.base.js.map +1 -1
  15. package/lib/module/ui/components/ErrorBoundary.js +139 -0
  16. package/lib/module/ui/components/ErrorBoundary.js.map +1 -0
  17. package/lib/module/ui/navigation/OxyRouter.js +83 -31
  18. package/lib/module/ui/navigation/OxyRouter.js.map +1 -1
  19. package/lib/module/ui/screens/AccountCenterScreen.js +19 -14
  20. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  21. package/lib/module/ui/screens/SessionManagementScreen.js +91 -78
  22. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  23. package/lib/module/ui/screens/SignInScreen.js +1 -1
  24. package/lib/module/ui/screens/SignInScreen.js.map +1 -1
  25. package/lib/typescript/core/OxyServices.base.d.ts +16 -10
  26. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  27. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts +0 -2
  28. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  29. package/lib/typescript/core/mixins/OxyServices.assets.d.ts +0 -2
  30. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  31. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +0 -2
  32. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  33. package/lib/typescript/core/mixins/OxyServices.developer.d.ts +0 -2
  34. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  35. package/lib/typescript/core/mixins/OxyServices.devices.d.ts +0 -2
  36. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  37. package/lib/typescript/core/mixins/OxyServices.karma.d.ts +0 -2
  38. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  39. package/lib/typescript/core/mixins/OxyServices.language.d.ts +0 -2
  40. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  41. package/lib/typescript/core/mixins/OxyServices.location.d.ts +0 -2
  42. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  43. package/lib/typescript/core/mixins/OxyServices.payment.d.ts +0 -2
  44. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  45. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts +0 -2
  46. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  47. package/lib/typescript/core/mixins/OxyServices.totp.d.ts +0 -2
  48. package/lib/typescript/core/mixins/OxyServices.totp.d.ts.map +1 -1
  49. package/lib/typescript/core/mixins/OxyServices.user.d.ts +0 -2
  50. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  51. package/lib/typescript/core/mixins/OxyServices.utility.d.ts +0 -2
  52. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  53. package/lib/typescript/core/mixins/index.d.ts +0 -26
  54. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  55. package/lib/typescript/ui/components/ErrorBoundary.d.ts +31 -0
  56. package/lib/typescript/ui/components/ErrorBoundary.d.ts.map +1 -0
  57. package/lib/typescript/ui/navigation/OxyRouter.d.ts +3 -1
  58. package/lib/typescript/ui/navigation/OxyRouter.d.ts.map +1 -1
  59. package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
  60. package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
  61. package/package.json +1 -1
  62. package/src/core/OxyServices.base.ts +37 -22
  63. package/src/ui/components/ErrorBoundary.tsx +154 -0
  64. package/src/ui/navigation/OxyRouter.tsx +90 -29
  65. package/src/ui/screens/AccountCenterScreen.tsx +17 -14
  66. package/src/ui/screens/SessionManagementScreen.tsx +81 -69
  67. package/src/ui/screens/SignInScreen.tsx +1 -1
@@ -146,36 +146,49 @@ class OxyServicesBase {
146
146
  }
147
147
 
148
148
  /**
149
- * Wait for authentication to be ready (public method)
150
- * Useful for apps that want to ensure authentication is complete before proceeding
149
+ * Wait for authentication to be ready
150
+ *
151
+ * Optimized for high-scale usage with immediate synchronous check and adaptive polling.
152
+ * Returns immediately if token is already available (0ms delay), otherwise uses
153
+ * adaptive polling that starts fast (50ms) and gradually increases to reduce CPU usage.
154
+ *
155
+ * @param timeoutMs Maximum time to wait in milliseconds (default: 5000ms)
156
+ * @returns Promise that resolves to true if authentication is ready, false if timeout
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const isReady = await oxyServices.waitForAuth(3000);
161
+ * if (isReady) {
162
+ * // Proceed with authenticated operations
163
+ * }
164
+ * ```
151
165
  */
152
166
  async waitForAuth(timeoutMs = 5000) {
153
- return this.waitForAuthentication(timeoutMs);
154
- }
167
+ // Immediate synchronous check - no delay if token is ready
168
+ if (this.httpClient.hasAccessToken()) {
169
+ return true;
170
+ }
171
+ const startTime = performance.now();
172
+ const maxTime = startTime + timeoutMs;
155
173
 
156
- /**
157
- * Wait for authentication to be ready with timeout
158
- */
159
- async waitForAuthentication(timeoutMs = 5000) {
160
- const startTime = Date.now();
161
- const checkInterval = 100; // Check every 100ms
174
+ // Adaptive polling: start fast, then slow down to reduce CPU usage
175
+ let pollInterval = 50; // Start with 50ms
162
176
 
163
- while (Date.now() - startTime < timeoutMs) {
177
+ while (performance.now() < maxTime) {
178
+ await new Promise(resolve => setTimeout(resolve, pollInterval));
164
179
  if (this.httpClient.hasAccessToken()) {
165
180
  return true;
166
181
  }
167
- await new Promise(resolve => setTimeout(resolve, checkInterval));
182
+
183
+ // Increase interval after first few checks (adaptive polling)
184
+ // This reduces CPU usage for long waits while maintaining responsiveness
185
+ if (pollInterval < 200) {
186
+ pollInterval = Math.min(pollInterval * 1.5, 200);
187
+ }
168
188
  }
169
189
  return false;
170
190
  }
171
191
 
172
- /**
173
- * Check if the client has a valid access token
174
- */
175
- hasAccessToken() {
176
- return this.httpClient.hasAccessToken();
177
- }
178
-
179
192
  /**
180
193
  * Execute a function with automatic authentication retry logic
181
194
  * This handles the common case where API calls are made before authentication completes
@@ -192,7 +205,7 @@ class OxyServicesBase {
192
205
  if (!this.httpClient.hasAccessToken()) {
193
206
  if (attempt === 0) {
194
207
  // On first attempt, wait briefly for authentication to complete
195
- const authReady = await this.waitForAuthentication(authTimeoutMs);
208
+ const authReady = await this.waitForAuth(authTimeoutMs);
196
209
  if (!authReady) {
197
210
  throw new _OxyServices.OxyAuthenticationTimeoutError(operationName, authTimeoutMs);
198
211
  }
@@ -228,7 +241,7 @@ class OxyServicesBase {
228
241
  * Validate the current access token with the server
229
242
  */
230
243
  async validate() {
231
- if (!this.hasAccessToken()) {
244
+ if (!this.hasValidToken()) {
232
245
  return false;
233
246
  }
234
247
  try {
@@ -1 +1 @@
1
- {"version":3,"names":["_jwtDecode","require","_errorUtils","_HttpClient","_RequestManager","_OxyServices","OxyServicesBase","constructor","args","config","Error","cloudURL","httpClient","HttpClient","requestManager","RequestManager","__resetTokensForTests","makeRequest","method","url","data","options","request","getBaseURL","getClient","getMetrics","clearCache","clearCacheEntry","key","getCacheStats","getCloudURL","setTokens","accessToken","refreshToken","clearTokens","getCurrentUserId","getAccessToken","decoded","jwtDecode","userId","id","error","hasValidToken","hasAccessToken","waitForAuth","timeoutMs","waitForAuthentication","startTime","Date","now","checkInterval","Promise","resolve","setTimeout","withAuthRetry","operation","operationName","maxRetries","retryDelay","authTimeoutMs","attempt","authReady","OxyAuthenticationTimeoutError","OxyAuthenticationError","isLastAttempt","isAuthError","response","status","code","message","includes","handleError","validate","res","undefined","cache","retry","valid","api","handleHttpError","err","details","healthCheck","exports"],"sourceRoot":"../../../src","sources":["core/OxyServices.base.ts"],"mappings":";;;;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAVA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACO,MAAMK,eAAe,CAAC;EAM3BC,WAAWA,CAAC,GAAGC,IAAW,EAAE;IAC1B,MAAMC,MAAM,GAAGD,IAAI,CAAC,CAAC,CAAc;IACnC,IAAI,CAACC,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,uBAAuB,CAAC;IAC1C;IACA,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,QAAQ,GAAGF,MAAM,CAACE,QAAQ,IAAI,sBAAsB;;IAEzD;IACA,IAAI,CAACC,UAAU,GAAG,IAAIC,sBAAU,CAACJ,MAAM,CAAC;;IAExC;IACA,IAAI,CAACK,cAAc,GAAG,IAAIC,8BAAc,CAAC,IAAI,CAACH,UAAU,EAAEH,MAAM,CAAC;EACnE;;EAEA;EACA,OAAOO,qBAAqBA,CAAA,EAAS;IACnCH,sBAAU,CAACG,qBAAqB,CAAC,CAAC;EACpC;;EAEA;AACF;AACA;AACA;EACE,MAAaC,WAAWA,CACtBC,MAAmD,EACnDC,GAAW,EACXC,IAA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A,CAAA7E,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_jwtDecode","require","_errorUtils","_HttpClient","_RequestManager","_OxyServices","OxyServicesBase","constructor","args","config","Error","cloudURL","httpClient","HttpClient","requestManager","RequestManager","__resetTokensForTests","makeRequest","method","url","data","options","request","getBaseURL","getClient","getMetrics","clearCache","clearCacheEntry","key","getCacheStats","getCloudURL","setTokens","accessToken","refreshToken","clearTokens","getCurrentUserId","getAccessToken","decoded","jwtDecode","userId","id","error","hasValidToken","hasAccessToken","waitForAuth","timeoutMs","startTime","performance","now","maxTime","pollInterval","Promise","resolve","setTimeout","Math","min","withAuthRetry","operation","operationName","maxRetries","retryDelay","authTimeoutMs","attempt","authReady","OxyAuthenticationTimeoutError","OxyAuthenticationError","isLastAttempt","isAuthError","response","status","code","message","includes","handleError","validate","res","undefined","cache","retry","valid","api","handleHttpError","err","details","healthCheck","exports"],"sourceRoot":"../../../src","sources":["core/OxyServices.base.ts"],"mappings":";;;;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAVA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACO,MAAMK,eAAe,CAAC;EAM3BC,WAAWA,CAAC,GAAGC,IAAW,EAAE;IAC1B,MAAMC,MAAM,GAAGD,IAAI,CAAC,CAAC,CAAc;IACnC,IAAI,CAACC,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,uBAAuB,CAAC;IAC1C;IACA,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,QAAQ,GAAGF,MAAM,CAACE,QAAQ,IAAI,sBAAsB;;IAEzD;IACA,IAAI,CAACC,UAAU,GAAG,IAAIC,sBAAU,CAACJ,MAAM,CAAC;;I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ACC,OAAO,GAAGH,GAAG,CAACG,OAAc;IAChC,OAAOD,GAAG;EACZ;;EAEA;AACF;AACA;EACE,MAAME,WAAWA,CAAA,EAKd;IACD,IAAI;MACF,OAAO,MAAM,IAAI,CAACnE,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE2D,SAAS,EAAE;QAAEC,KAAK,EAAE;MAAM,CAAC,CAAC;IAC9E,CAAC,CAAC,OAAOpC,KAAK,EAAE;MACd,MAAM,IAAI,CAACgC,WAAW,CAAChC,KAAK,CAAC;IAC/B;EACF;AACF;AAAC4C,OAAA,CAAA/E,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.ErrorBoundary = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ /**
12
+ * Error Boundary Component
13
+ *
14
+ * Catches JavaScript errors anywhere in the child component tree,
15
+ * logs those errors, and displays a fallback UI instead of crashing.
16
+ *
17
+ * Usage:
18
+ * <ErrorBoundary>
19
+ * <YourComponent />
20
+ * </ErrorBoundary>
21
+ */
22
+ class ErrorBoundary extends _react.Component {
23
+ constructor(props) {
24
+ super(props);
25
+ this.state = {
26
+ hasError: false,
27
+ error: null,
28
+ errorInfo: null
29
+ };
30
+ }
31
+ static getDerivedStateFromError(error) {
32
+ // Update state so the next render will show the fallback UI
33
+ return {
34
+ hasError: true,
35
+ error
36
+ };
37
+ }
38
+ componentDidCatch(error, errorInfo) {
39
+ // Log error to console in development
40
+ if (__DEV__) {
41
+ console.error('ErrorBoundary caught an error:', error, errorInfo);
42
+ }
43
+
44
+ // Call optional error handler
45
+ if (this.props.onError) {
46
+ this.props.onError(error, errorInfo);
47
+ }
48
+
49
+ // Update state with error info
50
+ this.setState({
51
+ error,
52
+ errorInfo
53
+ });
54
+ }
55
+ handleReset = () => {
56
+ this.setState({
57
+ hasError: false,
58
+ error: null,
59
+ errorInfo: null
60
+ });
61
+ };
62
+ render() {
63
+ if (this.state.hasError) {
64
+ // Use custom fallback if provided
65
+ if (this.props.fallback) {
66
+ return this.props.fallback;
67
+ }
68
+
69
+ // Default fallback UI
70
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
71
+ style: styles.container,
72
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
73
+ style: styles.errorContainer,
74
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
75
+ style: styles.errorTitle,
76
+ children: "Something went wrong"
77
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
78
+ style: styles.errorMessage,
79
+ children: this.state.error?.message || 'An unexpected error occurred'
80
+ }), __DEV__ && this.state.errorInfo && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
81
+ style: styles.errorDetails,
82
+ children: this.state.errorInfo.componentStack
83
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
84
+ style: styles.resetButton,
85
+ onPress: this.handleReset,
86
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
87
+ style: styles.resetButtonText,
88
+ children: "Try Again"
89
+ })
90
+ })]
91
+ })
92
+ });
93
+ }
94
+ return this.props.children;
95
+ }
96
+ }
97
+ exports.ErrorBoundary = ErrorBoundary;
98
+ const styles = _reactNative.StyleSheet.create({
99
+ container: {
100
+ flex: 1,
101
+ justifyContent: 'center',
102
+ alignItems: 'center',
103
+ padding: 20,
104
+ backgroundColor: '#fff'
105
+ },
106
+ errorContainer: {
107
+ maxWidth: 400,
108
+ width: '100%',
109
+ padding: 20,
110
+ borderRadius: 8,
111
+ backgroundColor: '#f5f5f5',
112
+ borderWidth: 1,
113
+ borderColor: '#e0e0e0'
114
+ },
115
+ errorTitle: {
116
+ fontSize: 20,
117
+ fontWeight: 'bold',
118
+ marginBottom: 10,
119
+ color: '#d32f2f'
120
+ },
121
+ errorMessage: {
122
+ fontSize: 14,
123
+ marginBottom: 15,
124
+ color: '#666'
125
+ },
126
+ errorDetails: {
127
+ fontSize: 12,
128
+ marginBottom: 15,
129
+ color: '#999',
130
+ fontFamily: 'monospace'
131
+ },
132
+ resetButton: {
133
+ backgroundColor: '#007AFF',
134
+ padding: 12,
135
+ borderRadius: 6,
136
+ alignItems: 'center'
137
+ },
138
+ resetButtonText: {
139
+ color: '#fff',
140
+ fontSize: 16,
141
+ fontWeight: '600'
142
+ }
143
+ });
144
+ var _default = exports.default = ErrorBoundary;
145
+ //# sourceMappingURL=ErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ErrorBoundary","Component","constructor","props","state","hasError","error","errorInfo","getDerivedStateFromError","componentDidCatch","__DEV__","console","onError","setState","handleReset","render","fallback","jsx","View","style","styles","container","children","jsxs","errorContainer","Text","errorTitle","errorMessage","message","errorDetails","componentStack","TouchableOpacity","resetButton","onPress","resetButtonText","exports","StyleSheet","create","flex","justifyContent","alignItems","padding","backgroundColor","maxWidth","width","borderRadius","borderWidth","borderColor","fontSize","fontWeight","marginBottom","color","fontFam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AE,GAAG;IACbC,KAAK,EAAE,MAAM;IACbH,OAAO,EAAE,EAAE;IACXI,YAAY,EAAE,CAAC;IACfH,eAAe,EAAE,SAAS;IAC1BI,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE;EACjB,CAAC;EACDrB,UAAU,EAAE;IACRsB,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,YAAY,EAAE,EAAE;IAChBC,KAAK,EAAE;EACX,CAAC;EACDxB,YAAY,EAAE;IACVqB,QAAQ,EAAE,EAAE;IACZE,YAAY,EAAE,EAAE;IAChBC,KAAK,EAAE;EACX,CAAC;EACDtB,YAAY,EAAE;IACVmB,QAAQ,EAAE,EAAE;IACZE,YAAY,EAAE,EAAE;IAChBC,KAAK,EAAE,MAAM;IACbC,UAAU,EAAE;EAChB,CAAC;EACDpB,WAAW,EAAE;IACTU,eAAe,EAAE,SAAS;IAC1BD,OAAO,EAAE,EAAE;IACXI,YAAY,EAAE,CAAC;IACfL,UAAU,EAAE;EAChB,CAAC;EACDN,eAAe,EAAE;IACbiB,KAAK,EAAE,MAAM;IACbH,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EAChB;AACJ,CAAC,CAAC;AAAC,IAAAI,QAAA,GAAAlB,OAAA,CAAA5C,OAAA,GAEYS,aAAa","ignoreList":[]}
@@ -3,13 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.OxyRouter = void 0;
7
7
  var _react = require("react");
8
8
  var _reactNative = require("react-native");
9
+ var _ErrorBoundary = _interopRequireDefault(require("../components/ErrorBoundary"));
9
10
  var _routes = require("./routes");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
13
  // Import types and route registry
12
14
 
15
+ // Helper function to validate route names at runtime
16
+ const isValidRouteName = screen => {
17
+ return _routes.routeNames.includes(screen);
18
+ };
19
+
20
+ // Helper function for safe navigation with validation
21
+ const validateAndNavigate = (screen, props, setCurrentScreen, setScreenHistory, setScreenPropsMap) => {
22
+ if (!isValidRouteName(screen)) {
23
+ const errorMsg = `Invalid route name: "${screen}". Valid routes are: ${_routes.routeNames.join(', ')}`;
24
+ console.error('OxyRouter:', errorMsg);
25
+ if (process.env.NODE_ENV !== 'production') {
26
+ console.error('Navigation error:', errorMsg);
27
+ }
28
+ return false;
29
+ }
30
+ if (!_routes.routes[screen]) {
31
+ const errorMsg = `Route "${screen}" is registered but component is missing`;
32
+ console.error('OxyRouter:', errorMsg);
33
+ if (process.env.NODE_ENV !== 'production') {
34
+ console.error('Navigation error:', errorMsg);
35
+ }
36
+ return false;
37
+ }
38
+ return true;
39
+ };
13
40
  const OxyRouter = ({
14
41
  oxyServices,
15
42
  initialScreen,
@@ -34,23 +61,22 @@ const OxyRouter = ({
34
61
  }
35
62
  }, [currentScreen, adjustSnapPoints]);
36
63
 
37
- // Memoized navigation methods
64
+ // Memoized navigation methods with validation
38
65
  const navigate = (0, _react.useCallback)((screen, props = {}) => {
39
66
  if (__DEV__) console.log('OxyRouter: navigate called', screen, props);
40
- if (_routes.routes[screen]) {
41
- if (__DEV__) console.log('OxyRouter: screen found in routes');
42
- setCurrentScreen(screen);
43
- setScreenHistory(prev => [...prev, screen]);
44
- setScreenPropsMap(prev => ({
45
- ...prev,
46
- [screen]: props
47
- }));
48
- } else {
49
- console.error(`OxyRouter: Screen "${screen}" not found in routes:`, Object.keys(_routes.routes));
50
- if (process.env.NODE_ENV !== 'production') {
51
- console.error(`Screen "${screen}" not found`);
52
- }
67
+
68
+ // Validate route before navigating
69
+ if (!validateAndNavigate(screen, props, setCurrentScreen, setScreenHistory, setScreenPropsMap)) {
70
+ return; // Early return if validation fails
53
71
  }
72
+
73
+ // All validations passed, proceed with navigation
74
+ setCurrentScreen(screen);
75
+ setScreenHistory(prev => [...prev, screen]);
76
+ setScreenPropsMap(prev => ({
77
+ ...prev,
78
+ [screen]: props
79
+ }));
54
80
  }, []);
55
81
  const goBack = (0, _react.useCallback)(() => {
56
82
  setScreenHistory(prev => {
@@ -86,13 +112,23 @@ const OxyRouter = ({
86
112
  const handleNavigationEvent = event => {
87
113
  if (event && event.detail) {
88
114
  if (typeof event.detail === 'string') {
89
- navigate(event.detail);
115
+ // Validate string route name before navigating
116
+ if (isValidRouteName(event.detail)) {
117
+ navigate(event.detail);
118
+ } else {
119
+ console.error('OxyRouter: Invalid route name in event:', event.detail);
120
+ }
90
121
  } else if (typeof event.detail === 'object' && event.detail.screen) {
91
122
  const {
92
123
  screen,
93
124
  props
94
125
  } = event.detail;
95
- navigate(screen, props || {});
126
+ // Validate route name before navigating
127
+ if (isValidRouteName(screen)) {
128
+ navigate(screen, props || {});
129
+ } else {
130
+ console.error('OxyRouter: Invalid route name in event:', screen);
131
+ }
96
132
  }
97
133
  }
98
134
  };
@@ -103,8 +139,14 @@ const OxyRouter = ({
103
139
  intervalId = setInterval(() => {
104
140
  const globalNav = globalThis.oxyNavigateEvent;
105
141
  if (globalNav && globalNav.screen) {
106
- navigate(globalNav.screen, globalNav.props || {});
107
- globalThis.oxyNavigateEvent = null;
142
+ // Validate route name before navigating
143
+ if (isValidRouteName(globalNav.screen)) {
144
+ navigate(globalNav.screen, globalNav.props || {});
145
+ globalThis.oxyNavigateEvent = null;
146
+ } else {
147
+ console.error('OxyRouter: Invalid route name in global event:', globalNav.screen);
148
+ globalThis.oxyNavigateEvent = null; // Clear invalid event
149
+ }
108
150
  }
109
151
  }, 100);
110
152
  }
@@ -118,7 +160,7 @@ const OxyRouter = ({
118
160
  };
119
161
  }, [navigate]);
120
162
 
121
- // Render the current screen component
163
+ // Render the current screen component with error boundary
122
164
  const renderScreen = () => {
123
165
  const CurrentScreen = _routes.routes[currentScreen]?.component;
124
166
  if (!CurrentScreen) {
@@ -129,15 +171,20 @@ const OxyRouter = ({
129
171
  style: styles.errorContainer
130
172
  });
131
173
  }
132
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(CurrentScreen, {
133
- oxyServices: oxyServices,
134
- navigate: navigate,
135
- goBack: goBack,
136
- onClose: onClose,
137
- onAuthenticated: onAuthenticated,
138
- theme: theme,
139
- containerWidth: containerWidth,
140
- ...(screenPropsMap[currentScreen] || {})
174
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorBoundary.default, {
175
+ onError: (error, errorInfo) => {
176
+ console.error(`Error in screen "${currentScreen}":`, error, errorInfo);
177
+ },
178
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CurrentScreen, {
179
+ oxyServices: oxyServices,
180
+ navigate: navigate,
181
+ goBack: goBack,
182
+ onClose: onClose,
183
+ onAuthenticated: onAuthenticated,
184
+ theme: theme,
185
+ containerWidth: containerWidth,
186
+ ...(screenPropsMap[currentScreen] || {})
187
+ })
141
188
  });
142
189
  };
143
190
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
@@ -145,6 +192,10 @@ const OxyRouter = ({
145
192
  children: renderScreen()
146
193
  });
147
194
  };
195
+
196
+ // Memoize the router component to prevent unnecessary re-renders
197
+ exports.OxyRouter = OxyRouter;
198
+ const MemoizedOxyRouter = /*#__PURE__*/(0, _react.memo)(OxyRouter);
148
199
  const styles = _reactNative.StyleSheet.create({
149
200
  container: {
150
201
  flex: 1
@@ -156,5 +207,7 @@ const styles = _reactNative.StyleSheet.create({
156
207
  minHeight: 100
157
208
  }
158
209
  });
159
- var _default = exports.default = OxyRouter;
210
+
211
+ // Export both the memoized version (default) and the original for testing
212
+ var _default = exports.default = MemoizedOxyRouter;
160
213
  //# sourceMappingURL=OxyRouter.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","_routes","_jsxRuntime","OxyRouter","oxyServices","initialScreen","onClose","onAuthenticated","theme","adjustSnapPoints","navigationRef","containerWidth","currentScreen","setCurrentScreen","useState","screenHistory","setScreenHistory","screenPropsMap","setScreenPropsMap","useEffect","routes","snapPoints","navigate","useCallback","screen","props","__DEV__","console","log","prev","error","Object","keys","process","env","NODE_ENV","goBack","length","newHistory","pop","previousScreen","current","handleNavigationEvent","event","detail","intervalId","document","addEventListener","setInterval","globalNav","globalThis","oxyNavigateEvent","removeEventListener","clearInterval","renderScreen","CurrentScreen","component","jsx","View","style","styles","errorContainer","container","children","StyleSheet","create","flex","justifyContent","alignItems","minHeight","_default","exports","default"],"sourceRoot":"../../../../src","sources":["ui/navigation/OxyRouter.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AAAkC,IAAAG,WAAA,GAAAH,OAAA;AAFlC;;AAKA,MAAMI,SAAmC,GAAGA,CAAC;EACzCC,WAAW;EACXC,aAAa;EACbC,OAAO;EACPC,eAAe;EACfC,KAAK;EACLC,gBAAgB;EAChBC,aAAa;EACbC;AACJ,CAAC,KAAK;EACF,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAG,IAAAC,eAAQ,EAAYT,aAAa,CAAC;EAC5E,MAAM,CAACU,aAAa,EAAEC,gBAAgB,CAAC,GAAG,IAAAF,eAAQ,EAAc,CAACT,aAAa,CAAC,CAAC;EAChF;EACA,MAAM,CAACY,cAAc,EAAEC,iBAAiB,CAAC,GAAG,IAAAJ,eAAQ,EAAkC;IAAE,CAACT,aAAa,GAAG,CAAC;EAAE,CAAC,CAAC;;EAE9G;EACA,IAAAc,gBAAS,EAAC,MAAM;IACZ,IAAKC,cAAM,CAASR,aAAa,CAAC,IAAI,OAAOH,gBAAgB,KAAK,UAAU,EAAE;MAC1EA,gBAAgB,CAAEW,cAAM,CAASR,aAAa,CAAC,CAACS,UAAU,CAAC;IAC/D;EACJ,CAAC,EAAE,CAACT,aAAa,EAAEH,gBAAgB,CAAC,CAAC;;EAErC;EACA,MAAMa,QAAQ,GAAG,IAAAC,kBAAW,EAAC,CAACC,MAAiB,EAAEC,KAA0B,GAAG,CAAC,CAAC,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EC,MAAM,CAACE,SAAU;IAAAC,QAAA,EACzBT,YAAY,CAAC;EAAC,CACb,CAAC;AAEf,CAAC;AAED,MAAMM,MAAM,GAAGI,uBAAU,CAACC,MAAM,CAAC;EAC7BH,SAAS,EAAE;IACPI,IAAI,EAAE;EACV,CAAC;EACDL,cAAc,EAAE;IACZK,IAAI,EAAE,CAAC;IACPC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,SAAS,EAAE;EACf;AACJ,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEYrE,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","_ErrorBoundary","_interopRequireDefault","_routes","_jsxRuntime","e","__esModule","default","isValidRouteName","screen","routeNames","includes","validateAndNavigate","props","setCurrentScreen","setScreenHistory","setScreenPropsMap","errorMsg","join","console","error","process","env","NODE_ENV","routes","OxyRouter","oxyServices","initialScreen","onClose","onAuthenticated","theme","adjustSnapPoints","navigationRef","containerWidth","currentScreen","useState","screenHistory","screenPropsMap","useEffect","snapPoints","navigate","useCallback","__DEV__","log","prev","goBack","length","newHistory","pop","previousScreen","current","handleNavigationEvent","event","detail","intervalId","document","addEventListener","setInterval","globalNav","globalThis","oxyNavigateEvent","removeEventListener","clearInterval","renderScreen","CurrentScreen","component","jsx","View","style","styles","errorContainer","onError","errorInfo","children","container","exports","MemoizedOxyRouter","memo","StyleSheet","create","flex","justifyContent","alignItems","minHeight","_default"],"sourceRoot":"../../../../src","sources":["ui/navigation/OxyRouter.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAC,sBAAA,CAAAH,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AAA8C,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,G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AACA,MAAMmD,iBAAiB,gBAAG,IAAAC,WAAI,EAACpD,SAAS,CAAC;AAEzC,MAAM4C,MAAM,GAAGS,uBAAU,CAACC,MAAM,CAAC;EAC7BL,SAAS,EAAE;IACPM,IAAI,EAAE;EACV,CAAC;EACDV,cAAc,EAAE;IACZU,IAAI,EAAE,CAAC;IACPC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,SAAS,EAAE;EACf;AACJ,CAAC,CAAC;;AAEF;AAAA,IAAAC,QAAA,GAAAT,OAAA,CAAApE,OAAA,GAEeqE,iBAAiB","ignoreList":[]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _reactNative = require("react-native");
8
+ var _react = require("react");
8
9
  var _OxyContext = require("../context/OxyContext");
9
10
  var _version = require("../../constants/version");
10
11
  var _sonner = require("../../lib/sonner");
@@ -40,7 +41,9 @@ const AccountCenterScreen = ({
40
41
  const borderColor = isDarkTheme ? '#444444' : '#E0E0E0';
41
42
  const primaryColor = '#0066CC';
42
43
  const dangerColor = '#D32F2F';
43
- const handleLogout = async () => {
44
+
45
+ // Memoized logout handler - prevents unnecessary re-renders
46
+ const handleLogout = (0, _react.useCallback)(async () => {
44
47
  try {
45
48
  await logout();
46
49
  if (onClose) {
@@ -50,10 +53,12 @@ const AccountCenterScreen = ({
50
53
  console.error('Logout failed:', error);
51
54
  _sonner.toast.error(t('common.errors.signOutFailed') || 'There was a problem signing you out. Please try again.');
52
55
  }
53
- };
54
- const confirmLogout = () => {
56
+ }, [logout, onClose, t]);
57
+
58
+ // Memoized confirm logout handler - prevents unnecessary re-renders
59
+ const confirmLogout = (0, _react.useCallback)(() => {
55
60
  (0, _confirmAction.confirmAction)(t('common.confirms.signOut') || 'Are you sure you want to sign out?', handleLogout);
56
- };
61
+ }, [handleLogout, t]);
57
62
  if (!isAuthenticated) {
58
63
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
59
64
  style: [styles.container, {
@@ -100,7 +105,7 @@ const AccountCenterScreen = ({
100
105
  theme: theme,
101
106
  isFirst: true,
102
107
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_QuickActions.default, {
103
- actions: [{
108
+ actions: (0, _react.useMemo)(() => [{
104
109
  id: 'overview',
105
110
  icon: 'person-circle',
106
111
  iconColor: '#007AFF',
@@ -136,14 +141,14 @@ const AccountCenterScreen = ({
136
141
  iconColor: '#FF9500',
137
142
  title: t('accountCenter.quickActions.switch') || 'Switch',
138
143
  onPress: () => navigate('AccountSwitcher')
139
- }] : [])],
144
+ }] : [])], [user?.isPremium, sessions, navigate, t]),
140
145
  theme: theme
141
146
  })
142
147
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Section.default, {
143
148
  title: t('accountCenter.sections.accountManagement') || 'Account Management',
144
149
  theme: theme,
145
150
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupedSection.default, {
146
- items: [{
151
+ items: (0, _react.useMemo)(() => [{
147
152
  id: 'overview',
148
153
  icon: 'person-circle',
149
154
  iconColor: '#007AFF',
@@ -185,14 +190,14 @@ const AccountCenterScreen = ({
185
190
  title: t('accountCenter.items.billing.title') || 'Billing Management',
186
191
  subtitle: t('accountCenter.items.billing.subtitle') || 'Payment methods and invoices',
187
192
  onPress: () => navigate('PaymentGateway')
188
- }] : [])],
193
+ }] : [])], [user?.isPremium, navigate, t]),
189
194
  theme: theme
190
195
  })
191
196
  }), sessions && sessions.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Section.default, {
192
197
  title: t('accountCenter.sections.multiAccount') || 'Multi-Account',
193
198
  theme: theme,
194
199
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupedSection.default, {
195
- items: [{
200
+ items: (0, _react.useMemo)(() => [{
196
201
  id: 'switch',
197
202
  icon: 'people',
198
203
  iconColor: '#FF9500',
@@ -208,28 +213,28 @@ const AccountCenterScreen = ({
208
213
  title: t('accountCenter.items.addAccount.title') || 'Add Another Account',
209
214
  subtitle: t('accountCenter.items.addAccount.subtitle') || 'Sign in with a different account',
210
215
  onPress: () => navigate('SignIn')
211
- }],
216
+ }], [sessions.length, navigate, t]),
212
217
  theme: theme
213
218
  })
214
219
  }), (!sessions || sessions.length <= 1) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Section.default, {
215
220
  title: t('accountCenter.sections.addAccount') || 'Add Account',
216
221
  theme: theme,
217
222
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupedSection.default, {
218
- items: [{
223
+ items: (0, _react.useMemo)(() => [{
219
224
  id: 'add',
220
225
  icon: 'person-add',
221
226
  iconColor: '#30D158',
222
227
  title: t('accountCenter.items.addAccount.title') || 'Add Another Account',
223
228
  subtitle: t('accountCenter.items.addAccount.subtitle') || 'Sign in with a different account',
224
229
  onPress: () => navigate('SignIn')
225
- }],
230
+ }], [navigate, t]),
226
231
  theme: theme
227
232
  })
228
233
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Section.default, {
229
234
  title: t('accountCenter.sections.moreOptions') || 'More Options',
230
235
  theme: theme,
231
236
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupedSection.default, {
232
- items: [...(_reactNative.Platform.OS !== 'web' ? [{
237
+ items: (0, _react.useMemo)(() => [...(_reactNative.Platform.OS !== 'web' ? [{
233
238
  id: 'notifications',
234
239
  icon: 'notifications',
235
240
  iconColor: '#FF9500',
@@ -257,7 +262,7 @@ const AccountCenterScreen = ({
257
262
  title: t('accountCenter.items.appInfo.title') || 'App Information',
258
263
  subtitle: t('accountCenter.items.appInfo.subtitle') || 'Version and system details',
259
264
  onPress: () => navigate('AppInfo')
260
- }],
265
+ }], [navigate, t]),
261
266
  theme: theme
262
267
  })
263
268
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Section.default, {