@glodon-aiot/bot-client-sdk 3.26.0-alpha.19 → 3.26.0-alpha.21
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 +18 -7
- 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
|
@@ -22,6 +22,10 @@ export declare class HostBridgeAdapter implements WorkspaceFileAdapter {
|
|
|
22
22
|
unavailableMessage(): string;
|
|
23
23
|
stat(path: string): Promise<WorkspaceEntry>;
|
|
24
24
|
listEntries(path: string, signal?: AbortSignal): Promise<WorkspaceEntry[]>;
|
|
25
|
+
url(path: string): Promise<{
|
|
26
|
+
url: string;
|
|
27
|
+
release: () => void;
|
|
28
|
+
}>;
|
|
25
29
|
readFile(path: string, window?: {
|
|
26
30
|
offset?: number;
|
|
27
31
|
maxBytes?: number;
|
|
@@ -19,6 +19,14 @@ export interface WorkspaceFileAdapter {
|
|
|
19
19
|
stat(path: string): Promise<WorkspaceEntry>;
|
|
20
20
|
listEntries(path: string, signal?: AbortSignal): Promise<WorkspaceEntry[]>;
|
|
21
21
|
readFile(path: string): Promise<Blob>;
|
|
22
|
+
/**
|
|
23
|
+
* 给页面标签的地址。实现方不得把文件字节读进页面。
|
|
24
|
+
* `release` 在地址不再使用时调用。
|
|
25
|
+
*/
|
|
26
|
+
url?(path: string): Promise<{
|
|
27
|
+
url: string;
|
|
28
|
+
release: () => void;
|
|
29
|
+
}>;
|
|
22
30
|
/** 全部内容写完才提交;失败或取消时原文件保持不变,新建的文件不会残留。 */
|
|
23
31
|
writeFile(path: string, source: WriteSource, options?: WriteOptions): Promise<void>;
|
|
24
32
|
/** 逐级创建目录,已存在时不报错。路径上有同名文件时抛 TypeMismatchError。 */
|
|
@@ -42,7 +42,11 @@ export declare class SandboxClient {
|
|
|
42
42
|
get ready(): boolean;
|
|
43
43
|
unavailableMessage(): string;
|
|
44
44
|
apply(notice?: SandboxNotice): void;
|
|
45
|
+
/** `ws://127.0.0.1:port` 的主机和端口,文件地址拼在它前面。 */
|
|
46
|
+
httpOrigin(): string;
|
|
45
47
|
stat(path: string): Promise<Record<string, unknown>>;
|
|
48
|
+
url(path: string): Promise<string>;
|
|
49
|
+
releaseUrl(ticket: string): Promise<void>;
|
|
46
50
|
list(path: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
47
51
|
read(path: string, offset?: number, maxBytes?: number, signal?: AbortSignal): Promise<Uint8Array<ArrayBuffer>>;
|
|
48
52
|
write(path: string, bytes: Uint8Array, createDirectories: boolean, signal?: AbortSignal): Promise<void>;
|
|
@@ -31,15 +31,22 @@ export interface WorkspaceWriteOptions extends WorkspaceReadOptions {
|
|
|
31
31
|
* 根目录在 allowRoot 时返回空字符串。
|
|
32
32
|
*/
|
|
33
33
|
export declare function normalizeFilePath(input: unknown, allowRoot: boolean): string;
|
|
34
|
-
/**
|
|
35
|
-
* 接入方使用的工作区文件操作。路径校验、敏感文件拦截和错误文案都在这里完成。
|
|
36
|
-
* 写入、建目录、删除、移动成功后会通知目录树重读。
|
|
37
|
-
*/
|
|
38
34
|
export declare class WorkspaceFiles {
|
|
39
35
|
private readonly host;
|
|
36
|
+
private readonly previews;
|
|
37
|
+
private readonly previewByPath;
|
|
40
38
|
constructor(host: WorkspaceFilesHost);
|
|
41
39
|
stat(path?: string): Promise<WorkspaceFileInfo>;
|
|
42
40
|
list(path?: string, options?: WorkspaceReadOptions): Promise<WorkspaceFileInfo[]>;
|
|
41
|
+
/**
|
|
42
|
+
* 给 `<img>`、`<video>`、`<audio>` 的地址。浏览器自己拉字节,调用方拿不到文件内容。
|
|
43
|
+
* 同一路径在大小和修改时间没变时返回同一个地址,并增加引用。用完调用 `releaseUrl`。
|
|
44
|
+
*/
|
|
45
|
+
url(path: string): Promise<string>;
|
|
46
|
+
/** 页面不再显示这个地址时调用。引用归零后,blob 地址会撤销,沙箱票据会作废。 */
|
|
47
|
+
releaseUrl(url: string): void;
|
|
48
|
+
/** 工作区断开时释放还没归还的地址。 */
|
|
49
|
+
releaseAllUrls(): void;
|
|
43
50
|
read(path: string): Promise<Blob>;
|
|
44
51
|
readText(path: string): Promise<string>;
|
|
45
52
|
write(path: string, source: WriteSource, options?: WorkspaceWriteOptions): Promise<void>;
|
|
@@ -49,6 +56,8 @@ export declare class WorkspaceFiles {
|
|
|
49
56
|
recursive?: boolean;
|
|
50
57
|
}): Promise<void>;
|
|
51
58
|
move(from: string, to: string): Promise<void>;
|
|
59
|
+
private openPreview;
|
|
60
|
+
private dropPreview;
|
|
52
61
|
private assertAccess;
|
|
53
62
|
private run;
|
|
54
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glodon-aiot/bot-client-sdk",
|
|
3
|
-
"version": "3.26.0-alpha.
|
|
3
|
+
"version": "3.26.0-alpha.21",
|
|
4
4
|
"author": "glodoncv",
|
|
5
5
|
"description": "aiot bot client js sdk",
|
|
6
6
|
"type": "module",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"registry": "https://registry.npmjs.org/"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
91
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.21",
|
|
92
92
|
"axios": "0.24.0",
|
|
93
93
|
"buffer": "^6.0.3",
|
|
94
94
|
"dayjs": "^1.11.13",
|