1
1
var $ = Object . defineProperty ;
2
2
var I = ( i , e , t ) => e in i ? $ ( i , e , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : t } ) : i [ e ] = t ;
3
- var u = ( i , e , t ) => ( I ( i , typeof e != "symbol" ? e + "" : e , t ) , t ) ;
4
- import { defineComponent as L , ref as d , onMounted as E , watchEffect as m , onUnmounted as O , openBlock as P , createElementBlock as X , normalizeStyle as y , createVNode as Y , Transition as V , withCtx as q , withDirectives as _ , createElementVNode as C , vShow as A } from "vue" ;
3
+ var l = ( i , e , t ) => ( I ( i , typeof e != "symbol" ? e + "" : e , t ) , t ) ;
4
+ import { defineComponent as L , ref as d , onMounted as E , watchEffect as m , onUnmounted as P , openBlock as O , createElementBlock as X , normalizeStyle as y , createVNode as Y , Transition as V , withCtx as q , withDirectives as _ , createElementVNode as C , vShow as k } from "vue" ;
5
5
class U {
6
6
constructor ( e , t , a ) {
7
- u ( this , "canvasCtx" ) ;
7
+ l ( this , "canvasCtx" ) ;
8
8
var n ;
9
9
this . canvas = e , this . props = t , this . filteredData = a , this . canvas = e , this . canvasCtx = ( n = this . canvas ) == null ? void 0 : n . getContext ( "2d" ) , this . props = t , this . filteredData = a ;
10
10
}
@@ -32,12 +32,12 @@ class U {
32
32
drawCanvasLines ( ) {
33
33
const { canvas : e , canvasCtx : t , filteredData : a } = this ;
34
34
a . forEach ( ( n , o ) => {
35
- const c = e . width / a . length , l = c * o - c / 2 ;
35
+ const c = e . width / a . length , u = c * o - c / 2 ;
36
36
t . moveTo (
37
- l ,
37
+ u ,
38
38
e . height / 2 - Math . abs ( n [ 0 ] ) * e . height * 0.4
39
39
) , t . lineTo (
40
- l ,
40
+ u ,
41
41
e . height / 2 + Math . abs ( n [ 0 ] ) * e . height * 0.4
42
42
) ;
43
43
} ) ;
@@ -57,12 +57,12 @@ class U {
57
57
}
58
58
class j {
59
59
constructor ( e ) {
60
- u ( this , "props" ) ;
61
- u ( this , "audioCtx" ) ;
62
- u ( this , "audioBuffer" ) ;
63
- u ( this , "audioBufferSourceNode" ) ;
64
- u ( this , "filterData" ) ;
65
- u ( this , "arrayBuffer" ) ;
60
+ l ( this , "props" ) ;
61
+ l ( this , "audioCtx" ) ;
62
+ l ( this , "audioBuffer" ) ;
63
+ l ( this , "audioBufferSourceNode" ) ;
64
+ l ( this , "filterData" ) ;
65
+ l ( this , "arrayBuffer" ) ;
66
66
this . props = e , this . audioCtx = new AudioContext ( ) ;
67
67
}
68
68
get _filterData ( ) {
@@ -93,9 +93,9 @@ class j {
93
93
a . push ( this . audioBuffer . getChannelData ( o ) ) ;
94
94
for ( let o = 0 ; o < e ; o ++ ) {
95
95
const c = [ 0 , 0 ] ;
96
- for ( let l = 0 ; l < t ; l ++ ) {
97
- const r = Math . floor ( a [ l ] . length / e ) ;
98
- c [ l ] = a [ l ] [ o * r ] ;
96
+ for ( let u = 0 ; u < t ; u ++ ) {
97
+ const r = Math . floor ( a [ u ] . length / e ) ;
98
+ c [ u ] = a [ u ] [ o * r ] ;
99
99
}
100
100
n . push ( c ) ;
101
101
}
@@ -114,10 +114,10 @@ class j {
114
114
class G extends j {
115
115
constructor ( t ) {
116
116
super ( t ) ;
117
- u ( this , "startAt" ) ;
118
- u ( this , "pauseAt" ) ;
119
- u ( this , "pickAt" ) ;
120
- u ( this , "playing" ) ;
117
+ l ( this , "startAt" ) ;
118
+ l ( this , "pauseAt" ) ;
119
+ l ( this , "pickAt" ) ;
120
+ l ( this , "playing" ) ;
121
121
this . startAt = 0 , this . pauseAt = 0 , this . pickAt = 0 , this . playing = ! 1 ;
122
122
}
123
123
get _playing ( ) {
@@ -135,11 +135,14 @@ class G extends j {
135
135
this . stop ( ) , this . pauseAt = t ;
136
136
}
137
137
pick ( t ) {
138
- t <= 0 && ( t = 0 ) , t >= this . _audioDuration && ( t = this . _audioDuration ) , this . pickAt = t , this . playing && ( this . stopSource ( ) , this . play ( ) ) ;
138
+ this . pickAt = t , this . playing && ( this . stopSource ( ) , this . play ( ) ) ;
139
139
}
140
140
replay ( ) {
141
141
this . audioBufferSourceNode && this . stop ( ) , this . play ( ) ;
142
142
}
143
+ finish ( ) {
144
+ this . pauseAt = 0 , this . stop ( ) ;
145
+ }
143
146
stop ( ) {
144
147
this . stopSource ( ) , this . initializeState ( ) ;
145
148
}
@@ -150,18 +153,18 @@ class G extends j {
150
153
this . playing = ! 1 , this . startAt = 0 , this . pauseAt = 0 , this . pickAt = 0 ;
151
154
}
152
155
}
153
- function D ( i ) {
156
+ function B ( i ) {
154
157
const e = Math . floor ( i / 60 ) , t = Math . floor ( i % 60 ) ;
155
158
return `${ e } :${ t < 10 ? "0" : "" } ${ t } ` ;
156
159
}
157
160
function J ( i , e ) {
158
- const t = Q ( ( ) => k ( i , e ) , 500 ) ;
161
+ const t = Q ( ( ) => A ( i , e ) , 500 ) ;
159
162
document . addEventListener ( "scroll" , ( ) => t ( ) ) ;
160
163
}
161
164
function K ( i , e ) {
162
- document . removeEventListener ( "scroll" , ( ) => k ( i , e ) ) ;
165
+ document . removeEventListener ( "scroll" , ( ) => A ( i , e ) ) ;
163
166
}
164
- function k ( i , e ) {
167
+ function A ( i , e ) {
165
168
const t = window . innerHeight , a = window . scrollY , n = window . pageYOffset + i . getBoundingClientRect ( ) . top ;
166
169
n >= a - t / 4 && n - a - t < t / 4 && e ( ) ;
167
170
}
@@ -201,86 +204,86 @@ const Z = /* @__PURE__ */ L({
201
204
setup ( i , { expose : e , emit : t } ) {
202
205
const a = i , n = d ( ! 1 ) , o = d ( null ) ;
203
206
E ( async ( ) => {
204
- a . lazy ? ( k ( o . value , c ) , J (
207
+ a . lazy ? ( A ( o . value , c ) , J (
205
208
o . value ,
206
209
c
207
210
) , m ( async ( ) => {
208
211
n . value && await x ( ) ;
209
212
} ) ) : await x ( ) ;
210
- } ) , O ( ( ) => {
213
+ } ) , P ( ( ) => {
211
214
a . lazy && K ( o . value , c ) ;
212
215
} ) ;
213
216
function c ( ) {
214
217
n . value = ! 0 ;
215
218
}
216
- const l = d ( null ) , r = d ( ! 1 ) ;
217
- let s , h ;
219
+ const u = d ( null ) , r = d ( ! 1 ) ;
220
+ let s , f ;
218
221
async function x ( ) {
219
- r . value || ( t ( "onInit" , ! 0 ) , await S ( ) , await W ( ) , r . value = ! 0 , t ( "onReady" , r . value ) ) ;
222
+ r . value || ( t ( "onInit" , ! 0 ) , await S ( ) , await D ( ) , r . value = ! 0 , t ( "onReady" , r . value ) ) ;
220
223
}
221
224
async function S ( ) {
222
225
s = new G ( a ) , await s . fetchAudioFile ( ) , t ( "onFetched" , ! 0 ) , await s . setupAudio ( ) , R ( ) ;
223
226
}
224
- async function W ( ) {
225
- h = new U (
226
- l . value ,
227
+ async function D ( ) {
228
+ f = new U (
229
+ u . value ,
227
230
a ,
228
231
s . _filterData
229
- ) , h . setupCanvas ( ) , m ( ( ) => {
230
- h . _props = a , h . setWaveStyle ( w . value ) ;
232
+ ) , f . setupCanvas ( ) , m ( ( ) => {
233
+ f . _props = a , f . setWaveStyle ( w . value ) ;
231
234
} ) ;
232
235
}
233
- const v = d ( 0 ) , p = d ( 0 ) , w = d ( 0 ) ;
236
+ const p = d ( 0 ) , v = d ( 0 ) , w = d ( 0 ) ;
234
237
function g ( ) {
235
- ! s . _playing || ( requestAnimationFrame ( g ) , p . value = s . _currentTime , w . value = p . value / s . _audioDuration * h . _canvas . width ) ;
238
+ ! s . _playing || ( requestAnimationFrame ( g ) , v . value = s . _currentTime , w . value = v . value / s . _audioDuration * f . _canvas . width ) ;
236
239
}
237
- function T ( f ) {
238
- ! r . value || ! a . interact || ( f . layerX <= 0 ? v . value = 0 : f . layerX >= h . _canvas . width ? v . value = h . _canvas . width : v . value = f . layerX ) ;
240
+ function W ( h ) {
241
+ ! r . value || ! a . interact || ( h . layerX <= 0 ? p . value = 0 : h . layerX >= f . _canvas . width ? p . value = f . _canvas . width : p . value = h . layerX ) ;
239
242
}
240
- function N ( ) {
243
+ function T ( ) {
241
244
if ( ! r . value || ! a . interact )
242
245
return ;
243
- w . value = v . value ;
244
- const f = v . value / h . _canvas . width * s . _audioDuration ;
245
- s . pick ( f ) , p . value = f , t ( "onClick" , o ) , t ( "onFinish" , ! 1 ) ;
246
+ w . value = p . value ;
247
+ const h = p . value / f . _canvas . width * s . _audioDuration ;
248
+ s . pick ( h ) , v . value = h , t ( "onClick" , o ) , t ( "onFinish" , ! 1 ) ;
246
249
}
247
250
function b ( ) {
248
251
! r . value || ( s . play ( ) , t ( "onPlay" , ! 0 ) , g ( ) ) ;
249
252
}
250
- function F ( ) {
253
+ function N ( ) {
251
254
s . replay ( ) , t ( "onFinish" , ! 1 ) , t ( "onPlay" , ! 0 ) , g ( ) ;
252
255
}
253
- function B ( ) {
256
+ function F ( ) {
254
257
s . pause ( ) , t ( "onPause" , ! 1 ) ;
255
258
}
256
259
function M ( ) {
257
- t ( "onFinish" , ! 0 ) ;
260
+ s . finish ( ) , t ( "onPlay" , ! 1 ) , t ( "onFinish" , ! 0 ) ;
258
261
}
259
262
function R ( ) {
260
263
m ( ( ) => {
261
- p . value < s . _audioDuration || ( B ( ) , M ( ) ) ;
264
+ v . value <= s . _audioDuration || M ( ) ;
262
265
} ) ;
263
266
}
264
267
function z ( ) {
265
- return D ( p . value ) ;
268
+ return B ( v . value ) ;
266
269
}
267
270
function H ( ) {
268
- const f = s . _audioDuration ;
269
- return D ( f ) ;
271
+ const h = s . _audioDuration ;
272
+ return B ( h ) ;
270
273
}
271
274
return e ( {
272
275
play : b ,
273
- pause : B ,
274
- replay : F ,
276
+ pause : F ,
277
+ replay : N ,
275
278
getCurrentTime : z ,
276
279
getDuration : H
277
- } ) , ( f , at ) => ( P ( ) , X ( "section" , {
280
+ } ) , ( h , at ) => ( O ( ) , X ( "section" , {
278
281
id : "illest-wave-container" ,
279
282
ref_key : "waveformContainer" ,
280
283
ref : o ,
281
284
style : y ( `${ r . value && i . interact ? "cursor: pointer" : "" } ` ) ,
282
- onMousemove : T ,
283
- onClick : N
285
+ onMousemove : W ,
286
+ onClick : T
284
287
} , [
285
288
Y ( V , { name : "fade" } , {
286
289
default : q ( ( ) => [
@@ -292,24 +295,24 @@ const Z = /* @__PURE__ */ L({
292
295
id : "illest-skeleton__load" ,
293
296
style : y ( `background-color: ${ i . skeletonColor } ` )
294
297
} , null , 4 ) , [
295
- [ A , ! r . value ]
298
+ [ k , ! r . value ]
296
299
] )
297
300
] , 4 ) , [
298
- [ A , a . skeleton && ! r . value ]
301
+ [ k , a . skeleton && ! r . value ]
299
302
] )
300
303
] ) ,
301
304
_ : 1
302
305
} ) ,
303
306
C ( "canvas" , {
304
307
id : "illest-wave" ,
305
308
ref_key : "waveRef" ,
306
- ref : l
309
+ ref : u
307
310
} , null , 512 ) ,
308
311
_ ( C ( "div" , {
309
312
id : "illest-cursor" ,
310
- style : y ( `width:${ a . cursorWidth } px; transform: translateX(${ v . value } px);background-color: ${ a . cursorColor } ; ` )
313
+ style : y ( `width:${ a . cursorWidth } px; transform: translateX(${ p . value } px);background-color: ${ a . cursorColor } ; ` )
311
314
} , null , 4 ) , [
312
- [ A , r . value && a . interact ]
315
+ [ k , r . value && a . interact ]
313
316
] )
314
317
] , 36 ) ) ;
315
318
}
@@ -319,7 +322,7 @@ const tt = (i, e) => {
319
322
for ( const [ a , n ] of e )
320
323
t [ a ] = n ;
321
324
return t ;
322
- } , et = /* @__PURE__ */ tt ( Z , [ [ "__scopeId" , "data-v-10d3d361 " ] ] ) , ot = {
325
+ } , et = /* @__PURE__ */ tt ( Z , [ [ "__scopeId" , "data-v-020db612 " ] ] ) , ot = {
323
326
install : ( i ) => {
324
327
i . component ( "IllestWaveform" , et ) ;
325
328
}
0 commit comments