@lcap/nasl 3.3.0-alpha.1 → 3.3.0-alpha.3
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/upgrader/2.20.js.map +1 -1
- package/out/bak/translator.js +52 -1
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/shared/utils.js +0 -2
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +9 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/Abort__.js +2 -1
- package/out/concepts/Abort__.js.map +1 -1
- package/out/concepts/Anchor__.js +1 -1
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js +2 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/Argument__.js +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.js +1 -1
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +2 -2
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +1 -1
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/Backend__.js +1 -1
- package/out/concepts/Backend__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +2 -2
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +2 -2
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +2 -0
- package/out/concepts/BindAttribute__.js +79 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -1
- package/out/concepts/BindEvent__.js +44 -37
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.js +1 -1
- package/out/concepts/CallAuthInterface__.js.map +1 -1
- package/out/concepts/CallConnector__.js +1 -1
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallFunction__.js +2 -2
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +2 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +69 -12
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Connection__.js +9 -10
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.js +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.js +2 -2
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.js +1 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +2 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.js +2 -2
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js +2 -2
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +2 -2
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +27 -37
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.js +1 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +2 -2
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/JavaLogic__.js +1 -1
- package/out/concepts/JavaLogic__.js.map +1 -1
- package/out/concepts/LogicItem__.js +3 -2
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +2 -1
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +1 -1
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +2 -2
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +117 -2
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -1
- package/out/concepts/Module__.js +34 -35
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +2 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js +2 -2
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/New__.js +1 -1
- package/out/concepts/New__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +2 -2
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +1 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +1 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/Return__.js +2 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +1 -1
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +1 -1
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +2 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +2 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +2 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +2 -2
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +2 -2
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TriggerLauncher__.js +1 -1
- package/out/concepts/TriggerLauncher__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +4 -3
- package/out/concepts/TypeAnnotation__.js +116 -75
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +2 -2
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +14 -14
- package/out/concepts/ValidationRule__.js +28 -24
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -2
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +88 -87
- package/out/concepts/ViewElement__.js +268 -204
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +6 -0
- package/out/concepts/View__.js +254 -11
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +2 -2
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.browser.js +1 -0
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.event.js +2 -0
- package/out/concepts/basics/stdlib/nasl.event.js.map +1 -1
- package/out/generator/genBundleFiles.js +90 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +1 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/natural/genNaturalTS.js +7 -3
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/knowledgeMap.js +12 -12
- package/out/natural/knowledgeMap.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +1 -1
- package/out/natural/transformTSCode.js +115 -141
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +69 -44
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +72 -63
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +20 -23
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +149 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +3 -3
- package/out/server/naslServer.js +182 -132
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +43 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +6 -6
- package/out/service/storage/init.js +16 -0
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +5 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +12 -8
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +8 -7
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.d.ts +1 -1
- package/out/templator/genEditTableBlock.js +12 -6
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +2 -2
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.d.ts +2 -2
- package/out/templator/genGridViewBlock.js +20 -7
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.d.ts +2 -2
- package/out/templator/genListViewBlock.js +13 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.d.ts +2 -2
- package/out/templator/genSelectBlock.js +8 -6
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +1 -1
- package/out/templator/genTableBlock.js +10 -5
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +5 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/package.json +3 -1
- package/sandbox/stdlib/nasl.auth.ts +40 -44
- package/sandbox/stdlib/nasl.core.ts +8 -1
- package/sandbox/stdlib/nasl.http.ts +22 -22
- package/sandbox-natural/stdlib/nasl.util.ts +74 -15
- package/src/automate/upgrader/2.20.js +17 -13
- package/src/bak/translator.js +50 -1
- package/src/breakpoint/shared/utils.ts +0 -2
- package/src/common/Command.ts +8 -0
- package/src/concepts/Abort__.ts +2 -2
- package/src/concepts/Anchor__.ts +2 -2
- package/src/concepts/AnonymousFunction__.ts +3 -3
- package/src/concepts/Argument__.ts +2 -2
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/AssignmentLine__.ts +2 -2
- package/src/concepts/Assignment__.ts +3 -3
- package/src/concepts/BackendVariable__.ts +2 -2
- package/src/concepts/Backend__.ts +1 -1
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BinaryExpression__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +69 -4
- package/src/concepts/BindDirective__.ts +2 -2
- package/src/concepts/BindEvent__.ts +44 -64
- package/src/concepts/BindStyle__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +2 -2
- package/src/concepts/CallAuthInterface__.ts +2 -2
- package/src/concepts/CallConnector__.ts +2 -2
- package/src/concepts/CallFunction__.ts +3 -3
- package/src/concepts/CallInterface__.ts +3 -3
- package/src/concepts/CallLogic__.ts +69 -13
- package/src/concepts/CallQueryComponent__.ts +2 -2
- package/src/concepts/Comment__.ts +2 -2
- package/src/concepts/ConfigProperty__.ts +2 -2
- package/src/concepts/Connection__.ts +15 -21
- package/src/concepts/Constant__.ts +2 -2
- package/src/concepts/DataSource__.ts +1 -1
- package/src/concepts/Destination__.ts +3 -3
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +2 -2
- package/src/concepts/EntityProperty__.ts +3 -3
- package/src/concepts/Entity__.ts +2 -2
- package/src/concepts/EnumItem__.ts +3 -3
- package/src/concepts/Enum__.ts +2 -2
- package/src/concepts/ForEachStatement__.ts +35 -46
- package/src/concepts/Frontend__.ts +1 -1
- package/src/concepts/Function__.ts +3 -3
- package/src/concepts/Identifier__.ts +2 -2
- package/src/concepts/IfStatement__.ts +3 -3
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/JSBlock__.ts +2 -2
- package/src/concepts/JavaLogic__.ts +2 -2
- package/src/concepts/LogicItem__.ts +3 -3
- package/src/concepts/Logic__.ts +2 -1
- package/src/concepts/MatchCase__.ts +2 -2
- package/src/concepts/Match__.ts +3 -3
- package/src/concepts/MemberExpression__.ts +112 -4
- package/src/concepts/Module__.ts +41 -58
- package/src/concepts/NewComposite__.ts +3 -3
- package/src/concepts/NewList__.ts +3 -3
- package/src/concepts/NewMap__.ts +3 -3
- package/src/concepts/New__.ts +2 -2
- package/src/concepts/NullLiteral__.ts +2 -2
- package/src/concepts/NumericLiteral__.ts +2 -2
- package/src/concepts/OqlQueryComponent__.ts +3 -3
- package/src/concepts/Param__.ts +2 -2
- package/src/concepts/ProcessElement__.ts +2 -2
- package/src/concepts/ProcessOutcome__.ts +2 -2
- package/src/concepts/ProcessOutcomes__.ts +2 -2
- package/src/concepts/Process__.ts +1 -1
- package/src/concepts/QueryAggregateExpression__.ts +2 -2
- package/src/concepts/QueryFieldExpression__.ts +2 -2
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/QueryLimitExpression__.ts +2 -2
- package/src/concepts/QueryOrderByExpression__.ts +2 -2
- package/src/concepts/Return__.ts +3 -3
- package/src/concepts/Role__.ts +1 -1
- package/src/concepts/SelectMembers__.ts +2 -2
- package/src/concepts/SqlQueryComponent__.ts +3 -3
- package/src/concepts/Start__.ts +2 -2
- package/src/concepts/StringInterpolation__.ts +3 -3
- package/src/concepts/StringLiteral__.ts +2 -2
- package/src/concepts/StructureProperty__.ts +3 -3
- package/src/concepts/Structure__.ts +2 -2
- package/src/concepts/SwitchCase__.ts +2 -2
- package/src/concepts/SwitchStatement__.ts +3 -3
- package/src/concepts/TriggerLauncher__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +145 -125
- package/src/concepts/TypeParam__.ts +2 -2
- package/src/concepts/UnaryExpression__.ts +3 -3
- package/src/concepts/ValidationRule__.ts +554 -524
- package/src/concepts/Variable__.ts +3 -3
- package/src/concepts/ViewElement__.ts +2445 -2498
- package/src/concepts/View__.ts +258 -10
- package/src/concepts/WhileStatement__.ts +3 -3
- package/src/concepts/basics/stdlib/nasl.browser.ts +1 -0
- package/src/concepts/basics/stdlib/nasl.event.ts +2 -0
- package/src/generator/genBundleFiles.ts +91 -1
- package/src/generator/genReleaseBody.ts +1 -1
- package/src/generator/permission.ts +3 -3
- package/src/index.ts +1 -0
- package/src/natural/genNaturalTS.ts +8 -4
- package/src/natural/knowledgeMap.ts +12 -12
- package/src/natural/transformTSCode.ts +139 -151
- package/src/server/extendBaseNode.ts +71 -45
- package/src/server/formatTsUtils.ts +64 -64
- package/src/server/getLogics.ts +23 -30
- package/src/server/getMemberIdentifier.ts +143 -0
- package/src/server/naslServer.ts +174 -148
- package/src/server/translator.ts +40 -39
- package/src/service/defaultErrorMessage.json +6 -6
- package/src/service/storage/init.ts +17 -0
- package/src/templator/genCreateBlock.ts +5 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +12 -8
- package/src/templator/genCurdMultipleKeyBlock.ts +8 -7
- package/src/templator/genEditTableBlock.ts +12 -7
- package/src/templator/genEnumSelectBlock.ts +2 -2
- package/src/templator/genGetBlock.ts +6 -6
- package/src/templator/genGridViewBlock.ts +22 -9
- package/src/templator/genListViewBlock.ts +14 -5
- package/src/templator/genSelectBlock.ts +8 -6
- package/src/templator/genTableBlock.ts +10 -9
- package/src/templator/genUpdateBlock.ts +5 -3
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +11 -0
- package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +10 -0
- package/test/concepts/validation-rule/fixtures/argument-without-keyword.json +34 -0
- package/test/concepts/validation-rule/fixtures/empty-rule.json +9 -0
- package/test/concepts/validation-rule/validation-rule.spec.ts +15 -0
package/src/bak/translator.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PAGE_COMPONENT_INCLUDE_TAG_MAP } from '..'
|
|
2
|
+
|
|
1
3
|
function safeCodeAsKey(name) {
|
|
2
4
|
return `['${name}']`;
|
|
3
5
|
}
|
|
@@ -66,6 +68,50 @@ export default function (definition) {
|
|
|
66
68
|
}
|
|
67
69
|
viewVariablesData.push(code);
|
|
68
70
|
});
|
|
71
|
+
/**
|
|
72
|
+
* 页面的 computed
|
|
73
|
+
* 包含 页面组件属性依赖
|
|
74
|
+
*/
|
|
75
|
+
const viewComputedData = []
|
|
76
|
+
const viewMethodData = []
|
|
77
|
+
definition.elements.forEach(element => {
|
|
78
|
+
element.bindAttrs.filter((attr) => PAGE_COMPONENT_INCLUDE_TAG_MAP[element.tag]?.[attr.name]).forEach(attr => {
|
|
79
|
+
let variable = ''
|
|
80
|
+
if (attr.expression) {
|
|
81
|
+
variable += `${attr.expression.toJS()}`
|
|
82
|
+
// attrsData.push(code)
|
|
83
|
+
} else if (attr.type === 'static') {
|
|
84
|
+
variable = `${attr.value}`
|
|
85
|
+
// attrsData.push(code)
|
|
86
|
+
}
|
|
87
|
+
if (attr.name === 'data-source' && attr.expression && variable.includes('await')) {
|
|
88
|
+
const code = `async '__${element.name}_${attr.name}'() {
|
|
89
|
+
const params = {}
|
|
90
|
+
return ${variable}
|
|
91
|
+
}`
|
|
92
|
+
viewMethodData.push(code)
|
|
93
|
+
} else {
|
|
94
|
+
const code = `['__${element.name}_${attr.name}']() {
|
|
95
|
+
return ${variable}
|
|
96
|
+
}`
|
|
97
|
+
viewComputedData.push(code)
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
if (['u-select', 'van-pickerson'].includes(element.tag)) {
|
|
101
|
+
viewVariablesData.push(`['__${element.name}_params']: {}`);
|
|
102
|
+
const code = `['__${element.name}_page-number']() {
|
|
103
|
+
return this['__${element.name}_params']?.number ?? 1
|
|
104
|
+
}`
|
|
105
|
+
viewComputedData.push(code)
|
|
106
|
+
} else if (['u-list-view', 'u-grid-view', 'u-table-view', 'van-list-view', 'van-grid-view'].includes(element.tag) && element.bindAttrs?.findIndex((attr) => attr.name === 'sorting') === -1) {
|
|
107
|
+
viewComputedData.push(`['__${element.name}_sorting']() {
|
|
108
|
+
return {
|
|
109
|
+
field: undefined,
|
|
110
|
+
order: undefined
|
|
111
|
+
}
|
|
112
|
+
}`)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
69
115
|
|
|
70
116
|
let viewExpressionMethods;
|
|
71
117
|
if (hasViewExpressions) {
|
|
@@ -111,6 +157,9 @@ export default function (definition) {
|
|
|
111
157
|
${viewVariablesData.join(',\n').trim()}
|
|
112
158
|
};
|
|
113
159
|
},
|
|
160
|
+
computed: {
|
|
161
|
+
${viewComputedData.join(',\n').trim()}
|
|
162
|
+
},
|
|
114
163
|
meta: {
|
|
115
164
|
title: ${JSON.stringify(definition.title)},
|
|
116
165
|
crumb: ${JSON.stringify(definition.crumb)},
|
|
@@ -118,7 +167,7 @@ meta: {
|
|
|
118
167
|
auth: ${JSON.stringify(definition.auth)},
|
|
119
168
|
},
|
|
120
169
|
methods: {
|
|
121
|
-
${[...(methods || []), ...(eventLogic || []), ...(viewExpressionMethods || [])].join(',\n\n')}
|
|
170
|
+
${[...(methods || []), ...(eventLogic || []), ...(viewExpressionMethods || []), ...(viewMethodData || [])].join(',\n\n')}
|
|
122
171
|
},
|
|
123
172
|
${events.join(',\n\n')}
|
|
124
173
|
`;
|
package/src/common/Command.ts
CHANGED
|
@@ -57,6 +57,14 @@ export function invokeCommand(command: string, ...args: any[]) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export function invokeOnlyCommand(command: string, ...args: any[]) {
|
|
61
|
+
const cmds = _commands.get(command);
|
|
62
|
+
if (!cmds?.length) {
|
|
63
|
+
console.warn(`Command ${command} not found!`);
|
|
64
|
+
}
|
|
65
|
+
return cmds[0]?.execute(...args);
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
export function hasCommand(command: string) {
|
|
61
69
|
return _commands.has(command);
|
|
62
70
|
}
|
package/src/concepts/Abort__.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, indent } from '../translator';
|
|
2
|
+
import { TranslatorState, indent, createCompilerState } from '../translator';
|
|
3
3
|
//= ===============================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
5
5
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -60,7 +60,7 @@ export class Abort extends LogicItem {
|
|
|
60
60
|
return code;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
toEmbeddedTS(state
|
|
63
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
64
64
|
let code = '';
|
|
65
65
|
// 中止放入表达式中,处理翻译就跳过
|
|
66
66
|
// 别的就增加一个 return;
|
package/src/concepts/Anchor__.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import StringLiteral from './StringLiteral__';
|
|
5
5
|
//= ===============================================================================
|
|
@@ -161,7 +161,7 @@ export class Anchor extends LogicItem {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
@withSourceMap()
|
|
164
|
-
toNaturalTS(state
|
|
164
|
+
toNaturalTS(state = createCompilerState(), isHaveKeyWord?: boolean): string {
|
|
165
165
|
let code = '';
|
|
166
166
|
if (isHaveKeyWord) {
|
|
167
167
|
code += `_anchor: `;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import Namespace from './Namespace__';
|
|
3
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
3
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
4
4
|
import { ElementToVueOptions } from './ViewElement__';
|
|
5
5
|
import ForEachStatement from './ForEachStatement__';
|
|
6
6
|
import NewList from './NewList__';
|
|
@@ -491,7 +491,7 @@ export class AnonymousFunction extends LogicItem {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
@withSourceMap()
|
|
494
|
-
toEmbeddedTS(state
|
|
494
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
495
495
|
let updateNoPropertyCode = '';
|
|
496
496
|
const grandParent = this.parentNode?.parentNode;
|
|
497
497
|
if (
|
|
@@ -540,7 +540,7 @@ export class AnonymousFunction extends LogicItem {
|
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
@withSourceMap()
|
|
543
|
-
toNaturalTS(state
|
|
543
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
544
544
|
let code = '';
|
|
545
545
|
if (this.body) {
|
|
546
546
|
code += `(`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import StringLiteral from './StringLiteral__';
|
|
5
5
|
import TypeAnnotation from './TypeAnnotation__';
|
|
@@ -252,7 +252,7 @@ export class Argument extends LogicItem {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
@withSourceMap()
|
|
255
|
-
toNaturalTS(state
|
|
255
|
+
toNaturalTS(state = createCompilerState(), isRequired: boolean = true, isHaveKeyWord?: boolean): string {
|
|
256
256
|
let code = this.spread ? '...' : '';
|
|
257
257
|
if (isHaveKeyWord) {
|
|
258
258
|
code += `${this.tsKeyword}:`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
3
3
|
import { ProcessElement, Process } from '..';
|
|
4
4
|
import Namespace from './Namespace__';
|
|
5
5
|
//= ===============================================================================
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
//= ===============================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
5
5
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -93,7 +93,7 @@ export class AssignmentLine extends BaseNode {
|
|
|
93
93
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
94
94
|
//= ===============================================================================
|
|
95
95
|
@withSourceMap()
|
|
96
|
-
toEmbeddedTS(state
|
|
96
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
97
97
|
const code = '';
|
|
98
98
|
return code;
|
|
99
99
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import Identifier from './Identifier__';
|
|
4
4
|
import { ElementToVueOptions } from './ViewElement__';
|
|
5
5
|
import BatchAssignment from './BatchAssignment__';
|
|
@@ -292,7 +292,7 @@ export class Assignment extends LogicItem {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
@withSourceMap()
|
|
295
|
-
toEmbeddedTS(state
|
|
295
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
296
296
|
let code = 'nasl.core.assign(';
|
|
297
297
|
|
|
298
298
|
code += this.left ? this.left.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
@@ -307,7 +307,7 @@ export class Assignment extends LogicItem {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
@withSourceMap()
|
|
310
|
-
toNaturalTS(state
|
|
310
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
311
311
|
let code = '';
|
|
312
312
|
|
|
313
313
|
code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { dataTypesMap } from './basics/types';
|
|
3
|
-
import { TranslatorState, shiftState, withSourceMap,
|
|
3
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
4
4
|
import { ElementToVueOptions } from './ViewElement__';
|
|
5
5
|
import EntityProperty from './EntityProperty__';
|
|
6
6
|
import StructureProperty from './StructureProperty__';
|
|
@@ -290,7 +290,7 @@ export class BackendVariable extends BaseNode {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
@withSourceMap()
|
|
293
|
-
toEmbeddedTS(state
|
|
293
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
294
294
|
let code = this.name;
|
|
295
295
|
if (this.typeAnnotation) {
|
|
296
296
|
code += ': ';
|
|
@@ -316,7 +316,7 @@ export class Backend extends BaseNode {
|
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
@withSourceMap()
|
|
319
|
-
toEmbeddedTS(state
|
|
319
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
320
320
|
let code = `export namespace ${this.name} {\n`;
|
|
321
321
|
code += 'const name = ';
|
|
322
322
|
code += `"${this.name}";\n`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import MemberExpression from './MemberExpression__';
|
|
5
5
|
import Assignment from './Assignment__';
|
|
@@ -973,7 +973,7 @@ export class BatchAssignment extends LogicItem {
|
|
|
973
973
|
}
|
|
974
974
|
|
|
975
975
|
@withSourceMap()
|
|
976
|
-
toEmbeddedTS(state
|
|
976
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
977
977
|
let code = '// 以下是批量赋值的翻译代码\n';
|
|
978
978
|
// 提供sourcemap,获取类型标注和上下文可选变量
|
|
979
979
|
code += this.left.expression ? `${this.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true }))}` : '';
|
|
@@ -1016,7 +1016,7 @@ export class BatchAssignment extends LogicItem {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
1018
|
@withSourceMap()
|
|
1019
|
-
toNaturalTS(state
|
|
1019
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
1020
1020
|
let code = '';
|
|
1021
1021
|
// 根据连线状态,拆分成多个单赋值
|
|
1022
1022
|
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
|
|
5
5
|
//= ===============================================================================
|
|
@@ -319,7 +319,7 @@ export class BinaryExpression extends LogicItem {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
@withSourceMap()
|
|
322
|
-
toEmbeddedTS(state
|
|
322
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
323
323
|
if (['startwith', 'endwith', 'like', 'in'].includes(this.operator)) {
|
|
324
324
|
const fnName = this.operator.toUpperCase();
|
|
325
325
|
let code = '';
|
|
@@ -363,7 +363,7 @@ export class BinaryExpression extends LogicItem {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
@withSourceMap()
|
|
366
|
-
toNaturalTS(state
|
|
366
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
367
367
|
if (['startwith', 'endwith', 'like', 'in'].includes(this.operator)) {
|
|
368
368
|
const fnName = this.operator.toUpperCase();
|
|
369
369
|
let code = '';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, indent, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import ViewElement, { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import Namespace from './Namespace__';
|
|
5
5
|
import MemberExpression from './MemberExpression__';
|
|
@@ -947,6 +947,8 @@ export class BindAttribute extends BaseNode {
|
|
|
947
947
|
value = `[${ruleStrs.join(' , ')}]`;
|
|
948
948
|
} else if (['destination', 'externalDestination'].includes(this.name)) {
|
|
949
949
|
value = (this as any)?.[this.name]?.toVue(options) || '';
|
|
950
|
+
} else if ('ArrowFunctionExpression'.includes(this.expression?.concept)) {
|
|
951
|
+
value = this.value;
|
|
950
952
|
} else {
|
|
951
953
|
value = this.expression?.toVue(options) || '';
|
|
952
954
|
}
|
|
@@ -1019,10 +1021,15 @@ export class BindAttribute extends BaseNode {
|
|
|
1019
1021
|
}
|
|
1020
1022
|
|
|
1021
1023
|
@withSourceMap()
|
|
1022
|
-
toEmbeddedTS(state
|
|
1024
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
1023
1025
|
const { name, type, value, rules, expression, playground } = this;
|
|
1024
1026
|
|
|
1025
|
-
let code = '
|
|
1027
|
+
let code = ''
|
|
1028
|
+
if (this?.name === 'data-source' && this?.expression?.concept === 'CallLogic') {
|
|
1029
|
+
code = `(params: nasl.ui.DataSourceParams) => {`;
|
|
1030
|
+
} else {
|
|
1031
|
+
code = '() => {';
|
|
1032
|
+
}
|
|
1026
1033
|
|
|
1027
1034
|
if (['destination', 'externalDestination'].includes(name) && type === 'dynamic') {
|
|
1028
1035
|
code += (this as any)[name].toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
@@ -1071,8 +1078,54 @@ export class BindAttribute extends BaseNode {
|
|
|
1071
1078
|
return code;
|
|
1072
1079
|
}
|
|
1073
1080
|
|
|
1081
|
+
toEmbeddedTSVariableDefinition(state?: TranslatorState, attrList?: string[], elementName?: string): string {
|
|
1082
|
+
let code = '';
|
|
1083
|
+
let arrCode = '';
|
|
1084
|
+
code += indent((state?.tabSize || 0) + 3);
|
|
1085
|
+
code += `${attrConvertCamelCase(this.name)}: `
|
|
1086
|
+
if (this.expression) {
|
|
1087
|
+
if (this.name === 'data-source') {
|
|
1088
|
+
if (this?.expression?.concept === 'CallLogic') {
|
|
1089
|
+
arrCode += `(params: nasl.ui.DataSourceParams) => `;
|
|
1090
|
+
}
|
|
1091
|
+
if (['CallLogic', 'CallFunction'].includes(this.expression?.concept)) {
|
|
1092
|
+
code += `nasl.ui.GetItemTypeFromDataSource<typeof __elements_stashFunctionVariable.${elementName}_${attrConvertCamelCase(this.name)}>`
|
|
1093
|
+
arrCode += `${this.expression.toEmbeddedTS()}`
|
|
1094
|
+
} else {
|
|
1095
|
+
code += `nasl.ui.GetItemTypeFromDataSource<typeof ${this.expression.toEmbeddedTS()}>`
|
|
1096
|
+
}
|
|
1097
|
+
} else {
|
|
1098
|
+
if (['CallLogic', 'CallFunction'].includes(this.expression?.concept)) {
|
|
1099
|
+
code += `typeof __elements_stashFunctionVariable.${elementName}_${attrConvertCamelCase(this.name)}`
|
|
1100
|
+
arrCode += `${this.expression.toEmbeddedTS()}`
|
|
1101
|
+
} else {
|
|
1102
|
+
code += `typeof ${this.expression.toEmbeddedTS()}`
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
} else if (this.name === 'sorting') {
|
|
1106
|
+
code += `{
|
|
1107
|
+
field: nasl.core.String
|
|
1108
|
+
order: nasl.core.String
|
|
1109
|
+
}`
|
|
1110
|
+
} else if (this.type === 'static') {
|
|
1111
|
+
let type = 'nasl.core.String'
|
|
1112
|
+
if (typeof this.value === 'number') {
|
|
1113
|
+
type = `${this.value}`.includes('.') ? 'nasl.core.Decimal' : 'nasl.core.Long';
|
|
1114
|
+
} else if (typeof this.value === 'boolean') {
|
|
1115
|
+
type = 'nasl.core.Boolean'
|
|
1116
|
+
}
|
|
1117
|
+
code += `${type}`
|
|
1118
|
+
} else {
|
|
1119
|
+
code += 'undefined'
|
|
1120
|
+
}
|
|
1121
|
+
code += `\n`
|
|
1122
|
+
if (arrCode.length > 0) {
|
|
1123
|
+
attrList.push(`${elementName}_${attrConvertCamelCase(this.name)}: ${arrCode},\n`)
|
|
1124
|
+
}
|
|
1125
|
+
return code
|
|
1126
|
+
}
|
|
1074
1127
|
@withSourceMap()
|
|
1075
|
-
toNaturalTS(state
|
|
1128
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
1076
1129
|
const { name, type, value, rules, expression, playground } = this;
|
|
1077
1130
|
let code = '() => {';
|
|
1078
1131
|
|
|
@@ -1143,3 +1196,15 @@ export default BindAttribute;
|
|
|
1143
1196
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
1144
1197
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
1145
1198
|
//= ===============================================================================
|
|
1199
|
+
|
|
1200
|
+
export function attrConvertCamelCase(str: string) {
|
|
1201
|
+
let strList: string[] = str.split('-')
|
|
1202
|
+
strList = strList.map((strItem, index) => {
|
|
1203
|
+
if (index === 0) {
|
|
1204
|
+
return strItem
|
|
1205
|
+
} else {
|
|
1206
|
+
return `${strItem.slice(0, 1).toUpperCase()}${strItem.slice(1)}`;
|
|
1207
|
+
}
|
|
1208
|
+
})
|
|
1209
|
+
return strList.join('')
|
|
1210
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import ViewElement, { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import MemberExpression from './MemberExpression__';
|
|
5
5
|
//= ===============================================================================
|
|
@@ -578,7 +578,7 @@ export class BindDirective extends BaseNode {
|
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
@withSourceMap()
|
|
581
|
-
toEmbeddedTS(state
|
|
581
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
582
582
|
let code = '()=>{';
|
|
583
583
|
if (this.expression) {
|
|
584
584
|
code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|