@remotion/player 3.3.45 → 3.3.52

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 (145) hide show
  1. package/dist/MediaVolumeSlider.d.ts +5 -0
  2. package/dist/MediaVolumeSlider.js +118 -0
  3. package/dist/Player.d.ts +43 -0
  4. package/dist/Player.js +143 -0
  5. package/dist/PlayerControls.d.ts +41 -0
  6. package/dist/PlayerControls.js +138 -0
  7. package/dist/PlayerSeekBar.d.ts +8 -0
  8. package/dist/PlayerSeekBar.js +146 -0
  9. package/dist/PlayerUI.d.ts +38 -0
  10. package/dist/PlayerUI.js +308 -0
  11. package/dist/SharedPlayerContext.d.ts +14 -0
  12. package/dist/SharedPlayerContext.js +72 -0
  13. package/dist/Thumbnail.d.ts +20 -0
  14. package/dist/Thumbnail.js +42 -0
  15. package/dist/ThumbnailUI.d.ts +11 -0
  16. package/dist/ThumbnailUI.js +107 -0
  17. package/dist/calculate-next-frame.d.ts +14 -0
  18. package/dist/calculate-next-frame.js +28 -0
  19. package/dist/calculate-scale.d.ts +39 -0
  20. package/dist/calculate-scale.js +85 -0
  21. package/dist/cjs/MediaVolumeSlider.js +7 -7
  22. package/dist/cjs/Player.d.ts +4 -4
  23. package/dist/cjs/Player.js +14 -14
  24. package/dist/cjs/PlayerControls.d.ts +1 -1
  25. package/dist/cjs/PlayerControls.js +9 -9
  26. package/dist/cjs/PlayerSeekBar.js +6 -6
  27. package/dist/cjs/PlayerUI.d.ts +2 -2
  28. package/dist/cjs/PlayerUI.js +21 -21
  29. package/dist/cjs/SharedPlayerContext.js +3 -3
  30. package/dist/cjs/Thumbnail.d.ts +3 -3
  31. package/dist/cjs/Thumbnail.js +6 -6
  32. package/dist/cjs/ThumbnailUI.d.ts +2 -2
  33. package/dist/cjs/ThumbnailUI.js +14 -14
  34. package/dist/cjs/calculate-scale.d.ts +2 -2
  35. package/dist/cjs/calculate-scale.js +2 -2
  36. package/dist/cjs/emitter-context.d.ts +1 -1
  37. package/dist/cjs/index.d.ts +12 -12
  38. package/dist/cjs/index.js +20 -20
  39. package/dist/cjs/player-methods.d.ts +1 -1
  40. package/dist/cjs/test/index.test.js +2 -2
  41. package/dist/cjs/test/validate-in-out-frames.test.js +11 -11
  42. package/dist/cjs/test/validate-prop.test.js +22 -22
  43. package/dist/cjs/use-playback.js +4 -4
  44. package/dist/cjs/use-player.d.ts +1 -1
  45. package/dist/cjs/use-player.js +2 -2
  46. package/dist/cjs/use-thumbnail.d.ts +1 -1
  47. package/dist/cjs/use-thumbnail.js +2 -2
  48. package/dist/cjs/use-video-controls-resize.js +11 -11
  49. package/dist/cjs/utils/calculate-player-size.d.ts +1 -1
  50. package/dist/cjs/utils/use-cancellable-promises.d.ts +1 -1
  51. package/dist/cjs/utils/use-click-prevention-on-double-click.js +5 -5
  52. package/dist/emitter-context.d.ts +4 -0
  53. package/dist/emitter-context.js +9 -0
  54. package/dist/error-boundary.d.ts +19 -0
  55. package/dist/error-boundary.js +39 -0
  56. package/dist/esm/MediaVolumeSlider.js +2 -2
  57. package/dist/esm/Player.d.ts +4 -4
  58. package/dist/esm/Player.js +8 -8
  59. package/dist/esm/PlayerControls.d.ts +1 -1
  60. package/dist/esm/PlayerControls.js +5 -5
  61. package/dist/esm/PlayerSeekBar.js +3 -3
  62. package/dist/esm/PlayerUI.d.ts +2 -2
  63. package/dist/esm/PlayerUI.js +10 -10
  64. package/dist/esm/SharedPlayerContext.js +1 -1
  65. package/dist/esm/Thumbnail.d.ts +3 -3
  66. package/dist/esm/Thumbnail.js +4 -4
  67. package/dist/esm/ThumbnailUI.d.ts +2 -2
  68. package/dist/esm/ThumbnailUI.js +6 -6
  69. package/dist/esm/calculate-scale.d.ts +2 -2
  70. package/dist/esm/calculate-scale.js +1 -1
  71. package/dist/esm/emitter-context.d.ts +1 -1
  72. package/dist/esm/index.d.ts +12 -12
  73. package/dist/esm/index.js +9 -9
  74. package/dist/esm/player-methods.d.ts +1 -1
  75. package/dist/esm/test/index.test.js +1 -1
  76. package/dist/esm/test/validate-in-out-frames.test.js +1 -1
  77. package/dist/esm/test/validate-prop.test.js +2 -2
  78. package/dist/esm/use-playback.js +2 -2
  79. package/dist/esm/use-player.d.ts +1 -1
  80. package/dist/esm/use-player.js +1 -1
  81. package/dist/esm/use-thumbnail.d.ts +1 -1
  82. package/dist/esm/use-thumbnail.js +1 -1
  83. package/dist/esm/use-video-controls-resize.js +3 -3
  84. package/dist/esm/utils/calculate-player-size.d.ts +1 -1
  85. package/dist/esm/utils/use-cancellable-promises.d.ts +1 -1
  86. package/dist/esm/utils/use-click-prevention-on-double-click.js +3 -3
  87. package/dist/event-emitter.d.ts +66 -0
  88. package/dist/event-emitter.js +87 -0
  89. package/dist/format-time.d.ts +1 -0
  90. package/dist/format-time.js +9 -0
  91. package/dist/icons.d.ts +10 -0
  92. package/dist/icons.js +50 -0
  93. package/dist/index.d.ts +61 -0
  94. package/dist/index.js +25 -0
  95. package/dist/player-css-classname.d.ts +1 -0
  96. package/dist/player-css-classname.js +4 -0
  97. package/dist/player-methods.d.ts +24 -0
  98. package/dist/player-methods.js +2 -0
  99. package/dist/test/index.test.d.ts +1 -0
  100. package/dist/test/index.test.js +9 -0
  101. package/dist/test/test-utils.d.ts +6 -0
  102. package/dist/test/test-utils.js +32 -0
  103. package/dist/test/validate-in-out-frames.test.d.ts +1 -0
  104. package/dist/test/validate-in-out-frames.test.js +56 -0
  105. package/dist/test/validate-prop.test.d.ts +1 -0
  106. package/dist/test/validate-prop.test.js +131 -0
  107. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  108. package/dist/tsconfig.tsbuildinfo +1 -1
  109. package/dist/use-hover-state.d.ts +1 -0
  110. package/dist/use-hover-state.js +27 -0
  111. package/dist/use-playback.d.ts +7 -0
  112. package/dist/use-playback.js +92 -0
  113. package/dist/use-player.d.ts +19 -0
  114. package/dist/use-player.js +132 -0
  115. package/dist/use-thumbnail.d.ts +6 -0
  116. package/dist/use-thumbnail.js +18 -0
  117. package/dist/use-video-controls-resize.d.ts +7 -0
  118. package/dist/use-video-controls-resize.js +36 -0
  119. package/dist/utils/calculate-player-size.d.ts +9 -0
  120. package/dist/utils/calculate-player-size.js +29 -0
  121. package/dist/utils/cancellable-promise.d.ts +5 -0
  122. package/dist/utils/cancellable-promise.js +26 -0
  123. package/dist/utils/delay.d.ts +1 -0
  124. package/dist/utils/delay.js +6 -0
  125. package/dist/utils/is-node.d.ts +1 -0
  126. package/dist/utils/is-node.js +4 -0
  127. package/dist/utils/preview-size.d.ts +8 -0
  128. package/dist/utils/preview-size.js +2 -0
  129. package/dist/utils/props-if-has-props.d.ts +5 -0
  130. package/dist/utils/props-if-has-props.js +2 -0
  131. package/dist/utils/use-cancellable-promises.d.ts +7 -0
  132. package/dist/utils/use-cancellable-promises.js +21 -0
  133. package/dist/utils/use-click-prevention-on-double-click.d.ts +3 -0
  134. package/dist/utils/use-click-prevention-on-double-click.js +45 -0
  135. package/dist/utils/use-element-size.d.ts +16 -0
  136. package/dist/utils/use-element-size.js +98 -0
  137. package/dist/utils/validate-in-out-frame.d.ts +6 -0
  138. package/dist/utils/validate-in-out-frame.js +54 -0
  139. package/dist/utils/validate-initial-frame.d.ts +4 -0
  140. package/dist/utils/validate-initial-frame.js +27 -0
  141. package/dist/utils/validate-playbackrate.d.ts +1 -0
  142. package/dist/utils/validate-playbackrate.js +18 -0
  143. package/dist/volume-persistance.d.ts +2 -0
  144. package/dist/volume-persistance.js +19 -0
  145. package/package.json +4 -3
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from 'react';
3
3
  import { Composition, Internals } from 'remotion';
4
- import { PlayerEventEmitterContext } from './emitter-context';
5
- import { PlayerEmitter } from './event-emitter';
6
- import { PLAYER_CSS_CLASSNAME } from './player-css-classname';
7
- import PlayerUI from './PlayerUI';
8
- import { SharedPlayerContexts } from './SharedPlayerContext';
9
- import { validateInOutFrames } from './utils/validate-in-out-frame';
10
- import { validateInitialFrame } from './utils/validate-initial-frame';
11
- import { validatePlaybackRate } from './utils/validate-playbackrate';
4
+ import { PlayerEventEmitterContext } from './emitter-context.js';
5
+ import { PlayerEmitter } from './event-emitter.js';
6
+ import { PLAYER_CSS_CLASSNAME } from './player-css-classname.js';
7
+ import PlayerUI from './PlayerUI.js';
8
+ import { SharedPlayerContexts } from './SharedPlayerContext.js';
9
+ import { validateInOutFrames } from './utils/validate-in-out-frame.js';
10
+ import { validateInitialFrame } from './utils/validate-initial-frame.js';
11
+ import { validatePlaybackRate } from './utils/validate-playbackrate.js';
12
12
  export const componentOrNullIfLazy = (props) => {
13
13
  if ('component' in props) {
14
14
  return props.component;
@@ -1,6 +1,6 @@
1
1
  import type { MouseEventHandler, ReactNode } from 'react';
2
2
  import React from 'react';
3
- import type { usePlayer } from './use-player';
3
+ import type { usePlayer } from './use-player.js';
4
4
  export declare type RenderPlayPauseButton = (props: {
5
5
  playing: boolean;
6
6
  }) => ReactNode;
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { Internals } from 'remotion';
4
- import { formatTime } from './format-time';
5
- import { FullscreenIcon, PauseIcon, PlayIcon } from './icons';
6
- import { MediaVolumeSlider } from './MediaVolumeSlider';
7
- import { PlayerSeekBar } from './PlayerSeekBar';
8
- import { useVideoControlsResize } from './use-video-controls-resize';
4
+ import { formatTime } from './format-time.js';
5
+ import { FullscreenIcon, PauseIcon, PlayIcon } from './icons.js';
6
+ import { MediaVolumeSlider } from './MediaVolumeSlider.js';
7
+ import { PlayerSeekBar } from './PlayerSeekBar.js';
8
+ import { useVideoControlsResize } from './use-video-controls-resize.js';
9
9
  export const X_SPACER = 10;
10
10
  export const X_PADDING = 12;
11
11
  const gradientSteps = [
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { Internals, interpolate } from 'remotion';
4
- import { useHoverState } from './use-hover-state';
5
- import { usePlayer } from './use-player';
6
- import { useElementSize } from './utils/use-element-size';
4
+ import { useHoverState } from './use-hover-state.js';
5
+ import { usePlayer } from './use-player.js';
6
+ import { useElementSize } from './utils/use-element-size.js';
7
7
  const getFrameFromX = (clientX, durationInFrames, width) => {
8
8
  var _a;
9
9
  const pos = clientX;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import type { PlayerRef } from './player-methods';
3
- import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
2
+ import type { PlayerRef } from './player-methods.js';
3
+ import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls.js';
4
4
  export declare type ErrorFallback = (info: {
5
5
  error: Error;
6
6
  }) => React.ReactNode;
@@ -1,16 +1,16 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { forwardRef, Suspense, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
3
3
  import { Internals } from 'remotion';
4
- import { calculateCanvasTransformation, calculateContainerStyle, calculateOuter, calculateOuterStyle, } from './calculate-scale';
5
- import { ErrorBoundary } from './error-boundary';
6
- import { PLAYER_CSS_CLASSNAME } from './player-css-classname';
7
- import { Controls } from './PlayerControls';
8
- import { useHoverState } from './use-hover-state';
9
- import { usePlayback } from './use-playback';
10
- import { usePlayer } from './use-player';
11
- import { IS_NODE } from './utils/is-node';
12
- import { useClickPreventionOnDoubleClick } from './utils/use-click-prevention-on-double-click';
13
- import { useElementSize } from './utils/use-element-size';
4
+ import { calculateCanvasTransformation, calculateContainerStyle, calculateOuter, calculateOuterStyle, } from './calculate-scale.js';
5
+ import { ErrorBoundary } from './error-boundary.js';
6
+ import { PLAYER_CSS_CLASSNAME } from './player-css-classname.js';
7
+ import { Controls } from './PlayerControls.js';
8
+ import { useHoverState } from './use-hover-state.js';
9
+ import { usePlayback } from './use-playback.js';
10
+ import { usePlayer } from './use-player.js';
11
+ import { IS_NODE } from './utils/is-node.js';
12
+ import { useClickPreventionOnDoubleClick } from './utils/use-click-prevention-on-double-click.js';
13
+ import { useElementSize } from './utils/use-element-size.js';
14
14
  const reactVersion = React.version.split('.')[0];
15
15
  if (reactVersion === '0') {
16
16
  throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useMemo, useState } from 'react';
3
3
  import { Internals } from 'remotion';
4
- import { getPreferredVolume, persistVolume } from './volume-persistance';
4
+ import { getPreferredVolume, persistVolume } from './volume-persistance.js';
5
5
  export const SharedPlayerContexts = ({ children, timelineContext, inputProps, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, }) => {
6
6
  const compositionManagerContext = useMemo(() => {
7
7
  return {
@@ -1,8 +1,8 @@
1
1
  import type { CSSProperties, MutableRefObject } from 'react';
2
2
  import type { CompProps } from 'remotion';
3
- import type { ThumbnailMethods } from './player-methods';
4
- import type { ErrorFallback, RenderLoading } from './PlayerUI';
5
- import type { PropsIfHasProps } from './utils/props-if-has-props';
3
+ import type { ThumbnailMethods } from './player-methods.js';
4
+ import type { ErrorFallback, RenderLoading } from './PlayerUI.js';
5
+ import type { PropsIfHasProps } from './utils/props-if-has-props.js';
6
6
  declare type ThumbnailProps<T> = PropsIfHasProps<T> & CompProps<T> & {
7
7
  frameToDisplay: number;
8
8
  style?: CSSProperties;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useImperativeHandle, useMemo, useRef, useState, } from 'react';
3
3
  import { Internals, random } from 'remotion';
4
- import { ThumbnailEmitterContext } from './emitter-context';
5
- import { ThumbnailEmitter } from './event-emitter';
6
- import { SharedPlayerContexts } from './SharedPlayerContext';
7
- import ThumbnailUI from './ThumbnailUI';
4
+ import { ThumbnailEmitterContext } from './emitter-context.js';
5
+ import { ThumbnailEmitter } from './event-emitter.js';
6
+ import { SharedPlayerContexts } from './SharedPlayerContext.js';
7
+ import ThumbnailUI from './ThumbnailUI.js';
8
8
  export const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback = () => '⚠️', renderLoading, ...componentProps }, ref) => {
9
9
  const [thumbnailId] = useState(() => String(random(null)));
10
10
  const rootRef = useRef(null);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import type { ThumbnailMethods } from './player-methods';
3
- import type { ErrorFallback, RenderLoading } from './PlayerUI';
2
+ import type { ThumbnailMethods } from './player-methods.js';
3
+ import type { ErrorFallback, RenderLoading } from './PlayerUI.js';
4
4
  declare const _default: React.ForwardRefExoticComponent<{
5
5
  inputProps: unknown;
6
6
  style?: React.CSSProperties | undefined;
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { forwardRef, Suspense, useCallback, useImperativeHandle, useMemo, useRef, } from 'react';
3
3
  import { Internals } from 'remotion';
4
- import { calculateCanvasTransformation, calculateContainerStyle, calculateOuter, calculateOuterStyle, } from './calculate-scale';
5
- import { ErrorBoundary } from './error-boundary';
6
- import { PLAYER_CSS_CLASSNAME } from './player-css-classname';
7
- import { useThumbnail } from './use-thumbnail';
8
- import { IS_NODE } from './utils/is-node';
9
- import { useElementSize } from './utils/use-element-size';
4
+ import { calculateCanvasTransformation, calculateContainerStyle, calculateOuter, calculateOuterStyle, } from './calculate-scale.js';
5
+ import { ErrorBoundary } from './error-boundary.js';
6
+ import { PLAYER_CSS_CLASSNAME } from './player-css-classname.js';
7
+ import { useThumbnail } from './use-thumbnail.js';
8
+ import { IS_NODE } from './utils/is-node.js';
9
+ import { useElementSize } from './utils/use-element-size.js';
10
10
  const reactVersion = React.version.split('.')[0];
11
11
  if (reactVersion === '0') {
12
12
  throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
@@ -1,6 +1,6 @@
1
1
  import type { VideoConfig } from 'remotion';
2
- import type { PreviewSize } from './utils/preview-size';
3
- import type { Size } from './utils/use-element-size';
2
+ import type { PreviewSize } from './utils/preview-size.js';
3
+ import type { Size } from './utils/use-element-size.js';
4
4
  export declare const calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
5
5
  previewSize: PreviewSize['size'];
6
6
  compositionWidth: number;
@@ -1,4 +1,4 @@
1
- import { calculatePlayerSize } from './utils/calculate-player-size';
1
+ import { calculatePlayerSize } from './utils/calculate-player-size.js';
2
2
  export const calculateScale = ({ canvasSize, compositionHeight, compositionWidth, previewSize, }) => {
3
3
  const heightRatio = canvasSize.height / compositionHeight;
4
4
  const widthRatio = canvasSize.width / compositionWidth;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import type { PlayerEmitter, ThumbnailEmitter } from './event-emitter';
2
+ import type { PlayerEmitter, ThumbnailEmitter } from './event-emitter.js';
3
3
  export declare const PlayerEventEmitterContext: React.Context<PlayerEmitter | undefined>;
4
4
  export declare const ThumbnailEmitterContext: React.Context<ThumbnailEmitter | undefined>;
@@ -1,13 +1,13 @@
1
1
  /// <reference types="react" />
2
- import type { CallbackListener, PlayerEventTypes } from './event-emitter';
3
- import { PlayerEmitter } from './event-emitter';
4
- export { Player, PlayerProps } from './Player';
5
- export { PlayerMethods, PlayerRef, ThumbnailMethods, ThumbnailRef, } from './player-methods';
6
- export type { RenderFullscreenButton, RenderPlayPauseButton, } from './PlayerControls';
7
- export type { ErrorFallback, RenderLoading, RenderPoster } from './PlayerUI';
8
- export { Thumbnail } from './Thumbnail';
9
- export { PreviewSize, Translation } from './utils/preview-size';
10
- export { Size } from './utils/use-element-size';
2
+ import type { CallbackListener, PlayerEventTypes } from './event-emitter.js';
3
+ import { PlayerEmitter } from './event-emitter.js';
4
+ export { Player, PlayerProps } from './Player.js';
5
+ export { PlayerMethods, PlayerRef, ThumbnailMethods, ThumbnailRef, } from './player-methods.js';
6
+ export type { RenderFullscreenButton, RenderPlayPauseButton, } from './PlayerControls.js';
7
+ export type { ErrorFallback, RenderLoading, RenderPoster } from './PlayerUI.js';
8
+ export { Thumbnail } from './Thumbnail.js';
9
+ export { PreviewSize, Translation } from './utils/preview-size.js';
10
+ export { Size } from './utils/use-element-size.js';
11
11
  export type { CallbackListener, PlayerEventTypes as EventTypes };
12
12
  export declare const PlayerInternals: {
13
13
  PlayerEventEmitterContext: import("react").Context<PlayerEmitter | undefined>;
@@ -37,12 +37,12 @@ export declare const PlayerInternals: {
37
37
  useElementSize: (ref: import("react").RefObject<HTMLElement>, options: {
38
38
  triggerOnWindowResize: boolean;
39
39
  shouldApplyCssTransforms: boolean;
40
- }) => import("./utils/use-element-size").Size | null;
40
+ }) => import("./utils/use-element-size.js").Size | null;
41
41
  calculateCanvasTransformation: ({ previewSize, compositionWidth, compositionHeight, canvasSize, }: {
42
42
  previewSize: number | "auto";
43
43
  compositionWidth: number;
44
44
  compositionHeight: number;
45
- canvasSize: import("./utils/use-element-size").Size;
45
+ canvasSize: import("./utils/use-element-size.js").Size;
46
46
  }) => {
47
47
  centerX: number;
48
48
  centerY: number;
@@ -56,6 +56,6 @@ export declare const PlayerInternals: {
56
56
  previewSize: number | "auto";
57
57
  compositionWidth: number;
58
58
  compositionHeight: number;
59
- canvasSize: import("./utils/use-element-size").Size;
59
+ canvasSize: import("./utils/use-element-size.js").Size;
60
60
  }) => number;
61
61
  };
package/dist/esm/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { calculateCanvasTransformation, calculateScale } from './calculate-scale';
2
- import { PlayerEventEmitterContext } from './emitter-context';
3
- import { PlayerEmitter } from './event-emitter';
4
- import { useHoverState } from './use-hover-state';
5
- import { usePlayback } from './use-playback';
6
- import { usePlayer } from './use-player';
7
- import { updateAllElementsSizes, useElementSize } from './utils/use-element-size';
8
- export { Player } from './Player';
9
- export { Thumbnail } from './Thumbnail';
1
+ import { calculateCanvasTransformation, calculateScale } from './calculate-scale.js';
2
+ import { PlayerEventEmitterContext } from './emitter-context.js';
3
+ import { PlayerEmitter } from './event-emitter.js';
4
+ import { useHoverState } from './use-hover-state.js';
5
+ import { usePlayback } from './use-playback.js';
6
+ import { usePlayer } from './use-player.js';
7
+ import { updateAllElementsSizes, useElementSize } from './utils/use-element-size.js';
8
+ export { Player } from './Player.js';
9
+ export { Thumbnail } from './Thumbnail.js';
10
10
  export const PlayerInternals = {
11
11
  PlayerEventEmitterContext,
12
12
  PlayerEmitter,
@@ -1,5 +1,5 @@
1
1
  import type { SyntheticEvent } from 'react';
2
- import type { PlayerEmitter } from './event-emitter';
2
+ import type { PlayerEmitter } from './event-emitter.js';
3
3
  export declare type ThumbnailMethods = {
4
4
  getContainerNode: () => HTMLDivElement | null;
5
5
  getScale: () => number;
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from 'vitest';
2
- import { usePlayer } from '../use-player';
2
+ import { usePlayer } from '../use-player.js';
3
3
  test('It should throw an error if not being used inside a RemotionRoot', () => {
4
4
  expect(() => {
5
5
  usePlayer();
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from 'vitest';
2
- import { validateInOutFrames } from '../utils/validate-in-out-frame';
2
+ import { validateInOutFrames } from '../utils/validate-in-out-frame.js';
3
3
  test('Validate in out frames', () => {
4
4
  expect(() => validateInOutFrames({
5
5
  durationInFrames: 200,
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Composition } from 'remotion';
3
3
  import { expect, test } from 'vitest';
4
- import { Player } from '../index';
5
- import { HelloWorld, render } from './test-utils';
4
+ import { Player } from '../index.js';
5
+ import { HelloWorld, render } from './test-utils.js';
6
6
  test('no compositionWidth should give errors', () => {
7
7
  try {
8
8
  render(_jsx(Player
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  import { Internals } from 'remotion';
3
- import { calculateNextFrame } from './calculate-next-frame';
4
- import { usePlayer } from './use-player';
3
+ import { calculateNextFrame } from './calculate-next-frame.js';
4
+ import { usePlayer } from './use-player.js';
5
5
  export const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }) => {
6
6
  const frame = Internals.Timeline.useTimelinePosition();
7
7
  const config = Internals.useUnsafeVideoConfig();
@@ -1,5 +1,5 @@
1
1
  import type { SyntheticEvent } from 'react';
2
- import type { PlayerEmitter } from './event-emitter';
2
+ import type { PlayerEmitter } from './event-emitter.js';
3
3
  declare type UsePlayerMethods = {
4
4
  frameBack: (frames: number) => void;
5
5
  frameForward: (frames: number) => void;
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useContext, useMemo, useRef, useState } from 'react';
2
2
  import { Internals } from 'remotion';
3
- import { PlayerEventEmitterContext } from './emitter-context';
3
+ import { PlayerEventEmitterContext } from './emitter-context.js';
4
4
  export const usePlayer = () => {
5
5
  var _a;
6
6
  const [playing, setPlaying, imperativePlaying] = Internals.Timeline.usePlayingState();
@@ -1,4 +1,4 @@
1
- import type { ThumbnailEmitter } from './event-emitter';
1
+ import type { ThumbnailEmitter } from './event-emitter.js';
2
2
  declare type UseThumbnailMethods = {
3
3
  emitter: ThumbnailEmitter;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import { useContext, useMemo } from 'react';
2
- import { ThumbnailEmitterContext } from './emitter-context';
2
+ import { ThumbnailEmitterContext } from './emitter-context.js';
3
3
  export const useThumbnail = () => {
4
4
  const emitter = useContext(ThumbnailEmitterContext);
5
5
  if (!emitter) {
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from 'react';
2
- import { fullscreenIconSize, ICON_SIZE } from './icons';
3
- import { VOLUME_SLIDER_WIDTH } from './MediaVolumeSlider';
4
- import { X_PADDING, X_SPACER } from './PlayerControls';
2
+ import { fullscreenIconSize, ICON_SIZE } from './icons.js';
3
+ import { VOLUME_SLIDER_WIDTH } from './MediaVolumeSlider.js';
4
+ import { X_PADDING, X_SPACER } from './PlayerControls.js';
5
5
  export const useVideoControlsResize = ({ allowFullscreen: allowFullScreen, playerWidth, }) => {
6
6
  const resizeInfo = useMemo(() => {
7
7
  const playPauseIconSize = ICON_SIZE;
@@ -1,5 +1,5 @@
1
1
  import type { StandardLonghandProperties } from 'csstype';
2
- import type { Size } from './use-element-size';
2
+ import type { Size } from './use-element-size.js';
3
3
  export declare const calculatePlayerSize: ({ currentSize, width, height, compositionWidth, compositionHeight, }: {
4
4
  currentSize: Size | null;
5
5
  width: StandardLonghandProperties['width'] | undefined;
@@ -1,4 +1,4 @@
1
- import type { CancellablePromise } from './cancellable-promise';
1
+ import type { CancellablePromise } from './cancellable-promise.js';
2
2
  declare const useCancellablePromises: () => {
3
3
  appendPendingPromise: (promise: CancellablePromise) => void;
4
4
  removePendingPromise: (promise: CancellablePromise) => void;
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useMemo } from 'react';
2
- import { cancellablePromise } from './cancellable-promise';
3
- import { delay } from './delay';
4
- import { useCancellablePromises } from './use-cancellable-promises';
2
+ import { cancellablePromise } from './cancellable-promise.js';
3
+ import { delay } from './delay.js';
4
+ import { useCancellablePromises } from './use-cancellable-promises.js';
5
5
  const useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
6
6
  const api = useCancellablePromises();
7
7
  const handleClick = useCallback(async (e) => {
@@ -0,0 +1,66 @@
1
+ declare type SeekPayload = {
2
+ frame: number;
3
+ };
4
+ declare type ErrorPayload = {
5
+ error: Error;
6
+ };
7
+ declare type TimeUpdateEventPayload = {
8
+ frame: number;
9
+ };
10
+ declare type FrameUpdateEventPayload = {
11
+ frame: number;
12
+ };
13
+ declare type RateChangeEventPayload = {
14
+ playbackRate: number;
15
+ };
16
+ declare type FullscreenChangeEventPayload = {
17
+ isFullscreen: boolean;
18
+ };
19
+ declare type PlayerStateEventMap = {
20
+ seeked: SeekPayload;
21
+ pause: undefined;
22
+ play: undefined;
23
+ ratechange: RateChangeEventPayload;
24
+ ended: undefined;
25
+ error: ErrorPayload;
26
+ timeupdate: TimeUpdateEventPayload;
27
+ frameupdate: FrameUpdateEventPayload;
28
+ fullscreenchange: FullscreenChangeEventPayload;
29
+ };
30
+ declare type ThumbnailStateEventMap = {
31
+ error: ErrorPayload;
32
+ };
33
+ export declare type PlayerEventTypes = keyof PlayerStateEventMap;
34
+ export declare type ThumbnailEventTypes = keyof ThumbnailStateEventMap;
35
+ export declare type CallbackListener<T extends PlayerEventTypes> = (data: {
36
+ detail: PlayerStateEventMap[T];
37
+ }) => void;
38
+ declare type PlayerListeners = {
39
+ [EventType in PlayerEventTypes]: CallbackListener<EventType>[];
40
+ };
41
+ declare type ThumbnailListeners = {
42
+ [EventType in ThumbnailEventTypes]: CallbackListener<EventType>[];
43
+ };
44
+ export declare class PlayerEmitter {
45
+ listeners: PlayerListeners;
46
+ addEventListener<Q extends PlayerEventTypes>(name: Q, callback: CallbackListener<Q>): void;
47
+ removeEventListener<Q extends PlayerEventTypes>(name: Q, callback: CallbackListener<Q>): void;
48
+ private dispatchEvent;
49
+ dispatchSeek(frame: number): void;
50
+ dispatchPause(): void;
51
+ dispatchPlay(): void;
52
+ dispatchEnded(): void;
53
+ dispatchRatechange(playbackRate: number): void;
54
+ dispatchError(error: Error): void;
55
+ dispatchTimeUpdate(event: TimeUpdateEventPayload): void;
56
+ dispatchFrameUpdate(event: FrameUpdateEventPayload): void;
57
+ dispatchFullscreenChangeUpdate(event: FullscreenChangeEventPayload): void;
58
+ }
59
+ export declare class ThumbnailEmitter {
60
+ listeners: ThumbnailListeners;
61
+ addEventListener<Q extends ThumbnailEventTypes>(name: Q, callback: CallbackListener<Q>): void;
62
+ removeEventListener<Q extends ThumbnailEventTypes>(name: Q, callback: CallbackListener<Q>): void;
63
+ private dispatchEvent;
64
+ dispatchError(error: Error): void;
65
+ }
66
+ export {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThumbnailEmitter = exports.PlayerEmitter = void 0;
4
+ class PlayerEmitter {
5
+ constructor() {
6
+ this.listeners = {
7
+ ended: [],
8
+ error: [],
9
+ pause: [],
10
+ play: [],
11
+ ratechange: [],
12
+ seeked: [],
13
+ timeupdate: [],
14
+ frameupdate: [],
15
+ fullscreenchange: [],
16
+ };
17
+ }
18
+ addEventListener(name, callback) {
19
+ this.listeners[name].push(callback);
20
+ }
21
+ removeEventListener(name, callback) {
22
+ this.listeners[name] = this.listeners[name].filter((l) => l !== callback);
23
+ }
24
+ dispatchEvent(dispatchName, context) {
25
+ this.listeners[dispatchName].forEach((callback) => {
26
+ callback({ detail: context });
27
+ });
28
+ }
29
+ dispatchSeek(frame) {
30
+ this.dispatchEvent('seeked', {
31
+ frame,
32
+ });
33
+ }
34
+ dispatchPause() {
35
+ this.dispatchEvent('pause', undefined);
36
+ }
37
+ dispatchPlay() {
38
+ this.dispatchEvent('play', undefined);
39
+ }
40
+ dispatchEnded() {
41
+ this.dispatchEvent('ended', undefined);
42
+ }
43
+ dispatchRatechange(playbackRate) {
44
+ this.dispatchEvent('ratechange', {
45
+ playbackRate,
46
+ });
47
+ }
48
+ dispatchError(error) {
49
+ this.dispatchEvent('error', {
50
+ error,
51
+ });
52
+ }
53
+ dispatchTimeUpdate(event) {
54
+ this.dispatchEvent('timeupdate', event);
55
+ }
56
+ dispatchFrameUpdate(event) {
57
+ this.dispatchEvent('frameupdate', event);
58
+ }
59
+ dispatchFullscreenChangeUpdate(event) {
60
+ this.dispatchEvent('fullscreenchange', event);
61
+ }
62
+ }
63
+ exports.PlayerEmitter = PlayerEmitter;
64
+ class ThumbnailEmitter {
65
+ constructor() {
66
+ this.listeners = {
67
+ error: [],
68
+ };
69
+ }
70
+ addEventListener(name, callback) {
71
+ this.listeners[name].push(callback);
72
+ }
73
+ removeEventListener(name, callback) {
74
+ this.listeners[name] = this.listeners[name].filter((l) => l !== callback);
75
+ }
76
+ dispatchEvent(dispatchName, context) {
77
+ this.listeners[dispatchName].forEach((callback) => {
78
+ callback({ detail: context });
79
+ });
80
+ }
81
+ dispatchError(error) {
82
+ this.dispatchEvent('error', {
83
+ error,
84
+ });
85
+ }
86
+ }
87
+ exports.ThumbnailEmitter = ThumbnailEmitter;
@@ -0,0 +1 @@
1
+ export declare const formatTime: (timeInSeconds: number) => string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatTime = void 0;
4
+ const formatTime = (timeInSeconds) => {
5
+ const minutes = Math.floor(timeInSeconds / 60);
6
+ const seconds = Math.floor(timeInSeconds - minutes * 60);
7
+ return `${String(minutes)}:${String(seconds).padStart(2, '0')}`;
8
+ };
9
+ exports.formatTime = formatTime;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export declare const ICON_SIZE = 25;
3
+ export declare const fullscreenIconSize = 16;
4
+ export declare const PlayIcon: React.FC;
5
+ export declare const PauseIcon: React.FC;
6
+ export declare const FullscreenIcon: React.FC<{
7
+ isFullscreen: boolean;
8
+ }>;
9
+ export declare const VolumeOffIcon: React.FC;
10
+ export declare const VolumeOnIcon: React.FC;
package/dist/icons.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VolumeOnIcon = exports.VolumeOffIcon = exports.FullscreenIcon = exports.PauseIcon = exports.PlayIcon = exports.fullscreenIconSize = exports.ICON_SIZE = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ exports.ICON_SIZE = 25;
6
+ exports.fullscreenIconSize = 16;
7
+ const rotate = {
8
+ transform: `rotate(90deg)`,
9
+ };
10
+ const PlayIcon = () => {
11
+ return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "-100 -100 400 400", style: rotate, children: (0, jsx_runtime_1.jsx)("path", { fill: "#fff", stroke: "#fff", strokeWidth: "100", strokeLinejoin: "round", d: "M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z" }) }));
12
+ };
13
+ exports.PlayIcon = PlayIcon;
14
+ const PauseIcon = () => {
15
+ return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 100 100", width: exports.ICON_SIZE, height: exports.ICON_SIZE, children: [(0, jsx_runtime_1.jsx)("rect", { x: "25", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" }), (0, jsx_runtime_1.jsx)("rect", { x: "55", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" })] }));
16
+ };
17
+ exports.PauseIcon = PauseIcon;
18
+ const FullscreenIcon = ({ isFullscreen, }) => {
19
+ const strokeWidth = 6;
20
+ const viewSize = 32;
21
+ const out = isFullscreen ? 0 : strokeWidth / 2;
22
+ const middleInset = isFullscreen ? strokeWidth * 1.6 : strokeWidth / 2;
23
+ const inset = isFullscreen ? strokeWidth * 1.6 : strokeWidth * 2;
24
+ return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${viewSize} ${viewSize}`, height: exports.fullscreenIconSize, width: exports.fullscreenIconSize, children: [(0, jsx_runtime_1.jsx)("path", { d: `
25
+ M ${out} ${inset}
26
+ L ${middleInset} ${middleInset}
27
+ L ${inset} ${out}
28
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }), (0, jsx_runtime_1.jsx)("path", { d: `
29
+ M ${viewSize - out} ${inset}
30
+ L ${viewSize - middleInset} ${middleInset}
31
+ L ${viewSize - inset} ${out}
32
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }), (0, jsx_runtime_1.jsx)("path", { d: `
33
+ M ${out} ${viewSize - inset}
34
+ L ${middleInset} ${viewSize - middleInset}
35
+ L ${inset} ${viewSize - out}
36
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }), (0, jsx_runtime_1.jsx)("path", { d: `
37
+ M ${viewSize - out} ${viewSize - inset}
38
+ L ${viewSize - middleInset} ${viewSize - middleInset}
39
+ L ${viewSize - inset} ${viewSize - out}
40
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" })] }));
41
+ };
42
+ exports.FullscreenIcon = FullscreenIcon;
43
+ const VolumeOffIcon = () => {
44
+ return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M3.63 3.63a.996.996 0 000 1.41L7.29 8.7 7 9H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71v-4.17l4.18 4.18c-.49.37-1.02.68-1.6.91-.36.15-.58.53-.58.92 0 .72.73 1.18 1.39.91.8-.33 1.55-.77 2.22-1.31l1.34 1.34a.996.996 0 101.41-1.41L5.05 3.63c-.39-.39-1.02-.39-1.42 0zM19 12c0 .82-.15 1.61-.41 2.34l1.53 1.53c.56-1.17.88-2.48.88-3.87 0-3.83-2.4-7.11-5.78-8.4-.59-.23-1.22.23-1.22.86v.19c0 .38.25.71.61.85C17.18 6.54 19 9.06 19 12zm-8.71-6.29l-.17.17L12 7.76V6.41c0-.89-1.08-1.33-1.71-.7zM16.5 12A4.5 4.5 0 0014 7.97v1.79l2.48 2.48c.01-.08.02-.16.02-.24z", fill: "#fff" }) }));
45
+ };
46
+ exports.VolumeOffIcon = VolumeOffIcon;
47
+ const VolumeOnIcon = () => {
48
+ return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M3 10v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71V6.41c0-.89-1.08-1.34-1.71-.71L7 9H4c-.55 0-1 .45-1 1zm13.5 2A4.5 4.5 0 0014 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 4.45v.2c0 .38.25.71.6.85C17.18 6.53 19 9.06 19 12s-1.82 5.47-4.4 6.5c-.36.14-.6.47-.6.85v.2c0 .63.63 1.07 1.21.85C18.6 19.11 21 15.84 21 12s-2.4-7.11-5.79-8.4c-.58-.23-1.21.22-1.21.85z", fill: "#fff" }) }));
49
+ };
50
+ exports.VolumeOnIcon = VolumeOnIcon;