efront 4.15.1 → 4.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -836,13 +836,6 @@ var hook = function (requires_count) {
836
836
  modules.hook_time = +new Date;
837
837
  if (document) {
838
838
  initPixelDecoder();
839
- if (modules.hook_time - efront_time < (isProduction ? 30 : 5) && document.querySelector && devicePixelRatio > 1 && /Linux/.test(navigator.platform) && navigator.maxTouchPoints > 0) {
840
- let ratio = +(1000000 / devicePixelRatio + .5 | 0) / 1000000;
841
- document.querySelector("meta[name=viewport]").setAttribute("content", `width=device-width,target-densitydpi=device-dpi,user-scalable=no,initial-scale=1,maximum-scale=${ratio}`);
842
- renderPixelRatio *= devicePixelRatio;
843
- modules.renderPixelRatio = renderPixelRatio;
844
- devicePixelRatio = modules.devicePixelRatio = 1;
845
- }
846
839
  if (!efrontPath) efrontPath = document.body.getAttribute("main-path") || document.body.getAttribute("path") || document.body.getAttribute("main") || "zimoli";
847
840
  }
848
841
  init(efrontPath, function (zimoli) {
@@ -1,4 +1,4 @@
1
- var { File } = this;
1
+ var { File, location, FormData, navigator } = this;
2
2
  function hasFile(o) {
3
3
  if (!File) return false;
4
4
  for (var k in o) {
@@ -151,13 +151,13 @@ function cross_(jsonp, digest = noop, method, url, headers) {
151
151
  digest();
152
152
  };
153
153
  var getErrorSystem = function () {
154
- if (!/^(\w+\:|\/\/)/.test(url) && /^file\:/i.test(location.href) || /^file\:/i.test(url)) return i18n`文件系统`;
155
- if (navigator.onLine) return i18n`网络`;
154
+ if (location && !/^(\w+\:|\/\/)/.test(url) && /^file\:/i.test(location.href) || /^file\:/i.test(url)) return i18n`文件系统`;
155
+ if (navigator?.onLine) return i18n`网络`;
156
156
  return i18n`服务器`;
157
157
  };
158
158
 
159
159
  var onerror = async function (e) {
160
- if (e.type === 'error') {
160
+ if (!e || e.type === 'error') {
161
161
  e = createResponse(i18n`无法访问${getErrorSystem()}`);
162
162
  }
163
163
  headers = extend({}, _headers);
@@ -1,47 +1,36 @@
1
1
  "use strict";
2
+ var bindObjK = function (obj, k, resolve, _object) {
3
+ Object.defineProperty(_object, k, {
4
+ get() {
5
+ var method = obj[k];
6
+ if (typeof method === 'function') {
7
+ return function () {
8
+ var r = method.apply(obj, arguments);
9
+ return resolve(r);
10
+ };
11
+ }
12
+ return method;
13
+ },
14
+ set(v) {
15
+ obj[k] = v;
16
+ },
17
+ });
18
+ };
2
19
  var enrich = function enrich(obj) {
3
20
  var _promise = Promise.resolve();
4
- var Base = function () {
5
- };
6
- Base.prototype = obj;
7
- var _object = new Base;
8
- for (var k in obj) {
9
- if (obj[k] instanceof Function) {
10
- _promise[k] = function () {
11
- var method = obj[k];
12
- var caller = function () {
13
- "use strict";
14
- var args = arguments;
15
- return this.then(function () {
16
- return method.apply(_object, args);
17
- });
18
- };
19
- _object[k] = function () {
20
- return caller.apply(_promise, arguments);
21
- };
22
- return caller;
23
- }();
24
- }
25
- }
26
- _promise._enrich = function (promise) {
27
- if (!promise._enrich) {
28
- for (var k in _promise) promise[k] = _promise[k];
29
- }
30
- return promise;
31
- };
21
+ var _object = Object.create(null);
32
22
  var _then = _promise.then;
33
- var _catch = _promise.catch;
34
- _promise.then = function () {
23
+ var pthen = function () {
35
24
  var promise = _then.apply(this, arguments);
36
- return this._enrich(promise);
25
+ return resolve(promise);
26
+ };
27
+ var resolve = function (result) {
28
+ var _promise = Promise.resolve(result);
29
+ for (var k in obj) if (k !== 'then') bindObjK(obj, k, resolve, _promise);
30
+ _promise.then = pthen;
31
+ return _promise;
37
32
  };
38
- _promise.catch = function () {
39
- var promise = _catch.apply(this, arguments);
40
- return this._enrich(promise);
41
- }
33
+ for (var k in obj) bindObjK(obj, k, resolve, _object);
42
34
  return _object;
43
35
  };
44
36
  module.exports = enrich;
45
-
46
-
47
- // var Promise = new Function(require("fs").readFileSync("coms/zimoli/promise.js").toString()+"\r\nreturn Promise;").apply(global);
@@ -567,7 +567,7 @@ var createScoped = function (parsed, wash) {
567
567
  else if (p.type & (EXPRESS | VALUE)) {
568
568
  p.equal = o;
569
569
  }
570
- else if (o.text === '=' && p.type === SCOPED) {
570
+ else if (o.text === '=' && p.type === SCOPED && !p.isprop) {
571
571
  if (!p.kind) {
572
572
  var pp = p.prev;
573
573
  if (!pp || pp.type === STAMP || pp.type === STRAP) {
@@ -1078,7 +1078,7 @@ var getDeclared = function (o, kind, queue) {
1078
1078
  o = f.next;
1079
1079
  break;
1080
1080
  default:
1081
- console.log(createString(pickSentence(o)));
1081
+ console.log(createString(pickSentence(queue)));
1082
1082
  throw new Error(i18n`代码结构异常`);
1083
1083
  }
1084
1084
  if (!o) break;
@@ -2245,4 +2245,7 @@ var createDataURL = function (width, height, getPixel) {
2245
2245
 
2246
2246
  // multibyte support
2247
2247
 
2248
- qrcode.stringToBytesFuncs['UTF-8'] = /* 这一块已被efront作者修改 */ encodeUTF8;
2248
+ qrcode.stringToBytes =
2249
+ qrcode.stringToBytesFuncs.default =
2250
+ qrcode.stringToBytesFuncs['UTF-8'] =
2251
+ /* 这一块已被efront作者修改 */ encodeUTF8;
@@ -15,11 +15,12 @@ var proto = {
15
15
  loginPath: null,
16
16
  session_time: 300000,
17
17
  session: "",
18
+ clean: null,
18
19
  loadSession: function () {
19
20
  var object = userInstance;
20
21
  if (object.session && !(new Date() > object.session_time)) {
21
- proto.session_time = object.session_time;
22
- proto.session = object.session;
22
+ this.session_time = object.session_time;
23
+ this.session = object.session;
23
24
  this.Login(object);
24
25
  }
25
26
  return object.session || "";
@@ -27,58 +28,57 @@ var proto = {
27
28
  saveSession: function (session = this.session) {
28
29
  this.session = session;
29
30
  data.setInstance(USERINFO, {
30
- roles: proto.roles,
31
- name: proto.name,
32
- _id: proto._id,
31
+ roles: this.roles,
32
+ name: this.name,
33
+ _id: this._id,
33
34
  session: session,
34
35
  _passport: this._passport,
35
36
  isLogin: !!session,
36
- session_time: +new Date() + proto.session_time
37
+ session_time: +new Date() + this.session_time
37
38
  });
38
39
  },
40
+ setLoginPath(pathname) {
41
+ this.loginPath = pathname;
42
+ },
43
+ setUserDataLoader(method) {
44
+ loadUserData = method;
45
+ },
46
+ setSessionTime(session_time) {
47
+ this.session_time = session_time;
48
+ },
49
+ refresh() {
50
+ loadUserData instanceof Function && loadUserData();
51
+ },
52
+ getPassport() {
53
+ if (!passport) {
54
+ passport = encode62.timeencode(encode62.decode62(user._passport, user.session));
55
+ }
56
+ return passport = encode62.timeupdate(passport);
57
+ },
39
58
  Login(userinfo) {
40
59
  this.login(userinfo);
41
60
  },
61
+ login(userinfo) {
62
+ this.roles = userinfo.roles || [];
63
+ this.isLogin = true;
64
+ this.name = userinfo.name;
65
+ this._id = "org.couchdb.user:" + userinfo.name;
66
+ this.clean?.(this.loginPath);
67
+ this.refresh();
68
+ },
42
69
  Logout() {
43
70
  this.logout();
44
- }
71
+ },
72
+ logout() {
73
+ delete user.isLogin;
74
+ delete user.roles;
75
+ delete user._passport;
76
+ this._passport = "";
77
+ this.roles = null;
78
+ this.isLogin = false;
79
+ passport = '';
80
+ this.saveSession("");
81
+ },
45
82
  };
46
83
  extend(proto, emptyProto, userInstance);
47
84
  var user = enrich(proto);
48
- user.setLoginPath = function (pathname) {
49
- proto.loginPath = pathname;
50
- };
51
- user.setUserDataLoader = function (method) {
52
- loadUserData = method;
53
- };
54
- user.setSessionTime = function (session_time) {
55
- proto.session_time = session_time;
56
- };
57
- user.refresh = function () {
58
- loadUserData instanceof Function && loadUserData();
59
- };
60
-
61
- user.getPassport = function () {
62
- if (!passport) {
63
- passport = encode62.timeencode(encode62.decode62(user._passport, user.session));
64
- }
65
- return passport = encode62.timeupdate(passport);
66
- };
67
- user.login = function (userinfo) {
68
- proto.roles = userinfo.roles || [];
69
- proto.isLogin = true;
70
- proto.name = userinfo.name;
71
- proto._id = "org.couchdb.user:" + userinfo.name;
72
- user.clean && user.clean(proto.loginPath);
73
- this.refresh();
74
- };
75
- user.logout = function () {
76
- delete user.isLogin;
77
- delete user.roles;
78
- delete user._passport;
79
- proto._passport = "";
80
- proto.roles = null;
81
- proto.isLogin = false;
82
- passport = '';
83
- this.saveSession("");
84
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.15.1",
3
+ "version": "4.15.3",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {