@oxyhq/services 22.10.0 → 22.11.0
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/ui/components/AvatarCameraBadge.js +42 -0
- package/lib/commonjs/ui/components/AvatarCameraBadge.js.map +1 -0
- package/lib/commonjs/ui/components/OxyAccountDialogScreen.js +41 -19
- package/lib/commonjs/ui/components/OxyAccountDialogScreen.js.map +1 -1
- package/lib/commonjs/ui/components/OxyAuthChooser.js +640 -168
- package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/commonjs/ui/components/ProfileButton.js +14 -0
- package/lib/commonjs/ui/components/ProfileButton.js.map +1 -1
- package/lib/commonjs/ui/components/ProfileSummaryCard.js +3 -23
- package/lib/commonjs/ui/components/ProfileSummaryCard.js.map +1 -1
- package/lib/commonjs/ui/components/SurfaceScreen.js +41 -5
- package/lib/commonjs/ui/components/SurfaceScreen.js.map +1 -1
- package/lib/commonjs/ui/components/oxyAuthChooserStyles.js +78 -26
- package/lib/commonjs/ui/components/oxyAuthChooserStyles.js.map +1 -1
- package/lib/commonjs/ui/components/photogrid/JustifiedPhotoGrid.js +83 -23
- package/lib/commonjs/ui/components/photogrid/JustifiedPhotoGrid.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +73 -37
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/queryKeys.js +18 -1
- package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useFileQueries.js +129 -0
- package/lib/commonjs/ui/hooks/queries/useFileQueries.js.map +1 -0
- package/lib/commonjs/ui/hooks/useAvatarPicker.js +36 -48
- package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +1 -1
- package/lib/commonjs/ui/hooks/useReduceMotion.js +57 -0
- package/lib/commonjs/ui/hooks/useReduceMotion.js.map +1 -0
- package/lib/commonjs/ui/hooks/useSurfaceHeader.js +1 -1
- package/lib/commonjs/ui/hooks/useSurfaceHeader.js.map +1 -1
- package/lib/commonjs/ui/navigation/accountDialogManager.js +22 -0
- package/lib/commonjs/ui/navigation/accountDialogManager.js.map +1 -1
- package/lib/commonjs/ui/navigation/bottomSheetManager.js +5 -6
- package/lib/commonjs/ui/navigation/bottomSheetManager.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +1 -0
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/navigation/surfaceNavStack.js +62 -15
- package/lib/commonjs/ui/navigation/surfaceNavStack.js.map +1 -1
- package/lib/commonjs/ui/navigation/surfaceRegistry.js +38 -17
- package/lib/commonjs/ui/navigation/surfaceRegistry.js.map +1 -1
- package/lib/commonjs/ui/navigation/surfaces.js +98 -21
- package/lib/commonjs/ui/navigation/surfaces.js.map +1 -1
- package/lib/commonjs/ui/screens/AvatarCropScreen.js +281 -279
- package/lib/commonjs/ui/screens/AvatarCropScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ChangeAvatarScreen.js +301 -0
- package/lib/commonjs/ui/screens/ChangeAvatarScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/FileManagementScreen.js +194 -431
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +16 -48
- package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/fileManagement/FileLibraryError.js +63 -0
- package/lib/commonjs/ui/screens/fileManagement/FileLibraryError.js.map +1 -0
- package/lib/commonjs/ui/screens/fileManagement/PhotoPickerSection.js +54 -41
- package/lib/commonjs/ui/screens/fileManagement/PhotoPickerSection.js.map +1 -1
- package/lib/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.js +44 -81
- package/lib/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.js.map +1 -1
- package/lib/commonjs/ui/stores/resetSessionScopedStores.js +8 -3
- package/lib/commonjs/ui/stores/resetSessionScopedStores.js.map +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js +11 -2
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/commonjs/ui/utils/fileManagement.js +0 -79
- package/lib/commonjs/ui/utils/fileManagement.js.map +1 -1
- package/lib/module/ui/components/AvatarCameraBadge.js +40 -0
- package/lib/module/ui/components/AvatarCameraBadge.js.map +1 -0
- package/lib/module/ui/components/OxyAccountDialogScreen.js +41 -19
- package/lib/module/ui/components/OxyAccountDialogScreen.js.map +1 -1
- package/lib/module/ui/components/OxyAuthChooser.js +642 -171
- package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/module/ui/components/ProfileButton.js +15 -1
- package/lib/module/ui/components/ProfileButton.js.map +1 -1
- package/lib/module/ui/components/ProfileSummaryCard.js +2 -23
- package/lib/module/ui/components/ProfileSummaryCard.js.map +1 -1
- package/lib/module/ui/components/SurfaceScreen.js +43 -7
- package/lib/module/ui/components/SurfaceScreen.js.map +1 -1
- package/lib/module/ui/components/oxyAuthChooserStyles.js +78 -26
- package/lib/module/ui/components/oxyAuthChooserStyles.js.map +1 -1
- package/lib/module/ui/components/photogrid/JustifiedPhotoGrid.js +83 -25
- package/lib/module/ui/components/photogrid/JustifiedPhotoGrid.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +74 -38
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/queries/queryKeys.js +16 -0
- package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -1
- package/lib/module/ui/hooks/queries/useFileQueries.js +120 -0
- package/lib/module/ui/hooks/queries/useFileQueries.js.map +1 -0
- package/lib/module/ui/hooks/useAvatarPicker.js +37 -49
- package/lib/module/ui/hooks/useAvatarPicker.js.map +1 -1
- package/lib/module/ui/hooks/useReduceMotion.js +53 -0
- package/lib/module/ui/hooks/useReduceMotion.js.map +1 -0
- package/lib/module/ui/hooks/useSurfaceHeader.js +1 -1
- package/lib/module/ui/hooks/useSurfaceHeader.js.map +1 -1
- package/lib/module/ui/navigation/accountDialogManager.js +20 -0
- package/lib/module/ui/navigation/accountDialogManager.js.map +1 -1
- package/lib/module/ui/navigation/bottomSheetManager.js +6 -7
- package/lib/module/ui/navigation/bottomSheetManager.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +1 -0
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/navigation/surfaceNavStack.js +62 -15
- package/lib/module/ui/navigation/surfaceNavStack.js.map +1 -1
- package/lib/module/ui/navigation/surfaceRegistry.js +38 -17
- package/lib/module/ui/navigation/surfaceRegistry.js.map +1 -1
- package/lib/module/ui/navigation/surfaces.js +97 -22
- package/lib/module/ui/navigation/surfaces.js.map +1 -1
- package/lib/module/ui/screens/AvatarCropScreen.js +283 -281
- package/lib/module/ui/screens/AvatarCropScreen.js.map +1 -1
- package/lib/module/ui/screens/ChangeAvatarScreen.js +298 -0
- package/lib/module/ui/screens/ChangeAvatarScreen.js.map +1 -0
- package/lib/module/ui/screens/FileManagementScreen.js +196 -433
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/WelcomeNewUserScreen.js +17 -49
- package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
- package/lib/module/ui/screens/fileManagement/FileLibraryError.js +59 -0
- package/lib/module/ui/screens/fileManagement/FileLibraryError.js.map +1 -0
- package/lib/module/ui/screens/fileManagement/PhotoPickerSection.js +54 -42
- package/lib/module/ui/screens/fileManagement/PhotoPickerSection.js.map +1 -1
- package/lib/module/ui/screens/fileManagement/hooks/useFileUploadState.js +45 -81
- package/lib/module/ui/screens/fileManagement/hooks/useFileUploadState.js.map +1 -1
- package/lib/module/ui/stores/resetSessionScopedStores.js +8 -3
- package/lib/module/ui/stores/resetSessionScopedStores.js.map +1 -1
- package/lib/module/ui/utils/avatarUtils.js +11 -2
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/ui/utils/fileManagement.js +0 -78
- package/lib/module/ui/utils/fileManagement.js.map +1 -1
- package/lib/typescript/commonjs/ui/components/AvatarCameraBadge.d.ts +4 -0
- package/lib/typescript/commonjs/ui/components/AvatarCameraBadge.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts +2 -1
- package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ProfileSummaryCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/SurfaceScreen.d.ts +1 -4
- package/lib/typescript/commonjs/ui/components/SurfaceScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/oxyAuthChooserStyles.d.ts +71 -19
- package/lib/typescript/commonjs/ui/components/oxyAuthChooserStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/photogrid/JustifiedPhotoGrid.d.ts +10 -8
- package/lib/typescript/commonjs/ui/components/photogrid/JustifiedPhotoGrid.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/queryKeys.d.ts +9 -0
- package/lib/typescript/commonjs/ui/hooks/queries/queryKeys.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useFileQueries.d.ts +50 -0
- package/lib/typescript/commonjs/ui/hooks/queries/useFileQueries.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useAvatarPicker.d.ts +15 -10
- package/lib/typescript/commonjs/ui/hooks/useAvatarPicker.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useReduceMotion.d.ts +14 -0
- package/lib/typescript/commonjs/ui/hooks/useReduceMotion.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useSurfaceHeader.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts +13 -0
- package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts +4 -5
- package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/surfaceNavStack.d.ts +21 -0
- package/lib/typescript/commonjs/ui/navigation/surfaceNavStack.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/surfaceRegistry.d.ts +73 -13
- package/lib/typescript/commonjs/ui/navigation/surfaceRegistry.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/surfaces.d.ts +42 -11
- package/lib/typescript/commonjs/ui/navigation/surfaces.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AvatarCropScreen.d.ts +18 -5
- package/lib/typescript/commonjs/ui/screens/AvatarCropScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/ChangeAvatarScreen.d.ts +34 -0
- package/lib/typescript/commonjs/ui/screens/ChangeAvatarScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/FileManagementScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/fileManagement/FileLibraryError.d.ts +23 -0
- package/lib/typescript/commonjs/ui/screens/fileManagement/FileLibraryError.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/fileManagement/PhotoPickerSection.d.ts +4 -0
- package/lib/typescript/commonjs/ui/screens/fileManagement/PhotoPickerSection.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.d.ts +10 -2
- package/lib/typescript/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/stores/resetSessionScopedStores.d.ts +8 -1
- package/lib/typescript/commonjs/ui/stores/resetSessionScopedStores.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/types/navigation.d.ts +2 -0
- package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/fileManagement.d.ts +0 -48
- package/lib/typescript/commonjs/ui/utils/fileManagement.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/AvatarCameraBadge.d.ts +4 -0
- package/lib/typescript/module/ui/components/AvatarCameraBadge.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts +2 -1
- package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ProfileButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ProfileSummaryCard.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/SurfaceScreen.d.ts +1 -4
- package/lib/typescript/module/ui/components/SurfaceScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/oxyAuthChooserStyles.d.ts +71 -19
- package/lib/typescript/module/ui/components/oxyAuthChooserStyles.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/photogrid/JustifiedPhotoGrid.d.ts +10 -8
- package/lib/typescript/module/ui/components/photogrid/JustifiedPhotoGrid.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/queryKeys.d.ts +9 -0
- package/lib/typescript/module/ui/hooks/queries/queryKeys.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useFileQueries.d.ts +50 -0
- package/lib/typescript/module/ui/hooks/queries/useFileQueries.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useAvatarPicker.d.ts +15 -10
- package/lib/typescript/module/ui/hooks/useAvatarPicker.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useReduceMotion.d.ts +14 -0
- package/lib/typescript/module/ui/hooks/useReduceMotion.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useSurfaceHeader.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts +13 -0
- package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +4 -5
- package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/surfaceNavStack.d.ts +21 -0
- package/lib/typescript/module/ui/navigation/surfaceNavStack.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/surfaceRegistry.d.ts +73 -13
- package/lib/typescript/module/ui/navigation/surfaceRegistry.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/surfaces.d.ts +42 -11
- package/lib/typescript/module/ui/navigation/surfaces.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AvatarCropScreen.d.ts +18 -5
- package/lib/typescript/module/ui/screens/AvatarCropScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/ChangeAvatarScreen.d.ts +34 -0
- package/lib/typescript/module/ui/screens/ChangeAvatarScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/FileManagementScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/fileManagement/FileLibraryError.d.ts +23 -0
- package/lib/typescript/module/ui/screens/fileManagement/FileLibraryError.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/fileManagement/PhotoPickerSection.d.ts +4 -0
- package/lib/typescript/module/ui/screens/fileManagement/PhotoPickerSection.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/fileManagement/hooks/useFileUploadState.d.ts +10 -2
- package/lib/typescript/module/ui/screens/fileManagement/hooks/useFileUploadState.d.ts.map +1 -1
- package/lib/typescript/module/ui/stores/resetSessionScopedStores.d.ts +8 -1
- package/lib/typescript/module/ui/stores/resetSessionScopedStores.d.ts.map +1 -1
- package/lib/typescript/module/ui/types/navigation.d.ts +2 -0
- package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/fileManagement.d.ts +0 -48
- package/lib/typescript/module/ui/utils/fileManagement.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/ui/components/AvatarCameraBadge.tsx +35 -0
- package/src/ui/components/OxyAccountDialogScreen.tsx +38 -15
- package/src/ui/components/OxyAuthChooser.tsx +722 -185
- package/src/ui/components/ProfileButton.tsx +16 -1
- package/src/ui/components/ProfileSummaryCard.tsx +2 -25
- package/src/ui/components/SurfaceScreen.tsx +48 -14
- package/src/ui/components/oxyAuthChooserStyles.ts +75 -23
- package/src/ui/components/photogrid/JustifiedPhotoGrid.tsx +158 -84
- package/src/ui/components/photogrid/__tests__/chunkPhotos.test.ts +51 -0
- package/src/ui/context/OxyContext.tsx +74 -34
- package/src/ui/hooks/queries/queryKeys.ts +15 -0
- package/src/ui/hooks/queries/useFileQueries.ts +162 -0
- package/src/ui/hooks/useAvatarPicker.ts +38 -53
- package/src/ui/hooks/useReduceMotion.ts +58 -0
- package/src/ui/hooks/useSurfaceHeader.ts +2 -1
- package/src/ui/navigation/__tests__/getSurfaceConfig.test.ts +55 -7
- package/src/ui/navigation/__tests__/surfaceNavStack.test.ts +81 -0
- package/src/ui/navigation/accountDialogManager.ts +28 -0
- package/src/ui/navigation/bottomSheetManager.ts +6 -7
- package/src/ui/navigation/routes.ts +3 -1
- package/src/ui/navigation/surfaceNavStack.ts +72 -9
- package/src/ui/navigation/surfaceRegistry.ts +91 -17
- package/src/ui/navigation/surfaces.ts +108 -29
- package/src/ui/screens/AvatarCropScreen.tsx +336 -298
- package/src/ui/screens/ChangeAvatarScreen.tsx +359 -0
- package/src/ui/screens/FileManagementScreen.tsx +189 -432
- package/src/ui/screens/WelcomeNewUserScreen.tsx +18 -48
- package/src/ui/screens/fileManagement/FileLibraryError.tsx +56 -0
- package/src/ui/screens/fileManagement/PhotoPickerSection.tsx +56 -46
- package/src/ui/screens/fileManagement/hooks/useFileUploadState.ts +55 -71
- package/src/ui/stores/resetSessionScopedStores.ts +8 -3
- package/src/ui/types/navigation.ts +2 -0
- package/src/ui/utils/avatarUtils.ts +11 -2
- package/src/ui/utils/fileManagement.ts +1 -101
- package/lib/commonjs/ui/stores/fileStore.js +0 -153
- package/lib/commonjs/ui/stores/fileStore.js.map +0 -1
- package/lib/module/ui/stores/fileStore.js +0 -145
- package/lib/module/ui/stores/fileStore.js.map +0 -1
- package/lib/typescript/commonjs/ui/stores/fileStore.d.ts +0 -31
- package/lib/typescript/commonjs/ui/stores/fileStore.d.ts.map +0 -1
- package/lib/typescript/module/ui/stores/fileStore.d.ts +0 -31
- package/lib/typescript/module/ui/stores/fileStore.d.ts.map +0 -1
- package/src/ui/stores/fileStore.ts +0 -118
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { create } from 'zustand';
|
|
4
|
-
// Shallow compare two file metadata objects by keys/values
|
|
5
|
-
function shallowEqualFile(a, b) {
|
|
6
|
-
if (a === b) return true;
|
|
7
|
-
if (!a || !b) return false;
|
|
8
|
-
const aKeys = Object.keys(a);
|
|
9
|
-
const bKeys = Object.keys(b);
|
|
10
|
-
if (aKeys.length !== bKeys.length) return false;
|
|
11
|
-
for (const k of aKeys) {
|
|
12
|
-
// treat metadata/variants shallowly by reference
|
|
13
|
-
if (a[k] !== b[k]) return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Basic upload progress type for aggregate tracking
|
|
19
|
-
|
|
20
|
-
const initialState = {
|
|
21
|
-
files: {},
|
|
22
|
-
order: [],
|
|
23
|
-
uploading: false,
|
|
24
|
-
deleting: null,
|
|
25
|
-
uploadProgress: null
|
|
26
|
-
};
|
|
27
|
-
export const useFileStore = create((set, get) => ({
|
|
28
|
-
...initialState,
|
|
29
|
-
setFiles: (files, opts) => set(state => {
|
|
30
|
-
const merge = opts?.merge !== false; // default true
|
|
31
|
-
if (!merge) {
|
|
32
|
-
const map = {};
|
|
33
|
-
const order = [];
|
|
34
|
-
files.forEach(f => {
|
|
35
|
-
map[f.id] = f;
|
|
36
|
-
order.push(f.id);
|
|
37
|
-
});
|
|
38
|
-
// detect if identical to avoid redundant updates
|
|
39
|
-
const sameOrder = order.length === state.order.length && order.every((id, i) => id === state.order[i]);
|
|
40
|
-
let sameFiles = sameOrder;
|
|
41
|
-
if (sameOrder) {
|
|
42
|
-
sameFiles = order.every(id => state.files[id] && shallowEqualFile(state.files[id], map[id]));
|
|
43
|
-
}
|
|
44
|
-
if (sameOrder && sameFiles) return state;
|
|
45
|
-
return {
|
|
46
|
-
files: map,
|
|
47
|
-
order
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const newFiles = {
|
|
51
|
-
...state.files
|
|
52
|
-
};
|
|
53
|
-
const newOrder = [...state.order];
|
|
54
|
-
let changed = false;
|
|
55
|
-
files.forEach(f => {
|
|
56
|
-
const prev = state.files[f.id];
|
|
57
|
-
const merged = {
|
|
58
|
-
...(prev || {}),
|
|
59
|
-
...f
|
|
60
|
-
};
|
|
61
|
-
if (!prev || !shallowEqualFile(prev, merged)) {
|
|
62
|
-
newFiles[f.id] = merged;
|
|
63
|
-
changed = true;
|
|
64
|
-
}
|
|
65
|
-
if (!newOrder.includes(f.id)) {
|
|
66
|
-
newOrder.unshift(f.id);
|
|
67
|
-
changed = true;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
if (!changed) return state;
|
|
71
|
-
return {
|
|
72
|
-
files: newFiles,
|
|
73
|
-
order: newOrder
|
|
74
|
-
};
|
|
75
|
-
}),
|
|
76
|
-
addFile: (file, opts) => set(state => {
|
|
77
|
-
const prepend = opts?.prepend !== false; // default true
|
|
78
|
-
if (state.files[file.id]) {
|
|
79
|
-
if (shallowEqualFile(state.files[file.id], file)) return state;
|
|
80
|
-
return {
|
|
81
|
-
files: {
|
|
82
|
-
...state.files,
|
|
83
|
-
[file.id]: file
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
files: {
|
|
89
|
-
...state.files,
|
|
90
|
-
[file.id]: file
|
|
91
|
-
},
|
|
92
|
-
order: prepend ? [file.id, ...state.order] : [...state.order, file.id]
|
|
93
|
-
};
|
|
94
|
-
}),
|
|
95
|
-
updateFile: (id, patch) => set(state => {
|
|
96
|
-
const existing = state.files[id];
|
|
97
|
-
if (!existing) return state;
|
|
98
|
-
const updated = {
|
|
99
|
-
...existing,
|
|
100
|
-
...patch
|
|
101
|
-
};
|
|
102
|
-
if (shallowEqualFile(existing, updated)) return state;
|
|
103
|
-
return {
|
|
104
|
-
files: {
|
|
105
|
-
...state.files,
|
|
106
|
-
[id]: updated
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}),
|
|
110
|
-
removeFile: id => set(state => {
|
|
111
|
-
if (!state.files[id]) return state;
|
|
112
|
-
const {
|
|
113
|
-
[id]: _removed,
|
|
114
|
-
...rest
|
|
115
|
-
} = state.files;
|
|
116
|
-
const newOrder = state.order.filter(fid => fid !== id);
|
|
117
|
-
return {
|
|
118
|
-
files: rest,
|
|
119
|
-
order: newOrder
|
|
120
|
-
};
|
|
121
|
-
}),
|
|
122
|
-
setUploading: val => set({
|
|
123
|
-
uploading: val
|
|
124
|
-
}),
|
|
125
|
-
setDeleting: id => set({
|
|
126
|
-
deleting: id
|
|
127
|
-
}),
|
|
128
|
-
setUploadProgress: p => set({
|
|
129
|
-
uploadProgress: p
|
|
130
|
-
}),
|
|
131
|
-
reset: () => set(initialState)
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
// selectors
|
|
135
|
-
export const useFiles = () => {
|
|
136
|
-
const files = useFileStore(s => s.files);
|
|
137
|
-
const order = useFileStore(s => s.order);
|
|
138
|
-
// Return stable array when contents unchanged
|
|
139
|
-
const out = order.map(id => files[id]);
|
|
140
|
-
return out;
|
|
141
|
-
};
|
|
142
|
-
export const useUploading = () => useFileStore(s => s.uploading);
|
|
143
|
-
export const useUploadAggregateProgress = () => useFileStore(s => s.uploadProgress);
|
|
144
|
-
export const useDeleting = () => useFileStore(s => s.deleting);
|
|
145
|
-
//# sourceMappingURL=fileStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["create","shallowEqualFile","a","b","aKeys","Object","keys","bKeys","length","k","initialState","files","order","uploading","deleting","uploadProgress","useFileStore","set","get","setFiles","opts","state","merge","map","forEach","f","id","push","sameOrder","every","i","sameFiles","newFiles","newOrder","changed","prev","merged","includes","unshift","addFile","file","prepend","updateFile","patch","existing","updated","removeFile","_removed","rest","filter","fid","setUploading","val","setDeleting","setUploadProgress","p","reset","useFiles","s","out","useUploading","useUploadAggregateProgress","useDeleting"],"sourceRoot":"../../../../src","sources":["ui/stores/fileStore.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,SAAS;AAGhC;AACA,SAASC,gBAAgBA,CAACC,CAAe,EAAEC,CAAe,EAAW;EACnE,IAAID,CAAC,KAAKC,CAAC,EAAE,OAAO,IAAI;EACxB,IAAI,CAACD,CAAC,IAAI,CAACC,CAAC,EAAE,OAAO,KAAK;EAC1B,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACJ,CAAC,CAAC;EAC5B,MAAMK,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACH,CAAC,C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7C,YAAY,CAAC0C,CAAC,IAAIA,CAAC,CAAC3C,cAAc,CAAC;AACnF,OAAO,MAAM+C,WAAW,GAAGA,CAAA,KAAM9C,YAAY,CAAC0C,CAAC,IAAIA,CAAC,CAAC5C,QAAQ,CAAC","ignoreList":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { FileMetadata } from '@oxyhq/core';
|
|
2
|
-
export interface FileUploadAggregateProgress {
|
|
3
|
-
current: number;
|
|
4
|
-
total: number;
|
|
5
|
-
}
|
|
6
|
-
interface FileState {
|
|
7
|
-
files: Record<string, FileMetadata>;
|
|
8
|
-
order: string[];
|
|
9
|
-
uploading: boolean;
|
|
10
|
-
deleting: string | null;
|
|
11
|
-
uploadProgress: FileUploadAggregateProgress | null;
|
|
12
|
-
setFiles: (files: FileMetadata[], opts?: {
|
|
13
|
-
merge?: boolean;
|
|
14
|
-
}) => void;
|
|
15
|
-
addFile: (file: FileMetadata, opts?: {
|
|
16
|
-
prepend?: boolean;
|
|
17
|
-
}) => void;
|
|
18
|
-
updateFile: (id: string, patch: Partial<FileMetadata>) => void;
|
|
19
|
-
removeFile: (id: string) => void;
|
|
20
|
-
setUploading: (val: boolean) => void;
|
|
21
|
-
setDeleting: (id: string | null) => void;
|
|
22
|
-
setUploadProgress: (p: FileUploadAggregateProgress | null) => void;
|
|
23
|
-
reset: () => void;
|
|
24
|
-
}
|
|
25
|
-
export declare const useFileStore: import("zustand").UseBoundStore<import("zustand").StoreApi<FileState>>;
|
|
26
|
-
export declare const useFiles: () => FileMetadata[];
|
|
27
|
-
export declare const useUploading: () => boolean;
|
|
28
|
-
export declare const useUploadAggregateProgress: () => FileUploadAggregateProgress | null;
|
|
29
|
-
export declare const useDeleting: () => string | null;
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=fileStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/stores/fileStore.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AACpF,eAAO,MAAM,WAAW,qBAAsC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { FileMetadata } from '@oxyhq/core';
|
|
2
|
-
export interface FileUploadAggregateProgress {
|
|
3
|
-
current: number;
|
|
4
|
-
total: number;
|
|
5
|
-
}
|
|
6
|
-
interface FileState {
|
|
7
|
-
files: Record<string, FileMetadata>;
|
|
8
|
-
order: string[];
|
|
9
|
-
uploading: boolean;
|
|
10
|
-
deleting: string | null;
|
|
11
|
-
uploadProgress: FileUploadAggregateProgress | null;
|
|
12
|
-
setFiles: (files: FileMetadata[], opts?: {
|
|
13
|
-
merge?: boolean;
|
|
14
|
-
}) => void;
|
|
15
|
-
addFile: (file: FileMetadata, opts?: {
|
|
16
|
-
prepend?: boolean;
|
|
17
|
-
}) => void;
|
|
18
|
-
updateFile: (id: string, patch: Partial<FileMetadata>) => void;
|
|
19
|
-
removeFile: (id: string) => void;
|
|
20
|
-
setUploading: (val: boolean) => void;
|
|
21
|
-
setDeleting: (id: string | null) => void;
|
|
22
|
-
setUploadProgress: (p: FileUploadAggregateProgress | null) => void;
|
|
23
|
-
reset: () => void;
|
|
24
|
-
}
|
|
25
|
-
export declare const useFileStore: import("zustand").UseBoundStore<import("zustand").StoreApi<FileState>>;
|
|
26
|
-
export declare const useFiles: () => FileMetadata[];
|
|
27
|
-
export declare const useUploading: () => boolean;
|
|
28
|
-
export declare const useUploadAggregateProgress: () => FileUploadAggregateProgress | null;
|
|
29
|
-
export declare const useDeleting: () => string | null;
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=fileStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/stores/fileStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgBhD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;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3
|
-
import type { FileMetadata } from '@oxyhq/core';
|
|
4
|
-
// Shallow compare two file metadata objects by keys/values
|
|
5
|
-
function shallowEqualFile(a: FileMetadata, b: FileMetadata): boolean {
|
|
6
|
-
if (a === b) return true;
|
|
7
|
-
if (!a || !b) return false;
|
|
8
|
-
const aKeys = Object.keys(a);
|
|
9
|
-
const bKeys = Object.keys(b);
|
|
10
|
-
if (aKeys.length !== bKeys.length) return false;
|
|
11
|
-
for (const k of aKeys) {
|
|
12
|
-
// treat metadata/variants shallowly by reference
|
|
13
|
-
if (a[k as keyof FileMetadata] !== b[k as keyof FileMetadata]) return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Basic upload progress type for aggregate tracking
|
|
19
|
-
export interface FileUploadAggregateProgress {
|
|
20
|
-
current: number;
|
|
21
|
-
total: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface FileState {
|
|
25
|
-
files: Record<string, FileMetadata>;
|
|
26
|
-
order: string[]; // maintain insertion / sort order
|
|
27
|
-
uploading: boolean;
|
|
28
|
-
deleting: string | null;
|
|
29
|
-
uploadProgress: FileUploadAggregateProgress | null;
|
|
30
|
-
// actions
|
|
31
|
-
setFiles: (files: FileMetadata[], opts?: { merge?: boolean }) => void;
|
|
32
|
-
addFile: (file: FileMetadata, opts?: { prepend?: boolean }) => void;
|
|
33
|
-
updateFile: (id: string, patch: Partial<FileMetadata>) => void;
|
|
34
|
-
removeFile: (id: string) => void;
|
|
35
|
-
setUploading: (val: boolean) => void;
|
|
36
|
-
setDeleting: (id: string | null) => void;
|
|
37
|
-
setUploadProgress: (p: FileUploadAggregateProgress | null) => void;
|
|
38
|
-
reset: () => void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const initialState = {
|
|
42
|
-
files: {} as Record<string, FileMetadata>,
|
|
43
|
-
order: [] as string[],
|
|
44
|
-
uploading: false,
|
|
45
|
-
deleting: null as string | null,
|
|
46
|
-
uploadProgress: null as FileUploadAggregateProgress | null,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const useFileStore = create<FileState>((set, get) => ({
|
|
50
|
-
...initialState,
|
|
51
|
-
setFiles: (files, opts) => set(state => {
|
|
52
|
-
const merge = opts?.merge !== false; // default true
|
|
53
|
-
if (!merge) {
|
|
54
|
-
const map: Record<string, FileMetadata> = {};
|
|
55
|
-
const order: string[] = [];
|
|
56
|
-
files.forEach(f => { map[f.id] = f; order.push(f.id); });
|
|
57
|
-
// detect if identical to avoid redundant updates
|
|
58
|
-
const sameOrder = order.length === state.order.length && order.every((id, i) => id === state.order[i]);
|
|
59
|
-
let sameFiles = sameOrder;
|
|
60
|
-
if (sameOrder) {
|
|
61
|
-
sameFiles = order.every(id => state.files[id] && shallowEqualFile(state.files[id], map[id] as FileMetadata));
|
|
62
|
-
}
|
|
63
|
-
if (sameOrder && sameFiles) return state;
|
|
64
|
-
return { files: map, order };
|
|
65
|
-
}
|
|
66
|
-
const newFiles = { ...state.files };
|
|
67
|
-
const newOrder = [...state.order];
|
|
68
|
-
let changed = false;
|
|
69
|
-
files.forEach(f => {
|
|
70
|
-
const prev = state.files[f.id];
|
|
71
|
-
const merged = { ...(prev || {}), ...f } as FileMetadata;
|
|
72
|
-
if (!prev || !shallowEqualFile(prev, merged)) { newFiles[f.id] = merged; changed = true; }
|
|
73
|
-
if (!newOrder.includes(f.id)) { newOrder.unshift(f.id); changed = true; }
|
|
74
|
-
});
|
|
75
|
-
if (!changed) return state;
|
|
76
|
-
return { files: newFiles, order: newOrder };
|
|
77
|
-
}),
|
|
78
|
-
addFile: (file, opts) => set(state => {
|
|
79
|
-
const prepend = opts?.prepend !== false; // default true
|
|
80
|
-
if (state.files[file.id]) {
|
|
81
|
-
if (shallowEqualFile(state.files[file.id], file)) return state;
|
|
82
|
-
return { files: { ...state.files, [file.id]: file } };
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
files: { ...state.files, [file.id]: file },
|
|
86
|
-
order: prepend ? [file.id, ...state.order] : [...state.order, file.id],
|
|
87
|
-
};
|
|
88
|
-
}),
|
|
89
|
-
updateFile: (id, patch) => set(state => {
|
|
90
|
-
const existing = state.files[id];
|
|
91
|
-
if (!existing) return state;
|
|
92
|
-
const updated = { ...existing, ...patch } as FileMetadata;
|
|
93
|
-
if (shallowEqualFile(existing, updated)) return state;
|
|
94
|
-
return { files: { ...state.files, [id]: updated } };
|
|
95
|
-
}),
|
|
96
|
-
removeFile: (id) => set(state => {
|
|
97
|
-
if (!state.files[id]) return state;
|
|
98
|
-
const { [id]: _removed, ...rest } = state.files;
|
|
99
|
-
const newOrder = state.order.filter(fid => fid !== id);
|
|
100
|
-
return { files: rest, order: newOrder };
|
|
101
|
-
}),
|
|
102
|
-
setUploading: (val) => set({ uploading: val }),
|
|
103
|
-
setDeleting: (id) => set({ deleting: id }),
|
|
104
|
-
setUploadProgress: (p) => set({ uploadProgress: p }),
|
|
105
|
-
reset: () => set(initialState),
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
// selectors
|
|
109
|
-
export const useFiles = () => {
|
|
110
|
-
const files = useFileStore(s => s.files);
|
|
111
|
-
const order = useFileStore(s => s.order);
|
|
112
|
-
// Return stable array when contents unchanged
|
|
113
|
-
const out = order.map((id: string) => files[id]);
|
|
114
|
-
return out;
|
|
115
|
-
};
|
|
116
|
-
export const useUploading = () => useFileStore(s => s.uploading);
|
|
117
|
-
export const useUploadAggregateProgress = () => useFileStore(s => s.uploadProgress);
|
|
118
|
-
export const useDeleting = () => useFileStore(s => s.deleting);
|