efront 3.34.4 → 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/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/playList.html +1 -1
- package/coms/kugou/playList.js +1 -0
- package/coms/kugou/player.html +3 -3
- package/coms/kugou/player.js +4 -3
- 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/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme.md +8 -8
|
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>
|
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,7 +285,9 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
276
285
|
flushTree(loadedModules, key);
|
|
277
286
|
return;
|
|
278
287
|
}
|
|
279
|
-
|
|
288
|
+
// <!--
|
|
289
|
+
if (!data) undefinedModules[name] = true;
|
|
290
|
+
// -->
|
|
280
291
|
var [argNames, body, args, required, strs, isAsync, isYield] = getArgs(data);
|
|
281
292
|
if (isProduction) {
|
|
282
293
|
strs = strs.map ? strs.map(toRem) : 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
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# efront 兼容性说明
|
|
2
|
+
* `coms/basic_`目录的代码均为非标准实现,如果你要兼容低版本的运行环境,尽量避免使用高级的功能
|
|
3
|
+
* 已知在转换成低版本代码后与高级版本有区别的语法如下:
|
|
4
|
+
1. ```javascript
|
|
5
|
+
class ... extends Array {...}
|
|
6
|
+
```
|
|
7
|
+
因为如果增加一级原型,数组的特性便会消失,`efront`暂时并没有实现完美的降级方案,未来实现的可能性也不大。类似语句经`typescript`转换后新定义的方法会丢失, `efront` 在降级编译期使用 `class ... extends Array2 {...}` 进行替换,`Array2`会将定义的方法挂载到新生成的对象上。
|
|
8
|
+
|
|
9
|
+
2. ```javascript
|
|
10
|
+
async function () {
|
|
11
|
+
await ...;
|
|
12
|
+
arguments; // typescript 转换后arguments对象的内容有误
|
|
13
|
+
}
|
|
14
|
+
// 或
|
|
15
|
+
function* (){
|
|
16
|
+
yield ...;
|
|
17
|
+
arguments;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
这不是一个难解决的问题,应该只是`typescript`已发现但不愿解决的问题。`efront`在降级编译时临时使用变量重命名的方法对代码中的`arguments`进行替换使其内容与原生高级代码一致。
|
|
21
|
+
|
|
22
|
+
3. ```javascript
|
|
23
|
+
Object.keys
|
|
24
|
+
Object.create
|
|
25
|
+
Array.prototype.map
|
|
26
|
+
Array.prototype.forEach
|
|
27
|
+
Array.prototype.filter
|
|
28
|
+
Array.prototype.indexOf
|
|
29
|
+
String.prototype.trim// 不同的支持环境实现不一致,大厂对空格的理解不一致
|
|
30
|
+
Function.prototype.bind
|
|
31
|
+
```
|
|
32
|
+
以上几个方法`ie9+`系列浏览器已支持,但`ie8`及以下版本不支持,如果没有指定`--no-polyfill`参数`efront`在降级编译期会使用`[]map.js`中提供的方法进行修补,这些方法会在加载器检测到浏览器不支持`[].map`时进行初始化
|
|
33
|
+
4. ```javascript
|
|
34
|
+
Object.assign
|
|
35
|
+
Array.prototype.fill
|
|
36
|
+
```
|
|
37
|
+
以上两个原生方法`ie`系列浏览器均不支持,由于经常被`efront`开发者使用,在降级编译期,如果没有指定`--no-polyfill`参数,将由`efront`处理成替代品,当前的处理方案如下:
|
|
38
|
+
```javascript
|
|
39
|
+
Object.assign // 由 extend 替代,见 ../basic/extend.js
|
|
40
|
+
Array.prototype.fill //..将按使用的目的进行不同的替换
|
|
41
|
+
Array(3).fill(0) // 类似这种的将变成[0,0,0]一个常量数组
|
|
42
|
+
var [a,b,c]=Array(3).fill(0).map((_,i)=>i+1) // 类似这种用于生成常量并赋值的,将直接变成赋值语句 var a=1,b=2,c=3
|
|
43
|
+
Array(3).fill(a)// 类似这种非常量的,将由类似 ArrayFill(3,a) 的语句替换
|
|
44
|
+
```
|
|
45
|
+
5. ```javascript
|
|
46
|
+
Promise
|
|
47
|
+
Promise.prototype.then
|
|
48
|
+
Promise.prototype.catch
|
|
49
|
+
Promise.all
|
|
50
|
+
Promise.race
|
|
51
|
+
Promise.reject
|
|
52
|
+
Promise.resolve
|
|
53
|
+
```
|
|
54
|
+
`Promise`对象也是`ie`系列浏览器均不支持的。`efront`实现的`Promise`与原生的特性并不一致,仅在运行环境不支持的时候进行替代。比如由`.then`触发的方法与`setTimeout`触发的方法执行的先后顺序会与高级的运行环境有所区别,但也会保持在当前语境执行后再执行相关的语句。以上没有提到的`Promise`相关的方法均不支持,如`Promise.prototype.finally`,如果您使用了这些缺失的特性,就只能自己实现或找类似[core-js](https://github.com/zloirock/core-js)的库填充了
|
|
55
|
+
6. ```javascript
|
|
56
|
+
obj.if
|
|
57
|
+
obj.catch
|
|
58
|
+
obj.for
|
|
59
|
+
```
|
|
60
|
+
类似这种用`.`取属性的语句,由于属性名与`js`的保留字一样,`ie6`等浏览器会报错,但您可以在`efront`提供的环境中放心使用。因为`efront`本身就会把取属性的语句处理掉。
|
|
61
|
+
7. `ie8`及以下浏览器中存在的一些与现代`js`标准不同的特性,`efront`提供的组件可能不兼容,在处理为这类环境进行应用开发时,应避免使用。
|
|
62
|
+
```javascript
|
|
63
|
+
Object.defineProperty(...);
|
|
64
|
+
({
|
|
65
|
+
get a(){},
|
|
66
|
+
set a(){}
|
|
67
|
+
});
|
|
68
|
+
class {
|
|
69
|
+
get a(){}
|
|
70
|
+
set a(){}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
`ie8`及以下浏览器对`Object.defineProperty`支持的不好或根本不支持,`efront`暂时没有实现这类功能的兼容方案。如果您要兼容相应的环境,请暂时避免使用相关的语句,也不要使用使用了这些特性的库。
|
|
74
|
+
```javascript
|
|
75
|
+
Array.prototype.slice.call(objNodeList,...)
|
|
76
|
+
```
|
|
77
|
+
`ie8`及以下浏览器不支持`this`指向`NodeList`等dom对象,而当前`efront`和内部使用的`typescript`转换的代码都没有处理这一细节,所以暂时不要在dom操作相关的语句中使用高级语法,以避免转换后的代码出问题。
|
|
78
|
+
```javascript
|
|
79
|
+
var div = document.createElement("div");
|
|
80
|
+
div.innerHTML = `<abcd><span></span></abcd>`;
|
|
81
|
+
console.log(div.innerHTML); // <SPAN></SPAN>
|
|
82
|
+
```
|
|
83
|
+
`ie8`及以下浏览器无法正确地通过`innerHTML`属性设置自定义标签,`efront`提供的大部分组件都使用了这一特性,`efront`示例项目中[ie8.js](../../apps/kugou/ie8.js)可以实现`ie8`上设置`innerHTML`的适配,但不能保证样式正常,对于`ie7`及以下的浏览器,就暂时别用`efront`提供的与元素相关的组件了。
|