remotion 3.3.55 → 3.3.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/cjs/audio/Audio.d.ts +1 -1
  2. package/dist/cjs/index.d.ts +1 -0
  3. package/dist/cjs/internals.d.ts +1 -1
  4. package/dist/cjs/multiple-versions-warning.js +1 -1
  5. package/dist/cjs/use-video.d.ts +1 -1
  6. package/dist/cjs/version.d.ts +1 -1
  7. package/dist/cjs/version.js +1 -1
  8. package/dist/esm/index.mjs +2 -2
  9. package/dist/esm/version.mjs +1 -1
  10. package/dist/tsconfig-esm.tsbuildinfo +1 -0
  11. package/package.json +3 -3
  12. package/tsconfig-esm.json +12 -0
  13. package/dist/esm/AbsoluteFill.js +0 -25
  14. package/dist/esm/CanUseRemotionHooks.js +0 -6
  15. package/dist/esm/Clipper.js +0 -20
  16. package/dist/esm/Composition.js +0 -112
  17. package/dist/esm/CompositionManager.js +0 -137
  18. package/dist/esm/Folder.js +0 -33
  19. package/dist/esm/IFrame.js +0 -25
  20. package/dist/esm/Img.js +0 -53
  21. package/dist/esm/NativeLayers.js +0 -25
  22. package/dist/esm/Null.js +0 -21
  23. package/dist/esm/RemotionRoot.js +0 -69
  24. package/dist/esm/Sequence.js +0 -128
  25. package/dist/esm/SequenceContext.js +0 -2
  26. package/dist/esm/Still.js +0 -9
  27. package/dist/esm/absolute-src.js +0 -3
  28. package/dist/esm/asset-types.js +0 -1
  29. package/dist/esm/audio/Audio.js +0 -53
  30. package/dist/esm/audio/AudioForDevelopment.js +0 -91
  31. package/dist/esm/audio/AudioForRendering.js +0 -108
  32. package/dist/esm/audio/index.js +0 -2
  33. package/dist/esm/audio/props.js +0 -1
  34. package/dist/esm/audio/shared-audio-tags.js +0 -194
  35. package/dist/esm/audio/use-audio-frame.js +0 -18
  36. package/dist/esm/bezier.js +0 -110
  37. package/dist/esm/cancel-render.js +0 -43
  38. package/dist/esm/config/input-props.js +0 -27
  39. package/dist/esm/config.js +0 -17
  40. package/dist/esm/default-css.js +0 -44
  41. package/dist/esm/delay-render.js +0 -72
  42. package/dist/esm/easing.js +0 -77
  43. package/dist/esm/freeze.js +0 -34
  44. package/dist/esm/get-asset-file-name.js +0 -10
  45. package/dist/esm/get-environment.js +0 -29
  46. package/dist/esm/get-preview-dom-element.js +0 -3
  47. package/dist/esm/get-static-files.js +0 -31
  48. package/dist/esm/get-timeline-clip-name.js +0 -21
  49. package/dist/esm/index.js +0 -49
  50. package/dist/esm/internals.js +0 -75
  51. package/dist/esm/interpolate-colors.js +0 -401
  52. package/dist/esm/interpolate.js +0 -123
  53. package/dist/esm/is-approximately-the-same.js +0 -4
  54. package/dist/esm/is-player.js +0 -9
  55. package/dist/esm/loading-indicator.js +0 -31
  56. package/dist/esm/loop/index.js +0 -29
  57. package/dist/esm/multiple-versions-warning.js +0 -28
  58. package/dist/esm/nonce.js +0 -13
  59. package/dist/esm/play-and-handle-not-allowed-error.js +0 -40
  60. package/dist/esm/portal-node.js +0 -19
  61. package/dist/esm/prefetch-state.js +0 -22
  62. package/dist/esm/prefetch.js +0 -107
  63. package/dist/esm/random.js +0 -37
  64. package/dist/esm/register-root.js +0 -31
  65. package/dist/esm/series/flatten-children.js +0 -12
  66. package/dist/esm/series/index.js +0 -61
  67. package/dist/esm/setup-env-variables.js +0 -32
  68. package/dist/esm/spring/index.js +0 -50
  69. package/dist/esm/spring/measure-spring.js +0 -64
  70. package/dist/esm/spring/spring-utils.js +0 -99
  71. package/dist/esm/static-file.js +0 -29
  72. package/dist/esm/test/Img.test.js +0 -20
  73. package/dist/esm/test/absolute-src.test.js +0 -16
  74. package/dist/esm/test/audio-for-rendering.test.js +0 -83
  75. package/dist/esm/test/audio.test.js +0 -51
  76. package/dist/esm/test/bezier.test.js +0 -50
  77. package/dist/esm/test/composition-rules.test.js +0 -28
  78. package/dist/esm/test/composition-validation.test.js +0 -97
  79. package/dist/esm/test/easing.test.js +0 -189
  80. package/dist/esm/test/expect-to-throw.js +0 -11
  81. package/dist/esm/test/freeze.test.js +0 -63
  82. package/dist/esm/test/get-asset-file-name.test.js +0 -12
  83. package/dist/esm/test/get-current-time.test.js +0 -72
  84. package/dist/esm/test/input-props.test.js +0 -29
  85. package/dist/esm/test/interpolate.test.js +0 -136
  86. package/dist/esm/test/interpolateColors.test.js +0 -61
  87. package/dist/esm/test/loop-validation.test.js +0 -68
  88. package/dist/esm/test/measure-spring.test.js +0 -43
  89. package/dist/esm/test/media-validation.test.js +0 -45
  90. package/dist/esm/test/nested-sequences.test.js +0 -130
  91. package/dist/esm/test/not-all-props-in-media-tags.test.js +0 -28
  92. package/dist/esm/test/random.test.js +0 -58
  93. package/dist/esm/test/ready-manager.test.js +0 -27
  94. package/dist/esm/test/render-hook.js +0 -20
  95. package/dist/esm/test/sequence-from-initial-offset.test.js +0 -33
  96. package/dist/esm/test/sequence-validation.test.js +0 -45
  97. package/dist/esm/test/series.test.js +0 -113
  98. package/dist/esm/test/spring.test.js +0 -36
  99. package/dist/esm/test/truthy.test.js +0 -22
  100. package/dist/esm/test/use-audio-frame.test.js +0 -53
  101. package/dist/esm/test/use-media-in-timeline.test.js +0 -49
  102. package/dist/esm/test/use-media-tag-volume.test.js +0 -44
  103. package/dist/esm/test/use-sync-volume-with-media-tag.test.js +0 -53
  104. package/dist/esm/test/validate-start-from-props.test.js +0 -37
  105. package/dist/esm/test/video.test.js +0 -55
  106. package/dist/esm/test/volume-prop.test.js +0 -93
  107. package/dist/esm/test/wrap-sequence-context.js +0 -37
  108. package/dist/esm/timeline-position-state.js +0 -35
  109. package/dist/esm/truthy.js +0 -3
  110. package/dist/esm/use-current-frame.js +0 -23
  111. package/dist/esm/use-lazy-component.js +0 -22
  112. package/dist/esm/use-media-in-timeline.js +0 -125
  113. package/dist/esm/use-media-playback.js +0 -73
  114. package/dist/esm/use-media-tag-volume.js +0 -27
  115. package/dist/esm/use-sync-volume-with-media-tag.js +0 -17
  116. package/dist/esm/use-unsafe-video-config.js +0 -23
  117. package/dist/esm/use-video-config.js +0 -26
  118. package/dist/esm/use-video.js +0 -24
  119. package/dist/esm/validate-frame.js +0 -20
  120. package/dist/esm/validate-media-props.js +0 -20
  121. package/dist/esm/validate-start-from-props.js +0 -27
  122. package/dist/esm/validation/validate-composition-id.js +0 -8
  123. package/dist/esm/validation/validate-dimensions.js +0 -17
  124. package/dist/esm/validation/validate-duration-in-frames.js +0 -11
  125. package/dist/esm/validation/validate-folder-name.js +0 -14
  126. package/dist/esm/validation/validate-fps.js +0 -17
  127. package/dist/esm/validation/validate-offthreadvideo-image-format.js +0 -11
  128. package/dist/esm/validation/validation-spring-duration.js +0 -17
  129. package/dist/esm/version.js +0 -2
  130. package/dist/esm/video/OffthreadVideo.js +0 -33
  131. package/dist/esm/video/OffthreadVideoForRendering.js +0 -100
  132. package/dist/esm/video/Video.js +0 -51
  133. package/dist/esm/video/VideoForDevelopment.js +0 -110
  134. package/dist/esm/video/VideoForRendering.js +0 -200
  135. package/dist/esm/video/duration-state.js +0 -29
  136. package/dist/esm/video/get-current-time.js +0 -26
  137. package/dist/esm/video/index.js +0 -2
  138. package/dist/esm/video/props.js +0 -1
  139. package/dist/esm/video/video-fragment.js +0 -55
  140. package/dist/esm/video-config.js +0 -1
  141. package/dist/esm/volume-position-state.js +0 -27
  142. package/dist/esm/volume-prop.js +0 -20
  143. package/dist/esm/warn-about-non-seekable-media.js +0 -30
  144. package/dist/esm/wrap-remotion-context.js +0 -45
@@ -1,123 +0,0 @@
1
- // Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
2
- /**
3
- * @description This function allows you to map a range of values to another with a conside syntax
4
- * @see [Documentation](https://www.remotion.dev/docs/interpolate)
5
- */
6
- function interpolateFunction(input, inputRange, outputRange, options) {
7
- const { extrapolateLeft, extrapolateRight, easing } = options;
8
- let result = input;
9
- const [inputMin, inputMax] = inputRange;
10
- const [outputMin, outputMax] = outputRange;
11
- if (result < inputMin) {
12
- if (extrapolateLeft === 'identity') {
13
- return result;
14
- }
15
- if (extrapolateLeft === 'clamp') {
16
- result = inputMin;
17
- }
18
- else if (extrapolateLeft === 'extend') {
19
- // noop
20
- }
21
- }
22
- if (result > inputMax) {
23
- if (extrapolateRight === 'identity') {
24
- return result;
25
- }
26
- if (extrapolateRight === 'clamp') {
27
- result = inputMax;
28
- }
29
- else if (extrapolateRight === 'extend') {
30
- // noop
31
- }
32
- }
33
- if (outputMin === outputMax) {
34
- return outputMin;
35
- }
36
- // Input Range
37
- result = (result - inputMin) / (inputMax - inputMin);
38
- // Easing
39
- result = easing(result);
40
- // Output Range
41
- result = result * (outputMax - outputMin) + outputMin;
42
- return result;
43
- }
44
- function findRange(input, inputRange) {
45
- let i;
46
- for (i = 1; i < inputRange.length - 1; ++i) {
47
- if (inputRange[i] >= input) {
48
- break;
49
- }
50
- }
51
- return i - 1;
52
- }
53
- function checkValidInputRange(arr) {
54
- for (let i = 1; i < arr.length; ++i) {
55
- if (!(arr[i] > arr[i - 1])) {
56
- throw new Error(`inputRange must be strictly monotonically non-decreasing but got [${arr.join(',')}]`);
57
- }
58
- }
59
- }
60
- function checkInfiniteRange(name, arr) {
61
- if (arr.length < 2) {
62
- throw new Error(name + ' must have at least 2 elements');
63
- }
64
- for (const index in arr) {
65
- if (typeof arr[index] !== 'number') {
66
- throw new Error(`${name} must contain only numbers`);
67
- }
68
- if (arr[index] === -Infinity || arr[index] === Infinity) {
69
- throw new Error(`${name} must contain only finite numbers, but got [${arr.join(',')}]`);
70
- }
71
- }
72
- }
73
- /**
74
- * Map a value from an input range to an output range.
75
- * @link https://www.remotion.dev/docs/interpolate
76
- * @param {!number} input value to interpolate
77
- * @param {!number[]} inputRange range of values that you expect the input to assume.
78
- * @param {!number[]} outputRange range of output values that you want the input to map to.
79
- * @param {?object} options
80
- * @param {?Function} options.easing easing function which allows you to customize the input, for example to apply a certain easing function. By default, the input is left unmodified, resulting in a pure linear interpolation {@link https://www.remotion.dev/docs/easing}
81
- * @param {string=} [options.extrapolateLeft="extend"] What should happen if the input value is outside left the input range, default: "extend" {@link https://www.remotion.dev/docs/interpolate#extrapolateleft}
82
- * @param {string=} [options.extrapolateRight="extend"] Same as extrapolateLeft, except for values outside right the input range {@link https://www.remotion.dev/docs/interpolate#extrapolateright}
83
- */
84
- export function interpolate(input, inputRange, outputRange, options) {
85
- var _a;
86
- if (typeof input === 'undefined') {
87
- throw new Error('input can not be undefined');
88
- }
89
- if (typeof inputRange === 'undefined') {
90
- throw new Error('inputRange can not be undefined');
91
- }
92
- if (typeof outputRange === 'undefined') {
93
- throw new Error('outputRange can not be undefined');
94
- }
95
- if (inputRange.length !== outputRange.length) {
96
- throw new Error('inputRange (' +
97
- inputRange.length +
98
- ') and outputRange (' +
99
- outputRange.length +
100
- ') must have the same length');
101
- }
102
- checkInfiniteRange('inputRange', inputRange);
103
- checkInfiniteRange('outputRange', outputRange);
104
- checkValidInputRange(inputRange);
105
- const easing = (_a = options === null || options === void 0 ? void 0 : options.easing) !== null && _a !== void 0 ? _a : ((num) => num);
106
- let extrapolateLeft = 'extend';
107
- if ((options === null || options === void 0 ? void 0 : options.extrapolateLeft) !== undefined) {
108
- extrapolateLeft = options.extrapolateLeft;
109
- }
110
- let extrapolateRight = 'extend';
111
- if ((options === null || options === void 0 ? void 0 : options.extrapolateRight) !== undefined) {
112
- extrapolateRight = options.extrapolateRight;
113
- }
114
- if (typeof input !== 'number') {
115
- throw new TypeError('Cannot interpolate an input which is not a number');
116
- }
117
- const range = findRange(input, inputRange);
118
- return interpolateFunction(input, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
119
- easing,
120
- extrapolateLeft,
121
- extrapolateRight,
122
- });
123
- }
@@ -1,4 +0,0 @@
1
- const FLOATING_POINT_ERROR_THRESHOLD = 0.00001;
2
- export const isApproximatelyTheSame = (num1, num2) => {
3
- return Math.abs(num1 - num2) < FLOATING_POINT_ERROR_THRESHOLD;
4
- };
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from 'react';
3
- const IsPlayerContext = createContext(false);
4
- export const IsPlayerContextProvider = ({ children, }) => {
5
- return _jsx(IsPlayerContext.Provider, { value: true, children: children });
6
- };
7
- export const useIsPlayer = () => {
8
- return useContext(IsPlayerContext);
9
- };
@@ -1,31 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AbsoluteFill } from './AbsoluteFill.js';
3
- const rotate = {
4
- transform: `rotate(90deg)`,
5
- };
6
- const ICON_SIZE = 40;
7
- const label = {
8
- color: '#555',
9
- fontSize: 14,
10
- fontFamily: 'sans-serif',
11
- };
12
- const container = {
13
- justifyContent: 'center',
14
- alignItems: 'center',
15
- };
16
- export const Loading = () => {
17
- return (_jsxs(AbsoluteFill, { style: container, id: "remotion-comp-loading", children: [_jsx("style", { type: "text/css", children: `
18
- @keyframes anim {
19
- from {
20
- opacity: 0
21
- }
22
- to {
23
- opacity: 1
24
- }
25
- }
26
- #remotion-comp-loading {
27
- animation: anim 2s;
28
- animation-fill-mode: forwards;
29
- }
30
- ` }), _jsx("svg", { width: ICON_SIZE, height: ICON_SIZE, viewBox: "-100 -100 400 400", style: rotate, children: _jsx("path", { fill: "#555", stroke: "#555", strokeWidth: "100", strokeLinejoin: "round", d: "M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z" }) }), _jsx("p", { style: label, children: "Loading..." })] }));
31
- };
@@ -1,29 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Sequence } from '../Sequence.js';
3
- import { useVideoConfig } from '../use-video-config.js';
4
- import { validateDurationInFrames } from '../validation/validate-duration-in-frames.js';
5
- /**
6
- * @description This component allows you to quickly lay out an animation so it repeats itself.
7
- * @see [Documentation](https://www.remotion.dev/docs/loop)
8
- */
9
- export const Loop = ({ durationInFrames, times = Infinity, children, name, ...props }) => {
10
- const { durationInFrames: compDuration } = useVideoConfig();
11
- validateDurationInFrames(durationInFrames, 'of the <Loop /> component');
12
- if (typeof times !== 'number') {
13
- throw new TypeError(`You passed to "times" an argument of type ${typeof times}, but it must be a number.`);
14
- }
15
- if (times !== Infinity && times % 1 !== 0) {
16
- throw new TypeError(`The "times" prop of a loop must be an integer, but got ${times}.`);
17
- }
18
- if (times < 0) {
19
- throw new TypeError(`The "times" prop of a loop must be at least 0, but got ${times}`);
20
- }
21
- const maxTimes = Math.ceil(compDuration / durationInFrames);
22
- const actualTimes = Math.min(maxTimes, times);
23
- const style = props.layout === 'none' ? undefined : props.style;
24
- return (_jsx(_Fragment, { children: new Array(actualTimes).fill(true).map((_, i) => {
25
- return (_jsx(Sequence
26
- // eslint-disable-next-line react/no-array-index-key
27
- , { durationInFrames: durationInFrames, from: i * durationInFrames, name: name, showLoopTimesInTimeline: actualTimes, showInTimeline: i === 0, layout: props.layout, style: style, children: children }, `loop-${i}`));
28
- }) }));
29
- };
@@ -1,28 +0,0 @@
1
- import { truthy } from './truthy.js';
2
- import { VERSION } from './version.js';
3
- export const checkMultipleRemotionVersions = () => {
4
- if (typeof globalThis === 'undefined') {
5
- return;
6
- }
7
- const alreadyImported = globalThis.remotion_imported ||
8
- (typeof window !== 'undefined' && window.remotion_imported);
9
- if (alreadyImported) {
10
- if (typeof window === 'undefined' && alreadyImported === VERSION) {
11
- // Next.JS will reload the package and cause a server-side warning.
12
- // It's okay if this happens during SSR in developement
13
- return;
14
- }
15
- throw new TypeError(`🚨 Multiple versions of Remotion detected: ${[
16
- VERSION,
17
- typeof alreadyImported === 'string'
18
- ? alreadyImported
19
- : 'an older version',
20
- ]
21
- .filter(truthy)
22
- .join(' and ')}. This will cause things to break in an unexpected way.\nCheck that all your Remotion packages are on the same version. If your dependencies depend on Remotion, make them peer dependencies. You can also run \`npx remotion versions\` from your terminal to see which versions are mismatching.`);
23
- }
24
- globalThis.remotion_imported = VERSION;
25
- if (typeof window !== 'undefined') {
26
- window.remotion_imported = VERSION;
27
- }
28
- };
package/dist/esm/nonce.js DELETED
@@ -1,13 +0,0 @@
1
- import { createContext, useContext, useEffect, useState } from 'react';
2
- export const NonceContext = createContext({
3
- getNonce: () => 0,
4
- fastRefreshes: 0,
5
- });
6
- export const useNonce = () => {
7
- const context = useContext(NonceContext);
8
- const [nonce, setNonce] = useState(() => context.getNonce());
9
- useEffect(() => {
10
- setNonce(context.getNonce);
11
- }, [context]);
12
- return nonce;
13
- };
@@ -1,40 +0,0 @@
1
- export const playAndHandleNotAllowedError = (mediaRef, mediaType) => {
2
- const { current } = mediaRef;
3
- if (!current) {
4
- return;
5
- }
6
- const prom = current.play();
7
- if (prom.catch) {
8
- prom.catch((err) => {
9
- if (!current) {
10
- return;
11
- }
12
- // Pause was called after play in Chrome
13
- if (err.message.includes('request was interrupted by a call to pause')) {
14
- return;
15
- }
16
- // Pause was called after play in Safari
17
- if (err.message.includes('The operation was aborted.')) {
18
- return;
19
- }
20
- // Pause was called after play in Firefox
21
- if (err.message.includes('The fetching process for the media resource was aborted by the user agent')) {
22
- return;
23
- }
24
- // Got replaced by a different audio source in Chromium
25
- if (err.message.includes('request was interrupted by a new load request')) {
26
- return;
27
- }
28
- // Audio tag got unmounted
29
- if (err.message.includes('because the media was removed from the document')) {
30
- return;
31
- }
32
- console.log(`Could not play ${mediaType} due to following error: `, err);
33
- if (!current.muted) {
34
- console.log(`The video will be muted and we'll retry playing it.`, err);
35
- current.muted = true;
36
- current.play();
37
- }
38
- });
39
- }
40
- };
@@ -1,19 +0,0 @@
1
- let _portalNode = null;
2
- export const portalNode = () => {
3
- if (!_portalNode) {
4
- if (typeof document === 'undefined') {
5
- throw new Error('Tried to call an API that only works in the browser from outside the browser');
6
- }
7
- _portalNode = document.createElement('div');
8
- _portalNode.style.position = 'absolute';
9
- _portalNode.style.top = '0px';
10
- _portalNode.style.left = '0px';
11
- _portalNode.style.right = '0px';
12
- _portalNode.style.bottom = '0px';
13
- _portalNode.style.width = '100%';
14
- _portalNode.style.height = '100%';
15
- _portalNode.style.display = 'flex';
16
- _portalNode.style.flexDirection = 'column';
17
- }
18
- return _portalNode;
19
- };
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useEffect, useState } from 'react';
3
- export const PreloadContext = createContext({});
4
- let preloads = {};
5
- let updaters = [];
6
- export const setPreloads = (updater) => {
7
- preloads = updater(preloads);
8
- updaters.forEach((u) => u());
9
- };
10
- export const PrefetchProvider = ({ children }) => {
11
- const [_preloads, _setPreloads] = useState(() => preloads);
12
- useEffect(() => {
13
- const updaterFunction = () => {
14
- _setPreloads(preloads);
15
- };
16
- updaters.push(updaterFunction);
17
- return () => {
18
- updaters = updaters.filter((u) => u !== updaterFunction);
19
- };
20
- }, []);
21
- return (_jsx(PreloadContext.Provider, { value: _preloads, children: children }));
22
- };
@@ -1,107 +0,0 @@
1
- import { useContext } from 'react';
2
- import { getRemotionEnvironment } from './get-environment.js';
3
- import { PreloadContext, setPreloads } from './prefetch-state.js';
4
- export const usePreload = (src) => {
5
- var _a;
6
- const preloads = useContext(PreloadContext);
7
- return (_a = preloads[src]) !== null && _a !== void 0 ? _a : src;
8
- };
9
- const blobToBase64 = function (blob) {
10
- const reader = new FileReader();
11
- return new Promise((resolve, reject) => {
12
- reader.onload = function () {
13
- const dataUrl = reader.result;
14
- resolve(dataUrl);
15
- };
16
- reader.onerror = (err) => {
17
- return reject(err);
18
- };
19
- reader.readAsDataURL(blob);
20
- });
21
- };
22
- /**
23
- * @description When you call the preFetch() function, an asset will be fetched and kept in memory so it is ready when you want to play it in a <Player>.
24
- * @see [Documentation](https://www.remotion.dev/docs/prefetch)
25
- */
26
- export const prefetch = (src, options) => {
27
- var _a;
28
- const method = (_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'blob-url';
29
- if (getRemotionEnvironment() === 'rendering') {
30
- return {
31
- free: () => undefined,
32
- waitUntilDone: () => Promise.resolve(src),
33
- };
34
- }
35
- let canceled = false;
36
- let objectUrl = null;
37
- let resolve = () => undefined;
38
- let reject = () => undefined;
39
- const waitUntilDone = new Promise((res, rej) => {
40
- resolve = res;
41
- reject = rej;
42
- });
43
- const controller = new AbortController();
44
- let canBeAborted = true;
45
- fetch(src, {
46
- signal: controller.signal,
47
- })
48
- .then((res) => {
49
- canBeAborted = false;
50
- if (canceled) {
51
- return null;
52
- }
53
- if (!res.ok) {
54
- throw new Error(`HTTP error, status = ${res.status}`);
55
- }
56
- return res.blob();
57
- })
58
- .then((buf) => {
59
- if (!buf) {
60
- return;
61
- }
62
- if (method === 'base64') {
63
- return blobToBase64(buf);
64
- }
65
- return URL.createObjectURL(buf);
66
- })
67
- .then((url) => {
68
- if (canceled) {
69
- return;
70
- }
71
- objectUrl = url;
72
- setPreloads((p) => ({
73
- ...p,
74
- [src]: objectUrl,
75
- }));
76
- resolve(objectUrl);
77
- })
78
- .catch((err) => {
79
- reject(err);
80
- });
81
- return {
82
- free: () => {
83
- if (objectUrl) {
84
- if (method === 'blob-url') {
85
- URL.revokeObjectURL(objectUrl);
86
- }
87
- setPreloads((p) => {
88
- const copy = { ...p };
89
- delete copy[src];
90
- return copy;
91
- });
92
- }
93
- else {
94
- canceled = true;
95
- if (canBeAborted) {
96
- try {
97
- controller.abort();
98
- }
99
- catch (e) { }
100
- }
101
- }
102
- },
103
- waitUntilDone: () => {
104
- return waitUntilDone;
105
- },
106
- };
107
- };
@@ -1,37 +0,0 @@
1
- /* eslint-disable no-bitwise */
2
- function mulberry32(a) {
3
- let t = a + 0x6d2b79f5;
4
- t = Math.imul(t ^ (t >>> 15), t | 1);
5
- t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
6
- return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
7
- }
8
- function hashCode(str) {
9
- let i = 0;
10
- let chr = 0;
11
- let hash = 0;
12
- for (i = 0; i < str.length; i++) {
13
- chr = str.charCodeAt(i);
14
- hash = (hash << 5) - hash + chr;
15
- hash |= 0; // Convert to 32bit integer
16
- }
17
- return hash;
18
- }
19
- /**
20
- * @description A deterministic pseudo-random number generator. Pass in the same seed and get the same pseudorandom number.
21
- * @see [Documentation](https://remotion.dev/docs/random)
22
- */
23
- export const random = (seed, dummy) => {
24
- if (dummy !== undefined) {
25
- throw new TypeError('random() takes only one argument');
26
- }
27
- if (seed === null) {
28
- return Math.random();
29
- }
30
- if (typeof seed === 'string') {
31
- return mulberry32(hashCode(seed));
32
- }
33
- if (typeof seed === 'number') {
34
- return mulberry32(seed * 10000000000);
35
- }
36
- throw new Error('random() argument must be a number or a string');
37
- };
@@ -1,31 +0,0 @@
1
- let Root = null;
2
- let listeners = [];
3
- /**
4
- * @description This function registers the root component of the Remotion project
5
- * @see [Documentation](https://www.remotion.dev/docs/register-root)
6
- */
7
- export const registerRoot = (comp) => {
8
- if (!comp) {
9
- throw new Error(`You must pass a React component to registerRoot(), but ${JSON.stringify(comp)} was passed.`);
10
- }
11
- if (Root) {
12
- throw new Error('registerRoot() was called more than once.');
13
- }
14
- Root = comp;
15
- listeners.forEach((l) => {
16
- l(comp);
17
- });
18
- };
19
- export const getRoot = () => {
20
- return Root;
21
- };
22
- export const waitForRoot = (fn) => {
23
- if (Root) {
24
- fn(Root);
25
- return () => undefined;
26
- }
27
- listeners.push(fn);
28
- return () => {
29
- listeners = listeners.filter((l) => l !== fn);
30
- };
31
- };
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- export const flattenChildren = (children) => {
3
- const childrenArray = React.Children.toArray(children);
4
- return childrenArray.reduce((flatChildren, child) => {
5
- if (child.type === React.Fragment) {
6
- return flatChildren.concat(flattenChildren(child.props
7
- .children));
8
- }
9
- flatChildren.push(child);
10
- return flatChildren;
11
- }, []);
12
- };
@@ -1,61 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { Children, forwardRef, useMemo } from 'react';
3
- import { Sequence } from '../Sequence.js';
4
- import { validateDurationInFrames } from '../validation/validate-duration-in-frames.js';
5
- import { flattenChildren } from './flatten-children.js';
6
- const SeriesSequenceRefForwardingFunction = ({ children }, _ref) => {
7
- // Discard ref
8
- // eslint-disable-next-line react/jsx-no-useless-fragment
9
- return _jsx(_Fragment, { children: children });
10
- };
11
- const SeriesSequence = forwardRef(SeriesSequenceRefForwardingFunction);
12
- /**
13
- * @description with this component, you can easily stitch together scenes that should play sequentially after another.
14
- * @see [Documentation](https://www.remotion.dev/docs/series)
15
- */
16
- const Series = ({ children }) => {
17
- const childrenValue = useMemo(() => {
18
- let startFrame = 0;
19
- const flattenedChildren = flattenChildren(children);
20
- return Children.map(flattenedChildren, (child, i) => {
21
- var _a;
22
- const castedChild = child;
23
- if (typeof castedChild === 'string') {
24
- // Don't throw if it's just some accidential whitespace
25
- if (castedChild.trim() === '') {
26
- return null;
27
- }
28
- throw new TypeError(`The <Series /> component only accepts a list of <Series.Sequence /> components as it's children, but you passed a string "${castedChild}"`);
29
- }
30
- if (castedChild.type !== SeriesSequence) {
31
- throw new TypeError(`The <Series /> component only accepts a list of <Series.Sequence /> components as it's children, but got ${castedChild} instead`);
32
- }
33
- const debugInfo = `index = ${i}, duration = ${castedChild.props.durationInFrames}`;
34
- if (!castedChild || !castedChild.props.children) {
35
- throw new TypeError(`A <Series.Sequence /> component (${debugInfo}) was detected to not have any children. Delete it to fix this error.`);
36
- }
37
- const durationInFramesProp = castedChild.props.durationInFrames;
38
- const { durationInFrames, children: _children, ...passedProps } = castedChild.props;
39
- if (i !== flattenedChildren.length - 1 || durationInFramesProp !== Infinity) {
40
- validateDurationInFrames(durationInFramesProp, `of a <Series.Sequence /> component`);
41
- }
42
- const offset = (_a = castedChild.props.offset) !== null && _a !== void 0 ? _a : 0;
43
- if (Number.isNaN(offset)) {
44
- throw new TypeError(`The "offset" property of a <Series.Sequence /> must not be NaN, but got NaN (${debugInfo}).`);
45
- }
46
- if (!Number.isFinite(offset)) {
47
- throw new TypeError(`The "offset" property of a <Series.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
48
- }
49
- if (offset % 1 !== 0) {
50
- throw new TypeError(`The "offset" property of a <Series.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
51
- }
52
- const currentStartFrame = startFrame + offset;
53
- startFrame += durationInFramesProp + offset;
54
- return (_jsx(Sequence, { from: currentStartFrame, durationInFrames: durationInFramesProp, ...passedProps, ref: castedChild.ref, children: child }));
55
- });
56
- }, [children]);
57
- /* eslint-disable react/jsx-no-useless-fragment */
58
- return _jsx(_Fragment, { children: childrenValue });
59
- };
60
- Series.Sequence = SeriesSequence;
61
- export { Series };
@@ -1,32 +0,0 @@
1
- import { getRemotionEnvironment } from './get-environment.js';
2
- export const ENV_VARIABLES_ENV_NAME = 'ENV_VARIABLES';
3
- const getEnvVariables = () => {
4
- if (getRemotionEnvironment() === 'rendering') {
5
- const param = window.remotion_envVariables;
6
- if (!param) {
7
- return {};
8
- }
9
- return { ...JSON.parse(param), NODE_ENV: process.env.NODE_ENV };
10
- }
11
- if (getRemotionEnvironment() === 'preview') {
12
- // Webpack will convert this to an object at compile time.
13
- // Don't convert this syntax to a computed property.
14
- return {
15
- ...process.env.ENV_VARIABLES,
16
- NODE_ENV: process.env.NODE_ENV,
17
- };
18
- }
19
- throw new Error('Can only call getEnvVariables() if environment is `rendering` or `preview`');
20
- };
21
- export const setupEnvVariables = () => {
22
- const env = getEnvVariables();
23
- if (!window.process) {
24
- window.process = {};
25
- }
26
- if (!window.process.env) {
27
- window.process.env = {};
28
- }
29
- Object.keys(env).forEach((key) => {
30
- window.process.env[key] = env[key];
31
- });
32
- };
@@ -1,50 +0,0 @@
1
- import { validateFrame } from '../validate-frame.js';
2
- import { validateFps } from '../validation/validate-fps.js';
3
- import { validateSpringDuration } from '../validation/validation-spring-duration.js';
4
- import { measureSpring } from './measure-spring.js';
5
- import { springCalculation } from './spring-utils.js';
6
- /**
7
- * @description Calculates a position based on physical parameters, start and end value, and time.
8
- * @see [Documentation](https://www.remotion.dev/docs/spring)
9
- * @param {number} frame The current time value. Most of the time you want to pass in the return value of useCurrentFrame.
10
- * @param {number} fps The framerate at which the animation runs. Pass in the value obtained by `useVideoConfig()`.
11
- * @param {?Object} config optional object that allows you to customize the physical properties of the animation.
12
- * @param {number} [config.mass=1] The weight of the spring. If you reduce the mass, the animation becomes faster!
13
- * @param {number} [config.damping=10] How hard the animation decelerates.
14
- * @param {number} [config.stiffness=100] Affects bounciness of the animation.
15
- * @param {boolean} [config.overshootClamping=false] Whether to prevent the animation going beyond the target value.
16
- * @param {?number} [config.from] The initial value of the animation. Default `0`
17
- * @param {?number} [config.to] The end value of the animation. Default `1`
18
- * @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
19
- * @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
20
- */
21
- export function spring({ frame, fps, config = {}, from = 0, to = 1, durationInFrames, durationRestThreshold, }) {
22
- validateSpringDuration(durationInFrames);
23
- validateFrame(frame, Infinity);
24
- validateFps(fps, 'to spring()', false);
25
- const durationRatio = durationInFrames === undefined
26
- ? 1
27
- : durationInFrames /
28
- measureSpring({
29
- fps,
30
- config,
31
- from,
32
- to,
33
- threshold: durationRestThreshold,
34
- });
35
- const spr = springCalculation({
36
- fps,
37
- frame: frame / durationRatio,
38
- config,
39
- from,
40
- to,
41
- });
42
- if (!config.overshootClamping) {
43
- return spr.current;
44
- }
45
- if (to >= from) {
46
- return Math.min(spr.current, to);
47
- }
48
- return Math.max(spr.current, to);
49
- }
50
- export { measureSpring } from './measure-spring.js';