@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/concepts/View__.ts
CHANGED
|
@@ -1634,14 +1634,14 @@ export class View extends BaseNode {
|
|
|
1634
1634
|
definition.viewLogics.forEach((logicOption: any) => {
|
|
1635
1635
|
// 页面逻辑只有load函数的走之前的逻辑其余不用创建
|
|
1636
1636
|
if (logicOption.name.startsWith('load')) {
|
|
1637
|
-
const logic = Logic.from(
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
);
|
|
1644
|
-
this.addLogic(logic);
|
|
1637
|
+
// const logic = Logic.from(
|
|
1638
|
+
// {
|
|
1639
|
+
// ...logicOption,
|
|
1640
|
+
// },
|
|
1641
|
+
// this,
|
|
1642
|
+
// 'logics'
|
|
1643
|
+
// );
|
|
1644
|
+
// this.addLogic(logic);
|
|
1645
1645
|
}
|
|
1646
1646
|
});
|
|
1647
1647
|
}
|
|
@@ -1731,6 +1731,8 @@ export class View extends BaseNode {
|
|
|
1731
1731
|
* @TODO 这一版先做成 componentOptions 式的,后面再美化
|
|
1732
1732
|
*/
|
|
1733
1733
|
genScript() {
|
|
1734
|
+
const componentList: Array<ViewElement> = []
|
|
1735
|
+
this.elementsAttrs(this.elements, componentList)
|
|
1734
1736
|
const definition = {
|
|
1735
1737
|
params: this.params,
|
|
1736
1738
|
variables: this.variables,
|
|
@@ -1742,6 +1744,7 @@ export class View extends BaseNode {
|
|
|
1742
1744
|
auth: this.auth ? 'loginAuth' : undefined,
|
|
1743
1745
|
viewBindEvents: this.getViewBindEvents(),
|
|
1744
1746
|
viewExpressions: this.getViewExpressions(),
|
|
1747
|
+
elements: componentList,
|
|
1745
1748
|
};
|
|
1746
1749
|
let code = '';
|
|
1747
1750
|
let mixin = '';
|
|
@@ -1892,9 +1895,22 @@ export class View extends BaseNode {
|
|
|
1892
1895
|
});
|
|
1893
1896
|
}
|
|
1894
1897
|
}
|
|
1898
|
+
// 获取当前element,铺平
|
|
1899
|
+
elementsAttrs(elements: Array<ViewElement>, componentList: Array<ViewElement>) {
|
|
1900
|
+
if (elements) {
|
|
1901
|
+
elements.forEach((item: ViewElement) => {
|
|
1902
|
+
if (PAGE_COMPONENT_INCLUDE_TAG_MAP?.[item.tag]) {
|
|
1903
|
+
componentList.push(item)
|
|
1904
|
+
}
|
|
1905
|
+
if (item.children.length > 0) {
|
|
1906
|
+
this.elementsAttrs(item.children, componentList)
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1895
1911
|
|
|
1896
1912
|
@withSourceMap()
|
|
1897
|
-
toEmbeddedTS(state
|
|
1913
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
1898
1914
|
function chineseTsName(name: string) {
|
|
1899
1915
|
let tsName = name;
|
|
1900
1916
|
// 匹配所有特殊字符都转为_
|
|
@@ -2008,6 +2024,28 @@ export class View extends BaseNode {
|
|
|
2008
2024
|
});
|
|
2009
2025
|
code += `${indent((state?.tabSize || 0) + 1)}}\n`;
|
|
2010
2026
|
code += `let __elements: __elements;\n`;
|
|
2027
|
+
|
|
2028
|
+
if (Array.isArray(this.elements)) {
|
|
2029
|
+
code += indent((state?.tabSize || 0) + 1) + 'interface ';
|
|
2030
|
+
code += `__elements_completionProperty {\n`;
|
|
2031
|
+
const componentList: Array<ViewElement> = []
|
|
2032
|
+
this.elementsAttrs(this.elements, componentList)
|
|
2033
|
+
const variableList: string[] = []
|
|
2034
|
+
componentList.forEach((item) => {
|
|
2035
|
+
code += item.toEmbeddedTSVariableDefinition(shiftState(state, code, { inline: true }), variableList);
|
|
2036
|
+
code += ';\n';
|
|
2037
|
+
})
|
|
2038
|
+
code += indent((state?.tabSize || 0) + 1) + `}\n`;
|
|
2039
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
2040
|
+
code += `let __elements_completionProperty: __elements_completionProperty;\n`
|
|
2041
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
2042
|
+
code += `let __elements_stashFunctionVariable = {\n`;
|
|
2043
|
+
variableList.forEach((item) => {
|
|
2044
|
+
code += indent((state?.tabSize || 0) + 2);
|
|
2045
|
+
code += `${item}`
|
|
2046
|
+
})
|
|
2047
|
+
code += indent((state?.tabSize || 0) + 1) + `}\n`;
|
|
2048
|
+
}
|
|
2011
2049
|
// 逻辑
|
|
2012
2050
|
if (Array.isArray(this.logics) && this.logics.length) {
|
|
2013
2051
|
code += indent((state?.tabSize || 0) + 1);
|
|
@@ -2074,7 +2112,7 @@ export class View extends BaseNode {
|
|
|
2074
2112
|
}
|
|
2075
2113
|
|
|
2076
2114
|
@withSourceMap()
|
|
2077
|
-
toNaturalTS(state
|
|
2115
|
+
toNaturalTS(state = createCompilerState(), currentNode?: BaseNode): string {
|
|
2078
2116
|
let code = `export function ${this.tsName}_view`;
|
|
2079
2117
|
const advanceMap: Map<Variable, Assignment | BatchAssignment> = new Map();
|
|
2080
2118
|
this.traverseChildren((el) => {
|
|
@@ -2508,3 +2546,213 @@ export default View;
|
|
|
2508
2546
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
2509
2547
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
2510
2548
|
//= ===============================================================================
|
|
2549
|
+
type AttrObject = {
|
|
2550
|
+
value: string,
|
|
2551
|
+
label: string
|
|
2552
|
+
}
|
|
2553
|
+
export const PAGE_COMPONENT_INCLUDE_TAG_MAP: Record<string, Record<string, AttrObject>> = {
|
|
2554
|
+
'u-list-view': {
|
|
2555
|
+
'page-size': {
|
|
2556
|
+
value: 'size',
|
|
2557
|
+
label: '分页大小'
|
|
2558
|
+
},
|
|
2559
|
+
'page-number': {
|
|
2560
|
+
value: 'page',
|
|
2561
|
+
label: '当前页数'
|
|
2562
|
+
},
|
|
2563
|
+
'data-source': {
|
|
2564
|
+
value: 'data',
|
|
2565
|
+
label: '数据'
|
|
2566
|
+
},
|
|
2567
|
+
},
|
|
2568
|
+
'u-grid-view': {
|
|
2569
|
+
'page-size': {
|
|
2570
|
+
value: 'size',
|
|
2571
|
+
label: '分页大小'
|
|
2572
|
+
},
|
|
2573
|
+
'page-number': {
|
|
2574
|
+
value: 'page',
|
|
2575
|
+
label: '当前页数'
|
|
2576
|
+
},
|
|
2577
|
+
'data-source': {
|
|
2578
|
+
value: 'data',
|
|
2579
|
+
label: '数据'
|
|
2580
|
+
},
|
|
2581
|
+
},
|
|
2582
|
+
'u-list-components': {
|
|
2583
|
+
'data-source': {
|
|
2584
|
+
value: 'data',
|
|
2585
|
+
label: '数据'
|
|
2586
|
+
},
|
|
2587
|
+
},
|
|
2588
|
+
'u-table-view': {
|
|
2589
|
+
'page-size': {
|
|
2590
|
+
value: 'size',
|
|
2591
|
+
label: '分页大小'
|
|
2592
|
+
},
|
|
2593
|
+
'page-number': {
|
|
2594
|
+
value: 'page',
|
|
2595
|
+
label: '当前页数'
|
|
2596
|
+
},
|
|
2597
|
+
'sorting': {
|
|
2598
|
+
value: 'sort',
|
|
2599
|
+
label: '排序属性'
|
|
2600
|
+
},
|
|
2601
|
+
'value': {
|
|
2602
|
+
value: 'value',
|
|
2603
|
+
label: '单选选中值'
|
|
2604
|
+
},
|
|
2605
|
+
'values': {
|
|
2606
|
+
value: 'values',
|
|
2607
|
+
label: '多选选中值'
|
|
2608
|
+
},
|
|
2609
|
+
'data-source': {
|
|
2610
|
+
value: 'data',
|
|
2611
|
+
label: '数据'
|
|
2612
|
+
},
|
|
2613
|
+
},
|
|
2614
|
+
'u-radios': {
|
|
2615
|
+
'value': {
|
|
2616
|
+
value: 'value',
|
|
2617
|
+
label: '选中值'
|
|
2618
|
+
},
|
|
2619
|
+
'data-source': {
|
|
2620
|
+
value: 'data',
|
|
2621
|
+
label: '数据'
|
|
2622
|
+
},
|
|
2623
|
+
},
|
|
2624
|
+
'u-checkboxes': {
|
|
2625
|
+
'value': {
|
|
2626
|
+
value: 'value',
|
|
2627
|
+
label: '选中值'
|
|
2628
|
+
},
|
|
2629
|
+
'data-source': {
|
|
2630
|
+
value: 'data',
|
|
2631
|
+
label: '数据'
|
|
2632
|
+
},
|
|
2633
|
+
},
|
|
2634
|
+
'u-select': {
|
|
2635
|
+
'value': {
|
|
2636
|
+
value: 'value',
|
|
2637
|
+
label: '选中值'
|
|
2638
|
+
},
|
|
2639
|
+
'data-source': {
|
|
2640
|
+
value: 'data',
|
|
2641
|
+
label: '数据'
|
|
2642
|
+
},
|
|
2643
|
+
'opened': {
|
|
2644
|
+
value: 'opened',
|
|
2645
|
+
label: '弹出状态'
|
|
2646
|
+
},
|
|
2647
|
+
'page-size': {
|
|
2648
|
+
value: 'size',
|
|
2649
|
+
label: '分页大小'
|
|
2650
|
+
},
|
|
2651
|
+
'page-number': {
|
|
2652
|
+
value: 'page',
|
|
2653
|
+
label: '当前页数'
|
|
2654
|
+
},
|
|
2655
|
+
},
|
|
2656
|
+
'u-cascader': {
|
|
2657
|
+
'value': {
|
|
2658
|
+
value: 'value',
|
|
2659
|
+
label: '选中值'
|
|
2660
|
+
},
|
|
2661
|
+
'data-source': {
|
|
2662
|
+
value: 'data',
|
|
2663
|
+
label: '数据'
|
|
2664
|
+
},
|
|
2665
|
+
},
|
|
2666
|
+
'u-tree-select-new': {
|
|
2667
|
+
'value': {
|
|
2668
|
+
value: 'value',
|
|
2669
|
+
label: '选中值'
|
|
2670
|
+
},
|
|
2671
|
+
'data-source': {
|
|
2672
|
+
value: 'data',
|
|
2673
|
+
label: '数据'
|
|
2674
|
+
},
|
|
2675
|
+
},
|
|
2676
|
+
'van-radio-group': {
|
|
2677
|
+
'value': {
|
|
2678
|
+
value: 'value',
|
|
2679
|
+
label: '选中值'
|
|
2680
|
+
},
|
|
2681
|
+
'data-source': {
|
|
2682
|
+
value: 'data',
|
|
2683
|
+
label: '数据'
|
|
2684
|
+
},
|
|
2685
|
+
},
|
|
2686
|
+
'van-checkbox-group': {
|
|
2687
|
+
'value': {
|
|
2688
|
+
value: 'value',
|
|
2689
|
+
label: '选中值'
|
|
2690
|
+
},
|
|
2691
|
+
'data-source': {
|
|
2692
|
+
value: 'data',
|
|
2693
|
+
label: '数据'
|
|
2694
|
+
},
|
|
2695
|
+
},
|
|
2696
|
+
'van-pickerson': {
|
|
2697
|
+
'pvalue': {
|
|
2698
|
+
value: 'value',
|
|
2699
|
+
label: '选中值'
|
|
2700
|
+
},
|
|
2701
|
+
'data-source': {
|
|
2702
|
+
value: 'data',
|
|
2703
|
+
label: '数据'
|
|
2704
|
+
},
|
|
2705
|
+
'page-size': {
|
|
2706
|
+
value: 'size',
|
|
2707
|
+
label: '分页大小'
|
|
2708
|
+
},
|
|
2709
|
+
'page-number': {
|
|
2710
|
+
value: 'page',
|
|
2711
|
+
label: '当前页数'
|
|
2712
|
+
},
|
|
2713
|
+
},
|
|
2714
|
+
'van-cascader': {
|
|
2715
|
+
'value': {
|
|
2716
|
+
value: 'value',
|
|
2717
|
+
label: '选中值'
|
|
2718
|
+
},
|
|
2719
|
+
'data-source': {
|
|
2720
|
+
value: 'data',
|
|
2721
|
+
label: '数据'
|
|
2722
|
+
},
|
|
2723
|
+
},
|
|
2724
|
+
'van-list-view': {
|
|
2725
|
+
'page-size': {
|
|
2726
|
+
value: 'size',
|
|
2727
|
+
label: '分页大小'
|
|
2728
|
+
},
|
|
2729
|
+
'page-number': {
|
|
2730
|
+
value: 'page',
|
|
2731
|
+
label: '当前页数'
|
|
2732
|
+
},
|
|
2733
|
+
'data-source': {
|
|
2734
|
+
value: 'data',
|
|
2735
|
+
label: '数据'
|
|
2736
|
+
},
|
|
2737
|
+
},
|
|
2738
|
+
'van-grid-view': {
|
|
2739
|
+
'page-size': {
|
|
2740
|
+
value: 'size',
|
|
2741
|
+
label: '分页大小'
|
|
2742
|
+
},
|
|
2743
|
+
'page-number': {
|
|
2744
|
+
value: 'page',
|
|
2745
|
+
label: '当前页数'
|
|
2746
|
+
},
|
|
2747
|
+
'data-source': {
|
|
2748
|
+
value: 'data',
|
|
2749
|
+
label: '数据'
|
|
2750
|
+
},
|
|
2751
|
+
},
|
|
2752
|
+
'van-for-components': {
|
|
2753
|
+
'data-source': {
|
|
2754
|
+
value: 'data',
|
|
2755
|
+
label: '数据'
|
|
2756
|
+
},
|
|
2757
|
+
},
|
|
2758
|
+
}
|
|
@@ -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
|
//= ===============================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
5
5
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -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
|
|
@@ -291,7 +291,7 @@ export class WhileStatement extends LogicItem {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
@withSourceMap()
|
|
294
|
-
toNaturalTS(state
|
|
294
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
295
295
|
let code = '';
|
|
296
296
|
code += 'while (';
|
|
297
297
|
code += this.test ? this.test.toNaturalTS(shiftState(state, code, {
|
|
@@ -6,11 +6,13 @@ export default new Namespace({
|
|
|
6
6
|
logics: [
|
|
7
7
|
new Logic({
|
|
8
8
|
name: 'preventDefault',
|
|
9
|
+
description: '阻止浏览器默认行为',
|
|
9
10
|
params: [],
|
|
10
11
|
body: [],
|
|
11
12
|
}),
|
|
12
13
|
new Logic({
|
|
13
14
|
name: 'stopPropagation',
|
|
15
|
+
description: '阻止事件向上传递',
|
|
14
16
|
params: [],
|
|
15
17
|
body: [],
|
|
16
18
|
}),
|
|
@@ -291,7 +291,27 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
291
291
|
document.documentElement.style.setProperty('--scrollbar-size', 0);
|
|
292
292
|
// 移除 iframe 边框
|
|
293
293
|
iframe.style.border = 'none';
|
|
294
|
+
// 当 iframe 跳转到外部页面时,需要跳转到外部页面
|
|
295
|
+
window.addEventListener('message', function (e) {
|
|
296
|
+
if (e.data.type === 'iframe-to-diff-origin') {
|
|
297
|
+
window.location.href = e.data.href;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
294
300
|
return;
|
|
301
|
+
} else {
|
|
302
|
+
// 点击跳转到外部页面时,通知顶层页面
|
|
303
|
+
// 由于顶层刷新会再次触发 iframe 的 beforeunload,因此加上 pending 防止多次触发
|
|
304
|
+
let pending = false;
|
|
305
|
+
window.addEventListener('beforeunload', function (e) {
|
|
306
|
+
// activeElement 是当前点击的元素
|
|
307
|
+
const href = e.target.activeElement.href;
|
|
308
|
+
if (!href || pending) return;
|
|
309
|
+
pending = true;
|
|
310
|
+
window.parent.postMessage({
|
|
311
|
+
type: 'iframe-to-diff-origin',
|
|
312
|
+
href,
|
|
313
|
+
}, '*');
|
|
314
|
+
});
|
|
295
315
|
}
|
|
296
316
|
}`;
|
|
297
317
|
}
|
|
@@ -342,7 +362,76 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
342
362
|
|
|
343
363
|
return window.appVM = appVM;
|
|
344
364
|
};
|
|
345
|
-
window.createLcapApp()
|
|
365
|
+
window.createLcapApp();`
|
|
366
|
+
if(frontend.globalScaleEnabled) {
|
|
367
|
+
content += `
|
|
368
|
+
/**
|
|
369
|
+
* iframe 路由同步的几种情况:
|
|
370
|
+
* 1. 跳转时,iframe 同步到顶层
|
|
371
|
+
* 2. 回退时,顶层同步到 iframe,经测试,即便在 iframe 里调用 back 也会先触发顶层回退
|
|
372
|
+
* 3. 前进时,iframe 同步到顶层
|
|
373
|
+
* 原因:顶层永远在 iframe 后面
|
|
374
|
+
*/
|
|
375
|
+
// 自增ID,用于判断路由是否回退
|
|
376
|
+
let incrementID = 0;
|
|
377
|
+
// 当前历史ID,用于判断路由是否回退
|
|
378
|
+
let curHID = 0;
|
|
379
|
+
// 当前顶层历史ID,用于判断顶层路由是否回退
|
|
380
|
+
let curParentHID = 0;
|
|
381
|
+
// 是否是回退
|
|
382
|
+
let isBack = false;
|
|
383
|
+
// 是否是前进
|
|
384
|
+
let isForward = false;
|
|
385
|
+
appVM.$router.afterEach((to, from)=> {
|
|
386
|
+
if(isBack) {
|
|
387
|
+
// 重置回退状态
|
|
388
|
+
isBack = false;
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
// iframe 前进时,需要让顶层页面也前进
|
|
392
|
+
if(isForward) {
|
|
393
|
+
isForward = false;
|
|
394
|
+
window.parent.history.forward();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
// 自增ID,用于判断路由是否回退
|
|
398
|
+
incrementID++;
|
|
399
|
+
window.history.replaceState({HID: incrementID}, '');
|
|
400
|
+
// iframe 路由变化时,需要同步顶层页面的路由
|
|
401
|
+
window.parent.history.pushState({HID: incrementID}, '', to.fullPath);
|
|
402
|
+
// iframe 路由变化时,title 也要同步
|
|
403
|
+
window.parent.document.title = document.title;
|
|
404
|
+
// 更新当前历史ID
|
|
405
|
+
curHID = incrementID;
|
|
406
|
+
curParentHID = incrementID;
|
|
407
|
+
});
|
|
408
|
+
window.addEventListener('popstate', function (e) {
|
|
409
|
+
if(curHID > e.state?.HID){
|
|
410
|
+
isBack = true;
|
|
411
|
+
} else {
|
|
412
|
+
isForward = true;
|
|
413
|
+
}
|
|
414
|
+
// 更新当前历史ID
|
|
415
|
+
curHID = e.state?.HID || 0;
|
|
416
|
+
});
|
|
417
|
+
// 顶层页面路由回退时,需要同步 iframe 的路由
|
|
418
|
+
window.parent.addEventListener('popstate', function (e) {
|
|
419
|
+
if(curParentHID > e.state?.HID){
|
|
420
|
+
appVM.$router.back();
|
|
421
|
+
}
|
|
422
|
+
// 更新当前顶层历史ID
|
|
423
|
+
curParentHID = e.state?.HID || 0;
|
|
424
|
+
});
|
|
425
|
+
// 首次加载同步 title 和 shortcut icon
|
|
426
|
+
window.addEventListener('load', function() {
|
|
427
|
+
window.parent.document.title = document.title;
|
|
428
|
+
const shortcutIconLink = document.querySelector('link[rel="shortcut icon"]');
|
|
429
|
+
if(shortcutIconLink) parent.document.head.appendChild(shortcutIconLink);
|
|
430
|
+
});
|
|
431
|
+
`
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
content += `
|
|
346
435
|
})();`;
|
|
347
436
|
|
|
348
437
|
if (config.env === 'dev') {
|
|
@@ -410,6 +499,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
410
499
|
}\`
|
|
411
500
|
document.getElementsByTagName('body')[0].appendChild(style);
|
|
412
501
|
window.addEventListener('message', function (e) {
|
|
502
|
+
console.log('message:',e)
|
|
413
503
|
if(e.data ==="release-start"){
|
|
414
504
|
showLoading()
|
|
415
505
|
}
|
|
@@ -243,7 +243,7 @@ export async function genReleaseBody(app: App, releaseData: ReleaseData) {
|
|
|
243
243
|
logPublishFunc(`[语言] "[${app.title}]" 获取类型标注成功!`);
|
|
244
244
|
} catch (err) {
|
|
245
245
|
console.error(err);
|
|
246
|
-
throw new Error(
|
|
246
|
+
throw new Error(`代码标注失败,原因是:${err.message},请稍后重试!或刷新后重试!`);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// 可能所有的前端都不选
|
|
@@ -57,7 +57,7 @@ async function findViewLogicReferences(logic: Logic, vis: Set<Logic> = new Set()
|
|
|
57
57
|
|
|
58
58
|
async function dfs(usage: Usage) {
|
|
59
59
|
if (usage.node instanceof CallLogic) {
|
|
60
|
-
const
|
|
60
|
+
const logic = usage.node.logic;
|
|
61
61
|
if (!vis.has(logic) && logic) {
|
|
62
62
|
vis.add(logic);
|
|
63
63
|
await findViewLogicReferences(logic, vis);
|
|
@@ -208,7 +208,7 @@ function getAllLogics(app: App) {
|
|
|
208
208
|
|
|
209
209
|
if (Array.isArray(entities)) {
|
|
210
210
|
entities.forEach((entity) => {
|
|
211
|
-
const
|
|
211
|
+
const ns = entity.ns;
|
|
212
212
|
if (Array.isArray(ns?.logics)) {
|
|
213
213
|
allLogics.push(...ns.logics);
|
|
214
214
|
}
|
|
@@ -296,7 +296,7 @@ export async function genPermissionData(app: App) {
|
|
|
296
296
|
if (authValue?.length) {
|
|
297
297
|
authValue.forEach((item) => {
|
|
298
298
|
const { key, authValue } = item;
|
|
299
|
-
logicPageResourceDtoList[`${key}:POST`] = checkPageAndUploadAuth(uploaders, key) !== -1 ? [] : convertArray(authValue);
|
|
299
|
+
logicPageResourceDtoList[`${key}:POST`] = checkPageAndUploadAuth(uploaders, key) !== -1 ? [[]] : convertArray(authValue);
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
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';
|
|
@@ -14,8 +14,10 @@ export function genNaturalTS(app: App, currentNode?: BaseNode) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function genNaturalTSContext(app: App, currentNode?: BaseNode) {
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
let code = `### 低代码平台的 ts 定义如下:\n`;
|
|
18
19
|
/* 标准库 */
|
|
20
|
+
code += `\`\`\`ts\n`;
|
|
19
21
|
code += '// 标准库\n';
|
|
20
22
|
code += Object.values(naslStdlibMap).join('\n') + '\n';
|
|
21
23
|
/* 全局上下文 */
|
|
@@ -27,7 +29,7 @@ export function genNaturalTSContext(app: App, currentNode?: BaseNode) {
|
|
|
27
29
|
app.structures
|
|
28
30
|
.filter((entity) => !entity.name.startsWith('LCAP'))
|
|
29
31
|
.forEach((structure) => code += structure.toNaturalTS() + '\n');
|
|
30
|
-
code += '//
|
|
32
|
+
code += '// 全局变量\n';
|
|
31
33
|
const variables = app.frontends.flatMap((item) => item.variables).filter((item) => !!item);
|
|
32
34
|
variables.forEach((variable) => {
|
|
33
35
|
const state = createCompilerState();
|
|
@@ -66,12 +68,14 @@ export function genNaturalTSContext(app: App, currentNode?: BaseNode) {
|
|
|
66
68
|
logic = currentNode.getAncestor('Logic') as Logic;
|
|
67
69
|
}
|
|
68
70
|
// code += '// 页面上下文\n';
|
|
69
|
-
code +=
|
|
71
|
+
code += `\`\`\`\n`;
|
|
72
|
+
code += '### 当前逻辑的 ts 定义\n';
|
|
73
|
+
code += `\`\`\`ts\n`;
|
|
70
74
|
if (view) { // 为页面中的逻辑
|
|
71
75
|
code += view.toNaturalTS(undefined, currentNode);
|
|
72
76
|
} else if (logic) { // 为全局逻辑
|
|
73
77
|
code += logic.toNaturalTS(undefined);
|
|
74
78
|
}
|
|
75
|
-
|
|
79
|
+
code += `\`\`\`\n`;
|
|
76
80
|
return code;
|
|
77
81
|
}
|
|
@@ -4,24 +4,24 @@ const docsMap: any = {};
|
|
|
4
4
|
if (globalThis.process) { // For TS build
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
knowledgeMap = {
|
|
7
|
-
index: fs.readFileSync(require.resolve('../../docs-for-aigc/index.md'), 'utf8'),
|
|
8
|
-
'实体和实体属性、实体索引': fs.readFileSync(require.resolve('../../docs-for-aigc/实体和实体属性、实体索引.d.ts'), 'utf8'),
|
|
9
|
-
'应用和数据源、数据源和实体': fs.readFileSync(require.resolve('../../docs-for-aigc/应用和数据源、数据源和实体.d.ts'), 'utf8'),
|
|
10
|
-
类型标注: fs.readFileSync(require.resolve('../../docs-for-aigc/类型标注.d.ts'), 'utf8'),
|
|
11
|
-
页面: fs.readFileSync(require.resolve('../../docs-for-aigc/页面.d.ts'), 'utf8'),
|
|
12
|
-
逻辑: fs.readFileSync(require.resolve('../../docs-for-aigc/逻辑.d.ts'), 'utf8'),
|
|
7
|
+
// index: fs.readFileSync(require.resolve('../../docs-for-aigc/index.md'), 'utf8'),
|
|
8
|
+
// '实体和实体属性、实体索引': fs.readFileSync(require.resolve('../../docs-for-aigc/实体和实体属性、实体索引.d.ts'), 'utf8'),
|
|
9
|
+
// '应用和数据源、数据源和实体': fs.readFileSync(require.resolve('../../docs-for-aigc/应用和数据源、数据源和实体.d.ts'), 'utf8'),
|
|
10
|
+
// 类型标注: fs.readFileSync(require.resolve('../../docs-for-aigc/类型标注.d.ts'), 'utf8'),
|
|
11
|
+
// 页面: fs.readFileSync(require.resolve('../../docs-for-aigc/页面.d.ts'), 'utf8'),
|
|
12
|
+
// 逻辑: fs.readFileSync(require.resolve('../../docs-for-aigc/逻辑.d.ts'), 'utf8'),
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
/// #endif
|
|
16
16
|
/// #if process.env.BUILD_TARGET !== 'node'
|
|
17
17
|
if (globalThis.window) { // For TS build
|
|
18
18
|
knowledgeMap = {
|
|
19
|
-
index: require('!!raw-loader!../../docs-for-aigc/index.md').default,
|
|
20
|
-
'实体和实体属性、实体索引': require('!!raw-loader!../../docs-for-aigc/实体和实体属性、实体索引.d.ts').default,
|
|
21
|
-
'应用和数据源、数据源和实体': require('!!raw-loader!../../docs-for-aigc/应用和数据源、数据源和实体.d.ts').default,
|
|
22
|
-
类型标注: require('!!raw-loader!../../docs-for-aigc/类型标注.d.ts').default,
|
|
23
|
-
页面: require('!!raw-loader!../../docs-for-aigc/页面.d.ts').default,
|
|
24
|
-
逻辑: require('!!raw-loader!../../docs-for-aigc/逻辑.d.ts').default,
|
|
19
|
+
// index: require('!!raw-loader!../../docs-for-aigc/index.md').default,
|
|
20
|
+
// '实体和实体属性、实体索引': require('!!raw-loader!../../docs-for-aigc/实体和实体属性、实体索引.d.ts').default,
|
|
21
|
+
// '应用和数据源、数据源和实体': require('!!raw-loader!../../docs-for-aigc/应用和数据源、数据源和实体.d.ts').default,
|
|
22
|
+
// 类型标注: require('!!raw-loader!../../docs-for-aigc/类型标注.d.ts').default,
|
|
23
|
+
// 页面: require('!!raw-loader!../../docs-for-aigc/页面.d.ts').default,
|
|
24
|
+
// 逻辑: require('!!raw-loader!../../docs-for-aigc/逻辑.d.ts').default,
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
/// #endif
|