efront 3.36.3 → 3.36.6

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.
@@ -244,12 +244,13 @@ var killCircle = function () {
244
244
  };
245
245
  // -->
246
246
  var hasOwnProperty = {}.hasOwnProperty;
247
- var loadModule = function (name, then, prebuilds = {}) {
247
+ var loadModule = function (url, then, prebuilds = {}) {
248
+ var name = url.replace(/[\*~][\s\S]*$/, '');
248
249
  if (/^(?:module|exports|define|require|window|global|undefined)$/.test(name)) return then();
249
- if ((hasOwnProperty.call(prebuilds, name)) || hasOwnProperty.call(modules, name) || (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name))
250
+ if ((hasOwnProperty.call(prebuilds, url)) || hasOwnProperty.call(modules, url) || (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name))
250
251
  ) return then();
251
- preLoad(name);
252
- var key = keyprefix + name;
252
+ preLoad(url);
253
+ var key = keyprefix + url;
253
254
  if (loadedModules[key] instanceof Function) {
254
255
  then();
255
256
  return;
@@ -267,15 +268,15 @@ var loadModule = function (name, then, prebuilds = {}) {
267
268
  }.bind(null, responseTree[name]));
268
269
  };
269
270
  if (/\.json([\#\?].*?)?$/i.test(name)) {
270
- readFile(["JSON", name], saveModule);
271
+ readFile(["JSON", url], saveModule);
271
272
  } else {
272
- readFile(name, saveModule);
273
+ readFile(url, saveModule);
273
274
  };
274
275
  }
275
276
  else {
276
277
 
277
278
  var saveModule = function (error) {
278
- var data = responseTree[name];
279
+ var data = responseTree[url];
279
280
  if (typeof data === "function") {
280
281
  var mod = data;
281
282
  flushTree(loadedModules, key, mod);
@@ -289,7 +290,8 @@ var loadModule = function (name, then, prebuilds = {}) {
289
290
  // <!--
290
291
  if (!data) undefinedModules[name] = true;
291
292
  // -->
292
- var [argNames, body, args, required, strs, isAsync, isYield] = getArgs(data);
293
+ var afterfix = url.slice(name.length);
294
+ var [argNames, body, args, required, strs, isAsync, isYield] = getArgs(data, afterfix);
293
295
  if (isProduction) {
294
296
  strs = strs.map ? strs.map(toRem) : strs;
295
297
  } else {
@@ -300,7 +302,10 @@ var loadModule = function (name, then, prebuilds = {}) {
300
302
  mod.argNames = argNames;
301
303
  mod.strs = strs;
302
304
  var loadingCount = 0;
303
- if (required) required = required.split(';').filter(a => !!a);
305
+ if (required) {
306
+ required = required.split(';').filter(a => !!a);
307
+ if (afterfix) required = required.map(r => r + afterfix);
308
+ }
304
309
  required = required ? get_relatives(name, required) : [];
305
310
  mod.required = required;
306
311
  mod.file = name;
@@ -328,13 +333,15 @@ var loadModule = function (name, then, prebuilds = {}) {
328
333
  });
329
334
  }
330
335
  };
331
- readFile(name, saveModule);
336
+ readFile(url, saveModule);
332
337
  }
333
338
  };
334
339
  var toRem = text => pixelDecoder && typeof text === 'string' ? text.replace(/(\:\s*)?\b((?:\d*\.)?\d+)px(\s*\))?/ig, (m, h, d, quote) => (h || "") + (d !== '1' ? h && quote ? renderPixelRatio * d + "pt" : pixelDecoder(d) : renderPixelRatio > 1 ? ".78pt" : 0.78 / devicePixelRatio + "pt") + (quote || "")) : text;
335
340
  "use ./#decrypt.js";
336
- var getArgs = function (text) {
337
- "use ./#decrypt_.js";
341
+ var getArgs = function (text, aftfix) {
342
+ if (!aftfix || /^\*/.test(aftfix)) {
343
+ "use ./#decrypt_.js";
344
+ }
338
345
  var args, functionBody;
339
346
  //依赖项名称部分的长度限制为36*36*18=23328
340
347
  var doublecount = parseInt(text.slice(0, 3), 36);
@@ -365,6 +372,9 @@ var getArgs = function (text) {
365
372
  var argNames = args.slice(argsstart, argsend);
366
373
  var required = args[argsend];
367
374
  args = args.slice(0, argsstart);
375
+ if (aftfix) {
376
+ args = args.map(a => a + aftfix);
377
+ }
368
378
  } else {
369
379
  functionBody = text;
370
380
  }
@@ -422,7 +432,8 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
422
432
  var isModuleInit = false;
423
433
  var required = exec.required;
424
434
  if (required) required = required.map(a => loadedModules[keyprefix + a]);
425
- var argsList = originNames.map(function (argName) {
435
+ var argsList = originNames.map(function (aName) {
436
+ var argName = aName.replace(/[\*~][\s\S]*$/, '');
426
437
  if (hasOwnProperty.call(prebuilds, argName)) {
427
438
  return prebuilds[argName];
428
439
  }
@@ -465,11 +476,8 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
465
476
  var prebuilds2 = Object.create(null);
466
477
  for (var k in prebuilds) if (hasOwnProperty.call(prebuilds, k)) prebuilds2[k] = prebuilds[k];
467
478
  prebuilds = prebuilds2;
468
- delete prebuilds.popup;
469
- delete prebuilds.action;
470
- delete prebuilds.init;
471
479
  }
472
- var promise = init(argName, function (res) {
480
+ var promise = init(aName, function (res) {
473
481
  result = res;
474
482
  created = true;
475
483
  }, prebuilds);
@@ -489,19 +497,20 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
489
497
  });
490
498
  };
491
499
 
492
- var init = function (name, then, prebuilds) {
500
+ var init = function (url, then, prebuilds) {
493
501
  // then = bindthen(then);
494
- var key = keyprefix + name;
502
+ var key = keyprefix + url;
495
503
  if (prebuilds) {
496
- if (hasOwnProperty.call(prebuilds, name)) {
497
- if (then) then(prebuilds[name]);
498
- return prebuilds[name];
504
+ if (hasOwnProperty.call(prebuilds, url)) {
505
+ if (then) then(prebuilds[url]);
506
+ return prebuilds[url];
499
507
  }
500
508
  }
501
- if (hasOwnProperty.call(modules, name)) {
502
- if (then) then(modules[name]);
503
- return modules[name];
509
+ if (hasOwnProperty.call(modules, url)) {
510
+ if (then) then(modules[url]);
511
+ return modules[url];
504
512
  }
513
+ var name = url.replace(/[\*~][\s\S]*$/, '');
505
514
  if (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name)) {
506
515
  modules[name] = window[name]
507
516
  if (then) then(modules[name]);
@@ -540,17 +549,17 @@ var init = function (name, then, prebuilds) {
540
549
  };
541
550
  var crack = function (error) {
542
551
  if (res.resolved || res.errored) return;
543
- var ed = errored[name];
552
+ var ed = errored[url];
544
553
  res.errored = true;
545
554
  res.error = error;
546
555
  res.fire();
547
- var rest = [name];
556
+ var rest = [url];
548
557
  var track = [];
549
558
  var length = 0;
550
559
  var deep = 0;
551
560
  // <!--
552
561
  var map = Object.create(null);
553
- map[name] = true;
562
+ map[url] = true;
554
563
  do {
555
564
  deep++;
556
565
  var rest2 = Object.create(null);
@@ -573,11 +582,11 @@ var init = function (name, then, prebuilds) {
573
582
  track = track.map(([d, a, e]) => ` ${new Array(d + 1).join("•")} ${new Array(2 + length - a.length - d).join("-")} ${a} 溃于: ${e.reverse().join(", ")}`)
574
583
  // -->
575
584
  var report = window.performance || !window.alert ? console.error : window.alert;
576
- report(`加载 ${name} 失败,${ed && ed.length ? `${ed.join(', ')} 等 ${ed.length} 个模块` : "没有其他模块"}受到影响。\r\n${track.join("\r\n")}`);
585
+ report(`加载 ${url} 失败,${ed && ed.length ? `${ed.join(', ')} 等 ${ed.length} 个模块` : "没有其他模块"}受到影响。\r\n${track.join("\r\n")}`);
577
586
  };
578
- loadModule(name, function (error) {
579
- if (hasOwnProperty.call(modules, name)) {
580
- then(modules[name]);
587
+ loadModule(url, function (error) {
588
+ if (hasOwnProperty.call(modules, url)) {
589
+ then(modules[url]);
581
590
  return;
582
591
  }
583
592
  if (error) return crack(error);
@@ -587,7 +596,7 @@ var init = function (name, then, prebuilds) {
587
596
 
588
597
  if (!args || !args.length) {
589
598
  var created = module.call(window);
590
- then(module.created = modules[name] = created);
599
+ then(module.created = modules[url] = created);
591
600
  return;
592
601
  }
593
602
  var filteredArgs = prebuilds ? args.filter(a => !hasOwnProperty.call(prebuilds, a)) : args;
@@ -611,12 +620,12 @@ var init = function (name, then, prebuilds) {
611
620
  if (saveAsModule) {
612
621
  penddings[key] = created;
613
622
  created.then(function (res) {
614
- then(modules[name] = res);
623
+ then(modules[url] = res);
615
624
  });
616
625
  return;
617
626
  }
618
627
  } else {
619
- if (saveAsModule) module.created = modules[name] = created;
628
+ if (saveAsModule) module.created = modules[url] = created;
620
629
  }
621
630
  then(created);
622
631
  }, prebuilds);
@@ -820,6 +829,12 @@ var modules = {
820
829
  createFunction,
821
830
  efrontsign: "",
822
831
  };
832
+ modules["set request"] = function (req) {
833
+ request = req;
834
+ };
835
+ modules["get request"] = function () {
836
+ return request;
837
+ };
823
838
  modules.debug = function () {
824
839
  document.addEventListener("blur", e => e.stopPropagation(), true);
825
840
  };
@@ -0,0 +1,62 @@
1
+ var exec = function (args, ok, oh) {
2
+ var p = null, index = 0, r, finished = false;
3
+ var next = function (arg) {
4
+ p = arg;
5
+ run();
6
+ };
7
+ var catches = [];
8
+ var thro = function (err) {
9
+ if (catches.length) {
10
+ [index, p] = catches[catches.length - 1]
11
+ index += p >>> 16;
12
+ p = err;
13
+ next();
14
+ }
15
+ else {
16
+ oh(err);
17
+ }
18
+ };
19
+ var retn = function (p) {
20
+ r = p;
21
+ finished = true;
22
+ if (catches.length) fina();
23
+ else ok(r);
24
+ };
25
+ var fina = function () {
26
+ // 仅在try或catch未结束时使用
27
+ [index, p] = catches[catches.length - 1];
28
+ index += (p >>> 16) + (p & 0xffff);
29
+ next();
30
+ };
31
+ var fine = function () {
32
+ catches.pop();
33
+ next();
34
+ }
35
+ var run = function () {
36
+ var args_length = args.length, i;
37
+ if (finished && !catches.length || index > args_length) return ok(r);
38
+ loop: while (index < args_length) {
39
+ try {
40
+ [p, i] = args[index](p) || [1, 0];
41
+ } catch (e) {
42
+ p = null;
43
+ thro(e);
44
+ break;
45
+ }
46
+ switch (i) {
47
+ case 0: index += p; break; // reflow
48
+ case 1: index += 1; break loop; // await p;
49
+ case 2: return finished = true, retn(p); // return p;
50
+ case 7: index++; catches.push([index, p]); break; // try start
51
+ case 9: return p ? fine() : fina(); // finally
52
+ default: throw "代码异常!";
53
+ }
54
+ }
55
+ if (p && isFunction(p.then)) p.then(next, thro);
56
+ else next(p);
57
+ };
58
+ next();
59
+ };
60
+ function async_() {
61
+ return new Promise(exec.bind(null, arguments));
62
+ }
@@ -0,0 +1,11 @@
1
+ var test = async function (queue, expect) {
2
+ var res = await async_.apply(null, queue);
3
+ assert(res, expect);
4
+ }
5
+ test([function () {
6
+ return [1, 0]
7
+ }, function () {
8
+ return [, 2];
9
+ }], 2);
10
+
11
+ test(compile$unstruct(compile$scanner2(`1+2`)), 3);
@@ -194,7 +194,8 @@ class Program {
194
194
  Object.defineProperty(scope, 'queue', { value: queue, enumerable: false });
195
195
  scope.prev = last;
196
196
  if (scope.type !== COMMENT && scope.type !== SPACE) {
197
- if (program.setType(scope) === false) {
197
+ var keeplast = program.setType(scope) === false;
198
+ if (keeplast) {
198
199
  if (queue.last !== last) last = queue.last;
199
200
  else if (scope.prev !== last) last = scope.prev;
200
201
  while (queue[queue.length - 1] !== last) queue.pop();
@@ -202,6 +203,10 @@ class Program {
202
203
  last.text = text.slice(last.start, last.end);
203
204
  return;
204
205
  }
206
+ if (queue.last !== last && queue.last !== o) {
207
+ last = queue.last, scope.prev = last;
208
+ if (last) last.text = text.slice(last.start, last.end);
209
+ }
205
210
  if (last) last.next = scope;
206
211
  queue.last = scope;
207
212
  for (var cx = queue.length - 1; cx >= 0; cx--) {
@@ -217,7 +222,7 @@ class Program {
217
222
  };
218
223
  var row = 1, colstart = -1;
219
224
  var save = (type) => {
220
- if (lasttype === STAMP && type === STAMP && !/[,;\:\?]/.test(m)) {
225
+ if (lasttype === STAMP && type === STAMP && !/[,;\:]/.test(m)) {
221
226
  var scope = queue[queue.length - 1];
222
227
  if (/=>$/i.test(scope.text) ||
223
228
  /[=>]$/.test(scope.text) && /[^>=]/.test(m) ||
@@ -146,6 +146,11 @@ var skipAssignment = function (o, cx) {
146
146
  needpunc = true;
147
147
  break;
148
148
  }
149
+ else if (o.text === 'debugger') {
150
+ next();
151
+ needpunc = false;
152
+ break loop;
153
+ }
149
154
  else {
150
155
  next();
151
156
  needpunc = false;
@@ -0,0 +1,19 @@
1
+ var { createExpressList, createString } = common;
2
+ var test = function (text) {
3
+ var code = scanner2(text);
4
+ var exps = createExpressList(code);
5
+ console.log(code.isExpressQueue(),exps.map(createString))
6
+ };
7
+ test('a')
8
+ test('a+b=c')
9
+ test('if(a)a+b=c')
10
+ test('if(a)b=c; else c=d+a')
11
+ test('if(a)b=c; else if(m)c=d+a;else aa')
12
+ test('with(a)b=c; if(m)c=d+a;else aa')
13
+ test('try{}catch(){}finally{} if(m)c=d+a;else aa')
14
+ test('try{}catch{}finally{} if(m)c=d+a;else aa')
15
+ test('try{}catch{}finally{} if(m)c=d+a;else aa debugger\r\n a')
16
+ test('try{}catch{}\r\nfinally{}\r\n if(m)c=d+a;else aa debugger\r\n a')
17
+ test('var a')
18
+ test('var a,b,c=1;')
19
+ test('a:')
@@ -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, QUOTED, number_reg, rename, getDeclared, skipAssignment, createString } = require("./common");
4
+ var { STAMP, SCOPED, STRAP, EXPRESS, COMMENT, SPACE, PROPERTY, VALUE, QUOTED, rename, getDeclared, skipAssignment, createString, relink, createExpressList } = require("./common");
5
5
  var link = function (a, b) {
6
6
  if (a) a.next = b;
7
7
  if (b) b.prev = a;
@@ -394,7 +394,7 @@ var killcls = function (body, o, getname_) {
394
394
  while (next && !next.isClass) next = next.next;
395
395
  base = createString(splice1(body, o, o = next));
396
396
  }
397
- if (base === 'Array') base = 'Array2';
397
+ // if (base === 'Array') base = 'Array2'; 降级时不做填充的工作
398
398
  var index = 0;
399
399
  while (o && o.isClass) {
400
400
  var m = o.first;
@@ -615,6 +615,9 @@ var killobj = function (body, getobjname, getname_, setsolid, deep = 0) {
615
615
  if (o && o.type === SCOPED) o = o.next;// ()
616
616
  if (o && o.type === SCOPED) o = o.next;// {}
617
617
  break;
618
+ case "async":
619
+ splice1(body, o, o = o.next);
620
+ break;
618
621
  default:
619
622
  o = o.next;
620
623
  }
@@ -667,9 +670,79 @@ var export_ = function () { };
667
670
  // 字面量 false|true|null|Infinity|NaN|undefined|arguments|this|eval|super
668
671
  var unfalse = function () { };
669
672
  var unyield = function () { };
670
- var unawait = function (body, awaits, getname_) {
673
+ var power_map = {};
674
+ [
675
+ '=,+=,-=,*=,/=,%=,|=,&=,^=,**=,~=',
676
+ '=>', '?,:', '&&,||', '&,|,^',
677
+ 'instanceof,in,==,>=,<=,>,<,!=,!==,===,!in,!instanceof',
678
+ '>>,>>>,<<', '+,-', '*,/,%', '**',
679
+ 'typeof,await,yield,!,~', '++,--'
680
+ ].forEach((pp, i) => {
681
+ pp.split(",").forEach(p => {
682
+ power_map[p] = i + 1;
683
+ })
684
+ });
685
+ var unawait = function (body, getname, argname) {
686
+ return unstruct(body, function () {
687
+ return getname("_");
688
+ }, argname);
689
+ };
690
+ var getsync = function (m) {
691
+ if (m.type === SCOPED && m.await) return null;
692
+ var n = skipAssignment(m);
693
+ while (m !== n) {
694
+ if (m.await || m.type === STRAP && m.text === 'await') return null;
695
+ m = m.next;
696
+ }
697
+ };
698
+ var isawait = function (o) {
699
+ if (o && o.type === SCOPED && o.entry === "{") {
700
+ if (!o.await) return false;
701
+ }
702
+ else while (o) {
703
+ o = getsync(o);
704
+ if (o === null) return true;
705
+ if (!o || o.type !== STAMP || o.text !== ',') {
706
+ break;
707
+ }
708
+ o = o.next;
709
+ }
710
+ return false;
711
+ }
712
+ var unforin = function (o, body, getnewname_) {
713
+ // 仅处理有 await 的代码
714
+ if (!o.await) {
715
+ if (!isawait(o.next)) return;
716
+ }
717
+ var m = o.first;
718
+ var hasdeclare = false;
719
+ if (m.type === STRAP) {
720
+ m = m.next;
721
+ hasdeclare = true;
722
+ }
723
+ var n = m.next;
724
+ if (n.type !== STRAP || n.text !== 'in') {
725
+ return;
726
+ }
727
+ n = n.next;
728
+ var tname = getnewname_();
729
+ var sname = getnewname_();
730
+ var kname = getnewname_();
731
+ var s = scanner2(`${sname}=`);
732
+ insert1(s, null, ...splice1(o, n));
733
+ insert1(s, null,
734
+ ...scanner2(`,${tname}=[];for(${kname} in ${sname})${tname}.push(${kname});`)
735
+ );
736
+ insert1(body, o.prev, ...s);
737
+ splice1(o, m.next);
738
+ splice1(o, m);
739
+ insert1(o, o.first, ...scanner2(`${kname}=0;${kname}<${tname}.length`));
740
+ var c = scanner2(`(=${tname}[${kname}]);${kname}++`);
741
+ insert1(c[0], c[0].first, m);
742
+ insert1(o, null, ...c);
671
743
  };
672
- var unforof = function (o, gettempname_, getnextname_) {
744
+
745
+ var unforof = function (o, getnewname, used) {
673
746
  var m = o.first;
674
747
  var hasdeclare = false;
675
748
  if (m.type === STRAP) {
@@ -687,17 +760,19 @@ var unforof = function (o, gettempname_, getnextname_) {
687
760
  var [d] = getDeclared(p);
688
761
  insert1(o, m, ...scanner2(d.map(a => a.text).join(",")));
689
762
  }
690
- splice1(o, m);
691
- var iname = gettempname_();
692
- insert1(o, null, ...scanner2(`${iname}=0`));
763
+ var iname = getnewname();
764
+ insert1(o, m, ...scanner2(`${iname}=0`));
693
765
  var oname;
694
- if (f.type === EXPRESS && !/\./.test(oname)) {
766
+ if (!f.next && f.type === EXPRESS && !/\./.test(f.text) && used[f.text].length === 1) {
767
+ splice1(o, m);
695
768
  oname = f.text;
696
769
  }
697
770
  else {
698
- oname = getnextname_();
771
+ oname = getnewname();
772
+ splice1(o, n, f);
773
+ var mo = splice1(o, f);
699
774
  insert1(o, null, ...scanner2(`,${oname}=`));
700
- insert1(o, null, ...splice1(o, f));
775
+ insert1(o, null, ...mo);
701
776
  }
702
777
  insert1(o, null, ...scanner2(`;${iname}<${oname}.length&&`));
703
778
  var q = scanner2(`(=${oname}[${iname}],true)`)[0];
@@ -853,7 +928,7 @@ var down = function (scoped) {
853
928
  argcodes.push(`var ${an}=arguments;`);
854
929
  }
855
930
  var fordeep = 0;
856
- var kill = function (scoped) {
931
+ var kill = function (scoped, _, body) {
857
932
  if (scoped.isfunc) return down(scoped);
858
933
  killlet(scoped);
859
934
  var saveddeep = fordeep;
@@ -865,7 +940,9 @@ var down = function (scoped) {
865
940
  var hp = scoped.head.prev;
866
941
  if (hp && hp.type === STRAP) {
867
942
  if (hp.text === 'for') {
868
- unforof(scoped.head, getdeepname, getdeepname);
943
+ unforof(scoped.head, getdeepname, scoped.used);
944
+ unforin(scoped.head, body, getdeepname);
945
+ // unforcx(scoped.head, getdeepname);
869
946
  }
870
947
  else if (hp.text === 'catch') {
871
948
  killarg(scoped.head, scoped.body, _getname);
@@ -884,11 +961,24 @@ var down = function (scoped) {
884
961
  if (argcodes.length) precode(argcodes.join(";") + ";");
885
962
  if (scoped.body) scoped.body.keeplet = false, killobj(scoped.body, gettmpname, _getname, setsolid);
886
963
  scoped.forEach(kill);
964
+ if (scoped.async) {
965
+ var argname = _getname("_");
966
+ var code = unawait(scoped.body, _getname, argname);
967
+ var body = scanner2(`return async_()`);
968
+ code.forEach(function (c) {
969
+ var f = scanner2(`function(${body[2].length ? argname : ''}){}`);
970
+ if (!c.length) insert1(f[2], null, ...scanner2('return []'));
971
+ else insert1(f[2], null, ...c);
972
+ if (body[2].length) insert1(body[2], null, { type: STAMP, text: "," });
973
+ insert1(body[2], null, ...f);
974
+ });
975
+ scoped.body.splice(0, scoped.body.length);
976
+ insert1(scoped.body, null, ...body);
977
+ }
887
978
  }
888
979
  else {
889
980
  kill(scoped);
890
981
  }
891
- Program.prototype.relink(scoped.body);
892
982
  };
893
983
  /**
894
984
  * @param {Program} code
@@ -58,7 +58,7 @@ assert(downLevel(`={a:1,[a]:1}`), `= (_ = { a: 1 }, _[a] = 1, _)`);
58
58
  assert(downLevel(`={a,[a]:1}`), `= (_ = {}, _.a = a, _[a] = 1, _)`);
59
59
  assert(downLevel(`={[a]:{[b]:1}}`), `= (_ = {}, _[a] = (_0 = {}, _0[b] = 1, _0), _)`);
60
60
  assert(downLevel(`={[a]:{[b]:{[c]:1}}}`), `= (_ = {}, _[a] = (_0 = {}, _0[b] = (_1 = {}, _1[c] = 1, _1), _0), _)`);
61
- assert(downLevel(`={[a]:{[b]:{[c]:1}},[b]:{[a]:1})}`), `= (_ = {}, _[a] = (_0 = {}, _0[b] = (_1 = {}, _1[c] = 1, _1), _0), _[b] = (_0 = {}, _0[a] = 1, _0), _)`);
61
+ assert(downLevel(`={[a]:{[b]:{[c]:1}},[b]:{[a]:1}}`), `= (_ = {}, _[a] = (_0 = {}, _0[b] = (_1 = {}, _1[c] = 1, _1), _0), _[b] = (_0 = {}, _0[a] = 1, _0), _)`);
62
62
  // 对象展开
63
63
  assert(downLevel(`={...a}`), `= extend({}, a)`);
64
64
  assert(downLevel(`={...{a:1}}`), `= extend({}, { a: 1 })`);
@@ -95,6 +95,7 @@ assert(downLevel(`function (a,...b,b){}`), "function (a, b) { b = arguments.leng
95
95
  assert(downLevel(`(a)=>k`), "function (a) { return k }")
96
96
  assert(downLevel(`(...a) => k`), "function () { var a = Array.prototype.slice.call(arguments, 0); return k }")
97
97
  assert(downLevel(`for(var o of os)`), "for (var _ = 0; _ < os.length && (o = os[_], true); _++)")
98
+ assert(downLevel(`for(var o of o)`), "for (var _ = 0, _0 = o; _ < _0.length && (o = _0[_], true); _++)")
98
99
  assert(downLevel(`for(var [a] of os)`), "for (var _ = 0; _ < os.length && (a = os[_][0], true); _++)")
99
100
  assert(downLevel(`for(var [a,b] of os)`), "for (var _ = 0; _ < os.length && (_0 = os[_], a = _0[0], b = _0[1], true); _++)")
100
101
  assert(downLevel(`[...a]=a`), "a = Array.prototype.slice.call(a, 0)")
@@ -104,8 +105,11 @@ assert(downLevel(`[...a,c]=a`), "_ = a, a = Array.prototype.slice.call(a, 0, -1)
104
105
  assert(downLevel(`{...a,c}=a`), `c = a.c, a = rest_(a, ["c"])`)
105
106
  assert(downLevel(`{c,...a}=a`), `c = a.c, a = rest_(a, ["c"])`)
106
107
  assert(downLevel(`{c,[c]:b,...a}=a`), `c = a.c, b = a[c], a = rest_(a, ["c", c])`)
107
- assert(downLevel(`async function(){}`), `function(){return Promise.resolve()}`)
108
- assert(downLevel(`async function(a){await a}`), `function(a){return Promise.resolve(a)}`)
109
- assert(downLevel(`async function(a){await a,await b}`), `function(a){return async_(function(){return a},function(){return b}})`)
110
- assert(downLevel(`async function(){await a,await b}`), `function(){return async_(function(){return a},function(){return b}})`)
111
- assert(downLevel(`async function(a){ if(c)await a}`), `function(){return Promise.resolve(a).then(b)}`)
108
+ assert(downLevel(`async function(){}`), `function () { return async_() }`)
109
+ assert(downLevel(`async function(){return 1}`), `function () { return async_(function () { _0 = 1; return [_0, 2] }) }`)
110
+ assert(downLevel(`async function(a){await a}`), `function (a) { return async_(function () { _0 = a; return [_0, 1] }) }`)
111
+ assert(downLevel(`async function(a){return await a}`), `function (a) { return async_(function () { _0 = a; return [_0, 1] }, function (_) { _0 = _; return [_0, 2] }) }`)
112
+ assert(downLevel(`async function(a){await a,await b}`), `function (a) { return async_(function () { _0 = a; return [_0, 1] }, function (_) { _0 = b; return [_0, 1] }) }`)
113
+ assert(downLevel(`async function(){await a,await b}`), `function () { return async_(function () { _0 = a; return [_0, 1] }, function (_) { _0 = b; return [_0, 1] }) }`)
114
+ assert(downLevel(`async function(a){ if(c)await a,await b;else if(s) await c;}`), `function (a) { return async_(function () { if (!c) return [3, 0]; _0 = a; return [_0, 1] }, function (_) { _0 = b; return [_0, 1] }, function (_) { return [2, 0] }, function (_) { if (!s) return [1, 0]; _0 = c; return [_0, 1] }) }`)
115
+ assert(downLevel(`async function(a){ for(i=1;i<2;i++) await 1 }`), `function (a) { return async_(function () { i = 1; return [1, 0] }, function (_) { _0 = i < 2; if (!_0) return [3, 0] }, function (_) { _0 = 1; return [_0, 1] }, function (_) { _0 = i++; return [-2, 0] }) }`)
@@ -0,0 +1,12 @@
1
+ var powermap = {};
2
+ [
3
+ '=,+=,-=,*=,/=,%=,|=,&=,^=,**=,~=,?,:,=>'/* 1 */,
4
+ '&&,||,??'/* 4 */, '&,|,^'/* 5 */,
5
+ 'instanceof,in,==,>=,<=,>,<,!=,!==,===,!in,!instanceof'/* 6 */,
6
+ '>>,>>>,<<'/* 7 */, '+,-'/* 8 */, '*,/,%'/* 9 */, '**'/* 10 */,
7
+ 'typeof,await,yield,new,delete,!,~'/* 11 */, '++,--'/* 12 */
8
+ ].forEach((pp, i) => {
9
+ pp.split(",").forEach(p => {
10
+ powermap[p] = i + 1;
11
+ })
12
+ });
@@ -26,13 +26,11 @@ Richcss.prototype.setType = function (o) {
26
26
  }
27
27
  if (pps.length > 1) {
28
28
  var i = q.lastIndexOf(p = pps.pop());
29
- q.splice(i + 1, q.length, o);
30
- p.next = o;
29
+ q.splice(i + 1, q.length);
31
30
  p.type = PROPERTY;
32
31
  p.end = pps[0].end;
33
- o.prev = p;
34
- q.last = o;
35
- return false;
32
+ q.last = p;
33
+ return;
36
34
  }
37
35
  }
38
36
  if (!q.entry && o.type !== SCOPED) {
@@ -10,4 +10,5 @@ test(`a{ >b{a:1}}`,`a>b{a:1;}`);
10
10
  test(`a{ &>b{a:1}}`,`a>b{a:1;}`);
11
11
  test(`a{ &b{a:1}}`,`ab{a:1;}`);
12
12
  test(`a{ &.b{a:1}}`,`a.b{a:1;}`);
13
- test(`a{ &[b]{a:1}}`,`a[b]{a:1;}`);
13
+ test(`a{ &[b]{a:1}}`,`a[b]{a:1;}`);
14
+ test(`a{ &[b]:nth-child(1){a:1}}`,`a[b]:nth-child(1){a:1;}`);