@oxyhq/services 5.6.7 → 5.6.9

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/src/index.ts CHANGED
@@ -6,143 +6,7 @@
6
6
  * - Backend: Core functionality only (UI components are no-ops)
7
7
  */
8
8
 
9
- // ------------- Core Imports (Always Safe) -------------
10
- import OxyCore from './core';
11
- import { OxyServices } from './core';
12
- import { DeviceManager } from './utils/deviceManager';
13
- import * as Models from './models/interfaces';
14
-
15
- // ------------- Environment Detection -------------
16
- const isFrontend = typeof window !== 'undefined' ||
17
- (typeof global !== 'undefined' && global.navigator) ||
18
- (typeof process !== 'undefined' && process.env.NODE_ENV === 'development' && typeof document !== 'undefined');
19
-
20
- // ------------- Core Exports (Always Available) -------------
21
- export default OxyCore;
22
- export { OxyServices };
9
+ // Universal entry: always statically export everything
23
10
  export * from './core';
24
- export { DeviceManager } from './utils';
25
- export type { DeviceFingerprint, StoredDeviceInfo } from './utils';
26
- export * from './models/interfaces';
27
- export * from './models/secureSession';
28
-
29
- // ------------- Safe Toast Export -------------
30
- export { toast } from './lib/sonner-safe';
31
-
32
- // ------------- UI Exports (Conditional) -------------
33
- if (isFrontend) {
34
- // Frontend: Export all UI components and hooks
35
- try {
36
- // Import UI components and hooks
37
- const {
38
- OxyProvider,
39
- OxySignInButton,
40
- OxyLogo,
41
- Avatar,
42
- FollowButton,
43
- OxyPayButton,
44
- FontLoader,
45
- useOxy,
46
- useOxyAuth,
47
- useOxyUser,
48
- useOxyKarma,
49
- useOxyPayments,
50
- useOxyDevices,
51
- useOxyNotifications,
52
- useOxySocket,
53
- useOxyQR,
54
- useOxyIAP,
55
- OxyContextProvider,
56
- OxyContextState,
57
- OxyContextProviderProps,
58
- useFollow,
59
- ProfileScreen,
60
- OxyRouter,
61
- useAuthStore,
62
- OxyIcon,
63
- IconProps,
64
- fontFamilies,
65
- fontStyles
66
- } = require('./ui');
67
-
68
- // Export all UI components
69
- exports.OxyProvider = OxyProvider;
70
- exports.OxySignInButton = OxySignInButton;
71
- exports.OxyLogo = OxyLogo;
72
- exports.Avatar = Avatar;
73
- exports.FollowButton = FollowButton;
74
- exports.OxyPayButton = OxyPayButton;
75
- exports.FontLoader = FontLoader;
76
-
77
- // Export all hooks
78
- exports.useOxy = useOxy;
79
- exports.useOxyAuth = useOxyAuth;
80
- exports.useOxyUser = useOxyUser;
81
- exports.useOxyKarma = useOxyKarma;
82
- exports.useOxyPayments = useOxyPayments;
83
- exports.useOxyDevices = useOxyDevices;
84
- exports.useOxyNotifications = useOxyNotifications;
85
- exports.useOxySocket = useOxySocket;
86
- exports.useOxyQR = useOxyQR;
87
- exports.useOxyIAP = useOxyIAP;
88
- exports.useFollow = useFollow;
89
-
90
- // Export context
91
- exports.OxyContextProvider = OxyContextProvider;
92
- exports.OxyContextState = OxyContextState;
93
- exports.OxyContextProviderProps = OxyContextProviderProps;
94
-
95
- // Export screens and navigation
96
- exports.ProfileScreen = ProfileScreen;
97
- exports.OxyRouter = OxyRouter;
98
- exports.useAuthStore = useAuthStore;
99
-
100
- // Export UI components
101
- exports.OxyIcon = OxyIcon;
102
- exports.IconProps = IconProps;
103
- exports.fontFamilies = fontFamilies;
104
- exports.fontStyles = fontStyles;
105
-
106
- } catch (e: any) {
107
- console.warn('UI components failed to load:', e?.message || 'Unknown error');
108
- // Fallback to no-op exports
109
- const noopComponent = () => null;
110
- const noopHook = () => ({});
111
-
112
- exports.OxyProvider = noopComponent;
113
- exports.useOxy = noopHook;
114
- exports.useOxyAuth = noopHook;
115
- exports.useOxyUser = noopHook;
116
- exports.useOxyKarma = noopHook;
117
- exports.useOxyPayments = noopHook;
118
- exports.useOxyDevices = noopHook;
119
- exports.useOxyNotifications = noopHook;
120
- exports.useOxySocket = noopHook;
121
- exports.useOxyQR = noopHook;
122
- exports.useOxyIAP = noopHook;
123
- exports.useFollow = noopHook;
124
- }
125
- } else {
126
- // Backend: Export no-op UI components
127
- const noopComponent = () => null;
128
- const noopHook = () => ({});
129
-
130
- exports.OxyProvider = noopComponent;
131
- exports.OxySignInButton = noopComponent;
132
- exports.OxyLogo = noopComponent;
133
- exports.Avatar = noopComponent;
134
- exports.FollowButton = noopComponent;
135
- exports.OxyPayButton = noopComponent;
136
- exports.FontLoader = { setupFonts: () => {} };
137
- exports.useOxy = noopHook;
138
- exports.useOxyAuth = noopHook;
139
- exports.useOxyUser = noopHook;
140
- exports.useOxyKarma = noopHook;
141
- exports.useOxyPayments = noopHook;
142
- exports.useOxyDevices = noopHook;
143
- exports.useOxyNotifications = noopHook;
144
- exports.useOxySocket = noopHook;
145
- exports.useOxyQR = noopHook;
146
- exports.useOxyIAP = noopHook;
147
- exports.useFollow = noopHook;
148
- }
11
+ export * from './ui';
12
+ export { toast } from './lib/sonner-safe';
package/src/ui/index.ts CHANGED
@@ -1,51 +1,83 @@
1
1
  /**
2
- * UI Component exports - Frontend Only
2
+ * UI Component exports - Frontend Only (with backend-safe fallbacks)
3
3
  *
4
4
  * This module exports all React/React Native UI components and hooks.
5
- * Use this for frontend applications only. For backend usage, import from the main package.
5
+ * In backend, all exports are no-ops or empty objects.
6
6
  */
7
+ import isFrontend from './isFrontend';
7
8
 
8
- // Export the main provider component and context
9
- export { default as OxyProvider } from './components/OxyProvider';
10
- export { default as OxySignInButton } from './components/OxySignInButton';
11
- export { default as OxyLogo } from './components/OxyLogo';
12
- export { default as Avatar } from './components/Avatar';
13
- export { default as FollowButton } from './components/FollowButton';
14
- export { default as OxyPayButton } from './components/OxyPayButton';
15
- export { FontLoader, setupFonts } from './components/FontLoader';
9
+ // Real UI exports
10
+ let OxyProvider, OxySignInButton, OxyLogo, Avatar, FollowButton, OxyPayButton, FontLoader, setupFonts, OxyIcon, useOxy, useOxyAuth, useOxyUser, useOxyKarma, useOxyPayments, useOxyDevices, useOxyNotifications, useOxySocket, useOxyQR, useOxyIAP, OxyContextProvider, OxyContextState, OxyContextProviderProps, useFollow, ProfileScreen, OxyRouter, useAuthStore, fontFamilies, fontStyles, toast;
16
11
 
17
- // Export icon components
18
- export { OxyIcon } from './components/icon';
19
- export type { IconProps } from './components/icon';
12
+ if (isFrontend) {
13
+ OxyProvider = require('./components/OxyProvider').default;
14
+ OxySignInButton = require('./components/OxySignInButton').default;
15
+ OxyLogo = require('./components/OxyLogo').default;
16
+ Avatar = require('./components/Avatar').default;
17
+ FollowButton = require('./components/FollowButton').default;
18
+ OxyPayButton = require('./components/OxyPayButton').default;
19
+ FontLoader = require('./components/FontLoader').FontLoader;
20
+ setupFonts = require('./components/FontLoader').setupFonts;
21
+ OxyIcon = require('./components/icon').OxyIcon;
22
+ useOxy = require('./context/OxyContext').useOxy;
23
+ OxyContextProvider = require('./context/OxyContext').OxyContextProvider;
24
+ OxyContextState = require('./context/OxyContext').OxyContextState;
25
+ OxyContextProviderProps = require('./context/OxyContext').OxyContextProviderProps;
26
+ useFollow = require('./hooks').useFollow;
27
+ ProfileScreen = require('./screens/ProfileScreen').default;
28
+ OxyRouter = require('./navigation/OxyRouter').default;
29
+ useAuthStore = require('./stores/authStore').useAuthStore;
30
+ fontFamilies = require('./styles/fonts').fontFamilies;
31
+ fontStyles = require('./styles/fonts').fontStyles;
32
+ toast = require('../lib/sonner').toast;
33
+ } else {
34
+ // Backend: no-op fallbacks
35
+ const noopComponent = () => null;
36
+ const noopHook = () => ({});
37
+ OxyProvider = noopComponent;
38
+ OxySignInButton = noopComponent;
39
+ OxyLogo = noopComponent;
40
+ Avatar = noopComponent;
41
+ FollowButton = noopComponent;
42
+ OxyPayButton = noopComponent;
43
+ FontLoader = noopComponent;
44
+ setupFonts = () => {};
45
+ OxyIcon = noopComponent;
46
+ useOxy = noopHook;
47
+ OxyContextProvider = noopComponent;
48
+ OxyContextState = {};
49
+ OxyContextProviderProps = {};
50
+ useFollow = noopHook;
51
+ ProfileScreen = noopComponent;
52
+ OxyRouter = noopComponent;
53
+ useAuthStore = noopHook;
54
+ fontFamilies = {};
55
+ fontStyles = {};
56
+ toast = () => {};
57
+ }
20
58
 
21
- // Export context and hooks
22
59
  export {
23
- OxyContextProvider,
60
+ OxyProvider,
61
+ OxySignInButton,
62
+ OxyLogo,
63
+ Avatar,
64
+ FollowButton,
65
+ OxyPayButton,
66
+ FontLoader,
67
+ setupFonts,
68
+ OxyIcon,
24
69
  useOxy,
70
+ OxyContextProvider,
25
71
  OxyContextState,
26
- OxyContextProviderProps
27
- } from './context/OxyContext';
28
-
29
- // Export styles
30
- export { fontFamilies, fontStyles } from './styles/fonts';
31
-
32
- // Export types for navigation and UI
33
- export * from './navigation/types';
34
-
35
- // Hooks
36
- export { useFollow } from './hooks';
37
-
38
- // Screens
39
- export { default as ProfileScreen } from './screens/ProfileScreen';
40
-
41
- // Navigation
42
- export { default as OxyRouter } from './navigation/OxyRouter';
43
-
44
- // Export stores for advanced usage
45
- export { useAuthStore } from './stores/authStore';
46
-
47
- // Export toast for UI notifications
48
- export { toast } from '../lib/sonner';
72
+ OxyContextProviderProps,
73
+ useFollow,
74
+ ProfileScreen,
75
+ OxyRouter,
76
+ useAuthStore,
77
+ fontFamilies,
78
+ fontStyles,
79
+ toast
80
+ };
49
81
 
50
82
  // Re-export core services for convenience in UI context
51
83
  export { OxyServices } from '../core';
@@ -0,0 +1,5 @@
1
+ // Utility to detect if running in a frontend (browser or React Native) environment
2
+ const isFrontend = typeof window !== 'undefined' ||
3
+ (typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
4
+
5
+ export default isFrontend;