@lcap/nasl 2.13.0-beta.1 → 2.13.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.
Files changed (129) hide show
  1. package/out/bak/translator.js +1 -6
  2. package/out/bak/translator.js.map +1 -1
  3. package/out/common/BaseNode.js +1 -1
  4. package/out/common/BaseNode.js.map +1 -1
  5. package/out/concepts/BindAttribute__.d.ts +65 -12
  6. package/out/concepts/BindAttribute__.js +78 -10
  7. package/out/concepts/BindAttribute__.js.map +1 -1
  8. package/out/concepts/BindDirective__.d.ts +55 -0
  9. package/out/concepts/BindDirective__.js +69 -0
  10. package/out/concepts/BindDirective__.js.map +1 -1
  11. package/out/concepts/BindEvent__.d.ts +2 -94
  12. package/out/concepts/BindEvent__.js +55 -347
  13. package/out/concepts/BindEvent__.js.map +1 -1
  14. package/out/concepts/CallQueryComponent__.d.ts +102 -26
  15. package/out/concepts/CallQueryComponent__.js +104 -28
  16. package/out/concepts/CallQueryComponent__.js.map +1 -1
  17. package/out/concepts/CompletionProperty__.d.ts +1 -0
  18. package/out/concepts/CompletionProperty__.js +1 -0
  19. package/out/concepts/CompletionProperty__.js.map +1 -1
  20. package/out/concepts/DataSource__.js +1 -0
  21. package/out/concepts/DataSource__.js.map +1 -1
  22. package/out/concepts/Destination__.d.ts +1 -0
  23. package/out/concepts/Destination__.js +10 -1
  24. package/out/concepts/Destination__.js.map +1 -1
  25. package/out/concepts/Entity__.js +1 -0
  26. package/out/concepts/Entity__.js.map +1 -1
  27. package/out/concepts/Enum__.js +1 -0
  28. package/out/concepts/Enum__.js.map +1 -1
  29. package/out/concepts/Function__.js.map +1 -1
  30. package/out/concepts/Interface__.js +1 -0
  31. package/out/concepts/Interface__.js.map +1 -1
  32. package/out/concepts/Logic__.d.ts +1 -7
  33. package/out/concepts/Logic__.js +11 -76
  34. package/out/concepts/Logic__.js.map +1 -1
  35. package/out/concepts/Param__.d.ts +0 -1
  36. package/out/concepts/Param__.js +0 -6
  37. package/out/concepts/Param__.js.map +1 -1
  38. package/out/concepts/ProcessElement__.d.ts +4 -86
  39. package/out/concepts/ProcessElement__.js +29 -128
  40. package/out/concepts/ProcessElement__.js.map +1 -1
  41. package/out/concepts/Process__.d.ts +0 -93
  42. package/out/concepts/Process__.js +1 -141
  43. package/out/concepts/Process__.js.map +1 -1
  44. package/out/concepts/Role__.js +1 -0
  45. package/out/concepts/Role__.js.map +1 -1
  46. package/out/concepts/Structure__.js +1 -0
  47. package/out/concepts/Structure__.js.map +1 -1
  48. package/out/concepts/ViewElement__.d.ts +8 -0
  49. package/out/concepts/ViewElement__.js +35 -47
  50. package/out/concepts/ViewElement__.js.map +1 -1
  51. package/out/concepts/View__.d.ts +8 -9
  52. package/out/concepts/View__.js +27 -72
  53. package/out/concepts/View__.js.map +1 -1
  54. package/out/concepts/basics/stdlib/nasl.ui.js +0 -4
  55. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  56. package/out/index.d.ts +1 -1
  57. package/out/index.js +3 -1
  58. package/out/index.js.map +1 -1
  59. package/out/server/createUiTs.d.ts +0 -9
  60. package/out/server/createUiTs.js +1 -28
  61. package/out/server/createUiTs.js.map +1 -1
  62. package/out/server/getMemberIdentifier.d.ts +1 -16
  63. package/out/server/getMemberIdentifier.js +29 -94
  64. package/out/server/getMemberIdentifier.js.map +1 -1
  65. package/out/server/getProcesses.d.ts +3 -3
  66. package/out/server/getProcesses.js +27 -28
  67. package/out/server/getProcesses.js.map +1 -1
  68. package/out/server/index.js +0 -3
  69. package/out/server/index.js.map +1 -1
  70. package/out/server/naslServer.d.ts +48 -0
  71. package/out/server/naslServer.js +58 -28
  72. package/out/server/naslServer.js.map +1 -1
  73. package/out/server/translator.js +5 -13
  74. package/out/server/translator.js.map +1 -1
  75. package/out/service/storage/init.d.ts +8 -0
  76. package/out/service/storage/init.js +5 -7
  77. package/out/service/storage/init.js.map +1 -1
  78. package/out/service/storage/service.d.ts +11 -2
  79. package/out/service/storage/service.js +26 -1
  80. package/out/service/storage/service.js.map +1 -1
  81. package/out/templator/genCurdEditMultipleKeyBlock.js +2 -4
  82. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  83. package/out/templator/genCurdMultipleKeyBlock.d.ts +0 -11
  84. package/out/templator/genCurdMultipleKeyBlock.js +19 -29
  85. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  86. package/out/templator/genEditTableBlock.js +30 -2
  87. package/out/templator/genEditTableBlock.js.map +1 -1
  88. package/out/templator/genGridViewBlock.js +15 -1
  89. package/out/templator/genGridViewBlock.js.map +1 -1
  90. package/out/templator/genTableBlock.js +15 -1
  91. package/out/templator/genTableBlock.js.map +1 -1
  92. package/package.json +1 -1
  93. package/src/bak/translator.js +1 -8
  94. package/src/common/BaseNode.ts +1 -1
  95. package/src/concepts/BindAttribute__.ts +147 -30
  96. package/src/concepts/BindDirective__.ts +139 -0
  97. package/src/concepts/BindEvent__.ts +57 -422
  98. package/src/concepts/CallQueryComponent__.ts +253 -56
  99. package/src/concepts/CompletionProperty__.ts +1 -0
  100. package/src/concepts/DataSource__.ts +1 -0
  101. package/src/concepts/Destination__.ts +11 -1
  102. package/src/concepts/Entity__.ts +1 -0
  103. package/src/concepts/Enum__.ts +1 -0
  104. package/src/concepts/Function__.ts +1 -15
  105. package/src/concepts/Interface__.ts +1 -0
  106. package/src/concepts/Logic__.ts +12 -77
  107. package/src/concepts/Param__.ts +0 -6
  108. package/src/concepts/ProcessElement__.ts +33 -225
  109. package/src/concepts/Process__.ts +2 -237
  110. package/src/concepts/Role__.ts +1 -0
  111. package/src/concepts/Structure__.ts +1 -0
  112. package/src/concepts/ViewElement__.ts +37 -67
  113. package/src/concepts/View__.ts +28 -72
  114. package/src/concepts/basics/stdlib/nasl.ui.ts +0 -4
  115. package/src/index.ts +1 -1
  116. package/src/server/createUiTs.ts +2 -26
  117. package/src/server/getMemberIdentifier.ts +28 -88
  118. package/src/server/getProcesses.ts +30 -31
  119. package/src/server/index.ts +0 -4
  120. package/src/server/naslServer.ts +59 -29
  121. package/src/server/translator.ts +6 -13
  122. package/src/service/storage/init.ts +5 -6
  123. package/src/service/storage/service.ts +28 -1
  124. package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -5
  125. package/src/templator/genCurdMultipleKeyBlock.ts +16 -27
  126. package/src/templator/genEditTableBlock.ts +27 -0
  127. package/src/templator/genGridViewBlock.ts +13 -0
  128. package/src/templator/genTableBlock.ts +13 -0
  129. package/src/server/events.yaml +0 -89
@@ -16,7 +16,6 @@ import * as utils from '../utils';
16
16
  import { v4 as uuidv4 } from 'uuid';
17
17
  import BaseNode from '../common/BaseNode';
18
18
  import classMap from '../common/classMap';
19
- import BindEvent from './BindEvent__';
20
19
  import Param from './Param__';
21
20
  import Return from './Return__';
22
21
  import Constant from './Constant__';
@@ -53,12 +52,6 @@ export class Process extends BaseNode {
53
52
  @property()
54
53
  description: string = undefined;
55
54
 
56
- /**
57
- * 元素绑定事件列表
58
- */
59
- @property('BindEvent')
60
- bindEvents: Array<BindEvent> = [];
61
-
62
55
  /**
63
56
  * 输入参数列表
64
57
  */
@@ -157,149 +150,7 @@ export class Process extends BaseNode {
157
150
  });
158
151
  }
159
152
 
160
- getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
161
- const excludedSet = new Set(excludedList);
162
- return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
163
- }
164
- getBindEventUniqueName(name = 'bindEvent1') {
165
- return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
166
- }
167
-
168
- /**
169
- * 插入元素绑定事件
170
- * @internal
171
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
172
- */
173
- _insertBindEventAt(name: string, index: number): BindEvent;
174
-
175
- /**
176
- * 插入元素绑定事件
177
- * @internal
178
- * @param bindEventOptions 元素绑定事件参数
179
- */
180
- _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
181
-
182
- /**
183
- * 插入元素绑定事件
184
- * @internal
185
- * @param bindEvent 已有的元素绑定事件实例
186
- */
187
- _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
188
-
189
- _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
190
- const bindEventOptions: any = {};
191
- const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
192
- let bindEvent: BindEvent;
193
- if (!options) {
194
- bindEvent = BindEvent.from({
195
- ...bindEventOptions,
196
- name: this.getBindEventUniqueName(),
197
- }, this, 'bindEvents');
198
- } else if (typeof options === 'string') {
199
- bindEvent = BindEvent.from({
200
- ...bindEventOptions,
201
- name: options,
202
- }, this, 'bindEvents');
203
- } else if (options instanceof BindEvent) {
204
- options.ensureDelete(); // 同一实例不支持多处存在
205
- bindEvent = options;
206
- Object.assign(bindEvent, relationOptions);
207
- } else {
208
- bindEvent = BindEvent.from({
209
- ...bindEventOptions,
210
- ...options,
211
- }, this, 'bindEvents');
212
- }
213
- this.bindEvents.splice(index, 0, bindEvent);
214
- return bindEvent;
215
- }
216
-
217
- /**
218
- * 插入元素绑定事件
219
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
220
- */
221
- insertBindEventAt(name: string, index: number): BindEvent;
222
-
223
- /**
224
- * 插入元素绑定事件
225
- * @param bindEventOptions 元素绑定事件参数
226
- */
227
- insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
228
-
229
- /**
230
- * 插入元素绑定事件
231
- * @param bindEvent 已有的元素绑定事件实例
232
- */
233
- insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
234
-
235
- insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
236
- const node = this._insertBindEventAt(options as any, index);
237
- node.create({
238
- index,
239
- parentNode: this,
240
- parentKey: 'bindEvents',
241
- });
242
- return node;
243
- }
244
-
245
- /**
246
- * 添加元素绑定事件
247
- * @internal
248
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
249
- */
250
- _addBindEvent(name?: string): BindEvent;
251
-
252
- /**
253
- * 添加元素绑定事件
254
- * @internal
255
- * @param bindEventOptions 元素绑定事件参数
256
- */
257
- _addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
258
-
259
- /**
260
- * 添加元素绑定事件
261
- * @internal
262
- * @param bindEvent 已有的元素绑定事件实例
263
- */
264
- _addBindEvent(bindEvent: BindEvent): BindEvent;
265
-
266
- _addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
267
- const index = this.bindEvents.length;
268
- return this._insertBindEventAt(options as any, index);
269
- }
270
-
271
- /**
272
- * 添加元素绑定事件
273
- * @internal
274
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
275
- */
276
- addBindEvent(name?: string): BindEvent;
277
-
278
- /**
279
- * 添加元素绑定事件
280
- * @param bindEventOptions 元素绑定事件参数
281
- */
282
- addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
283
-
284
- /**
285
- * 添加元素绑定事件
286
- * @param bindEvent 已有的元素绑定事件实例
287
- */
288
- addBindEvent(bindEvent: BindEvent): BindEvent;
289
-
290
- addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
291
- const node = this._addBindEvent(options as any);
292
- const index = this.bindEvents.indexOf(node);
293
- node.create({
294
- index,
295
- parentNode: this,
296
- parentKey: 'bindEvents',
297
- });
298
- return node;
299
- }
300
-
301
-
302
- getParamExistingNames(excludedList: Array<Param> = []) {
153
+ getParamExistingNames(excludedList: Array<Param> = []) {
303
154
  const excludedSet = new Set(excludedList);
304
155
  return (this.params || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
305
156
  }
@@ -869,56 +720,6 @@ export class Process extends BaseNode {
869
720
 
870
721
 
871
722
 
872
- /**
873
- * 删除元素绑定事件
874
- * @param name 元素绑定事件名称
875
- */
876
- removeBindEvent(name: string): void;
877
-
878
- /**
879
- * 删除元素绑定事件
880
- * @param bindEvent 已有的元素绑定事件实例
881
- */
882
- removeBindEvent(bindEvent: BindEvent): void;
883
-
884
- removeBindEvent(options: string | BindEvent) {
885
- let bindEvent: BindEvent;
886
- if (typeof options === 'string') {
887
- bindEvent = this.bindEvents.find((item) => item.name === options);
888
- if (!bindEvent) {
889
- throw new Error('找不到元素绑定事件 ' + options);
890
- }
891
- } else {
892
- bindEvent = options;
893
- }
894
- return bindEvent.delete();
895
- }
896
-
897
- __removeBindEvent(bindEvent: BindEvent) {
898
- const parentKey = bindEvent.parentKey;
899
- const params: Params = {
900
- parentNode: this,
901
- parentKey,
902
- index: -1,
903
- object: null,
904
- oldObject: bindEvent,
905
- };
906
- if (parentKey) {
907
- params.parentKey = parentKey;
908
- if (Array.isArray((this as any)[parentKey])) {
909
- const index = (this as any)[parentKey].indexOf(bindEvent);
910
- ~index && (this as any)[parentKey].splice(index, 1);
911
- params.index = index;
912
- } else if ((this as any)[parentKey] === bindEvent) {
913
- params.index = 0;
914
- (this as any)[parentKey] = undefined;
915
- }
916
- }
917
- return params;
918
- }
919
-
920
-
921
-
922
723
  /**
923
724
  * 删除输入参数
924
725
  * @param name 输入参数名称
@@ -1200,34 +1001,6 @@ export class Process extends BaseNode {
1200
1001
  ...logics,
1201
1002
  ];
1202
1003
  }
1203
- /**
1204
- * 获取当前逻辑下所有elements上bindEvents下的logic
1205
- */
1206
- get elementLogicRoot() {
1207
- const logics: Array<Logic> = [];
1208
- // 页面上的绑定的事件
1209
- this.bindEvents.forEach((bindEvent) => {
1210
- bindEvent.logics.forEach((logic) => {
1211
- logics.push(logic);
1212
- });
1213
- });
1214
- this.elements.forEach((item) => {
1215
- if (item.concept === 'ProcessElement' && item.type === 'UserTask') {
1216
- utils.traverse((current) => {
1217
- current.node.bindEvents.forEach((bindEvent) => {
1218
- bindEvent.logics.forEach((logic) => {
1219
- logics.push(logic);
1220
- });
1221
- });
1222
- }, { node: item });
1223
- }
1224
- });
1225
- return [{
1226
- concept: 'elementLogicRoot',
1227
- expanded: false,
1228
- children: logics,
1229
- }];
1230
- }
1231
1004
 
1232
1005
  toUserTaskPropertyGetterTS(userTask: ProcessElement) {
1233
1006
  return `let ${userTask.name} = elements.${userTask.name};`;
@@ -1275,15 +1048,6 @@ export class Process extends BaseNode {
1275
1048
  }
1276
1049
  });
1277
1050
  code += `${tab1}}\n`;
1278
- // 流程逻辑提示错误信息
1279
- if (Array.isArray(this.bindEvents)) {
1280
- this.bindEvents.forEach((event) => {
1281
- code += event.toEmbeddedTS(shiftState(state, code, {
1282
- tabSize: (state?.tabSize || 0),
1283
- }));
1284
- code += '\n';
1285
- });
1286
- }
1287
1051
  code += `}\n`;
1288
1052
  return code;
1289
1053
  }
@@ -1296,6 +1060,7 @@ export class Process extends BaseNode {
1296
1060
  code += this.toEmbeddedTS(state);
1297
1061
  } catch (err) {
1298
1062
  code += '';
1063
+ console.log(err);
1299
1064
  }
1300
1065
  code += '}\n';
1301
1066
 
@@ -145,6 +145,7 @@ export class Role extends BaseNode {
145
145
  code += this.toEmbeddedTS(state);
146
146
  } catch (err) {
147
147
  code += '';
148
+ console.log(err);
148
149
  }
149
150
  code += '}\n';
150
151
 
@@ -587,6 +587,7 @@ export class Structure extends BaseNode {
587
587
  code += this.toEmbeddedTS(state);
588
588
  } catch (err) {
589
589
  code += '';
590
+ console.log(err);
590
591
  }
591
592
  code += '}\n';
592
593
 
@@ -7,7 +7,7 @@ import * as compiler from 'vue-template-compiler';
7
7
 
8
8
  import LogicItem from './LogicItem__';
9
9
 
10
- import { config, Logic } from '..';
10
+ import { config } from '..';
11
11
 
12
12
  export interface ParseContext {
13
13
  [key: string]: any;
@@ -192,6 +192,12 @@ export class ViewElement extends BaseNode {
192
192
  @property()
193
193
  staticStyle: string = undefined;
194
194
 
195
+ /**
196
+ * 权限资源描述
197
+ */
198
+ @property()
199
+ authDescription: string = undefined;
200
+
195
201
  /**
196
202
  * 插槽目标
197
203
  */
@@ -262,8 +268,6 @@ export class ViewElement extends BaseNode {
262
268
  super.subConstructor(source);
263
269
  }
264
270
 
265
-
266
-
267
271
  /**
268
272
  * 从父级删除该节点
269
273
  * @internal
@@ -300,7 +304,19 @@ export class ViewElement extends BaseNode {
300
304
  });
301
305
  }
302
306
 
303
- getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
307
+ /**
308
+ * 设置权限资源描述
309
+ */
310
+ setAuthDescription(authDescription: string) {
311
+ const object = {
312
+ authDescription,
313
+ };
314
+ this.update({
315
+ ...object,
316
+ });
317
+ }
318
+
319
+ getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
304
320
  const excludedSet = new Set(excludedList);
305
321
  return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
306
322
  }
@@ -441,7 +457,6 @@ export class ViewElement extends BaseNode {
441
457
  return node;
442
458
  }
443
459
 
444
-
445
460
  getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
446
461
  const excludedSet = new Set(excludedList);
447
462
  return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -583,7 +598,6 @@ export class ViewElement extends BaseNode {
583
598
  return node;
584
599
  }
585
600
 
586
-
587
601
  getBindDirectiveExistingNames(excludedList: Array<BindDirective> = []) {
588
602
  const excludedSet = new Set(excludedList);
589
603
  return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -725,11 +739,6 @@ export class ViewElement extends BaseNode {
725
739
  return node;
726
740
  }
727
741
 
728
-
729
-
730
-
731
-
732
-
733
742
  /**
734
743
  * 插入页面元素
735
744
  * @internal
@@ -863,9 +872,6 @@ export class ViewElement extends BaseNode {
863
872
  return node;
864
873
  }
865
874
 
866
-
867
-
868
-
869
875
  /**
870
876
  * 删除元素绑定属性
871
877
  * @param name 元素绑定属性名称
@@ -914,8 +920,6 @@ export class ViewElement extends BaseNode {
914
920
  return params;
915
921
  }
916
922
 
917
-
918
-
919
923
  /**
920
924
  * 删除元素绑定事件
921
925
  * @param name 元素绑定事件名称
@@ -964,8 +968,6 @@ export class ViewElement extends BaseNode {
964
968
  return params;
965
969
  }
966
970
 
967
-
968
-
969
971
  /**
970
972
  * 删除元素指令
971
973
  * @param name 元素指令名称
@@ -1014,8 +1016,6 @@ export class ViewElement extends BaseNode {
1014
1016
  return params;
1015
1017
  }
1016
1018
 
1017
-
1018
-
1019
1019
  /**
1020
1020
  * 删除页面元素
1021
1021
  * @param name 页面元素名称
@@ -1227,18 +1227,6 @@ export class ViewElement extends BaseNode {
1227
1227
  code += indent((state?.tabSize || 0) + 2);
1228
1228
  code += '],\n';
1229
1229
  }
1230
- // 绑定属性
1231
- if (Array.isArray(this.bindAttrs)) {
1232
- this.bindAttrs.forEach((attr) => {
1233
- // 跳转页面
1234
- if (attr.destination) {
1235
- code += attr.destination.toEmbeddedTS(shiftState(state, code, {
1236
- tabSize: (state?.tabSize || 0),
1237
- }));
1238
- }
1239
- });
1240
- code += '\n';
1241
- }
1242
1230
 
1243
1231
  // 事件
1244
1232
  if (Array.isArray(this.bindEvents)) {
@@ -1256,38 +1244,16 @@ export class ViewElement extends BaseNode {
1256
1244
 
1257
1245
  if (Array.isArray(this.bindAttrs)) {
1258
1246
  code += `bindAttr: () => [\n`;
1259
- this.bindAttrs.forEach((attr) => {
1260
- if (attr.expression) {
1261
- code
1262
- += attr.expression.toEmbeddedTS(shiftState(state, code, {
1263
- tabSize: (state?.tabSize || 0) + 2,
1264
- })) + ',\n';
1265
- }
1266
- if (Array.isArray(attr.rules) && attr.rules.length) {
1267
- attr.rules.forEach((item) => {
1268
- code += item.toEmbeddedTS(shiftState(state, code)) + ',\n';
1269
- });
1270
- }
1271
- });
1272
- this.bindDirectives.forEach((directive) => {
1273
- if (directive.expression) {
1274
- code
1275
- += directive.expression.toEmbeddedTS(shiftState(state, code, {
1276
- tabSize: (state?.tabSize || 0) + 2,
1277
- })) + ',\n';
1278
- }
1279
- });
1247
+ this.bindAttrs.forEach((attr) => code += attr.toEmbeddedTS(shiftState(state, code, { tabSize: 0 })) + ',\n');
1248
+ this.bindDirectives.forEach((directive) => code += directive.toEmbeddedTS(shiftState(state, code, { tabSize: 0 })) + ',\n');
1280
1249
  code += indent((state?.tabSize || 0) + 2) + '],\n';
1281
1250
  }
1282
1251
 
1283
1252
  let levelIndex = parentLevel || 0;
1284
1253
  if (this.haveScope(this)) {
1285
- code += indent((state?.tabSize || 0) + 2);
1286
- // code += `slotDefault: (scope${levelIndex === 0 ? '' : levelIndex})=> [\n`;
1287
1254
  code += `slotDefault: (scope)=> [\n`;
1288
1255
  levelIndex++;
1289
1256
  } else {
1290
- code += indent((state?.tabSize || 0) + 2);
1291
1257
  code += `slotDefault: ()=> [\n`;
1292
1258
  }
1293
1259
 
@@ -1475,7 +1441,7 @@ export class ViewElement extends BaseNode {
1475
1441
  .forEach((name) => {
1476
1442
  const oldEvent = astNode.events[name] as compiler.ASTElementHandler;
1477
1443
  const str = oldEvent.value;
1478
- const calleeName = str.split('(')[0];
1444
+ let calleeName = str.split('(')[0];
1479
1445
  const matchArr = str.match(/\(([^)]*)\)/) || [];
1480
1446
  let argsStr = '';
1481
1447
  if (matchArr?.length >= 2) {
@@ -1492,17 +1458,21 @@ export class ViewElement extends BaseNode {
1492
1458
  expression: genArgumentMemberExpression(keyword),
1493
1459
  };
1494
1460
  });
1495
- const viewLogics = context?.definition?.viewLogics || [];
1496
- const currentLogic = viewLogics.find((item: Logic) => item.name === calleeName);
1497
- if (currentLogic) {
1498
- element.addBindEvent(new BindEvent({
1499
- name,
1500
- calleeNamespace: '',
1501
- calleeName: '',
1502
- arguments: args,
1503
- logics: [currentLogic],
1504
- }));
1461
+ let calleeNamespace = '';
1462
+ if (calleeName) {
1463
+ const namespaceArr = calleeName.split('.');
1464
+ const start = namespaceArr.shift();
1465
+ if (start === '$refs' && namespaceArr.length === 2) {
1466
+ calleeNamespace = `elements.${namespaceArr[0]}.logics`;
1467
+ calleeName = namespaceArr[1];
1468
+ }
1505
1469
  }
1470
+ element.addBindEvent(new BindEvent({
1471
+ name,
1472
+ calleeNamespace,
1473
+ calleeName,
1474
+ arguments: args,
1475
+ }));
1506
1476
  });
1507
1477
 
1508
1478
  astNode.directives
@@ -70,6 +70,12 @@ export class View extends BaseNode {
70
70
  @property()
71
71
  auth: boolean = undefined;
72
72
 
73
+ /**
74
+ * 权限资源描述
75
+ */
76
+ @property()
77
+ authDescription: string = undefined;
78
+
73
79
  /**
74
80
  * 是否是默认跳转的页面
75
81
  */
@@ -222,6 +228,18 @@ export class View extends BaseNode {
222
228
  });
223
229
  }
224
230
 
231
+ /**
232
+ * 设置权限资源描述
233
+ */
234
+ setAuthDescription(authDescription: string) {
235
+ const object = {
236
+ authDescription,
237
+ };
238
+ this.update({
239
+ ...object,
240
+ });
241
+ }
242
+
225
243
  /**
226
244
  * 设置是否是默认跳转的页面
227
245
  */
@@ -1453,7 +1471,6 @@ export class View extends BaseNode {
1453
1471
  if (template) {
1454
1472
  const node = ViewElement.fromHTML(template, {
1455
1473
  view: this,
1456
- definition,
1457
1474
  });
1458
1475
  if (!parentNode) {
1459
1476
  return;
@@ -1512,38 +1529,20 @@ export class View extends BaseNode {
1512
1529
  // 页面逻辑
1513
1530
  if (Array.isArray(definition.viewLogics)) {
1514
1531
  definition.viewLogics.forEach((logicOption: any) => {
1515
- // 页面逻辑只有load函数的走之前的逻辑其余不用创建
1516
- if (logicOption.name.startsWith('load')) {
1517
- const logic = Logic.from({
1518
- ...logicOption,
1519
- }, this, 'logics');
1520
- this.addLogic(logic);
1521
- }
1532
+ const logic = Logic.from({
1533
+ ...logicOption,
1534
+ }, this, 'logics');
1535
+ this.addLogic(logic);
1522
1536
  });
1523
1537
  }
1538
+
1524
1539
  // 页面事件
1525
1540
  if (Array.isArray(definition.viewBindEvents)) {
1526
1541
  definition.viewBindEvents.forEach((eventOption: any) => {
1527
- const newLogic = definition.viewLogics.find((logic: Logic) => {
1528
- return eventOption.calleeName === logic.name;
1529
- });
1530
- const bindEvent = this.bindEvents.find((currentEventItem) => {
1531
- return currentEventItem.name === eventOption.name;
1532
- });
1533
-
1534
- // 如果没有event对象就先新增一个,如果已经有了就在内部添加logic
1535
- if (!bindEvent) {
1536
- const event = BindEvent.from({
1537
- ...eventOption,
1538
- calleeName: '',
1539
- logics: [newLogic],
1540
- }, this, 'events');
1541
- this.addBindEvent(event);
1542
- } else {
1543
- const index = bindEvent.logics.length;
1544
- newLogic.name = newLogic.name + index;
1545
- bindEvent.addLogic(newLogic);
1546
- }
1542
+ const event = BindEvent.from({
1543
+ ...eventOption,
1544
+ }, this, 'events');
1545
+ this.addBindEvent(event);
1547
1546
  });
1548
1547
  }
1549
1548
  }
@@ -1611,7 +1610,6 @@ export class View extends BaseNode {
1611
1610
  crumb: this.crumb,
1612
1611
  first: this.children.find((child) => child.isIndex)?.name,
1613
1612
  auth: this.auth ? 'loginAuth' : undefined,
1614
- viewBindEvents: this.getViewBindEvents(),
1615
1613
  };
1616
1614
  return `${componentOptions}
1617
1615
  ${translator(definition)}
@@ -1815,6 +1813,7 @@ export class View extends BaseNode {
1815
1813
  code += this.toEmbeddedTS(state);
1816
1814
  } catch (err) {
1817
1815
  code += '';
1816
+ console.log(err);
1818
1817
  }
1819
1818
 
1820
1819
  code += '}\n';
@@ -1846,49 +1845,6 @@ export class View extends BaseNode {
1846
1845
  get authPath() {
1847
1846
  return this.path;
1848
1847
  }
1849
- /**
1850
- * 获取当前页面下所有elements上bindEvents下的logic
1851
- */
1852
- get elementLogicRoot() {
1853
- const logics: Array<Logic> = [];
1854
- // 页面上的绑定的事件
1855
- this.bindEvents.forEach((bindEvent) => {
1856
- bindEvent.logics.forEach((logic) => {
1857
- // logic.virtualParams = bindEvent.getContextRenderLogicParams(logic);
1858
- logics.push(logic);
1859
- });
1860
- });
1861
- this.elements.forEach((item) => {
1862
- utils.traverse((current) => {
1863
- current.node.bindEvents.forEach((bindEvent) => {
1864
- bindEvent.logics.forEach((logic) => {
1865
- // logic.virtualParams = bindEvent.getContextRenderLogicParams(logic);
1866
- logics.push(logic);
1867
- });
1868
- });
1869
- }, { node: item });
1870
- });
1871
- return [{
1872
- concept: 'elementLogicRoot',
1873
- expanded: false,
1874
- children: logics,
1875
- }];
1876
- }
1877
- getViewBindEvents() {
1878
- const bindEvents: Array<BindEvent> = [];
1879
- // 页面上的绑定的事件
1880
- this.bindEvents.forEach((bindEvent) => {
1881
- bindEvents.push(bindEvent);
1882
- });
1883
- this.elements.forEach((item) => {
1884
- utils.traverse((current) => {
1885
- current.node.bindEvents.forEach((bindEvent) => {
1886
- bindEvents.push(bindEvent);
1887
- });
1888
- }, { node: item });
1889
- });
1890
- return bindEvents;
1891
- }
1892
1848
 
1893
1849
  /**
1894
1850
  * @param path 子路径
@@ -38,10 +38,6 @@ export const uiStructures = [
38
38
  }),
39
39
  ],
40
40
  }),
41
- new Structure({
42
- name: 'BaseEvent',
43
- properties: [],
44
- }),
45
41
  new Structure({
46
42
  name: 'DataSourceParams',
47
43
  properties: [
package/src/index.ts CHANGED
@@ -8,5 +8,5 @@ export * as genBlock from './templator';
8
8
  export * as utils from './utils';
9
9
  export * from './config';
10
10
  export * from './eventBus';
11
- export { loadApp, loadAppSync, handleApp } from './service/storage/init';
11
+ export { loadApp, loadAppSync, handleApp, batchAction, batchQuery } from './service/storage/init';
12
12
  import './automate/engine';