@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.
Files changed (81) hide show
  1. package/dist/actions/dragSelectedToFolder.js +115 -104
  2. package/dist/components/FolderTree.svelte.d.ts +7 -4
  3. package/dist/components/core/FileBrowser.svelte +1 -3
  4. package/dist/components/core/dropzoneClick.js +2 -3
  5. package/dist/components/previews/FilePreview.svelte.d.ts +2 -2
  6. package/dist/config.js +3 -4
  7. package/dist/i18n/context.js +2 -2
  8. package/dist/i18n/errors.js +1 -2
  9. package/dist/i18n/messages.js +2 -2
  10. package/dist/i18n/text.js +2 -2
  11. package/dist/mediaLibrary/capabilities.js +3 -4
  12. package/dist/mediaLibrary/context.js +3 -4
  13. package/dist/mediaLibrary/errors.js +35 -46
  14. package/dist/mediaLibrary/normalize.js +42 -45
  15. package/dist/mediaLibrary/paging.js +45 -100
  16. package/dist/mediaLibrary/resolve.js +95 -214
  17. package/dist/mediaLibrary/treeOps.js +20 -40
  18. package/dist/mediaLibrary/urls.js +10 -12
  19. package/dist/mediaLibrary/widgetic.js +54 -140
  20. package/dist/stores/dragStore.js +1 -1
  21. package/dist/stores/fileStore.d.ts +3 -3
  22. package/dist/stores/fileStore.js +37 -44
  23. package/dist/stores/folderCountStore.js +11 -12
  24. package/dist/stores/missingFilesStore.js +3 -3
  25. package/dist/stores/navigationStore.d.ts +1 -1
  26. package/dist/stores/navigationStore.js +178 -217
  27. package/dist/stores/persistentSelectStore.d.ts +1 -1
  28. package/dist/stores/persistentSelectStore.js +94 -117
  29. package/dist/stores/searchStore.js +1 -1
  30. package/dist/stores/uploadApiStore.js +7 -7
  31. package/dist/stores/viewportStore.js +4 -4
  32. package/dist/types/index.js +1 -0
  33. package/dist/utils/apiConfig.js +9 -9
  34. package/dist/utils/brandKitLibraryTree.js +42 -57
  35. package/dist/utils/dateUtils.js +9 -11
  36. package/dist/utils/dragToFolder/batchMoveResult.js +54 -114
  37. package/dist/utils/dragToFolder/folderDropTarget.js +17 -23
  38. package/dist/utils/dragToFolder/springStep.js +3 -4
  39. package/dist/utils/fileGoneProbe.js +16 -65
  40. package/dist/utils/fileKinds.js +13 -14
  41. package/dist/utils/fileNames.js +7 -7
  42. package/dist/utils/fileOperations.js +332 -440
  43. package/dist/utils/fileTypes.js +14 -19
  44. package/dist/utils/fileUtils.js +31 -85
  45. package/dist/utils/folderUtils.js +4 -5
  46. package/dist/utils/gridLayout.js +7 -7
  47. package/dist/utils/imagePreviewCache.js +15 -26
  48. package/dist/utils/imagePreviewFrame.js +13 -13
  49. package/dist/utils/imagePreviewVisualState.js +4 -5
  50. package/dist/utils/imageTransform.js +14 -27
  51. package/dist/utils/itemMenuCapabilities.js +7 -7
  52. package/dist/utils/libraryTree.js +39 -55
  53. package/dist/utils/pendingUploadDeletes.js +113 -289
  54. package/dist/utils/previewKeys.js +1 -1
  55. package/dist/utils/previewListNavigation.js +11 -13
  56. package/dist/utils/previewNavigation.js +7 -10
  57. package/dist/utils/recentFiles.js +6 -16
  58. package/dist/utils/recentFilesLimit.js +2 -2
  59. package/dist/utils/removeItems.js +29 -61
  60. package/dist/utils/resolveFileUrl.js +6 -6
  61. package/dist/utils/safeText.js +12 -14
  62. package/dist/utils/searchDropdownPhase.js +2 -2
  63. package/dist/utils/searchItems.js +14 -30
  64. package/dist/utils/searchNavigation.js +5 -5
  65. package/dist/utils/uploadAuth.js +36 -111
  66. package/dist/utils/uploadDisplayProgress.js +1 -1
  67. package/dist/utils/uploadLimits.js +66 -138
  68. package/dist/utils/uploadListReconcile.js +11 -24
  69. package/dist/utils/uploadPanelDismiss.js +1 -1
  70. package/dist/utils/uploadPanelProgress.js +4 -4
  71. package/dist/utils/uploadProgressMath.js +11 -13
  72. package/dist/utils/uploadRefusals.js +24 -40
  73. package/dist/utils/uploadResponseMapping.js +8 -9
  74. package/dist/utils/uploadUiHelpers.js +17 -17
  75. package/dist/utils/userUploadsStorage.js +133 -270
  76. package/dist/utils/videoFrame.js +2 -2
  77. package/dist/utils/widgeticDelete.js +30 -103
  78. package/dist/utils/widgeticTusUpload.js +105 -189
  79. package/dist/utils/widgeticUpload.js +62 -130
  80. package/dist/utils/xhrMultipartUpload.js +116 -164
  81. 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
- var LEGACY_STORAGE_KEY = 'widgetic-file-browser-uploads';
50
- var LEGACY_LIBRARY_TREE_KEY = 'widgetic-file-browser-library-tree';
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
- var UPLOADS_KIND = 'fileBrowserUploads';
7
+ const UPLOADS_KIND = 'fileBrowserUploads';
53
8
  /** Entity kind for the saved "My uploads" tree in the L1 store. */
54
- var TREE_KIND = 'fileBrowserLibraryTree';
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
- var TREE_KEY_ROOT_CHILDREN = 'root-children';
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
- return __awaiter(this, void 0, Promise, function () {
69
- var ownerId, persisted, raw, parsed;
70
- return __generator(this, function (_a) {
71
- switch (_a.label) {
72
- case 0:
73
- ownerId = ownerIdOrNull();
74
- if (!ownerId) return [3 /*break*/, 2];
75
- return [4 /*yield*/, readEntity(ownerId, UPLOADS_KIND, entityKey(), CACHE_POLICIES['files.uploads'].staleTtlMs)];
76
- case 1:
77
- persisted = _a.sent();
78
- if (persisted && Array.isArray(persisted)) {
79
- return [2 /*return*/, persisted];
80
- }
81
- _a.label = 2;
82
- case 2:
83
- if (typeof localStorage === 'undefined')
84
- return [2 /*return*/, []];
85
- try {
86
- raw = localStorage.getItem(LEGACY_STORAGE_KEY);
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
- return __awaiter(this, void 0, Promise, function () {
116
- var ownerId, uploads, error_1;
117
- return __generator(this, function (_a) {
118
- switch (_a.label) {
119
- case 0:
120
- ownerId = ownerIdOrNull();
121
- if (!ownerId)
122
- return [2 /*return*/];
123
- uploads = files.filter(function (file) { return file.type === 'file'; });
124
- _a.label = 1;
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
- return __awaiter(this, void 0, Promise, function () {
145
- var ownerId, drop, existing, next, error_2;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0:
149
- ownerId = ownerIdOrNull();
150
- if (!ownerId || fileIds.length === 0)
151
- return [2 /*return*/];
152
- drop = new Set(fileIds);
153
- _a.label = 1;
154
- case 1:
155
- _a.trys.push([1, 4, , 5]);
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
- var _this = this;
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
- var ownerId = ownerIdOrNull();
90
+ const ownerId = ownerIdOrNull();
179
91
  if (!ownerId)
180
92
  return;
181
- var entries = validFiles.map(function (file) { return ({
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 (function () { return __awaiter(_this, void 0, void 0, function () {
193
- var existing, newIds_1, filteredExisting, merged, error_3;
194
- return __generator(this, function (_a) {
195
- switch (_a.label) {
196
- case 0:
197
- _a.trys.push([0, 3, , 4]);
198
- return [4 /*yield*/, loadAllPersistedUploads()];
199
- case 1:
200
- existing = _a.sent();
201
- newIds_1 = new Set(entries.map(function (e) { return e.id; }));
202
- filteredExisting = existing.filter(function (f) { return !newIds_1.has(f.id); });
203
- merged = __spreadArray(__spreadArray([], entries, true), filteredExisting, true);
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
- return __awaiter(this, void 0, Promise, function () {
220
- var ownerId, persisted, raw, parsed;
221
- return __generator(this, function (_a) {
222
- switch (_a.label) {
223
- case 0:
224
- ownerId = ownerIdOrNull();
225
- if (!ownerId) return [3 /*break*/, 2];
226
- return [4 /*yield*/, readEntity(ownerId, UPLOADS_KIND, entityKey())];
227
- case 1:
228
- persisted = _a.sent();
229
- if (persisted && Array.isArray(persisted)) {
230
- return [2 /*return*/, persisted];
231
- }
232
- _a.label = 2;
233
- case 2:
234
- if (typeof localStorage === 'undefined')
235
- return [2 /*return*/, []];
236
- try {
237
- raw = localStorage.getItem(LEGACY_STORAGE_KEY);
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
- return __awaiter(this, void 0, Promise, function () {
256
- var ownerId, rootPersisted, legacyInner, raw, parsed;
257
- return __generator(this, function (_a) {
258
- switch (_a.label) {
259
- case 0:
260
- ownerId = ownerIdOrNull();
261
- if (!ownerId) return [3 /*break*/, 3];
262
- return [4 /*yield*/, readEntity(ownerId, TREE_KIND, TREE_KEY_ROOT_CHILDREN, CACHE_POLICIES['files.libraryTree'].staleTtlMs)];
263
- case 1:
264
- rootPersisted = _a.sent();
265
- if (rootPersisted && Array.isArray(rootPersisted)) {
266
- return [2 /*return*/, rootPersisted];
267
- }
268
- return [4 /*yield*/, readEntity(ownerId, TREE_KIND, entityKey(), CACHE_POLICIES['files.libraryTree'].staleTtlMs)];
269
- case 2:
270
- legacyInner = _a.sent();
271
- if (legacyInner && Array.isArray(legacyInner)) {
272
- return [2 /*return*/, legacyInner];
273
- }
274
- _a.label = 3;
275
- case 3:
276
- if (typeof localStorage === 'undefined')
277
- return [2 /*return*/, null];
278
- try {
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
- var ownerId = ownerIdOrNull();
172
+ const ownerId = ownerIdOrNull();
298
173
  if (!ownerId)
299
174
  return;
300
- void writeEntity(ownerId, TREE_KIND, TREE_KEY_ROOT_CHILDREN, children).catch(function (error) {
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
- var byId = new Map();
184
+ const byId = new Map();
310
185
  if (savedChildren) {
311
- for (var _i = 0, savedChildren_1 = savedChildren; _i < savedChildren_1.length; _i++) {
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 (var _a = 0, uploadFiles_1 = uploadFiles; _a < uploadFiles_1.length; _a++) {
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(files_1) {
331
- return __awaiter(this, arguments, Promise, function (files, myUploadsName) {
332
- var savedRaw, savedChildren, children;
333
- if (myUploadsName === void 0) { myUploadsName = 'Uploads'; }
334
- return __generator(this, function (_a) {
335
- switch (_a.label) {
336
- case 0: return [4 /*yield*/, loadLibraryTreeChildren()];
337
- case 1:
338
- savedRaw = _a.sent();
339
- savedChildren = null;
340
- if (savedRaw && savedRaw.length > 0) {
341
- savedChildren = isLegacyUploadsOnlyChildren(savedRaw)
342
- ? migrateLegacyUploadsOnlyChildren(savedRaw, myUploadsName)
343
- : flattenLegacyBuiltinUploads(savedRaw);
344
- }
345
- children = mergeApiFilesIntoSavedTree(savedChildren, files, myUploadsName);
346
- return [2 /*return*/, {
347
- basePath: '',
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
  }
@@ -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 var VIDEO_FRAME_SECONDS = 0.1;
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 "".concat(url, "#t=").concat(VIDEO_FRAME_SECONDS);
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