efront 4.3.5 → 4.3.7

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.
@@ -103,7 +103,7 @@ inertia.MOVING = 移动;
103
103
  inertia.SLOWING_DWON = 减速;
104
104
  inertia.REBOUNDING = 回弹;
105
105
  inertia.DOCKING = 停靠;
106
- var performance = window.performance;
106
+ var performance = this.performance;
107
107
  if (!performance || !performance.now) performance = Date;
108
108
  var now = performance.now;
109
109
  if (!performance.now) performance.now = function () {
@@ -309,5 +309,3 @@ function main(text) {
309
309
  format();
310
310
  return result;
311
311
  }
312
- window.wordslike = wordslike;
313
- window.words = words;
@@ -2,7 +2,7 @@
2
2
  var languageMap = {};
3
3
  var languageIndex = 0;
4
4
  function i18n(arg) {
5
- if (typeof arg === 'string') arg = arguments;
5
+ if (typeof arg === 'string' || !isArrayLike(arg)) arg = arguments;
6
6
  return arg[isFinite(this) ? this : languageIndex];
7
7
  };
8
8
  i18n.lang = function (type) {
@@ -1,3 +1,4 @@
1
+ var window = this;
1
2
  function isArrayLike(a) {
2
3
  if (a === null || a === window || typeof a !== 'object' || isNode(a)) return false;
3
4
  if (isFinite(a.length)) {
@@ -420,19 +420,6 @@ var snapExpressFoot = function (o) {
420
420
  }
421
421
  return o;
422
422
  };
423
- var mustBeYield = function (o) {
424
- if (!o.next) return;
425
- var mustyield = false;
426
- if (o.next.type === STRAP && !/^(?:instanceof|in|of|from|as)$/.test(o.next.text)
427
- || o.next.type === STAMP && /[!~]/.test(o.next.text)
428
- || o.next.type === EXPRESS && !/^[\.\[]/.test(o.next.text)
429
- || o.next.type & (VALUE | QUOTED | SCOPED)
430
- ) {
431
- mustyield = true;
432
- }
433
- return mustyield;
434
-
435
- }
436
423
  var createScoped = function (parsed, wash) {
437
424
  var used = Object.create(null); var vars = Object.create(null), lets = vars;
438
425
  var scoped = [], funcbody = scoped, argscope = scoped, thisscope = scoped;
@@ -1332,14 +1319,40 @@ var canbeTemp = function (body, strip = false) {
1332
1319
  if (!o) return false;
1333
1320
  return o.type === EXPRESS && (strip || !/[\.\[]/.test(o.text)) || o.type === VALUE || o.type === QUOTED && !o.length;
1334
1321
  };
1335
-
1322
+ var pickArgument = function (o) {
1323
+ var res = [];
1324
+ var t = o && o.prev, p = o;
1325
+ while (t && (t.type !== STAMP || !/^[,;]$/.test(t.text))) {
1326
+ if (p.isprop) {
1327
+ p = t.prev;
1328
+ if (!p || !p.isprop) break;
1329
+ }
1330
+ res.push(t);
1331
+ p = t;
1332
+ t = t.prev;
1333
+ }
1334
+ while (o && (o.type !== STAMP || !/^[,;]$/.test(o.text))) {
1335
+ res.push(o);
1336
+ var n = o;
1337
+ o = o.next;
1338
+ if (o && o.isprop) {
1339
+ if (!n.isprop) break;
1340
+ }
1341
+ }
1342
+ return res;
1343
+ };
1336
1344
  var pickSentence = function (o) {
1337
1345
  if (!o) return [];
1338
1346
  if (o && o.type & (SPACE | COMMENT) && o.prev) o = o.prev;
1339
1347
  if (o && o.type === STAMP && o.prev) o = o.prev;
1340
1348
  if (o.type === STRAP && /^(in|instanceof|as|of)$/.test(o.text) && o.prev) o = o.prev;
1341
1349
  var h = snapSentenceHead(o);
1342
- var e = skipAssignment(h);
1350
+ var e = h;
1351
+ do {
1352
+ e = skipAssignment(e);
1353
+ if (!e || e.type !== STAMP || e.text !== ',') break;
1354
+ e = e.next;
1355
+ } while (e);
1343
1356
  var q = o.queue;
1344
1357
  if (q) {
1345
1358
  var qh = q.indexOf(h);
@@ -1375,6 +1388,7 @@ module.exports = {
1375
1388
  createScoped,
1376
1389
  createExpressList,
1377
1390
  snapSentenceHead,
1391
+ pickArgument,
1378
1392
  pickSentence,
1379
1393
  snapExpressHead,
1380
1394
  snapExpressFoot,
@@ -34,3 +34,6 @@ testPickSentence(`a+b\r\n++c`, 5, "++c")
34
34
  testPickSentence(`a+b++\r\nc`, 5, "c")
35
35
  testPickSentence(`a+b++\r\nc`, 5, "c")
36
36
  testPickSentence(`a+b++\r\n+c`, 6, "a + b++\r\n+ c")
37
+ assert(common.createString(common.pickArgument(scanner2(`a={a:1,c:d}`)[2][4])), 'c: d')
38
+ assert(common.createString(common.pickArgument(scanner2(`a=class{a=1\r\nc=d}`)[3][4])), 'c = d')
39
+ assert(common.createString(common.pickArgument(scanner2(`(a=1,c=d)`)[0][4])), 'c = d')
@@ -1361,7 +1361,7 @@ var patchMark = '';
1361
1361
  module.exports = function (body, newname, ret) {
1362
1362
  strip = body.strip;
1363
1363
  var patchMark_ = patchMark;
1364
- patchMark = body.patchMark;
1364
+ if (body.patchMark) patchMark = body.patchMark;
1365
1365
  if (ret) ret = isString(ret) ? ret : newname();
1366
1366
  var ret0 = ret_;
1367
1367
  var ret1 = null;
@@ -52,6 +52,11 @@ var cross = cross_.bind(function (callback, onerror) {
52
52
  auth,
53
53
  headers: this.headers,
54
54
  };
55
+ var onerror1 = function (e) {
56
+ xhr.readyState = 4;
57
+ error = e;
58
+ onerror(e);
59
+ };
55
60
  var req = this.http.request(options, function (res) {
56
61
  var data = [];
57
62
  xhr.status = res.statusCode;
@@ -65,16 +70,11 @@ var cross = cross_.bind(function (callback, onerror) {
65
70
  xhr.readyState = 4;
66
71
  callback();
67
72
  });
68
- var onerror1 = function (e) {
69
- xhr.readyState = 4;
70
- error = e;
71
- onerror(e);
72
- };
73
- res.on("error", onerror1);
74
- res.on('timeout', onerror1);
75
73
  this.readyState = 2;
76
74
  });
77
75
  this.readyState = 1;
76
+ req.on("error", onerror1);
77
+ req.on("timeout", onerror1);
78
78
  req.setTimeout(3000);
79
79
  if (data) req.end(data);
80
80
  else req.end();
@@ -1,7 +1,6 @@
1
1
  第三方代码来源及日期,后续版本请自行更新
2
2
  2022-12-30 https://npmjs.com/package/crypto-js
3
3
  2022-11-12 https://github.com/kazuhikoarase/qrcode-generator 逻辑有修改 qrcode.js
4
- 2022-09-29 https://github.com/richtr/NoSleep.js
5
4
  2021-06-15 https://www.npmjs.com/package/html2canvas
6
5
  2019-08-03 https://github.com/gorhill/Javascript-Voronoi
7
6
  2017-05-17 https://github.com/dankogai/js-deflate
@@ -64,8 +64,8 @@ var filterKey = function (event) {
64
64
  else if (keyCode > 95 && keyCode < 106) {
65
65
  char = keyCode - 96;
66
66
  }
67
- else if (keyCode > 46 && keyCode < 57) {
68
- char = keyCode - 47;
67
+ else if (keyCode > 47 && keyCode < 58) {
68
+ char = keyCode - 48;
69
69
  }
70
70
  else {
71
71
  return;
@@ -67,7 +67,7 @@ function alert() {
67
67
  var waitclose = function (autoclose, deltaTime) {
68
68
  if (autoclose) {
69
69
  if (autoclose === true) {
70
- autoclose = text.length * 160 + deltaTime;
70
+ autoclose = text && text.length * 160 + deltaTime;
71
71
  } else if (autoclose < 100) {
72
72
  autoclose = autoclose * 1000;
73
73
  }
@@ -104,8 +104,12 @@ function getErrorMessage(error = this) {
104
104
  if (error[a]) {
105
105
  return String(error[a]);
106
106
  }
107
+ a = a.charAt(0).toUpperCase() + a.slice(1);
108
+ if (error[a]) return String(error[a]);
109
+ a = a.toUpperCase();
110
+ if (error[a]) return String(error[a]);
107
111
  }
108
- return JSON.stringify(error);
112
+ return Object.keys(error).map(k => `${k}: ${error[k]}`).join(',\r\n');
109
113
  }
110
114
 
111
115
  function getTranspile(url) {
@@ -44,6 +44,7 @@
44
44
  <div -else>
45
45
  <button @click="chooseFolder">${i18n`选择代码文件夹`}</button>
46
46
  <button @click="editCode()">${i18n`修改国际化参数`}</button>
47
+ <button @click="显示翻译窗口()">${i18n`翻译工具`}</button>
47
48
  <button style="float:right" -if="tableData.length" @click="exportCSV">${i18n`导出到文件`}</button>
48
49
  <hr />
49
50
  <form>
@@ -389,14 +390,21 @@
389
390
  a: button,
390
391
  async baidu() {
391
392
  var fanyi = this.fanyi;
392
- var liang = this.item.liang;
393
+ var item = this.item;
394
+ if (item) {
395
+ var liang = item.liang;
396
+ var text = item.text;
397
+ }
398
+ if (!text) for (var k in fanyi) {
399
+ if (fanyi[k]) text = fanyi[k];
400
+ }
393
401
  for (var s of this.supports) {
394
402
  if (fanyi[s.id] && fanyi[s.id].trim()) continue;
395
- fanyi[s.id] = await requestBaiduFanyi(this.item.text, s.id);
403
+ fanyi[s.id] = await requestBaiduFanyi(text, s.id);
396
404
  liang++;
397
405
  render.digest();
398
406
  }
399
- this.item.liang = liang;
407
+ if (item) item.liang = liang;
400
408
  },
401
409
  save() {
402
410
 
@@ -406,12 +414,11 @@
406
414
  }
407
415
  };
408
416
  var activedRow;
409
- var showDetail = function (event) {
410
- var tr = getTargetIn(tableElement.children[1], event.active, false);
417
+ var initDetailWindow = function () {
411
418
  if (!detailWindow) {
412
419
  detailWindow = view();
413
420
  on('submit')(detailWindow, e => e.preventDefault());
414
- detailWindow.innerHTML = `<div head>${i18n`翻译: `}"<span -bind="item?.text"></span>"<drop @click="close()"></drop></div><lattice itemwidth=260 -src="s in supports" body><field style="display:inline-block;padding:0 0 6px 12px;" ><label style="padding-left:0"><span -bind="s.name"></span>(<span -bind="s.lang"></span>)</label><textarea -model="fanyi[s.id]" class='body' style="resize:none"></textarea></field></lattice><div foot><a style="float:left" @click="baidu">${i18n`一键百度`}</a></div>`;
421
+ detailWindow.innerHTML = `<div head><span -if=!item? >${i18n`翻译工具`} </span><template -else>${i18n`翻译: `}"<span -bind="item?.text"></span>"</template><drop @click="close()"></drop></div><lattice itemwidth=260 -src="s in supports" body><field style="display:inline-block;padding:0 0 6px 12px;" ><label style="padding-left:0"><span -bind="s.name"></span>(<span -bind="s.lang"></span>)</label><textarea -model="fanyi[s.id]" class='body' style="resize:none"></textarea></field></lattice><div foot><a style="float:left" @click="baidu">${i18n`一键百度`}</a></div>`;
415
422
  drag.on(detailWindow, detailWindow.firstElementChild);
416
423
  resize.on(detailWindow);
417
424
  css(detailWindow, `position:absolute;left:0;top:0;bottom:0;width:260px;`);
@@ -423,12 +430,21 @@
423
430
  for (var s of supports) {
424
431
  if (fanyi[s.id] && fanyi[s.id].trim()) count++;
425
432
  }
426
- detailScope.item.liang = count;
427
- removeClass(activedRow, "actived");
428
- activedRow = null;
433
+ if (detailScope.item) {
434
+ detailScope.item.liang = count;
435
+ }
436
+ if (activedRow) {
437
+ removeClass(activedRow, "actived");
438
+ activedRow = null;
439
+ delete detailScope.item;
440
+ }
429
441
  })
430
442
 
431
443
  }
444
+ }
445
+ var showDetail = function (event) {
446
+ initDetailWindow();
447
+ var tr = getTargetIn(tableElement.children[1], event.active, false);
432
448
  var item = detailScope.item = event.item;
433
449
  if (activedRow !== tr) {
434
450
  if (activedRow) removeClass(activedRow, 'actived');
@@ -445,7 +461,12 @@
445
461
  // }
446
462
  if (!item.fanyi) item.fanyi = {}, item.fanyi[supports[0].id] = item.text;
447
463
  detailScope.fanyi = item.fanyi;
448
-
464
+ if (!isMounted(detailWindow)) popup(detailWindow);
465
+ };
466
+ var 显示翻译窗口 = function () {
467
+ initDetailWindow();
468
+ delete detailScope.item;
469
+ detailScope.fanyi = Object.create(null);
449
470
  if (!isMounted(detailWindow)) popup(detailWindow);
450
471
  }
451
472
  var readText = async function (e) {
@@ -61,6 +61,7 @@
61
61
  var v = window.parseFloat(_value);
62
62
  if (s) v = -v;
63
63
  var i = Math.log2(v) | 0;
64
+ if (i < 0) i--;
64
65
  if (!v) i = 0;
65
66
  else v = (v * Math.pow(2, -i) - 1) * Math.pow(2, 52), i += 1023;
66
67
  return [
@@ -77,6 +78,7 @@
77
78
  var i = parseInt(v.slice(0, 3), 16) & 0x7ff;
78
79
  v = parseInt(v.slice(3), 16);
79
80
  if (i === 0 && v === 0) v = 0;
81
+ else if (i < 1023) v = (v + Math.pow(2, 52)) * Math.pow(2, i - 1022 - 53);
80
82
  else v = (v + Math.pow(2, 53)) * Math.pow(2, i - 1023 - 53);
81
83
  if (s) v = -v;
82
84
  _value = v;
@@ -71,7 +71,7 @@
71
71
  overflow: auto;
72
72
  width: 100%;
73
73
  height: 100%;
74
- padding: 10px 20px 600px 20px;
74
+ padding: 10px 20px 60px 20px;
75
75
  white-space: nowrap;
76
76
  outline: none;
77
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.3.5",
3
+ "version": "4.3.7",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {