@lcap/nasl 3.6.0-alpha.1 → 3.6.0-alpha.2
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/bak/translator.js +119 -39
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.d.ts +3 -0
- package/out/breakpoint/generator/BreakpointNode.js +9 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/constants.js +1 -0
- package/out/breakpoint/shared/constants.js.map +1 -1
- package/out/breakpoint/shared/utils.js +12 -6
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +1 -4
- package/out/common/BaseNode.js +23 -37
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +6 -1
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +55 -51
- package/out/concepts/App__.js +76 -80
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +10 -2
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +16 -6
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +1 -0
- package/out/concepts/BindDirective__.js +19 -4
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +3 -1
- package/out/concepts/BindEvent__.js +39 -14
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +641 -0
- package/out/concepts/BusinessComponent__.js +1921 -0
- package/out/concepts/BusinessComponent__.js.map +1 -0
- package/out/concepts/BusinessLogic__.d.ts +38 -0
- package/out/concepts/BusinessLogic__.js +358 -0
- package/out/concepts/BusinessLogic__.js.map +1 -0
- package/out/concepts/CallEvent__.d.ts +101 -0
- package/out/concepts/CallEvent__.js +280 -0
- package/out/concepts/CallEvent__.js.map +1 -0
- package/out/concepts/CallFunction__.d.ts +0 -1
- package/out/concepts/CallFunction__.js +10 -10
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -0
- package/out/concepts/CallLogic__.js +38 -27
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Constant__.js +7 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +7 -5
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Event__.d.ts +14 -0
- package/out/concepts/Event__.js +61 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +308 -0
- package/out/concepts/FrontendType__.js +605 -0
- package/out/concepts/FrontendType__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +0 -88
- package/out/concepts/Frontend__.js +1 -143
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +5 -0
- package/out/concepts/Identifier__.js +19 -9
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +3 -1
- package/out/concepts/Logic__.js +31 -21
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +3 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/ParamWithGroup__.d.ts +39 -0
- package/out/concepts/ParamWithGroup__.js +85 -0
- package/out/concepts/ParamWithGroup__.js.map +1 -0
- package/out/concepts/Param__.js +11 -3
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +9 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Return__.js +17 -9
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +17 -8
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +17 -1
- package/out/concepts/ViewElement__.js +145 -16
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +21 -20
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/index__.d.ts +5 -0
- package/out/concepts/index__.js +5 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +258 -3
- package/out/concepts/utils/asserts.js +351 -13
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +20 -3
- package/out/generator/genBundleFiles.js +25 -11
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +12 -3
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +6 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +62 -27
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +6 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +40 -19
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +6 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +1 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +36 -36
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +6 -5
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +12 -12
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +4 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +3 -3
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +10 -10
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +10 -9
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/translator/utils.js +12 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/i18nInfo.js +7 -2
- package/out/utils/i18nInfo.js.map +1 -1
- package/out/utils/index.d.ts +17 -0
- package/out/utils/index.js +184 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bak/translator.js +121 -43
- package/src/breakpoint/generator/BreakpointNode.ts +12 -0
- package/src/breakpoint/shared/constants.ts +1 -0
- package/src/breakpoint/shared/utils.ts +13 -8
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +22 -41
- package/src/concepts/AnonymousFunction__.ts +36 -18
- package/src/concepts/App__.ts +129 -130
- package/src/concepts/BackendVariable__.ts +10 -2
- package/src/concepts/BindAttribute__.ts +14 -6
- package/src/concepts/BindDirective__.ts +19 -4
- package/src/concepts/BindEvent__.ts +41 -13
- package/src/concepts/BusinessComponent__.ts +2693 -0
- package/src/concepts/BusinessLogic__.ts +376 -0
- package/src/concepts/CallEvent__.ts +351 -0
- package/src/concepts/CallFunction__.ts +10 -13
- package/src/concepts/CallLogic__.ts +45 -32
- package/src/concepts/Constant__.ts +5 -7
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/End__.ts +1 -0
- package/src/concepts/Event__.ts +70 -0
- package/src/concepts/FrontendType__.ts +919 -0
- package/src/concepts/Frontend__.ts +3 -251
- package/src/concepts/Identifier__.ts +29 -13
- package/src/concepts/LogicItem__.ts +1 -0
- package/src/concepts/Logic__.ts +36 -23
- package/src/concepts/MemberExpression__.ts +3 -3
- package/src/concepts/NewComposite__.ts +4 -6
- package/src/concepts/ParamWithGroup__.ts +101 -0
- package/src/concepts/Param__.ts +11 -3
- package/src/concepts/ProcessElement__.ts +8 -1
- package/src/concepts/Return__.ts +15 -12
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/Variable__.ts +17 -9
- package/src/concepts/ViewElement__.ts +168 -33
- package/src/concepts/View__.ts +23 -20
- package/src/concepts/index__.ts +5 -0
- package/src/concepts/utils/asserts.ts +367 -4
- package/src/concepts/utils/types.ts +28 -0
- package/src/generator/genBundleFiles.ts +33 -15
- package/src/generator/genReleaseBody.ts +14 -3
- package/src/generator/permission.ts +8 -6
- package/src/natural/transformTSCode.ts +1 -1
- package/src/server/extendBaseNode.ts +22 -20
- package/src/server/getLogics.ts +79 -41
- package/src/server/getMemberIdentifier.ts +7 -1
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +44 -20
- package/src/server/translator.ts +7 -1
- package/src/service/storage/init.ts +1 -2
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
- package/src/templator/genCurdMultipleKeyBlock.ts +36 -36
- package/src/templator/genGetBlock.ts +6 -5
- package/src/templator/genGridViewBlock.ts +12 -12
- package/src/templator/genListViewBlock.ts +4 -4
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +10 -10
- package/src/templator/genUpdateBlock.ts +10 -9
- package/src/templator/utils.ts +2 -2
- package/src/translator/utils.ts +12 -1
- package/src/utils/i18nInfo.ts +7 -2
- package/src/utils/index.ts +211 -1
- package/test/concepts/call-function/fixtures/from-string.json +68 -59
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +67 -58
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +57 -48
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +69 -60
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +69 -60
- package/test/concepts/call-interface/fixtures/only-interface.json +81 -72
- package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +223 -214
- package/test/concepts/call-interface/fixtures/with-body-no-argument.json +85 -76
- package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +100 -91
- package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-headers.json +90 -81
- package/test/concepts/call-interface/fixtures/with-query-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-query.json +90 -81
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +4 -2
- package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +104 -95
- package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +209 -200
- package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +97 -88
- package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +124 -115
- package/test/concepts/call-logic/fixtures/json-deserialize.json +120 -111
- package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +124 -115
- package/test/concepts/call-logic/fixtures/json-serialize.json +124 -115
- package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +91 -82
- package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +88 -79
- package/test/concepts/call-logic/fixtures/view-component-with-validation.json +144 -135
- package/test/concepts/identifier/fixtures/view-variable.json +145 -136
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/fixtures/default-login.json +221 -212
- package/test/concepts/view-element/fixtures/default-not-found.json +183 -174
- package/test/concepts/view-element/fixtures/with-role-auth.json +91 -82
- package/test/concepts/view-element/fixtures/with-table.json +1894 -1885
- package/test/concepts/view-element/toVue.spec.ts +1 -0
- package/ts-worker/package.json +1 -1
- package/ts-worker/src/index.js +1 -0
package/src/concepts/Param__.ts
CHANGED
|
@@ -361,17 +361,25 @@ export class Param extends BaseNode {
|
|
|
361
361
|
toJS(state?: TranslatorState): string {
|
|
362
362
|
if (this.view) {
|
|
363
363
|
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
364
|
+
let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
|
|
365
|
+
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
366
|
+
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
367
|
+
const typeAn = referenceNode.typeAnnotation || {};
|
|
368
|
+
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
369
|
+
typeKind = typeAn.typeKind;
|
|
370
|
+
typeName = typeAn.typeName;
|
|
371
|
+
}
|
|
364
372
|
const needGenInitFromSchema =
|
|
365
373
|
typeAnnotation &&
|
|
366
|
-
(!['primitive', 'union'].includes(
|
|
374
|
+
(!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
367
375
|
let code = `${this.name} = `;
|
|
368
376
|
if (needGenInitFromSchema) {
|
|
369
|
-
code += `this.$genInitFromSchema('${
|
|
377
|
+
code += `this.$genInitFromSchema('${sortedTypeKey}',`;
|
|
370
378
|
}
|
|
371
379
|
|
|
372
380
|
const expressionJS = this.defaultValue?.toJS?.();
|
|
373
381
|
|
|
374
|
-
code += `${this.name} || (this.$route.query.hasOwnProperty('${this.name}') ? this.$genInitFromSchema('${
|
|
382
|
+
code += `${this.name} || (this.$route.query.hasOwnProperty('${this.name}') ? this.$genInitFromSchema('${sortedTypeKey}', this.$route.query.${this.name}) : ${expressionJS})`;
|
|
375
383
|
if (needGenInitFromSchema) {
|
|
376
384
|
code += `)`;
|
|
377
385
|
}
|
|
@@ -1915,7 +1915,14 @@ export class ProcessElement extends BaseNode {
|
|
|
1915
1915
|
if (Array.isArray(self.bindEvents)) {
|
|
1916
1916
|
yield* wrapForEach(self.bindEvents, function* warpForEachGenerator(bindEvent) {
|
|
1917
1917
|
// 任务完成时可以拿到输出参数
|
|
1918
|
-
|
|
1918
|
+
let currentPrevCode: any;
|
|
1919
|
+
if(bindEvent.name !== 'OnClose') {
|
|
1920
|
+
currentPrevCode = prevCode;
|
|
1921
|
+
// 除了任务完成时的逻辑,其他逻辑拿不到自己任务下的输出参数,所以不需要__ProcessIdentification__标注
|
|
1922
|
+
currentPrevCode = currentPrevCode.replace('__ProcessIdentification__', '');
|
|
1923
|
+
} else {
|
|
1924
|
+
currentPrevCode = prevCodeClose;
|
|
1925
|
+
}
|
|
1919
1926
|
code += `${tab1}${bindEvent.name}: () => [\n`;
|
|
1920
1927
|
yield* wrapForEach(bindEvent.logics, function* warpForEachGenerator(logic) {
|
|
1921
1928
|
code += `${yield* logic.toEmbeddedTSInProcess(
|
package/src/concepts/Return__.ts
CHANGED
|
@@ -322,12 +322,20 @@ export class Return extends BaseNode {
|
|
|
322
322
|
toJS(state?: TranslatorState): string {
|
|
323
323
|
const context = this.view ? 'this' : 'Vue.prototype';
|
|
324
324
|
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
325
|
+
let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
|
|
326
|
+
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
327
|
+
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
328
|
+
const typeAn = referenceNode.typeAnnotation || {};
|
|
329
|
+
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
330
|
+
typeKind = typeAn.typeKind;
|
|
331
|
+
typeName = typeAn.typeName;
|
|
332
|
+
}
|
|
325
333
|
const needGenInitFromSchema =
|
|
326
334
|
typeAnnotation &&
|
|
327
|
-
(!['primitive', 'union'].includes(
|
|
335
|
+
(!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
328
336
|
let code = `${this.name} = `;
|
|
329
337
|
if (needGenInitFromSchema) {
|
|
330
|
-
code += `${context}.$genInitFromSchema('${
|
|
338
|
+
code += `${context}.$genInitFromSchema('${sortedTypeKey}',`;
|
|
331
339
|
}
|
|
332
340
|
|
|
333
341
|
if (this.defaultValue?.expression) {
|
|
@@ -401,18 +409,13 @@ export class Return extends BaseNode {
|
|
|
401
409
|
let code = this.name;
|
|
402
410
|
if (this.typeAnnotation) {
|
|
403
411
|
code += `: `;
|
|
404
|
-
if (
|
|
405
|
-
this.
|
|
406
|
-
!(
|
|
407
|
-
this.typeAnnotation &&
|
|
408
|
-
['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(this.typeAnnotation.typeKey)
|
|
409
|
-
)
|
|
410
|
-
) {
|
|
411
|
-
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
412
|
-
} else {
|
|
413
|
-
if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(this.typeAnnotation?.typeKey)) {
|
|
412
|
+
if (this.defaultValue?.expression) {
|
|
413
|
+
if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(this.typeAnnotation.typeKey)) {
|
|
414
414
|
code += yield* this.defaultValue.toEmbeddedTS(shiftState(state, code), true);
|
|
415
|
+
} else {
|
|
416
|
+
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
415
417
|
}
|
|
418
|
+
} else {
|
|
416
419
|
code += 'undefined';
|
|
417
420
|
}
|
|
418
421
|
code += ' as ';
|
|
@@ -500,7 +500,12 @@ export class ValidationRule extends LogicItem {
|
|
|
500
500
|
const { calleeName, target, calleeKey, arguments: args, errorMessage, view } = self;
|
|
501
501
|
if (calleeName) {
|
|
502
502
|
// 调用逻辑时绑定的验证器
|
|
503
|
-
if (
|
|
503
|
+
if (
|
|
504
|
+
self?.parentNode?.parentKey !== 'metadataTypes'
|
|
505
|
+
&& (
|
|
506
|
+
self.getAncestor('CallLogic') || !(view || this.getAncestor('BusinessComponent'))
|
|
507
|
+
)
|
|
508
|
+
) {
|
|
504
509
|
code += yield* target.toEmbeddedTS(shiftState(state, code));
|
|
505
510
|
code += ';\n';
|
|
506
511
|
}
|
|
@@ -342,12 +342,20 @@ export class Variable extends BaseNode {
|
|
|
342
342
|
toJS(state?: TranslatorState): string {
|
|
343
343
|
const context = this.view ? 'this' : 'Vue.prototype';
|
|
344
344
|
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
345
|
+
let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
|
|
346
|
+
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
347
|
+
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
348
|
+
const typeAn = referenceNode.typeAnnotation || {};
|
|
349
|
+
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
350
|
+
typeKind = typeAn.typeKind;
|
|
351
|
+
typeName = typeAn.typeName;
|
|
352
|
+
}
|
|
345
353
|
const needGenInitFromSchema =
|
|
346
354
|
typeAnnotation &&
|
|
347
|
-
(!['primitive', 'union'].includes(
|
|
355
|
+
(!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
348
356
|
let code = `${this.name} = `;
|
|
349
357
|
if (needGenInitFromSchema) {
|
|
350
|
-
code += `${context}.$genInitFromSchema('${
|
|
358
|
+
code += `${context}.$genInitFromSchema('${sortedTypeKey}',`;
|
|
351
359
|
}
|
|
352
360
|
|
|
353
361
|
if (this.defaultValue?.expression) {
|
|
@@ -457,7 +465,9 @@ export class Variable extends BaseNode {
|
|
|
457
465
|
* @param name 一般不用传,用于 rename
|
|
458
466
|
*/
|
|
459
467
|
getEmbeddedFilePath(name = this.name) {
|
|
460
|
-
return `/embedded/${this.
|
|
468
|
+
return `/embedded/${this.getAncestor('App')?.name}/frontendTypes/${
|
|
469
|
+
this.getAncestor('FrontendType')?.name
|
|
470
|
+
}/frontends/${this.getAncestor('Frontend')?.name}/variables/${name}.ts`;
|
|
461
471
|
}
|
|
462
472
|
|
|
463
473
|
*toEmbeddedTSFile(): EmbeddedTSFileGenerator {
|
|
@@ -490,15 +500,13 @@ export class Variable extends BaseNode {
|
|
|
490
500
|
}
|
|
491
501
|
if (this.typeAnnotation) {
|
|
492
502
|
code += `: `;
|
|
493
|
-
if (
|
|
494
|
-
this.defaultValue?.expression &&
|
|
495
|
-
!(this.typeAnnotation && ['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey))
|
|
496
|
-
) {
|
|
497
|
-
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
498
|
-
} else {
|
|
503
|
+
if (this.defaultValue?.expression) {
|
|
499
504
|
if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey)) {
|
|
500
505
|
code += yield* this.defaultValue.toEmbeddedTS(shiftState(state, code), true);
|
|
506
|
+
} else {
|
|
507
|
+
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
501
508
|
}
|
|
509
|
+
} else {
|
|
502
510
|
code += 'undefined';
|
|
503
511
|
}
|
|
504
512
|
code += ' as ';
|
|
@@ -21,6 +21,8 @@ import { config } from '../config';
|
|
|
21
21
|
import type MemberExpression from './MemberExpression__';
|
|
22
22
|
import type Identifier from './Identifier__';
|
|
23
23
|
import { PAGE_COMPONENT_INCLUDE_TAG_MAP } from './View__';
|
|
24
|
+
import type BusinessComponent from './BusinessComponent__';
|
|
25
|
+
import type FrontendType from './FrontendType__';
|
|
24
26
|
|
|
25
27
|
import { kebab2Camel } from '../utils';
|
|
26
28
|
export interface ParseContext {
|
|
@@ -72,6 +74,8 @@ function genArgumentMemberExpression(arr: string[]) {
|
|
|
72
74
|
return expressionNode;
|
|
73
75
|
}
|
|
74
76
|
export interface ElementToVueOptions {
|
|
77
|
+
isRoot?: boolean;
|
|
78
|
+
asCompontent?: boolean;
|
|
75
79
|
indentStyle?: 'space' | 'tab';
|
|
76
80
|
tabSize?: number;
|
|
77
81
|
indentLevel?: number;
|
|
@@ -1551,6 +1555,10 @@ export class ViewElement extends BaseNode {
|
|
|
1551
1555
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
1552
1556
|
//================================================================================
|
|
1553
1557
|
|
|
1558
|
+
get likeComponent(): View | BusinessComponent {
|
|
1559
|
+
return this.view || (this?.getAncestor('BusinessComponent') as BusinessComponent);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1554
1562
|
/* 主页面有没有权限 */
|
|
1555
1563
|
get parentAuth() {
|
|
1556
1564
|
const _nameSpace = this.view.getNamespace();
|
|
@@ -1577,11 +1585,11 @@ export class ViewElement extends BaseNode {
|
|
|
1577
1585
|
}
|
|
1578
1586
|
|
|
1579
1587
|
getViewElementUniqueName(name = 'viewElement1') {
|
|
1580
|
-
return this.
|
|
1588
|
+
return this.likeComponent?.getViewElementUniqueName(name);
|
|
1581
1589
|
}
|
|
1582
1590
|
|
|
1583
1591
|
getViewElementUniqueNameOld(name = 'viewElement1') {
|
|
1584
|
-
return this.
|
|
1592
|
+
return this.likeComponent?.getViewElementUniqueNameOld(name);
|
|
1585
1593
|
}
|
|
1586
1594
|
|
|
1587
1595
|
public static readonly TAG_NAME_PREFIX_REG?: RegExp = /^([lieu]|van)[-_]/;
|
|
@@ -1627,16 +1635,16 @@ export class ViewElement extends BaseNode {
|
|
|
1627
1635
|
const self = this;
|
|
1628
1636
|
let code = '';
|
|
1629
1637
|
code += indent((state?.tabSize || 0) + 1);
|
|
1630
|
-
|
|
1631
|
-
|
|
1638
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
1639
|
+
code += `${self.name}: ${self.correspondingBusinessComponentNamespace}.${self.tag.replace('bs-', '')};\n`;
|
|
1640
|
+
} else if (self.toHump(self.tag) === 'lcapLogin' || self.staticClass === 'login-form') { // 登录组件不翻译
|
|
1632
1641
|
code += `${self.name}: nasl.ui.div<any>;\n`;
|
|
1633
1642
|
} else if (self.tag === 'u-table-view-column-dynamic') {
|
|
1634
1643
|
code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<any, any>;\n`;
|
|
1635
1644
|
} else if (Object.keys(PAGE_COMPONENT_INCLUDE_TAG_MAP).includes(self.tag)) {
|
|
1636
1645
|
if (self.bindAttrs?.findIndex((attr) => attr.name === 'data-source') > -1) {
|
|
1637
|
-
code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<__elements_completionProperty['${
|
|
1638
|
-
|
|
1639
|
-
}']['dataSource']>;\n`;
|
|
1646
|
+
code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<__elements_completionProperty['${self.name
|
|
1647
|
+
}']['dataSource']>;\n`;
|
|
1640
1648
|
} else {
|
|
1641
1649
|
code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<any>;\n`;
|
|
1642
1650
|
}
|
|
@@ -1722,12 +1730,11 @@ export class ViewElement extends BaseNode {
|
|
|
1722
1730
|
const _this = self.parentNode;
|
|
1723
1731
|
let genericity = '';
|
|
1724
1732
|
if (_this.tag === 'u-table-view-column-dynamic') {
|
|
1725
|
-
genericity += `<${(_this.parentNode as any).__tsVariableDataSourceTypeName}, ${
|
|
1726
|
-
|
|
1727
|
-
}>`;
|
|
1733
|
+
genericity += `<${(_this.parentNode as any).__tsVariableDataSourceTypeName}, ${(_this as any).__tsVariableDataSourceTypeName
|
|
1734
|
+
}>`;
|
|
1728
1735
|
} else {
|
|
1729
1736
|
let targetNode: any = _this;
|
|
1730
|
-
while (!targetNode.__tsVariableDataSourceTypeName && asserts.isViewElement(targetNode?.parentNode)) {
|
|
1737
|
+
while ((!targetNode.__tsVariableDataSourceTypeName || targetNode.__tsVariableDataSourceTypeName === 'any') && asserts.isViewElement(targetNode?.parentNode)) {
|
|
1731
1738
|
targetNode = targetNode.parentNode;
|
|
1732
1739
|
}
|
|
1733
1740
|
genericity += `<${(targetNode as any).__tsVariableDataSourceTypeName ?? 'any'}>`;
|
|
@@ -1866,10 +1873,39 @@ export class ViewElement extends BaseNode {
|
|
|
1866
1873
|
code += indent((state?.tabSize || 0) + 2);
|
|
1867
1874
|
return code;
|
|
1868
1875
|
}
|
|
1876
|
+
|
|
1877
|
+
// 获取端类型
|
|
1878
|
+
get frontendType() {
|
|
1879
|
+
return this.getAncestor('FrontendType') as FrontendType;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// 对应业务组件
|
|
1883
|
+
get isCorrespondingBusinessComponent() {
|
|
1884
|
+
return this.tag.startsWith('bs-');
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
// 对应的业务组件的Namespace
|
|
1888
|
+
get correspondingBusinessComponentNamespace() {
|
|
1889
|
+
return `${this.frontendType?.getNamespace()}.${this.frontendType?.name}.businessComponents`;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
// 获取对应的业务组件
|
|
1893
|
+
get correspondingBusinessComponent() {
|
|
1894
|
+
if (this.isCorrespondingBusinessComponent) {
|
|
1895
|
+
// 端下的业务组件
|
|
1896
|
+
const businessComponents = this.frontendType?.businessComponents;
|
|
1897
|
+
const businessComponent = businessComponents.find((businessComponent) => {
|
|
1898
|
+
return `bs-${businessComponent?.name}` === this.tag;
|
|
1899
|
+
});
|
|
1900
|
+
return businessComponent;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
|
|
1869
1905
|
@withSourceMapGenerator
|
|
1870
1906
|
*toEmbeddedTS(state = createCompilerState(), parentLevel?: number): TranslatorGenerator {
|
|
1871
1907
|
const self = this;
|
|
1872
|
-
const { parentNode, app, tag, staticClass, name,
|
|
1908
|
+
const { parentNode, app, tag, staticClass, name, bindRoles, bindEvents, children } = self;
|
|
1873
1909
|
const chineseTsName = (name: string) => {
|
|
1874
1910
|
let tsName = name;
|
|
1875
1911
|
// 匹配所有特殊字符都转为_
|
|
@@ -1945,8 +1981,12 @@ export class ViewElement extends BaseNode {
|
|
|
1945
1981
|
code += '},\n';
|
|
1946
1982
|
return code;
|
|
1947
1983
|
}
|
|
1984
|
+
let namespace = `nasl.ui.${self.toHump(tag)}`;
|
|
1985
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
1986
|
+
namespace = `${self.correspondingBusinessComponentNamespace}.${self.tag.replace('bs-', '')}`;
|
|
1987
|
+
}
|
|
1948
1988
|
// 后面那个name是为了查找引用的时候用的
|
|
1949
|
-
let code = `new
|
|
1989
|
+
let code = `new ${namespace}${self.getTypeArgmentsStr(state)}({name: __elements.${name},\n`;
|
|
1950
1990
|
// 是否开启权限
|
|
1951
1991
|
// const hasAuth = Array.isArray(bindDirectives)
|
|
1952
1992
|
// ? !!bindDirectives.filter((directive) => directive.name === 'auth').length
|
|
@@ -1978,8 +2018,18 @@ export class ViewElement extends BaseNode {
|
|
|
1978
2018
|
if (Array.isArray(children)) {
|
|
1979
2019
|
code += indent((state?.tabSize || 0) + 1);
|
|
1980
2020
|
if (Array.isArray(self.bindAttrs)) {
|
|
1981
|
-
code += `bindAttr:
|
|
2021
|
+
code += `bindAttr: `;
|
|
2022
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
2023
|
+
code += `{\n`;
|
|
2024
|
+
} else {
|
|
2025
|
+
code += `() => [\n`;
|
|
2026
|
+
}
|
|
1982
2027
|
yield* wrapForEach(self.bindAttrs, function* warpForEachGenerator(attr) {
|
|
2028
|
+
// 过滤自由布局的key
|
|
2029
|
+
const shouldFilter = self.isCorrespondingBusinessComponent && (attr.name === 'key' && !attr.expression);
|
|
2030
|
+
if (shouldFilter) {
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
1983
2033
|
code += (yield* attr.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }))) + ',\n';
|
|
1984
2034
|
});
|
|
1985
2035
|
yield* wrapForEach(self.bindDirectives, function* warpForEachGenerator(directive) {
|
|
@@ -1988,7 +2038,12 @@ export class ViewElement extends BaseNode {
|
|
|
1988
2038
|
yield* wrapForEach(self.bindStyles, function* warpForEachGenerator(bindStyle) {
|
|
1989
2039
|
code += (yield* bindStyle.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }))) + ',\n';
|
|
1990
2040
|
});
|
|
1991
|
-
code += indent((state?.tabSize || 0) + 2)
|
|
2041
|
+
code += indent((state?.tabSize || 0) + 2)
|
|
2042
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
2043
|
+
code += '},\n';
|
|
2044
|
+
} else {
|
|
2045
|
+
code += '],\n';
|
|
2046
|
+
}
|
|
1992
2047
|
}
|
|
1993
2048
|
// 如果子集中有插槽的就
|
|
1994
2049
|
if (children.find((item) => item.tag === 'template' && item.slotTarget)) {
|
|
@@ -2049,7 +2104,7 @@ export class ViewElement extends BaseNode {
|
|
|
2049
2104
|
}
|
|
2050
2105
|
code += indent(state?.tabSize || 0) + '})';
|
|
2051
2106
|
// 顶层元素是单独的表达式
|
|
2052
|
-
if (parentNode.concept === 'View') {
|
|
2107
|
+
if (parentNode.concept === 'View' || asserts.isBusinessComponent(parentNode)) {
|
|
2053
2108
|
code += ';\n';
|
|
2054
2109
|
} else {
|
|
2055
2110
|
code += ',\n';
|
|
@@ -2162,10 +2217,20 @@ export class ViewElement extends BaseNode {
|
|
|
2162
2217
|
{ mode: 'anyObject', excludedKeySet: element.JSON_EXCLUDED_KEYS },
|
|
2163
2218
|
);
|
|
2164
2219
|
|
|
2165
|
-
this.
|
|
2220
|
+
this.likeComponent?.existingViewElement.clear();
|
|
2166
2221
|
return element;
|
|
2167
2222
|
}
|
|
2168
2223
|
|
|
2224
|
+
setTag(tag: string) {
|
|
2225
|
+
const object = {
|
|
2226
|
+
tag,
|
|
2227
|
+
};
|
|
2228
|
+
this.update({
|
|
2229
|
+
...object,
|
|
2230
|
+
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2169
2234
|
// 递归遍历组件
|
|
2170
2235
|
public traverseChildren(cb: (ele: ViewElement) => void): void {
|
|
2171
2236
|
utils.traverse(
|
|
@@ -2224,7 +2289,7 @@ export class ViewElement extends BaseNode {
|
|
|
2224
2289
|
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
2225
2290
|
}));
|
|
2226
2291
|
}
|
|
2227
|
-
} catch (error) {}
|
|
2292
|
+
} catch (error) { }
|
|
2228
2293
|
|
|
2229
2294
|
return {
|
|
2230
2295
|
concept: 'ValidationRule',
|
|
@@ -2519,8 +2584,10 @@ export class ViewElement extends BaseNode {
|
|
|
2519
2584
|
* 转换成设计器中使用的 Vue 文件
|
|
2520
2585
|
* @param options
|
|
2521
2586
|
*/
|
|
2522
|
-
toDesignerVue() {
|
|
2587
|
+
toDesignerVue(options?: { isRoot: boolean; asCompontent?: boolean }) {
|
|
2523
2588
|
return this.toVue({
|
|
2589
|
+
isRoot: options?.isRoot,
|
|
2590
|
+
asCompontent: options?.asCompontent,
|
|
2524
2591
|
finalCode: false,
|
|
2525
2592
|
nodePathAttr: true,
|
|
2526
2593
|
attrFormat: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => {
|
|
@@ -2655,12 +2722,16 @@ export class ViewElement extends BaseNode {
|
|
|
2655
2722
|
});
|
|
2656
2723
|
}
|
|
2657
2724
|
|
|
2725
|
+
isLikeComponent(node: types.SyntaxNode) {
|
|
2726
|
+
return ['View', 'BusinessComponent'].includes(node?.concept);
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2658
2729
|
// 获取currentList
|
|
2659
2730
|
getCurrentList() {
|
|
2660
2731
|
const argsList: string[] = [];
|
|
2661
2732
|
let parent = this.parentNode;
|
|
2662
2733
|
let index = 0;
|
|
2663
|
-
while (parent && parent
|
|
2734
|
+
while (parent && !this.isLikeComponent(parent)) {
|
|
2664
2735
|
if ((parent as ViewElement).slotScope) {
|
|
2665
2736
|
argsList.push(index === 0 ? 'current' : 'current' + index);
|
|
2666
2737
|
index++;
|
|
@@ -2700,6 +2771,10 @@ export class ViewElement extends BaseNode {
|
|
|
2700
2771
|
return null;
|
|
2701
2772
|
}
|
|
2702
2773
|
|
|
2774
|
+
get businessComponent() {
|
|
2775
|
+
return this.getAncestor('BusinessComponent');
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2703
2778
|
/**
|
|
2704
2779
|
* 转换成 Vue 的模板格式
|
|
2705
2780
|
*/
|
|
@@ -2710,6 +2785,65 @@ export class ViewElement extends BaseNode {
|
|
|
2710
2785
|
return ``;
|
|
2711
2786
|
}
|
|
2712
2787
|
|
|
2788
|
+
const { finalCode, asCompontent } = options || {};
|
|
2789
|
+
const parts: string[] = [];
|
|
2790
|
+
if (finalCode === false) {
|
|
2791
|
+
if (this.tag === 'slot') {
|
|
2792
|
+
if (asCompontent) {
|
|
2793
|
+
return `<div vusion-slot-name="${this.name}">
|
|
2794
|
+
<slot name="${this.name}">
|
|
2795
|
+
<div s-empty="true" bs-empty="true" style="background: #f7f8fa;
|
|
2796
|
+
border: 1px dashed #c3c3c3;
|
|
2797
|
+
text-align: center;
|
|
2798
|
+
color: #999;
|
|
2799
|
+
min-height: 32px;
|
|
2800
|
+
min-width: 32px;
|
|
2801
|
+
width: 100%;
|
|
2802
|
+
align-items: center;
|
|
2803
|
+
display: inline-flex;
|
|
2804
|
+
justify-content: center;">
|
|
2805
|
+
+
|
|
2806
|
+
</div>
|
|
2807
|
+
</slot>
|
|
2808
|
+
</div>`;
|
|
2809
|
+
} else {
|
|
2810
|
+
return `<div vusion-node-path="${this.nodePath}"
|
|
2811
|
+
style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
|
|
2812
|
+
background-size: 45px 45px;
|
|
2813
|
+
background-repeat: repeat;
|
|
2814
|
+
line-height: 32px;
|
|
2815
|
+
min-height: 32px;
|
|
2816
|
+
color: var(--font-second-color);
|
|
2817
|
+
text-align: center;">
|
|
2818
|
+
组件占位,可在使用业务组件时插入任意组件
|
|
2819
|
+
</div>`;
|
|
2820
|
+
}
|
|
2821
|
+
} else if (this.businessComponent?.name === this.tag) {
|
|
2822
|
+
// 组件内部使用自身的情况
|
|
2823
|
+
return `<div vusion-node-path="${this.nodePath}"
|
|
2824
|
+
style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
|
|
2825
|
+
background-size: 45px 45px;
|
|
2826
|
+
background-repeat: repeat;
|
|
2827
|
+
line-height: 32px;
|
|
2828
|
+
min-height: 32px;
|
|
2829
|
+
color: var(--font-second-color);
|
|
2830
|
+
text-align: center;">
|
|
2831
|
+
在组件内部使用自身可能会导致循环引用,请谨慎使用
|
|
2832
|
+
</div>`;
|
|
2833
|
+
}
|
|
2834
|
+
const isRoot = options.isRoot;
|
|
2835
|
+
if (isRoot && !options?.asCompontent) {
|
|
2836
|
+
parts.push('type="root"');
|
|
2837
|
+
if (this.frontendType?.kind === 'h5') {
|
|
2838
|
+
parts.push('class="l-root-h5"');
|
|
2839
|
+
} else {
|
|
2840
|
+
parts.push('style="height:100%; --custom-start: auto; min-height: 200px;"');
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
if (options) {
|
|
2845
|
+
options.isRoot = false;
|
|
2846
|
+
}
|
|
2713
2847
|
let currentList: string[] = [];
|
|
2714
2848
|
if (Array.isArray(options?.currentList)) {
|
|
2715
2849
|
currentList = [...options?.currentList];
|
|
@@ -2748,16 +2882,15 @@ export class ViewElement extends BaseNode {
|
|
|
2748
2882
|
const content: string = !this.children
|
|
2749
2883
|
? ''
|
|
2750
2884
|
: this.children
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2885
|
+
.map((element) => {
|
|
2886
|
+
const childOptions = Object.assign({}, newOptions);
|
|
2887
|
+
childOptions.indentLevel++;
|
|
2888
|
+
return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
|
|
2889
|
+
})
|
|
2890
|
+
.join('');
|
|
2757
2891
|
if (!content.length) {
|
|
2758
2892
|
shouldIndent = false;
|
|
2759
2893
|
}
|
|
2760
|
-
const parts: string[] = [];
|
|
2761
2894
|
if (newOptions.aslIdAttr) {
|
|
2762
2895
|
if (newOptions.aslIdAttr === true) {
|
|
2763
2896
|
newOptions.aslIdAttr = 'asl-id';
|
|
@@ -2772,9 +2905,9 @@ export class ViewElement extends BaseNode {
|
|
|
2772
2905
|
this.slotTarget &&
|
|
2773
2906
|
parts.push(
|
|
2774
2907
|
`#${this.slotTarget}` +
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2908
|
+
(this.slotScope
|
|
2909
|
+
? `="${currentList.length > 1 ? this.slotScope + (currentList.length - 1) : this.slotScope}"`
|
|
2910
|
+
: ''),
|
|
2778
2911
|
);
|
|
2779
2912
|
this.refName && parts.push(`:ref="\`${this.refName}\`"`);
|
|
2780
2913
|
this.keyName && parts.push(`:key="\`${this.keyName}\`"`);
|
|
@@ -2820,7 +2953,9 @@ export class ViewElement extends BaseNode {
|
|
|
2820
2953
|
) {
|
|
2821
2954
|
this.name && parts.push(`key="${this.name}"`);
|
|
2822
2955
|
}
|
|
2823
|
-
|
|
2956
|
+
if (this.tag === 'slot') {
|
|
2957
|
+
this.name && parts.push(`name="${this.name}"`);
|
|
2958
|
+
}
|
|
2824
2959
|
let partsLength = 0;
|
|
2825
2960
|
let partsString = '';
|
|
2826
2961
|
parts.forEach((part) => {
|
|
@@ -2853,7 +2988,7 @@ export class ViewElement extends BaseNode {
|
|
|
2853
2988
|
super.delete();
|
|
2854
2989
|
if (this.parentNode) {
|
|
2855
2990
|
this.traverseChildren((ele: ViewElement) => {
|
|
2856
|
-
(this.
|
|
2991
|
+
(this.likeComponent as any)?.removeExistingViewElement(ele);
|
|
2857
2992
|
});
|
|
2858
2993
|
}
|
|
2859
2994
|
}
|
|
@@ -2891,7 +3026,7 @@ export class ViewElement extends BaseNode {
|
|
|
2891
3026
|
let current = 'current';
|
|
2892
3027
|
let parent = this.parentNode;
|
|
2893
3028
|
let index = 0;
|
|
2894
|
-
while (parent && parent
|
|
3029
|
+
while (parent && !this.isLikeComponent(parent)) {
|
|
2895
3030
|
if ((parent as ViewElement).slotScope) {
|
|
2896
3031
|
index++;
|
|
2897
3032
|
}
|
package/src/concepts/View__.ts
CHANGED
|
@@ -1690,7 +1690,7 @@ export class View extends BaseNode {
|
|
|
1690
1690
|
newName = name.replace(/\d*$/, (m) => `_${BranchCopyUniCode}_${m}`);
|
|
1691
1691
|
}
|
|
1692
1692
|
// 主分支无 BranchCopyUniCode
|
|
1693
|
-
if (!BranchCopyUniCode && prefix
|
|
1693
|
+
if (!BranchCopyUniCode && prefix?.at(-1) !== '_') {
|
|
1694
1694
|
newName = name.replace(/\d*$/, (m) => `_${m}`);
|
|
1695
1695
|
}
|
|
1696
1696
|
const newPrefix = newName.replace(/\d*$/, '');
|
|
@@ -1836,22 +1836,6 @@ export class View extends BaseNode {
|
|
|
1836
1836
|
});
|
|
1837
1837
|
}
|
|
1838
1838
|
|
|
1839
|
-
// 页面逻辑
|
|
1840
|
-
if (Array.isArray(definition.viewLogics)) {
|
|
1841
|
-
definition.viewLogics.forEach((logicOption: any) => {
|
|
1842
|
-
// 页面逻辑只有load函数的走之前的逻辑其余不用创建
|
|
1843
|
-
if (logicOption.name.startsWith('load')) {
|
|
1844
|
-
// const logic = Logic.from(
|
|
1845
|
-
// {
|
|
1846
|
-
// ...logicOption,
|
|
1847
|
-
// },
|
|
1848
|
-
// this,
|
|
1849
|
-
// 'logics'
|
|
1850
|
-
// );
|
|
1851
|
-
// this.addLogic(logic);
|
|
1852
|
-
}
|
|
1853
|
-
});
|
|
1854
|
-
}
|
|
1855
1839
|
// 页面事件
|
|
1856
1840
|
if (Array.isArray(definition.viewBindEvents)) {
|
|
1857
1841
|
definition.viewBindEvents.forEach((eventOption: any) => {
|
|
@@ -1867,7 +1851,7 @@ export class View extends BaseNode {
|
|
|
1867
1851
|
logics: [newLogic],
|
|
1868
1852
|
},
|
|
1869
1853
|
this,
|
|
1870
|
-
'
|
|
1854
|
+
'bindEvents',
|
|
1871
1855
|
);
|
|
1872
1856
|
this.addBindEvent(event);
|
|
1873
1857
|
} else {
|
|
@@ -1935,6 +1919,23 @@ export class View extends BaseNode {
|
|
|
1935
1919
|
}
|
|
1936
1920
|
});
|
|
1937
1921
|
}
|
|
1922
|
+
this.traverseChildren((node) => {
|
|
1923
|
+
switch (node?.concept) {
|
|
1924
|
+
case 'ForEachStatement':
|
|
1925
|
+
if (node.item) {
|
|
1926
|
+
varList.push(node?.item);
|
|
1927
|
+
}
|
|
1928
|
+
if (node.index) {
|
|
1929
|
+
varList.push(node?.index);
|
|
1930
|
+
}
|
|
1931
|
+
break;
|
|
1932
|
+
case 'AnonymousFunction':
|
|
1933
|
+
node.params?.forEach((param: Param) => {
|
|
1934
|
+
varList.push(param);
|
|
1935
|
+
});
|
|
1936
|
+
break;
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1938
1939
|
return varList.filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
1939
1940
|
}
|
|
1940
1941
|
|
|
@@ -1990,7 +1991,7 @@ export class View extends BaseNode {
|
|
|
1990
1991
|
.join('\n')}
|
|
1991
1992
|
}
|
|
1992
1993
|
}
|
|
1993
|
-
}
|
|
1994
|
+
};\n`;
|
|
1994
1995
|
code += keyboardEventMixinCode;
|
|
1995
1996
|
if (this.script) {
|
|
1996
1997
|
mixin = this.script.trim().replace(/export default |module\.exports +=/, 'const mixin = ');
|
|
@@ -2069,7 +2070,9 @@ export class View extends BaseNode {
|
|
|
2069
2070
|
parent = parent.parentNode;
|
|
2070
2071
|
}
|
|
2071
2072
|
}
|
|
2072
|
-
return `/embedded/${this.
|
|
2073
|
+
return `/embedded/${this.getAncestor('App')?.name}/frontendTypes/${
|
|
2074
|
+
this.getAncestor('FrontendType')?.name
|
|
2075
|
+
}/frontends/${this.getAncestor('Frontend')?.name}/views/${pathName}.ts`;
|
|
2073
2076
|
}
|
|
2074
2077
|
|
|
2075
2078
|
getNamespace(): string {
|
package/src/concepts/index__.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './App__';
|
|
2
2
|
export * from './Module__';
|
|
3
3
|
export * from './Namespace__';
|
|
4
|
+
export * from './FrontendType__';
|
|
4
5
|
export * from './Frontend__';
|
|
5
6
|
export * from './Backend__';
|
|
6
7
|
export * from './Integration__';
|
|
@@ -24,6 +25,7 @@ export * from './BindDirective__';
|
|
|
24
25
|
export * from './BindEvent__';
|
|
25
26
|
export * from './BindStyle__';
|
|
26
27
|
export * from './ViewComponent__';
|
|
28
|
+
export * from './BusinessComponent__';
|
|
27
29
|
export * from './Attribute__';
|
|
28
30
|
export * from './Event__';
|
|
29
31
|
export * from './Slot__';
|
|
@@ -31,10 +33,12 @@ export * from './Theme__';
|
|
|
31
33
|
export * from './StaticString__';
|
|
32
34
|
export * from './Logic__';
|
|
33
35
|
export * from './AuthLogic__';
|
|
36
|
+
export * from './BusinessLogic__';
|
|
34
37
|
export * from './AuthLogicForCallInterface__';
|
|
35
38
|
export * from './OverriddenLogic__';
|
|
36
39
|
export * from './AbstractInterface__';
|
|
37
40
|
export * from './Param__';
|
|
41
|
+
export * from './ParamWithGroup__';
|
|
38
42
|
export * from './Return__';
|
|
39
43
|
export * from './Variable__';
|
|
40
44
|
export * from './BackendVariable__';
|
|
@@ -60,6 +64,7 @@ export * from './Assignment__';
|
|
|
60
64
|
export * from './BatchAssignment__';
|
|
61
65
|
export * from './Comment__';
|
|
62
66
|
export * from './CallLogic__';
|
|
67
|
+
export * from './CallEvent__';
|
|
63
68
|
export * from './CallFunction__';
|
|
64
69
|
export * from './CallInterface__';
|
|
65
70
|
export * from './Destination__';
|