efront 3.35.2 → 3.35.4

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,6 +23,7 @@ var {
23
23
  console,
24
24
  efrontURI,
25
25
  parseFloat,
26
+ encodeURI,
26
27
  preventFrame,
27
28
  PREVENT_FRAMEWORK_MODE = preventFrame,
28
29
  devicePixelRatio = 1,
@@ -46,6 +47,7 @@ var efront_time = +new Date;
46
47
  var _devicePixelRatio = devicePixelRatio;
47
48
  var request = window.request || function (url, onload, onerror, version) {
48
49
  var xhr = new (XMLHttpRequest || ActiveXObject)("Microsoft.XMLHTTP");
50
+ url = encodeURI(url);
49
51
  xhr.open("POST", url);
50
52
  xhr.onreadystatechange = function () {
51
53
  if (xhr.readyState === 4) {
@@ -41,20 +41,25 @@ function inertia(gun) {
41
41
  var id = smooth_timer;
42
42
  var res = gun.apply(that, args);
43
43
  if (id !== smooth_timer) return;
44
+
44
45
  if (false === res) {
45
46
  spd.reset();
46
47
  train.state = 回弹;
47
48
  smooth_timer = requestAnimationFrame(_decrease);
48
49
  return;
49
50
  }
50
- if (decrease && args.filter(a => Math.abs(a) > 1).length === 0) {
51
+ if (args.stop || rate && args.rate < rate) {
52
+ if (!decrease) {
53
+ train.state = 停止;
54
+ return;
55
+ }
51
56
  train.state = 回弹;
52
57
  smooth_timer = requestAnimationFrame(_decrease);
53
58
  return;
54
59
  }
55
60
  smooth_timer = requestAnimationFrame(smooth);
56
61
  };
57
- var spd, smooth_timer, that, decrease;
62
+ var spd, smooth_timer, that, decrease, rate;
58
63
  var train = function () {
59
64
  _cancel();
60
65
  var args = [].slice.call(arguments, 0, arguments.length);
@@ -63,9 +68,10 @@ function inertia(gun) {
63
68
  gun.apply(this, args);
64
69
  that = this;
65
70
  };
66
- train.smooth = function (d) {
71
+ train.smooth = function (d, r) {
67
72
  _cancel();
68
73
  decrease = d;
74
+ rate = r;
69
75
  if (train.state === 移动) {
70
76
  train.state = 减速;
71
77
  smooth_timer = requestAnimationFrame(smooth);
@@ -162,16 +168,20 @@ class Speed extends Array {
162
168
  for (var v of values) sum += v * v;
163
169
  v = Math.sqrt(sum);
164
170
  var a = this.accelerate * Math.atan(v + 1);
171
+ values.rate = v;
165
172
  if (v > a + 1e-14) {
166
173
  v = Math.sqrt(v * (v - a)) / v;
167
174
  }
168
175
  else {
169
- v = 1e-9;
176
+ if (v < 1e-6) {
177
+ values.stop = true;
178
+ }
179
+ v = 0.6180339887498949;
170
180
  }
171
181
  var r = ratio * v;
172
182
  for (var cx = 0, dx = values.length; cx < dx; cx++) {
173
183
  values[cx] *= r;
174
- if (Math.abs(this[cx]) > .1) this[cx] *= v;
184
+ if (Math.abs(this[cx]) > 1e-16) this[cx] *= v;
175
185
  }
176
186
  return values;
177
187
  }
@@ -0,0 +1,58 @@
1
+ var test = function (queue, wait = 40) {
2
+ var spd = new Speed;
3
+ var now = 0;
4
+ var writted = [];
5
+ for (var cx = 0, dx = queue.length; cx < dx; cx++) {
6
+ var s = queue[cx];
7
+ if (s instanceof Array && !Array.isArray(queue[cx + 1])) {
8
+ spd.write(s, now = queue[++cx]);
9
+ writted.push(s, now);
10
+ }
11
+ else {
12
+ spd.write([].concat(s), now = cx * 16 + 20 + Math.random() * 16);
13
+ writted.push([].concat(s), now);
14
+ }
15
+ }
16
+ for (var cx = now + wait, dx = now + 20000; cx < dx; cx += 16 + Math.random() * 16) {
17
+ var a = spd.read(cx);
18
+ if (a.stop) break;
19
+ }
20
+ if (!a.stop) {
21
+ console.log("测试数据:", writted, "\r\n当前状态:", a);
22
+ throw `已等待 ${+((cx - now) / 1000).toFixed(3)} 秒,未停止运行`;
23
+ }
24
+ console.log(cx - now, a.stop);
25
+ };
26
+ Speed.debug = true;
27
+ test([
28
+ [2.1878654669544666],
29
+ 27.956586758709825,
30
+ [2.1878654669544666],
31
+ 37.21775999809554,
32
+ [3.1878654669544666],
33
+ 67.83162606867668
34
+ ])
35
+ test([1.1878654669544668, 1.1878654669544668, 1.1878654669544668]);
36
+ test([2.1878654669544668, 2.1878654669544668, 3.1878654669544668]);
37
+ test([
38
+ 0.3251661026176258,
39
+ 0.44988734829376603,
40
+ 0.43652435853899707,
41
+ 0.43652435853899707,
42
+ 0.47438616350792273,
43
+ 0.4253885330796093,
44
+ 0.5300652921323553,
45
+ 0.5256109608866051,
46
+ ]);
47
+ test([
48
+ [0, false], 2880.300000011921,
49
+ [0, false], 2894.300000011921,
50
+ [0, false], 2969,
51
+ [0, false], 2971.199999988079,
52
+ [0, false], 3019.600000023842,
53
+ [0, false], 3026.800000011921,
54
+ [0, false], 3044.5,
55
+ [0, false], 3114.900000035763,
56
+ [0, false], 3250.199999988079,
57
+ [0, false], 3314.699999988079
58
+ ], 900);
@@ -1,7 +1,7 @@
1
1
  if (Promise) {
2
2
  var SafePromise = void 0;
3
3
  Promise.resolve({
4
- then() {
4
+ get then() {
5
5
  SafePromise = Promise;
6
6
  }
7
7
  });
@@ -2,6 +2,7 @@ var window = this;
2
2
  var Array = window.Array;
3
3
  var setTimeout = window.setTimeout;
4
4
  var Function = window.Function;
5
+ var Object = window.Object;
5
6
  var console = window.console;
6
7
  var navigator = window.navigator;
7
8
  var requestAnimationFrame = window.setImmediate || window.setTimeout;
@@ -15,33 +16,40 @@ if (!Promise) {
15
16
  return pendding instanceof Promise || pendding && isFunction(pendding.then);
16
17
  };
17
18
  var queue = [];
19
+ var running = false;
18
20
  var run = function (q) {
19
- var threads = queue.splice(0, queue.length);
20
- for (var t of threads) {
21
- if (t.oked) {
22
- for (var r of t.PromiseFulfillReactions) {
23
- r.call(null, t.oked[0]);
24
- }
25
- }
26
- if (t.ohed) {
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];
21
+ running = true;
22
+ while (queue.length) {
23
+ var threads = queue.splice(0, queue.length);
24
+ for (var t of threads) {
25
+ if (!t.oked && !t.ohed) continue;
26
+ var PromiseRejectReactions = t.PromiseRejectReactions.splice(0, t.PromiseRejectReactions.length);
27
+ var PromiseFulfillReactions = t.PromiseFulfillReactions.splice(0, t.PromiseFulfillReactions.length);
28
+
29
+ if (t.oked) {
30
+ for (var r of PromiseFulfillReactions) {
31
+ r.call(null, t.oked[0]);
32
+ }
34
33
  }
35
- for (var r of t.PromiseRejectReactions) {
36
- r.apply(null, t.ohed);
34
+ if (t.ohed) {
35
+ var throwed = t.throwed;
36
+ t.throwed = true;
37
+ if (!throwed && PromiseRejectReactions.length) {
38
+ // <!--
39
+ console.warn("在异步过程中发现未处理的异常:", t.ohed[0], t.ohed[1], t.ohed[2]);
40
+ // -->
41
+ throw t.ohed[0];
42
+ }
43
+ for (var r of PromiseRejectReactions) {
44
+ r.apply(null, t.ohed);
45
+ }
37
46
  }
38
47
  }
39
- t.PromiseRejectReactions.splice(0, t.PromiseRejectReactions.length);
40
- t.PromiseFulfillReactions.splice(0, t.PromiseFulfillReactions.length);
41
48
  }
49
+ running = false;
42
50
  };
43
51
  var fire = function (p) {
44
- if (queue.length) return queue.push(p);
52
+ if (running) return queue.push(p);
45
53
  queue.push(p);
46
54
  requestAnimationFrame(run);
47
55
  };
@@ -59,12 +67,12 @@ if (!Promise) {
59
67
  fire(p);
60
68
  }
61
69
  };
62
-
63
70
  var ResolvingFunctions_reject = function (e) { //oh
64
71
  if (p.oked || p.ohed) return;
65
72
  p.ohed = arguments;
66
73
  fire(p);
67
74
  };
75
+ fire(p);
68
76
  executor(ResolvingFunctions_resolve, ResolvingFunctions_reject);
69
77
  };
70
78
  Promise.prototype = {
@@ -147,5 +155,4 @@ if (!Promise) {
147
155
  ok.apply(null, args);
148
156
  });
149
157
  };
150
-
151
158
  }
@@ -243,7 +243,7 @@ Html.prototype.createString = function (code) {
243
243
  for (var c of code) {
244
244
  switch (c.type) {
245
245
  case PIECE:
246
- if (p && p.type === PIECE) dist.push(" ");
246
+ if (p && p.type & (PIECE | EXPRESS)) dist.push(" ");
247
247
  dist.push(c.text);
248
248
  break;
249
249
  case SPACE:
@@ -549,6 +549,9 @@ class Program {
549
549
  var scope = [];
550
550
  scope.entry = m;
551
551
  scope.type = SCOPED;
552
+ scope.start = match.index;
553
+ scope.col = match.index - colstart;
554
+ scope.row = row;
552
555
  var last = queue.last;
553
556
  if (m === "{") {
554
557
  if (!last) {
@@ -579,7 +582,6 @@ class Program {
579
582
  scope.isExpress = queue.inExpress;
580
583
  scope.inExpress = true;
581
584
  }
582
- scope.start = match.index;
583
585
  push_parents(scope);
584
586
  continue;
585
587
  }
@@ -596,13 +598,13 @@ class Program {
596
598
  pop_parents();
597
599
  continue;
598
600
  }
599
-
601
+ if (this.scope_leave[m]) console.warn("标记不匹配", queue.entry, m, "queue:", `${queue.row}:${queue.col}`, "position:", `${row}:${index - colstart}\r\n`, text.slice(queue.start, index));
600
602
  if (this.stamp_reg.test(m)) {
601
603
  save(STAMP);
602
604
  }
603
605
 
604
606
  }
605
- if (queue !== origin) throw console.log(createString(origin), createString([queue])), new Error("代码异常结束");
607
+ if (queue !== origin) throw console.log(createString(origin), `\r\n------ deep: ${parents.length} - enrty: ${queue.entry} - length: ${queue.length} - last: ${createString([queue.last])} -----\r\n`, createString([queue])), "代码异常结束";
606
608
  return queue;
607
609
  }
608
610
  commit() {
@@ -619,11 +621,13 @@ class Program {
619
621
  quoteslike.forEach(q => {
620
622
  var a = q[0];
621
623
  if (a instanceof RegExp) a = stringsFromRegExp(a);
622
- if (typeof a === "string" && a.length === 1) tokens[a] = true;
623
624
  if (a instanceof Array) {
624
- a.forEach(a => quote_map[a] = q);
625
+ a.forEach(a => {
626
+ quote_map[a] = q;
627
+ tokens[a.charAt(0)] = true;
628
+ });
625
629
  }
626
- else quote_map[a] = q;
630
+ else quote_map[a] = q, tokens[a.charAt(0)] = true;
627
631
  var r = q.slice(q[2] ? 2 : 3).concat(q[1]).map(q => {
628
632
  if (q instanceof Array) {
629
633
  q = q[q.length - 2];
@@ -76,7 +76,7 @@ source += source.toUpperCase() + "_$";
76
76
  var number = source + '0123456789';
77
77
  // source += "ªµºΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψω";
78
78
  source += function () {
79
- var reg = /\xAA\xB5\xBA\xC0-\xD5\xD8-\xF2\xF8-\u02af\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA/;
79
+ var reg = /\xAA\xB5\xBA\xC0-\xD5\xD8-\xF2\xF8-\u02AF\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0523\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0621-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA/;
80
80
  var dist = [];
81
81
  reg.source.replace(/\\[xu]([0-9a-f]+)(?:\-\\[xu]([0-9a-f]+))?/ig, function (_, a, b) {
82
82
  a = parseInt(a, 16);
@@ -96,15 +96,21 @@ function testJsxOnlyHtml() {
96
96
  <component1 ng-bind="expression"><child1></child1></component1>`);
97
97
  console.log(m.toString());
98
98
  }
99
+ function testSpaceLess() {
100
+ var m = scanner(`if(n<0)return'_f("'+t+'")('+e+")"`);
101
+ console.log(m.toString());
102
+ }
103
+ Program.debug = true;
99
104
  // testSpeed();
100
105
  // testVariables();
101
106
  // testRegexp();
102
107
  // testStatic();
103
108
  // testAssign();
104
109
  // testFormat();
105
- testJsx();
106
- testJsx2();
110
+ // testJsx();
111
+ // testJsx2();
107
112
  // testJsx3();
108
- testJsxOnlyHtml();
113
+ // testJsxOnlyHtml();
114
+ testSpaceLess();
109
115
  // var typescript = require("../typescript/index");
110
116
  // typescript.transpile(data.toString(), { noEmitHelpers: true });
@@ -70,6 +70,7 @@ var scrollX = function (targetBox, moveChildren) {
70
70
  scrollDelta = dragPosition.right + 20 - areaPosition.right;
71
71
  }
72
72
  if (scrollDelta) {
73
+ if (targetBox === document.documentElement) return;
73
74
  vscroll.X.call(targetBox, scrollDelta / 16, false);
74
75
  moveChildren();
75
76
  }
@@ -20,7 +20,7 @@ function main(elem = document.createElement("checkbox-group")) {
20
20
  options,
21
21
  select(a) {
22
22
  a.checked = !a.checked;
23
- elem.value = this.options.filter(a => !!a.checked);
23
+ elem.checked = elem.value = this.options.filter(a => !!a.checked);
24
24
  buildValue(elem.value, this.options);
25
25
  dispatch(elem, 'change');
26
26
  }
@@ -308,6 +308,7 @@ function grid(breakpoints) {
308
308
  }
309
309
  class Point extends Array {
310
310
  constructor(value, range) {
311
+ super();
311
312
  var solid = false;
312
313
  if (isObject(value)) {
313
314
  this.value = value.value;
@@ -390,7 +390,7 @@ function ylist(container, generator, $Y) {
390
390
  }
391
391
  if (absy <= 1) y = target_y;
392
392
  else {
393
- var speed = Math.abs(spd.read()[0]);
393
+ var speed = spd.read().rate;
394
394
  if (speed < 1) speed = 1;
395
395
  if (absy < 3) speed = .5;
396
396
  y = last_y + (target_y > last_y ? speed : -speed);
@@ -1,14 +1,17 @@
1
- <template -if='useIcon?||hasIcon?||icon?'>
2
- <i -class="icon?" -style="{color:color?}"></i>
3
- <template -if="name?">
1
+ <template -if='hasIcon?'>
2
+ <i -class="icon?" -style="{color:menu.color}"></i>
3
+ <template -if="menu.name">
4
4
  &nbsp;&nbsp;
5
5
  </template>
6
6
  </template>
7
- <span -html="name?" -style="{color:color?}"></span>
8
- <template -if="typeof hotkey==='string'">
7
+ <span -html="menu.name" -style="{color:menu.color}"></span>
8
+ <template -if="typeof menu.hotkey==='string'">
9
9
  &nbsp;&nbsp; <span class="hotkey" -html="hotkey"></span>
10
10
  </template>
11
- <template -elseif="hotkey?.length">
12
- &nbsp;&nbsp; <span ng-repeat="k of hotkey" class="hotkey" ng-html="k"></span>
11
+ <template -elseif="menu.hotkey?.length">
12
+ &nbsp;&nbsp; <span ng-repeat="k of menu.hotkey" class="hotkey" ng-html="k"></span>
13
+ </template>
14
+ <template -if="menu.isChecked?menu.isChecked():''">
15
+ &nbsp;&nbsp;✓
13
16
  </template>
14
17
  <s></s>
@@ -7,16 +7,21 @@ function main(elem, scope, hasIcon) {
7
7
  else if (item.$scope) {
8
8
  var scope = item.$scope;
9
9
  }
10
- if (scope.menu || scope.$item) scope = scope.menu || scope.$item;
11
- if (hasIcon === undefined) hasIcon = !!scope.icon;
12
- if (scope.disabled || scope.enabled === false) {
10
+ var menu = scope;
11
+ if (menu.menu || menu.$item) menu = menu.menu || menu.$item;
12
+ if (menu.disabled || menu.enabled === false) {
13
13
  item.setAttribute('disabled', '');
14
14
  }
15
15
  else {
16
16
  item.removeAttribute("disabled");
17
17
  }
18
- render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon }]);
19
- if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
18
+ scope = {
19
+ menu,
20
+ checker,
21
+ };
22
+ if (hasIcon) scope.hasIcon = true;
23
+ render(item.children, scope);
24
+ if (menu.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
20
25
  return item;
21
26
  }
22
27
  main.template = menuItem;
@@ -4,7 +4,7 @@
4
4
  top: 0;
5
5
  left: 0;
6
6
  bottom: 0;
7
- padding: 0 !important;
7
+ padding: 0;
8
8
  color: #333;
9
9
  right: 0;
10
10
  display: block;
@@ -1,18 +1,18 @@
1
- <thead @mounted="setFixedColumn.call(this.parentNode)">
1
+ <thead @mounted="setFixedColumn.call(this.parentNode),setContextMenu(this)">
2
2
  <tr inline-block #adapter thead @mounted="resizeT(this)">
3
3
  <td draggable="false" fixed row-index>序号</td>
4
4
  <td fixed:="f.fixed" -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i
5
5
  -if="f.icon" -class="f.icon"></i><span -if="f.name" -html="f.name"></span><template
6
6
  -else>&nbsp;</template>
7
7
  </td>
8
+ <td style="min-width: 0;" draggable="false">&nbsp;</td>
8
9
  </tr>
9
10
  </thead>
10
- <tbody -src="(d,i) in data" :style="tbodyHeight(this)">
11
- <tr inline-block @mounted="this.style.width=adapter.style.width">
12
- <td draggable="false" fixed row-index -bind="i+1" @mounted="this.style=adapter.firstChild.getAttribute('style')">
11
+ <tbody -src="(d,i) in data" :style="tbodyHeight(this,hasFoot)">
12
+ <tr inline-block :style="{width:adapter.style.width}" @click="rowClick(d,i,event)">
13
+ <td fixed row-index -bind="i+1" :style="adapter.firstChild.getAttribute('style')">
13
14
  </td>
14
- <td fixed:="f.fixed" -repeat="(f,i) in fields"
15
- @mounted="this.style=adapter.children[i+1].getAttribute('style')">
15
+ <td fixed:="f.fixed" -repeat="(f,i) in fields" :style="adapter.children[i+1].getAttribute('style')">
16
16
  <model -if="f.key&&!isEmpty(d[f.key])" :field=f :data=d readonly></model>
17
17
  <template -else>&nbsp;</template>
18
18
  <a on-click="o.do(d)" -if="!f.key&&f.options&&(!o.when||o.when(d))"
@@ -20,13 +20,19 @@
20
20
  <span -text="o.name instanceof Function?o.name(d):o.name"></span>
21
21
  </a>
22
22
  </td>
23
+ <td :style="adapter.lastChild.getAttribute('style')">&nbsp;</td>
23
24
  </tr>
24
25
  </tbody>
25
26
  <tfoot>
26
- <tr -if="!data||!data.length" style="padding-bottom: 20px;">
27
+ <tr .fade -if="!data||!data.length" style="padding-bottom: 20px;">
27
28
  <td style="text-align: center;">
28
29
  <template -if="data.is_loading">加载中</template>
29
30
  <template -else>无数据</template>
30
31
  </td>
31
32
  </tr>
33
+ <tr -elseif="hasFoot">
34
+ <td>
35
+ 共&nbsp;<span -bind="data.length"></span>&nbsp;个
36
+ </td>
37
+ </tr>
32
38
  </tfoot>