waveframe 0.2.2 → 0.3.1
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/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +3 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +562 -0
- package/dist/index.d.ts +562 -2
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/package.json +8 -8
- package/dist/src/App.d.ts +0 -2
- package/dist/src/__tests__/WaveframePlayer.test.d.ts +0 -1
- package/dist/src/atoms/CodeBlock.d.ts +0 -9
- package/dist/src/components/WaveframePlayer.d.ts +0 -83
- package/dist/src/core/PeakAnalyzer.d.ts +0 -41
- package/dist/src/core/PlayerCore.d.ts +0 -92
- package/dist/src/core/WaveframeEngine.d.ts +0 -122
- package/dist/src/hooks/usePersistentSettings.d.ts +0 -1
- package/dist/src/hooks/useResampledPeaks.d.ts +0 -1
- package/dist/src/hooks/useResizeObserver.d.ts +0 -1
- package/dist/src/hooks/useWaveframe.d.ts +0 -51
- package/dist/src/hooks/useWaveframeStore.d.ts +0 -27
- package/dist/src/index.d.ts +0 -7
- package/dist/src/main.d.ts +0 -0
- package/dist/src/molecules/ArtworkOverlay.d.ts +0 -20
- package/dist/src/organisms/SettingsPanel.d.ts +0 -29
- package/dist/src/organisms/Waveform.d.ts +0 -15
- package/dist/src/types/index.d.ts +0 -75
- package/dist/src/utils/audio.d.ts +0 -33
- package/dist/src/utils/index.d.ts +0 -13
- package/dist/waveframe.cjs +0 -7
- package/dist/waveframe.css +0 -3
- package/dist/waveframe.es.js +0 -603
package/dist/waveframe.es.js
DELETED
|
@@ -1,603 +0,0 @@
|
|
|
1
|
-
import { memo as e, useEffect as t, useMemo as n, useRef as r, useState as i, useSyncExternalStore as a } from "react";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
4
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
5
|
-
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
6
|
-
}), c = class {
|
|
7
|
-
audio;
|
|
8
|
-
listeners = /* @__PURE__ */ new Set();
|
|
9
|
-
_state;
|
|
10
|
-
constructor() {
|
|
11
|
-
this.audio = new Audio(), this._state = {
|
|
12
|
-
isPlaying: !1,
|
|
13
|
-
currentTime: 0,
|
|
14
|
-
duration: 0,
|
|
15
|
-
volume: 1,
|
|
16
|
-
muted: !1
|
|
17
|
-
}, this.initListeners();
|
|
18
|
-
}
|
|
19
|
-
initListeners() {
|
|
20
|
-
this.audio.addEventListener("play", () => this.updateState({ isPlaying: !0 })), this.audio.addEventListener("pause", () => this.updateState({ isPlaying: !1 })), this.audio.addEventListener("timeupdate", () => this.updateState({ currentTime: this.audio.currentTime })), this.audio.addEventListener("durationchange", () => this.updateState({ duration: this.audio.duration })), this.audio.addEventListener("volumechange", () => this.updateState({
|
|
21
|
-
volume: this.audio.volume,
|
|
22
|
-
muted: this.audio.muted
|
|
23
|
-
})), this.audio.addEventListener("ended", () => this.updateState({ isPlaying: !1 }));
|
|
24
|
-
}
|
|
25
|
-
updateState(e) {
|
|
26
|
-
this._state = {
|
|
27
|
-
...this._state,
|
|
28
|
-
...e
|
|
29
|
-
}, this.notify();
|
|
30
|
-
}
|
|
31
|
-
notify() {
|
|
32
|
-
this.listeners.forEach((e) => e(this._state));
|
|
33
|
-
}
|
|
34
|
-
subscribe(e) {
|
|
35
|
-
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
36
|
-
}
|
|
37
|
-
get state() {
|
|
38
|
-
return this._state;
|
|
39
|
-
}
|
|
40
|
-
setSource(e) {
|
|
41
|
-
this.audio.src = e, this.audio.load();
|
|
42
|
-
}
|
|
43
|
-
play() {
|
|
44
|
-
return this.audio.play();
|
|
45
|
-
}
|
|
46
|
-
pause() {
|
|
47
|
-
this.audio.pause();
|
|
48
|
-
}
|
|
49
|
-
togglePlay() {
|
|
50
|
-
this._state.isPlaying ? this.pause() : this.play();
|
|
51
|
-
}
|
|
52
|
-
seek(e) {
|
|
53
|
-
this.audio.currentTime = e;
|
|
54
|
-
}
|
|
55
|
-
setVolume(e) {
|
|
56
|
-
this.audio.volume = e;
|
|
57
|
-
}
|
|
58
|
-
setMuted(e) {
|
|
59
|
-
this.audio.muted = e;
|
|
60
|
-
}
|
|
61
|
-
dispose() {
|
|
62
|
-
this.pause(), this.audio.src = "", this.listeners.clear();
|
|
63
|
-
}
|
|
64
|
-
}, l = class {
|
|
65
|
-
audioCtx = null;
|
|
66
|
-
constructor() {}
|
|
67
|
-
getContext() {
|
|
68
|
-
return this.audioCtx ||= new (window.AudioContext || window.webkitAudioContext)(), this.audioCtx;
|
|
69
|
-
}
|
|
70
|
-
async generatePeaks(e, t = 512) {
|
|
71
|
-
try {
|
|
72
|
-
let n;
|
|
73
|
-
if (typeof e == "string") {
|
|
74
|
-
let t = await fetch(e);
|
|
75
|
-
if (!t.ok) throw Error(`Failed to fetch audio: ${t.statusText}`);
|
|
76
|
-
n = await t.arrayBuffer();
|
|
77
|
-
} else n = await e.arrayBuffer();
|
|
78
|
-
let r = (await this.getContext().decodeAudioData(n)).getChannelData(0), i = Math.floor(r.length / t), a = [];
|
|
79
|
-
for (let e = 0; e < t; e++) {
|
|
80
|
-
let t = 0, n = e * i, o = n + i;
|
|
81
|
-
for (let e = n; e < o; e++) {
|
|
82
|
-
let n = Math.abs(r[e]);
|
|
83
|
-
n > t && (t = n);
|
|
84
|
-
}
|
|
85
|
-
a.push(t);
|
|
86
|
-
}
|
|
87
|
-
let o = Math.max(...a);
|
|
88
|
-
return a.map((e) => e / (o || 1));
|
|
89
|
-
} catch (e) {
|
|
90
|
-
throw console.error("PeakAnalyzer Error:", e), e;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
dispose() {
|
|
94
|
-
this.audioCtx &&= (this.audioCtx.close(), null);
|
|
95
|
-
}
|
|
96
|
-
}, u = class {
|
|
97
|
-
player;
|
|
98
|
-
analyzer;
|
|
99
|
-
listeners = /* @__PURE__ */ new Set();
|
|
100
|
-
_state;
|
|
101
|
-
_media = null;
|
|
102
|
-
_objectUrl = null;
|
|
103
|
-
constructor() {
|
|
104
|
-
this.player = new c(), this.analyzer = new l(), this._state = {
|
|
105
|
-
...this.player.state,
|
|
106
|
-
peaks: [],
|
|
107
|
-
isAnalyzing: !1,
|
|
108
|
-
error: null
|
|
109
|
-
}, this.player.subscribe((e) => {
|
|
110
|
-
this.updateState({ ...e });
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
updateState(e) {
|
|
114
|
-
this._state = {
|
|
115
|
-
...this._state,
|
|
116
|
-
...e
|
|
117
|
-
}, this.notify();
|
|
118
|
-
}
|
|
119
|
-
notify() {
|
|
120
|
-
this.listeners.forEach((e) => e(this._state));
|
|
121
|
-
}
|
|
122
|
-
subscribe(e) {
|
|
123
|
-
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
124
|
-
}
|
|
125
|
-
getSnapshot() {
|
|
126
|
-
return this._state;
|
|
127
|
-
}
|
|
128
|
-
revokeOldSource() {
|
|
129
|
-
this._objectUrl &&= (URL.revokeObjectURL(this._objectUrl), null);
|
|
130
|
-
}
|
|
131
|
-
load(e, t) {
|
|
132
|
-
if (this._media !== e) {
|
|
133
|
-
this.revokeOldSource(), this._media = e;
|
|
134
|
-
let n;
|
|
135
|
-
typeof e == "string" ? n = e : (this._objectUrl = URL.createObjectURL(e), n = this._objectUrl), this.player.setSource(n);
|
|
136
|
-
let r = t && t.length > 0;
|
|
137
|
-
this.updateState({
|
|
138
|
-
peaks: t || [],
|
|
139
|
-
isAnalyzing: !1,
|
|
140
|
-
error: null
|
|
141
|
-
}), r || this.analyze();
|
|
142
|
-
} else t && t !== this._state.peaks && this.updateState({ peaks: t });
|
|
143
|
-
}
|
|
144
|
-
async analyze(e = 512) {
|
|
145
|
-
if (!this._media) {
|
|
146
|
-
this.updateState({ error: "No media loaded to analyze" });
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this.updateState({
|
|
150
|
-
isAnalyzing: !0,
|
|
151
|
-
error: null
|
|
152
|
-
});
|
|
153
|
-
try {
|
|
154
|
-
let t = await this.analyzer.generatePeaks(this._media, e);
|
|
155
|
-
this.updateState({
|
|
156
|
-
peaks: t,
|
|
157
|
-
isAnalyzing: !1
|
|
158
|
-
});
|
|
159
|
-
} catch (e) {
|
|
160
|
-
this.updateState({
|
|
161
|
-
isAnalyzing: !1,
|
|
162
|
-
error: e instanceof Error ? e.message : "Analysis failed"
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
togglePlay() {
|
|
167
|
-
this.player.togglePlay();
|
|
168
|
-
}
|
|
169
|
-
play() {
|
|
170
|
-
this.player.play();
|
|
171
|
-
}
|
|
172
|
-
pause() {
|
|
173
|
-
this.player.pause();
|
|
174
|
-
}
|
|
175
|
-
seek(e) {
|
|
176
|
-
let { duration: t } = this._state;
|
|
177
|
-
t && this.player.seek(e * t);
|
|
178
|
-
}
|
|
179
|
-
setVolume(e) {
|
|
180
|
-
this.player.setVolume(e);
|
|
181
|
-
}
|
|
182
|
-
setMuted(e) {
|
|
183
|
-
this.player.setMuted(e);
|
|
184
|
-
}
|
|
185
|
-
dispose() {
|
|
186
|
-
this.revokeOldSource(), this.player.dispose(), this.analyzer.dispose(), this.listeners.clear();
|
|
187
|
-
}
|
|
188
|
-
}, d = (e) => a((t) => e.subscribe(t), () => e.getSnapshot()), f = (e, r = {}) => {
|
|
189
|
-
let { peaks: i, engine: a } = r, o = n(() => a || new u(), [a]), s = a || o, c = d(s);
|
|
190
|
-
return t(() => {
|
|
191
|
-
e && s.load(e, i);
|
|
192
|
-
}, [
|
|
193
|
-
s,
|
|
194
|
-
e,
|
|
195
|
-
i
|
|
196
|
-
]), t(() => () => {
|
|
197
|
-
a || o.dispose();
|
|
198
|
-
}, [o, a]), {
|
|
199
|
-
state: c,
|
|
200
|
-
engine: s,
|
|
201
|
-
togglePlay: () => s.togglePlay(),
|
|
202
|
-
play: () => s.play(),
|
|
203
|
-
pause: () => s.pause(),
|
|
204
|
-
seek: (e) => s.seek(e),
|
|
205
|
-
setVolume: (e) => s.setVolume(e),
|
|
206
|
-
setMuted: (e) => s.setMuted(e),
|
|
207
|
-
analyze: (e) => s.analyze(e)
|
|
208
|
-
};
|
|
209
|
-
}, p = async (e, t = 512) => {
|
|
210
|
-
let n = new l();
|
|
211
|
-
try {
|
|
212
|
-
return await n.generatePeaks(e, t);
|
|
213
|
-
} finally {
|
|
214
|
-
n.dispose();
|
|
215
|
-
}
|
|
216
|
-
}, m = async (e) => {
|
|
217
|
-
let t = await (await fetch(e)).blob();
|
|
218
|
-
return URL.createObjectURL(t);
|
|
219
|
-
}, h = (e) => {
|
|
220
|
-
e && e.startsWith("blob:") && URL.revokeObjectURL(e);
|
|
221
|
-
}, g = (e) => isNaN(e) ? "0:00" : `${Math.floor(e / 60)}:${Math.floor(e % 60).toString().padStart(2, "0")}`, _ = (e, t) => {
|
|
222
|
-
if (e.length === 0) return [];
|
|
223
|
-
if (e.length === t) return e;
|
|
224
|
-
let n = Array(t), r = e.length / t;
|
|
225
|
-
if (r > 1) for (let i = 0; i < t; i++) {
|
|
226
|
-
let t = 0, a = Math.floor(i * r), o = Math.floor((i + 1) * r);
|
|
227
|
-
for (let n = a; n < o; n++) e[n] > t && (t = e[n]);
|
|
228
|
-
n[i] = t;
|
|
229
|
-
}
|
|
230
|
-
else for (let i = 0; i < t; i++) {
|
|
231
|
-
let t = i * r, a = Math.floor(t), o = Math.min(a + 1, e.length - 1), s = t - a;
|
|
232
|
-
n[i] = e[a] + (e[o] - e[a]) * s;
|
|
233
|
-
}
|
|
234
|
-
return n;
|
|
235
|
-
}, v = (e) => e.split("\n").map((e) => {
|
|
236
|
-
let t = e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), n = {}, r = 0, i = (e, t) => {
|
|
237
|
-
let i = `__TOKEN_${r++}__`;
|
|
238
|
-
return n[i] = `<span class="${t}">${e}</span>`, i;
|
|
239
|
-
};
|
|
240
|
-
return t = t.replace(/("(?:[^"\\]|\\.)*")/g, (e) => i(e, "text-[#ce9178]")), t = t.replace(/\b(\d+(\.\d+)?)\b/g, (e) => i(e, "text-[#b5cea8]")), t = t.replace(/\b(WaveframePlayer)\b/g, (e) => i(e, "text-[#4ec9b0]")), t = t.replace(/\b([a-z][a-zA-Z0-9]+)(?==)/g, (e) => i(e, "text-[#9cdcfe]")), t = t.replace(/(<|>|\{|\}|\/|:|,)/g, "<span class=\"text-gray-500\">$1</span>"), Object.entries(n).forEach(([e, n]) => {
|
|
241
|
-
t = t.replace(e, n);
|
|
242
|
-
}), t;
|
|
243
|
-
}), y = (e, t) => n(() => _(e, t), [e, t]), b = (e) => {
|
|
244
|
-
let [n, r] = i(0);
|
|
245
|
-
return t(() => {
|
|
246
|
-
if (!e.current) return;
|
|
247
|
-
let t = new ResizeObserver((e) => {
|
|
248
|
-
for (let t of e) r(t.contentRect.width);
|
|
249
|
-
});
|
|
250
|
-
return t.observe(e.current), () => t.disconnect();
|
|
251
|
-
}, [e]), n;
|
|
252
|
-
}, x = /* @__PURE__ */ o(((e) => {
|
|
253
|
-
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
254
|
-
function r(e, n, r) {
|
|
255
|
-
var i = null;
|
|
256
|
-
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
257
|
-
else r = n;
|
|
258
|
-
return n = r.ref, {
|
|
259
|
-
$$typeof: t,
|
|
260
|
-
type: e,
|
|
261
|
-
key: i,
|
|
262
|
-
ref: n === void 0 ? null : n,
|
|
263
|
-
props: r
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
267
|
-
})), S = /* @__PURE__ */ o(((e) => {
|
|
268
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
269
|
-
function t(e) {
|
|
270
|
-
if (e == null) return null;
|
|
271
|
-
if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
|
|
272
|
-
if (typeof e == "string") return e;
|
|
273
|
-
switch (e) {
|
|
274
|
-
case v: return "Fragment";
|
|
275
|
-
case b: return "Profiler";
|
|
276
|
-
case y: return "StrictMode";
|
|
277
|
-
case w: return "Suspense";
|
|
278
|
-
case T: return "SuspenseList";
|
|
279
|
-
case O: return "Activity";
|
|
280
|
-
}
|
|
281
|
-
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
282
|
-
case _: return "Portal";
|
|
283
|
-
case S: return e.displayName || "Context";
|
|
284
|
-
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
285
|
-
case C:
|
|
286
|
-
var n = e.render;
|
|
287
|
-
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
288
|
-
case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
289
|
-
case D:
|
|
290
|
-
n = e._payload, e = e._init;
|
|
291
|
-
try {
|
|
292
|
-
return t(e(n));
|
|
293
|
-
} catch {}
|
|
294
|
-
}
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
function n(e) {
|
|
298
|
-
return "" + e;
|
|
299
|
-
}
|
|
300
|
-
function r(e) {
|
|
301
|
-
try {
|
|
302
|
-
n(e);
|
|
303
|
-
var t = !1;
|
|
304
|
-
} catch {
|
|
305
|
-
t = !0;
|
|
306
|
-
}
|
|
307
|
-
if (t) {
|
|
308
|
-
t = console;
|
|
309
|
-
var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
310
|
-
return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
function i(e) {
|
|
314
|
-
if (e === v) return "<>";
|
|
315
|
-
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
316
|
-
try {
|
|
317
|
-
var n = t(e);
|
|
318
|
-
return n ? "<" + n + ">" : "<...>";
|
|
319
|
-
} catch {
|
|
320
|
-
return "<...>";
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function a() {
|
|
324
|
-
var e = A.A;
|
|
325
|
-
return e === null ? null : e.getOwner();
|
|
326
|
-
}
|
|
327
|
-
function o() {
|
|
328
|
-
return Error("react-stack-top-frame");
|
|
329
|
-
}
|
|
330
|
-
function c(e) {
|
|
331
|
-
if (j.call(e, "key")) {
|
|
332
|
-
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
333
|
-
if (t && t.isReactWarning) return !1;
|
|
334
|
-
}
|
|
335
|
-
return e.key !== void 0;
|
|
336
|
-
}
|
|
337
|
-
function l(e, t) {
|
|
338
|
-
function n() {
|
|
339
|
-
P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
|
|
340
|
-
}
|
|
341
|
-
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
342
|
-
get: n,
|
|
343
|
-
configurable: !0
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
function u() {
|
|
347
|
-
var e = t(this.type);
|
|
348
|
-
return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
|
|
349
|
-
}
|
|
350
|
-
function d(e, t, n, r, i, a) {
|
|
351
|
-
var o = n.ref;
|
|
352
|
-
return e = {
|
|
353
|
-
$$typeof: g,
|
|
354
|
-
type: e,
|
|
355
|
-
key: t,
|
|
356
|
-
props: n,
|
|
357
|
-
_owner: r
|
|
358
|
-
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
359
|
-
enumerable: !1,
|
|
360
|
-
value: null
|
|
361
|
-
}) : Object.defineProperty(e, "ref", {
|
|
362
|
-
enumerable: !1,
|
|
363
|
-
get: u
|
|
364
|
-
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
365
|
-
configurable: !1,
|
|
366
|
-
enumerable: !1,
|
|
367
|
-
writable: !0,
|
|
368
|
-
value: 0
|
|
369
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
370
|
-
configurable: !1,
|
|
371
|
-
enumerable: !1,
|
|
372
|
-
writable: !0,
|
|
373
|
-
value: null
|
|
374
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
375
|
-
configurable: !1,
|
|
376
|
-
enumerable: !1,
|
|
377
|
-
writable: !0,
|
|
378
|
-
value: i
|
|
379
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
380
|
-
configurable: !1,
|
|
381
|
-
enumerable: !1,
|
|
382
|
-
writable: !0,
|
|
383
|
-
value: a
|
|
384
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
385
|
-
}
|
|
386
|
-
function f(e, n, i, o, s, u) {
|
|
387
|
-
var f = n.children;
|
|
388
|
-
if (f !== void 0) if (o) if (M(f)) {
|
|
389
|
-
for (o = 0; o < f.length; o++) p(f[o]);
|
|
390
|
-
Object.freeze && Object.freeze(f);
|
|
391
|
-
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
392
|
-
else p(f);
|
|
393
|
-
if (j.call(n, "key")) {
|
|
394
|
-
f = t(e);
|
|
395
|
-
var m = Object.keys(n).filter(function(e) {
|
|
396
|
-
return e !== "key";
|
|
397
|
-
});
|
|
398
|
-
o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), R[f + o] = !0);
|
|
399
|
-
}
|
|
400
|
-
if (f = null, i !== void 0 && (r(i), f = "" + i), c(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
|
|
401
|
-
else i = n;
|
|
402
|
-
return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), s, u);
|
|
403
|
-
}
|
|
404
|
-
function p(e) {
|
|
405
|
-
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
406
|
-
}
|
|
407
|
-
function m(e) {
|
|
408
|
-
return typeof e == "object" && !!e && e.$$typeof === g;
|
|
409
|
-
}
|
|
410
|
-
var h = s("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
|
|
411
|
-
return null;
|
|
412
|
-
};
|
|
413
|
-
h = { react_stack_bottom_frame: function(e) {
|
|
414
|
-
return e();
|
|
415
|
-
} };
|
|
416
|
-
var P, F = {}, I = h.react_stack_bottom_frame.bind(h, o)(), L = N(i(o)), R = {};
|
|
417
|
-
e.Fragment = v, e.jsx = function(e, t, n) {
|
|
418
|
-
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
419
|
-
return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
420
|
-
}, e.jsxs = function(e, t, n) {
|
|
421
|
-
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
422
|
-
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
423
|
-
};
|
|
424
|
-
})();
|
|
425
|
-
})), C = (/* @__PURE__ */ o(((e, t) => {
|
|
426
|
-
process.env.NODE_ENV === "production" ? t.exports = x() : t.exports = S();
|
|
427
|
-
})))(), w = e(({ artworkUrl: e, title: t, isLoading: n }) => /* @__PURE__ */ (0, C.jsxs)("div", {
|
|
428
|
-
className: "relative flex-shrink-0 w-32 h-32 md:w-40 md:h-40 overflow-hidden rounded-[var(--wf-artwork-rounded,0.75rem)] shadow-lg group/artwork",
|
|
429
|
-
children: [/* @__PURE__ */ (0, C.jsx)("div", {
|
|
430
|
-
className: `w-full h-full transition-all duration-700 ${n ? "blur-md scale-110" : ""}`,
|
|
431
|
-
children: e ? /* @__PURE__ */ (0, C.jsx)("img", {
|
|
432
|
-
src: e,
|
|
433
|
-
alt: t,
|
|
434
|
-
className: "w-full h-full object-cover transition-transform duration-500 group-hover/artwork:scale-110"
|
|
435
|
-
}) : /* @__PURE__ */ (0, C.jsx)("div", {
|
|
436
|
-
className: "w-full h-full bg-gradient-to-br from-[var(--wf-placeholder-from,#fb923c)] to-[var(--wf-placeholder-to,#ec4899)] flex items-center justify-center",
|
|
437
|
-
children: /* @__PURE__ */ (0, C.jsx)("svg", {
|
|
438
|
-
className: "w-16 h-16 text-white opacity-50",
|
|
439
|
-
fill: "currentColor",
|
|
440
|
-
viewBox: "0 0 24 24",
|
|
441
|
-
children: /* @__PURE__ */ (0, C.jsx)("path", { d: "M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z" })
|
|
442
|
-
})
|
|
443
|
-
})
|
|
444
|
-
}), n && /* @__PURE__ */ (0, C.jsx)("div", {
|
|
445
|
-
className: "absolute inset-0 flex items-center justify-center bg-black/10 backdrop-blur-[1px]",
|
|
446
|
-
children: /* @__PURE__ */ (0, C.jsx)("div", { className: "w-8 h-8 border-4 border-white/30 border-t-white rounded-full animate-spin" })
|
|
447
|
-
})]
|
|
448
|
-
}));
|
|
449
|
-
w.displayName = "ArtworkOverlay";
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region src/organisms/Waveform.tsx
|
|
452
|
-
var T = e(({ peaks: e, currentTime: n, duration: i, waveColor: a, progressColor: o, height: s, onSeek: c, resolution: l = "auto", barWidth: u = 2, barGap: d = 1 }) => {
|
|
453
|
-
let f = r(null), p = r(null), m = r(null), h = b(m);
|
|
454
|
-
t(() => {
|
|
455
|
-
let t = f.current, n = p.current;
|
|
456
|
-
if (!t || !n) return;
|
|
457
|
-
let r = t.getContext("2d"), i = n.getContext("2d");
|
|
458
|
-
if (!r || !i) return;
|
|
459
|
-
let s = window.devicePixelRatio || 1, c = t.getBoundingClientRect(), m = c.width * s, h = c.height * s;
|
|
460
|
-
[t, n].forEach((e) => {
|
|
461
|
-
(e.width !== m || e.height !== h) && (e.width = m, e.height = h);
|
|
462
|
-
}), (() => {
|
|
463
|
-
if (e.length === 0) return;
|
|
464
|
-
let { width: n, height: c } = t;
|
|
465
|
-
r.clearRect(0, 0, n, c), i.clearRect(0, 0, n, c);
|
|
466
|
-
let f = n / e.length, p = typeof l == "number" ? f * .7 : u * s, m = typeof l == "number" ? f * .3 : d * s;
|
|
467
|
-
r.lineCap = "round", r.lineWidth = p, i.lineCap = "round", i.lineWidth = p, e.forEach((e, t) => {
|
|
468
|
-
let n = t * (p + m) + p / 2, s = e * c * .8, l = (c - s) / 2, u = l + s;
|
|
469
|
-
r.beginPath(), r.strokeStyle = a, r.moveTo(n, l), r.lineTo(n, u), r.stroke(), i.beginPath(), i.strokeStyle = o, i.moveTo(n, l), i.lineTo(n, u), i.stroke();
|
|
470
|
-
});
|
|
471
|
-
})();
|
|
472
|
-
}, [
|
|
473
|
-
e,
|
|
474
|
-
a,
|
|
475
|
-
o,
|
|
476
|
-
l,
|
|
477
|
-
u,
|
|
478
|
-
d,
|
|
479
|
-
s
|
|
480
|
-
]);
|
|
481
|
-
let g = (e) => {
|
|
482
|
-
if (m.current && i) {
|
|
483
|
-
let t = m.current.getBoundingClientRect(), n = e.clientX - t.left;
|
|
484
|
-
c(Math.max(0, Math.min(1, n / t.width)));
|
|
485
|
-
}
|
|
486
|
-
}, _ = i ? n / i * 100 : 0;
|
|
487
|
-
return /* @__PURE__ */ (0, C.jsxs)("div", {
|
|
488
|
-
ref: m,
|
|
489
|
-
className: "relative w-full cursor-pointer overflow-hidden",
|
|
490
|
-
style: { height: `${s}px` },
|
|
491
|
-
onClick: g,
|
|
492
|
-
children: [/* @__PURE__ */ (0, C.jsx)("canvas", {
|
|
493
|
-
ref: f,
|
|
494
|
-
className: "absolute inset-0 w-full h-full"
|
|
495
|
-
}), /* @__PURE__ */ (0, C.jsx)("div", {
|
|
496
|
-
className: "absolute inset-0 h-full overflow-hidden transition-[width] duration-100 ease-linear pointer-events-none",
|
|
497
|
-
style: { width: `${_}%` },
|
|
498
|
-
children: /* @__PURE__ */ (0, C.jsx)("canvas", {
|
|
499
|
-
ref: p,
|
|
500
|
-
className: "absolute h-full",
|
|
501
|
-
style: { width: `${h}px` }
|
|
502
|
-
})
|
|
503
|
-
})]
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
T.displayName = "Waveform";
|
|
507
|
-
//#endregion
|
|
508
|
-
//#region src/components/WaveframePlayer.tsx
|
|
509
|
-
var E = e(({ media: e, peaks: a, artwork: o, title: s, artist: c, waveColor: l, progressColor: u, height: d = 80, className: p = "", style: m, resolution: h = "auto", barWidth: _ = 2, barGap: v = 1, theme: x, engine: S }) => {
|
|
510
|
-
let { state: E, togglePlay: D, seek: O } = f(e, {
|
|
511
|
-
peaks: a,
|
|
512
|
-
engine: S
|
|
513
|
-
}), { isPlaying: k, currentTime: A, duration: j, peaks: M, isAnalyzing: N } = E, [P, F] = i(typeof o == "string" ? o : void 0);
|
|
514
|
-
t(() => {
|
|
515
|
-
if (o instanceof Blob) {
|
|
516
|
-
let e = URL.createObjectURL(o);
|
|
517
|
-
return F(e), () => URL.revokeObjectURL(e);
|
|
518
|
-
} else F(o);
|
|
519
|
-
}, [o]);
|
|
520
|
-
let I = r(null), L = b(I), R = y(M, n(() => typeof h == "number" ? h : L > 0 ? Math.max(1, Math.floor(L / (_ + v))) : M.length || 1, [
|
|
521
|
-
h,
|
|
522
|
-
L,
|
|
523
|
-
_,
|
|
524
|
-
v,
|
|
525
|
-
M.length
|
|
526
|
-
])), z = n(() => l || (x ? x.bg === "#ffffff" ? "#e5e7eb" : "#374151" : "#e5e7eb"), [l, x]), B = u || x?.primary || "#3b82f6", V = n(() => ({
|
|
527
|
-
"--wf-bg-color": x?.bg || "white",
|
|
528
|
-
"--wf-border-color": x?.border || "#f3f4f6",
|
|
529
|
-
"--wf-title-color": x?.text || "#111827",
|
|
530
|
-
"--wf-artist-color": x?.text || "#6b7280",
|
|
531
|
-
"--wf-time-color": x?.text || "#9ca3af",
|
|
532
|
-
"--wf-play-btn-bg": x?.primary || "#3b82f6",
|
|
533
|
-
"--wf-placeholder-from": x?.primary || "#fb923c",
|
|
534
|
-
"--wf-placeholder-to": x?.bg || "#ec4899",
|
|
535
|
-
...m
|
|
536
|
-
}), [x, m]);
|
|
537
|
-
return /* @__PURE__ */ (0, C.jsxs)("div", {
|
|
538
|
-
className: `group relative flex flex-col md:flex-row items-stretch gap-6 p-6 bg-[var(--wf-bg-color,white)] border border-[var(--wf-border-color,#f3f4f6)] rounded-[var(--wf-rounded,1rem)] shadow-xl hover:shadow-2xl transition-all duration-300 overflow-hidden ${p}`,
|
|
539
|
-
style: V,
|
|
540
|
-
children: [/* @__PURE__ */ (0, C.jsx)(w, {
|
|
541
|
-
artworkUrl: P,
|
|
542
|
-
title: s,
|
|
543
|
-
isLoading: N
|
|
544
|
-
}), /* @__PURE__ */ (0, C.jsxs)("div", {
|
|
545
|
-
className: "flex-1 w-full flex flex-col min-w-0",
|
|
546
|
-
children: [/* @__PURE__ */ (0, C.jsxs)("div", {
|
|
547
|
-
className: "flex items-center gap-4 mb-6",
|
|
548
|
-
children: [/* @__PURE__ */ (0, C.jsx)("button", {
|
|
549
|
-
onClick: D,
|
|
550
|
-
className: "w-12 h-12 md:w-14 md:h-14 flex-shrink-0 flex items-center justify-center rounded-full bg-[var(--wf-play-btn-bg,#3b82f6)] text-white shadow-[0_4px_12px_rgba(0,0,0,0.15)] hover:shadow-[0_6px_16px_rgba(0,0,0,0.2)] transition-all hover:scale-105 active:scale-95 cursor-pointer border-none outline-none group/play",
|
|
551
|
-
children: k ? /* @__PURE__ */ (0, C.jsx)("svg", {
|
|
552
|
-
className: "w-6 h-6 md:w-7 md:h-7",
|
|
553
|
-
fill: "currentColor",
|
|
554
|
-
viewBox: "0 0 24 24",
|
|
555
|
-
children: /* @__PURE__ */ (0, C.jsx)("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" })
|
|
556
|
-
}) : /* @__PURE__ */ (0, C.jsx)("svg", {
|
|
557
|
-
className: "w-6 h-6 md:w-7 md:h-7 ml-1",
|
|
558
|
-
fill: "currentColor",
|
|
559
|
-
viewBox: "0 0 24 24",
|
|
560
|
-
children: /* @__PURE__ */ (0, C.jsx)("path", { d: "M8 5v14l11-7z" })
|
|
561
|
-
})
|
|
562
|
-
}), /* @__PURE__ */ (0, C.jsxs)("div", {
|
|
563
|
-
className: "flex-1 flex flex-col min-w-0",
|
|
564
|
-
children: [/* @__PURE__ */ (0, C.jsxs)("div", {
|
|
565
|
-
className: "flex items-center justify-between gap-4",
|
|
566
|
-
children: [c && /* @__PURE__ */ (0, C.jsx)("p", {
|
|
567
|
-
className: "text-[10px] md:text-xs font-bold uppercase text-[var(--wf-artist-color,#6b7280)] opacity-60 tracking-[0.1em] line-clamp-1",
|
|
568
|
-
children: c
|
|
569
|
-
}), /* @__PURE__ */ (0, C.jsxs)("div", {
|
|
570
|
-
className: "text-[10px] font-mono text-[var(--wf-time-color,#9ca3af)] tabular-nums flex-shrink-0",
|
|
571
|
-
children: [
|
|
572
|
-
g(A),
|
|
573
|
-
" / ",
|
|
574
|
-
g(j)
|
|
575
|
-
]
|
|
576
|
-
})]
|
|
577
|
-
}), s && /* @__PURE__ */ (0, C.jsx)("h3", {
|
|
578
|
-
className: "text-lg md:text-xl font-black text-[var(--wf-title-color,#111827)] tracking-tight line-clamp-1 mt-0.5 leading-tight",
|
|
579
|
-
children: s
|
|
580
|
-
})]
|
|
581
|
-
})]
|
|
582
|
-
}), /* @__PURE__ */ (0, C.jsx)("div", {
|
|
583
|
-
className: "mt-auto",
|
|
584
|
-
ref: I,
|
|
585
|
-
children: /* @__PURE__ */ (0, C.jsx)(T, {
|
|
586
|
-
peaks: R,
|
|
587
|
-
currentTime: A,
|
|
588
|
-
duration: j,
|
|
589
|
-
waveColor: z,
|
|
590
|
-
progressColor: B,
|
|
591
|
-
height: d,
|
|
592
|
-
onSeek: O,
|
|
593
|
-
resolution: h,
|
|
594
|
-
barWidth: _,
|
|
595
|
-
barGap: v
|
|
596
|
-
})
|
|
597
|
-
})]
|
|
598
|
-
})]
|
|
599
|
-
});
|
|
600
|
-
});
|
|
601
|
-
E.displayName = "WaveframePlayer";
|
|
602
|
-
//#endregion
|
|
603
|
-
export { l as PeakAnalyzer, c as PlayerCore, u as WaveframeEngine, E as WaveframePlayer, g as formatTime, p as generatePeaks, v as highlightCode, m as loadAudioToMemory, _ as resamplePeaks, h as revokeAudioMemory, d as useWaveframeStore };
|