@lcap/nasl 0.3.10-beta → 0.3.10-beta.nocache
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/types/app/App.d.ts +1 -4
- package/out/types/app/App.js +0 -24
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/Service.js +2 -2
- package/out/types/app/Service.js.map +1 -1
- package/out/types/index.d.ts +1 -3
- package/out/types/index.js +2 -6
- package/out/types/index.js.map +1 -1
- package/out/types/logic/Logic.d.ts +0 -12
- package/out/types/logic/Logic.js +0 -14
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +1 -20
- package/out/types/logic/LogicItem.js +0 -184
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/page/View.d.ts +2 -16
- package/out/types/page/View.js +5 -16
- package/out/types/page/View.js.map +1 -1
- package/package.json +1 -2
- package/src/types/app/App.ts +1 -27
- package/src/types/app/Service.ts +2 -2
- package/src/types/index.ts +1 -3
- package/src/types/logic/Logic.ts +0 -24
- package/src/types/logic/LogicItem.ts +5 -207
- package/src/types/logic/translator.js +86 -146
- package/src/types/page/View.ts +7 -28
- package/src/types/page/dist/View.js +727 -0
- package/tsconfig.json +1 -1
- package/out/service/debugger/debugger.d.ts +0 -3
- package/out/service/debugger/debugger.js +0 -95
- package/out/service/debugger/debugger.js.map +0 -1
- package/out/test/units/config.spec.d.ts +0 -1
- package/out/test/units/config.spec.js +0 -12
- package/out/test/units/config.spec.js.map +0 -1
- package/out/types/logic/BreakPoint.d.ts +0 -42
- package/out/types/logic/BreakPoint.js +0 -155
- package/out/types/logic/BreakPoint.js.map +0 -1
- package/out/types/logic/Debugger.d.ts +0 -156
- package/out/types/logic/Debugger.js +0 -912
- package/out/types/logic/Debugger.js.map +0 -1
- package/src/service/debugger/debugger.js +0 -90
- package/src/types/logic/BreakPoint.ts +0 -200
- package/src/types/logic/Debugger.ts +0 -1140
- package/src/types/logic/translator.d.ts +0 -16
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Vertex } from '..';
|
|
2
2
|
|
|
3
|
-
function switchCase2If(
|
|
3
|
+
function switchCase2If(cases) {
|
|
4
4
|
const cas = cases.shift();
|
|
5
5
|
|
|
6
6
|
const result = {
|
|
7
7
|
type: 'IfStatement',
|
|
8
8
|
test: cas.test,
|
|
9
|
-
level: 'logicNode',
|
|
10
|
-
id: cas.id,
|
|
11
9
|
consequent: {
|
|
12
10
|
type: 'BlockStatement',
|
|
13
11
|
body: cas.consequent || [],
|
|
@@ -16,19 +14,18 @@ function switchCase2If(node, cases, idx = 0) {
|
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
if (cases.length) {
|
|
19
|
-
result.alternate = switchCase2If(
|
|
17
|
+
result.alternate = switchCase2If(cases);
|
|
20
18
|
} else {
|
|
21
19
|
return {
|
|
22
20
|
type: 'BlockStatement',
|
|
23
21
|
body: cas.consequent || [],
|
|
24
|
-
id: cas.id,
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
return result;
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
export default function (source
|
|
28
|
+
export default function (source) {
|
|
32
29
|
const definition = typeof source === 'string' ? JSON.parse(source) : source;
|
|
33
30
|
|
|
34
31
|
function traverse(node, func, parent, index) {
|
|
@@ -124,35 +121,6 @@ export default function (source, preScript) {
|
|
|
124
121
|
}
|
|
125
122
|
}`);
|
|
126
123
|
|
|
127
|
-
let output = `
|
|
128
|
-
const methods = componentOptions.methods = componentOptions.methods || {};
|
|
129
|
-
const computed = componentOptions.computed = componentOptions.computed || {};
|
|
130
|
-
const oldDataFunc = componentOptions.data;
|
|
131
|
-
const data = function () {
|
|
132
|
-
const oldData = oldDataFunc ? oldDataFunc.call(this) : {};
|
|
133
|
-
return Object.assign(oldData, {
|
|
134
|
-
${paramsData ? paramsData + ',' : ''}
|
|
135
|
-
${variablesData}
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
componentOptions.data = data;
|
|
139
|
-
const meta = componentOptions.meta = componentOptions.meta || {};
|
|
140
|
-
Object.assign(meta, {
|
|
141
|
-
title: ${JSON.stringify(definition.title)},
|
|
142
|
-
crumb: ${JSON.stringify(definition.crumb)},
|
|
143
|
-
first: ${JSON.stringify(definition.first)},
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
${lifecycles.join('\n\n')}
|
|
147
|
-
|
|
148
|
-
`;
|
|
149
|
-
|
|
150
|
-
let startLineNumber = output.split('\n').length;
|
|
151
|
-
if (preScript && typeof preScript === 'string') {
|
|
152
|
-
startLineNumber += (preScript.split('\n').length - 2);
|
|
153
|
-
}
|
|
154
|
-
// console.log(preScript.split('\n').length, output.split('\n').length, startLineNumber);
|
|
155
|
-
const sourceMap = {};
|
|
156
124
|
const methods = (definition.logics || []).map((logic) => {
|
|
157
125
|
let returnObj = {
|
|
158
126
|
type: 'Identifier',
|
|
@@ -162,18 +130,10 @@ export default function (source, preScript) {
|
|
|
162
130
|
if (logic.returns[0])
|
|
163
131
|
returnObj = logic.returns[0];
|
|
164
132
|
|
|
165
|
-
|
|
166
|
-
const recorder = {
|
|
167
|
-
line: startLineNumber,
|
|
168
|
-
};
|
|
169
|
-
const _newLine = () => '\n';
|
|
170
|
-
const newLine = () => {
|
|
171
|
-
recorder.line += 1;
|
|
172
|
-
return _newLine();
|
|
173
|
-
};
|
|
133
|
+
const newLine = () => '\n';
|
|
174
134
|
const colon = () => ';';
|
|
175
135
|
|
|
176
|
-
const
|
|
136
|
+
const generateNode = (node, logicItemIndex) => {
|
|
177
137
|
if (!node)
|
|
178
138
|
return '';
|
|
179
139
|
if (node.type === 'End') {
|
|
@@ -218,7 +178,7 @@ export default function (source, preScript) {
|
|
|
218
178
|
return `${object}[${property.value}]`;
|
|
219
179
|
}
|
|
220
180
|
if (node.type === 'AssignmentExpression') {
|
|
221
|
-
return `${generateNode(node.left)} = ${generateNode(node.right)}${colon()}${newLine()}`;
|
|
181
|
+
return `${newLine()}${generateNode(node.left)} = ${generateNode(node.right)}${colon()}${newLine()}`;
|
|
222
182
|
}
|
|
223
183
|
if (node.type === 'CallExpression') {
|
|
224
184
|
const args = [];
|
|
@@ -267,29 +227,23 @@ export default function (source, preScript) {
|
|
|
267
227
|
const interfaceKeyTarget = Vertex.getVertexByRef(key);
|
|
268
228
|
const arr = key.split('/');
|
|
269
229
|
const download = interfaceKeyTarget && interfaceKeyTarget.name && interfaceKeyTarget.name.includes('export');
|
|
270
|
-
return `await
|
|
230
|
+
return `await this.$services['_custom']['ID_${arr[arr.length - 1]}']({
|
|
271
231
|
config: {
|
|
272
232
|
download: ${download},
|
|
273
233
|
},
|
|
274
234
|
path: {
|
|
275
|
-
${getParams('path').join('
|
|
235
|
+
${getParams('path').join(',\n')}
|
|
276
236
|
},
|
|
277
237
|
query: {
|
|
278
|
-
${getParams('query').join('
|
|
238
|
+
${getParams('query').join(',\n')}
|
|
279
239
|
},
|
|
280
240
|
headers: {
|
|
281
|
-
${getParams('header').join('
|
|
241
|
+
${getParams('header').join(',\n')}
|
|
282
242
|
},
|
|
283
243
|
body: ${getParams('body') || '{}'},
|
|
284
|
-
})
|
|
285
|
-
console.debug('logic-trace-end');
|
|
286
|
-
return result;
|
|
287
|
-
})();
|
|
288
|
-
`;
|
|
244
|
+
})`;
|
|
289
245
|
} else {
|
|
290
|
-
return `await
|
|
291
|
-
console.debug('logic-trace-end');return result; })()
|
|
292
|
-
`;
|
|
246
|
+
return `await this.${node.calleeCode}(${node.params.map((param) => generateNode(param.callInterParamValue) || 'undefined').join(',')})`;
|
|
293
247
|
}
|
|
294
248
|
}
|
|
295
249
|
|
|
@@ -328,24 +282,21 @@ export default function (source, preScript) {
|
|
|
328
282
|
const interfaceKeyTarget = Vertex.getVertexByRef(node.interfaceKey);
|
|
329
283
|
const download = interfaceKeyTarget && interfaceKeyTarget.name && interfaceKeyTarget.name.includes('export');
|
|
330
284
|
|
|
331
|
-
return `await
|
|
285
|
+
return `await this.$services['_custom']['ID_${arr[arr.length - 1]}']({
|
|
332
286
|
config: {
|
|
333
287
|
download: ${download},
|
|
334
288
|
},
|
|
335
289
|
path: {
|
|
336
|
-
${getParams('path').join('
|
|
290
|
+
${getParams('path').join(',\n')}
|
|
337
291
|
},
|
|
338
292
|
query: {
|
|
339
|
-
${getParams('query').join('
|
|
293
|
+
${getParams('query').join(',\n')}
|
|
340
294
|
},
|
|
341
295
|
headers: {
|
|
342
|
-
${getParams('header').join('
|
|
296
|
+
${getParams('header').join(',\n')}
|
|
343
297
|
},
|
|
344
298
|
body: ${getParams('body') || '{}'},
|
|
345
|
-
})
|
|
346
|
-
console.debug('logic-trace-end');
|
|
347
|
-
return result; })()
|
|
348
|
-
`;
|
|
299
|
+
})`;
|
|
349
300
|
}
|
|
350
301
|
|
|
351
302
|
if (node.type === 'CallGraphQL') {
|
|
@@ -400,13 +351,13 @@ export default function (source, preScript) {
|
|
|
400
351
|
download: ${key.includes('export')},
|
|
401
352
|
},
|
|
402
353
|
path: {
|
|
403
|
-
${getParams('path').join('
|
|
354
|
+
${getParams('path').join(',\n')}
|
|
404
355
|
},
|
|
405
356
|
query: {
|
|
406
|
-
${getParams('query').join('
|
|
357
|
+
${getParams('query').join(',\n')}
|
|
407
358
|
},
|
|
408
359
|
headers: {
|
|
409
|
-
${getParams('header').join('
|
|
360
|
+
${getParams('header').join(',\n')}
|
|
410
361
|
},
|
|
411
362
|
body: ${getParams('body') || '{}'},
|
|
412
363
|
})).Data`;
|
|
@@ -417,7 +368,7 @@ export default function (source, preScript) {
|
|
|
417
368
|
.filter((param) => param.in === undefined) // 放在body内部的参数
|
|
418
369
|
.filter((param) => generateNode(param.value) !== '')
|
|
419
370
|
.map((param) => `${safeKey(param.name)}: ${generateNode(param.value)}`)
|
|
420
|
-
.join('
|
|
371
|
+
.join(',\n');
|
|
421
372
|
const getObj = (type) =>
|
|
422
373
|
(node.params || [])
|
|
423
374
|
.filter((param) => param.in === type)
|
|
@@ -500,11 +451,11 @@ export default function (source, preScript) {
|
|
|
500
451
|
}
|
|
501
452
|
|
|
502
453
|
if (node.type === 'CallMessageShow') {
|
|
503
|
-
return
|
|
454
|
+
return `${newLine()}this.$toast.show(${generateNode(node.arguments[0])})${colon()}${newLine()}`;
|
|
504
455
|
}
|
|
505
456
|
|
|
506
457
|
if (node.type === 'CallConsoleLog') {
|
|
507
|
-
return
|
|
458
|
+
return `${newLine()}console.log(${generateNode(node.arguments[0])})${colon()}${newLine()}`;
|
|
508
459
|
}
|
|
509
460
|
|
|
510
461
|
if (node.type === 'Destination') {
|
|
@@ -537,11 +488,12 @@ export default function (source, preScript) {
|
|
|
537
488
|
};
|
|
538
489
|
}
|
|
539
490
|
|
|
540
|
-
let resultScript = `if(${generateNode(node.test)}) ${generateNode(node.consequent)}`;
|
|
541
491
|
let alternateScript = '';
|
|
542
492
|
if (node.alternate) {
|
|
543
493
|
alternateScript = generateNode(node.alternate);
|
|
544
494
|
}
|
|
495
|
+
|
|
496
|
+
let resultScript = `if(${generateNode(node.test)}) ${generateNode(node.consequent)}`;
|
|
545
497
|
resultScript = alternateScript ? `${resultScript} else ${alternateScript}` : resultScript;
|
|
546
498
|
return resultScript;
|
|
547
499
|
}
|
|
@@ -550,41 +502,51 @@ export default function (source, preScript) {
|
|
|
550
502
|
if (!node.body) {
|
|
551
503
|
return '';
|
|
552
504
|
}
|
|
553
|
-
const str = `{${newLine()}`;
|
|
554
505
|
const body = (node.body || []).map((body) => `${generateNode(body)}${colon()}${newLine()}`);
|
|
555
|
-
return
|
|
506
|
+
return `{
|
|
507
|
+
${body.join(' ')}
|
|
508
|
+
}`;
|
|
556
509
|
}
|
|
557
510
|
|
|
558
511
|
if (node.type === 'WhileStatement') {
|
|
559
|
-
let bodyScript =
|
|
512
|
+
let bodyScript = '';
|
|
560
513
|
if (Array.isArray(node.body)) {
|
|
561
514
|
node.body.forEach((body) => {
|
|
562
515
|
bodyScript += `${generateNode(body)}${newLine()}`;
|
|
563
516
|
});
|
|
564
517
|
}
|
|
565
|
-
return `${
|
|
518
|
+
return `${newLine()}while(${generateNode(node.test)}) {
|
|
519
|
+
${bodyScript}
|
|
520
|
+
}${newLine()}`;
|
|
566
521
|
}
|
|
567
522
|
|
|
568
523
|
if (node.type === 'SwitchStatement') {
|
|
569
|
-
|
|
570
|
-
return
|
|
524
|
+
Object.assign(node, switchCase2If(node.cases));
|
|
525
|
+
return generateNode(node);
|
|
571
526
|
}
|
|
572
527
|
|
|
573
528
|
if (node.type === 'ForEachStatement') {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
529
|
+
let bodyScript = '';
|
|
530
|
+
if (Array.isArray(node.body)) {
|
|
531
|
+
node.body.forEach((body) => {
|
|
532
|
+
bodyScript += `${generateNode(body)}${newLine()}`;
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
const indexScript = generateNode(node.index);
|
|
536
|
+
const startScript = generateNode(node.start);
|
|
537
|
+
const itemScript = generateNode(node.item);
|
|
538
|
+
const endScript = generateNode(node.end);
|
|
539
|
+
const eachScript = generateNode(node.each);
|
|
583
540
|
|
|
584
541
|
if (node.label === 'async') { // 临时测试 async 的方式
|
|
585
|
-
return
|
|
542
|
+
return `${newLine()}await Promise.all(${eachScript}.slice(${startScript}, ${endScript}).map(async (${itemScript}, ${indexScript}) => {
|
|
543
|
+
${bodyScript}
|
|
544
|
+
})${newLine()}`;
|
|
586
545
|
} else {
|
|
587
|
-
return
|
|
546
|
+
return `${newLine()}for (let ${indexScript}=${startScript}; ${indexScript} < ${endScript}; ${indexScript}++){
|
|
547
|
+
const ${itemScript} = ${eachScript}[${indexScript}];
|
|
548
|
+
${bodyScript}
|
|
549
|
+
}${newLine()}`;
|
|
588
550
|
}
|
|
589
551
|
}
|
|
590
552
|
|
|
@@ -601,16 +563,12 @@ export default function (source, preScript) {
|
|
|
601
563
|
}
|
|
602
564
|
|
|
603
565
|
if (node.type === 'JSBlock') {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
// await jsBlock_${logicItemIndex}();
|
|
610
|
-
// }${newLine()}`;
|
|
566
|
+
return `${newLine()}{
|
|
567
|
+
const jsBlock_${logicItemIndex} = async () => {
|
|
568
|
+
${node.code}
|
|
569
|
+
}
|
|
611
570
|
|
|
612
|
-
|
|
613
|
-
${node.code}
|
|
571
|
+
await jsBlock_${logicItemIndex}();
|
|
614
572
|
}${newLine()}`;
|
|
615
573
|
}
|
|
616
574
|
|
|
@@ -633,60 +591,42 @@ export default function (source, preScript) {
|
|
|
633
591
|
return '';
|
|
634
592
|
};
|
|
635
593
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
const str = _generateNode(node, logicItemIndex);
|
|
641
|
-
const length = String(str).split('\n').length - 1;
|
|
642
|
-
recorder.line = startLine + length;
|
|
643
|
-
// console.log(node.type, startLine);
|
|
644
|
-
// if (node.type === 'JSBlock') {
|
|
645
|
-
// startLine = recorder.line - 2;
|
|
646
|
-
// }
|
|
647
|
-
sourceMap[node.id] = {
|
|
648
|
-
node,
|
|
649
|
-
// jsBlockFrom: recorder.line - 2,
|
|
650
|
-
from: startLine,
|
|
651
|
-
to: recorder.line,
|
|
652
|
-
};
|
|
653
|
-
return str;
|
|
654
|
-
};
|
|
594
|
+
let script = '';
|
|
595
|
+
logic.body.forEach((node, index) => {
|
|
596
|
+
script += `${generateNode(node, index)}${newLine()}`;
|
|
597
|
+
});
|
|
655
598
|
|
|
656
|
-
|
|
657
|
-
// console.log(generate({ type: 'Program', body: logic.body }).code);
|
|
658
|
-
sourceMap[logic.id] = {
|
|
659
|
-
node: logic,
|
|
660
|
-
isLogic: true,
|
|
661
|
-
from: startLineNumber,
|
|
662
|
-
};
|
|
663
|
-
// console.log(logic.name, startLineNumber);
|
|
664
|
-
let mstr = `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
|
|
599
|
+
return `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
|
|
665
600
|
${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`).join('\n') + '' : ''}
|
|
666
601
|
${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`).join('\n') + '' : ''}
|
|
667
602
|
let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});
|
|
668
|
-
|
|
603
|
+
${script}
|
|
604
|
+
}`;
|
|
605
|
+
});
|
|
669
606
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
607
|
+
const output = `
|
|
608
|
+
const methods = componentOptions.methods = componentOptions.methods || {};
|
|
609
|
+
const computed = componentOptions.computed = componentOptions.computed || {};
|
|
610
|
+
const oldDataFunc = componentOptions.data;
|
|
611
|
+
const data = function () {
|
|
612
|
+
const oldData = oldDataFunc ? oldDataFunc.call(this) : {};
|
|
613
|
+
return Object.assign(oldData, {
|
|
614
|
+
${paramsData ? paramsData + ',' : ''}
|
|
615
|
+
${variablesData}
|
|
616
|
+
});
|
|
617
|
+
};
|
|
618
|
+
componentOptions.data = data;
|
|
619
|
+
const meta = componentOptions.meta = componentOptions.meta || {};
|
|
620
|
+
Object.assign(meta, {
|
|
621
|
+
title: ${JSON.stringify(definition.title)},
|
|
622
|
+
crumb: ${JSON.stringify(definition.crumb)},
|
|
623
|
+
first: ${JSON.stringify(definition.first)},
|
|
675
624
|
});
|
|
676
625
|
|
|
677
|
-
|
|
678
|
-
mstr += `
|
|
679
|
-
}\n\n`;
|
|
680
|
-
// vital
|
|
681
|
-
startLineNumber += mstr.split('\n').length - 1;
|
|
682
|
-
sourceMap[logic.id].to = startLineNumber - 1;
|
|
683
|
-
return mstr;
|
|
684
|
-
});
|
|
626
|
+
${lifecycles.join('\n\n')}
|
|
685
627
|
|
|
686
|
-
|
|
628
|
+
${methods.join('\n\n')}
|
|
629
|
+
`;
|
|
687
630
|
|
|
688
|
-
return
|
|
689
|
-
output,
|
|
690
|
-
sourceMap,
|
|
691
|
-
};
|
|
631
|
+
return output;
|
|
692
632
|
}
|
package/src/types/page/View.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
1
|
import { immutable, circular, action, excludedInJSON } from '../decorators';
|
|
3
|
-
import { config, history, LEVEL_ENUM, Vertex, PackageJSON, App, Enum, Service, WebService, Structure, Page, Element, utils, ViewParam, ViewVariable, Lifecycle, genFinalCode, generator, Nuims, ActionOptions, ACTION_MODE, vertexsMap, updateDataTypeList, Interface
|
|
2
|
+
import { config, history, LEVEL_ENUM, Vertex, PackageJSON, App, Enum, Service, WebService, Structure, Page, Element, utils, ViewParam, ViewVariable, Lifecycle, genFinalCode, generator, Nuims, ActionOptions, ACTION_MODE, vertexsMap, updateDataTypeList, Interface } from '..';
|
|
4
3
|
import Block from './Block';
|
|
5
4
|
import { viewService } from '../../service/page';
|
|
6
5
|
import { Param } from '../logic/Param';
|
|
@@ -17,14 +16,6 @@ import * as babel from '@babel/core';
|
|
|
17
16
|
import view from '@/service/page/view';
|
|
18
17
|
import Entity from '../data/Entity';
|
|
19
18
|
import { postServiceType } from '../../service/common/preprocess';
|
|
20
|
-
export interface FrontEndsourceMap {
|
|
21
|
-
[id: string]: {
|
|
22
|
-
isLogic: boolean,
|
|
23
|
-
node: LogicItem,
|
|
24
|
-
from: number,
|
|
25
|
-
to: number,
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
19
|
import { catchFn } from './Page';
|
|
29
20
|
|
|
30
21
|
/**
|
|
@@ -121,9 +112,6 @@ export class View extends Block {
|
|
|
121
112
|
*/
|
|
122
113
|
@excludedInJSON()
|
|
123
114
|
public contentPromise: Promise<any> = undefined;
|
|
124
|
-
|
|
125
|
-
@excludedInJSON()
|
|
126
|
-
public sourceMap: FrontEndsourceMap = {};
|
|
127
115
|
/**
|
|
128
116
|
* 输入参数
|
|
129
117
|
*/
|
|
@@ -208,12 +196,11 @@ export class View extends Block {
|
|
|
208
196
|
// def 情况比较特殊,需要单独处理,防止逻辑重新加载
|
|
209
197
|
this._syncDef($def);
|
|
210
198
|
this.attachNodePath(true);
|
|
211
|
-
this.toVueOptions();
|
|
212
199
|
return this;
|
|
213
200
|
} catch (err) { }
|
|
214
201
|
})().finally(() => this.contentPromise = undefined);
|
|
215
202
|
}
|
|
216
|
-
loadAll(enableCache =
|
|
203
|
+
loadAll(enableCache = false) {
|
|
217
204
|
// 如果有正在进行的 Promise,则直接返回它
|
|
218
205
|
if (this.contentPromise)
|
|
219
206
|
return this.contentPromise;
|
|
@@ -681,6 +668,7 @@ export class View extends Block {
|
|
|
681
668
|
let componentOptions = 'const componentOptions = {};';
|
|
682
669
|
if (this.script)
|
|
683
670
|
componentOptions = this.script.trim().replace(/export default |module\.exports +=/, 'const componentOptions = ');
|
|
671
|
+
|
|
684
672
|
const $def = JSON.parse(JSON.stringify(this.$def));
|
|
685
673
|
$def.title = this.title;
|
|
686
674
|
$def.crumb = this.crumb;
|
|
@@ -706,16 +694,10 @@ export class View extends Block {
|
|
|
706
694
|
// );
|
|
707
695
|
// }
|
|
708
696
|
// }, { node: $def }, { mode: 'anyObject' });
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
sourceMap,
|
|
712
|
-
} = translator($def, this.script);
|
|
713
|
-
return {
|
|
714
|
-
script: `${componentOptions}${genFinalCode(output, options && options.finalCode)}
|
|
697
|
+
return `${componentOptions}
|
|
698
|
+
${genFinalCode(translator($def), options && options.finalCode)}
|
|
715
699
|
export default componentOptions;
|
|
716
|
-
|
|
717
|
-
sourceMap,
|
|
718
|
-
};
|
|
700
|
+
`;
|
|
719
701
|
}
|
|
720
702
|
/**
|
|
721
703
|
* 转换成 Vue 文件
|
|
@@ -749,12 +731,9 @@ export class View extends Block {
|
|
|
749
731
|
* @TODO 后面 template 可以优化成 render 函数
|
|
750
732
|
*/
|
|
751
733
|
toVueOptions(options?: ElementToVueOptions) {
|
|
752
|
-
const { script, sourceMap } = this.toScript(options);
|
|
753
|
-
this.sourceMap = sourceMap;
|
|
754
734
|
return {
|
|
755
735
|
template: this.$html.toVue(options),
|
|
756
|
-
script,
|
|
757
|
-
sourceMap,
|
|
736
|
+
script: this.toScript(options),
|
|
758
737
|
// definition: JSON.stringify(this.$def),
|
|
759
738
|
};
|
|
760
739
|
}
|