@oxyhq/services 6.9.19 → 6.9.21
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/lib/commonjs/index.js +3 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +33 -1
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuth.js +8 -0
- package/lib/commonjs/ui/hooks/useAuth.js.map +1 -1
- package/lib/commonjs/ui/index.js +95 -131
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +33 -1
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/useAuth.js +3 -0
- package/lib/module/ui/hooks/useAuth.js.map +1 -1
- package/lib/module/ui/index.js +86 -34
- package/lib/module/ui/index.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts +1 -0
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/index.d.ts +21 -28
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAuth.d.ts +1 -0
- package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/module/ui/index.d.ts +21 -28
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- package/package.json +10 -3
- package/src/index.ts +1 -2
- package/src/ui/context/OxyContext.tsx +35 -1
- package/src/ui/hooks/useAuth.ts +2 -0
- package/src/ui/index.ts +104 -33
|
@@ -712,10 +712,44 @@ export const OxyProvider: React.FC<OxyContextProviderProps> = ({
|
|
|
712
712
|
|
|
713
713
|
export const OxyContextProvider = OxyProvider;
|
|
714
714
|
|
|
715
|
+
const noop = () => Promise.resolve() as any;
|
|
716
|
+
|
|
717
|
+
const LOADING_STATE: OxyContextState = {
|
|
718
|
+
user: null,
|
|
719
|
+
sessions: [],
|
|
720
|
+
activeSessionId: null,
|
|
721
|
+
isAuthenticated: false,
|
|
722
|
+
isLoading: true,
|
|
723
|
+
isTokenReady: false,
|
|
724
|
+
isStorageReady: false,
|
|
725
|
+
error: null,
|
|
726
|
+
currentLanguage: 'en',
|
|
727
|
+
currentLanguageMetadata: {} as any,
|
|
728
|
+
currentLanguageName: 'English',
|
|
729
|
+
currentNativeLanguageName: 'English',
|
|
730
|
+
hasIdentity: () => Promise.resolve(false),
|
|
731
|
+
getPublicKey: () => Promise.resolve(null),
|
|
732
|
+
signIn: noop,
|
|
733
|
+
handlePopupSession: noop,
|
|
734
|
+
logout: noop,
|
|
735
|
+
logoutAll: noop,
|
|
736
|
+
switchSession: noop,
|
|
737
|
+
removeSession: noop,
|
|
738
|
+
refreshSessions: noop,
|
|
739
|
+
setLanguage: noop,
|
|
740
|
+
getDeviceSessions: () => Promise.resolve([]),
|
|
741
|
+
logoutAllDeviceSessions: noop,
|
|
742
|
+
updateDeviceName: noop,
|
|
743
|
+
clearSessionState: noop,
|
|
744
|
+
clearAllAccountData: noop,
|
|
745
|
+
oxyServices: null as any,
|
|
746
|
+
openAvatarPicker: () => {},
|
|
747
|
+
};
|
|
748
|
+
|
|
715
749
|
export const useOxy = (): OxyContextState => {
|
|
716
750
|
const context = useContext(OxyContext);
|
|
717
751
|
if (!context) {
|
|
718
|
-
|
|
752
|
+
return LOADING_STATE;
|
|
719
753
|
}
|
|
720
754
|
return context;
|
|
721
755
|
};
|
package/src/ui/hooks/useAuth.ts
CHANGED
package/src/ui/index.ts
CHANGED
|
@@ -1,47 +1,115 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* UI Component exports
|
|
2
|
+
* UI Component exports - Frontend Only (with backend-safe fallbacks)
|
|
3
3
|
*
|
|
4
|
-
* This
|
|
5
|
-
*
|
|
4
|
+
* This module exports all React/React Native UI components and hooks.
|
|
5
|
+
* In backend, all exports are no-ops or empty objects.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This entry point uses runtime detection which prevents tree-shaking.
|
|
8
|
+
* For better bundle optimization, use:
|
|
9
|
+
* - '@oxyhq/services/ui/client' for client bundles (tree-shakeable)
|
|
10
|
+
* - '@oxyhq/services/ui/server' for SSR environments (all noops)
|
|
6
11
|
*
|
|
7
12
|
* @example
|
|
8
|
-
*
|
|
13
|
+
* // Client bundle (tree-shakeable)
|
|
14
|
+
* import { OxyProvider, useOxy } from '@oxyhq/services/ui/client';
|
|
15
|
+
*
|
|
16
|
+
* // SSR (noops)
|
|
17
|
+
* import { OxyProvider, useOxy } from '@oxyhq/services/ui/server';
|
|
9
18
|
*/
|
|
19
|
+
import isFrontend from './isFrontend';
|
|
10
20
|
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
// UI exports
|
|
22
|
+
let OxyProvider;
|
|
23
|
+
let OxySignInButton;
|
|
24
|
+
let OxyLogo;
|
|
25
|
+
let Avatar;
|
|
26
|
+
let FollowButton;
|
|
27
|
+
let OxyPayButton;
|
|
28
|
+
let FontLoader;
|
|
29
|
+
let setupFonts;
|
|
30
|
+
let OxyIcon;
|
|
31
|
+
let useOxy;
|
|
32
|
+
let useAuth;
|
|
33
|
+
let useFollow;
|
|
34
|
+
let ProfileScreen;
|
|
35
|
+
let useAuthStore;
|
|
36
|
+
let useAccountStore;
|
|
37
|
+
let fontFamilies;
|
|
38
|
+
let fontStyles;
|
|
39
|
+
let toast;
|
|
40
|
+
let useStorage;
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
if (isFrontend) {
|
|
43
|
+
OxyProvider = require('./components/OxyProvider').default;
|
|
44
|
+
OxySignInButton = require('./components/OxySignInButton').default;
|
|
45
|
+
OxyLogo = require('./components/OxyLogo').default;
|
|
46
|
+
Avatar = require('./components/Avatar').default;
|
|
47
|
+
FollowButton = require('./components/FollowButton').default;
|
|
48
|
+
OxyPayButton = require('./components/OxyPayButton').default;
|
|
49
|
+
FontLoader = require('./components/FontLoader').FontLoader;
|
|
50
|
+
setupFonts = require('./components/FontLoader').setupFonts;
|
|
51
|
+
OxyIcon = require('./components/icon').OxyIcon;
|
|
52
|
+
useOxy = require('./context/OxyContext').useOxy;
|
|
53
|
+
useAuth = require('./hooks/useAuth').useAuth;
|
|
54
|
+
useFollow = require('./hooks').useFollow;
|
|
55
|
+
ProfileScreen = require('./screens/ProfileScreen').default;
|
|
56
|
+
useAuthStore = require('./stores/authStore').useAuthStore;
|
|
57
|
+
useAccountStore = require('./stores/accountStore').useAccountStore;
|
|
58
|
+
fontFamilies = require('./styles/fonts').fontFamilies;
|
|
59
|
+
fontStyles = require('./styles/fonts').fontStyles;
|
|
60
|
+
toast = require('../lib/sonner').toast;
|
|
61
|
+
useStorage = require('./hooks/useStorage').useStorage;
|
|
62
|
+
} else {
|
|
63
|
+
// Backend: no-op fallbacks
|
|
64
|
+
const noopComponent = () => null;
|
|
65
|
+
const noopHook = () => ({});
|
|
66
|
+
const noopStorageResult = { storage: null, isReady: false };
|
|
33
67
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
68
|
+
OxyProvider = noopComponent;
|
|
69
|
+
OxySignInButton = noopComponent;
|
|
70
|
+
OxyLogo = noopComponent;
|
|
71
|
+
Avatar = noopComponent;
|
|
72
|
+
FollowButton = noopComponent;
|
|
73
|
+
OxyPayButton = noopComponent;
|
|
74
|
+
FontLoader = noopComponent;
|
|
75
|
+
setupFonts = () => {};
|
|
76
|
+
OxyIcon = noopComponent;
|
|
77
|
+
useOxy = noopHook;
|
|
78
|
+
useAuth = noopHook;
|
|
79
|
+
useFollow = noopHook;
|
|
80
|
+
ProfileScreen = noopComponent;
|
|
81
|
+
useAuthStore = noopHook;
|
|
82
|
+
useAccountStore = noopHook;
|
|
83
|
+
fontFamilies = {};
|
|
84
|
+
fontStyles = {};
|
|
85
|
+
toast = () => {};
|
|
86
|
+
useStorage = () => noopStorageResult;
|
|
87
|
+
}
|
|
37
88
|
|
|
38
|
-
|
|
39
|
-
|
|
89
|
+
export {
|
|
90
|
+
OxyProvider,
|
|
91
|
+
OxySignInButton,
|
|
92
|
+
OxyLogo,
|
|
93
|
+
Avatar,
|
|
94
|
+
FollowButton,
|
|
95
|
+
OxyPayButton,
|
|
96
|
+
FontLoader,
|
|
97
|
+
setupFonts,
|
|
98
|
+
OxyIcon,
|
|
99
|
+
useOxy,
|
|
100
|
+
useAuth,
|
|
101
|
+
useFollow,
|
|
102
|
+
ProfileScreen,
|
|
103
|
+
useAuthStore,
|
|
104
|
+
useAccountStore,
|
|
105
|
+
fontFamilies,
|
|
106
|
+
fontStyles,
|
|
107
|
+
toast,
|
|
108
|
+
useStorage,
|
|
109
|
+
};
|
|
40
110
|
|
|
41
|
-
// Toast
|
|
42
|
-
export { toast } from '../lib/sonner';
|
|
43
111
|
|
|
44
|
-
//
|
|
112
|
+
// Export error handler utilities (pure functions, no conditional needed)
|
|
45
113
|
export {
|
|
46
114
|
handleAuthError,
|
|
47
115
|
isInvalidSessionError,
|
|
@@ -49,3 +117,6 @@ export {
|
|
|
49
117
|
extractErrorMessage,
|
|
50
118
|
} from './utils/errorHandlers';
|
|
51
119
|
export type { HandleAuthErrorOptions } from './utils/errorHandlers';
|
|
120
|
+
|
|
121
|
+
// Export useStorage hook and types (kept for external consumers)
|
|
122
|
+
export type { UseStorageOptions, UseStorageResult } from './hooks/useStorage';
|