@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataTypesMap } from './basics/types';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
3
3
|
import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
|
|
4
4
|
//================================================================================
|
|
5
5
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -257,7 +257,7 @@ export class StructureProperty extends BaseNode {
|
|
|
257
257
|
isLeaf: boolean = true;
|
|
258
258
|
|
|
259
259
|
@withSourceMap()
|
|
260
|
-
toEmbeddedTS(state
|
|
260
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
261
261
|
let code = this.name;
|
|
262
262
|
if (this.typeAnnotation) {
|
|
263
263
|
code += ': ';
|
|
@@ -270,6 +270,16 @@ export class StructureProperty extends BaseNode {
|
|
|
270
270
|
return code;
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
+
@withSourceMap()
|
|
274
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
275
|
+
let code = this.name;
|
|
276
|
+
if (this.typeAnnotation) {
|
|
277
|
+
code += ': ';
|
|
278
|
+
code += this.typeAnnotation.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
279
|
+
}
|
|
280
|
+
return code;
|
|
281
|
+
}
|
|
282
|
+
|
|
273
283
|
/**
|
|
274
284
|
* 设置数据类型
|
|
275
285
|
* @param typeAnnotation 类型标注对象
|
|
@@ -312,11 +322,18 @@ export class StructureProperty extends BaseNode {
|
|
|
312
322
|
};
|
|
313
323
|
}
|
|
314
324
|
|
|
325
|
+
/**
|
|
326
|
+
* 是否为连接器,连接器不允许编辑
|
|
327
|
+
*/
|
|
328
|
+
get isConnector() {
|
|
329
|
+
return !!this.getAncestor('Connector');
|
|
330
|
+
}
|
|
331
|
+
|
|
315
332
|
/**
|
|
316
333
|
* 是否可编辑
|
|
317
334
|
* */
|
|
318
335
|
get readonly() {
|
|
319
|
-
return !!this.module || (this.parentNode as Structure).origin === 'CallQueryComponent';
|
|
336
|
+
return !!this.module || (this.parentNode as Structure).origin === 'CallQueryComponent' || this.isConnector;
|
|
320
337
|
}
|
|
321
338
|
|
|
322
339
|
//================================================================================
|
|
@@ -535,11 +535,18 @@ export class Structure extends BaseNode {
|
|
|
535
535
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
536
536
|
//================================================================================
|
|
537
537
|
|
|
538
|
+
/**
|
|
539
|
+
* 是否为连接器,连接器不允许编辑
|
|
540
|
+
*/
|
|
541
|
+
get isConnector() {
|
|
542
|
+
return !!this.getAncestor('Connector');
|
|
543
|
+
}
|
|
544
|
+
|
|
538
545
|
/**
|
|
539
546
|
* 是否可编辑
|
|
540
547
|
* */
|
|
541
548
|
get readonly() {
|
|
542
|
-
return !!this.module || this.origin === 'CallQueryComponent';
|
|
549
|
+
return !!this.module || this.origin === 'CallQueryComponent' || this.isConnector;
|
|
543
550
|
}
|
|
544
551
|
|
|
545
552
|
/* 删除空数据模块 */
|
|
@@ -551,7 +558,7 @@ export class Structure extends BaseNode {
|
|
|
551
558
|
}
|
|
552
559
|
|
|
553
560
|
@withSourceMap()
|
|
554
|
-
toEmbeddedTS(state
|
|
561
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
555
562
|
let code = `export class ${this.tsName} {\n`;
|
|
556
563
|
code += indent((state?.tabSize || 0) + 1);
|
|
557
564
|
code += `__name: '${this.getTsNamespace()}.${this.tsName}';\n`;
|
|
@@ -565,6 +572,19 @@ export class Structure extends BaseNode {
|
|
|
565
572
|
return code;
|
|
566
573
|
}
|
|
567
574
|
|
|
575
|
+
@withSourceMap()
|
|
576
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
577
|
+
let code = `class ${this.name} {\n`;
|
|
578
|
+
// code += `${indent(state.tabSize + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
579
|
+
this.properties.forEach((property) => {
|
|
580
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
581
|
+
code += property.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
|
|
582
|
+
code += ';\n';
|
|
583
|
+
});
|
|
584
|
+
code += `${indent(state?.tabSize || 0)}}\n`;
|
|
585
|
+
return code;
|
|
586
|
+
}
|
|
587
|
+
|
|
568
588
|
getNamespace() {
|
|
569
589
|
// 针对 Connector 下的 Interface 需要做额外的兼容处理
|
|
570
590
|
// 本来 Connector 对应的 Namespace 是 connector,走默认逻辑就成
|
|
@@ -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
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -313,7 +313,40 @@ export class SwitchCase extends LogicItem {
|
|
|
313
313
|
return code;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
@withSourceMap()
|
|
317
|
+
toNaturalTS(state = createCompilerState(), isLast?: boolean, isFirst?: boolean): string {
|
|
318
|
+
let code = '\n';
|
|
319
|
+
if (!isLast) {
|
|
320
|
+
code += indent(state.tabSize + 2);
|
|
321
|
+
code += isFirst ? '' : 'else ';
|
|
322
|
+
code += 'if (';
|
|
323
|
+
code += this.test ? this.test.toNaturalTS(shiftState(state, code, { inline: true })) : '__IDENTIFIER__';
|
|
324
|
+
code += ') {\n';
|
|
325
|
+
if (Array.isArray(this.consequent)) {
|
|
326
|
+
this.consequent.forEach((logicItem) => {
|
|
327
|
+
code += indent(state.tabSize + 3);
|
|
328
|
+
code += `${logicItem.toNaturalTS(shiftState(state, code, { inline: true }))}\n`;
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
code += indent(state.tabSize + 2);
|
|
332
|
+
code += '}';
|
|
333
|
+
} else {
|
|
334
|
+
code += indent(state.tabSize + 2);
|
|
335
|
+
code += 'else {\n';
|
|
336
|
+
if (Array.isArray(this.consequent)) {
|
|
337
|
+
this.consequent.forEach((logicItem) => {
|
|
338
|
+
code += indent(state.tabSize + 2);
|
|
339
|
+
code += `${logicItem.toNaturalTS(shiftState(state, code, { inline: true }))}\n`;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
code += indent(state.tabSize + 2);
|
|
343
|
+
code += '}';
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return code;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
//= ===============================================================================
|
|
317
350
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
318
351
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
319
352
|
//================================================================================
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
|
|
3
3
|
//================================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -221,7 +221,7 @@ export class SwitchStatement extends LogicItem {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
@withSourceMap()
|
|
224
|
-
toEmbeddedTS(state
|
|
224
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
225
225
|
let code = '';
|
|
226
226
|
// 最后一项是else
|
|
227
227
|
this.cases.forEach((item, index) => {
|
|
@@ -234,7 +234,24 @@ export class SwitchStatement extends LogicItem {
|
|
|
234
234
|
});
|
|
235
235
|
return code;
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
|
|
238
|
+
@withSourceMap()
|
|
239
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
240
|
+
let code = '';
|
|
241
|
+
// 最后一项是else
|
|
242
|
+
this.cases.forEach((item, index) => {
|
|
243
|
+
// 如果是最后一项
|
|
244
|
+
if (index === this.cases.length - 1) {
|
|
245
|
+
code += item.toNaturalTS(shiftState(state, code, { inline: true }), true);
|
|
246
|
+
} else {
|
|
247
|
+
code += item.toNaturalTS(shiftState(state, code, { inline: true }), false, index === 0);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
code += '\n';
|
|
251
|
+
return code;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//= ===============================================================================
|
|
238
255
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
239
256
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
240
257
|
//================================================================================
|
|
@@ -152,7 +152,7 @@ export class TriggerLauncher extends BaseNode {
|
|
|
152
152
|
//================================================================================
|
|
153
153
|
|
|
154
154
|
@withSourceMap()
|
|
155
|
-
toEmbeddedTS(state
|
|
155
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
156
156
|
let code = '';
|
|
157
157
|
code += `export function ${this.name} () {\n`;
|
|
158
158
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import App from './App__';
|
|
2
2
|
import Structure from './Structure__';
|
|
3
|
-
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
3
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
|
|
4
4
|
import { genHash } from '../generator';
|
|
5
5
|
import { firstUpperCase } from '../utils/string';
|
|
6
6
|
|
|
@@ -925,7 +925,7 @@ export class TypeAnnotation extends BaseNode {
|
|
|
925
925
|
}
|
|
926
926
|
|
|
927
927
|
@withSourceMap()
|
|
928
|
-
toEmbeddedTS(state
|
|
928
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
929
929
|
if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
|
|
930
930
|
if (this.typeKind === 'reference' && this.typeNamespace && this.typeNamespace.endsWith('enums')) {
|
|
931
931
|
return `${this.tsCalleeNamespace}.${this.typeName}`;
|
|
@@ -973,6 +973,51 @@ export class TypeAnnotation extends BaseNode {
|
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
975
|
|
|
976
|
+
@withSourceMap()
|
|
977
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
978
|
+
if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
|
|
979
|
+
if (this.typeKind === 'reference' && this.typeNamespace && this.typeNamespace.endsWith('enums')) {
|
|
980
|
+
return this.tsCalleeNamespace.startsWith('nasl.ui') ? `${this.tsCalleeNamespace}.${this.typeName}` : `${this.typeName}`;
|
|
981
|
+
}
|
|
982
|
+
return this.tsCalleeNamespace.startsWith('nasl.ui') ? `${this.tsCalleeNamespace}.${this.typeName}` : `${this.typeName}`;
|
|
983
|
+
}
|
|
984
|
+
if (this.typeKind === 'generic') {
|
|
985
|
+
let code = `${this.typeName}<`;
|
|
986
|
+
(this.typeArguments || []).forEach((arg, index) => {
|
|
987
|
+
code += arg.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
988
|
+
if (index !== this.typeArguments.length - 1)
|
|
989
|
+
code += ', ';
|
|
990
|
+
});
|
|
991
|
+
code += '>';
|
|
992
|
+
return code;
|
|
993
|
+
}
|
|
994
|
+
if (this.typeKind === 'union') {
|
|
995
|
+
let code = '';
|
|
996
|
+
(this.typeArguments || []).forEach((arg, index) => {
|
|
997
|
+
code += arg.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
998
|
+
if (index !== this.typeArguments.length - 1)
|
|
999
|
+
code += ' | ';
|
|
1000
|
+
});
|
|
1001
|
+
return code;
|
|
1002
|
+
}
|
|
1003
|
+
if (this.typeKind === 'anonymousStructure') {
|
|
1004
|
+
let code = `{ `;
|
|
1005
|
+
(this.properties || []).forEach((property, i) => {
|
|
1006
|
+
code += `${property.name}: `;
|
|
1007
|
+
code += `${property.typeAnnotation.toNaturalTS(shiftState(state, code, { inline: true, tabSize: state.tabSize + 1 }))}`;
|
|
1008
|
+
code += i < this.properties?.length - 1 ? ', ' : ' }';
|
|
1009
|
+
});
|
|
1010
|
+
return code;
|
|
1011
|
+
}
|
|
1012
|
+
if (this.tsCalleeNamespace && this.typeName) {
|
|
1013
|
+
return `${this.typeName}`;
|
|
1014
|
+
}
|
|
1015
|
+
if (this.typeName) {
|
|
1016
|
+
return this.typeName;
|
|
1017
|
+
}
|
|
1018
|
+
return '__IDENTIFIER__';
|
|
1019
|
+
}
|
|
1020
|
+
|
|
976
1021
|
/**
|
|
977
1022
|
* 用于标准化数据结构,便于计算 anonymousStructure 的 __name
|
|
978
1023
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
|
|
3
3
|
//================================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -59,7 +59,13 @@ export class TypeParam extends BaseNode {
|
|
|
59
59
|
toEmbeddedTS(state?: TranslatorState, prefix?: string): string {
|
|
60
60
|
return this.name;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
@withSourceMap()
|
|
64
|
+
toNaturalTS(state = createCompilerState(), prefix?: string): string {
|
|
65
|
+
return this.name;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//= ===============================================================================
|
|
63
69
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
64
70
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
65
71
|
//================================================================================
|
|
@@ -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
|
|
|
4
4
|
//================================================================================
|
|
@@ -154,7 +154,7 @@ export class UnaryExpression extends LogicItem {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
@withSourceMap()
|
|
157
|
-
toEmbeddedTS(state
|
|
157
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
158
158
|
if (this.operator === 'isNull') {
|
|
159
159
|
const fnName = this.operator.toUpperCase();
|
|
160
160
|
let code = '';
|
|
@@ -172,7 +172,26 @@ export class UnaryExpression extends LogicItem {
|
|
|
172
172
|
return code;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
|
|
176
|
+
@withSourceMap()
|
|
177
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
178
|
+
if (this.operator === 'isNull') {
|
|
179
|
+
let code = '((';
|
|
180
|
+
code += this.argument?.toNaturalTS ? this.argument.toNaturalTS(shiftState(state, '', { inline: true })) : '__IDENTIFIER__';
|
|
181
|
+
code += ') === null';
|
|
182
|
+
code += ')';
|
|
183
|
+
return code;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (this.operator === '!') {
|
|
187
|
+
let code = '!(';
|
|
188
|
+
code += this.argument?.toNaturalTS ? this.argument.toNaturalTS(shiftState(state, '', { inline: true })) : '__IDENTIFIER__';
|
|
189
|
+
code += ')';
|
|
190
|
+
return code;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//= ===============================================================================
|
|
176
195
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
177
196
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
178
197
|
//================================================================================
|
|
@@ -86,7 +86,11 @@ export class Unparsed extends LogicItem {
|
|
|
86
86
|
return 'nasl.core.universalVariable';
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
@withSourceMap()
|
|
90
|
+
toNaturalTS(): string {
|
|
91
|
+
return ``;
|
|
92
|
+
}
|
|
93
|
+
//= ===============================================================================
|
|
90
94
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
91
95
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
92
96
|
//================================================================================
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
2
3
|
import Function from './Function__';
|
|
3
4
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
5
|
import { getValidationInFunction } from '../server/getFunctions';
|
|
@@ -13,7 +14,6 @@ import { EventPayload, Params } from '../common/EventEmitter';
|
|
|
13
14
|
import { concept, excludedInJSON, property, className } from '../decorators';
|
|
14
15
|
|
|
15
16
|
import * as utils from '../utils';
|
|
16
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
17
17
|
import BaseNode from '../common/BaseNode';
|
|
18
18
|
import Argument from './Argument__';
|
|
19
19
|
import LogicItem from './LogicItem__';
|
|
@@ -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__';
|
|
@@ -307,7 +307,7 @@ export class Variable extends BaseNode {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
@withSourceMap()
|
|
310
|
-
toEmbeddedTS(state
|
|
310
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
311
311
|
let code = this.name;
|
|
312
312
|
if (this.typeAnnotation) {
|
|
313
313
|
code += ': ';
|
|
@@ -324,6 +324,24 @@ export class Variable extends BaseNode {
|
|
|
324
324
|
return code;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
@withSourceMap()
|
|
328
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
329
|
+
let code = this.name;
|
|
330
|
+
if (this.typeAnnotation) {
|
|
331
|
+
code += ': ';
|
|
332
|
+
code += this.typeAnnotation.toNaturalTS(shiftState(state, code));
|
|
333
|
+
// toTS暂时只需要翻译引用数据类型的,因为值都是字符串
|
|
334
|
+
// 就不在这里赋值了,这里单纯就为了快速查找
|
|
335
|
+
// 并且屏蔽了一些异常的错误
|
|
336
|
+
if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
|
|
337
|
+
if (this.isEnum()) {
|
|
338
|
+
code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return code;
|
|
343
|
+
}
|
|
344
|
+
|
|
327
345
|
isEnum() {
|
|
328
346
|
return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
|
|
329
347
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
2
|
-
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
3
2
|
import { stdlibNamespace, CallLogic } from '../concepts';
|
|
4
3
|
|
|
5
4
|
import * as babelParser from '@babel/parser';
|
|
@@ -13,6 +12,7 @@ import MemberExpression from './MemberExpression__';
|
|
|
13
12
|
import Identifier from './Identifier__';
|
|
14
13
|
import { PAGE_COMPONENT_INCLUDE_TAG_MAP } from './View__';
|
|
15
14
|
|
|
15
|
+
import { kebab2Camel } from '../utils';
|
|
16
16
|
export interface ParseContext {
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
}
|
|
@@ -1929,6 +1929,74 @@ export class ViewElement extends BaseNode {
|
|
|
1929
1929
|
return code;
|
|
1930
1930
|
}
|
|
1931
1931
|
|
|
1932
|
+
@withSourceMap()
|
|
1933
|
+
toNaturalTS(state = createCompilerState(), parentLevel?: number): string {
|
|
1934
|
+
let code = '';
|
|
1935
|
+
const levelIndex = parentLevel || 0;
|
|
1936
|
+
if (Array.isArray(this.bindEvents)) {
|
|
1937
|
+
this.bindEvents.forEach((event) => {
|
|
1938
|
+
code += event.toNaturalTS(shiftState(state, code, {
|
|
1939
|
+
tabSize: state.tabSize,
|
|
1940
|
+
}));
|
|
1941
|
+
// code += '\n';
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
if (Array.isArray(this.children)) {
|
|
1946
|
+
if (this.children.find((item) => item.tag === 'template' && item.slotTarget)) {
|
|
1947
|
+
// code += indent(state.tabSize + 2);
|
|
1948
|
+
const defaultArr: ViewElement[] = [];
|
|
1949
|
+
// 先把插槽翻译了
|
|
1950
|
+
this.children.forEach((element) => {
|
|
1951
|
+
if (element.tag === 'template') {
|
|
1952
|
+
code += element.toNaturalTS(shiftState(state, code, {
|
|
1953
|
+
tabSize: state.tabSize,
|
|
1954
|
+
}), levelIndex);
|
|
1955
|
+
} else {
|
|
1956
|
+
defaultArr.push(element);
|
|
1957
|
+
}
|
|
1958
|
+
});
|
|
1959
|
+
// 翻译其余的子集
|
|
1960
|
+
if (defaultArr.length) {
|
|
1961
|
+
defaultArr.forEach((element) => {
|
|
1962
|
+
code += element.toNaturalTS(shiftState(state, code, {
|
|
1963
|
+
tabSize: state.tabSize,
|
|
1964
|
+
}), levelIndex);
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
} else {
|
|
1968
|
+
this.children.forEach((element) => {
|
|
1969
|
+
code += element.toNaturalTS(shiftState(state, code, {
|
|
1970
|
+
tabSize: state.tabSize,
|
|
1971
|
+
}), levelIndex);
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
return code;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
toNaturalTSDefinition(state?: TranslatorState): string {
|
|
1980
|
+
let code = '';
|
|
1981
|
+
|
|
1982
|
+
if (['u-button', 'u-form', 'u-modal', 'u-table-view', 'u-select', 'u-input', 'u-number-input'].includes(this.tag)) {
|
|
1983
|
+
code += indent(state.tabSize + 1);
|
|
1984
|
+
// 登录组件不翻译
|
|
1985
|
+
// if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form') {
|
|
1986
|
+
// code += `${this.name}: nasl.ui.div;\n`;
|
|
1987
|
+
// } else {
|
|
1988
|
+
code += `${this.name}: nasl.ui.${kebab2Camel(this.tag.replace(/^\w-/, ''))},\n`;
|
|
1989
|
+
// }
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
if (Array.isArray(this.children)) {
|
|
1993
|
+
this.children.forEach((element) => {
|
|
1994
|
+
code += element.toNaturalTSDefinition(shiftState(state, code));
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
return code;
|
|
1998
|
+
}
|
|
1999
|
+
|
|
1932
2000
|
_duplicate() {
|
|
1933
2001
|
const element = ViewElement.from(this.toTemplateJSON());
|
|
1934
2002
|
const nameMap = element.deepRenameElements(this);
|
|
@@ -2790,7 +2858,8 @@ export class ViewElement extends BaseNode {
|
|
|
2790
2858
|
);
|
|
2791
2859
|
}
|
|
2792
2860
|
parseStyleToObject(styleStr: string = '') {
|
|
2793
|
-
const
|
|
2861
|
+
const [styleStr1, styleStr2] = styleStr.split('--custom-start: auto;')
|
|
2862
|
+
const styleObj = styleStr1.split(/;/gim).reduce((obj: Record<string, string | number>, item) => {
|
|
2794
2863
|
// background-image:url(http://www...)
|
|
2795
2864
|
item = item.trim();
|
|
2796
2865
|
const pos = item.indexOf(':');
|
|
@@ -2801,16 +2870,20 @@ export class ViewElement extends BaseNode {
|
|
|
2801
2870
|
}
|
|
2802
2871
|
return obj;
|
|
2803
2872
|
}, {});
|
|
2873
|
+
styleObj['customStyle'] = styleStr2;
|
|
2804
2874
|
return styleObj;
|
|
2805
2875
|
}
|
|
2806
2876
|
stringifyStyleAttr(styleObj: Record<string, string | number>) {
|
|
2807
|
-
|
|
2877
|
+
const customStyle = styleObj['customStyle'] || '';
|
|
2878
|
+
delete styleObj['customStyle'];
|
|
2879
|
+
const styleStr = (
|
|
2808
2880
|
Object.keys(styleObj)
|
|
2809
2881
|
// 空字符串是允许的,因为有时候想要覆盖之前的样式。undefined 则不允许
|
|
2810
2882
|
.filter((key) => styleObj[key] !== undefined)
|
|
2811
2883
|
.map((key) => `${key}:${String(styleObj[key]).trim()};`)
|
|
2812
2884
|
.join('')
|
|
2813
2885
|
);
|
|
2886
|
+
return styleStr + '--custom-start: auto;' + customStyle;
|
|
2814
2887
|
}
|
|
2815
2888
|
// 批量更新绑定属性
|
|
2816
2889
|
batchUpdateBindAttrs(attrOptions: Record<string, any>[]) {
|