@remotion/promo-pages 4.0.481 → 4.0.483

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.481";
2338
+ var VERSION = "4.0.483";
2339
2339
  var checkMultipleRemotionVersions = () => {
2340
2340
  if (typeof globalThis === "undefined") {
2341
2341
  return;
@@ -2735,6 +2735,77 @@ var transformSchema = {
2735
2735
  }
2736
2736
  };
2737
2737
  var sequenceVisualStyleSchema = transformSchema;
2738
+ var textSchema = {
2739
+ "style.color": {
2740
+ type: "color",
2741
+ default: undefined,
2742
+ description: "Color"
2743
+ },
2744
+ "style.fontSize": {
2745
+ type: "number",
2746
+ default: undefined,
2747
+ min: 0,
2748
+ step: 1,
2749
+ description: "Font size",
2750
+ hiddenFromList: false
2751
+ },
2752
+ "style.lineHeight": {
2753
+ type: "number",
2754
+ default: undefined,
2755
+ min: 0,
2756
+ step: 0.05,
2757
+ description: "Line height",
2758
+ hiddenFromList: false
2759
+ },
2760
+ "style.fontWeight": {
2761
+ type: "enum",
2762
+ default: "400",
2763
+ description: "Font weight",
2764
+ variants: {
2765
+ "100": {},
2766
+ "200": {},
2767
+ "300": {},
2768
+ "400": {},
2769
+ "500": {},
2770
+ "600": {},
2771
+ "700": {},
2772
+ "800": {},
2773
+ "900": {},
2774
+ normal: {},
2775
+ bold: {}
2776
+ }
2777
+ },
2778
+ "style.fontStyle": {
2779
+ type: "enum",
2780
+ default: "normal",
2781
+ description: "Font style",
2782
+ variants: {
2783
+ normal: {},
2784
+ italic: {},
2785
+ oblique: {}
2786
+ }
2787
+ },
2788
+ "style.textAlign": {
2789
+ type: "enum",
2790
+ default: "left",
2791
+ description: "Text align",
2792
+ variants: {
2793
+ left: {},
2794
+ center: {},
2795
+ right: {},
2796
+ justify: {},
2797
+ start: {},
2798
+ end: {}
2799
+ }
2800
+ },
2801
+ "style.letterSpacing": {
2802
+ type: "number",
2803
+ default: undefined,
2804
+ step: 0.1,
2805
+ description: "Letter spacing",
2806
+ hiddenFromList: false
2807
+ }
2808
+ };
2738
2809
  var premountSchema = {
2739
2810
  premountFor: {
2740
2811
  type: "number",
@@ -2793,6 +2864,13 @@ var fromField = {
2793
2864
  step: 1,
2794
2865
  hiddenFromList: true
2795
2866
  };
2867
+ var trimBeforeField = {
2868
+ type: "number",
2869
+ default: 0,
2870
+ min: 0,
2871
+ step: 1,
2872
+ hiddenFromList: true
2873
+ };
2796
2874
  var freezeField = {
2797
2875
  type: "number",
2798
2876
  default: null,
@@ -2802,6 +2880,7 @@ var freezeField = {
2802
2880
  var baseSchema = {
2803
2881
  durationInFrames: durationInFramesField,
2804
2882
  from: fromField,
2883
+ trimBefore: trimBeforeField,
2805
2884
  freeze: freezeField,
2806
2885
  hidden: hiddenField,
2807
2886
  name: sequenceNameField,
@@ -2821,6 +2900,7 @@ var sequenceSchema = {
2821
2900
  };
2822
2901
  var baseSchemaWithoutFrom = {
2823
2902
  durationInFrames: durationInFramesField,
2903
+ trimBefore: trimBeforeField,
2824
2904
  freeze: freezeField,
2825
2905
  hidden: hiddenField,
2826
2906
  name: sequenceNameField,
@@ -3471,6 +3551,35 @@ function findRange(input, inputRange) {
3471
3551
  return i - 1;
3472
3552
  }
3473
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
+ };
3474
3583
  var interpolateNumber = ({
3475
3584
  input,
3476
3585
  inputRange,
@@ -3481,15 +3590,6 @@ var interpolateNumber = ({
3481
3590
  return outputRange[0];
3482
3591
  }
3483
3592
  const easingOption = options?.easing;
3484
- const resolveEasingForSegment = (segmentIndex) => {
3485
- if (easingOption === undefined) {
3486
- return defaultEasing;
3487
- }
3488
- if (typeof easingOption === "function") {
3489
- return easingOption;
3490
- }
3491
- return easingOption[segmentIndex];
3492
- };
3493
3593
  let extrapolateLeft = "extend";
3494
3594
  if (options?.extrapolateLeft !== undefined) {
3495
3595
  extrapolateLeft = options.extrapolateLeft;
@@ -3500,11 +3600,41 @@ var interpolateNumber = ({
3500
3600
  }
3501
3601
  const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
3502
3602
  const range = findRange(posterizedInput, inputRange);
3503
- return interpolateFunction(posterizedInput, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
3504
- 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,
3505
3612
  extrapolateLeft,
3506
3613
  extrapolateRight
3507
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;
3508
3638
  };
3509
3639
  var interpolateString = ({
3510
3640
  input,
@@ -3978,21 +4108,40 @@ class Easing {
3978
4108
  static back(s = 1.70158) {
3979
4109
  return (t) => t * t * ((s + 1) * t - s);
3980
4110
  }
3981
- static spring(config = {}) {
3982
- return (t) => {
4111
+ static spring({
4112
+ allowTail = false,
4113
+ durationRestThreshold,
4114
+ ...config
4115
+ } = {}) {
4116
+ const easing = (t) => {
3983
4117
  if (t <= 0) {
3984
4118
  return 0;
3985
4119
  }
3986
- if (t >= 1) {
4120
+ if (!allowTail && t >= 1) {
3987
4121
  return 1;
3988
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
+ }
3989
4134
  return spring({
3990
4135
  fps: springEasingDurationInFrames,
3991
4136
  frame: t * springEasingDurationInFrames,
3992
4137
  config,
3993
- durationInFrames: springEasingDurationInFrames
4138
+ durationInFrames: springEasingDurationInFrames,
4139
+ durationRestThreshold
3994
4140
  });
3995
4141
  };
4142
+ return Object.assign(easing, {
4143
+ remotionShouldExtendRight: allowTail
4144
+ });
3996
4145
  }
3997
4146
  static bounce(t) {
3998
4147
  const u = clampUnit(t);
@@ -4523,25 +4672,31 @@ var interpolateColors = (input, inputRange, outputRange, options) => {
4523
4672
  const processedOutputRange = outputRange.map((c2) => processColor(c2));
4524
4673
  return interpolateColorsRGB(input, inputRange, processedOutputRange, options);
4525
4674
  };
4526
- var easingToFn = (e) => {
4527
- switch (e.type) {
4675
+ var easingToFn = ({
4676
+ easing,
4677
+ forceSpringAllowTail
4678
+ }) => {
4679
+ switch (easing.type) {
4528
4680
  case "linear":
4529
4681
  return Easing.linear;
4530
4682
  case "spring":
4531
4683
  return Easing.spring({
4532
- damping: e.damping,
4533
- mass: e.mass,
4534
- overshootClamping: e.overshootClamping,
4535
- 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
4536
4690
  });
4537
4691
  case "bezier":
4538
- return bezier(e.x1, e.y1, e.x2, e.y2);
4692
+ return bezier(easing.x1, easing.y1, easing.x2, easing.y2);
4539
4693
  default:
4540
- throw new TypeError(`Unsupported easing: ${JSON.stringify(e)}`);
4694
+ throw new TypeError(`Unsupported easing: ${JSON.stringify(easing)}`);
4541
4695
  }
4542
4696
  };
4543
4697
  var interpolateKeyframedStatus = ({
4544
4698
  frame,
4699
+ forceSpringAllowTail,
4545
4700
  status
4546
4701
  }) => {
4547
4702
  const { keyframes, easing, clamping, interpolationFunction } = status;
@@ -4560,7 +4715,7 @@ var interpolateKeyframedStatus = ({
4560
4715
  }
4561
4716
  try {
4562
4717
  return interpolateColors(frame, inputRange, outputs, {
4563
- easing: easing.map(easingToFn),
4718
+ easing: easing.map((e) => easingToFn({ easing: e, forceSpringAllowTail })),
4564
4719
  posterize: status.posterize
4565
4720
  });
4566
4721
  } catch {
@@ -4572,7 +4727,7 @@ var interpolateKeyframedStatus = ({
4572
4727
  }
4573
4728
  try {
4574
4729
  return interpolate(frame, inputRange, outputs, {
4575
- easing: easing.map(easingToFn),
4730
+ easing: easing.map((e) => easingToFn({ easing: e, forceSpringAllowTail })),
4576
4731
  extrapolateLeft: clamping.left,
4577
4732
  extrapolateRight: clamping.right,
4578
4733
  posterize: status.posterize
@@ -4595,6 +4750,7 @@ var resolveDragOverrideValue = ({
4595
4750
  return { type: "none" };
4596
4751
  }
4597
4752
  const interpolated = interpolateKeyframedStatus({
4753
+ forceSpringAllowTail: null,
4598
4754
  frame,
4599
4755
  status: dragOverrideValue.status
4600
4756
  });
@@ -4620,6 +4776,7 @@ var getEffectiveVisualModeValue = ({
4620
4776
  if (propStatus.status === "keyframed") {
4621
4777
  if (frame !== null) {
4622
4778
  return interpolateKeyframedStatus({
4779
+ forceSpringAllowTail: null,
4623
4780
  frame,
4624
4781
  status: propStatus
4625
4782
  });
@@ -4688,6 +4845,7 @@ var resolvePropStatusOverrides = (propStatus, frame) => {
4688
4845
  }
4689
4846
  if (status.status === "keyframed") {
4690
4847
  const value = interpolateKeyframedStatus({
4848
+ forceSpringAllowTail: null,
4691
4849
  frame,
4692
4850
  status
4693
4851
  });
@@ -4863,6 +5021,17 @@ var findPropsToDelete = ({
4863
5021
  var DEFAULT_LINEAR_EASING = {
4864
5022
  type: "linear"
4865
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
+ };
4866
5035
  var makeStaticDragOverride = (value) => {
4867
5036
  return { type: "static", value };
4868
5037
  };
@@ -4874,6 +5043,16 @@ var makeKeyframedDragOverride = ({
4874
5043
  const existingIndex = status.keyframes.findIndex((keyframe) => keyframe.frame === frame);
4875
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);
4876
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
+ }
4877
5056
  while (easing.length < keyframes.length - 1) {
4878
5057
  easing.push(DEFAULT_LINEAR_EASING);
4879
5058
  }
@@ -4945,6 +5124,7 @@ var computeEffectiveSchemaValuesDotNotation = ({
4945
5124
  value = dragOverride.value;
4946
5125
  } else if (frame !== null) {
4947
5126
  const interpolated = interpolateKeyframedStatus({
5127
+ forceSpringAllowTail: null,
4948
5128
  frame,
4949
5129
  status
4950
5130
  });
@@ -5122,6 +5302,7 @@ var withInteractivitySchema = ({
5122
5302
  var EMPTY_EFFECTS = [];
5123
5303
  var RegularSequenceRefForwardingFunction = ({
5124
5304
  from = 0,
5305
+ trimBefore = 0,
5125
5306
  freeze,
5126
5307
  durationInFrames = Infinity,
5127
5308
  children,
@@ -5146,7 +5327,6 @@ var RegularSequenceRefForwardingFunction = ({
5146
5327
  const parentSequence = useContext17(SequenceContext);
5147
5328
  const { rootId } = useTimelineContext();
5148
5329
  const cumulatedFrom = parentSequence ? parentSequence.cumulatedFrom + parentSequence.relativeFrom : 0;
5149
- const absoluteFrom = (parentSequence?.absoluteFrom ?? 0) + from;
5150
5330
  const nonce = useNonce();
5151
5331
  if (layout !== "absolute-fill" && layout !== "none") {
5152
5332
  throw new TypeError(`The layout prop of <Sequence /> expects either "absolute-fill" or "none", but you passed: ${layout}`);
@@ -5166,6 +5346,18 @@ var RegularSequenceRefForwardingFunction = ({
5166
5346
  if (!Number.isFinite(from)) {
5167
5347
  throw new TypeError(`The "from" prop of a sequence must be finite, but got ${from}.`);
5168
5348
  }
5349
+ if (typeof trimBefore !== "number") {
5350
+ throw new TypeError(`You passed to the "trimBefore" prop of your <Sequence> an argument of type ${typeof trimBefore}, but it must be a number.`);
5351
+ }
5352
+ if (trimBefore < 0) {
5353
+ throw new TypeError(`The "trimBefore" prop of <Sequence /> must be greater than or equal to 0, but got ${trimBefore}.`);
5354
+ }
5355
+ if (Number.isNaN(trimBefore)) {
5356
+ throw new TypeError('The "trimBefore" prop of <Sequence /> must be a real number, but it is NaN.');
5357
+ }
5358
+ if (!Number.isFinite(trimBefore)) {
5359
+ throw new TypeError(`The "trimBefore" prop of <Sequence /> must be finite, but it is ${trimBefore}.`);
5360
+ }
5169
5361
  if (typeof freeze !== "undefined" && freeze !== null) {
5170
5362
  if (typeof freeze !== "number") {
5171
5363
  throw new TypeError(`The "freeze" prop of <Sequence /> must be a number, but is of type ${typeof freeze}.`);
@@ -5179,7 +5371,9 @@ var RegularSequenceRefForwardingFunction = ({
5179
5371
  }
5180
5372
  const absoluteFrame = useTimelinePosition();
5181
5373
  const videoConfig = useVideoConfig();
5182
- const parentSequenceDuration = parentSequence ? Math.min(parentSequence.durationInFrames - from, durationInFrames) : durationInFrames;
5374
+ const effectiveRelativeFrom = from - trimBefore;
5375
+ const absoluteFrom = (parentSequence?.absoluteFrom ?? 0) + effectiveRelativeFrom;
5376
+ const parentSequenceDuration = parentSequence ? Math.min(parentSequence.durationInFrames - effectiveRelativeFrom, durationInFrames) : durationInFrames;
5183
5377
  const actualDurationInFrames = Math.max(0, Math.min(videoConfig.durationInFrames - from, parentSequenceDuration));
5184
5378
  const { registerSequence, unregisterSequence } = useContext17(SequenceManager);
5185
5379
  const wrapperRefForOutline = useRef6(null);
@@ -5190,7 +5384,7 @@ var RegularSequenceRefForwardingFunction = ({
5190
5384
  const postmounting = useMemo14(() => {
5191
5385
  return parentSequence?.postmounting || Boolean(other._remotionInternalIsPostmounting);
5192
5386
  }, [other._remotionInternalIsPostmounting, parentSequence?.postmounting]);
5193
- const currentSequenceStart = cumulatedFrom + from;
5387
+ const currentSequenceStart = cumulatedFrom + effectiveRelativeFrom;
5194
5388
  const parentSequenceStart = parentSequence ? parentSequence.cumulatedFrom + parentSequence.relativeFrom : 0;
5195
5389
  const parentFirstFrame = parentSequence ? parentSequenceStart - parentSequence.cumulatedNegativeFrom : 0;
5196
5390
  const firstFrame = Math.max(0, parentFirstFrame, currentSequenceStart);
@@ -5199,7 +5393,7 @@ var RegularSequenceRefForwardingFunction = ({
5199
5393
  return {
5200
5394
  absoluteFrom,
5201
5395
  cumulatedFrom,
5202
- relativeFrom: from,
5396
+ relativeFrom: effectiveRelativeFrom,
5203
5397
  cumulatedNegativeFrom,
5204
5398
  durationInFrames: actualDurationInFrames,
5205
5399
  parentFrom: parentSequence?.relativeFrom ?? 0,
@@ -5214,7 +5408,7 @@ var RegularSequenceRefForwardingFunction = ({
5214
5408
  }, [
5215
5409
  cumulatedFrom,
5216
5410
  absoluteFrom,
5217
- from,
5411
+ effectiveRelativeFrom,
5218
5412
  actualDurationInFrames,
5219
5413
  parentSequence,
5220
5414
  id,
@@ -5236,6 +5430,7 @@ var RegularSequenceRefForwardingFunction = ({
5236
5430
  const stackRef = useRef6(null);
5237
5431
  stackRef.current = stack ?? inheritedStack;
5238
5432
  const registeredFrozenFrame = typeof freeze === "number" ? freeze : null;
5433
+ const registeredTrimBefore = trimBefore === 0 ? null : trimBefore;
5239
5434
  const parentCumulatedNegativeFrom = parentSequence?.cumulatedNegativeFrom ?? 0;
5240
5435
  const startMediaFrom = isMedia && isMedia.type !== "image" ? isMedia.data.startMediaFrom + parentCumulatedNegativeFrom - cumulatedNegativeFrom : null;
5241
5436
  const mediaFrameAtSequenceZero = isMedia && isMedia.type !== "image" ? isMedia.data.startMediaFrom + parentCumulatedNegativeFrom : null;
@@ -5254,6 +5449,7 @@ var RegularSequenceRefForwardingFunction = ({
5254
5449
  documentationLink: resolvedDocumentationLink,
5255
5450
  duration: actualDurationInFrames,
5256
5451
  from,
5452
+ trimBefore: registeredTrimBefore,
5257
5453
  id,
5258
5454
  loopDisplay,
5259
5455
  nonce: nonce.get(),
@@ -5278,6 +5474,7 @@ var RegularSequenceRefForwardingFunction = ({
5278
5474
  doesVolumeChange: isMedia.data.doesVolumeChange,
5279
5475
  duration: actualDurationInFrames,
5280
5476
  from,
5477
+ trimBefore: registeredTrimBefore,
5281
5478
  id,
5282
5479
  loopDisplay,
5283
5480
  nonce: nonce.get(),
@@ -5303,6 +5500,7 @@ var RegularSequenceRefForwardingFunction = ({
5303
5500
  }
5304
5501
  registerSequence({
5305
5502
  from,
5503
+ trimBefore: registeredTrimBefore,
5306
5504
  duration: actualDurationInFrames,
5307
5505
  id,
5308
5506
  displayName: timelineClipName,
@@ -5336,6 +5534,8 @@ var RegularSequenceRefForwardingFunction = ({
5336
5534
  actualDurationInFrames,
5337
5535
  rootId,
5338
5536
  from,
5537
+ trimBefore,
5538
+ registeredTrimBefore,
5339
5539
  showInTimeline,
5340
5540
  nonce,
5341
5541
  loopDisplay,
@@ -6603,13 +6803,15 @@ var prefetch = (src, options) => {
6603
6803
  resolve = res;
6604
6804
  reject = rej;
6605
6805
  });
6806
+ waitUntilDone.catch(() => {
6807
+ return;
6808
+ });
6606
6809
  const controller = new AbortController;
6607
- let canBeAborted = true;
6810
+ let reader = null;
6608
6811
  fetch(srcWithoutHash, {
6609
6812
  signal: controller.signal,
6610
6813
  credentials: options?.credentials ?? undefined
6611
6814
  }).then((res) => {
6612
- canBeAborted = false;
6613
6815
  if (canceled) {
6614
6816
  return null;
6615
6817
  }
@@ -6625,15 +6827,16 @@ var prefetch = (src, options) => {
6625
6827
  if (!res.body) {
6626
6828
  throw new Error(`HTTP response of ${srcWithoutHash} has no body`);
6627
6829
  }
6628
- const reader = res.body.getReader();
6830
+ const responseReader = res.body.getReader();
6831
+ reader = responseReader;
6629
6832
  return getBlobFromReader({
6630
- reader,
6833
+ reader: responseReader,
6631
6834
  contentType: options?.contentType ?? headerContentType ?? null,
6632
6835
  contentLength: res.headers.get("Content-Length") ? parseInt(res.headers.get("Content-Length"), 10) : null,
6633
6836
  onProgress: options?.onProgress
6634
6837
  });
6635
6838
  }).then((buf) => {
6636
- if (!buf) {
6839
+ if (!buf || canceled) {
6637
6840
  return;
6638
6841
  }
6639
6842
  const actualBlob = options?.contentType ? new Blob([buf], { type: options.contentType }) : buf;
@@ -6681,12 +6884,18 @@ var prefetch = (src, options) => {
6681
6884
  return copy;
6682
6885
  });
6683
6886
  } else {
6684
- canceled = true;
6685
- if (canBeAborted) {
6686
- try {
6687
- controller.abort(new Error("free() called"));
6688
- } catch {}
6887
+ if (canceled) {
6888
+ return;
6689
6889
  }
6890
+ canceled = true;
6891
+ const cancellationError = new Error("free() called");
6892
+ reject(cancellationError);
6893
+ try {
6894
+ controller.abort(cancellationError);
6895
+ } catch {}
6896
+ reader?.cancel(cancellationError).catch(() => {
6897
+ return;
6898
+ });
6690
6899
  }
6691
6900
  },
6692
6901
  waitUntilDone: () => {
@@ -7858,6 +8067,7 @@ var useMediaInTimeline = ({
7858
8067
  id,
7859
8068
  duration,
7860
8069
  from: 0,
8070
+ trimBefore: null,
7861
8071
  parent: parentSequence?.id ?? null,
7862
8072
  displayName: finalDisplayName,
7863
8073
  documentationLink,
@@ -8720,11 +8930,11 @@ var useMediaTag = ({
8720
8930
  ]);
8721
8931
  };
8722
8932
  var MediaVolumeContext = createContext22({
8723
- mediaMuted: false,
8933
+ playerMuted: false,
8724
8934
  mediaVolume: 1
8725
8935
  });
8726
8936
  var SetMediaVolumeContext = createContext22({
8727
- setMediaMuted: () => {
8937
+ setPlayerMuted: () => {
8728
8938
  throw new Error("default");
8729
8939
  },
8730
8940
  setMediaVolume: () => {
@@ -8738,12 +8948,12 @@ var useMediaVolumeState = () => {
8738
8948
  return [mediaVolume, setMediaVolume];
8739
8949
  }, [mediaVolume, setMediaVolume]);
8740
8950
  };
8741
- var useMediaMutedState = () => {
8742
- const { mediaMuted } = useContext27(MediaVolumeContext);
8743
- const { setMediaMuted } = useContext27(SetMediaVolumeContext);
8951
+ var usePlayerMutedState = () => {
8952
+ const { playerMuted } = useContext27(MediaVolumeContext);
8953
+ const { setPlayerMuted } = useContext27(SetMediaVolumeContext);
8744
8954
  return useMemo26(() => {
8745
- return [mediaMuted, setMediaMuted];
8746
- }, [mediaMuted, setMediaMuted]);
8955
+ return [playerMuted, setPlayerMuted];
8956
+ }, [playerMuted, setPlayerMuted]);
8747
8957
  };
8748
8958
  var warnAboutTooHighVolume = (volume) => {
8749
8959
  if (volume >= 100) {
@@ -8789,7 +8999,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
8789
8999
  throw new Error("typecheck error");
8790
9000
  }
8791
9001
  const [mediaVolume] = useMediaVolumeState();
8792
- const [mediaMuted] = useMediaMutedState();
9002
+ const [playerMuted] = usePlayerMutedState();
8793
9003
  const volumePropFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
8794
9004
  if (!src) {
8795
9005
  throw new TypeError("No 'src' was passed to <Html5Audio>.");
@@ -8810,7 +9020,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
8810
9020
  });
8811
9021
  const propsToPass = useMemo27(() => {
8812
9022
  return {
8813
- muted: muted || mediaMuted || userPreferredVolume <= 0,
9023
+ muted: muted || playerMuted || userPreferredVolume <= 0,
8814
9024
  src: preloadedSrc,
8815
9025
  loop: _remotionInternalNativeLoopPassed,
8816
9026
  crossOrigin: crossOriginValue,
@@ -8818,7 +9028,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
8818
9028
  };
8819
9029
  }, [
8820
9030
  _remotionInternalNativeLoopPassed,
8821
- mediaMuted,
9031
+ playerMuted,
8822
9032
  muted,
8823
9033
  nativeProps,
8824
9034
  preloadedSrc,
@@ -9066,6 +9276,7 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
9066
9276
  var AudioForRendering = forwardRef6(AudioForRenderingRefForwardingFunction);
9067
9277
  var AudioRefForwardingFunction = (props, ref) => {
9068
9278
  const audioTagsContext = useContext30(SharedAudioTagsContext);
9279
+ const propsWithFreeze = props;
9069
9280
  const {
9070
9281
  startFrom,
9071
9282
  endAt,
@@ -9076,14 +9287,18 @@ var AudioRefForwardingFunction = (props, ref) => {
9076
9287
  pauseWhenBuffering,
9077
9288
  showInTimeline,
9078
9289
  onError: onRemotionError,
9290
+ freeze,
9079
9291
  ...otherProps
9080
- } = props;
9081
- const { loop, ...propsOtherThanLoop } = props;
9292
+ } = propsWithFreeze;
9293
+ const { loop, freeze: _freeze, ...propsOtherThanLoop } = propsWithFreeze;
9082
9294
  const { fps } = useVideoConfig();
9083
9295
  const environment = useRemotionEnvironment();
9084
9296
  if (environment.isClientSideRendering) {
9085
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");
9086
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
+ }
9087
9302
  const { durations, setDurations } = useContext30(DurationsContext);
9088
9303
  if (typeof props.src !== "string") {
9089
9304
  throw new TypeError(`The \`<Html5Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
@@ -9215,6 +9430,15 @@ var solidSchema = {
9215
9430
  description: "Height",
9216
9431
  hiddenFromList: false
9217
9432
  },
9433
+ pixelDensity: {
9434
+ type: "number",
9435
+ min: 1,
9436
+ max: 3,
9437
+ step: 0.1,
9438
+ default: 1,
9439
+ description: "Pixel density",
9440
+ hiddenFromList: false
9441
+ },
9218
9442
  ...transformSchema
9219
9443
  };
9220
9444
  var SolidInner = ({
@@ -9331,6 +9555,7 @@ var SolidOuter = forwardRef8(({
9331
9555
  style,
9332
9556
  name,
9333
9557
  from,
9558
+ trimBefore,
9334
9559
  freeze,
9335
9560
  hidden,
9336
9561
  showInTimeline,
@@ -9345,6 +9570,7 @@ var SolidOuter = forwardRef8(({
9345
9570
  return /* @__PURE__ */ jsx24(Sequence, {
9346
9571
  layout: "none",
9347
9572
  from,
9573
+ trimBefore,
9348
9574
  freeze,
9349
9575
  hidden,
9350
9576
  showInTimeline,
@@ -9411,6 +9637,10 @@ function resolveHtmlInCanvasPixelDensity(pixelDensity) {
9411
9637
  }
9412
9638
  return pixelDensity;
9413
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.";
9414
9644
  var resizeOffscreenCanvas = ({
9415
9645
  offscreen,
9416
9646
  width,
@@ -9454,6 +9684,7 @@ var HtmlInCanvasContent = forwardRef9(({
9454
9684
  const canvasWidth = Math.ceil(width * resolvedPixelDensity);
9455
9685
  const canvasHeight = Math.ceil(height * resolvedPixelDensity);
9456
9686
  const { continueRender: continueRender2, cancelRender: cancelRender2 } = useDelayRender();
9687
+ const { isRendering } = useRemotionEnvironment();
9457
9688
  if (!isHtmlInCanvasSupported()) {
9458
9689
  cancelRender2(new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE));
9459
9690
  }
@@ -9502,34 +9733,53 @@ var HtmlInCanvasContent = forwardRef9(({
9502
9733
  if (!placeholderCanvas) {
9503
9734
  throw new Error("Canvas not found");
9504
9735
  }
9505
- const offscreen2d = offscreen.getContext("2d");
9506
- if (!offscreen2d) {
9507
- throw new Error("Failed to acquire 2D context for <HtmlInCanvas> offscreen canvas");
9508
- }
9509
9736
  const handle = delayRender("onPaint");
9510
9737
  if (!initializedRef.current) {
9511
- initializedRef.current = true;
9512
- const initImage = placeholderCanvas.captureElementImage(element);
9513
- const currentOnInit = onInitRef.current;
9514
- if (currentOnInit) {
9515
- const cleanup = await currentOnInit({
9516
- canvas: offscreen,
9517
- element,
9518
- elementImage: initImage,
9519
- pixelDensity: resolvedPixelDensity
9520
- });
9521
- if (typeof cleanup !== "function") {
9522
- throw new Error("HtmlInCanvas: when `onInit` is provided, it must return a cleanup function, or a Promise that resolves to one.");
9523
- }
9524
- if (unmountedRef.current) {
9525
- 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);
9526
9744
  } else {
9527
- 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
+ }
9528
9766
  }
9529
9767
  }
9530
9768
  }
9531
9769
  const handler = onPaintRef.current ?? defaultOnPaint;
9532
- 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
+ }
9533
9783
  await handler({
9534
9784
  canvas: offscreen,
9535
9785
  element,
@@ -9554,7 +9804,8 @@ var HtmlInCanvasContent = forwardRef9(({
9554
9804
  chainState,
9555
9805
  continueRender2,
9556
9806
  cancelRender2,
9557
- resolvedPixelDensity
9807
+ resolvedPixelDensity,
9808
+ isRendering
9558
9809
  ]);
9559
9810
  useLayoutEffect9(() => {
9560
9811
  const placeholder = canvas2dRef.current;
@@ -9690,6 +9941,15 @@ var HtmlInCanvasInner = forwardRef9(({
9690
9941
  HtmlInCanvasInner.displayName = "HtmlInCanvas";
9691
9942
  var htmlInCanvasSchema = {
9692
9943
  ...baseSchema,
9944
+ pixelDensity: {
9945
+ type: "number",
9946
+ min: 1,
9947
+ max: 3,
9948
+ step: 0.1,
9949
+ default: 1,
9950
+ description: "Pixel density",
9951
+ hiddenFromList: false
9952
+ },
9693
9953
  ...transformSchema
9694
9954
  };
9695
9955
  var HtmlInCanvasWrapped = withInteractivitySchema({
@@ -10007,6 +10267,7 @@ var CanvasImageInner = forwardRef10(({
10007
10267
  delayRenderTimeoutInMilliseconds,
10008
10268
  durationInFrames,
10009
10269
  from,
10270
+ trimBefore,
10010
10271
  freeze,
10011
10272
  hidden,
10012
10273
  name,
@@ -10028,6 +10289,7 @@ var CanvasImageInner = forwardRef10(({
10028
10289
  return /* @__PURE__ */ jsx26(Sequence, {
10029
10290
  layout: "none",
10030
10291
  from: from ?? 0,
10292
+ trimBefore,
10031
10293
  durationInFrames: durationInFrames ?? Infinity,
10032
10294
  freeze,
10033
10295
  hidden,
@@ -10264,6 +10526,7 @@ var NativeImgInner = ({
10264
10526
  showInTimeline,
10265
10527
  src,
10266
10528
  from,
10529
+ trimBefore,
10267
10530
  durationInFrames,
10268
10531
  freeze,
10269
10532
  controls,
@@ -10276,6 +10539,7 @@ var NativeImgInner = ({
10276
10539
  return /* @__PURE__ */ jsx28(Sequence, {
10277
10540
  layout: "none",
10278
10541
  from: from ?? 0,
10542
+ trimBefore,
10279
10543
  durationInFrames: durationInFrames ?? Infinity,
10280
10544
  freeze,
10281
10545
  _remotionInternalStack: stack,
@@ -10349,6 +10613,7 @@ var ImgInner = ({
10349
10613
  showInTimeline,
10350
10614
  src,
10351
10615
  from,
10616
+ trimBefore,
10352
10617
  durationInFrames,
10353
10618
  freeze,
10354
10619
  controls,
@@ -10374,6 +10639,7 @@ var ImgInner = ({
10374
10639
  showInTimeline,
10375
10640
  src,
10376
10641
  from,
10642
+ trimBefore,
10377
10643
  durationInFrames,
10378
10644
  freeze,
10379
10645
  controls,
@@ -10416,6 +10682,7 @@ var ImgInner = ({
10416
10682
  delayRenderRetries,
10417
10683
  delayRenderTimeoutInMilliseconds,
10418
10684
  from,
10685
+ trimBefore,
10419
10686
  durationInFrames,
10420
10687
  freeze,
10421
10688
  hidden,
@@ -10438,7 +10705,8 @@ var Img = withInteractivitySchema({
10438
10705
  addSequenceStackTraces(Img);
10439
10706
  var interactiveElementSchema = {
10440
10707
  ...baseSchema,
10441
- ...transformSchema
10708
+ ...transformSchema,
10709
+ ...textSchema
10442
10710
  };
10443
10711
  var setRef = (ref, value) => {
10444
10712
  if (typeof ref === "function") {
@@ -10452,6 +10720,7 @@ var makeInteractiveElement = (tag, displayName) => {
10452
10720
  const {
10453
10721
  durationInFrames,
10454
10722
  from,
10723
+ trimBefore,
10455
10724
  freeze,
10456
10725
  hidden,
10457
10726
  name,
@@ -10468,6 +10737,7 @@ var makeInteractiveElement = (tag, displayName) => {
10468
10737
  return /* @__PURE__ */ jsx29(Sequence, {
10469
10738
  layout: "none",
10470
10739
  from: from ?? 0,
10740
+ trimBefore,
10471
10741
  durationInFrames: durationInFrames ?? Infinity,
10472
10742
  freeze,
10473
10743
  hidden,
@@ -10498,6 +10768,7 @@ var makeInteractiveElement = (tag, displayName) => {
10498
10768
  var Interactive = {
10499
10769
  baseSchema,
10500
10770
  transformSchema,
10771
+ textSchema,
10501
10772
  premountSchema,
10502
10773
  sequenceSchema,
10503
10774
  withSchema: withInteractivitySchema,
@@ -11327,7 +11598,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
11327
11598
  throw new Error("acceptableTimeShift has been removed. Use acceptableTimeShiftInSeconds instead.");
11328
11599
  }
11329
11600
  const [mediaVolume] = useMediaVolumeState();
11330
- const [mediaMuted] = useMediaMutedState();
11601
+ const [playerMuted] = usePlayerMutedState();
11331
11602
  const userPreferredVolume = evaluateVolume({
11332
11603
  frame: volumePropFrame,
11333
11604
  volume,
@@ -11483,7 +11754,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
11483
11754
  return /* @__PURE__ */ jsx34("video", {
11484
11755
  ...nativeProps,
11485
11756
  ref: videoRef,
11486
- muted: muted || mediaMuted || userPreferredVolume <= 0,
11757
+ muted: muted || playerMuted || userPreferredVolume <= 0,
11487
11758
  playsInline: true,
11488
11759
  src: actualSrc,
11489
11760
  loop: _remotionInternalNativeLoopPassed,
@@ -11774,6 +12045,7 @@ var Internals = {
11774
12045
  sequenceStyleSchema,
11775
12046
  sequenceVisualStyleSchema,
11776
12047
  sequencePremountSchema,
12048
+ textSchema,
11777
12049
  transformSchema,
11778
12050
  premountSchema,
11779
12051
  flattenActiveSchema,
@@ -11783,7 +12055,7 @@ var Internals = {
11783
12055
  useVideo,
11784
12056
  getRoot,
11785
12057
  useMediaVolumeState,
11786
- useMediaMutedState,
12058
+ usePlayerMutedState,
11787
12059
  useMediaInTimeline,
11788
12060
  useLazyComponent,
11789
12061
  truthy,