efront 2.42.0 → 2.42.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.
@@ -147,9 +147,13 @@ var getDeclared = function (o, kind) {
147
147
  }
148
148
  }
149
149
  switch (o.type) {
150
+ case PROPERTY:
151
+ if (o.next && o.next.type === STAMP && o.next.text === ":") {
152
+ o = o.next.next;
153
+ continue;
154
+ }
150
155
  case STRAP:
151
156
  case VALUE:
152
- case PROPERTY:
153
157
  case EXPRESS:
154
158
  declared[o.text] = true;
155
159
  o.kind = kind;
@@ -225,6 +229,7 @@ var compress = function (scoped, maped) {
225
229
  for (var cx = 0, dx = keys.length; cx < dx; cx++) {
226
230
  var k = keys[cx];
227
231
  var name = names[cx];
232
+ map[k] = name;
228
233
  var list = used[k];
229
234
  if (list) for (var u of list) {
230
235
  if (!u) continue;
@@ -241,6 +246,7 @@ var compress = function (scoped, maped) {
241
246
  }
242
247
  };
243
248
 
249
+
244
250
  class Program extends Array {
245
251
  COMMENT = COMMENT
246
252
  SPACE = SPACE
@@ -254,6 +260,21 @@ class Program extends Array {
254
260
  LABEL = LABEL
255
261
  PROPERTY = PROPERTY
256
262
  pressed = false
263
+ _scoped = null;
264
+ isExpress() {
265
+ if (!this.first) return false;
266
+ var first = this.first;
267
+ if (first.type === SCOPED) {
268
+ if (first.entry === '{') return false;
269
+ }
270
+ else if (first.type === STRAP) {
271
+ if (!/^(new|void|typeof|delete|class|function|await)/.test(first.text)) return false;
272
+ }
273
+ else if (!~[EXPRESS, STAMP, QUOTED, SCOPED, VALUE].indexOf(first.type)) return false;
274
+ var last = skipAssignment(this.first);
275
+ return this.lastUncomment === last || !last;
276
+ }
277
+
257
278
  toString() {
258
279
  var lasttype;
259
280
  var result = [];
@@ -294,7 +315,7 @@ class Program extends Array {
294
315
  result.push(o.leave);
295
316
  break;
296
317
  default:
297
- if ([STRAP, EXPRESS, VALUE].indexOf(lasttype) >= 0 && [STRAP, EXPRESS, VALUE].indexOf(o.type) >= 0) result.push(" ");
318
+ if ([STRAP, EXPRESS, PROPERTY, VALUE].indexOf(lasttype) >= 0 && [STRAP, EXPRESS, PROPERTY, VALUE].indexOf(o.type) >= 0) result.push(" ");
298
319
  if (o instanceof Object) {
299
320
  // var broker = needBreak(o.prev, o);
300
321
  // if (broker) result.push(broker);
@@ -328,8 +349,20 @@ class Program extends Array {
328
349
  this.forEach(run);
329
350
  return result.join("");
330
351
  }
331
- toScoped() {
332
- var used = Object.create(null); var vars = Object.create(null), lets = vars; var scoped = [];
352
+ get envs() {
353
+ return this.scoped.envs;
354
+ }
355
+ get vars() {
356
+ return this.scoped.vars;
357
+ }
358
+ get used() {
359
+ return this.scoped.used;
360
+ }
361
+ get scoped() {
362
+ if (this._scoped) return this._scoped;
363
+ var used = Object.create(null); var vars = Object.create(null), lets = vars;
364
+ var scoped = this._scoped = [];
365
+ scoped.code = this;
333
366
  var run = function (o, id) {
334
367
  loop: while (o) {
335
368
  var isCatch = false;
@@ -550,15 +583,23 @@ class Program extends Array {
550
583
  }
551
584
  }
552
585
  scoped.envs = envs;
553
- return scoped;
586
+ return this._scoped;
554
587
  }
555
588
  getUndecleared() {
556
- return this.toScoped().envs;
589
+ return this.envs;
557
590
  }
591
+ // 绕开低版本ie的异常属性
592
+ detour() {
593
+ }
594
+ // 标记要保留的代码
595
+ ahchor() { }
596
+ // 清理无效的代码
597
+ clean() {
598
+ }
599
+ // 压缩
558
600
  press() {
559
601
  this.pressed = true;
560
- var scoped = this.toScoped();
561
- compress(scoped);
602
+ compress(this.scoped);
562
603
  return this;
563
604
  }
564
605
  }
@@ -582,7 +623,7 @@ class Javascript {
582
623
  stamps = "/=+;|:?<>-!~@#%^&*,".split("")
583
624
  value_reg = /^(false|true|null|Infinity|NaN|undefined|arguments|this)$/
584
625
  number_reg = /^[\+\-]?(0x[0-9a-f]+|0b\d+|0o\d+|(\d*\.\d+|\d+\.?)(e[\+\-]?\d+|[mn])?)$/i;
585
- transive = /^(new|void|in|of|typeof|delete|case|return|await|export|default|instanceof|throw|extends|import|from)$/
626
+ transive = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|export|default|instanceof|throw|extends|import|from)$/
586
627
  straps = `if,in,do,as,of
587
628
  var,for,new,try,let
588
629
  else,case,void,with,enum,from
@@ -937,12 +978,17 @@ class Javascript {
937
978
  else if (!queue.lastUncomment) {
938
979
  scope.isObject = queue.inExpress;
939
980
  }
940
- else if (~[STAMP, STRAP].indexOf(queue.lastUncomment.type)) {
941
- if (queue.lastUncomment.type === STAMP && queue.lastUncomment.text === ':') {
981
+ else if (queue.lastUncomment.type === STAMP) {
982
+ if (queue.lastUncomment.text === ':') {
942
983
  scope.isObject = queue.inExpress;
943
984
  }
944
- else if (!/try|do|=>|;|else|catch/i.test(queue.lastUncomment.text)) scope.isObject = true;
985
+ else scope.isObject = !/^(;|\+\+|\-\-|=>)$/.test(queue.lastUncomment.text);
986
+ }
987
+ else if (STRAP === queue.lastUncomment.type) {
988
+ if (queue[queue.length - 1].type === SPACE && queue.lastUncomment.text === 'return');
989
+ else scope.isObject = queue.inExpress;
945
990
  }
991
+ queue.inExpress = scope.isObject;
946
992
  }
947
993
  else {
948
994
  scope.isExpress = queue.inExpress;
@@ -63,7 +63,7 @@ function testVariables() {
63
63
 
64
64
  })
65
65
  }
66
- // testSpeed();
66
+ testSpeed();
67
67
  testVariables();
68
68
  // var typescript = require("../typescript/index");
69
69
  // typescript.transpile(data.toString(), { noEmitHelpers: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "2.42.0",
3
+ "version": "2.42.1",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {