verteilen-core 1.2.4 → 1.2.6

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/dist/index.d.ts +3 -0
  2. package/dist/jest.config.d.ts +2 -0
  3. package/dist/src/client/analysis.d.ts +35 -0
  4. package/dist/src/client/analysis.js +318 -319
  5. package/dist/src/client/client.d.ts +25 -0
  6. package/dist/src/client/client.js +162 -168
  7. package/dist/src/client/cluster.d.ts +1 -0
  8. package/dist/src/client/cluster.js +1 -2
  9. package/dist/src/client/database.d.ts +13 -0
  10. package/dist/src/client/database.js +28 -27
  11. package/dist/src/client/execute.d.ts +24 -0
  12. package/dist/src/client/execute.js +61 -51
  13. package/dist/src/client/http.d.ts +7 -0
  14. package/dist/src/client/http.js +29 -26
  15. package/dist/src/client/javascript.d.ts +47 -0
  16. package/dist/src/client/javascript.js +110 -136
  17. package/dist/src/client/job_database.d.ts +10 -0
  18. package/dist/src/client/job_database.js +27 -29
  19. package/dist/src/client/job_execute.d.ts +20 -0
  20. package/dist/src/client/job_execute.js +148 -146
  21. package/dist/src/client/os.d.ts +29 -0
  22. package/dist/src/client/os.js +131 -136
  23. package/dist/src/client/resource.d.ts +7 -0
  24. package/dist/src/client/resource.js +93 -104
  25. package/dist/src/client/shell.d.ts +16 -0
  26. package/dist/src/client/shell.js +102 -98
  27. package/dist/src/computed.d.ts +13 -0
  28. package/dist/src/interface/base.d.ts +70 -0
  29. package/dist/src/interface/bus.d.ts +90 -0
  30. package/dist/src/interface/enum.d.ts +143 -0
  31. package/dist/src/interface/execute.d.ts +20 -0
  32. package/dist/src/interface/record.d.ts +93 -0
  33. package/dist/src/interface/server.d.ts +76 -0
  34. package/dist/src/interface/struct.d.ts +182 -0
  35. package/dist/src/interface/table.d.ts +20 -0
  36. package/dist/src/interface/ui.d.ts +29 -0
  37. package/dist/src/interface.d.ts +29 -0
  38. package/dist/src/plugins/i18n.d.ts +1666 -0
  39. package/dist/src/script/console_manager.d.ts +18 -0
  40. package/dist/src/script/console_manager.js +97 -91
  41. package/dist/src/script/console_server_manager.d.ts +13 -0
  42. package/dist/src/script/console_server_manager.js +29 -26
  43. package/dist/src/script/execute/base.d.ts +45 -0
  44. package/dist/src/script/execute/base.js +165 -162
  45. package/dist/src/script/execute/feedback.d.ts +12 -0
  46. package/dist/src/script/execute/feedback.js +162 -171
  47. package/dist/src/script/execute/interface.d.ts +8 -0
  48. package/dist/src/script/execute/region_job.d.ts +5 -0
  49. package/dist/src/script/execute/region_job.js +1 -0
  50. package/dist/src/script/execute/region_project.d.ts +10 -0
  51. package/dist/src/script/execute/region_project.js +4 -0
  52. package/dist/src/script/execute/region_subtask.d.ts +5 -0
  53. package/dist/src/script/execute/region_subtask.js +1 -0
  54. package/dist/src/script/execute/region_task.d.ts +10 -0
  55. package/dist/src/script/execute/region_task.js +4 -0
  56. package/dist/src/script/execute/runner.d.ts +14 -0
  57. package/dist/src/script/execute/runner.js +129 -139
  58. package/dist/src/script/execute/util_parser.d.ts +14 -0
  59. package/dist/src/script/execute/util_parser.js +119 -121
  60. package/dist/src/script/execute_manager.d.ts +25 -0
  61. package/dist/src/script/execute_manager.js +266 -278
  62. package/dist/src/script/socket_manager.d.ts +31 -0
  63. package/dist/src/script/socket_manager.js +196 -193
  64. package/dist/src/script/webhook_manager.d.ts +3 -0
  65. package/dist/src/script/webhook_server_manager.d.ts +13 -0
  66. package/dist/src/script/webhook_server_manager.js +79 -86
  67. package/dist/src/server/detail.d.ts +72 -0
  68. package/dist/src/server/detail.js +401 -378
  69. package/dist/src/server/io.d.ts +46 -0
  70. package/dist/src/server/io.js +42 -51
  71. package/dist/src/server/plugin.d.ts +18 -0
  72. package/dist/src/server/plugin.js +45 -54
  73. package/dist/src/server/server.d.ts +27 -0
  74. package/dist/src/server/server.js +38 -36
  75. package/dist/src/server.d.ts +4 -0
  76. package/dist/src/util/console_handle.d.ts +20 -0
  77. package/dist/src/util/console_handle.js +214 -218
  78. package/dist/src/util/log_handle.d.ts +23 -0
  79. package/dist/src/util/log_handle.js +158 -164
  80. package/dist/test/TEST.d.ts +1 -0
  81. package/dist/test/TEST.js +37 -54
  82. package/dist/test/client/execute.test.d.ts +1 -0
  83. package/dist/test/client/execute.test.js +6 -15
  84. package/dist/test/client/javascript.test.d.ts +1 -0
  85. package/dist/test/client/javascript.test.js +21 -30
  86. package/dist/test/client/server.test.d.ts +1 -0
  87. package/dist/test/client/task.test.d.ts +1 -0
  88. package/dist/test/client/task.test.js +1 -1
  89. package/dist/test/script/parser.test.d.ts +1 -0
  90. package/dist/test/script/socket.test.d.ts +1 -0
  91. package/package.json +1 -1
  92. package/tsconfig.json +5 -3
@@ -6,143 +6,66 @@ const interface_1 = require("../../interface");
6
6
  const feedback_1 = require("./feedback");
7
7
  const util_parser_1 = require("./util_parser");
8
8
  class ExecuteManager_Runner extends feedback_1.ExecuteManager_Feedback {
9
- constructor() {
10
- super(...arguments);
11
- this.ExecuteProject = (project) => {
12
- var _a, _b, _c;
13
- if (this.current_t == undefined && project.task.length > 0 && this.t_state != interface_1.ExecuteState.FINISH) {
14
- this.current_t = project.task[0];
15
- this.messager_log(`[Execute] Task Start ${this.current_t.uuid}`);
16
- this.messager_log(`[Execute] Task cron state: ${this.current_t.cronjob}`);
17
- this.current_job = [];
18
- this.current_cron = [];
19
- }
20
- else if (project.task.length == 0) {
21
- this.current_t = undefined;
22
- }
23
- if (this.current_t != undefined) {
24
- this.ExecuteTask(project, this.current_t);
25
- }
26
- else {
27
- const index = this.current_projects.findIndex(x => x.uuid == project.uuid);
28
- if (index < this.current_projects.length - 1) {
29
- this.messager_log(`[Execute] Project Finish ${this.current_p.uuid}`);
30
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeProjectFinish([this.current_p, index]);
31
- this.current_p = this.current_projects[index + 1];
32
- (_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeProjectStart([this.current_p, index + 1]);
33
- this.t_state = interface_1.ExecuteState.NONE;
34
- }
35
- else {
36
- this.messager_log(`[Execute] Project Finish ${this.current_p.uuid}`);
37
- (_c = this.proxy) === null || _c === void 0 ? void 0 : _c.executeProjectFinish([this.current_p, index]);
38
- this.current_p = undefined;
39
- this.state = interface_1.ExecuteState.FINISH;
40
- this.t_state = interface_1.ExecuteState.NONE;
41
- }
42
- }
43
- };
44
- this.ExecuteTask = (project, task) => {
45
- var _a, _b;
46
- if (this.t_state == interface_1.ExecuteState.NONE) {
47
- this.t_state = interface_1.ExecuteState.RUNNING;
48
- this.current_multithread = task.multi ? this.get_task_multi_count(task) : 1;
49
- this.current_task_count = this.get_task_state_count(task);
50
- }
51
- let allJobFinish = false;
52
- const hasJob = task.jobs.length > 0;
53
- if (!hasJob) {
54
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskStart([task, this.current_task_count]);
55
- (_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeTaskFinish(task);
56
- this.messager_log(`[Execute] Skip ! No job exists ${task.uuid}`);
57
- this.ExecuteTask_AllFinish(project, task);
58
- return;
59
- }
60
- if (task.setupjob) {
61
- allJobFinish = this.ExecuteTask_Setup(project, task, this.current_task_count);
62
- }
63
- else if (task.cronjob) {
64
- allJobFinish = this.ExecuteTask_Cronjob(project, task, this.current_task_count);
9
+ ExecuteProject = (project) => {
10
+ if (this.current_t == undefined && project.task.length > 0 && this.t_state != interface_1.ExecuteState.FINISH) {
11
+ this.current_t = project.task[0];
12
+ this.messager_log(`[Execute] Task Start ${this.current_t.uuid}`);
13
+ this.messager_log(`[Execute] Task cron state: ${this.current_t.cronjob}`);
14
+ this.current_job = [];
15
+ this.current_cron = [];
16
+ }
17
+ else if (project.task.length == 0) {
18
+ this.current_t = undefined;
19
+ }
20
+ if (this.current_t != undefined) {
21
+ this.ExecuteTask(project, this.current_t);
22
+ }
23
+ else {
24
+ const index = this.current_projects.findIndex(x => x.uuid == project.uuid);
25
+ if (index < this.current_projects.length - 1) {
26
+ this.messager_log(`[Execute] Project Finish ${this.current_p.uuid}`);
27
+ this.proxy?.executeProjectFinish([this.current_p, index]);
28
+ this.current_p = this.current_projects[index + 1];
29
+ this.proxy?.executeProjectStart([this.current_p, index + 1]);
30
+ this.t_state = interface_1.ExecuteState.NONE;
65
31
  }
66
32
  else {
67
- allJobFinish = this.ExecuteTask_Single(project, task, this.current_task_count);
68
- }
69
- if (allJobFinish) {
70
- this.ExecuteTask_AllFinish(project, task);
71
- }
72
- };
73
- this.ExecuteCronTask = (project, task, work, ns) => {
74
- var _a;
75
- if (ns.current_job.length < this.current_multithread) {
76
- const rindex = work.work.findIndex(x => x.state == interface_1.ExecuteState.RUNNING);
77
- if (rindex != -1)
78
- return;
79
- const index = work.work.findIndex(x => x.state == interface_1.ExecuteState.NONE);
80
- if (index == 0)
81
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeSubtaskStart([task, work.id, ns.uuid]);
82
- if (index == -1)
83
- return;
84
- work.work[index].state = interface_1.ExecuteState.RUNNING;
85
- try {
86
- const job = JSON.parse(JSON.stringify(task.jobs[index]));
87
- job.index = work.id;
88
- job.runtime_uuid = work.work[index].runtime;
89
- this.ExecuteJob(project, task, job, ns, true);
90
- }
91
- catch (err) {
92
- this.messager_log(`[ExecuteCronTask Error] UUID: ${task.uuid}, Job count: ${task.jobs.length}, index: ${index}`);
93
- }
33
+ this.messager_log(`[Execute] Project Finish ${this.current_p.uuid}`);
34
+ this.proxy?.executeProjectFinish([this.current_p, index]);
35
+ this.current_p = undefined;
36
+ this.state = interface_1.ExecuteState.FINISH;
37
+ this.t_state = interface_1.ExecuteState.NONE;
94
38
  }
95
- };
96
- this.ExecuteJob = (project, task, job, wss, iscron) => {
97
- var _a;
98
- const n = job.index;
99
- this.messager_log(`[Execute] Job Start ${n} ${job.uuid} ${wss.uuid}`);
100
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeJobStart([job, n, wss.uuid]);
101
- ExecuteManager_Runner.string_args_transform(task, job, this.messager_log, this.localPara, n);
102
- const h = {
103
- name: 'execute_job',
104
- channel: this.uuid,
105
- data: job
106
- };
107
- wss.current_job.push(job.runtime_uuid);
108
- const stringdata = JSON.stringify(h);
109
- wss.websocket.send(stringdata);
110
- this.jobstack = this.jobstack + 1;
111
- };
112
- this.SyncDatabase = (p) => {
113
- this.localPara = JSON.parse(JSON.stringify(p.database));
114
- this.messager_log("[Execute] Sync Database !");
115
- this.messager_log("[Execute] Generate local database object");
116
- for (let i = 0; i < this.localPara.containers.length; i++) {
117
- if (this.localPara.containers[i].type == interface_1.DataType.Expression && this.localPara.containers[i].meta != undefined) {
118
- const text = `%{${this.localPara.containers[i].meta}}%`;
119
- const e = new util_parser_1.Util_Parser([...util_parser_1.Util_Parser.to_keyvalue(this.localPara)]);
120
- this.localPara.containers[i].value = e.replacePara(text);
121
- }
122
- }
123
- this.sync_local_para(this.localPara);
124
- };
125
- this.Init_CronContainer = (task, taskCount) => {
126
- var _a;
127
- this.sync_local_para(this.localPara);
128
- this.current_cron = [];
129
- for (let i = 0; i < taskCount; i++) {
130
- const d = {
131
- id: i,
132
- uuid: "",
133
- work: task.jobs.map(x => ({
134
- uuid: x.uuid,
135
- runtime: '',
136
- state: interface_1.ExecuteState.NONE,
137
- job: x
138
- }))
139
- };
140
- d.work.forEach((x, j) => x.runtime = (0, uuid_1.v6)({}, undefined, i * taskCount + j));
141
- this.current_cron.push(d);
142
- }
143
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskStart([task, taskCount]);
144
- };
145
- }
39
+ }
40
+ };
41
+ ExecuteTask = (project, task) => {
42
+ if (this.t_state == interface_1.ExecuteState.NONE) {
43
+ this.t_state = interface_1.ExecuteState.RUNNING;
44
+ this.current_multithread = task.multi ? this.get_task_multi_count(task) : 1;
45
+ this.current_task_count = this.get_task_state_count(task);
46
+ }
47
+ let allJobFinish = false;
48
+ const hasJob = task.jobs.length > 0;
49
+ if (!hasJob) {
50
+ this.proxy?.executeTaskStart([task, this.current_task_count]);
51
+ this.proxy?.executeTaskFinish(task);
52
+ this.messager_log(`[Execute] Skip ! No job exists ${task.uuid}`);
53
+ this.ExecuteTask_AllFinish(project, task);
54
+ return;
55
+ }
56
+ if (task.setupjob) {
57
+ allJobFinish = this.ExecuteTask_Setup(project, task, this.current_task_count);
58
+ }
59
+ else if (task.cronjob) {
60
+ allJobFinish = this.ExecuteTask_Cronjob(project, task, this.current_task_count);
61
+ }
62
+ else {
63
+ allJobFinish = this.ExecuteTask_Single(project, task, this.current_task_count);
64
+ }
65
+ if (allJobFinish) {
66
+ this.ExecuteTask_AllFinish(project, task);
67
+ }
68
+ };
146
69
  ExecuteTask_Cronjob(project, task, taskCount) {
147
70
  let ns = this.get_idle_open();
148
71
  let allJobFinish = false;
@@ -183,7 +106,6 @@ class ExecuteManager_Runner extends feedback_1.ExecuteManager_Feedback {
183
106
  return allJobFinish;
184
107
  }
185
108
  ExecuteTask_Single(project, task, taskCount) {
186
- var _a, _b;
187
109
  let allJobFinish = false;
188
110
  let ns = [];
189
111
  if (this.current_job.length > 0) {
@@ -204,8 +126,8 @@ class ExecuteManager_Runner extends feedback_1.ExecuteManager_Feedback {
204
126
  this.sync_local_para(this.localPara);
205
127
  ns = this.get_idle();
206
128
  if (ns.length > 0) {
207
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskStart([task, taskCount]);
208
- (_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeSubtaskStart([task, 0, ns[0].uuid]);
129
+ this.proxy?.executeTaskStart([task, taskCount]);
130
+ this.proxy?.executeSubtaskStart([task, 0, ns[0].uuid]);
209
131
  }
210
132
  }
211
133
  if (ns.length > 0 && ns[0].websocket.readyState == 1 && this.check_socket_state(ns[0]) != interface_1.ExecuteState.RUNNING) {
@@ -255,8 +177,7 @@ class ExecuteManager_Runner extends feedback_1.ExecuteManager_Feedback {
255
177
  return allJobFinish;
256
178
  }
257
179
  ExecuteTask_AllFinish(project, task) {
258
- var _a;
259
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskFinish(task);
180
+ this.proxy?.executeTaskFinish(task);
260
181
  this.messager_log(`[Execute] Task Finish ${task.uuid}`);
261
182
  const index = project.task.findIndex(x => x.uuid == task.uuid);
262
183
  if (index == project.task.length - 1) {
@@ -270,5 +191,74 @@ class ExecuteManager_Runner extends feedback_1.ExecuteManager_Feedback {
270
191
  this.current_job = [];
271
192
  this.current_cron = [];
272
193
  }
194
+ ExecuteCronTask = (project, task, work, ns) => {
195
+ if (ns.current_job.length < this.current_multithread) {
196
+ const rindex = work.work.findIndex(x => x.state == interface_1.ExecuteState.RUNNING);
197
+ if (rindex != -1)
198
+ return;
199
+ const index = work.work.findIndex(x => x.state == interface_1.ExecuteState.NONE);
200
+ if (index == 0)
201
+ this.proxy?.executeSubtaskStart([task, work.id, ns.uuid]);
202
+ if (index == -1)
203
+ return;
204
+ work.work[index].state = interface_1.ExecuteState.RUNNING;
205
+ try {
206
+ const job = JSON.parse(JSON.stringify(task.jobs[index]));
207
+ job.index = work.id;
208
+ job.runtime_uuid = work.work[index].runtime;
209
+ this.ExecuteJob(project, task, job, ns, true);
210
+ }
211
+ catch (err) {
212
+ this.messager_log(`[ExecuteCronTask Error] UUID: ${task.uuid}, Job count: ${task.jobs.length}, index: ${index}`);
213
+ }
214
+ }
215
+ };
216
+ ExecuteJob = (project, task, job, wss, iscron) => {
217
+ const n = job.index;
218
+ this.messager_log(`[Execute] Job Start ${n} ${job.uuid} ${wss.uuid}`);
219
+ this.proxy?.executeJobStart([job, n, wss.uuid]);
220
+ ExecuteManager_Runner.string_args_transform(task, job, this.messager_log, this.localPara, n);
221
+ const h = {
222
+ name: 'execute_job',
223
+ channel: this.uuid,
224
+ data: job
225
+ };
226
+ wss.current_job.push(job.runtime_uuid);
227
+ const stringdata = JSON.stringify(h);
228
+ wss.websocket.send(stringdata);
229
+ this.jobstack = this.jobstack + 1;
230
+ };
231
+ SyncDatabase = (p) => {
232
+ this.localPara = JSON.parse(JSON.stringify(p.database));
233
+ this.messager_log("[Execute] Sync Database !");
234
+ this.messager_log("[Execute] Generate local database object");
235
+ for (let i = 0; i < this.localPara.containers.length; i++) {
236
+ if (this.localPara.containers[i].type == interface_1.DataType.Expression && this.localPara.containers[i].meta != undefined) {
237
+ const text = `%{${this.localPara.containers[i].meta}}%`;
238
+ const e = new util_parser_1.Util_Parser([...util_parser_1.Util_Parser.to_keyvalue(this.localPara)]);
239
+ this.localPara.containers[i].value = e.replacePara(text);
240
+ }
241
+ }
242
+ this.sync_local_para(this.localPara);
243
+ };
244
+ Init_CronContainer = (task, taskCount) => {
245
+ this.sync_local_para(this.localPara);
246
+ this.current_cron = [];
247
+ for (let i = 0; i < taskCount; i++) {
248
+ const d = {
249
+ id: i,
250
+ uuid: "",
251
+ work: task.jobs.map(x => ({
252
+ uuid: x.uuid,
253
+ runtime: '',
254
+ state: interface_1.ExecuteState.NONE,
255
+ job: x
256
+ }))
257
+ };
258
+ d.work.forEach((x, j) => x.runtime = (0, uuid_1.v6)({}, undefined, i * taskCount + j));
259
+ this.current_cron.push(d);
260
+ }
261
+ this.proxy?.executeTaskStart([task, taskCount]);
262
+ };
273
263
  }
274
264
  exports.ExecuteManager_Runner = ExecuteManager_Runner;
@@ -0,0 +1,14 @@
1
+ import { KeyValue, Database, DatabaseContainer } from "../../interface";
2
+ export declare class Util_Parser {
3
+ paras: Array<KeyValue>;
4
+ get count(): number;
5
+ constructor(_paras: Array<KeyValue>);
6
+ clone: () => Util_Parser;
7
+ static to_keyvalue: (p: Database) => Array<KeyValue>;
8
+ private static getDeepKeys;
9
+ static _to_keyvalue: (p: Array<DatabaseContainer>) => Array<KeyValue>;
10
+ static replaceAll: (str: string, fi: string, tar: string) => string;
11
+ replacePara: (text: string) => string;
12
+ parse: (str: string) => string;
13
+ private _replacePara;
14
+ }
@@ -1,137 +1,135 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.Util_Parser = void 0;
5
4
  const expressionparser_1 = require("expressionparser");
6
5
  const interface_1 = require("../../interface");
7
6
  class Util_Parser {
7
+ paras = [];
8
8
  get count() {
9
9
  return this.paras.length;
10
10
  }
11
11
  constructor(_paras) {
12
- this.paras = [];
13
- this.clone = () => {
14
- const b = JSON.parse(JSON.stringify(this.paras));
15
- return new _a(b);
16
- };
17
- this.replacePara = (text) => {
18
- let buffer = '';
19
- let store = '';
20
- let state = false;
21
- let ignore = -1;
22
- let useExp = false;
23
- for (const v of text) {
24
- if (v == interface_1.IGNORE_CHARACTER && ignore == -1)
25
- ignore = 0;
26
- else if (ignore == 0)
27
- ignore = 1;
28
- else if (ignore == 1)
29
- ignore = 2;
30
- else if (ignore == 2)
31
- ignore = -1;
32
- if (v == interface_1.ENV_CHARACTER && ignore == -1) {
33
- state = !state;
34
- if (!state) {
35
- if (useExp) {
36
- buffer += this.parse(store);
37
- }
38
- else {
39
- buffer += this._replacePara(store);
40
- }
41
- store = "";
42
- useExp = false;
12
+ this.paras = _paras;
13
+ }
14
+ clone = () => {
15
+ const b = JSON.parse(JSON.stringify(this.paras));
16
+ return new Util_Parser(b);
17
+ };
18
+ static to_keyvalue = (p) => {
19
+ return [
20
+ ...this._to_keyvalue(p.containers)
21
+ ];
22
+ };
23
+ static getDeepKeys = (obj, name) => {
24
+ let keys = [];
25
+ for (var key in obj) {
26
+ keys.push([name ? name + "." + key : key, obj[key]]);
27
+ if (typeof obj[key] === "object") {
28
+ if (Array.isArray(obj[key])) {
29
+ if (typeof obj[key]['length'] === 'number') {
30
+ keys.push([name ? name + "." + key + ".length" : key + ".length", obj[key]['length']]);
43
31
  }
44
32
  }
45
- if (v == '{' && state && store.length == 0)
46
- useExp = true;
47
- if (state && v != interface_1.ENV_CHARACTER && (ignore != 0))
48
- store += v;
49
- if (!state && v != interface_1.ENV_CHARACTER && (ignore != 0))
50
- buffer += (ignore > 0 ? (interface_1.ENV_CHARACTER + v) : v);
33
+ var subkeys = this.getDeepKeys(obj[key]);
34
+ keys = keys.concat(subkeys.map(function (subkey) {
35
+ return [name ? name + "." + key + "." + subkey[0] : key + "." + subkey[0], subkey[1]];
36
+ }));
51
37
  }
52
- return buffer;
53
- };
54
- this.parse = (str) => {
55
- str = str.substring(1, str.length - 1);
56
- const parser = (0, expressionparser_1.init)(expressionparser_1.formula, (term) => {
57
- if (term.includes("_ck_")) {
58
- const index = this.paras.findIndex(x => x.key == "ck");
59
- if (index != -1)
60
- term = _a.replaceAll(term, "_ck_", this.paras[index].value);
61
- }
62
- const index = this.paras.findIndex(x => x.key == term);
63
- if (index != -1) {
64
- const n = Number(this.paras[index].value);
65
- if (Number.isNaN(n))
66
- return this.paras[index].value;
67
- return n;
68
- }
69
- else
70
- return 0;
71
- });
72
- const r = parser.expressionToValue(str).toString();
73
- return r;
74
- };
75
- this._replacePara = (store) => {
76
- const index = this.paras.findIndex(x => x.key == store);
77
- if (index == -1)
78
- return `%${store}%`;
79
- return this.paras[index].value;
80
- };
81
- this.paras = _paras;
82
- }
83
- }
84
- exports.Util_Parser = Util_Parser;
85
- _a = Util_Parser;
86
- Util_Parser.to_keyvalue = (p) => {
87
- return [
88
- ..._a._to_keyvalue(p.containers)
89
- ];
90
- };
91
- Util_Parser.getDeepKeys = (obj, name) => {
92
- let keys = [];
93
- for (var key in obj) {
94
- keys.push([name ? name + "." + key : key, obj[key]]);
95
- if (typeof obj[key] === "object") {
96
- if (Array.isArray(obj[key])) {
97
- if (typeof obj[key]['length'] === 'number') {
98
- keys.push([name ? name + "." + key + ".length" : key + ".length", obj[key]['length']]);
38
+ }
39
+ return keys;
40
+ };
41
+ static _to_keyvalue = (p) => {
42
+ const r = [];
43
+ r.push(...p.filter(x => x.type == interface_1.DataType.Boolean || x.type == interface_1.DataType.String || x.type == interface_1.DataType.Textarea || x.type == interface_1.DataType.Number || x.type == interface_1.DataType.Expression).map(x => { return { key: x.name, value: x.value.toString() }; }));
44
+ const objs = p.filter(x => x.type == interface_1.DataType.Object);
45
+ const lists = p.filter(x => x.type == interface_1.DataType.List);
46
+ const selects = p.filter(x => x.type == interface_1.DataType.Select);
47
+ for (const obj of objs) {
48
+ const v = obj.value;
49
+ const keys = this.getDeepKeys(v, obj.name);
50
+ r.push(...keys.map(x => { return { key: x[0], value: x[1].toString() }; }));
51
+ }
52
+ for (const list of lists) {
53
+ const a = list.value;
54
+ r.push(...a.map((x, index) => { return { key: list.name + "." + String(index), value: x }; }));
55
+ r.push({ key: list.name + ".length", value: a.length });
56
+ }
57
+ for (const select of selects) {
58
+ const a = select.meta;
59
+ const target = a[select.value];
60
+ r.push({ key: select.name, value: target });
61
+ }
62
+ return r;
63
+ };
64
+ static replaceAll = (str, fi, tar) => {
65
+ let p = str;
66
+ while (p.includes(fi))
67
+ p = p.replace(fi, tar);
68
+ return p;
69
+ };
70
+ replacePara = (text) => {
71
+ let buffer = '';
72
+ let store = '';
73
+ let state = false;
74
+ let ignore = -1;
75
+ let useExp = false;
76
+ for (const v of text) {
77
+ if (v == interface_1.IGNORE_CHARACTER && ignore == -1)
78
+ ignore = 0;
79
+ else if (ignore == 0)
80
+ ignore = 1;
81
+ else if (ignore == 1)
82
+ ignore = 2;
83
+ else if (ignore == 2)
84
+ ignore = -1;
85
+ if (v == interface_1.ENV_CHARACTER && ignore == -1) {
86
+ state = !state;
87
+ if (!state) {
88
+ if (useExp) {
89
+ buffer += this.parse(store);
90
+ }
91
+ else {
92
+ buffer += this._replacePara(store);
93
+ }
94
+ store = "";
95
+ useExp = false;
99
96
  }
100
97
  }
101
- var subkeys = _a.getDeepKeys(obj[key]);
102
- keys = keys.concat(subkeys.map(function (subkey) {
103
- return [name ? name + "." + key + "." + subkey[0] : key + "." + subkey[0], subkey[1]];
104
- }));
98
+ if (v == '{' && state && store.length == 0)
99
+ useExp = true;
100
+ if (state && v != interface_1.ENV_CHARACTER && (ignore != 0))
101
+ store += v;
102
+ if (!state && v != interface_1.ENV_CHARACTER && (ignore != 0))
103
+ buffer += (ignore > 0 ? (interface_1.ENV_CHARACTER + v) : v);
105
104
  }
106
- }
107
- return keys;
108
- };
109
- Util_Parser._to_keyvalue = (p) => {
110
- const r = [];
111
- r.push(...p.filter(x => x.type == interface_1.DataType.Boolean || x.type == interface_1.DataType.String || x.type == interface_1.DataType.Textarea || x.type == interface_1.DataType.Number || x.type == interface_1.DataType.Expression).map(x => { return { key: x.name, value: x.value.toString() }; }));
112
- const objs = p.filter(x => x.type == interface_1.DataType.Object);
113
- const lists = p.filter(x => x.type == interface_1.DataType.List);
114
- const selects = p.filter(x => x.type == interface_1.DataType.Select);
115
- for (const obj of objs) {
116
- const v = obj.value;
117
- const keys = _a.getDeepKeys(v, obj.name);
118
- r.push(...keys.map(x => { return { key: x[0], value: x[1].toString() }; }));
119
- }
120
- for (const list of lists) {
121
- const a = list.value;
122
- r.push(...a.map((x, index) => { return { key: list.name + "." + String(index), value: x }; }));
123
- r.push({ key: list.name + ".length", value: a.length });
124
- }
125
- for (const select of selects) {
126
- const a = select.meta;
127
- const target = a[select.value];
128
- r.push({ key: select.name, value: target });
129
- }
130
- return r;
131
- };
132
- Util_Parser.replaceAll = (str, fi, tar) => {
133
- let p = str;
134
- while (p.includes(fi))
135
- p = p.replace(fi, tar);
136
- return p;
137
- };
105
+ return buffer;
106
+ };
107
+ parse = (str) => {
108
+ str = str.substring(1, str.length - 1);
109
+ const parser = (0, expressionparser_1.init)(expressionparser_1.formula, (term) => {
110
+ if (term.includes("_ck_")) {
111
+ const index = this.paras.findIndex(x => x.key == "ck");
112
+ if (index != -1)
113
+ term = Util_Parser.replaceAll(term, "_ck_", this.paras[index].value);
114
+ }
115
+ const index = this.paras.findIndex(x => x.key == term);
116
+ if (index != -1) {
117
+ const n = Number(this.paras[index].value);
118
+ if (Number.isNaN(n))
119
+ return this.paras[index].value;
120
+ return n;
121
+ }
122
+ else
123
+ return 0;
124
+ });
125
+ const r = parser.expressionToValue(str).toString();
126
+ return r;
127
+ };
128
+ _replacePara = (store) => {
129
+ const index = this.paras.findIndex(x => x.key == store);
130
+ if (index == -1)
131
+ return `%${store}%`;
132
+ return this.paras[index].value;
133
+ };
134
+ }
135
+ exports.Util_Parser = Util_Parser;
@@ -0,0 +1,25 @@
1
+ import { Libraries, WebsocketPack } from "../interface";
2
+ import { ExecuteManager_Runner } from "./execute/runner";
3
+ export declare class ExecuteManager extends ExecuteManager_Runner {
4
+ Update: () => void;
5
+ Stop: () => void;
6
+ Register: (lib?: Libraries) => number;
7
+ Clean: () => void;
8
+ Release: () => void;
9
+ NewConnection: (source: WebsocketPack) => void;
10
+ Disconnect: (source: WebsocketPack) => void;
11
+ ClearState: (task_index: number) => void;
12
+ SkipProject: () => number;
13
+ PreviousProject: () => number;
14
+ SkipTask: () => number;
15
+ PreviousTask: () => number;
16
+ SkipSubTask: (v: number) => number;
17
+ private jumpProject;
18
+ private jumpTask;
19
+ private skipProjectFirst;
20
+ private _jumpProject;
21
+ private skipTaskFirst;
22
+ private previousTaskFirst;
23
+ private skipTask;
24
+ private previousTask;
25
+ }