remotion 4.1.0-alpha4 → 4.1.0-alpha7

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 (40) hide show
  1. package/dist/cjs/Composition.d.ts +24 -9
  2. package/dist/cjs/Composition.js +6 -17
  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/RemotionRoot.js +6 -4
  7. package/dist/cjs/ResolveCompositionConfig.js +24 -7
  8. package/dist/cjs/Still.d.ts +1 -1
  9. package/dist/cjs/audio/Audio.d.ts +1 -1
  10. package/dist/cjs/audio/shared-audio-tags.d.ts +1 -1
  11. package/dist/cjs/freeze.js +6 -2
  12. package/dist/cjs/index.d.ts +6 -6
  13. package/dist/cjs/index.js +1 -1
  14. package/dist/cjs/internals.d.ts +62 -60
  15. package/dist/cjs/internals.js +3 -0
  16. package/dist/cjs/loop/index.js +1 -2
  17. package/dist/cjs/props-if-has-props.d.ts +2 -2
  18. package/dist/cjs/resolve-video-config.d.ts +3 -2
  19. package/dist/cjs/resolve-video-config.js +23 -33
  20. package/dist/cjs/series/index.js +2 -3
  21. package/dist/cjs/spring/index.js +1 -1
  22. package/dist/cjs/static-file.js +11 -2
  23. package/dist/cjs/timeline-position-state.d.ts +5 -3
  24. package/dist/cjs/timeline-position-state.js +25 -7
  25. package/dist/cjs/use-unsafe-video-config.js +2 -1
  26. package/dist/cjs/use-video.d.ts +1 -1
  27. package/dist/cjs/use-video.js +3 -3
  28. package/dist/cjs/validation/validate-dimensions.d.ts +1 -1
  29. package/dist/cjs/validation/validate-dimensions.js +2 -2
  30. package/dist/cjs/validation/validate-duration-in-frames.d.ts +2 -3
  31. package/dist/cjs/validation/validate-duration-in-frames.js +6 -2
  32. package/dist/cjs/validation/validate-fps.d.ts +1 -1
  33. package/dist/cjs/validation/validate-fps.js +2 -2
  34. package/dist/cjs/version.d.ts +1 -1
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/cjs/video/OffthreadVideo.js +4 -2
  37. package/dist/cjs/video-config.d.ts +2 -1
  38. package/dist/esm/index.mjs +136 -99
  39. package/dist/esm/version.mjs +1 -1
  40. package/package.json +1 -1
@@ -8,45 +8,44 @@ import { processColor } from './interpolate-colors.js';
8
8
  import type { SetTimelineContextValue, TimelineContextValue } from './timeline-position-state.js';
9
9
  import * as TimelinePosition from './timeline-position-state.js';
10
10
  import { truthy } from './truthy.js';
11
+ import { validateDimension } from './validation/validate-dimensions.js';
12
+ import { validateDurationInFrames } from './validation/validate-duration-in-frames.js';
13
+ import { validateFps } from './validation/validate-fps.js';
11
14
  import type { MediaVolumeContextValue, SetMediaVolumeContextValue } from './volume-position-state.js';
12
15
  import { useRemotionContexts } from './wrap-remotion-context.js';
13
16
  declare const Timeline: typeof TimelinePosition;
14
17
  export declare const Internals: {
15
- useUnsafeVideoConfig: () => import("./video-config.js").VideoConfig | null;
16
- Timeline: typeof TimelinePosition;
17
- CompositionManager: import("react").Context<CompositionManagerContext>;
18
- SequenceManager: import("react").Context<import("./SequenceManager.js").SequenceManagerContext>;
19
- RemotionRoot: import("react").FC<{
18
+ readonly useUnsafeVideoConfig: () => import("./video-config.js").VideoConfig | null;
19
+ readonly Timeline: typeof TimelinePosition;
20
+ readonly CompositionManager: import("react").Context<CompositionManagerContext>;
21
+ readonly SequenceManager: import("react").Context<import("./SequenceManager.js").SequenceManagerContext>;
22
+ readonly RemotionRoot: import("react").FC<{
20
23
  children: import("react").ReactNode;
21
24
  numberOfAudioTags: number;
22
25
  }>;
23
- useVideo: () => (import("./video-config.js").VideoConfig & {
24
- component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown> | undefined>>;
26
+ readonly useVideo: () => (import("./video-config.js").VideoConfig & {
27
+ component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown>>>;
25
28
  }) | null;
26
- getRoot: () => import("react").FC<{}> | null;
27
- useMediaVolumeState: () => readonly [number, (u: number) => void];
28
- useMediaMutedState: () => readonly [boolean, (u: import("react").SetStateAction<boolean>) => void];
29
- useLazyComponent: <Props>(compProps: CompProps<Props>) => import("react").ExoticComponent<(import("react").PropsWithoutRef<Props> & import("react").RefAttributes<import("react").Component<Props, any, any>>) | import("react").PropsWithRef<Props>> & {
29
+ readonly getRoot: () => import("react").FC<{}> | null;
30
+ readonly useMediaVolumeState: () => readonly [number, (u: number) => void];
31
+ readonly useMediaMutedState: () => readonly [boolean, (u: import("react").SetStateAction<boolean>) => void];
32
+ readonly useLazyComponent: <Props>(compProps: CompProps<Props>) => import("react").ExoticComponent<(import("react").PropsWithoutRef<Props> & import("react").RefAttributes<import("react").Component<Props, any, any>>) | import("react").PropsWithRef<Props>> & {
30
33
  readonly _result: import("react").ComponentType<Props>;
31
34
  };
32
- truthy: typeof truthy;
33
- SequenceContext: import("react").Context<import("./SequenceContext.js").SequenceContextType | null>;
34
- useRemotionContexts: typeof useRemotionContexts;
35
- RemotionContextProvider: (props: import("./wrap-remotion-context.js").RemotionContextProviderProps) => JSX.Element;
36
- CSSUtils: typeof CSSUtils;
37
- setupEnvVariables: () => void;
38
- MediaVolumeContext: import("react").Context<MediaVolumeContextValue>;
39
- SetMediaVolumeContext: import("react").Context<SetMediaVolumeContextValue>;
40
- validateDurationInFrames: ({ allowFloats, component, durationInFrames, }: {
41
- durationInFrames: number;
42
- component: string;
43
- allowFloats: boolean;
44
- }) => void;
45
- validateFps: (fps: number, location: string, isGif: boolean) => void;
46
- validateDefaultAndInputProps: (defaultProps: unknown, name: "defaultProps" | "inputProps", compositionId: string | null) => void;
47
- validateDimension: (amount: number, nameOfProp: string, location: string) => void;
48
- getRemotionEnvironment: () => RemotionEnvironment;
49
- SharedAudioContext: import("react").Context<{
35
+ readonly truthy: typeof truthy;
36
+ readonly SequenceContext: import("react").Context<import("./SequenceContext.js").SequenceContextType | null>;
37
+ readonly useRemotionContexts: typeof useRemotionContexts;
38
+ readonly RemotionContextProvider: (props: import("./wrap-remotion-context.js").RemotionContextProviderProps) => JSX.Element;
39
+ readonly CSSUtils: typeof CSSUtils;
40
+ readonly setupEnvVariables: () => void;
41
+ readonly MediaVolumeContext: import("react").Context<MediaVolumeContextValue>;
42
+ readonly SetMediaVolumeContext: import("react").Context<SetMediaVolumeContextValue>;
43
+ readonly validateDurationInFrames: typeof validateDurationInFrames;
44
+ readonly validateFps: typeof validateFps;
45
+ readonly validateDefaultAndInputProps: (defaultProps: unknown, name: "defaultProps" | "inputProps", compositionId: string | null) => void;
46
+ readonly validateDimension: typeof validateDimension;
47
+ readonly getRemotionEnvironment: () => RemotionEnvironment;
48
+ readonly SharedAudioContext: import("react").Context<{
50
49
  registerAudio: (aud: import("./index.js").RemotionAudioProps, audioId: string) => {
51
50
  id: number;
52
51
  props: import("./index.js").RemotionAudioProps;
@@ -62,53 +61,54 @@ export declare const Internals: {
62
61
  playAllAudios: () => void;
63
62
  numberOfAudioTags: number;
64
63
  } | null>;
65
- SharedAudioContextProvider: import("react").FC<{
64
+ readonly SharedAudioContextProvider: import("react").FC<{
66
65
  numberOfAudioTags: number;
67
66
  children: import("react").ReactNode;
68
- component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown> | undefined>> | null;
67
+ component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown>>> | null;
69
68
  }>;
70
- invalidCompositionErrorMessage: string;
71
- isCompositionIdValid: (id: string) => RegExpMatchArray | null;
72
- getPreviewDomElement: () => HTMLElement | null;
73
- compositionsRef: import("react").RefObject<{
74
- getCompositions: () => import("./CompositionManager.js").TCompMetadataWithCalcFunction<import("zod").AnyZodObject, Record<string, unknown> | undefined>[];
69
+ readonly invalidCompositionErrorMessage: string;
70
+ readonly isCompositionIdValid: (id: string) => RegExpMatchArray | null;
71
+ readonly getPreviewDomElement: () => HTMLElement | null;
72
+ readonly compositionsRef: import("react").RefObject<{
73
+ getCompositions: () => import("./CompositionManager.js").TCompMetadataWithCalcFunction<import("zod").AnyZodObject, Record<string, unknown>>[];
75
74
  }>;
76
- DELAY_RENDER_CALLSTACK_TOKEN: string;
77
- portalNode: () => HTMLElement;
78
- waitForRoot: (fn: (comp: import("react").FC<{}>) => void) => () => void;
79
- CanUseRemotionHooksProvider: import("react").FC<{
75
+ readonly DELAY_RENDER_CALLSTACK_TOKEN: "The delayRender was called:";
76
+ readonly portalNode: () => HTMLElement;
77
+ readonly waitForRoot: (fn: (comp: import("react").FC<{}>) => void) => () => void;
78
+ readonly CanUseRemotionHooksProvider: import("react").FC<{
80
79
  children: import("react").ReactNode;
81
80
  }>;
82
- CanUseRemotionHooks: import("react").Context<boolean>;
83
- PrefetchProvider: import("react").FC<{
81
+ readonly CanUseRemotionHooks: import("react").Context<boolean>;
82
+ readonly PrefetchProvider: import("react").FC<{
84
83
  children: import("react").ReactNode;
85
84
  }>;
86
- DurationsContextProvider: import("react").FC<{
85
+ readonly DurationsContextProvider: import("react").FC<{
87
86
  children: import("react").ReactNode;
88
87
  }>;
89
- IsPlayerContextProvider: import("react").FC<{
88
+ readonly IsPlayerContextProvider: import("react").FC<{
90
89
  children?: import("react").ReactNode;
91
90
  }>;
92
- useIsPlayer: () => boolean;
93
- useRemotionEnvironment: () => RemotionEnvironment;
94
- validateFrame: ({ allowFloats, durationInFrames, frame, }: {
91
+ readonly useIsPlayer: () => boolean;
92
+ readonly useRemotionEnvironment: () => RemotionEnvironment;
93
+ readonly validateFrame: ({ allowFloats, durationInFrames, frame, }: {
95
94
  frame: number;
96
95
  durationInFrames: number;
97
96
  allowFloats: boolean;
98
97
  }) => void;
99
- EditorPropsProvider: import("react").FC<{
98
+ readonly EditorPropsProvider: import("react").FC<{
100
99
  children: import("react").ReactNode;
101
100
  }>;
102
- EditorPropsContext: import("react").Context<import("./EditorProps.js").EditorPropsContextType>;
103
- usePreload: (src: string) => string;
104
- processColor: typeof processColor;
105
- NonceContext: import("react").Context<import("./nonce.js").TNonceContext>;
106
- resolveVideoConfig: ({ composition, editorProps: editorPropsOrUndefined, signal, }: {
107
- composition: import("./CompositionManager.js").TCompMetadataWithCalcFunction<import("zod").AnyZodObject, Record<string, unknown> | undefined>;
101
+ readonly EditorPropsContext: import("react").Context<import("./EditorProps.js").EditorPropsContextType>;
102
+ readonly usePreload: (src: string) => string;
103
+ readonly processColor: typeof processColor;
104
+ readonly NonceContext: import("react").Context<import("./nonce.js").TNonceContext>;
105
+ readonly resolveVideoConfig: ({ composition, editorProps: editorPropsOrUndefined, signal, inputProps, }: {
106
+ composition: import("./CompositionManager.js").TCompMetadataWithCalcFunction<import("zod").AnyZodObject, Record<string, unknown>>;
108
107
  editorProps: object;
109
108
  signal: AbortSignal;
109
+ inputProps: Record<string, unknown>;
110
110
  }) => import("./video-config.js").VideoConfig | Promise<import("./video-config.js").VideoConfig>;
111
- useResolvedVideoConfig: (preferredCompositionId: string | null) => ({
111
+ readonly useResolvedVideoConfig: (preferredCompositionId: string | null) => ({
112
112
  type: "loading";
113
113
  } | {
114
114
  type: "success";
@@ -117,15 +117,17 @@ export declare const Internals: {
117
117
  type: "error";
118
118
  error: Error;
119
119
  }) | null;
120
- resolveCompositionsRef: import("react").RefObject<{
120
+ readonly resolveCompositionsRef: import("react").RefObject<{
121
121
  setCurrentRenderModalComposition: (compositionId: string | null) => void;
122
122
  reloadCurrentlySelectedComposition: () => void;
123
123
  }>;
124
- ResolveCompositionConfig: import("react").FC<import("react").PropsWithChildren<{
124
+ readonly ResolveCompositionConfig: import("react").FC<import("react").PropsWithChildren<{
125
125
  children: import("react").ReactNode;
126
126
  }>>;
127
- REMOTION_STUDIO_CONTAINER_ELEMENT: string;
128
- AssetManager: import("react").Context<import("./AssetManager.js").AssetManagerContext>;
129
- bundleName: string;
127
+ readonly REMOTION_STUDIO_CONTAINER_ELEMENT: "__remotion-studio-container";
128
+ readonly AssetManager: import("react").Context<import("./AssetManager.js").AssetManagerContext>;
129
+ readonly bundleName: "bundle.js";
130
+ readonly persistCurrentFrame: (frame: number, composition: string) => void;
131
+ readonly useTimelineSetFrame: () => (u: import("react").SetStateAction<Record<string, number>>) => void;
130
132
  };
131
133
  export type { TComposition, Timeline, TCompMetadata, TSequence, TAsset, TimelineContextValue, SetTimelineContextValue, CompProps, CompositionManagerContext, MediaVolumeContextValue, SetMediaVolumeContextValue, RemotionEnvironment, };
@@ -47,6 +47,7 @@ const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
47
47
  const SequenceContext_js_1 = require("./SequenceContext.js");
48
48
  const SequenceManager_js_1 = require("./SequenceManager.js");
49
49
  const setup_env_variables_js_1 = require("./setup-env-variables.js");
50
+ const timeline_position_state_js_1 = require("./timeline-position-state.js");
50
51
  const TimelinePosition = __importStar(require("./timeline-position-state.js"));
51
52
  const truthy_js_1 = require("./truthy.js");
52
53
  const use_lazy_component_js_1 = require("./use-lazy-component.js");
@@ -117,4 +118,6 @@ exports.Internals = {
117
118
  REMOTION_STUDIO_CONTAINER_ELEMENT: get_preview_dom_element_js_1.REMOTION_STUDIO_CONTAINER_ELEMENT,
118
119
  AssetManager: AssetManager_js_1.AssetManager,
119
120
  bundleName: 'bundle.js',
121
+ persistCurrentFrame: timeline_position_state_js_1.persistCurrentFrame,
122
+ useTimelineSetFrame: timeline_position_state_js_1.useTimelineSetFrame,
120
123
  };
@@ -14,8 +14,7 @@ const validate_duration_in_frames_js_1 = require("../validation/validate-duratio
14
14
  const Loop = ({ durationInFrames, times = Infinity, children, name, ...props }) => {
15
15
  const currentFrame = (0, use_current_frame_js_1.useCurrentFrame)();
16
16
  const { durationInFrames: compDuration } = (0, use_video_config_js_1.useVideoConfig)();
17
- (0, validate_duration_in_frames_js_1.validateDurationInFrames)({
18
- durationInFrames,
17
+ (0, validate_duration_in_frames_js_1.validateDurationInFrames)(durationInFrames, {
19
18
  component: 'of the <Loop /> component',
20
19
  allowFloats: true,
21
20
  });
@@ -1,10 +1,10 @@
1
1
  import type { AnyZodObject, z } from 'zod';
2
2
  type And<A extends boolean, B extends boolean> = A extends true ? B extends true ? true : false : false;
3
- export type PropsIfHasProps<Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined> = And<AnyZodObject extends Schema ? true : false, {} extends Props ? true : false> extends true ? {
3
+ export type PropsIfHasProps<Schema extends AnyZodObject, Props extends Record<string, unknown>> = And<AnyZodObject extends Schema ? true : false, {} extends Props ? true : false> extends true ? {
4
4
  defaultProps?: {};
5
5
  } : {
6
6
  defaultProps: InferProps<Schema, Props>;
7
7
  };
8
- export type InferProps<Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined> = AnyZodObject extends Schema ? {} extends Props ? Record<string, unknown> : Props : {} extends Props ? z.infer<Schema> : // Props and schema specified
8
+ export type InferProps<Schema extends AnyZodObject, Props extends Record<string, unknown>> = AnyZodObject extends Schema ? {} extends Props ? Record<string, unknown> : Props : {} extends Props ? z.infer<Schema> : // Props and schema specified
9
9
  z.infer<Schema> & Props;
10
10
  export {};
@@ -1,8 +1,9 @@
1
1
  import type { AnyZodObject } from 'zod';
2
2
  import type { TCompMetadataWithCalcFunction } from './CompositionManager.js';
3
3
  import type { VideoConfig } from './video-config.js';
4
- export declare const resolveVideoConfig: ({ composition, editorProps: editorPropsOrUndefined, signal, }: {
5
- composition: TCompMetadataWithCalcFunction<AnyZodObject, Record<string, unknown> | undefined>;
4
+ export declare const resolveVideoConfig: ({ composition, editorProps: editorPropsOrUndefined, signal, inputProps, }: {
5
+ composition: TCompMetadataWithCalcFunction<AnyZodObject, Record<string, unknown>>;
6
6
  editorProps: object;
7
7
  signal: AbortSignal;
8
+ inputProps: Record<string, unknown>;
8
9
  }) => VideoConfig | Promise<VideoConfig>;
@@ -1,23 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveVideoConfig = void 0;
4
- const input_props_js_1 = require("./config/input-props.js");
5
- const get_environment_js_1 = require("./get-environment.js");
6
4
  const validate_dimensions_js_1 = require("./validation/validate-dimensions.js");
7
5
  const validate_duration_in_frames_js_1 = require("./validation/validate-duration-in-frames.js");
8
- const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined, signal, }) => {
9
- var _a, _b, _c, _d, _e, _f;
6
+ const validate_fps_js_1 = require("./validation/validate-fps.js");
7
+ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined, signal, inputProps, }) => {
8
+ var _a, _b, _c, _d, _e, _f, _g;
10
9
  const calculatedProm = composition.calculateMetadata
11
10
  ? composition.calculateMetadata({
12
11
  defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
13
12
  props: {
14
13
  ...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
15
14
  ...(editorPropsOrUndefined !== null && editorPropsOrUndefined !== void 0 ? editorPropsOrUndefined : {}),
16
- ...(typeof window === 'undefined' ||
17
- (0, get_environment_js_1.getRemotionEnvironment)() === 'player-development' ||
18
- (0, get_environment_js_1.getRemotionEnvironment)() === 'player-production'
19
- ? {}
20
- : (_c = (0, input_props_js_1.getInputProps)()) !== null && _c !== void 0 ? _c : {}),
15
+ ...inputProps,
21
16
  },
22
17
  abortSignal: signal,
23
18
  })
@@ -26,7 +21,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
26
21
  typeof calculatedProm === 'object' &&
27
22
  'then' in calculatedProm) {
28
23
  return calculatedProm.then((c) => {
29
- var _a, _b;
24
+ var _a, _b, _c;
30
25
  const { height, width, durationInFrames, fps } = validateCalculated({
31
26
  calculated: c,
32
27
  composition,
@@ -37,7 +32,8 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
37
32
  fps,
38
33
  durationInFrames,
39
34
  id: composition.id,
40
- defaultProps: (_b = (_a = c.props) !== null && _a !== void 0 ? _a : composition.defaultProps) !== null && _b !== void 0 ? _b : {},
35
+ defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
36
+ props: (_c = (_b = c.props) !== null && _b !== void 0 ? _b : composition.defaultProps) !== null && _c !== void 0 ? _c : {},
41
37
  };
42
38
  });
43
39
  }
@@ -49,41 +45,35 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
49
45
  return {
50
46
  ...data,
51
47
  id: composition.id,
52
- defaultProps: (_d = composition === null || composition === void 0 ? void 0 : composition.defaultProps) !== null && _d !== void 0 ? _d : {},
48
+ defaultProps: (_c = composition.defaultProps) !== null && _c !== void 0 ? _c : {},
49
+ props: {
50
+ ...((_d = composition.defaultProps) !== null && _d !== void 0 ? _d : {}),
51
+ ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
52
+ },
53
53
  };
54
54
  }
55
55
  return {
56
56
  ...data,
57
57
  id: composition.id,
58
- defaultProps: (_f = (_e = calculatedProm === null || calculatedProm === void 0 ? void 0 : calculatedProm.props) !== null && _e !== void 0 ? _e : composition.defaultProps) !== null && _f !== void 0 ? _f : {},
58
+ defaultProps: (_e = composition.defaultProps) !== null && _e !== void 0 ? _e : {},
59
+ props: (_g = (_f = calculatedProm.props) !== null && _f !== void 0 ? _f : composition.defaultProps) !== null && _g !== void 0 ? _g : {},
59
60
  };
60
61
  };
61
62
  exports.resolveVideoConfig = resolveVideoConfig;
62
63
  const validateCalculated = ({ composition, calculated, }) => {
63
64
  var _a, _b, _c, _d, _e, _f, _g, _h;
64
- const potentialErrorLocation = `calculated by calculateMetadata() for the composition "${composition.id}"`;
65
- const width = (_b = (_a = calculated === null || calculated === void 0 ? void 0 : calculated.width) !== null && _a !== void 0 ? _a : composition.width) !== null && _b !== void 0 ? _b : null;
66
- if (!width) {
67
- throw new TypeError('Composition width was neither specified via the `width` prop nor the `calculateMetadata()` function.');
68
- }
69
- (0, validate_dimensions_js_1.validateDimension)(width, 'width', potentialErrorLocation);
70
- const height = (_d = (_c = calculated === null || calculated === void 0 ? void 0 : calculated.height) !== null && _c !== void 0 ? _c : composition.height) !== null && _d !== void 0 ? _d : null;
71
- if (!height) {
72
- throw new TypeError('Composition height was neither specified via the `height` prop nor the `calculateMetadata()` function.');
73
- }
74
- (0, validate_dimensions_js_1.validateDimension)(width, 'height', potentialErrorLocation);
65
+ const calculateMetadataErrorLocation = `calculated by calculateMetadata() for the composition "${composition.id}"`;
66
+ const defaultErrorLocation = `of the "<Composition />" component with the id "${composition.id}"`;
67
+ const width = (_b = (_a = calculated === null || calculated === void 0 ? void 0 : calculated.width) !== null && _a !== void 0 ? _a : composition.width) !== null && _b !== void 0 ? _b : undefined;
68
+ (0, validate_dimensions_js_1.validateDimension)(width, 'width', (calculated === null || calculated === void 0 ? void 0 : calculated.width) ? calculateMetadataErrorLocation : defaultErrorLocation);
69
+ const height = (_d = (_c = calculated === null || calculated === void 0 ? void 0 : calculated.height) !== null && _c !== void 0 ? _c : composition.height) !== null && _d !== void 0 ? _d : undefined;
70
+ (0, validate_dimensions_js_1.validateDimension)(height, 'height', (calculated === null || calculated === void 0 ? void 0 : calculated.height) ? calculateMetadataErrorLocation : defaultErrorLocation);
75
71
  const fps = (_f = (_e = calculated === null || calculated === void 0 ? void 0 : calculated.fps) !== null && _e !== void 0 ? _e : composition.fps) !== null && _f !== void 0 ? _f : null;
76
- if (!fps) {
77
- throw new TypeError('Composition fps was neither specified via the `fps` prop nor the `calculateMetadata()` function.');
78
- }
72
+ (0, validate_fps_js_1.validateFps)(fps, (calculated === null || calculated === void 0 ? void 0 : calculated.fps) ? calculateMetadataErrorLocation : defaultErrorLocation, false);
79
73
  const durationInFrames = (_h = (_g = calculated === null || calculated === void 0 ? void 0 : calculated.durationInFrames) !== null && _g !== void 0 ? _g : composition.durationInFrames) !== null && _h !== void 0 ? _h : null;
80
- if (!durationInFrames) {
81
- throw new TypeError('Composition durationInFrames was neither specified via the `durationInFrames` prop nor the `calculateMetadata()` function.');
82
- }
83
- (0, validate_duration_in_frames_js_1.validateDurationInFrames)({
84
- durationInFrames,
85
- component: potentialErrorLocation,
74
+ (0, validate_duration_in_frames_js_1.validateDurationInFrames)(durationInFrames, {
86
75
  allowFloats: false,
76
+ component: `of the "<Composition />" component with the id "${composition.id}"`,
87
77
  });
88
78
  return { width, height, fps, durationInFrames };
89
79
  };
@@ -38,11 +38,10 @@ const Series = ({ children }) => {
38
38
  throw new TypeError(`A <Series.Sequence /> component (${debugInfo}) was detected to not have any children. Delete it to fix this error.`);
39
39
  }
40
40
  const durationInFramesProp = castedChild.props.durationInFrames;
41
- const { durationInFrames, children: _children, ...passedProps } = castedChild.props;
41
+ const { durationInFrames, children: _children, from, ...passedProps } = castedChild.props; // `from` is not accepted and must be filtered out if used in JS
42
42
  if (i !== flattenedChildren.length - 1 ||
43
43
  durationInFramesProp !== Infinity) {
44
- (0, validate_duration_in_frames_js_1.validateDurationInFrames)({
45
- durationInFrames: durationInFramesProp,
44
+ (0, validate_duration_in_frames_js_1.validateDurationInFrames)(durationInFramesProp, {
46
45
  component: `of a <Series.Sequence /> component`,
47
46
  allowFloats: true,
48
47
  });
@@ -52,7 +52,7 @@ function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durati
52
52
  };
53
53
  const frame = (reverse
54
54
  ? (passedDurationInFrames !== null && passedDurationInFrames !== void 0 ? passedDurationInFrames : naturalDurationGetter.get()) - passedFrame
55
- : passedFrame) - delay;
55
+ : passedFrame) - (reverse ? -delay : delay);
56
56
  const spr = (0, spring_utils_js_1.springCalculation)({
57
57
  fps,
58
58
  frame: passedDurationInFrames === undefined
@@ -49,6 +49,14 @@ const inner = (path) => {
49
49
  }
50
50
  return `/${trimLeadingSlash(path)}`;
51
51
  };
52
+ const encodeBySplitting = (path) => {
53
+ const splitBySlash = path.split('/');
54
+ const encodedArray = splitBySlash.map((element) => {
55
+ return encodeURIComponent(element);
56
+ });
57
+ const merged = encodedArray.join('/');
58
+ return merged;
59
+ };
52
60
  /**
53
61
  * @description Reference a file from the public/ folder. If the file does not appear in the autocomplete, type the path manually.
54
62
  * @see [Documentation](https://www.remotion.dev/docs/staticfile)
@@ -76,9 +84,10 @@ const staticFile = (path) => {
76
84
  }
77
85
  const includesHex = (0, exports.includesHexOfUnsafeChar)(path);
78
86
  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() `);
87
+ warnOnce(`WARNING: You seem to pass an already encoded path (path contains ${includesHex.hexCode}). Since Remotion 4.0, the encoding is done by staticFile() itself. You may want to remove a encodeURIComponent() wrapping.`);
80
88
  }
81
- const preparsed = inner(encodeURIComponent(path));
89
+ const preprocessed = encodeBySplitting(path);
90
+ const preparsed = inner(preprocessed);
82
91
  if (!preparsed.startsWith('/')) {
83
92
  return `/${preparsed}`;
84
93
  }
@@ -4,7 +4,7 @@ export type PlayableMediaTag = {
4
4
  id: string;
5
5
  };
6
6
  export type TimelineContextValue = {
7
- frame: number;
7
+ frame: Record<string, number>;
8
8
  playing: boolean;
9
9
  rootId: string;
10
10
  playbackRate: number;
@@ -13,13 +13,15 @@ export type TimelineContextValue = {
13
13
  audioAndVideoTags: MutableRefObject<PlayableMediaTag[]>;
14
14
  };
15
15
  export type SetTimelineContextValue = {
16
- setFrame: (u: React.SetStateAction<number>) => void;
16
+ setFrame: (u: React.SetStateAction<Record<string, number>>) => void;
17
17
  setPlaying: (u: React.SetStateAction<boolean>) => void;
18
18
  };
19
19
  export declare const TimelineContext: import("react").Context<TimelineContextValue>;
20
20
  export declare const SetTimelineContext: import("react").Context<SetTimelineContextValue>;
21
+ export declare const persistCurrentFrame: (frame: number, composition: string) => void;
22
+ export declare const getFrameForComposition: (composition: string) => number;
21
23
  export declare const useTimelinePosition: () => number;
22
- export declare const useTimelineSetFrame: () => (u: React.SetStateAction<number>) => void;
24
+ export declare const useTimelineSetFrame: () => (u: React.SetStateAction<Record<string, number>>) => void;
23
25
  type PlayingReturnType = readonly [
24
26
  boolean,
25
27
  (u: React.SetStateAction<boolean>) => void,
@@ -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-alpha4";
1
+ export declare const VERSION = "4.1.0-alpha7";
@@ -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-alpha4';
5
+ exports.VERSION = '4.1.0-alpha7';