@ai-switch/tauri-plugin-runtime 0.1.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.
- package/LICENSE +21 -0
- package/README.md +327 -0
- package/THIRD_PARTY_NOTICES.md +210 -0
- package/dist/bridge/handshake.d.ts +11 -0
- package/dist/bridge/json-codec.d.ts +4 -0
- package/dist/bridge/rpc-peer.d.ts +7 -0
- package/dist/bridge/rpc-types.d.ts +20 -0
- package/dist/chunk-CFQSUF5W.js +1794 -0
- package/dist/chunk-JSBRDJBE.js +30 -0
- package/dist/chunk-K5YWIJN6.js +389 -0
- package/dist/chunk-PW7XHHWG.js +403 -0
- package/dist/chunk-RKQEK7DY.js +13879 -0
- package/dist/chunk-WT62GTMC.js +18 -0
- package/dist/chunk-YI6NQ6WR.js +513 -0
- package/dist/host/event-router.d.ts +19 -0
- package/dist/host/file-handles.d.ts +15 -0
- package/dist/host/host.d.ts +2 -0
- package/dist/host/index.d.ts +4 -0
- package/dist/host/index.js +791 -0
- package/dist/host/policy.d.ts +7 -0
- package/dist/host/requests.d.ts +13 -0
- package/dist/host/types.d.ts +19 -0
- package/dist/host/view.d.ts +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -0
- package/dist/node/buffer.d.ts +7 -0
- package/dist/node/buffer.js +8 -0
- package/dist/node/events.d.ts +12 -0
- package/dist/node/events.js +458 -0
- package/dist/node/fs/backend.d.ts +8 -0
- package/dist/node/fs/callback-types.d.ts +43 -0
- package/dist/node/fs/callbacks.d.ts +3 -0
- package/dist/node/fs/client.d.ts +3 -0
- package/dist/node/fs/errors.d.ts +5 -0
- package/dist/node/fs/lifecycle.d.ts +11 -0
- package/dist/node/fs/options.d.ts +7 -0
- package/dist/node/fs/promises.d.ts +33 -0
- package/dist/node/fs/promises.js +30 -0
- package/dist/node/fs/transfer.d.ts +7 -0
- package/dist/node/fs/types.d.ts +86 -0
- package/dist/node/fs.d.ts +36 -0
- package/dist/node/fs.js +92 -0
- package/dist/node/path.d.ts +20 -0
- package/dist/node/path.js +434 -0
- package/dist/plugin/client.d.ts +4 -0
- package/dist/plugin/connection.d.ts +6 -0
- package/dist/plugin/errors.d.ts +3 -0
- package/dist/plugin/index.d.ts +6 -0
- package/dist/plugin/index.js +12 -0
- package/dist/plugin/types.d.ts +28 -0
- package/dist/protocol/capabilities.d.ts +8 -0
- package/dist/protocol/errors.d.ts +14 -0
- package/dist/protocol/generated/capabilities.generated.d.ts +56 -0
- package/dist/protocol/generated/fs.generated.d.ts +178 -0
- package/dist/protocol/generated/host-event.generated.d.ts +17 -0
- package/dist/protocol/generated/manifest.generated.d.ts +64 -0
- package/dist/protocol/generated/session.generated.d.ts +93 -0
- package/dist/protocol/generated/types.generated.d.ts +6 -0
- package/dist/protocol/generated/validators.generated.d.mts +24 -0
- package/dist/protocol/generated/wire.generated.d.ts +63 -0
- package/dist/protocol/index.d.ts +18 -0
- package/dist/protocol/index.js +746 -0
- package/dist/protocol/json-safety.d.ts +3 -0
- package/dist/protocol/limits.d.ts +11 -0
- package/dist/protocol/manifest.d.ts +5 -0
- package/dist/protocol/path-policy.d.ts +2 -0
- package/dist/protocol/schema/capabilities.schema.json +301 -0
- package/dist/protocol/schema/fs.schema.json +900 -0
- package/dist/protocol/schema/host-event.schema.json +116 -0
- package/dist/protocol/schema/manifest.schema.json +60 -0
- package/dist/protocol/schema/session.schema.json +145 -0
- package/dist/protocol/schema/wire.schema.json +358 -0
- package/dist/protocol/session.d.ts +3 -0
- package/dist/protocol/types.d.ts +27 -0
- package/dist/protocol/validation.d.ts +2 -0
- package/dist/protocol/wire.d.ts +16 -0
- package/package.json +95 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FsPromises } from "./types.js";
|
|
2
|
+
export declare const readFile: {
|
|
3
|
+
(path: string, options?: import("./types.js").ReadBufferOptions): Promise<import("buffer/index.js").Buffer>;
|
|
4
|
+
(path: string, options: import("./types.js").ReadTextOptions): Promise<string>;
|
|
5
|
+
(path: string, options?: import("./types.js").ReadFileOptions): Promise<import("buffer/index.js").Buffer | string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const writeFile: (path: string, data: string | Uint8Array, options?: import("./types.js").WriteFileOptions) => Promise<void>;
|
|
8
|
+
export declare const appendFile: (path: string, data: string | Uint8Array, options?: import("./types.js").AppendFileOptions) => Promise<void>;
|
|
9
|
+
export declare const readdir: {
|
|
10
|
+
(path: string, options?: {
|
|
11
|
+
withFileTypes?: false;
|
|
12
|
+
}): Promise<string[]>;
|
|
13
|
+
(path: string, options: {
|
|
14
|
+
withFileTypes: true;
|
|
15
|
+
}): Promise<import("./types.js").DirectoryEntry[]>;
|
|
16
|
+
(path: string, options?: import("./types.js").ReaddirOptions): Promise<string[] | import("./types.js").DirectoryEntry[]>;
|
|
17
|
+
};
|
|
18
|
+
export declare const stat: (path: string) => Promise<import("./types.js").FileStats>;
|
|
19
|
+
export declare const mkdir: {
|
|
20
|
+
(path: string, options?: {
|
|
21
|
+
recursive?: false;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
(path: string, options: {
|
|
24
|
+
recursive: true;
|
|
25
|
+
}): Promise<string | undefined>;
|
|
26
|
+
(path: string, options?: import("./types.js").MkdirOptions): Promise<string | undefined>;
|
|
27
|
+
};
|
|
28
|
+
export declare const rename: (from: string, to: string) => Promise<void>;
|
|
29
|
+
export declare const copyFile: (from: string, to: string) => Promise<void>;
|
|
30
|
+
export declare const rm: (path: string, options?: import("./types.js").RemoveOptions) => Promise<void>;
|
|
31
|
+
declare const promises: FsPromises;
|
|
32
|
+
export default promises;
|
|
33
|
+
export type { FsPromises, FsError, FileStats, DirectoryEntry, ReadFileOptions, ReadBufferOptions, ReadTextOptions, WriteFileOptions, AppendFileOptions, ReaddirOptions, MkdirOptions, RemoveOptions } from "./types.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendFile,
|
|
3
|
+
copyFile,
|
|
4
|
+
mkdir,
|
|
5
|
+
promises_default,
|
|
6
|
+
readFile,
|
|
7
|
+
readdir,
|
|
8
|
+
rename,
|
|
9
|
+
rm,
|
|
10
|
+
stat,
|
|
11
|
+
writeFile
|
|
12
|
+
} from "../../chunk-YI6NQ6WR.js";
|
|
13
|
+
import "../../chunk-K5YWIJN6.js";
|
|
14
|
+
import "../../chunk-PW7XHHWG.js";
|
|
15
|
+
import "../../chunk-RKQEK7DY.js";
|
|
16
|
+
import "../../chunk-WT62GTMC.js";
|
|
17
|
+
import "../../chunk-CFQSUF5W.js";
|
|
18
|
+
import "../../chunk-JSBRDJBE.js";
|
|
19
|
+
export {
|
|
20
|
+
appendFile,
|
|
21
|
+
copyFile,
|
|
22
|
+
promises_default as default,
|
|
23
|
+
mkdir,
|
|
24
|
+
readFile,
|
|
25
|
+
readdir,
|
|
26
|
+
rename,
|
|
27
|
+
rm,
|
|
28
|
+
stat,
|
|
29
|
+
writeFile
|
|
30
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Buffer } from "../buffer.js";
|
|
2
|
+
import { type FileContext } from "./lifecycle.js";
|
|
3
|
+
import { type FsBackend } from "./backend.js";
|
|
4
|
+
export declare function createTransferClient(backend: FsBackend): {
|
|
5
|
+
read(context: FileContext, path: string): Promise<Buffer>;
|
|
6
|
+
write(context: FileContext, path: string, data: Buffer, mode: "w" | "wx" | "a" | "ax"): Promise<void>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Buffer } from "../buffer.js";
|
|
2
|
+
import type { PluginApi, ConnectionState } from "../../plugin/types.js";
|
|
3
|
+
import type { Unsubscribe } from "../../protocol/wire.js";
|
|
4
|
+
import type { FsCapabilityMessage } from "../../protocol/generated/types.generated.js";
|
|
5
|
+
export type CapabilityCall = PluginApi["call"];
|
|
6
|
+
export type FsMethod = Extract<FsCapabilityMessage, {
|
|
7
|
+
direction: "request";
|
|
8
|
+
}>["method"];
|
|
9
|
+
export type FsRequest<M extends FsMethod> = Extract<FsCapabilityMessage, {
|
|
10
|
+
direction: "request";
|
|
11
|
+
method: M;
|
|
12
|
+
}>["value"];
|
|
13
|
+
export type FsResult<M extends FsMethod> = Extract<FsCapabilityMessage, {
|
|
14
|
+
direction: "result";
|
|
15
|
+
method: M;
|
|
16
|
+
}>["value"];
|
|
17
|
+
export type ReadBufferOptions = null | {
|
|
18
|
+
encoding?: null;
|
|
19
|
+
};
|
|
20
|
+
export type ReadTextOptions = "utf8" | {
|
|
21
|
+
encoding: "utf8";
|
|
22
|
+
};
|
|
23
|
+
export type ReadFileOptions = ReadBufferOptions | ReadTextOptions;
|
|
24
|
+
export type WriteFileOptions = "utf8" | null | {
|
|
25
|
+
encoding?: "utf8";
|
|
26
|
+
flag?: "w" | "wx";
|
|
27
|
+
};
|
|
28
|
+
export type AppendFileOptions = "utf8" | null | {
|
|
29
|
+
encoding?: "utf8";
|
|
30
|
+
flag?: "a" | "ax";
|
|
31
|
+
};
|
|
32
|
+
export interface DirectoryEntry {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
isFile(): boolean;
|
|
35
|
+
isDirectory(): boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface FileStats {
|
|
38
|
+
readonly size: number;
|
|
39
|
+
readonly mtimeMs: number;
|
|
40
|
+
isFile(): boolean;
|
|
41
|
+
isDirectory(): boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface MkdirOptions {
|
|
44
|
+
recursive?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface RemoveOptions {
|
|
47
|
+
recursive?: boolean;
|
|
48
|
+
force?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface ReaddirOptions {
|
|
51
|
+
withFileTypes?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface FsError extends Error {
|
|
54
|
+
code: string;
|
|
55
|
+
syscall: string;
|
|
56
|
+
path?: string;
|
|
57
|
+
dest?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface FsClientOptions {
|
|
60
|
+
onConnectionChange?: (listener: (state: ConnectionState) => void) => Unsubscribe;
|
|
61
|
+
}
|
|
62
|
+
export interface FsPromises {
|
|
63
|
+
readFile(path: string, options?: ReadBufferOptions): Promise<Buffer>;
|
|
64
|
+
readFile(path: string, options: ReadTextOptions): Promise<string>;
|
|
65
|
+
readFile(path: string, options?: ReadFileOptions): Promise<Buffer | string>;
|
|
66
|
+
writeFile(path: string, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
|
|
67
|
+
appendFile(path: string, data: string | Uint8Array, options?: AppendFileOptions): Promise<void>;
|
|
68
|
+
readdir(path: string, options?: {
|
|
69
|
+
withFileTypes?: false;
|
|
70
|
+
}): Promise<string[]>;
|
|
71
|
+
readdir(path: string, options: {
|
|
72
|
+
withFileTypes: true;
|
|
73
|
+
}): Promise<DirectoryEntry[]>;
|
|
74
|
+
readdir(path: string, options?: ReaddirOptions): Promise<string[] | DirectoryEntry[]>;
|
|
75
|
+
stat(path: string): Promise<FileStats>;
|
|
76
|
+
mkdir(path: string, options?: {
|
|
77
|
+
recursive?: false;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
mkdir(path: string, options: {
|
|
80
|
+
recursive: true;
|
|
81
|
+
}): Promise<string | undefined>;
|
|
82
|
+
mkdir(path: string, options?: MkdirOptions): Promise<string | undefined>;
|
|
83
|
+
rename(from: string, to: string): Promise<void>;
|
|
84
|
+
copyFile(from: string, to: string): Promise<void>;
|
|
85
|
+
rm(path: string, options?: RemoveOptions): Promise<void>;
|
|
86
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import promises from "./fs/promises.js";
|
|
2
|
+
declare const fs: import("./fs.js").CallbackFs;
|
|
3
|
+
export { promises };
|
|
4
|
+
export declare const readFile: {
|
|
5
|
+
(path: string, callback: import("./fs.js").ValueCallback<import("buffer/index.js").Buffer>): void;
|
|
6
|
+
(path: string, options: import("./fs/types.js").ReadBufferOptions | undefined, callback: import("./fs.js").ValueCallback<import("buffer/index.js").Buffer>): void;
|
|
7
|
+
(path: string, options: import("./fs/types.js").ReadTextOptions, callback: import("./fs.js").ValueCallback<string>): void;
|
|
8
|
+
(path: string, options: import("./fs/types.js").ReadFileOptions | undefined, callback: import("./fs.js").ValueCallback<import("buffer/index.js").Buffer | string>): void;
|
|
9
|
+
}, writeFile: {
|
|
10
|
+
(path: string, data: string | Uint8Array, callback: import("./fs.js").VoidCallback): void;
|
|
11
|
+
(path: string, data: string | Uint8Array, options: import("./fs/types.js").WriteFileOptions | undefined, callback: import("./fs.js").VoidCallback): void;
|
|
12
|
+
}, appendFile: {
|
|
13
|
+
(path: string, data: string | Uint8Array, callback: import("./fs.js").VoidCallback): void;
|
|
14
|
+
(path: string, data: string | Uint8Array, options: import("./fs/types.js").AppendFileOptions | undefined, callback: import("./fs.js").VoidCallback): void;
|
|
15
|
+
}, readdir: {
|
|
16
|
+
(path: string, callback: import("./fs.js").ValueCallback<string[]>): void;
|
|
17
|
+
(path: string, options: {
|
|
18
|
+
withFileTypes?: false;
|
|
19
|
+
} | undefined, callback: import("./fs.js").ValueCallback<string[]>): void;
|
|
20
|
+
(path: string, options: {
|
|
21
|
+
withFileTypes: true;
|
|
22
|
+
}, callback: import("./fs.js").ValueCallback<import("./fs.js").DirectoryEntry[]>): void;
|
|
23
|
+
(path: string, options: import("./fs/types.js").ReaddirOptions | undefined, callback: import("./fs.js").ValueCallback<string[] | import("./fs.js").DirectoryEntry[]>): void;
|
|
24
|
+
}, stat: (path: string, callback: import("./fs.js").ValueCallback<import("./fs.js").FileStats>) => void, mkdir: {
|
|
25
|
+
(path: string, callback: import("./fs.js").VoidCallback): void;
|
|
26
|
+
(path: string, options: {
|
|
27
|
+
recursive?: false;
|
|
28
|
+
} | undefined, callback: import("./fs.js").VoidCallback): void;
|
|
29
|
+
(path: string, options: import("./fs/types.js").MkdirOptions, callback: import("./fs.js").ValueCallback<string | undefined>): void;
|
|
30
|
+
}, rename: (from: string, to: string, callback: import("./fs.js").VoidCallback) => void, copyFile: (from: string, to: string, callback: import("./fs.js").VoidCallback) => void, rm: {
|
|
31
|
+
(path: string, callback: import("./fs.js").VoidCallback): void;
|
|
32
|
+
(path: string, options: import("./fs/types.js").RemoveOptions | undefined, callback: import("./fs.js").VoidCallback): void;
|
|
33
|
+
}, readFileSync: import("./fs/callback-types.js").UnsupportedSync, writeFileSync: import("./fs/callback-types.js").UnsupportedSync, appendFileSync: import("./fs/callback-types.js").UnsupportedSync, readdirSync: import("./fs/callback-types.js").UnsupportedSync, statSync: import("./fs/callback-types.js").UnsupportedSync, mkdirSync: import("./fs/callback-types.js").UnsupportedSync, renameSync: import("./fs/callback-types.js").UnsupportedSync, copyFileSync: import("./fs/callback-types.js").UnsupportedSync, rmSync: import("./fs/callback-types.js").UnsupportedSync;
|
|
34
|
+
export default fs;
|
|
35
|
+
export type { CallbackFs, ValueCallback, VoidCallback } from "./fs/callback-types.js";
|
|
36
|
+
export type { FsPromises, FsError, DirectoryEntry, FileStats } from "./fs/types.js";
|
package/dist/node/fs.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promises_default,
|
|
3
|
+
unsupportedSync
|
|
4
|
+
} from "../chunk-YI6NQ6WR.js";
|
|
5
|
+
import "../chunk-K5YWIJN6.js";
|
|
6
|
+
import "../chunk-PW7XHHWG.js";
|
|
7
|
+
import "../chunk-RKQEK7DY.js";
|
|
8
|
+
import "../chunk-WT62GTMC.js";
|
|
9
|
+
import "../chunk-CFQSUF5W.js";
|
|
10
|
+
import "../chunk-JSBRDJBE.js";
|
|
11
|
+
|
|
12
|
+
// src/node/fs/callbacks.ts
|
|
13
|
+
function createCallbackFs(promises) {
|
|
14
|
+
const methods = ["readFile", "writeFile", "appendFile", "readdir", "stat", "mkdir", "rename", "copyFile", "rm"];
|
|
15
|
+
const wrappers = { promises };
|
|
16
|
+
for (const method of methods) {
|
|
17
|
+
wrappers[method] = (...args) => {
|
|
18
|
+
const callback = args.pop();
|
|
19
|
+
if (typeof callback !== "function") throw new TypeError("A filesystem callback function is required.");
|
|
20
|
+
const deliver = (...values) => {
|
|
21
|
+
try {
|
|
22
|
+
callback(...values);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
throw error;
|
|
26
|
+
}, 0);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
let result;
|
|
30
|
+
try {
|
|
31
|
+
result = Reflect.apply(promises[method], promises, args);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
result = Promise.reject(error);
|
|
34
|
+
}
|
|
35
|
+
void result.then((value) => {
|
|
36
|
+
if (method === "writeFile" || method === "appendFile" || method === "rename" || method === "copyFile" || method === "rm") deliver(null);
|
|
37
|
+
else deliver(null, value);
|
|
38
|
+
}, (error) => {
|
|
39
|
+
if (method === "readFile" || method === "readdir" || method === "stat" || method === "mkdir") deliver(error, void 0);
|
|
40
|
+
else deliver(error);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
wrappers[`${method}Sync`] = unsupportedSync;
|
|
44
|
+
}
|
|
45
|
+
return Object.freeze(wrappers);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/node/fs.ts
|
|
49
|
+
var fs = createCallbackFs(promises_default);
|
|
50
|
+
var {
|
|
51
|
+
readFile,
|
|
52
|
+
writeFile,
|
|
53
|
+
appendFile,
|
|
54
|
+
readdir,
|
|
55
|
+
stat,
|
|
56
|
+
mkdir,
|
|
57
|
+
rename,
|
|
58
|
+
copyFile,
|
|
59
|
+
rm,
|
|
60
|
+
readFileSync,
|
|
61
|
+
writeFileSync,
|
|
62
|
+
appendFileSync,
|
|
63
|
+
readdirSync,
|
|
64
|
+
statSync,
|
|
65
|
+
mkdirSync,
|
|
66
|
+
renameSync,
|
|
67
|
+
copyFileSync,
|
|
68
|
+
rmSync
|
|
69
|
+
} = fs;
|
|
70
|
+
var fs_default = fs;
|
|
71
|
+
export {
|
|
72
|
+
appendFile,
|
|
73
|
+
appendFileSync,
|
|
74
|
+
copyFile,
|
|
75
|
+
copyFileSync,
|
|
76
|
+
fs_default as default,
|
|
77
|
+
mkdir,
|
|
78
|
+
mkdirSync,
|
|
79
|
+
promises_default as promises,
|
|
80
|
+
readFile,
|
|
81
|
+
readFileSync,
|
|
82
|
+
readdir,
|
|
83
|
+
readdirSync,
|
|
84
|
+
rename,
|
|
85
|
+
renameSync,
|
|
86
|
+
rm,
|
|
87
|
+
rmSync,
|
|
88
|
+
stat,
|
|
89
|
+
statSync,
|
|
90
|
+
writeFile,
|
|
91
|
+
writeFileSync
|
|
92
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Pure string helpers, not filesystem authorization. All relative paths use /data. */
|
|
2
|
+
export declare const join: (...parts: string[]) => string;
|
|
3
|
+
export declare const resolve: (...parts: string[]) => string;
|
|
4
|
+
export declare const normalize: (path: string) => string;
|
|
5
|
+
export declare const dirname: (path: string) => string;
|
|
6
|
+
export declare const basename: (path: string, suffix?: string) => string;
|
|
7
|
+
export declare const extname: (path: string) => string;
|
|
8
|
+
export declare const isAbsolute: (path: string) => boolean;
|
|
9
|
+
export declare const relative: (from: string, to: string) => string;
|
|
10
|
+
declare const _default: Readonly<{
|
|
11
|
+
join: (...parts: string[]) => string;
|
|
12
|
+
resolve: (...parts: string[]) => string;
|
|
13
|
+
normalize: (path: string) => string;
|
|
14
|
+
dirname: (path: string) => string;
|
|
15
|
+
basename: (path: string, suffix?: string) => string;
|
|
16
|
+
extname: (path: string) => string;
|
|
17
|
+
relative: (from: string, to: string) => string;
|
|
18
|
+
isAbsolute: (path: string) => boolean;
|
|
19
|
+
}>;
|
|
20
|
+
export default _default;
|