efront 4.28.2 → 4.28.3

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,20 +1,23 @@
1
- - zh-CN: 不启用
2
- en: Disable
1
+ - zh-CN: 路径$1中发现冲突常量$2
2
+ en: Conflict constant $2 found in path $1
3
3
 
4
- - zh-CN: 禁用
5
- en: Disable
4
+ - zh-CN: 英文
5
+ en: English
6
6
 
7
- - zh-CN: 无法在当前浏览器操作!
8
- en: Cannot operate in the current browser!
7
+ - zh-CN: 英语
8
+ en: English
9
9
 
10
- - zh-CN: 无法在当前浏览器操作!
11
- en: Cannot operate in the current browser!
10
+ - zh-CN: 中文繁体
11
+ en: Traditional Chinese
12
12
 
13
- - zh-CN: 确定
14
- en: Confirm
13
+ - zh-CN: 繁体中文
14
+ en: Traditional Chinese
15
15
 
16
- - zh-CN: 确认
17
- en: Confirm
16
+ - zh-CN: 返回
17
+ en: Return
18
+
19
+ - zh-CN: 返回
20
+ en: Back
18
21
 
19
22
  - zh-CN: "参数异常: $1"
20
23
  en: "Parameter exception: $1"
@@ -22,23 +25,23 @@
22
25
  - zh-CN: 参数异常:$1
23
26
  en: "Parameter exception: $1"
24
27
 
25
- - zh-CN: 返回
26
- en: Return
28
+ - zh-CN: 确定
29
+ en: Confirm
27
30
 
28
- - zh-CN: 返回
29
- en: Back
31
+ - zh-CN: 确认
32
+ en: Confirm
30
33
 
31
- - zh-CN: 中文繁体
32
- en: Traditional Chinese
34
+ - zh-CN: 无法在当前浏览器操作!
35
+ en: Cannot operate in the current browser!
33
36
 
34
- - zh-CN: 繁体中文
35
- en: Traditional Chinese
37
+ - zh-CN: 无法在当前浏览器操作!
38
+ en: Cannot operate in the current browser!
36
39
 
37
- - zh-CN: 英文
38
- en: English
40
+ - zh-CN: 不启用
41
+ en: Disable
39
42
 
40
- - zh-CN: 英语
41
- en: English
43
+ - zh-CN: 禁用
44
+ en: Disable
42
45
 
43
46
  - zh-CN: 无法打开媒体设备
44
47
  en: Unable to open media device
@@ -52,9 +52,7 @@ var getAssignedConst = function (a, used) {
52
52
  return nn;
53
53
 
54
54
  }
55
- var findConsts = function (text) {
56
- var code = scanner2(text);
57
- code.fix();
55
+ var findConsts = function (code) {
58
56
  var consts = getExported(code);
59
57
  if (!consts) return;
60
58
  autoiota(code);
@@ -82,20 +80,54 @@ var setEnvDefinedConsts = function (used, k, v) {
82
80
  else {
83
81
  insertBefore(a, comment);
84
82
  }
85
- removeFromList(uk, a);
86
83
  a.type = v.type;
87
84
  a.text = v.text;
88
85
  }
89
86
  };
90
- var setMapDefinedConsts = function (u, m) {
91
-
87
+ var setMapDefinedConsts = function (used, k, consts) {
88
+ var u = used[k];
89
+ if (!u) return;
90
+ for (var o of u) {
91
+ var exp = pickAssignment(o);
92
+ var e = exp[exp.length - 1];
93
+ if (!isSimpleEqual(exp, o)) continue;
94
+ if (e !== o) {
95
+ if (e.prev !== o) continue;
96
+ if (o.text !== k) continue;
97
+ var t = null;
98
+ switch (e.type) {
99
+ default: continue;
100
+ case EXPRESS:
101
+ t = e.text;
102
+ t = t.replace(/^\./, '');
103
+ if (/[\.\[]/.test(t)) continue;
104
+ break;
105
+ case SCOPED:
106
+ if (e.entry !== "[" || e.first !== e.last) continue;
107
+ var t = getOnlyString(e);
108
+ break;
109
+ }
110
+ if (!t || !(t in consts)) continue;
111
+ var c = consts[t];
112
+ o.type = c.type;
113
+ o.text = c.text;
114
+ if (c.isdigit) o.isdigit = true;
115
+ remove(e);
116
+ continue;
117
+ }
118
+ set1Equal(exp, consts, used);
119
+ }
92
120
  };
93
121
  var getMaped = require("./getMaped");
94
122
  var maped = Object.create(null);
95
- var loadConsts = function (fullpath) {
123
+ var loadConsts = function (fullpath, commap) {
96
124
  if (fullpath in maped) return maped[fullpath];
125
+ maped[fullpath] = null;
97
126
  var data = fs.readFileSync(fullpath);
98
- var consts = findConsts(String(data));
127
+ var code = scanner2(String(data));
128
+ code.fix();
129
+ autoConst.call(commap, code, fullpath);
130
+ var consts = findConsts(code);
99
131
  maped[fullpath] = consts;
100
132
  return consts;
101
133
  };
@@ -113,11 +145,43 @@ var getCopy = function (o) {
113
145
  return a;
114
146
  }
115
147
 
116
- var setRequiredConsts = function (code, fullpath, commap) {
117
- var mmap = commap["?"]
118
- if (!mmap) return code;
119
- var url = mmap[fullpath];
120
- var upath = split(url);
148
+ var set1Equal = function (exp, consts, used) {
149
+ var f = exp[0];
150
+ if (f.type === SCOPED && f.entry === "{") {
151
+ var o = f.first;
152
+ var collected = [];
153
+ while (o) {
154
+ var exp = pickArgument(o);
155
+ var e = exp[exp.length - 1].next;
156
+ if (exp.length === 1) a: {
157
+ var t = o.text;
158
+ if (/[\.\[]/.test(t)) break a;
159
+ if (!(t in consts)) break a;
160
+ remove(o, e);
161
+ o.kind = 'const';
162
+ var eq = { type: STAMP, text: '=' };
163
+ o.equal = eq;
164
+ o.type = EXPRESS;
165
+ delete o.short;
166
+ collected.push(o, eq, getCopy(consts[t]), { type: STAMP, text: ',' });
167
+ var name = o.origin || o.tack;
168
+ var u = used[name];
169
+ removeFromList(u, o);
170
+ u.unshift(o);
171
+ }
172
+ if (e?.type === STAMP && e.text === ',') e = e.next;
173
+ o = e;
174
+ }
175
+ insertBefore(f, ...collected);
176
+ }
177
+ };
178
+ var isSimpleEqual = function (exp, o) {
179
+ var f = exp[0];
180
+ if (!f) return false;
181
+ var eq = f.equal;
182
+ return eq === f.next && eq?.next === o;
183
+ }
184
+ var setRequiredConsts = function (code, upath, commap) {
121
185
  var requires = code.used.require;
122
186
  if (!requires) return code;
123
187
  var used = code.used;
@@ -128,9 +192,10 @@ var setRequiredConsts = function (code, fullpath, commap) {
128
192
  if (!t) continue;
129
193
  var p = getMaped(upath, commap, t);
130
194
  if (!p) continue;
131
- var consts = loadConsts(p);
195
+ var consts = loadConsts(p, commap);
132
196
  if (!consts) continue;
133
197
  var exp = pickAssignment(r);
198
+ if (!isSimpleEqual(exp, r)) continue;
134
199
  var e = exp[exp.length - 1];
135
200
  if (e !== q) {
136
201
  if (e.prev !== q) continue;
@@ -153,60 +218,44 @@ var setRequiredConsts = function (code, fullpath, commap) {
153
218
  }
154
219
  var f = exp[0];
155
220
  if (f.type === EXPRESS) {
156
- setMapDefinedConsts(f.text, consts);
221
+ setMapDefinedConsts(used, f.text, consts);
157
222
  continue;
158
223
  }
159
- if (f.type === SCOPED && f.entry === "{") {
160
- var o = f.first;
161
- var collected = [];
162
- while (o) {
163
- var exp = pickArgument(o);
164
- var e = exp[exp.length - 1].next;
165
- if (exp.length === 1) a: {
166
- var t = o.text;
167
- if (/[\.\[]/.test(t)) break a;
168
- if (!(t in consts)) break a;
169
- remove(o, e);
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);
180
- }
181
- if (e?.type === STAMP && e.text === ',') e = e.next;
182
- o = e;
183
- }
184
- insertBefore(f, ...collected);
185
- }
224
+ set1Equal(exp, consts, used);
186
225
  }
187
226
  return code;
188
227
  }
228
+
189
229
  var autoConst = function (code, fullpath, ignoreImported) {
190
230
  var vmap = this?.["&"];
191
231
  var { envs, used, envs } = code;
192
- if (!vmap) {
193
- if (!ignoreImported) return setRequiredConsts(code, fullpath, this);
194
- return code;
195
- }
196
232
  var p = path.dirname(fullpath);
197
- var mp = vmap[p];
198
- if (!mp) {
199
- if (!ignoreImported) return setRequiredConsts(code, fullpath, this);
200
- return code;
233
+ var mp = vmap?.[p];
234
+ if (mp) {
235
+ for (var k in envs) if (k in mp) {
236
+ setEnvDefinedConsts(used, k, mp[k]);
237
+ delete envs[k];
238
+ delete used[k];
239
+ continue;
240
+ }
201
241
  }
242
+ var mmap = this?.["?"];
243
+ if (!mmap) return code;
244
+ var url = mmap[fullpath];
245
+ var upath = split(url);
246
+ if (ignoreImported) return code;
202
247
  for (var k in envs) {
203
248
  if (k === 'require') {
204
- if (!ignoreImported) setRequiredConsts(code, fullpath, this);
249
+ setRequiredConsts(code, upath, this);
205
250
  continue;
206
251
  }
207
- if (k in mp) setEnvDefinedConsts(used, k, mp[k]), delete envs[k];
252
+ p = getMaped(upath, this, k);
253
+ if (!p) continue;
254
+ var consts = loadConsts(p, this);
255
+ if (!consts) continue;
256
+ setMapDefinedConsts(used, k, consts)
208
257
  }
209
258
  return code;
210
259
  };
211
- autoConst.findConsts = findConsts;
260
+ autoConst.loadConsts = loadConsts;
212
261
  module.exports = autoConst;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.28.2",
3
+ "version": "4.28.3",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {