feat(desktop): fileTransfer bridge for plugin workbench webviews

This commit is contained in:
Jinpy authored and GitHub committed 2026-09-21 02:03:12 +08:00
1 parent 9b82ce86f9
commit bc490772eb
11 files changed
+1111 -2

No files matched your search

+22
View File
@@ -5128,3 +5128,25 @@ export async function refreshConnections(): Promise<void> {
export * from "@/lib/backend/mq-http";
export * from "@/lib/backend/mqtt-http";
// ---------------------------------------------------------------------------
// Plugin local file streaming (native dialogs / OS drops are Tauri-only)
// ---------------------------------------------------------------------------
import type { PluginLocalFileChunk, PluginLocalFileHandle, PluginLocalFileWriteResult } from "./tauri";
export async function openPluginLocalFile(_pluginId: string, _path: string, _write: boolean): Promise<PluginLocalFileHandle> {
throw new Error("Plugin local file access is not available in the web backend");
}
export async function readPluginLocalFileChunk(_pluginId: string, _handleId: number, _offset: number, _length?: number): Promise<PluginLocalFileChunk> {
throw new Error("Plugin local file access is not available in the web backend");
}
export async function writePluginLocalFileChunk(_pluginId: string, _handleId: number, _offset: number, _dataBase64: string): Promise<PluginLocalFileWriteResult> {
throw new Error("Plugin local file access is not available in the web backend");
}
export async function closePluginLocalFile(_pluginId: string, _handleId: number): Promise<void> {
throw new Error("Plugin local file access is not available in the web backend");
}
+35
View File
@@ -2419,6 +2419,41 @@ export async function sendPluginBinary(pluginId: string, channel: string, dataBa
return invoke("send_plugin_binary", { pluginId, channel, dataBase64 });
}
export interface PluginLocalFileHandle {
handleId: number;
name: string;
size: number;
contentType: string;
write: boolean;
}
export interface PluginLocalFileChunk {
dataBase64: string;
length: number;
eof: boolean;
}
export interface PluginLocalFileWriteResult {
written: number;
nextOffset: number;
}
export async function openPluginLocalFile(pluginId: string, path: string, write: boolean): Promise<PluginLocalFileHandle> {
return invoke("plugin_file_open", { pluginId, path, write });
}
export async function readPluginLocalFileChunk(pluginId: string, handleId: number, offset: number, length?: number): Promise<PluginLocalFileChunk> {
return invoke("plugin_file_read", { pluginId, handleId, offset, length });
}
export async function writePluginLocalFileChunk(pluginId: string, handleId: number, offset: number, dataBase64: string): Promise<PluginLocalFileWriteResult> {
return invoke("plugin_file_write", { pluginId, handleId, offset, dataBase64 });
}
export async function closePluginLocalFile(pluginId: string, handleId: number): Promise<void> {
return invoke("plugin_file_close", { pluginId, handleId });
}
export async function listPluginFilesystemEntries(pluginId: string, providerId: string, options: { connectionId?: string; uri?: string; cursor?: string; limit?: number } = {}): Promise<PluginFilesystemListResult> {
return invoke("list_plugin_filesystem_entries", { pluginId, providerId, ...options });
}