efront 3.36.5 → 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.
@@ -4,10 +4,9 @@ var { createString } = require("./common");
4
4
  function test(codetext, expect, ret = false) {
5
5
  var code = scanner2(codetext);
6
6
  var i = -2;
7
- code = unstruct(code, () => ++i >= 0 ? "_" + i : '_', ret);
7
+ code = unstruct(code, () => ++i >= 0 ? "_" + i : '_', ret && "@");
8
8
  assert(code.map(createString).join("; "), expect);
9
9
  }
10
-
11
10
  test('a+b', "a + b");
12
11
  test('a + !c', "_ = !c, a + _");
13
12
  test('a + b * c', "_ = b * c, a + _");
@@ -17,38 +16,46 @@ test('a * a + b * c', "_ = a * a, _0 = b * c, _ + _0");
17
16
  test('a * a + b * c * c ** d', "_ = a * a, _0 = b * c, _1 = c ** d, _0 = _0 * _1, _ + _0");
18
17
  test('a * a || b * c * c ** d', "_ = a * a @re _ = b * c, _0 = c ** d, _ * _0");
19
18
  test('a * a || b * c || c * d', "_ = a * a @re _ = b * c @re c * d");
20
- test('a?b:c', "_ = a; return [_ ? 1 : 2, _]; _ = b; return [2, _]; _ = c; return [1, _]");
19
+ test('a?b:c', "_ = a; return [_ ? 1 : 2, 0]; _ = b; return [2, 0]; _ = c");
21
20
  test('a * a && b * c * c ** d', "_ = a * a @rz _ = b * c, _0 = c ** d, _ * _0");
22
- test('a = b', "a = b; return [1, a]", true);
23
- test('a = b = c', "_ = c; b = _; a = _; return [1, a]", true);
24
- test('a = b = c + d', "_ = c + d; b = _; a = _; return [1, a]", true);
25
- test('a = b = c + d * 1', "_ = d * 1; _ = c + _; b = _; a = _; return [1, a]", true);
26
- test('return a = b', "a = b; return [1, a]", true);
27
- test('a*a', "_ = a * a; return [1, _]", true);
28
- test('a * a && b * c * c ** d', "_ = a * a; if (!_) return [2, _]; _ = b * c; _0 = c ** d; _ = _ * _0; return [1, _]", true);
21
+ test('a = 1 + 2', "_ = 1 + 2, a = _", true);
22
+ test('a = b', "a = b", true);
23
+ test('a = b = c', "_ = c, b = _, a = _", true);
24
+ test('a = b = c + d', "_ = c + d, b = _, a = _", true);
25
+ test('a = b = c + d * 1', "_ = d * 1, _ = c + _, b = _, a = _", true);
26
+ test('return a = b', "a = b; return [a, 2]", true);
27
+ test('a*a', "_ = a * a", true);
28
+ test('a * a && b * c * c ** d', "_ = a * a; if (!_) return [1, 0]; _ = b * c, _0 = c ** d, _ = _ * _0", true);
29
+ test('a * a || b * c * c ** d', "_ = a * a; if (_) return [1, 0]; _ = b * c, _0 = c ** d, _ = _ * _0", true);
30
+ test('a * a ?? b * c * c ** d', "_ = a * a; if (_ !== null && _ !== undefined) return [1, 0]; _ = b * c, _0 = c ** d, _ = _ * _0", true);
31
+ test('a * a && await b*c', "_ = a * a; if (!_) return [2, 0]; _ = b; return [_, 1]; _ = @; _ = _ * c", true);
29
32
 
30
- test("await a", "_ = a; return [1, _]", true);
31
- test("await a()", "_ = a(); return [1, _]", true);
32
- test("(1+ +1)", "_ = +1; _ = 1 + _; _ = (_); return [1, _]", true);
33
- test("await a(await b)", "_ = b; return [1, _]; _ = a(_); return [1, _]", true);
34
- test("await a(await b).s(await c)", "_ = b; return [1, _]; _ = a(_); _0 = c; return [1, _0]; _ = _.s(_0); return [1, _]", true);
35
- test("a*a + await a(await b).s(await c)", "_ = a * a; _0 = b; return [1, _0]; _0 = a(_0); _1 = c; return [1, _1]; _0 = _0.s(_1); return [1, _0]; _ = _ + _0; return [1, _]", true);
36
- test("a*a + await a(await b(await c)).s(await c)", "_ = a * a; _0 = c; return [1, _0]; _0 = b(_0); return [1, _0]; _0 = a(_0); _1 = c; return [1, _1]; _0 = _0.s(_1); return [1, _0]; _ = _ + _0; return [1, _]", true);
37
- test("await a, await b", "_ = a; return [1, _]; _ = b; return [1, _]", true);
38
- test("await a * b, await b", "_ = a; return [1, _]; _ = _ * b; return [1, _]; _ = b; return [1, _]", true);
39
- test("if(a) await b", "if (!a) return [1]; _ = b; return [1, _]", true);
40
- test("if(a) await b; else await c", "if (!a) return [1]; _ = b; return [2, _]; _ = c; return [1, _]", true);
41
- test("if(a) await b; else if(e) await c", "if (!a) return [1]; _ = b; return [2, _]; if (!e) return [1]; _ = c; return [1, _]", true);
42
- test("if(a) await b; else if(e) await c else await d", "if (!a) return [1]; _ = b; return [3, _]; if (!e) return [1]; _ = c; return [2, _]; _ = d; return [1, _]", true);
43
- test("if(await a) await b", "_ = a; return [1, _]; if (!_) return [1]; _ = b; return [1, _]", true);
44
- test("for(a=0;a<10;a++) await a", "a = 0; return [1]; _ = a < 10; if (!_) return [3]; _ = a; return [1, _]; _ = a++; return [-2]", true);
45
- test("for(a=0;a<10;a++) await a, await b", "a = 0; return [1]; _ = a < 10; if (!_) return [4]; _ = a; return [1, _]; _ = b; return [1, _]; _ = a++; return [-3]", true);
46
- test("while(a) await b", "_ = a; if (!_) return [3]; _ = b; return [1, _]; return [-2]", true);
47
- test("do{await b}while(a)", "_ = b; return [1, _]; _ = a; return [_ ? -2 : 1]", true);
48
- test("switch(a){case 1:}", "_ = a; _0 = 1; if (_ === _0) return [1]", true);
49
- test("switch(a){case 1:break;}", "_ = a; _0 = 1; if (_ === _0) return [1]; return [1]", true);
50
- test("switch(a){case 1:break;case 2:break;}", "_ = a; _0 = 1; if (_ === _0) return [2]; _0 = 2; if (_ === _0) return [2]; return [2]; return [1]", true);
51
- test("switch(a){case 1:case 2:break;}", "_ = a; _0 = 1; if (_ === _0) return [2]; _0 = 2; if (_ === _0) return [1]; return [1]", true);
52
- test("switch(a){case 1:case 2:x=1;}", "_ = a; _0 = 1; if (_ === _0) return [2]; _0 = 2; if (_ === _0) return [1]; x = 1", true);
53
- test("switch(a){case 1:case 2:x=1;}", "_ = a; _0 = 1; if (_ === _0) return [2]; _0 = 2; if (_ === _0) return [1]; x = 1", true);
33
+ test("await a", "_ = a; return [_, 1]", true);
34
+ test("await a()", "_ = a(); return [_, 1]", true);
35
+ test("(1+ +1)", "_ = +1, _ = 1 + _; _ = (_)", true);
36
+ test("await a(await b)", "_ = b; return [_, 1]; _ = @; _ = a(_); return [_, 1]", true);
37
+ test("await a(await b).s(await c)", "_ = b; return [_, 1]; _ = @; _ = a(_); _0 = c; return [_0, 1]; _0 = @; _ = _.s(_0); return [_, 1]", true);
38
+ test("a*a + await a(await b).s(await c)", "_ = a * a; _0 = b; return [_0, 1]; _0 = @; _0 = a(_0); _1 = c; return [_1, 1]; _1 = @; _0 = _0.s(_1); return [_0, 1]; _0 = @; _ = _ + _0", true);
39
+ test("a*a + await a(await b(await c)).s(await c)", "_ = a * a; _0 = c; return [_0, 1]; _0 = @; _0 = b(_0); return [_0, 1]; _0 = @; _0 = a(_0); _1 = c; return [_1, 1]; _1 = @; _0 = _0.s(_1); return [_0, 1]; _0 = @; _ = _ + _0", true);
40
+ test("await a, await b", "_ = a; return [_, 1]; _ = b; return [_, 1]", true);
41
+ test("await a * b, await b", "_ = a; return [_, 1]; _ = @; _ = _ * b; _ = b; return [_, 1]", true);
42
+ test("if(a);", "", true);
43
+ test("if(a) await b", "if (!a) return [1, 0]; _ = b; return [_, 1]", true);
44
+ test("if(a) await b; else await c", "if (!a) return [2, 0]; _ = b; return [_, 1]; return [2, 0]; _ = c; return [_, 1]", true);
45
+ test("if(a) b; else await c", "if (!a) return [1, 0]; _ = b; return [2, 0]; _ = c; return [_, 1]", true);
46
+ test("if(a) await b; else if(e) await c", "if (!a) return [2, 0]; _ = b; return [_, 1]; return [2, 0]; if (!e) return [1, 0]; _ = c; return [_, 1]", true);
47
+ test("if(a) await b; else if(e) await c else await d", "if (!a) return [2, 0]; _ = b; return [_, 1]; return [4, 0]; if (!e) return [2, 0]; _ = c; return [_, 1]; return [2, 0]; _ = d; return [_, 1]", true);
48
+ test("if(await a) await b", "_ = a; return [_, 1]; if (!_) return [1, 0]; _ = b; return [_, 1]", true);
49
+ test("for(a=0;a<10;a++) await a", "a = 0; return [1, 0]; _ = a < 10; if (!_) return [3, 0]; _ = a; return [_, 1]; _ = a++; return [-2, 0]", true);
50
+ test("for(a=0;a<10;a++) await a, await b", "a = 0; return [1, 0]; _ = a < 10; if (!_) return [4, 0]; _ = a; return [_, 1]; _ = b; return [_, 1]; _ = a++; return [-3, 0]", true);
51
+ test("while(a) await b", "_ = a; if (!_) return [3, 0]; _ = b; return [_, 1]; return [-2, 0]", true);
52
+ test("do{await b}while(a)", "_ = b; return [_, 1]; _ = a; return [_ ? -2 : 1, 0]", true);
53
+ test("switch(a){case 1:}", "_ = a; _0 = 1; if (_ === _0) return [1, 0]", true);
54
+ test("switch(a){case 1:break;}", "_ = a; _0 = 1; if (_ === _0) return [1, 0]; return [1, 0]", true);
55
+ test("switch(a){case 1:break;case 2:break;}", "_ = a; _0 = 1; if (_ === _0) return [1, 0]; _0 = 2; if (_ === _0) return [2, 0]; return [2, 0]; return [1, 0]", true);
56
+ test("switch(a){case 1:case 2:break;}", "_ = a; _0 = 1; if (_ === _0) return [1, 0]; _0 = 2; if (_ === _0) return [1, 0]; return [1, 0]", true);
57
+ test("switch(a){case 1:case 2:x=1;}", "_ = a; _0 = 1; if (_ === _0) return [1, 0]; _0 = 2; if (_ === _0) return [1, 0]; x = 1", true);
58
+ test("switch(a){case 1:case 2:x=1;}", "_ = a; _0 = 1; if (_ === _0) return [1, 0]; _0 = 2; if (_ === _0) return [1, 0]; x = 1", true);
54
59
  test("with(a){ a = 1}", `_ = a; if (_0 = with_("a", [_])) _0.a = 1; else a = 1;`, true);
60
+ test("try{a=2+1}catch(e){}", 'return [65536, 7]; _ = 2 + 1, a = _; return [0, 9]; e = @; return [1, 9]', true);
61
+ test("try{a=2+1}catch(e){a=3}", 'return [65536, 7]; _ = 2 + 1, a = _; return [0, 9]; e = @; a = 3; return [1, 9]', true);
@@ -78,7 +78,7 @@ function alert() {
78
78
  };
79
79
  waitclose(autoclose, 400)
80
80
  elem.setText = function (content, timeout = true) {
81
- var c = elem.children[0];
81
+ var c = elem;
82
82
  c.innerHTML = content;
83
83
  text = content;
84
84
  if (timeout) {
@@ -1,4 +1,4 @@
1
-
1
+ "use strict";
2
2
  var _create = function (commFactory, className, _invoke) {
3
3
  if (!className) return commFactory;
4
4
  if (commFactory instanceof Promise) {
@@ -1,5 +1,5 @@
1
1
  <template -if='hasIcon?'>
2
- <i -class="icon?" -style="{color:menu.color}"></i>
2
+ <i -class="menu.icon" -style="{color:menu.color}"></i>
3
3
  <template -if="menu.name">
4
4
  &nbsp;&nbsp;
5
5
  </template>
@@ -19,7 +19,7 @@ function main(elem, scope, hasIcon) {
19
19
  menu,
20
20
  checker,
21
21
  };
22
- if (hasIcon) scope.hasIcon = true;
22
+ if (hasIcon || menu.icon) scope.hasIcon = true;
23
23
  render(item.children, scope);
24
24
  if (menu.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
25
25
  return item;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.36.5",
3
+ "version": "3.36.6",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {