Comparing version 4.0.145 to 4.0.146
@@ -67,3 +67,3 @@ "use strict"; | ||
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null, | ||
audioStartFrame: -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _b !== void 0 ? _b : 0), | ||
audioStartFrame: Math.max(0, -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _b !== void 0 ? _b : 0)), | ||
}); | ||
@@ -70,0 +70,0 @@ return () => unregisterRenderAsset(id); |
@@ -30,7 +30,23 @@ "use strict"; | ||
const id = (0, delay_render_js_1.delayRender)(`Setting the current frame to ${f}`); | ||
setFrame((s) => ({ | ||
...s, | ||
[composition]: f, | ||
})); | ||
requestAnimationFrame(() => (0, delay_render_js_1.continueRender)(id)); | ||
let asyncUpdate = true; | ||
setFrame((s) => { | ||
var _a; | ||
const currentFrame = (_a = s[composition]) !== null && _a !== void 0 ? _a : window.remotion_initialFrame; | ||
// Avoid cloning the object | ||
if (currentFrame === f) { | ||
asyncUpdate = false; | ||
return s; | ||
} | ||
return { | ||
...s, | ||
[composition]: f, | ||
}; | ||
}); | ||
// After setting the state, need to wait until it is applied in the next cycle | ||
if (asyncUpdate) { | ||
requestAnimationFrame(() => (0, delay_render_js_1.continueRender)(id)); | ||
} | ||
else { | ||
(0, delay_render_js_1.continueRender)(id); | ||
} | ||
}; | ||
@@ -37,0 +53,0 @@ window.remotion_isPlayer = false; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const react_1 = require("react"); | ||
const get_remotion_environment_js_1 = require("./get-remotion-environment.js"); | ||
const use_video_js_1 = require("./use-video.js"); | ||
@@ -43,8 +44,12 @@ exports.TimelineContext = (0, react_1.createContext)({ | ||
const getFrameForComposition = (composition) => { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
const item = (_a = localStorage.getItem(makeKey())) !== null && _a !== void 0 ? _a : '{}'; | ||
const obj = JSON.parse(item); | ||
return obj[composition] | ||
? Number(obj[composition]) | ||
: (_c = (typeof window === 'undefined' ? 0 : (_b = window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0)) !== null && _c !== void 0 ? _c : 0; | ||
if (obj[composition] !== undefined) { | ||
return Number(obj[composition]); | ||
} | ||
if (typeof window === 'undefined') { | ||
return 0; | ||
} | ||
return (_b = window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0; | ||
}; | ||
@@ -61,3 +66,3 @@ exports.getFrameForComposition = getFrameForComposition; | ||
} | ||
const unclamped = (_b = state.frame[videoConfig.id]) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && window.remotion_isPlayer | ||
const unclamped = (_b = state.frame[videoConfig.id]) !== null && _b !== void 0 ? _b : ((0, get_remotion_environment_js_1.getRemotionEnvironment)().isPlayer | ||
? 0 | ||
@@ -64,0 +69,0 @@ : (0, exports.getFrameForComposition)(videoConfig.id)); |
@@ -7,2 +7,3 @@ "use strict"; | ||
const SequenceContext_js_1 = require("./SequenceContext.js"); | ||
const get_remotion_environment_js_1 = require("./get-remotion-environment.js"); | ||
const timeline_position_state_js_1 = require("./timeline-position-state.js"); | ||
@@ -16,3 +17,3 @@ /** | ||
if (!canUseRemotionHooks) { | ||
if (typeof window !== 'undefined' && window.remotion_isPlayer) { | ||
if ((0, get_remotion_environment_js_1.getRemotionEnvironment)().isPlayer) { | ||
throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`); | ||
@@ -19,0 +20,0 @@ } |
@@ -6,2 +6,2 @@ /** | ||
*/ | ||
export declare const VERSION = "4.0.145"; | ||
export declare const VERSION = "4.0.146"; |
@@ -10,2 +10,2 @@ "use strict"; | ||
*/ | ||
exports.VERSION = '4.0.145'; | ||
exports.VERSION = '4.0.146'; |
@@ -73,3 +73,3 @@ "use strict"; | ||
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null, | ||
audioStartFrame: -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0), | ||
audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)), | ||
}); | ||
@@ -76,0 +76,0 @@ return () => unregisterRenderAsset(id); |
@@ -74,3 +74,3 @@ "use strict"; | ||
toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null, | ||
audioStartFrame: -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0), | ||
audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)), | ||
}); | ||
@@ -77,0 +77,0 @@ return () => unregisterRenderAsset(id); |
{ | ||
"name": "remotion", | ||
"version": "4.0.145", | ||
"version": "4.0.146", | ||
"description": "Render videos in React", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
640065
14696
148