@lcap/nasl 3.4.0-beta.3 → 3.4.0-beta.4
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.d.ts +4 -4
- package/out/automate/engine/index.js +363 -363
- package/out/automate/engine/operators.d.ts +26 -16
- package/out/automate/engine/operators.js +363 -363
- package/out/automate/engine/uniqueName.d.ts +12 -12
- package/out/automate/engine/uniqueName.js +111 -111
- package/out/automate/engine/utils.d.ts +25 -25
- package/out/automate/engine/utils.js +443 -443
- package/out/automate/engine/viewCache.d.ts +19 -18
- package/out/automate/engine/viewCache.js +44 -44
- package/out/automate/template/myProcess.d.ts +10 -9
- package/out/automate/template/myProcess.js +11501 -11500
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/automate/upgrader/2.12.d.ts +7 -7
- package/out/automate/upgrader/2.12.js +62 -62
- package/out/automate/upgrader/2.14-components.d.ts +1115 -1115
- package/out/automate/upgrader/2.14-components.js +1086 -1086
- package/out/automate/upgrader/2.14.d.ts +10 -10
- package/out/automate/upgrader/2.14.js +235 -235
- package/out/automate/upgrader/2.14.old.d.ts +1 -1
- package/out/automate/upgrader/2.14.old.js +124 -124
- package/out/automate/upgrader/2.16.d.ts +10 -10
- package/out/automate/upgrader/2.16.js +74 -74
- package/out/automate/upgrader/2.17.d.ts +21 -21
- package/out/automate/upgrader/2.17.js +556 -556
- package/out/automate/upgrader/2.18.d.ts +10 -10
- package/out/automate/upgrader/2.18.js +106 -106
- package/out/automate/upgrader/2.20.d.ts +17 -17
- package/out/automate/upgrader/2.20.js +67 -67
- package/out/bak/translator.d.ts +1 -1
- package/out/bak/translator.js +143 -143
- package/out/breakpoint/generator/AfterStartNode.d.ts +7 -7
- package/out/breakpoint/generator/AfterStartNode.js +29 -29
- package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -7
- package/out/breakpoint/generator/BeforeEndNode.js +27 -27
- package/out/breakpoint/generator/BreakpointNode.d.ts +15 -15
- package/out/breakpoint/generator/BreakpointNode.js +283 -283
- package/out/breakpoint/generator/CallbackNode.d.ts +4 -4
- package/out/breakpoint/generator/CallbackNode.js +21 -21
- package/out/breakpoint/generator/FragmentNode.d.ts +4 -4
- package/out/breakpoint/generator/FragmentNode.js +17 -17
- package/out/breakpoint/generator/index.d.ts +4 -4
- package/out/breakpoint/generator/index.js +118 -118
- package/out/breakpoint/index.d.ts +3 -3
- package/out/breakpoint/index.js +19 -19
- package/out/breakpoint/shared/constants.d.ts +37 -37
- package/out/breakpoint/shared/constants.js +105 -105
- package/out/breakpoint/shared/index.d.ts +3 -3
- package/out/breakpoint/shared/index.js +32 -32
- package/out/breakpoint/shared/operations.d.ts +10 -10
- package/out/breakpoint/shared/operations.js +24 -24
- package/out/breakpoint/shared/socket.d.ts +48 -48
- package/out/breakpoint/shared/socket.js +256 -256
- package/out/breakpoint/shared/utils.d.ts +27 -27
- package/out/breakpoint/shared/utils.js +228 -228
- package/out/breakpoint/store/core.d.ts +80 -80
- package/out/breakpoint/store/core.js +415 -415
- package/out/breakpoint/store/dock.d.ts +1 -1
- package/out/breakpoint/store/dock.js +159 -159
- package/out/breakpoint/store/index.d.ts +2 -2
- package/out/breakpoint/store/index.js +18 -18
- package/out/common/BaseNode.d.ts +347 -334
- package/out/common/BaseNode.js +1376 -1325
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.d.ts +21 -21
- package/out/common/Command.js +78 -78
- package/out/common/ComponentAPI.d.ts +110 -110
- package/out/common/ComponentAPI.js +2 -2
- package/out/common/EventEmitter.d.ts +60 -60
- package/out/common/EventEmitter.js +68 -68
- package/out/common/EventEmitter.js.map +1 -1
- package/out/common/Messager.d.ts +91 -91
- package/out/common/Messager.js +206 -206
- package/out/common/asyncFuncMap.d.ts +2 -2
- package/out/common/asyncFuncMap.js +15 -15
- package/out/common/index.d.ts +3 -3
- package/out/common/index.js +19 -19
- package/out/concepts/Abort__.d.ts +28 -26
- package/out/concepts/Abort__.js +83 -81
- package/out/concepts/Abort__.js.map +1 -1
- package/out/concepts/AbstractInterface__.d.ts +22 -0
- package/out/concepts/AbstractInterface__.js +60 -0
- package/out/concepts/AbstractInterface__.js.map +1 -0
- package/out/concepts/Anchor__.d.ts +48 -46
- package/out/concepts/Anchor__.js +208 -206
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +175 -173
- package/out/concepts/AnonymousFunction__.js +548 -546
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +1770 -1687
- package/out/concepts/App__.js +2777 -2670
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +70 -68
- package/out/concepts/Argument__.js +285 -285
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +291 -289
- package/out/concepts/Assignee__.js +455 -452
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.d.ts +44 -42
- package/out/concepts/AssignmentLine__.js +120 -118
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.d.ts +77 -75
- package/out/concepts/Assignment__.js +328 -327
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.d.ts +112 -110
- package/out/concepts/Attribute__.js +259 -265
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/AuthInterface__.d.ts +38 -36
- package/out/concepts/AuthInterface__.js +86 -85
- package/out/concepts/AuthInterface__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.d.ts +141 -139
- package/out/concepts/AuthLogicForCallInterface__.js +535 -532
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/AuthLogic__.d.ts +69 -67
- package/out/concepts/AuthLogic__.js +222 -221
- package/out/concepts/AuthLogic__.js.map +1 -1
- package/out/concepts/BackendVariable__.d.ts +148 -146
- package/out/concepts/BackendVariable__.js +482 -481
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/Backend__.d.ts +137 -135
- package/out/concepts/Backend__.js +287 -285
- package/out/concepts/Backend__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +255 -253
- package/out/concepts/BatchAssignment__.js +883 -880
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +74 -72
- package/out/concepts/BinaryExpression__.js +398 -398
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +330 -328
- package/out/concepts/BindAttribute__.js +1064 -1071
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +169 -167
- package/out/concepts/BindDirective__.js +558 -562
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +255 -253
- package/out/concepts/BindEvent__.js +943 -942
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +142 -140
- package/out/concepts/BindStyle__.js +424 -423
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +38 -36
- package/out/concepts/BooleanLiteral__.js +109 -108
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.d.ts +128 -126
- package/out/concepts/CallAuthInterface__.js +421 -414
- package/out/concepts/CallAuthInterface__.js.map +1 -1
- package/out/concepts/CallConnector__.d.ts +49 -47
- package/out/concepts/CallConnector__.js +267 -266
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +161 -159
- package/out/concepts/CallFunction__.js +589 -568
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +132 -130
- package/out/concepts/CallInterface__.js +808 -802
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +233 -231
- package/out/concepts/CallLogic__.js +1317 -1319
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +435 -433
- package/out/concepts/CallQueryComponent__.js +1313 -1325
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.d.ts +35 -33
- package/out/concepts/Comment__.js +101 -100
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.d.ts +107 -105
- package/out/concepts/CompletionProperty__.js +279 -283
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +127 -125
- package/out/concepts/ConfigGroup__.js +266 -264
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigPropertyValue__.d.ts +47 -45
- package/out/concepts/ConfigPropertyValue__.js +110 -110
- package/out/concepts/ConfigPropertyValue__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +156 -154
- package/out/concepts/ConfigProperty__.js +334 -334
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +126 -124
- package/out/concepts/Configuration__.js +239 -236
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Connection__.d.ts +168 -166
- package/out/concepts/Connection__.js +347 -347
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/ConnectorTrigger__.d.ts +81 -79
- package/out/concepts/ConnectorTrigger__.js +160 -161
- package/out/concepts/ConnectorTrigger__.js.map +1 -1
- package/out/concepts/Connector__.d.ts +929 -570
- package/out/concepts/Connector__.js +1346 -907
- package/out/concepts/Connector__.js.map +1 -1
- package/out/concepts/Constant__.d.ts +121 -119
- package/out/concepts/Constant__.js +313 -313
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +171 -169
- package/out/concepts/DataSource__.js +477 -477
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/DatabaseTypeAnnotation__.d.ts +34 -32
- package/out/concepts/DatabaseTypeAnnotation__.js +82 -82
- package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
- package/out/concepts/DefaultValue__.d.ts +98 -98
- package/out/concepts/DefaultValue__.js +210 -209
- package/out/concepts/DefaultValue__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +160 -158
- package/out/concepts/Destination__.js +804 -804
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.d.ts +27 -25
- package/out/concepts/End__.js +117 -115
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +98 -96
- package/out/concepts/EntityIndex__.js +227 -229
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +289 -287
- package/out/concepts/EntityProperty__.js +883 -888
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +342 -340
- package/out/concepts/Entity__.js +779 -769
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +67 -65
- package/out/concepts/EnumItem__.js +155 -155
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +141 -139
- package/out/concepts/Enum__.js +341 -341
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.d.ts +146 -144
- package/out/concepts/Event__.js +261 -263
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +78 -76
- package/out/concepts/ExternalDestination__.js +292 -291
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +173 -190
- package/out/concepts/ForEachStatement__.js +533 -534
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +216 -214
- package/out/concepts/FrontendLibrary__.js +374 -372
- package/out/concepts/FrontendLibrary__.js.map +1 -1
- package/out/concepts/FrontendVariable__.d.ts +24 -22
- package/out/concepts/FrontendVariable__.js +66 -63
- package/out/concepts/FrontendVariable__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +511 -509
- package/out/concepts/Frontend__.js +1043 -1003
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.d.ts +420 -418
- package/out/concepts/Function__.js +805 -801
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/I18nInfo__.d.ts +44 -44
- package/out/concepts/I18nInfo__.js +110 -110
- package/out/concepts/I18nInfo__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +54 -52
- package/out/concepts/Identifier__.js +309 -305
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.d.ts +161 -159
- package/out/concepts/IfStatement__.js +353 -352
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Integration__.d.ts +146 -144
- package/out/concepts/Integration__.js +301 -298
- package/out/concepts/Integration__.js.map +1 -1
- package/out/concepts/InterfaceFromExample__.d.ts +88 -0
- package/out/concepts/InterfaceFromExample__.js +172 -0
- package/out/concepts/InterfaceFromExample__.js.map +1 -0
- package/out/concepts/InterfaceParam__.d.ts +151 -144
- package/out/concepts/InterfaceParam__.js +354 -346
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +334 -331
- package/out/concepts/Interface__.js +923 -910
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts +37 -35
- package/out/concepts/JSBlock__.js +113 -112
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/JavaLogic__.d.ts +45 -43
- package/out/concepts/JavaLogic__.js +127 -128
- package/out/concepts/JavaLogic__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +154 -152
- package/out/concepts/LogicItem__.js +289 -291
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +648 -644
- package/out/concepts/Logic__.js +1967 -1946
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +261 -259
- package/out/concepts/MatchCase__.js +703 -693
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +127 -125
- package/out/concepts/Match__.js +697 -695
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +77 -75
- package/out/concepts/MemberExpression__.js +496 -495
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/MicroApp__.d.ts +54 -52
- package/out/concepts/MicroApp__.js +122 -127
- package/out/concepts/MicroApp__.js.map +1 -1
- package/out/concepts/Module__.d.ts +985 -1236
- package/out/concepts/Module__.js +1450 -1756
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/MsgTriggerEvent__.d.ts +140 -138
- package/out/concepts/MsgTriggerEvent__.js +239 -236
- package/out/concepts/MsgTriggerEvent__.js.map +1 -1
- package/out/concepts/MsgTriggerLauncher__.d.ts +129 -127
- package/out/concepts/MsgTriggerLauncher__.js +234 -232
- package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +1086 -1070
- package/out/concepts/Namespace__.js +1546 -1491
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +351 -349
- package/out/concepts/NewComposite__.js +1261 -1311
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +138 -136
- package/out/concepts/NewList__.js +455 -449
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +229 -227
- package/out/concepts/NewMap__.js +600 -589
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/New__.d.ts +23 -21
- package/out/concepts/New__.js +71 -69
- package/out/concepts/New__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +29 -27
- package/out/concepts/NullLiteral__.js +84 -82
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +59 -57
- package/out/concepts/NumericLiteral__.js +190 -189
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +76 -74
- package/out/concepts/OqlQueryComponent__.js +368 -365
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.d.ts +637 -635
- package/out/concepts/OverriddenLogic__.js +1693 -1691
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.d.ts +182 -180
- package/out/concepts/Param__.js +512 -512
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.d.ts +34 -32
- package/out/concepts/Point__.js +82 -82
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.d.ts +222 -220
- package/out/concepts/ProcessComponent__.js +360 -360
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +649 -647
- package/out/concepts/ProcessElement__.js +1335 -1334
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.d.ts +33 -32
- package/out/concepts/ProcessOutcome__.js +108 -92
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.d.ts +33 -32
- package/out/concepts/ProcessOutcomes__.js +110 -93
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.d.ts +616 -614
- package/out/concepts/Process__.js +1139 -1135
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.d.ts +54 -52
- package/out/concepts/QueryAggregateExpression__.js +159 -159
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +56 -54
- package/out/concepts/QueryFieldExpression__.js +163 -164
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +101 -99
- package/out/concepts/QueryFromExpression__.js +220 -220
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +49 -47
- package/out/concepts/QueryGroupByExpression__.js +150 -148
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +188 -186
- package/out/concepts/QueryJoinExpression__.js +347 -348
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.d.ts +60 -58
- package/out/concepts/QueryLimitExpression__.js +172 -171
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +71 -69
- package/out/concepts/QueryOrderByExpression__.js +185 -184
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +206 -204
- package/out/concepts/QuerySelectExpression__.js +311 -308
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.d.ts +42 -40
- package/out/concepts/Rect__.js +98 -100
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.d.ts +147 -145
- package/out/concepts/Return__.js +410 -409
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.d.ts +65 -63
- package/out/concepts/Role__.js +172 -173
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +145 -143
- package/out/concepts/SelectMembers__.js +307 -305
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/Slot__.d.ts +77 -75
- package/out/concepts/Slot__.js +175 -178
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +74 -72
- package/out/concepts/SqlQueryComponent__.js +291 -292
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.d.ts +27 -25
- package/out/concepts/Start__.js +76 -74
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringInterpolation__.d.ts +118 -116
- package/out/concepts/StringInterpolation__.js +275 -272
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +45 -43
- package/out/concepts/StringLiteral__.js +165 -157
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +150 -148
- package/out/concepts/StructureProperty__.js +373 -372
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +252 -248
- package/out/concepts/Structure__.js +521 -506
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +97 -95
- package/out/concepts/SwitchCase__.js +287 -281
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.d.ts +87 -85
- package/out/concepts/SwitchStatement__.js +212 -209
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.d.ts +40 -38
- package/out/concepts/Theme__.js +91 -89
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +90 -88
- package/out/concepts/Transactional__.js +171 -172
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TriggerEvent__.d.ts +123 -121
- package/out/concepts/TriggerEvent__.js +236 -234
- package/out/concepts/TriggerEvent__.js.map +1 -1
- package/out/concepts/TriggerLauncher__.d.ts +84 -82
- package/out/concepts/TriggerLauncher__.js +223 -225
- package/out/concepts/TriggerLauncher__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +304 -299
- package/out/concepts/TypeAnnotation__.js +1054 -1025
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +28 -26
- package/out/concepts/TypeParam__.js +82 -81
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.d.ts +52 -50
- package/out/concepts/UnaryExpression__.js +200 -199
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.d.ts +36 -33
- package/out/concepts/Unparsed__.js +103 -102
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.d.ts +34 -32
- package/out/concepts/UseComponent__.js +82 -82
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +152 -150
- package/out/concepts/ValidationRule__.js +531 -525
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +167 -165
- package/out/concepts/Variable__.js +479 -478
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewBlock__.d.ts +38 -36
- package/out/concepts/ViewBlock__.js +90 -91
- package/out/concepts/ViewBlock__.js.map +1 -1
- package/out/concepts/ViewComponent__.d.ts +568 -566
- package/out/concepts/ViewComponent__.js +819 -816
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +628 -626
- package/out/concepts/ViewElement__.js +2315 -2316
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +725 -723
- package/out/concepts/View__.js +2219 -2217
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.d.ts +100 -98
- package/out/concepts/WhileStatement__.js +251 -247
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/constants.d.ts +1 -0
- package/out/concepts/basics/constants.js +6 -0
- package/out/concepts/basics/constants.js.map +1 -0
- package/out/concepts/basics/stdlib/index.d.ts +4 -4
- package/out/concepts/basics/stdlib/index.js +44 -44
- package/out/concepts/basics/stdlib/nasl.auth.d.ts +7 -7
- package/out/concepts/basics/stdlib/nasl.auth.js +163 -163
- package/out/concepts/basics/stdlib/nasl.browser.d.ts +3 -3
- package/out/concepts/basics/stdlib/nasl.browser.js +148 -148
- package/out/concepts/basics/stdlib/nasl.collection.d.ts +7 -7
- package/out/concepts/basics/stdlib/nasl.collection.js +51 -51
- package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -3
- package/out/concepts/basics/stdlib/nasl.configuration.js +55 -55
- package/out/concepts/basics/stdlib/nasl.core.d.ts +5 -5
- package/out/concepts/basics/stdlib/nasl.core.js +48 -48
- package/out/concepts/basics/stdlib/nasl.event.d.ts +3 -3
- package/out/concepts/basics/stdlib/nasl.event.js +24 -24
- package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -7
- package/out/concepts/basics/stdlib/nasl.http.js +168 -168
- package/out/concepts/basics/stdlib/nasl.interface.d.ts +7 -7
- package/out/concepts/basics/stdlib/nasl.interface.js +42 -42
- package/out/concepts/basics/stdlib/nasl.io.d.ts +3 -3
- package/out/concepts/basics/stdlib/nasl.io.js +51 -51
- package/out/concepts/basics/stdlib/nasl.logging.d.ts +3 -3
- package/out/concepts/basics/stdlib/nasl.logging.js +55 -55
- package/out/concepts/basics/stdlib/nasl.process.d.ts +7 -7
- package/out/concepts/basics/stdlib/nasl.process.js +637 -637
- package/out/concepts/basics/stdlib/nasl.ui.d.ts +7 -7
- package/out/concepts/basics/stdlib/nasl.ui.js +1062 -1062
- package/out/concepts/basics/stdlib/nasl.util.d.ts +5 -5
- package/out/concepts/basics/stdlib/nasl.util.js +2291 -2291
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.d.ts +3 -3
- package/out/concepts/basics/stdlib/nasl.validation.js +564 -564
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.d.ts +5 -5
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +25 -25
- package/out/concepts/basics/stdlib/timeZone.d.ts +5 -5
- package/out/concepts/basics/stdlib/timeZone.js +195 -195
- package/out/concepts/basics/types/coreTypeList.d.ts +2 -2
- package/out/concepts/basics/types/coreTypeList.js +14 -14
- package/out/concepts/basics/types/index.d.ts +16 -16
- package/out/concepts/basics/types/index.js +34 -34
- package/out/concepts/index.d.ts +6 -6
- package/out/concepts/index.js +24 -24
- package/out/concepts/index__.d.ts +126 -124
- package/out/concepts/index__.js +142 -140
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/types__.d.ts +128 -126
- package/out/concepts/types__.js +2 -2
- package/out/config.d.ts +43 -43
- package/out/config.js +71 -71
- package/out/decorators/index.d.ts +69 -57
- package/out/decorators/index.js +216 -172
- package/out/decorators/index.js.map +1 -1
- package/out/decorators/promise.d.ts +7 -7
- package/out/decorators/promise.js +27 -27
- package/out/enums/KEYWORDS.d.ts +6 -6
- package/out/enums/KEYWORDS.js +1245 -1243
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/enums/LEVEL_NAME_MAP.d.ts +26 -26
- package/out/enums/LEVEL_NAME_MAP.js +29 -29
- package/out/eventBus.d.ts +3 -3
- package/out/eventBus.js +6 -6
- package/out/generator/compileComponent.d.ts +11 -11
- package/out/generator/compileComponent.js +11 -11
- package/out/generator/genBundleFiles.d.ts +34 -34
- package/out/generator/genBundleFiles.js +356 -356
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genHash.d.ts +7 -7
- package/out/generator/genHash.js +38 -38
- package/out/generator/genMetaData.d.ts +31 -31
- package/out/generator/genMetaData.js +305 -301
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +72 -72
- package/out/generator/genReleaseBody.js +323 -321
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/icestark.d.ts +2 -2
- package/out/generator/icestark.js +7 -5
- package/out/generator/icestark.js.map +1 -1
- package/out/generator/index.d.ts +7 -7
- package/out/generator/index.js +23 -23
- package/out/generator/microApp.d.ts +2 -2
- package/out/generator/microApp.js +35 -35
- package/out/generator/permission.d.ts +10 -10
- package/out/generator/permission.js +269 -269
- package/out/generator/qiankun.d.ts +2 -2
- package/out/generator/qiankun.js +6 -4
- package/out/generator/qiankun.js.map +1 -1
- package/out/generator/styleReplacer.d.ts +3 -3
- package/out/generator/styleReplacer.js +67 -67
- package/out/index.d.ts +13 -13
- package/out/index.js +66 -66
- package/out/manager/diagnostic.d.ts +35 -35
- package/out/manager/diagnostic.js +62 -62
- package/out/manager/stepRecorder.d.ts +20 -20
- package/out/manager/stepRecorder.js +108 -108
- package/out/natural/componentData.d.ts +31 -31
- package/out/natural/componentData.js +84 -84
- package/out/natural/genNaturalTS.d.ts +3 -3
- package/out/natural/genNaturalTS.js +89 -90
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/index.d.ts +2 -2
- package/out/natural/index.js +18 -18
- package/out/natural/naslStdlibMap.d.ts +2 -2
- package/out/natural/naslStdlibMap.js +25 -25
- package/out/natural/transformTSCode.d.ts +7 -7
- package/out/natural/transformTSCode.js +919 -877
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/sentry/index.d.ts +34 -34
- package/out/sentry/index.js +148 -147
- package/out/sentry/index.js.map +1 -1
- package/out/server/createUiTs.d.ts +16 -16
- package/out/server/createUiTs.js +242 -242
- package/out/server/entity2LogicNamespace.d.ts +10 -10
- package/out/server/entity2LogicNamespace.js +381 -381
- package/out/server/event.d.ts +30 -30
- package/out/server/event.js +150 -150
- package/out/server/extendBaseNode.d.ts +1 -1
- package/out/server/extendBaseNode.js +574 -543
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +37 -37
- package/out/server/formatTsUtils.js +851 -851
- package/out/server/getConnector.d.ts +14 -14
- package/out/server/getConnector.js +77 -77
- package/out/server/getExtensionModules.d.ts +3 -3
- package/out/server/getExtensionModules.js +33 -33
- package/out/server/getFunctions.d.ts +3 -3
- package/out/server/getFunctions.js +19 -19
- package/out/server/getInterfaces.d.ts +2 -2
- package/out/server/getInterfaces.js +47 -47
- package/out/server/getLogging.d.ts +1 -1
- package/out/server/getLogging.js +8 -8
- package/out/server/getLogics.d.ts +4 -4
- package/out/server/getLogics.js +380 -380
- package/out/server/getMemberIdentifier.d.ts +17 -17
- package/out/server/getMemberIdentifier.js +508 -508
- package/out/server/getProcessComponents.d.ts +2 -2
- package/out/server/getProcessComponents.js +12 -12
- package/out/server/getProcesses.d.ts +33 -33
- package/out/server/getProcesses.js +596 -596
- package/out/server/getScope.d.ts +13 -13
- package/out/server/getScope.js +60 -60
- package/out/server/getValidates.d.ts +3 -3
- package/out/server/getValidates.js +13 -13
- package/out/server/index.d.ts +5 -5
- package/out/server/index.js +41 -41
- package/out/server/naslServer.d.ts +375 -371
- package/out/server/naslServer.js +4706 -4585
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.d.ts +2 -2
- package/out/server/naslStdlibMap.js +53 -53
- package/out/server/process2LogicNamespace.d.ts +26 -26
- package/out/server/process2LogicNamespace.js +108 -108
- package/out/server/translator.d.ts +26 -26
- package/out/server/translator.js +819 -805
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/add.configs.d.ts +1 -1
- package/out/service/creator/add.configs.js +102 -102
- package/out/service/creator/errHandles.d.ts +18 -18
- package/out/service/creator/errHandles.js +67 -67
- package/out/service/creator/index.d.ts +1 -1
- package/out/service/creator/index.js +86 -86
- package/out/service/datasource/api.d.ts +12 -12
- package/out/service/datasource/api.js +13 -13
- package/out/service/datasource/index.d.ts +2 -2
- package/out/service/datasource/index.js +9 -9
- package/out/service/defaultErrorMessage.json +98 -98
- package/out/service/logic/api.d.ts +9 -9
- package/out/service/logic/api.js +10 -10
- package/out/service/logic/checktypeSocket.d.ts +5 -5
- package/out/service/logic/checktypeSocket.js +54 -54
- package/out/service/logic/index.d.ts +2 -2
- package/out/service/logic/index.js +9 -9
- package/out/service/storage/api.d.ts +54 -54
- package/out/service/storage/api.js +41 -41
- package/out/service/storage/index.d.ts +2 -2
- package/out/service/storage/index.js +9 -9
- package/out/service/storage/init.d.ts +102 -102
- package/out/service/storage/init.js +1161 -1161
- package/out/service/storage/jsoner.d.ts +36 -36
- package/out/service/storage/jsoner.js +128 -130
- package/out/service/storage/jsoner.js.map +1 -1
- package/out/service/storage/map.d.ts +4 -4
- package/out/service/storage/map.js +53 -53
- package/out/service/storage/service.d.ts +25 -25
- package/out/service/storage/service.js +79 -79
- package/out/service/storage/storagePoint.d.ts +17 -17
- package/out/service/storage/storagePoint.js +75 -75
- package/out/service/video/BaseService.d.ts +7 -7
- package/out/service/video/BaseService.js +60 -60
- package/out/service/video/MainCallbackService.d.ts +12 -12
- package/out/service/video/MainCallbackService.js +182 -182
- package/out/service/video/VideoTranscribe.d.ts +15 -15
- package/out/service/video/VideoTranscribe.js +95 -95
- package/out/service/video/publishService.d.ts +1 -1
- package/out/service/video/publishService.js +57 -57
- package/out/templator/genCallComponentLogic.d.ts +17 -17
- package/out/templator/genCallComponentLogic.js +28 -28
- package/out/templator/genCreateBlock.d.ts +10 -10
- package/out/templator/genCreateBlock.js +297 -297
- package/out/templator/genCurdEditMultipleKeyBlock.d.ts +8 -8
- package/out/templator/genCurdEditMultipleKeyBlock.js +398 -398
- package/out/templator/genCurdMultipleKeyBlock.d.ts +34 -34
- package/out/templator/genCurdMultipleKeyBlock.js +541 -541
- package/out/templator/genEditTableBlock.d.ts +51 -51
- package/out/templator/genEditTableBlock.js +255 -255
- package/out/templator/genEnumSelectBlock.d.ts +10 -10
- package/out/templator/genEnumSelectBlock.js +21 -21
- package/out/templator/genGetBlock.d.ts +6 -6
- package/out/templator/genGetBlock.js +96 -96
- package/out/templator/genGridViewBlock.d.ts +55 -55
- package/out/templator/genGridViewBlock.js +286 -286
- package/out/templator/genListViewBlock.d.ts +19 -19
- package/out/templator/genListViewBlock.js +108 -108
- package/out/templator/genQueryComponent.d.ts +34 -34
- package/out/templator/genQueryComponent.js +348 -348
- package/out/templator/genSelectBlock.d.ts +45 -45
- package/out/templator/genSelectBlock.js +340 -340
- package/out/templator/genTableBlock.d.ts +53 -53
- package/out/templator/genTableBlock.js +226 -226
- package/out/templator/genUpdateBlock.d.ts +6 -6
- package/out/templator/genUpdateBlock.js +322 -322
- package/out/templator/index.d.ts +19 -19
- package/out/templator/index.js +37 -37
- package/out/templator/utils.d.ts +683 -683
- package/out/templator/utils.js +458 -458
- package/out/translator/constant.d.ts +6 -6
- package/out/translator/constant.js +9 -9
- package/out/translator/index.d.ts +3 -3
- package/out/translator/index.js +19 -19
- package/out/translator/types.d.ts +33 -32
- package/out/translator/types.js +2 -2
- package/out/translator/utils.d.ts +17 -17
- package/out/translator/utils.js +110 -97
- package/out/translator/utils.js.map +1 -1
- package/out/utils/cookie.d.ts +9 -9
- package/out/utils/cookie.js +61 -61
- package/out/utils/env.d.ts +2 -2
- package/out/utils/env.js +5 -5
- package/out/utils/i18nInfo.d.ts +5 -5
- package/out/utils/i18nInfo.js +60 -60
- package/out/utils/index.d.ts +44 -44
- package/out/utils/index.js +200 -200
- package/out/utils/logger.d.ts +7 -7
- package/out/utils/logger.js +22 -22
- package/out/utils/sortTsString.d.ts +1 -1
- package/out/utils/sortTsString.js +43 -37
- package/out/utils/sortTsString.js.map +1 -1
- package/out/utils/string.d.ts +51 -51
- package/out/utils/string.js +106 -106
- package/out/utils/time-slicing.d.ts +41 -41
- package/out/utils/time-slicing.js +81 -81
- package/out/utils/traverse.d.ts +36 -36
- package/out/utils/traverse.js +142 -142
- package/out/utils/types.d.ts +1 -1
- package/out/utils/types.js +2 -2
- package/out/utils/window.d.ts +7 -7
- package/out/utils/window.js +13 -13
- package/package.json +8 -8
- package/sandbox/stdlib/nasl.oql.ts +6 -1
- package/sandbox-natural/stdlib/nasl.core.ts +6 -3
- package/sandbox-natural/stdlib/nasl.oql.ts +6 -0
- package/sandbox-natural/stdlib/nasl.util.ts +2 -1
- package/src/automate/template/myProcess.js +3 -2
- package/src/common/BaseNode.ts +108 -51
- package/src/concepts/Abort__.ts +4 -1
- package/src/concepts/AbstractInterface__.ts +64 -0
- package/src/concepts/Anchor__.ts +6 -2
- package/src/concepts/AnonymousFunction__.ts +11 -5
- package/src/concepts/App__.ts +1648 -1378
- package/src/concepts/Argument__.ts +7 -3
- package/src/concepts/Assignee__.ts +10 -5
- package/src/concepts/AssignmentLine__.ts +3 -0
- package/src/concepts/Assignment__.ts +8 -4
- package/src/concepts/Attribute__.ts +7 -2
- package/src/concepts/AuthInterface__.ts +3 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +8 -4
- package/src/concepts/AuthLogic__.ts +3 -0
- package/src/concepts/BackendVariable__.ts +11 -4
- package/src/concepts/Backend__.ts +5 -1
- package/src/concepts/BatchAssignment__.ts +13 -8
- package/src/concepts/BinaryExpression__.ts +10 -6
- package/src/concepts/BindAttribute__.ts +6 -2
- package/src/concepts/BindDirective__.ts +11 -4
- package/src/concepts/BindEvent__.ts +8 -3
- package/src/concepts/BindStyle__.ts +5 -1
- package/src/concepts/BooleanLiteral__.ts +4 -1
- package/src/concepts/CallAuthInterface__.ts +11 -3
- package/src/concepts/CallConnector__.ts +3 -0
- package/src/concepts/CallFunction__.ts +41 -15
- package/src/concepts/CallInterface__.ts +33 -21
- package/src/concepts/CallLogic__.ts +41 -35
- package/src/concepts/CallQueryComponent__.ts +11 -14
- package/src/concepts/Comment__.ts +3 -0
- package/src/concepts/CompletionProperty__.ts +5 -1
- package/src/concepts/ConfigGroup__.ts +5 -1
- package/src/concepts/ConfigPropertyValue__.ts +3 -0
- package/src/concepts/ConfigProperty__.ts +5 -1
- package/src/concepts/Configuration__.ts +5 -1
- package/src/concepts/Connection__.ts +5 -1
- package/src/concepts/ConnectorTrigger__.ts +3 -0
- package/src/concepts/Connector__.ts +910 -25
- package/src/concepts/Constant__.ts +9 -4
- package/src/concepts/DataSource__.ts +5 -1
- package/src/concepts/DatabaseTypeAnnotation__.ts +3 -0
- package/src/concepts/DefaultValue__.ts +4 -3
- package/src/concepts/Destination__.ts +8 -4
- package/src/concepts/End__.ts +3 -0
- package/src/concepts/EntityIndex__.ts +3 -0
- package/src/concepts/EntityProperty__.ts +14 -4
- package/src/concepts/Entity__.ts +17 -2
- package/src/concepts/EnumItem__.ts +3 -0
- package/src/concepts/Enum__.ts +5 -1
- package/src/concepts/Event__.ts +5 -1
- package/src/concepts/ExternalDestination__.ts +7 -3
- package/src/concepts/ForEachStatement__.ts +21 -16
- package/src/concepts/FrontendLibrary__.ts +7 -2
- package/src/concepts/FrontendVariable__.ts +3 -0
- package/src/concepts/Frontend__.ts +59 -14
- package/src/concepts/Function__.ts +15 -7
- package/src/concepts/I18nInfo__.ts +1 -0
- package/src/concepts/Identifier__.ts +9 -2
- package/src/concepts/IfStatement__.ts +25 -22
- package/src/concepts/Integration__.ts +8 -4
- package/src/concepts/InterfaceFromExample__.ts +194 -0
- package/src/concepts/InterfaceParam__.ts +20 -4
- package/src/concepts/Interface__.ts +51 -25
- package/src/concepts/JSBlock__.ts +3 -0
- package/src/concepts/JavaLogic__.ts +3 -0
- package/src/concepts/LogicItem__.ts +3 -0
- package/src/concepts/Logic__.ts +48 -19
- package/src/concepts/MatchCase__.ts +16 -5
- package/src/concepts/Match__.ts +8 -4
- package/src/concepts/MemberExpression__.ts +8 -4
- package/src/concepts/MicroApp__.ts +3 -0
- package/src/concepts/Module__.ts +286 -893
- package/src/concepts/MsgTriggerEvent__.ts +5 -1
- package/src/concepts/MsgTriggerLauncher__.ts +6 -2
- package/src/concepts/Namespace__.ts +246 -173
- package/src/concepts/NewComposite__.ts +54 -103
- package/src/concepts/NewList__.ts +27 -18
- package/src/concepts/NewMap__.ts +29 -15
- package/src/concepts/New__.ts +3 -0
- package/src/concepts/NullLiteral__.ts +4 -1
- package/src/concepts/NumericLiteral__.ts +6 -2
- package/src/concepts/OqlQueryComponent__.ts +8 -1
- package/src/concepts/OverriddenLogic__.ts +18 -7
- package/src/concepts/Param__.ts +8 -2
- package/src/concepts/Point__.ts +3 -0
- package/src/concepts/ProcessComponent__.ts +7 -2
- package/src/concepts/ProcessElement__.ts +19 -8
- package/src/concepts/ProcessOutcome__.ts +20 -2
- package/src/concepts/ProcessOutcomes__.ts +20 -2
- package/src/concepts/Process__.ts +15 -7
- package/src/concepts/QueryAggregateExpression__.ts +5 -1
- package/src/concepts/QueryFieldExpression__.ts +3 -0
- package/src/concepts/QueryFromExpression__.ts +5 -1
- package/src/concepts/QueryGroupByExpression__.ts +5 -1
- package/src/concepts/QueryJoinExpression__.ts +5 -1
- package/src/concepts/QueryLimitExpression__.ts +5 -1
- package/src/concepts/QueryOrderByExpression__.ts +5 -1
- package/src/concepts/QuerySelectExpression__.ts +5 -1
- package/src/concepts/Rect__.ts +3 -0
- package/src/concepts/Return__.ts +9 -3
- package/src/concepts/Role__.ts +3 -0
- package/src/concepts/SelectMembers__.ts +5 -1
- package/src/concepts/Slot__.ts +5 -1
- package/src/concepts/SqlQueryComponent__.ts +5 -1
- package/src/concepts/Start__.ts +3 -0
- package/src/concepts/StringInterpolation__.ts +7 -3
- package/src/concepts/StringLiteral__.ts +12 -3
- package/src/concepts/StructureProperty__.ts +12 -4
- package/src/concepts/Structure__.ts +25 -3
- package/src/concepts/SwitchCase__.ts +9 -1
- package/src/concepts/SwitchStatement__.ts +7 -3
- package/src/concepts/Theme__.ts +3 -0
- package/src/concepts/Transactional__.ts +3 -0
- package/src/concepts/TriggerEvent__.ts +5 -1
- package/src/concepts/TriggerLauncher__.ts +3 -0
- package/src/concepts/TypeAnnotation__.ts +62 -23
- package/src/concepts/TypeParam__.ts +3 -0
- package/src/concepts/UnaryExpression__.ts +8 -4
- package/src/concepts/Unparsed__.ts +5 -2
- package/src/concepts/UseComponent__.ts +3 -0
- package/src/concepts/ValidationRule__.ts +21 -7
- package/src/concepts/Variable__.ts +10 -4
- package/src/concepts/ViewBlock__.ts +3 -0
- package/src/concepts/ViewComponent__.ts +15 -6
- package/src/concepts/ViewElement__.ts +13 -5
- package/src/concepts/View__.ts +27 -11
- package/src/concepts/WhileStatement__.ts +7 -1
- package/src/concepts/basics/constants.ts +2 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +3 -3
- package/src/concepts/index__.ts +2 -0
- package/src/concepts/types__.ts +4 -0
- package/src/decorators/index.ts +55 -0
- package/src/enums/KEYWORDS.ts +2 -0
- package/src/generator/genBundleFiles.ts +7 -7
- package/src/generator/genMetaData.ts +7 -2
- package/src/generator/genReleaseBody.ts +8 -4
- package/src/generator/icestark.ts +4 -2
- package/src/generator/qiankun.ts +3 -1
- package/src/natural/genNaturalTS.ts +5 -6
- package/src/natural/transformTSCode.ts +53 -13
- package/src/sentry/index.ts +3 -1
- package/src/server/extendBaseNode.ts +30 -2
- package/src/server/naslServer.ts +142 -22
- package/src/server/translator.ts +13 -1
- package/src/service/storage/jsoner.ts +2 -2
- package/src/translator/types.ts +1 -0
- package/src/translator/utils.ts +15 -0
- package/src/utils/sortTsString.ts +9 -4
- package/test/concepts/call-function/__snapshots__/toEmbeddedTS.spec.ts.snap +26 -0
- package/test/concepts/call-function/__snapshots__/toJS.spec.ts.snap +26 -0
- package/test/concepts/call-function/constant.ts +5 -0
- package/test/concepts/call-function/fixtures/from-string.json +100 -0
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +99 -0
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +89 -0
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +101 -0
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +101 -0
- package/test/concepts/call-function/toEmbeddedTS.spec.ts +14 -0
- package/test/concepts/call-function/toJS.spec.ts +14 -0
- package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +6 -3
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
- package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
|
@@ -1,2320 +1,2319 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
-
};
|
|
34
|
-
var ViewElement_1;
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ViewElement = void 0;
|
|
37
|
-
const translator_1 = require("../translator");
|
|
38
|
-
const concepts_1 = require("../concepts");
|
|
39
|
-
const babelParser = __importStar(require("@babel/parser"));
|
|
40
|
-
const json5 = __importStar(require("json5"));
|
|
41
|
-
const compiler = __importStar(require("vue-template-compiler"));
|
|
42
|
-
const LogicItem__1 = require("./LogicItem__");
|
|
43
|
-
const Logic__1 = require("./Logic__");
|
|
44
|
-
const config_1 = require("../config");
|
|
45
|
-
const MemberExpression__1 = __importDefault(require("./MemberExpression__"));
|
|
46
|
-
const Identifier__1 = __importDefault(require("./Identifier__"));
|
|
47
|
-
const View__1 = require("./View__");
|
|
48
|
-
const utils_1 = require("../utils");
|
|
49
|
-
/**
|
|
50
|
-
* 自闭合标签
|
|
51
|
-
*/
|
|
52
|
-
const selfClosingTag = [
|
|
53
|
-
'base',
|
|
54
|
-
'meta',
|
|
55
|
-
'area',
|
|
56
|
-
'embed',
|
|
57
|
-
'link',
|
|
58
|
-
'img',
|
|
59
|
-
'input',
|
|
60
|
-
'param',
|
|
61
|
-
'hr',
|
|
62
|
-
'br',
|
|
63
|
-
'source',
|
|
64
|
-
'track',
|
|
65
|
-
'wbr',
|
|
66
|
-
'col',
|
|
67
|
-
];
|
|
68
|
-
function genArgumentMemberExpression(arr) {
|
|
69
|
-
let expressionNode;
|
|
70
|
-
const propertyName = arr.pop();
|
|
71
|
-
if (arr.length >= 1) {
|
|
72
|
-
expressionNode = {
|
|
73
|
-
concept: 'MemberExpression',
|
|
74
|
-
name: '',
|
|
75
|
-
kind: 'Expression',
|
|
76
|
-
object: genArgumentMemberExpression(arr),
|
|
77
|
-
property: {
|
|
78
|
-
concept: 'Identifier',
|
|
79
|
-
kind: 'Expression',
|
|
80
|
-
name: propertyName,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return {
|
|
86
|
-
concept: 'Identifier',
|
|
87
|
-
kind: 'Expression',
|
|
88
|
-
name: propertyName,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return expressionNode;
|
|
92
|
-
}
|
|
93
|
-
function transAstNodeToNaslNode(astNode, namespace) {
|
|
94
|
-
let node = null;
|
|
95
|
-
if (astNode.type === 'CallExpression' && astNode.callee.object.name === '$utils') {
|
|
96
|
-
const calleeName = astNode.callee.property.name || astNode.callee.property.value;
|
|
97
|
-
node = {
|
|
98
|
-
concept: 'CallFunction',
|
|
99
|
-
name: '',
|
|
100
|
-
label: '调用内置函数',
|
|
101
|
-
kind: 'Expression',
|
|
102
|
-
calleeNamespace: 'nasl.util',
|
|
103
|
-
calleeName,
|
|
104
|
-
arguments: astNode.arguments
|
|
105
|
-
.map((argument) => ({
|
|
106
|
-
concept: 'Argument',
|
|
107
|
-
name: '',
|
|
108
|
-
kind: 'Statement',
|
|
109
|
-
keyword: '',
|
|
110
|
-
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
111
|
-
}))
|
|
112
|
-
.filter((item) => item.expression),
|
|
113
|
-
typeArguments: astNode.arguments
|
|
114
|
-
.map((argument) => transAstNodeToNaslTypeNode(Object.assign({}, argument)))
|
|
115
|
-
.filter((item) => item),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
else if (astNode.type === 'MemberExpression') {
|
|
119
|
-
if (astNode.object?.name === '$global') {
|
|
120
|
-
if (astNode.property?.name === 'userInfo') {
|
|
121
|
-
// 目前只有权限相关的
|
|
122
|
-
node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
|
|
123
|
-
}
|
|
124
|
-
else if (astNode.property?.name === 'frontendVariables') {
|
|
125
|
-
node = 'app.frontendVariables';
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else if (astNode.object?.name === 'frontendVariables') {
|
|
129
|
-
node = transAstNodeToNaslNode(astNode.property, 'app.frontendVariables');
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
const object = transAstNodeToNaslNode(astNode.object);
|
|
133
|
-
// object如果返回字符串,则将它当成namespace处理
|
|
134
|
-
if (Object.prototype.toString.call(object) === '[object String]') {
|
|
135
|
-
node = transAstNodeToNaslNode(astNode.property, object);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
const property = transAstNodeToNaslNode(astNode.property);
|
|
139
|
-
node = {
|
|
140
|
-
concept: 'MemberExpression',
|
|
141
|
-
name: '',
|
|
142
|
-
kind: 'Expression',
|
|
143
|
-
object,
|
|
144
|
-
property,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
else if (astNode.type === 'Identifier') {
|
|
150
|
-
node = {
|
|
151
|
-
concept: 'Identifier',
|
|
152
|
-
namespace: namespace || '',
|
|
153
|
-
name: astNode.name,
|
|
154
|
-
kind: 'Expression',
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
else if (astNode.type === 'ArrayExpression' || astNode.type === 'ObjectExpression') {
|
|
158
|
-
node = {
|
|
159
|
-
concept: 'Unparsed',
|
|
160
|
-
label: '原子项',
|
|
161
|
-
code: astNode.value,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
else if (astNode.type === 'StringLiteral') {
|
|
165
|
-
// 单独特殊处理枚举因为他不是MemberExpression,而是Identifier_
|
|
166
|
-
if (astNode?.value?.startsWith('__enumTypeAnnotation_')) {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
node = {
|
|
171
|
-
concept: 'StringLiteral',
|
|
172
|
-
kind: 'Expression',
|
|
173
|
-
name: '',
|
|
174
|
-
value: astNode.value,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
else if (astNode.type === 'UnaryExpression') {
|
|
179
|
-
const argument = astNode.argument;
|
|
180
|
-
if (argument.type === 'NumericLiteral') {
|
|
181
|
-
node = {
|
|
182
|
-
concept: 'NumericLiteral',
|
|
183
|
-
value: astNode.operator + argument.value,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
node = {
|
|
188
|
-
concept: 'UnaryExpression',
|
|
189
|
-
kind: 'Expression',
|
|
190
|
-
name: '',
|
|
191
|
-
operator: astNode.operator,
|
|
192
|
-
argument: transAstNodeToNaslNode(astNode.argument),
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
else if (astNode.type === 'NumericLiteral') {
|
|
197
|
-
const numberString = typeof astNode.value === 'number' ? astNode.value.toString() : astNode.value;
|
|
198
|
-
node = {
|
|
199
|
-
concept: 'NumericLiteral',
|
|
200
|
-
value: numberString,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
else if (astNode.type === 'ArrowFunctionExpression') {
|
|
204
|
-
if (astNode.body?.callee?.name) {
|
|
205
|
-
astNode.name = astNode.body.callee.name;
|
|
206
|
-
}
|
|
207
|
-
let tempNode = {
|
|
208
|
-
calleeNamespace: 'app.logics',
|
|
209
|
-
concept: 'CallLogic',
|
|
210
|
-
namespace: namespace || '',
|
|
211
|
-
name: astNode.name,
|
|
212
|
-
calleeName: astNode.name,
|
|
213
|
-
kind: 'Expression',
|
|
214
|
-
parentNode: astNode.parentNode,
|
|
215
|
-
parentKey: astNode.parentKey,
|
|
216
|
-
arguments: astNode?.body?.arguments
|
|
217
|
-
?.map((argument) => ({
|
|
218
|
-
concept: 'Argument',
|
|
219
|
-
name: '',
|
|
220
|
-
kind: 'Statement',
|
|
221
|
-
keyword: '',
|
|
222
|
-
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
223
|
-
}))
|
|
224
|
-
.filter((item) => item.expression),
|
|
225
|
-
typeArguments: astNode?.body?.arguments
|
|
226
|
-
?.map((argument) => transAstNodeToNaslTypeNode(Object.assign({}, argument)))
|
|
227
|
-
.filter((item) => item),
|
|
228
|
-
};
|
|
229
|
-
node = Logic__1.Logic.from({
|
|
230
|
-
...tempNode,
|
|
231
|
-
}, undefined, 'logics');
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
node = astNode;
|
|
235
|
-
node.concept = astNode.type;
|
|
236
|
-
}
|
|
237
|
-
return node;
|
|
238
|
-
}
|
|
239
|
-
function transAstNodeToNaslTypeNode(astNode, namespace) {
|
|
240
|
-
let node = null;
|
|
241
|
-
// 单独特殊处理枚举因为他不是MemberExpression,而是Identifier_
|
|
242
|
-
if (astNode?.value?.startsWith('__enumTypeAnnotation_')) {
|
|
243
|
-
const valueArr = astNode.value.replace('__enumTypeAnnotation_', '')?.split('.');
|
|
244
|
-
const name = valueArr.pop();
|
|
245
|
-
const namespace = valueArr.join('.');
|
|
246
|
-
node = {
|
|
247
|
-
concept: 'TypeAnnotation',
|
|
248
|
-
typeNamespace: namespace || '',
|
|
249
|
-
typeName: name || '',
|
|
250
|
-
typeKind: 'reference',
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
return node;
|
|
254
|
-
}
|
|
255
|
-
const decorators_1 = require("../decorators");
|
|
256
|
-
const utils = __importStar(require("../utils"));
|
|
257
|
-
const uuid_1 = require("uuid");
|
|
258
|
-
const BaseNode_1 = __importDefault(require("../common/BaseNode"));
|
|
259
|
-
const BindAttribute__1 = __importDefault(require("./BindAttribute__"));
|
|
260
|
-
const BindEvent__1 = __importDefault(require("./BindEvent__"));
|
|
261
|
-
const BindDirective__1 = __importDefault(require("./BindDirective__"));
|
|
262
|
-
const BindStyle__1 = __importDefault(require("./BindStyle__"));
|
|
263
|
-
/**
|
|
264
|
-
* 页面元素
|
|
265
|
-
*/
|
|
266
|
-
let ViewElement =
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
bindAttribute
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
return
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
bindEvent
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
bindDirective
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
return
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
bindStyle
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
viewElement
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
this[parentKey]
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
bindDirective
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
bindStyle = options;
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
get
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
else {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
code +=
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
var ViewElement_1;
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ViewElement = void 0;
|
|
37
|
+
const translator_1 = require("../translator");
|
|
38
|
+
const concepts_1 = require("../concepts");
|
|
39
|
+
const babelParser = __importStar(require("@babel/parser"));
|
|
40
|
+
const json5 = __importStar(require("json5"));
|
|
41
|
+
const compiler = __importStar(require("vue-template-compiler"));
|
|
42
|
+
const LogicItem__1 = require("./LogicItem__");
|
|
43
|
+
const Logic__1 = require("./Logic__");
|
|
44
|
+
const config_1 = require("../config");
|
|
45
|
+
const MemberExpression__1 = __importDefault(require("./MemberExpression__"));
|
|
46
|
+
const Identifier__1 = __importDefault(require("./Identifier__"));
|
|
47
|
+
const View__1 = require("./View__");
|
|
48
|
+
const utils_1 = require("../utils");
|
|
49
|
+
/**
|
|
50
|
+
* 自闭合标签
|
|
51
|
+
*/
|
|
52
|
+
const selfClosingTag = [
|
|
53
|
+
'base',
|
|
54
|
+
'meta',
|
|
55
|
+
'area',
|
|
56
|
+
'embed',
|
|
57
|
+
'link',
|
|
58
|
+
'img',
|
|
59
|
+
'input',
|
|
60
|
+
'param',
|
|
61
|
+
'hr',
|
|
62
|
+
'br',
|
|
63
|
+
'source',
|
|
64
|
+
'track',
|
|
65
|
+
'wbr',
|
|
66
|
+
'col',
|
|
67
|
+
];
|
|
68
|
+
function genArgumentMemberExpression(arr) {
|
|
69
|
+
let expressionNode;
|
|
70
|
+
const propertyName = arr.pop();
|
|
71
|
+
if (arr.length >= 1) {
|
|
72
|
+
expressionNode = {
|
|
73
|
+
concept: 'MemberExpression',
|
|
74
|
+
name: '',
|
|
75
|
+
kind: 'Expression',
|
|
76
|
+
object: genArgumentMemberExpression(arr),
|
|
77
|
+
property: {
|
|
78
|
+
concept: 'Identifier',
|
|
79
|
+
kind: 'Expression',
|
|
80
|
+
name: propertyName,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return {
|
|
86
|
+
concept: 'Identifier',
|
|
87
|
+
kind: 'Expression',
|
|
88
|
+
name: propertyName,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return expressionNode;
|
|
92
|
+
}
|
|
93
|
+
function transAstNodeToNaslNode(astNode, namespace) {
|
|
94
|
+
let node = null;
|
|
95
|
+
if (astNode.type === 'CallExpression' && astNode.callee.object.name === '$utils') {
|
|
96
|
+
const calleeName = astNode.callee.property.name || astNode.callee.property.value;
|
|
97
|
+
node = {
|
|
98
|
+
concept: 'CallFunction',
|
|
99
|
+
name: '',
|
|
100
|
+
label: '调用内置函数',
|
|
101
|
+
kind: 'Expression',
|
|
102
|
+
calleeNamespace: 'nasl.util',
|
|
103
|
+
calleeName,
|
|
104
|
+
arguments: astNode.arguments
|
|
105
|
+
.map((argument) => ({
|
|
106
|
+
concept: 'Argument',
|
|
107
|
+
name: '',
|
|
108
|
+
kind: 'Statement',
|
|
109
|
+
keyword: '',
|
|
110
|
+
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
111
|
+
}))
|
|
112
|
+
.filter((item) => item.expression),
|
|
113
|
+
typeArguments: astNode.arguments
|
|
114
|
+
.map((argument) => transAstNodeToNaslTypeNode(Object.assign({}, argument)))
|
|
115
|
+
.filter((item) => item),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
else if (astNode.type === 'MemberExpression') {
|
|
119
|
+
if (astNode.object?.name === '$global') {
|
|
120
|
+
if (astNode.property?.name === 'userInfo') {
|
|
121
|
+
// 目前只有权限相关的
|
|
122
|
+
node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
|
|
123
|
+
}
|
|
124
|
+
else if (astNode.property?.name === 'frontendVariables') {
|
|
125
|
+
node = 'app.frontendVariables';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (astNode.object?.name === 'frontendVariables') {
|
|
129
|
+
node = transAstNodeToNaslNode(astNode.property, 'app.frontendVariables');
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const object = transAstNodeToNaslNode(astNode.object);
|
|
133
|
+
// object如果返回字符串,则将它当成namespace处理
|
|
134
|
+
if (Object.prototype.toString.call(object) === '[object String]') {
|
|
135
|
+
node = transAstNodeToNaslNode(astNode.property, object);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const property = transAstNodeToNaslNode(astNode.property);
|
|
139
|
+
node = {
|
|
140
|
+
concept: 'MemberExpression',
|
|
141
|
+
name: '',
|
|
142
|
+
kind: 'Expression',
|
|
143
|
+
object,
|
|
144
|
+
property,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else if (astNode.type === 'Identifier') {
|
|
150
|
+
node = {
|
|
151
|
+
concept: 'Identifier',
|
|
152
|
+
namespace: namespace || '',
|
|
153
|
+
name: astNode.name,
|
|
154
|
+
kind: 'Expression',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
else if (astNode.type === 'ArrayExpression' || astNode.type === 'ObjectExpression') {
|
|
158
|
+
node = {
|
|
159
|
+
concept: 'Unparsed',
|
|
160
|
+
label: '原子项',
|
|
161
|
+
code: astNode.value,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
else if (astNode.type === 'StringLiteral') {
|
|
165
|
+
// 单独特殊处理枚举因为他不是MemberExpression,而是Identifier_
|
|
166
|
+
if (astNode?.value?.startsWith('__enumTypeAnnotation_')) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
node = {
|
|
171
|
+
concept: 'StringLiteral',
|
|
172
|
+
kind: 'Expression',
|
|
173
|
+
name: '',
|
|
174
|
+
value: astNode.value,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else if (astNode.type === 'UnaryExpression') {
|
|
179
|
+
const argument = astNode.argument;
|
|
180
|
+
if (argument.type === 'NumericLiteral') {
|
|
181
|
+
node = {
|
|
182
|
+
concept: 'NumericLiteral',
|
|
183
|
+
value: astNode.operator + argument.value,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
node = {
|
|
188
|
+
concept: 'UnaryExpression',
|
|
189
|
+
kind: 'Expression',
|
|
190
|
+
name: '',
|
|
191
|
+
operator: astNode.operator,
|
|
192
|
+
argument: transAstNodeToNaslNode(astNode.argument),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (astNode.type === 'NumericLiteral') {
|
|
197
|
+
const numberString = typeof astNode.value === 'number' ? astNode.value.toString() : astNode.value;
|
|
198
|
+
node = {
|
|
199
|
+
concept: 'NumericLiteral',
|
|
200
|
+
value: numberString,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
else if (astNode.type === 'ArrowFunctionExpression') {
|
|
204
|
+
if (astNode.body?.callee?.name) {
|
|
205
|
+
astNode.name = astNode.body.callee.name;
|
|
206
|
+
}
|
|
207
|
+
let tempNode = {
|
|
208
|
+
calleeNamespace: 'app.logics',
|
|
209
|
+
concept: 'CallLogic',
|
|
210
|
+
namespace: namespace || '',
|
|
211
|
+
name: astNode.name,
|
|
212
|
+
calleeName: astNode.name,
|
|
213
|
+
kind: 'Expression',
|
|
214
|
+
parentNode: astNode.parentNode,
|
|
215
|
+
parentKey: astNode.parentKey,
|
|
216
|
+
arguments: astNode?.body?.arguments
|
|
217
|
+
?.map((argument) => ({
|
|
218
|
+
concept: 'Argument',
|
|
219
|
+
name: '',
|
|
220
|
+
kind: 'Statement',
|
|
221
|
+
keyword: '',
|
|
222
|
+
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
223
|
+
}))
|
|
224
|
+
.filter((item) => item.expression),
|
|
225
|
+
typeArguments: astNode?.body?.arguments
|
|
226
|
+
?.map((argument) => transAstNodeToNaslTypeNode(Object.assign({}, argument)))
|
|
227
|
+
.filter((item) => item),
|
|
228
|
+
};
|
|
229
|
+
node = Logic__1.Logic.from({
|
|
230
|
+
...tempNode,
|
|
231
|
+
}, undefined, 'logics');
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
node = astNode;
|
|
235
|
+
node.concept = astNode.type;
|
|
236
|
+
}
|
|
237
|
+
return node;
|
|
238
|
+
}
|
|
239
|
+
function transAstNodeToNaslTypeNode(astNode, namespace) {
|
|
240
|
+
let node = null;
|
|
241
|
+
// 单独特殊处理枚举因为他不是MemberExpression,而是Identifier_
|
|
242
|
+
if (astNode?.value?.startsWith('__enumTypeAnnotation_')) {
|
|
243
|
+
const valueArr = astNode.value.replace('__enumTypeAnnotation_', '')?.split('.');
|
|
244
|
+
const name = valueArr.pop();
|
|
245
|
+
const namespace = valueArr.join('.');
|
|
246
|
+
node = {
|
|
247
|
+
concept: 'TypeAnnotation',
|
|
248
|
+
typeNamespace: namespace || '',
|
|
249
|
+
typeName: name || '',
|
|
250
|
+
typeKind: 'reference',
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
return node;
|
|
254
|
+
}
|
|
255
|
+
const decorators_1 = require("../decorators");
|
|
256
|
+
const utils = __importStar(require("../utils"));
|
|
257
|
+
const uuid_1 = require("uuid");
|
|
258
|
+
const BaseNode_1 = __importDefault(require("../common/BaseNode"));
|
|
259
|
+
const BindAttribute__1 = __importDefault(require("./BindAttribute__"));
|
|
260
|
+
const BindEvent__1 = __importDefault(require("./BindEvent__"));
|
|
261
|
+
const BindDirective__1 = __importDefault(require("./BindDirective__"));
|
|
262
|
+
const BindStyle__1 = __importDefault(require("./BindStyle__"));
|
|
263
|
+
/**
|
|
264
|
+
* 页面元素
|
|
265
|
+
*/
|
|
266
|
+
let ViewElement = ViewElement_1 =
|
|
267
|
+
// @ts-ignore
|
|
268
|
+
class ViewElement extends BaseNode_1.default {
|
|
269
|
+
/** 类名 */
|
|
270
|
+
static ConceptName = 'ViewElement';
|
|
271
|
+
/** 继承链 */
|
|
272
|
+
static inheritanceChain = ['BaseNode'];
|
|
273
|
+
/**
|
|
274
|
+
* 产品概念
|
|
275
|
+
*/
|
|
276
|
+
concept;
|
|
277
|
+
/**
|
|
278
|
+
* 类型
|
|
279
|
+
*/
|
|
280
|
+
// @ts-ignore
|
|
281
|
+
type;
|
|
282
|
+
/**
|
|
283
|
+
* 元素标签
|
|
284
|
+
*/
|
|
285
|
+
// @ts-ignore
|
|
286
|
+
tag;
|
|
287
|
+
/**
|
|
288
|
+
* 页面元素名称
|
|
289
|
+
*/
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
name;
|
|
292
|
+
/**
|
|
293
|
+
* 静态 class 名
|
|
294
|
+
*/
|
|
295
|
+
// @ts-ignore
|
|
296
|
+
staticClass;
|
|
297
|
+
/**
|
|
298
|
+
* 静态 style
|
|
299
|
+
*/
|
|
300
|
+
// @ts-ignore
|
|
301
|
+
staticStyle;
|
|
302
|
+
/**
|
|
303
|
+
* 权限资源描述
|
|
304
|
+
*/
|
|
305
|
+
// @ts-ignore
|
|
306
|
+
authDescription;
|
|
307
|
+
/**
|
|
308
|
+
* 插槽目标
|
|
309
|
+
*/
|
|
310
|
+
// @ts-ignore
|
|
311
|
+
slotTarget;
|
|
312
|
+
/**
|
|
313
|
+
* 插槽 scope 表达式
|
|
314
|
+
*/
|
|
315
|
+
// @ts-ignore
|
|
316
|
+
slotScope;
|
|
317
|
+
/**
|
|
318
|
+
* 元素绑定属性列表
|
|
319
|
+
*/
|
|
320
|
+
bindAttrs = [];
|
|
321
|
+
/**
|
|
322
|
+
* 元素绑定事件列表
|
|
323
|
+
*/
|
|
324
|
+
bindEvents = [];
|
|
325
|
+
/**
|
|
326
|
+
* 元素指令列表
|
|
327
|
+
*/
|
|
328
|
+
bindDirectives = [];
|
|
329
|
+
/**
|
|
330
|
+
* 绑定的角色
|
|
331
|
+
*/
|
|
332
|
+
bindRoles = [];
|
|
333
|
+
/**
|
|
334
|
+
* 元素绑定样式列表
|
|
335
|
+
*/
|
|
336
|
+
bindStyles = [];
|
|
337
|
+
/**
|
|
338
|
+
* 子元素列表
|
|
339
|
+
*/
|
|
340
|
+
children = [];
|
|
341
|
+
/**
|
|
342
|
+
* 祖先 View
|
|
343
|
+
*/
|
|
344
|
+
get view() {
|
|
345
|
+
return this.getAncestor('View');
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 祖先 Module
|
|
349
|
+
*/
|
|
350
|
+
get module() {
|
|
351
|
+
return this.getAncestor('Module');
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* 祖先 App
|
|
355
|
+
*/
|
|
356
|
+
get app() {
|
|
357
|
+
return this.getAncestor('App');
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* 祖先 Frontend
|
|
361
|
+
*/
|
|
362
|
+
get frontend() {
|
|
363
|
+
return this.getAncestor('Frontend');
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* @param source 需要合并的部分参数
|
|
367
|
+
*/
|
|
368
|
+
constructor(source) {
|
|
369
|
+
source = Object.assign({}, ViewElement_1.getDefaultOptions(), source);
|
|
370
|
+
super(source);
|
|
371
|
+
super.subConstructor(source);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* 从父级删除该节点
|
|
375
|
+
* @internal
|
|
376
|
+
*/
|
|
377
|
+
_delete() {
|
|
378
|
+
let params = null;
|
|
379
|
+
if (this.parentNode) {
|
|
380
|
+
params = this.parentNode?.__removeViewElement?.(this);
|
|
381
|
+
}
|
|
382
|
+
return params;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* 设置页面元素名称
|
|
386
|
+
*/
|
|
387
|
+
setName(name) {
|
|
388
|
+
const object = {
|
|
389
|
+
name,
|
|
390
|
+
};
|
|
391
|
+
this.update({
|
|
392
|
+
...object,
|
|
393
|
+
field: 'name',
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* 设置静态 style
|
|
398
|
+
*/
|
|
399
|
+
setStaticStyle(staticStyle) {
|
|
400
|
+
const object = {
|
|
401
|
+
staticStyle,
|
|
402
|
+
};
|
|
403
|
+
this.update({
|
|
404
|
+
...object,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* 设置权限资源描述
|
|
409
|
+
*/
|
|
410
|
+
setAuthDescription(authDescription) {
|
|
411
|
+
const object = {
|
|
412
|
+
authDescription,
|
|
413
|
+
};
|
|
414
|
+
this.update({
|
|
415
|
+
...object,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
getBindAttributeExistingNames(excludedList = []) {
|
|
419
|
+
const excludedSet = new Set(excludedList);
|
|
420
|
+
return (this.bindAttrs || [])
|
|
421
|
+
.filter((item) => !excludedSet.has(item))
|
|
422
|
+
.map((item) => item.name);
|
|
423
|
+
}
|
|
424
|
+
getBindAttributeUniqueName(name = 'bindAttribute1') {
|
|
425
|
+
return utils.unique(name, this.getBindAttributeExistingNames(), undefined, false);
|
|
426
|
+
}
|
|
427
|
+
_insertBindAttributeAt(options, index) {
|
|
428
|
+
const bindAttributeOptions = {};
|
|
429
|
+
const relationOptions = { parentNode: this, parentKey: 'bindAttrs' };
|
|
430
|
+
let bindAttribute;
|
|
431
|
+
if (!options) {
|
|
432
|
+
bindAttribute = BindAttribute__1.default.from({
|
|
433
|
+
...bindAttributeOptions,
|
|
434
|
+
name: this.getBindAttributeUniqueName(),
|
|
435
|
+
}, this, 'bindAttrs');
|
|
436
|
+
}
|
|
437
|
+
else if (typeof options === 'string') {
|
|
438
|
+
bindAttribute = BindAttribute__1.default.from({
|
|
439
|
+
...bindAttributeOptions,
|
|
440
|
+
name: options,
|
|
441
|
+
}, this, 'bindAttrs');
|
|
442
|
+
}
|
|
443
|
+
else if (options instanceof BindAttribute__1.default) {
|
|
444
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
445
|
+
bindAttribute = options;
|
|
446
|
+
Object.assign(bindAttribute, relationOptions);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
bindAttribute = BindAttribute__1.default.from({
|
|
450
|
+
...bindAttributeOptions,
|
|
451
|
+
...options,
|
|
452
|
+
}, this, 'bindAttrs');
|
|
453
|
+
}
|
|
454
|
+
this.bindAttrs.splice(index, 0, bindAttribute);
|
|
455
|
+
return bindAttribute;
|
|
456
|
+
}
|
|
457
|
+
insertBindAttributeAt(options, index) {
|
|
458
|
+
const node = this._insertBindAttributeAt(options, index);
|
|
459
|
+
node.create({
|
|
460
|
+
index,
|
|
461
|
+
parentNode: this,
|
|
462
|
+
parentKey: 'bindAttrs',
|
|
463
|
+
});
|
|
464
|
+
return node;
|
|
465
|
+
}
|
|
466
|
+
_addBindAttribute(options) {
|
|
467
|
+
const index = this.bindAttrs.length;
|
|
468
|
+
return this._insertBindAttributeAt(options, index);
|
|
469
|
+
}
|
|
470
|
+
addBindAttribute(options) {
|
|
471
|
+
const node = this._addBindAttribute(options);
|
|
472
|
+
const index = this.bindAttrs.indexOf(node);
|
|
473
|
+
node.create({
|
|
474
|
+
index,
|
|
475
|
+
parentNode: this,
|
|
476
|
+
parentKey: 'bindAttrs',
|
|
477
|
+
});
|
|
478
|
+
return node;
|
|
479
|
+
}
|
|
480
|
+
getBindEventExistingNames(excludedList = []) {
|
|
481
|
+
const excludedSet = new Set(excludedList);
|
|
482
|
+
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
483
|
+
}
|
|
484
|
+
getBindEventUniqueName(name = 'bindEvent1') {
|
|
485
|
+
return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
|
|
486
|
+
}
|
|
487
|
+
_insertBindEventAt(options, index) {
|
|
488
|
+
const bindEventOptions = {};
|
|
489
|
+
const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
|
|
490
|
+
let bindEvent;
|
|
491
|
+
if (!options) {
|
|
492
|
+
bindEvent = BindEvent__1.default.from({
|
|
493
|
+
...bindEventOptions,
|
|
494
|
+
name: this.getBindEventUniqueName(),
|
|
495
|
+
}, this, 'bindEvents');
|
|
496
|
+
}
|
|
497
|
+
else if (typeof options === 'string') {
|
|
498
|
+
bindEvent = BindEvent__1.default.from({
|
|
499
|
+
...bindEventOptions,
|
|
500
|
+
name: options,
|
|
501
|
+
}, this, 'bindEvents');
|
|
502
|
+
}
|
|
503
|
+
else if (options instanceof BindEvent__1.default) {
|
|
504
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
505
|
+
bindEvent = options;
|
|
506
|
+
Object.assign(bindEvent, relationOptions);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
bindEvent = BindEvent__1.default.from({
|
|
510
|
+
...bindEventOptions,
|
|
511
|
+
...options,
|
|
512
|
+
}, this, 'bindEvents');
|
|
513
|
+
}
|
|
514
|
+
this.bindEvents.splice(index, 0, bindEvent);
|
|
515
|
+
return bindEvent;
|
|
516
|
+
}
|
|
517
|
+
insertBindEventAt(options, index) {
|
|
518
|
+
const node = this._insertBindEventAt(options, index);
|
|
519
|
+
node.create({
|
|
520
|
+
index,
|
|
521
|
+
parentNode: this,
|
|
522
|
+
parentKey: 'bindEvents',
|
|
523
|
+
});
|
|
524
|
+
return node;
|
|
525
|
+
}
|
|
526
|
+
_addBindEvent(options) {
|
|
527
|
+
const index = this.bindEvents.length;
|
|
528
|
+
return this._insertBindEventAt(options, index);
|
|
529
|
+
}
|
|
530
|
+
addBindEvent(options) {
|
|
531
|
+
const node = this._addBindEvent(options);
|
|
532
|
+
const index = this.bindEvents.indexOf(node);
|
|
533
|
+
node.create({
|
|
534
|
+
index,
|
|
535
|
+
parentNode: this,
|
|
536
|
+
parentKey: 'bindEvents',
|
|
537
|
+
});
|
|
538
|
+
return node;
|
|
539
|
+
}
|
|
540
|
+
getBindDirectiveExistingNames(excludedList = []) {
|
|
541
|
+
const excludedSet = new Set(excludedList);
|
|
542
|
+
return (this.bindDirectives || [])
|
|
543
|
+
.filter((item) => !excludedSet.has(item))
|
|
544
|
+
.map((item) => item.name);
|
|
545
|
+
}
|
|
546
|
+
getBindDirectiveUniqueName(name = 'bindDirective1') {
|
|
547
|
+
return utils.unique(name, this.getBindDirectiveExistingNames(), undefined, false);
|
|
548
|
+
}
|
|
549
|
+
_insertBindDirectiveAt(options, index) {
|
|
550
|
+
const bindDirectiveOptions = {};
|
|
551
|
+
const relationOptions = { parentNode: this, parentKey: 'bindDirectives' };
|
|
552
|
+
let bindDirective;
|
|
553
|
+
if (!options) {
|
|
554
|
+
bindDirective = BindDirective__1.default.from({
|
|
555
|
+
...bindDirectiveOptions,
|
|
556
|
+
name: this.getBindDirectiveUniqueName(),
|
|
557
|
+
}, this, 'bindDirectives');
|
|
558
|
+
}
|
|
559
|
+
else if (typeof options === 'string') {
|
|
560
|
+
bindDirective = BindDirective__1.default.from({
|
|
561
|
+
...bindDirectiveOptions,
|
|
562
|
+
name: options,
|
|
563
|
+
}, this, 'bindDirectives');
|
|
564
|
+
}
|
|
565
|
+
else if (options instanceof BindDirective__1.default) {
|
|
566
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
567
|
+
bindDirective = options;
|
|
568
|
+
Object.assign(bindDirective, relationOptions);
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
bindDirective = BindDirective__1.default.from({
|
|
572
|
+
...bindDirectiveOptions,
|
|
573
|
+
...options,
|
|
574
|
+
}, this, 'bindDirectives');
|
|
575
|
+
}
|
|
576
|
+
this.bindDirectives.splice(index, 0, bindDirective);
|
|
577
|
+
return bindDirective;
|
|
578
|
+
}
|
|
579
|
+
insertBindDirectiveAt(options, index) {
|
|
580
|
+
const node = this._insertBindDirectiveAt(options, index);
|
|
581
|
+
node.create({
|
|
582
|
+
index,
|
|
583
|
+
parentNode: this,
|
|
584
|
+
parentKey: 'bindDirectives',
|
|
585
|
+
});
|
|
586
|
+
return node;
|
|
587
|
+
}
|
|
588
|
+
_addBindDirective(options) {
|
|
589
|
+
const index = this.bindDirectives.length;
|
|
590
|
+
return this._insertBindDirectiveAt(options, index);
|
|
591
|
+
}
|
|
592
|
+
addBindDirective(options) {
|
|
593
|
+
const node = this._addBindDirective(options);
|
|
594
|
+
const index = this.bindDirectives.indexOf(node);
|
|
595
|
+
node.create({
|
|
596
|
+
index,
|
|
597
|
+
parentNode: this,
|
|
598
|
+
parentKey: 'bindDirectives',
|
|
599
|
+
});
|
|
600
|
+
return node;
|
|
601
|
+
}
|
|
602
|
+
getBindStyleExistingNames(excludedList = []) {
|
|
603
|
+
const excludedSet = new Set(excludedList);
|
|
604
|
+
return (this.bindStyles || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
605
|
+
}
|
|
606
|
+
getBindStyleUniqueName(name = 'bindStyle1') {
|
|
607
|
+
return utils.unique(name, this.getBindStyleExistingNames(), undefined, false);
|
|
608
|
+
}
|
|
609
|
+
_insertBindStyleAt(options, index) {
|
|
610
|
+
const bindStyleOptions = {};
|
|
611
|
+
const relationOptions = { parentNode: this, parentKey: 'bindStyles' };
|
|
612
|
+
let bindStyle;
|
|
613
|
+
if (!options) {
|
|
614
|
+
bindStyle = BindStyle__1.default.from({
|
|
615
|
+
...bindStyleOptions,
|
|
616
|
+
name: this.getBindStyleUniqueName(),
|
|
617
|
+
}, this, 'bindStyles');
|
|
618
|
+
}
|
|
619
|
+
else if (typeof options === 'string') {
|
|
620
|
+
bindStyle = BindStyle__1.default.from({
|
|
621
|
+
...bindStyleOptions,
|
|
622
|
+
name: options,
|
|
623
|
+
}, this, 'bindStyles');
|
|
624
|
+
}
|
|
625
|
+
else if (options instanceof BindStyle__1.default) {
|
|
626
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
627
|
+
bindStyle = options;
|
|
628
|
+
Object.assign(bindStyle, relationOptions);
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
bindStyle = BindStyle__1.default.from({
|
|
632
|
+
...bindStyleOptions,
|
|
633
|
+
...options,
|
|
634
|
+
}, this, 'bindStyles');
|
|
635
|
+
}
|
|
636
|
+
this.bindStyles.splice(index, 0, bindStyle);
|
|
637
|
+
return bindStyle;
|
|
638
|
+
}
|
|
639
|
+
insertBindStyleAt(options, index) {
|
|
640
|
+
const node = this._insertBindStyleAt(options, index);
|
|
641
|
+
node.create({
|
|
642
|
+
index,
|
|
643
|
+
parentNode: this,
|
|
644
|
+
parentKey: 'bindStyles',
|
|
645
|
+
});
|
|
646
|
+
return node;
|
|
647
|
+
}
|
|
648
|
+
_addBindStyle(options) {
|
|
649
|
+
const index = this.bindStyles.length;
|
|
650
|
+
return this._insertBindStyleAt(options, index);
|
|
651
|
+
}
|
|
652
|
+
addBindStyle(options) {
|
|
653
|
+
const node = this._addBindStyle(options);
|
|
654
|
+
const index = this.bindStyles.indexOf(node);
|
|
655
|
+
node.create({
|
|
656
|
+
index,
|
|
657
|
+
parentNode: this,
|
|
658
|
+
parentKey: 'bindStyles',
|
|
659
|
+
});
|
|
660
|
+
return node;
|
|
661
|
+
}
|
|
662
|
+
_insertViewElementAt(options, index) {
|
|
663
|
+
const viewElementOptions = {};
|
|
664
|
+
const relationOptions = { parentNode: this, parentKey: 'children' };
|
|
665
|
+
let viewElement;
|
|
666
|
+
if (!options) {
|
|
667
|
+
viewElement = ViewElement_1.from({
|
|
668
|
+
...viewElementOptions,
|
|
669
|
+
name: this.getViewElementUniqueName(),
|
|
670
|
+
}, this, 'children');
|
|
671
|
+
}
|
|
672
|
+
else if (typeof options === 'string') {
|
|
673
|
+
viewElement = ViewElement_1.from({
|
|
674
|
+
...viewElementOptions,
|
|
675
|
+
name: options,
|
|
676
|
+
}, this, 'children');
|
|
677
|
+
}
|
|
678
|
+
else if (options instanceof ViewElement_1) {
|
|
679
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
680
|
+
viewElement = options;
|
|
681
|
+
Object.assign(viewElement, relationOptions);
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
viewElement = ViewElement_1.from({
|
|
685
|
+
...viewElementOptions,
|
|
686
|
+
...options,
|
|
687
|
+
}, this, 'children');
|
|
688
|
+
}
|
|
689
|
+
this.children.splice(index, 0, viewElement);
|
|
690
|
+
return viewElement;
|
|
691
|
+
}
|
|
692
|
+
insertViewElementAt(options, index) {
|
|
693
|
+
const node = this._insertViewElementAt(options, index);
|
|
694
|
+
node.create({
|
|
695
|
+
index,
|
|
696
|
+
parentNode: this,
|
|
697
|
+
parentKey: 'children',
|
|
698
|
+
});
|
|
699
|
+
return node;
|
|
700
|
+
}
|
|
701
|
+
_addViewElement(options) {
|
|
702
|
+
const index = this.children.length;
|
|
703
|
+
return this._insertViewElementAt(options, index);
|
|
704
|
+
}
|
|
705
|
+
addViewElement(options) {
|
|
706
|
+
const node = this._addViewElement(options);
|
|
707
|
+
const index = this.children.indexOf(node);
|
|
708
|
+
node.create({
|
|
709
|
+
index,
|
|
710
|
+
parentNode: this,
|
|
711
|
+
parentKey: 'children',
|
|
712
|
+
});
|
|
713
|
+
return node;
|
|
714
|
+
}
|
|
715
|
+
removeBindAttribute(options) {
|
|
716
|
+
let bindAttribute;
|
|
717
|
+
if (typeof options === 'string') {
|
|
718
|
+
bindAttribute = this.bindAttrs.find((item) => item.name === options);
|
|
719
|
+
if (!bindAttribute) {
|
|
720
|
+
throw new Error('找不到元素绑定属性 ' + options);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
bindAttribute = options;
|
|
725
|
+
}
|
|
726
|
+
return bindAttribute.delete();
|
|
727
|
+
}
|
|
728
|
+
__removeBindAttribute(bindAttribute) {
|
|
729
|
+
const parentKey = bindAttribute.parentKey;
|
|
730
|
+
const params = {
|
|
731
|
+
parentNode: this,
|
|
732
|
+
parentKey,
|
|
733
|
+
index: -1,
|
|
734
|
+
object: null,
|
|
735
|
+
oldObject: bindAttribute,
|
|
736
|
+
};
|
|
737
|
+
if (parentKey) {
|
|
738
|
+
params.parentKey = parentKey;
|
|
739
|
+
// @ts-ignore
|
|
740
|
+
const t = this.__v_raw || this;
|
|
741
|
+
// @ts-ignore
|
|
742
|
+
const n = bindAttribute.__v_raw || bindAttribute;
|
|
743
|
+
if (Array.isArray(t[parentKey])) {
|
|
744
|
+
// @ts-ignore
|
|
745
|
+
const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
746
|
+
~index && this[parentKey].splice(index, 1);
|
|
747
|
+
params.index = index;
|
|
748
|
+
}
|
|
749
|
+
else if (t[parentKey] === n) {
|
|
750
|
+
params.index = 0;
|
|
751
|
+
this[parentKey] = undefined;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return params;
|
|
755
|
+
}
|
|
756
|
+
removeBindEvent(options) {
|
|
757
|
+
let bindEvent;
|
|
758
|
+
if (typeof options === 'string') {
|
|
759
|
+
bindEvent = this.bindEvents.find((item) => item.name === options);
|
|
760
|
+
if (!bindEvent) {
|
|
761
|
+
throw new Error('找不到元素绑定事件 ' + options);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
else {
|
|
765
|
+
bindEvent = options;
|
|
766
|
+
}
|
|
767
|
+
return bindEvent.delete();
|
|
768
|
+
}
|
|
769
|
+
__removeBindEvent(bindEvent) {
|
|
770
|
+
const parentKey = bindEvent.parentKey;
|
|
771
|
+
const params = {
|
|
772
|
+
parentNode: this,
|
|
773
|
+
parentKey,
|
|
774
|
+
index: -1,
|
|
775
|
+
object: null,
|
|
776
|
+
oldObject: bindEvent,
|
|
777
|
+
};
|
|
778
|
+
if (parentKey) {
|
|
779
|
+
params.parentKey = parentKey;
|
|
780
|
+
// @ts-ignore
|
|
781
|
+
const t = this.__v_raw || this;
|
|
782
|
+
// @ts-ignore
|
|
783
|
+
const n = bindEvent.__v_raw || bindEvent;
|
|
784
|
+
if (Array.isArray(t[parentKey])) {
|
|
785
|
+
// @ts-ignore
|
|
786
|
+
const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
787
|
+
~index && this[parentKey].splice(index, 1);
|
|
788
|
+
params.index = index;
|
|
789
|
+
}
|
|
790
|
+
else if (t[parentKey] === n) {
|
|
791
|
+
params.index = 0;
|
|
792
|
+
this[parentKey] = undefined;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
return params;
|
|
796
|
+
}
|
|
797
|
+
removeBindDirective(options) {
|
|
798
|
+
let bindDirective;
|
|
799
|
+
if (typeof options === 'string') {
|
|
800
|
+
bindDirective = this.bindDirectives.find((item) => item.name === options);
|
|
801
|
+
if (!bindDirective) {
|
|
802
|
+
throw new Error('找不到元素指令 ' + options);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
bindDirective = options;
|
|
807
|
+
}
|
|
808
|
+
return bindDirective.delete();
|
|
809
|
+
}
|
|
810
|
+
__removeBindDirective(bindDirective) {
|
|
811
|
+
const parentKey = bindDirective.parentKey;
|
|
812
|
+
const params = {
|
|
813
|
+
parentNode: this,
|
|
814
|
+
parentKey,
|
|
815
|
+
index: -1,
|
|
816
|
+
object: null,
|
|
817
|
+
oldObject: bindDirective,
|
|
818
|
+
};
|
|
819
|
+
if (parentKey) {
|
|
820
|
+
params.parentKey = parentKey;
|
|
821
|
+
// @ts-ignore
|
|
822
|
+
const t = this.__v_raw || this;
|
|
823
|
+
// @ts-ignore
|
|
824
|
+
const n = bindDirective.__v_raw || bindDirective;
|
|
825
|
+
if (Array.isArray(t[parentKey])) {
|
|
826
|
+
// @ts-ignore
|
|
827
|
+
const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
828
|
+
~index && this[parentKey].splice(index, 1);
|
|
829
|
+
params.index = index;
|
|
830
|
+
}
|
|
831
|
+
else if (t[parentKey] === n) {
|
|
832
|
+
params.index = 0;
|
|
833
|
+
this[parentKey] = undefined;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return params;
|
|
837
|
+
}
|
|
838
|
+
removeBindStyle(options) {
|
|
839
|
+
let bindStyle;
|
|
840
|
+
if (typeof options === 'string') {
|
|
841
|
+
bindStyle = this.bindStyles.find((item) => item.name === options);
|
|
842
|
+
if (!bindStyle) {
|
|
843
|
+
throw new Error('找不到元素绑定样式 ' + options);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
847
|
+
bindStyle = options;
|
|
848
|
+
}
|
|
849
|
+
return bindStyle.delete();
|
|
850
|
+
}
|
|
851
|
+
__removeBindStyle(bindStyle) {
|
|
852
|
+
const parentKey = bindStyle.parentKey;
|
|
853
|
+
const params = {
|
|
854
|
+
parentNode: this,
|
|
855
|
+
parentKey,
|
|
856
|
+
index: -1,
|
|
857
|
+
object: null,
|
|
858
|
+
oldObject: bindStyle,
|
|
859
|
+
};
|
|
860
|
+
if (parentKey) {
|
|
861
|
+
params.parentKey = parentKey;
|
|
862
|
+
// @ts-ignore
|
|
863
|
+
const t = this.__v_raw || this;
|
|
864
|
+
// @ts-ignore
|
|
865
|
+
const n = bindStyle.__v_raw || bindStyle;
|
|
866
|
+
if (Array.isArray(t[parentKey])) {
|
|
867
|
+
// @ts-ignore
|
|
868
|
+
const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
869
|
+
~index && this[parentKey].splice(index, 1);
|
|
870
|
+
params.index = index;
|
|
871
|
+
}
|
|
872
|
+
else if (t[parentKey] === n) {
|
|
873
|
+
params.index = 0;
|
|
874
|
+
this[parentKey] = undefined;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return params;
|
|
878
|
+
}
|
|
879
|
+
removeViewElement(options) {
|
|
880
|
+
let viewElement;
|
|
881
|
+
if (typeof options === 'string') {
|
|
882
|
+
viewElement = this.children.find((item) => item.name === options);
|
|
883
|
+
if (!viewElement) {
|
|
884
|
+
throw new Error('找不到页面元素 ' + options);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
viewElement = options;
|
|
889
|
+
}
|
|
890
|
+
return viewElement.delete();
|
|
891
|
+
}
|
|
892
|
+
__removeViewElement(viewElement) {
|
|
893
|
+
const parentKey = viewElement.parentKey;
|
|
894
|
+
const params = {
|
|
895
|
+
parentNode: this,
|
|
896
|
+
parentKey,
|
|
897
|
+
index: -1,
|
|
898
|
+
object: null,
|
|
899
|
+
oldObject: viewElement,
|
|
900
|
+
};
|
|
901
|
+
if (parentKey) {
|
|
902
|
+
params.parentKey = parentKey;
|
|
903
|
+
// @ts-ignore
|
|
904
|
+
const t = this.__v_raw || this;
|
|
905
|
+
// @ts-ignore
|
|
906
|
+
const n = viewElement.__v_raw || viewElement;
|
|
907
|
+
if (Array.isArray(t[parentKey])) {
|
|
908
|
+
// @ts-ignore
|
|
909
|
+
const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
910
|
+
~index && this[parentKey].splice(index, 1);
|
|
911
|
+
params.index = index;
|
|
912
|
+
}
|
|
913
|
+
else if (t[parentKey] === n) {
|
|
914
|
+
params.index = 0;
|
|
915
|
+
this[parentKey] = undefined;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
return params;
|
|
919
|
+
}
|
|
920
|
+
//================================================================================
|
|
921
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
922
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
923
|
+
//================================================================================
|
|
924
|
+
/* 主页面有没有权限 */
|
|
925
|
+
get parentAuth() {
|
|
926
|
+
const _nameSpace = this.view.getNamespace();
|
|
927
|
+
const mainViewName = _nameSpace.split('.')[2];
|
|
928
|
+
return this.view.parentNode.concept === 'App'
|
|
929
|
+
? this.view.auth
|
|
930
|
+
: this.frontend.views.find((item) => item.name === mainViewName)?.auth;
|
|
931
|
+
}
|
|
932
|
+
// IDE内展示需要屏蔽掉“系统统一路径前缀”
|
|
933
|
+
get uiPath() {
|
|
934
|
+
return `${this.view.uiPath}/${this.name}`;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* 权限领域的资源路径
|
|
938
|
+
*/
|
|
939
|
+
get authPath() {
|
|
940
|
+
return `${this.view.path}/${this.name}`;
|
|
941
|
+
}
|
|
942
|
+
get auth() {
|
|
943
|
+
return this.bindDirectives.find((directive) => directive.name === 'auth');
|
|
944
|
+
}
|
|
945
|
+
getViewElementUniqueName(name = 'viewElement1') {
|
|
946
|
+
return this.view?.getViewElementUniqueName(name);
|
|
947
|
+
}
|
|
948
|
+
static TAG_NAME_PREFIX_REG = /^([lieu]|van)[-_]/;
|
|
949
|
+
static from(source, parentNode, parentKey) {
|
|
950
|
+
const node = super.from(source, parentNode, parentKey);
|
|
951
|
+
if (!node.name) {
|
|
952
|
+
const tagName = node.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
953
|
+
node.name = node.getViewElementUniqueName(`${tagName}1`);
|
|
954
|
+
}
|
|
955
|
+
return node;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* 设置组件权限
|
|
959
|
+
*/
|
|
960
|
+
setBindRoles(bindRoles) {
|
|
961
|
+
const object = {
|
|
962
|
+
bindRoles,
|
|
963
|
+
};
|
|
964
|
+
this.update({
|
|
965
|
+
...object,
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
getBindAttribute(name) {
|
|
969
|
+
return this.bindAttrs.find((bindAttr) => bindAttr.name === name);
|
|
970
|
+
}
|
|
971
|
+
toHump(name) {
|
|
972
|
+
return name.replace(/-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
973
|
+
}
|
|
974
|
+
toFirstUpper(name) {
|
|
975
|
+
return name.replace(/^\S/, (s) => s.toUpperCase());
|
|
976
|
+
}
|
|
977
|
+
haveScope() {
|
|
978
|
+
return Boolean(this.slotScope);
|
|
979
|
+
}
|
|
980
|
+
toEmbeddedTSDefinition(state) {
|
|
981
|
+
let code = '';
|
|
982
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
983
|
+
// 登录组件不翻译
|
|
984
|
+
if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form') {
|
|
985
|
+
code += `${this.name}: nasl.ui.div<any>;\n`;
|
|
986
|
+
}
|
|
987
|
+
else if (this.tag === 'u-table-view-column-dynamic') {
|
|
988
|
+
code += `${this.name}: nasl.ui.${this.toHump(this.tag)}<any, any>;\n`;
|
|
989
|
+
}
|
|
990
|
+
else if (Object.keys(View__1.PAGE_COMPONENT_INCLUDE_TAG_MAP).includes(this.tag)) {
|
|
991
|
+
if (this.bindAttrs?.findIndex((attr) => attr.name === 'data-source') > -1) {
|
|
992
|
+
code += `${this.name}: nasl.ui.${this.toHump(this.tag)}<__elements_completionProperty['${this.name}']['dataSource']>;\n`;
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
code += `${this.name}: nasl.ui.${this.toHump(this.tag)}<any>;\n`;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
code += `${this.name}: nasl.ui.${this.toHump(this.tag)}<any>;\n`;
|
|
1000
|
+
}
|
|
1001
|
+
if (Array.isArray(this.children)) {
|
|
1002
|
+
this.children.forEach((element) => {
|
|
1003
|
+
code += element.toEmbeddedTSDefinition((0, translator_1.shiftState)(state, code));
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
return code;
|
|
1007
|
+
}
|
|
1008
|
+
toEmbeddedTSVariableDefinition(state, variableList, nameLevel) {
|
|
1009
|
+
let code = '';
|
|
1010
|
+
let currentLevel = nameLevel ? `${nameLevel}?.` : '';
|
|
1011
|
+
currentLevel += `${this.name}?.()`;
|
|
1012
|
+
if (View__1.PAGE_COMPONENT_INCLUDE_TAG_MAP?.[this.tag]) {
|
|
1013
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1014
|
+
code += `${this.name}: {\n`;
|
|
1015
|
+
if (Array.isArray(this.bindAttrs)) {
|
|
1016
|
+
this.bindAttrs
|
|
1017
|
+
.filter((attr) => View__1.PAGE_COMPONENT_INCLUDE_TAG_MAP[this.tag]?.[attr.name])
|
|
1018
|
+
.forEach((attr) => {
|
|
1019
|
+
code += attr.toEmbeddedTSVariableDefinition((0, translator_1.shiftState)(state, code, { inline: true }), variableList, this.name, currentLevel);
|
|
1020
|
+
});
|
|
1021
|
+
if (['u-select', 'van-pickerson'].includes(this.tag)) {
|
|
1022
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1023
|
+
code += `pageNumber: nasl.core.Long\n`;
|
|
1024
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1025
|
+
code += `filterText: nasl.core.String\n`;
|
|
1026
|
+
}
|
|
1027
|
+
else if (['u-list-view', 'u-grid-view', 'u-table-view', 'van-list-view', 'van-grid-view'].includes(this.tag) &&
|
|
1028
|
+
this.bindAttrs?.findIndex((attr) => attr.name === 'sorting') === -1) {
|
|
1029
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1022
1030
|
code += `sorting: {
|
|
1023
1031
|
field: nasl.core.String
|
|
1024
1032
|
order: nasl.core.String
|
|
1025
|
-
}\n`;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1029
|
-
code += `};\n`;
|
|
1030
|
-
}
|
|
1031
|
-
if (Array.isArray(this.children)) {
|
|
1032
|
-
this.children.forEach((element) => {
|
|
1033
|
-
code += element.toEmbeddedTSVariableDefinition((0, translator_1.shiftState)(state, code), variableList, currentLevel);
|
|
1034
|
-
});
|
|
1035
|
-
}
|
|
1036
|
-
return code;
|
|
1037
|
-
}
|
|
1038
|
-
toEmbeddedTSVariableFunctionDefinition(state, parentLevel) {
|
|
1039
|
-
let code = '';
|
|
1040
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1041
|
-
let levelIndex = parentLevel || 0;
|
|
1042
|
-
code += `${this.name}: () => {\n`;
|
|
1043
|
-
if (this.tag === 'template' && this.haveScope() && this.parentNode instanceof ViewElement_1) {
|
|
1044
|
-
const currentType = this.parentNode.tag === 'u-table-view-column-dynamic' ? 'CurrentDynamic' : 'Current';
|
|
1045
|
-
const _this = this.parentNode;
|
|
1046
|
-
let genericity = '';
|
|
1047
|
-
if (_this.tag === 'u-table-view-column-dynamic') {
|
|
1048
|
-
genericity += `<${_this.parentNode.__tsVariableDataSourceTypeName}, ${_this.__tsVariableDataSourceTypeName}>`;
|
|
1049
|
-
}
|
|
1050
|
-
else {
|
|
1051
|
-
let targetNode = _this;
|
|
1052
|
-
while (!targetNode.__tsVariableDataSourceTypeName && targetNode?.parentNode instanceof ViewElement_1) {
|
|
1053
|
-
targetNode = targetNode.parentNode;
|
|
1054
|
-
}
|
|
1055
|
-
genericity += `<${targetNode.__tsVariableDataSourceTypeName ?? 'any'}>`;
|
|
1056
|
-
}
|
|
1057
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1058
|
-
code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}${genericity}\n`;
|
|
1059
|
-
levelIndex++;
|
|
1060
|
-
}
|
|
1061
|
-
const attr = this.bindAttrs?.find((item) => item.name === 'data-source');
|
|
1062
|
-
if (attr && attr.expression) {
|
|
1063
|
-
const datasourceName = `datasourceName${this.name}`;
|
|
1064
|
-
this.__tsVariableDataSourceTypeName = datasourceName;
|
|
1065
|
-
if (attr.expression instanceof MemberExpression__1.default ||
|
|
1066
|
-
attr.expression instanceof Identifier__1.default ||
|
|
1067
|
-
attr.expression instanceof concepts_1.CallLogic) {
|
|
1068
|
-
const extraParams = {
|
|
1069
|
-
tabSize: 4,
|
|
1070
|
-
inline: true,
|
|
1071
|
-
noNeedParams: true,
|
|
1072
|
-
};
|
|
1073
|
-
let value = attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}));
|
|
1074
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1075
|
-
code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<typeof ${value}>;\n`;
|
|
1076
|
-
// code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<typeof ${value}>>;\n`;
|
|
1077
|
-
}
|
|
1078
|
-
else {
|
|
1079
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1080
|
-
code += `const __funcName = () => { return `;
|
|
1081
|
-
code += attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code));
|
|
1082
|
-
code += '};\n';
|
|
1083
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1084
|
-
code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>;\n`;
|
|
1085
|
-
// code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>>;\n`;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1089
|
-
code += `return {\n`;
|
|
1090
|
-
if (Array.isArray(this.bindAttrs)) {
|
|
1091
|
-
this.bindAttrs
|
|
1092
|
-
.filter((attr) => View__1.PAGE_COMPONENT_INCLUDE_TAG_MAP[this.tag]?.[attr.name])
|
|
1093
|
-
.forEach((attr) => {
|
|
1094
|
-
code += attr.toEmbeddedTSVariableFunctionDefinition((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
if (Array.isArray(this.children)) {
|
|
1098
|
-
this.children.forEach((element) => {
|
|
1099
|
-
code += element.toEmbeddedTSVariableFunctionDefinition((0, translator_1.shiftState)({ ...state, tabSize: state.tabSize + 2 }, code), levelIndex);
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1103
|
-
code += `}\n`;
|
|
1104
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1105
|
-
code += `},\n`;
|
|
1106
|
-
return code;
|
|
1107
|
-
}
|
|
1108
|
-
getTypeArgmentsStr(state, currentNode) {
|
|
1109
|
-
// 登录组件不翻译
|
|
1110
|
-
if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
|
|
1111
|
-
return '<any>';
|
|
1112
|
-
let code = '';
|
|
1113
|
-
// formItem的单独处理
|
|
1114
|
-
if (this.tag === 'u-form-item') {
|
|
1115
|
-
if (Array.isArray(this.children) && this.children.length) {
|
|
1116
|
-
const tag = this.children[0].tag;
|
|
1117
|
-
if (tag === 'u-input') {
|
|
1118
|
-
code += '<nasl.core.String>';
|
|
1119
|
-
}
|
|
1120
|
-
else if (tag === 'u-input-number') {
|
|
1121
|
-
code += '<nasl.core.Long>';
|
|
1122
|
-
}
|
|
1123
|
-
else {
|
|
1124
|
-
code += '<any>';
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
return code;
|
|
1128
|
-
}
|
|
1129
|
-
if (this.tag === 'u-table-view-column-group') {
|
|
1130
|
-
code += `<${this.parentNode.__tsDataSourceTypeName}>`;
|
|
1131
|
-
return code;
|
|
1132
|
-
}
|
|
1133
|
-
const bindAttrs = this.bindAttrs;
|
|
1134
|
-
if (bindAttrs && bindAttrs.length) {
|
|
1135
|
-
const attr = bindAttrs.find((item) => item.name === 'data-source');
|
|
1136
|
-
if (attr && attr.expression) {
|
|
1137
|
-
if (this.tag === 'u-table-view-column-dynamic') {
|
|
1138
|
-
code += `<${this.parentNode.__tsDataSourceTypeName}, ${this.__tsDataSourceTypeName}>`;
|
|
1139
|
-
}
|
|
1140
|
-
else {
|
|
1141
|
-
code += `<${this.__tsDataSourceTypeName}>`;
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
return code;
|
|
1146
|
-
}
|
|
1147
|
-
getDatasourceTypeCodeStr(state, eleArr) {
|
|
1148
|
-
let code = '';
|
|
1149
|
-
(eleArr || []).forEach((element, index) => {
|
|
1150
|
-
const bindAttrs = element.bindAttrs;
|
|
1151
|
-
if (bindAttrs && bindAttrs.length) {
|
|
1152
|
-
const attr = bindAttrs.find((item) => item.name === 'data-source');
|
|
1153
|
-
if (attr && attr.expression) {
|
|
1154
|
-
const datasourceName = `datasourceName${element.name}`;
|
|
1155
|
-
element.__tsDataSourceTypeName = datasourceName;
|
|
1156
|
-
if (attr.expression instanceof MemberExpression__1.default ||
|
|
1157
|
-
attr.expression instanceof Identifier__1.default ||
|
|
1158
|
-
attr.expression instanceof concepts_1.CallLogic) {
|
|
1159
|
-
const extraParams = {
|
|
1160
|
-
tabSize: 4,
|
|
1161
|
-
inline: true,
|
|
1162
|
-
noNeedParams: true,
|
|
1163
|
-
};
|
|
1164
|
-
let value = attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}));
|
|
1165
|
-
code += `type ${datasourceName} = `;
|
|
1166
|
-
code += `nasl.ui.GetItemTypeFromDataSource<typeof ${value}>;\n`;
|
|
1167
|
-
}
|
|
1168
|
-
else {
|
|
1169
|
-
code += `const __funcName${index} = () => { return`;
|
|
1170
|
-
code += attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code));
|
|
1171
|
-
code += '};\n';
|
|
1172
|
-
code += `type ${datasourceName} = `;
|
|
1173
|
-
code += `nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName${index}>>;\n`;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
code += '\n';
|
|
1179
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1180
|
-
return code;
|
|
1181
|
-
}
|
|
1182
|
-
toEmbeddedTS(state, parentLevel) {
|
|
1183
|
-
const { parentNode, app, tag, staticClass, name, bindDirectives, bindRoles, bindEvents, children } = this;
|
|
1184
|
-
const chineseTsName = (name) => {
|
|
1185
|
-
let tsName = name;
|
|
1186
|
-
// 匹配所有特殊字符都转为_
|
|
1187
|
-
tsName = tsName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '_');
|
|
1188
|
-
if (/^\d/.test(tsName)) {
|
|
1189
|
-
tsName = '$' + tsName;
|
|
1190
|
-
}
|
|
1191
|
-
return tsName;
|
|
1192
|
-
};
|
|
1193
|
-
// 过滤模板的登录中的一些翻译,这里只过滤h5表格中的两个列
|
|
1194
|
-
if ((parentNode.concept === 'ViewElement' &&
|
|
1195
|
-
parentNode.tag &&
|
|
1196
|
-
this.toHump(parentNode.tag) === 'lcapLogin') ||
|
|
1197
|
-
staticClass === 'login-cell') {
|
|
1198
|
-
return '';
|
|
1199
|
-
}
|
|
1200
|
-
// pc事件翻译
|
|
1201
|
-
if (this.toHump(tag) === 'lcapLogin') {
|
|
1202
|
-
let code = `new nasl.ui.div({name: __elements.${this.name},\n`;
|
|
1203
|
-
// 事件
|
|
1204
|
-
if (Array.isArray(this.bindEvents)) {
|
|
1205
|
-
this.bindEvents.forEach((event) => {
|
|
1206
|
-
code += event.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1207
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
1208
|
-
}));
|
|
1209
|
-
code += '\n';
|
|
1210
|
-
});
|
|
1211
|
-
}
|
|
1212
|
-
code += `}),\n`;
|
|
1213
|
-
return code;
|
|
1214
|
-
}
|
|
1215
|
-
let levelIndex = parentLevel || 0;
|
|
1216
|
-
if (tag === 'template' && this.haveScope()) {
|
|
1217
|
-
const slotTarget = !this.slotTarget ? 'slotDefault' : 'slot' + this.toFirstUpper(this.toHump(this.slotTarget));
|
|
1218
|
-
let code = '';
|
|
1219
|
-
code += `${slotTarget}: (current${levelIndex === 0 ? '' : levelIndex})=> {\n`;
|
|
1220
|
-
code += this.getDatasourceTypeCodeStr(state, this.children);
|
|
1221
|
-
levelIndex++;
|
|
1222
|
-
code += 'return [';
|
|
1223
|
-
this.children.forEach((element) => {
|
|
1224
|
-
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1225
|
-
tabSize: state?.tabSize || 0,
|
|
1226
|
-
}), levelIndex);
|
|
1227
|
-
});
|
|
1228
|
-
code += ']';
|
|
1229
|
-
code += '\n';
|
|
1230
|
-
code += '},\n';
|
|
1231
|
-
return code;
|
|
1232
|
-
}
|
|
1233
|
-
else if (tag === 'template') {
|
|
1234
|
-
const slotTarget = !this.slotTarget ? 'slotDefault' : 'slot' + this.toFirstUpper(this.toHump(this.slotTarget));
|
|
1235
|
-
let code = '';
|
|
1236
|
-
code += `${slotTarget}: ()=> {\n`;
|
|
1237
|
-
code += this.getDatasourceTypeCodeStr(state, this.children);
|
|
1238
|
-
code += 'return [';
|
|
1239
|
-
this.children.forEach((element) => {
|
|
1240
|
-
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1241
|
-
tabSize: state?.tabSize || 0,
|
|
1242
|
-
}), levelIndex);
|
|
1243
|
-
});
|
|
1244
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1245
|
-
code += ']';
|
|
1246
|
-
code += '\n';
|
|
1247
|
-
code += '},\n';
|
|
1248
|
-
return code;
|
|
1249
|
-
}
|
|
1250
|
-
// 后面那个name是为了查找引用的时候用的
|
|
1251
|
-
let code = `new nasl.ui.${this.toHump(tag)}${this.getTypeArgmentsStr(state)}({name: __elements.${name},\n`;
|
|
1252
|
-
// 是否开启权限
|
|
1253
|
-
// const hasAuth = Array.isArray(bindDirectives)
|
|
1254
|
-
// ? !!bindDirectives.filter((directive) => directive.name === 'auth').length
|
|
1255
|
-
// : false;
|
|
1256
|
-
// 角色
|
|
1257
|
-
if (Array.isArray(bindRoles) && bindRoles.length) {
|
|
1258
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1259
|
-
code += 'roles: [\n';
|
|
1260
|
-
bindRoles.forEach((role) => {
|
|
1261
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1262
|
-
code += `${app.getNamespace()}.roles.${chineseTsName(role)}.${chineseTsName(role)},`;
|
|
1263
|
-
code += '\n';
|
|
1264
|
-
});
|
|
1265
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1266
|
-
code += '],\n';
|
|
1267
|
-
}
|
|
1268
|
-
// 事件
|
|
1269
|
-
if (Array.isArray(bindEvents)) {
|
|
1270
|
-
bindEvents.forEach((event) => {
|
|
1271
|
-
code += event.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1272
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
1273
|
-
}));
|
|
1274
|
-
code += '\n';
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1277
|
-
// 子元素
|
|
1278
|
-
if (Array.isArray(children)) {
|
|
1279
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1280
|
-
if (Array.isArray(this.bindAttrs)) {
|
|
1281
|
-
code += `bindAttr: () => [\n`;
|
|
1282
|
-
this.bindAttrs.forEach((attr) => (code += attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 })) + ',\n'));
|
|
1283
|
-
this.bindDirectives.forEach((directive) => (code += directive.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 })) + ',\n'));
|
|
1284
|
-
this.bindStyles.forEach((bindStyle) => (code += bindStyle.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 })) + ',\n'));
|
|
1285
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2) + '],\n';
|
|
1286
|
-
}
|
|
1287
|
-
// 如果子集中有插槽的就
|
|
1288
|
-
if (children.find((item) => item.tag === 'template' && item.slotTarget)) {
|
|
1289
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1290
|
-
const defaultArr = [];
|
|
1291
|
-
// 先把插槽翻译了
|
|
1292
|
-
children.forEach((element) => {
|
|
1293
|
-
if (element.tag === 'template') {
|
|
1294
|
-
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1295
|
-
tabSize: state?.tabSize || 0,
|
|
1296
|
-
}), levelIndex);
|
|
1297
|
-
}
|
|
1298
|
-
else {
|
|
1299
|
-
defaultArr.push(element);
|
|
1300
|
-
}
|
|
1301
|
-
});
|
|
1302
|
-
// 翻译其余的子集
|
|
1303
|
-
if (defaultArr.length) {
|
|
1304
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1305
|
-
code += `slotDefault: ()=> {\n`;
|
|
1306
|
-
code += this.getDatasourceTypeCodeStr(state, defaultArr);
|
|
1307
|
-
code += 'return [';
|
|
1308
|
-
defaultArr.forEach((element) => {
|
|
1309
|
-
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1310
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
1311
|
-
}), levelIndex);
|
|
1312
|
-
code += '\n';
|
|
1313
|
-
});
|
|
1314
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1315
|
-
code += ']\n';
|
|
1316
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1317
|
-
code += '}\n';
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
else {
|
|
1321
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1322
|
-
code += `slotDefault: ()=> {\n`;
|
|
1323
|
-
code += this.getDatasourceTypeCodeStr(state, children);
|
|
1324
|
-
code += 'return [';
|
|
1325
|
-
children.forEach((element) => {
|
|
1326
|
-
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1327
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
1328
|
-
}), levelIndex);
|
|
1329
|
-
code += '\n';
|
|
1330
|
-
});
|
|
1331
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1332
|
-
code += ']\n';
|
|
1333
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1334
|
-
code += '}\n';
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
code += (0, translator_1.indent)(state?.tabSize || 0) + '})';
|
|
1338
|
-
// 顶层元素是单独的表达式
|
|
1339
|
-
if (parentNode.concept === 'View') {
|
|
1340
|
-
code += ';\n';
|
|
1341
|
-
}
|
|
1342
|
-
else {
|
|
1343
|
-
code += ',\n';
|
|
1344
|
-
}
|
|
1345
|
-
return code;
|
|
1346
|
-
}
|
|
1347
|
-
toNaturalTS(state = (0, translator_1.createCompilerState)(), parentLevel) {
|
|
1348
|
-
let code = '';
|
|
1349
|
-
const levelIndex = parentLevel || 0;
|
|
1350
|
-
if (Array.isArray(this.bindEvents)) {
|
|
1351
|
-
this.bindEvents.forEach((event) => {
|
|
1352
|
-
code += event.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1353
|
-
tabSize: state.tabSize,
|
|
1354
|
-
}));
|
|
1355
|
-
// code += '\n';
|
|
1356
|
-
});
|
|
1357
|
-
}
|
|
1358
|
-
if (Array.isArray(this.children)) {
|
|
1359
|
-
if (this.children.find((item) => item.tag === 'template' && item.slotTarget)) {
|
|
1360
|
-
// code += indent(state.tabSize + 2);
|
|
1361
|
-
const defaultArr = [];
|
|
1362
|
-
// 先把插槽翻译了
|
|
1363
|
-
this.children.forEach((element) => {
|
|
1364
|
-
if (element.tag === 'template') {
|
|
1365
|
-
code += element.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1366
|
-
tabSize: state.tabSize,
|
|
1367
|
-
}), levelIndex);
|
|
1368
|
-
}
|
|
1369
|
-
else {
|
|
1370
|
-
defaultArr.push(element);
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1373
|
-
// 翻译其余的子集
|
|
1374
|
-
if (defaultArr.length) {
|
|
1375
|
-
defaultArr.forEach((element) => {
|
|
1376
|
-
code += element.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1377
|
-
tabSize: state.tabSize,
|
|
1378
|
-
}), levelIndex);
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
else {
|
|
1383
|
-
this.children.forEach((element) => {
|
|
1384
|
-
code += element.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1385
|
-
tabSize: state.tabSize,
|
|
1386
|
-
}), levelIndex);
|
|
1387
|
-
});
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
return code;
|
|
1391
|
-
}
|
|
1392
|
-
toNaturalTSDefinition(state) {
|
|
1393
|
-
let code = '';
|
|
1394
|
-
if (['u-button', 'u-form', 'u-modal', 'u-table-view', 'u-select', 'u-input', 'u-number-input'].includes(this.tag)) {
|
|
1395
|
-
code += (0, translator_1.indent)(state.tabSize + 1);
|
|
1396
|
-
// 登录组件不翻译
|
|
1397
|
-
// if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form') {
|
|
1398
|
-
// code += `${this.name}: nasl.ui.div;\n`;
|
|
1399
|
-
// } else {
|
|
1400
|
-
code += `${this.name}: nasl.ui.${(0, utils_1.kebab2Camel)(this.tag.replace(/^\w-/, ''))},\n`;
|
|
1401
|
-
// }
|
|
1402
|
-
}
|
|
1403
|
-
if (Array.isArray(this.children)) {
|
|
1404
|
-
this.children.forEach((element) => {
|
|
1405
|
-
code += element.toNaturalTSDefinition((0, translator_1.shiftState)(state, code));
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
return code;
|
|
1409
|
-
}
|
|
1410
|
-
_duplicate() {
|
|
1411
|
-
const element = ViewElement_1.from(this.toTemplateJSON());
|
|
1412
|
-
const nameMap = element.deepRenameElements(this);
|
|
1413
|
-
utils.traverse((current) => {
|
|
1414
|
-
const node = current.node;
|
|
1415
|
-
if (node.concept === 'CallLogic') {
|
|
1416
|
-
node.uuid = (0, uuid_1.v4)().replace(/-/g, '');
|
|
1417
|
-
if (/elements.(.+).logics/.test(node.calleeNamespace)) {
|
|
1418
|
-
const oldName = node.calleeNamespace.split('.')[1];
|
|
1419
|
-
if (nameMap.has(oldName)) {
|
|
1420
|
-
const newName = nameMap.get(oldName);
|
|
1421
|
-
node.calleeNamespace = `elements.${newName}.logics`;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
// 如果创建副本,内部的国际化标识都要去掉
|
|
1426
|
-
if (node.i18nKey) {
|
|
1427
|
-
delete node.i18nKey;
|
|
1428
|
-
}
|
|
1429
|
-
}, { node: element }, { mode: 'anyObject', excludedKeySet: element.JSON_EXCLUDED_KEYS });
|
|
1430
|
-
this.view.existingViewElement.clear();
|
|
1431
|
-
return element;
|
|
1432
|
-
}
|
|
1433
|
-
// 递归遍历组件
|
|
1434
|
-
traverseChildren(cb) {
|
|
1435
|
-
utils.traverse((current) => {
|
|
1436
|
-
cb(current.node);
|
|
1437
|
-
}, { node: this });
|
|
1438
|
-
}
|
|
1439
|
-
// 递归生成组件名
|
|
1440
|
-
deepRenameElements(node) {
|
|
1441
|
-
const map = new Map();
|
|
1442
|
-
this.traverseChildren((ele) => {
|
|
1443
|
-
const oldName = ele.name;
|
|
1444
|
-
const tagName = ele.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1445
|
-
ele.name = node.getViewElementUniqueName(`${tagName}1`);
|
|
1446
|
-
map.set(oldName, ele.name);
|
|
1447
|
-
});
|
|
1448
|
-
return map;
|
|
1449
|
-
}
|
|
1450
|
-
/**
|
|
1451
|
-
* 解析属性中的表达式
|
|
1452
|
-
* @param value
|
|
1453
|
-
* @param $def 目前 $def 只用来查找 $def.variables 和 $def.structures
|
|
1454
|
-
* @param dataSchema
|
|
1455
|
-
*/
|
|
1456
|
-
static _parseExpression(value) {
|
|
1457
|
-
try {
|
|
1458
|
-
const ast = babelParser.parseExpression(value);
|
|
1459
|
-
const node = transAstNodeToNaslNode(ast);
|
|
1460
|
-
return LogicItem__1.LogicItem.from(node, null, null);
|
|
1461
|
-
}
|
|
1462
|
-
catch (e) {
|
|
1463
|
-
return null;
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
static _parseValidationRule(value) {
|
|
1467
|
-
let calleeName = value;
|
|
1468
|
-
let args = [];
|
|
1469
|
-
try {
|
|
1470
|
-
const ast = babelParser.parseExpression(value);
|
|
1471
|
-
const validationNamespace = concepts_1.stdlibNamespace.findChild('validation');
|
|
1472
|
-
if (ast.type === 'CallExpression') {
|
|
1473
|
-
calleeName = (ast.callee?.property?.name ?? ast.callee?.property?.value ?? ast.callee?.name).replace(/\(.*/, '');
|
|
1474
|
-
const func = validationNamespace.functions.find((item) => item.name === calleeName);
|
|
1475
|
-
args = ast.arguments.map((argument, index) => ({
|
|
1476
|
-
concept: 'Argument',
|
|
1477
|
-
name: '',
|
|
1478
|
-
kind: 'Statement',
|
|
1479
|
-
keyword: func?.params?.[index]?.name ?? '',
|
|
1480
|
-
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
1481
|
-
}));
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
catch (error) { }
|
|
1485
|
-
return {
|
|
1486
|
-
concept: 'ValidationRule',
|
|
1487
|
-
name: '',
|
|
1488
|
-
label: '验证规则',
|
|
1489
|
-
kind: 'Expression',
|
|
1490
|
-
calleeNamespace: 'nasl.validation',
|
|
1491
|
-
arguments: args,
|
|
1492
|
-
calleeName,
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
/**
|
|
1496
|
-
* 从 Vue 的 ASTNode 转换成 ASL 元素
|
|
1497
|
-
* @param astNode Vue 的 ASTNode
|
|
1498
|
-
*/
|
|
1499
|
-
static _fromASTNode(astNode, context) {
|
|
1500
|
-
const view = context?.view;
|
|
1501
|
-
// 临时处理组件的 text
|
|
1502
|
-
//h5-mock
|
|
1503
|
-
if ([
|
|
1504
|
-
'u-text',
|
|
1505
|
-
'van-text',
|
|
1506
|
-
'u-link',
|
|
1507
|
-
'u-button',
|
|
1508
|
-
'u-label',
|
|
1509
|
-
'u-radio',
|
|
1510
|
-
'u-checkbox',
|
|
1511
|
-
'u-navbar-item',
|
|
1512
|
-
'u-sidebar-item',
|
|
1513
|
-
'u-menu-item',
|
|
1514
|
-
].includes(astNode.tag) &&
|
|
1515
|
-
astNode.children.length === 1 &&
|
|
1516
|
-
astNode.children[0].type === 3) {
|
|
1517
|
-
astNode.attrs = astNode.attrs || [];
|
|
1518
|
-
astNode.attrs.push({
|
|
1519
|
-
name: 'text',
|
|
1520
|
-
value: JSON.stringify(astNode.children[0].text),
|
|
1521
|
-
});
|
|
1522
|
-
astNode.children = [];
|
|
1523
|
-
}
|
|
1524
|
-
// 将 scopedSlots 合并到 children 中
|
|
1525
|
-
if (astNode.scopedSlots) {
|
|
1526
|
-
astNode.children = astNode.children || [];
|
|
1527
|
-
Object.keys(astNode.scopedSlots).forEach((key) => {
|
|
1528
|
-
if (!astNode.children.find((child) => key === child.slotTarget)) {
|
|
1529
|
-
astNode.children.unshift(astNode.scopedSlots[key]);
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
delete astNode.scopedSlots;
|
|
1533
|
-
}
|
|
1534
|
-
// 提示不支持的属性
|
|
1535
|
-
[
|
|
1536
|
-
'component',
|
|
1537
|
-
'inlineTemplate',
|
|
1538
|
-
'pre',
|
|
1539
|
-
'ns',
|
|
1540
|
-
'transition',
|
|
1541
|
-
'transitionOnAppear',
|
|
1542
|
-
'transitionMode',
|
|
1543
|
-
'slotName',
|
|
1544
|
-
'classBinding',
|
|
1545
|
-
'styleBinding',
|
|
1546
|
-
].forEach((key) => {
|
|
1547
|
-
if (astNode[key])
|
|
1548
|
-
console.warn(`[warn] ViewElement NASL unsupports '${key}' field in node `, astNode);
|
|
1549
|
-
});
|
|
1550
|
-
let element;
|
|
1551
|
-
if (astNode.type === 1) {
|
|
1552
|
-
if (astNode.tag === 'router-view') {
|
|
1553
|
-
if (view.frontend.type === 'h5') {
|
|
1554
|
-
astNode.tag = 'van-router-view';
|
|
1555
|
-
}
|
|
1556
|
-
else {
|
|
1557
|
-
astNode.tag = 'u-router-view';
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
const tagName = astNode.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1561
|
-
let newContext = {};
|
|
1562
|
-
if (context) {
|
|
1563
|
-
newContext = {
|
|
1564
|
-
...context,
|
|
1565
|
-
};
|
|
1566
|
-
}
|
|
1567
|
-
element = new ViewElement_1({
|
|
1568
|
-
tag: astNode.tag,
|
|
1569
|
-
name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
|
|
1570
|
-
staticClass: astNode.attrsMap.class,
|
|
1571
|
-
staticStyle: astNode.attrsMap.style,
|
|
1572
|
-
slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
|
|
1573
|
-
slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
|
|
1574
|
-
children: astNode.children.map((item) => this._fromASTNode(item, newContext)),
|
|
1575
|
-
});
|
|
1576
|
-
astNode?.attrs?.forEach((oldAttr) => {
|
|
1577
|
-
let attr;
|
|
1578
|
-
// 获取原始属性
|
|
1579
|
-
const orginAttrCode = (context?.code || '').substr(oldAttr.start, oldAttr.end - oldAttr.start);
|
|
1580
|
-
if (oldAttr.value === '""' && orginAttrCode.trim() === oldAttr.name) {
|
|
1581
|
-
attr = new BindAttribute__1.default({
|
|
1582
|
-
type: 'static',
|
|
1583
|
-
name: oldAttr.name,
|
|
1584
|
-
value: 'true',
|
|
1585
|
-
});
|
|
1586
|
-
}
|
|
1587
|
-
else {
|
|
1588
|
-
try {
|
|
1589
|
-
const tmp = json5.parse(oldAttr.value);
|
|
1590
|
-
const source = {
|
|
1591
|
-
type: typeof tmp === 'string' ? 'string' : 'static',
|
|
1592
|
-
name: oldAttr.name,
|
|
1593
|
-
value: typeof tmp === 'string' ? tmp : oldAttr.value,
|
|
1594
|
-
};
|
|
1595
|
-
if (oldAttr.name === 'rules') {
|
|
1596
|
-
source.rules = tmp?.split('|').map((ruleStr) => this._parseValidationRule(ruleStr.trim()));
|
|
1597
|
-
}
|
|
1598
|
-
else if (['page-number', 'page-size'].includes(oldAttr.name)) {
|
|
1599
|
-
source.value = Number(source.value);
|
|
1600
|
-
}
|
|
1601
|
-
attr = new BindAttribute__1.default(source);
|
|
1602
|
-
}
|
|
1603
|
-
catch (e) {
|
|
1604
|
-
const expression = this._parseExpression(oldAttr.value);
|
|
1605
|
-
attr = new BindAttribute__1.default({
|
|
1606
|
-
type: 'dynamic',
|
|
1607
|
-
name: oldAttr.name,
|
|
1608
|
-
value: expression ? '' : oldAttr.value,
|
|
1609
|
-
expression,
|
|
1610
|
-
});
|
|
1611
|
-
if (astNode.attrsMap[`:${attr.name}.sync`]) {
|
|
1612
|
-
attr.sync = true;
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
element.addBindAttribute(attr);
|
|
1617
|
-
});
|
|
1618
|
-
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
1619
|
-
astNode.events &&
|
|
1620
|
-
Object.keys(astNode.events)
|
|
1621
|
-
.filter((name) => !name.startsWith('update:'))
|
|
1622
|
-
.forEach((name) => {
|
|
1623
|
-
const oldEvent = astNode.events[name];
|
|
1624
|
-
const str = oldEvent.value;
|
|
1625
|
-
const calleeName = str.split('(')[0];
|
|
1626
|
-
const matchArr = str.match(/\(([^)]*)\)/) || [];
|
|
1627
|
-
let argsStr = '';
|
|
1628
|
-
if (matchArr?.length >= 2) {
|
|
1629
|
-
argsStr = matchArr[1];
|
|
1630
|
-
}
|
|
1631
|
-
let args = [];
|
|
1632
|
-
const argStrs = argsStr.split(',');
|
|
1633
|
-
args = argStrs
|
|
1634
|
-
.filter((argStr) => !!argStr)
|
|
1635
|
-
.map((argStr) => {
|
|
1636
|
-
const keyword = argStr.trim().split('.');
|
|
1637
|
-
return {
|
|
1638
|
-
concept: 'Argument',
|
|
1639
|
-
expression: genArgumentMemberExpression(keyword),
|
|
1640
|
-
};
|
|
1641
|
-
});
|
|
1642
|
-
const viewLogics = context?.definition?.viewLogics || [];
|
|
1643
|
-
const currentLogic = viewLogics.find((item) => item.name === calleeName);
|
|
1644
|
-
if (currentLogic) {
|
|
1645
|
-
element.addBindEvent(new BindEvent__1.default({
|
|
1646
|
-
name,
|
|
1647
|
-
calleeNamespace: '',
|
|
1648
|
-
calleeName: '',
|
|
1649
|
-
arguments: args,
|
|
1650
|
-
logics: [currentLogic],
|
|
1651
|
-
}));
|
|
1652
|
-
}
|
|
1653
|
-
});
|
|
1654
|
-
astNode.directives &&
|
|
1655
|
-
astNode.directives.forEach((directive) => {
|
|
1656
|
-
if (directive.name === 'model') {
|
|
1657
|
-
const valueAttr = astNode.attrs && astNode.attrs.find((attr) => attr.name === 'value');
|
|
1658
|
-
if (!valueAttr) {
|
|
1659
|
-
const expression = this._parseExpression(directive.value);
|
|
1660
|
-
element.addBindAttribute(new BindAttribute__1.default({
|
|
1661
|
-
type: 'dynamic',
|
|
1662
|
-
name: 'value',
|
|
1663
|
-
value: expression ? '' : directive.value,
|
|
1664
|
-
expression,
|
|
1665
|
-
sync: true,
|
|
1666
|
-
}));
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
else {
|
|
1670
|
-
const expression = this._parseExpression(directive.value);
|
|
1671
|
-
element.addBindDirective(new BindDirective__1.default({
|
|
1672
|
-
type: expression ? 'string' : 'dynamic',
|
|
1673
|
-
name: directive.name,
|
|
1674
|
-
rawName: directive.rawName,
|
|
1675
|
-
value: expression ? '' : directive.value,
|
|
1676
|
-
expression,
|
|
1677
|
-
arg: directive.arg,
|
|
1678
|
-
// modifiers: directive.modifiers,
|
|
1679
|
-
}));
|
|
1680
|
-
}
|
|
1681
|
-
});
|
|
1682
|
-
if (astNode.if) {
|
|
1683
|
-
element.addBindDirective(new BindDirective__1.default({
|
|
1684
|
-
type: 'dynamic',
|
|
1685
|
-
name: 'if',
|
|
1686
|
-
rawName: 'v-if',
|
|
1687
|
-
value: '',
|
|
1688
|
-
expression: this._parseExpression(astNode.if),
|
|
1689
|
-
}));
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
else if (astNode.type === 2) {
|
|
1693
|
-
const tagName = config_1.config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1694
|
-
const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1695
|
-
element = new ViewElement_1({
|
|
1696
|
-
tag: tagName,
|
|
1697
|
-
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1698
|
-
});
|
|
1699
|
-
const value = astNode.text?.match(/{{(.*?)}}/)[1].trim();
|
|
1700
|
-
const expression = this._parseExpression(value);
|
|
1701
|
-
element.addBindAttribute(new BindAttribute__1.default({
|
|
1702
|
-
type: 'dynamic',
|
|
1703
|
-
name: 'text',
|
|
1704
|
-
value: expression ? '' : value,
|
|
1705
|
-
expression,
|
|
1706
|
-
}));
|
|
1707
|
-
}
|
|
1708
|
-
else if (astNode.type === 3) {
|
|
1709
|
-
const tagName = config_1.config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1710
|
-
const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1711
|
-
element = new ViewElement_1({
|
|
1712
|
-
tag: tagName,
|
|
1713
|
-
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1714
|
-
});
|
|
1715
|
-
element.addBindAttribute(new BindAttribute__1.default({
|
|
1716
|
-
name: 'text',
|
|
1717
|
-
type: 'string',
|
|
1718
|
-
value: astNode.text?.trim(),
|
|
1719
|
-
}));
|
|
1720
|
-
}
|
|
1721
|
-
return element;
|
|
1722
|
-
}
|
|
1723
|
-
/**
|
|
1724
|
-
* 解析 Vue 模板
|
|
1725
|
-
* 该方法不会绑定 view 和 parent,如果是添加元素优先使用 fromHTML
|
|
1726
|
-
* @param html Vue 的模板
|
|
1727
|
-
* @TODO 处理多个元素的问题
|
|
1728
|
-
*/
|
|
1729
|
-
static parse(code, context) {
|
|
1730
|
-
code = code || '<div></div>';
|
|
1731
|
-
const compilerOptions = {
|
|
1732
|
-
preserveWhitespace: false,
|
|
1733
|
-
outputSourceRange: true,
|
|
1734
|
-
};
|
|
1735
|
-
let ast = compiler.compile(code, compilerOptions).ast;
|
|
1736
|
-
if (ast.tag === 'template' && !ast.slotTarget)
|
|
1737
|
-
ast = ast.children[0];
|
|
1738
|
-
return this._fromASTNode(ast, {
|
|
1739
|
-
...context,
|
|
1740
|
-
code,
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
1743
|
-
/**
|
|
1744
|
-
* 从模板生成规范的 ViewElement 对象
|
|
1745
|
-
*/
|
|
1746
|
-
static fromHTML(html, context) {
|
|
1747
|
-
return this.parse(html, context);
|
|
1748
|
-
}
|
|
1749
|
-
/**
|
|
1750
|
-
* 转换成设计器中使用的 Vue 文件
|
|
1751
|
-
* @param options
|
|
1752
|
-
*/
|
|
1753
|
-
toDesignerVue() {
|
|
1754
|
-
return this.toVue({
|
|
1755
|
-
finalCode: false,
|
|
1756
|
-
nodePathAttr: true,
|
|
1757
|
-
attrFormat: (attr, element, defaultResult) => {
|
|
1758
|
-
if (attr.concept === 'BindAttribute' &&
|
|
1759
|
-
!['href', 'destination', 'externalDestination', 'download'].includes(attr.name)) {
|
|
1760
|
-
const api = config_1.config?.allNodesAPI?.[element.tag];
|
|
1761
|
-
const apiOfAttr = api && api.attrs && api.attrs.find((_attr) => _attr.name === attr.name);
|
|
1762
|
-
if (['u-form-item', 'u-validator', 'van-field'].includes(element.tag) && attr.name === 'rules') {
|
|
1763
|
-
return `${attr.name}=""`;
|
|
1764
|
-
}
|
|
1765
|
-
if (apiOfAttr && apiOfAttr['designer-value'] !== undefined) {
|
|
1766
|
-
let designerValue = apiOfAttr['designer-value'];
|
|
1767
|
-
//对流程模板拖拽进行特判
|
|
1768
|
-
element.bindAttrs.forEach((property) => {
|
|
1769
|
-
if (property.name === 'repeat' && property.value === '1')
|
|
1770
|
-
designerValue = '[{}, {}]';
|
|
1771
|
-
});
|
|
1772
|
-
if (typeof designerValue === 'string') {
|
|
1773
|
-
designerValue = designerValue.replace(/"/g, "'");
|
|
1774
|
-
}
|
|
1775
|
-
try {
|
|
1776
|
-
json5.parse(designerValue);
|
|
1777
|
-
return `:${attr.name}="${designerValue}"`;
|
|
1778
|
-
}
|
|
1779
|
-
catch (e) {
|
|
1780
|
-
return `${attr.name}="${designerValue}"`;
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
if (attr.type === 'dynamic' &&
|
|
1784
|
-
!(element.tag === 'u-cascade-select' && attr.name === 'categories'))
|
|
1785
|
-
return defaultResult.replace(/:?([\w-]+)(?:.*?)="([\s\S]*)"/, (m, name, value) => {
|
|
1786
|
-
try {
|
|
1787
|
-
const tempValue = json5.parse(value);
|
|
1788
|
-
if (typeof tempValue === 'boolean' || typeof tempValue === 'number') {
|
|
1789
|
-
// 简单类型走属性
|
|
1790
|
-
return `:${name}="${value.replace(/"/g, "'")}"`;
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
catch (e) {
|
|
1794
|
-
if (apiOfAttr && !apiOfAttr.type.includes('string'))
|
|
1795
|
-
return '';
|
|
1796
|
-
}
|
|
1797
|
-
value = value
|
|
1798
|
-
.replace(/"/g, "'")
|
|
1799
|
-
.replace(/\$utils\['(.+?)'\]/g, '$1')
|
|
1800
|
-
.replace(/\$refs./g, 'elements.')
|
|
1801
|
-
.replace(/\$global.userInfo/g, 'nasl.auth.userInfo')
|
|
1802
|
-
.replace(/\$global./g, 'nasl.')
|
|
1803
|
-
.replace(/\bscope\.item\.\b/g, '')
|
|
1804
|
-
.replace(/\bcurrent\.item\.\b/g, '');
|
|
1805
|
-
return `${name}="{{ ${value} }}"`;
|
|
1806
|
-
});
|
|
1807
|
-
else
|
|
1808
|
-
return defaultResult;
|
|
1809
|
-
}
|
|
1810
|
-
return false;
|
|
1811
|
-
},
|
|
1812
|
-
bindStylesFormat: (bindStyles, element) => false,
|
|
1813
|
-
getExtraParts: (el) => {
|
|
1814
|
-
const parts = [];
|
|
1815
|
-
const api = config_1.config.allNodesAPI[el.tag];
|
|
1816
|
-
const emptySlot = api && api.slots && api.slots.find((slot) => slot.name === 'default' && slot['empty-background']);
|
|
1817
|
-
const hasSupport = api && api.slots && api.slots.some((slot) => slot.support);
|
|
1818
|
-
if (emptySlot || hasSupport) {
|
|
1819
|
-
// 有些限制的组件如侧边栏分组有title插槽但要限制子元素放入
|
|
1820
|
-
const validChildren = el.children.filter((elem) => !(elem.tag === 'template' && elem.slotTarget !== 'default'));
|
|
1821
|
-
let childEmpty = !validChildren.length;
|
|
1822
|
-
const defaultSlot = el.children.find((elem) => elem.tag === 'template' && elem.slotTarget === 'default');
|
|
1823
|
-
if (defaultSlot) {
|
|
1824
|
-
childEmpty = !defaultSlot.children.length;
|
|
1825
|
-
}
|
|
1826
|
-
if (childEmpty) {
|
|
1827
|
-
let addEmpty = true;
|
|
1828
|
-
if (['u-grid-view', 'u-list-view', 'van-list-view', 'van-grid-view', 'u-carousel'].includes(el.tag)) {
|
|
1829
|
-
const hasDataSource = el.bindAttrs.find((attr) => attr.name === 'data-source');
|
|
1830
|
-
addEmpty = !hasDataSource;
|
|
1831
|
-
}
|
|
1832
|
-
if (el.tag === 'u-crumb') {
|
|
1833
|
-
const attrList = el.bindAttrs;
|
|
1834
|
-
const hasAuto = attrList.some((attr) => attr.name === 'auto' && String(attr.value) === 'true');
|
|
1835
|
-
if (hasAuto)
|
|
1836
|
-
addEmpty = false;
|
|
1837
|
-
}
|
|
1838
|
-
if ([
|
|
1839
|
-
'u-select',
|
|
1840
|
-
'u-dropdown',
|
|
1841
|
-
'u-panel',
|
|
1842
|
-
'u-toc',
|
|
1843
|
-
'u-toc-item',
|
|
1844
|
-
'u-tree-view-new',
|
|
1845
|
-
'u-tree-view-node-new',
|
|
1846
|
-
'u-tree-select',
|
|
1847
|
-
'u-tree-select-new',
|
|
1848
|
-
'u-anchor',
|
|
1849
|
-
'u-drawer',
|
|
1850
|
-
'u-timeline',
|
|
1851
|
-
'u-tabs',
|
|
1852
|
-
].includes(el.tag)) {
|
|
1853
|
-
addEmpty = false;
|
|
1854
|
-
}
|
|
1855
|
-
const background = (emptySlot && emptySlot['empty-background']) || (hasSupport ? 'add-sub' : '');
|
|
1856
|
-
addEmpty && parts.push(`vusion-empty-background="${background}"`);
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
if (['u-router-view', 'van-router-view'].includes(el.tag)) {
|
|
1860
|
-
const excludes = ['background-color:', 'background:', 'background-image:'];
|
|
1861
|
-
if (excludes.some((key) => el.staticStyle && el.staticStyle.includes(key))) {
|
|
1862
|
-
parts.push(':designer="false"');
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
return parts;
|
|
1866
|
-
},
|
|
1867
|
-
});
|
|
1868
|
-
}
|
|
1869
|
-
// 获取currentList
|
|
1870
|
-
getCurrentList() {
|
|
1871
|
-
const argsList = [];
|
|
1872
|
-
let parent = this.parentNode;
|
|
1873
|
-
let index = 0;
|
|
1874
|
-
while (parent && parent.concept !== 'View') {
|
|
1875
|
-
if (parent.slotScope) {
|
|
1876
|
-
argsList.push(index === 0 ? 'current' : 'current' + index);
|
|
1877
|
-
index++;
|
|
1878
|
-
}
|
|
1879
|
-
parent = parent.parentNode;
|
|
1880
|
-
}
|
|
1881
|
-
return argsList;
|
|
1882
|
-
}
|
|
1883
|
-
get refName() {
|
|
1884
|
-
let refName = this.name;
|
|
1885
|
-
const list = this.getCurrentList();
|
|
1886
|
-
if (Array.isArray(list) && list.length) {
|
|
1887
|
-
list.forEach((item) => {
|
|
1888
|
-
refName += `_\${(${item} || {}).__nodeKey || (${item} || {}).index}`;
|
|
1889
|
-
});
|
|
1890
|
-
}
|
|
1891
|
-
return refName;
|
|
1892
|
-
}
|
|
1893
|
-
get keyName() {
|
|
1894
|
-
// 是否配置了v-if
|
|
1895
|
-
const isDefineIf = this.bindDirectives.some((directive) => directive.name === 'if' && directive.expression);
|
|
1896
|
-
if (isDefineIf) {
|
|
1897
|
-
let key = this.name;
|
|
1898
|
-
const list = this.getCurrentList();
|
|
1899
|
-
// v-for中需要加上nodeKey
|
|
1900
|
-
if (Array.isArray(list) && list.length) {
|
|
1901
|
-
list.forEach((item) => {
|
|
1902
|
-
key += `_\${(${item} || {}).__nodeKey || (${item} || {}).index}`;
|
|
1903
|
-
});
|
|
1904
|
-
}
|
|
1905
|
-
return key;
|
|
1906
|
-
}
|
|
1907
|
-
return null;
|
|
1908
|
-
}
|
|
1909
|
-
/**
|
|
1910
|
-
* 转换成 Vue 的模板格式
|
|
1911
|
-
*/
|
|
1912
|
-
toVue(options) {
|
|
1913
|
-
let currentList = [];
|
|
1914
|
-
if (Array.isArray(options?.currentList)) {
|
|
1915
|
-
currentList = [...options?.currentList];
|
|
1916
|
-
}
|
|
1917
|
-
if (this.slotScope) {
|
|
1918
|
-
currentList.unshift(this.slotScope);
|
|
1919
|
-
}
|
|
1920
|
-
const newOptions = Object.assign({
|
|
1921
|
-
indentStyle: 'space',
|
|
1922
|
-
tabSize: 4,
|
|
1923
|
-
indentLevel: 0,
|
|
1924
|
-
aslIdAttr: false,
|
|
1925
|
-
nodePathAttr: false,
|
|
1926
|
-
getExtraParts: () => [],
|
|
1927
|
-
attrFormat: (attr, element, defaultResult) => defaultResult,
|
|
1928
|
-
bindStylesFormat: (bindStyles, element) => {
|
|
1929
|
-
if (bindStyles.length === 0)
|
|
1930
|
-
return false;
|
|
1931
|
-
return `:style="{${bindStyles
|
|
1932
|
-
.map((item) => item.toVue())
|
|
1933
|
-
.filter((item) => item !== undefined)
|
|
1934
|
-
.join(', ')}}"`;
|
|
1935
|
-
},
|
|
1936
|
-
}, options, {
|
|
1937
|
-
currentList,
|
|
1938
|
-
});
|
|
1939
|
-
const tabString = ' '.repeat(newOptions.tabSize * newOptions.indentLevel);
|
|
1940
|
-
const insideTabString = ' '.repeat(newOptions.tabSize * (newOptions.indentLevel + 1));
|
|
1941
|
-
let shouldIndent = true;
|
|
1942
|
-
const content = !this.children
|
|
1943
|
-
? ''
|
|
1944
|
-
: this.children
|
|
1945
|
-
.map((element) => {
|
|
1946
|
-
const childOptions = Object.assign({}, newOptions);
|
|
1947
|
-
childOptions.indentLevel++;
|
|
1948
|
-
return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
|
|
1949
|
-
})
|
|
1950
|
-
.join('');
|
|
1951
|
-
if (!content.length) {
|
|
1952
|
-
shouldIndent = false;
|
|
1953
|
-
}
|
|
1954
|
-
const parts = [];
|
|
1955
|
-
if (newOptions.aslIdAttr) {
|
|
1956
|
-
if (newOptions.aslIdAttr === true) {
|
|
1957
|
-
newOptions.aslIdAttr = 'asl-id';
|
|
1958
|
-
}
|
|
1959
|
-
parts.push(`${newOptions.aslIdAttr}="${this.id}"`);
|
|
1960
|
-
}
|
|
1961
|
-
if (newOptions.nodePathAttr) {
|
|
1962
|
-
// 注入 asl 的 node-path
|
|
1963
|
-
parts.push(`vusion-node-path="${this.nodePath}"`);
|
|
1964
|
-
}
|
|
1965
|
-
// 模板里解析时候,可能会有多级嵌套的 current,所以当前有多少的长度,当前就是多大的下标
|
|
1966
|
-
this.slotTarget &&
|
|
1967
|
-
parts.push(`#${this.slotTarget}` +
|
|
1968
|
-
(this.slotScope
|
|
1969
|
-
? `="${currentList.length > 1 ? this.slotScope + (currentList.length - 1) : this.slotScope}"`
|
|
1970
|
-
: ''));
|
|
1971
|
-
this.refName && parts.push(`:ref="\`${this.refName}\`"`);
|
|
1972
|
-
this.keyName && parts.push(`:key="\`${this.keyName}\`"`);
|
|
1973
|
-
this.staticClass && parts.push(`class="${this.staticClass}"`);
|
|
1974
|
-
this.staticStyle && parts.push(`style="${this.staticStyle}"`);
|
|
1975
|
-
const vIfs = [];
|
|
1976
|
-
[]
|
|
1977
|
-
.concat(this.bindAttrs, this.bindDirectives, this.bindEvents)
|
|
1978
|
-
.forEach((attr) => {
|
|
1979
|
-
const result = newOptions.attrFormat(attr, this, attr?.toVue(newOptions));
|
|
1980
|
-
// v-auth v-if 都翻译成 v-if
|
|
1981
|
-
if (attr instanceof BindDirective__1.default && ['if', 'auth'].includes(attr.name) && result !== false) {
|
|
1982
|
-
const expr = result.replace(/v-(if|auth)="(.*)"/, (match, p1, p2) => p2);
|
|
1983
|
-
if (expr)
|
|
1984
|
-
vIfs.push(attr.name === 'if' ? expr : `$auth.has(${expr})`);
|
|
1985
|
-
return;
|
|
1986
|
-
}
|
|
1987
|
-
result && parts.push(result);
|
|
1988
|
-
});
|
|
1989
|
-
if (vIfs.length === 2)
|
|
1990
|
-
parts.push(`v-if="(${vIfs[0]}) && (${vIfs[1]})"`);
|
|
1991
|
-
else if (vIfs.length === 1)
|
|
1992
|
-
parts.push(`v-if="${vIfs[0]}"`);
|
|
1993
|
-
const bindStyles = newOptions.bindStylesFormat(this.bindStyles, this);
|
|
1994
|
-
if (bindStyles)
|
|
1995
|
-
parts.push(bindStyles);
|
|
1996
|
-
newOptions.getExtraParts(this).forEach((part) => parts.push(part));
|
|
1997
|
-
if (['u-modal', 'u-drawer'].includes(this.tag)) {
|
|
1998
|
-
this.children.forEach((citem) => {
|
|
1999
|
-
if (citem.tag === 'template' && !citem.children.length) {
|
|
2000
|
-
parts.push(`:is-${citem.slotTarget}-slot-empty=true`);
|
|
2001
|
-
}
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
// 部分组件增加 key 唯一标识,防止 vue 判断重复节点,导致渲染异常
|
|
2005
|
-
if (this.name &&
|
|
2006
|
-
['u-table-view', 'u-list-view', 'u-grid-view', 'u-list-components', 'u-form', 'u-select'].includes(this.tag)) {
|
|
2007
|
-
this.name && parts.push(`key="${this.name}"`);
|
|
2008
|
-
}
|
|
2009
|
-
let partsLength = 0;
|
|
2010
|
-
let partsString = '';
|
|
2011
|
-
parts.forEach((part) => {
|
|
2012
|
-
if (partsLength >= 120 || part.length >= 120) {
|
|
2013
|
-
partsString += '\n' + tabString + ' '.repeat(3); // ' '.repeat(el.tag.length + 1);
|
|
2014
|
-
partsLength = 0;
|
|
2015
|
-
}
|
|
2016
|
-
partsString += ' ' + part;
|
|
2017
|
-
partsLength += part.length;
|
|
2018
|
-
});
|
|
2019
|
-
let htmlContent = `<${this.tag}${partsString.length ? partsString : ''}>` +
|
|
2020
|
-
content +
|
|
2021
|
-
(shouldIndent ? '\n' + tabString : '') +
|
|
2022
|
-
`</${this.tag}>`;
|
|
2023
|
-
if (!content.trim() && selfClosingTag.includes(this.tag)) {
|
|
2024
|
-
htmlContent = `<${this.tag}${partsString.length ? partsString : ''} />`;
|
|
2025
|
-
}
|
|
2026
|
-
return htmlContent;
|
|
2027
|
-
}
|
|
2028
|
-
/**
|
|
2029
|
-
* 从父级删除该节点
|
|
2030
|
-
* @internal
|
|
2031
|
-
*/
|
|
2032
|
-
delete() {
|
|
2033
|
-
super.delete();
|
|
2034
|
-
if (this.parentNode) {
|
|
2035
|
-
this.traverseChildren((ele) => {
|
|
2036
|
-
this.view?.removeExistingViewElement(ele);
|
|
2037
|
-
});
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
findElementByName(name) {
|
|
2041
|
-
return utils.traverse((current) => {
|
|
2042
|
-
if (current.node.name === name)
|
|
2043
|
-
return current.node;
|
|
2044
|
-
}, { node: this });
|
|
2045
|
-
}
|
|
2046
|
-
findElementByTag(tag) {
|
|
2047
|
-
return utils.traverse((current) => {
|
|
2048
|
-
if (current.node.tag === tag)
|
|
2049
|
-
return current.node;
|
|
2050
|
-
}, { node: this });
|
|
2051
|
-
}
|
|
2052
|
-
findElementByAttr(name, value) {
|
|
2053
|
-
return utils.traverse((current) => {
|
|
2054
|
-
if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
|
|
2055
|
-
return current.node;
|
|
2056
|
-
}, { node: this });
|
|
2057
|
-
}
|
|
2058
|
-
computedStyle = {};
|
|
2059
|
-
getCurrentName() {
|
|
2060
|
-
let current = 'current';
|
|
2061
|
-
let parent = this.parentNode;
|
|
2062
|
-
let index = 0;
|
|
2063
|
-
while (parent && parent.concept !== 'View') {
|
|
2064
|
-
if (parent.slotScope) {
|
|
2065
|
-
index++;
|
|
2066
|
-
}
|
|
2067
|
-
parent = parent.parentNode;
|
|
2068
|
-
}
|
|
2069
|
-
current = index === 0 ? 'current' : 'current' + index;
|
|
2070
|
-
return current;
|
|
2071
|
-
}
|
|
2072
|
-
/**
|
|
2073
|
-
* 计算约束样式
|
|
2074
|
-
* @param positionData 位置数据
|
|
2075
|
-
* @param doNotRecordLastWidthHeight 是否不记录上一次的宽高
|
|
2076
|
-
*/
|
|
2077
|
-
computeConstraintStyle(positionData, ops = {}) {
|
|
2078
|
-
if (!positionData) {
|
|
2079
|
-
return;
|
|
2080
|
-
}
|
|
2081
|
-
const { nodeRect, parentRect, parentBorder } = positionData;
|
|
2082
|
-
const staticWidth = nodeRect.width;
|
|
2083
|
-
const staticHeight = nodeRect.height;
|
|
2084
|
-
const staticLeft = nodeRect.left - parentRect.left - parentBorder.left;
|
|
2085
|
-
const staticTop = nodeRect.top - parentRect.top - parentBorder.top;
|
|
2086
|
-
const staticRight = parentRect.width - nodeRect.width - staticLeft - parentBorder.right - parentBorder.left;
|
|
2087
|
-
const staticBottom = parentRect.height - nodeRect.height - staticTop - parentBorder.bottom - parentBorder.top;
|
|
2088
|
-
const styleObj = this.parseStyleToObject(this.staticStyle);
|
|
2089
|
-
const constraintX = styleObj['--constraint-x'] || 'left';
|
|
2090
|
-
const constraintY = styleObj['--constraint-y'] || 'top';
|
|
2091
|
-
const rawWidth = styleObj.width || '';
|
|
2092
|
-
const rawHeight = styleObj.height || '';
|
|
2093
|
-
let left = '';
|
|
2094
|
-
let right = '';
|
|
2095
|
-
let top = '';
|
|
2096
|
-
let bottom = '';
|
|
2097
|
-
let transform = '';
|
|
2098
|
-
// 如果宽高被约束规则改成 auto 了,就还原为上次的宽高,防止用户设置的宽高信息在切换约束时候丢失
|
|
2099
|
-
let width = Number(styleObj['--constraint-width-auto']) ? styleObj['--last-width'] : rawWidth;
|
|
2100
|
-
let height = Number(styleObj['--constraint-height-auto']) ? styleObj['--last-height'] : rawHeight;
|
|
2101
|
-
// 用于记录宽高是否被约束规则改成 auto 了
|
|
2102
|
-
let constraintWidthAuto = 0;
|
|
2103
|
-
let constraintHeightAuto = 0;
|
|
2104
|
-
const parentWidth = staticLeft + staticWidth + staticRight;
|
|
2105
|
-
const parentHeight = staticTop + staticHeight + staticBottom;
|
|
2106
|
-
if (constraintX === 'left') {
|
|
2107
|
-
left = staticLeft + 'px';
|
|
2108
|
-
right = '';
|
|
2109
|
-
}
|
|
2110
|
-
else if (constraintX === 'right') {
|
|
2111
|
-
left = '';
|
|
2112
|
-
right = staticRight + 'px';
|
|
2113
|
-
}
|
|
2114
|
-
else if (constraintX === 'center') {
|
|
2115
|
-
const offset = staticLeft + staticWidth / 2 - parentWidth / 2;
|
|
2116
|
-
left = `calc(50% ${offset > 0 ? '+' : '-'} ${Math.abs(offset)}px)`;
|
|
2117
|
-
right = '';
|
|
2118
|
-
transform = 'translateX(-50%)';
|
|
2119
|
-
}
|
|
2120
|
-
else if (constraintX === 'scale') {
|
|
2121
|
-
left = (staticLeft * 100) / parentWidth + '%';
|
|
2122
|
-
right = '';
|
|
2123
|
-
width = (staticWidth * 100) / parentWidth + '%';
|
|
2124
|
-
constraintWidthAuto = 1;
|
|
2125
|
-
}
|
|
2126
|
-
else if (constraintX === 'left-right') {
|
|
2127
|
-
left = staticLeft + 'px';
|
|
2128
|
-
right = staticRight + 'px';
|
|
2129
|
-
width = 'auto';
|
|
2130
|
-
constraintWidthAuto = 1;
|
|
2131
|
-
}
|
|
2132
|
-
if (constraintY === 'top') {
|
|
2133
|
-
top = staticTop + 'px';
|
|
2134
|
-
bottom = '';
|
|
2135
|
-
}
|
|
2136
|
-
else if (constraintY === 'bottom') {
|
|
2137
|
-
top = '';
|
|
2138
|
-
bottom = staticBottom + 'px';
|
|
2139
|
-
}
|
|
2140
|
-
else if (constraintY === 'center') {
|
|
2141
|
-
const offset = staticTop + staticHeight / 2 - parentHeight / 2;
|
|
2142
|
-
top = `calc(50% ${offset > 0 ? '+' : '-'} ${Math.abs(offset)}px)`;
|
|
2143
|
-
bottom = '';
|
|
2144
|
-
transform = transform ? 'translate(-50%, -50%)' : 'translateY(-50%)';
|
|
2145
|
-
}
|
|
2146
|
-
else if (constraintY === 'scale') {
|
|
2147
|
-
top = (staticTop * 100) / parentHeight + '%';
|
|
2148
|
-
bottom = '';
|
|
2149
|
-
height = (staticHeight * 100) / parentHeight + '%';
|
|
2150
|
-
constraintHeightAuto = 1;
|
|
2151
|
-
}
|
|
2152
|
-
else if (constraintY === 'top-bottom') {
|
|
2153
|
-
top = staticTop + 'px';
|
|
2154
|
-
bottom = staticBottom + 'px';
|
|
2155
|
-
height = 'auto';
|
|
2156
|
-
constraintHeightAuto = 1;
|
|
2157
|
-
}
|
|
2158
|
-
const newStyleObj = {
|
|
2159
|
-
...styleObj,
|
|
2160
|
-
left,
|
|
2161
|
-
right,
|
|
2162
|
-
top,
|
|
2163
|
-
bottom,
|
|
2164
|
-
transform,
|
|
2165
|
-
width,
|
|
2166
|
-
height,
|
|
2167
|
-
'--constraint-width-auto': constraintWidthAuto,
|
|
2168
|
-
'--constraint-height-auto': constraintHeightAuto,
|
|
2169
|
-
};
|
|
2170
|
-
if (!ops.doNotRecordLastWidthHeight) {
|
|
2171
|
-
if (rawWidth !== 'auto') {
|
|
2172
|
-
newStyleObj['--last-width'] = rawWidth;
|
|
2173
|
-
}
|
|
2174
|
-
if (rawHeight !== 'auto') {
|
|
2175
|
-
newStyleObj['--last-height'] = rawHeight;
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
ops.beforeSetStyleCb?.(newStyleObj);
|
|
2179
|
-
const newStaticStyle = this.stringifyStyleAttr(newStyleObj);
|
|
2180
|
-
this.setStaticStyle(newStaticStyle);
|
|
2181
|
-
}
|
|
2182
|
-
updateStyleObj(styleObj) {
|
|
2183
|
-
this.setStaticStyle(this.stringifyStyleAttr({
|
|
2184
|
-
...this.parseStyleToObject(this.staticStyle),
|
|
2185
|
-
...styleObj,
|
|
2186
|
-
}));
|
|
2187
|
-
}
|
|
2188
|
-
parseStyleToObject(styleStr = '') {
|
|
2189
|
-
const [styleStr1, styleStr2] = styleStr.split('--custom-start: auto;');
|
|
2190
|
-
const styleObj = styleStr1.split(/;/gim).reduce((obj, item) => {
|
|
2191
|
-
// background-image:url(http://www...)
|
|
2192
|
-
item = item.trim();
|
|
2193
|
-
const pos = item.indexOf(':');
|
|
2194
|
-
if (pos >= 0) {
|
|
2195
|
-
const key = item.slice(0, pos).trim();
|
|
2196
|
-
const value = item.slice(pos + 1).trim();
|
|
2197
|
-
obj[key] = value;
|
|
2198
|
-
}
|
|
2199
|
-
return obj;
|
|
2200
|
-
}, {});
|
|
2201
|
-
styleObj['customStyle'] = styleStr2;
|
|
2202
|
-
return styleObj;
|
|
2203
|
-
}
|
|
2204
|
-
stringifyStyleAttr(styleObj) {
|
|
2205
|
-
const customStyle = styleObj['customStyle'] || '';
|
|
2206
|
-
delete styleObj['customStyle'];
|
|
2207
|
-
const styleStr = Object.keys(styleObj)
|
|
2208
|
-
// 空字符串是允许的,因为有时候想要覆盖之前的样式。undefined 则不允许
|
|
2209
|
-
.filter((key) => styleObj[key] !== undefined)
|
|
2210
|
-
.map((key) => `${key}:${String(styleObj[key]).trim()};`)
|
|
2211
|
-
.join('');
|
|
2212
|
-
return styleStr + '--custom-start: auto;' + customStyle;
|
|
2213
|
-
}
|
|
2214
|
-
// 批量更新绑定属性
|
|
2215
|
-
batchUpdateBindAttrs(attrOptions) {
|
|
2216
|
-
const oldBindAttrs = this.bindAttrs.filter((it) => !attrOptions.some((item) => item.name === it.name));
|
|
2217
|
-
const newBindAttrs = attrOptions.map((it) => BindAttribute__1.default.from(it, this, 'bindAttrs'));
|
|
2218
|
-
this.update({
|
|
2219
|
-
bindAttrs: [...oldBindAttrs, ...newBindAttrs],
|
|
2220
|
-
});
|
|
2221
|
-
}
|
|
2222
|
-
};
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
], ViewElement.prototype, "
|
|
2232
|
-
__decorate([
|
|
2233
|
-
(0, decorators_1.property)()
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
], ViewElement.prototype, "
|
|
2244
|
-
__decorate([
|
|
2245
|
-
(0, decorators_1.property)()
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
], ViewElement.prototype, "
|
|
2294
|
-
__decorate([
|
|
2295
|
-
(0,
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
(0,
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
decorators_1.className,
|
|
2312
|
-
(0, decorators_1.concept)('页面元素')
|
|
2313
|
-
// @ts-ignore
|
|
2314
|
-
], ViewElement);
|
|
2315
|
-
exports.default = ViewElement;
|
|
2316
|
-
//================================================================================
|
|
2317
|
-
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
2318
|
-
// 自动生成的代码已结束。下面可以手动编写。
|
|
2319
|
-
//================================================================================
|
|
1033
|
+
}\n`;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1037
|
+
code += `};\n`;
|
|
1038
|
+
}
|
|
1039
|
+
if (Array.isArray(this.children)) {
|
|
1040
|
+
this.children.forEach((element) => {
|
|
1041
|
+
code += element.toEmbeddedTSVariableDefinition((0, translator_1.shiftState)(state, code), variableList, currentLevel);
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
return code;
|
|
1045
|
+
}
|
|
1046
|
+
toEmbeddedTSVariableFunctionDefinition(state, parentLevel) {
|
|
1047
|
+
let code = '';
|
|
1048
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1049
|
+
let levelIndex = parentLevel || 0;
|
|
1050
|
+
code += `${this.name}: () => {\n`;
|
|
1051
|
+
if (this.tag === 'template' && this.haveScope() && this.parentNode instanceof ViewElement_1) {
|
|
1052
|
+
const currentType = this.parentNode.tag === 'u-table-view-column-dynamic' ? 'CurrentDynamic' : 'Current';
|
|
1053
|
+
const _this = this.parentNode;
|
|
1054
|
+
let genericity = '';
|
|
1055
|
+
if (_this.tag === 'u-table-view-column-dynamic') {
|
|
1056
|
+
genericity += `<${_this.parentNode.__tsVariableDataSourceTypeName}, ${_this.__tsVariableDataSourceTypeName}>`;
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
let targetNode = _this;
|
|
1060
|
+
while (!targetNode.__tsVariableDataSourceTypeName && targetNode?.parentNode instanceof ViewElement_1) {
|
|
1061
|
+
targetNode = targetNode.parentNode;
|
|
1062
|
+
}
|
|
1063
|
+
genericity += `<${targetNode.__tsVariableDataSourceTypeName ?? 'any'}>`;
|
|
1064
|
+
}
|
|
1065
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1066
|
+
code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}${genericity}\n`;
|
|
1067
|
+
levelIndex++;
|
|
1068
|
+
}
|
|
1069
|
+
const attr = this.bindAttrs?.find((item) => item.name === 'data-source');
|
|
1070
|
+
if (attr && attr.expression) {
|
|
1071
|
+
const datasourceName = `datasourceName${this.name}`;
|
|
1072
|
+
this.__tsVariableDataSourceTypeName = datasourceName;
|
|
1073
|
+
if (attr.expression instanceof MemberExpression__1.default ||
|
|
1074
|
+
attr.expression instanceof Identifier__1.default ||
|
|
1075
|
+
attr.expression instanceof concepts_1.CallLogic) {
|
|
1076
|
+
const extraParams = {
|
|
1077
|
+
tabSize: 4,
|
|
1078
|
+
inline: true,
|
|
1079
|
+
noNeedParams: true,
|
|
1080
|
+
};
|
|
1081
|
+
let value = attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}));
|
|
1082
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1083
|
+
code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<typeof ${value}>;\n`;
|
|
1084
|
+
// code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<typeof ${value}>>;\n`;
|
|
1085
|
+
}
|
|
1086
|
+
else {
|
|
1087
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1088
|
+
code += `const __funcName = () => { return `;
|
|
1089
|
+
code += attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code));
|
|
1090
|
+
code += '};\n';
|
|
1091
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1092
|
+
code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>;\n`;
|
|
1093
|
+
// code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>>;\n`;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1097
|
+
code += `return {\n`;
|
|
1098
|
+
if (Array.isArray(this.bindAttrs)) {
|
|
1099
|
+
this.bindAttrs
|
|
1100
|
+
.filter((attr) => View__1.PAGE_COMPONENT_INCLUDE_TAG_MAP[this.tag]?.[attr.name])
|
|
1101
|
+
.forEach((attr) => {
|
|
1102
|
+
code += attr.toEmbeddedTSVariableFunctionDefinition((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
if (Array.isArray(this.children)) {
|
|
1106
|
+
this.children.forEach((element) => {
|
|
1107
|
+
code += element.toEmbeddedTSVariableFunctionDefinition((0, translator_1.shiftState)({ ...state, tabSize: state.tabSize + 2 }, code), levelIndex);
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1111
|
+
code += `}\n`;
|
|
1112
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1113
|
+
code += `},\n`;
|
|
1114
|
+
return code;
|
|
1115
|
+
}
|
|
1116
|
+
getTypeArgmentsStr(state, currentNode) {
|
|
1117
|
+
// 登录组件不翻译
|
|
1118
|
+
if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
|
|
1119
|
+
return '<any>';
|
|
1120
|
+
let code = '';
|
|
1121
|
+
// formItem的单独处理
|
|
1122
|
+
if (this.tag === 'u-form-item') {
|
|
1123
|
+
if (Array.isArray(this.children) && this.children.length) {
|
|
1124
|
+
const tag = this.children[0].tag;
|
|
1125
|
+
if (tag === 'u-input') {
|
|
1126
|
+
code += '<nasl.core.String>';
|
|
1127
|
+
}
|
|
1128
|
+
else if (tag === 'u-input-number') {
|
|
1129
|
+
code += '<nasl.core.Long>';
|
|
1130
|
+
}
|
|
1131
|
+
else {
|
|
1132
|
+
code += '<any>';
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return code;
|
|
1136
|
+
}
|
|
1137
|
+
if (this.tag === 'u-table-view-column-group') {
|
|
1138
|
+
code += `<${this.parentNode.__tsDataSourceTypeName}>`;
|
|
1139
|
+
return code;
|
|
1140
|
+
}
|
|
1141
|
+
const bindAttrs = this.bindAttrs;
|
|
1142
|
+
if (bindAttrs && bindAttrs.length) {
|
|
1143
|
+
const attr = bindAttrs.find((item) => item.name === 'data-source');
|
|
1144
|
+
if (attr && attr.expression) {
|
|
1145
|
+
if (this.tag === 'u-table-view-column-dynamic') {
|
|
1146
|
+
code += `<${this.parentNode.__tsDataSourceTypeName}, ${this.__tsDataSourceTypeName}>`;
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
code += `<${this.__tsDataSourceTypeName}>`;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
return code;
|
|
1154
|
+
}
|
|
1155
|
+
getDatasourceTypeCodeStr(state, eleArr) {
|
|
1156
|
+
let code = '';
|
|
1157
|
+
(eleArr || []).forEach((element, index) => {
|
|
1158
|
+
const bindAttrs = element.bindAttrs;
|
|
1159
|
+
if (bindAttrs && bindAttrs.length) {
|
|
1160
|
+
const attr = bindAttrs.find((item) => item.name === 'data-source');
|
|
1161
|
+
if (attr && attr.expression) {
|
|
1162
|
+
const datasourceName = `datasourceName${element.name}`;
|
|
1163
|
+
element.__tsDataSourceTypeName = datasourceName;
|
|
1164
|
+
if (attr.expression instanceof MemberExpression__1.default ||
|
|
1165
|
+
attr.expression instanceof Identifier__1.default ||
|
|
1166
|
+
attr.expression instanceof concepts_1.CallLogic) {
|
|
1167
|
+
const extraParams = {
|
|
1168
|
+
tabSize: 4,
|
|
1169
|
+
inline: true,
|
|
1170
|
+
noNeedParams: true,
|
|
1171
|
+
};
|
|
1172
|
+
let value = attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}));
|
|
1173
|
+
code += `type ${datasourceName} = `;
|
|
1174
|
+
code += `nasl.ui.GetItemTypeFromDataSource<typeof ${value}>;\n`;
|
|
1175
|
+
}
|
|
1176
|
+
else {
|
|
1177
|
+
code += `const __funcName${index} = () => { return`;
|
|
1178
|
+
code += attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code));
|
|
1179
|
+
code += '};\n';
|
|
1180
|
+
code += `type ${datasourceName} = `;
|
|
1181
|
+
code += `nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName${index}>>;\n`;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
code += '\n';
|
|
1187
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1188
|
+
return code;
|
|
1189
|
+
}
|
|
1190
|
+
toEmbeddedTS(state, parentLevel) {
|
|
1191
|
+
const { parentNode, app, tag, staticClass, name, bindDirectives, bindRoles, bindEvents, children } = this;
|
|
1192
|
+
const chineseTsName = (name) => {
|
|
1193
|
+
let tsName = name;
|
|
1194
|
+
// 匹配所有特殊字符都转为_
|
|
1195
|
+
tsName = tsName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '_');
|
|
1196
|
+
if (/^\d/.test(tsName)) {
|
|
1197
|
+
tsName = '$' + tsName;
|
|
1198
|
+
}
|
|
1199
|
+
return tsName;
|
|
1200
|
+
};
|
|
1201
|
+
// 过滤模板的登录中的一些翻译,这里只过滤h5表格中的两个列
|
|
1202
|
+
if ((parentNode.concept === 'ViewElement' &&
|
|
1203
|
+
parentNode.tag &&
|
|
1204
|
+
this.toHump(parentNode.tag) === 'lcapLogin') ||
|
|
1205
|
+
staticClass === 'login-cell') {
|
|
1206
|
+
return '';
|
|
1207
|
+
}
|
|
1208
|
+
// pc事件翻译
|
|
1209
|
+
if (this.toHump(tag) === 'lcapLogin') {
|
|
1210
|
+
let code = `new nasl.ui.div({name: __elements.${this.name},\n`;
|
|
1211
|
+
// 事件
|
|
1212
|
+
if (Array.isArray(this.bindEvents)) {
|
|
1213
|
+
this.bindEvents.forEach((event) => {
|
|
1214
|
+
code += event.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1215
|
+
tabSize: (state?.tabSize || 0) + 2,
|
|
1216
|
+
}));
|
|
1217
|
+
code += '\n';
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
code += `}),\n`;
|
|
1221
|
+
return code;
|
|
1222
|
+
}
|
|
1223
|
+
let levelIndex = parentLevel || 0;
|
|
1224
|
+
if (tag === 'template' && this.haveScope()) {
|
|
1225
|
+
const slotTarget = !this.slotTarget ? 'slotDefault' : 'slot' + this.toFirstUpper(this.toHump(this.slotTarget));
|
|
1226
|
+
let code = '';
|
|
1227
|
+
code += `${slotTarget}: (current${levelIndex === 0 ? '' : levelIndex})=> {\n`;
|
|
1228
|
+
code += this.getDatasourceTypeCodeStr(state, this.children);
|
|
1229
|
+
levelIndex++;
|
|
1230
|
+
code += 'return [';
|
|
1231
|
+
this.children.forEach((element) => {
|
|
1232
|
+
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1233
|
+
tabSize: state?.tabSize || 0,
|
|
1234
|
+
}), levelIndex);
|
|
1235
|
+
});
|
|
1236
|
+
code += ']';
|
|
1237
|
+
code += '\n';
|
|
1238
|
+
code += '},\n';
|
|
1239
|
+
return code;
|
|
1240
|
+
}
|
|
1241
|
+
else if (tag === 'template') {
|
|
1242
|
+
const slotTarget = !this.slotTarget ? 'slotDefault' : 'slot' + this.toFirstUpper(this.toHump(this.slotTarget));
|
|
1243
|
+
let code = '';
|
|
1244
|
+
code += `${slotTarget}: ()=> {\n`;
|
|
1245
|
+
code += this.getDatasourceTypeCodeStr(state, this.children);
|
|
1246
|
+
code += 'return [';
|
|
1247
|
+
this.children.forEach((element) => {
|
|
1248
|
+
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1249
|
+
tabSize: state?.tabSize || 0,
|
|
1250
|
+
}), levelIndex);
|
|
1251
|
+
});
|
|
1252
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1253
|
+
code += ']';
|
|
1254
|
+
code += '\n';
|
|
1255
|
+
code += '},\n';
|
|
1256
|
+
return code;
|
|
1257
|
+
}
|
|
1258
|
+
// 后面那个name是为了查找引用的时候用的
|
|
1259
|
+
let code = `new nasl.ui.${this.toHump(tag)}${this.getTypeArgmentsStr(state)}({name: __elements.${name},\n`;
|
|
1260
|
+
// 是否开启权限
|
|
1261
|
+
// const hasAuth = Array.isArray(bindDirectives)
|
|
1262
|
+
// ? !!bindDirectives.filter((directive) => directive.name === 'auth').length
|
|
1263
|
+
// : false;
|
|
1264
|
+
// 角色
|
|
1265
|
+
if (Array.isArray(bindRoles) && bindRoles.length) {
|
|
1266
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1267
|
+
code += 'roles: [\n';
|
|
1268
|
+
bindRoles.forEach((role) => {
|
|
1269
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
|
|
1270
|
+
code += `${app.getNamespace()}.roles.${chineseTsName(role)}.${chineseTsName(role)},`;
|
|
1271
|
+
code += '\n';
|
|
1272
|
+
});
|
|
1273
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1274
|
+
code += '],\n';
|
|
1275
|
+
}
|
|
1276
|
+
// 事件
|
|
1277
|
+
if (Array.isArray(bindEvents)) {
|
|
1278
|
+
bindEvents.forEach((event) => {
|
|
1279
|
+
code += event.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1280
|
+
tabSize: (state?.tabSize || 0) + 2,
|
|
1281
|
+
}));
|
|
1282
|
+
code += '\n';
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
// 子元素
|
|
1286
|
+
if (Array.isArray(children)) {
|
|
1287
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1288
|
+
if (Array.isArray(this.bindAttrs)) {
|
|
1289
|
+
code += `bindAttr: () => [\n`;
|
|
1290
|
+
this.bindAttrs.forEach((attr) => (code += attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 })) + ',\n'));
|
|
1291
|
+
this.bindDirectives.forEach((directive) => (code += directive.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 })) + ',\n'));
|
|
1292
|
+
this.bindStyles.forEach((bindStyle) => (code += bindStyle.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 })) + ',\n'));
|
|
1293
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2) + '],\n';
|
|
1294
|
+
}
|
|
1295
|
+
// 如果子集中有插槽的就
|
|
1296
|
+
if (children.find((item) => item.tag === 'template' && item.slotTarget)) {
|
|
1297
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1298
|
+
const defaultArr = [];
|
|
1299
|
+
// 先把插槽翻译了
|
|
1300
|
+
children.forEach((element) => {
|
|
1301
|
+
if (element.tag === 'template') {
|
|
1302
|
+
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1303
|
+
tabSize: state?.tabSize || 0,
|
|
1304
|
+
}), levelIndex);
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1307
|
+
defaultArr.push(element);
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
// 翻译其余的子集
|
|
1311
|
+
if (defaultArr.length) {
|
|
1312
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1313
|
+
code += `slotDefault: ()=> {\n`;
|
|
1314
|
+
code += this.getDatasourceTypeCodeStr(state, defaultArr);
|
|
1315
|
+
code += 'return [';
|
|
1316
|
+
defaultArr.forEach((element) => {
|
|
1317
|
+
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1318
|
+
tabSize: (state?.tabSize || 0) + 2,
|
|
1319
|
+
}), levelIndex);
|
|
1320
|
+
code += '\n';
|
|
1321
|
+
});
|
|
1322
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1323
|
+
code += ']\n';
|
|
1324
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1325
|
+
code += '}\n';
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
else {
|
|
1329
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1330
|
+
code += `slotDefault: ()=> {\n`;
|
|
1331
|
+
code += this.getDatasourceTypeCodeStr(state, children);
|
|
1332
|
+
code += 'return [';
|
|
1333
|
+
children.forEach((element) => {
|
|
1334
|
+
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1335
|
+
tabSize: (state?.tabSize || 0) + 2,
|
|
1336
|
+
}), levelIndex);
|
|
1337
|
+
code += '\n';
|
|
1338
|
+
});
|
|
1339
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1340
|
+
code += ']\n';
|
|
1341
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1342
|
+
code += '}\n';
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
code += (0, translator_1.indent)(state?.tabSize || 0) + '})';
|
|
1346
|
+
// 顶层元素是单独的表达式
|
|
1347
|
+
if (parentNode.concept === 'View') {
|
|
1348
|
+
code += ';\n';
|
|
1349
|
+
}
|
|
1350
|
+
else {
|
|
1351
|
+
code += ',\n';
|
|
1352
|
+
}
|
|
1353
|
+
return code;
|
|
1354
|
+
}
|
|
1355
|
+
toNaturalTS(state = (0, translator_1.createCompilerState)(), parentLevel) {
|
|
1356
|
+
let code = '';
|
|
1357
|
+
const levelIndex = parentLevel || 0;
|
|
1358
|
+
if (Array.isArray(this.bindEvents)) {
|
|
1359
|
+
this.bindEvents.forEach((event) => {
|
|
1360
|
+
code += event.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1361
|
+
tabSize: state.tabSize,
|
|
1362
|
+
}));
|
|
1363
|
+
// code += '\n';
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
if (Array.isArray(this.children)) {
|
|
1367
|
+
if (this.children.find((item) => item.tag === 'template' && item.slotTarget)) {
|
|
1368
|
+
// code += indent(state.tabSize + 2);
|
|
1369
|
+
const defaultArr = [];
|
|
1370
|
+
// 先把插槽翻译了
|
|
1371
|
+
this.children.forEach((element) => {
|
|
1372
|
+
if (element.tag === 'template') {
|
|
1373
|
+
code += element.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1374
|
+
tabSize: state.tabSize,
|
|
1375
|
+
}), levelIndex);
|
|
1376
|
+
}
|
|
1377
|
+
else {
|
|
1378
|
+
defaultArr.push(element);
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
// 翻译其余的子集
|
|
1382
|
+
if (defaultArr.length) {
|
|
1383
|
+
defaultArr.forEach((element) => {
|
|
1384
|
+
code += element.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1385
|
+
tabSize: state.tabSize,
|
|
1386
|
+
}), levelIndex);
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
this.children.forEach((element) => {
|
|
1392
|
+
code += element.toNaturalTS((0, translator_1.shiftState)(state, code, {
|
|
1393
|
+
tabSize: state.tabSize,
|
|
1394
|
+
}), levelIndex);
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
return code;
|
|
1399
|
+
}
|
|
1400
|
+
toNaturalTSDefinition(state) {
|
|
1401
|
+
let code = '';
|
|
1402
|
+
if (['u-button', 'u-form', 'u-modal', 'u-table-view', 'u-select', 'u-input', 'u-number-input'].includes(this.tag)) {
|
|
1403
|
+
code += (0, translator_1.indent)(state.tabSize + 1);
|
|
1404
|
+
// 登录组件不翻译
|
|
1405
|
+
// if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form') {
|
|
1406
|
+
// code += `${this.name}: nasl.ui.div;\n`;
|
|
1407
|
+
// } else {
|
|
1408
|
+
code += `${this.name}: nasl.ui.${(0, utils_1.kebab2Camel)(this.tag.replace(/^\w-/, ''))},\n`;
|
|
1409
|
+
// }
|
|
1410
|
+
}
|
|
1411
|
+
if (Array.isArray(this.children)) {
|
|
1412
|
+
this.children.forEach((element) => {
|
|
1413
|
+
code += element.toNaturalTSDefinition((0, translator_1.shiftState)(state, code));
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
return code;
|
|
1417
|
+
}
|
|
1418
|
+
_duplicate() {
|
|
1419
|
+
const element = ViewElement_1.from(this.toTemplateJSON());
|
|
1420
|
+
const nameMap = element.deepRenameElements(this);
|
|
1421
|
+
utils.traverse((current) => {
|
|
1422
|
+
const node = current.node;
|
|
1423
|
+
if (node.concept === 'CallLogic') {
|
|
1424
|
+
node.uuid = (0, uuid_1.v4)().replace(/-/g, '');
|
|
1425
|
+
if (/elements.(.+).logics/.test(node.calleeNamespace)) {
|
|
1426
|
+
const oldName = node.calleeNamespace.split('.')[1];
|
|
1427
|
+
if (nameMap.has(oldName)) {
|
|
1428
|
+
const newName = nameMap.get(oldName);
|
|
1429
|
+
node.calleeNamespace = `elements.${newName}.logics`;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
// 如果创建副本,内部的国际化标识都要去掉
|
|
1434
|
+
if (node.i18nKey) {
|
|
1435
|
+
delete node.i18nKey;
|
|
1436
|
+
}
|
|
1437
|
+
}, { node: element }, { mode: 'anyObject', excludedKeySet: element.JSON_EXCLUDED_KEYS });
|
|
1438
|
+
this.view.existingViewElement.clear();
|
|
1439
|
+
return element;
|
|
1440
|
+
}
|
|
1441
|
+
// 递归遍历组件
|
|
1442
|
+
traverseChildren(cb) {
|
|
1443
|
+
utils.traverse((current) => {
|
|
1444
|
+
cb(current.node);
|
|
1445
|
+
}, { node: this });
|
|
1446
|
+
}
|
|
1447
|
+
// 递归生成组件名
|
|
1448
|
+
deepRenameElements(node) {
|
|
1449
|
+
const map = new Map();
|
|
1450
|
+
this.traverseChildren((ele) => {
|
|
1451
|
+
const oldName = ele.name;
|
|
1452
|
+
const tagName = ele.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1453
|
+
ele.name = node.getViewElementUniqueName(`${tagName}1`);
|
|
1454
|
+
map.set(oldName, ele.name);
|
|
1455
|
+
});
|
|
1456
|
+
return map;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* 解析属性中的表达式
|
|
1460
|
+
* @param value
|
|
1461
|
+
* @param $def 目前 $def 只用来查找 $def.variables 和 $def.structures
|
|
1462
|
+
* @param dataSchema
|
|
1463
|
+
*/
|
|
1464
|
+
static _parseExpression(value) {
|
|
1465
|
+
try {
|
|
1466
|
+
const ast = babelParser.parseExpression(value);
|
|
1467
|
+
const node = transAstNodeToNaslNode(ast);
|
|
1468
|
+
return LogicItem__1.LogicItem.from(node, null, null);
|
|
1469
|
+
}
|
|
1470
|
+
catch (e) {
|
|
1471
|
+
return null;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
static _parseValidationRule(value) {
|
|
1475
|
+
let calleeName = value;
|
|
1476
|
+
let args = [];
|
|
1477
|
+
try {
|
|
1478
|
+
const ast = babelParser.parseExpression(value);
|
|
1479
|
+
const validationNamespace = concepts_1.stdlibNamespace.findChild('validation');
|
|
1480
|
+
if (ast.type === 'CallExpression') {
|
|
1481
|
+
calleeName = (ast.callee?.property?.name ?? ast.callee?.property?.value ?? ast.callee?.name).replace(/\(.*/, '');
|
|
1482
|
+
const func = validationNamespace.functions.find((item) => item.name === calleeName);
|
|
1483
|
+
args = ast.arguments.map((argument, index) => ({
|
|
1484
|
+
concept: 'Argument',
|
|
1485
|
+
name: '',
|
|
1486
|
+
kind: 'Statement',
|
|
1487
|
+
keyword: func?.params?.[index]?.name ?? '',
|
|
1488
|
+
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
1489
|
+
}));
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
catch (error) { }
|
|
1493
|
+
return {
|
|
1494
|
+
concept: 'ValidationRule',
|
|
1495
|
+
name: '',
|
|
1496
|
+
label: '验证规则',
|
|
1497
|
+
kind: 'Expression',
|
|
1498
|
+
calleeNamespace: 'nasl.validation',
|
|
1499
|
+
arguments: args,
|
|
1500
|
+
calleeName,
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* 从 Vue 的 ASTNode 转换成 ASL 元素
|
|
1505
|
+
* @param astNode Vue 的 ASTNode
|
|
1506
|
+
*/
|
|
1507
|
+
static _fromASTNode(astNode, context) {
|
|
1508
|
+
const view = context?.view;
|
|
1509
|
+
// 临时处理组件的 text
|
|
1510
|
+
//h5-mock
|
|
1511
|
+
if ([
|
|
1512
|
+
'u-text',
|
|
1513
|
+
'van-text',
|
|
1514
|
+
'u-link',
|
|
1515
|
+
'u-button',
|
|
1516
|
+
'u-label',
|
|
1517
|
+
'u-radio',
|
|
1518
|
+
'u-checkbox',
|
|
1519
|
+
'u-navbar-item',
|
|
1520
|
+
'u-sidebar-item',
|
|
1521
|
+
'u-menu-item',
|
|
1522
|
+
].includes(astNode.tag) &&
|
|
1523
|
+
astNode.children.length === 1 &&
|
|
1524
|
+
astNode.children[0].type === 3) {
|
|
1525
|
+
astNode.attrs = astNode.attrs || [];
|
|
1526
|
+
astNode.attrs.push({
|
|
1527
|
+
name: 'text',
|
|
1528
|
+
value: JSON.stringify(astNode.children[0].text),
|
|
1529
|
+
});
|
|
1530
|
+
astNode.children = [];
|
|
1531
|
+
}
|
|
1532
|
+
// 将 scopedSlots 合并到 children 中
|
|
1533
|
+
if (astNode.scopedSlots) {
|
|
1534
|
+
astNode.children = astNode.children || [];
|
|
1535
|
+
Object.keys(astNode.scopedSlots).forEach((key) => {
|
|
1536
|
+
if (!astNode.children.find((child) => key === child.slotTarget)) {
|
|
1537
|
+
astNode.children.unshift(astNode.scopedSlots[key]);
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
delete astNode.scopedSlots;
|
|
1541
|
+
}
|
|
1542
|
+
// 提示不支持的属性
|
|
1543
|
+
[
|
|
1544
|
+
'component',
|
|
1545
|
+
'inlineTemplate',
|
|
1546
|
+
'pre',
|
|
1547
|
+
'ns',
|
|
1548
|
+
'transition',
|
|
1549
|
+
'transitionOnAppear',
|
|
1550
|
+
'transitionMode',
|
|
1551
|
+
'slotName',
|
|
1552
|
+
'classBinding',
|
|
1553
|
+
'styleBinding',
|
|
1554
|
+
].forEach((key) => {
|
|
1555
|
+
if (astNode[key])
|
|
1556
|
+
console.warn(`[warn] ViewElement NASL unsupports '${key}' field in node `, astNode);
|
|
1557
|
+
});
|
|
1558
|
+
let element;
|
|
1559
|
+
if (astNode.type === 1) {
|
|
1560
|
+
if (astNode.tag === 'router-view') {
|
|
1561
|
+
if (view.frontend.type === 'h5') {
|
|
1562
|
+
astNode.tag = 'van-router-view';
|
|
1563
|
+
}
|
|
1564
|
+
else {
|
|
1565
|
+
astNode.tag = 'u-router-view';
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
const tagName = astNode.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1569
|
+
let newContext = {};
|
|
1570
|
+
if (context) {
|
|
1571
|
+
newContext = {
|
|
1572
|
+
...context,
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
element = new ViewElement_1({
|
|
1576
|
+
tag: astNode.tag,
|
|
1577
|
+
name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
|
|
1578
|
+
staticClass: astNode.attrsMap.class,
|
|
1579
|
+
staticStyle: astNode.attrsMap.style,
|
|
1580
|
+
slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
|
|
1581
|
+
slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
|
|
1582
|
+
children: astNode.children.map((item) => this._fromASTNode(item, newContext)),
|
|
1583
|
+
});
|
|
1584
|
+
astNode?.attrs?.forEach((oldAttr) => {
|
|
1585
|
+
let attr;
|
|
1586
|
+
// 获取原始属性
|
|
1587
|
+
const orginAttrCode = (context?.code || '').substr(oldAttr.start, oldAttr.end - oldAttr.start);
|
|
1588
|
+
if (oldAttr.value === '""' && orginAttrCode.trim() === oldAttr.name) {
|
|
1589
|
+
attr = new BindAttribute__1.default({
|
|
1590
|
+
type: 'static',
|
|
1591
|
+
name: oldAttr.name,
|
|
1592
|
+
value: 'true',
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
else {
|
|
1596
|
+
try {
|
|
1597
|
+
const tmp = json5.parse(oldAttr.value);
|
|
1598
|
+
const source = {
|
|
1599
|
+
type: typeof tmp === 'string' ? 'string' : 'static',
|
|
1600
|
+
name: oldAttr.name,
|
|
1601
|
+
value: typeof tmp === 'string' ? tmp : oldAttr.value,
|
|
1602
|
+
};
|
|
1603
|
+
if (oldAttr.name === 'rules') {
|
|
1604
|
+
source.rules = tmp?.split('|').map((ruleStr) => this._parseValidationRule(ruleStr.trim()));
|
|
1605
|
+
}
|
|
1606
|
+
else if (['page-number', 'page-size'].includes(oldAttr.name)) {
|
|
1607
|
+
source.value = Number(source.value);
|
|
1608
|
+
}
|
|
1609
|
+
attr = new BindAttribute__1.default(source);
|
|
1610
|
+
}
|
|
1611
|
+
catch (e) {
|
|
1612
|
+
const expression = this._parseExpression(oldAttr.value);
|
|
1613
|
+
attr = new BindAttribute__1.default({
|
|
1614
|
+
type: 'dynamic',
|
|
1615
|
+
name: oldAttr.name,
|
|
1616
|
+
value: expression ? '' : oldAttr.value,
|
|
1617
|
+
expression,
|
|
1618
|
+
});
|
|
1619
|
+
if (astNode.attrsMap[`:${attr.name}.sync`]) {
|
|
1620
|
+
attr.sync = true;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
element.addBindAttribute(attr);
|
|
1625
|
+
});
|
|
1626
|
+
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
1627
|
+
astNode.events &&
|
|
1628
|
+
Object.keys(astNode.events)
|
|
1629
|
+
.filter((name) => !name.startsWith('update:'))
|
|
1630
|
+
.forEach((name) => {
|
|
1631
|
+
const oldEvent = astNode.events[name];
|
|
1632
|
+
const str = oldEvent.value;
|
|
1633
|
+
const calleeName = str.split('(')[0];
|
|
1634
|
+
const matchArr = str.match(/\(([^)]*)\)/) || [];
|
|
1635
|
+
let argsStr = '';
|
|
1636
|
+
if (matchArr?.length >= 2) {
|
|
1637
|
+
argsStr = matchArr[1];
|
|
1638
|
+
}
|
|
1639
|
+
let args = [];
|
|
1640
|
+
const argStrs = argsStr.split(',');
|
|
1641
|
+
args = argStrs
|
|
1642
|
+
.filter((argStr) => !!argStr)
|
|
1643
|
+
.map((argStr) => {
|
|
1644
|
+
const keyword = argStr.trim().split('.');
|
|
1645
|
+
return {
|
|
1646
|
+
concept: 'Argument',
|
|
1647
|
+
expression: genArgumentMemberExpression(keyword),
|
|
1648
|
+
};
|
|
1649
|
+
});
|
|
1650
|
+
const viewLogics = context?.definition?.viewLogics || [];
|
|
1651
|
+
const currentLogic = viewLogics.find((item) => item.name === calleeName);
|
|
1652
|
+
if (currentLogic) {
|
|
1653
|
+
element.addBindEvent(new BindEvent__1.default({
|
|
1654
|
+
name,
|
|
1655
|
+
calleeNamespace: '',
|
|
1656
|
+
calleeName: '',
|
|
1657
|
+
arguments: args,
|
|
1658
|
+
logics: [currentLogic],
|
|
1659
|
+
}));
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
astNode.directives &&
|
|
1663
|
+
astNode.directives.forEach((directive) => {
|
|
1664
|
+
if (directive.name === 'model') {
|
|
1665
|
+
const valueAttr = astNode.attrs && astNode.attrs.find((attr) => attr.name === 'value');
|
|
1666
|
+
if (!valueAttr) {
|
|
1667
|
+
const expression = this._parseExpression(directive.value);
|
|
1668
|
+
element.addBindAttribute(new BindAttribute__1.default({
|
|
1669
|
+
type: 'dynamic',
|
|
1670
|
+
name: 'value',
|
|
1671
|
+
value: expression ? '' : directive.value,
|
|
1672
|
+
expression,
|
|
1673
|
+
sync: true,
|
|
1674
|
+
}));
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
else {
|
|
1678
|
+
const expression = this._parseExpression(directive.value);
|
|
1679
|
+
element.addBindDirective(new BindDirective__1.default({
|
|
1680
|
+
type: expression ? 'string' : 'dynamic',
|
|
1681
|
+
name: directive.name,
|
|
1682
|
+
rawName: directive.rawName,
|
|
1683
|
+
value: expression ? '' : directive.value,
|
|
1684
|
+
expression,
|
|
1685
|
+
arg: directive.arg,
|
|
1686
|
+
// modifiers: directive.modifiers,
|
|
1687
|
+
}));
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1690
|
+
if (astNode.if) {
|
|
1691
|
+
element.addBindDirective(new BindDirective__1.default({
|
|
1692
|
+
type: 'dynamic',
|
|
1693
|
+
name: 'if',
|
|
1694
|
+
rawName: 'v-if',
|
|
1695
|
+
value: '',
|
|
1696
|
+
expression: this._parseExpression(astNode.if),
|
|
1697
|
+
}));
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
else if (astNode.type === 2) {
|
|
1701
|
+
const tagName = config_1.config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1702
|
+
const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1703
|
+
element = new ViewElement_1({
|
|
1704
|
+
tag: tagName,
|
|
1705
|
+
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1706
|
+
});
|
|
1707
|
+
const value = astNode.text?.match(/{{(.*?)}}/)[1].trim();
|
|
1708
|
+
const expression = this._parseExpression(value);
|
|
1709
|
+
element.addBindAttribute(new BindAttribute__1.default({
|
|
1710
|
+
type: 'dynamic',
|
|
1711
|
+
name: 'text',
|
|
1712
|
+
value: expression ? '' : value,
|
|
1713
|
+
expression,
|
|
1714
|
+
}));
|
|
1715
|
+
}
|
|
1716
|
+
else if (astNode.type === 3) {
|
|
1717
|
+
const tagName = config_1.config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1718
|
+
const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1719
|
+
element = new ViewElement_1({
|
|
1720
|
+
tag: tagName,
|
|
1721
|
+
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1722
|
+
});
|
|
1723
|
+
element.addBindAttribute(new BindAttribute__1.default({
|
|
1724
|
+
name: 'text',
|
|
1725
|
+
type: 'string',
|
|
1726
|
+
value: astNode.text?.trim(),
|
|
1727
|
+
}));
|
|
1728
|
+
}
|
|
1729
|
+
return element;
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* 解析 Vue 模板
|
|
1733
|
+
* 该方法不会绑定 view 和 parent,如果是添加元素优先使用 fromHTML
|
|
1734
|
+
* @param html Vue 的模板
|
|
1735
|
+
* @TODO 处理多个元素的问题
|
|
1736
|
+
*/
|
|
1737
|
+
static parse(code, context) {
|
|
1738
|
+
code = code || '<div></div>';
|
|
1739
|
+
const compilerOptions = {
|
|
1740
|
+
preserveWhitespace: false,
|
|
1741
|
+
outputSourceRange: true,
|
|
1742
|
+
};
|
|
1743
|
+
let ast = compiler.compile(code, compilerOptions).ast;
|
|
1744
|
+
if (ast.tag === 'template' && !ast.slotTarget)
|
|
1745
|
+
ast = ast.children[0];
|
|
1746
|
+
return this._fromASTNode(ast, {
|
|
1747
|
+
...context,
|
|
1748
|
+
code,
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* 从模板生成规范的 ViewElement 对象
|
|
1753
|
+
*/
|
|
1754
|
+
static fromHTML(html, context) {
|
|
1755
|
+
return this.parse(html, context);
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* 转换成设计器中使用的 Vue 文件
|
|
1759
|
+
* @param options
|
|
1760
|
+
*/
|
|
1761
|
+
toDesignerVue() {
|
|
1762
|
+
return this.toVue({
|
|
1763
|
+
finalCode: false,
|
|
1764
|
+
nodePathAttr: true,
|
|
1765
|
+
attrFormat: (attr, element, defaultResult) => {
|
|
1766
|
+
if (attr.concept === 'BindAttribute' &&
|
|
1767
|
+
!['href', 'destination', 'externalDestination', 'download'].includes(attr.name)) {
|
|
1768
|
+
const api = config_1.config?.allNodesAPI?.[element.tag];
|
|
1769
|
+
const apiOfAttr = api && api.attrs && api.attrs.find((_attr) => _attr.name === attr.name);
|
|
1770
|
+
if (['u-form-item', 'u-validator', 'van-field'].includes(element.tag) && attr.name === 'rules') {
|
|
1771
|
+
return `${attr.name}=""`;
|
|
1772
|
+
}
|
|
1773
|
+
if (apiOfAttr && apiOfAttr['designer-value'] !== undefined) {
|
|
1774
|
+
let designerValue = apiOfAttr['designer-value'];
|
|
1775
|
+
//对流程模板拖拽进行特判
|
|
1776
|
+
element.bindAttrs.forEach((property) => {
|
|
1777
|
+
if (property.name === 'repeat' && property.value === '1')
|
|
1778
|
+
designerValue = '[{}, {}]';
|
|
1779
|
+
});
|
|
1780
|
+
if (typeof designerValue === 'string') {
|
|
1781
|
+
designerValue = designerValue.replace(/"/g, "'");
|
|
1782
|
+
}
|
|
1783
|
+
try {
|
|
1784
|
+
json5.parse(designerValue);
|
|
1785
|
+
return `:${attr.name}="${designerValue}"`;
|
|
1786
|
+
}
|
|
1787
|
+
catch (e) {
|
|
1788
|
+
return `${attr.name}="${designerValue}"`;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
if (attr.type === 'dynamic' &&
|
|
1792
|
+
!(element.tag === 'u-cascade-select' && attr.name === 'categories'))
|
|
1793
|
+
return defaultResult.replace(/:?([\w-]+)(?:.*?)="([\s\S]*)"/, (m, name, value) => {
|
|
1794
|
+
try {
|
|
1795
|
+
const tempValue = json5.parse(value);
|
|
1796
|
+
if (typeof tempValue === 'boolean' || typeof tempValue === 'number') {
|
|
1797
|
+
// 简单类型走属性
|
|
1798
|
+
return `:${name}="${value.replace(/"/g, "'")}"`;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
catch (e) {
|
|
1802
|
+
if (apiOfAttr && !apiOfAttr.type.includes('string'))
|
|
1803
|
+
return '';
|
|
1804
|
+
}
|
|
1805
|
+
value = value
|
|
1806
|
+
.replace(/"/g, "'")
|
|
1807
|
+
.replace(/\$utils\['(.+?)'\]/g, '$1')
|
|
1808
|
+
.replace(/\$refs./g, 'elements.')
|
|
1809
|
+
.replace(/\$global.userInfo/g, 'nasl.auth.userInfo')
|
|
1810
|
+
.replace(/\$global./g, 'nasl.')
|
|
1811
|
+
.replace(/\bscope\.item\.\b/g, '')
|
|
1812
|
+
.replace(/\bcurrent\.item\.\b/g, '');
|
|
1813
|
+
return `${name}="{{ ${value} }}"`;
|
|
1814
|
+
});
|
|
1815
|
+
else
|
|
1816
|
+
return defaultResult;
|
|
1817
|
+
}
|
|
1818
|
+
return false;
|
|
1819
|
+
},
|
|
1820
|
+
bindStylesFormat: (bindStyles, element) => false,
|
|
1821
|
+
getExtraParts: (el) => {
|
|
1822
|
+
const parts = [];
|
|
1823
|
+
const api = config_1.config.allNodesAPI[el.tag];
|
|
1824
|
+
const emptySlot = api && api.slots && api.slots.find((slot) => slot.name === 'default' && slot['empty-background']);
|
|
1825
|
+
const hasSupport = api && api.slots && api.slots.some((slot) => slot.support);
|
|
1826
|
+
if (emptySlot || hasSupport) {
|
|
1827
|
+
// 有些限制的组件如侧边栏分组有title插槽但要限制子元素放入
|
|
1828
|
+
const validChildren = el.children.filter((elem) => !(elem.tag === 'template' && elem.slotTarget !== 'default'));
|
|
1829
|
+
let childEmpty = !validChildren.length;
|
|
1830
|
+
const defaultSlot = el.children.find((elem) => elem.tag === 'template' && elem.slotTarget === 'default');
|
|
1831
|
+
if (defaultSlot) {
|
|
1832
|
+
childEmpty = !defaultSlot.children.length;
|
|
1833
|
+
}
|
|
1834
|
+
if (childEmpty) {
|
|
1835
|
+
let addEmpty = true;
|
|
1836
|
+
if (['u-grid-view', 'u-list-view', 'van-list-view', 'van-grid-view', 'u-carousel'].includes(el.tag)) {
|
|
1837
|
+
const hasDataSource = el.bindAttrs.find((attr) => attr.name === 'data-source');
|
|
1838
|
+
addEmpty = !hasDataSource;
|
|
1839
|
+
}
|
|
1840
|
+
if (el.tag === 'u-crumb') {
|
|
1841
|
+
const attrList = el.bindAttrs;
|
|
1842
|
+
const hasAuto = attrList.some((attr) => attr.name === 'auto' && String(attr.value) === 'true');
|
|
1843
|
+
if (hasAuto)
|
|
1844
|
+
addEmpty = false;
|
|
1845
|
+
}
|
|
1846
|
+
if ([
|
|
1847
|
+
'u-select',
|
|
1848
|
+
'u-dropdown',
|
|
1849
|
+
'u-panel',
|
|
1850
|
+
'u-toc',
|
|
1851
|
+
'u-toc-item',
|
|
1852
|
+
'u-tree-view-new',
|
|
1853
|
+
'u-tree-view-node-new',
|
|
1854
|
+
'u-tree-select',
|
|
1855
|
+
'u-tree-select-new',
|
|
1856
|
+
'u-anchor',
|
|
1857
|
+
'u-drawer',
|
|
1858
|
+
'u-timeline',
|
|
1859
|
+
'u-tabs',
|
|
1860
|
+
].includes(el.tag)) {
|
|
1861
|
+
addEmpty = false;
|
|
1862
|
+
}
|
|
1863
|
+
const background = (emptySlot && emptySlot['empty-background']) || (hasSupport ? 'add-sub' : '');
|
|
1864
|
+
addEmpty && parts.push(`vusion-empty-background="${background}"`);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
if (['u-router-view', 'van-router-view'].includes(el.tag)) {
|
|
1868
|
+
const excludes = ['background-color:', 'background:', 'background-image:'];
|
|
1869
|
+
if (excludes.some((key) => el.staticStyle && el.staticStyle.includes(key))) {
|
|
1870
|
+
parts.push(':designer="false"');
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
return parts;
|
|
1874
|
+
},
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
// 获取currentList
|
|
1878
|
+
getCurrentList() {
|
|
1879
|
+
const argsList = [];
|
|
1880
|
+
let parent = this.parentNode;
|
|
1881
|
+
let index = 0;
|
|
1882
|
+
while (parent && parent.concept !== 'View') {
|
|
1883
|
+
if (parent.slotScope) {
|
|
1884
|
+
argsList.push(index === 0 ? 'current' : 'current' + index);
|
|
1885
|
+
index++;
|
|
1886
|
+
}
|
|
1887
|
+
parent = parent.parentNode;
|
|
1888
|
+
}
|
|
1889
|
+
return argsList;
|
|
1890
|
+
}
|
|
1891
|
+
get refName() {
|
|
1892
|
+
let refName = this.name;
|
|
1893
|
+
const list = this.getCurrentList();
|
|
1894
|
+
if (Array.isArray(list) && list.length) {
|
|
1895
|
+
list.forEach((item) => {
|
|
1896
|
+
refName += `_\${(${item} || {}).__nodeKey || (${item} || {}).index}`;
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
return refName;
|
|
1900
|
+
}
|
|
1901
|
+
get keyName() {
|
|
1902
|
+
// 是否配置了v-if
|
|
1903
|
+
const isDefineIf = this.bindDirectives.some((directive) => directive.name === 'if' && directive.expression);
|
|
1904
|
+
if (isDefineIf) {
|
|
1905
|
+
let key = this.name;
|
|
1906
|
+
const list = this.getCurrentList();
|
|
1907
|
+
// v-for中需要加上nodeKey
|
|
1908
|
+
if (Array.isArray(list) && list.length) {
|
|
1909
|
+
list.forEach((item) => {
|
|
1910
|
+
key += `_\${(${item} || {}).__nodeKey || (${item} || {}).index}`;
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
return key;
|
|
1914
|
+
}
|
|
1915
|
+
return null;
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* 转换成 Vue 的模板格式
|
|
1919
|
+
*/
|
|
1920
|
+
toVue(options) {
|
|
1921
|
+
let currentList = [];
|
|
1922
|
+
if (Array.isArray(options?.currentList)) {
|
|
1923
|
+
currentList = [...options?.currentList];
|
|
1924
|
+
}
|
|
1925
|
+
if (this.slotScope) {
|
|
1926
|
+
currentList.unshift(this.slotScope);
|
|
1927
|
+
}
|
|
1928
|
+
const newOptions = Object.assign({
|
|
1929
|
+
indentStyle: 'space',
|
|
1930
|
+
tabSize: 4,
|
|
1931
|
+
indentLevel: 0,
|
|
1932
|
+
aslIdAttr: false,
|
|
1933
|
+
nodePathAttr: false,
|
|
1934
|
+
getExtraParts: () => [],
|
|
1935
|
+
attrFormat: (attr, element, defaultResult) => defaultResult,
|
|
1936
|
+
bindStylesFormat: (bindStyles, element) => {
|
|
1937
|
+
if (bindStyles.length === 0)
|
|
1938
|
+
return false;
|
|
1939
|
+
return `:style="{${bindStyles
|
|
1940
|
+
.map((item) => item.toVue())
|
|
1941
|
+
.filter((item) => item !== undefined)
|
|
1942
|
+
.join(', ')}}"`;
|
|
1943
|
+
},
|
|
1944
|
+
}, options, {
|
|
1945
|
+
currentList,
|
|
1946
|
+
});
|
|
1947
|
+
const tabString = ' '.repeat(newOptions.tabSize * newOptions.indentLevel);
|
|
1948
|
+
const insideTabString = ' '.repeat(newOptions.tabSize * (newOptions.indentLevel + 1));
|
|
1949
|
+
let shouldIndent = true;
|
|
1950
|
+
const content = !this.children
|
|
1951
|
+
? ''
|
|
1952
|
+
: this.children
|
|
1953
|
+
.map((element) => {
|
|
1954
|
+
const childOptions = Object.assign({}, newOptions);
|
|
1955
|
+
childOptions.indentLevel++;
|
|
1956
|
+
return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
|
|
1957
|
+
})
|
|
1958
|
+
.join('');
|
|
1959
|
+
if (!content.length) {
|
|
1960
|
+
shouldIndent = false;
|
|
1961
|
+
}
|
|
1962
|
+
const parts = [];
|
|
1963
|
+
if (newOptions.aslIdAttr) {
|
|
1964
|
+
if (newOptions.aslIdAttr === true) {
|
|
1965
|
+
newOptions.aslIdAttr = 'asl-id';
|
|
1966
|
+
}
|
|
1967
|
+
parts.push(`${newOptions.aslIdAttr}="${this.id}"`);
|
|
1968
|
+
}
|
|
1969
|
+
if (newOptions.nodePathAttr) {
|
|
1970
|
+
// 注入 asl 的 node-path
|
|
1971
|
+
parts.push(`vusion-node-path="${this.nodePath}"`);
|
|
1972
|
+
}
|
|
1973
|
+
// 模板里解析时候,可能会有多级嵌套的 current,所以当前有多少的长度,当前就是多大的下标
|
|
1974
|
+
this.slotTarget &&
|
|
1975
|
+
parts.push(`#${this.slotTarget}` +
|
|
1976
|
+
(this.slotScope
|
|
1977
|
+
? `="${currentList.length > 1 ? this.slotScope + (currentList.length - 1) : this.slotScope}"`
|
|
1978
|
+
: ''));
|
|
1979
|
+
this.refName && parts.push(`:ref="\`${this.refName}\`"`);
|
|
1980
|
+
this.keyName && parts.push(`:key="\`${this.keyName}\`"`);
|
|
1981
|
+
this.staticClass && parts.push(`class="${this.staticClass}"`);
|
|
1982
|
+
this.staticStyle && parts.push(`style="${this.staticStyle}"`);
|
|
1983
|
+
const vIfs = [];
|
|
1984
|
+
[]
|
|
1985
|
+
.concat(this.bindAttrs, this.bindDirectives, this.bindEvents)
|
|
1986
|
+
.forEach((attr) => {
|
|
1987
|
+
const result = newOptions.attrFormat(attr, this, attr?.toVue(newOptions));
|
|
1988
|
+
// v-auth v-if 都翻译成 v-if
|
|
1989
|
+
if (attr instanceof BindDirective__1.default && ['if', 'auth'].includes(attr.name) && result !== false) {
|
|
1990
|
+
const expr = result.replace(/v-(if|auth)="(.*)"/, (match, p1, p2) => p2);
|
|
1991
|
+
if (expr)
|
|
1992
|
+
vIfs.push(attr.name === 'if' ? expr : `$auth.has(${expr})`);
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1995
|
+
result && parts.push(result);
|
|
1996
|
+
});
|
|
1997
|
+
if (vIfs.length === 2)
|
|
1998
|
+
parts.push(`v-if="(${vIfs[0]}) && (${vIfs[1]})"`);
|
|
1999
|
+
else if (vIfs.length === 1)
|
|
2000
|
+
parts.push(`v-if="${vIfs[0]}"`);
|
|
2001
|
+
const bindStyles = newOptions.bindStylesFormat(this.bindStyles, this);
|
|
2002
|
+
if (bindStyles)
|
|
2003
|
+
parts.push(bindStyles);
|
|
2004
|
+
newOptions.getExtraParts(this).forEach((part) => parts.push(part));
|
|
2005
|
+
if (['u-modal', 'u-drawer'].includes(this.tag)) {
|
|
2006
|
+
this.children.forEach((citem) => {
|
|
2007
|
+
if (citem.tag === 'template' && !citem.children.length) {
|
|
2008
|
+
parts.push(`:is-${citem.slotTarget}-slot-empty=true`);
|
|
2009
|
+
}
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
// 部分组件增加 key 唯一标识,防止 vue 判断重复节点,导致渲染异常
|
|
2013
|
+
if (this.name &&
|
|
2014
|
+
['u-table-view', 'u-list-view', 'u-grid-view', 'u-list-components', 'u-form', 'u-select'].includes(this.tag)) {
|
|
2015
|
+
this.name && parts.push(`key="${this.name}"`);
|
|
2016
|
+
}
|
|
2017
|
+
let partsLength = 0;
|
|
2018
|
+
let partsString = '';
|
|
2019
|
+
parts.forEach((part) => {
|
|
2020
|
+
if (partsLength >= 120 || part.length >= 120) {
|
|
2021
|
+
partsString += '\n' + tabString + ' '.repeat(3); // ' '.repeat(el.tag.length + 1);
|
|
2022
|
+
partsLength = 0;
|
|
2023
|
+
}
|
|
2024
|
+
partsString += ' ' + part;
|
|
2025
|
+
partsLength += part.length;
|
|
2026
|
+
});
|
|
2027
|
+
let htmlContent = `<${this.tag}${partsString.length ? partsString : ''}>` +
|
|
2028
|
+
content +
|
|
2029
|
+
(shouldIndent ? '\n' + tabString : '') +
|
|
2030
|
+
`</${this.tag}>`;
|
|
2031
|
+
if (!content.trim() && selfClosingTag.includes(this.tag)) {
|
|
2032
|
+
htmlContent = `<${this.tag}${partsString.length ? partsString : ''} />`;
|
|
2033
|
+
}
|
|
2034
|
+
return htmlContent;
|
|
2035
|
+
}
|
|
2036
|
+
/**
|
|
2037
|
+
* 从父级删除该节点
|
|
2038
|
+
* @internal
|
|
2039
|
+
*/
|
|
2040
|
+
delete() {
|
|
2041
|
+
super.delete();
|
|
2042
|
+
if (this.parentNode) {
|
|
2043
|
+
this.traverseChildren((ele) => {
|
|
2044
|
+
this.view?.removeExistingViewElement(ele);
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
findElementByName(name) {
|
|
2049
|
+
return utils.traverse((current) => {
|
|
2050
|
+
if (current.node.name === name)
|
|
2051
|
+
return current.node;
|
|
2052
|
+
}, { node: this });
|
|
2053
|
+
}
|
|
2054
|
+
findElementByTag(tag) {
|
|
2055
|
+
return utils.traverse((current) => {
|
|
2056
|
+
if (current.node.tag === tag)
|
|
2057
|
+
return current.node;
|
|
2058
|
+
}, { node: this });
|
|
2059
|
+
}
|
|
2060
|
+
findElementByAttr(name, value) {
|
|
2061
|
+
return utils.traverse((current) => {
|
|
2062
|
+
if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
|
|
2063
|
+
return current.node;
|
|
2064
|
+
}, { node: this });
|
|
2065
|
+
}
|
|
2066
|
+
computedStyle = {};
|
|
2067
|
+
getCurrentName() {
|
|
2068
|
+
let current = 'current';
|
|
2069
|
+
let parent = this.parentNode;
|
|
2070
|
+
let index = 0;
|
|
2071
|
+
while (parent && parent.concept !== 'View') {
|
|
2072
|
+
if (parent.slotScope) {
|
|
2073
|
+
index++;
|
|
2074
|
+
}
|
|
2075
|
+
parent = parent.parentNode;
|
|
2076
|
+
}
|
|
2077
|
+
current = index === 0 ? 'current' : 'current' + index;
|
|
2078
|
+
return current;
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* 计算约束样式
|
|
2082
|
+
* @param positionData 位置数据
|
|
2083
|
+
* @param doNotRecordLastWidthHeight 是否不记录上一次的宽高
|
|
2084
|
+
*/
|
|
2085
|
+
computeConstraintStyle(positionData, ops = {}) {
|
|
2086
|
+
if (!positionData) {
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
const { nodeRect, parentRect, parentBorder } = positionData;
|
|
2090
|
+
const staticWidth = nodeRect.width;
|
|
2091
|
+
const staticHeight = nodeRect.height;
|
|
2092
|
+
const staticLeft = nodeRect.left - parentRect.left - parentBorder.left;
|
|
2093
|
+
const staticTop = nodeRect.top - parentRect.top - parentBorder.top;
|
|
2094
|
+
const staticRight = parentRect.width - nodeRect.width - staticLeft - parentBorder.right - parentBorder.left;
|
|
2095
|
+
const staticBottom = parentRect.height - nodeRect.height - staticTop - parentBorder.bottom - parentBorder.top;
|
|
2096
|
+
const styleObj = this.parseStyleToObject(this.staticStyle);
|
|
2097
|
+
const constraintX = styleObj['--constraint-x'] || 'left';
|
|
2098
|
+
const constraintY = styleObj['--constraint-y'] || 'top';
|
|
2099
|
+
const rawWidth = styleObj.width || '';
|
|
2100
|
+
const rawHeight = styleObj.height || '';
|
|
2101
|
+
let left = '';
|
|
2102
|
+
let right = '';
|
|
2103
|
+
let top = '';
|
|
2104
|
+
let bottom = '';
|
|
2105
|
+
let transform = '';
|
|
2106
|
+
// 如果宽高被约束规则改成 auto 了,就还原为上次的宽高,防止用户设置的宽高信息在切换约束时候丢失
|
|
2107
|
+
let width = Number(styleObj['--constraint-width-auto']) ? styleObj['--last-width'] : rawWidth;
|
|
2108
|
+
let height = Number(styleObj['--constraint-height-auto']) ? styleObj['--last-height'] : rawHeight;
|
|
2109
|
+
// 用于记录宽高是否被约束规则改成 auto 了
|
|
2110
|
+
let constraintWidthAuto = 0;
|
|
2111
|
+
let constraintHeightAuto = 0;
|
|
2112
|
+
const parentWidth = staticLeft + staticWidth + staticRight;
|
|
2113
|
+
const parentHeight = staticTop + staticHeight + staticBottom;
|
|
2114
|
+
if (constraintX === 'left') {
|
|
2115
|
+
left = staticLeft + 'px';
|
|
2116
|
+
right = '';
|
|
2117
|
+
}
|
|
2118
|
+
else if (constraintX === 'right') {
|
|
2119
|
+
left = '';
|
|
2120
|
+
right = staticRight + 'px';
|
|
2121
|
+
}
|
|
2122
|
+
else if (constraintX === 'center') {
|
|
2123
|
+
const offset = staticLeft + staticWidth / 2 - parentWidth / 2;
|
|
2124
|
+
left = `calc(50% ${offset > 0 ? '+' : '-'} ${Math.abs(offset)}px)`;
|
|
2125
|
+
right = '';
|
|
2126
|
+
transform = 'translateX(-50%)';
|
|
2127
|
+
}
|
|
2128
|
+
else if (constraintX === 'scale') {
|
|
2129
|
+
left = (staticLeft * 100) / parentWidth + '%';
|
|
2130
|
+
right = '';
|
|
2131
|
+
width = (staticWidth * 100) / parentWidth + '%';
|
|
2132
|
+
constraintWidthAuto = 1;
|
|
2133
|
+
}
|
|
2134
|
+
else if (constraintX === 'left-right') {
|
|
2135
|
+
left = staticLeft + 'px';
|
|
2136
|
+
right = staticRight + 'px';
|
|
2137
|
+
width = 'auto';
|
|
2138
|
+
constraintWidthAuto = 1;
|
|
2139
|
+
}
|
|
2140
|
+
if (constraintY === 'top') {
|
|
2141
|
+
top = staticTop + 'px';
|
|
2142
|
+
bottom = '';
|
|
2143
|
+
}
|
|
2144
|
+
else if (constraintY === 'bottom') {
|
|
2145
|
+
top = '';
|
|
2146
|
+
bottom = staticBottom + 'px';
|
|
2147
|
+
}
|
|
2148
|
+
else if (constraintY === 'center') {
|
|
2149
|
+
const offset = staticTop + staticHeight / 2 - parentHeight / 2;
|
|
2150
|
+
top = `calc(50% ${offset > 0 ? '+' : '-'} ${Math.abs(offset)}px)`;
|
|
2151
|
+
bottom = '';
|
|
2152
|
+
transform = transform ? 'translate(-50%, -50%)' : 'translateY(-50%)';
|
|
2153
|
+
}
|
|
2154
|
+
else if (constraintY === 'scale') {
|
|
2155
|
+
top = (staticTop * 100) / parentHeight + '%';
|
|
2156
|
+
bottom = '';
|
|
2157
|
+
height = (staticHeight * 100) / parentHeight + '%';
|
|
2158
|
+
constraintHeightAuto = 1;
|
|
2159
|
+
}
|
|
2160
|
+
else if (constraintY === 'top-bottom') {
|
|
2161
|
+
top = staticTop + 'px';
|
|
2162
|
+
bottom = staticBottom + 'px';
|
|
2163
|
+
height = 'auto';
|
|
2164
|
+
constraintHeightAuto = 1;
|
|
2165
|
+
}
|
|
2166
|
+
const newStyleObj = {
|
|
2167
|
+
...styleObj,
|
|
2168
|
+
left,
|
|
2169
|
+
right,
|
|
2170
|
+
top,
|
|
2171
|
+
bottom,
|
|
2172
|
+
transform,
|
|
2173
|
+
width,
|
|
2174
|
+
height,
|
|
2175
|
+
'--constraint-width-auto': constraintWidthAuto,
|
|
2176
|
+
'--constraint-height-auto': constraintHeightAuto,
|
|
2177
|
+
};
|
|
2178
|
+
if (!ops.doNotRecordLastWidthHeight) {
|
|
2179
|
+
if (rawWidth !== 'auto') {
|
|
2180
|
+
newStyleObj['--last-width'] = rawWidth;
|
|
2181
|
+
}
|
|
2182
|
+
if (rawHeight !== 'auto') {
|
|
2183
|
+
newStyleObj['--last-height'] = rawHeight;
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
ops.beforeSetStyleCb?.(newStyleObj);
|
|
2187
|
+
const newStaticStyle = this.stringifyStyleAttr(newStyleObj);
|
|
2188
|
+
this.setStaticStyle(newStaticStyle);
|
|
2189
|
+
}
|
|
2190
|
+
updateStyleObj(styleObj) {
|
|
2191
|
+
this.setStaticStyle(this.stringifyStyleAttr({
|
|
2192
|
+
...this.parseStyleToObject(this.staticStyle),
|
|
2193
|
+
...styleObj,
|
|
2194
|
+
}));
|
|
2195
|
+
}
|
|
2196
|
+
parseStyleToObject(styleStr = '') {
|
|
2197
|
+
const [styleStr1, styleStr2] = styleStr.split('--custom-start: auto;');
|
|
2198
|
+
const styleObj = styleStr1.split(/;/gim).reduce((obj, item) => {
|
|
2199
|
+
// background-image:url(http://www...)
|
|
2200
|
+
item = item.trim();
|
|
2201
|
+
const pos = item.indexOf(':');
|
|
2202
|
+
if (pos >= 0) {
|
|
2203
|
+
const key = item.slice(0, pos).trim();
|
|
2204
|
+
const value = item.slice(pos + 1).trim();
|
|
2205
|
+
obj[key] = value;
|
|
2206
|
+
}
|
|
2207
|
+
return obj;
|
|
2208
|
+
}, {});
|
|
2209
|
+
styleObj['customStyle'] = styleStr2;
|
|
2210
|
+
return styleObj;
|
|
2211
|
+
}
|
|
2212
|
+
stringifyStyleAttr(styleObj) {
|
|
2213
|
+
const customStyle = styleObj['customStyle'] || '';
|
|
2214
|
+
delete styleObj['customStyle'];
|
|
2215
|
+
const styleStr = Object.keys(styleObj)
|
|
2216
|
+
// 空字符串是允许的,因为有时候想要覆盖之前的样式。undefined 则不允许
|
|
2217
|
+
.filter((key) => styleObj[key] !== undefined)
|
|
2218
|
+
.map((key) => `${key}:${String(styleObj[key]).trim()};`)
|
|
2219
|
+
.join('');
|
|
2220
|
+
return styleStr + '--custom-start: auto;' + customStyle;
|
|
2221
|
+
}
|
|
2222
|
+
// 批量更新绑定属性
|
|
2223
|
+
batchUpdateBindAttrs(attrOptions) {
|
|
2224
|
+
const oldBindAttrs = this.bindAttrs.filter((it) => !attrOptions.some((item) => item.name === it.name));
|
|
2225
|
+
const newBindAttrs = attrOptions.map((it) => BindAttribute__1.default.from(it, this, 'bindAttrs'));
|
|
2226
|
+
this.update({
|
|
2227
|
+
bindAttrs: [...oldBindAttrs, ...newBindAttrs],
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
__decorate([
|
|
2232
|
+
(0, decorators_1.property)('concept')
|
|
2233
|
+
], ViewElement.prototype, "concept", void 0);
|
|
2234
|
+
__decorate([
|
|
2235
|
+
(0, decorators_1.property)()
|
|
2236
|
+
], ViewElement.prototype, "type", void 0);
|
|
2237
|
+
__decorate([
|
|
2238
|
+
(0, decorators_1.property)()
|
|
2239
|
+
], ViewElement.prototype, "tag", void 0);
|
|
2240
|
+
__decorate([
|
|
2241
|
+
(0, decorators_1.property)()
|
|
2242
|
+
], ViewElement.prototype, "name", void 0);
|
|
2243
|
+
__decorate([
|
|
2244
|
+
(0, decorators_1.property)()
|
|
2245
|
+
], ViewElement.prototype, "staticClass", void 0);
|
|
2246
|
+
__decorate([
|
|
2247
|
+
(0, decorators_1.property)()
|
|
2248
|
+
], ViewElement.prototype, "staticStyle", void 0);
|
|
2249
|
+
__decorate([
|
|
2250
|
+
(0, decorators_1.property)()
|
|
2251
|
+
], ViewElement.prototype, "authDescription", void 0);
|
|
2252
|
+
__decorate([
|
|
2253
|
+
(0, decorators_1.property)()
|
|
2254
|
+
], ViewElement.prototype, "slotTarget", void 0);
|
|
2255
|
+
__decorate([
|
|
2256
|
+
(0, decorators_1.property)()
|
|
2257
|
+
], ViewElement.prototype, "slotScope", void 0);
|
|
2258
|
+
__decorate([
|
|
2259
|
+
(0, decorators_1.property)({
|
|
2260
|
+
objectRef: 'BindAttribute',
|
|
2261
|
+
isArray: true,
|
|
2262
|
+
defaultValue: [],
|
|
2263
|
+
})
|
|
2264
|
+
], ViewElement.prototype, "bindAttrs", void 0);
|
|
2265
|
+
__decorate([
|
|
2266
|
+
(0, decorators_1.property)({
|
|
2267
|
+
objectRef: 'BindEvent',
|
|
2268
|
+
isArray: true,
|
|
2269
|
+
defaultValue: [],
|
|
2270
|
+
})
|
|
2271
|
+
], ViewElement.prototype, "bindEvents", void 0);
|
|
2272
|
+
__decorate([
|
|
2273
|
+
(0, decorators_1.property)({
|
|
2274
|
+
objectRef: 'BindDirective',
|
|
2275
|
+
isArray: true,
|
|
2276
|
+
defaultValue: [],
|
|
2277
|
+
})
|
|
2278
|
+
], ViewElement.prototype, "bindDirectives", void 0);
|
|
2279
|
+
__decorate([
|
|
2280
|
+
(0, decorators_1.property)({
|
|
2281
|
+
isArray: true,
|
|
2282
|
+
defaultValue: [],
|
|
2283
|
+
})
|
|
2284
|
+
], ViewElement.prototype, "bindRoles", void 0);
|
|
2285
|
+
__decorate([
|
|
2286
|
+
(0, decorators_1.property)({
|
|
2287
|
+
objectRef: 'BindStyle',
|
|
2288
|
+
isArray: true,
|
|
2289
|
+
defaultValue: [],
|
|
2290
|
+
})
|
|
2291
|
+
], ViewElement.prototype, "bindStyles", void 0);
|
|
2292
|
+
__decorate([
|
|
2293
|
+
(0, decorators_1.property)({
|
|
2294
|
+
objectRef: 'ViewElement',
|
|
2295
|
+
isArray: true,
|
|
2296
|
+
defaultValue: [],
|
|
2297
|
+
})
|
|
2298
|
+
], ViewElement.prototype, "children", void 0);
|
|
2299
|
+
__decorate([
|
|
2300
|
+
(0, translator_1.withSourceMap)()
|
|
2301
|
+
], ViewElement.prototype, "toEmbeddedTS", null);
|
|
2302
|
+
__decorate([
|
|
2303
|
+
(0, translator_1.withSourceMap)()
|
|
2304
|
+
], ViewElement.prototype, "toNaturalTS", null);
|
|
2305
|
+
__decorate([
|
|
2306
|
+
(0, decorators_1.excludedInJSON)()
|
|
2307
|
+
], ViewElement.prototype, "computedStyle", void 0);
|
|
2308
|
+
ViewElement = ViewElement_1 = __decorate([
|
|
2309
|
+
decorators_1.className,
|
|
2310
|
+
(0, decorators_1.concept)('页面元素')
|
|
2311
|
+
// @ts-ignore
|
|
2312
|
+
], ViewElement);
|
|
2313
|
+
exports.ViewElement = ViewElement;
|
|
2314
|
+
exports.default = ViewElement;
|
|
2315
|
+
//================================================================================
|
|
2316
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
2317
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
2318
|
+
//================================================================================
|
|
2320
2319
|
//# sourceMappingURL=ViewElement__.js.map
|