@lcap/nasl 3.8.2-beta.8 → 3.8.3-beta.1
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/ai-engineer.config.js +617 -0
- package/out/common/BaseNode.js +5 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/ComponentAPI.d.ts +9 -0
- package/out/concepts/AuthLogicForCallInterface__.js +21 -6
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +16 -1
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +12 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BusinessComponent__.js +24 -8
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +21 -6
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallInterface__.js +2 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -0
- package/out/concepts/CallLogic__.js +32 -11
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +1 -0
- package/out/concepts/CallQueryComponent__.js +23 -12
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Destination__.js +11 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +3 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.js +1 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.js +49 -17
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +19 -13
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +37 -12
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +21 -6
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +5 -4
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +0 -1
- package/out/concepts/QueryOrderByExpression__.js +0 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/Structure__.js +5 -7
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/Variable__.js +5 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +17 -7
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +70 -14
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +78 -0
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +40 -40
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/generator/genBundleFiles.js +1 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/release-body/utils.js +1 -1
- package/out/natural/genNaturalTS.d.ts +45 -10
- package/out/natural/genNaturalTS.js +57 -33
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.js +6 -3
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +20 -7
- package/out/natural/getContext/index.js +143 -23
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/getContext/naslStdlibMap.js +8 -8
- package/out/natural/getContext/naslStdlibMap.js.map +1 -1
- package/out/natural/tools.d.ts +16 -0
- package/out/natural/tools.js +110 -2
- package/out/natural/tools.js.map +1 -1
- package/out/natural/transformTS2UI.js +361 -304
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +3 -5
- package/out/natural/transformTSCode.js +30 -1089
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/natural/transforms/registerTransform.d.ts +7 -0
- package/out/natural/transforms/registerTransform.js +24 -0
- package/out/natural/transforms/registerTransform.js.map +1 -0
- package/out/natural/transforms/transform2LogicItem.d.ts +24 -0
- package/out/natural/transforms/transform2LogicItem.js +1240 -0
- package/out/natural/transforms/transform2LogicItem.js.map +1 -0
- package/out/natural/transforms/transform2TypeAnnotation.d.ts +2 -0
- package/out/natural/transforms/transform2TypeAnnotation.js +86 -0
- package/out/natural/transforms/transform2TypeAnnotation.js.map +1 -0
- package/out/natural/transforms/utils.d.ts +8 -0
- package/out/natural/transforms/utils.js +59 -0
- package/out/natural/transforms/utils.js.map +1 -0
- package/out/server/getLogics.js +12 -12
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +11 -17
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +2 -2
- package/out/server/naslServer.js +38 -18
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +5 -0
- package/out/server/translator.js.map +1 -1
- package/out/templator/block2nasl/jsx2nasl/index.d.ts +5 -0
- package/out/templator/block2nasl/jsx2nasl/index.js +15 -0
- package/out/templator/block2nasl/jsx2nasl/index.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.d.ts +3 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.js +213 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.d.ts +14 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js +201 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.d.ts +4 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.js +186 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.d.ts +28 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js +336 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/utils.d.ts +2 -0
- package/out/templator/block2nasl/jsx2nasl/utils.js +26 -0
- package/out/templator/block2nasl/jsx2nasl/utils.js.map +1 -0
- package/out/templator/block2nasl/transformBlock2Nasl.d.ts +10 -0
- package/out/templator/block2nasl/transformBlock2Nasl.js +122 -0
- package/out/templator/block2nasl/transformBlock2Nasl.js.map +1 -0
- package/out/templator/block2nasl/viewMergeBlock.d.ts +9 -0
- package/out/templator/block2nasl/viewMergeBlock.js +110 -0
- package/out/templator/block2nasl/viewMergeBlock.js.map +1 -0
- package/out/translator/types.d.ts +2 -0
- package/out/translator/utils.js +1 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/index.js +0 -4
- package/out/utils/index.js.map +1 -1
- package/out/utils/language-cache/constant.d.ts +2 -1
- package/out/utils/language-cache/constant.js +1 -0
- package/out/utils/language-cache/constant.js.map +1 -1
- package/out/utils/language-cache/nasl.d.ts +1 -0
- package/out/utils/language-cache/nasl.js +9 -1
- package/out/utils/language-cache/nasl.js.map +1 -1
- package/package.json +6 -2
- package/sandbox/stdlib/nasl.processV2.ts +19 -0
- package/sandbox/stdlib/nasl.ui.ts +8 -8
- package/sandbox-natural/stdlib/nasl.core.d.ts +54 -0
- package/sandbox-natural/stdlib/nasl.oql.d.ts +22 -0
- package/sandbox-natural/stdlib/nasl.ui.d.ts +78 -0
- package/sandbox-natural/stdlib/nasl.ui.h5.d.ts +1684 -1643
- package/sandbox-natural/stdlib/nasl.ui.h5.json +15746 -15045
- package/sandbox-natural/stdlib/nasl.ui.pc.d.ts +5341 -5154
- package/sandbox-natural/stdlib/nasl.ui.pc.json +31176 -30681
- package/sandbox-natural/stdlib/{nasl.util.ts → nasl.util.d.ts} +49 -43
- package/src/common/BaseNode.ts +5 -3
- package/src/common/ComponentAPI.ts +7 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +23 -6
- package/src/concepts/BackendVariable__.ts +16 -1
- package/src/concepts/BindAttribute__.ts +18 -13
- package/src/concepts/BindDirective__.ts +1 -1
- package/src/concepts/BindStyle__.ts +1 -1
- package/src/concepts/BusinessComponent__.ts +26 -8
- package/src/concepts/BusinessLogic__.ts +23 -6
- package/src/concepts/CallInterface__.ts +2 -2
- package/src/concepts/CallLogic__.ts +50 -24
- package/src/concepts/CallQueryComponent__.ts +26 -12
- package/src/concepts/Destination__.ts +14 -12
- package/src/concepts/EntityProperty__.ts +5 -5
- package/src/concepts/Entity__.ts +1 -1
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/Logic__.ts +62 -33
- package/src/concepts/MemberExpression__.ts +20 -13
- package/src/concepts/OqlQueryComponent__.ts +29 -5
- package/src/concepts/OverriddenLogic__.ts +23 -6
- package/src/concepts/Param__.ts +5 -4
- package/src/concepts/QueryOrderByExpression__.ts +0 -1
- package/src/concepts/Structure__.ts +5 -7
- package/src/concepts/Variable__.ts +9 -5
- package/src/concepts/ViewElement__.ts +25 -9
- package/src/concepts/View__.ts +97 -37
- package/src/concepts/basics/stdlib/nasl.processV2.ts +79 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +40 -40
- package/src/generator/genBundleFiles.ts +1 -1
- package/src/generator/release-body/utils.ts +1 -1
- package/src/natural/genNaturalTS.ts +88 -39
- package/src/natural/getContext/getUILib.ts +6 -3
- package/src/natural/getContext/index.ts +125 -23
- package/src/natural/getContext/naslStdlibMap.ts +8 -8
- package/src/natural/tools.ts +107 -2
- package/src/natural/transformTS2UI.ts +205 -147
- package/src/natural/transformTSCode.ts +29 -1055
- package/src/natural/transforms/registerTransform.ts +34 -0
- package/src/natural/transforms/transform2LogicItem.ts +1335 -0
- package/src/natural/transforms/transform2TypeAnnotation.ts +77 -0
- package/src/natural/transforms/utils.ts +25 -0
- package/src/server/getLogics.ts +12 -12
- package/src/server/getMemberIdentifier.ts +14 -14
- package/src/server/naslServer.ts +39 -19
- package/src/server/translator.ts +5 -0
- package/src/templator/block2nasl/jsx2nasl/index.ts +11 -0
- package/src/templator/block2nasl/jsx2nasl/transform-expression2nasl.ts +238 -0
- package/src/templator/block2nasl/jsx2nasl/transform-func2nasl.ts +241 -0
- package/src/templator/block2nasl/jsx2nasl/transform-tstype2nasl.ts +213 -0
- package/src/templator/block2nasl/jsx2nasl/transform-tsx2nasl.ts +422 -0
- package/src/templator/block2nasl/jsx2nasl/utils.ts +19 -0
- package/src/templator/block2nasl/transformBlock2Nasl.ts +99 -0
- package/src/templator/block2nasl/viewMergeBlock.ts +149 -0
- package/src/translator/types.ts +2 -0
- package/src/translator/utils.ts +1 -1
- package/src/utils/index.ts +0 -4
- package/src/utils/language-cache/constant.ts +1 -0
- package/src/utils/language-cache/nasl.ts +6 -0
- package/test/concepts/member-expression/__snapshots__/toJS.spec.ts.snap +1 -1
- package/test/concepts/member-expression/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/tdd/dataQuery/QueryFieldExpression/case1/ast.json +7 -0
- package/test/tdd/dataQuery/QueryFieldExpression/case1/natural.ts.txt +1 -0
- package/test/tdd/dataQuery/QueryFieldExpression/case2/ast.json +7 -0
- package/test/tdd/dataQuery/QueryFieldExpression/case2/natural.ts.txt +1 -0
- package/test/tdd/transform/case1/ast.json +243 -0
- package/test/tdd/transform/case1/natural.ts.md +20 -0
- package/test/tdd/transform/case2/ast.json +207 -0
- package/test/tdd/transform/case2/natural.ts.md +12 -0
- package/test/tdd.test.js +10 -0
- package/test/tdd.transform.test.js +38 -0
- package/test/utils.js +40 -0
- package/sandbox-natural/stdlib/nasl.core.ts +0 -36
- package/sandbox-natural/stdlib/nasl.oql.ts +0 -14
- package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +0 -90
- package/sandbox-natural/stdlib/nasl.ui.ts +0 -63
|
@@ -1012,46 +1012,46 @@ export function initialize() {
|
|
|
1012
1012
|
new Structure({
|
|
1013
1013
|
name: 'KeyboardEvent',
|
|
1014
1014
|
properties: [
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1015
|
+
new StructureProperty({
|
|
1016
|
+
name: 'altKey',
|
|
1017
|
+
description: '事件触发时 alt 键 (OS X 系统上的 Option 或 ⌥ 键) 是 (true) 否 (false) 被按下',
|
|
1018
|
+
typeAnnotation: TypeAnnotation.createPrimitive('Boolean')
|
|
1019
|
+
}),
|
|
1020
|
+
new StructureProperty({
|
|
1021
|
+
name: 'code',
|
|
1022
|
+
description: '',
|
|
1023
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String')
|
|
1024
|
+
}),
|
|
1025
|
+
new StructureProperty({
|
|
1026
|
+
name: 'ctrlKey',
|
|
1027
|
+
description: '事件触发时 control 键是 (true) 否 (false) 按下',
|
|
1028
|
+
typeAnnotation: TypeAnnotation.createPrimitive('Boolean')
|
|
1029
|
+
}),
|
|
1030
|
+
new StructureProperty({
|
|
1031
|
+
name: 'isComposing',
|
|
1032
|
+
description: '该事件是否在 compositionstart 之后和 compositionend 之前被触发',
|
|
1033
|
+
typeAnnotation: TypeAnnotation.createPrimitive('Boolean')
|
|
1034
|
+
}),
|
|
1035
|
+
new StructureProperty({
|
|
1036
|
+
name: 'key',
|
|
1037
|
+
description: '',
|
|
1038
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String')
|
|
1039
|
+
}),
|
|
1040
|
+
new StructureProperty({
|
|
1041
|
+
name: 'metaKey',
|
|
1042
|
+
description: '指示 Meta 键是按下状态(true),还是释放状态(false)',
|
|
1043
|
+
typeAnnotation: TypeAnnotation.createPrimitive('Boolean')
|
|
1044
|
+
}),
|
|
1045
|
+
new StructureProperty({
|
|
1046
|
+
name: 'repeat',
|
|
1047
|
+
description: '如果按键被一直按住,返回值为true',
|
|
1048
|
+
typeAnnotation: TypeAnnotation.createPrimitive('Boolean')
|
|
1049
|
+
}),
|
|
1050
|
+
new StructureProperty({
|
|
1051
|
+
name: 'shiftKey',
|
|
1052
|
+
description: '事件触发时 shift 键是 (true) 否 (false) 按下',
|
|
1053
|
+
typeAnnotation: TypeAnnotation.createPrimitive('Boolean')
|
|
1054
|
+
})
|
|
1055
1055
|
],
|
|
1056
1056
|
}),
|
|
1057
1057
|
);
|
|
@@ -860,7 +860,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
860
860
|
if (window.annotationAllData) {
|
|
861
861
|
resolve(window.annotationAllData);
|
|
862
862
|
} else {
|
|
863
|
-
let sysPrefixPath =
|
|
863
|
+
let sysPrefixPath = ${ config?.sysPrefixPath ? "'" + config?.sysPrefixPath + "'" : "'" + "'" } ||'';
|
|
864
864
|
let urlEntity = sysPrefixPath + '/api/system/annotation/entityAll'
|
|
865
865
|
let urlLogic = sysPrefixPath + '/api/system/annotation/logicAll'
|
|
866
866
|
Promise.all([
|
|
@@ -425,7 +425,7 @@ export function getProcessFormDefinitions(app: App) {
|
|
|
425
425
|
);
|
|
426
426
|
formDefinition = formDefinition.replaceAll(
|
|
427
427
|
`(${process.name} ||`,
|
|
428
|
-
'
|
|
428
|
+
'(processDetailFormData ||'
|
|
429
429
|
);
|
|
430
430
|
formDefinition = formDefinition.replace(
|
|
431
431
|
/:ref="([^"]+)"/g,
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
getConnectors,
|
|
14
14
|
getDependencies,
|
|
15
15
|
getFrontendVariables,
|
|
16
|
+
getServerVariables,
|
|
17
|
+
getVariablesCode,
|
|
16
18
|
getFrontendViews,
|
|
17
19
|
getCurrentNodeContext,
|
|
18
20
|
getCurrentNodeContextForUI,
|
|
@@ -26,6 +28,7 @@ import {
|
|
|
26
28
|
getConnectorsCode,
|
|
27
29
|
getDependenciesCode,
|
|
28
30
|
getFrontendViewsCode,
|
|
31
|
+
getCurrentComponentDeclaration,
|
|
29
32
|
wrapTSBlock,
|
|
30
33
|
} from './getContext';
|
|
31
34
|
import { createCompilerState } from '../translator';
|
|
@@ -57,20 +60,35 @@ export function genNaturalTSContextJSONForLogic(
|
|
|
57
60
|
moduleInterfaces: any;
|
|
58
61
|
connectors: any;
|
|
59
62
|
dependencies: any;
|
|
60
|
-
|
|
63
|
+
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string; };
|
|
64
|
+
extensionMaterials: 'pc' | 'h5' | {
|
|
65
|
+
name: string;
|
|
66
|
+
title: string;
|
|
67
|
+
description: string;
|
|
68
|
+
tsDescription: string;
|
|
69
|
+
}[];
|
|
70
|
+
},
|
|
71
|
+
restParams?: any
|
|
61
72
|
) {
|
|
62
73
|
const frontend = currentNode?.getAncestor('Frontend') as Frontend;
|
|
63
74
|
const logicType = currentNode?.parentNode?.concept === 'App' ? 'global_logic' : 'view_logic';
|
|
64
|
-
const state = createCompilerState('', { descriptionComment: true });
|
|
75
|
+
const state = createCompilerState('', { descriptionComment: true, typeMap: restParams?.typeMap });
|
|
65
76
|
|
|
66
77
|
const { naslCore } = getNaslCore(logicType);
|
|
67
78
|
const { naslUtil } = getNaslUtil();
|
|
68
79
|
const { naslUI } = getNaslUIOld();
|
|
80
|
+
let components = [];
|
|
81
|
+
if (logicType === 'view_logic' && material?.basicMaterials && material?.extensionMaterials) {
|
|
82
|
+
components = getNaslUI(app, frontend.type, {
|
|
83
|
+
basicMaterials: material?.basicMaterials,
|
|
84
|
+
extensionMaterials: material?.extensionMaterials,
|
|
85
|
+
}).naslUI;
|
|
86
|
+
}
|
|
69
87
|
const { naslOql } = getNaslOQL();
|
|
70
88
|
const { enums } = getEnums(app, state);
|
|
71
89
|
const { entities } = getEntities(app, state);
|
|
72
90
|
const { structures } = getStructures(app, state);
|
|
73
|
-
const { appLogics } = getLogics(app, currentNode);
|
|
91
|
+
const { appLogics } = getLogics(app, currentNode, state);
|
|
74
92
|
const { interfaceDependencies } = getModuleInterfaces(
|
|
75
93
|
material?.moduleInterfaces || app?.interfaceDependencies,
|
|
76
94
|
state
|
|
@@ -89,17 +107,21 @@ export function genNaturalTSContextJSONForLogic(
|
|
|
89
107
|
logicType,
|
|
90
108
|
frontend?.type
|
|
91
109
|
);
|
|
92
|
-
const {
|
|
110
|
+
const { frontendVariables } = getFrontendVariables(
|
|
93
111
|
currentNode?.getAncestor('Frontend') as Frontend,
|
|
94
112
|
state
|
|
95
113
|
);
|
|
96
|
-
const { views } = getFrontendViews(frontend, state, currentNode, false);
|
|
97
|
-
const { currentLogic } = getCurrentNodeContext(currentNode, focusedNodePath, experimental);
|
|
98
114
|
|
|
115
|
+
const { backendVariables } = getServerVariables(app, state);
|
|
116
|
+
|
|
117
|
+
const { views } = getFrontendViews(frontend, state, currentNode, false);
|
|
118
|
+
const { currentLogic } = getCurrentNodeContext(currentNode, focusedNodePath, experimental, restParams?.typeMap);
|
|
119
|
+
const { componentDeclaration } = getCurrentComponentDeclaration(currentNode, components);
|
|
99
120
|
return {
|
|
100
121
|
naslCore,
|
|
101
122
|
naslUtil,
|
|
102
123
|
naslUI,
|
|
124
|
+
components,
|
|
103
125
|
naslOql,
|
|
104
126
|
enums,
|
|
105
127
|
entities,
|
|
@@ -108,11 +130,12 @@ export function genNaturalTSContextJSONForLogic(
|
|
|
108
130
|
interfaceDependencies,
|
|
109
131
|
connections,
|
|
110
132
|
dependencies,
|
|
111
|
-
frontendVar, // @deprecated
|
|
112
133
|
frontendVariables,
|
|
134
|
+
backendVariables,
|
|
113
135
|
views,
|
|
114
136
|
currentLogic,
|
|
115
137
|
logicType,
|
|
138
|
+
componentDeclaration
|
|
116
139
|
};
|
|
117
140
|
}
|
|
118
141
|
|
|
@@ -142,16 +165,18 @@ export const genNaturalTSContextFromJSONForLogic = (
|
|
|
142
165
|
connections,
|
|
143
166
|
dependencies,
|
|
144
167
|
frontendVariables,
|
|
168
|
+
backendVariables,
|
|
145
169
|
views,
|
|
146
170
|
currentLogic,
|
|
147
171
|
logicType,
|
|
172
|
+
componentDeclaration
|
|
148
173
|
} = tsContextJSON;
|
|
149
174
|
|
|
150
175
|
let code = '';
|
|
151
|
-
code += '### [1]
|
|
176
|
+
code += '### [1]标准库与类型定义\n';
|
|
152
177
|
code += wrapTSBlock(naslCore);
|
|
153
178
|
|
|
154
|
-
code += '\n### [2]
|
|
179
|
+
code += '\n### [2]平台内置函数库\n';
|
|
155
180
|
code += wrapTSBlock(naslUtil);
|
|
156
181
|
|
|
157
182
|
if (naslUI && logicType === 'view_logic') {
|
|
@@ -161,10 +186,14 @@ export const genNaturalTSContextFromJSONForLogic = (
|
|
|
161
186
|
} else {
|
|
162
187
|
code += getNaslUICode(naslUI, codeType, requiredIndexes);
|
|
163
188
|
}
|
|
189
|
+
if (componentDeclaration) {
|
|
190
|
+
code += '\n#### [3-1] 组件声明\n';
|
|
191
|
+
code += wrapTSBlock(`declare namespace nasl.ui {\n${componentDeclaration}}`);
|
|
192
|
+
}
|
|
164
193
|
}
|
|
165
194
|
|
|
166
195
|
if (naslOql && logicType === 'global_logic') {
|
|
167
|
-
code += '\n### [4]
|
|
196
|
+
code += '\n### [4]数据查询定义\n';
|
|
168
197
|
code += wrapTSBlock(naslOql);
|
|
169
198
|
}
|
|
170
199
|
|
|
@@ -205,15 +234,20 @@ export const genNaturalTSContextFromJSONForLogic = (
|
|
|
205
234
|
|
|
206
235
|
if (logicType === 'view_logic') {
|
|
207
236
|
code += '\n### [10] 页面上下文\n';
|
|
208
|
-
if (frontendVariables) {
|
|
237
|
+
if (frontendVariables?.data?.length) {
|
|
209
238
|
code += '\n#### [10-0] 前端全局变量\n';
|
|
210
|
-
code += frontendVariables;
|
|
239
|
+
code += getVariablesCode(frontendVariables);
|
|
211
240
|
}
|
|
212
241
|
|
|
213
242
|
if (views?.data?.length) {
|
|
214
243
|
code += '\n#### [10-1] 前端页面列表\n';
|
|
215
244
|
code += getFrontendViewsCode(views);
|
|
216
245
|
}
|
|
246
|
+
} else {
|
|
247
|
+
code += '\n### [10] 全局变量\n';
|
|
248
|
+
if (backendVariables?.data?.length) {
|
|
249
|
+
code += getVariablesCode(backendVariables);
|
|
250
|
+
}
|
|
217
251
|
}
|
|
218
252
|
|
|
219
253
|
code += '\n### 当前逻辑上下文\n';
|
|
@@ -232,9 +266,17 @@ export function genNaturalTSContextForLogic(
|
|
|
232
266
|
moduleInterfaces: any;
|
|
233
267
|
connectors: any;
|
|
234
268
|
dependencies: any;
|
|
269
|
+
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string; };
|
|
270
|
+
extensionMaterials: 'pc' | 'h5' | {
|
|
271
|
+
name: string;
|
|
272
|
+
title: string;
|
|
273
|
+
description: string;
|
|
274
|
+
tsDescription: string;
|
|
275
|
+
}[];
|
|
235
276
|
},
|
|
236
277
|
restParams?: {
|
|
237
|
-
codeType
|
|
278
|
+
codeType: 'detail' | 'short';
|
|
279
|
+
typeMap?: any;
|
|
238
280
|
}
|
|
239
281
|
) {
|
|
240
282
|
const tsContextJSON = genNaturalTSContextJSONForLogic(
|
|
@@ -242,11 +284,12 @@ export function genNaturalTSContextForLogic(
|
|
|
242
284
|
currentNode,
|
|
243
285
|
focusedNodePath,
|
|
244
286
|
experimental,
|
|
245
|
-
material
|
|
287
|
+
material,
|
|
288
|
+
restParams
|
|
246
289
|
);
|
|
247
290
|
const code = genNaturalTSContextFromJSONForLogic(
|
|
248
291
|
tsContextJSON,
|
|
249
|
-
restParams
|
|
292
|
+
restParams?.codeType || 'short',
|
|
250
293
|
requiredIndexes
|
|
251
294
|
);
|
|
252
295
|
return code;
|
|
@@ -262,8 +305,8 @@ export function genNaturalTSContextJSONForUI(
|
|
|
262
305
|
app: App,
|
|
263
306
|
currentNode: BaseNode,
|
|
264
307
|
material?: {
|
|
265
|
-
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string };
|
|
266
|
-
extensionMaterials: {
|
|
308
|
+
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string; };
|
|
309
|
+
extensionMaterials: 'pc' | 'h5' | {
|
|
267
310
|
name: string;
|
|
268
311
|
title: string;
|
|
269
312
|
description: string;
|
|
@@ -272,21 +315,23 @@ export function genNaturalTSContextJSONForUI(
|
|
|
272
315
|
moduleInterfaces: any;
|
|
273
316
|
connectors: any;
|
|
274
317
|
dependencies: any;
|
|
275
|
-
}
|
|
318
|
+
},
|
|
319
|
+
restParams?: any
|
|
276
320
|
) {
|
|
277
321
|
const frontend = currentNode.getAncestor('Frontend') as Frontend;
|
|
278
|
-
const state = createCompilerState();
|
|
322
|
+
const state = createCompilerState('', { descriptionComment: true, needNamespace: true, typeMap: restParams?.typeMap });
|
|
279
323
|
|
|
280
324
|
const { naslCore } = getNaslCore('view_logic');
|
|
281
325
|
const { naslUtil } = getNaslUtil();
|
|
282
|
-
const { naslUI } =
|
|
326
|
+
const { naslUI } = getNaslUIOld();
|
|
327
|
+
const components = getNaslUI(app, frontend.type, {
|
|
283
328
|
basicMaterials: material?.basicMaterials,
|
|
284
329
|
extensionMaterials: material?.extensionMaterials,
|
|
285
|
-
});
|
|
330
|
+
}).naslUI;
|
|
286
331
|
const { enums } = getEnums(app, state);
|
|
287
332
|
const { entities } = getEntities(app, state);
|
|
288
333
|
const { structures } = getStructures(app, state);
|
|
289
|
-
const { appLogics } = getLogics(app, currentNode);
|
|
334
|
+
const { appLogics } = getLogics(app, currentNode, state);
|
|
290
335
|
const { interfaceDependencies } = getModuleInterfaces(
|
|
291
336
|
material?.moduleInterfaces || app?.interfaceDependencies,
|
|
292
337
|
state
|
|
@@ -299,12 +344,15 @@ export function genNaturalTSContextJSONForUI(
|
|
|
299
344
|
);
|
|
300
345
|
const { frontendVariables } = getFrontendVariables(frontend, state);
|
|
301
346
|
const { views } = getFrontendViews(frontend, state, currentNode, false);
|
|
302
|
-
const { currentLogic } = getCurrentNodeContextForUI(currentNode);
|
|
347
|
+
const { currentLogic } = getCurrentNodeContextForUI(currentNode, restParams?.typeMap);
|
|
348
|
+
const { componentDeclaration } = getCurrentComponentDeclaration(currentNode, components);
|
|
303
349
|
|
|
304
350
|
return {
|
|
305
351
|
naslCore,
|
|
306
352
|
naslUtil,
|
|
307
353
|
naslUI,
|
|
354
|
+
components,
|
|
355
|
+
componentDeclaration,
|
|
308
356
|
enums,
|
|
309
357
|
entities,
|
|
310
358
|
structures,
|
|
@@ -333,7 +381,8 @@ export const genNaturalTSContextFromJSONForUI = (
|
|
|
333
381
|
const {
|
|
334
382
|
naslCore,
|
|
335
383
|
naslUtil,
|
|
336
|
-
|
|
384
|
+
components,
|
|
385
|
+
componentDeclaration,
|
|
337
386
|
enums,
|
|
338
387
|
entities,
|
|
339
388
|
structures,
|
|
@@ -346,18 +395,18 @@ export const genNaturalTSContextFromJSONForUI = (
|
|
|
346
395
|
} = tsContextJSON;
|
|
347
396
|
|
|
348
397
|
let code = '';
|
|
349
|
-
code += '### [1]
|
|
398
|
+
code += '### [1] 标准库与类型定义\n';
|
|
350
399
|
code += wrapTSBlock(naslCore);
|
|
351
400
|
|
|
352
|
-
code += '\n### [2]
|
|
401
|
+
code += '\n### [2] 平台内置函数库\n';
|
|
353
402
|
code += wrapTSBlock(naslUtil);
|
|
354
403
|
|
|
355
|
-
if (
|
|
404
|
+
if (components) {
|
|
356
405
|
code += '\n### [3] nasl.ui\n';
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
code +=
|
|
406
|
+
code += getNaslUICode(components, codeType, requiredIndexes);
|
|
407
|
+
if (componentDeclaration) {
|
|
408
|
+
code += '\n#### [3-1] 组件声明\n';
|
|
409
|
+
code += wrapTSBlock(`declare namespace nasl.ui {\n${componentDeclaration}\n}`);
|
|
361
410
|
}
|
|
362
411
|
}
|
|
363
412
|
|
|
@@ -393,11 +442,10 @@ export const genNaturalTSContextFromJSONForUI = (
|
|
|
393
442
|
}
|
|
394
443
|
|
|
395
444
|
code += '\n### [10] 页面上下文\n';
|
|
396
|
-
if (frontendVariables) {
|
|
445
|
+
if (frontendVariables?.data?.length) {
|
|
397
446
|
code += '\n#### [10-0] 前端全局变量\n';
|
|
398
|
-
code += frontendVariables;
|
|
447
|
+
code += getVariablesCode(frontendVariables);
|
|
399
448
|
}
|
|
400
|
-
|
|
401
449
|
if (views?.data?.length) {
|
|
402
450
|
code += '\n#### [10-1] 前端页面列表\n';
|
|
403
451
|
code += getFrontendViewsCode(views);
|
|
@@ -416,8 +464,8 @@ export function genNaturalTSContextForUI(
|
|
|
416
464
|
focusedNodePath?: string,
|
|
417
465
|
requiredIndexes?: string[],
|
|
418
466
|
material?: {
|
|
419
|
-
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string };
|
|
420
|
-
extensionMaterials: {
|
|
467
|
+
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string; };
|
|
468
|
+
extensionMaterials: 'pc' | 'h5' | {
|
|
421
469
|
name: string;
|
|
422
470
|
title: string;
|
|
423
471
|
description: string;
|
|
@@ -428,13 +476,14 @@ export function genNaturalTSContextForUI(
|
|
|
428
476
|
dependencies: any;
|
|
429
477
|
},
|
|
430
478
|
restParams?: {
|
|
431
|
-
codeType
|
|
479
|
+
codeType: 'detail' | 'short';
|
|
480
|
+
typeMap?: any;
|
|
432
481
|
}
|
|
433
482
|
) {
|
|
434
|
-
const tsContextJSON = genNaturalTSContextJSONForUI(app, currentNode, material);
|
|
483
|
+
const tsContextJSON = genNaturalTSContextJSONForUI(app, currentNode, material, restParams);
|
|
435
484
|
const code = genNaturalTSContextFromJSONForUI(
|
|
436
485
|
tsContextJSON,
|
|
437
|
-
restParams
|
|
486
|
+
restParams?.codeType || 'short',
|
|
438
487
|
requiredIndexes
|
|
439
488
|
);
|
|
440
489
|
return code;
|
|
@@ -50,7 +50,10 @@ export function handleMaterial({ json, tsDeclaration }: { json: Array<{ name: st
|
|
|
50
50
|
snippets.forEach((code) => {
|
|
51
51
|
const cap = code.match(/class ([a-zA-Z]+).+?extends ViewComponent/);
|
|
52
52
|
if (cap) {
|
|
53
|
-
|
|
53
|
+
const newCode = code
|
|
54
|
+
.replace(/nasl\.core\./g, "")
|
|
55
|
+
.replace(/Integer/g, "Long");
|
|
56
|
+
snippetMap[cap[1]] = `declare namespace nasl.ui${newCode}`;
|
|
54
57
|
}
|
|
55
58
|
});
|
|
56
59
|
json.forEach((item) => {
|
|
@@ -79,12 +82,12 @@ export function getPreDeclaration() {
|
|
|
79
82
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
80
83
|
if (globalThis.process) { // For TS build
|
|
81
84
|
const fs = require('fs');
|
|
82
|
-
code = fs.readFileSync(require.resolve(`../../../sandbox-natural/stdlib/nasl.ui.
|
|
85
|
+
code = fs.readFileSync(require.resolve(`../../../sandbox-natural/stdlib/nasl.ui.d.ts`), 'utf8');
|
|
83
86
|
}
|
|
84
87
|
/// #endif
|
|
85
88
|
/// #if process.env.BUILD_TARGET !== 'node'
|
|
86
89
|
if (globalThis.window) { // For TS build
|
|
87
|
-
code = require('!!raw-loader!../../../sandbox-natural/stdlib/nasl.ui.
|
|
90
|
+
code = require('!!raw-loader!../../../sandbox-natural/stdlib/nasl.ui.d.ts').default;
|
|
88
91
|
}
|
|
89
92
|
/// #endif
|
|
90
93
|
return code;
|