@glodon-aiot/bot-client-sdk 3.26.0-alpha.19 → 3.26.0-alpha.20
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 +12 -2
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +47 -33
- package/dist/es/localFiles/errors.mjs +21 -19
- package/dist/es/localFiles/host/sandboxClient.mjs +196 -171
- package/dist/es/localFiles/preview.mjs +33 -0
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +19 -16
- package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +191 -133
- package/dist/es/package.json.mjs +2 -2
- package/dist/lib/index.js +22 -22
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +4 -0
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +8 -0
- package/dist/src/localFiles/host/sandboxClient.d.ts +4 -0
- package/dist/src/localFiles/preview.d.ts +2 -0
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +1 -0
- package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +13 -4
- package/package.json +2 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _ = Object.defineProperty, b = Object.defineProperties;
|
|
2
2
|
var C = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var k = Object.getOwnPropertySymbols;
|
|
4
4
|
var R = Object.prototype.hasOwnProperty, H = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var p = (r, e, t) => e in r ?
|
|
5
|
+
var p = (r, e, t) => e in r ? _(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
7
|
R.call(e, t) && p(r, t, e[t]);
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
8
|
+
if (k)
|
|
9
|
+
for (var t of k(e))
|
|
10
10
|
H.call(e, t) && p(r, t, e[t]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
12
|
+
}, P = (r, e) => b(r, C(e));
|
|
13
13
|
var s = (r, e, t) => (p(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
14
|
var d = (r, e, t) => new Promise((i, n) => {
|
|
15
15
|
var a = (o) => {
|
|
@@ -28,7 +28,7 @@ var d = (r, e, t) => new Promise((i, n) => {
|
|
|
28
28
|
l((t = t.apply(r, e)).next());
|
|
29
29
|
});
|
|
30
30
|
import T from "../../EventBus.mjs";
|
|
31
|
-
import { FileSystemAccessAdapter as
|
|
31
|
+
import { FileSystemAccessAdapter as S } from "../adapters/FileSystemAccessAdapter.mjs";
|
|
32
32
|
import { FileSnapshotAdapter as F } from "../adapters/FileSnapshotAdapter.mjs";
|
|
33
33
|
import { getNativeDirectoryPicker as D } from "../adapters/fsaTypes.mjs";
|
|
34
34
|
import { LOCAL_FILES_FUNCTION_CODES as W } from "../constants.mjs";
|
|
@@ -143,8 +143,11 @@ class te {
|
|
|
143
143
|
displayName: t
|
|
144
144
|
}));
|
|
145
145
|
}
|
|
146
|
+
replaceAdapter(e) {
|
|
147
|
+
this._adapter !== e && this.files.releaseAllUrls(), this._adapter = e;
|
|
148
|
+
}
|
|
146
149
|
attachHandle(e) {
|
|
147
|
-
this.cancelFilesChanged(), this.pendingHandle = e, this.
|
|
150
|
+
this.cancelFilesChanged(), this.pendingHandle = e, this.replaceAdapter(new S(e)), this.setStatus("granted", e.name), this.unwatchDirectory(), this.stopWatching = U(e, (t) => this.notifyFilesChanged(t));
|
|
148
151
|
}
|
|
149
152
|
// -------------------------------------------------------------------------
|
|
150
153
|
// 授权
|
|
@@ -196,7 +199,7 @@ class te {
|
|
|
196
199
|
if (e !== this.epoch)
|
|
197
200
|
return;
|
|
198
201
|
if (!(t != null && t.handle)) {
|
|
199
|
-
this.pendingHandle = null, this.
|
|
202
|
+
this.pendingHandle = null, this.replaceAdapter(null), this.setStatus("none", void 0);
|
|
200
203
|
return;
|
|
201
204
|
}
|
|
202
205
|
let i;
|
|
@@ -212,14 +215,14 @@ class te {
|
|
|
212
215
|
this.attachHandle(t.handle);
|
|
213
216
|
return;
|
|
214
217
|
}
|
|
215
|
-
this.pendingHandle = t.handle, this.
|
|
218
|
+
this.pendingHandle = t.handle, this.replaceAdapter(null), this.setStatus(i === "denied" ? "denied" : "prompt", t.displayName);
|
|
216
219
|
}
|
|
217
220
|
});
|
|
218
221
|
}
|
|
219
222
|
/** queryPermission 仍可能是 prompt,但选择框留下的句柄其实列得出目录。 */
|
|
220
223
|
canList(e) {
|
|
221
224
|
return d(this, null, function* () {
|
|
222
|
-
const t = new
|
|
225
|
+
const t = new S(e);
|
|
223
226
|
let i;
|
|
224
227
|
const n = new Promise((l) => {
|
|
225
228
|
i = setTimeout(() => l(!1), 2e3);
|
|
@@ -238,12 +241,12 @@ class te {
|
|
|
238
241
|
} catch (i) {
|
|
239
242
|
return Promise.reject(i);
|
|
240
243
|
}
|
|
241
|
-
return t.then((i) => i === "granted" ? (this.attachHandle(e), !0) : (this.
|
|
244
|
+
return t.then((i) => i === "granted" ? (this.attachHandle(e), !0) : (this.replaceAdapter(null), this.setStatus(i === "denied" ? "denied" : "prompt", e.name), !1));
|
|
242
245
|
}
|
|
243
246
|
/** 断开工作区并删除持久化句柄。状态立即变为未授权,存储删除在其后完成。 */
|
|
244
247
|
clear() {
|
|
245
248
|
return d(this, null, function* () {
|
|
246
|
-
this.epoch += 1, this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.pendingHandle = null, this.
|
|
249
|
+
this.epoch += 1, this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.pendingHandle = null, this.replaceAdapter(null), this.setStatus(this.picker ? "none" : "unsupported", void 0), yield this.store.delete(this.handleKey).catch(() => {
|
|
247
250
|
});
|
|
248
251
|
});
|
|
249
252
|
}
|
|
@@ -263,7 +266,7 @@ class te {
|
|
|
263
266
|
}
|
|
264
267
|
/** 直接挂载一个 Adapter(测试或自定义后端),视为已授权。 */
|
|
265
268
|
attachAdapter(e, t = e.displayName) {
|
|
266
|
-
this.epoch += 1, this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.pendingHandle = null, this.
|
|
269
|
+
this.epoch += 1, this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.pendingHandle = null, this.replaceAdapter(e), this.setStatus("granted", t);
|
|
267
270
|
}
|
|
268
271
|
/**
|
|
269
272
|
* 通知目录树重读。`paths` 是相对工作区根的目录;省略时重读当前展开的全部目录。
|
|
@@ -297,7 +300,7 @@ class te {
|
|
|
297
300
|
if ((i && typeof i == "object" ? i.name : void 0) !== "NotAllowedError")
|
|
298
301
|
return;
|
|
299
302
|
}
|
|
300
|
-
this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.
|
|
303
|
+
this.cancelAll(), this.cancelFilesChanged(), this.unwatchDirectory(), this.replaceAdapter(null), this.setStatus(t === "denied" ? "denied" : "prompt", e.name);
|
|
301
304
|
}
|
|
302
305
|
});
|
|
303
306
|
}
|
|
@@ -365,7 +368,7 @@ class te {
|
|
|
365
368
|
const e = Object.fromEntries(W.map((t) => [t, !0]));
|
|
366
369
|
return {
|
|
367
370
|
protocolVersion: "1.0",
|
|
368
|
-
capabilities:
|
|
371
|
+
capabilities: P(u({}, e), {
|
|
369
372
|
cancellation: !0,
|
|
370
373
|
atomicWrite: !0
|
|
371
374
|
}),
|
|
@@ -1,188 +1,246 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var B = (n, t, e) => t in n ? A(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var p = (n, t, e) => (B(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
var a = (n, t, e) => new Promise((s, r) => {
|
|
5
|
+
var i = (c) => {
|
|
3
6
|
try {
|
|
4
|
-
|
|
5
|
-
} catch (
|
|
6
|
-
|
|
7
|
+
h(e.next(c));
|
|
8
|
+
} catch (w) {
|
|
9
|
+
r(w);
|
|
7
10
|
}
|
|
8
11
|
}, o = (c) => {
|
|
9
12
|
try {
|
|
10
|
-
|
|
11
|
-
} catch (
|
|
12
|
-
|
|
13
|
+
h(e.throw(c));
|
|
14
|
+
} catch (w) {
|
|
15
|
+
r(w);
|
|
13
16
|
}
|
|
14
|
-
},
|
|
15
|
-
|
|
17
|
+
}, h = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(i, o);
|
|
18
|
+
h((e = e.apply(n, t)).next());
|
|
16
19
|
});
|
|
17
|
-
import { ToolError as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import { ToolError as l, ToolCode as f, toToolError as F, workspaceNotGranted as E } from "../errors.mjs";
|
|
21
|
+
import { mediaTypeOf as k, PREVIEW_TYPE_MESSAGE as R } from "../preview.mjs";
|
|
22
|
+
import { parentPath as d } from "../security/pathPolicy.mjs";
|
|
23
|
+
import { SensitiveFilePolicy as U } from "../security/sensitiveFiles.mjs";
|
|
24
|
+
const b = "路径必须在工作区内,不能包含 ..、盘符或空字符。";
|
|
25
|
+
function m() {
|
|
26
|
+
return new l(f.Forbidden, b, {
|
|
23
27
|
reason: "path_outside_workspace"
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
28
|
-
if (
|
|
30
|
+
function u(n, t) {
|
|
31
|
+
if (n == null || n === "") {
|
|
32
|
+
if (t)
|
|
29
33
|
return "";
|
|
30
|
-
throw new
|
|
31
|
-
}
|
|
32
|
-
if (typeof
|
|
33
|
-
throw new
|
|
34
|
-
if (
|
|
35
|
-
throw
|
|
36
|
-
const
|
|
37
|
-
if (/^[a-zA-Z]:/.test(
|
|
38
|
-
throw
|
|
39
|
-
const
|
|
40
|
-
for (const
|
|
41
|
-
if (!(
|
|
42
|
-
if (
|
|
43
|
-
throw
|
|
44
|
-
|
|
34
|
+
throw new l(f.BadRequest, "缺少参数 path。");
|
|
35
|
+
}
|
|
36
|
+
if (typeof n != "string")
|
|
37
|
+
throw new l(f.BadRequest, "path 必须是字符串。");
|
|
38
|
+
if (n.includes("\0") || /%(2e|2f|5c|00)/i.test(n))
|
|
39
|
+
throw m();
|
|
40
|
+
const e = n.normalize("NFC").replace(/\\/g, "/").trim();
|
|
41
|
+
if (/^[a-zA-Z]:/.test(e))
|
|
42
|
+
throw m();
|
|
43
|
+
const s = [];
|
|
44
|
+
for (const i of e.split("/"))
|
|
45
|
+
if (!(i === "" || i === ".")) {
|
|
46
|
+
if (i === "..")
|
|
47
|
+
throw m();
|
|
48
|
+
s.push(i);
|
|
45
49
|
}
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
throw new
|
|
49
|
-
return
|
|
50
|
+
const r = s.join("/");
|
|
51
|
+
if (!r && !t)
|
|
52
|
+
throw new l(f.BadRequest, "path 不能指向工作区根目录。");
|
|
53
|
+
return r;
|
|
50
54
|
}
|
|
51
|
-
function
|
|
52
|
-
return new
|
|
55
|
+
function g(n) {
|
|
56
|
+
return new l(f.NotImplemented, `当前工作区不能${n}。`);
|
|
53
57
|
}
|
|
54
|
-
function
|
|
58
|
+
function P(n, t, e) {
|
|
55
59
|
return {
|
|
56
|
-
name:
|
|
57
|
-
path:
|
|
58
|
-
kind:
|
|
59
|
-
size:
|
|
60
|
-
lastModified:
|
|
61
|
-
sensitive:
|
|
60
|
+
name: e.name,
|
|
61
|
+
path: t,
|
|
62
|
+
kind: e.kind,
|
|
63
|
+
size: e.size,
|
|
64
|
+
lastModified: e.lastModified,
|
|
65
|
+
sensitive: e.kind === "file" && n.sensitive.isSensitive(t)
|
|
62
66
|
};
|
|
63
67
|
}
|
|
64
|
-
class
|
|
65
|
-
constructor(
|
|
66
|
-
this
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
class C {
|
|
69
|
+
constructor(t) {
|
|
70
|
+
p(this, "previews", /* @__PURE__ */ new Map());
|
|
71
|
+
p(this, "previewByPath", /* @__PURE__ */ new Map());
|
|
72
|
+
this.host = t;
|
|
73
|
+
}
|
|
74
|
+
stat(t = "") {
|
|
75
|
+
return a(this, null, function* () {
|
|
76
|
+
const e = u(t, !0), s = yield this.run((r) => r.stat(e));
|
|
77
|
+
return P(this.host, e, s);
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
80
|
list() {
|
|
75
|
-
return
|
|
76
|
-
const
|
|
77
|
-
return (yield this.run((
|
|
78
|
-
const o =
|
|
79
|
-
return
|
|
81
|
+
return a(this, arguments, function* (t = "", e = {}) {
|
|
82
|
+
const s = u(t, !0);
|
|
83
|
+
return (yield this.run((i) => i.listEntries(s, e.signal))).map((i) => {
|
|
84
|
+
const o = s ? `${s}/${i.name}` : i.name;
|
|
85
|
+
return P(this.host, o, i);
|
|
80
86
|
});
|
|
81
87
|
});
|
|
82
88
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
|
+
* 给 `<img>`、`<video>`、`<audio>` 的地址。浏览器自己拉字节,调用方拿不到文件内容。
|
|
91
|
+
* 同一路径在大小和修改时间没变时返回同一个地址,并增加引用。用完调用 `releaseUrl`。
|
|
92
|
+
*/
|
|
93
|
+
url(t) {
|
|
94
|
+
return a(this, null, function* () {
|
|
95
|
+
var c, w;
|
|
96
|
+
const e = u(t, !1);
|
|
97
|
+
if (this.assertAccess(e, "read"), !k(e))
|
|
98
|
+
throw new l(f.BadRequest, R);
|
|
99
|
+
const s = yield this.stat(e);
|
|
100
|
+
if (s.kind !== "file")
|
|
101
|
+
throw new l(f.BadRequest, "目标是目录,不是文件。");
|
|
102
|
+
const r = `${(c = s.size) != null ? c : ""}:${(w = s.lastModified) != null ? w : ""}`, i = this.previewByPath.get(e);
|
|
103
|
+
if ((i == null ? void 0 : i.stamp) === r)
|
|
104
|
+
return i.refs += 1, i.url;
|
|
105
|
+
const o = yield this.openPreview(e), h = {
|
|
106
|
+
url: o.url,
|
|
107
|
+
path: e,
|
|
108
|
+
stamp: r,
|
|
109
|
+
refs: 1,
|
|
110
|
+
release: o.release
|
|
111
|
+
};
|
|
112
|
+
return this.previews.set(h.url, h), this.previewByPath.set(e, h), h.url;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** 页面不再显示这个地址时调用。引用归零后,blob 地址会撤销,沙箱票据会作废。 */
|
|
116
|
+
releaseUrl(t) {
|
|
117
|
+
const e = this.previews.get(t);
|
|
118
|
+
e && (e.refs -= 1, !(e.refs > 0) && this.dropPreview(e));
|
|
119
|
+
}
|
|
120
|
+
/** 工作区断开时释放还没归还的地址。 */
|
|
121
|
+
releaseAllUrls() {
|
|
122
|
+
const t = [...this.previews.values()];
|
|
123
|
+
this.previews.clear(), this.previewByPath.clear(), t.forEach((e) => e.release());
|
|
124
|
+
}
|
|
125
|
+
read(t) {
|
|
126
|
+
return a(this, null, function* () {
|
|
127
|
+
const e = u(t, !1);
|
|
128
|
+
return this.assertAccess(e, "read"), this.run((s) => a(this, null, function* () {
|
|
129
|
+
if ((yield s.stat(e)).kind !== "file")
|
|
130
|
+
throw new l(f.BadRequest, "目标是目录,不是文件。");
|
|
131
|
+
return s.readFile(e);
|
|
90
132
|
}));
|
|
91
133
|
});
|
|
92
134
|
}
|
|
93
|
-
readText(
|
|
94
|
-
return
|
|
95
|
-
return (yield this.read(
|
|
135
|
+
readText(t) {
|
|
136
|
+
return a(this, null, function* () {
|
|
137
|
+
return (yield this.read(t)).text();
|
|
96
138
|
});
|
|
97
139
|
}
|
|
98
|
-
write(
|
|
99
|
-
return
|
|
100
|
-
const o =
|
|
101
|
-
this.assertAccess(o, "write"), yield this.run((
|
|
102
|
-
createDirectories:
|
|
103
|
-
signal:
|
|
104
|
-
})), this.host.notifyFilesChanged([
|
|
140
|
+
write(r, i) {
|
|
141
|
+
return a(this, arguments, function* (t, e, s = {}) {
|
|
142
|
+
const o = u(t, !1);
|
|
143
|
+
this.assertAccess(o, "write"), yield this.run((h) => h.writeFile(o, e, {
|
|
144
|
+
createDirectories: s.createDirectories !== !1,
|
|
145
|
+
signal: s.signal
|
|
146
|
+
})), this.host.notifyFilesChanged([d(o)]);
|
|
105
147
|
});
|
|
106
148
|
}
|
|
107
|
-
append(
|
|
108
|
-
return
|
|
109
|
-
const o =
|
|
149
|
+
append(r, i) {
|
|
150
|
+
return a(this, arguments, function* (t, e, s = {}) {
|
|
151
|
+
const o = u(t, !1);
|
|
110
152
|
this.assertAccess(o, "write");
|
|
111
|
-
const
|
|
112
|
-
yield this.run((c) =>
|
|
113
|
-
let
|
|
153
|
+
const h = typeof e == "string" ? new TextEncoder().encode(e) : e;
|
|
154
|
+
yield this.run((c) => a(this, null, function* () {
|
|
155
|
+
let w = new Uint8Array();
|
|
114
156
|
try {
|
|
115
157
|
if ((yield c.stat(o)).kind !== "file")
|
|
116
|
-
throw new
|
|
117
|
-
|
|
158
|
+
throw new l(f.BadRequest, "目标是目录,不是文件。");
|
|
159
|
+
w = new Uint8Array(yield (yield c.readFile(o)).arrayBuffer());
|
|
118
160
|
} catch (y) {
|
|
119
|
-
if (y instanceof
|
|
161
|
+
if (y instanceof l || F(y).code !== f.NotFound)
|
|
120
162
|
throw y;
|
|
121
163
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
164
|
+
const v = new Uint8Array(w.byteLength + h.byteLength);
|
|
165
|
+
v.set(w), v.set(h, w.byteLength), yield c.writeFile(o, v, {
|
|
124
166
|
createDirectories: !0,
|
|
125
|
-
signal:
|
|
167
|
+
signal: s.signal
|
|
126
168
|
});
|
|
127
|
-
})), this.host.notifyFilesChanged([
|
|
169
|
+
})), this.host.notifyFilesChanged([d(o)]);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
mkdir(t) {
|
|
173
|
+
return a(this, null, function* () {
|
|
174
|
+
const e = u(t, !0);
|
|
175
|
+
e && (yield this.run((s) => a(this, null, function* () {
|
|
176
|
+
if (!s.createDirectory)
|
|
177
|
+
throw g("创建目录");
|
|
178
|
+
yield s.createDirectory(e);
|
|
179
|
+
})), this.host.notifyFilesChanged([d(e)]));
|
|
128
180
|
});
|
|
129
181
|
}
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
if (!
|
|
135
|
-
throw
|
|
136
|
-
yield
|
|
137
|
-
})), this.host.notifyFilesChanged([
|
|
182
|
+
remove(s) {
|
|
183
|
+
return a(this, arguments, function* (t, e = {}) {
|
|
184
|
+
const r = u(t, !1);
|
|
185
|
+
this.assertAccess(r, "write"), yield this.run((i) => a(this, null, function* () {
|
|
186
|
+
if (!i.remove)
|
|
187
|
+
throw g("删除");
|
|
188
|
+
yield i.remove(r, e);
|
|
189
|
+
})), this.host.notifyFilesChanged([d(r)]);
|
|
138
190
|
});
|
|
139
191
|
}
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
const
|
|
143
|
-
this.assertAccess(
|
|
144
|
-
if (!
|
|
145
|
-
throw
|
|
146
|
-
yield
|
|
147
|
-
})), this.host.notifyFilesChanged([
|
|
192
|
+
move(t, e) {
|
|
193
|
+
return a(this, null, function* () {
|
|
194
|
+
const s = u(t, !1), r = u(e, !1);
|
|
195
|
+
this.assertAccess(s, "write"), this.assertAccess(r, "write"), yield this.run((i) => a(this, null, function* () {
|
|
196
|
+
if (!i.move)
|
|
197
|
+
throw g("移动");
|
|
198
|
+
yield i.move(s, r);
|
|
199
|
+
})), this.host.notifyFilesChanged([d(s), d(r)]);
|
|
148
200
|
});
|
|
149
201
|
}
|
|
150
|
-
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
202
|
+
openPreview(t) {
|
|
203
|
+
return a(this, null, function* () {
|
|
204
|
+
return this.run((e) => a(this, null, function* () {
|
|
205
|
+
if (e.url)
|
|
206
|
+
return e.url(t);
|
|
207
|
+
const s = yield e.readFile(t), r = URL.createObjectURL(s);
|
|
208
|
+
return {
|
|
209
|
+
url: r,
|
|
210
|
+
release: () => URL.revokeObjectURL(r)
|
|
211
|
+
};
|
|
212
|
+
}));
|
|
158
213
|
});
|
|
159
214
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
215
|
+
dropPreview(t) {
|
|
216
|
+
t.release(), this.previews.delete(t.url), this.previewByPath.get(t.path) === t && this.previewByPath.delete(t.path);
|
|
217
|
+
}
|
|
218
|
+
assertAccess(t, e) {
|
|
219
|
+
const s = this.host.sensitive.match(t, e);
|
|
220
|
+
if (s)
|
|
221
|
+
throw new l(f.Forbidden, U.reasonOf(s), {
|
|
164
222
|
reason: "sensitive_file",
|
|
165
|
-
ruleId:
|
|
223
|
+
ruleId: s.id
|
|
166
224
|
});
|
|
167
225
|
}
|
|
168
|
-
run(
|
|
169
|
-
return
|
|
170
|
-
var
|
|
171
|
-
const
|
|
172
|
-
if (!
|
|
173
|
-
throw
|
|
226
|
+
run(t) {
|
|
227
|
+
return a(this, null, function* () {
|
|
228
|
+
var s;
|
|
229
|
+
const e = this.host.adapter;
|
|
230
|
+
if (!e)
|
|
231
|
+
throw E();
|
|
174
232
|
try {
|
|
175
|
-
return yield
|
|
176
|
-
} catch (
|
|
177
|
-
if (
|
|
178
|
-
throw
|
|
179
|
-
const
|
|
180
|
-
throw ((
|
|
233
|
+
return yield t(e);
|
|
234
|
+
} catch (r) {
|
|
235
|
+
if (r instanceof l)
|
|
236
|
+
throw r;
|
|
237
|
+
const i = F(r);
|
|
238
|
+
throw ((s = i.data) == null ? void 0 : s.reason) === "workspace_not_granted" && (yield this.host.handlePermissionLost()), i;
|
|
181
239
|
}
|
|
182
240
|
});
|
|
183
241
|
}
|
|
184
242
|
}
|
|
185
243
|
export {
|
|
186
|
-
|
|
187
|
-
|
|
244
|
+
C as WorkspaceFiles,
|
|
245
|
+
u as normalizeFilePath
|
|
188
246
|
};
|
package/dist/es/package.json.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.
|
|
1
|
+
const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.20", t = "glodoncv", i = "aiot bot client js sdk", n = "module", g = !1, o = [
|
|
2
2
|
"aiot",
|
|
3
3
|
"bot",
|
|
4
4
|
"bot client",
|
|
@@ -68,7 +68,7 @@ const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.19", t = "glodoncv",
|
|
|
68
68
|
access: "public",
|
|
69
69
|
registry: "https://registry.npmjs.org/"
|
|
70
70
|
}, y = {
|
|
71
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
71
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.20",
|
|
72
72
|
axios: "0.24.0",
|
|
73
73
|
buffer: "^6.0.3",
|
|
74
74
|
dayjs: "^1.11.13",
|