efront 4.10.1 → 4.11.0
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/i18n.md +1 -1
- 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 +101 -63
- package/coms/compile/Javascript_test.js +17 -5
- package/coms/compile/Program.js +202 -76
- package/coms/compile/autoenum.js +5 -0
- package/coms/compile/common.js +82 -44
- package/coms/compile/downLevel.js +132 -51
- package/coms/compile/downLevel_test.js +9 -2
- package/coms/compile/powermap.js +6 -23
- package/coms/compile/rescan.js +4 -2
- package/coms/compile/unstruct.js +8 -5
- package/coms/compile/unstruct_test.js +2 -2
- package/coms/docs/codecolor.js +23 -2
- package/coms/docs/codetext.xht +20 -6
- 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,12 @@ var skipAssignment = function (o, cx) {
|
|
|
114
115
|
next();
|
|
115
116
|
break;
|
|
116
117
|
}
|
|
117
|
-
if (
|
|
118
|
-
needpunc = false;
|
|
118
|
+
if (needfoot_reg.test(o.text)) {
|
|
119
119
|
next();
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
var prev = o.prev;
|
|
123
|
+
if (prev?.type === EXPRESS && needfoot_reg.test(prev.text)) {
|
|
124
124
|
next();
|
|
125
125
|
break;
|
|
126
126
|
}
|
|
@@ -321,7 +321,7 @@ function snapSentenceHead(o) {
|
|
|
321
321
|
}
|
|
322
322
|
var maybeprop = o.type === SCOPED && !o.brace || o.type === EXPRESS && /^[\.\[]/.test(o.text);
|
|
323
323
|
if (p.type === EXPRESS) {
|
|
324
|
-
if (maybeprop ||
|
|
324
|
+
if (maybeprop || p.needle || needfoot_reg.test(p.text)) {
|
|
325
325
|
o = p;
|
|
326
326
|
continue;
|
|
327
327
|
}
|
|
@@ -423,18 +423,22 @@ var getStrapHead = function (o) {
|
|
|
423
423
|
return null;
|
|
424
424
|
}
|
|
425
425
|
var snapExpressHead = function (o) {
|
|
426
|
-
if (!o || o.type & ~(EXPRESS | SCOPED | QUOTED)) return o;
|
|
426
|
+
if (!o || o.type & ~(EXPRESS | SCOPED | QUOTED) && !o.needle) return o;
|
|
427
427
|
var a = o;
|
|
428
428
|
while (o && o.prev) {
|
|
429
429
|
var p = o.prev;
|
|
430
|
+
if (p.type === STAMP && p.needle || o.type === STAMP && o.needle) {
|
|
431
|
+
o = p;
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
430
434
|
if (p && p.type === STRAP && p.text === 'new') return p;
|
|
431
435
|
if (o.type === SCOPED && o.entry === '(') {
|
|
432
436
|
var h = getStrapHead(o);
|
|
433
437
|
if (h) return h;
|
|
434
438
|
}
|
|
435
439
|
if (o.type === SCOPED && o.entry !== '{'
|
|
436
|
-
||
|
|
437
|
-
||
|
|
440
|
+
|| needhead_reg.test(o.text) && !o.isdigit
|
|
441
|
+
|| needfoot_reg.test(p.text) && !p.isdigit
|
|
438
442
|
|| o.type === QUOTED && (o.length || /^\`/.test(o.text))
|
|
439
443
|
) {
|
|
440
444
|
if (p.type === SCOPED && p.entry === '(') {
|
|
@@ -482,6 +486,10 @@ var snapExpressHead = function (o) {
|
|
|
482
486
|
|
|
483
487
|
var snapExpressFoot = function (o) {
|
|
484
488
|
while (o && o.next) {
|
|
489
|
+
if (o.needle) {
|
|
490
|
+
o = o.next;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
485
493
|
var n = null;
|
|
486
494
|
var isExpress = o.isExpress;
|
|
487
495
|
if (o.type & STRAP) {
|
|
@@ -504,8 +512,8 @@ var snapExpressFoot = function (o) {
|
|
|
504
512
|
}
|
|
505
513
|
if (!n) break;
|
|
506
514
|
if (n.type === SCOPED && (o.entry !== '{' || isExpress)
|
|
507
|
-
||
|
|
508
|
-
|| n.type === EXPRESS && needhead_reg.test(n.text)
|
|
515
|
+
|| needfoot_reg.test(o.text) && !o.isdigit
|
|
516
|
+
|| n.needle || n.type === EXPRESS && needhead_reg.test(n.text)
|
|
509
517
|
|| n.type === QUOTED && (n.length || /^\`/.test(n.text))
|
|
510
518
|
) {
|
|
511
519
|
o = n;
|
|
@@ -521,16 +529,21 @@ var createScoped = function (parsed, wash) {
|
|
|
521
529
|
funcbody.isroot = true;
|
|
522
530
|
scoped.body = parsed;
|
|
523
531
|
scoped.isfunc = true;
|
|
524
|
-
var dec = function (
|
|
525
|
-
var
|
|
526
|
-
|
|
527
|
-
while (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
skiped.
|
|
532
|
+
var dec = function (map, o) {
|
|
533
|
+
var kind = o.text;
|
|
534
|
+
o = o.next;
|
|
535
|
+
while (o && o.type === STRAP) o = o.next;
|
|
536
|
+
var [declared, used0, o0, skiped] = getDeclared(o, kind);
|
|
537
|
+
if (o0 !== o) {
|
|
538
|
+
mergeTo(used, used0);
|
|
539
|
+
while (skiped.length) {
|
|
540
|
+
var o1 = run(skiped[0], 0);
|
|
541
|
+
let sindex = skiped.indexOf(o1);
|
|
542
|
+
if (sindex < 0) break;
|
|
543
|
+
skiped.splice(0, sindex + 1);
|
|
544
|
+
}
|
|
545
|
+
mapDeclared(map, declared);
|
|
532
546
|
}
|
|
533
|
-
mapDeclared(m, declared);
|
|
534
547
|
return o0;
|
|
535
548
|
};
|
|
536
549
|
var run = function (o, id, body) {
|
|
@@ -577,16 +590,19 @@ var createScoped = function (parsed, wash) {
|
|
|
577
590
|
if (o.isdigit || /^(null|false|true)$/.test(o.text)) break;
|
|
578
591
|
case EXPRESS:
|
|
579
592
|
if (needhead_reg.test(o.text)) break;
|
|
593
|
+
|
|
580
594
|
var prev = o.prev;
|
|
581
595
|
if (prev) {
|
|
582
|
-
if (prev.type === EXPRESS &&
|
|
583
|
-
if (prev.istype) {
|
|
584
|
-
|
|
585
|
-
if (
|
|
596
|
+
if (prev.needle || prev.type === EXPRESS && needfoot_reg.test(prev.text)) break;
|
|
597
|
+
if (prev.type === STRAP && prev.istype) {
|
|
598
|
+
var o0 = dec(lets, prev);
|
|
599
|
+
if (o0 && o0.type === SCOPED && o0.entry === "(") {
|
|
586
600
|
isFunction = true;
|
|
587
601
|
isScope = true;
|
|
588
602
|
break;
|
|
589
603
|
}
|
|
604
|
+
if (o === o0) o = o.next;
|
|
605
|
+
else o = o0;
|
|
590
606
|
continue;
|
|
591
607
|
}
|
|
592
608
|
}
|
|
@@ -598,7 +614,7 @@ var createScoped = function (parsed, wash) {
|
|
|
598
614
|
else {
|
|
599
615
|
var u = o.text;
|
|
600
616
|
if (/^\.\.\./.test(u)) u = u.slice(3);
|
|
601
|
-
var u = u.replace(/^([^\.\[\?\s]*)[\s\S]*$/, '$1');
|
|
617
|
+
var u = u.replace(/^([^\.\[\?\s\:]*)[\s\S]*$/, '$1');
|
|
602
618
|
if (!u) break;
|
|
603
619
|
var prev = o.prev;
|
|
604
620
|
if (prev && prev.type === STAMP && /^(?:\+\+|\-\-)$/.test(prev.text)) {
|
|
@@ -643,18 +659,27 @@ var createScoped = function (parsed, wash) {
|
|
|
643
659
|
case "let":
|
|
644
660
|
case "const":
|
|
645
661
|
m = lets;
|
|
646
|
-
if (!o.next || o.next.type
|
|
662
|
+
if (!o.next || o.next.type & ~(EXPRESS | STRAP) && (o.next.type !== SCOPED || o.next.entry === "(")) {
|
|
647
663
|
o.type = EXPRESS;
|
|
648
664
|
continue;
|
|
649
665
|
}
|
|
650
666
|
case "import":
|
|
667
|
+
case "use":
|
|
651
668
|
if (!o.next || o.next.type === QUOTED) break;
|
|
669
|
+
if (o.next.needle) {
|
|
670
|
+
o.type = EXPRESS;
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
652
673
|
case "var":
|
|
653
674
|
m = m || vars;
|
|
654
|
-
|
|
675
|
+
var o0 = dec(m, o);
|
|
676
|
+
if (o0 === o) o = o.next;
|
|
677
|
+
else o = o0;
|
|
655
678
|
continue loop;
|
|
656
679
|
case "static":
|
|
657
680
|
case "function":
|
|
681
|
+
case "fn":
|
|
682
|
+
case "func":
|
|
658
683
|
isFunction = true;
|
|
659
684
|
var op = o.prev;
|
|
660
685
|
if (op?.type === STRAP && op.text === 'async') {
|
|
@@ -859,7 +884,7 @@ var createScoped = function (parsed, wash) {
|
|
|
859
884
|
var e = o;
|
|
860
885
|
if (o.type === STAMP && /^(\+\+|\-\-)$/.test(o.text) && o.prev && o.prev.type === EXPRESS
|
|
861
886
|
|| (VALUE | QUOTED | SCOPED) & o.type
|
|
862
|
-
|| EXPRESS === o.type &&
|
|
887
|
+
|| EXPRESS === o.type && !needfoot_reg.test(o.text)) {
|
|
863
888
|
if ((VALUE | QUOTED | PROPERTY | LABEL) & next.type) break;
|
|
864
889
|
if (EXPRESS === next.type && !/^[\.\[]/.test(next.text)) break;
|
|
865
890
|
if (next.type === SCOPED && next.brace) break;
|
|
@@ -962,6 +987,11 @@ var getDeclared = function (o, kind, queue) {
|
|
|
962
987
|
index--;
|
|
963
988
|
break;
|
|
964
989
|
}
|
|
990
|
+
var next = o.next;
|
|
991
|
+
if (next?.needle) {
|
|
992
|
+
o = next.next;
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
965
995
|
if (o.isprop) {
|
|
966
996
|
prop = createString([o]).trim();
|
|
967
997
|
if (/^(['"`])[\s\S]*\1$/.test(prop)) {
|
|
@@ -990,13 +1020,19 @@ var getDeclared = function (o, kind, queue) {
|
|
|
990
1020
|
break;
|
|
991
1021
|
}
|
|
992
1022
|
case STAMP:
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1023
|
+
var next = o.next;
|
|
1024
|
+
if (o.text === "*" && next) {
|
|
1025
|
+
if (next.type === STRAP && next.text === 'as') {
|
|
1026
|
+
o = next.next;
|
|
996
1027
|
prop = "*";
|
|
997
1028
|
continue;
|
|
998
1029
|
}
|
|
999
1030
|
}
|
|
1031
|
+
if (o.text === '...') {
|
|
1032
|
+
o = o.next;
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
break;
|
|
1000
1036
|
case PROPERTY:
|
|
1001
1037
|
if (o.next) {
|
|
1002
1038
|
if (o.next.type === STAMP && o.next.text === ":" || o.next.type === STRAP && o.next.text === "as") {
|
|
@@ -1013,6 +1049,12 @@ var getDeclared = function (o, kind, queue) {
|
|
|
1013
1049
|
var k = o.text;
|
|
1014
1050
|
if (isrest) declared.push(k = k.slice(3))
|
|
1015
1051
|
else if (o.text) declared.push(k);
|
|
1052
|
+
if (!isrest) {
|
|
1053
|
+
var prev = o.prev;
|
|
1054
|
+
if (prev?.type === STAMP && prev.text === '...') {
|
|
1055
|
+
isrest = true;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1016
1058
|
if (!isrest && !prop) {
|
|
1017
1059
|
if (queue && queue.entry === '{') {
|
|
1018
1060
|
if (o.type & (EXPRESS | STRAP)) {
|
|
@@ -1026,7 +1068,7 @@ var getDeclared = function (o, kind, queue) {
|
|
|
1026
1068
|
}
|
|
1027
1069
|
else prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
|
|
1028
1070
|
}
|
|
1029
|
-
var f =
|
|
1071
|
+
var f = snapExpressFoot(o);
|
|
1030
1072
|
if (k) saveTo(used, k, o);
|
|
1031
1073
|
var s = [o];
|
|
1032
1074
|
while (o !== f) o = o.next, s.push(o);
|
|
@@ -1119,7 +1161,7 @@ var hasBreakBetween = function (prev, next) {
|
|
|
1119
1161
|
if (!prev || !next) return true;
|
|
1120
1162
|
if (prev.type === STAMP && /^[,;]/.test(prev.text)) return true;
|
|
1121
1163
|
if (next.type === STAMP && /^[,;]/.test(next.text)) return true;
|
|
1122
|
-
if (prev.type === EXPRESS &&
|
|
1164
|
+
if (prev.type === EXPRESS && needfoot_reg.test(prev.text)) return true;
|
|
1123
1165
|
if (next.type === EXPRESS && /^[\.\[]/.test(next.text)) return true;
|
|
1124
1166
|
};
|
|
1125
1167
|
var getSemicolonBetween = function (prev, next) {
|
|
@@ -1147,7 +1189,7 @@ var getSemicolonBetween = function (prev, next) {
|
|
|
1147
1189
|
}
|
|
1148
1190
|
var needBreakBetween = function (prev, next) {
|
|
1149
1191
|
if (hasBreakBetween(prev, next)) return;
|
|
1150
|
-
return getSemicolonBetween(prev, next);
|
|
1192
|
+
return getSemicolonBetween(prev, next) === ';' ? ';' : '';
|
|
1151
1193
|
};
|
|
1152
1194
|
var relink = function (list) {
|
|
1153
1195
|
var pi = 0, p = null;
|
|
@@ -1192,7 +1234,6 @@ var setqueue = function (list, queue = list) {
|
|
|
1192
1234
|
var v = { value: queue, configurable: true, enumerable: false };
|
|
1193
1235
|
for (var o of list) delete o.queue, Object.defineProperty(o, 'queue', v);
|
|
1194
1236
|
};
|
|
1195
|
-
|
|
1196
1237
|
var createString = function (parsed) {
|
|
1197
1238
|
var autospace = parsed.autospace !== false;
|
|
1198
1239
|
var keepspace = parsed.keepspace !== false;
|
|
@@ -1215,7 +1256,7 @@ var createString = function (parsed) {
|
|
|
1215
1256
|
var prev = o.prev;
|
|
1216
1257
|
a: if (prev && lasttype !== SPACE && patchspace && ~(SPACE | COMMENT | STAMP | PIECE | SCOPED) & o.type) {
|
|
1217
1258
|
if ((QUOTED | SCOPED | STRAP | LABEL | COMMENT | ELEMENT | PROPERTY) & lasttype
|
|
1218
|
-
|| prev.type === STAMP && !prev.unary
|
|
1259
|
+
|| prev.type === STAMP && !prev.unary && !prev.needle && !prev.isprop
|
|
1219
1260
|
) {
|
|
1220
1261
|
if (intag || prev.type === ELEMENT && o.type === ELEMENT) break a;
|
|
1221
1262
|
if ((o.type & ~(EXPRESS | PROPERTY) || !needhead_reg.test(o.text)) && (!prev.tag && !o.tag || prev.type === STAMP || o.type === STAMP)) {
|
|
@@ -1307,7 +1348,7 @@ var createString = function (parsed) {
|
|
|
1307
1348
|
result.push(o.leave);
|
|
1308
1349
|
}
|
|
1309
1350
|
else {
|
|
1310
|
-
result.push(o.tag_leave);
|
|
1351
|
+
if (o.tag_leave) result.push(o.tag_leave);
|
|
1311
1352
|
if (o.length) o.forEach(run);
|
|
1312
1353
|
}
|
|
1313
1354
|
break;
|
|
@@ -1319,7 +1360,7 @@ var createString = function (parsed) {
|
|
|
1319
1360
|
}
|
|
1320
1361
|
case SCOPED:
|
|
1321
1362
|
var prev = o.prev;
|
|
1322
|
-
if (patchspace && prev && o.type !== QUOTED && (lasttype === STAMP && !prev.unary
|
|
1363
|
+
if (patchspace && !intag && prev && o.type !== QUOTED && (lasttype === STAMP && !prev.unary && !prev.needle
|
|
1323
1364
|
|| lasttype & ~(SPACE | STAMP | COMMENT) && o.brace
|
|
1324
1365
|
|| lasttype === STRAP && !/^(this|arguments|import)$/.test(prev.text)
|
|
1325
1366
|
)) result.push(" ");
|
|
@@ -1352,8 +1393,8 @@ var createString = function (parsed) {
|
|
|
1352
1393
|
break;
|
|
1353
1394
|
default:
|
|
1354
1395
|
if (o && typeof o === "object") {
|
|
1355
|
-
if (intag || o.type & (EXPRESS | PROPERTY) && (needhead_reg.test(o.text) || lasttype & EXPRESS &&
|
|
1356
|
-
if (
|
|
1396
|
+
if (intag || o.needle || o.type & (EXPRESS | PROPERTY) && (needhead_reg.test(o.text) || lasttype & EXPRESS && needfoot_reg.test(prev?.text))) {
|
|
1397
|
+
if (prev?.isdigit && !/^0[\dxbo]|[mni]$|[e\.]/.test(prev.text) && lasttype & ~(SPACE | COMMENT)) result.push(" ");
|
|
1357
1398
|
}
|
|
1358
1399
|
else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
|
|
1359
1400
|
if (autospace || o.prev?.isdigit) result.push(" ");
|
|
@@ -1374,11 +1415,8 @@ var createString = function (parsed) {
|
|
|
1374
1415
|
}
|
|
1375
1416
|
}
|
|
1376
1417
|
|
|
1377
|
-
else if (o.text === '*') {
|
|
1378
|
-
if (patchspace && lasttype !== SPACE && (lasttype !== STRAP || o.prev && o.prev.text !== 'function')) result.push(" ");
|
|
1379
|
-
}
|
|
1380
1418
|
else if (!/^(\+\+|\-\-)$/.test(o.text) || o.prev && o.prev.type & (STAMP | STRAP)) {
|
|
1381
|
-
if (patchspace && lasttype !== SPACE) result.push(" ");
|
|
1419
|
+
if (patchspace && lasttype !== SPACE && !o.needle) result.push(" ");
|
|
1382
1420
|
}
|
|
1383
1421
|
}
|
|
1384
1422
|
if (o.isdigit) {
|
|
@@ -1393,7 +1431,6 @@ var createString = function (parsed) {
|
|
|
1393
1431
|
}
|
|
1394
1432
|
}
|
|
1395
1433
|
lasttype = o.type;
|
|
1396
|
-
if (o.isprop) lasttype = PROPERTY;
|
|
1397
1434
|
};
|
|
1398
1435
|
parsed.forEach(run);
|
|
1399
1436
|
return finalresult.join("");
|
|
@@ -1741,6 +1778,7 @@ module.exports = {
|
|
|
1741
1778
|
number_reg,
|
|
1742
1779
|
equal_reg,
|
|
1743
1780
|
needhead_reg,
|
|
1781
|
+
needfoot_reg,
|
|
1744
1782
|
unshort,
|
|
1745
1783
|
skipAssignment,
|
|
1746
1784
|
getDeclared,
|