@remotion/studio 4.0.450 → 4.0.452

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/Studio.js CHANGED
@@ -17,7 +17,7 @@ const getServerDisconnectedDomElement = () => {
17
17
  };
18
18
  const StudioInner = ({ rootComponent, readOnly, visualModeEnabled }) => {
19
19
  var _a, _b;
20
- return (jsx_runtime_1.jsx(remotion_1.Internals.CompositionManagerProvider, { onlyRenderComposition: null, currentCompositionMetadata: null, initialCompositions: [], initialCanvasContent: null, children: jsx_runtime_1.jsx(remotion_1.Internals.RemotionRootContexts, { visualModeEnabled: visualModeEnabled, frameState: null, audioEnabled: window.remotion_audioEnabled, videoEnabled: window.remotion_videoEnabled, logLevel: (_a = window.remotion_logLevel) !== null && _a !== void 0 ? _a : 'info', numberOfAudioTags: window.remotion_numberOfAudioTags, audioLatencyHint: (_b = window.remotion_audioLatencyHint) !== null && _b !== void 0 ? _b : 'interactive', children: jsx_runtime_1.jsx(use_static_files_1.StaticFilesProvider, { children: jsx_runtime_1.jsx(ResolveCompositionConfigInStudio_1.ResolveCompositionConfigInStudio, { children: jsx_runtime_1.jsxs(EditorContexts_1.EditorContexts, { readOnlyStudio: readOnly, children: [
20
+ return (jsx_runtime_1.jsx(remotion_1.Internals.CompositionManagerProvider, { onlyRenderComposition: null, currentCompositionMetadata: null, initialCompositions: [], initialCanvasContent: null, children: jsx_runtime_1.jsx(remotion_1.Internals.RemotionRootContexts, { visualModeEnabled: visualModeEnabled, frameState: null, audioEnabled: window.remotion_audioEnabled, videoEnabled: window.remotion_videoEnabled, logLevel: (_a = window.remotion_logLevel) !== null && _a !== void 0 ? _a : 'info', numberOfAudioTags: window.remotion_numberOfAudioTags, audioLatencyHint: (_b = window.remotion_audioLatencyHint) !== null && _b !== void 0 ? _b : 'playback', children: jsx_runtime_1.jsx(use_static_files_1.StaticFilesProvider, { children: jsx_runtime_1.jsx(ResolveCompositionConfigInStudio_1.ResolveCompositionConfigInStudio, { children: jsx_runtime_1.jsxs(EditorContexts_1.EditorContexts, { readOnlyStudio: readOnly, children: [
21
21
  jsx_runtime_1.jsx(Editor_1.Editor, { readOnlyStudio: readOnly, Root: rootComponent }), readOnly
22
22
  ? null
23
23
  : (0, react_dom_1.createPortal)(jsx_runtime_1.jsx(ServerDisconnected_1.ServerDisconnected, {}), getServerDisconnectedDomElement())] }) }) }) }) }));
@@ -4,7 +4,6 @@ exports.TimelineWidthProvider = exports.TimelineWidthContext = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const player_1 = require("@remotion/player");
6
6
  const react_1 = require("react");
7
- const timeline_zoom_1 = require("../../state/timeline-zoom");
8
7
  const timeline_refs_1 = require("./timeline-refs");
9
8
  exports.TimelineWidthContext = (0, react_1.createContext)(null);
10
9
  const TimelineWidthProvider = ({ children }) => {
@@ -13,20 +12,6 @@ const TimelineWidthProvider = ({ children }) => {
13
12
  triggerOnWindowResize: false,
14
13
  shouldApplyCssTransforms: true,
15
14
  });
16
- const { zoom: zoomMap } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
17
- const [widthOverride, setWidthOverride] = (0, react_1.useState)(null);
18
- const observedWidth = (_a = size === null || size === void 0 ? void 0 : size.width) !== null && _a !== void 0 ? _a : null;
19
- (0, react_1.useLayoutEffect)(() => {
20
- var _a;
21
- var _b;
22
- const actual = (_b = (_a = timeline_refs_1.sliderAreaRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : null;
23
- if (actual !== null && actual !== observedWidth) {
24
- setWidthOverride(actual);
25
- }
26
- else {
27
- setWidthOverride(null);
28
- }
29
- }, [observedWidth, zoomMap]);
30
- return (jsx_runtime_1.jsx(exports.TimelineWidthContext.Provider, { value: widthOverride !== null && widthOverride !== void 0 ? widthOverride : observedWidth, children: children }));
15
+ return (jsx_runtime_1.jsx(exports.TimelineWidthContext.Provider, { value: (_a = size === null || size === void 0 ? void 0 : size.width) !== null && _a !== void 0 ? _a : null, children: children }));
31
16
  };
32
17
  exports.TimelineWidthProvider = TimelineWidthProvider;
@@ -7,6 +7,7 @@ const TARGET_SAMPLE_RATE = 100;
7
7
  exports.TARGET_SAMPLE_RATE = TARGET_SAMPLE_RATE;
8
8
  const peaksCache = new Map();
9
9
  async function loadWaveformPeaks(url, signal) {
10
+ var _a;
10
11
  const cached = peaksCache.get(url);
11
12
  if (cached)
12
13
  return cached;
@@ -22,7 +23,7 @@ async function loadWaveformPeaks(url, signal) {
22
23
  const { sampleRate } = audioTrack;
23
24
  const durationInSeconds = await audioTrack.computeDuration();
24
25
  const totalPeaks = Math.ceil(durationInSeconds * TARGET_SAMPLE_RATE);
25
- const samplesPerPeak = Math.floor(sampleRate / TARGET_SAMPLE_RATE);
26
+ const samplesPerPeak = Math.max(1, Math.floor(sampleRate / TARGET_SAMPLE_RATE));
26
27
  const peaks = new Float32Array(totalPeaks);
27
28
  let peakIndex = 0;
28
29
  let peakMax = 0;
@@ -39,11 +40,22 @@ async function loadWaveformPeaks(url, signal) {
39
40
  });
40
41
  const floats = new Float32Array(bytesNeeded / 4);
41
42
  sample.copyTo(floats, { format: 'f32', planeIndex: 0 });
43
+ const channels = Math.max(1, sample.numberOfChannels);
44
+ const frames = sample.numberOfFrames;
42
45
  sample.close();
43
- for (let i = 0; i < floats.length; i++) {
44
- const abs = Math.abs(floats[i]);
45
- if (abs > peakMax)
46
- peakMax = abs;
46
+ for (let frame = 0; frame < frames; frame++) {
47
+ // `f32` copies are interleaved, so timing must advance per frame, not per float.
48
+ let framePeak = 0;
49
+ for (let channel = 0; channel < channels; channel++) {
50
+ const sampleIndex = frame * channels + channel;
51
+ const abs = Math.abs((_a = floats[sampleIndex]) !== null && _a !== void 0 ? _a : 0);
52
+ if (abs > framePeak) {
53
+ framePeak = abs;
54
+ }
55
+ }
56
+ if (framePeak > peakMax) {
57
+ peakMax = framePeak;
58
+ }
47
59
  sampleInPeak++;
48
60
  if (sampleInPeak >= samplesPerPeak) {
49
61
  if (peakIndex < totalPeaks) {