efront 4.9.4 → 4.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coms/basic/Item.js +6 -1
- package/coms/basic/Tree.js +15 -1
- package/coms/basic/shallowClone.js +6 -2
- package/coms/basic_/JSON.js +1 -5
- package/coms/basic_/JSON_test.js +7 -1
- package/coms/compile/Html_test.js +12 -1
- package/coms/compile/Javascript.js +94 -58
- package/coms/compile/Javascript_test.js +70 -2
- package/coms/compile/Program.js +187 -53
- package/coms/compile/audit.js +1 -1
- package/coms/compile/autoenum.js +1 -1
- package/coms/compile/cloneNode.js +2 -0
- package/coms/compile/common.js +74 -43
- package/coms/compile/downLevel.js +6 -6
- package/coms/compile/downLevel_test.js +5 -1
- package/coms/compile/formatcode.js +1 -1
- package/coms/compile/powermap.js +1 -1
- package/coms/compile/unstruct.js +2 -2
- package/coms/docs/codecolor.js +47 -17
- package/coms/docs/codetext.xht +83 -12
- package/coms/frame/route.js +15 -15
- package/coms/zimoli/XMLHttpRequest.js +2 -5
- package/coms/zimoli/alert.js +2 -2
- package/coms/zimoli/confirm.js +1 -1
- package/coms/zimoli/createEvent.js +6 -7
- package/coms/zimoli/dispatch.js +8 -4
- package/coms/zimoli/getScreenPosition.js +6 -6
- package/coms/zimoli/grid.js +14 -10
- package/coms/zimoli/list.js +13 -1
- package/coms/zimoli/on.js +2 -1
- package/coms/zimoli/picture.js +1 -1
- package/coms/zimoli/render.js +1 -1
- package/coms/zimoli/slider.js +4 -0
- package/coms/zimoli/tree.js +133 -43
- package/coms/zimoli/tree.less +2 -1
- package/coms/zimoli/vbox.js +5 -5
- package/coms/zimoli/vbox.less +3 -1
- package/coms/zimoli/zimoli.js +1 -1
- package/data/packexe-setup.sfx +0 -0
- package/docs//347/273/204/344/273/266.xht +4 -4
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/compile/common.js
CHANGED
|
@@ -14,9 +14,9 @@ const [
|
|
|
14
14
|
/*2048 */ELEMENT,
|
|
15
15
|
] = new Array(20).fill(0).map((_, a) => 1 << a);
|
|
16
16
|
// --------------//1//2/////////////////////////22/////////////2//2//3//4/////4////////3/////3//////3//3//////3///////211/////////////2//////2//////1///
|
|
17
|
-
var number_reg = /^(?:(?:0x[0-9a-f]+|0b
|
|
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
|
-
var needhead_reg =
|
|
19
|
+
var needhead_reg = /^\?|^\.(?:[^\.]|$)|^\[/;
|
|
20
20
|
var skipAssignment = function (o, cx) {
|
|
21
21
|
if (!o) return;
|
|
22
22
|
var next = arguments.length === 1 ? function () {
|
|
@@ -96,7 +96,7 @@ var skipAssignment = function (o, cx) {
|
|
|
96
96
|
}
|
|
97
97
|
break;
|
|
98
98
|
case SCOPED:
|
|
99
|
-
if (needpunc && o.
|
|
99
|
+
if (needpunc && o.brace) break loop;
|
|
100
100
|
next();
|
|
101
101
|
needpunc = true;
|
|
102
102
|
break;
|
|
@@ -104,6 +104,11 @@ var skipAssignment = function (o, cx) {
|
|
|
104
104
|
if (needpunc) break loop;
|
|
105
105
|
next();
|
|
106
106
|
break;
|
|
107
|
+
case ELEMENT:
|
|
108
|
+
if (o.istype) {
|
|
109
|
+
next();
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
107
112
|
case EXPRESS:
|
|
108
113
|
if (needhead_reg.test(o.text)) {
|
|
109
114
|
next();
|
|
@@ -299,7 +304,7 @@ function snapSentenceHead(o) {
|
|
|
299
304
|
while (o && o.prev) {
|
|
300
305
|
var p = o.prev;
|
|
301
306
|
if (o.entry === '(') {
|
|
302
|
-
if (
|
|
307
|
+
if (p.type & ~(STAMP | STRAP)) {
|
|
303
308
|
o = p;
|
|
304
309
|
p = o.prev;
|
|
305
310
|
if (!p) break;
|
|
@@ -314,7 +319,7 @@ function snapSentenceHead(o) {
|
|
|
314
319
|
continue
|
|
315
320
|
};
|
|
316
321
|
}
|
|
317
|
-
var maybeprop = o.type === SCOPED && o.
|
|
322
|
+
var maybeprop = o.type === SCOPED && !o.brace || o.type === EXPRESS && /^[\.\[]/.test(o.text);
|
|
318
323
|
if (p.type === EXPRESS) {
|
|
319
324
|
if (maybeprop || /\.$/.test(p.text)) {
|
|
320
325
|
o = p;
|
|
@@ -329,7 +334,7 @@ function snapSentenceHead(o) {
|
|
|
329
334
|
if (p.type & (VALUE | QUOTED)) {
|
|
330
335
|
if (maybeprop) {
|
|
331
336
|
o = p;
|
|
332
|
-
if (p.entry === '`' && p.prev &&
|
|
337
|
+
if (p.entry === '`' && p.prev && p.prev.type & ~(STAMP | STRAP)) o = p.prev;
|
|
333
338
|
continue;
|
|
334
339
|
}
|
|
335
340
|
break;
|
|
@@ -516,6 +521,18 @@ var createScoped = function (parsed, wash) {
|
|
|
516
521
|
funcbody.isroot = true;
|
|
517
522
|
scoped.body = parsed;
|
|
518
523
|
scoped.isfunc = true;
|
|
524
|
+
var dec = function (m, o) {
|
|
525
|
+
var [declared, used0, o0, skiped] = getDeclared(o.next, o.text);
|
|
526
|
+
mergeTo(used, used0);
|
|
527
|
+
while (skiped.length) {
|
|
528
|
+
var o1 = run(skiped[0], 0);
|
|
529
|
+
let sindex = skiped.indexOf(o1);
|
|
530
|
+
if (sindex < 0) break;
|
|
531
|
+
skiped.splice(0, sindex + 1);
|
|
532
|
+
}
|
|
533
|
+
mapDeclared(m, declared);
|
|
534
|
+
return o0;
|
|
535
|
+
};
|
|
519
536
|
var run = function (o, id, body) {
|
|
520
537
|
loop: while (o) {
|
|
521
538
|
var isCatch = false;
|
|
@@ -560,9 +577,18 @@ var createScoped = function (parsed, wash) {
|
|
|
560
577
|
if (o.isdigit || /^(null|false|true)$/.test(o.text)) break;
|
|
561
578
|
case EXPRESS:
|
|
562
579
|
if (needhead_reg.test(o.text)) break;
|
|
563
|
-
|
|
564
|
-
if (
|
|
565
|
-
if (/\.$/.test(o.prev.text)) break;
|
|
580
|
+
var prev = o.prev;
|
|
581
|
+
if (prev) {
|
|
582
|
+
if (prev.type === EXPRESS && /\.$/.test(o.prev.text)) break;
|
|
583
|
+
if (prev.istype) {
|
|
584
|
+
o = dec(lets, prev);
|
|
585
|
+
if (o && o.type === SCOPED && o.entry === "(") {
|
|
586
|
+
isFunction = true;
|
|
587
|
+
isScope = true;
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
566
592
|
}
|
|
567
593
|
if (o.next && o.next.type === STAMP && o.next.text === "=>") {
|
|
568
594
|
isScope = true;
|
|
@@ -625,16 +651,7 @@ var createScoped = function (parsed, wash) {
|
|
|
625
651
|
if (!o.next || o.next.type === QUOTED) break;
|
|
626
652
|
case "var":
|
|
627
653
|
m = m || vars;
|
|
628
|
-
|
|
629
|
-
mergeTo(used, used0);
|
|
630
|
-
while (skiped.length) {
|
|
631
|
-
var o1 = run(skiped[0], 0);
|
|
632
|
-
let sindex = skiped.indexOf(o1);
|
|
633
|
-
if (sindex < 0) break;
|
|
634
|
-
skiped.splice(0, sindex + 1);
|
|
635
|
-
}
|
|
636
|
-
o = o0;
|
|
637
|
-
mapDeclared(m, declared);
|
|
654
|
+
o = dec(m, o);
|
|
638
655
|
continue loop;
|
|
639
656
|
case "static":
|
|
640
657
|
case "function":
|
|
@@ -653,7 +670,8 @@ var createScoped = function (parsed, wash) {
|
|
|
653
670
|
case "catch":
|
|
654
671
|
if (s === 'catch') isCatch = true;
|
|
655
672
|
case "class":
|
|
656
|
-
|
|
673
|
+
case "interface":
|
|
674
|
+
if (/^interface|class$/.test(s)) isClass = true;
|
|
657
675
|
if (!o.isExpress) {
|
|
658
676
|
o = o.next;
|
|
659
677
|
|
|
@@ -662,6 +680,7 @@ var createScoped = function (parsed, wash) {
|
|
|
662
680
|
o.kind = isFunction ? 'function' : 'class';
|
|
663
681
|
saveTo(used, o.text, o);
|
|
664
682
|
o = o.next;
|
|
683
|
+
if (o?.type === ELEMENT) o = o.next;
|
|
665
684
|
}
|
|
666
685
|
}
|
|
667
686
|
isScope = true;
|
|
@@ -680,14 +699,15 @@ var createScoped = function (parsed, wash) {
|
|
|
680
699
|
break;
|
|
681
700
|
case SCOPED:
|
|
682
701
|
if (o.entry === "(") {
|
|
702
|
+
var prev = o.prev;
|
|
683
703
|
if (o.next && o.next.type === STAMP && o.next.text === "=>") {
|
|
684
704
|
isArrow = true;
|
|
685
705
|
isScope = true;
|
|
686
|
-
if (
|
|
706
|
+
if (prev?.type === STRAP && prev.text === 'async') {
|
|
687
707
|
isAsync = true;
|
|
688
708
|
}
|
|
689
709
|
}
|
|
690
|
-
else if (
|
|
710
|
+
else if (prev?.isprop) {
|
|
691
711
|
isFunction = true;
|
|
692
712
|
isScope = true;
|
|
693
713
|
var pp = o.prev.prev;
|
|
@@ -702,7 +722,7 @@ var createScoped = function (parsed, wash) {
|
|
|
702
722
|
run(o.first);
|
|
703
723
|
}
|
|
704
724
|
}
|
|
705
|
-
else if (o.
|
|
725
|
+
else if (o.brace && !o.isObject) {
|
|
706
726
|
isScope = true;
|
|
707
727
|
}
|
|
708
728
|
else {
|
|
@@ -799,7 +819,7 @@ var createScoped = function (parsed, wash) {
|
|
|
799
819
|
o = o.next.next;
|
|
800
820
|
}
|
|
801
821
|
if (!o);
|
|
802
|
-
else if (o.type === SCOPED && o.
|
|
822
|
+
else if (o.type === SCOPED && o.brace) {
|
|
803
823
|
scoped.body = o;
|
|
804
824
|
o.scoped = scoped;
|
|
805
825
|
o.isExpress = isExpress;
|
|
@@ -842,7 +862,7 @@ var createScoped = function (parsed, wash) {
|
|
|
842
862
|
|| EXPRESS === o.type && !/\.$/.test(o.text)) {
|
|
843
863
|
if ((VALUE | QUOTED | PROPERTY | LABEL) & next.type) break;
|
|
844
864
|
if (EXPRESS === next.type && !/^[\.\[]/.test(next.text)) break;
|
|
845
|
-
if (next.type === SCOPED && next.
|
|
865
|
+
if (next.type === SCOPED && next.brace) break;
|
|
846
866
|
if (next.type === STRAP && !next.isExpress) break;
|
|
847
867
|
}
|
|
848
868
|
o = next;
|
|
@@ -1006,7 +1026,7 @@ var getDeclared = function (o, kind, queue) {
|
|
|
1006
1026
|
}
|
|
1007
1027
|
else prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
|
|
1008
1028
|
}
|
|
1009
|
-
var f = snapExpressFoot(o);
|
|
1029
|
+
var f = o.isprop || prop ? snapExpressFoot(o) : o;
|
|
1010
1030
|
if (k) saveTo(used, k, o);
|
|
1011
1031
|
var s = [o];
|
|
1012
1032
|
while (o !== f) o = o.next, s.push(o);
|
|
@@ -1042,6 +1062,14 @@ var getDeclared = function (o, kind, queue) {
|
|
|
1042
1062
|
break;
|
|
1043
1063
|
}
|
|
1044
1064
|
break;
|
|
1065
|
+
case EXPRESS:
|
|
1066
|
+
if (o.text === '?') o = o.next;
|
|
1067
|
+
break;
|
|
1068
|
+
}
|
|
1069
|
+
if (o?.type === STAMP) {
|
|
1070
|
+
while (o?.istype) {
|
|
1071
|
+
o = o.next;
|
|
1072
|
+
}
|
|
1045
1073
|
}
|
|
1046
1074
|
if (!o) break;
|
|
1047
1075
|
if (o.type !== STAMP) break;
|
|
@@ -1104,7 +1132,7 @@ var getSemicolonBetween = function (prev, next) {
|
|
|
1104
1132
|
) {
|
|
1105
1133
|
if ((EXPRESS | VALUE | QUOTED | LABEL) & next.type) return ";";
|
|
1106
1134
|
if (next.type === STRAP) {
|
|
1107
|
-
if (!/^(in|of|extends|instanceof|as)$/.test(next.text)) return ";";
|
|
1135
|
+
if (!/^(in|of|extends|implements|instanceof|as|is|from)$/.test(next.text)) return ";";
|
|
1108
1136
|
return " ";
|
|
1109
1137
|
}
|
|
1110
1138
|
if (next.type === SCOPED && next.entry === '{') {
|
|
@@ -1185,12 +1213,12 @@ var createString = function (parsed) {
|
|
|
1185
1213
|
var intag = false;
|
|
1186
1214
|
var run = (o, i, a) => {
|
|
1187
1215
|
var prev = o.prev;
|
|
1188
|
-
a: if (
|
|
1189
|
-
if ((QUOTED | SCOPED | STRAP | LABEL | COMMENT | ELEMENT) & lasttype
|
|
1216
|
+
a: if (prev && lasttype !== SPACE && patchspace && ~(SPACE | COMMENT | STAMP | PIECE | SCOPED) & o.type) {
|
|
1217
|
+
if ((QUOTED | SCOPED | STRAP | LABEL | COMMENT | ELEMENT | PROPERTY) & lasttype
|
|
1190
1218
|
|| prev.type === STAMP && !prev.unary
|
|
1191
1219
|
) {
|
|
1192
1220
|
if (intag || prev.type === ELEMENT && o.type === ELEMENT) break a;
|
|
1193
|
-
if (o.type
|
|
1221
|
+
if ((o.type & ~(EXPRESS | PROPERTY) || !needhead_reg.test(o.text)) && (!prev.tag && !o.tag || prev.type === STAMP || o.type === STAMP)) {
|
|
1194
1222
|
result.push(" ");
|
|
1195
1223
|
lasttype = SPACE
|
|
1196
1224
|
}
|
|
@@ -1245,6 +1273,7 @@ var createString = function (parsed) {
|
|
|
1245
1273
|
result.push(o.entry);
|
|
1246
1274
|
result.push(o.tag);
|
|
1247
1275
|
if (o.attributes) {
|
|
1276
|
+
var _intag = intag;
|
|
1248
1277
|
intag = 0;
|
|
1249
1278
|
var attributes = o.attributes;
|
|
1250
1279
|
var needvalue = false;
|
|
@@ -1256,14 +1285,14 @@ var createString = function (parsed) {
|
|
|
1256
1285
|
}
|
|
1257
1286
|
else {
|
|
1258
1287
|
if (a.type === PIECE && !a.text) continue;
|
|
1259
|
-
if (!needvalue && (a.type !== PIECE ||
|
|
1288
|
+
if (!needvalue && !/\s$/.test(result[result.length - 1]) && a.type !== ELEMENT && (a.type !== PIECE || !/^[\=\s]/.test(a.text))) result.push(" ");
|
|
1260
1289
|
run(a);
|
|
1261
1290
|
needvalue = a.type === PIECE && /[\=]$/.test(a.text);
|
|
1262
1291
|
}
|
|
1263
1292
|
}
|
|
1264
|
-
intag =
|
|
1265
|
-
if (o.short && attributes.length > 0 &&
|
|
1266
|
-
if (!/[\s'"]$/.test(result[result.length - 1])) result.push(' ');
|
|
1293
|
+
intag = _intag;
|
|
1294
|
+
if (o.short && attributes.length > 0 && lasttype & ~(SPACE | QUOTED)) {
|
|
1295
|
+
if (!o.istype && !/[\s'"]$/.test(result[result.length - 1])) result.push(' ');
|
|
1267
1296
|
}
|
|
1268
1297
|
}
|
|
1269
1298
|
if (o.closed) {
|
|
@@ -1289,14 +1318,15 @@ var createString = function (parsed) {
|
|
|
1289
1318
|
break;
|
|
1290
1319
|
}
|
|
1291
1320
|
case SCOPED:
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|| lasttype
|
|
1321
|
+
var prev = o.prev;
|
|
1322
|
+
if (patchspace && prev && o.type !== QUOTED && (lasttype === STAMP && !prev.unary
|
|
1323
|
+
|| lasttype & ~(SPACE | STAMP | COMMENT) && o.brace
|
|
1324
|
+
|| lasttype === STRAP && !/^(this|arguments|import)$/.test(prev.text)
|
|
1295
1325
|
)) result.push(" ");
|
|
1296
1326
|
result.push(o.entry);
|
|
1297
1327
|
if (o.length > 0) {
|
|
1298
1328
|
var fillspace = patchspace && lasttype !== PIECE && !intag;
|
|
1299
|
-
if (o.
|
|
1329
|
+
if (o.brace && o[0].type !== SPACE) {
|
|
1300
1330
|
if (fillspace) {
|
|
1301
1331
|
result.push(" ");
|
|
1302
1332
|
}
|
|
@@ -1314,7 +1344,7 @@ var createString = function (parsed) {
|
|
|
1314
1344
|
else result.pop();
|
|
1315
1345
|
}
|
|
1316
1346
|
}
|
|
1317
|
-
if (o.
|
|
1347
|
+
if (o.brace && o[o.length - 1].type !== SPACE) {
|
|
1318
1348
|
if (fillspace) result.push(" ");
|
|
1319
1349
|
}
|
|
1320
1350
|
}
|
|
@@ -1322,11 +1352,11 @@ var createString = function (parsed) {
|
|
|
1322
1352
|
break;
|
|
1323
1353
|
default:
|
|
1324
1354
|
if (o && typeof o === "object") {
|
|
1325
|
-
if (intag || o.type
|
|
1326
|
-
if (o.prev?.isdigit &&
|
|
1355
|
+
if (intag || o.type & (EXPRESS | PROPERTY) && (needhead_reg.test(o.text) || lasttype & EXPRESS && /\.$/.test(o.prev?.text))) {
|
|
1356
|
+
if (o.prev?.isdigit && !/^0[\dxbo]|[mni]$|[e\.]/.test(o.prev.text) && lasttype & ~(SPACE | COMMENT)) result.push(" ");
|
|
1327
1357
|
}
|
|
1328
1358
|
else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
|
|
1329
|
-
if (autospace) result.push(" ");
|
|
1359
|
+
if (autospace || o.prev?.isdigit) result.push(" ");
|
|
1330
1360
|
}
|
|
1331
1361
|
else if (o.prev && o.type === STAMP && !/^[,;]/.test(o.text)) {
|
|
1332
1362
|
if (result[result.length - 1] === " " || (lasttype === PROPERTY || !o.isExpress && o.prev && o.prev.type !== LABEL) && o.text === ':') { }
|
|
@@ -1632,7 +1662,7 @@ var unshort = function (o, text) {
|
|
|
1632
1662
|
};
|
|
1633
1663
|
var getFuncBody = function (o) {
|
|
1634
1664
|
var q = o.queue;
|
|
1635
|
-
while (q && !
|
|
1665
|
+
while (q && !q.scoped?.isfunc) q = q.queue;
|
|
1636
1666
|
return q;
|
|
1637
1667
|
};
|
|
1638
1668
|
var getBodyWith = function (o, k) {
|
|
@@ -1710,6 +1740,7 @@ module.exports = {
|
|
|
1710
1740
|
/*2048 */ELEMENT,
|
|
1711
1741
|
number_reg,
|
|
1712
1742
|
equal_reg,
|
|
1743
|
+
needhead_reg,
|
|
1713
1744
|
unshort,
|
|
1714
1745
|
skipAssignment,
|
|
1715
1746
|
getDeclared,
|
|
@@ -510,7 +510,7 @@ var getprop = function (o, m) {
|
|
|
510
510
|
prop[m.text] = true;
|
|
511
511
|
m = m.next;
|
|
512
512
|
}
|
|
513
|
-
if (m && (m.
|
|
513
|
+
if (m && (m.isprop)) {
|
|
514
514
|
prop.name = createString([m]);
|
|
515
515
|
if (m.short) {
|
|
516
516
|
prop.short = true;
|
|
@@ -539,7 +539,7 @@ var getprop = function (o, m) {
|
|
|
539
539
|
var s = m;
|
|
540
540
|
if (m && prop.sfunc !== false && m.type === SCOPED && m.entry === '(') {
|
|
541
541
|
m = m.next;
|
|
542
|
-
if (m && m.type === SCOPED && m.
|
|
542
|
+
if (m && m.type === SCOPED && m.brace) m = m.next;
|
|
543
543
|
}
|
|
544
544
|
else m = skipAssignment(m);
|
|
545
545
|
if (m && !m.isprop) m = m.next;
|
|
@@ -1058,7 +1058,7 @@ var hasbreak = function (body) {
|
|
|
1058
1058
|
return false;
|
|
1059
1059
|
};
|
|
1060
1060
|
var ises3 = function (o, killobj) {
|
|
1061
|
-
if (o && o.type === SCOPED && o.
|
|
1061
|
+
if (o && o.type === SCOPED && o.brace) {
|
|
1062
1062
|
killobj(o);
|
|
1063
1063
|
if (o.await_) return false;
|
|
1064
1064
|
if (hasbreak(o)) return false;
|
|
@@ -1210,7 +1210,7 @@ var unarrow = function (body, i, killobj, letname_) {
|
|
|
1210
1210
|
h = scanner2("()")[0];
|
|
1211
1211
|
splice(h, 0, 0, ...splice(body, i, 1, h));
|
|
1212
1212
|
}
|
|
1213
|
-
if (n.type !== SCOPED || n.
|
|
1213
|
+
if (n.type !== SCOPED || !n.brace) {
|
|
1214
1214
|
var nni = skipAssignment(body, ni);
|
|
1215
1215
|
b = scanner2('{}')[0];
|
|
1216
1216
|
splice(b, 0, 0, { type: STRAP, transive: true, text: "return" }, ...splice(body, ni, nni - ni, b));
|
|
@@ -1376,7 +1376,7 @@ var killret = function (body, labels = Object.create(null), gettmpname) {
|
|
|
1376
1376
|
lbls.push(lbl);
|
|
1377
1377
|
}
|
|
1378
1378
|
}
|
|
1379
|
-
else if (o.type === SCOPED && o.
|
|
1379
|
+
else if (o.type === SCOPED && o.brace) {
|
|
1380
1380
|
if (o.isClass || o.isObject);
|
|
1381
1381
|
else killret(o, labels, gettmpname);
|
|
1382
1382
|
unlabel = true;
|
|
@@ -1721,7 +1721,7 @@ var down = function (scoped) {
|
|
|
1721
1721
|
fordeep = saveddeep;
|
|
1722
1722
|
};
|
|
1723
1723
|
if (scoped.isfunc) {
|
|
1724
|
-
if (!scoped.body && scoped.head?.next?.
|
|
1724
|
+
if (!scoped.body && scoped.head?.next?.brace) scoped.body = scoped.head.next;
|
|
1725
1725
|
if (scoped.head) var [argsmap, argcodes] = killarg(scoped.head, scoped.body, _letname, false);
|
|
1726
1726
|
else argcodes = [];
|
|
1727
1727
|
if ((markcodes.length || argcodes.length) && !funcMark) precode(markcodes.concat(argcodes).join(";") + ";");
|
|
@@ -431,4 +431,8 @@ _0 = a; return [_0, 1]
|
|
|
431
431
|
})
|
|
432
432
|
var a, _0 }`)
|
|
433
433
|
|
|
434
|
-
assert(downLevel(`function(a=b=>b,c){c}`), 'function (a, c) { if (a === undefined) a = function (b) { return b }; c }')
|
|
434
|
+
assert(downLevel(`function(a=b=>b,c){c}`), 'function (a, c) { if (a === undefined) a = function (b) { return b }; c }')
|
|
435
|
+
assert(downLevel(`Object.defineProperty(dis, f.key, {get() {}, set(v) {}})`), `Object.defineProperty(dis, f.key, (_ = {},
|
|
436
|
+
_.get = function () {},
|
|
437
|
+
_.set = function (v) {}, _))
|
|
438
|
+
var _`)
|
|
@@ -20,7 +20,7 @@ function format(code, step) {
|
|
|
20
20
|
var space = lowspace + step;
|
|
21
21
|
if (code.length === 0) continue;
|
|
22
22
|
var explist = createExpressList(code);
|
|
23
|
-
var breakline = explist.length > 1 && (code.isObject || !code.entry || code.
|
|
23
|
+
var breakline = explist.length > 1 && (code.isObject || !code.entry || code.brace);
|
|
24
24
|
code.splice(0, code.length);
|
|
25
25
|
if (breakline) code.push({ type: SPACE, text: space });
|
|
26
26
|
if (breakline) var deepspace = space + step;
|
package/coms/compile/powermap.js
CHANGED
|
@@ -23,7 +23,7 @@ var powermap = new class {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
[
|
|
26
|
-
'
|
|
26
|
+
'=,+=,-=,*=,/=,%=,|=,&=,^=,||=,&&=,??=,<<=,>>=,>>>=,**=,~=,:=,?,:,=>'/* 1 */,
|
|
27
27
|
'&&,||,^^,??'/* 4 */, '&,|,^'/* 5 */,
|
|
28
28
|
'instanceof,in,==,>=,<=,>,<,!=,!==,===,!in,!instanceof'/* 6 */,
|
|
29
29
|
'>>,>>>,<<'/* 7 */, '+,-'/* 8 */, '*,/,%'/* 9 */, '**'/* 10 */,
|
package/coms/compile/unstruct.js
CHANGED
|
@@ -529,7 +529,7 @@ var _invoke = function (t, getname) {
|
|
|
529
529
|
for (var cx = 0; cx < t.length; cx++) {
|
|
530
530
|
var o = t[cx];
|
|
531
531
|
a: if (o.type === STRAP) {
|
|
532
|
-
if (/^(async|function)/.test(o.text)) while (o && o.
|
|
532
|
+
if (/^(async|function)/.test(o.text)) while (o && !o.brace) o = o.next;
|
|
533
533
|
else if (o.text === 'class') {
|
|
534
534
|
while (o && !o.isClass) o = o.next;
|
|
535
535
|
var n = o.next;
|
|
@@ -898,7 +898,7 @@ var isFunctionOnly = function (body) {
|
|
|
898
898
|
var o = body[cx];
|
|
899
899
|
if (!o) return false;
|
|
900
900
|
if (o.type === STRAP) {
|
|
901
|
-
if (/^(async|function)$/.test(o.text)) while (o && o.
|
|
901
|
+
if (/^(async|function)$/.test(o.text)) while (o && !o.brace) o = body[cx++];
|
|
902
902
|
else if (o.text === 'class') {
|
|
903
903
|
while (o && !o.isClass) o = body[cx++];
|
|
904
904
|
while (o && (o.type & (SPACE | COMMENT) || o.isClass)) o = body[cx++];
|
package/coms/docs/codecolor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
var { STRAP, SCOPED, ELEMENT, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE } = compile$common;
|
|
2
|
+
var { STRAP, SCOPED, ELEMENT, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE, needhead_reg } = compile$common;
|
|
3
3
|
var predefs = Object.create(null);
|
|
4
4
|
predefs.module = true;
|
|
5
5
|
predefs.exports = true;
|
|
@@ -10,27 +10,49 @@ var codecolor = function (c, encode) {
|
|
|
10
10
|
var envs = c.envs;
|
|
11
11
|
var deep = 0;
|
|
12
12
|
var used = c.used;
|
|
13
|
+
var isConstValue = () => false;
|
|
14
|
+
if (c.program) {
|
|
15
|
+
var { strap_reg, value_reg } = c.program;
|
|
16
|
+
isConstValue = a => strap_reg.test(a) || value_reg.test(a);
|
|
17
|
+
};
|
|
18
|
+
var isInvoke = function (o) {
|
|
19
|
+
var o = o.next;
|
|
20
|
+
if (o?.type === EXPRESS && needhead_reg.test(o.text)) o = o.next;
|
|
21
|
+
if (o?.type === ELEMENT && o.istype) o = o.next;
|
|
22
|
+
if (o?.type === SCOPED && o.entry === "(") return true;
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
13
25
|
var setExpress = function (o, label) {
|
|
14
26
|
if (!o.text) return;
|
|
15
27
|
var keys = o.text.split(".");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!/^\</.test(keys[keys.length - 1])) keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
|
|
28
|
+
if (isInvoke(o)) {
|
|
29
|
+
if (!/^[\<\?]/.test(keys[keys.length - 1])) keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
|
|
19
30
|
}
|
|
20
31
|
var [name] = keys;
|
|
21
32
|
if (/^[\<\?]/.test(name) || !name);
|
|
22
|
-
else if (
|
|
33
|
+
else if (!o.isprop && isConstValue(name)) name = `<strap>${name}</strap>`;
|
|
23
34
|
else name = `<${label}>${name}</${label}>`;
|
|
24
35
|
keys[0] = name;
|
|
25
|
-
o.text = keys.map(k =>
|
|
36
|
+
o.text = keys.map(k => /^[\<\?]/.test(k) || !k ? k : `<express>${k}</express>`).join(".");
|
|
26
37
|
}
|
|
27
38
|
var setPredef = o => setExpress(o, 'predef');
|
|
28
39
|
var setOutside = o => setExpress(o, 'outside');
|
|
29
40
|
if (used) for (var k in envs) {
|
|
30
41
|
used[k].forEach(k in predefs ? setPredef : setOutside);
|
|
31
42
|
}
|
|
32
|
-
|
|
43
|
+
if (c.program) var { space_exp: spaceReg, control_reg } = c.program;
|
|
44
|
+
var unspaceReg = new RegExp(spaceReg.source.replace(/^\[/, "[^"), spaceReg.flags + 'g');
|
|
45
|
+
var wraptext = function (t, l) {
|
|
46
|
+
if (unspaceReg) t = t.replace(unspaceReg, a => {
|
|
47
|
+
a = encode(a);
|
|
48
|
+
return `<${l}>${a}</${l}>`
|
|
49
|
+
});
|
|
50
|
+
return t;
|
|
51
|
+
}
|
|
52
|
+
c.colored = true;
|
|
33
53
|
var setcolor = function (o) {
|
|
54
|
+
if (o.colored) return;
|
|
55
|
+
o.colored = true;
|
|
34
56
|
var text = o.text;
|
|
35
57
|
switch (o.type) {
|
|
36
58
|
case LABEL:
|
|
@@ -43,14 +65,23 @@ var codecolor = function (c, encode) {
|
|
|
43
65
|
o.leave = "<text>" + o.leave + "</text>";
|
|
44
66
|
break;
|
|
45
67
|
}
|
|
68
|
+
if (/^\//.test(o.text)) {
|
|
69
|
+
var source = o.text;
|
|
70
|
+
var flags = /[^\/]+$/.exec(source);
|
|
71
|
+
if (flags) {
|
|
72
|
+
flags = flags[0];
|
|
73
|
+
source = source.slice(0, source.length - flags.length);
|
|
74
|
+
}
|
|
75
|
+
source = wraptext(source, 'regexp');
|
|
76
|
+
if (flags) source = source + wraptext(flags, 'strap');
|
|
77
|
+
o.text = source;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
46
80
|
case PIECE:
|
|
47
81
|
if (o.queue && o.queue.tag) {
|
|
48
82
|
o.text = encode(o.text);
|
|
49
83
|
}
|
|
50
|
-
else
|
|
51
|
-
o.text = `<regexp>${encode(o.text)}</regexp>`;
|
|
52
|
-
}
|
|
53
|
-
else o.text = `<text>${encode(o.text)}</text>`;
|
|
84
|
+
else o.text = wraptext(o.text, 'text');
|
|
54
85
|
break;
|
|
55
86
|
break;
|
|
56
87
|
case ELEMENT:
|
|
@@ -76,17 +107,16 @@ var codecolor = function (c, encode) {
|
|
|
76
107
|
case PROPERTY:
|
|
77
108
|
var next = o.next;
|
|
78
109
|
if (next && next.type === SCOPED && next.entry === '(') {
|
|
79
|
-
o
|
|
110
|
+
setExpress(o, 'method');
|
|
80
111
|
}
|
|
81
|
-
else o
|
|
112
|
+
else setExpress(o, 'property');
|
|
82
113
|
|
|
83
114
|
break;
|
|
84
115
|
case EXPRESS:
|
|
85
|
-
setExpress(o, 'express');
|
|
116
|
+
setExpress(o, o.istype ? 'predef' : 'express');
|
|
86
117
|
break;
|
|
87
118
|
case STRAP:
|
|
88
|
-
if (
|
|
89
|
-
o.text = `<flow>${o.text}</flow>`;
|
|
119
|
+
if (control_reg?.test(text)) o.text = `<flow>${o.text}</flow>`;
|
|
90
120
|
else o.text = `<strap>${o.text}</strap>`;
|
|
91
121
|
break;
|
|
92
122
|
case STAMP:
|
|
@@ -95,7 +125,7 @@ var codecolor = function (c, encode) {
|
|
|
95
125
|
// else o.text = `<stamp>${encode(o.text)}</stamp>`;
|
|
96
126
|
break;
|
|
97
127
|
case COMMENT:
|
|
98
|
-
o.text =
|
|
128
|
+
o.text = wraptext(o.text, 'comment');
|
|
99
129
|
break;
|
|
100
130
|
}
|
|
101
131
|
};
|