@widgetic/file-browser 0.5.24 → 0.5.26
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 +279 -0
- package/dist/components/FolderTree.svelte +16 -9
- package/dist/components/FolderTree.svelte.d.ts +2 -6
- package/dist/components/core/FileBrowser.svelte +529 -127
- package/dist/components/core/FileBrowser.svelte.d.ts +40 -1
- package/dist/components/core/FileUploader.svelte +130 -57
- package/dist/components/core/Header.svelte +13 -2
- package/dist/components/core/Header.svelte.d.ts +1 -0
- package/dist/components/core/RecentFiles.svelte +41 -29
- package/dist/components/core/UploadStatus.svelte +14 -7
- package/dist/components/core/UploadStatusList.svelte +13 -21
- package/dist/components/items/FileItem.svelte +28 -15
- package/dist/components/items/FolderItem.svelte +13 -6
- package/dist/components/modals/MoveDialog.svelte +49 -38
- package/dist/components/modals/NewFolderButton.svelte +5 -2
- package/dist/components/modals/SearchModal.svelte +25 -26
- package/dist/components/modals/SearchModal.svelte.d.ts +1 -1
- package/dist/components/modals/SelectedFilesModal.svelte +23 -14
- package/dist/components/modals/SelectedFilesModal.svelte.d.ts +1 -1
- package/dist/components/previews/AudioPlayer.svelte +5 -2
- package/dist/components/previews/ErrorPreview.svelte +7 -4
- package/dist/components/previews/ErrorPreview.svelte.d.ts +1 -1
- package/dist/components/previews/FilePreview.svelte +25 -9
- package/dist/components/previews/FontPreview.svelte +18 -9
- package/dist/components/previews/FontPreview.svelte.d.ts +1 -1
- package/dist/components/previews/TextPreview.svelte +12 -5
- package/dist/components/previews/VideoPlayer.svelte +11 -7
- package/dist/components/ui/ControlToolbar.svelte +50 -28
- package/dist/components/ui/ControlToolbar.svelte.d.ts +1 -1
- package/dist/components/ui/DragSelect.svelte +3 -2
- package/dist/components/ui/DropdownMenu.svelte +35 -14
- package/dist/components/ui/FileIcon.svelte +8 -5
- package/dist/components/ui/FileIcon.svelte.d.ts +1 -0
- package/dist/components/ui/FileMetadata.svelte +16 -15
- package/dist/components/ui/SearchResults.svelte +9 -2
- package/dist/i18n/context.d.ts +28 -0
- package/dist/i18n/context.js +17 -0
- package/dist/i18n/errors.d.ts +11 -0
- package/dist/i18n/errors.js +19 -0
- package/dist/i18n/index.d.ts +15 -0
- package/dist/i18n/index.js +18 -0
- package/dist/i18n/messages.d.ts +281 -0
- package/dist/i18n/messages.js +294 -0
- package/dist/i18n/text.d.ts +19 -0
- package/dist/i18n/text.js +35 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/mediaLibrary/capabilities.d.ts +22 -0
- package/dist/mediaLibrary/capabilities.js +42 -0
- package/dist/mediaLibrary/context.d.ts +17 -0
- package/dist/mediaLibrary/context.js +16 -0
- package/dist/mediaLibrary/errors.d.ts +42 -0
- package/dist/mediaLibrary/errors.js +114 -0
- package/dist/mediaLibrary/index.d.ts +10 -0
- package/dist/mediaLibrary/index.js +9 -0
- package/dist/mediaLibrary/normalize.d.ts +39 -0
- package/dist/mediaLibrary/normalize.js +139 -0
- package/dist/mediaLibrary/paging.d.ts +37 -0
- package/dist/mediaLibrary/paging.js +62 -0
- package/dist/mediaLibrary/resolve.d.ts +39 -0
- package/dist/mediaLibrary/resolve.js +137 -0
- package/dist/mediaLibrary/treeOps.d.ts +24 -0
- package/dist/mediaLibrary/treeOps.js +67 -0
- package/dist/mediaLibrary/types.d.ts +126 -0
- package/dist/mediaLibrary/types.js +11 -0
- package/dist/mediaLibrary/urls.d.ts +30 -0
- package/dist/mediaLibrary/urls.js +59 -0
- package/dist/mediaLibrary/widgetic.d.ts +39 -0
- package/dist/mediaLibrary/widgetic.js +89 -0
- package/dist/stores/fileStore.d.ts +2 -2
- package/dist/stores/folderCountStore.js +2 -2
- package/dist/stores/navigationStore.d.ts +1 -1
- package/dist/stores/persistentSelectStore.d.ts +11 -1
- package/dist/stores/persistentSelectStore.js +26 -0
- package/dist/utils/dateUtils.d.ts +11 -2
- package/dist/utils/dateUtils.js +20 -15
- package/dist/utils/fileKinds.d.ts +44 -0
- package/dist/utils/fileKinds.js +96 -0
- package/dist/utils/fileNames.d.ts +7 -0
- package/dist/utils/fileNames.js +19 -0
- package/dist/utils/fileOperations.js +2 -11
- package/dist/utils/fileTypes.d.ts +11 -2
- package/dist/utils/fileTypes.js +26 -14
- package/dist/utils/fileUtils.d.ts +8 -1
- package/dist/utils/fileUtils.js +22 -7
- package/dist/utils/folderUtils.js +3 -2
- package/dist/utils/previewKeys.d.ts +12 -0
- package/dist/utils/previewKeys.js +14 -0
- package/dist/utils/safeText.d.ts +29 -0
- package/dist/utils/safeText.js +66 -0
- package/dist/utils/userUploadsStorage.d.ts +4 -1
- package/dist/utils/userUploadsStorage.js +5 -2
- package/dist/utils/widgeticTusUpload.d.ts +10 -0
- package/dist/utils/widgeticTusUpload.js +61 -3
- package/dist/utils/widgeticUpload.d.ts +3 -0
- package/dist/utils/widgeticUpload.js +7 -2
- package/package.json +5 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MediaLibraryError, codeForHttpStatus } from '../mediaLibrary/errors';
|
|
1
2
|
import { shouldUseTusUpload, uploadToWidgeticApiTus, } from './widgeticTusUpload';
|
|
2
3
|
/**
|
|
3
4
|
* Upload a file to Widgetic API Gateway.
|
|
@@ -26,6 +27,8 @@ export async function uploadToWidgeticApi(file, config, options = {}) {
|
|
|
26
27
|
Authorization: `Bearer ${token}`,
|
|
27
28
|
},
|
|
28
29
|
body: formData,
|
|
30
|
+
// Lets the visitor's Cancel stop the request instead of only hiding it.
|
|
31
|
+
signal: options.abortSignal,
|
|
29
32
|
});
|
|
30
33
|
if (!response.ok) {
|
|
31
34
|
let detail = `Upload failed (${response.status})`;
|
|
@@ -36,7 +39,7 @@ export async function uploadToWidgeticApi(file, config, options = {}) {
|
|
|
36
39
|
catch {
|
|
37
40
|
/* ignore */
|
|
38
41
|
}
|
|
39
|
-
return { success: false, error: detail };
|
|
42
|
+
return { success: false, error: detail, status: response.status };
|
|
40
43
|
}
|
|
41
44
|
const json = await response.json();
|
|
42
45
|
const data = json?.data ?? json;
|
|
@@ -96,6 +99,7 @@ export async function fetchUserUploadsFromApi(config, options = {}) {
|
|
|
96
99
|
params.set('limit', String(options.limit ?? 100));
|
|
97
100
|
const response = await fetch(`${basePath}/uploads?${params.toString()}`, {
|
|
98
101
|
headers: { Authorization: `Bearer ${token}` },
|
|
102
|
+
signal: options.signal,
|
|
99
103
|
});
|
|
100
104
|
if (!response.ok) {
|
|
101
105
|
let detail = `List uploads failed (${response.status})`;
|
|
@@ -106,7 +110,8 @@ export async function fetchUserUploadsFromApi(config, options = {}) {
|
|
|
106
110
|
catch {
|
|
107
111
|
/* ignore */
|
|
108
112
|
}
|
|
109
|
-
|
|
113
|
+
// A MediaLibraryError is an Error too; it also says whether the token was refused (401).
|
|
114
|
+
throw new MediaLibraryError(codeForHttpStatus(response.status), detail, { status: response.status });
|
|
110
115
|
}
|
|
111
116
|
const json = await response.json();
|
|
112
117
|
const rows = (json?.data ?? []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/file-browser",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
82
82
|
"check:deps": "check-runtime-deps",
|
|
83
83
|
"check:peers": "check-design-system-peers ..",
|
|
84
|
+
"test": "vitest run",
|
|
84
85
|
"test:deps": "check-runtime-deps-fixtures",
|
|
85
86
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
86
87
|
"lint": "prettier --check . && eslint .",
|
|
@@ -109,7 +110,8 @@
|
|
|
109
110
|
"tailwindcss": "^4.3.0",
|
|
110
111
|
"typescript": "^5.0.0",
|
|
111
112
|
"typescript-eslint": "^8.0.0",
|
|
112
|
-
"vite": "^6.4.3"
|
|
113
|
+
"vite": "^6.4.3",
|
|
114
|
+
"vitest": "^5.0.3"
|
|
113
115
|
},
|
|
114
116
|
"peerDependencies": {
|
|
115
117
|
"@sveltejs/kit": "^2.20.7",
|
|
@@ -129,6 +131,7 @@
|
|
|
129
131
|
"tus-js-client": "^4.2.3"
|
|
130
132
|
},
|
|
131
133
|
"overrides": {
|
|
134
|
+
"shell-quote": "^1.12.0",
|
|
132
135
|
"bits-ui": {
|
|
133
136
|
"@melt-ui/svelte": "^0.86.3"
|
|
134
137
|
},
|