efront 4.0.29 → 4.0.31

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.
@@ -78,5 +78,5 @@ function parseURL(url) {
78
78
  obj.locate(url);
79
79
  return obj;
80
80
  }
81
- // mdn说__proto__这玩意在deno上不支持,吓我一跳,2023-01-04亲测支持
81
+ // mdn说__proto__这玩意在deno上不支持,吓我一跳,2023-01-04亲测支持, 2023-07-27已不支持
82
82
  module.exports = parseURL;
@@ -508,6 +508,18 @@ var removeImport = function (c, i, code) {
508
508
  }
509
509
  else o = c;
510
510
  var n = o.next;
511
+ var t = null;
512
+ if (n && n.type === EXPRESS) {
513
+ t = Object.create(null);
514
+ var ts = n.text.split(".")
515
+ for (var e of ts) {
516
+ t[e] = true;
517
+ }
518
+ var ni = code.indexOf(n, i);
519
+ removeFromList(used[ts[0]], n);
520
+ splice(code, ni, 1);
521
+ n = n.next;
522
+ }
511
523
  if (!n || n.type !== QUOTED) throw new Error("缺少导入路径!");
512
524
  var oi = code.indexOf(o, i);
513
525
  var ns = skipAssignment(n);
@@ -515,6 +527,7 @@ var removeImport = function (c, i, code) {
515
527
  var q = scan(`require()`);
516
528
  if (!used.require) used.require = [], envs.require = true;
517
529
  used.require.push(q[0]);
530
+ Object.assign(q[0], t);
518
531
  var cs = code.splice(oi + 1, nsi - oi - 1, ...q);
519
532
  q[1].push.apply(q[1], cs);
520
533
  relink(q[1]);
@@ -339,7 +339,9 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
339
339
  splice(queue, i, 0, { type: EXPRESS, text: tmpname }, { type: STAMP, text: "=" });
340
340
  i += 2;
341
341
  var i2 = skipAssignment(queue, i);
342
+ var n = queue[i2];
342
343
  killobj(queue.slice(i, i = i2));
344
+ if (hasnext) splice(queue, i, 1);
343
345
  index++;
344
346
  }
345
347
  for (var o0 of objs) {
@@ -9,6 +9,7 @@ assert = function (a, b) {
9
9
  var innerJs = new Javascript;
10
10
  innerJs.defaultType = common.STRAP;
11
11
  // 声明及解构
12
+ assert(downLevel(`var [data, args, strs] = breakcode(data, occurs), strs = []`), 'var _ = breakcode(data, occurs), data = _[0], args = _[1], strs = _[2], strs = []\r\nvar _');
12
13
  assert(downLevel(`var [name, type, options] = piece, key, repeat;`), 'var name = piece[0], type = piece[1], options = piece[2], key, repeat;');
13
14
  assert(downLevel(`var [] = piece, key,[]= repeat;`), 'var key;');
14
15
  assert(downLevel(`var [] = piece, key,[]`), 'var key');
@@ -319,6 +319,7 @@ function block_code_scanner(index, blocks = [], keepdeep = Infinity) {
319
319
  return tempIndex;
320
320
  };
321
321
  var saved_index = index;
322
+ var start_index = index;
322
323
  var c, deep = 0;
323
324
  var length = this.length;
324
325
  var reg = /[\/\{\}'"`]/g;
@@ -348,8 +349,8 @@ function block_code_scanner(index, blocks = [], keepdeep = Infinity) {
348
349
  // return/a/
349
350
  //switch case break,while continue,break abcd;
350
351
  var tempIndex = lookback.call(this, index - 1);
351
- isReg = tempIndex < 0 || /[[|,+=*~?:&\^{\(\/><;%\-!]/.test(this[tempIndex]);
352
- if (!isReg && tempIndex >= 5) {
352
+ isReg = tempIndex <= start_index || /[[|,+=*~?:&\^{\(\/><;%\-!]/.test(this[tempIndex]);
353
+ if (!isReg && tempIndex >= start_index + 5) {
353
354
  var last_pice = this.slice(Math.max(tempIndex - 50, 0), tempIndex + 1);
354
355
  isReg = /return\s*$|([)};:{]|[^\.\s]\s+)(continue|break|case)\s*$/.test(last_pice);
355
356
  isReg = isReg || /([)};:{]|[^\.\s]\s+)(?:continue|break)\s+([\w\u0100-\u2027\u2030-\uffff]+?)$/.test(last_pice);
@@ -699,6 +699,7 @@ var ternary = function (body, getname, ret) {
699
699
  qe.text = String(explist.length - qi);
700
700
  explist.push(...d);
701
701
  hasquestion = true;
702
+ explist.unshift(...exphead);
702
703
  return explist;
703
704
  }
704
705
  }
@@ -9,6 +9,7 @@ function test(codetext, expect, ret = false) {
9
9
  try { code = unstruct(code, () => ++i >= 0 ? "_" + i : '_', ret && "@"); } catch (e) { console.log(r); throw e }
10
10
  assert(code.map(createString).join(";\r\n "), expect, r++);
11
11
  }
12
+ test('var o = loaded[f.name] = f.isFile() ? new File(p, rebuild, limit) : new Directory(p, rebuild, limit)', "_ = f.name; _0 = f.isFile(); if (!_0) return [1, 0]; _0 = new File(p, rebuild, limit); loaded[_] = _0; o = _0; return [2, 0];\r\n _0 = new Directory(p, rebuild, limit); loaded[_] = _0; o = _0; return [1, 0]");
12
13
  test('a+b', "a + b");
13
14
  test('var a = b', "a = b");
14
15
  test('a + !c', "_ = !c, a + _");
@@ -179,7 +179,7 @@ var format = function (arg, deep = 0) {
179
179
  if (deep > 1) return "<green>" + strings.encode(arg) + "</green>";
180
180
  return arg;
181
181
  }
182
- if (typeof arg === 'function') return `<cyan>[${arg.__proto__.constructor.name}${arg.name ? ": " + arg.name : " (匿名)"}]</cyan>`;
182
+ if (typeof arg === 'function') return `<cyan>[${arg.constructor.name}${arg.name ? ": " + arg.name : " (匿名)"}]</cyan>`;
183
183
  if (/^(number|boolean)$/.test(typeof arg)) return '<yellow>' + arg + "</yellow>";
184
184
  if (arg === undefined) return "<gray>undefined</gray>";
185
185
  if (typeof arg === "object") {
@@ -194,12 +194,12 @@ var format = function (arg, deep = 0) {
194
194
  }
195
195
  if (arg instanceof Buffer || arg instanceof ArrayBuffer || arg instanceof SharedArrayBuffer) {
196
196
  var data = new Uint8Array(arg.buffer || arg, arg.byteOffset || 0, arg.byteLength);
197
- return `<magenta><${arg.__proto__.constructor.name} ${Array.prototype.slice.call(data, 0, 20).map(a => a < 16 ? "0" + a.toString(16) : a.toString(16)).join(' ')}${arg.byteLength > 20 ? ` ... 其他 ${arg.byteLength - 20} 字节` : ''}></megenta>`;
197
+ return `<magenta><${arg.constructor.name} ${Array.prototype.slice.call(data, 0, 20).map(a => a < 16 ? "0" + a.toString(16) : a.toString(16)).join(' ')}${arg.byteLength > 20 ? ` ... 其他 ${arg.byteLength - 20} 字节` : ''}></megenta>`;
198
198
  }
199
199
  else if (isFinite(arg.length)) {
200
200
  var entry = "[";
201
201
  var leave = "]";
202
- entry = `${arg.__proto__.constructor.name}(${arg.length})${entry}`;
202
+ entry = `${arg.constructor.name}(${arg.length})${entry}`;
203
203
  if (arg.length === 0) return entry + leave;
204
204
  if (deep > 3 && deep + arg.length > 5) return `${entry} ... ${leave}`;
205
205
  deepobjs.push(arg);
@@ -110,7 +110,7 @@ var cross = cross_.bind(function (callback, onerror) {
110
110
  overrideMimeType(type) {
111
111
  responseType = type;
112
112
  if (/gb(k|2312|18030)/.test(type)) {
113
- decoder = require("./gbk2utf8");
113
+ decoder = decodeGBK;
114
114
  }
115
115
  },
116
116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.0.29",
3
+ "version": "4.0.31",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {
@@ -10,7 +10,7 @@
10
10
  "efront": "public/efront.js"
11
11
  },
12
12
  "scripts": {
13
- "prepare": "node tools/build-efront.js --uplevel",
13
+ "prepare": "node tools/build-efront.js --uplevel --node --deno",
14
14
  "start": "efront ./efront/ --libs=typescript,esprima,escodegen,esmangle,pngjs,less-node"
15
15
  },
16
16
  "repository": {