efront 3.35.1 → 3.35.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.
@@ -621,7 +621,9 @@ var init = function (name, then, prebuilds) {
621
621
  }, prebuilds);
622
622
  return res;
623
623
  };
624
- var forceRequest = {};
624
+ var forceRequest = {
625
+ Promise: true
626
+ };
625
627
  var removeGlobalProperty = function (property) {
626
628
  forceRequest[property] = true;
627
629
  };
@@ -853,6 +855,7 @@ var initIfNotDefined = function (defined, path, onload) {
853
855
 
854
856
  if (document) loadResponseTreeFromStorage();
855
857
  initIfNotDefined([].map, "[]map", map => map);
858
+ "use ../basic_/#checkPromise.js";
856
859
  initIfNotDefined(Promise, "Promise", promise => Promise = promise);
857
860
  // <!-- window.modules = modules; -->
858
861
  var onload = function () {
@@ -169,7 +169,7 @@ class Tree extends Array {
169
169
  for (var data of datas) {
170
170
  if (isObject(data) || isString(data)) {
171
171
  var item;
172
- if (data instanceof Item) {
172
+ if (data.constructor === Item) {
173
173
  item = data;
174
174
  Tree.remove(item);
175
175
  }
@@ -0,0 +1,9 @@
1
+ if (Promise) {
2
+ var SafePromise = void 0;
3
+ Promise.resolve({
4
+ then() {
5
+ SafePromise = Promise;
6
+ }
7
+ });
8
+ Promise = SafePromise;
9
+ }
@@ -1,9 +1,61 @@
1
- var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
2
- var hasOwnProperty = Object.prototype.hasOwnProperty;
3
- for (var p in proto) if (hasOwnProperty.call(proto, p) && !(p in obj)) obj[p] = proto[p];
4
- return obj;
1
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
2
+ var setPrototypeOf = Object.setPrototypeOf;
3
+ a: if (!setPrototypeOf) {
4
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
5
+ var getOwnPropertyNames = Object.getOwnPropertyNames;
6
+ var defineProperty = Object.defineProperty;
7
+ try {
8
+ defineProperty({}, 'o', { value: 0 });
9
+ setPrototypeOf = function (obj, proto) {
10
+ for (var n of getOwnPropertyNames(proto)) {
11
+ var d = getOwnPropertyDescriptor(proto, n);
12
+ defineProperty(obj, n, d);
13
+ }
14
+ return obj;
15
+ }
16
+ break a;
17
+ } catch (e) {
18
+ getOwnPropertyDescriptor = null;
19
+ defineProperty = null;
20
+ getOwnPropertyNames = null;
21
+ }
22
+ // <!--
23
+ console.error('当前运行环境使用class extends Array会有难以解决的不兼容性问题,请更换代码的实现方式!');
24
+ // -->
25
+ setPrototypeOf = function (obj, proto) {
26
+ for (var p in proto) if (hasOwnProperty.call(proto, p) && !(p in obj)) obj[p] = proto[p];
27
+ obj.constructor = proto.constructor;
28
+ return obj;
29
+ }
5
30
  }
31
+ var wrapMethod = method => function () {
32
+ var res = method.apply(this, arguments);
33
+ var res0 = this.constructor.apply(this, []);
34
+ res0.length = res.length;
35
+ for (var k in res) {
36
+ k = +k;
37
+ if ((k & 0x7fffffff) !== k) break;
38
+ res0[k] = res[k];
39
+ }
40
+ return res0;
41
+ };
42
+ var map = wrapMethod([].map);
43
+ var slice = wrapMethod([].slice);
44
+ var filter = wrapMethod([].filter);
45
+ var splice = wrapMethod([].splice);
46
+ var concat = wrapMethod([].concat);
47
+
6
48
  function Array2() {
7
- return setPrototypeOf(Array.apply(this, arguments), this.constructor.prototype);
49
+ var proto = this.constructor.prototype;
50
+ /**
51
+ * @type {PropertyDescriptor}
52
+ */
53
+ if (!hasOwnProperty.call(proto, 'map')) proto.map = map;
54
+ if (!hasOwnProperty.call(proto, 'slice')) proto.slice = slice;
55
+ if (!hasOwnProperty.call(proto, 'filter')) proto.filter = filter;
56
+ if (!hasOwnProperty.call(proto, 'splice')) proto.splice = splice;
57
+ if (!hasOwnProperty.call(proto, 'concat')) proto.concat = concat;
58
+ var obj = setPrototypeOf(Array.apply(this, arguments), proto);
59
+ return obj;
8
60
  }
9
61
  Array2.prototype = Array.prototype;
@@ -3,14 +3,14 @@ var Array = window.Array;
3
3
  var setTimeout = window.setTimeout;
4
4
  var Function = window.Function;
5
5
  var console = window.console;
6
- var Error = window.Error;
6
+ var navigator = window.navigator;
7
7
  var requestAnimationFrame = window.setImmediate || window.setTimeout;
8
8
  var isFunction = function (f) {
9
9
  return typeof f === "function";
10
10
  };
11
- if (window.Promise) {
12
- var Promise = window.Promise;
13
- } else {
11
+ var Promise = window.Promise;
12
+ "use ./#checkPromise.js";
13
+ if (!Promise) {
14
14
  var isThenable = function (pendding) {
15
15
  return pendding instanceof Promise || pendding && isFunction(pendding.then);
16
16
  };
@@ -93,7 +93,7 @@ if (window.Promise) {
93
93
  if (this.oked || this.ohed) fire(this);
94
94
  return promise;
95
95
  },
96
- catch(f) {
96
+ "catch"(f) {
97
97
  return this.then(null, f);
98
98
  },
99
99
  }
@@ -94,7 +94,33 @@ var stringsFromRegExp = function (reg) {
94
94
  var res = combine(...queue).map(a => a.join(""));
95
95
  return res;
96
96
  }
97
-
97
+ var supportUnicodeRegExp = false;
98
+ var spaceDefined = [
99
+ "\\u0002",
100
+ "\\b-\\r",// "\\b"/*8*/, "\\t"/*9*/, "\\n"/*10*/, "\\v"/*11*/, "\\f"/*12*/, "\\r"/*13*/,
101
+ " "/*32*/,
102
+ "\\u007f", "\\u00a0", "\\u00ad", "\\u034f", "\\u061c",
103
+ "\\u115f", "\\u1160",
104
+ "\\u17b4", "\\u17b5",
105
+ "\\u180b-\\u180e",
106
+ "\\u1cbb", "\\u1cbc",
107
+ "\\u2000-\\u200f",
108
+ "\\u2028-\\u202f",
109
+ "\\u205f-\\u206f",
110
+ "\\u2800", "\\u3000", "\\u3164",
111
+ "\\ufe00-\\ufe0f",
112
+ "\\ufeff", "\\uffa0",
113
+ "\\ufff0-\\ufff8",
114
+ "\\u{133fc}",
115
+ "\\u{1d173}-\\u{1d17a}"
116
+ ]
117
+ try {
118
+ new RegExp('.', 'u');
119
+ supportUnicodeRegExp = true;
120
+ } catch (e) {
121
+ spaceDefined.pop();
122
+ spaceDefined.pop();
123
+ }
98
124
  class Program {
99
125
  quotes = [
100
126
  [/'/, /'/, /\\[\s\S]/],
@@ -126,29 +152,11 @@ class Program {
126
152
  classstrap_reg = /^(class)$/;
127
153
  extends_reg = /^(extends)$/;
128
154
  export_reg = /^(export)$/;
129
- spaces = [
130
- "\\u0002",
131
- "\\b-\\r",// "\\b"/*8*/, "\\t"/*9*/, "\\n"/*10*/, "\\v"/*11*/, "\\f"/*12*/, "\\r"/*13*/,
132
- " "/*32*/,
133
- "\\u007f", "\\u00a0", "\\u00ad", "\\u034f", "\\u061c",
134
- "\\u115f", "\\u1160",
135
- "\\u17b4", "\\u17b5",
136
- "\\u180b-\\u180e",
137
- "\\u1cbb", "\\u1cbc",
138
- "\\u2000-\\u200f",
139
- "\\u2028-\\u202f",
140
- "\\u205f-\\u206f",
141
- "\\u2800", "\\u3000", "\\u3164",
142
- "\\ufe00-\\ufe0f",
143
- "\\ufeff", "\\uffa0",
144
- "\\ufff0-\\ufff8",
145
- "\\u{133fc}",
146
- "\\u{1d173}-\\u{1d17a}"
147
- ]
155
+ spaces = spaceDefined;
148
156
  nocase = false
149
157
  lastIndex = 0
150
158
  compile(s) {
151
- return s.replace(/\\[\s\S]|[\[\]\(\)\{\}\+\.\-\*\?\$\^\|\\\/]/g, function (m) {
159
+ return s.replace(/\\[\s\S]|[\[\]\(\)\{\}\+\.\-\*\?\$\^\|\\\/ ]/g, function (m) {
152
160
  if (m.length > 1) {
153
161
  return m;
154
162
  }
@@ -177,7 +185,6 @@ class Program {
177
185
  var lasttype;
178
186
  var Code = this.Code;
179
187
  var queue = new Code();
180
- queue.__proto__ = Code.prototype;
181
188
  var origin = queue;
182
189
  var colonstrap_reg = this.colonstrap_reg;
183
190
  var forceend_reg = this.forceend_reg;
@@ -656,11 +663,12 @@ class Program {
656
663
  tokens = Object.keys(tokens).join("");
657
664
  tokens = this.compile(tokens) + spaces;
658
665
  var express = `[^${tokens}]+`;
659
- this.express_reg = new RegExp(`^${express}$`, 'u');
660
- this.space_reg = new RegExp(`^[${spaces}]+$`, 'u');
661
- this.space_exp = new RegExp(`[${spaces}]+`, 'u');
666
+ var flagUnicode = supportUnicodeRegExp ? 'u' : '';
667
+ this.express_reg = new RegExp(`^${express}$`, flagUnicode);
668
+ this.space_reg = new RegExp(`^[${spaces}]+$`, flagUnicode);
669
+ this.space_exp = new RegExp(`[${spaces}]+`, flagUnicode);
662
670
  var quotes = this.createRegExp(quoteslike.map(q => q[0]), true).source;
663
- this.entry_reg = new RegExp([`[${spaces}]+|${quotes}|[${scopes}]|${this.number_reg.source.replace(/^\^|\$$/g, "")}[^${tokens}]*|${express}|[${stamps}]`], "giu");
671
+ this.entry_reg = new RegExp([`[${spaces}]+|${quotes}|[${scopes}]|${this.number_reg.source.replace(/^\^|\$$/g, "")}[^${tokens}]*|${express}|[${stamps}]`], "gi" + flagUnicode);
664
672
  }
665
673
  }
666
674
  module.exports = Program;
@@ -4,8 +4,8 @@ function active(target, value, item = value, srcElem) {
4
4
  activeEvent.item = item;
5
5
  activeEvent.value = value;
6
6
  if (srcElem) {
7
- if (Object.defineProperty) Object.defineProperty(activeEvent, 'currentTarget', { value: srcElem });
8
- else activeEvent.currentTarget = srcElem;
7
+ if (Object.defineProperty) Object.defineProperty(activeEvent, 'active', { value: srcElem });
8
+ else activeEvent.active = srcElem;
9
9
  }
10
10
  activeEvent = dispatch(target, activeEvent);
11
11
  return activeEvent && !activeEvent.defaultPrevented;
@@ -1,7 +1,4 @@
1
1
  var slice = [].slice;
2
- var { appendChild: _appendChild, insertBefore: _insertBefore } = document.createElement('a');
3
- var isWorseIE = /msie\s+[2-8]/i.test(navigator.userAgent);
4
-
5
2
  function release(node) {
6
3
  if (node === null || node === undefined) return node;
7
4
  return isFunction(node) ? node() : isNode(node) ? node : document.createTextNode(node);
@@ -35,15 +32,7 @@ function appendChild(parent, obj, transition) {
35
32
  if (hasEnterStyle(o) && transition !== false) {
36
33
  isFunction(appendChild.transition) && appendChild.transition(o);
37
34
  }
38
- if (isWorseIE) {
39
- try {
40
- _appendChild.call(parent, o);
41
- } catch (e) {
42
- console.error("appendChild", parent.tagName, o.tagName);
43
- }
44
- } else {
45
- _appendChild.call(parent, o);
46
- }
35
+ parent.appendChild(o);
47
36
  o.with && appendChild(parent, o.with, transition);
48
37
  if (isMounted(parent)) _onappend(o);
49
38
  }
@@ -62,7 +51,7 @@ function insertBefore(alreadyMounted, obj, transition) {
62
51
  var o = release(children[cx]);
63
52
  if (!o) continue;
64
53
  if (o.removeTimer) clearTimeout(o.removeTimer);
65
- _insertBefore.call(parent, o, alreadyMounted);
54
+ parent.insertBefore(o, alreadyMounted);
66
55
  o.with && insertBefore(alreadyMounted, o.with, transition);
67
56
  if (isMounted(parent)) _onappend(o);
68
57
  if (hasEnterStyle(o) && transition !== false) {
@@ -82,7 +71,7 @@ function insertAfter(alreadyMounted, obj, transition) {
82
71
  for (var cx = 0, dx = children.length; cx < dx; cx++) {
83
72
  var o = release(children[cx]);
84
73
  if (o.removeTimer) clearTimeout(o.removeTimer);
85
- _insertBefore.call(parent, o, alreadyMounted.nextSibling);
74
+ parent.insertBefore(o, alreadyMounted.nextSibling);
86
75
  o.with && insertBefore(alreadyMounted.nextSibling, o.with, transition);
87
76
  if (isMounted(parent)) _onappend(o);
88
77
  if (hasEnterStyle(o) && transition !== false) {
@@ -108,4 +97,18 @@ appendChild.replace = function (alreadyMounted, element) {
108
97
  if (!alreadyMounted || !alreadyMounted.parentNode) return;
109
98
  insertBefore(alreadyMounted, element);
110
99
  remove(alreadyMounted);
100
+ };
101
+ var wrapTargetMethod = function (target, methodName) {
102
+ var method = target[methodName];
103
+ if (method.wrapped) return;
104
+ var newMethod = target[methodName] = function (node) {
105
+ var res = method.apply(this, arguments);
106
+ _onappend(node);
107
+ return res;
108
+ };
109
+ newMethod.wrapped = true;
110
+ };
111
+ appendChild.wrapTarget = function (target) {
112
+ wrapTargetMethod(target, 'insertBefore');
113
+ wrapTargetMethod(target, 'appendChild');
111
114
  };
@@ -40,6 +40,9 @@ var cross = cross_.bind(function (callback, onerror) {
40
40
  }
41
41
  break;
42
42
  default:
43
+ if (xhr.response === void 0) {
44
+ xhr.response = xhr.responseText;
45
+ }
43
46
  callback();
44
47
  }
45
48
  saveCookie();
@@ -129,13 +129,10 @@ var cssTargetSelector = function (targetSelector, oStyle, oValue) {
129
129
  var key = transformCssKey(oStyle);
130
130
  styleobject[key] = oValue;
131
131
  } else {
132
- oStyle.replace(/^;+|;+$/g, "").split(/;+/).map(function (kv) {
133
- var [k, v] = kv.split(":");
134
- delete styleobject[k];
135
- if (k) styleobject[k] = v || '';
136
- });
132
+ oStyle = parseKV(oStyle, ';', ':');
137
133
  }
138
- } else if (isObject(oStyle)) {
134
+ }
135
+ if (isObject(oStyle)) {
139
136
  for (var k in oStyle) {
140
137
  var key = transformCssKey(k);
141
138
  styleobject[key] = oStyle[k];
@@ -144,12 +141,12 @@ var cssTargetSelector = function (targetSelector, oStyle, oValue) {
144
141
  var rowStyles = [];
145
142
  var styleSheet = stylesheet.styleSheet;
146
143
  var cssText = stylesheet.savedText || (styleSheet ? styleSheet.cssText : stylesheet.innerHTML).replace(/^[\s\S]*?\{([\s\S]*?)\}[\s\S]*?$/, "$1");
147
- cssText.split(";").forEach(function (kv) {
148
- var k = kv.replace(/^(.*?)\:.*$/, "$1");
144
+ cssText.trim().split(/\s*;\s*/).forEach(function (kv) {
145
+ var k = kv.replace(/^(.*?)\s*\:.*$/, "$1");
149
146
  if (k && !(k in styleobject)) rowStyles.push(kv);
150
147
  });
151
148
  for (var k in styleobject) {
152
- if (styleobject[k]) {
149
+ if (!isEmpty(styleobject[k])) {
153
150
  rowStyles.push(k + ":" + transformValue(styleobject[k], k));
154
151
  }
155
152
  }
@@ -8,6 +8,7 @@ var dispatch = "dispatchEvent" in document ? function dispatchEvent(target, even
8
8
  return target[fire] && target[fire](event);
9
9
  }
10
10
  };
11
+ var isWorseEnv = /MSIE\s([2-9]|10)|Presto/.test(navigator.userAgent);
11
12
  /**
12
13
  * @param {Event} e
13
14
  */
@@ -15,7 +16,7 @@ function dispatch2(t, e) {
15
16
  var on = 'on' + e.type;
16
17
  var f = t[on];
17
18
  var res = dispatch(t, e);
18
- if (f && (t.nodeType !== 1 || t.constructor === window.HTMLUnknownElement)) {
19
+ if (f && (t.nodeType !== 1 || t.constructor === window.HTMLUnknownElement || isWorseEnv && !(on in t.constructor.prototype))) {
19
20
  return f.call(t, e) !== false;
20
21
  }
21
22
  return res;
@@ -308,7 +308,6 @@ function grid(breakpoints) {
308
308
  }
309
309
  class Point extends Array {
310
310
  constructor(value, range) {
311
- super();
312
311
  var solid = false;
313
312
  if (isObject(value)) {
314
313
  this.value = value.value;
@@ -334,7 +333,7 @@ var createPoints = function (values, direction = "x", result = new Point(0)) {
334
333
  if (!(values instanceof Array)) values = arguments;
335
334
  for (var cx = 0, dx = values.length; cx < dx; cx++) {
336
335
  var value = values[cx];
337
- if (value instanceof Array && !(value instanceof Point)) {
336
+ if (value instanceof Array && value.constructor !== Point) {
338
337
  if (!result.length) throw new Error("数据转换为grid失败!");
339
338
  createPoints(value, direction === "x" ? "y" : "x", result[result.length - 1]);
340
339
  } else {
@@ -581,20 +581,6 @@ var getGeneratorFromArray = function (source) {
581
581
  };
582
582
  };
583
583
 
584
-
585
- var _insertBefore = function (child, referer) {
586
- if (referer) {
587
- if (referer.parentNode !== this) throw new Error('关联节点不是当前节点的子节点!');
588
- appendChild.before(referer, child, false);
589
- } else {
590
- appendChild(this, child, false);
591
- }
592
- return child;
593
- };
594
- var _appendChild = function (child) {
595
- appendChild(this, child, false);
596
- return child;
597
- };
598
584
  /**
599
585
  *
600
586
  * @param {Boolean|Array|Function} generator
@@ -644,8 +630,7 @@ function list() {
644
630
  if (groupCount) groupCount = +groupCount[0];
645
631
  $Y = /^[xh]|[xh]$/i.test($Y) ? "X" : "Y";
646
632
  if (!container) container = document.createElement('list');
647
- container.insertBefore = _insertBefore;
648
- container.appendChild = _appendChild;
633
+ appendChild.wrapTarget(container);
649
634
  var list = ($Y === "X" ? xlist : ylist)(container, generator, $Y);
650
635
  if (!list.group) list.group = groupCount || 2;
651
636
  if (bindSrc instanceof Array) {
@@ -133,7 +133,6 @@ function main(elem, mode) {
133
133
  care(elem, function (src) {
134
134
  if (src) src = getTreeFromData(src);
135
135
  var hasIcon = src.hasIcon;
136
- JSON.stringify(src);
137
136
  elem.useIcon = hasIcon;
138
137
  elem.src = src;
139
138
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var oncetree = {};
3
3
  function emit(ontype, target, handler, firstmost) {
4
- var off = ontype.call(this, target, function (event) {
4
+ var off = ontype(target, function (event) {
5
5
  off();
6
6
  return handler.call(this, event);
7
7
  }, firstmost);
@@ -648,7 +648,8 @@ var createEmiter = function (on) {
648
648
  digest();
649
649
  var parsedSrc = this.$src;
650
650
  if (parsedSrc instanceof Repeater) {
651
- var target = e.currentTarget === this ? e.target : e.currentTarget || e.target;
651
+ if (e.active || e.currentTarget) var target = e.active || e.currentTarget;
652
+ else var target = e.target;
652
653
  if (target === this) {
653
654
  scope = parsedSrc.createScope();
654
655
  }
@@ -61,7 +61,7 @@ function tree() {
61
61
  }
62
62
  var tabs = new Array(com.tab + 1).join("<t></t>");
63
63
  if (isFunction(generator)) {
64
- var elem = generator(index, com instanceof Item ? com.value : com, com);
64
+ var elem = generator(index, com.constructor === Item ? com.value : com, com);
65
65
  if (!elem) return;
66
66
  span = document.createElement('span');
67
67
  span.innerHTML = tabs;
package/docs/index.html CHANGED
@@ -8,7 +8,7 @@
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="/favicon.ico" type="image/x-icon" />
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
13
  <title>efront 文档</title>
14
14
  <style>
package/docs/main.xht CHANGED
@@ -11,6 +11,7 @@
11
11
  position: absolute;
12
12
  padding-left: var(--leftwidth);
13
13
  overflow: hidden;
14
+ background: #fff;
14
15
  }
15
16
 
16
17
  :root+scrollbar {
@@ -61,7 +62,8 @@
61
62
  position: relative;
62
63
  background: linear-gradient(#f2f4ff, 70%, #e9fff2);
63
64
  }
64
- :root>menu v{
65
+
66
+ :root>menu v {
65
67
  display: inline-block;
66
68
  font-size: 12px;
67
69
  color: #79a;
@@ -110,7 +112,6 @@
110
112
  })
111
113
  var initVersionInfo = async function () {
112
114
  var xhr = await cross("get", "version");
113
- console.log(xhr)
114
115
  var version = xhr.response.split(",");
115
116
  menus[0].name += ` <v>${version[0]}</v>`;
116
117
  }
package/docs/mark.xht CHANGED
@@ -160,7 +160,7 @@
160
160
  };
161
161
  var page = document.createElement("markdown");
162
162
  on("mounted")(page, async function () {
163
- var xhr = await cross('get', "./welcome:" + md);
163
+ var xhr = await cross('get', "./welcome:" + encodeURI(md));
164
164
  page.innerHTML = markdown(xhr.response, md);
165
165
  for (var target of page.querySelectorAll("a")) {
166
166
  onclick(target, clickAnchor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.35.1",
3
+ "version": "3.35.2",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {