efront 4.26.2 → 4.28.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.
@@ -40,6 +40,24 @@
40
40
  - zh-CN: 英语
41
41
  en: English
42
42
 
43
+ - zh-CN: 无法打开媒体设备
44
+ en: Unable to open media device
45
+
46
+ - zh-CN: 通话中
47
+ en: During the call
48
+
49
+ - zh-CN: 无应答
50
+ en: no response
51
+
52
+ - zh-CN: 正在呼叫
53
+ en: Calling in progress
54
+
55
+ - zh-CN: $1天
56
+ en: $1 day
57
+
58
+ - zh-CN: 正在通话中..
59
+ en: In a call
60
+
43
61
  - zh-CN: 大写锁定已打开
44
62
  en: Capitalization lock turned on
45
63
 
@@ -1,13 +1,23 @@
1
- module.exports = function (p) {
1
+ var split = function (reg, p) {
2
2
  var s = [];
3
+ reg.lastIndex = 0;
4
+ var lastIndex = 0;
3
5
  while (p) {
4
- var reg = /[\$\/\\]/g;
5
- reg.lastIndex = 1;
6
+ reg.lastIndex++;
6
7
  var m = reg.exec(p);
7
- var i = m ? m.index : p.length;
8
- s.push(p.slice(0, i));
9
- p = p.slice(i + 1);
8
+ if (!m) {
9
+ s.push(p.slice(lastIndex, p.length));
10
+ break;
11
+ }
12
+ s.push(p.slice(lastIndex, m.index));
13
+ lastIndex = m.index + m.length;
10
14
  }
11
15
  if (m) s.push('');
12
16
  return s;
17
+
18
+ }
19
+ module.exports = function (p) {
20
+ var s = split(/[\\\/]/g, p);
21
+ if (s.length > 1) return s;
22
+ return split(/\$/g, p);
13
23
  }
@@ -839,6 +839,17 @@ var data = {
839
839
  return datas.concat.apply([], datas);
840
840
  }));
841
841
  },
842
+ wait(ref, params, parse) {
843
+ var response = this.from(ref, params, parse);
844
+ var loading = response.loading;
845
+ if (!("timeout" in loading)) {
846
+ loading.then(function () {
847
+ response.loading.timeout = 0;
848
+ });
849
+ }
850
+ loading.timeout = 0;
851
+ return response;
852
+ },
842
853
  from(ref, params, parse) {
843
854
  if (params instanceof Function) {
844
855
  parse = params;
@@ -933,12 +944,14 @@ var data = {
933
944
  asyncInstance(sid, params, parse) {
934
945
  // 不同参数的请求互不影响
935
946
  if (typeof sid !== "string") throw new Error(i18n`serviceId 只能是字符串`);
936
- var p = privates.getApi(sid).then((api) => {
947
+ var p0 = privates.getApi(sid);
948
+ var p = p0.then((api) => {
937
949
  params = privates.pack(sid, params);
938
950
  var p = privates.fromApi(api, params);
939
951
  p.loading = response.loading = p.loading;
940
952
  return p;
941
953
  }, oncatch);
954
+ p.loading = p0;
942
955
  if (isEmpty(params)) p.id = sid;
943
956
  var response = this.createResponse(p, parse);
944
957
  return response;
@@ -7,4 +7,5 @@ function removeFromList(list, item) {
7
7
  cx = list.indexOf(item, cx);
8
8
  }
9
9
  return count;
10
- }
10
+ }
11
+ module.exports = removeFromList;
@@ -1,8 +1,9 @@
1
1
  var KMGT = 'KMGT';
2
2
  "use ./KMGT.txt"
3
- module.exports = function (f) {
3
+ module.exports = function (f, fix) {
4
4
  var log = Math.log(f) / Math.LN2 / 10 | 0;
5
5
  f /= Math.pow(2, log * 10);
6
- f = +f.toFixed(2);
6
+ f = f.toFixed(fix >= 0 ? fix : 2);
7
+ if (!fix) f = +f;
7
8
  return f + KMGT.charAt(log - 1) + "B";
8
9
  };
@@ -63,4 +63,4 @@ function recode(s) {
63
63
  s = encode(s);
64
64
  return s;
65
65
  }
66
- module.exports = { encode, decode, recode, kicode, uncode };
66
+ export { encode, decode, recode, kicode, uncode };
@@ -3,6 +3,8 @@ var strings = require("../basic/strings");
3
3
  var Program = require("./Program");
4
4
  var backEach = require("../basic/backEach");
5
5
  var parseNumber = require('../basic/parseNumber');
6
+ var removeFromList = require("../basic/removeFromList");
7
+ var patchname = require("./patchname");
6
8
  const {
7
9
  /* 1 */COMMENT,
8
10
  /* 2 */SPACE,
@@ -713,6 +715,7 @@ var removeExport = function (c, i, code) {
713
715
  }
714
716
  var o = n.first;
715
717
  var allexports = [];
718
+ var exports = used.exports;
716
719
  while (o) {
717
720
  var name = o, prop = o.text;
718
721
  if (from) {
@@ -734,6 +737,15 @@ var removeExport = function (c, i, code) {
734
737
  o = n && n.next;
735
738
  var exp = scan(`\r\nexports.${prop}=`);
736
739
  exp.push(name);
740
+ var exported = exp.first;
741
+ var u0 = used[name.tack][0];
742
+ var kind = u0.kind;
743
+ exports.push(exported);
744
+ if (kind === "const") {
745
+ exported.tack = 'exports';
746
+ exported.origin = name.tack;
747
+ exported.kind = kind;;
748
+ }
737
749
  name.isExpress = true;
738
750
  allexports.push(exp);
739
751
  }
@@ -743,10 +755,10 @@ var removeExport = function (c, i, code) {
743
755
  i = ni;
744
756
  }
745
757
  else {
746
- code.splice(i, ni - i);
758
+ splice(code, i, ni - i);
747
759
  }
748
760
  for (var exp of allexports) {
749
- code.splice(i, 0, ...exp);
761
+ splice(code, i, 0, ...exp);
750
762
  }
751
763
  if (!allexports.length) code.exportEmpty = true;
752
764
  return;
@@ -771,7 +783,10 @@ var removeExport = function (c, i, code) {
771
783
  }
772
784
  return;
773
785
  }
774
- var [dec, map, o] = getDeclared(n.next, 'export');
786
+ if (n.type === STRAP && n.text === 'async') n = n.next;
787
+ var s = n.next;
788
+ if (s.type === STAMP && s.text === "*") s = s.next;
789
+ var [dec, map, o] = getDeclared(s, 'export');
775
790
  if (/^(class|function)$/.test(n.text)) {
776
791
  var exports = used.exports;
777
792
  if (!exports) {
@@ -806,14 +821,17 @@ var removeExport = function (c, i, code) {
806
821
  }
807
822
  }
808
823
  var oi = code.indexOf(nn, i);
809
- if (!code.exportDecs) {
810
- code.exportDecs = [];
824
+ var exportDecs = code.exportDecs;
825
+ if (!exportDecs) {
826
+ exportDecs = code.exportDecs = [];
811
827
  }
828
+ var kind = n.text;
812
829
  dec.forEach(function rm(d) {
813
830
  if (d instanceof Array) return d.forEach(rm);
814
831
  for (var a of used[d]) {
815
832
  if (a.kind && a.kind !== 'export') continue;
816
- if (!a.export) code.exportDecs.push(a), a.export = true;
833
+ a.kind = kind;
834
+ if (!a.export) exportDecs.push(a), a.export = true;
817
835
  }
818
836
  });
819
837
  dec.forEach(d => {
@@ -903,22 +921,24 @@ Javascript.prototype.fix = function (code) {
903
921
  }
904
922
  if (code.exportDecs) {
905
923
  var exportDecs = code.exportDecs;
906
- delete code.exportDecs;
907
- var exports = code.used.exports;
908
924
  var used = code.used;
925
+ var exports = used.exports;
909
926
  var envs = code.envs;
910
927
  if (!exports) {
911
- exports = code.used.exports = [];
928
+ exports = used.exports = [];
912
929
  }
913
930
  exportDecs.forEach(e => {
914
931
  e.text = 'exports.' + e.text;
915
932
  exports.push(e);
916
- removeFromList(used[e.tack], e);
917
- if (!used[e.tack].length) {
918
- delete used[e.tack];
919
- delete envs[e.tack];
933
+ 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) {
938
+ delete used[tack];
939
+ delete envs[tack];
920
940
  }
921
- e.origin = e.tack;
941
+ e.origin = tack;
922
942
  e.tack = 'exports';
923
943
  if (e.needEqual) {
924
944
  var n = e.next;
@@ -21,6 +21,10 @@ testFix(`import "windows.inc"`, 'require("windows.inc")');
21
21
  testFix(`import "windows.inc";import "abc.inc";`, 'require("windows.inc"); require("abc.inc");');
22
22
  testFix(`import "windows.inc";\r\nimport "abc.inc";`, 'require("windows.inc");\r\nrequire("abc.inc");');
23
23
  testFix(`console.log(import.meta)`, `console.log(import_meta)`);
24
+ testFix(`export async function a(){}`, 'exports.a = async function a() {}');
25
+ testFix(`export async function *a(){}`, 'exports.a = async function *a() {}');
26
+ testFix(`export function *a(){}`, 'exports.a = function *a() {}');
27
+ testFix(`export var a = async()=>{}`, 'exports.a = async () => {}');
24
28
  var testDetour = function (a, e) {
25
29
  var c = scanner2(a);
26
30
  c.break();
@@ -0,0 +1,192 @@
1
+ var isConst = a => a.kind === 'const';
2
+ var autoiota = require("./autoiota");
3
+ var autoenum = require("./autoenum");
4
+ var scanner2 = require("./scanner2");
5
+ var strings = require("../basic/strings");
6
+ var split = require("../basic/$split");
7
+ var path = require("path");
8
+ var fs = require('fs');
9
+ var { STAMP, QUOTED, SCOPED, EXPRESS, COMMENT, pickArgument, remove, splice, insertBefore, VALUE, pickAssignment, createString } = require("./common");
10
+ var getExported = function (code) {
11
+ var used = code.used;
12
+ var exports = used.exports;
13
+ if (!exports) {
14
+ if (used.module || code.return) return;
15
+ var consts = [];
16
+ for (var k in used) {
17
+ var u = used[k];
18
+ var o = u[0];
19
+ if (isConst(o)) {
20
+ o.name = o.text;
21
+ consts.push(o);
22
+ }
23
+ }
24
+ return consts;
25
+ }
26
+ var consts = [];
27
+ for (var a of exports) {
28
+ if (isConst(a)) {
29
+ a.name = a.origin;
30
+ consts.push(a);
31
+ }
32
+ }
33
+ return consts;
34
+ };
35
+ var getAssignedConst = function (a, used) {
36
+ var exp = pickAssignment(a);
37
+ var n = a.next;
38
+ if (!n || n.type !== STAMP || n.text !== "=") return;
39
+ var nn = n.next;
40
+ if (!nn) return;
41
+ if (nn !== exp[exp.length - 1]) return;
42
+ if (nn.type === EXPRESS) {
43
+ var a = nn.text;
44
+ if (/[\.\[]/.test(a)) return;
45
+ var u0 = used[a][0];
46
+ if (u0.kind === 'const') {
47
+ return getAssignedConst(u0, used);
48
+ }
49
+ return;
50
+ }
51
+ if (nn.type !== QUOTED && !nn.isdigit) return;
52
+ return nn;
53
+
54
+ }
55
+ var findConsts = function (text) {
56
+ var code = scanner2(text);
57
+ code.fix();
58
+ var consts = getExported(code);
59
+ if (!consts) return;
60
+ autoiota(code);
61
+ var used = code.used;
62
+ var vmap = Object.create(null);
63
+ for (var a of consts) {
64
+ var name = a.name;
65
+ if (/[\.\[]/.test(name)) continue;
66
+ var c = getAssignedConst(a, used);
67
+ if (c) vmap[name] = c;
68
+ }
69
+ return vmap;
70
+ };
71
+ var setEnvDefinedConsts = function (used, k, v) {
72
+ for (var a of used[k]) {
73
+ var t = a.text;
74
+ var dots = /^\.+/.exec(t);
75
+ if (dots) t = t.slice(dots[0].length);
76
+ t = t.slice(a.tack.length);
77
+ 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;
86
+ }
87
+ };
88
+ var setMapDefinedConsts = function (u, m) {
89
+
90
+ };
91
+ var getMaped = require("./getMaped");
92
+ var maped = Object.create(null);
93
+ var loadConsts = function (fullpath) {
94
+ if (fullpath in maped) return maped[fullpath];
95
+ var data = fs.readFileSync(fullpath);
96
+ var consts = findConsts(String(data));
97
+ maped[fullpath] = consts;
98
+ return consts;
99
+ };
100
+
101
+
102
+ var getOnlyString = function (q) {
103
+ var f = q.first;
104
+ if (f !== q.last || f?.type !== QUOTED || f.length) return;
105
+ var t = strings.decode(f.text);
106
+ return t;
107
+ };
108
+ var getCopy = function (o) {
109
+ return { type: o.type, text: o.text };
110
+ }
111
+
112
+ var setRequiredConsts = function (code, fullpath, commap) {
113
+ var mmap = commap["?"]
114
+ if (!mmap) return code;
115
+ var url = mmap[fullpath];
116
+ var upath = split(url);
117
+ var requires = code.used.require;
118
+ if (!requires) return code;
119
+ for (var r of requires) {
120
+ var q = r.next;
121
+ if (q?.type !== SCOPED || q.entry !== '(') continue;
122
+ var t = getOnlyString(q);
123
+ if (!t) continue;
124
+ var p = getMaped(upath, commap, t);
125
+ if (!p) continue;
126
+ var consts = loadConsts(p);
127
+ if (!consts) continue;
128
+ var exp = pickAssignment(r);
129
+ var e = exp[exp.length - 1];
130
+ if (e !== q) {
131
+ if (e.prev !== q) continue;
132
+ var t = null;
133
+ switch (e.type) {
134
+ default: continue;
135
+ case EXPRESS:
136
+ t = e.text;
137
+ t = t.replace(/^\./, '');
138
+ if (/[\.\[]/.test(t)) continue;
139
+ break;
140
+ case SCOPED:
141
+ if (e.entry !== "[" || e.first !== e.last) continue;
142
+ var t = getOnlyString(e);
143
+ break;
144
+ }
145
+ if (!t || !(t in consts)) continue;
146
+ insertBefore(r, getCopy(consts[t]), { type: STAMP, text: ',' });
147
+ continue;
148
+ }
149
+ var f = exp[0];
150
+ if (f.type === EXPRESS) {
151
+ setMapDefinedConsts(f.text, consts);
152
+ continue;
153
+ }
154
+ if (f.type === SCOPED && f.entry === "{") {
155
+ var o = f.first;
156
+ var collected = [];
157
+ while (o) {
158
+ var exp = pickArgument(o);
159
+ var e = exp[exp.length - 1].next;
160
+ if (exp.length === 1) a: {
161
+ var t = o.text;
162
+ if (/[\.\[]/.test(t)) break a;
163
+ if (!(t in consts)) break a;
164
+ remove(o, e);
165
+ collected.push(o, { type: STAMP, text: '=' }, getCopy(consts[t]), { type: STAMP, text: ',' });
166
+ }
167
+ if (e?.type === STAMP && e.text === ',') e = e.next;
168
+ o = e;
169
+ }
170
+ insertBefore(f, ...collected);
171
+ }
172
+ }
173
+ return code;
174
+ }
175
+ var autoConst = function (code, fullpath) {
176
+ var vmap = this?.["&"];
177
+ var { envs, used } = code;
178
+ if (!vmap) return setRequiredConsts(code, fullpath, this);
179
+ var p = path.dirname(fullpath);
180
+ var mp = vmap[p];
181
+ if (!mp) return setRequiredConsts(code, fullpath, this);
182
+ for (var k in envs) {
183
+ if (k === 'require') {
184
+ setRequiredConsts(code, fullpath, this);
185
+ continue;
186
+ }
187
+ if (k in mp) setEnvDefinedConsts(used, k, mp[k]);
188
+ }
189
+ return code;
190
+ };
191
+ autoConst.findConsts = findConsts;
192
+ module.exports = autoConst;
@@ -299,7 +299,7 @@ var getFunctionHeadBeforeScoped = function (p) {
299
299
  }
300
300
  if (p.isprop) return p;
301
301
  }
302
- function snapSentenceHead(o) {
302
+ function snapAssignmentHead(o) {
303
303
  // 只检查一级
304
304
  while (o && getprev(o)) {
305
305
  var p = getprev(o);
@@ -358,7 +358,7 @@ function snapSentenceHead(o) {
358
358
  break;
359
359
  }
360
360
  if (p.type === STRAP) {
361
- if (/^(?:new|void|typeof|delete|await|var|let|const|class|function|async)$/.test(p.text)) {
361
+ if (/^(?:new|void|typeof|delete|await|class|function|async)$/.test(p.text)) {
362
362
  o = p;
363
363
  continue;
364
364
  }
@@ -383,7 +383,7 @@ function snapSentenceHead(o) {
383
383
  break;
384
384
  }
385
385
  if (p.type === STAMP) {
386
- if (/=>|;/.test(p.text)) {
386
+ if (/^(=>|;|,)$/.test(p.text)) {
387
387
  break;
388
388
  }
389
389
  if (/^[\?\:]$/.test(p.text)) {
@@ -408,11 +408,6 @@ function snapSentenceHead(o) {
408
408
  }
409
409
  break;
410
410
  }
411
- while (o) {
412
- var p = getprev(o);
413
- if (!p || p.type !== LABEL) break;
414
- o = p;
415
- }
416
411
  return o;
417
412
  }
418
413
  var getStrapHead = function (o) {
@@ -1228,7 +1223,7 @@ var mapDeclared = function (map, declared) {
1228
1223
  }
1229
1224
  return map;
1230
1225
  };
1231
- var { uncode } = require("../basic/strings");
1226
+ import { uncode } from "../basic/strings.js";
1232
1227
  var saveTo = function (used, k, o) {
1233
1228
  k = uncode(k);
1234
1229
  if (!(used[k] instanceof Array)) used[k] = [];
@@ -1593,7 +1588,7 @@ var createExpressList = function (code) {
1593
1588
  if (/^[,;]$/.test(c.text)) {
1594
1589
  ex++;
1595
1590
  }
1596
- else if (c.text === ':' && !c.isExpress && c.prev?.type !== PROPERTY) {
1591
+ else if (c.text === ':' && !c.isExpress && getprev(c)?.type !== PROPERTY) {
1597
1592
  ex++;
1598
1593
  }
1599
1594
  }
@@ -1655,11 +1650,13 @@ var remove = function (o, end) {
1655
1650
  var i = q.indexOf(o);
1656
1651
  var length = 1;
1657
1652
  if (arguments.length === 2) {
1658
- end = q.indexOf(end, i) + 1;
1659
- if (end < 0) end = i;
1653
+ var e = q.indexOf(end, i);
1654
+ if (e < 0) end = end ? i : q.length;
1655
+ else end = e + 1;
1660
1656
  length = end - i;
1661
1657
  }
1662
1658
  if (i >= 0) splice(q, i, length);
1659
+ return length;
1663
1660
  };
1664
1661
  var replace = function (o, ...args) {
1665
1662
  var queue = o.queue;
@@ -1739,6 +1736,29 @@ var pickArgument = function (o) {
1739
1736
  }
1740
1737
  return res;
1741
1738
  };
1739
+ var snapSentenceHead = function (o) {
1740
+ while (o) {
1741
+ o = snapAssignmentHead(o)
1742
+ var p = getprev(o);
1743
+ if (p?.type === STAMP && p.text === ',') {
1744
+ var pp = getprev(p);
1745
+ if (!pp) break;
1746
+ o = pp;
1747
+ continue;
1748
+ }
1749
+ break;
1750
+ }
1751
+ var p = getprev(o);
1752
+ if (p?.type === STRAP && /^(var|let|const)$/.test(p.text)) {
1753
+ o = p;
1754
+ }
1755
+ while (o) {
1756
+ var p = getprev(o);
1757
+ if (!p || p.type !== LABEL) break;
1758
+ o = p;
1759
+ }
1760
+ return o;
1761
+ };
1742
1762
  var pickSentence = function (o) {
1743
1763
  if (!o) return [];
1744
1764
  if (o && o.type & (SPACE | COMMENT) && getprev(o)) o = getprev(o);
@@ -1775,6 +1795,7 @@ var pickExpress = function (o) {
1775
1795
  return os;
1776
1796
  };
1777
1797
  var pickAssignment = function (n) {
1798
+ n = snapAssignmentHead(n);
1778
1799
  var e = skipAssignment(n);
1779
1800
  var values = [];
1780
1801
  while (n && n !== e) {
@@ -1905,7 +1926,7 @@ var isDeclareOnly = function (o) {
1905
1926
  return false;
1906
1927
  }
1907
1928
 
1908
- module.exports = {
1929
+ export {
1909
1930
  /* 1 */COMMENT,
1910
1931
  /* 2 */SPACE,
1911
1932
  /* 4 */STRAP,
@@ -1937,6 +1958,7 @@ module.exports = {
1937
1958
  pickArgument,
1938
1959
  pickSentence,
1939
1960
  pickExpress,
1961
+ snapAssignmentHead,
1940
1962
  pickAssignment,
1941
1963
  snapExpressHead,
1942
1964
  snapExpressFoot,
@@ -0,0 +1,36 @@
1
+ var split = require("../basic/$split");
2
+ function getMaped(refpath, mmap, m) {
3
+ var refs = refpath.slice();
4
+ refs.pop();
5
+ var a = split(m);
6
+ for (var cx = 0; cx < a.length; cx++) switch (a[cx]) {
7
+ case "..":
8
+ if (cx > 0) {
9
+ a.splice(cx - 1, 2);
10
+ cx -= 2;
11
+ }
12
+ else {
13
+ refs.pop();
14
+ }
15
+ break;
16
+ case ".":
17
+ case "":
18
+ a.splice(cx, 1);
19
+ cx--;
20
+ break;
21
+ }
22
+ while (refs.length) {
23
+ var tmp = refs.concat(a);
24
+ var r = tmp.join("$");
25
+ if (r in mmap) {
26
+ r = mmap[r];
27
+ return r;
28
+ }
29
+ refs.pop();
30
+ }
31
+ if (m in mmap) {
32
+ var r = mmap[m];
33
+ return r;
34
+ }
35
+ }
36
+ module.exports = getMaped;
@@ -1,4 +1,4 @@
1
- var { QUOTED, unshort } = common;
1
+ var { QUOTED, unshort } = require("./common");
2
2
  var patchname = function (prefix, node, alias) {
3
3
  if (node.isprop && node.short) {
4
4
  unshort(node);
@@ -11,3 +11,4 @@ var patchname = function (prefix, node, alias) {
11
11
  if (hasdot) t = "..." + t;
12
12
  node.text = t;
13
13
  };
14
+ module.exports = patchname;