fullstacked 0.11.3-1141 → 0.11.3-1150
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/lib/archive/archive.ts +140 -140
- package/lib/archive/index.ts +4 -4
- package/lib/base64.ts +144 -144
- package/lib/bridge/index.ts +53 -53
- package/lib/bridge/platform/android.ts +18 -18
- package/lib/bridge/platform/apple.ts +46 -46
- package/lib/bridge/platform/electron.ts +14 -14
- package/lib/bridge/platform/linux-gtk.ts +48 -48
- package/lib/bridge/platform/linux-qt.ts +68 -68
- package/lib/bridge/platform/node.ts +32 -32
- package/lib/bridge/platform/wasm.ts +17 -17
- package/lib/bridge/platform/windows.ts +49 -49
- package/lib/bridge/serialization.ts +153 -153
- package/lib/components/snackbar.ts +60 -60
- package/lib/connect/index.ts +125 -125
- package/lib/core_message/core_message.ts +76 -57
- package/lib/core_message/index.ts +3 -3
- package/lib/fetch/index.ts +318 -318
- package/lib/fs/fs.ts +157 -157
- package/lib/fs/index.ts +3 -3
- package/lib/fullstacked.d.ts +208 -208
- package/lib/platform/index.ts +14 -14
- package/package.json +2 -2
package/lib/fs/fs.ts
CHANGED
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
import { bridge } from "../bridge";
|
|
2
|
-
import { serializeArgs } from "../bridge/serialization";
|
|
3
|
-
|
|
4
|
-
const te = new TextEncoder();
|
|
5
|
-
|
|
6
|
-
// 2
|
|
7
|
-
export function readFile(path: string): Promise<Uint8Array>;
|
|
8
|
-
export function readFile(
|
|
9
|
-
path: string,
|
|
10
|
-
options: { encoding: "utf8" }
|
|
11
|
-
): Promise<string>;
|
|
12
|
-
export function readFile(path: string, options?: { encoding: "utf8" }) {
|
|
13
|
-
const payload = new Uint8Array([
|
|
14
|
-
2,
|
|
15
|
-
...serializeArgs([path, options?.encoding === "utf8"])
|
|
16
|
-
]);
|
|
17
|
-
|
|
18
|
-
const transformer = ([stringOrBuffer]) => stringOrBuffer;
|
|
19
|
-
|
|
20
|
-
return bridge(payload, transformer);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// 3
|
|
24
|
-
export function writeFile(
|
|
25
|
-
path: string,
|
|
26
|
-
data: string | Uint8Array,
|
|
27
|
-
origin = ""
|
|
28
|
-
): Promise<boolean> {
|
|
29
|
-
if (typeof data === "string") {
|
|
30
|
-
data = te.encode(data);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const payload = new Uint8Array([3, ...serializeArgs([path, data, origin])]);
|
|
34
|
-
|
|
35
|
-
return bridge(payload, ([success]) => success);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 4
|
|
39
|
-
export function unlink(path: string, origin = ""): Promise<boolean> {
|
|
40
|
-
const payload = new Uint8Array([4, ...serializeArgs([path, origin])]);
|
|
41
|
-
|
|
42
|
-
return bridge(payload, ([success]) => success);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type FileInfo = {
|
|
46
|
-
name: string;
|
|
47
|
-
isDirectory: boolean;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// 5
|
|
51
|
-
export function readdir(
|
|
52
|
-
path: string,
|
|
53
|
-
options?: { recursive?: boolean; withFileTypes?: false }
|
|
54
|
-
): Promise<string[]>;
|
|
55
|
-
export function readdir(
|
|
56
|
-
path: string,
|
|
57
|
-
options?: { recursive?: boolean; withFileTypes: true }
|
|
58
|
-
): Promise<FileInfo[]>;
|
|
59
|
-
export function readdir(
|
|
60
|
-
path: string,
|
|
61
|
-
options?: { recursive?: boolean; withFileTypes?: boolean }
|
|
62
|
-
) {
|
|
63
|
-
const payload = new Uint8Array([
|
|
64
|
-
5,
|
|
65
|
-
...serializeArgs([path, !!options?.recursive, !!options?.withFileTypes])
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
const transformer = (items: string[] | (string | boolean)[]) => {
|
|
69
|
-
if (options?.withFileTypes) {
|
|
70
|
-
const dirents: FileInfo[] = [];
|
|
71
|
-
for (let i = 0; i < items.length; i = i + 2) {
|
|
72
|
-
dirents.push({
|
|
73
|
-
name: items[i] as string,
|
|
74
|
-
isDirectory: items[i + 1] as boolean
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return dirents;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return items;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return bridge(payload, transformer);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// 6
|
|
87
|
-
export function mkdir(path: string, origin = ""): Promise<boolean> {
|
|
88
|
-
const payload = new Uint8Array([6, ...serializeArgs([path, origin])]);
|
|
89
|
-
|
|
90
|
-
return bridge(payload, ([success]) => success);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// 7
|
|
94
|
-
export function rmdir(path: string, origin = ""): Promise<boolean> {
|
|
95
|
-
const payload = new Uint8Array([7, ...serializeArgs([path, origin])]);
|
|
96
|
-
|
|
97
|
-
return bridge(payload, ([success]) => success);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// 8
|
|
101
|
-
export function exists(path: string): Promise<{ isFile: boolean }> {
|
|
102
|
-
const payload = new Uint8Array([8, ...serializeArgs([path])]);
|
|
103
|
-
|
|
104
|
-
const transformer = ([exists, isFile]: [boolean, boolean]) => {
|
|
105
|
-
if (!exists) return undefined;
|
|
106
|
-
return { isFile };
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
return bridge(payload, transformer);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// 9
|
|
113
|
-
export function rename(
|
|
114
|
-
oldPath: string,
|
|
115
|
-
newPath: string,
|
|
116
|
-
origin = ""
|
|
117
|
-
): Promise<boolean> {
|
|
118
|
-
const payload = new Uint8Array([
|
|
119
|
-
9,
|
|
120
|
-
...serializeArgs([oldPath, newPath, origin])
|
|
121
|
-
]);
|
|
122
|
-
|
|
123
|
-
return bridge(payload, ([success]) => success);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
type FileStats = {
|
|
127
|
-
name: string;
|
|
128
|
-
size: number;
|
|
129
|
-
modTime: number;
|
|
130
|
-
isDirectory: boolean;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// 10
|
|
134
|
-
export function stat(path: string): Promise<FileStats> {
|
|
135
|
-
const payload = new Uint8Array([10, ...serializeArgs([path])]);
|
|
136
|
-
|
|
137
|
-
const transformer = (responseArgs: any[]) => {
|
|
138
|
-
if (!responseArgs.length) return null;
|
|
139
|
-
|
|
140
|
-
const [name, size, atimeMs, mtimeMs, ctimeMs, isDirectory] =
|
|
141
|
-
responseArgs;
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
name,
|
|
145
|
-
size,
|
|
146
|
-
atimeMs,
|
|
147
|
-
mtimeMs,
|
|
148
|
-
ctimeMs,
|
|
149
|
-
atime: new Date(atimeMs),
|
|
150
|
-
mtime: new Date(mtimeMs),
|
|
151
|
-
ctime: new Date(ctimeMs),
|
|
152
|
-
isDirectory
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
return bridge(payload, transformer);
|
|
157
|
-
}
|
|
1
|
+
import { bridge } from "../bridge";
|
|
2
|
+
import { serializeArgs } from "../bridge/serialization";
|
|
3
|
+
|
|
4
|
+
const te = new TextEncoder();
|
|
5
|
+
|
|
6
|
+
// 2
|
|
7
|
+
export function readFile(path: string): Promise<Uint8Array>;
|
|
8
|
+
export function readFile(
|
|
9
|
+
path: string,
|
|
10
|
+
options: { encoding: "utf8" }
|
|
11
|
+
): Promise<string>;
|
|
12
|
+
export function readFile(path: string, options?: { encoding: "utf8" }) {
|
|
13
|
+
const payload = new Uint8Array([
|
|
14
|
+
2,
|
|
15
|
+
...serializeArgs([path, options?.encoding === "utf8"])
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const transformer = ([stringOrBuffer]) => stringOrBuffer;
|
|
19
|
+
|
|
20
|
+
return bridge(payload, transformer);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 3
|
|
24
|
+
export function writeFile(
|
|
25
|
+
path: string,
|
|
26
|
+
data: string | Uint8Array,
|
|
27
|
+
origin = ""
|
|
28
|
+
): Promise<boolean> {
|
|
29
|
+
if (typeof data === "string") {
|
|
30
|
+
data = te.encode(data);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const payload = new Uint8Array([3, ...serializeArgs([path, data, origin])]);
|
|
34
|
+
|
|
35
|
+
return bridge(payload, ([success]) => success);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 4
|
|
39
|
+
export function unlink(path: string, origin = ""): Promise<boolean> {
|
|
40
|
+
const payload = new Uint8Array([4, ...serializeArgs([path, origin])]);
|
|
41
|
+
|
|
42
|
+
return bridge(payload, ([success]) => success);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type FileInfo = {
|
|
46
|
+
name: string;
|
|
47
|
+
isDirectory: boolean;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// 5
|
|
51
|
+
export function readdir(
|
|
52
|
+
path: string,
|
|
53
|
+
options?: { recursive?: boolean; withFileTypes?: false }
|
|
54
|
+
): Promise<string[]>;
|
|
55
|
+
export function readdir(
|
|
56
|
+
path: string,
|
|
57
|
+
options?: { recursive?: boolean; withFileTypes: true }
|
|
58
|
+
): Promise<FileInfo[]>;
|
|
59
|
+
export function readdir(
|
|
60
|
+
path: string,
|
|
61
|
+
options?: { recursive?: boolean; withFileTypes?: boolean }
|
|
62
|
+
) {
|
|
63
|
+
const payload = new Uint8Array([
|
|
64
|
+
5,
|
|
65
|
+
...serializeArgs([path, !!options?.recursive, !!options?.withFileTypes])
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
const transformer = (items: string[] | (string | boolean)[]) => {
|
|
69
|
+
if (options?.withFileTypes) {
|
|
70
|
+
const dirents: FileInfo[] = [];
|
|
71
|
+
for (let i = 0; i < items.length; i = i + 2) {
|
|
72
|
+
dirents.push({
|
|
73
|
+
name: items[i] as string,
|
|
74
|
+
isDirectory: items[i + 1] as boolean
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return dirents;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return items;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return bridge(payload, transformer);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 6
|
|
87
|
+
export function mkdir(path: string, origin = ""): Promise<boolean> {
|
|
88
|
+
const payload = new Uint8Array([6, ...serializeArgs([path, origin])]);
|
|
89
|
+
|
|
90
|
+
return bridge(payload, ([success]) => success);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 7
|
|
94
|
+
export function rmdir(path: string, origin = ""): Promise<boolean> {
|
|
95
|
+
const payload = new Uint8Array([7, ...serializeArgs([path, origin])]);
|
|
96
|
+
|
|
97
|
+
return bridge(payload, ([success]) => success);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 8
|
|
101
|
+
export function exists(path: string): Promise<{ isFile: boolean }> {
|
|
102
|
+
const payload = new Uint8Array([8, ...serializeArgs([path])]);
|
|
103
|
+
|
|
104
|
+
const transformer = ([exists, isFile]: [boolean, boolean]) => {
|
|
105
|
+
if (!exists) return undefined;
|
|
106
|
+
return { isFile };
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return bridge(payload, transformer);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 9
|
|
113
|
+
export function rename(
|
|
114
|
+
oldPath: string,
|
|
115
|
+
newPath: string,
|
|
116
|
+
origin = ""
|
|
117
|
+
): Promise<boolean> {
|
|
118
|
+
const payload = new Uint8Array([
|
|
119
|
+
9,
|
|
120
|
+
...serializeArgs([oldPath, newPath, origin])
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
return bridge(payload, ([success]) => success);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
type FileStats = {
|
|
127
|
+
name: string;
|
|
128
|
+
size: number;
|
|
129
|
+
modTime: number;
|
|
130
|
+
isDirectory: boolean;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// 10
|
|
134
|
+
export function stat(path: string): Promise<FileStats> {
|
|
135
|
+
const payload = new Uint8Array([10, ...serializeArgs([path])]);
|
|
136
|
+
|
|
137
|
+
const transformer = (responseArgs: any[]) => {
|
|
138
|
+
if (!responseArgs.length) return null;
|
|
139
|
+
|
|
140
|
+
const [name, size, atimeMs, mtimeMs, ctimeMs, isDirectory] =
|
|
141
|
+
responseArgs;
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
name,
|
|
145
|
+
size,
|
|
146
|
+
atimeMs,
|
|
147
|
+
mtimeMs,
|
|
148
|
+
ctimeMs,
|
|
149
|
+
atime: new Date(atimeMs),
|
|
150
|
+
mtime: new Date(mtimeMs),
|
|
151
|
+
ctime: new Date(ctimeMs),
|
|
152
|
+
isDirectory
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
return bridge(payload, transformer);
|
|
157
|
+
}
|
package/lib/fs/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as fs from "./fs";
|
|
2
|
-
export default fs;
|
|
3
|
-
export * from "./fs";
|
|
1
|
+
import * as fs from "./fs";
|
|
2
|
+
export default fs;
|
|
3
|
+
export * from "./fs";
|