react-audio-visualize
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -17,12 +17,12 @@ import Ae, { useState as J, useRef as De, useEffect as G, useCallback as fr, forwardRef as dr, useImperativeHandle as vr } from "react"; | ||
Pe = 1; | ||
var l = Ae, v = Symbol.for("react.element"), w = Symbol.for("react.fragment"), E = Object.prototype.hasOwnProperty, g = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, R = { key: !0, ref: !0, __self: !0, __source: !0 }; | ||
function b(u, c, p) { | ||
var i, a = {}, f = null, S = null; | ||
p !== void 0 && (f = "" + p), c.key !== void 0 && (f = "" + c.key), c.ref !== void 0 && (S = c.ref); | ||
for (i in c) | ||
E.call(c, i) && !R.hasOwnProperty(i) && (a[i] = c[i]); | ||
if (u && u.defaultProps) | ||
for (i in c = u.defaultProps, c) | ||
a[i] === void 0 && (a[i] = c[i]); | ||
return { $$typeof: v, type: u, key: f, ref: S, props: a, _owner: g.current }; | ||
var d = Ae, v = Symbol.for("react.element"), w = Symbol.for("react.fragment"), E = Object.prototype.hasOwnProperty, g = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, R = { key: !0, ref: !0, __self: !0, __source: !0 }; | ||
function b(s, c, p) { | ||
var o, a = {}, l = null, S = null; | ||
p !== void 0 && (l = "" + p), c.key !== void 0 && (l = "" + c.key), c.ref !== void 0 && (S = c.ref); | ||
for (o in c) | ||
E.call(c, o) && !R.hasOwnProperty(o) && (a[o] = c[o]); | ||
if (s && s.defaultProps) | ||
for (o in c = s.defaultProps, c) | ||
a[o] === void 0 && (a[o] = c[o]); | ||
return { $$typeof: v, type: s, key: l, ref: S, props: a, _owner: g.current }; | ||
} | ||
@@ -44,3 +44,3 @@ return V.Fragment = w, V.jsx = b, V.jsxs = b, V; | ||
return je || (je = 1, process.env.NODE_ENV !== "production" && function() { | ||
var l = Ae, v = Symbol.for("react.element"), w = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), b = Symbol.for("react.provider"), u = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), p = Symbol.for("react.suspense"), i = Symbol.for("react.suspense_list"), a = Symbol.for("react.memo"), f = Symbol.for("react.lazy"), S = Symbol.for("react.offscreen"), C = Symbol.iterator, A = "@@iterator"; | ||
var d = Ae, v = Symbol.for("react.element"), w = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), b = Symbol.for("react.provider"), s = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), p = Symbol.for("react.suspense"), o = Symbol.for("react.suspense_list"), a = Symbol.for("react.memo"), l = Symbol.for("react.lazy"), S = Symbol.for("react.offscreen"), C = Symbol.iterator, A = "@@iterator"; | ||
function D(e) { | ||
@@ -52,3 +52,3 @@ if (e === null || typeof e != "object") | ||
} | ||
var y = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
var y = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
function m(e) { | ||
@@ -63,6 +63,6 @@ { | ||
{ | ||
var n = y.ReactDebugCurrentFrame, d = n.getStackAddendum(); | ||
d !== "" && (r += "%s", t = t.concat([d])); | ||
var h = t.map(function(s) { | ||
return String(s); | ||
var n = y.ReactDebugCurrentFrame, f = n.getStackAddendum(); | ||
f !== "" && (r += "%s", t = t.concat([f])); | ||
var h = t.map(function(u) { | ||
return String(u); | ||
}); | ||
@@ -72,10 +72,10 @@ h.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, h); | ||
} | ||
var P = !1, Fe = !1, Ie = !1, $e = !1, Ye = !1, oe; | ||
oe = Symbol.for("react.module.reference"); | ||
var P = !1, Fe = !1, Ie = !1, $e = !1, Ye = !1, ie; | ||
ie = Symbol.for("react.module.reference"); | ||
function Me(e) { | ||
return !!(typeof e == "string" || typeof e == "function" || e === E || e === R || Ye || e === g || e === p || e === i || $e || e === S || P || Fe || Ie || typeof e == "object" && e !== null && (e.$$typeof === f || e.$$typeof === a || e.$$typeof === b || e.$$typeof === u || e.$$typeof === c || // This needs to include all possible module reference object | ||
return !!(typeof e == "string" || typeof e == "function" || e === E || e === R || Ye || e === g || e === p || e === o || $e || e === S || P || Fe || Ie || typeof e == "object" && e !== null && (e.$$typeof === l || e.$$typeof === a || e.$$typeof === b || e.$$typeof === s || e.$$typeof === c || // This needs to include all possible module reference object | ||
// types supported by any Flight configuration anywhere since | ||
// we don't know which Flight build this will end up being used | ||
// with. | ||
e.$$typeof === oe || e.getModuleId !== void 0)); | ||
e.$$typeof === ie || e.getModuleId !== void 0)); | ||
} | ||
@@ -86,6 +86,6 @@ function Ne(e, r, t) { | ||
return n; | ||
var d = r.displayName || r.name || ""; | ||
return d !== "" ? t + "(" + d + ")" : t; | ||
var f = r.displayName || r.name || ""; | ||
return f !== "" ? t + "(" + f + ")" : t; | ||
} | ||
function ie(e) { | ||
function oe(e) { | ||
return e.displayName || "Context"; | ||
@@ -111,3 +111,3 @@ } | ||
return "Suspense"; | ||
case i: | ||
case o: | ||
return "SuspenseList"; | ||
@@ -117,8 +117,8 @@ } | ||
switch (e.$$typeof) { | ||
case u: | ||
case s: | ||
var r = e; | ||
return ie(r) + ".Consumer"; | ||
return oe(r) + ".Consumer"; | ||
case b: | ||
var t = e; | ||
return ie(t._context) + ".Provider"; | ||
return oe(t._context) + ".Provider"; | ||
case c: | ||
@@ -129,6 +129,6 @@ return Ne(e, e.render, "ForwardRef"); | ||
return n !== null ? n : k(e.type) || "Memo"; | ||
case f: { | ||
var d = e, h = d._payload, s = d._init; | ||
case l: { | ||
var f = e, h = f._payload, u = f._init; | ||
try { | ||
return k(s(h)); | ||
return k(u(h)); | ||
} catch { | ||
@@ -141,3 +141,3 @@ return null; | ||
} | ||
var I = Object.assign, M = 0, se, ue, ce, le, fe, de, ve; | ||
var I = Object.assign, M = 0, ue, se, ce, le, fe, de, ve; | ||
function pe() { | ||
@@ -149,3 +149,3 @@ } | ||
if (M === 0) { | ||
se = console.log, ue = console.info, ce = console.warn, le = console.error, fe = console.group, de = console.groupCollapsed, ve = console.groupEnd; | ||
ue = console.log, se = console.info, ce = console.warn, le = console.error, fe = console.group, de = console.groupCollapsed, ve = console.groupEnd; | ||
var e = { | ||
@@ -180,6 +180,6 @@ configurable: !0, | ||
log: I({}, e, { | ||
value: se | ||
value: ue | ||
}), | ||
info: I({}, e, { | ||
value: ue | ||
value: se | ||
}), | ||
@@ -212,4 +212,4 @@ warn: I({}, e, { | ||
throw Error(); | ||
} catch (d) { | ||
var n = d.stack.trim().match(/\n( *(at )?)/); | ||
} catch (f) { | ||
var n = f.stack.trim().match(/\n( *(at )?)/); | ||
K = n && n[1] || ""; | ||
@@ -236,3 +236,3 @@ } | ||
X = !0; | ||
var d = Error.prepareStackTrace; | ||
var f = Error.prepareStackTrace; | ||
Error.prepareStackTrace = void 0; | ||
@@ -243,6 +243,6 @@ var h; | ||
if (r) { | ||
var s = function() { | ||
var u = function() { | ||
throw Error(); | ||
}; | ||
if (Object.defineProperty(s.prototype, "props", { | ||
if (Object.defineProperty(u.prototype, "props", { | ||
set: function() { | ||
@@ -253,14 +253,14 @@ throw Error(); | ||
try { | ||
Reflect.construct(s, []); | ||
Reflect.construct(u, []); | ||
} catch (F) { | ||
n = F; | ||
} | ||
Reflect.construct(e, [], s); | ||
Reflect.construct(e, [], u); | ||
} else { | ||
try { | ||
s.call(); | ||
u.call(); | ||
} catch (F) { | ||
n = F; | ||
} | ||
e.call(s.prototype); | ||
e.call(u.prototype); | ||
} | ||
@@ -277,13 +277,13 @@ } else { | ||
if (F && n && typeof F.stack == "string") { | ||
for (var o = F.stack.split(` | ||
for (var i = F.stack.split(` | ||
`), O = n.stack.split(` | ||
`), _ = o.length - 1, x = O.length - 1; _ >= 1 && x >= 0 && o[_] !== O[x]; ) | ||
`), _ = i.length - 1, x = O.length - 1; _ >= 1 && x >= 0 && i[_] !== O[x]; ) | ||
x--; | ||
for (; _ >= 1 && x >= 0; _--, x--) | ||
if (o[_] !== O[x]) { | ||
if (i[_] !== O[x]) { | ||
if (_ !== 1 || x !== 1) | ||
do | ||
if (_--, x--, x < 0 || o[_] !== O[x]) { | ||
if (_--, x--, x < 0 || i[_] !== O[x]) { | ||
var j = ` | ||
` + o[_].replace(" at new ", " at "); | ||
` + i[_].replace(" at new ", " at "); | ||
return e.displayName && j.includes("<anonymous>") && (j = j.replace("<anonymous>", e.displayName)), typeof e == "function" && B.set(e, j), j; | ||
@@ -296,3 +296,3 @@ } | ||
} finally { | ||
X = !1, H.current = h, Le(), Error.prepareStackTrace = d; | ||
X = !1, H.current = h, Le(), Error.prepareStackTrace = f; | ||
} | ||
@@ -319,3 +319,3 @@ var Y = e ? e.displayName || e.name : "", Oe = Y ? W(Y) : ""; | ||
return W("Suspense"); | ||
case i: | ||
case o: | ||
return W("SuspenseList"); | ||
@@ -329,6 +329,6 @@ } | ||
return U(e.type, r, t); | ||
case f: { | ||
var n = e, d = n._payload, h = n._init; | ||
case l: { | ||
var n = e, f = n._payload, h = n._init; | ||
try { | ||
return U(h(d), r, t); | ||
return U(h(f), r, t); | ||
} catch { | ||
@@ -348,18 +348,18 @@ } | ||
} | ||
function ze(e, r, t, n, d) { | ||
function ze(e, r, t, n, f) { | ||
{ | ||
var h = Function.call.bind(z); | ||
for (var s in e) | ||
if (h(e, s)) { | ||
var o = void 0; | ||
for (var u in e) | ||
if (h(e, u)) { | ||
var i = void 0; | ||
try { | ||
if (typeof e[s] != "function") { | ||
var O = Error((n || "React class") + ": " + t + " type `" + s + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[s] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); | ||
if (typeof e[u] != "function") { | ||
var O = Error((n || "React class") + ": " + t + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); | ||
throw O.name = "Invariant Violation", O; | ||
} | ||
o = e[s](r, s, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
i = e[u](r, u, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
} catch (_) { | ||
o = _; | ||
i = _; | ||
} | ||
o && !(o instanceof Error) && (q(d), m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, s, typeof o), q(null)), o instanceof Error && !(o.message in he) && (he[o.message] = !0, q(d), m("Failed %s type: %s", t, o.message), q(null)); | ||
i && !(i instanceof Error) && (q(f), m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, u, typeof i), q(null)), i instanceof Error && !(i.message in he) && (he[i.message] = !0, q(f), m("Failed %s type: %s", t, i.message), q(null)); | ||
} | ||
@@ -443,4 +443,4 @@ } | ||
} | ||
var rr = function(e, r, t, n, d, h, s) { | ||
var o = { | ||
var rr = function(e, r, t, n, f, h, u) { | ||
var i = { | ||
// This tag allows us to uniquely identify this as a React Element | ||
@@ -452,7 +452,7 @@ $$typeof: v, | ||
ref: t, | ||
props: s, | ||
props: u, | ||
// Record the component responsible for creating this element. | ||
_owner: h | ||
}; | ||
return o._store = {}, Object.defineProperty(o._store, "validated", { | ||
return i._store = {}, Object.defineProperty(i._store, "validated", { | ||
configurable: !1, | ||
@@ -462,3 +462,3 @@ enumerable: !1, | ||
value: !1 | ||
}), Object.defineProperty(o, "_self", { | ||
}), Object.defineProperty(i, "_self", { | ||
configurable: !1, | ||
@@ -468,25 +468,25 @@ enumerable: !1, | ||
value: n | ||
}), Object.defineProperty(o, "_source", { | ||
}), Object.defineProperty(i, "_source", { | ||
configurable: !1, | ||
enumerable: !1, | ||
writable: !1, | ||
value: d | ||
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o; | ||
value: f | ||
}), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i; | ||
}; | ||
function tr(e, r, t, n, d) { | ||
function tr(e, r, t, n, f) { | ||
{ | ||
var h, s = {}, o = null, O = null; | ||
t !== void 0 && (Ee(t), o = "" + t), Xe(r) && (Ee(r.key), o = "" + r.key), Ke(r) && (O = r.ref, Ze(r, d)); | ||
var h, u = {}, i = null, O = null; | ||
t !== void 0 && (Ee(t), i = "" + t), Xe(r) && (Ee(r.key), i = "" + r.key), Ke(r) && (O = r.ref, Ze(r, f)); | ||
for (h in r) | ||
z.call(r, h) && !He.hasOwnProperty(h) && (s[h] = r[h]); | ||
z.call(r, h) && !He.hasOwnProperty(h) && (u[h] = r[h]); | ||
if (e && e.defaultProps) { | ||
var _ = e.defaultProps; | ||
for (h in _) | ||
s[h] === void 0 && (s[h] = _[h]); | ||
u[h] === void 0 && (u[h] = _[h]); | ||
} | ||
if (o || O) { | ||
if (i || O) { | ||
var x = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; | ||
o && Qe(s, x), O && er(s, x); | ||
i && Qe(u, x), O && er(u, x); | ||
} | ||
return rr(e, o, O, d, n, N.current, s); | ||
return rr(e, i, O, f, n, N.current, u); | ||
} | ||
@@ -568,10 +568,10 @@ } | ||
else if (e) { | ||
var d = D(e); | ||
if (typeof d == "function" && d !== e.entries) | ||
for (var h = d.call(e), s; !(s = h.next()).done; ) | ||
te(s.value) && Te(s.value, r); | ||
var f = D(e); | ||
if (typeof f == "function" && f !== e.entries) | ||
for (var h = f.call(e), u; !(u = h.next()).done; ) | ||
te(u.value) && Te(u.value, r); | ||
} | ||
} | ||
} | ||
function or(e) { | ||
function ir(e) { | ||
{ | ||
@@ -595,4 +595,4 @@ var r = e.type; | ||
re = !0; | ||
var d = k(r); | ||
m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", d || "Unknown"); | ||
var f = k(r); | ||
m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", f || "Unknown"); | ||
} | ||
@@ -602,3 +602,3 @@ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); | ||
} | ||
function ir(e) { | ||
function or(e) { | ||
{ | ||
@@ -615,17 +615,17 @@ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) { | ||
} | ||
function Ce(e, r, t, n, d, h) { | ||
function Ce(e, r, t, n, f, h) { | ||
{ | ||
var s = Me(e); | ||
if (!s) { | ||
var o = ""; | ||
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (o += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); | ||
var O = nr(d); | ||
O ? o += O : o += xe(); | ||
var u = Me(e); | ||
if (!u) { | ||
var i = ""; | ||
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (i += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); | ||
var O = nr(f); | ||
O ? i += O : i += xe(); | ||
var _; | ||
e === null ? _ = "null" : Z(e) ? _ = "array" : e !== void 0 && e.$$typeof === v ? (_ = "<" + (k(e.type) || "Unknown") + " />", o = " Did you accidentally export a JSX literal instead of a component?") : _ = typeof e, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", _, o); | ||
e === null ? _ = "null" : Z(e) ? _ = "array" : e !== void 0 && e.$$typeof === v ? (_ = "<" + (k(e.type) || "Unknown") + " />", i = " Did you accidentally export a JSX literal instead of a component?") : _ = typeof e, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", _, i); | ||
} | ||
var x = tr(e, r, t, d, h); | ||
var x = tr(e, r, t, f, h); | ||
if (x == null) | ||
return x; | ||
if (s) { | ||
if (u) { | ||
var j = r.children; | ||
@@ -643,12 +643,12 @@ if (j !== void 0) | ||
} | ||
return e === E ? ir(x) : or(x), x; | ||
return e === E ? or(x) : ir(x), x; | ||
} | ||
} | ||
function sr(e, r, t) { | ||
function ur(e, r, t) { | ||
return Ce(e, r, t, !0); | ||
} | ||
function ur(e, r, t) { | ||
function sr(e, r, t) { | ||
return Ce(e, r, t, !1); | ||
} | ||
var cr = ur, lr = sr; | ||
var cr = sr, lr = ur; | ||
L.Fragment = E, L.jsx = cr, L.jsxs = lr; | ||
@@ -659,22 +659,22 @@ }()), L; | ||
var ke = ae.exports; | ||
const hr = (l, v, w, E) => { | ||
let g = v / (w + E), R = Math.floor(l.length / g); | ||
g > l.length && (g = l.length, R = 1); | ||
const hr = (d, v, w, E) => { | ||
let g = v / (w + E), R = Math.floor(d.length / g); | ||
g > d.length && (g = d.length, R = 1); | ||
const b = []; | ||
for (let u = 0; u < g; u++) { | ||
for (let s = 0; s < g; s++) { | ||
let c = 0; | ||
for (let p = 0; p < R && u * R + p < l.length; p++) | ||
c += l[u * R + p]; | ||
for (let p = 0; p < R && s * R + p < d.length; p++) | ||
c += d[s * R + p]; | ||
b.push(c / R); | ||
} | ||
return b; | ||
}, gr = (l, v, w, E, g, R) => { | ||
const b = v.height / 2, u = v.getContext("2d"); | ||
u && (u.clearRect(0, 0, v.width, v.height), g !== "transparent" && (u.fillStyle = g, u.fillRect(0, 0, v.width, v.height)), l.forEach((c, p) => { | ||
u.fillStyle = R; | ||
const i = p * (w + E), a = b - c / 2, f = w, S = c || 1; | ||
u.beginPath(), u.roundRect(i, a, f, S, 50), u.fill(); | ||
}, gr = (d, v, w, E, g, R) => { | ||
const b = v.height / 2, s = v.getContext("2d"); | ||
s && (s.clearRect(0, 0, v.width, v.height), g !== "transparent" && (s.fillStyle = g, s.fillRect(0, 0, v.width, v.height)), d.forEach((c, p) => { | ||
s.fillStyle = R; | ||
const o = p * (w + E), a = b - c / 2, l = w, S = c || 1; | ||
s.beginPath(), s.roundRect(o, a, l, S, 50), s.fill(); | ||
})); | ||
}, _r = ({ | ||
mediaRecorder: l, | ||
mediaRecorder: d, | ||
width: v = "100%", | ||
@@ -686,22 +686,22 @@ height: w = "100%", | ||
barColor: b = "rgb(160, 198, 255)", | ||
fftSize: u = 1024, | ||
fftSize: s = 1024, | ||
maxDecibels: c = -10, | ||
minDecibels: p = -90, | ||
smoothingTimeConstant: i = 0.4 | ||
smoothingTimeConstant: o = 0.4 | ||
}) => { | ||
const [a] = J(() => new AudioContext()), [f, S] = J(), C = De(null); | ||
const [a] = J(() => new AudioContext()), [l, S] = J(), C = De(null); | ||
G(() => { | ||
if (!l.stream) | ||
if (!d.stream) | ||
return; | ||
const y = a.createAnalyser(); | ||
S(y), y.fftSize = u, y.minDecibels = p, y.maxDecibels = c, y.smoothingTimeConstant = i, a.createMediaStreamSource(l.stream).connect(y); | ||
}, [l.stream]), G(() => { | ||
f && l.state === "recording" && (console.log("report ==== mediaRecorder.state", l.state), console.log("report ==== context.state", a.state), A()); | ||
}, [f, l.state]); | ||
S(y), y.fftSize = s, y.minDecibels = p, y.maxDecibels = c, y.smoothingTimeConstant = o, a.createMediaStreamSource(d.stream).connect(y); | ||
}, [d.stream]), G(() => { | ||
l && d.state === "recording" && A(); | ||
}, [l, d.state]); | ||
const A = fr(() => { | ||
if (!f) | ||
if (!l) | ||
return; | ||
const y = new Uint8Array(f == null ? void 0 : f.frequencyBinCount); | ||
l.state === "recording" ? (f == null || f.getByteFrequencyData(y), D(y), requestAnimationFrame(A)) : l.state === "paused" ? D(y) : l.state === "inactive" && a.state !== "closed" && (console.log("mediaRecorder.state", l.state), console.log("context.state", a.state), a.close(), console.log("context.close()")); | ||
}, [f, a.state]), D = (y) => { | ||
const y = new Uint8Array(l == null ? void 0 : l.frequencyBinCount); | ||
d.state === "recording" ? (l == null || l.getByteFrequencyData(y), D(y), requestAnimationFrame(A)) : d.state === "paused" ? D(y) : d.state === "inactive" && a.state !== "closed" && a.close(); | ||
}, [l, a.state]), D = (y) => { | ||
if (!C.current) | ||
@@ -735,40 +735,40 @@ return; | ||
); | ||
}, yr = (l, v, w, E, g) => { | ||
const R = l.getChannelData(0), b = w / (E + g), u = Math.floor(R.length / b), c = v / 2; | ||
let p = [], i = 0; | ||
}, yr = (d, v, w, E, g) => { | ||
const R = d.getChannelData(0), b = w / (E + g), s = Math.floor(R.length / b), c = v / 2; | ||
let p = [], o = 0; | ||
for (let a = 0; a < b; a++) { | ||
const f = []; | ||
const l = []; | ||
let S = 0; | ||
const C = []; | ||
let A = 0; | ||
for (let T = 0; T < u && a * u + T < l.length; T++) { | ||
const P = R[a * u + T]; | ||
P <= 0 && (f.push(P), S++), P > 0 && (C.push(P), A++); | ||
for (let T = 0; T < s && a * s + T < d.length; T++) { | ||
const P = R[a * s + T]; | ||
P <= 0 && (l.push(P), S++), P > 0 && (C.push(P), A++); | ||
} | ||
const D = f.reduce((T, P) => T + P, 0) / S, m = { max: C.reduce((T, P) => T + P, 0) / A, min: D }; | ||
m.max > i && (i = m.max), Math.abs(m.min) > i && (i = Math.abs(m.min)), p.push(m); | ||
const D = l.reduce((T, P) => T + P, 0) / S, m = { max: C.reduce((T, P) => T + P, 0) / A, min: D }; | ||
m.max > o && (o = m.max), Math.abs(m.min) > o && (o = Math.abs(m.min)), p.push(m); | ||
} | ||
if (c * 0.8 > i * c) { | ||
const a = c * 0.8 / i; | ||
p = p.map((f) => ({ | ||
max: f.max * a, | ||
min: f.min * a | ||
if (c * 0.8 > o * c) { | ||
const a = c * 0.8 / o; | ||
p = p.map((l) => ({ | ||
max: l.max * a, | ||
min: l.min * a | ||
})); | ||
} | ||
return p; | ||
}, ne = (l, v, w, E, g, R, b, u = 0, c = 1) => { | ||
const p = v.height / 2, i = v.getContext("2d"); | ||
if (!i) | ||
}, ne = (d, v, w, E, g, R, b, s = 0, c = 1) => { | ||
const p = v.height / 2, o = v.getContext("2d"); | ||
if (!o) | ||
return; | ||
i.clearRect(0, 0, v.width, v.height), g !== "transparent" && (i.fillStyle = g, i.fillRect(0, 0, v.width, v.height)); | ||
const a = (u || 0) / c; | ||
l.forEach((f, S) => { | ||
const C = S / l.length, A = a > C; | ||
i.fillStyle = A && b ? b : R; | ||
const D = S * (w + E), y = p + f.min, m = w, T = p + f.max - y; | ||
i.beginPath(), i.roundRect(D, y, m, T, 50), i.fill(); | ||
o.clearRect(0, 0, v.width, v.height), g !== "transparent" && (o.fillStyle = g, o.fillRect(0, 0, v.width, v.height)); | ||
const a = (s || 0) / c; | ||
d.forEach((l, S) => { | ||
const C = S / d.length, A = a > C; | ||
o.fillStyle = A && b ? b : R; | ||
const D = S * (w + E), y = p + l.min, m = w, T = p + l.max - y; | ||
o.beginPath(), o.roundRect(D, y, m, T, 50), o.fill(); | ||
}); | ||
}, Er = dr( | ||
({ | ||
blob: l, | ||
blob: d, | ||
width: v, | ||
@@ -780,9 +780,9 @@ height: w, | ||
style: b, | ||
backgroundColor: u = "transparent", | ||
backgroundColor: s = "transparent", | ||
barColor: c = "rgb(184, 184, 184)", | ||
barPlayedColor: p = "rgb(160, 198, 255)" | ||
}, i) => { | ||
const a = De(null), [f, S] = J([]), [C, A] = J(0); | ||
}, o) => { | ||
const a = De(null), [l, S] = J([]), [C, A] = J(0); | ||
return vr( | ||
i, | ||
o, | ||
() => a.current, | ||
@@ -794,3 +794,3 @@ [] | ||
return; | ||
if (!l) { | ||
if (!d) { | ||
const T = Array.from({ length: 100 }, () => ({ | ||
@@ -805,3 +805,3 @@ max: 0, | ||
g, | ||
u, | ||
s, | ||
c, | ||
@@ -812,3 +812,3 @@ p | ||
} | ||
const y = await l.arrayBuffer(); | ||
const y = await d.arrayBuffer(); | ||
await new AudioContext().decodeAudioData(y, (T) => { | ||
@@ -830,3 +830,3 @@ if (!a.current) | ||
g, | ||
u, | ||
s, | ||
c, | ||
@@ -837,9 +837,9 @@ p | ||
})(); | ||
}, [l, a.current]), G(() => { | ||
}, [d, a.current]), G(() => { | ||
a.current && ne( | ||
f, | ||
l, | ||
a.current, | ||
E, | ||
g, | ||
u, | ||
s, | ||
c, | ||
@@ -846,0 +846,0 @@ p, |
@@ -9,3 +9,3 @@ (function(V,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],T):(V=typeof globalThis<"u"?globalThis:V||self,T(V.AudioVisualize={},V.React))})(this,function(V,T){"use strict";var X={exports:{}},N={};/** | ||
* LICENSE file in the root directory of this source tree. | ||
*/var oe;function ke(){if(oe)return N;oe=1;var l=T,v=Symbol.for("react.element"),w=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,g=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,R={key:!0,ref:!0,__self:!0,__source:!0};function b(u,c,p){var i,a={},f=null,O=null;p!==void 0&&(f=""+p),c.key!==void 0&&(f=""+c.key),c.ref!==void 0&&(O=c.ref);for(i in c)E.call(c,i)&&!R.hasOwnProperty(i)&&(a[i]=c[i]);if(u&&u.defaultProps)for(i in c=u.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:v,type:u,key:f,ref:O,props:a,_owner:g.current}}return N.Fragment=w,N.jsx=b,N.jsxs=b,N}var W={};/** | ||
*/var oe;function ke(){if(oe)return N;oe=1;var d=T,v=Symbol.for("react.element"),w=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,g=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,R={key:!0,ref:!0,__self:!0,__source:!0};function b(u,c,p){var i,a={},f=null,O=null;p!==void 0&&(f=""+p),c.key!==void 0&&(f=""+c.key),c.ref!==void 0&&(O=c.ref);for(i in c)E.call(c,i)&&!R.hasOwnProperty(i)&&(a[i]=c[i]);if(u&&u.defaultProps)for(i in c=u.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:v,type:u,key:f,ref:O,props:a,_owner:g.current}}return N.Fragment=w,N.jsx=b,N.jsxs=b,N}var W={};/** | ||
* @license React | ||
@@ -18,12 +18,12 @@ * react-jsx-runtime.development.js | ||
* LICENSE file in the root directory of this source tree. | ||
*/var ie;function Fe(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&function(){var l=T,v=Symbol.for("react.element"),w=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),i=Symbol.for("react.suspense_list"),a=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),P=Symbol.iterator,D="@@iterator";function k(e){if(e===null||typeof e!="object")return null;var t=P&&e[P]||e[D];return typeof t=="function"?t:null}var y=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];S("error",e,r)}}function S(e,t,r){{var n=y.ReactDebugCurrentFrame,d=n.getStackAddendum();d!==""&&(t+="%s",r=r.concat([d]));var m=r.map(function(s){return String(s)});m.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,m)}}var j=!1,Le=!1,Ne=!1,We=!1,Be=!1,ce;ce=Symbol.for("react.module.reference");function Ue(e){return!!(typeof e=="string"||typeof e=="function"||e===E||e===R||Be||e===g||e===p||e===i||We||e===O||j||Le||Ne||typeof e=="object"&&e!==null&&(e.$$typeof===f||e.$$typeof===a||e.$$typeof===b||e.$$typeof===u||e.$$typeof===c||e.$$typeof===ce||e.getModuleId!==void 0))}function ze(e,t,r){var n=e.displayName;if(n)return n;var d=t.displayName||t.name||"";return d!==""?r+"("+d+")":r}function le(e){return e.displayName||"Context"}function F(e){if(e==null)return null;if(typeof e.tag=="number"&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case w:return"Portal";case R:return"Profiler";case g:return"StrictMode";case p:return"Suspense";case i:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case u:var t=e;return le(t)+".Consumer";case b:var r=e;return le(r._context)+".Provider";case c:return ze(e,e.render,"ForwardRef");case a:var n=e.displayName||null;return n!==null?n:F(e.type)||"Memo";case f:{var d=e,m=d._payload,s=d._init;try{return F(s(m))}catch{return null}}}return null}var Y=Object.assign,B=0,fe,de,ve,pe,he,me,ge;function ye(){}ye.__reactDisabledLog=!0;function Je(){{if(B===0){fe=console.log,de=console.info,ve=console.warn,pe=console.error,he=console.group,me=console.groupCollapsed,ge=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ye,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}B++}}function Ge(){{if(B--,B===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Y({},e,{value:fe}),info:Y({},e,{value:de}),warn:Y({},e,{value:ve}),error:Y({},e,{value:pe}),group:Y({},e,{value:he}),groupCollapsed:Y({},e,{value:me}),groupEnd:Y({},e,{value:ge})})}B<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Q=y.ReactCurrentDispatcher,$;function z(e,t,r){{if($===void 0)try{throw Error()}catch(d){var n=d.stack.trim().match(/\n( *(at )?)/);$=n&&n[1]||""}return` | ||
`+$+e}}var q=!1,J;{var He=typeof WeakMap=="function"?WeakMap:Map;J=new He}function Ee(e,t){if(!e||q)return"";{var r=J.get(e);if(r!==void 0)return r}var n;q=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var m;m=Q.current,Q.current=null,Je();try{if(t){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(I){n=I}Reflect.construct(e,[],s)}else{try{s.call()}catch(I){n=I}e.call(s.prototype)}}else{try{throw Error()}catch(I){n=I}e()}}catch(I){if(I&&n&&typeof I.stack=="string"){for(var o=I.stack.split(` | ||
*/var ie;function Fe(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&function(){var d=T,v=Symbol.for("react.element"),w=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),i=Symbol.for("react.suspense_list"),a=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),P=Symbol.iterator,D="@@iterator";function k(e){if(e===null||typeof e!="object")return null;var r=P&&e[P]||e[D];return typeof r=="function"?r:null}var y=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];S("error",e,t)}}function S(e,r,t){{var n=y.ReactDebugCurrentFrame,l=n.getStackAddendum();l!==""&&(r+="%s",t=t.concat([l]));var m=t.map(function(s){return String(s)});m.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,m)}}var j=!1,Le=!1,Ne=!1,We=!1,Be=!1,ce;ce=Symbol.for("react.module.reference");function Ue(e){return!!(typeof e=="string"||typeof e=="function"||e===E||e===R||Be||e===g||e===p||e===i||We||e===O||j||Le||Ne||typeof e=="object"&&e!==null&&(e.$$typeof===f||e.$$typeof===a||e.$$typeof===b||e.$$typeof===u||e.$$typeof===c||e.$$typeof===ce||e.getModuleId!==void 0))}function ze(e,r,t){var n=e.displayName;if(n)return n;var l=r.displayName||r.name||"";return l!==""?t+"("+l+")":t}function fe(e){return e.displayName||"Context"}function F(e){if(e==null)return null;if(typeof e.tag=="number"&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case w:return"Portal";case R:return"Profiler";case g:return"StrictMode";case p:return"Suspense";case i:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case u:var r=e;return fe(r)+".Consumer";case b:var t=e;return fe(t._context)+".Provider";case c:return ze(e,e.render,"ForwardRef");case a:var n=e.displayName||null;return n!==null?n:F(e.type)||"Memo";case f:{var l=e,m=l._payload,s=l._init;try{return F(s(m))}catch{return null}}}return null}var Y=Object.assign,B=0,le,de,ve,pe,he,me,ge;function ye(){}ye.__reactDisabledLog=!0;function Je(){{if(B===0){le=console.log,de=console.info,ve=console.warn,pe=console.error,he=console.group,me=console.groupCollapsed,ge=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ye,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}B++}}function Ge(){{if(B--,B===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Y({},e,{value:le}),info:Y({},e,{value:de}),warn:Y({},e,{value:ve}),error:Y({},e,{value:pe}),group:Y({},e,{value:he}),groupCollapsed:Y({},e,{value:me}),groupEnd:Y({},e,{value:ge})})}B<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Q=y.ReactCurrentDispatcher,$;function z(e,r,t){{if($===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);$=n&&n[1]||""}return` | ||
`+$+e}}var q=!1,J;{var He=typeof WeakMap=="function"?WeakMap:Map;J=new He}function Ee(e,r){if(!e||q)return"";{var t=J.get(e);if(t!==void 0)return t}var n;q=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var m;m=Q.current,Q.current=null,Je();try{if(r){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(I){n=I}Reflect.construct(e,[],s)}else{try{s.call()}catch(I){n=I}e.call(s.prototype)}}else{try{throw Error()}catch(I){n=I}e()}}catch(I){if(I&&n&&typeof I.stack=="string"){for(var o=I.stack.split(` | ||
`),C=n.stack.split(` | ||
`),_=o.length-1,x=C.length-1;_>=1&&x>=0&&o[_]!==C[x];)x--;for(;_>=1&&x>=0;_--,x--)if(o[_]!==C[x]){if(_!==1||x!==1)do if(_--,x--,x<0||o[_]!==C[x]){var A=` | ||
`+o[_].replace(" at new "," at ");return e.displayName&&A.includes("<anonymous>")&&(A=A.replace("<anonymous>",e.displayName)),typeof e=="function"&&J.set(e,A),A}while(_>=1&&x>=0);break}}}finally{q=!1,Q.current=m,Ge(),Error.prepareStackTrace=d}var L=e?e.displayName||e.name:"",De=L?z(L):"";return typeof e=="function"&&J.set(e,De),De}function Ke(e,t,r){return Ee(e,!1)}function Xe(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function G(e,t,r){if(e==null)return"";if(typeof e=="function")return Ee(e,Xe(e));if(typeof e=="string")return z(e);switch(e){case p:return z("Suspense");case i:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case c:return Ke(e.render);case a:return G(e.type,t,r);case f:{var n=e,d=n._payload,m=n._init;try{return G(m(d),t,r)}catch{}}}return""}var H=Object.prototype.hasOwnProperty,Re={},_e=y.ReactDebugCurrentFrame;function K(e){if(e){var t=e._owner,r=G(e.type,e._source,t?t.type:null);_e.setExtraStackFrame(r)}else _e.setExtraStackFrame(null)}function Ze(e,t,r,n,d){{var m=Function.call.bind(H);for(var s in e)if(m(e,s)){var o=void 0;try{if(typeof e[s]!="function"){var C=Error((n||"React class")+": "+r+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw C.name="Invariant Violation",C}o=e[s](t,s,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(_){o=_}o&&!(o instanceof Error)&&(K(d),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,s,typeof o),K(null)),o instanceof Error&&!(o.message in Re)&&(Re[o.message]=!0,K(d),h("Failed %s type: %s",r,o.message),K(null))}}}var Qe=Array.isArray;function ee(e){return Qe(e)}function $e(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function qe(e){try{return be(e),!1}catch{return!0}}function be(e){return""+e}function xe(e){if(qe(e))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",$e(e)),be(e)}var U=y.ReactCurrentOwner,et={key:!0,ref:!0,__self:!0,__source:!0},Te,we,te;te={};function tt(e){if(H.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function rt(e){if(H.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function nt(e,t){if(typeof e.ref=="string"&&U.current&&t&&U.current.stateNode!==t){var r=F(U.current.type);te[r]||(h('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(U.current.type),e.ref),te[r]=!0)}}function at(e,t){{var r=function(){Te||(Te=!0,h("%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://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function ot(e,t){{var r=function(){we||(we=!0,h("%s: `ref` 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://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var it=function(e,t,r,n,d,m,s){var o={$$typeof:v,type:e,key:t,ref:r,props:s,_owner:m};return o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(o,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(o,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o};function st(e,t,r,n,d){{var m,s={},o=null,C=null;r!==void 0&&(xe(r),o=""+r),rt(t)&&(xe(t.key),o=""+t.key),tt(t)&&(C=t.ref,nt(t,d));for(m in t)H.call(t,m)&&!et.hasOwnProperty(m)&&(s[m]=t[m]);if(e&&e.defaultProps){var _=e.defaultProps;for(m in _)s[m]===void 0&&(s[m]=_[m])}if(o||C){var x=typeof e=="function"?e.displayName||e.name||"Unknown":e;o&&at(s,x),C&&ot(s,x)}return it(e,o,C,d,n,U.current,s)}}var re=y.ReactCurrentOwner,Se=y.ReactDebugCurrentFrame;function M(e){if(e){var t=e._owner,r=G(e.type,e._source,t?t.type:null);Se.setExtraStackFrame(r)}else Se.setExtraStackFrame(null)}var ne;ne=!1;function ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===v}function Oe(){{if(re.current){var e=F(re.current.type);if(e)return` | ||
`+o[_].replace(" at new "," at ");return e.displayName&&A.includes("<anonymous>")&&(A=A.replace("<anonymous>",e.displayName)),typeof e=="function"&&J.set(e,A),A}while(_>=1&&x>=0);break}}}finally{q=!1,Q.current=m,Ge(),Error.prepareStackTrace=l}var L=e?e.displayName||e.name:"",De=L?z(L):"";return typeof e=="function"&&J.set(e,De),De}function Ke(e,r,t){return Ee(e,!1)}function Xe(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function G(e,r,t){if(e==null)return"";if(typeof e=="function")return Ee(e,Xe(e));if(typeof e=="string")return z(e);switch(e){case p:return z("Suspense");case i:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case c:return Ke(e.render);case a:return G(e.type,r,t);case f:{var n=e,l=n._payload,m=n._init;try{return G(m(l),r,t)}catch{}}}return""}var H=Object.prototype.hasOwnProperty,Re={},_e=y.ReactDebugCurrentFrame;function K(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);_e.setExtraStackFrame(t)}else _e.setExtraStackFrame(null)}function Ze(e,r,t,n,l){{var m=Function.call.bind(H);for(var s in e)if(m(e,s)){var o=void 0;try{if(typeof e[s]!="function"){var C=Error((n||"React class")+": "+t+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw C.name="Invariant Violation",C}o=e[s](r,s,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(_){o=_}o&&!(o instanceof Error)&&(K(l),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,s,typeof o),K(null)),o instanceof Error&&!(o.message in Re)&&(Re[o.message]=!0,K(l),h("Failed %s type: %s",t,o.message),K(null))}}}var Qe=Array.isArray;function ee(e){return Qe(e)}function $e(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function qe(e){try{return be(e),!1}catch{return!0}}function be(e){return""+e}function xe(e){if(qe(e))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",$e(e)),be(e)}var U=y.ReactCurrentOwner,er={key:!0,ref:!0,__self:!0,__source:!0},Te,we,re;re={};function rr(e){if(H.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function tr(e){if(H.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function nr(e,r){if(typeof e.ref=="string"&&U.current&&r&&U.current.stateNode!==r){var t=F(U.current.type);re[t]||(h('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(U.current.type),e.ref),re[t]=!0)}}function ar(e,r){{var t=function(){Te||(Te=!0,h("%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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function or(e,r){{var t=function(){we||(we=!0,h("%s: `ref` 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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ir=function(e,r,t,n,l,m,s){var o={$$typeof:v,type:e,key:r,ref:t,props:s,_owner:m};return o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(o,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(o,"_source",{configurable:!1,enumerable:!1,writable:!1,value:l}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o};function sr(e,r,t,n,l){{var m,s={},o=null,C=null;t!==void 0&&(xe(t),o=""+t),tr(r)&&(xe(r.key),o=""+r.key),rr(r)&&(C=r.ref,nr(r,l));for(m in r)H.call(r,m)&&!er.hasOwnProperty(m)&&(s[m]=r[m]);if(e&&e.defaultProps){var _=e.defaultProps;for(m in _)s[m]===void 0&&(s[m]=_[m])}if(o||C){var x=typeof e=="function"?e.displayName||e.name||"Unknown":e;o&&ar(s,x),C&&or(s,x)}return ir(e,o,C,l,n,U.current,s)}}var te=y.ReactCurrentOwner,Se=y.ReactDebugCurrentFrame;function M(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);Se.setExtraStackFrame(t)}else Se.setExtraStackFrame(null)}var ne;ne=!1;function ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===v}function Oe(){{if(te.current){var e=F(te.current.type);if(e)return` | ||
Check the render method of \``+e+"`."}return""}}function ut(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),r=e.lineNumber;return` | ||
Check the render method of \``+e+"`."}return""}}function ur(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return` | ||
Check your code at `+t+":"+r+"."}return""}}var Pe={};function ct(e){{var t=Oe();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=` | ||
Check your code at `+r+":"+t+"."}return""}}var Pe={};function cr(e){{var r=Oe();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=` | ||
Check the top-level render call using <`+r+">.")}return t}}function Ce(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=ct(t);if(Pe[r])return;Pe[r]=!0;var n="";e&&e._owner&&e._owner!==re.current&&(n=" It was passed a child from "+F(e._owner.type)+"."),M(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,n),M(null)}}function je(e,t){{if(typeof e!="object")return;if(ee(e))for(var r=0;r<e.length;r++){var n=e[r];ae(n)&&Ce(n,t)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var d=k(e);if(typeof d=="function"&&d!==e.entries)for(var m=d.call(e),s;!(s=m.next()).done;)ae(s.value)&&Ce(s.value,t)}}}function lt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===c||t.$$typeof===a))r=t.propTypes;else return;if(r){var n=F(t);Ze(r,e.props,"prop",n,e)}else if(t.PropTypes!==void 0&&!ne){ne=!0;var d=F(t);h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ft(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if(n!=="children"&&n!=="key"){M(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),M(null);break}}e.ref!==null&&(M(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),M(null))}}function Ae(e,t,r,n,d,m){{var s=Ue(e);if(!s){var o="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(o+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var C=ut(d);C?o+=C:o+=Oe();var _;e===null?_="null":ee(e)?_="array":e!==void 0&&e.$$typeof===v?(_="<"+(F(e.type)||"Unknown")+" />",o=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,o)}var x=st(e,t,r,d,m);if(x==null)return x;if(s){var A=t.children;if(A!==void 0)if(n)if(ee(A)){for(var L=0;L<A.length;L++)je(A[L],e);Object.freeze&&Object.freeze(A)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else je(A,e)}return e===E?ft(x):lt(x),x}}function dt(e,t,r){return Ae(e,t,r,!0)}function vt(e,t,r){return Ae(e,t,r,!1)}var pt=vt,ht=dt;W.Fragment=E,W.jsx=pt,W.jsxs=ht}()),W}process.env.NODE_ENV==="production"?X.exports=ke():X.exports=Fe();var se=X.exports;const Ie=(l,v,w,E)=>{let g=v/(w+E),R=Math.floor(l.length/g);g>l.length&&(g=l.length,R=1);const b=[];for(let u=0;u<g;u++){let c=0;for(let p=0;p<R&&u*R+p<l.length;p++)c+=l[u*R+p];b.push(c/R)}return b},Ve=(l,v,w,E,g,R)=>{const b=v.height/2,u=v.getContext("2d");u&&(u.clearRect(0,0,v.width,v.height),g!=="transparent"&&(u.fillStyle=g,u.fillRect(0,0,v.width,v.height)),l.forEach((c,p)=>{u.fillStyle=R;const i=p*(w+E),a=b-c/2,f=w,O=c||1;u.beginPath(),u.roundRect(i,a,f,O,50),u.fill()}))},Ye=({mediaRecorder:l,width:v="100%",height:w="100%",barWidth:E=2,gap:g=1,backgroundColor:R="transparent",barColor:b="rgb(160, 198, 255)",fftSize:u=1024,maxDecibels:c=-10,minDecibels:p=-90,smoothingTimeConstant:i=.4})=>{const[a]=T.useState(()=>new AudioContext),[f,O]=T.useState(),P=T.useRef(null);T.useEffect(()=>{if(!l.stream)return;const y=a.createAnalyser();O(y),y.fftSize=u,y.minDecibels=p,y.maxDecibels=c,y.smoothingTimeConstant=i,a.createMediaStreamSource(l.stream).connect(y)},[l.stream]),T.useEffect(()=>{f&&l.state==="recording"&&(console.log("report ==== mediaRecorder.state",l.state),console.log("report ==== context.state",a.state),D())},[f,l.state]);const D=T.useCallback(()=>{if(!f)return;const y=new Uint8Array(f==null?void 0:f.frequencyBinCount);l.state==="recording"?(f==null||f.getByteFrequencyData(y),k(y),requestAnimationFrame(D)):l.state==="paused"?k(y):l.state==="inactive"&&a.state!=="closed"&&(console.log("mediaRecorder.state",l.state),console.log("context.state",a.state),a.close(),console.log("context.close()"))},[f,a.state]),k=y=>{if(!P.current)return;const h=Ie(y,P.current.width,E,g);Ve(h,P.current,E,g,R,b)};return se.jsx("canvas",{ref:P,width:v,height:w,style:{aspectRatio:"unset"}})},Me=(l,v,w,E,g)=>{const R=l.getChannelData(0),b=w/(E+g),u=Math.floor(R.length/b),c=v/2;let p=[],i=0;for(let a=0;a<b;a++){const f=[];let O=0;const P=[];let D=0;for(let S=0;S<u&&a*u+S<l.length;S++){const j=R[a*u+S];j<=0&&(f.push(j),O++),j>0&&(P.push(j),D++)}const k=f.reduce((S,j)=>S+j,0)/O,h={max:P.reduce((S,j)=>S+j,0)/D,min:k};h.max>i&&(i=h.max),Math.abs(h.min)>i&&(i=Math.abs(h.min)),p.push(h)}if(c*.8>i*c){const a=c*.8/i;p=p.map(f=>({max:f.max*a,min:f.min*a}))}return p},Z=(l,v,w,E,g,R,b,u=0,c=1)=>{const p=v.height/2,i=v.getContext("2d");if(!i)return;i.clearRect(0,0,v.width,v.height),g!=="transparent"&&(i.fillStyle=g,i.fillRect(0,0,v.width,v.height));const a=(u||0)/c;l.forEach((f,O)=>{const P=O/l.length,D=a>P;i.fillStyle=D&&b?b:R;const k=O*(w+E),y=p+f.min,h=w,S=p+f.max-y;i.beginPath(),i.roundRect(k,y,h,S,50),i.fill()})},ue=T.forwardRef(({blob:l,width:v,height:w,barWidth:E=2,gap:g=1,currentTime:R,style:b,backgroundColor:u="transparent",barColor:c="rgb(184, 184, 184)",barPlayedColor:p="rgb(160, 198, 255)"},i)=>{const a=T.useRef(null),[f,O]=T.useState([]),[P,D]=T.useState(0);return T.useImperativeHandle(i,()=>a.current,[]),T.useEffect(()=>{(async()=>{if(!a.current)return;if(!l){const S=Array.from({length:100},()=>({max:0,min:0}));Z(S,a.current,E,g,u,c,p);return}const y=await l.arrayBuffer();await new AudioContext().decodeAudioData(y,S=>{if(!a.current)return;D(S.duration);const j=Me(S,w,v,E,g);O(j),Z(j,a.current,E,g,u,c,p)})})()},[l,a.current]),T.useEffect(()=>{a.current&&Z(f,a.current,E,g,u,c,p,R,P)},[R,P]),se.jsx("canvas",{ref:a,width:v,height:w,style:{...b}})});ue.displayName="AudioVisualizer",V.AudioVisualizer=ue,V.LiveAudioVisualizer=Ye,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})}); | ||
Check the top-level render call using <`+t+">.")}return r}}function Ce(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=cr(r);if(Pe[t])return;Pe[t]=!0;var n="";e&&e._owner&&e._owner!==te.current&&(n=" It was passed a child from "+F(e._owner.type)+"."),M(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),M(null)}}function je(e,r){{if(typeof e!="object")return;if(ee(e))for(var t=0;t<e.length;t++){var n=e[t];ae(n)&&Ce(n,r)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var l=k(e);if(typeof l=="function"&&l!==e.entries)for(var m=l.call(e),s;!(s=m.next()).done;)ae(s.value)&&Ce(s.value,r)}}}function fr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===c||r.$$typeof===a))t=r.propTypes;else return;if(t){var n=F(r);Ze(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ne){ne=!0;var l=F(r);h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",l||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){M(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),M(null);break}}e.ref!==null&&(M(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),M(null))}}function Ae(e,r,t,n,l,m){{var s=Ue(e);if(!s){var o="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(o+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var C=ur(l);C?o+=C:o+=Oe();var _;e===null?_="null":ee(e)?_="array":e!==void 0&&e.$$typeof===v?(_="<"+(F(e.type)||"Unknown")+" />",o=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,o)}var x=sr(e,r,t,l,m);if(x==null)return x;if(s){var A=r.children;if(A!==void 0)if(n)if(ee(A)){for(var L=0;L<A.length;L++)je(A[L],e);Object.freeze&&Object.freeze(A)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else je(A,e)}return e===E?lr(x):fr(x),x}}function dr(e,r,t){return Ae(e,r,t,!0)}function vr(e,r,t){return Ae(e,r,t,!1)}var pr=vr,hr=dr;W.Fragment=E,W.jsx=pr,W.jsxs=hr}()),W}process.env.NODE_ENV==="production"?X.exports=ke():X.exports=Fe();var se=X.exports;const Ie=(d,v,w,E)=>{let g=v/(w+E),R=Math.floor(d.length/g);g>d.length&&(g=d.length,R=1);const b=[];for(let u=0;u<g;u++){let c=0;for(let p=0;p<R&&u*R+p<d.length;p++)c+=d[u*R+p];b.push(c/R)}return b},Ve=(d,v,w,E,g,R)=>{const b=v.height/2,u=v.getContext("2d");u&&(u.clearRect(0,0,v.width,v.height),g!=="transparent"&&(u.fillStyle=g,u.fillRect(0,0,v.width,v.height)),d.forEach((c,p)=>{u.fillStyle=R;const i=p*(w+E),a=b-c/2,f=w,O=c||1;u.beginPath(),u.roundRect(i,a,f,O,50),u.fill()}))},Ye=({mediaRecorder:d,width:v="100%",height:w="100%",barWidth:E=2,gap:g=1,backgroundColor:R="transparent",barColor:b="rgb(160, 198, 255)",fftSize:u=1024,maxDecibels:c=-10,minDecibels:p=-90,smoothingTimeConstant:i=.4})=>{const[a]=T.useState(()=>new AudioContext),[f,O]=T.useState(),P=T.useRef(null);T.useEffect(()=>{if(!d.stream)return;const y=a.createAnalyser();O(y),y.fftSize=u,y.minDecibels=p,y.maxDecibels=c,y.smoothingTimeConstant=i,a.createMediaStreamSource(d.stream).connect(y)},[d.stream]),T.useEffect(()=>{f&&d.state==="recording"&&D()},[f,d.state]);const D=T.useCallback(()=>{if(!f)return;const y=new Uint8Array(f==null?void 0:f.frequencyBinCount);d.state==="recording"?(f==null||f.getByteFrequencyData(y),k(y),requestAnimationFrame(D)):d.state==="paused"?k(y):d.state==="inactive"&&a.state!=="closed"&&a.close()},[f,a.state]),k=y=>{if(!P.current)return;const h=Ie(y,P.current.width,E,g);Ve(h,P.current,E,g,R,b)};return se.jsx("canvas",{ref:P,width:v,height:w,style:{aspectRatio:"unset"}})},Me=(d,v,w,E,g)=>{const R=d.getChannelData(0),b=w/(E+g),u=Math.floor(R.length/b),c=v/2;let p=[],i=0;for(let a=0;a<b;a++){const f=[];let O=0;const P=[];let D=0;for(let S=0;S<u&&a*u+S<d.length;S++){const j=R[a*u+S];j<=0&&(f.push(j),O++),j>0&&(P.push(j),D++)}const k=f.reduce((S,j)=>S+j,0)/O,h={max:P.reduce((S,j)=>S+j,0)/D,min:k};h.max>i&&(i=h.max),Math.abs(h.min)>i&&(i=Math.abs(h.min)),p.push(h)}if(c*.8>i*c){const a=c*.8/i;p=p.map(f=>({max:f.max*a,min:f.min*a}))}return p},Z=(d,v,w,E,g,R,b,u=0,c=1)=>{const p=v.height/2,i=v.getContext("2d");if(!i)return;i.clearRect(0,0,v.width,v.height),g!=="transparent"&&(i.fillStyle=g,i.fillRect(0,0,v.width,v.height));const a=(u||0)/c;d.forEach((f,O)=>{const P=O/d.length,D=a>P;i.fillStyle=D&&b?b:R;const k=O*(w+E),y=p+f.min,h=w,S=p+f.max-y;i.beginPath(),i.roundRect(k,y,h,S,50),i.fill()})},ue=T.forwardRef(({blob:d,width:v,height:w,barWidth:E=2,gap:g=1,currentTime:R,style:b,backgroundColor:u="transparent",barColor:c="rgb(184, 184, 184)",barPlayedColor:p="rgb(160, 198, 255)"},i)=>{const a=T.useRef(null),[f,O]=T.useState([]),[P,D]=T.useState(0);return T.useImperativeHandle(i,()=>a.current,[]),T.useEffect(()=>{(async()=>{if(!a.current)return;if(!d){const S=Array.from({length:100},()=>({max:0,min:0}));Z(S,a.current,E,g,u,c,p);return}const y=await d.arrayBuffer();await new AudioContext().decodeAudioData(y,S=>{if(!a.current)return;D(S.duration);const j=Me(S,w,v,E,g);O(j),Z(j,a.current,E,g,u,c,p)})})()},[d,a.current]),T.useEffect(()=>{a.current&&Z(f,a.current,E,g,u,c,p,R,P)},[R,P]),se.jsx("canvas",{ref:a,width:v,height:w,style:{...b}})});ue.displayName="AudioVisualizer",V.AudioVisualizer=ue,V.LiveAudioVisualizer=Ye,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})}); |
{ | ||
"name": "react-audio-visualize", | ||
"private": false, | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55467
1034