@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/design.js CHANGED
@@ -5565,7 +5565,7 @@ var getComponentsToAddStacksTo = () => componentsToAddStacksTo;
5565
5565
  var addSequenceStackTraces = (component) => {
5566
5566
  componentsToAddStacksTo.push(component);
5567
5567
  };
5568
- var VERSION = "4.0.481";
5568
+ var VERSION = "4.0.483";
5569
5569
  var checkMultipleRemotionVersions = () => {
5570
5570
  if (typeof globalThis === "undefined") {
5571
5571
  return;
@@ -5965,6 +5965,77 @@ var transformSchema = {
5965
5965
  }
5966
5966
  };
5967
5967
  var sequenceVisualStyleSchema = transformSchema;
5968
+ var textSchema = {
5969
+ "style.color": {
5970
+ type: "color",
5971
+ default: undefined,
5972
+ description: "Color"
5973
+ },
5974
+ "style.fontSize": {
5975
+ type: "number",
5976
+ default: undefined,
5977
+ min: 0,
5978
+ step: 1,
5979
+ description: "Font size",
5980
+ hiddenFromList: false
5981
+ },
5982
+ "style.lineHeight": {
5983
+ type: "number",
5984
+ default: undefined,
5985
+ min: 0,
5986
+ step: 0.05,
5987
+ description: "Line height",
5988
+ hiddenFromList: false
5989
+ },
5990
+ "style.fontWeight": {
5991
+ type: "enum",
5992
+ default: "400",
5993
+ description: "Font weight",
5994
+ variants: {
5995
+ "100": {},
5996
+ "200": {},
5997
+ "300": {},
5998
+ "400": {},
5999
+ "500": {},
6000
+ "600": {},
6001
+ "700": {},
6002
+ "800": {},
6003
+ "900": {},
6004
+ normal: {},
6005
+ bold: {}
6006
+ }
6007
+ },
6008
+ "style.fontStyle": {
6009
+ type: "enum",
6010
+ default: "normal",
6011
+ description: "Font style",
6012
+ variants: {
6013
+ normal: {},
6014
+ italic: {},
6015
+ oblique: {}
6016
+ }
6017
+ },
6018
+ "style.textAlign": {
6019
+ type: "enum",
6020
+ default: "left",
6021
+ description: "Text align",
6022
+ variants: {
6023
+ left: {},
6024
+ center: {},
6025
+ right: {},
6026
+ justify: {},
6027
+ start: {},
6028
+ end: {}
6029
+ }
6030
+ },
6031
+ "style.letterSpacing": {
6032
+ type: "number",
6033
+ default: undefined,
6034
+ step: 0.1,
6035
+ description: "Letter spacing",
6036
+ hiddenFromList: false
6037
+ }
6038
+ };
5968
6039
  var premountSchema = {
5969
6040
  premountFor: {
5970
6041
  type: "number",
@@ -6023,6 +6094,13 @@ var fromField = {
6023
6094
  step: 1,
6024
6095
  hiddenFromList: true
6025
6096
  };
6097
+ var trimBeforeField = {
6098
+ type: "number",
6099
+ default: 0,
6100
+ min: 0,
6101
+ step: 1,
6102
+ hiddenFromList: true
6103
+ };
6026
6104
  var freezeField = {
6027
6105
  type: "number",
6028
6106
  default: null,
@@ -6032,6 +6110,7 @@ var freezeField = {
6032
6110
  var baseSchema = {
6033
6111
  durationInFrames: durationInFramesField,
6034
6112
  from: fromField,
6113
+ trimBefore: trimBeforeField,
6035
6114
  freeze: freezeField,
6036
6115
  hidden: hiddenField,
6037
6116
  name: sequenceNameField,
@@ -6051,6 +6130,7 @@ var sequenceSchema = {
6051
6130
  };
6052
6131
  var baseSchemaWithoutFrom = {
6053
6132
  durationInFrames: durationInFramesField,
6133
+ trimBefore: trimBeforeField,
6054
6134
  freeze: freezeField,
6055
6135
  hidden: hiddenField,
6056
6136
  name: sequenceNameField,
@@ -6701,6 +6781,35 @@ function findRange(input, inputRange) {
6701
6781
  return i - 1;
6702
6782
  }
6703
6783
  var defaultEasing = (num) => num;
6784
+ var shouldExtendRightForEasing = (easing) => {
6785
+ return easing.remotionShouldExtendRight === true;
6786
+ };
6787
+ var resolveEasingForSegment = ({
6788
+ easing,
6789
+ segmentIndex
6790
+ }) => {
6791
+ if (easing === undefined) {
6792
+ return defaultEasing;
6793
+ }
6794
+ if (typeof easing === "function") {
6795
+ return easing;
6796
+ }
6797
+ return easing[segmentIndex];
6798
+ };
6799
+ var interpolateSegment = ({
6800
+ input,
6801
+ inputRange,
6802
+ outputRange,
6803
+ easing,
6804
+ extrapolateLeft,
6805
+ extrapolateRight
6806
+ }) => {
6807
+ return interpolateFunction(input, inputRange, outputRange, {
6808
+ easing,
6809
+ extrapolateLeft,
6810
+ extrapolateRight: input > inputRange[1] && extrapolateRight === "clamp" && shouldExtendRightForEasing(easing) ? "extend" : extrapolateRight
6811
+ });
6812
+ };
6704
6813
  var interpolateNumber = ({
6705
6814
  input,
6706
6815
  inputRange,
@@ -6711,15 +6820,6 @@ var interpolateNumber = ({
6711
6820
  return outputRange[0];
6712
6821
  }
6713
6822
  const easingOption = options?.easing;
6714
- const resolveEasingForSegment = (segmentIndex) => {
6715
- if (easingOption === undefined) {
6716
- return defaultEasing;
6717
- }
6718
- if (typeof easingOption === "function") {
6719
- return easingOption;
6720
- }
6721
- return easingOption[segmentIndex];
6722
- };
6723
6823
  let extrapolateLeft = "extend";
6724
6824
  if (options?.extrapolateLeft !== undefined) {
6725
6825
  extrapolateLeft = options.extrapolateLeft;
@@ -6730,11 +6830,41 @@ var interpolateNumber = ({
6730
6830
  }
6731
6831
  const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
6732
6832
  const range = findRange(posterizedInput, inputRange);
6733
- return interpolateFunction(posterizedInput, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
6734
- easing: resolveEasingForSegment(range),
6833
+ const easing = resolveEasingForSegment({
6834
+ easing: easingOption,
6835
+ segmentIndex: range
6836
+ });
6837
+ let result = interpolateSegment({
6838
+ input: posterizedInput,
6839
+ inputRange: [inputRange[range], inputRange[range + 1]],
6840
+ outputRange: [outputRange[range], outputRange[range + 1]],
6841
+ easing,
6735
6842
  extrapolateLeft,
6736
6843
  extrapolateRight
6737
6844
  });
6845
+ for (let segmentIndex = 0;segmentIndex < range; segmentIndex++) {
6846
+ const previousEasing = resolveEasingForSegment({
6847
+ easing: easingOption,
6848
+ segmentIndex
6849
+ });
6850
+ if (!shouldExtendRightForEasing(previousEasing)) {
6851
+ continue;
6852
+ }
6853
+ const previousSegmentEnd = inputRange[segmentIndex + 1];
6854
+ if (posterizedInput <= previousSegmentEnd) {
6855
+ continue;
6856
+ }
6857
+ const continuedSegmentValue = interpolateSegment({
6858
+ input: posterizedInput,
6859
+ inputRange: [inputRange[segmentIndex], previousSegmentEnd],
6860
+ outputRange: [outputRange[segmentIndex], outputRange[segmentIndex + 1]],
6861
+ easing: previousEasing,
6862
+ extrapolateLeft,
6863
+ extrapolateRight: "extend"
6864
+ });
6865
+ result += continuedSegmentValue - outputRange[segmentIndex + 1];
6866
+ }
6867
+ return result;
6738
6868
  };
6739
6869
  var interpolateString = ({
6740
6870
  input,
@@ -7208,21 +7338,40 @@ class Easing {
7208
7338
  static back(s = 1.70158) {
7209
7339
  return (t) => t * t * ((s + 1) * t - s);
7210
7340
  }
7211
- static spring(config = {}) {
7212
- return (t) => {
7341
+ static spring({
7342
+ allowTail = false,
7343
+ durationRestThreshold,
7344
+ ...config
7345
+ } = {}) {
7346
+ const easing = (t) => {
7213
7347
  if (t <= 0) {
7214
7348
  return 0;
7215
7349
  }
7216
- if (t >= 1) {
7350
+ if (!allowTail && t >= 1) {
7217
7351
  return 1;
7218
7352
  }
7353
+ if (allowTail) {
7354
+ return spring({
7355
+ fps: springEasingDurationInFrames,
7356
+ frame: t * measureSpring({
7357
+ fps: springEasingDurationInFrames,
7358
+ config,
7359
+ threshold: durationRestThreshold
7360
+ }),
7361
+ config
7362
+ });
7363
+ }
7219
7364
  return spring({
7220
7365
  fps: springEasingDurationInFrames,
7221
7366
  frame: t * springEasingDurationInFrames,
7222
7367
  config,
7223
- durationInFrames: springEasingDurationInFrames
7368
+ durationInFrames: springEasingDurationInFrames,
7369
+ durationRestThreshold
7224
7370
  });
7225
7371
  };
7372
+ return Object.assign(easing, {
7373
+ remotionShouldExtendRight: allowTail
7374
+ });
7226
7375
  }
7227
7376
  static bounce(t) {
7228
7377
  const u = clampUnit(t);
@@ -7753,25 +7902,31 @@ var interpolateColors = (input, inputRange, outputRange, options) => {
7753
7902
  const processedOutputRange = outputRange.map((c2) => processColor(c2));
7754
7903
  return interpolateColorsRGB(input, inputRange, processedOutputRange, options);
7755
7904
  };
7756
- var easingToFn = (e) => {
7757
- switch (e.type) {
7905
+ var easingToFn = ({
7906
+ easing,
7907
+ forceSpringAllowTail
7908
+ }) => {
7909
+ switch (easing.type) {
7758
7910
  case "linear":
7759
7911
  return Easing.linear;
7760
7912
  case "spring":
7761
7913
  return Easing.spring({
7762
- damping: e.damping,
7763
- mass: e.mass,
7764
- overshootClamping: e.overshootClamping,
7765
- stiffness: e.stiffness
7914
+ allowTail: forceSpringAllowTail ?? easing.allowTail ?? undefined,
7915
+ damping: easing.damping,
7916
+ durationRestThreshold: easing.durationRestThreshold ?? undefined,
7917
+ mass: easing.mass,
7918
+ overshootClamping: easing.overshootClamping,
7919
+ stiffness: easing.stiffness
7766
7920
  });
7767
7921
  case "bezier":
7768
- return bezier(e.x1, e.y1, e.x2, e.y2);
7922
+ return bezier(easing.x1, easing.y1, easing.x2, easing.y2);
7769
7923
  default:
7770
- throw new TypeError(`Unsupported easing: ${JSON.stringify(e)}`);
7924
+ throw new TypeError(`Unsupported easing: ${JSON.stringify(easing)}`);
7771
7925
  }
7772
7926
  };
7773
7927
  var interpolateKeyframedStatus = ({
7774
7928
  frame,
7929
+ forceSpringAllowTail,
7775
7930
  status
7776
7931
  }) => {
7777
7932
  const { keyframes, easing, clamping, interpolationFunction } = status;
@@ -7790,7 +7945,7 @@ var interpolateKeyframedStatus = ({
7790
7945
  }
7791
7946
  try {
7792
7947
  return interpolateColors(frame, inputRange, outputs, {
7793
- easing: easing.map(easingToFn),
7948
+ easing: easing.map((e) => easingToFn({ easing: e, forceSpringAllowTail })),
7794
7949
  posterize: status.posterize
7795
7950
  });
7796
7951
  } catch {
@@ -7802,7 +7957,7 @@ var interpolateKeyframedStatus = ({
7802
7957
  }
7803
7958
  try {
7804
7959
  return interpolate(frame, inputRange, outputs, {
7805
- easing: easing.map(easingToFn),
7960
+ easing: easing.map((e) => easingToFn({ easing: e, forceSpringAllowTail })),
7806
7961
  extrapolateLeft: clamping.left,
7807
7962
  extrapolateRight: clamping.right,
7808
7963
  posterize: status.posterize
@@ -7825,6 +7980,7 @@ var resolveDragOverrideValue = ({
7825
7980
  return { type: "none" };
7826
7981
  }
7827
7982
  const interpolated = interpolateKeyframedStatus({
7983
+ forceSpringAllowTail: null,
7828
7984
  frame,
7829
7985
  status: dragOverrideValue.status
7830
7986
  });
@@ -7850,6 +8006,7 @@ var getEffectiveVisualModeValue = ({
7850
8006
  if (propStatus.status === "keyframed") {
7851
8007
  if (frame !== null) {
7852
8008
  return interpolateKeyframedStatus({
8009
+ forceSpringAllowTail: null,
7853
8010
  frame,
7854
8011
  status: propStatus
7855
8012
  });
@@ -7918,6 +8075,7 @@ var resolvePropStatusOverrides = (propStatus, frame) => {
7918
8075
  }
7919
8076
  if (status.status === "keyframed") {
7920
8077
  const value = interpolateKeyframedStatus({
8078
+ forceSpringAllowTail: null,
7921
8079
  frame,
7922
8080
  status
7923
8081
  });
@@ -8093,6 +8251,17 @@ var findPropsToDelete = ({
8093
8251
  var DEFAULT_LINEAR_EASING = {
8094
8252
  type: "linear"
8095
8253
  };
8254
+ var getEasingIndexToDuplicate = ({
8255
+ insertedKeyframeIndex,
8256
+ easingLength,
8257
+ keyframeCount
8258
+ }) => {
8259
+ const isSplittingExistingSegment = insertedKeyframeIndex > 0 && insertedKeyframeIndex < keyframeCount - 1;
8260
+ if (!isSplittingExistingSegment || easingLength === 0) {
8261
+ return null;
8262
+ }
8263
+ return Math.min(insertedKeyframeIndex - 1, easingLength - 1);
8264
+ };
8096
8265
  var makeStaticDragOverride = (value) => {
8097
8266
  return { type: "static", value };
8098
8267
  };
@@ -8104,6 +8273,16 @@ var makeKeyframedDragOverride = ({
8104
8273
  const existingIndex = status.keyframes.findIndex((keyframe) => keyframe.frame === frame);
8105
8274
  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);
8106
8275
  const easing = [...status.easing];
8276
+ if (existingIndex === -1) {
8277
+ const insertedKeyframeIndex = keyframes.findIndex((keyframe) => keyframe.frame === frame);
8278
+ const easingIndexToDuplicate = getEasingIndexToDuplicate({
8279
+ insertedKeyframeIndex,
8280
+ easingLength: easing.length,
8281
+ keyframeCount: keyframes.length
8282
+ });
8283
+ const easingToDuplicate = easingIndexToDuplicate === null ? DEFAULT_LINEAR_EASING : easing[easingIndexToDuplicate];
8284
+ easing.splice(insertedKeyframeIndex, 0, easingToDuplicate);
8285
+ }
8107
8286
  while (easing.length < keyframes.length - 1) {
8108
8287
  easing.push(DEFAULT_LINEAR_EASING);
8109
8288
  }
@@ -8175,6 +8354,7 @@ var computeEffectiveSchemaValuesDotNotation = ({
8175
8354
  value = dragOverride.value;
8176
8355
  } else if (frame !== null) {
8177
8356
  const interpolated = interpolateKeyframedStatus({
8357
+ forceSpringAllowTail: null,
8178
8358
  frame,
8179
8359
  status
8180
8360
  });
@@ -8352,6 +8532,7 @@ var withInteractivitySchema = ({
8352
8532
  var EMPTY_EFFECTS = [];
8353
8533
  var RegularSequenceRefForwardingFunction = ({
8354
8534
  from = 0,
8535
+ trimBefore = 0,
8355
8536
  freeze,
8356
8537
  durationInFrames = Infinity,
8357
8538
  children,
@@ -8376,7 +8557,6 @@ var RegularSequenceRefForwardingFunction = ({
8376
8557
  const parentSequence = useContext17(SequenceContext);
8377
8558
  const { rootId } = useTimelineContext();
8378
8559
  const cumulatedFrom = parentSequence ? parentSequence.cumulatedFrom + parentSequence.relativeFrom : 0;
8379
- const absoluteFrom = (parentSequence?.absoluteFrom ?? 0) + from;
8380
8560
  const nonce = useNonce();
8381
8561
  if (layout !== "absolute-fill" && layout !== "none") {
8382
8562
  throw new TypeError(`The layout prop of <Sequence /> expects either "absolute-fill" or "none", but you passed: ${layout}`);
@@ -8396,6 +8576,18 @@ var RegularSequenceRefForwardingFunction = ({
8396
8576
  if (!Number.isFinite(from)) {
8397
8577
  throw new TypeError(`The "from" prop of a sequence must be finite, but got ${from}.`);
8398
8578
  }
8579
+ if (typeof trimBefore !== "number") {
8580
+ throw new TypeError(`You passed to the "trimBefore" prop of your <Sequence> an argument of type ${typeof trimBefore}, but it must be a number.`);
8581
+ }
8582
+ if (trimBefore < 0) {
8583
+ throw new TypeError(`The "trimBefore" prop of <Sequence /> must be greater than or equal to 0, but got ${trimBefore}.`);
8584
+ }
8585
+ if (Number.isNaN(trimBefore)) {
8586
+ throw new TypeError('The "trimBefore" prop of <Sequence /> must be a real number, but it is NaN.');
8587
+ }
8588
+ if (!Number.isFinite(trimBefore)) {
8589
+ throw new TypeError(`The "trimBefore" prop of <Sequence /> must be finite, but it is ${trimBefore}.`);
8590
+ }
8399
8591
  if (typeof freeze !== "undefined" && freeze !== null) {
8400
8592
  if (typeof freeze !== "number") {
8401
8593
  throw new TypeError(`The "freeze" prop of <Sequence /> must be a number, but is of type ${typeof freeze}.`);
@@ -8409,7 +8601,9 @@ var RegularSequenceRefForwardingFunction = ({
8409
8601
  }
8410
8602
  const absoluteFrame = useTimelinePosition();
8411
8603
  const videoConfig = useVideoConfig();
8412
- const parentSequenceDuration = parentSequence ? Math.min(parentSequence.durationInFrames - from, durationInFrames) : durationInFrames;
8604
+ const effectiveRelativeFrom = from - trimBefore;
8605
+ const absoluteFrom = (parentSequence?.absoluteFrom ?? 0) + effectiveRelativeFrom;
8606
+ const parentSequenceDuration = parentSequence ? Math.min(parentSequence.durationInFrames - effectiveRelativeFrom, durationInFrames) : durationInFrames;
8413
8607
  const actualDurationInFrames = Math.max(0, Math.min(videoConfig.durationInFrames - from, parentSequenceDuration));
8414
8608
  const { registerSequence, unregisterSequence } = useContext17(SequenceManager);
8415
8609
  const wrapperRefForOutline = useRef6(null);
@@ -8420,7 +8614,7 @@ var RegularSequenceRefForwardingFunction = ({
8420
8614
  const postmounting = useMemo14(() => {
8421
8615
  return parentSequence?.postmounting || Boolean(other._remotionInternalIsPostmounting);
8422
8616
  }, [other._remotionInternalIsPostmounting, parentSequence?.postmounting]);
8423
- const currentSequenceStart = cumulatedFrom + from;
8617
+ const currentSequenceStart = cumulatedFrom + effectiveRelativeFrom;
8424
8618
  const parentSequenceStart = parentSequence ? parentSequence.cumulatedFrom + parentSequence.relativeFrom : 0;
8425
8619
  const parentFirstFrame = parentSequence ? parentSequenceStart - parentSequence.cumulatedNegativeFrom : 0;
8426
8620
  const firstFrame = Math.max(0, parentFirstFrame, currentSequenceStart);
@@ -8429,7 +8623,7 @@ var RegularSequenceRefForwardingFunction = ({
8429
8623
  return {
8430
8624
  absoluteFrom,
8431
8625
  cumulatedFrom,
8432
- relativeFrom: from,
8626
+ relativeFrom: effectiveRelativeFrom,
8433
8627
  cumulatedNegativeFrom,
8434
8628
  durationInFrames: actualDurationInFrames,
8435
8629
  parentFrom: parentSequence?.relativeFrom ?? 0,
@@ -8444,7 +8638,7 @@ var RegularSequenceRefForwardingFunction = ({
8444
8638
  }, [
8445
8639
  cumulatedFrom,
8446
8640
  absoluteFrom,
8447
- from,
8641
+ effectiveRelativeFrom,
8448
8642
  actualDurationInFrames,
8449
8643
  parentSequence,
8450
8644
  id,
@@ -8466,6 +8660,7 @@ var RegularSequenceRefForwardingFunction = ({
8466
8660
  const stackRef = useRef6(null);
8467
8661
  stackRef.current = stack ?? inheritedStack;
8468
8662
  const registeredFrozenFrame = typeof freeze === "number" ? freeze : null;
8663
+ const registeredTrimBefore = trimBefore === 0 ? null : trimBefore;
8469
8664
  const parentCumulatedNegativeFrom = parentSequence?.cumulatedNegativeFrom ?? 0;
8470
8665
  const startMediaFrom = isMedia && isMedia.type !== "image" ? isMedia.data.startMediaFrom + parentCumulatedNegativeFrom - cumulatedNegativeFrom : null;
8471
8666
  const mediaFrameAtSequenceZero = isMedia && isMedia.type !== "image" ? isMedia.data.startMediaFrom + parentCumulatedNegativeFrom : null;
@@ -8484,6 +8679,7 @@ var RegularSequenceRefForwardingFunction = ({
8484
8679
  documentationLink: resolvedDocumentationLink,
8485
8680
  duration: actualDurationInFrames,
8486
8681
  from,
8682
+ trimBefore: registeredTrimBefore,
8487
8683
  id,
8488
8684
  loopDisplay,
8489
8685
  nonce: nonce.get(),
@@ -8508,6 +8704,7 @@ var RegularSequenceRefForwardingFunction = ({
8508
8704
  doesVolumeChange: isMedia.data.doesVolumeChange,
8509
8705
  duration: actualDurationInFrames,
8510
8706
  from,
8707
+ trimBefore: registeredTrimBefore,
8511
8708
  id,
8512
8709
  loopDisplay,
8513
8710
  nonce: nonce.get(),
@@ -8533,6 +8730,7 @@ var RegularSequenceRefForwardingFunction = ({
8533
8730
  }
8534
8731
  registerSequence({
8535
8732
  from,
8733
+ trimBefore: registeredTrimBefore,
8536
8734
  duration: actualDurationInFrames,
8537
8735
  id,
8538
8736
  displayName: timelineClipName,
@@ -8566,6 +8764,8 @@ var RegularSequenceRefForwardingFunction = ({
8566
8764
  actualDurationInFrames,
8567
8765
  rootId,
8568
8766
  from,
8767
+ trimBefore,
8768
+ registeredTrimBefore,
8569
8769
  showInTimeline,
8570
8770
  nonce,
8571
8771
  loopDisplay,
@@ -9833,13 +10033,15 @@ var prefetch = (src, options) => {
9833
10033
  resolve = res;
9834
10034
  reject = rej;
9835
10035
  });
10036
+ waitUntilDone.catch(() => {
10037
+ return;
10038
+ });
9836
10039
  const controller = new AbortController;
9837
- let canBeAborted = true;
10040
+ let reader = null;
9838
10041
  fetch(srcWithoutHash, {
9839
10042
  signal: controller.signal,
9840
10043
  credentials: options?.credentials ?? undefined
9841
10044
  }).then((res) => {
9842
- canBeAborted = false;
9843
10045
  if (canceled) {
9844
10046
  return null;
9845
10047
  }
@@ -9855,15 +10057,16 @@ var prefetch = (src, options) => {
9855
10057
  if (!res.body) {
9856
10058
  throw new Error(`HTTP response of ${srcWithoutHash} has no body`);
9857
10059
  }
9858
- const reader = res.body.getReader();
10060
+ const responseReader = res.body.getReader();
10061
+ reader = responseReader;
9859
10062
  return getBlobFromReader({
9860
- reader,
10063
+ reader: responseReader,
9861
10064
  contentType: options?.contentType ?? headerContentType ?? null,
9862
10065
  contentLength: res.headers.get("Content-Length") ? parseInt(res.headers.get("Content-Length"), 10) : null,
9863
10066
  onProgress: options?.onProgress
9864
10067
  });
9865
10068
  }).then((buf) => {
9866
- if (!buf) {
10069
+ if (!buf || canceled) {
9867
10070
  return;
9868
10071
  }
9869
10072
  const actualBlob = options?.contentType ? new Blob([buf], { type: options.contentType }) : buf;
@@ -9911,12 +10114,18 @@ var prefetch = (src, options) => {
9911
10114
  return copy;
9912
10115
  });
9913
10116
  } else {
9914
- canceled = true;
9915
- if (canBeAborted) {
9916
- try {
9917
- controller.abort(new Error("free() called"));
9918
- } catch {}
10117
+ if (canceled) {
10118
+ return;
9919
10119
  }
10120
+ canceled = true;
10121
+ const cancellationError = new Error("free() called");
10122
+ reject(cancellationError);
10123
+ try {
10124
+ controller.abort(cancellationError);
10125
+ } catch {}
10126
+ reader?.cancel(cancellationError).catch(() => {
10127
+ return;
10128
+ });
9920
10129
  }
9921
10130
  },
9922
10131
  waitUntilDone: () => {
@@ -11088,6 +11297,7 @@ var useMediaInTimeline = ({
11088
11297
  id,
11089
11298
  duration,
11090
11299
  from: 0,
11300
+ trimBefore: null,
11091
11301
  parent: parentSequence?.id ?? null,
11092
11302
  displayName: finalDisplayName,
11093
11303
  documentationLink,
@@ -11950,11 +12160,11 @@ var useMediaTag = ({
11950
12160
  ]);
11951
12161
  };
11952
12162
  var MediaVolumeContext = createContext22({
11953
- mediaMuted: false,
12163
+ playerMuted: false,
11954
12164
  mediaVolume: 1
11955
12165
  });
11956
12166
  var SetMediaVolumeContext = createContext22({
11957
- setMediaMuted: () => {
12167
+ setPlayerMuted: () => {
11958
12168
  throw new Error("default");
11959
12169
  },
11960
12170
  setMediaVolume: () => {
@@ -11968,12 +12178,12 @@ var useMediaVolumeState = () => {
11968
12178
  return [mediaVolume, setMediaVolume];
11969
12179
  }, [mediaVolume, setMediaVolume]);
11970
12180
  };
11971
- var useMediaMutedState = () => {
11972
- const { mediaMuted } = useContext27(MediaVolumeContext);
11973
- const { setMediaMuted } = useContext27(SetMediaVolumeContext);
12181
+ var usePlayerMutedState = () => {
12182
+ const { playerMuted } = useContext27(MediaVolumeContext);
12183
+ const { setPlayerMuted } = useContext27(SetMediaVolumeContext);
11974
12184
  return useMemo26(() => {
11975
- return [mediaMuted, setMediaMuted];
11976
- }, [mediaMuted, setMediaMuted]);
12185
+ return [playerMuted, setPlayerMuted];
12186
+ }, [playerMuted, setPlayerMuted]);
11977
12187
  };
11978
12188
  var warnAboutTooHighVolume = (volume) => {
11979
12189
  if (volume >= 100) {
@@ -12019,7 +12229,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
12019
12229
  throw new Error("typecheck error");
12020
12230
  }
12021
12231
  const [mediaVolume] = useMediaVolumeState();
12022
- const [mediaMuted] = useMediaMutedState();
12232
+ const [playerMuted] = usePlayerMutedState();
12023
12233
  const volumePropFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
12024
12234
  if (!src) {
12025
12235
  throw new TypeError("No 'src' was passed to <Html5Audio>.");
@@ -12040,7 +12250,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
12040
12250
  });
12041
12251
  const propsToPass = useMemo27(() => {
12042
12252
  return {
12043
- muted: muted || mediaMuted || userPreferredVolume <= 0,
12253
+ muted: muted || playerMuted || userPreferredVolume <= 0,
12044
12254
  src: preloadedSrc,
12045
12255
  loop: _remotionInternalNativeLoopPassed,
12046
12256
  crossOrigin: crossOriginValue,
@@ -12048,7 +12258,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
12048
12258
  };
12049
12259
  }, [
12050
12260
  _remotionInternalNativeLoopPassed,
12051
- mediaMuted,
12261
+ playerMuted,
12052
12262
  muted,
12053
12263
  nativeProps,
12054
12264
  preloadedSrc,
@@ -12296,6 +12506,7 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
12296
12506
  var AudioForRendering = forwardRef6(AudioForRenderingRefForwardingFunction);
12297
12507
  var AudioRefForwardingFunction = (props, ref) => {
12298
12508
  const audioTagsContext = useContext30(SharedAudioTagsContext);
12509
+ const propsWithFreeze = props;
12299
12510
  const {
12300
12511
  startFrom,
12301
12512
  endAt,
@@ -12306,14 +12517,18 @@ var AudioRefForwardingFunction = (props, ref) => {
12306
12517
  pauseWhenBuffering,
12307
12518
  showInTimeline,
12308
12519
  onError: onRemotionError,
12520
+ freeze,
12309
12521
  ...otherProps
12310
- } = props;
12311
- const { loop, ...propsOtherThanLoop } = props;
12522
+ } = propsWithFreeze;
12523
+ const { loop, freeze: _freeze, ...propsOtherThanLoop } = propsWithFreeze;
12312
12524
  const { fps } = useVideoConfig();
12313
12525
  const environment = useRemotionEnvironment();
12314
12526
  if (environment.isClientSideRendering) {
12315
12527
  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");
12316
12528
  }
12529
+ if (typeof freeze !== "undefined") {
12530
+ throw new TypeError('The "freeze" prop is not supported on <Html5Audio />. Use <Sequence freeze={...}> to freeze media playback.');
12531
+ }
12317
12532
  const { durations, setDurations } = useContext30(DurationsContext);
12318
12533
  if (typeof props.src !== "string") {
12319
12534
  throw new TypeError(`The \`<Html5Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
@@ -12445,6 +12660,15 @@ var solidSchema = {
12445
12660
  description: "Height",
12446
12661
  hiddenFromList: false
12447
12662
  },
12663
+ pixelDensity: {
12664
+ type: "number",
12665
+ min: 1,
12666
+ max: 3,
12667
+ step: 0.1,
12668
+ default: 1,
12669
+ description: "Pixel density",
12670
+ hiddenFromList: false
12671
+ },
12448
12672
  ...transformSchema
12449
12673
  };
12450
12674
  var SolidInner = ({
@@ -12561,6 +12785,7 @@ var SolidOuter = forwardRef8(({
12561
12785
  style,
12562
12786
  name,
12563
12787
  from,
12788
+ trimBefore,
12564
12789
  freeze,
12565
12790
  hidden,
12566
12791
  showInTimeline,
@@ -12575,6 +12800,7 @@ var SolidOuter = forwardRef8(({
12575
12800
  return /* @__PURE__ */ jsx24(Sequence, {
12576
12801
  layout: "none",
12577
12802
  from,
12803
+ trimBefore,
12578
12804
  freeze,
12579
12805
  hidden,
12580
12806
  showInTimeline,
@@ -12641,6 +12867,10 @@ function resolveHtmlInCanvasPixelDensity(pixelDensity) {
12641
12867
  }
12642
12868
  return pixelDensity;
12643
12869
  }
12870
+ var isMissingPaintRecordError = (error2) => {
12871
+ return error2 instanceof DOMException && error2.name === "InvalidStateError";
12872
+ };
12873
+ var missingPaintRecordMessage = "HtmlInCanvas: Expected the element to be inside the viewport during rendering, but Chrome had no cached paint record for it.";
12644
12874
  var resizeOffscreenCanvas = ({
12645
12875
  offscreen,
12646
12876
  width,
@@ -12684,6 +12914,7 @@ var HtmlInCanvasContent = forwardRef9(({
12684
12914
  const canvasWidth = Math.ceil(width * resolvedPixelDensity);
12685
12915
  const canvasHeight = Math.ceil(height * resolvedPixelDensity);
12686
12916
  const { continueRender: continueRender2, cancelRender: cancelRender2 } = useDelayRender();
12917
+ const { isRendering } = useRemotionEnvironment();
12687
12918
  if (!isHtmlInCanvasSupported()) {
12688
12919
  cancelRender2(new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE));
12689
12920
  }
@@ -12732,34 +12963,53 @@ var HtmlInCanvasContent = forwardRef9(({
12732
12963
  if (!placeholderCanvas) {
12733
12964
  throw new Error("Canvas not found");
12734
12965
  }
12735
- const offscreen2d = offscreen.getContext("2d");
12736
- if (!offscreen2d) {
12737
- throw new Error("Failed to acquire 2D context for <HtmlInCanvas> offscreen canvas");
12738
- }
12739
12966
  const handle = delayRender("onPaint");
12740
12967
  if (!initializedRef.current) {
12741
- initializedRef.current = true;
12742
- const initImage = placeholderCanvas.captureElementImage(element);
12743
- const currentOnInit = onInitRef.current;
12744
- if (currentOnInit) {
12745
- const cleanup = await currentOnInit({
12746
- canvas: offscreen,
12747
- element,
12748
- elementImage: initImage,
12749
- pixelDensity: resolvedPixelDensity
12750
- });
12751
- if (typeof cleanup !== "function") {
12752
- throw new Error("HtmlInCanvas: when `onInit` is provided, it must return a cleanup function, or a Promise that resolves to one.");
12753
- }
12754
- if (unmountedRef.current) {
12755
- cleanup();
12968
+ let initImage = null;
12969
+ try {
12970
+ initImage = placeholderCanvas.captureElementImage(element);
12971
+ } catch (error2) {
12972
+ if (isMissingPaintRecordError(error2) && !isRendering) {} else if (isMissingPaintRecordError(error2)) {
12973
+ throw new Error(missingPaintRecordMessage);
12756
12974
  } else {
12757
- onInitCleanupRef.current = cleanup;
12975
+ throw error2;
12976
+ }
12977
+ }
12978
+ if (initImage) {
12979
+ initializedRef.current = true;
12980
+ const currentOnInit = onInitRef.current;
12981
+ if (currentOnInit) {
12982
+ const cleanup = await currentOnInit({
12983
+ canvas: offscreen,
12984
+ element,
12985
+ elementImage: initImage,
12986
+ pixelDensity: resolvedPixelDensity
12987
+ });
12988
+ if (typeof cleanup !== "function") {
12989
+ throw new Error("HtmlInCanvas: when `onInit` is provided, it must return a cleanup function, or a Promise that resolves to one.");
12990
+ }
12991
+ if (unmountedRef.current) {
12992
+ cleanup();
12993
+ } else {
12994
+ onInitCleanupRef.current = cleanup;
12995
+ }
12758
12996
  }
12759
12997
  }
12760
12998
  }
12761
12999
  const handler = onPaintRef.current ?? defaultOnPaint;
12762
- const elImage = placeholderCanvas.captureElementImage(element);
13000
+ let elImage;
13001
+ try {
13002
+ elImage = placeholderCanvas.captureElementImage(element);
13003
+ } catch (error2) {
13004
+ if (isMissingPaintRecordError(error2) && !isRendering) {
13005
+ continueRender2(handle);
13006
+ return;
13007
+ }
13008
+ if (isMissingPaintRecordError(error2)) {
13009
+ throw new Error(missingPaintRecordMessage);
13010
+ }
13011
+ throw error2;
13012
+ }
12763
13013
  await handler({
12764
13014
  canvas: offscreen,
12765
13015
  element,
@@ -12784,7 +13034,8 @@ var HtmlInCanvasContent = forwardRef9(({
12784
13034
  chainState,
12785
13035
  continueRender2,
12786
13036
  cancelRender2,
12787
- resolvedPixelDensity
13037
+ resolvedPixelDensity,
13038
+ isRendering
12788
13039
  ]);
12789
13040
  useLayoutEffect9(() => {
12790
13041
  const placeholder = canvas2dRef.current;
@@ -12920,6 +13171,15 @@ var HtmlInCanvasInner = forwardRef9(({
12920
13171
  HtmlInCanvasInner.displayName = "HtmlInCanvas";
12921
13172
  var htmlInCanvasSchema = {
12922
13173
  ...baseSchema,
13174
+ pixelDensity: {
13175
+ type: "number",
13176
+ min: 1,
13177
+ max: 3,
13178
+ step: 0.1,
13179
+ default: 1,
13180
+ description: "Pixel density",
13181
+ hiddenFromList: false
13182
+ },
12923
13183
  ...transformSchema
12924
13184
  };
12925
13185
  var HtmlInCanvasWrapped = withInteractivitySchema({
@@ -13237,6 +13497,7 @@ var CanvasImageInner = forwardRef10(({
13237
13497
  delayRenderTimeoutInMilliseconds,
13238
13498
  durationInFrames,
13239
13499
  from,
13500
+ trimBefore,
13240
13501
  freeze,
13241
13502
  hidden,
13242
13503
  name,
@@ -13258,6 +13519,7 @@ var CanvasImageInner = forwardRef10(({
13258
13519
  return /* @__PURE__ */ jsx26(Sequence, {
13259
13520
  layout: "none",
13260
13521
  from: from ?? 0,
13522
+ trimBefore,
13261
13523
  durationInFrames: durationInFrames ?? Infinity,
13262
13524
  freeze,
13263
13525
  hidden,
@@ -13494,6 +13756,7 @@ var NativeImgInner = ({
13494
13756
  showInTimeline,
13495
13757
  src,
13496
13758
  from,
13759
+ trimBefore,
13497
13760
  durationInFrames,
13498
13761
  freeze,
13499
13762
  controls,
@@ -13506,6 +13769,7 @@ var NativeImgInner = ({
13506
13769
  return /* @__PURE__ */ jsx28(Sequence, {
13507
13770
  layout: "none",
13508
13771
  from: from ?? 0,
13772
+ trimBefore,
13509
13773
  durationInFrames: durationInFrames ?? Infinity,
13510
13774
  freeze,
13511
13775
  _remotionInternalStack: stack,
@@ -13579,6 +13843,7 @@ var ImgInner = ({
13579
13843
  showInTimeline,
13580
13844
  src,
13581
13845
  from,
13846
+ trimBefore,
13582
13847
  durationInFrames,
13583
13848
  freeze,
13584
13849
  controls,
@@ -13604,6 +13869,7 @@ var ImgInner = ({
13604
13869
  showInTimeline,
13605
13870
  src,
13606
13871
  from,
13872
+ trimBefore,
13607
13873
  durationInFrames,
13608
13874
  freeze,
13609
13875
  controls,
@@ -13646,6 +13912,7 @@ var ImgInner = ({
13646
13912
  delayRenderRetries,
13647
13913
  delayRenderTimeoutInMilliseconds,
13648
13914
  from,
13915
+ trimBefore,
13649
13916
  durationInFrames,
13650
13917
  freeze,
13651
13918
  hidden,
@@ -13668,7 +13935,8 @@ var Img = withInteractivitySchema({
13668
13935
  addSequenceStackTraces(Img);
13669
13936
  var interactiveElementSchema = {
13670
13937
  ...baseSchema,
13671
- ...transformSchema
13938
+ ...transformSchema,
13939
+ ...textSchema
13672
13940
  };
13673
13941
  var setRef = (ref, value) => {
13674
13942
  if (typeof ref === "function") {
@@ -13682,6 +13950,7 @@ var makeInteractiveElement = (tag, displayName) => {
13682
13950
  const {
13683
13951
  durationInFrames,
13684
13952
  from,
13953
+ trimBefore,
13685
13954
  freeze,
13686
13955
  hidden,
13687
13956
  name,
@@ -13698,6 +13967,7 @@ var makeInteractiveElement = (tag, displayName) => {
13698
13967
  return /* @__PURE__ */ jsx29(Sequence, {
13699
13968
  layout: "none",
13700
13969
  from: from ?? 0,
13970
+ trimBefore,
13701
13971
  durationInFrames: durationInFrames ?? Infinity,
13702
13972
  freeze,
13703
13973
  hidden,
@@ -13728,6 +13998,7 @@ var makeInteractiveElement = (tag, displayName) => {
13728
13998
  var Interactive = {
13729
13999
  baseSchema,
13730
14000
  transformSchema,
14001
+ textSchema,
13731
14002
  premountSchema,
13732
14003
  sequenceSchema,
13733
14004
  withSchema: withInteractivitySchema,
@@ -14557,7 +14828,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
14557
14828
  throw new Error("acceptableTimeShift has been removed. Use acceptableTimeShiftInSeconds instead.");
14558
14829
  }
14559
14830
  const [mediaVolume] = useMediaVolumeState();
14560
- const [mediaMuted] = useMediaMutedState();
14831
+ const [playerMuted] = usePlayerMutedState();
14561
14832
  const userPreferredVolume = evaluateVolume({
14562
14833
  frame: volumePropFrame,
14563
14834
  volume,
@@ -14713,7 +14984,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
14713
14984
  return /* @__PURE__ */ jsx34("video", {
14714
14985
  ...nativeProps,
14715
14986
  ref: videoRef,
14716
- muted: muted || mediaMuted || userPreferredVolume <= 0,
14987
+ muted: muted || playerMuted || userPreferredVolume <= 0,
14717
14988
  playsInline: true,
14718
14989
  src: actualSrc,
14719
14990
  loop: _remotionInternalNativeLoopPassed,
@@ -15004,6 +15275,7 @@ var Internals = {
15004
15275
  sequenceStyleSchema,
15005
15276
  sequenceVisualStyleSchema,
15006
15277
  sequencePremountSchema,
15278
+ textSchema,
15007
15279
  transformSchema,
15008
15280
  premountSchema,
15009
15281
  flattenActiveSchema,
@@ -15013,7 +15285,7 @@ var Internals = {
15013
15285
  useVideo,
15014
15286
  getRoot,
15015
15287
  useMediaVolumeState,
15016
- useMediaMutedState,
15288
+ usePlayerMutedState,
15017
15289
  useMediaInTimeline,
15018
15290
  useLazyComponent,
15019
15291
  truthy,
@@ -15956,6 +16228,7 @@ var RenderSvg = ({
15956
16228
  pixelDensity,
15957
16229
  durationInFrames,
15958
16230
  from,
16231
+ trimBefore,
15959
16232
  freeze,
15960
16233
  hidden,
15961
16234
  name,
@@ -16065,6 +16338,7 @@ var RenderSvg = ({
16065
16338
  return /* @__PURE__ */ jsx40(Sequence, {
16066
16339
  layout: "none",
16067
16340
  from,
16341
+ trimBefore,
16068
16342
  freeze,
16069
16343
  hidden,
16070
16344
  showInTimeline,