clickgo 3.1.2-dev11 → 3.1.3-dev12

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 (103) hide show
  1. package/dist/app/demo/app.js +0 -73
  2. package/dist/app/demo/config.json +109 -0
  3. package/dist/app/demo/form/control/button/button.js +12 -11
  4. package/dist/app/demo/form/control/button/button.xml +6 -6
  5. package/dist/app/demo/form/control/check/check.js +14 -10
  6. package/dist/app/demo/form/control/file/file.js +15 -13
  7. package/dist/app/demo/form/control/{overflow/overflow.css → flow/flow.css} +0 -0
  8. package/dist/app/demo/form/control/flow/flow.js +64 -0
  9. package/dist/app/demo/form/control/{overflow/overflow.scss → flow/flow.scss} +0 -0
  10. package/dist/app/demo/form/control/flow/flow.xml +101 -0
  11. package/dist/app/demo/form/control/form/form.js +1 -1
  12. package/dist/app/demo/form/control/form/form.xml +3 -3
  13. package/dist/app/demo/form/control/img/img.xml +2 -2
  14. package/dist/app/demo/form/control/list/list.js +95 -75
  15. package/dist/app/demo/form/control/list/list.xml +15 -11
  16. package/dist/app/demo/form/control/marquee/marquee.js +12 -10
  17. package/dist/app/demo/form/control/menu/menu.js +10 -6
  18. package/dist/app/demo/form/control/monaco/monaco.js +50 -60
  19. package/dist/app/demo/form/control/monaco/monaco.xml +6 -5
  20. package/dist/app/demo/form/control/property/property.js +131 -127
  21. package/dist/app/demo/form/control/radio/radio.js +9 -5
  22. package/dist/app/demo/form/control/scroll/scroll.js +16 -12
  23. package/dist/app/demo/form/control/scroll/scroll.xml +10 -10
  24. package/dist/app/demo/form/control/select/select.js +132 -71
  25. package/dist/app/demo/form/control/select/select.xml +69 -67
  26. package/dist/app/demo/form/control/tab/tab.js +21 -20
  27. package/dist/app/demo/form/control/tab/tab.xml +2 -2
  28. package/dist/app/demo/form/control/text/text.js +53 -45
  29. package/dist/app/demo/form/control/text/text.xml +3 -3
  30. package/dist/app/demo/form/control/{greatview/greatview.css → vflow/vflow.css} +0 -0
  31. package/dist/app/demo/form/control/vflow/vflow.js +79 -0
  32. package/dist/app/demo/form/control/{greatview/greatview.scss → vflow/vflow.scss} +0 -0
  33. package/dist/app/demo/form/control/{greatview/greatview.xml → vflow/vflow.xml} +25 -25
  34. package/dist/app/demo/form/event/form/form.js +58 -56
  35. package/dist/app/demo/form/event/form/form.xml +3 -3
  36. package/dist/app/demo/form/event/screen/screen.js +30 -28
  37. package/dist/app/demo/form/event/screen/screen.xml +2 -2
  38. package/dist/app/demo/form/event/task/task.js +31 -31
  39. package/dist/app/demo/form/event/task/task.xml +3 -3
  40. package/dist/app/demo/form/main.js +161 -5
  41. package/dist/app/demo/form/main.xml +36 -35
  42. package/dist/app/demo/form/method/aform/aform.xml +3 -2
  43. package/dist/app/demo/form/method/core/core.js +11 -8
  44. package/dist/app/demo/form/method/core/core.xml +2 -1
  45. package/dist/app/demo/form/method/dom/dom.js +91 -99
  46. package/dist/app/demo/form/method/dom/dom.xml +6 -7
  47. package/dist/app/demo/form/method/form/form.js +8 -8
  48. package/dist/app/demo/form/method/form/form.xml +4 -4
  49. package/dist/app/demo/form/method/fs/fs.js +34 -33
  50. package/dist/app/demo/form/method/fs/fs.xml +1 -1
  51. package/dist/app/demo/form/method/fs/text.js +12 -12
  52. package/dist/app/demo/form/method/native/native.js +50 -0
  53. package/dist/app/demo/form/method/native/native.xml +12 -0
  54. package/dist/app/demo/form/method/system/system.js +50 -0
  55. package/dist/app/demo/form/method/system/system.xml +11 -0
  56. package/dist/app/demo/form/method/task/task.js +59 -61
  57. package/dist/app/demo/form/method/task/task.xml +4 -6
  58. package/dist/app/demo/form/method/theme/theme.js +14 -14
  59. package/dist/app/demo/form/method/tool/tool.js +29 -28
  60. package/dist/app/demo/form/method/tool/tool.xml +3 -3
  61. package/dist/app/demo/form/method/zip/zip.js +46 -41
  62. package/dist/app/demo/form/method/zip/zip.xml +1 -1
  63. package/dist/app/task/app.js +0 -25
  64. package/dist/app/task/config.json +29 -0
  65. package/dist/app/task/form/bar/bar.js +1 -1
  66. package/dist/app/task/form/bar/bar.xml +1 -1
  67. package/dist/clickgo.js +1 -1
  68. package/dist/clickgo.ts +1 -1
  69. package/dist/control/common.cgc +0 -0
  70. package/dist/control/form.cgc +0 -0
  71. package/dist/control/monaco.cgc +0 -0
  72. package/dist/control/property.cgc +0 -0
  73. package/dist/control/task.cgc +0 -0
  74. package/dist/global.css +1 -1
  75. package/dist/index.js +3 -3
  76. package/dist/index.ts +3 -3
  77. package/dist/lib/control.js +70 -104
  78. package/dist/lib/control.ts +97 -123
  79. package/dist/lib/core.js +108 -252
  80. package/dist/lib/core.ts +122 -268
  81. package/dist/lib/dom.js +564 -483
  82. package/dist/lib/dom.ts +703 -546
  83. package/dist/lib/form.js +146 -138
  84. package/dist/lib/form.ts +108 -86
  85. package/dist/lib/fs.js +1 -1
  86. package/dist/lib/fs.ts +1 -1
  87. package/dist/lib/native.js +135 -8
  88. package/dist/lib/native.ts +175 -11
  89. package/dist/lib/task.js +294 -158
  90. package/dist/lib/task.ts +326 -172
  91. package/dist/lib/tool.js +48 -1
  92. package/dist/lib/tool.ts +61 -0
  93. package/dist/lib/zip.ts +2 -0
  94. package/dist/theme/familiar.cgt +0 -0
  95. package/package.json +1 -1
  96. package/types/index.d.ts +23 -24
  97. package/dist/app/demo/form/control/greatview/greatview.js +0 -92
  98. package/dist/app/demo/form/control/overflow/overflow.js +0 -70
  99. package/dist/app/demo/form/control/overflow/overflow.xml +0 -98
  100. package/dist/app/demo/form/control/view/view.css +0 -1
  101. package/dist/app/demo/form/control/view/view.js +0 -73
  102. package/dist/app/demo/form/control/view/view.scss +0 -18
  103. package/dist/app/demo/form/control/view/view.xml +0 -94
@@ -1,32 +1,159 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.size = exports.restore = exports.min = exports.max = exports.invoke = exports.getToken = void 0;
12
+ exports.isMax = exports.ping = exports.size = exports.restore = exports.min = exports.max = exports.invoke = exports.getListenerList = exports.clear = exports.off = exports.once = exports.on = exports.getToken = void 0;
4
13
  const clickgo = require("../clickgo");
5
14
  const token = (Math.random() * 100000000000000 * (100 + Math.round(Math.random() * (999 - 100)))).toString(32);
6
15
  function getToken() {
7
16
  return token;
8
17
  }
9
18
  exports.getToken = getToken;
10
- function invoke(name, ...param) {
11
- if (!clickgo.isNative()) {
19
+ const methods = {};
20
+ window.clickgoNativeWeb = {
21
+ invoke: function (name, ...param) {
22
+ for (const taskId in methods) {
23
+ for (const n in methods[taskId]) {
24
+ if (!n.startsWith(name + '-')) {
25
+ continue;
26
+ }
27
+ methods[taskId][n].handler(...param);
28
+ if (methods[taskId][n].once) {
29
+ delete methods[taskId][n];
30
+ if (!Object.keys(methods[taskId]).length) {
31
+ delete methods[taskId];
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ };
38
+ function on(name, handler, once = false, formId, taskId) {
39
+ if (!taskId) {
12
40
  return;
13
41
  }
14
- return window.clickgoNative.invoke(name, ...param);
42
+ if (!methods[taskId]) {
43
+ methods[taskId] = {};
44
+ }
45
+ methods[taskId][name + '-' + (formId ? formId.toString() : '0')] = {
46
+ 'once': once,
47
+ 'handler': handler
48
+ };
49
+ }
50
+ exports.on = on;
51
+ function once(name, handler, formId, taskId) {
52
+ on(name, handler, true, formId, taskId);
53
+ }
54
+ exports.once = once;
55
+ function off(name, formId, taskId) {
56
+ if (!taskId) {
57
+ return;
58
+ }
59
+ if (!methods[taskId]) {
60
+ return;
61
+ }
62
+ const key = name + '-' + (formId ? formId.toString() : '0');
63
+ if (!methods[taskId][key]) {
64
+ return;
65
+ }
66
+ delete methods[taskId][key];
67
+ }
68
+ exports.off = off;
69
+ function clear(formId, taskId) {
70
+ if (!taskId) {
71
+ return;
72
+ }
73
+ if (!methods[taskId]) {
74
+ return;
75
+ }
76
+ if (!formId) {
77
+ delete methods[taskId];
78
+ return;
79
+ }
80
+ for (const key in methods[taskId]) {
81
+ if (!key.endsWith('-' + formId.toString())) {
82
+ continue;
83
+ }
84
+ delete methods[taskId][key];
85
+ }
86
+ }
87
+ exports.clear = clear;
88
+ function getListenerList(taskId) {
89
+ const rtn = {};
90
+ for (const tid in methods) {
91
+ if (taskId) {
92
+ if (tid !== taskId.toString()) {
93
+ continue;
94
+ }
95
+ }
96
+ rtn[tid] = {};
97
+ for (const key in methods[tid]) {
98
+ const lio = key.lastIndexOf('-');
99
+ const name = key.slice(0, lio);
100
+ const id = key.slice(lio + 1);
101
+ if (!rtn[tid][id]) {
102
+ rtn[tid][id] = {};
103
+ }
104
+ if (rtn[tid][id][name]) {
105
+ ++rtn[tid][id][name];
106
+ }
107
+ else {
108
+ rtn[tid][id][name] = 1;
109
+ }
110
+ }
111
+ }
112
+ return rtn;
113
+ }
114
+ exports.getListenerList = getListenerList;
115
+ function invoke(name, ...param) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ if (!clickgo.isNative()) {
118
+ return;
119
+ }
120
+ return window.clickgoNative.invoke(name, ...param);
121
+ });
15
122
  }
16
123
  exports.invoke = invoke;
17
124
  function max() {
18
- invoke('cg-set-state', token, 'max');
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ yield invoke('cg-set-state', token, 'max');
127
+ });
19
128
  }
20
129
  exports.max = max;
21
130
  function min() {
22
- invoke('cg-set-state', token, 'min');
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ yield invoke('cg-set-state', token, 'min');
133
+ });
23
134
  }
24
135
  exports.min = min;
25
136
  function restore() {
26
- invoke('cg-set-state', token, 'restore');
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ yield invoke('cg-set-state', token, 'restore');
139
+ });
27
140
  }
28
141
  exports.restore = restore;
29
142
  function size(width, height) {
30
- invoke('cg-set-size', token, width, height);
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ yield invoke('cg-set-size', token, width, height);
145
+ });
31
146
  }
32
147
  exports.size = size;
148
+ function ping(val) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ return invoke('cg-ping', val);
151
+ });
152
+ }
153
+ exports.ping = ping;
154
+ function isMax() {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ return invoke('cg-is-max');
157
+ });
158
+ }
159
+ exports.isMax = isMax;
@@ -23,32 +23,196 @@ export function getToken(): string {
23
23
  return token;
24
24
  }
25
25
 
26
+ // ---------------------------
27
+ // --- 供 native 调用的部分 ---
28
+ // ---------------------------
29
+
30
+ /** --- 用户添加的监听 --- */
31
+ const methods: Record<string,
32
+ Record<string, {
33
+ 'once': boolean;
34
+ 'handler': (...param: any[]) => any | Promise<any>;
35
+ }>
36
+ > = {
37
+
38
+ };
39
+
40
+ // --- 供 native 调用的 web 上的对象 ---
41
+ (window as any).clickgoNativeWeb = {
42
+ invoke: function(name: string, ...param: any[]) {
43
+ for (const taskId in methods) {
44
+ for (const n in methods[taskId]) {
45
+ if (!n.startsWith(name + '-')) {
46
+ continue;
47
+ }
48
+ methods[taskId][n].handler(...param);
49
+ if (methods[taskId][n].once) {
50
+ delete methods[taskId][n];
51
+ if (!Object.keys(methods[taskId]).length) {
52
+ delete methods[taskId];
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ };
59
+
60
+ /**
61
+ * --- 监听 native 传输过来的事件 ---
62
+ * @param name 事件名
63
+ * @param handler 回调函数
64
+ * @param once 是否只监听一次
65
+ * @param formId 限定某个窗体
66
+ * @param taskId 绑定到任务,App 模式下无效
67
+ */
68
+ export function on(
69
+ name: string,
70
+ handler: (...param: any[]) => any | Promise<any>,
71
+ once: boolean = false,
72
+ formId?: number,
73
+ taskId?: number
74
+ ): void {
75
+ if (!taskId) {
76
+ return;
77
+ }
78
+ if (!methods[taskId]) {
79
+ methods[taskId] = {};
80
+ }
81
+ methods[taskId][name + '-' + (formId ? formId.toString() : '0')] = {
82
+ 'once': once,
83
+ 'handler': handler
84
+ };
85
+ }
86
+
87
+ /**
88
+ * --- 监听 native 传输过来的事件(仅一次) ---
89
+ */
90
+ export function once(
91
+ name: string,
92
+ handler: (...param: any[]) => any | Promise<any>,
93
+ formId?: number,
94
+ taskId?: number
95
+ ): void {
96
+ on(name, handler, true, formId, taskId);
97
+ }
98
+
99
+ /**
100
+ * --- 解绑监听的方法 ---
101
+ * @param name 方法名
102
+ * @param formId 要清除的窗体的 ID
103
+ * @param taskId 所属的任务 ID,App 模式下无效
104
+ */
105
+ export function off(name: string, formId?: number, taskId?: number): void {
106
+ if (!taskId) {
107
+ return;
108
+ }
109
+ if (!methods[taskId]) {
110
+ return;
111
+ }
112
+ const key = name + '-' + (formId ? formId.toString() : '0');
113
+ if (!methods[taskId][key]) {
114
+ return;
115
+ }
116
+ delete methods[taskId][key];
117
+ }
118
+
119
+ /**
120
+ * --- 清除某个窗体或某个任务的所有事件监听 ---
121
+ * @param formId 窗体 ID,留空为清除任务的所有事件
122
+ * @param taskId 要清楚的任务 ID,App 模式下无效
123
+ */
124
+ export function clear(formId?: number, taskId?: number): void {
125
+ if (!taskId) {
126
+ return;
127
+ }
128
+ if (!methods[taskId]) {
129
+ return;
130
+ }
131
+ if (!formId) {
132
+ delete methods[taskId];
133
+ return;
134
+ }
135
+ for (const key in methods[taskId]) {
136
+ if (!key.endsWith('-' + formId.toString())) {
137
+ continue;
138
+ }
139
+ delete methods[taskId][key];
140
+ }
141
+ }
142
+
143
+ /**
144
+ * --- 获取监听 native 事件的监听统计信息列表 ---
145
+ * @param taskId 为 0 或 undefined 则返回所有
146
+ */
147
+ export function getListenerList(taskId?: number): Record<string, Record<string, Record<string, number>>> {
148
+ const rtn: Record<string,
149
+ Record<string, Record<string, number>>
150
+ > = {};
151
+ for (const tid in methods) {
152
+ if (taskId) {
153
+ if (tid !== taskId.toString()) {
154
+ continue;
155
+ }
156
+ }
157
+ rtn[tid] = {};
158
+ for (const key in methods[tid]) {
159
+ const lio = key.lastIndexOf('-');
160
+ const name = key.slice(0, lio);
161
+ const id = key.slice(lio + 1);
162
+ if (!rtn[tid][id]) {
163
+ rtn[tid][id] = {};
164
+ }
165
+ if (rtn[tid][id][name]) {
166
+ ++rtn[tid][id][name];
167
+ }
168
+ else {
169
+ rtn[tid][id][name] = 1;
170
+ }
171
+ }
172
+ }
173
+ return rtn;
174
+ }
175
+
176
+ // ---------------------------
177
+ // --- 向 native 发送的部分 ---
178
+ // ---------------------------
179
+
26
180
  /**
27
181
  * --- 向 native 发送指令 ---
28
182
  * @param name 指令名
29
183
  * @param param 参数
30
184
  */
31
- export function invoke(name: string, ...param: any[]): any {
185
+ export async function invoke(name: string, ...param: any[]): Promise<any> {
32
186
  if (!clickgo.isNative()) {
33
187
  return;
34
188
  }
35
- return (window as any).clickgoNative.invoke(name, ...param);
189
+ return (window as any).clickgoNative.invoke(name, ...param) as Promise<any>;
190
+ }
191
+
192
+ // --- 常见向 native 发送的操作 ---
193
+
194
+ export async function max(): Promise<void> {
195
+ await invoke('cg-set-state', token, 'max');
36
196
  }
37
197
 
38
- // --- 常见操作 ---
198
+ export async function min(): Promise<void> {
199
+ await invoke('cg-set-state', token, 'min');
200
+ }
39
201
 
40
- export function max(): void {
41
- invoke('cg-set-state', token, 'max');
202
+ export async function restore(): Promise<void> {
203
+ await invoke('cg-set-state', token, 'restore');
42
204
  }
43
205
 
44
- export function min(): void {
45
- invoke('cg-set-state', token, 'min');
206
+ export async function size(width: number, height: number): Promise<void> {
207
+ await invoke('cg-set-size', token, width, height);
46
208
  }
47
209
 
48
- export function restore(): void {
49
- invoke('cg-set-state', token, 'restore');
210
+ // --- 以下无需 token ---
211
+
212
+ export async function ping(val: string): Promise<string> {
213
+ return invoke('cg-ping', val);
50
214
  }
51
215
 
52
- export function size(width: number, height: number): void {
53
- invoke('cg-set-size', token, width, height);
216
+ export async function isMax(): Promise<boolean> {
217
+ return invoke('cg-is-max');
54
218
  }