@oxyhq/services 5.4.8 → 5.5.1
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/core/index.js +0 -59
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/index.js +174 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +8 -23
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +49 -38
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/OxySignInButton.js +2 -8
- package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
- package/lib/commonjs/ui/hooks/index.js +15 -2
- package/lib/commonjs/ui/hooks/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuthFetch.js +182 -0
- package/lib/commonjs/ui/hooks/useAuthFetch.js.map +1 -0
- package/lib/commonjs/ui/hooks/useFollow.js +10 -29
- package/lib/commonjs/ui/hooks/useFollow.js.map +1 -1
- package/lib/commonjs/ui/hooks/useOxyFollow.js +190 -0
- package/lib/commonjs/ui/hooks/useOxyFollow.js.map +1 -0
- package/lib/commonjs/ui/index.js +183 -0
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +18 -14
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +37 -19
- package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +27 -9
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +2 -8
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/commonjs/ui/store/index.js +51 -255
- package/lib/commonjs/ui/store/index.js.map +1 -1
- package/lib/commonjs/ui/store/setupOxyStore.js +63 -0
- package/lib/commonjs/ui/store/setupOxyStore.js.map +1 -0
- package/lib/commonjs/ui/store/slices/authSlice.js +56 -0
- package/lib/commonjs/ui/store/slices/authSlice.js.map +1 -0
- package/lib/commonjs/ui/store/slices/followSlice.js +238 -0
- package/lib/commonjs/ui/store/slices/followSlice.js.map +1 -0
- package/lib/commonjs/ui/store/slices/index.js +129 -0
- package/lib/commonjs/ui/store/slices/index.js.map +1 -0
- package/lib/commonjs/ui/store/slices/types.js +19 -0
- package/lib/commonjs/ui/store/slices/types.js.map +1 -0
- package/lib/commonjs/ui/styles/index.js +11 -0
- package/lib/commonjs/ui/styles/index.js.map +1 -1
- package/lib/commonjs/ui/styles/shadows.js +123 -0
- package/lib/commonjs/ui/styles/shadows.js.map +1 -0
- package/lib/module/core/index.js +0 -59
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/index.js +14 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +8 -23
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +49 -38
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/OxySignInButton.js +2 -8
- package/lib/module/ui/components/OxySignInButton.js.map +1 -1
- package/lib/module/ui/hooks/index.js +2 -1
- package/lib/module/ui/hooks/index.js.map +1 -1
- package/lib/module/ui/hooks/useAuthFetch.js +177 -0
- package/lib/module/ui/hooks/useAuthFetch.js.map +1 -0
- package/lib/module/ui/hooks/useFollow.js +10 -29
- package/lib/module/ui/hooks/useFollow.js.map +1 -1
- package/lib/module/ui/hooks/useOxyFollow.js +186 -0
- package/lib/module/ui/hooks/useOxyFollow.js.map +1 -0
- package/lib/module/ui/index.js +12 -2
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +5 -1
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +37 -19
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +27 -9
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +2 -8
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/module/ui/store/index.js +23 -249
- package/lib/module/ui/store/index.js.map +1 -1
- package/lib/module/ui/store/setupOxyStore.js +59 -0
- package/lib/module/ui/store/setupOxyStore.js.map +1 -0
- package/lib/module/ui/store/slices/authSlice.js +48 -0
- package/lib/module/ui/store/slices/authSlice.js.map +1 -0
- package/lib/module/ui/store/slices/followSlice.js +232 -0
- package/lib/module/ui/store/slices/followSlice.js.map +1 -0
- package/lib/module/ui/store/slices/index.js +11 -0
- package/lib/module/ui/store/slices/index.js.map +1 -0
- package/lib/module/ui/store/slices/types.js +15 -0
- package/lib/module/ui/store/slices/types.js.map +1 -0
- package/lib/module/ui/styles/index.js +1 -0
- package/lib/module/ui/styles/index.js.map +1 -1
- package/lib/module/ui/styles/shadows.js +119 -0
- package/lib/module/ui/styles/shadows.js.map +1 -0
- package/lib/typescript/core/index.d.ts +0 -28
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +3 -5
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/index.d.ts +2 -1
- package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useAuthFetch.d.ts +33 -0
- package/lib/typescript/ui/hooks/useAuthFetch.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useFollow.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useOxyFollow.d.ts +81 -0
- package/lib/typescript/ui/hooks/useOxyFollow.d.ts.map +1 -0
- package/lib/typescript/ui/index.d.ts +3 -1
- package/lib/typescript/ui/index.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/types.d.ts +22 -4
- package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AppInfoScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/FileManagementScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/store/index.d.ts +19 -58
- package/lib/typescript/ui/store/index.d.ts.map +1 -1
- package/lib/typescript/ui/store/setupOxyStore.d.ts +29 -0
- package/lib/typescript/ui/store/setupOxyStore.d.ts.map +1 -0
- package/lib/typescript/ui/store/slices/authSlice.d.ts +32 -0
- package/lib/typescript/ui/store/slices/authSlice.d.ts.map +1 -0
- package/lib/typescript/ui/store/slices/followSlice.d.ts +120 -0
- package/lib/typescript/ui/store/slices/followSlice.d.ts.map +1 -0
- package/lib/typescript/ui/store/slices/index.d.ts +9 -0
- package/lib/typescript/ui/store/slices/index.d.ts.map +1 -0
- package/lib/typescript/ui/store/slices/types.d.ts +16 -0
- package/lib/typescript/ui/store/slices/types.d.ts.map +1 -0
- package/lib/typescript/ui/styles/index.d.ts +1 -0
- package/lib/typescript/ui/styles/index.d.ts.map +1 -1
- package/lib/typescript/ui/styles/shadows.d.ts +233 -0
- package/lib/typescript/ui/styles/shadows.d.ts.map +1 -0
- package/package.json +14 -15
- package/src/__tests__/ui/hooks/useOxyFollow.test.tsx +92 -0
- package/src/__tests__/ui/store/setupOxyStore.test.ts +50 -0
- package/src/__tests__/validate-structure.js +91 -0
- package/src/__tests__/validation.js +42 -0
- package/src/core/index.ts +0 -66
- package/src/index.ts +36 -4
- package/src/ui/components/FollowButton.tsx +11 -25
- package/src/ui/components/OxyProvider.tsx +48 -33
- package/src/ui/components/OxySignInButton.tsx +2 -6
- package/src/ui/hooks/index.ts +2 -1
- package/src/ui/hooks/useAuthFetch.ts +200 -0
- package/src/ui/hooks/useFollow.ts +10 -30
- package/src/ui/hooks/useOxyFollow.ts +188 -0
- package/src/ui/index.ts +34 -2
- package/src/ui/navigation/types.ts +24 -4
- package/src/ui/screens/AccountCenterScreen.tsx +5 -7
- package/src/ui/screens/AppInfoScreen.tsx +40 -23
- package/src/ui/screens/FileManagementScreen.tsx +268 -248
- package/src/ui/screens/karma/KarmaRewardsScreen.tsx +2 -5
- package/src/ui/store/index.ts +31 -245
- package/src/ui/store/setupOxyStore.ts +58 -0
- package/src/ui/store/slices/authSlice.ts +43 -0
- package/src/ui/store/slices/followSlice.ts +207 -0
- package/src/ui/store/slices/index.ts +31 -0
- package/src/ui/store/slices/types.ts +33 -0
- package/src/ui/styles/index.ts +1 -0
- package/src/ui/styles/shadows.ts +112 -0
|
@@ -3,269 +3,65 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isLoading: false,
|
|
12
|
-
error: null
|
|
13
|
-
};
|
|
14
|
-
const initialFollowState = {
|
|
15
|
-
followingUsers: {},
|
|
16
|
-
loadingUsers: {},
|
|
17
|
-
fetchingUsers: {},
|
|
18
|
-
errors: {}
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
store: true,
|
|
8
|
+
selectIsUserBeingFetched: true,
|
|
9
|
+
setupOxyStore: true,
|
|
10
|
+
oxyReducers: true
|
|
19
11
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
oxyServices
|
|
25
|
-
}, {
|
|
26
|
-
rejectWithValue
|
|
27
|
-
}) => {
|
|
28
|
-
try {
|
|
29
|
-
// Use the proper core service method
|
|
30
|
-
const response = await oxyServices.getFollowStatus(userId);
|
|
31
|
-
return {
|
|
32
|
-
userId,
|
|
33
|
-
isFollowing: response.isFollowing
|
|
34
|
-
};
|
|
35
|
-
} catch (error) {
|
|
36
|
-
// Ignore authentication errors when user isn't signed in - don't update state
|
|
37
|
-
if (error?.status === 401 || error?.message?.includes('Authentication')) {
|
|
38
|
-
return rejectWithValue('Not authenticated');
|
|
39
|
-
}
|
|
40
|
-
// Log other failures and reject to not update state
|
|
41
|
-
console.warn(`Failed to fetch follow status for user ${userId}:`, error);
|
|
42
|
-
return rejectWithValue(error?.message || 'Failed to fetch follow status');
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
// Prevent duplicate requests for the same user ID
|
|
46
|
-
condition: ({
|
|
47
|
-
userId
|
|
48
|
-
}, {
|
|
49
|
-
getState
|
|
50
|
-
}) => {
|
|
51
|
-
const state = getState();
|
|
52
|
-
// Defensive check for follow state
|
|
53
|
-
if (!state.follow?.fetchingUsers) {
|
|
54
|
-
return true; // Allow request if state not initialized
|
|
55
|
-
}
|
|
56
|
-
const isAlreadyFetching = state.follow.fetchingUsers[userId];
|
|
57
|
-
if (isAlreadyFetching) {
|
|
58
|
-
console.log(`⚡ Deduplicating fetch request for user ${userId} - already in progress`);
|
|
59
|
-
return false; // Cancel this request
|
|
60
|
-
}
|
|
61
|
-
return true; // Allow this request
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Async thunk for following/unfollowing users using core services
|
|
66
|
-
const toggleFollowUser = exports.toggleFollowUser = (0, _toolkit.createAsyncThunk)('follow/toggleFollowUser', async ({
|
|
67
|
-
userId,
|
|
68
|
-
oxyServices,
|
|
69
|
-
isCurrentlyFollowing
|
|
70
|
-
}, {
|
|
71
|
-
rejectWithValue,
|
|
72
|
-
dispatch
|
|
73
|
-
}) => {
|
|
74
|
-
try {
|
|
75
|
-
let response;
|
|
76
|
-
let newFollowState;
|
|
77
|
-
if (isCurrentlyFollowing) {
|
|
78
|
-
// Use the core service to unfollow user
|
|
79
|
-
response = await oxyServices.unfollowUser(userId);
|
|
80
|
-
newFollowState = false;
|
|
81
|
-
} else {
|
|
82
|
-
// Use the core service to follow user
|
|
83
|
-
response = await oxyServices.followUser(userId);
|
|
84
|
-
newFollowState = true;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Check if the response indicates success (different APIs might return different formats)
|
|
88
|
-
const isSuccess = response.success !== false && response.action !== 'error';
|
|
89
|
-
if (isSuccess) {
|
|
90
|
-
return {
|
|
91
|
-
userId,
|
|
92
|
-
isFollowing: newFollowState,
|
|
93
|
-
message: response.message || `Successfully ${newFollowState ? 'followed' : 'unfollowed'} user`
|
|
94
|
-
};
|
|
95
|
-
} else {
|
|
96
|
-
return rejectWithValue(response.message || `Failed to ${newFollowState ? 'follow' : 'unfollow'} user`);
|
|
97
|
-
}
|
|
98
|
-
} catch (error) {
|
|
99
|
-
// Enhanced error handling with state mismatch detection
|
|
100
|
-
let errorMessage = 'Network error occurred';
|
|
101
|
-
if (error?.message) {
|
|
102
|
-
errorMessage = error.message;
|
|
103
|
-
} else if (error?.response?.data?.message) {
|
|
104
|
-
errorMessage = error.response.data.message;
|
|
105
|
-
} else if (error?.data?.message) {
|
|
106
|
-
errorMessage = error.data.message;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Handle state mismatch errors by syncing with backend
|
|
110
|
-
if (errorMessage.includes('Not following this user') && isCurrentlyFollowing) {
|
|
111
|
-
console.warn(`State mismatch detected for user ${userId}: Frontend thinks following, backend says not following. Syncing state...`);
|
|
112
|
-
// Auto-sync with backend state
|
|
113
|
-
try {
|
|
114
|
-
const actualStatus = await oxyServices.getFollowStatus(userId);
|
|
115
|
-
dispatch({
|
|
116
|
-
type: 'follow/setFollowingStatus',
|
|
117
|
-
payload: {
|
|
118
|
-
userId,
|
|
119
|
-
isFollowing: actualStatus.isFollowing
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
return rejectWithValue('State synced with backend. Please try again.');
|
|
123
|
-
} catch (syncError) {
|
|
124
|
-
console.error('Failed to sync state with backend:', syncError);
|
|
125
|
-
}
|
|
126
|
-
} else if (errorMessage.includes('Already following this user') && !isCurrentlyFollowing) {
|
|
127
|
-
console.warn(`State mismatch detected for user ${userId}: Frontend thinks not following, backend says following. Syncing state...`);
|
|
128
|
-
// Auto-sync with backend state
|
|
129
|
-
try {
|
|
130
|
-
const actualStatus = await oxyServices.getFollowStatus(userId);
|
|
131
|
-
dispatch({
|
|
132
|
-
type: 'follow/setFollowingStatus',
|
|
133
|
-
payload: {
|
|
134
|
-
userId,
|
|
135
|
-
isFollowing: actualStatus.isFollowing
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
return rejectWithValue('State synced with backend. Please try again.');
|
|
139
|
-
} catch (syncError) {
|
|
140
|
-
console.error('Failed to sync state with backend:', syncError);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return rejectWithValue(errorMessage);
|
|
12
|
+
Object.defineProperty(exports, "oxyReducers", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _setupOxyStore.oxyReducers;
|
|
144
16
|
}
|
|
145
17
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
state.isLoading = true;
|
|
152
|
-
state.error = null;
|
|
153
|
-
},
|
|
154
|
-
loginSuccess(state, action) {
|
|
155
|
-
state.isLoading = false;
|
|
156
|
-
state.isAuthenticated = true;
|
|
157
|
-
state.user = action.payload;
|
|
158
|
-
},
|
|
159
|
-
loginFailure(state, action) {
|
|
160
|
-
state.isLoading = false;
|
|
161
|
-
state.error = action.payload;
|
|
162
|
-
},
|
|
163
|
-
logout(state) {
|
|
164
|
-
state.user = null;
|
|
165
|
-
state.isAuthenticated = false;
|
|
166
|
-
}
|
|
18
|
+
exports.selectIsUserBeingFetched = void 0;
|
|
19
|
+
Object.defineProperty(exports, "setupOxyStore", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _setupOxyStore.setupOxyStore;
|
|
167
23
|
}
|
|
168
24
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
state.errors[userId] = null;
|
|
180
|
-
},
|
|
181
|
-
clearFollowError(state, action) {
|
|
182
|
-
const userId = action.payload;
|
|
183
|
-
state.errors[userId] = null;
|
|
184
|
-
},
|
|
185
|
-
resetFollowState(state) {
|
|
186
|
-
state.followingUsers = {};
|
|
187
|
-
state.loadingUsers = {};
|
|
188
|
-
state.fetchingUsers = {};
|
|
189
|
-
state.errors = {};
|
|
25
|
+
exports.store = void 0;
|
|
26
|
+
var _slices = require("./slices");
|
|
27
|
+
Object.keys(_slices).forEach(function (key) {
|
|
28
|
+
if (key === "default" || key === "__esModule") return;
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
30
|
+
if (key in exports && exports[key] === _slices[key]) return;
|
|
31
|
+
Object.defineProperty(exports, key, {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _slices[key];
|
|
190
35
|
}
|
|
191
|
-
}
|
|
192
|
-
extraReducers: builder => {
|
|
193
|
-
builder
|
|
194
|
-
// Handle fetchFollowStatus
|
|
195
|
-
.addCase(fetchFollowStatus.pending, (state, action) => {
|
|
196
|
-
const {
|
|
197
|
-
userId
|
|
198
|
-
} = action.meta.arg;
|
|
199
|
-
state.fetchingUsers[userId] = true;
|
|
200
|
-
state.errors[userId] = null;
|
|
201
|
-
}).addCase(fetchFollowStatus.fulfilled, (state, action) => {
|
|
202
|
-
const {
|
|
203
|
-
userId,
|
|
204
|
-
isFollowing
|
|
205
|
-
} = action.payload;
|
|
206
|
-
state.followingUsers[userId] = isFollowing;
|
|
207
|
-
state.fetchingUsers[userId] = false;
|
|
208
|
-
state.errors[userId] = null;
|
|
209
|
-
}).addCase(fetchFollowStatus.rejected, (state, action) => {
|
|
210
|
-
const {
|
|
211
|
-
userId
|
|
212
|
-
} = action.meta.arg;
|
|
213
|
-
state.fetchingUsers[userId] = false;
|
|
214
|
-
// Don't update follow state on fetch errors - preserve existing/initial state
|
|
215
|
-
if (action.payload !== 'Not authenticated') {
|
|
216
|
-
console.warn(`Failed to fetch follow status for user ${userId}:`, action.payload);
|
|
217
|
-
}
|
|
218
|
-
})
|
|
219
|
-
// Handle toggleFollowUser
|
|
220
|
-
.addCase(toggleFollowUser.pending, (state, action) => {
|
|
221
|
-
const {
|
|
222
|
-
userId
|
|
223
|
-
} = action.meta.arg;
|
|
224
|
-
state.loadingUsers[userId] = true;
|
|
225
|
-
state.errors[userId] = null;
|
|
226
|
-
}).addCase(toggleFollowUser.fulfilled, (state, action) => {
|
|
227
|
-
const {
|
|
228
|
-
userId,
|
|
229
|
-
isFollowing
|
|
230
|
-
} = action.payload;
|
|
231
|
-
state.followingUsers[userId] = isFollowing;
|
|
232
|
-
state.loadingUsers[userId] = false;
|
|
233
|
-
state.errors[userId] = null;
|
|
234
|
-
}).addCase(toggleFollowUser.rejected, (state, action) => {
|
|
235
|
-
const {
|
|
236
|
-
userId
|
|
237
|
-
} = action.meta.arg;
|
|
238
|
-
state.loadingUsers[userId] = false;
|
|
239
|
-
state.errors[userId] = action.error.message || 'Failed to update follow status';
|
|
240
|
-
});
|
|
241
|
-
}
|
|
36
|
+
});
|
|
242
37
|
});
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
exports
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
exports.loginStart = loginStart;
|
|
253
|
-
const {
|
|
254
|
-
setFollowingStatus,
|
|
255
|
-
clearFollowError,
|
|
256
|
-
resetFollowState
|
|
257
|
-
} = followSlice.actions;
|
|
38
|
+
var _setupOxyStore = require("./setupOxyStore");
|
|
39
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
40
|
+
/**
|
|
41
|
+
* OxyHQ Services Redux Store
|
|
42
|
+
* Framework-agnostic, tree-shakable Redux integration
|
|
43
|
+
*
|
|
44
|
+
* This module exports individual slices, reducers, actions, selectors, and helpers
|
|
45
|
+
* for easy integration into any Redux store without internal dependencies.
|
|
46
|
+
*/
|
|
258
47
|
|
|
259
|
-
//
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
48
|
+
// Export individual slices and their components
|
|
49
|
+
|
|
50
|
+
// Export setup helper for easy integration
|
|
51
|
+
|
|
52
|
+
// Export types for external store integration
|
|
53
|
+
|
|
54
|
+
// For backward compatibility: create a legacy store instance
|
|
55
|
+
// This will be deprecated in favor of setupOxyStore()
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use setupOxyStore() instead to integrate with your app's store
|
|
59
|
+
* This internal store will be removed in a future version
|
|
60
|
+
*/
|
|
265
61
|
const store = exports.store = (0, _toolkit.configureStore)({
|
|
266
|
-
reducer:
|
|
267
|
-
auth: authSlice.reducer,
|
|
268
|
-
follow: followSlice.reducer
|
|
269
|
-
}
|
|
62
|
+
reducer: (0, _setupOxyStore.setupOxyStore)()
|
|
270
63
|
});
|
|
64
|
+
// Legacy selector (deprecated)
|
|
65
|
+
const selectIsUserBeingFetched = (state, userId) => state.follow.fetchingUsers[userId] ?? false;
|
|
66
|
+
exports.selectIsUserBeingFetched = selectIsUserBeingFetched;
|
|
271
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_slices","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_setupOxyStore","_toolkit","store","configureStore","reducer","setupOxyStore","selectIsUserBeingFetched","state","userId","follow","fetchingUsers"],"sourceRoot":"../../../../src","sources":["ui/store/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAGA,IAAAS,cAAA,GAAAb,OAAA;AAOA,IAAAc,QAAA,GAAAd,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAGA;;AAGA;;AAGA;AACA;;AAIA;AACA;AACA;AACA;AACO,MAAMe,KAAK,GAAAN,OAAA,CAAAM,KAAA,GAAG,IAAAC,uBAAc,EAAC;EAClCC,OAAO,EAAE,IAAAC,4BAAa,EAAC;AACzB,CAAC,CAAC;AAKF;AACO,MAAMC,wBAAwB,GAAGA,CAACC,KAAgB,EAAEC,MAAc,KACvED,KAAK,CAACE,MAAM,CAACC,aAAa,CAACF,MAAM,CAAC,IAAI,KAAK;AAACZ,OAAA,CAAAU,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.oxyReducers = void 0;
|
|
7
|
+
exports.setupOxyStore = setupOxyStore;
|
|
8
|
+
var _authSlice = require("./slices/authSlice");
|
|
9
|
+
var _followSlice = require("./slices/followSlice");
|
|
10
|
+
/**
|
|
11
|
+
* Setup helper for Oxy Store
|
|
12
|
+
* Returns all Oxy reducers ready to be spread into a host app's Redux store
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* const store = configureStore({
|
|
17
|
+
* reducer: {
|
|
18
|
+
* ...setupOxyStore(),
|
|
19
|
+
* appSpecificReducer,
|
|
20
|
+
* },
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function setupOxyStore() {
|
|
25
|
+
return {
|
|
26
|
+
auth: _authSlice.authReducer,
|
|
27
|
+
follow: _followSlice.followReducer
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Tree-shakable version where you can pick specific reducers
|
|
33
|
+
*
|
|
34
|
+
* Usage:
|
|
35
|
+
* ```ts
|
|
36
|
+
* const store = configureStore({
|
|
37
|
+
* reducer: {
|
|
38
|
+
* ...setupOxyStore.pick('auth'), // Only include auth
|
|
39
|
+
* // or
|
|
40
|
+
* ...setupOxyStore.pick('auth', 'follow'), // Include both
|
|
41
|
+
* appSpecificReducer,
|
|
42
|
+
* },
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
setupOxyStore.pick = function (...keys) {
|
|
47
|
+
const allReducers = setupOxyStore();
|
|
48
|
+
const pickedReducers = {};
|
|
49
|
+
for (const key of keys) {
|
|
50
|
+
if (key in allReducers) {
|
|
51
|
+
// Use bracket notation with explicit typing
|
|
52
|
+
pickedReducers[key] = allReducers[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return pickedReducers;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Export individual reducers for maximum flexibility
|
|
59
|
+
const oxyReducers = exports.oxyReducers = {
|
|
60
|
+
auth: _authSlice.authReducer,
|
|
61
|
+
follow: _followSlice.followReducer
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=setupOxyStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_authSlice","require","_followSlice","setupOxyStore","auth","authReducer","follow","followReducer","pick","keys","allReducers","pickedReducers","key","oxyReducers","exports"],"sourceRoot":"../../../../src","sources":["ui/store/setupOxyStore.ts"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,aAAaA,CAAA,EAAG;EAC9B,OAAO;IACLC,IAAI,EAAEC,sBAAW;IACjBC,MAAM,EAAEC;EACV,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAJ,aAAa,CAACK,IAAI,GAAG,UAAS,GAAGC,IAA8B,EAAE;EAC/D,MAAMC,WAAW,GAAGP,aAAa,CAAC,CAAC;EACnC,MAAMQ,cAAc,GAAG,CAAC,CAA8C;EAEtE,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;IACtB,IAAIG,GAAG,IAAIF,WAAW,EAAE;MACtB;MACCC,cAAc,CAAyBC,GAAG,CAAC,GAAGF,WAAW,CAACE,GAAG,CAAC;IACjE;EACF;EAEA,OAAOD,cAAc;AACvB,CAAC;;AAED;AACO,MAAME,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBT,IAAI,EAAEC,sBAAW;EACjBC,MAAM,EAAEC;AACV,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logout = exports.loginSuccess = exports.loginStart = exports.loginFailure = exports.authSlice = exports.authSelectors = exports.authReducer = exports.authActions = void 0;
|
|
7
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
8
|
+
var _types = require("./types");
|
|
9
|
+
const authSlice = exports.authSlice = (0, _toolkit.createSlice)({
|
|
10
|
+
name: 'auth',
|
|
11
|
+
initialState: _types.initialAuthState,
|
|
12
|
+
reducers: {
|
|
13
|
+
loginStart(state) {
|
|
14
|
+
state.isLoading = true;
|
|
15
|
+
state.error = null;
|
|
16
|
+
},
|
|
17
|
+
loginSuccess(state, action) {
|
|
18
|
+
state.isLoading = false;
|
|
19
|
+
state.isAuthenticated = true;
|
|
20
|
+
state.user = action.payload;
|
|
21
|
+
},
|
|
22
|
+
loginFailure(state, action) {
|
|
23
|
+
state.isLoading = false;
|
|
24
|
+
state.error = action.payload;
|
|
25
|
+
},
|
|
26
|
+
logout(state) {
|
|
27
|
+
state.user = null;
|
|
28
|
+
state.isAuthenticated = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Export actions
|
|
34
|
+
const authActions = exports.authActions = authSlice.actions;
|
|
35
|
+
const {
|
|
36
|
+
loginStart,
|
|
37
|
+
loginSuccess,
|
|
38
|
+
loginFailure,
|
|
39
|
+
logout
|
|
40
|
+
} = authSlice.actions;
|
|
41
|
+
|
|
42
|
+
// Export selectors
|
|
43
|
+
exports.logout = logout;
|
|
44
|
+
exports.loginFailure = loginFailure;
|
|
45
|
+
exports.loginSuccess = loginSuccess;
|
|
46
|
+
exports.loginStart = loginStart;
|
|
47
|
+
const authSelectors = exports.authSelectors = {
|
|
48
|
+
selectUser: state => state.auth.user,
|
|
49
|
+
selectIsAuthenticated: state => state.auth.isAuthenticated,
|
|
50
|
+
selectIsLoading: state => state.auth.isLoading,
|
|
51
|
+
selectError: state => state.auth.error
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Export reducer
|
|
55
|
+
const authReducer = exports.authReducer = authSlice.reducer;
|
|
56
|
+
//# sourceMappingURL=authSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_toolkit","require","_types","authSlice","exports","createSlice","name","initialState","initialAuthState","reducers","loginStart","state","isLoading","error","loginSuccess","action","isAuthenticated","user","payload","loginFailure","logout","authActions","actions","authSelectors","selectUser","auth","selectIsAuthenticated","selectIsLoading","selectError","authReducer","reducer"],"sourceRoot":"../../../../../src","sources":["ui/store/slices/authSlice.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAAE,oBAAW,EAAC;EACnCC,IAAI,EAAE,MAAM;EACZC,YAAY,EAAEC,uBAAgB;EAC9BC,QAAQ,EAAE;IACRC,UAAUA,CAACC,KAAgB,EAAE;MAC3BA,KAAK,CAACC,SAAS,GAAG,IAAI;MACtBD,KAAK,CAACE,KAAK,GAAG,IAAI;IACpB,CAAC;IACDC,YAAYA,CAACH,KAAgB,EAAEI,MAA2B,EAAE;MAC1DJ,KAAK,CAACC,SAAS,GAAG,KAAK;MACvBD,KAAK,CAACK,eAAe,GAAG,IAAI;MAC5BL,KAAK,CAACM,IAAI,GAAGF,MAAM,CAACG,OAAO;IAC7B,CAAC;IACDC,YAAYA,CAACR,KAAgB,EAAEI,MAA6B,EAAE;MAC5DJ,KAAK,CAACC,SAAS,GAAG,KAAK;MACvBD,KAAK,CAACE,KAAK,GAAGE,MAAM,CAACG,OAAO;IAC9B,CAAC;IACDE,MAAMA,CAACT,KAAgB,EAAE;MACvBA,KAAK,CAACM,IAAI,GAAG,IAAI;MACjBN,KAAK,CAACK,eAAe,GAAG,KAAK;IAC/B;EACF;AACF,CAAC,CAAC;;AAEF;AACO,MAAMK,WAAW,GAAAjB,OAAA,CAAAiB,WAAA,GAAGlB,SAAS,CAACmB,OAAO;AACrC,MAAM;EAAEZ,UAAU;EAAEI,YAAY;EAAEK,YAAY;EAAEC;AAAO,CAAC,GAAGjB,SAAS,CAACmB,OAAO;;AAEnF;AAAAlB,OAAA,CAAAgB,MAAA,GAAAA,MAAA;AAAAhB,OAAA,CAAAe,YAAA,GAAAA,YAAA;AAAAf,OAAA,CAAAU,YAAA,GAAAA,YAAA;AAAAV,OAAA,CAAAM,UAAA,GAAAA,UAAA;AACO,MAAMa,aAAa,GAAAnB,OAAA,CAAAmB,aAAA,GAAG;EAC3BC,UAAU,EAAGb,KAA0B,IAAKA,KAAK,CAACc,IAAI,CAACR,IAAI;EAC3DS,qBAAqB,EAAGf,KAA0B,IAAKA,KAAK,CAACc,IAAI,CAACT,eAAe;EACjFW,eAAe,EAAGhB,KAA0B,IAAKA,KAAK,CAACc,IAAI,CAACb,SAAS;EACrEgB,WAAW,EAAGjB,KAA0B,IAAKA,KAAK,CAACc,IAAI,CAACZ;AAC1D,CAAC;;AAED;AACO,MAAMgB,WAAW,GAAAzB,OAAA,CAAAyB,WAAA,GAAG1B,SAAS,CAAC2B,OAAO","ignoreList":[]}
|