@lcap/nasl 3.5.0-beta.3 → 3.5.0-beta.5
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/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +7 -0
- package/out/common/BaseNode.js +15 -2
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +1 -0
- package/out/concepts/Argument__.js +28 -8
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignment__.js +5 -7
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +5 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +1 -0
- package/out/concepts/BinaryExpression__.js +30 -13
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +11 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +3 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +2 -2
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +1 -0
- package/out/concepts/BooleanLiteral__.js +6 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +4 -2
- package/out/concepts/BusinessComponent__.js +128 -89
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/CallConnector__.d.ts +1 -0
- package/out/concepts/CallConnector__.js +6 -0
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallEvent__.d.ts +4 -0
- package/out/concepts/CallEvent__.js +19 -2
- package/out/concepts/CallEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +1 -0
- package/out/concepts/CallFunction__.js +62 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +31 -22
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +49 -38
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +2 -0
- package/out/concepts/CallQueryComponent__.js +94 -8
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/DefaultValue__.d.ts +1 -0
- package/out/concepts/DefaultValue__.js +7 -1
- package/out/concepts/DefaultValue__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +34 -22
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +1 -0
- package/out/concepts/EntityProperty__.js +26 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +25 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +1 -0
- package/out/concepts/EnumItem__.js +12 -0
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +16 -2
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.d.ts +4 -0
- package/out/concepts/Event__.js +12 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +10 -16
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendType__.js +1 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -0
- package/out/concepts/Identifier__.js +21 -0
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +6 -0
- package/out/concepts/LogicItem__.js +11 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +24 -23
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +5 -5
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +1 -1
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +13 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js +3 -3
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +4 -4
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -1
- package/out/concepts/NewMap__.js +6 -5
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +2 -0
- package/out/concepts/NullLiteral__.js +12 -0
- 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__.js +4 -2
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -0
- package/out/concepts/Param__.js +41 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +9 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.d.ts +2 -0
- package/out/concepts/QueryAggregateExpression__.js +16 -0
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +33 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +2 -0
- package/out/concepts/QueryFromExpression__.js +27 -0
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +2 -0
- package/out/concepts/QueryGroupByExpression__.js +13 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +2 -0
- package/out/concepts/QueryJoinExpression__.js +37 -0
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.d.ts +2 -0
- package/out/concepts/QueryLimitExpression__.js +16 -0
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +2 -0
- package/out/concepts/QueryOrderByExpression__.js +22 -0
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +3 -0
- package/out/concepts/QuerySelectExpression__.js +41 -0
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -0
- package/out/concepts/SelectMembers__.js +7 -0
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +4 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringInterpolation__.d.ts +1 -0
- package/out/concepts/StringInterpolation__.js +20 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -0
- package/out/concepts/StringLiteral__.js +21 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -0
- package/out/concepts/StructureProperty__.js +19 -0
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -0
- package/out/concepts/Structure__.js +22 -7
- 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/TypeAnnotation__.d.ts +1 -0
- package/out/concepts/TypeAnnotation__.js +42 -1
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +2 -1
- package/out/concepts/TypeParam__.js +7 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +72 -59
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +2 -1
- package/out/concepts/View__.js +6 -19
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +4 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +4 -1
- package/out/natural/genNaturalTS.js +38 -1
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/transformTSCode.js +52 -41
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/formatTsUtils.js +10 -9
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getFunctions.js +3 -3
- package/out/server/getFunctions.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +52 -17
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +8 -0
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +2 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -1
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +3 -3
- package/out/templator/utils.js.map +1 -1
- package/out/translator/types.d.ts +2 -0
- package/out/translator/utils.d.ts +2 -1
- package/out/translator/utils.js +44 -7
- package/out/translator/utils.js.map +1 -1
- package/out/utils/string.js +2 -2
- package/out/utils/string.js.map +1 -1
- package/out/utils/time-slicing/performance.js +3 -3
- package/out/utils/time-slicing/performance.js.map +1 -1
- package/package.json +2 -2
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +17 -3
- package/src/concepts/AnonymousFunction__.ts +24 -9
- package/src/concepts/Argument__.ts +28 -6
- package/src/concepts/Assignment__.ts +5 -7
- package/src/concepts/BatchAssignment__.ts +6 -3
- package/src/concepts/BinaryExpression__.ts +30 -13
- package/src/concepts/BindAttribute__.ts +10 -3
- package/src/concepts/BindDirective__.ts +3 -3
- package/src/concepts/BindEvent__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +5 -0
- package/src/concepts/BusinessComponent__.ts +144 -100
- package/src/concepts/CallConnector__.ts +5 -0
- package/src/concepts/CallEvent__.ts +20 -3
- package/src/concepts/CallFunction__.ts +54 -8
- package/src/concepts/CallInterface__.ts +31 -24
- package/src/concepts/CallLogic__.ts +48 -37
- package/src/concepts/CallQueryComponent__.ts +101 -8
- package/src/concepts/DefaultValue__.ts +6 -1
- package/src/concepts/Destination__.ts +32 -22
- package/src/concepts/EntityProperty__.ts +30 -2
- package/src/concepts/Entity__.ts +29 -0
- package/src/concepts/EnumItem__.ts +17 -0
- package/src/concepts/Enum__.ts +19 -2
- package/src/concepts/Event__.ts +13 -0
- package/src/concepts/ForEachStatement__.ts +10 -20
- package/src/concepts/FrontendType__.ts +1 -0
- package/src/concepts/Identifier__.ts +19 -0
- package/src/concepts/JSBlock__.ts +1 -1
- package/src/concepts/LogicItem__.ts +13 -1
- package/src/concepts/Logic__.ts +24 -24
- package/src/concepts/MatchCase__.ts +5 -5
- package/src/concepts/Match__.ts +1 -1
- package/src/concepts/MemberExpression__.ts +12 -3
- package/src/concepts/NewComposite__.ts +7 -9
- package/src/concepts/NewList__.ts +4 -4
- package/src/concepts/NewMap__.ts +6 -5
- package/src/concepts/NullLiteral__.ts +10 -0
- package/src/concepts/NumericLiteral__.ts +6 -1
- package/src/concepts/OqlQueryComponent__.ts +4 -2
- package/src/concepts/Param__.ts +39 -0
- package/src/concepts/ProcessElement__.ts +8 -1
- package/src/concepts/QueryAggregateExpression__.ts +15 -0
- package/src/concepts/QueryFieldExpression__.ts +34 -0
- package/src/concepts/QueryFromExpression__.ts +29 -0
- package/src/concepts/QueryGroupByExpression__.ts +11 -1
- package/src/concepts/QueryJoinExpression__.ts +39 -0
- package/src/concepts/QueryLimitExpression__.ts +14 -0
- package/src/concepts/QueryOrderByExpression__.ts +23 -0
- package/src/concepts/QuerySelectExpression__.ts +55 -0
- package/src/concepts/SelectMembers__.ts +7 -0
- package/src/concepts/SqlQueryComponent__.ts +4 -2
- package/src/concepts/StringInterpolation__.ts +18 -2
- package/src/concepts/StringLiteral__.ts +20 -1
- package/src/concepts/StructureProperty__.ts +22 -0
- package/src/concepts/Structure__.ts +24 -7
- package/src/concepts/SwitchCase__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +37 -1
- package/src/concepts/TypeParam__.ts +6 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/ViewElement__.ts +74 -58
- package/src/concepts/View__.ts +6 -19
- package/src/generator/genBundleFiles.ts +6 -1
- package/src/natural/genNaturalTS.ts +41 -0
- package/src/natural/transformTSCode.ts +50 -42
- package/src/server/formatTsUtils.ts +16 -11
- package/src/server/getFunctions.ts +3 -3
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +56 -18
- package/src/server/translator.ts +7 -0
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -1
- package/src/templator/genGetBlock.ts +2 -1
- package/src/templator/genUpdateBlock.ts +2 -1
- package/src/templator/utils.ts +3 -3
- package/src/translator/types.ts +4 -0
- package/src/translator/utils.ts +73 -34
- package/src/utils/string.ts +2 -2
- package/src/utils/time-slicing/performance.ts +3 -3
- package/test/concepts/call-interface/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
- package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
- package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +199 -0
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +127 -6
- package/test/concepts/view-element/fixtures/table-data-source-calllogic-with-server-validation.json +2074 -0
- package/test/concepts/view-element/toVue.spec.ts +0 -1
- package/ts-worker/package.json +1 -1
- package/ts-worker/src/index.js +1 -0
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
withGenerator,
|
|
10
10
|
TranslatorGenerator,
|
|
11
11
|
} from '../translator';
|
|
12
|
+
|
|
13
|
+
import Identifier from './Identifier__';
|
|
14
|
+
import StringLiteral from './StringLiteral__';
|
|
12
15
|
//================================================================================
|
|
13
16
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
14
17
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -209,6 +212,26 @@ export class QueryOrderByExpression extends LogicItem {
|
|
|
209
212
|
return code;
|
|
210
213
|
}
|
|
211
214
|
|
|
215
|
+
@withSourceMap()
|
|
216
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
217
|
+
let orderElement = this.orderElement.concept === 'Identifier' && (this.orderElement as Identifier).namespace === 'inner'
|
|
218
|
+
? (this.orderElement as Identifier).name
|
|
219
|
+
: this.orderElement.toNaturalTS(state);
|
|
220
|
+
let order = this.order.toNaturalTS(state);
|
|
221
|
+
return `[${orderElement || '__IDENTIFIER__'}, ${order || '__IDENTIFIER__'}]`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@withSourceMap()
|
|
225
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
226
|
+
let orderElement = this.orderElement.concept === 'QueryOrderByExpression'
|
|
227
|
+
? this.orderElement.toTextualNASL(state)
|
|
228
|
+
: this.orderElement.concept === 'Identifier' && (this.orderElement as Identifier).namespace === 'inner'
|
|
229
|
+
? (this.orderElement as Identifier).name
|
|
230
|
+
: `\${${this.orderElement.toTextualNASL(state)}}`;
|
|
231
|
+
let order = this.order.concept === 'StringLiteral' ? (this.order as StringLiteral).value : `\${${this.order.toTextualNASL(state)}}`;
|
|
232
|
+
return `${orderElement || '__IDENTIFIER__'} ${order || '__IDENTIFIER__'}`;
|
|
233
|
+
}
|
|
234
|
+
|
|
212
235
|
//================================================================================
|
|
213
236
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
214
237
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TranslatorState,
|
|
3
|
+
withSourceMap,
|
|
4
|
+
createCompilerState,
|
|
5
|
+
withSourceMapGenerator,
|
|
6
|
+
withGenerator,
|
|
7
|
+
TranslatorGenerator,
|
|
8
|
+
indent,
|
|
9
|
+
} from '../translator';
|
|
10
|
+
import CallQueryComponent from './CallQueryComponent__';
|
|
1
11
|
//================================================================================
|
|
2
12
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
3
13
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -547,6 +557,51 @@ export class QuerySelectExpression extends LogicItem {
|
|
|
547
557
|
return utils.unique(name, this.getQueryFieldExpressionExistingNames(), undefined, false);
|
|
548
558
|
}
|
|
549
559
|
|
|
560
|
+
@withSourceMap()
|
|
561
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
562
|
+
let code = this.distinct ? `\n${indent(state.tabSize)}.SELECT_DISTINCT(() => ({\n` : `\n${indent(state.tabSize)}.SELECT(() => ({\n`;
|
|
563
|
+
|
|
564
|
+
this.selectElements.forEach((element) => {
|
|
565
|
+
code += indent(state.tabSize + 1);
|
|
566
|
+
code += element.toNaturalTS(state, true);
|
|
567
|
+
code += ',\n';
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
if ((this.parentNode as CallQueryComponent)?.groupBy.length) {
|
|
571
|
+
(this.parentNode as CallQueryComponent)?.groupBy.forEach((groupElement, index) => {
|
|
572
|
+
code += indent(state.tabSize);
|
|
573
|
+
code += (groupElement.groupElement as QueryFieldExpression).toNaturalTS(state, true) + ',\n';
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
code += `${indent(state.tabSize)}}))`;
|
|
578
|
+
|
|
579
|
+
return code;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
@withSourceMap()
|
|
583
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
584
|
+
let code = 'SELECT ';
|
|
585
|
+
if (this.distinct)
|
|
586
|
+
code += 'DISTINCT ';
|
|
587
|
+
|
|
588
|
+
this.selectElements.forEach((element) => {
|
|
589
|
+
code += element.toTextualNASL(state);
|
|
590
|
+
if (element !== this.selectElements[this.selectElements.length - 1])
|
|
591
|
+
code += ', ';
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
if ((this.parentNode as CallQueryComponent)?.groupBy.length) {
|
|
595
|
+
(this.parentNode as CallQueryComponent)?.groupBy.forEach((element, index) => {
|
|
596
|
+
code += element.toTextualNASL(state);
|
|
597
|
+
if (element !== (this.parentNode as CallQueryComponent)?.groupBy[this.selectElements.length - 1])
|
|
598
|
+
code += ', ';
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return code;
|
|
603
|
+
}
|
|
604
|
+
|
|
550
605
|
//================================================================================
|
|
551
606
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
552
607
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runGeneratorSync as runSync } from '../utils/time-slicing';
|
|
1
2
|
import { wrapForEachToGenerator as wrapForEach } from '../utils/time-slicing';
|
|
2
3
|
import {
|
|
3
4
|
TranslatorState,
|
|
@@ -402,6 +403,12 @@ export class SelectMembers extends BaseNode {
|
|
|
402
403
|
const code = '';
|
|
403
404
|
return code;
|
|
404
405
|
}
|
|
406
|
+
|
|
407
|
+
@withSourceMap()
|
|
408
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
409
|
+
return runSync(this.toEmbeddedTS(state));
|
|
410
|
+
}
|
|
411
|
+
|
|
405
412
|
//================================================================================
|
|
406
413
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
407
414
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -290,8 +290,10 @@ export class SqlQueryComponent extends LogicItem {
|
|
|
290
290
|
|
|
291
291
|
@withSourceMap()
|
|
292
292
|
toNaturalTS(state = createCompilerState()): string {
|
|
293
|
-
const code
|
|
294
|
-
|
|
293
|
+
const code = this.code
|
|
294
|
+
.replace(/\.(\d+)\}/g, '[$1]}')
|
|
295
|
+
.replace(/`/g, '\\`'); // 处理枚举 TS 转不回来的情况 ${app.enums.NetStatusEnum.1}
|
|
296
|
+
return `nasl.oql.query(\`${code}\`)`;
|
|
295
297
|
}
|
|
296
298
|
|
|
297
299
|
/**
|
|
@@ -360,14 +360,30 @@ export class StringInterpolation extends LogicItem {
|
|
|
360
360
|
let code = '`';
|
|
361
361
|
this.expressions.forEach((exp) => {
|
|
362
362
|
if (exp.concept === 'StringLiteral') {
|
|
363
|
-
code += (exp as StringLiteral).
|
|
363
|
+
code += (exp as StringLiteral).toNaturalTS(shiftState(state, code));
|
|
364
364
|
} else {
|
|
365
365
|
code += '${';
|
|
366
366
|
code += exp.toNaturalTS(shiftState(state, code));
|
|
367
367
|
code += '}';
|
|
368
368
|
}
|
|
369
369
|
});
|
|
370
|
-
code += '
|
|
370
|
+
code += '`';
|
|
371
|
+
return code;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
@withSourceMap()
|
|
375
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
376
|
+
let code = 's"';
|
|
377
|
+
this.expressions.forEach((exp) => {
|
|
378
|
+
if (exp.concept === 'StringLiteral') {
|
|
379
|
+
code += (exp as StringLiteral).toNaturalTS(shiftState(state, code));
|
|
380
|
+
} else {
|
|
381
|
+
code += '${';
|
|
382
|
+
code += exp.toNaturalTS(shiftState(state, code));
|
|
383
|
+
code += '}';
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
code += '"';
|
|
371
387
|
return code;
|
|
372
388
|
}
|
|
373
389
|
|
|
@@ -141,7 +141,26 @@ export class StringLiteral extends LogicItem {
|
|
|
141
141
|
|
|
142
142
|
@withSourceMap()
|
|
143
143
|
toNaturalTS(state = createCompilerState(), isRequired?: boolean): string {
|
|
144
|
-
|
|
144
|
+
|
|
145
|
+
if (this.parentNode?.concept === 'StringInterpolation') {
|
|
146
|
+
const code = this.value.replace(/[`$\\]/g, '\\$&');
|
|
147
|
+
return code;
|
|
148
|
+
} else {
|
|
149
|
+
const code = this.value.replace(/['\\]/g, '\\$&');
|
|
150
|
+
// if (code.includes("'"))
|
|
151
|
+
// return `"${code}"`;
|
|
152
|
+
// else
|
|
153
|
+
return `'${code}'`;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@withSourceMap()
|
|
158
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
159
|
+
const code = this.value;
|
|
160
|
+
if (this.parentNode?.concept === 'StringInterpolation')
|
|
161
|
+
return code;
|
|
162
|
+
else
|
|
163
|
+
return `'${code}'`;
|
|
145
164
|
}
|
|
146
165
|
|
|
147
166
|
/**
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
withSourceMapGenerator,
|
|
8
8
|
withGenerator,
|
|
9
9
|
TranslatorGenerator,
|
|
10
|
+
indent,
|
|
11
|
+
createDecoratorCode,
|
|
10
12
|
} from '../translator';
|
|
11
13
|
|
|
12
14
|
interface defaultCode {
|
|
@@ -353,6 +355,26 @@ export class StructureProperty extends BaseNode {
|
|
|
353
355
|
return code;
|
|
354
356
|
}
|
|
355
357
|
|
|
358
|
+
@withSourceMap()
|
|
359
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
360
|
+
let code = '';
|
|
361
|
+
|
|
362
|
+
const index = (this.parentNode as Structure)?.properties.indexOf(this);
|
|
363
|
+
if (index > 0) code += `\n${indent(state.tabSize)}`;
|
|
364
|
+
|
|
365
|
+
code += createDecoratorCode(state, this, ['label', 'description', 'jsonName']);
|
|
366
|
+
|
|
367
|
+
code += this.name;
|
|
368
|
+
if (this.typeAnnotation) {
|
|
369
|
+
code += ': ';
|
|
370
|
+
code += this.typeAnnotation.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
371
|
+
}
|
|
372
|
+
if (this.defaultValue) {
|
|
373
|
+
code += ` = ${this.defaultValue}`;
|
|
374
|
+
}
|
|
375
|
+
return code;
|
|
376
|
+
}
|
|
377
|
+
|
|
356
378
|
/**
|
|
357
379
|
* 设置数据类型
|
|
358
380
|
* @param typeAnnotation 类型标注对象
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
withSourceMapGenerator,
|
|
10
10
|
withGenerator,
|
|
11
11
|
TranslatorGenerator,
|
|
12
|
+
createDecoratorCode,
|
|
12
13
|
} from '../translator';
|
|
13
14
|
import type Namespace from './Namespace__';
|
|
14
15
|
import { CUSTOM_CONNECTOR_EDITABLE_SUFFIX } from './basics/constants';
|
|
@@ -614,24 +615,24 @@ export class Structure extends BaseNode {
|
|
|
614
615
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
615
616
|
const self = this;
|
|
616
617
|
let code = `export class ${self.tsName} {\n`;
|
|
617
|
-
code += indent(
|
|
618
|
+
code += indent(state.tabSize + 1);
|
|
618
619
|
code += `__name: '${self.getTsNamespace()}.${self.tsName}';\n`;
|
|
619
620
|
yield* wrapForEach(self.properties, function* warpForEachGenerator(property) {
|
|
620
|
-
code += indent(
|
|
621
|
+
code += indent(state.tabSize + 1);
|
|
621
622
|
code += yield* property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
|
|
622
623
|
code += ';\n';
|
|
623
624
|
});
|
|
624
625
|
|
|
625
626
|
/* 默认值草稿区 */
|
|
626
|
-
code += `${
|
|
627
|
+
code += `${state.tabSize + 1}playground = () => {\n`;
|
|
627
628
|
for (const prop of this.properties) {
|
|
628
629
|
for (const item of prop.defaultValue?.playground ?? []) {
|
|
629
630
|
code += yield* item.toEmbeddedTS(shiftState(state, code));
|
|
630
631
|
code += ';\n';
|
|
631
632
|
}
|
|
632
633
|
}
|
|
633
|
-
code += `${
|
|
634
|
-
code += `${
|
|
634
|
+
code += `${state.tabSize + 1}}\n`;
|
|
635
|
+
code += `${state.tabSize}}\n`;
|
|
635
636
|
return code;
|
|
636
637
|
}
|
|
637
638
|
|
|
@@ -640,11 +641,27 @@ export class Structure extends BaseNode {
|
|
|
640
641
|
let code = `class ${this.name} {\n`;
|
|
641
642
|
// code += `${indent(state.tabSize + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
642
643
|
this.properties.forEach((property) => {
|
|
643
|
-
code += indent(
|
|
644
|
+
code += indent(state.tabSize + 1);
|
|
644
645
|
code += property.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
|
|
645
646
|
code += ';\n';
|
|
646
647
|
});
|
|
647
|
-
code += `${indent(state
|
|
648
|
+
code += `${indent(state.tabSize)}}\n`;
|
|
649
|
+
return code;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
@withSourceMap()
|
|
653
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
654
|
+
let code = '';
|
|
655
|
+
|
|
656
|
+
code += createDecoratorCode(state, this, ['description']);
|
|
657
|
+
|
|
658
|
+
code += `struct ${this.name} {\n`;
|
|
659
|
+
// code += `${indent(state.tabSize + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
660
|
+
this.properties.forEach((property) => {
|
|
661
|
+
code += property.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
662
|
+
code += '\n';
|
|
663
|
+
});
|
|
664
|
+
code += `${indent(state.tabSize)}}\n`;
|
|
648
665
|
return code;
|
|
649
666
|
}
|
|
650
667
|
|
|
@@ -339,7 +339,7 @@ export class SwitchCase extends LogicItem {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
@withSourceMap()
|
|
342
|
-
toNaturalTS(state = createCompilerState(), isLast?: boolean, isFirst
|
|
342
|
+
toNaturalTS(state = createCompilerState(), isLast?: boolean, isFirst = true): string {
|
|
343
343
|
let code = '\n';
|
|
344
344
|
if (!isLast) {
|
|
345
345
|
code += indent(state.tabSize + 2);
|
|
@@ -760,7 +760,7 @@ export class TypeAnnotation extends BaseNode {
|
|
|
760
760
|
return this.typeName;
|
|
761
761
|
} else if (this.typeKind === 'generic') {
|
|
762
762
|
return `${this.typeName}<${
|
|
763
|
-
!this.typeArguments
|
|
763
|
+
!this.typeArguments?.length
|
|
764
764
|
? 'T'
|
|
765
765
|
: this.typeArguments.map((arg) => arg?.typeTitle || arg?.name || 'T').join(', ')
|
|
766
766
|
}>`;
|
|
@@ -1081,6 +1081,42 @@ export class TypeAnnotation extends BaseNode {
|
|
|
1081
1081
|
return '__IDENTIFIER__';
|
|
1082
1082
|
}
|
|
1083
1083
|
|
|
1084
|
+
@withSourceMap()
|
|
1085
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
1086
|
+
if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
|
|
1087
|
+
if (this.typeName === 'Long')
|
|
1088
|
+
return `${this.typeNamespace}.Integer`;
|
|
1089
|
+
return `${this.typeNamespace}.${this.typeName}`;
|
|
1090
|
+
} else if (this.typeKind === 'generic') {
|
|
1091
|
+
let code = `${this.typeName}<`;
|
|
1092
|
+
(this.typeArguments || []).forEach((arg, index) => {
|
|
1093
|
+
code += arg?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1094
|
+
if (index !== this.typeArguments.length - 1) code += ', ';
|
|
1095
|
+
});
|
|
1096
|
+
code += '>';
|
|
1097
|
+
return code;
|
|
1098
|
+
} else if (this.typeKind === 'union') {
|
|
1099
|
+
let code = '';
|
|
1100
|
+
(this.typeArguments || []).forEach((arg, index) => {
|
|
1101
|
+
code += arg?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1102
|
+
if (index !== this.typeArguments.length - 1) code += ' | ';
|
|
1103
|
+
});
|
|
1104
|
+
return code;
|
|
1105
|
+
} else if (this.typeKind === 'anonymousStructure') {
|
|
1106
|
+
let code = `{ `;
|
|
1107
|
+
(this.properties || []).forEach((property, i) => {
|
|
1108
|
+
code += `${property.name}: `;
|
|
1109
|
+
code += `${property.typeAnnotation?.toNaturalTS(
|
|
1110
|
+
shiftState(state, code, { inline: true, tabSize: state.tabSize + 1 }),
|
|
1111
|
+
)}`;
|
|
1112
|
+
code += i < this.properties?.length - 1 ? ', ' : ' }';
|
|
1113
|
+
});
|
|
1114
|
+
return code;
|
|
1115
|
+
} else {
|
|
1116
|
+
return this.typeName;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1084
1120
|
/**
|
|
1085
1121
|
* 用于标准化数据结构,便于计算 anonymousStructure 的 __name
|
|
1086
1122
|
*/
|
|
@@ -73,7 +73,12 @@ export class TypeParam extends BaseNode {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
@withSourceMap()
|
|
76
|
-
toNaturalTS(state = createCompilerState()
|
|
76
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
77
|
+
return this.name;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@withSourceMap()
|
|
81
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
77
82
|
return this.name;
|
|
78
83
|
}
|
|
79
84
|
|
|
@@ -98,7 +98,7 @@ export class Unparsed extends LogicItem {
|
|
|
98
98
|
|
|
99
99
|
@withSourceMap()
|
|
100
100
|
toNaturalTS(): string {
|
|
101
|
-
return
|
|
101
|
+
return '__IDENTIFIER__';
|
|
102
102
|
}
|
|
103
103
|
//================================================================================
|
|
104
104
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -500,7 +500,12 @@ export class ValidationRule extends LogicItem {
|
|
|
500
500
|
const { calleeName, target, calleeKey, arguments: args, errorMessage, view } = self;
|
|
501
501
|
if (calleeName) {
|
|
502
502
|
// 调用逻辑时绑定的验证器
|
|
503
|
-
if (
|
|
503
|
+
if (
|
|
504
|
+
self?.parentNode?.parentKey !== 'metadataTypes'
|
|
505
|
+
&& (
|
|
506
|
+
self.getAncestor('CallLogic') || !(view || this.getAncestor('BusinessComponent'))
|
|
507
|
+
)
|
|
508
|
+
) {
|
|
504
509
|
code += yield* target.toEmbeddedTS(shiftState(state, code));
|
|
505
510
|
code += ';\n';
|
|
506
511
|
}
|
|
@@ -1725,7 +1725,7 @@ export class ViewElement extends BaseNode {
|
|
|
1725
1725
|
}>`;
|
|
1726
1726
|
} else {
|
|
1727
1727
|
let targetNode: any = _this;
|
|
1728
|
-
while (!targetNode.__tsVariableDataSourceTypeName && asserts.isViewElement(targetNode?.parentNode)) {
|
|
1728
|
+
while ((!targetNode.__tsVariableDataSourceTypeName || targetNode.__tsVariableDataSourceTypeName === 'any') && asserts.isViewElement(targetNode?.parentNode)) {
|
|
1729
1729
|
targetNode = targetNode.parentNode;
|
|
1730
1730
|
}
|
|
1731
1731
|
genericity += `<${(targetNode as any).__tsVariableDataSourceTypeName ?? 'any'}>`;
|
|
@@ -1747,8 +1747,9 @@ export class ViewElement extends BaseNode {
|
|
|
1747
1747
|
tabSize: 4,
|
|
1748
1748
|
inline: true,
|
|
1749
1749
|
noNeedParams: true,
|
|
1750
|
+
callLogicNoIife: true,
|
|
1750
1751
|
};
|
|
1751
|
-
|
|
1752
|
+
const value = yield* attr.expression.toEmbeddedTS(
|
|
1752
1753
|
shiftState(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}),
|
|
1753
1754
|
);
|
|
1754
1755
|
code += indent((state?.tabSize || 0) + 3);
|
|
@@ -1844,8 +1845,9 @@ export class ViewElement extends BaseNode {
|
|
|
1844
1845
|
tabSize: 4,
|
|
1845
1846
|
inline: true,
|
|
1846
1847
|
noNeedParams: true,
|
|
1848
|
+
callLogicNoIife: true,
|
|
1847
1849
|
};
|
|
1848
|
-
|
|
1850
|
+
const value = yield* attr.expression.toEmbeddedTS(
|
|
1849
1851
|
shiftState(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}),
|
|
1850
1852
|
);
|
|
1851
1853
|
code += `type ${datasourceName} = `;
|
|
@@ -1892,6 +1894,29 @@ export class ViewElement extends BaseNode {
|
|
|
1892
1894
|
}
|
|
1893
1895
|
}
|
|
1894
1896
|
|
|
1897
|
+
// 收集页面元素中的业务组件
|
|
1898
|
+
collectExistingBusinessComponent() {
|
|
1899
|
+
const excludedSet = new Set();
|
|
1900
|
+
utils.traverse(
|
|
1901
|
+
({ node }) => {
|
|
1902
|
+
const correspondingBusinessComponent = node.correspondingBusinessComponent;
|
|
1903
|
+
if (correspondingBusinessComponent && !excludedSet.has(correspondingBusinessComponent)) {
|
|
1904
|
+
const set = correspondingBusinessComponent.collectExistingBusinessComponent();
|
|
1905
|
+
if (set.size) {
|
|
1906
|
+
set.forEach(value => {
|
|
1907
|
+
if (!excludedSet.has(value)) {
|
|
1908
|
+
excludedSet.add(value);
|
|
1909
|
+
}
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
},
|
|
1914
|
+
{
|
|
1915
|
+
node: this,
|
|
1916
|
+
},
|
|
1917
|
+
);
|
|
1918
|
+
return excludedSet;
|
|
1919
|
+
}
|
|
1895
1920
|
|
|
1896
1921
|
@withSourceMapGenerator
|
|
1897
1922
|
*toEmbeddedTS(state = createCompilerState(), parentLevel?: number): TranslatorGenerator {
|
|
@@ -2016,8 +2041,8 @@ export class ViewElement extends BaseNode {
|
|
|
2016
2041
|
code += `() => [\n`;
|
|
2017
2042
|
}
|
|
2018
2043
|
yield* wrapForEach(self.bindAttrs, function* warpForEachGenerator(attr) {
|
|
2019
|
-
//
|
|
2020
|
-
const shouldFilter = self.isCorrespondingBusinessComponent &&
|
|
2044
|
+
// 过滤业务组件的非表达式模式的翻译
|
|
2045
|
+
const shouldFilter = self.isCorrespondingBusinessComponent && (attr.type !== 'dynamic');
|
|
2021
2046
|
if (shouldFilter) {
|
|
2022
2047
|
return;
|
|
2023
2048
|
}
|
|
@@ -2768,49 +2793,6 @@ export class ViewElement extends BaseNode {
|
|
|
2768
2793
|
const { finalCode, asCompontent } = options || {};
|
|
2769
2794
|
const parts: string[] = [];
|
|
2770
2795
|
if (finalCode === false) {
|
|
2771
|
-
if (this.tag === 'slot') {
|
|
2772
|
-
if (asCompontent) {
|
|
2773
|
-
return `<div vusion-slot-name="${this.name}">
|
|
2774
|
-
<slot name="${this.name}">
|
|
2775
|
-
<div s-empty="true" style="background: #f7f8fa;
|
|
2776
|
-
border: 1px dashed #c3c3c3;
|
|
2777
|
-
text-align: center;
|
|
2778
|
-
color: #999;
|
|
2779
|
-
min-height: 32px;
|
|
2780
|
-
min-width: 32px;
|
|
2781
|
-
width: 100%;
|
|
2782
|
-
align-items: center;
|
|
2783
|
-
display: inline-flex;
|
|
2784
|
-
justify-content: center;">
|
|
2785
|
-
+
|
|
2786
|
-
</div>
|
|
2787
|
-
</slot>
|
|
2788
|
-
</div>`;
|
|
2789
|
-
} else {
|
|
2790
|
-
return `<div vusion-node-path="${this.nodePath}"
|
|
2791
|
-
style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
|
|
2792
|
-
background-size: 45px 45px;
|
|
2793
|
-
background-repeat: repeat;
|
|
2794
|
-
line-height: 32px;
|
|
2795
|
-
min-height: 32px;
|
|
2796
|
-
color: var(--font-second-color);
|
|
2797
|
-
text-align: center;">
|
|
2798
|
-
组件占位,可在使用业务组件时插入任意组件
|
|
2799
|
-
</div>`;
|
|
2800
|
-
}
|
|
2801
|
-
} else if (this.businessComponent?.name === this.tag) {
|
|
2802
|
-
// 组件内部使用自身的情况
|
|
2803
|
-
return `<div vusion-node-path="${this.nodePath}"
|
|
2804
|
-
style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
|
|
2805
|
-
background-size: 45px 45px;
|
|
2806
|
-
background-repeat: repeat;
|
|
2807
|
-
line-height: 32px;
|
|
2808
|
-
min-height: 32px;
|
|
2809
|
-
color: var(--font-second-color);
|
|
2810
|
-
text-align: center;">
|
|
2811
|
-
在组件内部使用自身可能会导致循环引用,请谨慎使用
|
|
2812
|
-
</div>`;
|
|
2813
|
-
}
|
|
2814
2796
|
const isRoot = options.isRoot;
|
|
2815
2797
|
if (isRoot && !options?.asCompontent) {
|
|
2816
2798
|
parts.push('type="root"');
|
|
@@ -2859,7 +2841,7 @@ export class ViewElement extends BaseNode {
|
|
|
2859
2841
|
const tabString = ' '.repeat(newOptions.tabSize * newOptions.indentLevel);
|
|
2860
2842
|
const insideTabString = ' '.repeat(newOptions.tabSize * (newOptions.indentLevel + 1));
|
|
2861
2843
|
let shouldIndent = true;
|
|
2862
|
-
|
|
2844
|
+
let content: string = !this.children
|
|
2863
2845
|
? ''
|
|
2864
2846
|
: this.children
|
|
2865
2847
|
.map((element) => {
|
|
@@ -2868,9 +2850,6 @@ export class ViewElement extends BaseNode {
|
|
|
2868
2850
|
return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
|
|
2869
2851
|
})
|
|
2870
2852
|
.join('');
|
|
2871
|
-
if (!content.length) {
|
|
2872
|
-
shouldIndent = false;
|
|
2873
|
-
}
|
|
2874
2853
|
if (newOptions.aslIdAttr) {
|
|
2875
2854
|
if (newOptions.aslIdAttr === true) {
|
|
2876
2855
|
newOptions.aslIdAttr = 'asl-id';
|
|
@@ -2892,7 +2871,6 @@ export class ViewElement extends BaseNode {
|
|
|
2892
2871
|
this.refName && parts.push(`:ref="\`${this.refName}\`"`);
|
|
2893
2872
|
this.keyName && parts.push(`:key="\`${this.keyName}\`"`);
|
|
2894
2873
|
this.staticClass && parts.push(`class="${this.staticClass}"`);
|
|
2895
|
-
this.staticStyle && parts.push(`style="${this.staticStyle}"`);
|
|
2896
2874
|
|
|
2897
2875
|
const vIfs: string[] = [];
|
|
2898
2876
|
[]
|
|
@@ -2933,7 +2911,45 @@ export class ViewElement extends BaseNode {
|
|
|
2933
2911
|
) {
|
|
2934
2912
|
this.name && parts.push(`key="${this.name}"`);
|
|
2935
2913
|
}
|
|
2936
|
-
|
|
2914
|
+
let tag = this.tag;
|
|
2915
|
+
let staticStyle = this.staticStyle ?? '';
|
|
2916
|
+
if (this.tag === 'slot') {
|
|
2917
|
+
this.name && parts.push(`name="${this.name}"`);
|
|
2918
|
+
if (finalCode === false) {
|
|
2919
|
+
tag = 'div';
|
|
2920
|
+
if (asCompontent) {
|
|
2921
|
+
parts.push(`vusion-slot-name="${this.name}"`);
|
|
2922
|
+
content = `<slot name="${this.name}">
|
|
2923
|
+
<div s-empty="true" bs-empty="true" style="background: #f7f8fa;
|
|
2924
|
+
border: 1px dashed #c3c3c3;
|
|
2925
|
+
text-align: center;
|
|
2926
|
+
color: #999;
|
|
2927
|
+
min-height: 32px;
|
|
2928
|
+
min-width: 32px;
|
|
2929
|
+
width: 100%;
|
|
2930
|
+
align-items: center;
|
|
2931
|
+
display: inline-flex;
|
|
2932
|
+
justify-content: center;">
|
|
2933
|
+
+
|
|
2934
|
+
</div>
|
|
2935
|
+
</slot>`;
|
|
2936
|
+
} else {
|
|
2937
|
+
parts.push(`vusion-node-path="${this.nodePath}"`);
|
|
2938
|
+
content = `组件占位,可在使用业务组件时插入任意组件`;
|
|
2939
|
+
staticStyle += `background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
|
|
2940
|
+
background-size: 45px 45px;
|
|
2941
|
+
background-repeat: repeat;
|
|
2942
|
+
line-height: 32px;
|
|
2943
|
+
min-height: 32px;
|
|
2944
|
+
color: var(--font-second-color);
|
|
2945
|
+
text-align: center;`;
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
staticStyle && parts.push(`style="${staticStyle}"`);
|
|
2950
|
+
if (!content.length) {
|
|
2951
|
+
shouldIndent = false;
|
|
2952
|
+
}
|
|
2937
2953
|
let partsLength = 0;
|
|
2938
2954
|
let partsString = '';
|
|
2939
2955
|
parts.forEach((part) => {
|
|
@@ -2945,12 +2961,12 @@ export class ViewElement extends BaseNode {
|
|
|
2945
2961
|
partsLength += part.length;
|
|
2946
2962
|
});
|
|
2947
2963
|
let htmlContent =
|
|
2948
|
-
`<${
|
|
2964
|
+
`<${tag}${partsString.length ? partsString : ''}>` +
|
|
2949
2965
|
content +
|
|
2950
2966
|
(shouldIndent ? '\n' + tabString : '') +
|
|
2951
|
-
`</${
|
|
2952
|
-
if (!content.trim() && selfClosingTag.includes(
|
|
2953
|
-
htmlContent = `<${
|
|
2967
|
+
`</${tag}>`;
|
|
2968
|
+
if (!content.trim() && selfClosingTag.includes(tag)) {
|
|
2969
|
+
htmlContent = `<${tag}${partsString.length ? partsString : ''} />`;
|
|
2954
2970
|
}
|
|
2955
2971
|
return htmlContent;
|
|
2956
2972
|
}
|
package/src/concepts/View__.ts
CHANGED
|
@@ -1690,7 +1690,7 @@ export class View extends BaseNode {
|
|
|
1690
1690
|
newName = name.replace(/\d*$/, (m) => `_${BranchCopyUniCode}_${m}`);
|
|
1691
1691
|
}
|
|
1692
1692
|
// 主分支无 BranchCopyUniCode
|
|
1693
|
-
if (!BranchCopyUniCode && prefix?.
|
|
1693
|
+
if (!BranchCopyUniCode && prefix?.slice(-1) !== '_') {
|
|
1694
1694
|
newName = name.replace(/\d*$/, (m) => `_${m}`);
|
|
1695
1695
|
}
|
|
1696
1696
|
const newPrefix = newName.replace(/\d*$/, '');
|
|
@@ -1738,13 +1738,16 @@ export class View extends BaseNode {
|
|
|
1738
1738
|
|
|
1739
1739
|
public static readonly TAG_NAME_PREFIX_REG?: RegExp = /^([lieu]|van)[-_]/;
|
|
1740
1740
|
|
|
1741
|
-
mergeBlock({ code, nodePath, position, cb }: { code: string; nodePath: string; position: string; cb?: Function }) {
|
|
1741
|
+
mergeBlock({ code, nodePath, position, slotTarget, cb }: { code: string; nodePath: string; position: string; slotTarget?: string; cb?: Function }) {
|
|
1742
1742
|
const ViewElement = getConceptConstructor('ViewElement');
|
|
1743
1743
|
const Logic = getConceptConstructor('Logic');
|
|
1744
1744
|
const Param = getConceptConstructor('Param');
|
|
1745
1745
|
const Variable = getConceptConstructor('Variable');
|
|
1746
1746
|
const BindEvent = getConceptConstructor('BindEvent');
|
|
1747
|
-
|
|
1747
|
+
let template = utils.sliceTagContent(code, 'template');
|
|
1748
|
+
if (slotTarget) {
|
|
1749
|
+
template = `<template #${slotTarget}>${template}</template>`;
|
|
1750
|
+
}
|
|
1748
1751
|
let targetNode = this.app.findNodeByPath(nodePath);
|
|
1749
1752
|
let parentNode = position === 'append' ? targetNode : targetNode.parentNode;
|
|
1750
1753
|
if (parentNode.concept === 'View') {
|
|
@@ -1836,22 +1839,6 @@ export class View extends BaseNode {
|
|
|
1836
1839
|
});
|
|
1837
1840
|
}
|
|
1838
1841
|
|
|
1839
|
-
// 页面逻辑
|
|
1840
|
-
if (Array.isArray(definition.viewLogics)) {
|
|
1841
|
-
definition.viewLogics.forEach((logicOption: any) => {
|
|
1842
|
-
// 页面逻辑只有load函数的走之前的逻辑其余不用创建
|
|
1843
|
-
if (logicOption.name.startsWith('load')) {
|
|
1844
|
-
// const logic = Logic.from(
|
|
1845
|
-
// {
|
|
1846
|
-
// ...logicOption,
|
|
1847
|
-
// },
|
|
1848
|
-
// this,
|
|
1849
|
-
// 'logics'
|
|
1850
|
-
// );
|
|
1851
|
-
// this.addLogic(logic);
|
|
1852
|
-
}
|
|
1853
|
-
});
|
|
1854
|
-
}
|
|
1855
1842
|
// 页面事件
|
|
1856
1843
|
if (Array.isArray(definition.viewBindEvents)) {
|
|
1857
1844
|
definition.viewBindEvents.forEach((eventOption: any) => {
|