efront 3.24.7 → 3.25.0

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.
@@ -10,7 +10,7 @@
10
10
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11
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>Efront 项目</title>
13
+ <title>efront 项目</title>
14
14
  <script deleteoncompile efrontloader>
15
15
  // 若要在开发环境使用内置组件,请保留此script标签中的代码,在编译发布时,这里的代码会自动删除
16
16
  </script>
package/apps/index.jsp ADDED
@@ -0,0 +1,58 @@
1
+ <script serverside>
2
+ var fs = require("fs");
3
+ var path = require("path");
4
+ return new Promise(function (ok, oh) {
5
+ fs.readdir(__dirname, { withFileTypes: true }, function (error, names) {
6
+ if (error) oh(error);
7
+ names = names.filter(a => a.isDirectory()).map(a => a.name);
8
+ context.names = [];
9
+ for (var n of names) {
10
+ if (fs.existsSync(path.join(__dirname, n, 'index.html'))) context.names.push(n);
11
+ }
12
+ ok();
13
+ });
14
+ });
15
+ </script>
16
+ <!DOCTYPE html>
17
+ <!--
18
+ http://efront.cc
19
+ -->
20
+ <html lang="zh-CN">
21
+
22
+ <head>
23
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
24
+ <meta charset="utf-8" />
25
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
26
+ <link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
27
+ <meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
28
+ <title>efront 项目</title>
29
+ <style>
30
+ html {
31
+ height: 100%;
32
+ font-family: "SF Pro SC", "SF Pro Text", "SF Pro Icons", "PingFang SC", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
33
+ }
34
+
35
+ *,
36
+ ::before,
37
+ ::after {
38
+ box-sizing: border-box;
39
+ }
40
+
41
+ body {
42
+ border: none;
43
+ margin: 0;
44
+ padding: 0;
45
+ height: 100%;
46
+ overflow: hidden;
47
+ }
48
+ </style>
49
+ </head>
50
+
51
+ <body scroll=no max-render=1440>
52
+ 欢迎使用efront开发套件
53
+ <script serverside>
54
+ return context.names.map(n => `<a href="${n}">${n}</a>`)
55
+ </script>
56
+ </body>
57
+
58
+ </html>
@@ -0,0 +1,38 @@
1
+ var reg = /([a-z]?)(\d*)/g;
2
+ function decode(str, i) {
3
+ reg.lastIndex = i;
4
+ var a = reg.exec(str);
5
+ if (!a) return [, str.length];
6
+ var [m, t, l] = a;
7
+ var e = a.index + m.length;
8
+ switch (t) {
9
+ case "":
10
+ e++;
11
+ return [str.slice(e, e += +l), e];
12
+ case "i":
13
+ e = str.indexOf("e", a.index + +m.length);
14
+ if (e < 0) e = str.length;
15
+ return [+str.slice(a.index + 1, e), e + 1];
16
+ case "d":
17
+ var res = {};
18
+ i++;
19
+ while (i < str.length && str.charAt(i) !== 'e') {
20
+ var [k, i] = decode(str, i);
21
+ var [v, i] = decode(str, i);
22
+ res[k] = v;
23
+ }
24
+ return [res, i + 1];
25
+ case "l":
26
+ var res = [];
27
+ i++;
28
+ while (i < str.length && str.charAt(i) !== 'e') {
29
+ var [o, i] = decode(str, i);
30
+ res.push(o);
31
+ }
32
+ return [res, i + 1];
33
+ }
34
+ return [, str.length]
35
+ }
36
+ function bdecode(str) {
37
+ return decode(str, 0)[0];
38
+ }
@@ -0,0 +1,13 @@
1
+ var test = function (data, res) {
2
+ var d = bdecode(res);
3
+ assert(d, data);
4
+ };
5
+ test({ "t": "aa", "y": "e", "e": [201, "A Generic Error Ocurred"] }, 'd1:eli201e23:A Generic Error Ocurrede1:t2:aa1:y1:ee')
6
+ test({ "t": "aa", "y": "q", "q": "ping", "a": { "id": "abcdefghij0123456789" } }, 'd1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe')
7
+ test({ "t": "aa", "y": "r", "r": { "id": "mnopqrstuvwxyz123456" } }, 'd1:rd2:id20:mnopqrstuvwxyz123456e1:t2:aa1:y1:re')
8
+ test({ "t": "aa", "y": "q", "q": "find_node", "a": { "id": "abcdefghij0123456789", "target": "mnopqrstuvwxyz123456" } }, 'd1:ad2:id20:abcdefghij01234567896:target20:mnopqrstuvwxyz123456e1:q9:find_node1:t2:aa1:y1:qe')
9
+ test({ "t": "aa", "y": "r", "r": { "id": "0123456789abcdefghij", "nodes": "def456..." } }, 'd1:rd2:id20:0123456789abcdefghij5:nodes9:def456...e1:t2:aa1:y1:re')
10
+ test({ "t": "aa", "y": "q", "q": "get_peers", "a": { "id": "abcdefghij0123456789", "info_hash": "mnopqrstuvwxyz123456" } }, 'd1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz123456e1:q9:get_peers1:t2:aa1:y1:qe')
11
+ test({ "t": "aa", "y": "r", "r": { "id": "abcdefghij0123456789", "token": "aoeusnth", "nodes": "def456..." } }, 'd1:rd2:id20:abcdefghij01234567895:nodes9:def456...5:token8:aoeusnthe1:t2:aa1:y1:re')
12
+ test({ "t": "aa", "y": "q", "q": "announce_peer", "a": { "id": "abcdefghij0123456789", "implied_port": 1, "info_hash": "mnopqrstuvwxyz123456", "port": 6881, "token": "aoeusnth" } }, 'd1:ad2:id20:abcdefghij012345678912:implied_porti1e9:info_hash20:mnopqrstuvwxyz1234564:porti6881e5:token8:aoeusnthe1:q13:announce_peer1:t2:aa1:y1:qe')
13
+ test({ "t": "aa", "y": "r", "r": { "id": "mnopqrstuvwxyz123456" } }, 'd1:rd2:id20:mnopqrstuvwxyz123456e1:t2:aa1:y1:re')
@@ -0,0 +1,14 @@
1
+ function bencode(object) {
2
+ if (isString(object)) return `${object.length}:${object}`;
3
+ if (isNumber(object)) return `i${object}e`;
4
+ if (isArray(object)) return `l${object.map(bencode).join('')}e`;
5
+ if (isEmpty(object)) return ``;
6
+ if (!isObject(object)) return ``;
7
+ var res = [];
8
+ for (var k in object) {
9
+ var o = object[k];
10
+ if (isEmpty(o)) continue;
11
+ res.push(bencode(k), bencode(o));
12
+ }
13
+ return `d${res.join('')}e`;
14
+ }
@@ -0,0 +1,20 @@
1
+ var format = function (data) {
2
+ if (!isObject(data)) return data;
3
+ if (isArray(data)) return data.map(format);
4
+ var d = {};
5
+ Object.keys(data).sort().map(k => d[k] = format(data[k]));
6
+ return d;
7
+ }
8
+ var test = function (data, res) {
9
+ var d = format(data);
10
+ assert(bencode(d), res);
11
+ };
12
+ test({ "t": "aa", "y": "e", "e": [201, "A Generic Error Ocurred"] }, 'd1:eli201e23:A Generic Error Ocurrede1:t2:aa1:y1:ee')
13
+ test({ "t": "aa", "y": "q", "q": "ping", "a": { "id": "abcdefghij0123456789" } }, 'd1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe')
14
+ test({ "t": "aa", "y": "r", "r": { "id": "mnopqrstuvwxyz123456" } }, 'd1:rd2:id20:mnopqrstuvwxyz123456e1:t2:aa1:y1:re')
15
+ test({ "t": "aa", "y": "q", "q": "find_node", "a": { "id": "abcdefghij0123456789", "target": "mnopqrstuvwxyz123456" } }, 'd1:ad2:id20:abcdefghij01234567896:target20:mnopqrstuvwxyz123456e1:q9:find_node1:t2:aa1:y1:qe')
16
+ test({ "t": "aa", "y": "r", "r": { "id": "0123456789abcdefghij", "nodes": "def456..." } }, 'd1:rd2:id20:0123456789abcdefghij5:nodes9:def456...e1:t2:aa1:y1:re')
17
+ test({ "t": "aa", "y": "q", "q": "get_peers", "a": { "id": "abcdefghij0123456789", "info_hash": "mnopqrstuvwxyz123456" } }, 'd1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz123456e1:q9:get_peers1:t2:aa1:y1:qe')
18
+ test({ "t": "aa", "y": "r", "r": { "id": "abcdefghij0123456789", "token": "aoeusnth", "nodes": "def456..." } }, 'd1:rd2:id20:abcdefghij01234567895:nodes9:def456...5:token8:aoeusnthe1:t2:aa1:y1:re')
19
+ test({ "t": "aa", "y": "q", "q": "announce_peer", "a": { "id": "abcdefghij0123456789", "implied_port": 1, "info_hash": "mnopqrstuvwxyz123456", "port": 6881, "token": "aoeusnth" } }, 'd1:ad2:id20:abcdefghij012345678912:implied_porti1e9:info_hash20:mnopqrstuvwxyz1234564:porti6881e5:token8:aoeusnthe1:q13:announce_peer1:t2:aa1:y1:qe')
20
+ test({ "t": "aa", "y": "r", "r": { "id": "mnopqrstuvwxyz123456" } }, 'd1:rd2:id20:mnopqrstuvwxyz123456e1:t2:aa1:y1:re')
@@ -0,0 +1,21 @@
1
+ function combine() {
2
+ var total = 1;
3
+ var argsList = Array.prototype.map.call(arguments, a => {
4
+ total *= a.length;
5
+ return a;
6
+ });
7
+
8
+ var temp = total;
9
+ var ratioList = argsList.map(a => temp = temp / a.length);
10
+ var dist = new Array(total);
11
+ for (var cx = 0, dx = total; cx < dx; cx++) {
12
+ var temp = cx;
13
+ dist[cx] = argsList.map(function (a, cx) {
14
+ var index = temp / ratioList[cx] | 0;
15
+ temp = temp - index * ratioList[cx];
16
+ return a[index];
17
+ });
18
+ }
19
+ return dist;
20
+ }
21
+ module.exports = combine;
@@ -118,8 +118,12 @@ function cross_(jsonp, digest = noop, method, url, headers) {
118
118
  var flush = function () {
119
119
  var then = xhr.then;
120
120
  delete xhr.then;
121
- if (loaded) onloads.splice(0, onloads.length).map(e => e instanceof Function && e(xhr));
122
- if (errored) onerrors.splice(0, onerrors.length).map(e => e instanceof Function && e(errored));
121
+ if (loaded) onloads.forEach(e => e instanceof Function && e(xhr));
122
+ if (errored) onerrors.forEach(e => e instanceof Function && e(errored));
123
+ if (loaded || errored) {
124
+ onloads.splice(0, onloads.length);
125
+ onerrors.splice(0, onerrors.length);
126
+ }
123
127
  xhr.then = then;
124
128
  };
125
129
  if (/^jsonp/i.test(method)) {
@@ -198,9 +202,11 @@ function cross_(jsonp, digest = noop, method, url, headers) {
198
202
  case 304:
199
203
  onload(xhr);
200
204
  break;
201
- case 307:
202
205
  case 302:
203
206
  case 301:
207
+ method = 'get';
208
+ datas = null;
209
+ case 307:
204
210
  if (xhr.isRedirected > 2) break;
205
211
  var exposekey = nocross ? "location" : "efront-location";
206
212
  var location = exposeMap[exposekey] && xhr.getResponseHeader(exposekey);
@@ -212,10 +218,11 @@ function cross_(jsonp, digest = noop, method, url, headers) {
212
218
  }
213
219
  location = getRequestProtocol(url) + "//" + location;
214
220
  }
215
- var crs = cross_("get", location, _headers);
221
+ var crs = cross_.call(cross, jsonp, digest, method, location, _headers);
216
222
  crs.isRedirected = (xhr.isRedirected || 0) + 1;
217
223
  crs.done(onload, false);
218
224
  crs.error(onerror, false);
225
+ if (!isEmpty(datas)) crs.send(datas);
219
226
  break;
220
227
  default:
221
228
  onerror(xhr);
@@ -41,6 +41,20 @@
41
41
  }
42
42
  }
43
43
 
44
+ @keyframes busy-pending {
45
+ 0% {
46
+ transform: rotate(0);
47
+ }
48
+
49
+ 70% {
50
+ transform: rotate(180deg);
51
+ }
52
+
53
+ 100% {
54
+ transform: rotate(360deg);
55
+ }
56
+ }
57
+
44
58
  &>input {
45
59
  position: absolute;
46
60
  opacity: 0;
@@ -149,6 +163,29 @@
149
163
  animation: ltr 2s linear 0s infinite;
150
164
  }
151
165
 
166
+ a&,
167
+ &[type=anchor] {
168
+ &:before {
169
+ display: none;
170
+ }
171
+
172
+ overflow: visible;
173
+
174
+ &.track {
175
+ display: none;
176
+ }
177
+
178
+ &:after {
179
+ content: "↻";
180
+ font-family: 'Times New Roman', Times, serif;
181
+ display: inline-block;
182
+ vertical-align: middle;
183
+ position: absolute;
184
+ animation: busy-pending 2s linear 0s infinite;
185
+ }
186
+ }
187
+
188
+
152
189
  }
153
190
 
154
191
  &:focus {
@@ -174,6 +211,13 @@
174
211
  background: #fff;
175
212
  animation: busy-loading 3s linear 0s infinite;
176
213
  }
214
+
215
+ a&,
216
+ &[type=anchor] {
217
+ &:before {
218
+ animation: busy-pending 3s linear 0s infinite;
219
+ }
220
+ }
177
221
  }
178
222
 
179
223
  a&,
@@ -198,6 +242,10 @@ a&,
198
242
  }
199
243
  }
200
244
 
245
+ &[loading],
246
+ &[pending] {
247
+ .clear();
248
+ }
201
249
 
202
250
  &.hover {
203
251
  color: lighten(@default-color, 10%);
@@ -265,5 +313,6 @@ a&,
265
313
  &:before {
266
314
  content: "确认";
267
315
  }
316
+
268
317
  background: #333;
269
318
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  var coordIn = move.coordIn;
3
- var _createImage = function (url, callback) {
3
+ var _createImage = function (url, callback, iscurrent) {
4
4
  var imgpic;
5
5
  if (url instanceof Image) {
6
6
  imgpic = new Image;
@@ -18,10 +18,11 @@ var _createImage = function (url, callback) {
18
18
  onload.call(imgpic);
19
19
  } else {
20
20
  imgpic.onload = onload;
21
+ if (iscurrent) imgpic.onerror = () => alert("打开失败!");
21
22
  }
22
23
  return imgpic;
23
24
  };
24
- var create = function (url, key) {
25
+ var create = function (url, key, report_error) {
25
26
  if (!url) return;
26
27
 
27
28
  var image = picture_();
@@ -90,7 +91,7 @@ var create = function (url, key) {
90
91
  }
91
92
  };
92
93
 
93
- createImage(url, image.setImage);
94
+ createImage(url, image.setImage, report_error);
94
95
 
95
96
 
96
97
  var get_style = function (x, y, scaled, rotate) {
@@ -127,10 +128,10 @@ function picture(url, to = 0, key) {
127
128
  delete images[index];
128
129
  }
129
130
  if (!images[index]) {
130
- images[index] = create.call(p, urls[index], key);
131
+ images[index] = create.call(p, urls[index], key, p.index === index);
131
132
  }
132
133
  if (!images[index + 1] && index + 1 < urls.length) {
133
- images[index + 1] = create.call(p, urls[index + 1], key);
134
+ images[index + 1] = create.call(p, urls[index + 1], key, p.index === index);
134
135
  }
135
136
  if (index >= 5) delete images[index - 5];
136
137
  if (index + 5 < urls.length) {
@@ -85,8 +85,10 @@ function picture_(image = document.createElement("div")) {
85
85
  cover_scale = isxrelex ? x_scale : y_scale;
86
86
  loaded_scale = contain_scale = isxrelex ? y_scale : x_scale;
87
87
  if (loaded_scale >= 1) {
88
- click_scale = 4;
89
- loaded_scale = 1;
88
+ if (loaded_scale > devicePixelRatio) {
89
+ loaded_scale = devicePixelRatio;
90
+ }
91
+ click_scale = loaded_scale * 2;
90
92
  }
91
93
  else if (loaded_scale > .5) {
92
94
  click_scale = 2;
@@ -554,6 +554,7 @@ var binders = {
554
554
  });
555
555
  }
556
556
  };
557
+ var reject = function (e) { digest(); throw e };
557
558
  var createEmiter = function (on) {
558
559
  return function (key, search) {
559
560
  var parsedSrc = this.$src;
@@ -603,7 +604,7 @@ var createEmiter = function (on) {
603
604
  else {
604
605
  res = getter0.call(this, e);
605
606
  }
606
- if (res && isFunction(res.then)) res.then(digest, digest);
607
+ if (res && isFunction(res.then)) res.then(digest, reject);
607
608
  return res;
608
609
  });
609
610
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.24.7",
3
+ "version": "3.25.0",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {