@widgetic/file-browser 0.5.41 → 0.5.43
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.d.ts +41 -0
- package/dist/actions/dragSelectedToFolder.js +320 -0
- package/dist/components/core/FileBrowser.svelte +239 -36
- package/dist/components/core/Header.svelte +4 -0
- package/dist/components/core/Header.svelte.d.ts +2 -0
- package/dist/components/drag/DragGhostStack.svelte +69 -0
- package/dist/components/drag/DragGhostStack.svelte.d.ts +21 -0
- package/dist/components/items/FolderItem.svelte +5 -2
- package/dist/components/previews/FilePreview.svelte +87 -26
- package/dist/components/previews/FilePreview.svelte.d.ts +6 -3
- package/dist/components/previews/FontPreview.svelte +4 -1
- package/dist/components/previews/FontPreview.svelte.d.ts +2 -0
- package/dist/components/ui/DragSelect.svelte +8 -0
- package/dist/components/ui/DropdownMenu.svelte +9 -8
- package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/utils/dragToFolder/batchMoveResult.d.ts +18 -0
- package/dist/utils/dragToFolder/batchMoveResult.js +87 -0
- package/dist/utils/dragToFolder/folderDropTarget.d.ts +15 -0
- package/dist/utils/dragToFolder/folderDropTarget.js +71 -0
- package/dist/utils/dragToFolder/springStep.d.ts +16 -0
- package/dist/utils/dragToFolder/springStep.js +21 -0
- package/dist/utils/fileOperations.d.ts +5 -0
- package/dist/utils/fileOperations.js +72 -0
- package/dist/utils/imagePreviewFrame.d.ts +22 -0
- package/dist/utils/imagePreviewFrame.js +29 -0
- package/dist/utils/itemMenuCapabilities.d.ts +19 -0
- package/dist/utils/itemMenuCapabilities.js +13 -0
- package/dist/utils/libraryTree.d.ts +5 -2
- package/dist/utils/libraryTree.js +15 -35
- package/dist/utils/uploadListReconcile.d.ts +11 -0
- package/dist/utils/uploadListReconcile.js +30 -0
- package/dist/utils/userUploadsStorage.d.ts +8 -0
- package/dist/utils/userUploadsStorage.js +36 -2
- package/package.json +3 -3
|
@@ -338,6 +338,78 @@ export function moveItem(itemId, targetFolderId) {
|
|
|
338
338
|
}
|
|
339
339
|
return success;
|
|
340
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* Moves multiple items in one `fileStore` update (folders and files).
|
|
343
|
+
* @returns ids that were moved in the tree
|
|
344
|
+
*/
|
|
345
|
+
export function moveItems(itemIds, targetFolderId) {
|
|
346
|
+
if (itemIds.length === 0)
|
|
347
|
+
return [];
|
|
348
|
+
const updatedTime = new Date().toISOString();
|
|
349
|
+
const idSet = new Set(itemIds);
|
|
350
|
+
const collected = [];
|
|
351
|
+
const movedIds = [];
|
|
352
|
+
fileStore.update((store) => {
|
|
353
|
+
const removeCollected = (items) => {
|
|
354
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
355
|
+
const entry = items[i];
|
|
356
|
+
if (idSet.has(entry.id)) {
|
|
357
|
+
collected.push({ ...entry, modified: updatedTime });
|
|
358
|
+
movedIds.push(entry.id);
|
|
359
|
+
items.splice(i, 1);
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (entry.type === 'folder' && entry.children) {
|
|
363
|
+
removeCollected(entry.children);
|
|
364
|
+
entry.modified = updatedTime;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
const rootChildren = store.root.children ?? [];
|
|
369
|
+
removeCollected(rootChildren);
|
|
370
|
+
store.root.children = rootChildren;
|
|
371
|
+
if (collected.length === 0)
|
|
372
|
+
return store;
|
|
373
|
+
const isTargetRoot = targetFolderId === '' ||
|
|
374
|
+
targetFolderId === 'root' ||
|
|
375
|
+
Boolean(store.root && targetFolderId === store.root.id);
|
|
376
|
+
if (isTargetRoot) {
|
|
377
|
+
store.root.children.push(...collected);
|
|
378
|
+
store.root.modified = updatedTime;
|
|
379
|
+
sortFolderContents(store.root.children);
|
|
380
|
+
return store;
|
|
381
|
+
}
|
|
382
|
+
const addToTarget = (items) => {
|
|
383
|
+
for (let i = 0; i < items.length; i++) {
|
|
384
|
+
if (items[i].id === targetFolderId && items[i].type === 'folder') {
|
|
385
|
+
const targetFolder = items[i];
|
|
386
|
+
targetFolder.children = targetFolder.children ?? [];
|
|
387
|
+
targetFolder.children.push(...collected);
|
|
388
|
+
targetFolder.modified = updatedTime;
|
|
389
|
+
sortFolderContents(targetFolder.children);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
if (items[i].type === 'folder') {
|
|
393
|
+
const children = items[i].children ?? [];
|
|
394
|
+
if (addToTarget(children))
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return false;
|
|
399
|
+
};
|
|
400
|
+
addToTarget(rootChildren);
|
|
401
|
+
return store;
|
|
402
|
+
});
|
|
403
|
+
if (movedIds.length > 0) {
|
|
404
|
+
const store = get(fileStore);
|
|
405
|
+
const currentFilter = get(fileFilter);
|
|
406
|
+
const filterValue = typeof currentFilter === 'string' && ['all', 'image', 'video', 'document'].includes(currentFilter)
|
|
407
|
+
? currentFilter
|
|
408
|
+
: 'all';
|
|
409
|
+
updateFolderCounts(store.root, filterValue);
|
|
410
|
+
}
|
|
411
|
+
return movedIds;
|
|
412
|
+
}
|
|
341
413
|
/**
|
|
342
414
|
* Mock API function for delete
|
|
343
415
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Layout constants shared with FilePreview (header, padding, min card width). */
|
|
2
|
+
export type ImagePreviewFrameInsets = {
|
|
3
|
+
hostWidth: number;
|
|
4
|
+
hostHeight: number;
|
|
5
|
+
sideMargin?: number;
|
|
6
|
+
dialogHorizontalPad?: number;
|
|
7
|
+
headerBlock?: number;
|
|
8
|
+
verticalPad?: number;
|
|
9
|
+
contentVerticalGutter?: number;
|
|
10
|
+
minDialogWidth?: number;
|
|
11
|
+
maxHostFraction?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Sizes an image preview card to fit the host frame while keeping chrome visible.
|
|
15
|
+
* Pictures are not upscaled beyond their natural size.
|
|
16
|
+
*/
|
|
17
|
+
export declare function computeImagePreviewModalFrame(naturalWidth: number, naturalHeight: number, insets: ImagePreviewFrameInsets): {
|
|
18
|
+
width: string;
|
|
19
|
+
height: string;
|
|
20
|
+
pictureWidth: number;
|
|
21
|
+
pictureHeight: number;
|
|
22
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const DEFAULTS = {
|
|
2
|
+
sideMargin: 24,
|
|
3
|
+
dialogHorizontalPad: 50,
|
|
4
|
+
headerBlock: 52,
|
|
5
|
+
verticalPad: 50,
|
|
6
|
+
contentVerticalGutter: 48,
|
|
7
|
+
minDialogWidth: 320,
|
|
8
|
+
maxHostFraction: 0.92
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Sizes an image preview card to fit the host frame while keeping chrome visible.
|
|
12
|
+
* Pictures are not upscaled beyond their natural size.
|
|
13
|
+
*/
|
|
14
|
+
export function computeImagePreviewModalFrame(naturalWidth, naturalHeight, insets) {
|
|
15
|
+
const { hostWidth, hostHeight, sideMargin = DEFAULTS.sideMargin, dialogHorizontalPad = DEFAULTS.dialogHorizontalPad, headerBlock = DEFAULTS.headerBlock, verticalPad = DEFAULTS.verticalPad, contentVerticalGutter = DEFAULTS.contentVerticalGutter, minDialogWidth = DEFAULTS.minDialogWidth, maxHostFraction = DEFAULTS.maxHostFraction } = insets;
|
|
16
|
+
const totalVerticalSpace = verticalPad + headerBlock;
|
|
17
|
+
const maxPictureWidth = Math.max(100, hostWidth * maxHostFraction - 2 * sideMargin - dialogHorizontalPad);
|
|
18
|
+
const maxPictureHeight = Math.max(100, hostHeight * maxHostFraction - totalVerticalSpace - contentVerticalGutter);
|
|
19
|
+
const scale = Math.min(1, maxPictureWidth / naturalWidth, maxPictureHeight / naturalHeight);
|
|
20
|
+
const pictureWidth = Math.max(68, Math.round(naturalWidth * scale));
|
|
21
|
+
const pictureHeight = Math.max(68, Math.round(naturalHeight * scale));
|
|
22
|
+
const cardWidth = Math.min(Math.max(minDialogWidth, pictureWidth + dialogHorizontalPad), Math.max(pictureWidth + dialogHorizontalPad, hostWidth * maxHostFraction - 2 * sideMargin));
|
|
23
|
+
return {
|
|
24
|
+
width: `${cardWidth}px`,
|
|
25
|
+
height: `${pictureHeight + totalVerticalSpace}px`,
|
|
26
|
+
pictureWidth,
|
|
27
|
+
pictureHeight
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MediaLibraryCapabilities } from '../mediaLibrary/types';
|
|
2
|
+
export type ItemMenuCapabilitiesInput = {
|
|
3
|
+
readonly capabilities: MediaLibraryCapabilities;
|
|
4
|
+
readonly isFolder: boolean;
|
|
5
|
+
readonly isMissing: boolean;
|
|
6
|
+
readonly fileUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ItemMenuCapabilities = {
|
|
9
|
+
readonly canRename: boolean;
|
|
10
|
+
readonly canMove: boolean;
|
|
11
|
+
readonly canDownload: boolean;
|
|
12
|
+
readonly canDelete: boolean;
|
|
13
|
+
readonly hasAnyAction: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Which row actions the item "…" menu may show. Folders never offer Download; missing items lose destructive actions.
|
|
17
|
+
* The legacy Uploads folder (`folder_my_uploads`) is treated like any other folder — nothing here is reserved.
|
|
18
|
+
*/
|
|
19
|
+
export declare function itemMenuCapabilities(input: ItemMenuCapabilitiesInput): ItemMenuCapabilities;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which row actions the item "…" menu may show. Folders never offer Download; missing items lose destructive actions.
|
|
3
|
+
* The legacy Uploads folder (`folder_my_uploads`) is treated like any other folder — nothing here is reserved.
|
|
4
|
+
*/
|
|
5
|
+
export function itemMenuCapabilities(input) {
|
|
6
|
+
const { capabilities, isFolder, isMissing, fileUrl } = input;
|
|
7
|
+
const canRename = capabilities.rename && !isMissing;
|
|
8
|
+
const canMove = capabilities.folders && !isMissing;
|
|
9
|
+
const canDownload = capabilities.download && !isMissing && !isFolder && Boolean(fileUrl);
|
|
10
|
+
const canDelete = capabilities.delete;
|
|
11
|
+
const hasAnyAction = canRename || canMove || canDownload || canDelete;
|
|
12
|
+
return { canRename, canMove, canDownload, canDelete, hasAnyAction };
|
|
13
|
+
}
|
|
@@ -12,9 +12,12 @@ export declare function findItemByIdInTree(root: FileSystemItem, id: string): Fi
|
|
|
12
12
|
export declare function dedupeTreeIds(items: FileSystemItem[]): FileSystemItem[];
|
|
13
13
|
/**
|
|
14
14
|
* Merges flat API file list into a saved tree: known ids refresh in place (their saved, possibly renamed, name is kept);
|
|
15
|
-
* unknown files
|
|
15
|
+
* unknown files appear at the root. The legacy `folder_my_uploads` folder is kept only when the visitor still has it in
|
|
16
|
+
* their saved tree (it is never recreated after delete).
|
|
16
17
|
*/
|
|
17
|
-
export declare function mergeApiFilesIntoSavedTree(rootChildren: FileSystemItem[] | null, apiFiles: FileSystemItem[],
|
|
18
|
+
export declare function mergeApiFilesIntoSavedTree(rootChildren: FileSystemItem[] | null, apiFiles: FileSystemItem[], _myUploadsName: string): FileSystemItem[];
|
|
19
|
+
/** Saved tree held only files with no folder wrapper (pre–whole-tree persistence). */
|
|
20
|
+
export declare function isLegacyUploadsOnlyChildren(children: FileSystemItem[]): boolean;
|
|
18
21
|
/**
|
|
19
22
|
* One-step legacy migration: old persist stored only My Uploads' children under key `current`.
|
|
20
23
|
* Wraps them inside `folder_my_uploads` at the root.
|
|
@@ -87,36 +87,13 @@ export function dedupeTreeIds(items) {
|
|
|
87
87
|
}
|
|
88
88
|
return walk(items);
|
|
89
89
|
}
|
|
90
|
-
function getOrCreateMyUploadsFolder(rootChildren, myUploadsName) {
|
|
91
|
-
let myUploads = rootChildren.find((c) => c.id === BUILTIN_UPLOADS_ID && c.type === 'folder');
|
|
92
|
-
if (!myUploads) {
|
|
93
|
-
myUploads = {
|
|
94
|
-
id: BUILTIN_UPLOADS_ID,
|
|
95
|
-
name: myUploadsName,
|
|
96
|
-
type: 'folder',
|
|
97
|
-
children: [],
|
|
98
|
-
modified: new Date().toISOString()
|
|
99
|
-
};
|
|
100
|
-
return { rootChildren: [...rootChildren, myUploads].sort(sortRootLevelItems), myUploads };
|
|
101
|
-
}
|
|
102
|
-
if (myUploads.name !== myUploadsName) {
|
|
103
|
-
const updated = { ...myUploads, name: myUploadsName };
|
|
104
|
-
return {
|
|
105
|
-
rootChildren: rootChildren.map((c) => (c === myUploads ? updated : c)),
|
|
106
|
-
myUploads: updated
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return { rootChildren, myUploads };
|
|
110
|
-
}
|
|
111
90
|
/**
|
|
112
91
|
* Merges flat API file list into a saved tree: known ids refresh in place (their saved, possibly renamed, name is kept);
|
|
113
|
-
* unknown files
|
|
92
|
+
* unknown files appear at the root. The legacy `folder_my_uploads` folder is kept only when the visitor still has it in
|
|
93
|
+
* their saved tree (it is never recreated after delete).
|
|
114
94
|
*/
|
|
115
|
-
export function mergeApiFilesIntoSavedTree(rootChildren, apiFiles,
|
|
95
|
+
export function mergeApiFilesIntoSavedTree(rootChildren, apiFiles, _myUploadsName) {
|
|
116
96
|
let children = dedupeTreeIds(reviveFileSystemDates(rootChildren ?? []));
|
|
117
|
-
const ensured = getOrCreateMyUploadsFolder(children, myUploadsName);
|
|
118
|
-
children = ensured.rootChildren;
|
|
119
|
-
const myUploads = ensured.myUploads;
|
|
120
97
|
function replaceFileById(items, id, file) {
|
|
121
98
|
for (let i = 0; i < items.length; i++) {
|
|
122
99
|
const it = items[i];
|
|
@@ -148,19 +125,22 @@ export function mergeApiFilesIntoSavedTree(rootChildren, apiFiles, myUploadsName
|
|
|
148
125
|
if (findItemByIdInTree(rootFolder, file.id)) {
|
|
149
126
|
replaceFileById(rootFolder.children, file.id, normalized);
|
|
150
127
|
}
|
|
151
|
-
else {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
direction: 'asc'
|
|
158
|
-
});
|
|
159
|
-
}
|
|
128
|
+
else if (!rootFolder.children.some((c) => c.type === 'file' && c.id === file.id)) {
|
|
129
|
+
rootFolder.children.push(normalized);
|
|
130
|
+
sortFolderContentsLikeGrid(rootFolder.children, {
|
|
131
|
+
criteria: 'name',
|
|
132
|
+
direction: 'asc'
|
|
133
|
+
});
|
|
160
134
|
}
|
|
161
135
|
}
|
|
162
136
|
return dedupeTreeIds(rootFolder.children);
|
|
163
137
|
}
|
|
138
|
+
/** Saved tree held only files with no folder wrapper (pre–whole-tree persistence). */
|
|
139
|
+
export function isLegacyUploadsOnlyChildren(children) {
|
|
140
|
+
if (!children.length)
|
|
141
|
+
return false;
|
|
142
|
+
return children.every((c) => c.type === 'file');
|
|
143
|
+
}
|
|
164
144
|
/**
|
|
165
145
|
* One-step legacy migration: old persist stored only My Uploads' children under key `current`.
|
|
166
146
|
* Wraps them inside `folder_my_uploads` at the root.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FileSystemItem } from '../types';
|
|
2
|
+
/** Default page size for GET /v1/uploads (no cursor yet). */
|
|
3
|
+
export declare const WIDGETIC_UPLOADS_LIST_LIMIT = 100;
|
|
4
|
+
/**
|
|
5
|
+
* Merges a Dexie-cached upload list with a fresh API page.
|
|
6
|
+
* When the API returns fewer than `listLimit` rows, the list is treated as complete and cached-only ids are dropped.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mergeRemoteUploadList(cachedFiles: FileSystemItem[], remoteFiles: FileSystemItem[], options: {
|
|
9
|
+
listLimit?: number;
|
|
10
|
+
apiHydrationSucceeded: boolean;
|
|
11
|
+
}): FileSystemItem[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Default page size for GET /v1/uploads (no cursor yet). */
|
|
2
|
+
export const WIDGETIC_UPLOADS_LIST_LIMIT = 100;
|
|
3
|
+
/**
|
|
4
|
+
* Merges a Dexie-cached upload list with a fresh API page.
|
|
5
|
+
* When the API returns fewer than `listLimit` rows, the list is treated as complete and cached-only ids are dropped.
|
|
6
|
+
*/
|
|
7
|
+
export function mergeRemoteUploadList(cachedFiles, remoteFiles, options) {
|
|
8
|
+
if (!options.apiHydrationSucceeded) {
|
|
9
|
+
const byId = new Map(cachedFiles.map((file) => [file.id, file]));
|
|
10
|
+
for (const remoteFile of remoteFiles) {
|
|
11
|
+
byId.set(remoteFile.id, remoteFile);
|
|
12
|
+
}
|
|
13
|
+
return Array.from(byId.values());
|
|
14
|
+
}
|
|
15
|
+
const listLimit = options.listLimit ?? WIDGETIC_UPLOADS_LIST_LIMIT;
|
|
16
|
+
const remoteIds = new Set(remoteFiles.map((file) => file.id));
|
|
17
|
+
const completeList = remoteFiles.length < listLimit;
|
|
18
|
+
const byId = new Map(cachedFiles.map((file) => [file.id, file]));
|
|
19
|
+
for (const remoteFile of remoteFiles) {
|
|
20
|
+
byId.set(remoteFile.id, remoteFile);
|
|
21
|
+
}
|
|
22
|
+
if (completeList) {
|
|
23
|
+
for (const cachedId of [...byId.keys()]) {
|
|
24
|
+
if (!remoteIds.has(cachedId)) {
|
|
25
|
+
byId.delete(cachedId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return Array.from(byId.values());
|
|
30
|
+
}
|
|
@@ -12,6 +12,14 @@ export declare function saveUserUpload(file: FileSystemItem): void;
|
|
|
12
12
|
* Persist multiple uploads into L1 in a single atomic transaction.
|
|
13
13
|
* Eliminates IndexedDB race conditions and reduces write overhead when hydrating batches of files.
|
|
14
14
|
*/
|
|
15
|
+
/**
|
|
16
|
+
* Replaces the persisted upload list in L1 (used after API hydration or session preload).
|
|
17
|
+
*/
|
|
18
|
+
export declare function replacePersistedUploads(files: FileSystemItem[]): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Removes uploads from L1 by id (after delete elsewhere or preview 404).
|
|
21
|
+
*/
|
|
22
|
+
export declare function removePersistedUploads(fileIds: ReadonlyArray<string>): Promise<void>;
|
|
15
23
|
export declare function saveUserUploadsBatch(files: FileSystemItem[]): void;
|
|
16
24
|
/**
|
|
17
25
|
* Load the saved library tree children (the children of the synthetic root) from L1, with legacy migration.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeApiFilesIntoSavedTree, migrateLegacyUploadsOnlyChildren } from './libraryTree';
|
|
1
|
+
import { isLegacyUploadsOnlyChildren, mergeApiFilesIntoSavedTree, migrateLegacyUploadsOnlyChildren } from './libraryTree';
|
|
2
2
|
import { CACHE_POLICIES, getCacheOwner, readEntity, writeEntity } from '@widgetic/cache-layer';
|
|
3
3
|
// Legacy localStorage keys, read once for migration then superseded by L1.
|
|
4
4
|
const LEGACY_STORAGE_KEY = 'widgetic-file-browser-uploads';
|
|
@@ -50,6 +50,38 @@ export function saveUserUpload(file) {
|
|
|
50
50
|
* Persist multiple uploads into L1 in a single atomic transaction.
|
|
51
51
|
* Eliminates IndexedDB race conditions and reduces write overhead when hydrating batches of files.
|
|
52
52
|
*/
|
|
53
|
+
/**
|
|
54
|
+
* Replaces the persisted upload list in L1 (used after API hydration or session preload).
|
|
55
|
+
*/
|
|
56
|
+
export async function replacePersistedUploads(files) {
|
|
57
|
+
const ownerId = ownerIdOrNull();
|
|
58
|
+
if (!ownerId)
|
|
59
|
+
return;
|
|
60
|
+
const uploads = files.filter((file) => file.type === 'file');
|
|
61
|
+
try {
|
|
62
|
+
await writeEntity(ownerId, UPLOADS_KIND, entityKey(), uploads);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error('[userUploadsStorage] Failed to replace uploads list:', error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Removes uploads from L1 by id (after delete elsewhere or preview 404).
|
|
70
|
+
*/
|
|
71
|
+
export async function removePersistedUploads(fileIds) {
|
|
72
|
+
const ownerId = ownerIdOrNull();
|
|
73
|
+
if (!ownerId || fileIds.length === 0)
|
|
74
|
+
return;
|
|
75
|
+
const drop = new Set(fileIds);
|
|
76
|
+
try {
|
|
77
|
+
const existing = await loadAllPersistedUploads();
|
|
78
|
+
const next = existing.filter((file) => !drop.has(file.id));
|
|
79
|
+
await writeEntity(ownerId, UPLOADS_KIND, entityKey(), next);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error('[userUploadsStorage] Failed to remove uploads from cache:', error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
53
85
|
export function saveUserUploadsBatch(files) {
|
|
54
86
|
const validFiles = files.filter((f) => f.type === 'file');
|
|
55
87
|
if (validFiles.length === 0)
|
|
@@ -174,7 +206,9 @@ export async function createUserUploadsFileSystemRoot(files, myUploadsName = 'Up
|
|
|
174
206
|
const hasBuiltInUploads = savedRaw.some((c) => c.id === 'folder_my_uploads' && c.type === 'folder');
|
|
175
207
|
savedChildren = hasBuiltInUploads
|
|
176
208
|
? savedRaw
|
|
177
|
-
:
|
|
209
|
+
: isLegacyUploadsOnlyChildren(savedRaw)
|
|
210
|
+
? migrateLegacyUploadsOnlyChildren(savedRaw, myUploadsName)
|
|
211
|
+
: savedRaw;
|
|
178
212
|
}
|
|
179
213
|
const children = mergeApiFilesIntoSavedTree(savedChildren, files, myUploadsName);
|
|
180
214
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/file-browser",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.43",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"@tailwindcss/postcss": "^4.3.0",
|
|
98
98
|
"@types/node": "^22.13.4",
|
|
99
99
|
"@widgetic/cache-layer": "^0.1.1",
|
|
100
|
-
"@widgetic/design-system": "^0.5.
|
|
100
|
+
"@widgetic/design-system": "^0.5.28",
|
|
101
101
|
"@widgetic/dev-tools": "^0.3.0",
|
|
102
102
|
"concurrently": "^9.1.2",
|
|
103
103
|
"eslint": "^9.0.0",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"peerDependencies": {
|
|
119
119
|
"@sveltejs/kit": "^2.20.7",
|
|
120
120
|
"@widgetic/cache-layer": "^0.1.1",
|
|
121
|
-
"@widgetic/design-system": ">=0.5.
|
|
121
|
+
"@widgetic/design-system": ">=0.5.28",
|
|
122
122
|
"pdfjs-dist": "^4.10.38",
|
|
123
123
|
"svelte": "^5.0.0"
|
|
124
124
|
},
|