remotion 4.0.145 → 4.0.146
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/cjs/RemotionRoot.js +21 -5
- package/dist/cjs/audio/AudioForRendering.js +1 -1
- package/dist/cjs/timeline-position-state.js +10 -5
- package/dist/cjs/use-current-frame.js +2 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/OffthreadVideoForRendering.js +1 -1
- package/dist/cjs/video/VideoForRendering.js +1 -1
- package/dist/esm/index.mjs +35 -15
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/dist/cjs/RemotionRoot.js
CHANGED
|
@@ -27,11 +27,27 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
27
27
|
window.remotion_setFrame = (f, composition, attempt) => {
|
|
28
28
|
window.remotion_attempt = attempt;
|
|
29
29
|
const id = (0, delay_render_js_1.delayRender)(`Setting the current frame to ${f}`);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
let asyncUpdate = true;
|
|
31
|
+
setFrame((s) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const currentFrame = (_a = s[composition]) !== null && _a !== void 0 ? _a : window.remotion_initialFrame;
|
|
34
|
+
// Avoid cloning the object
|
|
35
|
+
if (currentFrame === f) {
|
|
36
|
+
asyncUpdate = false;
|
|
37
|
+
return s;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...s,
|
|
41
|
+
[composition]: f,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
// After setting the state, need to wait until it is applied in the next cycle
|
|
45
|
+
if (asyncUpdate) {
|
|
46
|
+
requestAnimationFrame(() => (0, delay_render_js_1.continueRender)(id));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
(0, delay_render_js_1.continueRender)(id);
|
|
50
|
+
}
|
|
35
51
|
};
|
|
36
52
|
window.remotion_isPlayer = false;
|
|
37
53
|
}, []);
|
|
@@ -64,7 +64,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
64
64
|
playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
|
|
65
65
|
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
66
66
|
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
|
|
67
|
-
audioStartFrame: -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _b !== void 0 ? _b : 0),
|
|
67
|
+
audioStartFrame: Math.max(0, -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _b !== void 0 ? _b : 0)),
|
|
68
68
|
});
|
|
69
69
|
return () => unregisterRenderAsset(id);
|
|
70
70
|
}, [
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.getFrameForComposition = exports.getInitialFrameState = exports.persistCurrentFrame = exports.SetTimelineContext = exports.TimelineContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
const get_remotion_environment_js_1 = require("./get-remotion-environment.js");
|
|
5
6
|
const use_video_js_1 = require("./use-video.js");
|
|
6
7
|
exports.TimelineContext = (0, react_1.createContext)({
|
|
7
8
|
frame: {},
|
|
@@ -39,12 +40,16 @@ const getInitialFrameState = () => {
|
|
|
39
40
|
};
|
|
40
41
|
exports.getInitialFrameState = getInitialFrameState;
|
|
41
42
|
const getFrameForComposition = (composition) => {
|
|
42
|
-
var _a, _b
|
|
43
|
+
var _a, _b;
|
|
43
44
|
const item = (_a = localStorage.getItem(makeKey())) !== null && _a !== void 0 ? _a : '{}';
|
|
44
45
|
const obj = JSON.parse(item);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (obj[composition] !== undefined) {
|
|
47
|
+
return Number(obj[composition]);
|
|
48
|
+
}
|
|
49
|
+
if (typeof window === 'undefined') {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
return (_b = window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0;
|
|
48
53
|
};
|
|
49
54
|
exports.getFrameForComposition = getFrameForComposition;
|
|
50
55
|
const useTimelinePosition = () => {
|
|
@@ -56,7 +61,7 @@ const useTimelinePosition = () => {
|
|
|
56
61
|
? 0
|
|
57
62
|
: (_a = window.remotion_initialFrame) !== null && _a !== void 0 ? _a : 0;
|
|
58
63
|
}
|
|
59
|
-
const unclamped = (_b = state.frame[videoConfig.id]) !== null && _b !== void 0 ? _b : (
|
|
64
|
+
const unclamped = (_b = state.frame[videoConfig.id]) !== null && _b !== void 0 ? _b : ((0, get_remotion_environment_js_1.getRemotionEnvironment)().isPlayer
|
|
60
65
|
? 0
|
|
61
66
|
: (0, exports.getFrameForComposition)(videoConfig.id));
|
|
62
67
|
return Math.min(videoConfig.durationInFrames - 1, unclamped);
|
|
@@ -4,6 +4,7 @@ exports.useCurrentFrame = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
|
|
6
6
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
7
|
+
const get_remotion_environment_js_1 = require("./get-remotion-environment.js");
|
|
7
8
|
const timeline_position_state_js_1 = require("./timeline-position-state.js");
|
|
8
9
|
/**
|
|
9
10
|
* @description Get the current frame of the video. Frames are 0-indexed, meaning the first frame is 0, the last frame is the duration of the composition in frames minus one.
|
|
@@ -12,7 +13,7 @@ const timeline_position_state_js_1 = require("./timeline-position-state.js");
|
|
|
12
13
|
const useCurrentFrame = () => {
|
|
13
14
|
const canUseRemotionHooks = (0, react_1.useContext)(CanUseRemotionHooks_js_1.CanUseRemotionHooks);
|
|
14
15
|
if (!canUseRemotionHooks) {
|
|
15
|
-
if (
|
|
16
|
+
if ((0, get_remotion_environment_js_1.getRemotionEnvironment)().isPlayer) {
|
|
16
17
|
throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`);
|
|
17
18
|
}
|
|
18
19
|
throw new Error(`useCurrentFrame() can only be called inside a component that was registered as a composition. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions`);
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -70,7 +70,7 @@ const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate,
|
|
|
70
70
|
playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
|
|
71
71
|
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
72
72
|
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
|
|
73
|
-
audioStartFrame: -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0),
|
|
73
|
+
audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)),
|
|
74
74
|
});
|
|
75
75
|
return () => unregisterRenderAsset(id);
|
|
76
76
|
}, [
|
|
@@ -71,7 +71,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
71
71
|
playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
|
|
72
72
|
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
73
73
|
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
|
|
74
|
-
audioStartFrame: -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0),
|
|
74
|
+
audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)),
|
|
75
75
|
});
|
|
76
76
|
return () => unregisterRenderAsset(id);
|
|
77
77
|
}, [
|
package/dist/esm/index.mjs
CHANGED
|
@@ -110,7 +110,7 @@ function truthy(value) {
|
|
|
110
110
|
* @see [Documentation](https://remotion.dev/docs/version)
|
|
111
111
|
* @returns {string} The current version of the remotion package
|
|
112
112
|
*/
|
|
113
|
-
const VERSION = '4.0.
|
|
113
|
+
const VERSION = '4.0.146';
|
|
114
114
|
|
|
115
115
|
const checkMultipleRemotionVersions = () => {
|
|
116
116
|
if (typeof globalThis === 'undefined') {
|
|
@@ -857,12 +857,16 @@ const getInitialFrameState = () => {
|
|
|
857
857
|
return obj;
|
|
858
858
|
};
|
|
859
859
|
const getFrameForComposition = (composition) => {
|
|
860
|
-
var _a, _b
|
|
860
|
+
var _a, _b;
|
|
861
861
|
const item = (_a = localStorage.getItem(makeKey())) !== null && _a !== void 0 ? _a : '{}';
|
|
862
862
|
const obj = JSON.parse(item);
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
863
|
+
if (obj[composition] !== undefined) {
|
|
864
|
+
return Number(obj[composition]);
|
|
865
|
+
}
|
|
866
|
+
if (typeof window === 'undefined') {
|
|
867
|
+
return 0;
|
|
868
|
+
}
|
|
869
|
+
return (_b = window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0;
|
|
866
870
|
};
|
|
867
871
|
const useTimelinePosition = () => {
|
|
868
872
|
var _a, _b;
|
|
@@ -873,7 +877,7 @@ const useTimelinePosition = () => {
|
|
|
873
877
|
? 0
|
|
874
878
|
: (_a = window.remotion_initialFrame) !== null && _a !== void 0 ? _a : 0;
|
|
875
879
|
}
|
|
876
|
-
const unclamped = (_b = state.frame[videoConfig.id]) !== null && _b !== void 0 ? _b : (
|
|
880
|
+
const unclamped = (_b = state.frame[videoConfig.id]) !== null && _b !== void 0 ? _b : (getRemotionEnvironment().isPlayer
|
|
877
881
|
? 0
|
|
878
882
|
: getFrameForComposition(videoConfig.id));
|
|
879
883
|
return Math.min(videoConfig.durationInFrames - 1, unclamped);
|
|
@@ -963,7 +967,7 @@ const useVideoConfig = () => {
|
|
|
963
967
|
const useCurrentFrame = () => {
|
|
964
968
|
const canUseRemotionHooks = useContext(CanUseRemotionHooks);
|
|
965
969
|
if (!canUseRemotionHooks) {
|
|
966
|
-
if (
|
|
970
|
+
if (getRemotionEnvironment().isPlayer) {
|
|
967
971
|
throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`);
|
|
968
972
|
}
|
|
969
973
|
throw new Error(`useCurrentFrame() can only be called inside a component that was registered as a composition. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions`);
|
|
@@ -2836,7 +2840,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
2836
2840
|
playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
|
|
2837
2841
|
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
2838
2842
|
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
|
|
2839
|
-
audioStartFrame: -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _b !== void 0 ? _b : 0),
|
|
2843
|
+
audioStartFrame: Math.max(0, -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _b !== void 0 ? _b : 0)),
|
|
2840
2844
|
});
|
|
2841
2845
|
return () => unregisterRenderAsset(id);
|
|
2842
2846
|
}, [
|
|
@@ -3757,11 +3761,27 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
3757
3761
|
window.remotion_setFrame = (f, composition, attempt) => {
|
|
3758
3762
|
window.remotion_attempt = attempt;
|
|
3759
3763
|
const id = delayRender(`Setting the current frame to ${f}`);
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3764
|
+
let asyncUpdate = true;
|
|
3765
|
+
setFrame((s) => {
|
|
3766
|
+
var _a;
|
|
3767
|
+
const currentFrame = (_a = s[composition]) !== null && _a !== void 0 ? _a : window.remotion_initialFrame;
|
|
3768
|
+
// Avoid cloning the object
|
|
3769
|
+
if (currentFrame === f) {
|
|
3770
|
+
asyncUpdate = false;
|
|
3771
|
+
return s;
|
|
3772
|
+
}
|
|
3773
|
+
return {
|
|
3774
|
+
...s,
|
|
3775
|
+
[composition]: f,
|
|
3776
|
+
};
|
|
3777
|
+
});
|
|
3778
|
+
// After setting the state, need to wait until it is applied in the next cycle
|
|
3779
|
+
if (asyncUpdate) {
|
|
3780
|
+
requestAnimationFrame(() => continueRender(id));
|
|
3781
|
+
}
|
|
3782
|
+
else {
|
|
3783
|
+
continueRender(id);
|
|
3784
|
+
}
|
|
3765
3785
|
};
|
|
3766
3786
|
window.remotion_isPlayer = false;
|
|
3767
3787
|
}, []);
|
|
@@ -4874,7 +4894,7 @@ const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate,
|
|
|
4874
4894
|
playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
|
|
4875
4895
|
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
4876
4896
|
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
|
|
4877
|
-
audioStartFrame: -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0),
|
|
4897
|
+
audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)),
|
|
4878
4898
|
});
|
|
4879
4899
|
return () => unregisterRenderAsset(id);
|
|
4880
4900
|
}, [
|
|
@@ -5233,7 +5253,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
5233
5253
|
playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
|
|
5234
5254
|
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
5235
5255
|
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
|
|
5236
|
-
audioStartFrame: -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0),
|
|
5256
|
+
audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)),
|
|
5237
5257
|
});
|
|
5238
5258
|
return () => unregisterRenderAsset(id);
|
|
5239
5259
|
}, [
|
package/dist/esm/version.mjs
CHANGED