@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,12 +1,9 @@
|
|
|
1
1
|
import * as babel from '@babel/core';
|
|
2
|
+
import Logic from './Logic__';
|
|
2
3
|
import LogicItem from './LogicItem__';
|
|
3
4
|
import Namespace from './Namespace__';
|
|
4
5
|
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState, embeddedTSEmitter } from '../translator';
|
|
5
6
|
import { ElementToVueOptions } from './ViewElement__';
|
|
6
|
-
import { elementsEventsMap } from '../server/createUiTs';
|
|
7
|
-
import Param from './Param__';
|
|
8
|
-
import TypeAnnotation from './TypeAnnotation__';
|
|
9
|
-
|
|
10
7
|
//================================================================================
|
|
11
8
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
12
9
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -18,7 +15,6 @@ import * as utils from '../utils';
|
|
|
18
15
|
import { v4 as uuidv4 } from 'uuid';
|
|
19
16
|
import BaseNode from '../common/BaseNode';
|
|
20
17
|
import classMap from '../common/classMap';
|
|
21
|
-
import Logic from './Logic__';
|
|
22
18
|
import Argument from './Argument__';
|
|
23
19
|
import ViewElement from './ViewElement__';
|
|
24
20
|
import View from './View__';
|
|
@@ -42,12 +38,6 @@ export class BindEvent extends BaseNode {
|
|
|
42
38
|
@property()
|
|
43
39
|
name: string = undefined;
|
|
44
40
|
|
|
45
|
-
/**
|
|
46
|
-
* 逻辑列表
|
|
47
|
-
*/
|
|
48
|
-
@property('Logic')
|
|
49
|
-
logics: Array<Logic> = [];
|
|
50
|
-
|
|
51
41
|
/**
|
|
52
42
|
* calleeNamespace
|
|
53
43
|
*/
|
|
@@ -152,149 +142,7 @@ export class BindEvent extends BaseNode {
|
|
|
152
142
|
});
|
|
153
143
|
}
|
|
154
144
|
|
|
155
|
-
|
|
156
|
-
const excludedSet = new Set(excludedList);
|
|
157
|
-
return (this.logics || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
158
|
-
}
|
|
159
|
-
getLogicUniqueName(name = 'logic1') {
|
|
160
|
-
return utils.unique(name, this.getLogicExistingNames(), undefined, true);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* 插入逻辑
|
|
165
|
-
* @internal
|
|
166
|
-
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
167
|
-
*/
|
|
168
|
-
_insertLogicAt(name: string, index: number): Logic;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* 插入逻辑
|
|
172
|
-
* @internal
|
|
173
|
-
* @param logicOptions 逻辑参数
|
|
174
|
-
*/
|
|
175
|
-
_insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* 插入逻辑
|
|
179
|
-
* @internal
|
|
180
|
-
* @param logic 已有的逻辑实例
|
|
181
|
-
*/
|
|
182
|
-
_insertLogicAt(logic: Logic, index: number): Logic;
|
|
183
|
-
|
|
184
|
-
_insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
|
|
185
|
-
const logicOptions: any = {};
|
|
186
|
-
const relationOptions = { parentNode: this, parentKey: 'logics' };
|
|
187
|
-
let logic: Logic;
|
|
188
|
-
if (!options) {
|
|
189
|
-
logic = Logic.from({
|
|
190
|
-
...logicOptions,
|
|
191
|
-
name: this.getLogicUniqueName(),
|
|
192
|
-
}, this, 'logics');
|
|
193
|
-
} else if (typeof options === 'string') {
|
|
194
|
-
logic = Logic.from({
|
|
195
|
-
...logicOptions,
|
|
196
|
-
name: options,
|
|
197
|
-
}, this, 'logics');
|
|
198
|
-
} else if (options instanceof Logic) {
|
|
199
|
-
options.ensureDelete(); // 同一实例不支持多处存在
|
|
200
|
-
logic = options;
|
|
201
|
-
Object.assign(logic, relationOptions);
|
|
202
|
-
} else {
|
|
203
|
-
logic = Logic.from({
|
|
204
|
-
...logicOptions,
|
|
205
|
-
...options,
|
|
206
|
-
}, this, 'logics');
|
|
207
|
-
}
|
|
208
|
-
this.logics.splice(index, 0, logic);
|
|
209
|
-
return logic;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* 插入逻辑
|
|
214
|
-
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
215
|
-
*/
|
|
216
|
-
insertLogicAt(name: string, index: number): Logic;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* 插入逻辑
|
|
220
|
-
* @param logicOptions 逻辑参数
|
|
221
|
-
*/
|
|
222
|
-
insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* 插入逻辑
|
|
226
|
-
* @param logic 已有的逻辑实例
|
|
227
|
-
*/
|
|
228
|
-
insertLogicAt(logic: Logic, index: number): Logic;
|
|
229
|
-
|
|
230
|
-
insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
|
|
231
|
-
const node = this._insertLogicAt(options as any, index);
|
|
232
|
-
node.create({
|
|
233
|
-
index,
|
|
234
|
-
parentNode: this,
|
|
235
|
-
parentKey: 'logics',
|
|
236
|
-
});
|
|
237
|
-
return node;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* 添加逻辑
|
|
242
|
-
* @internal
|
|
243
|
-
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
244
|
-
*/
|
|
245
|
-
_addLogic(name?: string): Logic;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* 添加逻辑
|
|
249
|
-
* @internal
|
|
250
|
-
* @param logicOptions 逻辑参数
|
|
251
|
-
*/
|
|
252
|
-
_addLogic(logicOptions: Partial<Logic>): Logic;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* 添加逻辑
|
|
256
|
-
* @internal
|
|
257
|
-
* @param logic 已有的逻辑实例
|
|
258
|
-
*/
|
|
259
|
-
_addLogic(logic: Logic): Logic;
|
|
260
|
-
|
|
261
|
-
_addLogic(options?: string | Partial<Logic> | Logic) {
|
|
262
|
-
const index = 0;
|
|
263
|
-
return this._insertLogicAt(options as any, index);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* 添加逻辑
|
|
268
|
-
* @internal
|
|
269
|
-
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
270
|
-
*/
|
|
271
|
-
addLogic(name?: string): Logic;
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* 添加逻辑
|
|
275
|
-
* @param logicOptions 逻辑参数
|
|
276
|
-
*/
|
|
277
|
-
addLogic(logicOptions: Partial<Logic>): Logic;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* 添加逻辑
|
|
281
|
-
* @param logic 已有的逻辑实例
|
|
282
|
-
*/
|
|
283
|
-
addLogic(logic: Logic): Logic;
|
|
284
|
-
|
|
285
|
-
addLogic(options?: string | Partial<Logic> | Logic) {
|
|
286
|
-
const node = this._addLogic(options as any);
|
|
287
|
-
const index = this.logics.indexOf(node);
|
|
288
|
-
node.create({
|
|
289
|
-
index,
|
|
290
|
-
parentNode: this,
|
|
291
|
-
parentKey: 'logics',
|
|
292
|
-
});
|
|
293
|
-
return node;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
145
|
+
|
|
298
146
|
|
|
299
147
|
|
|
300
148
|
|
|
@@ -403,56 +251,6 @@ export class BindEvent extends BaseNode {
|
|
|
403
251
|
|
|
404
252
|
|
|
405
253
|
|
|
406
|
-
/**
|
|
407
|
-
* 删除逻辑
|
|
408
|
-
* @param name 逻辑名称
|
|
409
|
-
*/
|
|
410
|
-
removeLogic(name: string): void;
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* 删除逻辑
|
|
414
|
-
* @param logic 已有的逻辑实例
|
|
415
|
-
*/
|
|
416
|
-
removeLogic(logic: Logic): void;
|
|
417
|
-
|
|
418
|
-
removeLogic(options: string | Logic) {
|
|
419
|
-
let logic: Logic;
|
|
420
|
-
if (typeof options === 'string') {
|
|
421
|
-
logic = this.logics.find((item) => item.name === options);
|
|
422
|
-
if (!logic) {
|
|
423
|
-
throw new Error('找不到逻辑 ' + options);
|
|
424
|
-
}
|
|
425
|
-
} else {
|
|
426
|
-
logic = options;
|
|
427
|
-
}
|
|
428
|
-
return logic.delete();
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
__removeLogic(logic: Logic) {
|
|
432
|
-
const parentKey = logic.parentKey;
|
|
433
|
-
const params: Params = {
|
|
434
|
-
parentNode: this,
|
|
435
|
-
parentKey,
|
|
436
|
-
index: -1,
|
|
437
|
-
object: null,
|
|
438
|
-
oldObject: logic,
|
|
439
|
-
};
|
|
440
|
-
if (parentKey) {
|
|
441
|
-
params.parentKey = parentKey;
|
|
442
|
-
if (Array.isArray((this as any)[parentKey])) {
|
|
443
|
-
const index = (this as any)[parentKey].indexOf(logic);
|
|
444
|
-
~index && (this as any)[parentKey].splice(index, 1);
|
|
445
|
-
params.index = index;
|
|
446
|
-
} else if ((this as any)[parentKey] === logic) {
|
|
447
|
-
params.index = 0;
|
|
448
|
-
(this as any)[parentKey] = undefined;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
return params;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
254
|
/**
|
|
457
255
|
* 删除实际参数
|
|
458
256
|
* @param argument 已有的实际参数实例
|
|
@@ -491,7 +289,14 @@ export class BindEvent extends BaseNode {
|
|
|
491
289
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
492
290
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
493
291
|
//================================================================================
|
|
494
|
-
|
|
292
|
+
// 用于logic回填
|
|
293
|
+
get calleewholeKey(): string {
|
|
294
|
+
if (!this.calleeNamespace && this.calleeName) {
|
|
295
|
+
// 页面逻辑单独处理
|
|
296
|
+
return `${this.view.getNamespace()}.${this.view.name}.logics.${this.calleeName}`;
|
|
297
|
+
}
|
|
298
|
+
return this.calleeNamespace + '.' + this.calleeName;
|
|
299
|
+
}
|
|
495
300
|
get tsCalleeNamespace() {
|
|
496
301
|
if (this.calleeNamespace) {
|
|
497
302
|
let tsCalleeNamespace = this.calleeNamespace;
|
|
@@ -530,94 +335,22 @@ export class BindEvent extends BaseNode {
|
|
|
530
335
|
// 绑定事件转驼峰
|
|
531
336
|
toHump = (name: string) => (name ? name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase()) : '');
|
|
532
337
|
|
|
533
|
-
toJS(state?: TranslatorState): string {
|
|
534
|
-
// shiftState(state, code)
|
|
535
|
-
let code = `methods['${this.getViewEventName()}'] = async function (`;
|
|
536
|
-
const params = this.getContextLogicParams();
|
|
537
|
-
code += params.map((item: Param) => item.name).toString();
|
|
538
|
-
code += ') { \n';
|
|
539
|
-
this.logics.forEach((logic) => {
|
|
540
|
-
code += logic.toJS(shiftState(state, code), 'IIFE');
|
|
541
|
-
});
|
|
542
|
-
code += '};\n';
|
|
543
|
-
return code;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
338
|
@withSourceMap()
|
|
547
339
|
toEmbeddedTS(state?: TranslatorState, isPageCycle?: Boolean): string {
|
|
548
340
|
// 如果有绑定的事件名
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
const logicName = logic.name;
|
|
553
|
-
logic.name = logic.view.name + logic.name + index;
|
|
554
|
-
code += logic.toEmbeddedTS(shiftState(state, code, {
|
|
555
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
556
|
-
}), 'noExport');
|
|
557
|
-
code += indent((state?.tabSize || 0));
|
|
558
|
-
code += `${logic.name}();`;
|
|
559
|
-
logic.name = logicName;
|
|
560
|
-
});
|
|
561
|
-
return code;
|
|
562
|
-
}
|
|
563
|
-
code = `${this.toHump(this.name) || '__IDENTIFIER__'}: (event: `;
|
|
564
|
-
|
|
565
|
-
// event的类型
|
|
566
|
-
code += this.getEventTypeString();
|
|
567
|
-
|
|
568
|
-
code += ') => [\n';
|
|
569
|
-
this.logics.forEach((logic) => {
|
|
570
|
-
if (logic.view) {
|
|
571
|
-
const logicName = logic.name;
|
|
572
|
-
logic.name = logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
|
|
573
|
-
logic.name = logic.name.replace(/-/g, '');
|
|
574
|
-
code += logic.toEmbeddedTS(shiftState(state, code, {
|
|
575
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
576
|
-
}), 'noExport');
|
|
577
|
-
logic.name = logicName;
|
|
578
|
-
} else {
|
|
579
|
-
code += logic.toEmbeddedTS(shiftState(state, code, {
|
|
580
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
581
|
-
}), 'noExport');
|
|
341
|
+
if (this.calleeName) {
|
|
342
|
+
if (isPageCycle) {
|
|
343
|
+
return `${this.calleeKey}();`;
|
|
582
344
|
}
|
|
583
|
-
|
|
345
|
+
let code = `${this.toHump(this.name) || '__IDENTIFIER__'}: (event: any) => [\n`;
|
|
346
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
347
|
+
code += `() => {${this.calleeKey}()}`;
|
|
348
|
+
code += '\n';
|
|
584
349
|
code += indent((state?.tabSize || 0));
|
|
585
|
-
code += ',\n';
|
|
586
|
-
|
|
587
|
-
code += '],\n';
|
|
588
|
-
return code;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
getEventTypeString() {
|
|
592
|
-
let code = '';
|
|
593
|
-
if (!Object.keys(elementsEventsMap).length)
|
|
594
|
-
return;
|
|
595
|
-
if (this.element && elementsEventsMap[`${this.element.tag}-${this.name}`]) {
|
|
596
|
-
const pageInfo = elementsEventsMap[`${this.element.tag}-${this.name}`];
|
|
597
|
-
const refParam = pageInfo.params && pageInfo.params.find((item: any) => item.schema);
|
|
598
|
-
if (refParam) {
|
|
599
|
-
const ref = refParam.schema.$ref;
|
|
600
|
-
let type = '';
|
|
601
|
-
if (ref.includes('systemTypes')) {
|
|
602
|
-
// 不要删除,用于转换类型
|
|
603
|
-
type = ref.replace('#/systemTypes/', 'nasl.ui.');
|
|
604
|
-
} else if (ref.includes('basicTypes')) {
|
|
605
|
-
// 不要删除,用于转换类型
|
|
606
|
-
type = ref.replace('#/basicTypes/', 'nasl.core.');
|
|
607
|
-
}
|
|
608
|
-
code = `${type}`;
|
|
609
|
-
} else {
|
|
610
|
-
code = `nasl.ui.BaseEvent`;
|
|
611
|
-
}
|
|
612
|
-
} else if (['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focus', 'blur'].includes(this.name)) {
|
|
613
|
-
const eventInfo = elementsEventsMap[this.name];
|
|
614
|
-
const ref = eventInfo.params[0].schema.$ref;
|
|
615
|
-
const type = ref.replace('#/systemTypes/', 'nasl.ui.');
|
|
616
|
-
code = `${type}`;
|
|
617
|
-
} else {
|
|
618
|
-
code = 'nasl.ui.BaseEvent';
|
|
350
|
+
code += '],\n';
|
|
351
|
+
return code;
|
|
619
352
|
}
|
|
620
|
-
return
|
|
353
|
+
return '';
|
|
621
354
|
}
|
|
622
355
|
|
|
623
356
|
// @withSourceMap()
|
|
@@ -650,43 +383,50 @@ export class BindEvent extends BaseNode {
|
|
|
650
383
|
...object,
|
|
651
384
|
});
|
|
652
385
|
}
|
|
653
|
-
|
|
654
|
-
getNamespace(ns: string) {
|
|
655
|
-
if (this.view)
|
|
656
|
-
return `${this.view.getNamespace()}.${this.view.name}.bindEvents.${this.name}.logics`;
|
|
657
|
-
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
658
|
-
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
659
|
-
const parentName = this.parentNode.name;
|
|
660
|
-
const arr = [parentNamespace];
|
|
661
|
-
if (this.parentNode.concept !== 'App' && parentName) {
|
|
662
|
-
arr.push(parentName);
|
|
663
|
-
}
|
|
664
|
-
return `${arr.join('.')}.${ns || 'bindEvent'}`;
|
|
665
|
-
} else
|
|
666
|
-
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
667
|
-
}
|
|
668
386
|
/**
|
|
669
387
|
* 转换成 Vue 的模板格式
|
|
670
388
|
*/
|
|
671
389
|
toVue(options?: ElementToVueOptions) {
|
|
390
|
+
const calleeNamespace = this.calleeNamespace;
|
|
391
|
+
let isComponentLogic = false;
|
|
392
|
+
let componentName = '';
|
|
393
|
+
if (calleeNamespace) {
|
|
394
|
+
const namespaceArr = calleeNamespace.split('.');
|
|
395
|
+
const start = namespaceArr.shift();
|
|
396
|
+
if (start === 'elements' && namespaceArr.length === 2 && namespaceArr[1] === 'logics') {
|
|
397
|
+
isComponentLogic = true;
|
|
398
|
+
componentName = namespaceArr[0];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
let callee = '';
|
|
402
|
+
if (isComponentLogic)
|
|
403
|
+
callee = `$refs.${componentName}.${this.calleeName}`;
|
|
404
|
+
else if (calleeNamespace?.startsWith('nasl.'))
|
|
405
|
+
callee = `$global.${this.calleeName}`;
|
|
406
|
+
else
|
|
407
|
+
callee = this.calleeName;
|
|
672
408
|
let code = '';
|
|
673
|
-
if (
|
|
674
|
-
code += `@${this.name}="`;
|
|
409
|
+
if (callee) {
|
|
410
|
+
code += `@${this.name}="${callee}`;
|
|
675
411
|
const argsList: string[] = [];
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
parent = parent.parentNode;
|
|
685
|
-
}
|
|
686
|
-
argsList.unshift('event');
|
|
412
|
+
const argsMap: any = {};
|
|
413
|
+
if (Array.isArray(this.arguments) && this.arguments.length) {
|
|
414
|
+
this.arguments.forEach((arg) => {
|
|
415
|
+
const argStr = arg.toJS();
|
|
416
|
+
argsList.push(argStr);
|
|
417
|
+
argsMap[argStr] = true;
|
|
418
|
+
});
|
|
687
419
|
}
|
|
688
|
-
|
|
689
|
-
|
|
420
|
+
const additionalArgs: string[] = ['$event'];
|
|
421
|
+
if (Array.isArray(options?.scopeList) && options?.scopeList.length) {
|
|
422
|
+
additionalArgs.push(...options.scopeList);
|
|
423
|
+
}
|
|
424
|
+
additionalArgs.forEach((arg) => {
|
|
425
|
+
if (!argsMap[arg]) {
|
|
426
|
+
argsList.push(arg);
|
|
427
|
+
argsMap[arg] = true;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
690
430
|
code += '(';
|
|
691
431
|
argsList.forEach((arg, index) => {
|
|
692
432
|
code += arg;
|
|
@@ -694,115 +434,10 @@ export class BindEvent extends BaseNode {
|
|
|
694
434
|
code += ', ';
|
|
695
435
|
});
|
|
696
436
|
code += ')';
|
|
697
|
-
|
|
698
437
|
code += `"`;
|
|
699
438
|
}
|
|
700
439
|
return code;
|
|
701
440
|
}
|
|
702
|
-
|
|
703
|
-
// 获取bindEvent上的logic的参数从上文获取
|
|
704
|
-
getContextLogicParams() {
|
|
705
|
-
const argsList: string[] = [];
|
|
706
|
-
if (this.logics?.length) {
|
|
707
|
-
let parent = this.parentNode;
|
|
708
|
-
let index = 0;
|
|
709
|
-
while (parent && parent.concept !== 'View') {
|
|
710
|
-
if ((parent as ViewElement).slotScope) {
|
|
711
|
-
argsList.unshift(index === 0 ? 'scope' : 'scope' + index);
|
|
712
|
-
index++;
|
|
713
|
-
}
|
|
714
|
-
parent = parent.parentNode;
|
|
715
|
-
}
|
|
716
|
-
argsList.unshift('event');
|
|
717
|
-
}
|
|
718
|
-
return argsList.map((name: string) => new Param({ name }));
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
// 获取bindEvent上的logic的参数从上文获取
|
|
722
|
-
getContextRenderLogicParams(logic: Logic) {
|
|
723
|
-
const argsList: Param[] = [];
|
|
724
|
-
if (this.logics?.length) {
|
|
725
|
-
let parent = this.parentNode;
|
|
726
|
-
let index = 0;
|
|
727
|
-
const event = Param.from({ name: 'event' }, logic, 'virtualParams');
|
|
728
|
-
const typeString = this.getEventTypeString();
|
|
729
|
-
if (!typeString)
|
|
730
|
-
return argsList;
|
|
731
|
-
if (typeString && typeString.includes('nasl.ui')) {
|
|
732
|
-
const last = typeString.lastIndexOf('.');
|
|
733
|
-
event.typeAnnotation = TypeAnnotation.createReference(typeString.substring(last + 1, typeString.length), {
|
|
734
|
-
typeNamespace: 'nasl.ui',
|
|
735
|
-
});
|
|
736
|
-
} else {
|
|
737
|
-
const last = typeString.lastIndexOf('.');
|
|
738
|
-
event.typeAnnotation = TypeAnnotation.createPrimitive(typeString.substring(last + 1, typeString.length), {
|
|
739
|
-
typeNamespace: 'nasl.core',
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
argsList.push(event);
|
|
743
|
-
|
|
744
|
-
while (parent && parent.concept !== 'View') {
|
|
745
|
-
if ((parent as ViewElement).slotScope) {
|
|
746
|
-
const param = Param.from({ name: index === 0 ? 'scope' : 'scope' + index }, logic, 'virtualParams');
|
|
747
|
-
param.typeAnnotation = TypeAnnotation.createGeneric('ScopeOf', {
|
|
748
|
-
typeNamespace: 'nasl.ui',
|
|
749
|
-
typeArguments: [],
|
|
750
|
-
});
|
|
751
|
-
argsList.push(param);
|
|
752
|
-
index++;
|
|
753
|
-
}
|
|
754
|
-
parent = parent.parentNode;
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
return argsList;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
getPageViewEventChineseName() {
|
|
761
|
-
const parent = this.parentNode;
|
|
762
|
-
if (parent instanceof View) {
|
|
763
|
-
const page = elementsEventsMap[this.name];
|
|
764
|
-
return `${parent.name}-${page.title}`;
|
|
765
|
-
} else if (parent instanceof ViewElement) {
|
|
766
|
-
const eventName = `${parent.tag}-${this.name}`;
|
|
767
|
-
if (elementsEventsMap[eventName]) {
|
|
768
|
-
const page = elementsEventsMap[eventName];
|
|
769
|
-
return `${parent.name}-${page.title}`;
|
|
770
|
-
} else if (['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focus', 'blur'].includes(this.name)) {
|
|
771
|
-
const page = elementsEventsMap[this.name];
|
|
772
|
-
return `${parent.name}-${page.title}`;
|
|
773
|
-
}
|
|
774
|
-
return `${parent.name}-${this.name}`;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
getViewEventChineseName() {
|
|
779
|
-
const parent = this.parentNode;
|
|
780
|
-
if (parent instanceof View) {
|
|
781
|
-
const page = elementsEventsMap[this.name];
|
|
782
|
-
return `${page.title}`;
|
|
783
|
-
} else if (parent instanceof ViewElement) {
|
|
784
|
-
const eventName = `${parent.tag}-${this.name}`;
|
|
785
|
-
if (elementsEventsMap[eventName]) {
|
|
786
|
-
const page = elementsEventsMap[eventName];
|
|
787
|
-
return `${page.title}`;
|
|
788
|
-
} else if (['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focus', 'blur'].includes(this.name)) {
|
|
789
|
-
const page = elementsEventsMap[this.name];
|
|
790
|
-
return `${page.title}`;
|
|
791
|
-
}
|
|
792
|
-
return `${this.name}`;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
getViewEventName() {
|
|
796
|
-
// 名称规则:组件的名称 + 组件的事件 + 逻辑本身的事件 用下划线链接
|
|
797
|
-
const parentNode = this.parentNode;
|
|
798
|
-
const newName = this.name.replace(/-/g, '');
|
|
799
|
-
|
|
800
|
-
if (parentNode instanceof ViewElement) {
|
|
801
|
-
return `${parentNode.name}_${newName}`;
|
|
802
|
-
} else if (parentNode instanceof View) {
|
|
803
|
-
return `${this.view.name}_${newName}`;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
441
|
//================================================================================
|
|
807
442
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
808
443
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|