@emailmaker/filemanager 0.10.45 → 0.10.47
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/components/FileContent/FileContent.d.ts +1 -0
- package/components/FileManagerApp/ActionsHeader.d.ts +6 -0
- package/components/FileModals/FileModals.d.ts +4 -1
- package/components/ImageIcons/IconsControls.d.ts +26 -0
- package/components/ImageIcons/IconsGrid.d.ts +26 -0
- package/components/ImageIcons/IconsSearchForm.d.ts +13 -0
- package/components/ImageIcons/IconsTab.d.ts +4 -0
- package/components/ImageIcons/useIconsCopyToFolder.d.ts +28 -0
- package/components/ImageIcons/useStreamlineApi.d.ts +47 -0
- package/components/index.d.ts +1 -0
- package/constants/index.d.ts +2 -0
- package/file-manager.css +475 -21
- package/file-manager.d.ts +2 -0
- package/file-manager.esm.js +9 -9
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/file-manager.js.LICENSE.txt +2 -0
- package/hooks/core/files/actions/useFilesCopy.d.ts +1 -0
- package/hooks/core/files/useFilesAPI.d.ts +1 -0
- package/hooks/core/files/useFilesSelection.d.ts +1 -0
- package/hooks/core/types.d.ts +6 -1
- package/hooks/core/useFiles.d.ts +1 -0
- package/hooks/useCustomIcons.d.ts +1 -0
- package/hooks/useFileActions.d.ts +6 -1
- package/hooks/useFolderSelectionMenu.d.ts +26 -0
- package/notification.d.ts +16 -8
- package/package.json +1 -1
- package/shared/config.d.ts +1 -0
- package/types.d.ts +82 -7
- package/utils/cacheClear.d.ts +8 -0
- package/utils/errorMessages.d.ts +22 -2
- package/utils/fileFormatUtils.d.ts +39 -0
- package/utils/fileValidation.d.ts +22 -0
- package/utils/imageCompression.d.ts +1 -0
- package/utils/jsonDataProvider.d.ts +8 -0
- package/utils/mimeUtils.d.ts +12 -0
- package/utils/nameNormalization.d.ts +23 -0
- package/utils/svgToPng.d.ts +11 -0
|
@@ -143,6 +143,8 @@ and limitations under the License.
|
|
|
143
143
|
|
|
144
144
|
/** */
|
|
145
145
|
|
|
146
|
+
/** */
|
|
147
|
+
|
|
146
148
|
/** */
|
|
147
149
|
|
|
148
150
|
/** */
|
package/hooks/core/types.d.ts
CHANGED
|
@@ -78,7 +78,12 @@ export interface FileManagerActions {
|
|
|
78
78
|
generateMenuItems: () => MenuItem[];
|
|
79
79
|
fetchFiles: (params?: FilesQueryParams) => Promise<void>;
|
|
80
80
|
handleDeleteFile: (fileId: string) => Promise<void>;
|
|
81
|
-
toggleFileSelection: (fileId: string
|
|
81
|
+
toggleFileSelection: (fileId: string, opts?: {
|
|
82
|
+
metaKey?: boolean;
|
|
83
|
+
ctrlKey?: boolean;
|
|
84
|
+
shiftKey?: boolean;
|
|
85
|
+
forceToggle?: boolean;
|
|
86
|
+
}) => void;
|
|
82
87
|
handleItemClick: (record: File) => void;
|
|
83
88
|
handleAddFile: () => Promise<void>;
|
|
84
89
|
handleDroppedFiles: (droppedFiles: globalThis.File[]) => Promise<void>;
|
package/hooks/core/useFiles.d.ts
CHANGED
|
@@ -29,5 +29,6 @@ export declare const useCustomIcons: () => {
|
|
|
29
29
|
DarkModeIcon: (props?: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
30
30
|
AiIcon_2: (props?: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
31
31
|
NoFilesIcon: (props?: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
32
|
+
ThumbsUpIcon: (props?: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
32
33
|
getCustomIcon: (iconName: keyof NonNullable<import("../types").CustomIcons | undefined>, defaultIcon: React.ComponentType<any>, props?: IconProps) => React.ReactElement;
|
|
33
34
|
};
|
|
@@ -3,7 +3,12 @@ interface UseFileActionsProps {
|
|
|
3
3
|
files: AppFile[];
|
|
4
4
|
selectedFiles: Set<string>;
|
|
5
5
|
currentMenuFile: string;
|
|
6
|
-
toggleFileSelection: (fileId: string
|
|
6
|
+
toggleFileSelection: (fileId: string, opts?: {
|
|
7
|
+
metaKey?: boolean;
|
|
8
|
+
ctrlKey?: boolean;
|
|
9
|
+
shiftKey?: boolean;
|
|
10
|
+
forceToggle?: boolean;
|
|
11
|
+
}) => void;
|
|
7
12
|
showRenameModal: (fileId: string) => void;
|
|
8
13
|
showMoveModal: () => void;
|
|
9
14
|
showCopyModal: () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FormInstance } from 'antd/es/form';
|
|
3
|
+
import type { Folder, MenuItem } from '../types';
|
|
4
|
+
interface UseFolderSelectionMenuParams {
|
|
5
|
+
folders: Folder[];
|
|
6
|
+
selectedFolder: string | null;
|
|
7
|
+
EmptyFolderIcon: React.ComponentType<{
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
}>;
|
|
10
|
+
handleCreateFolderModalOk: (currentForm?: FormInstance) => Promise<Folder | {
|
|
11
|
+
id?: string;
|
|
12
|
+
} | undefined>;
|
|
13
|
+
setIsLoading: (value: boolean) => void;
|
|
14
|
+
t: (key: string) => string;
|
|
15
|
+
}
|
|
16
|
+
export declare function useFolderSelectionMenu({ folders, selectedFolder, EmptyFolderIcon, handleCreateFolderModalOk, setIsLoading, t, }: UseFolderSelectionMenuParams): {
|
|
17
|
+
activeFormField: string;
|
|
18
|
+
setActiveFormField: React.Dispatch<React.SetStateAction<string>>;
|
|
19
|
+
generateMenuItemsFromFolders: (params: {
|
|
20
|
+
targetForm: FormInstance;
|
|
21
|
+
onTreeSelect: (selectedKeys: React.Key[]) => Promise<void>;
|
|
22
|
+
onComplete: (targetFolder?: string) => void;
|
|
23
|
+
actionButtonText: string;
|
|
24
|
+
}) => MenuItem[];
|
|
25
|
+
};
|
|
26
|
+
export {};
|
package/notification.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
interface FileManageErrorInfo {
|
|
2
|
-
message?: string;
|
|
2
|
+
message?: string;
|
|
3
3
|
code?: FileManagerErrorCode;
|
|
4
4
|
status?: number;
|
|
5
|
-
raw?: any;
|
|
5
|
+
raw?: any;
|
|
6
6
|
stack?: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
/**
|
|
11
10
|
* Error codes for FileManager API operations.
|
|
12
11
|
*/
|
|
@@ -211,7 +210,7 @@ declare namespace Notify {
|
|
|
211
210
|
/**
|
|
212
211
|
* Details of a single item in batch operation results.
|
|
213
212
|
* Used in the `detailed` array for batch operations (deleteItems, moveItems, copyItems, uploadFiles).
|
|
214
|
-
*
|
|
213
|
+
*
|
|
215
214
|
* @template T - Type of successful operation result data
|
|
216
215
|
*/
|
|
217
216
|
export interface BatchOperationDetail<T = unknown> {
|
|
@@ -230,7 +229,7 @@ declare namespace Notify {
|
|
|
230
229
|
/**
|
|
231
230
|
* Result of a batch operation with support for detailed results.
|
|
232
231
|
* Unified type for all batch operations in the file manager.
|
|
233
|
-
*
|
|
232
|
+
*
|
|
234
233
|
* @template T - Type of successful operation result data
|
|
235
234
|
*/
|
|
236
235
|
export interface BatchOperationResult<T = unknown> {
|
|
@@ -376,7 +375,7 @@ declare namespace Notify {
|
|
|
376
375
|
/**
|
|
377
376
|
* Base type for error notification events.
|
|
378
377
|
* Includes innerException field for error details.
|
|
379
|
-
*
|
|
378
|
+
*
|
|
380
379
|
* @template TId - Notification event ID type
|
|
381
380
|
* @template TData - Payload data type
|
|
382
381
|
*/
|
|
@@ -403,7 +402,7 @@ declare namespace Notify {
|
|
|
403
402
|
/**
|
|
404
403
|
* Base type for success, warning, and info notification events.
|
|
405
404
|
* Does not include innerException field.
|
|
406
|
-
*
|
|
405
|
+
*
|
|
407
406
|
* @template TId - Notification event ID type
|
|
408
407
|
* @template TData - Payload data type
|
|
409
408
|
*/
|
|
@@ -475,7 +474,6 @@ declare namespace Notify {
|
|
|
475
474
|
* Extends ItemErrorMap for single item operations and BatchErrorMap for batch operations.
|
|
476
475
|
*/
|
|
477
476
|
export interface ErrorMap extends ItemErrorMap, BatchErrorMap {
|
|
478
|
-
|
|
479
477
|
FILE_DOWNLOAD_FAILED: ImageFilePayload;
|
|
480
478
|
IMAGE_DOWNLOAD_FAILED: ImageFilePayload;
|
|
481
479
|
IMAGE_SAVE_FAILED: ImageFilePayload;
|
|
@@ -509,11 +507,17 @@ declare namespace Notify {
|
|
|
509
507
|
FILES_COPY_DIRECTORY_NOT_SELECTED: never;
|
|
510
508
|
|
|
511
509
|
FOLDERS_FETCH_FAILED: FolderOperationPayload;
|
|
510
|
+
FOLDER_ALREADY_EXISTS: FolderOperationPayload;
|
|
511
|
+
FOLDER_ALREADY_EXISTS_COPY: FolderOperationPayload & { targetFolderId?: string };
|
|
512
|
+
FOLDER_ALREADY_EXISTS_MOVE: FolderOperationPayload & { targetFolderId?: string };
|
|
512
513
|
FOLDER_CREATE_PROVIDER_NOT_CONFIGURED: FolderOperationPayload;
|
|
513
514
|
FOLDER_CREATE_FAILED: FolderOperationPayload;
|
|
514
515
|
FOLDER_CHILDREN_COUNT_FAILED: FolderOperationPayload;
|
|
515
516
|
FOLDER_CHILDREN_FETCH_FAILED: FolderOperationPayload;
|
|
516
517
|
FILE_URL_VALIDATION_FAILED: FileUrlValidationErrorPayload;
|
|
518
|
+
|
|
519
|
+
TRASH_CLEAR_FAILED: OperationErrorPayload;
|
|
520
|
+
TRASH_CLEAR_ERROR: never;
|
|
517
521
|
}
|
|
518
522
|
|
|
519
523
|
/**
|
|
@@ -544,6 +548,8 @@ declare namespace Notify {
|
|
|
544
548
|
FOLDER_CREATE_SUCCESS: FolderOperationPayload;
|
|
545
549
|
|
|
546
550
|
FILE_UPLOAD_ITEM_SUCCESS: FileUploadPayload;
|
|
551
|
+
|
|
552
|
+
TRASH_CLEARED_SUCCESS: never;
|
|
547
553
|
}
|
|
548
554
|
|
|
549
555
|
/**
|
|
@@ -564,6 +570,8 @@ declare namespace Notify {
|
|
|
564
570
|
export interface WarningMap {
|
|
565
571
|
FILES_UPLOAD_UNSUPPORTED_TYPE: UnsupportedFileTypePayload;
|
|
566
572
|
FOLDER_OPERATION_VALIDATION_FAILED: FolderOperationPayload;
|
|
573
|
+
|
|
574
|
+
TRASH_CLEARED_PARTIAL: OperationErrorPayload;
|
|
567
575
|
}
|
|
568
576
|
|
|
569
577
|
/**
|
package/package.json
CHANGED
package/shared/config.d.ts
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { ReactNode, RefObject } from 'react';
|
|
2
2
|
import { FormInstance } from 'antd/es/form';
|
|
3
|
-
import { MY_FILES, GIF, STOCK_IMAGES, AI, EDITOR, IMAGE_EXTENSIONS } from './constants';
|
|
3
|
+
import { MY_FILES, GIF, STOCK_IMAGES, ICONS, AI, EDITOR, IMAGE_EXTENSIONS } from './constants';
|
|
4
4
|
import type { InputRef } from 'antd';
|
|
5
|
-
import type { FileManageErrorInfo, Notify, NotifyEvent } from 'notification';
|
|
6
|
-
export * from 'notification';
|
|
5
|
+
import type { FileManageErrorInfo, Notify, NotifyEvent } from './notification';
|
|
6
|
+
export * from './notification';
|
|
7
7
|
export interface Folder {
|
|
8
8
|
id: string;
|
|
9
9
|
name: string;
|
|
@@ -83,6 +83,7 @@ export interface ApiEndpoints {
|
|
|
83
83
|
renameFile?: string;
|
|
84
84
|
moveFile?: string;
|
|
85
85
|
updateFile?: string;
|
|
86
|
+
clearCache?: string;
|
|
86
87
|
}
|
|
87
88
|
export interface IconProps {
|
|
88
89
|
style?: React.CSSProperties;
|
|
@@ -111,6 +112,7 @@ export interface CustomIcons {
|
|
|
111
112
|
darkMode?: React.ComponentType<IconProps>;
|
|
112
113
|
aiIcon_2?: React.ComponentType<IconProps>;
|
|
113
114
|
noFiles?: React.ComponentType<IconProps>;
|
|
115
|
+
thumbsUp?: React.ComponentType<IconProps>;
|
|
114
116
|
}
|
|
115
117
|
type MayBePromise<T> = T | Promise<T>;
|
|
116
118
|
export type NotifyListener<T> = (value: T) => MayBePromise<void | false | (NotifyEvent & Notify)>;
|
|
@@ -125,6 +127,7 @@ export interface FileManagerOptions {
|
|
|
125
127
|
renameFile?: string;
|
|
126
128
|
moveFile?: string;
|
|
127
129
|
updateFile?: string;
|
|
130
|
+
clearCache?: string;
|
|
128
131
|
};
|
|
129
132
|
dataProviders?: FileManagerDataProviders;
|
|
130
133
|
searchQuery?: string;
|
|
@@ -135,7 +138,7 @@ export interface FileManagerOptions {
|
|
|
135
138
|
id: string;
|
|
136
139
|
folderId: string | undefined;
|
|
137
140
|
name: string;
|
|
138
|
-
}) => void
|
|
141
|
+
}) => void | Promise<void>;
|
|
139
142
|
config?: Config;
|
|
140
143
|
customIcons?: CustomIcons;
|
|
141
144
|
dragDropIcon?: string;
|
|
@@ -231,6 +234,9 @@ export interface FileManagerDataProviders {
|
|
|
231
234
|
* в остальных случаях — Blob.
|
|
232
235
|
*/
|
|
233
236
|
data: UploadBinary;
|
|
237
|
+
thumbnail?: string;
|
|
238
|
+
dimensions?: string;
|
|
239
|
+
aspectRatio?: string;
|
|
234
240
|
extension?: string;
|
|
235
241
|
}) => Promise<File>;
|
|
236
242
|
uploadFiles?: (request: UploadFilesRequest) => Promise<BatchResult<UploadFileResultData>>;
|
|
@@ -238,18 +244,28 @@ export interface FileManagerDataProviders {
|
|
|
238
244
|
url: string;
|
|
239
245
|
folderId?: string | null;
|
|
240
246
|
noFolder?: boolean;
|
|
247
|
+
name?: string;
|
|
241
248
|
}) => Promise<File>;
|
|
242
249
|
deleteItems?: (items: string[], options?: {
|
|
243
250
|
permanent?: boolean;
|
|
244
251
|
}) => Promise<BatchResult<unknown>>;
|
|
252
|
+
cleanTrash?: () => Promise<{
|
|
253
|
+
success: boolean;
|
|
254
|
+
deletedCount?: number;
|
|
255
|
+
}>;
|
|
245
256
|
renameFile?: (fileId: string, newName: string) => Promise<File>;
|
|
246
257
|
moveItems?: (targetFolderId: string, files: string[]) => Promise<BatchResult<unknown>>;
|
|
247
258
|
copyItem?: (options: {
|
|
248
259
|
itemId: string;
|
|
249
260
|
targetFolderId: string;
|
|
250
261
|
isFolder: boolean;
|
|
262
|
+
/** При конфликте имени в целевой папке — использовать это имя для копии */
|
|
263
|
+
newName?: string;
|
|
251
264
|
}) => Promise<boolean>;
|
|
252
|
-
copyItems?: (targetFolderId: string,
|
|
265
|
+
copyItems?: (targetFolderId: string, items: Array<{
|
|
266
|
+
id: string;
|
|
267
|
+
newName?: string;
|
|
268
|
+
}> | string[]) => Promise<BatchResult<unknown>>;
|
|
253
269
|
updateFile?: (fileId: string, updates: {
|
|
254
270
|
name?: string;
|
|
255
271
|
type?: string;
|
|
@@ -263,6 +279,7 @@ export interface FileManagerDataProviders {
|
|
|
263
279
|
aspectRatio?: string;
|
|
264
280
|
extension?: string;
|
|
265
281
|
}) => Promise<File>;
|
|
282
|
+
clearCache?: (pathFolder?: string | null) => Promise<void>;
|
|
266
283
|
}
|
|
267
284
|
export interface FileManagerHookReturn {
|
|
268
285
|
folders: Folder[];
|
|
@@ -293,7 +310,12 @@ export interface FileManagerHookReturn {
|
|
|
293
310
|
handleDeleteFile: (fileId: string) => Promise<void>;
|
|
294
311
|
handleAddFile: () => void;
|
|
295
312
|
handleFolderSelect: (folderId: string) => void;
|
|
296
|
-
toggleFileSelection: (fileId: string
|
|
313
|
+
toggleFileSelection: (fileId: string, opts?: {
|
|
314
|
+
metaKey?: boolean;
|
|
315
|
+
ctrlKey?: boolean;
|
|
316
|
+
shiftKey?: boolean;
|
|
317
|
+
forceToggle?: boolean;
|
|
318
|
+
}) => void;
|
|
297
319
|
handleBreadcrumbClick: (index: number) => void;
|
|
298
320
|
handleItemClick: (record: File) => void;
|
|
299
321
|
handleAddFileByUrl: (url?: string | null) => Promise<void>;
|
|
@@ -358,6 +380,10 @@ export interface Config {
|
|
|
358
380
|
dataProcessingMode?: 'server' | 'client' | 'auto';
|
|
359
381
|
enableClientSideProcessing?: boolean;
|
|
360
382
|
disablePagination?: boolean;
|
|
383
|
+
/** При false (или при disablePagination) — пагинации нет, фронт проверяет дубликаты имён и добавляет _1 */
|
|
384
|
+
hasPagination?: boolean;
|
|
385
|
+
/** Наличие пагинации. При false — проверка дубликатов имён папок при создании и при copy/move */
|
|
386
|
+
paginationAvailable?: boolean;
|
|
361
387
|
enableTrashFolder?: boolean;
|
|
362
388
|
staticData?: {
|
|
363
389
|
files?: File[];
|
|
@@ -366,6 +392,11 @@ export interface Config {
|
|
|
366
392
|
customTheme?: CustomTheme;
|
|
367
393
|
UNSPLASH_KEY?: string;
|
|
368
394
|
APP_NAME_UNSPLASH?: string;
|
|
395
|
+
/** Переопределение URL прокси Streamline (по умолчанию /streamline). Ключ добавляется на прокси. */
|
|
396
|
+
STREAMLINE_BASE_URL?: string;
|
|
397
|
+
handleTranslate?: (input: string, opts: {
|
|
398
|
+
locale?: string;
|
|
399
|
+
}) => Promise<string>;
|
|
369
400
|
UNSLASH_PROXY_URL?: string;
|
|
370
401
|
pushToGTM?: boolean;
|
|
371
402
|
projectId?: string;
|
|
@@ -398,10 +429,53 @@ export interface Config {
|
|
|
398
429
|
multiSelect?: boolean;
|
|
399
430
|
defaultFolderName?: string;
|
|
400
431
|
availableImageExtensions?: Array<(typeof IMAGE_EXTENSIONS)[number]>;
|
|
432
|
+
/** Настройки обработки имен файлов при загрузке */
|
|
433
|
+
fileNameProcessing?: {
|
|
434
|
+
transliterate?: boolean;
|
|
435
|
+
replaceSpaces?: boolean;
|
|
436
|
+
removeForbiddenChars?: boolean;
|
|
437
|
+
toLowerCase?: boolean;
|
|
438
|
+
};
|
|
439
|
+
/** Настройки обработки имен папок при создании */
|
|
440
|
+
folderNameProcessing?: {
|
|
441
|
+
transliterate?: boolean;
|
|
442
|
+
replaceSpaces?: boolean;
|
|
443
|
+
removeForbiddenChars?: boolean;
|
|
444
|
+
toLowerCase?: boolean;
|
|
445
|
+
};
|
|
401
446
|
/** Разрешаем произвольные дополнительные поля */
|
|
402
447
|
[key: string]: unknown;
|
|
403
448
|
}
|
|
404
|
-
export type LibraryMenuKey = typeof MY_FILES | typeof GIF | typeof STOCK_IMAGES | typeof AI | typeof EDITOR;
|
|
449
|
+
export type LibraryMenuKey = typeof MY_FILES | typeof GIF | typeof STOCK_IMAGES | typeof ICONS | typeof AI | typeof EDITOR;
|
|
450
|
+
export type StreamlineSearchItem = {
|
|
451
|
+
hash: string;
|
|
452
|
+
name: string;
|
|
453
|
+
imagePreviewUrl: string;
|
|
454
|
+
isFree: boolean;
|
|
455
|
+
familySlug: string;
|
|
456
|
+
familyName: string;
|
|
457
|
+
categorySlug?: string;
|
|
458
|
+
categoryName?: string;
|
|
459
|
+
subcategorySlug?: string;
|
|
460
|
+
subcategoryName?: string;
|
|
461
|
+
};
|
|
462
|
+
export type StreamlineSearchResponse = {
|
|
463
|
+
query: string;
|
|
464
|
+
results: StreamlineSearchItem[];
|
|
465
|
+
pagination: {
|
|
466
|
+
total: number;
|
|
467
|
+
hasMore: boolean;
|
|
468
|
+
offset: number;
|
|
469
|
+
nextSkip?: number;
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
export interface IconsTabProps {
|
|
473
|
+
apiKey?: string;
|
|
474
|
+
customRequest: (data: string) => void | Promise<void>;
|
|
475
|
+
query?: string;
|
|
476
|
+
setQuery?: (query: string) => void;
|
|
477
|
+
inputRef?: React.RefObject<InputRef>;
|
|
478
|
+
}
|
|
405
479
|
export interface GifItem {
|
|
406
480
|
id: string;
|
|
407
481
|
title: string;
|
|
@@ -537,6 +611,7 @@ export interface FileManagerProps {
|
|
|
537
611
|
renameFile?: string;
|
|
538
612
|
moveFile?: string;
|
|
539
613
|
updateFile?: string;
|
|
614
|
+
clearCache?: string;
|
|
540
615
|
};
|
|
541
616
|
customIcons?: CustomIcons;
|
|
542
617
|
dragDropIcon?: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FileManagerDataProviders, FileManagerOptions, PathItem } from '../types';
|
|
2
|
+
export declare const resolveCachePathForError: (error: unknown, pathHistory: PathItem[]) => string;
|
|
3
|
+
export declare const getPathFromHistory: (pathHistory: PathItem[]) => string;
|
|
4
|
+
export declare const clearFolderCache: (params: {
|
|
5
|
+
options: FileManagerOptions;
|
|
6
|
+
pathFolder: string;
|
|
7
|
+
dataProviders?: FileManagerDataProviders;
|
|
8
|
+
}) => Promise<void>;
|
package/utils/errorMessages.d.ts
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import type { FileManageErrorInfo, FileManagerErrorCode } from 'notification';
|
|
2
2
|
type TFunction = (key: string, params?: Record<string, unknown>) => string;
|
|
3
|
+
export interface ErrorMessageParams {
|
|
4
|
+
allowedChars?: string;
|
|
5
|
+
fileSize?: string;
|
|
6
|
+
maxSize?: string;
|
|
7
|
+
}
|
|
3
8
|
/**
|
|
4
9
|
* Возвращает локализованное сообщение по коду ошибки, если для него есть i18n-ключ.
|
|
5
|
-
*
|
|
10
|
+
* Поддерживает параметры для шаблонов: allowedChars, fileSize, maxSize.
|
|
6
11
|
*/
|
|
7
|
-
export declare const getErrorMessageFromCode: (code: FileManagerErrorCode | undefined, t: TFunction) => string | undefined;
|
|
12
|
+
export declare const getErrorMessageFromCode: (code: FileManagerErrorCode | undefined, t: TFunction, params?: ErrorMessageParams) => string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Пытается определить более точный код ошибки по тексту сообщения бэкенда.
|
|
15
|
+
* Используется когда бэкенд возвращает ValidationError/BackendError с информативным сообщением.
|
|
16
|
+
*/
|
|
17
|
+
export declare const inferErrorCodeFromMessage: (message: string | undefined) => FileManagerErrorCode | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Определяет код ошибки по тексту сообщения для контекста загрузки по URL.
|
|
20
|
+
* 403/forbidden при загрузке по URL = внешний ресурс недоступен (UploadUrlNotReachable).
|
|
21
|
+
*/
|
|
22
|
+
export declare const inferErrorCodeFromMessageForUrlUpload: (message: string | undefined) => FileManagerErrorCode | undefined;
|
|
8
23
|
/**
|
|
9
24
|
* Пытается извлечь IFileManagerApiError из unknown.
|
|
10
25
|
*/
|
|
11
26
|
export declare const asFileManagerApiError: (error: unknown) => FileManageErrorInfo;
|
|
27
|
+
/**
|
|
28
|
+
* Возвращает сообщение для отображения при ошибке загрузки по URL.
|
|
29
|
+
* Приоритет: код ошибки → понятное сообщение бэкенда → общий fallback.
|
|
30
|
+
*/
|
|
31
|
+
export declare const getUploadByUrlErrorMessage: (apiError: FileManageErrorInfo | undefined, t: TFunction, params?: ErrorMessageParams) => string;
|
|
12
32
|
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type ImageFormat = 'jpeg' | 'png' | 'gif' | 'webp' | 'svg';
|
|
2
|
+
export type PixieFormat = 'jpeg' | 'png' | 'json' | 'svg';
|
|
3
|
+
export interface FileFormatInfo {
|
|
4
|
+
extension: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
format: ImageFormat;
|
|
7
|
+
pixieFormat: PixieFormat;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Определяет формат файла из нескольких источников с правильным приоритетом
|
|
11
|
+
* @param file - Объект файла с возможными полями name, extension, type
|
|
12
|
+
* @param fallbackType - Запасной MIME-тип если не удалось определить из файла
|
|
13
|
+
* @returns Информация о формате файла
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectFileFormat(file: {
|
|
16
|
+
name?: string;
|
|
17
|
+
extension?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
} | null, fallbackType?: string): FileFormatInfo;
|
|
20
|
+
/**
|
|
21
|
+
* Константы для сжатия изображений
|
|
22
|
+
*/
|
|
23
|
+
export declare const IMAGE_COMPRESSION_DEFAULTS: {
|
|
24
|
+
readonly MAX_SIZE_MB: 0.5;
|
|
25
|
+
readonly MAX_WIDTH_OR_HEIGHT: 2000;
|
|
26
|
+
readonly QUALITY: 0.8;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Поддерживаемые форматы изображений
|
|
30
|
+
*/
|
|
31
|
+
export declare const SUPPORTED_IMAGE_FORMATS: readonly ["jpg", "jpeg", "png", "gif", "webp", "svg"];
|
|
32
|
+
/**
|
|
33
|
+
* Форматы, которые не нужно сжимать
|
|
34
|
+
*/
|
|
35
|
+
export declare const NON_COMPRESSIBLE_FORMATS: readonly ["gif", "svg"];
|
|
36
|
+
/**
|
|
37
|
+
* Проверяет, нужно ли сжимать файл данного формата
|
|
38
|
+
*/
|
|
39
|
+
export declare function shouldCompressFormat(format: string): boolean;
|
|
@@ -32,4 +32,26 @@ export declare const validateFileUrl: (url: string) => Promise<FileValidationRes
|
|
|
32
32
|
export declare const getFileCategory: (file: File) => string;
|
|
33
33
|
export declare const formatFileSize: (bytes: number) => string;
|
|
34
34
|
export declare const formatFileSizeShort: (bytes?: number) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Генерирует уникальное имя файла: если name уже есть в existingNames, добавляет _1 (или _2, _3 и т.д.).
|
|
37
|
+
* @param name — исходное имя файла (с расширением)
|
|
38
|
+
* @param existingNames — массив имён файлов/папок в целевой директории
|
|
39
|
+
*/
|
|
40
|
+
export declare const getUniqueFileName: (name: string, existingNames: string[]) => string;
|
|
41
|
+
/**
|
|
42
|
+
* Кодирует URL для безопасного использования в img src. Решает проблему с кириллицей и другими
|
|
43
|
+
* не-ASCII символами в пути (например, emcdn.ru/.../Снимок_экрана.png).
|
|
44
|
+
* data: и blob: URLs возвращаются без изменений.
|
|
45
|
+
*/
|
|
46
|
+
export declare const encodeUrlForImageSrc: (url: string | undefined | null) => string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Эта функция оставлена только для обратной совместимости.
|
|
49
|
+
* Используйте {@link normalizeFileName} из `nameNormalization.ts` для настраиваемой нормализации имен файлов.
|
|
50
|
+
*
|
|
51
|
+
* Упрощенная санитизация имени файла:
|
|
52
|
+
* - Заменяет запрещенные символы на `_`
|
|
53
|
+
* - Заменяет пробелы на `_`
|
|
54
|
+
* - Удаляет множественные подчеркивания
|
|
55
|
+
* - Ограничивает длину до 255 символов
|
|
56
|
+
*/
|
|
35
57
|
export declare const sanitizeFileName: (fileName: string) => string;
|
|
@@ -37,6 +37,9 @@ export declare class JSONDataProvider implements FileManagerDataProviders {
|
|
|
37
37
|
type: string;
|
|
38
38
|
folderId?: string | null;
|
|
39
39
|
data: UploadBinary;
|
|
40
|
+
thumbnail?: string;
|
|
41
|
+
dimensions?: string;
|
|
42
|
+
aspectRatio?: string;
|
|
40
43
|
extension?: string;
|
|
41
44
|
}) => Promise<File>;
|
|
42
45
|
uploadFiles: (request: UploadFilesRequest) => Promise<BatchResult<UploadFileResultData>>;
|
|
@@ -44,6 +47,7 @@ export declare class JSONDataProvider implements FileManagerDataProviders {
|
|
|
44
47
|
url: string;
|
|
45
48
|
folderId?: string | null;
|
|
46
49
|
noFolder?: boolean;
|
|
50
|
+
name?: string;
|
|
47
51
|
}) => Promise<File>;
|
|
48
52
|
updateFile: (fileId: string, updates: {
|
|
49
53
|
name?: string;
|
|
@@ -55,6 +59,10 @@ export declare class JSONDataProvider implements FileManagerDataProviders {
|
|
|
55
59
|
extension?: string;
|
|
56
60
|
}) => Promise<File>;
|
|
57
61
|
deleteFile: (fileId: string) => Promise<boolean>;
|
|
62
|
+
cleanTrash: () => Promise<{
|
|
63
|
+
success: boolean;
|
|
64
|
+
deletedCount?: number;
|
|
65
|
+
}>;
|
|
58
66
|
renameFile: (fileId: string, newName: string) => Promise<File>;
|
|
59
67
|
moveItem: (options: {
|
|
60
68
|
itemId: string;
|
package/utils/mimeUtils.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Нормализует MIME-тип изображения до стандартного формата
|
|
3
|
+
* @param mimeType - MIME-тип для нормализации
|
|
4
|
+
* @returns Нормализованный MIME-тип
|
|
5
|
+
*/
|
|
6
|
+
export declare const normalizeImageMimeType: (mimeType: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Извлекает MIME-тип из data URL
|
|
9
|
+
* @param dataUrl - Data URL строка
|
|
10
|
+
* @returns MIME-тип или null если не найден
|
|
11
|
+
*/
|
|
12
|
+
export declare const extractMimeFromDataUrl: (dataUrl: string) => string | null;
|
|
1
13
|
/**
|
|
2
14
|
* Нормализует MIME тип изображения на основе данных thumbnail и типа файла
|
|
3
15
|
* @param thumbnail - Данные изображения (может быть data URL)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Config } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Настройки обработки имени по умолчанию
|
|
4
|
+
*/
|
|
5
|
+
export interface NameProcessingOptions {
|
|
6
|
+
transliterate?: boolean;
|
|
7
|
+
replaceSpaces?: boolean;
|
|
8
|
+
removeForbiddenChars?: boolean;
|
|
9
|
+
toLowerCase?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Транслитерирует кириллицу в латиницу
|
|
13
|
+
*/
|
|
14
|
+
export declare function transliterateRuToEn(text: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Нормализует имя файла с учетом настроек из конфига
|
|
17
|
+
* Сохраняет оригинальное расширение файла
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeFileName(fileName: string, config?: Config): string;
|
|
20
|
+
/**
|
|
21
|
+
* Нормализует имя папки с учетом настроек из конфига
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeFolderName(folderName: string, config?: Config): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type SvgColorOptions = {
|
|
2
|
+
colorHex: string;
|
|
3
|
+
colorHex2: string;
|
|
4
|
+
colorHex3: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function applyInlineColors(svg: string, colors: SvgColorOptions): string;
|
|
7
|
+
export declare function computeSvgTargetDimensions(svgText: string, targetSize: number): {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function rasterizeSvgToPng(svgText: string, outW: number, outH: number, bg?: string): Promise<string>;
|