remotion 4.0.496 → 4.0.498

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 (49) hide show
  1. package/dist/cjs/HtmlInCanvas.d.ts +35 -0
  2. package/dist/cjs/HtmlInCanvas.js +2 -0
  3. package/dist/cjs/Img.d.ts +55 -3
  4. package/dist/cjs/Img.js +22 -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/html5-audio.js +4 -4
  17. package/dist/cjs/audio/shared-audio-tags.js +18 -16
  18. package/dist/cjs/audio/shared-element-source-node.d.ts +2 -1
  19. package/dist/cjs/audio/shared-element-source-node.js +6 -2
  20. package/dist/cjs/canvas-image/CanvasImage.d.ts +53 -1
  21. package/dist/cjs/canvas-image/CanvasImage.js +17 -2
  22. package/dist/cjs/canvas-image/props.d.ts +2 -2
  23. package/dist/cjs/effects/Solid.d.ts +35 -0
  24. package/dist/cjs/effects/Solid.js +2 -0
  25. package/dist/cjs/interactivity-schema.d.ts +144 -32
  26. package/dist/cjs/interactivity-schema.js +44 -10
  27. package/dist/cjs/internals.d.ts +77 -26
  28. package/dist/cjs/internals.js +2 -1
  29. package/dist/cjs/no-react.d.ts +36 -6
  30. package/dist/cjs/no-react.js +2 -1
  31. package/dist/cjs/series/index.d.ts +1 -1
  32. package/dist/cjs/series/index.js +1 -0
  33. package/dist/cjs/use-amplification.d.ts +1 -0
  34. package/dist/cjs/v5-flag.d.ts +1 -0
  35. package/dist/cjs/v5-flag.js +5 -1
  36. package/dist/cjs/version.d.ts +1 -1
  37. package/dist/cjs/version.js +1 -1
  38. package/dist/cjs/video/OffthreadVideo.js +6 -4
  39. package/dist/cjs/video/html5-video.js +4 -4
  40. package/dist/esm/index.mjs +379 -119
  41. package/dist/esm/no-react.mjs +44 -11
  42. package/dist/esm/version.mjs +1 -1
  43. package/package.json +2 -2
  44. package/dist/cjs/interpolate-translate.d.ts +0 -8
  45. package/dist/cjs/interpolate-translate.js +0 -70
  46. package/dist/cjs/sequence-field-schema.d.ts +0 -425
  47. package/dist/cjs/sequence-field-schema.js +0 -133
  48. package/dist/cjs/wrap-in-schema.d.ts +0 -20
  49. package/dist/cjs/wrap-in-schema.js +0 -203
@@ -1310,7 +1310,7 @@ var getSingleChildComponent = (children) => {
1310
1310
  };
1311
1311
 
1312
1312
  // src/version.ts
1313
- var VERSION = "4.0.496";
1313
+ var VERSION = "4.0.498";
1314
1314
 
1315
1315
  // src/multiple-versions-warning.ts
1316
1316
  var checkMultipleRemotionVersions = () => {
@@ -1847,6 +1847,45 @@ var textSchema = {
1847
1847
  hiddenFromList: false
1848
1848
  }
1849
1849
  };
1850
+ var borderSchema = {
1851
+ "style.borderWidth": {
1852
+ type: "number",
1853
+ default: undefined,
1854
+ min: 0,
1855
+ step: 1,
1856
+ description: "Border width",
1857
+ hiddenFromList: false
1858
+ },
1859
+ "style.borderStyle": {
1860
+ type: "enum",
1861
+ default: "none",
1862
+ description: "Border style",
1863
+ variants: {
1864
+ none: {},
1865
+ hidden: {},
1866
+ solid: {},
1867
+ dashed: {},
1868
+ dotted: {},
1869
+ double: {},
1870
+ groove: {},
1871
+ ridge: {},
1872
+ inset: {},
1873
+ outset: {}
1874
+ }
1875
+ },
1876
+ "style.borderColor": {
1877
+ type: "color",
1878
+ default: undefined,
1879
+ description: "Border color"
1880
+ }
1881
+ };
1882
+ var backgroundSchema = {
1883
+ "style.backgroundColor": {
1884
+ type: "color",
1885
+ default: "transparent",
1886
+ description: "Color"
1887
+ }
1888
+ };
1850
1889
  var textContentSchema = {
1851
1890
  children: {
1852
1891
  type: "text-content",
@@ -1874,20 +1913,13 @@ var premountSchema = {
1874
1913
  keyframable: false
1875
1914
  }
1876
1915
  };
1877
- var premountStyleSchema = {
1878
- styleWhilePremounted: {
1879
- type: "hidden"
1880
- },
1881
- styleWhilePostmounted: {
1882
- type: "hidden"
1883
- }
1884
- };
1885
1916
  var sequencePremountSchema = {
1886
- ...premountSchema,
1887
- ...premountStyleSchema
1917
+ ...premountSchema
1888
1918
  };
1889
1919
  var sequenceStyleSchema = {
1890
1920
  ...transformSchema,
1921
+ ...backgroundSchema,
1922
+ ...borderSchema,
1891
1923
  ...sequencePremountSchema
1892
1924
  };
1893
1925
  var hiddenField = {
@@ -2191,6 +2223,9 @@ var PremountContext = createContext15({
2191
2223
 
2192
2224
  // src/v5-flag.ts
2193
2225
  var ENABLE_V5_BREAKING_CHANGES = false;
2226
+ var resolveV5Default = (value) => {
2227
+ return value ?? ENABLE_V5_BREAKING_CHANGES;
2228
+ };
2194
2229
 
2195
2230
  // src/use-premounting.ts
2196
2231
  var usePremounting = ({
@@ -5319,39 +5354,56 @@ var CanvasRefForwardingFunction = ({ width, height, fit, className, style, effec
5319
5354
  };
5320
5355
  var Canvas = React16.forwardRef(CanvasRefForwardingFunction);
5321
5356
 
5322
- // src/animated-image/decode-image.ts
5323
- var CACHE_SIZE = 5;
5324
- var getActualTime = ({
5325
- loopBehavior,
5326
- durationFound,
5327
- timeInSec
5328
- }) => {
5329
- return loopBehavior === "loop" ? durationFound ? timeInSec % durationFound : timeInSec : Math.min(timeInSec, durationFound || Infinity);
5330
- };
5331
- var decodeImage = async ({
5357
+ // src/animated-image/create-image-decoder.ts
5358
+ var createImageDecoder = async ({
5332
5359
  resolvedSrc,
5333
5360
  signal,
5334
5361
  requestInit,
5335
- currentTime,
5336
- initialLoopBehavior
5362
+ contentType
5337
5363
  }) => {
5338
5364
  if (typeof ImageDecoder === "undefined") {
5339
5365
  throw new Error("Your browser does not support the WebCodecs ImageDecoder API.");
5340
5366
  }
5341
- const res = await fetch(resolvedSrc, { ...requestInit, signal });
5342
- const { body } = res;
5367
+ const response = await fetch(resolvedSrc, { ...requestInit, signal });
5368
+ const { body } = response;
5343
5369
  if (!body) {
5344
5370
  throw new Error("Got no body");
5345
5371
  }
5346
5372
  const decoder = new ImageDecoder({
5347
5373
  data: body,
5348
- type: res.headers.get("Content-Type") || "image/gif"
5374
+ type: contentType ?? response.headers.get("Content-Type") ?? "image/gif"
5349
5375
  });
5350
- await decoder.completed;
5376
+ await Promise.all([decoder.completed, decoder.tracks.ready]);
5351
5377
  const { selectedTrack } = decoder.tracks;
5352
5378
  if (!selectedTrack) {
5379
+ decoder.close();
5353
5380
  throw new Error("No selected track");
5354
5381
  }
5382
+ return { decoder, selectedTrack };
5383
+ };
5384
+
5385
+ // src/animated-image/decode-image.ts
5386
+ var CACHE_SIZE = 5;
5387
+ var getActualTime = ({
5388
+ loopBehavior,
5389
+ durationFound,
5390
+ timeInSec
5391
+ }) => {
5392
+ return loopBehavior === "loop" ? durationFound ? timeInSec % durationFound : timeInSec : Math.min(timeInSec, durationFound || Infinity);
5393
+ };
5394
+ var decodeImage = async ({
5395
+ resolvedSrc,
5396
+ signal,
5397
+ requestInit,
5398
+ currentTime,
5399
+ initialLoopBehavior
5400
+ }) => {
5401
+ const { decoder, selectedTrack } = await createImageDecoder({
5402
+ resolvedSrc,
5403
+ signal,
5404
+ requestInit,
5405
+ contentType: null
5406
+ });
5355
5407
  const cache2 = [];
5356
5408
  let durationFound = null;
5357
5409
  const getFrameByIndex = async (frameIndex) => {
@@ -5457,6 +5509,13 @@ var decodeImage = async ({
5457
5509
  return closest;
5458
5510
  };
5459
5511
  return {
5512
+ close: () => {
5513
+ for (const item of cache2) {
5514
+ item.frame?.close();
5515
+ item.frame = null;
5516
+ }
5517
+ decoder.close();
5518
+ },
5460
5519
  getFrame,
5461
5520
  frameCount: selectedTrack.frameCount
5462
5521
  };
@@ -5503,6 +5562,7 @@ var animatedImageSchema = {
5503
5562
  keyframable: false
5504
5563
  },
5505
5564
  ...baseSchema,
5565
+ ...premountSchema,
5506
5566
  playbackRate: {
5507
5567
  type: "number",
5508
5568
  min: 0,
@@ -5513,7 +5573,9 @@ var animatedImageSchema = {
5513
5573
  hiddenFromList: false,
5514
5574
  keyframable: false
5515
5575
  },
5516
- ...transformSchema
5576
+ ...transformSchema,
5577
+ ...backgroundSchema,
5578
+ ...borderSchema
5517
5579
  };
5518
5580
  var getCanvasPropsFromSequenceProps = (props) => {
5519
5581
  const canvasProps = {};
@@ -5565,6 +5627,15 @@ var AnimatedImageContent = forwardRef4(({
5565
5627
  const [initialLoopBehavior] = useState6(() => loopBehavior);
5566
5628
  useEffect5(() => {
5567
5629
  const controller = new AbortController;
5630
+ let cancelled = false;
5631
+ let continued = false;
5632
+ const continueRenderOnce = () => {
5633
+ if (continued) {
5634
+ return;
5635
+ }
5636
+ continued = true;
5637
+ continueRender2(decodeHandle);
5638
+ };
5568
5639
  decodeImage({
5569
5640
  resolvedSrc,
5570
5641
  signal: controller.signal,
@@ -5572,22 +5643,31 @@ var AnimatedImageContent = forwardRef4(({
5572
5643
  currentTime: currentTimeRef.current,
5573
5644
  initialLoopBehavior
5574
5645
  }).then((d) => {
5646
+ if (cancelled) {
5647
+ d.close();
5648
+ return;
5649
+ }
5575
5650
  setImageDecoder(d);
5576
- continueRender2(decodeHandle);
5651
+ continueRenderOnce();
5577
5652
  }).catch((err) => {
5653
+ if (cancelled) {
5654
+ return;
5655
+ }
5578
5656
  if (err.name === "AbortError") {
5579
- continueRender2(decodeHandle);
5657
+ continueRenderOnce();
5580
5658
  return;
5581
5659
  }
5582
5660
  if (onError) {
5583
5661
  onError?.(err);
5584
- continueRender2(decodeHandle);
5662
+ continueRenderOnce();
5585
5663
  } else {
5586
5664
  cancelRender(err);
5587
5665
  }
5588
5666
  });
5589
5667
  return () => {
5668
+ cancelled = true;
5590
5669
  controller.abort();
5670
+ continueRenderOnce();
5591
5671
  };
5592
5672
  }, [
5593
5673
  resolvedSrc,
@@ -5597,6 +5677,11 @@ var AnimatedImageContent = forwardRef4(({
5597
5677
  initialLoopBehavior,
5598
5678
  continueRender2
5599
5679
  ]);
5680
+ useEffect5(() => {
5681
+ return () => {
5682
+ imageDecoder?.close();
5683
+ };
5684
+ }, [imageDecoder]);
5600
5685
  useLayoutEffect2(() => {
5601
5686
  if (!imageDecoder) {
5602
5687
  return;
@@ -5666,6 +5751,11 @@ var AnimatedImageInner = ({
5666
5751
  className,
5667
5752
  style,
5668
5753
  durationInFrames,
5754
+ from,
5755
+ premountFor,
5756
+ postmountFor,
5757
+ styleWhilePremounted,
5758
+ styleWhilePostmounted,
5669
5759
  requestInit,
5670
5760
  effects = [],
5671
5761
  controls,
@@ -5677,6 +5767,24 @@ var AnimatedImageInner = ({
5677
5767
  useImperativeHandle2(ref, () => {
5678
5768
  return actualRef.current;
5679
5769
  }, []);
5770
+ const {
5771
+ effectivePostmountFor,
5772
+ effectivePremountFor,
5773
+ freezeFrame,
5774
+ isPremountingOrPostmounting,
5775
+ postmountingActive,
5776
+ premountingActive,
5777
+ premountingStyle
5778
+ } = usePremounting({
5779
+ from: from ?? 0,
5780
+ durationInFrames: durationInFrames ?? Infinity,
5781
+ premountFor: premountFor ?? null,
5782
+ postmountFor: postmountFor ?? null,
5783
+ style: style ?? null,
5784
+ styleWhilePremounted: styleWhilePremounted ?? null,
5785
+ styleWhilePostmounted: styleWhilePostmounted ?? null,
5786
+ hideWhilePremounted: "display-none"
5787
+ });
5680
5788
  const canvasProps = getCanvasPropsFromSequenceProps(sequenceProps);
5681
5789
  const animatedImageProps = {
5682
5790
  src,
@@ -5688,24 +5796,33 @@ var AnimatedImageInner = ({
5688
5796
  loopBehavior,
5689
5797
  id,
5690
5798
  className,
5691
- style,
5799
+ style: premountingStyle ?? undefined,
5692
5800
  requestInit,
5693
5801
  ...canvasProps
5694
5802
  };
5695
- return /* @__PURE__ */ jsx14(Sequence, {
5696
- layout: "none",
5697
- durationInFrames,
5698
- name: "<AnimatedImage>",
5699
- _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/animatedimage",
5700
- controls,
5701
- _remotionInternalEffects: memoizedEffectDefinitions,
5702
- ...sequenceProps,
5703
- outlineRef: actualRef,
5704
- children: /* @__PURE__ */ jsx14(AnimatedImageContent, {
5705
- ...animatedImageProps,
5706
- ref: actualRef,
5707
- effects,
5708
- controls
5803
+ return /* @__PURE__ */ jsx14(Freeze, {
5804
+ frame: freezeFrame,
5805
+ active: isPremountingOrPostmounting,
5806
+ children: /* @__PURE__ */ jsx14(Sequence, {
5807
+ layout: "none",
5808
+ from: from ?? 0,
5809
+ durationInFrames: durationInFrames ?? Infinity,
5810
+ name: "<AnimatedImage>",
5811
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/animatedimage",
5812
+ controls,
5813
+ _remotionInternalEffects: memoizedEffectDefinitions,
5814
+ _remotionInternalPremountDisplay: effectivePremountFor || null,
5815
+ _remotionInternalPostmountDisplay: effectivePostmountFor || null,
5816
+ _remotionInternalIsPremounting: premountingActive,
5817
+ _remotionInternalIsPostmounting: postmountingActive,
5818
+ ...sequenceProps,
5819
+ outlineRef: actualRef,
5820
+ children: /* @__PURE__ */ jsx14(AnimatedImageContent, {
5821
+ ...animatedImageProps,
5822
+ ref: actualRef,
5823
+ effects,
5824
+ controls
5825
+ })
5709
5826
  })
5710
5827
  });
5711
5828
  };
@@ -6504,13 +6621,17 @@ var makeSharedElementSourceNode = ({
6504
6621
  }) => {
6505
6622
  let connected = null;
6506
6623
  let disposed = false;
6624
+ let currentAudioContext = audioContext;
6507
6625
  return {
6626
+ setAudioContext: (newAudioContext) => {
6627
+ currentAudioContext = newAudioContext;
6628
+ },
6508
6629
  attemptToConnect: () => {
6509
6630
  if (disposed) {
6510
6631
  throw new Error("SharedElementSourceNode has been disposed");
6511
6632
  }
6512
- if (!connected && ref.current) {
6513
- const mediaElementSourceNode = audioContext.createMediaElementSource(ref.current);
6633
+ if (!connected && ref.current && currentAudioContext) {
6634
+ const mediaElementSourceNode = currentAudioContext.createMediaElementSource(ref.current);
6514
6635
  connected = mediaElementSourceNode;
6515
6636
  }
6516
6637
  },
@@ -6846,19 +6967,22 @@ var SharedAudioTagsContextProvider = ({ children, numberOfAudioTags }) => {
6846
6967
  const audioCtx = useContext21(SharedAudioContext);
6847
6968
  const audioContext = audioCtx?.audioContext ?? null;
6848
6969
  const resume = audioCtx?.resume;
6849
- const refs = useMemo22(() => {
6970
+ const [refs] = useState10(() => {
6850
6971
  return new Array(numberOfAudioTags).fill(true).map(() => {
6851
6972
  const ref = createRef2();
6852
6973
  return {
6853
6974
  id: Math.random(),
6854
6975
  ref,
6855
- mediaElementSourceNode: audioContext ? makeSharedElementSourceNode({
6976
+ mediaElementSourceNode: makeSharedElementSourceNode({
6856
6977
  audioContext,
6857
6978
  ref
6858
- }) : null
6979
+ })
6859
6980
  };
6860
6981
  });
6861
- }, [audioContext, numberOfAudioTags]);
6982
+ });
6983
+ for (const { mediaElementSourceNode } of refs) {
6984
+ mediaElementSourceNode?.setAudioContext(audioContext);
6985
+ }
6862
6986
  const effectToUse = React20.useInsertionEffect ?? React20.useLayoutEffect;
6863
6987
  effectToUse(() => {
6864
6988
  return () => {
@@ -6926,7 +7050,7 @@ var SharedAudioTagsContextProvider = ({ children, numberOfAudioTags }) => {
6926
7050
  const cloned = [...takenAudios.current];
6927
7051
  const index = refs.findIndex((r) => r.id === id);
6928
7052
  if (index === -1) {
6929
- throw new TypeError("Error occured in ");
7053
+ throw new TypeError(`Unknown audio ref ${id}; refs: ${refs.map((r) => r.id).join(", ")}`);
6930
7054
  }
6931
7055
  cloned[index] = false;
6932
7056
  takenAudios.current = cloned;
@@ -7030,10 +7154,10 @@ var useSharedAudio = ({
7030
7154
  return tagsCtx.registerAudio({ aud, audioId, premounting, postmounting });
7031
7155
  }
7032
7156
  const el = React20.createRef();
7033
- const mediaElementSourceNode = audioCtx?.audioContext ? makeSharedElementSourceNode({
7034
- audioContext: audioCtx.audioContext,
7157
+ const mediaElementSourceNode = makeSharedElementSourceNode({
7158
+ audioContext: audioCtx?.audioContext ?? null,
7035
7159
  ref: el
7036
- }) : null;
7160
+ });
7037
7161
  return {
7038
7162
  el,
7039
7163
  id: Math.random(),
@@ -7048,6 +7172,7 @@ var useSharedAudio = ({
7048
7172
  }
7049
7173
  };
7050
7174
  });
7175
+ elem.mediaElementSourceNode?.setAudioContext(audioCtx?.audioContext ?? null);
7051
7176
  const effectToUse = React20.useInsertionEffect ?? React20.useLayoutEffect;
7052
7177
  if (typeof document !== "undefined") {
7053
7178
  effectToUse(() => {
@@ -8856,6 +8981,7 @@ var AudioRefForwardingFunction = (props, ref) => {
8856
8981
  const { loop, freeze: _freeze, ...propsOtherThanLoop } = propsWithFreeze;
8857
8982
  const { fps } = useVideoConfig();
8858
8983
  const environment = useRemotionEnvironment();
8984
+ const shouldPauseWhenBuffering = resolveV5Default(pauseWhenBuffering);
8859
8985
  if (environment.isClientSideRendering) {
8860
8986
  throw new Error("<Html5Audio> is not supported in @remotion/web-renderer. Use <Audio> from @remotion/media instead. See https://remotion.dev/docs/client-side-rendering/limitations");
8861
8987
  }
@@ -8925,7 +9051,7 @@ var AudioRefForwardingFunction = (props, ref) => {
8925
9051
  name,
8926
9052
  children: /* @__PURE__ */ jsx23(Html5Audio, {
8927
9053
  _remotionInternalNeedsDurationCalculation: Boolean(loop),
8928
- pauseWhenBuffering: pauseWhenBuffering ?? false,
9054
+ pauseWhenBuffering: shouldPauseWhenBuffering,
8929
9055
  ...otherProps,
8930
9056
  ref
8931
9057
  })
@@ -8953,7 +9079,7 @@ var AudioRefForwardingFunction = (props, ref) => {
8953
9079
  ref,
8954
9080
  onNativeError: onError,
8955
9081
  onDuration,
8956
- pauseWhenBuffering: pauseWhenBuffering ?? false,
9082
+ pauseWhenBuffering: shouldPauseWhenBuffering,
8957
9083
  _remotionInternalNeedsDurationCalculation: Boolean(loop),
8958
9084
  showInTimeline: showInTimeline ?? true
8959
9085
  });
@@ -9013,7 +9139,9 @@ var solidSchema = {
9013
9139
  description: "Pixel density",
9014
9140
  hiddenFromList: false
9015
9141
  },
9016
- ...transformSchema
9142
+ ...transformSchema,
9143
+ ...backgroundSchema,
9144
+ ...borderSchema
9017
9145
  };
9018
9146
  var SolidInner = ({
9019
9147
  color,
@@ -9578,7 +9706,9 @@ var htmlInCanvasSchema = {
9578
9706
  description: "Pixel density",
9579
9707
  hiddenFromList: false
9580
9708
  },
9581
- ...transformSchema
9709
+ ...transformSchema,
9710
+ ...backgroundSchema,
9711
+ ...borderSchema
9582
9712
  };
9583
9713
  var HtmlInCanvasWrapped = withInteractivitySchema({
9584
9714
  Component: HtmlInCanvasInner,
@@ -9616,6 +9746,7 @@ function truncateSrcForLabel(src) {
9616
9746
  import { jsx as jsx26 } from "react/jsx-runtime";
9617
9747
  var canvasImageSchema = {
9618
9748
  ...baseSchema,
9749
+ ...premountSchema,
9619
9750
  fit: {
9620
9751
  type: "enum",
9621
9752
  default: "fill",
@@ -9626,7 +9757,9 @@ var canvasImageSchema = {
9626
9757
  cover: {}
9627
9758
  }
9628
9759
  },
9629
- ...transformSchema
9760
+ ...transformSchema,
9761
+ ...backgroundSchema,
9762
+ ...borderSchema
9630
9763
  };
9631
9764
  var makeAbortError = () => {
9632
9765
  if (typeof DOMException !== "undefined") {
@@ -9950,6 +10083,10 @@ var CanvasImageInner = forwardRef10(({
9950
10083
  from,
9951
10084
  trimBefore,
9952
10085
  freeze,
10086
+ premountFor,
10087
+ postmountFor,
10088
+ styleWhilePremounted,
10089
+ styleWhilePostmounted,
9953
10090
  hidden,
9954
10091
  name,
9955
10092
  showInTimeline,
@@ -9967,39 +10104,65 @@ var CanvasImageInner = forwardRef10(({
9967
10104
  useImperativeHandle7(ref, () => {
9968
10105
  return actualRef.current;
9969
10106
  }, []);
9970
- return /* @__PURE__ */ jsx26(Sequence, {
9971
- layout: "none",
10107
+ const {
10108
+ effectivePostmountFor,
10109
+ effectivePremountFor,
10110
+ freezeFrame,
10111
+ isPremountingOrPostmounting,
10112
+ postmountingActive,
10113
+ premountingActive,
10114
+ premountingStyle
10115
+ } = usePremounting({
9972
10116
  from: from ?? 0,
9973
- trimBefore,
9974
10117
  durationInFrames: durationInFrames ?? Infinity,
9975
- freeze,
9976
- hidden,
9977
- showInTimeline: showInTimeline ?? true,
9978
- name: name ?? "<CanvasImage>",
9979
- _remotionInternalDocumentationLink: _remotionInternalDocumentationLink ?? "https://www.remotion.dev/docs/canvasimage",
9980
- controls,
9981
- _remotionInternalEffects: memoizedEffectDefinitions,
9982
- _remotionInternalIsMedia: { type: "image", src },
9983
- _remotionInternalStack: stack,
9984
- outlineRef: outlineRef ?? actualRef,
9985
- children: /* @__PURE__ */ jsx26(CanvasImageContent, {
9986
- ref: actualRef,
9987
- src,
9988
- width,
9989
- height,
9990
- fit,
9991
- effects,
10118
+ premountFor: premountFor ?? null,
10119
+ postmountFor: postmountFor ?? null,
10120
+ style: style ?? null,
10121
+ styleWhilePremounted: styleWhilePremounted ?? null,
10122
+ styleWhilePostmounted: styleWhilePostmounted ?? null,
10123
+ hideWhilePremounted: "display-none"
10124
+ });
10125
+ return /* @__PURE__ */ jsx26(Freeze, {
10126
+ frame: freezeFrame,
10127
+ active: isPremountingOrPostmounting,
10128
+ children: /* @__PURE__ */ jsx26(Sequence, {
10129
+ layout: "none",
10130
+ from: from ?? 0,
10131
+ trimBefore,
10132
+ durationInFrames: durationInFrames ?? Infinity,
10133
+ freeze,
10134
+ hidden,
10135
+ showInTimeline: showInTimeline ?? true,
10136
+ name: name ?? "<CanvasImage>",
10137
+ _remotionInternalDocumentationLink: _remotionInternalDocumentationLink ?? "https://www.remotion.dev/docs/canvasimage",
9992
10138
  controls,
9993
- className,
9994
- style,
9995
- id,
9996
- onError,
9997
- pauseWhenLoading,
9998
- maxRetries,
9999
- delayRenderRetries,
10000
- delayRenderTimeoutInMilliseconds,
10001
- refForOutline: outlineRef ?? null,
10002
- ...canvasProps
10139
+ _remotionInternalEffects: memoizedEffectDefinitions,
10140
+ _remotionInternalIsMedia: { type: "image", src },
10141
+ _remotionInternalStack: stack,
10142
+ _remotionInternalPremountDisplay: effectivePremountFor || null,
10143
+ _remotionInternalPostmountDisplay: effectivePostmountFor || null,
10144
+ _remotionInternalIsPremounting: premountingActive,
10145
+ _remotionInternalIsPostmounting: postmountingActive,
10146
+ outlineRef: outlineRef ?? actualRef,
10147
+ children: /* @__PURE__ */ jsx26(CanvasImageContent, {
10148
+ ref: actualRef,
10149
+ src,
10150
+ width,
10151
+ height,
10152
+ fit,
10153
+ effects,
10154
+ controls,
10155
+ className,
10156
+ style: premountingStyle ?? undefined,
10157
+ id,
10158
+ onError,
10159
+ pauseWhenLoading,
10160
+ maxRetries,
10161
+ delayRenderRetries,
10162
+ delayRenderTimeoutInMilliseconds,
10163
+ refForOutline: outlineRef ?? null,
10164
+ ...canvasProps
10165
+ })
10003
10166
  })
10004
10167
  });
10005
10168
  });
@@ -10259,6 +10422,11 @@ var NativeImgInner = ({
10259
10422
  trimBefore,
10260
10423
  durationInFrames,
10261
10424
  freeze,
10425
+ premountFor,
10426
+ postmountFor,
10427
+ style,
10428
+ styleWhilePremounted,
10429
+ styleWhilePostmounted,
10262
10430
  controls,
10263
10431
  outlineRef: refForOutline,
10264
10432
  ...props2
@@ -10266,24 +10434,51 @@ var NativeImgInner = ({
10266
10434
  if (!src) {
10267
10435
  throw new Error('No "src" prop was passed to <Img>.');
10268
10436
  }
10269
- return /* @__PURE__ */ jsx28(Sequence, {
10270
- layout: "none",
10437
+ const {
10438
+ effectivePostmountFor,
10439
+ effectivePremountFor,
10440
+ freezeFrame,
10441
+ isPremountingOrPostmounting,
10442
+ postmountingActive,
10443
+ premountingActive,
10444
+ premountingStyle
10445
+ } = usePremounting({
10271
10446
  from: from ?? 0,
10272
- trimBefore,
10273
10447
  durationInFrames: durationInFrames ?? Infinity,
10274
- freeze,
10275
- _remotionInternalStack: stack,
10276
- _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/img",
10277
- _remotionInternalIsMedia: { type: "image", src },
10278
- name: name ?? "<Img>",
10279
- controls,
10280
- showInTimeline: showInTimeline ?? true,
10281
- hidden,
10282
- outlineRef: refForOutline,
10283
- children: /* @__PURE__ */ jsx28(ImgContent, {
10284
- src,
10285
- refForOutline,
10286
- ...props2
10448
+ premountFor: premountFor ?? null,
10449
+ postmountFor: postmountFor ?? null,
10450
+ style: style ?? null,
10451
+ styleWhilePremounted: styleWhilePremounted ?? null,
10452
+ styleWhilePostmounted: styleWhilePostmounted ?? null,
10453
+ hideWhilePremounted: "display-none"
10454
+ });
10455
+ return /* @__PURE__ */ jsx28(Freeze, {
10456
+ frame: freezeFrame,
10457
+ active: isPremountingOrPostmounting,
10458
+ children: /* @__PURE__ */ jsx28(Sequence, {
10459
+ layout: "none",
10460
+ from: from ?? 0,
10461
+ trimBefore,
10462
+ durationInFrames: durationInFrames ?? Infinity,
10463
+ freeze,
10464
+ _remotionInternalStack: stack,
10465
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/img",
10466
+ _remotionInternalIsMedia: { type: "image", src },
10467
+ _remotionInternalPremountDisplay: effectivePremountFor || null,
10468
+ _remotionInternalPostmountDisplay: effectivePostmountFor || null,
10469
+ _remotionInternalIsPremounting: premountingActive,
10470
+ _remotionInternalIsPostmounting: postmountingActive,
10471
+ name: name ?? "<Img>",
10472
+ controls,
10473
+ showInTimeline: showInTimeline ?? true,
10474
+ hidden,
10475
+ outlineRef: refForOutline,
10476
+ children: /* @__PURE__ */ jsx28(ImgContent, {
10477
+ src,
10478
+ refForOutline,
10479
+ style: premountingStyle ?? undefined,
10480
+ ...props2
10481
+ })
10287
10482
  })
10288
10483
  });
10289
10484
  };
@@ -10296,7 +10491,10 @@ var imgSchema = {
10296
10491
  keyframable: false
10297
10492
  },
10298
10493
  ...baseSchema,
10299
- ...transformSchema
10494
+ ...premountSchema,
10495
+ ...transformSchema,
10496
+ ...backgroundSchema,
10497
+ ...borderSchema
10300
10498
  };
10301
10499
  var imgCanvasFallbackIncompatibleProps = new Set([
10302
10500
  "alt",
@@ -10352,6 +10550,10 @@ var ImgInner = ({
10352
10550
  trimBefore,
10353
10551
  durationInFrames,
10354
10552
  freeze,
10553
+ premountFor,
10554
+ postmountFor,
10555
+ styleWhilePremounted,
10556
+ styleWhilePostmounted,
10355
10557
  controls,
10356
10558
  width,
10357
10559
  height,
@@ -10365,6 +10567,7 @@ var ImgInner = ({
10365
10567
  ...props2
10366
10568
  }) => {
10367
10569
  const refForOutline = useRef24(null);
10570
+ const shouldPauseWhenLoading = resolveV5Default(pauseWhenLoading);
10368
10571
  if (effects.length === 0) {
10369
10572
  return /* @__PURE__ */ jsx28(NativeImgInner, {
10370
10573
  ...props2,
@@ -10378,13 +10581,17 @@ var ImgInner = ({
10378
10581
  trimBefore,
10379
10582
  durationInFrames,
10380
10583
  freeze,
10584
+ premountFor,
10585
+ postmountFor,
10586
+ styleWhilePremounted,
10587
+ styleWhilePostmounted,
10381
10588
  controls,
10382
10589
  width,
10383
10590
  height,
10384
10591
  className,
10385
10592
  style,
10386
10593
  id,
10387
- pauseWhenLoading,
10594
+ pauseWhenLoading: shouldPauseWhenLoading,
10388
10595
  maxRetries,
10389
10596
  delayRenderRetries,
10390
10597
  delayRenderTimeoutInMilliseconds,
@@ -10413,7 +10620,7 @@ var ImgInner = ({
10413
10620
  className,
10414
10621
  style,
10415
10622
  id,
10416
- pauseWhenLoading,
10623
+ pauseWhenLoading: shouldPauseWhenLoading,
10417
10624
  maxRetries,
10418
10625
  delayRenderRetries,
10419
10626
  delayRenderTimeoutInMilliseconds,
@@ -10421,6 +10628,10 @@ var ImgInner = ({
10421
10628
  trimBefore,
10422
10629
  durationInFrames,
10423
10630
  freeze,
10631
+ premountFor,
10632
+ postmountFor,
10633
+ styleWhilePremounted,
10634
+ styleWhilePostmounted,
10424
10635
  hidden,
10425
10636
  name: name ?? "<Img>",
10426
10637
  showInTimeline,
@@ -10462,7 +10673,20 @@ var interactiveElementSchema = {
10462
10673
  ...baseSchema,
10463
10674
  ...transformSchema
10464
10675
  };
10676
+ var interactiveBackgroundElementSchema = {
10677
+ ...interactiveElementSchema,
10678
+ ...backgroundSchema
10679
+ };
10680
+ var interactiveBorderElementSchema = {
10681
+ ...interactiveBackgroundElementSchema,
10682
+ ...borderSchema
10683
+ };
10465
10684
  var interactiveTextElementSchema = {
10685
+ ...interactiveBorderElementSchema,
10686
+ ...textSchema,
10687
+ ...textContentSchema
10688
+ };
10689
+ var interactiveSvgTextElementSchema = {
10466
10690
  ...interactiveElementSchema,
10467
10691
  ...textSchema,
10468
10692
  ...textContentSchema
@@ -10541,6 +10765,8 @@ var Interactive = {
10541
10765
  baseSchema,
10542
10766
  transformSchema,
10543
10767
  textSchema,
10768
+ backgroundSchema,
10769
+ borderSchema,
10544
10770
  premountSchema,
10545
10771
  sequenceSchema,
10546
10772
  withSchema,
@@ -10577,13 +10803,44 @@ var Interactive = {
10577
10803
  Small: makeInteractiveTextElement("small", "<Interactive.Small>"),
10578
10804
  Span: makeInteractiveTextElement("span", "<Interactive.Span>"),
10579
10805
  Strong: makeInteractiveTextElement("strong", "<Interactive.Strong>"),
10580
- Svg: makeInteractiveNonTextElement("svg", "<Interactive.Svg>"),
10581
- Text: makeInteractiveTextElement("text", "<Interactive.Text>"),
10806
+ Svg: makeInteractiveElement("svg", "<Interactive.Svg>", interactiveBorderElementSchema),
10807
+ Text: makeInteractiveElement("text", "<Interactive.Text>", interactiveSvgTextElementSchema),
10582
10808
  Ul: makeInteractiveTextElement("ul", "<Interactive.Ul>")
10583
10809
  };
10584
10810
  // src/internals.ts
10585
10811
  import { createRef as createRef3 } from "react";
10586
10812
 
10813
+ // src/animated-image/get-duration-in-seconds.ts
10814
+ var getAnimatedImageDurationInSeconds = async ({
10815
+ resolvedSrc,
10816
+ signal,
10817
+ requestInit,
10818
+ contentType
10819
+ }) => {
10820
+ const { decoder, selectedTrack } = await createImageDecoder({
10821
+ resolvedSrc,
10822
+ signal,
10823
+ requestInit,
10824
+ contentType
10825
+ });
10826
+ try {
10827
+ const { image } = await decoder.decode({
10828
+ frameIndex: selectedTrack.frameCount - 1,
10829
+ completeFramesOnly: true
10830
+ });
10831
+ try {
10832
+ if (image.duration === null) {
10833
+ throw new Error("Could not determine animated image duration");
10834
+ }
10835
+ return (image.timestamp + image.duration) / 1e6;
10836
+ } finally {
10837
+ image.close();
10838
+ }
10839
+ } finally {
10840
+ decoder.close();
10841
+ }
10842
+ };
10843
+
10587
10844
  // src/CompositionManager.tsx
10588
10845
  import React31 from "react";
10589
10846
  var compositionsRef = React31.createRef();
@@ -11718,6 +11975,7 @@ var InnerOffthreadVideo = (props2) => {
11718
11975
  ...otherProps
11719
11976
  } = props2;
11720
11977
  const environment = useRemotionEnvironment();
11978
+ const shouldPauseWhenBuffering = resolveV5Default(pauseWhenBuffering);
11721
11979
  if (environment.isClientSideRendering) {
11722
11980
  throw new Error("<OffthreadVideo> is not supported in @remotion/web-renderer. Use <Video> from @remotion/media instead. See https://remotion.dev/docs/client-side-rendering/limitations");
11723
11981
  }
@@ -11742,7 +12000,7 @@ var InnerOffthreadVideo = (props2) => {
11742
12000
  durationInFrames: trimAfterValue,
11743
12001
  name,
11744
12002
  children: /* @__PURE__ */ jsx35(InnerOffthreadVideo, {
11745
- pauseWhenBuffering: pauseWhenBuffering ?? false,
12003
+ pauseWhenBuffering: shouldPauseWhenBuffering,
11746
12004
  ...otherProps,
11747
12005
  trimAfter: undefined,
11748
12006
  name: undefined,
@@ -11757,7 +12015,7 @@ var InnerOffthreadVideo = (props2) => {
11757
12015
  validateMediaProps(props2, "Video");
11758
12016
  if (environment.isRendering) {
11759
12017
  return /* @__PURE__ */ jsx35(OffthreadVideoForRendering, {
11760
- pauseWhenBuffering: pauseWhenBuffering ?? false,
12018
+ pauseWhenBuffering: shouldPauseWhenBuffering,
11761
12019
  ...otherProps,
11762
12020
  trimAfter: undefined,
11763
12021
  name: undefined,
@@ -11782,7 +12040,7 @@ var InnerOffthreadVideo = (props2) => {
11782
12040
  _remotionInternalStack: stack ?? null,
11783
12041
  onDuration,
11784
12042
  onlyWarnForMediaSeekingError: true,
11785
- pauseWhenBuffering: pauseWhenBuffering ?? false,
12043
+ pauseWhenBuffering: shouldPauseWhenBuffering,
11786
12044
  showInTimeline: showInTimeline ?? true,
11787
12045
  onAutoPlayError: onAutoPlayError ?? undefined,
11788
12046
  onVideoFrame: onVideoFrame ?? null,
@@ -11840,7 +12098,7 @@ var OffthreadVideo = ({
11840
12098
  onAutoPlayError: onAutoPlayError ?? null,
11841
12099
  onError,
11842
12100
  onVideoFrame,
11843
- pauseWhenBuffering: pauseWhenBuffering ?? true,
12101
+ pauseWhenBuffering: resolveV5Default(pauseWhenBuffering),
11844
12102
  playbackRate: playbackRate ?? 1,
11845
12103
  preservePitch,
11846
12104
  toneFrequency: toneFrequency ?? 1,
@@ -12006,6 +12264,7 @@ var Internals = {
12006
12264
  useAbsoluteTimelinePosition,
12007
12265
  evaluateVolume,
12008
12266
  getAbsoluteSrc,
12267
+ getAnimatedImageDurationInSeconds,
12009
12268
  getAssetDisplayName,
12010
12269
  Timeline: exports_timeline_position_state,
12011
12270
  validateMediaTrimProps,
@@ -12030,7 +12289,6 @@ var Internals = {
12030
12289
  textSchema,
12031
12290
  transformSchema,
12032
12291
  premountSchema,
12033
- premountStyleSchema,
12034
12292
  flattenActiveSchema,
12035
12293
  getFlatSchemaWithAllKeys,
12036
12294
  RemotionRootContexts,
@@ -12180,6 +12438,7 @@ var seriesSequenceSchema = {
12180
12438
  hidden: Interactive.sequenceSchema.hidden,
12181
12439
  showInTimeline: Interactive.sequenceSchema.showInTimeline,
12182
12440
  freeze: Interactive.baseSchema.freeze,
12441
+ trimBefore: Interactive.sequenceSchema.trimBefore,
12183
12442
  layout: Interactive.sequenceSchema.layout
12184
12443
  };
12185
12444
  var SeriesSequenceInner = forwardRef14(({
@@ -12799,6 +13058,7 @@ var VideoForwardingFunction = (props2, ref) => {
12799
13058
  const { loop, ...propsOtherThanLoop } = props2;
12800
13059
  const { fps } = useVideoConfig();
12801
13060
  const environment = useRemotionEnvironment();
13061
+ const shouldPauseWhenBuffering = resolveV5Default(pauseWhenBuffering);
12802
13062
  if (environment.isClientSideRendering) {
12803
13063
  throw new Error("<Html5Video> is not supported in @remotion/web-renderer. Use <Video> from @remotion/media instead. See https://remotion.dev/docs/client-side-rendering/limitations");
12804
13064
  }
@@ -12857,7 +13117,7 @@ var VideoForwardingFunction = (props2, ref) => {
12857
13117
  durationInFrames: trimAfterValue === undefined ? undefined : trimAfterValue / (props2.playbackRate ?? 1),
12858
13118
  name,
12859
13119
  children: /* @__PURE__ */ jsx39(Html5Video, {
12860
- pauseWhenBuffering: pauseWhenBuffering ?? false,
13120
+ pauseWhenBuffering: shouldPauseWhenBuffering,
12861
13121
  onVideoFrame,
12862
13122
  ...otherProps,
12863
13123
  ref,
@@ -12883,7 +13143,7 @@ var VideoForwardingFunction = (props2, ref) => {
12883
13143
  ...otherProps,
12884
13144
  ref,
12885
13145
  onVideoFrame: onVideoFrame ?? null,
12886
- pauseWhenBuffering: pauseWhenBuffering ?? false,
13146
+ pauseWhenBuffering: shouldPauseWhenBuffering,
12887
13147
  onDuration,
12888
13148
  _remotionInternalStack: stack ?? null,
12889
13149
  _remotionInternalNativeLoopPassed: _remotionInternalNativeLoopPassed ?? false,