efront 3.36.7 → 3.36.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.
@@ -219,7 +219,8 @@ function parseValue(map) {
219
219
  case "nil":
220
220
  return null;
221
221
  }
222
- return parseNumber(map);
222
+ if (/^[\d\.]/.test(map)) return parseNumber(map);
223
+ return map;
223
224
  }
224
225
 
225
226
  var last_type = '';
@@ -228,7 +229,7 @@ var getComment = function (piece) {
228
229
  for (var cx = 0, dx = piece.length; cx < dx; cx++) {
229
230
  var p = piece[cx];
230
231
  if (!isString(p)) continue;
231
- var a = /^\/\//.exec(p);
232
+ var a = /^(\/\/|;)/.exec(p);
232
233
  if (a) {
233
234
  return piece.splice(cx, piece.length - cx).join(' ').slice(2);
234
235
  }
@@ -329,11 +330,11 @@ function parse(piece) {
329
330
  let [_, t, d] = /^(\w*?)\/?(\d+)$/.exec(type);
330
331
  type = d + 'bit/' + t;
331
332
  }
332
- var sizematch = /^(\-?\d+|\-?\d*\.\d+)([YZEPTGMK]i?b?|bytes?|bits?|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
333
+ var sizematch = /^(\-?\d+|\-?\d*\.\d+)?([YZEPTGMK]i?b?|bytes?|bits?|words?|dword|real[48]|long|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
333
334
  if (sizematch) {
334
- var [size_text, size, unit] = sizematch;
335
- if (unit) {
336
- var ratio = KMGT.indexOf(unit.toUpperCase().charAt(0));
335
+ var [size_text, size = 1, unit, eq] = sizematch;
336
+ if (unit && /^i?b?$/i.test(unit.slice(1))) {
337
+ let ratio = KMGT.indexOf(unit.toUpperCase().charAt(0));
337
338
  size *= Math.pow(1024, ratio + 1);
338
339
  if (ratio >= 0) {
339
340
  unit = unit.slice(1).replace(/^i/, '');
@@ -345,12 +346,19 @@ function parse(piece) {
345
346
  var ratio;
346
347
  switch (unit) {
347
348
  case "long":
349
+ case "qword":
350
+ case "real8":
348
351
  case "double":
349
- if (!size) size = 8;
352
+ ratio = 8;
353
+ break;
354
+ case "dword":
355
+ case "real":
356
+ case "real4":
350
357
  case "float":
351
358
  case "uint":
352
359
  case "int":
353
- if (!size) size = 4;
360
+ ratio = 4;
361
+ break;
354
362
  case "bit":
355
363
  case "utf":
356
364
  case "bool":
@@ -368,12 +376,17 @@ function parse(piece) {
368
376
  ratio = 1;
369
377
  }
370
378
  type = type.slice(size_text.length);
371
- if (/\=/.test(type)) {
372
- var value = type.slice(1, (size * ratio) + 1);
373
- type = type.slice(value.length + 1) || 'flag';
379
+ if (eq === '=') {
380
+ // 只读
381
+ var value = parseValue(type);
382
+ type = "flag";
383
+ }
384
+ else if (/=/.test(type)) {
385
+ [type, value] = type.split("=");
386
+ value = parseValue(value);
374
387
  }
375
388
  if (!type) {
376
- type = size + unit;
389
+ type = (!sizematch[1] ? '' : size) + unit;
377
390
  } else {
378
391
  type = type.replace(/^[\|\:\-\,\/]/, '');
379
392
  }
@@ -387,7 +400,6 @@ function parse(piece) {
387
400
  type = type.slice(1);
388
401
  }
389
402
  if (typeof options === "string" && !/^[\$#]+\d+$/.test(options)) {
390
- console.log(options)
391
403
  options = is(options);
392
404
  var needUnfold = /^\[|\]$/.test(options);
393
405
  options = options.replace(/^\[|\]$/g, '');
@@ -439,7 +439,7 @@ Javascript.prototype.detour = function detour(o, ie) {
439
439
  };
440
440
 
441
441
  var removeImport = function (c, i, code) {
442
- var { used, envs } = code;
442
+ var { used, envs, vars } = code;
443
443
  var [dec, map, o] = getDeclared(c.next);
444
444
  if (dec.length !== 1 || !o) throw new Error("代码结构异常!");
445
445
  if (o.type !== STRAP || o.text !== 'from') throw new Error("缺少from语句");
@@ -484,8 +484,8 @@ var removeImport = function (c, i, code) {
484
484
  used[name].push(u);
485
485
  });
486
486
  delete used[dn];
487
+ delete vars[dn];
487
488
  });
488
-
489
489
  }
490
490
  var u = { type: EXPRESS, text: name };
491
491
  code.splice(i + 1, oi - i - 1, u);
@@ -282,6 +282,7 @@ var createScoped = function (parsed, wash) {
282
282
  var isClass = false;
283
283
  var isAsync = false;
284
284
  var isAster = false;
285
+ var function_obj = null;
285
286
  if (o.type === STAMP && equal_reg.test(o.text)) {
286
287
  var p = snapExpressHead(o.prev);
287
288
  if (!p) {
@@ -424,6 +425,7 @@ var createScoped = function (parsed, wash) {
424
425
  if (o.prev && o.prev.text === 'async') {
425
426
  isAsync = true;
426
427
  }
428
+ function_obj = o;
427
429
  if (o.next.type === STAMP) {
428
430
  isAster = true;
429
431
  o = o.next;
@@ -508,6 +510,7 @@ var createScoped = function (parsed, wash) {
508
510
  scoped.async = isAsync;
509
511
  scoped.isfunc = true;
510
512
  isFunction = true;
513
+ if (function_obj) function_obj.scoped = scoped;
511
514
  funcbody = scoped;
512
515
  } else {
513
516
  vars = _vars;
@@ -6,7 +6,7 @@ var RD = { type: STRAP, text: "@rd" };// if (_) return
6
6
  var RETURN = { type: STRAP, text: "@ret" };// return;
7
7
  var YIELD = { type: STRAP, text: "@yield" };// return;
8
8
  var NEXT = { type: STRAP, text: "@next" };// return;
9
- var _break = function (body, cx, result) {
9
+ var _break = function (body, cx, result, iscontinue) {
10
10
  var label;
11
11
  do {
12
12
  var o = body[++cx];
@@ -15,15 +15,20 @@ var _break = function (body, cx, result) {
15
15
  } while (true);
16
16
  var bx = cx;
17
17
  if (label) {
18
+ var s;
18
19
  for (var cx = labels.length - 1; cx >= 0; cx--) {
19
20
  var b = labels[cx];
20
21
  if (b.type === LABEL && b.text === label) {
21
22
  if (!b.breaks) b.breaks = [];
22
23
  var _b = scanner2(`return[]`);
24
+ if (iscontinue) _b.continue = s, s.continue = true;
23
25
  addresult(result, _b);
24
26
  b.breaks.push(_b);
25
27
  break;
26
28
  }
29
+ else {
30
+ s = b;
31
+ }
27
32
  }
28
33
  }
29
34
  else {
@@ -32,6 +37,7 @@ var _break = function (body, cx, result) {
32
37
  if (b.type !== LABEL) {
33
38
  if (!b.breaks) b.breaks = [];
34
39
  var _b = scanner2(`return[]`);
40
+ if (iscontinue) _b.continue = b, b.continue = true;
35
41
  addresult(result, _b);
36
42
  b.breaks.push(_b);
37
43
  break;
@@ -155,6 +161,7 @@ var _switch = function (body, cx, unblock, result, getname) {
155
161
  };
156
162
  var _for = function (body, cx, unblock, result, tmpname) {
157
163
  var o = body[cx];
164
+ var label = o;
158
165
  o = o.next;
159
166
  var m = o.first;
160
167
  if (m.type === STRAP && /^(let|const|var)$/.test(m.text)) {
@@ -187,6 +194,7 @@ var _for = function (body, cx, unblock, result, tmpname) {
187
194
  relink(result[result.length - 1]);
188
195
  var i = result.length;
189
196
  unblock(block_);
197
+ if (label.continue) label.continue = result.length, result[result.length - 1].cont = true, label.contat = result.length;
190
198
  unblock(block2);
191
199
  result[result.length - 1].push(...scanner2(`;return [${i - result.length},0]`));
192
200
  b[b.length - 1].push(...scanner2(`${result.length - i + 1},0`));
@@ -219,6 +227,7 @@ var getCondition = function (o, unblock, not_) {
219
227
  }
220
228
  var _while = function (body, cx, unblock, result, tmpname) {
221
229
  var o = body[cx];
230
+ o.contat = result.length;
222
231
  o = o.next;
223
232
  while (body[cx] !== o) cx++;
224
233
  var b = scanner2(`if(${getCondition(o, unblock, true)})return []`)
@@ -244,7 +253,7 @@ var pushstep = function (result, step) {
244
253
  relink(step);
245
254
  result.push(step);
246
255
  }
247
- else if (q.ifrt) {
256
+ else if (q.ifrt || q.cont) {
248
257
  result.push(step);
249
258
  }
250
259
  else {
@@ -310,10 +319,12 @@ var addresult = function (result, step) {
310
319
  };
311
320
  var _do = function (body, cx, unblock, result, tmpname) {
312
321
  var o = body[cx];
322
+ var label = o;
313
323
  o = o.next;
314
324
  var i = result.length;
315
325
  unblock(o);
316
326
  o = o.next.next;
327
+ if (label.continue) result[result.length - 1].cont = true, label.contat = result.length;
317
328
  var b = scanner2(`if(${getCondition(o, unblock)})return [${i - result.length},0];return [1,0]`);
318
329
  addresult(result, b);
319
330
  while (body[cx] !== o) cx++;
@@ -451,7 +462,7 @@ var ternary = function (body, getname, ret) {
451
462
  addresult(res, scanner2(`if(${getCondition(b, function (b) {
452
463
  addresult(res, _express(b));
453
464
  return res[res.length - 1];
454
- })})return [1,0];return [${c.length + 1},0]`));
465
+ })})return [1,0]`));
455
466
  res.push(...c);
456
467
  res.push(...d);
457
468
  }
@@ -540,6 +551,7 @@ var _express = function (body, getname, ret) {
540
551
  }
541
552
  }
542
553
  var b = body.slice(bx, cx);
554
+ var needname = false;
543
555
  if (cache.length) while (cache.length) {
544
556
  var p = cache.pop();
545
557
  if (needcomma(q)) q.push({ type: STAMP, text: ',' });
@@ -550,31 +562,33 @@ var _express = function (body, getname, ret) {
550
562
  q.push.apply(q, t);
551
563
  q.push.apply(q, b);
552
564
  if (isawait) q.push(NEXT);
565
+ needname = true;
553
566
  b = [{ type: EXPRESS, text: getname(nameindex) }];
554
567
  }
555
568
  else if (ax !== 1) {
556
569
  if (ret && b.length || ax > 1) {
557
570
  q.push(...scanner2(`${getname(nameindex)}=`));
558
571
  q.push(...b);
572
+ needname = true;
559
573
  }
560
574
  else {
561
575
  q.push(...b);
562
576
  }
563
577
  }
564
- q.name = getname(nameindex);
578
+ if (needname) q.name = getname(nameindex);
565
579
  if (ax === 1) {
566
580
  if (q.length) q.push({ type: STAMP, text: ';' });
567
581
  q.push(exps[0], { type: STAMP, text: "=" });
568
582
  q.push(...b);
569
583
  q.name = exps[0].text;
570
- exps[0].set = getname(nameindex);
584
+ if (evals.length) exps[0].set = getname(nameindex);
571
585
  exps.shift();
572
586
  }
573
587
  if (ax > 1) {
574
588
  while (ax > 0) {
575
589
  q.push({ type: STAMP, text: ';' });
576
590
  var [e] = exps.splice(ax - 1, 1);
577
- e.set = getname(nameindex + 1);
591
+ if (evals.length) e.set = getname(nameindex + 1);
578
592
  q.push(e);
579
593
  q.push(...scanner2(`=${getname(nameindex)}`))
580
594
  ax--;
@@ -608,6 +622,10 @@ var getblock = function (body, cx) {
608
622
  return body.slice(ax, cx);
609
623
  };
610
624
  var labels = [];
625
+ var scopes = [];
626
+ var isbreak = function (o) {
627
+ return o.type === STRAP && /^(break|return|continue|yield)$/.test(o.text);
628
+ };
611
629
 
612
630
  function toqueue(body, getname, ret = false) {
613
631
  var retn = false;
@@ -617,18 +635,27 @@ function toqueue(body, getname, ret = false) {
617
635
  addresult(result, re);
618
636
  }
619
637
  var uniftop = function () {
620
- for (var cx = 2, dx = iftop.length; cx < dx; cx += 2) {
638
+ for (var cx = 3, dx = iftop.length; cx < dx; cx += 3) {
621
639
  var findex = iftop[cx];
640
+ var r = iftop[cx + 1];
622
641
  var p = result[findex - 1];
623
- p.pop();
624
- p.push(...scanner2(`[${result.length + 1 - findex},0]`));
625
- relink(p);
642
+ if (!r) {
643
+ p.pop();
644
+ p.push(...scanner2(`[${result.length + 1 - findex},0]`));
645
+ relink(p);
646
+ }
626
647
  }
627
- for (var cx = 0, dx = iftop.length - 1; cx < dx;) {
648
+ for (var cx = 0, dx = iftop.length - 2; cx < dx;) {
628
649
  var findex = iftop[cx++];
629
650
  var f = result[findex];
651
+ var r = iftop[cx++];
630
652
  var n = iftop[cx++];
631
- if (f) {
653
+ if (r) {
654
+ var c = scanner2(`if(${n})`);
655
+ f.unshift.apply(f, c);
656
+ relink(f);
657
+ }
658
+ else if (f) {
632
659
  var c = scanner2(`if(${n})return [${iftop.length > cx ? iftop[cx] - findex : result.length - findex},0];`);
633
660
  f.unshift.apply(f, c);
634
661
  relink(f);
@@ -660,7 +687,7 @@ function toqueue(body, getname, ret = false) {
660
687
  var r = result[cx];
661
688
  if (r[r.length - 1] === end) { break }
662
689
  }
663
- end.push({ type: VALUE, text: result.length - cx }, { type: STAMP, text: "," }, { type: VALUE, text: "0" });
690
+ end.push({ type: VALUE, text: b.contat - cx ? b.continue : result.length - cx }, { type: STAMP, text: "," }, { type: VALUE, text: "0" });
664
691
  relink(end);
665
692
  }
666
693
  }
@@ -675,23 +702,20 @@ function toqueue(body, getname, ret = false) {
675
702
  if (!o) break;
676
703
  while (labels.length) {
677
704
  var e = labels[labels.length - 1];
678
- if (e.type !== LABEL) {
679
- break;
680
- }
681
- if (e.keep) {
682
- e.keep = false;
683
- break;
684
- }
705
+ if (e.type !== LABEL && !iftop) break;
706
+ if (scopes.lastIndexOf(e.scope) >= 0) break;
685
707
  poplabel();
686
708
  }
687
709
 
688
710
  if (o.type === LABEL) {
689
- o.keep = true;
711
+ o.scope = scopes[scopes.length - 1];
690
712
  labels.push(o);
691
713
  continue;
692
714
  }
693
715
  if (o.type === SCOPED && o.entry === '{' && !o.isExpress) {
716
+ scopes.push(o);
694
717
  var b = toqueue(o, getname, false);
718
+ scopes.pop();
695
719
  // addresult(result, b);
696
720
  result.push.apply(result, b);
697
721
  cx++;
@@ -722,8 +746,8 @@ function toqueue(body, getname, ret = false) {
722
746
  bx = cx + 1;
723
747
  break a;
724
748
  }
725
- if (o.text === 'break') {
726
- cx = _break(body, cx, result);
749
+ if (/^(break|continue)$/.test(o.text)) {
750
+ cx = _break(body, cx, result, o.text === 'continue');
727
751
  bx = cx + 1;
728
752
  continue;
729
753
  };
@@ -768,23 +792,25 @@ function toqueue(body, getname, ret = false) {
768
792
  var elseif = false;
769
793
  if (o.text === 'else') {
770
794
  ifpatch();
771
- iftop.push(result.length);
772
795
  while (body[cx] !== o.next) cx++;
773
796
  o = o.next;
797
+ var isbr = isbreak(o);
798
+ iftop.push(result.length, isbr);
774
799
  elseif = true;
775
800
  }
776
801
  if (o.text === 'if') {
777
802
  while (body[cx] !== o.next) cx++;
778
803
  o = o.next;
779
- var n = getCondition(o, unblock, true);
804
+ var isbr = isbreak(o.next);
805
+ var n = getCondition(o, unblock, !isbr);
806
+ o = o.next;
780
807
  if (!elseif) {
781
808
  if (iftop) uniftop();
782
- iftop = [result.length, n];
809
+ iftop = [result.length, isbr, n];
783
810
  }
784
811
  else {
785
812
  iftop.push(n);
786
813
  }
787
- o = o.next;
788
814
  elseif = true;
789
815
  }
790
816
  if (elseif) {
@@ -823,7 +849,13 @@ var ret_ = '';
823
849
  module.exports = function (body, newname, ret) {
824
850
  if (ret) ret = isString(ret) ? ret : newname();
825
851
  var ret0 = ret_;
826
- ret_ = ret;
852
+ var ret1 = null;
853
+ if (ret) ret_ = isString(ret) ? ret : {
854
+ toString() {
855
+ if (ret1) return ret1;
856
+ return newname();
857
+ }
858
+ };
827
859
  var tmpnames = [];
828
860
  var p = 0;
829
861
  var getname = function (i) {
@@ -16,7 +16,7 @@ test('a * a + b * c', "_ = a * a, _0 = b * c, _ + _0");
16
16
  test('a * a + b * c * c ** d', "_ = a * a, _0 = b * c, _1 = c ** d, _0 = _0 * _1, _ + _0");
17
17
  test('a * a || b * c * c ** d', "_ = a * a @re _ = b * c, _0 = c ** d, _ * _0");
18
18
  test('a * a || b * c || c * d', "_ = a * a @re _ = b * c @re c * d");
19
- test('a?b:c', "if (a) return [1, 0]; _ = b; return [2, 0]; _ = c;");
19
+ test('a?b:c', "if (a) return [1, 0]; _ = b; return [2, 0]; _ = c");
20
20
  test('a * a && b * c * c ** d', "_ = a * a @rz _ = b * c, _0 = c ** d, _ * _0");
21
21
  test('a = 1 + 2', "_ = 1 + 2, a = _", true);
22
22
  test('a = b', "a = b", true);
@@ -1,6 +1,5 @@
1
1
  function Main(dataid, datapath, titleid) {
2
2
  var _titlebar = titlebar(" ");
3
- state.with(_titlebar);
4
3
  var page = createVboxWithState(state);
5
4
  page.initialStyle = 'margin-left:100%';
6
5
  page.innerHTML = buildScroll;
@@ -339,7 +339,7 @@ function prepare(pgpath, ok) {
339
339
  };
340
340
  state.titlebar = function () {
341
341
  var realTitleBar = titlebar.apply(null, arguments);
342
- if (!realTitleBar.parentNode) state.with(realTitleBar);
342
+ if (!realTitleBar.parentNode) _with_elements.push(realTitleBar);
343
343
  return realTitleBar;
344
344
  };
345
345
  var roles = res || null;
@@ -397,7 +397,7 @@ function create(pagepath, args, from, needroles) {
397
397
  }
398
398
  else if (isFunction(pagepath)) {
399
399
  var pg = pagepath;
400
- var { with: _with_elements, state = {}, onback: _pageback_listener, roles } = pg;
400
+ var { with: _with_elements = [], state = {}, onback: _pageback_listener, roles } = pg;
401
401
  }
402
402
  if (!checkroles(user.roles, roles) || !checkroles(user.roles, needroles)) {
403
403
  // 检查权限
@@ -406,14 +406,15 @@ function create(pagepath, args, from, needroles) {
406
406
  }
407
407
  return alert(i18n`没有权限!`, 0);
408
408
  }
409
- _with_elements = [].concat(_with_elements);
409
+ var _with_length = _with_elements.length;
410
410
  state.onback = function (handler) {
411
411
  _pageback_listener = handler;
412
412
  };
413
413
  var _page = pg.call(state, args, from);
414
414
  if (undefined === args || null === args) args = {};
415
415
  if (_page) {
416
- if (_with_elements.length) _page.with = _with_elements.concat(_page.with || []);
416
+ if (_with_length) _page.with = _with_elements.concat(_page.with || []);
417
+ _with_elements.splice(_with_length, _with_elements.length - _with_length);
417
418
  if (args.initialStyle) _page.initialStyle = args.initialStyle;
418
419
  if (args.holdupStyle) _page.holdupStyle = args.holdupStyle;
419
420
  if (_page.initialStyle && !_page.holdupStyle) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.36.7",
3
+ "version": "3.36.9",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {