clickgo 3.1.5-dev14 → 3.1.6-dev15

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 (92) hide show
  1. package/README.md +7 -7
  2. package/dist/app/demo/app.js +28 -2
  3. package/dist/app/demo/config.json +17 -1
  4. package/dist/app/demo/form/control/box/box.js +66 -0
  5. package/dist/app/demo/form/control/box/box.xml +18 -0
  6. package/dist/app/demo/form/control/button/button.js +24 -1
  7. package/dist/app/demo/form/control/check/check.js +24 -1
  8. package/dist/app/demo/form/control/dialog/dialog.js +24 -1
  9. package/dist/app/demo/form/control/file/file.js +24 -1
  10. package/dist/app/demo/form/control/flow/flow.js +24 -1
  11. package/dist/app/demo/form/control/form/form.js +24 -1
  12. package/dist/app/demo/form/control/layout/layout.js +57 -0
  13. package/dist/app/demo/form/control/layout/layout.xml +16 -0
  14. package/dist/app/demo/form/control/list/list.js +24 -1
  15. package/dist/app/demo/form/control/list/list.xml +8 -2
  16. package/dist/app/demo/form/control/marquee/marquee.js +24 -2
  17. package/dist/app/demo/form/control/marquee/marquee.xml +2 -5
  18. package/dist/app/demo/form/control/menu/menu.js +24 -1
  19. package/dist/app/demo/form/control/monaco/monaco.js +24 -1
  20. package/dist/app/demo/form/control/nav/nav.js +52 -0
  21. package/dist/app/demo/form/control/nav/nav.xml +43 -0
  22. package/dist/app/demo/form/control/panel/panel.js +67 -0
  23. package/dist/app/demo/form/control/panel/panel.xml +11 -0
  24. package/dist/app/demo/form/control/panel/test1.js +58 -0
  25. package/dist/app/demo/form/control/panel/test1.xml +16 -0
  26. package/dist/app/demo/form/control/panel/test2.xml +3 -0
  27. package/dist/app/demo/form/control/property/property.js +24 -1
  28. package/dist/app/demo/form/control/radio/radio.js +24 -1
  29. package/dist/app/demo/form/control/scroll/scroll.js +25 -1
  30. package/dist/app/demo/form/control/scroll/scroll.xml +5 -2
  31. package/dist/app/demo/form/control/select/select.js +24 -1
  32. package/dist/app/demo/form/control/tab/tab.js +24 -1
  33. package/dist/app/demo/form/control/table/table.js +164 -0
  34. package/dist/app/demo/form/control/table/table.xml +35 -0
  35. package/dist/app/demo/form/control/text/text.js +24 -1
  36. package/dist/app/demo/form/control/vflow/vflow.js +24 -1
  37. package/dist/app/demo/form/event/form/form.js +24 -1
  38. package/dist/app/demo/form/event/other/other.js +24 -1
  39. package/dist/app/demo/form/event/screen/screen.js +24 -1
  40. package/dist/app/demo/form/event/task/task.js +24 -1
  41. package/dist/app/demo/form/main.js +84 -33
  42. package/dist/app/demo/form/main.xml +5 -0
  43. package/dist/app/demo/form/method/aform/aform.js +28 -2
  44. package/dist/app/demo/form/method/aform/sd.js +24 -1
  45. package/dist/app/demo/form/method/core/core.js +24 -1
  46. package/dist/app/demo/form/method/dom/dom.js +48 -2
  47. package/dist/app/demo/form/method/dom/dom.xml +11 -0
  48. package/dist/app/demo/form/method/form/form.js +35 -1
  49. package/dist/app/demo/form/method/form/form.xml +2 -0
  50. package/dist/app/demo/form/method/fs/fs.js +138 -4
  51. package/dist/app/demo/form/method/fs/fs.xml +11 -1
  52. package/dist/app/demo/form/method/fs/text.js +24 -1
  53. package/dist/app/demo/form/method/native/native.js +24 -1
  54. package/dist/app/demo/form/method/system/system.js +24 -1
  55. package/dist/app/demo/form/method/task/task.js +31 -4
  56. package/dist/app/demo/form/method/task/task.xml +6 -1
  57. package/dist/app/demo/form/method/theme/theme.js +24 -1
  58. package/dist/app/demo/form/method/tool/tool.js +35 -1
  59. package/dist/app/demo/form/method/zip/zip.js +29 -3
  60. package/dist/app/task/app.js +28 -2
  61. package/dist/app/task/form/bar/bar.js +24 -1
  62. package/dist/clickgo.js +33 -10
  63. package/dist/control/box.cgc +0 -0
  64. package/dist/control/common.cgc +0 -0
  65. package/dist/control/form.cgc +0 -0
  66. package/dist/control/monaco.cgc +0 -0
  67. package/dist/control/nav.cgc +0 -0
  68. package/dist/control/property.cgc +0 -0
  69. package/dist/control/table.cgc +0 -0
  70. package/dist/control/task.cgc +0 -0
  71. package/dist/global.css +1 -1
  72. package/dist/lib/control.js +53 -12
  73. package/dist/lib/control.ts +25 -5
  74. package/dist/lib/core.js +44 -45
  75. package/dist/lib/core.ts +17 -41
  76. package/dist/lib/dom.js +322 -108
  77. package/dist/lib/dom.ts +394 -127
  78. package/dist/lib/form.js +441 -58
  79. package/dist/lib/form.ts +525 -74
  80. package/dist/lib/fs.js +485 -224
  81. package/dist/lib/fs.ts +493 -287
  82. package/dist/lib/native.js +24 -1
  83. package/dist/lib/task.js +143 -136
  84. package/dist/lib/task.ts +124 -127
  85. package/dist/lib/theme.js +27 -4
  86. package/dist/lib/tool.js +19 -2
  87. package/dist/lib/tool.ts +23 -1
  88. package/dist/lib/zip.js +29 -3
  89. package/dist/lib/zip.ts +1 -1
  90. package/dist/theme/familiar.cgt +0 -0
  91. package/package.json +4 -6
  92. package/types/index.d.ts +42 -34
package/dist/lib/fs.js CHANGED
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -10,23 +33,40 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
33
  };
11
34
  Object.defineProperty(exports, "__esModule", { value: true });
12
35
  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
- const tool = require("./tool");
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'];
36
+ const tool = __importStar(require("./tool"));
37
+ const task = __importStar(require("./task"));
38
+ const form = __importStar(require("./form"));
39
+ const core = __importStar(require("./core"));
40
+ const native = __importStar(require("./native"));
41
+ 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/box/', '/app/demo/form/control/box/box.js', '/app/demo/form/control/box/box.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/layout/', '/app/demo/form/control/layout/layout.js', '/app/demo/form/control/layout/layout.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/nav/', '/app/demo/form/control/nav/nav.js', '/app/demo/form/control/nav/nav.xml', '/app/demo/form/control/panel/', '/app/demo/form/control/panel/panel.js', '/app/demo/form/control/panel/panel.xml', '/app/demo/form/control/panel/test1.js', '/app/demo/form/control/panel/test1.xml', '/app/demo/form/control/panel/test2.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/table/', '/app/demo/form/control/table/table.js', '/app/demo/form/control/table/table.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/box.cgc', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/nav.cgc', '/control/property.cgc', '/control/table.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'];
42
+ const localeData = {
43
+ 'en': {
44
+ 'apply-unmount': 'Are you sure to unmount the "?" mount point?',
45
+ },
46
+ 'sc': {
47
+ 'apply-unmount': '确定卸载“?”挂载点吗?'
48
+ },
49
+ 'tc': {
50
+ 'apply-unmount': '確定卸載「?」掛載點嗎?'
51
+ },
52
+ 'ja': {
53
+ 'apply-unmount': '「?」マウント ポイントをアンマウントしますか?'
54
+ }
55
+ };
16
56
  const mounts = {};
17
57
  function getMountName(path) {
18
58
  const io = path.slice(9).indexOf('/');
19
- return path.slice(9, io + 9);
59
+ return io === -1 ? path.slice(9) : path.slice(9, io + 9);
20
60
  }
21
- function mount(name, handler) {
61
+ function mount(name, handler, taskId) {
22
62
  if (mounts[name]) {
23
63
  return false;
24
64
  }
25
65
  if (!/^[a-zA-Z][\w]+$/.test(name)) {
26
66
  return false;
27
67
  }
28
- if (handler.taskId) {
29
- const t = task.list[handler.taskId];
68
+ if (taskId) {
69
+ const t = task.list[taskId];
30
70
  if (t) {
31
71
  const val = 'fs./mounted/' + name + '/w';
32
72
  if (!t.runtime.permissions.includes(val)) {
@@ -34,22 +74,27 @@ function mount(name, handler) {
34
74
  }
35
75
  }
36
76
  }
77
+ handler.date = new Date();
37
78
  mounts[name] = handler;
38
79
  return true;
39
80
  }
40
81
  exports.mount = mount;
41
- function unmount(name, taskId) {
42
- if (!mounts[name]) {
82
+ function unmount(name) {
83
+ var _a, _b;
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ if (!mounts[name]) {
86
+ return true;
87
+ }
88
+ const loc = (_b = (_a = localeData[core.config.locale]) === null || _a === void 0 ? void 0 : _a['apply-unmount']) !== null && _b !== void 0 ? _b : localeData['en']['apply-unmount'];
89
+ if (!(yield form.superConfirm(loc.replace('?', '/mount/' + name + '/')))) {
90
+ return false;
91
+ }
92
+ delete mounts[name];
43
93
  return true;
44
- }
45
- if (taskId && (mounts[name].taskId !== taskId)) {
46
- return false;
47
- }
48
- delete mounts[name];
49
- return true;
94
+ });
50
95
  }
51
96
  exports.unmount = unmount;
52
- function getContent(path, options) {
97
+ function getContent(path, options, taskId) {
53
98
  var _a, _b;
54
99
  return __awaiter(this, void 0, void 0, function* () {
55
100
  path = tool.urlResolve('/', path);
@@ -113,22 +158,41 @@ function getContent(path, options) {
113
158
  return null;
114
159
  }
115
160
  }
116
- else if (path.startsWith('/storage/')) {
117
- return null;
118
- }
119
- else if (path.startsWith('/mounted/')) {
120
- const name = getMountName(path);
121
- const hanlder = mounts[name];
122
- if (!hanlder) {
161
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
162
+ const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
163
+ if (!r[0]) {
164
+ return null;
165
+ }
166
+ if (path.startsWith('/mounted/')) {
167
+ const name = getMountName(path);
168
+ const hanlder = mounts[name];
169
+ if (!hanlder) {
170
+ return null;
171
+ }
172
+ 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;
173
+ }
174
+ if (options.progress) {
175
+ delete options.progress;
176
+ }
177
+ const rtn = yield native.invoke('cg-fs-getContent', native.getToken(), fpath, options);
178
+ if (!rtn) {
123
179
  return null;
124
180
  }
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;
181
+ if (typeof rtn === 'string') {
182
+ return rtn;
183
+ }
184
+ return new Blob([rtn], {
185
+ 'type': tool.getMimeByPath(path).mime
186
+ });
126
187
  }
127
- else if (path.startsWith('/package/')) {
128
- if (!options.files) {
188
+ else if (path.startsWith('/package/') || path.startsWith('/current/')) {
189
+ if (!taskId) {
129
190
  return null;
130
191
  }
131
- const file = options.files[fpath];
192
+ if (path.startsWith('/current/')) {
193
+ return getContent(task.list[taskId].current + fpath, options, taskId);
194
+ }
195
+ const file = task.list[taskId].app.files[fpath];
132
196
  if (!file) {
133
197
  return null;
134
198
  }
@@ -136,7 +200,10 @@ function getContent(path, options) {
136
200
  return file;
137
201
  }
138
202
  if (!options.encoding) {
139
- return file;
203
+ if (start === undefined && end === undefined) {
204
+ return file;
205
+ }
206
+ return file.slice(start, end, file.type);
140
207
  }
141
208
  const encoding = options.encoding;
142
209
  return new Promise(function (resolve) {
@@ -147,20 +214,13 @@ function getContent(path, options) {
147
214
  fr.readAsText(file, encoding);
148
215
  });
149
216
  }
150
- else if (path.startsWith('/current/')) {
151
- if (!options.current) {
152
- return null;
153
- }
154
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
155
- return getContent(current + fpath, options);
156
- }
157
217
  else {
158
218
  return null;
159
219
  }
160
220
  });
161
221
  }
162
222
  exports.getContent = getContent;
163
- function putContent(path, data, options = {}) {
223
+ function putContent(path, data, options = {}, taskId) {
164
224
  var _a, _b;
165
225
  return __awaiter(this, void 0, void 0, function* () {
166
226
  path = tool.urlResolve('/', path);
@@ -168,26 +228,33 @@ function putContent(path, data, options = {}) {
168
228
  if (path.startsWith('/clickgo/')) {
169
229
  return false;
170
230
  }
171
- else if (path.startsWith('/storage/')) {
172
- return false;
173
- }
174
- else if (path.startsWith('/mounted/')) {
175
- const name = getMountName(path);
176
- const hanlder = mounts[name];
177
- if (!hanlder) {
231
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
232
+ const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
233
+ if (!r[0]) {
178
234
  return false;
179
235
  }
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;
236
+ if (path.startsWith('/mounted/')) {
237
+ const name = getMountName(path);
238
+ const hanlder = mounts[name];
239
+ if (!hanlder) {
240
+ return false;
241
+ }
242
+ 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;
243
+ }
244
+ let buf = undefined;
245
+ if (data instanceof Blob) {
246
+ buf = new Uint8Array(yield data.arrayBuffer());
247
+ }
248
+ return native.invoke('cg-fs-putContent', native.getToken(), fpath, buf !== null && buf !== void 0 ? buf : data, options);
181
249
  }
182
250
  else if (path.startsWith('/package/')) {
183
251
  return false;
184
252
  }
185
253
  else if (path.startsWith('/current/')) {
186
- if (!options.current) {
254
+ if (!taskId) {
187
255
  return false;
188
256
  }
189
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
190
- return putContent(current + fpath, data, options);
257
+ return putContent(task.list[taskId].current + fpath, data, options, taskId);
191
258
  }
192
259
  else {
193
260
  return false;
@@ -195,44 +262,37 @@ function putContent(path, data, options = {}) {
195
262
  });
196
263
  }
197
264
  exports.putContent = putContent;
198
- function readLink(path, options) {
265
+ function readLink(path, encoding, taskId) {
199
266
  var _a, _b;
200
267
  return __awaiter(this, void 0, void 0, function* () {
201
268
  path = tool.urlResolve('/', path);
202
269
  const fpath = path.slice(8);
203
- if (typeof options === 'string') {
204
- options = {
205
- 'encoding': options
206
- };
207
- }
208
- else if (!options) {
209
- options = {};
210
- }
211
270
  if (path.startsWith('/clickgo/')) {
212
271
  return null;
213
272
  }
214
- else if (path.startsWith('/storage/')) {
215
- return null;
216
- }
217
- else if (path.startsWith('/mounted/')) {
218
- const name = getMountName(path);
219
- const hanlder = mounts[name];
220
- if (!hanlder) {
273
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
274
+ const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
275
+ if (!r[0]) {
221
276
  return null;
222
277
  }
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;
278
+ if (path.startsWith('/mounted/')) {
279
+ const name = getMountName(path);
280
+ const hanlder = mounts[name];
281
+ if (!hanlder) {
282
+ return null;
283
+ }
284
+ return (_b = (_a = hanlder.readLink) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), encoding)) !== null && _b !== void 0 ? _b : null;
285
+ }
286
+ return native.invoke('cg-fs-readLink', native.getToken(), fpath, encoding);
224
287
  }
225
288
  else if (path.startsWith('/package/')) {
226
289
  return null;
227
290
  }
228
291
  else if (path.startsWith('/current/')) {
229
- if (!options.current) {
292
+ if (!taskId) {
230
293
  return null;
231
294
  }
232
- if (options.current.endsWith('/')) {
233
- return options.current.slice(0, -1);
234
- }
235
- return options.current;
295
+ return task.list[taskId].current;
236
296
  }
237
297
  else {
238
298
  return null;
@@ -240,7 +300,7 @@ function readLink(path, options) {
240
300
  });
241
301
  }
242
302
  exports.readLink = readLink;
243
- function symlink(filePath, linkPath, options = {}) {
303
+ function symlink(filePath, linkPath, type, taskId) {
244
304
  var _a, _b;
245
305
  return __awaiter(this, void 0, void 0, function* () {
246
306
  filePath = tool.urlResolve('/', filePath);
@@ -248,33 +308,36 @@ function symlink(filePath, linkPath, options = {}) {
248
308
  if (filePath.startsWith('/clickgo/')) {
249
309
  return false;
250
310
  }
251
- else if (filePath.startsWith('/storage/')) {
252
- return false;
253
- }
254
- else if (filePath.startsWith('/mounted/')) {
255
- const fname = getMountName(filePath);
256
- const lname = getMountName(linkPath);
257
- if (fname !== lname) {
311
+ else if (filePath.startsWith('/storage/') || filePath.startsWith('/mounted/')) {
312
+ const r = yield task.checkPermission('fs.' + filePath + 'w', false, undefined, taskId);
313
+ if (!r[0]) {
258
314
  return false;
259
315
  }
260
- const hanlder = mounts[fname];
261
- if (!hanlder) {
262
- return false;
316
+ if (filePath.startsWith('/mounted/')) {
317
+ const fname = getMountName(filePath);
318
+ const lname = getMountName(linkPath);
319
+ if (fname !== lname) {
320
+ return false;
321
+ }
322
+ const hanlder = mounts[fname];
323
+ if (!hanlder) {
324
+ return false;
325
+ }
326
+ return (_b = (_a = hanlder.symlink) === null || _a === void 0 ? void 0 : _a.call(hanlder, filePath.slice(9 + fname.length), linkPath.slice(9 + fname.length), type)) !== null && _b !== void 0 ? _b : false;
263
327
  }
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;
328
+ return native.invoke('cg-fs-symlink', native.getToken(), filePath.slice(8), linkPath.slice(8), type);
265
329
  }
266
330
  else if (filePath.startsWith('/package/')) {
267
331
  return false;
268
332
  }
269
333
  else if (filePath.startsWith('/current/')) {
270
- if (!options.current) {
334
+ if (!taskId) {
271
335
  return false;
272
336
  }
273
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
274
337
  if (linkPath.startsWith('/current/')) {
275
- linkPath = current + linkPath.slice(8);
338
+ linkPath = task.list[taskId].current + linkPath.slice(8);
276
339
  }
277
- return symlink(current + filePath.slice(8), linkPath, options);
340
+ return symlink(task.list[taskId].current + filePath.slice(8), linkPath, type, taskId);
278
341
  }
279
342
  else {
280
343
  return false;
@@ -282,7 +345,7 @@ function symlink(filePath, linkPath, options = {}) {
282
345
  });
283
346
  }
284
347
  exports.symlink = symlink;
285
- function unlink(path, options = {}) {
348
+ function unlink(path, taskId) {
286
349
  var _a, _b;
287
350
  return __awaiter(this, void 0, void 0, function* () {
288
351
  path = tool.urlResolve('/', path);
@@ -290,26 +353,29 @@ function unlink(path, options = {}) {
290
353
  if (path.startsWith('/clickgo/')) {
291
354
  return false;
292
355
  }
293
- else if (path.startsWith('/storage/')) {
294
- return false;
295
- }
296
- else if (path.startsWith('/mounted/')) {
297
- const name = getMountName(path);
298
- const hanlder = mounts[name];
299
- if (!hanlder) {
356
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
357
+ const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
358
+ if (!r[0]) {
300
359
  return false;
301
360
  }
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;
361
+ if (path.startsWith('/mounted/')) {
362
+ const name = getMountName(path);
363
+ const hanlder = mounts[name];
364
+ if (!hanlder) {
365
+ return false;
366
+ }
367
+ return (_b = (_a = hanlder.unlink) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length))) !== null && _b !== void 0 ? _b : false;
368
+ }
369
+ return native.invoke('cg-fs-unlink', native.getToken(), fpath);
303
370
  }
304
371
  else if (path.startsWith('/package/')) {
305
372
  return false;
306
373
  }
307
374
  else if (path.startsWith('/current/')) {
308
- if (!options.current) {
375
+ if (!taskId) {
309
376
  return false;
310
377
  }
311
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
312
- return unlink(current + fpath, options);
378
+ return unlink(task.list[taskId].current + fpath, taskId);
313
379
  }
314
380
  else {
315
381
  return false;
@@ -353,7 +419,11 @@ function getClickGoStats(path) {
353
419
  });
354
420
  const hdate = res.headers.get('date');
355
421
  const hmdate = res.headers.get('last-modified');
356
- const hlength = res.headers.get('content-length');
422
+ let hlength = res.headers.get('content-range');
423
+ if (hlength) {
424
+ const lio = hlength.lastIndexOf('/');
425
+ hlength = hlength.slice(lio + 1);
426
+ }
357
427
  let date = new Date();
358
428
  let mdate = date;
359
429
  if (hdate) {
@@ -392,10 +462,63 @@ function getClickGoStats(path) {
392
462
  }
393
463
  });
394
464
  }
395
- function stats(path, options = {}) {
465
+ function stats(path, taskId) {
396
466
  var _a, _b;
397
467
  return __awaiter(this, void 0, void 0, function* () {
398
468
  path = tool.urlResolve('/', path);
469
+ if (path.endsWith('/')) {
470
+ path = path.slice(0, -1);
471
+ }
472
+ if (['', '/clickgo', '/storage', '/mounted', '/package'].includes(path)) {
473
+ const date = new Date();
474
+ const ms = date.getTime();
475
+ return {
476
+ isFile: function () {
477
+ return false;
478
+ },
479
+ isDirectory: function () {
480
+ return true;
481
+ },
482
+ isSymbolicLink: function () {
483
+ return false;
484
+ },
485
+ 'size': 0,
486
+ 'blksize': 0,
487
+ 'atimeMs': ms,
488
+ 'mtimeMs': ms,
489
+ 'ctimeMs': ms,
490
+ 'birthtimeMs': ms,
491
+ 'atime': date,
492
+ 'mtime': date,
493
+ 'ctime': date,
494
+ 'birthtime': date
495
+ };
496
+ }
497
+ if (path === '/current') {
498
+ const date = new Date();
499
+ const ms = date.getTime();
500
+ return {
501
+ isFile: function () {
502
+ return false;
503
+ },
504
+ isDirectory: function () {
505
+ return false;
506
+ },
507
+ isSymbolicLink: function () {
508
+ return true;
509
+ },
510
+ 'size': 0,
511
+ 'blksize': 0,
512
+ 'atimeMs': ms,
513
+ 'mtimeMs': ms,
514
+ 'ctimeMs': ms,
515
+ 'birthtimeMs': ms,
516
+ 'atime': date,
517
+ 'mtime': date,
518
+ 'ctime': date,
519
+ 'birthtime': date
520
+ };
521
+ }
399
522
  let fpath = path.slice(8);
400
523
  if (path.startsWith('/clickgo/')) {
401
524
  if (!clickgoFiles.includes(fpath)) {
@@ -407,7 +530,35 @@ function stats(path, options = {}) {
407
530
  return getClickGoStats(fpath);
408
531
  }
409
532
  else if (path.startsWith('/storage/')) {
410
- return null;
533
+ const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
534
+ if (!r[0]) {
535
+ return null;
536
+ }
537
+ const item = yield native.invoke('cg-fs-stats', native.getToken(), fpath);
538
+ if (!item) {
539
+ return null;
540
+ }
541
+ return {
542
+ isFile: function () {
543
+ return item.isFile;
544
+ },
545
+ isDirectory: function () {
546
+ return item.isDirectory;
547
+ },
548
+ isSymbolicLink: function () {
549
+ return item.isSymbolicLink;
550
+ },
551
+ 'size': item.size,
552
+ 'blksize': item.blksize,
553
+ 'atimeMs': item.atimeMs,
554
+ 'mtimeMs': item.mtimeMs,
555
+ 'ctimeMs': item.ctimeMs,
556
+ 'birthtimeMs': item.birthtimeMs,
557
+ 'atime': item.atime,
558
+ 'mtime': item.mtime,
559
+ 'ctime': item.ctime,
560
+ 'birthtime': item.birthtime
561
+ };
411
562
  }
412
563
  else if (path.startsWith('/mounted/')) {
413
564
  const name = getMountName(path);
@@ -415,14 +566,45 @@ function stats(path, options = {}) {
415
566
  if (!hanlder) {
416
567
  return null;
417
568
  }
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;
569
+ if (path === '/mounted/' + name) {
570
+ const ms = hanlder.date.getTime();
571
+ return {
572
+ isFile: function () {
573
+ return false;
574
+ },
575
+ isDirectory: function () {
576
+ return true;
577
+ },
578
+ isSymbolicLink: function () {
579
+ return false;
580
+ },
581
+ 'size': 0,
582
+ 'blksize': 0,
583
+ 'atimeMs': ms,
584
+ 'mtimeMs': ms,
585
+ 'ctimeMs': ms,
586
+ 'birthtimeMs': ms,
587
+ 'atime': hanlder.date,
588
+ 'mtime': hanlder.date,
589
+ 'ctime': hanlder.date,
590
+ 'birthtime': hanlder.date
591
+ };
592
+ }
593
+ const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
594
+ if (!r[0]) {
595
+ return null;
596
+ }
597
+ return (_b = (_a = hanlder.stats) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length))) !== null && _b !== void 0 ? _b : null;
419
598
  }
420
- else if (path.startsWith('/package/')) {
421
- if (!options.files) {
599
+ else if (path.startsWith('/package/') || path.startsWith('/current/')) {
600
+ if (!taskId) {
422
601
  return null;
423
602
  }
424
- if (options.files[fpath]) {
425
- const file = options.files[fpath];
603
+ if (path.startsWith('/current/')) {
604
+ return stats(task.list[taskId].current + fpath, taskId);
605
+ }
606
+ if (task.list[taskId].app.files[fpath]) {
607
+ const file = task.list[taskId].app.files[fpath];
426
608
  const date = new Date();
427
609
  const ms = date.getTime();
428
610
  let size = 0;
@@ -457,7 +639,7 @@ function stats(path, options = {}) {
457
639
  if (!fpath.endsWith('/')) {
458
640
  fpath += '/';
459
641
  }
460
- for (const p in options.files) {
642
+ for (const p in task.list[taskId].app.files) {
461
643
  if (!p.startsWith(fpath)) {
462
644
  continue;
463
645
  }
@@ -487,70 +669,66 @@ function stats(path, options = {}) {
487
669
  }
488
670
  return null;
489
671
  }
490
- else if (path.startsWith('/current/')) {
491
- if (!options.current) {
492
- return null;
493
- }
494
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
495
- return stats(current + fpath, options);
496
- }
497
672
  else {
498
673
  return null;
499
674
  }
500
675
  });
501
676
  }
502
677
  exports.stats = stats;
503
- function isDir(path, options = {}) {
678
+ function isDir(path, taskId) {
504
679
  return __awaiter(this, void 0, void 0, function* () {
505
- const pstats = yield stats(path, options);
506
- if (!pstats || !pstats.isDirectory()) {
680
+ const pstats = yield stats(path, taskId);
681
+ if (!(pstats === null || pstats === void 0 ? void 0 : pstats.isDirectory())) {
507
682
  return false;
508
683
  }
509
684
  return pstats;
510
685
  });
511
686
  }
512
687
  exports.isDir = isDir;
513
- function isFile(path, options = {}) {
688
+ function isFile(path, taskId) {
514
689
  return __awaiter(this, void 0, void 0, function* () {
515
- const pstats = yield stats(path, options);
516
- if (!pstats || !pstats.isFile()) {
690
+ const pstats = yield stats(path, taskId);
691
+ if (!(pstats === null || pstats === void 0 ? void 0 : pstats.isFile())) {
517
692
  return false;
518
693
  }
519
694
  return pstats;
520
695
  });
521
696
  }
522
697
  exports.isFile = isFile;
523
- function mkdir(path, mode = 0o755, options = {}) {
698
+ function mkdir(path, mode = 0o755, taskId) {
524
699
  var _a, _b;
525
700
  return __awaiter(this, void 0, void 0, function* () {
526
701
  path = tool.urlResolve('/', path);
527
- if (yield isDir(path, options)) {
702
+ if (yield isDir(path, taskId)) {
528
703
  return true;
529
704
  }
530
705
  const fpath = path.slice(8);
531
706
  if (path.startsWith('/clickgo/')) {
532
707
  return false;
533
708
  }
534
- else if (path.startsWith('/storage/')) {
535
- return false;
536
- }
537
- else if (path.startsWith('/mounted/')) {
538
- const name = getMountName(path);
539
- const hanlder = mounts[name];
540
- if (!hanlder) {
709
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
710
+ const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
711
+ if (!r[0]) {
541
712
  return false;
542
713
  }
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;
714
+ if (path.startsWith('/mounted/')) {
715
+ const name = getMountName(path);
716
+ const hanlder = mounts[name];
717
+ if (!hanlder) {
718
+ return false;
719
+ }
720
+ return (_b = (_a = hanlder.mkdir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), mode)) !== null && _b !== void 0 ? _b : false;
721
+ }
722
+ return native.invoke('cg-fs-mkdir', native.getToken(), fpath, mode);
544
723
  }
545
724
  else if (path.startsWith('/package/')) {
546
725
  return false;
547
726
  }
548
727
  else if (path.startsWith('/current/')) {
549
- if (!options.current) {
728
+ if (!taskId) {
550
729
  return false;
551
730
  }
552
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
553
- return mkdir(current + fpath, mode, options);
731
+ return mkdir(task.list[taskId].current + fpath, mode, taskId);
554
732
  }
555
733
  else {
556
734
  return false;
@@ -558,7 +736,7 @@ function mkdir(path, mode = 0o755, options = {}) {
558
736
  });
559
737
  }
560
738
  exports.mkdir = mkdir;
561
- function rmdir(path, options = {}) {
739
+ function rmdir(path, taskId) {
562
740
  var _a, _b;
563
741
  return __awaiter(this, void 0, void 0, function* () {
564
742
  path = tool.urlResolve('/', path);
@@ -566,26 +744,29 @@ function rmdir(path, options = {}) {
566
744
  if (path.startsWith('/clickgo/')) {
567
745
  return false;
568
746
  }
569
- else if (path.startsWith('/storage/')) {
570
- return false;
571
- }
572
- else if (path.startsWith('/mounted/')) {
573
- const name = getMountName(path);
574
- const hanlder = mounts[name];
575
- if (!hanlder) {
747
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
748
+ const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
749
+ if (!r[0]) {
576
750
  return false;
577
751
  }
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;
752
+ if (path.startsWith('/mounted/')) {
753
+ const name = getMountName(path);
754
+ const hanlder = mounts[name];
755
+ if (!hanlder) {
756
+ return false;
757
+ }
758
+ return (_b = (_a = hanlder.rmdir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length))) !== null && _b !== void 0 ? _b : false;
759
+ }
760
+ return native.invoke('cg-fs-rmdir', native.getToken(), fpath);
579
761
  }
580
762
  else if (path.startsWith('/package/')) {
581
763
  return false;
582
764
  }
583
765
  else if (path.startsWith('/current/')) {
584
- if (!options.current) {
766
+ if (!taskId) {
585
767
  return false;
586
768
  }
587
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
588
- return rmdir(current + fpath, options);
769
+ return rmdir(task.list[taskId].current + fpath, taskId);
589
770
  }
590
771
  else {
591
772
  return false;
@@ -593,36 +774,36 @@ function rmdir(path, options = {}) {
593
774
  });
594
775
  }
595
776
  exports.rmdir = rmdir;
596
- function rmdirDeep(path, options = {}) {
777
+ function rmdirDeep(path, taskId) {
597
778
  return __awaiter(this, void 0, void 0, function* () {
598
779
  path = tool.urlResolve('/', path);
599
780
  if (!path.endsWith('/')) {
600
781
  path += '/';
601
782
  }
602
- const list = yield readDir(path, options);
783
+ const list = yield readDir(path, undefined, taskId);
603
784
  for (const item of list) {
604
- const stat = yield stats(path + item.name, options);
785
+ const stat = yield stats(path + item.name, taskId);
605
786
  if (!stat) {
606
787
  return false;
607
788
  }
608
789
  if (stat.isDirectory()) {
609
- const rtn = yield rmdirDeep(path + item.name, options);
790
+ const rtn = yield rmdirDeep(path + item.name, taskId);
610
791
  if (!rtn) {
611
792
  return false;
612
793
  }
613
794
  }
614
795
  else {
615
- const rtn = yield unlink(path + item.name, options);
796
+ const rtn = yield unlink(path + item.name, taskId);
616
797
  if (!rtn) {
617
798
  return false;
618
799
  }
619
800
  }
620
801
  }
621
- return rmdir(path, options);
802
+ return rmdir(path, taskId);
622
803
  });
623
804
  }
624
805
  exports.rmdirDeep = rmdirDeep;
625
- function chmod(path, mod, options = {}) {
806
+ function chmod(path, mod, taskId) {
626
807
  var _a, _b;
627
808
  return __awaiter(this, void 0, void 0, function* () {
628
809
  path = tool.urlResolve('/', path);
@@ -630,26 +811,29 @@ function chmod(path, mod, options = {}) {
630
811
  if (path.startsWith('/clickgo/')) {
631
812
  return false;
632
813
  }
633
- else if (path.startsWith('/storage/')) {
634
- return false;
635
- }
636
- else if (path.startsWith('/mounted/')) {
637
- const name = getMountName(path);
638
- const hanlder = mounts[name];
639
- if (!hanlder) {
814
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
815
+ const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
816
+ if (!r[0]) {
640
817
  return false;
641
818
  }
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;
819
+ if (path.startsWith('/mounted/')) {
820
+ const name = getMountName(path);
821
+ const hanlder = mounts[name];
822
+ if (!hanlder) {
823
+ return false;
824
+ }
825
+ return (_b = (_a = hanlder.chmod) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), mod)) !== null && _b !== void 0 ? _b : false;
826
+ }
827
+ return native.invoke('cg-fs-chmod', native.getToken(), fpath, mod);
643
828
  }
644
829
  else if (path.startsWith('/package/')) {
645
830
  return false;
646
831
  }
647
832
  else if (path.startsWith('/current/')) {
648
- if (!options.current) {
833
+ if (!taskId) {
649
834
  return false;
650
835
  }
651
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
652
- return chmod(current + fpath, mod, options);
836
+ return chmod(task.list[taskId].current + fpath, mod, taskId);
653
837
  }
654
838
  else {
655
839
  return false;
@@ -657,7 +841,8 @@ function chmod(path, mod, options = {}) {
657
841
  });
658
842
  }
659
843
  exports.chmod = chmod;
660
- function rename(oldPath, newPath, options = {}) {
844
+ function rename(oldPath, newPath, taskId) {
845
+ var _a, _b;
661
846
  return __awaiter(this, void 0, void 0, function* () {
662
847
  oldPath = tool.urlResolve('/', oldPath);
663
848
  newPath = tool.urlResolve('/', newPath);
@@ -669,21 +854,37 @@ function rename(oldPath, newPath, options = {}) {
669
854
  if (oldPath.startsWith('/clickgo/')) {
670
855
  return false;
671
856
  }
672
- else if (oldPath.startsWith('/storage/')) {
673
- return false;
674
- }
675
- else if (oldPath.startsWith('/mounted/')) {
676
- return false;
857
+ else if (oldPath.startsWith('/storage/') || oldPath.startsWith('/mounted/')) {
858
+ let r = yield task.checkPermission('fs.' + oldPath + 'w', false, undefined, taskId);
859
+ if (!r[0]) {
860
+ return false;
861
+ }
862
+ r = yield task.checkPermission('fs.' + newPath + 'w', false, undefined, taskId);
863
+ if (!r[0]) {
864
+ return false;
865
+ }
866
+ if (oldPath.startsWith('/mounted/')) {
867
+ const fname = getMountName(oldPath);
868
+ const lname = getMountName(newPath);
869
+ if (fname !== lname) {
870
+ return false;
871
+ }
872
+ const hanlder = mounts[fname];
873
+ if (!hanlder) {
874
+ return false;
875
+ }
876
+ return (_b = (_a = hanlder.rename) === null || _a === void 0 ? void 0 : _a.call(hanlder, oldPath.slice(9 + fname.length), newPath.slice(9 + fname.length))) !== null && _b !== void 0 ? _b : false;
877
+ }
878
+ return native.invoke('cg-fs-rename', native.getToken(), ofpath, nfpath);
677
879
  }
678
880
  else if (oldPath.startsWith('/package/')) {
679
881
  return false;
680
882
  }
681
883
  else if (oldPath.startsWith('/current/')) {
682
- if (!options.current) {
884
+ if (!taskId) {
683
885
  return false;
684
886
  }
685
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
686
- return rename(current + ofpath, current + nfpath, options);
887
+ return rename(task.list[taskId].current + ofpath, task.list[taskId].current + nfpath, taskId);
687
888
  }
688
889
  else {
689
890
  return false;
@@ -691,7 +892,8 @@ function rename(oldPath, newPath, options = {}) {
691
892
  });
692
893
  }
693
894
  exports.rename = rename;
694
- function readDir(path, options = {}) {
895
+ function readDir(path, encoding, taskId) {
896
+ var _a, _b;
695
897
  return __awaiter(this, void 0, void 0, function* () {
696
898
  path = tool.urlResolve('/', path);
697
899
  if (path === '/') {
@@ -733,7 +935,7 @@ function readDir(path, options = {}) {
733
935
  'name': 'mounted'
734
936
  }
735
937
  ];
736
- if (options.files) {
938
+ if (taskId) {
737
939
  list.push({
738
940
  isFile: function () {
739
941
  return false;
@@ -747,7 +949,7 @@ function readDir(path, options = {}) {
747
949
  'name': 'package'
748
950
  });
749
951
  }
750
- if (options.current) {
952
+ if (taskId) {
751
953
  list.push({
752
954
  isFile: function () {
753
955
  return false;
@@ -812,19 +1014,64 @@ function readDir(path, options = {}) {
812
1014
  }
813
1015
  return list;
814
1016
  }
815
- else if (path.startsWith('/storage/')) {
816
- return [];
817
- }
818
- else if (path.startsWith('/mounted/')) {
819
- return [];
1017
+ else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
1018
+ const list = [];
1019
+ if (path === '/mounted/') {
1020
+ for (const name in mounts) {
1021
+ list.push({
1022
+ isFile: function () {
1023
+ return false;
1024
+ },
1025
+ isDirectory: function () {
1026
+ return true;
1027
+ },
1028
+ isSymbolicLink: function () {
1029
+ return false;
1030
+ },
1031
+ 'name': name
1032
+ });
1033
+ }
1034
+ return list;
1035
+ }
1036
+ const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
1037
+ if (!r[0]) {
1038
+ return [];
1039
+ }
1040
+ if (path.startsWith('/mounted/')) {
1041
+ const name = getMountName(path);
1042
+ const hanlder = mounts[name];
1043
+ if (!hanlder) {
1044
+ return [];
1045
+ }
1046
+ return (_b = (_a = hanlder.readDir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), encoding)) !== null && _b !== void 0 ? _b : [];
1047
+ }
1048
+ const ls = yield native.invoke('cg-fs-readDir', native.getToken(), fpath, encoding);
1049
+ for (const item of ls) {
1050
+ list.push({
1051
+ isFile: function () {
1052
+ return item.isFile;
1053
+ },
1054
+ isDirectory: function () {
1055
+ return item.isDirectory;
1056
+ },
1057
+ isSymbolicLink: function () {
1058
+ return item.isSymbolicLink;
1059
+ },
1060
+ 'name': item.name
1061
+ });
1062
+ }
1063
+ return list;
820
1064
  }
821
- else if (path.startsWith('/package/')) {
822
- if (!options.files) {
1065
+ else if (path.startsWith('/package/') || path.startsWith('/current/')) {
1066
+ if (!taskId) {
823
1067
  return [];
824
1068
  }
1069
+ if (path.startsWith('/current/')) {
1070
+ return readDir(task.list[taskId].current + fpath, encoding, taskId);
1071
+ }
825
1072
  const list = [];
826
1073
  const dirs = [];
827
- for (const p in options.files) {
1074
+ for (const p in task.list[taskId].app.files) {
828
1075
  if (!p.startsWith(fpath)) {
829
1076
  continue;
830
1077
  }
@@ -864,54 +1111,52 @@ function readDir(path, options = {}) {
864
1111
  }
865
1112
  return list;
866
1113
  }
867
- else if (path.startsWith('/current/')) {
868
- if (!options.current) {
869
- return [];
870
- }
871
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
872
- return readDir(current + fpath, options);
873
- }
874
1114
  else {
875
1115
  return [];
876
1116
  }
877
1117
  });
878
1118
  }
879
1119
  exports.readDir = readDir;
880
- function copyFolder(from, to, options = {}) {
1120
+ function copyFolder(from, to, ignore = [], taskId) {
881
1121
  return __awaiter(this, void 0, void 0, function* () {
882
- from = tool.urlResolve('/', from);
883
- to = tool.urlResolve('/', to);
884
- if (!from.startsWith(to.slice(0, 9))) {
885
- return 0;
886
- }
887
- const ffpath = from.slice(8);
888
- const tfpath = from.slice(8);
889
- if (from.startsWith('/clickgo/')) {
890
- return 0;
891
- }
892
- else if (from.startsWith('/storage/')) {
893
- return 0;
894
- }
895
- else if (from.startsWith('/mounted/')) {
896
- return 0;
897
- }
898
- else if (from.startsWith('/package/')) {
1122
+ let num = 0;
1123
+ if (!(yield isDir(from, taskId))) {
899
1124
  return 0;
900
1125
  }
901
- else if (from.startsWith('/current/')) {
902
- if (!options.current) {
903
- return 0;
1126
+ const flist = yield readDir(from, undefined, taskId);
1127
+ let checkTo = false;
1128
+ for (const item of flist) {
1129
+ if (item.isDirectory()) {
1130
+ const r = yield copyFolder(from + item.name + '/', to + item.name + '/', ignore, taskId);
1131
+ if (r === -1) {
1132
+ return r;
1133
+ }
1134
+ else {
1135
+ num += r;
1136
+ }
1137
+ }
1138
+ else if (item.isFile()) {
1139
+ if (ignore.length > 0 && tool.match(item.name, ignore)) {
1140
+ continue;
1141
+ }
1142
+ if (!checkTo) {
1143
+ if (!(yield mkdir(to, undefined, taskId))) {
1144
+ return -1;
1145
+ }
1146
+ checkTo = true;
1147
+ }
1148
+ if (!(yield copyFile(from + item.name, to + item.name, taskId))) {
1149
+ continue;
1150
+ }
1151
+ ++num;
904
1152
  }
905
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
906
- return copyFolder(current + ffpath, current + tfpath, options);
907
- }
908
- else {
909
- return 0;
910
1153
  }
1154
+ return num;
911
1155
  });
912
1156
  }
913
1157
  exports.copyFolder = copyFolder;
914
- function copyFile(src, dest, options = {}) {
1158
+ function copyFile(src, dest, taskId) {
1159
+ var _a, _b;
915
1160
  return __awaiter(this, void 0, void 0, function* () {
916
1161
  src = tool.urlResolve('/', src);
917
1162
  dest = tool.urlResolve('/', dest);
@@ -923,21 +1168,37 @@ function copyFile(src, dest, options = {}) {
923
1168
  if (src.startsWith('/clickgo/')) {
924
1169
  return false;
925
1170
  }
926
- else if (src.startsWith('/storage/')) {
927
- return false;
928
- }
929
- else if (src.startsWith('/mounted/')) {
930
- return false;
1171
+ else if (src.startsWith('/storage/') || dest.startsWith('/mounted/')) {
1172
+ let r = yield task.checkPermission('fs.' + src + 'r', false, undefined, taskId);
1173
+ if (!r[0]) {
1174
+ return false;
1175
+ }
1176
+ r = yield task.checkPermission('fs.' + dest + 'w', false, undefined, taskId);
1177
+ if (!r[0]) {
1178
+ return false;
1179
+ }
1180
+ if (src.startsWith('/mounted/')) {
1181
+ const fname = getMountName(src);
1182
+ const lname = getMountName(dest);
1183
+ if (fname !== lname) {
1184
+ return false;
1185
+ }
1186
+ const hanlder = mounts[fname];
1187
+ if (!hanlder) {
1188
+ return false;
1189
+ }
1190
+ return (_b = (_a = hanlder.copyFile) === null || _a === void 0 ? void 0 : _a.call(hanlder, src.slice(9 + fname.length), dest.slice(9 + fname.length))) !== null && _b !== void 0 ? _b : false;
1191
+ }
1192
+ return native.invoke('cg-fs-copyFile', native.getToken(), sfpath, dfpath);
931
1193
  }
932
1194
  else if (src.startsWith('/package/')) {
933
1195
  return false;
934
1196
  }
935
1197
  else if (src.startsWith('/current/')) {
936
- if (!options.current) {
1198
+ if (!taskId) {
937
1199
  return false;
938
1200
  }
939
- const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
940
- return copyFile(current + sfpath, current + dfpath, options);
1201
+ return copyFile(task.list[taskId].current + sfpath, task.list[taskId].current + dfpath, taskId);
941
1202
  }
942
1203
  else {
943
1204
  return false;