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.
@@ -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 { MutableRefObject } from 'react';
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
- MutableRefObject<boolean>
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 { duration } = mediaRef.current;
156
- const shouldBeTime = !Number.isNaN(duration) && Number.isFinite(duration)
157
- ? Math.min(duration, desiredUnclampedTime)
158
- : desiredUnclampedTime;
159
- const mediaTagTime = mediaTagCurrentTime.current.time;
160
- const rvcTime = (_c = (_a = rvcCurrentTime.current) === null || _a === void 0 ? void 0 : _a.time) !== null && _c !== void 0 ? _c : null;
161
- const isVariableFpsVideo = isVariableFpsVideoMap.current[src];
162
- const timeShiftMediaTag = Math.abs(shouldBeTime - mediaTagTime);
163
- const timeShiftRvcTag = rvcTime ? Math.abs(shouldBeTime - rvcTime) : null;
164
- const mostRecentTimeshift = ((_b = rvcCurrentTime.current) === null || _b === void 0 ? void 0 : _b.lastUpdate) &&
165
- rvcCurrentTime.current.time > mediaTagCurrentTime.current.lastUpdate
166
- ? timeShiftRvcTag
167
- : timeShiftMediaTag;
168
- const timeShift = timeShiftRvcTag && !isVariableFpsVideo
169
- ? mostRecentTimeshift
170
- : timeShiftMediaTag;
171
- if (timeShift > acceptableTimeShiftButLessThanDuration &&
172
- lastSeekDueToShift.current !== shouldBeTime) {
173
- // If scrubbing around, adjust timing
174
- // or if time shift is bigger than 0.45sec
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: mediaRef.current,
177
- time: shouldBeTime,
185
+ mediaRef: current,
186
+ time: action.shouldBeTime,
178
187
  logLevel,
179
- why: `because time shift is too big. shouldBeTime = ${shouldBeTime}, isTime = ${mediaTagTime}, requestVideoCallbackTime = ${rvcTime}, timeShift = ${timeShift}${isVariableFpsVideo ? ', isVariableFpsVideo = true' : ''}, isPremounting = ${isPremounting}, isPostmounting = ${isPostmounting}, pauseWhenBuffering = ${pauseWhenBuffering}`,
188
+ why: action.why,
180
189
  mountTime,
181
190
  });
182
191
  lastSeekDueToShift.current = lastSeek.current;
183
- if (playing) {
184
- if (playbackRate > 0) {
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 (!onlyWarnForMediaSeekingError) {
200
- (0, warn_about_non_seekable_media_js_1.warnAboutNonSeekableMedia)(mediaRef.current, onlyWarnForMediaSeekingError ? 'console-warning' : 'console-error');
201
- }
202
- return;
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 (!playing || buffering.buffering.current) {
226
- return;
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: mediaRef.current,
238
- time: shouldBeTime,
214
+ mediaRef: current,
215
+ time: action.shouldBeTime,
239
216
  logLevel,
240
- why: `is over timeshift threshold (threshold = ${seekThreshold}) and ${reason}`,
217
+ why: action.why,
241
218
  mountTime,
242
219
  });
243
220
  }
244
- (0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
245
- mediaRef,
246
- mediaType,
247
- onAutoPlayError,
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
- if (!isVariableFpsVideo && playbackRate > 0) {
254
- bufferUntilFirstFrame(shouldBeTime);
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: import("react").MutableRefObject<number | null>;
5
+ lastSeek: RefObject<number | null>;
6
6
  onVariableFpsVideoDetected: () => void;
7
7
  }) => RefObject<{
8
8
  time: number;
@@ -3,4 +3,4 @@
3
3
  * @see [Documentation](https://remotion.dev/docs/version)
4
4
  * @returns {string} The current version of the remotion package
5
5
  */
6
- export declare const VERSION = "4.0.486";
6
+ export declare const VERSION = "4.0.488";
@@ -7,4 +7,4 @@ exports.VERSION = void 0;
7
7
  * @see [Documentation](https://remotion.dev/docs/version)
8
8
  * @returns {string} The current version of the remotion package
9
9
  */
10
- exports.VERSION = '4.0.486';
10
+ exports.VERSION = '4.0.488';
@@ -1,16 +1,16 @@
1
1
  import React from 'react';
2
2
  import type { SequenceControls } from './CompositionManager.js';
3
- import { type InteractivitySchema } from './interactivity-schema.js';
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: InteractivitySchema, values: Record<string, unknown>) => string[];
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 InteractivitySchema, Props extends object>({ Component, componentIdentity, schema, supportsEffects, }: {
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 interactivity_schema_js_1 = require("./interactivity-schema.js");
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, interactivity_schema_js_1.extendSchemaWithSequenceName)(schema);
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.MutableRefObject<boolean>;
42
+ buffering: React.RefObject<boolean>;
43
43
  } | null;
44
44
  logLevelContext: import("./log-level-context.js").LoggingContextValue;
45
45
  };