remotion 4.0.505 → 4.0.507

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.
Files changed (41) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/CompositionManager.d.ts +7 -3
  3. package/dist/cjs/Interactive.d.ts +12 -2
  4. package/dist/cjs/Interactive.js +12 -1
  5. package/dist/cjs/Sequence.js +35 -4
  6. package/dist/cjs/TimelineContext.d.ts +6 -0
  7. package/dist/cjs/TimelineContext.js +12 -2
  8. package/dist/cjs/audio/shared-audio-tags.d.ts +2 -1
  9. package/dist/cjs/audio/shared-audio-tags.js +22 -6
  10. package/dist/cjs/audio/wait-until-actually-resumed.d.ts +2 -1
  11. package/dist/cjs/audio/wait-until-actually-resumed.js +34 -4
  12. package/dist/cjs/buffering.js +17 -8
  13. package/dist/cjs/index.d.ts +3 -2
  14. package/dist/cjs/interactivity-schema.d.ts +10 -0
  15. package/dist/cjs/interactivity-schema.js +8 -0
  16. package/dist/cjs/internals.d.ts +7 -3
  17. package/dist/cjs/internals.js +5 -0
  18. package/dist/cjs/interpolate-keyframed-status.js +2 -0
  19. package/dist/cjs/portal-node.d.ts +3 -0
  20. package/dist/cjs/portal-node.js +22 -1
  21. package/dist/cjs/render-resource-manager.d.ts +13 -0
  22. package/dist/cjs/render-resource-manager.js +47 -0
  23. package/dist/cjs/runtime-value-store.d.ts +10 -0
  24. package/dist/cjs/runtime-value-store.js +29 -0
  25. package/dist/cjs/use-current-scale.js +10 -6
  26. package/dist/cjs/use-schema.d.ts +4 -1
  27. package/dist/cjs/version.d.ts +1 -1
  28. package/dist/cjs/version.js +1 -1
  29. package/dist/cjs/with-interactivity-schema.js +14 -2
  30. package/dist/cjs/wrap-remotion-context.d.ts +1 -0
  31. package/dist/cjs/wrap-remotion-context.js +4 -1
  32. package/dist/esm/index.mjs +331 -108
  33. package/dist/esm/no-react.mjs +8 -0
  34. package/dist/esm/version.mjs +1 -1
  35. package/package.json +2 -2
  36. package/dist/cjs/interpolate-translate.d.ts +0 -8
  37. package/dist/cjs/interpolate-translate.js +0 -70
  38. package/dist/cjs/sequence-field-schema.d.ts +0 -425
  39. package/dist/cjs/sequence-field-schema.js +0 -133
  40. package/dist/cjs/wrap-in-schema.d.ts +0 -20
  41. package/dist/cjs/wrap-in-schema.js +0 -203
package/README.md CHANGED
@@ -48,6 +48,7 @@ Remotion is extensively documented over more than 1000 pages.
48
48
  - [Prompts](https://www.remotion.dev/prompts)
49
49
  - [Templates](https://remotion.dev/templates)
50
50
  - Components
51
+ - [Elements](https://remotion.dev/elements)
51
52
  - [Effects](https://remotion.dev/effects)
52
53
  - [Shapes](https://remotion.dev/docs/shapes)
53
54
  - [Transitions](https://remotion.dev/transitions)
@@ -7,6 +7,7 @@ import type { EffectDefinition } from './effects/effect-types.js';
7
7
  import type { InteractivitySchema } from './interactivity-schema.js';
8
8
  import type { NonceHistory } from './nonce.js';
9
9
  import type { InferProps, PropsIfHasProps } from './props-if-has-props.js';
10
+ import type { RuntimeValueSnapshot, RuntimeValueStore } from './runtime-value-store.js';
10
11
  export type TComposition<Schema extends AnyZodObject, Props extends Record<string, unknown>> = {
11
12
  width: number | undefined;
12
13
  height: number | undefined;
@@ -56,14 +57,17 @@ export type LoopDisplay = {
56
57
  durationInFrames: number;
57
58
  };
58
59
  export type JsxComponentIdentity = string;
59
- export type SequenceControls = {
60
+ export type SequenceRegistrationControls = {
60
61
  schema: InteractivitySchema;
61
- currentRuntimeValueDotNotation: Record<string, unknown>;
62
+ runtimeValues: RuntimeValueStore;
62
63
  overrideId: string;
63
64
  supportsEffects: boolean;
64
65
  componentIdentity: JsxComponentIdentity | null;
65
66
  componentName: string;
66
67
  };
68
+ export type SequenceControls = SequenceRegistrationControls & {
69
+ currentRuntimeValueDotNotation: RuntimeValueSnapshot;
70
+ };
67
71
  export type TSequence = {
68
72
  from: number;
69
73
  trimBefore: number | null;
@@ -78,7 +82,7 @@ export type TSequence = {
78
82
  getStack: () => string | null;
79
83
  premountDisplay: number | null;
80
84
  postmountDisplay: number | null;
81
- controls: SequenceControls | null;
85
+ controls: SequenceRegistrationControls | null;
82
86
  refForOutline: React.RefObject<Element | null> | null;
83
87
  effects: readonly EffectDefinition<unknown>[];
84
88
  isInsideSeries: boolean;
@@ -10,8 +10,8 @@ export type InteractiveBaseProps = Pick<SequenceProps, 'durationInFrames' | 'fro
10
10
  export type InteractiveTransformProps = Pick<AbsoluteFillLayout, 'style'>;
11
11
  export type InteractiveCropProps = Pick<SequenceProps, 'cropLeft' | 'cropRight' | 'cropTop' | 'cropBottom'>;
12
12
  export type InteractivePremountProps = Pick<AbsoluteFillLayout, 'premountFor' | 'postmountFor' | 'styleWhilePremounted' | 'styleWhilePostmounted'>;
13
- type InteractiveSequenceProps = InteractiveBaseProps;
14
- type InteractiveElementProps<Tag extends InteractiveTag> = Omit<React.ComponentPropsWithoutRef<Tag>, keyof InteractiveSequenceProps> & InteractiveSequenceProps;
13
+ type InteractiveManagedProps = InteractiveBaseProps & InteractiveCropProps;
14
+ type InteractiveElementProps<Tag extends InteractiveTag> = Omit<React.ComponentPropsWithoutRef<Tag>, keyof InteractiveManagedProps> & InteractiveManagedProps;
15
15
  type InteractiveElementComponent<Tag extends InteractiveTag> = React.ComponentType<InteractiveElementProps<Tag> & React.RefAttributes<ElementForTag<Tag>>>;
16
16
  type RemotionComponentIdentityPackage = 'remotion' | `@remotion/${string}`;
17
17
  /**
@@ -296,6 +296,11 @@ export declare const Interactive: {
296
296
  };
297
297
  };
298
298
  svgPaintSchema: {
299
+ readonly color: {
300
+ readonly type: "color";
301
+ readonly default: undefined;
302
+ readonly description: "Current color";
303
+ };
299
304
  readonly stroke: {
300
305
  readonly type: "color";
301
306
  readonly default: "none";
@@ -316,6 +321,11 @@ export declare const Interactive: {
316
321
  };
317
322
  };
318
323
  svgStrokeSchema: {
324
+ readonly color: {
325
+ readonly type: "color";
326
+ readonly default: undefined;
327
+ readonly description: "Current color";
328
+ };
319
329
  readonly stroke: {
320
330
  readonly type: "color";
321
331
  readonly default: "none";
@@ -39,6 +39,7 @@ const react_1 = __importStar(require("react"));
39
39
  const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
40
40
  const interactivity_schema_js_1 = require("./interactivity-schema.js");
41
41
  const Sequence_js_1 = require("./Sequence.js");
42
+ const use_crop_style_js_1 = require("./use-crop-style.js");
42
43
  const with_interactivity_schema_js_1 = require("./with-interactivity-schema.js");
43
44
  const sourcePathToIdentityPrefix = (packageName) => {
44
45
  if (packageName === 'remotion') {
@@ -58,6 +59,7 @@ const makeRemotionComponentIdentity = ({ packageName, componentName, }) => {
58
59
  const interactiveElementSchema = {
59
60
  ...interactivity_schema_js_1.baseSchema,
60
61
  ...interactivity_schema_js_1.transformSchema,
62
+ ...interactivity_schema_js_1.cropSchema,
61
63
  };
62
64
  const interactiveBackgroundElementSchema = {
63
65
  ...interactiveElementSchema,
@@ -106,7 +108,15 @@ const withSchema = (options) => {
106
108
  };
107
109
  const makeInteractiveElement = (tag, displayName, schema) => {
108
110
  const Inner = (0, react_1.forwardRef)((propsWithControls, ref) => {
109
- const { durationInFrames, from, trimBefore, freeze, hidden, name, showInTimeline, controls, ...props } = propsWithControls;
111
+ const { durationInFrames, from, trimBefore, freeze, hidden, name, showInTimeline, controls, cropLeft, cropRight, cropTop, cropBottom, style, ...props } = propsWithControls;
112
+ const croppedStyle = (0, use_crop_style_js_1.useCropStyle)({
113
+ cropLeft,
114
+ cropRight,
115
+ cropTop,
116
+ cropBottom,
117
+ style: style !== null && style !== void 0 ? style : null,
118
+ componentName: displayName,
119
+ });
110
120
  const refForOutline = (0, react_1.useRef)(null);
111
121
  const callbackRef = (0, react_1.useCallback)((element) => {
112
122
  refForOutline.current = element;
@@ -114,6 +124,7 @@ const makeInteractiveElement = (tag, displayName, schema) => {
114
124
  }, [ref]);
115
125
  return (jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: from !== null && from !== void 0 ? from : 0, trimBefore: trimBefore, durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity, freeze: freeze, hidden: hidden, name: name !== null && name !== void 0 ? name : displayName, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, controls: controls, _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/interactive", outlineRef: refForOutline, children: react_1.default.createElement(tag, {
116
126
  ...props,
127
+ style: croppedStyle !== null && croppedStyle !== void 0 ? croppedStyle : undefined,
117
128
  ref: callbackRef,
118
129
  }) }));
119
130
  });
@@ -189,6 +189,37 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, freeze
189
189
  : registeredFrozenFrame) *
190
190
  isMedia.data.playbackRate
191
191
  : null;
192
+ const controlsSchema = controls === null || controls === void 0 ? void 0 : controls.schema;
193
+ const controlsRuntimeValues = controls === null || controls === void 0 ? void 0 : controls.runtimeValues;
194
+ const controlsOverrideId = controls === null || controls === void 0 ? void 0 : controls.overrideId;
195
+ const controlsSupportsEffects = controls === null || controls === void 0 ? void 0 : controls.supportsEffects;
196
+ const controlsComponentIdentity = controls === null || controls === void 0 ? void 0 : controls.componentIdentity;
197
+ const controlsComponentName = controls === null || controls === void 0 ? void 0 : controls.componentName;
198
+ const registrationControls = (0, react_1.useMemo)(() => {
199
+ if (controlsSchema === undefined ||
200
+ controlsRuntimeValues === undefined ||
201
+ controlsOverrideId === undefined ||
202
+ controlsSupportsEffects === undefined ||
203
+ controlsComponentIdentity === undefined ||
204
+ controlsComponentName === undefined) {
205
+ return null;
206
+ }
207
+ return {
208
+ schema: controlsSchema,
209
+ runtimeValues: controlsRuntimeValues,
210
+ overrideId: controlsOverrideId,
211
+ supportsEffects: controlsSupportsEffects,
212
+ componentIdentity: controlsComponentIdentity,
213
+ componentName: controlsComponentName,
214
+ };
215
+ }, [
216
+ controlsComponentIdentity,
217
+ controlsComponentName,
218
+ controlsOverrideId,
219
+ controlsRuntimeValues,
220
+ controlsSchema,
221
+ controlsSupportsEffects,
222
+ ]);
192
223
  (0, react_1.useEffect)(() => {
193
224
  var _a, _b, _c;
194
225
  if (!env.isStudio) {
@@ -198,7 +229,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, freeze
198
229
  if (isMedia.type === 'image') {
199
230
  registerSequence({
200
231
  type: 'image',
201
- controls: controls !== null && controls !== void 0 ? controls : null,
232
+ controls: registrationControls,
202
233
  effects: _remotionInternalEffects !== null && _remotionInternalEffects !== void 0 ? _remotionInternalEffects : EMPTY_EFFECTS,
203
234
  displayName: timelineClipName,
204
235
  documentationLink: resolvedDocumentationLink,
@@ -223,7 +254,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, freeze
223
254
  else {
224
255
  registerSequence({
225
256
  type: isMedia.type,
226
- controls: controls !== null && controls !== void 0 ? controls : null,
257
+ controls: registrationControls,
227
258
  effects: _remotionInternalEffects !== null && _remotionInternalEffects !== void 0 ? _remotionInternalEffects : EMPTY_EFFECTS,
228
259
  displayName: timelineClipName,
229
260
  documentationLink: resolvedDocumentationLink,
@@ -270,7 +301,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, freeze
270
301
  getStack: () => stackRef.current,
271
302
  premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
272
303
  postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
273
- controls: controls !== null && controls !== void 0 ? controls : null,
304
+ controls: registrationControls,
274
305
  effects: _remotionInternalEffects !== null && _remotionInternalEffects !== void 0 ? _remotionInternalEffects : EMPTY_EFFECTS,
275
306
  refForOutline: refForOutline !== null && refForOutline !== void 0 ? refForOutline : null,
276
307
  isInsideSeries,
@@ -298,7 +329,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, freeze
298
329
  premountDisplay,
299
330
  postmountDisplay,
300
331
  env.isStudio,
301
- controls,
332
+ registrationControls,
302
333
  _remotionInternalEffects,
303
334
  isMedia,
304
335
  resolvedDocumentationLink,
@@ -7,6 +7,11 @@ export type TimelineContextValue = {
7
7
  imperativePlaying: RefObject<boolean>;
8
8
  audioAndVideoTags: RefObject<PlayableMediaTag[]>;
9
9
  };
10
+ export type TimelineImperativeContextValue = {
11
+ frameRef: RefObject<Record<string, number>>;
12
+ imperativePlaying: RefObject<boolean>;
13
+ audioAndVideoTags: RefObject<PlayableMediaTag[]>;
14
+ };
10
15
  export type PlaybackRateContextValue = {
11
16
  playbackRate: number;
12
17
  setPlaybackRate: (u: React.SetStateAction<number>) => void;
@@ -17,6 +22,7 @@ export type SetTimelineContextValue = {
17
22
  };
18
23
  export declare const SetTimelineContext: React.Context<SetTimelineContextValue>;
19
24
  export declare const TimelineContext: React.Context<TimelineContextValue | null>;
25
+ export declare const TimelineImperativeContext: React.Context<TimelineImperativeContextValue | null>;
20
26
  export declare const PlaybackRateContext: React.Context<PlaybackRateContextValue | null>;
21
27
  export declare const AbsoluteTimeContext: React.Context<TimelineContextValue | null>;
22
28
  export declare const TimelineContextProvider: React.FC<{
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimelineContextProvider = exports.AbsoluteTimeContext = exports.PlaybackRateContext = exports.TimelineContext = exports.SetTimelineContext = void 0;
3
+ exports.TimelineContextProvider = exports.AbsoluteTimeContext = exports.PlaybackRateContext = exports.TimelineImperativeContext = exports.TimelineContext = exports.SetTimelineContext = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const timeline_position_state_1 = require("./timeline-position-state");
@@ -14,6 +14,7 @@ exports.SetTimelineContext = (0, react_1.createContext)({
14
14
  },
15
15
  });
16
16
  exports.TimelineContext = (0, react_1.createContext)(null);
17
+ exports.TimelineImperativeContext = (0, react_1.createContext)(null);
17
18
  exports.PlaybackRateContext = (0, react_1.createContext)(null);
18
19
  exports.AbsoluteTimeContext = (0, react_1.createContext)(null);
19
20
  const TimelineContextProvider = ({ children, frameState }) => {
@@ -23,6 +24,8 @@ const TimelineContextProvider = ({ children, frameState }) => {
23
24
  const audioAndVideoTags = (0, react_1.useRef)([]);
24
25
  const [_frame, setFrame] = (0, react_1.useState)(() => (0, timeline_position_state_1.getInitialFrameState)());
25
26
  const frame = frameState !== null && frameState !== void 0 ? frameState : _frame;
27
+ const frameRef = (0, react_1.useRef)(frame);
28
+ frameRef.current = frame;
26
29
  const { delayRender, continueRender } = (0, use_delay_render_1.useDelayRender)();
27
30
  if (typeof window !== 'undefined') {
28
31
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -63,6 +66,13 @@ const TimelineContextProvider = ({ children, frameState }) => {
63
66
  audioAndVideoTags,
64
67
  };
65
68
  }, [frame, playing]);
69
+ const timelineImperativeContextValue = (0, react_1.useMemo)(() => {
70
+ return {
71
+ frameRef,
72
+ imperativePlaying,
73
+ audioAndVideoTags,
74
+ };
75
+ }, []);
66
76
  const playbackRateContextValue = (0, react_1.useMemo)(() => {
67
77
  return {
68
78
  playbackRate,
@@ -75,6 +85,6 @@ const TimelineContextProvider = ({ children, frameState }) => {
75
85
  setPlaying,
76
86
  };
77
87
  }, []);
78
- return (jsx_runtime_1.jsx(exports.AbsoluteTimeContext.Provider, { value: timelineContextValue, children: jsx_runtime_1.jsx(exports.PlaybackRateContext.Provider, { value: playbackRateContextValue, children: jsx_runtime_1.jsx(exports.TimelineContext.Provider, { value: timelineContextValue, children: jsx_runtime_1.jsx(exports.SetTimelineContext.Provider, { value: setTimelineContextValue, children: children }) }) }) }));
88
+ return (jsx_runtime_1.jsx(exports.AbsoluteTimeContext.Provider, { value: timelineContextValue, children: jsx_runtime_1.jsx(exports.PlaybackRateContext.Provider, { value: playbackRateContextValue, children: jsx_runtime_1.jsx(exports.TimelineImperativeContext.Provider, { value: timelineImperativeContextValue, children: jsx_runtime_1.jsx(exports.TimelineContext.Provider, { value: timelineContextValue, children: jsx_runtime_1.jsx(exports.SetTimelineContext.Provider, { value: setTimelineContextValue, children: children }) }) }) }) }));
79
89
  };
80
90
  exports.TimelineContextProvider = TimelineContextProvider;
@@ -1,6 +1,7 @@
1
1
  import React, { type AudioHTMLAttributes } from 'react';
2
2
  import type { SharedElementSourceNode } from './shared-element-source-node.js';
3
3
  import type { RemotionAudioContextState } from './use-audio-context.js';
4
+ import { type AudioContextResumeResult } from './wait-until-actually-resumed.js';
4
5
  /**
5
6
  * This functionality of Remotion will keep a certain amount
6
7
  * of <audio> tags pre-mounted and by default filled with an empty audio track.
@@ -58,7 +59,7 @@ type SharedAudioContextValue = {
58
59
  scheduleAudioNode: (options: ScheduleAudioNodeOptions) => ScheduleAudioNodeResult;
59
60
  resume: () => Promise<void>;
60
61
  suspend: () => Promise<void>;
61
- getIsResumingAudioContext: () => Promise<void> | null;
62
+ getIsResumingAudioContext: () => Promise<AudioContextResumeResult> | null;
62
63
  unscheduleAudioNode: (node: AudioBufferSourceNode) => void;
63
64
  };
64
65
  type SharedAudioTagsContextValue = {
@@ -105,6 +105,7 @@ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled,
105
105
  });
106
106
  const audioContextIsPlayingEventually = (0, react_1.useRef)(false);
107
107
  const isResuming = (0, react_1.useRef)(null);
108
+ const nextResumeAttemptId = (0, react_1.useRef)(0);
108
109
  const audioSyncAnchor = (0, react_1.useMemo)(() => ({ value: 0 }), []);
109
110
  const audioSyncAnchorListeners = (0, react_1.useRef)([]);
110
111
  const audioSyncAnchorEmitter = (0, react_1.useMemo)(() => {
@@ -203,24 +204,39 @@ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled,
203
204
  });
204
205
  nodesToResume.current.clear();
205
206
  const resumePromise = ctxAndGain.resume();
206
- isResuming.current = new Promise((resolve) => {
207
- (0, wait_until_actually_resumed_js_1.waitUntilActuallyResumed)(ctxAndGain.audioContext, logLevel).then(resolve);
207
+ const abortController = new AbortController();
208
+ const resumeAttemptId = nextResumeAttemptId.current++;
209
+ const waitPromise = new Promise((resolve) => {
210
+ (0, wait_until_actually_resumed_js_1.waitUntilActuallyResumed)(ctxAndGain.audioContext, logLevel, abortController.signal).then(resolve);
208
211
  resumePromise.catch((err) => {
209
- log_js_1.Log.warn({ logLevel, tag: 'audio' }, 'AudioContext resume rejected, continuing without audio sync', err);
210
- resolve();
212
+ log_js_1.Log.warn({ logLevel, tag: 'audio' }, 'AudioContext resume rejected, muting playback and continuing without audio', err);
213
+ abortController.abort();
214
+ resolve('failed');
211
215
  });
212
216
  }).finally(() => {
213
- isResuming.current = null;
217
+ var _a;
218
+ if (((_a = isResuming.current) === null || _a === void 0 ? void 0 : _a.id) === resumeAttemptId) {
219
+ isResuming.current = null;
220
+ }
214
221
  });
222
+ isResuming.current = {
223
+ abortController,
224
+ id: resumeAttemptId,
225
+ promise: waitPromise,
226
+ };
215
227
  return resumePromise.catch(() => {
216
228
  // Already logged above; swallow to avoid unhandled rejection
217
229
  // since callers (e.g. use-playback.ts) do not await this.
218
230
  });
219
231
  }, [ctxAndGain, logLevel]);
220
232
  const getIsResumingAudioContext = (0, react_1.useCallback)(() => {
221
- return isResuming.current;
233
+ var _a;
234
+ var _b;
235
+ return (_b = (_a = isResuming.current) === null || _a === void 0 ? void 0 : _a.promise) !== null && _b !== void 0 ? _b : null;
222
236
  }, []);
223
237
  const suspend = (0, react_1.useCallback)(() => {
238
+ var _a;
239
+ (_a = isResuming.current) === null || _a === void 0 ? void 0 : _a.abortController.abort();
224
240
  if (!ctxAndGain) {
225
241
  return Promise.resolve();
226
242
  }
@@ -1 +1,2 @@
1
- export declare const waitUntilActuallyResumed: (audioContext: AudioContext, logLevel: "error" | "info" | "trace" | "verbose" | "warn") => Promise<void>;
1
+ export type AudioContextResumeResult = 'resumed' | 'cancelled' | 'failed';
2
+ export declare const waitUntilActuallyResumed: (audioContext: AudioContext, logLevel: "error" | "info" | "trace" | "verbose" | "warn", signal: AbortSignal) => Promise<AudioContextResumeResult>;
@@ -2,15 +2,36 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.waitUntilActuallyResumed = void 0;
4
4
  const log_js_1 = require("../log.js");
5
- const waitUntilActuallyResumed = (audioContext, logLevel) => {
5
+ const RESUME_WAIT_TIMEOUT = 1000;
6
+ const waitUntilActuallyResumed = (audioContext, logLevel, signal) => {
6
7
  return new Promise((resolve) => {
7
8
  const startCurrentTime = audioContext.currentTime;
8
9
  const start = audioContext.getOutputTimestamp();
9
10
  const startOutputPerformanceTime = start.performanceTime;
10
11
  const startWallClock = performance.now();
12
+ let animationFrame = null;
13
+ let timeout = null;
14
+ let settled = false;
15
+ let onAbort = () => undefined;
16
+ const finish = (result) => {
17
+ if (settled) {
18
+ return;
19
+ }
20
+ settled = true;
21
+ if (animationFrame !== null) {
22
+ cancelAnimationFrame(animationFrame);
23
+ }
24
+ if (timeout !== null) {
25
+ clearTimeout(timeout);
26
+ }
27
+ signal.removeEventListener('abort', onAbort);
28
+ resolve(result);
29
+ };
30
+ onAbort = () => finish('cancelled');
11
31
  const check = () => {
12
32
  var _a;
13
33
  var _b;
34
+ animationFrame = null;
14
35
  const { currentTime } = audioContext;
15
36
  const outputTimestamp = audioContext.getOutputTimestamp();
16
37
  const elapsedWallClock = performance.now() - startWallClock;
@@ -20,12 +41,21 @@ const waitUntilActuallyResumed = (audioContext, logLevel) => {
20
41
  outputTimestamp.contextTime !== undefined &&
21
42
  outputTimestamp.contextTime > startCurrentTime) {
22
43
  log_js_1.Log.verbose({ logLevel, tag: 'audio' }, `waitUntilActuallyResumed: getOutputTimestamp.performanceTime advanced from ${startOutputPerformanceTime.toFixed(6)} to ${outputTimestamp.performanceTime.toFixed(6)} after ${elapsedWallClock.toFixed(1)}ms. currentTime=${currentTime.toFixed(6)} (advanced by ${(currentTime - startCurrentTime).toFixed(6)}), getOutputTimestamp.performanceTime=${(_b = (_a = outputTimestamp.performanceTime) === null || _a === void 0 ? void 0 : _a.toFixed(1)) !== null && _b !== void 0 ? _b : 'undefined'}`);
23
- resolve();
44
+ finish('resumed');
24
45
  return;
25
46
  }
26
- requestAnimationFrame(check);
47
+ animationFrame = requestAnimationFrame(check);
27
48
  };
28
- requestAnimationFrame(check);
49
+ if (signal.aborted) {
50
+ finish('cancelled');
51
+ return;
52
+ }
53
+ signal.addEventListener('abort', onAbort, { once: true });
54
+ timeout = setTimeout(() => {
55
+ log_js_1.Log.warn({ logLevel, tag: 'audio' }, 'WARNING: You enabled autoPlay on an unmuted <Player /> and the browser did not allow the video to be started. Remotion muted the <Player /> so it can play. To properly handle this, either set the `muted` prop or remove the `autoPlay` prop');
56
+ finish('failed');
57
+ }, RESUME_WAIT_TIMEOUT);
58
+ animationFrame = requestAnimationFrame(check);
29
59
  });
30
60
  };
31
61
  exports.waitUntilActuallyResumed = waitUntilActuallyResumed;
@@ -41,8 +41,14 @@ const playback_logging_1 = require("./playback-logging");
41
41
  const use_remotion_environment_1 = require("./use-remotion-environment");
42
42
  const useBufferManager = (logLevel, mountTime) => {
43
43
  const [blocks, setBlocks] = (0, react_1.useState)([]);
44
- const [onBufferingCallbacks, setOnBufferingCallbacks] = (0, react_1.useState)([]);
45
- const [onResumeCallbacks, setOnResumeCallbacks] = (0, react_1.useState)([]);
44
+ // Listener registries are refs, not state: `usePlayback` parks its loop
45
+ // during buffering and registers its resume listener from a rAF callback.
46
+ // With state, that registration only lands after the next React commit -
47
+ // if the last block unblocks before then, the resume dispatch reads the
48
+ // previous array, the listener is never called, and the playback loop
49
+ // stays parked forever (frame clock frozen while isPlaying() is true).
50
+ const onBufferingCallbacks = (0, react_1.useRef)([]);
51
+ const onResumeCallbacks = (0, react_1.useRef)([]);
46
52
  const env = (0, use_remotion_environment_1.useRemotionEnvironment)();
47
53
  const rendering = env.isRendering;
48
54
  const buffering = (0, react_1.useRef)(false);
@@ -71,18 +77,21 @@ const useBufferManager = (logLevel, mountTime) => {
71
77
  };
72
78
  }, [rendering]);
73
79
  const listenForBuffering = (0, react_1.useCallback)((callback) => {
74
- setOnBufferingCallbacks((c) => [...c, callback]);
80
+ onBufferingCallbacks.current = [
81
+ ...onBufferingCallbacks.current,
82
+ callback,
83
+ ];
75
84
  return {
76
85
  remove: () => {
77
- setOnBufferingCallbacks((c) => c.filter((cb) => cb !== callback));
86
+ onBufferingCallbacks.current = onBufferingCallbacks.current.filter((cb) => cb !== callback);
78
87
  },
79
88
  };
80
89
  }, []);
81
90
  const listenForResume = (0, react_1.useCallback)((callback) => {
82
- setOnResumeCallbacks((c) => [...c, callback]);
91
+ onResumeCallbacks.current = [...onResumeCallbacks.current, callback];
83
92
  return {
84
93
  remove: () => {
85
- setOnResumeCallbacks((c) => c.filter((cb) => cb !== callback));
94
+ onResumeCallbacks.current = onResumeCallbacks.current.filter((cb) => cb !== callback);
86
95
  },
87
96
  };
88
97
  }, []);
@@ -95,7 +104,7 @@ const useBufferManager = (logLevel, mountTime) => {
95
104
  // not re-dispatch `waiting` to listeners.
96
105
  if (blocks.length > 0 && !buffering.current) {
97
106
  buffering.current = true;
98
- onBufferingCallbacks.forEach((c) => c());
107
+ [...onBufferingCallbacks.current].forEach((c) => c());
99
108
  (0, playback_logging_1.playbackLogging)({
100
109
  logLevel,
101
110
  message: 'Player is entering buffer state',
@@ -119,7 +128,7 @@ const useBufferManager = (logLevel, mountTime) => {
119
128
  // dispatch `resume` to listeners.
120
129
  if (blocks.length === 0 && buffering.current) {
121
130
  buffering.current = false;
122
- onResumeCallbacks.forEach((c) => c());
131
+ [...onResumeCallbacks.current].forEach((c) => c());
123
132
  (0, playback_logging_1.playbackLogging)({
124
133
  logLevel,
125
134
  message: 'Player is exiting buffer state',
@@ -1,7 +1,7 @@
1
1
  import './_check-rsc.js';
2
2
  import './asset-types.js';
3
3
  import type { Codec } from './codec.js';
4
- import type { AnyCompMetadata, AnyComposition, AudioOrVideoAsset, JsxComponentIdentity, LoopDisplay, SequenceControls, TRenderAsset } from './CompositionManager.js';
4
+ import type { AnyCompMetadata, AnyComposition, AudioOrVideoAsset, JsxComponentIdentity, LoopDisplay, SequenceControls, SequenceRegistrationControls, TRenderAsset } from './CompositionManager.js';
5
5
  import type { DelayRenderScope } from './delay-render.js';
6
6
  import { type TFolder } from './Folder.js';
7
7
  import type { StaticFile } from './get-static-files.js';
@@ -9,6 +9,7 @@ import type { AssetFieldSchema, ArrayFieldSchema, ArrayItemFieldSchema, Captions
9
9
  import type { LogLevel } from './log.js';
10
10
  import type { ProResProfile } from './prores-profile.js';
11
11
  import type { PixelFormat, VideoImageFormat } from './render-types.js';
12
+ import type { RuntimeValueSnapshot, RuntimeValueStore } from './runtime-value-store.js';
12
13
  import type { UseBufferState } from './use-buffer-state';
13
14
  import type { VideoConfig } from './video-config.js';
14
15
  export type VideoConfigWithSerializedProps = Omit<VideoConfig, 'defaultProps' | 'props'> & {
@@ -183,4 +184,4 @@ export type _InternalTypes = {
183
184
  TRenderAsset: TRenderAsset;
184
185
  ProResProfile: ProResProfile;
185
186
  };
186
- export type { AnyComposition, AssetFieldSchema, ArrayFieldSchema, ArrayItemFieldSchema, CaptionsFieldSchema, DelayRenderScope, JsxComponentIdentity, LoopDisplay, SequenceControls, InteractivitySchemaField, InteractivitySchema, UseBufferState, };
187
+ export type { AnyComposition, AssetFieldSchema, ArrayFieldSchema, ArrayItemFieldSchema, CaptionsFieldSchema, DelayRenderScope, JsxComponentIdentity, LoopDisplay, RuntimeValueSnapshot, RuntimeValueStore, SequenceControls, SequenceRegistrationControls, InteractivitySchemaField, InteractivitySchema, UseBufferState, };
@@ -386,6 +386,11 @@ export declare const backgroundSchema: {
386
386
  };
387
387
  };
388
388
  export declare const svgStrokeSchema: {
389
+ readonly color: {
390
+ readonly type: "color";
391
+ readonly default: undefined;
392
+ readonly description: "Current color";
393
+ };
389
394
  readonly stroke: {
390
395
  readonly type: "color";
391
396
  readonly default: "none";
@@ -401,6 +406,11 @@ export declare const svgStrokeSchema: {
401
406
  };
402
407
  };
403
408
  export declare const svgPaintSchema: {
409
+ readonly color: {
410
+ readonly type: "color";
411
+ readonly default: undefined;
412
+ readonly description: "Current color";
413
+ };
404
414
  readonly stroke: {
405
415
  readonly type: "color";
406
416
  readonly default: "none";
@@ -208,7 +208,15 @@ exports.backgroundSchema = {
208
208
  description: 'Color',
209
209
  },
210
210
  };
211
+ const svgColorSchema = {
212
+ color: {
213
+ type: 'color',
214
+ default: undefined,
215
+ description: 'Current color',
216
+ },
217
+ };
211
218
  exports.svgStrokeSchema = {
219
+ ...svgColorSchema,
212
220
  stroke: {
213
221
  type: 'color',
214
222
  // `none` is the SVG initial value of stroke.
@@ -16,7 +16,7 @@ import type { ResolvedStackLocation } from './sequence-stack-traces.js';
16
16
  import type { CannotUpdateSequenceReason } from './SequenceManager.js';
17
17
  import { type CanUpdateEffectPropsResponse, type CanUpdateEffectPropsResponseFalse, type CanUpdateEffectPropsResponseTrue, type CanUpdateSequencePropsResponse, type CanUpdateSequencePropsResponseFalse, type CanUpdateSequencePropsResponseTrue, type SequenceNodePath, type SequencePropsSubscriptionKey, type VideoConfigValues } from './SequenceManager.js';
18
18
  import * as TimelinePosition from './timeline-position-state.js';
19
- import { type PlaybackRateContextValue, type SetTimelineContextValue, type TimelineContextValue } from './TimelineContext.js';
19
+ import { type PlaybackRateContextValue, type SetTimelineContextValue, type TimelineImperativeContextValue, type TimelineContextValue } from './TimelineContext.js';
20
20
  import { truthy } from './truthy.js';
21
21
  import type { CanUpdateSequencePropStatusFalse, CanUpdateSequencePropStatusEasing, CanUpdateSequencePropStatusKeyframed, CanUpdateSequencePropStatusStatic, DragOverrideValue, GetDragOverrides, GetEffectDragOverrides, GetEffectPropStatuses, GetPropStatuses, VideoConfigNumericExpression } from './use-schema.js';
22
22
  import { type CanUpdateSequencePropStatus, type DragOverrides, type EffectDragOverrides, type PropStatuses } from './use-schema.js';
@@ -26,6 +26,8 @@ import { useRemotionContexts } from './wrap-remotion-context.js';
26
26
  export type { EffectChainState } from './effects/run-effect-chain.js';
27
27
  export declare const Internals: {
28
28
  readonly MaxMediaCacheSizeContext: import("react").Context<number | null>;
29
+ readonly makeRenderResourceManager: () => import("./render-resource-manager.js").RenderResourceManager;
30
+ readonly RenderResourceManagerContext: import("react").Context<import("./render-resource-manager.js").RenderResourceManager | null>;
29
31
  readonly useUnsafeVideoConfig: () => import("./video-config.js").VideoConfig | null;
30
32
  readonly useFrameForVolumeProp: (behavior: import("./index.js").LoopVolumeCurveBehavior) => number;
31
33
  readonly useTimelinePosition: () => number;
@@ -812,7 +814,7 @@ export declare const Internals: {
812
814
  scheduleAudioNode: (options: ScheduleAudioNodeOptions) => ScheduleAudioNodeResult;
813
815
  resume: () => Promise<void>;
814
816
  suspend: () => Promise<void>;
815
- getIsResumingAudioContext: () => Promise<void> | null;
817
+ getIsResumingAudioContext: () => Promise<import("./audio/wait-until-actually-resumed.js").AudioContextResumeResult> | null;
816
818
  unscheduleAudioNode: (node: AudioBufferSourceNode) => void;
817
819
  } | null>;
818
820
  readonly SharedAudioContextProvider: import("react").FC<{
@@ -873,6 +875,7 @@ export declare const Internals: {
873
875
  getCompositions: () => import("./CompositionManager.js").AnyComposition[];
874
876
  } | null>;
875
877
  readonly portalNode: () => HTMLElement;
878
+ readonly setPortalNodeCurrentScale: (scale: number) => void;
876
879
  readonly waitForRoot: (fn: (comp: import("react").FC<{}>) => void) => () => void;
877
880
  readonly SetTimelineContext: import("react").Context<SetTimelineContextValue>;
878
881
  readonly CanUseRemotionHooksProvider: import("react").FC<{
@@ -1166,6 +1169,7 @@ export declare const Internals: {
1166
1169
  readonly TimelinePosition: typeof TimelinePosition;
1167
1170
  readonly DelayRenderContextType: import("react").Context<import("./delay-render.js").DelayRenderScope | null>;
1168
1171
  readonly TimelineContext: import("react").Context<TimelineContextValue | null>;
1172
+ readonly TimelineImperativeContext: import("react").Context<TimelineImperativeContextValue | null>;
1169
1173
  readonly PlaybackRateContext: import("react").Context<PlaybackRateContextValue | null>;
1170
1174
  readonly AbsoluteTimeContext: import("react").Context<TimelineContextValue | null>;
1171
1175
  readonly RenderAssetManagerProvider: import("react").FC<{
@@ -1269,4 +1273,4 @@ export declare const Internals: {
1269
1273
  readonly componentName: string;
1270
1274
  }) => import("react").CSSProperties | null;
1271
1275
  };
1272
- export type { ArrayFieldSchema, AssetFieldSchema, ArrayItemFieldSchema, CannotUpdateSequenceReason, CanUpdateEffectPropsResponse, CanUpdateEffectPropsResponseFalse, CanUpdateEffectPropsResponseTrue, CanUpdateSequencePropsResponse, CanUpdateSequencePropsResponseFalse, CanUpdateSequencePropsResponseTrue, CanUpdateSequencePropStatus, CanUpdateSequencePropStatusEasing, CanUpdateSequencePropStatusFalse, CanUpdateSequencePropStatusKeyframed, CanUpdateSequencePropStatusStatic, VideoConfigNumericExpression, CompositionManagerContext, CompProps, DragOverrides, DragOverrideValue, EffectDragOverrides, GetDragOverrides, GetEffectDragOverrides, GetEffectPropStatuses, GetPropStatuses, JsxComponentIdentity, LoggingContextValue, MediaVolumeContextValue, NonceHistory, OverrideIdsToNodePathsGettersContext, OverrideIdsToNodePathsSettersContext, OverrideIdToNodePaths, OverrideToNodePathGetters, OverrideToNodeSetters, PlaybackRateContextValue, PropStatuses, RemotionAudioContextState, RemotionEnvironment, ResolvedStackLocation, ScheduleAudioNodeOptions, ScheduleAudioNodeResult, InteractivitySchemaField, SequenceNodePath, SequencePropsSubscriptionKey, VideoConfigValues, InteractivitySchema, SerializedJSONWithCustomFields, SetMediaVolumeContextValue, SetTimelineContextValue, TCompMetadata, TComposition, TimelineContextValue, TRenderAsset, TSequence, VisibleFieldSchema, WatchRemotionStaticFilesPayload, };
1276
+ export type { ArrayFieldSchema, AssetFieldSchema, ArrayItemFieldSchema, CannotUpdateSequenceReason, CanUpdateEffectPropsResponse, CanUpdateEffectPropsResponseFalse, CanUpdateEffectPropsResponseTrue, CanUpdateSequencePropsResponse, CanUpdateSequencePropsResponseFalse, CanUpdateSequencePropsResponseTrue, CanUpdateSequencePropStatus, CanUpdateSequencePropStatusEasing, CanUpdateSequencePropStatusFalse, CanUpdateSequencePropStatusKeyframed, CanUpdateSequencePropStatusStatic, VideoConfigNumericExpression, CompositionManagerContext, CompProps, DragOverrides, DragOverrideValue, EffectDragOverrides, GetDragOverrides, GetEffectDragOverrides, GetEffectPropStatuses, GetPropStatuses, JsxComponentIdentity, LoggingContextValue, MediaVolumeContextValue, NonceHistory, OverrideIdsToNodePathsGettersContext, OverrideIdsToNodePathsSettersContext, OverrideIdToNodePaths, OverrideToNodePathGetters, OverrideToNodeSetters, PlaybackRateContextValue, PropStatuses, RemotionAudioContextState, RemotionEnvironment, ResolvedStackLocation, ScheduleAudioNodeOptions, ScheduleAudioNodeResult, InteractivitySchemaField, SequenceNodePath, SequencePropsSubscriptionKey, VideoConfigValues, InteractivitySchema, SerializedJSONWithCustomFields, SetMediaVolumeContextValue, SetTimelineContextValue, TCompMetadata, TComposition, TimelineContextValue, TimelineImperativeContextValue, TRenderAsset, TSequence, VisibleFieldSchema, WatchRemotionStaticFilesPayload, };
@@ -78,6 +78,7 @@ const PremountContext_js_1 = require("./PremountContext.js");
78
78
  const register_root_js_1 = require("./register-root.js");
79
79
  const remotion_environment_context_js_1 = require("./remotion-environment-context.js");
80
80
  const RemotionRoot_js_1 = require("./RemotionRoot.js");
81
+ const render_resource_manager_js_1 = require("./render-resource-manager.js");
81
82
  const RenderAssetManager_js_1 = require("./RenderAssetManager.js");
82
83
  const resolve_video_config_js_1 = require("./resolve-video-config.js");
83
84
  const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
@@ -123,6 +124,8 @@ const compositionSelectorRef = (0, react_1.createRef)();
123
124
  // API and are less likely to use it
124
125
  exports.Internals = {
125
126
  MaxMediaCacheSizeContext: max_video_cache_size_js_1.MaxMediaCacheSizeContext,
127
+ makeRenderResourceManager: render_resource_manager_js_1.makeRenderResourceManager,
128
+ RenderResourceManagerContext: render_resource_manager_js_1.RenderResourceManagerContext,
126
129
  useUnsafeVideoConfig: use_unsafe_video_config_js_1.useUnsafeVideoConfig,
127
130
  useFrameForVolumeProp: use_audio_frame_js_1.useFrameForVolumeProp,
128
131
  useTimelinePosition: TimelinePosition.useTimelinePosition,
@@ -188,6 +191,7 @@ exports.Internals = {
188
191
  getPreviewDomElement: get_preview_dom_element_js_1.getPreviewDomElement,
189
192
  compositionsRef: CompositionManager_js_1.compositionsRef,
190
193
  portalNode: portal_node_js_1.portalNode,
194
+ setPortalNodeCurrentScale: portal_node_js_1.setPortalNodeCurrentScale,
191
195
  waitForRoot: register_root_js_1.waitForRoot,
192
196
  SetTimelineContext: TimelineContext_js_1.SetTimelineContext,
193
197
  CanUseRemotionHooksProvider: CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider,
@@ -248,6 +252,7 @@ exports.Internals = {
248
252
  TimelinePosition,
249
253
  DelayRenderContextType: use_delay_render_js_1.DelayRenderContextType,
250
254
  TimelineContext: TimelineContext_js_1.TimelineContext,
255
+ TimelineImperativeContext: TimelineContext_js_1.TimelineImperativeContext,
251
256
  PlaybackRateContext: TimelineContext_js_1.PlaybackRateContext,
252
257
  AbsoluteTimeContext: TimelineContext_js_1.AbsoluteTimeContext,
253
258
  RenderAssetManagerProvider: RenderAssetManager_js_1.RenderAssetManagerProvider,
@@ -10,6 +10,8 @@ const easingToFn = ({ easing, forceSpringAllowTail, }) => {
10
10
  switch (easing.type) {
11
11
  case 'linear':
12
12
  return easing_js_1.Easing.linear;
13
+ case 'step1':
14
+ return easing_js_1.Easing.step1;
13
15
  case 'spring':
14
16
  return easing_js_1.Easing.spring({
15
17
  allowTail: (_a = forceSpringAllowTail !== null && forceSpringAllowTail !== void 0 ? forceSpringAllowTail : easing.allowTail) !== null && _a !== void 0 ? _a : undefined,
@@ -1 +1,4 @@
1
+ export declare const getPortalNodeCurrentScale: () => number;
2
+ export declare const subscribeToPortalNodeCurrentScale: (listener: () => void) => () => void;
3
+ export declare const setPortalNodeCurrentScale: (scale: number) => void;
1
4
  export declare const portalNode: () => HTMLElement;