Skip to content

Commit cb47df9

Browse files
committed
chore: modify build .d.ts methods & rebuild lib
1 parent 02562e7 commit cb47df9

File tree

5 files changed

+114
-98
lines changed

5 files changed

+114
-98
lines changed

buildTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
12
// @ts-nocheck
23
import glob from 'npm:fast-glob@3.2.12'
34
import { Project } from 'https://deno.land/x/ts_morph/mod.ts'
@@ -24,7 +25,7 @@ const CONFIG_PATH = await Deno.realPath('./tsconfig.json')
2425
skipAddingFilesFromTsConfig: true,
2526
})
2627

27-
const files = await glob(['src/**/*.ts', 'src/**/*.vue'])
28+
const files = await glob(['src/**/*.vue'])
2829
const sourceFiles = []
2930

3031
let index = 1

lib/1llest-waveform-vue.mjs

Lines changed: 97 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var E = Object.defineProperty;
2-
var O = (a, e, t) => e in a ? E(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3-
var u = (a, e, t) => (O(a, typeof e != "symbol" ? e + "" : e, t), t);
4-
import { defineComponent as X, ref as h, onMounted as Y, watchEffect as m, onUnmounted as V, openBlock as q, createElementBlock as U, normalizeStyle as C, createVNode as j, Transition as G, withCtx as J, withDirectives as x, createElementVNode as v, vShow as A } from "vue";
1+
var P = Object.defineProperty;
2+
var O = (i, e, t) => e in i ? P(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3+
var u = (i, e, t) => (O(i, typeof e != "symbol" ? e + "" : e, t), t);
4+
import { defineComponent as X, ref as h, onMounted as Y, watchEffect as g, onUnmounted as V, openBlock as q, createElementBlock as U, createVNode as j, Transition as G, withCtx as J, withDirectives as x, createElementVNode as v, normalizeStyle as m, vShow as A } from "vue";
55
class K {
66
constructor(e) {
77
u(this, "props");
@@ -14,6 +14,8 @@ class K {
1414
return this.createFilterData();
1515
}
1616
get _audioDuration() {
17+
if (!this.audioBuffer)
18+
throw new Error("can not get duration before audio inited");
1719
return this.audioBuffer.duration;
1820
}
1921
async setupAudio() {
@@ -24,18 +26,18 @@ class K {
2426
this.audioBuffer = await this.audioCtx.decodeAudioData(t);
2527
}
2628
createFilterData() {
27-
const e = this.props.samplingRate, t = this.audioBuffer.numberOfChannels, i = [], s = [];
28-
for (let n = 0; n < t; n++)
29-
i.push(this.audioBuffer.getChannelData(n));
30-
for (let n = 0; n < e; n++) {
31-
const c = [0, 0];
29+
const e = this.props.samplingRate, t = this.audioBuffer.numberOfChannels, a = [], n = [];
30+
for (let s = 0; s < t; s++)
31+
a.push(this.audioBuffer.getChannelData(s));
32+
for (let s = 0; s < e; s++) {
33+
const l = [0, 0];
3234
for (let r = 0; r < t; r++) {
33-
const y = Math.floor(i[r].length / e);
34-
c[r] = i[r][n * y];
35+
const C = Math.floor(a[r].length / e);
36+
l[r] = a[r][s * C];
3537
}
36-
s.push(c);
38+
n.push(l);
3739
}
38-
return Promise.resolve(s);
40+
return Promise.resolve(n);
3941
}
4042
connectDestination() {
4143
this.createAudioBufferSourceNode(), this.disconnectDestination(), this.audioBufferSourceNode.connect(this.audioCtx.destination);
@@ -87,10 +89,10 @@ class Q extends K {
8789
}
8890
}
8991
class M {
90-
constructor(e, t, i) {
92+
constructor(e, t, a) {
9193
u(this, "canvasCtx");
92-
var s;
93-
this.canvas = e, this.props = t, this.filteredData = i, this.canvas = e, this.canvasCtx = (s = this.canvas) == null ? void 0 : s.getContext("2d"), this.props = t, this.filteredData = i;
94+
var n;
95+
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;
9496
}
9597
get _canvas() {
9698
return this.canvas;
@@ -114,15 +116,15 @@ class M {
114116
);
115117
}
116118
drawCanvasLines() {
117-
const { canvas: e, canvasCtx: t, filteredData: i } = this;
118-
i.forEach((s, n) => {
119-
const c = e.width / i.length, r = c * n - c / 2;
119+
const { canvas: e, canvasCtx: t, filteredData: a } = this;
120+
a.forEach((n, s) => {
121+
const l = e.width / a.length, r = l * s - l / 2;
120122
t.moveTo(
121123
r,
122-
e.height / 2 - Math.abs(s[0]) * e.height * 0.4
124+
e.height / 2 - Math.abs(n[0]) * e.height * 0.4
123125
), t.lineTo(
124126
r,
125-
e.height / 2 + Math.abs(s[0]) * e.height * 0.4
127+
e.height / 2 + Math.abs(n[0]) * e.height * 0.4
126128
);
127129
});
128130
}
@@ -131,10 +133,10 @@ class M {
131133
}
132134
}
133135
class Z extends M {
134-
constructor(t, i, s, n) {
135-
super(t, i, s);
136+
constructor(t, a, n, s) {
137+
super(t, a, n);
136138
u(this, "waveCanvas");
137-
this.waveCanvas = n;
139+
this.waveCanvas = s;
138140
}
139141
setCanvasBase() {
140142
this.canvas.width = this.waveCanvas.width, this.canvas.height = this.waveCanvas.height, this.canvas.style.opacity = "1";
@@ -143,26 +145,26 @@ class Z extends M {
143145
this.canvasCtx.lineWidth = this.props.lineWidth, this.canvasCtx.lineCap = this.props.lineCap, this.canvasCtx.strokeStyle = this.props.maskColor, this.canvasCtx.stroke();
144146
}
145147
}
146-
function W(a) {
147-
const e = Math.floor(a / 60), t = Math.floor(a % 60);
148+
function W(i) {
149+
const e = Math.floor(i / 60), t = Math.floor(i % 60);
148150
return `${e}:${t < 10 ? "0" : ""}${t}`;
149151
}
150-
function tt(a, e) {
151-
const t = at(() => B(a, e), 500);
152+
function tt(i, e) {
153+
const t = at(() => B(i, e), 500);
152154
document.addEventListener("scroll", () => t());
153155
}
154-
function et(a, e) {
155-
document.removeEventListener("scroll", () => B(a, e));
156+
function et(i, e) {
157+
document.removeEventListener("scroll", () => B(i, e));
156158
}
157-
function B(a, e) {
158-
const t = window.innerHeight, i = window.scrollY, s = window.pageYOffset + a.getBoundingClientRect().top;
159-
s >= i - t / 4 && s - i - t < t / 4 && e();
159+
function B(i, e) {
160+
const t = window.innerHeight, a = window.scrollY, n = window.pageYOffset + i.getBoundingClientRect().top;
161+
n >= a - t / 4 && n - a - t < t / 4 && e();
160162
}
161-
function at(a, e) {
163+
function at(i, e) {
162164
let t;
163165
return () => {
164166
t || (t = setTimeout(() => {
165-
a(), t = void 0;
167+
i(), t = void 0;
166168
}, e));
167169
};
168170
}
@@ -179,7 +181,8 @@ const it = /* @__PURE__ */ X({
179181
maskColor: { default: "#fff" },
180182
lazy: { type: Boolean, default: !0 },
181183
skeleton: { type: Boolean, default: !0 },
182-
skeletonColor: { default: "#232323" }
184+
skeletonColor: { default: "#232323" },
185+
interact: { type: Boolean, default: !0 }
183186
},
184187
emits: [
185188
"onInit",
@@ -189,66 +192,66 @@ const it = /* @__PURE__ */ X({
189192
"onFinish",
190193
"onClick"
191194
],
192-
setup(a, { expose: e, emit: t }) {
193-
const i = a, s = h(!1), n = h(null);
195+
setup(i, { expose: e, emit: t }) {
196+
const a = i, n = h(!1), s = h(null);
194197
Y(async () => {
195-
i.lazy ? (B(n.value, c), tt(
196-
n.value,
197-
c
198-
), m(async () => {
199-
s.value && await S();
198+
a.lazy ? (B(s.value, l), tt(
199+
s.value,
200+
l
201+
), g(async () => {
202+
n.value && await S();
200203
})) : await S();
201204
}), V(() => {
202-
i.lazy && et(n.value, c);
205+
a.lazy && et(s.value, l);
203206
});
204-
function c() {
205-
s.value = !0;
207+
function l() {
208+
n.value = !0;
206209
}
207-
const r = h(null), y = h(null), l = h(!1);
208-
let o, f, w;
210+
const r = h(null), C = h(null), c = h(!1);
211+
let o, f, y;
209212
async function S() {
210-
l.value || (t("onInit", !0), await T(), await Promise.all([b(), N()]), l.value = !0, t("onReady", l.value));
213+
c.value || (t("onInit", !0), await T(), await Promise.all([N(), b()]), c.value = !0, t("onReady", c.value));
211214
}
212215
async function T() {
213-
o = new Q(i), await o.setupAudio(), I();
216+
o = new Q(a), await o.setupAudio(), I();
214217
}
215-
async function b() {
218+
async function N() {
216219
f = new M(
217220
r.value,
218-
i,
221+
a,
219222
await o._filterData
220-
), f.setupCanvas(), m(() => {
221-
f._props = i, f.setCanvasStyle();
223+
), f.setupCanvas(), g(() => {
224+
f._props = a, f.setCanvasStyle();
222225
});
223226
}
224-
async function N() {
225-
w = new Z(
226-
y.value,
227-
i,
227+
async function b() {
228+
y = new Z(
229+
C.value,
230+
a,
228231
await o._filterData,
229232
f._canvas
230-
), w.setupCanvas(), m(() => {
231-
w._props = i, w.setCanvasStyle();
233+
), y.setupCanvas(), g(() => {
234+
y._props = a, y.setCanvasStyle();
232235
});
233236
}
234-
const g = h(0), p = h(0), _ = h(0);
237+
const w = h(0), p = h(0), _ = h(0);
235238
function k() {
236239
!o._playing || (requestAnimationFrame(k), p.value = o._currentTime, _.value = p.value / o._audioDuration * f._canvas.width);
237240
}
238241
function R(d) {
239-
!l.value || (g.value = d.layerX);
240-
}
241-
function $() {
242-
if (!l.value)
243-
return;
244-
_.value = g.value;
245-
const d = g.value / f._canvas.width * o._audioDuration;
246-
o.pick(d), p.value = d, t("onClick", n), t("onFinish", !1);
242+
!c.value || !a.interact || (w.value = d.layerX);
247243
}
248244
function z() {
249-
!l.value || (o.play(), t("onPlay", !0), k());
245+
if (!c.value || !a.interact)
246+
return;
247+
_.value = w.value;
248+
const d = w.value / f._canvas.width * o._audioDuration;
249+
o.pick(d), p.value = d, t("onClick", s), t("onFinish", !1);
250250
}
251251
function H() {
252+
!c.value || (o.play(), t("onPlay", !0), k());
253+
}
254+
function $() {
252255
o.replay(), t("onFinish", !1), t("onPlay", !0), k();
253256
}
254257
function D() {
@@ -258,45 +261,44 @@ const it = /* @__PURE__ */ X({
258261
t("onFinish", !0);
259262
}
260263
function I() {
261-
m(() => {
264+
g(() => {
262265
p.value < o._audioDuration || (D(), F());
263266
});
264267
}
265268
function L() {
266269
return W(p.value);
267270
}
268-
function P() {
271+
function E() {
269272
const d = o._audioDuration;
270273
return W(d);
271274
}
272275
return e({
273-
play: z,
276+
play: H,
274277
pause: D,
275-
replay: H,
278+
replay: $,
276279
getCurrentTime: L,
277-
getDuration: P
280+
getDuration: E
278281
}), (d, ot) => (q(), U("section", {
279282
id: "ill-wave-container",
280283
ref_key: "waveformContainer",
281-
ref: n,
282-
style: C(`${l.value ? "cursor: pointer" : "cursor: progress;"}`),
284+
ref: s,
283285
onMousemove: R,
284-
onClick: $
286+
onClick: z
285287
}, [
286288
j(G, { name: "fade" }, {
287289
default: J(() => [
288290
x(v("div", {
289291
id: "ill-skeleton",
290-
style: C(`background-color: ${a.skeletonColor}`)
292+
style: m(`background-color: ${i.skeletonColor}`)
291293
}, [
292294
x(v("div", {
293295
id: "ill-skeleton__load",
294-
style: C(`background-color: ${a.skeletonColor}`)
296+
style: m(`background-color: ${i.skeletonColor}`)
295297
}, null, 4), [
296-
[A, !l.value]
298+
[A, !c.value]
297299
])
298300
], 4), [
299-
[A, i.skeleton && !l.value]
301+
[A, a.skeleton && !c.value]
300302
])
301303
]),
302304
_: 1
@@ -308,34 +310,34 @@ const it = /* @__PURE__ */ X({
308310
}, null, 512),
309311
v("div", {
310312
id: "ill-waveMask-container",
311-
style: C(`width:${_.value}px;`)
313+
style: m(`width:${_.value}px;`)
312314
}, [
313315
v("canvas", {
314316
id: "ill-waveMask",
315317
ref_key: "maskRef",
316-
ref: y
318+
ref: C
317319
}, null, 512)
318320
], 4),
319321
x(v("div", {
320322
id: "ill-cursor",
321-
style: C(`width:${i.cursorWidth}px; transform: translateX(${g.value}px);background-color: ${i.cursorColor}; `)
323+
style: m(`width:${a.cursorWidth}px; transform: translateX(${w.value}px);background-color: ${a.cursorColor}; `)
322324
}, null, 4), [
323-
[A, l.value]
325+
[A, c.value && a.interact]
324326
])
325-
], 36));
327+
], 544));
326328
}
327329
});
328-
const st = (a, e) => {
329-
const t = a.__vccOpts || a;
330-
for (const [i, s] of e)
331-
t[i] = s;
330+
const nt = (i, e) => {
331+
const t = i.__vccOpts || i;
332+
for (const [a, n] of e)
333+
t[a] = n;
332334
return t;
333-
}, nt = /* @__PURE__ */ st(it, [["__scopeId", "data-v-528b7817"]]), lt = {
334-
install: (a) => {
335-
a.component("IllestWaveform", nt);
335+
}, st = /* @__PURE__ */ nt(it, [["__scopeId", "data-v-5260ed6e"]]), lt = {
336+
install: (i) => {
337+
i.component("IllestWaveform", st);
336338
}
337339
};
338340
export {
339-
nt as IllestWaveform,
341+
st as IllestWaveform,
340342
lt as default
341343
};

0 commit comments

Comments
 (0)