@huyooo/file-explorer-bridge-electron 0.3.0 → 0.4.3

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.
@@ -1,5 +1,5 @@
1
- import { FileItem, OperationResult, FileInfo } from '@huyooo/file-explorer-core';
2
- export { FileInfo, FileItem, OperationResult, SystemPathId } from '@huyooo/file-explorer-core';
1
+ import { FileItem, OperationResult, FileInfo, CompressFormat, CompressLevel } from '@huyooo/file-explorer-core';
2
+ export { CompressFormat, CompressLevel, FileInfo, FileItem, OperationResult, SystemPathId } from '@huyooo/file-explorer-core';
3
3
 
4
4
  /**
5
5
  * File Explorer Electron Bridge - Renderer Process
@@ -7,6 +7,64 @@ export { FileInfo, FileItem, OperationResult, SystemPathId } from '@huyooo/file-
7
7
  * 提供渲染进程使用的适配器
8
8
  */
9
9
 
10
+ /** 压缩选项 */
11
+ interface CompressOptions {
12
+ format: CompressFormat;
13
+ level?: CompressLevel;
14
+ outputName: string;
15
+ outputDir: string;
16
+ deleteSource?: boolean;
17
+ }
18
+ /** 解压选项 */
19
+ interface ExtractOptions {
20
+ targetDir: string;
21
+ deleteArchive?: boolean;
22
+ }
23
+ /** 压缩进度 */
24
+ interface CompressProgress {
25
+ currentFile: string;
26
+ processedCount: number;
27
+ totalCount: number;
28
+ percent: number;
29
+ }
30
+ /** 压缩结果 */
31
+ interface CompressResult {
32
+ success: boolean;
33
+ outputPath?: string;
34
+ error?: string;
35
+ }
36
+ /** 文件变化事件类型 */
37
+ type WatchEventType = 'add' | 'change' | 'remove' | 'rename';
38
+ /** 文件变化事件 */
39
+ interface WatchEvent {
40
+ type: WatchEventType;
41
+ path: string;
42
+ filename: string;
43
+ }
44
+ /** 媒体转码信息 */
45
+ interface TranscodeInfo {
46
+ type: 'video' | 'audio';
47
+ needsTranscode: boolean;
48
+ method: 'direct' | 'remux' | 'transcode';
49
+ estimatedTime?: number;
50
+ targetFormat?: string;
51
+ }
52
+ /** 媒体转码进度 */
53
+ interface MediaTranscodeProgress {
54
+ percent: number;
55
+ time?: number;
56
+ duration?: number;
57
+ speed?: string;
58
+ }
59
+ /** 媒体元数据 */
60
+ interface MediaMetadata {
61
+ filePath: string;
62
+ type: 'video' | 'audio';
63
+ duration: number;
64
+ title?: string;
65
+ artist?: string;
66
+ album?: string;
67
+ }
10
68
  /**
11
69
  * 文件操作适配器接口
12
70
  */
@@ -79,6 +137,56 @@ interface FileExplorerAdapter {
79
137
  items: FileItem[];
80
138
  done: boolean;
81
139
  }) => void): () => void;
140
+ /** 压缩文件 */
141
+ compressFiles(sources: string[], options: CompressOptions): Promise<CompressResult>;
142
+ /** 解压文件 */
143
+ extractArchive(archivePath: string, options: ExtractOptions): Promise<CompressResult>;
144
+ /** 判断是否为压缩文件 */
145
+ isArchiveFile(filePath: string): Promise<boolean>;
146
+ /** 监听压缩进度 */
147
+ onCompressProgress(callback: (data: CompressProgress) => void): () => void;
148
+ /** 监听解压进度 */
149
+ onExtractProgress(callback: (data: CompressProgress) => void): () => void;
150
+ /** 监听目录变化 */
151
+ watchDirectory(dirPath: string, watchId: string): Promise<OperationResult>;
152
+ /** 停止监听目录 */
153
+ unwatchDirectory(watchId: string): Promise<OperationResult>;
154
+ /** 监听文件变化事件 */
155
+ onWatchEvent(callback: (data: {
156
+ watchId: string;
157
+ event: WatchEvent;
158
+ }) => void): () => void;
159
+ /** 显示文件/文件夹的系统属性窗口 */
160
+ showFileInfo(filePath: string): Promise<OperationResult>;
161
+ /** 在终端中打开目录 */
162
+ openInTerminal(dirPath: string): Promise<OperationResult>;
163
+ /** 通过 Cursor 打开 */
164
+ openInEditor(targetPath: string): Promise<OperationResult>;
165
+ /** 在新窗口中打开文件夹(使用系统文件管理器) */
166
+ openInNewWindow(folderPath: string): Promise<OperationResult>;
167
+ /** 请求窗口聚焦(用于右键打开菜单前激活窗口) */
168
+ requestWindowFocus(): void;
169
+ /** 检测媒体文件是否需要转码 */
170
+ mediaNeedsTranscode(filePath: string): Promise<OperationResult<TranscodeInfo>>;
171
+ /** 获取可播放的媒体 URL(自动转码) */
172
+ mediaGetPlayableUrl(filePath: string): Promise<{
173
+ success: boolean;
174
+ url?: string;
175
+ error?: string;
176
+ }>;
177
+ /** 获取媒体元数据 */
178
+ mediaGetMetadata(filePath: string): Promise<OperationResult<MediaMetadata>>;
179
+ /** 监听转码进度 */
180
+ onMediaTranscodeProgress(callback: (data: {
181
+ filePath: string;
182
+ progress: MediaTranscodeProgress;
183
+ }) => void): () => void;
184
+ /** 清理指定文件的转码缓存 */
185
+ mediaCleanupFile(filePath: string): Promise<OperationResult>;
186
+ /** 打开媒体预览窗口(原生窗口) */
187
+ openMediaPreviewWindow(filePath: string, mediaType: 'image' | 'video' | 'audio'): Promise<OperationResult>;
188
+ /** 关闭媒体预览窗口 */
189
+ closeMediaPreviewWindow(filePath: string): Promise<OperationResult>;
82
190
  }
83
191
  /**
84
192
  * Window 扩展类型
@@ -132,6 +240,36 @@ declare global {
132
240
  items: FileItem[];
133
241
  done: boolean;
134
242
  }) => void) => () => void;
243
+ compressFiles: (sources: string[], options: CompressOptions) => Promise<CompressResult>;
244
+ extractArchive: (archivePath: string, options: ExtractOptions) => Promise<CompressResult>;
245
+ isArchiveFile: (filePath: string) => Promise<boolean>;
246
+ onCompressProgress: (callback: (data: CompressProgress) => void) => () => void;
247
+ onExtractProgress: (callback: (data: CompressProgress) => void) => () => void;
248
+ watchDirectory: (dirPath: string, watchId: string) => Promise<OperationResult>;
249
+ unwatchDirectory: (watchId: string) => Promise<OperationResult>;
250
+ onWatchEvent: (callback: (data: {
251
+ watchId: string;
252
+ event: WatchEvent;
253
+ }) => void) => () => void;
254
+ showFileInfo: (filePath: string) => Promise<OperationResult>;
255
+ openInTerminal: (dirPath: string) => Promise<OperationResult>;
256
+ openInEditor: (targetPath: string) => Promise<OperationResult>;
257
+ openInNewWindow: (folderPath: string) => Promise<OperationResult>;
258
+ requestWindowFocus: () => void;
259
+ mediaNeedsTranscode: (filePath: string) => Promise<OperationResult<TranscodeInfo>>;
260
+ mediaGetPlayableUrl: (filePath: string) => Promise<{
261
+ success: boolean;
262
+ url?: string;
263
+ error?: string;
264
+ }>;
265
+ mediaGetMetadata: (filePath: string) => Promise<OperationResult<MediaMetadata>>;
266
+ onMediaTranscodeProgress: (callback: (data: {
267
+ filePath: string;
268
+ progress: MediaTranscodeProgress;
269
+ }) => void) => () => void;
270
+ mediaCleanupFile: (filePath: string) => Promise<OperationResult>;
271
+ openMediaPreviewWindow: (filePath: string, mediaType: 'image' | 'video' | 'audio') => Promise<OperationResult>;
272
+ closeMediaPreviewWindow: (filePath: string) => Promise<OperationResult>;
135
273
  };
136
274
  }
137
275
  }
@@ -147,4 +285,4 @@ declare global {
147
285
  */
148
286
  declare function createElectronAdapter(): FileExplorerAdapter;
149
287
 
150
- export { type FileExplorerAdapter, createElectronAdapter };
288
+ export { type CompressOptions, type CompressProgress, type CompressResult, type ExtractOptions, type FileExplorerAdapter, type MediaMetadata, type MediaTranscodeProgress, type TranscodeInfo, type WatchEvent, type WatchEventType, createElectronAdapter };
@@ -1,5 +1,5 @@
1
- import { FileItem, OperationResult, FileInfo } from '@huyooo/file-explorer-core';
2
- export { FileInfo, FileItem, OperationResult, SystemPathId } from '@huyooo/file-explorer-core';
1
+ import { FileItem, OperationResult, FileInfo, CompressFormat, CompressLevel } from '@huyooo/file-explorer-core';
2
+ export { CompressFormat, CompressLevel, FileInfo, FileItem, OperationResult, SystemPathId } from '@huyooo/file-explorer-core';
3
3
 
4
4
  /**
5
5
  * File Explorer Electron Bridge - Renderer Process
@@ -7,6 +7,64 @@ export { FileInfo, FileItem, OperationResult, SystemPathId } from '@huyooo/file-
7
7
  * 提供渲染进程使用的适配器
8
8
  */
9
9
 
10
+ /** 压缩选项 */
11
+ interface CompressOptions {
12
+ format: CompressFormat;
13
+ level?: CompressLevel;
14
+ outputName: string;
15
+ outputDir: string;
16
+ deleteSource?: boolean;
17
+ }
18
+ /** 解压选项 */
19
+ interface ExtractOptions {
20
+ targetDir: string;
21
+ deleteArchive?: boolean;
22
+ }
23
+ /** 压缩进度 */
24
+ interface CompressProgress {
25
+ currentFile: string;
26
+ processedCount: number;
27
+ totalCount: number;
28
+ percent: number;
29
+ }
30
+ /** 压缩结果 */
31
+ interface CompressResult {
32
+ success: boolean;
33
+ outputPath?: string;
34
+ error?: string;
35
+ }
36
+ /** 文件变化事件类型 */
37
+ type WatchEventType = 'add' | 'change' | 'remove' | 'rename';
38
+ /** 文件变化事件 */
39
+ interface WatchEvent {
40
+ type: WatchEventType;
41
+ path: string;
42
+ filename: string;
43
+ }
44
+ /** 媒体转码信息 */
45
+ interface TranscodeInfo {
46
+ type: 'video' | 'audio';
47
+ needsTranscode: boolean;
48
+ method: 'direct' | 'remux' | 'transcode';
49
+ estimatedTime?: number;
50
+ targetFormat?: string;
51
+ }
52
+ /** 媒体转码进度 */
53
+ interface MediaTranscodeProgress {
54
+ percent: number;
55
+ time?: number;
56
+ duration?: number;
57
+ speed?: string;
58
+ }
59
+ /** 媒体元数据 */
60
+ interface MediaMetadata {
61
+ filePath: string;
62
+ type: 'video' | 'audio';
63
+ duration: number;
64
+ title?: string;
65
+ artist?: string;
66
+ album?: string;
67
+ }
10
68
  /**
11
69
  * 文件操作适配器接口
12
70
  */
@@ -79,6 +137,56 @@ interface FileExplorerAdapter {
79
137
  items: FileItem[];
80
138
  done: boolean;
81
139
  }) => void): () => void;
140
+ /** 压缩文件 */
141
+ compressFiles(sources: string[], options: CompressOptions): Promise<CompressResult>;
142
+ /** 解压文件 */
143
+ extractArchive(archivePath: string, options: ExtractOptions): Promise<CompressResult>;
144
+ /** 判断是否为压缩文件 */
145
+ isArchiveFile(filePath: string): Promise<boolean>;
146
+ /** 监听压缩进度 */
147
+ onCompressProgress(callback: (data: CompressProgress) => void): () => void;
148
+ /** 监听解压进度 */
149
+ onExtractProgress(callback: (data: CompressProgress) => void): () => void;
150
+ /** 监听目录变化 */
151
+ watchDirectory(dirPath: string, watchId: string): Promise<OperationResult>;
152
+ /** 停止监听目录 */
153
+ unwatchDirectory(watchId: string): Promise<OperationResult>;
154
+ /** 监听文件变化事件 */
155
+ onWatchEvent(callback: (data: {
156
+ watchId: string;
157
+ event: WatchEvent;
158
+ }) => void): () => void;
159
+ /** 显示文件/文件夹的系统属性窗口 */
160
+ showFileInfo(filePath: string): Promise<OperationResult>;
161
+ /** 在终端中打开目录 */
162
+ openInTerminal(dirPath: string): Promise<OperationResult>;
163
+ /** 通过 Cursor 打开 */
164
+ openInEditor(targetPath: string): Promise<OperationResult>;
165
+ /** 在新窗口中打开文件夹(使用系统文件管理器) */
166
+ openInNewWindow(folderPath: string): Promise<OperationResult>;
167
+ /** 请求窗口聚焦(用于右键打开菜单前激活窗口) */
168
+ requestWindowFocus(): void;
169
+ /** 检测媒体文件是否需要转码 */
170
+ mediaNeedsTranscode(filePath: string): Promise<OperationResult<TranscodeInfo>>;
171
+ /** 获取可播放的媒体 URL(自动转码) */
172
+ mediaGetPlayableUrl(filePath: string): Promise<{
173
+ success: boolean;
174
+ url?: string;
175
+ error?: string;
176
+ }>;
177
+ /** 获取媒体元数据 */
178
+ mediaGetMetadata(filePath: string): Promise<OperationResult<MediaMetadata>>;
179
+ /** 监听转码进度 */
180
+ onMediaTranscodeProgress(callback: (data: {
181
+ filePath: string;
182
+ progress: MediaTranscodeProgress;
183
+ }) => void): () => void;
184
+ /** 清理指定文件的转码缓存 */
185
+ mediaCleanupFile(filePath: string): Promise<OperationResult>;
186
+ /** 打开媒体预览窗口(原生窗口) */
187
+ openMediaPreviewWindow(filePath: string, mediaType: 'image' | 'video' | 'audio'): Promise<OperationResult>;
188
+ /** 关闭媒体预览窗口 */
189
+ closeMediaPreviewWindow(filePath: string): Promise<OperationResult>;
82
190
  }
83
191
  /**
84
192
  * Window 扩展类型
@@ -132,6 +240,36 @@ declare global {
132
240
  items: FileItem[];
133
241
  done: boolean;
134
242
  }) => void) => () => void;
243
+ compressFiles: (sources: string[], options: CompressOptions) => Promise<CompressResult>;
244
+ extractArchive: (archivePath: string, options: ExtractOptions) => Promise<CompressResult>;
245
+ isArchiveFile: (filePath: string) => Promise<boolean>;
246
+ onCompressProgress: (callback: (data: CompressProgress) => void) => () => void;
247
+ onExtractProgress: (callback: (data: CompressProgress) => void) => () => void;
248
+ watchDirectory: (dirPath: string, watchId: string) => Promise<OperationResult>;
249
+ unwatchDirectory: (watchId: string) => Promise<OperationResult>;
250
+ onWatchEvent: (callback: (data: {
251
+ watchId: string;
252
+ event: WatchEvent;
253
+ }) => void) => () => void;
254
+ showFileInfo: (filePath: string) => Promise<OperationResult>;
255
+ openInTerminal: (dirPath: string) => Promise<OperationResult>;
256
+ openInEditor: (targetPath: string) => Promise<OperationResult>;
257
+ openInNewWindow: (folderPath: string) => Promise<OperationResult>;
258
+ requestWindowFocus: () => void;
259
+ mediaNeedsTranscode: (filePath: string) => Promise<OperationResult<TranscodeInfo>>;
260
+ mediaGetPlayableUrl: (filePath: string) => Promise<{
261
+ success: boolean;
262
+ url?: string;
263
+ error?: string;
264
+ }>;
265
+ mediaGetMetadata: (filePath: string) => Promise<OperationResult<MediaMetadata>>;
266
+ onMediaTranscodeProgress: (callback: (data: {
267
+ filePath: string;
268
+ progress: MediaTranscodeProgress;
269
+ }) => void) => () => void;
270
+ mediaCleanupFile: (filePath: string) => Promise<OperationResult>;
271
+ openMediaPreviewWindow: (filePath: string, mediaType: 'image' | 'video' | 'audio') => Promise<OperationResult>;
272
+ closeMediaPreviewWindow: (filePath: string) => Promise<OperationResult>;
135
273
  };
136
274
  }
137
275
  }
@@ -147,4 +285,4 @@ declare global {
147
285
  */
148
286
  declare function createElectronAdapter(): FileExplorerAdapter;
149
287
 
150
- export { type FileExplorerAdapter, createElectronAdapter };
288
+ export { type CompressOptions, type CompressProgress, type CompressResult, type ExtractOptions, type FileExplorerAdapter, type MediaMetadata, type MediaTranscodeProgress, type TranscodeInfo, type WatchEvent, type WatchEventType, createElectronAdapter };
@@ -28,7 +28,29 @@ function createElectronAdapter() {
28
28
  pasteFiles: (targetDir, sourcePaths) => api.pasteFiles(targetDir, sourcePaths),
29
29
  searchFiles: (searchPath, pattern, maxDepth) => api.searchFiles(searchPath, pattern, maxDepth),
30
30
  searchFilesStream: (searchPath, pattern, searchId) => api.searchFilesStream(searchPath, pattern, searchId),
31
- onSearchResults: (callback) => api.onSearchResults(callback)
31
+ onSearchResults: (callback) => api.onSearchResults(callback),
32
+ compressFiles: (sources, options) => api.compressFiles(sources, options),
33
+ extractArchive: (archivePath, options) => api.extractArchive(archivePath, options),
34
+ isArchiveFile: (filePath) => api.isArchiveFile(filePath),
35
+ onCompressProgress: (callback) => api.onCompressProgress(callback),
36
+ onExtractProgress: (callback) => api.onExtractProgress(callback),
37
+ watchDirectory: (dirPath, watchId) => api.watchDirectory(dirPath, watchId),
38
+ unwatchDirectory: (watchId) => api.unwatchDirectory(watchId),
39
+ onWatchEvent: (callback) => api.onWatchEvent(callback),
40
+ showFileInfo: (filePath) => api.showFileInfo(filePath),
41
+ openInTerminal: (dirPath) => api.openInTerminal(dirPath),
42
+ openInEditor: (targetPath) => api.openInEditor(targetPath),
43
+ openInNewWindow: (folderPath) => api.openInNewWindow(folderPath),
44
+ requestWindowFocus: () => api.requestWindowFocus(),
45
+ // 媒体服务
46
+ mediaNeedsTranscode: (filePath) => api.mediaNeedsTranscode(filePath),
47
+ mediaGetPlayableUrl: (filePath) => api.mediaGetPlayableUrl(filePath),
48
+ mediaGetMetadata: (filePath) => api.mediaGetMetadata(filePath),
49
+ onMediaTranscodeProgress: (callback) => api.onMediaTranscodeProgress(callback),
50
+ mediaCleanupFile: (filePath) => api.mediaCleanupFile(filePath),
51
+ // 媒体预览窗口
52
+ openMediaPreviewWindow: (filePath, mediaType) => api.openMediaPreviewWindow(filePath, mediaType),
53
+ closeMediaPreviewWindow: (filePath) => api.closeMediaPreviewWindow(filePath)
32
54
  };
33
55
  }
34
56
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huyooo/file-explorer-bridge-electron",
3
- "version": "0.3.0",
3
+ "version": "0.4.3",
4
4
  "description": "File Explorer Electron Bridge - IPC integration for Electron apps",
5
5
  "type": "module",
6
6
  "main": "./dist/main/index.cjs",
@@ -36,7 +36,8 @@
36
36
  "clean": "rm -rf dist"
37
37
  },
38
38
  "dependencies": {
39
- "@huyooo/file-explorer-core": "^0.3.0"
39
+ "@huyooo/file-explorer-core": "^0.4.3",
40
+ "@huyooo/file-explorer-preview": "^0.1.0"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "electron": ">=20.0.0"