react-audio-wavekit 0.1.0 → 0.1.2
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.
|
@@ -106,21 +106,7 @@ const LiveStreamingStackRecorder = react.forwardRef(
|
|
|
106
106
|
}
|
|
107
107
|
drawWaveform();
|
|
108
108
|
}, [isRecording, isPaused, drawWaveform]);
|
|
109
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
110
|
-
"canvas",
|
|
111
|
-
{
|
|
112
|
-
ref: canvasRef,
|
|
113
|
-
className,
|
|
114
|
-
style: {
|
|
115
|
-
width: "100%",
|
|
116
|
-
height: "100%",
|
|
117
|
-
...style
|
|
118
|
-
},
|
|
119
|
-
"aria-hidden": "true",
|
|
120
|
-
tabIndex: -1,
|
|
121
|
-
...props
|
|
122
|
-
}
|
|
123
|
-
);
|
|
109
|
+
return /* @__PURE__ */ jsxRuntime.jsx("canvas", { ref: canvasRef, className, style, "aria-hidden": "true", tabIndex: -1, ...props });
|
|
124
110
|
}
|
|
125
111
|
);
|
|
126
112
|
exports.LiveStreamingStackRecorder = LiveStreamingStackRecorder;
|
|
@@ -104,21 +104,7 @@ const LiveStreamingStackRecorder = forwardRef(
|
|
|
104
104
|
}
|
|
105
105
|
drawWaveform();
|
|
106
106
|
}, [isRecording, isPaused, drawWaveform]);
|
|
107
|
-
return /* @__PURE__ */ jsx(
|
|
108
|
-
"canvas",
|
|
109
|
-
{
|
|
110
|
-
ref: canvasRef,
|
|
111
|
-
className,
|
|
112
|
-
style: {
|
|
113
|
-
width: "100%",
|
|
114
|
-
height: "100%",
|
|
115
|
-
...style
|
|
116
|
-
},
|
|
117
|
-
"aria-hidden": "true",
|
|
118
|
-
tabIndex: -1,
|
|
119
|
-
...props
|
|
120
|
-
}
|
|
121
|
-
);
|
|
107
|
+
return /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className, style, "aria-hidden": "true", tabIndex: -1, ...props });
|
|
122
108
|
}
|
|
123
109
|
);
|
|
124
110
|
export {
|
package/dist/waveform/index.cjs
CHANGED
|
@@ -5,20 +5,16 @@ const react = require("react");
|
|
|
5
5
|
const utilAudioDecoder = require("./util-audio-decoder.cjs");
|
|
6
6
|
const utilSuspense = require("./util-suspense.cjs");
|
|
7
7
|
const waveformRenderer = require("./waveform-renderer.cjs");
|
|
8
|
-
const
|
|
8
|
+
const getInitialSampleCount = () => {
|
|
9
|
+
if (typeof window === "undefined") return 500;
|
|
10
|
+
return Math.max(500, Math.ceil(window.innerWidth));
|
|
11
|
+
};
|
|
9
12
|
const AudioWaveform = react.forwardRef(function AudioWaveform2({ blob, appearance, suspense = false, currentTime, duration, onSeek, ...props }, ref) {
|
|
10
13
|
const [peaks, setPeaks] = react.useState(null);
|
|
11
14
|
const [error, setError] = react.useState(null);
|
|
12
|
-
const [sampleCount, setSampleCount] = react.useState(DEFAULT_SAMPLE_COUNT);
|
|
13
|
-
const sampleCountInitializedRef = react.useRef(false);
|
|
14
15
|
const blobRef = react.useRef(null);
|
|
15
16
|
const rendererRef = react.useRef(null);
|
|
16
|
-
react.
|
|
17
|
-
if (!sampleCountInitializedRef.current) {
|
|
18
|
-
setSampleCount(Math.max(500, Math.ceil(window.innerWidth)));
|
|
19
|
-
sampleCountInitializedRef.current = true;
|
|
20
|
-
}
|
|
21
|
-
}, []);
|
|
17
|
+
const sampleCount = react.useMemo(() => getInitialSampleCount(), []);
|
|
22
18
|
react.useEffect(() => {
|
|
23
19
|
if (ref && typeof ref === "function") {
|
|
24
20
|
ref({ canvas: rendererRef.current?.canvas || null });
|
package/dist/waveform/index.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useState, useRef, useEffect } from "react";
|
|
2
|
+
import { forwardRef, useState, useRef, useMemo, useEffect } from "react";
|
|
3
3
|
import { getAudioData, decodeAudioBlob } from "./util-audio-decoder.js";
|
|
4
4
|
import { unwrapPromise } from "./util-suspense.js";
|
|
5
5
|
import { WaveformRenderer } from "./waveform-renderer.js";
|
|
6
|
-
const
|
|
6
|
+
const getInitialSampleCount = () => {
|
|
7
|
+
if (typeof window === "undefined") return 500;
|
|
8
|
+
return Math.max(500, Math.ceil(window.innerWidth));
|
|
9
|
+
};
|
|
7
10
|
const AudioWaveform = forwardRef(function AudioWaveform2({ blob, appearance, suspense = false, currentTime, duration, onSeek, ...props }, ref) {
|
|
8
11
|
const [peaks, setPeaks] = useState(null);
|
|
9
12
|
const [error, setError] = useState(null);
|
|
10
|
-
const [sampleCount, setSampleCount] = useState(DEFAULT_SAMPLE_COUNT);
|
|
11
|
-
const sampleCountInitializedRef = useRef(false);
|
|
12
13
|
const blobRef = useRef(null);
|
|
13
14
|
const rendererRef = useRef(null);
|
|
14
|
-
|
|
15
|
-
if (!sampleCountInitializedRef.current) {
|
|
16
|
-
setSampleCount(Math.max(500, Math.ceil(window.innerWidth)));
|
|
17
|
-
sampleCountInitializedRef.current = true;
|
|
18
|
-
}
|
|
19
|
-
}, []);
|
|
15
|
+
const sampleCount = useMemo(() => getInitialSampleCount(), []);
|
|
20
16
|
useEffect(() => {
|
|
21
17
|
if (ref && typeof ref === "function") {
|
|
22
18
|
ref({ canvas: rendererRef.current?.canvas || null });
|