@huyooo/file-explorer-bridge-electron 0.2.0

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.
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/main/index.ts
31
+ var main_exports = {};
32
+ __export(main_exports, {
33
+ createElectronAdapter: () => createElectronAdapter,
34
+ electronUrlEncoder: () => electronUrlEncoder,
35
+ registerFileExplorerHandlers: () => registerFileExplorerHandlers,
36
+ setClipboardAdapter: () => setClipboardAdapter
37
+ });
38
+ module.exports = __toCommonJS(main_exports);
39
+ var import_electron = require("electron");
40
+ var import_node_path = __toESM(require("path"), 1);
41
+ var import_file_explorer_core = require("@huyooo/file-explorer-core");
42
+ var import_node_fs = require("fs");
43
+ var CHANNEL_PREFIX = "file-explorer";
44
+ var channel = (name) => `${CHANNEL_PREFIX}:${name}`;
45
+ var clipboardAdapter = null;
46
+ function setClipboardAdapter(adapter) {
47
+ clipboardAdapter = adapter;
48
+ }
49
+ function createElectronAdapter() {
50
+ return {
51
+ trashItem: async (filePath) => {
52
+ await import_electron.shell.trashItem(filePath);
53
+ },
54
+ openPath: async (filePath) => {
55
+ await import_electron.shell.openPath(filePath);
56
+ }
57
+ };
58
+ }
59
+ function electronUrlEncoder(filePath) {
60
+ const encodedPath = encodeURIComponent(filePath);
61
+ return `app://file${encodedPath}`;
62
+ }
63
+ function registerFileExplorerHandlers() {
64
+ const adapter = createElectronAdapter();
65
+ import_electron.ipcMain.handle(channel("readDirectory"), async (_event, dirPath) => {
66
+ const thumbnailService = (0, import_file_explorer_core.getThumbnailService)();
67
+ return await (0, import_file_explorer_core.readDirectory)(dirPath, {
68
+ urlEncoder: electronUrlEncoder,
69
+ getThumbnailUrl: thumbnailService ? (filePath) => thumbnailService.getThumbnailUrl(filePath) : void 0
70
+ });
71
+ });
72
+ import_electron.ipcMain.handle(channel("readSystemPath"), async (_event, pathId) => {
73
+ const systemPath = (0, import_file_explorer_core.getSystemPath)(pathId);
74
+ if (!systemPath) return [];
75
+ const thumbnailService = (0, import_file_explorer_core.getThumbnailService)();
76
+ return await (0, import_file_explorer_core.readDirectory)(systemPath, {
77
+ urlEncoder: electronUrlEncoder,
78
+ getThumbnailUrl: thumbnailService ? (filePath) => thumbnailService.getThumbnailUrl(filePath) : void 0
79
+ });
80
+ });
81
+ import_electron.ipcMain.handle(channel("getSystemPath"), async (_event, pathId) => {
82
+ return (0, import_file_explorer_core.getSystemPath)(pathId);
83
+ });
84
+ import_electron.ipcMain.handle(channel("readFileContent"), async (_event, filePath) => {
85
+ return await (0, import_file_explorer_core.readFileContent)(filePath);
86
+ });
87
+ import_electron.ipcMain.handle(channel("writeFileContent"), async (_event, filePath, content) => {
88
+ return await (0, import_file_explorer_core.writeFileContent)(filePath, content);
89
+ });
90
+ import_electron.ipcMain.handle(channel("createFolder"), async (_event, parentDir, folderName) => {
91
+ const folderPath = import_node_path.default.join(parentDir, folderName);
92
+ return await (0, import_file_explorer_core.createFolder)(folderPath);
93
+ });
94
+ import_electron.ipcMain.handle(channel("createFile"), async (_event, parentDir, fileName, content) => {
95
+ const filePath = import_node_path.default.join(parentDir, fileName);
96
+ return await (0, import_file_explorer_core.createFile)(filePath, content);
97
+ });
98
+ import_electron.ipcMain.handle(channel("deleteFiles"), async (_event, paths) => {
99
+ const thumbnailService = (0, import_file_explorer_core.getThumbnailService)();
100
+ return await (0, import_file_explorer_core.deleteFiles)(paths, {
101
+ adapter,
102
+ useTrash: true,
103
+ onDeleted: (p) => thumbnailService?.deleteThumbnail(p)
104
+ });
105
+ });
106
+ import_electron.ipcMain.handle(channel("renameFile"), async (_event, oldPath, newPath) => {
107
+ const thumbnailService = (0, import_file_explorer_core.getThumbnailService)();
108
+ return await (0, import_file_explorer_core.renameFile)(oldPath, newPath, {
109
+ onRenamed: (old) => thumbnailService?.deleteThumbnail(old)
110
+ });
111
+ });
112
+ import_electron.ipcMain.handle(channel("copyFiles"), async (_event, sourcePaths, targetDir) => {
113
+ return await (0, import_file_explorer_core.copyFiles)(sourcePaths, targetDir);
114
+ });
115
+ import_electron.ipcMain.handle(channel("moveFiles"), async (_event, sourcePaths, targetDir) => {
116
+ return await (0, import_file_explorer_core.moveFiles)(sourcePaths, targetDir);
117
+ });
118
+ import_electron.ipcMain.handle(channel("getFileInfo"), async (_event, filePath) => {
119
+ return await (0, import_file_explorer_core.getFileInfo)(filePath);
120
+ });
121
+ import_electron.ipcMain.handle(channel("readImageAsBase64"), async (_event, imagePath) => {
122
+ return await (0, import_file_explorer_core.readImageAsBase64)(imagePath);
123
+ });
124
+ import_electron.ipcMain.handle(channel("openPath"), async (_event, filePath) => {
125
+ try {
126
+ await import_electron.shell.openPath(filePath);
127
+ return { success: true };
128
+ } catch (error) {
129
+ return { success: false, error: String(error) };
130
+ }
131
+ });
132
+ import_electron.ipcMain.handle(channel("getApplicationIcon"), async (_event, appPath) => {
133
+ return await (0, import_file_explorer_core.getApplicationIcon)(appPath);
134
+ });
135
+ import_electron.ipcMain.handle(channel("getThumbnailUrl"), async (_event, filePath) => {
136
+ const thumbnailService = (0, import_file_explorer_core.getThumbnailService)();
137
+ if (!thumbnailService) return null;
138
+ return await thumbnailService.getThumbnailUrl(filePath);
139
+ });
140
+ import_electron.ipcMain.handle(channel("copyFilesToClipboard"), async (_event, filePaths) => {
141
+ if (!clipboardAdapter) {
142
+ return { success: false, error: "\u526A\u8D34\u677F\u9002\u914D\u5668\u672A\u521D\u59CB\u5316" };
143
+ }
144
+ return await (0, import_file_explorer_core.copyFilesToClipboard)(filePaths, clipboardAdapter);
145
+ });
146
+ import_electron.ipcMain.handle(channel("getClipboardFiles"), async () => {
147
+ if (!clipboardAdapter) {
148
+ return { success: false, error: "\u526A\u8D34\u677F\u9002\u914D\u5668\u672A\u521D\u59CB\u5316" };
149
+ }
150
+ return (0, import_file_explorer_core.getClipboardFiles)(clipboardAdapter);
151
+ });
152
+ import_electron.ipcMain.handle(channel("pasteFiles"), async (_event, targetDir, sourcePaths) => {
153
+ return await (0, import_file_explorer_core.pasteFiles)(targetDir, sourcePaths);
154
+ });
155
+ import_electron.ipcMain.handle(channel("searchFiles"), async (_event, searchPath, pattern, maxDepth) => {
156
+ try {
157
+ const filePaths = await (0, import_file_explorer_core.searchFiles)(searchPath, pattern, maxDepth);
158
+ const thumbnailService = (0, import_file_explorer_core.getThumbnailService)();
159
+ const maxResults = 100;
160
+ const results = [];
161
+ for (const filePath of filePaths.slice(0, maxResults)) {
162
+ try {
163
+ const stats = await import_node_fs.promises.stat(filePath);
164
+ const fileType = (0, import_file_explorer_core.getFileType)(filePath, stats);
165
+ const item = {
166
+ id: filePath,
167
+ name: import_node_path.default.basename(filePath),
168
+ type: fileType,
169
+ size: stats.isDirectory() ? void 0 : (0, import_file_explorer_core.formatFileSize)(stats.size),
170
+ dateModified: (0, import_file_explorer_core.formatDateTime)(stats.mtime),
171
+ url: electronUrlEncoder(filePath)
172
+ };
173
+ if (thumbnailService) {
174
+ const thumbnailUrl = await thumbnailService.getThumbnailUrl(filePath);
175
+ if (thumbnailUrl) {
176
+ item.thumbnailUrl = thumbnailUrl;
177
+ }
178
+ }
179
+ results.push(item);
180
+ } catch {
181
+ }
182
+ }
183
+ return { success: true, data: { items: results, total: filePaths.length } };
184
+ } catch (error) {
185
+ return { success: false, error: String(error) };
186
+ }
187
+ });
188
+ import_electron.ipcMain.handle(channel("searchFilesStream"), async (event, searchPath, pattern, searchId) => {
189
+ const thumbnailService = (0, import_file_explorer_core.getThumbnailService)();
190
+ const pathToItem = async (filePath) => {
191
+ try {
192
+ const stats = await import_node_fs.promises.stat(filePath);
193
+ const fileType = (0, import_file_explorer_core.getFileType)(filePath, stats);
194
+ const item = {
195
+ id: filePath,
196
+ name: import_node_path.default.basename(filePath),
197
+ type: fileType,
198
+ size: stats.isDirectory() ? void 0 : (0, import_file_explorer_core.formatFileSize)(stats.size),
199
+ dateModified: (0, import_file_explorer_core.formatDateTime)(stats.mtime),
200
+ url: electronUrlEncoder(filePath)
201
+ };
202
+ if (thumbnailService) {
203
+ const thumbnailUrl = await thumbnailService.getThumbnailUrl(filePath);
204
+ if (thumbnailUrl) {
205
+ item.thumbnailUrl = thumbnailUrl;
206
+ }
207
+ }
208
+ return item;
209
+ } catch {
210
+ return null;
211
+ }
212
+ };
213
+ (0, import_file_explorer_core.searchFilesStream)(searchPath, pattern, async (paths, done) => {
214
+ const items = [];
215
+ for (const p of paths) {
216
+ const item = await pathToItem(p);
217
+ if (item) items.push(item);
218
+ }
219
+ event.sender.send(channel("searchResults"), {
220
+ searchId,
221
+ items,
222
+ done
223
+ });
224
+ }, 100);
225
+ return { success: true };
226
+ });
227
+ console.log("\u2705 File Explorer IPC handlers registered");
228
+ }
229
+ // Annotate the CommonJS export names for ESM import in node:
230
+ 0 && (module.exports = {
231
+ createElectronAdapter,
232
+ electronUrlEncoder,
233
+ registerFileExplorerHandlers,
234
+ setClipboardAdapter
235
+ });
@@ -0,0 +1,27 @@
1
+ import { PlatformAdapter, ClipboardAdapter } from '@huyooo/file-explorer-core';
2
+
3
+ /**
4
+ * File Explorer Electron Bridge - Main Process
5
+ *
6
+ * 只负责 IPC 通信,具体实现在 @huyooo/file-explorer-core 中
7
+ */
8
+
9
+ /**
10
+ * 设置剪贴板适配器
11
+ * 在主进程中调用,注入 clipboard-files 模块
12
+ */
13
+ declare function setClipboardAdapter(adapter: ClipboardAdapter): void;
14
+ /**
15
+ * 创建 Electron 平台适配器
16
+ */
17
+ declare function createElectronAdapter(): PlatformAdapter;
18
+ /**
19
+ * URL 编码器(使用 app:// 协议)
20
+ */
21
+ declare function electronUrlEncoder(filePath: string): string;
22
+ /**
23
+ * 注册文件系统 IPC handlers
24
+ */
25
+ declare function registerFileExplorerHandlers(): void;
26
+
27
+ export { createElectronAdapter, electronUrlEncoder, registerFileExplorerHandlers, setClipboardAdapter };
@@ -0,0 +1,27 @@
1
+ import { PlatformAdapter, ClipboardAdapter } from '@huyooo/file-explorer-core';
2
+
3
+ /**
4
+ * File Explorer Electron Bridge - Main Process
5
+ *
6
+ * 只负责 IPC 通信,具体实现在 @huyooo/file-explorer-core 中
7
+ */
8
+
9
+ /**
10
+ * 设置剪贴板适配器
11
+ * 在主进程中调用,注入 clipboard-files 模块
12
+ */
13
+ declare function setClipboardAdapter(adapter: ClipboardAdapter): void;
14
+ /**
15
+ * 创建 Electron 平台适配器
16
+ */
17
+ declare function createElectronAdapter(): PlatformAdapter;
18
+ /**
19
+ * URL 编码器(使用 app:// 协议)
20
+ */
21
+ declare function electronUrlEncoder(filePath: string): string;
22
+ /**
23
+ * 注册文件系统 IPC handlers
24
+ */
25
+ declare function registerFileExplorerHandlers(): void;
26
+
27
+ export { createElectronAdapter, electronUrlEncoder, registerFileExplorerHandlers, setClipboardAdapter };
@@ -0,0 +1,220 @@
1
+ // src/main/index.ts
2
+ import { ipcMain, shell } from "electron";
3
+ import path from "path";
4
+ import {
5
+ readDirectory,
6
+ readFileContent,
7
+ readImageAsBase64,
8
+ writeFileContent,
9
+ createFolder,
10
+ createFile,
11
+ deleteFiles,
12
+ renameFile,
13
+ copyFiles,
14
+ moveFiles,
15
+ getFileInfo,
16
+ getSystemPath,
17
+ getThumbnailService,
18
+ getApplicationIcon,
19
+ copyFilesToClipboard,
20
+ getClipboardFiles,
21
+ pasteFiles,
22
+ searchFiles,
23
+ searchFilesStream,
24
+ getFileType,
25
+ formatFileSize,
26
+ formatDateTime
27
+ } from "@huyooo/file-explorer-core";
28
+ import { promises as fs } from "fs";
29
+ var CHANNEL_PREFIX = "file-explorer";
30
+ var channel = (name) => `${CHANNEL_PREFIX}:${name}`;
31
+ var clipboardAdapter = null;
32
+ function setClipboardAdapter(adapter) {
33
+ clipboardAdapter = adapter;
34
+ }
35
+ function createElectronAdapter() {
36
+ return {
37
+ trashItem: async (filePath) => {
38
+ await shell.trashItem(filePath);
39
+ },
40
+ openPath: async (filePath) => {
41
+ await shell.openPath(filePath);
42
+ }
43
+ };
44
+ }
45
+ function electronUrlEncoder(filePath) {
46
+ const encodedPath = encodeURIComponent(filePath);
47
+ return `app://file${encodedPath}`;
48
+ }
49
+ function registerFileExplorerHandlers() {
50
+ const adapter = createElectronAdapter();
51
+ ipcMain.handle(channel("readDirectory"), async (_event, dirPath) => {
52
+ const thumbnailService = getThumbnailService();
53
+ return await readDirectory(dirPath, {
54
+ urlEncoder: electronUrlEncoder,
55
+ getThumbnailUrl: thumbnailService ? (filePath) => thumbnailService.getThumbnailUrl(filePath) : void 0
56
+ });
57
+ });
58
+ ipcMain.handle(channel("readSystemPath"), async (_event, pathId) => {
59
+ const systemPath = getSystemPath(pathId);
60
+ if (!systemPath) return [];
61
+ const thumbnailService = getThumbnailService();
62
+ return await readDirectory(systemPath, {
63
+ urlEncoder: electronUrlEncoder,
64
+ getThumbnailUrl: thumbnailService ? (filePath) => thumbnailService.getThumbnailUrl(filePath) : void 0
65
+ });
66
+ });
67
+ ipcMain.handle(channel("getSystemPath"), async (_event, pathId) => {
68
+ return getSystemPath(pathId);
69
+ });
70
+ ipcMain.handle(channel("readFileContent"), async (_event, filePath) => {
71
+ return await readFileContent(filePath);
72
+ });
73
+ ipcMain.handle(channel("writeFileContent"), async (_event, filePath, content) => {
74
+ return await writeFileContent(filePath, content);
75
+ });
76
+ ipcMain.handle(channel("createFolder"), async (_event, parentDir, folderName) => {
77
+ const folderPath = path.join(parentDir, folderName);
78
+ return await createFolder(folderPath);
79
+ });
80
+ ipcMain.handle(channel("createFile"), async (_event, parentDir, fileName, content) => {
81
+ const filePath = path.join(parentDir, fileName);
82
+ return await createFile(filePath, content);
83
+ });
84
+ ipcMain.handle(channel("deleteFiles"), async (_event, paths) => {
85
+ const thumbnailService = getThumbnailService();
86
+ return await deleteFiles(paths, {
87
+ adapter,
88
+ useTrash: true,
89
+ onDeleted: (p) => thumbnailService?.deleteThumbnail(p)
90
+ });
91
+ });
92
+ ipcMain.handle(channel("renameFile"), async (_event, oldPath, newPath) => {
93
+ const thumbnailService = getThumbnailService();
94
+ return await renameFile(oldPath, newPath, {
95
+ onRenamed: (old) => thumbnailService?.deleteThumbnail(old)
96
+ });
97
+ });
98
+ ipcMain.handle(channel("copyFiles"), async (_event, sourcePaths, targetDir) => {
99
+ return await copyFiles(sourcePaths, targetDir);
100
+ });
101
+ ipcMain.handle(channel("moveFiles"), async (_event, sourcePaths, targetDir) => {
102
+ return await moveFiles(sourcePaths, targetDir);
103
+ });
104
+ ipcMain.handle(channel("getFileInfo"), async (_event, filePath) => {
105
+ return await getFileInfo(filePath);
106
+ });
107
+ ipcMain.handle(channel("readImageAsBase64"), async (_event, imagePath) => {
108
+ return await readImageAsBase64(imagePath);
109
+ });
110
+ ipcMain.handle(channel("openPath"), async (_event, filePath) => {
111
+ try {
112
+ await shell.openPath(filePath);
113
+ return { success: true };
114
+ } catch (error) {
115
+ return { success: false, error: String(error) };
116
+ }
117
+ });
118
+ ipcMain.handle(channel("getApplicationIcon"), async (_event, appPath) => {
119
+ return await getApplicationIcon(appPath);
120
+ });
121
+ ipcMain.handle(channel("getThumbnailUrl"), async (_event, filePath) => {
122
+ const thumbnailService = getThumbnailService();
123
+ if (!thumbnailService) return null;
124
+ return await thumbnailService.getThumbnailUrl(filePath);
125
+ });
126
+ ipcMain.handle(channel("copyFilesToClipboard"), async (_event, filePaths) => {
127
+ if (!clipboardAdapter) {
128
+ return { success: false, error: "\u526A\u8D34\u677F\u9002\u914D\u5668\u672A\u521D\u59CB\u5316" };
129
+ }
130
+ return await copyFilesToClipboard(filePaths, clipboardAdapter);
131
+ });
132
+ ipcMain.handle(channel("getClipboardFiles"), async () => {
133
+ if (!clipboardAdapter) {
134
+ return { success: false, error: "\u526A\u8D34\u677F\u9002\u914D\u5668\u672A\u521D\u59CB\u5316" };
135
+ }
136
+ return getClipboardFiles(clipboardAdapter);
137
+ });
138
+ ipcMain.handle(channel("pasteFiles"), async (_event, targetDir, sourcePaths) => {
139
+ return await pasteFiles(targetDir, sourcePaths);
140
+ });
141
+ ipcMain.handle(channel("searchFiles"), async (_event, searchPath, pattern, maxDepth) => {
142
+ try {
143
+ const filePaths = await searchFiles(searchPath, pattern, maxDepth);
144
+ const thumbnailService = getThumbnailService();
145
+ const maxResults = 100;
146
+ const results = [];
147
+ for (const filePath of filePaths.slice(0, maxResults)) {
148
+ try {
149
+ const stats = await fs.stat(filePath);
150
+ const fileType = getFileType(filePath, stats);
151
+ const item = {
152
+ id: filePath,
153
+ name: path.basename(filePath),
154
+ type: fileType,
155
+ size: stats.isDirectory() ? void 0 : formatFileSize(stats.size),
156
+ dateModified: formatDateTime(stats.mtime),
157
+ url: electronUrlEncoder(filePath)
158
+ };
159
+ if (thumbnailService) {
160
+ const thumbnailUrl = await thumbnailService.getThumbnailUrl(filePath);
161
+ if (thumbnailUrl) {
162
+ item.thumbnailUrl = thumbnailUrl;
163
+ }
164
+ }
165
+ results.push(item);
166
+ } catch {
167
+ }
168
+ }
169
+ return { success: true, data: { items: results, total: filePaths.length } };
170
+ } catch (error) {
171
+ return { success: false, error: String(error) };
172
+ }
173
+ });
174
+ ipcMain.handle(channel("searchFilesStream"), async (event, searchPath, pattern, searchId) => {
175
+ const thumbnailService = getThumbnailService();
176
+ const pathToItem = async (filePath) => {
177
+ try {
178
+ const stats = await fs.stat(filePath);
179
+ const fileType = getFileType(filePath, stats);
180
+ const item = {
181
+ id: filePath,
182
+ name: path.basename(filePath),
183
+ type: fileType,
184
+ size: stats.isDirectory() ? void 0 : formatFileSize(stats.size),
185
+ dateModified: formatDateTime(stats.mtime),
186
+ url: electronUrlEncoder(filePath)
187
+ };
188
+ if (thumbnailService) {
189
+ const thumbnailUrl = await thumbnailService.getThumbnailUrl(filePath);
190
+ if (thumbnailUrl) {
191
+ item.thumbnailUrl = thumbnailUrl;
192
+ }
193
+ }
194
+ return item;
195
+ } catch {
196
+ return null;
197
+ }
198
+ };
199
+ searchFilesStream(searchPath, pattern, async (paths, done) => {
200
+ const items = [];
201
+ for (const p of paths) {
202
+ const item = await pathToItem(p);
203
+ if (item) items.push(item);
204
+ }
205
+ event.sender.send(channel("searchResults"), {
206
+ searchId,
207
+ items,
208
+ done
209
+ });
210
+ }, 100);
211
+ return { success: true };
212
+ });
213
+ console.log("\u2705 File Explorer IPC handlers registered");
214
+ }
215
+ export {
216
+ createElectronAdapter,
217
+ electronUrlEncoder,
218
+ registerFileExplorerHandlers,
219
+ setClipboardAdapter
220
+ };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/preload/index.ts
21
+ var preload_exports = {};
22
+ __export(preload_exports, {
23
+ createFileExplorerAPI: () => createFileExplorerAPI,
24
+ exposeFileExplorerAPI: () => exposeFileExplorerAPI
25
+ });
26
+ module.exports = __toCommonJS(preload_exports);
27
+ var import_electron = require("electron");
28
+ var CHANNEL_PREFIX = "file-explorer";
29
+ var channel = (name) => `${CHANNEL_PREFIX}:${name}`;
30
+ function createFileExplorerAPI() {
31
+ return {
32
+ readDirectory: (dirPath) => import_electron.ipcRenderer.invoke(channel("readDirectory"), dirPath),
33
+ readSystemPath: (pathId) => import_electron.ipcRenderer.invoke(channel("readSystemPath"), pathId),
34
+ getSystemPath: (pathId) => import_electron.ipcRenderer.invoke(channel("getSystemPath"), pathId),
35
+ readFileContent: (filePath) => import_electron.ipcRenderer.invoke(channel("readFileContent"), filePath),
36
+ writeFileContent: (filePath, content) => import_electron.ipcRenderer.invoke(channel("writeFileContent"), filePath, content),
37
+ createFolder: (parentDir, folderName) => import_electron.ipcRenderer.invoke(channel("createFolder"), parentDir, folderName),
38
+ createFile: (parentDir, fileName, content) => import_electron.ipcRenderer.invoke(channel("createFile"), parentDir, fileName, content),
39
+ deleteFiles: (paths) => import_electron.ipcRenderer.invoke(channel("deleteFiles"), paths),
40
+ renameFile: (oldPath, newPath) => import_electron.ipcRenderer.invoke(channel("renameFile"), oldPath, newPath),
41
+ copyFiles: (sourcePaths, targetDir) => import_electron.ipcRenderer.invoke(channel("copyFiles"), sourcePaths, targetDir),
42
+ moveFiles: (sourcePaths, targetDir) => import_electron.ipcRenderer.invoke(channel("moveFiles"), sourcePaths, targetDir),
43
+ getFileInfo: (filePath) => import_electron.ipcRenderer.invoke(channel("getFileInfo"), filePath),
44
+ readImageAsBase64: (imagePath) => import_electron.ipcRenderer.invoke(channel("readImageAsBase64"), imagePath),
45
+ openPath: (filePath) => import_electron.ipcRenderer.invoke(channel("openPath"), filePath),
46
+ getApplicationIcon: (appPath) => import_electron.ipcRenderer.invoke(channel("getApplicationIcon"), appPath),
47
+ getThumbnailUrl: (filePath) => import_electron.ipcRenderer.invoke(channel("getThumbnailUrl"), filePath),
48
+ copyFilesToClipboard: (filePaths) => import_electron.ipcRenderer.invoke(channel("copyFilesToClipboard"), filePaths),
49
+ getClipboardFiles: () => import_electron.ipcRenderer.invoke(channel("getClipboardFiles")),
50
+ pasteFiles: (targetDir, sourcePaths) => import_electron.ipcRenderer.invoke(channel("pasteFiles"), targetDir, sourcePaths),
51
+ searchFiles: (searchPath, pattern, maxDepth) => import_electron.ipcRenderer.invoke(channel("searchFiles"), searchPath, pattern, maxDepth),
52
+ searchFilesStream: (searchPath, pattern, searchId) => import_electron.ipcRenderer.invoke(channel("searchFilesStream"), searchPath, pattern, searchId),
53
+ onSearchResults: (callback) => {
54
+ const handler = (_event, data) => {
55
+ callback(data);
56
+ };
57
+ import_electron.ipcRenderer.on(channel("searchResults"), handler);
58
+ return () => import_electron.ipcRenderer.removeListener(channel("searchResults"), handler);
59
+ }
60
+ };
61
+ }
62
+ function exposeFileExplorerAPI(apiName = "fileExplorerAPI") {
63
+ const api = createFileExplorerAPI();
64
+ import_electron.contextBridge.exposeInMainWorld(apiName, api);
65
+ console.log(`\u2705 File Explorer API exposed as window.${apiName}`);
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ createFileExplorerAPI,
70
+ exposeFileExplorerAPI
71
+ });