@lcap/nasl 1.0.0-alpha.13 → 1.0.0-alpha.14
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/automate/engine/index.js +1 -1
- package/out/automate/engine/index.js.map +1 -1
- package/out/common/BaseNode.d.ts +4 -4
- package/out/common/BaseNode.js +45 -41
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +17 -0
- package/out/concepts/App__.js +54 -12
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +2 -2
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +8 -6
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +21 -21
- package/out/concepts/BindAttribute__.js +4 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +3 -3
- package/out/concepts/BindDirective__.js +22 -2
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +9 -8
- package/out/concepts/BindEvent__.js +17 -7
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.js +10 -5
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +11 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -0
- package/out/concepts/CallLogic__.js +17 -7
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +0 -1
- package/out/concepts/CallQueryComponent__.js +5 -8
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +6 -2
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Destination__.js +10 -7
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +3 -0
- package/out/concepts/EntityProperty__.js +38 -0
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +34 -31
- package/out/concepts/Entity__.js +29 -12
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +1 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +8 -12
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js +4 -4
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +13 -7
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.d.ts +2 -0
- package/out/concepts/InterfaceParam__.js +10 -0
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +3 -3
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -0
- package/out/concepts/LogicItem__.js +14 -0
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -0
- package/out/concepts/Logic__.js +16 -11
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.js +8 -8
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js +12 -12
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -0
- package/out/concepts/Param__.js +3 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +2 -2
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +5 -5
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/Process__.js +4 -4
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +2 -2
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -0
- package/out/concepts/Return__.js +6 -3
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +2 -2
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +3 -6
- package/out/concepts/StructureProperty__.js +38 -32
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +3 -3
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +3 -3
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +10 -2
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +1 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +27 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -0
- package/out/concepts/Variable__.js +6 -3
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +5 -5
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +63 -60
- package/out/concepts/ViewElement__.js +123 -88
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +4 -0
- package/out/concepts/View__.js +26 -10
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +3 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.auth.js +39 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.js +70 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.browser.js +6 -35
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.util.js +0 -29
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/enums/KEYWORDS.js +1 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +98 -72
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/server/createUiTs.d.ts +1 -0
- package/out/server/createUiTs.js +15 -1
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +27 -45
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +3 -3
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +1 -1
- package/out/server/getProcesses.js +2 -2
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -3
- package/out/server/naslServer.js +73 -57
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.d.ts +0 -3
- package/out/server/translator.js +16 -7
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +21 -12
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +3 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +6 -10
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +2 -2
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -0
- package/out/templator/genQueryComponent.js +1 -0
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genUpdateBlock.js +5 -5
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +3 -1
- package/out/templator/utils.js +2 -1
- package/out/templator/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/index.js +1 -1
- package/src/common/BaseNode.ts +46 -42
- package/src/concepts/App__.ts +54 -12
- package/src/concepts/Argument__.ts +3 -2
- package/src/concepts/BinaryExpression__.ts +8 -6
- package/src/concepts/BindAttribute__.ts +26 -32
- package/src/concepts/BindDirective__.ts +24 -9
- package/src/concepts/BindEvent__.ts +25 -29
- package/src/concepts/CallFunction__.ts +11 -6
- package/src/concepts/CallInterface__.ts +11 -1
- package/src/concepts/CallLogic__.ts +21 -40
- package/src/concepts/CallQueryComponent__.ts +6 -10
- package/src/concepts/Comment__.ts +6 -2
- package/src/concepts/ConfigGroup__.ts +1 -1
- package/src/concepts/ConfigProperty__.ts +1 -1
- package/src/concepts/Configuration__.ts +1 -1
- package/src/concepts/Destination__.ts +9 -7
- package/src/concepts/EntityProperty__.ts +36 -0
- package/src/concepts/Entity__.ts +63 -50
- package/src/concepts/Enum__.ts +1 -1
- package/src/concepts/Event__.ts +1 -1
- package/src/concepts/ForEachStatement__.ts +8 -13
- package/src/concepts/Function__.ts +4 -4
- package/src/concepts/Identifier__.ts +15 -18
- package/src/concepts/IfStatement__.ts +2 -2
- package/src/concepts/InterfaceParam__.ts +11 -0
- package/src/concepts/Interface__.ts +3 -3
- package/src/concepts/LogicItem__.ts +15 -0
- package/src/concepts/Logic__.ts +34 -50
- package/src/concepts/Module__.ts +8 -8
- package/src/concepts/Namespace__.ts +12 -12
- package/src/concepts/Param__.ts +3 -0
- package/src/concepts/ProcessComponent__.ts +2 -2
- package/src/concepts/ProcessElement__.ts +5 -5
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +4 -4
- package/src/concepts/QueryFromExpression__.ts +1 -1
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/QuerySelectExpression__.ts +1 -1
- package/src/concepts/Return__.ts +6 -3
- package/src/concepts/StringLiteral__.ts +2 -2
- package/src/concepts/StructureProperty__.ts +36 -29
- package/src/concepts/Structure__.ts +3 -3
- package/src/concepts/SwitchCase__.ts +3 -3
- package/src/concepts/SwitchStatement__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +8 -2
- package/src/concepts/UnaryExpression__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +24 -1
- package/src/concepts/Variable__.ts +6 -3
- package/src/concepts/ViewComponent__.ts +5 -5
- package/src/concepts/ViewElement__.ts +183 -147
- package/src/concepts/View__.ts +30 -32
- package/src/concepts/WhileStatement__.ts +1 -1
- package/src/concepts/basics/stdlib/index.ts +3 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +35 -0
- package/src/concepts/basics/stdlib/nasl.browser.ts +7 -41
- package/src/concepts/basics/stdlib/nasl.configuration.ts +21 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +0 -29
- package/src/enums/KEYWORDS.ts +1 -0
- package/src/generator/genBundleFiles.ts +102 -74
- package/src/server/createUiTs.ts +18 -3
- package/src/server/getLogics.ts +29 -47
- package/src/server/getMemberIdentifier.ts +3 -3
- package/src/server/getProcesses.ts +2 -2
- package/src/server/naslServer.ts +84 -62
- package/src/server/translator.ts +18 -6
- package/src/service/storage/init.ts +20 -13
- package/src/templator/genCreateBlock.ts +3 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +22 -23
- package/src/templator/genCurdMultipleKeyBlock.ts +2 -2
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genQueryComponent.ts +1 -0
- package/src/templator/genUpdateBlock.ts +5 -6
- package/src/templator/utils.ts +2 -1
|
@@ -86,7 +86,8 @@ function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
|
|
|
86
86
|
}
|
|
87
87
|
} else if (astNode.type === 'MemberExpression') {
|
|
88
88
|
if (astNode.object?.name === '$global') {
|
|
89
|
-
|
|
89
|
+
// 目前只有权限相关的
|
|
90
|
+
node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
|
|
90
91
|
} else {
|
|
91
92
|
node = {
|
|
92
93
|
concept: 'MemberExpression',
|
|
@@ -305,24 +306,24 @@ export class ViewElement extends BaseNode {
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
/**
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
* 插入元素绑定属性
|
|
310
|
+
* @internal
|
|
311
|
+
* @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
|
|
312
|
+
*/
|
|
312
313
|
_insertBindAttributeAt(name: string, index: number): BindAttribute;
|
|
313
314
|
|
|
314
315
|
/**
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
316
|
+
* 插入元素绑定属性
|
|
317
|
+
* @internal
|
|
318
|
+
* @param bindAttributeOptions 元素绑定属性参数
|
|
319
|
+
*/
|
|
319
320
|
_insertBindAttributeAt(bindAttributeOptions: Partial<BindAttribute>, index: number): BindAttribute;
|
|
320
321
|
|
|
321
322
|
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
323
|
+
* 插入元素绑定属性
|
|
324
|
+
* @internal
|
|
325
|
+
* @param bindAttribute 已有的元素绑定属性实例
|
|
326
|
+
*/
|
|
326
327
|
_insertBindAttributeAt(bindAttribute: BindAttribute, index: number): BindAttribute;
|
|
327
328
|
|
|
328
329
|
_insertBindAttributeAt(options: string | Partial<BindAttribute> | BindAttribute, index: number) {
|
|
@@ -340,7 +341,7 @@ export class ViewElement extends BaseNode {
|
|
|
340
341
|
name: options,
|
|
341
342
|
}, this, 'bindAttrs');
|
|
342
343
|
} else if (options instanceof BindAttribute) {
|
|
343
|
-
options.
|
|
344
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
344
345
|
bindAttribute = options;
|
|
345
346
|
Object.assign(bindAttribute, relationOptions);
|
|
346
347
|
} else {
|
|
@@ -446,24 +447,24 @@ export class ViewElement extends BaseNode {
|
|
|
446
447
|
}
|
|
447
448
|
|
|
448
449
|
/**
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
450
|
+
* 插入元素绑定事件
|
|
451
|
+
* @internal
|
|
452
|
+
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
453
|
+
*/
|
|
453
454
|
_insertBindEventAt(name: string, index: number): BindEvent;
|
|
454
455
|
|
|
455
456
|
/**
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
457
|
+
* 插入元素绑定事件
|
|
458
|
+
* @internal
|
|
459
|
+
* @param bindEventOptions 元素绑定事件参数
|
|
460
|
+
*/
|
|
460
461
|
_insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
|
|
461
462
|
|
|
462
463
|
/**
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
464
|
+
* 插入元素绑定事件
|
|
465
|
+
* @internal
|
|
466
|
+
* @param bindEvent 已有的元素绑定事件实例
|
|
467
|
+
*/
|
|
467
468
|
_insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
|
|
468
469
|
|
|
469
470
|
_insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
|
|
@@ -481,7 +482,7 @@ export class ViewElement extends BaseNode {
|
|
|
481
482
|
name: options,
|
|
482
483
|
}, this, 'bindEvents');
|
|
483
484
|
} else if (options instanceof BindEvent) {
|
|
484
|
-
options.
|
|
485
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
485
486
|
bindEvent = options;
|
|
486
487
|
Object.assign(bindEvent, relationOptions);
|
|
487
488
|
} else {
|
|
@@ -587,24 +588,24 @@ export class ViewElement extends BaseNode {
|
|
|
587
588
|
}
|
|
588
589
|
|
|
589
590
|
/**
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
591
|
+
* 插入元素指令
|
|
592
|
+
* @internal
|
|
593
|
+
* @param name 元素指令名称,如果不填会自动生成一个唯一名称
|
|
594
|
+
*/
|
|
594
595
|
_insertBindDirectiveAt(name: string, index: number): BindDirective;
|
|
595
596
|
|
|
596
597
|
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
598
|
+
* 插入元素指令
|
|
599
|
+
* @internal
|
|
600
|
+
* @param bindDirectiveOptions 元素指令参数
|
|
601
|
+
*/
|
|
601
602
|
_insertBindDirectiveAt(bindDirectiveOptions: Partial<BindDirective>, index: number): BindDirective;
|
|
602
603
|
|
|
603
604
|
/**
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
605
|
+
* 插入元素指令
|
|
606
|
+
* @internal
|
|
607
|
+
* @param bindDirective 已有的元素指令实例
|
|
608
|
+
*/
|
|
608
609
|
_insertBindDirectiveAt(bindDirective: BindDirective, index: number): BindDirective;
|
|
609
610
|
|
|
610
611
|
_insertBindDirectiveAt(options: string | Partial<BindDirective> | BindDirective, index: number) {
|
|
@@ -622,7 +623,7 @@ export class ViewElement extends BaseNode {
|
|
|
622
623
|
name: options,
|
|
623
624
|
}, this, 'bindDirectives');
|
|
624
625
|
} else if (options instanceof BindDirective) {
|
|
625
|
-
options.
|
|
626
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
626
627
|
bindDirective = options;
|
|
627
628
|
Object.assign(bindDirective, relationOptions);
|
|
628
629
|
} else {
|
|
@@ -720,24 +721,24 @@ export class ViewElement extends BaseNode {
|
|
|
720
721
|
}
|
|
721
722
|
|
|
722
723
|
/**
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
724
|
+
* 插入页面元素
|
|
725
|
+
* @internal
|
|
726
|
+
* @param name 页面元素名称,如果不填会自动生成一个唯一名称
|
|
727
|
+
*/
|
|
727
728
|
_insertViewElementAt(name: string, index: number): ViewElement;
|
|
728
729
|
|
|
729
730
|
/**
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
731
|
+
* 插入页面元素
|
|
732
|
+
* @internal
|
|
733
|
+
* @param viewElementOptions 页面元素参数
|
|
734
|
+
*/
|
|
734
735
|
_insertViewElementAt(viewElementOptions: Partial<ViewElement>, index: number): ViewElement;
|
|
735
736
|
|
|
736
737
|
/**
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
738
|
+
* 插入页面元素
|
|
739
|
+
* @internal
|
|
740
|
+
* @param viewElement 已有的页面元素实例
|
|
741
|
+
*/
|
|
741
742
|
_insertViewElementAt(viewElement: ViewElement, index: number): ViewElement;
|
|
742
743
|
|
|
743
744
|
_insertViewElementAt(options: string | Partial<ViewElement> | ViewElement, index: number) {
|
|
@@ -755,7 +756,7 @@ export class ViewElement extends BaseNode {
|
|
|
755
756
|
name: options,
|
|
756
757
|
}, this, 'children');
|
|
757
758
|
} else if (options instanceof ViewElement) {
|
|
758
|
-
options.
|
|
759
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
759
760
|
viewElement = options;
|
|
760
761
|
Object.assign(viewElement, relationOptions);
|
|
761
762
|
} else {
|
|
@@ -853,9 +854,9 @@ export class ViewElement extends BaseNode {
|
|
|
853
854
|
}
|
|
854
855
|
|
|
855
856
|
/**
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
857
|
+
* 删除元素绑定属性
|
|
858
|
+
* @param name 元素绑定属性名称
|
|
859
|
+
*/
|
|
859
860
|
removeBindAttribute(name: string): void;
|
|
860
861
|
|
|
861
862
|
/**
|
|
@@ -901,9 +902,9 @@ export class ViewElement extends BaseNode {
|
|
|
901
902
|
}
|
|
902
903
|
|
|
903
904
|
/**
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
905
|
+
* 删除元素绑定事件
|
|
906
|
+
* @param name 元素绑定事件名称
|
|
907
|
+
*/
|
|
907
908
|
removeBindEvent(name: string): void;
|
|
908
909
|
|
|
909
910
|
/**
|
|
@@ -949,9 +950,9 @@ export class ViewElement extends BaseNode {
|
|
|
949
950
|
}
|
|
950
951
|
|
|
951
952
|
/**
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
953
|
+
* 删除元素指令
|
|
954
|
+
* @param name 元素指令名称
|
|
955
|
+
*/
|
|
955
956
|
removeBindDirective(name: string): void;
|
|
956
957
|
|
|
957
958
|
/**
|
|
@@ -997,9 +998,9 @@ export class ViewElement extends BaseNode {
|
|
|
997
998
|
}
|
|
998
999
|
|
|
999
1000
|
/**
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1001
|
+
* 删除页面元素
|
|
1002
|
+
* @param name 页面元素名称
|
|
1003
|
+
*/
|
|
1003
1004
|
removeViewElement(name: string): void;
|
|
1004
1005
|
|
|
1005
1006
|
/**
|
|
@@ -1053,7 +1054,7 @@ export class ViewElement extends BaseNode {
|
|
|
1053
1054
|
get parentAuth() {
|
|
1054
1055
|
const _nameSpace = this.view.getNamespace();
|
|
1055
1056
|
const mainViewName = _nameSpace.split('.')[2];
|
|
1056
|
-
return this.app.views.find((item) => item.name === mainViewName)?.auth;
|
|
1057
|
+
return this.view.parentNode.concept === 'App' ? this.view.auth : this.app.views.find((item) => item.name === mainViewName)?.auth;
|
|
1057
1058
|
}
|
|
1058
1059
|
|
|
1059
1060
|
getViewElementUniqueName(name = 'viewElement1') {
|
|
@@ -1092,8 +1093,9 @@ export class ViewElement extends BaseNode {
|
|
|
1092
1093
|
}
|
|
1093
1094
|
|
|
1094
1095
|
haveScope(node: ViewElement): boolean {
|
|
1095
|
-
|
|
1096
|
-
const
|
|
1096
|
+
// uGallery 没有子集不需要scope
|
|
1097
|
+
const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
|
|
1098
|
+
const dataSourceH5List = ['vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
|
|
1097
1099
|
const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
|
|
1098
1100
|
return dataSourceList.includes(node.toHump(node.tag));
|
|
1099
1101
|
}
|
|
@@ -1231,6 +1233,11 @@ export class ViewElement extends BaseNode {
|
|
|
1231
1233
|
tabSize: state.tabSize + 2,
|
|
1232
1234
|
})) + ',\n';
|
|
1233
1235
|
}
|
|
1236
|
+
if (Array.isArray(attr.rules) && attr.rules.length) {
|
|
1237
|
+
attr.rules.forEach((item) => {
|
|
1238
|
+
code += item.toEmbeddedTS(shiftState(state, code)) + ',\n';
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1234
1241
|
});
|
|
1235
1242
|
this.bindDirectives.forEach((directive) => {
|
|
1236
1243
|
if (directive.expression) {
|
|
@@ -1336,6 +1343,11 @@ export class ViewElement extends BaseNode {
|
|
|
1336
1343
|
*/
|
|
1337
1344
|
private static _fromASTNode(astNode: compiler.ASTElement, context?: ParseContext): ViewElement {
|
|
1338
1345
|
const view: View = context?.view;
|
|
1346
|
+
// 从祖先节点收集的slot列表
|
|
1347
|
+
let slotScopeList: string[] = [];
|
|
1348
|
+
if (Array.isArray(context?.slotScopeList)) {
|
|
1349
|
+
slotScopeList = [...context?.slotScopeList];
|
|
1350
|
+
}
|
|
1339
1351
|
// 临时处理组件的 text
|
|
1340
1352
|
//h5-mock
|
|
1341
1353
|
if (
|
|
@@ -1350,13 +1362,13 @@ export class ViewElement extends BaseNode {
|
|
|
1350
1362
|
});
|
|
1351
1363
|
astNode.children = [];
|
|
1352
1364
|
}
|
|
1353
|
-
|
|
1354
1365
|
// 将 scopedSlots 合并到 children 中
|
|
1355
1366
|
if (astNode.scopedSlots) {
|
|
1356
1367
|
astNode.children = astNode.children || [];
|
|
1357
1368
|
Object.keys(astNode.scopedSlots).forEach((key) => {
|
|
1358
|
-
if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget))
|
|
1369
|
+
if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget)) {
|
|
1359
1370
|
astNode.children.unshift(astNode.scopedSlots[key]);
|
|
1371
|
+
}
|
|
1360
1372
|
});
|
|
1361
1373
|
delete astNode.scopedSlots;
|
|
1362
1374
|
}
|
|
@@ -1375,8 +1387,17 @@ export class ViewElement extends BaseNode {
|
|
|
1375
1387
|
} else {
|
|
1376
1388
|
astNode.tag = 'u-router-view';
|
|
1377
1389
|
}
|
|
1390
|
+
} else if (astNode.tag === 'template') {
|
|
1391
|
+
slotScopeList.unshift(astNode.slotScope);
|
|
1378
1392
|
}
|
|
1379
1393
|
const tagName = astNode.tag.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1394
|
+
let newContext: any = {};
|
|
1395
|
+
if (context) {
|
|
1396
|
+
newContext = {
|
|
1397
|
+
...context,
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
newContext.slotScopeList = slotScopeList;
|
|
1380
1401
|
element = new ViewElement({
|
|
1381
1402
|
tag: astNode.tag,
|
|
1382
1403
|
name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
|
|
@@ -1384,45 +1405,43 @@ export class ViewElement extends BaseNode {
|
|
|
1384
1405
|
staticStyle: astNode.attrsMap.style,
|
|
1385
1406
|
slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
|
|
1386
1407
|
slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
|
|
1387
|
-
children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement,
|
|
1408
|
+
children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement, newContext)) as unknown as Array<ViewElement>,
|
|
1388
1409
|
});
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
&&
|
|
1392
|
-
|
|
1393
|
-
|
|
1410
|
+
astNode?.attrs?.forEach((oldAttr) => {
|
|
1411
|
+
let attr: BindAttribute;
|
|
1412
|
+
if (oldAttr.value === '""' && (oldAttr as any).end - (oldAttr as any).start === oldAttr.name.length) {
|
|
1413
|
+
attr = new BindAttribute({
|
|
1414
|
+
type: 'static',
|
|
1415
|
+
name: oldAttr.name,
|
|
1416
|
+
value: 'true',
|
|
1417
|
+
});
|
|
1418
|
+
} else {
|
|
1419
|
+
try {
|
|
1420
|
+
const tmp = json5.parse(oldAttr.value);
|
|
1421
|
+
const source: any = {
|
|
1422
|
+
type: typeof tmp === 'string' ? 'string' : 'static',
|
|
1423
|
+
name: oldAttr.name,
|
|
1424
|
+
value: typeof tmp === 'string' ? tmp : oldAttr.value,
|
|
1425
|
+
};
|
|
1426
|
+
if (oldAttr.name === 'rules') {
|
|
1427
|
+
source.rules = tmp?.split('|').map((ruleStr: string) => this._parseValidationRule(ruleStr.trim()));
|
|
1428
|
+
}
|
|
1429
|
+
attr = new BindAttribute(source);
|
|
1430
|
+
} catch (e) {
|
|
1431
|
+
const expression = <any> this._parseExpression(oldAttr.value);
|
|
1394
1432
|
attr = new BindAttribute({
|
|
1395
|
-
type: '
|
|
1433
|
+
type: 'dynamic',
|
|
1396
1434
|
name: oldAttr.name,
|
|
1397
|
-
value: '
|
|
1435
|
+
value: expression ? '' : oldAttr.value,
|
|
1436
|
+
expression,
|
|
1398
1437
|
});
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
const tmp = json5.parse(oldAttr.value);
|
|
1402
|
-
const source: any = {
|
|
1403
|
-
type: typeof tmp === 'string' ? 'string' : 'static',
|
|
1404
|
-
name: oldAttr.name,
|
|
1405
|
-
value: typeof tmp === 'string' ? tmp : oldAttr.value,
|
|
1406
|
-
};
|
|
1407
|
-
if (oldAttr.name === 'rules') {
|
|
1408
|
-
source.rules = tmp?.split('|').map((ruleStr: string) => this._parseValidationRule(ruleStr.trim()));
|
|
1409
|
-
}
|
|
1410
|
-
attr = new BindAttribute(source);
|
|
1411
|
-
} catch (e) {
|
|
1412
|
-
const expression = <any> this._parseExpression(oldAttr.value);
|
|
1413
|
-
attr = new BindAttribute({
|
|
1414
|
-
type: 'dynamic',
|
|
1415
|
-
name: oldAttr.name,
|
|
1416
|
-
value: expression ? '' : oldAttr.value,
|
|
1417
|
-
expression,
|
|
1418
|
-
});
|
|
1419
|
-
if (astNode.attrsMap[`:${attr.name}.sync`]) {
|
|
1420
|
-
attr.sync = true;
|
|
1421
|
-
}
|
|
1438
|
+
if (astNode.attrsMap[`:${attr.name}.sync`]) {
|
|
1439
|
+
attr.sync = true;
|
|
1422
1440
|
}
|
|
1423
1441
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1442
|
+
}
|
|
1443
|
+
element.addBindAttribute(attr);
|
|
1444
|
+
});
|
|
1426
1445
|
|
|
1427
1446
|
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
1428
1447
|
astNode.events
|
|
@@ -1437,19 +1456,24 @@ export class ViewElement extends BaseNode {
|
|
|
1437
1456
|
if (matchArr?.length >= 2) {
|
|
1438
1457
|
argsStr = matchArr[1];
|
|
1439
1458
|
}
|
|
1459
|
+
const newArgList = ['$event', ...slotScopeList];
|
|
1440
1460
|
let args: any[] = [];
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1461
|
+
const argStrs: string[] = argsStr.split(',');
|
|
1462
|
+
argStrs.forEach((argStr) => {
|
|
1463
|
+
const index = newArgList.indexOf(argStr.trim());
|
|
1464
|
+
if (index !== -1) {
|
|
1465
|
+
newArgList.splice(index, 1);
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
argStrs.push(...newArgList);
|
|
1469
|
+
args = argStrs.filter((argStr) => !!argStr && argStr !== '_empty_').map((argStr) => {
|
|
1470
|
+
const keyword = argStr.trim().split('.');
|
|
1471
|
+
return {
|
|
1472
|
+
concept: 'Argument',
|
|
1473
|
+
expression: genArgumentMemberExpression(keyword),
|
|
1474
|
+
};
|
|
1475
|
+
});
|
|
1476
|
+
let calleeNamespace = '';
|
|
1453
1477
|
if (calleeName) {
|
|
1454
1478
|
const namespaceArr = calleeName.split('.');
|
|
1455
1479
|
const start = namespaceArr.shift();
|
|
@@ -1504,15 +1528,12 @@ export class ViewElement extends BaseNode {
|
|
|
1504
1528
|
}));
|
|
1505
1529
|
}
|
|
1506
1530
|
} else if (astNode.type === 2) {
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
tag: 'u-text',
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1531
|
+
const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1532
|
+
const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1533
|
+
element = new ViewElement({
|
|
1534
|
+
tag: tagName,
|
|
1535
|
+
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1536
|
+
});
|
|
1516
1537
|
const value = astNode.text.match(/{{(.*?)}}/)[1].trim();
|
|
1517
1538
|
const expression = <any> this._parseExpression(value);
|
|
1518
1539
|
element.addBindAttribute(new BindAttribute({
|
|
@@ -1522,15 +1543,12 @@ export class ViewElement extends BaseNode {
|
|
|
1522
1543
|
expression,
|
|
1523
1544
|
}));
|
|
1524
1545
|
} else if (astNode.type === 3) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
tag: 'u-text',
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1546
|
+
const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1547
|
+
const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1548
|
+
element = new ViewElement({
|
|
1549
|
+
tag: tagName,
|
|
1550
|
+
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1551
|
+
});
|
|
1534
1552
|
element.addBindAttribute(new BindAttribute({
|
|
1535
1553
|
name: 'text',
|
|
1536
1554
|
type: 'string',
|
|
@@ -1557,24 +1575,14 @@ export class ViewElement extends BaseNode {
|
|
|
1557
1575
|
let ast = compiler.compile(html, compilerOptions).ast;
|
|
1558
1576
|
if (ast.tag === 'template' && !ast.slotTarget)
|
|
1559
1577
|
ast = ast.children[0] as compiler.ASTElement;
|
|
1560
|
-
|
|
1561
|
-
let root: ViewElement;
|
|
1562
|
-
utils.traverse((current) => {
|
|
1563
|
-
// 处理 scopedSlots;
|
|
1564
|
-
if (!current.parent)
|
|
1565
|
-
root = this._fromASTNode(current.node, context);
|
|
1566
|
-
else
|
|
1567
|
-
(current.parent.children as any)[current.index] = this._fromASTNode(current.node, context);
|
|
1568
|
-
}, { node: ast });
|
|
1569
|
-
return root;
|
|
1578
|
+
return this._fromASTNode(ast, context);
|
|
1570
1579
|
}
|
|
1571
1580
|
|
|
1572
1581
|
/**
|
|
1573
1582
|
* 从模板生成规范的 ViewElement 对象
|
|
1574
1583
|
*/
|
|
1575
1584
|
public static fromHTML(html: string, context?: ParseContext) {
|
|
1576
|
-
|
|
1577
|
-
return element;
|
|
1585
|
+
return this.parse(html, context);
|
|
1578
1586
|
}
|
|
1579
1587
|
|
|
1580
1588
|
/**
|
|
@@ -1613,7 +1621,12 @@ export class ViewElement extends BaseNode {
|
|
|
1613
1621
|
if (apiOfAttr && !apiOfAttr.type.includes('string'))
|
|
1614
1622
|
return '';
|
|
1615
1623
|
}
|
|
1616
|
-
|
|
1624
|
+
value = value
|
|
1625
|
+
.replace(/"/g, "'")
|
|
1626
|
+
.replace(/\$utils\['(.+?)'\]/g, '$1')
|
|
1627
|
+
.replace(/\$refs./g, 'elements.')
|
|
1628
|
+
.replace(/\$global./g, 'nasl.auth.');
|
|
1629
|
+
return `${name}="{{ ${value} }}"`;
|
|
1617
1630
|
});
|
|
1618
1631
|
else
|
|
1619
1632
|
return defaultResult;
|
|
@@ -1728,11 +1741,34 @@ export class ViewElement extends BaseNode {
|
|
|
1728
1741
|
let params: Params = null;
|
|
1729
1742
|
if (this.parentNode) {
|
|
1730
1743
|
params = (this.parentNode as any)?.__removeViewElement?.(this);
|
|
1731
|
-
|
|
1744
|
+
this.traverseChildren((ele: ViewElement) => {
|
|
1745
|
+
(this.view as any)?.removeExistingViewElement(ele);
|
|
1746
|
+
});
|
|
1732
1747
|
}
|
|
1733
1748
|
return params;
|
|
1734
1749
|
}
|
|
1735
1750
|
|
|
1751
|
+
findElementByName(name: string): ViewElement {
|
|
1752
|
+
return utils.traverse((current) => {
|
|
1753
|
+
if (current.node.name === name)
|
|
1754
|
+
return current.node;
|
|
1755
|
+
}, { node: this });
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
findElementByTag(tag: string): ViewElement {
|
|
1759
|
+
return utils.traverse((current) => {
|
|
1760
|
+
if (current.node.tag === tag)
|
|
1761
|
+
return current.node;
|
|
1762
|
+
}, { node: this });
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
findElementByAttr(name: string, value: string): ViewElement {
|
|
1766
|
+
return utils.traverse((current) => {
|
|
1767
|
+
if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
|
|
1768
|
+
return current.node;
|
|
1769
|
+
}, { node: this });
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1736
1772
|
//================================================================================
|
|
1737
1773
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
1738
1774
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|