remotion 4.1.0-alpha1 → 4.1.0-alpha10

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 (51) hide show
  1. package/dist/cjs/Composition.d.ts +26 -10
  2. package/dist/cjs/Composition.js +8 -18
  3. package/dist/cjs/CompositionManager.d.ts +11 -12
  4. package/dist/cjs/CompositionManagerContext.d.ts +4 -3
  5. package/dist/cjs/Img.d.ts +1 -1
  6. package/dist/cjs/Img.js +2 -2
  7. package/dist/cjs/NativeLayers.js +5 -4
  8. package/dist/cjs/RemotionRoot.js +6 -4
  9. package/dist/cjs/RenderAssetManager.d.ts +11 -0
  10. package/dist/cjs/RenderAssetManager.js +40 -0
  11. package/dist/cjs/ResolveCompositionConfig.js +24 -7
  12. package/dist/cjs/Still.d.ts +1 -1
  13. package/dist/cjs/audio/AudioForDevelopment.js +1 -1
  14. package/dist/cjs/audio/shared-audio-tags.d.ts +1 -1
  15. package/dist/cjs/audio/shared-audio-tags.js +5 -1
  16. package/dist/cjs/config/input-props.d.ts +1 -1
  17. package/dist/cjs/config/input-props.js +2 -1
  18. package/dist/cjs/delay-render.js +22 -14
  19. package/dist/cjs/freeze.js +6 -2
  20. package/dist/cjs/index.d.ts +17 -7
  21. package/dist/cjs/index.js +1 -1
  22. package/dist/cjs/input-props-serialization.d.ts +15 -0
  23. package/dist/cjs/input-props-serialization.js +49 -0
  24. package/dist/cjs/internals.d.ts +80 -62
  25. package/dist/cjs/internals.js +13 -0
  26. package/dist/cjs/loop/index.js +1 -2
  27. package/dist/cjs/props-if-has-props.d.ts +2 -2
  28. package/dist/cjs/resolve-video-config.d.ts +3 -2
  29. package/dist/cjs/resolve-video-config.js +23 -33
  30. package/dist/cjs/series/index.js +2 -3
  31. package/dist/cjs/spring/index.js +1 -1
  32. package/dist/cjs/static-file.js +11 -2
  33. package/dist/cjs/timeline-position-state.d.ts +5 -3
  34. package/dist/cjs/timeline-position-state.js +25 -7
  35. package/dist/cjs/use-unsafe-video-config.js +2 -1
  36. package/dist/cjs/use-video.d.ts +1 -1
  37. package/dist/cjs/use-video.js +3 -3
  38. package/dist/cjs/validation/validate-dimensions.d.ts +1 -1
  39. package/dist/cjs/validation/validate-dimensions.js +2 -2
  40. package/dist/cjs/validation/validate-duration-in-frames.d.ts +2 -3
  41. package/dist/cjs/validation/validate-duration-in-frames.js +6 -2
  42. package/dist/cjs/validation/validate-fps.d.ts +1 -1
  43. package/dist/cjs/validation/validate-fps.js +2 -2
  44. package/dist/cjs/version.d.ts +1 -1
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/cjs/video/OffthreadVideo.js +6 -3
  47. package/dist/cjs/video/OffthreadVideoForRendering.js +8 -2
  48. package/dist/cjs/video-config.d.ts +2 -1
  49. package/dist/esm/index.mjs +323 -214
  50. package/dist/esm/version.mjs +1 -1
  51. package/package.json +2 -2
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.SetTimelineContext = exports.TimelineContext = void 0;
3
+ exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.getFrameForComposition = exports.persistCurrentFrame = exports.SetTimelineContext = exports.TimelineContext = void 0;
4
4
  const react_1 = require("react");
5
5
  const use_video_js_1 = require("./use-video.js");
6
6
  exports.TimelineContext = (0, react_1.createContext)({
7
- frame: 0,
7
+ frame: {},
8
8
  playing: false,
9
9
  playbackRate: 1,
10
10
  rootId: '',
@@ -24,16 +24,34 @@ exports.SetTimelineContext = (0, react_1.createContext)({
24
24
  throw new Error('default');
25
25
  },
26
26
  });
27
+ const makeKey = (composition) => {
28
+ return `remotion.time.${composition}`;
29
+ };
30
+ const persistCurrentFrame = (frame, composition) => {
31
+ localStorage.setItem(makeKey(composition), String(frame));
32
+ };
33
+ exports.persistCurrentFrame = persistCurrentFrame;
34
+ const getFrameForComposition = (composition) => {
35
+ var _a, _b;
36
+ const frame = localStorage.getItem(makeKey(composition));
37
+ return frame
38
+ ? Number(frame)
39
+ : (_b = (typeof window === 'undefined' ? 0 : (_a = window.remotion_initialFrame) !== null && _a !== void 0 ? _a : 0)) !== null && _b !== void 0 ? _b : 0;
40
+ };
41
+ exports.getFrameForComposition = getFrameForComposition;
27
42
  const useTimelinePosition = () => {
43
+ var _a, _b;
28
44
  const videoConfig = (0, use_video_js_1.useVideo)();
29
45
  const state = (0, react_1.useContext)(exports.TimelineContext);
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
46
  if (!videoConfig) {
34
- return state.frame;
47
+ return typeof window === 'undefined'
48
+ ? 0
49
+ : (_a = window.remotion_initialFrame) !== null && _a !== void 0 ? _a : 0;
35
50
  }
36
- return Math.min(videoConfig.durationInFrames - 1, state.frame);
51
+ const unclamped = (_b = state.frame[videoConfig.id]) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && window.remotion_isPlayer
52
+ ? 0
53
+ : (0, exports.getFrameForComposition)(videoConfig.id));
54
+ return Math.min(videoConfig.durationInFrames - 1, unclamped);
37
55
  };
38
56
  exports.useTimelinePosition = useTimelinePosition;
39
57
  const useTimelineSetFrame = () => {
@@ -13,7 +13,7 @@ const useUnsafeVideoConfig = () => {
13
13
  if (!video) {
14
14
  return null;
15
15
  }
16
- const { id, durationInFrames, fps, height, width, defaultProps } = video;
16
+ const { id, durationInFrames, fps, height, width, defaultProps, props } = video;
17
17
  return {
18
18
  id,
19
19
  width,
@@ -21,6 +21,7 @@ const useUnsafeVideoConfig = () => {
21
21
  fps,
22
22
  durationInFrames: ctxDuration !== null && ctxDuration !== void 0 ? ctxDuration : durationInFrames,
23
23
  defaultProps,
24
+ props,
24
25
  };
25
26
  }, [ctxDuration, video]);
26
27
  };
@@ -1,7 +1,7 @@
1
1
  import type { ComponentType, LazyExoticComponent } from 'react';
2
2
  import type { VideoConfig } from './video-config.js';
3
3
  type ReturnType = (VideoConfig & {
4
- component: LazyExoticComponent<ComponentType<Record<string, unknown> | undefined>>;
4
+ component: LazyExoticComponent<ComponentType<Record<string, unknown>>>;
5
5
  }) | null;
6
6
  export declare const useVideo: () => ReturnType;
7
7
  export {};
@@ -11,7 +11,7 @@ const useVideo = () => {
11
11
  });
12
12
  const resolved = (0, ResolveCompositionConfig_js_1.useResolvedVideoConfig)(context.currentComposition);
13
13
  return (0, react_1.useMemo)(() => {
14
- var _a;
14
+ var _a, _b;
15
15
  if (!resolved) {
16
16
  return null;
17
17
  }
@@ -26,11 +26,11 @@ const useVideo = () => {
26
26
  }
27
27
  return {
28
28
  ...resolved.result,
29
- defaultProps: selected.defaultProps,
29
+ defaultProps: (_a = selected.defaultProps) !== null && _a !== void 0 ? _a : {},
30
30
  id: selected.id,
31
31
  // We override the selected metadata with the metadata that was passed to renderMedia(),
32
32
  // and don't allow it to be changed during render anymore
33
- ...((_a = context.currentCompositionMetadata) !== null && _a !== void 0 ? _a : {}),
33
+ ...((_b = context.currentCompositionMetadata) !== null && _b !== void 0 ? _b : {}),
34
34
  component: selected.component,
35
35
  };
36
36
  }, [context.currentCompositionMetadata, resolved, selected]);
@@ -1 +1 @@
1
- export declare const validateDimension: (amount: number, nameOfProp: string, location: string) => void;
1
+ export declare function validateDimension(amount: unknown, nameOfProp: string, location: string): asserts amount is number;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateDimension = void 0;
4
- const validateDimension = (amount, nameOfProp, location) => {
4
+ function validateDimension(amount, nameOfProp, location) {
5
5
  if (typeof amount !== 'number') {
6
6
  throw new Error(`The "${nameOfProp}" prop ${location} must be a number, but you passed a value of type ${typeof amount}`);
7
7
  }
@@ -17,5 +17,5 @@ const validateDimension = (amount, nameOfProp, location) => {
17
17
  if (amount <= 0) {
18
18
  throw new TypeError(`The "${nameOfProp}" prop ${location} must be positive, but got ${amount}.`);
19
19
  }
20
- };
20
+ }
21
21
  exports.validateDimension = validateDimension;
@@ -1,5 +1,4 @@
1
- export declare const validateDurationInFrames: ({ allowFloats, component, durationInFrames, }: {
2
- durationInFrames: number;
1
+ export declare function validateDurationInFrames(durationInFrames: unknown, options: {
3
2
  component: string;
4
3
  allowFloats: boolean;
5
- }) => void;
4
+ }): asserts durationInFrames is number;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateDurationInFrames = void 0;
4
- const validateDurationInFrames = ({ allowFloats, component, durationInFrames, }) => {
4
+ function validateDurationInFrames(durationInFrames, options) {
5
+ const { allowFloats, component } = options;
6
+ if (typeof durationInFrames === 'undefined') {
7
+ throw new Error(`The "durationInFrames" prop ${component} is missing.`);
8
+ }
5
9
  if (typeof durationInFrames !== 'number') {
6
10
  throw new Error(`The "durationInFrames" prop ${component} must be a number, but you passed a value of type ${typeof durationInFrames}`);
7
11
  }
@@ -14,5 +18,5 @@ const validateDurationInFrames = ({ allowFloats, component, durationInFrames, })
14
18
  if (!Number.isFinite(durationInFrames)) {
15
19
  throw new TypeError(`The "durationInFrames" prop ${component} must be finite, but got ${durationInFrames}.`);
16
20
  }
17
- };
21
+ }
18
22
  exports.validateDurationInFrames = validateDurationInFrames;
@@ -1 +1 @@
1
- export declare const validateFps: (fps: number, location: string, isGif: boolean) => void;
1
+ export declare function validateFps(fps: unknown, location: string, isGif: boolean): asserts fps is number;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateFps = void 0;
4
- const validateFps = (fps, location, isGif) => {
4
+ function validateFps(fps, location, isGif) {
5
5
  if (typeof fps !== 'number') {
6
6
  throw new Error(`"fps" must be a number, but you passed a value of type ${typeof fps} ${location}`);
7
7
  }
@@ -17,5 +17,5 @@ const validateFps = (fps, location, isGif) => {
17
17
  if (isGif && fps > 50) {
18
18
  throw new TypeError(`The FPS for a GIF cannot be higher than 50. Use the --every-nth-frame option to lower the FPS: https://remotion.dev/docs/render-as-gif`);
19
19
  }
20
- };
20
+ }
21
21
  exports.validateFps = validateFps;
@@ -1 +1 @@
1
- export declare const VERSION = "4.1.0-alpha1";
1
+ export declare const VERSION = "4.1.0-alpha10";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.1.0-alpha1';
5
+ exports.VERSION = '4.1.0-alpha10';
@@ -14,7 +14,9 @@ const VideoForDevelopment_js_1 = require("./VideoForDevelopment.js");
14
14
  * @see [Documentation](https://www.remotion.dev/docs/offthreadvideo)
15
15
  */
16
16
  const OffthreadVideo = (props) => {
17
- const { startFrom, endAt, imageFormat, ...otherProps } = props;
17
+ // Should only destruct `startFrom` and `endAt` from props,
18
+ // rest gets drilled down
19
+ const { startFrom, endAt, ...otherProps } = props;
18
20
  const environment = (0, get_environment_js_1.useRemotionEnvironment)();
19
21
  const onDuration = (0, react_1.useCallback)(() => undefined, []);
20
22
  if (typeof props.src !== 'string') {
@@ -31,8 +33,9 @@ const OffthreadVideo = (props) => {
31
33
  }
32
34
  (0, validate_media_props_js_1.validateMediaProps)(props, 'Video');
33
35
  if (environment === 'rendering') {
34
- return ((0, jsx_runtime_1.jsx)(OffthreadVideoForRendering_js_1.OffthreadVideoForRendering, { imageFormat: imageFormat, ...otherProps }));
36
+ return (0, jsx_runtime_1.jsx)(OffthreadVideoForRendering_js_1.OffthreadVideoForRendering, { ...otherProps });
35
37
  }
36
- return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_js_1.VideoForDevelopment, { onDuration: onDuration, onlyWarnForMediaSeekingError: true, ...otherProps }));
38
+ const { transparent, ...withoutTransparent } = otherProps;
39
+ return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_js_1.VideoForDevelopment, { onDuration: onDuration, onlyWarnForMediaSeekingError: true, ...withoutTransparent }));
37
40
  };
38
41
  exports.OffthreadVideo = OffthreadVideo;
@@ -6,6 +6,7 @@ const react_1 = require("react");
6
6
  const absolute_src_js_1 = require("../absolute-src.js");
7
7
  const AssetManager_js_1 = require("../AssetManager.js");
8
8
  const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
9
+ const cancel_render_js_1 = require("../cancel-render.js");
9
10
  const default_css_js_1 = require("../default-css.js");
10
11
  const Img_js_1 = require("../Img.js");
11
12
  const random_js_1 = require("../random.js");
@@ -91,8 +92,13 @@ const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate,
91
92
  return `http://localhost:${window.remotion_proxyPort}/proxy?src=${encodeURIComponent((0, absolute_src_js_1.getAbsoluteSrc)(src))}&time=${encodeURIComponent(currentTime)}&transparent=${String(transparent)}`;
92
93
  }, [currentTime, src, transparent]);
93
94
  const onErr = (0, react_1.useCallback)((e) => {
94
- onError === null || onError === void 0 ? void 0 : onError(e);
95
- }, [onError]);
95
+ if (onError) {
96
+ onError === null || onError === void 0 ? void 0 : onError(e);
97
+ }
98
+ else {
99
+ (0, cancel_render_js_1.cancelRender)('Failed to load image with src ' + actualSrc);
100
+ }
101
+ }, [actualSrc, onError]);
96
102
  const className = (0, react_1.useMemo)(() => {
97
103
  return [default_css_js_1.OFFTHREAD_VIDEO_CLASS_NAME, props.className]
98
104
  .filter(truthy_js_1.truthy)
@@ -4,5 +4,6 @@ export type VideoConfig = {
4
4
  fps: number;
5
5
  durationInFrames: number;
6
6
  id: string;
7
- defaultProps: Record<string, unknown> | undefined;
7
+ defaultProps: Record<string, unknown>;
8
+ props: Record<string, unknown>;
8
9
  };