efront 4.21.3 → 4.22.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.
Files changed (96) hide show
  1. package/#/345/233/275/351/231/205/345/214/226.yml +117 -66
  2. package/apps/blank/index.html +1 -1
  3. package/apps/index.jsp +76 -27
  4. package/apps/pay/alipay-query.jsp +1 -1
  5. package/apps/pay/alipay.jsp +1 -1
  6. package/apps/pivot/auth/login.js +2 -2
  7. package/apps/pivot/cert/main.xht +18 -5
  8. package/apps/pivot/db/act.xht +53 -0
  9. package/apps/pivot/db/config.xht +56 -16
  10. package/apps/pivot/home/welcome.html +12 -13
  11. package/apps/pivot/home/welcome.js +6 -6
  12. package/apps/pivot/home/welcome.less +12 -3
  13. package/apps/pivot/link/room.js +1 -1
  14. package/apps/pivot/main.js +3 -2
  15. package/apps/pivot/task/invoke.js +3 -3
  16. package/apps/pivot/task/rsync.js +2 -2
  17. package/apps/pivot/wow/root.js +8 -8
  18. package/coms/basic/#loader.js +9 -8
  19. package/coms/basic/Item.js +2 -2
  20. package/coms/basic/Tree.js +14 -2
  21. package/coms/basic/crc.js +5 -1
  22. package/coms/basic/cross_.js +2 -2
  23. package/coms/basic/decode62S.js +44 -0
  24. package/coms/basic/encode62S.js +40 -0
  25. package/coms/basic/encode62S_test.js +18 -0
  26. package/coms/basic/enrich.js +6 -1
  27. package/coms/basic/parseNumber.js +12 -7
  28. package/coms/basic/percent.js +28 -0
  29. package/coms/basic/refilm.js +24 -5
  30. package/coms/basic/refilm_decode.js +46 -22
  31. package/coms/basic/refilm_decode_test.js +5 -0
  32. package/coms/basic/valid.js +4 -0
  33. package/coms/basic_/&Array.js +64 -49
  34. package/coms/basic_/&extends.js +9 -2
  35. package/coms/compile/Html_test.js +5 -0
  36. package/coms/compile/Javascript.js +13 -3
  37. package/coms/compile/Javascript_test.js +3 -0
  38. package/coms/compile/Program.js +119 -43
  39. package/coms/compile/audit.js +23 -1
  40. package/coms/compile/cloneNode.js +3 -1
  41. package/coms/compile/common.js +7 -1
  42. package/coms/compile/downLevel.js +21 -11
  43. package/coms/compile/downLevel_test.js +52 -14
  44. package/coms/compile/rescan.js +8 -2
  45. package/coms/compile/scanner2.js +53 -7
  46. package/coms/compile/translate.js +1 -1
  47. package/coms/compile/unstruct.js +9 -9
  48. package/coms/crypt/encode62.js +36 -6
  49. package/coms/crypt/encode62_test.js +8 -48
  50. package/coms/explorer/main.less +1 -5
  51. package/coms/frame/chat.js +2 -2
  52. package/coms/frame/left.html +5 -4
  53. package/coms/frame/left.js +1 -0
  54. package/coms/frame/left.less +5 -3
  55. package/coms/frame/payment.js +2 -2
  56. package/coms/pivot/acme2.js +7 -4
  57. package/coms/pivot/left-footer.xht +25 -0
  58. package/coms/pivot/pedit.js +3 -3
  59. package/coms/pivot/plist.js +2 -2
  60. package/coms/pivot/qrcode.xht +3 -0
  61. package/coms/zimoli/XMLHttpRequest.js +16 -13
  62. package/coms/zimoli/container.js +34 -34
  63. package/coms/zimoli/design.html +6 -13
  64. package/coms/zimoli/design.js +49 -13
  65. package/coms/zimoli/design.less +62 -25
  66. package/coms/zimoli/drag.js +8 -3
  67. package/coms/zimoli/encode62.js +40 -12
  68. package/coms/zimoli/lattice.js +0 -1
  69. package/coms/zimoli/list.js +0 -8
  70. package/coms/zimoli/menu.js +29 -5
  71. package/coms/zimoli/model.js +150 -195
  72. package/coms/zimoli/model.less +4 -8
  73. package/coms/zimoli/on.js +14 -12
  74. package/coms/zimoli/padding.less +1 -0
  75. package/coms/zimoli/progbar.xht +9 -8
  76. package/coms/zimoli/prompt.less +0 -3
  77. package/coms/zimoli/render.js +210 -125
  78. package/coms/zimoli/select.js +9 -4
  79. package/coms/zimoli/select.less +3 -14
  80. package/coms/zimoli/selectList.js +5 -1
  81. package/coms/zimoli/selectList.less +3 -0
  82. package/coms/zimoli/table.html +7 -7
  83. package/coms/zimoli/table.js +12 -9
  84. package/coms/zimoli/table.less +5 -0
  85. package/coms/zimoli/user.js +2 -2
  86. package/coms/zimoli/view.js +3 -4
  87. package/coms/zimoli/watch.js +3 -1
  88. package/coms/zimoli/zimoli.js +6 -2
  89. package/coms//350/214/250/350/217/260/tab.js +26 -2
  90. package/coms//350/214/250/350/217/260//346/240/207/347/255/276/345/214/226.js +1 -1
  91. package/coms//350/214/250/350/217/260//347/274/226/350/276/221/346/241/206.xht +183 -20
  92. package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +5 -0
  93. package/package.json +1 -1
  94. package/public/efront.js +1 -1
  95. package/readme-en.md +3 -5
  96. package/readme.md +3 -4
@@ -11,7 +11,9 @@ const {
11
11
  /* 512 */LABEL,
12
12
  /*1024 */PROPERTY,
13
13
  /*2048 */ELEMENT,
14
+ pickAssignment,
14
15
  createString,
16
+ setqueue,
15
17
  number_reg,
16
18
  digit_reg,
17
19
  } = require("./common");
@@ -53,6 +55,16 @@ var stringsFromRegExp = function (reg) {
53
55
  var res = combine(...queue).map(a => a.join(""));
54
56
  return res;
55
57
  }
58
+
59
+ var trimDulp = function (list) {
60
+ var dist = [];
61
+ for (var a of list) {
62
+ if (dist.indexOf(a) >= 0) continue;
63
+ dist.push(a);
64
+ }
65
+ return dist;
66
+ }
67
+
56
68
  var spaceDefined = require("../basic/spaces");
57
69
 
58
70
  var powermap = require("./powermap");
@@ -64,7 +76,7 @@ class Program {
64
76
  ["`", "`", /\\[\s\S]/, ["${", "}"]],
65
77
  ]
66
78
  tags = [
67
- [["<", "</"], /\/?>/, /\\[\s\S]|\=\>/, "'", '"', "<!--", ["${", "}"]]
79
+ [["<", "</"], /\/?>/, /\\[\s\S]/, "'", '"', "<!--", ["${", "}"]]
68
80
  ];
69
81
  scriptTags = [];
70
82
  ignoreTags = ["STYLE", "SCRIPT"];
@@ -323,10 +335,10 @@ class Program {
323
335
  var scriptTags = this.scriptTags;
324
336
  var ignoreTags = this.ignoreTags;
325
337
  var structstrap_reg = this.structstrap_reg;
338
+ var mindpath = this.mindpath;
326
339
  var openTag = function () {
327
340
  var m1 = text.slice(start, match.index);
328
341
  var s = space_exp.exec(m1);
329
-
330
342
  if (s) var tag = m1.slice(0, s.index);
331
343
  else {
332
344
  tag = m1;
@@ -373,7 +385,10 @@ class Program {
373
385
  if (scope) queue = scope;
374
386
  return true;
375
387
  }
376
-
388
+ if (s && !tag) {
389
+ undefTag();
390
+ return;
391
+ }
377
392
  queue.inTag = true;
378
393
  queue.tag = tag;
379
394
  var tagName = tag.toUpperCase();
@@ -386,7 +401,8 @@ class Program {
386
401
  }
387
402
  if (s) {
388
403
  m = m1.slice(s[0].length + s.index);
389
- if (m) save(PIECE);
404
+ start += s[0].length + s.index;
405
+ push_piece();
390
406
  }
391
407
  queue.first = null;
392
408
  queue.last = null;
@@ -405,12 +421,60 @@ class Program {
405
421
  }
406
422
  }
407
423
  return istype;
424
+ };
425
+ var undefTag = () => {
426
+ var scope = {
427
+ type: STAMP,
428
+ text: queue.entry,
429
+ col: queue.col,
430
+ row: queue.row,
431
+ start: queue.start,
432
+ };
433
+ if (queue[0]) {
434
+ queue.splice(0, queue.length);
435
+ start = index = queue[0].start;
436
+ }
437
+ else {
438
+ queue = parents.pop();
439
+ start = index = scope.start + scope.text.length;
440
+ }
441
+ var last = queue.last;
442
+ if (last.type === PIECE) {
443
+ this.lastIndex = 0;
444
+ var thist = this.type;
445
+ this.type = undefined;
446
+ var res = this.exec(last.text);
447
+ this.type = thist;
448
+ this.lastIndex = index;
449
+ var prev = last.prev;
450
+ if (prev) {
451
+ prev.next = res.first;
452
+ }
453
+ if (res.first) {
454
+ res.first.prev = prev;
455
+ }
456
+ queue.last = res.last;
457
+ queue.splice(queue.length - 1, 1, ...res);
458
+ setqueue(res, queue);
459
+
460
+ }
461
+ queue_push(scope);
462
+
408
463
  }
409
464
  var closeTag = function () {
410
465
  queue.inTag = false;
466
+ if (text.charAt(index) === m) {
467
+ if ((m + m) in powermap) {
468
+ if (!parents[parents.length - 1].tag) {
469
+ undefTag();
470
+ return false;
471
+ }
472
+ }
473
+ }
411
474
  if (queue.closed) return;
412
475
  if (queue.length) queue.attributes = queue.splice(0, queue.length);
413
476
  if (/^\//.test(m) || queue.istype) return queue.short = true, queue.closed = true;
477
+ queue.tag_leave = m;
414
478
  return false;
415
479
  };
416
480
  var push_quote = function () {
@@ -506,10 +570,8 @@ class Program {
506
570
  start = index = match.index;
507
571
  }
508
572
  else queue.inTag = false;
509
-
510
- continue;
573
+ continue loop;
511
574
  }
512
-
513
575
  if (quote.end.test(m)) {
514
576
  end = match.index;
515
577
  if (queue.tag) {
@@ -517,7 +579,6 @@ class Program {
517
579
  if (!queue.inTag) continue;
518
580
  if (closeTag() === false) {
519
581
  start = index;
520
- queue.tag_leave = m;
521
582
  continue loop;
522
583
  }
523
584
  queue.type = ELEMENT;
@@ -542,7 +603,7 @@ class Program {
542
603
  scope.entry = m;
543
604
  scope.type = QUOTED;
544
605
  if (queue.istype) scope.istype = queue.istype;
545
- scope.start = index;
606
+ scope.start = match.index;
546
607
  scope.isExpress = queue.inExpress;
547
608
  push_parents(scope);
548
609
  queue.inTag = 0;
@@ -708,7 +769,7 @@ class Program {
708
769
  }
709
770
  queue.inExpress = true;
710
771
  queue.end = index;
711
- queue.text = text.slice(queue.start, index);
772
+ queue.text = text.slice(start, index);
712
773
  pop_parents();
713
774
  continue;
714
775
  }
@@ -746,13 +807,15 @@ class Program {
746
807
  }
747
808
  save(STRAP);
748
809
  var last = queue.last;
749
- if (last.type === STRAP && structstrap_reg.test(last.text) && !queue.classed) {
750
- queue.classed = [last.text];
810
+ m = last.text;
811
+ if (last.type === STRAP && structstrap_reg.test(m) && !queue.classed) {
812
+ queue.classed = [m];
751
813
  }
752
814
  else if (queue.classed) {
753
- if (last.type === STRAP && funcstrap_reg.test(last.text)) queue.classed.push(last.text);
815
+ if (last.type === STRAP && funcstrap_reg.test(m)) queue.classed.push(m);
754
816
  }
755
817
  if (funcstrap_reg.test(m)) {
818
+ last.isExpress = queue.inExpress;
756
819
  last.isargl = true;
757
820
  }
758
821
  else if (type_reg.test(m)) {
@@ -874,7 +937,7 @@ class Program {
874
937
  scope.istype = true;
875
938
  }
876
939
  }
877
- if (!last || (last.type !== STRAP && (!last.isObject || m === '(') || last.transive)) queue.inExpress = true;
940
+ if (!last || last.type !== STRAP && last.isExpress || last.transive) queue.inExpress = true;
878
941
  scope.isExpress = queue.inExpress;
879
942
  scope.inExpress = true;
880
943
  }
@@ -893,7 +956,16 @@ class Program {
893
956
  pop_parents();
894
957
  continue;
895
958
  }
896
- if (this.scope_leave[m]) console.warn(i18n`标记不匹配`, queue.entry, m, "queue-start:", queue.start, "position:", `${row}:${index - colstart}\r\n`, index - queue.start < 200 ? text.slice(queue.start, index) : text.slice(queue.start, queue.start + 100) + "..." + text.slice(index - 97, index));
959
+ if (this.scope_leave[m]) {
960
+ console.warn(
961
+ i18n`标记不匹配:`, queue.entry, m,
962
+ i18n`\r\n文件位置:`, this.mindpath + ":" + `${row}:${index - colstart}`,
963
+ i18n`\r\n摘要:\r\n`,
964
+ index - queue.start < 200
965
+ ? text.slice(queue.start, index)
966
+ : text.slice(queue.start, queue.start + 100) + "..." + text.slice(index - 97, index)
967
+ );
968
+ }
897
969
  save(STAMP);
898
970
  }
899
971
  while (queue.tag && parents.length) {
@@ -912,16 +984,12 @@ class Program {
912
984
  if (cache_stamp) push_stamp();
913
985
  this.lastIndex = index;
914
986
  if (queue !== origin) {
915
- console.log(
916
- "代码异常结束",
917
- createString(origin.slice(0, 30)),
918
- `\r\n ----- deep: ${parents.length}`,
919
- `\r\n ---- enrty: ${queue.entry}`,
920
- `\r\n --- length: ${queue.length}`,
921
- `\r\n ----- last: ${queue.last ? createString([queue.last]).slice(0, 30) : createString(queue).slice(0, 30)}`,
922
- `\r\n -- parents: ${parents.map(p => `${p.row}:${p.col}-${p.tag || p.text || p.entry} `).join('-)> ')}`,
923
- `\r\n ----- snap: ${createString([queue]).slice(-200)}`,
924
- `\r\n ------ end. `
987
+ var last = queue.last || queue;
988
+ console.warn(
989
+ "代码异常结束", createString(origin.slice(0, 30)),
990
+ `\r\n - 祖先标记: ${parents.slice(1).map(p => `<red2>${p.tag || p.text || ""}${p.entry || ""}</red2><gray>${p.row}:${p.col}</gray>`).join('')}`,
991
+ `\r\n - 内层入口: <yellow>${this.mindpath}</yellow>:${last.row}:${last.col} ${last.text || last.entry}`,
992
+ `\r\n ----- 快照: ${createString(pickAssignment(queue.last || queue))}`,
925
993
  );
926
994
  while (queue !== origin) {
927
995
  queue.error = "代码异常结束";
@@ -957,24 +1025,6 @@ class Program {
957
1025
  }
958
1026
  });
959
1027
  quoteslike.forEach(q => {
960
- var ts = [];
961
- var r = q.slice(q[2] ? 2 : 3).concat(q[1]).map(q => {
962
- if (q instanceof Array) {
963
- if (q.length > 2) {
964
- ts.push(...q.slice(0, q.length - 2));
965
- }
966
- else if (q.length !== 2) throw new Error(i18n`配置错误!`);
967
- q = q[q.length - 2];
968
- }
969
- if (q instanceof RegExp) {
970
- return q.source;
971
- }
972
- return this.compile(q);
973
- });
974
- if (q.tag) r = r.concat(q.tag);
975
- r = r.concat(ts.map(this.compile));
976
- r = sortRegster(r).join("|");
977
- q.reg = new RegExp(r, 'g');
978
1028
  q.end = this.createRegExp([q[1]]);
979
1029
  if (q.length >= 4) {
980
1030
  var entry = q.slice(3);
@@ -1019,6 +1069,32 @@ class Program {
1019
1069
  for (var k in this.powermap) if (k.length === 1 && stamps.indexOf(k) < 0) stamps.push(k);
1020
1070
  stamps.push.apply(stamps, powers);
1021
1071
  this.stamp_reg = new RegExp(`^(${stamps.map(this.compile).join('|')})$`);
1072
+ quoteslike.forEach(q => {
1073
+ var ts = [];
1074
+ var r = q.slice(q[2] ? 2 : 3).concat(q[1]).map(q => {
1075
+ if (q instanceof Array) {
1076
+ if (q.length > 2) {
1077
+ ts.push(...q.slice(0, q.length - 2));
1078
+ }
1079
+ else if (q.length !== 2) throw new Error(i18n`配置错误!`);
1080
+ q = q[q.length - 2];
1081
+ }
1082
+ if (q instanceof RegExp) {
1083
+ return q.source;
1084
+ }
1085
+ return this.compile(q);
1086
+ });
1087
+ if (q.tag) r = r.concat(q.tag, powers.filter(p => {
1088
+ var tagentries = q.tag[0];
1089
+ for (var t of tagentries) {
1090
+ if (p.indexOf(t) >= 0) return true;
1091
+ }
1092
+ return false;
1093
+ }).map(this.compile));
1094
+ r = r.concat(ts.map(this.compile));
1095
+ r = sortRegster(trimDulp(r)).join("|");
1096
+ q.reg = new RegExp(r, 'g');
1097
+ })
1022
1098
  }
1023
1099
  }
1024
1100
  module.exports = Program;
@@ -1,4 +1,4 @@
1
- var { STAMP, EXPRESS, STRAP, isHalfSentence, skipAssignment, skipFunction, getDeclared, VALUE, STRAP, SCOPED, QUOTED, snapSentenceHead, pickSentence, createString, getBodyWith, getFuncBody } = require("./common");
1
+ var { STAMP, EXPRESS, STRAP, isHalfSentence, pickArgument, skipAssignment, skipFunction, getDeclared, VALUE, STRAP, SCOPED, QUOTED, snapSentenceHead, pickSentence, createString, getBodyWith, getFuncBody } = require("./common");
2
2
  var addAccessedStart = function (matched, namedMap) {
3
3
  var start = +namedMap["#1"];
4
4
  var body = getBodyWith(matched[0], 'arguments');
@@ -125,6 +125,22 @@ var unMultiple = function (matched) {
125
125
  matched.suggest = `${createString(matched)}{\r\n // 不建议在可并行执行的函数中更改外部变量,以防并发调用时出现异常\r\n // 建议在可并行函数内声明如下变量,并修改用到这些变量的代码\r\n var ${undec.join(',')};\r\n }`;
126
126
  return matched;
127
127
  }
128
+ var checkSpliceSize = function (matched, i) {
129
+ var [m] = matched;
130
+ var argq = m.next;
131
+ if (argq?.type !== SCOPED || argq.entry !== '(') return;
132
+ var o = argq.first;
133
+ while (i-- > 0) {
134
+ o = skipAssignment(o).next;
135
+ }
136
+ var arg3 = pickArgument(o);
137
+ if (arg3.length === 1) {
138
+ var [size] = arg3;
139
+ if (!size.isdigit && !/\.length$/.test(size.text)) {
140
+ matched.suggest = `//第三个参数可能出错\r\n${createString([argq])}`;
141
+ }
142
+ }
143
+ }
128
144
  var suggest = {
129
145
  "while($2[$1++]!==$3)": "while($1<$2.length&&$2[$1++]!==$3)",
130
146
  "while($2[$1]!==$3)$1++": "while($1<$2.length&&$2[$1]!==$3)$1++",
@@ -132,6 +148,12 @@ var suggest = {
132
148
  "for(var $1=#1;$1<arguments.length;$1++)": addAccessedStart,
133
149
  "await": unMultiple,
134
150
  "yield": unMultiple,
151
+ "splice"(matched) {
152
+ checkSpliceSize(matched, 2);
153
+ },
154
+ ".splice"(matched) {
155
+ checkSpliceSize(matched, 1);
156
+ },
135
157
  "arguments"(matched) {
136
158
  var m = matched[0];
137
159
  var body = getBodyWith(m, 'arguments');
@@ -1,7 +1,8 @@
1
1
  var { VALUE, QUOTED, EXPRESS, STRAP, relink } = require("./common");
2
- var cloneNode = function (o) {
2
+ var cloneNode = function (o, keep) {
3
3
  var c = o;
4
4
  if (c instanceof Array && !c.text) {
5
+ if (keep) return c;
5
6
  c = c.map(cloneNode);
6
7
  c.entry = o.entry;
7
8
  c.leave = o.leave;
@@ -12,6 +13,7 @@ var cloneNode = function (o) {
12
13
  relink(c);
13
14
  }
14
15
  else if (typeof c === 'object' && c instanceof Object) {
16
+ if (keep) return c;
15
17
  c = Object.assign({}, c);
16
18
  }
17
19
  else switch (typeof c) {
@@ -1233,7 +1233,13 @@ var getSemicolonBetween = function (prev, next) {
1233
1233
  if (
1234
1234
  (EXPRESS | VALUE | QUOTED) & prev.type
1235
1235
  || prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
1236
- || prev.type === SCOPED && (prev.isExpress || prev.isObject)
1236
+ || prev.type === SCOPED && (prev.isExpress || prev.isObject || prev.entry === '(' && (
1237
+ // 这两种分号不存在时efront的解析器可以识别,v8的识别不了,为了兼容追加分号
1238
+ // do{}while(); return
1239
+ // =function(){}(); return
1240
+ prev.perv?.type === STRAP && prev.prev.text === 'while' || prev.prev?.type === SCOPED
1241
+ )
1242
+ )
1237
1243
  ) {
1238
1244
  if ((EXPRESS | VALUE | QUOTED | LABEL) & next.type) return ";";
1239
1245
  if (next.type === STRAP) {
@@ -355,7 +355,7 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
355
355
  else {
356
356
  var objname = getobjname(0);
357
357
  q = scanner2(`(${objname} =)`);
358
- q[0].push(...splice(queue, i, i2));
358
+ q[0].push(...splice(queue, i, i2 - i));
359
359
  q[0].push(...scanner2(`${a[0]},${objname}!== undefined ? ${objname}: `), ...splice2(a[2], a[3], a[4]));
360
360
  i2 = i;
361
361
  }
@@ -365,7 +365,7 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
365
365
  }
366
366
  }
367
367
  tmpname = getobjname(0);
368
- if (i > i0) splice(queue, i++, 0, { type: STAMP, text: ',' }, { type: EXPRESS, text: tmpname }, { type: STAMP, text: "=" });
368
+ if (index > 0) splice(queue, i++, 0, { type: STAMP, text: ',' }, { type: EXPRESS, text: tmpname }, { type: STAMP, text: "=" });
369
369
  else splice(queue, i, 0, { type: EXPRESS, text: tmpname }, { type: STAMP, text: "=" });
370
370
  i += 2;
371
371
  var i2 = skipAssignment(queue, i);
@@ -591,7 +591,7 @@ var setprop = function (prop, k, d, q, tempname) {
591
591
  tmp = tmp[tmp.length - 1];
592
592
  d[prop.name] = tmp;
593
593
  }
594
- insert1(d[prop.name], null, ...rescan`[${prop.get ? '"get"' : '"set"'}]=${pv},${tempname}`);
594
+ insert1(d[prop.name], null, ...rescan.keep`[${prop.get ? '"get"' : '"set"'}]=${pv},${tempname}`);
595
595
  }
596
596
  else {
597
597
  insert1(q, null, ...scanner2(`${q && q.length ? "\r\n" : ''}${k}${prop.name}=`));
@@ -599,7 +599,7 @@ var setprop = function (prop, k, d, q, tempname) {
599
599
  }
600
600
  }
601
601
  var rootenvs = null, rootHyper;
602
- var killcls = function (body, i, letname_, getname_) {
602
+ var killcls = function (body, i, letname_, getname_, killobj) {
603
603
  var extends_ = [];
604
604
  var o = body[i];
605
605
  var ishalf = isHalfSentence(body, i - 1);
@@ -651,6 +651,7 @@ var killcls = function (body, i, letname_, getname_) {
651
651
  while (m) {
652
652
  var [prop, m] = getprop(o, m);
653
653
  if (!prop.value.length) prop.value = scanner2('undefined;');
654
+ else if (!prop.sfunc) killobj(prop.value);
654
655
  var k = prop.static ? clz.name : `${clz.name}["prototype"]`;
655
656
  var d = prop.static ? static_ : define_;
656
657
  if (prop.get || prop.set || prop.static) {
@@ -683,14 +684,18 @@ var killcls = function (body, i, letname_, getname_) {
683
684
  if (isExpress) fname[0].isExpress = true;
684
685
  insert1(invokes, null, ...fname);
685
686
  if (base) {
686
- constructor[1].push(...scanner2('return this'))
687
+ var retthis = 'return this';
688
+ if (assign.length && assign.last.type !== SPACE && assign.last.text !== ';') {
689
+ retthis = "\r\n" + retthis;
690
+ }
691
+ constructor[1].push(...scanner2(retthis))
687
692
  relink(constructor[1]);
688
693
  var cs = createScoped(constructor[1]);
689
694
  var newt = getname(cs.vars, cs.envs, 'this_');
690
695
  if (cs.caps.this) rename(cs.caps, 'this', newt);
691
696
  var inited = false;
692
697
  assign.forEach(o => {
693
- if (o.type === EXPRESS) o.text = o.text.replace(/^this([\[\.]|$)/g, newt + "$1");
698
+ if (o.type === EXPRESS || o.type === VALUE && !o.isdigit) o.text = o.text.replace(/^this([\[\.]|$)/g, newt + "$1");
694
699
  });
695
700
  if (cs.caps.super) {
696
701
  cs.caps.super.forEach(o => {
@@ -704,7 +709,7 @@ var killcls = function (body, i, letname_, getname_) {
704
709
  inited = true;
705
710
  insert1(o.queue, o, ...scanner2(`var ${newt}=`));
706
711
  if (n.length) n.unshift({ type: STAMP, text: ',' });
707
- n.unshift({ type: EXPRESS, text: 'this' });
712
+ n.unshift({ type: VALUE, text: 'this' });
708
713
  insert1(o.queue, n.next, ...scanner2(`||this;`));
709
714
  })
710
715
  }
@@ -984,7 +989,7 @@ var killobj = function (body, getobjname, getletname, getname_, letname_, deep =
984
989
  i++;
985
990
  break;
986
991
  case "class":
987
- i = killcls(body, i, letname_, getname_);
992
+ i = killcls(body, i, letname_, getname_, deepkill);
988
993
  break;
989
994
  case "for":
990
995
  case "function":
@@ -1042,6 +1047,11 @@ var killobj = function (body, getobjname, getletname, getname_, letname_, deep =
1042
1047
  continue;
1043
1048
  }
1044
1049
  else if (o.entry === '(') {
1050
+ var arg = o.last;
1051
+ if (arg?.type === STAMP && arg.text === ',') {
1052
+ splice2(o, arg, arg.next);
1053
+ arg = arg.prev;
1054
+ }
1045
1055
  if (o.next && o.next.type === STAMP && o.next.text === '=>');
1046
1056
  else if (o.prev && o.prev.type === STRAP) {
1047
1057
  var p = o.prev;
@@ -1200,7 +1210,7 @@ var unforof = function (o, getnewname, used, killobj) {
1200
1210
  if (hasdeclare) {
1201
1211
  var [d] = getDeclared(m0);
1202
1212
  if (d.length) insert1(o, m, ...scanner2(d.join(",") + ","));
1203
- else splice(o, o.first, m0);
1213
+ else splice2(o, o.first, m0);
1204
1214
  }
1205
1215
  var iname = getnewname();
1206
1216
  var gname = getnewname();
@@ -1266,7 +1276,7 @@ var unarrow = function (body, i, killobj, letname_) {
1266
1276
  splice(b, 0, 0, { type: STRAP, transive: true, text: "return" }, ...splice(body, ni, nni - ni, b));
1267
1277
  killarg(h, b, letname_);
1268
1278
  killobj(b);
1269
- ni = nni;
1279
+ nni = indexof(body, b, ni) + 1;
1270
1280
  }
1271
1281
  else nni = ni + 1;
1272
1282
  return nni;
@@ -1614,7 +1624,7 @@ var newpunc = function (body, i, newname) {
1614
1624
  }
1615
1625
  splice(sentence, 0, 0, ...scanner2(`,${name}.${n}=${name}.${n}${punc}`));
1616
1626
  }
1617
- splice(sentence, 0, 0, ...scanner2(`${name}=`), ...splice(body, hi, i));
1627
+ splice(sentence, 0, 0, ...scanner2(`${name}=`), ...splice(body, hi, i - hi));
1618
1628
  if (!isEval(body) || hp && hp.type === STAMP && /[=>]$/.test(hp.text)) {
1619
1629
  var temp = scanner2(`()`)
1620
1630
  splice(temp[0], 0, 0, ...sentence);
@@ -258,7 +258,7 @@ function () {
258
258
  return [0, 9]
259
259
  },
260
260
  function () {
261
- _2 = _; if (!_2) return [1, 0]; _2 = !_["done"]; if (!_2) return [1, 0]; _2 = _0["return"]; _2 = isFunction(_2)
261
+ _2 = _; if (!_2) return [1, 0]; _2 = !_["done"]; if (!_2) return [1, 0]; _2 = _0["return"], _2 = typeof _2, _2 = _2 === "function"
262
262
  },
263
263
  function () {
264
264
  if (!_2) return [1, 0]; _2 = _0["return"](); return [1, 0]
@@ -287,10 +287,10 @@ function (_4) {
287
287
  _5 = _4; _1 = _5; _6 = Symbol["iterator"]; _6 = _1[_6]; if (_6) return [1, 0]; _6 = Array["prototype"]; _7 = Symbol["iterator"]; _6 = _6[_7]
288
288
  },
289
289
  function () {
290
- _2 = _6["call"](_1); _3 = undefined; _3 = _2["next"](); o = _3["value"]; _3 = _2["next"](); s = _3["value"]; _10 = !_3; if (_10) return [1, 0]; _10 = !_3["done"]
290
+ _2 = _6["call"](_1); _3 = undefined; _3 = _2["next"](); o = _3["value"]; _3 = _2["next"](); s = _3["value"]; _11 = !_3; if (_11) return [1, 0]; _11 = !_3["done"]
291
291
  },
292
292
  function () {
293
- if (!_10) return [1, 0]; _10 = _2["return"]; _10 = isFunction(_10); if (!_10) return [1, 0]; _10 = _2["return"]()
293
+ _10 = _11; if (!_10) return [1, 0]; _10 = _2["return"], _10 = typeof _10, _10 = _10 === "function"; if (!_10) return [1, 0]; _10 = _2["return"]()
294
294
  },
295
295
  function () {
296
296
  _3 = _10; _5 = true
@@ -305,7 +305,7 @@ function () {
305
305
  return [0, 9]
306
306
  },
307
307
  function () {
308
- _5 = _; if (!_5) return [1, 0]; _5 = !_["done"]; if (!_5) return [1, 0]; _5 = _0["return"]; _5 = isFunction(_5)
308
+ _5 = _; if (!_5) return [1, 0]; _5 = !_["done"]; if (!_5) return [1, 0]; _5 = _0["return"], _5 = typeof _5, _5 = _5 === "function"
309
309
  },
310
310
  function () {
311
311
  if (!_5) return [1, 0]; _5 = _0["return"](); return [1, 0]
@@ -313,14 +313,14 @@ if (!_5) return [1, 0]; _5 = _0["return"](); return [1, 0]
313
313
  function () {
314
314
  return [1, 9]
315
315
  })
316
- var o, s, _, _0, _1, _2, _3, _5, _6, _7, _8, _9, _10`);
316
+ var o, s, _, _0, _1, _2, _3, _5, _6, _7, _8, _9, _10, _11`);
317
317
  assert(downLevel(`for(o of os) noSymbol`), `for (_ = 0; _ < os["length"] && (o = os[_], true); _++) noSymbol\r\nvar _, _0`)
318
- assert(downLevel(`for(var o of os) Symbol`), `try { for (var o, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && isFunction(_0["return"])) _0["return"]() }\r\nvar _, _0`)
319
- assert(downLevel(`for(var o of os) Symbol`), `try { for (var o, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && isFunction(_0["return"])) _0["return"]() }\r\nvar _, _0`)
320
- assert(downLevel(`for(var o of o)Symbol`), `try { for (var o, _1 = o, _0 = _1[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](_1), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && isFunction(_0["return"])) _0["return"]() }\r\nvar _, _0, _1`)
321
- assert(downLevel(`for(var [a] of os)Symbol`), `try { for (var a, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (_1 = _["value"], _2 = (_1[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]])["call"](_1), _3 = undefined, _3 = _2["next"](), a = _3["value"], _3 = (!_3 || !_3["done"]) && isFunction(_2["return"]) && _2["return"](), true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && isFunction(_0["return"])) _0["return"]() }
318
+ assert(downLevel(`for(var o of os) Symbol`), `try { for (var o, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && typeof _0["return"] === "function") _0["return"]() }\r\nvar _, _0`)
319
+ assert(downLevel(`for(var o of os) Symbol`), `try { for (var o, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && typeof _0["return"] === "function") _0["return"]() }\r\nvar _, _0`)
320
+ assert(downLevel(`for(var o of o)Symbol`), `try { for (var o, _1 = o, _0 = _1[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](_1), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && typeof _0["return"] === "function") _0["return"]() }\r\nvar _, _0, _1`)
321
+ assert(downLevel(`for(var [a] of os)Symbol`), `try { for (var a, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (_1 = _["value"], _2 = (_1[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]])["call"](_1), _3 = undefined, _3 = _2["next"](), a = _3["value"], _3 = (!_3 || !_3["done"]) && typeof _2["return"] === "function" && _2["return"](), true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && typeof _0["return"] === "function") _0["return"]() }
322
322
  var _, _0, _1, _2, _3`)
323
- assert(downLevel(`for(var [a,b] of os)Symbol`), `try { for (var a, b, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (_1 = _["value"], _2 = (_1[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]])["call"](_1), _3 = undefined, _3 = _2["next"](), a = _3["value"], _3 = _2["next"](), b = _3["value"], _3 = (!_3 || !_3["done"]) && isFunction(_2["return"]) && _2["return"](), true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && isFunction(_0["return"])) _0["return"]() }
323
+ assert(downLevel(`for(var [a,b] of os)Symbol`), `try { for (var a, b, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (_1 = _["value"], _2 = (_1[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]])["call"](_1), _3 = undefined, _3 = _2["next"](), a = _3["value"], _3 = _2["next"](), b = _3["value"], _3 = (!_3 || !_3["done"]) && typeof _2["return"] === "function" && _2["return"](), true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && typeof _0["return"] === "function") _0["return"]() }
324
324
  var _, _0, _1, _2, _3`)
325
325
  assert(downLevel(`[...a]=a`), `var &slice = Array["prototype"]["slice"];\r\na = &slice["call"](a, 0)`)
326
326
  assert(downLevel(`[c,...a]=a`), `var &slice = Array["prototype"]["slice"];\r\nc = a[0], a = &slice["call"](a, 1)`)
@@ -368,7 +368,7 @@ function () {
368
368
  return [0, 9]
369
369
  },
370
370
  function () {
371
- _3 = _0; if (!_3) return [1, 0]; _3 = !_0["done"]; if (!_3) return [1, 0]; _3 = _1["return"]; _3 = isFunction(_3)
371
+ _3 = _0; if (!_3) return [1, 0]; _3 = !_0["done"]; if (!_3) return [1, 0]; _3 = _1["return"], _3 = typeof _3, _3 = _3 === "function"
372
372
  },
373
373
  function () {
374
374
  if (!_3) return [1, 0]; _3 = _1["return"](); return [1, 0]
@@ -398,7 +398,7 @@ function () {
398
398
  return [0, 9]
399
399
  },
400
400
  function () {
401
- _2 = _; if (!_2) return [1, 0]; _2 = !_["done"]; if (!_2) return [1, 0]; _2 = _0["return"]; _2 = isFunction(_2)
401
+ _2 = _; if (!_2) return [1, 0]; _2 = !_["done"]; if (!_2) return [1, 0]; _2 = _0["return"], _2 = typeof _2, _2 = _2 === "function"
402
402
  },
403
403
  function () {
404
404
  if (!_2) return [1, 0]; _2 = _0["return"](); return [1, 0]
@@ -487,12 +487,50 @@ var _, _0`)
487
487
  assert(downLevel(`[...{}[a]]=[1]`), `var &slice = Array["prototype"]["slice"];
488
488
  _ = [1], {}[a] = &slice["call"](_, 0)
489
489
  var _`)
490
- assert(downLevel(`,{...{}[a]}=[1]`), `_ = [1], {}[a] = &rest(_, [])
490
+ assert(downLevel(`,{...{}[a]}=[1]`), `, _ = [1], {}[a] = &rest(_, [])
491
491
  var _`)
492
492
  assert(downLevel(`var res=null,res2=1,{...{}[a]}=[1]`), `var res = null, res2 = 1, _ = [1], {}[a] = &rest(_, [])
493
493
  var _`);
494
494
  assert(downLevel(`var res=null,{...{}[a]}=[1]`), `var res = null, _ = [1], {}[a] = &rest(_, [])
495
495
  var _`)
496
- assert(downLevel(`,{b,...{}[a]}=[1]`), `_ = [1], b = _.b, {}[a] = &rest(_, ["b"])
496
+ assert(downLevel(`,{b,...{}[a]}=[1]`), `, _ = [1], b = _.b, {}[a] = &rest(_, ["b"])
497
497
  var _`)
498
498
  assert(downLevel(`var penddings = {}, circle = [], module_keys = [];`), `var penddings = {}, circle = [], module_keys = [];`)
499
+ assert(downLevel(`0,{a,b}=this`), '0, _ = this, a = _.a, b = _.b\r\nvar _')
500
+ assert(downLevel(`0,{a,b}=1`), '0, _ = 1, a = _.a, b = _.b\r\nvar _')
501
+ assert(downLevel(`0,{a,b}=true`), '0, _ = true, a = _.a, b = _.b\r\nvar _')
502
+ assert(downLevel(`0,{a,b}=eval`), '0, _ = eval, a = _.a, b = _.b\r\nvar _')
503
+ assert(downLevel(`0,{a,b}=a`), '0, _ = a, a = a.a, b = _.b\r\nvar _')
504
+ assert(downLevel(`0,{a,b}=[]`), '0, _ = [], a = _.a, b = _.b\r\nvar _')
505
+ assert(downLevel(`0,{a,b}=a.b`), '0, _ = a.b, a = _.a, b = _.b\r\nvar _')
506
+ assert(downLevel(`var [list = this] = arguments;`), `var list = (_ = arguments[0], _ !== undefined ? _ : this);
507
+ var _`)
508
+ assert(downLevel(`var [list = this] = arguments`), `var list = (_ = arguments[0], _ !== undefined ? _ : this)
509
+ var _`)
510
+ assert(downLevel(`var [list = this] = 0;`), `var list = (_ = 0[0], _ !== undefined ? _ : this);
511
+ var _`)
512
+ assert(downLevel(`a => a() + a(1), a => a`), `function (a) { return a() + a(1) }, function (a) { return a }`)
513
+ assert(downLevel(`a(a,)`), `a(a)`);
514
+ assert(downLevel(`class{a=[...presets.source]}`), `var &slice = Array["prototype"]["slice"];
515
+ function () { this.a = &slice["call"](presets.source) }`);
516
+ assert(downLevel(`class{a=a=>a}`), `function () { this.a = function (a) { return a } }`);
517
+ assert(downLevel(`class{ get a(){[...a]}}`), `var &slice = Array["prototype"]["slice"];
518
+ function () {};
519
+ Object["defineProperty"](cls0["prototype"], "a", (tmp = {}, tmp["get"] = function () { &slice["call"](a) }, tmp))
520
+ var tmp`);
521
+ assert(downLevel(`class{ get (){[...a]}}`), `var &slice = Array["prototype"]["slice"];
522
+ function () {}; cls0["prototype"].get = function () { &slice["call"](a) }`);
523
+ assert(downLevel(`class{ async get a(){[...a]}}`), `var &slice = Array["prototype"]["slice"];
524
+ function () {};
525
+ Object["defineProperty"](cls0["prototype"], "a", (tmp = {}, tmp["get"] = function () { &slice["call"](a) }, tmp))
526
+ var tmp`);
527
+ assert(downLevel(`a=class{ static a(){[...a]}}`), `var &slice = Array["prototype"]["slice"];
528
+ a = function (cls0) { cls0.a = function () { &slice["call"](a) }
529
+ return cls0 }(function () {})`);
530
+ assert(downLevel(`a=class{ static(){[...a]}}`), `var &slice = Array["prototype"]["slice"];
531
+ a = function (cls0) { cls0["prototype"].static = function () { &slice["call"](a) }
532
+ return cls0 }(function () {})`);
533
+ assert(downLevel(`a=class{ static{[...a]}}`), `var &slice = Array["prototype"]["slice"];
534
+ a = function (cls0) { (function () { &slice["call"](a) }())
535
+ return cls0 }(function () {})`);
536
+
@@ -1,5 +1,5 @@
1
1
  var { SCOPED, EXPRESS, replace } = require("./common");
2
-
2
+ var keep = false;
3
3
  var patchObject = function (code, objs) {
4
4
  var rest = [code];
5
5
  var m = null;
@@ -12,7 +12,7 @@ var patchObject = function (code, objs) {
12
12
  }
13
13
  if (c.type === EXPRESS) {
14
14
  if (m = /^#\\(\d+)$/.exec(c.text)) {
15
- var o = cloneNode(objs[+m[1]]);
15
+ var o = cloneNode(objs[+m[1]], keep);
16
16
  if (o instanceof Array) replace(c, ...o);
17
17
  else replace(c, o);
18
18
  }
@@ -32,4 +32,10 @@ function rescan(strs, ...args) {
32
32
  dist = scanner2(dist.join(''));
33
33
  patchObject(dist, args);
34
34
  return dist;
35
+ }
36
+ rescan.keep = function () {
37
+ keep = true;
38
+ var res = rescan.apply(this, arguments);
39
+ keep = false;
40
+ return res;
35
41
  }