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

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