@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
|
@@ -956,30 +956,42 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
956
956
|
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
957
957
|
let levelIndex = parentLevel || 0;
|
|
958
958
|
code += `${self.name}: () => {\n`;
|
|
959
|
-
const
|
|
960
|
-
let
|
|
959
|
+
const getMultipleDefaultValue = (name) => {
|
|
960
|
+
let v = 'new nasl.core.BooleanFalse()';
|
|
961
961
|
const attr = self.bindAttrs?.find((attr) => attr.name === name);
|
|
962
962
|
if (['static', 'string'].includes(attr?.type)) {
|
|
963
|
-
|
|
963
|
+
v = attr.value ? 'new nasl.core.BooleanTrue()' : 'new nasl.core.BooleanFalse()';
|
|
964
964
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
965
|
+
return v;
|
|
966
|
+
};
|
|
967
|
+
const getConverterDefaultValue = (name) => {
|
|
968
|
+
let v = 'new nasl.core.StringLiteral<\`\`>()';
|
|
969
|
+
const attr = self.bindAttrs?.find((attr) => attr.name === name);
|
|
970
|
+
if (['static', 'string'].includes(attr?.type)) {
|
|
971
|
+
if ([true, 'true'].includes(attr.value)) {
|
|
972
|
+
v = 'new nasl.core.BooleanTrue()';
|
|
973
|
+
}
|
|
974
|
+
else if ([false, 'false'].includes(attr.value)) {
|
|
975
|
+
v = 'new nasl.core.BooleanFalse()';
|
|
976
|
+
}
|
|
977
|
+
else {
|
|
978
|
+
v = `new nasl.core.StringLiteral<\`${attr.value}\`>()`;
|
|
979
|
+
}
|
|
970
980
|
}
|
|
971
|
-
return
|
|
981
|
+
return v;
|
|
972
982
|
};
|
|
973
|
-
const hasDataSource = config_1.config?.allNodesAPI?.[self.tag]?.props?.findIndex((prop) => ['dataSource', 'data-source'].includes(prop.name)) >
|
|
974
|
-
|
|
983
|
+
const hasDataSource = config_1.config?.allNodesAPI?.[self.tag]?.props?.findIndex((prop) => ['dataSource', 'data-source'].includes(prop.name)) > -1;
|
|
984
|
+
let dataSourceSetted = false;
|
|
985
|
+
let staticItem = '';
|
|
975
986
|
// 有数据源属性的组件 才需要生成 item
|
|
976
987
|
if (hasDataSource && T) {
|
|
977
988
|
const key = T1 ? '__columnItem' : '__item';
|
|
978
989
|
const dataSourceAttr = self.bindAttrs?.find((attr) => attr.name === 'dataSource');
|
|
979
990
|
if (dataSourceAttr?.expression) {
|
|
991
|
+
dataSourceSetted = true;
|
|
980
992
|
if (asserts.isMemberExpression(dataSourceAttr.expression) ||
|
|
981
993
|
asserts.isIdentifier(dataSourceAttr.expression) ||
|
|
982
|
-
asserts.isCallLogic(dataSourceAttr.expression)) {
|
|
994
|
+
(asserts.isCallLogic(dataSourceAttr.expression) && !dataSourceAttr.expression?.calleeNamespace?.startsWith('extensions'))) {
|
|
983
995
|
const value = yield* dataSourceAttr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, dataSourceAttr.expression.concept === 'CallLogic'
|
|
984
996
|
? {
|
|
985
997
|
tabSize: 4,
|
|
@@ -1025,41 +1037,83 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
1025
1037
|
}
|
|
1026
1038
|
}
|
|
1027
1039
|
else {
|
|
1028
|
-
|
|
1040
|
+
// 根据静态子节点生成类型
|
|
1041
|
+
const attrs = {
|
|
1042
|
+
'u-checkbox': 'label',
|
|
1043
|
+
'u-radio': 'label',
|
|
1044
|
+
'van-radio': 'name',
|
|
1045
|
+
'van-checkbox': 'label',
|
|
1046
|
+
};
|
|
1047
|
+
const child = self.children?.filter((item) => item.tag !== 'template')[0];
|
|
1048
|
+
if (child) {
|
|
1049
|
+
const valueAttr = child.bindAttrs?.find((attr) => attr.name === (attrs[child.tag] || 'value'));
|
|
1050
|
+
if (valueAttr) {
|
|
1051
|
+
// 开启了绑定
|
|
1052
|
+
if (valueAttr.expression) {
|
|
1053
|
+
const attrCode = yield* valueAttr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, '', { tabSize: 0 }));
|
|
1054
|
+
staticItem = `${attrCode}`;
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
try {
|
|
1058
|
+
if (valueAttr.type === 'static') {
|
|
1059
|
+
const value = json5.parse(valueAttr.value);
|
|
1060
|
+
const map = {
|
|
1061
|
+
'string': 'new nasl.core.String("")',
|
|
1062
|
+
'number': 'new nasl.core.Long(1)',
|
|
1063
|
+
'boolean': 'new nasl.core.Boolean(false)',
|
|
1064
|
+
};
|
|
1065
|
+
staticItem = map[typeof value] || 'new nasl.core.String("")';
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
staticItem = 'new nasl.core.String("")';
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
catch (error) {
|
|
1072
|
+
// @ts-ignore
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
staticItem = 'new nasl.core.String("")';
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
code += `let __staticItem = ${staticItem};\n`;
|
|
1081
|
+
code += `let ${key}: typeof __staticItem;\n`;
|
|
1029
1082
|
}
|
|
1030
1083
|
}
|
|
1031
1084
|
// 值
|
|
1032
1085
|
let valueType;
|
|
1033
1086
|
if (hasDataSource && V && !T1) {
|
|
1034
1087
|
const valueFieldAttr = self.bindAttrs?.find((attr) => attr.name === 'valueField');
|
|
1035
|
-
if (['static', 'string'].includes(valueFieldAttr?.type)) {
|
|
1088
|
+
if (dataSourceSetted && ['static', 'string'].includes(valueFieldAttr?.type)) {
|
|
1036
1089
|
valueType = `typeof __item.${valueFieldAttr.value}`;
|
|
1037
1090
|
}
|
|
1038
1091
|
else {
|
|
1039
|
-
valueType =
|
|
1092
|
+
valueType = `typeof __staticItem`;
|
|
1040
1093
|
}
|
|
1041
1094
|
}
|
|
1042
1095
|
// 分页
|
|
1043
|
-
let
|
|
1096
|
+
let pageableDefaultValue;
|
|
1044
1097
|
if (hasDataSource && P && !T1) {
|
|
1045
|
-
|
|
1046
|
-
code += `let __pageable
|
|
1098
|
+
pageableDefaultValue = getMultipleDefaultValue('pageable');
|
|
1099
|
+
code += `let __pageable = ${pageableDefaultValue};\n`;
|
|
1047
1100
|
}
|
|
1048
1101
|
// 多选
|
|
1049
|
-
let
|
|
1102
|
+
let multipleDefaultValue;
|
|
1050
1103
|
if (hasDataSource && M && !T1) {
|
|
1051
|
-
|
|
1052
|
-
code += `let __multiple
|
|
1104
|
+
multipleDefaultValue = getMultipleDefaultValue('multiple');
|
|
1105
|
+
code += `let __multiple = ${multipleDefaultValue};\n`;
|
|
1053
1106
|
}
|
|
1054
1107
|
if (hasDataSource && V && !T1) {
|
|
1055
1108
|
code += `// @ts-ignore
|
|
1056
|
-
let __value:
|
|
1109
|
+
let __value: typeof __multiple extends nasl.core.BooleanTrue ? ${valueType}[] : ${valueType};\n`;
|
|
1057
1110
|
code += `// @ts-ignore
|
|
1058
1111
|
let __V: ${valueType};\n`;
|
|
1059
1112
|
}
|
|
1113
|
+
let converterDefaultValue;
|
|
1060
1114
|
if (C) {
|
|
1061
|
-
|
|
1062
|
-
code += `let __converter
|
|
1115
|
+
converterDefaultValue = getConverterDefaultValue('converter');
|
|
1116
|
+
code += `let __converter = ${converterDefaultValue};\n`;
|
|
1063
1117
|
}
|
|
1064
1118
|
if (self.tag === 'template' && self.haveScope() && asserts.isViewElement(self.parentNode)) {
|
|
1065
1119
|
const currentType = self.parentNode.tag === 'u-table-view-column-dynamic' ? 'CurrentDynamic' : 'Current';
|
|
@@ -1327,11 +1381,9 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
1327
1381
|
if (shouldFilter) {
|
|
1328
1382
|
return;
|
|
1329
1383
|
}
|
|
1330
|
-
let attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }));
|
|
1384
|
+
let attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }), { carryName: true });
|
|
1331
1385
|
if (attrCode.trim()) {
|
|
1332
|
-
|
|
1333
|
-
code += `${humpName}: `;
|
|
1334
|
-
attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }));
|
|
1386
|
+
attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }), { carryName: true });
|
|
1335
1387
|
code += attrCode;
|
|
1336
1388
|
code += `,\n`;
|
|
1337
1389
|
}
|
|
@@ -1412,7 +1464,8 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
1412
1464
|
const param = hasScope ? `current${levelIndex === 0 ? '' : levelIndex}` : '';
|
|
1413
1465
|
const levelIndexDelta = Number(hasScope);
|
|
1414
1466
|
code += `slotDefault: (${param}) => [\n`;
|
|
1415
|
-
|
|
1467
|
+
const defaultArr = self.shouldHandleChildren(self) ? children : [];
|
|
1468
|
+
yield* (0, time_slicing_1.wrapForEachToGenerator)(defaultArr, function* warpForEachGenerator(element) {
|
|
1416
1469
|
code += yield* element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
1417
1470
|
tabSize: (state?.tabSize || 0) + 2,
|
|
1418
1471
|
}), levelIndex + levelIndexDelta);
|
|
@@ -1433,6 +1486,25 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
1433
1486
|
}
|
|
1434
1487
|
return code;
|
|
1435
1488
|
}
|
|
1489
|
+
shouldHandleChildren(element) {
|
|
1490
|
+
// 数据源与静态子节点不共存的组件
|
|
1491
|
+
const tags = [
|
|
1492
|
+
'u-tabs',
|
|
1493
|
+
'u-selectable-steps',
|
|
1494
|
+
'van-swipe',
|
|
1495
|
+
'van-steps',
|
|
1496
|
+
]; // 数据源与静态子节点不共存的组件
|
|
1497
|
+
// 判断当前是否配置了数据源
|
|
1498
|
+
const isDataSourceConfigured = () => element.bindAttrs.some((attr) => {
|
|
1499
|
+
if (['data-source', 'dataSource'].includes(attr.name)) {
|
|
1500
|
+
if (attr.type === 'dynamic' && attr.expression) {
|
|
1501
|
+
return true;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
return false;
|
|
1505
|
+
});
|
|
1506
|
+
return !tags.includes(element.tag) || !isDataSourceConfigured();
|
|
1507
|
+
}
|
|
1436
1508
|
toNaturalTS(state = (0, translator_1.createCompilerState)(), parentLevel) {
|
|
1437
1509
|
let code = '';
|
|
1438
1510
|
code += `$refs.${this.name} = new ${(0, utils_1.kebab2Camel)(this.tag)}({\n`;
|
|
@@ -1527,6 +1599,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
1527
1599
|
code += element.toTextualNASL((0, translator_1.shiftState)(state, code, {
|
|
1528
1600
|
tabSize: state.tabSize + 2,
|
|
1529
1601
|
}));
|
|
1602
|
+
code += ',\n';
|
|
1530
1603
|
});
|
|
1531
1604
|
code += `${(0, translator_1.indent)(state.tabSize + 1)}] },\n`;
|
|
1532
1605
|
}
|
|
@@ -1536,15 +1609,13 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
1536
1609
|
});
|
|
1537
1610
|
// 翻译其余的子集
|
|
1538
1611
|
if (defaultArr.length) {
|
|
1539
|
-
throw new Error('多个插槽必须都在 template 内');
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
// );
|
|
1547
|
-
// });
|
|
1612
|
+
// throw new Error('多个插槽必须都在 template 内');
|
|
1613
|
+
defaultArr.forEach((element) => {
|
|
1614
|
+
code += element.toTextualNASL((0, translator_1.shiftState)(state, code, {
|
|
1615
|
+
tabSize: state.tabSize,
|
|
1616
|
+
}));
|
|
1617
|
+
code += ',\n';
|
|
1618
|
+
});
|
|
1548
1619
|
}
|
|
1549
1620
|
}
|
|
1550
1621
|
else {
|
|
@@ -2227,7 +2298,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
2227
2298
|
}
|
|
2228
2299
|
});
|
|
2229
2300
|
}
|
|
2230
|
-
if (options?.isExport &&
|
|
2301
|
+
if ((options?.isExport || options?.isRelease) &&
|
|
2231
2302
|
attr?.concept === 'BindAttribute' &&
|
|
2232
2303
|
attr?.name === 'src' &&
|
|
2233
2304
|
/^\/assets\/(.*?)$/.test(attr?.value) &&
|
|
@@ -2264,7 +2335,6 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
2264
2335
|
argsList,
|
|
2265
2336
|
dataRefList,
|
|
2266
2337
|
};
|
|
2267
|
-
// debugger
|
|
2268
2338
|
// 所有参数序列化之后当字符串传进指令参数 (目前不支持<div v-demo="{ color: 'white', text: 'hello!' }"></div>
|
|
2269
2339
|
let expression = StringLiteral__1.StringLiteral.from({
|
|
2270
2340
|
concept: 'StringLiteral',
|
|
@@ -2294,21 +2364,23 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
2294
2364
|
ve?.bindAttrs?.find((attr) => {
|
|
2295
2365
|
let type = attr?.expression?.object?.__TypeAnnotation;
|
|
2296
2366
|
if (type) {
|
|
2297
|
-
console.log('type: ', type);
|
|
2298
2367
|
let { typeKind, typeName, typeNamespace } = type || {};
|
|
2299
|
-
// todo 这里可能不是匿名数据结构吗
|
|
2300
2368
|
if (typeKind === 'anonymousStructure') {
|
|
2301
2369
|
let parent = this.getAncestorByTag('ViewElement', 'u-table-view') ||
|
|
2302
2370
|
this.getAncestorByTag('ViewElement', 'u-list-view') ||
|
|
2303
2371
|
this.getAncestorByTag('ViewElement', 'u-grid-view') ||
|
|
2304
2372
|
this.getAncestorByTag('ViewElement', 'van-grid-view') ||
|
|
2305
2373
|
this.getAncestorByTag('ViewElement', 'van-list-view');
|
|
2306
|
-
|
|
2374
|
+
let canAdd = parent?.tag;
|
|
2375
|
+
if (isGridViewLayout || isListViewLayout) {
|
|
2376
|
+
let nestLinearLayout = this.children.find(c => c.tag === 'u-linear-layout');
|
|
2377
|
+
canAdd = canAdd && !nestLinearLayout;
|
|
2378
|
+
}
|
|
2379
|
+
if (canAdd) {
|
|
2307
2380
|
let dataSourceAttr = parent?.bindAttrs?.find((it) => it?.name === 'dataSource');
|
|
2308
2381
|
if (dataSourceAttr?.expression?.concept === 'CallLogic') {
|
|
2309
2382
|
if (dataSourceAttr?.expression?.calleeNamespace === 'app.logics') {
|
|
2310
2383
|
logicName = dataSourceAttr?.expression?.calleeName;
|
|
2311
|
-
// debugger
|
|
2312
2384
|
let ref = {
|
|
2313
2385
|
typeNamespace: 'app.logics',
|
|
2314
2386
|
typeName: logicName,
|
|
@@ -2345,11 +2417,15 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
2345
2417
|
const addDataRefDriective = (ve) => {
|
|
2346
2418
|
ve?.bindAttrs?.find((attr) => {
|
|
2347
2419
|
let type = attr?.expression?.object?.__TypeAnnotation;
|
|
2348
|
-
|
|
2420
|
+
let canAdd = type;
|
|
2421
|
+
if (isGridViewLayout || isListViewLayout) {
|
|
2422
|
+
let nestLinearLayout = this.children.find(c => c.tag === 'u-linear-layout');
|
|
2423
|
+
canAdd = canAdd && !nestLinearLayout;
|
|
2424
|
+
}
|
|
2425
|
+
if (canAdd) {
|
|
2349
2426
|
let { typeKind, typeName, typeNamespace } = type || {};
|
|
2350
2427
|
if (typeKind === 'reference' && typeNamespace) {
|
|
2351
2428
|
let entityPropName = attr?.expression?.property?.name;
|
|
2352
|
-
// debugger;
|
|
2353
2429
|
let ref = {
|
|
2354
2430
|
typeNamespace,
|
|
2355
2431
|
typeName,
|
|
@@ -2488,7 +2564,14 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
|
|
|
2488
2564
|
* 从父级删除该节点
|
|
2489
2565
|
* @internal
|
|
2490
2566
|
*/
|
|
2491
|
-
delete() {
|
|
2567
|
+
delete() {
|
|
2568
|
+
super.delete();
|
|
2569
|
+
if (this.parentNode) {
|
|
2570
|
+
this.traverseChildren((ele) => {
|
|
2571
|
+
this.likeComponent?.removeExistingViewElement(ele);
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2492
2575
|
findElementByName(name) {
|
|
2493
2576
|
return utils.traverse((current) => {
|
|
2494
2577
|
if (current.node.name === name)
|