efront 4.3.15 → 4.4.0

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.
@@ -10,6 +10,7 @@ const {
10
10
  /* 256 */SCOPED,
11
11
  /* 512 */LABEL,
12
12
  /*1024 */PROPERTY,
13
+ /*2048 */ELEMENT,
13
14
  createString,
14
15
  number_reg,
15
16
  } = require("./common");
@@ -90,8 +91,10 @@ class Program {
90
91
  ["`", "`", /\\[\s\S]/, ["${", "}"]],
91
92
  ]
92
93
  tags = [
93
- [["<", "</"], /\/?>/, null, ["=", "'", '"', "{", "}"], [/<!--/, /--!?>/]]
94
+ [["<", "</"], /\/?>/, null, ["'", '"', "{", "}"], [/<!--/, /--!?>/]]
94
95
  ];
96
+ scriptTags = [];
97
+ ignoreTags = ["STYLE", "SCRIPT"];
95
98
  comments = [
96
99
  ["//", /(?=[\r\n\u2028\u2029])/],
97
100
  ["/*", "*/"],
@@ -213,45 +216,79 @@ class Program {
213
216
  queue_push(scope);
214
217
  };
215
218
  var space_exp = this.space_exp;
219
+ var scriptTags = this.scriptTags;
220
+ var ignoreTags = this.ignoreTags;
216
221
  var openTag = function () {
217
- queue.inTag = true;
218
222
  var m1 = text.slice(start, match.index);
219
223
  var s = space_exp.exec(m1);
224
+
220
225
  if (s) var tag = m1.slice(0, s.index);
221
226
  else {
222
227
  tag = m1;
223
228
  }
224
229
  if (queue.tag) {
225
- if (queue.last.text === quote.tag[1]) {
226
- while (p && p.tag && p.tag !== p.tag) ps.push(p), p = parents[--pi];
227
- if (p && ps.length) {
228
- var pie = queue.pop();
229
- queue.last = pie.prev;
230
- queue = p;
231
- while (ps.length) queue_push(ps.shift());
232
- queue_push(pie);
233
- }
234
- m = tag;
235
- save(PIECE);
236
- queue.closed = true;
237
- var p = queue;
238
- var pi = parents.length;
239
- var ps = [];
230
+ if (!quote.end.test(m)) return;
231
+ var qtag = quote.tag[1];
232
+ if (queue.tag_entry !== qtag) return;
233
+ var p = queue;
234
+ var pi = parents.length;
235
+ var ps = [];
236
+ for (var cx = 0, dx = parents.length; cx < dx; cx++) {
237
+ if (parents[cx].tag) break;
238
+ }
239
+ while (pi >= cx && p.tag !== tag) {
240
+ ps.push(p);
241
+ p = parents[--pi];
242
+ }
243
+ if (!p.tag) {
244
+ if (queue.waitTag) return;
245
+ pi++;
246
+ var scope = [];
247
+ scope.entry = queue.tag_entry;
248
+ scope.tag_leave = queue.tag_leave;
249
+ scope.tag = tag;
250
+ scope.inTag = true;
251
+ scope.type = ELEMENT;
240
252
  }
253
+ else {
254
+ p.tag_entry = queue.tag_entry;
255
+ p.closed = true;
256
+ p.inTag = true;
257
+ }
258
+ if (pi < parents.length) parents.splice(pi, parents.length - pi);
259
+ queue = p;
260
+ while (ps.length) {
261
+ var q = ps.pop();
262
+ if (q.tag) q.type = ELEMENT;
263
+ queue_push(q);
264
+ }
265
+ if (scope) queue = scope;
266
+ return true;
267
+ }
241
268
 
269
+ queue.inTag = true;
270
+ queue.tag = tag;
271
+ var tagName = tag.toUpperCase();
272
+ if (scriptTags.indexOf(tagName) >= 0) {
273
+ queue.waitTag = tagName;
274
+ queue.type = SCOPED;
242
275
  }
243
- else {
244
- queue.tag = tag;
245
- m = m1;
246
- save(PIECE);
276
+ else if (ignoreTags.indexOf(tagName) >= 0) {
277
+ queue.waitTag = tagName;
247
278
  }
248
- if (queue.closed) {
249
- index = match.index;
279
+ if (s) {
280
+ m = m1.slice(s[0].length + s.index);
281
+ if (m) save(PIECE);
250
282
  }
283
+ queue.first = null;
284
+ queue.last = null;
285
+ return true;
251
286
  };
252
287
  var closeTag = function () {
253
288
  queue.inTag = false;
254
289
  if (queue.closed) return;
290
+ if (queue.length) queue.attributes = queue.splice(0, queue.length);
291
+ if (/^\//.test(m)) return queue.short = true, queue.closed = true;
255
292
  return false;
256
293
  };
257
294
  var push_quote = function () {
@@ -278,7 +315,20 @@ class Program {
278
315
  queue_push(scope);
279
316
  lasttype = scope.type;
280
317
  }
281
-
318
+ var push_piece = function (index = match.index) {
319
+ if (index > start) {
320
+ var piece = queue[queue.length - 1];
321
+ if (piece && piece.type === PIECE) {
322
+ piece.text = text.slice(piece.start, index);
323
+ piece.end = match.index;
324
+ }
325
+ else {
326
+ m = text.slice(start, index);
327
+ save(PIECE);
328
+ }
329
+ }
330
+ m = match[0];
331
+ }
282
332
  loop: while (index < text.length) {
283
333
  if (queue.type === QUOTED) {
284
334
  var quote = this.quote_map[queue.entry];
@@ -294,16 +344,26 @@ class Program {
294
344
  var m = match[0];
295
345
  index = match.index + m.length;
296
346
  if (quote.tag && queue.inTag === 0) {
297
- openTag();
298
- index = start = match.index;
347
+ if (openTag()) {
348
+ if (queue.type === ELEMENT) break;
349
+ start = index = match.index;
350
+ }
351
+ else queue.inTag = false;
352
+
299
353
  continue;
300
354
  }
301
355
  if (quote.end.test(m)) {
302
356
  end = match.index;
303
- if (queue.tag && closeTag() === false) {
304
- save(PIECE);
305
- start = index;
306
- continue loop;
357
+ if (queue.tag) {
358
+ push_piece();
359
+ if (!queue.inTag) continue;
360
+
361
+ if (closeTag() === false) {
362
+ start = index;
363
+ queue.tag_leave = m;
364
+ continue loop;
365
+ }
366
+ queue.type = ELEMENT;
307
367
  }
308
368
  queue.leave = m;
309
369
  if (start < end) {
@@ -314,8 +374,12 @@ class Program {
314
374
  }
315
375
  a: if (quote.tag) {
316
376
  var mi = quote.tag.indexOf(m);
317
- if (mi < 0) break a;
377
+ if (mi < 0) {
378
+ break a;
379
+ }
318
380
  if (mi === 0) {
381
+ if (queue.waitTag) continue;
382
+ push_piece();
319
383
  var scope = [];
320
384
  scope.entry = m;
321
385
  scope.type = QUOTED;
@@ -326,20 +390,34 @@ class Program {
326
390
  start = index;
327
391
  continue;
328
392
  }
329
- save(PIECE);
393
+ push_piece();
394
+ queue.tag_entry = m;
330
395
  queue.inTag = 0;
331
396
  start = index;
332
397
  continue;
333
398
  }
334
399
  if (m in quote.entry) {
400
+ if (queue.tag && !queue.inTag && queue.waitTag) {
401
+ continue;
402
+ }
335
403
  push_quote();
336
404
  continue loop;
337
405
  }
406
+ if (m in this.quote_map) {
407
+ if (queue.tag && !queue.inTag) continue;
408
+ push_piece();
409
+ var scope = [];
410
+ scope.entry = m;
411
+ scope.type = QUOTED;
412
+ push_parents(scope);
413
+ continue loop;
414
+ }
338
415
  }
339
416
  queue.end = match.index;
340
417
  pop_parents();
341
418
  continue;
342
419
  }
420
+
343
421
  var reg = this.entry_reg;
344
422
  var start = reg.lastIndex = index;
345
423
  var match = reg.exec(text);
@@ -349,6 +427,18 @@ class Program {
349
427
  var m = match[0];
350
428
  test: if (this.quote_map.hasOwnProperty(m)) {
351
429
  var last = queue.last;
430
+ var quote = this.quote_map[m];
431
+ if (queue.tag && quote.tag) {
432
+ var tagend = end + queue.tag.length
433
+ var leavem = quote.entry[m];
434
+ if (text.slice(end, tagend) === queue.tag && text.slice(tagend, tagend + leavem.length) === leavem) {
435
+ push_piece();
436
+ queue.type = QUOTED;
437
+ queue.inTag = 0;
438
+ queue.tag_entry = m;
439
+ break test;
440
+ }
441
+ }
352
442
  if (this.stamp_reg.test(m) && last) {
353
443
  if ((VALUE | EXPRESS) & last.type) break test;
354
444
  if (last.type === QUOTED && !last.tag) break test;
@@ -356,7 +446,6 @@ class Program {
356
446
  if (lasttype === STAMP && m === last.text) break test;
357
447
  }
358
448
  var scope = [];
359
- var quote = this.quote_map[m];
360
449
  scope.type = this.comment_entry.test(m) ? COMMENT : QUOTED;
361
450
  scope.isExpress = queue.inExpress;
362
451
  scope.start = start;
@@ -402,7 +491,7 @@ class Program {
402
491
  continue;
403
492
  }
404
493
  var parent = parents[parents.length - 1];
405
- if (parent && this.quote_map[parent.entry] && queue.leave_map[m] === queue.entry) {
494
+ if (parent && this.quote_map[parent.entry] && queue.leave_map?.[m] === queue.entry) {
406
495
  delete queue.leave_map;
407
496
  queue.end = end;
408
497
  queue.leave = m;
@@ -520,16 +609,32 @@ class Program {
520
609
 
521
610
  queue.end = end;
522
611
  queue.leave = m;
612
+
523
613
  pop_parents();
524
614
  continue;
525
615
  }
526
- if (this.scope_leave[m]) console.warn(i18n`标记不匹配`, queue.entry, m, "queue:", `${queue.row}:${queue.col}`, "position:", `${row}:${index - colstart}\r\n`, text.slice(queue.start, index));
616
+ if (this.scope_leave[m]) console.warn(i18n`标记不匹配`, queue.entry, m, "queue-start:", queue.start, "position:", `${row}:${index - colstart}\r\n`, index - queue.start < 200 ? text.slice(queue.start, index) : text.slice(queue.start, queue.start + 100) + "..." + text.slice(index - 97, index));
527
617
  if (this.stamp_reg.test(m)) {
528
618
  save(STAMP);
529
619
  }
530
620
 
531
621
  }
532
- 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])), "代码异常结束";
622
+ while (queue.tag && parents.length) {
623
+ for (var cx = 0, dx = parents.length; cx < dx; cx++) {
624
+ if (parents[cx].tag) break;
625
+ }
626
+ var ps = parents.splice(cx, parents.length - cx);
627
+ ps.push(queue);
628
+ queue = parents[cx - 1];
629
+ while (ps.length) {
630
+ var p = ps.shift();
631
+ if (p.tag) p.type = ELEMENT;
632
+ queue_push(p);
633
+ }
634
+ };
635
+ if (queue !== origin) {
636
+ throw console.log(createString(origin), `\r\n------ deep: ${parents.length}\r\n --- enrty: ${queue.entry}\r\n -- length: ${queue.length}\r\n ---- last: ${createString([queue.last])}\r\n------- end\r\n --parents: ${parents.map(p => p.tag || p.entry || p.text).join('->')}`, createString([queue]).slice(-200)), "代码异常结束";
637
+ }
533
638
  return queue;
534
639
  }
535
640
  commit() {
@@ -556,8 +661,15 @@ class Program {
556
661
  quote_map[a] = q
557
662
  if (a.length === 1) tokens[a] = true;
558
663
  }
664
+ });
665
+ quoteslike.forEach(q => {
666
+ var ts = [];
559
667
  var r = q.slice(q[2] ? 2 : 3).concat(q[1]).map(q => {
560
668
  if (q instanceof Array) {
669
+ if (q.length > 2) {
670
+ ts.push(...q.slice(0, q.length - 2));
671
+ }
672
+ else if (q.length !== 2) throw new Error("配置错误!");
561
673
  q = q[q.length - 2];
562
674
  }
563
675
  if (q instanceof RegExp) {
@@ -566,7 +678,7 @@ class Program {
566
678
  return this.compile(q);
567
679
  });
568
680
  if (q.tag) r = r.concat(q.tag.slice().sort(sortRegExpSource));
569
- r = r.join("|");
681
+ r = r.concat(ts.map(this.compile)).join("|");
570
682
  q.reg = new RegExp(r, 'g');
571
683
  q.end = this.createRegExp([q[1]]);
572
684
  if (q.length >= 4) {
@@ -11,6 +11,7 @@ const [
11
11
  /* 256 */SCOPED,
12
12
  /* 512 */LABEL,
13
13
  /*1024 */PROPERTY,
14
+ /*2048 */ELEMENT,
14
15
  ] = new Array(20).fill(0).map((_, a) => 1 << a);
15
16
  // --------------//1//2/////////////////////////22/////////////2//2//3//4/////4////////3/////3//////3//3//////3///////211/////////////2//////2//////1///
16
17
  var number_reg = /^(?:(?:0x[0-9a-f]+|0b\d+|0o\d+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[mniul]|ll)?$/i;
@@ -486,7 +487,7 @@ var createScoped = function (parsed, wash) {
486
487
  else {
487
488
  var u = o.text;
488
489
  if (/^\.\.\./.test(u)) u = u.slice(3);
489
- var u = u.replace(/^([^\.\[]*)[\s\S]*$/, '$1');
490
+ var u = u.replace(/^([^\.\[\?]*)[\s\S]*$/, '$1');
490
491
  if (!u) break;
491
492
  var prev = o.prev;
492
493
  if (prev && prev.type === STAMP && /^(?:\+\+|\-\-)$/.test(prev.text)) {
@@ -1050,12 +1051,14 @@ var createString = function (parsed) {
1050
1051
  var uncomment = parsed.comment === false;
1051
1052
  var result = [], cacheresult, finalresult = result;
1052
1053
  var helpcolor = parsed.keepcolor === false;
1054
+ var intag = false;
1053
1055
  var run = (o, i, a) => {
1054
1056
  var prev = o.prev;
1055
- if (!((SPACE | COMMENT | STAMP | PIECE | SCOPED) & o.type) && prev && lasttype !== SPACE && patchspace) {
1056
- if ((QUOTED | SCOPED | STRAP | LABEL | COMMENT) & lasttype
1057
+ a: if (!((SPACE | COMMENT | STAMP | PIECE | SCOPED) & o.type) && prev && lasttype !== SPACE && patchspace) {
1058
+ if ((QUOTED | SCOPED | STRAP | LABEL | COMMENT | ELEMENT) & lasttype
1057
1059
  || prev.type === STAMP && !prev.unary
1058
1060
  ) {
1061
+ if (intag || prev.type === ELEMENT && o.type === ELEMENT) break a;
1059
1062
  if (o.type !== EXPRESS || !/^(\.[^\.]|\[)/.test(o.text) && !prev.tag && !o.tag) {
1060
1063
  result.push(" ");
1061
1064
  lasttype = SPACE
@@ -1106,8 +1109,46 @@ var createString = function (parsed) {
1106
1109
  var b = breakSpace(o);
1107
1110
  if (b) result.push(b);
1108
1111
  break;
1112
+ case ELEMENT:
1113
+ result.push(o.entry);
1114
+ result.push(o.tag);
1115
+ if (o.attributes) {
1116
+ intag = 0;
1117
+ var attributes = o.attributes;
1118
+ var needvalue = false;
1119
+ while (intag < attributes.length) {
1120
+ var a = attributes[intag++];
1121
+ if (a.type === STAMP && a.text === "=") {
1122
+ run(a);
1123
+ needvalue = true;
1124
+ }
1125
+ else {
1126
+ if (a.type === PIECE && !a.text) continue;
1127
+ if (!needvalue && (a.type !== PIECE || !/^\=/.test(a.text))) result.push(" ");
1128
+ run(a);
1129
+ needvalue = a.type === PIECE && /[\=]$/.test(a.text);
1130
+ }
1131
+ }
1132
+ intag = 0;
1133
+ }
1134
+ if (o.closed) {
1135
+ if (!o.short) {
1136
+ result.push(o.tag_leave);
1137
+ if (o.length) {
1138
+ o.forEach(run);
1139
+ }
1140
+ result.push(o.tag_entry);
1141
+ result.push(o.tag);
1142
+ }
1143
+ result.push(o.leave);
1144
+ }
1145
+ else {
1146
+ result.push(o.tag_leave);
1147
+ if (o.length) o.forEach(run);
1148
+ }
1149
+ break;
1109
1150
  case QUOTED:
1110
- if (!o.length) {
1151
+ if (!o.length && o.text) {
1111
1152
  if (helpcolor) o.text = color.transform(o.text);
1112
1153
  result.push(o.text);
1113
1154
  break;
@@ -1119,8 +1160,9 @@ var createString = function (parsed) {
1119
1160
  )) result.push(" ");
1120
1161
  result.push(o.entry);
1121
1162
  if (o.length > 0) {
1163
+ var fillspace = patchspace && lasttype !== PIECE && !intag;
1122
1164
  if (o.entry === "{" && o[0].type !== SPACE) {
1123
- if (patchspace && lasttype !== PIECE) {
1165
+ if (fillspace) {
1124
1166
  result.push(" ");
1125
1167
  }
1126
1168
  }
@@ -1138,14 +1180,14 @@ var createString = function (parsed) {
1138
1180
  }
1139
1181
  }
1140
1182
  if (o.leave === "}" && o.entry === "{" && o[o.length - 1].type !== SPACE) {
1141
- if (patchspace) result.push(" ");
1183
+ if (fillspace) result.push(" ");
1142
1184
  }
1143
1185
  }
1144
1186
  result.push(o.leave);
1145
1187
  break;
1146
1188
  default:
1147
1189
  if (o && typeof o === "object") {
1148
- if (o.prev && o.prev.type === EXPRESS && o.type === EXPRESS && (/^[\.\[]/.test(o.text) || /\.$/.test(o.prev.text)));
1190
+ if (intag || o.prev && o.prev.type === EXPRESS && o.type === EXPRESS && (/^[\.\[]/.test(o.text) || /\.$/.test(o.prev.text)));
1149
1191
  else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
1150
1192
  if (autospace) result.push(" ");
1151
1193
  }
@@ -1380,6 +1422,7 @@ module.exports = {
1380
1422
  /* 256 */SCOPED,
1381
1423
  /* 512 */LABEL,
1382
1424
  /*1024 */PROPERTY,
1425
+ /*2048 */ELEMENT,
1383
1426
  number_reg,
1384
1427
  equal_reg,
1385
1428
  skipAssignment,
@@ -3,17 +3,18 @@ var createNamelist = require("./namelist");
3
3
  var Html = require("./Html");
4
4
  var Javascript = require("./Javascript");
5
5
  const {
6
- /*-1 */COMMENT,
7
- /* 0 */SPACE,
8
- /* 1 */STRAP,
9
- /* 2 */STAMP,
10
- /* 3 */VALUE,
11
- /* 4 */QUOTED,
12
- /* 5 */PIECE,
13
- /* 6 */EXPRESS,
14
- /* 7 */SCOPED,
15
- /* 8 */LABEL,
16
- /* 9 */PROPERTY,
6
+ /* 1 */COMMENT,
7
+ /* 2 */SPACE,
8
+ /* 4 */STRAP,
9
+ /* 8 */STAMP,
10
+ /* 16 */VALUE,
11
+ /* 32 */QUOTED,
12
+ /* 64 */PIECE,
13
+ /* 128 */EXPRESS,
14
+ /* 256 */SCOPED,
15
+ /* 512 */LABEL,
16
+ /* 1024 */PROPERTY,
17
+ /* 2048 */ELEMENT,
17
18
  skipSentenceQueue,
18
19
  rename,
19
20
  relink,
@@ -65,6 +66,7 @@ class Code extends Array {
65
66
  SCOPED = SCOPED
66
67
  LABEL = LABEL
67
68
  PROPERTY = PROPERTY
69
+ ELEMENT = ELEMENT
68
70
  pressed = false
69
71
  _scoped = null;
70
72
  helpcode = false;
@@ -1,7 +1,7 @@
1
1
  var fs = require("fs");
2
2
  var path = require("path");
3
3
  var esprima// = require("../esprima/index");
4
- // var typescript = require("../typescript/index");
4
+ var typescript// = require("../typescript/index");
5
5
  var console = require("../reptile/colored_console");
6
6
  var scanner = require("./scanner2");
7
7
  var data //= fs.readFileSync(path.join(__dirname, "../typescript/index.js")).toString();
@@ -98,11 +98,39 @@ function testJsx2() {
98
98
  function testJsx3() {
99
99
  var m = scanner(`return <a></b></c>`);
100
100
  }
101
- function testJsxOnlyHtml() {
102
- var m = scanner(`<!-- angular 1.x -->
103
- <component1 ng-bind="expression"><child1></child1></component1>`);
104
- console.log(m.toString());
105
- }
101
+ function testJsxOnlyHtml(html) {
102
+ var m = scanner(html);
103
+ assert(m.toString(), html);
104
+ }
105
+ testJsxOnlyHtml(`<!-- angular 1.x --><component1 ng-bind="expression"><child1></child1></component1>`)
106
+ testJsxOnlyHtml(`<a #c>bdf</a>`);
107
+ testJsxOnlyHtml(`<a #c>b<c></c></a>`);
108
+ testJsxOnlyHtml(`<c b=x>d</c>`);
109
+ testJsxOnlyHtml(`<o/>`);
110
+ testJsxOnlyHtml(`<o>`);
111
+ testJsxOnlyHtml(`</o>`);
112
+ testJsxOnlyHtml(`<a></o>`);
113
+ testJsxOnlyHtml(`<a></a></o>`);
114
+ testJsxOnlyHtml(`<o><a><b></o>`);
115
+ testJsxOnlyHtml(`<o><a><b><c></o>`);
116
+ testJsxOnlyHtml(`<a><b><c>`);
117
+ testJsxOnlyHtml(`<a></b><c>`);
118
+ testJsxOnlyHtml(`<a>{aa}</c>`);
119
+ testJsxOnlyHtml(`<a {aa}>a</c>`);
120
+ testJsxOnlyHtml(`Let's Crypt`);
121
+ testJsxOnlyHtml(`<h><a #c>b</a><c b=x>d</c><d/><e>2px</e></h>`)
122
+ testJsxOnlyHtml(`<a {a}=b></a>`);
123
+ // testJsxOnlyHtml(`<script></script>`);
124
+ testJsxOnlyHtml("<script>a=`<v>${version[0]}</v>`</script>");
125
+ testJsxOnlyHtml(`<script>var menu=[{name:'aa'}]</script>`);
126
+ testJsxOnlyHtml(`<script><v></v>;var menu=[{name:i18n\`aa\`}]</script>`);
127
+ testJsxOnlyHtml(`<component1 ng-if="expression"> </component1>`);
128
+ testJsxOnlyHtml(`render(){
129
+ return <Component1 onClick={expression}> </Component1>
130
+ }`);
131
+ testJsxOnlyHtml(`render(){
132
+ return expression.map((item,index)=><Copoment1></Component1>)
133
+ }`);
106
134
  function testSpaceLess() {
107
135
  var m = scanner(`if(n<0)return'_f("'+t+'")('+e+")"`);
108
136
  console.log(m.toString());
@@ -3,11 +3,16 @@
3
3
  padding: 10px 20px;
4
4
  border-radius: 3px;
5
5
  display: inline-block;
6
- background: #333;
6
+ background: #2c2c2c;
7
7
  color: #d4d4d4;
8
+ font-family: Consolas, "Courier New", monospace;
8
9
  vertical-align: top;
9
10
  }
10
11
 
12
+ stamp {
13
+ color: #808080;
14
+ }
15
+
11
16
  strap,
12
17
  value {
13
18
  color: #569cd6;
@@ -92,7 +97,7 @@
92
97
  predefs["module.exports"] = true;
93
98
  predefs.Promise = true;
94
99
  [Boolean, Number, String, Function, Object, Array, Date, RegExp, Error].forEach(p => predefs[p.name] = true);
95
- var { STRAP, SCOPED, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE } = c;
100
+ var { STRAP, SCOPED, ELEMENT, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE } = c;
96
101
  var deep = 0;
97
102
  var setcolor = function (o) {
98
103
  var text = o.text;
@@ -102,17 +107,30 @@
102
107
  o.text = `<label>${o.text}</label>`;
103
108
  break;
104
109
  case QUOTED:
105
- case PIECE:
106
- if (!o.length) {
107
- if (/^\//.test(o.text)) {
108
- o.text = `<regexp>${encode(o.text)}</regexp>`;
109
- }
110
- else o.text = `<text>${encode(o.text)}</text>`;
110
+ if (o.length || !o.text) {
111
+ o.forEach(setcolor);
112
+ o.entry = "<text>" + o.entry;
113
+ o.leave = o.leave + "</text>";
111
114
  break;
112
115
  }
116
+ case PIECE:
117
+ if (o.queue && o.queue.tag) {
118
+ o.text = encode(o.text);
119
+ }
120
+ else if (/^\//.test(o.text)) {
121
+ o.text = `<regexp>${encode(o.text)}</regexp>`;
122
+ }
123
+ else o.text = `<text>${encode(o.text)}</text>`;
124
+ break;
125
+ break;
126
+ case ELEMENT:
127
+ if (o.attributes) o.attributes.forEach(setcolor);
128
+ if (o.tag_entry) o.tag_entry = `<stamp>${encode(o.tag_entry)}</stamp>`;
129
+ if (o.tag_leave) o.tag_leave = `<stamp>${encode(o.tag_leave)}</stamp>`;
130
+ if (o.entry) o.entry = `<stamp>${encode(o.entry)}</stamp>`;
131
+ if (o.leave) o.leave = `<stamp>${encode(o.leave)}</stamp>`;
132
+ o.tag = `<label>${o.tag}</label>`;
113
133
  o.forEach(setcolor);
114
- o.entry = "<text>" + o.entry;
115
- o.leave = o.leave + "</text>";
116
134
  break;
117
135
  case SCOPED:
118
136
  deep++;
@@ -154,8 +172,8 @@
154
172
  break;
155
173
  case STAMP:
156
174
  if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === c.STRAP) o.text = `<strap>${encode(o.text)}</strap>`;
157
- else if (!/^[<\/>]+$/.test(o.text));
158
- else o.text = `<stamp>${encode(o.text)}</stamp>`;
175
+ // else if (!/^[<\/>]+$/.test(o.text));
176
+ // else o.text = `<stamp>${encode(o.text)}</stamp>`;
159
177
  break;
160
178
  case COMMENT:
161
179
  o.text = `<comment>${encode(o.text)}</comment>`;
@@ -194,9 +212,9 @@
194
212
  codecolor(code);
195
213
  backEach(scoped.richNodes, n => {
196
214
  if (n.isScript) {
197
- var js = compile$scanner2(n.innerText);
215
+ var js = compile$scanner2(compile$common.createString(n));
198
216
  codecolor(js);
199
- code.splice(n.innerStart, n.innerEnd - n.innerStart, { text: js.toString() });
217
+ n.splice(0, n.length, ...js);
200
218
  }
201
219
  })
202
220
  return code.toString();
@@ -690,6 +690,7 @@ var createPointsFromElements = function (elements, xList, yList) {
690
690
  var y1 = yList[cx - 1];
691
691
  var y2 = yList[cx];
692
692
  var temp = elements.filter(e => e[3] >= y1 && e[4] <= y2);
693
+ if (temp.length === elements.length) throw new Error("遇到不规则布局,无法自动处理!");
693
694
  if (temp.length > 1) {
694
695
  var children = createPointsFromElements(temp, [xList[0], xList[xList.length - 1]], [y1, y2]);
695
696
  if (children.length) {
@@ -710,6 +711,7 @@ var createPointsFromElements = function (elements, xList, yList) {
710
711
  var x1 = xList[cx - 1];
711
712
  var x2 = xList[cx];
712
713
  var temp = elements.filter(e => e[1] >= x1 && e[2] <= x2);
714
+ if (temp.length === elements.length) throw new Error("遇到不规则布局,无法自动处理!");
713
715
  if (temp.length > 1) {
714
716
  var children = createPointsFromElements(temp, [x1, x2], [yList[0], yList[yList.length - 1]]);
715
717
  if (children.length) xList.splice(cx, 0, children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.3.15",
3
+ "version": "4.4.0",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {