efront 4.1.6 → 4.1.9

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.
@@ -153,8 +153,10 @@ var readFile = function (names, then) {
153
153
  return;
154
154
  }
155
155
  }
156
- loadingTree[key].error = e;
157
- loadingTree[key].forEach(a => a(e));
156
+ if (loadingTree[key]) {
157
+ loadingTree[key].error = e;
158
+ loadingTree[key].forEach(a => a(e));
159
+ }
158
160
  };
159
161
  var tryload = function () {
160
162
  request(url, ok, oh, version);
@@ -279,6 +281,7 @@ var loadModule = function (url, then, prebuilds = {}) {
279
281
  var data = responseTree[url];
280
282
  if (typeof data === "function") {
281
283
  var mod = data;
284
+ mod.noenv = true;
282
285
  flushTree(loadedModules, key, mod);
283
286
  return;
284
287
  }
@@ -494,7 +497,6 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
494
497
  if (created) return result;
495
498
  return promise;
496
499
  });
497
-
498
500
  var _this = isModuleInit ? exports : window;
499
501
  var argsPromises = argsList.filter(isThenable);
500
502
  argsList = argsList.concat(exec.strs);
@@ -609,7 +611,12 @@ var init = function (url, then, prebuilds) {
609
611
  if (error) return crack(error);
610
612
 
611
613
  var module = loadedModules[key];
612
- if (!module) return;
614
+ if (!module || module.noenv) {
615
+ // <!--
616
+ undefinedModules[key] = true;
617
+ // -->
618
+ return then();
619
+ }
613
620
  var args = module.args || [];
614
621
 
615
622
  if (!args || !args.length) {
@@ -26,7 +26,8 @@ var couple = function (source, marker, pinyin) {
26
26
  };
27
27
  var len1 = source.length;
28
28
  var len2 = marker.length;
29
- var match = "", begin1 = len1, begin2 = len2;
29
+ var begin1 = len1, begin2 = len2;
30
+ var end1 = begin1;
30
31
  var end2 = begin2;
31
32
  for (var cx = -len1, dx = len2; cx < dx; cx++) {
32
33
  var c1 = cx >= 0 ? 0 : -cx;
@@ -38,17 +39,17 @@ var couple = function (source, marker, pinyin) {
38
39
  var m = marker[c2 + ct];
39
40
  if (s === m || pinyin && isLike()) {
40
41
  end = ct + 1;
41
- if (end === dt && end - start > match.length) {
42
- match = source.slice(c1 + start, c1 + end);
42
+ if (end === dt && c2 + end - cc - start > end2 - begin2) {
43
43
  begin1 = c1 + start;
44
44
  begin2 = cc + start;
45
45
  end2 = c2 + end;
46
+ end1 = c1 + end;
46
47
  }
47
48
  } else {
48
- if (end - start > match.length) {
49
- match = source.slice(c1 + start, c1 + end);
49
+ if (c2 + end - cc - start > end2 - begin2) {
50
50
  begin1 = c1 + start;
51
51
  begin2 = cc + start;
52
+ end1 = c1 + end;
52
53
  end2 = c2 + end;
53
54
  }
54
55
  cc = c2;
@@ -56,7 +57,7 @@ var couple = function (source, marker, pinyin) {
56
57
  }
57
58
  }
58
59
  }
59
- return [match, begin1, begin2, end2];
60
+ return [source.slice(begin1, end1), begin1, begin2, end2];
60
61
  };
61
62
  var MARK_PRE1, MARK_PRE2, _PRE1, _PRE2 = _PRE1 = "<b>";
62
63
  var MARK_AFT1, MARK_AFT2, _AFT1, _AFT2 = _AFT1 = "</b>";
@@ -85,6 +86,7 @@ var power = function (source, search) {
85
86
  var matchers = couple(source, search, _pinyin);
86
87
  var match_text = matchers[0];
87
88
  var match_start = matchers[1];
89
+ var match_length = matchers[3] - matchers[2];
88
90
  if (search.length === 1) {
89
91
  var p = 0;
90
92
  var res = source.replace(new RegExp(search.replace(/[\\\*\?\+\(\)\[]/g, "\\$&"), "ig"), (m, i) => {
@@ -93,12 +95,11 @@ var power = function (source, search) {
93
95
  });
94
96
  return [p, res];
95
97
  }
96
- if (matchers[3] - matchers[2] > 1) {
98
+ if (match_length > 1) {
97
99
  var match_text_pre = source.slice(0, match_start);
98
100
  var match_text_aft = source.slice(match_start + match_text.length);
99
101
  var pp = 0, ap = 0;
100
- var p = match_text.length;
101
- p = match_text.length;
102
+ var p = match_length !== match_text.length ? match_length - .1 : match_length;
102
103
  if (match_start) p += .1 / match_start - .2;
103
104
  if (match_text_pre.length > 1) {
104
105
  [pp, match_text_pre] = power(match_text_pre, search);
@@ -106,9 +107,15 @@ var power = function (source, search) {
106
107
  if (match_text_aft.length > 1) {
107
108
  [ap, match_text_aft] = power(match_text_aft, search);
108
109
  }
109
- if (matchers[3] - matchers[2] !== search.length) {
110
+ if (match_length !== search.length) {
110
111
  p += (pp + ap) / source.length / search.length * .01 - .2;
111
112
  }
113
+ else if (pp >= p) {
114
+ p += pp / source.length / search.length * .01 - .2;
115
+ }
116
+ else if (ap >= p) {
117
+ p += ap / source.length / search.length * .01 - .2;
118
+ }
112
119
  return [p, match_text_pre.concat(MARK_PRE1, match_text, MARK_AFT1, match_text_aft)];
113
120
  }
114
121
  return [0, source];
@@ -4,11 +4,11 @@ function parseKV(string) {
4
4
  var spliter, equals, decode;
5
5
  for (var cx = 1, dx = arguments.length; cx < dx; cx++) {
6
6
  var a = arguments[cx];
7
- if (typeof a === 'string') {
7
+ if (typeof a === 'string' || a instanceof RegExp) {
8
8
  if (!spliter) spliter = a;
9
9
  else if (!equals) equals = a;
10
10
  }
11
- else {
11
+ else if (typeof decode === 'function') {
12
12
  decode = a;
13
13
  }
14
14
  }
@@ -21,7 +21,7 @@ function parseKV(string) {
21
21
  for (var cx = 0, dx = kvs.length; cx < dx; cx++) {
22
22
  var kv = kvs[cx];
23
23
  if (!kv) continue;
24
- var index = kv.indexOf(equals);
24
+ var index = equals instanceof RegExp ? equals.exec(kv).index : kv.indexOf(equals);
25
25
  if (index < 0) index = kv.length;
26
26
  var k = kv.slice(0, index);
27
27
  var v = kv.slice(index + 1);
@@ -853,7 +853,7 @@ Javascript.prototype.fix = function (code) {
853
853
  });
854
854
  delete code.used.import;
855
855
  delete code.envs.import;
856
- if (imports.length) code.used.import_meta = imports;
856
+ if (imports.length) code.used["import_meta"] = imports, code.envs["import_meta"] = true;
857
857
  }
858
858
  if (code.exportDecs) {
859
859
  var exportDecs = code.exportDecs;
@@ -91,9 +91,13 @@ var maplist = function (u) {
91
91
  }
92
92
  if (enumtype & (REFSTRC | REFMOVE)) {
93
93
  if (o.property) o[ignore] = true;
94
- else m.wcount++;
94
+ else if (o.equal) m.enumref = o.enumref, m.wcount++;
95
+ else if (enumtype & REFMOVE) m.wcount++;
95
96
  }
96
97
  }
98
+ else if (enumtype & REFSTRC) {
99
+ if (o.enumref && o.enumref !== m.enumref) m.wcount++, m.enumref = o.enumref;
100
+ }
97
101
  if (o.called) m.ccount++;
98
102
  }
99
103
  return map;
@@ -220,6 +224,12 @@ function enumref(refitem, scoped) {
220
224
  }
221
225
  }
222
226
  }
227
+ else if (o.enumref) {
228
+ if (enumtype & REFSTRC) {
229
+ em = o.enumref;
230
+ continue;
231
+ }
232
+ }
223
233
  else {
224
234
  if (enumtype & REFTYPE) {
225
235
  if (tp) {
@@ -277,6 +277,11 @@ function snapSentenceHead(o) {
277
277
  }
278
278
  break;
279
279
  }
280
+ while (o) {
281
+ var p = o.prev;
282
+ if (!p || p.type !== LABEL) break;
283
+ o = p;
284
+ }
280
285
  return o;
281
286
  }
282
287
  var getStrapHead = function (o) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.1.6",
3
+ "version": "4.1.9",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {