verteilen-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/bun.lock +730 -0
- package/index.ts +1 -0
- package/jest.config.js +8 -0
- package/package.json +42 -0
- package/src/client/analysis.ts +377 -0
- package/src/client/client.ts +230 -0
- package/src/client/cluster.ts +125 -0
- package/src/client/execute.ts +210 -0
- package/src/client/http.ts +45 -0
- package/src/client/javascript.ts +535 -0
- package/src/client/job_execute.ts +216 -0
- package/src/client/job_parameter.ts +41 -0
- package/src/client/os.ts +210 -0
- package/src/client/parameter.ts +58 -0
- package/src/client/resource.ts +121 -0
- package/src/client/shell.ts +147 -0
- package/src/interface/base.ts +82 -0
- package/src/interface/bus.ts +144 -0
- package/src/interface/enum.ts +181 -0
- package/src/interface/execute.ts +47 -0
- package/src/interface/record.ts +131 -0
- package/src/interface/server.ts +91 -0
- package/src/interface/struct.ts +292 -0
- package/src/interface/table.ts +34 -0
- package/src/interface/ui.ts +35 -0
- package/src/interface.ts +50 -0
- package/src/lan/en.json +395 -0
- package/src/lan/zh_TW.json +395 -0
- package/src/plugins/i18n.ts +20 -0
- package/src/script/console_manager.ts +135 -0
- package/src/script/console_server_manager.ts +46 -0
- package/src/script/execute/base.ts +309 -0
- package/src/script/execute/feedback.ts +212 -0
- package/src/script/execute/region_job.ts +14 -0
- package/src/script/execute/region_project.ts +23 -0
- package/src/script/execute/region_subtask.ts +14 -0
- package/src/script/execute/region_task.ts +23 -0
- package/src/script/execute/runner.ts +339 -0
- package/src/script/execute/util_parser.ts +175 -0
- package/src/script/execute_manager.ts +348 -0
- package/src/script/socket_manager.ts +329 -0
- package/src/script/webhook_manager.ts +6 -0
- package/src/script/webhook_server_manager.ts +102 -0
- package/src/util/server/console_handle.ts +248 -0
- package/src/util/server/log_handle.ts +194 -0
- package/test/TEST.ts +63 -0
- package/test/client/execute.test.ts +54 -0
- package/test/client/javascript.test.ts +78 -0
- package/test/client/server.test.ts +26 -0
- package/test/client/task.test.ts +136 -0
- package/test/script/parser.test.ts +110 -0
- package/test/script/socket.test.ts +27 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
{
|
|
2
|
+
"login": {
|
|
3
|
+
"title": "帳號登入",
|
|
4
|
+
"submit": "登入",
|
|
5
|
+
"account": "帳號",
|
|
6
|
+
"password": "密碼"
|
|
7
|
+
},
|
|
8
|
+
"guides": {
|
|
9
|
+
"workflow": "工作流程",
|
|
10
|
+
"core": "核心運作",
|
|
11
|
+
"ui": "UI 結構",
|
|
12
|
+
"project": "專案容器",
|
|
13
|
+
"task": "流程容器",
|
|
14
|
+
"job": "工作容器",
|
|
15
|
+
"parameter": "數據綁定",
|
|
16
|
+
"console": "控制台"
|
|
17
|
+
},
|
|
18
|
+
"profile": {
|
|
19
|
+
"username": "用戶名",
|
|
20
|
+
"description": "用戶敘述",
|
|
21
|
+
"admin": "是否管理員"
|
|
22
|
+
},
|
|
23
|
+
"menu": {
|
|
24
|
+
"file": "檔案",
|
|
25
|
+
"edit": "編輯",
|
|
26
|
+
"execute": "執行",
|
|
27
|
+
"help": "幫助",
|
|
28
|
+
"new-project": "新專案",
|
|
29
|
+
"import": "匯入",
|
|
30
|
+
"export": "匯出",
|
|
31
|
+
"quit": "退出",
|
|
32
|
+
"undo": "回復",
|
|
33
|
+
"redo": "復原",
|
|
34
|
+
"cut": "剪下",
|
|
35
|
+
"copy": "複製",
|
|
36
|
+
"paste": "複製",
|
|
37
|
+
"delete": "刪除",
|
|
38
|
+
"selectAll": "全選",
|
|
39
|
+
"language": "語言",
|
|
40
|
+
"log": "紀錄",
|
|
41
|
+
"font": "字型大小",
|
|
42
|
+
"animation": "動畫"
|
|
43
|
+
},
|
|
44
|
+
"settings": {
|
|
45
|
+
"system": "系統",
|
|
46
|
+
"appearance": "外觀",
|
|
47
|
+
"workflow": "流程"
|
|
48
|
+
},
|
|
49
|
+
"toast": {
|
|
50
|
+
"server": "伺服器模式",
|
|
51
|
+
"node": "節點模式",
|
|
52
|
+
"server_d": "用戶選擇了伺服器模式, 主控台出現後, 控制其他節點進行工作",
|
|
53
|
+
"node_d": "用戶選擇了節點模式, 被動架構的情況下無法做任意事件, 將會等待伺服器連線...",
|
|
54
|
+
"connection-create-title": "連線建立",
|
|
55
|
+
"connection-create-des": "建立新的連線",
|
|
56
|
+
"connection-remove-title": "連線中斷",
|
|
57
|
+
"connection-remove-des": "連線中斷偵測"
|
|
58
|
+
},
|
|
59
|
+
"modeselect": {
|
|
60
|
+
"title": "你擔任的角色",
|
|
61
|
+
"titlebar": "角色選擇"
|
|
62
|
+
},
|
|
63
|
+
"error": {
|
|
64
|
+
"title-needed": "名稱不能為空",
|
|
65
|
+
"title-repeat": "名稱不能重複",
|
|
66
|
+
"url-needed": "URL 不能為空",
|
|
67
|
+
"project-empty": "專案清單不能爲空",
|
|
68
|
+
"parameter-empty": "專案必須綁定參數",
|
|
69
|
+
"node-empty": "節點清單不能爲空"
|
|
70
|
+
},
|
|
71
|
+
"filter": {
|
|
72
|
+
"type": "資料型態",
|
|
73
|
+
"canwrite": "運行讀寫",
|
|
74
|
+
"show-hidden": "隱藏",
|
|
75
|
+
"show-runtime": "唯獨運行"
|
|
76
|
+
},
|
|
77
|
+
"modal": {
|
|
78
|
+
"project-template-select": "樣板選擇",
|
|
79
|
+
"parameter-template-select": "樣板選擇",
|
|
80
|
+
"new-project": "新增專案",
|
|
81
|
+
"modify-project": "編輯專案",
|
|
82
|
+
"delete-project": "刪除專案",
|
|
83
|
+
"import-project": "匯入專案",
|
|
84
|
+
"delete-project-confirm": "確定刪除以下專案嗎?",
|
|
85
|
+
"delete-project-binding": "連同綁定的參數集一起刪除",
|
|
86
|
+
"enter-project-name": "輸入專案名稱",
|
|
87
|
+
"enter-project-description": "輸入專案敘述",
|
|
88
|
+
"new-task": "新增流程",
|
|
89
|
+
"modify-task": "編輯流程",
|
|
90
|
+
"enter-task-name": "輸入流程名稱",
|
|
91
|
+
"enter-task-description": "輸入流程敘述",
|
|
92
|
+
"new-job": "新增工作",
|
|
93
|
+
"new-parameter": "新增參數",
|
|
94
|
+
"edit-parameter": "編輯參數",
|
|
95
|
+
"delete-parameter": "刪除參數",
|
|
96
|
+
"enter-parameter-name": "輸入參數名稱",
|
|
97
|
+
"new-parameter-set": "新增參數組",
|
|
98
|
+
"clone-parameter-set": "複製參數組",
|
|
99
|
+
"edit-parameter-set": "編輯參數組",
|
|
100
|
+
"enter-parameter-set-name": "輸入參數組名稱",
|
|
101
|
+
"import-parameter": "刪除參數",
|
|
102
|
+
"delete-parameter-confirm": "確認刪除選擇參數嗎?",
|
|
103
|
+
"parameter-datatype": "資料型態",
|
|
104
|
+
"create-library": "新增程式庫",
|
|
105
|
+
"enter-library-name": "輸入程式庫名稱",
|
|
106
|
+
"enter-library-type": "輸入程式庫類型",
|
|
107
|
+
"new-node": "新增節點",
|
|
108
|
+
"enter-node-address": "輸入節點位址",
|
|
109
|
+
"skip-step": "跳過步驟",
|
|
110
|
+
"delete-node": "刪除節點",
|
|
111
|
+
"delete-node-confirm": "確定刪除以下節點嗎?",
|
|
112
|
+
"log-recover-project-title": "新專案名稱",
|
|
113
|
+
"log-recover-parameter-title": "新參數名稱",
|
|
114
|
+
"console-create": "建立控制台",
|
|
115
|
+
"console-name": "控制台名稱",
|
|
116
|
+
"delete-library": "刪除程式腳本",
|
|
117
|
+
"delete-library-confirm": "確定刪除選取的程式腳本嗎?",
|
|
118
|
+
"upload-pic": "上傳用戶照片",
|
|
119
|
+
"delete-plugin": "刪除插件",
|
|
120
|
+
"delete-template": "刪除樣板",
|
|
121
|
+
"delete-plugin-confirm": "確定刪除選取的插件嗎?",
|
|
122
|
+
"delete-template-confirm": "確定刪除選取的樣板嗎?",
|
|
123
|
+
"delete-job": "刪除工作",
|
|
124
|
+
"delete-job-confirm": "確定刪除選取的工作嗎?"
|
|
125
|
+
},
|
|
126
|
+
"toolbar": {
|
|
127
|
+
"server": "伺服器",
|
|
128
|
+
"compute": "運算",
|
|
129
|
+
"editor": "編輯器",
|
|
130
|
+
"backend": "後端功能",
|
|
131
|
+
"project": "專案管理 (Q)",
|
|
132
|
+
"task": "流程管理 (W)",
|
|
133
|
+
"job": "工作管理 (E)",
|
|
134
|
+
"parameter": "參數管理 (R)",
|
|
135
|
+
"node": "節點管理 (A)",
|
|
136
|
+
"console": "控制台 (S)",
|
|
137
|
+
"log": "紀錄 (D)",
|
|
138
|
+
"library": "運行庫 (F)",
|
|
139
|
+
"client": "客戶端 (Z)",
|
|
140
|
+
"setting": "設定",
|
|
141
|
+
"role": "權限組 (X)",
|
|
142
|
+
"service": "服務 (C)",
|
|
143
|
+
"plugin": "插件 (G)",
|
|
144
|
+
"profile": "個人資料 (B)"
|
|
145
|
+
},
|
|
146
|
+
"tooltip": {
|
|
147
|
+
"select-server": "作為伺服器下指令的一方",
|
|
148
|
+
"select-node": "作為節點負責運作的一方",
|
|
149
|
+
"select-cluster": "作為中繼節點集和多項子節點",
|
|
150
|
+
"project-id": "專案的 UUID",
|
|
151
|
+
"project-taskCount": "專案下的流程總數",
|
|
152
|
+
"task-id": "流程的 UUID",
|
|
153
|
+
"task-jobCount": "流程下的工作總數",
|
|
154
|
+
"task-cronjob": "用多台電腦執行的任務",
|
|
155
|
+
"task-multi": "單一電腦會使用多核心運算"
|
|
156
|
+
},
|
|
157
|
+
"jobpage": {
|
|
158
|
+
"if-error": "如果出錯",
|
|
159
|
+
"from": "來源",
|
|
160
|
+
"to": "目的",
|
|
161
|
+
"path": "路徑",
|
|
162
|
+
"content": "內容",
|
|
163
|
+
"command": "命令",
|
|
164
|
+
"parameters": "參數值"
|
|
165
|
+
},
|
|
166
|
+
"enum":{
|
|
167
|
+
"jobtype": {
|
|
168
|
+
"copy-file": "複製檔案",
|
|
169
|
+
"copy-dir": "複製資料夾",
|
|
170
|
+
"delete-file": "刪除檔案",
|
|
171
|
+
"delete-dir": "刪除資料夾",
|
|
172
|
+
"create-file": "建立檔案",
|
|
173
|
+
"create-dir": "建立資料夾",
|
|
174
|
+
"rename": "改名",
|
|
175
|
+
"lua": "LUA 腳本",
|
|
176
|
+
"javascript": "Javascript 腳本",
|
|
177
|
+
"command": "指令執行",
|
|
178
|
+
"lib_command": "插件指令執行"
|
|
179
|
+
},
|
|
180
|
+
"jobtype2": {
|
|
181
|
+
"check-path": "檢查路徑",
|
|
182
|
+
"lua": "LUA 腳本",
|
|
183
|
+
"javascript": "Javascript 腳本"
|
|
184
|
+
},
|
|
185
|
+
"jobresult": {
|
|
186
|
+
"none": "無",
|
|
187
|
+
"skip-project": "跳過專案",
|
|
188
|
+
"throw-project": "放棄專案",
|
|
189
|
+
"skip-task": "跳過流程",
|
|
190
|
+
"throw-task": "放棄流程",
|
|
191
|
+
"skip-subtask": "跳過子流程",
|
|
192
|
+
"throw-subtask": "放棄子流程",
|
|
193
|
+
"pause": "暫停"
|
|
194
|
+
},
|
|
195
|
+
"project": {
|
|
196
|
+
"default": "範例",
|
|
197
|
+
"default_short": "短範例",
|
|
198
|
+
"ffmpeg_download": "FFmpeg 下載影片",
|
|
199
|
+
"concat": "FFmpeg 合成影片",
|
|
200
|
+
"blender": "Blender 渲染",
|
|
201
|
+
"blender_cluster": "Blender 群集渲染",
|
|
202
|
+
"aftereffect": "After Effect 渲染"
|
|
203
|
+
},
|
|
204
|
+
"parameter": {
|
|
205
|
+
"default": "Default",
|
|
206
|
+
"ffmpeg": "FFmpeg"
|
|
207
|
+
},
|
|
208
|
+
"state": {
|
|
209
|
+
"none": "準備中",
|
|
210
|
+
"running": "執行中",
|
|
211
|
+
"finish": "完成",
|
|
212
|
+
"error": "錯誤",
|
|
213
|
+
"skip": "跳過"
|
|
214
|
+
},
|
|
215
|
+
"lua": {
|
|
216
|
+
"default": "預設",
|
|
217
|
+
"gs4-sort": "睿智 GS4 資料夾整理 v1"
|
|
218
|
+
},
|
|
219
|
+
"connection": {
|
|
220
|
+
"connecting": "連線中...",
|
|
221
|
+
"connected": "連線",
|
|
222
|
+
"closing": "關閉中...",
|
|
223
|
+
"closed": "關閉"
|
|
224
|
+
},
|
|
225
|
+
"category": {
|
|
226
|
+
"condition": "偵測",
|
|
227
|
+
"execution": "執行"
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
"console": {
|
|
231
|
+
"list": "專案列表",
|
|
232
|
+
"dashboard": "儀錶板",
|
|
233
|
+
"parameter": "參數版"
|
|
234
|
+
},
|
|
235
|
+
"types": {
|
|
236
|
+
"number": "數字",
|
|
237
|
+
"string": "字串",
|
|
238
|
+
"boolean": "布林",
|
|
239
|
+
"expression": "表達式",
|
|
240
|
+
"object": "物件",
|
|
241
|
+
"textarea": "文字",
|
|
242
|
+
"select": "選擇",
|
|
243
|
+
"list": "清單"
|
|
244
|
+
},
|
|
245
|
+
"expression": {
|
|
246
|
+
"title": "標題",
|
|
247
|
+
"value": "表達式",
|
|
248
|
+
"deep": "深度"
|
|
249
|
+
},
|
|
250
|
+
"headers": {
|
|
251
|
+
"title": "名稱",
|
|
252
|
+
"description": "敘述",
|
|
253
|
+
"detail": "動作",
|
|
254
|
+
"type": "種類",
|
|
255
|
+
"multi": "多核心",
|
|
256
|
+
"cronjob": "分散運算",
|
|
257
|
+
"task-count": "流程數",
|
|
258
|
+
"job-count": "工作數"
|
|
259
|
+
},
|
|
260
|
+
"codehint": {
|
|
261
|
+
"v_path": "Path module",
|
|
262
|
+
"v_os": "Operation system action module",
|
|
263
|
+
"v_env": "Environment module",
|
|
264
|
+
"v_message": "Messager module",
|
|
265
|
+
"v_http": "Http module",
|
|
266
|
+
"v_setTimeout": "setTimeout(callback,time:number)\nExecute methoid after #time milliseconds",
|
|
267
|
+
"v_wait": "wait(time:number)=>Promise<void>\nWaiting for #time seconds",
|
|
268
|
+
"v_sleep": "sleep(time:number)\nStop the thread for #time seconds",
|
|
269
|
+
"v_console": "Console Module",
|
|
270
|
+
"v_json": "JSON module",
|
|
271
|
+
"json": {
|
|
272
|
+
"parse": "Convert text to json object",
|
|
273
|
+
"stringify": "Convert json object to text"
|
|
274
|
+
},
|
|
275
|
+
"console": {
|
|
276
|
+
"log": "Print message"
|
|
277
|
+
},
|
|
278
|
+
"path": {
|
|
279
|
+
"filename": "filename(path:string,extension:boolean)=>string\nGet file name\n* path: The path string\n* extension: include the extension string",
|
|
280
|
+
"extname": "extname(path:string)=>string\n",
|
|
281
|
+
"dirname": "dirname(path:string)=>string\n"
|
|
282
|
+
},
|
|
283
|
+
"os": {
|
|
284
|
+
"exec": "exec(command:string,args:string,cwd?:string)",
|
|
285
|
+
"command": "command(command:string,args:string,cwd?:string)=>Promise<void>",
|
|
286
|
+
"plugin_exec": "plugin_exec(command:string,args:string)",
|
|
287
|
+
"plugin_command": "plugin_command(command:string,args:string)=>Promise<void>",
|
|
288
|
+
"copyfile": "copyfile(from:string,to:string)",
|
|
289
|
+
"copydir": "copydir(from:string,to: string)",
|
|
290
|
+
"deletefile": "deletefile(path:string)",
|
|
291
|
+
"deletedir": "deletedir(path:string)",
|
|
292
|
+
"exist": "exist(path:string):boolean",
|
|
293
|
+
"listfile": "listfile(path:string):string[]",
|
|
294
|
+
"listdir": "listdir(path:string):string[]",
|
|
295
|
+
"createdir": "createdir(path:string)",
|
|
296
|
+
"writefile": "writefile(path:string,data:string)",
|
|
297
|
+
"readfile": "readfile(path:string):string",
|
|
298
|
+
"rename": "rename(from:string,to:string)"
|
|
299
|
+
},
|
|
300
|
+
"env": {
|
|
301
|
+
"has": "has(key:string,checker?:DatatypeChecker):boolean",
|
|
302
|
+
"get": "get(key:string,checker?:DatatypeChecker):any",
|
|
303
|
+
"set": "set(key:string,value:any)",
|
|
304
|
+
"hasboolean": "hasboolean(key:string,checker?:DatatypeChecker):boolean",
|
|
305
|
+
"getboolean": "getboolean(key:string):boolean",
|
|
306
|
+
"setboolean": "setboolean(key:string,value:boolean)",
|
|
307
|
+
"hasnumber": "hasnumber(key:string,checker?:DatatypeChecker):boolean",
|
|
308
|
+
"getnumber": "getnumber(key:string):number",
|
|
309
|
+
"setnumber": "setnumber(key:string,value:number)",
|
|
310
|
+
"hasstring": "hasstring(key:string,checker?:DatatypeChecker):boolean",
|
|
311
|
+
"getstring": "getstring(key:string):string",
|
|
312
|
+
"setstring": "setstring(key:string,value:string)",
|
|
313
|
+
"hasobject": "hasobject(key:string,checker?:DatatypeChecker):boolean",
|
|
314
|
+
"getobject": "getobject(key:string):any",
|
|
315
|
+
"setobject": "setobject(key:string,value:any)",
|
|
316
|
+
"haslist": "haslist(key:string,checker?:DatatypeChecker):boolean",
|
|
317
|
+
"getlist": "getlist(key:string):any[]",
|
|
318
|
+
"setlist": "setlist(key:string,value:any[])",
|
|
319
|
+
"hasselect": "hasselect(key:string,checker?:DatatypeChecker):boolean",
|
|
320
|
+
"getselect": "getselect(key:string):string",
|
|
321
|
+
"setselect": "setselect(key:string,value:numer)",
|
|
322
|
+
"getselectlength": "getselect(key:string):number"
|
|
323
|
+
},
|
|
324
|
+
"m": {
|
|
325
|
+
"messager": "messager(message:string)",
|
|
326
|
+
"messager_log": "messager_log(message:string)"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"info": "資訊",
|
|
330
|
+
"search": "搜尋",
|
|
331
|
+
"selectall": "全選",
|
|
332
|
+
"unselectall": "取消全選",
|
|
333
|
+
"project": "專案",
|
|
334
|
+
"task": "流程",
|
|
335
|
+
"job": "工作",
|
|
336
|
+
"parameter": "參數",
|
|
337
|
+
"create": "新增",
|
|
338
|
+
"import-template": "匯入樣板",
|
|
339
|
+
"import-plugin": "匯入插件",
|
|
340
|
+
"import-template-buildin": "匯入內建樣板",
|
|
341
|
+
"import-plugin-buildin": "匯入內建插件",
|
|
342
|
+
"clone": "克隆",
|
|
343
|
+
"delete": "刪除",
|
|
344
|
+
"save": "存檔",
|
|
345
|
+
"server": "伺服器",
|
|
346
|
+
"node": "節點",
|
|
347
|
+
"cluster": "中繼節點",
|
|
348
|
+
"action": "動作",
|
|
349
|
+
"skip": "跳過",
|
|
350
|
+
"property": "屬性",
|
|
351
|
+
"create-property": "新增屬性",
|
|
352
|
+
"check": "查看",
|
|
353
|
+
"edit": "編輯",
|
|
354
|
+
"modify": "修改",
|
|
355
|
+
"moveup": "往上移動",
|
|
356
|
+
"movedown": "往下移動",
|
|
357
|
+
"rename": "改名",
|
|
358
|
+
"execute": "執行",
|
|
359
|
+
"execute-0": "全部",
|
|
360
|
+
"execute-1": "專案",
|
|
361
|
+
"execute-2": "流程",
|
|
362
|
+
"skip-0": "跳過專案",
|
|
363
|
+
"skip-1": "跳過流程",
|
|
364
|
+
"stop": "停下",
|
|
365
|
+
"export": "匯出",
|
|
366
|
+
"import": "匯入",
|
|
367
|
+
"useTemplate": "使用樣板",
|
|
368
|
+
"useExistParameter": "使用參數組",
|
|
369
|
+
"execute-keep": "執行 (保留)",
|
|
370
|
+
"parameter-setting": "參數設定",
|
|
371
|
+
"parameter-select": "參數選擇",
|
|
372
|
+
"is-running": "是否執行中",
|
|
373
|
+
"is-stop": "是否停止",
|
|
374
|
+
"clear": "清除",
|
|
375
|
+
"auto-scroll": "自動滑動",
|
|
376
|
+
"close-all": "全部關閉",
|
|
377
|
+
"clean": "清除",
|
|
378
|
+
"singlejob": "単次運算",
|
|
379
|
+
"cronjob": "分散運算",
|
|
380
|
+
"setupjob": "設置作業",
|
|
381
|
+
"multicore": "多核運算",
|
|
382
|
+
"recover": "恢復",
|
|
383
|
+
"cancel": "取消",
|
|
384
|
+
"step": "步驟",
|
|
385
|
+
"confirm": "確認",
|
|
386
|
+
"close": "關閉",
|
|
387
|
+
"enter": "進入",
|
|
388
|
+
"filters": "篩選",
|
|
389
|
+
"setting": "設定",
|
|
390
|
+
"guide": "指南",
|
|
391
|
+
"plugin": "插件",
|
|
392
|
+
"template": "樣板",
|
|
393
|
+
"loading": "讀取中",
|
|
394
|
+
"relogin": "重新登入"
|
|
395
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ========================
|
|
2
|
+
//
|
|
3
|
+
// Share Codebase
|
|
4
|
+
//
|
|
5
|
+
// ========================
|
|
6
|
+
import { createI18n } from 'vue-i18n'
|
|
7
|
+
import en from './../lan/en.json'
|
|
8
|
+
import zh_TW from './../lan/zh_TW.json'
|
|
9
|
+
|
|
10
|
+
export const i18nData = {
|
|
11
|
+
locale: 'en',
|
|
12
|
+
globalInjection: true,
|
|
13
|
+
fallbackFormat: 'en',
|
|
14
|
+
messages: {
|
|
15
|
+
en: en,
|
|
16
|
+
zh_TW: zh_TW
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const i18n = createI18n(i18nData)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// ========================
|
|
2
|
+
//
|
|
3
|
+
// Share Codebase
|
|
4
|
+
//
|
|
5
|
+
// ========================
|
|
6
|
+
import { BusType, EmitterProxy, Header, RawSend } from "../interface"
|
|
7
|
+
export type Listener = (...args: any[]) => void
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Console helper, web client side handle cluster server connection instance
|
|
11
|
+
*/
|
|
12
|
+
export class ConsoleManager {
|
|
13
|
+
url:string
|
|
14
|
+
ws:WebSocket
|
|
15
|
+
emitter:EmitterProxy<BusType>
|
|
16
|
+
messager_log:Function
|
|
17
|
+
events:Array<[string, Array<Listener>]>
|
|
18
|
+
events_once:Array<[string, Array<Listener>]>
|
|
19
|
+
buffer:Array<Header> = []
|
|
20
|
+
|
|
21
|
+
constructor(_url:string, _messager_log:Function, _emitter:EmitterProxy<BusType>){
|
|
22
|
+
this.messager_log = _messager_log
|
|
23
|
+
this.url = _url
|
|
24
|
+
this.emitter = _emitter
|
|
25
|
+
this.events = []
|
|
26
|
+
this.events_once = []
|
|
27
|
+
this.ws = new WebSocket(this.url)
|
|
28
|
+
this.ws.onerror = (err:any) => {
|
|
29
|
+
this.messager_log(`[Error] Express Connection failed ${this.url}`)
|
|
30
|
+
}
|
|
31
|
+
this.ws.onclose = (ev) => {
|
|
32
|
+
this.messager_log(`[Close] Express Client close, ${ev.code}, ${ev.reason}`)
|
|
33
|
+
this.buffer = []
|
|
34
|
+
}
|
|
35
|
+
this.ws.onopen = () => {
|
|
36
|
+
this.messager_log('[Connection] Express New Connection !')
|
|
37
|
+
for(let i = 0; i < this.buffer.length; i++){
|
|
38
|
+
this.ws.send(JSON.stringify(this.buffer[i]))
|
|
39
|
+
}
|
|
40
|
+
this.buffer = []
|
|
41
|
+
}
|
|
42
|
+
this.ws.onmessage = (ev) => {
|
|
43
|
+
this.received(JSON.parse(ev.data.toString()))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public get connected() : boolean {
|
|
48
|
+
return this.ws.readyState === 1
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
on = (channel: string, listener: Listener) => {
|
|
52
|
+
const index = this.events.findIndex(x => x[0] == channel)
|
|
53
|
+
if(index == -1){
|
|
54
|
+
this.events.push([channel, [listener]])
|
|
55
|
+
}else{
|
|
56
|
+
this.events[index][1].push(listener)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
once = (channel: string, listener: Listener) => {
|
|
61
|
+
const index = this.events.findIndex(x => x[0] == channel)
|
|
62
|
+
if(index == -1){
|
|
63
|
+
this.events_once.push([channel, [listener]])
|
|
64
|
+
}else{
|
|
65
|
+
this.events_once[index][1].push(listener)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
off = (channel: string, listener: Listener) => {
|
|
70
|
+
const index = this.events.findIndex(x => x[0] == channel)
|
|
71
|
+
if(index == -1){
|
|
72
|
+
return
|
|
73
|
+
}else{
|
|
74
|
+
const index2 = this.events[index][1].findIndex(x => x == listener)
|
|
75
|
+
if(index2 != -1) this.events[index][1].splice(index2, 1)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
send = (data:RawSend) => {
|
|
80
|
+
const d:Header = {
|
|
81
|
+
name: data.name,
|
|
82
|
+
token: data.token,
|
|
83
|
+
data: data.data
|
|
84
|
+
}
|
|
85
|
+
if(this.ws.readyState !== WebSocket.OPEN){
|
|
86
|
+
this.buffer.push(d)
|
|
87
|
+
}else{
|
|
88
|
+
this.ws.send(JSON.stringify(d))
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
received = (h:Header) => {
|
|
93
|
+
if (h == undefined){
|
|
94
|
+
this.messager_log('[Source Analysis] Analysis Failed, Value is undefined')
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (h.message != undefined && h.message.length > 0){
|
|
98
|
+
this.messager_log(`[Source Analysis] ${h.message}`)
|
|
99
|
+
}
|
|
100
|
+
if (h.data == undefined) return
|
|
101
|
+
const index = this.events.findIndex(x => x[0] == h.name)
|
|
102
|
+
const index2 = this.events_once.findIndex(x => x[0] == h.name)
|
|
103
|
+
let p = false
|
|
104
|
+
if(index != -1){
|
|
105
|
+
const castingFunc = this.events[index][1]
|
|
106
|
+
castingFunc.forEach(x => {
|
|
107
|
+
if(h.data instanceof Array){
|
|
108
|
+
if(h.data.length == 1) x(h.data[0])
|
|
109
|
+
else x(...h.data)
|
|
110
|
+
}else{
|
|
111
|
+
x(h.data)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
p = true
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if(index2 != -1){
|
|
118
|
+
const castingFunc = this.events_once[index2][1]
|
|
119
|
+
castingFunc.forEach(x => {
|
|
120
|
+
if(h.data instanceof Array){
|
|
121
|
+
if(h.data.length == 1) x(h.data[0])
|
|
122
|
+
else x(...h.data)
|
|
123
|
+
}else{
|
|
124
|
+
x(h.data)
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
this.events_once.splice(index2, 1)
|
|
128
|
+
p = true
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if(!p){
|
|
132
|
+
this.messager_log(`[Source Analysis] Analysis Failed, Unknowed header, name: ${h.name}, meta: ${h.meta}`)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ========================
|
|
2
|
+
//
|
|
3
|
+
// Share Codebase
|
|
4
|
+
//
|
|
5
|
+
// ========================
|
|
6
|
+
import * as ws from 'ws';
|
|
7
|
+
import { Header } from "../interface";
|
|
8
|
+
|
|
9
|
+
type calltype = { [key:string]:Function }
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Console server helper, cluster server side handle web client connection instances
|
|
13
|
+
*/
|
|
14
|
+
export class ConsoleServerManager {
|
|
15
|
+
ws:ws.WebSocket
|
|
16
|
+
typeMap: calltype
|
|
17
|
+
messager_log:Function
|
|
18
|
+
|
|
19
|
+
constructor(_ws:ws.WebSocket, _messager_log:Function, _typeMap: calltype){
|
|
20
|
+
this.messager_log = _messager_log
|
|
21
|
+
this.ws = _ws
|
|
22
|
+
this.typeMap = _typeMap
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Analysis = (h:Header) => {
|
|
26
|
+
if (h == undefined){
|
|
27
|
+
this.messager_log('[Source Analysis] Failed, Get a undefined value')
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (h.message != undefined && h.message.length > 0){
|
|
31
|
+
this.messager_log(`[Source Analysis] ${h.message}`)
|
|
32
|
+
}
|
|
33
|
+
if (h.data == undefined) return
|
|
34
|
+
if(this.typeMap.hasOwnProperty(h.name)){
|
|
35
|
+
const castingFunc = this.typeMap[h.name]
|
|
36
|
+
if(h.data instanceof Array){
|
|
37
|
+
if(h.data.length == 1) castingFunc(this.ws, h.data[0])
|
|
38
|
+
else castingFunc(this.ws, ...h.data)
|
|
39
|
+
}else{
|
|
40
|
+
castingFunc(this.ws, h.data)
|
|
41
|
+
}
|
|
42
|
+
}else{
|
|
43
|
+
this.messager_log(`[Source Analysis] Failed, Unknown, name: ${h.name}, meta: ${h.meta}`)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|