@glodon-aiot/bot-client-sdk 3.26.0-alpha.4 → 3.26.0-alpha.5
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 +105 -76
- package/dist/es/Config.mjs +63 -85
- package/dist/es/builtinTools/browserRuntime/BrowserCommandRunner.mjs +201 -0
- package/dist/es/builtinTools/browserRuntime/PythonRunner.mjs +356 -0
- package/dist/es/builtinTools/browserRuntime/WorkspaceBashFs.mjs +350 -0
- package/dist/es/builtinTools/browserRuntime/assets.mjs +9 -0
- package/dist/es/builtinTools/browserRuntime/loadBash.mjs +17 -0
- package/dist/es/builtinTools/browserRuntime/pyodideRunner.py.mjs +96 -0
- package/dist/es/builtinTools/browserRuntime/pyodideWorker.mjs +242 -0
- package/dist/es/builtinTools/command.mjs +56 -0
- package/dist/es/builtinTools/constants.mjs +10 -0
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +236 -0
- package/dist/es/builtinTools/overview.mjs +77 -0
- package/dist/es/builtinTools/paths.mjs +63 -0
- package/dist/es/builtinTools/schemas.mjs +216 -0
- package/dist/es/builtinTools/tools.mjs +471 -0
- package/dist/es/index.mjs +49 -48
- package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +193 -103
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +138 -77
- package/dist/es/localFiles/adapters/MemoryWorkspaceAdapter.mjs +132 -97
- package/dist/es/localFiles/adapters/WorkspaceFileAdapter.mjs +32 -28
- package/dist/es/localFiles/constants.mjs +1 -1
- package/dist/es/localFiles/host/connectHostBridge.mjs +22 -18
- package/dist/es/localFiles/host/protocol.mjs +6 -5
- package/dist/es/localFiles/schemas.mjs +45 -60
- package/dist/es/localFiles/validate.mjs +37 -37
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +71 -52
- package/dist/es/package.json.mjs +33 -27
- package/dist/lib/index.js +372 -9
- package/dist/src/Config.d.ts +2 -2
- package/dist/src/builtinTools/browserRuntime/BrowserCommandRunner.d.ts +26 -0
- package/dist/src/builtinTools/browserRuntime/PythonRunner.d.ts +67 -0
- package/dist/src/builtinTools/browserRuntime/WorkspaceBashFs.d.ts +51 -0
- package/dist/src/builtinTools/browserRuntime/assets.d.ts +13 -0
- package/dist/src/builtinTools/browserRuntime/loadBash.d.ts +3 -0
- package/dist/src/builtinTools/browserRuntime/pyodideWorker.d.ts +44 -0
- package/dist/src/builtinTools/command.d.ts +26 -0
- package/dist/src/builtinTools/constants.d.ts +17 -0
- package/dist/src/builtinTools/createBuiltinToolsPlugin.d.ts +11 -0
- package/dist/src/builtinTools/overview.d.ts +5 -0
- package/dist/src/builtinTools/paths.d.ts +15 -0
- package/dist/src/builtinTools/schemas.d.ts +3 -0
- package/dist/src/builtinTools/tools.d.ts +60 -0
- package/dist/src/localFiles/adapters/FileSystemAccessAdapter.d.ts +4 -1
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +20 -1
- package/dist/src/localFiles/adapters/MemoryWorkspaceAdapter.d.ts +4 -1
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +14 -0
- package/dist/src/localFiles/adapters/fsaTypes.d.ts +2 -0
- package/dist/src/localFiles/constants.d.ts +2 -1
- package/dist/src/localFiles/host/protocol.d.ts +13 -0
- package/dist/src/localFiles/index.d.ts +3 -2
- package/dist/src/localFiles/schemas.d.ts +2 -3
- package/dist/src/localFiles/types.d.ts +14 -1
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +12 -0
- package/package.json +8 -2
- package/dist/es/localFiles/createLocalPythonPlugin.mjs +0 -196
package/dist/es/index.mjs
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
1
|
import { configuration as e, configure as T, getRegisteredLocalFilesPluginCode as E, getRegisteredLocalPythonPluginCode as r, resolveLocalFilesPluginCode as L } from "./Config.mjs";
|
|
2
2
|
import { default as S } from "./BotClient.mjs";
|
|
3
3
|
import { default as O } from "./Session.mjs";
|
|
4
|
-
import { default as
|
|
4
|
+
import { default as C } from "./AgentPlugin.mjs";
|
|
5
5
|
import { ToolCode as l, ToolError as D, toToolError as R } from "./localFiles/errors.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { LOCAL_FILE_TOOL_SCHEMAS as a, LOCAL_PYTHON_TOOL_SCHEMA as U } from "./localFiles/schemas.mjs";
|
|
7
|
+
import { BUILTIN_TOOL_SCHEMAS as M } from "./builtinTools/schemas.mjs";
|
|
8
|
+
import { createLocalFilesPlugin as s } from "./localFiles/createLocalFilesPlugin.mjs";
|
|
8
9
|
import { LocalWorkspace as P } from "./localFiles/workspace/LocalWorkspace.mjs";
|
|
9
|
-
import { createIndexedDbStore as H, createMemoryStore as
|
|
10
|
+
import { createIndexedDbStore as H, createMemoryStore as n } from "./localFiles/workspace/handleStore.mjs";
|
|
10
11
|
import { FileSystemAccessAdapter as d } from "./localFiles/adapters/FileSystemAccessAdapter.mjs";
|
|
11
|
-
import { MemoryWorkspaceAdapter as
|
|
12
|
-
import { createDefaultSessionFileTransfer as
|
|
13
|
-
import { getDownloadUrlAllowlist as
|
|
14
|
-
import { SDK_SENSITIVE_BASELINE as
|
|
15
|
-
import { BINARY_SNIFF_BYTES as
|
|
12
|
+
import { MemoryWorkspaceAdapter as g } from "./localFiles/adapters/MemoryWorkspaceAdapter.mjs";
|
|
13
|
+
import { createDefaultSessionFileTransfer as u } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
14
|
+
import { getDownloadUrlAllowlist as Y, isDownloadUrlAllowed as G } from "./localFiles/security/downloadUrlPolicy.mjs";
|
|
15
|
+
import { SDK_SENSITIVE_BASELINE as w } from "./localFiles/security/sensitiveFiles.mjs";
|
|
16
|
+
import { BINARY_SNIFF_BYTES as K, BUILTIN_TOOLS_PLUGIN_CODE as k, BUILTIN_TOOLS_PLUGIN_CODES as b, DEFAULT_DOWNLOAD_URL_ALLOWLIST as h, DEFAULT_IGNORED_DIRECTORIES as v, DEFAULT_IGNORED_FILE_PATTERNS as V, DEFAULT_LIMITS as Z, KiB as j, LIST_DIRECTORY_DEFAULT_LIMIT as q, LIST_DIRECTORY_MAX_LIMIT as z, LOCAL_FILES_FUNCTION_CODES as J, LOCAL_FILES_PLUGIN_CODES as Q, LOCAL_PYTHON_FUNCTION_CODE as $, LOCAL_PYTHON_PLUGIN_CODES as __, MiB as o_, PYTHON_DEFAULT_TIMEOUT_MS as e_, PYTHON_MAX_ARGS as T_, PYTHON_MAX_TIMEOUT_MS as E_, SEARCH_DEFAULT_DEPTH as r_, SEARCH_FUNCTION_CODES as L_, SEARCH_MAX_DEPTH as I_, TEXT_SEARCH_MAX_CONTEXT_LINES as S_, TEXT_SEARCH_MAX_FILES as A_, TEXT_SEARCH_MAX_FILE_BYTES as O_, TEXT_SEARCH_MAX_LINE_CHARS as t_, TRANSFER_FILE_SIZE_LIMIT_MB as C_, TRANSFER_FUNCTION_CODES as N_, WORKSPACE_GRANT_ID as l_, WRITE_FUNCTION_CODES as D_ } from "./localFiles/constants.mjs";
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
C as AgentPlugin,
|
|
19
|
+
K as BINARY_SNIFF_BYTES,
|
|
20
|
+
k as BUILTIN_TOOLS_PLUGIN_CODE,
|
|
21
|
+
b as BUILTIN_TOOLS_PLUGIN_CODES,
|
|
22
|
+
M as BUILTIN_TOOL_SCHEMAS,
|
|
22
23
|
S as BotClient,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
h as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
|
|
25
|
+
v as DEFAULT_IGNORED_DIRECTORIES,
|
|
26
|
+
V as DEFAULT_IGNORED_FILE_PATTERNS,
|
|
27
|
+
Z as DEFAULT_LIMITS,
|
|
27
28
|
d as FileSystemAccessAdapter,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
j as KiB,
|
|
30
|
+
q as LIST_DIRECTORY_DEFAULT_LIMIT,
|
|
31
|
+
z as LIST_DIRECTORY_MAX_LIMIT,
|
|
32
|
+
J as LOCAL_FILES_FUNCTION_CODES,
|
|
33
|
+
Q as LOCAL_FILES_PLUGIN_CODES,
|
|
34
|
+
a as LOCAL_FILE_TOOL_SCHEMAS,
|
|
35
|
+
$ as LOCAL_PYTHON_FUNCTION_CODE,
|
|
36
|
+
__ as LOCAL_PYTHON_PLUGIN_CODES,
|
|
37
|
+
U as LOCAL_PYTHON_TOOL_SCHEMA,
|
|
37
38
|
P as LocalWorkspace,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
g as MemoryWorkspaceAdapter,
|
|
40
|
+
o_ as MiB,
|
|
41
|
+
e_ as PYTHON_DEFAULT_TIMEOUT_MS,
|
|
42
|
+
T_ as PYTHON_MAX_ARGS,
|
|
43
|
+
E_ as PYTHON_MAX_TIMEOUT_MS,
|
|
44
|
+
w as SDK_SENSITIVE_BASELINE,
|
|
45
|
+
r_ as SEARCH_DEFAULT_DEPTH,
|
|
46
|
+
L_ as SEARCH_FUNCTION_CODES,
|
|
47
|
+
I_ as SEARCH_MAX_DEPTH,
|
|
47
48
|
O as Session,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
S_ as TEXT_SEARCH_MAX_CONTEXT_LINES,
|
|
50
|
+
A_ as TEXT_SEARCH_MAX_FILES,
|
|
51
|
+
O_ as TEXT_SEARCH_MAX_FILE_BYTES,
|
|
52
|
+
t_ as TEXT_SEARCH_MAX_LINE_CHARS,
|
|
52
53
|
C_ as TRANSFER_FILE_SIZE_LIMIT_MB,
|
|
53
|
-
|
|
54
|
+
N_ as TRANSFER_FUNCTION_CODES,
|
|
54
55
|
l as ToolCode,
|
|
55
56
|
D as ToolError,
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
l_ as WORKSPACE_GRANT_ID,
|
|
58
|
+
D_ as WRITE_FUNCTION_CODES,
|
|
58
59
|
e as configuration,
|
|
59
60
|
T as configure,
|
|
60
|
-
|
|
61
|
+
u as createDefaultSessionFileTransfer,
|
|
61
62
|
H as createIndexedDbStore,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
s as createLocalFilesPlugin,
|
|
64
|
+
n as createMemoryStore,
|
|
65
|
+
Y as getDownloadUrlAllowlist,
|
|
65
66
|
E as getRegisteredLocalFilesPluginCode,
|
|
66
67
|
r as getRegisteredLocalPythonPluginCode,
|
|
67
|
-
|
|
68
|
+
G as isDownloadUrlAllowed,
|
|
68
69
|
L as resolveLocalFilesPluginCode,
|
|
69
70
|
R as toToolError
|
|
70
71
|
};
|
|
@@ -1,174 +1,264 @@
|
|
|
1
|
-
var g = (
|
|
2
|
-
if (
|
|
3
|
-
return
|
|
4
|
-
throw Error("Symbol." +
|
|
1
|
+
var g = (o, t) => {
|
|
2
|
+
if (t = Symbol[o])
|
|
3
|
+
return t;
|
|
4
|
+
throw Error("Symbol." + o + " is not defined");
|
|
5
5
|
};
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var y = (o, t, e) => new Promise((r, a) => {
|
|
7
|
+
var c = (i) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
} catch (
|
|
11
|
-
a(
|
|
9
|
+
l(e.next(i));
|
|
10
|
+
} catch (n) {
|
|
11
|
+
a(n);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, w = (i) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
a(
|
|
15
|
+
l(e.throw(i));
|
|
16
|
+
} catch (n) {
|
|
17
|
+
a(n);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, l = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(c, w);
|
|
20
|
+
l((e = e.apply(o, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
import { domError as
|
|
24
|
-
import { throwIfAborted as
|
|
25
|
-
import { splitPath as
|
|
26
|
-
function
|
|
27
|
-
return !!
|
|
22
|
+
var p = (o, t, e) => (t = o[g("asyncIterator")]) ? t.call(o) : (o = o[g("iterator")](), t = {}, e = (r, a) => (a = o[r]) && (t[r] = (c) => new Promise((w, l, i) => (c = a.call(o, c), i = c.done, Promise.resolve(c.value).then((n) => w({ value: n, done: i }), l)))), e("next"), e("return"), t);
|
|
23
|
+
import { domError as m, toChunks as D, isSameOrInside as k } from "./WorkspaceFileAdapter.mjs";
|
|
24
|
+
import { throwIfAborted as v } from "../errors.mjs";
|
|
25
|
+
import { splitPath as f } from "../security/pathPolicy.mjs";
|
|
26
|
+
function u(o, t) {
|
|
27
|
+
return !!o && typeof o == "object" && o.name === t;
|
|
28
28
|
}
|
|
29
|
-
class
|
|
30
|
-
constructor(
|
|
31
|
-
this.root =
|
|
29
|
+
class b {
|
|
30
|
+
constructor(t) {
|
|
31
|
+
this.root = t;
|
|
32
32
|
}
|
|
33
33
|
get displayName() {
|
|
34
34
|
return this.root.name;
|
|
35
35
|
}
|
|
36
|
-
resolveDirectory(
|
|
37
|
-
return
|
|
38
|
-
let
|
|
39
|
-
for (const a of
|
|
40
|
-
|
|
41
|
-
create:
|
|
36
|
+
resolveDirectory(t, e = !1) {
|
|
37
|
+
return y(this, null, function* () {
|
|
38
|
+
let r = this.root;
|
|
39
|
+
for (const a of t)
|
|
40
|
+
r = yield r.getDirectoryHandle(a, {
|
|
41
|
+
create: e
|
|
42
42
|
});
|
|
43
|
-
return
|
|
43
|
+
return r;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
resolveFile(
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
throw
|
|
51
|
-
return (yield this.resolveDirectory(
|
|
46
|
+
resolveFile(t) {
|
|
47
|
+
return y(this, null, function* () {
|
|
48
|
+
const e = f(t), r = e.pop();
|
|
49
|
+
if (!r)
|
|
50
|
+
throw m("TypeMismatchError");
|
|
51
|
+
return (yield this.resolveDirectory(e)).getFileHandle(r);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
stat(
|
|
55
|
-
return
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
54
|
+
stat(t) {
|
|
55
|
+
return y(this, null, function* () {
|
|
56
|
+
const e = f(t), r = e.pop();
|
|
57
|
+
if (!r)
|
|
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(e);
|
|
63
63
|
try {
|
|
64
|
-
const
|
|
64
|
+
const c = yield (yield a.getFileHandle(r)).getFile();
|
|
65
65
|
return {
|
|
66
|
-
name:
|
|
66
|
+
name: r,
|
|
67
67
|
kind: "file",
|
|
68
|
-
size:
|
|
69
|
-
lastModified:
|
|
68
|
+
size: c.size,
|
|
69
|
+
lastModified: c.lastModified
|
|
70
70
|
};
|
|
71
|
-
} catch (
|
|
72
|
-
if (!
|
|
73
|
-
throw
|
|
74
|
-
return yield a.getDirectoryHandle(
|
|
75
|
-
name:
|
|
71
|
+
} catch (c) {
|
|
72
|
+
if (!u(c, "TypeMismatchError"))
|
|
73
|
+
throw c;
|
|
74
|
+
return yield a.getDirectoryHandle(r), {
|
|
75
|
+
name: r,
|
|
76
76
|
kind: "directory"
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
listEntries(
|
|
82
|
-
return
|
|
83
|
-
const
|
|
81
|
+
listEntries(t, e) {
|
|
82
|
+
return y(this, null, function* () {
|
|
83
|
+
const r = yield this.resolveDirectory(f(t)), a = [];
|
|
84
84
|
try {
|
|
85
|
-
for (var
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
85
|
+
for (var c = p(r.values()), w, l, i; w = !(l = yield c.next()).done; w = !1) {
|
|
86
|
+
const n = l.value;
|
|
87
|
+
if (v(e), n.kind === "directory")
|
|
88
88
|
a.push({
|
|
89
|
-
name:
|
|
89
|
+
name: n.name,
|
|
90
90
|
kind: "directory"
|
|
91
91
|
});
|
|
92
92
|
else
|
|
93
93
|
try {
|
|
94
|
-
const
|
|
94
|
+
const s = yield n.getFile();
|
|
95
95
|
a.push({
|
|
96
|
-
name:
|
|
96
|
+
name: n.name,
|
|
97
97
|
kind: "file",
|
|
98
|
-
size:
|
|
99
|
-
lastModified:
|
|
98
|
+
size: s.size,
|
|
99
|
+
lastModified: s.lastModified
|
|
100
100
|
});
|
|
101
|
-
} catch (
|
|
102
|
-
if (
|
|
103
|
-
throw
|
|
101
|
+
} catch (s) {
|
|
102
|
+
if (u(s, "NotAllowedError"))
|
|
103
|
+
throw s;
|
|
104
104
|
a.push({
|
|
105
|
-
name:
|
|
105
|
+
name: n.name,
|
|
106
106
|
kind: "file"
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
} catch (
|
|
111
|
-
|
|
110
|
+
} catch (l) {
|
|
111
|
+
i = [l];
|
|
112
112
|
} finally {
|
|
113
113
|
try {
|
|
114
|
-
|
|
114
|
+
w && (l = c.return) && (yield l.call(c));
|
|
115
115
|
} finally {
|
|
116
|
-
if (
|
|
117
|
-
throw
|
|
116
|
+
if (i)
|
|
117
|
+
throw i[0];
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
return a;
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
readFile(
|
|
124
|
-
return
|
|
125
|
-
return (yield this.resolveFile(
|
|
123
|
+
readFile(t) {
|
|
124
|
+
return y(this, null, function* () {
|
|
125
|
+
return (yield this.resolveFile(t)).getFile();
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
writeFile(a,
|
|
129
|
-
return
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
throw
|
|
133
|
-
const
|
|
134
|
-
let
|
|
128
|
+
writeFile(a, c) {
|
|
129
|
+
return y(this, arguments, function* (t, e, r = {}) {
|
|
130
|
+
const w = f(t), l = w.pop();
|
|
131
|
+
if (!l)
|
|
132
|
+
throw m("TypeMismatchError");
|
|
133
|
+
const i = yield this.resolveDirectory(w, r.createDirectories);
|
|
134
|
+
let n = !0;
|
|
135
135
|
try {
|
|
136
|
-
yield
|
|
137
|
-
} catch (
|
|
138
|
-
if (!
|
|
139
|
-
throw
|
|
140
|
-
|
|
136
|
+
yield i.getFileHandle(l);
|
|
137
|
+
} catch (h) {
|
|
138
|
+
if (!u(h, "NotFoundError"))
|
|
139
|
+
throw h;
|
|
140
|
+
n = !1;
|
|
141
141
|
}
|
|
142
|
-
const
|
|
142
|
+
const s = yield i.getFileHandle(l, {
|
|
143
143
|
create: !0
|
|
144
144
|
});
|
|
145
|
-
let
|
|
145
|
+
let d;
|
|
146
146
|
try {
|
|
147
|
-
|
|
147
|
+
d = yield s.createWritable();
|
|
148
148
|
try {
|
|
149
|
-
for (var
|
|
150
|
-
const
|
|
151
|
-
|
|
149
|
+
for (var A = p(D(e)), x, S, W; x = !(S = yield A.next()).done; x = !1) {
|
|
150
|
+
const h = S.value;
|
|
151
|
+
v(r.signal), yield d.write(h);
|
|
152
152
|
}
|
|
153
|
-
} catch (
|
|
154
|
-
|
|
153
|
+
} catch (S) {
|
|
154
|
+
W = [S];
|
|
155
155
|
} finally {
|
|
156
156
|
try {
|
|
157
|
-
|
|
157
|
+
x && (S = A.return) && (yield S.call(A));
|
|
158
158
|
} finally {
|
|
159
|
-
if (
|
|
160
|
-
throw
|
|
159
|
+
if (W)
|
|
160
|
+
throw W[0];
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
} catch (
|
|
165
|
-
throw yield
|
|
166
|
-
}),
|
|
167
|
-
})),
|
|
163
|
+
v(r.signal), yield d.close();
|
|
164
|
+
} catch (h) {
|
|
165
|
+
throw yield d == null ? void 0 : d.abort().catch(() => {
|
|
166
|
+
}), n || (yield i.removeEntry(l).catch(() => {
|
|
167
|
+
})), h;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
createDirectory(t) {
|
|
172
|
+
return y(this, null, function* () {
|
|
173
|
+
yield this.resolveDirectory(f(t), !0);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
remove(r) {
|
|
177
|
+
return y(this, arguments, function* (t, e = {}) {
|
|
178
|
+
const a = f(t), c = a.pop();
|
|
179
|
+
if (!c)
|
|
180
|
+
throw m("InvalidModificationError");
|
|
181
|
+
yield (yield this.resolveDirectory(a)).removeEntry(c, {
|
|
182
|
+
recursive: e.recursive === !0
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
move(t, e) {
|
|
187
|
+
return y(this, null, function* () {
|
|
188
|
+
const r = f(t), a = f(e), c = r.pop(), w = a.pop();
|
|
189
|
+
if (!c || !w)
|
|
190
|
+
throw m("InvalidModificationError");
|
|
191
|
+
const l = yield this.resolveDirectory(r), i = yield E(l, c), n = yield this.resolveDirectory(a);
|
|
192
|
+
if (k(t, e))
|
|
193
|
+
throw m("InvalidModificationError");
|
|
194
|
+
let s;
|
|
195
|
+
try {
|
|
196
|
+
s = yield E(n, w);
|
|
197
|
+
} catch (d) {
|
|
198
|
+
if (!u(d, "NotFoundError"))
|
|
199
|
+
throw d;
|
|
168
200
|
}
|
|
201
|
+
if (s && (s.kind === "directory" || i.kind === "directory"))
|
|
202
|
+
throw m("InvalidModificationError");
|
|
203
|
+
if (!s && typeof i.move == "function")
|
|
204
|
+
try {
|
|
205
|
+
yield i.move(n, w);
|
|
206
|
+
return;
|
|
207
|
+
} catch (d) {
|
|
208
|
+
if (!u(d, "NotSupportedError") && !(d instanceof TypeError))
|
|
209
|
+
throw d;
|
|
210
|
+
}
|
|
211
|
+
yield F(i, n, w), yield l.removeEntry(c, {
|
|
212
|
+
recursive: !0
|
|
213
|
+
});
|
|
169
214
|
});
|
|
170
215
|
}
|
|
171
216
|
}
|
|
217
|
+
function E(o, t) {
|
|
218
|
+
return y(this, null, function* () {
|
|
219
|
+
try {
|
|
220
|
+
return yield o.getFileHandle(t);
|
|
221
|
+
} catch (e) {
|
|
222
|
+
if (!u(e, "TypeMismatchError"))
|
|
223
|
+
throw e;
|
|
224
|
+
return o.getDirectoryHandle(t);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
function F(o, t, e) {
|
|
229
|
+
return y(this, null, function* () {
|
|
230
|
+
if (o.kind === "file") {
|
|
231
|
+
const i = yield o.getFile(), n = yield (yield t.getFileHandle(e, {
|
|
232
|
+
create: !0
|
|
233
|
+
})).createWritable();
|
|
234
|
+
try {
|
|
235
|
+
yield n.write(i), yield n.close();
|
|
236
|
+
} catch (s) {
|
|
237
|
+
throw yield n.abort().catch(() => {
|
|
238
|
+
}), s;
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const r = yield t.getDirectoryHandle(e, {
|
|
243
|
+
create: !0
|
|
244
|
+
});
|
|
245
|
+
try {
|
|
246
|
+
for (var a = p(o.values()), c, w, l; c = !(w = yield a.next()).done; c = !1) {
|
|
247
|
+
const i = w.value;
|
|
248
|
+
yield F(i, r, i.name);
|
|
249
|
+
}
|
|
250
|
+
} catch (w) {
|
|
251
|
+
l = [w];
|
|
252
|
+
} finally {
|
|
253
|
+
try {
|
|
254
|
+
c && (w = a.return) && (yield w.call(a));
|
|
255
|
+
} finally {
|
|
256
|
+
if (l)
|
|
257
|
+
throw l[0];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
172
262
|
export {
|
|
173
|
-
|
|
263
|
+
b as FileSystemAccessAdapter
|
|
174
264
|
};
|