@huyooo/file-explorer-core 0.3.0 → 0.4.2
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/index.cjs +1380 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +427 -12
- package/dist/index.d.ts +427 -12
- package/dist/index.js +1381 -127
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -260,6 +260,115 @@ declare function exists(filePath: string): Promise<boolean>;
|
|
|
260
260
|
*/
|
|
261
261
|
declare function isDirectory(filePath: string): Promise<boolean>;
|
|
262
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Shell 操作
|
|
265
|
+
*
|
|
266
|
+
* 系统级操作:显示简介、在新窗口打开等
|
|
267
|
+
*/
|
|
268
|
+
/**
|
|
269
|
+
* 显示文件/文件夹的系统属性窗口
|
|
270
|
+
*
|
|
271
|
+
* - macOS: 打开 Finder 的"显示简介"窗口
|
|
272
|
+
* - Windows: 打开"属性"窗口
|
|
273
|
+
* - Linux: 尝试使用文件管理器的属性功能
|
|
274
|
+
*/
|
|
275
|
+
declare function showFileInfo(filePath: string): Promise<{
|
|
276
|
+
success: boolean;
|
|
277
|
+
error?: string;
|
|
278
|
+
}>;
|
|
279
|
+
/**
|
|
280
|
+
* 在系统文件管理器中显示文件(选中状态)
|
|
281
|
+
*
|
|
282
|
+
* 注意:这个功能在 Electron 中可以用 shell.showItemInFolder 实现
|
|
283
|
+
* 这里提供一个纯 Node.js 的替代实现
|
|
284
|
+
*/
|
|
285
|
+
declare function revealInFileManager(filePath: string): Promise<{
|
|
286
|
+
success: boolean;
|
|
287
|
+
error?: string;
|
|
288
|
+
}>;
|
|
289
|
+
/**
|
|
290
|
+
* 在终端中打开目录
|
|
291
|
+
* macOS: 优先 iTerm2,回退到 Terminal.app
|
|
292
|
+
*/
|
|
293
|
+
declare function openInTerminal(dirPath: string): Promise<{
|
|
294
|
+
success: boolean;
|
|
295
|
+
error?: string;
|
|
296
|
+
}>;
|
|
297
|
+
/**
|
|
298
|
+
* 通过 Cursor 打开
|
|
299
|
+
* 优先 Cursor,回退到 VSCode
|
|
300
|
+
*/
|
|
301
|
+
declare function openInEditor(targetPath: string): Promise<{
|
|
302
|
+
success: boolean;
|
|
303
|
+
error?: string;
|
|
304
|
+
}>;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* 压缩/解压操作
|
|
308
|
+
*
|
|
309
|
+
* 支持格式:zip, tar, tar.gz (tgz), tar.bz2
|
|
310
|
+
*/
|
|
311
|
+
/** 压缩格式 */
|
|
312
|
+
type CompressFormat = 'zip' | 'tar' | 'tgz' | 'tarbz2';
|
|
313
|
+
/** 压缩级别 */
|
|
314
|
+
type CompressLevel = 'fast' | 'normal' | 'best';
|
|
315
|
+
/** 压缩选项 */
|
|
316
|
+
interface CompressOptions {
|
|
317
|
+
/** 输出格式 */
|
|
318
|
+
format: CompressFormat;
|
|
319
|
+
/** 压缩级别 */
|
|
320
|
+
level?: CompressLevel;
|
|
321
|
+
/** 输出文件名(不含路径) */
|
|
322
|
+
outputName: string;
|
|
323
|
+
/** 输出目录 */
|
|
324
|
+
outputDir: string;
|
|
325
|
+
/** 压缩后删除源文件 */
|
|
326
|
+
deleteSource?: boolean;
|
|
327
|
+
}
|
|
328
|
+
/** 解压选项 */
|
|
329
|
+
interface ExtractOptions {
|
|
330
|
+
/** 目标目录 */
|
|
331
|
+
targetDir: string;
|
|
332
|
+
/** 解压后删除压缩包 */
|
|
333
|
+
deleteArchive?: boolean;
|
|
334
|
+
}
|
|
335
|
+
/** 进度信息 */
|
|
336
|
+
interface CompressProgress {
|
|
337
|
+
/** 当前文件 */
|
|
338
|
+
currentFile: string;
|
|
339
|
+
/** 已处理文件数 */
|
|
340
|
+
processedCount: number;
|
|
341
|
+
/** 总文件数 */
|
|
342
|
+
totalCount: number;
|
|
343
|
+
/** 进度百分比 */
|
|
344
|
+
percent: number;
|
|
345
|
+
}
|
|
346
|
+
/** 操作结果 */
|
|
347
|
+
interface CompressResult {
|
|
348
|
+
success: boolean;
|
|
349
|
+
/** 输出路径 */
|
|
350
|
+
outputPath?: string;
|
|
351
|
+
error?: string;
|
|
352
|
+
}
|
|
353
|
+
/** 进度回调 */
|
|
354
|
+
type ProgressCallback$1 = (progress: CompressProgress) => void;
|
|
355
|
+
/**
|
|
356
|
+
* 根据文件扩展名检测格式
|
|
357
|
+
*/
|
|
358
|
+
declare function detectArchiveFormat(filePath: string): CompressFormat | null;
|
|
359
|
+
/**
|
|
360
|
+
* 判断文件是否为支持的压缩文件
|
|
361
|
+
*/
|
|
362
|
+
declare function isArchiveFile(filePath: string): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* 压缩文件/目录
|
|
365
|
+
*/
|
|
366
|
+
declare function compressFiles(sources: string[], options: CompressOptions, onProgress?: ProgressCallback$1): Promise<CompressResult>;
|
|
367
|
+
/**
|
|
368
|
+
* 解压文件
|
|
369
|
+
*/
|
|
370
|
+
declare function extractArchive(archivePath: string, options: ExtractOptions, onProgress?: ProgressCallback$1): Promise<CompressResult>;
|
|
371
|
+
|
|
263
372
|
/**
|
|
264
373
|
* 获取系统路径
|
|
265
374
|
*/
|
|
@@ -302,13 +411,13 @@ declare function searchFilesSync(searchPath: string, pattern?: string, maxDepth?
|
|
|
302
411
|
|
|
303
412
|
/**
|
|
304
413
|
* 计算文件的快速 hash(使用文件大小和修改时间)
|
|
414
|
+
* 使用 xxHash64 算法,专为非加密场景设计,性能极快
|
|
305
415
|
* 这比计算完整文件 hash 快得多,适合用于缓存判断
|
|
416
|
+
*
|
|
417
|
+
* @param filePath - 文件路径
|
|
418
|
+
* @param stats - 可选的文件状态(如果已获取,避免重复调用 stat)
|
|
306
419
|
*/
|
|
307
|
-
declare function getFileHash(filePath: string): Promise<string>;
|
|
308
|
-
/**
|
|
309
|
-
* 批量计算文件 hash
|
|
310
|
-
*/
|
|
311
|
-
declare function getFileHashes(filePaths: string[]): Promise<Map<string, string>>;
|
|
420
|
+
declare function getFileHash(filePath: string, stats?: Stats): Promise<string>;
|
|
312
421
|
|
|
313
422
|
/**
|
|
314
423
|
* 剪贴板文件操作接口
|
|
@@ -347,6 +456,61 @@ declare function pasteFiles(targetDir: string, sourcePaths: string[]): Promise<O
|
|
|
347
456
|
*/
|
|
348
457
|
declare function getApplicationIcon(appPath: string): Promise<string | null>;
|
|
349
458
|
|
|
459
|
+
/**
|
|
460
|
+
* 文件系统监听服务
|
|
461
|
+
*
|
|
462
|
+
* 监听目录变化,当文件增删改时触发回调
|
|
463
|
+
*/
|
|
464
|
+
/** 文件变化类型 */
|
|
465
|
+
type WatchEventType = 'add' | 'change' | 'remove' | 'rename';
|
|
466
|
+
/** 文件变化事件 */
|
|
467
|
+
interface WatchEvent {
|
|
468
|
+
type: WatchEventType;
|
|
469
|
+
path: string;
|
|
470
|
+
filename: string;
|
|
471
|
+
}
|
|
472
|
+
/** 监听回调 */
|
|
473
|
+
type WatchCallback = (event: WatchEvent) => void;
|
|
474
|
+
/** 监听器实例 */
|
|
475
|
+
interface Watcher {
|
|
476
|
+
/** 停止监听 */
|
|
477
|
+
close: () => void;
|
|
478
|
+
/** 监听的目录路径 */
|
|
479
|
+
path: string;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* 监听目录变化
|
|
483
|
+
*
|
|
484
|
+
* @param dirPath 要监听的目录路径
|
|
485
|
+
* @param callback 变化回调
|
|
486
|
+
* @returns Watcher 实例
|
|
487
|
+
*/
|
|
488
|
+
declare function watchDirectory(dirPath: string, callback: WatchCallback): Watcher;
|
|
489
|
+
/**
|
|
490
|
+
* 监听管理器
|
|
491
|
+
* 用于管理多个监听器,确保同一目录只有一个监听器
|
|
492
|
+
*/
|
|
493
|
+
declare class WatchManager {
|
|
494
|
+
private watchers;
|
|
495
|
+
private callbacks;
|
|
496
|
+
/**
|
|
497
|
+
* 开始监听目录
|
|
498
|
+
*/
|
|
499
|
+
watch(dirPath: string, callback: WatchCallback): () => void;
|
|
500
|
+
/**
|
|
501
|
+
* 停止监听
|
|
502
|
+
*/
|
|
503
|
+
private unwatch;
|
|
504
|
+
/**
|
|
505
|
+
* 关闭所有监听器
|
|
506
|
+
*/
|
|
507
|
+
closeAll(): void;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* 获取全局监听管理器
|
|
511
|
+
*/
|
|
512
|
+
declare function getWatchManager(): WatchManager;
|
|
513
|
+
|
|
350
514
|
/**
|
|
351
515
|
* 缩略图数据库接口
|
|
352
516
|
*/
|
|
@@ -417,13 +581,13 @@ declare class ThumbnailService {
|
|
|
417
581
|
*/
|
|
418
582
|
generateThumbnail(filePath: string, fileHash: string, mtime: number): Promise<string | null>;
|
|
419
583
|
/**
|
|
420
|
-
*
|
|
584
|
+
* 批量生成缩略图(带并发限制,避免资源耗尽)
|
|
421
585
|
*/
|
|
422
586
|
generateThumbnailsBatch(files: Array<{
|
|
423
587
|
path: string;
|
|
424
588
|
hash: string;
|
|
425
589
|
mtime: number;
|
|
426
|
-
}
|
|
590
|
+
}>, concurrency?: number): Promise<void>;
|
|
427
591
|
/**
|
|
428
592
|
* 删除缩略图
|
|
429
593
|
*/
|
|
@@ -448,13 +612,36 @@ declare function getThumbnailService(): ThumbnailService | null;
|
|
|
448
612
|
* 需要安装 better-sqlite3:npm install better-sqlite3
|
|
449
613
|
*/
|
|
450
614
|
|
|
615
|
+
interface SqliteThumbnailDatabaseOptions {
|
|
616
|
+
/**
|
|
617
|
+
* 缩略图存储目录(绝对路径)。如果提供,则优先使用该目录。
|
|
618
|
+
* 适用于将本库嵌入到其他应用时,自定义缩略图缓存位置。
|
|
619
|
+
*/
|
|
620
|
+
thumbnailDir?: string;
|
|
621
|
+
/**
|
|
622
|
+
* 缩略图子目录名(相对 userDataPath)。默认:`thumbnails`
|
|
623
|
+
* 仅在未提供 thumbnailDir 时生效。
|
|
624
|
+
*/
|
|
625
|
+
dirName?: string;
|
|
626
|
+
/**
|
|
627
|
+
* 缩略图数据库文件名(默认:`thumbnails.db`)
|
|
628
|
+
* 仅在未提供 dbPath 时生效。
|
|
629
|
+
*/
|
|
630
|
+
dbFileName?: string;
|
|
631
|
+
/**
|
|
632
|
+
* 缩略图数据库文件路径(绝对路径)。如果提供,则优先使用该路径。
|
|
633
|
+
* 注意:缩略图 jpg 仍然会写入 thumbnailDir(若未显式提供,则使用 dbPath 所在目录)。
|
|
634
|
+
*/
|
|
635
|
+
dbPath?: string;
|
|
636
|
+
}
|
|
451
637
|
/**
|
|
452
638
|
* SQLite 缩略图数据库实现
|
|
453
639
|
*/
|
|
454
640
|
declare class SqliteThumbnailDatabase implements ThumbnailDatabase {
|
|
455
641
|
private db;
|
|
456
642
|
private cacheDir;
|
|
457
|
-
|
|
643
|
+
private dbPath;
|
|
644
|
+
constructor(userDataPath: string, options?: SqliteThumbnailDatabaseOptions);
|
|
458
645
|
/**
|
|
459
646
|
* 初始化数据库
|
|
460
647
|
*/
|
|
@@ -474,11 +661,21 @@ declare class SqliteThumbnailDatabase implements ThumbnailDatabase {
|
|
|
474
661
|
/**
|
|
475
662
|
* 创建 SQLite 缩略图数据库
|
|
476
663
|
*/
|
|
477
|
-
|
|
664
|
+
/**
|
|
665
|
+
* 创建 SQLite 缩略图数据库(统一入口:仅支持 options 对象)
|
|
666
|
+
* 说明:不再支持“传 dbPath 当作参数”的用法;宿主需要显式传入 userDataPath(以及可选的目录/文件覆盖)。
|
|
667
|
+
*/
|
|
668
|
+
declare function createSqliteThumbnailDatabase(options: {
|
|
669
|
+
userDataPath: string;
|
|
670
|
+
} & SqliteThumbnailDatabaseOptions): SqliteThumbnailDatabase;
|
|
478
671
|
/**
|
|
479
672
|
* 获取缩略图数据库实例
|
|
480
673
|
*/
|
|
481
674
|
declare function getSqliteThumbnailDatabase(): SqliteThumbnailDatabase | null;
|
|
675
|
+
/**
|
|
676
|
+
* 关闭缩略图数据库(应在应用退出时调用)
|
|
677
|
+
*/
|
|
678
|
+
declare function closeThumbnailDatabase(): void;
|
|
482
679
|
|
|
483
680
|
/**
|
|
484
681
|
* 缩略图处理器工厂函数
|
|
@@ -492,12 +689,14 @@ declare function getSqliteThumbnailDatabase(): SqliteThumbnailDatabase | null;
|
|
|
492
689
|
* Sharp 类型定义(宽松类型,兼容 sharp 模块)
|
|
493
690
|
*/
|
|
494
691
|
interface SharpInstance {
|
|
495
|
-
resize(
|
|
496
|
-
|
|
692
|
+
resize(options?: {
|
|
693
|
+
width?: number;
|
|
694
|
+
height?: number;
|
|
497
695
|
withoutEnlargement?: boolean;
|
|
498
696
|
}): SharpInstance;
|
|
499
697
|
jpeg(options?: {
|
|
500
698
|
quality?: number;
|
|
699
|
+
optimiseCoding?: boolean;
|
|
501
700
|
}): SharpInstance;
|
|
502
701
|
toFile(outputPath: string): Promise<unknown>;
|
|
503
702
|
}
|
|
@@ -531,4 +730,220 @@ declare function createSharpImageProcessor(sharp: SharpModule): ImageProcessor;
|
|
|
531
730
|
*/
|
|
532
731
|
declare function createFfmpegVideoProcessor(ffmpegPath: string): VideoProcessor;
|
|
533
732
|
|
|
534
|
-
|
|
733
|
+
/**
|
|
734
|
+
* 媒体类型
|
|
735
|
+
*/
|
|
736
|
+
type MediaType = 'video' | 'audio';
|
|
737
|
+
/**
|
|
738
|
+
* 转码方式
|
|
739
|
+
* - direct: 直接播放,无需转换
|
|
740
|
+
* - remux: 转封装,只改变容器格式,不重新编码(快速)
|
|
741
|
+
* - transcode: 转码,重新编码(较慢)
|
|
742
|
+
*/
|
|
743
|
+
type TranscodeMethod = 'direct' | 'remux' | 'transcode';
|
|
744
|
+
/**
|
|
745
|
+
* 转码状态
|
|
746
|
+
*/
|
|
747
|
+
type TranscodeStatus = 'idle' | 'checking' | 'transcoding' | 'ready' | 'error';
|
|
748
|
+
/**
|
|
749
|
+
* 媒体格式信息
|
|
750
|
+
*/
|
|
751
|
+
interface MediaFormatInfo {
|
|
752
|
+
/** 媒体类型 */
|
|
753
|
+
type: MediaType;
|
|
754
|
+
/** 容器格式 (mp4, mkv, avi...) */
|
|
755
|
+
container: string;
|
|
756
|
+
/** 视频编码 (h264, h265, vp9...) */
|
|
757
|
+
videoCodec?: string;
|
|
758
|
+
/** 音频编码 (aac, mp3, flac...) */
|
|
759
|
+
audioCodec?: string;
|
|
760
|
+
/** 时长(秒) */
|
|
761
|
+
duration?: number;
|
|
762
|
+
/** 宽度 */
|
|
763
|
+
width?: number;
|
|
764
|
+
/** 高度 */
|
|
765
|
+
height?: number;
|
|
766
|
+
/** 比特率 */
|
|
767
|
+
bitrate?: number;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* 转码检测结果
|
|
771
|
+
*/
|
|
772
|
+
interface TranscodeInfo {
|
|
773
|
+
/** 媒体类型 */
|
|
774
|
+
type: MediaType;
|
|
775
|
+
/** 是否需要转码 */
|
|
776
|
+
needsTranscode: boolean;
|
|
777
|
+
/** 转码方式 */
|
|
778
|
+
method: TranscodeMethod;
|
|
779
|
+
/** 预估时间(秒),仅转码时有值 */
|
|
780
|
+
estimatedTime?: number;
|
|
781
|
+
/** 原始格式信息 */
|
|
782
|
+
formatInfo?: MediaFormatInfo;
|
|
783
|
+
/** 目标格式 */
|
|
784
|
+
targetFormat?: string;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* 转码进度
|
|
788
|
+
*/
|
|
789
|
+
interface TranscodeProgress {
|
|
790
|
+
/** 进度百分比 0-100 */
|
|
791
|
+
percent: number;
|
|
792
|
+
/** 当前处理时间(秒) */
|
|
793
|
+
time?: number;
|
|
794
|
+
/** 总时长(秒) */
|
|
795
|
+
duration?: number;
|
|
796
|
+
/** 速度(如 "2.5x") */
|
|
797
|
+
speed?: string;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* 转码结果
|
|
801
|
+
*/
|
|
802
|
+
interface TranscodeResult {
|
|
803
|
+
/** 是否成功 */
|
|
804
|
+
success: boolean;
|
|
805
|
+
/** 可播放的 URL(成功时) */
|
|
806
|
+
url?: string;
|
|
807
|
+
/** 输出文件路径(成功时) */
|
|
808
|
+
outputPath?: string;
|
|
809
|
+
/** 错误信息(失败时) */
|
|
810
|
+
error?: string;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* 媒体元数据
|
|
814
|
+
*/
|
|
815
|
+
interface MediaMetadata {
|
|
816
|
+
/** 文件路径 */
|
|
817
|
+
filePath: string;
|
|
818
|
+
/** 媒体类型 */
|
|
819
|
+
type: MediaType;
|
|
820
|
+
/** 时长(秒) */
|
|
821
|
+
duration: number;
|
|
822
|
+
/** 格式信息 */
|
|
823
|
+
format: MediaFormatInfo;
|
|
824
|
+
/** 标题 */
|
|
825
|
+
title?: string;
|
|
826
|
+
/** 艺术家 */
|
|
827
|
+
artist?: string;
|
|
828
|
+
/** 专辑 */
|
|
829
|
+
album?: string;
|
|
830
|
+
/** 年份 */
|
|
831
|
+
year?: string;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* 进度回调函数
|
|
835
|
+
*/
|
|
836
|
+
type ProgressCallback = (progress: TranscodeProgress) => void;
|
|
837
|
+
/**
|
|
838
|
+
* 媒体服务配置
|
|
839
|
+
*/
|
|
840
|
+
interface MediaServiceOptions {
|
|
841
|
+
/** ffmpeg 路径 */
|
|
842
|
+
ffmpegPath: string;
|
|
843
|
+
/** ffprobe 路径(可选,默认与 ffmpeg 同目录) */
|
|
844
|
+
ffprobePath?: string;
|
|
845
|
+
/** 临时文件目录 */
|
|
846
|
+
tempDir?: string;
|
|
847
|
+
/** URL 编码器 */
|
|
848
|
+
urlEncoder?: (filePath: string) => string;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* 媒体格式检测
|
|
853
|
+
*
|
|
854
|
+
* 判断媒体文件是否需要转码,以及使用何种转码方式
|
|
855
|
+
*/
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* 从文件扩展名判断媒体类型
|
|
859
|
+
*/
|
|
860
|
+
declare function getMediaTypeByExtension(filePath: string): MediaType | null;
|
|
861
|
+
/**
|
|
862
|
+
* 使用 ffprobe 获取媒体格式信息
|
|
863
|
+
*/
|
|
864
|
+
declare function getMediaFormat(filePath: string, ffprobePath: string): Promise<MediaFormatInfo | null>;
|
|
865
|
+
/**
|
|
866
|
+
* 检测媒体文件的转码需求
|
|
867
|
+
*/
|
|
868
|
+
declare function detectTranscodeNeeds(filePath: string, ffprobePath: string): Promise<TranscodeInfo>;
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* 媒体转码器
|
|
872
|
+
*
|
|
873
|
+
* 使用 ffmpeg 进行媒体格式转换
|
|
874
|
+
*/
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* 执行媒体转码
|
|
878
|
+
*/
|
|
879
|
+
declare function transcodeMedia(ffmpegPath: string, inputPath: string, transcodeInfo: TranscodeInfo, tempDir?: string, onProgress?: ProgressCallback): Promise<TranscodeResult>;
|
|
880
|
+
/**
|
|
881
|
+
* 清理临时转码文件
|
|
882
|
+
*/
|
|
883
|
+
declare function cleanupTranscodedFile(filePath: string): Promise<void>;
|
|
884
|
+
/**
|
|
885
|
+
* 清理所有临时转码文件
|
|
886
|
+
*/
|
|
887
|
+
declare function cleanupAllTranscodedFiles(tempDir?: string): Promise<void>;
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* 统一媒体服务
|
|
891
|
+
*
|
|
892
|
+
* 提供媒体格式检测、转码、元数据获取等功能
|
|
893
|
+
*/
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* 媒体服务类
|
|
897
|
+
*/
|
|
898
|
+
declare class MediaService {
|
|
899
|
+
private ffmpegPath;
|
|
900
|
+
private ffprobePath;
|
|
901
|
+
private tempDir?;
|
|
902
|
+
private urlEncoder?;
|
|
903
|
+
private transcodeInfoCache;
|
|
904
|
+
private transcodedFiles;
|
|
905
|
+
constructor(options: MediaServiceOptions);
|
|
906
|
+
/**
|
|
907
|
+
* 检测文件是否需要转码
|
|
908
|
+
*/
|
|
909
|
+
needsTranscode(filePath: string): Promise<TranscodeInfo>;
|
|
910
|
+
/**
|
|
911
|
+
* 执行转码并返回可播放的 URL
|
|
912
|
+
*/
|
|
913
|
+
transcode(filePath: string, onProgress?: ProgressCallback): Promise<TranscodeResult>;
|
|
914
|
+
/**
|
|
915
|
+
* 获取媒体元数据
|
|
916
|
+
*/
|
|
917
|
+
getMetadata(filePath: string): Promise<MediaMetadata | null>;
|
|
918
|
+
/**
|
|
919
|
+
* 获取可播放的 URL
|
|
920
|
+
* 如果文件需要转码,则执行转码;否则直接返回文件 URL
|
|
921
|
+
*/
|
|
922
|
+
getPlayableUrl(filePath: string, onProgress?: ProgressCallback): Promise<string | null>;
|
|
923
|
+
/**
|
|
924
|
+
* 清理指定文件的转码缓存
|
|
925
|
+
*/
|
|
926
|
+
cleanupFile(filePath: string): Promise<void>;
|
|
927
|
+
/**
|
|
928
|
+
* 清理所有转码缓存
|
|
929
|
+
*/
|
|
930
|
+
cleanup(): Promise<void>;
|
|
931
|
+
/**
|
|
932
|
+
* 清除缓存(不删除文件)
|
|
933
|
+
*/
|
|
934
|
+
clearCache(): void;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* 初始化媒体服务
|
|
938
|
+
*/
|
|
939
|
+
declare function initMediaService(options: MediaServiceOptions): MediaService;
|
|
940
|
+
/**
|
|
941
|
+
* 获取媒体服务实例
|
|
942
|
+
*/
|
|
943
|
+
declare function getMediaService(): MediaService | null;
|
|
944
|
+
/**
|
|
945
|
+
* 创建媒体服务(不设为全局实例)
|
|
946
|
+
*/
|
|
947
|
+
declare function createMediaService(options: MediaServiceOptions): MediaService;
|
|
948
|
+
|
|
949
|
+
export { APP_PROTOCOL_HOST, APP_PROTOCOL_PREFIX, APP_PROTOCOL_SCHEME, type ClipboardAdapter, type CompressFormat, type CompressLevel, type CompressOptions, type CompressProgress, type CompressResult, type DeleteOptions, type ExtractOptions, type FileInfo, type FileItem, type FileOperationOptions, FileType, type ImageProcessor, type MediaFormatInfo, type MediaMetadata, type ProgressCallback as MediaProgressCallback, MediaService, type MediaServiceOptions, type MediaType, type OperationResult, type PlatformAdapter, type ProgressCallback$1 as ProgressCallback, type ReadDirectoryOptions, type RenameOptions, SqliteThumbnailDatabase, type SystemPathId, type ThumbnailDatabase, ThumbnailService, type ThumbnailServiceOptions, type TranscodeInfo, type TranscodeMethod, type TranscodeProgress, type TranscodeResult, type TranscodeStatus, type UrlEncoder, type VideoProcessor, type WatchCallback, type WatchEvent, type WatchEventType, WatchManager, type Watcher, cleanupAllTranscodedFiles, cleanupTranscodedFile, closeThumbnailDatabase, compressFiles, copyFiles, copyFilesToClipboard, createFfmpegVideoProcessor, createFile, createFolder, createMediaService, createSharpImageProcessor, createSqliteThumbnailDatabase, decodeFileUrl, deleteFiles, detectArchiveFormat, detectTranscodeNeeds, encodeFileUrl, exists, extractArchive, formatDate, formatDateTime, formatFileSize, getAllSystemPaths, getApplicationIcon, getClipboardFiles, getFileHash, getFileInfo, getFileType, getHomeDirectory, getMediaFormat, getMediaService, getMediaTypeByExtension, getPlatform, getSqliteThumbnailDatabase, getSystemPath, getThumbnailService, getWatchManager, initMediaService, initThumbnailService, isAppProtocolUrl, isArchiveFile, isDirectory, isMediaFile, isPreviewable, moveFiles, openInEditor, openInTerminal, pasteFiles, readDirectory, readFileContent, readImageAsBase64, renameFile, revealInFileManager, searchFiles, searchFilesStream, searchFilesSync, showFileInfo, transcodeMedia, watchDirectory, writeFileContent };
|