efront 4.9.4 → 4.10.1

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.
Files changed (42) hide show
  1. package/coms/basic/Item.js +6 -1
  2. package/coms/basic/Tree.js +15 -1
  3. package/coms/basic/shallowClone.js +6 -2
  4. package/coms/basic_/JSON.js +1 -5
  5. package/coms/basic_/JSON_test.js +7 -1
  6. package/coms/compile/Html_test.js +12 -1
  7. package/coms/compile/Javascript.js +94 -58
  8. package/coms/compile/Javascript_test.js +70 -2
  9. package/coms/compile/Program.js +187 -53
  10. package/coms/compile/audit.js +1 -1
  11. package/coms/compile/autoenum.js +1 -1
  12. package/coms/compile/cloneNode.js +2 -0
  13. package/coms/compile/common.js +74 -43
  14. package/coms/compile/downLevel.js +6 -6
  15. package/coms/compile/downLevel_test.js +5 -1
  16. package/coms/compile/formatcode.js +1 -1
  17. package/coms/compile/powermap.js +1 -1
  18. package/coms/compile/unstruct.js +2 -2
  19. package/coms/docs/codecolor.js +47 -17
  20. package/coms/docs/codetext.xht +83 -12
  21. package/coms/frame/route.js +15 -15
  22. package/coms/zimoli/XMLHttpRequest.js +2 -5
  23. package/coms/zimoli/alert.js +2 -2
  24. package/coms/zimoli/confirm.js +1 -1
  25. package/coms/zimoli/createEvent.js +6 -7
  26. package/coms/zimoli/dispatch.js +8 -4
  27. package/coms/zimoli/getScreenPosition.js +6 -6
  28. package/coms/zimoli/grid.js +14 -10
  29. package/coms/zimoli/list.js +13 -1
  30. package/coms/zimoli/on.js +2 -1
  31. package/coms/zimoli/picture.js +1 -1
  32. package/coms/zimoli/render.js +1 -1
  33. package/coms/zimoli/slider.js +4 -0
  34. package/coms/zimoli/tree.js +133 -43
  35. package/coms/zimoli/tree.less +2 -1
  36. package/coms/zimoli/vbox.js +5 -5
  37. package/coms/zimoli/vbox.less +3 -1
  38. package/coms/zimoli/zimoli.js +1 -1
  39. package/data/packexe-setup.sfx +0 -0
  40. package/docs//347/273/204/344/273/266.xht +4 -4
  41. package/package.json +1 -1
  42. package/public/efront.js +1 -1
@@ -91,7 +91,7 @@ class Program {
91
91
  ["`", "`", /\\[\s\S]/, ["${", "}"]],
92
92
  ]
93
93
  tags = [
94
- [["<", "</"], /\/?>/, /\\[\s\S]/, "'", '"', "<!--", ["${", "}"]]
94
+ [["<", "</"], /\/?>/, /\\[\s\S]|\=\>/, "'", '"', "<!--", ["${", "}"]]
95
95
  ];
96
96
  scriptTags = [];
97
97
  ignoreTags = ["STYLE", "SCRIPT"];
@@ -112,8 +112,9 @@ class Program {
112
112
  transive_reg = /^(new|void|case|break|continue|return|throw|extends|import)$/
113
113
  straps = "if,for".split(',');
114
114
  forceend_reg = /^(return|break|continue)$/;
115
- classstrap_reg = /^(class)$/;
116
- extends_reg = /^(extends)$/;
115
+ classstrap_reg = /^(class|function|async|interface)$/;
116
+ extends_reg = /^(extends|implements)$/;
117
+ control_reg = /^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/;
117
118
  spaces = spaceDefined;
118
119
  nocase = false
119
120
  keepspace = false;
@@ -150,10 +151,33 @@ class Program {
150
151
  var Code = this.Code;
151
152
  var queue = new Code();
152
153
  queue.type = this.type;
154
+ queue.inExpress = this.inExpress;
155
+ if (this.type === ELEMENT) {
156
+ queue.entry = this.tags[0].tag[0];
157
+ }
153
158
  var origin = queue;
154
159
  var forceend_reg = this.forceend_reg;
155
160
  var program = this;
161
+ var quote_map = this.quote_map;
162
+ var space_reg = this.space_reg;
163
+ var strap_reg = this.strap_reg;
164
+ var stamp_reg = this.stamp_reg;
165
+ var scope_entry = this.scope_entry;
166
+ var express_reg = this.express_reg;
167
+ var value_reg = this.value_reg;
168
+ var extends_reg = this.extends_reg;
169
+ var classstrap_reg = this.classstrap_reg;
170
+ var entry_reg = this.entry_reg;
171
+ var comment_entry = this.comment_entry;
172
+ var rowsOf = m => m.replace(/[^\r\n\u2028\u2029]+/g, ';').replace(/\r\n|\r|\n|\u2028|\u2029/g, ' ').replace(/;/g, '').length;
173
+ var setRows = m => {
174
+ row += rowsOf(m);
175
+ colstart = start + m.length - m.replace(/^[\s\S]*?([^\r\n\u2028\u2029]*)$/, '$1').length - 1;
176
+ };
156
177
  var queue_push = function (scope) {
178
+ if (scope.type & (SPACE | COMMENT | PIECE | QUOTED)) {
179
+ if (scope.text) setRows(scope.text);
180
+ }
157
181
  var last = queue.last;
158
182
  Object.defineProperty(scope, 'queue', { value: queue, enumerable: false, configurable: true });
159
183
  scope.prev = last;
@@ -181,16 +205,10 @@ class Program {
181
205
  }
182
206
  if (!queue.first) queue.first = scope;
183
207
  }
184
- scope.row = row;
185
- scope.col = scope.start - colstart;
186
208
  queue.push(scope);
187
209
  };
188
210
  var row = 1, colstart = -1;
189
211
  var save = (type) => {
190
- if (type & (SPACE | COMMENT | PIECE | QUOTED)) {
191
- row += m.replace(/[^\r\n\u2028\u2029]+/g, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, ' ').length;
192
- colstart = start + m.length - m.replace(/^[\s\S]*?([^\r\n\u2028\u2029]*)$/, '$1').length - 1;
193
- }
194
212
  if (lasttype === STAMP && type === STAMP && !/[,;\:]/.test(m)) {
195
213
  var scope = queue[queue.length - 1];
196
214
  if (/=>$/i.test(scope.text) ||
@@ -210,6 +228,8 @@ class Program {
210
228
  type,
211
229
  start,
212
230
  end,
231
+ row,
232
+ col: start - colstart,
213
233
  isExpress: queue.inExpress,
214
234
  text: m
215
235
  }
@@ -253,6 +273,9 @@ class Program {
253
273
  scope.entry = queue.tag_entry;
254
274
  scope.tag_leave = queue.tag_leave;
255
275
  scope.tag = tag;
276
+ scope.row = row;
277
+ scope.col = scope.start - colstart;
278
+
256
279
  scope.inTag = true;
257
280
  scope.type = ELEMENT;
258
281
  }
@@ -290,11 +313,25 @@ class Program {
290
313
  queue.last = null;
291
314
  return true;
292
315
  };
316
+ var isTypedColon = function (qp) {
317
+ var istype = false;
318
+ if (qp?.type === STAMP && qp.text === ':' && !qp.isExpress) {
319
+ if (qp.istype) return true;
320
+ var qpp = qp.prev;
321
+ if (qpp.type === SCOPED && qpp.entry === '(') {
322
+ var qppp = qpp.prev;
323
+ if (qppp && (qppp.isprop)) {
324
+ istype = true;
325
+ }
326
+ }
327
+ }
328
+ return istype;
329
+ }
293
330
  var closeTag = function () {
294
331
  queue.inTag = false;
295
332
  if (queue.closed) return;
296
333
  if (queue.length) queue.attributes = queue.splice(0, queue.length);
297
- if (/^\//.test(m)) return queue.short = true, queue.closed = true;
334
+ if (/^\//.test(m) || queue.istype) return queue.short = true, queue.closed = true;
298
335
  return false;
299
336
  };
300
337
  var push_quote = function () {
@@ -311,11 +348,35 @@ class Program {
311
348
  var push_parents = function (scope) {
312
349
  scope.queue = queue;
313
350
  scope.prev = queue.last;
351
+ scope.row = row;
352
+ scope.col = match.index - colstart;
314
353
  parents.push(queue);
315
354
  queue = scope;
316
355
  lasttype = null;
317
356
  }
318
357
  var pop_parents = function () {
358
+ if (!parents.length) {
359
+ delete queue.end;
360
+ var last = queue.last;
361
+ if (last) {
362
+ while (queue[queue.length - 1] !== last) {
363
+ queue.pop();
364
+ }
365
+ queue.pop();
366
+ index = queue.last.start;
367
+ queue.last = last.prev;
368
+ }
369
+ else {
370
+ var m = queue.leave;
371
+ index = queue.end - m.length;
372
+ }
373
+ delete queue.start;
374
+ delete queue.end;
375
+ delete queue.leave;
376
+ delete queue.type;
377
+ delete queue.entry;
378
+ return;
379
+ }
319
380
  var scope = queue;
320
381
  queue = parents.pop();
321
382
  queue_push(scope);
@@ -325,19 +386,21 @@ class Program {
325
386
  if (index > start) {
326
387
  var piece = queue[queue.length - 1];
327
388
  if (piece && piece.type === PIECE) {
389
+ row -= rowsOf(piece.text);
328
390
  piece.text = text.slice(piece.start, index);
329
- piece.end = match.index;
391
+ setRows(piece.text);
392
+ piece.end = index;
330
393
  }
331
394
  else {
332
395
  m = text.slice(start, index);
333
- save(PIECE);
396
+ save(space_reg.test(m) ? SPACE : PIECE);
334
397
  }
335
398
  }
336
399
  m = match[0];
337
400
  }
338
401
  loop: while (index < text.length) {
339
- if (queue.type === QUOTED) {
340
- var quote = this.quote_map[queue.entry];
402
+ if (queue.type & (QUOTED | ELEMENT)) {
403
+ var quote = quote_map[queue.entry];
341
404
  var reg = quote.reg;
342
405
  start = index;
343
406
  while (index < text.length) {
@@ -359,12 +422,12 @@ class Program {
359
422
 
360
423
  continue;
361
424
  }
425
+
362
426
  if (quote.end.test(m)) {
363
427
  end = match.index;
364
428
  if (queue.tag) {
365
429
  push_piece();
366
430
  if (!queue.inTag) continue;
367
-
368
431
  if (closeTag() === false) {
369
432
  start = index;
370
433
  queue.tag_leave = m;
@@ -391,6 +454,7 @@ class Program {
391
454
  var scope = [];
392
455
  scope.entry = m;
393
456
  scope.type = QUOTED;
457
+ if (queue.istype) scope.istype = queue.istype;
394
458
  scope.start = index;
395
459
  scope.isExpress = queue.inExpress;
396
460
  push_parents(scope);
@@ -411,15 +475,15 @@ class Program {
411
475
  push_quote();
412
476
  continue loop;
413
477
  }
414
- if (m in this.quote_map) {
415
- if (this.comment_entry.test(m)) {
478
+ if (m in quote_map) {
479
+ if (comment_entry.test(m)) {
416
480
  push_piece();
417
481
  var start = match.index;
418
- var comment = this.quote_map[m];
419
- comment.lastIndex = index;
482
+ var { reg: comment_reg, end: comment_end } = quote_map[m];
483
+ comment_reg.lastIndex = index;
420
484
  do {
421
- var match = comment.reg.exec(text);
422
- } while (match && !comment.end.test(match[0]));
485
+ var match = comment_reg.exec(text);
486
+ } while (match && !comment_end.test(match[0]));
423
487
  if (match) end = index = match.index + match[0].length;
424
488
  m = text.slice(start, index);
425
489
  save(COMMENT);
@@ -439,16 +503,15 @@ class Program {
439
503
  continue;
440
504
  }
441
505
 
442
- var reg = this.entry_reg;
443
- var start = reg.lastIndex = index;
444
- var match = reg.exec(text);
506
+ var start = entry_reg.lastIndex = index;
507
+ var match = entry_reg.exec(text);
445
508
  if (!match) return null;
446
509
  var end = match[0].length + match.index;
447
510
  index = end;
448
511
  var m = match[0];
449
- test: if (this.quote_map.hasOwnProperty(m)) {
512
+ test: if (quote_map.hasOwnProperty(m)) {
450
513
  var last = queue.last;
451
- var quote = this.quote_map[m];
514
+ var quote = quote_map[m];
452
515
  if (queue.tag && quote.tag) {
453
516
  var tagend = end + queue.tag.length
454
517
  var leavem = quote.entry[m];
@@ -460,22 +523,63 @@ class Program {
460
523
  break test;
461
524
  }
462
525
  }
463
- if (this.stamp_reg.test(m) && last) {
464
- if ((VALUE | EXPRESS) & last.type) {
465
- if (queue.type !== ELEMENT) break test;
526
+
527
+ var isTypeTag = false;
528
+ if (queue.istype) {
529
+ isTypeTag = true;
530
+ }
531
+ else if (!last) {
532
+ if (!queue.brace) {
533
+ isTypeTag = isTypedColon(queue.prev);
534
+ }
535
+ }
536
+ else if (stamp_reg.test(m) && last) {
537
+ if (lasttype === STAMP && m === last.text) break test;
538
+ if (last.istype || last.isprop) {
539
+ isTypeTag = true;
540
+ }
541
+ else if ((VALUE | EXPRESS | PROPERTY) & last.type) a: {
542
+ if (queue.classed) {
543
+ isTypeTag = true;
544
+ break a;
545
+ }
466
546
  var lp = last.prev;
467
547
  if (lp) {
468
- if (lp.type === STAMP && lp.text !== ';') break test;
469
- if (lp.type === STRAP && lp.transive) break test;
548
+ if (lp.type === STAMP) {
549
+ if (lp.text === ':') {
550
+ if (isTypedColon(lp)) {
551
+ last.istype = true;
552
+ isTypeTag = true;
553
+ break a;
554
+ }
555
+ }
556
+ break test;
557
+ }
558
+ if (lp.type === STRAP) {
559
+ if (lp.istype) {
560
+ isTypeTag = true;
561
+ break a;
562
+ }
563
+ if (lp.transive) break test;
564
+ }
470
565
  }
566
+ if (queue.type !== ELEMENT) break test;
567
+ }
568
+ else switch (last.type) {
569
+ case QUOTED:
570
+ if (!last.tag) break test;
571
+ break;
572
+ case SCOPED:
573
+ if (queue.inExpress) break test;
574
+ break;
575
+ case STAMP:
576
+ if (/^(\+\+|\-\-)$/.test(last.text)) break test;
577
+ break;
471
578
  }
472
- if (last.type === QUOTED && !last.tag) break test;
473
- if (last.type === SCOPED && queue.inExpress) break test;
474
- if (lasttype === STAMP && m === last.text) break test;
475
- if (last.type === STAMP && /^(\+\+|\-\-)$/.test(last.text)) break test;
476
579
  }
477
580
  var scope = [];
478
- scope.type = this.comment_entry.test(m) ? COMMENT : QUOTED;
581
+ scope.type = comment_entry.test(m) ? COMMENT : QUOTED;
582
+ if (isTypeTag && scope.type === QUOTED) scope.istype = isTypeTag;
479
583
  scope.isExpress = queue.inExpress;
480
584
  scope.start = start;
481
585
  push_parents(scope);
@@ -519,14 +623,14 @@ class Program {
519
623
  continue;
520
624
  }
521
625
  var parent = parents[parents.length - 1];
522
- if (parent && this.quote_map[parent.entry] && queue.leave_map?.[m] === queue.entry) {
626
+ if (parent && quote_map[parent.entry] && queue.leave_map?.[m] === queue.entry) {
523
627
  delete queue.leave_map;
524
628
  queue.end = end;
525
629
  queue.leave = m;
526
630
  pop_parents();
527
631
  continue;
528
632
  }
529
- if (this.space_reg.test(m)) {
633
+ if (space_reg.test(m)) {
530
634
  if (/[\r\n\u2028\u2029]/.test(m)) {
531
635
  var last = queue.last;
532
636
  if (last && last.isend === false) {
@@ -541,8 +645,8 @@ class Program {
541
645
  lasttype = SPACE;
542
646
  continue;
543
647
  }
544
- if (this.strap_reg.test(m)) {
545
- if (!this.classstrap_reg.test(m)) queue.inExpress = this.transive_reg.test(m);
648
+ if (strap_reg.test(m)) {
649
+ if (!classstrap_reg.test(m)) queue.inExpress = this.transive_reg.test(m);
546
650
  else {
547
651
  var last = queue.last;
548
652
  if (!last);
@@ -558,11 +662,20 @@ class Program {
558
662
  }
559
663
  var isdigit = number_reg.exec(m);
560
664
  if (isdigit) {
561
- m = isdigit[0];
562
- index = match.index + m.length;
665
+ var m1 = isdigit[0];
666
+ if (m1.length < m.length) {
667
+ if (m.charAt(m1.length) === ".") {
668
+ m = m1;
669
+ index = match.index + m.length;
670
+ }
671
+ else if (/\.$/.test(m1)) {
672
+ m = m1.slice(0, m1.length - 1);
673
+ index = match.index + m.length;
674
+ }
675
+ }
563
676
  isdigit = true;
564
677
  }
565
- if (this.value_reg.test(m) || isdigit) {
678
+ if (value_reg.test(m) || isdigit) {
566
679
  queue.inExpress = true;
567
680
  if (isdigit && lasttype === STAMP) {
568
681
  var last = queue.last;
@@ -579,15 +692,15 @@ class Program {
579
692
  save(VALUE);
580
693
  continue;
581
694
  }
582
- if (this.express_reg.test(m)) {
695
+ if (express_reg.test(m)) {
583
696
  var last = queue.last;
584
- if (last && last.type === STRAP && this.classstrap_reg.test(last.text));
697
+ if (last && last.type === STRAP && classstrap_reg.test(last.text));
585
698
  else queue.inExpress = true;
586
699
  save(EXPRESS);
587
700
  continue;
588
701
  }
589
702
 
590
- if (this.scope_entry[m]) {
703
+ if (scope_entry[m]) {
591
704
  var scope = [];
592
705
  scope.entry = m;
593
706
  scope.type = SCOPED;
@@ -597,18 +710,25 @@ class Program {
597
710
  var last = queue.last;
598
711
  if (m === "{") {
599
712
  if (!last) {
600
- scope.isObject = queue.inExpress;
713
+ if (queue.istype) scope.isClass = true;
714
+ else scope.isObject = queue.inExpress;
601
715
  }
602
- else if (queue.classed > 0) {
716
+ else if (queue.classed) {
603
717
  if (last.type !== STAMP || last.text !== "=>") {
604
- queue.classed--;
718
+ var classed = queue.classed;
719
+ var clsd = classed.pop();
605
720
  scope.isClass = true;
606
- scope.extend += this.extends_reg.test(last.text);
721
+ if (!classed.length) queue.classed = null;
722
+ scope.istype = clsd === 'interface';
723
+ scope.extend += extends_reg.test(last.text);
607
724
  scope.inExpress = false;
608
725
  }
609
726
  }
610
727
  else if (last.type === STAMP) {
611
- if (last.text === ':') {
728
+ if (last.istype) {
729
+ scope.isClass = true;
730
+ }
731
+ else if (last.text === ':') {
612
732
  scope.isObject = queue.inExpress;
613
733
  }
614
734
  else queue.inExpress = scope.isObject = !/^(;|\+\+|\-\-|=>)$/.test(last.text);
@@ -620,11 +740,16 @@ class Program {
620
740
  if (last.isend);
621
741
  else scope.isObject = queue.inExpress;
622
742
  }
743
+ scope.brace = true;
744
+ scope.isExpress = queue.inExpress;
623
745
  }
624
746
  else {
625
747
  if (!last || (last.type & (SCOPED | STAMP))) queue.inExpress = true;
626
748
  scope.isExpress = queue.inExpress;
627
749
  scope.inExpress = true;
750
+ if (last?.istype && last.type === STAMP) {
751
+ scope.istype = true;
752
+ }
628
753
  }
629
754
  push_parents(scope);
630
755
  continue;
@@ -644,7 +769,7 @@ class Program {
644
769
  continue;
645
770
  }
646
771
  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));
647
- if (this.stamp_reg.test(m)) {
772
+ if (stamp_reg.test(m)) {
648
773
  save(STAMP);
649
774
  }
650
775
 
@@ -664,7 +789,16 @@ class Program {
664
789
  };
665
790
  this.lastIndex = index;
666
791
  if (queue !== origin) {
667
- 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)), "代码异常结束";
792
+ throw console.log(
793
+ createString(origin),
794
+ `\r\n ----- deep: ${parents.length}`,
795
+ `\r\n ---- enrty: ${queue.entry}`,
796
+ `\r\n --- length: ${queue.length}`,
797
+ `\r\n ----- last: ${queue.last ? createString([queue.last]) : createString(queue)}`,
798
+ `\r\n -- parents: ${parents.map(p => `${p.row}:${p.col}-${p.tag || p.text || p.entry} `).join('-)> ')}`,
799
+ `\r\n ----- snap: ${createString([queue]).slice(-200)}`,
800
+ `\r\n ------ end. `
801
+ ), "代码异常结束";
668
802
  }
669
803
  return queue;
670
804
  }
@@ -37,7 +37,7 @@ var hasRupt = function (a) {
37
37
  a = skipAssignment(a);
38
38
  }
39
39
  else if (a.type === SCOPED) {
40
- if (a.entry === "{") {
40
+ if (a.brace) {
41
41
  if (!a.isObject) {
42
42
  if (hasRupt(a)) return true;
43
43
  }
@@ -199,7 +199,7 @@ function enumref(refitem, scoped) {
199
199
  if (q !== scoped.body) {
200
200
  if (q.entry === '(' && q.queue === scoped.body) {
201
201
  var qp = q.prev;
202
- if (qp.type === EXPRESS) qp = qp.prev;
202
+ if (qp?.type === EXPRESS) qp = qp.prev;
203
203
  if (qp && qp.type === STRAP && qp.text === "await") qp = qp.prev;
204
204
  if (qp && qp.type === STRAP && qp.text === 'for') {
205
205
  var f = q.first;
@@ -6,6 +6,8 @@ var cloneNode = function (o) {
6
6
  c.entry = o.entry;
7
7
  c.leave = o.leave;
8
8
  c.type = o.type;
9
+ c.istype = o.istype;
10
+ c.brace = o.brace;
9
11
  c.isExpress = o.isExpress;
10
12
  relink(c);
11
13
  }