efront 4.15.2 → 4.16.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.
@@ -32,7 +32,7 @@ var skipAssignment = function (o, cx) {
32
32
  var ox = cx;
33
33
  o = body[ox];
34
34
  while (o && o.type & (SPACE | COMMENT)) o = body[++ox];
35
- cx = ox + 1;
35
+ cx = ox;
36
36
  }
37
37
  else if (o.type & (SPACE | COMMENT)) o = o.next;
38
38
  var needpunc = false;
@@ -558,7 +558,7 @@ var createScoped = function (parsed, wash) {
558
558
  var function_obj = null;
559
559
  if (o.type === STAMP && equal_reg.test(o.text)) {
560
560
  var p = snapExpressHead(o.prev);
561
- if (!p || p.type & (STRAP | STAMP) || !p.isExpress) {
561
+ if (!p || p.type & (STRAP | STAMP) || p.type !== EXPRESS && !p.isExpress) {
562
562
  let n = o.next;
563
563
  if (n && n.type & (EXPRESS | VALUE)) {
564
564
  n.equal = o;
@@ -586,6 +586,14 @@ var createScoped = function (parsed, wash) {
586
586
  break;
587
587
  case PROPERTY:
588
588
  if (!o.short) break;
589
+ switch (o.text) {
590
+ case "yield":
591
+ scoped.yield = false;
592
+ break;
593
+ case "await":
594
+ scoped.await = false;
595
+ break;
596
+ }
589
597
  case VALUE:
590
598
  if (o.isdigit || /^(null|false|true)$/.test(o.text)) break;
591
599
  case EXPRESS:
@@ -651,7 +659,12 @@ var createScoped = function (parsed, wash) {
651
659
  funcbody.return.push(o);
652
660
  break;
653
661
  case "await":
654
- funcbody.async = funcbody.await = true;
662
+ funcbody.await = true;
663
+ if (!funcbody.async) saveTo(used, 'await', o);
664
+ break;
665
+ case "yield":
666
+ funcbody.yield = true;
667
+ if (!funcbody.aster) saveTo(used, 'yield', o);
655
668
  break;
656
669
  case "as":
657
670
  case "from":
@@ -776,7 +789,7 @@ var createScoped = function (parsed, wash) {
776
789
  lets = vars;
777
790
  if (isFunction) {
778
791
  vars.this = true, vars.arguments = true;
779
- scoped.yield = scoped.aster = isAster;
792
+ scoped.aster = isAster;
780
793
  thisscope = scoped;
781
794
  argscope = scoped;
782
795
  }
@@ -797,7 +810,7 @@ var createScoped = function (parsed, wash) {
797
810
  }
798
811
  }
799
812
  if (isArrow);
800
- else while (o && o.isExpress && o.type !== SCOPED) {
813
+ else while (o && (o.type !== SCOPED || o.entry === '[')) {
801
814
  o = o.next;
802
815
  if (o && o.type === EXPRESS) {
803
816
  saveTo(used, o.text, o);
@@ -806,7 +819,6 @@ var createScoped = function (parsed, wash) {
806
819
  o.kind = isFunction ? 'function' : 'class';
807
820
  o = o.next;
808
821
  }
809
- if (isFunction) break;
810
822
  }
811
823
  if (!isFunction) while (o.type !== SCOPED) {
812
824
  // if (o.next && o.next.type === STAMP && o.next.text === "=>") break;
@@ -959,23 +971,55 @@ var createScoped = function (parsed, wash) {
959
971
  }
960
972
  if (vars.yield) scoped.yield = false;
961
973
  if (vars.await) scoped.await = false;
962
- if (scoped.yield !== false && envs.yield) {
974
+ y: if (scoped.yield !== false && envs.yield) {
975
+ for (var s of scoped) if (s.isfunc && s.envs.yield) break y;
976
+ for (var s of used.yield) if (s.kind || s.isprop || hasEqual(s)) break y;
963
977
  used.yield.forEach(o => o.type = STRAP);
964
978
  scoped.yield = scoped.aster = true;
965
979
  delete envs.yield;
966
980
  delete used.yield;
967
981
  }
968
- if (scoped.await !== false && envs.await) {
982
+ a: if (scoped.await !== false && envs.await) {
983
+ for (var s of scoped) if (s.isfunc && s.envs.await) break a;
984
+ for (var s of used.await) if (s.kind || s.isprop || hasEqual(s)) break a;
969
985
  used.await.forEach(o => o.type = STRAP);
970
986
  scoped.await = scoped.async = true;
971
987
  delete envs.await;
972
988
  delete used.await;
973
989
  }
990
+ if (used.yield) {
991
+ used.yield.forEach(o => { if (o.type === STRAP) o.type = EXPRESS });
992
+ }
993
+ if (used.await) {
994
+ used.await.forEach(o => { if (o.type === STRAP) o.type = EXPRESS });
995
+ }
974
996
  delete envs.eval;
975
997
  delete envs.new;
976
998
  scoped.envs = envs;
977
999
  return scoped;
978
1000
  };
1001
+ var hasEqual = function (s) {
1002
+ while (s) {
1003
+ if (s.equal) return true;
1004
+ var sn = s.next;
1005
+ if (sn?.type === STRAP) {
1006
+ if (sn.text === 'of') return true;
1007
+ if (sn.text === "in") {
1008
+ var q = s.queue;
1009
+ if (q.entry === '(') {
1010
+ var qp = q.prev;
1011
+ if (qp.type === STRAP && qp.text === 'await') qp = qp.text;
1012
+ if (qp.type === STRAP && qp.text === 'for') return true;
1013
+ }
1014
+ }
1015
+ }
1016
+ var sp = s.prev;
1017
+ if (sp?.type === STRAP && sp.text === 'as') return true;
1018
+ s = s.queue;
1019
+ }
1020
+ return false;
1021
+ };
1022
+
979
1023
  var getDeclared = function (o, kind, queue) {
980
1024
  var declared = [], used = Object.create(null); var skiped = [];
981
1025
  var prop = null;
@@ -1007,18 +1051,31 @@ var getDeclared = function (o, kind, queue) {
1007
1051
  }
1008
1052
  switch (o.type) {
1009
1053
  case SCOPED:
1010
- if (snapExpressFoot(o) === o) {
1054
+ var foot = snapExpressFoot(o);
1055
+ if (!prop) prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
1056
+ if (foot === o) {
1011
1057
  var [d, u, _, s] = getDeclared(o.first, kind, o);
1012
1058
  while (s.length) skiped.push.apply(skiped, s.splice(0, 1024));
1013
1059
  mergeTo(used, u);
1014
1060
  if (d.length || d.attributes.length) declared.push(d);
1015
- if (!prop) prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
1016
1061
  d.entry = o.entry;
1017
1062
  o.kind = kind;
1018
1063
  attributes.push([prop, d]);
1019
1064
  o = o.next;
1020
1065
  break;
1021
1066
  }
1067
+ else {
1068
+ var s = [];
1069
+ while (foot !== o) {
1070
+ s.push(o);
1071
+ o = o.next;
1072
+ }
1073
+ s.push(foot);
1074
+ skiped.push(...s);
1075
+ o = o.next;
1076
+ attributes.push([prop, s]);
1077
+ break;
1078
+ }
1022
1079
  case STAMP:
1023
1080
  var next = o.next;
1024
1081
  if (o.text === "*" && next) {
@@ -1044,11 +1101,12 @@ var getDeclared = function (o, kind, queue) {
1044
1101
  case EXPRESS:
1045
1102
  case STRAP:
1046
1103
  case VALUE:
1047
- var isrest = /^\.\.\./.test(o.text);
1048
1104
  var n = o;
1049
1105
  var k = o.text;
1050
- if (isrest) declared.push(k = k.slice(3))
1051
- else if (o.text) declared.push(k);
1106
+ var isrest = /^\.\.\./.test(k);
1107
+ if (isrest) k = k.slice(3);
1108
+ var isdec = !/[\.\[]/.test(k);
1109
+ if (k && isdec) declared.push(k);
1052
1110
  if (!isrest) {
1053
1111
  var prev = o.prev;
1054
1112
  if (prev?.type === STAMP && prev.text === '...') {
@@ -1078,7 +1136,7 @@ var getDeclared = function (o, kind, queue) {
1078
1136
  o = f.next;
1079
1137
  break;
1080
1138
  default:
1081
- console.log(createString(pickSentence(queue)));
1139
+ console.log(createString(pickSentence(queue)), o.text, o.type);
1082
1140
  throw new Error(i18n`代码结构异常`);
1083
1141
  }
1084
1142
  if (!o) break;
@@ -1094,7 +1152,7 @@ var getDeclared = function (o, kind, queue) {
1094
1152
  o.prev.equal = o;
1095
1153
  o = o.next;
1096
1154
  var o0 = skipAssignment(o);
1097
- if (isrest) throw i18n`余集变量不能有默认值`;
1155
+ if (isrest) throw new Error(i18n`余集变量不能有默认值`);
1098
1156
  attributes[attributes.length - 1].push(queue, o, o0);
1099
1157
  while (o !== o0) {
1100
1158
  skiped.push(o);
@@ -1274,30 +1332,28 @@ var createString = function (parsed) {
1274
1332
  // 每一次要远行,我都不得不对自己的物品去粗取精。取舍之间,什么重要,什么不是那么重要,都有了一道明显的分界线。
1275
1333
  if (uncomment) break;
1276
1334
  var tmp = o.text, opentmp = false;
1277
- if (helpcode) {
1278
- if (helpreg.test(tmp)) {
1279
- opentmp = true;
1280
- if (/^\/\*/.test(tmp)) opentmp = 2;
1281
- tmp = tmp.replace(helpreg, '');
1282
- cacheresult = [];
1283
- result = cacheresult;
1284
- result.push("/* [[ 开发辅助代码: */");
1285
- }
1286
- if (/--\!?\>\s*(?:\*\/)?$/.test(tmp) && result !== finalresult) {
1287
- if (!opentmp) tmp = tmp.replace(/^\/[\/\*]\s*/, '');
1288
- tmp = tmp.replace(/\s*--\!?\>\s*(?:\*\/)?$/, "");
1289
- if (tmp) {
1290
- result.push(tmp);
1291
- }
1292
- result.push("/* ]] */");
1293
- opentmp = true;
1294
- if (helpcode && cacheresult) finalresult = finalresult.concat(cacheresult), cacheresult = [];
1295
- result = finalresult;
1296
- }
1297
- else if (opentmp) {
1298
- if (opentmp === 2) tmp = tmp.replace(/\s*\*\/$/, '');
1299
- if (tmp) result.push("\r\n", tmp);
1335
+ if (helpreg.test(tmp)) {
1336
+ opentmp = true;
1337
+ if (/^\/\*/.test(tmp)) opentmp = 2;
1338
+ tmp = tmp.replace(helpreg, '');
1339
+ cacheresult = [];
1340
+ result = cacheresult;
1341
+ result.push("/* [[ 开发辅助代码: */");
1342
+ }
1343
+ if (/--\!?\>\s*(?:\*\/)?$/.test(tmp) && result !== finalresult) {
1344
+ if (!opentmp) tmp = tmp.replace(/^\/[\/\*]\s*/, '');
1345
+ tmp = tmp.replace(/\s*--\!?\>\s*(?:\*\/)?$/, "");
1346
+ if (tmp) {
1347
+ result.push(tmp);
1300
1348
  }
1349
+ result.push("/* ]] */");
1350
+ opentmp = true;
1351
+ if (helpcode && cacheresult) finalresult = finalresult.concat(cacheresult), cacheresult = [];
1352
+ result = finalresult;
1353
+ }
1354
+ else if (opentmp) {
1355
+ if (opentmp === 2) tmp = tmp.replace(/\s*\*\/$/, '');
1356
+ if (tmp) result.push("\r\n", tmp);
1301
1357
  }
1302
1358
  if (keepspace && !opentmp) {
1303
1359
  if (patchspace && lasttype !== SPACE && lasttype !== EXPRESS) result.push(" ");
@@ -42,6 +42,16 @@ var unslice = function (arr) {
42
42
  }
43
43
  };
44
44
  };
45
+ var patchCurve = function (b) {
46
+ if (b.length > 1) {
47
+ var b0 = b[0];
48
+ if (b0.brace) {
49
+ b[0] = scanner2(`()`)[0];
50
+ b[0].push(b0);
51
+ relink(b[0]);
52
+ }
53
+ }
54
+ }
45
55
  // 解构赋值
46
56
  var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
47
57
  var tmpname = '';
@@ -52,11 +62,11 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
52
62
  var [k, v] = d;
53
63
  var dp = 0;
54
64
  if (typeof k === 'number' && k < 0) {
55
- if (iter) throw i18n`暂不支持在当前语境读取尾部非剩余元素`;
65
+ if (iter) throw new Error(i18n`暂不支持在当前语境读取尾部非剩余元素`);
56
66
  dp = 1;
57
67
  k = `${tmpname}["length"]>${doged - k - 1}?${tmpname}[${tmpname}["length"] - ${-k}]:undefined`;
58
68
  } else {
59
- if (rootenvs.Symbol && /\[\d+\]/.test(k)) {
69
+ if (rootenvs.Symbol && /\[\d+\]/.test(k) && iter) {
60
70
  var inc = parseInt(k.slice(1, k.length - 1));
61
71
  inc++;
62
72
  while (iter.index < inc) iter.next();
@@ -235,8 +245,18 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
235
245
  return single(v, p);
236
246
  };
237
247
  if (_var && i < queue.length) splice(queue, i++, 0, { type: STRAP, text: _var });
248
+ var i0 = i;
238
249
  loop: while (i < queue.length) {
239
250
  var o = queue[i];
251
+ if (o.type === STAMP) {
252
+ switch (o.text) {
253
+ case ",":
254
+ i++;
255
+ continue;
256
+ case ";":
257
+ return i;
258
+ }
259
+ }
240
260
  var next = snapExpressFoot(o).next;
241
261
  tmpname = '';
242
262
  var index0 = index;
@@ -317,6 +337,7 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
317
337
  var a = single(d, '');
318
338
  if (a) {
319
339
  if (index > 0) splice(queue, i++, 0, { type: STAMP, text: ',' });
340
+ patchCurve(a[1]);
320
341
  var i2 = skipAssignment(queue, i);
321
342
  var restq = splice(queue, i, i2 - i, ...a[1], { type: STAMP, text: "=" });
322
343
  killobj(restq);
@@ -341,12 +362,12 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
341
362
  }
342
363
  splice(queue, i = i2, 0, ...q);
343
364
  i += q.length;
344
- index++;
345
365
  continue;
346
366
  }
347
367
  }
348
368
  tmpname = getobjname(0);
349
- splice(queue, i, 0, { type: EXPRESS, text: tmpname }, { type: STAMP, text: "=" });
369
+ if (i > i0) splice(queue, i++, 0, { type: STAMP, text: ',' }, { type: EXPRESS, text: tmpname }, { type: STAMP, text: "=" });
370
+ else splice(queue, i, 0, { type: EXPRESS, text: tmpname }, { type: STAMP, text: "=" });
350
371
  i += 2;
351
372
  var i2 = skipAssignment(queue, i);
352
373
  var n = queue[i2];
@@ -356,8 +377,10 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
356
377
  }
357
378
  for (var o0 of objs) {
358
379
  deep = 0;
359
- var [[d]] = getDeclared(o0);
360
- dog(d);
380
+ var dd = getDeclared(o0)[0];
381
+ var d = dd[0];
382
+ if (!d) dog(dd.attributes[0][1]);
383
+ else dog(d);
361
384
  }
362
385
  if (hasnext && index > index0) {
363
386
  splice(queue, i++, 0, { type: STAMP, text: ',' });
@@ -1322,7 +1345,7 @@ var killarg = function (head, body, _getname, setarg = true) {
1322
1345
  cname = '';
1323
1346
  collect = index + 1;
1324
1347
  }
1325
- else throw i18n`参数声明异常!`;
1348
+ else throw new Error(i18n`参数声明异常!`);
1326
1349
  if (o && o.type === STAMP) {
1327
1350
  if (o.text === ',') {
1328
1351
  o = o.next; continue;
@@ -338,18 +338,45 @@ var _0 };`);
338
338
  i++//异步或步进函数
339
339
  assert(downLevel(`function *(){yield *a}`), `function () { return aster_(
340
340
  function () {
341
- _; _0 = 0; return [1, 0]
341
+ return [9, 8]
342
342
  },
343
343
  function () {
344
- _3 = _0 < a["length"]; if (!_3) return [1, 0]; _ = a[_0]; _3 = true
344
+ _; _3 = Symbol["asyncIterator"]; _3 = a[_3]; if (_3) return [1, 0]; _3 = Symbol["iterator"]; _3 = a[_3]; if (_3) return [1, 0]; _3 = Array["prototype"]; _4 = Symbol["iterator"]; _3 = _3[_4]
345
345
  },
346
346
  function () {
347
- if (!_3) return [2, 0]; return [_, 3]
347
+ _1 = _3; _1 = _1["call"](a); _3 = _1["next"](); return [_3, 1]
348
+ },
349
+ function (_2) {
350
+ _3 = _2; _0 = _3; return [1, 0]
351
+ },
352
+ function () {
353
+ _3 = !_0["done"]; if (!_3) return [2, 0]; _3 = _0["value"]; return [_3, 1]
354
+ },
355
+ function (_2) {
356
+ _3 = _2; _ = _3; _3 = true
357
+ },
358
+ function () {
359
+ if (!_3) return [3, 0]; return [_, 3]
360
+ },
361
+ function () {
362
+ _3 = _1["next"](); return [_3, 1]
363
+ },
364
+ function (_2) {
365
+ _3 = _2; _0 = _3; return [-4, 0]
348
366
  },
349
367
  function () {
350
- _3 = _0++; return [-2, 0]
368
+ return [0, 9]
369
+ },
370
+ function () {
371
+ _3 = _0; if (!_3) return [1, 0]; _3 = !_0["done"]; if (!_3) return [1, 0]; _3 = _1["return"]; _3 = isFunction(_3)
372
+ },
373
+ function () {
374
+ if (!_3) return [1, 0]; _3 = _1["return"](); return [1, 0]
375
+ },
376
+ function () {
377
+ return [1, 9]
351
378
  })
352
- var _, _0, _1, _3 }`)
379
+ var _, _0, _1, _3, _4 }`)
353
380
  assert(downLevel(`async function(){}`), `function () { return async_() }`)
354
381
  assert(downLevel(`async function(){for(var a of b){Symbol}}`), `function () { return async_(
355
382
  function () {
@@ -424,7 +451,6 @@ function (_) {
424
451
  _0 = _; _0 = _0.a; a = _0
425
452
  })
426
453
  var a, _0`)
427
-
428
454
  assert(downLevel(`async a=>await a`), `function (a) { return return async_(
429
455
  function () {
430
456
  _0 = a; return [_0, 1]
@@ -437,10 +463,36 @@ _.set = function (v) {}, _))
437
463
  var _`);
438
464
  assert(downLevel(`var restq = splice(queue, i, i2 - i, ...a[1], { type: STAMP, text: "=" });`), `var slice_ = Array["prototype"]["slice"];
439
465
  var restq = splice["apply"](null, [queue, i, i2 - i]["concat"](slice_["call"](a[1]), [{ type: STAMP, text: "=" }]));`)
440
- var c = scanner2(`\r\n if (search.length) return null;\r\n return path.join(...pathlist);\r\n`);
441
- c.fix();
442
- c.break();
443
- assert(c.toString(), `\r\n if (search["length"]) return null;\r\n return path["join"](...pathlist);\r\n`)
466
+ var c = scanner2(`\r\n if (search.length) return null;\r\n return path.join(...pathlist);\r\n`); i++
467
+ c.fix(); i++
468
+ c.break(); i++
469
+ assert(c.toString(), `\r\n if (search["length"]) return null;\r\n return path["join"](...pathlist);\r\n`);
444
470
  assert(downLevel.code(c).toString(), `\r\n if (search["length"]) return null;\r\n return path["join"]["apply"](path, pathlist);\r\n`);
445
471
  downLevel.debug = true; i++;
446
472
  assert(downLevel(`Symbol;var c = (a.data || (a.data = {})).transition = no(this);`), 'Symbol; var c = (a.data || (a.data = {})).transition = no(this);', true);
473
+ assert(downLevel(`[a.b]=[1]`), 'a.b = [1][0]')
474
+ assert(downLevel(`[a[b]]=[1]`), 'a[b] = [1][0]')
475
+ assert(downLevel(`[(a)[b]]=[1]`), '(a)[b] = [1][0]')
476
+ assert(downLevel(`[[a][b]]=[1]`), '[a][b] = [1][0]')
477
+ assert(downLevel(`[a,{}.b,c]=[1]`), '_ = [1], a = _[0], {}.b = _[1], c = _[2]\r\nvar _')
478
+ assert(downLevel(`[{}.b,c]=[1]`), '_ = [1], {}.b = _[0], c = _[1]\r\nvar _')
479
+ assert(downLevel(`[{}.b]=[1]`), '({}).b = [1][0]')
480
+ assert(downLevel(`[[[a[b]]]]=[1]`), 'a[b] = [1][0][0][0]')
481
+ assert(downLevel(`[[[{}[b]]]]=[1]`), '({})[b] = [1][0][0][0]')
482
+ assert(downLevel(`[...a[b]]=[1]`), 'var slice_ = Array["prototype"]["slice"];\r\n_ = [1], a[b] = slice_["call"](_, 0)\r\nvar _')
483
+ assert(downLevel(`[a,...{length}]=[1]`), 'var slice_ = Array["prototype"]["slice"];\r\n_ = [1], a = _[0], _0 = slice_["call"](_, 1), length = _0.length\r\nvar _, _0')
484
+ assert(downLevel(`[...{length}]=[1]`), `var slice_ = Array["prototype"]["slice"];
485
+ _ = [1], _0 = slice_["call"](_, 0), length = _0.length
486
+ var _, _0`)
487
+ assert(downLevel(`[...{}[a]]=[1]`), `var slice_ = Array["prototype"]["slice"];
488
+ _ = [1], {}[a] = slice_["call"](_, 0)
489
+ var _`)
490
+ assert(downLevel(`,{...{}[a]}=[1]`), `_ = [1], {}[a] = rest_(_, [])
491
+ var _`)
492
+ assert(downLevel(`var res=null,res2=1,{...{}[a]}=[1]`), `var res = null, res2 = 1, _ = [1], {}[a] = rest_(_, [])
493
+ var _`);
494
+ assert(downLevel(`var res=null,{...{}[a]}=[1]`), `var res = null, _ = [1], {}[a] = rest_(_, [])
495
+ var _`)
496
+ assert(downLevel(`,{b,...{}[a]}=[1]`), `_ = [1], b = _.b, {}[a] = rest_(_, ["b"])
497
+ var _`)
498
+ assert(downLevel(`var penddings = {}, circle = [], module_keys = [];`), `var penddings = {}, circle = [], module_keys = [];`)
@@ -49,6 +49,7 @@ await async function () {
49
49
  aster_,
50
50
  async_,
51
51
  asyncAster_,
52
+ extends_,
52
53
  isFunction,
53
54
  restIter_,
54
55
  rest_,
@@ -59,6 +60,7 @@ await async function () {
59
60
  var ignore = [
60
61
  "dynamic-import",
61
62
  "intl402",
63
+ "identifiers",
62
64
  "built-ins",
63
65
  ];
64
66
  ignore.forEach(k => ignore[k] = true);
@@ -94,15 +96,17 @@ await async function () {
94
96
  * @type {vm.RunningCodeInNewContextOptions}
95
97
  */
96
98
  var ctxOptions = {
99
+ timeout: 1000,
97
100
  filename: f,
98
- displayErrors: false,
101
+ displayErrors: true,
99
102
  };
100
- running = true;
101
- if (code.envs.$DONE) harness.$DONE = function (e) {
102
- if (e) console.fail(ti, f + "\r\n"), console.log(currentText), console.trace(e), process.exit();
103
- };
104
- vm.runInThisContext(text, ctxOptions);
105
- running = false;
103
+ var sandbox = Object.create(null);
104
+ for (var k in code.envs) {
105
+ if (k in harness) sandbox[k] = harness[k];
106
+ }
107
+ var ctx = vm.createContext(sandbox);
108
+ var p = vm.runInContext(text, ctx, ctxOptions);
109
+ await Promise.race([p, wait(1000)]);
106
110
  };
107
111
  var ti = `${i}/${testFiles.length}`;
108
112
  var data = await fs.readFile(f);
@@ -119,23 +123,29 @@ await async function () {
119
123
  currentText = text;
120
124
  currentIndex = ti;
121
125
  if (text) {
126
+ running = true;
122
127
  try {
123
128
  console.test("执行", ti, f);
124
129
  await runText(text);
125
130
  } catch (e) { de = e };
131
+ running = false;
126
132
  }
127
133
  if (de) try {
134
+ running = true;
128
135
  try {
129
136
  console.test("检查", ti, f);
130
137
  await runText(data);
131
- } catch (e) { de = null };
138
+ } catch (e) {
139
+ if (typeof e === typeof de) de = null
140
+ };
141
+ running = false;
132
142
  } catch { de = null; }
133
143
  if (!text && de) {
134
144
  console.log(de)
135
145
  console.fail(ti, f);
136
146
  throw de;
137
147
  }
138
- console.pass(path.relative(testpath, f));
148
+ console.pass(ti, path.relative(testpath, f));
139
149
  }, 1, null);
140
150
  console.log(`\r\n完成 ${testFiles.length} 个测试项!`);
141
151
  }();
@@ -590,7 +590,7 @@ var _invoke = function (t, getname) {
590
590
  if (q0f?.type === STRAP && !q0f.transive) remove_end_comma(queue[queue.length - 1]);
591
591
  }
592
592
  var qe = q[q.length - 1];
593
- splice(o, by, ey - by, ...qe ? cloneNode(qe.name) : []);
593
+ splice(o, by, ey - by, ...qe?.name ? cloneNode(qe.name) : []);
594
594
  cy = by + 1;
595
595
  }
596
596
  else {
@@ -1206,7 +1206,6 @@ function toqueue(body, getname, ret = false, result = []) {
1206
1206
  else if (ei >= 0) break;
1207
1207
  _poplabel();
1208
1208
  }
1209
-
1210
1209
  if (o.type === LABEL) {
1211
1210
  o.scope = scopes[scopes.length - 1];
1212
1211
  o.final = body.indexOf(skipSentenceQueue(o.next), cx);
@@ -1231,6 +1230,10 @@ function toqueue(body, getname, ret = false, result = []) {
1231
1230
  if (/^(new|typeof|delete|await|void|debugger)$/.test(o.text)) {
1232
1231
  break a;
1233
1232
  }
1233
+ if (/^(var|let|const)$/i.test(o.text)) {
1234
+ bx = ++cx;
1235
+ continue;
1236
+ }
1234
1237
  if (brk("yield", YIELD, skipAssignment)) break a;
1235
1238
  if (brk("return", RETURN, skipSentenceQueue)) break a;
1236
1239
  if (brk("throw", THROW, skipSentenceQueue)) break a;
@@ -1340,7 +1343,13 @@ function toqueue(body, getname, ret = false, result = []) {
1340
1343
  }
1341
1344
  }
1342
1345
  else {
1343
- cx++;
1346
+ cx = skipAssignment(body, cx);
1347
+ if (cx > bx) {
1348
+ var b = body.slice(bx, cx);
1349
+ var bs = ternary(b, getname, ret);
1350
+ for (var b of bs) pushstep(result, b);
1351
+ }
1352
+ else cx++;
1344
1353
  }
1345
1354
  bx = cx;
1346
1355
  continue;
@@ -159,4 +159,6 @@ r++// test("if(a)else {}",'')
159
159
  test("if(a){if(b){c}d}else{e}", `if (!a) return [2, 0]; if (!b) return [1, 0]; c; return [1, 0];\r\n d; return [2, 0];\r\n e; return [1, 0]`)
160
160
  test("if(a){if(b){c}else{d}}else{e}", `if (!a) return [3, 0]; if (!b) return [1, 0]; c; return [2, 0];\r\n d; return [1, 0];\r\n return [2, 0];\r\n e; return [1, 0]`)
161
161
  test("if(a&&b||c){d}", `_ = a; if (!_) return [1, 0]; _ = b;\r\n if (_) return [1, 0]; _ = c;\r\n if (!_) return [1, 0]; d; return [1, 0]`, true);
162
- test("if(a)switch(b){case c:d;break;} else{h}", `if (!a) return [3, 0]; if (b === c) return [1, 0]; return [2, 0];\r\n d; return [1, 0];\r\n return [2, 0];\r\n h; return [1, 0]`)
162
+ test("if(a)switch(b){case c:d;break;} else{h}", `if (!a) return [3, 0]; if (b === c) return [1, 0]; return [2, 0];\r\n d; return [1, 0];\r\n return [2, 0];\r\n h; return [1, 0]`)
163
+ test("var res = null, krc;", `res = null; krc`)
164
+ test("res = null, krc;", `res = null; krc`)
@@ -497,6 +497,7 @@ var killneg = function (v, n) {
497
497
  v = n + v;
498
498
  }
499
499
  }
500
+ else if (n) v = n + v;
500
501
  return v;
501
502
  };
502
503
  var calcvars = function (v) {
@@ -87,6 +87,7 @@ assert(素馨(`a{a:extract(2 3,2)}`), `a{a:3;}`);
87
87
  assert(素馨(`value: range(10px, 30px, 10);`, '', true), `value:10px 20px 30px;`);
88
88
  assert(素馨(`value: range(4);`, '', true), `value:1 2 3 4;`);
89
89
  assert(素馨(`@a:-1;b{a:-@a}`, '', true), `b{a:1;}`);
90
+ assert(素馨(`--mwidth:0px;--bwidth:2px;--qwidth: var(--mwidth)+var(--bwidth);width:--qwidth`, '', true), `width:2px;`);
90
91
  assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[0].text, '-0.2em');
91
92
  assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[0].isdigit, true);
92
93
  assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[2].text, ".3em");
@@ -2245,4 +2245,7 @@ var createDataURL = function (width, height, getPixel) {
2245
2245
 
2246
2246
  // multibyte support
2247
2247
 
2248
- qrcode.stringToBytesFuncs['UTF-8'] = /* 这一块已被efront作者修改 */ encodeUTF8;
2248
+ qrcode.stringToBytes =
2249
+ qrcode.stringToBytesFuncs.default =
2250
+ qrcode.stringToBytesFuncs['UTF-8'] =
2251
+ /* 这一块已被efront作者修改 */ encodeUTF8;
@@ -6,6 +6,7 @@
6
6
  border: 1px solid #0003;
7
7
  padding: 6px 0;
8
8
  outline: none;
9
+ background: #fff;
9
10
 
10
11
  >menu-item {
11
12
  display: block;
@@ -27,6 +27,7 @@ var create = function (url, key, report_error) {
27
27
 
28
28
  var image = picture_();
29
29
  image.url = url;
30
+ var rotate = url.rotate | 0;
30
31
  if (广告 && !广告.parentNode) appendChild(image, 广告);
31
32
  if (isObject(url)) {
32
33
  if (key) {
@@ -69,6 +70,7 @@ var create = function (url, key, report_error) {
69
70
  };
70
71
  var imgpic;
71
72
  image.setImage = function (_imgpic) {
73
+ _imgpic.rotate = rotate;
72
74
  if (!isElement(_imgpic)) _imgpic = this;
73
75
  if (imgpic) {
74
76
  [].forEach.call(imgpic.attributes, a => {
@@ -109,6 +111,7 @@ var create = function (url, key, report_error) {
109
111
  marginTop
110
112
  };
111
113
  }
114
+ image.rotateTo(rotate);
112
115
  return image;
113
116
  };
114
117
 
@@ -172,7 +172,7 @@ var isypop = function (target) {
172
172
  if (
173
173
  target.offsetWidth >= (innerWidth >> 1) &&
174
174
  target.offsetHeight < (innerHeight >> 1) ||
175
- offsetParent.offsetWidth >= (innerWidth >> 1) &&
175
+ offsetParent && offsetParent.offsetWidth >= (innerWidth >> 1) &&
176
176
  offsetParent.offsetHeight < (innerHeight >> 1)) return true;
177
177
  if (
178
178
  nextSibling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.15.2",
3
+ "version": "4.16.0",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {