efront 3.34.3 → 3.34.6
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/apps/kugou/favicon.ico +0 -0
- package/apps/kugou/home.js +1 -1
- package/apps/kugou/ie8.js +93 -0
- package/apps/kugou/index.html +5 -2
- package/apps/kugou/search/search.js +5 -3
- package/coms/basic/#decrypt.js +1 -0
- package/coms/basic/#loader.js +26 -14
- package/coms/basic/ArrayFill.js +1 -1
- package/coms/basic/JSAM.js +7 -3
- package/coms/basic/parseURL.js +49 -13
- package/coms/basic/parseURL_test.js +6 -1
- package/coms/basic/renderExpress.js +1 -1
- package/coms/basic_/Array2.js +1 -1
- package/coms/basic_/Promise.js +21 -14
- package/coms/basic_/[]map.js +27 -3
- package/coms/basic_/readme.md +83 -0
- package/coms/kugou/api.js +2 -2
- package/coms/kugou/bindScroll.js +0 -1
- package/coms/kugou/buildScroll.js +1 -0
- package/{apps → coms}/kugou/icons/kugo.ico +0 -0
- package/{apps → coms}/kugou/icons/kuwo.png +0 -0
- package/coms/kugou/icons/qqjt.ico +0 -0
- package/{apps → coms}/kugou/icons/yyyy.ico +0 -0
- package/coms/kugou/page.js +6 -3
- package/coms/kugou/playList.html +1 -1
- package/coms/kugou/playList.js +1 -0
- package/coms/kugou/player.html +3 -3
- package/coms/kugou/player.js +5 -4
- package/coms/zimoli/LoadingArray.js +9 -25
- package/coms/zimoli/appendChild.js +1 -1
- package/coms/zimoli/data.js +16 -6
- package/coms/zimoli/gallery.js +1 -1
- package/coms/zimoli/getGenerator.js +1 -1
- package/coms/zimoli/on.js +2 -0
- package/coms/zimoli/render.js +33 -33
- package/coms/zimoli/selectList.js +1 -1
- package/coms/zimoli/zimoli.js +4 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme.md +8 -8
- package/apps/kugou/icons/qqjt.ico +0 -0
|
Binary file
|
package/apps/kugou/home.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var page =
|
|
1
|
+
var page = document.createElement("page");
|
|
2
2
|
page.initialStyle = 'transform:scale(.9);opacity:0;';
|
|
3
3
|
var tags = "新歌:song/list:音乐总有新玩法,排行:rank/list:排行榜 - 酷狗音乐,歌单:plist/list:歌单 - 酷狗音乐,歌手:singer/keywords:歌手分类 - 酷狗音乐".split(",").map(function (tag, cx) {
|
|
4
4
|
var [str, url, title] = tag.split(":");
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
document.createElement = function (document, createElement, defineProperty) {
|
|
2
|
+
var setHTML = function (v) {
|
|
3
|
+
v = String(v);
|
|
4
|
+
var nodePath = [this], currentNode = this;
|
|
5
|
+
v.replace(/<\!\-\-[\s\S]*?(?:\-\-\!?>|$)|<(?:[^>'"]+|(["'])(?:\\[\s\S]|[\s\S])*?\1)*>|[^<]+/g, function (m, q, index) {
|
|
6
|
+
var tagCloseIndex = index + m.length + 3;
|
|
7
|
+
var isComment = /^<\!\-\-/.test(m);
|
|
8
|
+
var tag = /^<([^\s]+)([\s\S]*)\/?>/.exec(m);
|
|
9
|
+
var isTextNode = !tag;
|
|
10
|
+
if (isComment || isTextNode) {
|
|
11
|
+
if (v.charAt(tagCloseIndex - 1) !== '/' || v.slice(tagCloseIndex, tagCloseIndex + currentNode.tagName.length).toUpperCase() !== currentNode.tagName.toUpperCase()) {
|
|
12
|
+
currentNode = nodePath[nodePath.length - 1];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (isComment) {
|
|
16
|
+
var comment = document.createComment(m.replace(/^<\!\-\-|\-\-\!?>$/g, ''));
|
|
17
|
+
currentNode.appendChild(comment);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (isTextNode) {
|
|
21
|
+
var textNode = document.createTextNode(m);
|
|
22
|
+
currentNode.appendChild(textNode);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
var tagName = tag[1];
|
|
26
|
+
if (/^[!?]/.test(tagName)) return;
|
|
27
|
+
if (tagName.charAt(0) === "/") {
|
|
28
|
+
tagName = tagName.slice(1).toUpperCase();
|
|
29
|
+
while (currentNode && currentNode.tagName.toUpperCase() !== tagName) currentNode = nodePath.pop();
|
|
30
|
+
if (currentNode === nodePath[nodePath.length - 1]) nodePath.pop();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
currentNode = nodePath[nodePath.length - 1];
|
|
34
|
+
tagName = tagName.replace(/\/$/, '');
|
|
35
|
+
var element = createElement.call(document, tagName);
|
|
36
|
+
var attributes = tag[2].trim();
|
|
37
|
+
if (attributes) attributes.replace(/([^\s\'\"\=\/]+)(?:\s*\=\s*((['"])(?:\\[\s\S]|[\s\S])*?\3|\S+))?/g, function (_, name, value) {
|
|
38
|
+
if (value) value = value.replace(/^['"]|["']$/g, '').replace(/\\([\s\S])/, '$1');
|
|
39
|
+
else value = '';
|
|
40
|
+
element.setAttribute(name, value);
|
|
41
|
+
})
|
|
42
|
+
currentNode.appendChild(element);
|
|
43
|
+
if (!/^(input|meta|link|img)$/i.test(tagName) && !/\/\>$/.test(tag)) {
|
|
44
|
+
nodePath.push(element);
|
|
45
|
+
};
|
|
46
|
+
currentNode = element;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var getHTML = function () {
|
|
50
|
+
/**
|
|
51
|
+
* @type {NodeList}
|
|
52
|
+
*/
|
|
53
|
+
var childNodes = this.childNodes;
|
|
54
|
+
var text = [];
|
|
55
|
+
for (var cx = 0, dx = childNodes.length; cx < dx; cx++) {
|
|
56
|
+
var c = childNodes[cx];
|
|
57
|
+
switch (c.nodeType === 8) {
|
|
58
|
+
case 8: text.push("<!", "-", "-", c.nodeValue, "-", "-", ">"); continue;
|
|
59
|
+
case 3: text.push('"', c.nodeValue.replace(/[\\"]/g, "\\$&"), '"'); continue;
|
|
60
|
+
case 1:
|
|
61
|
+
var attributes = c.attributes;
|
|
62
|
+
text.push("<", c.nodeName);
|
|
63
|
+
for (var cy = 0, dy = attributes.length; cy < dy; cy++) {
|
|
64
|
+
var a = attributes[cy];
|
|
65
|
+
text.push(" ", a.name)
|
|
66
|
+
if (a.value) text.push("=\"", a.value.replace(/[\\"]/g, "\\$&"), "\"");
|
|
67
|
+
}
|
|
68
|
+
var innerHTML = c.innerHTML;
|
|
69
|
+
if (!innerHTML && /^(input|meta|link)$/i.test(c.nodeName)) {
|
|
70
|
+
text.push('>');
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
text.push(">", innerHTML, "</", c.nodeName, ">");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return text.join('');
|
|
77
|
+
};
|
|
78
|
+
var descriptor = { set: setHTML, get: getHTML };
|
|
79
|
+
return function (tagName) {
|
|
80
|
+
var element = createElement.call(document, tagName);
|
|
81
|
+
if (/^(style|script)$/i.test(element.tagName)) return element;
|
|
82
|
+
defineProperty(element, "innerHTML", descriptor);
|
|
83
|
+
return element;
|
|
84
|
+
};
|
|
85
|
+
}(document, document.createElement, Object.defineProperty);
|
|
86
|
+
Object.defineProperty = function (Object, defineProperty) {
|
|
87
|
+
return function (o, k, v) {
|
|
88
|
+
if (o.nodeType) return defineProperty.call(Object, o, k, v);
|
|
89
|
+
if ("value" in v) {
|
|
90
|
+
return o[k] = v.value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}(Object, Object.defineProperty);
|
package/apps/kugou/index.html
CHANGED
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
|
9
9
|
<meta charset="utf-8" />
|
|
10
10
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
11
|
-
<link rel="Shortcut Icon" href="
|
|
11
|
+
<link rel="Shortcut Icon" href="favicon.ico" type="image/x-icon" />
|
|
12
12
|
<meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
|
|
13
|
-
<title
|
|
13
|
+
<title>酷酷千百易云音乐</title>
|
|
14
|
+
<!--[if IE 8]>
|
|
15
|
+
<script src="ie8.js"></script>
|
|
16
|
+
<![endif]-->
|
|
14
17
|
<script deleteoncompile efrontloader>
|
|
15
18
|
// 若要在开发环境使用内置组件,请保留此script标签中的代码,在编译发布时,这里的代码会自动删除
|
|
16
19
|
</script>
|
|
@@ -42,7 +42,7 @@ function main(params, from) {
|
|
|
42
42
|
},
|
|
43
43
|
async requestSearch(type, id, params, mp, timeout, parse) {
|
|
44
44
|
var res = await data.lazyInstance(id, params, timeout, parse);
|
|
45
|
-
if (mp !== this.resultMap) return;
|
|
45
|
+
if (mp !== this.resultMap || !(res instanceof Array)) return;
|
|
46
46
|
res.forEach(a => a.type = type);
|
|
47
47
|
res.forEach(this.addResult, this);
|
|
48
48
|
this.result = Object.keys(this.resultMap).map(k => this.resultMap[k]).sort((a, b) => b.length - a.length);
|
|
@@ -58,20 +58,22 @@ function main(params, from) {
|
|
|
58
58
|
this.result = [];
|
|
59
59
|
if (!keyword) return;
|
|
60
60
|
var s1 = this.requestSearch("kugo", 'search', { keyword }, this.resultMap, timeout, function (s1) {
|
|
61
|
-
s1.forEach(a => {
|
|
61
|
+
if (s1 instanceof Array) s1.forEach(a => {
|
|
62
62
|
a.priced = a.privilege === 10 && (a.price_sq > 0);
|
|
63
63
|
});
|
|
64
|
+
else s1 = [];
|
|
64
65
|
return s1;
|
|
65
66
|
});
|
|
66
67
|
var s2 = this.requestSearch("kuwo", "search-kuwo", { key: keyword }, this.resultMap, timeout);
|
|
67
68
|
var s3 = this.requestSearch("yyyy", "search-yyyy", yyyc.encode({ hlposttag: "</span>", hlposttag: `<span class="s-fc7">`, limit: 30, offset: 0, s: keyword, total: true, type: 1 }), this.resultMap, timeout, function (s3) {
|
|
68
|
-
s3.forEach(a => {
|
|
69
|
+
if (s3 instanceof Array) s3.forEach(a => {
|
|
69
70
|
a.priced = a.fee === 1;
|
|
70
71
|
a.singername = a.ar.map(a => {
|
|
71
72
|
if (a.name === "." || isEmpty(a.name)) return a.alia.join("、");
|
|
72
73
|
return a.name;
|
|
73
74
|
}).join("、");
|
|
74
75
|
});
|
|
76
|
+
else s3 = [];
|
|
75
77
|
return s3;
|
|
76
78
|
});
|
|
77
79
|
var p4 = {
|
package/coms/basic/#decrypt.js
CHANGED
package/coms/basic/#loader.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var window = this;
|
|
3
|
+
var isProduction = true;
|
|
4
|
+
// <!-- isProduction = false -->
|
|
5
|
+
|
|
3
6
|
var {
|
|
4
7
|
parseInt,
|
|
5
8
|
XMLHttpRequest,
|
|
6
9
|
ActiveXObject,
|
|
7
|
-
isProduction = function develop() { return develop.name !== 'develop'; }(),
|
|
8
10
|
Error,
|
|
9
11
|
Function,
|
|
10
12
|
Array,
|
|
@@ -18,7 +20,6 @@ var {
|
|
|
18
20
|
top,
|
|
19
21
|
location,
|
|
20
22
|
Object,
|
|
21
|
-
String,
|
|
22
23
|
console,
|
|
23
24
|
efrontURI,
|
|
24
25
|
parseFloat,
|
|
@@ -137,9 +138,11 @@ var readFile = function (names, then) {
|
|
|
137
138
|
clearTimeout(flush_to_storage_timer);
|
|
138
139
|
flush_to_storage_timer = setTimeout(saveResponseTreeToStorage, 200);
|
|
139
140
|
readingCount--;
|
|
141
|
+
// <!--
|
|
140
142
|
if (readingCount === 0) {
|
|
141
143
|
killCircle();
|
|
142
144
|
}
|
|
145
|
+
// -->
|
|
143
146
|
};
|
|
144
147
|
var oh = function (e) {
|
|
145
148
|
if (isProduction) {
|
|
@@ -164,7 +167,12 @@ var createFunction = function (name, body, args, isAsync, isYield) {
|
|
|
164
167
|
|
|
165
168
|
var FILE_NAME_REG = /^https?\:|\.(html?|css|asp|jsp|php)$/i;
|
|
166
169
|
var loadedModules = {};
|
|
170
|
+
// <!--
|
|
171
|
+
var undefinedModules = {};
|
|
167
172
|
var killCircle = function () {
|
|
173
|
+
var undefinedkeys = Object.keys(undefinedModules);
|
|
174
|
+
if (undefinedkeys.length) console.warn("已使用 undefined 代替", undefinedkeys.join(", "));
|
|
175
|
+
undefinedModules = {};
|
|
168
176
|
var penddings = {}, circle = [], module_keys = [];
|
|
169
177
|
for (var k in loadedModules) {
|
|
170
178
|
if (k.slice(0, keyprefix.length) === keyprefix && loadedModules[k] instanceof Array) {
|
|
@@ -233,10 +241,11 @@ var killCircle = function () {
|
|
|
233
241
|
});
|
|
234
242
|
}
|
|
235
243
|
};
|
|
244
|
+
// -->
|
|
236
245
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
237
246
|
var loadModule = function (name, then, prebuilds = {}) {
|
|
238
247
|
if (/^(?:module|exports|define|require|window|global|undefined|__dirname|__filename)$/.test(name)) return then();
|
|
239
|
-
if ((name
|
|
248
|
+
if ((hasOwnProperty.call(prebuilds, name)) || hasOwnProperty.call(modules, name) || (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name))
|
|
240
249
|
) return then();
|
|
241
250
|
preLoad(name);
|
|
242
251
|
var key = keyprefix + name;
|
|
@@ -276,6 +285,9 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
276
285
|
flushTree(loadedModules, key);
|
|
277
286
|
return;
|
|
278
287
|
}
|
|
288
|
+
// <!--
|
|
289
|
+
if (!data) undefinedModules[name] = true;
|
|
290
|
+
// -->
|
|
279
291
|
var [argNames, body, args, required, strs, isAsync, isYield] = getArgs(data);
|
|
280
292
|
if (isProduction) {
|
|
281
293
|
strs = strs.map ? strs.map(toRem) : strs;
|
|
@@ -283,7 +295,6 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
283
295
|
body = toRem(body);
|
|
284
296
|
}
|
|
285
297
|
var mod = createFunction(name, body, argNames, isAsync, isYield);
|
|
286
|
-
if (!mod) console.log(name, mod);
|
|
287
298
|
mod.args = args;
|
|
288
299
|
mod.argNames = argNames;
|
|
289
300
|
mod.strs = strs;
|
|
@@ -412,7 +423,7 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
412
423
|
var required = exec.required;
|
|
413
424
|
if (required) required = required.map(a => loadedModules[keyprefix + a]);
|
|
414
425
|
var argsList = originNames.map(function (argName) {
|
|
415
|
-
if (argName
|
|
426
|
+
if (hasOwnProperty.call(prebuilds, argName)) {
|
|
416
427
|
return prebuilds[argName];
|
|
417
428
|
}
|
|
418
429
|
if (argName === "module") {
|
|
@@ -459,7 +470,7 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
459
470
|
var result, created;
|
|
460
471
|
if (prebuilds.init) {
|
|
461
472
|
var prebuilds2 = Object.create(null);
|
|
462
|
-
for (var k in prebuilds) prebuilds2[k] = prebuilds[k];
|
|
473
|
+
for (var k in prebuilds) if (hasOwnProperty.call(prebuilds, k)) prebuilds2[k] = prebuilds[k];
|
|
463
474
|
prebuilds = prebuilds2;
|
|
464
475
|
delete prebuilds.popup;
|
|
465
476
|
delete prebuilds.action;
|
|
@@ -489,7 +500,7 @@ var init = function (name, then, prebuilds) {
|
|
|
489
500
|
// then = bindthen(then);
|
|
490
501
|
var key = keyprefix + name;
|
|
491
502
|
if (prebuilds) {
|
|
492
|
-
if (name
|
|
503
|
+
if (hasOwnProperty.call(prebuilds, name)) {
|
|
493
504
|
if (then) then(prebuilds[name]);
|
|
494
505
|
return prebuilds[name];
|
|
495
506
|
}
|
|
@@ -585,7 +596,7 @@ var init = function (name, then, prebuilds) {
|
|
|
585
596
|
then(module.created = modules[name] = created);
|
|
586
597
|
return;
|
|
587
598
|
}
|
|
588
|
-
var filteredArgs = prebuilds ? args.filter(a => !(a
|
|
599
|
+
var filteredArgs = prebuilds ? args.filter(a => !hasOwnProperty.call(prebuilds, a)) : args;
|
|
589
600
|
|
|
590
601
|
var saveAsModule = filteredArgs.length === args.length;
|
|
591
602
|
if (!filteredArgs.length) {
|
|
@@ -794,6 +805,7 @@ var loadResponseTreeFromStorage = function () {
|
|
|
794
805
|
var preLoad = function () { };
|
|
795
806
|
var start_time = efront_time / 1000 | 0;
|
|
796
807
|
var errored = {};
|
|
808
|
+
// modules 的代码不可出现多层
|
|
797
809
|
var modules = {
|
|
798
810
|
isProduction,
|
|
799
811
|
undefined: void 0,
|
|
@@ -810,12 +822,12 @@ var modules = {
|
|
|
810
822
|
devicePixelRatio,
|
|
811
823
|
renderPixelRatio,
|
|
812
824
|
efrontsign: "",
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
825
|
+
};
|
|
826
|
+
modules.debug = function () {
|
|
827
|
+
document.addEventListener("blur", e => e.stopPropagation(), true);
|
|
828
|
+
};
|
|
829
|
+
modules.put = function (name, module) {
|
|
830
|
+
modules[name] = module;
|
|
819
831
|
};
|
|
820
832
|
var penddings = {};
|
|
821
833
|
|
package/coms/basic/ArrayFill.js
CHANGED
package/coms/basic/JSAM.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var isEmpty = require("./isEmpty");
|
|
2
2
|
var convertReg = /^(?:object|function)$/;
|
|
3
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3
4
|
var check = function (o) {
|
|
4
5
|
return o === null || typeof o === 'bigint' || o instanceof BigInt || typeof o === 'number' || typeof o === "boolean";
|
|
5
6
|
};
|
|
@@ -260,6 +261,7 @@ function parse(string, preload) {
|
|
|
260
261
|
if (!isEmpty(preload)) dist = dist.concat(preload);
|
|
261
262
|
var preloads_length = dist.length - 1;
|
|
262
263
|
dist = dist.concat(trimed.slice(1, trimed.length));
|
|
264
|
+
|
|
263
265
|
for (var cx = 0, dx = marked.length; cx < dx; cx++) {
|
|
264
266
|
var index = marked[cx];
|
|
265
267
|
var o = trimed[index];
|
|
@@ -276,11 +278,13 @@ function parse(string, preload) {
|
|
|
276
278
|
delete o[""];
|
|
277
279
|
delete o._;
|
|
278
280
|
if (arr) for (var k in arr) {
|
|
279
|
-
t[k] = dist[arr[k]];
|
|
281
|
+
if (hasOwnProperty.call(arr, k)) t[k] = dist[arr[k]];
|
|
280
282
|
}
|
|
281
283
|
for (var k in o) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
if (hasOwnProperty.call(o, k)) {
|
|
285
|
+
var v = o[k];
|
|
286
|
+
t[dist[k]] = dist[v];
|
|
287
|
+
}
|
|
284
288
|
}
|
|
285
289
|
}
|
|
286
290
|
if (trimed.length > 1 && typeof trimed[0] === 'number') {
|
package/coms/basic/parseURL.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// 下图来自 https://nodejs.org/dist/latest-v16.x/docs/api/
|
|
1
|
+
// 下图来自 https://nodejs.org/dist/latest-v16.x/docs/api/html#urlobjectauth
|
|
2
2
|
// ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
3
3
|
// │ href │
|
|
4
4
|
// ├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤
|
|
@@ -19,8 +19,46 @@
|
|
|
19
19
|
|
|
20
20
|
// -------/// ---------------1---------------------------------///////////////////2-----3--------//////// ------4----2/////5---------------------------------------------------6------------------------------------------------------------------------------------//////////////-7--5///8-------9----------//10--11---10/8/--12----////
|
|
21
21
|
var reg = /^([^\:\/\\\?#\[]+\:(?![^\:\/\\\?\#]*@|[\/\\][^\/\\]))?(?:\/\/|\\\\)?(?:(([^\:\/\\\?#]+)?(?:\:([^\/\\\?#]+))?)@)?(([^\/\\@\?\#\.]*?[^\/\\@\:\?\#\.\d][^\/\\@\:\?\#\.]*?|[^\/\\@\:\?\#\.]+(?:\:[^\@\/\\\?#\.]*[^\d\@\:\/\\\?#\.]+|(?:\.[^\/\\@\:\?\#\.]+)+))?(?:(?:\:|^)(\d+))?)(((?:\/|\\|^)[^\?#]*)?(\?([^#]*))?)(#[\s\S]*)?$/;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
class URL {
|
|
23
|
+
locate(url) {
|
|
24
|
+
if (url === undefined || url === null) url = '';
|
|
25
|
+
var [__, protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash] = reg.exec(url);
|
|
26
|
+
if (protocol) {
|
|
27
|
+
this.protocol = protocol;
|
|
28
|
+
}
|
|
29
|
+
if (host) {
|
|
30
|
+
this.auth = auth;
|
|
31
|
+
this.username = username;
|
|
32
|
+
this.password = password;
|
|
33
|
+
this.host = host;
|
|
34
|
+
this.hostname = hostname;
|
|
35
|
+
this.port = port;
|
|
36
|
+
this.path = path;
|
|
37
|
+
this.pathname = pathname;
|
|
38
|
+
this.search = search;
|
|
39
|
+
this.query = query;
|
|
40
|
+
this.hash = hash;
|
|
41
|
+
}
|
|
42
|
+
else if (pathname) {
|
|
43
|
+
this.path = path;
|
|
44
|
+
this.pathname = pathname;
|
|
45
|
+
this.search = search;
|
|
46
|
+
this.query = query;
|
|
47
|
+
this.hash = hash;
|
|
48
|
+
}
|
|
49
|
+
else if (search) {
|
|
50
|
+
this.search = search;
|
|
51
|
+
this.path = (this.pathname || '') + search;
|
|
52
|
+
this.query = query;
|
|
53
|
+
this.hash = hash;
|
|
54
|
+
}
|
|
55
|
+
else if (hash) {
|
|
56
|
+
this.hash = hash;
|
|
57
|
+
}
|
|
58
|
+
this.href = this.toString();
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
toString() {
|
|
24
62
|
var href = '';
|
|
25
63
|
if (this.protocol) href += this.protocol;
|
|
26
64
|
if (this.auth) href += "//" + this.auth + "@" + this.host;
|
|
@@ -28,19 +66,17 @@ var hrefDescriptor = {
|
|
|
28
66
|
if (this.path) href += this.path;
|
|
29
67
|
if (this.hash) href += this.hash;
|
|
30
68
|
return href;
|
|
31
|
-
},
|
|
32
|
-
set(href) {
|
|
33
|
-
Object.assign(this, parseURL(href));
|
|
34
69
|
}
|
|
35
|
-
};
|
|
36
|
-
function parse(url) {
|
|
37
|
-
if (url === undefined || url === null) url = '';
|
|
38
|
-
var [__, protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash] = reg.exec(url);
|
|
39
|
-
return { protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash };
|
|
40
70
|
}
|
|
71
|
+
// function parse(url) {
|
|
72
|
+
// if (url === undefined || url === null) url = '';
|
|
73
|
+
// var [__, protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash] = reg.exec(url);
|
|
74
|
+
// return { protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash };
|
|
75
|
+
// }
|
|
41
76
|
function parseURL(url) {
|
|
42
|
-
var obj =
|
|
43
|
-
|
|
77
|
+
var obj = new URL;
|
|
78
|
+
obj.locate(url);
|
|
44
79
|
return obj;
|
|
45
80
|
}
|
|
81
|
+
// mdn说__proto__这玩意在deno上不支持,吓我一跳,2023-01-04亲测支持
|
|
46
82
|
module.exports = parseURL;
|
|
@@ -6,15 +6,19 @@ var test = function (url, key, value) {
|
|
|
6
6
|
else console.pass(`url:${url}, key:${key}, expect:${value}, result:${parsed[key]}`);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
test('//efront.cc/kugou', 'pathname', '/kugou')
|
|
10
|
+
test('//efront.cc/kugou', 'host', 'efront.cc')
|
|
11
|
+
test('//efront.cc/kugou', 'href', '//efront.cc/kugou')
|
|
9
12
|
test('http://efront.cc/kugou', 'pathname', '/kugou')
|
|
10
13
|
test('http://efront.cc/kugou?a', 'path', '/kugou?a')
|
|
14
|
+
test('http://efront.cc/kugou?a', 'href', 'http://efront.cc/kugou?a')
|
|
11
15
|
test('http://yunxu1019@live.cn@github.com/?a', 'username', 'yunxu1019@live.cn')
|
|
12
16
|
test('localhost', 'host', 'localhost')
|
|
13
17
|
test('localhost:80', 'port', '80')
|
|
14
18
|
test('localhost:80/', 'port', '80')
|
|
15
19
|
test('magnet:?xt=::', 'search', '?xt=::')
|
|
16
20
|
test('magnet:?xt=::', 'protocol', 'magnet:')
|
|
17
|
-
test('magnet:?xt=::', 'host',
|
|
21
|
+
test('magnet:?xt=::', 'host', undefined)
|
|
18
22
|
test('magnet:?xt=::', 'pathname', undefined)
|
|
19
23
|
test('efront.cc', 'host', 'efront.cc')
|
|
20
24
|
test('127.0.0.1', 'host', '127.0.0.1')
|
|
@@ -35,6 +39,7 @@ test('efront.', 'pathname', "efront.")
|
|
|
35
39
|
test('http//:80', 'hostname', 'http')
|
|
36
40
|
test('http//:80', 'pathname', '//:80')
|
|
37
41
|
test('//h:80', 'host', 'h:80')
|
|
42
|
+
test('//h:80', 'href', '//h:80')
|
|
38
43
|
test('?80', 'path', '?80')
|
|
39
44
|
test('?80', 'search', '?80')
|
|
40
45
|
test('?80', 'query', '80')
|
package/coms/basic_/Array2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
|
|
2
2
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3
|
-
for (var p in proto) if (
|
|
3
|
+
for (var p in proto) if (hasOwnProperty.call(proto, p) && !(p in obj)) obj[p] = proto[p];
|
|
4
4
|
return obj;
|
|
5
5
|
}
|
|
6
6
|
function Array2() {
|
package/coms/basic_/Promise.js
CHANGED
|
@@ -20,11 +20,18 @@ if (window.Promise) {
|
|
|
20
20
|
for (var t of threads) {
|
|
21
21
|
if (t.oked) {
|
|
22
22
|
for (var r of t.PromiseFulfillReactions) {
|
|
23
|
-
r.
|
|
23
|
+
r.call(null, t.oked[0]);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
if (t.ohed) {
|
|
27
|
-
|
|
27
|
+
var throwed = t.throwed;
|
|
28
|
+
t.throwed = true;
|
|
29
|
+
if (!throwed && !t.PromiseRejectReactions.length) {
|
|
30
|
+
// <!--
|
|
31
|
+
console.warn("在异步过程中发现未处理的异常:", t.ohed[0], t.ohed[1], t.ohed[2]);
|
|
32
|
+
// -->
|
|
33
|
+
throw t.ohed[0];
|
|
34
|
+
}
|
|
28
35
|
for (var r of t.PromiseRejectReactions) {
|
|
29
36
|
r.apply(null, t.ohed);
|
|
30
37
|
}
|
|
@@ -42,21 +49,21 @@ if (window.Promise) {
|
|
|
42
49
|
this.PromiseFulfillReactions = []; //thens
|
|
43
50
|
this.PromiseRejectReactions = []; //catches
|
|
44
51
|
this.oked = this.ohed = null;
|
|
45
|
-
|
|
46
|
-
var ResolvingFunctions_resolve = (result)
|
|
47
|
-
if (
|
|
52
|
+
var p = this;
|
|
53
|
+
var ResolvingFunctions_resolve = function (result) { //ok
|
|
54
|
+
if (p.oked || p.ohed) return;
|
|
48
55
|
if (isThenable(result)) {
|
|
49
56
|
result.then(ResolvingFunctions_resolve, ResolvingFunctions_reject);
|
|
50
57
|
} else {
|
|
51
|
-
|
|
52
|
-
fire(
|
|
58
|
+
p.oked = arguments;
|
|
59
|
+
fire(p);
|
|
53
60
|
}
|
|
54
61
|
};
|
|
55
62
|
|
|
56
|
-
var ResolvingFunctions_reject = (e)
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
fire(
|
|
63
|
+
var ResolvingFunctions_reject = function (e) { //oh
|
|
64
|
+
if (p.oked || p.ohed) return;
|
|
65
|
+
p.ohed = arguments;
|
|
66
|
+
fire(p);
|
|
60
67
|
};
|
|
61
68
|
executor(ResolvingFunctions_resolve, ResolvingFunctions_reject);
|
|
62
69
|
};
|
|
@@ -69,15 +76,15 @@ if (window.Promise) {
|
|
|
69
76
|
a = onok(a);
|
|
70
77
|
ok(a);
|
|
71
78
|
} catch (e) {
|
|
72
|
-
oh(e);
|
|
79
|
+
oh(e, onok, onoh);
|
|
73
80
|
}
|
|
74
81
|
};
|
|
75
82
|
if (onoh) reject = function (a) {
|
|
76
83
|
try {
|
|
77
|
-
a = onoh(
|
|
84
|
+
a = onoh.apply(null, arguments);
|
|
78
85
|
ok(a);
|
|
79
86
|
} catch (e) {
|
|
80
|
-
oh(e);
|
|
87
|
+
oh(e, onok, onoh);
|
|
81
88
|
}
|
|
82
89
|
};
|
|
83
90
|
})
|
package/coms/basic_/[]map.js
CHANGED
|
@@ -5,6 +5,7 @@ var {
|
|
|
5
5
|
String,
|
|
6
6
|
Object,
|
|
7
7
|
isFinite,
|
|
8
|
+
document,
|
|
8
9
|
console
|
|
9
10
|
} = this;
|
|
10
11
|
|
|
@@ -33,7 +34,7 @@ function forEach(f, o) {
|
|
|
33
34
|
}
|
|
34
35
|
function filter(f, o) {
|
|
35
36
|
if (!(f instanceof Function)) return;
|
|
36
|
-
var result =
|
|
37
|
+
var result = Object.create(this.constructor.prototype);
|
|
37
38
|
if (this instanceof String) {
|
|
38
39
|
result = this.split("").filter(f, o);
|
|
39
40
|
}
|
|
@@ -73,14 +74,37 @@ if (!ArrayProto.filter) ArrayProto.filter = filter;
|
|
|
73
74
|
if (!"".trim) String.prototype.trim = trim;
|
|
74
75
|
if (!Object.keys) Object.keys = keys;
|
|
75
76
|
if (!Object.create) Object.create = function (object) {
|
|
76
|
-
|
|
77
|
+
if (object === null) {
|
|
78
|
+
// 参考 https://github.com/tarruda/object-create
|
|
79
|
+
var iframe = document.createElement('iframe');
|
|
80
|
+
var parent = document.body || document.documentElement;
|
|
81
|
+
iframe.style.display = 'none';
|
|
82
|
+
parent.appendChild(iframe);
|
|
83
|
+
iframe.src = 'javascript:';
|
|
84
|
+
var empty = iframe.contentWindow.Object.prototype;
|
|
85
|
+
parent.removeChild(iframe);
|
|
86
|
+
iframe = null;
|
|
87
|
+
delete empty.constructor;
|
|
88
|
+
delete empty.hasOwnProperty;
|
|
89
|
+
delete empty.propertyIsEnumerable;
|
|
90
|
+
delete empty.isPrototypeOf;
|
|
91
|
+
delete empty.toLocaleString;
|
|
92
|
+
delete empty.toString;
|
|
93
|
+
delete empty.valueOf;
|
|
94
|
+
return empty;
|
|
95
|
+
};
|
|
96
|
+
var f = function () { };
|
|
97
|
+
f.prototype = object;
|
|
98
|
+
return new f;
|
|
77
99
|
};
|
|
78
100
|
if (!Function.prototype.bind) Function.prototype.bind = function (context) {
|
|
79
101
|
var args = [].slice.call(arguments, 1);
|
|
80
102
|
var f = this;
|
|
81
|
-
|
|
103
|
+
var c = function () {
|
|
82
104
|
var _args = args.slice.call(arguments, 0, arguments.length);
|
|
83
105
|
args.unshift.apply(_args, args);
|
|
84
106
|
return f.apply(context === void 0 || context === null ? this : context, _args);
|
|
85
107
|
};
|
|
108
|
+
c.prototype = this.prototype;
|
|
109
|
+
return c;
|
|
86
110
|
};
|