remotion 4.0.475 → 4.0.476

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.
@@ -1291,7 +1291,7 @@ var addSequenceStackTraces = (component) => {
1291
1291
  };
1292
1292
 
1293
1293
  // src/version.ts
1294
- var VERSION = "4.0.475";
1294
+ var VERSION = "4.0.476";
1295
1295
 
1296
1296
  // src/multiple-versions-warning.ts
1297
1297
  var checkMultipleRemotionVersions = () => {
@@ -1786,6 +1786,18 @@ var hiddenField = {
1786
1786
  default: false,
1787
1787
  description: "Hidden"
1788
1788
  };
1789
+ var showInTimelineField = {
1790
+ type: "hidden"
1791
+ };
1792
+ var sequenceNameField = {
1793
+ type: "hidden"
1794
+ };
1795
+ var extendSchemaWithSequenceName = (schema) => {
1796
+ return {
1797
+ name: sequenceNameField,
1798
+ ...schema
1799
+ };
1800
+ };
1789
1801
  var durationInFramesField = {
1790
1802
  type: "number",
1791
1803
  default: undefined,
@@ -1799,8 +1811,9 @@ var fromField = {
1799
1811
  step: 1,
1800
1812
  hiddenFromList: true
1801
1813
  };
1802
- var sequenceSchema = {
1814
+ var sequenceSchema = extendSchemaWithSequenceName({
1803
1815
  hidden: hiddenField,
1816
+ showInTimeline: showInTimelineField,
1804
1817
  from: fromField,
1805
1818
  durationInFrames: durationInFramesField,
1806
1819
  layout: {
@@ -1812,12 +1825,13 @@ var sequenceSchema = {
1812
1825
  none: {}
1813
1826
  }
1814
1827
  }
1815
- };
1816
- var sequenceSchemaWithoutFrom = {
1828
+ });
1829
+ var sequenceSchemaWithoutFrom = extendSchemaWithSequenceName({
1817
1830
  hidden: hiddenField,
1831
+ showInTimeline: showInTimelineField,
1818
1832
  durationInFrames: durationInFramesField,
1819
1833
  layout: sequenceSchema.layout
1820
- };
1834
+ });
1821
1835
  var sequenceSchemaDefaultLayoutNone = {
1822
1836
  ...sequenceSchema,
1823
1837
  layout: {
@@ -2182,83 +2196,6 @@ function bezier(mX1, mY1, mX2, mY2) {
2182
2196
  };
2183
2197
  }
2184
2198
 
2185
- // src/easing.ts
2186
- var clampUnit = (t) => Math.min(1, Math.max(0, t));
2187
-
2188
- class Easing {
2189
- static step0(n) {
2190
- return n > 0 ? 1 : 0;
2191
- }
2192
- static step1(n) {
2193
- return n >= 1 ? 1 : 0;
2194
- }
2195
- static linear(t) {
2196
- return t;
2197
- }
2198
- static ease(t) {
2199
- return Easing.bezier(0.42, 0, 1, 1)(t);
2200
- }
2201
- static quad(t) {
2202
- return t * t;
2203
- }
2204
- static cubic(t) {
2205
- return t * t * t;
2206
- }
2207
- static poly(n) {
2208
- return (t) => t ** n;
2209
- }
2210
- static sin(t) {
2211
- return 1 - Math.cos(t * Math.PI / 2);
2212
- }
2213
- static circle(t) {
2214
- const u = clampUnit(t);
2215
- return 1 - Math.sqrt(1 - u * u);
2216
- }
2217
- static exp(t) {
2218
- return 2 ** (10 * (t - 1));
2219
- }
2220
- static elastic(bounciness = 1) {
2221
- const p = bounciness * Math.PI;
2222
- return (t) => 1 - Math.cos(t * Math.PI / 2) ** 3 * Math.cos(t * p);
2223
- }
2224
- static back(s = 1.70158) {
2225
- return (t) => t * t * ((s + 1) * t - s);
2226
- }
2227
- static bounce(t) {
2228
- const u = clampUnit(t);
2229
- if (u < 1 / 2.75) {
2230
- return 7.5625 * u * u;
2231
- }
2232
- if (u < 2 / 2.75) {
2233
- const t2_ = u - 1.5 / 2.75;
2234
- return 7.5625 * t2_ * t2_ + 0.75;
2235
- }
2236
- if (u < 2.5 / 2.75) {
2237
- const t2_ = u - 2.25 / 2.75;
2238
- return 7.5625 * t2_ * t2_ + 0.9375;
2239
- }
2240
- const t2 = u - 2.625 / 2.75;
2241
- return 7.5625 * t2 * t2 + 0.984375;
2242
- }
2243
- static bezier(x1, y1, x2, y2) {
2244
- return bezier(x1, y1, x2, y2);
2245
- }
2246
- static in(easing) {
2247
- return easing;
2248
- }
2249
- static out(easing) {
2250
- return (t) => 1 - easing(1 - t);
2251
- }
2252
- static inOut(easing) {
2253
- return (t) => {
2254
- if (t < 0.5) {
2255
- return easing(t * 2) / 2;
2256
- }
2257
- return 1 - easing((1 - t) * 2) / 2;
2258
- };
2259
- }
2260
- }
2261
-
2262
2199
  // src/normalize-number.ts
2263
2200
  var normalizeNumber = (value) => {
2264
2201
  return Math.round(value * 1e6) / 1e6;
@@ -2765,123 +2702,485 @@ function interpolate(input, inputRange, outputRange, options) {
2765
2702
  return interpolateNumber({ input, inputRange, outputRange, options });
2766
2703
  }
2767
2704
 
2768
- // src/interpolate-colors.ts
2769
- var NUMBER = "[-+]?\\d*\\.?\\d+";
2770
- var PERCENTAGE = NUMBER + "%";
2771
- function call(...args) {
2772
- return "\\(\\s*(" + args.join(")\\s*,\\s*(") + ")\\s*\\)";
2773
- }
2774
- var MODERN_VALUE = "(?:none|[-+]?\\d*\\.?\\d+(?:%|deg|rad|grad|turn)?)";
2775
- function modernColorCall(name) {
2776
- return new RegExp(name + "\\(\\s*(" + MODERN_VALUE + ")\\s+(" + MODERN_VALUE + ")\\s+(" + MODERN_VALUE + ")(?:\\s*\\/\\s*(" + MODERN_VALUE + "))?\\s*\\)");
2777
- }
2778
- function getMatchers() {
2779
- const cachedMatchers = {
2780
- rgb: undefined,
2781
- rgba: undefined,
2782
- hsl: undefined,
2783
- hsla: undefined,
2784
- hex3: undefined,
2785
- hex4: undefined,
2786
- hex5: undefined,
2787
- hex6: undefined,
2788
- hex8: undefined,
2789
- oklch: undefined,
2790
- oklab: undefined,
2791
- lab: undefined,
2792
- lch: undefined,
2793
- hwb: undefined
2794
- };
2795
- if (cachedMatchers.rgb === undefined) {
2796
- cachedMatchers.rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
2797
- cachedMatchers.rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
2798
- cachedMatchers.hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
2799
- cachedMatchers.hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
2800
- cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
2801
- cachedMatchers.hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
2802
- cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
2803
- cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
2804
- cachedMatchers.oklch = modernColorCall("oklch");
2805
- cachedMatchers.oklab = modernColorCall("oklab");
2806
- cachedMatchers.lab = modernColorCall("lab");
2807
- cachedMatchers.lch = modernColorCall("lch");
2808
- cachedMatchers.hwb = modernColorCall("hwb");
2705
+ // src/validate-frame.ts
2706
+ var validateFrame = ({
2707
+ allowFloats,
2708
+ durationInFrames,
2709
+ frame
2710
+ }) => {
2711
+ if (typeof frame === "undefined") {
2712
+ throw new TypeError(`Argument missing for parameter "frame"`);
2809
2713
  }
2810
- return cachedMatchers;
2811
- }
2812
- function hue2rgb(p, q, t) {
2813
- if (t < 0) {
2814
- t += 1;
2714
+ if (typeof frame !== "number") {
2715
+ throw new TypeError(`Argument passed for "frame" is not a number: ${frame}`);
2815
2716
  }
2816
- if (t > 1) {
2817
- t -= 1;
2717
+ if (!Number.isFinite(frame)) {
2718
+ throw new RangeError(`Frame ${frame} is not finite`);
2818
2719
  }
2819
- if (t < 1 / 6) {
2820
- return p + (q - p) * 6 * t;
2720
+ if (frame % 1 !== 0 && !allowFloats) {
2721
+ throw new RangeError(`Argument for frame must be an integer, but got ${frame}`);
2821
2722
  }
2822
- if (t < 1 / 2) {
2823
- return q;
2723
+ if (frame < 0 && frame < -durationInFrames) {
2724
+ throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the lowest frame that can be rendered is ${-durationInFrames}`);
2824
2725
  }
2825
- if (t < 2 / 3) {
2826
- return p + (q - p) * (2 / 3 - t) * 6;
2726
+ if (frame > durationInFrames - 1) {
2727
+ throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the highest frame that can be rendered is ${durationInFrames - 1}`);
2827
2728
  }
2828
- return p;
2829
- }
2830
- function hslToRgb(h, s, l) {
2831
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
2832
- const p = 2 * l - q;
2833
- const r = hue2rgb(p, q, h + 1 / 3);
2834
- const g = hue2rgb(p, q, h);
2835
- const b2 = hue2rgb(p, q, h - 1 / 3);
2836
- return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b2 * 255) << 8;
2837
- }
2838
- function parse255(str) {
2839
- const int = Number.parseInt(str, 10);
2840
- if (int < 0) {
2841
- return 0;
2729
+ };
2730
+
2731
+ // src/validation/validation-spring-duration.ts
2732
+ var validateSpringDuration = (dur) => {
2733
+ if (typeof dur === "undefined") {
2734
+ return;
2842
2735
  }
2843
- if (int > 255) {
2844
- return 255;
2736
+ if (typeof dur !== "number") {
2737
+ throw new TypeError(`A "duration" of a spring must be a "number" but is "${typeof dur}"`);
2845
2738
  }
2846
- return int;
2847
- }
2848
- function parse360(str) {
2849
- const int = Number.parseFloat(str);
2850
- return (int % 360 + 360) % 360 / 360;
2851
- }
2852
- function parse1(str) {
2853
- const num = Number.parseFloat(str);
2854
- if (num < 0) {
2855
- return 0;
2739
+ if (Number.isNaN(dur)) {
2740
+ throw new TypeError('A "duration" of a spring is NaN, which it must not be');
2856
2741
  }
2857
- if (num > 1) {
2858
- return 255;
2742
+ if (!Number.isFinite(dur)) {
2743
+ throw new TypeError('A "duration" of a spring must be finite, but is ' + dur);
2859
2744
  }
2860
- return Math.round(num * 255);
2861
- }
2862
- function parsePercentage(str) {
2863
- const int = Number.parseFloat(str);
2864
- if (int < 0) {
2865
- return 0;
2745
+ if (dur <= 0) {
2746
+ throw new TypeError('A "duration" of a spring must be positive, but is ' + dur);
2866
2747
  }
2867
- if (int > 100) {
2868
- return 1;
2748
+ };
2749
+
2750
+ // src/spring/spring-utils.ts
2751
+ var defaultSpringConfig = {
2752
+ damping: 10,
2753
+ mass: 1,
2754
+ stiffness: 100,
2755
+ overshootClamping: false
2756
+ };
2757
+ var advanceCache = {};
2758
+ function advance({
2759
+ animation,
2760
+ now,
2761
+ config
2762
+ }) {
2763
+ const { toValue, lastTimestamp, current, velocity } = animation;
2764
+ const deltaTime = Math.min(now - lastTimestamp, 64);
2765
+ if (config.damping <= 0) {
2766
+ throw new Error("Spring damping must be greater than 0, otherwise the spring() animation will never end, causing an infinite loop.");
2869
2767
  }
2870
- return int / 100;
2871
- }
2872
- function parseModernComponent(str, percentScale) {
2873
- if (str === "none")
2874
- return 0;
2875
- if (str.endsWith("%")) {
2876
- return Number.parseFloat(str) / 100 * percentScale;
2768
+ const c2 = config.damping;
2769
+ const m = config.mass;
2770
+ const k = config.stiffness;
2771
+ const cacheKey = [
2772
+ toValue,
2773
+ lastTimestamp,
2774
+ current,
2775
+ velocity,
2776
+ c2,
2777
+ m,
2778
+ k,
2779
+ now
2780
+ ].join("-");
2781
+ if (advanceCache[cacheKey]) {
2782
+ return advanceCache[cacheKey];
2877
2783
  }
2878
- return Number.parseFloat(str);
2879
- }
2880
- function parseHueAngle(str) {
2881
- if (str === "none")
2882
- return 0;
2883
- if (str.endsWith("rad")) {
2884
- return Number.parseFloat(str) * 180 / Math.PI;
2784
+ const v0 = -velocity;
2785
+ const x0 = toValue - current;
2786
+ const zeta = c2 / (2 * Math.sqrt(k * m));
2787
+ const omega0 = Math.sqrt(k / m);
2788
+ const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);
2789
+ const t = deltaTime / 1000;
2790
+ const sin1 = Math.sin(omega1 * t);
2791
+ const cos1 = Math.cos(omega1 * t);
2792
+ const underDampedEnvelope = Math.exp(-zeta * omega0 * t);
2793
+ const underDampedFrag1 = underDampedEnvelope * (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
2794
+ const underDampedPosition = toValue - underDampedFrag1;
2795
+ const underDampedVelocity = zeta * omega0 * underDampedFrag1 - underDampedEnvelope * (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
2796
+ const criticallyDampedEnvelope = Math.exp(-omega0 * t);
2797
+ const criticallyDampedPosition = toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
2798
+ const criticallyDampedVelocity = criticallyDampedEnvelope * (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);
2799
+ const animationNode = {
2800
+ toValue,
2801
+ prevPosition: current,
2802
+ lastTimestamp: now,
2803
+ current: zeta < 1 ? underDampedPosition : criticallyDampedPosition,
2804
+ velocity: zeta < 1 ? underDampedVelocity : criticallyDampedVelocity
2805
+ };
2806
+ advanceCache[cacheKey] = animationNode;
2807
+ return animationNode;
2808
+ }
2809
+ var calculationCache = {};
2810
+ function springCalculation({
2811
+ frame,
2812
+ fps,
2813
+ config = {}
2814
+ }) {
2815
+ const from = 0;
2816
+ const to = 1;
2817
+ const cacheKey = [
2818
+ frame,
2819
+ fps,
2820
+ config.damping,
2821
+ config.mass,
2822
+ config.overshootClamping,
2823
+ config.stiffness
2824
+ ].join("-");
2825
+ if (calculationCache[cacheKey]) {
2826
+ return calculationCache[cacheKey];
2827
+ }
2828
+ let animation = {
2829
+ lastTimestamp: 0,
2830
+ current: from,
2831
+ toValue: to,
2832
+ velocity: 0,
2833
+ prevPosition: 0
2834
+ };
2835
+ const frameClamped = Math.max(0, frame);
2836
+ const unevenRest = frameClamped % 1;
2837
+ for (let f = 0;f <= Math.floor(frameClamped); f++) {
2838
+ if (f === Math.floor(frameClamped)) {
2839
+ f += unevenRest;
2840
+ }
2841
+ const time = f / fps * 1000;
2842
+ animation = advance({
2843
+ animation,
2844
+ now: time,
2845
+ config: {
2846
+ ...defaultSpringConfig,
2847
+ ...config
2848
+ }
2849
+ });
2850
+ }
2851
+ calculationCache[cacheKey] = animation;
2852
+ return animation;
2853
+ }
2854
+
2855
+ // src/spring/measure-spring.ts
2856
+ var cache = new Map;
2857
+ function measureSpring({
2858
+ fps,
2859
+ config = {},
2860
+ threshold = 0.005
2861
+ }) {
2862
+ if (typeof threshold !== "number") {
2863
+ throw new TypeError(`threshold must be a number, got ${threshold} of type ${typeof threshold}`);
2864
+ }
2865
+ if (threshold === 0) {
2866
+ return Infinity;
2867
+ }
2868
+ if (threshold === 1) {
2869
+ return 0;
2870
+ }
2871
+ if (isNaN(threshold)) {
2872
+ throw new TypeError("Threshold is NaN");
2873
+ }
2874
+ if (!Number.isFinite(threshold)) {
2875
+ throw new TypeError("Threshold is not finite");
2876
+ }
2877
+ if (threshold < 0) {
2878
+ throw new TypeError("Threshold is below 0");
2879
+ }
2880
+ const cacheKey = [
2881
+ fps,
2882
+ config.damping,
2883
+ config.mass,
2884
+ config.overshootClamping,
2885
+ config.stiffness,
2886
+ threshold
2887
+ ].join("-");
2888
+ if (cache.has(cacheKey)) {
2889
+ return cache.get(cacheKey);
2890
+ }
2891
+ validateFps(fps, "to the measureSpring() function", false);
2892
+ let frame = 0;
2893
+ let finishedFrame = 0;
2894
+ const calc = () => {
2895
+ return springCalculation({
2896
+ fps,
2897
+ frame,
2898
+ config
2899
+ });
2900
+ };
2901
+ let animation = calc();
2902
+ const calcDifference = () => {
2903
+ return Math.abs(animation.current - animation.toValue);
2904
+ };
2905
+ let difference = calcDifference();
2906
+ while (difference >= threshold) {
2907
+ frame++;
2908
+ animation = calc();
2909
+ difference = calcDifference();
2910
+ }
2911
+ finishedFrame = frame;
2912
+ for (let i = 0;i < 20; i++) {
2913
+ frame++;
2914
+ animation = calc();
2915
+ difference = calcDifference();
2916
+ if (difference >= threshold) {
2917
+ i = 0;
2918
+ finishedFrame = frame + 1;
2919
+ }
2920
+ }
2921
+ cache.set(cacheKey, finishedFrame);
2922
+ return finishedFrame;
2923
+ }
2924
+
2925
+ // src/spring/index.ts
2926
+ function spring({
2927
+ frame: passedFrame,
2928
+ fps,
2929
+ config = {},
2930
+ from = 0,
2931
+ to = 1,
2932
+ durationInFrames: passedDurationInFrames,
2933
+ durationRestThreshold,
2934
+ delay = 0,
2935
+ reverse = false
2936
+ }) {
2937
+ validateSpringDuration(passedDurationInFrames);
2938
+ validateFrame({
2939
+ frame: passedFrame,
2940
+ durationInFrames: Infinity,
2941
+ allowFloats: true
2942
+ });
2943
+ validateFps(fps, "to spring()", false);
2944
+ const needsToCalculateNaturalDuration = reverse || typeof passedDurationInFrames !== "undefined";
2945
+ const naturalDuration = needsToCalculateNaturalDuration ? measureSpring({
2946
+ fps,
2947
+ config,
2948
+ threshold: durationRestThreshold
2949
+ }) : undefined;
2950
+ const naturalDurationGetter = needsToCalculateNaturalDuration ? {
2951
+ get: () => naturalDuration
2952
+ } : {
2953
+ get: () => {
2954
+ throw new Error("did not calculate natural duration, this is an error with Remotion. Please report");
2955
+ }
2956
+ };
2957
+ const reverseProcessed = reverse ? (passedDurationInFrames ?? naturalDurationGetter.get()) - passedFrame : passedFrame;
2958
+ const delayProcessed = reverseProcessed + (reverse ? delay : -delay);
2959
+ const durationProcessed = passedDurationInFrames === undefined ? delayProcessed : delayProcessed / (passedDurationInFrames / naturalDurationGetter.get());
2960
+ if (passedDurationInFrames && delayProcessed > passedDurationInFrames) {
2961
+ return to;
2962
+ }
2963
+ const spr = springCalculation({
2964
+ fps,
2965
+ frame: durationProcessed,
2966
+ config
2967
+ });
2968
+ const inner = config.overshootClamping ? to >= from ? Math.min(spr.current, to) : Math.max(spr.current, to) : spr.current;
2969
+ const interpolated = from === 0 && to === 1 ? inner : interpolate(inner, [0, 1], [from, to]);
2970
+ return interpolated;
2971
+ }
2972
+
2973
+ // src/easing.ts
2974
+ var clampUnit = (t) => Math.min(1, Math.max(0, t));
2975
+ var springEasingDurationInFrames = 30;
2976
+
2977
+ class Easing {
2978
+ static step0(n) {
2979
+ return n > 0 ? 1 : 0;
2980
+ }
2981
+ static step1(n) {
2982
+ return n >= 1 ? 1 : 0;
2983
+ }
2984
+ static linear(t) {
2985
+ return t;
2986
+ }
2987
+ static ease(t) {
2988
+ return Easing.bezier(0.42, 0, 1, 1)(t);
2989
+ }
2990
+ static quad(t) {
2991
+ return t * t;
2992
+ }
2993
+ static cubic(t) {
2994
+ return t * t * t;
2995
+ }
2996
+ static poly(n) {
2997
+ return (t) => t ** n;
2998
+ }
2999
+ static sin(t) {
3000
+ return 1 - Math.cos(t * Math.PI / 2);
3001
+ }
3002
+ static circle(t) {
3003
+ const u = clampUnit(t);
3004
+ return 1 - Math.sqrt(1 - u * u);
3005
+ }
3006
+ static exp(t) {
3007
+ return 2 ** (10 * (t - 1));
3008
+ }
3009
+ static elastic(bounciness = 1) {
3010
+ const p = bounciness * Math.PI;
3011
+ return (t) => 1 - Math.cos(t * Math.PI / 2) ** 3 * Math.cos(t * p);
3012
+ }
3013
+ static back(s = 1.70158) {
3014
+ return (t) => t * t * ((s + 1) * t - s);
3015
+ }
3016
+ static spring(config = {}) {
3017
+ return (t) => {
3018
+ if (t <= 0) {
3019
+ return 0;
3020
+ }
3021
+ if (t >= 1) {
3022
+ return 1;
3023
+ }
3024
+ return spring({
3025
+ fps: springEasingDurationInFrames,
3026
+ frame: t * springEasingDurationInFrames,
3027
+ config,
3028
+ durationInFrames: springEasingDurationInFrames
3029
+ });
3030
+ };
3031
+ }
3032
+ static bounce(t) {
3033
+ const u = clampUnit(t);
3034
+ if (u < 1 / 2.75) {
3035
+ return 7.5625 * u * u;
3036
+ }
3037
+ if (u < 2 / 2.75) {
3038
+ const t2_ = u - 1.5 / 2.75;
3039
+ return 7.5625 * t2_ * t2_ + 0.75;
3040
+ }
3041
+ if (u < 2.5 / 2.75) {
3042
+ const t2_ = u - 2.25 / 2.75;
3043
+ return 7.5625 * t2_ * t2_ + 0.9375;
3044
+ }
3045
+ const t2 = u - 2.625 / 2.75;
3046
+ return 7.5625 * t2 * t2 + 0.984375;
3047
+ }
3048
+ static bezier(x1, y1, x2, y2) {
3049
+ return bezier(x1, y1, x2, y2);
3050
+ }
3051
+ static in(easing) {
3052
+ return easing;
3053
+ }
3054
+ static out(easing) {
3055
+ return (t) => 1 - easing(1 - t);
3056
+ }
3057
+ static inOut(easing) {
3058
+ return (t) => {
3059
+ if (t < 0.5) {
3060
+ return easing(t * 2) / 2;
3061
+ }
3062
+ return 1 - easing((1 - t) * 2) / 2;
3063
+ };
3064
+ }
3065
+ }
3066
+
3067
+ // src/interpolate-colors.ts
3068
+ var NUMBER = "[-+]?\\d*\\.?\\d+";
3069
+ var PERCENTAGE = NUMBER + "%";
3070
+ function call(...args) {
3071
+ return "\\(\\s*(" + args.join(")\\s*,\\s*(") + ")\\s*\\)";
3072
+ }
3073
+ var MODERN_VALUE = "(?:none|[-+]?\\d*\\.?\\d+(?:%|deg|rad|grad|turn)?)";
3074
+ function modernColorCall(name) {
3075
+ return new RegExp(name + "\\(\\s*(" + MODERN_VALUE + ")\\s+(" + MODERN_VALUE + ")\\s+(" + MODERN_VALUE + ")(?:\\s*\\/\\s*(" + MODERN_VALUE + "))?\\s*\\)");
3076
+ }
3077
+ function getMatchers() {
3078
+ const cachedMatchers = {
3079
+ rgb: undefined,
3080
+ rgba: undefined,
3081
+ hsl: undefined,
3082
+ hsla: undefined,
3083
+ hex3: undefined,
3084
+ hex4: undefined,
3085
+ hex5: undefined,
3086
+ hex6: undefined,
3087
+ hex8: undefined,
3088
+ oklch: undefined,
3089
+ oklab: undefined,
3090
+ lab: undefined,
3091
+ lch: undefined,
3092
+ hwb: undefined
3093
+ };
3094
+ if (cachedMatchers.rgb === undefined) {
3095
+ cachedMatchers.rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
3096
+ cachedMatchers.rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
3097
+ cachedMatchers.hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
3098
+ cachedMatchers.hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
3099
+ cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3100
+ cachedMatchers.hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3101
+ cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
3102
+ cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
3103
+ cachedMatchers.oklch = modernColorCall("oklch");
3104
+ cachedMatchers.oklab = modernColorCall("oklab");
3105
+ cachedMatchers.lab = modernColorCall("lab");
3106
+ cachedMatchers.lch = modernColorCall("lch");
3107
+ cachedMatchers.hwb = modernColorCall("hwb");
3108
+ }
3109
+ return cachedMatchers;
3110
+ }
3111
+ function hue2rgb(p, q, t) {
3112
+ if (t < 0) {
3113
+ t += 1;
3114
+ }
3115
+ if (t > 1) {
3116
+ t -= 1;
3117
+ }
3118
+ if (t < 1 / 6) {
3119
+ return p + (q - p) * 6 * t;
3120
+ }
3121
+ if (t < 1 / 2) {
3122
+ return q;
3123
+ }
3124
+ if (t < 2 / 3) {
3125
+ return p + (q - p) * (2 / 3 - t) * 6;
3126
+ }
3127
+ return p;
3128
+ }
3129
+ function hslToRgb(h, s, l) {
3130
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
3131
+ const p = 2 * l - q;
3132
+ const r = hue2rgb(p, q, h + 1 / 3);
3133
+ const g = hue2rgb(p, q, h);
3134
+ const b2 = hue2rgb(p, q, h - 1 / 3);
3135
+ return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b2 * 255) << 8;
3136
+ }
3137
+ function parse255(str) {
3138
+ const int = Number.parseInt(str, 10);
3139
+ if (int < 0) {
3140
+ return 0;
3141
+ }
3142
+ if (int > 255) {
3143
+ return 255;
3144
+ }
3145
+ return int;
3146
+ }
3147
+ function parse360(str) {
3148
+ const int = Number.parseFloat(str);
3149
+ return (int % 360 + 360) % 360 / 360;
3150
+ }
3151
+ function parse1(str) {
3152
+ const num = Number.parseFloat(str);
3153
+ if (num < 0) {
3154
+ return 0;
3155
+ }
3156
+ if (num > 1) {
3157
+ return 255;
3158
+ }
3159
+ return Math.round(num * 255);
3160
+ }
3161
+ function parsePercentage(str) {
3162
+ const int = Number.parseFloat(str);
3163
+ if (int < 0) {
3164
+ return 0;
3165
+ }
3166
+ if (int > 100) {
3167
+ return 1;
3168
+ }
3169
+ return int / 100;
3170
+ }
3171
+ function parseModernComponent(str, percentScale) {
3172
+ if (str === "none")
3173
+ return 0;
3174
+ if (str.endsWith("%")) {
3175
+ return Number.parseFloat(str) / 100 * percentScale;
3176
+ }
3177
+ return Number.parseFloat(str);
3178
+ }
3179
+ function parseHueAngle(str) {
3180
+ if (str === "none")
3181
+ return 0;
3182
+ if (str.endsWith("rad")) {
3183
+ return Number.parseFloat(str) * 180 / Math.PI;
2885
3184
  }
2886
3185
  if (str.endsWith("grad"))
2887
3186
  return Number.parseFloat(str) * 0.9;
@@ -3779,7 +4078,8 @@ var wrapInSchema = ({
3779
4078
  schema,
3780
4079
  supportsEffects
3781
4080
  }) => {
3782
- const flatSchema = getFlatSchemaWithAllKeys(schema);
4081
+ const schemaWithSequenceName = extendSchemaWithSequenceName(schema);
4082
+ const flatSchema = getFlatSchemaWithAllKeys(schemaWithSequenceName);
3783
4083
  const flatKeys = Object.keys(flatSchema);
3784
4084
  const Wrapped = forwardRef2((props, ref) => {
3785
4085
  const env = useRemotionEnvironment();
@@ -3818,7 +4118,7 @@ var wrapInSchema = ({
3818
4118
  const currentRuntimeValueDotNotation = useMemo13(() => readValuesFromProps(props, flatKeys), runtimeValues);
3819
4119
  const controls = useMemo13(() => {
3820
4120
  return {
3821
- schema,
4121
+ schema: schemaWithSequenceName,
3822
4122
  currentRuntimeValueDotNotation,
3823
4123
  overrideId,
3824
4124
  supportsEffects
@@ -3826,7 +4126,7 @@ var wrapInSchema = ({
3826
4126
  }, [currentRuntimeValueDotNotation, overrideId]);
3827
4127
  const { merged: valuesDotNotation, propsToDelete } = useMemo13(() => {
3828
4128
  return computeEffectiveSchemaValuesDotNotation({
3829
- schema,
4129
+ schema: schemaWithSequenceName,
3830
4130
  currentValue: currentRuntimeValueDotNotation,
3831
4131
  overrideValues: nodePath === null ? {} : getDragOverrides(nodePath),
3832
4132
  propStatus: nodePath === null ? undefined : getPropStatusesCtx(propStatuses, nodePath),
@@ -3839,7 +4139,7 @@ var wrapInSchema = ({
3839
4139
  propStatuses,
3840
4140
  frame
3841
4141
  ]);
3842
- const activeKeys = selectActiveKeys(schema, valuesDotNotation);
4142
+ const activeKeys = selectActiveKeys(schemaWithSequenceName, valuesDotNotation);
3843
4143
  const mergedProps = mergeValues({
3844
4144
  props,
3845
4145
  valuesDotNotation,
@@ -3884,6 +4184,7 @@ var RegularSequenceRefForwardingFunction = ({
3884
4184
  const parentSequence = useContext17(SequenceContext);
3885
4185
  const { rootId } = useTimelineContext();
3886
4186
  const cumulatedFrom = parentSequence ? parentSequence.cumulatedFrom + parentSequence.relativeFrom : 0;
4187
+ const absoluteFrom = (parentSequence?.absoluteFrom ?? 0) + from;
3887
4188
  const nonce = useNonce();
3888
4189
  if (layout !== "absolute-fill" && layout !== "none") {
3889
4190
  throw new TypeError(`The layout prop of <Sequence /> expects either "absolute-fill" or "none", but you passed: ${layout}`);
@@ -3921,6 +4222,7 @@ var RegularSequenceRefForwardingFunction = ({
3921
4222
  const cumulatedNegativeFrom = currentSequenceStart - firstFrame;
3922
4223
  const contextValue = useMemo14(() => {
3923
4224
  return {
4225
+ absoluteFrom,
3924
4226
  cumulatedFrom,
3925
4227
  relativeFrom: from,
3926
4228
  cumulatedNegativeFrom,
@@ -3936,6 +4238,7 @@ var RegularSequenceRefForwardingFunction = ({
3936
4238
  };
3937
4239
  }, [
3938
4240
  cumulatedFrom,
4241
+ absoluteFrom,
3939
4242
  from,
3940
4243
  actualDurationInFrames,
3941
4244
  parentSequence,
@@ -3951,7 +4254,7 @@ var RegularSequenceRefForwardingFunction = ({
3951
4254
  const timelineClipName = useMemo14(() => {
3952
4255
  return name ?? "";
3953
4256
  }, [name]);
3954
- const resolvedDocumentationLink = documentationLink ?? (name === undefined ? "https://www.remotion.dev/docs/sequence" : null);
4257
+ const resolvedDocumentationLink = documentationLink ?? "https://www.remotion.dev/docs/sequence";
3955
4258
  const env = useRemotionEnvironment();
3956
4259
  const isInsideSeries = useContext17(IsInsideSeriesContext);
3957
4260
  const inheritedStack = other?.stack ?? null;
@@ -4609,10 +4912,10 @@ var decodeImage = async ({
4609
4912
  if (!selectedTrack) {
4610
4913
  throw new Error("No selected track");
4611
4914
  }
4612
- const cache = [];
4915
+ const cache2 = [];
4613
4916
  let durationFound = null;
4614
4917
  const getFrameByIndex = async (frameIndex) => {
4615
- const foundInCache = cache.find((c2) => c2.frameIndex === frameIndex);
4918
+ const foundInCache = cache2.find((c2) => c2.frameIndex === frameIndex);
4616
4919
  if (foundInCache && foundInCache.frame) {
4617
4920
  return foundInCache;
4618
4921
  }
@@ -4623,7 +4926,7 @@ var decodeImage = async ({
4623
4926
  if (foundInCache) {
4624
4927
  foundInCache.frame = frame.image;
4625
4928
  } else {
4626
- cache.push({
4929
+ cache2.push({
4627
4930
  frame: frame.image,
4628
4931
  frameIndex,
4629
4932
  timeInSeconds: frame.image.timestamp / 1e6
@@ -4636,7 +4939,7 @@ var decodeImage = async ({
4636
4939
  };
4637
4940
  };
4638
4941
  const clearCache = (closeToTimeInSec) => {
4639
- const itemsInCache = cache.filter((c2) => c2.frame);
4942
+ const itemsInCache = cache2.filter((c2) => c2.frame);
4640
4943
  const sortByClosestToCurrentTime = itemsInCache.sort((a2, b2) => {
4641
4944
  const aDiff = Math.abs(a2.timeInSeconds - closeToTimeInSec);
4642
4945
  const bDiff = Math.abs(b2.timeInSeconds - closeToTimeInSec);
@@ -4659,7 +4962,7 @@ var decodeImage = async ({
4659
4962
  loopBehavior,
4660
4963
  timeInSec
4661
4964
  });
4662
- const framesBefore = cache.filter((c2) => c2.timeInSeconds <= actualTimeInSec);
4965
+ const framesBefore = cache2.filter((c2) => c2.timeInSeconds <= actualTimeInSec);
4663
4966
  const biggestIndex = framesBefore.map((c2) => c2.frameIndex).reduce((a2, b2) => Math.max(a2, b2), 0);
4664
4967
  let i = biggestIndex;
4665
4968
  while (true) {
@@ -4702,7 +5005,7 @@ var decodeImage = async ({
4702
5005
  timeInSec
4703
5006
  });
4704
5007
  await ensureFrameBeforeAndAfter({ timeInSec: actualTimeInSec, loopBehavior });
4705
- const itemsInCache = cache.filter((c2) => c2.frame);
5008
+ const itemsInCache = cache2.filter((c2) => c2.frame);
4706
5009
  const closest = itemsInCache.reduce((a2, b2) => {
4707
5010
  const aDiff = Math.abs(a2.timeInSeconds - actualTimeInSec);
4708
5011
  const bDiff = Math.abs(b2.timeInSeconds - actualTimeInSec);
@@ -5200,7 +5503,7 @@ var Loop = ({
5200
5503
  durationInFrames,
5201
5504
  from,
5202
5505
  name: name ?? "<Loop>",
5203
- _remotionInternalDocumentationLink: name === undefined ? "https://www.remotion.dev/docs/loop" : undefined,
5506
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/loop",
5204
5507
  _remotionInternalLoopDisplay: loopDisplay,
5205
5508
  layout: props.layout,
5206
5509
  style,
@@ -7729,7 +8032,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
7729
8032
  premountDisplay: sequenceContext?.premountDisplay ?? null,
7730
8033
  postmountDisplay: sequenceContext?.postmountDisplay ?? null,
7731
8034
  loopDisplay: undefined,
7732
- documentationLink: name === undefined ? "https://www.remotion.dev/docs/html5-audio" : null,
8035
+ documentationLink: "https://www.remotion.dev/docs/html5-audio",
7733
8036
  refForOutline: null
7734
8037
  });
7735
8038
  useMediaPlayback({
@@ -8249,7 +8552,7 @@ var SolidOuter = forwardRef8(({
8249
8552
  durationInFrames,
8250
8553
  name: name ?? "<Solid>",
8251
8554
  _remotionInternalRefForOutline: actualRef,
8252
- _remotionInternalDocumentationLink: name === undefined ? "https://www.remotion.dev/docs/solid" : undefined,
8555
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/solid",
8253
8556
  ...props2,
8254
8557
  children: /* @__PURE__ */ jsx24(SolidInner, {
8255
8558
  reference: actualRef,
@@ -8572,7 +8875,7 @@ var HtmlInCanvasInner = forwardRef9(({
8572
8875
  return /* @__PURE__ */ jsx25(Sequence, {
8573
8876
  durationInFrames: resolvedDuration,
8574
8877
  name: name ?? "<HtmlInCanvas>",
8575
- _remotionInternalDocumentationLink: name === undefined ? "https://www.remotion.dev/docs/remotion/html-in-canvas" : undefined,
8878
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/remotion/html-in-canvas",
8576
8879
  _experimentalControls: controls,
8577
8880
  _remotionInternalEffects: memoizedEffectDefinitions,
8578
8881
  _remotionInternalRefForOutline: actualRef,
@@ -9189,7 +9492,7 @@ var NativeImgInner = ({
9189
9492
  from: from ?? 0,
9190
9493
  durationInFrames: durationInFrames ?? Infinity,
9191
9494
  _remotionInternalStack: stack,
9192
- _remotionInternalDocumentationLink: name === undefined ? "https://www.remotion.dev/docs/img" : undefined,
9495
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/img",
9193
9496
  _remotionInternalIsMedia: { type: "image", src },
9194
9497
  name: name ?? "<Img>",
9195
9498
  _experimentalControls: controls,
@@ -9331,7 +9634,7 @@ var ImgInner = ({
9331
9634
  name: name ?? "<Img>",
9332
9635
  showInTimeline,
9333
9636
  stack,
9334
- _remotionInternalDocumentationLink: name === undefined ? "https://www.remotion.dev/docs/img" : undefined,
9637
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/img",
9335
9638
  _experimentalControls: controls,
9336
9639
  _remotionInternalRefForOutline: refForOutline,
9337
9640
  ...canvasProps
@@ -9385,6 +9688,7 @@ var makeInteractiveElement = (tag, displayName) => {
9385
9688
  showInTimeline: showInTimeline ?? true,
9386
9689
  _experimentalControls,
9387
9690
  _remotionInternalStack: stack,
9691
+ _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/interactive",
9388
9692
  _remotionInternalRefForOutline: refForOutline,
9389
9693
  children: React29.createElement(tag, {
9390
9694
  ...props2,
@@ -10437,7 +10741,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
10437
10741
  premountDisplay: parentSequence?.premountDisplay ?? null,
10438
10742
  postmountDisplay: parentSequence?.postmountDisplay ?? null,
10439
10743
  loopDisplay: undefined,
10440
- documentationLink: name === undefined ? onlyWarnForMediaSeekingError ? "https://www.remotion.dev/docs/offthreadvideo" : "https://www.remotion.dev/docs/html5-video" : null,
10744
+ documentationLink: onlyWarnForMediaSeekingError ? "https://www.remotion.dev/docs/offthreadvideo" : "https://www.remotion.dev/docs/html5-video",
10441
10745
  refForOutline: videoRef
10442
10746
  });
10443
10747
  useMediaPlayback({
@@ -10568,6 +10872,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
10568
10872
  isClientSideRendering: false
10569
10873
  });
10570
10874
  return /* @__PURE__ */ jsx34("video", {
10875
+ ...nativeProps,
10571
10876
  ref: videoRef,
10572
10877
  muted: muted || mediaMuted || userPreferredVolume <= 0,
10573
10878
  playsInline: true,
@@ -10576,7 +10881,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
10576
10881
  style: actualStyle,
10577
10882
  disableRemotePlayback: true,
10578
10883
  crossOrigin: crossOriginValue,
10579
- ...nativeProps
10884
+ controls: false
10580
10885
  });
10581
10886
  };
10582
10887
  var VideoForPreview = forwardRef13(VideoForDevelopmentRefForwardingFunction);
@@ -11006,46 +11311,21 @@ var Internals = {
11006
11311
  createEffect,
11007
11312
  createWebGLContextError,
11008
11313
  createWebGL2ContextError,
11009
- computeEffectiveSchemaValuesDotNotation,
11010
- interpolateKeyframedStatus,
11011
- makeStaticDragOverride,
11012
- makeKeyframedDragOverride,
11013
- resolveDragOverrideValue,
11014
- getStaticDragOverrideValue,
11015
- OverrideIdsToNodePathsGettersContext,
11016
- OverrideIdsToNodePathsSettersContext,
11017
- findPropsToDelete,
11018
- makeSequencePropsSubscriptionKey,
11019
- getPropStatusesCtx,
11020
- getEffectPropStatusesCtx,
11021
- hiddenField,
11022
- durationInFramesField,
11023
- fromField
11024
- };
11025
- // src/validate-frame.ts
11026
- var validateFrame = ({
11027
- allowFloats,
11028
- durationInFrames,
11029
- frame
11030
- }) => {
11031
- if (typeof frame === "undefined") {
11032
- throw new TypeError(`Argument missing for parameter "frame"`);
11033
- }
11034
- if (typeof frame !== "number") {
11035
- throw new TypeError(`Argument passed for "frame" is not a number: ${frame}`);
11036
- }
11037
- if (!Number.isFinite(frame)) {
11038
- throw new RangeError(`Frame ${frame} is not finite`);
11039
- }
11040
- if (frame % 1 !== 0 && !allowFloats) {
11041
- throw new RangeError(`Argument for frame must be an integer, but got ${frame}`);
11042
- }
11043
- if (frame < 0 && frame < -durationInFrames) {
11044
- throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the lowest frame that can be rendered is ${-durationInFrames}`);
11045
- }
11046
- if (frame > durationInFrames - 1) {
11047
- throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the highest frame that can be rendered is ${durationInFrames - 1}`);
11048
- }
11314
+ computeEffectiveSchemaValuesDotNotation,
11315
+ interpolateKeyframedStatus,
11316
+ makeStaticDragOverride,
11317
+ makeKeyframedDragOverride,
11318
+ resolveDragOverrideValue,
11319
+ getStaticDragOverrideValue,
11320
+ OverrideIdsToNodePathsGettersContext,
11321
+ OverrideIdsToNodePathsSettersContext,
11322
+ findPropsToDelete,
11323
+ makeSequencePropsSubscriptionKey,
11324
+ getPropStatusesCtx,
11325
+ getEffectPropStatusesCtx,
11326
+ hiddenField,
11327
+ durationInFramesField,
11328
+ fromField
11049
11329
  };
11050
11330
  // src/series/index.tsx
11051
11331
  import {
@@ -11148,247 +11428,6 @@ var Series = Object.assign(wrapInSchema({
11148
11428
  Sequence: SeriesSequence
11149
11429
  });
11150
11430
  addSequenceStackTraces(Series);
11151
- // src/validation/validation-spring-duration.ts
11152
- var validateSpringDuration = (dur) => {
11153
- if (typeof dur === "undefined") {
11154
- return;
11155
- }
11156
- if (typeof dur !== "number") {
11157
- throw new TypeError(`A "duration" of a spring must be a "number" but is "${typeof dur}"`);
11158
- }
11159
- if (Number.isNaN(dur)) {
11160
- throw new TypeError('A "duration" of a spring is NaN, which it must not be');
11161
- }
11162
- if (!Number.isFinite(dur)) {
11163
- throw new TypeError('A "duration" of a spring must be finite, but is ' + dur);
11164
- }
11165
- if (dur <= 0) {
11166
- throw new TypeError('A "duration" of a spring must be positive, but is ' + dur);
11167
- }
11168
- };
11169
-
11170
- // src/spring/spring-utils.ts
11171
- var defaultSpringConfig = {
11172
- damping: 10,
11173
- mass: 1,
11174
- stiffness: 100,
11175
- overshootClamping: false
11176
- };
11177
- var advanceCache = {};
11178
- function advance({
11179
- animation,
11180
- now,
11181
- config
11182
- }) {
11183
- const { toValue, lastTimestamp, current, velocity } = animation;
11184
- const deltaTime = Math.min(now - lastTimestamp, 64);
11185
- if (config.damping <= 0) {
11186
- throw new Error("Spring damping must be greater than 0, otherwise the spring() animation will never end, causing an infinite loop.");
11187
- }
11188
- const c2 = config.damping;
11189
- const m = config.mass;
11190
- const k = config.stiffness;
11191
- const cacheKey = [
11192
- toValue,
11193
- lastTimestamp,
11194
- current,
11195
- velocity,
11196
- c2,
11197
- m,
11198
- k,
11199
- now
11200
- ].join("-");
11201
- if (advanceCache[cacheKey]) {
11202
- return advanceCache[cacheKey];
11203
- }
11204
- const v0 = -velocity;
11205
- const x0 = toValue - current;
11206
- const zeta = c2 / (2 * Math.sqrt(k * m));
11207
- const omega0 = Math.sqrt(k / m);
11208
- const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);
11209
- const t = deltaTime / 1000;
11210
- const sin1 = Math.sin(omega1 * t);
11211
- const cos1 = Math.cos(omega1 * t);
11212
- const underDampedEnvelope = Math.exp(-zeta * omega0 * t);
11213
- const underDampedFrag1 = underDampedEnvelope * (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
11214
- const underDampedPosition = toValue - underDampedFrag1;
11215
- const underDampedVelocity = zeta * omega0 * underDampedFrag1 - underDampedEnvelope * (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
11216
- const criticallyDampedEnvelope = Math.exp(-omega0 * t);
11217
- const criticallyDampedPosition = toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
11218
- const criticallyDampedVelocity = criticallyDampedEnvelope * (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);
11219
- const animationNode = {
11220
- toValue,
11221
- prevPosition: current,
11222
- lastTimestamp: now,
11223
- current: zeta < 1 ? underDampedPosition : criticallyDampedPosition,
11224
- velocity: zeta < 1 ? underDampedVelocity : criticallyDampedVelocity
11225
- };
11226
- advanceCache[cacheKey] = animationNode;
11227
- return animationNode;
11228
- }
11229
- var calculationCache = {};
11230
- function springCalculation({
11231
- frame,
11232
- fps,
11233
- config = {}
11234
- }) {
11235
- const from = 0;
11236
- const to = 1;
11237
- const cacheKey = [
11238
- frame,
11239
- fps,
11240
- config.damping,
11241
- config.mass,
11242
- config.overshootClamping,
11243
- config.stiffness
11244
- ].join("-");
11245
- if (calculationCache[cacheKey]) {
11246
- return calculationCache[cacheKey];
11247
- }
11248
- let animation = {
11249
- lastTimestamp: 0,
11250
- current: from,
11251
- toValue: to,
11252
- velocity: 0,
11253
- prevPosition: 0
11254
- };
11255
- const frameClamped = Math.max(0, frame);
11256
- const unevenRest = frameClamped % 1;
11257
- for (let f = 0;f <= Math.floor(frameClamped); f++) {
11258
- if (f === Math.floor(frameClamped)) {
11259
- f += unevenRest;
11260
- }
11261
- const time = f / fps * 1000;
11262
- animation = advance({
11263
- animation,
11264
- now: time,
11265
- config: {
11266
- ...defaultSpringConfig,
11267
- ...config
11268
- }
11269
- });
11270
- }
11271
- calculationCache[cacheKey] = animation;
11272
- return animation;
11273
- }
11274
-
11275
- // src/spring/measure-spring.ts
11276
- var cache = new Map;
11277
- function measureSpring({
11278
- fps,
11279
- config = {},
11280
- threshold = 0.005
11281
- }) {
11282
- if (typeof threshold !== "number") {
11283
- throw new TypeError(`threshold must be a number, got ${threshold} of type ${typeof threshold}`);
11284
- }
11285
- if (threshold === 0) {
11286
- return Infinity;
11287
- }
11288
- if (threshold === 1) {
11289
- return 0;
11290
- }
11291
- if (isNaN(threshold)) {
11292
- throw new TypeError("Threshold is NaN");
11293
- }
11294
- if (!Number.isFinite(threshold)) {
11295
- throw new TypeError("Threshold is not finite");
11296
- }
11297
- if (threshold < 0) {
11298
- throw new TypeError("Threshold is below 0");
11299
- }
11300
- const cacheKey = [
11301
- fps,
11302
- config.damping,
11303
- config.mass,
11304
- config.overshootClamping,
11305
- config.stiffness,
11306
- threshold
11307
- ].join("-");
11308
- if (cache.has(cacheKey)) {
11309
- return cache.get(cacheKey);
11310
- }
11311
- validateFps(fps, "to the measureSpring() function", false);
11312
- let frame = 0;
11313
- let finishedFrame = 0;
11314
- const calc = () => {
11315
- return springCalculation({
11316
- fps,
11317
- frame,
11318
- config
11319
- });
11320
- };
11321
- let animation = calc();
11322
- const calcDifference = () => {
11323
- return Math.abs(animation.current - animation.toValue);
11324
- };
11325
- let difference = calcDifference();
11326
- while (difference >= threshold) {
11327
- frame++;
11328
- animation = calc();
11329
- difference = calcDifference();
11330
- }
11331
- finishedFrame = frame;
11332
- for (let i = 0;i < 20; i++) {
11333
- frame++;
11334
- animation = calc();
11335
- difference = calcDifference();
11336
- if (difference >= threshold) {
11337
- i = 0;
11338
- finishedFrame = frame + 1;
11339
- }
11340
- }
11341
- cache.set(cacheKey, finishedFrame);
11342
- return finishedFrame;
11343
- }
11344
-
11345
- // src/spring/index.ts
11346
- function spring({
11347
- frame: passedFrame,
11348
- fps,
11349
- config = {},
11350
- from = 0,
11351
- to = 1,
11352
- durationInFrames: passedDurationInFrames,
11353
- durationRestThreshold,
11354
- delay = 0,
11355
- reverse = false
11356
- }) {
11357
- validateSpringDuration(passedDurationInFrames);
11358
- validateFrame({
11359
- frame: passedFrame,
11360
- durationInFrames: Infinity,
11361
- allowFloats: true
11362
- });
11363
- validateFps(fps, "to spring()", false);
11364
- const needsToCalculateNaturalDuration = reverse || typeof passedDurationInFrames !== "undefined";
11365
- const naturalDuration = needsToCalculateNaturalDuration ? measureSpring({
11366
- fps,
11367
- config,
11368
- threshold: durationRestThreshold
11369
- }) : undefined;
11370
- const naturalDurationGetter = needsToCalculateNaturalDuration ? {
11371
- get: () => naturalDuration
11372
- } : {
11373
- get: () => {
11374
- throw new Error("did not calculate natural duration, this is an error with Remotion. Please report");
11375
- }
11376
- };
11377
- const reverseProcessed = reverse ? (passedDurationInFrames ?? naturalDurationGetter.get()) - passedFrame : passedFrame;
11378
- const delayProcessed = reverseProcessed + (reverse ? delay : -delay);
11379
- const durationProcessed = passedDurationInFrames === undefined ? delayProcessed : delayProcessed / (passedDurationInFrames / naturalDurationGetter.get());
11380
- if (passedDurationInFrames && delayProcessed > passedDurationInFrames) {
11381
- return to;
11382
- }
11383
- const spr = springCalculation({
11384
- fps,
11385
- frame: durationProcessed,
11386
- config
11387
- });
11388
- const inner = config.overshootClamping ? to >= from ? Math.min(spr.current, to) : Math.max(spr.current, to) : spr.current;
11389
- const interpolated = from === 0 && to === 1 ? inner : interpolate(inner, [0, 1], [from, to]);
11390
- return interpolated;
11391
- }
11392
11431
  // src/static-file.ts
11393
11432
  var problematicCharacters = {
11394
11433
  "%3A": ":",