@oxiaom/adoremix-linux-arm 1.0.0 → 1.0.2
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.
- package/native/etc/docroot/bangzhu/css/app.css +5 -5
- package/native/etc/docroot/bangzhu/css/feedback.css +7 -7
- package/native/etc/docroot/bangzhu/css/mui.dtpicker.css +1 -1
- package/native/etc/docroot/bangzhu/css/mui.picker.all.css +4 -4
- package/native/etc/docroot/bangzhu/css/mui.picker.min.css +6 -6
- package/native/etc/docroot/bangzhu/css/mui.poppicker.css +3 -3
- package/native/etc/docroot/bangzhu/examples/actionsheet-plus.html +20 -20
- package/native/etc/docroot/bangzhu/examples/actionsheet.html +6 -6
- package/native/etc/docroot/bangzhu/examples/best-practices/list-to-detail/detail.html +3 -3
- package/native/etc/docroot/bangzhu/examples/card.html +24 -24
- package/native/etc/docroot/bangzhu/examples/im-chat.html +5 -5
- package/native/etc/docroot/bangzhu/examples/media-list.html +49 -49
- package/native/etc/docroot/bangzhu/examples/message-bottom.html +2 -2
- package/native/etc/docroot/bangzhu/examples/offcanvas-drag-left-plus-main.html +13 -13
- package/native/etc/docroot/bangzhu/examples/picker.html +2 -2
- package/native/etc/docroot/bangzhu/examples/popovers.html +12 -12
- package/native/etc/docroot/bangzhu/examples/pullrefresh_sub.html +11 -11
- package/native/etc/docroot/bangzhu/examples/slider-default.html +18 -18
- package/native/etc/docroot/bangzhu/examples/tab-webview-subpage-setting.html +3 -3
- package/native/etc/docroot/bangzhu/index.html +413 -413
- package/native/etc/docroot/bangzhu/js/mui.picker.min.js +6 -6
- package/native/etc/docroot/bangzhu/manifest.json +993 -993
- package/native/etc/docroot/luyin2/index.html +144 -144
- package/native/etc/docroot/luyin2/js/jquery-1.10.1.min.js +5 -5
- package/native/etc/docroot/luyin2/js/lame.min.js +307 -307
- package/native/etc/docroot/luyin2/js/recordmp3.js +239 -239
- package/native/etc/docroot/luyin2/js/worker-realtime.js +105 -105
- package/native/etc/docroot/luyin2//346/223/215/344/275/234/346/214/207/345/215/227.txt +2 -2
- package/native/etc/docroot/static/css/app.8421a6d597ba48619941ccd4e386fbb2.css +332 -332
- package/native/etc/docroot/tts.js +150 -150
- package/native/etc/docroot/xcx/devicelist.html +658 -658
- package/native/etc/docroot/xcx/index.html +74 -74
- package/native/etc/docroot/xcx/main.html +84 -84
- package/native/etc/ttys/adore03.sql +426 -426
- package/native/etc/ttys/adore04.sql +426 -426
- package/native/etc/ttys/adore1.sql +859 -859
- package/native/etc/ttys/adore_mix22.sql +806 -806
- package/native/etc/ttys/sqlite.sql +1140 -1140
- package/native/etc/ttys/sqlite3main.sql +434 -434
- package/native/etc/ttys/sqltest.sql +279 -279
- package/native/etc/ttys/tp3sql.sql +1412 -1412
- package/native/find.js +523 -523
- package/native/findsc.js +695 -695
- package/native/tts.js +150 -150
- package/package.json +1 -1
|
@@ -1,239 +1,239 @@
|
|
|
1
|
-
(function (exports) {
|
|
2
|
-
|
|
3
|
-
var MP3Recorder = function (config) {
|
|
4
|
-
|
|
5
|
-
var recorder = this;
|
|
6
|
-
config = config || {};
|
|
7
|
-
config.sampleRate = config.sampleRate || 44100;
|
|
8
|
-
config.bitRate = config.bitRate || 64;
|
|
9
|
-
config.broadcasttype = config.broadcasttype || 1;//1:为录制,2:为广播
|
|
10
|
-
|
|
11
|
-
navigator.getUserMedia = navigator.getUserMedia ||
|
|
12
|
-
navigator.webkitGetUserMedia ||
|
|
13
|
-
navigator.mozGetUserMedia ||
|
|
14
|
-
navigator.msGetUserMedia;
|
|
15
|
-
|
|
16
|
-
if (navigator.getUserMedia) {
|
|
17
|
-
navigator.getUserMedia({
|
|
18
|
-
audio: true
|
|
19
|
-
},
|
|
20
|
-
function (stream) {
|
|
21
|
-
var context = new AudioContext(),
|
|
22
|
-
microphone = context.createMediaStreamSource(stream),
|
|
23
|
-
processor = context.createScriptProcessor(16384, 2, 2),//bufferSize大小,输入channel数,输出channel数
|
|
24
|
-
mp3ReceiveSuccess, currentErrorCallback;
|
|
25
|
-
|
|
26
|
-
config.sampleRate = context.sampleRate;
|
|
27
|
-
processor.onaudioprocess = function (event) {
|
|
28
|
-
//边录音边转换
|
|
29
|
-
var array = event.inputBuffer.getChannelData(0);
|
|
30
|
-
if(config.broadcasttype == 1){
|
|
31
|
-
realTimeWorker.postMessage({ cmd: 'encode', buf: array });
|
|
32
|
-
}else{
|
|
33
|
-
realTimeWorker.postMessage({ cmd: 'open', buf: array });
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var realTimeWorker = new Worker('js/worker-realtime.js');
|
|
38
|
-
realTimeWorker.onmessage = function (e) {
|
|
39
|
-
switch (e.data.cmd) {
|
|
40
|
-
case 'init':
|
|
41
|
-
log('初始化成功');
|
|
42
|
-
if (config.funOk) {
|
|
43
|
-
config.funOk();
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
case 'end':
|
|
47
|
-
log('MP3大小:', e.data.buf.length);
|
|
48
|
-
if (mp3ReceiveSuccess) {
|
|
49
|
-
mp3ReceiveSuccess(new Blob(e.data.buf, { type: 'audio/mp3' }));
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
case 'error':
|
|
53
|
-
log('错误信息:' + e.data.error);
|
|
54
|
-
if (currentErrorCallback) {
|
|
55
|
-
currentErrorCallback(e.data.error);
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
case 'close':
|
|
59
|
-
|
|
60
|
-
if( e.data.buf.length > 0 ){
|
|
61
|
-
var i = 0 ;
|
|
62
|
-
var senddata = "";
|
|
63
|
-
var dataforsend = e.data.buf[i] ;
|
|
64
|
-
for( i = 1 ; i <e.data.buf.length ; i++ ){
|
|
65
|
-
if(e.data.buf[i].length >0 ){
|
|
66
|
-
dataforsend = dataforsend + ","+ e.data.buf[i];
|
|
67
|
-
console.log("=============================" + e.data.buf[i].toString("hex")) ;
|
|
68
|
-
senddata =uintbase64(e.data.buf[i]);
|
|
69
|
-
ws.send(senddata);
|
|
70
|
-
//senddata = senddata + uintbase64(e.data.buf[i]) + "|"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
log('未知信息:', e.data);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
recorder.getMp3Blob = function (onSuccess, onError) {
|
|
82
|
-
currentErrorCallback = onError;
|
|
83
|
-
mp3ReceiveSuccess = onSuccess;
|
|
84
|
-
realTimeWorker.postMessage({ cmd: 'finish' });
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
recorder.start = function () {
|
|
88
|
-
if (processor && microphone) {
|
|
89
|
-
microphone.connect(processor);
|
|
90
|
-
processor.connect(context.destination);
|
|
91
|
-
log('开始录音');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
recorder.stop = function () {
|
|
96
|
-
if (processor && microphone) {
|
|
97
|
-
microphone.disconnect();
|
|
98
|
-
processor.disconnect();
|
|
99
|
-
log('录音结束');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
recorder.Ontime = function (broadcasttype) {
|
|
104
|
-
config.broadcasttype = broadcasttype || 1;
|
|
105
|
-
if (processor && microphone) {
|
|
106
|
-
microphone.connect(processor);
|
|
107
|
-
processor.connect(context.destination);
|
|
108
|
-
log('开启广播');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
recorder.Onstop = function (broadcasttype) {
|
|
113
|
-
config.broadcasttype = broadcasttype || 1;
|
|
114
|
-
if (processor && microphone) {
|
|
115
|
-
microphone.disconnect();
|
|
116
|
-
processor.disconnect();
|
|
117
|
-
log('关闭广播');
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
realTimeWorker.postMessage({
|
|
122
|
-
cmd: 'init',
|
|
123
|
-
config: {
|
|
124
|
-
sampleRate: config.sampleRate,
|
|
125
|
-
bitRate: config.bitRate
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
function (error) {
|
|
130
|
-
var msg;
|
|
131
|
-
switch (error.code || error.name) {
|
|
132
|
-
case 'PERMISSION_DENIED':
|
|
133
|
-
case 'PermissionDeniedError':
|
|
134
|
-
msg = '用户拒绝访问麦客风';
|
|
135
|
-
break;
|
|
136
|
-
case 'NOT_SUPPORTED_ERROR':
|
|
137
|
-
case 'NotSupportedError':
|
|
138
|
-
msg = '浏览器不支持麦客风';
|
|
139
|
-
break;
|
|
140
|
-
case 'MANDATORY_UNSATISFIED_ERROR':
|
|
141
|
-
case 'MandatoryUnsatisfiedError':
|
|
142
|
-
msg = '找不到麦客风设备';
|
|
143
|
-
break;
|
|
144
|
-
default:
|
|
145
|
-
msg = '无法打开麦克风,异常信息:' + (error.code || error.name);
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
if (config.funCancel) {
|
|
149
|
-
config.funCancel(msg);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
} else {
|
|
153
|
-
if (config.funCancel) {
|
|
154
|
-
config.funCancel('当前浏览器不支持录音功能');
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function log(str) {
|
|
159
|
-
if (config.debug) {
|
|
160
|
-
console.log(str);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
exports.MP3Recorder = MP3Recorder;
|
|
166
|
-
})(window);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var toBase64 = [
|
|
170
|
-
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
171
|
-
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
172
|
-
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
173
|
-
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
|
174
|
-
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
function uintbase64(src) {
|
|
178
|
-
let dstLen = Math.ceil(src.length * 4 / 3);
|
|
179
|
-
let dst = new Array(dstLen);
|
|
180
|
-
let pos = 0;
|
|
181
|
-
let dstIndex = 0;
|
|
182
|
-
let nextLeft = 0;
|
|
183
|
-
src.forEach( b => {
|
|
184
|
-
let r = 0;
|
|
185
|
-
if (pos == 0) {
|
|
186
|
-
r = b >> 2;
|
|
187
|
-
dst[dstIndex++] = toBase64[nextLeft + r];
|
|
188
|
-
nextLeft = (b & 0x03) << 4;
|
|
189
|
-
} else if (pos == 1) {
|
|
190
|
-
r = b >> 4;
|
|
191
|
-
dst[dstIndex++] = toBase64[nextLeft + r];
|
|
192
|
-
nextLeft = (b & 0x0F) << 2;
|
|
193
|
-
} else if (pos == 2) {
|
|
194
|
-
r = b >> 6;
|
|
195
|
-
dst[dstIndex++] = toBase64[nextLeft + r];
|
|
196
|
-
dst[dstIndex++] = toBase64[b & 0x3F];
|
|
197
|
-
nextLeft = 0;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
pos++;
|
|
201
|
-
if (pos == 3) {
|
|
202
|
-
pos = 0;
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
if (pos != 0) {
|
|
207
|
-
dst[dstIndex] = toBase64[nextLeft];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return dst.join('');
|
|
211
|
-
}
|
|
212
|
-
function uint8arrayToBase64(u8Arr) {
|
|
213
|
-
let CHUNK_SIZE = 0x8000; //arbitrary number
|
|
214
|
-
let index = 0;
|
|
215
|
-
let length = u8Arr.length;
|
|
216
|
-
let result = '';
|
|
217
|
-
let slice;
|
|
218
|
-
while (index < length) {
|
|
219
|
-
slice = u8Arr.subarray(index, Math.min(index + CHUNK_SIZE, length));
|
|
220
|
-
result += String.fromCharCode.apply(null, slice);
|
|
221
|
-
index += CHUNK_SIZE;
|
|
222
|
-
}
|
|
223
|
-
return btoa(result);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function base64ToUint8Array(base64String) {
|
|
227
|
-
let padding = '='.repeat((4 - base64String.length % 4) % 4);
|
|
228
|
-
let base64 = (base64String + padding)
|
|
229
|
-
.replace(/\-/g, '+')
|
|
230
|
-
.replace(/_/g, '/');
|
|
231
|
-
|
|
232
|
-
let rawData = window.atob(base64);
|
|
233
|
-
let outputArray = new Uint8Array(rawData.length);
|
|
234
|
-
|
|
235
|
-
for (var i = 0; i < rawData.length; ++i) {
|
|
236
|
-
outputArray[i] = rawData.charCodeAt(i);
|
|
237
|
-
}
|
|
238
|
-
return outputArray;
|
|
239
|
-
}
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
var MP3Recorder = function (config) {
|
|
4
|
+
|
|
5
|
+
var recorder = this;
|
|
6
|
+
config = config || {};
|
|
7
|
+
config.sampleRate = config.sampleRate || 44100;
|
|
8
|
+
config.bitRate = config.bitRate || 64;
|
|
9
|
+
config.broadcasttype = config.broadcasttype || 1;//1:为录制,2:为广播
|
|
10
|
+
|
|
11
|
+
navigator.getUserMedia = navigator.getUserMedia ||
|
|
12
|
+
navigator.webkitGetUserMedia ||
|
|
13
|
+
navigator.mozGetUserMedia ||
|
|
14
|
+
navigator.msGetUserMedia;
|
|
15
|
+
|
|
16
|
+
if (navigator.getUserMedia) {
|
|
17
|
+
navigator.getUserMedia({
|
|
18
|
+
audio: true
|
|
19
|
+
},
|
|
20
|
+
function (stream) {
|
|
21
|
+
var context = new AudioContext(),
|
|
22
|
+
microphone = context.createMediaStreamSource(stream),
|
|
23
|
+
processor = context.createScriptProcessor(16384, 2, 2),//bufferSize大小,输入channel数,输出channel数
|
|
24
|
+
mp3ReceiveSuccess, currentErrorCallback;
|
|
25
|
+
|
|
26
|
+
config.sampleRate = context.sampleRate;
|
|
27
|
+
processor.onaudioprocess = function (event) {
|
|
28
|
+
//边录音边转换
|
|
29
|
+
var array = event.inputBuffer.getChannelData(0);
|
|
30
|
+
if(config.broadcasttype == 1){
|
|
31
|
+
realTimeWorker.postMessage({ cmd: 'encode', buf: array });
|
|
32
|
+
}else{
|
|
33
|
+
realTimeWorker.postMessage({ cmd: 'open', buf: array });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var realTimeWorker = new Worker('js/worker-realtime.js');
|
|
38
|
+
realTimeWorker.onmessage = function (e) {
|
|
39
|
+
switch (e.data.cmd) {
|
|
40
|
+
case 'init':
|
|
41
|
+
log('初始化成功');
|
|
42
|
+
if (config.funOk) {
|
|
43
|
+
config.funOk();
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case 'end':
|
|
47
|
+
log('MP3大小:', e.data.buf.length);
|
|
48
|
+
if (mp3ReceiveSuccess) {
|
|
49
|
+
mp3ReceiveSuccess(new Blob(e.data.buf, { type: 'audio/mp3' }));
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case 'error':
|
|
53
|
+
log('错误信息:' + e.data.error);
|
|
54
|
+
if (currentErrorCallback) {
|
|
55
|
+
currentErrorCallback(e.data.error);
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case 'close':
|
|
59
|
+
|
|
60
|
+
if( e.data.buf.length > 0 ){
|
|
61
|
+
var i = 0 ;
|
|
62
|
+
var senddata = "";
|
|
63
|
+
var dataforsend = e.data.buf[i] ;
|
|
64
|
+
for( i = 1 ; i <e.data.buf.length ; i++ ){
|
|
65
|
+
if(e.data.buf[i].length >0 ){
|
|
66
|
+
dataforsend = dataforsend + ","+ e.data.buf[i];
|
|
67
|
+
console.log("=============================" + e.data.buf[i].toString("hex")) ;
|
|
68
|
+
senddata =uintbase64(e.data.buf[i]);
|
|
69
|
+
ws.send(senddata);
|
|
70
|
+
//senddata = senddata + uintbase64(e.data.buf[i]) + "|"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
log('未知信息:', e.data);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
recorder.getMp3Blob = function (onSuccess, onError) {
|
|
82
|
+
currentErrorCallback = onError;
|
|
83
|
+
mp3ReceiveSuccess = onSuccess;
|
|
84
|
+
realTimeWorker.postMessage({ cmd: 'finish' });
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
recorder.start = function () {
|
|
88
|
+
if (processor && microphone) {
|
|
89
|
+
microphone.connect(processor);
|
|
90
|
+
processor.connect(context.destination);
|
|
91
|
+
log('开始录音');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
recorder.stop = function () {
|
|
96
|
+
if (processor && microphone) {
|
|
97
|
+
microphone.disconnect();
|
|
98
|
+
processor.disconnect();
|
|
99
|
+
log('录音结束');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
recorder.Ontime = function (broadcasttype) {
|
|
104
|
+
config.broadcasttype = broadcasttype || 1;
|
|
105
|
+
if (processor && microphone) {
|
|
106
|
+
microphone.connect(processor);
|
|
107
|
+
processor.connect(context.destination);
|
|
108
|
+
log('开启广播');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
recorder.Onstop = function (broadcasttype) {
|
|
113
|
+
config.broadcasttype = broadcasttype || 1;
|
|
114
|
+
if (processor && microphone) {
|
|
115
|
+
microphone.disconnect();
|
|
116
|
+
processor.disconnect();
|
|
117
|
+
log('关闭广播');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
realTimeWorker.postMessage({
|
|
122
|
+
cmd: 'init',
|
|
123
|
+
config: {
|
|
124
|
+
sampleRate: config.sampleRate,
|
|
125
|
+
bitRate: config.bitRate
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
function (error) {
|
|
130
|
+
var msg;
|
|
131
|
+
switch (error.code || error.name) {
|
|
132
|
+
case 'PERMISSION_DENIED':
|
|
133
|
+
case 'PermissionDeniedError':
|
|
134
|
+
msg = '用户拒绝访问麦客风';
|
|
135
|
+
break;
|
|
136
|
+
case 'NOT_SUPPORTED_ERROR':
|
|
137
|
+
case 'NotSupportedError':
|
|
138
|
+
msg = '浏览器不支持麦客风';
|
|
139
|
+
break;
|
|
140
|
+
case 'MANDATORY_UNSATISFIED_ERROR':
|
|
141
|
+
case 'MandatoryUnsatisfiedError':
|
|
142
|
+
msg = '找不到麦客风设备';
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
msg = '无法打开麦克风,异常信息:' + (error.code || error.name);
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
if (config.funCancel) {
|
|
149
|
+
config.funCancel(msg);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
if (config.funCancel) {
|
|
154
|
+
config.funCancel('当前浏览器不支持录音功能');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function log(str) {
|
|
159
|
+
if (config.debug) {
|
|
160
|
+
console.log(str);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
exports.MP3Recorder = MP3Recorder;
|
|
166
|
+
})(window);
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
var toBase64 = [
|
|
170
|
+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
171
|
+
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
172
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
173
|
+
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
|
174
|
+
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
function uintbase64(src) {
|
|
178
|
+
let dstLen = Math.ceil(src.length * 4 / 3);
|
|
179
|
+
let dst = new Array(dstLen);
|
|
180
|
+
let pos = 0;
|
|
181
|
+
let dstIndex = 0;
|
|
182
|
+
let nextLeft = 0;
|
|
183
|
+
src.forEach( b => {
|
|
184
|
+
let r = 0;
|
|
185
|
+
if (pos == 0) {
|
|
186
|
+
r = b >> 2;
|
|
187
|
+
dst[dstIndex++] = toBase64[nextLeft + r];
|
|
188
|
+
nextLeft = (b & 0x03) << 4;
|
|
189
|
+
} else if (pos == 1) {
|
|
190
|
+
r = b >> 4;
|
|
191
|
+
dst[dstIndex++] = toBase64[nextLeft + r];
|
|
192
|
+
nextLeft = (b & 0x0F) << 2;
|
|
193
|
+
} else if (pos == 2) {
|
|
194
|
+
r = b >> 6;
|
|
195
|
+
dst[dstIndex++] = toBase64[nextLeft + r];
|
|
196
|
+
dst[dstIndex++] = toBase64[b & 0x3F];
|
|
197
|
+
nextLeft = 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
pos++;
|
|
201
|
+
if (pos == 3) {
|
|
202
|
+
pos = 0;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
if (pos != 0) {
|
|
207
|
+
dst[dstIndex] = toBase64[nextLeft];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return dst.join('');
|
|
211
|
+
}
|
|
212
|
+
function uint8arrayToBase64(u8Arr) {
|
|
213
|
+
let CHUNK_SIZE = 0x8000; //arbitrary number
|
|
214
|
+
let index = 0;
|
|
215
|
+
let length = u8Arr.length;
|
|
216
|
+
let result = '';
|
|
217
|
+
let slice;
|
|
218
|
+
while (index < length) {
|
|
219
|
+
slice = u8Arr.subarray(index, Math.min(index + CHUNK_SIZE, length));
|
|
220
|
+
result += String.fromCharCode.apply(null, slice);
|
|
221
|
+
index += CHUNK_SIZE;
|
|
222
|
+
}
|
|
223
|
+
return btoa(result);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function base64ToUint8Array(base64String) {
|
|
227
|
+
let padding = '='.repeat((4 - base64String.length % 4) % 4);
|
|
228
|
+
let base64 = (base64String + padding)
|
|
229
|
+
.replace(/\-/g, '+')
|
|
230
|
+
.replace(/_/g, '/');
|
|
231
|
+
|
|
232
|
+
let rawData = window.atob(base64);
|
|
233
|
+
let outputArray = new Uint8Array(rawData.length);
|
|
234
|
+
|
|
235
|
+
for (var i = 0; i < rawData.length; ++i) {
|
|
236
|
+
outputArray[i] = rawData.charCodeAt(i);
|
|
237
|
+
}
|
|
238
|
+
return outputArray;
|
|
239
|
+
}
|