remotion 3.3.55 → 3.3.56

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 (143) 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/use-video.d.ts +1 -1
  5. package/dist/cjs/version.d.ts +1 -1
  6. package/dist/cjs/version.js +1 -1
  7. package/dist/esm/index.mjs +1 -1
  8. package/dist/esm/version.mjs +1 -1
  9. package/dist/tsconfig-esm.tsbuildinfo +1 -0
  10. package/package.json +3 -3
  11. package/tsconfig-esm.json +12 -0
  12. package/dist/esm/AbsoluteFill.js +0 -25
  13. package/dist/esm/CanUseRemotionHooks.js +0 -6
  14. package/dist/esm/Clipper.js +0 -20
  15. package/dist/esm/Composition.js +0 -112
  16. package/dist/esm/CompositionManager.js +0 -137
  17. package/dist/esm/Folder.js +0 -33
  18. package/dist/esm/IFrame.js +0 -25
  19. package/dist/esm/Img.js +0 -53
  20. package/dist/esm/NativeLayers.js +0 -25
  21. package/dist/esm/Null.js +0 -21
  22. package/dist/esm/RemotionRoot.js +0 -69
  23. package/dist/esm/Sequence.js +0 -128
  24. package/dist/esm/SequenceContext.js +0 -2
  25. package/dist/esm/Still.js +0 -9
  26. package/dist/esm/absolute-src.js +0 -3
  27. package/dist/esm/asset-types.js +0 -1
  28. package/dist/esm/audio/Audio.js +0 -53
  29. package/dist/esm/audio/AudioForDevelopment.js +0 -91
  30. package/dist/esm/audio/AudioForRendering.js +0 -108
  31. package/dist/esm/audio/index.js +0 -2
  32. package/dist/esm/audio/props.js +0 -1
  33. package/dist/esm/audio/shared-audio-tags.js +0 -194
  34. package/dist/esm/audio/use-audio-frame.js +0 -18
  35. package/dist/esm/bezier.js +0 -110
  36. package/dist/esm/cancel-render.js +0 -43
  37. package/dist/esm/config/input-props.js +0 -27
  38. package/dist/esm/config.js +0 -17
  39. package/dist/esm/default-css.js +0 -44
  40. package/dist/esm/delay-render.js +0 -72
  41. package/dist/esm/easing.js +0 -77
  42. package/dist/esm/freeze.js +0 -34
  43. package/dist/esm/get-asset-file-name.js +0 -10
  44. package/dist/esm/get-environment.js +0 -29
  45. package/dist/esm/get-preview-dom-element.js +0 -3
  46. package/dist/esm/get-static-files.js +0 -31
  47. package/dist/esm/get-timeline-clip-name.js +0 -21
  48. package/dist/esm/index.js +0 -49
  49. package/dist/esm/internals.js +0 -75
  50. package/dist/esm/interpolate-colors.js +0 -401
  51. package/dist/esm/interpolate.js +0 -123
  52. package/dist/esm/is-approximately-the-same.js +0 -4
  53. package/dist/esm/is-player.js +0 -9
  54. package/dist/esm/loading-indicator.js +0 -31
  55. package/dist/esm/loop/index.js +0 -29
  56. package/dist/esm/multiple-versions-warning.js +0 -28
  57. package/dist/esm/nonce.js +0 -13
  58. package/dist/esm/play-and-handle-not-allowed-error.js +0 -40
  59. package/dist/esm/portal-node.js +0 -19
  60. package/dist/esm/prefetch-state.js +0 -22
  61. package/dist/esm/prefetch.js +0 -107
  62. package/dist/esm/random.js +0 -37
  63. package/dist/esm/register-root.js +0 -31
  64. package/dist/esm/series/flatten-children.js +0 -12
  65. package/dist/esm/series/index.js +0 -61
  66. package/dist/esm/setup-env-variables.js +0 -32
  67. package/dist/esm/spring/index.js +0 -50
  68. package/dist/esm/spring/measure-spring.js +0 -64
  69. package/dist/esm/spring/spring-utils.js +0 -99
  70. package/dist/esm/static-file.js +0 -29
  71. package/dist/esm/test/Img.test.js +0 -20
  72. package/dist/esm/test/absolute-src.test.js +0 -16
  73. package/dist/esm/test/audio-for-rendering.test.js +0 -83
  74. package/dist/esm/test/audio.test.js +0 -51
  75. package/dist/esm/test/bezier.test.js +0 -50
  76. package/dist/esm/test/composition-rules.test.js +0 -28
  77. package/dist/esm/test/composition-validation.test.js +0 -97
  78. package/dist/esm/test/easing.test.js +0 -189
  79. package/dist/esm/test/expect-to-throw.js +0 -11
  80. package/dist/esm/test/freeze.test.js +0 -63
  81. package/dist/esm/test/get-asset-file-name.test.js +0 -12
  82. package/dist/esm/test/get-current-time.test.js +0 -72
  83. package/dist/esm/test/input-props.test.js +0 -29
  84. package/dist/esm/test/interpolate.test.js +0 -136
  85. package/dist/esm/test/interpolateColors.test.js +0 -61
  86. package/dist/esm/test/loop-validation.test.js +0 -68
  87. package/dist/esm/test/measure-spring.test.js +0 -43
  88. package/dist/esm/test/media-validation.test.js +0 -45
  89. package/dist/esm/test/nested-sequences.test.js +0 -130
  90. package/dist/esm/test/not-all-props-in-media-tags.test.js +0 -28
  91. package/dist/esm/test/random.test.js +0 -58
  92. package/dist/esm/test/ready-manager.test.js +0 -27
  93. package/dist/esm/test/render-hook.js +0 -20
  94. package/dist/esm/test/sequence-from-initial-offset.test.js +0 -33
  95. package/dist/esm/test/sequence-validation.test.js +0 -45
  96. package/dist/esm/test/series.test.js +0 -113
  97. package/dist/esm/test/spring.test.js +0 -36
  98. package/dist/esm/test/truthy.test.js +0 -22
  99. package/dist/esm/test/use-audio-frame.test.js +0 -53
  100. package/dist/esm/test/use-media-in-timeline.test.js +0 -49
  101. package/dist/esm/test/use-media-tag-volume.test.js +0 -44
  102. package/dist/esm/test/use-sync-volume-with-media-tag.test.js +0 -53
  103. package/dist/esm/test/validate-start-from-props.test.js +0 -37
  104. package/dist/esm/test/video.test.js +0 -55
  105. package/dist/esm/test/volume-prop.test.js +0 -93
  106. package/dist/esm/test/wrap-sequence-context.js +0 -37
  107. package/dist/esm/timeline-position-state.js +0 -35
  108. package/dist/esm/truthy.js +0 -3
  109. package/dist/esm/use-current-frame.js +0 -23
  110. package/dist/esm/use-lazy-component.js +0 -22
  111. package/dist/esm/use-media-in-timeline.js +0 -125
  112. package/dist/esm/use-media-playback.js +0 -73
  113. package/dist/esm/use-media-tag-volume.js +0 -27
  114. package/dist/esm/use-sync-volume-with-media-tag.js +0 -17
  115. package/dist/esm/use-unsafe-video-config.js +0 -23
  116. package/dist/esm/use-video-config.js +0 -26
  117. package/dist/esm/use-video.js +0 -24
  118. package/dist/esm/validate-frame.js +0 -20
  119. package/dist/esm/validate-media-props.js +0 -20
  120. package/dist/esm/validate-start-from-props.js +0 -27
  121. package/dist/esm/validation/validate-composition-id.js +0 -8
  122. package/dist/esm/validation/validate-dimensions.js +0 -17
  123. package/dist/esm/validation/validate-duration-in-frames.js +0 -11
  124. package/dist/esm/validation/validate-folder-name.js +0 -14
  125. package/dist/esm/validation/validate-fps.js +0 -17
  126. package/dist/esm/validation/validate-offthreadvideo-image-format.js +0 -11
  127. package/dist/esm/validation/validation-spring-duration.js +0 -17
  128. package/dist/esm/version.js +0 -2
  129. package/dist/esm/video/OffthreadVideo.js +0 -33
  130. package/dist/esm/video/OffthreadVideoForRendering.js +0 -100
  131. package/dist/esm/video/Video.js +0 -51
  132. package/dist/esm/video/VideoForDevelopment.js +0 -110
  133. package/dist/esm/video/VideoForRendering.js +0 -200
  134. package/dist/esm/video/duration-state.js +0 -29
  135. package/dist/esm/video/get-current-time.js +0 -26
  136. package/dist/esm/video/index.js +0 -2
  137. package/dist/esm/video/props.js +0 -1
  138. package/dist/esm/video/video-fragment.js +0 -55
  139. package/dist/esm/video-config.js +0 -1
  140. package/dist/esm/volume-position-state.js +0 -27
  141. package/dist/esm/volume-prop.js +0 -20
  142. package/dist/esm/warn-about-non-seekable-media.js +0 -30
  143. package/dist/esm/wrap-remotion-context.js +0 -45
@@ -1,189 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { Easing } from '../easing.js';
3
- const numbersToTest = [-0.5, 0, 0.4, 0.5, 0.7, 1, 1.5];
4
- describe('Easing step0', () => {
5
- const step0 = (n) => {
6
- return n > 0 ? 1 : 0;
7
- };
8
- const out = (n) => 1 - step0(1 - n);
9
- const inOut = (n) => {
10
- if (n >= 0.5) {
11
- return 1 - step0((1 - n) * 2) / 2;
12
- }
13
- return step0(n * 2) / 2;
14
- };
15
- test('Easing In', () => {
16
- const easingIn = Easing.in(Easing.step0);
17
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(step0(n)));
18
- });
19
- test('Easing Out', () => {
20
- const easingOut = Easing.out(Easing.step0);
21
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
22
- });
23
- test('Easing In Out', () => {
24
- const easingInOut = Easing.inOut(Easing.step0);
25
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
26
- });
27
- });
28
- describe('Easing step1', () => {
29
- const step1 = (n) => {
30
- return n >= 1 ? 1 : 0;
31
- };
32
- const out = (n) => 1 - step1(1 - n);
33
- const inOut = (n) => {
34
- if (n >= 0.5) {
35
- return 1 - step1((1 - n) * 2) / 2;
36
- }
37
- return step1(n * 2) / 2;
38
- };
39
- test('Easing In', () => {
40
- const easingIn = Easing.in(Easing.step1);
41
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(step1(n)));
42
- });
43
- test('Easing Out', () => {
44
- const easingOut = Easing.out(Easing.step1);
45
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
46
- });
47
- test('Easing In Out', () => {
48
- const easingInOut = Easing.inOut(Easing.step1);
49
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
50
- });
51
- });
52
- describe('Easing linear', () => {
53
- test('Easing In', () => {
54
- const easingIn = Easing.in(Easing.linear);
55
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(n));
56
- });
57
- test('Easing In Out', () => {
58
- const easingOut = Easing.out(Easing.linear);
59
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(n));
60
- });
61
- test('Easing Out', () => {
62
- const easingInOut = Easing.inOut(Easing.linear);
63
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(n));
64
- });
65
- });
66
- describe('Easing Quadratic', () => {
67
- const quad = (n) => n * n;
68
- const out = (n) => 1 - quad(1 - n);
69
- const inOut = (n) => {
70
- if (n >= 0.5) {
71
- return 1 - quad((1 - n) * 2) / 2;
72
- }
73
- return quad(n * 2) / 2;
74
- };
75
- test('Easing In', () => {
76
- const easingIn = Easing.in(Easing.quad);
77
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(quad(n)));
78
- });
79
- test('Easing In Out', () => {
80
- const easingOut = Easing.out(Easing.quad);
81
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
82
- });
83
- test('Easing Out', () => {
84
- const easingInOut = Easing.inOut(Easing.quad);
85
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
86
- });
87
- });
88
- describe('Easing Cubic', () => {
89
- const cubic = (n) => n * n * n;
90
- const out = (n) => 1 - cubic(1 - n);
91
- const inOut = (n) => {
92
- if (n >= 0.5) {
93
- return 1 - cubic((1 - n) * 2) / 2;
94
- }
95
- return cubic(n * 2) / 2;
96
- };
97
- test('Easing In', () => {
98
- const easingIn = Easing.in(Easing.cubic);
99
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(cubic(n)));
100
- });
101
- test('Easing In Out', () => {
102
- const easingOut = Easing.out(Easing.cubic);
103
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
104
- });
105
- test('Easing Out', () => {
106
- const easingInOut = Easing.inOut(Easing.cubic);
107
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
108
- });
109
- });
110
- describe('Easing Circle', () => {
111
- const circle = (n) => 1 - Math.sqrt(1 - n * n);
112
- const out = (n) => 1 - circle(1 - n);
113
- const inOut = (n) => {
114
- if (n >= 0.5) {
115
- return 1 - circle((1 - n) * 2) / 2;
116
- }
117
- return circle(n * 2) / 2;
118
- };
119
- test('Easing In', () => {
120
- const easingIn = Easing.in(Easing.circle);
121
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(circle(n)));
122
- });
123
- test('Easing In Out', () => {
124
- const easingOut = Easing.out(Easing.circle);
125
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
126
- });
127
- test('Easing Out', () => {
128
- const easingInOut = Easing.inOut(Easing.circle);
129
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
130
- });
131
- });
132
- describe('Easing Exp', () => {
133
- const exp = (n) => 2 ** (10 * (n - 1));
134
- const out = (n) => 1 - exp(1 - n);
135
- const inOut = (n) => {
136
- if (n >= 0.5) {
137
- return 1 - exp((1 - n) * 2) / 2;
138
- }
139
- return exp(n * 2) / 2;
140
- };
141
- test('Easing In', () => {
142
- const easingIn = Easing.in(Easing.exp);
143
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(exp(n)));
144
- });
145
- test('Easing In Out', () => {
146
- const easingOut = Easing.out(Easing.exp);
147
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
148
- });
149
- test('Easing Out', () => {
150
- const easingInOut = Easing.inOut(Easing.exp);
151
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
152
- });
153
- });
154
- describe('Easing Bounce', () => {
155
- const bounce = (n) => {
156
- if (n < 1 / 2.75) {
157
- return 7.5625 * n * n;
158
- }
159
- if (n < 2 / 2.75) {
160
- const t2_ = n - 1.5 / 2.75;
161
- return 7.5625 * t2_ * t2_ + 0.75;
162
- }
163
- if (n < 2.5 / 2.75) {
164
- const t2_ = n - 2.25 / 2.75;
165
- return 7.5625 * t2_ * t2_ + 0.9375;
166
- }
167
- const t2 = n - 2.625 / 2.75;
168
- return 7.5625 * t2 * t2 + 0.984375;
169
- };
170
- const out = (n) => 1 - bounce(1 - n);
171
- const inOut = (n) => {
172
- if (n >= 0.5) {
173
- return 1 - bounce((1 - n) * 2) / 2;
174
- }
175
- return bounce(n * 2) / 2;
176
- };
177
- test('Easing In', () => {
178
- const easingIn = Easing.in(Easing.bounce);
179
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(bounce(n)));
180
- });
181
- test('Easing In Out', () => {
182
- const easingOut = Easing.out(Easing.bounce);
183
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
184
- });
185
- test('Easing Out', () => {
186
- const easingInOut = Easing.inOut(Easing.bounce);
187
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
188
- });
189
- });
@@ -1,11 +0,0 @@
1
- import { expect, vitest } from 'vitest';
2
- export const expectToThrow = (func, err) => {
3
- // Even though the error is caught, it still gets printed to the console
4
- // so we mock that out to avoid the wall of red text.
5
- vitest.spyOn(console, 'error');
6
- // @ts-expect-error
7
- console.error.mockImplementation(() => undefined);
8
- expect(func).toThrow(err);
9
- // @ts-expect-error
10
- console.error.mockRestore();
11
- };
@@ -1,63 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * @vitest-environment jsdom
4
- */
5
- import { render } from '@testing-library/react';
6
- import { describe, expect, test } from 'vitest';
7
- import { CanUseRemotionHooksProvider } from '../CanUseRemotionHooks.js';
8
- import { Freeze } from '../freeze.js';
9
- import { Sequence } from '../Sequence.js';
10
- import { TimelineContext } from '../timeline-position-state.js';
11
- import { useCurrentFrame } from '../use-current-frame.js';
12
- import { expectToThrow } from './expect-to-throw.js';
13
- import { WrapSequenceContext } from './wrap-sequence-context.js';
14
- describe('Prop validation', () => {
15
- test('It should throw if Freeze has string as frame prop value', () => {
16
- expectToThrow(
17
- // @ts-expect-error
18
- () => render(_jsx(Freeze, { frame: '0' })), /The 'frame' prop of <Freeze \/> must be a number, but is of type string/);
19
- });
20
- test('It should throw if Freeze has undefined as frame prop value', () => {
21
- expectToThrow(
22
- // @ts-expect-error
23
- () => render(_jsx(Freeze, {})), /The <Freeze \/> component requires a 'frame' prop, but none was passed./);
24
- });
25
- });
26
- const timelineCtxValue = (frame) => ({
27
- rootId: '',
28
- frame,
29
- playing: false,
30
- imperativePlaying: {
31
- current: false,
32
- },
33
- playbackRate: 1,
34
- setPlaybackRate: () => {
35
- throw new Error('playback rate');
36
- },
37
- audioAndVideoTags: { current: [] },
38
- });
39
- const renderForFrame = (frame, markup) => {
40
- return render(_jsx(CanUseRemotionHooksProvider, { children: _jsx(TimelineContext.Provider, { value: timelineCtxValue(frame), children: markup }) }));
41
- };
42
- const Basic = () => {
43
- return (_jsx(Freeze, { frame: 300, children: _jsx(TestComponent, {}) }));
44
- };
45
- const WithSequence = () => {
46
- const SequenceFrom = 200;
47
- const FreezeFrame = 100;
48
- return (_jsx(WrapSequenceContext, { children: _jsx(Sequence, { from: SequenceFrom, layout: "none", children: _jsx(Freeze, { frame: FreezeFrame, children: _jsx(TestComponent, {}) }) }) }));
49
- };
50
- const TestComponent = () => {
51
- const frame = useCurrentFrame();
52
- return _jsx("div", { children: frame });
53
- };
54
- describe('Integration tests', () => {
55
- test('Basic test', () => {
56
- const { container } = renderForFrame(0, _jsx(Basic, {}));
57
- expect(container.innerHTML).toBe('<div>300</div>');
58
- });
59
- test('Should ignore a Sequence', () => {
60
- const { container } = renderForFrame(300, _jsx(WithSequence, {}));
61
- expect(container.innerHTML).toBe('<div>100</div>');
62
- });
63
- });
@@ -1,12 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { getAssetDisplayName } from '../get-asset-file-name.js';
3
- describe('get asset file name test', () => {
4
- const testStrings = [
5
- ['assets/images/sample.png', 'sample.png'],
6
- ['assets\\images\\sample.png', 'sample.png'],
7
- ['sample.png', 'sample.png'],
8
- ];
9
- testStrings.forEach((entry) => test(`test for ${entry[0]}`, () => {
10
- expect(getAssetDisplayName(entry[0])).toEqual(entry[1]);
11
- }));
12
- });
@@ -1,72 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { getMediaTime } from '../video/get-current-time.js';
3
- describe('correctly calculate media time of video element', () => {
4
- const mp4Precision = 0.04;
5
- const webmPrecision = 0.02;
6
- describe('src mp4', () => {
7
- test('mp4 - Should correctly calculate the media time of a video element', () => {
8
- expect(getMediaTime({
9
- fps: 30,
10
- frame: 30,
11
- playbackRate: 1,
12
- src: 'video.mp4',
13
- startFrom: 0,
14
- mediaType: 'video',
15
- })).toBeCloseTo(1, mp4Precision);
16
- });
17
- test('mp4 - Should correctly calculate the media time of a video element with faster framerate', () => {
18
- expect(getMediaTime({
19
- fps: 30,
20
- frame: 30,
21
- playbackRate: 2,
22
- src: 'video.mp4',
23
- startFrom: 0,
24
- mediaType: 'video',
25
- })).toBeCloseTo(2, mp4Precision);
26
- });
27
- test('mp4 - Should correctly calculate the media time of a video element with faster framerate and a startFrom', () => {
28
- // If playbackrate is 2, but the video only starts after 1 second, at 2sec, the video position should be 3sec
29
- expect(getMediaTime({
30
- fps: 30,
31
- frame: 60,
32
- playbackRate: 2,
33
- src: 'video.mp4',
34
- startFrom: 30,
35
- mediaType: 'video',
36
- })).toBeCloseTo(3, mp4Precision);
37
- });
38
- });
39
- describe('src webm', () => {
40
- test('webm - Should correctly calculate the media time of a video element', () => {
41
- expect(getMediaTime({
42
- fps: 30,
43
- frame: 30,
44
- playbackRate: 1,
45
- src: 'video.webm',
46
- startFrom: 0,
47
- mediaType: 'video',
48
- })).toBeCloseTo(1, webmPrecision);
49
- });
50
- test('webm - Should correctly calculate the media time of a video element with faster framerate', () => {
51
- expect(getMediaTime({
52
- fps: 30,
53
- frame: 30,
54
- playbackRate: 2,
55
- src: 'video.webm',
56
- startFrom: 0,
57
- mediaType: 'video',
58
- })).toBeCloseTo(2, webmPrecision);
59
- });
60
- test('webm - Should correctly calculate the media time of a video element with faster framerate and a startFrom', () => {
61
- // If playbackrate is 2, but the video only starts after 1 second, at 2sec, the video position should be 3sec
62
- expect(getMediaTime({
63
- fps: 30,
64
- frame: 60,
65
- playbackRate: 2,
66
- src: 'video.webm',
67
- startFrom: 30,
68
- mediaType: 'video',
69
- })).toBeCloseTo(3, webmPrecision);
70
- });
71
- });
72
- });
@@ -1,29 +0,0 @@
1
- /**
2
- * @vitest-environment jsdom
3
- */
4
- import { afterAll, beforeEach, describe, expect, test, vitest } from 'vitest';
5
- import { getInputProps } from '../config/input-props.js';
6
- describe('input props', () => {
7
- const OLD_ENV = process.env;
8
- beforeEach(() => {
9
- vitest.resetModules(); // Most important - it clears the cache
10
- process.env = { ...OLD_ENV }; // Make a copy
11
- });
12
- afterAll(() => {
13
- process.env = OLD_ENV; // Restore old environment
14
- });
15
- test('input props in non production env', () => {
16
- process.env.NODE_ENV = 'development';
17
- const inputProps = {
18
- firstProperty: 'firstProperty',
19
- secondProperty: 'secondProperty',
20
- };
21
- window.remotion_inputProps = JSON.stringify(JSON.stringify(inputProps));
22
- expect(getInputProps()).toEqual(JSON.stringify(inputProps));
23
- });
24
- test('input props in production env', () => {
25
- process.env.NODE_ENV = 'production';
26
- window.remotion_inputProps = JSON.stringify({});
27
- expect(getInputProps()).toEqual({});
28
- });
29
- });
@@ -1,136 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { Easing } from '../easing.js';
3
- import { interpolate } from '../interpolate.js';
4
- import { expectToThrow } from './expect-to-throw.js';
5
- describe('Basic interpolations', () => {
6
- test('Input and output range strictly monotonically increasing', () => {
7
- expect(interpolate(1, [0, 1], [0, 2])).toEqual(2);
8
- });
9
- test('Input range strictly monotonically increasing, Output range non-increasing', () => {
10
- expect(interpolate(1, [0, 1], [2, 2])).toEqual(2);
11
- });
12
- test('Interpolate with 4 values, output non-increasing', () => {
13
- expect(interpolate(Math.PI, [0, 1, 4, 9], [0, 2, 1000, -1000])).toEqual(714.4364894275378);
14
- });
15
- test('Interpolate Infinity: output range increasing', () => {
16
- expect(interpolate(Infinity, [0, 1], [0, 2])).toEqual(Infinity);
17
- });
18
- test('Interpolate Infinity: output range decreasing', () => {
19
- expect(interpolate(Infinity, [0, 1], [1, 0])).toEqual(-Infinity);
20
- });
21
- });
22
- test('Must be the same length', () => {
23
- expectToThrow(() => {
24
- interpolate(1, [0, 2], [0, 1, 2]);
25
- }, /inputRange \(2\) and outputRange \(3\) must have the same length/);
26
- });
27
- test('Must pass at least 2 elements for input range', () => {
28
- expectToThrow(() => {
29
- interpolate(1, [0], [9]);
30
- }, /inputRange must have at least 2 elements/);
31
- });
32
- test('Input range must be strictly monotonically non-decreasing', () => {
33
- expectToThrow(() => {
34
- interpolate(1, [0, 1, 0.5], [0, 2, 0.2]);
35
- }, /inputRange must be strictly monotonically non-decreasing/);
36
- expectToThrow(() => {
37
- interpolate(0.75, [0, 1, 1], [0, 2, 0]);
38
- }, /inputRange must be strictly monotonically non-decreasing/);
39
- });
40
- test('Output range can be non-monotonic', () => {
41
- expect(interpolate(0.75, [0, 0.5, 1], [0, 2, 0])).toEqual(1);
42
- });
43
- test('Output range monotonically decreasing', () => {
44
- expect(interpolate(0.75, [0, 0.5, 1], [0, 2, 2])).toEqual(2);
45
- });
46
- test('Cannot have Infinity in input range', () => {
47
- expectToThrow(() => {
48
- interpolate(1, [-Infinity, 0], [0, 2]);
49
- }, /inputRange must contain only finite numbers, but got \[-Infinity,0\]/);
50
- });
51
- test('Cannot have Infinity in output Range', () => {
52
- expectToThrow(() => interpolate(1, [0, 1], [Infinity, 2]), /outputRange must contain only finite numbers, but got \[Infinity,2\]/);
53
- });
54
- test('Should throw if passing 2x infinity input range', () => {
55
- expectToThrow(() => interpolate(1, [Infinity, Infinity], [0, 2]), /inputRange must contain only finite numbers, but got \[Infinity,Infinity\]/);
56
- });
57
- test('Should throw if passing 2x infinity output range', () => {
58
- expectToThrow(() => interpolate(1, [0, 1], [-Infinity, Infinity]), /outputRange must contain only finite numbers, but got \[-Infinity,Infinity\]/);
59
- });
60
- test('Should throw on Infinity as third argument', () => {
61
- expectToThrow(() => interpolate(1, [0, 1, Infinity], [0, 2, 3]), /inputRange must contain only finite numbers, but got \[0,1,Infinity\]/);
62
- });
63
- test('Should throw on Infinity as third argument', () => {
64
- expectToThrow(() => interpolate(1, [0, 1, Infinity], [0, 2, 3]), /inputRange must contain only finite numbers, but got \[0,1,Infinity\]/);
65
- });
66
- test('Easing test', () => {
67
- expect(interpolate(0.5, [0, 1], [0, 1], {
68
- easing: Easing.sin,
69
- })).toEqual(1 - Math.cos((0.5 * Math.PI) / 2));
70
- });
71
- test('Extrapolation left test', () => {
72
- const testValues = ['extend', undefined];
73
- testValues.forEach((entry) => {
74
- expect(interpolate(-3, [0, 1, 2], [0, 0.5, 1], {
75
- extrapolateRight: entry,
76
- })).toEqual(-1.5);
77
- });
78
- });
79
- test('Extrapolation right test', () => {
80
- const testValues = ['extend', undefined];
81
- testValues.forEach((entry) => {
82
- expect(interpolate(3, [0, 1, 2], [0, 0.5, 1], {
83
- extrapolateRight: entry,
84
- })).toEqual(1.5);
85
- });
86
- });
87
- test('Extrapolation identity', () => {
88
- const testValues = [
89
- [1000, { extrapolateRight: 'identity' }],
90
- [-1000, { extrapolateLeft: 'identity' }],
91
- ];
92
- testValues.forEach((entry) => {
93
- expect(interpolate(entry[0], [0, 1, 2], [0, 2, 4], entry[1])).toBe(entry[0]);
94
- });
95
- });
96
- test('Clamp right test', () => {
97
- expect(interpolate(2000, [0, 1, 1000], [0, 1, -1000], {
98
- extrapolateRight: 'clamp',
99
- })).toEqual(-1000);
100
- });
101
- test('Clamp left test', () => {
102
- expect(interpolate(-2000, [0, 1, 1000], [Math.PI, 1, -1000], {
103
- extrapolateLeft: 'clamp',
104
- })).toEqual(Math.PI);
105
- });
106
- test('Zig-zag test', () => {
107
- const testValues = [
108
- [3.5, -500],
109
- [4, -1000],
110
- [6, 3000],
111
- [-0.1, -1100],
112
- ];
113
- testValues.forEach((entry) => {
114
- expect(interpolate(entry[0], [1, 2, 3, 4, 5], [0, 1000, 0, -1000, 1000])).toBe(entry[1]);
115
- });
116
- });
117
- test('Handle bad types', () => {
118
- // @ts-expect-error
119
- expect(() => interpolate(undefined, [0, 1], [1, 0])).toThrowError(/input can not be undefined/);
120
- // @ts-expect-error
121
- expect(() => interpolate(1, undefined, [1, 0])).toThrowError(/inputRange can not be undefined/);
122
- // @ts-expect-error
123
- expect(() => interpolate(1, [1, 0], undefined)).toThrowError(/outputRange can not be undefined/);
124
- // @ts-expect-error
125
- expect(() => interpolate(1)).toThrowError(/inputRange can not be undefined/);
126
- // @ts-expect-error
127
- expect(() => interpolate('1', [0, 1], [1, 0])).toThrowError(/Cannot interpolate an input which is not a number/);
128
- // @ts-expect-error
129
- expect(() => interpolate(1, 'string', 'string')).toThrowError(/inputRange must contain only numbers/);
130
- // @ts-expect-error
131
- expect(() => interpolate(1, [1, 2, 3], 'str')).toThrowError(/outputRange must contain only numbers/);
132
- // @ts-expect-error
133
- expect(() => interpolate(1, undefined, 'string')).toThrowError(/inputRange can not be undefined/);
134
- // @ts-expect-error
135
- expect(() => interpolate([1, 2], undefined, 'string')).toThrowError(/inputRange can not be undefined/);
136
- });
@@ -1,61 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { interpolateColors } from '../interpolate-colors.js';
3
- import { expectToThrow } from './expect-to-throw.js';
4
- test('Throws if color string is not right', () => {
5
- expectToThrow(() => {
6
- interpolateColors(1, [0, 1], ['#fabgdf', '#ffaabb']);
7
- }, /invalid color string #fabgdf provided/);
8
- });
9
- describe('Throws error for undefined parameters', () => {
10
- test('Undefined input', () => {
11
- expectToThrow(() => {
12
- // @ts-expect-error
13
- interpolateColors(undefined, ['#aaa', '#bbb'], ['#fff', '#000']);
14
- }, /input can not be undefined/);
15
- });
16
- test('Undefined inputRange', () => {
17
- expectToThrow(() => {
18
- // @ts-expect-error
19
- interpolateColors(1, undefined, ['#fff', '#000']);
20
- }, /inputRange can not be undefined/);
21
- });
22
- test('Undefined outputRange', () => {
23
- expectToThrow(() => {
24
- // @ts-expect-error
25
- interpolateColors(1, ['#fff', '#000'], undefined);
26
- }, /outputRange can not be undefined/);
27
- });
28
- });
29
- test('inputRange and outputRange must be of same length', () => {
30
- expectToThrow(() => {
31
- interpolateColors(1, [1, 2, 3], ['#ffffff', '#aaaaaa']);
32
- }, /inputRange \(3 values provided\) and outputRange \(2 values provided\) must have the same length/);
33
- });
34
- test('Basic interpolate Colors', () => {
35
- expect(interpolateColors(1, [0, 1], ['#ffaadd', '#fabfdf'])).toBe('rgba(250, 191, 223, 1)');
36
- });
37
- test('Clamp Right', () => {
38
- expect(interpolateColors(2, [0, 1], ['#ffaadd', '#fabfdf'])).toBe('rgba(250, 191, 223, 1)');
39
- });
40
- test('Clamp Left', () => {
41
- expect(interpolateColors(-1, [0, 1], ['#ffaadd', '#fabfdf'])).toBe('rgba(255, 170, 221, 1)');
42
- });
43
- test('Color shorthands', () => {
44
- expect(interpolateColors(1, [0, 1], ['#fad', '#fabfdf'])).toBe('rgba(250, 191, 223, 1)');
45
- });
46
- test('Color names', () => {
47
- expect(interpolateColors(1, [0, 1], ['red', 'blue'])).toBe('rgba(0, 0, 255, 1)');
48
- });
49
- test('Mix transparency', () => {
50
- expect(interpolateColors(0.5, [0, 1], ['transparent', 'blue'])).toBe('rgba(0, 0, 128, 0.5)');
51
- });
52
- test('HSV', () => {
53
- expect(interpolateColors(0.5, [0, 1], ['hsla(120, 100%, 25%, 0)', 'blue'])).toBe('rgba(0, 64, 128, 0.5)');
54
- expect(interpolateColors(0.5, [0, 1], ['hsl(120, 50%, 50%)', 'blue'])).toBe('rgba(32, 96, 160, 1)');
55
- });
56
- describe('RGB', () => {
57
- test('standard rgb interpolation', () => expect(interpolateColors(0.5, [0, 1], ['rgb(0,0,0)', 'rgb(255,255,255)'])).toBe('rgba(128, 128, 128, 1)'));
58
- test('rgb clamping', () => {
59
- expect(interpolateColors(0.5, [0, 1], ['rgb(-1,0,0)', 'rgb(256,255,255)'])).toBe('rgba(128, 128, 128, 1)');
60
- });
61
- });
@@ -1,68 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * @vitest-environment jsdom
4
- */
5
- import { render } from '@testing-library/react';
6
- import React, { useContext } from 'react';
7
- import { describe, expect, test } from 'vitest';
8
- import { CanUseRemotionHooksProvider } from '../CanUseRemotionHooks.js';
9
- import { CompositionManager } from '../CompositionManager.js';
10
- import { Loop } from '../loop/index.js';
11
- import { RemotionRoot } from '../RemotionRoot.js';
12
- import { expectToThrow } from './expect-to-throw.js';
13
- const Wrapper = ({ children }) => {
14
- const compositions = useContext(CompositionManager);
15
- return (_jsx(CanUseRemotionHooksProvider, { children: _jsx(RemotionRoot, { numberOfAudioTags: 0, children: _jsx(CompositionManager.Provider
16
- // eslint-disable-next-line react/jsx-no-constructed-context-values
17
- , {
18
- // eslint-disable-next-line react/jsx-no-constructed-context-values
19
- value: {
20
- ...compositions,
21
- compositions: [
22
- {
23
- height: 1080,
24
- width: 1080,
25
- fps: 30,
26
- durationInFrames: 30,
27
- id: 'markup',
28
- nonce: 0,
29
- component: React.lazy(() => Promise.resolve({
30
- default: (() => null),
31
- })),
32
- defaultProps: undefined,
33
- folderName: null,
34
- parentFolderName: null,
35
- },
36
- ],
37
- currentComposition: 'markup',
38
- }, children: children }) }) }));
39
- };
40
- describe('Loop-validation render should throw with invalid props', () => {
41
- describe('Throw with invalid durationInFrames prop', () => {
42
- test('It should throw if Loop has non-number durationInFrames', () => {
43
- expectToThrow(() => render(_jsx(Wrapper, { children: _jsx(Loop, { durationInFrames: '1', children: "hi" }) })), /The "durationInFrames" prop of the <Loop \/> component must be a number, but you passed a value of type string/);
44
- });
45
- test('It should throw if Loop has non-integer durationInFrames', () => {
46
- expectToThrow(() => render(_jsx(Wrapper, { children: _jsx(Loop, { durationInFrames: 1.1, children: "hi" }) })), /The "durationInFrames" prop of the <Loop \/> component must be an integer, but got 1.1./);
47
- });
48
- test('It should throw if Loop has a negative duration', () => {
49
- expectToThrow(() => render(_jsx(Wrapper, { children: _jsx(Loop, { durationInFrames: -1, children: "hi" }) })), /The "durationInFrames" prop of the <Loop \/> component must be positive, but got -1./);
50
- });
51
- });
52
- describe('Throw with invalid times prop', () => {
53
- test('It should throw if Loop has non-number times', () => {
54
- expectToThrow(() => render(_jsx(Wrapper, { children: _jsx(Loop, { durationInFrames: 50, times: "1", children: "hi" }) })), /You passed to "times" an argument of type string, but it must be a number./);
55
- });
56
- test('It should throw if Loop has non-integer times', () => {
57
- expectToThrow(() => render(_jsx(Wrapper, { children: _jsx(Loop, { durationInFrames: 50, times: 1.1, children: "hi" }) })), /The "times" prop of a loop must be an integer, but got 1.1./);
58
- });
59
- });
60
- });
61
- describe('Should NOT throw with valid props', () => {
62
- test('It should allow null as children', () => {
63
- expect(() => render(_jsx(Wrapper, { children: _jsx(Loop, { durationInFrames: 50, children: null }) }))).not.toThrow();
64
- });
65
- test('It should allow undefined as children', () => {
66
- expect(() => render(_jsx(Wrapper, { children: _jsx(Loop, { durationInFrames: 50, children: undefined }) }))).not.toThrow();
67
- });
68
- });