remotion 3.3.88 → 3.3.90
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/EditorProps.d.ts +15 -0
- package/dist/cjs/EditorProps.js +53 -0
- package/dist/cjs/audio/AudioForDevelopment.js +10 -3
- package/dist/cjs/props-if-has-props.d.ts +10 -0
- package/dist/cjs/props-if-has-props.js +2 -0
- package/dist/cjs/spring/index.d.ts +3 -1
- package/dist/cjs/spring/index.js +9 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/OffthreadVideo.js +2 -2
- package/dist/cjs/video/VideoForDevelopment.js +6 -2
- package/dist/cjs/video/VideoForRendering.js +6 -1
- package/dist/cjs/z-color.d.ts +9 -0
- package/dist/cjs/z-color.js +28 -0
- package/dist/esm/index.mjs +34 -11
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type Props = Record<string, object>;
|
|
3
|
+
export declare type EditorPropsContextType = {
|
|
4
|
+
props: Props;
|
|
5
|
+
updateProps: (options: {
|
|
6
|
+
id: string;
|
|
7
|
+
defaultProps: object;
|
|
8
|
+
newProps: object;
|
|
9
|
+
}) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const EditorPropsContext: React.Context<EditorPropsContextType>;
|
|
12
|
+
export declare const EditorPropsProvider: React.FC<{
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.EditorPropsProvider = exports.EditorPropsContext = void 0;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
exports.EditorPropsContext = (0, react_1.createContext)({
|
|
30
|
+
props: {},
|
|
31
|
+
updateProps: () => {
|
|
32
|
+
throw new Error('Not implemented');
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const EditorPropsProvider = ({ children }) => {
|
|
36
|
+
const [props, setProps] = react_1.default.useState({});
|
|
37
|
+
const updateProps = (0, react_1.useCallback)(({ defaultProps, id, newProps, }) => {
|
|
38
|
+
setProps((prev) => {
|
|
39
|
+
var _a;
|
|
40
|
+
return {
|
|
41
|
+
...prev,
|
|
42
|
+
[id]: typeof newProps === 'function'
|
|
43
|
+
? newProps((_a = prev[id]) !== null && _a !== void 0 ? _a : defaultProps)
|
|
44
|
+
: newProps,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}, []);
|
|
48
|
+
const ctx = (0, react_1.useMemo)(() => {
|
|
49
|
+
return { props, updateProps };
|
|
50
|
+
}, [props, updateProps]);
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(exports.EditorPropsContext.Provider, { value: ctx, children: children }));
|
|
52
|
+
};
|
|
53
|
+
exports.EditorPropsProvider = EditorPropsProvider;
|
|
@@ -36,7 +36,14 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
36
36
|
const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
37
37
|
// Generate a string that's as unique as possible for this asset
|
|
38
38
|
// but at the same time deterministic. We use it to combat strict mode issues.
|
|
39
|
-
const id = (0, react_1.useMemo)(() => `audio-${(0, random_js_1.random)(src !== null && src !== void 0 ? src : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}-muted:${props.muted}`, [
|
|
39
|
+
const id = (0, react_1.useMemo)(() => `audio-${(0, random_js_1.random)(src !== null && src !== void 0 ? src : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}-muted:${props.muted}-loop:${props.loop}`, [
|
|
40
|
+
src,
|
|
41
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
|
|
42
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
|
|
43
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
|
|
44
|
+
props.muted,
|
|
45
|
+
props.loop,
|
|
46
|
+
]);
|
|
40
47
|
const audioRef = (0, shared_audio_tags_js_1.useSharedAudio)(propsToPass, id).el;
|
|
41
48
|
const actualVolume = (0, use_media_tag_volume_js_1.useMediaTagVolume)(audioRef);
|
|
42
49
|
(0, use_sync_volume_with_media_tag_js_1.useSyncVolumeWithMediaTag)({
|
|
@@ -74,12 +81,12 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
74
81
|
return;
|
|
75
82
|
}
|
|
76
83
|
if (current.duration) {
|
|
77
|
-
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
|
|
84
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
|
|
78
85
|
return;
|
|
79
86
|
}
|
|
80
87
|
const onLoadedMetadata = () => {
|
|
81
88
|
var _a;
|
|
82
|
-
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
|
|
89
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
|
|
83
90
|
};
|
|
84
91
|
current.addEventListener('loadedmetadata', onLoadedMetadata);
|
|
85
92
|
return () => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export declare type PropsIfHasProps<Schema extends z.ZodTypeAny, Props> = z.ZodTypeAny extends Schema ? {} extends Props ? {
|
|
3
|
+
defaultProps?: Props;
|
|
4
|
+
} : {
|
|
5
|
+
defaultProps: Props;
|
|
6
|
+
} : {} extends Props ? {
|
|
7
|
+
defaultProps: z.infer<Schema>;
|
|
8
|
+
} : {
|
|
9
|
+
defaultProps: z.infer<Schema> & Props;
|
|
10
|
+
};
|
|
@@ -13,8 +13,9 @@ import type { SpringConfig } from './spring-utils.js';
|
|
|
13
13
|
* @param {?number} [config.to] The end value of the animation. Default `1`
|
|
14
14
|
* @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
|
|
15
15
|
* @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
|
|
16
|
+
* @param {?number} [config.delay] Delay the animation for this amount of frames. Default `0`
|
|
16
17
|
*/
|
|
17
|
-
export declare function spring({ frame, fps, config, from, to, durationInFrames, durationRestThreshold, }: {
|
|
18
|
+
export declare function spring({ frame: passedFrame, fps, config, from, to, durationInFrames, durationRestThreshold, delay, }: {
|
|
18
19
|
frame: number;
|
|
19
20
|
fps: number;
|
|
20
21
|
config?: Partial<SpringConfig>;
|
|
@@ -22,6 +23,7 @@ export declare function spring({ frame, fps, config, from, to, durationInFrames,
|
|
|
22
23
|
to?: number;
|
|
23
24
|
durationInFrames?: number;
|
|
24
25
|
durationRestThreshold?: number;
|
|
26
|
+
delay?: number;
|
|
25
27
|
}): number;
|
|
26
28
|
export { measureSpring } from './measure-spring.js';
|
|
27
29
|
export { SpringConfig } from './spring-utils.js';
|
package/dist/cjs/spring/index.js
CHANGED
|
@@ -20,10 +20,15 @@ const spring_utils_js_1 = require("./spring-utils.js");
|
|
|
20
20
|
* @param {?number} [config.to] The end value of the animation. Default `1`
|
|
21
21
|
* @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
|
|
22
22
|
* @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
|
|
23
|
+
* @param {?number} [config.delay] Delay the animation for this amount of frames. Default `0`
|
|
23
24
|
*/
|
|
24
|
-
function spring({ frame, fps, config = {}, from = 0, to = 1, durationInFrames, durationRestThreshold, }) {
|
|
25
|
+
function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durationInFrames, durationRestThreshold, delay = 0, }) {
|
|
25
26
|
(0, validation_spring_duration_js_1.validateSpringDuration)(durationInFrames);
|
|
26
|
-
(0, validate_frame_js_1.validateFrame)({
|
|
27
|
+
(0, validate_frame_js_1.validateFrame)({
|
|
28
|
+
frame: passedFrame,
|
|
29
|
+
durationInFrames: Infinity,
|
|
30
|
+
allowFloats: true,
|
|
31
|
+
});
|
|
27
32
|
(0, validate_fps_js_1.validateFps)(fps, 'to spring()', false);
|
|
28
33
|
const durationRatio = durationInFrames === undefined
|
|
29
34
|
? 1
|
|
@@ -35,6 +40,8 @@ function spring({ frame, fps, config = {}, from = 0, to = 1, durationInFrames, d
|
|
|
35
40
|
to,
|
|
36
41
|
threshold: durationRestThreshold,
|
|
37
42
|
});
|
|
43
|
+
// Delay the spring by telling the calculation we're at an earlier frame.
|
|
44
|
+
const frame = passedFrame - delay;
|
|
38
45
|
const spr = (0, spring_utils_js_1.springCalculation)({
|
|
39
46
|
fps,
|
|
40
47
|
frame: frame / durationRatio,
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.3.
|
|
1
|
+
export declare const VERSION = "3.3.90";
|
package/dist/cjs/version.js
CHANGED
|
@@ -15,7 +15,7 @@ const VideoForDevelopment_js_1 = require("./VideoForDevelopment.js");
|
|
|
15
15
|
* @see [Documentation](https://www.remotion.dev/docs/offthreadvideo)
|
|
16
16
|
*/
|
|
17
17
|
const OffthreadVideo = (props) => {
|
|
18
|
-
const { startFrom, endAt, ...otherProps } = props;
|
|
18
|
+
const { startFrom, endAt, imageFormat, ...otherProps } = props;
|
|
19
19
|
const environment = (0, get_environment_js_1.useRemotionEnvironment)();
|
|
20
20
|
const onDuration = (0, react_1.useCallback)(() => undefined, []);
|
|
21
21
|
if (typeof props.src !== 'string') {
|
|
@@ -30,7 +30,7 @@ const OffthreadVideo = (props) => {
|
|
|
30
30
|
(0, validate_media_props_js_1.validateMediaProps)(props, 'Video');
|
|
31
31
|
(0, validate_offthreadvideo_image_format_js_1.validateOffthreadVideoImageFormat)(props.imageFormat);
|
|
32
32
|
if (environment === 'rendering') {
|
|
33
|
-
return (0, jsx_runtime_1.jsx)(OffthreadVideoForRendering_js_1.OffthreadVideoForRendering, { ...otherProps });
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(OffthreadVideoForRendering_js_1.OffthreadVideoForRendering, { imageFormat: imageFormat, ...otherProps }));
|
|
34
34
|
}
|
|
35
35
|
return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_js_1.VideoForDevelopment, { onDuration: onDuration, onlyWarnForMediaSeekingError: true, ...otherProps }));
|
|
36
36
|
};
|
|
@@ -75,7 +75,11 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
|
|
|
75
75
|
var _a;
|
|
76
76
|
if (current === null || current === void 0 ? void 0 : current.error) {
|
|
77
77
|
console.error('Error occurred in video', current === null || current === void 0 ? void 0 : current.error);
|
|
78
|
-
|
|
78
|
+
// If user is handling the error, we don't cause an unhandled exception
|
|
79
|
+
if (props.onError) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`The browser threw an error while playing the video ${src}: Code ${current.error.code} - ${(_a = current === null || current === void 0 ? void 0 : current.error) === null || _a === void 0 ? void 0 : _a.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`);
|
|
79
83
|
}
|
|
80
84
|
else {
|
|
81
85
|
throw new Error('The browser threw an error');
|
|
@@ -85,7 +89,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
|
|
|
85
89
|
return () => {
|
|
86
90
|
current.removeEventListener('error', errorHandler);
|
|
87
91
|
};
|
|
88
|
-
}, [src]);
|
|
92
|
+
}, [props.onError, src]);
|
|
89
93
|
const currentOnDurationCallback = (0, react_1.useRef)();
|
|
90
94
|
currentOnDurationCallback.current = onDuration;
|
|
91
95
|
(0, react_1.useEffect)(() => {
|
|
@@ -146,7 +146,11 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
146
146
|
var _a;
|
|
147
147
|
if (current === null || current === void 0 ? void 0 : current.error) {
|
|
148
148
|
console.error('Error occurred in video', current === null || current === void 0 ? void 0 : current.error);
|
|
149
|
-
|
|
149
|
+
// If user is handling the error, we don't cause an unhandled exception
|
|
150
|
+
if (onError) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
throw new Error(`The browser threw an error while playing the video ${props.src}: Code ${current.error.code} - ${(_a = current === null || current === void 0 ? void 0 : current.error) === null || _a === void 0 ? void 0 : _a.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`);
|
|
150
154
|
}
|
|
151
155
|
else {
|
|
152
156
|
throw new Error('The browser threw an error');
|
|
@@ -167,6 +171,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
167
171
|
videoConfig.fps,
|
|
168
172
|
frame,
|
|
169
173
|
mediaStartsAt,
|
|
174
|
+
onError,
|
|
170
175
|
]);
|
|
171
176
|
const { src } = props;
|
|
172
177
|
// If video source switches, make new handle
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const REMOTION_COLOR_BRAND = "__remotion-color";
|
|
3
|
+
export declare const parseColor: (value: string) => {
|
|
4
|
+
a: number;
|
|
5
|
+
r: number;
|
|
6
|
+
g: number;
|
|
7
|
+
b: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const zColor: () => z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zColor = exports.parseColor = exports.REMOTION_COLOR_BRAND = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const interpolate_colors_js_1 = require("./interpolate-colors.js");
|
|
6
|
+
exports.REMOTION_COLOR_BRAND = '__remotion-color';
|
|
7
|
+
const parseColor = (value) => {
|
|
8
|
+
const colored = (0, interpolate_colors_js_1.processColor)(value).toString(16).padStart(8, '0');
|
|
9
|
+
const opacity = parseInt(colored.slice(0, 2), 16);
|
|
10
|
+
const r = parseInt(colored.slice(2, 4), 16);
|
|
11
|
+
const g = parseInt(colored.slice(4, 6), 16);
|
|
12
|
+
const b = parseInt(colored.slice(6, 8), 16);
|
|
13
|
+
return { a: opacity, r, g, b };
|
|
14
|
+
};
|
|
15
|
+
exports.parseColor = parseColor;
|
|
16
|
+
const zColor = () => zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.refine((value) => {
|
|
19
|
+
try {
|
|
20
|
+
(0, exports.parseColor)(value);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}, { message: 'Invalid color' })
|
|
27
|
+
.describe(exports.REMOTION_COLOR_BRAND);
|
|
28
|
+
exports.zColor = zColor;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -58,7 +58,7 @@ function truthy(value) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Automatically generated on publish
|
|
61
|
-
const VERSION = '3.3.
|
|
61
|
+
const VERSION = '3.3.90';
|
|
62
62
|
|
|
63
63
|
const checkMultipleRemotionVersions = () => {
|
|
64
64
|
if (typeof globalThis === 'undefined') {
|
|
@@ -1626,7 +1626,14 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
1626
1626
|
const sequenceContext = useContext(SequenceContext);
|
|
1627
1627
|
// Generate a string that's as unique as possible for this asset
|
|
1628
1628
|
// but at the same time deterministic. We use it to combat strict mode issues.
|
|
1629
|
-
const id = useMemo(() => `audio-${random(src !== null && src !== void 0 ? src : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}-muted:${props.muted}`, [
|
|
1629
|
+
const id = useMemo(() => `audio-${random(src !== null && src !== void 0 ? src : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}-muted:${props.muted}-loop:${props.loop}`, [
|
|
1630
|
+
src,
|
|
1631
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
|
|
1632
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
|
|
1633
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
|
|
1634
|
+
props.muted,
|
|
1635
|
+
props.loop,
|
|
1636
|
+
]);
|
|
1630
1637
|
const audioRef = useSharedAudio(propsToPass, id).el;
|
|
1631
1638
|
const actualVolume = useMediaTagVolume(audioRef);
|
|
1632
1639
|
useSyncVolumeWithMediaTag({
|
|
@@ -1664,12 +1671,12 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
1664
1671
|
return;
|
|
1665
1672
|
}
|
|
1666
1673
|
if (current.duration) {
|
|
1667
|
-
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
|
|
1674
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
|
|
1668
1675
|
return;
|
|
1669
1676
|
}
|
|
1670
1677
|
const onLoadedMetadata = () => {
|
|
1671
1678
|
var _a;
|
|
1672
|
-
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
|
|
1679
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
|
|
1673
1680
|
};
|
|
1674
1681
|
current.addEventListener('loadedmetadata', onLoadedMetadata);
|
|
1675
1682
|
return () => {
|
|
@@ -3564,10 +3571,15 @@ function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1,
|
|
|
3564
3571
|
* @param {?number} [config.to] The end value of the animation. Default `1`
|
|
3565
3572
|
* @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
|
|
3566
3573
|
* @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
|
|
3574
|
+
* @param {?number} [config.delay] Delay the animation for this amount of frames. Default `0`
|
|
3567
3575
|
*/
|
|
3568
|
-
function spring({ frame, fps, config = {}, from = 0, to = 1, durationInFrames, durationRestThreshold, }) {
|
|
3576
|
+
function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durationInFrames, durationRestThreshold, delay = 0, }) {
|
|
3569
3577
|
validateSpringDuration(durationInFrames);
|
|
3570
|
-
validateFrame({
|
|
3578
|
+
validateFrame({
|
|
3579
|
+
frame: passedFrame,
|
|
3580
|
+
durationInFrames: Infinity,
|
|
3581
|
+
allowFloats: true,
|
|
3582
|
+
});
|
|
3571
3583
|
validateFps(fps, 'to spring()', false);
|
|
3572
3584
|
const durationRatio = durationInFrames === undefined
|
|
3573
3585
|
? 1
|
|
@@ -3579,6 +3591,8 @@ function spring({ frame, fps, config = {}, from = 0, to = 1, durationInFrames, d
|
|
|
3579
3591
|
to,
|
|
3580
3592
|
threshold: durationRestThreshold,
|
|
3581
3593
|
});
|
|
3594
|
+
// Delay the spring by telling the calculation we're at an earlier frame.
|
|
3595
|
+
const frame = passedFrame - delay;
|
|
3582
3596
|
const spr = springCalculation({
|
|
3583
3597
|
fps,
|
|
3584
3598
|
frame: frame / durationRatio,
|
|
@@ -3850,7 +3864,11 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
|
|
|
3850
3864
|
var _a;
|
|
3851
3865
|
if (current === null || current === void 0 ? void 0 : current.error) {
|
|
3852
3866
|
console.error('Error occurred in video', current === null || current === void 0 ? void 0 : current.error);
|
|
3853
|
-
|
|
3867
|
+
// If user is handling the error, we don't cause an unhandled exception
|
|
3868
|
+
if (props.onError) {
|
|
3869
|
+
return;
|
|
3870
|
+
}
|
|
3871
|
+
throw new Error(`The browser threw an error while playing the video ${src}: Code ${current.error.code} - ${(_a = current === null || current === void 0 ? void 0 : current.error) === null || _a === void 0 ? void 0 : _a.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`);
|
|
3854
3872
|
}
|
|
3855
3873
|
else {
|
|
3856
3874
|
throw new Error('The browser threw an error');
|
|
@@ -3860,7 +3878,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
|
|
|
3860
3878
|
return () => {
|
|
3861
3879
|
current.removeEventListener('error', errorHandler);
|
|
3862
3880
|
};
|
|
3863
|
-
}, [src]);
|
|
3881
|
+
}, [props.onError, src]);
|
|
3864
3882
|
const currentOnDurationCallback = useRef();
|
|
3865
3883
|
currentOnDurationCallback.current = onDuration;
|
|
3866
3884
|
useEffect(() => {
|
|
@@ -3892,7 +3910,7 @@ const VideoForDevelopment = forwardRef(VideoForDevelopmentRefForwardingFunction)
|
|
|
3892
3910
|
* @see [Documentation](https://www.remotion.dev/docs/offthreadvideo)
|
|
3893
3911
|
*/
|
|
3894
3912
|
const OffthreadVideo = (props) => {
|
|
3895
|
-
const { startFrom, endAt, ...otherProps } = props;
|
|
3913
|
+
const { startFrom, endAt, imageFormat, ...otherProps } = props;
|
|
3896
3914
|
const environment = useRemotionEnvironment();
|
|
3897
3915
|
const onDuration = useCallback(() => undefined, []);
|
|
3898
3916
|
if (typeof props.src !== 'string') {
|
|
@@ -3907,7 +3925,7 @@ const OffthreadVideo = (props) => {
|
|
|
3907
3925
|
validateMediaProps(props, 'Video');
|
|
3908
3926
|
validateOffthreadVideoImageFormat(props.imageFormat);
|
|
3909
3927
|
if (environment === 'rendering') {
|
|
3910
|
-
return jsx(OffthreadVideoForRendering, { ...otherProps });
|
|
3928
|
+
return (jsx(OffthreadVideoForRendering, { imageFormat: imageFormat, ...otherProps }));
|
|
3911
3929
|
}
|
|
3912
3930
|
return (jsx(VideoForDevelopment, { onDuration: onDuration, onlyWarnForMediaSeekingError: true, ...otherProps }));
|
|
3913
3931
|
};
|
|
@@ -4041,7 +4059,11 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
4041
4059
|
var _a;
|
|
4042
4060
|
if (current === null || current === void 0 ? void 0 : current.error) {
|
|
4043
4061
|
console.error('Error occurred in video', current === null || current === void 0 ? void 0 : current.error);
|
|
4044
|
-
|
|
4062
|
+
// If user is handling the error, we don't cause an unhandled exception
|
|
4063
|
+
if (onError) {
|
|
4064
|
+
return;
|
|
4065
|
+
}
|
|
4066
|
+
throw new Error(`The browser threw an error while playing the video ${props.src}: Code ${current.error.code} - ${(_a = current === null || current === void 0 ? void 0 : current.error) === null || _a === void 0 ? void 0 : _a.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`);
|
|
4045
4067
|
}
|
|
4046
4068
|
else {
|
|
4047
4069
|
throw new Error('The browser threw an error');
|
|
@@ -4062,6 +4084,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
4062
4084
|
videoConfig.fps,
|
|
4063
4085
|
frame,
|
|
4064
4086
|
mediaStartsAt,
|
|
4087
|
+
onError,
|
|
4065
4088
|
]);
|
|
4066
4089
|
const { src } = props;
|
|
4067
4090
|
// If video source switches, make new handle
|
package/dist/esm/version.mjs
CHANGED