@lcap/nasl 2.13.0-beta.1 → 2.13.0-beta.2
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/out/bak/translator.js +1 -6
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +1 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +65 -12
- package/out/concepts/BindAttribute__.js +72 -7
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +55 -0
- package/out/concepts/BindDirective__.js +69 -0
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -94
- package/out/concepts/BindEvent__.js +55 -347
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +102 -26
- package/out/concepts/CallQueryComponent__.js +104 -28
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.d.ts +1 -0
- package/out/concepts/CompletionProperty__.js +1 -0
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +5 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/Function__.d.ts +1 -2
- package/out/concepts/Function__.js +28 -0
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -7
- package/out/concepts/Logic__.js +10 -76
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Param__.d.ts +0 -1
- package/out/concepts/Param__.js +0 -6
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +0 -86
- package/out/concepts/ProcessElement__.js +0 -130
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +0 -93
- package/out/concepts/Process__.js +0 -141
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +8 -0
- package/out/concepts/ViewElement__.js +35 -47
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +8 -9
- package/out/concepts/View__.js +26 -72
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +0 -4
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/createUiTs.d.ts +0 -9
- package/out/server/createUiTs.js +1 -28
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -16
- package/out/server/getMemberIdentifier.js +29 -94
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +3 -3
- package/out/server/getProcesses.js +27 -28
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/index.js +0 -3
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.js +7 -19
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +5 -13
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +8 -0
- package/out/service/storage/init.js +5 -7
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +11 -2
- package/out/service/storage/service.js +26 -1
- package/out/service/storage/service.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +2 -4
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +0 -11
- package/out/templator/genCurdMultipleKeyBlock.js +19 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +30 -2
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +15 -1
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +15 -1
- package/out/templator/genTableBlock.js.map +1 -1
- package/package.json +1 -1
- package/src/bak/translator.js +1 -8
- package/src/common/BaseNode.ts +1 -1
- package/src/concepts/BindAttribute__.ts +153 -19
- package/src/concepts/BindDirective__.ts +139 -0
- package/src/concepts/BindEvent__.ts +57 -422
- package/src/concepts/CallQueryComponent__.ts +253 -56
- package/src/concepts/CompletionProperty__.ts +1 -0
- package/src/concepts/Destination__.ts +6 -1
- package/src/concepts/Function__.ts +1 -15
- package/src/concepts/Logic__.ts +11 -77
- package/src/concepts/Param__.ts +0 -6
- package/src/concepts/ProcessElement__.ts +1 -227
- package/src/concepts/Process__.ts +1 -237
- package/src/concepts/ViewElement__.ts +36 -48
- package/src/concepts/View__.ts +27 -72
- package/src/concepts/basics/stdlib/nasl.ui.ts +0 -4
- package/src/index.ts +1 -1
- package/src/server/createUiTs.ts +2 -26
- package/src/server/getMemberIdentifier.ts +28 -88
- package/src/server/getProcesses.ts +30 -31
- package/src/server/index.ts +0 -4
- package/src/server/naslServer.ts +7 -20
- package/src/server/translator.ts +6 -13
- package/src/service/storage/init.ts +5 -6
- package/src/service/storage/service.ts +28 -1
- package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -5
- package/src/templator/genCurdMultipleKeyBlock.ts +16 -27
- package/src/templator/genEditTableBlock.ts +27 -0
- package/src/templator/genGridViewBlock.ts +13 -0
- package/src/templator/genTableBlock.ts +13 -0
- package/src/server/events.yaml +0 -89
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState, embeddedTSEmitter } from '../translator';
|
|
2
2
|
import { constantToParam, genUserTaskLogic, returnToParam, getPreviousTask, syncMemberExpression, getFlowAfterElements, isFromStartNode, getFlowBeforeElements } from '../server/getProcesses';
|
|
3
|
-
import Namespace from './Namespace__';
|
|
4
3
|
//================================================================================
|
|
5
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
6
5
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -12,7 +11,6 @@ import * as utils from '../utils';
|
|
|
12
11
|
import { v4 as uuidv4 } from 'uuid';
|
|
13
12
|
import BaseNode from '../common/BaseNode';
|
|
14
13
|
import classMap from '../common/classMap';
|
|
15
|
-
import BindEvent from './BindEvent__';
|
|
16
14
|
import Rect from './Rect__';
|
|
17
15
|
import Point from './Point__';
|
|
18
16
|
import Logic from './Logic__';
|
|
@@ -53,12 +51,6 @@ export class ProcessElement extends BaseNode {
|
|
|
53
51
|
@property()
|
|
54
52
|
description: string = undefined;
|
|
55
53
|
|
|
56
|
-
/**
|
|
57
|
-
* 元素绑定事件列表
|
|
58
|
-
*/
|
|
59
|
-
@property('BindEvent')
|
|
60
|
-
bindEvents: Array<BindEvent> = [];
|
|
61
|
-
|
|
62
54
|
/**
|
|
63
55
|
* type
|
|
64
56
|
*/
|
|
@@ -256,149 +248,7 @@ export class ProcessElement extends BaseNode {
|
|
|
256
248
|
});
|
|
257
249
|
}
|
|
258
250
|
|
|
259
|
-
|
|
260
|
-
const excludedSet = new Set(excludedList);
|
|
261
|
-
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
262
|
-
}
|
|
263
|
-
getBindEventUniqueName(name = 'bindEvent1') {
|
|
264
|
-
return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* 插入元素绑定事件
|
|
269
|
-
* @internal
|
|
270
|
-
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
271
|
-
*/
|
|
272
|
-
_insertBindEventAt(name: string, index: number): BindEvent;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* 插入元素绑定事件
|
|
276
|
-
* @internal
|
|
277
|
-
* @param bindEventOptions 元素绑定事件参数
|
|
278
|
-
*/
|
|
279
|
-
_insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* 插入元素绑定事件
|
|
283
|
-
* @internal
|
|
284
|
-
* @param bindEvent 已有的元素绑定事件实例
|
|
285
|
-
*/
|
|
286
|
-
_insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
|
|
287
|
-
|
|
288
|
-
_insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
|
|
289
|
-
const bindEventOptions: any = {};
|
|
290
|
-
const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
|
|
291
|
-
let bindEvent: BindEvent;
|
|
292
|
-
if (!options) {
|
|
293
|
-
bindEvent = BindEvent.from({
|
|
294
|
-
...bindEventOptions,
|
|
295
|
-
name: this.getBindEventUniqueName(),
|
|
296
|
-
}, this, 'bindEvents');
|
|
297
|
-
} else if (typeof options === 'string') {
|
|
298
|
-
bindEvent = BindEvent.from({
|
|
299
|
-
...bindEventOptions,
|
|
300
|
-
name: options,
|
|
301
|
-
}, this, 'bindEvents');
|
|
302
|
-
} else if (options instanceof BindEvent) {
|
|
303
|
-
options.ensureDelete(); // 同一实例不支持多处存在
|
|
304
|
-
bindEvent = options;
|
|
305
|
-
Object.assign(bindEvent, relationOptions);
|
|
306
|
-
} else {
|
|
307
|
-
bindEvent = BindEvent.from({
|
|
308
|
-
...bindEventOptions,
|
|
309
|
-
...options,
|
|
310
|
-
}, this, 'bindEvents');
|
|
311
|
-
}
|
|
312
|
-
this.bindEvents.splice(index, 0, bindEvent);
|
|
313
|
-
return bindEvent;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* 插入元素绑定事件
|
|
318
|
-
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
319
|
-
*/
|
|
320
|
-
insertBindEventAt(name: string, index: number): BindEvent;
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* 插入元素绑定事件
|
|
324
|
-
* @param bindEventOptions 元素绑定事件参数
|
|
325
|
-
*/
|
|
326
|
-
insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* 插入元素绑定事件
|
|
330
|
-
* @param bindEvent 已有的元素绑定事件实例
|
|
331
|
-
*/
|
|
332
|
-
insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
|
|
333
|
-
|
|
334
|
-
insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
|
|
335
|
-
const node = this._insertBindEventAt(options as any, index);
|
|
336
|
-
node.create({
|
|
337
|
-
index,
|
|
338
|
-
parentNode: this,
|
|
339
|
-
parentKey: 'bindEvents',
|
|
340
|
-
});
|
|
341
|
-
return node;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* 添加元素绑定事件
|
|
346
|
-
* @internal
|
|
347
|
-
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
348
|
-
*/
|
|
349
|
-
_addBindEvent(name?: string): BindEvent;
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* 添加元素绑定事件
|
|
353
|
-
* @internal
|
|
354
|
-
* @param bindEventOptions 元素绑定事件参数
|
|
355
|
-
*/
|
|
356
|
-
_addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* 添加元素绑定事件
|
|
360
|
-
* @internal
|
|
361
|
-
* @param bindEvent 已有的元素绑定事件实例
|
|
362
|
-
*/
|
|
363
|
-
_addBindEvent(bindEvent: BindEvent): BindEvent;
|
|
364
|
-
|
|
365
|
-
_addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
|
|
366
|
-
const index = this.bindEvents.length;
|
|
367
|
-
return this._insertBindEventAt(options as any, index);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* 添加元素绑定事件
|
|
372
|
-
* @internal
|
|
373
|
-
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
374
|
-
*/
|
|
375
|
-
addBindEvent(name?: string): BindEvent;
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* 添加元素绑定事件
|
|
379
|
-
* @param bindEventOptions 元素绑定事件参数
|
|
380
|
-
*/
|
|
381
|
-
addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* 添加元素绑定事件
|
|
385
|
-
* @param bindEvent 已有的元素绑定事件实例
|
|
386
|
-
*/
|
|
387
|
-
addBindEvent(bindEvent: BindEvent): BindEvent;
|
|
388
|
-
|
|
389
|
-
addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
|
|
390
|
-
const node = this._addBindEvent(options as any);
|
|
391
|
-
const index = this.bindEvents.indexOf(node);
|
|
392
|
-
node.create({
|
|
393
|
-
index,
|
|
394
|
-
parentNode: this,
|
|
395
|
-
parentKey: 'bindEvents',
|
|
396
|
-
});
|
|
397
|
-
return node;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
getPointExistingNames(excludedList: Array<Point> = []) {
|
|
251
|
+
getPointExistingNames(excludedList: Array<Point> = []) {
|
|
402
252
|
const excludedSet = new Set(excludedList);
|
|
403
253
|
return (this.waypoints || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
404
254
|
}
|
|
@@ -1110,56 +960,6 @@ export class ProcessElement extends BaseNode {
|
|
|
1110
960
|
|
|
1111
961
|
|
|
1112
962
|
|
|
1113
|
-
/**
|
|
1114
|
-
* 删除元素绑定事件
|
|
1115
|
-
* @param name 元素绑定事件名称
|
|
1116
|
-
*/
|
|
1117
|
-
removeBindEvent(name: string): void;
|
|
1118
|
-
|
|
1119
|
-
/**
|
|
1120
|
-
* 删除元素绑定事件
|
|
1121
|
-
* @param bindEvent 已有的元素绑定事件实例
|
|
1122
|
-
*/
|
|
1123
|
-
removeBindEvent(bindEvent: BindEvent): void;
|
|
1124
|
-
|
|
1125
|
-
removeBindEvent(options: string | BindEvent) {
|
|
1126
|
-
let bindEvent: BindEvent;
|
|
1127
|
-
if (typeof options === 'string') {
|
|
1128
|
-
bindEvent = this.bindEvents.find((item) => item.name === options);
|
|
1129
|
-
if (!bindEvent) {
|
|
1130
|
-
throw new Error('找不到元素绑定事件 ' + options);
|
|
1131
|
-
}
|
|
1132
|
-
} else {
|
|
1133
|
-
bindEvent = options;
|
|
1134
|
-
}
|
|
1135
|
-
return bindEvent.delete();
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
__removeBindEvent(bindEvent: BindEvent) {
|
|
1139
|
-
const parentKey = bindEvent.parentKey;
|
|
1140
|
-
const params: Params = {
|
|
1141
|
-
parentNode: this,
|
|
1142
|
-
parentKey,
|
|
1143
|
-
index: -1,
|
|
1144
|
-
object: null,
|
|
1145
|
-
oldObject: bindEvent,
|
|
1146
|
-
};
|
|
1147
|
-
if (parentKey) {
|
|
1148
|
-
params.parentKey = parentKey;
|
|
1149
|
-
if (Array.isArray((this as any)[parentKey])) {
|
|
1150
|
-
const index = (this as any)[parentKey].indexOf(bindEvent);
|
|
1151
|
-
~index && (this as any)[parentKey].splice(index, 1);
|
|
1152
|
-
params.index = index;
|
|
1153
|
-
} else if ((this as any)[parentKey] === bindEvent) {
|
|
1154
|
-
params.index = 0;
|
|
1155
|
-
(this as any)[parentKey] = undefined;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
return params;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
963
|
/**
|
|
1164
964
|
* 删除矩形信息
|
|
1165
965
|
* @param name 矩形信息名称
|
|
@@ -1524,19 +1324,6 @@ export class ProcessElement extends BaseNode {
|
|
|
1524
1324
|
// return ns;
|
|
1525
1325
|
}
|
|
1526
1326
|
|
|
1527
|
-
getNamespace(ns: string) {
|
|
1528
|
-
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
1529
|
-
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
1530
|
-
const parentName = this.parentNode.name;
|
|
1531
|
-
const arr = [parentNamespace];
|
|
1532
|
-
if (this.parentNode.concept !== 'App' && parentName) {
|
|
1533
|
-
arr.push(parentName);
|
|
1534
|
-
}
|
|
1535
|
-
return `${arr.join('.')}.${ns || 'bindEvent'}`;
|
|
1536
|
-
} else
|
|
1537
|
-
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
1327
|
@withSourceMap()
|
|
1541
1328
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
1542
1329
|
// this.syncLogic();
|
|
@@ -1582,21 +1369,8 @@ export class ProcessElement extends BaseNode {
|
|
|
1582
1369
|
// prevCode += `${tab4}}\n`
|
|
1583
1370
|
|
|
1584
1371
|
if (this.type === 'UserTask') {
|
|
1585
|
-
//任务完成时可以拿到输出参数,prevCodeClose包含输出参数
|
|
1586
|
-
let prevCodeClose = prevCode + `\n${tab5}${this.name}: { \n${this.constants.map((c) => `${tab6}${c.name}: "",`).join('\n')} \n${this.returns.map((c) => `${tab6}${c.name}: "",`).join('\n')}}\n`;
|
|
1587
|
-
prevCodeClose += `${tab3}}\n`;
|
|
1588
1372
|
prevCode += `\n${tab5}${this.name}: { \n${this.constants.map((c) => `${tab6}${c.name}: "",`).join('\n')} }\n`;
|
|
1589
1373
|
prevCode += `${tab3}}\n`;
|
|
1590
|
-
if (Array.isArray(this.bindEvents)) {
|
|
1591
|
-
this.bindEvents.forEach((bindEvent) => {
|
|
1592
|
-
//任务完成时可以拿到输出参数
|
|
1593
|
-
const currentPrevCode = bindEvent.name === 'OnClose' ? prevCodeClose : prevCode;
|
|
1594
|
-
bindEvent.logics.forEach((logic) => {
|
|
1595
|
-
code += `${tab1}${logic.name}: `;
|
|
1596
|
-
code += `${logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), currentPrevCode, true)},\n`;
|
|
1597
|
-
});
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
1374
|
code += `${tab1}logics: {\n`;
|
|
1601
1375
|
this.bindAttrs.forEach((attr) => {
|
|
1602
1376
|
if (attr.name === 'destination') {
|
|
@@ -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
|
-
|
|
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
|
}
|
|
@@ -7,7 +7,7 @@ import * as compiler from 'vue-template-compiler';
|
|
|
7
7
|
|
|
8
8
|
import LogicItem from './LogicItem__';
|
|
9
9
|
|
|
10
|
-
import { config
|
|
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
|
*/
|
|
@@ -300,6 +306,18 @@ export class ViewElement extends BaseNode {
|
|
|
300
306
|
});
|
|
301
307
|
}
|
|
302
308
|
|
|
309
|
+
/**
|
|
310
|
+
* 设置权限资源描述
|
|
311
|
+
*/
|
|
312
|
+
setAuthDescription(authDescription: string) {
|
|
313
|
+
const object = {
|
|
314
|
+
authDescription,
|
|
315
|
+
};
|
|
316
|
+
this.update({
|
|
317
|
+
...object,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
303
321
|
getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
|
|
304
322
|
const excludedSet = new Set(excludedList);
|
|
305
323
|
return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -1227,18 +1245,6 @@ export class ViewElement extends BaseNode {
|
|
|
1227
1245
|
code += indent((state?.tabSize || 0) + 2);
|
|
1228
1246
|
code += '],\n';
|
|
1229
1247
|
}
|
|
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
1248
|
|
|
1243
1249
|
// 事件
|
|
1244
1250
|
if (Array.isArray(this.bindEvents)) {
|
|
@@ -1256,38 +1262,16 @@ export class ViewElement extends BaseNode {
|
|
|
1256
1262
|
|
|
1257
1263
|
if (Array.isArray(this.bindAttrs)) {
|
|
1258
1264
|
code += `bindAttr: () => [\n`;
|
|
1259
|
-
this.bindAttrs.forEach((attr) => {
|
|
1260
|
-
|
|
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
|
-
});
|
|
1265
|
+
this.bindAttrs.forEach((attr) => code += attr.toEmbeddedTS(shiftState(state, code, { tabSize: 0 })) + ',\n');
|
|
1266
|
+
this.bindDirectives.forEach((directive) => code += directive.toEmbeddedTS(shiftState(state, code, { tabSize: 0 })) + ',\n');
|
|
1280
1267
|
code += indent((state?.tabSize || 0) + 2) + '],\n';
|
|
1281
1268
|
}
|
|
1282
1269
|
|
|
1283
1270
|
let levelIndex = parentLevel || 0;
|
|
1284
1271
|
if (this.haveScope(this)) {
|
|
1285
|
-
code += indent((state?.tabSize || 0) + 2);
|
|
1286
|
-
// code += `slotDefault: (scope${levelIndex === 0 ? '' : levelIndex})=> [\n`;
|
|
1287
1272
|
code += `slotDefault: (scope)=> [\n`;
|
|
1288
1273
|
levelIndex++;
|
|
1289
1274
|
} else {
|
|
1290
|
-
code += indent((state?.tabSize || 0) + 2);
|
|
1291
1275
|
code += `slotDefault: ()=> [\n`;
|
|
1292
1276
|
}
|
|
1293
1277
|
|
|
@@ -1475,7 +1459,7 @@ export class ViewElement extends BaseNode {
|
|
|
1475
1459
|
.forEach((name) => {
|
|
1476
1460
|
const oldEvent = astNode.events[name] as compiler.ASTElementHandler;
|
|
1477
1461
|
const str = oldEvent.value;
|
|
1478
|
-
|
|
1462
|
+
let calleeName = str.split('(')[0];
|
|
1479
1463
|
const matchArr = str.match(/\(([^)]*)\)/) || [];
|
|
1480
1464
|
let argsStr = '';
|
|
1481
1465
|
if (matchArr?.length >= 2) {
|
|
@@ -1492,17 +1476,21 @@ export class ViewElement extends BaseNode {
|
|
|
1492
1476
|
expression: genArgumentMemberExpression(keyword),
|
|
1493
1477
|
};
|
|
1494
1478
|
});
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
calleeNamespace
|
|
1501
|
-
calleeName
|
|
1502
|
-
|
|
1503
|
-
logics: [currentLogic],
|
|
1504
|
-
}));
|
|
1479
|
+
let calleeNamespace = '';
|
|
1480
|
+
if (calleeName) {
|
|
1481
|
+
const namespaceArr = calleeName.split('.');
|
|
1482
|
+
const start = namespaceArr.shift();
|
|
1483
|
+
if (start === '$refs' && namespaceArr.length === 2) {
|
|
1484
|
+
calleeNamespace = `elements.${namespaceArr[0]}.logics`;
|
|
1485
|
+
calleeName = namespaceArr[1];
|
|
1486
|
+
}
|
|
1505
1487
|
}
|
|
1488
|
+
element.addBindEvent(new BindEvent({
|
|
1489
|
+
name,
|
|
1490
|
+
calleeNamespace,
|
|
1491
|
+
calleeName,
|
|
1492
|
+
arguments: args,
|
|
1493
|
+
}));
|
|
1506
1494
|
});
|
|
1507
1495
|
|
|
1508
1496
|
astNode.directives
|