remotion 4.0.533 → 4.0.535

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 (107) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/AbsoluteFill.d.ts +1 -6
  3. package/dist/cjs/AbsoluteFill.js +1 -1
  4. package/dist/cjs/Composition.js +15 -20
  5. package/dist/cjs/CompositionManager.d.ts +4 -4
  6. package/dist/cjs/CompositionManagerContext.d.ts +1 -6
  7. package/dist/cjs/CompositionManagerContext.js +0 -4
  8. package/dist/cjs/CompositionManagerProvider.js +77 -172
  9. package/dist/cjs/CompositionRegistryProvider.d.ts +5 -0
  10. package/dist/cjs/CompositionRegistryProvider.js +142 -0
  11. package/dist/cjs/DefaultPremountContext.d.ts +1 -0
  12. package/dist/cjs/DefaultPremountContext.js +6 -0
  13. package/dist/cjs/Folder.js +11 -20
  14. package/dist/cjs/HtmlInCanvas.d.ts +2 -2
  15. package/dist/cjs/HtmlInCanvas.js +179 -31
  16. package/dist/cjs/IFrame.js +40 -8
  17. package/dist/cjs/Img.js +2 -1
  18. package/dist/cjs/Interactive.d.ts +12 -0
  19. package/dist/cjs/Interactive.js +19 -8
  20. package/dist/cjs/RemotionRoot.js +2 -1
  21. package/dist/cjs/Sequence.d.ts +6 -2
  22. package/dist/cjs/Sequence.js +107 -40
  23. package/dist/cjs/SequenceActivityBoundary.d.ts +10 -0
  24. package/dist/cjs/SequenceActivityBoundary.js +88 -0
  25. package/dist/cjs/SequenceActivityBudget.d.ts +13 -0
  26. package/dist/cjs/SequenceActivityBudget.js +181 -0
  27. package/dist/cjs/SequenceManager.d.ts +13 -29
  28. package/dist/cjs/SequenceManager.js +36 -176
  29. package/dist/cjs/SequenceRegistryProvider.d.ts +4 -0
  30. package/dist/cjs/SequenceRegistryProvider.js +292 -0
  31. package/dist/cjs/Track.d.ts +13 -0
  32. package/dist/cjs/Track.js +33 -0
  33. package/dist/cjs/animated-image/AnimatedImage.js +42 -30
  34. package/dist/cjs/audio/AudioForPreview.js +54 -41
  35. package/dist/cjs/audio/get-audio-sync-anchor-tolerance.d.ts +1 -0
  36. package/dist/cjs/audio/get-audio-sync-anchor-tolerance.js +11 -0
  37. package/dist/cjs/audio/use-audio-context.js +26 -7
  38. package/dist/cjs/canvas-image/CanvasImage.js +4 -2
  39. package/dist/cjs/committed-metadata.d.ts +68 -0
  40. package/dist/cjs/committed-metadata.js +39 -0
  41. package/dist/cjs/component-identity.d.ts +6 -0
  42. package/dist/cjs/component-identity.js +39 -0
  43. package/dist/cjs/composition-registry-fallback.d.ts +14 -0
  44. package/dist/cjs/composition-registry-fallback.js +35 -0
  45. package/dist/cjs/create-element-source-proxy.d.ts +4 -0
  46. package/dist/cjs/create-element-source-proxy.js +46 -0
  47. package/dist/cjs/default-premount-in-seconds.d.ts +3 -0
  48. package/dist/cjs/default-premount-in-seconds.js +12 -0
  49. package/dist/cjs/effects/Solid.js +5 -3
  50. package/dist/cjs/effects/canvas-pool.d.ts +1 -0
  51. package/dist/cjs/effects/canvas-pool.js +15 -10
  52. package/dist/cjs/effects/run-effect-chain.js +3 -3
  53. package/dist/cjs/effects/use-memoized-effects.d.ts +3 -1
  54. package/dist/cjs/effects/use-memoized-effects.js +104 -21
  55. package/dist/cjs/enable-sequence-stack-traces.d.ts +2 -8
  56. package/dist/cjs/enable-sequence-stack-traces.js +7 -38
  57. package/dist/cjs/evaluate-source-expressions.d.ts +5 -0
  58. package/dist/cjs/evaluate-source-expressions.js +98 -0
  59. package/dist/cjs/freeze.js +9 -8
  60. package/dist/cjs/index.d.ts +2 -2
  61. package/dist/cjs/index.js +3 -3
  62. package/dist/cjs/interactivity-schema.d.ts +45 -9
  63. package/dist/cjs/interactivity-schema.js +30 -3
  64. package/dist/cjs/internals.d.ts +113 -27
  65. package/dist/cjs/internals.js +37 -7
  66. package/dist/cjs/interpolate-keyframed-status.d.ts +4 -0
  67. package/dist/cjs/interpolate-keyframed-status.js +38 -1
  68. package/dist/cjs/interpolate.d.ts +12 -0
  69. package/dist/cjs/interpolate.js +7 -0
  70. package/dist/cjs/no-react.d.ts +6 -0
  71. package/dist/cjs/no-react.js +9 -0
  72. package/dist/cjs/optimistic-sequence-deletion.d.ts +17 -0
  73. package/dist/cjs/optimistic-sequence-deletion.js +114 -0
  74. package/dist/cjs/registry-store.d.ts +17 -0
  75. package/dist/cjs/registry-store.js +68 -0
  76. package/dist/cjs/sequence-activity-context.d.ts +13 -0
  77. package/dist/cjs/sequence-activity-context.js +20 -0
  78. package/dist/cjs/sequence-activity-defaults.d.ts +1 -0
  79. package/dist/cjs/sequence-activity-defaults.js +4 -0
  80. package/dist/cjs/sequence-outline.js +1 -2
  81. package/dist/cjs/sequence-registry-context.d.ts +26 -0
  82. package/dist/cjs/sequence-registry-context.js +71 -0
  83. package/dist/cjs/series/index.d.ts +2 -1
  84. package/dist/cjs/series/index.js +15 -5
  85. package/dist/cjs/timeline-position-state.js +11 -3
  86. package/dist/cjs/timeline-track-context.d.ts +10 -0
  87. package/dist/cjs/timeline-track-context.js +6 -0
  88. package/dist/cjs/use-lazy-component.js +29 -15
  89. package/dist/cjs/use-media-in-timeline.d.ts +7 -14
  90. package/dist/cjs/use-media-in-timeline.js +29 -119
  91. package/dist/cjs/use-premounting.js +3 -4
  92. package/dist/cjs/use-schema.d.ts +32 -18
  93. package/dist/cjs/use-sequence-registration.d.ts +1 -1
  94. package/dist/cjs/use-sequence-registration.js +22 -6
  95. package/dist/cjs/use-video.d.ts +7 -2
  96. package/dist/cjs/use-video.js +11 -3
  97. package/dist/cjs/version.d.ts +1 -1
  98. package/dist/cjs/version.js +1 -1
  99. package/dist/cjs/video/VideoForPreview.js +55 -42
  100. package/dist/cjs/video/html5-video.js +1 -1
  101. package/dist/cjs/with-interactivity-schema.js +48 -16
  102. package/dist/cjs/wrap-remotion-context.d.ts +17 -2
  103. package/dist/cjs/wrap-remotion-context.js +108 -4
  104. package/dist/esm/index.mjs +3526 -2259
  105. package/dist/esm/no-react.mjs +149 -35
  106. package/dist/esm/version.mjs +1 -1
  107. package/package.json +2 -2
@@ -11,11 +11,12 @@ const prefetch_state_js_1 = require("./prefetch-state.js");
11
11
  const SequenceManager_js_1 = require("./SequenceManager.js");
12
12
  const TimelineContext_js_1 = require("./TimelineContext.js");
13
13
  const use_media_enabled_js_1 = require("./use-media-enabled.js");
14
+ const use_video_js_1 = require("./use-video.js");
14
15
  const duration_state_js_1 = require("./video/duration-state.js");
15
16
  const RemotionRootContexts = ({ children, numberOfAudioTags, logLevel, audioLatencyHint, previewSampleRate, videoEnabled, audioEnabled, frameState, _experimentalKeepAudioContextAlive, }) => {
16
17
  const logging = (0, react_1.useMemo)(() => {
17
18
  return { logLevel, mountTime: Date.now() };
18
19
  }, [logLevel]);
19
- return (jsx_runtime_1.jsx(log_level_context_js_1.LogLevelContext.Provider, { value: logging, children: jsx_runtime_1.jsx(TimelineContext_js_1.TimelineContextProvider, { frameState: frameState, children: jsx_runtime_1.jsx(use_media_enabled_js_1.MediaEnabledProvider, { videoEnabled: videoEnabled, audioEnabled: audioEnabled, children: jsx_runtime_1.jsx(EditorProps_js_1.EditorPropsProvider, { children: jsx_runtime_1.jsx(prefetch_state_js_1.PrefetchProvider, { children: jsx_runtime_1.jsx(SequenceManager_js_1.SequenceManagerProvider, { children: jsx_runtime_1.jsx(duration_state_js_1.DurationsContextProvider, { children: jsx_runtime_1.jsx(buffering_js_1.BufferingProvider, { children: jsx_runtime_1.jsx(shared_audio_tags_js_1.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: audioEnabled, previewSampleRate: previewSampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, children: jsx_runtime_1.jsx(shared_audio_tags_js_1.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfAudioTags, children: children }) }) }) }) }) }) }) }) }) }));
20
+ return (jsx_runtime_1.jsx(log_level_context_js_1.LogLevelContext.Provider, { value: logging, children: jsx_runtime_1.jsx(TimelineContext_js_1.TimelineContextProvider, { frameState: frameState, children: jsx_runtime_1.jsx(use_media_enabled_js_1.MediaEnabledProvider, { videoEnabled: videoEnabled, audioEnabled: audioEnabled, children: jsx_runtime_1.jsx(EditorProps_js_1.EditorPropsProvider, { children: jsx_runtime_1.jsx(prefetch_state_js_1.PrefetchProvider, { children: jsx_runtime_1.jsx(SequenceManager_js_1.SequenceManagerProvider, { children: jsx_runtime_1.jsx(duration_state_js_1.DurationsContextProvider, { children: jsx_runtime_1.jsx(buffering_js_1.BufferingProvider, { children: jsx_runtime_1.jsx(shared_audio_tags_js_1.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: audioEnabled, previewSampleRate: previewSampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, children: jsx_runtime_1.jsx(shared_audio_tags_js_1.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfAudioTags, children: jsx_runtime_1.jsx(use_video_js_1.VideoProvider, { children: children }) }) }) }) }) }) }) }) }) }) }));
20
21
  };
21
22
  exports.RemotionRootContexts = RemotionRootContexts;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { LoopDisplay, SequenceControls } from './CompositionManager.js';
3
3
  import type { EffectDefinition } from './effects/effect-types.js';
4
+ import { type TimelineTrackItem } from './timeline-track-context.js';
4
5
  import type { BasicMediaInTimelineReturnType } from './use-media-in-timeline.js';
5
6
  export type AbsoluteFillLayout = {
6
7
  layout?: 'absolute-fill';
@@ -32,6 +33,10 @@ export type SequencePropsWithoutDuration = {
32
33
  readonly hidden?: boolean;
33
34
  readonly controls?: SequenceControls;
34
35
  readonly _remotionInternalEffects?: readonly EffectDefinition<unknown>[];
36
+ /**
37
+ * @deprecated For internal use only.
38
+ */
39
+ readonly _remotionInternalTimelineTrack?: Pick<TimelineTrackItem, 'role' | 'seriesOffset'>;
35
40
  /**
36
41
  * @deprecated For internal use only.
37
42
  */
@@ -75,8 +80,7 @@ export type SequencePropsWithoutDuration = {
75
80
  src: string;
76
81
  };
77
82
  /**
78
- * @deprecated Remotion Studio discovers rendered elements automatically.
79
- * Remove this prop.
83
+ * @deprecated This prop has no effect. Remotion Studio discovers selection outlines automatically.
80
84
  */
81
85
  readonly outlineRef?: React.RefObject<Element | null> | null;
82
86
  } & LayoutAndStyle;
@@ -2,36 +2,48 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SequenceWithoutFrom = exports.Sequence = exports.SequenceWithoutSchema = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- /* eslint-disable @typescript-eslint/no-use-before-define */
6
5
  const react_1 = require("react");
7
6
  const AbsoluteFillElement_js_1 = require("./AbsoluteFillElement.js");
7
+ const committed_metadata_js_1 = require("./committed-metadata.js");
8
+ const component_identity_js_1 = require("./component-identity.js");
9
+ const DefaultPremountContext_js_1 = require("./DefaultPremountContext.js");
8
10
  const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
9
11
  const freeze_js_1 = require("./freeze.js");
10
12
  const get_sequence_boundary_tolerance_js_1 = require("./get-sequence-boundary-tolerance.js");
11
13
  const interactivity_schema_js_1 = require("./interactivity-schema.js");
12
14
  const loop_context_js_1 = require("./loop/loop-context.js");
13
15
  const resolve_sequence_duration_js_1 = require("./resolve-sequence-duration.js");
16
+ const sequence_activity_context_js_1 = require("./sequence-activity-context.js");
14
17
  const sequence_crop_js_1 = require("./sequence-crop.js");
15
- const sequence_order_marker_js_1 = require("./sequence-order-marker.js");
16
18
  const sequence_outline_js_1 = require("./sequence-outline.js");
19
+ const SequenceActivityBoundary_js_1 = require("./SequenceActivityBoundary.js");
20
+ const SequenceActivityBudget_js_1 = require("./SequenceActivityBudget.js");
17
21
  const SequenceContext_js_1 = require("./SequenceContext.js");
18
22
  const SequenceManager_js_1 = require("./SequenceManager.js");
19
23
  const is_inside_series_js_1 = require("./series/is-inside-series.js");
20
24
  const timeline_position_state_js_1 = require("./timeline-position-state.js");
25
+ const timeline_track_context_js_1 = require("./timeline-track-context.js");
21
26
  const use_premounting_js_1 = require("./use-premounting.js");
22
27
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
23
28
  const use_sequence_registration_js_1 = require("./use-sequence-registration.js");
24
29
  const use_video_config_js_1 = require("./use-video-config.js");
25
- const v5_flag_js_1 = require("./v5-flag.js");
26
30
  const with_interactivity_schema_js_1 = require("./with-interactivity-schema.js");
27
31
  const SeriesContentVisibilityContext = (0, react_1.createContext)(true);
32
+ const SequenceContextProvider = (0, committed_metadata_js_1.withCommittedMetadata)(SequenceContext_js_1.SequenceContext.Provider);
28
33
  const EMPTY_EFFECTS = [];
29
- const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playbackRate = 1, loop = false, freeze, durationInFrames, children, name, height, width, showInTimeline = true, hidden = false, controls, _remotionInternalEffects, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalDocumentationLink: documentationLink, _remotionInternalSingleChildComponent: singleChildComponent, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, _remotionInternalIsMedia: isMedia, outlineRef: passedRefForOutline, cropLeft, cropRight, cropTop, cropBottom, ...other }, ref) => {
30
- var _a, _b, _c, _d, _e;
34
+ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playbackRate = 1, loop = false, freeze, durationInFrames, children, name, height, width, showInTimeline = true, hidden = false, controls, _remotionInternalEffects, _remotionInternalTimelineTrack: timelineTrackItem, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalSingleChildComponent: childComponentOverride, _remotionInternalDocumentationLink: documentationLink, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, _remotionInternalIsMedia: isMedia, cropLeft, cropRight, cropTop, cropBottom, ...other }, ref) => {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h;
31
36
  const { layout = 'absolute-fill' } = other;
32
37
  const [id] = (0, react_1.useState)(() => String(Math.random()));
33
38
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
34
- const parentPlaybackRate = (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.playbackRate) !== null && _a !== void 0 ? _a : 1;
39
+ const activityRequested = (0, react_1.useContext)(sequence_activity_context_js_1.SequenceActivityContext);
40
+ const parentDormant = (0, react_1.useContext)(sequence_activity_context_js_1.SequenceActivityDormantContext);
41
+ const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
42
+ const activityEnabled = activityRequested && env.isStudio && !env.isRendering;
43
+ const timelineTrack = (0, react_1.useContext)(timeline_track_context_js_1.TimelineTrackContext);
44
+ const timelineTrackRole = (_a = timelineTrackItem === null || timelineTrackItem === void 0 ? void 0 : timelineTrackItem.role) !== null && _a !== void 0 ? _a : 'clip';
45
+ const seriesOffset = (_b = timelineTrackItem === null || timelineTrackItem === void 0 ? void 0 : timelineTrackItem.seriesOffset) !== null && _b !== void 0 ? _b : null;
46
+ const parentPlaybackRate = (_c = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.playbackRate) !== null && _c !== void 0 ? _c : 1;
35
47
  const cumulativePlaybackRate = parentPlaybackRate * playbackRate;
36
48
  const cumulatedFrom = parentSequence
37
49
  ? parentSequence.cumulatedFrom + parentSequence.relativeFrom
@@ -107,7 +119,9 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
107
119
  lastPlaybackRate.current.playbackRate !== playbackRate) {
108
120
  throw new Error('The "playbackRate" prop of <Sequence /> must be constant. Animating playbackRate is not supported.');
109
121
  }
110
- lastPlaybackRate.current = { playbackRate, frame: absoluteFrame };
122
+ (0, react_1.useLayoutEffect)(() => {
123
+ lastPlaybackRate.current = { playbackRate, frame: absoluteFrame };
124
+ }, [absoluteFrame, playbackRate]);
111
125
  const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
112
126
  const effectiveDurationInFrames = (0, resolve_sequence_duration_js_1.resolveSequenceDuration)({
113
127
  durationInFrames,
@@ -127,7 +141,11 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
127
141
  ? contentDurationInFrames / playbackRate
128
142
  : null;
129
143
  let loopIteration = 0;
130
- if (loopPeriod !== null) {
144
+ if (loopPeriod !== null &&
145
+ (!activityEnabled ||
146
+ (!parentDormant &&
147
+ frameInParent >= from &&
148
+ frameInParent < from + actualDurationInFrames))) {
131
149
  const loopsElapsed = (frameInParent - from) / loopPeriod;
132
150
  const nearestIteration = Math.round(loopsElapsed);
133
151
  // Fractional periods and nested playback rates can put an exact loop
@@ -141,7 +159,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
141
159
  const clockFrom = from + loopOffset;
142
160
  const effectiveRelativeFrom = clockFrom - trimBefore / playbackRate;
143
161
  const relativeFrom = effectiveRelativeFrom / parentPlaybackRate;
144
- const absoluteFrom = ((_b = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.absoluteFrom) !== null && _b !== void 0 ? _b : 0) + relativeFrom;
162
+ const absoluteFrom = ((_d = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.absoluteFrom) !== null && _d !== void 0 ? _d : 0) + relativeFrom;
145
163
  // Inside a loop, the local clock ends after `durationInFrames`, except in a final
146
164
  // iteration that the parent cuts short.
147
165
  const localClockEnd = loopPeriod === null
@@ -151,15 +169,12 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
151
169
  trimBefore;
152
170
  const sequenceRegistrationEnabled = (0, react_1.useContext)(SequenceManager_js_1.SequenceRegistrationContext);
153
171
  const canvasOutlinesEnabled = (0, react_1.useContext)(sequence_outline_js_1.SequenceOutlineContext);
154
- const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
155
172
  const shouldDiscoverOutline = env.isStudio || canvasOutlinesEnabled;
156
- const automaticOutlineRef = (0, react_1.useMemo)(() => shouldDiscoverOutline && layout === 'none' && !passedRefForOutline
173
+ const automaticOutlineRef = (0, react_1.useMemo)(() => shouldDiscoverOutline && layout === 'none'
157
174
  ? sequence_outline_js_1.SequenceOutlineInternals.createRef()
158
- : null, [shouldDiscoverOutline, layout, passedRefForOutline]);
175
+ : null, [shouldDiscoverOutline, layout]);
159
176
  const wrapperRefForOutline = (0, react_1.useRef)(null);
160
- const refForOutline = other.layout === 'none'
161
- ? (passedRefForOutline !== null && passedRefForOutline !== void 0 ? passedRefForOutline : automaticOutlineRef)
162
- : (passedRefForOutline !== null && passedRefForOutline !== void 0 ? passedRefForOutline : wrapperRefForOutline);
177
+ const refForOutline = layout === 'none' ? automaticOutlineRef : wrapperRefForOutline;
163
178
  const premounting = (0, react_1.useMemo)(() => {
164
179
  // || is intentional, ?? would not trigger on `false`
165
180
  return ((parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting) ||
@@ -251,15 +266,22 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
251
266
  }, [name]);
252
267
  const resolvedDocumentationLink = documentationLink !== null && documentationLink !== void 0 ? documentationLink : 'https://www.remotion.dev/docs/sequence';
253
268
  const isInsideSeries = (0, react_1.useContext)(is_inside_series_js_1.IsInsideSeriesContext);
254
- // Our assumption: Stack doesnt' change. After we symbolicate we assign it a nodePath
255
- // and if it changes, it would lead to-remounting of the sequence.
256
- const stackRef = (0, react_1.useRef)(null);
257
- stackRef.current = controls
258
- ? ((_d = (_c = (0, enable_sequence_stack_traces_js_1.getStackForControls)(controls)) !== null && _c !== void 0 ? _c : stack) !== null && _d !== void 0 ? _d : null)
269
+ const singleChildComponent = (0, react_1.useMemo)(() => childComponentOverride === undefined
270
+ ? (0, component_identity_js_1.getSingleChildComponent)(children)
271
+ : childComponentOverride, [children, childComponentOverride]);
272
+ const registrationStack = controls
273
+ ? ((_f = (_e = (0, enable_sequence_stack_traces_js_1.getStackForControls)(controls)) !== null && _e !== void 0 ? _e : stack) !== null && _f !== void 0 ? _f : null)
259
274
  : (stack !== null && stack !== void 0 ? stack : null);
275
+ const getStack = (0, react_1.useCallback)(() => registrationStack, [registrationStack]);
260
276
  const registeredFrozenFrame = typeof freeze === 'number' ? freeze : null;
277
+ const currentFrame = registeredFrozenFrame !== null && registeredFrozenFrame !== void 0 ? registeredFrozenFrame : (absoluteFrame - currentSequenceStart) * cumulativePlaybackRate;
278
+ const currentFrameRef = (0, react_1.useRef)(currentFrame);
279
+ (0, react_1.useLayoutEffect)(() => {
280
+ currentFrameRef.current = currentFrame;
281
+ }, [currentFrame]);
282
+ const getCurrentFrame = (0, react_1.useCallback)(() => currentFrameRef.current, []);
261
283
  const registeredTrimBefore = trimBefore === 0 ? null : trimBefore;
262
- const parentCumulatedNegativeFrom = (_e = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.cumulatedNegativeFrom) !== null && _e !== void 0 ? _e : 0;
284
+ const parentCumulatedNegativeFrom = (_g = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.cumulatedNegativeFrom) !== null && _g !== void 0 ? _g : 0;
263
285
  const startMediaFrom = isMedia && isMedia.type !== 'image'
264
286
  ? isMedia.data.startMediaFrom +
265
287
  parentCumulatedNegativeFrom -
@@ -335,9 +357,19 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
335
357
  ]);
336
358
  const getSequenceForRegistration = (0, react_1.useCallback)(() => {
337
359
  var _a, _b, _c;
360
+ const trackRegistration = timelineTrack
361
+ ? {
362
+ timelineTrack: {
363
+ ...timelineTrack,
364
+ role: timelineTrackRole,
365
+ seriesOffset,
366
+ },
367
+ }
368
+ : {};
338
369
  if (isMedia) {
339
370
  if (isMedia.type === 'image') {
340
371
  return {
372
+ ...trackRegistration,
341
373
  sequencePlaybackRate: playbackRate,
342
374
  type: 'image',
343
375
  controls: registrationControls,
@@ -356,7 +388,8 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
356
388
  showInTimeline,
357
389
  timelineOrder: null,
358
390
  src: isMedia.src,
359
- getStack: () => stackRef.current,
391
+ getStack,
392
+ getCurrentFrame,
360
393
  refForOutline: refForOutline !== null && refForOutline !== void 0 ? refForOutline : null,
361
394
  isInsideSeries,
362
395
  frozenFrame: registeredFrozenFrame,
@@ -364,6 +397,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
364
397
  };
365
398
  }
366
399
  return {
400
+ ...trackRegistration,
367
401
  type: isMedia.type,
368
402
  sequencePlaybackRate: playbackRate,
369
403
  controls: registrationControls,
@@ -371,7 +405,6 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
371
405
  effectRuntimeValues,
372
406
  displayName: timelineClipName,
373
407
  documentationLink: resolvedDocumentationLink,
374
- doesVolumeChange: isMedia.data.doesVolumeChange,
375
408
  duration: actualDurationInFrames,
376
409
  from,
377
410
  trimBefore: registeredTrimBefore,
@@ -384,10 +417,10 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
384
417
  showInTimeline,
385
418
  timelineOrder: null,
386
419
  src: isMedia.data.src,
387
- getStack: () => stackRef.current,
420
+ getStack,
421
+ getCurrentFrame,
388
422
  startMediaFrom: startMediaFrom !== null && startMediaFrom !== void 0 ? startMediaFrom : isMedia.data.startMediaFrom,
389
423
  mediaFrameAtSequenceZero,
390
- volume: isMedia.data.volumes,
391
424
  muted: isMedia.data.muted,
392
425
  refForOutline: refForOutline !== null && refForOutline !== void 0 ? refForOutline : null,
393
426
  isInsideSeries,
@@ -397,6 +430,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
397
430
  };
398
431
  }
399
432
  return {
433
+ ...trackRegistration,
400
434
  from,
401
435
  sequencePlaybackRate: playbackRate,
402
436
  trimBefore: registeredTrimBefore,
@@ -412,7 +446,8 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
412
446
  showInTimeline,
413
447
  timelineOrder: null,
414
448
  loopDisplay: resolvedLoopDisplay,
415
- getStack: () => stackRef.current,
449
+ getStack,
450
+ getCurrentFrame,
416
451
  premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
417
452
  postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
418
453
  controls: registrationControls,
@@ -425,6 +460,11 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
425
460
  };
426
461
  }, [
427
462
  id,
463
+ timelineTrack,
464
+ timelineTrackRole,
465
+ seriesOffset,
466
+ getCurrentFrame,
467
+ getStack,
428
468
  timelineClipName,
429
469
  playbackRate,
430
470
  parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id,
@@ -452,7 +492,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
452
492
  frozenMediaFrame,
453
493
  singleChildComponent,
454
494
  ]);
455
- (0, use_sequence_registration_js_1.useSequenceRegistration)({
495
+ const registration = (0, use_sequence_registration_js_1.useSequenceRegistration)({
456
496
  getSequence: env.isStudio || sequenceRegistrationEnabled
457
497
  ? getSequenceForRegistration
458
498
  : null,
@@ -467,11 +507,24 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
467
507
  parentPlaybackRate,
468
508
  durationInFrames: effectiveDurationInFrames,
469
509
  });
470
- const content = !seriesContentVisible || frameInParent - from < -boundaryTolerance
471
- ? null
472
- : frameInParent - endThreshold >= -boundaryTolerance
473
- ? null
474
- : children;
510
+ const contentVisible = seriesContentVisible &&
511
+ frameInParent - from >= -boundaryTolerance &&
512
+ frameInParent - endThreshold < -boundaryTolerance;
513
+ const activityDormant = parentDormant || !contentVisible;
514
+ const admitted = (0, SequenceActivityBudget_js_1.useSequenceActivityAdmission)(activityEnabled && !hidden
515
+ ? {
516
+ id,
517
+ parent: (_h = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _h !== void 0 ? _h : null,
518
+ compositionId: videoConfig.id,
519
+ from: firstFrame,
520
+ end: cumulatedFrom +
521
+ (from + actualDurationInFrames) / parentPlaybackRate,
522
+ }
523
+ : null);
524
+ const renderActivity = activityEnabled && (!activityDormant || admitted);
525
+ const content = (activityEnabled ? renderActivity : contentVisible)
526
+ ? children
527
+ : null;
475
528
  const frozenContent = content === null || typeof freeze === 'undefined' || freeze === null ? (content) : (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freeze, children: content }));
476
529
  const loopedContent = frozenContent === null || loopContextValue === null ? (frozenContent) : (jsx_runtime_1.jsx(loop_context_js_1.LoopContext.Provider, { value: loopContextValue, children: frozenContent }));
477
530
  const styleIfThere = other.layout === 'none' ? undefined : other.style;
@@ -507,15 +560,30 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, trimBefore = 0, playba
507
560
  if (ref !== null && layout === 'none') {
508
561
  throw new TypeError('It is not supported to pass both a `ref` and `layout="none"` to <Sequence />.');
509
562
  }
563
+ const metadata = (0, react_1.useMemo)(() => shouldDiscoverOutline || registration !== null
564
+ ? {
565
+ type: 'sequence',
566
+ id,
567
+ value: registration,
568
+ outlineChildrenRef: automaticOutlineRef,
569
+ }
570
+ : null, [automaticOutlineRef, id, registration, shouldDiscoverOutline]);
510
571
  if (hidden) {
511
- return shouldDiscoverOutline ? (jsx_runtime_1.jsx(sequence_order_marker_js_1.SequenceOrderMarker, { sequenceId: id, outlineChildrenRef: automaticOutlineRef, children: null })) : null;
572
+ return shouldDiscoverOutline || registration !== null ? (jsx_runtime_1.jsx(SequenceContextProvider, { value: contextValue, _remotionCommitMetadata: metadata, children: null })) : null;
512
573
  }
513
574
  // Retain resolved scene registrations so Studio can recover the natural end
514
575
  // even when seeking past an explicit wrapper trim. Scene contents stay hidden.
515
576
  const retainSeriesRegistration = env.isStudio && canInferDuration;
516
- const sequenceContent = loopedContent === null ? (retainSeriesRegistration ? (children) : null) : other.layout === 'none' ? (loopedContent) : (jsx_runtime_1.jsx(AbsoluteFillElement_js_1.AbsoluteFillElement, { ref: sequenceRef, style: defaultStyle, className: other.className, children: loopedContent }));
517
- const sequence = (jsx_runtime_1.jsx(SequenceContext_js_1.SequenceContext.Provider, { value: contextValue, children: retainSeriesRegistration ? (jsx_runtime_1.jsx(SeriesContentVisibilityContext.Provider, { value: content !== null, children: sequenceContent })) : (sequenceContent) }));
518
- return shouldDiscoverOutline ? (jsx_runtime_1.jsx(sequence_order_marker_js_1.SequenceOrderMarker, { sequenceId: id, outlineChildrenRef: automaticOutlineRef, children: sequence })) : (sequence);
577
+ const contentForLayout = renderActivity ? (jsx_runtime_1.jsx(SequenceActivityBoundary_js_1.SequenceActivityContent, { dormant: activityDormant, children: loopedContent })) : (loopedContent);
578
+ const renderedContent = loopedContent === null ? (retainSeriesRegistration ? (children) : null) : other.layout === 'none' ? (contentForLayout) : (jsx_runtime_1.jsx(AbsoluteFillElement_js_1.AbsoluteFillElement, { ref: sequenceRef, style: defaultStyle, className: other.className, children: contentForLayout }));
579
+ const activityContent = renderActivity ? (jsx_runtime_1.jsx(SequenceActivityBoundary_js_1.SequenceActivityBoundary, { dormant: activityDormant, frame: firstFrame, children: renderedContent })) : (renderedContent);
580
+ const sequenceContent = (jsx_runtime_1.jsx(SequenceContextProvider, { value: contextValue, _remotionCommitMetadata: metadata, children: retainSeriesRegistration ? (jsx_runtime_1.jsx(SeriesContentVisibilityContext.Provider, { value: renderActivity || contentVisible, children: activityContent })) : (activityContent) }));
581
+ // Keep the provider mounted when track grouping changes so clip state survives.
582
+ const sequence = (jsx_runtime_1.jsx(timeline_track_context_js_1.TimelineTrackContext.Provider, { value: timelineTrackRole === 'track' ||
583
+ (timelineTrackRole === 'clip' && !showInTimeline)
584
+ ? timelineTrack
585
+ : null, children: sequenceContent }));
586
+ return sequence;
519
587
  };
520
588
  const RegularSequence = (0, react_1.forwardRef)(RegularSequenceRefForwardingFunction);
521
589
  const PremountedPostmountedSequenceRefForwardingFunction = (props, ref) => {
@@ -537,17 +605,16 @@ const PremountedPostmountedSequenceRefForwardingFunction = (props, ref) => {
537
605
  styleWhilePostmounted: styleWhilePostmounted !== null && styleWhilePostmounted !== void 0 ? styleWhilePostmounted : null,
538
606
  hideWhilePremounted: 'opacity',
539
607
  });
540
- return (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, _remotionInternalIsPremounting: premountingActive, children: jsx_runtime_1.jsx(SequenceInner, { ref: ref, from: from, durationInFrames: durationInFrames, style: premountingStyle !== null && premountingStyle !== void 0 ? premountingStyle : undefined, _remotionInternalPremountDisplay: premountFor, _remotionInternalPostmountDisplay: postmountFor, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, ...otherProps }) }));
608
+ return (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, _remotionInternalIsPremounting: premountingActive, children: jsx_runtime_1.jsx(RegularSequence, { ref: ref, from: from, durationInFrames: durationInFrames, style: premountingStyle !== null && premountingStyle !== void 0 ? premountingStyle : undefined, _remotionInternalPremountDisplay: premountFor, _remotionInternalPostmountDisplay: postmountFor, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, ...otherProps }) }));
541
609
  };
542
610
  const PremountedPostmountedSequence = (0, react_1.forwardRef)(PremountedPostmountedSequenceRefForwardingFunction);
543
611
  const SequenceRefForwardingFunction = (props, ref) => {
544
612
  var _a;
545
613
  const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
546
614
  const { fps } = (0, use_video_config_js_1.useVideoConfig)();
615
+ const defaultPremountInSeconds = (0, react_1.useContext)(DefaultPremountContext_js_1.DefaultPremountContext);
547
616
  if (props.layout !== 'none' && !env.isRendering) {
548
- const effectivePremountFor = v5_flag_js_1.ENABLE_V5_BREAKING_CHANGES
549
- ? ((_a = props.premountFor) !== null && _a !== void 0 ? _a : fps)
550
- : props.premountFor;
617
+ const effectivePremountFor = (_a = props.premountFor) !== null && _a !== void 0 ? _a : Math.round(defaultPremountInSeconds * fps);
551
618
  if (effectivePremountFor || props.postmountFor) {
552
619
  return (jsx_runtime_1.jsx(PremountedPostmountedSequence, { ref: ref, ...props, premountFor: effectivePremountFor }));
553
620
  }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export declare const SequenceActivityContent: React.NamedExoticComponent<{
3
+ readonly children: React.ReactNode;
4
+ readonly dormant: boolean;
5
+ }>;
6
+ export declare const SequenceActivityBoundary: React.FC<{
7
+ readonly children: React.ReactNode;
8
+ readonly dormant: boolean;
9
+ readonly frame: number;
10
+ }>;
@@ -0,0 +1,88 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SequenceActivityBoundary = exports.SequenceActivityContent = void 0;
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const react_1 = __importStar(require("react"));
39
+ const sequence_activity_context_js_1 = require("./sequence-activity-context.js");
40
+ const TimelineContext_js_1 = require("./TimelineContext.js");
41
+ const use_video_config_js_1 = require("./use-video-config.js");
42
+ const areActivityChildrenEqual = (previous, next) => {
43
+ if (Object.is(previous, next)) {
44
+ return true;
45
+ }
46
+ if (Array.isArray(previous) && Array.isArray(next)) {
47
+ return (previous.length === next.length &&
48
+ previous.every((child, index) => areActivityChildrenEqual(child, next[index])));
49
+ }
50
+ if (!react_1.default.isValidElement(previous) ||
51
+ !react_1.default.isValidElement(next) ||
52
+ previous.type !== next.type ||
53
+ previous.key !== next.key) {
54
+ return false;
55
+ }
56
+ const keys = Object.keys(previous.props);
57
+ return (keys.length === Object.keys(next.props).length &&
58
+ keys.every((key) => Object.prototype.hasOwnProperty.call(next.props, key) &&
59
+ (key === 'children'
60
+ ? areActivityChildrenEqual(previous.props.children, next.props.children)
61
+ : Object.is(previous.props[key], next.props[key]))));
62
+ };
63
+ // Parent frame subscriptions often recreate unchanged JSX. Compare element
64
+ // structure and all props instead of ignoring changes to dormant scene props.
65
+ exports.SequenceActivityContent = react_1.default.memo(({ children }) => children, (previous, next) => previous.dormant &&
66
+ next.dormant &&
67
+ areActivityChildrenEqual(previous.children, next.children));
68
+ const SequenceActivityBoundary = ({ children, dormant, frame }) => {
69
+ const parentDormant = (0, react_1.useContext)(sequence_activity_context_js_1.SequenceActivityDormantContext);
70
+ const timeline = (0, react_1.useContext)(parentDormant ? sequence_activity_context_js_1.SequenceActivityTimelineContext : TimelineContext_js_1.TimelineContext);
71
+ const absoluteTime = (0, react_1.useContext)(parentDormant ? sequence_activity_context_js_1.SequenceActivityAbsoluteTimeContext : TimelineContext_js_1.AbsoluteTimeContext);
72
+ const { id } = (0, use_video_config_js_1.useVideoConfig)();
73
+ if (timeline === null) {
74
+ throw new Error('TimelineContext is missing');
75
+ }
76
+ const { audioAndVideoTags } = timeline;
77
+ const dormantTimeline = (0, react_1.useMemo)(() => ({
78
+ frame: { [id]: frame },
79
+ isPlaying: () => false,
80
+ isInsideFreeze: true,
81
+ audioAndVideoTags,
82
+ }), [audioAndVideoTags, frame, id]);
83
+ // Keep the providers and Activity at the same position when activating a
84
+ // scene. Unlike Freeze, discovery does not reset SequenceContext origins or
85
+ // disable Series duration inference.
86
+ return (jsx_runtime_1.jsx(sequence_activity_context_js_1.SequenceActivityDormantContext.Provider, { value: dormant, children: jsx_runtime_1.jsx(sequence_activity_context_js_1.SequenceActivityTimelineContext.Provider, { value: dormant ? dormantTimeline : null, children: jsx_runtime_1.jsx(sequence_activity_context_js_1.SequenceActivityAbsoluteTimeContext.Provider, { value: dormant ? dormantTimeline : null, children: jsx_runtime_1.jsx(TimelineContext_js_1.TimelineContext.Provider, { value: dormant ? dormantTimeline : timeline, children: jsx_runtime_1.jsx(TimelineContext_js_1.AbsoluteTimeContext.Provider, { value: dormant ? dormantTimeline : absoluteTime, children: jsx_runtime_1.jsx(react_1.default.Activity, { mode: dormant && !parentDormant ? 'hidden' : 'visible', children: children }) }) }) }) }) }));
87
+ };
88
+ exports.SequenceActivityBoundary = SequenceActivityBoundary;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ type ActivityCandidate = {
3
+ readonly id: string;
4
+ readonly parent: string | null;
5
+ readonly compositionId: string;
6
+ readonly from: number;
7
+ readonly end: number;
8
+ };
9
+ export declare const SequenceActivityBudgetProvider: React.FC<{
10
+ readonly children: React.ReactNode;
11
+ }>;
12
+ export declare const useSequenceActivityAdmission: (candidate: ActivityCandidate | null) => boolean;
13
+ export {};