efront 3.22.9 → 3.24.2
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.
- package/coms/basic/BigNumber.js +28 -5
- package/coms/basic/BigNumber_test.js +14 -1
- package/coms/basic/[]map.js +18 -13
- package/coms/basic/loader.js +25 -11
- package/coms/basic/parseKV.js +3 -2
- package/coms/compile/common.js +5 -0
- package/coms/compile/scanner2.js +13 -1
- package/coms/kugou/parseSongsList.js +1 -1
- package/coms/kugou/player.js +3 -2
- package/coms/layer/glance.js +0 -21
- package/coms/zimoli/Promise.js +84 -133
- package/coms/zimoli/appendChild.js +4 -14
- package/coms/zimoli/cless.js +11 -5
- package/coms/zimoli/color.js +0 -1
- package/coms/zimoli/cross.js +1 -1
- package/coms/zimoli/data.js +6 -2
- package/coms/zimoli/dispatch.js +1 -1
- package/coms/zimoli/input.js +39 -6
- package/coms/zimoli/moveupon.js +32 -4
- package/coms/zimoli/on.js +64 -47
- package/coms/zimoli/remove.js +0 -9
- package/coms/zimoli/render.js +2 -2
- package/coms/zimoli/table.js +18 -4
- package/coms/zimoli/view.js +0 -1
- package/coms/zimoli/zimoli.js +2 -2
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/basic/BigNumber.js
CHANGED
|
@@ -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
|
-
|
|
202
|
-
|
|
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
|
-
|
|
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");
|
package/coms/basic/[]map.js
CHANGED
|
@@ -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
|
|
16
|
-
if (cx
|
|
17
|
-
|
|
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
|
|
28
|
-
if (cx
|
|
29
|
-
|
|
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
|
|
39
|
-
if (cx
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
86
|
+
return f.apply(context === void 0 || context === null ? this : context, _args);
|
|
82
87
|
};
|
|
83
88
|
};
|
package/coms/basic/loader.js
CHANGED
|
@@ -314,9 +314,17 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
316
|
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)
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
if (document.head) {
|
|
318
|
+
var efrontsign = document.head.lastElementChild.attributes[0];
|
|
319
|
+
if (efrontsign && /^compiledinfo\-/.test(efrontsign.name)) efrontsign = efrontsign.name.slice(efrontsign.name.indexOf('-') + 1);
|
|
320
|
+
else efrontsign = '';
|
|
321
|
+
}
|
|
322
|
+
else if (document.getElementsByTagName) {
|
|
323
|
+
document.head = document.getElementsByTagName("head")[0];
|
|
324
|
+
efrontsign = /\<script\s+compiledinfo\-(\S*?)\s*\=/i.exec(document.head.lastChild.outerHTML);
|
|
325
|
+
if (efrontsign) efrontsign = efrontsign[1];
|
|
326
|
+
else efrontsign = '';
|
|
327
|
+
}
|
|
320
328
|
var uncode = function (text) {
|
|
321
329
|
var ratio = 1;
|
|
322
330
|
var sum = 0;
|
|
@@ -556,8 +564,10 @@ var init = function (name, then, prebuilds) {
|
|
|
556
564
|
var res = {
|
|
557
565
|
oks,
|
|
558
566
|
ohs,
|
|
559
|
-
resolved:
|
|
560
|
-
errored:
|
|
567
|
+
resolved: false,
|
|
568
|
+
errored: false,
|
|
569
|
+
result: null,
|
|
570
|
+
error: null,
|
|
561
571
|
then(ok, oh) {
|
|
562
572
|
if (ok) this.oks.push(ok);
|
|
563
573
|
if (oh) this.ohs.push(oh);
|
|
@@ -567,18 +577,22 @@ var init = function (name, then, prebuilds) {
|
|
|
567
577
|
if (this.resolved || this.errored) {
|
|
568
578
|
var oks = this.oks.splice(0, this.oks.length);
|
|
569
579
|
var ohs = this.ohs.splice(0, this.ohs.length);
|
|
570
|
-
if (this.
|
|
571
|
-
if (this.
|
|
580
|
+
if (this.errored) for (var o of ohs) o(this.error);
|
|
581
|
+
if (this.resolved) for (var o of oks) o(this.result);
|
|
572
582
|
}
|
|
573
583
|
},
|
|
574
584
|
};
|
|
575
585
|
then = function (created) {
|
|
586
|
+
if (res.resolved || res.errored) return;
|
|
576
587
|
if (Promise && created instanceof Promise) return created.then(then, crack);
|
|
577
|
-
res.resolved =
|
|
588
|
+
res.resolved = true;
|
|
589
|
+
res.result = created;
|
|
578
590
|
res.fire();
|
|
579
591
|
};
|
|
580
592
|
var crack = function (error) {
|
|
581
|
-
res.errored
|
|
593
|
+
if (res.resolved || res.errored) return;
|
|
594
|
+
res.errored = true;
|
|
595
|
+
res.error = error;
|
|
582
596
|
res.fire();
|
|
583
597
|
};
|
|
584
598
|
loadModule(name, function (error) {
|
|
@@ -624,7 +638,6 @@ var init = function (name, then, prebuilds) {
|
|
|
624
638
|
} else {
|
|
625
639
|
if (saveAsModule) module.created = modules[name] = created;
|
|
626
640
|
}
|
|
627
|
-
|
|
628
641
|
then(created);
|
|
629
642
|
}, prebuilds);
|
|
630
643
|
return res;
|
|
@@ -693,7 +706,7 @@ var initPixelDecoder = function () {
|
|
|
693
706
|
* 从pixel到offset
|
|
694
707
|
*/
|
|
695
708
|
var calcPixel = modules.calcPixel = _calcPixel;
|
|
696
|
-
document.documentElement.style.fontSize = `${16 * renderPixelRatio}pt`;
|
|
709
|
+
if (document.documentElement) document.documentElement.style.fontSize = `${16 * renderPixelRatio}pt`;
|
|
697
710
|
} else {
|
|
698
711
|
if (maxRenderWidth < minRenderWidth) {
|
|
699
712
|
[minRenderWidth, maxRenderWidth] = [maxRenderWidth, minRenderWidth];
|
|
@@ -819,6 +832,7 @@ var start_time = +new Date / 1000 | 0;
|
|
|
819
832
|
|
|
820
833
|
var modules = {
|
|
821
834
|
isProduction,
|
|
835
|
+
undefined: void 0,
|
|
822
836
|
start_time,
|
|
823
837
|
MOVELOCK_DELTA: 3 * renderPixelRatio,
|
|
824
838
|
SAFE_CIRCLE_DEPTH: 300,
|
package/coms/basic/parseKV.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var trim = a => a.trim();
|
|
3
|
+
function parseKV(string, spliter = "&", equals = "=", decode) {
|
|
3
4
|
var object = {};
|
|
4
|
-
|
|
5
|
+
if (!decode) decode = spliter === "&" && equals === "=" ? decodeURIComponent : trim;
|
|
5
6
|
if (typeof string === "string") {
|
|
6
7
|
var kvs = string.split(spliter);
|
|
7
8
|
for (var cx = 0, dx = kvs.length; cx < dx; cx++) {
|
package/coms/compile/common.js
CHANGED
|
@@ -648,6 +648,11 @@ var createString = function (parsed) {
|
|
|
648
648
|
if (!pressed && lasttype !== SPACE) result.push(" ");
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
+
if (o.type === VALUE) {
|
|
652
|
+
if (/^0[0-7]+$/.test(o.text)) {
|
|
653
|
+
o.text = '0o' + o.text.slice(1);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
651
656
|
result.push(o.text);
|
|
652
657
|
}
|
|
653
658
|
else {
|
package/coms/compile/scanner2.js
CHANGED
|
@@ -109,7 +109,6 @@ var detour = function (o, ie) {
|
|
|
109
109
|
break;
|
|
110
110
|
case EXPRESS:
|
|
111
111
|
if (!/^\.\.\.|\.\.\.$/.test(o.text)) {
|
|
112
|
-
var ot = o.text;
|
|
113
112
|
o.text = o.text.replace(/\.([^\.\[]+)/g, (_, a) => ie === undefined || program.strap_reg.test(a) ? `[${strings.encode(strings.decode(a))}]` : _);
|
|
114
113
|
}
|
|
115
114
|
break;
|
|
@@ -285,6 +284,19 @@ class Program extends Array {
|
|
|
285
284
|
compress(this.scoped);
|
|
286
285
|
return this;
|
|
287
286
|
}
|
|
287
|
+
relink(list = this) {
|
|
288
|
+
var p = null;
|
|
289
|
+
for (var o of list) {
|
|
290
|
+
if (o.type === COMMENT || o.type === SPACE) continue;
|
|
291
|
+
o.prev = p;
|
|
292
|
+
if (!p) list.first = o;
|
|
293
|
+
else p.next = o;
|
|
294
|
+
p = o;
|
|
295
|
+
}
|
|
296
|
+
if (p) p.next = null;
|
|
297
|
+
list.lastUncomment = p;
|
|
298
|
+
return list;
|
|
299
|
+
}
|
|
288
300
|
}
|
|
289
301
|
|
|
290
302
|
var isShortMethodEnd = function (o) {
|
package/coms/kugou/player.js
CHANGED
|
@@ -143,11 +143,11 @@ var $scope = {
|
|
|
143
143
|
},
|
|
144
144
|
draw(buf) {
|
|
145
145
|
if (!player || !player.offsetHeight || !$scope.dance) return;
|
|
146
|
-
buf =
|
|
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 =
|
|
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) {
|
package/coms/layer/glance.js
CHANGED
|
@@ -7,28 +7,7 @@ var dragview = function (dragview) {
|
|
|
7
7
|
savedX = event.clientX;
|
|
8
8
|
savedY = event.clientY;
|
|
9
9
|
offsetWidth = menu.offsetWidth;
|
|
10
|
-
var { target } = event;
|
|
11
10
|
moving = null;
|
|
12
|
-
if (/(input|textarea|select)/i.test(target.tagName) || getTargetIn(a => a.contentEditbale || a.draggable, event.target)) {
|
|
13
|
-
moving = false;
|
|
14
|
-
} else {
|
|
15
|
-
var { childNodes } = target;
|
|
16
|
-
if (getComputedStyle(target).cursor === 'auto' && getComputedStyle(target).userSelect !== 'none') for (var cx = 0, dx = childNodes.length; cx < dx; cx++) {
|
|
17
|
-
var child = childNodes[cx];
|
|
18
|
-
if (child.nodeType === 3) {
|
|
19
|
-
moving = false;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (moving !== false) do {
|
|
24
|
-
var contentEditbale = target.getAttribute("contenteditable") !== null;
|
|
25
|
-
if (contentEditbale) {
|
|
26
|
-
moving = false;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
target = target.parentNode;
|
|
30
|
-
} while (target && target.nodeType == 1);
|
|
31
|
-
}
|
|
32
11
|
},
|
|
33
12
|
move(event) {
|
|
34
13
|
if (moving === false) return;
|
package/coms/zimoli/Promise.js
CHANGED
|
@@ -4,177 +4,128 @@ var setTimeout = window.setTimeout;
|
|
|
4
4
|
var Function = window.Function;
|
|
5
5
|
var console = window.console;
|
|
6
6
|
var Error = window.Error;
|
|
7
|
+
var requestAnimationFrame = window.setImmediate || window.setTimeout;
|
|
7
8
|
var isFunction = function (f) {
|
|
8
9
|
return typeof f === "function";
|
|
9
10
|
};
|
|
10
11
|
if (window.Promise) {
|
|
11
12
|
var Promise = window.Promise;
|
|
12
13
|
} else {
|
|
13
|
-
var
|
|
14
|
-
return pendding instanceof Promise || pendding && isFunction(pendding.then)
|
|
14
|
+
var isThenable = function (pendding) {
|
|
15
|
+
return pendding instanceof Promise || pendding && isFunction(pendding.then);
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
oh.apply(null, _ohed);
|
|
24
|
-
} else {
|
|
25
|
-
_ok = ok;
|
|
26
|
-
_oh = oh;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var _promise = new Promise(runable);
|
|
30
|
-
var onpermit = function (f, args) {
|
|
31
|
-
if (!removeed) {
|
|
32
|
-
try {
|
|
33
|
-
var pendding = f.apply(null, args);
|
|
34
|
-
if (_ok) _ok(pendding);
|
|
35
|
-
else _oked = [pendding];
|
|
36
|
-
} catch (e) {
|
|
37
|
-
if (_oh) _oh(e);
|
|
38
|
-
else _ohed = [e];
|
|
17
|
+
var queue = [];
|
|
18
|
+
var run = function (q) {
|
|
19
|
+
var threads = queue.splice(0, queue.length);
|
|
20
|
+
for (var t of threads) {
|
|
21
|
+
if (t.oked) {
|
|
22
|
+
for (var r of t.PromiseFulfillReactions) {
|
|
23
|
+
r.apply(null, t.oked);
|
|
39
24
|
}
|
|
40
|
-
removeed = true;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var onresolve = function () {
|
|
44
|
-
if (okfun instanceof Function) onpermit(okfun, arguments);
|
|
45
|
-
if (!removeed) {
|
|
46
|
-
if (_ok) _ok.apply(null, arguments);
|
|
47
|
-
else _oked = arguments;
|
|
48
|
-
removeed = true;
|
|
49
25
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
else _ohed = arguments;
|
|
56
|
-
removeed = true;
|
|
26
|
+
if (t.ohed) {
|
|
27
|
+
if (!t.PromiseRejectReactions.length) throw `未处理的异常:${t.ohed}`;
|
|
28
|
+
for (var r of t.PromiseRejectReactions) {
|
|
29
|
+
r.apply(null, t.ohed);
|
|
30
|
+
}
|
|
57
31
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
32
|
+
t.PromiseRejectReactions.splice(0, t.PromiseRejectReactions.length);
|
|
33
|
+
t.PromiseFulfillReactions.splice(0, t.PromiseFulfillReactions.length);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var fire = function (p) {
|
|
37
|
+
if (queue.length) return queue.push(p);
|
|
38
|
+
queue.push(p);
|
|
39
|
+
requestAnimationFrame(run);
|
|
40
|
+
};
|
|
64
41
|
var Promise = function (executor) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
this.PromiseFulfillReactions = []; //thens
|
|
43
|
+
this.PromiseRejectReactions = []; //catches
|
|
44
|
+
this.oked = this.ohed = null;
|
|
68
45
|
|
|
69
46
|
var ResolvingFunctions_resolve = (result) => { //ok
|
|
70
|
-
if (
|
|
71
|
-
|
|
47
|
+
if (this.oked || this.ohed) return;
|
|
48
|
+
if (isThenable(result)) {
|
|
49
|
+
result.then(ResolvingFunctions_resolve, ResolvingFunctions_reject);
|
|
72
50
|
} else {
|
|
73
|
-
|
|
74
|
-
this
|
|
51
|
+
this.oked = arguments;
|
|
52
|
+
fire(this);
|
|
75
53
|
}
|
|
76
54
|
};
|
|
77
55
|
|
|
78
56
|
var ResolvingFunctions_reject = (e) => { //oh
|
|
79
|
-
|
|
80
|
-
this.
|
|
57
|
+
if (this.oked || this.ohed) return;
|
|
58
|
+
this.ohed = arguments;
|
|
59
|
+
fire(this);
|
|
81
60
|
};
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
executor(ResolvingFunctions_resolve, ResolvingFunctions_reject);
|
|
85
|
-
} catch (e) {
|
|
86
|
-
ResolvingFunctions_reject(e);
|
|
87
|
-
}
|
|
61
|
+
executor(ResolvingFunctions_resolve, ResolvingFunctions_reject);
|
|
88
62
|
};
|
|
89
63
|
Promise.prototype = {
|
|
90
64
|
then(onok, onoh) {
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
65
|
+
var resolve, reject;
|
|
66
|
+
var promise = new Promise(function (ok, oh) {
|
|
67
|
+
if (onok) resolve = function (a) {
|
|
68
|
+
try {
|
|
69
|
+
a = onok(a);
|
|
70
|
+
ok(a);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
oh(e);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (onoh) reject = function (a) {
|
|
76
|
+
try {
|
|
77
|
+
a = onoh(a);
|
|
78
|
+
ok(a);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
oh(e);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
})
|
|
84
|
+
if (resolve) this.PromiseFulfillReactions.push(resolve);
|
|
85
|
+
if (reject) this.PromiseRejectReactions.push(reject);
|
|
86
|
+
if (this.oked || this.ohed) fire(this);
|
|
87
|
+
return promise;
|
|
95
88
|
},
|
|
96
89
|
catch(f) {
|
|
97
90
|
return this.then(null, f);
|
|
98
91
|
},
|
|
99
|
-
run(threads, args) {
|
|
100
|
-
if (threads.pendding) return;
|
|
101
|
-
threads.pendding = true;
|
|
102
|
-
setTimeout(_ => {
|
|
103
|
-
do {
|
|
104
|
-
var next = threads.shift();
|
|
105
|
-
if (next instanceof Function) {
|
|
106
|
-
next.apply(null, args);
|
|
107
|
-
}
|
|
108
|
-
} while (threads.length);
|
|
109
|
-
this.PromiseRejectReactions.splice(0, this.PromiseRejectReactions.length);
|
|
110
|
-
this.PromiseFulfillReactions.splice(0, this.PromiseFulfillReactions.length);
|
|
111
|
-
threads.pendding = false;
|
|
112
|
-
}, 0);
|
|
113
|
-
}
|
|
114
92
|
}
|
|
115
93
|
Promise.all = function (penddings) {
|
|
116
94
|
return new Promise(function (ok, oh) {
|
|
117
95
|
if (!(penddings && penddings.length)) {
|
|
118
96
|
return ok();
|
|
119
97
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
results
|
|
130
|
-
if (++resolved_count === dx) {
|
|
131
|
-
ok(results);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}(cx));
|
|
135
|
-
pendding.catch(function (e) {
|
|
136
|
-
if (rejected_count++ === 0) {
|
|
137
|
-
oh(e);
|
|
98
|
+
var resolved_count = 0,
|
|
99
|
+
results = Array(penddings.length);
|
|
100
|
+
for (var cx = 0, dx = penddings.length; cx < dx; cx++) {
|
|
101
|
+
var pendding = penddings[cx];
|
|
102
|
+
if (isThenable(pendding)) {
|
|
103
|
+
pendding.then(function (cx) {
|
|
104
|
+
return function (arg) {
|
|
105
|
+
results[cx] = arg;
|
|
106
|
+
if (++resolved_count === dx) {
|
|
107
|
+
ok(results);
|
|
138
108
|
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} catch (e) {
|
|
148
|
-
oh(e);
|
|
109
|
+
};
|
|
110
|
+
}(cx), oh);
|
|
111
|
+
} else {
|
|
112
|
+
results[cx] = pendding;
|
|
113
|
+
if (++resolved_count === dx) {
|
|
114
|
+
ok(results);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
149
117
|
}
|
|
150
118
|
});
|
|
151
119
|
};
|
|
152
120
|
Promise.race = function (penddings) {
|
|
153
121
|
return new Promise(function (ok, oh) {
|
|
154
|
-
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
pendding.then(function (cx) {
|
|
162
|
-
return function (arg) {
|
|
163
|
-
if (++resolved_count === 0) {
|
|
164
|
-
ok(arg);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}(cx)).catch(function (e) {
|
|
168
|
-
if (rejected_count++ === dx) {
|
|
169
|
-
oh(e);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
} else {
|
|
173
|
-
results[cx] = pendding;
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
} catch (e) {
|
|
177
|
-
oh(e);
|
|
122
|
+
for (var cx = 0, dx = penddings.length; cx < dx; cx++) {
|
|
123
|
+
var pendding = penddings[cx];
|
|
124
|
+
if (isThenable(pendding)) {
|
|
125
|
+
pendding.then(ok, oh);
|
|
126
|
+
} else {
|
|
127
|
+
ok(pendding);
|
|
128
|
+
};
|
|
178
129
|
}
|
|
179
130
|
});
|
|
180
131
|
};
|
|
@@ -15,18 +15,9 @@ function _onappend(node, append = createEvent("append"), mount = createEvent("mo
|
|
|
15
15
|
if (node.isMounted) return;
|
|
16
16
|
if (node.nodeType === 1 || node.nodeType === 8) node.isMounted = true;
|
|
17
17
|
dispatch(node, append);
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
append_handler.call(this, append);
|
|
22
|
-
}, node);
|
|
23
|
-
}
|
|
24
|
-
if (isFunction(onappend)) {
|
|
25
|
-
onappend.call(node, append);
|
|
26
|
-
}
|
|
27
|
-
var children = [].concat.apply([], node.childNodes);
|
|
28
|
-
if (children) for (var cx = 0, dx = children.length; cx < dx; cx++) {
|
|
29
|
-
_onappend(children[cx], append, mount);
|
|
18
|
+
var children = [...node.childNodes];
|
|
19
|
+
for (var c of children) {
|
|
20
|
+
_onappend(c, append, mount);
|
|
30
21
|
}
|
|
31
22
|
dispatch(node, mount);
|
|
32
23
|
}
|
|
@@ -93,8 +84,7 @@ function insertAfter(alreadyMounted, obj, transition) {
|
|
|
93
84
|
if (o.removeTimer) clearTimeout(o.removeTimer);
|
|
94
85
|
_insertBefore.call(parent, o, alreadyMounted.nextSibling);
|
|
95
86
|
o.with && insertBefore(alreadyMounted.nextSibling, o.with, transition);
|
|
96
|
-
if (isMounted(parent))
|
|
97
|
-
_onappend(o);
|
|
87
|
+
if (isMounted(parent)) _onappend(o);
|
|
98
88
|
if (hasEnterStyle(o) && transition !== false) {
|
|
99
89
|
isFunction(appendChild.transition) && appendChild.transition(o);
|
|
100
90
|
}
|