@remotion/player 4.0.0-lambda.3 → 4.0.0-newpaths.1

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 (245) hide show
  1. package/LICENSE.md +8 -8
  2. package/README.md +1 -1
  3. package/dist/cjs/MediaVolumeSlider.d.ts +5 -0
  4. package/dist/cjs/MediaVolumeSlider.js +118 -0
  5. package/dist/cjs/Player.d.ts +43 -0
  6. package/dist/{Player.js → cjs/Player.js} +26 -70
  7. package/dist/cjs/PlayerControls.d.ts +41 -0
  8. package/dist/cjs/PlayerControls.js +152 -0
  9. package/dist/{PlayerSeekBar.d.ts → cjs/PlayerSeekBar.d.ts} +4 -0
  10. package/dist/{PlayerSeekBar.js → cjs/PlayerSeekBar.js} +35 -11
  11. package/dist/cjs/PlayerUI.d.ts +38 -0
  12. package/dist/{PlayerUI.js → cjs/PlayerUI.js} +118 -76
  13. package/dist/cjs/SharedPlayerContext.d.ts +14 -0
  14. package/dist/cjs/SharedPlayerContext.js +72 -0
  15. package/dist/cjs/Thumbnail.d.ts +20 -0
  16. package/dist/cjs/Thumbnail.js +42 -0
  17. package/dist/cjs/ThumbnailUI.d.ts +11 -0
  18. package/dist/cjs/ThumbnailUI.js +107 -0
  19. package/dist/{calculate-next-frame.d.ts → cjs/calculate-next-frame.d.ts} +0 -0
  20. package/dist/{calculate-next-frame.js → cjs/calculate-next-frame.js} +0 -0
  21. package/dist/cjs/calculate-scale.d.ts +39 -0
  22. package/dist/cjs/calculate-scale.js +85 -0
  23. package/dist/cjs/emitter-context.d.ts +4 -0
  24. package/dist/{emitter-context.js → cjs/emitter-context.js} +2 -1
  25. package/dist/{error-boundary.d.ts → cjs/error-boundary.d.ts} +0 -0
  26. package/dist/{error-boundary.js → cjs/error-boundary.js} +0 -0
  27. package/dist/cjs/event-emitter.d.ts +66 -0
  28. package/dist/{event-emitter.js → cjs/event-emitter.js} +33 -1
  29. package/dist/{format-time.d.ts → cjs/format-time.d.ts} +0 -0
  30. package/dist/{format-time.js → cjs/format-time.js} +0 -0
  31. package/dist/{icons.d.ts → cjs/icons.d.ts} +2 -1
  32. package/dist/{icons.js → cjs/icons.js} +7 -7
  33. package/dist/cjs/index.d.ts +61 -0
  34. package/dist/{index.js → cjs/index.js} +5 -2
  35. package/dist/{player-css-classname.d.ts → cjs/player-css-classname.d.ts} +0 -1
  36. package/dist/cjs/player-css-classname.js +4 -0
  37. package/dist/{player-methods.d.ts → cjs/player-methods.d.ts} +8 -4
  38. package/dist/{player-methods.js → cjs/player-methods.js} +0 -0
  39. package/dist/{test → cjs/test}/index.test.d.ts +0 -0
  40. package/dist/{test → cjs/test}/index.test.js +3 -2
  41. package/dist/{test → cjs/test}/test-utils.d.ts +2 -2
  42. package/dist/{test → cjs/test}/test-utils.js +0 -0
  43. package/dist/{test/validate-prop.test.d.ts → cjs/test/validate-in-out-frames.test.d.ts} +0 -0
  44. package/dist/cjs/test/validate-in-out-frames.test.js +56 -0
  45. package/dist/cjs/test/validate-prop.test.d.ts +1 -0
  46. package/dist/{test → cjs/test}/validate-prop.test.js +24 -23
  47. package/dist/{use-hover-state.d.ts → cjs/use-hover-state.d.ts} +0 -0
  48. package/dist/{use-hover-state.js → cjs/use-hover-state.js} +0 -0
  49. package/dist/cjs/use-playback.d.ts +7 -0
  50. package/dist/{use-playback.js → cjs/use-playback.js} +7 -3
  51. package/dist/{use-player.d.ts → cjs/use-player.d.ts} +8 -3
  52. package/dist/{use-player.js → cjs/use-player.js} +23 -4
  53. package/dist/cjs/use-thumbnail.d.ts +6 -0
  54. package/dist/cjs/use-thumbnail.js +18 -0
  55. package/dist/cjs/use-video-controls-resize.d.ts +7 -0
  56. package/dist/cjs/use-video-controls-resize.js +36 -0
  57. package/dist/{utils → cjs/utils}/calculate-player-size.d.ts +2 -2
  58. package/dist/{utils → cjs/utils}/calculate-player-size.js +0 -0
  59. package/dist/{utils → cjs/utils}/cancellable-promise.d.ts +0 -0
  60. package/dist/{utils → cjs/utils}/cancellable-promise.js +0 -0
  61. package/dist/{utils → cjs/utils}/delay.d.ts +0 -0
  62. package/dist/{utils → cjs/utils}/delay.js +0 -0
  63. package/dist/{utils → cjs/utils}/is-node.d.ts +0 -0
  64. package/dist/{utils → cjs/utils}/is-node.js +0 -0
  65. package/dist/cjs/utils/preview-size.d.ts +8 -0
  66. package/dist/{utils → cjs/utils}/preview-size.js +0 -0
  67. package/dist/cjs/utils/props-if-has-props.d.ts +5 -0
  68. package/dist/cjs/utils/props-if-has-props.js +2 -0
  69. package/dist/{utils → cjs/utils}/use-cancellable-promises.d.ts +1 -1
  70. package/dist/{utils → cjs/utils}/use-cancellable-promises.js +0 -0
  71. package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.d.ts +1 -1
  72. package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.js +0 -0
  73. package/dist/{utils → cjs/utils}/use-element-size.d.ts +5 -0
  74. package/dist/{utils → cjs/utils}/use-element-size.js +9 -1
  75. package/dist/cjs/utils/validate-in-out-frame.d.ts +6 -0
  76. package/dist/cjs/utils/validate-in-out-frame.js +54 -0
  77. package/dist/cjs/utils/validate-initial-frame.d.ts +4 -0
  78. package/dist/cjs/utils/validate-initial-frame.js +27 -0
  79. package/dist/{utils → cjs/utils}/validate-playbackrate.d.ts +0 -0
  80. package/dist/{utils → cjs/utils}/validate-playbackrate.js +0 -0
  81. package/dist/{volume-persistance.d.ts → cjs/volume-persistance.d.ts} +0 -0
  82. package/dist/{volume-persistance.js → cjs/volume-persistance.js} +0 -0
  83. package/dist/esm/MediaVolumeSlider.d.ts +5 -0
  84. package/dist/esm/MediaVolumeSlider.js +114 -0
  85. package/dist/esm/Player.d.ts +43 -0
  86. package/dist/esm/Player.js +136 -0
  87. package/dist/esm/PlayerControls.d.ts +41 -0
  88. package/dist/esm/PlayerControls.js +148 -0
  89. package/dist/esm/PlayerSeekBar.d.ts +8 -0
  90. package/dist/esm/PlayerSeekBar.js +142 -0
  91. package/dist/esm/PlayerUI.d.ts +38 -0
  92. package/dist/esm/PlayerUI.js +283 -0
  93. package/dist/esm/SharedPlayerContext.d.ts +14 -0
  94. package/dist/esm/SharedPlayerContext.js +68 -0
  95. package/dist/esm/Thumbnail.d.ts +20 -0
  96. package/dist/esm/Thumbnail.js +35 -0
  97. package/dist/esm/ThumbnailUI.d.ts +11 -0
  98. package/dist/esm/ThumbnailUI.js +82 -0
  99. package/dist/esm/calculate-next-frame.d.ts +14 -0
  100. package/dist/esm/calculate-next-frame.js +24 -0
  101. package/dist/esm/calculate-scale.d.ts +39 -0
  102. package/dist/esm/calculate-scale.js +77 -0
  103. package/dist/esm/emitter-context.d.ts +4 -0
  104. package/dist/esm/emitter-context.js +3 -0
  105. package/dist/esm/error-boundary.d.ts +19 -0
  106. package/dist/esm/error-boundary.js +32 -0
  107. package/dist/esm/event-emitter.d.ts +66 -0
  108. package/dist/esm/event-emitter.js +82 -0
  109. package/dist/esm/format-time.d.ts +1 -0
  110. package/dist/esm/format-time.js +5 -0
  111. package/dist/esm/icons.d.ts +10 -0
  112. package/dist/esm/icons.js +42 -0
  113. package/dist/esm/index.d.ts +61 -0
  114. package/dist/esm/index.js +20 -0
  115. package/dist/esm/player-css-classname.d.ts +1 -0
  116. package/dist/esm/player-css-classname.js +1 -0
  117. package/dist/esm/player-methods.d.ts +24 -0
  118. package/dist/esm/player-methods.js +1 -0
  119. package/dist/esm/test/index.test.d.ts +1 -0
  120. package/dist/esm/test/index.test.js +7 -0
  121. package/dist/esm/test/test-utils.d.ts +6 -0
  122. package/dist/esm/test/test-utils.js +14 -0
  123. package/dist/esm/test/validate-in-out-frames.test.d.ts +1 -0
  124. package/dist/esm/test/validate-in-out-frames.test.js +54 -0
  125. package/dist/esm/test/validate-prop.test.d.ts +1 -0
  126. package/dist/esm/test/validate-prop.test.js +129 -0
  127. package/dist/esm/use-hover-state.d.ts +1 -0
  128. package/dist/esm/use-hover-state.js +23 -0
  129. package/dist/esm/use-playback.d.ts +7 -0
  130. package/dist/esm/use-playback.js +88 -0
  131. package/dist/esm/use-player.d.ts +19 -0
  132. package/dist/esm/use-player.js +128 -0
  133. package/dist/esm/use-thumbnail.d.ts +6 -0
  134. package/dist/esm/use-thumbnail.js +14 -0
  135. package/dist/esm/use-video-controls-resize.d.ts +7 -0
  136. package/dist/esm/use-video-controls-resize.js +32 -0
  137. package/dist/esm/utils/calculate-player-size.d.ts +9 -0
  138. package/dist/esm/utils/calculate-player-size.js +25 -0
  139. package/dist/esm/utils/cancellable-promise.d.ts +5 -0
  140. package/dist/esm/utils/cancellable-promise.js +22 -0
  141. package/dist/esm/utils/delay.d.ts +1 -0
  142. package/dist/esm/utils/delay.js +2 -0
  143. package/dist/esm/utils/is-node.d.ts +1 -0
  144. package/dist/esm/utils/is-node.js +1 -0
  145. package/dist/esm/utils/preview-size.d.ts +8 -0
  146. package/dist/esm/utils/preview-size.js +1 -0
  147. package/dist/esm/utils/props-if-has-props.d.ts +5 -0
  148. package/dist/esm/utils/props-if-has-props.js +1 -0
  149. package/dist/esm/utils/use-cancellable-promises.d.ts +7 -0
  150. package/dist/esm/utils/use-cancellable-promises.js +18 -0
  151. package/dist/esm/utils/use-click-prevention-on-double-click.d.ts +3 -0
  152. package/dist/esm/utils/use-click-prevention-on-double-click.js +42 -0
  153. package/dist/esm/utils/use-element-size.d.ts +16 -0
  154. package/dist/esm/utils/use-element-size.js +93 -0
  155. package/dist/esm/utils/validate-in-out-frame.d.ts +6 -0
  156. package/dist/esm/utils/validate-in-out-frame.js +49 -0
  157. package/dist/esm/utils/validate-initial-frame.d.ts +4 -0
  158. package/dist/esm/utils/validate-initial-frame.js +23 -0
  159. package/dist/esm/utils/validate-playbackrate.d.ts +1 -0
  160. package/dist/esm/utils/validate-playbackrate.js +14 -0
  161. package/dist/esm/volume-persistance.d.ts +2 -0
  162. package/dist/esm/volume-persistance.js +14 -0
  163. package/dist/tsconfig-cjs.tsbuildinfo +1 -0
  164. package/dist/tsconfig.tsbuildinfo +1 -0
  165. package/package.json +26 -17
  166. package/dist/MediaVolumeSlider.d.ts +0 -2
  167. package/dist/MediaVolumeSlider.d.ts.map +0 -1
  168. package/dist/MediaVolumeSlider.js +0 -93
  169. package/dist/MediaVolumeSlider.js.map +0 -1
  170. package/dist/Player.d.ts +0 -38
  171. package/dist/Player.d.ts.map +0 -1
  172. package/dist/Player.js.map +0 -1
  173. package/dist/PlayerControls.d.ts +0 -14
  174. package/dist/PlayerControls.d.ts.map +0 -1
  175. package/dist/PlayerControls.js +0 -87
  176. package/dist/PlayerControls.js.map +0 -1
  177. package/dist/PlayerSeekBar.d.ts.map +0 -1
  178. package/dist/PlayerSeekBar.js.map +0 -1
  179. package/dist/PlayerUI.d.ts +0 -29
  180. package/dist/PlayerUI.d.ts.map +0 -1
  181. package/dist/PlayerUI.js.map +0 -1
  182. package/dist/calculate-next-frame.d.ts.map +0 -1
  183. package/dist/calculate-next-frame.js.map +0 -1
  184. package/dist/calculate-scale.d.ts +0 -14
  185. package/dist/calculate-scale.d.ts.map +0 -1
  186. package/dist/calculate-scale.js +0 -24
  187. package/dist/calculate-scale.js.map +0 -1
  188. package/dist/emitter-context.d.ts +0 -3
  189. package/dist/emitter-context.d.ts.map +0 -1
  190. package/dist/emitter-context.js.map +0 -1
  191. package/dist/error-boundary.d.ts.map +0 -1
  192. package/dist/error-boundary.js.map +0 -1
  193. package/dist/event-emitter.d.ts +0 -42
  194. package/dist/event-emitter.d.ts.map +0 -1
  195. package/dist/event-emitter.js.map +0 -1
  196. package/dist/format-time.d.ts.map +0 -1
  197. package/dist/format-time.js.map +0 -1
  198. package/dist/icons.d.ts.map +0 -1
  199. package/dist/icons.js.map +0 -1
  200. package/dist/index.d.ts +0 -45
  201. package/dist/index.d.ts.map +0 -1
  202. package/dist/index.js.map +0 -1
  203. package/dist/player-css-classname.d.ts.map +0 -1
  204. package/dist/player-css-classname.js +0 -5
  205. package/dist/player-css-classname.js.map +0 -1
  206. package/dist/player-methods.d.ts.map +0 -1
  207. package/dist/player-methods.js.map +0 -1
  208. package/dist/test/index.test.d.ts.map +0 -1
  209. package/dist/test/index.test.js.map +0 -1
  210. package/dist/test/test-utils.d.ts.map +0 -1
  211. package/dist/test/test-utils.js.map +0 -1
  212. package/dist/test/validate-prop.test.d.ts.map +0 -1
  213. package/dist/test/validate-prop.test.js.map +0 -1
  214. package/dist/use-hover-state.d.ts.map +0 -1
  215. package/dist/use-hover-state.js.map +0 -1
  216. package/dist/use-playback.d.ts +0 -4
  217. package/dist/use-playback.d.ts.map +0 -1
  218. package/dist/use-playback.js.map +0 -1
  219. package/dist/use-player.d.ts.map +0 -1
  220. package/dist/use-player.js.map +0 -1
  221. package/dist/utils/browser-supports-fullscreen.d.ts +0 -11
  222. package/dist/utils/browser-supports-fullscreen.d.ts.map +0 -1
  223. package/dist/utils/browser-supports-fullscreen.js +0 -5
  224. package/dist/utils/browser-supports-fullscreen.js.map +0 -1
  225. package/dist/utils/calculate-player-size.d.ts.map +0 -1
  226. package/dist/utils/calculate-player-size.js.map +0 -1
  227. package/dist/utils/cancellable-promise.d.ts.map +0 -1
  228. package/dist/utils/cancellable-promise.js.map +0 -1
  229. package/dist/utils/delay.d.ts.map +0 -1
  230. package/dist/utils/delay.js.map +0 -1
  231. package/dist/utils/is-node.d.ts.map +0 -1
  232. package/dist/utils/is-node.js.map +0 -1
  233. package/dist/utils/preview-size.d.ts +0 -1
  234. package/dist/utils/preview-size.d.ts.map +0 -1
  235. package/dist/utils/preview-size.js.map +0 -1
  236. package/dist/utils/use-cancellable-promises.d.ts.map +0 -1
  237. package/dist/utils/use-cancellable-promises.js.map +0 -1
  238. package/dist/utils/use-click-prevention-on-double-click.d.ts.map +0 -1
  239. package/dist/utils/use-click-prevention-on-double-click.js.map +0 -1
  240. package/dist/utils/use-element-size.d.ts.map +0 -1
  241. package/dist/utils/use-element-size.js.map +0 -1
  242. package/dist/utils/validate-playbackrate.d.ts.map +0 -1
  243. package/dist/utils/validate-playbackrate.js.map +0 -1
  244. package/dist/volume-persistance.d.ts.map +0 -1
  245. package/dist/volume-persistance.js.map +0 -1
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const remotion_1 = require("remotion");
5
+ const vitest_1 = require("vitest");
5
6
  const index_1 = require("../index");
6
7
  const test_utils_1 = require("./test-utils");
7
- test('no compositionWidth should give errors', () => {
8
+ (0, vitest_1.test)('no compositionWidth should give errors', () => {
8
9
  try {
9
10
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player
10
11
  // @ts-expect-error
@@ -13,27 +14,27 @@ test('no compositionWidth should give errors', () => {
13
14
  compositionWidth: null, errorFallback: () => 'something went wrong', compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
14
15
  }
15
16
  catch (e) {
16
- expect(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
17
+ (0, vitest_1.expect)(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
17
18
  }
18
19
  });
19
- test('no compositionHeight should give errors', () => {
20
+ (0, vitest_1.test)('no compositionHeight should give errors', () => {
20
21
  try {
21
22
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 400, errorFallback: () => 'something went wrong',
22
23
  // @ts-expect-error
23
24
  compositionHeight: undefined, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
24
25
  }
25
26
  catch (e) {
26
- expect(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
27
+ (0, vitest_1.expect)(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
27
28
  }
28
29
  });
29
- test('No fps should give errors', () => {
30
+ (0, vitest_1.test)('No fps should give errors', () => {
30
31
  try {
31
32
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
32
33
  // @ts-expect-error
33
34
  fps: null, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
34
35
  }
35
36
  catch (e) {
36
- expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
37
+ (0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
37
38
  }
38
39
  try {
39
40
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
@@ -41,51 +42,51 @@ test('No fps should give errors', () => {
41
42
  fps: undefined, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
42
43
  }
43
44
  catch (e) {
44
- expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
45
+ (0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
45
46
  }
46
47
  });
47
- test('No durationInFrames should give errors', () => {
48
+ (0, vitest_1.test)('No durationInFrames should give errors', () => {
48
49
  try {
49
50
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30,
50
51
  // @ts-expect-error
51
52
  durationInFrames: undefined, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
52
53
  }
53
54
  catch (e) {
54
- expect(e.message).toMatch(/The "durationInFrames" prop of the <Player\/> component must be a number, but you passed a value of type undefined/);
55
+ (0, vitest_1.expect)(e.message).toMatch(/durationInFrames` must be a number, but is undefined/);
55
56
  }
56
57
  });
57
- test('Invalid playbackRate should give error', () => {
58
+ (0, vitest_1.test)('Invalid playbackRate should give error', () => {
58
59
  try {
59
60
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: -5 }));
60
61
  }
61
62
  catch (e) {
62
- expect(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
63
+ (0, vitest_1.expect)(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
63
64
  }
64
65
  });
65
- test('playbackRate of 0 should not be possible', () => {
66
+ (0, vitest_1.test)('playbackRate of 0 should not be possible', () => {
66
67
  try {
67
68
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: 0 }));
68
69
  }
69
70
  catch (e) {
70
- expect(e.message).toMatch(/A playback rate of 0 is not supported./);
71
+ (0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
71
72
  }
72
73
  });
73
- test('playbackRate of wrong type should not be possible', () => {
74
+ (0, vitest_1.test)('playbackRate of wrong type should not be possible', () => {
74
75
  try {
75
76
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true,
76
77
  // @ts-expect-error
77
78
  playbackRate: 'hi' }));
78
79
  }
79
80
  catch (e) {
80
- expect(e.message).toMatch(/A playback rate of 0 is not supported./);
81
+ (0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
81
82
  }
82
83
  });
83
- test('playbackRate of undefined should be okay', () => {
84
+ (0, vitest_1.test)('playbackRate of undefined should be okay', () => {
84
85
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
85
- expect(true).toBe(true);
86
+ (0, vitest_1.expect)(true).toBe(true);
86
87
  });
87
- test('passing in <Composition /> instance should not be possible', () => {
88
- expect(() => {
88
+ (0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
89
+ (0, vitest_1.expect)(() => {
89
90
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: remotion_1.Composition, controls: true, showVolumeControls: true, inputProps: {
90
91
  id: 'HelloWorld',
91
92
  width: 500,
@@ -96,8 +97,8 @@ test('passing in <Composition /> instance should not be possible', () => {
96
97
  } }));
97
98
  }).toThrow(/'component' must not be the 'Composition' component\. Pass your own React/);
98
99
  });
99
- test('passing in <Composition /> instance should not be possible', () => {
100
- expect(() => {
100
+ (0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
101
+ (0, vitest_1.expect)(() => {
101
102
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500,
102
103
  // @ts-expect-error
103
104
  component: (0, jsx_runtime_1.jsx)(remotion_1.Composition, { durationInFrames: 30, fps: 30, height: 10, width: 10, id: "hello", component: test_utils_1.HelloWorld }), controls: true, showVolumeControls: true, inputProps: {
@@ -110,7 +111,7 @@ test('passing in <Composition /> instance should not be possible', () => {
110
111
  } }));
111
112
  }).toThrow(/'component' should not be an instance of <Composition\/>\. Pass the React component dir/);
112
113
  });
113
- test.each([
114
+ vitest_1.test.each([
114
115
  ['controls'],
115
116
  ['loop'],
116
117
  ['autoPlay'],
@@ -125,6 +126,6 @@ test.each([
125
126
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30, durationInFrames: 100, component: test_utils_1.HelloWorld, ...props }));
126
127
  }
127
128
  catch (e) {
128
- expect(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
129
+ (0, vitest_1.expect)(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
129
130
  }
130
131
  });
@@ -0,0 +1,7 @@
1
+ export declare const usePlayback: ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }: {
2
+ loop: boolean;
3
+ playbackRate: number;
4
+ moveToBeginningWhenEnded: boolean;
5
+ inFrame: number | null;
6
+ outFrame: number | null;
7
+ }) => void;
@@ -5,12 +5,11 @@ const react_1 = require("react");
5
5
  const remotion_1 = require("remotion");
6
6
  const calculate_next_frame_1 = require("./calculate-next-frame");
7
7
  const use_player_1 = require("./use-player");
8
- const usePlayback = ({ loop, playbackRate, }) => {
8
+ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }) => {
9
9
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
10
10
  const config = remotion_1.Internals.useUnsafeVideoConfig();
11
11
  const { playing, pause, emitter } = (0, use_player_1.usePlayer)();
12
12
  const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
13
- const { inFrame, outFrame } = remotion_1.Internals.Timeline.useTimelineInOutFramePosition();
14
13
  const frameRef = (0, react_1.useRef)(frame);
15
14
  frameRef.current = frame;
16
15
  const lastTimeUpdateEvent = (0, react_1.useRef)(null);
@@ -46,7 +45,8 @@ const usePlayback = ({ loop, playbackRate, }) => {
46
45
  shouldLoop: loop,
47
46
  });
48
47
  framesAdvanced += framesToAdvance;
49
- if (nextFrame !== frameRef.current) {
48
+ if (nextFrame !== frameRef.current &&
49
+ (!hasEnded || moveToBeginningWhenEnded)) {
50
50
  setFrame(nextFrame);
51
51
  }
52
52
  if (hasEnded) {
@@ -73,6 +73,7 @@ const usePlayback = ({ loop, playbackRate, }) => {
73
73
  playbackRate,
74
74
  inFrame,
75
75
  outFrame,
76
+ moveToBeginningWhenEnded,
76
77
  ]);
77
78
  (0, react_1.useEffect)(() => {
78
79
  const interval = setInterval(() => {
@@ -84,5 +85,8 @@ const usePlayback = ({ loop, playbackRate, }) => {
84
85
  }, 250);
85
86
  return () => clearInterval(interval);
86
87
  }, [emitter]);
88
+ (0, react_1.useEffect)(() => {
89
+ emitter.dispatchFrameUpdate({ frame });
90
+ }, [emitter, frame]);
87
91
  };
88
92
  exports.usePlayback = usePlayback;
@@ -1,14 +1,19 @@
1
- import { SyntheticEvent } from 'react';
2
- import { PlayerEmitter } from './event-emitter';
3
- export declare const usePlayer: () => {
1
+ import type { SyntheticEvent } from 'react';
2
+ import type { PlayerEmitter } from './event-emitter';
3
+ declare type UsePlayerMethods = {
4
4
  frameBack: (frames: number) => void;
5
5
  frameForward: (frames: number) => void;
6
6
  isLastFrame: boolean;
7
+ isFirstFrame: boolean;
7
8
  emitter: PlayerEmitter;
8
9
  playing: boolean;
9
10
  play: (e?: SyntheticEvent) => void;
10
11
  pause: () => void;
12
+ pauseAndReturnToPlayStart: () => void;
11
13
  seek: (newFrame: number) => void;
12
14
  getCurrentFrame: () => number;
13
15
  isPlaying: () => boolean;
16
+ hasPlayed: boolean;
14
17
  };
18
+ export declare const usePlayer: () => UsePlayerMethods;
19
+ export {};
@@ -7,7 +7,9 @@ const emitter_context_1 = require("./emitter-context");
7
7
  const usePlayer = () => {
8
8
  var _a;
9
9
  const [playing, setPlaying, imperativePlaying] = remotion_1.Internals.Timeline.usePlayingState();
10
+ const [hasPlayed, setHasPlayed] = (0, react_1.useState)(false);
10
11
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
12
+ const playStart = (0, react_1.useRef)(frame);
11
13
  const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
12
14
  const setTimelinePosition = remotion_1.Internals.Timeline.useTimelineSetFrame();
13
15
  const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
@@ -19,6 +21,7 @@ const usePlayer = () => {
19
21
  const emitter = (0, react_1.useContext)(emitter_context_1.PlayerEventEmitterContext);
20
22
  const lastFrame = ((_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
21
23
  const isLastFrame = frame === lastFrame;
24
+ const isFirstFrame = frame === 0;
22
25
  if (!emitter) {
23
26
  throw new TypeError('Expected Player event emitter context');
24
27
  }
@@ -30,6 +33,7 @@ const usePlayer = () => {
30
33
  if (imperativePlaying.current) {
31
34
  return;
32
35
  }
36
+ setHasPlayed(true);
33
37
  if (isLastFrame) {
34
38
  seek(0);
35
39
  }
@@ -46,6 +50,7 @@ const usePlayer = () => {
46
50
  audioAndVideoTags.current.forEach((a) => a.play());
47
51
  imperativePlaying.current = true;
48
52
  setPlaying(true);
53
+ playStart.current = frameRef.current;
49
54
  emitter.dispatchPlay();
50
55
  }, [
51
56
  imperativePlaying,
@@ -63,6 +68,14 @@ const usePlayer = () => {
63
68
  emitter.dispatchPause();
64
69
  }
65
70
  }, [emitter, imperativePlaying, setPlaying]);
71
+ const pauseAndReturnToPlayStart = (0, react_1.useCallback)(() => {
72
+ if (imperativePlaying.current) {
73
+ imperativePlaying.current = false;
74
+ setTimelinePosition(playStart.current);
75
+ setPlaying(false);
76
+ emitter.dispatchPause();
77
+ }
78
+ }, [emitter, imperativePlaying, setPlaying, setTimelinePosition]);
66
79
  const hasVideo = Boolean(video);
67
80
  const frameBack = (0, react_1.useCallback)((frames) => {
68
81
  if (!hasVideo) {
@@ -94,19 +107,25 @@ const usePlayer = () => {
94
107
  play,
95
108
  pause,
96
109
  seek,
110
+ isFirstFrame,
97
111
  getCurrentFrame: () => frameRef.current,
98
112
  isPlaying: () => imperativePlaying.current,
113
+ pauseAndReturnToPlayStart,
114
+ hasPlayed,
99
115
  };
100
116
  }, [
101
- emitter,
102
117
  frameBack,
103
118
  frameForward,
104
- imperativePlaying,
105
119
  isLastFrame,
106
- pause,
107
- play,
120
+ emitter,
108
121
  playing,
122
+ play,
123
+ pause,
109
124
  seek,
125
+ isFirstFrame,
126
+ pauseAndReturnToPlayStart,
127
+ imperativePlaying,
128
+ hasPlayed,
110
129
  ]);
111
130
  return returnValue;
112
131
  };
@@ -0,0 +1,6 @@
1
+ import type { ThumbnailEmitter } from './event-emitter';
2
+ declare type UseThumbnailMethods = {
3
+ emitter: ThumbnailEmitter;
4
+ };
5
+ export declare const useThumbnail: () => UseThumbnailMethods;
6
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useThumbnail = void 0;
4
+ const react_1 = require("react");
5
+ const emitter_context_1 = require("./emitter-context");
6
+ const useThumbnail = () => {
7
+ const emitter = (0, react_1.useContext)(emitter_context_1.ThumbnailEmitterContext);
8
+ if (!emitter) {
9
+ throw new TypeError('Expected Player event emitter context');
10
+ }
11
+ const returnValue = (0, react_1.useMemo)(() => {
12
+ return {
13
+ emitter,
14
+ };
15
+ }, [emitter]);
16
+ return returnValue;
17
+ };
18
+ exports.useThumbnail = useThumbnail;
@@ -0,0 +1,7 @@
1
+ export declare const useVideoControlsResize: ({ allowFullscreen: allowFullScreen, playerWidth, }: {
2
+ allowFullscreen: boolean;
3
+ playerWidth: number;
4
+ }) => {
5
+ maxTimeLabelWidth: number;
6
+ displayVerticalVolumeSlider: boolean;
7
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useVideoControlsResize = void 0;
4
+ const react_1 = require("react");
5
+ const icons_1 = require("./icons");
6
+ const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
7
+ const PlayerControls_1 = require("./PlayerControls");
8
+ const useVideoControlsResize = ({ allowFullscreen: allowFullScreen, playerWidth, }) => {
9
+ const resizeInfo = (0, react_1.useMemo)(() => {
10
+ const playPauseIconSize = icons_1.ICON_SIZE;
11
+ const volumeIconSize = icons_1.ICON_SIZE;
12
+ const _fullscreenIconSize = allowFullScreen ? icons_1.fullscreenIconSize : 0;
13
+ const elementsSize = volumeIconSize +
14
+ playPauseIconSize +
15
+ _fullscreenIconSize +
16
+ PlayerControls_1.X_PADDING * 2 +
17
+ PlayerControls_1.X_SPACER * 2;
18
+ const maxTimeLabelWidth = playerWidth - elementsSize;
19
+ const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
20
+ const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH;
21
+ // If max label width is lower than the volume width
22
+ // then it means we need to take it's width as the max label width
23
+ // otherwise we took the available width when volume open
24
+ const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen < MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH
25
+ ? maxTimeLabelWidthWithoutNegativeValue
26
+ : availableTimeLabelWidthIfVolumeOpen;
27
+ const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize + MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH;
28
+ const displayVerticalVolumeSlider = playerWidth < minWidthForHorizontalDisplay;
29
+ return {
30
+ maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue,
31
+ displayVerticalVolumeSlider,
32
+ };
33
+ }, [allowFullScreen, playerWidth]);
34
+ return resizeInfo;
35
+ };
36
+ exports.useVideoControlsResize = useVideoControlsResize;
@@ -1,5 +1,5 @@
1
- import { StandardLonghandProperties } from 'csstype';
2
- import { Size } from './use-element-size';
1
+ import type { StandardLonghandProperties } from 'csstype';
2
+ import type { Size } from './use-element-size';
3
3
  export declare const calculatePlayerSize: ({ currentSize, width, height, compositionWidth, compositionHeight, }: {
4
4
  currentSize: Size | null;
5
5
  width: StandardLonghandProperties['width'] | undefined;
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ export declare type Translation = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ export declare type PreviewSize = {
6
+ size: number | 'auto';
7
+ translation: Translation;
8
+ };
File without changes
@@ -0,0 +1,5 @@
1
+ export declare type PropsIfHasProps<Props> = {} extends Props ? {
2
+ inputProps?: Props;
3
+ } : {
4
+ inputProps: Props;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { CancellablePromise } from './cancellable-promise';
1
+ import type { CancellablePromise } from './cancellable-promise';
2
2
  declare const useCancellablePromises: () => {
3
3
  appendPendingPromise: (promise: CancellablePromise) => void;
4
4
  removePendingPromise: (promise: CancellablePromise) => void;
@@ -1,3 +1,3 @@
1
- import { SyntheticEvent } from 'react';
1
+ import type { SyntheticEvent } from 'react';
2
2
  declare const useClickPreventionOnDoubleClick: (onClick: (e: SyntheticEvent) => void, onDoubleClick: () => void, doubleClickToFullscreen: boolean) => [(e: SyntheticEvent) => void, () => void];
3
3
  export { useClickPreventionOnDoubleClick };
@@ -3,6 +3,11 @@ export declare type Size = {
3
3
  height: number;
4
4
  left: number;
5
5
  top: number;
6
+ windowSize: {
7
+ width: number;
8
+ height: number;
9
+ };
10
+ refresh: () => void;
6
11
  };
7
12
  export declare const updateAllElementsSizes: () => void;
8
13
  export declare const useElementSize: (ref: React.RefObject<HTMLElement>, options: {
@@ -36,6 +36,10 @@ const useElementSize = (ref, options) => {
36
36
  height,
37
37
  left: newSize[0].x,
38
38
  top: newSize[0].y,
39
+ windowSize: {
40
+ height: window.innerHeight,
41
+ width: window.innerWidth,
42
+ },
39
43
  });
40
44
  });
41
45
  }, [options.shouldApplyCssTransforms]);
@@ -53,6 +57,10 @@ const useElementSize = (ref, options) => {
53
57
  height: rect[0].height,
54
58
  left: rect[0].x,
55
59
  top: rect[0].y,
60
+ windowSize: {
61
+ height: window.innerHeight,
62
+ width: window.innerWidth,
63
+ },
56
64
  });
57
65
  }, [ref]);
58
66
  (0, react_1.useEffect)(() => {
@@ -85,6 +93,6 @@ const useElementSize = (ref, options) => {
85
93
  elementSizeHooks = elementSizeHooks.filter((e) => e !== updateSize);
86
94
  };
87
95
  }, [updateSize]);
88
- return size;
96
+ return size ? { ...size, refresh: updateSize } : null;
89
97
  };
90
98
  exports.useElementSize = useElementSize;
@@ -0,0 +1,6 @@
1
+ export declare const validateSingleFrame: (frame: unknown, variableName: string) => number | null;
2
+ export declare const validateInOutFrames: ({ inFrame, durationInFrames, outFrame, }: {
3
+ inFrame: unknown;
4
+ outFrame: unknown;
5
+ durationInFrames: number;
6
+ }) => void;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateInOutFrames = exports.validateSingleFrame = void 0;
4
+ const validateSingleFrame = (frame, variableName) => {
5
+ if (typeof frame === 'undefined' || frame === null) {
6
+ return frame !== null && frame !== void 0 ? frame : null;
7
+ }
8
+ if (typeof frame !== 'number') {
9
+ throw new TypeError(`"${variableName}" must be a number, but is ${JSON.stringify(frame)}`);
10
+ }
11
+ if (Number.isNaN(frame)) {
12
+ throw new TypeError(`"${variableName}" must not be NaN, but is ${JSON.stringify(frame)}`);
13
+ }
14
+ if (!Number.isFinite(frame)) {
15
+ throw new TypeError(`"${variableName}" must be finite, but is ${JSON.stringify(frame)}`);
16
+ }
17
+ if (frame % 1 !== 0) {
18
+ throw new TypeError(`"${variableName}" must be an integer, but is ${JSON.stringify(frame)}`);
19
+ }
20
+ return frame;
21
+ };
22
+ exports.validateSingleFrame = validateSingleFrame;
23
+ const validateInOutFrames = ({ inFrame, durationInFrames, outFrame, }) => {
24
+ const validatedInFrame = (0, exports.validateSingleFrame)(inFrame, 'inFrame');
25
+ const validatedOutFrame = (0, exports.validateSingleFrame)(outFrame, 'outFrame');
26
+ if (validatedInFrame === null && validatedOutFrame === null) {
27
+ return;
28
+ }
29
+ // Must not be over the duration
30
+ if (validatedInFrame !== null && validatedInFrame > durationInFrames - 1) {
31
+ throw new Error('inFrame must be less than (durationInFrames - 1), but is ' +
32
+ validatedInFrame);
33
+ }
34
+ if (validatedOutFrame !== null && validatedOutFrame > durationInFrames - 1) {
35
+ throw new Error('outFrame must be less than (durationInFrames - 1), but is ' +
36
+ validatedOutFrame);
37
+ }
38
+ // Must not be under 0
39
+ if (validatedInFrame !== null && validatedInFrame < 0) {
40
+ throw new Error('inFrame must be greater than 0, but is ' + validatedInFrame);
41
+ }
42
+ if (validatedOutFrame !== null && validatedOutFrame <= 0) {
43
+ throw new Error(`outFrame must be greater than 0, but is ${validatedOutFrame}. If you want to render a single frame, use <Thumbnail /> instead.`);
44
+ }
45
+ if (validatedOutFrame !== null &&
46
+ validatedInFrame !== null &&
47
+ validatedOutFrame <= validatedInFrame) {
48
+ throw new Error('outFrame must be greater than inFrame, but is ' +
49
+ validatedOutFrame +
50
+ ' <= ' +
51
+ validatedInFrame);
52
+ }
53
+ };
54
+ exports.validateInOutFrames = validateInOutFrames;
@@ -0,0 +1,4 @@
1
+ export declare const validateInitialFrame: ({ initialFrame, durationInFrames, }: {
2
+ initialFrame: unknown;
3
+ durationInFrames: unknown;
4
+ }) => void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateInitialFrame = void 0;
4
+ const validateInitialFrame = ({ initialFrame, durationInFrames, }) => {
5
+ if (typeof durationInFrames !== 'number') {
6
+ throw new Error(`\`durationInFrames\` must be a number, but is ${JSON.stringify(durationInFrames)}`);
7
+ }
8
+ if (typeof initialFrame === 'undefined') {
9
+ return;
10
+ }
11
+ if (typeof initialFrame !== 'number') {
12
+ throw new Error(`\`initialFrame\` must be a number, but is ${JSON.stringify(initialFrame)}`);
13
+ }
14
+ if (Number.isNaN(initialFrame)) {
15
+ throw new Error(`\`initialFrame\` must be a number, but is NaN`);
16
+ }
17
+ if (!Number.isFinite(initialFrame)) {
18
+ throw new Error(`\`initialFrame\` must be a number, but is Infinity`);
19
+ }
20
+ if (initialFrame % 1 !== 0) {
21
+ throw new Error(`\`initialFrame\` must be an integer, but is ${JSON.stringify(initialFrame)}`);
22
+ }
23
+ if (initialFrame > durationInFrames - 1) {
24
+ throw new Error(`\`initialFrame\` must be less or equal than \`durationInFrames - 1\`, but is ${JSON.stringify(initialFrame)}`);
25
+ }
26
+ };
27
+ exports.validateInitialFrame = validateInitialFrame;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const VOLUME_SLIDER_WIDTH = 100;
3
+ export declare const MediaVolumeSlider: React.FC<{
4
+ displayVerticalVolumeSlider: Boolean;
5
+ }>;