efront 3.27.0 → 3.27.1

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.
@@ -77,7 +77,7 @@ function tohuff(buff, result = [], type_limit) {
77
77
  b.sort(function (m, n) {
78
78
  return a[n] - a[m];
79
79
  });
80
- var size = getIndexFromOrderedArray(b, 1, (m, n) => a[m] >= n);
80
+ var size = getIndexFromOrderedArray(b, 1, (m, n) => a[m] >= n, false);
81
81
  if (a[b[size]] > 0) size++;
82
82
  if (size + 1 > b.length) console.log(a.slice(420), buff.filter(a => a > 512), b.slice(420))
83
83
 
@@ -285,7 +285,7 @@ function pack2(buff) {
285
285
  range_compress,
286
286
  other_compress << 5 | el.length,
287
287
  ],
288
- el, e]));
288
+ el, e]));
289
289
  }
290
290
  result = concatTypedArray(result);
291
291
  return pack0(buff, result);
@@ -19,7 +19,7 @@ var defaultIsLE = (sample, search) => isArray(sample) && isArray(search) ? array
19
19
  * @param {Array} orderArray
20
20
  * @param {string|number} searchItem
21
21
  */
22
- module.exports = function (orderArray, searchItem, isLE = typeof searchItem === "function" ? searchItem : defaultIsLE) {
22
+ module.exports = function (orderArray, searchItem, isLE = typeof searchItem === "function" ? searchItem : defaultIsLE, findEqual = true) {
23
23
  for (var cx = 0, dx = orderArray.length, ci = cx + dx >>> 1; cx < dx; ci = cx + dx >>> 1) {
24
24
  var orderItem = orderArray[ci];
25
25
  if (isLE(orderItem, searchItem)) {
@@ -28,8 +28,8 @@ module.exports = function (orderArray, searchItem, isLE = typeof searchItem ===
28
28
  dx = ci;
29
29
  }
30
30
  }
31
- var index = dx - 1;
32
- if (index < orderArray.length) {
31
+ if (findEqual && dx <= orderArray.length) {
32
+ var index = dx - 1;
33
33
  while (index >= 0 && isLE(searchItem, orderArray[index])) {
34
34
  if (orderArray[index] === searchItem) return index;
35
35
  index--;
@@ -1,5 +1,5 @@
1
1
  function isArrayLike(a) {
2
- if (a === null || typeof a !== 'object' || isNode(a)) return false;
2
+ if (a === null || a === window || typeof a !== 'object' || isNode(a)) return false;
3
3
  if (isFinite(a.length)) {
4
4
  if (a.length > 0) {
5
5
  return a.length - 1 in a;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var colored = Object.create(null);
3
+ var lazy = require("../basic/lazy");
4
+ var colors = require("./colors");
5
+ var lastLogLength = 0;
6
+ var getColor = function (c) {
7
+ switch (c) {
8
+ case "red":
9
+ case "error":
10
+ case "danger":
11
+ return colors.FgRed;
12
+ case "info":
13
+ case "tip":
14
+ case "blue":
15
+ return colors.FgBlue;
16
+ case "green":
17
+ return colors.FgGreen;
18
+ default:
19
+ if (c in colors) return colors[c];
20
+ c = c[0].toUpperCase() + c.slice(1).toLowerCase();
21
+ if (c in colors) return colors[c];
22
+ var k = "Fg" + c;
23
+ if (k in colors) {
24
+ return colors[k];
25
+ }
26
+ c = c.slice(0, 2) + c[2].toUpperCase() + c.slice(3);
27
+ if (c in colors) return colors[c];
28
+ }
29
+ return '';
30
+ };
31
+ var write = function (hasNewLine, str) {
32
+ str = String(str).replace(/<([a-z][\w]*)[^\>]*\>([\s\S]*?)<\/\1\>/ig, function (_, c, s) {
33
+ var color = getColor(c);
34
+ if (color) return color + s + colors.Reset;
35
+ return s;
36
+ });
37
+ process.stdout.cork();
38
+ var hasNextLine = /[\r\n\u2028\u2029]/.test(str);
39
+ if (process.stdout.isTTY) {
40
+ if (lastLogLength) {
41
+ var width = process.stdout.columns;
42
+ var dx = lastLogLength % width;
43
+ var dy = (lastLogLength - 1) / width | 0;
44
+ process.stdout.moveCursor(-dx, -dy);
45
+ process.stdout.clearScreenDown();
46
+ }
47
+ }
48
+ else {
49
+ if (!hasNewLine && !hasNextLine) str = '';
50
+ }
51
+ hasNewLine && !hasNextLine ? process.stdout.write(str + "\r\n") : process.stdout.write("\r" + str);
52
+ if (hasNextLine) hasNewLine = true;
53
+ if (hasNewLine) {
54
+ lastLogLength = 0;
55
+ } else {
56
+ str = str.replace(/\x1b\[\d+m/g, '').replace(/\b/g, '');
57
+ lastLogLength = str.length + str.replace(/[\x20-\xff]/g, "").length;
58
+ }
59
+ process.stdout.uncork();
60
+ };
61
+ [
62
+ "pass:[ ✔ ]:FgGreen:",
63
+ "fail:[ ✘ ]:FgRed2:",
64
+ "test:[ ∞ ]:FgYellow:",
65
+ "info:提示:FgCyan:",
66
+ "warn:注意:FgYellow:",
67
+ "error:错误:FgRed2:"
68
+ ].forEach(function (config) {
69
+ var [log, info = log.toUpperCase(), fg, bg] = config.split(":");
70
+ var fgColor = colors[fg] || "",
71
+ bgColor = colors[bg] || "",
72
+ reset = colors.Reset;
73
+ var hasNewLine = /^(warn|error|pass|fail)$/.test(log);
74
+ var logger = function (...args) {
75
+ var label = fgColor + bgColor + info + reset;
76
+ var time_stamp = '';
77
+ var str = [time_stamp, label, ...args].join(" ");
78
+ if (queue.length > 1 && !queue[queue.length - 2] && !/[\r\n\u2028\u2029]/.test(queue[queue.length - 1])) {
79
+ queue.pop();
80
+ queue.pop();
81
+ }
82
+ write1(hasNewLine, str);
83
+ };
84
+ colored[log] = logger;
85
+ });
86
+ var queue = [];
87
+ var flush = function () {
88
+ while (queue.length) write(queue.shift(), queue.shift());
89
+ };
90
+ // var write0 = lazy(flush, -60);
91
+ var write1 = function (hasNewLine, str) {
92
+ writeid++;
93
+ // queue.push(hasNewLine, str);
94
+ write(hasNewLine, str);
95
+ };
96
+ colored.flush = flush;
97
+ colored.type = function (...args) {
98
+ write1(false, args.join(' '));
99
+ };
100
+ var _log = console.log;
101
+ colored.log = function () {
102
+ flush();
103
+ _log.apply(console, arguments);
104
+ };
105
+ colored.begin = function (c) {
106
+ return write1(false, getColor(c));
107
+ };
108
+ var writeid = 0;
109
+ var drop = lazy(function (dropid) {
110
+ if (dropid === writeid) write1(false, "");
111
+ }, 160);
112
+ colored.drop = function () {
113
+ drop(++writeid);
114
+ };
115
+ colored.end = function () {
116
+ return write1(false, colors.Reset);
117
+ };
118
+ colored.clear = function (tag) {
119
+ write1(false, '');
120
+ if (tag) write1(true, tag);
121
+ };
122
+ module.exports = colored;
@@ -0,0 +1,54 @@
1
+ var colors = module.exports = {
2
+ Reset: "\x1b[0m",
3
+ Bright: "\x1b[1m",
4
+ Dim: "\x1b[2m",
5
+ Underscore: "\x1b[4m",
6
+ Blink: "\x1b[5m",
7
+ Reverse: "\x1b[7m",
8
+ Hidden: "\x1b[8m",
9
+ FgBlack: "\x1b[30m",
10
+ FgRed: "\x1b[31m",
11
+ FgGreen: "\x1b[32m",
12
+ FgYellow: "\x1b[33m",
13
+ FgBlue: "\x1b[34m",
14
+ FgMagenta: "\x1b[35m",
15
+ FgCyan: "\x1b[36m",
16
+ FgWhite: "\x1b[37m",
17
+ BgBlack: "\x1b[40m",
18
+ BgRed: "\x1b[41m",
19
+ BgGreen: "\x1b[42m",
20
+ BgYellow: "\x1b[43m",
21
+ BgBlue: "\x1b[44m",
22
+ BgMagenta: "\x1b[45m",
23
+ BgCyan: "\x1b[46m",
24
+ BgWhite: "\x1b[47m",
25
+ FgGray: "\x1b[90m",
26
+ FgRed2: "\x1b[91m",
27
+ FgGreen2: "\x1b[92m",
28
+ FgYellow2: "\x1b[93m",
29
+ FgBlue2: "\x1b[94m",
30
+ FgPurple: "\x1b[95m",
31
+ FgCyan2: "\x1b[96m",
32
+ FgWhite2: "\x1b[97m",
33
+ // test: "\x1b[97m",
34
+ BgGray: "\x1b[100m",
35
+ BgRed2: "\x1b[102m",
36
+ BgGreen2: "\x1b[102m",
37
+ BgYellow2: "\x1b[103m",
38
+ BgBlue2: "\x1b[104m",
39
+ BgMagenta2: "\x1b[105m",
40
+ BgCyan2: "\x1b[106m",
41
+ BgWhite2: "\x1b[107m",
42
+ };
43
+ class Color {
44
+ constructor(name, value) {
45
+ this.name = name;
46
+ this.value = value;
47
+ }
48
+ toString() {
49
+ return this.value;
50
+ }
51
+ }
52
+ for (var k in colors) {
53
+ colors[k] = new Color(k, colors[k]);
54
+ }
@@ -4,7 +4,8 @@
4
4
  */
5
5
  var emitEvent = function (item, event) {
6
6
  if (event.defaultPrevented) return;
7
- if (!getTargetIn(this, event.target) && !getTargetIn(event.target, this)) return;
7
+ var target = this.target || this;
8
+ if (!getTargetIn(target, event.target) && !getTargetIn(event.target, target)) return;
8
9
  event.preventDefault(true);
9
10
  if (item.disabled) return;
10
11
  active(this, item, "global", this.$src ? createItemTarget.call(this, item) : this);
@@ -31,7 +32,7 @@ function bindGlobalkey(elem, keymap, item) {
31
32
  if (!keymap) return;
32
33
  var keyoff = [];
33
34
  for (let k in keymap) {
34
- keyoff.push(bindonly(elem, k, item));
35
+ keyoff.push(bindonly(elem, k, keymap[k]));
35
36
  }
36
37
  elem.$keyoff = keyoff;
37
38
  }
@@ -206,7 +206,7 @@ function main(elem, mode) {
206
206
  }
207
207
  if (!elem.hasAttribute('mode')) elem.setAttribute('mode', mode);
208
208
  if (!elem.hasAttribute(mode)) elem.setAttribute(mode, '');
209
-
209
+ elem.target = document.body;
210
210
  return elem;
211
211
 
212
212
  }
@@ -93,7 +93,7 @@ var init = function () {
93
93
  var isType = function (target, type) {
94
94
  // 记得小时候,不论是苍蝇还是蚊子,飞起来都是有声音的。最近看到的一种像蚊子一样小的飞虫,喜欢像苍蝇一样趴在食物上,飞起来却听不到声音。
95
95
  // 是我的听力下降了?还是外界太过嘈杂?还是飞虫拍打翅膀的频率超出了我的听觉范围?还是飞行可以不产生声音?
96
- return target.hasAttribute(type) || hasClass(type);
96
+ return target.hasAttribute(type) || hasClass(target, type);
97
97
  }
98
98
  var resize2 = function () {
99
99
  var head, body, foot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.27.0",
3
+ "version": "3.27.1",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {