efront 3.3.5 → 3.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.
@@ -1,6 +1,6 @@
1
1
  var createNamelist = require("./namelist");
2
2
 
3
- const [
3
+ const {
4
4
  /*-1 */COMMENT,
5
5
  /* 0 */SPACE,
6
6
  /* 1 */STRAP,
@@ -12,104 +12,12 @@ const [
12
12
  /* 7 */SCOPED,
13
13
  /* 8 */LABEL,
14
14
  /* 9 */PROPERTY,
15
- ] = new Array(20).fill(0).map((_, a) => a - 1);
15
+ number_reg,
16
+ skipAssignment,
17
+ createScoped,
18
+ } = require("./common");
16
19
 
17
- var saveTo = function (used, k, o) {
18
- if (!(used[k] instanceof Array)) used[k] = [];
19
- used[k].push(o);
20
- };
21
20
 
22
- var mergeTo = function (used, used0) {
23
- for (var k in used0) {
24
- var v = used0[k];
25
- for (var s of v) saveTo(used, k, s);
26
- }
27
- };
28
- var skipAssignment = function (o) {
29
- var needpunc = false;
30
- var o0 = o;
31
- loop: while (o) switch (o.type) {
32
- case STAMP:
33
- switch (o.text) {
34
- case ",":
35
- case ";":
36
- break loop;
37
- case "++":
38
- case "--":
39
- o = o.next;
40
- break;
41
- case "!":
42
- case "~":
43
- case "+":
44
- case "-":
45
- o = o.next;
46
- needpunc = false;
47
- break;
48
- default:
49
- if (/^[!~\+\-]+$/.test(o.text)) {
50
- needpunc = false;
51
- o = o.next;
52
- break;
53
- }
54
- if (!needpunc) break loop;
55
- needpunc = false;
56
- o = o.next;
57
- }
58
- break;
59
- case SCOPED:
60
- if (needpunc && o.entry === "{") break loop;
61
- o = o.next;
62
- needpunc = true;
63
- break;
64
- case EXPRESS:
65
- if (/^\.|\.$/.test(o.text)) {
66
- o = o.next;
67
- break;
68
- }
69
- else if (/^\[/.test(o.text)) {
70
- needpunc = true;
71
- o = o.next;
72
- break;
73
- }
74
- case VALUE:
75
- case QUOTED:
76
- if (needpunc) break loop;
77
- needpunc = true;
78
- o = o.next;
79
- break;
80
- case STRAP:
81
- if (needpunc) {
82
- if (!/^(in|instanceof)$/.test(o.text)) break loop;
83
- o = o.next;
84
- needpunc = false;
85
- }
86
- else if (o.text === "class") {
87
- o = o.next;
88
- while (o && !o.isClass) o = o.next;
89
- while (o && o.isClass) o = o.next;
90
- needpunc = true;
91
- break;
92
- }
93
- else if (o.text === "function") {
94
- o = o.next;
95
- if (o && o.type === EXPRESS) o = o.next;
96
- if (o) o = o.next;
97
- if (o) o = o.next;
98
- needpunc = true;
99
- break;
100
- }
101
- else {
102
- o = o.next;
103
- needpunc = false;
104
- }
105
- break;
106
- default:
107
- console.log(o);
108
- throw new Error('代码结构异常!');
109
- o = o.next;
110
- }
111
- return o;
112
- };
113
21
 
114
22
  var needBreak = function (prev, next) {
115
23
  if (!prev || !next) return;
@@ -139,78 +47,6 @@ var needBreak = function (prev, next) {
139
47
  }
140
48
  };
141
49
 
142
- var getDeclared = function (o, kind) {
143
- var declared = Object.create(null), used = Object.create(null); var skiped = [];
144
- loop: while (o) {
145
- while (o && o.type === STAMP && o.text === ',') o = o.next;
146
- if (!o) break;
147
- if (o.isprop) {
148
- skiped.push(o);
149
- if (o.next && o.next.type === STAMP && o.next.text === ":") {
150
- o = o.next;
151
- o = o.next;
152
- }
153
- }
154
- switch (o.type) {
155
- case PROPERTY:
156
- if (o.next && o.next.type === STAMP && o.next.text === ":") {
157
- o = o.next.next;
158
- continue;
159
- }
160
- case STRAP:
161
- case VALUE:
162
- case EXPRESS:
163
- var n = o.text.replace(/^\.\.\.|\.\.\.$/g, '');
164
- declared[n] = true;
165
- o.kind = kind;
166
- saveTo(used, n, o);
167
- o = o.next;
168
- break;
169
- case SCOPED:
170
- var [d, u, _, s] = getDeclared(o.first, kind);
171
- while (s.length) skiped.push.apply(skiped, s.splice(0, 1024));
172
- mergeTo(used, u);
173
- Object.assign(declared, d);
174
- o = o.next;
175
- break;
176
-
177
- default:
178
- console.log(o);
179
- throw new Error("代码结构异常");
180
- }
181
- if (!o) break;
182
- switch (o.type) {
183
- case STRAP:
184
- if (/^(in|of)$/.test(o.text)) {
185
- o = o.next;
186
- var o0 = skipAssignment(o);
187
- do {
188
- skiped.push(o);
189
- o = o.next;
190
- } while (o !== o0);
191
- o = o0;
192
- break;
193
- }
194
- break loop;
195
- case STAMP:
196
- if (o.text === "=") {
197
- o = o.next;
198
- var o0 = skipAssignment(o);
199
- do {
200
- skiped.push(o);
201
- o = o.next;
202
- } while (o !== o0);
203
- o = o0;
204
- break;
205
- }
206
- break;
207
- }
208
- if (!o) break;
209
- if (o.type !== STAMP) break;
210
- if (o.text !== ',') break;
211
- }
212
- return [declared, used, o, skiped];
213
- }
214
50
 
215
51
  var compress = function (scoped, maped) {
216
52
  var { lets, vars, used } = scoped;
@@ -443,240 +279,7 @@ class Program extends Array {
443
279
  }
444
280
  get scoped() {
445
281
  if (this._scoped) return this._scoped;
446
- var used = Object.create(null); var vars = Object.create(null), lets = vars;
447
- var scoped = this._scoped = [];
448
- var run = function (o, id) {
449
- loop: while (o) {
450
- var isCatch = false;
451
- var isFunction = false;
452
- var isScope = false;
453
- var isArrow = false;
454
- switch (o.type) {
455
- case QUOTED:
456
- if (o.length) {
457
- run(o.first);
458
- }
459
- break;
460
- case STAMP:
461
- break;
462
- case PROPERTY:
463
- if (o.next) {
464
- if (o.next.type !== STAMP || o.next.text !== ",") break;
465
- }
466
- case VALUE:
467
- if (program.number_reg.test(o.text)) break;
468
- case EXPRESS:
469
- if (o.prev && o.prev.type === EXPRESS) {
470
- if (/\.$/.test(o.prev.text)) break;
471
- }
472
- var u = o.text.replace(/^([^\.\[]*)[\s\S]*$/, '$1');
473
- if (!u) break;
474
- if (o.next && o.next.type === STAMP && o.next.text === "=>") {
475
- isScope = true;
476
- isArrow = true;
477
- }
478
- else {
479
- saveTo(used, u, o);
480
- }
481
- break;
482
- case LABEL:
483
- var name = o.text;
484
- name = name.slice(0, name.length - 1);
485
- vars[name] = true;
486
- o.kind = "label";
487
- saveTo(used, name, o);
488
- break;
489
-
490
- case STRAP:
491
- var s = o.text;
492
- switch (s) {
493
- case "var":
494
- case "import":
495
- var m = vars;
496
- case "let":
497
- case "const":
498
- m = m || lets;
499
- var [declared, used0, o0, skiped] = getDeclared(o.next, s);
500
- while (skiped.length) {
501
- var o1 = run(skiped[0], 0);
502
- let sindex = skiped.indexOf(o1);
503
- if (sindex < 0) break;
504
- skiped.splice(0, sindex + 1);
505
- }
506
- o = o0;
507
- mergeTo(used, used0);
508
- Object.assign(m, declared);
509
- continue loop;
510
- case "function":
511
- isFunction = true;
512
- case "catch":
513
- isCatch = true;
514
- case "class":
515
- if (!o.isExpress) {
516
- o = o.next;
517
-
518
- if (o.type === EXPRESS) {
519
- vars[o.text] = true;
520
- o.kind = isFunction ? 'function' : 'class';
521
- saveTo(used, o.text, o);
522
-
523
- o = o.next;
524
- }
525
- }
526
- isScope = true;
527
- break;
528
-
529
- }
530
- break;
531
- case SCOPED:
532
- if (o.entry === "(") {
533
- if (o.next && o.next.type === STAMP && o.next.text === "=>"
534
- || o.prev && (o.prev.type === PROPERTY || o.prev.isprop)) {
535
- isArrow = true;
536
- isScope = true;
537
- }
538
- else {
539
- run(o.first);
540
- }
541
- }
542
- else if (o.entry === "{") {
543
- isScope = true;
544
- }
545
- else {
546
- run(o.first);
547
- }
548
- break;
549
- }
550
- if (isScope) {
551
- var _used = used;
552
- var _lets = lets;
553
- var _vars = vars;
554
- var _scoped = scoped;
555
- used = Object.create(null);
556
- lets = Object.create(null);
557
- vars = Object.create(null);
558
- scoped = [];
559
- var isExpress = o.isExpress;
560
-
561
- if (isFunction || isArrow) {
562
- scoped.used = used;
563
- scoped.vars = vars;
564
- lets = vars;
565
- if (isFunction) vars.this = true, vars.arguments = true;
566
- isFunction = true;
567
- } else {
568
- vars = _vars;
569
- scoped.lets = lets;
570
- scoped.used = used;
571
- }
572
- if (isArrow);
573
- else if (o.isExpress && o.type !== SCOPED) {
574
- o = o.next;
575
- if (o.type === EXPRESS) {
576
- vars[o.text] = true;
577
- o.kind = isFunction ? 'function' : 'class';
578
- saveTo(used, o.text, o);
579
- o = o.next;
580
- }
581
- }
582
- if (!isFunction) while (o.type !== SCOPED) {
583
- // if (o.next && o.next.type === STAMP && o.next.text === "=>") break;
584
- o = run(o, 0);
585
- o = o.next;
586
- if (!o) break loop;
587
- }
588
-
589
- if (o.entry === "(") {
590
- o.isExpress = isExpress;
591
- if (isFunction || isCatch) {
592
- var [declared, used0, o0, skiped] = getDeclared(o.first, 'argument');
593
- mergeTo(used, used0);
594
- while (skiped.length) {
595
- var o1 = run(skiped[0], 0);
596
- var sindex = skiped.indexOf(o1);
597
- if (sindex < 0) break;
598
- skiped.splice(0, sindex + 1);
599
- }
600
- Object.assign(isCatch ? lets : vars, declared);
601
- }
602
- else {
603
- run(o.first);
604
- }
605
- o = o.next;
606
- if (!o) break;
607
- if (o.type === STAMP && o.text === "=>") o = o.next;
608
- }
609
- else if (isArrow) {
610
- vars[o.text] = true;
611
- o.kind = 'argument';
612
- saveTo(used, o.text, o);
613
- o = o.next.next;
614
- }
615
- if (!o) break;
616
- if (o.type === SCOPED && o.entry === "{") {
617
- o.isExpress = isExpress;
618
- run(o.first);
619
- }
620
- else {
621
- do {
622
- if (o.type === STAMP && o.text === ";") break;
623
- o = run(o, 0);
624
- var next = o.next;
625
- if (!next) break;
626
- var e = o;
627
- if (o.type === STAMP && /^(\+\+|\-\-)$/.test(o.text) || ~[VALUE, QUOTED, SCOPED].indexOf(o.type) || EXPRESS === o.type && !/\.$/.test(o.text)) {
628
- if (~[VALUE, QUOTED, PROPERTY, LABEL].indexOf(next.type)) break;
629
- if (EXPRESS === next.type && !/^\./.test(next.text)) break;
630
- if (next.type === SCOPED && next.entry === "{") break;
631
- }
632
- o = next;
633
- } while (o);
634
- }
635
- var map = isFunction ? vars : lets;
636
- var keepscope = false;
637
- for (var k in map) {
638
- keepscope = true;
639
- break;
640
- }
641
- if (keepscope) {
642
- for (var k in used) {
643
- if (!(k in map)) {
644
- for (var u of used[k]) {
645
- saveTo(_used, k, u);
646
- }
647
- }
648
- }
649
- _scoped.push(scoped);
650
- }
651
- else {
652
- mergeTo(_used, used);
653
- if (scoped.length) _scoped.push(scoped);
654
- }
655
- if (vars.this) {
656
- delete vars.this;
657
- delete vars.arguments;
658
- }
659
- used = _used;
660
- lets = _lets;
661
- vars = _vars;
662
- scoped = _scoped;
663
- }
664
- if (id >= 0) break;
665
- if (o) o = o.next;
666
- }
667
- return o;
668
- };
669
- run(this.first);
670
- scoped.used = used;
671
- scoped.vars = vars;
672
- var envs = Object.create(null);
673
- for (var u in used) {
674
- if (!(u in vars)) {
675
- if (!/^(true|false|null|this|arguments)$/.test(u)) envs[u] = true;
676
- }
677
- }
678
- scoped.envs = envs;
679
- return this._scoped;
282
+ return this._scoped = createScoped(this);
680
283
  }
681
284
  getUndecleared() {
682
285
  return this.envs;
@@ -717,7 +320,7 @@ class Javascript {
717
320
  ]
718
321
  stamps = "/=+;|:?<>-!~@#%^&*,".split("")
719
322
  value_reg = /^(false|true|null|Infinity|NaN|undefined|arguments|this|eval)$/
720
- number_reg = /^[\+\-]?(0x[0-9a-f]+|0b\d+|0o\d+|(\d*\.\d+|\d+\.?)(e[\+\-]?\d+|[mn])?)$/i;
323
+ number_reg = number_reg;
721
324
  transive = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|export|default|instanceof|throw|extends|import|from)$/
722
325
  straps = `if,in,do,as,of
723
326
  var,for,new,try,let,get,set
@@ -7,7 +7,7 @@ src.split("").forEach((s, i) => map[s] = i);
7
7
  function encode62(string) {
8
8
  string = String(string)
9
9
  string = string.length + string + "2017-08-19";
10
- var buff = Buffer.from(src);
10
+ var buff = src.split('');
11
11
  for (var cx = 0, dx = buff.length + src.length, sl = string.length, cl = buff.length; cx < dx; cx++) {
12
12
  var s1 = string.charCodeAt(cx % sl) % cl;
13
13
  var s2 = cx % cl;
@@ -15,7 +15,7 @@ function encode62(string) {
15
15
  buff[s1] = buff[s2];
16
16
  buff[s2] = btemp;
17
17
  }
18
- return buff.toString();
18
+ return buff.join('');
19
19
  };
20
20
 
21
21
 
@@ -35,9 +35,23 @@ Object.assign(encode62, {
35
35
  },
36
36
  timeencode(string) {
37
37
  var { time_delta } = this;
38
- var time_stamp = +new Date();
38
+ var time_free = time_delta / 6 | 0;
39
+ var time_stamp = +new Date() - time_free;
39
40
  var time_rest = time_stamp % time_delta;
40
- return this.encode62(string, time_stamp.toString(36)) + time_rest.toString(36).padStart(time_delta.toString(36).length, '0');
41
+ var time_rest_str = time_rest.toString(36);
42
+ var time_delta_str = time_delta.toString(36);
43
+ return this.encode62(string, time_stamp.toString(36)) + repeat("0", time_delta_str.length - time_rest_str.length) + time_rest_str;
44
+ },
45
+ timeupdate(string) {
46
+ var { time_delta } = this;
47
+ var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
48
+ var time_start = parseInt((new Date() - parseInt(time_rest, 36)) / time_delta) * time_delta;
49
+ var time_stamp = time_start + parseInt(time_rest, 36);
50
+ if (time_stamp + (time_delta >> 1) > +new Date()) {
51
+ return string;
52
+ } else {
53
+ return this.timeencode(this.timedecode(string));
54
+ }
41
55
  },
42
56
  encode62(data, sign) {
43
57
  if (!sign) return data;
@@ -53,15 +67,6 @@ Object.assign(encode62, {
53
67
  });
54
68
  return result;
55
69
  },
56
- encode(data, sign) {
57
- if (!sign) return data;
58
- var result = Buffer.from(data);
59
- sign = Buffer.from(sign);
60
- for (var cx = 0, dx = data.length; cx < dx; cx++) {
61
- result[cx] = result[cx] ^ sign[cx % sign.length];
62
- }
63
- return result;
64
- },
65
70
  decode(data, sign) {
66
71
  if (!sign) return data;
67
72
  var result = Buffer.from(data);
@@ -75,7 +80,7 @@ Object.assign(encode62, {
75
80
  return encode62(string);
76
81
  },
77
82
  genb() {
78
- return encode62(Date.now() + "" + Math.random());
83
+ return encode62(Date.now() * Math.random() + "" + Math.random().toString(36) + Math.random().toString(36).toUpperCase());
79
84
  },
80
85
  huan(x, y) {
81
86
  return x.split("").map(s => y[map[s]]).join("");
@@ -90,24 +95,9 @@ Object.assign(encode62, {
90
95
  y.split("").forEach((a, j) => y_map[a] = j);
91
96
  return z.split("").map(c => src[y_map[c]]).join("");
92
97
  },
93
- ab2c(a, b) {
94
- return this.huan(a, b);
95
- },
96
- ba2d(a, b) {
97
- return this.huan(b, a);
98
- },
99
- ca2b(c, a) {
100
- return this.yuan(c, a);
101
- },
102
- cb2a(c, b) {
103
- return this.suan(c, b);
104
- },
105
- da2b(d, a) {
106
- return this.suan(d, a);
107
- },
108
- db2a(d, b) {
109
- return this.yuan(d, b);
110
- }
111
98
  });
112
-
99
+ encode62.ab2c = encode62.ba2d = encode62.huan;
100
+ encode62.db2a = encode62.ca2b = encode62.yuan;
101
+ encode62.da2b = encode62.cb2a = encode62.suan;
102
+ encode62.encode = encode62.decode;
113
103
  encode62.decode62 = encode62.encode62;
@@ -32,7 +32,8 @@ describe("encode62_test", function () {
32
32
  c = encode62.ab2c(a, b);
33
33
  });
34
34
  it("ba2d", function () {
35
- d = encode62.ba2d(a, b);
35
+ // 注意,参数顺序已变更
36
+ d = encode62.ba2d(b, a);
36
37
  });
37
38
  it("ca2b", function () {
38
39
  expect(encode62.ca2b(c, a)).to.be.eq(b);
@@ -1,9 +1,13 @@
1
1
  var styles = {
2
- log: "#2a53cd",
3
- info: "#228B22",
4
- warn: "#dd6a16",
5
- error: "#dc352e"
2
+ blue: "#2a53cd",
3
+ green: "#228B22",
4
+ orange: "#dd6a16",
5
+ red: "#dc352e"
6
6
  };
7
+ styles.success = styles.pass = styles.green;
8
+ styles.info = styles.blue;
9
+ styles.error = styles.danger = styles.red;
10
+ styles.warn = styles.orange;
7
11
  var alerts = [];
8
12
  var clean = Cleanup(alerts);
9
13
  var build = function () {
@@ -323,7 +323,7 @@ function addDirect(a) {
323
323
  if (typeof a === 'string' || a instanceof RegExp) cors_hosts.push(a);
324
324
  }
325
325
  function notCross(domain) {
326
- if (location_host === domain.slice(0, location_host.length)) return true;
326
+ if (location_host === domain.slice(0, location_host.length) || !/^https?\:\/\/|^s?\/\//.test(domain)) return true;
327
327
  for (var cx = 0, dx = cors_hosts.length; cx < dx; cx++) {
328
328
  var host = cors_hosts[cx];
329
329
  if (host instanceof RegExp) {
@@ -166,6 +166,7 @@ function cssTargetStyleSheet(stylesheet, innerCss) {
166
166
  * @param {|string} oValue
167
167
  */
168
168
  var css = function (target, oStyle, oValue) {
169
+ if (!oStyle) return;
169
170
  if (isElement(target)) {
170
171
  if (/^style$/i.test(target.tagName)) {
171
172
  cssTargetStyleSheet(target, oStyle, oValue);
@@ -269,9 +269,9 @@ function parseConfig(api) {
269
269
  });
270
270
  return '';
271
271
  });
272
- url.replace(/[\?\#][\s\S]*$/, '').replace(/\:\w+/g, function (p) {
272
+ url.replace(/[\?\#][\s\S]*$/, '').replace(/([\:\\]\:|\:\w+)/g, function (p) {
273
273
  p = p.slice(1);
274
- if (!required[p]) {
274
+ if (!required[p] && p !== ':') {
275
275
  required.push(p);
276
276
  required[p] = p;
277
277
  }
@@ -495,8 +495,9 @@ var privates = {
495
495
  var coinmethod = method.slice(0, spliterIndex).toLowerCase();
496
496
  var realmethod = coinmethod.replace(/\W+$/g, '');
497
497
  var rest = [];
498
- var uri = url.replace(/#[\s\S]*$/, "").replace(/\:[a-z\_][\w]*/gi, function (d) {
498
+ var uri = url.replace(/#[\s\S]*$/, "").replace(/[\\\:]\:|\:[a-z\_][\w]*/gi, function (d) {
499
499
  d = d.slice(1);
500
+ if (d === ":") return d;
500
501
  rest.push(d);
501
502
  return seekResponse(params, d) || '';
502
503
  });
@@ -912,6 +913,10 @@ var data = {
912
913
  localStorage.setItem(sourceDataId, JSAM.stringify(dataSourceMap));
913
914
  }
914
915
  },
916
+ getSource(sourceid) {
917
+ if (sourceid) return dataSourceMap[sourceid];
918
+ return dataSourceMap;
919
+ },
915
920
  clearSource() {
916
921
  localStorage.removeItem(sourceDataId);
917
922
  sessionStorage.removeItem(sourceDataId);
@@ -5,6 +5,19 @@ var encode62 = {
5
5
  src,
6
6
  map,
7
7
  time_delta: parseInt("zzzzz", 36),
8
+ geta(string) {
9
+ string = String(string)
10
+ string = string.length + string + "2017-08-19";
11
+ var buff = src.split('');
12
+ for (var cx = 0, dx = buff.length + src.length, sl = string.length, cl = buff.length; cx < dx; cx++) {
13
+ var s1 = string.charCodeAt(cx % sl) % cl;
14
+ var s2 = cx % cl;
15
+ var btemp = buff[s1];
16
+ buff[s1] = buff[s2];
17
+ buff[s2] = btemp;
18
+ }
19
+ return buff.join('');
20
+ },
8
21
  timedecode(string) {
9
22
  var { time_delta } = this;
10
23
  var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
@@ -1,8 +1,10 @@
1
1
  <div class="head">
2
2
  <span ng-bind=field.name></span>
3
+ <span class="required" ng-if="field.required">*</span>
3
4
  </div>
4
5
  <div class="body">
5
6
  <model _data=data _field=field></model>
7
+ <span class="error" ng-bind="error"></span>
6
8
  </div>
7
9
  <div class="foot" ng-if="field.msg">
8
10
  <span ng-bind=field.msg></span>