@widgetic/file-browser 0.5.47 → 0.5.48

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 (102) hide show
  1. package/dist/actions/dragSelectedToFolder.js +104 -115
  2. package/dist/components/FolderTree.svelte.d.ts +4 -7
  3. package/dist/components/core/Dropzone.svelte +42 -2
  4. package/dist/components/core/FileBrowser.svelte +224 -14
  5. package/dist/components/core/FileUploader.svelte +124 -41
  6. package/dist/components/core/RecentFiles.svelte +54 -16
  7. package/dist/components/core/SearchDropdown.svelte +6 -8
  8. package/dist/components/core/UploadPanel.svelte +7 -0
  9. package/dist/components/core/UploadPanel.svelte.d.ts +4 -0
  10. package/dist/components/core/UploadRow.svelte +9 -4
  11. package/dist/components/core/UploadRow.svelte.d.ts +2 -0
  12. package/dist/components/core/dropzoneClick.d.ts +28 -0
  13. package/dist/components/core/dropzoneClick.js +32 -0
  14. package/dist/components/previews/FilePreview.svelte.d.ts +2 -2
  15. package/dist/components/ui/DropdownMenu.svelte +1 -1
  16. package/dist/config.js +4 -3
  17. package/dist/i18n/context.js +2 -2
  18. package/dist/i18n/errors.js +2 -1
  19. package/dist/i18n/messages.d.ts +13 -0
  20. package/dist/i18n/messages.js +15 -2
  21. package/dist/i18n/text.js +2 -2
  22. package/dist/mediaLibrary/capabilities.js +4 -3
  23. package/dist/mediaLibrary/context.js +4 -3
  24. package/dist/mediaLibrary/errors.js +46 -35
  25. package/dist/mediaLibrary/normalize.js +45 -42
  26. package/dist/mediaLibrary/paging.js +100 -45
  27. package/dist/mediaLibrary/resolve.js +214 -95
  28. package/dist/mediaLibrary/treeOps.js +40 -20
  29. package/dist/mediaLibrary/urls.js +12 -10
  30. package/dist/mediaLibrary/widgetic.js +140 -54
  31. package/dist/stores/dragStore.js +1 -1
  32. package/dist/stores/fileStore.d.ts +3 -3
  33. package/dist/stores/fileStore.js +44 -37
  34. package/dist/stores/folderCountStore.js +12 -11
  35. package/dist/stores/missingFilesStore.js +3 -3
  36. package/dist/stores/navigationStore.d.ts +1 -1
  37. package/dist/stores/navigationStore.js +217 -178
  38. package/dist/stores/persistentSelectStore.d.ts +1 -1
  39. package/dist/stores/persistentSelectStore.js +117 -94
  40. package/dist/stores/searchStore.js +1 -1
  41. package/dist/stores/uploadApiStore.d.ts +10 -0
  42. package/dist/stores/uploadApiStore.js +7 -7
  43. package/dist/stores/viewportStore.js +4 -4
  44. package/dist/types/index.js +0 -1
  45. package/dist/utils/apiConfig.js +9 -9
  46. package/dist/utils/brandKitLibraryTree.js +57 -42
  47. package/dist/utils/dateUtils.js +11 -9
  48. package/dist/utils/deleteSelectionAction.d.ts +26 -0
  49. package/dist/utils/deleteSelectionAction.js +23 -0
  50. package/dist/utils/dragToFolder/batchMoveResult.js +114 -54
  51. package/dist/utils/dragToFolder/folderDropTarget.js +23 -17
  52. package/dist/utils/dragToFolder/springStep.js +4 -3
  53. package/dist/utils/fileGoneProbe.js +65 -16
  54. package/dist/utils/fileKinds.js +14 -13
  55. package/dist/utils/fileNames.js +7 -7
  56. package/dist/utils/fileOperations.js +440 -332
  57. package/dist/utils/fileTypes.js +19 -14
  58. package/dist/utils/fileUtils.js +85 -31
  59. package/dist/utils/folderUtils.js +5 -4
  60. package/dist/utils/gridLayout.js +7 -7
  61. package/dist/utils/imagePreviewCache.js +26 -15
  62. package/dist/utils/imagePreviewFrame.js +13 -13
  63. package/dist/utils/imagePreviewVisualState.js +5 -4
  64. package/dist/utils/imageTransform.js +27 -14
  65. package/dist/utils/itemMenuCapabilities.js +7 -7
  66. package/dist/utils/libraryTree.js +55 -39
  67. package/dist/utils/pendingUploadDeletes.d.ts +102 -0
  68. package/dist/utils/pendingUploadDeletes.js +400 -0
  69. package/dist/utils/previewKeys.js +1 -1
  70. package/dist/utils/previewListNavigation.js +13 -11
  71. package/dist/utils/previewNavigation.js +10 -7
  72. package/dist/utils/recentFiles.js +16 -6
  73. package/dist/utils/recentFilesLimit.js +2 -2
  74. package/dist/utils/removeItems.d.ts +30 -0
  75. package/dist/utils/removeItems.js +124 -0
  76. package/dist/utils/resolveFileUrl.js +6 -6
  77. package/dist/utils/safeText.js +14 -12
  78. package/dist/utils/searchDropdownPhase.d.ts +14 -3
  79. package/dist/utils/searchDropdownPhase.js +13 -9
  80. package/dist/utils/searchItems.js +30 -14
  81. package/dist/utils/searchNavigation.js +5 -5
  82. package/dist/utils/uploadAuth.d.ts +24 -0
  83. package/dist/utils/uploadAuth.js +140 -0
  84. package/dist/utils/uploadDisplayProgress.js +1 -1
  85. package/dist/utils/uploadLimits.d.ts +76 -0
  86. package/dist/utils/uploadLimits.js +242 -0
  87. package/dist/utils/uploadListReconcile.js +24 -11
  88. package/dist/utils/uploadPanelDismiss.js +1 -1
  89. package/dist/utils/uploadPanelProgress.js +4 -4
  90. package/dist/utils/uploadProgressMath.js +13 -11
  91. package/dist/utils/uploadRefusals.d.ts +42 -0
  92. package/dist/utils/uploadRefusals.js +86 -0
  93. package/dist/utils/uploadResponseMapping.js +9 -8
  94. package/dist/utils/uploadUiHelpers.js +17 -17
  95. package/dist/utils/userUploadsStorage.js +270 -133
  96. package/dist/utils/videoFrame.d.ts +23 -0
  97. package/dist/utils/videoFrame.js +26 -0
  98. package/dist/utils/widgeticDelete.js +103 -28
  99. package/dist/utils/widgeticTusUpload.js +189 -105
  100. package/dist/utils/widgeticUpload.js +133 -59
  101. package/dist/utils/xhrMultipartUpload.js +164 -116
  102. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  import { translateEnglish } from '../i18n/context';
2
2
  // Define which document types can be displayed as text
3
- export const PREVIEWABLE_TEXT_EXTENSIONS = ['.txt', '.md', '.csv', '.json', '.xml', '.log'];
4
- export const FILE_TYPES = {
3
+ export var PREVIEWABLE_TEXT_EXTENSIONS = ['.txt', '.md', '.csv', '.json', '.xml', '.log'];
4
+ export var FILE_TYPES = {
5
5
  image: ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.heic', '.heif'],
6
6
  audio: ['.mp3'],
7
7
  video: ['.mp4'],
@@ -9,7 +9,7 @@ export const FILE_TYPES = {
9
9
  font: ['.ttf', '.otf', '.woff', '.woff2'],
10
10
  svg: ['.svg']
11
11
  };
12
- export const FILTER_OPTIONS = ['all', 'image', 'audio', 'video', 'document', 'font', 'svg'];
12
+ export var FILTER_OPTIONS = ['all', 'image', 'audio', 'video', 'document', 'font', 'svg'];
13
13
  export function getAllowedFileTypes(filter) {
14
14
  if (filter === 'all') {
15
15
  return Object.values(FILE_TYPES).flat();
@@ -18,8 +18,9 @@ export function getAllowedFileTypes(filter) {
18
18
  }
19
19
  export function getFileTypeFromExtension(extension) {
20
20
  extension = extension.toLowerCase();
21
- for (const [type, extensions] of Object.entries(FILE_TYPES)) {
22
- if (extensions.some(ext => ext.toLowerCase() === extension)) {
21
+ for (var _i = 0, _a = Object.entries(FILE_TYPES); _i < _a.length; _i++) {
22
+ var _b = _a[_i], type = _b[0], extensions = _b[1];
23
+ if (extensions.some(function (ext) { return ext.toLowerCase() === extension; })) {
23
24
  return type;
24
25
  }
25
26
  }
@@ -27,15 +28,17 @@ export function getFileTypeFromExtension(extension) {
27
28
  }
28
29
  // New function to check if a file can be displayed as text
29
30
  export function isPreviewableTextFile(filename) {
30
- const extension = '.' + filename.split('.').pop()?.toLowerCase();
31
+ var _a;
32
+ var extension = '.' + ((_a = filename.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase());
31
33
  return PREVIEWABLE_TEXT_EXTENSIONS.includes(extension);
32
34
  }
33
35
  /**
34
36
  * One sentence that lists every kind of file with its extensions ("Add images (.jpg, .png), audio (.mp3) ..."). Pass the
35
37
  * `t` of the File Browser to have it in the page's language (English when left out).
36
38
  */
37
- export function formatFileTypesForDisplay(translate = translateEnglish) {
38
- const separator = translate('list.separator');
39
+ export function formatFileTypesForDisplay(translate) {
40
+ if (translate === void 0) { translate = translateEnglish; }
41
+ var separator = translate('list.separator');
39
42
  return translate('fileTypes.addAll', {
40
43
  images: FILE_TYPES.image.join(separator),
41
44
  audio: FILE_TYPES.audio.join(separator),
@@ -49,12 +52,13 @@ export function formatFileTypesForDisplay(translate = translateEnglish) {
49
52
  * The help text about what can be uploaded under a filter: "Allowed types: .jpg, .png ...", and for fonts how a font
50
53
  * file must be named. Pass the `t` of the File Browser to have it in the page's language (English when left out).
51
54
  */
52
- export function formatAllowedTypesForDisplay(filter, translate = translateEnglish) {
53
- const separator = translate('list.separator');
55
+ export function formatAllowedTypesForDisplay(filter, translate) {
56
+ if (translate === void 0) { translate = translateEnglish; }
57
+ var separator = translate('list.separator');
54
58
  if (filter === 'all') {
55
59
  return translate('fileTypes.allowed', { types: Object.values(FILE_TYPES).flat().join(separator) });
56
60
  }
57
- let allowedTypes = '';
61
+ var allowedTypes = '';
58
62
  if (filter === 'svg') {
59
63
  allowedTypes = translate('fileTypes.allowedSvg');
60
64
  }
@@ -65,11 +69,11 @@ export function formatAllowedTypesForDisplay(filter, translate = translateEnglis
65
69
  allowedTypes = translate('fileTypes.allowed', { types: FILE_TYPES[filter].join(separator) });
66
70
  }
67
71
  if (filter === 'font') {
68
- allowedTypes += `\n\n${translate('fileTypes.fontNaming')}`;
72
+ allowedTypes += "\n\n".concat(translate('fileTypes.fontNaming'));
69
73
  }
70
74
  return allowedTypes;
71
75
  }
72
- export const MIME_TYPES = {
76
+ export var MIME_TYPES = {
73
77
  // Images
74
78
  'image/jpeg': '.jpg',
75
79
  'image/jpg': '.jpg',
@@ -112,9 +116,10 @@ export function getMimeTypeExtension(mimeType) {
112
116
  * uploads declare image/heic.
113
117
  */
114
118
  export function normalizeFileMimeType(file) {
119
+ var _a;
115
120
  if (file.type)
116
121
  return file;
117
- const extension = '.' + file.name.split('.').pop()?.toLowerCase();
122
+ var extension = '.' + ((_a = file.name.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase());
118
123
  if (extension === '.heic' || extension === '.heif') {
119
124
  return new File([file], file.name, { type: 'image/heic', lastModified: file.lastModified });
120
125
  }
@@ -1,3 +1,39 @@
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
+ };
1
37
  import { FILE_TYPES } from './fileTypes';
2
38
  import { isKnownNonImageFile } from './fileKinds';
3
39
  import { translateEnglish } from '../i18n/context';
@@ -16,10 +52,10 @@ import icUnorganizedFolder from '../static/icons/unorganized-folder.svg?url';
16
52
  * Pattern to match if a path is already an absolute URL
17
53
  * This will match http://, https://, data:, etc.
18
54
  */
19
- const absoluteUrlPattern = /^(?:[a-z+]+:)?\/\//i;
55
+ var absoluteUrlPattern = /^(?:[a-z+]+:)?\/\//i;
20
56
  // Show logs for debugging
21
- let showLogs = false;
22
- const bundledIconUrls = {
57
+ var showLogs = false;
58
+ var bundledIconUrls = {
23
59
  '/icons/audio.svg': icAudio,
24
60
  '/icons/checked.svg': icChecked,
25
61
  '/icons/document.svg': icDocument,
@@ -33,29 +69,33 @@ const bundledIconUrls = {
33
69
  '/icons/unorganized-folder.svg': icUnorganizedFolder,
34
70
  };
35
71
  /** The message for each unit of size, from bytes to terabytes. */
36
- const SIZE_MESSAGES = ['size.bytes', 'size.kb', 'size.mb', 'size.gb', 'size.tb'];
72
+ var SIZE_MESSAGES = ['size.bytes', 'size.kb', 'size.mb', 'size.gb', 'size.tb'];
37
73
  /** A number of a size, written the way `locale` writes numbers, with up to `fractionDigits` decimals and no thousands separator ("1.5", "1,5"). */
38
74
  function formatSizeNumber(value, locale, minimumFractionDigits, maximumFractionDigits) {
39
- return new Intl.NumberFormat(locale, { minimumFractionDigits, maximumFractionDigits, useGrouping: false }).format(value);
75
+ return new Intl.NumberFormat(locale, { minimumFractionDigits: minimumFractionDigits, maximumFractionDigits: maximumFractionDigits, useGrouping: false }).format(value);
40
76
  }
41
77
  /**
42
78
  * A size in bytes as the biggest unit that keeps it above 1: "0 Bytes", "1.5 MB". The units and the number format
43
79
  * follow the language: pass the `t` and the `locale` of the File Browser (English when left out).
44
80
  */
45
- export function formatFileSize(bytes, translate = translateEnglish, locale = 'en') {
81
+ export function formatFileSize(bytes, translate, locale) {
82
+ if (translate === void 0) { translate = translateEnglish; }
83
+ if (locale === void 0) { locale = 'en'; }
46
84
  if (bytes === 0)
47
85
  return translate('size.bytes', { size: formatSizeNumber(0, locale, 0, 2) });
48
- const k = 1024;
49
- const unitIndex = Math.min(SIZE_MESSAGES.length - 1, Math.max(0, Math.floor(Math.log(bytes) / Math.log(k))));
86
+ var k = 1024;
87
+ var unitIndex = Math.min(SIZE_MESSAGES.length - 1, Math.max(0, Math.floor(Math.log(bytes) / Math.log(k))));
50
88
  return translate(SIZE_MESSAGES[unitIndex], { size: formatSizeNumber(bytes / Math.pow(k, unitIndex), locale, 0, 2) });
51
89
  }
52
90
  /** A size in bytes as kilobytes with one decimal ("12.3 KB"), the way the upload list shows it. */
53
- export function formatKilobytes(bytes, translate = translateEnglish, locale = 'en') {
91
+ export function formatKilobytes(bytes, translate, locale) {
92
+ if (translate === void 0) { translate = translateEnglish; }
93
+ if (locale === void 0) { locale = 'en'; }
54
94
  return translate('size.kb', { size: formatSizeNumber(bytes / 1024, locale, 1, 1) });
55
95
  }
56
96
  export function getFileIcon(fileName) {
57
- const fileType = getFileType(fileName);
58
- const extension = getFileExtension(fileName).toLowerCase();
97
+ var fileType = getFileType(fileName);
98
+ var extension = getFileExtension(fileName).toLowerCase();
59
99
  switch (fileType) {
60
100
  case 'audio':
61
101
  return getAssetUrl('/icons/audio.svg');
@@ -75,14 +115,16 @@ export function getFileIcon(fileName) {
75
115
  }
76
116
  }
77
117
  export function getFileExtension(fileNameOrUrl) {
78
- const cleanPath = fileNameOrUrl.split(/[?#]/)[0];
79
- const fileName = cleanPath.split('/').pop() || '';
80
- const extension = fileName.split('.').pop()?.toLowerCase() || '';
81
- return extension ? `.${extension}` : '';
118
+ var _a;
119
+ var cleanPath = fileNameOrUrl.split(/[?#]/)[0];
120
+ var fileName = cleanPath.split('/').pop() || '';
121
+ var extension = ((_a = fileName.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
122
+ return extension ? ".".concat(extension) : '';
82
123
  }
83
124
  export function getFileType(fileNameOrUrl) {
84
- const extension = getFileExtension(fileNameOrUrl);
85
- for (const [type, extensions] of Object.entries(FILE_TYPES)) {
125
+ var extension = getFileExtension(fileNameOrUrl);
126
+ for (var _i = 0, _a = Object.entries(FILE_TYPES); _i < _a.length; _i++) {
127
+ var _b = _a[_i], type = _b[0], extensions = _b[1];
86
128
  if (extensions.includes(extension.toLowerCase())) {
87
129
  return type;
88
130
  }
@@ -91,14 +133,14 @@ export function getFileType(fileNameOrUrl) {
91
133
  }
92
134
  /** Prefer mime / thumbnail URL when the filename has no real image extension (e.g. IMG_8658). */
93
135
  export function getItemFileType(item) {
94
- const mime = (item.mimeType || '').toLowerCase();
136
+ var mime = (item.mimeType || '').toLowerCase();
95
137
  if (mime.startsWith('image/'))
96
138
  return 'image';
97
139
  if (mime.startsWith('video/'))
98
140
  return 'video';
99
141
  if (mime.startsWith('audio/'))
100
142
  return 'audio';
101
- const fromName = getFileType(item.name || '');
143
+ var fromName = getFileType(item.name || '');
102
144
  if (fromName !== 'document')
103
145
  return fromName;
104
146
  // A PDF, a text file or any other named non-picture stays that kind. A thumbnail
@@ -109,22 +151,34 @@ export function getItemFileType(item) {
109
151
  }
110
152
  if (/IMG_\d+/i.test(item.name || ''))
111
153
  return 'image';
112
- const urlHint = item.thumbnail || item.url || '';
154
+ var urlHint = item.thumbnail || item.url || '';
113
155
  if (urlHint && (/^data:image\//i.test(urlHint) || /\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i.test(urlHint.split(/[?#]/)[0]))) {
114
156
  return 'image';
115
157
  }
116
158
  return getFileType(item.url || item.name || '');
117
159
  }
118
- export async function checkFileExists(url) {
119
- if (!url)
120
- return false;
121
- try {
122
- const response = await fetch(url, { method: 'HEAD' });
123
- return response.ok;
124
- }
125
- catch (error) {
126
- return false;
127
- }
160
+ export function checkFileExists(url) {
161
+ return __awaiter(this, void 0, Promise, function () {
162
+ var response, error_1;
163
+ return __generator(this, function (_a) {
164
+ switch (_a.label) {
165
+ case 0:
166
+ if (!url)
167
+ return [2 /*return*/, false];
168
+ _a.label = 1;
169
+ case 1:
170
+ _a.trys.push([1, 3, , 4]);
171
+ return [4 /*yield*/, fetch(url, { method: 'HEAD' })];
172
+ case 2:
173
+ response = _a.sent();
174
+ return [2 /*return*/, response.ok];
175
+ case 3:
176
+ error_1 = _a.sent();
177
+ return [2 /*return*/, false];
178
+ case 4: return [2 /*return*/];
179
+ }
180
+ });
181
+ });
128
182
  }
129
183
  /**
130
184
  * Gets the correct URL for a static asset using SvelteKit's assets path
@@ -141,7 +195,7 @@ export function getAssetUrl(path) {
141
195
  if (absoluteUrlPattern.test(path) || /^(?:data|blob):/i.test(path))
142
196
  return path;
143
197
  // Ensure path starts with a slash
144
- let normalizedPath = path.startsWith('/') ? path : `/${path}`;
198
+ var normalizedPath = path.startsWith('/') ? path : "/".concat(path);
145
199
  if (bundledIconUrls[normalizedPath]) {
146
200
  return bundledIconUrls[normalizedPath];
147
201
  }
@@ -1,10 +1,11 @@
1
1
  import { getAssetUrl } from './fileUtils';
2
2
  import { getFileTypeOf } from './fileKinds';
3
- const UNORGANIZED_THRESHOLD = 50;
3
+ var UNORGANIZED_THRESHOLD = 50;
4
4
  export function countFilteredItems(folder, filter) {
5
- let count = 0;
5
+ var count = 0;
6
6
  if (folder.type === 'folder' && folder.children) {
7
- for (const item of folder.children) {
7
+ for (var _i = 0, _a = folder.children; _i < _a.length; _i++) {
8
+ var item = _a[_i];
8
9
  if (item.type === 'folder') {
9
10
  count += countFilteredItems(item, filter);
10
11
  }
@@ -16,7 +17,7 @@ export function countFilteredItems(folder, filter) {
16
17
  return count;
17
18
  }
18
19
  export function getFolderIcon(folder, filter) {
19
- const fileCount = folder.matchingFileCount || countFilteredItems(folder, filter);
20
+ var fileCount = folder.matchingFileCount || countFilteredItems(folder, filter);
20
21
  if (fileCount === 0) {
21
22
  return getAssetUrl('/icons/empty-folder.svg');
22
23
  }
@@ -2,17 +2,17 @@
2
2
  * Grid column count from the file browser panel width (Figma File Tile ~264px, 16px gap).
3
3
  * At 1152px panel width → 4 columns; scales up to 6 on very wide panels.
4
4
  */
5
- export const GRID_TILE_MIN_WIDTH_PX = 264;
6
- export const GRID_GAP_PX = 16;
7
- export const GRID_MAX_COLUMNS = 6;
5
+ export var GRID_TILE_MIN_WIDTH_PX = 264;
6
+ export var GRID_GAP_PX = 16;
7
+ export var GRID_MAX_COLUMNS = 6;
8
8
  /** Same rhythm for the recent-files strip (Figma 24px gap, ~3 cards at 1152px). */
9
- export const RECENT_TILE_MIN_WIDTH_PX = 352;
10
- export const RECENT_GAP_PX = 24;
11
- export const RECENT_MAX_COLUMNS = 5;
9
+ export var RECENT_TILE_MIN_WIDTH_PX = 352;
10
+ export var RECENT_GAP_PX = 24;
11
+ export var RECENT_MAX_COLUMNS = 5;
12
12
  function columnsForWidth(width, minTile, gap, maxColumns) {
13
13
  if (width < 420)
14
14
  return 1;
15
- const columns = Math.floor((width + gap) / (minTile + gap));
15
+ var columns = Math.floor((width + gap) / (minTile + gap));
16
16
  return Math.min(maxColumns, Math.max(1, columns));
17
17
  }
18
18
  /** Main folder/file grid. */
@@ -1,15 +1,26 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  /** Natural pixel size of a picture the preview has already decoded, keyed by its fetch URL. */
2
- const MAX_CACHED_URLS = 64;
3
- const naturalSizeByUrl = new Map();
13
+ var MAX_CACHED_URLS = 64;
14
+ var naturalSizeByUrl = new Map();
4
15
  export function rememberImageNaturalSize(url, width, height) {
5
16
  if (!url || !width || !height)
6
17
  return;
7
18
  if (naturalSizeByUrl.has(url)) {
8
19
  naturalSizeByUrl.delete(url);
9
20
  }
10
- naturalSizeByUrl.set(url, { width, height });
21
+ naturalSizeByUrl.set(url, { width: width, height: height });
11
22
  while (naturalSizeByUrl.size > MAX_CACHED_URLS) {
12
- const oldest = naturalSizeByUrl.keys().next().value;
23
+ var oldest = naturalSizeByUrl.keys().next().value;
13
24
  if (oldest)
14
25
  naturalSizeByUrl.delete(oldest);
15
26
  }
@@ -17,20 +28,20 @@ export function rememberImageNaturalSize(url, width, height) {
17
28
  export function getCachedImageNaturalSize(url) {
18
29
  if (!url)
19
30
  return undefined;
20
- const hit = naturalSizeByUrl.get(url);
21
- return hit ? { ...hit } : undefined;
31
+ var hit = naturalSizeByUrl.get(url);
32
+ return hit ? __assign({}, hit) : undefined;
22
33
  }
23
34
  /**
24
35
  * The natural size of a picture the browser already holds decoded (shown before, in a tile or in this preview), found at once.
25
36
  * A picture that is not in the browser's memory is not waited for: it starts loading and this returns nothing.
26
37
  */
27
38
  export function probeDecodedImage(url) {
28
- const known = getCachedImageNaturalSize(url);
39
+ var known = getCachedImageNaturalSize(url);
29
40
  if (known)
30
41
  return known;
31
42
  if (!url || typeof Image === 'undefined')
32
43
  return undefined;
33
- const probe = new Image();
44
+ var probe = new Image();
34
45
  probe.src = url;
35
46
  if (probe.complete && probe.naturalWidth > 0 && probe.naturalHeight > 0) {
36
47
  rememberImageNaturalSize(url, probe.naturalWidth, probe.naturalHeight);
@@ -38,27 +49,27 @@ export function probeDecodedImage(url) {
38
49
  }
39
50
  return undefined;
40
51
  }
41
- const inFlightByUrl = new Map();
52
+ var inFlightByUrl = new Map();
42
53
  /** Warm the decoder cache; resolves when decode finishes or the request fails. */
43
54
  export function preloadImageUrl(url) {
44
55
  if (!url)
45
56
  return Promise.resolve();
46
- const cached = naturalSizeByUrl.get(url);
57
+ var cached = naturalSizeByUrl.get(url);
47
58
  if (cached)
48
59
  return Promise.resolve();
49
- const pending = inFlightByUrl.get(url);
60
+ var pending = inFlightByUrl.get(url);
50
61
  if (pending)
51
62
  return pending;
52
- const job = new Promise((resolve) => {
53
- const img = new Image();
54
- img.onload = () => {
63
+ var job = new Promise(function (resolve) {
64
+ var img = new Image();
65
+ img.onload = function () {
55
66
  if (img.naturalWidth && img.naturalHeight) {
56
67
  rememberImageNaturalSize(url, img.naturalWidth, img.naturalHeight);
57
68
  }
58
69
  inFlightByUrl.delete(url);
59
70
  resolve();
60
71
  };
61
- img.onerror = () => {
72
+ img.onerror = function () {
62
73
  inFlightByUrl.delete(url);
63
74
  resolve();
64
75
  };
@@ -1,4 +1,4 @@
1
- const DEFAULTS = {
1
+ var DEFAULTS = {
2
2
  sideMargin: 24,
3
3
  dialogHorizontalPad: 50,
4
4
  headerBlock: 52,
@@ -12,18 +12,18 @@ const DEFAULTS = {
12
12
  * Pictures are not upscaled beyond their natural size.
13
13
  */
14
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));
15
+ var hostWidth = insets.hostWidth, hostHeight = insets.hostHeight, _a = insets.sideMargin, sideMargin = _a === void 0 ? DEFAULTS.sideMargin : _a, _b = insets.dialogHorizontalPad, dialogHorizontalPad = _b === void 0 ? DEFAULTS.dialogHorizontalPad : _b, _c = insets.headerBlock, headerBlock = _c === void 0 ? DEFAULTS.headerBlock : _c, _d = insets.verticalPad, verticalPad = _d === void 0 ? DEFAULTS.verticalPad : _d, _e = insets.contentVerticalGutter, contentVerticalGutter = _e === void 0 ? DEFAULTS.contentVerticalGutter : _e, _f = insets.minDialogWidth, minDialogWidth = _f === void 0 ? DEFAULTS.minDialogWidth : _f, _g = insets.maxHostFraction, maxHostFraction = _g === void 0 ? DEFAULTS.maxHostFraction : _g;
16
+ var totalVerticalSpace = verticalPad + headerBlock;
17
+ var maxPictureWidth = Math.max(100, hostWidth * maxHostFraction - 2 * sideMargin - dialogHorizontalPad);
18
+ var maxPictureHeight = Math.max(100, hostHeight * maxHostFraction - totalVerticalSpace - contentVerticalGutter);
19
+ var scale = Math.min(1, maxPictureWidth / naturalWidth, maxPictureHeight / naturalHeight);
20
+ var pictureWidth = Math.max(68, Math.round(naturalWidth * scale));
21
+ var pictureHeight = Math.max(68, Math.round(naturalHeight * scale));
22
+ var cardWidth = Math.min(Math.max(minDialogWidth, pictureWidth + dialogHorizontalPad), Math.max(pictureWidth + dialogHorizontalPad, hostWidth * maxHostFraction - 2 * sideMargin));
23
23
  return {
24
- width: `${cardWidth}px`,
25
- height: `${pictureHeight + totalVerticalSpace}px`,
26
- pictureWidth,
27
- pictureHeight
24
+ width: "".concat(cardWidth, "px"),
25
+ height: "".concat(pictureHeight + totalVerticalSpace, "px"),
26
+ pictureWidth: pictureWidth,
27
+ pictureHeight: pictureHeight
28
28
  };
29
29
  }
@@ -9,14 +9,15 @@
9
9
  * picture fades in (a picture that arrives long after the card was sized shows at once).
10
10
  */
11
11
  /** How long a picture may take before the spinner shows ("more than a few seconds" in the request, round 26). */
12
- export const IMAGE_SLOW_LOADER_DELAY_MS = 2000;
12
+ export var IMAGE_SLOW_LOADER_DELAY_MS = 2000;
13
13
  /** The card eases to the size of its picture for this long, the picture waits for the end of that move. */
14
- export const IMAGE_FRAME_EASE_MS = 220;
14
+ export var IMAGE_FRAME_EASE_MS = 220;
15
15
  /**
16
16
  * How much longer the picture has to wait, once it has loaded, so that it appears after the card's move.
17
17
  * 0 when the card reached its size long ago; never more than the move itself (a clock that went backwards).
18
18
  */
19
- export function imageRevealDelayMs(frameSizedAtMs, nowMs, easeMs = IMAGE_FRAME_EASE_MS) {
20
- const elapsedMs = nowMs - frameSizedAtMs;
19
+ export function imageRevealDelayMs(frameSizedAtMs, nowMs, easeMs) {
20
+ if (easeMs === void 0) { easeMs = IMAGE_FRAME_EASE_MS; }
21
+ var elapsedMs = nowMs - frameSizedAtMs;
21
22
  return Math.min(easeMs, Math.max(0, easeMs - elapsedMs));
22
23
  }
@@ -4,25 +4,36 @@
4
4
  * right-sized variant instead of the full-size original. Non-CDN URLs
5
5
  * (localhost, blob:, external providers) pass through untouched.
6
6
  */
7
+ var __assign = (this && this.__assign) || function () {
8
+ __assign = Object.assign || function(t) {
9
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
10
+ s = arguments[i];
11
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
12
+ t[p] = s[p];
13
+ }
14
+ return t;
15
+ };
16
+ return __assign.apply(this, arguments);
17
+ };
18
+ var _a;
7
19
  /** Hosts allowed for transformation — keeps unique-transformation billing bounded. */
8
- const TRANSFORM_HOSTS = (import.meta.env.PUBLIC_IMAGE_TRANSFORM_HOSTS ??
9
- 'static.widgetic.com,cdn.widgetic.com')
20
+ var TRANSFORM_HOSTS = ((_a = import.meta.env.PUBLIC_IMAGE_TRANSFORM_HOSTS) !== null && _a !== void 0 ? _a : 'static.widgetic.com,cdn.widgetic.com')
10
21
  .split(',')
11
- .map((host) => host.trim().toLowerCase())
22
+ .map(function (host) { return host.trim().toLowerCase(); })
12
23
  .filter(Boolean);
13
- const ENABLED = import.meta.env.PUBLIC_IMAGE_TRANSFORMS !== 'false';
24
+ var ENABLED = import.meta.env.PUBLIC_IMAGE_TRANSFORMS !== 'false';
14
25
  function isTransformable(url) {
15
26
  if (!ENABLED || !url)
16
27
  return false;
17
28
  if (url.startsWith('blob:') || url.startsWith('data:'))
18
29
  return false;
19
30
  try {
20
- const parsed = new URL(url);
31
+ var parsed = new URL(url);
21
32
  if (parsed.protocol !== 'https:')
22
33
  return false;
23
34
  return TRANSFORM_HOSTS.includes(parsed.hostname.toLowerCase());
24
35
  }
25
- catch {
36
+ catch (_a) {
26
37
  return false;
27
38
  }
28
39
  }
@@ -31,30 +42,32 @@ function isTransformable(url) {
31
42
  * URL when transformation is disabled or the host is not allowlisted.
32
43
  */
33
44
  export function buildTransformedUrl(url, options) {
34
- const source = url ?? '';
45
+ var _a;
46
+ var source = url !== null && url !== void 0 ? url : '';
35
47
  if (!isTransformable(source))
36
48
  return source;
37
- const params = new URLSearchParams();
49
+ var params = new URLSearchParams();
38
50
  params.set('width', String(options.width));
39
51
  if (options.height)
40
52
  params.set('height', String(options.height));
41
53
  if (options.fit)
42
54
  params.set('fit', options.fit);
43
- params.set('q', String(options.quality ?? 75));
55
+ params.set('q', String((_a = options.quality) !== null && _a !== void 0 ? _a : 75));
44
56
  // format=auto lets Cloudflare negotiate AVIF/WebP from the Accept header.
45
57
  params.set('format', 'auto');
46
- const parsed = new URL(source);
47
- return `${parsed.origin}/cdn-cgi/image?${params.toString()}/${encodeURIComponent(source)}`;
58
+ var parsed = new URL(source);
59
+ return "".concat(parsed.origin, "/cdn-cgi/image?").concat(params.toString(), "/").concat(encodeURIComponent(source));
48
60
  }
49
61
  /**
50
62
  * Builds a srcset across a fixed width ladder. Widths should come from a small
51
63
  * allowlist — every unique width is billed as a separate transformation.
52
64
  */
53
- export function buildImageSrcset(url, widths, options = {}) {
54
- const source = url ?? '';
65
+ export function buildImageSrcset(url, widths, options) {
66
+ if (options === void 0) { options = {}; }
67
+ var source = url !== null && url !== void 0 ? url : '';
55
68
  if (!isTransformable(source))
56
69
  return undefined;
57
70
  return widths
58
- .map((width) => `${buildTransformedUrl(source, { ...options, width })} ${width}w`)
71
+ .map(function (width) { return "".concat(buildTransformedUrl(source, __assign(__assign({}, options), { width: width })), " ").concat(width, "w"); })
59
72
  .join(', ');
60
73
  }
@@ -3,11 +3,11 @@
3
3
  * The legacy Uploads folder (`folder_my_uploads`) is treated like any other folder — nothing here is reserved.
4
4
  */
5
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 };
6
+ var capabilities = input.capabilities, isFolder = input.isFolder, isMissing = input.isMissing, fileUrl = input.fileUrl;
7
+ var canRename = capabilities.rename && !isMissing;
8
+ var canMove = capabilities.folders && !isMissing;
9
+ var canDownload = capabilities.download && !isMissing && !isFolder && Boolean(fileUrl);
10
+ var canDelete = capabilities.delete;
11
+ var hasAnyAction = canRename || canMove || canDownload || canDelete;
12
+ return { canRename: canRename, canMove: canMove, canDownload: canDownload, canDelete: canDelete, hasAnyAction: hasAnyAction };
13
13
  }