@lcap/nasl 3.3.0-beta.0 → 3.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/common/BaseNode.js +2 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/Abort__.js +2 -1
- package/out/concepts/Abort__.js.map +1 -1
- package/out/concepts/Anchor__.d.ts +1 -0
- package/out/concepts/Anchor__.js +16 -0
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +28 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.js +2 -1
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +1 -0
- package/out/concepts/Argument__.js +21 -0
- 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__.d.ts +1 -0
- package/out/concepts/Assignment__.js +15 -1
- 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__.d.ts +1 -0
- package/out/concepts/BatchAssignment__.js +18 -1
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +1 -0
- package/out/concepts/BinaryExpression__.js +53 -16
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +1 -0
- package/out/concepts/BindAttribute__.js +67 -3
- 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 +1 -0
- package/out/concepts/BindEvent__.js +57 -0
- 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__.d.ts +1 -0
- package/out/concepts/BooleanLiteral__.js +7 -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__.d.ts +1 -0
- package/out/concepts/CallFunction__.js +45 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +1 -0
- package/out/concepts/CallInterface__.js +44 -8
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -0
- package/out/concepts/CallLogic__.js +101 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.d.ts +1 -0
- package/out/concepts/Comment__.js +7 -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/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.js +2 -2
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +52 -1
- 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__.d.ts +1 -0
- package/out/concepts/EntityProperty__.js +17 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +25 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +1 -0
- package/out/concepts/EnumItem__.js +7 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +14 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +1 -0
- package/out/concepts/ForEachStatement__.js +44 -1
- 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__.d.ts +1 -0
- package/out/concepts/Function__.js +29 -1
- 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__.d.ts +1 -0
- package/out/concepts/IfStatement__.js +30 -1
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +3 -1
- package/out/concepts/Interface__.js +19 -3
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts +1 -0
- package/out/concepts/JSBlock__.js +7 -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__.d.ts +6 -0
- package/out/concepts/LogicItem__.js +10 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -0
- package/out/concepts/Logic__.js +133 -1
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +1 -0
- package/out/concepts/MatchCase__.js +88 -0
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +1 -0
- package/out/concepts/Match__.js +44 -1
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +19 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +1 -0
- package/out/concepts/NewComposite__.js +91 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +17 -1
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +11 -1
- 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__.d.ts +1 -0
- package/out/concepts/NumericLiteral__.js +7 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +1 -0
- package/out/concepts/OqlQueryComponent__.js +8 -1
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -0
- package/out/concepts/Param__.js +41 -0
- 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/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__.d.ts +1 -0
- package/out/concepts/Return__.js +20 -1
- 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__.d.ts +1 -0
- package/out/concepts/SqlQueryComponent__.js +8 -1
- 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__.d.ts +1 -0
- package/out/concepts/StringInterpolation__.js +19 -1
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -0
- package/out/concepts/StringLiteral__.js +6 -0
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +5 -0
- package/out/concepts/StructureProperty__.js +19 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +5 -0
- package/out/concepts/Structure__.js +22 -2
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -0
- package/out/concepts/SwitchCase__.js +34 -0
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.d.ts +1 -0
- package/out/concepts/SwitchStatement__.js +19 -1
- 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 +1 -0
- package/out/concepts/TypeAnnotation__.js +47 -1
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +1 -0
- package/out/concepts/TypeParam__.js +6 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.d.ts +1 -0
- package/out/concepts/UnaryExpression__.js +19 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.d.ts +1 -0
- package/out/concepts/Unparsed__.js +6 -0
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -0
- package/out/concepts/Variable__.js +20 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +67 -0
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -0
- package/out/concepts/View__.js +94 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.d.ts +1 -0
- package/out/concepts/WhileStatement__.js +21 -1
- package/out/concepts/WhileStatement__.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/componentData.d.ts +31 -0
- package/out/natural/componentData.js +85 -0
- package/out/natural/componentData.js.map +1 -0
- package/out/natural/genNaturalTS.d.ts +3 -0
- package/out/natural/genNaturalTS.js +91 -0
- package/out/natural/genNaturalTS.js.map +1 -0
- package/out/natural/index.d.ts +2 -0
- package/out/natural/index.js +19 -0
- package/out/natural/index.js.map +1 -0
- package/out/natural/naslStdlibMap.d.ts +2 -0
- package/out/natural/naslStdlibMap.js +26 -0
- package/out/natural/naslStdlibMap.js.map +1 -0
- package/out/natural/transformTSCode.d.ts +7 -0
- package/out/natural/transformTSCode.js +878 -0
- package/out/natural/transformTSCode.js.map +1 -0
- package/out/server/naslServer.d.ts +3 -3
- package/out/server/naslServer.js +93 -108
- package/out/server/naslServer.js.map +1 -1
- package/out/service/storage/init.js +16 -0
- package/out/service/storage/init.js.map +1 -1
- package/out/utils/env.d.ts +2 -0
- package/out/utils/env.js +6 -0
- package/out/utils/env.js.map +1 -0
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.js +1 -0
- package/out/utils/index.js.map +1 -1
- package/out/utils/time-slicing.js +2 -1
- package/out/utils/time-slicing.js.map +1 -1
- package/package.json +11 -5
- package/sandbox-natural/stdlib/nasl.core.ts +36 -0
- package/sandbox-natural/stdlib/nasl.oql.ts +8 -0
- package/sandbox-natural/stdlib/nasl.ui.ts +63 -0
- package/sandbox-natural/stdlib/nasl.util.ts +119 -0
- package/sandbox-natural/tsconfig.json +12 -0
- package/src/common/BaseNode.ts +3 -1
- package/src/concepts/Abort__.ts +2 -2
- package/src/concepts/Anchor__.ts +16 -2
- package/src/concepts/AnonymousFunction__.ts +29 -4
- package/src/concepts/App__.ts +2 -1
- package/src/concepts/Argument__.ts +19 -1
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/AssignmentLine__.ts +2 -2
- package/src/concepts/Assignment__.ts +26 -11
- package/src/concepts/BackendVariable__.ts +2 -2
- package/src/concepts/Backend__.ts +1 -1
- package/src/concepts/BatchAssignment__.ts +20 -3
- package/src/concepts/BinaryExpression__.ts +54 -18
- package/src/concepts/BindAttribute__.ts +63 -4
- package/src/concepts/BindDirective__.ts +2 -2
- package/src/concepts/BindEvent__.ts +58 -0
- package/src/concepts/BindStyle__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +7 -2
- package/src/concepts/CallAuthInterface__.ts +2 -2
- package/src/concepts/CallConnector__.ts +2 -2
- package/src/concepts/CallFunction__.ts +42 -2
- package/src/concepts/CallInterface__.ts +48 -10
- package/src/concepts/CallLogic__.ts +123 -3
- package/src/concepts/CallQueryComponent__.ts +2 -2
- package/src/concepts/Comment__.ts +9 -3
- package/src/concepts/ConfigProperty__.ts +1 -1
- package/src/concepts/Constant__.ts +2 -2
- package/src/concepts/DataSource__.ts +2 -2
- package/src/concepts/Destination__.ts +58 -2
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +2 -2
- package/src/concepts/EntityProperty__.ts +18 -2
- package/src/concepts/Entity__.ts +27 -1
- package/src/concepts/EnumItem__.ts +7 -2
- package/src/concepts/Enum__.ts +14 -1
- package/src/concepts/ForEachStatement__.ts +48 -4
- package/src/concepts/Frontend__.ts +1 -1
- package/src/concepts/Function__.ts +30 -2
- package/src/concepts/Identifier__.ts +2 -2
- package/src/concepts/IfStatement__.ts +39 -3
- package/src/concepts/Interface__.ts +20 -3
- package/src/concepts/JSBlock__.ts +7 -2
- package/src/concepts/JavaLogic__.ts +2 -2
- package/src/concepts/LogicItem__.ts +11 -2
- package/src/concepts/Logic__.ts +137 -1
- package/src/concepts/MatchCase__.ts +90 -2
- package/src/concepts/Match__.ts +47 -3
- package/src/concepts/MemberExpression__.ts +19 -2
- package/src/concepts/NewComposite__.ts +85 -2
- package/src/concepts/NewList__.ts +17 -2
- package/src/concepts/NewMap__.ts +11 -2
- package/src/concepts/New__.ts +2 -2
- package/src/concepts/NullLiteral__.ts +2 -2
- package/src/concepts/NumericLiteral__.ts +7 -2
- package/src/concepts/OqlQueryComponent__.ts +8 -2
- package/src/concepts/Param__.ts +40 -1
- package/src/concepts/ProcessElement__.ts +2 -2
- package/src/concepts/ProcessOutcome__.ts +2 -2
- package/src/concepts/ProcessOutcomes__.ts +2 -2
- 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 +20 -2
- package/src/concepts/Role__.ts +1 -1
- package/src/concepts/SelectMembers__.ts +2 -2
- package/src/concepts/SqlQueryComponent__.ts +8 -2
- package/src/concepts/Start__.ts +2 -2
- package/src/concepts/StringInterpolation__.ts +20 -3
- package/src/concepts/StringLiteral__.ts +6 -1
- package/src/concepts/StructureProperty__.ts +20 -3
- package/src/concepts/Structure__.ts +22 -2
- package/src/concepts/SwitchCase__.ts +35 -2
- package/src/concepts/SwitchStatement__.ts +20 -3
- package/src/concepts/TriggerLauncher__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +47 -2
- package/src/concepts/TypeParam__.ts +8 -2
- package/src/concepts/UnaryExpression__.ts +22 -3
- package/src/concepts/Unparsed__.ts +5 -1
- package/src/concepts/ValidationRule__.ts +2 -2
- package/src/concepts/Variable__.ts +20 -2
- package/src/concepts/ViewElement__.ts +70 -2
- package/src/concepts/View__.ts +106 -8
- package/src/concepts/WhileStatement__.ts +25 -3
- package/src/index.ts +1 -0
- package/src/natural/componentData.ts +81 -0
- package/src/natural/genNaturalTS.ts +91 -0
- package/src/natural/index.ts +2 -0
- package/src/natural/naslStdlibMap.ts +24 -0
- package/src/natural/transformTSCode.ts +834 -0
- package/src/server/naslServer.ts +90 -87
- package/src/service/storage/init.ts +17 -0
- package/src/utils/env.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/time-slicing.ts +3 -1
- package/test/concepts/anonymous-function/__snapshots__/toEmbeddedTS.spec.ts.snap +8 -0
- package/test/concepts/anonymous-function/__snapshots__/toJS.spec.ts.snap +3 -0
- package/test/concepts/anonymous-function/__snapshots__/toVue.spec.ts.snap +6 -0
- package/test/concepts/anonymous-function/constant.ts +5 -0
- package/test/concepts/anonymous-function/fixtures/simple.json +85 -0
- package/test/concepts/anonymous-function/toEmbeddedTS.spec.ts +14 -0
- package/test/concepts/anonymous-function/toJS.spec.ts +14 -0
- package/test/concepts/anonymous-function/toVue.spec.ts +14 -0
- package/test/concepts/assignment/__snapshots__/toEmbeddedTS.spec.ts.snap +21 -0
- package/test/concepts/assignment/__snapshots__/toJS.spec.ts.snap +9 -0
- package/test/concepts/assignment/__snapshots__/toVue.spec.ts.snap +21 -0
- package/test/concepts/assignment/constant.ts +5 -0
- package/test/concepts/assignment/fixtures/both-space.json +4 -0
- package/test/concepts/assignment/fixtures/left-space.json +14 -0
- package/test/concepts/assignment/fixtures/right-space.json +8 -0
- package/test/concepts/assignment/fixtures/simple.json +12 -0
- package/test/concepts/assignment/toEmbeddedTS.spec.ts +14 -0
- package/test/concepts/assignment/toJS.spec.ts +14 -0
- package/test/concepts/assignment/toVue.spec.ts +14 -0
- package/test/concepts/batch-assignment/__snapshots__/toEmbeddedTS.spec.ts.snap +28 -0
- package/test/concepts/batch-assignment/__snapshots__/toJS.spec.ts.snap +13 -0
- package/test/concepts/batch-assignment/__snapshots__/toVue.spec.ts.snap +14 -0
- package/test/concepts/batch-assignment/constant.ts +5 -0
- package/test/concepts/batch-assignment/fixtures/muli-var-muli-value.json +144 -0
- package/test/concepts/batch-assignment/fixtures/simple-var-simple-value.json +36 -0
- package/test/concepts/batch-assignment/toEmbeddedTS.spec.ts +14 -0
- package/test/concepts/batch-assignment/toJS.spec.ts +14 -0
- package/test/concepts/batch-assignment/toVue.spec.ts +14 -0
- package/test/concepts/binary-expression/__snapshots__/toEmbeddedTS.spec.ts.snap +25 -0
- package/test/concepts/binary-expression/__snapshots__/toJS.spec.ts.snap +16 -0
- package/test/concepts/binary-expression/__snapshots__/toVue.spec.ts.snap +19 -0
- package/test/concepts/binary-expression/constant.ts +5 -0
- package/test/concepts/binary-expression/fixtures/constant-nested.json +36 -0
- package/test/concepts/binary-expression/fixtures/constant-simple.json +12 -0
- package/test/concepts/binary-expression/fixtures/variable-nested.json +69 -0
- package/test/concepts/binary-expression/toEmbeddedTS.spec.ts +14 -0
- package/test/concepts/binary-expression/toJS.spec.ts +14 -0
- package/test/concepts/binary-expression/toVue.spec.ts +14 -0
- package/test/concepts/boolean-literal/toEmbeddedTS.spec.ts +2 -2
- package/test/concepts/boolean-literal/toJS.spec.ts +2 -2
- package/test/concepts/boolean-literal/toVue.spec.ts +2 -2
- package/test/concepts/data-source/__snapshots__/toEmbeddedTS.spec.ts.snap +8 -0
- package/test/concepts/data-source/__snapshots__/toEmbeddedTSFile.spec.ts.snap +12 -0
- package/test/concepts/data-source/constant.ts +5 -0
- package/test/concepts/data-source/fixtures/normal.json +289 -0
- package/test/concepts/data-source/toEmbeddedTS.spec.ts +14 -0
- package/test/concepts/data-source/toEmbeddedTSFile.spec.ts +15 -0
- package/test/concepts/entity/__snapshots__/toEmbeddedTS.spec.ts.snap +74 -0
- package/test/concepts/entity/__snapshots__/toEmbeddedTSFile.spec.ts.snap +3 -0
- package/test/concepts/entity/constant.ts +5 -0
- package/test/concepts/entity/fixtures/normal.json +469 -0
- package/test/concepts/entity/toEmbeddedTS.spec.ts +14 -0
- package/test/concepts/entity/toEmbeddedTSFile.spec.ts +14 -0
- package/test/concepts/identifier/toEmbeddedTS.spec.ts +2 -2
- package/test/concepts/identifier/toJS.spec.ts +2 -2
- package/test/concepts/identifier/toVue.spec.ts +2 -2
- package/test/concepts/member-expression/toEmbeddedTS.spec.ts +2 -2
- package/test/concepts/member-expression/toJS.spec.ts +2 -2
- package/test/concepts/member-expression/toVue.spec.ts +2 -2
- package/test/concepts/null-literal/toEmbeddedTS.spec.ts +2 -2
- package/test/concepts/null-literal/toJS.spec.ts +2 -2
- package/test/concepts/null-literal/toVue.spec.ts +2 -2
- package/test/concepts/numeric-literal/toEmbeddedTS.spec.ts +2 -2
- package/test/concepts/numeric-literal/toJS.spec.ts +2 -2
- package/test/concepts/numeric-literal/toVue.spec.ts +2 -2
- package/test/concepts/string-literal/toEmbeddedTS.spec.ts +2 -2
- package/test/concepts/string-literal/toJS.spec.ts +2 -2
- package/test/concepts/string-literal/toVue.spec.ts +2 -2
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +66 -62
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Namespace from './Namespace__';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import ForEachStatement from './ForEachStatement__';
|
|
5
5
|
import NewList from './NewList__';
|
|
@@ -492,7 +492,7 @@ export class AnonymousFunction extends LogicItem {
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
@withSourceMap()
|
|
495
|
-
toEmbeddedTS(state
|
|
495
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
496
496
|
let updateNoPropertyCode = '';
|
|
497
497
|
const grandParent = this.parentNode?.parentNode;
|
|
498
498
|
if (
|
|
@@ -504,7 +504,6 @@ export class AnonymousFunction extends LogicItem {
|
|
|
504
504
|
const entity = logicNode?.upperNode?.upperNode as Entity;
|
|
505
505
|
if (entity) {
|
|
506
506
|
const primaryKeys = entity.properties.filter((item) => item.primaryKey);
|
|
507
|
-
|
|
508
507
|
const propertyArg = grandParent.arguments.find((item) => item.keyword === 'properties');
|
|
509
508
|
const expression = propertyArg?.expression as unknown as AnonymousFunction;
|
|
510
509
|
const newList = expression?.body as NewList;
|
|
@@ -531,8 +530,34 @@ export class AnonymousFunction extends LogicItem {
|
|
|
531
530
|
|
|
532
531
|
if (this.body) {
|
|
533
532
|
code +=
|
|
534
|
-
this.body.toEmbeddedTS && this.body.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
533
|
+
this.body.toEmbeddedTS && this.body.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize ?? 0) + 1 }));
|
|
534
|
+
}
|
|
535
|
+
code += ';';
|
|
536
|
+
code += `${indent(state?.tabSize ?? 0)}}`;
|
|
537
|
+
} else {
|
|
538
|
+
code += '__IDENTIFIER__';
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
return code;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
@withSourceMap()
|
|
545
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
546
|
+
let code = '';
|
|
547
|
+
if (this.body) {
|
|
548
|
+
code += `(`;
|
|
549
|
+
this.params.forEach((param, index) => {
|
|
550
|
+
code += param.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
551
|
+
if (index !== this.params.length - 1)
|
|
552
|
+
code += ', ';
|
|
553
|
+
});
|
|
554
|
+
code += `)`;
|
|
555
|
+
code += ` => (`;
|
|
556
|
+
|
|
557
|
+
if (this.body) {
|
|
558
|
+
code += this.body.toNaturalTS && this.body.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1, inline: true }));
|
|
535
559
|
}
|
|
560
|
+
code += ')';
|
|
536
561
|
code += ';';
|
|
537
562
|
code += `${indent(state.tabSize)}}`;
|
|
538
563
|
} else {
|
package/src/concepts/App__.ts
CHANGED
|
@@ -3850,7 +3850,8 @@ export class App extends BaseNode {
|
|
|
3850
3850
|
const start = nameArr.shift();
|
|
3851
3851
|
const mod = 0;
|
|
3852
3852
|
const modulesMap: any = {
|
|
3853
|
-
|
|
3853
|
+
// v3.3 版本引入自定义连接器,在配置自定义连接器时需要同步支持内部数据结构使用,所以这里做扩展
|
|
3854
|
+
extensions: [...node.dependencies, ...(node?.integration?.connectors || [])],
|
|
3854
3855
|
apis: node.interfaceDependencies,
|
|
3855
3856
|
components: node.componentDependencies,
|
|
3856
3857
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
import StringLiteral from './StringLiteral__';
|
|
4
4
|
import TypeAnnotation from './TypeAnnotation__';
|
|
@@ -253,6 +253,24 @@ export class Argument extends LogicItem {
|
|
|
253
253
|
return code;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
@withSourceMap()
|
|
257
|
+
toNaturalTS(state = createCompilerState(), isRequired: boolean = true, isHaveKeyWord?: boolean): string {
|
|
258
|
+
let code = this.spread ? '...' : '';
|
|
259
|
+
if (isHaveKeyWord) {
|
|
260
|
+
code += `${this.tsKeyword}:`;
|
|
261
|
+
}
|
|
262
|
+
if (this.expression) {
|
|
263
|
+
if ((this.expression as StringLiteral).name === 'ListDistinctByTargetDefaultExpression') {
|
|
264
|
+
code += (this.expression as NewList).toEmbeddedIgnoreTS(shiftState(state, code));
|
|
265
|
+
} else {
|
|
266
|
+
code += (this.expression as StringLiteral).toNaturalTS(shiftState(state, code), isRequired);
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
code += isRequired ? '__IDENTIFIER__' : 'undefined';
|
|
270
|
+
}
|
|
271
|
+
return code;
|
|
272
|
+
}
|
|
273
|
+
|
|
256
274
|
// 参数的类型
|
|
257
275
|
paramTypeAnnotation?: TypeAnnotation = undefined;
|
|
258
276
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
2
2
|
import { ProcessElement, Process } from '..';
|
|
3
3
|
import Namespace from './Namespace__';
|
|
4
4
|
//================================================================================
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
//================================================================================
|
|
3
3
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
4
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -91,7 +91,7 @@ export class AssignmentLine extends BaseNode {
|
|
|
91
91
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
92
92
|
//================================================================================
|
|
93
93
|
@withSourceMap()
|
|
94
|
-
toEmbeddedTS(state
|
|
94
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
95
95
|
const code = '';
|
|
96
96
|
return code;
|
|
97
97
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import Identifier from './Identifier__';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import BatchAssignment from './BatchAssignment__';
|
|
@@ -226,15 +226,15 @@ export class Assignment extends LogicItem {
|
|
|
226
226
|
});
|
|
227
227
|
const batchObject = this.right
|
|
228
228
|
? {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
left: leftSelect,
|
|
230
|
+
rights: [rightSelect],
|
|
231
|
+
assignmentLines: [assignmentLine],
|
|
232
|
+
}
|
|
233
233
|
: {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
left: leftSelect,
|
|
235
|
+
rights: [],
|
|
236
|
+
assignmentLines: [],
|
|
237
|
+
};
|
|
238
238
|
const batchAssignment = new BatchAssignment({
|
|
239
239
|
...batchObject,
|
|
240
240
|
offsetX: this.offsetX,
|
|
@@ -296,7 +296,7 @@ export class Assignment extends LogicItem {
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
@withSourceMap()
|
|
299
|
-
toEmbeddedTS(state
|
|
299
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
300
300
|
let code = 'nasl.core.assign(';
|
|
301
301
|
|
|
302
302
|
code += this.left ? this.left.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
@@ -318,7 +318,22 @@ export class Assignment extends LogicItem {
|
|
|
318
318
|
return code;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
@withSourceMap()
|
|
322
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
323
|
+
let code = '';
|
|
324
|
+
|
|
325
|
+
code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
326
|
+
code += ' = ';
|
|
327
|
+
// 因为右侧枚举要赋值就得new 一下;
|
|
328
|
+
if (this.right && this.right instanceof Identifier && this.right.namespace && this.right.namespace.endsWith('enums')) {
|
|
329
|
+
code += 'new ';
|
|
330
|
+
}
|
|
331
|
+
code += (this.right && this.right.toNaturalTS) ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
|
|
332
|
+
|
|
333
|
+
return code;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
//= ===============================================================================
|
|
322
337
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
323
338
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
324
339
|
//================================================================================
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataTypesMap } from './basics/types';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap,
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import EntityProperty from './EntityProperty__';
|
|
5
5
|
import StructureProperty from './StructureProperty__';
|
|
@@ -289,7 +289,7 @@ export class BackendVariable extends BaseNode {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
@withSourceMap()
|
|
292
|
-
toEmbeddedTS(state
|
|
292
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
293
293
|
let code = this.name;
|
|
294
294
|
if (this.typeAnnotation) {
|
|
295
295
|
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,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
import MemberExpression from './MemberExpression__';
|
|
4
4
|
import Assignment from './Assignment__';
|
|
@@ -999,7 +999,7 @@ export class BatchAssignment extends LogicItem {
|
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
1001
|
@withSourceMap()
|
|
1002
|
-
toEmbeddedTS(state
|
|
1002
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
1003
1003
|
let code = '// 以下是批量赋值的翻译代码\n';
|
|
1004
1004
|
// 提供sourcemap,获取类型标注和上下文可选变量
|
|
1005
1005
|
code += this.left.expression
|
|
@@ -1042,7 +1042,24 @@ export class BatchAssignment extends LogicItem {
|
|
|
1042
1042
|
code += '// 批量赋值的翻译代码结束---------\n';
|
|
1043
1043
|
return code;
|
|
1044
1044
|
}
|
|
1045
|
-
|
|
1045
|
+
|
|
1046
|
+
@withSourceMap()
|
|
1047
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
1048
|
+
let code = '';
|
|
1049
|
+
// 根据连线状态,拆分成多个单赋值
|
|
1050
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1051
|
+
const leftValue = leftIndex.length === 1 ? this.left.expression.toNaturalTS(shiftState(state, code, { inline: true })) : this.left.members[leftIndex[1]]?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1052
|
+
code += `${leftValue}`;
|
|
1053
|
+
code += ' = ';
|
|
1054
|
+
const rightValue = rightIndex.length === 1 ? this.rights[rightIndex[0]]?.expression?.toNaturalTS(shiftState(state, code, { inline: true })) : this.rights[rightIndex[0]]?.members[rightIndex[1]]?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1055
|
+
code += `${rightValue}`;
|
|
1056
|
+
code += ';';
|
|
1057
|
+
code += '\n';
|
|
1058
|
+
});
|
|
1059
|
+
return code;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
//= ===============================================================================
|
|
1046
1063
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
1047
1064
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
1048
1065
|
//================================================================================
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
|
|
4
|
+
const operatorMap = {
|
|
5
|
+
'&&': 'and',
|
|
6
|
+
'||': 'or',
|
|
7
|
+
'+': 'add',
|
|
8
|
+
'-': 'minus',
|
|
9
|
+
'*': 'multiply',
|
|
10
|
+
'/': 'divide',
|
|
11
|
+
'%': 'remainder',
|
|
12
|
+
'==': 'equal',
|
|
13
|
+
'!=': 'notEqual',
|
|
14
|
+
'>': 'greaterThan',
|
|
15
|
+
'<': 'lessThan',
|
|
16
|
+
'>=': 'greaterThanOrEqual',
|
|
17
|
+
'<=': 'lessThanOrEqual',
|
|
18
|
+
};
|
|
19
|
+
|
|
4
20
|
//================================================================================
|
|
5
21
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
6
22
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -357,7 +373,7 @@ export class BinaryExpression extends LogicItem {
|
|
|
357
373
|
}
|
|
358
374
|
|
|
359
375
|
@withSourceMap()
|
|
360
|
-
toEmbeddedTS(state
|
|
376
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
361
377
|
if (['startwith', 'endwith', 'like', 'in'].includes(this.operator)) {
|
|
362
378
|
const fnName = this.operator.toUpperCase();
|
|
363
379
|
let code = '';
|
|
@@ -371,21 +387,6 @@ export class BinaryExpression extends LogicItem {
|
|
|
371
387
|
return code;
|
|
372
388
|
}
|
|
373
389
|
if (['&&', '||', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<='].includes(this.operator)) {
|
|
374
|
-
const operatorMap = {
|
|
375
|
-
'&&': 'and',
|
|
376
|
-
'||': 'or',
|
|
377
|
-
'+': 'add',
|
|
378
|
-
'-': 'minus',
|
|
379
|
-
'*': 'multiply',
|
|
380
|
-
'/': 'divide',
|
|
381
|
-
'%': 'remainder',
|
|
382
|
-
'==': 'equal',
|
|
383
|
-
'!=': 'notEqual',
|
|
384
|
-
'>': 'greaterThan',
|
|
385
|
-
'<': 'lessThan',
|
|
386
|
-
'>=': 'greaterThanOrEqual',
|
|
387
|
-
'<=': 'lessThanOrEqual',
|
|
388
|
-
};
|
|
389
390
|
let code = '';
|
|
390
391
|
code += `nasl.core.${operatorMap[this.operator as keyof typeof operatorMap]}(`;
|
|
391
392
|
code += this.left?.toEmbeddedTS ? this.left.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
@@ -404,7 +405,42 @@ export class BinaryExpression extends LogicItem {
|
|
|
404
405
|
return code;
|
|
405
406
|
}
|
|
406
407
|
|
|
407
|
-
|
|
408
|
+
@withSourceMap()
|
|
409
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
410
|
+
if (['startwith', 'endwith', 'like', 'in'].includes(this.operator)) {
|
|
411
|
+
const fnName = this.operator.toUpperCase();
|
|
412
|
+
let code = '';
|
|
413
|
+
code += `nasl.langUtil.${fnName}(`;
|
|
414
|
+
code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
415
|
+
code += ', ';
|
|
416
|
+
code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
|
|
417
|
+
code += ')';
|
|
418
|
+
return code;
|
|
419
|
+
}
|
|
420
|
+
if (['&&', '||', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<='].includes(this.operator)) {
|
|
421
|
+
let code = '';
|
|
422
|
+
if (this.left && this.left.concept === 'BinaryExpression') {
|
|
423
|
+
code += this.left ? `(${this.left.toNaturalTS(shiftState(state, code, { inline: true }))})` : '__LEFT__';
|
|
424
|
+
} else {
|
|
425
|
+
code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
426
|
+
}
|
|
427
|
+
code += `${this.operator}`;
|
|
428
|
+
if (this.right && this.right.concept === 'BinaryExpression') {
|
|
429
|
+
code += this.right ? `(${this.right.toNaturalTS(shiftState(state, code, { inline: true }))})` : '__RIGHT__';
|
|
430
|
+
} else {
|
|
431
|
+
code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
|
|
432
|
+
}
|
|
433
|
+
return code;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
let code = '';
|
|
437
|
+
code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
438
|
+
code += ` ${this.operator} `;
|
|
439
|
+
code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
|
|
440
|
+
return code;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
//= ===============================================================================
|
|
408
444
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
409
445
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
410
446
|
//================================================================================
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, indent, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, indent, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
import Namespace from './Namespace__';
|
|
4
4
|
import MemberExpression from './MemberExpression__';
|
|
@@ -977,7 +977,11 @@ export class BindAttribute extends BaseNode {
|
|
|
977
977
|
code = value;
|
|
978
978
|
if (options?.finalCode !== false) {
|
|
979
979
|
code = value.replace(/['"`\\]/g, (m) => {
|
|
980
|
-
|
|
980
|
+
let escape = '\\\\';
|
|
981
|
+
escape = '\\\\';
|
|
982
|
+
/// #if process.env.BUILD_TARGET === 'node'
|
|
983
|
+
escape = '\\';
|
|
984
|
+
/// #endif
|
|
981
985
|
if (m === '\\') {
|
|
982
986
|
return `${escape}${escape}`;
|
|
983
987
|
}
|
|
@@ -1003,7 +1007,11 @@ export class BindAttribute extends BaseNode {
|
|
|
1003
1007
|
value = `$utils['ToString'](${value}, '${expTypeAnnotation?.sortedTypeKey}')`;
|
|
1004
1008
|
}
|
|
1005
1009
|
if (this.type === 'string' && name !== 'rules') {
|
|
1006
|
-
|
|
1010
|
+
if (options?.finalCode !== false) {
|
|
1011
|
+
str += `:${name}="\`${value}\`"`;
|
|
1012
|
+
} else {
|
|
1013
|
+
str += `${name}="${value}"`;
|
|
1014
|
+
}
|
|
1007
1015
|
} else if (this.sync) {
|
|
1008
1016
|
str += `:${name}.sync="${value}"`;
|
|
1009
1017
|
} else if (name === 'destination') {
|
|
@@ -1023,7 +1031,7 @@ export class BindAttribute extends BaseNode {
|
|
|
1023
1031
|
}
|
|
1024
1032
|
|
|
1025
1033
|
@withSourceMap()
|
|
1026
|
-
toEmbeddedTS(state
|
|
1034
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
1027
1035
|
const { name, type, value, rules, expression, playground } = this;
|
|
1028
1036
|
|
|
1029
1037
|
let code = '';
|
|
@@ -1156,6 +1164,57 @@ export class BindAttribute extends BaseNode {
|
|
|
1156
1164
|
return undefined
|
|
1157
1165
|
}
|
|
1158
1166
|
}
|
|
1167
|
+
@withSourceMap()
|
|
1168
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
1169
|
+
const { name, type, value, rules, expression, playground } = this;
|
|
1170
|
+
let code = '() => {';
|
|
1171
|
+
|
|
1172
|
+
if (['destination', 'externalDestination'].includes(name) && type === 'dynamic') {
|
|
1173
|
+
code += (this as any)[name].toNaturalTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1174
|
+
code += ';\n';
|
|
1175
|
+
} else if (name === 'rules') {
|
|
1176
|
+
rules?.forEach((item) => {
|
|
1177
|
+
code += item.toNaturalTS(shiftState(state, code));
|
|
1178
|
+
code += ';\n';
|
|
1179
|
+
});
|
|
1180
|
+
} else if (expression) {
|
|
1181
|
+
code += expression.toNaturalTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1182
|
+
code += ';\n';
|
|
1183
|
+
} else if (name === 'url' && value) {
|
|
1184
|
+
/**
|
|
1185
|
+
* ls定制化处理
|
|
1186
|
+
* url字符串处理成实体的引用,方便改名或者删除的时候查找引用
|
|
1187
|
+
* 因为这里只有字符串信息,所以在这里拼接成一个有引用的内容
|
|
1188
|
+
*/
|
|
1189
|
+
const names = /api\/(.+?)\/import/g.exec(value);
|
|
1190
|
+
if (names) {
|
|
1191
|
+
const dataSourceNameAndEntityName = names[1];
|
|
1192
|
+
let dataSourceName = '';
|
|
1193
|
+
let entityName = '';
|
|
1194
|
+
if (dataSourceNameAndEntityName.includes('/')) {
|
|
1195
|
+
const arr: string[] = dataSourceNameAndEntityName.split('/');
|
|
1196
|
+
dataSourceName = arr[0];
|
|
1197
|
+
entityName = arr[1];
|
|
1198
|
+
} else {
|
|
1199
|
+
entityName = dataSourceNameAndEntityName;
|
|
1200
|
+
}
|
|
1201
|
+
// 连接符转驼峰
|
|
1202
|
+
entityName = entityName.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
1203
|
+
entityName = entityName[0].toUpperCase() + entityName.substr(1);
|
|
1204
|
+
code += `app.dataSources.${dataSourceName || 'defaultDS'}.entities.${entityName}`;
|
|
1205
|
+
code += ';\n';
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (type === 'dynamic') {
|
|
1209
|
+
playground?.forEach((item) => {
|
|
1210
|
+
code += item.toNaturalTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1211
|
+
code += ';\n';
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
code += '}';
|
|
1216
|
+
return code;
|
|
1217
|
+
}
|
|
1159
1218
|
|
|
1160
1219
|
setUrlValue(newValue: string) {
|
|
1161
1220
|
const object = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
import MemberExpression from './MemberExpression__';
|
|
4
4
|
//================================================================================
|
|
@@ -583,7 +583,7 @@ export class BindDirective extends BaseNode {
|
|
|
583
583
|
}
|
|
584
584
|
|
|
585
585
|
@withSourceMap()
|
|
586
|
-
toEmbeddedTS(state
|
|
586
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
587
587
|
let code = '()=>{';
|
|
588
588
|
if (this.expression) {
|
|
589
589
|
code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
@@ -669,6 +669,64 @@ export class BindEvent extends BaseNode {
|
|
|
669
669
|
return code;
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
+
@withSourceMap()
|
|
673
|
+
toNaturalTS(state = createCompilerState(), isPageCycle?: Boolean): string {
|
|
674
|
+
// 如果有绑定的事件名
|
|
675
|
+
let code = ``;
|
|
676
|
+
if (isPageCycle) {
|
|
677
|
+
this.logics.forEach((logic, index) => {
|
|
678
|
+
const logicName = `viewLogic_${logic.name}${index}`;
|
|
679
|
+
// logic.name = logic.view.name + logic.name + index;
|
|
680
|
+
code += logic.toNaturalTS(shiftState(state, code, {
|
|
681
|
+
tabSize: state.tabSize,
|
|
682
|
+
}), 'noExport', logicName);
|
|
683
|
+
|
|
684
|
+
// logic.name = logicName;
|
|
685
|
+
// code += indent(state.tabSize);
|
|
686
|
+
// code += `${logicName}();\n`;
|
|
687
|
+
});
|
|
688
|
+
return code;
|
|
689
|
+
}
|
|
690
|
+
// code = `${this.toHump(this.name) || '__IDENTIFIER__'}: (event: `;
|
|
691
|
+
|
|
692
|
+
// event的类型
|
|
693
|
+
// code += this.getEventTypeString();
|
|
694
|
+
|
|
695
|
+
// code += ') => [\n';
|
|
696
|
+
this.logics.forEach((logic) => {
|
|
697
|
+
// 一些默认的逻辑不翻译 排除掉
|
|
698
|
+
if (logic.name.startsWith('__')) {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
if (logic.view) {
|
|
702
|
+
const logicName = logic.name;
|
|
703
|
+
logic.name = `on_${(logic.parentNode as BindEvent).element.name}_${logic.name}`;
|
|
704
|
+
// logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
|
|
705
|
+
logic.name = logic.name.replace(/-/g, '');
|
|
706
|
+
try {
|
|
707
|
+
code += logic.toNaturalTS(shiftState(state, code, {
|
|
708
|
+
tabSize: state.tabSize,
|
|
709
|
+
}), 'noExport');
|
|
710
|
+
} finally {
|
|
711
|
+
// 翻译logic可能出错
|
|
712
|
+
logic.name = logicName;
|
|
713
|
+
}
|
|
714
|
+
} else {
|
|
715
|
+
code += logic.toNaturalTS(shiftState(state, code, {
|
|
716
|
+
tabSize: state.tabSize,
|
|
717
|
+
}), 'noExport');
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
code += indent(state.tabSize);
|
|
721
|
+
// code += ',\n';
|
|
722
|
+
});
|
|
723
|
+
// if (this.view)
|
|
724
|
+
// code += '],\n';
|
|
725
|
+
// else
|
|
726
|
+
// code += ']\n';
|
|
727
|
+
return code;
|
|
728
|
+
}
|
|
729
|
+
|
|
672
730
|
getEventTypeString() {
|
|
673
731
|
let code = '';
|
|
674
732
|
if (!Object.keys(elementsEventsMap).length) return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
import MemberExpression from './MemberExpression__';
|
|
4
4
|
//================================================================================
|
|
@@ -482,7 +482,7 @@ export class BindStyle extends BaseNode {
|
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
@withSourceMap()
|
|
485
|
-
toEmbeddedTS(state
|
|
485
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
486
486
|
let code = '()=>{';
|
|
487
487
|
if (this.expression) {
|
|
488
488
|
code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
//================================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -69,10 +69,15 @@ export class BooleanLiteral extends LogicItem {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
@withSourceMap()
|
|
72
|
-
toEmbeddedTS(state
|
|
72
|
+
toEmbeddedTS(state = createCompilerState()) {
|
|
73
73
|
return `new nasl.core.Boolean(${this.value})`;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
@withSourceMap()
|
|
77
|
+
toNaturalTS(): string {
|
|
78
|
+
return this.value;
|
|
79
|
+
}
|
|
80
|
+
|
|
76
81
|
/**
|
|
77
82
|
* 设置布尔值内容
|
|
78
83
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Param from './Param__';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import { getNodeByNodeCallee } from '../automate/engine/utils.js';
|
|
4
4
|
import AuthLogicForCallInterface from './AuthLogicForCallInterface__';
|
|
5
5
|
import LogicItem from './LogicItem__';
|
|
@@ -328,7 +328,7 @@ export class CallAuthInterface extends CallInterface {
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
@withSourceMap()
|
|
331
|
-
toEmbeddedTS(state
|
|
331
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
332
332
|
let code = this.tsAuthLogicKey;
|
|
333
333
|
// 目前没有任何其他范型,故这里先支持默认俩范型
|
|
334
334
|
// FIXME
|
|
@@ -5,7 +5,7 @@ import Argument from './Argument__';
|
|
|
5
5
|
import Identifier from './Identifier__';
|
|
6
6
|
import TypeAnnotation from './TypeAnnotation__';
|
|
7
7
|
import Connection from './Connection__';
|
|
8
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
8
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
9
9
|
import Namespace from './Namespace__';
|
|
10
10
|
|
|
11
11
|
//================================================================================
|
|
@@ -201,7 +201,7 @@ export class CallConnector extends CallLogic {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
@withSourceMap()
|
|
204
|
-
toEmbeddedTS(state
|
|
204
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
205
205
|
let code = '';
|
|
206
206
|
if (this.handleError) {
|
|
207
207
|
code += 'nasl.util.autoHandleError(';
|