efront 4.28.0 → 4.28.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.
@@ -759,6 +759,7 @@ var removeExport = function (c, i, code) {
759
759
  }
760
760
  for (var exp of allexports) {
761
761
  splice(code, i, 0, ...exp);
762
+ i += exp.length;
762
763
  }
763
764
  if (!allexports.length) code.exportEmpty = true;
764
765
  return;
@@ -931,10 +932,9 @@ Javascript.prototype.fix = function (code) {
931
932
  e.text = 'exports.' + e.text;
932
933
  exports.push(e);
933
934
  var tack = e.tack;
934
- var u = used[tack];
935
- if (u[0].kind === 'const') e.kind = 'const';
936
- removeFromList(u, e);
937
- if (!used[tack].length) {
935
+ var ud = used[tack];
936
+ removeFromList(ud, e);
937
+ if (!ud.length) {
938
938
  delete used[tack];
939
939
  delete envs[tack];
940
940
  }
@@ -1,6 +1,6 @@
1
1
  var isConst = a => a.kind === 'const';
2
2
  var autoiota = require("./autoiota");
3
- var autoenum = require("./autoenum");
3
+ var removeFromList = require("../basic/removeFromList");
4
4
  var scanner2 = require("./scanner2");
5
5
  var strings = require("../basic/strings");
6
6
  var split = require("../basic/$split");
@@ -69,20 +69,22 @@ var findConsts = function (text) {
69
69
  return vmap;
70
70
  };
71
71
  var setEnvDefinedConsts = function (used, k, v) {
72
- for (var a of used[k]) {
72
+ var uk = used[k];
73
+ for (var a of uk) {
73
74
  var t = a.text;
74
75
  var dots = /^\.+/.exec(t);
75
76
  if (dots) t = t.slice(dots[0].length);
76
77
  t = t.slice(a.tack.length);
77
78
  var comment = { type: COMMENT, text: `/*${k}*/` };
78
- // if (t) {
79
- // insertBefore(a, comment, { type: EXPRESS, text: t });
80
- // }
81
- // else {
82
- // insertBefore(a, comment);
83
- // }
84
- // a.type = v.type;
85
- // a.text = v.text;
79
+ if (t) {
80
+ insertBefore(a, comment, { type: EXPRESS, text: t });
81
+ }
82
+ else {
83
+ insertBefore(a, comment);
84
+ }
85
+ removeFromList(uk, a);
86
+ a.type = v.type;
87
+ a.text = v.text;
86
88
  }
87
89
  };
88
90
  var setMapDefinedConsts = function (u, m) {
@@ -106,7 +108,9 @@ var getOnlyString = function (q) {
106
108
  return t;
107
109
  };
108
110
  var getCopy = function (o) {
109
- return { type: o.type, text: o.text };
111
+ var a = { type: o.type, text: o.text };
112
+ if (o.isdigit) a.isdigit = true;
113
+ return a;
110
114
  }
111
115
 
112
116
  var setRequiredConsts = function (code, fullpath, commap) {
@@ -116,6 +120,7 @@ var setRequiredConsts = function (code, fullpath, commap) {
116
120
  var upath = split(url);
117
121
  var requires = code.used.require;
118
122
  if (!requires) return code;
123
+ var used = code.used;
119
124
  for (var r of requires) {
120
125
  var q = r.next;
121
126
  if (q?.type !== SCOPED || q.entry !== '(') continue;
@@ -162,7 +167,16 @@ var setRequiredConsts = function (code, fullpath, commap) {
162
167
  if (/[\.\[]/.test(t)) break a;
163
168
  if (!(t in consts)) break a;
164
169
  remove(o, e);
165
- collected.push(o, { type: STAMP, text: '=' }, getCopy(consts[t]), { type: STAMP, text: ',' });
170
+ o.kind = 'const';
171
+ var eq = { type: STAMP, text: '=' };
172
+ o.equal = eq;
173
+ o.type = EXPRESS;
174
+ delete o.short;
175
+ collected.push(o, eq, getCopy(consts[t]), { type: STAMP, text: ',' });
176
+ var name = o.origin || o.tack;
177
+ var u = used[name];
178
+ removeFromList(u, o);
179
+ u.unshift(o);
166
180
  }
167
181
  if (e?.type === STAMP && e.text === ',') e = e.next;
168
182
  o = e;
@@ -172,19 +186,25 @@ var setRequiredConsts = function (code, fullpath, commap) {
172
186
  }
173
187
  return code;
174
188
  }
175
- var autoConst = function (code, fullpath) {
189
+ var autoConst = function (code, fullpath, ignoreImported) {
176
190
  var vmap = this?.["&"];
177
- var { envs, used } = code;
178
- if (!vmap) return setRequiredConsts(code, fullpath, this);
191
+ var { envs, used, envs } = code;
192
+ if (!vmap) {
193
+ if (!ignoreImported) return setRequiredConsts(code, fullpath, this);
194
+ return code;
195
+ }
179
196
  var p = path.dirname(fullpath);
180
197
  var mp = vmap[p];
181
- if (!mp) return setRequiredConsts(code, fullpath, this);
198
+ if (!mp) {
199
+ if (!ignoreImported) return setRequiredConsts(code, fullpath, this);
200
+ return code;
201
+ }
182
202
  for (var k in envs) {
183
203
  if (k === 'require') {
184
- setRequiredConsts(code, fullpath, this);
204
+ if (!ignoreImported) setRequiredConsts(code, fullpath, this);
185
205
  continue;
186
206
  }
187
- if (k in mp) setEnvDefinedConsts(used, k, mp[k]);
207
+ if (k in mp) setEnvDefinedConsts(used, k, mp[k]), delete envs[k];
188
208
  }
189
209
  return code;
190
210
  };
@@ -1,4 +1,4 @@
1
- var { skipAssignment, snapSentenceHead, snapExpressFoot, EXPRESS, SPACE, SCOPED, QUOTED, VALUE, STRAP, STAMP, number_reg, createString } = require("./common");
1
+ var { skipAssignment, snapSentenceHead, snapExpressFoot, pickAssignment, EXPRESS, SPACE, SCOPED, QUOTED, VALUE, STRAP, STAMP, number_reg, createString } = require("./common");
2
2
  var strings = require("../basic/strings");
3
3
 
4
4
  var createRefId = function (o) {
@@ -59,6 +59,8 @@ var ignore = Symbol("ignore");
59
59
  var maplist = function (u) {
60
60
  var map = Object.create(null);
61
61
  for (var o of u) {
62
+ if (o.maped) continue;
63
+ o.maped = true;
62
64
  var r = createRefId(o);
63
65
  if (!map[r]) {
64
66
  map[r] = [];
@@ -1,4 +1,4 @@
1
- var { skipAssignment, createString, createScoped, relink, STRAP, STAMP, SCOPED, EXPRESS, VALUE, SPACE, COMMENT } = require("./common");
1
+ var { skipAssignment, createString, createScoped, splice, relink, STRAP, STAMP, SCOPED, EXPRESS, VALUE, SPACE, COMMENT } = require("./common");
2
2
  var backEach = require("../basic/backEach");
3
3
  var scanner2 = require("./scanner2");
4
4
 
@@ -6,7 +6,7 @@ var removeNew = function (a, ai) {
6
6
  var p = a.prev;
7
7
  if (p && p.type === STRAP && p.text === 'new') {
8
8
  ai = a.queue.lastIndexOf(p, ai);
9
- a.queue.splice(ai, 1);
9
+ splice(a.queue, ai, 1);
10
10
  }
11
11
  return ai;
12
12
  };
@@ -60,6 +60,7 @@ var assignIota = function (v) {
60
60
  ppmap.forEach((ppm, i) => {
61
61
  if (!ppm) return;
62
62
  var eq = { type: STAMP, text: '=' };
63
+ ppm[0].equal = eq;
63
64
  if (vmap[i]) res.push(...ppm, eq, ...vmap[i]);
64
65
  else if (ppval[i]) res.push(...ppm, eq, ...ppval[i]);
65
66
  else res.push(...ppm);
@@ -68,8 +69,7 @@ var assignIota = function (v) {
68
69
  res.pop();
69
70
  var ppi = p.queue.indexOf(pp);
70
71
  var vi = p.queue.indexOf(v, ppi);
71
- p.queue.splice(ppi, vi - ppi + 1, ...res);
72
- relink(p.queue);
72
+ splice(p.queue, ppi, vi - ppi + 1, ...res);
73
73
  }
74
74
  var arrayFillMap = function (a, i, as) {
75
75
  if (a.text !== 'Array' || !a.next) return;
@@ -89,20 +89,17 @@ var arrayFillMap = function (a, i, as) {
89
89
  var ni = a.queue.indexOf(n);
90
90
  var nnni = a.queue.indexOf(nnn, ni);
91
91
  if (!f) {
92
- a.queue.splice(n + 1, nnni - ni);
93
- relink(a.queue);
92
+ splice(a.queue, n + 1, nnni - ni);
94
93
  return;
95
94
  }
96
- a.queue.splice(ni, nnni - ni);
95
+ splice(a.queue, ni, nnni - ni);
97
96
  nnn.unshift({ type: STAMP, text: ',' });
98
97
  nnn.unshift.apply(nnn, n);
99
98
  a.text = "ArrayFill";
100
- as.splice(i, 1);
99
+ splice(as, i, 1);
101
100
  if (!this.envs.ArrayFill) this.envs.ArrayFill = true;
102
101
  if (!this.used.ArrayFill) this.used.ArrayFill = [];
103
102
  this.used.ArrayFill.push(a);
104
- relink(nnn);
105
- relink(a.queue);
106
103
  return;
107
104
  }
108
105
  var ai = a.queue.indexOf(a);
@@ -0,0 +1,14 @@
1
+ export const [
2
+ /* 1 */COMMENT,
3
+ /* 2 */SPACE,
4
+ /* 4 */STRAP,
5
+ /* 8 */STAMP,
6
+ /* 16 */VALUE,
7
+ /* 32 */QUOTED,
8
+ /* 64 */PIECE,
9
+ /* 128 */EXPRESS,
10
+ /* 256 */SCOPED,
11
+ /* 512 */LABEL,
12
+ /*1024 */PROPERTY,
13
+ /*2048 */ELEMENT,
14
+ ] = new Array(20).fill(0).map((_, a) => 1 << a);
@@ -0,0 +1 @@
1
+ console.log(SPACE, COMMENT);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.28.0",
3
+ "version": "4.28.1",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {