remotion 4.0.463 → 4.0.465

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 (40) hide show
  1. package/dist/cjs/CompositionErrorBoundary.d.ts +6 -1
  2. package/dist/cjs/CompositionErrorBoundary.js +65 -1
  3. package/dist/cjs/CompositionManager.d.ts +1 -1
  4. package/dist/cjs/HtmlInCanvas.d.ts +10 -6
  5. package/dist/cjs/HtmlInCanvas.js +45 -39
  6. package/dist/cjs/Img.d.ts +3 -2
  7. package/dist/cjs/Img.js +4 -21
  8. package/dist/cjs/Sequence.d.ts +4 -1
  9. package/dist/cjs/Sequence.js +53 -30
  10. package/dist/cjs/animated-image/AnimatedImage.d.ts +3 -1
  11. package/dist/cjs/animated-image/AnimatedImage.js +36 -22
  12. package/dist/cjs/animated-image/canvas.d.ts +3 -1
  13. package/dist/cjs/animated-image/canvas.js +31 -10
  14. package/dist/cjs/animated-image/props.d.ts +3 -1
  15. package/dist/cjs/audio/AudioForPreview.js +16 -12
  16. package/dist/cjs/effects/Solid.d.ts +2 -2
  17. package/dist/cjs/effects/Solid.js +12 -9
  18. package/dist/cjs/effects/canvas-pool.js +2 -1
  19. package/dist/cjs/effects/create-effect.js +10 -7
  20. package/dist/cjs/effects/effect-types.d.ts +8 -0
  21. package/dist/cjs/effects/run-effect-chain.d.ts +3 -1
  22. package/dist/cjs/effects/run-effect-chain.js +26 -12
  23. package/dist/cjs/effects/webgl2-context-error.d.ts +3 -0
  24. package/dist/cjs/effects/webgl2-context-error.js +13 -0
  25. package/dist/cjs/index.d.ts +5 -9
  26. package/dist/cjs/index.js +7 -3
  27. package/dist/cjs/internals.d.ts +68 -18
  28. package/dist/cjs/internals.js +5 -0
  29. package/dist/cjs/no-react.d.ts +16 -16
  30. package/dist/cjs/sequence-field-schema.d.ts +66 -18
  31. package/dist/cjs/sequence-field-schema.js +8 -2
  32. package/dist/cjs/use-media-in-timeline.d.ts +3 -14
  33. package/dist/cjs/use-media-in-timeline.js +4 -75
  34. package/dist/cjs/version.d.ts +1 -1
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/cjs/video/VideoForPreview.js +4 -1
  37. package/dist/esm/index.mjs +792 -722
  38. package/dist/esm/no-react.mjs +8 -2
  39. package/dist/esm/version.mjs +1 -1
  40. package/package.json +2 -2
@@ -9,9 +9,14 @@ type State = {
9
9
  };
10
10
  export declare class CompositionErrorBoundary extends React.Component<Props, State> {
11
11
  state: State;
12
+ private hmrStatusHandler;
12
13
  static getDerivedStateFromError(): Partial<State>;
13
14
  componentDidCatch(error: Error): void;
14
- componentDidUpdate(_prevProps: Props): void;
15
+ componentDidMount(): void;
16
+ componentDidUpdate(_prevProps: Props, prevState: State): void;
17
+ componentWillUnmount(): void;
18
+ private subscribeToHmrReset;
19
+ private unsubscribeFromHmrReset;
15
20
  render(): React.ReactNode;
16
21
  }
17
22
  export {};
@@ -5,22 +5,86 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CompositionErrorBoundary = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
+ const getHot = () => {
9
+ var _a;
10
+ try {
11
+ if (typeof __webpack_module__ === 'undefined') {
12
+ return null;
13
+ }
14
+ return (_a = __webpack_module__.hot) !== null && _a !== void 0 ? _a : null;
15
+ }
16
+ catch (_b) {
17
+ return null;
18
+ }
19
+ };
8
20
  class CompositionErrorBoundary extends react_1.default.Component {
9
21
  constructor() {
10
22
  super(...arguments);
11
23
  this.state = { hasError: false };
24
+ this.hmrStatusHandler = null;
12
25
  }
13
26
  static getDerivedStateFromError() {
14
27
  return { hasError: true };
15
28
  }
16
29
  componentDidCatch(error) {
17
30
  this.props.onError(error);
31
+ this.subscribeToHmrReset();
18
32
  }
19
- componentDidUpdate(_prevProps) {
33
+ componentDidMount() {
34
+ // A fresh boundary mounting in the success state means any stale
35
+ // `renderError` left over by a previous boundary instance should be
36
+ // cleared. Fast Refresh sometimes unmounts the old (errored) boundary
37
+ // and mounts a new one during `apply`, so `componentDidUpdate`'s
38
+ // error→success transition never fires.
20
39
  if (!this.state.hasError) {
21
40
  this.props.onClear();
22
41
  }
23
42
  }
43
+ componentDidUpdate(_prevProps, prevState) {
44
+ if (prevState.hasError && !this.state.hasError) {
45
+ this.props.onClear();
46
+ }
47
+ }
48
+ componentWillUnmount() {
49
+ this.unsubscribeFromHmrReset();
50
+ }
51
+ subscribeToHmrReset() {
52
+ if (this.hmrStatusHandler) {
53
+ return;
54
+ }
55
+ const hot = getHot();
56
+ if (!hot) {
57
+ return;
58
+ }
59
+ // Once the boundary catches a runtime error it returns `null` on every
60
+ // render and never retries the children — so any subsequent HMR fix
61
+ // would be invisible. While in the error state, wait for the next
62
+ // time webpack HMR settles (`idle`), drop the error flag, and let the
63
+ // boundary re-render. If the children still throw, `componentDidCatch`
64
+ // resubscribes. If they succeed, `componentDidUpdate` calls
65
+ // `onClear()`. See https://github.com/remotion-dev/remotion/issues/7447.
66
+ const handler = (status) => {
67
+ if (status !== 'idle') {
68
+ return;
69
+ }
70
+ this.unsubscribeFromHmrReset();
71
+ this.setState({ hasError: false });
72
+ };
73
+ this.hmrStatusHandler = handler;
74
+ hot.addStatusHandler(handler);
75
+ }
76
+ unsubscribeFromHmrReset() {
77
+ const handler = this.hmrStatusHandler;
78
+ if (!handler) {
79
+ return;
80
+ }
81
+ this.hmrStatusHandler = null;
82
+ const hot = getHot();
83
+ if (!hot) {
84
+ return;
85
+ }
86
+ hot.removeStatusHandler(handler);
87
+ }
24
88
  render() {
25
89
  if (this.state.hasError) {
26
90
  return null;
@@ -65,7 +65,7 @@ export type TSequence = {
65
65
  showInTimeline: boolean;
66
66
  nonce: NonceHistory;
67
67
  loopDisplay: LoopDisplay | undefined;
68
- stack: string | null;
68
+ getStack: () => string | null;
69
69
  premountDisplay: number | null;
70
70
  postmountDisplay: number | null;
71
71
  controls: SequenceControls | null;
@@ -14,10 +14,10 @@ declare global {
14
14
  drawElementImage(element: Element | ElementImage, sx: number, sy: number, swidth: number, sheight: number, dx: number, dy: number, dwidth: number, dheight: number): DOMMatrix;
15
15
  }
16
16
  interface OffscreenCanvasRenderingContext2D {
17
- drawElementImage(element: ElementImage, dx: number, dy: number): DOMMatrix;
18
- drawElementImage(element: ElementImage, dx: number, dy: number, dwidth: number, dheight: number): DOMMatrix;
19
- drawElementImage(element: ElementImage, sx: number, sy: number, swidth: number, sheight: number, dx: number, dy: number): DOMMatrix;
20
- drawElementImage(element: ElementImage, sx: number, sy: number, swidth: number, sheight: number, dx: number, dy: number, dwidth: number, dheight: number): DOMMatrix;
17
+ drawElementImage(element: Element | ElementImage, dx: number, dy: number): DOMMatrix;
18
+ drawElementImage(element: Element | ElementImage, dx: number, dy: number, dwidth: number, dheight: number): DOMMatrix;
19
+ drawElementImage(element: Element | ElementImage, sx: number, sy: number, swidth: number, sheight: number, dx: number, dy: number): DOMMatrix;
20
+ drawElementImage(element: Element | ElementImage, sx: number, sy: number, swidth: number, sheight: number, dx: number, dy: number, dwidth: number, dheight: number): DOMMatrix;
21
21
  }
22
22
  interface WebGLRenderingContextBase {
23
23
  texElementImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, element: Element | ElementImage): void;
@@ -37,6 +37,10 @@ declare global {
37
37
  }
38
38
  }
39
39
  export type HtmlInCanvasOnPaintParams = {
40
+ /**
41
+ * The `OffscreenCanvas` from {@link HTMLCanvasElement.transferControlToOffscreen}
42
+ * on the layout `<canvas>` (same logical canvas as the forwarded ref).
43
+ */
40
44
  readonly canvas: OffscreenCanvas;
41
45
  readonly element: HTMLDivElement;
42
46
  readonly elementImage: ElementImage;
@@ -47,11 +51,11 @@ export declare const HTML_IN_CANVAS_UNSUPPORTED_MESSAGE = "HTML in Canvas is not
47
51
  export type HtmlInCanvasOnPaint = (params: HtmlInCanvasOnPaintParams) => void | Promise<void>;
48
52
  export type HtmlInCanvasOnInitCleanup = () => void;
49
53
  export type HtmlInCanvasOnInit = (params: HtmlInCanvasOnPaintParams) => HtmlInCanvasOnInitCleanup | Promise<HtmlInCanvasOnInitCleanup>;
50
- export type HtmlInCanvasProps = Omit<SequenceProps, 'children' | 'durationInFrames' | keyof LayoutAndStyle | '_experimentalEffects'> & Omit<AbsoluteFillLayout, 'layout' | 'styleWhilePostmounted' | 'postmountFor' | 'premountFor' | 'styleWhilePremounted'> & {
54
+ export type HtmlInCanvasProps = Omit<SequenceProps, 'children' | 'durationInFrames' | keyof LayoutAndStyle | '_remotionInternalEffects'> & Omit<AbsoluteFillLayout, 'layout' | 'styleWhilePostmounted' | 'postmountFor' | 'premountFor' | 'styleWhilePremounted'> & {
51
55
  readonly durationInFrames?: number;
52
56
  readonly width: number;
53
57
  readonly height: number;
54
- readonly _experimentalEffects?: EffectsProp;
58
+ readonly effects?: EffectsProp;
55
59
  readonly children: React.ReactNode;
56
60
  readonly onPaint?: HtmlInCanvasOnPaint;
57
61
  readonly onInit?: HtmlInCanvasOnInit;
@@ -29,7 +29,8 @@ const isHtmlInCanvasSupported = () => {
29
29
  cachedSupport =
30
30
  typeof (ctx === null || ctx === void 0 ? void 0 : ctx.drawElementImage) === 'function' &&
31
31
  typeof canvas.requestPaint === 'function' &&
32
- typeof canvas.captureElementImage === 'function';
32
+ typeof canvas.captureElementImage === 'function' &&
33
+ 'transferControlToOffscreen' in HTMLCanvasElement.prototype;
33
34
  return cachedSupport;
34
35
  };
35
36
  exports.isHtmlInCanvasSupported = isHtmlInCanvasSupported;
@@ -66,7 +67,9 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
66
67
  cancelRender(new Error(exports.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE));
67
68
  }
68
69
  const canvas2dRef = (0, react_1.useRef)(null);
70
+ const offscreenRef = (0, react_1.useRef)(null);
69
71
  const divRef = (0, react_1.useRef)(null);
72
+ const canvasSizeKey = `${width}x${height}`;
70
73
  const setLayoutCanvasRef = (0, react_1.useCallback)((node) => {
71
74
  canvas2dRef.current = node;
72
75
  if (typeof ref === 'function') {
@@ -77,7 +80,6 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
77
80
  node;
78
81
  }
79
82
  }, [ref]);
80
- const [offscreenCanvas] = (0, react_1.useState)(() => new OffscreenCanvas(1, 1));
81
83
  const chainState = (0, use_effect_chain_state_js_1.useEffectChainState)();
82
84
  const memoizedEffects = (0, use_memoized_effects_js_1.useMemoizedEffects)({
83
85
  effects,
@@ -99,19 +101,23 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
99
101
  if (!element) {
100
102
  throw new Error('Canvas or scene element not found');
101
103
  }
102
- offscreenCanvas.width = width;
103
- offscreenCanvas.height = height;
104
+ const offscreen = offscreenRef.current;
105
+ if (!offscreen) {
106
+ throw new Error('HtmlInCanvas: offscreen canvas not ready (transferControlToOffscreen failed or canvas is remounting)');
107
+ }
108
+ offscreen.width = width;
109
+ offscreen.height = height;
104
110
  try {
105
- const layoutCanvas = canvas2dRef.current;
106
- if (!layoutCanvas) {
111
+ const placeholderCanvas = canvas2dRef.current;
112
+ if (!placeholderCanvas) {
107
113
  throw new Error('Canvas not found');
108
114
  }
109
115
  // `GPUQueue.copyElementImageToTexture` / related paths validate the
110
- // layout canvas has a rendering context. `runEffectChain` only runs
111
- // after `onPaint`, so acquire `2d` here before any capture or handler.
112
- const layout2d = layoutCanvas.getContext('2d');
113
- if (!layout2d) {
114
- throw new Error('Failed to acquire 2D context for <HtmlInCanvas> layout canvas');
116
+ // linked offscreen surface has a rendering context. Acquire `2d` here
117
+ // before any capture or handler (must not call getContext on placeholder).
118
+ const offscreen2d = offscreen.getContext('2d');
119
+ if (!offscreen2d) {
120
+ throw new Error('Failed to acquire 2D context for <HtmlInCanvas> offscreen canvas');
115
121
  }
116
122
  const handle = (0, delay_render_js_1.delayRender)('onPaint');
117
123
  if (!initializedRef.current) {
@@ -122,11 +128,11 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
122
128
  // can invalidate the capture's paint context, leaving subsequent
123
129
  // uploads (e.g. `copyElementImageToTexture`) failing with
124
130
  // "No context found for ElementImage" on the very first paint.
125
- const initImage = layoutCanvas.captureElementImage(element);
131
+ const initImage = placeholderCanvas.captureElementImage(element);
126
132
  const currentOnInit = onInitRef.current;
127
133
  if (currentOnInit) {
128
134
  const cleanup = await currentOnInit({
129
- canvas: offscreenCanvas,
135
+ canvas: offscreen,
130
136
  element,
131
137
  elementImage: initImage,
132
138
  });
@@ -142,17 +148,17 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
142
148
  }
143
149
  }
144
150
  const handler = (_a = onPaintRef.current) !== null && _a !== void 0 ? _a : defaultOnPaint;
145
- const elImage = layoutCanvas.captureElementImage(element);
151
+ const elImage = placeholderCanvas.captureElementImage(element);
146
152
  await handler({
147
- canvas: offscreenCanvas,
153
+ canvas: offscreen,
148
154
  element,
149
155
  elementImage: elImage,
150
156
  });
151
157
  await (0, run_effect_chain_js_1.runEffectChain)({
152
158
  state: chainState.get(width, height),
153
- source: offscreenCanvas,
159
+ source: offscreen,
154
160
  effects: effectsRef.current,
155
- output: canvas2dRef.current,
161
+ output: offscreen,
156
162
  width,
157
163
  height,
158
164
  });
@@ -161,32 +167,32 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
161
167
  catch (error) {
162
168
  cancelRender(error);
163
169
  }
164
- }, [
165
- chainState,
166
- continueRender,
167
- cancelRender,
168
- width,
169
- height,
170
- offscreenCanvas,
171
- ]);
172
- // Set up layoutSubtree and persistent paint listener. Runs as a
173
- // layout effect so the listener is attached before the resize effect
174
- // below dispatches its first synthetic paint.
170
+ }, [chainState, continueRender, cancelRender, width, height]);
171
+ // Transfer control once per layout canvas instance, then listen for paint on
172
+ // the placeholder (capture) while drawing on the linked offscreen surface.
175
173
  (0, react_1.useLayoutEffect)(() => {
176
- const canvas = canvas2dRef.current;
177
- if (!canvas) {
174
+ const placeholder = canvas2dRef.current;
175
+ if (!placeholder) {
178
176
  throw new Error('Canvas not found');
179
177
  }
180
- canvas.layoutSubtree = true;
181
- canvas.addEventListener('paint', onPaintCb);
178
+ placeholder.layoutSubtree = true;
179
+ const offscreen = placeholder.transferControlToOffscreen();
180
+ offscreenRef.current = offscreen;
181
+ offscreen.width = width;
182
+ offscreen.height = height;
183
+ initializedRef.current = false;
184
+ unmountedRef.current = false;
185
+ placeholder.addEventListener('paint', onPaintCb);
182
186
  return () => {
183
187
  var _a;
184
- canvas.removeEventListener('paint', onPaintCb);
188
+ placeholder.removeEventListener('paint', onPaintCb);
189
+ offscreenRef.current = null;
190
+ initializedRef.current = false;
185
191
  unmountedRef.current = true;
186
192
  (_a = onInitCleanupRef.current) === null || _a === void 0 ? void 0 : _a.call(onInitCleanupRef);
187
193
  onInitCleanupRef.current = null;
188
194
  };
189
- }, [onPaintCb, cancelRender]);
195
+ }, [onPaintCb, cancelRender, width, height]);
190
196
  const onPaintChangedRef = (0, react_1.useRef)(false);
191
197
  (0, react_1.useLayoutEffect)(() => {
192
198
  var _a;
@@ -212,7 +218,7 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
212
218
  return () => {
213
219
  continueRender(handle);
214
220
  };
215
- }, [width, height, continueRender]);
221
+ }, [width, height, continueRender, canvasSizeKey]);
216
222
  const innerStyle = (0, react_1.useMemo)(() => {
217
223
  return {
218
224
  width,
@@ -222,18 +228,18 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
222
228
  if (isInsideAncestorHtmlInCanvas) {
223
229
  throw new Error('<HtmlInCanvas> effects cannot be nested together. Chrome will only display the outer effect. Consider merging the effects into one if you can.');
224
230
  }
225
- return ((0, jsx_runtime_1.jsx)(HtmlInCanvasAncestorContext.Provider, { value: true, children: (0, jsx_runtime_1.jsx)("canvas", { ref: setLayoutCanvasRef, width: width, height: height, style: style, children: (0, jsx_runtime_1.jsx)("div", { ref: divRef, style: innerStyle, children: children }) }) }));
231
+ return ((0, jsx_runtime_1.jsx)(HtmlInCanvasAncestorContext.Provider, { value: true, children: (0, jsx_runtime_1.jsx)("canvas", { ref: setLayoutCanvasRef, width: width, height: height, style: style, children: (0, jsx_runtime_1.jsx)("div", { ref: divRef, style: innerStyle, children: children }) }, canvasSizeKey) }));
226
232
  });
227
233
  HtmlInCanvasContent.displayName = 'HtmlInCanvasContent';
228
- const HtmlInCanvasInner = (0, react_1.forwardRef)(({ width, height, _experimentalEffects: effects = [], children, onPaint, onInit, _experimentalControls: controls, style, durationInFrames, name, ...sequenceProps }, ref) => {
234
+ const HtmlInCanvasInner = (0, react_1.forwardRef)(({ width, height, effects = [], children, onPaint, onInit, _experimentalControls: controls, style, durationInFrames, name, ...sequenceProps }, ref) => {
229
235
  const { durationInFrames: videoDuration } = (0, use_video_config_js_1.useVideoConfig)();
230
236
  const resolvedDuration = durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : videoDuration;
231
237
  const memoizedEffectDefinitions = (0, use_memoized_effects_js_1.useMemoizedEffectDefinitions)(effects);
232
- return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: resolvedDuration, name: name !== null && name !== void 0 ? name : '<HtmlInCanvas>', _experimentalControls: controls, _experimentalEffects: memoizedEffectDefinitions, layout: "none", ...sequenceProps, children: (0, jsx_runtime_1.jsx)(HtmlInCanvasContent, { ref: ref, width: width, height: height, effects: effects, onPaint: onPaint, onInit: onInit, controls: controls, style: style, children: children }) }));
238
+ return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: resolvedDuration, name: name !== null && name !== void 0 ? name : '<HtmlInCanvas>', _experimentalControls: controls, _remotionInternalEffects: memoizedEffectDefinitions, layout: "none", ...sequenceProps, children: (0, jsx_runtime_1.jsx)(HtmlInCanvasContent, { ref: ref, width: width, height: height, effects: effects, onPaint: onPaint, onInit: onInit, controls: controls, style: style, children: children }) }));
233
239
  });
234
240
  HtmlInCanvasInner.displayName = 'HtmlInCanvas';
235
241
  const htmlInCanvasSchema = {
236
- ...sequence_field_schema_js_1.sequenceStyleSchema,
242
+ ...sequence_field_schema_js_1.sequenceVisualStyleSchema,
237
243
  hidden: sequence_field_schema_js_1.hiddenField,
238
244
  };
239
245
  const HtmlInCanvasWrapped = (0, wrap_in_schema_js_1.wrapInSchema)(HtmlInCanvasInner, htmlInCanvasSchema);
package/dist/cjs/Img.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { SequenceProps } from './Sequence.js';
2
3
  export declare function truncateSrcForLabel(src: string): string;
3
4
  type NativeImgProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'src'>;
4
5
  export type ImgProps = NativeImgProps & {
@@ -14,7 +15,7 @@ export type ImgProps = NativeImgProps & {
14
15
  * @deprecated For internal use only
15
16
  */
16
17
  readonly stack?: string;
17
- };
18
+ } & Pick<SequenceProps, 'durationInFrames' | 'from' | 'hidden'>;
18
19
  export declare const Img: React.ComponentType<NativeImgProps & {
19
20
  readonly maxRetries?: number;
20
21
  readonly pauseWhenLoading?: boolean;
@@ -28,5 +29,5 @@ export declare const Img: React.ComponentType<NativeImgProps & {
28
29
  * @deprecated For internal use only
29
30
  */
30
31
  readonly stack?: string;
31
- }>;
32
+ } & Pick<SequenceProps, "hidden" | "durationInFrames" | "from">>;
32
33
  export {};
package/dist/cjs/Img.js CHANGED
@@ -8,10 +8,10 @@ const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-trace
8
8
  const get_cross_origin_value_js_1 = require("./get-cross-origin-value.js");
9
9
  const prefetch_js_1 = require("./prefetch.js");
10
10
  const sequence_field_schema_js_1 = require("./sequence-field-schema.js");
11
+ const Sequence_js_1 = require("./Sequence.js");
11
12
  const SequenceContext_js_1 = require("./SequenceContext.js");
12
13
  const use_buffer_state_js_1 = require("./use-buffer-state.js");
13
14
  const use_delay_render_js_1 = require("./use-delay-render.js");
14
- const use_media_in_timeline_js_1 = require("./use-media-in-timeline.js");
15
15
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
16
16
  const wrap_in_schema_js_1 = require("./wrap-in-schema.js");
17
17
  function exponentialBackoff(errorCount) {
@@ -181,31 +181,14 @@ const ImgContent = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRende
181
181
  // src gets set once we've loaded and decoded the image.
182
182
  return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, crossOrigin: crossOriginValue, onError: didGetError, decoding: "sync" }));
183
183
  };
184
- const ImgInner = ({ hidden, name, stack, showInTimeline, src, _experimentalControls: controls, ...props }) => {
185
- var _a, _b;
186
- const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
187
- const [timelineId] = (0, react_1.useState)(() => String(Math.random()));
184
+ const ImgInner = ({ hidden, name, stack, showInTimeline, src, from, durationInFrames, _experimentalControls: controls, ...props }) => {
188
185
  if (!src) {
189
186
  throw new Error('No "src" prop was passed to <Img>.');
190
187
  }
191
- (0, use_media_in_timeline_js_1.useImageInTimeline)({
192
- src,
193
- displayName: name !== null && name !== void 0 ? name : null,
194
- id: timelineId,
195
- stack: stack !== null && stack !== void 0 ? stack : null,
196
- showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true,
197
- premountDisplay: (_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premountDisplay) !== null && _a !== void 0 ? _a : null,
198
- postmountDisplay: (_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmountDisplay) !== null && _b !== void 0 ? _b : null,
199
- loopDisplay: undefined,
200
- controls: controls !== null && controls !== void 0 ? controls : null,
201
- });
202
- if (hidden) {
203
- return null;
204
- }
205
- return (0, jsx_runtime_1.jsx)(ImgContent, { src: src, ...props });
188
+ return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: from !== null && from !== void 0 ? from : 0, durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity, _remotionInternalStack: stack, _remotionInternalIsMedia: { type: 'image', src }, name: name !== null && name !== void 0 ? name : '<Img>', _experimentalControls: controls, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, hidden: hidden, children: (0, jsx_runtime_1.jsx)(ImgContent, { src: src, ...props }) }));
206
189
  };
207
190
  const imgSchema = {
208
- ...sequence_field_schema_js_1.sequenceStyleSchema,
191
+ ...sequence_field_schema_js_1.sequenceVisualStyleSchema,
209
192
  hidden: sequence_field_schema_js_1.hiddenField,
210
193
  };
211
194
  /*
@@ -23,7 +23,7 @@ export type SequencePropsWithoutDuration = {
23
23
  readonly showInTimeline?: boolean;
24
24
  readonly hidden?: boolean;
25
25
  readonly _experimentalControls?: SequenceControls;
26
- readonly _experimentalEffects?: readonly EffectDefinition<unknown>[];
26
+ readonly _remotionInternalEffects?: readonly EffectDefinition<unknown>[];
27
27
  /**
28
28
  * @deprecated For internal use only.
29
29
  */
@@ -54,6 +54,9 @@ export type SequencePropsWithoutDuration = {
54
54
  readonly _remotionInternalIsMedia?: {
55
55
  type: 'video' | 'audio';
56
56
  data: BasicMediaInTimelineReturnType;
57
+ } | {
58
+ type: 'image';
59
+ src: string;
57
60
  };
58
61
  } & LayoutAndStyle;
59
62
  export type SequenceProps = {
@@ -4,6 +4,7 @@ exports.Sequence = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  /* eslint-disable @typescript-eslint/no-use-before-define */
6
6
  const react_1 = require("react");
7
+ const react_2 = require("react");
7
8
  const AbsoluteFill_js_1 = require("./AbsoluteFill.js");
8
9
  const freeze_js_1 = require("./freeze.js");
9
10
  const nonce_js_1 = require("./nonce.js");
@@ -17,7 +18,7 @@ const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
17
18
  const use_video_config_js_1 = require("./use-video-config.js");
18
19
  const v5_flag_js_1 = require("./v5-flag.js");
19
20
  const wrap_in_schema_js_1 = require("./wrap-in-schema.js");
20
- const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, hidden = false, _experimentalControls: controls, _experimentalEffects, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, _remotionInternalIsMedia: isMedia, ...other }, ref) => {
21
+ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, hidden = false, _experimentalControls: controls, _remotionInternalEffects, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, _remotionInternalIsMedia: isMedia, ...other }, ref) => {
21
22
  var _a;
22
23
  const { layout = 'absolute-fill' } = other;
23
24
  const [id] = (0, react_1.useState)(() => String(Math.random()));
@@ -100,35 +101,58 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
100
101
  const inheritedStack = (_a = other === null || other === void 0 ? void 0 : other.stack) !== null && _a !== void 0 ? _a : null;
101
102
  // Our assumption: Stack doesnt' change. After we symbolicate we assign it a nodePath
102
103
  // and if it changes, it would lead to-remounting of the sequence.
103
- const [stackDoesntChange] = (0, react_1.useState)(() => stack !== null && stack !== void 0 ? stack : inheritedStack);
104
+ const stackRef = (0, react_2.useRef)(null);
105
+ stackRef.current = stack !== null && stack !== void 0 ? stack : inheritedStack;
104
106
  (0, react_1.useEffect)(() => {
105
- var _a, _b;
107
+ var _a, _b, _c;
106
108
  if (!env.isStudio) {
107
109
  return;
108
110
  }
109
111
  if (isMedia) {
110
- registerSequence({
111
- type: isMedia.type,
112
- controls: controls !== null && controls !== void 0 ? controls : null,
113
- effects: _experimentalEffects !== null && _experimentalEffects !== void 0 ? _experimentalEffects : [],
114
- displayName: timelineClipName,
115
- doesVolumeChange: isMedia.data.doesVolumeChange,
116
- duration: actualDurationInFrames,
117
- from,
118
- id,
119
- loopDisplay,
120
- nonce: nonce.get(),
121
- parent: (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _a !== void 0 ? _a : null,
122
- playbackRate: isMedia.data.playbackRate,
123
- postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
124
- premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
125
- rootId,
126
- showInTimeline,
127
- src: isMedia.data.src,
128
- stack: stackDoesntChange,
129
- startMediaFrom: isMedia.data.startMediaFrom,
130
- volume: isMedia.data.volumes,
131
- });
112
+ if (isMedia.type === 'image') {
113
+ registerSequence({
114
+ type: 'image',
115
+ controls: controls !== null && controls !== void 0 ? controls : null,
116
+ effects: _remotionInternalEffects !== null && _remotionInternalEffects !== void 0 ? _remotionInternalEffects : [],
117
+ displayName: timelineClipName,
118
+ duration: actualDurationInFrames,
119
+ from,
120
+ id,
121
+ loopDisplay,
122
+ nonce: nonce.get(),
123
+ parent: (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _a !== void 0 ? _a : null,
124
+ postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
125
+ premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
126
+ rootId,
127
+ showInTimeline,
128
+ src: isMedia.src,
129
+ getStack: () => stackRef.current,
130
+ });
131
+ }
132
+ else {
133
+ registerSequence({
134
+ type: isMedia.type,
135
+ controls: controls !== null && controls !== void 0 ? controls : null,
136
+ effects: _remotionInternalEffects !== null && _remotionInternalEffects !== void 0 ? _remotionInternalEffects : [],
137
+ displayName: timelineClipName,
138
+ doesVolumeChange: isMedia.data.doesVolumeChange,
139
+ duration: actualDurationInFrames,
140
+ from,
141
+ id,
142
+ loopDisplay,
143
+ nonce: nonce.get(),
144
+ parent: (_b = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _b !== void 0 ? _b : null,
145
+ playbackRate: isMedia.data.playbackRate,
146
+ postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
147
+ premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
148
+ rootId,
149
+ showInTimeline,
150
+ src: isMedia.data.src,
151
+ getStack: () => stackRef.current,
152
+ startMediaFrom: isMedia.data.startMediaFrom,
153
+ volume: isMedia.data.volumes,
154
+ });
155
+ }
132
156
  return () => {
133
157
  unregisterSequence(id);
134
158
  };
@@ -138,17 +162,17 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
138
162
  duration: actualDurationInFrames,
139
163
  id,
140
164
  displayName: timelineClipName,
141
- parent: (_b = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _b !== void 0 ? _b : null,
165
+ parent: (_c = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _c !== void 0 ? _c : null,
142
166
  type: 'sequence',
143
167
  rootId,
144
168
  showInTimeline,
145
169
  nonce: nonce.get(),
146
170
  loopDisplay,
147
- stack: stackDoesntChange,
171
+ getStack: () => stackRef.current,
148
172
  premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
149
173
  postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
150
174
  controls: controls !== null && controls !== void 0 ? controls : null,
151
- effects: _experimentalEffects !== null && _experimentalEffects !== void 0 ? _experimentalEffects : [],
175
+ effects: _remotionInternalEffects !== null && _remotionInternalEffects !== void 0 ? _remotionInternalEffects : [],
152
176
  });
153
177
  return () => {
154
178
  unregisterSequence(id);
@@ -167,12 +191,11 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
167
191
  showInTimeline,
168
192
  nonce,
169
193
  loopDisplay,
170
- stackDoesntChange,
171
194
  premountDisplay,
172
195
  postmountDisplay,
173
196
  env.isStudio,
174
197
  controls,
175
- _experimentalEffects,
198
+ _remotionInternalEffects,
176
199
  isMedia,
177
200
  ]);
178
201
  // Ceil to support floats
@@ -1,8 +1,10 @@
1
1
  import type React from 'react';
2
2
  import type { SequenceControls } from '../CompositionManager.js';
3
+ import type { EffectsProp } from '../effects/effect-types.js';
3
4
  import type { RemotionAnimatedImageProps } from './props';
4
- export declare const AnimatedImage: React.ComponentType<Omit<import("../Sequence.js").SequenceProps, "children" | "layout" | "durationInFrames"> & RemotionAnimatedImageProps & {
5
+ export declare const AnimatedImage: React.ComponentType<Omit<import("../Sequence.js").SequenceProps, "children" | "layout" | "durationInFrames" | "_remotionInternalEffects"> & RemotionAnimatedImageProps & {
5
6
  readonly durationInFrames?: number;
7
+ readonly effects?: EffectsProp;
6
8
  } & {
7
9
  readonly _experimentalControls?: SequenceControls | undefined;
8
10
  readonly ref?: React.Ref<HTMLCanvasElement>;