remotion 4.0.495 → 4.0.497

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 (43) hide show
  1. package/dist/cjs/HtmlInCanvas.d.ts +35 -0
  2. package/dist/cjs/HtmlInCanvas.js +7 -5
  3. package/dist/cjs/Img.d.ts +55 -3
  4. package/dist/cjs/Img.js +20 -5
  5. package/dist/cjs/Interactive.d.ts +74 -6
  6. package/dist/cjs/Interactive.js +17 -2
  7. package/dist/cjs/animated-image/AnimatedImage.d.ts +135 -1
  8. package/dist/cjs/animated-image/AnimatedImage.js +47 -9
  9. package/dist/cjs/animated-image/create-image-decoder.d.ts +9 -0
  10. package/dist/cjs/animated-image/create-image-decoder.js +26 -0
  11. package/dist/cjs/animated-image/decode-image.d.ts +1 -0
  12. package/dist/cjs/animated-image/decode-image.js +14 -16
  13. package/dist/cjs/animated-image/get-duration-in-seconds.d.ts +6 -0
  14. package/dist/cjs/animated-image/get-duration-in-seconds.js +31 -0
  15. package/dist/cjs/animated-image/props.d.ts +2 -2
  16. package/dist/cjs/audio/shared-audio-tags.js +18 -16
  17. package/dist/cjs/audio/shared-element-source-node.d.ts +2 -1
  18. package/dist/cjs/audio/shared-element-source-node.js +6 -2
  19. package/dist/cjs/canvas-image/CanvasImage.d.ts +53 -1
  20. package/dist/cjs/canvas-image/CanvasImage.js +17 -2
  21. package/dist/cjs/canvas-image/props.d.ts +2 -2
  22. package/dist/cjs/effects/Solid.d.ts +35 -0
  23. package/dist/cjs/effects/Solid.js +2 -0
  24. package/dist/cjs/interactivity-schema.d.ts +144 -32
  25. package/dist/cjs/interactivity-schema.js +44 -10
  26. package/dist/cjs/internals.d.ts +77 -26
  27. package/dist/cjs/internals.js +2 -1
  28. package/dist/cjs/no-react.d.ts +35 -6
  29. package/dist/cjs/series/index.d.ts +1 -1
  30. package/dist/cjs/series/index.js +1 -0
  31. package/dist/cjs/use-amplification.d.ts +1 -0
  32. package/dist/cjs/version.d.ts +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/index.mjs +367 -113
  35. package/dist/esm/no-react.mjs +42 -10
  36. package/dist/esm/version.mjs +1 -1
  37. package/package.json +2 -2
  38. package/dist/cjs/interpolate-translate.d.ts +0 -8
  39. package/dist/cjs/interpolate-translate.js +0 -70
  40. package/dist/cjs/sequence-field-schema.d.ts +0 -425
  41. package/dist/cjs/sequence-field-schema.js +0 -133
  42. package/dist/cjs/wrap-in-schema.d.ts +0 -20
  43. package/dist/cjs/wrap-in-schema.js +0 -203
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AnimatedImage = void 0;
3
+ exports.AnimatedImage = exports.animatedImageSchema = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const cancel_render_js_1 = require("../cancel-render.js");
7
7
  const use_memoized_effects_js_1 = require("../effects/use-memoized-effects.js");
8
8
  const enable_sequence_stack_traces_js_1 = require("../enable-sequence-stack-traces.js");
9
+ const freeze_js_1 = require("../freeze.js");
9
10
  const interactivity_schema_js_1 = require("../interactivity-schema.js");
10
11
  const Sequence_js_1 = require("../Sequence.js");
11
12
  const use_current_frame_js_1 = require("../use-current-frame.js");
12
13
  const use_delay_render_js_1 = require("../use-delay-render.js");
14
+ const use_premounting_js_1 = require("../use-premounting.js");
13
15
  const use_video_config_js_1 = require("../use-video-config.js");
14
16
  const with_interactivity_schema_js_1 = require("../with-interactivity-schema.js");
15
17
  const canvas_1 = require("./canvas");
@@ -17,7 +19,7 @@ const decode_image_js_1 = require("./decode-image.js");
17
19
  const get_current_time_js_1 = require("./get-current-time.js");
18
20
  const request_init_1 = require("./request-init");
19
21
  const resolve_image_source_1 = require("./resolve-image-source");
20
- const animatedImageSchema = {
22
+ exports.animatedImageSchema = {
21
23
  src: {
22
24
  type: 'asset',
23
25
  default: undefined,
@@ -25,6 +27,7 @@ const animatedImageSchema = {
25
27
  keyframable: false,
26
28
  },
27
29
  ...interactivity_schema_js_1.baseSchema,
30
+ ...interactivity_schema_js_1.premountSchema,
28
31
  playbackRate: {
29
32
  type: 'number',
30
33
  min: 0,
@@ -36,6 +39,8 @@ const animatedImageSchema = {
36
39
  keyframable: false,
37
40
  },
38
41
  ...interactivity_schema_js_1.transformSchema,
42
+ ...interactivity_schema_js_1.backgroundSchema,
43
+ ...interactivity_schema_js_1.borderSchema,
39
44
  };
40
45
  const getCanvasPropsFromSequenceProps = (props) => {
41
46
  const canvasProps = {};
@@ -78,6 +83,15 @@ const AnimatedImageContent = (0, react_1.forwardRef)(({ src, width, height, onEr
78
83
  const [initialLoopBehavior] = (0, react_1.useState)(() => loopBehavior);
79
84
  (0, react_1.useEffect)(() => {
80
85
  const controller = new AbortController();
86
+ let cancelled = false;
87
+ let continued = false;
88
+ const continueRenderOnce = () => {
89
+ if (continued) {
90
+ return;
91
+ }
92
+ continued = true;
93
+ continueRender(decodeHandle);
94
+ };
81
95
  (0, decode_image_js_1.decodeImage)({
82
96
  resolvedSrc,
83
97
  signal: controller.signal,
@@ -86,24 +100,33 @@ const AnimatedImageContent = (0, react_1.forwardRef)(({ src, width, height, onEr
86
100
  initialLoopBehavior,
87
101
  })
88
102
  .then((d) => {
103
+ if (cancelled) {
104
+ d.close();
105
+ return;
106
+ }
89
107
  setImageDecoder(d);
90
- continueRender(decodeHandle);
108
+ continueRenderOnce();
91
109
  })
92
110
  .catch((err) => {
111
+ if (cancelled) {
112
+ return;
113
+ }
93
114
  if (err.name === 'AbortError') {
94
- continueRender(decodeHandle);
115
+ continueRenderOnce();
95
116
  return;
96
117
  }
97
118
  if (onError) {
98
119
  onError === null || onError === void 0 ? void 0 : onError(err);
99
- continueRender(decodeHandle);
120
+ continueRenderOnce();
100
121
  }
101
122
  else {
102
123
  (0, cancel_render_js_1.cancelRender)(err);
103
124
  }
104
125
  });
105
126
  return () => {
127
+ cancelled = true;
106
128
  controller.abort();
129
+ continueRenderOnce();
107
130
  };
108
131
  }, [
109
132
  resolvedSrc,
@@ -113,6 +136,11 @@ const AnimatedImageContent = (0, react_1.forwardRef)(({ src, width, height, onEr
113
136
  initialLoopBehavior,
114
137
  continueRender,
115
138
  ]);
139
+ (0, react_1.useEffect)(() => {
140
+ return () => {
141
+ imageDecoder === null || imageDecoder === void 0 ? void 0 : imageDecoder.close();
142
+ };
143
+ }, [imageDecoder]);
116
144
  (0, react_1.useLayoutEffect)(() => {
117
145
  if (!imageDecoder) {
118
146
  return;
@@ -168,12 +196,22 @@ const AnimatedImageContent = (0, react_1.forwardRef)(({ src, width, height, onEr
168
196
  return (jsx_runtime_1.jsx(canvas_1.Canvas, { ref: ref, width: width, height: height, fit: fit, effects: memoizedEffects, ...props }));
169
197
  });
170
198
  AnimatedImageContent.displayName = 'AnimatedImageContent';
171
- const AnimatedImageInner = ({ src, width, height, onError, fit, playbackRate, loopBehavior, id, className, style, durationInFrames, requestInit, effects = [], controls, ref, ...sequenceProps }) => {
199
+ const AnimatedImageInner = ({ src, width, height, onError, fit, playbackRate, loopBehavior, id, className, style, durationInFrames, from, premountFor, postmountFor, styleWhilePremounted, styleWhilePostmounted, requestInit, effects = [], controls, ref, ...sequenceProps }) => {
172
200
  const actualRef = (0, react_1.useRef)(null);
173
201
  const memoizedEffectDefinitions = (0, use_memoized_effects_js_1.useMemoizedEffectDefinitions)(effects);
174
202
  (0, react_1.useImperativeHandle)(ref, () => {
175
203
  return actualRef.current;
176
204
  }, []);
205
+ const { effectivePostmountFor, effectivePremountFor, freezeFrame, isPremountingOrPostmounting, postmountingActive, premountingActive, premountingStyle, } = (0, use_premounting_js_1.usePremounting)({
206
+ from: from !== null && from !== void 0 ? from : 0,
207
+ durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity,
208
+ premountFor: premountFor !== null && premountFor !== void 0 ? premountFor : null,
209
+ postmountFor: postmountFor !== null && postmountFor !== void 0 ? postmountFor : null,
210
+ style: style !== null && style !== void 0 ? style : null,
211
+ styleWhilePremounted: styleWhilePremounted !== null && styleWhilePremounted !== void 0 ? styleWhilePremounted : null,
212
+ styleWhilePostmounted: styleWhilePostmounted !== null && styleWhilePostmounted !== void 0 ? styleWhilePostmounted : null,
213
+ hideWhilePremounted: 'display-none',
214
+ });
177
215
  const canvasProps = getCanvasPropsFromSequenceProps(sequenceProps);
178
216
  const animatedImageProps = {
179
217
  src,
@@ -185,17 +223,17 @@ const AnimatedImageInner = ({ src, width, height, onError, fit, playbackRate, lo
185
223
  loopBehavior,
186
224
  id,
187
225
  className,
188
- style,
226
+ style: premountingStyle !== null && premountingStyle !== void 0 ? premountingStyle : undefined,
189
227
  requestInit,
190
228
  ...canvasProps,
191
229
  };
192
- return (jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", durationInFrames: durationInFrames, name: "<AnimatedImage>", _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/animatedimage", controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, ...sequenceProps, outlineRef: actualRef, children: jsx_runtime_1.jsx(AnimatedImageContent, { ...animatedImageProps, ref: actualRef, effects: effects, controls: controls }) }));
230
+ return (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: 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, name: "<AnimatedImage>", _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/animatedimage", controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, ...sequenceProps, outlineRef: actualRef, children: jsx_runtime_1.jsx(AnimatedImageContent, { ...animatedImageProps, ref: actualRef, effects: effects, controls: controls }) }) }));
193
231
  };
194
232
  exports.AnimatedImage = (0, with_interactivity_schema_js_1.withInteractivitySchema)({
195
233
  Component: AnimatedImageInner,
196
234
  componentName: '<AnimatedImage>',
197
235
  componentIdentity: 'dev.remotion.remotion.AnimatedImage',
198
- schema: animatedImageSchema,
236
+ schema: exports.animatedImageSchema,
199
237
  supportsEffects: true,
200
238
  });
201
239
  exports.AnimatedImage.displayName = 'AnimatedImage';
@@ -0,0 +1,9 @@
1
+ export declare const createImageDecoder: ({ resolvedSrc, signal, requestInit, contentType, }: {
2
+ resolvedSrc: string;
3
+ signal: AbortSignal;
4
+ requestInit?: RequestInit | undefined;
5
+ contentType: string | null;
6
+ }) => Promise<{
7
+ decoder: ImageDecoder;
8
+ selectedTrack: ImageTrack;
9
+ }>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createImageDecoder = void 0;
4
+ const createImageDecoder = async ({ resolvedSrc, signal, requestInit, contentType, }) => {
5
+ var _a;
6
+ if (typeof ImageDecoder === 'undefined') {
7
+ throw new Error('Your browser does not support the WebCodecs ImageDecoder API.');
8
+ }
9
+ const response = await fetch(resolvedSrc, { ...requestInit, signal });
10
+ const { body } = response;
11
+ if (!body) {
12
+ throw new Error('Got no body');
13
+ }
14
+ const decoder = new ImageDecoder({
15
+ data: body,
16
+ type: (_a = contentType !== null && contentType !== void 0 ? contentType : response.headers.get('Content-Type')) !== null && _a !== void 0 ? _a : 'image/gif',
17
+ });
18
+ await Promise.all([decoder.completed, decoder.tracks.ready]);
19
+ const { selectedTrack } = decoder.tracks;
20
+ if (!selectedTrack) {
21
+ decoder.close();
22
+ throw new Error('No selected track');
23
+ }
24
+ return { decoder, selectedTrack };
25
+ };
26
+ exports.createImageDecoder = createImageDecoder;
@@ -5,6 +5,7 @@ export type AnimatedImageCacheItem = {
5
5
  frame: VideoFrame | null;
6
6
  };
7
7
  export type RemotionImageDecoder = {
8
+ close: () => void;
8
9
  getFrame: (i: number, loopBehavior: RemotionAnimatedImageLoopBehavior) => Promise<AnimatedImageCacheItem | null>;
9
10
  frameCount: number;
10
11
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decodeImage = void 0;
4
+ const create_image_decoder_1 = require("./create-image-decoder");
4
5
  const CACHE_SIZE = 5;
5
6
  const getActualTime = ({ loopBehavior, durationFound, timeInSec, }) => {
6
7
  return loopBehavior === 'loop'
@@ -10,23 +11,12 @@ const getActualTime = ({ loopBehavior, durationFound, timeInSec, }) => {
10
11
  : Math.min(timeInSec, durationFound || Infinity);
11
12
  };
12
13
  const decodeImage = async ({ resolvedSrc, signal, requestInit, currentTime, initialLoopBehavior, }) => {
13
- if (typeof ImageDecoder === 'undefined') {
14
- throw new Error('Your browser does not support the WebCodecs ImageDecoder API.');
15
- }
16
- const res = await fetch(resolvedSrc, { ...requestInit, signal });
17
- const { body } = res;
18
- if (!body) {
19
- throw new Error('Got no body');
20
- }
21
- const decoder = new ImageDecoder({
22
- data: body,
23
- type: res.headers.get('Content-Type') || 'image/gif',
14
+ const { decoder, selectedTrack } = await (0, create_image_decoder_1.createImageDecoder)({
15
+ resolvedSrc,
16
+ signal,
17
+ requestInit,
18
+ contentType: null,
24
19
  });
25
- await decoder.completed;
26
- const { selectedTrack } = decoder.tracks;
27
- if (!selectedTrack) {
28
- throw new Error('No selected track');
29
- }
30
20
  const cache = [];
31
21
  let durationFound = null;
32
22
  const getFrameByIndex = async (frameIndex) => {
@@ -138,6 +128,14 @@ const decodeImage = async ({ resolvedSrc, signal, requestInit, currentTime, init
138
128
  return closest;
139
129
  };
140
130
  return {
131
+ close: () => {
132
+ var _a;
133
+ for (const item of cache) {
134
+ (_a = item.frame) === null || _a === void 0 ? void 0 : _a.close();
135
+ item.frame = null;
136
+ }
137
+ decoder.close();
138
+ },
141
139
  getFrame,
142
140
  frameCount: selectedTrack.frameCount,
143
141
  };
@@ -0,0 +1,6 @@
1
+ export declare const getAnimatedImageDurationInSeconds: ({ resolvedSrc, signal, requestInit, contentType, }: {
2
+ resolvedSrc: string;
3
+ signal: AbortSignal;
4
+ requestInit?: RequestInit | undefined;
5
+ contentType: string | null;
6
+ }) => Promise<number>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAnimatedImageDurationInSeconds = void 0;
4
+ const create_image_decoder_1 = require("./create-image-decoder");
5
+ const getAnimatedImageDurationInSeconds = async ({ resolvedSrc, signal, requestInit, contentType, }) => {
6
+ const { decoder, selectedTrack } = await (0, create_image_decoder_1.createImageDecoder)({
7
+ resolvedSrc,
8
+ signal,
9
+ requestInit,
10
+ contentType,
11
+ });
12
+ try {
13
+ const { image } = await decoder.decode({
14
+ frameIndex: selectedTrack.frameCount - 1,
15
+ completeFramesOnly: true,
16
+ });
17
+ try {
18
+ if (image.duration === null) {
19
+ throw new Error('Could not determine animated image duration');
20
+ }
21
+ return (image.timestamp + image.duration) / 1000000;
22
+ }
23
+ finally {
24
+ image.close();
25
+ }
26
+ }
27
+ finally {
28
+ decoder.close();
29
+ }
30
+ };
31
+ exports.getAnimatedImageDurationInSeconds = getAnimatedImageDurationInSeconds;
@@ -1,6 +1,6 @@
1
1
  import type { ImageFit } from '../calculate-image-fit.js';
2
2
  import type { EffectsProp } from '../effects/effect-types.js';
3
- import type { InteractiveBaseProps } from '../Interactive.js';
3
+ import type { InteractiveBaseProps, InteractivePremountProps } from '../Interactive.js';
4
4
  export type RemotionAnimatedImageLoopBehavior = 'loop' | 'pause-after-finish' | 'clear-after-finish';
5
5
  export type AnimatedImageCanvasProps = React.AriaAttributes & Record<`data-${string}`, string | undefined>;
6
6
  export type RemotionAnimatedImageProps = {
@@ -16,7 +16,7 @@ export type RemotionAnimatedImageProps = {
16
16
  className?: string;
17
17
  requestInit?: RequestInit;
18
18
  } & AnimatedImageCanvasProps;
19
- export type AnimatedImageProps = InteractiveBaseProps & RemotionAnimatedImageProps & {
19
+ export type AnimatedImageProps = InteractiveBaseProps & InteractivePremountProps & RemotionAnimatedImageProps & {
20
20
  readonly effects?: EffectsProp;
21
21
  };
22
22
  export type AnimatedImageFillMode = ImageFit;
@@ -273,21 +273,22 @@ const SharedAudioTagsContextProvider = ({ children, numberOfAudioTags }) => {
273
273
  const audioCtx = (0, react_1.useContext)(exports.SharedAudioContext);
274
274
  const audioContext = (_a = audioCtx === null || audioCtx === void 0 ? void 0 : audioCtx.audioContext) !== null && _a !== void 0 ? _a : null;
275
275
  const resume = audioCtx === null || audioCtx === void 0 ? void 0 : audioCtx.resume;
276
- const refs = (0, react_1.useMemo)(() => {
276
+ const [refs] = (0, react_1.useState)(() => {
277
277
  return new Array(numberOfAudioTags).fill(true).map(() => {
278
278
  const ref = (0, react_1.createRef)();
279
279
  return {
280
280
  id: Math.random(),
281
281
  ref,
282
- mediaElementSourceNode: audioContext
283
- ? (0, shared_element_source_node_js_1.makeSharedElementSourceNode)({
284
- audioContext,
285
- ref,
286
- })
287
- : null,
282
+ mediaElementSourceNode: (0, shared_element_source_node_js_1.makeSharedElementSourceNode)({
283
+ audioContext,
284
+ ref,
285
+ }),
288
286
  };
289
287
  });
290
- }, [audioContext, numberOfAudioTags]);
288
+ });
289
+ for (const { mediaElementSourceNode } of refs) {
290
+ mediaElementSourceNode === null || mediaElementSourceNode === void 0 ? void 0 : mediaElementSourceNode.setAudioContext(audioContext);
291
+ }
291
292
  /**
292
293
  * Effects in React 18 fire twice, and we are looking for a way to only fire it once.
293
294
  * - useInsertionEffect only fires once. If it's available we are in React 18.
@@ -375,7 +376,7 @@ const SharedAudioTagsContextProvider = ({ children, numberOfAudioTags }) => {
375
376
  const cloned = [...takenAudios.current];
376
377
  const index = refs.findIndex((r) => r.id === id);
377
378
  if (index === -1) {
378
- throw new TypeError('Error occured in ');
379
+ throw new TypeError(`Unknown audio ref ${id}; refs: ${refs.map((r) => r.id).join(', ')}`);
379
380
  }
380
381
  cloned[index] = false;
381
382
  takenAudios.current = cloned;
@@ -464,23 +465,23 @@ const SharedAudioTagsContextProvider = ({ children, numberOfAudioTags }) => {
464
465
  exports.SharedAudioTagsContextProvider = SharedAudioTagsContextProvider;
465
466
  const useSharedAudio = ({ aud, audioId, premounting, postmounting, }) => {
466
467
  var _a;
468
+ var _b, _c;
467
469
  const audioCtx = (0, react_1.useContext)(exports.SharedAudioContext);
468
470
  const tagsCtx = (0, react_1.useContext)(exports.SharedAudioTagsContext);
469
471
  /**
470
472
  * We work around this in React 18 so an audio tag will only register itself once
471
473
  */
472
474
  const [elem] = (0, react_1.useState)(() => {
475
+ var _a;
473
476
  if (tagsCtx && tagsCtx.numberOfAudioTags > 0) {
474
477
  return tagsCtx.registerAudio({ aud, audioId, premounting, postmounting });
475
478
  }
476
479
  // numberOfSharedAudioTags is 0
477
480
  const el = react_1.default.createRef();
478
- const mediaElementSourceNode = (audioCtx === null || audioCtx === void 0 ? void 0 : audioCtx.audioContext)
479
- ? (0, shared_element_source_node_js_1.makeSharedElementSourceNode)({
480
- audioContext: audioCtx.audioContext,
481
- ref: el,
482
- })
483
- : null;
481
+ const mediaElementSourceNode = (0, shared_element_source_node_js_1.makeSharedElementSourceNode)({
482
+ audioContext: (_a = audioCtx === null || audioCtx === void 0 ? void 0 : audioCtx.audioContext) !== null && _a !== void 0 ? _a : null,
483
+ ref: el,
484
+ });
484
485
  return {
485
486
  el,
486
487
  id: Math.random(),
@@ -495,6 +496,7 @@ const useSharedAudio = ({ aud, audioId, premounting, postmounting, }) => {
495
496
  },
496
497
  };
497
498
  });
499
+ (_a = elem.mediaElementSourceNode) === null || _a === void 0 ? void 0 : _a.setAudioContext((_b = audioCtx === null || audioCtx === void 0 ? void 0 : audioCtx.audioContext) !== null && _b !== void 0 ? _b : null);
498
500
  /**
499
501
  * Effects in React 18 fire twice, and we are looking for a way to only fire it once.
500
502
  * - useInsertionEffect only fires once. If it's available we are in React 18.
@@ -502,7 +504,7 @@ const useSharedAudio = ({ aud, audioId, premounting, postmounting, }) => {
502
504
  *
503
505
  * Need to import it from React to fix React 17 ESM support.
504
506
  */
505
- const effectToUse = (_a = react_1.default.useInsertionEffect) !== null && _a !== void 0 ? _a : react_1.default.useLayoutEffect;
507
+ const effectToUse = (_c = react_1.default.useInsertionEffect) !== null && _c !== void 0 ? _c : react_1.default.useLayoutEffect;
506
508
  if (typeof document !== 'undefined') {
507
509
  effectToUse(() => {
508
510
  if (tagsCtx && tagsCtx.numberOfAudioTags > 0) {
@@ -1,7 +1,8 @@
1
1
  export declare const makeSharedElementSourceNode: ({ audioContext, ref, }: {
2
- audioContext: AudioContext;
2
+ audioContext: AudioContext | null;
3
3
  ref: import("react").RefObject<HTMLAudioElement | null>;
4
4
  }) => {
5
+ setAudioContext: (newAudioContext: AudioContext | null) => void;
5
6
  attemptToConnect: () => void;
6
7
  get: () => MediaElementAudioSourceNode;
7
8
  cleanup: () => void;
@@ -4,14 +4,18 @@ exports.makeSharedElementSourceNode = void 0;
4
4
  const makeSharedElementSourceNode = ({ audioContext, ref, }) => {
5
5
  let connected = null;
6
6
  let disposed = false;
7
+ let currentAudioContext = audioContext;
7
8
  // We must allow this to cleanup and create a new one due to strict mode.
8
9
  return {
10
+ setAudioContext: (newAudioContext) => {
11
+ currentAudioContext = newAudioContext;
12
+ },
9
13
  attemptToConnect: () => {
10
14
  if (disposed) {
11
15
  throw new Error('SharedElementSourceNode has been disposed');
12
16
  }
13
- if (!connected && ref.current) {
14
- const mediaElementSourceNode = audioContext.createMediaElementSource(ref.current);
17
+ if (!connected && ref.current && currentAudioContext) {
18
+ const mediaElementSourceNode = currentAudioContext.createMediaElementSource(ref.current);
15
19
  connected = mediaElementSourceNode;
16
20
  }
17
21
  },
@@ -37,6 +37,58 @@ export declare const canvasImageSchema: {
37
37
  readonly description: "Opacity";
38
38
  readonly hiddenFromList: false;
39
39
  };
40
+ readonly 'style.borderWidth': {
41
+ readonly type: "number";
42
+ readonly default: undefined;
43
+ readonly min: 0;
44
+ readonly step: 1;
45
+ readonly description: "Border width";
46
+ readonly hiddenFromList: false;
47
+ };
48
+ readonly 'style.borderStyle': {
49
+ readonly type: "enum";
50
+ readonly default: "none";
51
+ readonly description: "Border style";
52
+ readonly variants: {
53
+ readonly none: {};
54
+ readonly hidden: {};
55
+ readonly solid: {};
56
+ readonly dashed: {};
57
+ readonly dotted: {};
58
+ readonly double: {};
59
+ readonly groove: {};
60
+ readonly ridge: {};
61
+ readonly inset: {};
62
+ readonly outset: {};
63
+ };
64
+ };
65
+ readonly 'style.borderColor': {
66
+ readonly type: "color";
67
+ readonly default: undefined;
68
+ readonly description: "Border color";
69
+ };
70
+ readonly 'style.backgroundColor': {
71
+ readonly type: "color";
72
+ readonly default: "transparent";
73
+ readonly description: "Color";
74
+ };
75
+ readonly premountFor: {
76
+ readonly type: "number";
77
+ readonly default: 0;
78
+ readonly description: "Premount For";
79
+ readonly min: 0;
80
+ readonly step: 1;
81
+ readonly hiddenFromList: false;
82
+ readonly keyframable: false;
83
+ };
84
+ readonly postmountFor: {
85
+ readonly type: "number";
86
+ readonly default: 0;
87
+ readonly min: 0;
88
+ readonly step: 1;
89
+ readonly hiddenFromList: true;
90
+ readonly keyframable: false;
91
+ };
40
92
  readonly durationInFrames: {
41
93
  readonly type: "number";
42
94
  readonly default: undefined;
@@ -77,7 +129,7 @@ export declare const canvasImageSchema: {
77
129
  };
78
130
  };
79
131
  };
80
- export declare const CanvasImage: import("react").ComponentType<import("../Interactive.js").InteractiveBaseProps & {
132
+ export declare const CanvasImage: import("react").ComponentType<import("../Interactive.js").InteractiveBaseProps & import("../Interactive.js").InteractivePremountProps & {
81
133
  readonly stack?: string | undefined;
82
134
  } & CanvasImageCanvasProps & {
83
135
  readonly src: string;
@@ -8,6 +8,7 @@ const run_effect_chain_js_1 = require("../effects/run-effect-chain.js");
8
8
  const use_effect_chain_state_js_1 = require("../effects/use-effect-chain-state.js");
9
9
  const use_memoized_effects_js_1 = require("../effects/use-memoized-effects.js");
10
10
  const enable_sequence_stack_traces_js_1 = require("../enable-sequence-stack-traces.js");
11
+ const freeze_js_1 = require("../freeze.js");
11
12
  const interactivity_schema_js_1 = require("../interactivity-schema.js");
12
13
  const prefetch_js_1 = require("../prefetch.js");
13
14
  const Sequence_js_1 = require("../Sequence.js");
@@ -15,9 +16,11 @@ const SequenceContext_js_1 = require("../SequenceContext.js");
15
16
  const truncate_src_for_label_js_1 = require("../truncate-src-for-label.js");
16
17
  const use_buffer_state_js_1 = require("../use-buffer-state.js");
17
18
  const use_delay_render_js_1 = require("../use-delay-render.js");
19
+ const use_premounting_js_1 = require("../use-premounting.js");
18
20
  const with_interactivity_schema_js_1 = require("../with-interactivity-schema.js");
19
21
  exports.canvasImageSchema = {
20
22
  ...interactivity_schema_js_1.baseSchema,
23
+ ...interactivity_schema_js_1.premountSchema,
21
24
  fit: {
22
25
  type: 'enum',
23
26
  default: 'fill',
@@ -29,6 +32,8 @@ exports.canvasImageSchema = {
29
32
  },
30
33
  },
31
34
  ...interactivity_schema_js_1.transformSchema,
35
+ ...interactivity_schema_js_1.backgroundSchema,
36
+ ...interactivity_schema_js_1.borderSchema,
32
37
  };
33
38
  const makeAbortError = () => {
34
39
  if (typeof DOMException !== 'undefined') {
@@ -314,7 +319,7 @@ const CanvasImageContent = (0, react_1.forwardRef)(({ src, width, height, fit =
314
319
  return (jsx_runtime_1.jsx("canvas", { ...canvasProps, ref: canvasRef, width: width, height: height, className: className, style: style, id: id }));
315
320
  });
316
321
  CanvasImageContent.displayName = 'CanvasImageContent';
317
- const CanvasImageInner = (0, react_1.forwardRef)(({ src, width, height, fit, effects = [], className, style, id, onError, pauseWhenLoading, maxRetries, delayRenderRetries, delayRenderTimeoutInMilliseconds, durationInFrames, from, trimBefore, freeze, hidden, name, showInTimeline, stack, controls, _remotionInternalDocumentationLink, outlineRef, ...canvasProps }, ref) => {
322
+ const CanvasImageInner = (0, react_1.forwardRef)(({ src, width, height, fit, effects = [], className, style, id, onError, pauseWhenLoading, maxRetries, delayRenderRetries, delayRenderTimeoutInMilliseconds, durationInFrames, from, trimBefore, freeze, premountFor, postmountFor, styleWhilePremounted, styleWhilePostmounted, hidden, name, showInTimeline, stack, controls, _remotionInternalDocumentationLink, outlineRef, ...canvasProps }, ref) => {
318
323
  if (!src) {
319
324
  throw new Error('No "src" prop was passed to <CanvasImage>.');
320
325
  }
@@ -323,7 +328,17 @@ const CanvasImageInner = (0, react_1.forwardRef)(({ src, width, height, fit, eff
323
328
  (0, react_1.useImperativeHandle)(ref, () => {
324
329
  return actualRef.current;
325
330
  }, []);
326
- 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, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, name: name !== null && name !== void 0 ? name : '<CanvasImage>', _remotionInternalDocumentationLink: _remotionInternalDocumentationLink !== null && _remotionInternalDocumentationLink !== void 0 ? _remotionInternalDocumentationLink : 'https://www.remotion.dev/docs/canvasimage', controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalIsMedia: { type: 'image', src }, _remotionInternalStack: stack, outlineRef: outlineRef !== null && outlineRef !== void 0 ? outlineRef : actualRef, children: jsx_runtime_1.jsx(CanvasImageContent, { ref: actualRef, src: src, width: width, height: height, fit: fit, effects: effects, controls: controls, className: className, style: style, id: id, onError: onError, pauseWhenLoading: pauseWhenLoading, maxRetries: maxRetries, delayRenderRetries: delayRenderRetries, delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds, refForOutline: outlineRef !== null && outlineRef !== void 0 ? outlineRef : null, ...canvasProps }) }));
331
+ const { effectivePostmountFor, effectivePremountFor, freezeFrame, isPremountingOrPostmounting, postmountingActive, premountingActive, premountingStyle, } = (0, use_premounting_js_1.usePremounting)({
332
+ from: from !== null && from !== void 0 ? from : 0,
333
+ durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity,
334
+ premountFor: premountFor !== null && premountFor !== void 0 ? premountFor : null,
335
+ postmountFor: postmountFor !== null && postmountFor !== void 0 ? postmountFor : null,
336
+ style: style !== null && style !== void 0 ? style : null,
337
+ styleWhilePremounted: styleWhilePremounted !== null && styleWhilePremounted !== void 0 ? styleWhilePremounted : null,
338
+ styleWhilePostmounted: styleWhilePostmounted !== null && styleWhilePostmounted !== void 0 ? styleWhilePostmounted : null,
339
+ hideWhilePremounted: 'display-none',
340
+ });
341
+ return (jsx_runtime_1.jsx(freeze_js_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: 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, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, name: name !== null && name !== void 0 ? name : '<CanvasImage>', _remotionInternalDocumentationLink: _remotionInternalDocumentationLink !== null && _remotionInternalDocumentationLink !== void 0 ? _remotionInternalDocumentationLink : 'https://www.remotion.dev/docs/canvasimage', controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalIsMedia: { type: 'image', src }, _remotionInternalStack: stack, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, outlineRef: outlineRef !== null && outlineRef !== void 0 ? outlineRef : actualRef, children: jsx_runtime_1.jsx(CanvasImageContent, { ref: actualRef, src: src, width: width, height: height, fit: fit, effects: effects, controls: controls, className: className, style: premountingStyle !== null && premountingStyle !== void 0 ? premountingStyle : undefined, id: id, onError: onError, pauseWhenLoading: pauseWhenLoading, maxRetries: maxRetries, delayRenderRetries: delayRenderRetries, delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds, refForOutline: outlineRef !== null && outlineRef !== void 0 ? outlineRef : null, ...canvasProps }) }) }));
327
342
  });
328
343
  /*
329
344
  * @description Renders a static image to a `<canvas>` and applies Remotion effects.
@@ -1,8 +1,8 @@
1
1
  import type React from 'react';
2
2
  import type { ImageFit } from '../calculate-image-fit.js';
3
3
  import type { EffectsProp } from '../effects/effect-types.js';
4
- import type { InteractiveBaseProps } from '../Interactive.js';
5
- type CanvasImageSequenceProps = InteractiveBaseProps & {
4
+ import type { InteractiveBaseProps, InteractivePremountProps } from '../Interactive.js';
5
+ type CanvasImageSequenceProps = InteractiveBaseProps & InteractivePremountProps & {
6
6
  /**
7
7
  * @deprecated For internal use only.
8
8
  */
@@ -49,6 +49,41 @@ export declare const solidSchema: {
49
49
  readonly description: "Opacity";
50
50
  readonly hiddenFromList: false;
51
51
  };
52
+ readonly 'style.borderWidth': {
53
+ readonly type: "number";
54
+ readonly default: undefined;
55
+ readonly min: 0;
56
+ readonly step: 1;
57
+ readonly description: "Border width";
58
+ readonly hiddenFromList: false;
59
+ };
60
+ readonly 'style.borderStyle': {
61
+ readonly type: "enum";
62
+ readonly default: "none";
63
+ readonly description: "Border style";
64
+ readonly variants: {
65
+ readonly none: {};
66
+ readonly hidden: {};
67
+ readonly solid: {};
68
+ readonly dashed: {};
69
+ readonly dotted: {};
70
+ readonly double: {};
71
+ readonly groove: {};
72
+ readonly ridge: {};
73
+ readonly inset: {};
74
+ readonly outset: {};
75
+ };
76
+ };
77
+ readonly 'style.borderColor': {
78
+ readonly type: "color";
79
+ readonly default: undefined;
80
+ readonly description: "Border color";
81
+ };
82
+ readonly 'style.backgroundColor': {
83
+ readonly type: "color";
84
+ readonly default: "transparent";
85
+ readonly description: "Color";
86
+ };
52
87
  readonly durationInFrames: {
53
88
  readonly type: "number";
54
89
  readonly default: undefined;
@@ -55,6 +55,8 @@ exports.solidSchema = {
55
55
  hiddenFromList: false,
56
56
  },
57
57
  ...interactivity_schema_js_1.transformSchema,
58
+ ...interactivity_schema_js_1.backgroundSchema,
59
+ ...interactivity_schema_js_1.borderSchema,
58
60
  };
59
61
  const SolidInner = ({ color, width, height, effects = [], className, style, pixelDensity, overrideId, reference, }) => {
60
62
  const { delayRender, continueRender, cancelRender } = (0, use_delay_render_js_1.useDelayRender)();