@remotion/promo-pages 4.0.482 → 4.0.484

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.
package/dist/experts.js CHANGED
@@ -2335,7 +2335,7 @@ var getComponentsToAddStacksTo = () => componentsToAddStacksTo;
2335
2335
  var addSequenceStackTraces = (component) => {
2336
2336
  componentsToAddStacksTo.push(component);
2337
2337
  };
2338
- var VERSION = "4.0.482";
2338
+ var VERSION = "4.0.484";
2339
2339
  var checkMultipleRemotionVersions = () => {
2340
2340
  if (typeof globalThis === "undefined") {
2341
2341
  return;
@@ -3551,6 +3551,35 @@ function findRange(input, inputRange) {
3551
3551
  return i - 1;
3552
3552
  }
3553
3553
  var defaultEasing = (num) => num;
3554
+ var shouldExtendRightForEasing = (easing) => {
3555
+ return easing.remotionShouldExtendRight === true;
3556
+ };
3557
+ var resolveEasingForSegment = ({
3558
+ easing,
3559
+ segmentIndex
3560
+ }) => {
3561
+ if (easing === undefined) {
3562
+ return defaultEasing;
3563
+ }
3564
+ if (typeof easing === "function") {
3565
+ return easing;
3566
+ }
3567
+ return easing[segmentIndex];
3568
+ };
3569
+ var interpolateSegment = ({
3570
+ input,
3571
+ inputRange,
3572
+ outputRange,
3573
+ easing,
3574
+ extrapolateLeft,
3575
+ extrapolateRight
3576
+ }) => {
3577
+ return interpolateFunction(input, inputRange, outputRange, {
3578
+ easing,
3579
+ extrapolateLeft,
3580
+ extrapolateRight: input > inputRange[1] && extrapolateRight === "clamp" && shouldExtendRightForEasing(easing) ? "extend" : extrapolateRight
3581
+ });
3582
+ };
3554
3583
  var interpolateNumber = ({
3555
3584
  input,
3556
3585
  inputRange,
@@ -3561,15 +3590,6 @@ var interpolateNumber = ({
3561
3590
  return outputRange[0];
3562
3591
  }
3563
3592
  const easingOption = options?.easing;
3564
- const resolveEasingForSegment = (segmentIndex) => {
3565
- if (easingOption === undefined) {
3566
- return defaultEasing;
3567
- }
3568
- if (typeof easingOption === "function") {
3569
- return easingOption;
3570
- }
3571
- return easingOption[segmentIndex];
3572
- };
3573
3593
  let extrapolateLeft = "extend";
3574
3594
  if (options?.extrapolateLeft !== undefined) {
3575
3595
  extrapolateLeft = options.extrapolateLeft;
@@ -3580,11 +3600,41 @@ var interpolateNumber = ({
3580
3600
  }
3581
3601
  const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
3582
3602
  const range = findRange(posterizedInput, inputRange);
3583
- return interpolateFunction(posterizedInput, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
3584
- easing: resolveEasingForSegment(range),
3603
+ const easing = resolveEasingForSegment({
3604
+ easing: easingOption,
3605
+ segmentIndex: range
3606
+ });
3607
+ let result = interpolateSegment({
3608
+ input: posterizedInput,
3609
+ inputRange: [inputRange[range], inputRange[range + 1]],
3610
+ outputRange: [outputRange[range], outputRange[range + 1]],
3611
+ easing,
3585
3612
  extrapolateLeft,
3586
3613
  extrapolateRight
3587
3614
  });
3615
+ for (let segmentIndex = 0;segmentIndex < range; segmentIndex++) {
3616
+ const previousEasing = resolveEasingForSegment({
3617
+ easing: easingOption,
3618
+ segmentIndex
3619
+ });
3620
+ if (!shouldExtendRightForEasing(previousEasing)) {
3621
+ continue;
3622
+ }
3623
+ const previousSegmentEnd = inputRange[segmentIndex + 1];
3624
+ if (posterizedInput <= previousSegmentEnd) {
3625
+ continue;
3626
+ }
3627
+ const continuedSegmentValue = interpolateSegment({
3628
+ input: posterizedInput,
3629
+ inputRange: [inputRange[segmentIndex], previousSegmentEnd],
3630
+ outputRange: [outputRange[segmentIndex], outputRange[segmentIndex + 1]],
3631
+ easing: previousEasing,
3632
+ extrapolateLeft,
3633
+ extrapolateRight: "extend"
3634
+ });
3635
+ result += continuedSegmentValue - outputRange[segmentIndex + 1];
3636
+ }
3637
+ return result;
3588
3638
  };
3589
3639
  var interpolateString = ({
3590
3640
  input,
@@ -4058,21 +4108,40 @@ class Easing {
4058
4108
  static back(s = 1.70158) {
4059
4109
  return (t) => t * t * ((s + 1) * t - s);
4060
4110
  }
4061
- static spring(config = {}) {
4062
- return (t) => {
4111
+ static spring({
4112
+ allowTail = false,
4113
+ durationRestThreshold,
4114
+ ...config
4115
+ } = {}) {
4116
+ const easing = (t) => {
4063
4117
  if (t <= 0) {
4064
4118
  return 0;
4065
4119
  }
4066
- if (t >= 1) {
4120
+ if (!allowTail && t >= 1) {
4067
4121
  return 1;
4068
4122
  }
4123
+ if (allowTail) {
4124
+ return spring({
4125
+ fps: springEasingDurationInFrames,
4126
+ frame: t * measureSpring({
4127
+ fps: springEasingDurationInFrames,
4128
+ config,
4129
+ threshold: durationRestThreshold
4130
+ }),
4131
+ config
4132
+ });
4133
+ }
4069
4134
  return spring({
4070
4135
  fps: springEasingDurationInFrames,
4071
4136
  frame: t * springEasingDurationInFrames,
4072
4137
  config,
4073
- durationInFrames: springEasingDurationInFrames
4138
+ durationInFrames: springEasingDurationInFrames,
4139
+ durationRestThreshold
4074
4140
  });
4075
4141
  };
4142
+ return Object.assign(easing, {
4143
+ remotionShouldExtendRight: allowTail
4144
+ });
4076
4145
  }
4077
4146
  static bounce(t) {
4078
4147
  const u = clampUnit(t);
@@ -4603,25 +4672,31 @@ var interpolateColors = (input, inputRange, outputRange, options) => {
4603
4672
  const processedOutputRange = outputRange.map((c2) => processColor(c2));
4604
4673
  return interpolateColorsRGB(input, inputRange, processedOutputRange, options);
4605
4674
  };
4606
- var easingToFn = (e) => {
4607
- switch (e.type) {
4675
+ var easingToFn = ({
4676
+ easing,
4677
+ forceSpringAllowTail
4678
+ }) => {
4679
+ switch (easing.type) {
4608
4680
  case "linear":
4609
4681
  return Easing.linear;
4610
4682
  case "spring":
4611
4683
  return Easing.spring({
4612
- damping: e.damping,
4613
- mass: e.mass,
4614
- overshootClamping: e.overshootClamping,
4615
- stiffness: e.stiffness
4684
+ allowTail: forceSpringAllowTail ?? easing.allowTail ?? undefined,
4685
+ damping: easing.damping,
4686
+ durationRestThreshold: easing.durationRestThreshold ?? undefined,
4687
+ mass: easing.mass,
4688
+ overshootClamping: easing.overshootClamping,
4689
+ stiffness: easing.stiffness
4616
4690
  });
4617
4691
  case "bezier":
4618
- return bezier(e.x1, e.y1, e.x2, e.y2);
4692
+ return bezier(easing.x1, easing.y1, easing.x2, easing.y2);
4619
4693
  default:
4620
- throw new TypeError(`Unsupported easing: ${JSON.stringify(e)}`);
4694
+ throw new TypeError(`Unsupported easing: ${JSON.stringify(easing)}`);
4621
4695
  }
4622
4696
  };
4623
4697
  var interpolateKeyframedStatus = ({
4624
4698
  frame,
4699
+ forceSpringAllowTail,
4625
4700
  status
4626
4701
  }) => {
4627
4702
  const { keyframes, easing, clamping, interpolationFunction } = status;
@@ -4640,7 +4715,7 @@ var interpolateKeyframedStatus = ({
4640
4715
  }
4641
4716
  try {
4642
4717
  return interpolateColors(frame, inputRange, outputs, {
4643
- easing: easing.map(easingToFn),
4718
+ easing: easing.map((e) => easingToFn({ easing: e, forceSpringAllowTail })),
4644
4719
  posterize: status.posterize
4645
4720
  });
4646
4721
  } catch {
@@ -4652,7 +4727,7 @@ var interpolateKeyframedStatus = ({
4652
4727
  }
4653
4728
  try {
4654
4729
  return interpolate(frame, inputRange, outputs, {
4655
- easing: easing.map(easingToFn),
4730
+ easing: easing.map((e) => easingToFn({ easing: e, forceSpringAllowTail })),
4656
4731
  extrapolateLeft: clamping.left,
4657
4732
  extrapolateRight: clamping.right,
4658
4733
  posterize: status.posterize
@@ -4675,6 +4750,7 @@ var resolveDragOverrideValue = ({
4675
4750
  return { type: "none" };
4676
4751
  }
4677
4752
  const interpolated = interpolateKeyframedStatus({
4753
+ forceSpringAllowTail: null,
4678
4754
  frame,
4679
4755
  status: dragOverrideValue.status
4680
4756
  });
@@ -4700,6 +4776,7 @@ var getEffectiveVisualModeValue = ({
4700
4776
  if (propStatus.status === "keyframed") {
4701
4777
  if (frame !== null) {
4702
4778
  return interpolateKeyframedStatus({
4779
+ forceSpringAllowTail: null,
4703
4780
  frame,
4704
4781
  status: propStatus
4705
4782
  });
@@ -4768,6 +4845,7 @@ var resolvePropStatusOverrides = (propStatus, frame) => {
4768
4845
  }
4769
4846
  if (status.status === "keyframed") {
4770
4847
  const value = interpolateKeyframedStatus({
4848
+ forceSpringAllowTail: null,
4771
4849
  frame,
4772
4850
  status
4773
4851
  });
@@ -4943,6 +5021,17 @@ var findPropsToDelete = ({
4943
5021
  var DEFAULT_LINEAR_EASING = {
4944
5022
  type: "linear"
4945
5023
  };
5024
+ var getEasingIndexToDuplicate = ({
5025
+ insertedKeyframeIndex,
5026
+ easingLength,
5027
+ keyframeCount
5028
+ }) => {
5029
+ const isSplittingExistingSegment = insertedKeyframeIndex > 0 && insertedKeyframeIndex < keyframeCount - 1;
5030
+ if (!isSplittingExistingSegment || easingLength === 0) {
5031
+ return null;
5032
+ }
5033
+ return Math.min(insertedKeyframeIndex - 1, easingLength - 1);
5034
+ };
4946
5035
  var makeStaticDragOverride = (value) => {
4947
5036
  return { type: "static", value };
4948
5037
  };
@@ -4954,6 +5043,16 @@ var makeKeyframedDragOverride = ({
4954
5043
  const existingIndex = status.keyframes.findIndex((keyframe) => keyframe.frame === frame);
4955
5044
  const keyframes = existingIndex === -1 ? [...status.keyframes, { frame, value }].sort((first, second) => first.frame - second.frame) : status.keyframes.map((keyframe, index) => index === existingIndex ? { frame, value } : keyframe);
4956
5045
  const easing = [...status.easing];
5046
+ if (existingIndex === -1) {
5047
+ const insertedKeyframeIndex = keyframes.findIndex((keyframe) => keyframe.frame === frame);
5048
+ const easingIndexToDuplicate = getEasingIndexToDuplicate({
5049
+ insertedKeyframeIndex,
5050
+ easingLength: easing.length,
5051
+ keyframeCount: keyframes.length
5052
+ });
5053
+ const easingToDuplicate = easingIndexToDuplicate === null ? DEFAULT_LINEAR_EASING : easing[easingIndexToDuplicate];
5054
+ easing.splice(insertedKeyframeIndex, 0, easingToDuplicate);
5055
+ }
4957
5056
  while (easing.length < keyframes.length - 1) {
4958
5057
  easing.push(DEFAULT_LINEAR_EASING);
4959
5058
  }
@@ -5025,6 +5124,7 @@ var computeEffectiveSchemaValuesDotNotation = ({
5025
5124
  value = dragOverride.value;
5026
5125
  } else if (frame !== null) {
5027
5126
  const interpolated = interpolateKeyframedStatus({
5127
+ forceSpringAllowTail: null,
5028
5128
  frame,
5029
5129
  status
5030
5130
  });
@@ -9176,6 +9276,7 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
9176
9276
  var AudioForRendering = forwardRef6(AudioForRenderingRefForwardingFunction);
9177
9277
  var AudioRefForwardingFunction = (props, ref) => {
9178
9278
  const audioTagsContext = useContext30(SharedAudioTagsContext);
9279
+ const propsWithFreeze = props;
9179
9280
  const {
9180
9281
  startFrom,
9181
9282
  endAt,
@@ -9186,14 +9287,18 @@ var AudioRefForwardingFunction = (props, ref) => {
9186
9287
  pauseWhenBuffering,
9187
9288
  showInTimeline,
9188
9289
  onError: onRemotionError,
9290
+ freeze,
9189
9291
  ...otherProps
9190
- } = props;
9191
- const { loop, ...propsOtherThanLoop } = props;
9292
+ } = propsWithFreeze;
9293
+ const { loop, freeze: _freeze, ...propsOtherThanLoop } = propsWithFreeze;
9192
9294
  const { fps } = useVideoConfig();
9193
9295
  const environment = useRemotionEnvironment();
9194
9296
  if (environment.isClientSideRendering) {
9195
9297
  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");
9196
9298
  }
9299
+ if (typeof freeze !== "undefined") {
9300
+ throw new TypeError('The "freeze" prop is not supported on <Html5Audio />. Use <Sequence freeze={...}> to freeze media playback.');
9301
+ }
9197
9302
  const { durations, setDurations } = useContext30(DurationsContext);
9198
9303
  if (typeof props.src !== "string") {
9199
9304
  throw new TypeError(`The \`<Html5Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
@@ -9532,6 +9637,10 @@ function resolveHtmlInCanvasPixelDensity(pixelDensity) {
9532
9637
  }
9533
9638
  return pixelDensity;
9534
9639
  }
9640
+ var isMissingPaintRecordError = (error2) => {
9641
+ return error2 instanceof DOMException && error2.name === "InvalidStateError";
9642
+ };
9643
+ var missingPaintRecordMessage = "HtmlInCanvas: Expected the element to be inside the viewport during rendering, but Chrome had no cached paint record for it.";
9535
9644
  var resizeOffscreenCanvas = ({
9536
9645
  offscreen,
9537
9646
  width,
@@ -9575,6 +9684,7 @@ var HtmlInCanvasContent = forwardRef9(({
9575
9684
  const canvasWidth = Math.ceil(width * resolvedPixelDensity);
9576
9685
  const canvasHeight = Math.ceil(height * resolvedPixelDensity);
9577
9686
  const { continueRender: continueRender2, cancelRender: cancelRender2 } = useDelayRender();
9687
+ const { isRendering } = useRemotionEnvironment();
9578
9688
  if (!isHtmlInCanvasSupported()) {
9579
9689
  cancelRender2(new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE));
9580
9690
  }
@@ -9625,28 +9735,51 @@ var HtmlInCanvasContent = forwardRef9(({
9625
9735
  }
9626
9736
  const handle = delayRender("onPaint");
9627
9737
  if (!initializedRef.current) {
9628
- initializedRef.current = true;
9629
- const initImage = placeholderCanvas.captureElementImage(element);
9630
- const currentOnInit = onInitRef.current;
9631
- if (currentOnInit) {
9632
- const cleanup = await currentOnInit({
9633
- canvas: offscreen,
9634
- element,
9635
- elementImage: initImage,
9636
- pixelDensity: resolvedPixelDensity
9637
- });
9638
- if (typeof cleanup !== "function") {
9639
- throw new Error("HtmlInCanvas: when `onInit` is provided, it must return a cleanup function, or a Promise that resolves to one.");
9640
- }
9641
- if (unmountedRef.current) {
9642
- cleanup();
9738
+ let initImage = null;
9739
+ try {
9740
+ initImage = placeholderCanvas.captureElementImage(element);
9741
+ } catch (error2) {
9742
+ if (isMissingPaintRecordError(error2) && !isRendering) {} else if (isMissingPaintRecordError(error2)) {
9743
+ throw new Error(missingPaintRecordMessage);
9643
9744
  } else {
9644
- onInitCleanupRef.current = cleanup;
9745
+ throw error2;
9746
+ }
9747
+ }
9748
+ if (initImage) {
9749
+ initializedRef.current = true;
9750
+ const currentOnInit = onInitRef.current;
9751
+ if (currentOnInit) {
9752
+ const cleanup = await currentOnInit({
9753
+ canvas: offscreen,
9754
+ element,
9755
+ elementImage: initImage,
9756
+ pixelDensity: resolvedPixelDensity
9757
+ });
9758
+ if (typeof cleanup !== "function") {
9759
+ throw new Error("HtmlInCanvas: when `onInit` is provided, it must return a cleanup function, or a Promise that resolves to one.");
9760
+ }
9761
+ if (unmountedRef.current) {
9762
+ cleanup();
9763
+ } else {
9764
+ onInitCleanupRef.current = cleanup;
9765
+ }
9645
9766
  }
9646
9767
  }
9647
9768
  }
9648
9769
  const handler = onPaintRef.current ?? defaultOnPaint;
9649
- const elImage = placeholderCanvas.captureElementImage(element);
9770
+ let elImage;
9771
+ try {
9772
+ elImage = placeholderCanvas.captureElementImage(element);
9773
+ } catch (error2) {
9774
+ if (isMissingPaintRecordError(error2) && !isRendering) {
9775
+ continueRender2(handle);
9776
+ return;
9777
+ }
9778
+ if (isMissingPaintRecordError(error2)) {
9779
+ throw new Error(missingPaintRecordMessage);
9780
+ }
9781
+ throw error2;
9782
+ }
9650
9783
  await handler({
9651
9784
  canvas: offscreen,
9652
9785
  element,
@@ -9671,7 +9804,8 @@ var HtmlInCanvasContent = forwardRef9(({
9671
9804
  chainState,
9672
9805
  continueRender2,
9673
9806
  cancelRender2,
9674
- resolvedPixelDensity
9807
+ resolvedPixelDensity,
9808
+ isRendering
9675
9809
  ]);
9676
9810
  useLayoutEffect9(() => {
9677
9811
  const placeholder = canvas2dRef.current;