efront 3.1.3 → 3.2.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.
@@ -23,7 +23,8 @@ var seek = function (object, seeker) {
23
23
  if (isObject(seeker)) {
24
24
  var dist = {};
25
25
  for (var k in seeker) {
26
- var o = seek(object, seeker[k]);
26
+ var { k: v = k } = seeker;
27
+ var o = seek(object, v);
27
28
  if (o === undefined) return;
28
29
  dist[k] = o;
29
30
  }
@@ -104,10 +104,10 @@ var skipAssignment = function (o) {
104
104
  }
105
105
  break;
106
106
  default:
107
+ console.log(o);
107
108
  throw new Error('代码结构异常!');
108
109
  o = o.next;
109
110
  }
110
- if (o === o0) throw new Error("代码结构异常!");
111
111
  return o;
112
112
  };
113
113
 
@@ -302,7 +302,8 @@ var detour = function (o, ie) {
302
302
  insertAfter(o, { text: ':', type: STAMP }, { text: o.text, type: EXPRESS, isExpress: true });
303
303
  o.short = false;
304
304
  }
305
- o.text = `[${strings.encode(strings.decode(o.text))}]`;
305
+ var text = strings.encode(strings.decode(o.text));
306
+ o.text = ie ? text : `[${text}]`;
306
307
  }
307
308
  }
308
309
  break;
@@ -689,11 +690,6 @@ class Program extends Array {
689
690
  detour(this.first, true);
690
691
  return this;
691
692
  }
692
- // 标记要保留的代码
693
- ahchor() { }
694
- // 清理无效的代码
695
- clean() {
696
- }
697
693
  // 压缩
698
694
  press() {
699
695
  this.pressed = true;
@@ -39,7 +39,7 @@ var active = function () {
39
39
  __addClass(this, "hover active");
40
40
  };
41
41
  var checkclick = function () {
42
- if (this.hasAttribute("disabled") || this.disabled || this.hasAttribute("loading") || this.loading) onclick.preventClick = true;
42
+ if (this.hasAttribute("disabled") || this.disabled || this.hasAttribute("loading") || this.loading || this.hasAttribute("pending") || this.pending) onclick.preventClick = true;
43
43
  };
44
44
  var resetactive = function () {
45
45
  removeClass(this, "active");
@@ -94,6 +94,7 @@
94
94
  }
95
95
 
96
96
  &.active,
97
+ &[pending],
97
98
  &[loading] {
98
99
  >.track {
99
100
  background: #0003;
@@ -102,6 +103,7 @@
102
103
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.3) inset;
103
104
  }
104
105
 
106
+ &[pending],
105
107
  &[loading] {
106
108
  @keyframes ltr {
107
109
  0% {
@@ -102,7 +102,7 @@ function isChildPath(relative, path) {
102
102
  return relative.replace(/^(.*\/)[^\/]*$/, path);
103
103
  }
104
104
  var digest = function () {
105
- if (cross.digest instanceof Function) cross.digest();
105
+ dispatch('render', window);
106
106
  };
107
107
 
108
108
  var getCrossUrl = function (domain, headers) {
@@ -117,7 +117,7 @@ var getCrossUrl = function (domain, headers) {
117
117
  _headers = serialize(_headers);
118
118
  if (_headers) _headers = "," + _headers;
119
119
  return domain
120
- .replace(/^s?\/\//i, "http$&")
120
+ .replace(/^(s?)(\/\/)/i, "http$1:$2")
121
121
  .replace(domainReg, base + `*${/^(https\:|s\/\/)/i.test(domain) ? "*" : ""}$2${_headers}/$3$4`);
122
122
  };
123
123
  function cross(method, url, headers) {
@@ -212,6 +212,11 @@ function cross(method, url, headers) {
212
212
  xhr.setRequestHeader = function (key, value) {
213
213
  realHeaders[key] = value;
214
214
  };
215
+ xhr.then = function (ok, oh) {
216
+ onloads.push(ok);
217
+ onerrors.push(oh);
218
+ flush();
219
+ };
215
220
  setTimeout(function () {
216
221
  var isform = /^f/i.test(method);
217
222
  if (isform) {
@@ -244,24 +249,32 @@ function cross(method, url, headers) {
244
249
  send.call(xhr, datas);
245
250
  }, 0);
246
251
  }
252
+ var loaded, errored;
247
253
  var onload = function (xhr) {
248
254
  if (xhr.decoder) {
249
255
  xhr = xhr.decoder(xhr);
250
256
  }
251
- onloads.map(e => e instanceof Function && e(xhr));
257
+ loaded = xhr;
258
+ flush();
252
259
  digest();
253
260
  };
254
261
  var onerror = function (xhr) {
255
- onerrors.map(e => e instanceof Function && e(xhr));
262
+ errored = xhr;
263
+ flush();
256
264
  digest();
257
265
  };
266
+ var flush = function () {
267
+ var then = xhr.then;
268
+ delete xhr.then;
269
+ if (loaded) onloads.splice(0, onloads.length).map(e => e instanceof Function && e(xhr));
270
+ if (errored) onerrors.splice(0, onerrors.length).map(e => e instanceof Function && e(xhr));
271
+ xhr.then = then;
272
+ };
258
273
  var onloads = [], onerrors = [];
259
274
  xhr.done = xhr.success = function (on, asqueue = true) {
260
- if (asqueue) {
261
- onloads.push(on);
262
- } else {
263
- onload = on;
264
- }
275
+ if (!asqueue) onloads.splice(0, onloads.length);
276
+ onloads.push(on);
277
+ flush();
265
278
  return xhr;
266
279
  };
267
280
  var send = xhr.send;
@@ -296,12 +309,11 @@ function cross(method, url, headers) {
296
309
  }
297
310
  };
298
311
  xhr.fail = xhr.error = function (on, asqueue = true) {
299
- if (asqueue) {
300
- onerrors.push(on);
301
- } else {
302
- onerror = on;
312
+ if (!asqueue) {
313
+ onerrors.splice(0, onerrors.length);
303
314
  }
304
- onerror = on;
315
+ onerrors.push(on);
316
+ flush();
305
317
  return xhr;
306
318
  };
307
319
  return xhr;
@@ -112,8 +112,8 @@ var getXYFromMouseEvent = function (event) {
112
112
  var grid = this;
113
113
  var position = getScreenPosition(grid);
114
114
  var computed = getComputedStyle(grid);
115
- var clientX = event.clientX - position.left;
116
- var clientY = event.clientY - position.top;
115
+ var clientX = event.clientX - position.left - grid.clientLeft;
116
+ var clientY = event.clientY - position.top - grid.clientTop;
117
117
  var [padLeft, padTop, padRight, padBottom] = [
118
118
  computed.paddingLeft,
119
119
  computed.paddingTop,
@@ -302,7 +302,7 @@ function grid(breakpoints) {
302
302
  }
303
303
  class Point extends Array {
304
304
  constructor(value, range) {
305
- if (!this) return new Point(value);
305
+ super();
306
306
  var solid = false;
307
307
  if (isObject(value)) {
308
308
  this.value = value.value;
@@ -324,7 +324,7 @@ class Point extends Array {
324
324
  return this.value;
325
325
  }
326
326
  }
327
- var createPoints = function (values, direction = "x", result = Point(0)) {
327
+ var createPoints = function (values, direction = "x", result = new Point(0)) {
328
328
  if (!(values instanceof Array)) values = arguments;
329
329
  for (var cx = 0, dx = values.length; cx < dx; cx++) {
330
330
  var value = values[cx];
@@ -332,7 +332,7 @@ var createPoints = function (values, direction = "x", result = Point(0)) {
332
332
  if (!result.length) throw new Error("数据转换为grid失败!");
333
333
  createPoints(value, direction === "x" ? "y" : "x", result[result.length - 1]);
334
334
  } else {
335
- var breakpoint = Point(value);
335
+ var breakpoint = new Point(value);
336
336
  breakpoint.direction = direction;
337
337
  breakpoint.parent = result;
338
338
  result.push(breakpoint);
@@ -412,7 +412,7 @@ var grid_prototype = {
412
412
  _reshape() {
413
413
  var grid = this;
414
414
  var bounds = this.bounds;
415
- var current_l, current_t, current_w, current_h, current_d = this.breakpoints.direction, current_r = Point(grid.width), current_b = Point(grid.height);
415
+ var current_l, current_t, current_w, current_h, current_d = this.breakpoints.direction, current_r = new Point(grid.width), current_b = new Point(grid.height);
416
416
  // var xPoints = [];
417
417
  // var yPoints = [];
418
418
  var getDivSize = function (top, height, bounds_top, bounds_bottom, grid_height, grid_padding_top, grid_padding_bottom) {
@@ -569,14 +569,14 @@ var grid_prototype = {
569
569
  }
570
570
  },
571
571
  seprate(x) {
572
- saveToOrderedArray(this.breakpoints, Point(x));
572
+ saveToOrderedArray(this.breakpoints, new Point(x));
573
573
  },
574
574
  nearby(x, y) {
575
575
  var breakpoints = this.breakpoints;
576
576
  var breakpath = [];
577
- var maxXStart = Point(0), maxYStart = Point(0);
578
- var minXEnd = Point(this.width);
579
- var minYEnd = Point(this.height);
577
+ var maxXStart = new Point(0), maxYStart = new Point(0);
578
+ var minXEnd = new Point(this.width);
579
+ var minYEnd = new Point(this.height);
580
580
  var isX = true;
581
581
  do {
582
582
  var value = isX ? x : y;// 先 y 后 x
@@ -577,14 +577,16 @@ var emiters = {
577
577
  on(key, search) {
578
578
  var getter = createGetter(search, false);
579
579
  on(key)(this, function (e) {
580
- getter.call(this, e);
580
+ var res = getter.call(this, e);
581
+ if (res && isFunction(res.then)) res.then(digest, digest);
581
582
  digest();
582
583
  });
583
584
  },
584
585
  once(key, search) {
585
586
  var getter = createGetter(search, false);
586
587
  once(key)(this, function (e) {
587
- getter.call(this, e);
588
+ var res = getter.call(this, e);
589
+ if (res && isFunction(res.then)) res.then(digest, digest);
588
590
  digest();
589
591
  });
590
592
  }
@@ -786,7 +788,7 @@ function render(element, scope, parentScopes) {
786
788
  return e;
787
789
  }
788
790
 
789
- var digest = lazy(refresh, +{});
791
+ var digest = lazy(refresh, -{});
790
792
  render.digest = render.apply = render.refresh = digest;
791
793
  render.parseRepeat = parseRepeat;
792
794
  var eventsHandlers = "fullscreenchange,change,click,paste,resize,keydown,keypress,keyup,input,drop".split(",").map(k => on(k));
@@ -805,19 +807,3 @@ render.register = function (key, name) {
805
807
  register(key, name);
806
808
  }
807
809
  };
808
-
809
- var promisePrototype = Promise.prototype;
810
- var __then = promisePrototype.then;
811
- var __wrap = function (f) {
812
- if (f instanceof Function) {
813
- return function () {
814
- var res = f.apply(this, arguments);
815
- digest();
816
- return res;
817
- };
818
- }
819
- return f;
820
- };
821
- promisePrototype.then = function () {
822
- return __then.apply(this, [].map.call(arguments, __wrap));
823
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.1.3",
3
+ "version": "3.2.2",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {