@glodon-aiot/bot-client-sdk 3.26.0-alpha.20 → 3.26.0-alpha.23
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 +130 -179
- package/dist/es/BotClient.mjs +136 -154
- package/dist/es/Config.mjs +88 -51
- package/dist/es/Session.mjs +23 -35
- package/dist/es/index.mjs +64 -66
- package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -185
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +137 -127
- package/dist/es/localFiles/adapters/MemoryWorkspaceAdapter.mjs +97 -132
- package/dist/es/localFiles/adapters/WorkspaceFileAdapter.mjs +28 -32
- package/dist/es/localFiles/constants.mjs +29 -24
- package/dist/es/localFiles/createLocalPythonPlugin.mjs +196 -0
- package/dist/es/localFiles/errors.mjs +19 -21
- package/dist/es/localFiles/host/connectHostBridge.mjs +34 -37
- package/dist/es/localFiles/host/protocol.mjs +13 -27
- package/dist/es/localFiles/schemas.mjs +86 -40
- package/dist/es/localFiles/validate.mjs +37 -37
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +87 -161
- package/dist/es/package.json.mjs +29 -38
- package/dist/lib/index.js +9 -373
- package/dist/src/Config.d.ts +7 -5
- package/dist/src/Session.d.ts +0 -6
- package/dist/src/index.d.ts +1 -2
- package/dist/src/localFiles/adapters/FileSystemAccessAdapter.d.ts +1 -4
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +14 -30
- package/dist/src/localFiles/adapters/MemoryWorkspaceAdapter.d.ts +1 -4
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +0 -22
- package/dist/src/localFiles/adapters/fsaTypes.d.ts +0 -2
- package/dist/src/localFiles/constants.d.ts +13 -3
- package/dist/src/localFiles/host/protocol.d.ts +16 -34
- package/dist/src/localFiles/index.d.ts +6 -11
- package/dist/src/localFiles/schemas.d.ts +5 -2
- package/dist/src/localFiles/types.d.ts +23 -16
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +1 -32
- package/package.json +4 -13
- package/dist/es/builtinTools/browserRuntime/BrowserCommandRunner.mjs +0 -201
- package/dist/es/builtinTools/browserRuntime/PythonRunner.mjs +0 -356
- package/dist/es/builtinTools/browserRuntime/WorkspaceBashFs.mjs +0 -350
- package/dist/es/builtinTools/browserRuntime/assets.mjs +0 -9
- package/dist/es/builtinTools/browserRuntime/loadBash.mjs +0 -17
- package/dist/es/builtinTools/browserRuntime/pyodideRunner.py.mjs +0 -96
- package/dist/es/builtinTools/browserRuntime/pyodideWorker.mjs +0 -242
- package/dist/es/builtinTools/command.mjs +0 -56
- package/dist/es/builtinTools/constants.mjs +0 -10
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +0 -261
- package/dist/es/builtinTools/overview.mjs +0 -77
- package/dist/es/builtinTools/paths.mjs +0 -69
- package/dist/es/builtinTools/platformSkills.mjs +0 -210
- package/dist/es/builtinTools/schemas.mjs +0 -216
- package/dist/es/builtinTools/tools.mjs +0 -494
- package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +0 -160
- package/dist/es/localFiles/host/sandboxClient.mjs +0 -420
- package/dist/es/localFiles/host/sandboxFrames.mjs +0 -21
- package/dist/es/localFiles/preview.mjs +0 -33
- package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +0 -246
- package/dist/es/sessionUpload.mjs +0 -49
- package/dist/src/builtinTools/browserRuntime/BrowserCommandRunner.d.ts +0 -26
- package/dist/src/builtinTools/browserRuntime/PythonRunner.d.ts +0 -67
- package/dist/src/builtinTools/browserRuntime/WorkspaceBashFs.d.ts +0 -51
- package/dist/src/builtinTools/browserRuntime/assets.d.ts +0 -13
- package/dist/src/builtinTools/browserRuntime/loadBash.d.ts +0 -3
- package/dist/src/builtinTools/browserRuntime/pyodideWorker.d.ts +0 -44
- package/dist/src/builtinTools/command.d.ts +0 -35
- package/dist/src/builtinTools/constants.d.ts +0 -17
- package/dist/src/builtinTools/createBuiltinToolsPlugin.d.ts +0 -11
- package/dist/src/builtinTools/overview.d.ts +0 -5
- package/dist/src/builtinTools/paths.d.ts +0 -16
- package/dist/src/builtinTools/platformSkills.d.ts +0 -67
- package/dist/src/builtinTools/schemas.d.ts +0 -3
- package/dist/src/builtinTools/tools.d.ts +0 -64
- package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +0 -24
- package/dist/src/localFiles/host/sandboxClient.d.ts +0 -81
- package/dist/src/localFiles/host/sandboxFrames.d.ts +0 -9
- package/dist/src/localFiles/preview.d.ts +0 -2
- package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +0 -63
- package/dist/src/sessionUpload.d.ts +0 -14
|
@@ -1,48 +1,46 @@
|
|
|
1
|
-
var _ = Object.defineProperty,
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var _ = Object.defineProperty, k = Object.defineProperties;
|
|
2
|
+
var S = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var w = Object.getOwnPropertySymbols;
|
|
4
|
+
var C = Object.prototype.hasOwnProperty, P = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var u = (r, e, t) => e in r ? _(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, f = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
7
|
+
C.call(e, t) && u(r, t, e[t]);
|
|
8
|
+
if (w)
|
|
9
|
+
for (var t of w(e))
|
|
10
|
+
P.call(e, t) && u(r, t, e[t]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
13
|
-
var s = (r, e, t) => (
|
|
14
|
-
var
|
|
15
|
-
var
|
|
12
|
+
}, A = (r, e) => k(r, S(e));
|
|
13
|
+
var s = (r, e, t) => (u(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
|
+
var o = (r, e, t) => new Promise((i, a) => {
|
|
15
|
+
var n = (l) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
|
|
17
|
+
c(t.next(l));
|
|
18
|
+
} catch (d) {
|
|
19
|
+
a(d);
|
|
20
20
|
}
|
|
21
|
-
}, h = (
|
|
21
|
+
}, h = (l) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
23
|
+
c(t.throw(l));
|
|
24
|
+
} catch (d) {
|
|
25
|
+
a(d);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, c = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(n, h);
|
|
28
|
+
c((t = t.apply(r, e)).next());
|
|
29
29
|
});
|
|
30
|
-
import
|
|
31
|
-
import { FileSystemAccessAdapter as
|
|
32
|
-
import { FileSnapshotAdapter as F } from "../adapters/FileSnapshotAdapter.mjs";
|
|
30
|
+
import H from "../../EventBus.mjs";
|
|
31
|
+
import { FileSystemAccessAdapter as b } from "../adapters/FileSystemAccessAdapter.mjs";
|
|
33
32
|
import { getNativeDirectoryPicker as D } from "../adapters/fsaTypes.mjs";
|
|
34
|
-
import { LOCAL_FILES_FUNCTION_CODES as
|
|
35
|
-
import { getDownloadUrlAllowlist as
|
|
36
|
-
import { SensitiveFilePolicy as
|
|
37
|
-
import { resolveLimits as
|
|
38
|
-
import { createDefaultSessionFileTransfer as
|
|
39
|
-
import { createMemoryStore as
|
|
40
|
-
import { watchDirectoryHandle as
|
|
41
|
-
|
|
42
|
-
const m = {
|
|
33
|
+
import { LOCAL_FILES_FUNCTION_CODES as T } from "../constants.mjs";
|
|
34
|
+
import { getDownloadUrlAllowlist as F } from "../security/downloadUrlPolicy.mjs";
|
|
35
|
+
import { SensitiveFilePolicy as W } from "../security/sensitiveFiles.mjs";
|
|
36
|
+
import { resolveLimits as q } from "../limits.mjs";
|
|
37
|
+
import { createDefaultSessionFileTransfer as N } from "../transfer/SessionFileTransfer.mjs";
|
|
38
|
+
import { createMemoryStore as I } from "./handleStore.mjs";
|
|
39
|
+
import { watchDirectoryHandle as E } from "./watchDirectory.mjs";
|
|
40
|
+
const p = {
|
|
43
41
|
mode: "readwrite"
|
|
44
42
|
};
|
|
45
|
-
function
|
|
43
|
+
function K(r) {
|
|
46
44
|
const e = r.replace(/\\/g, "/").trim().replace(/^\.\/+/, "").replace(/\/+$/, "");
|
|
47
45
|
if (!e || e === ".")
|
|
48
46
|
return "";
|
|
@@ -52,10 +50,10 @@ function x(r) {
|
|
|
52
50
|
if (!t.some((i) => !i || i === "." || i === ".."))
|
|
53
51
|
return t.join("/");
|
|
54
52
|
}
|
|
55
|
-
function
|
|
53
|
+
function L(r) {
|
|
56
54
|
return !!r && typeof r == "object" && r.name === "AbortError";
|
|
57
55
|
}
|
|
58
|
-
class
|
|
56
|
+
class J {
|
|
59
57
|
constructor(e) {
|
|
60
58
|
s(this, "applicationId");
|
|
61
59
|
s(this, "limits");
|
|
@@ -64,22 +62,15 @@ class te {
|
|
|
64
62
|
s(this, "allowWorkspaceWideTextSearch");
|
|
65
63
|
s(this, "transfer");
|
|
66
64
|
s(this, "fetch");
|
|
67
|
-
s(this, "commandRunner");
|
|
68
|
-
/** 平台技能同步。由 BotClient 在启用本地工作区后挂上。 */
|
|
69
|
-
s(this, "platformSkills");
|
|
70
|
-
s(this, "browserRuntime");
|
|
71
|
-
/** 接入方的文件操作入口。不要使用 `adapter`。 */
|
|
72
|
-
s(this, "files");
|
|
73
65
|
s(this, "store");
|
|
74
66
|
s(this, "picker");
|
|
75
|
-
s(this, "event", new
|
|
67
|
+
s(this, "event", new H(!0));
|
|
76
68
|
s(this, "_status");
|
|
77
69
|
s(this, "_displayName");
|
|
78
70
|
s(this, "_adapter", null);
|
|
79
71
|
s(this, "pendingHandle", null);
|
|
80
72
|
s(this, "approvalHandler");
|
|
81
73
|
s(this, "activeCalls", 0);
|
|
82
|
-
s(this, "commandRunning", !1);
|
|
83
74
|
s(this, "inflight", /* @__PURE__ */ new Set());
|
|
84
75
|
s(this, "_ready", Promise.resolve());
|
|
85
76
|
s(this, "stopWatching", () => {
|
|
@@ -87,25 +78,17 @@ class te {
|
|
|
87
78
|
s(this, "pendingChangePaths", /* @__PURE__ */ new Set());
|
|
88
79
|
s(this, "changeTimer");
|
|
89
80
|
s(this, "refreshAllVisible", !1);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
this.applicationId = e.applicationId, this.store = (l = e.store) != null ? l : q(), this.picker = e.picker === null ? void 0 : (o = e.picker) != null ? o : D(), this.limits = E(t.limits), this.sensitive = new N(t.sensitiveRulesAppend), this.downloadUrlAllowlist = L(t.downloadUrlAllowlistAppend), this.allowWorkspaceWideTextSearch = !!t.allowWorkspaceWideTextSearch, this.approvalHandler = t.onApprovalRequired;
|
|
95
|
-
const i = (c = e.transfer) != null ? c : I(() => {
|
|
81
|
+
var n, h, c, l, d, m, g, y, v;
|
|
82
|
+
const t = (n = e.config) != null ? n : {};
|
|
83
|
+
this.applicationId = e.applicationId, this.store = (h = e.store) != null ? h : I(), this.picker = e.picker === null ? void 0 : (c = e.picker) != null ? c : D(), this.limits = q(t.limits), this.sensitive = new W(t.sensitiveRulesAppend), this.downloadUrlAllowlist = F(t.downloadUrlAllowlistAppend), this.allowWorkspaceWideTextSearch = !!t.allowWorkspaceWideTextSearch, this.approvalHandler = t.onApprovalRequired;
|
|
84
|
+
const i = (l = e.transfer) != null ? l : N(() => {
|
|
96
85
|
});
|
|
97
86
|
this.transfer = {
|
|
98
|
-
upload: (
|
|
99
|
-
resolveDownload: (
|
|
87
|
+
upload: (m = (d = t.transfer) == null ? void 0 : d.upload) != null ? m : i.upload,
|
|
88
|
+
resolveDownload: (y = (g = t.transfer) == null ? void 0 : g.resolveDownload) != null ? y : i.resolveDownload
|
|
100
89
|
};
|
|
101
|
-
const
|
|
102
|
-
this.fetch =
|
|
103
|
-
const a = (A = t.commandRuntime) == null ? void 0 : A.browser;
|
|
104
|
-
this.browserRuntime = {
|
|
105
|
-
enabled: (a == null ? void 0 : a.enabled) !== !1,
|
|
106
|
-
bashModuleURL: a == null ? void 0 : a.bashModuleURL,
|
|
107
|
-
pyodideIndexURL: a == null ? void 0 : a.pyodideIndexURL
|
|
108
|
-
}, this._status = this.picker ? "none" : "unsupported", this.files = new j(this);
|
|
90
|
+
const a = (v = e.fetch) != null ? v : typeof fetch == "function" ? fetch : void 0;
|
|
91
|
+
this.fetch = a ? a.bind(globalThis) : () => Promise.reject(new Error("fetch is not available")), this._status = this.picker ? "none" : "unsupported";
|
|
109
92
|
}
|
|
110
93
|
// -------------------------------------------------------------------------
|
|
111
94
|
// 状态
|
|
@@ -124,10 +107,7 @@ class te {
|
|
|
124
107
|
get ready() {
|
|
125
108
|
return this._ready;
|
|
126
109
|
}
|
|
127
|
-
/**
|
|
128
|
-
* @internal 已授权时的磁盘后端,供内置工具使用。
|
|
129
|
-
* 接入方用 `files`:这里的路径必须已规范化,异常里也可能带系统路径。
|
|
130
|
-
*/
|
|
110
|
+
/** @internal 已授权时可用的 Adapter。 */
|
|
131
111
|
get adapter() {
|
|
132
112
|
return this._status === "granted" ? this._adapter : null;
|
|
133
113
|
}
|
|
@@ -143,11 +123,8 @@ class te {
|
|
|
143
123
|
displayName: t
|
|
144
124
|
}));
|
|
145
125
|
}
|
|
146
|
-
replaceAdapter(e) {
|
|
147
|
-
this._adapter !== e && this.files.releaseAllUrls(), this._adapter = e;
|
|
148
|
-
}
|
|
149
126
|
attachHandle(e) {
|
|
150
|
-
this.cancelFilesChanged(), this.pendingHandle = e, this.
|
|
127
|
+
this.cancelFilesChanged(), this.pendingHandle = e, this._adapter = new b(e), this.setStatus("granted", e.name), this.unwatchDirectory(), this.stopWatching = E(e, (t) => this.notifyFilesChanged(t));
|
|
151
128
|
}
|
|
152
129
|
// -------------------------------------------------------------------------
|
|
153
130
|
// 授权
|
|
@@ -167,13 +144,18 @@ class te {
|
|
|
167
144
|
} catch (t) {
|
|
168
145
|
return Promise.reject(t);
|
|
169
146
|
}
|
|
170
|
-
return e.then((t) => (this
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
147
|
+
return e.then((t) => o(this, null, function* () {
|
|
148
|
+
var a, n;
|
|
149
|
+
this.cancelAll();
|
|
150
|
+
const i = (n = yield (a = t.queryPermission) == null ? void 0 : a.call(t, p)) != null ? n : "granted";
|
|
151
|
+
return yield this.store.set(this.handleKey, {
|
|
152
|
+
handle: t,
|
|
153
|
+
displayName: t.name,
|
|
154
|
+
savedAt: Date.now()
|
|
155
|
+
}).catch(() => {
|
|
156
|
+
}), i === "denied" ? (this.pendingHandle = t, this._adapter = null, this.setStatus("denied", t.name), !1) : (this.attachHandle(t), !0);
|
|
157
|
+
}), (t) => {
|
|
158
|
+
if (L(t))
|
|
177
159
|
return !1;
|
|
178
160
|
throw t;
|
|
179
161
|
});
|
|
@@ -183,51 +165,29 @@ class te {
|
|
|
183
165
|
return this._ready = this.doRestore(), this._ready;
|
|
184
166
|
}
|
|
185
167
|
doRestore() {
|
|
186
|
-
return
|
|
187
|
-
var
|
|
188
|
-
const e = this.epoch;
|
|
168
|
+
return o(this, null, function* () {
|
|
169
|
+
var i, a, n;
|
|
189
170
|
if (!this.picker) {
|
|
190
171
|
this._adapter || this.setStatus("unsupported");
|
|
191
172
|
return;
|
|
192
173
|
}
|
|
193
|
-
let
|
|
174
|
+
let e;
|
|
194
175
|
try {
|
|
195
|
-
|
|
196
|
-
} catch (
|
|
197
|
-
|
|
176
|
+
e = yield this.store.get(this.handleKey);
|
|
177
|
+
} catch (h) {
|
|
178
|
+
e = void 0;
|
|
198
179
|
}
|
|
199
|
-
if (e
|
|
200
|
-
|
|
201
|
-
if (!(t != null && t.handle)) {
|
|
202
|
-
this.pendingHandle = null, this.replaceAdapter(null), this.setStatus("none", void 0);
|
|
180
|
+
if (!(e != null && e.handle)) {
|
|
181
|
+
this.pendingHandle = null, this._adapter = null, this.setStatus("none", void 0);
|
|
203
182
|
return;
|
|
204
183
|
}
|
|
205
|
-
let
|
|
184
|
+
let t;
|
|
206
185
|
try {
|
|
207
|
-
|
|
208
|
-
} catch (
|
|
209
|
-
|
|
186
|
+
t = (n = yield (a = (i = e.handle).queryPermission) == null ? void 0 : a.call(i, p)) != null ? n : "prompt";
|
|
187
|
+
} catch (h) {
|
|
188
|
+
t = "prompt";
|
|
210
189
|
}
|
|
211
|
-
|
|
212
|
-
if (i === "granted" || i === "prompt" && (yield this.canList(t.handle))) {
|
|
213
|
-
if (e !== this.epoch)
|
|
214
|
-
return;
|
|
215
|
-
this.attachHandle(t.handle);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
this.pendingHandle = t.handle, this.replaceAdapter(null), this.setStatus(i === "denied" ? "denied" : "prompt", t.displayName);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
/** queryPermission 仍可能是 prompt,但选择框留下的句柄其实列得出目录。 */
|
|
223
|
-
canList(e) {
|
|
224
|
-
return d(this, null, function* () {
|
|
225
|
-
const t = new S(e);
|
|
226
|
-
let i;
|
|
227
|
-
const n = new Promise((l) => {
|
|
228
|
-
i = setTimeout(() => l(!1), 2e3);
|
|
229
|
-
}), a = t.listEntries("").then(() => !0).catch(() => !1), h = yield Promise.race([a, n]);
|
|
230
|
-
return clearTimeout(i), h;
|
|
190
|
+
t === "granted" ? this.attachHandle(e.handle) : (this.pendingHandle = e.handle, this._adapter = null, this.setStatus(t === "denied" ? "denied" : "prompt", e.displayName));
|
|
231
191
|
});
|
|
232
192
|
}
|
|
233
193
|
/** 对已保存的目录重新申请权限。必须在用户点击事件中调用。 */
|
|
@@ -237,36 +197,22 @@ class te {
|
|
|
237
197
|
return Promise.resolve(!1);
|
|
238
198
|
let t;
|
|
239
199
|
try {
|
|
240
|
-
t = e.requestPermission(
|
|
200
|
+
t = e.requestPermission(p);
|
|
241
201
|
} catch (i) {
|
|
242
202
|
return Promise.reject(i);
|
|
243
203
|
}
|
|
244
|
-
return t.then((i) => i === "granted" ? (this.attachHandle(e), !0) : (this.
|
|
204
|
+
return t.then((i) => i === "granted" ? (this.attachHandle(e), !0) : (this._adapter = null, this.setStatus(i === "denied" ? "denied" : "prompt", e.name), !1));
|
|
245
205
|
}
|
|
246
206
|
/** 断开工作区并删除持久化句柄。状态立即变为未授权,存储删除在其后完成。 */
|
|
247
207
|
clear() {
|
|
248
|
-
return
|
|
249
|
-
this.
|
|
208
|
+
return o(this, null, function* () {
|
|
209
|
+
this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.pendingHandle = null, this._adapter = null, this.setStatus(this.picker ? "none" : "unsupported", void 0), yield this.store.delete(this.handleKey).catch(() => {
|
|
250
210
|
});
|
|
251
211
|
});
|
|
252
212
|
}
|
|
253
|
-
/**
|
|
254
|
-
* 用文件列表挂上工作区。路径来自 webkitRelativePath,选完就能列出层级。
|
|
255
|
-
* 写入只留在内存里,不会出现在用户磁盘上。需要落盘时用 pick()。
|
|
256
|
-
*/
|
|
257
|
-
attachFileSnapshot(e, t) {
|
|
258
|
-
var h, l, o;
|
|
259
|
-
const i = Array.from(e), n = t || ((l = (h = i[0]) == null ? void 0 : h.webkitRelativePath) == null ? void 0 : l.split(/[/\\]/)[0]) || ((o = i[0]) == null ? void 0 : o.name) || "工作文件夹", a = i.map((c) => ({
|
|
260
|
-
name: c.name,
|
|
261
|
-
webkitRelativePath: c.webkitRelativePath,
|
|
262
|
-
lastModified: c.lastModified,
|
|
263
|
-
blob: c
|
|
264
|
-
}));
|
|
265
|
-
this.attachAdapter(new F(a, n), n);
|
|
266
|
-
}
|
|
267
213
|
/** 直接挂载一个 Adapter(测试或自定义后端),视为已授权。 */
|
|
268
214
|
attachAdapter(e, t = e.displayName) {
|
|
269
|
-
this.
|
|
215
|
+
this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.pendingHandle = null, this._adapter = e, this.setStatus("granted", t);
|
|
270
216
|
}
|
|
271
217
|
/**
|
|
272
218
|
* 通知目录树重读。`paths` 是相对工作区根的目录;省略时重读当前展开的全部目录。
|
|
@@ -278,7 +224,7 @@ class te {
|
|
|
278
224
|
this.refreshAllVisible = !0;
|
|
279
225
|
else
|
|
280
226
|
for (const t of e) {
|
|
281
|
-
const i =
|
|
227
|
+
const i = K(t);
|
|
282
228
|
i === void 0 ? this.refreshAllVisible = !0 : this.pendingChangePaths.add(i);
|
|
283
229
|
}
|
|
284
230
|
clearTimeout(this.changeTimer), this.changeTimer = setTimeout(() => this.flushFilesChanged(), 150);
|
|
@@ -286,29 +232,19 @@ class te {
|
|
|
286
232
|
}
|
|
287
233
|
/** @internal 工具执行中遇到权限错误时调用,重新检查并更新状态。 */
|
|
288
234
|
handlePermissionLost() {
|
|
289
|
-
return
|
|
235
|
+
return o(this, null, function* () {
|
|
290
236
|
const e = this.pendingHandle;
|
|
291
237
|
if (!(e != null && e.queryPermission))
|
|
292
238
|
return;
|
|
293
|
-
const t = yield e.queryPermission(
|
|
294
|
-
|
|
295
|
-
if (t === "prompt" && this._adapter)
|
|
296
|
-
try {
|
|
297
|
-
yield this._adapter.listEntries("");
|
|
298
|
-
return;
|
|
299
|
-
} catch (i) {
|
|
300
|
-
if ((i && typeof i == "object" ? i.name : void 0) !== "NotAllowedError")
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.replaceAdapter(null), this.setStatus(t === "denied" ? "denied" : "prompt", e.name);
|
|
304
|
-
}
|
|
239
|
+
const t = yield e.queryPermission(p).catch(() => "prompt");
|
|
240
|
+
t !== "granted" && (this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this._adapter = null, this.setStatus(t === "denied" ? "denied" : "prompt", e.name));
|
|
305
241
|
});
|
|
306
242
|
}
|
|
307
243
|
// -------------------------------------------------------------------------
|
|
308
244
|
// 外发提示
|
|
309
245
|
// -------------------------------------------------------------------------
|
|
310
246
|
isDisclosureAcknowledged() {
|
|
311
|
-
return
|
|
247
|
+
return o(this, null, function* () {
|
|
312
248
|
try {
|
|
313
249
|
return !!(yield this.store.get(this.disclosureKey));
|
|
314
250
|
} catch (e) {
|
|
@@ -317,7 +253,7 @@ class te {
|
|
|
317
253
|
});
|
|
318
254
|
}
|
|
319
255
|
acknowledgeDisclosure() {
|
|
320
|
-
return
|
|
256
|
+
return o(this, null, function* () {
|
|
321
257
|
yield this.store.set(this.disclosureKey, !0).catch(() => {
|
|
322
258
|
});
|
|
323
259
|
});
|
|
@@ -345,16 +281,6 @@ class te {
|
|
|
345
281
|
e || (e = !0, this.activeCalls--);
|
|
346
282
|
};
|
|
347
283
|
}
|
|
348
|
-
/** @internal 同一工作区同一时间只跑一个命令;已有命令在运行时返回 null。 */
|
|
349
|
-
acquireCommand() {
|
|
350
|
-
if (this.commandRunning)
|
|
351
|
-
return null;
|
|
352
|
-
this.commandRunning = !0;
|
|
353
|
-
let e = !1;
|
|
354
|
-
return () => {
|
|
355
|
-
e || (e = !0, this.commandRunning = !1);
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
284
|
/** @internal 登记进行中的调用,更换或断开工作区时统一中止。 */
|
|
359
285
|
track(e) {
|
|
360
286
|
return this.inflight.add(e), () => this.inflight.delete(e);
|
|
@@ -365,14 +291,14 @@ class te {
|
|
|
365
291
|
this.inflight.clear(), e.forEach((t) => t.abort());
|
|
366
292
|
}
|
|
367
293
|
handshake() {
|
|
368
|
-
const e = Object.fromEntries(
|
|
294
|
+
const e = Object.fromEntries(T.map((t) => [t, !0]));
|
|
369
295
|
return {
|
|
370
296
|
protocolVersion: "1.0",
|
|
371
|
-
capabilities:
|
|
297
|
+
capabilities: A(f({}, e), {
|
|
372
298
|
cancellation: !0,
|
|
373
299
|
atomicWrite: !0
|
|
374
300
|
}),
|
|
375
|
-
limits:
|
|
301
|
+
limits: f({}, this.limits)
|
|
376
302
|
};
|
|
377
303
|
}
|
|
378
304
|
// -------------------------------------------------------------------------
|
|
@@ -394,7 +320,7 @@ class te {
|
|
|
394
320
|
}
|
|
395
321
|
flushFilesChanged() {
|
|
396
322
|
this.changeTimer = void 0;
|
|
397
|
-
const e = this.refreshAllVisible, t = [...this.pendingChangePaths].sort((i,
|
|
323
|
+
const e = this.refreshAllVisible, t = [...this.pendingChangePaths].sort((i, a) => i < a ? -1 : i > a ? 1 : 0);
|
|
398
324
|
this.pendingChangePaths.clear(), this.refreshAllVisible = !1, this._status === "granted" && this.emit("files:changed", {
|
|
399
325
|
paths: e ? [] : t
|
|
400
326
|
});
|
|
@@ -409,5 +335,5 @@ class te {
|
|
|
409
335
|
}
|
|
410
336
|
}
|
|
411
337
|
export {
|
|
412
|
-
|
|
338
|
+
J as LocalWorkspace
|
|
413
339
|
};
|
package/dist/es/package.json.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const e = "@glodon-aiot/bot-client-sdk",
|
|
1
|
+
const e = "@glodon-aiot/bot-client-sdk", t = "3.26.0-alpha.23", i = "glodoncv", s = "aiot bot client js sdk", n = "module", y = !1, o = [
|
|
2
2
|
"aiot",
|
|
3
3
|
"bot",
|
|
4
4
|
"bot client",
|
|
5
5
|
"sdk"
|
|
6
|
-
],
|
|
6
|
+
], l = [
|
|
7
7
|
"dist"
|
|
8
|
-
], p = "./dist/es/index.mjs",
|
|
8
|
+
], p = "./dist/es/index.mjs", c = "./dist/lib/index.js", r = "./dist/src/index.d.ts", d = {
|
|
9
9
|
".": {
|
|
10
10
|
import: "./dist/es/index.mjs",
|
|
11
11
|
require: "./dist/lib/index.js",
|
|
@@ -22,14 +22,8 @@ const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.20", t = "glodoncv",
|
|
|
22
22
|
preview: "vite preview",
|
|
23
23
|
check: "yarn prettier --check .",
|
|
24
24
|
write: "yarn prettier --write .",
|
|
25
|
-
lint: "eslint --ext .tsx,.ts --fix ./example -c .eslintrc.js"
|
|
26
|
-
|
|
27
|
-
"upload:just-bash": "node scripts/build-just-bash.mjs && node scripts/upload-cdn-libs.cjs just-bash",
|
|
28
|
-
"build:pyodide": "node scripts/build-pyodide.mjs",
|
|
29
|
-
"upload:pyodide": "node scripts/build-pyodide.mjs && node scripts/upload-cdn-libs.cjs pyodide",
|
|
30
|
-
test: "vitest run",
|
|
31
|
-
"test:watch": "vitest"
|
|
32
|
-
}, b = {
|
|
25
|
+
lint: "eslint --ext .tsx,.ts --fix ./example -c .eslintrc.js"
|
|
26
|
+
}, g = {
|
|
33
27
|
"@babel/core": "^7.20.12",
|
|
34
28
|
"@commitlint/cli": "^17.0.3",
|
|
35
29
|
"@commitlint/config-conventional": "^17.0.3",
|
|
@@ -51,10 +45,8 @@ const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.20", t = "glodoncv",
|
|
|
51
45
|
express: "4",
|
|
52
46
|
"http-proxy-middleware": "^3.0.0",
|
|
53
47
|
"identity-obj-proxy": "^3.0.0",
|
|
54
|
-
"just-bash": "3.6.0",
|
|
55
48
|
"npm-run-all": "^4.1.5",
|
|
56
49
|
prettier: "2.7.1",
|
|
57
|
-
pyodide: "314.0.7",
|
|
58
50
|
"rollup-plugin-visualizer": "^6.0.1",
|
|
59
51
|
"socket.io": "^4.7.5",
|
|
60
52
|
"ts-node": "^10.9.2",
|
|
@@ -62,58 +54,57 @@ const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.20", t = "glodoncv",
|
|
|
62
54
|
vite: "^4.1.1",
|
|
63
55
|
"vite-plugin-dts": "^4.3.0",
|
|
64
56
|
"vite-plugin-externalize-deps": "^0.9.0",
|
|
65
|
-
"vite-tsconfig-paths": "^5.1.4"
|
|
66
|
-
vitest: "^0.34.6"
|
|
57
|
+
"vite-tsconfig-paths": "^5.1.4"
|
|
67
58
|
}, m = {
|
|
68
59
|
access: "public",
|
|
69
60
|
registry: "https://registry.npmjs.org/"
|
|
70
|
-
},
|
|
71
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
61
|
+
}, b = {
|
|
62
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.23",
|
|
72
63
|
axios: "0.24.0",
|
|
73
64
|
buffer: "^6.0.3",
|
|
74
65
|
dayjs: "^1.11.13",
|
|
75
66
|
"js-base64": "^3.7.7",
|
|
76
67
|
"socket.io-client": "^4.7.5",
|
|
77
68
|
uuid: "^11.1.0"
|
|
78
|
-
},
|
|
69
|
+
}, x = {
|
|
79
70
|
name: e,
|
|
80
|
-
version:
|
|
81
|
-
author:
|
|
82
|
-
description:
|
|
71
|
+
version: t,
|
|
72
|
+
author: i,
|
|
73
|
+
description: s,
|
|
83
74
|
type: n,
|
|
84
75
|
sideEffects: !1,
|
|
85
76
|
keywords: o,
|
|
86
|
-
files:
|
|
77
|
+
files: l,
|
|
87
78
|
module: p,
|
|
88
|
-
main:
|
|
89
|
-
typings:
|
|
90
|
-
exports:
|
|
79
|
+
main: c,
|
|
80
|
+
typings: r,
|
|
81
|
+
exports: d,
|
|
91
82
|
license: a,
|
|
92
83
|
scripts: u,
|
|
93
|
-
devDependencies:
|
|
84
|
+
devDependencies: g,
|
|
94
85
|
"lint-staged": {
|
|
95
86
|
"*.{js,css,md,jsx,less,ts,tsx,json}": "prettier --write"
|
|
96
87
|
},
|
|
97
88
|
publishConfig: m,
|
|
98
|
-
dependencies:
|
|
89
|
+
dependencies: b
|
|
99
90
|
};
|
|
100
91
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
i as author,
|
|
93
|
+
x as default,
|
|
94
|
+
b as dependencies,
|
|
95
|
+
s as description,
|
|
96
|
+
g as devDependencies,
|
|
97
|
+
d as exports,
|
|
98
|
+
l as files,
|
|
108
99
|
o as keywords,
|
|
109
100
|
a as license,
|
|
110
|
-
|
|
101
|
+
c as main,
|
|
111
102
|
p as module,
|
|
112
103
|
e as name,
|
|
113
104
|
m as publishConfig,
|
|
114
105
|
u as scripts,
|
|
115
|
-
|
|
106
|
+
y as sideEffects,
|
|
116
107
|
n as type,
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
r as typings,
|
|
109
|
+
t as version
|
|
119
110
|
};
|