efront 3.22.10 → 3.24.3

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.
Files changed (39) hide show
  1. package/coms/basic/BigNumber.js +28 -5
  2. package/coms/basic/BigNumber_test.js +14 -1
  3. package/coms/basic/[]map.js +18 -13
  4. package/coms/basic/assert.js +10 -2
  5. package/coms/basic/extends_.js +13 -0
  6. package/coms/basic/loader.js +47 -28
  7. package/coms/basic/mark.js +155 -0
  8. package/coms/basic/queue.js +11 -14
  9. package/coms/basic/rest_.js +27 -0
  10. package/coms/kugou/parseSongsList.js +1 -1
  11. package/coms/kugou/player.js +3 -2
  12. package/coms/zimoli/Promise.js +84 -133
  13. package/coms/zimoli/appendChild.js +4 -14
  14. package/coms/zimoli/cless.js +11 -5
  15. package/coms/zimoli/color.js +0 -1
  16. package/coms/zimoli/compile.js +64 -1
  17. package/coms/{compile → zimoli}/compile_test.js +0 -0
  18. package/coms/zimoli/cross.js +1 -1
  19. package/coms/zimoli/data.js +6 -2
  20. package/coms/zimoli/dispatch.js +1 -1
  21. package/coms/zimoli/on.js +64 -47
  22. package/coms/zimoli/remove.js +0 -9
  23. package/coms/zimoli/render.js +2 -2
  24. package/coms/zimoli/zimoli.js +2 -2
  25. package/package.json +1 -1
  26. package/public/efront.js +1 -1
  27. package/coms/compile/breakcode.js +0 -78
  28. package/coms/compile/common.js +0 -683
  29. package/coms/compile/compile.js +0 -64
  30. package/coms/compile/keywords.js +0 -6
  31. package/coms/compile/namelist.js +0 -142
  32. package/coms/compile/namelist_test.js +0 -7
  33. package/coms/compile/required.js +0 -20
  34. package/coms/compile/scanner.js +0 -653
  35. package/coms/compile/scanner2.js +0 -909
  36. package/coms/compile/scanner2_test.js +0 -85
  37. package/coms/compile/scanner_test.js +0 -10
  38. package/coms/compile/washcode.js +0 -313
  39. package/coms/zimoli/mark.js +0 -70
@@ -194,13 +194,36 @@ class BigNumber {
194
194
  if (isEmpty(decimal)) throw new Error("请输入保留小数的位数!");
195
195
  var [neg1, s11, s12] = prepare(numstr1);
196
196
  var [neg2, s21, s22] = prepare(numstr2);
197
- var d = s12.length - s22.length;
197
+ var d = s12.length + decimal - s22.length;
198
+ decimal = (decimal | 0) + 1;
198
199
  numstr1 = s11 + s12;
199
200
  numstr2 = s21 + s22;
200
-
201
- if (d < 0) {
202
- numstr2 += repeat0(0, -d);
201
+ numstr1 = numstr1.replace(/^0+/, '');
202
+ numstr2 = numstr2.replace(/^0+/, '');
203
+ if (d < 0) numstr2 += repeat0(-d);
204
+ else if (d > 0) numstr1 += repeat0(d);
205
+ var result = [];
206
+ var ns1 = split(numstr1, 9);
207
+ var s1 = "";
208
+ while (ns1.length) {
209
+ s1 = s1 + ns1.pop();
210
+ if (s1.length >= numstr2.length) {
211
+ for (var cx = 0, dx = 1000000000, ci = cx + dx >> 1; cx < dx; ci = cx + dx + 1 >> 1) {
212
+ var s2 = BigNumber.sub(s1, BigNumber.prd(numstr2, ci));
213
+ if (/^\-/.test(s2)) dx = ci - 1;
214
+ else cx = ci;
215
+ }
216
+ }
217
+ else {
218
+ ci = 0;
219
+ }
220
+ ci = String(ci);
221
+ s1 = BigNumber.sub(s1, BigNumber.prd(numstr2, ci));
222
+ if (result.length) ci = repeat0(9 - ci.length) + ci;
223
+ result.push(ci);
203
224
  }
204
- numstr1 += repeat0(0);
225
+ result = result.join('');
226
+ result = fixme(neg1 ^ neg2, result, +d + s12.length - s22.length);
227
+ return BigNumber.fix(result, decimal - 1);
205
228
  }
206
229
  }
@@ -54,4 +54,17 @@ assert(BigNumber.floor(2.999), '2');
54
54
  assert(BigNumber.floor(-2.999), '-3');
55
55
  assert(BigNumber.ceil(2.001), '3');
56
56
  assert(BigNumber.ceil(2.999), '3');
57
- assert(BigNumber.fix("9007199254740992.234", 6), '9007199254740992.234000');
57
+ assert(BigNumber.fix("9007199254740992.234", 6), '9007199254740992.234000');
58
+ assert(BigNumber.div("9", 6, 1), "1.5");
59
+ assert(BigNumber.div("9", 6, 2), "1.50");
60
+ assert(BigNumber.div("9", 66, 2), "0.13");
61
+ assert(BigNumber.div("9007199254740992.234", 10, 4), "900719925474099.2234");
62
+ assert(BigNumber.div("9007199254740992.234", 100, 5), "90071992547409.92234");
63
+ assert(BigNumber.div("9007199254740992.234", 1000, 6), "9007199254740.992234");
64
+ assert(BigNumber.div("9007199254740992.234", 0.1, 6), "90071992547409922.340000");
65
+ assert(BigNumber.div("9007199254740992.234", 0.001, 6), "9007199254740992234.000000");
66
+ assert(BigNumber.div("9007199254740992.2345678901", 0.001, 6), "9007199254740992234.567890");
67
+ assert(BigNumber.div("9007199254740992.2345678901", "9007199254740992.2345678901", 6), "1.000000");
68
+ assert(BigNumber.div("9007199254740992.2345678901", "90071992547409922345678.901", 6), "0.000000");
69
+ assert(BigNumber.div("9007199254740992.2345678901", "900719925474099223456.78901", 6), "0.000010");
70
+ assert(BigNumber.div("99999", "9", 6), "11111.000000");
@@ -3,18 +3,20 @@ var {
3
3
  Array,
4
4
  Function,
5
5
  String,
6
- Object
6
+ Object,
7
+ isFinite,
8
+ console
7
9
  } = this;
8
10
 
9
11
  function map(f, o) {
10
- var res = new this.constructor(this.length);
12
+ var res = new (this.constructor === Array ? this.constructor : Array)(this.length);
11
13
  if (!(f instanceof Function)) return res;
12
14
  if (this instanceof String) {
13
15
  res = this.split("").map(f, o);
14
16
  } else {
15
- for (var cx = 0, dx = this.length; cx < dx; cx++) {
16
- if (cx in this)
17
- res[cx] = f.call(o, this[cx], cx, this);
17
+ for (var cx in this) {
18
+ if (!isFinite(cx)) break;
19
+ res[cx] = f.call(o, this[cx], cx, this);
18
20
  }
19
21
  }
20
22
  return res;
@@ -24,9 +26,9 @@ function forEach(f, o) {
24
26
  if (this instanceof String) {
25
27
  this.split("").forEach(f, o);
26
28
  }
27
- for (var cx = 0, dx = this.length; cx < dx; cx++) {
28
- if (cx in this[cx])
29
- f.call(o, this[cx], cx, this);
29
+ for (var cx in this) {
30
+ if (!isFinite(cx)) break;
31
+ f.call(o, this[cx], cx, this);
30
32
  }
31
33
  }
32
34
  function filter(f, o) {
@@ -35,14 +37,16 @@ function filter(f, o) {
35
37
  if (this instanceof String) {
36
38
  result = this.split("").filter(f, o);
37
39
  }
38
- for (var cx = 0, dx = this.length; cx < dx; cx++) {
39
- if (cx in this[cx])
40
- if (f.call(o, this[cx], cx, this))
41
- result.push(this[cx]);
40
+ for (var cx in this) {
41
+ if (!isFinite(cx)) break;
42
+ if (f.call(o, this[cx], cx, this))
43
+ result.push(this[cx]);
42
44
  }
43
45
  return result;
44
46
  }
45
47
  function indexOf(searchElement, fromIndex = 0) {
48
+ if (fromIndex < 0) fromIndex += this.length;
49
+ if (fromIndex < 0) fromIndex = 0;
46
50
  for (var cx = fromIndex, dx = this.length; cx < dx; cx++) {
47
51
  if (cx in this && this[cx] === searchElement) return cx;
48
52
  }
@@ -75,9 +79,10 @@ if (!Object.create) Object.create = function (object) {
75
79
  };
76
80
  if (!function () { }.bind) Function.prototype.bind = function (context) {
77
81
  var args = [].slice.call(arguments, 1);
82
+ var f = this;
78
83
  return function () {
79
84
  var _args = args.slice.call(arguments, 0, arguments.length);
80
85
  args.unshift.apply(_args, args);
81
- return this.apply(context === void 0 || context === null ? this : context, _args);
86
+ return f.apply(context === void 0 || context === null ? this : context, _args);
82
87
  };
83
88
  };
@@ -1,3 +1,4 @@
1
+ var mark = require("./mark");
1
2
  var dump = function (a, msg) {
2
3
  if (a instanceof Object) console.error('对象的属性不符合'), console.log(msg ? msg + " " : " ", a);
3
4
  else if (msg) console.error(msg + ":", a);
@@ -8,10 +9,17 @@ var assert = function (result, expect, log = dump) {
8
9
  var collect = function (k, args) {
9
10
  hasCollect = true;
10
11
  if (args) return function () {
11
- errors = `Except (${args}) to be ${JSON.stringify(k)}`;
12
+ errors = `结果 (${args}) 应为 ${JSON.stringify(k)}`;
12
13
  }
13
14
  if (k === undefined) return function () {
14
- errors = `Except ${result} to be ${expect}`;
15
+ var color1 = "bgred";
16
+ var color2 = "bgblue";
17
+ mark.setTag1(` </${color1}>`, `<${color1}>`);
18
+ mark.setTag2(` </${color2}>`, `<${color2}>`);
19
+ var [r, e] = mark.pair(result, expect);
20
+ r = String(r).trim();
21
+ e = String(e).trim();
22
+ errors = `<cyan>结果 </cyan><${color1}>${r}</${color1}>\r\n <cyan>应为 </cyan><${color2}>${e}</${color2}>\r\n`;
15
23
  };
16
24
  return function (error) {
17
25
  if (error instanceof Object) {
@@ -0,0 +1,13 @@
1
+ var __static = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
2
+ d.__proto__ = b;
3
+ } || extend;
4
+ var setConstructor = Object.defineProperty ? function (a, c) {
5
+ Object.defineProperty(a, "constructor", { value: c });
6
+ } : function (a, c) {
7
+ a.constructor = c;
8
+ };
9
+ // class A extends B {}
10
+ function extends_(A, B) {
11
+ __static(A, B);
12
+ A.prototype = B === null ? Object.create(null) : new (_ = function () { setConstructor(this, A) }, _.prototype = B.prototype, _);
13
+ }
@@ -59,7 +59,9 @@ var request = window.request || function (url, onload, onerror, version) {
59
59
  var loadingTree = {};
60
60
  var responseTree = {};
61
61
  var versionTree = {};
62
-
62
+ var isThenable = function (a) {
63
+ return a && a.then instanceof Function;
64
+ };
63
65
  var keyprefix = "";
64
66
  var flushTree = function (tree, key, res) {
65
67
  var response = tree[key];
@@ -138,7 +140,7 @@ var readFile = function (names, then) {
138
140
  }
139
141
  };
140
142
  var oh = function (e) {
141
- if (!isProduction) {
143
+ if (isProduction) {
142
144
  if (errorcount < 2) {
143
145
  errorcount++;
144
146
  setTimeout(tryload, 200 + 1000 * errorcount);
@@ -166,6 +168,7 @@ var killCircle = function () {
166
168
  if (k.slice(0, keyprefix.length) === keyprefix && loadedModules[k] instanceof Array) {
167
169
  var key = k.slice(keyprefix.length);
168
170
  var args = loadedModules[k].args;
171
+ if (loadedModules[k] instanceof Array) continue;
169
172
  args.forEach(arg => {
170
173
  if (!penddings[arg]) {
171
174
  penddings[arg] = [];
@@ -239,6 +242,7 @@ var loadModule = function (name, then, prebuilds = {}) {
239
242
  return;
240
243
  }
241
244
  if (loadedModules[key] instanceof Array) {
245
+ if (loadedModules[key].error) return then(key);
242
246
  loadedModules[key].push(then);
243
247
  return;
244
248
  }
@@ -286,16 +290,19 @@ var loadModule = function (name, then, prebuilds = {}) {
286
290
  mod.required = required;
287
291
  mod.file = name;
288
292
  args = args.concat(required);
289
- var errored = 0;
290
- // console.log(args);
293
+ var _errored = 0;
291
294
  var response = function (error) {
292
295
  loadingCount++;
293
296
  if (error) {
294
- errored += error;
297
+ if (!errored[error]) {
298
+ errored[error] = [];
299
+ }
300
+ errored[error].push(key);
301
+ _errored++;
295
302
  }
296
303
  if (loadingCount === args.length) {
297
- if (errored) {
298
- loadedModules[key].error = errored;
304
+ if (_errored.length) {
305
+ loadedModules[key].error = true;
299
306
  }
300
307
  flushTree(loadedModules, key, mod);
301
308
  }
@@ -314,9 +321,17 @@ var loadModule = function (name, then, prebuilds = {}) {
314
321
  }
315
322
  };
316
323
  var toRem = text => pixelDecoder && typeof text === 'string' ? text.replace(/(\:\s*)?\b((?:\d*\.)?\d+)px(\s*\))?/ig, (m, h, d, quote) => (h || "") + (d !== '1' ? h && quote ? renderPixelRatio * d + "pt" : pixelDecoder(d) : renderPixelRatio > 1 ? ".78pt" : 0.78 / devicePixelRatio + "pt") + (quote || "")) : text;
317
- if (document.head) var efrontsign = document.head.lastElementChild.attributes[0];
318
- if (efrontsign && /^compiledinfo\-/.test(efrontsign.name)) efrontsign = efrontsign.name.slice(efrontsign.name.indexOf('-') + 1);
319
- else efrontsign = '';
324
+ if (document.head) {
325
+ var efrontsign = document.head.lastElementChild.attributes[0];
326
+ if (efrontsign && /^compiledinfo\-/.test(efrontsign.name)) efrontsign = efrontsign.name.slice(efrontsign.name.indexOf('-') + 1);
327
+ else efrontsign = '';
328
+ }
329
+ else if (document.getElementsByTagName) {
330
+ document.head = document.getElementsByTagName("head")[0];
331
+ efrontsign = /\<script\s+compiledinfo\-(\S*?)\s*\=/i.exec(document.head.lastChild.outerHTML);
332
+ if (efrontsign) efrontsign = efrontsign[1];
333
+ else efrontsign = '';
334
+ }
320
335
  var uncode = function (text) {
321
336
  var ratio = 1;
322
337
  var sum = 0;
@@ -499,10 +514,7 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
499
514
  }
500
515
  return exec.apply(_this, requires.map(a => init(a)));
501
516
  };
502
- var _ok, result, created;
503
- var promise = new Promise(function (ok) {
504
- _ok = ok;
505
- });
517
+ var result, created;
506
518
  if (prebuilds.init) {
507
519
  var prebuilds2 = Object.create(null);
508
520
  for (var k in prebuilds) prebuilds2[k] = prebuilds[k];
@@ -511,17 +523,16 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
511
523
  delete prebuilds.action;
512
524
  delete prebuilds.init;
513
525
  }
514
- init(argName, function (res) {
526
+ var promise = init(argName, function (res) {
515
527
  result = res;
516
528
  created = true;
517
- _ok(res);
518
529
  }, prebuilds);
519
530
  if (created) return result;
520
531
  return promise;
521
532
  });
522
533
 
523
534
  var _this = isModuleInit ? exports : window;
524
- var argsPromises = argsList.filter(a => a instanceof Promise);
535
+ var argsPromises = argsList.filter(isThenable);
525
536
  argsList = argsList.concat(exec.strs);
526
537
  argsList.push(compiledNames || []);
527
538
  if (!argsPromises.length) {
@@ -556,8 +567,10 @@ var init = function (name, then, prebuilds) {
556
567
  var res = {
557
568
  oks,
558
569
  ohs,
559
- resolved: null,
560
- errored: null,
570
+ resolved: false,
571
+ errored: false,
572
+ result: null,
573
+ error: null,
561
574
  then(ok, oh) {
562
575
  if (ok) this.oks.push(ok);
563
576
  if (oh) this.ohs.push(oh);
@@ -567,18 +580,24 @@ var init = function (name, then, prebuilds) {
567
580
  if (this.resolved || this.errored) {
568
581
  var oks = this.oks.splice(0, this.oks.length);
569
582
  var ohs = this.ohs.splice(0, this.ohs.length);
570
- if (this.resolved) for (var o of oks) o(this.resolved);
571
- if (this.errored) for (var o of ohs) o(this.errored);
583
+ if (this.errored) for (var o of ohs) o(this.error);
584
+ if (this.resolved) for (var o of oks) o(this.result);
572
585
  }
573
586
  },
574
587
  };
575
588
  then = function (created) {
576
- if (Promise && created instanceof Promise) return created.then(then, crack);
577
- res.resolved = created;
589
+ if (res.resolved || res.errored) return;
590
+ if (isThenable(created)) return created.then(then, crack);
591
+ res.resolved = true;
592
+ res.result = created;
578
593
  res.fire();
579
594
  };
580
595
  var crack = function (error) {
581
- res.errored = error;
596
+ if (res.resolved || res.errored) return;
597
+ var ed = errored[name];
598
+ console.error(`加载${name}失败,${ed && ed.length ? `${ed.join(', ')} 等${ed.length}个模块` : "没有其他模块"}受到影响`);
599
+ res.errored = true;
600
+ res.error = error;
582
601
  res.fire();
583
602
  };
584
603
  loadModule(name, function (error) {
@@ -613,7 +632,7 @@ var init = function (name, then, prebuilds) {
613
632
  }
614
633
  }
615
634
  var created = createModule(module, args, module.argNames, prebuilds);
616
- if (created instanceof Promise) {
635
+ if (isThenable(created)) {
617
636
  if (saveAsModule) {
618
637
  penddings[key] = created;
619
638
  created.then(function (res) {
@@ -624,7 +643,6 @@ var init = function (name, then, prebuilds) {
624
643
  } else {
625
644
  if (saveAsModule) module.created = modules[name] = created;
626
645
  }
627
-
628
646
  then(created);
629
647
  }, prebuilds);
630
648
  return res;
@@ -693,7 +711,7 @@ var initPixelDecoder = function () {
693
711
  * 从pixel到offset
694
712
  */
695
713
  var calcPixel = modules.calcPixel = _calcPixel;
696
- document.documentElement.style.fontSize = `${16 * renderPixelRatio}pt`;
714
+ if (document.documentElement) document.documentElement.style.fontSize = `${16 * renderPixelRatio}pt`;
697
715
  } else {
698
716
  if (maxRenderWidth < minRenderWidth) {
699
717
  [minRenderWidth, maxRenderWidth] = [maxRenderWidth, minRenderWidth];
@@ -816,9 +834,10 @@ var loadResponseTreeFromStorage = function () {
816
834
  var preLoad = function () { };
817
835
 
818
836
  var start_time = +new Date / 1000 | 0;
819
-
837
+ var errored = {};
820
838
  var modules = {
821
839
  isProduction,
840
+ undefined: void 0,
822
841
  start_time,
823
842
  MOVELOCK_DELTA: 3 * renderPixelRatio,
824
843
  SAFE_CIRCLE_DEPTH: 300,
@@ -0,0 +1,155 @@
1
+ var couple = function (source, marker) {
2
+ var len1 = source.length;
3
+ var len2 = marker.length;
4
+ var match = "", begin1 = len1, begin2 = len2;
5
+ for (var cx = -len1, dx = len2; cx < dx; cx++) {
6
+ var c1 = cx >= 0 ? 0 : -cx;
7
+ var c2 = cx >= 0 ? cx : 0;
8
+ var d1 = len1 - c1;
9
+ var d2 = len2 - c2;
10
+ var start = 0, end = 0;
11
+ for (var ct = 0, dt = d1 > d2 ? d2 : d1; ct < dt; ct++) {
12
+ if (source[c1 + ct] === marker[c2 + ct]) {
13
+ end = ct + 1;
14
+ if (end === dt && end - start > match.length) {
15
+ match = source.slice(c1 + start, c1 + end);
16
+ begin1 = c1 + start;
17
+ begin2 = c2 + start;
18
+ }
19
+ } else {
20
+ if (end - start > match.length) {
21
+ match = source.slice(c1 + start, c1 + end);
22
+ begin1 = c1 + start;
23
+ begin2 = c2 + start;
24
+ }
25
+ start = ct + 1;
26
+ }
27
+ }
28
+ }
29
+ return [match, begin1, begin2];
30
+ };
31
+ var MARK_PRE1, MARK_PRE2, _PRE1, _PRE2 = _PRE1 = "<b>";
32
+ var MARK_AFT1, MARK_AFT2, _AFT1, _AFT2 = _AFT1 = "</b>";
33
+ var mark = function (source, search) {
34
+ return power(source, search)[1];
35
+ };
36
+ var pair = function (source, search, t1, t2, t3, t4) {
37
+ switch (arguments.length) {
38
+ case 2:
39
+ break;
40
+ case 4:
41
+ setTag1(t1, t2);
42
+ setTag2(t1, t2);
43
+ break;
44
+ case 6:
45
+ setTag1(t1, t2);
46
+ setTag2(t3, t4);
47
+ break;
48
+ }
49
+ return power2(source, search);
50
+ }
51
+ var power = function (source, search) {
52
+ if (!search || !source) {
53
+ return [0, source];
54
+ }
55
+ var matchers = couple(source, search);
56
+ var match_text = matchers[0];
57
+ var match_start2 = matchers[1];
58
+ if (search.length === 1) {
59
+ var p = 0;
60
+ var res = source.replace(new RegExp(search.replace(/[\\\*\?\+\(\)\[]/g, "\\$&"), "g"), () => {
61
+ if (!p) p = 1;
62
+ return MARK_PRE1 + search + MARK_AFT1;
63
+ });
64
+ return [p, res];
65
+ }
66
+ if (match_text.length > 1) {
67
+ var match_text_pre = source.slice(0, match_start2);
68
+ var match_text_aft = source.slice(match_start2 + match_text.length);
69
+ var pp = 0, ap = 0;
70
+ var p = match_text.length;
71
+ if (match_text_pre.length) p += .1 / match_text_pre.length - .2;
72
+ if (match_text_aft.length) p += .1 / match_text_aft.length - .1;
73
+ if (match_text_pre.length > 1) {
74
+ [pp, match_text_pre] = power(match_text_pre, search);
75
+ }
76
+ if (match_text_aft.length > 1) {
77
+ [ap, match_text_aft] = power(match_text_aft, search);
78
+ }
79
+ p += (pp + ap) * .01;
80
+ return [p, match_text_pre.concat(MARK_PRE1, match_text, MARK_AFT1, match_text_aft)];
81
+ }
82
+ return [0, source];
83
+ };
84
+
85
+
86
+ var power2 = function (src1, src2) {
87
+
88
+ if (!src2 || !src1) {
89
+ return [src1, src2, 0];
90
+ }
91
+ var matchers = couple(src1, src2);
92
+ var [match_text, match_start1, match_start2] = matchers;
93
+ if (match_text.length > 0) {
94
+ var src1_pre = src1.slice(0, match_start1);
95
+ var src1_aft = src1.slice(match_start1 + match_text.length);
96
+ var src2_pre = src2.slice(0, match_start2);
97
+ var src2_aft = src2.slice(match_start2 + match_text.length);
98
+ var pp = 0, ap = 0;
99
+ var p = match_text.length;
100
+ if (src1_pre.length) p += .1 / src1_pre.length - .2;
101
+ if (src1_aft.length) p += .1 / src1_aft.length - .1;
102
+ if (src1_pre.length > 0 && src2_pre.length > 0) {
103
+ [src1_pre, src2_pre, pp] = power2(src1_pre, src2_pre);
104
+ }
105
+ if (src1_aft.length > 0 && src2_aft.length > 0) {
106
+ [src1_aft, src2_aft, ap] = power2(src1_aft, src2_aft);
107
+ }
108
+ p += (pp + ap) * .01;
109
+ return [
110
+ src1_pre.concat(MARK_PRE1, match_text, MARK_AFT1, src1_aft),
111
+ src2_pre.concat(MARK_PRE2, match_text, MARK_AFT2, src2_aft),
112
+ p
113
+ ];
114
+ }
115
+ return [src1, src2, 0];
116
+
117
+ };
118
+
119
+
120
+ var setTag1 = function (pre, aft) {
121
+ if (arguments.length === 1) {
122
+ if (pre instanceof Array) {
123
+ [pre, aft] = pre;
124
+ }
125
+ else {
126
+ pre.replace(/^<|>$/g, '');
127
+ pre = `<${pre}>`;
128
+ aft = `</${pre}>`;
129
+ }
130
+ }
131
+ MARK_PRE1 = pre;
132
+ MARK_AFT1 = aft;
133
+ };
134
+ var setTag2 = function (pre = _PRE2, aft = _AFT2) {
135
+ if (arguments.length === 1) {
136
+ if (pre instanceof Array) {
137
+ [pre, aft] = pre;
138
+ }
139
+ else {
140
+ pre.replace(/^<|>$/g, '');
141
+ pre = `<${pre}>;`
142
+ aft = `</${pre}>`;
143
+ }
144
+ }
145
+ MARK_PRE2 = pre;
146
+ MARK_AFT2 = aft;
147
+ };
148
+ setTag1(_PRE1, _AFT1);
149
+ setTag2(_PRE2, _AFT2);
150
+ mark.setTag1 = setTag1;
151
+ mark.setTag2 = setTag2;
152
+ mark.power = power;
153
+ mark.power2 = power2;
154
+ mark.pair = pair;
155
+ mark.couple = couple;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  function queue(list, count = 1, context = null) {
3
3
  var f = this;
4
- if (list instanceof Function) {
4
+ if (isFunction(list)) {
5
5
  f = list;
6
6
  list = this;
7
7
  }
8
- if (count instanceof Object) {
8
+ if (isObject(count)) {
9
9
  let temp = count;
10
10
  count = context || temp;
11
11
  context = temp;
@@ -13,39 +13,36 @@ function queue(list, count = 1, context = null) {
13
13
  return new Promise(function (ok, oh) {
14
14
  var cx = 0;
15
15
  var result = [];
16
- var loaded_count = 0;
16
+ var promised = false;
17
17
  var error_count = 0;
18
18
  var reject = function (e) {
19
19
  error_count++;
20
20
  oh(e);
21
21
  };
22
22
  var next = function () {
23
- loaded_count++;
24
23
  run();
25
24
  };
26
25
  var run = function () {
27
- if (error_count && count === 1) return;
28
- if (cx >= list.length) return Promise.all(result).then(ok, oh);
26
+ if (error_count && count === 1) return promised = null;
27
+ if (cx >= list.length) return promised = null, count = 0, Promise.all(result).then(ok, oh);
29
28
  var saved_cx = cx;
30
29
  var args = list[cx];
31
30
  try {
32
31
  result[saved_cx] = f.call(context, args, cx++, list);
33
32
  } catch (e) {
34
33
  oh(e);
35
- return;
34
+ return promised = null;
36
35
  }
37
- Promise.resolve(result[saved_cx]).then(next, reject);
36
+ if (!promised && (!result[saved_cx] || !isFunction(result[saved_cx].then)));
37
+ else Promise.resolve(result[saved_cx]).then(next, reject), promised = true;
38
38
  };
39
- if (count > list.length >> 1) {
40
- count = list.length >> 1;
39
+ if (count > list.length) {
40
+ count = list.length;
41
41
  }
42
42
  if (!(count >= 1)) {
43
43
  count = 1;
44
44
  }
45
- if (list.length === 0) run();
46
- else while (cx < count) {
47
- run();
48
- }
45
+ while (promised === false || count-- > 0) run();
49
46
  });
50
47
  }
51
48
  module.exports = queue;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * {a:b,c:d, ...z} = o;
3
+ * params (o , [a,c])
4
+ * return z
5
+ */
6
+ function rest_(o, keys) {
7
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
8
+ var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
9
+ var map = Object.create(null);
10
+ for (var k of keys) map[k] = true;
11
+ var res = Object.create(null);
12
+ for (var k in o) {
13
+ if (hasOwnProperty.call(o, k)) {
14
+ if (k in map) continue;
15
+ res[k] = o[k];
16
+ }
17
+ }
18
+ if (typeof Object.getOwnPropertySymbols === 'function') {
19
+ for (var k of Object.getOwnPropertySymbols(o)) {
20
+ if (propertyIsEnumerable.call(o, k)) {
21
+ if (k in map) continue;
22
+ res[k] = o[k];
23
+ }
24
+ }
25
+ }
26
+ return res;
27
+ }
@@ -5,7 +5,7 @@ a => {
5
5
  if (m) a = m[1];
6
6
  a = JSON.parse(a);
7
7
  }
8
- return a.map(b => {
8
+ if (a) return a.map(b => {
9
9
  var data = {};
10
10
  if (b.data) extend(data, {
11
11
  name: b.data.filename.replace(/^[\s\S]*?\s*\-\s*/, ''),
@@ -143,11 +143,11 @@ var $scope = {
143
143
  },
144
144
  draw(buf) {
145
145
  if (!player || !player.offsetHeight || !$scope.dance) return;
146
- buf = [].map.call(buf, a => (a / 128.0 - 1) * 2 / 9 + 0.6);
146
+ buf = Array.prototype.map.call(buf, a => (a / 128.0 - 1) * 2 / 9 + 0.6);
147
147
  var width = freePixel(player.offsetWidth);
148
148
  var height = 72;
149
149
  var ratio = 1 / width * buf.length;
150
- var buf = [].map.call(buf, (y, i) => [i / buf.length, y]);
150
+ var buf = Array.prototype.map.call(buf, (y, i) => [i / buf.length, y]);
151
151
  var { sin, cos } = Math;
152
152
  var { currentTheta } = $scope;
153
153
  if (player.offsetHeight <= calcPixel(80)) {
@@ -237,6 +237,7 @@ var $scope = {
237
237
  $scope.playing = true;
238
238
  playState.width = 0;
239
239
  getMusicInfo(hash).loading_promise.then((response) => {
240
+ console.log(response)
240
241
  if (!this.playing) return;
241
242
  if (hash !== musicList.active_hash) return;
242
243
  if (response.imgUrl) {