@glodon-aiot/bot-client-sdk 3.26.0-alpha.9 → 3.26.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/README.md +243 -225
- package/dist/es/AgentSession.mjs +267 -197
- package/dist/es/BotClient.mjs +200 -123
- package/dist/es/Config.mjs +56 -67
- package/dist/es/DialogSession.mjs +123 -118
- package/dist/es/EventBus.mjs +38 -34
- package/dist/es/Logger.mjs +19 -21
- package/dist/es/Session.mjs +338 -284
- package/dist/es/api/index.mjs +31 -30
- package/dist/es/builtinTools/constants.mjs +12 -5
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +182 -160
- package/dist/es/builtinTools/paths.mjs +34 -27
- package/dist/es/builtinTools/platformSkills.mjs +248 -0
- package/dist/es/builtinTools/schemas.mjs +63 -18
- package/dist/es/builtinTools/tools.mjs +368 -244
- package/dist/es/index.mjs +62 -61
- package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +160 -0
- package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -131
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +60 -55
- package/dist/es/localFiles/constants.mjs +24 -28
- package/dist/es/localFiles/createLocalFilesPlugin.mjs +53 -52
- package/dist/es/localFiles/errors.mjs +44 -35
- package/dist/es/localFiles/host/connectHostBridge.mjs +20 -15
- package/dist/es/localFiles/host/protocol.mjs +27 -14
- package/dist/es/localFiles/host/sandboxClient.mjs +297 -127
- package/dist/es/localFiles/preview.mjs +33 -0
- package/dist/es/localFiles/schemas.mjs +22 -53
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +156 -89
- package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +246 -0
- package/dist/es/localMcp/client.mjs +234 -0
- package/dist/es/localMcp/endpoints.mjs +94 -0
- package/dist/es/localMcp/register.mjs +207 -0
- package/dist/es/localMcp/registry.mjs +43 -0
- package/dist/es/package.json.mjs +34 -54
- package/dist/es/sessionUpload.mjs +49 -0
- package/dist/es/utils.mjs +24 -11
- package/dist/lib/index.js +48 -40
- package/dist/src/AgentSession.d.ts +13 -0
- package/dist/src/BotClient.d.ts +13 -1
- package/dist/src/Config.d.ts +6 -7
- package/dist/src/EventBus.d.ts +3 -0
- package/dist/src/Logger.d.ts +15 -8
- package/dist/src/PayloadTypes.d.ts +2 -0
- package/dist/src/Session.d.ts +19 -2
- package/dist/src/api/index.d.ts +2 -2
- package/dist/src/builtinTools/command.d.ts +7 -0
- package/dist/src/builtinTools/constants.d.ts +10 -2
- package/dist/src/builtinTools/paths.d.ts +3 -2
- package/dist/src/builtinTools/platformSkills.d.ts +92 -0
- package/dist/src/builtinTools/tools.d.ts +13 -0
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +24 -0
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +7 -4
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +8 -0
- package/dist/src/localFiles/constants.d.ts +4 -13
- package/dist/src/localFiles/errors.d.ts +1 -1
- package/dist/src/localFiles/host/protocol.d.ts +14 -3
- package/dist/src/localFiles/host/sandboxClient.d.ts +50 -0
- package/dist/src/localFiles/index.d.ts +9 -5
- package/dist/src/localFiles/preview.d.ts +2 -0
- package/dist/src/localFiles/schemas.d.ts +0 -2
- package/dist/src/localFiles/types.d.ts +2 -22
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +25 -3
- package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +63 -0
- package/dist/src/localMcp/client.d.ts +15 -0
- package/dist/src/localMcp/endpoints.d.ts +19 -0
- package/dist/src/localMcp/register.d.ts +34 -0
- package/dist/src/localMcp/registry.d.ts +27 -0
- package/dist/src/sessionUpload.d.ts +14 -0
- package/dist/src/utils.d.ts +6 -0
- package/package.json +4 -24
package/dist/es/index.mjs
CHANGED
|
@@ -1,71 +1,72 @@
|
|
|
1
|
-
import { configuration as e, configure as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
5
|
-
import { ToolCode as
|
|
6
|
-
import { LOCAL_FILE_TOOL_SCHEMAS as
|
|
7
|
-
import { BUILTIN_TOOL_SCHEMAS as
|
|
1
|
+
import { configuration as e, configure as r, getRegisteredLocalFilesPluginCode as E, resolveLocalFilesPluginCode as T } from "./Config.mjs";
|
|
2
|
+
import { default as I } from "./BotClient.mjs";
|
|
3
|
+
import { default as A } from "./Session.mjs";
|
|
4
|
+
import { default as O } from "./AgentPlugin.mjs";
|
|
5
|
+
import { ToolCode as C, ToolError as N, toToolError as D } from "./localFiles/errors.mjs";
|
|
6
|
+
import { LOCAL_FILE_TOOL_SCHEMAS as R } from "./localFiles/schemas.mjs";
|
|
7
|
+
import { BUILTIN_TOOL_SCHEMAS as f } from "./builtinTools/schemas.mjs";
|
|
8
8
|
import { createLocalFilesPlugin as s } from "./localFiles/createLocalFilesPlugin.mjs";
|
|
9
|
-
import { LocalWorkspace as
|
|
10
|
-
import {
|
|
9
|
+
import { LocalWorkspace as m } from "./localFiles/workspace/LocalWorkspace.mjs";
|
|
10
|
+
import { WorkspaceFiles as U, normalizeFilePath as M } from "./localFiles/workspace/WorkspaceFiles.mjs";
|
|
11
|
+
import { createIndexedDbStore as B, createMemoryStore as H } from "./localFiles/workspace/handleStore.mjs";
|
|
11
12
|
import { FileSystemAccessAdapter as d } from "./localFiles/adapters/FileSystemAccessAdapter.mjs";
|
|
12
13
|
import { MemoryWorkspaceAdapter as g } from "./localFiles/adapters/MemoryWorkspaceAdapter.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { HOST_BRIDGE_GLOBAL as u, HOST_CHANNEL as G, SANDBOX_MAX_FILE_BYTES as W, registerHostBridge as Y } from "./localFiles/host/protocol.mjs";
|
|
15
|
+
import { createDefaultSessionFileTransfer as k } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
16
|
+
import { getDownloadUrlAllowlist as K, isDownloadUrlAllowed as b } from "./localFiles/security/downloadUrlPolicy.mjs";
|
|
17
|
+
import { SDK_SENSITIVE_BASELINE as v } from "./localFiles/security/sensitiveFiles.mjs";
|
|
18
|
+
import { BINARY_SNIFF_BYTES as V, BUILTIN_TOOLS_PLUGIN_CODE as Z, BUILTIN_TOOLS_PLUGIN_CODES as j, DEFAULT_DOWNLOAD_URL_ALLOWLIST as q, DEFAULT_IGNORED_DIRECTORIES as J, DEFAULT_IGNORED_FILE_PATTERNS as Q, DEFAULT_LIMITS as $, KiB as oo, LIST_DIRECTORY_DEFAULT_LIMIT as _o, LIST_DIRECTORY_MAX_LIMIT as eo, LOCAL_FILES_FUNCTION_CODES as ro, LOCAL_FILES_PLUGIN_CODES as Eo, MiB as To, SEARCH_DEFAULT_DEPTH as Lo, SEARCH_FUNCTION_CODES as Io, SEARCH_MAX_DEPTH as So, TEXT_SEARCH_MAX_CONTEXT_LINES as Ao, TEXT_SEARCH_MAX_FILES as to, TEXT_SEARCH_MAX_FILE_BYTES as Oo, TEXT_SEARCH_MAX_LINE_CHARS as lo, TRANSFER_FILE_SIZE_LIMIT_MB as Co, TRANSFER_FUNCTION_CODES as No, WORKSPACE_GRANT_ID as Do, WRITE_FUNCTION_CODES as Fo } from "./localFiles/constants.mjs";
|
|
17
19
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
O as AgentPlugin,
|
|
21
|
+
V as BINARY_SNIFF_BYTES,
|
|
22
|
+
Z as BUILTIN_TOOLS_PLUGIN_CODE,
|
|
23
|
+
j as BUILTIN_TOOLS_PLUGIN_CODES,
|
|
24
|
+
f as BUILTIN_TOOL_SCHEMAS,
|
|
25
|
+
I as BotClient,
|
|
26
|
+
q as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
|
|
27
|
+
J as DEFAULT_IGNORED_DIRECTORIES,
|
|
28
|
+
Q as DEFAULT_IGNORED_FILE_PATTERNS,
|
|
29
|
+
$ as DEFAULT_LIMITS,
|
|
28
30
|
d as FileSystemAccessAdapter,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
P as LocalWorkspace,
|
|
31
|
+
u as HOST_BRIDGE_GLOBAL,
|
|
32
|
+
G as HOST_CHANNEL,
|
|
33
|
+
oo as KiB,
|
|
34
|
+
_o as LIST_DIRECTORY_DEFAULT_LIMIT,
|
|
35
|
+
eo as LIST_DIRECTORY_MAX_LIMIT,
|
|
36
|
+
ro as LOCAL_FILES_FUNCTION_CODES,
|
|
37
|
+
Eo as LOCAL_FILES_PLUGIN_CODES,
|
|
38
|
+
R as LOCAL_FILE_TOOL_SCHEMAS,
|
|
39
|
+
m as LocalWorkspace,
|
|
39
40
|
g as MemoryWorkspaceAdapter,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
D_ as WRITE_FUNCTION_CODES,
|
|
41
|
+
To as MiB,
|
|
42
|
+
W as SANDBOX_MAX_FILE_BYTES,
|
|
43
|
+
v as SDK_SENSITIVE_BASELINE,
|
|
44
|
+
Lo as SEARCH_DEFAULT_DEPTH,
|
|
45
|
+
Io as SEARCH_FUNCTION_CODES,
|
|
46
|
+
So as SEARCH_MAX_DEPTH,
|
|
47
|
+
A as Session,
|
|
48
|
+
Ao as TEXT_SEARCH_MAX_CONTEXT_LINES,
|
|
49
|
+
to as TEXT_SEARCH_MAX_FILES,
|
|
50
|
+
Oo as TEXT_SEARCH_MAX_FILE_BYTES,
|
|
51
|
+
lo as TEXT_SEARCH_MAX_LINE_CHARS,
|
|
52
|
+
Co as TRANSFER_FILE_SIZE_LIMIT_MB,
|
|
53
|
+
No as TRANSFER_FUNCTION_CODES,
|
|
54
|
+
C as ToolCode,
|
|
55
|
+
N as ToolError,
|
|
56
|
+
Do as WORKSPACE_GRANT_ID,
|
|
57
|
+
Fo as WRITE_FUNCTION_CODES,
|
|
58
|
+
U as WorkspaceFiles,
|
|
59
59
|
e as configuration,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
r as configure,
|
|
61
|
+
k as createDefaultSessionFileTransfer,
|
|
62
|
+
B as createIndexedDbStore,
|
|
63
63
|
s as createLocalFilesPlugin,
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
H as createMemoryStore,
|
|
65
|
+
K as getDownloadUrlAllowlist,
|
|
66
66
|
E as getRegisteredLocalFilesPluginCode,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
b as isDownloadUrlAllowed,
|
|
68
|
+
M as normalizeFilePath,
|
|
69
|
+
Y as registerHostBridge,
|
|
70
|
+
T as resolveLocalFilesPluginCode,
|
|
71
|
+
D as toToolError
|
|
71
72
|
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var y = (n, r) => {
|
|
3
|
+
if (r = Symbol[n])
|
|
4
|
+
return r;
|
|
5
|
+
throw Error("Symbol." + n + " is not defined");
|
|
6
|
+
};
|
|
7
|
+
var g = (n, r, e) => r in n ? M(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
|
|
8
|
+
var m = (n, r, e) => (g(n, typeof r != "symbol" ? r + "" : r, e), e);
|
|
9
|
+
var f = (n, r, e) => new Promise((t, o) => {
|
|
10
|
+
var i = (s) => {
|
|
11
|
+
try {
|
|
12
|
+
c(e.next(s));
|
|
13
|
+
} catch (d) {
|
|
14
|
+
o(d);
|
|
15
|
+
}
|
|
16
|
+
}, l = (s) => {
|
|
17
|
+
try {
|
|
18
|
+
c(e.throw(s));
|
|
19
|
+
} catch (d) {
|
|
20
|
+
o(d);
|
|
21
|
+
}
|
|
22
|
+
}, c = (s) => s.done ? t(s.value) : Promise.resolve(s.value).then(i, l);
|
|
23
|
+
c((e = e.apply(n, r)).next());
|
|
24
|
+
});
|
|
25
|
+
var u = (n, r, e) => (r = n[y("asyncIterator")]) ? r.call(n) : (n = n[y("iterator")](), r = {}, e = (t, o) => (o = n[t]) && (r[t] = (i) => new Promise((l, c, s) => (i = o.call(n, i), s = i.done, Promise.resolve(i.value).then((d) => l({ value: d, done: s }), c)))), e("next"), e("return"), r);
|
|
26
|
+
import { domError as a, toChunks as D } from "./WorkspaceFileAdapter.mjs";
|
|
27
|
+
import { throwIfAborted as w } from "../errors.mjs";
|
|
28
|
+
import { splitPath as h } from "../security/pathPolicy.mjs";
|
|
29
|
+
function k() {
|
|
30
|
+
return {
|
|
31
|
+
kind: "directory",
|
|
32
|
+
children: /* @__PURE__ */ new Map()
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
class A {
|
|
36
|
+
constructor(r, e) {
|
|
37
|
+
m(this, "root", k());
|
|
38
|
+
var t;
|
|
39
|
+
this.displayName = e;
|
|
40
|
+
for (const o of r) {
|
|
41
|
+
const i = E(o, e);
|
|
42
|
+
i && this.writeNode(i, o.blob, (t = o.lastModified) != null ? t : Date.now());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
writeNode(r, e, t) {
|
|
46
|
+
const o = r.split("/").filter(Boolean), i = o.pop();
|
|
47
|
+
if (!i)
|
|
48
|
+
return;
|
|
49
|
+
this.resolveDirectory(o, !0).children.set(i, {
|
|
50
|
+
kind: "file",
|
|
51
|
+
blob: e,
|
|
52
|
+
lastModified: t
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
resolveDirectory(r, e = !1) {
|
|
56
|
+
let t = this.root;
|
|
57
|
+
for (const o of r) {
|
|
58
|
+
let i = t.children.get(o);
|
|
59
|
+
if (!i) {
|
|
60
|
+
if (!e)
|
|
61
|
+
throw a("NotFoundError");
|
|
62
|
+
i = k(), t.children.set(o, i);
|
|
63
|
+
}
|
|
64
|
+
if (i.kind !== "directory")
|
|
65
|
+
throw a("TypeMismatchError");
|
|
66
|
+
t = i;
|
|
67
|
+
}
|
|
68
|
+
return t;
|
|
69
|
+
}
|
|
70
|
+
resolveNode(r) {
|
|
71
|
+
const e = h(r), t = e.pop();
|
|
72
|
+
if (t === void 0)
|
|
73
|
+
return this.root;
|
|
74
|
+
const o = this.resolveDirectory(e).children.get(t);
|
|
75
|
+
if (!o)
|
|
76
|
+
throw a("NotFoundError");
|
|
77
|
+
return o;
|
|
78
|
+
}
|
|
79
|
+
stat(r) {
|
|
80
|
+
return f(this, null, function* () {
|
|
81
|
+
var o;
|
|
82
|
+
const e = this.resolveNode(r), t = (o = h(r).pop()) != null ? o : this.displayName;
|
|
83
|
+
return e.kind === "directory" ? {
|
|
84
|
+
name: t,
|
|
85
|
+
kind: "directory"
|
|
86
|
+
} : {
|
|
87
|
+
name: t,
|
|
88
|
+
kind: "file",
|
|
89
|
+
size: e.blob.size,
|
|
90
|
+
lastModified: e.lastModified
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
listEntries(r, e) {
|
|
95
|
+
return f(this, null, function* () {
|
|
96
|
+
w(e);
|
|
97
|
+
const t = this.resolveDirectory(h(r));
|
|
98
|
+
return Array.from(t.children.entries()).map(([o, i]) => i.kind === "directory" ? {
|
|
99
|
+
name: o,
|
|
100
|
+
kind: "directory"
|
|
101
|
+
} : {
|
|
102
|
+
name: o,
|
|
103
|
+
kind: "file",
|
|
104
|
+
size: i.blob.size,
|
|
105
|
+
lastModified: i.lastModified
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
readFile(r) {
|
|
110
|
+
return f(this, null, function* () {
|
|
111
|
+
const e = this.resolveNode(r);
|
|
112
|
+
if (e.kind !== "file")
|
|
113
|
+
throw a("TypeMismatchError");
|
|
114
|
+
return e.blob;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** 只更新内存中的快照,不会写回用户磁盘。 */
|
|
118
|
+
writeFile(o, i) {
|
|
119
|
+
return f(this, arguments, function* (r, e, t = {}) {
|
|
120
|
+
const l = h(r), c = l.pop();
|
|
121
|
+
if (!c)
|
|
122
|
+
throw a("TypeMismatchError");
|
|
123
|
+
const s = this.resolveDirectory(l, t.createDirectories), d = s.children.get(c);
|
|
124
|
+
if ((d == null ? void 0 : d.kind) === "directory")
|
|
125
|
+
throw a("TypeMismatchError");
|
|
126
|
+
const p = [];
|
|
127
|
+
try {
|
|
128
|
+
for (var B = u(D(e)), C, I, R; C = !(I = yield B.next()).done; C = !1) {
|
|
129
|
+
const v = I.value;
|
|
130
|
+
w(t.signal), p.push(v);
|
|
131
|
+
}
|
|
132
|
+
} catch (I) {
|
|
133
|
+
R = [I];
|
|
134
|
+
} finally {
|
|
135
|
+
try {
|
|
136
|
+
C && (I = B.return) && (yield I.call(B));
|
|
137
|
+
} finally {
|
|
138
|
+
if (R)
|
|
139
|
+
throw R[0];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const b = new Blob(p);
|
|
143
|
+
s.children.set(c, {
|
|
144
|
+
kind: "file",
|
|
145
|
+
blob: b,
|
|
146
|
+
lastModified: Date.now()
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function E(n, r) {
|
|
152
|
+
const e = (n.webkitRelativePath || n.name).replace(/\\/g, "/").replace(/^\/+/, "");
|
|
153
|
+
if (!e)
|
|
154
|
+
return "";
|
|
155
|
+
const t = `${r}/`;
|
|
156
|
+
return e.startsWith(t) ? e.slice(t.length) : e;
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
A as FileSnapshotAdapter
|
|
160
|
+
};
|
|
@@ -3,27 +3,27 @@ var g = (o, t) => {
|
|
|
3
3
|
return t;
|
|
4
4
|
throw Error("Symbol." + o + " is not defined");
|
|
5
5
|
};
|
|
6
|
-
var
|
|
6
|
+
var w = (o, t, r) => new Promise((e, a) => {
|
|
7
7
|
var c = (i) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
s(r.next(i));
|
|
10
10
|
} catch (n) {
|
|
11
11
|
a(n);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, d = (i) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
s(r.throw(i));
|
|
16
16
|
} catch (n) {
|
|
17
17
|
a(n);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, s = (i) => i.done ? e(i.value) : Promise.resolve(i.value).then(c, d);
|
|
20
|
+
s((r = r.apply(o, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
import { domError as
|
|
24
|
-
import { throwIfAborted as
|
|
25
|
-
import { splitPath as
|
|
26
|
-
function
|
|
22
|
+
var v = (o, t, r) => (t = o[g("asyncIterator")]) ? t.call(o) : (o = o[g("iterator")](), t = {}, r = (e, a) => (a = o[e]) && (t[e] = (c) => new Promise((d, s, i) => (c = a.call(o, c), i = c.done, Promise.resolve(c.value).then((n) => d({ value: n, done: i }), s)))), r("next"), r("return"), t);
|
|
23
|
+
import { domError as u, toChunks as F, isSameOrInside as H } from "./WorkspaceFileAdapter.mjs";
|
|
24
|
+
import { throwIfAborted as p } from "../errors.mjs";
|
|
25
|
+
import { splitPath as h } from "../security/pathPolicy.mjs";
|
|
26
|
+
function m(o, t) {
|
|
27
27
|
return !!o && typeof o == "object" && o.name === t;
|
|
28
28
|
}
|
|
29
29
|
class b {
|
|
@@ -33,85 +33,67 @@ class b {
|
|
|
33
33
|
get displayName() {
|
|
34
34
|
return this.root.name;
|
|
35
35
|
}
|
|
36
|
-
resolveDirectory(t,
|
|
37
|
-
return
|
|
38
|
-
let
|
|
36
|
+
resolveDirectory(t, r = !1) {
|
|
37
|
+
return w(this, null, function* () {
|
|
38
|
+
let e = this.root;
|
|
39
39
|
for (const a of t)
|
|
40
|
-
|
|
41
|
-
create:
|
|
40
|
+
e = yield e.getDirectoryHandle(a, {
|
|
41
|
+
create: r
|
|
42
42
|
});
|
|
43
|
-
return
|
|
43
|
+
return e;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
resolveFile(t) {
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
throw
|
|
51
|
-
return (yield this.resolveDirectory(
|
|
47
|
+
return w(this, null, function* () {
|
|
48
|
+
const r = h(t), e = r.pop();
|
|
49
|
+
if (!e)
|
|
50
|
+
throw u("TypeMismatchError");
|
|
51
|
+
return (yield this.resolveDirectory(r)).getFileHandle(e);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
stat(t) {
|
|
55
|
-
return
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
55
|
+
return w(this, null, function* () {
|
|
56
|
+
const r = h(t), e = r.pop();
|
|
57
|
+
if (!e)
|
|
58
58
|
return {
|
|
59
59
|
name: this.root.name,
|
|
60
60
|
kind: "directory"
|
|
61
61
|
};
|
|
62
|
-
const a = yield this.resolveDirectory(
|
|
62
|
+
const a = yield this.resolveDirectory(r);
|
|
63
63
|
try {
|
|
64
|
-
const c = yield (yield a.getFileHandle(
|
|
64
|
+
const c = yield (yield a.getFileHandle(e)).getFile();
|
|
65
65
|
return {
|
|
66
|
-
name:
|
|
66
|
+
name: e,
|
|
67
67
|
kind: "file",
|
|
68
68
|
size: c.size,
|
|
69
69
|
lastModified: c.lastModified
|
|
70
70
|
};
|
|
71
71
|
} catch (c) {
|
|
72
|
-
if (!
|
|
72
|
+
if (!m(c, "TypeMismatchError"))
|
|
73
73
|
throw c;
|
|
74
|
-
return yield a.getDirectoryHandle(
|
|
75
|
-
name:
|
|
74
|
+
return yield a.getDirectoryHandle(e), {
|
|
75
|
+
name: e,
|
|
76
76
|
kind: "directory"
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
listEntries(t,
|
|
82
|
-
return
|
|
83
|
-
const
|
|
81
|
+
listEntries(t, r) {
|
|
82
|
+
return w(this, null, function* () {
|
|
83
|
+
const e = yield this.resolveDirectory(h(t)), a = [];
|
|
84
84
|
try {
|
|
85
|
-
for (var c =
|
|
86
|
-
const n =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
else
|
|
93
|
-
try {
|
|
94
|
-
const s = yield n.getFile();
|
|
95
|
-
a.push({
|
|
96
|
-
name: n.name,
|
|
97
|
-
kind: "file",
|
|
98
|
-
size: s.size,
|
|
99
|
-
lastModified: s.lastModified
|
|
100
|
-
});
|
|
101
|
-
} catch (s) {
|
|
102
|
-
if (u(s, "NotAllowedError"))
|
|
103
|
-
throw s;
|
|
104
|
-
a.push({
|
|
105
|
-
name: n.name,
|
|
106
|
-
kind: "file"
|
|
107
|
-
});
|
|
108
|
-
}
|
|
85
|
+
for (var c = v(e.values()), d, s, i; d = !(s = yield c.next()).done; d = !1) {
|
|
86
|
+
const n = s.value;
|
|
87
|
+
p(r), a.push({
|
|
88
|
+
name: n.name,
|
|
89
|
+
kind: n.kind === "directory" ? "directory" : "file"
|
|
90
|
+
});
|
|
109
91
|
}
|
|
110
|
-
} catch (
|
|
111
|
-
i = [
|
|
92
|
+
} catch (s) {
|
|
93
|
+
i = [s];
|
|
112
94
|
} finally {
|
|
113
95
|
try {
|
|
114
|
-
|
|
96
|
+
d && (s = c.return) && (yield s.call(c));
|
|
115
97
|
} finally {
|
|
116
98
|
if (i)
|
|
117
99
|
throw i[0];
|
|
@@ -121,140 +103,140 @@ class b {
|
|
|
121
103
|
});
|
|
122
104
|
}
|
|
123
105
|
readFile(t) {
|
|
124
|
-
return
|
|
106
|
+
return w(this, null, function* () {
|
|
125
107
|
return (yield this.resolveFile(t)).getFile();
|
|
126
108
|
});
|
|
127
109
|
}
|
|
128
110
|
writeFile(a, c) {
|
|
129
|
-
return
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
throw
|
|
133
|
-
const i = yield this.resolveDirectory(
|
|
111
|
+
return w(this, arguments, function* (t, r, e = {}) {
|
|
112
|
+
const d = h(t), s = d.pop();
|
|
113
|
+
if (!s)
|
|
114
|
+
throw u("TypeMismatchError");
|
|
115
|
+
const i = yield this.resolveDirectory(d, e.createDirectories);
|
|
134
116
|
let n = !0;
|
|
135
117
|
try {
|
|
136
|
-
yield i.getFileHandle(
|
|
137
|
-
} catch (
|
|
138
|
-
if (!
|
|
139
|
-
throw
|
|
118
|
+
yield i.getFileHandle(s);
|
|
119
|
+
} catch (f) {
|
|
120
|
+
if (!m(f, "NotFoundError"))
|
|
121
|
+
throw f;
|
|
140
122
|
n = !1;
|
|
141
123
|
}
|
|
142
|
-
const
|
|
124
|
+
const y = yield i.getFileHandle(s, {
|
|
143
125
|
create: !0
|
|
144
126
|
});
|
|
145
|
-
let
|
|
127
|
+
let l;
|
|
146
128
|
try {
|
|
147
|
-
|
|
129
|
+
l = yield y.createWritable();
|
|
148
130
|
try {
|
|
149
|
-
for (var A =
|
|
150
|
-
const
|
|
151
|
-
|
|
131
|
+
for (var A = v(F(r)), S, z, W; S = !(z = yield A.next()).done; S = !1) {
|
|
132
|
+
const f = z.value;
|
|
133
|
+
p(e.signal), yield l.write(f);
|
|
152
134
|
}
|
|
153
|
-
} catch (
|
|
154
|
-
W = [
|
|
135
|
+
} catch (z) {
|
|
136
|
+
W = [z];
|
|
155
137
|
} finally {
|
|
156
138
|
try {
|
|
157
|
-
|
|
139
|
+
S && (z = A.return) && (yield z.call(A));
|
|
158
140
|
} finally {
|
|
159
141
|
if (W)
|
|
160
142
|
throw W[0];
|
|
161
143
|
}
|
|
162
144
|
}
|
|
163
|
-
|
|
164
|
-
} catch (
|
|
165
|
-
throw yield
|
|
166
|
-
}), n || (yield i.removeEntry(
|
|
167
|
-
})),
|
|
145
|
+
p(e.signal), yield l.close();
|
|
146
|
+
} catch (f) {
|
|
147
|
+
throw yield l == null ? void 0 : l.abort().catch(() => {
|
|
148
|
+
}), n || (yield i.removeEntry(s).catch(() => {
|
|
149
|
+
})), f;
|
|
168
150
|
}
|
|
169
151
|
});
|
|
170
152
|
}
|
|
171
153
|
createDirectory(t) {
|
|
172
|
-
return
|
|
173
|
-
yield this.resolveDirectory(
|
|
154
|
+
return w(this, null, function* () {
|
|
155
|
+
yield this.resolveDirectory(h(t), !0);
|
|
174
156
|
});
|
|
175
157
|
}
|
|
176
|
-
remove(
|
|
177
|
-
return
|
|
178
|
-
const a =
|
|
158
|
+
remove(e) {
|
|
159
|
+
return w(this, arguments, function* (t, r = {}) {
|
|
160
|
+
const a = h(t), c = a.pop();
|
|
179
161
|
if (!c)
|
|
180
|
-
throw
|
|
162
|
+
throw u("InvalidModificationError");
|
|
181
163
|
yield (yield this.resolveDirectory(a)).removeEntry(c, {
|
|
182
|
-
recursive:
|
|
164
|
+
recursive: r.recursive === !0
|
|
183
165
|
});
|
|
184
166
|
});
|
|
185
167
|
}
|
|
186
|
-
move(t,
|
|
187
|
-
return
|
|
188
|
-
const
|
|
189
|
-
if (!c || !
|
|
190
|
-
throw
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
throw
|
|
194
|
-
let
|
|
168
|
+
move(t, r) {
|
|
169
|
+
return w(this, null, function* () {
|
|
170
|
+
const e = h(t), a = h(r), c = e.pop(), d = a.pop();
|
|
171
|
+
if (!c || !d)
|
|
172
|
+
throw u("InvalidModificationError");
|
|
173
|
+
const s = yield this.resolveDirectory(e), i = yield E(s, c), n = yield this.resolveDirectory(a);
|
|
174
|
+
if (H(t, r))
|
|
175
|
+
throw u("InvalidModificationError");
|
|
176
|
+
let y;
|
|
195
177
|
try {
|
|
196
|
-
|
|
197
|
-
} catch (
|
|
198
|
-
if (!
|
|
199
|
-
throw
|
|
178
|
+
y = yield E(n, d);
|
|
179
|
+
} catch (l) {
|
|
180
|
+
if (!m(l, "NotFoundError"))
|
|
181
|
+
throw l;
|
|
200
182
|
}
|
|
201
|
-
if (
|
|
202
|
-
throw
|
|
203
|
-
if (!
|
|
183
|
+
if (y && (y.kind === "directory" || i.kind === "directory"))
|
|
184
|
+
throw u("InvalidModificationError");
|
|
185
|
+
if (!y && typeof i.move == "function")
|
|
204
186
|
try {
|
|
205
|
-
yield i.move(n,
|
|
187
|
+
yield i.move(n, d);
|
|
206
188
|
return;
|
|
207
|
-
} catch (
|
|
208
|
-
if (!
|
|
209
|
-
throw
|
|
189
|
+
} catch (l) {
|
|
190
|
+
if (!m(l, "NotSupportedError") && !(l instanceof TypeError))
|
|
191
|
+
throw l;
|
|
210
192
|
}
|
|
211
|
-
yield
|
|
193
|
+
yield D(i, n, d), yield s.removeEntry(c, {
|
|
212
194
|
recursive: !0
|
|
213
195
|
});
|
|
214
196
|
});
|
|
215
197
|
}
|
|
216
198
|
}
|
|
217
199
|
function E(o, t) {
|
|
218
|
-
return
|
|
200
|
+
return w(this, null, function* () {
|
|
219
201
|
try {
|
|
220
202
|
return yield o.getFileHandle(t);
|
|
221
|
-
} catch (
|
|
222
|
-
if (!
|
|
223
|
-
throw
|
|
203
|
+
} catch (r) {
|
|
204
|
+
if (!m(r, "TypeMismatchError"))
|
|
205
|
+
throw r;
|
|
224
206
|
return o.getDirectoryHandle(t);
|
|
225
207
|
}
|
|
226
208
|
});
|
|
227
209
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
210
|
+
function D(o, t, r) {
|
|
211
|
+
return w(this, null, function* () {
|
|
230
212
|
if (o.kind === "file") {
|
|
231
|
-
const i = yield o.getFile(), n = yield (yield t.getFileHandle(
|
|
213
|
+
const i = yield o.getFile(), n = yield (yield t.getFileHandle(r, {
|
|
232
214
|
create: !0
|
|
233
215
|
})).createWritable();
|
|
234
216
|
try {
|
|
235
217
|
yield n.write(i), yield n.close();
|
|
236
|
-
} catch (
|
|
218
|
+
} catch (y) {
|
|
237
219
|
throw yield n.abort().catch(() => {
|
|
238
|
-
}),
|
|
220
|
+
}), y;
|
|
239
221
|
}
|
|
240
222
|
return;
|
|
241
223
|
}
|
|
242
|
-
const
|
|
224
|
+
const e = yield t.getDirectoryHandle(r, {
|
|
243
225
|
create: !0
|
|
244
226
|
});
|
|
245
227
|
try {
|
|
246
|
-
for (var a =
|
|
247
|
-
const i =
|
|
248
|
-
yield
|
|
228
|
+
for (var a = v(o.values()), c, d, s; c = !(d = yield a.next()).done; c = !1) {
|
|
229
|
+
const i = d.value;
|
|
230
|
+
yield D(i, e, i.name);
|
|
249
231
|
}
|
|
250
|
-
} catch (
|
|
251
|
-
|
|
232
|
+
} catch (d) {
|
|
233
|
+
s = [d];
|
|
252
234
|
} finally {
|
|
253
235
|
try {
|
|
254
|
-
c && (
|
|
236
|
+
c && (d = a.return) && (yield d.call(a));
|
|
255
237
|
} finally {
|
|
256
|
-
if (
|
|
257
|
-
throw
|
|
238
|
+
if (s)
|
|
239
|
+
throw s[0];
|
|
258
240
|
}
|
|
259
241
|
}
|
|
260
242
|
});
|