@lcap/nasl 3.8.0-beta.3 → 3.8.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/automate/engine/utils.js +1 -2
- package/out/automate/engine/utils.js.map +1 -1
- package/out/bak/translator.js +1 -1
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +7 -2
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.js +6 -1
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +11 -5
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +3 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +49 -2
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +4 -3
- package/out/concepts/BindAttribute__.js +121 -42
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js +5 -42
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +1 -0
- package/out/concepts/BusinessComponent__.js +16 -0
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +3 -0
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallConnector__.js +1 -1
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallFunction__.js +1 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +6 -1
- package/out/concepts/CallLogic__.js +58 -17
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Connection__.d.ts +4 -0
- package/out/concepts/Connection__.js +15 -0
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/DatabaseTypeAnnotation__.d.ts +2 -0
- package/out/concepts/DatabaseTypeAnnotation__.js +20 -0
- package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
- package/out/concepts/End__.js +5 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +2 -0
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +24 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +12 -0
- package/out/concepts/EnumItem__.js +49 -5
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +4 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +1 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +46 -46
- package/out/concepts/FrontendLibrary__.js +34 -36
- package/out/concepts/FrontendLibrary__.js.map +1 -1
- package/out/concepts/I18nInfo__.d.ts +1 -0
- package/out/concepts/I18nInfo__.js +7 -0
- package/out/concepts/I18nInfo__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +4 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +2 -3
- package/out/concepts/Logic__.js +33 -8
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +2 -2
- package/out/concepts/MatchCase__.js +7 -7
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/NewComposite__.js +2 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +2 -1
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js +2 -1
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +3 -11
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +7 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +2 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElementV2__.d.ts +4 -5
- package/out/concepts/ProcessElementV2__.js +12 -17
- package/out/concepts/ProcessElementV2__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +3 -4
- package/out/concepts/ProcessElement__.js +44 -46
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessV2__.d.ts +5 -0
- package/out/concepts/ProcessV2__.js +30 -2
- package/out/concepts/ProcessV2__.js.map +1 -1
- package/out/concepts/Process__.d.ts +5 -0
- package/out/concepts/Process__.js +28 -0
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +2 -2
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +2 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StaticString__.d.ts +4 -0
- package/out/concepts/StaticString__.js +11 -0
- package/out/concepts/StaticString__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +5 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +9 -3
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SubLogic__.d.ts +1 -3
- package/out/concepts/SubLogic__.js +14 -8
- package/out/concepts/SubLogic__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +1 -0
- package/out/concepts/Transactional__.js +7 -0
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +4 -0
- package/out/concepts/TypeParam__.js +3 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -6
- package/out/concepts/ValidationRule__.js +9 -6
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -1
- package/out/concepts/Variable__.js +7 -2
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +130 -47
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +8 -0
- package/out/concepts/View__.js +123 -7
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +2 -2
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.js +110 -4
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +2 -0
- package/out/generator/genBundleFiles.js +51 -37
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +20 -26
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/release-body/body.js +8 -6
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/index.d.ts +1 -0
- package/out/generator/release-body/index.js +1 -0
- package/out/generator/release-body/index.js.map +1 -1
- package/out/generator/release-body/utils.js +1 -1
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +56 -24
- package/out/natural/genNaturalTS.js +182 -112
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.js +4 -2
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +34 -25
- package/out/natural/getContext/index.js +304 -157
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/index.d.ts +1 -0
- package/out/natural/index.js +1 -0
- package/out/natural/index.js.map +1 -1
- package/out/natural/tools.d.ts +11 -0
- package/out/natural/tools.js +155 -0
- package/out/natural/tools.js.map +1 -0
- package/out/natural/transformTS2UI.js +84 -22
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.js +83 -22
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/formatTsUtils.js +17 -1
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +1 -4
- package/out/server/getLogics.js.map +1 -1
- package/out/server/naslServer.js +285 -32
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +5 -1
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCreateBlock.js +5 -18
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +11 -32
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +82 -59
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +4 -4
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -15
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/translator/types.d.ts +4 -0
- package/out/translator/utils.d.ts +1 -0
- package/out/translator/utils.js +6 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/env.d.ts +4 -0
- package/out/utils/env.js +6 -3
- package/out/utils/env.js.map +1 -1
- package/out/utils/index.d.ts +19 -0
- package/out/utils/index.js +61 -1
- package/out/utils/index.js.map +1 -1
- package/out/utils/language-cache/constant.d.ts +18 -0
- package/out/utils/language-cache/constant.js +35 -0
- package/out/utils/language-cache/constant.js.map +1 -0
- package/out/utils/language-cache/index.d.ts +2 -0
- package/out/utils/language-cache/index.js +19 -0
- package/out/utils/language-cache/index.js.map +1 -0
- package/out/utils/language-cache/nasl.d.ts +10 -0
- package/out/utils/language-cache/nasl.js +98 -0
- package/out/utils/language-cache/nasl.js.map +1 -0
- package/out/utils/language-cache/types.d.ts +44 -0
- package/out/utils/language-cache/types.js +4 -0
- package/out/utils/language-cache/types.js.map +1 -0
- package/out/utils/time-slicing/controller.js.map +1 -1
- package/out/utils/types.d.ts +17 -0
- package/package.json +3 -2
- package/sandbox/stdlib/nasl.core.ts +15 -11
- package/sandbox/stdlib/nasl.oql.ts +5 -1
- package/sandbox/stdlib/nasl.processV2.ts +5 -4
- package/sandbox/stdlib/nasl.ui.components.pc.ts +225 -225
- package/sandbox/stdlib/nasl.ui.ts +10 -0
- package/sandbox/stdlib/nasl.util.ts +11 -0
- package/sandbox/stdlib/nasl.validation.ts +3 -2
- package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +1 -1
- package/sandbox-natural/stdlib/nasl.ui.ts +2 -2
- package/sandbox-natural/stdlib/nasl.util.ts +2 -2
- package/src/automate/engine/utils.js +1 -2
- package/src/bak/translator.js +1 -1
- package/src/common/BaseNode.ts +7 -3
- package/src/concepts/App__.ts +9 -1
- package/src/concepts/Argument__.ts +10 -5
- package/src/concepts/AuthLogicForCallInterface__.ts +3 -0
- package/src/concepts/BinaryExpression__.ts +46 -2
- package/src/concepts/BindAttribute__.ts +144 -46
- package/src/concepts/BindEvent__.ts +8 -47
- package/src/concepts/BusinessComponent__.ts +17 -0
- package/src/concepts/BusinessLogic__.ts +3 -0
- package/src/concepts/CallConnector__.ts +1 -1
- package/src/concepts/CallFunction__.ts +1 -1
- package/src/concepts/CallLogic__.ts +63 -17
- package/src/concepts/Connection__.ts +16 -0
- package/src/concepts/DatabaseTypeAnnotation__.ts +11 -0
- package/src/concepts/End__.ts +5 -1
- package/src/concepts/EntityProperty__.ts +5 -0
- package/src/concepts/Entity__.ts +29 -1
- package/src/concepts/EnumItem__.ts +64 -1
- package/src/concepts/Enum__.ts +6 -1
- package/src/concepts/ForEachStatement__.ts +1 -1
- package/src/concepts/FrontendLibrary__.ts +78 -80
- package/src/concepts/I18nInfo__.ts +5 -0
- package/src/concepts/IfStatement__.ts +2 -2
- package/src/concepts/Interface__.ts +6 -1
- package/src/concepts/Logic__.ts +39 -10
- package/src/concepts/MatchCase__.ts +8 -9
- package/src/concepts/NewComposite__.ts +2 -1
- package/src/concepts/NewList__.ts +2 -1
- package/src/concepts/NewMap__.ts +2 -1
- package/src/concepts/OqlQueryComponent__.ts +3 -11
- package/src/concepts/OverriddenLogic__.ts +7 -0
- package/src/concepts/Param__.ts +1 -0
- package/src/concepts/ProcessElementV2__.ts +14 -16
- package/src/concepts/ProcessElement__.ts +16 -16
- package/src/concepts/ProcessV2__.ts +39 -3
- package/src/concepts/Process__.ts +36 -0
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/Return__.ts +2 -1
- package/src/concepts/StaticString__.ts +12 -0
- package/src/concepts/StructureProperty__.ts +7 -2
- package/src/concepts/Structure__.ts +11 -3
- package/src/concepts/SubLogic__.ts +15 -9
- package/src/concepts/Transactional__.ts +5 -0
- package/src/concepts/TypeParam__.ts +6 -0
- package/src/concepts/ValidationRule__.ts +7 -6
- package/src/concepts/Variable__.ts +7 -2
- package/src/concepts/ViewElement__.ts +130 -47
- package/src/concepts/View__.ts +157 -8
- package/src/concepts/basics/stdlib/nasl.processV2.ts +2 -2
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.validation.ts +111 -4
- package/src/generator/genBundleFiles.ts +53 -39
- package/src/generator/genMetaData.ts +21 -26
- package/src/generator/release-body/body.ts +9 -6
- package/src/generator/release-body/index.ts +1 -0
- package/src/generator/release-body/utils.ts +4 -2
- package/src/natural/genNaturalTS.ts +327 -141
- package/src/natural/getContext/getUILib.ts +4 -2
- package/src/natural/getContext/index.ts +348 -171
- package/src/natural/index.ts +1 -0
- package/src/natural/tools.ts +130 -0
- package/src/natural/transformTS2UI.ts +84 -22
- package/src/natural/transformTSCode.ts +83 -22
- package/src/server/formatTsUtils.ts +21 -1
- package/src/server/getLogics.ts +1 -4
- package/src/server/naslServer.ts +302 -33
- package/src/server/translator.ts +5 -1
- package/src/templator/genCreateBlock.ts +5 -18
- package/src/templator/genCurdMultipleKeyBlock.ts +14 -32
- package/src/templator/genGetBlock.ts +2 -4
- package/src/templator/genListViewBlock.ts +6 -4
- package/src/templator/genSelectBlock.ts +88 -61
- package/src/templator/genTableBlock.ts +4 -4
- package/src/templator/genUpdateBlock.ts +2 -15
- package/src/templator/utils.ts +1 -1
- package/src/translator/types.ts +4 -0
- package/src/translator/utils.ts +6 -0
- package/src/utils/env.ts +5 -4
- package/src/utils/index.ts +50 -1
- package/src/utils/language-cache/constant.ts +37 -0
- package/src/utils/language-cache/index.ts +2 -0
- package/src/utils/language-cache/nasl.ts +83 -0
- package/src/utils/language-cache/types.ts +48 -0
- package/src/utils/time-slicing/controller.ts +0 -1
- package/src/utils/types.ts +20 -0
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +13 -13
- package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +12 -12
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +1 -2
- package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +221 -217
- package/ts-worker/bundle.js +1 -1
- package/ts-worker/src/index.js +0 -1
- package/out/utils/delay/index.d.ts +0 -0
- package/out/utils/delay/index.js +0 -1
- package/out/utils/delay/index.js.map +0 -1
- package/src/utils/delay/index.ts +0 -0
|
@@ -536,39 +536,18 @@ export class BindEvent extends BaseNode {
|
|
|
536
536
|
if (logic.name.startsWith('__')) {
|
|
537
537
|
return;
|
|
538
538
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
try {
|
|
546
|
-
code += yield* logic.toEmbeddedTS(
|
|
547
|
-
shiftState(state, code, {
|
|
548
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
549
|
-
}),
|
|
550
|
-
'noExport',
|
|
551
|
-
);
|
|
552
|
-
} finally {
|
|
553
|
-
// 翻译logic可能出错
|
|
554
|
-
logic.name = logicName;
|
|
555
|
-
}
|
|
556
|
-
} else {
|
|
557
|
-
code += yield* logic.toEmbeddedTS(
|
|
558
|
-
shiftState(state, code, {
|
|
559
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
560
|
-
}),
|
|
561
|
-
'noExport',
|
|
562
|
-
);
|
|
563
|
-
}
|
|
539
|
+
code += yield* logic.toEmbeddedTS(
|
|
540
|
+
shiftState(state, code, {
|
|
541
|
+
tabSize: (state?.tabSize || 0) + 2,
|
|
542
|
+
}),
|
|
543
|
+
'noExport',
|
|
544
|
+
);
|
|
564
545
|
code += indent(state?.tabSize || 0);
|
|
565
546
|
code += ',\n';
|
|
566
547
|
});
|
|
567
548
|
code += '];\n';
|
|
568
549
|
} else {
|
|
569
550
|
yield* wrapForEach(self.logics, function* warpForEachGenerator(logic, index) {
|
|
570
|
-
const logicName = logic.name;
|
|
571
|
-
logic.name = logic.likeComponent.name + logic.name + index;
|
|
572
551
|
code += yield* logic.toEmbeddedTS(
|
|
573
552
|
shiftState(state, code, {
|
|
574
553
|
tabSize: (state?.tabSize || 0) + 2,
|
|
@@ -576,8 +555,7 @@ export class BindEvent extends BaseNode {
|
|
|
576
555
|
'noExport',
|
|
577
556
|
);
|
|
578
557
|
code += indent(state?.tabSize || 0);
|
|
579
|
-
code += `${logic.
|
|
580
|
-
logic.name = logicName;
|
|
558
|
+
code += `${logic.tsName}();\n`;
|
|
581
559
|
});
|
|
582
560
|
}
|
|
583
561
|
return code;
|
|
@@ -598,24 +576,7 @@ export class BindEvent extends BaseNode {
|
|
|
598
576
|
if (logic.name.startsWith('__')) {
|
|
599
577
|
return;
|
|
600
578
|
}
|
|
601
|
-
if (logic.
|
|
602
|
-
const logicName = logic.name;
|
|
603
|
-
if ((logic.parentNode as BindEvent)?.element) {
|
|
604
|
-
logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
|
|
605
|
-
}
|
|
606
|
-
logic.name = logic.name.replace(/-/g, '');
|
|
607
|
-
try {
|
|
608
|
-
code += yield* logic.toEmbeddedTS(
|
|
609
|
-
shiftState(state, code, {
|
|
610
|
-
tabSize: (state?.tabSize || 0) + 2,
|
|
611
|
-
}),
|
|
612
|
-
'noExport',
|
|
613
|
-
);
|
|
614
|
-
} finally {
|
|
615
|
-
// 翻译logic可能出错
|
|
616
|
-
logic.name = logicName;
|
|
617
|
-
}
|
|
618
|
-
} else if (logic.processV2) {
|
|
579
|
+
if (logic.processV2) {
|
|
619
580
|
code += yield* logic.toEmbeddedTSInProcess(
|
|
620
581
|
shiftState(state, code, {
|
|
621
582
|
tabSize: (state?.tabSize || 0) + 2,
|
|
@@ -1841,6 +1841,10 @@ export class BusinessComponent extends BaseNode {
|
|
|
1841
1841
|
const calleeLogic = (this.getAncestor('App') as App).logics.find((l) => l.name === calleeName);
|
|
1842
1842
|
return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
|
|
1843
1843
|
}
|
|
1844
|
+
// 调用依赖库逻辑可能会有子逻辑,子逻辑拼接可能有ts忽略先去掉
|
|
1845
|
+
if (asserts.isCallLogic(rightNode) && rightNode.calleeNamespace?.startsWith('extensions.')) {
|
|
1846
|
+
code = code.replaceAll('// @ts-ignore', '');
|
|
1847
|
+
}
|
|
1844
1848
|
|
|
1845
1849
|
// view 局部变量,申明提升前增加判断,使用 logic 内的 result 直接替换成对应 logic,logic 内部变量替换成 null
|
|
1846
1850
|
if (logicRtn && code.includes(logicRtn.name)) {
|
|
@@ -2004,6 +2008,9 @@ export class BusinessComponent extends BaseNode {
|
|
|
2004
2008
|
// 内置函数对集合类型的推导
|
|
2005
2009
|
(asserts.isCallFunction(el) && el.derivablecollection?.name))
|
|
2006
2010
|
) {
|
|
2011
|
+
if (el?.getAncestor('SubLogic')) {
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2007
2014
|
if (asserts.isAssignment(el)) {
|
|
2008
2015
|
const advanceVar = self.variables?.find(
|
|
2009
2016
|
(variable) => !variable.typeAnnotation && el.left?.name === variable.name,
|
|
@@ -2458,6 +2465,16 @@ export class BusinessComponent extends BaseNode {
|
|
|
2458
2465
|
});
|
|
2459
2466
|
return Array.from(res);
|
|
2460
2467
|
}
|
|
2468
|
+
|
|
2469
|
+
getViewCallLogics(): string[] {
|
|
2470
|
+
const callbackLogics: string[] = [];
|
|
2471
|
+
this.traverseChildren((el) => {
|
|
2472
|
+
if (asserts.isIdentifier(el) && el.namespace?.endsWith('logics')) {
|
|
2473
|
+
callbackLogics.push(`${el.namespace}.${el.name}`);
|
|
2474
|
+
}
|
|
2475
|
+
});
|
|
2476
|
+
return callbackLogics;
|
|
2477
|
+
}
|
|
2461
2478
|
//================================================================================
|
|
2462
2479
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
2463
2480
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -145,6 +145,9 @@ export class BusinessLogic extends Logic {
|
|
|
145
145
|
// 内置函数对集合类型的推导
|
|
146
146
|
(asserts.isCallFunction(el) && el.derivablecollection?.name))
|
|
147
147
|
) {
|
|
148
|
+
if (el?.getAncestor('SubLogic')) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
148
151
|
if (asserts.isAssignment(el)) {
|
|
149
152
|
const advanceVar = self.variables?.find(
|
|
150
153
|
(variable) => !variable.typeAnnotation && el.left?.name === variable.name,
|
|
@@ -98,7 +98,7 @@ export class CallConnector extends CallLogic {
|
|
|
98
98
|
if (this.calleeConnectionName) {
|
|
99
99
|
let tsName = this.calleeConnectionName;
|
|
100
100
|
// 匹配所有特殊字符都转为_
|
|
101
|
-
tsName = tsName.replace(
|
|
101
|
+
tsName = tsName.replace(/[^\w\u4e00-\u9fa5]/g, '_');
|
|
102
102
|
if (/^\d/.test(tsName)) {
|
|
103
103
|
tsName = `$${tsName}`;
|
|
104
104
|
}
|
|
@@ -690,7 +690,7 @@ export class CallFunction extends LogicItem {
|
|
|
690
690
|
if (!arg) {
|
|
691
691
|
code += '__IDENTIFIER__';
|
|
692
692
|
} else {
|
|
693
|
-
code += arg.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
693
|
+
code += indent(state.tabSize + 1) + arg.toNaturalTS(shiftState(state, code, { inline: true, tabSize: state.tabSize + 1 }));
|
|
694
694
|
}
|
|
695
695
|
if (index !== this.arguments.length - 1) {
|
|
696
696
|
code += ',\n';
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import type { ViewElement, ElementToVueOptions } from './ViewElement__';
|
|
26
26
|
import type { MemberExpression } from './MemberExpression__';
|
|
27
27
|
import type { StringLiteral } from './StringLiteral__';
|
|
28
|
+
import type { TypeParam } from './TypeParam__';
|
|
28
29
|
|
|
29
30
|
//================================================================================
|
|
30
31
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -965,7 +966,7 @@ export class CallLogic extends LogicItem {
|
|
|
965
966
|
if (isSpreadFunc) {
|
|
966
967
|
spreadParams = formatArgs.pop();
|
|
967
968
|
}
|
|
968
|
-
const
|
|
969
|
+
const filterArgs = formatArgs
|
|
969
970
|
.map((arg, index) => {
|
|
970
971
|
const actualArg = completeArguments[index];
|
|
971
972
|
const keyword = arg?.name;
|
|
@@ -976,10 +977,18 @@ export class CallLogic extends LogicItem {
|
|
|
976
977
|
})
|
|
977
978
|
.filter((item) => {
|
|
978
979
|
return isShowArgument(item.arg);
|
|
979
|
-
})
|
|
980
|
+
});
|
|
981
|
+
const argsStr = filterArgs
|
|
980
982
|
.map((obj) => `\n${obj?.keyword}: ${obj?.arg?.toJS(state)}`)
|
|
981
983
|
.join(', ');
|
|
984
|
+
|
|
982
985
|
code += argsStr;
|
|
986
|
+
// 如果参数长度不为 0,则表示有参数,需要添加逗号
|
|
987
|
+
// 放弃开头加逗号的写法,因为这样会导致参数为空的时候,会多一个逗号
|
|
988
|
+
// https://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2851152441926912
|
|
989
|
+
if (filterArgs.length) {
|
|
990
|
+
code += ', ';
|
|
991
|
+
}
|
|
983
992
|
// 如果是可变参数,需要单独处理
|
|
984
993
|
if (isSpreadFunc) {
|
|
985
994
|
const spreadArg = completeArguments.slice(formatArgs.length);
|
|
@@ -989,11 +998,11 @@ export class CallLogic extends LogicItem {
|
|
|
989
998
|
})
|
|
990
999
|
.map((arg) => arg?.toJS?.(state) || '')
|
|
991
1000
|
.join(', ');
|
|
992
|
-
code +=
|
|
1001
|
+
code += `\n${spreadParams.name}: [${spreadArgStr}], `;
|
|
993
1002
|
}
|
|
994
1003
|
|
|
995
1004
|
if (Array.isArray(completeTypeArguments) && completeTypeArguments.length) {
|
|
996
|
-
code +=
|
|
1005
|
+
code += `\n__typeArguments: ${JSON5.stringify(completeTypeArguments)}`;
|
|
997
1006
|
}
|
|
998
1007
|
}
|
|
999
1008
|
code += '\n}';
|
|
@@ -1320,21 +1329,21 @@ export class CallLogic extends LogicItem {
|
|
|
1320
1329
|
// 统一处理需要有泛型的 调用逻辑,其余的走老逻辑
|
|
1321
1330
|
if (completeTypeParams.length) {
|
|
1322
1331
|
code += '(() =>{';
|
|
1323
|
-
code += '\nconst
|
|
1332
|
+
code += '\nconst __genericWrapper = ';
|
|
1324
1333
|
code += calleeKey;
|
|
1325
1334
|
yield* setInputParam();
|
|
1326
|
-
code += ';\nconst
|
|
1327
|
-
code += '
|
|
1335
|
+
code += ';\nconst __warpperRes =';
|
|
1336
|
+
code += '__genericWrapper';
|
|
1328
1337
|
yield* setNeedCompleteTypeArguments();
|
|
1329
|
-
code += '();\nconst
|
|
1338
|
+
code += '();\nconst __wrapper =';
|
|
1330
1339
|
if (handleError) {
|
|
1331
1340
|
code += 'nasl.util.autoTypeHandleError(';
|
|
1332
1341
|
}
|
|
1333
|
-
code += '
|
|
1342
|
+
code += '__warpperRes[0]';
|
|
1334
1343
|
if (handleError) {
|
|
1335
1344
|
code += ')';
|
|
1336
1345
|
}
|
|
1337
|
-
code += ';\nreturn
|
|
1346
|
+
code += ';\nreturn __wrapper';
|
|
1338
1347
|
code += ';\n})()';
|
|
1339
1348
|
setEndSemi();
|
|
1340
1349
|
return code;
|
|
@@ -1363,7 +1372,7 @@ export class CallLogic extends LogicItem {
|
|
|
1363
1372
|
}
|
|
1364
1373
|
|
|
1365
1374
|
if (!state.callLogicNoIife && useIife) {
|
|
1366
|
-
code += '(() =>{\nconst
|
|
1375
|
+
code += '(() =>{\nconst __wrapper = ';
|
|
1367
1376
|
if (handleError) {
|
|
1368
1377
|
code += 'nasl.util.autoHandleError(';
|
|
1369
1378
|
}
|
|
@@ -1382,7 +1391,7 @@ export class CallLogic extends LogicItem {
|
|
|
1382
1391
|
if (handleError) {
|
|
1383
1392
|
code += ')';
|
|
1384
1393
|
}
|
|
1385
|
-
code += ';\nreturn
|
|
1394
|
+
code += ';\nreturn __wrapper';
|
|
1386
1395
|
yield* setInputParam();
|
|
1387
1396
|
code += ';\n})()';
|
|
1388
1397
|
} else {
|
|
@@ -1430,8 +1439,8 @@ export class CallLogic extends LogicItem {
|
|
|
1430
1439
|
|
|
1431
1440
|
let code = '';
|
|
1432
1441
|
let calleeKey = this.calleeKey.replace('__elements', '$refs');
|
|
1433
|
-
if (/^app.+?\.entities\..+?logics/.test(calleeKey))
|
|
1434
|
-
|
|
1442
|
+
// if (/^app.+?\.entities\..+?logics/.test(calleeKey))
|
|
1443
|
+
// calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$1Entity');
|
|
1435
1444
|
/** 设置函数范型参数 */
|
|
1436
1445
|
const setTypeArguments = () => {
|
|
1437
1446
|
if (Array.isArray(typeArguments) && typeArguments.length) {
|
|
@@ -1612,7 +1621,14 @@ export class CallLogic extends LogicItem {
|
|
|
1612
1621
|
const characterOffset = 7;
|
|
1613
1622
|
const code = getCode();
|
|
1614
1623
|
const lines = code.split('\n');
|
|
1615
|
-
|
|
1624
|
+
let lineOffset = 0;
|
|
1625
|
+
// nasl的 check 不让用 findLastIndex,自己写个for循环
|
|
1626
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
1627
|
+
if (lines[i]?.startsWith('const __warpperRes')) {
|
|
1628
|
+
lineOffset = i;
|
|
1629
|
+
break;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1616
1632
|
return {
|
|
1617
1633
|
line: range.start.line + lineOffset + 1,
|
|
1618
1634
|
offset: characterOffset,
|
|
@@ -1621,7 +1637,7 @@ export class CallLogic extends LogicItem {
|
|
|
1621
1637
|
const characterOffset = 8;
|
|
1622
1638
|
const code = getCode();
|
|
1623
1639
|
const lines = code.split('\n');
|
|
1624
|
-
const lineOffset = lines.findIndex((item) => item.startsWith('return
|
|
1640
|
+
const lineOffset = lines.findIndex((item) => item.startsWith('return __wrapper'));
|
|
1625
1641
|
|
|
1626
1642
|
return {
|
|
1627
1643
|
line: range.start.line + lineOffset + 1,
|
|
@@ -1631,7 +1647,19 @@ export class CallLogic extends LogicItem {
|
|
|
1631
1647
|
// 怕改坏其他地方,业务组件单独处理
|
|
1632
1648
|
return getBusinessComponentCallExpressionQuickInfo(range, getCode);
|
|
1633
1649
|
} else {
|
|
1634
|
-
|
|
1650
|
+
const result = getCallExpressionQuickInfo(range, getCode);
|
|
1651
|
+
let code = getCode();
|
|
1652
|
+
if(code.includes('__elements.')){
|
|
1653
|
+
const prefixOffset = code.indexOf('__elements.');
|
|
1654
|
+
code = code.slice(prefixOffset);
|
|
1655
|
+
let indexOf = code.indexOf('(');
|
|
1656
|
+
const subStr = code.substring(0, indexOf);
|
|
1657
|
+
const codeArr = subStr?.split('.');
|
|
1658
|
+
const lastLen = codeArr?.[codeArr.length - 1]?.length;
|
|
1659
|
+
indexOf = subStr.length - lastLen;
|
|
1660
|
+
result.offset = result.offset + prefixOffset + indexOf;
|
|
1661
|
+
}
|
|
1662
|
+
return result;
|
|
1635
1663
|
}
|
|
1636
1664
|
}
|
|
1637
1665
|
|
|
@@ -1712,6 +1740,24 @@ export class CallLogic extends LogicItem {
|
|
|
1712
1740
|
}
|
|
1713
1741
|
return this.typeArguments;
|
|
1714
1742
|
}
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* 获取需要用户手动选择的参数列表 的原始范型参数
|
|
1746
|
+
*/
|
|
1747
|
+
get needCompleteTypeArgumentGenerics() {
|
|
1748
|
+
if (this.completeTypeParams?.length) {
|
|
1749
|
+
const typeParams: TypeParam[] = [];
|
|
1750
|
+
this.completeTypeParams.forEach((typeParam, typeIndex) => {
|
|
1751
|
+
if (typeParam.needChoose && this.typeArguments?.[typeIndex]) {
|
|
1752
|
+
typeParams.push(typeParam);
|
|
1753
|
+
}
|
|
1754
|
+
});
|
|
1755
|
+
return typeParams;
|
|
1756
|
+
}
|
|
1757
|
+
return [];
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
|
|
1715
1761
|
static isSystem(node: CallLogic) {
|
|
1716
1762
|
// 如此处需要更新,则需同时更新 menu-poppup 组件下的 includesSystemLogic 校验逻辑
|
|
1717
1763
|
return ['nasl.process', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.io'].includes(
|
|
@@ -375,6 +375,22 @@ export class Connection extends BaseNode {
|
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
/**
|
|
379
|
+
* 获取当前的TsName
|
|
380
|
+
*/
|
|
381
|
+
get tsName() {
|
|
382
|
+
if (this.name) {
|
|
383
|
+
let tsName = this.name;
|
|
384
|
+
// 匹配所有非数字、字母、中文字符都转为_
|
|
385
|
+
tsName = tsName.replace(/[^\w\u4e00-\u9fa5]/g, '_');
|
|
386
|
+
if (/^\d/.test(tsName)) {
|
|
387
|
+
tsName = `$${tsName}`;
|
|
388
|
+
}
|
|
389
|
+
return tsName;
|
|
390
|
+
}
|
|
391
|
+
return '';
|
|
392
|
+
}
|
|
393
|
+
|
|
378
394
|
@withSourceMapGenerator
|
|
379
395
|
*toEmbeddedTS(
|
|
380
396
|
state = createCompilerState(),
|
|
@@ -62,7 +62,18 @@ export class DatabaseTypeAnnotation extends BaseNode {
|
|
|
62
62
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
63
63
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
64
64
|
//================================================================================
|
|
65
|
+
@withSourceMap()
|
|
66
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
65
69
|
|
|
70
|
+
@withSourceMap()
|
|
71
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
72
|
+
let code = createDecoratorCode(state, this, ['typeName', 'arguments'], {
|
|
73
|
+
concept: true,
|
|
74
|
+
});
|
|
75
|
+
return code;
|
|
76
|
+
}
|
|
66
77
|
//================================================================================
|
|
67
78
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
68
79
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
package/src/concepts/End__.ts
CHANGED
|
@@ -108,6 +108,9 @@ export class End extends LogicItem {
|
|
|
108
108
|
case 'OverriddenLogic':
|
|
109
109
|
ret = self.OverriddenLogic.returns[0];
|
|
110
110
|
break;
|
|
111
|
+
case 'SubLogic':
|
|
112
|
+
ret = self.parentNode?.returns?.[0];
|
|
113
|
+
break;
|
|
111
114
|
default:
|
|
112
115
|
// 旧逻辑默认走这里,
|
|
113
116
|
// 期望后期可以直接走完整的case, default 直接抛出异常好更明确定位错误
|
|
@@ -116,7 +119,8 @@ export class End extends LogicItem {
|
|
|
116
119
|
self.parentNode.getAncestor('Logic') ||
|
|
117
120
|
self.parentNode.getAncestor('AuthLogic') ||
|
|
118
121
|
self.parentNode.getAncestor('AuthLogicForCallInterface') ||
|
|
119
|
-
self.parentNode.getAncestor('OverriddenLogic')
|
|
122
|
+
self.parentNode.getAncestor('OverriddenLogic') ||
|
|
123
|
+
self.parentNode.getAncestor('SubLogic');
|
|
120
124
|
ret = (logic as Logic).returns[0];
|
|
121
125
|
}
|
|
122
126
|
if (ret && self.parentNode.concept === 'AuthLogicForCallInterface') {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
withGenerator,
|
|
11
11
|
TranslatorGenerator,
|
|
12
12
|
createDecoratorCode,
|
|
13
|
+
createDescriptionComment,
|
|
13
14
|
} from '../translator';
|
|
14
15
|
import type CallQueryComponent from './CallQueryComponent__';
|
|
15
16
|
|
|
@@ -477,6 +478,10 @@ export class EntityProperty extends BaseNode {
|
|
|
477
478
|
@withSourceMap()
|
|
478
479
|
toNaturalTS(state = createCompilerState()): string {
|
|
479
480
|
let code = '';
|
|
481
|
+
|
|
482
|
+
if (state.descriptionComment)
|
|
483
|
+
code += createDescriptionComment(state, this, ['label', 'description']);
|
|
484
|
+
|
|
480
485
|
if (this.relationNamespace && this.relationEntity && this.relationProperty) {
|
|
481
486
|
code += `@EntityRelation(() => new ${this.relationEntity}().${this.relationProperty})\n`;
|
|
482
487
|
code += indent(state.tabSize);
|
package/src/concepts/Entity__.ts
CHANGED
|
@@ -11,12 +11,15 @@ import {
|
|
|
11
11
|
withGenerator,
|
|
12
12
|
TranslatorGenerator,
|
|
13
13
|
createDecoratorCode,
|
|
14
|
+
createDescriptionComment,
|
|
14
15
|
} from '../translator';
|
|
15
16
|
import { entity2LogicNamespace } from '../server/entity2LogicNamespace';
|
|
16
17
|
import type CallQueryComponent from './CallQueryComponent__';
|
|
17
18
|
import Module from './Module__';
|
|
18
19
|
import DataSource from './DataSource__';
|
|
19
20
|
import View from './View__';
|
|
21
|
+
import ProcessV2 from './ProcessV2__';
|
|
22
|
+
|
|
20
23
|
//================================================================================
|
|
21
24
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
22
25
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -837,7 +840,11 @@ export class Entity extends Annotatable {
|
|
|
837
840
|
|
|
838
841
|
@withSourceMap()
|
|
839
842
|
toNaturalTS(state = createCompilerState(), entityName?: string): string {
|
|
840
|
-
let code =
|
|
843
|
+
let code = '';
|
|
844
|
+
if (state.descriptionComment)
|
|
845
|
+
code += createDescriptionComment(state, this, ['description']);
|
|
846
|
+
code = `class ${this?.name} {\n`;
|
|
847
|
+
|
|
841
848
|
this.properties.forEach((property) => {
|
|
842
849
|
code += `${property.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }))};\n`;
|
|
843
850
|
});
|
|
@@ -961,6 +968,27 @@ export class Entity extends Annotatable {
|
|
|
961
968
|
});
|
|
962
969
|
return res;
|
|
963
970
|
}
|
|
971
|
+
|
|
972
|
+
syncProcessPermission(propertyNames: string[]) {
|
|
973
|
+
const path = `${this.ns?.path}.${this.name}`
|
|
974
|
+
const bindProcessV2s = this.app?.processV2s.filter((processV2) => `${processV2.bind.refNamespace}.${processV2.bind.refName}` === path) || []
|
|
975
|
+
bindProcessV2s.forEach((processV2) => {
|
|
976
|
+
processV2.elements.forEach((ele) => {
|
|
977
|
+
if (['InitiateTask', 'ApprovalTask'].includes(ele.type)) {
|
|
978
|
+
const fieldPermissions = propertyNames.map((propertyName: string) => {
|
|
979
|
+
return {
|
|
980
|
+
concept: 'FieldPermissionV2',
|
|
981
|
+
propertyName,
|
|
982
|
+
permission: 'hidden',
|
|
983
|
+
}
|
|
984
|
+
})
|
|
985
|
+
ele.update({
|
|
986
|
+
fieldPermissions: [...ele.fieldPermissions, ...fieldPermissions]
|
|
987
|
+
})
|
|
988
|
+
}
|
|
989
|
+
})
|
|
990
|
+
})
|
|
991
|
+
}
|
|
964
992
|
//================================================================================
|
|
965
993
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
966
994
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
TranslatorGenerator,
|
|
9
9
|
indent,
|
|
10
10
|
createDecoratorCode,
|
|
11
|
+
createDescriptionComment,
|
|
11
12
|
} from '../translator';
|
|
12
13
|
import type Namespace from './Namespace__';
|
|
13
14
|
import Enum from './Enum__';
|
|
@@ -106,6 +107,62 @@ export class EnumItem extends BaseNode {
|
|
|
106
107
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
107
108
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
108
109
|
//================================================================================
|
|
110
|
+
/**
|
|
111
|
+
* 删除静态字符串
|
|
112
|
+
* @param name 静态字符串名称
|
|
113
|
+
*/
|
|
114
|
+
removeLabel(name: string): void;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 删除静态字符串
|
|
118
|
+
* @param label 已有的静态字符串实例
|
|
119
|
+
*/
|
|
120
|
+
removeLabel(label: StaticString): void;
|
|
121
|
+
|
|
122
|
+
removeLabel(options: string | StaticString) {
|
|
123
|
+
let label: StaticString;
|
|
124
|
+
if (typeof options === 'string') {
|
|
125
|
+
label = this.label;
|
|
126
|
+
if (!label) {
|
|
127
|
+
throw new Error('找不到静态字符串 ' + options);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
label = options;
|
|
131
|
+
}
|
|
132
|
+
return label.delete();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
__removeStaticString(staticString: StaticString) {
|
|
136
|
+
const parentKey = staticString.parentKey;
|
|
137
|
+
const params: Params = {
|
|
138
|
+
parentNode: this,
|
|
139
|
+
parentKey,
|
|
140
|
+
index: -1,
|
|
141
|
+
object: null,
|
|
142
|
+
oldObject: staticString,
|
|
143
|
+
};
|
|
144
|
+
if (parentKey) {
|
|
145
|
+
params.parentKey = parentKey;
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
const t = this.__v_raw || this;
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
const n = staticString.__v_raw || staticString;
|
|
150
|
+
if (Array.isArray((t as any)[parentKey])) {
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
153
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
154
|
+
params.index = index;
|
|
155
|
+
} else {
|
|
156
|
+
const q = (t as any)[parentKey];
|
|
157
|
+
if ((q.__v_raw || q) === n) {
|
|
158
|
+
params.index = 0;
|
|
159
|
+
(this as any)[parentKey] = undefined;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return params;
|
|
164
|
+
}
|
|
165
|
+
|
|
109
166
|
/**
|
|
110
167
|
* 祖先 Enum
|
|
111
168
|
*/
|
|
@@ -151,7 +208,13 @@ export class EnumItem extends BaseNode {
|
|
|
151
208
|
|
|
152
209
|
@withSourceMap()
|
|
153
210
|
toNaturalTS(state = createCompilerState()): string {
|
|
154
|
-
|
|
211
|
+
let code = '';
|
|
212
|
+
|
|
213
|
+
if (state.descriptionComment)
|
|
214
|
+
code += createDescriptionComment(state, this, ['label']);
|
|
215
|
+
code += `'${this.value}' = '${this.label?.value}'`;
|
|
216
|
+
|
|
217
|
+
return code;
|
|
155
218
|
}
|
|
156
219
|
|
|
157
220
|
@withSourceMap()
|
package/src/concepts/Enum__.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
withGenerator,
|
|
11
11
|
TranslatorGenerator,
|
|
12
12
|
createDecoratorCode,
|
|
13
|
+
createDescriptionComment,
|
|
13
14
|
} from '../translator';
|
|
14
15
|
import type Namespace from './Namespace__';
|
|
15
16
|
import type Identifier from './Identifier__';
|
|
@@ -317,7 +318,11 @@ export class Enum extends BaseNode {
|
|
|
317
318
|
|
|
318
319
|
@withSourceMap()
|
|
319
320
|
toNaturalTS(state = createCompilerState()): string {
|
|
320
|
-
let code =
|
|
321
|
+
let code = '';
|
|
322
|
+
if (state.descriptionComment)
|
|
323
|
+
code += createDescriptionComment(state, this, ['label', 'description']);
|
|
324
|
+
|
|
325
|
+
code += `enum ${this.name} {\n`;
|
|
321
326
|
this.enumItems.forEach((item) => {
|
|
322
327
|
code += indent(state.tabSize + 1);
|
|
323
328
|
code += item.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
|
|
@@ -472,7 +472,7 @@ export class ForEachStatement extends LogicItem {
|
|
|
472
472
|
if (state?.focusedNodePath === `${this?.nodePath}.body[${this.body?.length}]`)
|
|
473
473
|
code += `${indent((state?.tabSize || 0) + 1)}/* 当前位置 */\n`;
|
|
474
474
|
|
|
475
|
-
code += `${indent(state.tabSize)}
|
|
475
|
+
code += `${indent(state.tabSize)}}\n`;
|
|
476
476
|
|
|
477
477
|
return code;
|
|
478
478
|
}
|