@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,59 +1,14 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
-
if (ar || !(i in from)) {
|
|
40
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
-
ar[i] = from[i];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
-
};
|
|
46
1
|
import { flattenLegacyBuiltinUploads, isLegacyUploadsOnlyChildren, mergeApiFilesIntoSavedTree, migrateLegacyUploadsOnlyChildren } from './libraryTree';
|
|
47
2
|
import { CACHE_POLICIES, ensureCacheOwnerFromSessionHint, getCacheOwner, readEntity, writeEntity } from '@widgetic/cache-layer';
|
|
48
3
|
// Legacy localStorage keys, read once for migration then superseded by L1.
|
|
49
|
-
|
|
50
|
-
|
|
4
|
+
const LEGACY_STORAGE_KEY = 'widgetic-file-browser-uploads';
|
|
5
|
+
const LEGACY_LIBRARY_TREE_KEY = 'widgetic-file-browser-library-tree';
|
|
51
6
|
/** Entity kind for uploaded files in the L1 store. */
|
|
52
|
-
|
|
7
|
+
const UPLOADS_KIND = 'fileBrowserUploads';
|
|
53
8
|
/** Entity kind for the saved "My uploads" tree in the L1 store. */
|
|
54
|
-
|
|
9
|
+
const TREE_KIND = 'fileBrowserLibraryTree';
|
|
55
10
|
/** Persisted root children (Uploads folder, sibling folders, loose root files). Legacy key `current` held only Uploads' children. */
|
|
56
|
-
|
|
11
|
+
const TREE_KEY_ROOT_CHILDREN = 'root-children';
|
|
57
12
|
function entityKey() {
|
|
58
13
|
return 'current';
|
|
59
14
|
}
|
|
@@ -64,38 +19,26 @@ function ownerIdOrNull() {
|
|
|
64
19
|
/**
|
|
65
20
|
* Load persisted uploads from L1 (falling back to the legacy localStorage blob).
|
|
66
21
|
*/
|
|
67
|
-
export function loadUserUploads() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!raw)
|
|
88
|
-
return [2 /*return*/, []];
|
|
89
|
-
parsed = JSON.parse(raw);
|
|
90
|
-
return [2 /*return*/, Array.isArray(parsed) ? parsed : []];
|
|
91
|
-
}
|
|
92
|
-
catch (_b) {
|
|
93
|
-
return [2 /*return*/, []];
|
|
94
|
-
}
|
|
95
|
-
return [2 /*return*/];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
22
|
+
export async function loadUserUploads() {
|
|
23
|
+
const ownerId = ownerIdOrNull();
|
|
24
|
+
if (ownerId) {
|
|
25
|
+
const persisted = await readEntity(ownerId, UPLOADS_KIND, entityKey(), CACHE_POLICIES['files.uploads'].staleTtlMs);
|
|
26
|
+
if (persisted && Array.isArray(persisted)) {
|
|
27
|
+
return persisted;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (typeof localStorage === 'undefined')
|
|
31
|
+
return [];
|
|
32
|
+
try {
|
|
33
|
+
const raw = localStorage.getItem(LEGACY_STORAGE_KEY);
|
|
34
|
+
if (!raw)
|
|
35
|
+
return [];
|
|
36
|
+
const parsed = JSON.parse(raw);
|
|
37
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
99
42
|
}
|
|
100
43
|
/**
|
|
101
44
|
* Persist one upload into L1 (no entry cap; IndexedDB handles large sets).
|
|
@@ -111,74 +54,43 @@ export function saveUserUpload(file) {
|
|
|
111
54
|
/**
|
|
112
55
|
* Replaces the persisted upload list in L1 (used after API hydration or session preload).
|
|
113
56
|
*/
|
|
114
|
-
export function replacePersistedUploads(files) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
case 1:
|
|
126
|
-
_a.trys.push([1, 3, , 4]);
|
|
127
|
-
return [4 /*yield*/, writeEntity(ownerId, UPLOADS_KIND, entityKey(), uploads)];
|
|
128
|
-
case 2:
|
|
129
|
-
_a.sent();
|
|
130
|
-
return [3 /*break*/, 4];
|
|
131
|
-
case 3:
|
|
132
|
-
error_1 = _a.sent();
|
|
133
|
-
console.error('[userUploadsStorage] Failed to replace uploads list:', error_1);
|
|
134
|
-
return [3 /*break*/, 4];
|
|
135
|
-
case 4: return [2 /*return*/];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
57
|
+
export async function replacePersistedUploads(files) {
|
|
58
|
+
const ownerId = ownerIdOrNull();
|
|
59
|
+
if (!ownerId)
|
|
60
|
+
return;
|
|
61
|
+
const uploads = files.filter((file) => file.type === 'file');
|
|
62
|
+
try {
|
|
63
|
+
await writeEntity(ownerId, UPLOADS_KIND, entityKey(), uploads);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error('[userUploadsStorage] Failed to replace uploads list:', error);
|
|
67
|
+
}
|
|
139
68
|
}
|
|
140
69
|
/**
|
|
141
70
|
* Removes uploads from L1 by id (after delete elsewhere or preview 404).
|
|
142
71
|
*/
|
|
143
|
-
export function removePersistedUploads(fileIds) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return [4 /*yield*/, loadAllPersistedUploads()];
|
|
157
|
-
case 2:
|
|
158
|
-
existing = _a.sent();
|
|
159
|
-
next = existing.filter(function (file) { return !drop.has(file.id); });
|
|
160
|
-
return [4 /*yield*/, writeEntity(ownerId, UPLOADS_KIND, entityKey(), next)];
|
|
161
|
-
case 3:
|
|
162
|
-
_a.sent();
|
|
163
|
-
return [3 /*break*/, 5];
|
|
164
|
-
case 4:
|
|
165
|
-
error_2 = _a.sent();
|
|
166
|
-
console.error('[userUploadsStorage] Failed to remove uploads from cache:', error_2);
|
|
167
|
-
return [3 /*break*/, 5];
|
|
168
|
-
case 5: return [2 /*return*/];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
72
|
+
export async function removePersistedUploads(fileIds) {
|
|
73
|
+
const ownerId = ownerIdOrNull();
|
|
74
|
+
if (!ownerId || fileIds.length === 0)
|
|
75
|
+
return;
|
|
76
|
+
const drop = new Set(fileIds);
|
|
77
|
+
try {
|
|
78
|
+
const existing = await loadAllPersistedUploads();
|
|
79
|
+
const next = existing.filter((file) => !drop.has(file.id));
|
|
80
|
+
await writeEntity(ownerId, UPLOADS_KIND, entityKey(), next);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('[userUploadsStorage] Failed to remove uploads from cache:', error);
|
|
84
|
+
}
|
|
172
85
|
}
|
|
173
86
|
export function saveUserUploadsBatch(files) {
|
|
174
|
-
|
|
175
|
-
var validFiles = files.filter(function (f) { return f.type === 'file'; });
|
|
87
|
+
const validFiles = files.filter((f) => f.type === 'file');
|
|
176
88
|
if (validFiles.length === 0)
|
|
177
89
|
return;
|
|
178
|
-
|
|
90
|
+
const ownerId = ownerIdOrNull();
|
|
179
91
|
if (!ownerId)
|
|
180
92
|
return;
|
|
181
|
-
|
|
93
|
+
const entries = validFiles.map((file) => ({
|
|
182
94
|
id: file.id,
|
|
183
95
|
name: file.name,
|
|
184
96
|
type: 'file',
|
|
@@ -188,116 +100,79 @@ export function saveUserUploadsBatch(files) {
|
|
|
188
100
|
modified: file.modified || new Date().toISOString(),
|
|
189
101
|
hash: file.hash,
|
|
190
102
|
mimeType: file.mimeType,
|
|
191
|
-
})
|
|
192
|
-
void (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return [4 /*yield*/, writeEntity(ownerId, UPLOADS_KIND, entityKey(), merged)];
|
|
205
|
-
case 2:
|
|
206
|
-
_a.sent();
|
|
207
|
-
return [3 /*break*/, 4];
|
|
208
|
-
case 3:
|
|
209
|
-
error_3 = _a.sent();
|
|
210
|
-
console.error('[userUploadsStorage] Failed to persist uploads batch:', error_3);
|
|
211
|
-
return [3 /*break*/, 4];
|
|
212
|
-
case 4: return [2 /*return*/];
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}); })();
|
|
103
|
+
}));
|
|
104
|
+
void (async () => {
|
|
105
|
+
try {
|
|
106
|
+
const existing = await loadAllPersistedUploads();
|
|
107
|
+
const newIds = new Set(entries.map((e) => e.id));
|
|
108
|
+
const filteredExisting = existing.filter((f) => !newIds.has(f.id));
|
|
109
|
+
const merged = [...entries, ...filteredExisting];
|
|
110
|
+
await writeEntity(ownerId, UPLOADS_KIND, entityKey(), merged);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error('[userUploadsStorage] Failed to persist uploads batch:', error);
|
|
114
|
+
}
|
|
115
|
+
})();
|
|
216
116
|
}
|
|
217
117
|
/** Reads every persisted upload regardless of TTL (used for merge-on-save). */
|
|
218
|
-
function loadAllPersistedUploads() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (!raw)
|
|
239
|
-
return [2 /*return*/, []];
|
|
240
|
-
parsed = JSON.parse(raw);
|
|
241
|
-
return [2 /*return*/, Array.isArray(parsed) ? parsed : []];
|
|
242
|
-
}
|
|
243
|
-
catch (_b) {
|
|
244
|
-
return [2 /*return*/, []];
|
|
245
|
-
}
|
|
246
|
-
return [2 /*return*/];
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
118
|
+
async function loadAllPersistedUploads() {
|
|
119
|
+
const ownerId = ownerIdOrNull();
|
|
120
|
+
if (ownerId) {
|
|
121
|
+
const persisted = await readEntity(ownerId, UPLOADS_KIND, entityKey());
|
|
122
|
+
if (persisted && Array.isArray(persisted)) {
|
|
123
|
+
return persisted;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (typeof localStorage === 'undefined')
|
|
127
|
+
return [];
|
|
128
|
+
try {
|
|
129
|
+
const raw = localStorage.getItem(LEGACY_STORAGE_KEY);
|
|
130
|
+
if (!raw)
|
|
131
|
+
return [];
|
|
132
|
+
const parsed = JSON.parse(raw);
|
|
133
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
250
138
|
}
|
|
251
139
|
/**
|
|
252
140
|
* Load the saved library tree children (the children of the synthetic root) from L1, with legacy migration.
|
|
253
141
|
*/
|
|
254
|
-
export function loadLibraryTreeChildren() {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
raw = localStorage.getItem(LEGACY_LIBRARY_TREE_KEY);
|
|
280
|
-
if (!raw)
|
|
281
|
-
return [2 /*return*/, null];
|
|
282
|
-
parsed = JSON.parse(raw);
|
|
283
|
-
return [2 /*return*/, Array.isArray(parsed) ? parsed : null];
|
|
284
|
-
}
|
|
285
|
-
catch (_b) {
|
|
286
|
-
return [2 /*return*/, null];
|
|
287
|
-
}
|
|
288
|
-
return [2 /*return*/];
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
});
|
|
142
|
+
export async function loadLibraryTreeChildren() {
|
|
143
|
+
const ownerId = ownerIdOrNull();
|
|
144
|
+
if (ownerId) {
|
|
145
|
+
const rootPersisted = await readEntity(ownerId, TREE_KIND, TREE_KEY_ROOT_CHILDREN, CACHE_POLICIES['files.libraryTree'].staleTtlMs);
|
|
146
|
+
if (rootPersisted && Array.isArray(rootPersisted)) {
|
|
147
|
+
return rootPersisted;
|
|
148
|
+
}
|
|
149
|
+
// Legacy: only `folder_my_uploads` inner children were stored under `current`.
|
|
150
|
+
const legacyInner = await readEntity(ownerId, TREE_KIND, entityKey(), CACHE_POLICIES['files.libraryTree'].staleTtlMs);
|
|
151
|
+
if (legacyInner && Array.isArray(legacyInner)) {
|
|
152
|
+
return legacyInner;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (typeof localStorage === 'undefined')
|
|
156
|
+
return null;
|
|
157
|
+
try {
|
|
158
|
+
const raw = localStorage.getItem(LEGACY_LIBRARY_TREE_KEY);
|
|
159
|
+
if (!raw)
|
|
160
|
+
return null;
|
|
161
|
+
const parsed = JSON.parse(raw);
|
|
162
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
292
167
|
}
|
|
293
168
|
/**
|
|
294
169
|
* Persist the library tree children (the whole root: Uploads, sibling folders, loose files) to L1 (fire-and-forget).
|
|
295
170
|
*/
|
|
296
171
|
export function saveLibraryTreeChildren(children) {
|
|
297
|
-
|
|
172
|
+
const ownerId = ownerIdOrNull();
|
|
298
173
|
if (!ownerId)
|
|
299
174
|
return;
|
|
300
|
-
void writeEntity(ownerId, TREE_KIND, TREE_KEY_ROOT_CHILDREN, children).catch(
|
|
175
|
+
void writeEntity(ownerId, TREE_KIND, TREE_KEY_ROOT_CHILDREN, children).catch((error) => {
|
|
301
176
|
console.error('[userUploadsStorage] Failed to persist root library tree:', error);
|
|
302
177
|
});
|
|
303
178
|
}
|
|
@@ -306,15 +181,13 @@ export function saveLibraryTreeChildren(children) {
|
|
|
306
181
|
* Saved tree keeps user-created subfolders; upload files are upserted by id.
|
|
307
182
|
*/
|
|
308
183
|
export function mergeMyUploadsChildren(savedChildren, uploadFiles) {
|
|
309
|
-
|
|
184
|
+
const byId = new Map();
|
|
310
185
|
if (savedChildren) {
|
|
311
|
-
for (
|
|
312
|
-
var item = savedChildren_1[_i];
|
|
186
|
+
for (const item of savedChildren) {
|
|
313
187
|
byId.set(item.id, item);
|
|
314
188
|
}
|
|
315
189
|
}
|
|
316
|
-
for (
|
|
317
|
-
var file = uploadFiles_1[_a];
|
|
190
|
+
for (const file of uploadFiles) {
|
|
318
191
|
if (file.type === 'file') {
|
|
319
192
|
byId.set(file.id, file);
|
|
320
193
|
}
|
|
@@ -327,32 +200,22 @@ export function mergeMyUploadsChildren(savedChildren, uploadFiles) {
|
|
|
327
200
|
* `myUploadsName` is what the visitor reads as the name of the one folder in it: the File Browser passes the word in
|
|
328
201
|
* the visitor's language ("Uploads" in English).
|
|
329
202
|
*/
|
|
330
|
-
export function createUserUploadsFileSystemRoot(
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
root: {
|
|
349
|
-
id: 'root',
|
|
350
|
-
name: 'Root',
|
|
351
|
-
type: 'folder',
|
|
352
|
-
children: children,
|
|
353
|
-
},
|
|
354
|
-
}];
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
});
|
|
203
|
+
export async function createUserUploadsFileSystemRoot(files, myUploadsName = 'Uploads') {
|
|
204
|
+
const savedRaw = await loadLibraryTreeChildren();
|
|
205
|
+
let savedChildren = null;
|
|
206
|
+
if (savedRaw && savedRaw.length > 0) {
|
|
207
|
+
savedChildren = isLegacyUploadsOnlyChildren(savedRaw)
|
|
208
|
+
? migrateLegacyUploadsOnlyChildren(savedRaw, myUploadsName)
|
|
209
|
+
: flattenLegacyBuiltinUploads(savedRaw);
|
|
210
|
+
}
|
|
211
|
+
const children = mergeApiFilesIntoSavedTree(savedChildren, files, myUploadsName);
|
|
212
|
+
return {
|
|
213
|
+
basePath: '',
|
|
214
|
+
root: {
|
|
215
|
+
id: 'root',
|
|
216
|
+
name: 'Root',
|
|
217
|
+
type: 'folder',
|
|
218
|
+
children,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
358
221
|
}
|
package/dist/utils/videoFrame.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* videos is black.
|
|
8
8
|
*/
|
|
9
9
|
/** Where in the video the cover is taken, in seconds. */
|
|
10
|
-
export
|
|
10
|
+
export const VIDEO_FRAME_SECONDS = 0.1;
|
|
11
11
|
/**
|
|
12
12
|
* The address to give a `<video>` so that it shows a frame without playing. An address that already carries a media
|
|
13
13
|
* fragment (`#t=…`) or any other fragment is left alone: the one who wrote it knows better.
|
|
@@ -15,7 +15,7 @@ export var VIDEO_FRAME_SECONDS = 0.1;
|
|
|
15
15
|
export function videoFrameSrc(url) {
|
|
16
16
|
if (!url || url.includes('#'))
|
|
17
17
|
return url;
|
|
18
|
-
return
|
|
18
|
+
return `${url}#t=${VIDEO_FRAME_SECONDS}`;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* True when a card draws the video itself as its cover: the file has an address and no thumbnail. A video that comes with a
|