efront 3.34.6 → 3.34.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.
@@ -8,6 +8,7 @@ function main(params, from) {
8
8
  var page = div();
9
9
  page.initialStyle = 'margin-left:100%';
10
10
  page.innerHTML = search;
11
+ document.title = "搜索";
11
12
  var $scope = render(page, {
12
13
  titlebar,
13
14
  back,
@@ -59,7 +60,7 @@ function main(params, from) {
59
60
  if (!keyword) return;
60
61
  var s1 = this.requestSearch("kugo", 'search', { keyword }, this.resultMap, timeout, function (s1) {
61
62
  if (s1 instanceof Array) s1.forEach(a => {
62
- a.priced = a.privilege === 10 && (a.price_sq > 0);
63
+ a.priced = a.privilege === 10
63
64
  });
64
65
  else s1 = [];
65
66
  return s1;
@@ -84,8 +84,11 @@ class Matrix extends Array {
84
84
  }
85
85
  }
86
86
  class MathMatrix extends Matrix {
87
+ getTransform() {
88
+ return [this[0], this[1], this[3], this[4], this[6], this[7]];
89
+ }
87
90
  toDOMString() {
88
- if (this.size()[1] === 2) return `matrix(${[this[0], this[1], this[3], this[4], this[6], this[7]]})`;
91
+ if (this.size()[1] === 2) return `matrix(${this.getTransform()})`;
89
92
  return `matrix(${this})`;
90
93
  }
91
94
 
@@ -222,8 +225,11 @@ class MathMatrix extends Matrix {
222
225
 
223
226
  }
224
227
  class MatrixTransposed extends Matrix {
228
+ getTransform() {
229
+ return [this[0], this[3], this[1], this[4], this[2], this[5]];
230
+ }
225
231
  toDOMString() {
226
- if (this.size()[1] === 2) return `matrix(${[this[0], this[3], this[1], this[4], this[2], this[5]]})`;
232
+ if (this.size()[1] === 2) return `matrix(${this.getTransform()})`;
227
233
  return `matrix(${this.transpose()})`;
228
234
  }
229
235
  static transform(B, dots) {
@@ -4,7 +4,7 @@
4
4
  * @param {Element|Object|any} image;
5
5
  */
6
6
  function awaitable(image) {
7
- if (image.complete) return image;
7
+ if (image.complete || image.then) return image;
8
8
  var oks = [];
9
9
  var ohs = [];
10
10
  var resolved = false,
@@ -162,7 +162,7 @@ var hex256 = function (num) {
162
162
  return num.toString(16);
163
163
  }
164
164
  var hex16 = function (num) {
165
- num = trim16(num);
165
+ num = trim16(num / 17);
166
166
  return num.toString(16);
167
167
  }
168
168
  function color(rgba) {
@@ -242,6 +242,9 @@ function parse(color) {
242
242
  return [R, G, B, A >= 0 ? A / 0xff : 1];
243
243
  }
244
244
  }
245
+ var maybe16 = function (n) {
246
+ return (n >> 4) === (n & 0xf);
247
+ }
245
248
  function stringify(color) {
246
249
  var [R, G, B, a] = color;
247
250
  if (a >= 0 && a < 1) {
@@ -250,9 +253,11 @@ function stringify(color) {
250
253
  B = B.toFixed();
251
254
  a = +a.toFixed(3);
252
255
  return `rgba(${R},${G},${B},${a})`;
253
- } else {
254
- return "#" + [R, G, B].map(hex256).join("");
255
256
  }
257
+ if (maybe16(R) && maybe16(G) && maybe16(B)) {
258
+ return "#" + [R, G, B].map(hex16).join("");
259
+ }
260
+ return "#" + [R, G, B].map(hex256).join("");
256
261
  }
257
262
  function doWith(manager, color, args) {
258
263
  var isparsed = color instanceof Array,
@@ -317,6 +322,11 @@ var colorReg = /(?:rgb|hsl)a?\s*\([\,\.\d\s%]+\)|#[\da-f]{3,8}/ig;
317
322
  function isColor(text) {
318
323
  return rgbReg.test(text) || rgbHex.test(text) || rgbHex2.test(text) || hslReg.test(text);
319
324
  }
325
+ function format(color) {
326
+ var c = parse(color);
327
+ if (!c) return color;
328
+ return stringify(c);
329
+ }
320
330
  var replacer = function (match) {
321
331
  if (!isColor(match)) return match;
322
332
  if (colorDesigner.rotate !== 0) {
@@ -325,7 +335,7 @@ var replacer = function (match) {
325
335
  if (colorDesigner.contrast !== 1) {
326
336
  match = color.contrast(match, colorDesigner.contrast);
327
337
  }
328
- return match;
338
+ return format(match);
329
339
  };
330
340
  var colorDesigner = {
331
341
  rotate: 0,
File without changes
@@ -1,13 +1,14 @@
1
- function decodeUTF16(buff) {
1
+ function decodeUTF16(buff, be = true) {
2
2
  var dist = [];
3
+ var dec = be ? (a, b) => a << 8 | b : (a, b) => b << 8 | a;
3
4
  for (var cx = 0, dx = buff; cx < dx; cx += 2) {
4
- var m = (buff[cx] << 8) + buff[cx + 1];
5
+ var m = dec(buff[cx], buff[cx + 1]);
5
6
  var t;
6
7
  if (m > 0b1101111111111111 || m < 0b1101100000000000) {
7
8
  t = m;
8
9
  }
9
10
  else {
10
- var n = (buff[cx + 2] << 8) + buff[cx + 3];
11
+ var n = dec(buff[cx + 2], buff[cx + 3]);
11
12
  if (n < 0b1101100000000000 || n > 0b1101111111111111) {
12
13
  continue;
13
14
  }
@@ -1,5 +1,5 @@
1
1
  function numberUTF16(t, dist = []) {
2
- if (t > 0x10ffff) {
2
+ if (t > 0x10ffff) {
3
3
  throw new Error("编码错误");
4
4
  }
5
5
  if (t <= 0xffff) {
@@ -11,12 +11,27 @@ function numberUTF16(t, dist = []) {
11
11
  }
12
12
  return dist;
13
13
  }
14
- function encodeUTF16(strings) {
14
+ function numberUTF16LE(t, dist = []) {
15
+ if (t > 0x10ffff) {
16
+ throw new Error("编码错误");
17
+ }
18
+ if (t <= 0xffff) {
19
+ dist.push(t & 0xff, t >> 8);
20
+ }
21
+ else {
22
+ t -= 0x10000;
23
+ dist.push(t >> 10 & 0xff, 0b11011000 | t >> 18, t & 0xff, t >> 8 & 0b00000011 | 0b11011100);
24
+ }
25
+ return dist;
26
+
27
+ }
28
+ function encodeUTF16(strings, be = true) {
15
29
  var dist = [];
30
+ var utf16 = be ? numberUTF16 : numberUTF16LE;
16
31
  for (var cx = 0, dx = strings.length; cx < dx; cx++) {
17
32
  var s = strings.codePointAt(cx);
18
33
  if (s > 0xffff) cx++;
19
- numberUTF16(s, dist);
34
+ utf16(s, dist);
20
35
  }
21
36
  return dist;
22
37
  }
@@ -31,18 +31,18 @@
31
31
  ```
32
32
  以上几个方法`ie9+`系列浏览器已支持,但`ie8`及以下版本不支持,如果没有指定`--no-polyfill`参数`efront`在降级编译期会使用`[]map.js`中提供的方法进行修补,这些方法会在加载器检测到浏览器不支持`[].map`时进行初始化
33
33
  4. ```javascript
34
- Object.assign
35
34
  Array.prototype.fill
36
- ```
37
- 以上两个原生方法`ie`系列浏览器均不支持,由于经常被`efront`开发者使用,在降级编译期,如果没有指定`--no-polyfill`参数,将由`efront`处理成替代品,当前的处理方案如下:
38
- ```javascript
39
- Object.assign // 由 extend 替代,见 ../basic/extend.js
40
- Array.prototype.fill //..将按使用的目的进行不同的替换
41
35
  Array(3).fill(0) // 类似这种的将变成[0,0,0]一个常量数组
42
36
  var [a,b,c]=Array(3).fill(0).map((_,i)=>i+1) // 类似这种用于生成常量并赋值的,将直接变成赋值语句 var a=1,b=2,c=3
43
37
  Array(3).fill(a)// 类似这种非常量的,将由类似 ArrayFill(3,a) 的语句替换
44
38
  ```
39
+ `Array(...).fill(...).map(...)`这种写法经常被`efront`开发者用来生成自增赋值序列,并且非所有运行环境都支持,所以包括其它显式用到`Array.prototype.fill`的几种写法都会被替换。为了目标代码的性能考虑,这种替换在自动常量化之前就要执行,所以不再支持用`polyfill`的开关进行关闭。如果要关闭,请使用参数`--no-autoeval`将自动常量化的功能一同关闭。
40
+
45
41
  5. ```javascript
42
+ Object.assign
43
+ ```
44
+ Object.assign,`ie`系列浏览器均不支持,由于经常被`efront`开发者使用,在降级编译期,如果没有指定`--no-polyfill`参数,将由`efront`处理成替代品[extend](../basic/extend.js)
45
+ 6. ```javascript
46
46
  Promise
47
47
  Promise.prototype.then
48
48
  Promise.prototype.catch
@@ -52,13 +52,13 @@
52
52
  Promise.resolve
53
53
  ```
54
54
  `Promise`对象也是`ie`系列浏览器均不支持的。`efront`实现的`Promise`与原生的特性并不一致,仅在运行环境不支持的时候进行替代。比如由`.then`触发的方法与`setTimeout`触发的方法执行的先后顺序会与高级的运行环境有所区别,但也会保持在当前语境执行后再执行相关的语句。以上没有提到的`Promise`相关的方法均不支持,如`Promise.prototype.finally`,如果您使用了这些缺失的特性,就只能自己实现或找类似[core-js](https://github.com/zloirock/core-js)的库填充了
55
- 6. ```javascript
55
+ 7. ```javascript
56
56
  obj.if
57
57
  obj.catch
58
58
  obj.for
59
59
  ```
60
60
  类似这种用`.`取属性的语句,由于属性名与`js`的保留字一样,`ie6`等浏览器会报错,但您可以在`efront`提供的环境中放心使用。因为`efront`本身就会把取属性的语句处理掉。
61
- 7. `ie8`及以下浏览器中存在的一些与现代`js`标准不同的特性,`efront`提供的组件可能不兼容,在处理为这类环境进行应用开发时,应避免使用。
61
+ 8. `ie8`及以下浏览器中存在的一些与现代`js`标准不同的特性,`efront`提供的组件可能不兼容,在处理为这类环境进行应用开发时,应避免使用。
62
62
  ```javascript
63
63
  Object.defineProperty(...);
64
64
  ({
@@ -1,10 +1,28 @@
1
- var activeDevice;
1
+ var activeDevice, ratio = 1;
2
2
  function line(buffer, style, lineWidth = window.devicePixelRatio || 1) {
3
3
  var canvas = this;
4
4
  var context = canvas.getContext("2d");
5
5
  context.moveTo.apply(context, buffer[0]);
6
6
  context.beginPath();
7
7
  var { width, height } = canvas;
8
+ var lasty = buffer[0][1], deltay = 0, changed = 0;
9
+ for (var cx = 1, dx = Math.min(100, buffer.length); cx < dx; cx++) {
10
+ var [, y] = buffer[cx];
11
+ if (y > lasty) {
12
+ if (deltay < 0) {
13
+ changed++;
14
+ }
15
+ deltay = 1;
16
+ }
17
+ else {
18
+ if (deltay > 0) {
19
+ changed++;
20
+ }
21
+ deltay = -1;
22
+ }
23
+ lasty = y;
24
+ }
25
+ ratio = (dx - changed / 2) / dx;
8
26
  for (var cx = 1, dx = buffer.length; cx < dx; cx++) {
9
27
  var [x, y] = buffer[cx];
10
28
  context.lineTo(x * width, y * height);
@@ -13,7 +31,37 @@ function line(buffer, style, lineWidth = window.devicePixelRatio || 1) {
13
31
  context.lineWidth = lineWidth;
14
32
  context.stroke();
15
33
  }
34
+ var linkImage;
35
+ var danceIcon = lazy(async function (theta) {
36
+ if (!linkImage) linkImage = new Image, linkImage.canvas = document.createElement("canvas");
37
+ var canvas = linkImage.canvas;
38
+ /**
39
+ * @type {CanvasRenderingContext2D}
40
+ */
41
+ var context = canvas.getContext("2d");
42
+ var size = 32;
43
+ if (linkImage.src !== shortcurt.getHref()) {
44
+ linkImage.src = shortcurt.getHref();
45
+ await awaitable(linkImage);
46
+ canvas.width = size;
47
+ canvas.height = size;
48
+ }
49
+ context.setTransform(1, 0, 0, 1, 0, 0);
50
+ context.clearRect(0, 0, size, size);
51
+ var matrix = Matrix.create2d(0);
52
+ matrix.translate(-size >> 1, -size >> 1);
53
+ matrix.rotate(-theta);
54
+ matrix.scale(ratio);
55
+ matrix.translate(size >> 1, size >> 1);
56
+ context.setTransform.apply(context, matrix.getTransform());
57
+ context.drawImage(linkImage, 0, 0, size, size);
58
+ shortcurt.href = canvas.toDataURL();
59
+ }, -120);
60
+ /**
61
+ * @this {HTMLCanvasElement}
62
+ */
16
63
  function draw(buffer) {
64
+ danceIcon(buffer.theta);
17
65
  var canvas = this;
18
66
  var context = canvas.getContext("2d");
19
67
  if (canvas.width !== canvas.offsetWidth * devicePixelRatio) canvas.width = canvas.offsetWidth * devicePixelRatio;
@@ -57,6 +105,6 @@ function draw(buffer) {
57
105
 
58
106
  function dance(elem) {
59
107
  var canvas = /^canvas$/i.test(elem.tagName) ? elem : document.createElement("canvas");
60
- care(canvas, draw);
108
+ if (canvas.getContext) care(canvas, draw);
61
109
  return canvas;
62
110
  }
package/coms/kugou/krc.js CHANGED
@@ -9,6 +9,10 @@ function krc(list = div()) {
9
9
  appendChild(list, children);
10
10
  list.process = children.process;
11
11
  }
12
+ else {
13
+ list.process = Function.prototype;
14
+ document.title = `${info.songName} - ${info.singerName}`;
15
+ }
12
16
  return;
13
17
  }
14
18
  var content = info.krc.slice(4).map((a, i) => a ^ secret[i % 16]);
@@ -77,6 +81,7 @@ function setClass(krcList, index) {
77
81
  removeClass(ele, "after before after-active before-active");
78
82
  addClass(krcList[index - 1], 'before-active');
79
83
  addClass(ele, "active");
84
+ if (ele.innerText) document.title = ele.innerText;
80
85
  krcList.slice(index + 1).map(function (a) {
81
86
  removeClass(a, "before active after-active before-active");
82
87
  addClass(a, "after");
@@ -8,7 +8,6 @@ var patchMusicInfo = async function (info) {
8
8
  switch (info.type) {
9
9
  case "qqjt":
10
10
  info.lrc = (await cross("get", info.lyric)).response;
11
- console.log(info)
12
11
  res = await data.from("qqjt-url", qqjc({
13
12
  TSID: info.id
14
13
  }))
@@ -167,8 +166,9 @@ var $scope = {
167
166
  }
168
167
  $scope.currentTime = filterTime(currentTime, duration);
169
168
  $scope.totalTime = filterTime(duration, duration);
170
- $scope.currentRotate = `rotate(${currentTime * 6}deg)`;
171
- $scope.currentTheta = ((currentTime * 6 + 90) % 180 - 90) / 180 * Math.PI;
169
+ $scope.currentRotate = `rotate(${-currentTime * 6}deg)`;
170
+ $scope.quickTheta = currentTime / 3 * Math.PI;
171
+ $scope.currentTheta = (90 - (currentTime * 6 + 90) % 180) / 180 * Math.PI;
172
172
  playState.width = (currentTime * 100 / duration).toFixed(2) + `%`;
173
173
  $scope.currentProcess = `width:` + playState.width;
174
174
  },
@@ -207,6 +207,8 @@ var $scope = {
207
207
  if (player.offsetHeight <= calcPixel(80)) {
208
208
  var centerx = 44 / width, centery = .5;
209
209
  var start = 11 * ratio | 0, end = 77 * ratio | 0;
210
+ var cost = cos(currentTheta);
211
+ var sint = sin(currentTheta);
210
212
  for (var cx = start, dx = end; cx < dx; cx++) {
211
213
  var [x, y] = buf[cx];
212
214
  y -= 0.1;
@@ -214,24 +216,26 @@ var $scope = {
214
216
  x = (x - centerx) * width;
215
217
  y = (y - centery) * height;
216
218
  y = y * cos(x / 66 * Math.PI);
217
- var x1 = cos(currentTheta) * x - sin(currentTheta) * y,
218
- y1 = cos(currentTheta) * y + sin(currentTheta) * x;
219
+ var x1 = cost * x - sint * y,
220
+ y1 = cost * y + sint * x;
219
221
  buf[cx][0] = x1 / width + centerx;
220
222
  buf[cx][1] = y1 / height + centery;
221
223
  } else {
222
224
  buf[cx][1] = y;
223
225
  }
224
226
  }
225
- cast($scope.dance, [{
227
+ buf = [{
226
228
  data: buf.slice(0, start),
227
229
  }, {
228
230
  data: buf.slice(start, end)
229
231
  }, {
230
232
  data: buf.slice(end)
231
- }]);
232
- } else {
233
+ }]
234
+
233
235
  cast($scope.dance, buf);
234
236
  }
237
+ buf.theta = $scope.quickTheta || 0;
238
+ cast($scope.dance, buf);
235
239
  },
236
240
  playid: 0,
237
241
  play(music = musicList.getActived()) {
@@ -342,8 +346,7 @@ if (hasContext) {
342
346
  var animate = function () {
343
347
  if (analyser) {
344
348
  analyser.getByteTimeDomainData(dancingArray);
345
- // console.log(dancingArray);
346
- $scope.draw(dancingArray);
349
+ if ($scope.playing) $scope.draw(dancingArray);
347
350
  }
348
351
  requestAnimationFrame(animate);
349
352
  };
@@ -0,0 +1,8 @@
1
+ var shortcurt = document.querySelector("link[type='image/x-icon']");
2
+ shortcurt._href = shortcurt.href;
3
+ shortcurt.setHref = function (href) {
4
+ shortcurt._href = shortcurt.href = href;
5
+ };
6
+ shortcurt.getHref = function () {
7
+ return shortcurt._href;
8
+ };
@@ -52,7 +52,6 @@ function cless(commFactory, innerCss, className) {
52
52
  var stylesheet = document.createElement("style");
53
53
  stylesheet.type = "text/css";
54
54
  stylesheet.savedText = innerCss;
55
- innerCss = color.transform(innerCss);
56
55
  if (stylesheet.styleSheet) {
57
56
  stylesheet.styleSheet.cssText = innerCss;
58
57
  } else {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.34.6",
3
+ "version": "3.34.7",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {