remotion 4.0.486 → 4.0.488
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/HtmlInCanvas.js +2 -4
- package/dist/cjs/Img.js +18 -11
- package/dist/cjs/Still.js +2 -0
- package/dist/cjs/TimelineContext.d.ts +3 -3
- package/dist/cjs/animated-image/AnimatedImage.d.ts +13 -2
- package/dist/cjs/animated-image/AnimatedImage.js +13 -0
- package/dist/cjs/animated-image/canvas.d.ts +8 -11
- package/dist/cjs/animated-image/canvas.js +2 -2
- package/dist/cjs/animated-image/props.d.ts +2 -1
- package/dist/cjs/audio/shared-audio-tags.d.ts +1 -0
- package/dist/cjs/audio/shared-audio-tags.js +2 -2
- package/dist/cjs/buffering.d.ts +1 -1
- package/dist/cjs/buffering.js +14 -6
- package/dist/cjs/canvas-image/CanvasImage.js +28 -17
- package/dist/cjs/get-media-sync-action.d.ts +44 -0
- package/dist/cjs/get-media-sync-action.js +78 -0
- package/dist/cjs/internals.d.ts +2 -2
- package/dist/cjs/interpolate-translate.d.ts +8 -0
- package/dist/cjs/interpolate-translate.js +70 -0
- package/dist/cjs/timeline-position-state.d.ts +2 -2
- package/dist/cjs/use-media-playback.js +70 -82
- package/dist/cjs/use-request-video-callback-time.d.ts +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wrap-in-schema.d.ts +3 -3
- package/dist/cjs/wrap-in-schema.js +2 -2
- package/dist/cjs/wrap-remotion-context.d.ts +1 -1
- package/dist/esm/index.mjs +224 -119
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.interpolateTranslate = void 0;
|
|
4
|
+
const interpolate_js_1 = require("./interpolate.js");
|
|
5
|
+
const pixelValueRegex = /^([+-]?(?:\d+\.?\d*|\.\d+))px$/;
|
|
6
|
+
const parseTranslate = (value) => {
|
|
7
|
+
if (typeof value !== 'string') {
|
|
8
|
+
throw new TypeError(`outputRange must contain only strings, but got ${typeof value}`);
|
|
9
|
+
}
|
|
10
|
+
const parts = value.trim().split(/\s+/);
|
|
11
|
+
if (parts.length < 1 || parts.length > 3 || parts[0] === '') {
|
|
12
|
+
throw new TypeError(`translate values must contain 1 to 3 pixel values, but got "${value}"`);
|
|
13
|
+
}
|
|
14
|
+
return parts.map((part) => {
|
|
15
|
+
const match = pixelValueRegex.exec(part);
|
|
16
|
+
if (match === null) {
|
|
17
|
+
throw new TypeError(`interpolateTranslate() only supports px values, but got "${part}" in "${value}"`);
|
|
18
|
+
}
|
|
19
|
+
return Number(match[1]);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
/*
|
|
23
|
+
* @description Allows you to map a range of values to CSS translate values using pixel units.
|
|
24
|
+
* @see [Documentation](https://remotion.dev/docs/interpolate-translate)
|
|
25
|
+
*/
|
|
26
|
+
const interpolateTranslate = (input, inputRange, outputRange, options) => {
|
|
27
|
+
var _a;
|
|
28
|
+
if (typeof input === 'undefined') {
|
|
29
|
+
throw new TypeError('input can not be undefined');
|
|
30
|
+
}
|
|
31
|
+
if (typeof inputRange === 'undefined') {
|
|
32
|
+
throw new TypeError('inputRange can not be undefined');
|
|
33
|
+
}
|
|
34
|
+
if (typeof outputRange === 'undefined') {
|
|
35
|
+
throw new TypeError('outputRange can not be undefined');
|
|
36
|
+
}
|
|
37
|
+
if (inputRange.length !== outputRange.length) {
|
|
38
|
+
throw new TypeError('inputRange (' +
|
|
39
|
+
inputRange.length +
|
|
40
|
+
' values provided) and outputRange (' +
|
|
41
|
+
outputRange.length +
|
|
42
|
+
' values provided) must have the same length');
|
|
43
|
+
}
|
|
44
|
+
const parsedOutputRange = outputRange.map((translateValue) => parseTranslate(translateValue));
|
|
45
|
+
const firstValueLength = (_a = parsedOutputRange[0]) === null || _a === void 0 ? void 0 : _a.length;
|
|
46
|
+
if (firstValueLength === undefined) {
|
|
47
|
+
throw new TypeError('outputRange must have at least 1 element');
|
|
48
|
+
}
|
|
49
|
+
for (const parsedTranslate of parsedOutputRange) {
|
|
50
|
+
if (parsedTranslate.length !== firstValueLength) {
|
|
51
|
+
throw new TypeError(`All translate values must have the same number of pixel values, but got ${firstValueLength} and ${parsedTranslate.length}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return new Array(firstValueLength)
|
|
55
|
+
.fill(true)
|
|
56
|
+
.map((_, index) => {
|
|
57
|
+
const outputValues = [];
|
|
58
|
+
for (const translateValue of parsedOutputRange) {
|
|
59
|
+
const value = translateValue[index];
|
|
60
|
+
if (value === undefined) {
|
|
61
|
+
throw new TypeError(`All translate values must have the same number of pixel values, but got ${firstValueLength} and ${translateValue.length}`);
|
|
62
|
+
}
|
|
63
|
+
outputValues.push(value);
|
|
64
|
+
}
|
|
65
|
+
const interpolatedValue = (0, interpolate_js_1.interpolate)(input, inputRange, outputValues, options);
|
|
66
|
+
return `${interpolatedValue}px`;
|
|
67
|
+
})
|
|
68
|
+
.join(' ');
|
|
69
|
+
};
|
|
70
|
+
exports.interpolateTranslate = interpolateTranslate;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
2
|
import { type PlaybackRateContextValue, type TimelineContextValue } from './TimelineContext.js';
|
|
3
3
|
export type PlayableMediaTag = {
|
|
4
4
|
play: (reason: string) => void;
|
|
@@ -17,7 +17,7 @@ export declare const useTimelineSetFrame: () => (u: import("react").SetStateActi
|
|
|
17
17
|
type PlayingReturnType = readonly [
|
|
18
18
|
boolean,
|
|
19
19
|
(u: React.SetStateAction<boolean>) => void,
|
|
20
|
-
|
|
20
|
+
RefObject<boolean>
|
|
21
21
|
];
|
|
22
22
|
export declare const usePlayingState: () => PlayingReturnType;
|
|
23
23
|
export {};
|
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
|
|
6
6
|
const buffer_until_first_frame_js_1 = require("./buffer-until-first-frame.js");
|
|
7
7
|
const buffering_js_1 = require("./buffering.js");
|
|
8
|
+
const get_media_sync_action_js_1 = require("./get-media-sync-action.js");
|
|
8
9
|
const log_level_context_js_1 = require("./log-level-context.js");
|
|
9
10
|
const log_js_1 = require("./log.js");
|
|
10
11
|
const media_tag_current_time_timestamp_js_1 = require("./media-tag-current-time-timestamp.js");
|
|
@@ -144,7 +145,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
144
145
|
}, [mediaRef, playbackRate, preservePitch]);
|
|
145
146
|
(0, react_1.useEffect)(() => {
|
|
146
147
|
var _a, _b;
|
|
147
|
-
var _c;
|
|
148
|
+
var _c, _d;
|
|
148
149
|
const tagName = mediaType === 'audio' ? '<Html5Audio>' : '<Html5Video>';
|
|
149
150
|
if (!mediaRef.current) {
|
|
150
151
|
throw new Error(`No ${mediaType} ref found`);
|
|
@@ -152,107 +153,94 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
152
153
|
if (!src) {
|
|
153
154
|
throw new Error(`No 'src' attribute was passed to the ${tagName} element.`);
|
|
154
155
|
}
|
|
155
|
-
const {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
rvcCurrentTime.current
|
|
166
|
-
|
|
167
|
-
:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
156
|
+
const { current } = mediaRef;
|
|
157
|
+
const action = (0, get_media_sync_action_js_1.getMediaSyncAction)({
|
|
158
|
+
duration: current.duration,
|
|
159
|
+
currentTime: current.currentTime,
|
|
160
|
+
paused: current.paused,
|
|
161
|
+
ended: current.ended,
|
|
162
|
+
desiredUnclampedTime,
|
|
163
|
+
mediaTagTime: mediaTagCurrentTime.current.time,
|
|
164
|
+
mediaTagLastUpdate: mediaTagCurrentTime.current.lastUpdate,
|
|
165
|
+
rvcTime: (_c = (_a = rvcCurrentTime.current) === null || _a === void 0 ? void 0 : _a.time) !== null && _c !== void 0 ? _c : null,
|
|
166
|
+
rvcLastUpdate: (_d = (_b = rvcCurrentTime.current) === null || _b === void 0 ? void 0 : _b.lastUpdate) !== null && _d !== void 0 ? _d : null,
|
|
167
|
+
isVariableFpsVideo: Boolean(isVariableFpsVideoMap.current[src]),
|
|
168
|
+
acceptableTimeShift: acceptableTimeShiftButLessThanDuration,
|
|
169
|
+
lastSeekDueToShift: lastSeekDueToShift.current,
|
|
170
|
+
playing,
|
|
171
|
+
playbackRate,
|
|
172
|
+
mediaTagBufferingOrStalled: isMediaTagBuffering || isBuffering(),
|
|
173
|
+
playerBuffering: buffering.buffering.current,
|
|
174
|
+
absoluteFrame,
|
|
175
|
+
onlyWarnForMediaSeekingError,
|
|
176
|
+
isPremounting,
|
|
177
|
+
isPostmounting,
|
|
178
|
+
pauseWhenBuffering,
|
|
179
|
+
});
|
|
180
|
+
if (action.type === 'none') {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (action.type === 'seek-due-to-shift') {
|
|
175
184
|
lastSeek.current = (0, seek_js_1.seek)({
|
|
176
|
-
mediaRef:
|
|
177
|
-
time: shouldBeTime,
|
|
185
|
+
mediaRef: current,
|
|
186
|
+
time: action.shouldBeTime,
|
|
178
187
|
logLevel,
|
|
179
|
-
why:
|
|
188
|
+
why: action.why,
|
|
180
189
|
mountTime,
|
|
181
190
|
});
|
|
182
191
|
lastSeekDueToShift.current = lastSeek.current;
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
bufferUntilFirstFrame(shouldBeTime);
|
|
186
|
-
}
|
|
187
|
-
if (mediaRef.current.paused) {
|
|
188
|
-
(0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
|
|
189
|
-
mediaRef,
|
|
190
|
-
mediaType,
|
|
191
|
-
onAutoPlayError,
|
|
192
|
-
logLevel,
|
|
193
|
-
mountTime,
|
|
194
|
-
reason: 'player is playing but media tag is paused, and just seeked',
|
|
195
|
-
isPlayer: env.isPlayer,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
192
|
+
if (action.bufferUntilFirstFrame) {
|
|
193
|
+
bufferUntilFirstFrame(action.shouldBeTime);
|
|
198
194
|
}
|
|
199
|
-
if (
|
|
200
|
-
(0,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const seekThreshold = playing ? 0.15 : 0.01;
|
|
205
|
-
// Only perform a seek if the time is not already the same.
|
|
206
|
-
// Chrome rounds to 6 digits, so 0.033333333 -> 0.033333,
|
|
207
|
-
// therefore a threshold is allowed.
|
|
208
|
-
// Refer to the https://github.com/remotion-dev/video-buffering-example
|
|
209
|
-
// which is fixed by only seeking conditionally.
|
|
210
|
-
const makesSenseToSeek = Math.abs(mediaRef.current.currentTime - shouldBeTime) > seekThreshold;
|
|
211
|
-
const isMediaTagBufferingOrStalled = isMediaTagBuffering || isBuffering();
|
|
212
|
-
const isSomethingElseBuffering = buffering.buffering.current && !isMediaTagBufferingOrStalled;
|
|
213
|
-
if (!playing || isSomethingElseBuffering) {
|
|
214
|
-
if (makesSenseToSeek) {
|
|
215
|
-
lastSeek.current = (0, seek_js_1.seek)({
|
|
216
|
-
mediaRef: mediaRef.current,
|
|
217
|
-
time: shouldBeTime,
|
|
195
|
+
if (action.playReason !== null) {
|
|
196
|
+
(0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
|
|
197
|
+
mediaRef,
|
|
198
|
+
mediaType,
|
|
199
|
+
onAutoPlayError,
|
|
218
200
|
logLevel,
|
|
219
|
-
why: `not playing or something else is buffering. time offset is over seek threshold (${seekThreshold})`,
|
|
220
201
|
mountTime,
|
|
202
|
+
reason: action.playReason,
|
|
203
|
+
isPlayer: env.isPlayer,
|
|
221
204
|
});
|
|
222
205
|
}
|
|
206
|
+
if (action.warnAboutNonSeekable) {
|
|
207
|
+
(0, warn_about_non_seekable_media_js_1.warnAboutNonSeekableMedia)(current, 'console-error');
|
|
208
|
+
}
|
|
223
209
|
return;
|
|
224
210
|
}
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
// We now assured we are in playing state and not buffering
|
|
229
|
-
const pausedCondition = mediaRef.current.paused && !mediaRef.current.ended;
|
|
230
|
-
const firstFrameCondition = absoluteFrame === 0;
|
|
231
|
-
if (pausedCondition || firstFrameCondition) {
|
|
232
|
-
const reason = pausedCondition
|
|
233
|
-
? 'media tag is paused'
|
|
234
|
-
: 'absolute frame is 0';
|
|
235
|
-
if (makesSenseToSeek) {
|
|
211
|
+
if (action.type === 'seek-if-not-playing') {
|
|
212
|
+
if (action.why !== null) {
|
|
236
213
|
lastSeek.current = (0, seek_js_1.seek)({
|
|
237
|
-
mediaRef:
|
|
238
|
-
time: shouldBeTime,
|
|
214
|
+
mediaRef: current,
|
|
215
|
+
time: action.shouldBeTime,
|
|
239
216
|
logLevel,
|
|
240
|
-
why:
|
|
217
|
+
why: action.why,
|
|
241
218
|
mountTime,
|
|
242
219
|
});
|
|
243
220
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
// action.type === 'play-and-seek'
|
|
224
|
+
if (action.why !== null) {
|
|
225
|
+
lastSeek.current = (0, seek_js_1.seek)({
|
|
226
|
+
mediaRef: current,
|
|
227
|
+
time: action.shouldBeTime,
|
|
248
228
|
logLevel,
|
|
229
|
+
why: action.why,
|
|
249
230
|
mountTime,
|
|
250
|
-
reason: `player is playing and ${reason}`,
|
|
251
|
-
isPlayer: env.isPlayer,
|
|
252
231
|
});
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
232
|
+
}
|
|
233
|
+
(0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
|
|
234
|
+
mediaRef,
|
|
235
|
+
mediaType,
|
|
236
|
+
onAutoPlayError,
|
|
237
|
+
logLevel,
|
|
238
|
+
mountTime,
|
|
239
|
+
reason: action.playReason,
|
|
240
|
+
isPlayer: env.isPlayer,
|
|
241
|
+
});
|
|
242
|
+
if (action.bufferUntilFirstFrame) {
|
|
243
|
+
bufferUntilFirstFrame(action.shouldBeTime);
|
|
256
244
|
}
|
|
257
245
|
}, [
|
|
258
246
|
absoluteFrame,
|
|
@@ -2,7 +2,7 @@ import type { RefObject } from 'react';
|
|
|
2
2
|
export declare const useRequestVideoCallbackTime: ({ mediaRef, mediaType, lastSeek, onVariableFpsVideoDetected, }: {
|
|
3
3
|
mediaRef: RefObject<HTMLAudioElement | HTMLVideoElement | null>;
|
|
4
4
|
mediaType: "audio" | "video";
|
|
5
|
-
lastSeek:
|
|
5
|
+
lastSeek: RefObject<number | null>;
|
|
6
6
|
onVariableFpsVideoDetected: () => void;
|
|
7
7
|
}) => RefObject<{
|
|
8
8
|
time: number;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SequenceControls } from './CompositionManager.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type SequenceSchema } from './sequence-field-schema.js';
|
|
4
4
|
export declare const getNestedValue: (obj: Record<string, unknown>, key: string) => unknown;
|
|
5
5
|
export declare const readValuesFromProps: (props: Record<string, unknown>, keys: string[]) => Record<string, unknown>;
|
|
6
|
-
export declare const selectActiveKeys: (schema:
|
|
6
|
+
export declare const selectActiveKeys: (schema: SequenceSchema, values: Record<string, unknown>) => string[];
|
|
7
7
|
export declare const mergeValues: ({ props, valuesDotNotation, schemaKeys, propsToDelete, }: {
|
|
8
8
|
props: Record<string, unknown>;
|
|
9
9
|
valuesDotNotation: Record<string, unknown>;
|
|
10
10
|
schemaKeys: string[];
|
|
11
11
|
propsToDelete: Set<string>;
|
|
12
12
|
}) => Record<string, unknown>;
|
|
13
|
-
export declare const wrapInSchema: <S extends
|
|
13
|
+
export declare const wrapInSchema: <S extends SequenceSchema, Props extends object>({ Component, componentIdentity, schema, supportsEffects, }: {
|
|
14
14
|
Component: React.ComponentType<Props & {
|
|
15
15
|
readonly _experimentalControls: SequenceControls | undefined;
|
|
16
16
|
}>;
|
|
@@ -38,7 +38,7 @@ const react_1 = __importStar(require("react"));
|
|
|
38
38
|
const delete_nested_key_js_1 = require("./delete-nested-key.js");
|
|
39
39
|
const use_memoized_effects_js_1 = require("./effects/use-memoized-effects.js");
|
|
40
40
|
const flatten_schema_js_1 = require("./flatten-schema.js");
|
|
41
|
-
const
|
|
41
|
+
const sequence_field_schema_js_1 = require("./sequence-field-schema.js");
|
|
42
42
|
const sequence_node_path_js_1 = require("./sequence-node-path.js");
|
|
43
43
|
const SequenceManager_js_1 = require("./SequenceManager.js");
|
|
44
44
|
const use_current_frame_js_1 = require("./use-current-frame.js");
|
|
@@ -100,7 +100,7 @@ exports.mergeValues = mergeValues;
|
|
|
100
100
|
const stackToOverrideMap = {};
|
|
101
101
|
const wrapInSchema = ({ Component, componentIdentity, schema, supportsEffects, }) => {
|
|
102
102
|
// Schema is static for a component, so we move this outside
|
|
103
|
-
const schemaWithSequenceName = (0,
|
|
103
|
+
const schemaWithSequenceName = (0, sequence_field_schema_js_1.extendSchemaWithSequenceName)(schema);
|
|
104
104
|
const flatSchema = (0, flatten_schema_js_1.getFlatSchemaWithAllKeys)(schemaWithSequenceName);
|
|
105
105
|
const flatKeys = Object.keys(flatSchema);
|
|
106
106
|
const Wrapped = (0, react_1.forwardRef)((props, ref) => {
|
|
@@ -39,7 +39,7 @@ export declare function useRemotionContexts(): {
|
|
|
39
39
|
listenForResume: (callback: () => void) => {
|
|
40
40
|
remove: () => void;
|
|
41
41
|
};
|
|
42
|
-
buffering: React.
|
|
42
|
+
buffering: React.RefObject<boolean>;
|
|
43
43
|
} | null;
|
|
44
44
|
logLevelContext: import("./log-level-context.js").LoggingContextValue;
|
|
45
45
|
};
|