efront 4.10.1 → 4.10.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/coms/basic/sortRegister.js +16 -0
- package/coms/basic_/nullish_.js +1 -1
- package/coms/compile/Html.js +5 -1
- package/coms/compile/Javascript.js +68 -55
- package/coms/compile/Javascript_test.js +7 -5
- package/coms/compile/Program.js +200 -76
- package/coms/compile/autoenum.js +5 -0
- package/coms/compile/common.js +81 -47
- package/coms/compile/downLevel.js +131 -48
- package/coms/compile/downLevel_test.js +8 -2
- package/coms/compile/powermap.js +6 -23
- package/coms/compile/unstruct.js +8 -5
- package/coms/compile/unstruct_test.js +3 -3
- package/coms/docs/codecolor.js +23 -2
- package/coms/docs/codetext.xht +12 -2
- package/coms/maps/gaode.js +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/compile/common.js
CHANGED
|
@@ -17,6 +17,7 @@ const [
|
|
|
17
17
|
var number_reg = /^(?:(?:0x[0-9a-f]+|0b[01]+|0o?[0-7]+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[hijklmnu]+)?/i;
|
|
18
18
|
var equal_reg = /^(?:[\+\-\*\/~\^&\|%]|\*\*|>>>?|<<)?\=$|^(?:\+\+|\-\-)$/;
|
|
19
19
|
var needhead_reg = /^\?|^\.(?:[^\.]|$)|^\[/;
|
|
20
|
+
var needfoot_reg = /(\:\:|([^\.]|^)\.)$/;
|
|
20
21
|
var skipAssignment = function (o, cx) {
|
|
21
22
|
if (!o) return;
|
|
22
23
|
var next = arguments.length === 1 ? function () {
|
|
@@ -114,13 +115,8 @@ var skipAssignment = function (o, cx) {
|
|
|
114
115
|
next();
|
|
115
116
|
break;
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
next();
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
if (/^\[/.test(o.text)) {
|
|
123
|
-
needpunc = true;
|
|
118
|
+
var prev = o.prev;
|
|
119
|
+
if (prev?.type === EXPRESS && needfoot_reg.test(prev.text)) {
|
|
124
120
|
next();
|
|
125
121
|
break;
|
|
126
122
|
}
|
|
@@ -321,7 +317,7 @@ function snapSentenceHead(o) {
|
|
|
321
317
|
}
|
|
322
318
|
var maybeprop = o.type === SCOPED && !o.brace || o.type === EXPRESS && /^[\.\[]/.test(o.text);
|
|
323
319
|
if (p.type === EXPRESS) {
|
|
324
|
-
if (maybeprop ||
|
|
320
|
+
if (maybeprop || p.needle || needfoot_reg.test(p.text)) {
|
|
325
321
|
o = p;
|
|
326
322
|
continue;
|
|
327
323
|
}
|
|
@@ -423,18 +419,22 @@ var getStrapHead = function (o) {
|
|
|
423
419
|
return null;
|
|
424
420
|
}
|
|
425
421
|
var snapExpressHead = function (o) {
|
|
426
|
-
if (!o || o.type & ~(EXPRESS | SCOPED | QUOTED)) return o;
|
|
422
|
+
if (!o || o.type & ~(EXPRESS | SCOPED | QUOTED) && !o.needle) return o;
|
|
427
423
|
var a = o;
|
|
428
424
|
while (o && o.prev) {
|
|
429
425
|
var p = o.prev;
|
|
426
|
+
if (p.type === STAMP && p.needle || o.type === STAMP && o.needle) {
|
|
427
|
+
o = p;
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
430
|
if (p && p.type === STRAP && p.text === 'new') return p;
|
|
431
431
|
if (o.type === SCOPED && o.entry === '(') {
|
|
432
432
|
var h = getStrapHead(o);
|
|
433
433
|
if (h) return h;
|
|
434
434
|
}
|
|
435
435
|
if (o.type === SCOPED && o.entry !== '{'
|
|
436
|
-
||
|
|
437
|
-
||
|
|
436
|
+
|| needhead_reg.test(o.text) && !o.isdigit
|
|
437
|
+
|| needfoot_reg.test(p.text) && !p.isdigit
|
|
438
438
|
|| o.type === QUOTED && (o.length || /^\`/.test(o.text))
|
|
439
439
|
) {
|
|
440
440
|
if (p.type === SCOPED && p.entry === '(') {
|
|
@@ -482,6 +482,10 @@ var snapExpressHead = function (o) {
|
|
|
482
482
|
|
|
483
483
|
var snapExpressFoot = function (o) {
|
|
484
484
|
while (o && o.next) {
|
|
485
|
+
if (o.needle) {
|
|
486
|
+
o = o.next;
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
485
489
|
var n = null;
|
|
486
490
|
var isExpress = o.isExpress;
|
|
487
491
|
if (o.type & STRAP) {
|
|
@@ -504,8 +508,8 @@ var snapExpressFoot = function (o) {
|
|
|
504
508
|
}
|
|
505
509
|
if (!n) break;
|
|
506
510
|
if (n.type === SCOPED && (o.entry !== '{' || isExpress)
|
|
507
|
-
||
|
|
508
|
-
|| n.type === EXPRESS && needhead_reg.test(n.text)
|
|
511
|
+
|| needfoot_reg.test(o.text) && !o.isdigit
|
|
512
|
+
|| n.needle || n.type === EXPRESS && needhead_reg.test(n.text)
|
|
509
513
|
|| n.type === QUOTED && (n.length || /^\`/.test(n.text))
|
|
510
514
|
) {
|
|
511
515
|
o = n;
|
|
@@ -521,16 +525,21 @@ var createScoped = function (parsed, wash) {
|
|
|
521
525
|
funcbody.isroot = true;
|
|
522
526
|
scoped.body = parsed;
|
|
523
527
|
scoped.isfunc = true;
|
|
524
|
-
var dec = function (
|
|
525
|
-
var
|
|
526
|
-
|
|
527
|
-
while (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
skiped.
|
|
528
|
+
var dec = function (map, o) {
|
|
529
|
+
var kind = o.text;
|
|
530
|
+
o = o.next;
|
|
531
|
+
while (o && o.type === STRAP) o = o.next;
|
|
532
|
+
var [declared, used0, o0, skiped] = getDeclared(o, kind);
|
|
533
|
+
if (o0 !== o) {
|
|
534
|
+
mergeTo(used, used0);
|
|
535
|
+
while (skiped.length) {
|
|
536
|
+
var o1 = run(skiped[0], 0);
|
|
537
|
+
let sindex = skiped.indexOf(o1);
|
|
538
|
+
if (sindex < 0) break;
|
|
539
|
+
skiped.splice(0, sindex + 1);
|
|
540
|
+
}
|
|
541
|
+
mapDeclared(map, declared);
|
|
532
542
|
}
|
|
533
|
-
mapDeclared(m, declared);
|
|
534
543
|
return o0;
|
|
535
544
|
};
|
|
536
545
|
var run = function (o, id, body) {
|
|
@@ -577,16 +586,19 @@ var createScoped = function (parsed, wash) {
|
|
|
577
586
|
if (o.isdigit || /^(null|false|true)$/.test(o.text)) break;
|
|
578
587
|
case EXPRESS:
|
|
579
588
|
if (needhead_reg.test(o.text)) break;
|
|
589
|
+
|
|
580
590
|
var prev = o.prev;
|
|
581
591
|
if (prev) {
|
|
582
|
-
if (prev.type === EXPRESS &&
|
|
583
|
-
if (prev.istype) {
|
|
584
|
-
|
|
585
|
-
if (
|
|
592
|
+
if (prev.needle || prev.type === EXPRESS && needfoot_reg.test(prev.text)) break;
|
|
593
|
+
if (prev.type === STRAP && prev.istype) {
|
|
594
|
+
var o0 = dec(lets, prev);
|
|
595
|
+
if (o0 && o0.type === SCOPED && o0.entry === "(") {
|
|
586
596
|
isFunction = true;
|
|
587
597
|
isScope = true;
|
|
588
598
|
break;
|
|
589
599
|
}
|
|
600
|
+
if (o === o0) o = o.next;
|
|
601
|
+
else o = o0;
|
|
590
602
|
continue;
|
|
591
603
|
}
|
|
592
604
|
}
|
|
@@ -598,7 +610,7 @@ var createScoped = function (parsed, wash) {
|
|
|
598
610
|
else {
|
|
599
611
|
var u = o.text;
|
|
600
612
|
if (/^\.\.\./.test(u)) u = u.slice(3);
|
|
601
|
-
var u = u.replace(/^([^\.\[\?\s]*)[\s\S]*$/, '$1');
|
|
613
|
+
var u = u.replace(/^([^\.\[\?\s\:]*)[\s\S]*$/, '$1');
|
|
602
614
|
if (!u) break;
|
|
603
615
|
var prev = o.prev;
|
|
604
616
|
if (prev && prev.type === STAMP && /^(?:\+\+|\-\-)$/.test(prev.text)) {
|
|
@@ -643,18 +655,27 @@ var createScoped = function (parsed, wash) {
|
|
|
643
655
|
case "let":
|
|
644
656
|
case "const":
|
|
645
657
|
m = lets;
|
|
646
|
-
if (!o.next || o.next.type
|
|
658
|
+
if (!o.next || o.next.type & ~(EXPRESS | STRAP) && (o.next.type !== SCOPED || o.next.entry === "(")) {
|
|
647
659
|
o.type = EXPRESS;
|
|
648
660
|
continue;
|
|
649
661
|
}
|
|
650
662
|
case "import":
|
|
663
|
+
case "use":
|
|
651
664
|
if (!o.next || o.next.type === QUOTED) break;
|
|
665
|
+
if (o.next.needle) {
|
|
666
|
+
o.type = EXPRESS;
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
652
669
|
case "var":
|
|
653
670
|
m = m || vars;
|
|
654
|
-
|
|
671
|
+
var o0 = dec(m, o);
|
|
672
|
+
if (o0 === o) o = o.next;
|
|
673
|
+
else o = o0;
|
|
655
674
|
continue loop;
|
|
656
675
|
case "static":
|
|
657
676
|
case "function":
|
|
677
|
+
case "fn":
|
|
678
|
+
case "func":
|
|
658
679
|
isFunction = true;
|
|
659
680
|
var op = o.prev;
|
|
660
681
|
if (op?.type === STRAP && op.text === 'async') {
|
|
@@ -859,7 +880,7 @@ var createScoped = function (parsed, wash) {
|
|
|
859
880
|
var e = o;
|
|
860
881
|
if (o.type === STAMP && /^(\+\+|\-\-)$/.test(o.text) && o.prev && o.prev.type === EXPRESS
|
|
861
882
|
|| (VALUE | QUOTED | SCOPED) & o.type
|
|
862
|
-
|| EXPRESS === o.type &&
|
|
883
|
+
|| EXPRESS === o.type && !needfoot_reg.test(o.text)) {
|
|
863
884
|
if ((VALUE | QUOTED | PROPERTY | LABEL) & next.type) break;
|
|
864
885
|
if (EXPRESS === next.type && !/^[\.\[]/.test(next.text)) break;
|
|
865
886
|
if (next.type === SCOPED && next.brace) break;
|
|
@@ -962,6 +983,11 @@ var getDeclared = function (o, kind, queue) {
|
|
|
962
983
|
index--;
|
|
963
984
|
break;
|
|
964
985
|
}
|
|
986
|
+
var next = o.next;
|
|
987
|
+
if (next?.needle) {
|
|
988
|
+
o = next.next;
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
965
991
|
if (o.isprop) {
|
|
966
992
|
prop = createString([o]).trim();
|
|
967
993
|
if (/^(['"`])[\s\S]*\1$/.test(prop)) {
|
|
@@ -990,13 +1016,19 @@ var getDeclared = function (o, kind, queue) {
|
|
|
990
1016
|
break;
|
|
991
1017
|
}
|
|
992
1018
|
case STAMP:
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1019
|
+
var next = o.next;
|
|
1020
|
+
if (o.text === "*" && next) {
|
|
1021
|
+
if (next.type === STRAP && next.text === 'as') {
|
|
1022
|
+
o = next.next;
|
|
996
1023
|
prop = "*";
|
|
997
1024
|
continue;
|
|
998
1025
|
}
|
|
999
1026
|
}
|
|
1027
|
+
if (o.text === '...') {
|
|
1028
|
+
o = o.next;
|
|
1029
|
+
continue;
|
|
1030
|
+
}
|
|
1031
|
+
break;
|
|
1000
1032
|
case PROPERTY:
|
|
1001
1033
|
if (o.next) {
|
|
1002
1034
|
if (o.next.type === STAMP && o.next.text === ":" || o.next.type === STRAP && o.next.text === "as") {
|
|
@@ -1013,6 +1045,12 @@ var getDeclared = function (o, kind, queue) {
|
|
|
1013
1045
|
var k = o.text;
|
|
1014
1046
|
if (isrest) declared.push(k = k.slice(3))
|
|
1015
1047
|
else if (o.text) declared.push(k);
|
|
1048
|
+
if (!isrest) {
|
|
1049
|
+
var prev = o.prev;
|
|
1050
|
+
if (prev?.type === STAMP && prev.text === '...') {
|
|
1051
|
+
isrest = true;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1016
1054
|
if (!isrest && !prop) {
|
|
1017
1055
|
if (queue && queue.entry === '{') {
|
|
1018
1056
|
if (o.type & (EXPRESS | STRAP)) {
|
|
@@ -1026,7 +1064,7 @@ var getDeclared = function (o, kind, queue) {
|
|
|
1026
1064
|
}
|
|
1027
1065
|
else prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
|
|
1028
1066
|
}
|
|
1029
|
-
var f =
|
|
1067
|
+
var f = snapExpressFoot(o);
|
|
1030
1068
|
if (k) saveTo(used, k, o);
|
|
1031
1069
|
var s = [o];
|
|
1032
1070
|
while (o !== f) o = o.next, s.push(o);
|
|
@@ -1119,7 +1157,7 @@ var hasBreakBetween = function (prev, next) {
|
|
|
1119
1157
|
if (!prev || !next) return true;
|
|
1120
1158
|
if (prev.type === STAMP && /^[,;]/.test(prev.text)) return true;
|
|
1121
1159
|
if (next.type === STAMP && /^[,;]/.test(next.text)) return true;
|
|
1122
|
-
if (prev.type === EXPRESS &&
|
|
1160
|
+
if (prev.type === EXPRESS && needfoot_reg.test(prev.text)) return true;
|
|
1123
1161
|
if (next.type === EXPRESS && /^[\.\[]/.test(next.text)) return true;
|
|
1124
1162
|
};
|
|
1125
1163
|
var getSemicolonBetween = function (prev, next) {
|
|
@@ -1147,7 +1185,7 @@ var getSemicolonBetween = function (prev, next) {
|
|
|
1147
1185
|
}
|
|
1148
1186
|
var needBreakBetween = function (prev, next) {
|
|
1149
1187
|
if (hasBreakBetween(prev, next)) return;
|
|
1150
|
-
return getSemicolonBetween(prev, next);
|
|
1188
|
+
return getSemicolonBetween(prev, next) === ';' ? ';' : '';
|
|
1151
1189
|
};
|
|
1152
1190
|
var relink = function (list) {
|
|
1153
1191
|
var pi = 0, p = null;
|
|
@@ -1192,7 +1230,6 @@ var setqueue = function (list, queue = list) {
|
|
|
1192
1230
|
var v = { value: queue, configurable: true, enumerable: false };
|
|
1193
1231
|
for (var o of list) delete o.queue, Object.defineProperty(o, 'queue', v);
|
|
1194
1232
|
};
|
|
1195
|
-
|
|
1196
1233
|
var createString = function (parsed) {
|
|
1197
1234
|
var autospace = parsed.autospace !== false;
|
|
1198
1235
|
var keepspace = parsed.keepspace !== false;
|
|
@@ -1215,7 +1252,7 @@ var createString = function (parsed) {
|
|
|
1215
1252
|
var prev = o.prev;
|
|
1216
1253
|
a: if (prev && lasttype !== SPACE && patchspace && ~(SPACE | COMMENT | STAMP | PIECE | SCOPED) & o.type) {
|
|
1217
1254
|
if ((QUOTED | SCOPED | STRAP | LABEL | COMMENT | ELEMENT | PROPERTY) & lasttype
|
|
1218
|
-
|| prev.type === STAMP && !prev.unary
|
|
1255
|
+
|| prev.type === STAMP && !prev.unary && !prev.needle && !prev.isprop
|
|
1219
1256
|
) {
|
|
1220
1257
|
if (intag || prev.type === ELEMENT && o.type === ELEMENT) break a;
|
|
1221
1258
|
if ((o.type & ~(EXPRESS | PROPERTY) || !needhead_reg.test(o.text)) && (!prev.tag && !o.tag || prev.type === STAMP || o.type === STAMP)) {
|
|
@@ -1307,7 +1344,7 @@ var createString = function (parsed) {
|
|
|
1307
1344
|
result.push(o.leave);
|
|
1308
1345
|
}
|
|
1309
1346
|
else {
|
|
1310
|
-
result.push(o.tag_leave);
|
|
1347
|
+
if (o.tag_leave) result.push(o.tag_leave);
|
|
1311
1348
|
if (o.length) o.forEach(run);
|
|
1312
1349
|
}
|
|
1313
1350
|
break;
|
|
@@ -1319,7 +1356,7 @@ var createString = function (parsed) {
|
|
|
1319
1356
|
}
|
|
1320
1357
|
case SCOPED:
|
|
1321
1358
|
var prev = o.prev;
|
|
1322
|
-
if (patchspace && prev && o.type !== QUOTED && (lasttype === STAMP && !prev.unary
|
|
1359
|
+
if (patchspace && prev && o.type !== QUOTED && (lasttype === STAMP && !prev.unary && !prev.needle
|
|
1323
1360
|
|| lasttype & ~(SPACE | STAMP | COMMENT) && o.brace
|
|
1324
1361
|
|| lasttype === STRAP && !/^(this|arguments|import)$/.test(prev.text)
|
|
1325
1362
|
)) result.push(" ");
|
|
@@ -1352,8 +1389,8 @@ var createString = function (parsed) {
|
|
|
1352
1389
|
break;
|
|
1353
1390
|
default:
|
|
1354
1391
|
if (o && typeof o === "object") {
|
|
1355
|
-
if (intag || o.type & (EXPRESS | PROPERTY) && (needhead_reg.test(o.text) || lasttype & EXPRESS &&
|
|
1356
|
-
if (
|
|
1392
|
+
if (intag || o.needle || o.type & (EXPRESS | PROPERTY) && (needhead_reg.test(o.text) || lasttype & EXPRESS && needfoot_reg.test(prev?.text))) {
|
|
1393
|
+
if (prev?.isdigit && !/^0[\dxbo]|[mni]$|[e\.]/.test(prev.text) && lasttype & ~(SPACE | COMMENT)) result.push(" ");
|
|
1357
1394
|
}
|
|
1358
1395
|
else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
|
|
1359
1396
|
if (autospace || o.prev?.isdigit) result.push(" ");
|
|
@@ -1374,11 +1411,8 @@ var createString = function (parsed) {
|
|
|
1374
1411
|
}
|
|
1375
1412
|
}
|
|
1376
1413
|
|
|
1377
|
-
else if (o.text === '*') {
|
|
1378
|
-
if (patchspace && lasttype !== SPACE && (lasttype !== STRAP || o.prev && o.prev.text !== 'function')) result.push(" ");
|
|
1379
|
-
}
|
|
1380
1414
|
else if (!/^(\+\+|\-\-)$/.test(o.text) || o.prev && o.prev.type & (STAMP | STRAP)) {
|
|
1381
|
-
if (patchspace && lasttype !== SPACE) result.push(" ");
|
|
1415
|
+
if (patchspace && lasttype !== SPACE && !o.needle) result.push(" ");
|
|
1382
1416
|
}
|
|
1383
1417
|
}
|
|
1384
1418
|
if (o.isdigit) {
|
|
@@ -1393,7 +1427,6 @@ var createString = function (parsed) {
|
|
|
1393
1427
|
}
|
|
1394
1428
|
}
|
|
1395
1429
|
lasttype = o.type;
|
|
1396
|
-
if (o.isprop) lasttype = PROPERTY;
|
|
1397
1430
|
};
|
|
1398
1431
|
parsed.forEach(run);
|
|
1399
1432
|
return finalresult.join("");
|
|
@@ -1741,6 +1774,7 @@ module.exports = {
|
|
|
1741
1774
|
number_reg,
|
|
1742
1775
|
equal_reg,
|
|
1743
1776
|
needhead_reg,
|
|
1777
|
+
needfoot_reg,
|
|
1744
1778
|
unshort,
|
|
1745
1779
|
skipAssignment,
|
|
1746
1780
|
getDeclared,
|