@widgetic/file-browser 0.5.48 → 0.5.49
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/dist/actions/dragSelectedToFolder.js +115 -104
- package/dist/components/FolderTree.svelte.d.ts +7 -4
- package/dist/components/core/FileBrowser.svelte +1 -3
- package/dist/components/core/dropzoneClick.js +2 -3
- package/dist/components/previews/FilePreview.svelte.d.ts +2 -2
- package/dist/config.js +3 -4
- package/dist/i18n/context.js +2 -2
- package/dist/i18n/errors.js +1 -2
- package/dist/i18n/messages.js +2 -2
- package/dist/i18n/text.js +2 -2
- package/dist/mediaLibrary/capabilities.js +3 -4
- package/dist/mediaLibrary/context.js +3 -4
- package/dist/mediaLibrary/errors.js +35 -46
- package/dist/mediaLibrary/normalize.js +42 -45
- package/dist/mediaLibrary/paging.js +45 -100
- package/dist/mediaLibrary/resolve.js +95 -214
- package/dist/mediaLibrary/treeOps.js +20 -40
- package/dist/mediaLibrary/urls.js +10 -12
- package/dist/mediaLibrary/widgetic.js +54 -140
- package/dist/stores/dragStore.js +1 -1
- package/dist/stores/fileStore.d.ts +3 -3
- package/dist/stores/fileStore.js +37 -44
- package/dist/stores/folderCountStore.js +11 -12
- package/dist/stores/missingFilesStore.js +3 -3
- package/dist/stores/navigationStore.d.ts +1 -1
- package/dist/stores/navigationStore.js +178 -217
- package/dist/stores/persistentSelectStore.d.ts +1 -1
- package/dist/stores/persistentSelectStore.js +94 -117
- package/dist/stores/searchStore.js +1 -1
- package/dist/stores/uploadApiStore.js +7 -7
- package/dist/stores/viewportStore.js +4 -4
- package/dist/types/index.js +1 -0
- package/dist/utils/apiConfig.js +9 -9
- package/dist/utils/brandKitLibraryTree.js +42 -57
- package/dist/utils/dateUtils.js +9 -11
- package/dist/utils/dragToFolder/batchMoveResult.js +54 -114
- package/dist/utils/dragToFolder/folderDropTarget.js +17 -23
- package/dist/utils/dragToFolder/springStep.js +3 -4
- package/dist/utils/fileGoneProbe.js +16 -65
- package/dist/utils/fileKinds.js +13 -14
- package/dist/utils/fileNames.js +7 -7
- package/dist/utils/fileOperations.js +332 -440
- package/dist/utils/fileTypes.js +14 -19
- package/dist/utils/fileUtils.js +31 -85
- package/dist/utils/folderUtils.js +4 -5
- package/dist/utils/gridLayout.js +7 -7
- package/dist/utils/imagePreviewCache.js +15 -26
- package/dist/utils/imagePreviewFrame.js +13 -13
- package/dist/utils/imagePreviewVisualState.js +4 -5
- package/dist/utils/imageTransform.js +14 -27
- package/dist/utils/itemMenuCapabilities.js +7 -7
- package/dist/utils/libraryTree.js +39 -55
- package/dist/utils/pendingUploadDeletes.js +113 -289
- package/dist/utils/previewKeys.js +1 -1
- package/dist/utils/previewListNavigation.js +11 -13
- package/dist/utils/previewNavigation.js +7 -10
- package/dist/utils/recentFiles.js +6 -16
- package/dist/utils/recentFilesLimit.js +2 -2
- package/dist/utils/removeItems.js +29 -61
- package/dist/utils/resolveFileUrl.js +6 -6
- package/dist/utils/safeText.js +12 -14
- package/dist/utils/searchDropdownPhase.js +2 -2
- package/dist/utils/searchItems.js +14 -30
- package/dist/utils/searchNavigation.js +5 -5
- package/dist/utils/uploadAuth.js +36 -111
- package/dist/utils/uploadDisplayProgress.js +1 -1
- package/dist/utils/uploadLimits.js +66 -138
- package/dist/utils/uploadListReconcile.js +11 -24
- package/dist/utils/uploadPanelDismiss.js +1 -1
- package/dist/utils/uploadPanelProgress.js +4 -4
- package/dist/utils/uploadProgressMath.js +11 -13
- package/dist/utils/uploadRefusals.js +24 -40
- package/dist/utils/uploadResponseMapping.js +8 -9
- package/dist/utils/uploadUiHelpers.js +17 -17
- package/dist/utils/userUploadsStorage.js +133 -270
- package/dist/utils/videoFrame.js +2 -2
- package/dist/utils/widgeticDelete.js +30 -103
- package/dist/utils/widgeticTusUpload.js +105 -189
- package/dist/utils/widgeticUpload.js +62 -130
- package/dist/utils/xhrMultipartUpload.js +116 -164
- package/package.json +1 -1
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure helpers for the Widgetic library-mode tree: persistence covers the whole root and API hydration merges by id.
|
|
3
3
|
*/
|
|
4
|
-
var __assign = (this && this.__assign) || function () {
|
|
5
|
-
__assign = Object.assign || function(t) {
|
|
6
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7
|
-
s = arguments[i];
|
|
8
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
-
t[p] = s[p];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
return __assign.apply(this, arguments);
|
|
14
|
-
};
|
|
15
4
|
import { placeBrandKitFileInTree } from './brandKitLibraryTree.js';
|
|
16
|
-
export
|
|
5
|
+
export const BUILTIN_UPLOADS_ID = 'folder_my_uploads';
|
|
17
6
|
function sortFolderContentsLikeGrid(items, sort) {
|
|
18
|
-
items.sort(
|
|
7
|
+
items.sort((a, b) => {
|
|
19
8
|
if (a.type === 'folder' && b.type !== 'folder')
|
|
20
9
|
return -1;
|
|
21
10
|
if (a.type !== 'folder' && b.type === 'folder')
|
|
22
11
|
return 1;
|
|
23
|
-
|
|
12
|
+
let comparison = 0;
|
|
24
13
|
switch (sort.criteria) {
|
|
25
14
|
case 'name':
|
|
26
15
|
comparison = a.name.localeCompare(b.name);
|
|
@@ -54,10 +43,12 @@ function ensureDate(value) {
|
|
|
54
43
|
}
|
|
55
44
|
/** Deep clone with Date revival for `modified` fields (JSON persistence). */
|
|
56
45
|
export function reviveFileSystemDates(items) {
|
|
57
|
-
return items.map(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
return items.map((item) => {
|
|
47
|
+
const revived = {
|
|
48
|
+
...item,
|
|
49
|
+
modified: item.modified !== undefined ? new Date(item.modified) : undefined
|
|
50
|
+
};
|
|
51
|
+
if (item.children?.length) {
|
|
61
52
|
revived.children = reviveFileSystemDates(item.children);
|
|
62
53
|
}
|
|
63
54
|
return revived;
|
|
@@ -68,9 +59,8 @@ export function findItemByIdInTree(root, id) {
|
|
|
68
59
|
return root;
|
|
69
60
|
if (!root.children)
|
|
70
61
|
return null;
|
|
71
|
-
for (
|
|
72
|
-
|
|
73
|
-
var found = findItemByIdInTree(child, id);
|
|
62
|
+
for (const child of root.children) {
|
|
63
|
+
const found = findItemByIdInTree(child, id);
|
|
74
64
|
if (found)
|
|
75
65
|
return found;
|
|
76
66
|
}
|
|
@@ -81,17 +71,15 @@ export function findItemByIdInTree(root, id) {
|
|
|
81
71
|
* Why: legacy data could list the same file id twice.
|
|
82
72
|
*/
|
|
83
73
|
export function dedupeTreeIds(items) {
|
|
84
|
-
|
|
74
|
+
const seen = new Set();
|
|
85
75
|
function walk(list) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
|
|
89
|
-
var item = list_1[_i];
|
|
76
|
+
const out = [];
|
|
77
|
+
for (const item of list) {
|
|
90
78
|
if (seen.has(item.id))
|
|
91
79
|
continue;
|
|
92
80
|
seen.add(item.id);
|
|
93
|
-
|
|
94
|
-
if (
|
|
81
|
+
const next = { ...item };
|
|
82
|
+
if (item.children?.length) {
|
|
95
83
|
next.children = walk(item.children);
|
|
96
84
|
}
|
|
97
85
|
out.push(next);
|
|
@@ -106,39 +94,41 @@ export function dedupeTreeIds(items) {
|
|
|
106
94
|
* their saved tree (it is never recreated after delete).
|
|
107
95
|
*/
|
|
108
96
|
export function mergeApiFilesIntoSavedTree(rootChildren, apiFiles, _myUploadsName) {
|
|
109
|
-
|
|
97
|
+
let children = dedupeTreeIds(reviveFileSystemDates(rootChildren ?? []));
|
|
110
98
|
function replaceFileById(items, id, file) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var it = items[i];
|
|
99
|
+
for (let i = 0; i < items.length; i++) {
|
|
100
|
+
const it = items[i];
|
|
114
101
|
if (it.type === 'file' && it.id === id) {
|
|
115
102
|
// Brand-kit uploads keep the server file name; other files keep a visitor rename.
|
|
116
|
-
|
|
117
|
-
items[i] =
|
|
103
|
+
const name = file.libraryFolderPath ? file.name : it.name;
|
|
104
|
+
items[i] = { ...file, name, modified: ensureDate(file.modified) };
|
|
118
105
|
return true;
|
|
119
106
|
}
|
|
120
|
-
if (it.type === 'folder' &&
|
|
107
|
+
if (it.type === 'folder' && it.children?.length) {
|
|
121
108
|
if (replaceFileById(it.children, id, file))
|
|
122
109
|
return true;
|
|
123
110
|
}
|
|
124
111
|
}
|
|
125
112
|
return false;
|
|
126
113
|
}
|
|
127
|
-
|
|
114
|
+
const rootFolder = {
|
|
128
115
|
id: 'root',
|
|
129
116
|
name: 'Root',
|
|
130
117
|
type: 'folder',
|
|
131
|
-
children
|
|
118
|
+
children
|
|
132
119
|
};
|
|
133
|
-
|
|
120
|
+
for (const file of apiFiles) {
|
|
134
121
|
if (file.type !== 'file')
|
|
135
|
-
|
|
136
|
-
|
|
122
|
+
continue;
|
|
123
|
+
const normalized = {
|
|
124
|
+
...file,
|
|
125
|
+
modified: ensureDate(file.modified)
|
|
126
|
+
};
|
|
137
127
|
if (findItemByIdInTree(rootFolder, file.id)) {
|
|
138
128
|
replaceFileById(rootFolder.children, file.id, normalized);
|
|
139
129
|
}
|
|
140
130
|
else if (file.libraryFolderPath) {
|
|
141
|
-
|
|
131
|
+
const placed = placeBrandKitFileInTree(rootFolder.children, {
|
|
142
132
|
uploadId: file.id,
|
|
143
133
|
displayName: file.name,
|
|
144
134
|
folderPath: file.libraryFolderPath.split('/').filter(Boolean),
|
|
@@ -146,17 +136,13 @@ export function mergeApiFilesIntoSavedTree(rootChildren, apiFiles, _myUploadsNam
|
|
|
146
136
|
});
|
|
147
137
|
rootFolder.children = placed;
|
|
148
138
|
}
|
|
149
|
-
else if (!rootFolder.children.some(
|
|
139
|
+
else if (!rootFolder.children.some((c) => c.type === 'file' && c.id === file.id)) {
|
|
150
140
|
rootFolder.children.push(normalized);
|
|
151
141
|
sortFolderContentsLikeGrid(rootFolder.children, {
|
|
152
142
|
criteria: 'name',
|
|
153
143
|
direction: 'asc'
|
|
154
144
|
});
|
|
155
145
|
}
|
|
156
|
-
};
|
|
157
|
-
for (var _i = 0, apiFiles_1 = apiFiles; _i < apiFiles_1.length; _i++) {
|
|
158
|
-
var file = apiFiles_1[_i];
|
|
159
|
-
_loop_1(file);
|
|
160
146
|
}
|
|
161
147
|
return dedupeTreeIds(rootFolder.children);
|
|
162
148
|
}
|
|
@@ -164,7 +150,7 @@ export function mergeApiFilesIntoSavedTree(rootChildren, apiFiles, _myUploadsNam
|
|
|
164
150
|
export function isLegacyUploadsOnlyChildren(children) {
|
|
165
151
|
if (!children.length)
|
|
166
152
|
return false;
|
|
167
|
-
return children.every(
|
|
153
|
+
return children.every((c) => c.type === 'file');
|
|
168
154
|
}
|
|
169
155
|
/**
|
|
170
156
|
* One-step legacy migration: old persist stored only upload files under key `current` with no folder wrapper.
|
|
@@ -177,18 +163,16 @@ export function migrateLegacyUploadsOnlyChildren(legacyChildren, _myUploadsName)
|
|
|
177
163
|
* Unwraps the legacy built-in `folder_my_uploads` (and any nested uploads shells) so children live at the root.
|
|
178
164
|
*/
|
|
179
165
|
export function flattenLegacyBuiltinUploads(children) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
for (var _i = 0, _c = dedupeTreeIds(reviveFileSystemDates(children)); _i < _c.length; _i++) {
|
|
183
|
-
var child = _c[_i];
|
|
166
|
+
const out = [];
|
|
167
|
+
for (const child of dedupeTreeIds(reviveFileSystemDates(children))) {
|
|
184
168
|
if (child.type === 'folder' && child.id === BUILTIN_UPLOADS_ID) {
|
|
185
|
-
if (
|
|
186
|
-
out.push
|
|
169
|
+
if (child.children?.length) {
|
|
170
|
+
out.push(...flattenLegacyBuiltinUploads(child.children));
|
|
187
171
|
}
|
|
188
172
|
continue;
|
|
189
173
|
}
|
|
190
|
-
if (child.type === 'folder' &&
|
|
191
|
-
out.push(
|
|
174
|
+
if (child.type === 'folder' && child.children?.length) {
|
|
175
|
+
out.push({ ...child, children: flattenLegacyBuiltinUploads(child.children) });
|
|
192
176
|
}
|
|
193
177
|
else {
|
|
194
178
|
out.push(child);
|