efront 4.7.3 → 4.8.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.
@@ -36,9 +36,13 @@ var skipAssignment = function (o, cx) {
36
36
  else if (o.type & (SPACE | COMMENT)) o = o.next;
37
37
  var needpunc = false;
38
38
  var qcount = 0;
39
+ var condition = false;
39
40
  var ifdeep = 0;
40
- var labeled = o && o.type === LABEL;
41
- while (o && o.type === LABEL) next();
41
+ var labeled = o && (o.type === LABEL || o.type === STRAP && /^(var|const|let)$/i.test(o.text));
42
+ var skipLabel = function () {
43
+ while (o?.type === LABEL) next();
44
+ };
45
+ skipLabel();
42
46
  loop: while (o) switch (o.type) {
43
47
  case LABEL:
44
48
  if (!ifdeep) break loop;
@@ -51,7 +55,7 @@ var skipAssignment = function (o, cx) {
51
55
  next();
52
56
  break;
53
57
  case ",":
54
- if (!ifdeep && !labeled) break loop;
58
+ if (!ifdeep && !labeled && !condition) break loop;
55
59
  needpunc = false;
56
60
  next();
57
61
  break;
@@ -132,6 +136,7 @@ var skipAssignment = function (o, cx) {
132
136
  if (o.text === 'catch') {
133
137
  next();
134
138
  if (o && o.entry === '(') next();
139
+ skipLabel();
135
140
  needpunc = false;
136
141
  break;
137
142
  }
@@ -147,14 +152,23 @@ var skipAssignment = function (o, cx) {
147
152
  if (ifdeep <= 0) break loop;
148
153
  ifdeep--;
149
154
  needpunc = false;
155
+ skipLabel();
150
156
  next();
151
157
  }
152
158
  else if (/^(if|while|with|switch|try)$/.test(o.text)) {
153
159
  if (o.text === 'if') ifdeep++;
160
+ skipLabel();
154
161
  next();
155
- if (o.entry === "(") next();
162
+ skipLabel();
163
+ if (o?.entry === "(") next();
164
+ skipLabel();
165
+ if (o?.type === SCOPED && o.entry === '{') {
166
+ condition = false;
167
+ }
168
+ else condition = true;
156
169
  }
157
170
  else if (o.text === 'do') {
171
+ skipLabel();
158
172
  next();
159
173
  next();
160
174
  next();
@@ -162,6 +176,7 @@ var skipAssignment = function (o, cx) {
162
176
  else if (o.text === 'for') {
163
177
  next();
164
178
  if (o.type === STRAP && o.text === 'await') next();
179
+ skipLabel();
165
180
  next();
166
181
  }
167
182
  else if (o.text === "class") {
@@ -289,12 +304,15 @@ function snapSentenceHead(o) {
289
304
  p = o.prev;
290
305
  if (!p) break;
291
306
  }
292
- else if (p.type === STRAP) {
293
- var pp = getContitionHeadBeforeScoped(o, false);
294
- if (pp) { o = pp; break; }
295
- pp = getFunctionHeadBeforeScoped(o);
296
- if (pp) { o = pp; continue };
297
- }
307
+ var pp = getContitionHeadBeforeScoped(o, false);
308
+ if (pp) { o = pp; break; }
309
+ pp = getFunctionHeadBeforeScoped(o);
310
+ if (pp) {
311
+ o = pp;
312
+ p = o.prev;
313
+ if (!p || p.type === STAMP && /^[,;]$/.test(p.text)) break;
314
+ continue
315
+ };
298
316
  }
299
317
  var maybeprop = o.type === SCOPED && o.entry !== "{" || o.type === EXPRESS && /^[\.\[]/.test(o.text);
300
318
  if (p.type === EXPRESS) {
@@ -325,7 +343,12 @@ function snapSentenceHead(o) {
325
343
  var pp = getContitionHeadBeforeScoped(p, true);
326
344
  if (pp) { o = pp; break; }
327
345
  var pp = getFunctionHeadBeforeScoped(p);
328
- if (pp) { o = pp; continue; }
346
+ if (pp) {
347
+ o = pp;
348
+ p = o.prev;
349
+ if (!p || p.type === STAMP && /^[,;]$/.test(p.text)) break;
350
+ continue;
351
+ }
329
352
  }
330
353
  break;
331
354
  }
@@ -361,7 +384,7 @@ function snapSentenceHead(o) {
361
384
  if (/^[\?\:]$/.test(p.text)) {
362
385
  if (o) {
363
386
  var e = snapExpressFoot(o).next;
364
- if (e.type === STAMP && equal_reg.test(e.text)) break;
387
+ if (!e || e.type === STAMP && equal_reg.test(e.text)) break;
365
388
  }
366
389
  }
367
390
  if (/^(?:[!~]|\+\+|\-\-)$/.test(p.text)) {
@@ -375,11 +398,6 @@ function snapSentenceHead(o) {
375
398
  o = p;
376
399
  continue;
377
400
  }
378
- var pp = p.prev;
379
- if (pp.type === STAMP && /^(\+\+|\-\-)$/.test(pp.text) && pp.prev) {
380
- o = pp.prev;
381
- continue;
382
- }
383
401
  o = p.prev;
384
402
  continue;
385
403
  }
@@ -541,6 +559,7 @@ var createScoped = function (parsed, wash) {
541
559
  case VALUE:
542
560
  if (o.isdigit || /^(null|false|true)$/.test(o.text)) break;
543
561
  case EXPRESS:
562
+ if (needhead_reg.test(o.text)) break;
544
563
  // if (o.text === 'readFileAsync') console.log(o)
545
564
  if (o.prev && o.prev.type === EXPRESS) {
546
565
  if (/\.$/.test(o.prev.text)) break;
@@ -548,6 +567,7 @@ var createScoped = function (parsed, wash) {
548
567
  if (o.next && o.next.type === STAMP && o.next.text === "=>") {
549
568
  isScope = true;
550
569
  isArrow = true;
570
+ isAsync = o.prev?.type === STRAP && o.prev.text === 'async';
551
571
  }
552
572
  else {
553
573
  var u = o.text;
@@ -569,7 +589,7 @@ var createScoped = function (parsed, wash) {
569
589
  name = name.replace(/\s*\:$/, '');
570
590
  vars[name] = true;
571
591
  o.kind = "label";
572
- saveTo(used, name, o);
592
+ saveTo(labelused, name, o);
573
593
  break;
574
594
 
575
595
  case STRAP:
@@ -663,7 +683,7 @@ var createScoped = function (parsed, wash) {
663
683
  if (o.next && o.next.type === STAMP && o.next.text === "=>") {
664
684
  isArrow = true;
665
685
  isScope = true;
666
- if (o.prev && o.prev.text === 'async') {
686
+ if (o.prev?.type === STRAP && o.prev.text === 'async') {
667
687
  isAsync = true;
668
688
  }
669
689
  }
@@ -801,6 +821,7 @@ var createScoped = function (parsed, wash) {
801
821
  }
802
822
  else if (isArrow) {
803
823
  var next = skipAssignment(o);
824
+ scoped.arraw = o;
804
825
  var u = o;
805
826
  while (o !== next) {
806
827
  var n = run(o, 0);
@@ -1047,6 +1068,7 @@ var saveTo = function (used, k, o) {
1047
1068
  k = uncode(k);
1048
1069
  if (!(used[k] instanceof Array)) used[k] = [];
1049
1070
  used[k].push(o);
1071
+ o.tack = k;
1050
1072
  };
1051
1073
 
1052
1074
  var mergeTo = function (used, used0) {
@@ -1114,6 +1136,27 @@ var relink = function (list) {
1114
1136
  list.last = p;
1115
1137
  return list;
1116
1138
  };
1139
+ var rehead = function (list) {
1140
+ for (var cx = 0, dx = list.length; cx < dx; cx++) {
1141
+ var o = list[cx];
1142
+ if (o.type & (COMMENT | SPACE)) {
1143
+ o.prev = null;
1144
+ continue;
1145
+ }
1146
+ list.first = o;
1147
+ break;
1148
+ }
1149
+ for (var cx = list.length - 1; cx >= 0; cx--) {
1150
+ var o = list[cx];
1151
+ if (o.type & (COMMENT | SPACE)) {
1152
+ o.last = null;
1153
+ continue;
1154
+ }
1155
+ list.last = o;
1156
+ break;
1157
+ }
1158
+ return list;
1159
+ }
1117
1160
  var setqueue = function (list, queue = list) {
1118
1161
  /**
1119
1162
  * @type {PropertyDescriptor}
@@ -1219,6 +1262,9 @@ var createString = function (parsed) {
1219
1262
  }
1220
1263
  }
1221
1264
  intag = 0;
1265
+ if (o.short && attributes.length > 0 && !(lasttype & (SPACE | QUOTED))) {
1266
+ if (!/[\s'"]$/.test(result[result.length - 1])) result.push(' ');
1267
+ }
1222
1268
  }
1223
1269
  if (o.closed) {
1224
1270
  if (!o.short) {
@@ -1521,6 +1567,25 @@ var pickSentence = function (o) {
1521
1567
  } while (h !== e);
1522
1568
  return res;
1523
1569
  };
1570
+ var pickExpress = function (o) {
1571
+ o = snapExpressFoot(o);
1572
+ var e = snapExpressFoot(o);
1573
+ var os = [];
1574
+ do {
1575
+ os.push(o);
1576
+ }
1577
+ while (o && o !== e);
1578
+ return os;
1579
+ };
1580
+ var pickAssignment = function (n) {
1581
+ var e = skipAssignment(n);
1582
+ var values = [];
1583
+ while (n && n !== e) {
1584
+ values.push(n);
1585
+ n = n.next;
1586
+ }
1587
+ return values;
1588
+ }
1524
1589
  var insertBefore = function () {
1525
1590
  var [o] = arguments;
1526
1591
  var queue = this || o.queue;
@@ -1565,12 +1630,57 @@ var unshort = function (o, text) {
1565
1630
  o.type = EXPRESS;
1566
1631
  delete o.short;
1567
1632
  };
1633
+ var getFuncBody = function (o) {
1634
+ var q = o.queue;
1635
+ while (q && !(q.scoped?.isfunc)) q = q.queue;
1636
+ return q;
1637
+ };
1568
1638
  var getBodyWith = function (o, k) {
1569
1639
  var q = o.queue;
1570
1640
  while (q && (!q.scoped || !q.scoped.caps[k])) q = q.queue;
1571
1641
  return q;
1572
1642
  };
1573
1643
 
1644
+
1645
+ var createSeeker = function (o) {
1646
+ var os = pickExpress(o);
1647
+ var ids = [];
1648
+ for (var o of os) {
1649
+ if (o.type === SCOPED) {
1650
+ if (o.entry !== '[') break;
1651
+ var t = o.last;
1652
+ if (!t) throw new Error(i18n`格式错误`);
1653
+ if (t.type === QUOTED) {
1654
+ if (!t.length) {
1655
+ if (/\.|^#/.test(t.text)) {
1656
+ ids.push(`[${t.text}]`);
1657
+ }
1658
+ else {
1659
+ ids.push(strings.decode(t.text));
1660
+ }
1661
+ }
1662
+ else {
1663
+ ids.push("...");
1664
+ break;
1665
+ }
1666
+ }
1667
+ }
1668
+ else if (o.type === EXPRESS) {
1669
+ var t = o.text.replace(/^\.\.\./, "").replace(/^[^\.\[]+/, '');
1670
+ t.replace(/[^\.\[]+|\[[\s\S]*?\]/g, function (m) {
1671
+ if (/^\[/.test(m)) {
1672
+ ids.push(strings.decode(m.slice(1, -1)));
1673
+ }
1674
+ else {
1675
+ ids.push(m);
1676
+ }
1677
+ })
1678
+ }
1679
+
1680
+ }
1681
+ return ids;
1682
+ };
1683
+
1574
1684
  var patchArrawScope = function (arraw, origin) {
1575
1685
  var s1 = createScoped(arraw);
1576
1686
  if (s1.caps.this) {
@@ -1604,6 +1714,7 @@ module.exports = {
1604
1714
  skipAssignment,
1605
1715
  getDeclared,
1606
1716
  getBodyWith,
1717
+ getFuncBody,
1607
1718
  patchArrawScope,
1608
1719
  remove,
1609
1720
  createString,
@@ -1612,6 +1723,8 @@ module.exports = {
1612
1723
  snapSentenceHead,
1613
1724
  pickArgument,
1614
1725
  pickSentence,
1726
+ pickExpress,
1727
+ pickAssignment,
1615
1728
  snapExpressHead,
1616
1729
  snapExpressFoot,
1617
1730
  skipSentenceQueue,
@@ -1620,6 +1733,8 @@ module.exports = {
1620
1733
  isEval,
1621
1734
  rename,
1622
1735
  relink,
1736
+ rehead,
1737
+ createSeeker,
1623
1738
  setqueue,
1624
1739
  replace,
1625
1740
  canbeTemp,
@@ -1,7 +1,7 @@
1
1
  var scanner2 = require("./scanner2");
2
2
  var strings = require("../basic/strings");
3
3
  var Program = scanner2.Program;
4
- var { STAMP, SCOPED, STRAP, EXPRESS, COMMENT, SPACE, PROPERTY, VALUE, LABEL, QUOTED, snapExpressFoot, isEval, canbeTemp, rename, isHalfSentence, skipFunction, getDeclared, skipAssignment, skipSentenceQueue, createScoped, createString, splice, relink, snapExpressHead, needBreakBetween } = require("./common");
4
+ var { STAMP, SCOPED, STRAP, EXPRESS, pickAssignment, COMMENT, SPACE, PROPERTY, VALUE, LABEL, QUOTED, snapExpressFoot, isEval, canbeTemp, rename, isHalfSentence, skipFunction, getDeclared, skipAssignment, skipSentenceQueue, createScoped, createString, splice, relink, snapExpressHead, needBreakBetween } = require("./common");
5
5
  var splice2 = function (q, from, to, ...a) {
6
6
  var cx = q.indexOf(from);
7
7
  if (cx < 0) throw console.log(splice2.caller, console.format(`\r\n<red2>${i18n`自`}</red2>`), from && createString([from]), console.format(`\r\n<yellow>${i18n`至`}</yellow>`), to && createString([to]), console.format(`\r\n<cyan>${i18n`码列`}</cyan>`), createString(q)), i18n`结构异常`;
@@ -1721,13 +1721,19 @@ var down = function (scoped) {
1721
1721
  fordeep = saveddeep;
1722
1722
  };
1723
1723
  if (scoped.isfunc) {
1724
- if (!scoped.body && scoped.head) scoped.body = scoped.head.next;
1724
+ if (!scoped.body && scoped.head?.next?.type === SCOPED && scoped.head.next.entry === "{") 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(";") + ";");
1728
1728
  if (scoped.body) scoped.body.keeplet = false, _killobj(_getname, scoped.body);
1729
-
1730
1729
  scoped.forEach(kill);
1730
+ var requeue = null, requeuei = -1, requeuee = -1;
1731
+ if (!scoped.body && scoped.arraw) {
1732
+ requeue = scoped.arraw.queue;
1733
+ requeuei = requeue.indexOf(scoped.arraw);
1734
+ scoped.body = pickAssignment(scoped.arraw);
1735
+ requeuee = requeue.indexOf(scoped.body[scoped.body.length - 1], requeuei) + 1;
1736
+ }
1731
1737
  if (funcMark) {
1732
1738
  var argname = _letname("_");
1733
1739
  unstruct.debug = downLevel.debug;
@@ -1761,6 +1767,8 @@ var down = function (scoped) {
1761
1767
  if (argsmap) vars1 = vars1.filter(k => !(k in argsmap));
1762
1768
  if (vars1.length && scoped.body) scoped.body.push(...scanner2(`\r\nvar ${vars1}`));
1763
1769
  if (scoped.body) relink(scoped.body);
1770
+
1771
+ if (requeuei >= 0) splice(requeue, requeuei, requeuee - requeuei, ...scoped.body);
1764
1772
  }
1765
1773
  else {
1766
1774
  kill(scoped);
@@ -85,7 +85,7 @@ assert(downLevel(`class a { static{ a.a=1}}`), "function a() {}; (function () {
85
85
  assert(downLevel(`if(a) a = 1; class a {}`), "if (a) a = 1; function a() {}")
86
86
  assert(downLevel(`async function(){if(a) a = 1; class a {}}`), `function () { return async_(
87
87
  function () {
88
- a = function a() {}; if (!a) return [1, 0]; a = 1; return [1, 0]
88
+ a = function () {}; if (!a) return [1, 0]; a = 1; return [1, 0]
89
89
  })
90
90
  var a, _0 }`)
91
91
  assert(downLevel(`if(a) class b{ c(){}};`), `if (a) var b = function (b) { b["prototype"].c = function () {}\r\nreturn b }(function b() {});`)
@@ -424,3 +424,11 @@ function (_) {
424
424
  _0 = _; _0 = _0.a; a = _0
425
425
  })
426
426
  var a, _0`)
427
+
428
+ assert(downLevel(`async a=>await a`), `function (a) { return return async_(
429
+ function () {
430
+ _0 = a; return [_0, 1]
431
+ })
432
+ var a, _0 }`)
433
+
434
+ assert(downLevel(`function(a=b=>b,c){c}`), 'function (a, c) { if (a === undefined) a = function (b) { return b }; c }')
@@ -0,0 +1,38 @@
1
+ var { COMMENT, SPACE, STRAP, EXPRESS, STAMP, skipAssignment, isHalfSentence, splice } = common;
2
+ // 将当前代码队列中的function及class声明提前
3
+ var prefunc = function (sbody) {
4
+ var fx = 0;
5
+ for (var cx = 0, dx = sbody.length; cx < dx; cx++) {
6
+ var o = sbody[cx];
7
+ var bx = cx;
8
+ while (o && o.type & (SPACE | COMMENT)) o = sbody[++cx];
9
+ if (!o) break;
10
+ if (o.type === STRAP && /^(async|function|class)$/.test(o.text)) {
11
+ if (!o.isExpress) {
12
+ var ex = skipAssignment(sbody, cx);
13
+ var fname = '';
14
+ o = o.next;
15
+ while (o.type & (STRAP | STAMP)) o = o.next;
16
+ if (o.type === EXPRESS) fname = o.text;
17
+ if (fname) {
18
+ var ni = sbody.indexOf(o, cx);
19
+ splice(sbody, ni, 1);
20
+ if (isHalfSentence(sbody, cx - 1)) {
21
+ splice(sbody, cx, 0, o, { type: STAMP, text: "=" });
22
+ ex++;
23
+ dx++;
24
+ }
25
+ else {
26
+ var sb = splice(sbody, bx, ex - bx);
27
+ splice(sbody, fx, 0, { type: SPACE, text: "\r\n" }, o, { type: STAMP, text: "=" }, ...sb);
28
+ fx += ex - bx + 2;
29
+ ex += 2;
30
+ dx += 2;
31
+ }
32
+ }
33
+ cx = ex;
34
+ continue;
35
+ }
36
+ }
37
+ }
38
+ };
@@ -110,7 +110,7 @@ function translate([imap, supports], code) {
110
110
 
111
111
  var imp = imap[tt];
112
112
  if (!imp) {
113
- if (warn !== false && !warningMap[tt]) warningMap[tt] = true, console.warn(`<yellow>${i18n`翻译缺失:`}</yellow>${tt}`);
113
+ if (warn !== false && !/^\s*$/.test(tt) && !warningMap[tt]) warningMap[tt] = true, console.warn(`<yellow>${i18n`翻译缺失:`}</yellow>${tt}`);
114
114
  imp = imap[tt] = supports.map(_ => tt);
115
115
  }
116
116
  if (nodup && imp.length <= 1) nodup = false;
@@ -158,7 +158,7 @@ function translate([imap, supports], code) {
158
158
  if (a in t) v = t[a];
159
159
  else v = scanner2(JSON.stringify(v));
160
160
  }
161
- else if (k === 'name') v = ctn('i18n' + getm(v, t.nodup, t.warn), t);
161
+ else if (/^(name|holder|comment)$/.test(k)) v = ctn('i18n' + getm(v, t.nodup, t.warn), t);
162
162
  else v = scanner2(JSON.stringify(v));
163
163
  o.push({ type: PROPERTY, isprop: true, text: JSON.stringify(k) }, { type: STAMP, text: ':' }, ...v, { type: STAMP, text: ',' });
164
164
  })
@@ -1,4 +1,4 @@
1
- var { SPACE, COMMENT, EXPRESS, STRAP, QUOTED, STAMP, SCOPED, VALUE, LABEL, canbeTemp: _canbeTemp, isEval, createString, skipAssignment, pickSentence, skipSentenceQueue, isHalfSentence, splice, relink, createExpressList, snapExpressHead, snapExpressFoot } = require("./common");
1
+ var { SPACE, COMMENT, EXPRESS, STRAP, QUOTED, STAMP, SCOPED, VALUE, LABEL, canbeTemp: _canbeTemp, isEval, createString, skipAssignment, pickSentence, skipSentenceQueue, splice, relink, createExpressList, snapExpressHead, snapExpressFoot } = require("./common");
2
2
  var scanner2 = require("./scanner2");
3
3
  var returnText = function () { return this.text };
4
4
  var NodeNotClone = o => Object.assign(Object.create(null), o, { toString: returnText });
@@ -889,38 +889,6 @@ var ternary = function (body, getname, ret) {
889
889
  }
890
890
  return explist;
891
891
  };
892
- var prefunc = function (sbody) {
893
- var fx = 0;
894
- for (var cx = 0, dx = sbody.length; cx < dx; cx++) {
895
- var o = sbody[cx];
896
- var bx = cx;
897
- while (o && o.type & (SPACE | COMMENT)) o = sbody[++cx];
898
- if (!o) break;
899
- if (o.type === STRAP && /^(async|function|class)$/.test(o.text)) {
900
- if (!o.isExpress) {
901
- var ex = skipAssignment(sbody, cx);
902
- var fname = '';
903
- o = o.next;
904
- while (o.type & (STRAP | STAMP)) o = o.next;
905
- if (o.type === EXPRESS) fname = o.text;
906
- if (fname) {
907
- if (isHalfSentence(sbody, cx - 1)) {
908
- splice(sbody, cx, 0, { type: EXPRESS, text: fname }, { type: STAMP, text: "=" });
909
- }
910
- else {
911
- var sb = splice(sbody, bx, ex - bx);
912
- splice(sbody, fx, 0, { type: EXPRESS, text: fname }, { type: STAMP, text: "=" }, ...sb);
913
- fx += ex - bx + 2;
914
- }
915
- ex += 2;
916
- dx += 2;
917
- }
918
- cx = ex;
919
- continue;
920
- }
921
- }
922
- }
923
- };
924
892
 
925
893
  var isFunctionOnly = function (body) {
926
894
  for (var cx = 2, dx = body.length; cx < dx; cx++) {
@@ -91,14 +91,14 @@ test("try{a=2+1}catch(e){}", 'return [1, 7];\r\n a = 2 + 1; return [0, 9];\r\n r
91
91
  test("try{a=2+1}catch(e){a=3}", 'return [65537, 7];\r\n a = 2 + 1; return [0, 9];\r\n e = @; a = 3; return [0, 9];\r\n return [1, 9]', true);
92
92
  test("(function(){})", '_ = function () {}; _', true);
93
93
  test("(1+2*function(){}())", '_ = 2 * function () {}(), _ = 1 + _; _', true);
94
- test("function a(){}", 'a = function a() {}', true);
95
- test("if(1) function a(){}", 'if (false) return [1, 0]; a = function a() {}; return [1, 0]', true);
96
- test("if(1) {function a(){}}", 'if (false) return [1, 0]; a = function a() {}; return [1, 0]', true);
97
- test("if(a) a = 1;function a(){}", "a = function a() {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
98
- test("if(a) a = 1;async function a(){}", "a = async function a() {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
99
- test("if(a) a = 1;async function* a(){}", "a = async function* a() {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
100
- test("if(a) a = 1;class a{}", "a = class a{}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
101
- test("if(a) a = 1;function* a(){}", "a = function* a() {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
94
+ test("function a(){}", 'a = function () {}', true);
95
+ test("if(1) function a(){}", 'if (false) return [1, 0]; a = function () {}; return [1, 0]', true);
96
+ test("if(1) {function a(){}}", 'if (false) return [1, 0]; a = function () {}; return [1, 0]', true);
97
+ test("if(a) a = 1;function a(){}", "a = function () {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
98
+ test("if(a) a = 1;async function a(){}", "a = async function () {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
99
+ test("if(a) a = 1;async function* a(){}", "a = async function* () {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
100
+ test("if(a) a = 1;class a{}", "a = class {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
101
+ test("if(a) a = 1;function* a(){}", "a = function* () {}; if (!a) return [1, 0]; a = 1; return [1, 0]", true);
102
102
  test("await new Promise(function(){})", '_ = function () {}; _ = new Promise(_); return [_, 1]', true);
103
103
  test(`onerror({ status: xhr.status, response: "Cookie解析异常!", toString: toResponse })`, '_ = { status: xhr.status, response: "Cookie解析异常!", toString: toResponse }; onerror(_)', true);
104
104
  test(`if (!/^https\\:\\/\\/|^s\\/\\//.test(url)) console.warn("请使用https访问如下路径:" + url)`, '_ = /^https\\:\\/\\/|^s\\/\\//.test(url); if (_) return [1, 0]; _ = "请使用https访问如下路径:" + url; _ = console.warn(_); return [1, 0]', true);
@@ -324,6 +324,7 @@ var acme2 = new class {
324
324
  }
325
325
  async auditOrder(o, setauth) {
326
326
  if (o.status !== 'pending') return o;
327
+ var bs = [];
327
328
  a: for (var a of o.authorizations) {
328
329
  var b = await data.fromURL(a);
329
330
  if (b.challenges) {
@@ -335,9 +336,12 @@ var acme2 = new class {
335
336
  continue a;
336
337
  }
337
338
  }
339
+ bs.push(c);
338
340
  }
339
341
  }
340
- o = await this.waitStatus(o);
342
+ if (bs.length === 0) {
343
+ o = await this.waitStatus(o);
344
+ }
341
345
  return o;
342
346
  }
343
347
  async finalizeOrder(o, upload) {
@@ -83,6 +83,9 @@ function alert() {
83
83
  }
84
84
  if (close_timer) clearTimeout(close_timer);
85
85
  });
86
+ on('removed')(elem, function () {
87
+ if (!container.children.length) remove(container);
88
+ });
86
89
  onremove(elem, _onclose);
87
90
  var close_timer;
88
91
  elem.setText = function () {
@@ -1,3 +1,3 @@
1
- 加载中..
1
+ ${i18n`加载中..`}
2
2
  <div class="loader">
3
3
  </div>
@@ -31,6 +31,7 @@ function remove(node, transition) {
31
31
  if (node.with) {
32
32
  remove(node.with, transition);
33
33
  }
34
+ dispatch(node, createEvent('removed'));
34
35
  }
35
36
  }
36
37
  }
@@ -12,7 +12,6 @@ var sessionInitHash = sessionStorage.getItem(sessionSavedHashKey);
12
12
  var hostoryStorage = sessionStorage;
13
13
  var pagehash_reg = /#([\/\w\:@\.\_\(\)\+\-\*\$@!~_'\?,&~%]+)$/;
14
14
  var locationInitHash = location.hash;
15
- var hashchangecount = 0;
16
15
  var isFirstTimeLoad = sessionInitHash === null;
17
16
  var isSimpleRefresh = sessionInitHash === locationInitHash;
18
17
  var isWithHashLoad = !!location.hash;
@@ -25,10 +24,8 @@ if (isWithHashLoad && !isSimpleRefresh) {
25
24
 
26
25
  if (/MSIE\s*[2-7]/.test(navigator.userAgent)) {
27
26
  window.onhistorychange = function (url) {
28
- hashchangecount++;
29
27
  // 如果是返回事件,一定不是第一次改变hash
30
28
  // 这里刚好可以屏蔽首次手动改变url可能产生的hashchange事件
31
- if (hashchangecount < 2) return;
32
29
  if (preventNextHashChange) return preventNextHashChange = false, window_history.go(-1);
33
30
  if (preventNextHashChange === void 0 ? onback && onback() === true : preventNextHashChange = void 0) { }
34
31
  };
@@ -48,7 +45,6 @@ if (/MSIE\s*[2-7]/.test(navigator.userAgent)) {
48
45
  backman();
49
46
  } else {
50
47
  onhashchange(window, function (event) {
51
- hashchangecount++;
52
48
  // 如果是返回事件,一定不是第一次改变hash
53
49
  // 这里刚好可以屏蔽首次手动改变url可能产生的hashchange事件
54
50
  var targetHash = location.hash;
@@ -550,6 +546,7 @@ var checkonback = function (elements) {
550
546
  var onback = element && element.onback;
551
547
  if (isFunction(onback)) {
552
548
  onback = element.onback();
549
+ if (onback === false) console.info(i18n`onback中阻止跳转的功能在新老版本的chrome上及其他不同浏览器上的表现均不一致,建议更换实现方式!`);
553
550
  }
554
551
  if (onback === false || isString(onback)) {
555
552
  break;
@@ -46,6 +46,7 @@
46
46
  width: 100%;
47
47
  height: 36px;
48
48
  }
49
+
49
50
  &:last-child {
50
51
  float: left;
51
52
  }
@@ -467,14 +468,7 @@
467
468
  detailWindow.initialStyle = "margin-left:-100px;opacity:0";
468
469
  render(detailWindow, detailScope);
469
470
  on("remove")(detailWindow, function () {
470
- var count = 0;
471
- var fanyi = detailScope.fanyi;
472
- for (var s of supports) {
473
- if (fanyi[s.id] && fanyi[s.id].trim()) count++;
474
- }
475
- if (detailScope.item) {
476
- detailScope.item.liang = count;
477
- }
471
+ 更新翻译数();
478
472
  if (activedRow) {
479
473
  removeClass(activedRow, "actived");
480
474
  activedRow = null;
@@ -484,8 +478,19 @@
484
478
 
485
479
  }
486
480
  }
481
+ var 更新翻译数 = function () {
482
+ var count = 0;
483
+ var fanyi = detailScope.fanyi;
484
+ if (fanyi) for (var s of supports) {
485
+ if (fanyi[s.id] && fanyi[s.id].trim()) count++;
486
+ }
487
+ if (detailScope.item) {
488
+ detailScope.item.liang = count;
489
+ }
490
+ };
487
491
  var showDetail = function (event) {
488
492
  initDetailWindow();
493
+ 更新翻译数();
489
494
  var tr = getTargetIn(tableElement.children[1], event.active, false);
490
495
  var item = detailScope.item = event.item;
491
496
  if (activedRow !== tr) {
@@ -558,6 +563,7 @@
558
563
  var textMap = Object.create(null);
559
564
  已找到的字符串.is_loading = true;
560
565
  var addTranslate = function (translate) {
566
+ if (!isHandled(translate)) return;
561
567
  var tmap = textMap[translate];
562
568
  if (!tmap) tmap = textMap[translate] = Object.create(null), tmap["#count"] = 0;
563
569
  if (!tmap[e.path]) tmap[e.path] = [];
@@ -573,7 +579,11 @@
573
579
  addTranslate(t.translate);
574
580
  }
575
581
  else if (t.transtype === compile$translate.字段名) {
576
- t.fields.forEach(f => addTranslate(f.name));
582
+ t.fields.forEach(f => {
583
+ addTranslate(f.name);
584
+ addTranslate(f.holder);
585
+ addTranslate(f.comment);
586
+ });
577
587
  }
578
588
  }
579
589
  }