remotion 4.0.526 → 4.0.528

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.
Files changed (66) hide show
  1. package/dist/cjs/AbsoluteFill.d.ts +29 -3
  2. package/dist/cjs/AbsoluteFill.js +19 -2
  3. package/dist/cjs/CompositionManager.d.ts +2 -0
  4. package/dist/cjs/HtmlInCanvas.d.ts +28 -2
  5. package/dist/cjs/HtmlInCanvas.js +17 -3
  6. package/dist/cjs/Img.d.ts +2 -2
  7. package/dist/cjs/Img.js +1 -1
  8. package/dist/cjs/Interactive.d.ts +20 -2
  9. package/dist/cjs/Interactive.js +30 -8
  10. package/dist/cjs/Sequence.d.ts +1 -0
  11. package/dist/cjs/Sequence.js +49 -18
  12. package/dist/cjs/SequenceContext.d.ts +5 -0
  13. package/dist/cjs/TimelineContext.d.ts +2 -0
  14. package/dist/cjs/TimelineContext.js +8 -1
  15. package/dist/cjs/animated-image/AnimatedImage.d.ts +9 -10
  16. package/dist/cjs/animated-image/AnimatedImage.js +1 -12
  17. package/dist/cjs/audio/AudioForPreview.js +1 -0
  18. package/dist/cjs/audio/AudioForRendering.js +11 -7
  19. package/dist/cjs/audio/html5-audio.js +14 -7
  20. package/dist/cjs/audio/use-audio-frame.d.ts +1 -0
  21. package/dist/cjs/audio/use-audio-frame.js +14 -2
  22. package/dist/cjs/calculate-media-duration.js +1 -2
  23. package/dist/cjs/canvas-image/CanvasImage.d.ts +1 -1
  24. package/dist/cjs/canvas-image/CanvasImage.js +1 -1
  25. package/dist/cjs/canvas-image/props.d.ts +1 -1
  26. package/dist/cjs/effects/Solid.d.ts +28 -2
  27. package/dist/cjs/effects/Solid.js +16 -3
  28. package/dist/cjs/freeze.js +11 -3
  29. package/dist/cjs/get-asset-file-name.js +7 -1
  30. package/dist/cjs/get-sequence-boundary-tolerance.d.ts +7 -0
  31. package/dist/cjs/get-sequence-boundary-tolerance.js +10 -0
  32. package/dist/cjs/index.d.ts +3 -3
  33. package/dist/cjs/interactivity-schema.d.ts +75 -1
  34. package/dist/cjs/interactivity-schema.js +21 -1
  35. package/dist/cjs/internals.d.ts +23 -2
  36. package/dist/cjs/internals.js +2 -0
  37. package/dist/cjs/interpolate.d.ts +5 -0
  38. package/dist/cjs/interpolate.js +85 -5
  39. package/dist/cjs/loop/index.d.ts +7 -1
  40. package/dist/cjs/loop/index.js +35 -9
  41. package/dist/cjs/no-react.d.ts +10 -1
  42. package/dist/cjs/series/index.d.ts +1 -1
  43. package/dist/cjs/series/index.js +1 -0
  44. package/dist/cjs/spring/spring-utils.js +15 -12
  45. package/dist/cjs/timeline-position-state.d.ts +1 -0
  46. package/dist/cjs/timeline-position-state.js +8 -1
  47. package/dist/cjs/use-current-frame.js +2 -1
  48. package/dist/cjs/use-media-in-timeline.d.ts +5 -2
  49. package/dist/cjs/use-media-in-timeline.js +78 -13
  50. package/dist/cjs/use-media-playback.js +8 -3
  51. package/dist/cjs/use-premounting.js +19 -5
  52. package/dist/cjs/use-timeline-seek.d.ts +6 -0
  53. package/dist/cjs/use-timeline-seek.js +18 -0
  54. package/dist/cjs/version.d.ts +1 -1
  55. package/dist/cjs/version.js +1 -1
  56. package/dist/cjs/video/OffthreadVideo.js +7 -1
  57. package/dist/cjs/video/OffthreadVideoForRendering.js +11 -8
  58. package/dist/cjs/video/VideoForPreview.js +1 -0
  59. package/dist/cjs/video/VideoForRendering.js +12 -10
  60. package/dist/cjs/video/html5-video.js +12 -7
  61. package/dist/esm/index.mjs +927 -477
  62. package/dist/esm/no-react.mjs +103 -17
  63. package/dist/esm/version.mjs +1 -1
  64. package/package.json +2 -2
  65. package/dist/cjs/nonce.d.ts +0 -11
  66. package/dist/cjs/nonce.js +0 -42
@@ -6,10 +6,13 @@ const react_1 = require("react");
6
6
  const runtime_value_store_js_1 = require("./runtime-value-store.js");
7
7
  const timeline_position_state_1 = require("./timeline-position-state");
8
8
  const use_delay_render_1 = require("./use-delay-render");
9
+ const use_remotion_environment_1 = require("./use-remotion-environment");
10
+ const use_timeline_seek_1 = require("./use-timeline-seek");
9
11
  const missingSetTimelineContext = () => {
10
12
  throw new Error('SetTimelineContext is missing. This is likely caused by a Remotion version mismatch.');
11
13
  };
12
14
  exports.SetTimelineContext = (0, react_1.createContext)({
15
+ seek: null,
13
16
  setFrame: missingSetTimelineContext,
14
17
  setPlaying: missingSetTimelineContext,
15
18
  setBuffering: missingSetTimelineContext,
@@ -29,6 +32,9 @@ const TimelineContextProvider = ({ children, frameState }) => {
29
32
  const [playbackRate, setPlaybackRate] = (0, react_1.useState)(1);
30
33
  const audioAndVideoTags = (0, react_1.useRef)([]);
31
34
  const [_frame, setFrame] = (0, react_1.useState)(() => (0, timeline_position_state_1.getInitialFrameState)());
35
+ const timelineSeek = (0, use_timeline_seek_1.useTimelineSeek)(setFrame);
36
+ const { isStudio } = (0, use_remotion_environment_1.useRemotionEnvironment)();
37
+ const seek = isStudio ? timelineSeek : null;
32
38
  const frame = frameState !== null && frameState !== void 0 ? frameState : _frame;
33
39
  const frameRef = (0, react_1.useRef)(frame);
34
40
  frameRef.current = frame;
@@ -83,6 +89,7 @@ const TimelineContextProvider = ({ children, frameState }) => {
83
89
  const setTimelineContextValue = (0, react_1.useMemo)(() => {
84
90
  return {
85
91
  setFrame,
92
+ seek,
86
93
  setPlaying: (updater) => {
87
94
  const current = playingStore.store.getSnapshot().playing;
88
95
  const next = typeof updater === 'function' ? updater(current) : updater;
@@ -102,7 +109,7 @@ const TimelineContextProvider = ({ children, frameState }) => {
102
109
  frameRef,
103
110
  audioAndVideoTags,
104
111
  };
105
- }, [bufferingStore, playingStore, readIsBuffering, readIsPlaying]);
112
+ }, [bufferingStore, playingStore, readIsBuffering, readIsPlaying, seek]);
106
113
  return (jsx_runtime_1.jsx(exports.AbsoluteTimeContext.Provider, { value: timelineContextValue, children: jsx_runtime_1.jsx(exports.PlaybackRateContext.Provider, { value: playbackRateContextValue, children: jsx_runtime_1.jsx(exports.TimelineContext.Provider, { value: timelineContextValue, children: jsx_runtime_1.jsx(exports.SetTimelineContext.Provider, { value: setTimelineContextValue, children: children }) }) }) }));
107
114
  };
108
115
  exports.TimelineContextProvider = TimelineContextProvider;
@@ -190,6 +190,15 @@ export declare const animatedImageSchema: {
190
190
  readonly step: 1;
191
191
  readonly hiddenFromList: true;
192
192
  };
193
+ readonly playbackRate: {
194
+ readonly type: "number";
195
+ readonly default: 1;
196
+ readonly min: 0.01;
197
+ readonly step: 0.1;
198
+ readonly description: "Playback rate";
199
+ readonly hiddenFromList: false;
200
+ readonly keyframable: false;
201
+ };
193
202
  readonly freeze: {
194
203
  readonly type: "number";
195
204
  readonly default: null;
@@ -206,16 +215,6 @@ export declare const animatedImageSchema: {
206
215
  readonly description: "Source";
207
216
  readonly keyframable: false;
208
217
  };
209
- readonly playbackRate: {
210
- readonly type: "number";
211
- readonly min: 0;
212
- readonly max: 10;
213
- readonly step: 0.1;
214
- readonly default: 1;
215
- readonly description: "Playback rate";
216
- readonly hiddenFromList: false;
217
- readonly keyframable: false;
218
- };
219
218
  };
220
219
  export declare const AnimatedImage: React.ComponentType<import("../Interactive.js").InteractiveBaseProps & import("../Interactive.js").InteractiveCropProps & import("../Interactive.js").InteractivePremountProps & {
221
220
  src: string;
@@ -31,16 +31,6 @@ exports.animatedImageSchema = {
31
31
  ...interactivity_schema_js_1.baseSchema,
32
32
  ...interactivity_schema_js_1.cropSchema,
33
33
  ...interactivity_schema_js_1.premountSchema,
34
- playbackRate: {
35
- type: 'number',
36
- min: 0,
37
- max: 10,
38
- step: 0.1,
39
- default: 1,
40
- description: 'Playback rate',
41
- hiddenFromList: false,
42
- keyframable: false,
43
- },
44
34
  ...interactivity_schema_js_1.transformSchema,
45
35
  ...interactivity_schema_js_1.backgroundSchema,
46
36
  ...interactivity_schema_js_1.borderSchema,
@@ -231,7 +221,6 @@ const AnimatedImageInner = ({ src, width, height, onError, fit, playbackRate, lo
231
221
  height,
232
222
  onError,
233
223
  fit,
234
- playbackRate,
235
224
  loopBehavior,
236
225
  id,
237
226
  className,
@@ -239,7 +228,7 @@ const AnimatedImageInner = ({ src, width, height, onError, fit, playbackRate, lo
239
228
  requestInit,
240
229
  ...canvasProps,
241
230
  };
242
- return (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: from !== null && from !== void 0 ? from : 0, durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity, name: "<AnimatedImage>", _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/animatedimage", controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, ...sequenceProps, outlineRef: actualRef, children: jsx_runtime_1.jsx(AnimatedImageContent, { ...animatedImageProps, ref: actualRef, effects: effects, controls: controls }) }) }));
231
+ return (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: from !== null && from !== void 0 ? from : 0, playbackRate: playbackRate, durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity, name: "<AnimatedImage>", _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/animatedimage", controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, ...sequenceProps, outlineRef: actualRef, children: jsx_runtime_1.jsx(AnimatedImageContent, { ...animatedImageProps, ref: actualRef, effects: effects, controls: controls }) }) }));
243
232
  };
244
233
  exports.AnimatedImage = (0, with_interactivity_schema_js_1.withInteractivitySchema)({
245
234
  Component: AnimatedImageInner,
@@ -140,6 +140,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
140
140
  premountDisplay: (_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premountDisplay) !== null && _a !== void 0 ? _a : null,
141
141
  postmountDisplay: (_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmountDisplay) !== null && _b !== void 0 ? _b : null,
142
142
  loopDisplay: undefined,
143
+ loopVolumeCurveBehavior: loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat',
143
144
  documentationLink: 'https://www.remotion.dev/docs/html5-audio',
144
145
  refForOutline: null,
145
146
  muted: isMutedForTimeline,
@@ -16,13 +16,15 @@ const volume_safeguard_js_1 = require("../volume-safeguard.js");
16
16
  const use_audio_frame_js_1 = require("./use-audio-frame.js");
17
17
  const use_media_audio_state_js_1 = require("./use-media-audio-state.js");
18
18
  const AudioForRenderingRefForwardingFunction = (props, ref) => {
19
- var _a;
19
+ var _a, _b;
20
20
  const audioRef = (0, react_1.useRef)(null);
21
21
  const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onNativeError, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, pauseWhenBuffering, audioStreamIndex, preservePitch: _preservePitch, ...nativeProps } = props;
22
22
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
23
23
  const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
24
24
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
25
25
  const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
26
+ const sequencePlaybackRate = (_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.playbackRate) !== null && _a !== void 0 ? _a : 1;
27
+ const audioStartFrame = (0, react_1.useContext)(use_audio_frame_js_1.Html5MediaTrimContext);
26
28
  const { registerRenderAsset, unregisterRenderAsset } = (0, react_1.useContext)(RenderAssetManager_js_1.RenderAssetManager);
27
29
  const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
28
30
  // Generate a string that's as unique as possible for this asset
@@ -44,7 +46,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
44
46
  (0, volume_safeguard_js_1.warnAboutTooHighVolume)(volume);
45
47
  const audioEnabled = (0, use_media_enabled_js_1.useAudioEnabled)();
46
48
  const { shouldUseAudio } = (0, use_media_audio_state_js_1.useMediaAudioState)({
47
- muted: (_a = props.muted) !== null && _a !== void 0 ? _a : false,
49
+ muted: (_b = props.muted) !== null && _b !== void 0 ? _b : false,
48
50
  volume,
49
51
  audioEnabled,
50
52
  });
@@ -52,7 +54,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
52
54
  return audioRef.current;
53
55
  }, []);
54
56
  (0, react_1.useEffect)(() => {
55
- var _a, _b;
57
+ var _a;
56
58
  if (!props.src) {
57
59
  throw new Error('No src passed');
58
60
  }
@@ -65,10 +67,11 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
65
67
  id,
66
68
  frame: absoluteFrame,
67
69
  volume,
68
- mediaFrame: frame,
69
- playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
70
+ // Render assets use composition frames; source trimming stays in media frames.
71
+ mediaFrame: audioStartFrame + (frame - audioStartFrame) / sequencePlaybackRate,
72
+ playbackRate: ((_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1) * sequencePlaybackRate,
70
73
  toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : 1,
71
- audioStartFrame: Math.max(0, -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedNegativeFrom) !== null && _b !== void 0 ? _b : 0)),
74
+ audioStartFrame,
72
75
  audioStreamIndex: audioStreamIndex !== null && audioStreamIndex !== void 0 ? audioStreamIndex : 0,
73
76
  });
74
77
  return () => unregisterRenderAsset(id);
@@ -85,7 +88,8 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
85
88
  playbackRate,
86
89
  props.playbackRate,
87
90
  toneFrequency,
88
- sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedNegativeFrom,
91
+ audioStartFrame,
92
+ sequencePlaybackRate,
89
93
  audioStreamIndex,
90
94
  ]);
91
95
  const { src } = props;
@@ -20,8 +20,9 @@ const duration_state_js_1 = require("../video/duration-state.js");
20
20
  const AudioForPreview_js_1 = require("./AudioForPreview.js");
21
21
  const AudioForRendering_js_1 = require("./AudioForRendering.js");
22
22
  const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
23
+ const use_audio_frame_js_1 = require("./use-audio-frame.js");
23
24
  const AudioRefForwardingFunction = (props, ref) => {
24
- var _a, _b, _c;
25
+ var _a, _b, _c, _d;
25
26
  const audioTagsContext = (0, react_1.useContext)(shared_audio_tags_js_1.SharedAudioTagsContext);
26
27
  const propsWithFreeze = props;
27
28
  const { startFrom, endAt, trimBefore, trimAfter, name, _remotionInternalStack, pauseWhenBuffering, showInTimeline, onError: onRemotionError, freeze, ...otherProps } = propsWithFreeze;
@@ -70,21 +71,27 @@ const AudioRefForwardingFunction = (props, ref) => {
70
71
  trimBefore,
71
72
  trimAfter,
72
73
  });
73
- if (loop && durationFetched !== undefined) {
74
- if (!Number.isFinite(durationFetched)) {
74
+ // An explicit trim end defines the loop before metadata has loaded. Waiting
75
+ // for metadata would leave the media unmounted when seeking into later loops.
76
+ const loopDuration = trimAfterValue !== null && trimAfterValue !== void 0 ? trimAfterValue : (durationFetched === undefined ? undefined : durationFetched * fps);
77
+ if (loop && loopDuration !== undefined) {
78
+ if (!Number.isFinite(loopDuration)) {
75
79
  return (jsx_runtime_1.jsx(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }));
76
80
  }
77
- const duration = durationFetched * fps;
78
81
  return (jsx_runtime_1.jsx(index_js_1.Loop, { layout: "none", durationInFrames: (0, calculate_media_duration_js_1.calculateMediaDuration)({
79
82
  trimAfter: trimAfterValue,
80
- mediaDurationInFrames: duration,
83
+ mediaDurationInFrames: loopDuration,
81
84
  playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
82
85
  trimBefore: trimBeforeValue,
83
86
  }), children: jsx_runtime_1.jsx(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
84
87
  }
85
88
  if (typeof trimBeforeValue !== 'undefined' ||
86
89
  typeof trimAfterValue !== 'undefined') {
87
- return (jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: jsx_runtime_1.jsx(exports.Html5Audio, { _remotionInternalNeedsDurationCalculation: Boolean(loop), pauseWhenBuffering: shouldPauseWhenBuffering, ...otherProps, ref: ref }) }));
90
+ return (jsx_runtime_1.jsx(use_audio_frame_js_1.Html5MediaTrimContext.Provider, { value: trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0, children: jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue === undefined
91
+ ? undefined
92
+ : (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0) +
93
+ (trimAfterValue - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0)) /
94
+ ((_c = props.playbackRate) !== null && _c !== void 0 ? _c : 1), name: name, children: jsx_runtime_1.jsx(exports.Html5Audio, { _remotionInternalNeedsDurationCalculation: Boolean(loop), pauseWhenBuffering: shouldPauseWhenBuffering, ...otherProps, ref: ref }) }) }));
88
95
  }
89
96
  (0, validate_media_props_js_1.validateMediaProps)({
90
97
  playbackRate: props.playbackRate,
@@ -94,7 +101,7 @@ const AudioRefForwardingFunction = (props, ref) => {
94
101
  if (environment.isRendering) {
95
102
  return (jsx_runtime_1.jsx(AudioForRendering_js_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onNativeError: onError, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
96
103
  }
97
- return (jsx_runtime_1.jsx(AudioForPreview_js_1.AudioForPreview, { _remotionInternalNativeLoopPassed: (_c = props._remotionInternalNativeLoopPassed) !== null && _c !== void 0 ? _c : false, _remotionInternalStack: _remotionInternalStack !== null && _remotionInternalStack !== void 0 ? _remotionInternalStack : null, shouldPreMountAudioTags: audioTagsContext !== null && audioTagsContext.numberOfAudioTags > 0, ...props, ref: ref, onNativeError: onError, onDuration: onDuration, pauseWhenBuffering: shouldPauseWhenBuffering, _remotionInternalNeedsDurationCalculation: Boolean(loop), showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true }));
104
+ return (jsx_runtime_1.jsx(AudioForPreview_js_1.AudioForPreview, { _remotionInternalNativeLoopPassed: (_d = props._remotionInternalNativeLoopPassed) !== null && _d !== void 0 ? _d : false, _remotionInternalStack: _remotionInternalStack !== null && _remotionInternalStack !== void 0 ? _remotionInternalStack : null, shouldPreMountAudioTags: audioTagsContext !== null && audioTagsContext.numberOfAudioTags > 0, ...props, ref: ref, onNativeError: onError, onDuration: onDuration, pauseWhenBuffering: shouldPauseWhenBuffering, _remotionInternalNeedsDurationCalculation: Boolean(loop), showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true }));
98
105
  };
99
106
  /**
100
107
  * @description With this component, you can add audio to your video. All audio formats which are supported by Chromium are supported by the component.
@@ -1,3 +1,4 @@
1
+ export declare const Html5MediaTrimContext: import("react").Context<number>;
1
2
  export declare const useMediaStartsAt: () => number;
2
3
  export type LoopVolumeCurveBehavior = 'repeat' | 'extend';
3
4
  /**
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFrameForVolumeProp = exports.useMediaStartsAt = void 0;
3
+ exports.useFrameForVolumeProp = exports.useMediaStartsAt = exports.Html5MediaTrimContext = void 0;
4
4
  const react_1 = require("react");
5
5
  const index_js_1 = require("../loop/index.js");
6
6
  const SequenceContext_js_1 = require("../SequenceContext.js");
7
7
  const use_current_frame_js_1 = require("../use-current-frame.js");
8
+ // A media trim is a source-frame offset, unlike elapsed time inherited from a Sequence.
9
+ exports.Html5MediaTrimContext = (0, react_1.createContext)(0);
8
10
  const useMediaStartsAt = () => {
9
11
  var _a;
10
12
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
@@ -16,12 +18,22 @@ exports.useMediaStartsAt = useMediaStartsAt;
16
18
  * we calculate the way more intuitive value for currentFrame
17
19
  */
18
20
  const useFrameForVolumeProp = (behavior) => {
21
+ var _a, _b;
19
22
  const loop = index_js_1.Loop.useLoop();
23
+ const loopTimeline = (0, react_1.useContext)(index_js_1.LoopTimelineContext);
24
+ const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
20
25
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
21
26
  const startsAt = (0, exports.useMediaStartsAt)();
22
27
  if (behavior === 'repeat' || loop === null) {
23
28
  return frame + startsAt;
24
29
  }
25
- return frame + startsAt + loop.durationInFrames * loop.iteration;
30
+ // Loop durations use the parent's clock, while volume callbacks use the
31
+ // media's clock, including rates applied inside the loop.
32
+ return (frame +
33
+ startsAt +
34
+ (loop.durationInFrames *
35
+ loop.iteration *
36
+ ((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.playbackRate) !== null && _a !== void 0 ? _a : 1)) /
37
+ ((_b = loopTimeline === null || loopTimeline === void 0 ? void 0 : loopTimeline.playbackRate) !== null && _b !== void 0 ? _b : 1));
26
38
  };
27
39
  exports.useFrameForVolumeProp = useFrameForVolumeProp;
@@ -11,7 +11,6 @@ const calculateMediaDuration = ({ trimAfter, mediaDurationInFrames, playbackRate
11
11
  if (typeof trimBefore !== 'undefined') {
12
12
  duration -= trimBefore;
13
13
  }
14
- const actualDuration = duration / playbackRate;
15
- return Number(actualDuration.toFixed(10));
14
+ return duration / playbackRate;
16
15
  };
17
16
  exports.calculateMediaDuration = calculateMediaDuration;
@@ -217,7 +217,7 @@ export declare const canvasImageSchema: {
217
217
  };
218
218
  };
219
219
  };
220
- export declare const CanvasImage: import("react").ComponentType<import("../Interactive.js").InteractiveBaseProps & import("../Interactive.js").InteractiveCropProps & import("../Interactive.js").InteractivePremountProps & CanvasImageCanvasProps & {
220
+ export declare const CanvasImage: import("react").ComponentType<Omit<import("../Interactive.js").InteractiveBaseProps, "playbackRate"> & import("../Interactive.js").InteractiveCropProps & import("../Interactive.js").InteractivePremountProps & CanvasImageCanvasProps & {
221
221
  readonly src: string;
222
222
  readonly crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
223
223
  readonly width?: number | undefined;
@@ -27,7 +27,7 @@ exports.canvasImageSchema = {
27
27
  description: 'Source',
28
28
  keyframable: false,
29
29
  },
30
- ...interactivity_schema_js_1.baseSchema,
30
+ ...interactivity_schema_js_1.baseSchemaWithoutPlaybackRate,
31
31
  ...interactivity_schema_js_1.cropSchema,
32
32
  ...interactivity_schema_js_1.premountSchema,
33
33
  fit: {
@@ -2,7 +2,7 @@ import type React from 'react';
2
2
  import type { ImageFit } from '../calculate-image-fit.js';
3
3
  import type { EffectsProp } from '../effects/effect-types.js';
4
4
  import type { InteractiveBaseProps, InteractiveCropProps, InteractivePremountProps } from '../Interactive.js';
5
- type CanvasImageSequenceProps = InteractiveBaseProps & InteractiveCropProps & InteractivePremountProps;
5
+ type CanvasImageSequenceProps = Omit<InteractiveBaseProps, 'playbackRate'> & InteractiveCropProps & InteractivePremountProps;
6
6
  export type CanvasImageCanvasProps = Omit<React.CanvasHTMLAttributes<HTMLCanvasElement>, 'children' | 'height' | 'onError' | 'width'>;
7
7
  export type CanvasImageProps = CanvasImageSequenceProps & CanvasImageCanvasProps & {
8
8
  readonly src: string;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { InteractiveBaseProps, InteractiveCropProps } from '../Interactive.js';
2
+ import type { InteractiveBaseProps, InteractivePremountProps, InteractiveCropProps } from '../Interactive.js';
3
3
  import type { EffectsProp } from './effect-types.js';
4
4
  type MandatoryProps = {
5
5
  readonly width: number;
@@ -125,6 +125,23 @@ export declare const solidSchema: {
125
125
  readonly default: "transparent";
126
126
  readonly description: "Color";
127
127
  };
128
+ readonly premountFor: {
129
+ readonly type: "number";
130
+ readonly default: 0;
131
+ readonly description: "Premount For";
132
+ readonly min: 0;
133
+ readonly step: 1;
134
+ readonly hiddenFromList: false;
135
+ readonly keyframable: false;
136
+ };
137
+ readonly postmountFor: {
138
+ readonly type: "number";
139
+ readonly default: 0;
140
+ readonly min: 0;
141
+ readonly step: 1;
142
+ readonly hiddenFromList: true;
143
+ readonly keyframable: false;
144
+ };
128
145
  readonly cropLeft: {
129
146
  readonly type: "number";
130
147
  readonly default: 0;
@@ -185,6 +202,15 @@ export declare const solidSchema: {
185
202
  readonly step: 1;
186
203
  readonly hiddenFromList: true;
187
204
  };
205
+ readonly playbackRate: {
206
+ readonly type: "number";
207
+ readonly default: 1;
208
+ readonly min: 0.01;
209
+ readonly step: 0.1;
210
+ readonly description: "Playback rate";
211
+ readonly hiddenFromList: false;
212
+ readonly keyframable: false;
213
+ };
188
214
  readonly freeze: {
189
215
  readonly type: "number";
190
216
  readonly default: null;
@@ -225,5 +251,5 @@ export declare const solidSchema: {
225
251
  readonly hiddenFromList: false;
226
252
  };
227
253
  };
228
- export declare const Solid: React.ComponentType<MandatoryProps & Partial<OptionalProps> & InteractiveCropProps & InteractiveBaseProps & React.RefAttributes<HTMLCanvasElement>>;
254
+ export declare const Solid: React.ComponentType<MandatoryProps & Partial<OptionalProps> & InteractiveCropProps & InteractiveBaseProps & InteractivePremountProps & React.RefAttributes<HTMLCanvasElement>>;
229
255
  export {};
@@ -4,10 +4,12 @@ exports.Solid = exports.solidSchema = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const enable_sequence_stack_traces_js_1 = require("../enable-sequence-stack-traces.js");
7
+ const freeze_js_1 = require("../freeze.js");
7
8
  const interactivity_schema_js_1 = require("../interactivity-schema.js");
8
9
  const Sequence_js_1 = require("../Sequence.js");
9
10
  const use_crop_style_js_1 = require("../use-crop-style.js");
10
11
  const use_delay_render_js_1 = require("../use-delay-render.js");
12
+ const use_premounting_js_1 = require("../use-premounting.js");
11
13
  const with_interactivity_schema_js_1 = require("../with-interactivity-schema.js");
12
14
  const run_effect_chain_js_1 = require("./run-effect-chain.js");
13
15
  const use_effect_chain_state_js_1 = require("./use-effect-chain-state.js");
@@ -25,6 +27,7 @@ const resolveSolidPixelDensity = (pixelDensity) => {
25
27
  };
26
28
  exports.solidSchema = {
27
29
  ...interactivity_schema_js_1.baseSchema,
30
+ ...interactivity_schema_js_1.premountSchema,
28
31
  color: {
29
32
  type: 'color',
30
33
  default: 'transparent',
@@ -152,7 +155,7 @@ const SolidInner = ({ color, width, height, effects = [], className, style, pixe
152
155
  }, [height, style, width]);
153
156
  return (jsx_runtime_1.jsx("canvas", { ref: canvasRef, width: canvasWidth, height: canvasHeight, className: className, style: canvasStyle }));
154
157
  };
155
- const SolidOuter = (0, react_1.forwardRef)(({ effects = [], controls, color, height, width, className, durationInFrames, style, name, from, trimBefore, freeze, hidden, showInTimeline, pixelDensity, cropLeft, cropRight, cropTop, cropBottom, ...props }, ref) => {
158
+ const SolidOuter = (0, react_1.forwardRef)(({ effects = [], controls, color, height, width, className, durationInFrames, style, name, from, premountFor, postmountFor, styleWhilePremounted, styleWhilePostmounted, trimBefore, playbackRate, freeze, hidden, showInTimeline, pixelDensity, cropLeft, cropRight, cropTop, cropBottom, ...props }, ref) => {
156
159
  var _a;
157
160
  props;
158
161
  const memoizedEffectDefinitions = (0, use_memoized_effects_js_1.useMemoizedEffectDefinitions)(effects);
@@ -160,15 +163,25 @@ const SolidOuter = (0, react_1.forwardRef)(({ effects = [], controls, color, hei
160
163
  (0, react_1.useImperativeHandle)(ref, () => {
161
164
  return actualRef.current;
162
165
  }, []);
166
+ const { effectivePremountFor, effectivePostmountFor, freezeFrame, isPremountingOrPostmounting, premountingActive, postmountingActive, premountingStyle, } = (0, use_premounting_js_1.usePremounting)({
167
+ from: from !== null && from !== void 0 ? from : 0,
168
+ durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity,
169
+ premountFor: premountFor !== null && premountFor !== void 0 ? premountFor : null,
170
+ postmountFor: postmountFor !== null && postmountFor !== void 0 ? postmountFor : null,
171
+ style: style !== null && style !== void 0 ? style : null,
172
+ styleWhilePremounted: styleWhilePremounted !== null && styleWhilePremounted !== void 0 ? styleWhilePremounted : null,
173
+ styleWhilePostmounted: styleWhilePostmounted !== null && styleWhilePostmounted !== void 0 ? styleWhilePostmounted : null,
174
+ hideWhilePremounted: 'opacity',
175
+ });
163
176
  const croppedStyle = (0, use_crop_style_js_1.useCropStyle)({
164
177
  cropLeft,
165
178
  cropRight,
166
179
  cropTop,
167
180
  cropBottom,
168
- style: style !== null && style !== void 0 ? style : null,
181
+ style: premountingStyle,
169
182
  componentName: '<Solid />',
170
183
  });
171
- return (jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: from, trimBefore: trimBefore, freeze: freeze, hidden: hidden, showInTimeline: showInTimeline, controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, durationInFrames: durationInFrames, name: name !== null && name !== void 0 ? name : '<Solid>', outlineRef: actualRef, _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/solid", ...props, children: jsx_runtime_1.jsx(SolidInner, { reference: actualRef, overrideId: (_a = controls === null || controls === void 0 ? void 0 : controls.overrideId) !== null && _a !== void 0 ? _a : null, color: color, height: height, width: width, className: className, style: croppedStyle !== null && croppedStyle !== void 0 ? croppedStyle : undefined, effects: effects, pixelDensity: pixelDensity }) }));
184
+ return (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: from, trimBefore: trimBefore, playbackRate: playbackRate, freeze: freeze, hidden: hidden, showInTimeline: showInTimeline, controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, durationInFrames: durationInFrames, name: name !== null && name !== void 0 ? name : '<Solid>', outlineRef: actualRef, _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/solid", ...props, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, children: jsx_runtime_1.jsx(SolidInner, { reference: actualRef, overrideId: (_a = controls === null || controls === void 0 ? void 0 : controls.overrideId) !== null && _a !== void 0 ? _a : null, color: color, height: height, width: width, className: className, style: croppedStyle !== null && croppedStyle !== void 0 ? croppedStyle : undefined, effects: effects, pixelDensity: pixelDensity }) }) }));
172
185
  });
173
186
  exports.Solid = (0, with_interactivity_schema_js_1.withInteractivitySchema)({
174
187
  Component: SolidOuter,
@@ -13,7 +13,7 @@ const use_video_config_js_1 = require("./use-video-config.js");
13
13
  * @see [Documentation](https://remotion.dev/docs/freeze)
14
14
  */
15
15
  const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
16
- var _a;
16
+ var _a, _b;
17
17
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
18
18
  const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
19
19
  if (typeof frameToFreeze === 'undefined') {
@@ -39,6 +39,7 @@ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
39
39
  const timelineContext = (0, timeline_position_state_js_1.useTimelineContext)();
40
40
  const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
41
41
  const relativeFrom = (_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0;
42
+ const playbackRate = (_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.playbackRate) !== null && _b !== void 0 ? _b : 1;
42
43
  const timelineValue = (0, react_1.useMemo)(() => {
43
44
  if (!isActive) {
44
45
  return timelineContext;
@@ -48,10 +49,17 @@ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
48
49
  isPlaying: () => false,
49
50
  isInsideFreeze: true,
50
51
  frame: {
51
- [videoConfig.id]: frameToFreeze + relativeFrom,
52
+ [videoConfig.id]: frameToFreeze / playbackRate + relativeFrom,
52
53
  },
53
54
  };
54
- }, [isActive, timelineContext, videoConfig.id, frameToFreeze, relativeFrom]);
55
+ }, [
56
+ isActive,
57
+ timelineContext,
58
+ videoConfig.id,
59
+ frameToFreeze,
60
+ relativeFrom,
61
+ playbackRate,
62
+ ]);
55
63
  const newSequenceContext = (0, react_1.useMemo)(() => {
56
64
  if (!sequenceContext) {
57
65
  return null;
@@ -16,6 +16,12 @@ const getAssetDisplayName = (filename) => {
16
16
  .split('/')
17
17
  .map((s) => s.split('\\'))
18
18
  .flat(1);
19
- return splitted[splitted.length - 1];
19
+ const name = splitted[splitted.length - 1];
20
+ try {
21
+ return decodeURIComponent(name);
22
+ }
23
+ catch (_b) {
24
+ return name;
25
+ }
20
26
  };
21
27
  exports.getAssetDisplayName = getAssetDisplayName;
@@ -0,0 +1,7 @@
1
+ export declare const getSequenceBoundaryTolerance: ({ absoluteFrame, cumulatedFrom, from, parentPlaybackRate, durationInFrames, }: {
2
+ absoluteFrame: number;
3
+ cumulatedFrom: number;
4
+ from: number;
5
+ parentPlaybackRate: number;
6
+ durationInFrames: number;
7
+ }) => number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSequenceBoundaryTolerance = void 0;
4
+ const getSequenceBoundaryTolerance = ({ absoluteFrame, cumulatedFrom, from, parentPlaybackRate, durationInFrames, }) => {
5
+ // Nested rates can put exact boundaries a few floating-point units apart.
6
+ return Math.min(durationInFrames / 2, Number.EPSILON *
7
+ Math.max(Math.abs(absoluteFrame * parentPlaybackRate), Math.abs(cumulatedFrom * parentPlaybackRate), Math.abs(from)) *
8
+ 4);
9
+ };
10
+ exports.getSequenceBoundaryTolerance = getSequenceBoundaryTolerance;
@@ -5,7 +5,7 @@ import type { AnyCompMetadata, AnyComposition, AudioOrVideoAsset, JsxComponentId
5
5
  import type { DelayRenderScope } from './delay-render.js';
6
6
  import { type TFolder } from './Folder.js';
7
7
  import type { StaticFile } from './get-static-files.js';
8
- import type { AssetFieldSchema, ArrayFieldSchema, ArrayItemFieldSchema, CaptionsFieldSchema, InteractivitySchemaField, InteractivitySchema } from './interactivity-schema.js';
8
+ import type { ArrayFieldSchema, ArrayItemFieldSchema, AssetFieldSchema, CaptionsFieldSchema, InteractivitySchema, InteractivitySchemaField } from './interactivity-schema.js';
9
9
  import type { LogLevel } from './log.js';
10
10
  import type { ProResProfile } from './prores-profile.js';
11
11
  import type { PixelFormat, VideoImageFormat } from './render-types.js';
@@ -135,7 +135,7 @@ export * from './internals.js';
135
135
  export { interpolateColors, type InterpolateColorsOptions, } from './interpolate-colors.js';
136
136
  export { LogLevel } from './log.js';
137
137
  export { Loop } from './loop/index.js';
138
- export { assertValidInterpolateEasingOption, assertValidInterpolatePosterizeOption, EasingFunction, ExtrapolateType, interpolate, InterpolateOutputOption, InterpolateOptions, random, RandomSeed, } from './no-react';
138
+ export { assertValidInterpolateEasingOption, assertValidInterpolatePosterizeOption, EasingFunction, ExtrapolateType, interpolate, InterpolateOptions, InterpolateOutputOption, InterpolateOutputType, random, RandomSeed, } from './no-react';
139
139
  export { prefetch, PrefetchOnProgress } from './prefetch.js';
140
140
  export { registerRoot } from './register-root.js';
141
141
  export type { PixelFormat, VideoImageFormat } from './render-types.js';
@@ -184,4 +184,4 @@ export type _InternalTypes = {
184
184
  TRenderAsset: TRenderAsset;
185
185
  ProResProfile: ProResProfile;
186
186
  };
187
- export type { AnyComposition, AssetFieldSchema, ArrayFieldSchema, ArrayItemFieldSchema, CaptionsFieldSchema, DelayRenderScope, JsxComponentIdentity, LoopDisplay, RuntimeValueSnapshot, RuntimeValueStore, SequenceControls, SequenceRegistrationControls, InteractivitySchemaField, InteractivitySchema, UseBufferState, };
187
+ export type { AnyComposition, ArrayFieldSchema, ArrayItemFieldSchema, AssetFieldSchema, CaptionsFieldSchema, DelayRenderScope, InteractivitySchema, InteractivitySchemaField, JsxComponentIdentity, LoopDisplay, RuntimeValueSnapshot, RuntimeValueStore, SequenceControls, SequenceRegistrationControls, UseBufferState, };