react_hsbc_teller 2.0.25 → 2.0.27

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,289 +0,0 @@
1
- /*!
2
- *
3
- * js-audio-recorder - js audio recorder plugin
4
- *
5
- * @version v0.5.7
6
- * @homepage https://github.com/2fps/recorder
7
- * @author 2fps <echoweb@126.com> (https://www.zhuyuntao.cn)
8
- * @license MIT
9
- *
10
- */
11
- !function (t, e) {
12
- "object" == typeof exports && "object" == typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports ? exports.Recorder = e() : t.Recorder = e()
13
- }(this, function () {
14
- return function (t) {
15
- var e = {};
16
-
17
- function i(n) {
18
- if (e[n]) return e[n].exports;
19
- var r = e[n] = {
20
- i: n,
21
- l: !1,
22
- exports: {}
23
- };
24
- return t[n].call(r.exports, r, r.exports, i), r.l = !0, r.exports
25
- }
26
-
27
- return i.m = t, i.c = e, i.d = function (t, e, n) {
28
- i.o(t, e) || Object.defineProperty(t, e, {
29
- enumerable: !0,
30
- get: n
31
- })
32
- }, i.r = function (t) {
33
- "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, {
34
- value: "Module"
35
- }), Object.defineProperty(t, "__esModule", {
36
- value: !0
37
- })
38
- }, i.t = function (t, e) {
39
- if (1 & e && (t = i(t)), 8 & e) return t;
40
- if (4 & e && "object" == typeof t && t && t.__esModule) return t;
41
- var n = Object.create(null);
42
- if (i.r(n), Object.defineProperty(n, "default", {
43
- enumerable: !0,
44
- value: t
45
- }), 2 & e && "string" != typeof t)
46
- for (var r in t) i.d(n, r, function (e) {
47
- return t[e]
48
- }.bind(null, r));
49
- return n
50
- }, i.n = function (t) {
51
- var e = t && t.__esModule ? function () {
52
- return t.default
53
- } : function () {
54
- return t
55
- };
56
- return i.d(e, "a", e), e
57
- }, i.o = function (t, e) {
58
- return Object.prototype.hasOwnProperty.call(t, e)
59
- }, i.p = "", i(i.s = 0)
60
- }([function (t, e, i) {
61
- "use strict";
62
- Object.defineProperty(e, "__esModule", {
63
- value: !0
64
- });
65
- var n = function () {
66
- function t(e) {
67
- void 0 === e && (e = {}), this.isplaying = !1, this.lBuffer = [], this.rBuffer = [], this.tempPCM = [], this.inputSampleBits = 16, this.playStamp = 0, this.playTime = 0, this.totalPlayTime = 0, this.offset = 0, this.fileSize = 0;
68
- var i, n = new (window.AudioContext || window.webkitAudioContext);
69
- this.inputSampleRate = n.sampleRate, this.config = {
70
- sampleBits: ~[8, 16].indexOf(e.sampleBits) ? e.sampleBits : 16,
71
- sampleRate: ~[8e3, 11025, 16e3, 22050, 24e3, 44100, 48e3].indexOf(e.sampleRate) ? e.sampleRate : this.inputSampleRate,
72
- numChannels: ~[1, 2].indexOf(e.numChannels) ? e.numChannels : 1,
73
- compiling: !!e.compiling || !1
74
- }, this.outputSampleRate = this.config.sampleRate, this.oututSampleBits = this.config.sampleBits, this.littleEdian = (i = new ArrayBuffer(2), new DataView(i).setInt16(0, 256, !0), 256 === new Int16Array(i)[0]), t.initUserMedia()
75
- }
76
-
77
- return t.prototype.initRecorder = function () {
78
- var t = this;
79
- this.context && this.destroy(), this.context = new (window.AudioContext || window.webkitAudioContext), this.analyser = this.context.createAnalyser(), this.analyser.fftSize = 2048;
80
- var e = this.context.createScriptProcessor || this.context.createJavaScriptNode;
81
- this.recorder = e.apply(this.context, [4096, this.config.numChannels, this.config.numChannels]), this.recorder.onaudioprocess = function (e) {
82
- if (t.isrecording && !t.ispause) {
83
- var i, n = e.inputBuffer.getChannelData(0),
84
- r = null;
85
- if (t.lBuffer.push(new Float32Array(n)), t.size += n.length, 2 === t.config.numChannels && (r = e.inputBuffer.getChannelData(1), t.rBuffer.push(new Float32Array(r)), t.size += r.length), t.config.compiling) {
86
- var o = t.transformIntoPCM(n, r);
87
- t.tempPCM.push(o), t.fileSize = o.byteLength * t.tempPCM.length
88
- } else t.fileSize = Math.floor(t.size / Math.max(t.inputSampleRate / t.outputSampleRate, 1)) * (t.oututSampleBits / 8);
89
- i = 100 * Math.max.apply(Math, n), t.duration += 4096 / t.inputSampleRate, t.onprocess && t.onprocess(t.duration), t.onprogress && t.onprogress({
90
- duration: t.duration,
91
- fileSize: t.fileSize,
92
- vol: i,
93
- data: t.tempPCM
94
- })
95
- }
96
- }
97
- }, t.prototype.start = function () {
98
- var t = this;
99
- if (!this.isrecording) return this.clear(), this.initRecorder(), this.isrecording = !0, navigator.mediaDevices.getUserMedia({
100
- audio: !0
101
- }).then(function (e) {
102
- t.audioInput = t.context.createMediaStreamSource(e), t.stream = e
103
- }).then(function () {
104
- t.audioInput.connect(t.analyser), t.analyser.connect(t.recorder), t.recorder.connect(t.context.destination)
105
- })
106
- }, t.prototype.pause = function () {
107
- this.isrecording && !this.ispause && (this.ispause = !0)
108
- }, t.prototype.resume = function () {
109
- this.isrecording && this.ispause && (this.ispause = !1)
110
- }, t.prototype.stop = function () {
111
- this.isrecording = !1, this.audioInput && this.audioInput.disconnect(), this.recorder.disconnect()
112
- }, t.prototype.play = function () {
113
- this.stop(), this.source && this.source.stop(), this.isplaying = !0, this.playTime = 0, this.playAudioData()
114
- }, t.prototype.getPlayTime = function () {
115
- var t = 0;
116
- return (t = this.isplaying ? this.context.currentTime - this.playStamp + this.playTime : this.playTime) >= this.totalPlayTime && (t = this.totalPlayTime), t
117
- }, t.prototype.pausePlay = function () {
118
- !this.isrecording && this.isplaying && (this.source && this.source.disconnect(), this.playTime += this.context.currentTime - this.playStamp, this.isplaying = !1)
119
- }, t.prototype.resumePlay = function () {
120
- this.isrecording || this.isplaying || 0 === this.playTime || (this.isplaying = !0, this.playAudioData())
121
- }, t.prototype.stopPlay = function () {
122
- this.isrecording || (this.playTime = 0, this.isplaying = !1, this.source && this.source.stop())
123
- }, t.prototype.getWholeData = function () {
124
-
125
- return this.tempPCM
126
- }, t.prototype.getNextData = function () {
127
- var t1 = this.tempPCM.length,
128
- e1 = this.tempPCM.slice(this.offset)
129
-
130
- if (e1.length) {
131
- var e = new ArrayBuffer(e1.length * e1[0].byteLength),
132
- i = new DataView(e),
133
- n = 0;
134
- e1.forEach(function (t) {
135
- for (var e = 0, r = t.byteLength; e < r; ++e) i.setInt8(n, t.getInt8(e)), n++
136
- }), this.PCM = i, this.tempPCM = []
137
- }
138
- if (this.PCM) return this.PCM;
139
- var r = this.flat();
140
- r = t.compress(r, this.inputSampleRate, this.outputSampleRate), this.PCM = t.encodePCM(r, this.oututSampleBits, this.littleEdian)
141
- this.offset = t1
142
- return new Blob([r])
143
- // return e1
144
- }, t.prototype.playAudioData = function () {
145
- var e = this;
146
- this.context.decodeAudioData(this.getWAV().buffer, function (t) {
147
- e.source = e.context.createBufferSource(), e.source.buffer = t, e.totalPlayTime = e.source.buffer.duration, e.source.connect(e.analyser), e.analyser.connect(e.context.destination), e.source.start(0, e.playTime), e.playStamp = e.context.currentTime
148
- }, function (e) {
149
- t.throwError(e)
150
- })
151
- }, t.prototype.getRecordAnalyseData = function () {
152
- if (this.ispause) return this.prevDomainData;
153
- var t = new Uint8Array(this.analyser.frequencyBinCount);
154
- return this.analyser.getByteTimeDomainData(t), this.prevDomainData = t
155
- }, t.prototype.getPlayAnalyseData = function () {
156
- return this.getRecordAnalyseData()
157
- }, t.prototype.getPCM = function () {
158
- if (this.tempPCM.length) {
159
- var e = new ArrayBuffer(this.tempPCM.length * this.tempPCM[0].byteLength),
160
- i = new DataView(e),
161
- n = 0;
162
- this.tempPCM.forEach(function (t) {
163
- for (var e = 0, r = t.byteLength; e < r; ++e) i.setInt8(n, t.getInt8(e)), n++
164
- }), this.PCM = i, this.tempPCM = []
165
- }
166
- if (this.PCM) return this.PCM;
167
- var r = this.flat();
168
- return r = t.compress(r, this.inputSampleRate, this.outputSampleRate), this.PCM = t.encodePCM(r, this.oututSampleBits, this.littleEdian)
169
- }, t.prototype.getPCMBlob = function () {
170
- return this.stop(), new Blob([this.getPCM()])
171
- }, t.prototype.downloadPCM = function (t) {
172
- void 0 === t && (t = "recorder");
173
- var e = this.getPCMBlob();
174
- this.download(e, t, "pcm")
175
- }, t.prototype.getWAV = function () {
176
- var e = this.getPCM();
177
- return t.encodeWAV(e, this.inputSampleRate, this.outputSampleRate, this.config.numChannels, this.oututSampleBits, this.littleEdian)
178
- }, t.prototype.getWAVBlob = function () {
179
- return this.stop(), new Blob([this.getWAV()], {
180
- type: "audio/wav"
181
- })
182
- }, t.prototype.downloadWAV = function (t) {
183
- void 0 === t && (t = "recorder");
184
- var e = this.getWAVBlob();
185
- this.download(e, t, "wav")
186
- }, t.prototype.transformIntoPCM = function (e, i) {
187
- var n = new Float32Array(e),
188
- r = new Float32Array(i),
189
- o = t.compress({
190
- left: n,
191
- right: r
192
- }, this.inputSampleRate, this.outputSampleRate);
193
- return t.encodePCM(o, this.oututSampleBits, this.littleEdian)
194
- }, t.prototype.destroy = function () {
195
- return this.stopStream(), this.closeAudioContext()
196
- }, t.prototype.stopStream = function () {
197
- this.stream && this.stream.getTracks && (this.stream.getTracks().forEach(function (t) {
198
- return t.stop()
199
- }), this.stream = null)
200
- }, t.prototype.closeAudioContext = function () {
201
- return this.context && this.context.close && "closed" !== this.context.state ? this.context.close() : new Promise(function (t) {
202
- t()
203
- })
204
- }, t.prototype.download = function (e, i, n) {
205
- try {
206
- var r = document.createElement("a");
207
- r.href = window.URL.createObjectURL(e), r.download = i + "." + n, r.click()
208
- } catch (e) {
209
- t.throwError(e)
210
- }
211
- }, t.prototype.clear = function () {
212
- this.lBuffer.length = 0, this.rBuffer.length = 0, this.size = 0, this.fileSize = 0, this.PCM = null, this.audioInput = null, this.duration = 0, this.ispause = !1, this.isplaying = !1, this.playTime = 0, this.totalPlayTime = 0, this.source && (this.source.stop(), this.source = null)
213
- }, t.prototype.flat = function () {
214
- var t = null,
215
- e = new Float32Array(0);
216
- 1 === this.config.numChannels ? t = new Float32Array(this.size) : (t = new Float32Array(this.size / 2), e = new Float32Array(this.size / 2));
217
- for (var i = 0, n = 0; n < this.lBuffer.length; n++) t.set(this.lBuffer[n], i), i += this.lBuffer[n].length;
218
- i = 0;
219
- for (n = 0; n < this.rBuffer.length; n++) e.set(this.rBuffer[n], i), i += this.rBuffer[n].length;
220
- return {
221
- left: t,
222
- right: e
223
- }
224
- }, t.playAudio = function (t) {
225
- var e = document.createElement("audio");
226
- e.src = window.URL.createObjectURL(t), e.play()
227
- }, t.compress = function (t, e, i) {
228
- for (var n = e / i, r = Math.max(n, 1), o = t.left, s = t.right, a = Math.floor((o.length + s.length) / n), u = new Float32Array(a), h = 0, c = 0; h < a;) {
229
- var l = Math.floor(c);
230
- u[h] = o[l], h++, s.length && (u[h] = s[l], h++), c += r
231
- }
232
- return u
233
- }, t.encodePCM = function (t, e, i) {
234
- void 0 === i && (i = !0);
235
- var n = 0,
236
- r = t.length * (e / 8),
237
- o = new ArrayBuffer(r),
238
- s = new DataView(o);
239
- if (8 === e)
240
- for (var a = 0; a < t.length; a++, n++) {
241
- var u = (h = Math.max(-1, Math.min(1, t[a]))) < 0 ? 128 * h : 127 * h;
242
- u = +u + 128, s.setInt8(n, u)
243
- } else
244
- for (a = 0; a < t.length; a++, n += 2) {
245
- var h = Math.max(-1, Math.min(1, t[a]));
246
- s.setInt16(n, h < 0 ? 32768 * h : 32767 * h, i)
247
- }
248
- return s
249
- }, t.encodeWAV = function (t, e, i, n, o, s) {
250
- void 0 === s && (s = !0);
251
- var a = i > e ? e : i,
252
- u = o,
253
- h = new ArrayBuffer(44 + t.byteLength),
254
- c = new DataView(h),
255
- l = n,
256
- p = 0;
257
- r(c, p, "RIFF"), p += 4, c.setUint32(p, 36 + t.byteLength, s), r(c, p += 4, "WAVE"), r(c, p += 4, "fmt "), p += 4, c.setUint32(p, 16, s), p += 4, c.setUint16(p, 1, s), p += 2, c.setUint16(p, l, s), p += 2, c.setUint32(p, a, s), p += 4, c.setUint32(p, l * a * (u / 8), s), p += 4, c.setUint16(p, l * (u / 8), s), p += 2, c.setUint16(p, u, s), r(c, p += 2, "data"), p += 4, c.setUint32(p, t.byteLength, s), p += 4;
258
- for (var f = 0; f < t.byteLength;) c.setUint8(p, t.getUint8(f)), p++, f++;
259
- return c
260
- }, t.throwError = function (t) {
261
- throw new Error(t)
262
- }, t.initUserMedia = function () {
263
- void 0 === navigator.mediaDevices && (navigator.mediaDevices = {}), void 0 === navigator.mediaDevices.getUserMedia && (navigator.mediaDevices.getUserMedia = function (t) {
264
- var e = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
265
- return e ? new Promise(function (i, n) {
266
- e.call(navigator, t, i, n)
267
- }) : Promise.reject(new Error("浏览器不支持 getUserMedia !"))
268
- })
269
- }, t.getPermission = function () {
270
- return this.initUserMedia(), navigator.mediaDevices.getUserMedia({
271
- audio: !0
272
- }).then(function (t) {
273
- t.getTracks().forEach(function (t) {
274
- return t.stop()
275
- })
276
- })
277
- }, t
278
- }();
279
-
280
- function r(t, e, i) {
281
- for (var n = 0; n < i.length; n++) t.setUint8(e + n, i.charCodeAt(n))
282
- }
283
-
284
- e.default = n
285
- }]).default
286
- });
287
-
288
-
289
-