@burdenoff/microfe-files 2026.1014.12 → 2026.1016.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/README.md +37 -0
- package/dist/config/index.js.map +1 -1
- package/dist/files/FilesRoot.js +17 -10
- package/dist/files/FilesRoot.js.map +1 -1
- package/dist/files/FilesRoutes.d.ts +1 -1
- package/dist/files/FilesRoutes.js.map +1 -1
- package/dist/files/components/ActionMenu.js.map +1 -1
- package/dist/files/components/ConfirmDialog.d.ts +1 -1
- package/dist/files/components/ConfirmDialog.js.map +1 -1
- package/dist/files/components/ContextMenu.d.ts +1 -1
- package/dist/files/components/ContextMenu.js.map +1 -1
- package/dist/files/components/CopyDialog.js.map +1 -1
- package/dist/files/components/EmptyState.d.ts +1 -1
- package/dist/files/components/EmptyState.js.map +1 -1
- package/dist/files/components/FileBrowser.js +2 -1
- package/dist/files/components/FileBrowser.js.map +1 -1
- package/dist/files/components/FileCard.d.ts.map +1 -1
- package/dist/files/components/FileCard.js +150 -142
- package/dist/files/components/FileCard.js.map +1 -1
- package/dist/files/components/FileInfoPanel.d.ts +1 -1
- package/dist/files/components/FileInfoPanel.d.ts.map +1 -1
- package/dist/files/components/FileInfoPanel.js +3 -7
- package/dist/files/components/FileInfoPanel.js.map +1 -1
- package/dist/files/components/FileListItem.d.ts.map +1 -1
- package/dist/files/components/FileListItem.js +1 -1
- package/dist/files/components/FileListItem.js.map +1 -1
- package/dist/files/components/FilePreviewModal.d.ts +1 -1
- package/dist/files/components/FilePreviewModal.d.ts.map +1 -1
- package/dist/files/components/FilePreviewModal.js +5 -0
- package/dist/files/components/FilePreviewModal.js.map +1 -1
- package/dist/files/components/FileVersionPanel.d.ts.map +1 -1
- package/dist/files/components/FileVersionPanel.js +122 -121
- package/dist/files/components/FileVersionPanel.js.map +1 -1
- package/dist/files/components/FolderCard.d.ts.map +1 -1
- package/dist/files/components/FolderCard.js +1 -1
- package/dist/files/components/FolderCard.js.map +1 -1
- package/dist/files/components/MoveDialog.js +2 -2
- package/dist/files/components/MoveDialog.js.map +1 -1
- package/dist/files/components/SearchBar.d.ts +1 -1
- package/dist/files/components/SearchBar.d.ts.map +1 -1
- package/dist/files/components/SearchBar.js +132 -128
- package/dist/files/components/SearchBar.js.map +1 -1
- package/dist/files/components/ShareDialog.d.ts +1 -1
- package/dist/files/components/ShareDialog.js.map +1 -1
- package/dist/files/components/StorageBanner.js.map +1 -1
- package/dist/files/components/TabBar.d.ts +1 -1
- package/dist/files/components/TabBar.js.map +1 -1
- package/dist/files/components/Toast.d.ts +1 -1
- package/dist/files/components/Toast.js.map +1 -1
- package/dist/files/components/UploadQueue.d.ts +1 -1
- package/dist/files/components/UploadQueue.js +1 -1
- package/dist/files/components/UploadQueue.js.map +1 -1
- package/dist/files/components/contextMenuItems.d.ts +4 -4
- package/dist/files/components/contextMenuItems.js.map +1 -1
- package/dist/files/components/viewers/AudioPlayer.d.ts +1 -1
- package/dist/files/components/viewers/AudioPlayer.js.map +1 -1
- package/dist/files/components/viewers/CodeViewer.d.ts +1 -1
- package/dist/files/components/viewers/CodeViewer.js.map +1 -1
- package/dist/files/components/viewers/ImageViewer.d.ts +1 -1
- package/dist/files/components/viewers/ImageViewer.js.map +1 -1
- package/dist/files/components/viewers/PDFViewer.d.ts +1 -1
- package/dist/files/components/viewers/PDFViewer.js.map +1 -1
- package/dist/files/components/viewers/TextViewer.d.ts +1 -1
- package/dist/files/components/viewers/TextViewer.js.map +1 -1
- package/dist/files/components/viewers/VideoPlayer.d.ts +1 -1
- package/dist/files/components/viewers/VideoPlayer.js.map +1 -1
- package/dist/files/graphql-types.d.ts +2 -17
- package/dist/files/graphql-types.d.ts.map +1 -1
- package/dist/files/hooks/useBatchOperations.d.ts +6 -1
- package/dist/files/hooks/useBatchOperations.d.ts.map +1 -1
- package/dist/files/hooks/useBatchOperations.js +8 -7
- package/dist/files/hooks/useBatchOperations.js.map +1 -1
- package/dist/files/hooks/useBinItems.d.ts.map +1 -1
- package/dist/files/hooks/useBinItems.js +14 -12
- package/dist/files/hooks/useBinItems.js.map +1 -1
- package/dist/files/hooks/useBrowsePage.d.ts +131 -8
- package/dist/files/hooks/useBrowsePage.d.ts.map +1 -1
- package/dist/files/hooks/useBrowsePage.js +23 -22
- package/dist/files/hooks/useBrowsePage.js.map +1 -1
- package/dist/files/hooks/useCopyFile.d.ts +22 -1
- package/dist/files/hooks/useCopyFile.d.ts.map +1 -1
- package/dist/files/hooks/useCopyFile.js +9 -8
- package/dist/files/hooks/useCopyFile.js.map +1 -1
- package/dist/files/hooks/useCreateFolder.d.ts +23 -1
- package/dist/files/hooks/useCreateFolder.d.ts.map +1 -1
- package/dist/files/hooks/useCreateFolder.js +16 -9
- package/dist/files/hooks/useCreateFolder.js.map +1 -1
- package/dist/files/hooks/useCreateFolderShare.d.ts +20 -1
- package/dist/files/hooks/useCreateFolderShare.d.ts.map +1 -1
- package/dist/files/hooks/useCreateFolderShare.js +22 -7
- package/dist/files/hooks/useCreateFolderShare.js.map +1 -1
- package/dist/files/hooks/useCreateShare.d.ts +19 -1
- package/dist/files/hooks/useCreateShare.d.ts.map +1 -1
- package/dist/files/hooks/useCreateShare.js +22 -7
- package/dist/files/hooks/useCreateShare.js.map +1 -1
- package/dist/files/hooks/useDeleteFile.d.ts +1 -1
- package/dist/files/hooks/useDeleteFile.d.ts.map +1 -1
- package/dist/files/hooks/useDeleteFile.js +8 -7
- package/dist/files/hooks/useDeleteFile.js.map +1 -1
- package/dist/files/hooks/useDeleteFolder.d.ts +1 -1
- package/dist/files/hooks/useDeleteFolder.d.ts.map +1 -1
- package/dist/files/hooks/useDeleteFolder.js +9 -8
- package/dist/files/hooks/useDeleteFolder.js.map +1 -1
- package/dist/files/hooks/useDragDrop.js.map +1 -1
- package/dist/files/hooks/useFileVersions.d.ts +36 -9
- package/dist/files/hooks/useFileVersions.d.ts.map +1 -1
- package/dist/files/hooks/useFileVersions.js +14 -13
- package/dist/files/hooks/useFileVersions.js.map +1 -1
- package/dist/files/hooks/useFoldersQuery.d.ts +8 -4
- package/dist/files/hooks/useFoldersQuery.d.ts.map +1 -1
- package/dist/files/hooks/useFoldersQuery.js +7 -6
- package/dist/files/hooks/useFoldersQuery.js.map +1 -1
- package/dist/files/hooks/useKeyboardNavigation.js +7 -8
- package/dist/files/hooks/useKeyboardNavigation.js.map +1 -1
- package/dist/files/hooks/useMoveFile.d.ts +22 -1
- package/dist/files/hooks/useMoveFile.d.ts.map +1 -1
- package/dist/files/hooks/useMoveFile.js +9 -8
- package/dist/files/hooks/useMoveFile.js.map +1 -1
- package/dist/files/hooks/useMoveFolder.d.ts +22 -1
- package/dist/files/hooks/useMoveFolder.d.ts.map +1 -1
- package/dist/files/hooks/useMoveFolder.js +9 -8
- package/dist/files/hooks/useMoveFolder.js.map +1 -1
- package/dist/files/hooks/usePermanentlyDeleteFile.d.ts +1 -1
- package/dist/files/hooks/usePermanentlyDeleteFile.d.ts.map +1 -1
- package/dist/files/hooks/usePermanentlyDeleteFile.js +8 -7
- package/dist/files/hooks/usePermanentlyDeleteFile.js.map +1 -1
- package/dist/files/hooks/usePermanentlyDeleteFolder.d.ts +1 -1
- package/dist/files/hooks/usePermanentlyDeleteFolder.d.ts.map +1 -1
- package/dist/files/hooks/usePermanentlyDeleteFolder.js +8 -7
- package/dist/files/hooks/usePermanentlyDeleteFolder.js.map +1 -1
- package/dist/files/hooks/useRecentFiles.d.ts.map +1 -1
- package/dist/files/hooks/useRecentFiles.js +13 -11
- package/dist/files/hooks/useRecentFiles.js.map +1 -1
- package/dist/files/hooks/useRenameFile.d.ts +22 -1
- package/dist/files/hooks/useRenameFile.d.ts.map +1 -1
- package/dist/files/hooks/useRenameFile.js +9 -8
- package/dist/files/hooks/useRenameFile.js.map +1 -1
- package/dist/files/hooks/useRenameFolder.d.ts +22 -1
- package/dist/files/hooks/useRenameFolder.d.ts.map +1 -1
- package/dist/files/hooks/useRenameFolder.js +9 -8
- package/dist/files/hooks/useRenameFolder.js.map +1 -1
- package/dist/files/hooks/useRestoreFile.d.ts +22 -1
- package/dist/files/hooks/useRestoreFile.d.ts.map +1 -1
- package/dist/files/hooks/useRestoreFile.js +8 -7
- package/dist/files/hooks/useRestoreFile.js.map +1 -1
- package/dist/files/hooks/useRestoreFolder.d.ts +22 -1
- package/dist/files/hooks/useRestoreFolder.d.ts.map +1 -1
- package/dist/files/hooks/useRestoreFolder.js +8 -7
- package/dist/files/hooks/useRestoreFolder.js.map +1 -1
- package/dist/files/hooks/useSearch.d.ts +2 -3
- package/dist/files/hooks/useSearch.d.ts.map +1 -1
- package/dist/files/hooks/useSearch.js +14 -12
- package/dist/files/hooks/useSearch.js.map +1 -1
- package/dist/files/hooks/useStarredItems.d.ts +2 -3
- package/dist/files/hooks/useStarredItems.d.ts.map +1 -1
- package/dist/files/hooks/useStarredItems.js +12 -10
- package/dist/files/hooks/useStarredItems.js.map +1 -1
- package/dist/files/hooks/useStorageQuota.d.ts.map +1 -1
- package/dist/files/hooks/useStorageQuota.js +17 -16
- package/dist/files/hooks/useStorageQuota.js.map +1 -1
- package/dist/files/hooks/useToast.js.map +1 -1
- package/dist/files/hooks/useToggleStar.d.ts +43 -1
- package/dist/files/hooks/useToggleStar.d.ts.map +1 -1
- package/dist/files/hooks/useToggleStar.js +9 -8
- package/dist/files/hooks/useToggleStar.js.map +1 -1
- package/dist/files/hooks/useUploadFile.d.ts +23 -1
- package/dist/files/hooks/useUploadFile.d.ts.map +1 -1
- package/dist/files/hooks/useUploadFile.js +28 -27
- package/dist/files/hooks/useUploadFile.js.map +1 -1
- package/dist/files/hooks/useUploadQueueState.d.ts +32 -0
- package/dist/files/hooks/useUploadQueueState.d.ts.map +1 -0
- package/dist/files/hooks/useUploadQueueState.js +61 -0
- package/dist/files/hooks/useUploadQueueState.js.map +1 -0
- package/dist/files/index.js +4 -3
- package/dist/files/pages/BrowserPage.d.ts +1 -1
- package/dist/files/pages/BrowserPage.d.ts.map +1 -1
- package/dist/files/pages/BrowserPage.js +383 -387
- package/dist/files/pages/BrowserPage.js.map +1 -1
- package/dist/files/pages/ShareAccessPage.d.ts +1 -1
- package/dist/files/pages/ShareAccessPage.js.map +1 -1
- package/dist/files/providers/FilesProvider.js.map +1 -1
- package/dist/files/store/filesStore.js.map +1 -1
- package/dist/files/types.d.ts.map +1 -1
- package/dist/files/utils/events.js.map +1 -1
- package/dist/files/utils/fileViewModel.d.ts +7 -0
- package/dist/files/utils/fileViewModel.d.ts.map +1 -0
- package/dist/files/utils/fileViewModel.js +34 -0
- package/dist/files/utils/fileViewModel.js.map +1 -0
- package/dist/files/utils/i18n.js.map +1 -1
- package/dist/files/utils/index.js +19 -19
- package/dist/files/utils/index.js.map +1 -1
- package/dist/files/utils/quotaUtils.js +1 -2
- package/dist/files/utils/thumbnail.js +19 -23
- package/dist/files/utils/thumbnail.js.map +1 -1
- package/dist/files/utils/uploadDigest.js +1 -1
- package/dist/files/utils/uploadDigest.js.map +1 -1
- package/dist/generated/global-operations.d.ts +4 -1
- package/dist/generated/global-operations.d.ts.map +1 -1
- package/dist/generated/global-types.d.ts +16 -21
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-operations.d.ts +503 -1784
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +15278 -1110
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +90013 -24889
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +16 -0
- package/dist/generated/wspace-types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/shared/hooks/useTr.js.map +1 -1
- package/dist/translations/en.js.map +1 -1
- package/dist/utils/nativeBridge.js +1 -2
- package/package.json +24 -22
- package/dist/files.d.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToggleStar.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useToggleStar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useToggleStar.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useToggleStar.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;CACzB;AAED,eAAO,MAAM,aAAa;gCA4BY,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBpD,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ToggleFileStarredDocument as e, ToggleFolderStarredDocument as t } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useMutation as n } from "@apollo/client/react";
|
|
2
3
|
//#region src/files/hooks/useToggleStar.ts
|
|
3
|
-
var
|
|
4
|
-
let [
|
|
4
|
+
var r = () => {
|
|
5
|
+
let [r, { loading: i, error: a }] = n(e, { refetchQueries: [
|
|
5
6
|
"GetFilesRootBrowsePage",
|
|
6
7
|
"GetFilesFolderBrowsePage",
|
|
7
8
|
"GetFilesStarredPage",
|
|
8
9
|
"GetFilesRecentPage",
|
|
9
10
|
"GetFolders"
|
|
10
|
-
] }), [
|
|
11
|
+
] }), [o, { loading: s, error: c }] = n(t, { refetchQueries: [
|
|
11
12
|
"GetFilesRootBrowsePage",
|
|
12
13
|
"GetFilesFolderBrowsePage",
|
|
13
14
|
"GetFilesStarredPage",
|
|
@@ -15,12 +16,12 @@ var n = () => {
|
|
|
15
16
|
"GetFolders"
|
|
16
17
|
] });
|
|
17
18
|
return {
|
|
18
|
-
mutateAsync: async ({ id: e, type: t }) => t === "file" ? (await
|
|
19
|
-
isPending:
|
|
20
|
-
error:
|
|
19
|
+
mutateAsync: async ({ id: e, type: t }) => t === "file" ? (await r({ variables: { id: e } })).data?.toggleFileStarred : (await o({ variables: { id: e } })).data?.toggleFolderStarred,
|
|
20
|
+
isPending: i || s,
|
|
21
|
+
error: a || c
|
|
21
22
|
};
|
|
22
23
|
};
|
|
23
24
|
//#endregion
|
|
24
|
-
export {
|
|
25
|
+
export { r as useToggleStar };
|
|
25
26
|
|
|
26
27
|
//# sourceMappingURL=useToggleStar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToggleStar.js","names":[],"sources":["../../../src/files/hooks/useToggleStar.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"useToggleStar.js","names":["useToggleStar","toggleFileStarredMutation","fileLoading","fileError","useMutation","ToggleFileStarredDocument","toggleFolderStarredMutation","folderLoading","folderError","ToggleFolderStarredDocument","type"],"sources":["../../../src/files/hooks/useToggleStar.ts"],"sourcesContent":["import { useMutation } from \"@apollo/client/react\";\nimport {\n ToggleFileStarredDocument,\n ToggleFolderStarredDocument,\n} from \"../../generated/wspace-operations\";\n\nexport interface ToggleStarInput {\n id: string;\n type: \"file\" | \"folder\";\n}\n\nexport const useToggleStar = () => {\n const [\n toggleFileStarredMutation,\n { loading: fileLoading, error: fileError },\n ] = useMutation(ToggleFileStarredDocument, {\n refetchQueries: [\n \"GetFilesRootBrowsePage\",\n \"GetFilesFolderBrowsePage\",\n \"GetFilesStarredPage\",\n \"GetFilesRecentPage\",\n \"GetFolders\",\n ],\n });\n\n const [\n toggleFolderStarredMutation,\n { loading: folderLoading, error: folderError },\n ] = useMutation(ToggleFolderStarredDocument, {\n refetchQueries: [\n \"GetFilesRootBrowsePage\",\n \"GetFilesFolderBrowsePage\",\n \"GetFilesStarredPage\",\n \"GetFilesRecentPage\",\n \"GetFolders\",\n ],\n });\n\n return {\n mutateAsync: async ({ id, type }: ToggleStarInput) => {\n if (type === \"file\") {\n const result = await toggleFileStarredMutation({\n variables: { id },\n });\n return result.data?.toggleFileStarred;\n } else {\n const result = await toggleFolderStarredMutation({\n variables: { id },\n });\n return result.data?.toggleFolderStarred;\n }\n },\n isPending: fileLoading || folderLoading,\n error: fileError || folderError,\n };\n};\n"],"mappings":";;;AAWA,IAAaA,UAAsB;CACjC,IAAM,CACJC,GACA,EAAE,SAASC,GAAa,OAAOC,OAC7BC,EAAYC,GAA2B,EACzC,gBAAgB;EACd;EACA;EACA;EACA;EACA;CACF,EACF,CAAC,GAEK,CACJC,GACA,EAAE,SAASC,GAAe,OAAOC,OAC/BJ,EAAYK,GAA6B,EAC3C,gBAAgB;EACd;EACA;EACA;EACA;EACA;CACF,EACF,CAAC;CAED,OAAO;EACL,aAAa,OAAO,EAAE,OAAI,cACpBC,MAAS,UAIJ,MAHcT,EAA0B,EAC7C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM,qBAKb,MAHcK,EAA4B,EAC/C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;EAGxB,WAAWJ,KAAeK;EAC1B,OAAOJ,KAAaK;CACtB;AACF"}
|
|
@@ -17,7 +17,29 @@ export declare const useUploadFile: () => {
|
|
|
17
17
|
file: File;
|
|
18
18
|
folderId?: string;
|
|
19
19
|
onProgress?: (progress: number) => void;
|
|
20
|
-
}) => Promise<
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
workspaceId: string;
|
|
23
|
+
folderId: string | null;
|
|
24
|
+
status: import('../../generated/wspace-types').FileStatus;
|
|
25
|
+
canRead: boolean | null;
|
|
26
|
+
canUpdate: boolean | null;
|
|
27
|
+
canDelete: boolean | null;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string | null;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
extension: string;
|
|
32
|
+
size: string;
|
|
33
|
+
downloadUrl: string | null;
|
|
34
|
+
visibility: import('../../generated/wspace-types').FileVisibility;
|
|
35
|
+
starred: boolean;
|
|
36
|
+
downloadCount: number;
|
|
37
|
+
viewCount: number;
|
|
38
|
+
uploadedById: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
s3Key: string;
|
|
42
|
+
}>;
|
|
21
43
|
isPending: boolean;
|
|
22
44
|
error: Error | null;
|
|
23
45
|
pause: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUploadFile.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useUploadFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUploadFile.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useUploadFile.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,aAAa;0BA+BW;QACjC,IAAI,EAAE,IAAI,CAAC;QACX,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;KACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4KF,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useFilesContext as e } from "../providers/FilesProvider.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CompleteUploadDocument as t, InitiateUploadDocument as n } from "../../generated/wspace-operations.js";
|
|
3
3
|
import { isQuotaExhaustedError as r } from "../utils/quotaUtils.js";
|
|
4
4
|
import { computeUploadSha256 as i } from "../utils/uploadDigest.js";
|
|
5
5
|
import { useCallback as a, useRef as o, useState as s } from "react";
|
|
6
|
+
import { useMutation as c } from "@apollo/client/react";
|
|
6
7
|
//#region src/files/hooks/useUploadFile.ts
|
|
7
|
-
var
|
|
8
|
-
let { workspaceId:
|
|
8
|
+
var l = () => {
|
|
9
|
+
let { workspaceId: l } = e(), [u, d] = s(!1), [f, p] = s(null), m = o(null), h = o(!1), [g] = c(n), [_] = c(t, {
|
|
9
10
|
refetchQueries: [
|
|
10
11
|
"GetFilesRootBrowsePage",
|
|
11
12
|
"GetFilesFolderBrowsePage",
|
|
@@ -18,10 +19,10 @@ var c = () => {
|
|
|
18
19
|
mutateAsync: async (e) => {
|
|
19
20
|
let { file: t, folderId: n, onProgress: a } = e, o = t.name.split(".").pop() || "";
|
|
20
21
|
try {
|
|
21
|
-
|
|
22
|
-
let e = await i(t, () =>
|
|
23
|
-
if (
|
|
24
|
-
let s = await
|
|
22
|
+
d(!0), p(null), h.current = !1, a?.(0);
|
|
23
|
+
let e = await i(t, () => h.current);
|
|
24
|
+
if (h.current) throw Error("Upload paused");
|
|
25
|
+
let s = await g({ variables: { input: {
|
|
25
26
|
fileName: t.name,
|
|
26
27
|
fileSize: t.size.toString(),
|
|
27
28
|
mimeType: t.type || "application/octet-stream",
|
|
@@ -34,18 +35,18 @@ var c = () => {
|
|
|
34
35
|
let e = s.error.message || "";
|
|
35
36
|
throw Error(e || "Failed to initiate upload");
|
|
36
37
|
}
|
|
37
|
-
let c = s.data?.initiateUpload, l = c?.session,
|
|
38
|
-
if (!l || !
|
|
39
|
-
if (
|
|
38
|
+
let c = s.data?.initiateUpload, l = c?.session, u = c?.uploadUrl;
|
|
39
|
+
if (!l || !u) throw Error("Failed to initiate upload session");
|
|
40
|
+
if (h.current) throw Error("Upload paused");
|
|
40
41
|
if (a?.(10), !(await new Promise((e, n) => {
|
|
41
42
|
let r = new XMLHttpRequest();
|
|
42
|
-
|
|
43
|
-
if (e.lengthComputable && !
|
|
43
|
+
m.current = r, r.upload.addEventListener("progress", (e) => {
|
|
44
|
+
if (e.lengthComputable && !h.current) {
|
|
44
45
|
let t = 10 + Math.round(e.loaded / e.total * 80);
|
|
45
46
|
a?.(t);
|
|
46
47
|
}
|
|
47
48
|
}), r.addEventListener("load", () => {
|
|
48
|
-
r.status >= 200 && r.status < 300 ? (
|
|
49
|
+
r.status >= 200 && r.status < 300 ? (h.current || a?.(90), e(new Response(r.response, {
|
|
49
50
|
status: r.status,
|
|
50
51
|
statusText: r.statusText,
|
|
51
52
|
headers: new Headers(r.getAllResponseHeaders().split("\r\n").reduce((e, t) => {
|
|
@@ -54,38 +55,38 @@ var c = () => {
|
|
|
54
55
|
}, {}))
|
|
55
56
|
}))) : n(/* @__PURE__ */ Error(`Upload failed with status ${r.status}`));
|
|
56
57
|
}), r.addEventListener("error", () => {
|
|
57
|
-
|
|
58
|
+
h.current || n(/* @__PURE__ */ Error("Upload failed"));
|
|
58
59
|
}), r.addEventListener("abort", () => {
|
|
59
|
-
|
|
60
|
-
}), r.open("PUT",
|
|
60
|
+
h.current ? n(/* @__PURE__ */ Error("Upload paused")) : n(/* @__PURE__ */ Error("Upload aborted"));
|
|
61
|
+
}), r.open("PUT", u), r.setRequestHeader("Content-Type", t.type), r.send(t);
|
|
61
62
|
})).ok) throw Error("Failed to upload file to S3");
|
|
62
|
-
if (
|
|
63
|
-
let
|
|
63
|
+
if (h.current) throw Error("Upload paused");
|
|
64
|
+
let f = await _({ variables: { input: {
|
|
64
65
|
sessionId: l.id,
|
|
65
66
|
fileSize: t.size.toString(),
|
|
66
67
|
sha256Hash: e,
|
|
67
68
|
folderId: n || null
|
|
68
69
|
} } });
|
|
69
|
-
if (
|
|
70
|
-
let v =
|
|
70
|
+
if (f.error) throw r(f.error) ? f.error : (f.error.message, Error(f.error.message || "Failed to complete upload"));
|
|
71
|
+
let v = f.data?.completeUpload?.file;
|
|
71
72
|
if (!v) throw Error("Upload completed but file data was not returned. The file may not have been created properly.");
|
|
72
73
|
return a?.(100), v;
|
|
73
74
|
} catch (e) {
|
|
74
75
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Upload failed");
|
|
75
|
-
throw
|
|
76
|
+
throw p(t), t;
|
|
76
77
|
} finally {
|
|
77
|
-
|
|
78
|
+
d(!1), m.current = null;
|
|
78
79
|
}
|
|
79
80
|
},
|
|
80
|
-
isPending:
|
|
81
|
-
error:
|
|
81
|
+
isPending: u,
|
|
82
|
+
error: f,
|
|
82
83
|
pause: a(() => {
|
|
83
|
-
|
|
84
|
+
h.current || (h.current = !0, m.current?.abort(), m.current = null);
|
|
84
85
|
}, []),
|
|
85
|
-
isPaused: a(() =>
|
|
86
|
+
isPaused: a(() => h.current, [])
|
|
86
87
|
};
|
|
87
88
|
};
|
|
88
89
|
//#endregion
|
|
89
|
-
export {
|
|
90
|
+
export { l as useUploadFile };
|
|
90
91
|
|
|
91
92
|
//# sourceMappingURL=useUploadFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUploadFile.js","names":[],"sources":["../../../src/files/hooks/useUploadFile.ts"],"sourcesContent":["import { useState, useRef, useCallback } from \"react\";\nimport {\n useInitiateUploadMutation,\n useCompleteUploadMutation,\n} from \"../../generated/wspace-operations\";\nimport { useFilesContext } from \"../providers/FilesProvider\";\nimport { isQuotaExhaustedError } from \"../utils/quotaUtils\";\nimport { computeUploadSha256 } from \"../utils/uploadDigest\";\n\nexport interface InitiateUploadInput {\n fileName: string;\n fileSize: number;\n mimeType: string;\n folderId?: string;\n}\n\nexport interface CompleteUploadInput {\n sessionId: string;\n fileSize: string;\n}\n\nexport interface UploadController {\n pause: () => void;\n isPaused: () => boolean;\n}\n\nexport const useUploadFile = () => {\n const { workspaceId } = useFilesContext();\n const [isUploading, setIsUploading] = useState(false);\n const [uploadError, setUploadError] = useState<Error | null>(null);\n\n const activeXhrRef = useRef<XMLHttpRequest | null>(null);\n const isPausedRef = useRef(false);\n\n const [initiateUploadMutation] = useInitiateUploadMutation();\n const [completeUploadMutation] = useCompleteUploadMutation({\n refetchQueries: [\n \"GetFilesRootBrowsePage\",\n \"GetFilesFolderBrowsePage\",\n \"GetFilesRecentPage\",\n \"GetFiles\",\n ],\n // Named refetches also include skipped (standby) Apollo observables.\n // The root browser keeps a skipped folder query with an empty folder ID.\n onQueryUpdated: (query) => query.options.fetchPolicy !== \"standby\",\n });\n\n const pause = useCallback(() => {\n if (!isPausedRef.current) {\n isPausedRef.current = true;\n activeXhrRef.current?.abort();\n activeXhrRef.current = null;\n }\n }, []);\n\n const isPaused = useCallback(() => isPausedRef.current, []);\n\n const mutateAsync = async (params: {\n file: File;\n folderId?: string;\n onProgress?: (progress: number) => void;\n }) => {\n const { file, folderId, onProgress } = params;\n const extension = file.name.split(\".\").pop() || \"\";\n\n try {\n setIsUploading(true);\n setUploadError(null);\n isPausedRef.current = false;\n\n onProgress?.(0);\n\n // Declare the same exact-byte digest before creating a session and on completion.\n // The Files owner separately records whether storage verified this declaration.\n const sha256Hash = await computeUploadSha256(\n file,\n () => isPausedRef.current,\n );\n if (isPausedRef.current) {\n throw new Error(\"Upload paused\");\n }\n\n const initiateResult = await initiateUploadMutation({\n variables: {\n input: {\n fileName: file.name,\n fileSize: file.size.toString(),\n mimeType: file.type || \"application/octet-stream\",\n extension: extension,\n sha256Hash,\n folderId: folderId || null,\n },\n },\n });\n\n // Check for GraphQL errors FIRST - before checking data\n // This ensures backend error messages are properly surfaced to the user\n if (initiateResult.error) {\n if (isQuotaExhaustedError(initiateResult.error)) {\n throw initiateResult.error;\n }\n const errorMsg = initiateResult.error.message || \"\";\n throw new Error(errorMsg || \"Failed to initiate upload\");\n }\n\n const result = initiateResult.data?.initiateUpload;\n const session = result?.session;\n const uploadUrl = result?.uploadUrl;\n\n if (!session || !uploadUrl) {\n throw new Error(\"Failed to initiate upload session\");\n }\n\n if (isPausedRef.current) {\n throw new Error(\"Upload paused\");\n }\n\n onProgress?.(10);\n\n const uploadResponse = await new Promise<Response>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n activeXhrRef.current = xhr;\n\n xhr.upload.addEventListener(\"progress\", (e) => {\n if (e.lengthComputable && !isPausedRef.current) {\n const percentComplete = 10 + Math.round((e.loaded / e.total) * 80);\n onProgress?.(percentComplete);\n }\n });\n\n xhr.addEventListener(\"load\", () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n if (!isPausedRef.current) {\n onProgress?.(90);\n }\n resolve(\n new Response(xhr.response, {\n status: xhr.status,\n statusText: xhr.statusText,\n headers: new Headers(\n xhr\n .getAllResponseHeaders()\n .split(\"\\r\\n\")\n .reduce(\n (acc, current) => {\n const parts = current.split(\": \");\n if (parts[0]) acc[parts[0]] = parts[1] || \"\";\n return acc;\n },\n {} as Record<string, string>,\n ),\n ),\n }),\n );\n } else {\n reject(new Error(`Upload failed with status ${xhr.status}`));\n }\n });\n\n xhr.addEventListener(\"error\", () => {\n if (!isPausedRef.current) {\n reject(new Error(\"Upload failed\"));\n }\n });\n\n xhr.addEventListener(\"abort\", () => {\n if (isPausedRef.current) {\n reject(new Error(\"Upload paused\"));\n } else {\n reject(new Error(\"Upload aborted\"));\n }\n });\n\n xhr.open(\"PUT\", uploadUrl);\n xhr.setRequestHeader(\"Content-Type\", file.type);\n xhr.send(file);\n });\n\n if (!uploadResponse.ok) {\n throw new Error(\"Failed to upload file to S3\");\n }\n\n if (isPausedRef.current) {\n throw new Error(\"Upload paused\");\n }\n\n const completeResult = await completeUploadMutation({\n variables: {\n input: {\n sessionId: session.id,\n fileSize: file.size.toString(),\n sha256Hash,\n folderId: folderId || null,\n },\n },\n });\n\n if (completeResult.error) {\n if (isQuotaExhaustedError(completeResult.error)) {\n throw completeResult.error;\n }\n const errorMsg = completeResult.error.message || \"\";\n throw new Error(\n completeResult.error.message || \"Failed to complete upload\",\n );\n }\n\n const uploadedFile = completeResult.data?.completeUpload?.file;\n if (!uploadedFile) {\n throw new Error(\n \"Upload completed but file data was not returned. The file may not have been created properly.\",\n );\n }\n\n onProgress?.(100);\n return uploadedFile;\n } catch (error) {\n const err = error instanceof Error ? error : new Error(\"Upload failed\");\n setUploadError(err);\n throw err;\n } finally {\n setIsUploading(false);\n activeXhrRef.current = null;\n }\n };\n\n return {\n mutateAsync,\n isPending: isUploading,\n error: uploadError,\n pause,\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ACF,EACF,CAAC;AAEF,QAAI,EAAe,MAKjB,OAJI,EAAsB,EAAe,MAAM,GACvC,EAAe,SAEN,EAAe,MAAM,SAC5B,MACR,EAAe,MAAM,WAAW,4BACjC;IAGH,IAAM,IAAe,EAAe,MAAM,gBAAgB;AAC1D,QAAI,CAAC,EACH,OAAU,MACR,gGACD;AAIH,WADA,IAAa,IAAI,EACV;YACA,GAAO;IACd,IAAM,IAAM,aAAiB,QAAQ,IAAQ,gBAAI,MAAM,gBAAgB;AAEvE,UADA,EAAe,EAAI,EACb;aACE;AAER,IADA,EAAe,GAAM,EACrB,EAAa,UAAU;;;EAMzB,WAAW;EACX,OAAO;EACP,OAvLY,QAAkB;AAC9B,GAAK,EAAY,YACf,EAAY,UAAU,IACtB,EAAa,SAAS,OAAO,EAC7B,EAAa,UAAU;KAExB,EAAE,CAAC;EAkLJ,UAhLe,QAAkB,EAAY,SAAS,EAAE,CAAC;EAiL1D"}
|
|
1
|
+
{"version":3,"file":"useUploadFile.js","names":["useUploadFile","useFilesContext","isUploading","setIsUploading","useState","uploadError","setUploadError","activeXhrRef","useRef","isPausedRef","initiateUploadMutation","useMutation","InitiateUploadDocument","completeUploadMutation","CompleteUploadDocument","query","params","extension","file","onProgress","sha256Hash","computeUploadSha256","initiateResult","folderId","isQuotaExhaustedError","errorMsg","result","session","uploadUrl","xhr","percentComplete","resolve","parts","current","acc","reject","completeResult","uploadedFile","error","err","useCallback"],"sources":["../../../src/files/hooks/useUploadFile.ts"],"sourcesContent":["import { useState, useRef, useCallback } from \"react\";\nimport { useMutation } from \"@apollo/client/react\";\nimport {\n InitiateUploadDocument,\n CompleteUploadDocument,\n} from \"../../generated/wspace-operations\";\nimport { useFilesContext } from \"../providers/FilesProvider\";\nimport { isQuotaExhaustedError } from \"../utils/quotaUtils\";\nimport { computeUploadSha256 } from \"../utils/uploadDigest\";\n\nexport interface InitiateUploadInput {\n fileName: string;\n fileSize: number;\n mimeType: string;\n folderId?: string;\n}\n\nexport interface CompleteUploadInput {\n sessionId: string;\n fileSize: string;\n}\n\nexport interface UploadController {\n pause: () => void;\n isPaused: () => boolean;\n}\n\nexport const useUploadFile = () => {\n const { workspaceId } = useFilesContext();\n const [isUploading, setIsUploading] = useState(false);\n const [uploadError, setUploadError] = useState<Error | null>(null);\n\n const activeXhrRef = useRef<XMLHttpRequest | null>(null);\n const isPausedRef = useRef(false);\n\n const [initiateUploadMutation] = useMutation(InitiateUploadDocument);\n const [completeUploadMutation] = useMutation(CompleteUploadDocument, {\n refetchQueries: [\n \"GetFilesRootBrowsePage\",\n \"GetFilesFolderBrowsePage\",\n \"GetFilesRecentPage\",\n \"GetFiles\",\n ],\n // Named refetches also include skipped (standby) Apollo observables.\n // The root browser keeps a skipped folder query with an empty folder ID.\n onQueryUpdated: (query) => query.options.fetchPolicy !== \"standby\",\n });\n\n const pause = useCallback(() => {\n if (!isPausedRef.current) {\n isPausedRef.current = true;\n activeXhrRef.current?.abort();\n activeXhrRef.current = null;\n }\n }, []);\n\n const isPaused = useCallback(() => isPausedRef.current, []);\n\n const mutateAsync = async (params: {\n file: File;\n folderId?: string;\n onProgress?: (progress: number) => void;\n }) => {\n const { file, folderId, onProgress } = params;\n const extension = file.name.split(\".\").pop() || \"\";\n\n try {\n setIsUploading(true);\n setUploadError(null);\n isPausedRef.current = false;\n\n onProgress?.(0);\n\n // Declare the same exact-byte digest before creating a session and on completion.\n // The Files owner separately records whether storage verified this declaration.\n const sha256Hash = await computeUploadSha256(\n file,\n () => isPausedRef.current,\n );\n if (isPausedRef.current) {\n throw new Error(\"Upload paused\");\n }\n\n const initiateResult = await initiateUploadMutation({\n variables: {\n input: {\n fileName: file.name,\n fileSize: file.size.toString(),\n mimeType: file.type || \"application/octet-stream\",\n extension: extension,\n sha256Hash,\n folderId: folderId || null,\n },\n },\n });\n\n // Check for GraphQL errors FIRST - before checking data\n // This ensures backend error messages are properly surfaced to the user\n if (initiateResult.error) {\n if (isQuotaExhaustedError(initiateResult.error)) {\n throw initiateResult.error;\n }\n const errorMsg = initiateResult.error.message || \"\";\n throw new Error(errorMsg || \"Failed to initiate upload\");\n }\n\n const result = initiateResult.data?.initiateUpload;\n const session = result?.session;\n const uploadUrl = result?.uploadUrl;\n\n if (!session || !uploadUrl) {\n throw new Error(\"Failed to initiate upload session\");\n }\n\n if (isPausedRef.current) {\n throw new Error(\"Upload paused\");\n }\n\n onProgress?.(10);\n\n const uploadResponse = await new Promise<Response>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n activeXhrRef.current = xhr;\n\n xhr.upload.addEventListener(\"progress\", (e) => {\n if (e.lengthComputable && !isPausedRef.current) {\n const percentComplete = 10 + Math.round((e.loaded / e.total) * 80);\n onProgress?.(percentComplete);\n }\n });\n\n xhr.addEventListener(\"load\", () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n if (!isPausedRef.current) {\n onProgress?.(90);\n }\n resolve(\n new Response(xhr.response, {\n status: xhr.status,\n statusText: xhr.statusText,\n headers: new Headers(\n xhr\n .getAllResponseHeaders()\n .split(\"\\r\\n\")\n .reduce(\n (acc, current) => {\n const parts = current.split(\": \");\n if (parts[0]) acc[parts[0]] = parts[1] || \"\";\n return acc;\n },\n {} as Record<string, string>,\n ),\n ),\n }),\n );\n } else {\n reject(new Error(`Upload failed with status ${xhr.status}`));\n }\n });\n\n xhr.addEventListener(\"error\", () => {\n if (!isPausedRef.current) {\n reject(new Error(\"Upload failed\"));\n }\n });\n\n xhr.addEventListener(\"abort\", () => {\n if (isPausedRef.current) {\n reject(new Error(\"Upload paused\"));\n } else {\n reject(new Error(\"Upload aborted\"));\n }\n });\n\n xhr.open(\"PUT\", uploadUrl);\n xhr.setRequestHeader(\"Content-Type\", file.type);\n xhr.send(file);\n });\n\n if (!uploadResponse.ok) {\n throw new Error(\"Failed to upload file to S3\");\n }\n\n if (isPausedRef.current) {\n throw new Error(\"Upload paused\");\n }\n\n const completeResult = await completeUploadMutation({\n variables: {\n input: {\n sessionId: session.id,\n fileSize: file.size.toString(),\n sha256Hash,\n folderId: folderId || null,\n },\n },\n });\n\n if (completeResult.error) {\n if (isQuotaExhaustedError(completeResult.error)) {\n throw completeResult.error;\n }\n const errorMsg = completeResult.error.message || \"\";\n throw new Error(\n completeResult.error.message || \"Failed to complete upload\",\n );\n }\n\n const uploadedFile = completeResult.data?.completeUpload?.file;\n if (!uploadedFile) {\n throw new Error(\n \"Upload completed but file data was not returned. The file may not have been created properly.\",\n );\n }\n\n onProgress?.(100);\n return uploadedFile;\n } catch (error) {\n const err = error instanceof Error ? error : new Error(\"Upload failed\");\n setUploadError(err);\n throw err;\n } finally {\n setIsUploading(false);\n activeXhrRef.current = null;\n }\n };\n\n return {\n mutateAsync,\n isPending: isUploading,\n error: uploadError,\n pause,\n isPaused,\n };\n};\n"],"mappings":";;;;;;;AA2BA,IAAaA,UAAsB;CACjC,IAAM,EAAE,mBAAgBC,EAAgB,GAClC,CAACC,GAAaC,KAAkBC,EAAS,EAAK,GAC9C,CAACC,GAAaC,KAAkBF,EAAuB,IAAI,GAE3DG,IAAeC,EAA8B,IAAI,GACjDC,IAAcD,EAAO,EAAK,GAE1B,CAACE,KAA0BC,EAAYC,CAAsB,GAC7D,CAACC,KAA0BF,EAAYG,GAAwB;EACnE,gBAAgB;GACd;GACA;GACA;GACA;EACF;EAGA,iBAAiB,MAAUC,EAAM,QAAQ,gBAAgB;CAC3D,CAAC;CAqLD,OAAO;EACL,oBA1KyB,MAIrB;GACJ,IAAM,EAAE,SAAM,aAAU,kBAAeC,GACjCC,IAAYC,EAAK,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK;GAEhD,IAAI;IAKF,AAJAf,EAAe,EAAI,GACnBG,EAAe,IAAI,GACnB,EAAY,UAAU,IAEtBa,IAAa,CAAC;IAId,IAAMC,IAAa,MAAMC,EACvBH,SACMT,EAAY,OACpB;IACA,IAAIA,EAAY,SACd,MAAU,MAAM,eAAe;IAGjC,IAAMa,IAAiB,MAAMZ,EAAuB,EAClD,WAAW,EACT,O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QAAkB/B,EAAY,SAAS,CAAC,CAgLvD;CACF;AACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SetStateAction } from 'react';
|
|
2
|
+
import { UploadItem } from '../types';
|
|
3
|
+
export interface UploadQueueState {
|
|
4
|
+
items: UploadItem[];
|
|
5
|
+
uploading: boolean;
|
|
6
|
+
open: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type UploadQueueAction = {
|
|
9
|
+
type: "items";
|
|
10
|
+
update: SetStateAction<UploadItem[]>;
|
|
11
|
+
} | {
|
|
12
|
+
type: "uploading";
|
|
13
|
+
value: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
type: "open";
|
|
16
|
+
value: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
type: "cancel";
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
/** Cancellation and its display flags use the same latest state, with no nested setters. */
|
|
22
|
+
export declare function uploadQueueReducer(state: UploadQueueState, action: UploadQueueAction): UploadQueueState;
|
|
23
|
+
export declare function useUploadQueueState(): {
|
|
24
|
+
uploadQueue: UploadItem[];
|
|
25
|
+
uploading: boolean;
|
|
26
|
+
isUploadPanelOpen: boolean;
|
|
27
|
+
setUploadQueue: (update: SetStateAction<UploadItem[]>) => void;
|
|
28
|
+
setUploading: (value: boolean) => void;
|
|
29
|
+
setIsUploadPanelOpen: (value: boolean) => void;
|
|
30
|
+
cancelUpload: (id: string) => void;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useUploadQueueState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUploadQueueState.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useUploadQueueState.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;CACf;AACD,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,CAAC,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC,4FAA4F;AAC5F,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,GACxB,gBAAgB,CAqBlB;AAED,wBAAgB,mBAAmB;;;;6BAOtB,cAAc,CAAC,UAAU,EAAE,CAAC;0BAK7B,OAAO;kCAIP,OAAO;uBAIV,MAAM;EAYd"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useCallback as e, useReducer as t } from "react";
|
|
2
|
+
//#region src/files/hooks/useUploadQueueState.ts
|
|
3
|
+
function n(e, t) {
|
|
4
|
+
switch (t.type) {
|
|
5
|
+
case "items": return {
|
|
6
|
+
...e,
|
|
7
|
+
items: typeof t.update == "function" ? t.update(e.items) : t.update
|
|
8
|
+
};
|
|
9
|
+
case "uploading": return {
|
|
10
|
+
...e,
|
|
11
|
+
uploading: t.value
|
|
12
|
+
};
|
|
13
|
+
case "open": return {
|
|
14
|
+
...e,
|
|
15
|
+
open: t.value
|
|
16
|
+
};
|
|
17
|
+
case "cancel": {
|
|
18
|
+
let n = e.items.filter((e) => e.id !== t.id);
|
|
19
|
+
return n.length ? {
|
|
20
|
+
...e,
|
|
21
|
+
items: n
|
|
22
|
+
} : {
|
|
23
|
+
items: n,
|
|
24
|
+
uploading: !1,
|
|
25
|
+
open: !1
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function r() {
|
|
31
|
+
let [r, i] = t(n, {
|
|
32
|
+
items: [],
|
|
33
|
+
uploading: !1,
|
|
34
|
+
open: !1
|
|
35
|
+
}), a = e((e) => i({
|
|
36
|
+
type: "items",
|
|
37
|
+
update: e
|
|
38
|
+
}), []), o = e((e) => i({
|
|
39
|
+
type: "uploading",
|
|
40
|
+
value: e
|
|
41
|
+
}), []), s = e((e) => i({
|
|
42
|
+
type: "open",
|
|
43
|
+
value: e
|
|
44
|
+
}), []), c = e((e) => i({
|
|
45
|
+
type: "cancel",
|
|
46
|
+
id: e
|
|
47
|
+
}), []);
|
|
48
|
+
return {
|
|
49
|
+
uploadQueue: r.items,
|
|
50
|
+
uploading: r.uploading,
|
|
51
|
+
isUploadPanelOpen: r.open,
|
|
52
|
+
setUploadQueue: a,
|
|
53
|
+
setUploading: o,
|
|
54
|
+
setIsUploadPanelOpen: s,
|
|
55
|
+
cancelUpload: c
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { n as uploadQueueReducer, r as useUploadQueueState };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=useUploadQueueState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUploadQueueState.js","names":["uploadQueueReducer","action","state","items","item","useUploadQueueState","dispatch","useReducer","setUploadQueue","useCallback","setUploading","setIsUploadPanelOpen","cancelUpload"],"sources":["../../../src/files/hooks/useUploadQueueState.ts"],"sourcesContent":["import { useCallback, useReducer, type SetStateAction } from \"react\";\nimport type { UploadItem } from \"../types\";\n\nexport interface UploadQueueState {\n items: UploadItem[];\n uploading: boolean;\n open: boolean;\n}\nexport type UploadQueueAction =\n | { type: \"items\"; update: SetStateAction<UploadItem[]> }\n | { type: \"uploading\"; value: boolean }\n | { type: \"open\"; value: boolean }\n | { type: \"cancel\"; id: string };\n\n/** Cancellation and its display flags use the same latest state, with no nested setters. */\nexport function uploadQueueReducer(\n state: UploadQueueState,\n action: UploadQueueAction,\n): UploadQueueState {\n switch (action.type) {\n case \"items\":\n return {\n ...state,\n items:\n typeof action.update === \"function\"\n ? action.update(state.items)\n : action.update,\n };\n case \"uploading\":\n return { ...state, uploading: action.value };\n case \"open\":\n return { ...state, open: action.value };\n case \"cancel\": {\n const items = state.items.filter((item) => item.id !== action.id);\n return items.length\n ? { ...state, items }\n : { items, uploading: false, open: false };\n }\n }\n}\n\nexport function useUploadQueueState() {\n const [state, dispatch] = useReducer(uploadQueueReducer, {\n items: [],\n uploading: false,\n open: false,\n });\n const setUploadQueue = useCallback(\n (update: SetStateAction<UploadItem[]>) =>\n dispatch({ type: \"items\", update }),\n [],\n );\n const setUploading = useCallback(\n (value: boolean) => dispatch({ type: \"uploading\", value }),\n [],\n );\n const setIsUploadPanelOpen = useCallback(\n (value: boolean) => dispatch({ type: \"open\", value }),\n [],\n );\n const cancelUpload = useCallback(\n (id: string) => dispatch({ type: \"cancel\", id }),\n [],\n );\n return {\n uploadQueue: state.items,\n uploading: state.uploading,\n isUploadPanelOpen: state.open,\n setUploadQueue,\n setUploading,\n setIsUploadPanelOpen,\n cancelUpload,\n };\n}\n"],"mappings":";;AAeA,SAAgBA,EACd,GACA,GACkB;CAClB,QAAQC,EAAO,MAAf;EACE,KAAK,SACH,OAAO;GACL,GAAGC;GACH,OACE,OAAOD,EAAO,UAAW,aACrBA,EAAO,OAAOC,EAAM,KAAK,IACzBD,EAAO;EACf;EACF,KAAK,aACH,OAAO;GAAE,GAAGC;GAAO,WAAWD,EAAO;EAAM;EAC7C,KAAK,QACH,OAAO;GAAE,GAAGC;GAAO,MAAMD,EAAO;EAAM;EACxC,KAAK,UAAU;GACb,IAAME,IAAQD,EAAM,MAAM,QAAQ,MAASE,EAAK,OAAOH,EAAO,EAAE;GAChE,OAAOE,EAAM,SACT;IAAE,GAAGD;IAAO;GAAM,IAClB;IAAE;IAAO,WAAW;IAAO,MAAM;GAAM;EAC7C;CACF;AACF;AAEA,SAAgBG,IAAsB;CACpC,IAAM,CAACH,GAAOI,KAAYC,EAAWP,GAAoB;EACvD,OAAO,CAAC;EACR,WAAW;EACX,MAAM;CACR,CAAC,GACKQ,IAAiBC,GACpB,MACCH,EAAS;EAAE,MAAM;EAAS;CAAO,CAAC,GACpC,CAAC,CACH,GACMI,IAAeD,GAClB,MAAmBH,EAAS;EAAE,MAAM;EAAa;CAAM,CAAC,GACzD,CAAC,CACH,GACMK,IAAuBF,GAC1B,MAAmBH,EAAS;EAAE,MAAM;EAAQ;CAAM,CAAC,GACpD,CAAC,CACH,GACMM,IAAeH,GAClB,MAAeH,EAAS;EAAE,MAAM;EAAU;CAAG,CAAC,GAC/C,CAAC,CACH;CACA,OAAO;EACL,aAAaJ,EAAM;EACnB,WAAWA,EAAM;EACjB,mBAAmBA,EAAM;EACzB;EACA;EACA;EACA;CACF;AACF"}
|
package/dist/files/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import "./providers/FilesProvider.js";
|
|
2
|
-
import "./store/filesStore.js";
|
|
3
|
-
import "./FilesRoot.js";
|
|
1
|
+
import { useFilesContext as e } from "./providers/FilesProvider.js";
|
|
2
|
+
import { useFilesStore as t } from "./store/filesStore.js";
|
|
3
|
+
import { FilesRoot as n } from "./FilesRoot.js";
|
|
4
|
+
export { n as FilesRoot, e as useFilesContext, t as useFilesStore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserPage.d.ts","sourceRoot":"","sources":["../../../src/files/pages/BrowserPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BrowserPage.d.ts","sourceRoot":"","sources":["../../../src/files/pages/BrowserPage.tsx"],"names":[],"mappings":"AAwGA;;GAEG;AACH,wBAAgB,WAAW,gCAsqE1B"}
|