@glodon-aiot/bot-client-sdk 3.26.0-alpha.15 → 3.26.0-alpha.16

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.
@@ -0,0 +1,23 @@
1
+ import { WorkspaceEntry, WorkspaceFileAdapter, WriteOptions, WriteSource } from './WorkspaceFileAdapter';
2
+ export interface SnapshotFileInput {
3
+ name: string;
4
+ webkitRelativePath?: string;
5
+ lastModified?: number;
6
+ blob: Blob;
7
+ }
8
+ /**
9
+ * 用一次目录选择拿到的文件列表画出目录树。
10
+ * 浏览器取消或无法返回目录句柄时,仍然能按相对路径列出文件夹结构。
11
+ */
12
+ export declare class FileSnapshotAdapter implements WorkspaceFileAdapter {
13
+ readonly displayName: string;
14
+ private readonly root;
15
+ constructor(files: Iterable<SnapshotFileInput>, displayName: string);
16
+ private writeNode;
17
+ private resolveDirectory;
18
+ private resolveNode;
19
+ stat(path: string): Promise<WorkspaceEntry>;
20
+ listEntries(path: string, signal?: AbortSignal): Promise<WorkspaceEntry[]>;
21
+ readFile(path: string): Promise<Blob>;
22
+ writeFile(path: string, source: WriteSource, options?: WriteOptions): Promise<void>;
23
+ }
@@ -55,6 +55,8 @@ export declare class LocalWorkspace {
55
55
  private readonly pendingChangePaths;
56
56
  private changeTimer;
57
57
  private refreshAllVisible;
58
+ /** 选择、关闭会推进它。进行中的 restore 若发现已经变了,就不再覆盖当前目录。 */
59
+ private epoch;
58
60
  constructor(options: LocalWorkspaceOptions);
59
61
  get status(): LocalWorkspaceStatus;
60
62
  /** 当前(或待恢复的)文件夹名,不含绝对路径。 */
@@ -76,10 +78,17 @@ export declare class LocalWorkspace {
76
78
  /** 读取上次的目录句柄并检查权限,不弹窗。 */
77
79
  restore(): Promise<void>;
78
80
  private doRestore;
81
+ /** queryPermission 仍可能是 prompt,但选择框留下的句柄其实列得出目录。 */
82
+ private canList;
79
83
  /** 对已保存的目录重新申请权限。必须在用户点击事件中调用。 */
80
84
  requestPermission(): Promise<boolean>;
81
85
  /** 断开工作区并删除持久化句柄。状态立即变为未授权,存储删除在其后完成。 */
82
86
  clear(): Promise<void>;
87
+ /**
88
+ * 用目录选择框返回的文件列表挂上工作区。路径来自 webkitRelativePath,
89
+ * 不依赖目录句柄,选完就能列出文件夹层级。
90
+ */
91
+ attachFileSnapshot(files: Iterable<File>, displayName?: string): void;
83
92
  /** 直接挂载一个 Adapter(测试或自定义后端),视为已授权。 */
84
93
  attachAdapter(adapter: WorkspaceFileAdapter, displayName?: string): void;
85
94
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glodon-aiot/bot-client-sdk",
3
- "version": "3.26.0-alpha.15",
3
+ "version": "3.26.0-alpha.16",
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.15",
91
+ "@glodon-aiot/apis": "^3.26.0-alpha.16",
92
92
  "axios": "0.24.0",
93
93
  "buffer": "^6.0.3",
94
94
  "dayjs": "^1.11.13",