@lcap/nasl 3.3.0-beta.0 → 3.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/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 +27 -1
- 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 +38 -1
- 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 +3 -1
- package/out/concepts/CallInterface__.js +112 -17
- 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 +1 -1
- 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 +132 -20
- 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/Module__.d.ts +1 -0
- package/out/concepts/Module__.js +16 -0
- package/out/concepts/Module__.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/OverriddenLogic__.js +1 -1
- package/out/concepts/OverriddenLogic__.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 +74 -2
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +2 -0
- package/out/concepts/View__.js +106 -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/generator/permission.js +3 -1
- 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/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 +90 -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 +883 -0
- package/out/natural/transformTSCode.js.map +1 -0
- package/out/server/naslServer.d.ts +4 -4
- package/out/server/naslServer.js +98 -111
- 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/translator/utils.js +24 -28
- package/out/translator/utils.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 +28 -2
- 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 +38 -3
- 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 +113 -20
- 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 +1 -1
- 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 +149 -26
- package/src/concepts/MatchCase__.ts +90 -2
- package/src/concepts/Match__.ts +47 -3
- package/src/concepts/MemberExpression__.ts +19 -2
- package/src/concepts/Module__.ts +16 -0
- 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/OverriddenLogic__.ts +1 -1
- 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 +77 -4
- package/src/concepts/View__.ts +122 -8
- package/src/concepts/WhileStatement__.ts +25 -3
- package/src/generator/permission.ts +3 -1
- package/src/index.ts +1 -0
- package/src/natural/componentData.ts +81 -0
- package/src/natural/genNaturalTS.ts +90 -0
- package/src/natural/index.ts +2 -0
- package/src/natural/naslStdlibMap.ts +24 -0
- package/src/natural/transformTSCode.ts +840 -0
- package/src/server/naslServer.ts +95 -90
- package/src/service/storage/init.ts +17 -0
- package/src/translator/utils.ts +7 -9
- 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/view-element/__snapshots__/toVue.spec.ts.snap +66 -62
package/src/concepts/View__.ts
CHANGED
|
@@ -1531,6 +1531,22 @@ export class View extends BaseNode {
|
|
|
1531
1531
|
return viewElementUniqueName;
|
|
1532
1532
|
}
|
|
1533
1533
|
|
|
1534
|
+
getAllViewElementNames(excludeName: string) {
|
|
1535
|
+
const res: Array<string> = [];
|
|
1536
|
+
this.elements.forEach((element) => {
|
|
1537
|
+
utils.traverse(
|
|
1538
|
+
({ node }) => {
|
|
1539
|
+
if (node.name !== excludeName)
|
|
1540
|
+
res.push(node.name);
|
|
1541
|
+
},
|
|
1542
|
+
{
|
|
1543
|
+
node: element,
|
|
1544
|
+
},
|
|
1545
|
+
);
|
|
1546
|
+
});
|
|
1547
|
+
return Array.from(res);
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1534
1550
|
// 组件名是否有效
|
|
1535
1551
|
isValidElementName(name: string): boolean {
|
|
1536
1552
|
if (name) {
|
|
@@ -1765,15 +1781,15 @@ export class View extends BaseNode {
|
|
|
1765
1781
|
methods: {
|
|
1766
1782
|
async onKeyDown(e) {
|
|
1767
1783
|
${this.bindEvents
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1784
|
+
.filter((event) => ['keydown'].includes(event.name))
|
|
1785
|
+
.map((event) => `await this.${event.view.name}_${event.name}(e);`)
|
|
1786
|
+
.join('\n')}
|
|
1771
1787
|
},
|
|
1772
1788
|
async onKeyUp(e) {
|
|
1773
1789
|
${this.bindEvents
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1790
|
+
.filter((event) => ['keyup'].includes(event.name))
|
|
1791
|
+
.map((event) => `await this.${event.view.name}_${event.name}(e);`)
|
|
1792
|
+
.join('\n')}
|
|
1777
1793
|
}
|
|
1778
1794
|
}
|
|
1779
1795
|
};`;
|
|
@@ -1900,6 +1916,7 @@ export class View extends BaseNode {
|
|
|
1900
1916
|
});
|
|
1901
1917
|
}
|
|
1902
1918
|
}
|
|
1919
|
+
|
|
1903
1920
|
// 获取当前element,铺平
|
|
1904
1921
|
elementsAttrs(elements: Array<ViewElement>, componentList: Array<ViewElement>) {
|
|
1905
1922
|
if (elements) {
|
|
@@ -1915,7 +1932,7 @@ export class View extends BaseNode {
|
|
|
1915
1932
|
}
|
|
1916
1933
|
|
|
1917
1934
|
@withSourceMap()
|
|
1918
|
-
toEmbeddedTS(state
|
|
1935
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
1919
1936
|
function chineseTsName(name: string) {
|
|
1920
1937
|
let tsName = name;
|
|
1921
1938
|
// 匹配所有特殊字符都转为_
|
|
@@ -2039,7 +2056,7 @@ export class View extends BaseNode {
|
|
|
2039
2056
|
code += `let __elements: __elements;\n`;
|
|
2040
2057
|
|
|
2041
2058
|
if (Array.isArray(this.elements)) {
|
|
2042
|
-
code += indent((state?.tabSize || 0) + 1)
|
|
2059
|
+
code += `${indent((state?.tabSize || 0) + 1) }interface `;
|
|
2043
2060
|
code += `__elements_completionProperty {\n`;
|
|
2044
2061
|
const componentList: Array<ViewElement> = [];
|
|
2045
2062
|
this.elementsAttrs(this.elements, componentList);
|
|
@@ -2131,6 +2148,103 @@ export class View extends BaseNode {
|
|
|
2131
2148
|
return code;
|
|
2132
2149
|
}
|
|
2133
2150
|
|
|
2151
|
+
@withSourceMap()
|
|
2152
|
+
toNaturalTS(state = createCompilerState(), currentNode?: BaseNode, declaration?: boolean): string {
|
|
2153
|
+
// const isCurrentInThisView = currentNode?.getAncestor('View') === this;
|
|
2154
|
+
|
|
2155
|
+
if (declaration) {
|
|
2156
|
+
let code = `
|
|
2157
|
+
${indent(state.tabSize)}export function ${this.tsName}_view`;
|
|
2158
|
+
// 有参数长度
|
|
2159
|
+
code += '(';
|
|
2160
|
+
this.params.forEach((param, index) => {
|
|
2161
|
+
code += param.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
2162
|
+
if (index !== this.params.length - 1)
|
|
2163
|
+
code += ', ';
|
|
2164
|
+
});
|
|
2165
|
+
code += ') {';
|
|
2166
|
+
this.children.forEach((child, index) => {
|
|
2167
|
+
code += child.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }), currentNode, declaration);
|
|
2168
|
+
});
|
|
2169
|
+
code += `${indent(state.tabSize)}}`;
|
|
2170
|
+
return code;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
let code = `${indent(state.tabSize)}/**
|
|
2174
|
+
${indent(state.tabSize)} * 当前页面
|
|
2175
|
+
${indent(state.tabSize)} */
|
|
2176
|
+
${indent(state.tabSize)}export function ${this.tsName}_view`;
|
|
2177
|
+
const advanceMap: Map<Variable, Assignment | BatchAssignment> = new Map();
|
|
2178
|
+
this.traverseChildren((el) => {
|
|
2179
|
+
if (el && (el instanceof BatchAssignment || (el instanceof Assignment && el.left?.name))) {
|
|
2180
|
+
// 子页面内部逻辑过滤
|
|
2181
|
+
if (el.view !== this)
|
|
2182
|
+
return;
|
|
2183
|
+
const jsCode = el.toJS();
|
|
2184
|
+
const advanceVar = this.variables?.find((variable) =>
|
|
2185
|
+
!variable.typeAnnotation && jsCode.includes(`this.${variable.name} = `));
|
|
2186
|
+
if (advanceVar && !advanceMap.get(advanceVar)) {
|
|
2187
|
+
advanceMap.set(advanceVar, el);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
|
|
2192
|
+
// 有参数长度
|
|
2193
|
+
code += '(';
|
|
2194
|
+
this.params.forEach((param, index) => {
|
|
2195
|
+
code += param.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
2196
|
+
if (index !== this.params.length - 1)
|
|
2197
|
+
code += ', ';
|
|
2198
|
+
});
|
|
2199
|
+
code += ')';
|
|
2200
|
+
|
|
2201
|
+
code += ' {\n';
|
|
2202
|
+
|
|
2203
|
+
this.variables.forEach((variable) => {
|
|
2204
|
+
if (!advanceMap.get(variable)) {
|
|
2205
|
+
code += `${indent(state.tabSize + 1)}let `;
|
|
2206
|
+
code += variable.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
2207
|
+
code += ';\n';
|
|
2208
|
+
}
|
|
2209
|
+
});
|
|
2210
|
+
code += `\n${indent(state.tabSize + 1)}const $refs = {\n`;
|
|
2211
|
+
// 生成所有的name和类型定义
|
|
2212
|
+
this.elements.forEach((element) => {
|
|
2213
|
+
code += element.toNaturalTSDefinition(shiftState(state, code, {
|
|
2214
|
+
tabSize: state.tabSize + 1,
|
|
2215
|
+
}));
|
|
2216
|
+
});
|
|
2217
|
+
code += `${indent(state.tabSize + 1)}}\n`;
|
|
2218
|
+
// 逻辑
|
|
2219
|
+
if (currentNode?.concept === 'Logic') {
|
|
2220
|
+
code += '\n';
|
|
2221
|
+
this.logics.forEach((logic) => {
|
|
2222
|
+
if (logic === currentNode)
|
|
2223
|
+
return;
|
|
2224
|
+
code += logic.toNaturalTS(shiftState(state, code, {
|
|
2225
|
+
tabSize: state.tabSize + 1,
|
|
2226
|
+
}), 'noExport', undefined, currentNode);
|
|
2227
|
+
code += '\n';
|
|
2228
|
+
});
|
|
2229
|
+
// 包含了事件逻辑的处理
|
|
2230
|
+
code += (currentNode as Logic).toNaturalTS(shiftState(state, code, {
|
|
2231
|
+
tabSize: state.tabSize + 1,
|
|
2232
|
+
}), 'noExport', undefined, currentNode);
|
|
2233
|
+
code += '\n';
|
|
2234
|
+
} else if (this.logics.length) {
|
|
2235
|
+
code += '\n';
|
|
2236
|
+
this.logics.forEach((logic) => {
|
|
2237
|
+
code += logic.toNaturalTS(shiftState(state, code, {
|
|
2238
|
+
tabSize: state.tabSize + 1,
|
|
2239
|
+
}), 'noExport', undefined, currentNode);
|
|
2240
|
+
code += '\n';
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
code += `${indent(state.tabSize)}}\n`;
|
|
2244
|
+
|
|
2245
|
+
return code;
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2134
2248
|
toEmbeddedTSFile() {
|
|
2135
2249
|
let code = `namespace ${this.getTsNamespace()} {\n`;
|
|
2136
2250
|
const state = createCompilerState(code, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
2
2
|
//================================================================================
|
|
3
3
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
4
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -264,7 +264,7 @@ export class WhileStatement extends LogicItem {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
@withSourceMap()
|
|
267
|
-
toEmbeddedTS(state
|
|
267
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
268
268
|
let code = '';
|
|
269
269
|
code += 'while (nasl.core.ensureBoolean(';
|
|
270
270
|
code += this.test
|
|
@@ -289,7 +289,29 @@ export class WhileStatement extends LogicItem {
|
|
|
289
289
|
code += `${indent(state?.tabSize || 0)}}\n`;
|
|
290
290
|
return code;
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
|
|
293
|
+
@withSourceMap()
|
|
294
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
295
|
+
let code = '';
|
|
296
|
+
code += 'while (';
|
|
297
|
+
code += this.test ? this.test.toNaturalTS(shiftState(state, code, {
|
|
298
|
+
tabSize: 0,
|
|
299
|
+
})) : '__IDENTIFIER__';
|
|
300
|
+
code += ') {\n';
|
|
301
|
+
|
|
302
|
+
if (Array.isArray(this.body)) {
|
|
303
|
+
this.body.forEach((logicItem) => {
|
|
304
|
+
code += `${logicItem.toNaturalTS(shiftState(state, code, {
|
|
305
|
+
tabSize: state.tabSize + 1,
|
|
306
|
+
}))};\n`;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
code += `${indent(state.tabSize)}}\n`;
|
|
311
|
+
return code;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
//= ===============================================================================
|
|
293
315
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
294
316
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
295
317
|
//================================================================================
|
|
@@ -296,7 +296,9 @@ export async function genPermissionData(app: App) {
|
|
|
296
296
|
if (authValue?.length) {
|
|
297
297
|
authValue.forEach((item) => {
|
|
298
298
|
const { key, authValue } = item;
|
|
299
|
-
|
|
299
|
+
if (key.startsWith('/upload' || '/api/')) {
|
|
300
|
+
logicPageResourceDtoList[`${key}:POST`] = checkPageAndUploadAuth(uploaders, key) !== -1 ? [[]] : convertArray(authValue);
|
|
301
|
+
}
|
|
300
302
|
});
|
|
301
303
|
}
|
|
302
304
|
closeCache();
|
package/src/index.ts
CHANGED
|
@@ -10,3 +10,4 @@ export * from './eventBus';
|
|
|
10
10
|
export * as breakpoint from './breakpoint';
|
|
11
11
|
export { loadApp, loadAppSync, handleApp, batchAction, batchQuery, mountDatabaseTypes } from './service/storage/init';
|
|
12
12
|
export { createService } from './service/creator';
|
|
13
|
+
export * from './natural';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const componentData = [
|
|
2
|
+
{
|
|
3
|
+
name: 'u-tabs',
|
|
4
|
+
title: '选项卡',
|
|
5
|
+
description: '选项卡切换组件,常用于平级区域大块内容的收纳和展现。',
|
|
6
|
+
template: {
|
|
7
|
+
0: '基本用法',
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: 'i-ico',
|
|
12
|
+
title: '图标',
|
|
13
|
+
description: '仅图标或图标及文本',
|
|
14
|
+
template: {
|
|
15
|
+
0: '组合图标-上下',
|
|
16
|
+
1: '组合图标-左右',
|
|
17
|
+
2: '组合图标-仅图标',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'u-button',
|
|
22
|
+
title: '按钮',
|
|
23
|
+
description: '用于触发一个即时操作。',
|
|
24
|
+
template: {
|
|
25
|
+
0: '主要按钮',
|
|
26
|
+
// 1: '次要按钮',
|
|
27
|
+
// 2: '普通按钮',
|
|
28
|
+
3: '图标按钮',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'u-list-view',
|
|
33
|
+
title: '数据列表',
|
|
34
|
+
description: '用于列举大量数据的列表框,支持单选、多选、过滤(搜索)、分页等功能。',
|
|
35
|
+
template: {
|
|
36
|
+
0: '基本用法',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'u-modal',
|
|
41
|
+
title: '弹窗',
|
|
42
|
+
description: '弹窗',
|
|
43
|
+
template: {
|
|
44
|
+
0: '基本用法',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'u-rate',
|
|
49
|
+
title: '评分',
|
|
50
|
+
description: '评分组件。',
|
|
51
|
+
template: {
|
|
52
|
+
0: '基本用法',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'u-label',
|
|
57
|
+
title: '标签',
|
|
58
|
+
description: '用于展示状态、标签、分类等',
|
|
59
|
+
template: {
|
|
60
|
+
0: '基本用法',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'u-card',
|
|
65
|
+
title: '卡片',
|
|
66
|
+
description: '用于快速布局,单个组件的显示',
|
|
67
|
+
template: {
|
|
68
|
+
0: '基本样式',
|
|
69
|
+
1: '带分割线样式',
|
|
70
|
+
2: '带图片样式',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'u-grid-view',
|
|
75
|
+
title: '数据网格',
|
|
76
|
+
description: '用于列举大量数据的列表框,支持单选、多选、过滤(搜索)、分页等功能。内部可添加卡片等用于展示的组件',
|
|
77
|
+
template: {
|
|
78
|
+
0: '基本数据网格',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { App, View, Logic, BaseNode, Frontend } from '../concepts';
|
|
2
|
+
import { shiftState, createCompilerState } from '../translator';
|
|
3
|
+
|
|
4
|
+
import naslStdlibMap from './naslStdlibMap';
|
|
5
|
+
|
|
6
|
+
export function genNaturalTS(app: App, currentNode?: BaseNode) {
|
|
7
|
+
const logic = currentNode as Logic;
|
|
8
|
+
const code = logic?.toNaturalTS(undefined);
|
|
9
|
+
return code;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function genNaturalTSContext(app: App, currentNode?: BaseNode) {
|
|
13
|
+
let code = `### 低代码应用的 ts 上下文定义如下:\n`;
|
|
14
|
+
/* 标准库 */
|
|
15
|
+
code += `\`\`\`ts\n`;
|
|
16
|
+
code += '// 标准库\n';
|
|
17
|
+
code += `${Object.values(naslStdlibMap).join('\n')}\n`;
|
|
18
|
+
/* 全局上下文 */
|
|
19
|
+
code += '\n// 全局上下文\n';
|
|
20
|
+
app.enums.forEach((enumeration) => code += `${enumeration?.toNaturalTS()}\n`);
|
|
21
|
+
app.dataSources.forEach((dataSource) => dataSource.entities
|
|
22
|
+
.filter((entity) => !entity.name.startsWith('LCAP') || entity.name === 'LCAPUser')
|
|
23
|
+
.forEach((entity) => code += `${entity?.toNaturalTS()}\n`));
|
|
24
|
+
app.structures
|
|
25
|
+
.filter((entity) => !entity.name.startsWith('LCAP'))
|
|
26
|
+
.forEach((structure) => code += `${structure?.toNaturalTS()}\n`);
|
|
27
|
+
|
|
28
|
+
code += '\n// 服务端逻辑\n';
|
|
29
|
+
app?.logics
|
|
30
|
+
?.filter((logic) => logic !== currentNode && !logic.name.startsWith('LCAP'))
|
|
31
|
+
?.forEach((logic) => code += `${logic?.toNaturalTS(undefined, undefined, undefined, currentNode)}`);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const frontend = currentNode?.getAncestor('Frontend') as Frontend;
|
|
35
|
+
if (frontend) {
|
|
36
|
+
code += '\n// 前端全局变量\n';
|
|
37
|
+
frontend?.variables?.forEach((variable) => {
|
|
38
|
+
const state = createCompilerState();
|
|
39
|
+
code += 'let ';
|
|
40
|
+
code += variable?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
41
|
+
code += ';\n';
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
code += '\n// 前端页面\n';
|
|
45
|
+
frontend?.views?.forEach((view) => {
|
|
46
|
+
code += view?.toNaturalTS(undefined, currentNode, true);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* 页面上下文 */
|
|
51
|
+
let view: View;
|
|
52
|
+
if (currentNode?.concept === 'View') {
|
|
53
|
+
view = currentNode as View;
|
|
54
|
+
} else if (currentNode) {
|
|
55
|
+
if (!currentNode.getAncestor) {
|
|
56
|
+
console.log(currentNode.concept, currentNode.parentNode?.concept);
|
|
57
|
+
}
|
|
58
|
+
view = currentNode.getAncestor('View') as View;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (currentNode?.concept === 'ViewElement') {
|
|
62
|
+
code += '\n// 页面变量\n';
|
|
63
|
+
view.variables.forEach((variable) => {
|
|
64
|
+
const state = createCompilerState();
|
|
65
|
+
code += 'let ';
|
|
66
|
+
code += variable?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
67
|
+
code += ';\n';
|
|
68
|
+
});
|
|
69
|
+
code += 'let current.item.supplier: Supplier; \n';
|
|
70
|
+
code += '\n';
|
|
71
|
+
return code;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* 逻辑上下文 */
|
|
75
|
+
let logic: Logic;
|
|
76
|
+
if (currentNode?.concept === 'Logic')
|
|
77
|
+
logic = currentNode as Logic;
|
|
78
|
+
else if (currentNode) {
|
|
79
|
+
logic = currentNode.getAncestor('Logic') as Logic;
|
|
80
|
+
}
|
|
81
|
+
// code += '// 页面上下文\n';
|
|
82
|
+
code += ``;
|
|
83
|
+
if (view) { // 为页面中的逻辑
|
|
84
|
+
code += view?.toNaturalTS(undefined, currentNode);
|
|
85
|
+
} else if (logic) { // 为全局逻辑
|
|
86
|
+
code += logic?.toNaturalTS(undefined, undefined, undefined, currentNode);
|
|
87
|
+
}
|
|
88
|
+
code += `\n\`\`\`\n`;
|
|
89
|
+
return code;
|
|
90
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
let naslStdlibMap: any;
|
|
2
|
+
/// #if process.env.BUILD_TARGET === 'node'
|
|
3
|
+
if (globalThis.process) { // For TS build
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
naslStdlibMap = {
|
|
6
|
+
'nasl.core.ts': fs.readFileSync(require.resolve('../../sandbox-natural/stdlib/nasl.core.ts'), 'utf8'),
|
|
7
|
+
'nasl.util.ts': fs.readFileSync(require.resolve('../../sandbox-natural/stdlib/nasl.util.ts'), 'utf8'),
|
|
8
|
+
'nasl.oql.ts': fs.readFileSync(require.resolve('../../sandbox-natural/stdlib/nasl.oql.ts'), 'utf8'),
|
|
9
|
+
'nasl.ui.ts': fs.readFileSync(require.resolve('../../sandbox-natural/stdlib/nasl.ui.ts'), 'utf8'),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/// #endif
|
|
13
|
+
/// #if process.env.BUILD_TARGET !== 'node'
|
|
14
|
+
if (globalThis.window) { // For TS build
|
|
15
|
+
naslStdlibMap = {
|
|
16
|
+
'nasl.core.ts': require('!!raw-loader!../../sandbox-natural/stdlib/nasl.core.ts').default,
|
|
17
|
+
'nasl.util.ts': require('!!raw-loader!../../sandbox-natural/stdlib/nasl.util.ts').default,
|
|
18
|
+
'nasl.oql.ts': require('!!raw-loader!../../sandbox-natural/stdlib/nasl.oql.ts').default,
|
|
19
|
+
'nasl.ui.ts': require('!!raw-loader!../../sandbox-natural/stdlib/nasl.ui.ts').default,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/// #endif
|
|
23
|
+
|
|
24
|
+
export default naslStdlibMap;
|