@lcap/nasl 3.8.0-beta.8 → 3.8.2-alpha.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/.nyc_output/fe4ca6db-1eb6-4898-8aa5-ba8f8d4128f2.json +1 -0
- package/.nyc_output/processinfo/fe4ca6db-1eb6-4898-8aa5-ba8f8d4128f2.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/coverage/cobertura-coverage.xml +9325 -77393
- package/out/concepts/AuthLogicForCallInterface__.js +13 -2
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +11 -1
- package/out/concepts/BackendVariable__.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 +14 -3
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +13 -2
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallConnector__.js +2 -1
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallInterface__.js +12 -3
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +24 -1
- package/out/concepts/CallLogic__.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/EnumItem__.js +2 -2
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.js +13 -2
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +1 -0
- package/out/concepts/NewComposite__.js +23 -0
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +13 -2
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Structure__.js +1 -3
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SubLogic__.js +13 -2
- package/out/concepts/SubLogic__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +6 -3
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ViewComponentDeclaration__.js +3 -3
- package/out/concepts/ViewComponentDeclaration__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +60 -19
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +24 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genBundleFiles.js +1 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +69 -16
- package/out/natural/genNaturalTS.js +198 -117
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/index.d.ts +38 -26
- package/out/natural/getContext/index.js +318 -160
- 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 +162 -0
- package/out/natural/tools.js.map +1 -0
- package/out/natural/transformTS2UI.js +63 -26
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.js +26 -15
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/naslServer.js +1 -0
- package/out/server/naslServer.js.map +1 -1
- package/out/translator/utils.js +1 -1
- package/out/translator/utils.js.map +1 -1
- package/package.json +1 -1
- package/sandbox/stdlib/nasl.util.ts +2 -2
- package/sandbox-natural/stdlib/nasl.core.ts +11 -0
- package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +37 -37
- package/sandbox-natural/stdlib/nasl.util.ts +6 -6
- package/src/concepts/AuthLogicForCallInterface__.ts +13 -1
- package/src/concepts/BackendVariable__.ts +11 -1
- package/src/concepts/BindDirective__.ts +1 -1
- package/src/concepts/BindStyle__.ts +1 -1
- package/src/concepts/BusinessComponent__.ts +14 -2
- package/src/concepts/BusinessLogic__.ts +13 -1
- package/src/concepts/CallConnector__.ts +2 -1
- package/src/concepts/CallInterface__.ts +10 -3
- package/src/concepts/CallLogic__.ts +34 -14
- package/src/concepts/EntityProperty__.ts +5 -5
- package/src/concepts/Entity__.ts +1 -1
- package/src/concepts/EnumItem__.ts +2 -2
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/Logic__.ts +13 -1
- package/src/concepts/NewComposite__.ts +24 -0
- package/src/concepts/OverriddenLogic__.ts +13 -1
- package/src/concepts/Param__.ts +1 -1
- package/src/concepts/Structure__.ts +1 -3
- package/src/concepts/SubLogic__.ts +13 -1
- package/src/concepts/TypeAnnotation__.ts +5 -3
- package/src/concepts/ViewComponentDeclaration__.ts +3 -3
- package/src/concepts/ViewElement__.ts +78 -19
- package/src/concepts/View__.ts +48 -24
- package/src/generator/genBundleFiles.ts +1 -1
- package/src/natural/genNaturalTS.ts +363 -147
- package/src/natural/getContext/index.ts +363 -175
- package/src/natural/index.ts +1 -0
- package/src/natural/tools.ts +138 -0
- package/src/natural/transformTS2UI.ts +60 -25
- package/src/natural/transformTSCode.ts +26 -16
- package/src/server/naslServer.ts +1 -0
- package/src/translator/utils.ts +1 -1
- package/.nyc_output/047fb941-6e69-4829-8b3c-14d37e06c63b.json +0 -1
- package/.nyc_output/processinfo/047fb941-6e69-4829-8b3c-14d37e06c63b.json +0 -1
|
@@ -993,6 +993,30 @@ export class NewComposite extends LogicItem {
|
|
|
993
993
|
return this.rights[firstIndex].members[secondIndex];
|
|
994
994
|
}
|
|
995
995
|
|
|
996
|
+
toBrief(): string {
|
|
997
|
+
let code = '新建:{ ';
|
|
998
|
+
if (this.typeAnnotation) {
|
|
999
|
+
const leftAssignmentMap = new Map();
|
|
1000
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1001
|
+
const rightItem = this.findMember(rightIndex);
|
|
1002
|
+
const leftItem = this.findMember(leftIndex, 'left');
|
|
1003
|
+
if (!leftAssignmentMap.has(leftItem)) {
|
|
1004
|
+
leftAssignmentMap.set(leftItem, rightItem);
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
this.properties.forEach((leftItem, index) => {
|
|
1008
|
+
if (index) {
|
|
1009
|
+
code += ', ';
|
|
1010
|
+
}
|
|
1011
|
+
const rightItem = leftAssignmentMap.get(leftItem);
|
|
1012
|
+
const value = rightItem ? rightItem.toBrief() : 'null';
|
|
1013
|
+
code += `${leftItem.name}: ${value}`;
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
code += ` }`;
|
|
1017
|
+
return code;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
996
1020
|
toUI(state?: TranslatorState, hideDetails?: boolean): string {
|
|
997
1021
|
let code = '新建:{ ';
|
|
998
1022
|
if (this.typeAnnotation) {
|
|
@@ -1770,8 +1770,20 @@ export class OverriddenLogic extends BaseNode {
|
|
|
1770
1770
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
1771
1771
|
if (itemNode) {
|
|
1772
1772
|
code += `const __${key}_${node?.name} = `;
|
|
1773
|
-
|
|
1773
|
+
let itemCode = '';
|
|
1774
|
+
if (
|
|
1775
|
+
asserts.isNewComposite(itemNode)
|
|
1776
|
+
|| asserts.isNewList(itemNode)
|
|
1777
|
+
|| asserts.isNewMap(itemNode)
|
|
1778
|
+
) {
|
|
1779
|
+
itemCode += yield* itemNode?.getInitCode(shiftState(state, code, {
|
|
1780
|
+
inline: true
|
|
1781
|
+
})) ??
|
|
1774
1782
|
returnOrigin('');
|
|
1783
|
+
} else {
|
|
1784
|
+
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
1785
|
+
returnOrigin('');
|
|
1786
|
+
}
|
|
1775
1787
|
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
1776
1788
|
code += ';\n';
|
|
1777
1789
|
}
|
package/src/concepts/Param__.ts
CHANGED
|
@@ -580,9 +580,7 @@ export class Structure extends BaseNode {
|
|
|
580
580
|
|
|
581
581
|
// code += `${indent(state.tabSize + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
582
582
|
this.properties.forEach((property) => {
|
|
583
|
-
code +=
|
|
584
|
-
code += property.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
|
|
585
|
-
code += ';\n';
|
|
583
|
+
code += `${property.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }))};\n`;
|
|
586
584
|
});
|
|
587
585
|
code += `${indent(state.tabSize)}}\n`;
|
|
588
586
|
return code;
|
|
@@ -1391,8 +1391,20 @@ export class SubLogic extends LogicItem {
|
|
|
1391
1391
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
1392
1392
|
if (itemNode) {
|
|
1393
1393
|
code += `const __${key}_${node?.name} = `;
|
|
1394
|
-
|
|
1394
|
+
let itemCode = '';
|
|
1395
|
+
if (
|
|
1396
|
+
asserts.isNewComposite(itemNode)
|
|
1397
|
+
|| asserts.isNewList(itemNode)
|
|
1398
|
+
|| asserts.isNewMap(itemNode)
|
|
1399
|
+
) {
|
|
1400
|
+
itemCode += yield* itemNode?.getInitCode(shiftState(state, code, {
|
|
1401
|
+
inline: true
|
|
1402
|
+
})) ??
|
|
1395
1403
|
returnOrigin('');
|
|
1404
|
+
} else {
|
|
1405
|
+
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
1406
|
+
returnOrigin('');
|
|
1407
|
+
}
|
|
1396
1408
|
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
1397
1409
|
code += ';\n';
|
|
1398
1410
|
}
|
|
@@ -978,9 +978,11 @@ export class TypeAnnotation extends BaseNode {
|
|
|
978
978
|
code += ')';
|
|
979
979
|
code += '=>';
|
|
980
980
|
const returnTypes = self?.returnType || [];
|
|
981
|
-
|
|
982
|
-
code += yield*
|
|
983
|
-
}
|
|
981
|
+
if (returnTypes.length) {
|
|
982
|
+
code += yield* returnTypes[0].toEmbeddedTS(shiftState(state, code));
|
|
983
|
+
} else {
|
|
984
|
+
code += 'void';
|
|
985
|
+
}
|
|
984
986
|
return code;
|
|
985
987
|
} else {
|
|
986
988
|
if (self.tsCalleeNamespace && self.typeName) {
|
|
@@ -1667,19 +1667,19 @@ export class ViewComponentDeclaration extends BaseNode {
|
|
|
1667
1667
|
code += `${indent(state.tabSize + 1)}}\n`;
|
|
1668
1668
|
code += `${indent(state.tabSize + 1)}class ${componentName}Options extends ViewComponentOptions {\n`;
|
|
1669
1669
|
// props
|
|
1670
|
-
this.props?.forEach((prop: PropDeclaration) => {
|
|
1670
|
+
(this.props || [])?.forEach((prop: PropDeclaration) => {
|
|
1671
1671
|
const desc = utils.getDescription(prop.title, prop.description);
|
|
1672
1672
|
code += desc ? `${indent(state.tabSize + 2)}${desc}\n` : '';
|
|
1673
1673
|
code += `${indent(state.tabSize + 2)}${prop.toNaturalTS(state)}`;
|
|
1674
1674
|
});
|
|
1675
1675
|
// events
|
|
1676
|
-
this.events?.forEach((event: EventDeclaration) => {
|
|
1676
|
+
(this.events || [])?.forEach((event: EventDeclaration) => {
|
|
1677
1677
|
const desc = utils.getDescription(event.title, event.description);
|
|
1678
1678
|
code += desc ? `${indent(state.tabSize + 2)}${desc}\n` : '';
|
|
1679
1679
|
code += `${indent(state.tabSize + 2)}${event.toNaturalTS()}`;
|
|
1680
1680
|
});
|
|
1681
1681
|
// slots
|
|
1682
|
-
this.slots?.forEach((slot: SlotDeclaration) => {
|
|
1682
|
+
(this.slots || [])?.forEach((slot: SlotDeclaration) => {
|
|
1683
1683
|
const desc = utils.getDescription(slot.title, slot.description);
|
|
1684
1684
|
code += desc ? `${indent(state.tabSize + 2)}${desc}\n` : '';
|
|
1685
1685
|
code += `${indent(state.tabSize + 2)}${slot.toNaturalTS()}`;
|
|
@@ -1493,6 +1493,10 @@ export class ViewElement extends Annotatable {
|
|
|
1493
1493
|
return this.bindStyles.find((bindStyle) => bindStyle.name === name);
|
|
1494
1494
|
}
|
|
1495
1495
|
|
|
1496
|
+
getBindEvent(name: string) {
|
|
1497
|
+
return this.bindEvents.find((bindEvent) => bindEvent.name === name);
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1496
1500
|
toHump(name: string): string {
|
|
1497
1501
|
return name.replace(/-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
1498
1502
|
}
|
|
@@ -1915,7 +1919,6 @@ export class ViewElement extends Annotatable {
|
|
|
1915
1919
|
noNeedParams: true,
|
|
1916
1920
|
callLogicNoIife: true,
|
|
1917
1921
|
};
|
|
1918
|
-
debugger;
|
|
1919
1922
|
const value = yield* attr.expression.toEmbeddedTS(
|
|
1920
1923
|
shiftState(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}),
|
|
1921
1924
|
);
|
|
@@ -2263,6 +2266,15 @@ export class ViewElement extends Annotatable {
|
|
|
2263
2266
|
|
|
2264
2267
|
code += `$refs.${this.name} = new ${kebab2Camel(this.tag)}({\n`;
|
|
2265
2268
|
|
|
2269
|
+
this?.bindDirectives?.forEach((directive) => {
|
|
2270
|
+
code += directive.toNaturalTS(
|
|
2271
|
+
shiftState(state, code, {
|
|
2272
|
+
tabSize: state.tabSize + 1,
|
|
2273
|
+
}),
|
|
2274
|
+
);
|
|
2275
|
+
code += ',\n';
|
|
2276
|
+
});
|
|
2277
|
+
|
|
2266
2278
|
this.bindAttrs.forEach((attr) => {
|
|
2267
2279
|
code += attr.toNaturalTS(
|
|
2268
2280
|
shiftState(state, code, {
|
|
@@ -2272,6 +2284,15 @@ export class ViewElement extends Annotatable {
|
|
|
2272
2284
|
code += ',\n';
|
|
2273
2285
|
});
|
|
2274
2286
|
|
|
2287
|
+
this.bindStyles.forEach((style) => {
|
|
2288
|
+
code += style.toNaturalTS(
|
|
2289
|
+
shiftState(state, code, {
|
|
2290
|
+
tabSize: state.tabSize + 1,
|
|
2291
|
+
}),
|
|
2292
|
+
);
|
|
2293
|
+
code += ',\n';
|
|
2294
|
+
});
|
|
2295
|
+
|
|
2275
2296
|
this.bindEvents.forEach((event) => {
|
|
2276
2297
|
code += event.toNaturalTS(
|
|
2277
2298
|
shiftState(state, code, {
|
|
@@ -3186,6 +3207,7 @@ export class ViewElement extends Annotatable {
|
|
|
3186
3207
|
|
|
3187
3208
|
result && parts.push(result);
|
|
3188
3209
|
});
|
|
3210
|
+
let preAnnoParts:any = []
|
|
3189
3211
|
const genDirectiveByAnno = (viewElement: ViewElement) => {
|
|
3190
3212
|
if (viewElement?.applyAnnotations?.length > 0) {
|
|
3191
3213
|
// todo: 根据注解生成自定义指令 v-annoName="context"
|
|
@@ -3203,22 +3225,12 @@ export class ViewElement extends Annotatable {
|
|
|
3203
3225
|
};
|
|
3204
3226
|
let argsList = aa.arguments.map((arg: any) => getExpressionValue(arg.expression));
|
|
3205
3227
|
let annoArgs = {
|
|
3228
|
+
annotationName:aa.annotationName,
|
|
3206
3229
|
argsList,
|
|
3207
3230
|
dataRefList,
|
|
3208
3231
|
};
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
concept: 'StringLiteral',
|
|
3212
|
-
kind: 'Expression',
|
|
3213
|
-
name: '',
|
|
3214
|
-
value: JSON.stringify(annoArgs),
|
|
3215
|
-
});
|
|
3216
|
-
let annoDirective = BindDirective.from({
|
|
3217
|
-
name: aa.annotationName,
|
|
3218
|
-
// arg:'arg',
|
|
3219
|
-
expression,
|
|
3220
|
-
});
|
|
3221
|
-
return annoDirective;
|
|
3232
|
+
return annoArgs
|
|
3233
|
+
|
|
3222
3234
|
});
|
|
3223
3235
|
}
|
|
3224
3236
|
};
|
|
@@ -3258,9 +3270,8 @@ export class ViewElement extends Annotatable {
|
|
|
3258
3270
|
propName: attr?.expression.toUI()?.replace('current.item.', ''),
|
|
3259
3271
|
};
|
|
3260
3272
|
dataRefList.push(ref);
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
result && result?.length > 0 && parts.push(...result);
|
|
3273
|
+
let result = (genDirectiveByAnno(viewElement) as any)
|
|
3274
|
+
result && result?.length > 0 && preAnnoParts.push(...result);
|
|
3264
3275
|
}
|
|
3265
3276
|
}
|
|
3266
3277
|
}
|
|
@@ -3309,8 +3320,9 @@ export class ViewElement extends Annotatable {
|
|
|
3309
3320
|
propName: entityPropName,
|
|
3310
3321
|
};
|
|
3311
3322
|
dataRefList.push(ref);
|
|
3312
|
-
|
|
3313
|
-
|
|
3323
|
+
|
|
3324
|
+
let result = (genDirectiveByAnno(viewElement) as any)
|
|
3325
|
+
result && result?.length > 0 && preAnnoParts.push(...result);
|
|
3314
3326
|
}
|
|
3315
3327
|
// typeName "Entity1"
|
|
3316
3328
|
// typeNamespace "app.dataSources.defaultDS.entities"
|
|
@@ -3337,7 +3349,38 @@ export class ViewElement extends Annotatable {
|
|
|
3337
3349
|
// 2 向上是线性布局 卡片 template gridView
|
|
3338
3350
|
};
|
|
3339
3351
|
getEntityDataRef(this);
|
|
3352
|
+
let annoMap:any = {}
|
|
3340
3353
|
|
|
3354
|
+
preAnnoParts?.map((annoArgs:any)=>{
|
|
3355
|
+
let annotationName =annoArgs.annotationName
|
|
3356
|
+
if(!annoMap[annotationName] ){
|
|
3357
|
+
annoMap[annotationName] =[]
|
|
3358
|
+
}
|
|
3359
|
+
annoMap[annotationName] = annoArgs
|
|
3360
|
+
})
|
|
3361
|
+
Object.keys(annoMap)?.map(key=>{
|
|
3362
|
+
let annoArgs =annoMap[key]
|
|
3363
|
+
let {
|
|
3364
|
+
annotationName,
|
|
3365
|
+
argsList,
|
|
3366
|
+
dataRefList,
|
|
3367
|
+
}= annoArgs;
|
|
3368
|
+
// 一个元素可以有多个指令; 其中一个指令可以从多处获取参数 这里就不能直接生成指令了 不然多个参数就变成了多个指令 实现同一个指令多个参数
|
|
3369
|
+
// 所有参数序列化之后当字符串传进指令参数 (目前不支持<div v-demo="{ color: 'white', text: 'hello!' }"></div>
|
|
3370
|
+
let expression = StringLiteral.from({
|
|
3371
|
+
concept: 'StringLiteral',
|
|
3372
|
+
kind: 'Expression',
|
|
3373
|
+
name: '',
|
|
3374
|
+
value: JSON.stringify(annoArgs),
|
|
3375
|
+
});
|
|
3376
|
+
let annoDirective = BindDirective.from({
|
|
3377
|
+
name: annotationName,
|
|
3378
|
+
// arg:'arg',
|
|
3379
|
+
expression,
|
|
3380
|
+
});
|
|
3381
|
+
let directString = annoDirective?.toVue()
|
|
3382
|
+
directString && parts.push(directString)
|
|
3383
|
+
})
|
|
3341
3384
|
if (vIfs.length === 2) parts.push(`v-if="(${vIfs[0]}) && (${vIfs[1]})"`);
|
|
3342
3385
|
else if (vIfs.length === 1) parts.push(`v-if="${vIfs[0]}"`);
|
|
3343
3386
|
|
|
@@ -3705,6 +3748,22 @@ export class ViewElement extends Annotatable {
|
|
|
3705
3748
|
this.getBindAttribute('processPrefix')
|
|
3706
3749
|
);
|
|
3707
3750
|
}
|
|
3751
|
+
|
|
3752
|
+
getBindViewDestination() {
|
|
3753
|
+
let bindView
|
|
3754
|
+
utils.traverse(
|
|
3755
|
+
({ node }) => {
|
|
3756
|
+
if (this.composedBy?.[0] === (node as any).composedBy?.[0]) {
|
|
3757
|
+
bindView = node
|
|
3758
|
+
}
|
|
3759
|
+
},
|
|
3760
|
+
{
|
|
3761
|
+
node: { children: this.frontend?.views },
|
|
3762
|
+
}
|
|
3763
|
+
);
|
|
3764
|
+
return bindView;
|
|
3765
|
+
}
|
|
3766
|
+
|
|
3708
3767
|
getAncestorByTag<Node extends types.SyntaxNode = types.SyntaxNode>(
|
|
3709
3768
|
concept: types.SyntaxNode['concept'],
|
|
3710
3769
|
tag: string,
|
package/src/concepts/View__.ts
CHANGED
|
@@ -1583,8 +1583,8 @@ export class View extends Annotatable {
|
|
|
1583
1583
|
const BindEvent = getConceptConstructor('BindEvent');
|
|
1584
1584
|
const definitionStr = utils.sliceTagContent(code, 'definition') || '{}';
|
|
1585
1585
|
const definition: any = JSON.parse(definitionStr);
|
|
1586
|
-
|
|
1587
|
-
|
|
1586
|
+
// 服务端逻辑
|
|
1587
|
+
if (Array.isArray(definition.logics)) {
|
|
1588
1588
|
definition.logics.forEach((logicOption: any) => {
|
|
1589
1589
|
const logic = Logic.from(
|
|
1590
1590
|
{
|
|
@@ -1671,8 +1671,8 @@ export class View extends Annotatable {
|
|
|
1671
1671
|
const BindEvent = getConceptConstructor('BindEvent');
|
|
1672
1672
|
const definitionStr = utils.sliceTagContent(code, 'definition') || '{}';
|
|
1673
1673
|
const definition: any = JSON.parse(definitionStr);
|
|
1674
|
-
|
|
1675
|
-
|
|
1674
|
+
// 服务端逻辑
|
|
1675
|
+
if (Array.isArray(definition.logics)) {
|
|
1676
1676
|
definition.logics.forEach((logicOption: any) => {
|
|
1677
1677
|
const logic = Logic.from(
|
|
1678
1678
|
{
|
|
@@ -1834,7 +1834,7 @@ export class View extends Annotatable {
|
|
|
1834
1834
|
*/
|
|
1835
1835
|
genScript() {
|
|
1836
1836
|
const componentList: Array<ViewElement> = [];
|
|
1837
|
-
const allComponentList: Array<ViewElement & { currentIndex: number }> = [];
|
|
1837
|
+
const allComponentList: Array<ViewElement & { currentIndex: number; }> = [];
|
|
1838
1838
|
this.elementsAttrs(this.elements, componentList, allComponentList, -1);
|
|
1839
1839
|
|
|
1840
1840
|
const routeMeta = this.getRouteMeta();
|
|
@@ -1864,15 +1864,15 @@ export class View extends Annotatable {
|
|
|
1864
1864
|
methods: {
|
|
1865
1865
|
async onKeyDown(e) {
|
|
1866
1866
|
${this.bindEvents
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1867
|
+
.filter((event) => ['keydown'].includes(event.name))
|
|
1868
|
+
.map((event) => `await this.${event.view.name}_${event.name}(e);`)
|
|
1869
|
+
.join('\n')}
|
|
1870
1870
|
},
|
|
1871
1871
|
async onKeyUp(e) {
|
|
1872
1872
|
${this.bindEvents
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1873
|
+
.filter((event) => ['keyup'].includes(event.name))
|
|
1874
|
+
.map((event) => `await this.${event.view.name}_${event.name}(e);`)
|
|
1875
|
+
.join('\n')}
|
|
1876
1876
|
}
|
|
1877
1877
|
}
|
|
1878
1878
|
};\n`;
|
|
@@ -2066,9 +2066,8 @@ export class View extends Annotatable {
|
|
|
2066
2066
|
parent = parent.parentNode;
|
|
2067
2067
|
}
|
|
2068
2068
|
}
|
|
2069
|
-
return `/embedded/${this.getAncestor('App')?.name}/frontendTypes/${
|
|
2070
|
-
this.getAncestor('
|
|
2071
|
-
}/frontends/${this.getAncestor('Frontend')?.name}/views/${pathName}.ts`;
|
|
2069
|
+
return `/embedded/${this.getAncestor('App')?.name}/frontendTypes/${this.getAncestor('FrontendType')?.name
|
|
2070
|
+
}/frontends/${this.getAncestor('Frontend')?.name}/views/${pathName}.ts`;
|
|
2072
2071
|
}
|
|
2073
2072
|
|
|
2074
2073
|
getNamespace(): string {
|
|
@@ -2117,11 +2116,11 @@ export class View extends Annotatable {
|
|
|
2117
2116
|
elementsAttrs(
|
|
2118
2117
|
elements: Array<ViewElement>,
|
|
2119
2118
|
componentList: Array<ViewElement>,
|
|
2120
|
-
allComponentList: Array<ViewElement & { currentIndex: number }>,
|
|
2119
|
+
allComponentList: Array<ViewElement & { currentIndex: number; }>,
|
|
2121
2120
|
currentIndex: number,
|
|
2122
2121
|
) {
|
|
2123
2122
|
if (elements) {
|
|
2124
|
-
elements.forEach((item: ViewElement & { currentIndex: number }) => {
|
|
2123
|
+
elements.forEach((item: ViewElement & { currentIndex: number; }) => {
|
|
2125
2124
|
let index = currentIndex ?? -1;
|
|
2126
2125
|
if (item.tag === 'template' && item.haveScope()) {
|
|
2127
2126
|
index += 1;
|
|
@@ -2246,9 +2245,9 @@ export class View extends Annotatable {
|
|
|
2246
2245
|
const leftCode =
|
|
2247
2246
|
leftIndex.length === 1
|
|
2248
2247
|
? yield* el.left?.expression?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2249
|
-
|
|
2248
|
+
returnOrigin('')
|
|
2250
2249
|
: yield* el.left?.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2251
|
-
|
|
2250
|
+
returnOrigin('');
|
|
2252
2251
|
const advanceVar = self.variables?.find(
|
|
2253
2252
|
(variable) => !variable.typeAnnotation && leftCode === variable.name,
|
|
2254
2253
|
);
|
|
@@ -2303,7 +2302,7 @@ export class View extends Annotatable {
|
|
|
2303
2302
|
leftIndex.length === 1
|
|
2304
2303
|
? yield* assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true }))
|
|
2305
2304
|
: yield* assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2306
|
-
|
|
2305
|
+
returnOrigin('');
|
|
2307
2306
|
if (leftCode === variable.name) {
|
|
2308
2307
|
const rightNode =
|
|
2309
2308
|
rightIndex.length === 1
|
|
@@ -2361,8 +2360,20 @@ export class View extends Annotatable {
|
|
|
2361
2360
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
2362
2361
|
if (itemNode) {
|
|
2363
2362
|
code += `const __${key}_${node?.name} = `;
|
|
2364
|
-
|
|
2365
|
-
|
|
2363
|
+
let itemCode = '';
|
|
2364
|
+
if (
|
|
2365
|
+
asserts.isNewComposite(itemNode)
|
|
2366
|
+
|| asserts.isNewList(itemNode)
|
|
2367
|
+
|| asserts.isNewMap(itemNode)
|
|
2368
|
+
) {
|
|
2369
|
+
itemCode += yield* itemNode?.getInitCode(shiftState(state, code, {
|
|
2370
|
+
inline: true
|
|
2371
|
+
})) ??
|
|
2372
|
+
returnOrigin('');
|
|
2373
|
+
} else {
|
|
2374
|
+
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2375
|
+
returnOrigin('');
|
|
2376
|
+
}
|
|
2366
2377
|
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
2367
2378
|
code += ';\n';
|
|
2368
2379
|
}
|
|
@@ -2562,6 +2573,19 @@ export class View extends Annotatable {
|
|
|
2562
2573
|
});
|
|
2563
2574
|
if (this.variables.length) code += '\n';
|
|
2564
2575
|
|
|
2576
|
+
this.logics.forEach((logic) => {
|
|
2577
|
+
const logicCode = logic.toNaturalTS(
|
|
2578
|
+
shiftState(state, code, {
|
|
2579
|
+
tabSize: state.tabSize + 1,
|
|
2580
|
+
declaration: true,
|
|
2581
|
+
autoPrefixName: true,
|
|
2582
|
+
})
|
|
2583
|
+
);
|
|
2584
|
+
code += logicCode.replace('declare function', 'function');
|
|
2585
|
+
code += '\n';
|
|
2586
|
+
});
|
|
2587
|
+
if (this.logics.length) code += '\n';
|
|
2588
|
+
|
|
2565
2589
|
if (callback) {
|
|
2566
2590
|
code += callback.call(this, state);
|
|
2567
2591
|
} else {
|
|
@@ -3685,9 +3709,9 @@ export const ComponentCompletionPropertyMap: Record<string, any> = {
|
|
|
3685
3709
|
prop: 'sorting',
|
|
3686
3710
|
label: '排序方式',
|
|
3687
3711
|
},
|
|
3688
|
-
filter:{
|
|
3689
|
-
prop:'filter',
|
|
3690
|
-
label:'筛选条件'
|
|
3712
|
+
filter: {
|
|
3713
|
+
prop: 'filter',
|
|
3714
|
+
label: '筛选条件'
|
|
3691
3715
|
},
|
|
3692
3716
|
},
|
|
3693
3717
|
List: {
|
|
@@ -271,7 +271,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
271
271
|
return 'bundle';
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
|
-
let baseUrl = `${config.
|
|
274
|
+
let baseUrl = `${config.USER_STATIC_URL}/${config.tenant}/${app.id}/${config.env}`;
|
|
275
275
|
let { basePath } = frontend;
|
|
276
276
|
|
|
277
277
|
if (config.isExport as any) {
|