efront 3.38.1 → 4.0.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.
@@ -2,7 +2,7 @@ var downLevel = require("./downLevel");
2
2
  var _asert = assert, i = 10;
3
3
  assert = function (a, b) {
4
4
  var d = 1;
5
- b = b.split(/(?<!\r)\n/), d = b.length, b = b.join("\r\n");
5
+ b = b.split(/(?<!\r)\n/), d = b["length"], b = b["join"]("\r\n");
6
6
  _asert(a, b, i);
7
7
  i += d;
8
8
  }
@@ -54,27 +54,27 @@ assert(downLevel(`function (arg1=b,[c],d,e=f){}`), "function (arg1, arg2, d, e)
54
54
  i++// class降级
55
55
  assert(downLevel(`class a {}`), "function a() {}")
56
56
  assert(downLevel(`class a {a=1}`), "function a() { this.a = 1 }")
57
- assert(downLevel(`class a {a=1; b(){}}`), "function a() { this.a = 1; }; a.prototype.b = function () {}")
58
- assert(downLevel(`=class a {a=1; b(){}}`), "= function (a) { a.prototype.b = function () {}\r\nreturn a }(function a() { this.a = 1; })")
59
- assert(downLevel(`var a=class {a=1; static b=2 b(){}};`), "var a = function (cls0) { cls0.b = 2\r\ncls0.prototype.b = function () {}\r\nreturn cls0 }(function () { this.a = 1; });")
60
- assert(downLevel(`var a=class { constructor(){this.a=1}; static b=2 b(){}};`), "var a = function (cls0) { cls0.b = 2\r\ncls0.prototype.b = function () {}\r\nreturn cls0 }(function () { this.a = 1 });")
57
+ assert(downLevel(`class a {a=1; b(){}}`), `function a() { this.a = 1; }; a["prototype"].b = function () {}`)
58
+ assert(downLevel(`=class a {a=1; b(){}}`), `= function (a) { a["prototype"].b = function () {}\r\nreturn a }(function a() { this.a = 1; })`)
59
+ assert(downLevel(`var a=class {a=1; static b=2 b(){}};`), `var a = function (cls0) { cls0.b = 2\r\ncls0["prototype"].b = function () {}\r\nreturn cls0 }(function () { this.a = 1; });`)
60
+ assert(downLevel(`var a=class { constructor(){this.a=1}; static b=2 b(){}};`), `var a = function (cls0) { cls0.b = 2\r\ncls0["prototype"].b = function () {}\r\nreturn cls0 }(function () { this.a = 1 });`)
61
61
  assert(downLevel(`class a {static b(){}}`), "function a() {}; a.b = function () {}")
62
62
  assert(downLevel(`class a extends b{}`), `function a() {
63
- var this_ = b.apply(this, arguments) || this;
63
+ var this_ = b["apply"](this, arguments) || this;
64
64
  return this_ }; extends_(a, b)`);
65
65
  assert(downLevel(`class a extends class b{}{}`), `var a = function (b, a) { extends_(a, b)\r\nreturn a }(function b() {}, function a() {
66
- var this_ = b.apply(this, arguments) || this;
66
+ var this_ = b["apply"](this, arguments) || this;
67
67
  return this_ })`);
68
68
  assert(downLevel(`class a {get a(){}}`), `function a() {};
69
- Object.defineProperty(a.prototype, "a", { get: function () {} })`);
69
+ Object["defineProperty"](a["prototype"], "a", { get: function () {} })`);
70
70
  assert(downLevel(`class a {set a(){}}`), `function a() {};
71
- Object.defineProperty(a.prototype, "a", { set: function () {} })`);
71
+ Object["defineProperty"](a["prototype"], "a", { set: function () {} })`);
72
72
  assert(downLevel(`class a {get a(){}; get b(){}; set a(){}}`), `function a() {};
73
- Object.defineProperty(a.prototype, "a", { get: function () {}, set: function () {} });
74
- Object.defineProperty(a.prototype, "b", { get: function () {} });`);
73
+ Object["defineProperty"](a["prototype"], "a", { get: function () {}, set: function () {} });
74
+ Object["defineProperty"](a["prototype"], "b", { get: function () {} });`);
75
75
  assert(downLevel(`class a {set a(){}; get b(){}; set a(){}}`), `function a() {};
76
- Object.defineProperty(a.prototype, "a", { set: function () {}, set: function () {} });
77
- Object.defineProperty(a.prototype, "b", { get: function () {} });`);
76
+ Object["defineProperty"](a["prototype"], "a", { set: function () {}, set: function () {} });
77
+ Object["defineProperty"](a["prototype"], "b", { get: function () {} });`);
78
78
  i++// 属性降级
79
79
  assert(downLevel(`return ({b,async a(){}})`), `return ((_ = {},
80
80
  _.b = b,
@@ -132,38 +132,37 @@ assert(downLevel(`={...{},...c,b}`), `= (_ = extend({}, {}, c),
132
132
  _.b = b, _)\r\nvar _`);
133
133
  assert(downLevel(`={a(){},get c(){},b}`), `= (_ = {},
134
134
  _.a = function () {},
135
- Object.defineProperty(_, "c", { get: function () {} }),
135
+ Object["defineProperty"](_, "c", { get: function () {} }),
136
136
  _.b = b, _)\r\nvar _`);
137
- assert(downLevel(`=[...a]`), `= Array.prototype.slice.call(a)`)
138
- assert(downLevel(`let a = [...a,...a()];`), `var a = (slice_ = Array.prototype.slice).call(a).concat(slice_.call(a()));
139
- var slice_`)
140
- assert(downLevel(`=[...a,...b]`), `= (slice_ = Array.prototype.slice).call(a).concat(slice_.call(b))\r\nvar slice_`)
141
- assert(downLevel(`=[a,...b]`), `= [a].concat(Array.prototype.slice.call(b))`)
142
- assert(downLevel(`=[a,...b,...c]`), `= [a].concat((slice_ = Array.prototype.slice).call(b), slice_.call(c))\r\nvar slice_`)
143
- assert(downLevel(`=[a,b,...c]`), `= [a, b].concat(Array.prototype.slice.call(c))`)
144
- assert(downLevel(`=[a,b,...c,d]`), `= [a, b].concat(Array.prototype.slice.call(c), [d])`)
145
- assert(downLevel(`=[a,b,...c,d,e,f]`), `= [a, b].concat(Array.prototype.slice.call(c), [d, e, f])`)
146
- assert(downLevel(`=[a,b,...c,d,e,f,...g]`), `= [a, b].concat((slice_ = Array.prototype.slice).call(c), [d, e, f], slice_.call(g))\r\nvar slice_`)
147
- assert(downLevel(`=[a,b,...c,d,...e]`), `= [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e))\r\nvar slice_`)
148
- assert(downLevel(`a(...b)`), `a.apply(null, b)`)
149
- assert(downLevel(`a(c,d,e,...b(...c))`), `a.apply(null, [c, d, e].concat(Array.prototype.slice.call(b.apply(null, c))))`)
150
- assert(downLevel(`a(c,d,e,...b.a(...c))`), `a.apply(null, [c, d, e].concat(Array.prototype.slice.call(b.a.apply(b, c))))`)
151
- assert(downLevel(`a(c,d,e,...b.a.c(...c))`), `a.apply(null, [c, d, e].concat(Array.prototype.slice.call((_ = b.a).c.apply(_, c))))\r\nvar _`)
152
- assert(downLevel(`a(...b,...c)`), `a.apply(null, (slice_ = Array.prototype.slice).call(b).concat(slice_.call(c)))\r\nvar slice_`)
153
- assert(downLevel(`a(...b,c)`), `a.apply(null, Array.prototype.slice.call(b).concat([c]))`)
154
- assert(downLevel(`getPendingExpressions()[_push](...flattenCommaList(expr));`), `(_ = getPendingExpressions())[_push].apply(_, flattenCommaList(expr));\r\nvar _`)
155
- assert(downLevel(`a(b,...c)`), `a.apply(null, [b].concat(Array.prototype.slice.call(c)))`)
156
- assert(downLevel(`a(a,b,...c,d,...e)`), `a.apply(null, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))\r\nvar slice_`)
157
- assert(downLevel(`a.call(a,b,...c,d,...e)`), `a.call.apply(a, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))\r\nvar slice_`)
158
- assert(downLevel(`a.b(a,b,...c,d,...e)`), `a.b.apply(a, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))\r\nvar slice_`)
159
- assert(downLevel(`[].b(a,b,...c,d,...e)`), `(_ = []).b.apply(_, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))\r\nvar _, slice_`)
160
- assert(downLevel(`a(...b).c(...d)`), `(_ = a.apply(null, b)).c.apply(_, d)\r\nvar _`)
161
- assert(downLevel(`a(...b).c(...d).e(...f)`), `(_ = (_ = a.apply(null, b)).c.apply(_, d)).e.apply(_, f)\r\nvar _`)
162
- assert(downLevel(`diagnostic.relatedInformation.push(...relatedInformation);`), `(_ = diagnostic.relatedInformation).push.apply(_, relatedInformation);\r\nvar _`);
163
- assert(downLevel(`const typeNames = [79 /* Identifier */, ...typeKeywords];`), `var typeNames = [79 /* Identifier */].concat(Array.prototype.slice.call(typeKeywords));`);
137
+ assert(downLevel(`=[...a]`), `var slice_ = Array["prototype"]["slice"];\r\n= slice_["call"](a)`)
138
+ assert(downLevel(`let a = [...a,...a()];`), `var slice_ = Array["prototype"]["slice"];\r\nvar a = slice_["call"](a)["concat"](slice_["call"](a()));`)
139
+ assert(downLevel(`=[...a,...b]`), `var slice_ = Array["prototype"]["slice"];\r\n= slice_["call"](a)["concat"](slice_["call"](b))`)
140
+ assert(downLevel(`=[a,...b]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a]["concat"](slice_["call"](b))`)
141
+ assert(downLevel(`=[a,...b,...c]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a]["concat"](slice_["call"](b), slice_["call"](c))`)
142
+ assert(downLevel(`=[a,b,...c]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a, b]["concat"](slice_["call"](c))`)
143
+ assert(downLevel(`=[a,b,...c,d]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a, b]["concat"](slice_["call"](c), [d])`)
144
+ assert(downLevel(`=[a,b,...c,d,e,f]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a, b]["concat"](slice_["call"](c), [d, e, f])`)
145
+ assert(downLevel(`=[a,b,...c,d,e,f,...g]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a, b]["concat"](slice_["call"](c), [d, e, f], slice_["call"](g))`)
146
+ assert(downLevel(`=[a,b,...c,d,...e]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a, b]["concat"](slice_["call"](c), [d], slice_["call"](e))`)
147
+ assert(downLevel(`a(...b)`), `a["apply"](null, b)`)
148
+ assert(downLevel(`a(c,d,e,...b(...c))`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [c, d, e]["concat"](slice_["call"](b["apply"](null, c))))`)
149
+ assert(downLevel(`a(c,d,e,...b.a(...c))`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [c, d, e]["concat"](slice_["call"](b.a["apply"](b, c))))`)
150
+ assert(downLevel(`a(c,d,e,...b.a.c(...c))`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [c, d, e]["concat"](slice_["call"]((_ = b.a).c["apply"](_, c))))\r\nvar _`)
151
+ assert(downLevel(`a(...b,...c)`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, slice_["call"](b)["concat"](slice_["call"](c)))`)
152
+ assert(downLevel(`a(...b,c)`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, slice_["call"](b)["concat"]([c]))`)
153
+ assert(downLevel(`getPendingExpressions()[_push](...flattenCommaList(expr));`), `(_ = getPendingExpressions())[_push]["apply"](_, flattenCommaList(expr));\r\nvar _`)
154
+ assert(downLevel(`a(b,...c)`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [b]["concat"](slice_["call"](c)))`)
155
+ assert(downLevel(`a(a,b,...c,d,...e)`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [a, b]["concat"](slice_["call"](c), [d], slice_["call"](e)))`)
156
+ assert(downLevel(`a["call"](a,b,...c,d,...e)`), `var slice_ = Array["prototype"]["slice"];\r\na["call"]["apply"](a, [a, b]["concat"](slice_["call"](c), [d], slice_["call"](e)))`)
157
+ assert(downLevel(`a.b(a,b,...c,d,...e)`), `var slice_ = Array["prototype"]["slice"];\r\na.b["apply"](a, [a, b]["concat"](slice_["call"](c), [d], slice_["call"](e)))`)
158
+ assert(downLevel(`[].b(a,b,...c,d,...e)`), `var slice_ = Array["prototype"]["slice"];\r\n(_ = []).b["apply"](_, [a, b]["concat"](slice_["call"](c), [d], slice_["call"](e)))\r\nvar _`)
159
+ assert(downLevel(`a(...b).c(...d)`), `(_ = a["apply"](null, b)).c["apply"](_, d)\r\nvar _`)
160
+ assert(downLevel(`a(...b).c(...d).e(...f)`), `(_ = (_ = a["apply"](null, b)).c["apply"](_, d)).e["apply"](_, f)\r\nvar _`)
161
+ assert(downLevel(`diagnostic.relatedInformation.push(...relatedInformation);`), `(_ = diagnostic.relatedInformation).push["apply"](_, relatedInformation);\r\nvar _`);
162
+ assert(downLevel(`const typeNames = [79 /* Identifier */, ...typeKeywords];`), `var slice_ = Array["prototype"]["slice"];\r\nvar typeNames = [79 /* Identifier */]["concat"](slice_["call"](typeKeywords));`);
164
163
  i++// 箭头函数
165
164
  assert(downLevel(`a=>k`), "function (a) { return k }")
166
- assert(downLevel(`function (a,...b,b){}`), "function (a, b) { b = arguments.length > 1 ? arguments[arguments.length - 1] : undefined; }")
165
+ assert(downLevel(`function (a,...b,b){}`), `function (a, b) { b = arguments["length"] > 1 ? arguments[arguments["length"] - 1] : undefined; }`)
167
166
  assert(downLevel(`(a)=>k`), "function (a) { return k }")
168
167
  assert(downLevel(`(a=1)=>k`), "function (a) { if (a === undefined) a = 1; return k }")
169
168
  assert(downLevel(`([a])=>b`), "function (arg) { var a = arg[0]; return b }")
@@ -171,31 +170,36 @@ assert(downLevel(`map(([a])=>a)`), "map(function (arg) { var a = arg[0]; return
171
170
  assert(downLevel(`var [_, R, G, B, A] = rgbHex.exec(color).map(a => parseInt(a + a, 16));`), "var _0 = rgbHex.exec(color).map(function (a) { return parseInt(a + a, 16) }), _ = _0[0], R = _0[1], G = _0[2], B = _0[3], A = _0[4];")
172
171
  assert(downLevel(`if (/^(?:select|input|textarea)$/i.test(initialEvent.target.tagName) || getTargetIn(a => a.nodrag || a.hasAttribute('nodrag'), initialEvent.target)) return;`), "if (/^(?:select|input|textarea)$/i.test(initialEvent.target.tagName) || getTargetIn(function (a) { return a.nodrag || a.hasAttribute('nodrag') }, initialEvent.target)) return;")
173
172
  i++// 对象收集
174
- assert(downLevel(`function (a,...b){}`), "function (a) { var b = Array.prototype.slice.call(arguments, 1); }")
175
- assert(downLevel(`function (a,...b,c){}`), "function (a, c) { var b = Array.prototype.slice.call(arguments, 1, -1); c = arguments.length > 1 ? arguments[arguments.length - 1] : undefined; }")
176
- assert(downLevel(`function (a,...,c){}`), "function (a, c) { c = arguments.length > 1 ? arguments[arguments.length - 1] : undefined; }")
177
- assert(downLevel(`(...a) => k`), "function () { var a = Array.prototype.slice.call(arguments, 0); return k }")
178
- assert(downLevel(`for(o of os) noSymbol`), "for (_ = 0, _0 = os.length; _ < _0 && (o = os[_], true); _++) noSymbol\r\nvar _, _0")
179
- assert(downLevel(`for(var o of os) Symbol`), "for (var o, _0 = os[Symbol.iterator] || os[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], _0 = _0.call(os), _ = _0.next(); !_.done && (o = _.value, true); _ = _0.next()) Symbol\r\nvar _, _0")
180
- assert(downLevel(`for(var o of os) Symbol`), "for (var o, _0 = os[Symbol.iterator] || os[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], _0 = _0.call(os), _ = _0.next(); !_.done && (o = _.value, true); _ = _0.next()) Symbol\r\nvar _, _0")
181
- assert(downLevel(`for(var o of o)Symbol`), "for (var o, _1 = o, _0 = _1[Symbol.iterator] || _1[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], _0 = _0.call(_1), _ = _0.next(); !_.done && (o = _.value, true); _ = _0.next()) Symbol\r\nvar _, _0, _1")
182
- assert(downLevel(`for(var [a] of os)Symbol`), "for (var a, _0 = os[Symbol.iterator] || os[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], _0 = _0.call(os), _ = _0.next(); !_.done && (a = _.value[0], true); _ = _0.next()) Symbol\r\nvar _, _0")
183
- assert(downLevel(`for(var [a,b] of os)Symbol`), "for (var a, b, _0 = os[Symbol.iterator] || os[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], _0 = _0.call(os), _ = _0.next(); !_.done && (_1 = _.value, a = _1[0], b = _1[1], true); _ = _0.next()) Symbol\r\nvar _, _0, _1")
184
- assert(downLevel(`[...a]=a`), "a = Array.prototype.slice.call(a, 0)")
185
- assert(downLevel(`[c,...a]=a`), "c = a[0], a = Array.prototype.slice.call(a, 1)")
186
- assert(downLevel(`[...a]=a`), "a = Array.prototype.slice.call(a, 0)")
187
- assert(downLevel(`[...a,c]=a`), "_ = a, a = Array.prototype.slice.call(a, 0, -1), c = _.length > 1 ? _[_.length - 1] : undefined\r\nvar _")
173
+ assert(downLevel(`function (a,...b){}`), `var slice_ = Array["prototype"]["slice"];\r\nfunction (a) { var b = slice_["call"](arguments, 1); }`)
174
+ assert(downLevel(`function (a,...b,c){}`), `var slice_ = Array["prototype"]["slice"];\r\nfunction (a, c) { var b = slice_["call"](arguments, 1, -1); c = arguments["length"] > 1 ? arguments[arguments["length"] - 1] : undefined; }`)
175
+ assert(downLevel(`function (a,...,c){}`), `function (a, c) { c = arguments["length"] > 1 ? arguments[arguments["length"] - 1] : undefined; }`)
176
+ assert(downLevel(`(...a) => k`), `var slice_ = Array["prototype"]["slice"];\r\nfunction () { var a = slice_["call"](arguments, 0); return k }`)
177
+ assert(downLevel(`for(o of os) noSymbol`), `for (_ = 0, _0 = os["length"]; _ < _0 && (o = os[_], true); _++) noSymbol\r\nvar _, _0`)
178
+ assert(downLevel(`for(var o of os) Symbol`), `for (var o, _0 = os[Symbol["iterator"]] || os[Symbol["asyncIterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol\r\nvar _, _0`)
179
+ assert(downLevel(`for(var o of os) Symbol`), `for (var o, _0 = os[Symbol["iterator"]] || os[Symbol["asyncIterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol\r\nvar _, _0`)
180
+ assert(downLevel(`for(var o of o)Symbol`), `for (var o, _1 = o, _0 = _1[Symbol["iterator"]] || _1[Symbol["asyncIterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](_1), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol\r\nvar _, _0, _1`)
181
+ assert(downLevel(`for(var [a] of os)Symbol`), `for (var a, _0 = os[Symbol["iterator"]] || os[Symbol["asyncIterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (a = _["value"][0], true); _ = _0["next"]()) Symbol\r\nvar _, _0`)
182
+ assert(downLevel(`for(var [a,b] of os)Symbol`), `for (var a, b, _0 = os[Symbol["iterator"]] || os[Symbol["asyncIterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (_1 = _["value"], a = _1[0], b = _1[1], true); _ = _0["next"]()) Symbol\r\nvar _, _0, _1`)
183
+ assert(downLevel(`[...a]=a`), `var slice_ = Array["prototype"]["slice"];\r\na = slice_["call"](a, 0)`)
184
+ assert(downLevel(`[c,...a]=a`), `var slice_ = Array["prototype"]["slice"];\r\nc = a[0], a = slice_["call"](a, 1)`)
185
+ assert(downLevel(`[...a]=a`), `var slice_ = Array["prototype"]["slice"];\r\na = slice_["call"](a, 0)`)
186
+ assert(downLevel(`[...a,c]=a`), `var slice_ = Array["prototype"]["slice"];\r\n_ = a, a = slice_["call"](a, 0, -1), c = _["length"] > 1 ? _[_["length"] - 1] : undefined\r\nvar _`)
188
187
  assert(downLevel(`{...a,c}=a`), `c = a.c, a = rest_(a, ["c"])`)
189
188
  assert(downLevel(`{c,...a}=a`), `c = a.c, a = rest_(a, ["c"])`)
190
189
  assert(downLevel("if(a){}[r, g, b] = rgb4s(r, g, b, s)"), "if (a) {} _ = rgb4s(r, g, b, s), r = _[0], g = _[1], b = _[2]\r\nvar _", true);
191
190
  assert(downLevel(`{c,[c]:b,...a}=a`), `c = a.c, b = a[c], a = rest_(a, ["c", c])`)
191
+ assert(downLevel(`async()=>name = require("./$split")(name)["join"]("/");`), `function () { return async_(
192
+ function () {
193
+ _0 = require("./$split")(name)["join"]("/"); name = _0; return [_0, 2]
194
+ })
195
+ var _0 };`);
192
196
  i++//异步或步进函数
193
197
  assert(downLevel(`function *(){yield *a}`), `function () { return aster_(
194
198
  function () {
195
- _; _0 = 0; _3 = a.length; _1 = _3; return [1, 0]
199
+ _; _0 = 0; _3 = a["length"]; _1 = _3; return [1, 0]
196
200
  },
197
201
  function () {
198
- _3 = _0 < _1; if (!_3) return [1, 0]; _4 = a[_0]; _ = _4; _3 = (_4, true)
202
+ _3 = _0 < _1; if (!_3) return [1, 0]; _4 = a[_0]; _ = _4; _3 = (true)
199
203
  },
200
204
  function () {
201
205
  if (!_3) return [2, 0]; return [_, 3]
@@ -207,16 +211,16 @@ var _, _0, _1, _3, _4 }`)
207
211
  assert(downLevel(`async function(){}`), `function () { return async_() }`)
208
212
  assert(downLevel(`async function(){for(var a of b){Symbol}}`), `function () { return async_(
209
213
  function () {
210
- a; _3 = Symbol.iterator; _2 = b[_3]; if (_2) return [1, 0]; _3 = Symbol.asyncIterator; _2 = b[_3]; if (_2) return [1, 0]; _3 = Symbol.iterator; _2 = Array.prototype[_3]
214
+ a; _3 = Symbol["iterator"]; _2 = b[_3]; if (_2) return [1, 0]; _3 = Symbol["asyncIterator"]; _2 = b[_3]; if (_2) return [1, 0]; _3 = Symbol["iterator"]; _2 = Array["prototype"][_3]
211
215
  },
212
216
  function () {
213
- _0 = _2; _2 = _0.call(b); _0 = _2; _2 = _0.next(); _ = _2; return [1, 0]
217
+ _0 = _2; _2 = _0["call"](b); _0 = _2; _2 = _0["next"](); _ = _2; return [1, 0]
214
218
  },
215
219
  function () {
216
- _2 = !_.done; if (!_2) return [1, 0]; _3 = _.value; a = _3; _2 = (_3, true)
220
+ _2 = !_["done"]; if (!_2) return [1, 0]; _3 = _["value"]; a = _3; _2 = (true)
217
221
  },
218
222
  function () {
219
- if (!_2) return [1, 0]; Symbol; _2 = _0.next(); _ = _2; return [-1, 0]
223
+ if (!_2) return [1, 0]; Symbol; _2 = _0["next"](); _ = _2; return [-1, 0]
220
224
  })
221
225
  var a, _, _0, _2, _3 }`)
222
226
  assert(downLevel(`a={async a(){var b =c;return 1}}`), `a = (_ = {},
@@ -126,6 +126,24 @@ class Code extends Array {
126
126
  set scoped(w) {
127
127
  this._scoped = w;
128
128
  }
129
+ get occurs() {
130
+ var rest = [this.scoped];
131
+ var occurs = Object.create(null);
132
+ Object.assign(occurs, this.scoped.envs);
133
+ while (rest.length) {
134
+ var scoped = rest.pop();
135
+ for (var k in scoped.vars) {
136
+ if (k in occurs) continue;
137
+ occurs[k] = true;
138
+ }
139
+ for (var k in scoped.lets) {
140
+ if (k in occurs) continue;
141
+ occurs[k] = true;
142
+ }
143
+ rest.push(...scoped);
144
+ }
145
+ return occurs;
146
+ }
129
147
  getUndecleared() {
130
148
  var res = Object.create(null);
131
149
  for (var k in this.envs) {
@@ -438,6 +438,17 @@ var remove_end_comma = function (o) {
438
438
  o.splice(cx, cx + 1);
439
439
  }
440
440
  };
441
+ var isEvalScope = function (o) {
442
+ if (o.entry === "[") {
443
+ var h = snapExpressHead(o);
444
+ return o !== h;
445
+ }
446
+ else if (o.entry === '(') {
447
+ var h = snapExpressHead(o);
448
+ return o === h;
449
+ }
450
+ return false;
451
+ }
441
452
  var _invoke = function (t, getname) {
442
453
  var nameindex = 0;;
443
454
  var getdeepname = function (deep = 0) {
@@ -464,6 +475,7 @@ var _invoke = function (t, getname) {
464
475
  if (o.type === SCOPED && (o.entry === '[' || o.entry === "(")) {
465
476
  var _nameindex = nameindex;
466
477
  remove_end_comma(o);
478
+ var iseval = isEvalScope(o);
467
479
  for (var cy = 0; cy < o.length; cy++) {
468
480
  if (o[cy].type & (SPACE | COMMENT)) continue;
469
481
  var by = cy;
@@ -477,10 +489,17 @@ var _invoke = function (t, getname) {
477
489
  }
478
490
  var q = toqueue(m, getdeepname, true);
479
491
  var qe = q[q.length - 1];
480
- o.splice(by, cy - by, { text: qe.name, type: EXPRESS });
481
- cy -= cy - by - 1;
482
- nameindex++;
492
+ if (!iseval || m[m.length - 1] === o.last) {
493
+ splice(o, by, cy - by, { text: qe.name, type: EXPRESS });
494
+ cy = by + 1;
495
+ }
496
+ else {
497
+ while (o[cy].type & (SPACE | COMMENT)) cy++;
498
+ splice(o, by, cy - by + 1);
499
+ cy = by;
500
+ }
483
501
  cache.push(...q);
502
+ nameindex++;
484
503
  }
485
504
  nameindex = _nameindex;
486
505
  if (!cache.length) continue;
@@ -665,6 +684,23 @@ var ternary = function (body, getname, ret) {
665
684
  }
666
685
  return explist;
667
686
  };
687
+ var isFunctionOnly = function (body) {
688
+ for (var cx = 2, dx = body.length; cx < dx; cx++) {
689
+ if (body[cx].type & (SPACE | COMMENT)) continue;
690
+ break;
691
+ }
692
+ var o = body[cx];
693
+ if (!o) return false;
694
+ if (o.type === STRAP && o.text === 'function') {
695
+ while (o && o.entry !== "{") o = body[cx++];
696
+ if (!o) return false;
697
+ }
698
+ else return false;
699
+ for (; cx < dx; cx++) {
700
+ if (!(body[cx].type & (SPACE | COMMENT))) return false;
701
+ }
702
+ return true;
703
+ };
668
704
  var canbeOnce = function (body) {
669
705
  for (var cx = 0, dx = body.length; cx < dx; cx++) {
670
706
  if (body[cx].type & (SPACE | COMMENT)) continue;
@@ -825,7 +861,12 @@ var _express = function (body, getname, ret) {
825
861
  }
826
862
  if (needname) q.name = getname(nameindex);
827
863
  relink(q);
828
- result = _invoke(q, getdeepname);
864
+ if (isFunctionOnly(q)) {
865
+ result = [q];
866
+ }
867
+ else {
868
+ result = _invoke(q, getdeepname);
869
+ }
829
870
  if (hasor) result[result.length - 1].ret_ = true;
830
871
  return result;
831
872
  };
@@ -57,7 +57,7 @@ test("if(await a) await b", "_ = a; return [_, 1];\r\n if (!@) return [2, 0]; _
57
57
  test("for(a in b)", "for (a in b)", true);
58
58
  test("for(var a in b) a.push()", "for (var a in b) a.push()", true);
59
59
  test("for(;;)", "return [0, 0]", true);
60
- test("for(a = os[Symbol.iterator] || os[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], a = a.call(os), b = a.next(); !b.done && (o = b.value, true); b = a.next())", "_0 = Symbol.iterator; _ = os[_0]; if (_) return [1, 0]; _0 = Symbol.asyncIterator; _ = os[_0]; if (_) return [1, 0]; _0 = Symbol.iterator; _ = Array.prototype[_0];\r\n a = _; _ = a.call(os); a = _; _ = a.next(); b = _; return [1, 0];\r\n _ = !b.done; if (!_) return [1, 0]; _0 = b.value; o = _0; _ = (_0, true);\r\n if (!_) return [1, 0]; _ = a.next(); b = _; return [-1, 0]", true);
60
+ test("for(a = os[Symbol.iterator] || os[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], a = a.call(os), b = a.next(); !b.done && (o = b.value, true); b = a.next())", "_0 = Symbol.iterator; _ = os[_0]; if (_) return [1, 0]; _0 = Symbol.asyncIterator; _ = os[_0]; if (_) return [1, 0]; _0 = Symbol.iterator; _ = Array.prototype[_0];\r\n a = _; _ = a.call(os); a = _; _ = a.next(); b = _; return [1, 0];\r\n _ = !b.done; if (!_) return [1, 0]; _0 = b.value; o = _0; _ = (true);\r\n if (!_) return [1, 0]; _ = a.next(); b = _; return [-1, 0]", true);
61
61
  test("for(a=0;a<1;a++)if(a==0)continue", `a = 0; return [1, 0];\r\n _ = a < 1; if (!_) return [2, 0]; _ = a == 0; if (_) return [1, 0]; return [1, 0];\r\n _ = a++; return [-1, 0]`, true);
62
62
  test("for(a=0;a<10;a++) await a", "a = 0; return [1, 0];\r\n _ = a < 10; if (!_) return [2, 0]; _ = a; return [_, 1];\r\n _ = @; _ = a++; return [-1, 0]", true);
63
63
  test("for(a=0;a<10;a++) await a, await b", "a = 0; return [1, 0];\r\n _ = a < 10; if (!_) return [3, 0]; _ = a; return [_, 1];\r\n _ = @; _ = b; return [_, 1];\r\n _ = @; _ = a++; return [-2, 0]", true);
@@ -156,14 +156,14 @@ var formatRows = function (arg, rows, deep, entry, leave) {
156
156
  if (isArray) {
157
157
  for (var cx = 0, dx = rows.length; cx < dx; cx += itemcount) {
158
158
  res.push(rows.slice(cx, cx + itemcount).map((r, i) => {
159
- return Array(maxLength[i] - lens[cx + i] + 1).join(" ") + r;
159
+ return Array(Math.max(maxLength[i] - lens[cx + i], 0)).join(" ") + r;
160
160
  }).join(', '));
161
161
  }
162
162
  }
163
163
  else {
164
164
  for (var cx = 0, dx = rows.length; cx < dx; cx += itemcount) {
165
165
  res.push([rows[cx], ...rows.slice(cx + 1, cx + itemcount).map((r, i) => {
166
- return Array(maxLength[i] - lens[cx + i] + 1).join(" ") + r;
166
+ return Array(Math.max(maxLength[i] - lens[cx + i], 0)).join(" ") + r;
167
167
  })].join(', '));
168
168
  }
169
169
  }
@@ -26,8 +26,8 @@ var checkUnEqual = function (deepEqual) {
26
26
  && !deepEqual({ b: 0 }, { a: 0 })
27
27
  && !deepEqual({ b: 0 }, { a: 0 })
28
28
  && !deepEqual(new Date(1), new Date(2))
29
- && !deepEqual(document.createElement("a"), document.createElement("b"))
30
- && !deepEqual(window, document)
29
+ // && !deepEqual(document.createElement("a"), document.createElement("b"))
30
+ // && !deepEqual(window, document)
31
31
  && !deepEqual(function () { }, function (a) { return a })
32
32
  && !deepEqual({ a: {} }, { a: new Date() })
33
33
  && !deepEqual({ a: { c: {} } }, { a: { b: {} } })
@@ -7,3 +7,5 @@
7
7
  2.x版本 `efront`采用自我编译的形式发布,依赖项基本不变
8
8
 
9
9
  3.x版本 `efront`拥有自建的语法解析器,不再依赖`esprima`、`esmangle`、`escodegen`,自我编译耗时由原来的10分钟github工作流,逐步减少到2分钟左右。
10
+
11
+ 4.0版本 不再依赖`typescipt`(近17万行源码)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.38.1",
3
+ "version": "4.0.0",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {