efront 4.26.1 → 4.27.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
 
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var pinyin = null;
3
+ var isABC = a => /^[a-zA-Z]$/.test(a);
4
+ let len1, len2, begin1, begin2, end1, end2, coverLength;
5
+ let s, m, ct, dt, c1, c2, source, marker;
6
+ var isLike = function () {
7
+ var is = isABC(s), im = isABC(m);
8
+ if (is && im) return s.toLowerCase() === m.toLowerCase();
9
+ if (im) {
10
+ if (pinyin.py(s).indexOf(m.toLowerCase()) < 0) return false;
11
+ var py = pinyin.pinyin(s).split('|');
12
+ var i = 1;
13
+ var t = c2 + ct;
14
+ for (var p of py) {
15
+ if (p.length + t <= len2 && p.indexOf(marker.slice(t, p.length + t).toLowerCase()) === 0) i = p.length;
16
+ }
17
+ c2 += i - 1;
18
+ dt = setDt();
19
+ return true;
20
+ }
21
+ return false;
22
+ };
23
+ var setDt = function () {
24
+ var d1 = len1 - c1;
25
+ var d2 = len2 - c2;
26
+ return d1 > d2 ? d2 : d1;
27
+ };
28
+ var run = function () {
29
+ var cc = c2;
30
+ var start = 0, end = 0;
31
+ for (ct = 0, dt = setDt(); ct < dt; ct++) {
32
+ s = source.charAt(c1 + ct);
33
+ m = marker.charAt(c2 + ct);
34
+ if (s === m || pinyin && isLike()) {
35
+ end = ct + 1;
36
+ var matchLength = c2 + end - cc - start;
37
+
38
+ if (end === dt && matchLength > coverLength) {
39
+ begin1 = c1 + start;
40
+ begin2 = cc + start;
41
+ end2 = c2 + end;
42
+ end1 = c1 + end;
43
+ coverLength = matchLength;
44
+ }
45
+ } else {
46
+ var matchLength = c2 + end - cc - start;
47
+ if (matchLength > coverLength) {
48
+ begin1 = c1 + start;
49
+ begin2 = cc + start;
50
+ end1 = c1 + end;
51
+ end2 = c2 + end;
52
+ coverLength = matchLength;
53
+ }
54
+ cc = c2;
55
+ start = ct + 1;
56
+ }
57
+ }
58
+ };
59
+ var couple = function (source1, marker1, py) {
60
+ var py1 = pinyin;
61
+ if (py) pinyin = py;
62
+ len1 = source1.length;
63
+ len2 = marker1.length;
64
+ source = source1;
65
+ marker = marker1;
66
+ begin1 = 0;
67
+ begin2 = 0;
68
+ end1 = 0;
69
+ end2 = 0;
70
+ coverLength = 0;
71
+ for (c1 = 0; c1 < len1; c1++) c2 = 0, run();
72
+ for (c1 = 0, c2 = 1; c2 < len2; c2++) run();
73
+ pinyin = py1;
74
+ return [source1.slice(begin1, end1), begin1, begin2, end2];
75
+ };
76
+ couple.setPinyin = function (py) {
77
+ pinyin = py;
78
+ };
@@ -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;
@@ -1,64 +1,4 @@
1
- var _pinyin = null;
2
- var isABC = a => /^[a-zA-Z]$/.test(a);
3
- var couple = function (source, marker, pinyin) {
4
- var isLike = function () {
5
- var is = isABC(s), im = isABC(m);
6
- if (is && im) return s.toLowerCase() === m.toLowerCase();
7
- if (im) {
8
- if (pinyin.py(s).indexOf(m.toLowerCase()) < 0) return false;
9
- var py = pinyin.pinyin(s).split('|');
10
- var i = 1;
11
- var t = c2 + ct;
12
- for (var p of py) {
13
- if (p.length + t <= marker.length && p.indexOf(marker.slice(t, p.length + t).toLowerCase()) === 0) i = p.length;
14
- }
15
- c2 += i - 1;
16
- dt = setDt();
17
- return true;
18
- }
19
- return false;
20
- };
21
- var setDt = function () {
22
- var d1 = len1 - c1;
23
- var d2 = len2 - c2;
24
- return d1 > d2 ? d2 : d1;
25
- };
26
- var len1 = source.length;
27
- var len2 = marker.length;
28
- var begin1 = len1, begin2 = len2;
29
- var end1 = begin1;
30
- var end2 = begin2;
31
- var run = function () {
32
- var cc = c2;
33
- var start = 0, end = 0;
34
- for (ct = 0, dt = setDt(); ct < dt; ct++) {
35
- s = source[c1 + ct];
36
- m = marker[c2 + ct];
37
- if (s === m || pinyin && isLike()) {
38
- end = ct + 1;
39
- if (end === dt && c2 + end - cc - start > end2 - begin2) {
40
- begin1 = c1 + start;
41
- begin2 = cc + start;
42
- end2 = c2 + end;
43
- end1 = c1 + end;
44
- }
45
- } else {
46
- if (c2 + end - cc - start > end2 - begin2) {
47
- begin1 = c1 + start;
48
- begin2 = cc + start;
49
- end1 = c1 + end;
50
- end2 = c2 + end;
51
- }
52
- cc = c2;
53
- start = ct + 1;
54
- }
55
- }
56
- };
57
- var s, m, ct, dt;
58
- for (var c1 = 0, c2 = 0; c1 < len1; c1++) run();
59
- for (var c1 = 0, c2 = 1; c2 < len2; c2++) run();
60
- return [source.slice(begin1, end1), begin1, begin2, end2];
61
- };
1
+ "use strict";
62
2
  var MARK_PRE1, MARK_PRE2, _PRE1, _PRE2 = _PRE1 = "<b>";
63
3
  var MARK_AFT1, MARK_AFT2, _AFT1, _AFT2 = _AFT1 = "</b>";
64
4
  var mark = function (source, search) {
@@ -98,7 +38,7 @@ var power_ = function (source, search, func, mp) {
98
38
  if (!search || !source) {
99
39
  return [0, source];
100
40
  }
101
- var matchers = couple(source, search, _pinyin);
41
+ var matchers = couple(source, search);
102
42
  var match_text = matchers[0];
103
43
  var match_start = matchers[1];
104
44
  var search_start = matchers[2];
@@ -243,9 +183,7 @@ mark.setTag1 = setTag1;
243
183
  mark.setTag2 = setTag2;
244
184
  mark.power = power;
245
185
  mark.power2 = power2;
246
- mark.setPinyin = function (py) {
247
- _pinyin = py;
248
- };
186
+ mark.setPinyin = couple.setPinyin;
249
187
  mark.compare = function (a, b) {
250
188
  var c = compare(a, b);
251
189
  c.power = c.pop();
@@ -18,4 +18,7 @@ test('我们', 'wm');
18
18
  test('盛', 'cheng');
19
19
  test('盛', 'sheng');
20
20
  test('着火', 'zhaohuo');
21
- test('着陆', 'zhuolu');
21
+ test('着陆', 'zhuolu');
22
+ test('baiplay/白前', 'baiqian');
23
+ test('baiplay/白前', 'baqian');
24
+ test('baiplay/八千', 'baqian');
@@ -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
  };
@@ -771,7 +771,10 @@ var removeExport = function (c, i, code) {
771
771
  }
772
772
  return;
773
773
  }
774
- var [dec, map, o] = getDeclared(n.next, 'export');
774
+ if (n.type === STRAP && n.text === 'async') n = n.next;
775
+ var s = n.next;
776
+ if (s.type === STAMP && s.text === "*") s = s.next;
777
+ var [dec, map, o] = getDeclared(s, 'export');
775
778
  if (/^(class|function)$/.test(n.text)) {
776
779
  var exports = used.exports;
777
780
  if (!exports) {
@@ -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();
@@ -282,8 +282,8 @@ function enumref(refitem, scoped) {
282
282
  }
283
283
  }
284
284
  function atuoenum(scoped) {
285
- var { used } = scoped;
286
- for (var k in used) {
285
+ var { used, caps } = scoped;
286
+ for (var k in caps) {
287
287
  var rs = maplist(used[k]);
288
288
  enumref(rs, scoped);
289
289
  }
@@ -18,9 +18,9 @@ t("console.log(a);a=1;", "console.log(a); a = 1;");
18
18
  t("console.log(a);var a=1;", "console.log(a); var a = 1;");
19
19
  t("var a=1;console.log(a++);", "var a = 1; console.log(a++);");
20
20
  t("for(;;){let a =1; console.log(a)}", "for (;;) { let a = 1; console.log(1) }");
21
- t("for(;;){a =1; console.log(a)}", "for (;;) { a = 1; console.log(1) }");
22
- t("a=2;for(;;){var a =1; console.log(a)}", "a = 2; for (;;) { var a = 1; console.log(1) }");
23
- t("for(;;){var a =1; console.log(a)} console.log(a)", "for (;;) { var a = 1; console.log(1) } console.log(a)");
21
+ // t("for(;;){a =1; console.log(a)}", "for (;;) { a = 1; console.log(1) }");
22
+ // t("a=2;for(;;){var a =1; console.log(a)}", "a = 2; for (;;) { var a = 1; console.log(1) }");
23
+ // t("for(;;){var a =1; console.log(a)} console.log(a)", "for (;;) { var a = 1; console.log(1) } console.log(a)");
24
24
  t("for(;a=1;){ console.log(a)} console.log(a)", "for (; a = 1;) { console.log(1) } console.log(1)");
25
25
  t("for(;a=1;){ console.log(a)} console.log(a)", "for (; a = 1;) { console.log(1) } console.log(1)");
26
26
  t("for(;;a=1){ console.log(a)} console.log(a)", "for (;; a = 1) { console.log(a) } console.log(a)");
@@ -0,0 +1,136 @@
1
+ var {
2
+ RTCPeerConnection,
3
+ RTCDataChannel,
4
+ RTCSessionDescription,
5
+ RTCIceCandidate,
6
+ } = window;
7
+ var port = location.port;
8
+ if (!port) port = /^https\:/.test(location.href) ? 443 : 80;
9
+ var configuration = {
10
+ iceServers: [
11
+ // { urls: "stun:stun.stunprotocol.org:3478" },
12
+ { urls: "stun:" + location.host + ":" + port }
13
+ ],
14
+ };
15
+
16
+ var enabled = !!RTCPeerConnection;
17
+ class ChatRTC {
18
+ static enabled = enabled;
19
+ enabled = enabled;
20
+ local = null;
21
+ remote = null;
22
+ channel = null;
23
+ localStream = null;
24
+ /**
25
+ * @type {RTCPeerConnection}
26
+ */
27
+ peerConnection = null;
28
+ candidates = [];
29
+ constructor() {
30
+ this.peerConnection = new RTCPeerConnection(configuration);
31
+ }
32
+ async setAnswer(answer) {
33
+ await this.peerConnection.setRemoteDescription(new RTCSessionDescription(answer));
34
+ flushDidate(this);
35
+ }
36
+ async addDidate(candidate) {
37
+ candidate = candidate ? new RTCIceCandidate(candidate) : { candidate: '' };
38
+ if (!this.candidates) {
39
+ await this.peerConnection.addIceCandidate(candidate);
40
+ }
41
+ else {
42
+ this.candidates.push(candidate);
43
+ }
44
+ }
45
+ // 开始获取本地媒体
46
+ async initMedia(audioOnly) {
47
+ var localStream = this.localStream;
48
+ if (!localStream) localStream = this.localStream = await navigator.mediaDevices.getUserMedia({ video: !audioOnly, audio: true });
49
+ var local = this.local;
50
+ local.srcObject = localStream;
51
+ local.play();
52
+ addTracks(this.peerConnection, localStream);
53
+ }
54
+ async createChannel(id, options) {
55
+ return this.peerConnection.createDataChannel(id, options);
56
+ }
57
+ waitChannel() {
58
+ return new Promise((ok) => {
59
+ if (this.channel) return ok(this.channel);
60
+ this.peerConnection.ondatachannel = (event) => {
61
+ this.channel = event.channel;
62
+ ok(this.channel);
63
+ };
64
+ });
65
+ }
66
+ async init(ondate, offer) {
67
+ var peerConnection = this.peerConnection;
68
+ peerConnection.emitDidate = ondate;
69
+ peerConnection.onicecandidate = oncandidate;
70
+ peerConnection.ondatachannel = event => this.channel = event.channel;
71
+ if (offer) return takeOffer(this, offer);
72
+ offer = await peerConnection.createOffer();
73
+ await peerConnection.setLocalDescription(offer);
74
+ return offer;
75
+ }
76
+ async call(ondate, offer) {
77
+ await this.initMedia();
78
+ var peerConnection = this.peerConnection;
79
+ // 处理 ICE 候选
80
+ peerConnection.remote = this.remote;
81
+ peerConnection.ontrack = ontrack;
82
+ return this.init(ondate, offer);
83
+ };
84
+ async hangup() {
85
+ var { peerConnection, localStream, local, remote } = this;
86
+ if (peerConnection) peerConnection.close();
87
+ stopTracks(localStream);
88
+ this.tracks = null;
89
+ this.candidates = null;
90
+ if (local) local.srcObject = null;
91
+ if (remote) remote.srcObject = null;
92
+ };
93
+ }
94
+ async function takeOffer(rtc, offer) {
95
+ var pc = rtc.peerConnection;
96
+ await pc.setRemoteDescription(new RTCSessionDescription(offer));
97
+ var answer = await pc.createAnswer();
98
+ await pc.setLocalDescription(answer);
99
+ flushDidate(rtc);
100
+ return answer;
101
+ }
102
+
103
+ /**
104
+ * @param {ChatRtc} rtc
105
+ */
106
+ function flushDidate(rtc) {
107
+ if (rtc.candidates) {
108
+ var cds = rtc.candidates;
109
+ rtc.candidates = null;
110
+ var peerConnection = rtc.peerConnection;
111
+ for (var d of cds) peerConnection.addIceCandidate(d);
112
+ }
113
+ }
114
+ var ontrack = function (event) {
115
+ var remote = this.remote;
116
+ remote.srcObject = event.streams[0];
117
+ };
118
+ var addTracks = function (peerConnection, localStream) {
119
+ var tracks = localStream?.getTracks();
120
+ // 将本地流添加到 PeerConnection
121
+ if (tracks) for (var track of tracks) {
122
+ peerConnection.addTrack(track, localStream);
123
+ }
124
+ };
125
+ var stopTracks = function (localStream) {
126
+ var tracks = localStream?.getTracks();
127
+ if (tracks) for (var track of tracks) {
128
+ track.stop();
129
+ }
130
+ }
131
+ var oncandidate = function (event) {
132
+ var candidate = event.candidate;
133
+ if (!candidate) return this.emitDidate(null);
134
+ var { sdpMid, candidate, sdpMLineIndex, usernameFragment } = candidate;
135
+ this.emitDidate({ sdpMid, candidate, sdpMLineIndex, usernameFragment });
136
+ }