remotion 4.0.0-webhook.27 → 4.1.0-alpha1

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 (283) hide show
  1. package/LICENSE.md +8 -8
  2. package/README.md +7 -7
  3. package/dist/{AbsoluteFill.d.ts → cjs/AbsoluteFill.d.ts} +2 -2
  4. package/dist/{AbsoluteFill.js → cjs/AbsoluteFill.js} +2 -2
  5. package/dist/cjs/AssetManager.d.ts +11 -0
  6. package/dist/cjs/AssetManager.js +40 -0
  7. package/dist/{CanUseRemotionHooks.d.ts → cjs/CanUseRemotionHooks.d.ts} +0 -0
  8. package/dist/{CanUseRemotionHooks.js → cjs/CanUseRemotionHooks.js} +0 -0
  9. package/dist/cjs/Clipper.d.ts +7 -0
  10. package/dist/cjs/Clipper.js +24 -0
  11. package/dist/cjs/Composition.d.ts +41 -0
  12. package/dist/cjs/Composition.js +132 -0
  13. package/dist/cjs/CompositionManager.d.ts +75 -0
  14. package/dist/{CompositionManager.js → cjs/CompositionManager.js} +29 -66
  15. package/dist/cjs/CompositionManagerContext.d.ts +18 -0
  16. package/dist/cjs/CompositionManagerContext.js +16 -0
  17. package/dist/cjs/EditorProps.d.ts +15 -0
  18. package/dist/cjs/EditorProps.js +53 -0
  19. package/dist/{Folder.d.ts → cjs/Folder.d.ts} +6 -2
  20. package/dist/{Folder.js → cjs/Folder.js} +10 -6
  21. package/dist/{IFrame.d.ts → cjs/IFrame.d.ts} +4 -0
  22. package/dist/{IFrame.js → cjs/IFrame.js} +8 -4
  23. package/dist/cjs/Img.d.ts +9 -0
  24. package/dist/cjs/Img.js +100 -0
  25. package/dist/cjs/NativeLayers.d.ts +13 -0
  26. package/dist/cjs/NativeLayers.js +29 -0
  27. package/dist/cjs/Null.d.ts +2 -0
  28. package/dist/cjs/Null.js +25 -0
  29. package/dist/{RemotionRoot.d.ts → cjs/RemotionRoot.d.ts} +1 -0
  30. package/dist/cjs/RemotionRoot.js +72 -0
  31. package/dist/cjs/ResolveCompositionConfig.d.ts +24 -0
  32. package/dist/cjs/ResolveCompositionConfig.js +192 -0
  33. package/dist/cjs/Sequence.d.ts +22 -0
  34. package/dist/{Sequence.js → cjs/Sequence.js} +27 -29
  35. package/dist/cjs/SequenceContext.d.ts +9 -0
  36. package/dist/cjs/SequenceContext.js +5 -0
  37. package/dist/cjs/SequenceManager.d.ts +11 -0
  38. package/dist/cjs/SequenceManager.js +57 -0
  39. package/dist/cjs/Still.d.ts +8 -0
  40. package/dist/cjs/Still.js +22 -0
  41. package/dist/{absolute-src.d.ts → cjs/absolute-src.d.ts} +0 -0
  42. package/dist/{absolute-src.js → cjs/absolute-src.js} +0 -0
  43. package/dist/{asset-types.d.ts → cjs/asset-types.d.ts} +0 -0
  44. package/dist/{asset-types.js → cjs/asset-types.js} +0 -0
  45. package/dist/{audio → cjs/audio}/Audio.d.ts +10 -4
  46. package/dist/cjs/audio/Audio.js +58 -0
  47. package/dist/cjs/audio/AudioForDevelopment.d.ts +11 -0
  48. package/dist/cjs/audio/AudioForDevelopment.js +101 -0
  49. package/dist/cjs/audio/AudioForRendering.d.ts +10 -0
  50. package/dist/cjs/audio/AudioForRendering.js +111 -0
  51. package/dist/cjs/audio/index.d.ts +2 -0
  52. package/dist/{audio → cjs/audio}/index.js +2 -2
  53. package/dist/cjs/audio/props.d.ts +12 -0
  54. package/dist/{audio → cjs/audio}/props.js +0 -0
  55. package/dist/{audio → cjs/audio}/shared-audio-tags.d.ts +10 -4
  56. package/dist/{audio → cjs/audio}/shared-audio-tags.js +35 -13
  57. package/dist/{audio → cjs/audio}/use-audio-frame.d.ts +0 -0
  58. package/dist/{audio → cjs/audio}/use-audio-frame.js +4 -4
  59. package/dist/{bezier.d.ts → cjs/bezier.d.ts} +0 -0
  60. package/dist/{bezier.js → cjs/bezier.js} +0 -0
  61. package/dist/cjs/cancel-render.d.ts +5 -0
  62. package/dist/cjs/cancel-render.js +47 -0
  63. package/dist/{config → cjs/config}/input-props.d.ts +0 -0
  64. package/dist/{config → cjs/config}/input-props.js +3 -3
  65. package/dist/{default-css.d.ts → cjs/default-css.d.ts} +0 -0
  66. package/dist/{default-css.js → cjs/default-css.js} +0 -0
  67. package/dist/{delay-render.d.ts → cjs/delay-render.d.ts} +4 -4
  68. package/dist/{delay-render.js → cjs/delay-render.js} +12 -12
  69. package/dist/{easing.d.ts → cjs/easing.d.ts} +4 -0
  70. package/dist/{easing.js → cjs/easing.js} +6 -2
  71. package/dist/cjs/freeze.d.ts +11 -0
  72. package/dist/{freeze.js → cjs/freeze.js} +8 -4
  73. package/dist/{get-asset-file-name.d.ts → cjs/get-asset-file-name.d.ts} +0 -0
  74. package/dist/{get-asset-file-name.js → cjs/get-asset-file-name.js} +0 -0
  75. package/dist/cjs/get-environment.d.ts +3 -0
  76. package/dist/{get-environment.js → cjs/get-environment.js} +14 -2
  77. package/dist/cjs/get-preview-dom-element.d.ts +2 -0
  78. package/dist/cjs/get-preview-dom-element.js +8 -0
  79. package/dist/cjs/get-static-files.d.ts +21 -0
  80. package/dist/cjs/get-static-files.js +35 -0
  81. package/dist/{get-timeline-clip-name.d.ts → cjs/get-timeline-clip-name.d.ts} +0 -0
  82. package/dist/{get-timeline-clip-name.js → cjs/get-timeline-clip-name.js} +0 -0
  83. package/dist/cjs/index.d.ts +102 -0
  84. package/dist/cjs/index.js +105 -0
  85. package/dist/cjs/internals.d.ts +131 -0
  86. package/dist/cjs/internals.js +120 -0
  87. package/dist/{interpolate-colors.d.ts → cjs/interpolate-colors.d.ts} +5 -0
  88. package/dist/{interpolate-colors.js → cjs/interpolate-colors.js} +10 -10
  89. package/dist/{interpolate.d.ts → cjs/interpolate.d.ts} +11 -7
  90. package/dist/{interpolate.js → cjs/interpolate.js} +0 -0
  91. package/dist/{is-approximately-the-same.d.ts → cjs/is-approximately-the-same.d.ts} +0 -0
  92. package/dist/{is-approximately-the-same.js → cjs/is-approximately-the-same.js} +0 -0
  93. package/dist/cjs/is-player.d.ts +3 -0
  94. package/dist/cjs/is-player.js +14 -0
  95. package/dist/{loading-indicator.d.ts → cjs/loading-indicator.d.ts} +0 -0
  96. package/dist/{loading-indicator.js → cjs/loading-indicator.js} +4 -4
  97. package/dist/cjs/loop/index.d.ts +13 -0
  98. package/dist/cjs/loop/index.js +46 -0
  99. package/dist/{multiple-versions-warning.d.ts → cjs/multiple-versions-warning.d.ts} +0 -0
  100. package/dist/{multiple-versions-warning.js → cjs/multiple-versions-warning.js} +11 -6
  101. package/dist/{nonce.d.ts → cjs/nonce.d.ts} +1 -1
  102. package/dist/{nonce.js → cjs/nonce.js} +6 -0
  103. package/dist/{play-and-handle-not-allowed-error.d.ts → cjs/play-and-handle-not-allowed-error.d.ts} +0 -0
  104. package/dist/{play-and-handle-not-allowed-error.js → cjs/play-and-handle-not-allowed-error.js} +4 -0
  105. package/dist/{portal-node.d.ts → cjs/portal-node.d.ts} +0 -0
  106. package/dist/{portal-node.js → cjs/portal-node.js} +0 -0
  107. package/dist/cjs/prefetch-state.d.ts +8 -0
  108. package/dist/cjs/prefetch-state.js +27 -0
  109. package/dist/cjs/prefetch.d.ts +13 -0
  110. package/dist/{prefetch.js → cjs/prefetch.js} +43 -17
  111. package/dist/cjs/props-if-has-props.d.ts +10 -0
  112. package/dist/{video-config.js → cjs/props-if-has-props.js} +0 -0
  113. package/dist/cjs/random.d.ts +6 -0
  114. package/dist/{random.js → cjs/random.js} +3 -3
  115. package/dist/{register-root.d.ts → cjs/register-root.d.ts} +4 -0
  116. package/dist/{register-root.js → cjs/register-root.js} +4 -0
  117. package/dist/cjs/resolve-video-config.d.ts +8 -0
  118. package/dist/cjs/resolve-video-config.js +89 -0
  119. package/dist/cjs/series/flatten-children.d.ts +2 -0
  120. package/dist/{series → cjs/series}/flatten-children.js +0 -0
  121. package/dist/cjs/series/index.d.ts +17 -0
  122. package/dist/{series → cjs/series}/index.js +22 -8
  123. package/dist/cjs/setup-env-variables.d.ts +1 -0
  124. package/dist/{setup-env-variables.js → cjs/setup-env-variables.js} +7 -9
  125. package/dist/{spring → cjs/spring}/index.d.ts +10 -6
  126. package/dist/cjs/spring/index.js +75 -0
  127. package/dist/cjs/spring/measure-spring.d.ts +12 -0
  128. package/dist/{spring → cjs/spring}/measure-spring.js +8 -4
  129. package/dist/{spring → cjs/spring}/spring-utils.d.ts +2 -2
  130. package/dist/{spring → cjs/spring}/spring-utils.js +0 -0
  131. package/dist/cjs/static-file.d.ts +33 -0
  132. package/dist/cjs/static-file.js +87 -0
  133. package/dist/{timeline-position-state.d.ts → cjs/timeline-position-state.d.ts} +4 -4
  134. package/dist/{timeline-position-state.js → cjs/timeline-position-state.js} +9 -1
  135. package/dist/cjs/truthy.d.ts +3 -0
  136. package/dist/{truthy.js → cjs/truthy.js} +0 -0
  137. package/dist/cjs/use-current-frame.d.ts +5 -0
  138. package/dist/{use-current-frame.js → cjs/use-current-frame.js} +8 -9
  139. package/dist/cjs/use-lazy-component.d.ts +7 -0
  140. package/dist/{use-lazy-component.js → cjs/use-lazy-component.js} +0 -0
  141. package/dist/{use-media-in-timeline.d.ts → cjs/use-media-in-timeline.d.ts} +3 -2
  142. package/dist/{use-media-in-timeline.js → cjs/use-media-in-timeline.js} +29 -25
  143. package/dist/{use-media-playback.d.ts → cjs/use-media-playback.d.ts} +3 -1
  144. package/dist/cjs/use-media-playback.js +86 -0
  145. package/dist/{use-media-tag-volume.d.ts → cjs/use-media-tag-volume.d.ts} +0 -0
  146. package/dist/{use-media-tag-volume.js → cjs/use-media-tag-volume.js} +0 -0
  147. package/dist/{use-sync-volume-with-media-tag.d.ts → cjs/use-sync-volume-with-media-tag.d.ts} +2 -2
  148. package/dist/{use-sync-volume-with-media-tag.js → cjs/use-sync-volume-with-media-tag.js} +5 -4
  149. package/dist/{use-unsafe-video-config.d.ts → cjs/use-unsafe-video-config.d.ts} +1 -1
  150. package/dist/{use-unsafe-video-config.js → cjs/use-unsafe-video-config.js} +4 -4
  151. package/dist/cjs/use-video-config.d.ts +8 -0
  152. package/dist/cjs/use-video-config.js +34 -0
  153. package/dist/cjs/use-video.d.ts +7 -0
  154. package/dist/cjs/use-video.js +38 -0
  155. package/dist/cjs/validate-frame.d.ts +5 -0
  156. package/dist/cjs/validate-frame.js +24 -0
  157. package/dist/cjs/validate-media-props.d.ts +4 -0
  158. package/dist/{validate-media-props.js → cjs/validate-media-props.js} +0 -0
  159. package/dist/{validate-start-from-props.d.ts → cjs/validate-start-from-props.d.ts} +0 -0
  160. package/dist/{validate-start-from-props.js → cjs/validate-start-from-props.js} +0 -0
  161. package/dist/{validation → cjs/validation}/validate-composition-id.d.ts +0 -0
  162. package/dist/{validation → cjs/validation}/validate-composition-id.js +0 -0
  163. package/dist/cjs/validation/validate-default-props.d.ts +1 -0
  164. package/dist/cjs/validation/validate-default-props.js +15 -0
  165. package/dist/{validation → cjs/validation}/validate-dimensions.d.ts +0 -0
  166. package/dist/{validation → cjs/validation}/validate-dimensions.js +0 -0
  167. package/dist/cjs/validation/validate-duration-in-frames.d.ts +5 -0
  168. package/dist/{validation → cjs/validation}/validate-duration-in-frames.js +5 -2
  169. package/dist/{validation → cjs/validation}/validate-folder-name.d.ts +0 -0
  170. package/dist/{validation → cjs/validation}/validate-folder-name.js +0 -0
  171. package/dist/{validation → cjs/validation}/validate-fps.d.ts +0 -0
  172. package/dist/{validation → cjs/validation}/validate-fps.js +0 -0
  173. package/dist/{validation → cjs/validation}/validation-spring-duration.d.ts +0 -0
  174. package/dist/{validation → cjs/validation}/validation-spring-duration.js +0 -0
  175. package/dist/cjs/version.d.ts +1 -0
  176. package/dist/{version.js → cjs/version.js} +1 -1
  177. package/dist/cjs/video/OffthreadVideo.d.ts +7 -0
  178. package/dist/cjs/video/OffthreadVideo.js +38 -0
  179. package/dist/{video → cjs/video}/OffthreadVideoForRendering.d.ts +1 -1
  180. package/dist/cjs/video/OffthreadVideoForRendering.js +103 -0
  181. package/dist/cjs/video/Video.d.ts +12 -0
  182. package/dist/cjs/video/Video.js +55 -0
  183. package/dist/{video → cjs/video}/VideoForDevelopment.d.ts +5 -2
  184. package/dist/cjs/video/VideoForDevelopment.js +117 -0
  185. package/dist/cjs/video/VideoForRendering.d.ts +10 -0
  186. package/dist/cjs/video/VideoForRendering.js +208 -0
  187. package/dist/cjs/video/duration-state.d.ts +17 -0
  188. package/dist/cjs/video/duration-state.js +35 -0
  189. package/dist/{video → cjs/video}/get-current-time.d.ts +0 -0
  190. package/dist/{video → cjs/video}/get-current-time.js +12 -11
  191. package/dist/cjs/video/index.d.ts +3 -0
  192. package/dist/{video → cjs/video}/index.js +4 -4
  193. package/dist/cjs/video/props.d.ts +32 -0
  194. package/dist/cjs/video/props.js +2 -0
  195. package/dist/cjs/video/video-fragment.d.ts +12 -0
  196. package/dist/cjs/video/video-fragment.js +60 -0
  197. package/dist/{video-config.d.ts → cjs/video-config.d.ts} +2 -2
  198. package/dist/{video/props.js → cjs/video-config.js} +0 -0
  199. package/dist/{volume-position-state.d.ts → cjs/volume-position-state.d.ts} +4 -4
  200. package/dist/{volume-position-state.js → cjs/volume-position-state.js} +0 -0
  201. package/dist/{volume-prop.d.ts → cjs/volume-prop.d.ts} +3 -2
  202. package/dist/{volume-prop.js → cjs/volume-prop.js} +4 -3
  203. package/dist/{warn-about-non-seekable-media.d.ts → cjs/warn-about-non-seekable-media.d.ts} +0 -0
  204. package/dist/{warn-about-non-seekable-media.js → cjs/warn-about-non-seekable-media.js} +2 -2
  205. package/dist/cjs/wrap-remotion-context.d.ts +31 -0
  206. package/dist/cjs/wrap-remotion-context.js +85 -0
  207. package/dist/esm/index.mjs +4623 -0
  208. package/dist/esm/version.mjs +4 -0
  209. package/package.json +80 -57
  210. package/version.js +2 -1
  211. package/.prettierrc.js +0 -14
  212. package/.turbo/turbo-build.log +0 -5
  213. package/dist/Composition.d.ts +0 -22
  214. package/dist/Composition.js +0 -98
  215. package/dist/CompositionManager.d.ts +0 -79
  216. package/dist/Img.d.ts +0 -2
  217. package/dist/Img.js +0 -51
  218. package/dist/RemotionRoot.js +0 -71
  219. package/dist/Sequence.d.ts +0 -29
  220. package/dist/Still.d.ts +0 -3
  221. package/dist/Still.js +0 -9
  222. package/dist/audio/Audio.js +0 -32
  223. package/dist/audio/AudioForDevelopment.d.ts +0 -8
  224. package/dist/audio/AudioForDevelopment.js +0 -71
  225. package/dist/audio/AudioForRendering.d.ts +0 -6
  226. package/dist/audio/AudioForRendering.js +0 -75
  227. package/dist/audio/index.d.ts +0 -2
  228. package/dist/audio/props.d.ts +0 -10
  229. package/dist/config.d.ts +0 -218
  230. package/dist/config.js +0 -21
  231. package/dist/freeze.d.ts +0 -7
  232. package/dist/get-environment.d.ts +0 -2
  233. package/dist/get-preview-dom-element.d.ts +0 -1
  234. package/dist/get-preview-dom-element.js +0 -7
  235. package/dist/index.d.ts +0 -72
  236. package/dist/index.js +0 -58
  237. package/dist/internals.d.ts +0 -88
  238. package/dist/internals.js +0 -93
  239. package/dist/loop/index.d.ts +0 -9
  240. package/dist/loop/index.js +0 -28
  241. package/dist/prefetch-state.d.ts +0 -13
  242. package/dist/prefetch-state.js +0 -26
  243. package/dist/prefetch.d.ts +0 -7
  244. package/dist/random.d.ts +0 -6
  245. package/dist/series/flatten-children.d.ts +0 -2
  246. package/dist/series/index.d.ts +0 -13
  247. package/dist/setup-env-variables.d.ts +0 -2
  248. package/dist/spring/index.js +0 -51
  249. package/dist/spring/measure-spring.d.ts +0 -8
  250. package/dist/static-file.d.ts +0 -1
  251. package/dist/static-file.js +0 -29
  252. package/dist/truthy.d.ts +0 -3
  253. package/dist/use-current-frame.d.ts +0 -6
  254. package/dist/use-lazy-component.d.ts +0 -7
  255. package/dist/use-media-playback.js +0 -75
  256. package/dist/use-video-config.d.ts +0 -7
  257. package/dist/use-video-config.js +0 -26
  258. package/dist/use-video.d.ts +0 -13
  259. package/dist/use-video.js +0 -28
  260. package/dist/validate-media-props.d.ts +0 -4
  261. package/dist/validation/validate-duration-in-frames.d.ts +0 -1
  262. package/dist/validation/validate-offthreadvideo-image-format.d.ts +0 -1
  263. package/dist/validation/validate-offthreadvideo-image-format.js +0 -15
  264. package/dist/version.d.ts +0 -1
  265. package/dist/video/LoopedVideo.d.ts +0 -3
  266. package/dist/video/LoopedVideo.js +0 -16
  267. package/dist/video/OffthreadVideo.d.ts +0 -3
  268. package/dist/video/OffthreadVideo.js +0 -27
  269. package/dist/video/OffthreadVideoForRendering.js +0 -101
  270. package/dist/video/Video.d.ts +0 -6
  271. package/dist/video/Video.js +0 -29
  272. package/dist/video/VideoForDevelopment.js +0 -69
  273. package/dist/video/VideoForRendering.d.ts +0 -6
  274. package/dist/video/VideoForRendering.js +0 -168
  275. package/dist/video/duration-state.d.ts +0 -8
  276. package/dist/video/duration-state.js +0 -15
  277. package/dist/video/index.d.ts +0 -3
  278. package/dist/video/props.d.ts +0 -21
  279. package/dist/wrap-remotion-context.d.ts +0 -14
  280. package/dist/wrap-remotion-context.js +0 -65
  281. package/ensure-correct-version.js +0 -24
  282. package/tsconfig.json +0 -12
  283. package/version.d.ts +0 -1
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.measureSpring = exports.spring = void 0;
4
+ const validate_frame_js_1 = require("../validate-frame.js");
5
+ const validate_fps_js_1 = require("../validation/validate-fps.js");
6
+ const validation_spring_duration_js_1 = require("../validation/validation-spring-duration.js");
7
+ const measure_spring_js_1 = require("./measure-spring.js");
8
+ const spring_utils_js_1 = require("./spring-utils.js");
9
+ /**
10
+ * @description Calculates a position based on physical parameters, start and end value, and time.
11
+ * @see [Documentation](https://www.remotion.dev/docs/spring)
12
+ * @param {number} frame The current time value. Most of the time you want to pass in the return value of useCurrentFrame.
13
+ * @param {number} fps The framerate at which the animation runs. Pass in the value obtained by `useVideoConfig()`.
14
+ * @param {?boolean} reverse Whether the animation plays in reverse or not. Default `false`.
15
+ * @param {?Object} config optional object that allows you to customize the physical properties of the animation.
16
+ * @param {number} [config.mass=1] The weight of the spring. If you reduce the mass, the animation becomes faster!
17
+ * @param {number} [config.damping=10] How hard the animation decelerates.
18
+ * @param {number} [config.stiffness=100] Affects bounciness of the animation.
19
+ * @param {boolean} [config.overshootClamping=false] Whether to prevent the animation going beyond the target value.
20
+ * @param {?number} [config.from] The initial value of the animation. Default `0`
21
+ * @param {?number} [config.to] The end value of the animation. Default `1`
22
+ * @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
23
+ * @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
24
+ * @param {?number} [config.delay] Delay the animation for this amount of frames. Default `0`
25
+ */
26
+ function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durationInFrames: passedDurationInFrames, durationRestThreshold, delay = 0, reverse = false, }) {
27
+ (0, validation_spring_duration_js_1.validateSpringDuration)(passedDurationInFrames);
28
+ (0, validate_frame_js_1.validateFrame)({
29
+ frame: passedFrame,
30
+ durationInFrames: Infinity,
31
+ allowFloats: true,
32
+ });
33
+ (0, validate_fps_js_1.validateFps)(fps, 'to spring()', false);
34
+ const needsToCalculateNaturalDuration = reverse || typeof passedDurationInFrames !== 'undefined';
35
+ const naturalDuration = needsToCalculateNaturalDuration
36
+ ? (0, measure_spring_js_1.measureSpring)({
37
+ fps,
38
+ config,
39
+ from,
40
+ to,
41
+ threshold: durationRestThreshold,
42
+ })
43
+ : undefined;
44
+ const naturalDurationGetter = needsToCalculateNaturalDuration
45
+ ? {
46
+ get: () => naturalDuration,
47
+ }
48
+ : {
49
+ get: () => {
50
+ throw new Error('did not calculate natural duration, this is an error with Remotion. Please report');
51
+ },
52
+ };
53
+ const frame = (reverse
54
+ ? (passedDurationInFrames !== null && passedDurationInFrames !== void 0 ? passedDurationInFrames : naturalDurationGetter.get()) - passedFrame
55
+ : passedFrame) - delay;
56
+ const spr = (0, spring_utils_js_1.springCalculation)({
57
+ fps,
58
+ frame: passedDurationInFrames === undefined
59
+ ? frame
60
+ : frame / (passedDurationInFrames / naturalDurationGetter.get()),
61
+ config,
62
+ from,
63
+ to,
64
+ });
65
+ if (!config.overshootClamping) {
66
+ return spr.current;
67
+ }
68
+ if (to >= from) {
69
+ return Math.min(spr.current, to);
70
+ }
71
+ return Math.max(spr.current, to);
72
+ }
73
+ exports.spring = spring;
74
+ var measure_spring_js_2 = require("./measure-spring.js");
75
+ Object.defineProperty(exports, "measureSpring", { enumerable: true, get: function () { return measure_spring_js_2.measureSpring; } });
@@ -0,0 +1,12 @@
1
+ import type { SpringConfig } from './spring-utils.js';
2
+ /**
3
+ * @description The function returns how long it takes for a spring animation to settle
4
+ * @see [Documentation](https://www.remotion.dev/docs/measure-spring)
5
+ */
6
+ export declare function measureSpring({ fps, config, threshold, from, to, }: {
7
+ fps: number;
8
+ config?: Partial<SpringConfig>;
9
+ threshold?: number;
10
+ from?: number;
11
+ to?: number;
12
+ }): number;
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.measureSpring = void 0;
4
- const validate_fps_1 = require("../validation/validate-fps");
5
- const spring_utils_1 = require("./spring-utils");
4
+ const validate_fps_js_1 = require("../validation/validate-fps.js");
5
+ const spring_utils_js_1 = require("./spring-utils.js");
6
+ /**
7
+ * @description The function returns how long it takes for a spring animation to settle
8
+ * @see [Documentation](https://www.remotion.dev/docs/measure-spring)
9
+ */
6
10
  function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1, }) {
7
11
  if (typeof threshold !== 'number') {
8
12
  throw new TypeError(`threshold must be a number, got ${threshold} of type ${typeof threshold}`);
@@ -22,12 +26,12 @@ function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1,
22
26
  if (threshold < 0) {
23
27
  throw new TypeError('Threshold is below 0');
24
28
  }
25
- (0, validate_fps_1.validateFps)(fps, 'to the measureSpring() function', false);
29
+ (0, validate_fps_js_1.validateFps)(fps, 'to the measureSpring() function', false);
26
30
  const range = Math.abs(from - to);
27
31
  let frame = 0;
28
32
  let finishedFrame = 0;
29
33
  const calc = () => {
30
- return (0, spring_utils_1.springCalculation)({
34
+ return (0, spring_utils_js_1.springCalculation)({
31
35
  fps,
32
36
  frame,
33
37
  config,
@@ -1,11 +1,11 @@
1
- declare type AnimationNode = {
1
+ type AnimationNode = {
2
2
  lastTimestamp: number;
3
3
  toValue: number;
4
4
  current: number;
5
5
  velocity: number;
6
6
  prevPosition?: number;
7
7
  };
8
- export declare type SpringConfig = {
8
+ export type SpringConfig = {
9
9
  damping: number;
10
10
  mass: number;
11
11
  stiffness: number;
File without changes
@@ -0,0 +1,33 @@
1
+ declare const problematicCharacters: {
2
+ '%3A': string;
3
+ '%2F': string;
4
+ '%3F': string;
5
+ '%23': string;
6
+ '%5B': string;
7
+ '%5D': string;
8
+ '%40': string;
9
+ '%21': string;
10
+ '%24': string;
11
+ '%26': string;
12
+ '%27': string;
13
+ '%28': string;
14
+ '%29': string;
15
+ '%2A': string;
16
+ '%2B': string;
17
+ '%2C': string;
18
+ '%3B': string;
19
+ };
20
+ type HexCode = keyof typeof problematicCharacters;
21
+ export type HexInfo = {
22
+ containsHex: false;
23
+ } | {
24
+ containsHex: true;
25
+ hexCode: HexCode;
26
+ };
27
+ export declare const includesHexOfUnsafeChar: (path: string) => HexInfo;
28
+ /**
29
+ * @description Reference a file from the public/ folder. If the file does not appear in the autocomplete, type the path manually.
30
+ * @see [Documentation](https://www.remotion.dev/docs/staticfile)
31
+ */
32
+ export declare const staticFile: (path: string) => string;
33
+ export {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.staticFile = exports.includesHexOfUnsafeChar = void 0;
4
+ const problematicCharacters = {
5
+ '%3A': ':',
6
+ '%2F': '/',
7
+ '%3F': '?',
8
+ '%23': '#',
9
+ '%5B': '[',
10
+ '%5D': ']',
11
+ '%40': '@',
12
+ '%21': '!',
13
+ '%24': '$',
14
+ '%26': '&',
15
+ '%27': "'",
16
+ '%28': '(',
17
+ '%29': ')',
18
+ '%2A': '*',
19
+ '%2B': '+',
20
+ '%2C': ',',
21
+ '%3B': ';',
22
+ };
23
+ const didWarn = {};
24
+ const warnOnce = (message) => {
25
+ if (didWarn[message]) {
26
+ return;
27
+ }
28
+ console.warn(message);
29
+ didWarn[message] = true;
30
+ };
31
+ const includesHexOfUnsafeChar = (path) => {
32
+ for (const key of Object.keys(problematicCharacters)) {
33
+ if (path.includes(key)) {
34
+ return { containsHex: true, hexCode: key };
35
+ }
36
+ }
37
+ return { containsHex: false };
38
+ };
39
+ exports.includesHexOfUnsafeChar = includesHexOfUnsafeChar;
40
+ const trimLeadingSlash = (path) => {
41
+ if (path.startsWith('/')) {
42
+ return trimLeadingSlash(path.substring(1));
43
+ }
44
+ return path;
45
+ };
46
+ const inner = (path) => {
47
+ if (typeof window !== 'undefined' && window.remotion_staticBase) {
48
+ return `${window.remotion_staticBase}/${trimLeadingSlash(path)}`;
49
+ }
50
+ return `/${trimLeadingSlash(path)}`;
51
+ };
52
+ /**
53
+ * @description Reference a file from the public/ folder. If the file does not appear in the autocomplete, type the path manually.
54
+ * @see [Documentation](https://www.remotion.dev/docs/staticfile)
55
+ */
56
+ const staticFile = (path) => {
57
+ if (path.startsWith('http://') || path.startsWith('https://')) {
58
+ throw new TypeError(`staticFile() does not support remote URLs - got "${path}". Instead, pass the URL without wrapping it in staticFile(). See: https://remotion.dev/docs/staticfile-remote-urls`);
59
+ }
60
+ if (path.startsWith('..') || path.startsWith('./')) {
61
+ throw new TypeError(`staticFile() does not support relative paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
62
+ }
63
+ if (path.startsWith('/Users') ||
64
+ path.startsWith('/home') ||
65
+ path.startsWith('/tmp') ||
66
+ path.startsWith('/etc') ||
67
+ path.startsWith('/opt') ||
68
+ path.startsWith('/var') ||
69
+ path.startsWith('C:') ||
70
+ path.startsWith('D:') ||
71
+ path.startsWith('E:')) {
72
+ throw new TypeError(`staticFile() does not support absolute paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
73
+ }
74
+ if (path.startsWith('public/')) {
75
+ throw new TypeError(`Do not include the public/ prefix when using staticFile() - got "${path}". See: https://remotion.dev/docs/staticfile-relative-paths`);
76
+ }
77
+ const includesHex = (0, exports.includesHexOfUnsafeChar)(path);
78
+ if (includesHex.containsHex) {
79
+ warnOnce(`WARNING: You seem to pass an already encoded path (path contains ${includesHex.hexCode}). The encoding gets automatically handled by staticFile() `);
80
+ }
81
+ const preparsed = inner(encodeURIComponent(path));
82
+ if (!preparsed.startsWith('/')) {
83
+ return `/${preparsed}`;
84
+ }
85
+ return preparsed;
86
+ };
87
+ exports.staticFile = staticFile;
@@ -1,9 +1,9 @@
1
1
  import type { MutableRefObject } from 'react';
2
- export declare type PlayableMediaTag = {
2
+ export type PlayableMediaTag = {
3
3
  play: () => void;
4
4
  id: string;
5
5
  };
6
- export declare type TimelineContextValue = {
6
+ export type TimelineContextValue = {
7
7
  frame: number;
8
8
  playing: boolean;
9
9
  rootId: string;
@@ -12,7 +12,7 @@ export declare type TimelineContextValue = {
12
12
  setPlaybackRate: (u: React.SetStateAction<number>) => void;
13
13
  audioAndVideoTags: MutableRefObject<PlayableMediaTag[]>;
14
14
  };
15
- export declare type SetTimelineContextValue = {
15
+ export type SetTimelineContextValue = {
16
16
  setFrame: (u: React.SetStateAction<number>) => void;
17
17
  setPlaying: (u: React.SetStateAction<boolean>) => void;
18
18
  };
@@ -20,7 +20,7 @@ export declare const TimelineContext: import("react").Context<TimelineContextVal
20
20
  export declare const SetTimelineContext: import("react").Context<SetTimelineContextValue>;
21
21
  export declare const useTimelinePosition: () => number;
22
22
  export declare const useTimelineSetFrame: () => (u: React.SetStateAction<number>) => void;
23
- declare type PlayingReturnType = readonly [
23
+ type PlayingReturnType = readonly [
24
24
  boolean,
25
25
  (u: React.SetStateAction<boolean>) => void,
26
26
  MutableRefObject<boolean>
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.SetTimelineContext = exports.TimelineContext = void 0;
4
4
  const react_1 = require("react");
5
+ const use_video_js_1 = require("./use-video.js");
5
6
  exports.TimelineContext = (0, react_1.createContext)({
6
7
  frame: 0,
7
8
  playing: false,
@@ -24,8 +25,15 @@ exports.SetTimelineContext = (0, react_1.createContext)({
24
25
  },
25
26
  });
26
27
  const useTimelinePosition = () => {
28
+ const videoConfig = (0, use_video_js_1.useVideo)();
27
29
  const state = (0, react_1.useContext)(exports.TimelineContext);
28
- return state.frame;
30
+ // A dynamically calculated duration using calculateMetadata()
31
+ // may lead to the frame being bigger than the duration.
32
+ // If we have the config, we clamp the frame to the duration.
33
+ if (!videoConfig) {
34
+ return state.frame;
35
+ }
36
+ return Math.min(videoConfig.durationInFrames - 1, state.frame);
29
37
  };
30
38
  exports.useTimelinePosition = useTimelinePosition;
31
39
  const useTimelineSetFrame = () => {
@@ -0,0 +1,3 @@
1
+ type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T;
2
+ export declare function truthy<T>(value: T): value is Truthy<T>;
3
+ export {};
File without changes
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @description Get the current frame of the video. Frames are 0-indexed, meaning the first frame is 0, the last frame is the duration of the composition in frames minus one.
3
+ * @see [Documentation](https://remotion.dev/docs/use-current-frame)
4
+ */
5
+ export declare const useCurrentFrame: () => number;
@@ -2,24 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCurrentFrame = void 0;
4
4
  const react_1 = require("react");
5
- const CanUseRemotionHooks_1 = require("./CanUseRemotionHooks");
6
- const Sequence_1 = require("./Sequence");
7
- const timeline_position_state_1 = require("./timeline-position-state");
5
+ const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
6
+ const SequenceContext_js_1 = require("./SequenceContext.js");
7
+ const timeline_position_state_js_1 = require("./timeline-position-state.js");
8
8
  /**
9
- * Get the current frame of the video.
10
- * Frames are 0-indexed, meaning the first frame is 0, the last frame is the duration of the composition in frames minus one.
11
- * @link https://www.remotion.dev/docs/use-current-frame
9
+ * @description Get the current frame of the video. Frames are 0-indexed, meaning the first frame is 0, the last frame is the duration of the composition in frames minus one.
10
+ * @see [Documentation](https://remotion.dev/docs/use-current-frame)
12
11
  */
13
12
  const useCurrentFrame = () => {
14
- const canUseRemotionHooks = (0, react_1.useContext)(CanUseRemotionHooks_1.CanUseRemotionHooks);
13
+ const canUseRemotionHooks = (0, react_1.useContext)(CanUseRemotionHooks_js_1.CanUseRemotionHooks);
15
14
  if (!canUseRemotionHooks) {
16
15
  if (typeof window !== 'undefined' && window.remotion_isPlayer) {
17
16
  throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`);
18
17
  }
19
18
  throw new Error(`useCurrentFrame() can only be called inside a component that was registered as a composition. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions`);
20
19
  }
21
- const frame = (0, timeline_position_state_1.useTimelinePosition)();
22
- const context = (0, react_1.useContext)(Sequence_1.SequenceContext);
20
+ const frame = (0, timeline_position_state_js_1.useTimelinePosition)();
21
+ const context = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
23
22
  const contextOffset = context
24
23
  ? context.cumulatedFrom + context.relativeFrom
25
24
  : 0;
@@ -0,0 +1,7 @@
1
+ import type { ComponentPropsWithRef, ComponentType, ExoticComponent } from 'react';
2
+ import type { CompProps } from './Composition.js';
3
+ type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
4
+ readonly _result: T;
5
+ };
6
+ export declare const useLazyComponent: <Props>(compProps: CompProps<Props>) => LazyExoticComponent<ComponentType<Props>>;
7
+ export {};
@@ -1,9 +1,10 @@
1
1
  import type { RefObject } from 'react';
2
- import type { VolumeProp } from './volume-prop';
3
- export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, }: {
2
+ import type { VolumeProp } from './volume-prop.js';
3
+ export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, }: {
4
4
  volume: VolumeProp | undefined;
5
5
  mediaVolume: number;
6
6
  mediaRef: RefObject<HTMLAudioElement | HTMLVideoElement>;
7
7
  src: string | undefined;
8
8
  mediaType: 'audio' | 'video';
9
+ playbackRate: number;
9
10
  }) => void;
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMediaInTimeline = void 0;
4
4
  const react_1 = require("react");
5
- const use_audio_frame_1 = require("./audio/use-audio-frame");
6
- const CompositionManager_1 = require("./CompositionManager");
7
- const get_asset_file_name_1 = require("./get-asset-file-name");
8
- const get_environment_1 = require("./get-environment");
9
- const nonce_1 = require("./nonce");
10
- const play_and_handle_not_allowed_error_1 = require("./play-and-handle-not-allowed-error");
11
- const Sequence_1 = require("./Sequence");
12
- const timeline_position_state_1 = require("./timeline-position-state");
13
- const use_video_config_1 = require("./use-video-config");
14
- const volume_prop_1 = require("./volume-prop");
5
+ const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
6
+ const get_asset_file_name_js_1 = require("./get-asset-file-name.js");
7
+ const get_environment_js_1 = require("./get-environment.js");
8
+ const nonce_js_1 = require("./nonce.js");
9
+ const play_and_handle_not_allowed_error_js_1 = require("./play-and-handle-not-allowed-error.js");
10
+ const SequenceContext_js_1 = require("./SequenceContext.js");
11
+ const SequenceManager_js_1 = require("./SequenceManager.js");
12
+ const timeline_position_state_js_1 = require("./timeline-position-state.js");
13
+ const use_video_config_js_1 = require("./use-video-config.js");
14
+ const volume_prop_js_1 = require("./volume-prop.js");
15
15
  const didWarn = {};
16
16
  const warnOnce = (message) => {
17
17
  if (didWarn[message]) {
@@ -20,34 +20,36 @@ const warnOnce = (message) => {
20
20
  console.warn(message);
21
21
  didWarn[message] = true;
22
22
  };
23
- const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, }) => {
24
- const videoConfig = (0, use_video_config_1.useVideoConfig)();
25
- const { rootId, audioAndVideoTags } = (0, react_1.useContext)(timeline_position_state_1.TimelineContext);
26
- const parentSequence = (0, react_1.useContext)(Sequence_1.SequenceContext);
23
+ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, }) => {
24
+ const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
25
+ const { rootId, audioAndVideoTags } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
26
+ const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
27
27
  const actualFrom = parentSequence
28
28
  ? parentSequence.relativeFrom + parentSequence.cumulatedFrom
29
29
  : 0;
30
- const [playing] = (0, timeline_position_state_1.usePlayingState)();
31
- const startsAt = (0, use_audio_frame_1.useMediaStartsAt)();
32
- const { registerSequence, unregisterSequence } = (0, react_1.useContext)(CompositionManager_1.CompositionManager);
30
+ const [playing] = (0, timeline_position_state_js_1.usePlayingState)();
31
+ const startsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
32
+ const { registerSequence, unregisterSequence } = (0, react_1.useContext)(SequenceManager_js_1.SequenceManager);
33
33
  const [id] = (0, react_1.useState)(() => String(Math.random()));
34
34
  const [initialVolume] = (0, react_1.useState)(() => volume);
35
- const nonce = (0, nonce_1.useNonce)();
35
+ const nonce = (0, nonce_js_1.useNonce)();
36
36
  const duration = parentSequence
37
37
  ? Math.min(parentSequence.durationInFrames, videoConfig.durationInFrames)
38
38
  : videoConfig.durationInFrames;
39
39
  const doesVolumeChange = typeof volume === 'function';
40
+ const environment = (0, get_environment_js_1.useRemotionEnvironment)();
40
41
  const volumes = (0, react_1.useMemo)(() => {
41
42
  if (typeof volume === 'number') {
42
43
  return volume;
43
44
  }
44
- return new Array(Math.max(0, duration + startsAt))
45
+ return new Array(Math.floor(Math.max(0, duration + startsAt)))
45
46
  .fill(true)
46
47
  .map((_, i) => {
47
- return (0, volume_prop_1.evaluateVolume)({
48
+ return (0, volume_prop_js_1.evaluateVolume)({
48
49
  frame: i + startsAt,
49
50
  volume,
50
51
  mediaVolume,
52
+ allowAmplificationDuringRender: false,
51
53
  });
52
54
  })
53
55
  .join(',');
@@ -65,8 +67,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, })
65
67
  if (!src) {
66
68
  throw new Error('No src passed');
67
69
  }
68
- if ((0, get_environment_1.getRemotionEnvironment)() !== 'preview' &&
69
- process.env.NODE_ENV !== 'test') {
70
+ if (environment !== 'preview' && process.env.NODE_ENV !== 'test') {
70
71
  return;
71
72
  }
72
73
  registerSequence({
@@ -76,14 +77,15 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, })
76
77
  duration,
77
78
  from: 0,
78
79
  parent: (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _a !== void 0 ? _a : null,
79
- displayName: (0, get_asset_file_name_1.getAssetDisplayName)(src),
80
+ displayName: (0, get_asset_file_name_js_1.getAssetDisplayName)(src),
80
81
  rootId,
81
82
  volume: volumes,
82
83
  showInTimeline: true,
83
84
  nonce,
84
85
  startMediaFrom: 0 - startsAt,
85
86
  doesVolumeChange,
86
- showLoopTimesInTimeline: undefined,
87
+ loopDisplay: undefined,
88
+ playbackRate,
87
89
  });
88
90
  return () => {
89
91
  unregisterSequence(id);
@@ -104,6 +106,8 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, })
104
106
  mediaRef,
105
107
  mediaType,
106
108
  startsAt,
109
+ playbackRate,
110
+ environment,
107
111
  ]);
108
112
  (0, react_1.useEffect)(() => {
109
113
  const tag = {
@@ -113,7 +117,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, })
113
117
  // Don't play if for example in a <Freeze> state.
114
118
  return;
115
119
  }
116
- return (0, play_and_handle_not_allowed_error_1.playAndHandleNotAllowedError)(mediaRef, mediaType);
120
+ return (0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)(mediaRef, mediaType);
117
121
  },
118
122
  };
119
123
  audioAndVideoTags.current.push(tag);
@@ -1,8 +1,10 @@
1
1
  import type { RefObject } from 'react';
2
- export declare const useMediaPlayback: ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, }: {
2
+ export declare const DEFAULT_ACCEPTABLE_TIMESHIFT = 0.45;
3
+ export declare const useMediaPlayback: ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, acceptableTimeshift, }: {
3
4
  mediaRef: RefObject<HTMLVideoElement | HTMLAudioElement>;
4
5
  src: string | undefined;
5
6
  mediaType: 'audio' | 'video';
6
7
  playbackRate: number;
7
8
  onlyWarnForMediaSeekingError: boolean;
9
+ acceptableTimeshift: number;
8
10
  }) => void;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMediaPlayback = exports.DEFAULT_ACCEPTABLE_TIMESHIFT = void 0;
4
+ const react_1 = require("react");
5
+ const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
6
+ const play_and_handle_not_allowed_error_js_1 = require("./play-and-handle-not-allowed-error.js");
7
+ const timeline_position_state_js_1 = require("./timeline-position-state.js");
8
+ const use_current_frame_js_1 = require("./use-current-frame.js");
9
+ const use_video_config_js_1 = require("./use-video-config.js");
10
+ const get_current_time_js_1 = require("./video/get-current-time.js");
11
+ const warn_about_non_seekable_media_js_1 = require("./warn-about-non-seekable-media.js");
12
+ exports.DEFAULT_ACCEPTABLE_TIMESHIFT = 0.45;
13
+ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, acceptableTimeshift, }) => {
14
+ const { playbackRate: globalPlaybackRate } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
15
+ const frame = (0, use_current_frame_js_1.useCurrentFrame)();
16
+ const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
17
+ const [playing] = (0, timeline_position_state_js_1.usePlayingState)();
18
+ const { fps } = (0, use_video_config_js_1.useVideoConfig)();
19
+ const mediaStartsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
20
+ const playbackRate = localPlaybackRate * globalPlaybackRate;
21
+ (0, react_1.useEffect)(() => {
22
+ var _a;
23
+ if (!playing) {
24
+ (_a = mediaRef.current) === null || _a === void 0 ? void 0 : _a.pause();
25
+ }
26
+ }, [mediaRef, mediaType, playing]);
27
+ (0, react_1.useEffect)(() => {
28
+ const tagName = mediaType === 'audio' ? '<Audio>' : '<Video>';
29
+ if (!mediaRef.current) {
30
+ throw new Error(`No ${mediaType} ref found`);
31
+ }
32
+ if (!src) {
33
+ throw new Error(`No 'src' attribute was passed to the ${tagName} element.`);
34
+ }
35
+ mediaRef.current.playbackRate = Math.max(0, playbackRate);
36
+ const shouldBeTime = (0, get_current_time_js_1.getMediaTime)({
37
+ fps,
38
+ frame,
39
+ src,
40
+ playbackRate: localPlaybackRate,
41
+ startFrom: -mediaStartsAt,
42
+ mediaType,
43
+ });
44
+ const isTime = mediaRef.current.currentTime;
45
+ const timeShift = Math.abs(shouldBeTime - isTime);
46
+ if (timeShift > acceptableTimeshift && !mediaRef.current.ended) {
47
+ // If scrubbing around, adjust timing
48
+ // or if time shift is bigger than 0.2sec
49
+ mediaRef.current.currentTime = shouldBeTime;
50
+ if (!onlyWarnForMediaSeekingError) {
51
+ (0, warn_about_non_seekable_media_js_1.warnAboutNonSeekableMedia)(mediaRef.current, onlyWarnForMediaSeekingError ? 'console-warning' : 'console-error');
52
+ }
53
+ }
54
+ // Only perform a seek if the time is not already the same.
55
+ // Chrome rounds to 6 digits, so 0.033333333 -> 0.033333,
56
+ // therefore a threshold is allowed.
57
+ // Refer to the https://github.com/remotion-dev/video-buffering-example
58
+ // which is fixed by only seeking conditionally.
59
+ const makesSenseToSeek = Math.abs(mediaRef.current.currentTime - shouldBeTime) > 0.00001;
60
+ if (!playing || absoluteFrame === 0) {
61
+ if (makesSenseToSeek) {
62
+ mediaRef.current.currentTime = shouldBeTime;
63
+ }
64
+ }
65
+ if (mediaRef.current.paused && !mediaRef.current.ended && playing) {
66
+ if (makesSenseToSeek) {
67
+ mediaRef.current.currentTime = shouldBeTime;
68
+ }
69
+ (0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)(mediaRef, mediaType);
70
+ }
71
+ }, [
72
+ absoluteFrame,
73
+ fps,
74
+ playbackRate,
75
+ frame,
76
+ mediaRef,
77
+ mediaType,
78
+ playing,
79
+ src,
80
+ mediaStartsAt,
81
+ localPlaybackRate,
82
+ onlyWarnForMediaSeekingError,
83
+ acceptableTimeshift,
84
+ ]);
85
+ };
86
+ exports.useMediaPlayback = useMediaPlayback;
@@ -1,6 +1,6 @@
1
1
  import type { RefObject } from 'react';
2
- import type { VolumeProp } from './volume-prop';
3
- export declare type UseSyncVolumeWithMediaTagOptions = {
2
+ import type { VolumeProp } from './volume-prop.js';
3
+ export type UseSyncVolumeWithMediaTagOptions = {
4
4
  volumePropFrame: number;
5
5
  actualVolume: number;
6
6
  volume?: VolumeProp;
@@ -2,16 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSyncVolumeWithMediaTag = void 0;
4
4
  const react_1 = require("react");
5
- const is_approximately_the_same_1 = require("./is-approximately-the-same");
6
- const volume_prop_1 = require("./volume-prop");
5
+ const is_approximately_the_same_js_1 = require("./is-approximately-the-same.js");
6
+ const volume_prop_js_1 = require("./volume-prop.js");
7
7
  const useSyncVolumeWithMediaTag = ({ volumePropFrame, actualVolume, volume, mediaVolume, mediaRef, }) => {
8
8
  (0, react_1.useEffect)(() => {
9
- const userPreferredVolume = (0, volume_prop_1.evaluateVolume)({
9
+ const userPreferredVolume = (0, volume_prop_js_1.evaluateVolume)({
10
10
  frame: volumePropFrame,
11
11
  volume,
12
12
  mediaVolume,
13
+ allowAmplificationDuringRender: false,
13
14
  });
14
- if (!(0, is_approximately_the_same_1.isApproximatelyTheSame)(userPreferredVolume, actualVolume) &&
15
+ if (!(0, is_approximately_the_same_js_1.isApproximatelyTheSame)(userPreferredVolume, actualVolume) &&
15
16
  mediaRef.current) {
16
17
  mediaRef.current.volume = userPreferredVolume;
17
18
  }
@@ -1,2 +1,2 @@
1
- import type { VideoConfig } from './video-config';
1
+ import type { VideoConfig } from './video-config.js';
2
2
  export declare const useUnsafeVideoConfig: () => VideoConfig | null;