efront 4.1.9 → 4.1.10

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.
@@ -30,10 +30,15 @@ var skipAssignment = function (o, cx) {
30
30
  while (o && o.type & (SPACE | COMMENT)) o = body[++ox];
31
31
  cx = ox + 1;
32
32
  }
33
+ else if (o.type & (SPACE | COMMENT)) o = o.next;
33
34
  var needpunc = false;
34
35
  var qcount = 0;
35
36
  var ifdeep = 0;
37
+ var labeled = o && o.type === LABEL;
38
+ while (o && o.type === LABEL) next();
36
39
  loop: while (o) switch (o.type) {
40
+ case LABEL:
41
+ if (!ifdeep) break loop;
37
42
  case STAMP:
38
43
  switch (o.text) {
39
44
  case ";":
@@ -43,7 +48,7 @@ var skipAssignment = function (o, cx) {
43
48
  next();
44
49
  break;
45
50
  case ",":
46
- if (!ifdeep) break loop;
51
+ if (!ifdeep && !labeled) break loop;
47
52
  needpunc = false;
48
53
  next();
49
54
  break;
@@ -259,7 +264,7 @@ function snapSentenceHead(o) {
259
264
  break;
260
265
  }
261
266
  if (p.type === STAMP) {
262
- if (/=>|[,;]/.test(p.text)) {
267
+ if (/=>|;/.test(p.text)) {
263
268
  break;
264
269
  }
265
270
  if (/^[\?\:]$/.test(p.text)) {
@@ -1293,7 +1298,7 @@ var pickSentence = function (o) {
1293
1298
  if (o && o.type === STAMP && o.prev) o = o.prev;
1294
1299
  if (o.type === STRAP && /^(in|instanceof|as|of)$/.test(o.text) && o.prev) o = o.prev;
1295
1300
  var h = snapSentenceHead(o);
1296
- var e = skipAssignment(o);
1301
+ var e = skipAssignment(h);
1297
1302
  var q = o.queue;
1298
1303
  if (q) {
1299
1304
  var qh = q.indexOf(h);
@@ -0,0 +1,12 @@
1
+ function testPickSentence(text, index, except) {
2
+ var code = scanner2(text);
3
+ assert(common.createString(common.pickSentence(code[index])), except);
4
+ }
5
+ testPickSentence(`function 九尾妖狐(){}`, 0, "function 九尾妖狐() {}")
6
+ testPickSentence(`function 九尾妖狐(){}`, 2, "function 九尾妖狐() {}")
7
+ testPickSentence(`a: function 九尾妖狐(){}`, 1, "a: function 九尾妖狐() {}")
8
+ testPickSentence(`a: function 九尾妖狐(){}`, 0, "a: function 九尾妖狐() {}")
9
+ testPickSentence(`a: function 九尾妖狐(){}`, 2, "a: function 九尾妖狐() {}")
10
+ testPickSentence(`a: 王天霸, 步惊云 b:叶流云, 四顾剑`, 2, "a: 王天霸, 步惊云")
11
+ testPickSentence(`a: 王天霸, 步惊云 b:叶流云, 四顾剑`, 4, "b: 叶流云, 四顾剑")
12
+ testPickSentence(`a: 王天霸, 步惊云; b:叶流云, 四顾剑`, 4, "a: 王天霸, 步惊云")
@@ -61,6 +61,11 @@ function getI18nPrefixedText(code, dist = []) {
61
61
  c.fields = refilm([c.translate]);
62
62
  dist.push(c);
63
63
  }, 字段名);
64
+ if (envs.refilm_decode) get(used.refilm_decode.filter(o => o.text === 'refilm_decode').map(o => o.next), c => {
65
+ c.fields = refilm([c.translate]);
66
+ c.warn = false;
67
+ dist.push(c);
68
+ }, 字段名);
64
69
  return dist;
65
70
  }
66
71
  var ctn = function (tt, t) {
@@ -86,10 +91,10 @@ function translate([imap, supports], code) {
86
91
  if (a.start > b.start && a.end < b.end) return -1;
87
92
  return 0;
88
93
  });
89
- var getm = function (tt) {
94
+ var getm = function (tt, warn) {
90
95
  tt = tt.trim();
91
96
  if (!imap[tt]) {
92
- console.warn(`<yellow>${i18n`国际化翻译缺失:`}</yellow>${tt}`);
97
+ if (warn !== false) console.warn(`<yellow>${i18n`国际化翻译缺失:`}</yellow>${tt}`);
93
98
  imap[tt] = supports.map(_ => tt);
94
99
  }
95
100
  return imap[tt].map(m => strings.encode(m || tt, '`'));
@@ -110,8 +115,14 @@ function translate([imap, supports], code) {
110
115
  else if (t.transtype === 字段名) {
111
116
  var i = t.queue.indexOf(t.prev);
112
117
  var e = t.queue.indexOf(t, i);
113
- var ui = used.refilm.indexOf(t.prev);
114
- used.refilm.splice(ui, 1);
118
+ if (t.warn === false) {
119
+ var ui = used.refilm_decode.indexOf(t.prev);
120
+ if (ui >= 0) used.refilm_decode.splice(ui, 1);
121
+ }
122
+ else {
123
+ var ui = used.refilm.indexOf(t.prev);
124
+ if (ui >= 0) used.refilm.splice(ui, 1);
125
+ }
115
126
  if (!used.i18n) {
116
127
  used.i18n = [];
117
128
  code.envs.i18n = true;
@@ -127,7 +138,7 @@ function translate([imap, supports], code) {
127
138
  if (a in t) v = t[a];
128
139
  else v = scanner2(JSON.stringify(v));
129
140
  }
130
- else if (k === 'name') v = ctn(`i18n(${getm(v)})`, t);
141
+ else if (k === 'name') v = ctn(`i18n(${getm(v, t.warn)})`, t);
131
142
  else v = scanner2(JSON.stringify(v));
132
143
  o.push({ type: PROPERTY, isprop: true, text: JSON.stringify(k) }, { type: STAMP, text: ':' }, ...v, { type: STAMP, text: ',' });
133
144
  })
@@ -472,8 +472,13 @@ var src2 = function (search) {
472
472
  } else if (isEmpty(origin)) {
473
473
  temp = "";
474
474
  }
475
- var changes = getChanges(temp, savedValue);
476
- if (!changes || isEmpty(origin) && isEmpty(this.src) && isEmpty(savedValue)) return;
475
+ if (savedValue !== undefined && savedValue !== null) {
476
+ var changes = getChanges(temp, savedValue);
477
+ if (!changes || isEmpty(origin) && isEmpty(this.src) && isEmpty(savedValue)) return;
478
+ }
479
+ else {
480
+ if (origin === undefined || origin === null) return;
481
+ }
477
482
  savedValue = temp;
478
483
  this.src = origin;
479
484
  cast(this, origin);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.1.9",
3
+ "version": "4.1.10",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {