clickgo 3.1.3-dev12 → 3.1.5-dev14

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 (50) hide show
  1. package/README.md +1 -1
  2. package/dist/app/demo/app.js +1 -1
  3. package/dist/app/demo/config.json +9 -2
  4. package/dist/app/demo/form/control/text/text.js +1 -0
  5. package/dist/app/demo/form/control/text/text.xml +1 -1
  6. package/dist/app/demo/form/event/other/other.js +29 -0
  7. package/dist/app/demo/form/event/other/other.xml +5 -0
  8. package/dist/app/demo/form/main.js +51 -51
  9. package/dist/app/demo/form/main.xml +1 -0
  10. package/dist/app/demo/form/method/aform/aform.js +2 -13
  11. package/dist/app/demo/form/method/aform/aform.xml +0 -1
  12. package/dist/app/demo/form/method/aform/sd.js +25 -0
  13. package/dist/app/demo/form/method/aform/{test.xml → sd.xml} +3 -2
  14. package/dist/app/demo/form/method/core/core.js +12 -0
  15. package/dist/app/demo/form/method/core/core.xml +4 -0
  16. package/dist/app/demo/form/method/form/form.js +5 -6
  17. package/dist/app/demo/form/method/form/form.xml +1 -0
  18. package/dist/app/demo/form/method/form/test.xml +5 -0
  19. package/dist/app/demo/form/method/fs/fs.js +1 -4
  20. package/dist/app/demo/form/method/task/task.js +9 -1
  21. package/dist/app/demo/form/method/task/task.xml +1 -0
  22. package/dist/app/demo/form/method/tool/tool.js +3 -0
  23. package/dist/app/demo/form/method/tool/tool.xml +1 -0
  24. package/dist/app/demo/form/method/zip/zip.js +1 -4
  25. package/dist/app/task/app.js +1 -1
  26. package/dist/control/common.cgc +0 -0
  27. package/dist/control/form.cgc +0 -0
  28. package/dist/control/monaco.cgc +0 -0
  29. package/dist/control/property.cgc +0 -0
  30. package/dist/control/task.cgc +0 -0
  31. package/dist/global.css +1 -1
  32. package/dist/index.js +3 -0
  33. package/dist/index.ts +6 -0
  34. package/dist/lib/core.js +59 -10
  35. package/dist/lib/core.ts +67 -10
  36. package/dist/lib/dom.js +3 -3
  37. package/dist/lib/dom.ts +4 -4
  38. package/dist/lib/form.js +240 -215
  39. package/dist/lib/form.ts +290 -249
  40. package/dist/lib/fs.js +107 -12
  41. package/dist/lib/fs.ts +111 -20
  42. package/dist/lib/native.js +8 -1
  43. package/dist/lib/native.ts +6 -0
  44. package/dist/lib/task.js +253 -14
  45. package/dist/lib/task.ts +298 -12
  46. package/dist/lib/tool.js +39 -1
  47. package/dist/lib/tool.ts +45 -0
  48. package/dist/theme/familiar.cgt +0 -0
  49. package/package.json +3 -3
  50. package/types/index.d.ts +70 -52
package/dist/lib/fs.js CHANGED
@@ -9,10 +9,48 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.copyFile = exports.copyFolder = exports.readDir = exports.rename = exports.chmod = exports.rmdirDeep = exports.rmdir = exports.mkdir = exports.isFile = exports.isDir = exports.stats = exports.unlink = exports.symlink = exports.readLink = exports.putContent = exports.getContent = void 0;
12
+ exports.copyFile = exports.copyFolder = exports.readDir = exports.rename = exports.chmod = exports.rmdirDeep = exports.rmdir = exports.mkdir = exports.isFile = exports.isDir = exports.stats = exports.unlink = exports.symlink = exports.readLink = exports.putContent = exports.getContent = exports.unmount = exports.mount = void 0;
13
13
  const tool = require("./tool");
14
- const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/app.js', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/flow/', '/app/demo/form/control/flow/flow.css', '/app/demo/form/control/flow/flow.js', '/app/demo/form/control/flow/flow.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/vflow/', '/app/demo/form/control/vflow/vflow.css', '/app/demo/form/control/vflow/vflow.js', '/app/demo/form/control/vflow/vflow.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/aform/', '/app/demo/form/method/aform/aform.js', '/app/demo/form/method/aform/aform.xml', '/app/demo/form/method/aform/test.xml', '/app/demo/form/method/core/', '/app/demo/form/method/core/core.js', '/app/demo/form/method/core/core.xml', '/app/demo/form/method/dom/', '/app/demo/form/method/dom/dom.css', '/app/demo/form/method/dom/dom.js', '/app/demo/form/method/dom/dom.xml', '/app/demo/form/method/form/', '/app/demo/form/method/form/form.css', '/app/demo/form/method/form/form.js', '/app/demo/form/method/form/form.xml', '/app/demo/form/method/fs/', '/app/demo/form/method/fs/fs.js', '/app/demo/form/method/fs/fs.xml', '/app/demo/form/method/fs/text.js', '/app/demo/form/method/fs/text.xml', '/app/demo/form/method/native/', '/app/demo/form/method/native/native.js', '/app/demo/form/method/native/native.xml', '/app/demo/form/method/system/', '/app/demo/form/method/system/system.js', '/app/demo/form/method/system/system.xml', '/app/demo/form/method/task/', '/app/demo/form/method/task/locale1.json', '/app/demo/form/method/task/locale2.json', '/app/demo/form/method/task/task.js', '/app/demo/form/method/task/task.xml', '/app/demo/form/method/theme/', '/app/demo/form/method/theme/theme.js', '/app/demo/form/method/theme/theme.xml', '/app/demo/form/method/tool/', '/app/demo/form/method/tool/tool.js', '/app/demo/form/method/tool/tool.xml', '/app/demo/form/method/zip/', '/app/demo/form/method/zip/zip.js', '/app/demo/form/method/zip/zip.xml', '/app/demo/global.css', '/app/demo/res/', '/app/demo/res/icon.svg', '/app/demo/res/img.jpg', '/app/demo/res/r-1.svg', '/app/demo/res/r-2.svg', '/app/demo/res/sql.svg', '/app/demo/res/txt.svg', '/app/demo/res/zip.svg', '/app/task/', '/app/task/app.js', '/app/task/config.json', '/app/task/form/', '/app/task/form/bar/', '/app/task/form/bar/bar.js', '/app/task/form/bar/bar.xml', '/app/task/form/desktop/', '/app/task/form/desktop/desktop.xml', '/app/task/locale/', '/app/task/locale/en.json', '/app/task/locale/ja.json', '/app/task/locale/sc.json', '/app/task/locale/tc.json', '/clickgo.js', '/clickgo.ts', '/control/', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/property.cgc', '/control/task.cgc', '/global.css', '/icon.png', '/index.js', '/index.ts', '/lib/', '/lib/control.js', '/lib/control.ts', '/lib/core.js', '/lib/core.ts', '/lib/dom.js', '/lib/dom.ts', '/lib/form.js', '/lib/form.ts', '/lib/fs.js', '/lib/fs.ts', '/lib/native.js', '/lib/native.ts', '/lib/task.js', '/lib/task.ts', '/lib/theme.js', '/lib/theme.ts', '/lib/tool.js', '/lib/tool.ts', '/lib/zip.js', '/lib/zip.ts', '/theme/', '/theme/familiar.cgt'];
14
+ const task = require("./task");
15
+ const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/app.js', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/flow/', '/app/demo/form/control/flow/flow.css', '/app/demo/form/control/flow/flow.js', '/app/demo/form/control/flow/flow.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/vflow/', '/app/demo/form/control/vflow/vflow.css', '/app/demo/form/control/vflow/vflow.js', '/app/demo/form/control/vflow/vflow.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/other/', '/app/demo/form/event/other/other.js', '/app/demo/form/event/other/other.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/aform/', '/app/demo/form/method/aform/aform.js', '/app/demo/form/method/aform/aform.xml', '/app/demo/form/method/aform/sd.js', '/app/demo/form/method/aform/sd.xml', '/app/demo/form/method/core/', '/app/demo/form/method/core/core.js', '/app/demo/form/method/core/core.xml', '/app/demo/form/method/dom/', '/app/demo/form/method/dom/dom.css', '/app/demo/form/method/dom/dom.js', '/app/demo/form/method/dom/dom.xml', '/app/demo/form/method/form/', '/app/demo/form/method/form/form.css', '/app/demo/form/method/form/form.js', '/app/demo/form/method/form/form.xml', '/app/demo/form/method/form/test.xml', '/app/demo/form/method/fs/', '/app/demo/form/method/fs/fs.js', '/app/demo/form/method/fs/fs.xml', '/app/demo/form/method/fs/text.js', '/app/demo/form/method/fs/text.xml', '/app/demo/form/method/native/', '/app/demo/form/method/native/native.js', '/app/demo/form/method/native/native.xml', '/app/demo/form/method/system/', '/app/demo/form/method/system/system.js', '/app/demo/form/method/system/system.xml', '/app/demo/form/method/task/', '/app/demo/form/method/task/locale1.json', '/app/demo/form/method/task/locale2.json', '/app/demo/form/method/task/task.js', '/app/demo/form/method/task/task.xml', '/app/demo/form/method/theme/', '/app/demo/form/method/theme/theme.js', '/app/demo/form/method/theme/theme.xml', '/app/demo/form/method/tool/', '/app/demo/form/method/tool/tool.js', '/app/demo/form/method/tool/tool.xml', '/app/demo/form/method/zip/', '/app/demo/form/method/zip/zip.js', '/app/demo/form/method/zip/zip.xml', '/app/demo/global.css', '/app/demo/res/', '/app/demo/res/icon.svg', '/app/demo/res/img.jpg', '/app/demo/res/r-1.svg', '/app/demo/res/r-2.svg', '/app/demo/res/sql.svg', '/app/demo/res/txt.svg', '/app/demo/res/zip.svg', '/app/task/', '/app/task/app.js', '/app/task/config.json', '/app/task/form/', '/app/task/form/bar/', '/app/task/form/bar/bar.js', '/app/task/form/bar/bar.xml', '/app/task/form/desktop/', '/app/task/form/desktop/desktop.xml', '/app/task/locale/', '/app/task/locale/en.json', '/app/task/locale/ja.json', '/app/task/locale/sc.json', '/app/task/locale/tc.json', '/clickgo.js', '/clickgo.ts', '/control/', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/property.cgc', '/control/task.cgc', '/global.css', '/icon.png', '/index.js', '/index.ts', '/lib/', '/lib/control.js', '/lib/control.ts', '/lib/core.js', '/lib/core.ts', '/lib/dom.js', '/lib/dom.ts', '/lib/form.js', '/lib/form.ts', '/lib/fs.js', '/lib/fs.ts', '/lib/native.js', '/lib/native.ts', '/lib/task.js', '/lib/task.ts', '/lib/theme.js', '/lib/theme.ts', '/lib/tool.js', '/lib/tool.ts', '/lib/zip.js', '/lib/zip.ts', '/theme/', '/theme/familiar.cgt'];
16
+ const mounts = {};
17
+ function getMountName(path) {
18
+ const io = path.slice(9).indexOf('/');
19
+ return path.slice(9, io + 9);
20
+ }
21
+ function mount(name, handler) {
22
+ if (mounts[name]) {
23
+ return false;
24
+ }
25
+ if (!/^[a-zA-Z][\w]+$/.test(name)) {
26
+ return false;
27
+ }
28
+ if (handler.taskId) {
29
+ const t = task.list[handler.taskId];
30
+ if (t) {
31
+ const val = 'fs./mounted/' + name + '/w';
32
+ if (!t.runtime.permissions.includes(val)) {
33
+ t.runtime.permissions.push(val);
34
+ }
35
+ }
36
+ }
37
+ mounts[name] = handler;
38
+ return true;
39
+ }
40
+ exports.mount = mount;
41
+ function unmount(name, taskId) {
42
+ if (!mounts[name]) {
43
+ return true;
44
+ }
45
+ if (taskId && (mounts[name].taskId !== taskId)) {
46
+ return false;
47
+ }
48
+ delete mounts[name];
49
+ return true;
50
+ }
51
+ exports.unmount = unmount;
15
52
  function getContent(path, options) {
53
+ var _a, _b;
16
54
  return __awaiter(this, void 0, void 0, function* () {
17
55
  path = tool.urlResolve('/', path);
18
56
  const fpath = path.slice(8);
@@ -71,7 +109,7 @@ function getContent(path, options) {
71
109
  fr.readAsText(blob, encoding);
72
110
  });
73
111
  }
74
- catch (_a) {
112
+ catch (_c) {
75
113
  return null;
76
114
  }
77
115
  }
@@ -79,7 +117,12 @@ function getContent(path, options) {
79
117
  return null;
80
118
  }
81
119
  else if (path.startsWith('/mounted/')) {
82
- return null;
120
+ const name = getMountName(path);
121
+ const hanlder = mounts[name];
122
+ if (!hanlder) {
123
+ return null;
124
+ }
125
+ return (_b = (_a = hanlder.getContent) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), options)) !== null && _b !== void 0 ? _b : null;
83
126
  }
84
127
  else if (path.startsWith('/package/')) {
85
128
  if (!options.files) {
@@ -118,6 +161,7 @@ function getContent(path, options) {
118
161
  }
119
162
  exports.getContent = getContent;
120
163
  function putContent(path, data, options = {}) {
164
+ var _a, _b;
121
165
  return __awaiter(this, void 0, void 0, function* () {
122
166
  path = tool.urlResolve('/', path);
123
167
  const fpath = path.slice(8);
@@ -128,7 +172,12 @@ function putContent(path, data, options = {}) {
128
172
  return false;
129
173
  }
130
174
  else if (path.startsWith('/mounted/')) {
131
- return false;
175
+ const name = getMountName(path);
176
+ const hanlder = mounts[name];
177
+ if (!hanlder) {
178
+ return false;
179
+ }
180
+ return (_b = (_a = hanlder.putContent) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), data, options)) !== null && _b !== void 0 ? _b : false;
132
181
  }
133
182
  else if (path.startsWith('/package/')) {
134
183
  return false;
@@ -147,6 +196,7 @@ function putContent(path, data, options = {}) {
147
196
  }
148
197
  exports.putContent = putContent;
149
198
  function readLink(path, options) {
199
+ var _a, _b;
150
200
  return __awaiter(this, void 0, void 0, function* () {
151
201
  path = tool.urlResolve('/', path);
152
202
  const fpath = path.slice(8);
@@ -165,7 +215,12 @@ function readLink(path, options) {
165
215
  return null;
166
216
  }
167
217
  else if (path.startsWith('/mounted/')) {
168
- return null;
218
+ const name = getMountName(path);
219
+ const hanlder = mounts[name];
220
+ if (!hanlder) {
221
+ return null;
222
+ }
223
+ return (_b = (_a = hanlder.readLink) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), options)) !== null && _b !== void 0 ? _b : null;
169
224
  }
170
225
  else if (path.startsWith('/package/')) {
171
226
  return null;
@@ -186,6 +241,7 @@ function readLink(path, options) {
186
241
  }
187
242
  exports.readLink = readLink;
188
243
  function symlink(filePath, linkPath, options = {}) {
244
+ var _a, _b;
189
245
  return __awaiter(this, void 0, void 0, function* () {
190
246
  filePath = tool.urlResolve('/', filePath);
191
247
  linkPath = tool.urlResolve('/', linkPath);
@@ -196,7 +252,16 @@ function symlink(filePath, linkPath, options = {}) {
196
252
  return false;
197
253
  }
198
254
  else if (filePath.startsWith('/mounted/')) {
199
- return false;
255
+ const fname = getMountName(filePath);
256
+ const lname = getMountName(linkPath);
257
+ if (fname !== lname) {
258
+ return false;
259
+ }
260
+ const hanlder = mounts[fname];
261
+ if (!hanlder) {
262
+ return false;
263
+ }
264
+ return (_b = (_a = hanlder.symlink) === null || _a === void 0 ? void 0 : _a.call(hanlder, filePath.slice(9 + fname.length), linkPath.slice(9 + fname.length), options)) !== null && _b !== void 0 ? _b : false;
200
265
  }
201
266
  else if (filePath.startsWith('/package/')) {
202
267
  return false;
@@ -218,6 +283,7 @@ function symlink(filePath, linkPath, options = {}) {
218
283
  }
219
284
  exports.symlink = symlink;
220
285
  function unlink(path, options = {}) {
286
+ var _a, _b;
221
287
  return __awaiter(this, void 0, void 0, function* () {
222
288
  path = tool.urlResolve('/', path);
223
289
  const fpath = path.slice(8);
@@ -228,7 +294,12 @@ function unlink(path, options = {}) {
228
294
  return false;
229
295
  }
230
296
  else if (path.startsWith('/mounted/')) {
231
- return false;
297
+ const name = getMountName(path);
298
+ const hanlder = mounts[name];
299
+ if (!hanlder) {
300
+ return false;
301
+ }
302
+ return (_b = (_a = hanlder.unlink) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), options)) !== null && _b !== void 0 ? _b : false;
232
303
  }
233
304
  else if (path.startsWith('/package/')) {
234
305
  return false;
@@ -322,6 +393,7 @@ function getClickGoStats(path) {
322
393
  });
323
394
  }
324
395
  function stats(path, options = {}) {
396
+ var _a, _b;
325
397
  return __awaiter(this, void 0, void 0, function* () {
326
398
  path = tool.urlResolve('/', path);
327
399
  let fpath = path.slice(8);
@@ -338,7 +410,12 @@ function stats(path, options = {}) {
338
410
  return null;
339
411
  }
340
412
  else if (path.startsWith('/mounted/')) {
341
- return null;
413
+ const name = getMountName(path);
414
+ const hanlder = mounts[name];
415
+ if (!hanlder) {
416
+ return null;
417
+ }
418
+ return (_b = (_a = hanlder.stats) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), options)) !== null && _b !== void 0 ? _b : false;
342
419
  }
343
420
  else if (path.startsWith('/package/')) {
344
421
  if (!options.files) {
@@ -444,6 +521,7 @@ function isFile(path, options = {}) {
444
521
  }
445
522
  exports.isFile = isFile;
446
523
  function mkdir(path, mode = 0o755, options = {}) {
524
+ var _a, _b;
447
525
  return __awaiter(this, void 0, void 0, function* () {
448
526
  path = tool.urlResolve('/', path);
449
527
  if (yield isDir(path, options)) {
@@ -457,7 +535,12 @@ function mkdir(path, mode = 0o755, options = {}) {
457
535
  return false;
458
536
  }
459
537
  else if (path.startsWith('/mounted/')) {
460
- return false;
538
+ const name = getMountName(path);
539
+ const hanlder = mounts[name];
540
+ if (!hanlder) {
541
+ return false;
542
+ }
543
+ return (_b = (_a = hanlder.mkdir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), mode, options)) !== null && _b !== void 0 ? _b : false;
461
544
  }
462
545
  else if (path.startsWith('/package/')) {
463
546
  return false;
@@ -476,6 +559,7 @@ function mkdir(path, mode = 0o755, options = {}) {
476
559
  }
477
560
  exports.mkdir = mkdir;
478
561
  function rmdir(path, options = {}) {
562
+ var _a, _b;
479
563
  return __awaiter(this, void 0, void 0, function* () {
480
564
  path = tool.urlResolve('/', path);
481
565
  const fpath = path.slice(8);
@@ -486,7 +570,12 @@ function rmdir(path, options = {}) {
486
570
  return false;
487
571
  }
488
572
  else if (path.startsWith('/mounted/')) {
489
- return false;
573
+ const name = getMountName(path);
574
+ const hanlder = mounts[name];
575
+ if (!hanlder) {
576
+ return false;
577
+ }
578
+ return (_b = (_a = hanlder.rmdir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), options)) !== null && _b !== void 0 ? _b : false;
490
579
  }
491
580
  else if (path.startsWith('/package/')) {
492
581
  return false;
@@ -534,6 +623,7 @@ function rmdirDeep(path, options = {}) {
534
623
  }
535
624
  exports.rmdirDeep = rmdirDeep;
536
625
  function chmod(path, mod, options = {}) {
626
+ var _a, _b;
537
627
  return __awaiter(this, void 0, void 0, function* () {
538
628
  path = tool.urlResolve('/', path);
539
629
  const fpath = path.slice(8);
@@ -544,7 +634,12 @@ function chmod(path, mod, options = {}) {
544
634
  return false;
545
635
  }
546
636
  else if (path.startsWith('/mounted/')) {
547
- return false;
637
+ const name = getMountName(path);
638
+ const hanlder = mounts[name];
639
+ if (!hanlder) {
640
+ return false;
641
+ }
642
+ return (_b = (_a = hanlder.chmod) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), mod, options)) !== null && _b !== void 0 ? _b : false;
548
643
  }
549
644
  else if (path.startsWith('/package/')) {
550
645
  return false;
package/dist/lib/fs.ts CHANGED
@@ -7,8 +7,59 @@
7
7
  */
8
8
  import * as types from '../../types';
9
9
  import * as tool from './tool';
10
+ import * as task from './task';
10
11
 
11
- const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/app.js', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/flow/', '/app/demo/form/control/flow/flow.css', '/app/demo/form/control/flow/flow.js', '/app/demo/form/control/flow/flow.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/vflow/', '/app/demo/form/control/vflow/vflow.css', '/app/demo/form/control/vflow/vflow.js', '/app/demo/form/control/vflow/vflow.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/aform/', '/app/demo/form/method/aform/aform.js', '/app/demo/form/method/aform/aform.xml', '/app/demo/form/method/aform/test.xml', '/app/demo/form/method/core/', '/app/demo/form/method/core/core.js', '/app/demo/form/method/core/core.xml', '/app/demo/form/method/dom/', '/app/demo/form/method/dom/dom.css', '/app/demo/form/method/dom/dom.js', '/app/demo/form/method/dom/dom.xml', '/app/demo/form/method/form/', '/app/demo/form/method/form/form.css', '/app/demo/form/method/form/form.js', '/app/demo/form/method/form/form.xml', '/app/demo/form/method/fs/', '/app/demo/form/method/fs/fs.js', '/app/demo/form/method/fs/fs.xml', '/app/demo/form/method/fs/text.js', '/app/demo/form/method/fs/text.xml', '/app/demo/form/method/native/', '/app/demo/form/method/native/native.js', '/app/demo/form/method/native/native.xml', '/app/demo/form/method/system/', '/app/demo/form/method/system/system.js', '/app/demo/form/method/system/system.xml', '/app/demo/form/method/task/', '/app/demo/form/method/task/locale1.json', '/app/demo/form/method/task/locale2.json', '/app/demo/form/method/task/task.js', '/app/demo/form/method/task/task.xml', '/app/demo/form/method/theme/', '/app/demo/form/method/theme/theme.js', '/app/demo/form/method/theme/theme.xml', '/app/demo/form/method/tool/', '/app/demo/form/method/tool/tool.js', '/app/demo/form/method/tool/tool.xml', '/app/demo/form/method/zip/', '/app/demo/form/method/zip/zip.js', '/app/demo/form/method/zip/zip.xml', '/app/demo/global.css', '/app/demo/res/', '/app/demo/res/icon.svg', '/app/demo/res/img.jpg', '/app/demo/res/r-1.svg', '/app/demo/res/r-2.svg', '/app/demo/res/sql.svg', '/app/demo/res/txt.svg', '/app/demo/res/zip.svg', '/app/task/', '/app/task/app.js', '/app/task/config.json', '/app/task/form/', '/app/task/form/bar/', '/app/task/form/bar/bar.js', '/app/task/form/bar/bar.xml', '/app/task/form/desktop/', '/app/task/form/desktop/desktop.xml', '/app/task/locale/', '/app/task/locale/en.json', '/app/task/locale/ja.json', '/app/task/locale/sc.json', '/app/task/locale/tc.json', '/clickgo.js', '/clickgo.ts', '/control/', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/property.cgc', '/control/task.cgc', '/global.css', '/icon.png', '/index.js', '/index.ts', '/lib/', '/lib/control.js', '/lib/control.ts', '/lib/core.js', '/lib/core.ts', '/lib/dom.js', '/lib/dom.ts', '/lib/form.js', '/lib/form.ts', '/lib/fs.js', '/lib/fs.ts', '/lib/native.js', '/lib/native.ts', '/lib/task.js', '/lib/task.ts', '/lib/theme.js', '/lib/theme.ts', '/lib/tool.js', '/lib/tool.ts', '/lib/zip.js', '/lib/zip.ts', '/theme/', '/theme/familiar.cgt'];
12
+ const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/app.js', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/flow/', '/app/demo/form/control/flow/flow.css', '/app/demo/form/control/flow/flow.js', '/app/demo/form/control/flow/flow.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/vflow/', '/app/demo/form/control/vflow/vflow.css', '/app/demo/form/control/vflow/vflow.js', '/app/demo/form/control/vflow/vflow.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/other/', '/app/demo/form/event/other/other.js', '/app/demo/form/event/other/other.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/aform/', '/app/demo/form/method/aform/aform.js', '/app/demo/form/method/aform/aform.xml', '/app/demo/form/method/aform/sd.js', '/app/demo/form/method/aform/sd.xml', '/app/demo/form/method/core/', '/app/demo/form/method/core/core.js', '/app/demo/form/method/core/core.xml', '/app/demo/form/method/dom/', '/app/demo/form/method/dom/dom.css', '/app/demo/form/method/dom/dom.js', '/app/demo/form/method/dom/dom.xml', '/app/demo/form/method/form/', '/app/demo/form/method/form/form.css', '/app/demo/form/method/form/form.js', '/app/demo/form/method/form/form.xml', '/app/demo/form/method/form/test.xml', '/app/demo/form/method/fs/', '/app/demo/form/method/fs/fs.js', '/app/demo/form/method/fs/fs.xml', '/app/demo/form/method/fs/text.js', '/app/demo/form/method/fs/text.xml', '/app/demo/form/method/native/', '/app/demo/form/method/native/native.js', '/app/demo/form/method/native/native.xml', '/app/demo/form/method/system/', '/app/demo/form/method/system/system.js', '/app/demo/form/method/system/system.xml', '/app/demo/form/method/task/', '/app/demo/form/method/task/locale1.json', '/app/demo/form/method/task/locale2.json', '/app/demo/form/method/task/task.js', '/app/demo/form/method/task/task.xml', '/app/demo/form/method/theme/', '/app/demo/form/method/theme/theme.js', '/app/demo/form/method/theme/theme.xml', '/app/demo/form/method/tool/', '/app/demo/form/method/tool/tool.js', '/app/demo/form/method/tool/tool.xml', '/app/demo/form/method/zip/', '/app/demo/form/method/zip/zip.js', '/app/demo/form/method/zip/zip.xml', '/app/demo/global.css', '/app/demo/res/', '/app/demo/res/icon.svg', '/app/demo/res/img.jpg', '/app/demo/res/r-1.svg', '/app/demo/res/r-2.svg', '/app/demo/res/sql.svg', '/app/demo/res/txt.svg', '/app/demo/res/zip.svg', '/app/task/', '/app/task/app.js', '/app/task/config.json', '/app/task/form/', '/app/task/form/bar/', '/app/task/form/bar/bar.js', '/app/task/form/bar/bar.xml', '/app/task/form/desktop/', '/app/task/form/desktop/desktop.xml', '/app/task/locale/', '/app/task/locale/en.json', '/app/task/locale/ja.json', '/app/task/locale/sc.json', '/app/task/locale/tc.json', '/clickgo.js', '/clickgo.ts', '/control/', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/property.cgc', '/control/task.cgc', '/global.css', '/icon.png', '/index.js', '/index.ts', '/lib/', '/lib/control.js', '/lib/control.ts', '/lib/core.js', '/lib/core.ts', '/lib/dom.js', '/lib/dom.ts', '/lib/form.js', '/lib/form.ts', '/lib/fs.js', '/lib/fs.ts', '/lib/native.js', '/lib/native.ts', '/lib/task.js', '/lib/task.ts', '/lib/theme.js', '/lib/theme.ts', '/lib/tool.js', '/lib/tool.ts', '/lib/zip.js', '/lib/zip.ts', '/theme/', '/theme/familiar.cgt'];
13
+
14
+ /** --- 已经挂载的列表 --- */
15
+ const mounts: Record<string, types.IMountHandler> = {};
16
+
17
+ /** --- 根据 mounted 的 path 获取挂载点 name --- */
18
+ function getMountName(path: string): string {
19
+ const io = path.slice(9).indexOf('/');
20
+ return path.slice(9, io + 9);
21
+ }
22
+
23
+ /**
24
+ * --- 挂载到 mounted 目录下 ---
25
+ * @param name 目录名
26
+ * @param handler 回调相关,taskId 在 App 模式下无效
27
+ */
28
+ export function mount(name: string, handler: types.IMountHandler): boolean {
29
+ if (mounts[name]) {
30
+ return false;
31
+ }
32
+ if (!/^[a-zA-Z][\w]+$/.test(name)) {
33
+ return false;
34
+ }
35
+ if (handler.taskId) {
36
+ const t = task.list[handler.taskId];
37
+ if (t) {
38
+ const val = 'fs./mounted/' + name + '/w';
39
+ if (!t.runtime.permissions.includes(val)) {
40
+ t.runtime.permissions.push(val);
41
+ }
42
+ }
43
+ }
44
+ mounts[name] = handler;
45
+ return true;
46
+ }
47
+
48
+ /**
49
+ * --- 卸载 mounted ---
50
+ * @param name 目录名
51
+ * @param taskId 校验 taskId,App 模式下无效
52
+ */
53
+ export function unmount(name: string, taskId?: number): boolean {
54
+ if (!mounts[name]) {
55
+ return true;
56
+ }
57
+ if (taskId && (mounts[name].taskId !== taskId)) {
58
+ return false;
59
+ }
60
+ delete mounts[name];
61
+ return true;
62
+ }
12
63
 
13
64
  export async function getContent(path: string, options?: {
14
65
  'start'?: number;
@@ -104,8 +155,12 @@ export async function getContent(path: string, options?: BufferEncoding | {
104
155
  return null;
105
156
  }
106
157
  else if (path.startsWith('/mounted/')) {
107
- // --- TODO ---
108
- return null;
158
+ const name = getMountName(path);
159
+ const hanlder = mounts[name];
160
+ if (!hanlder) {
161
+ return null;
162
+ }
163
+ return hanlder.getContent?.(path.slice(9 + name.length), options) ?? null;
109
164
  }
110
165
  else if (path.startsWith('/package/')) {
111
166
  if (!options.files) {
@@ -150,7 +205,7 @@ export async function getContent(path: string, options?: BufferEncoding | {
150
205
  * @param data 要写入的内容
151
206
  * @param options 选项
152
207
  */
153
- export async function putContent(path: string, data: string | Buffer, options: {
208
+ export async function putContent(path: string, data: string | Blob, options: {
154
209
  'encoding'?: BufferEncoding | null;
155
210
  'mode'?: string | number;
156
211
  'flag'?: string | number;
@@ -166,8 +221,12 @@ export async function putContent(path: string, data: string | Buffer, options: {
166
221
  return false;
167
222
  }
168
223
  else if (path.startsWith('/mounted/')) {
169
- // --- TODO ---
170
- return false;
224
+ const name = getMountName(path);
225
+ const hanlder = mounts[name];
226
+ if (!hanlder) {
227
+ return false;
228
+ }
229
+ return hanlder.putContent?.(path.slice(9 + name.length), data, options) ?? false;
171
230
  }
172
231
  else if (path.startsWith('/package/')) {
173
232
  return false;
@@ -212,8 +271,12 @@ export async function readLink(path: string, options?: BufferEncoding | {
212
271
  return null;
213
272
  }
214
273
  else if (path.startsWith('/mounted/')) {
215
- // --- TODO ---
216
- return null;
274
+ const name = getMountName(path);
275
+ const hanlder = mounts[name];
276
+ if (!hanlder) {
277
+ return null;
278
+ }
279
+ return hanlder.readLink?.(path.slice(9 + name.length), options) ?? null;
217
280
  }
218
281
  else if (path.startsWith('/package/')) {
219
282
  return null;
@@ -252,8 +315,16 @@ export async function symlink(filePath: string, linkPath: string, options: {
252
315
  return false;
253
316
  }
254
317
  else if (filePath.startsWith('/mounted/')) {
255
- // --- TODO ---
256
- return false;
318
+ const fname = getMountName(filePath);
319
+ const lname = getMountName(linkPath);
320
+ if (fname !== lname) {
321
+ return false;
322
+ }
323
+ const hanlder = mounts[fname];
324
+ if (!hanlder) {
325
+ return false;
326
+ }
327
+ return hanlder.symlink?.(filePath.slice(9 + fname.length), linkPath.slice(9 + fname.length), options) ?? false;
257
328
  }
258
329
  else if (filePath.startsWith('/package/')) {
259
330
  return false;
@@ -290,8 +361,12 @@ export async function unlink(path: string, options: {
290
361
  return false;
291
362
  }
292
363
  else if (path.startsWith('/mounted/')) {
293
- // --- TODO ---
294
- return false;
364
+ const name = getMountName(path);
365
+ const hanlder = mounts[name];
366
+ if (!hanlder) {
367
+ return false;
368
+ }
369
+ return hanlder.unlink?.(path.slice(9 + name.length), options) ?? false;
295
370
  }
296
371
  else if (path.startsWith('/package/')) {
297
372
  return false;
@@ -409,8 +484,12 @@ export async function stats(path: string, options: {
409
484
  return null;
410
485
  }
411
486
  else if (path.startsWith('/mounted/')) {
412
- // --- TODO ---
413
- return null;
487
+ const name = getMountName(path);
488
+ const hanlder = mounts[name];
489
+ if (!hanlder) {
490
+ return null;
491
+ }
492
+ return hanlder.stats?.(path.slice(9 + name.length), options) ?? false;
414
493
  }
415
494
  else if (path.startsWith('/package/')) {
416
495
  if (!options.files) {
@@ -549,8 +628,12 @@ export async function mkdir(path: string, mode: number = 0o755, options: {
549
628
  return false;
550
629
  }
551
630
  else if (path.startsWith('/mounted/')) {
552
- // --- TODO ---
553
- return false;
631
+ const name = getMountName(path);
632
+ const hanlder = mounts[name];
633
+ if (!hanlder) {
634
+ return false;
635
+ }
636
+ return hanlder.mkdir?.(path.slice(9 + name.length), mode, options) ?? false;
554
637
  }
555
638
  else if (path.startsWith('/package/')) {
556
639
  return false;
@@ -584,8 +667,12 @@ export async function rmdir(path: string, options: {
584
667
  return false;
585
668
  }
586
669
  else if (path.startsWith('/mounted/')) {
587
- // --- TODO ---
588
- return false;
670
+ const name = getMountName(path);
671
+ const hanlder = mounts[name];
672
+ if (!hanlder) {
673
+ return false;
674
+ }
675
+ return hanlder.rmdir?.(path.slice(9 + name.length), options) ?? false;
589
676
  }
590
677
  else if (path.startsWith('/package/')) {
591
678
  return false;
@@ -654,8 +741,12 @@ export async function chmod(path: string, mod: string | number, options: {
654
741
  return false;
655
742
  }
656
743
  else if (path.startsWith('/mounted/')) {
657
- // --- TODO ---
658
- return false;
744
+ const name = getMountName(path);
745
+ const hanlder = mounts[name];
746
+ if (!hanlder) {
747
+ return false;
748
+ }
749
+ return hanlder.chmod?.(path.slice(9 + name.length), mod, options) ?? false;
659
750
  }
660
751
  else if (path.startsWith('/package/')) {
661
752
  return false;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.isMax = exports.ping = exports.size = exports.restore = exports.min = exports.max = exports.invoke = exports.getListenerList = exports.clear = exports.off = exports.once = exports.on = exports.getToken = void 0;
12
+ exports.isMax = exports.ping = exports.maximizable = exports.size = exports.restore = exports.min = exports.max = exports.invoke = exports.getListenerList = exports.clear = exports.off = exports.once = exports.on = exports.getToken = void 0;
13
13
  const clickgo = require("../clickgo");
14
14
  const token = (Math.random() * 100000000000000 * (100 + Math.round(Math.random() * (999 - 100)))).toString(32);
15
15
  function getToken() {
@@ -121,6 +121,7 @@ function invoke(name, ...param) {
121
121
  });
122
122
  }
123
123
  exports.invoke = invoke;
124
+ invoke('cg-init', token);
124
125
  function max() {
125
126
  return __awaiter(this, void 0, void 0, function* () {
126
127
  yield invoke('cg-set-state', token, 'max');
@@ -145,6 +146,12 @@ function size(width, height) {
145
146
  });
146
147
  }
147
148
  exports.size = size;
149
+ function maximizable(val) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ yield invoke('cg-maximizable', token, val);
152
+ });
153
+ }
154
+ exports.maximizable = maximizable;
148
155
  function ping(val) {
149
156
  return __awaiter(this, void 0, void 0, function* () {
150
157
  return invoke('cg-ping', val);
@@ -189,6 +189,8 @@ export async function invoke(name: string, ...param: any[]): Promise<any> {
189
189
  return (window as any).clickgoNative.invoke(name, ...param) as Promise<any>;
190
190
  }
191
191
 
192
+ invoke('cg-init', token) as any;
193
+
192
194
  // --- 常见向 native 发送的操作 ---
193
195
 
194
196
  export async function max(): Promise<void> {
@@ -207,6 +209,10 @@ export async function size(width: number, height: number): Promise<void> {
207
209
  await invoke('cg-set-size', token, width, height);
208
210
  }
209
211
 
212
+ export async function maximizable(val: boolean): Promise<void> {
213
+ await invoke('cg-maximizable', token, val);
214
+ }
215
+
210
216
  // --- 以下无需 token ---
211
217
 
212
218
  export async function ping(val: string): Promise<string> {