remotion 4.1.0-alpha1 → 4.1.0-alpha11

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 (49) 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/ResolveCompositionConfig.js +24 -7
  10. package/dist/cjs/Still.d.ts +1 -1
  11. package/dist/cjs/audio/AudioForDevelopment.js +1 -1
  12. package/dist/cjs/audio/shared-audio-tags.d.ts +1 -1
  13. package/dist/cjs/audio/shared-audio-tags.js +5 -1
  14. package/dist/cjs/config/input-props.d.ts +1 -1
  15. package/dist/cjs/config/input-props.js +2 -1
  16. package/dist/cjs/delay-render.js +22 -14
  17. package/dist/cjs/freeze.js +6 -2
  18. package/dist/cjs/index.d.ts +17 -7
  19. package/dist/cjs/index.js +1 -1
  20. package/dist/cjs/input-props-serialization.d.ts +15 -0
  21. package/dist/cjs/input-props-serialization.js +49 -0
  22. package/dist/cjs/internals.d.ts +80 -62
  23. package/dist/cjs/internals.js +13 -0
  24. package/dist/cjs/loop/index.js +1 -2
  25. package/dist/cjs/props-if-has-props.d.ts +2 -2
  26. package/dist/cjs/resolve-video-config.d.ts +3 -2
  27. package/dist/cjs/resolve-video-config.js +23 -33
  28. package/dist/cjs/series/index.js +2 -3
  29. package/dist/cjs/spring/index.js +1 -1
  30. package/dist/cjs/static-file.js +11 -2
  31. package/dist/cjs/timeline-position-state.d.ts +5 -3
  32. package/dist/cjs/timeline-position-state.js +25 -7
  33. package/dist/cjs/use-unsafe-video-config.js +2 -1
  34. package/dist/cjs/use-video.d.ts +1 -1
  35. package/dist/cjs/use-video.js +3 -3
  36. package/dist/cjs/validation/validate-dimensions.d.ts +1 -1
  37. package/dist/cjs/validation/validate-dimensions.js +2 -2
  38. package/dist/cjs/validation/validate-duration-in-frames.d.ts +2 -3
  39. package/dist/cjs/validation/validate-duration-in-frames.js +6 -2
  40. package/dist/cjs/validation/validate-fps.d.ts +1 -1
  41. package/dist/cjs/validation/validate-fps.js +2 -2
  42. package/dist/cjs/version.d.ts +1 -1
  43. package/dist/cjs/version.js +1 -1
  44. package/dist/cjs/video/OffthreadVideo.js +6 -3
  45. package/dist/cjs/video/OffthreadVideoForRendering.js +8 -2
  46. package/dist/cjs/video-config.d.ts +2 -1
  47. package/dist/esm/index.mjs +323 -214
  48. package/dist/esm/version.mjs +1 -1
  49. package/package.json +2 -2
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // Must keep this file in sync with the one in packages/lambda/src/shared/serialize-props.ts!
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.deserializeJSONWithCustomFields = exports.serializeJSONWithDate = exports.FILE_TOKEN = exports.DATE_TOKEN = void 0;
5
+ const static_file_js_1 = require("./static-file.js");
6
+ exports.DATE_TOKEN = 'remotion-date:';
7
+ exports.FILE_TOKEN = 'remotion-file:';
8
+ const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
9
+ let customDateUsed = false;
10
+ let customFileUsed = false;
11
+ let mapUsed = false;
12
+ let setUsed = false;
13
+ const serializedString = JSON.stringify(data, function (key, value) {
14
+ const item = this[key];
15
+ if (item instanceof Date) {
16
+ customDateUsed = true;
17
+ return `${exports.DATE_TOKEN}${item.toISOString()}`;
18
+ }
19
+ if (item instanceof Map) {
20
+ mapUsed = true;
21
+ return value;
22
+ }
23
+ if (item instanceof Set) {
24
+ setUsed = true;
25
+ return value;
26
+ }
27
+ if (typeof item === 'string' &&
28
+ staticBase !== null &&
29
+ item.startsWith(staticBase)) {
30
+ customFileUsed = true;
31
+ return `${exports.FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
32
+ }
33
+ return value;
34
+ }, indent);
35
+ return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
36
+ };
37
+ exports.serializeJSONWithDate = serializeJSONWithDate;
38
+ const deserializeJSONWithCustomFields = (data) => {
39
+ return JSON.parse(data, (_, value) => {
40
+ if (typeof value === 'string' && value.startsWith(exports.DATE_TOKEN)) {
41
+ return new Date(value.replace(exports.DATE_TOKEN, ''));
42
+ }
43
+ if (typeof value === 'string' && value.startsWith(exports.FILE_TOKEN)) {
44
+ return (0, static_file_js_1.staticFile)(value.replace(exports.FILE_TOKEN, ''));
45
+ }
46
+ return value;
47
+ });
48
+ };
49
+ exports.deserializeJSONWithCustomFields = deserializeJSONWithCustomFields;
@@ -1,52 +1,52 @@
1
1
  /// <reference types="react" />
2
- import type { CompProps } from './Composition.js';
2
+ import { type CompProps } from './Composition.js';
3
3
  import type { TAsset, TCompMetadata, TComposition, TSequence } from './CompositionManager.js';
4
4
  import type { CompositionManagerContext } from './CompositionManagerContext.js';
5
5
  import * as CSSUtils from './default-css.js';
6
6
  import type { RemotionEnvironment } from './get-environment.js';
7
+ import type { SerializedJSONWithCustomFields } from './input-props-serialization.js';
7
8
  import { processColor } from './interpolate-colors.js';
8
9
  import type { SetTimelineContextValue, TimelineContextValue } from './timeline-position-state.js';
9
10
  import * as TimelinePosition from './timeline-position-state.js';
10
11
  import { truthy } from './truthy.js';
12
+ import { validateDimension } from './validation/validate-dimensions.js';
13
+ import { validateDurationInFrames } from './validation/validate-duration-in-frames.js';
14
+ import { validateFps } from './validation/validate-fps.js';
11
15
  import type { MediaVolumeContextValue, SetMediaVolumeContextValue } from './volume-position-state.js';
12
16
  import { useRemotionContexts } from './wrap-remotion-context.js';
13
17
  declare const Timeline: typeof TimelinePosition;
14
18
  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<{
19
+ readonly useUnsafeVideoConfig: () => import("./video-config.js").VideoConfig | null;
20
+ readonly Timeline: typeof TimelinePosition;
21
+ readonly CompositionManager: import("react").Context<CompositionManagerContext>;
22
+ readonly SequenceManager: import("react").Context<import("./SequenceManager.js").SequenceManagerContext>;
23
+ readonly RemotionRoot: import("react").FC<{
20
24
  children: import("react").ReactNode;
21
25
  numberOfAudioTags: number;
22
26
  }>;
23
- useVideo: () => (import("./video-config.js").VideoConfig & {
24
- component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown> | undefined>>;
27
+ readonly useVideo: () => (import("./video-config.js").VideoConfig & {
28
+ component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown>>>;
25
29
  }) | 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>> & {
30
+ readonly getRoot: () => import("react").FC<{}> | null;
31
+ readonly useMediaVolumeState: () => readonly [number, (u: number) => void];
32
+ readonly useMediaMutedState: () => readonly [boolean, (u: import("react").SetStateAction<boolean>) => void];
33
+ 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
34
  readonly _result: import("react").ComponentType<Props>;
31
35
  };
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<{
36
+ readonly truthy: typeof truthy;
37
+ readonly SequenceContext: import("react").Context<import("./SequenceContext.js").SequenceContextType | null>;
38
+ readonly useRemotionContexts: typeof useRemotionContexts;
39
+ readonly RemotionContextProvider: (props: import("./wrap-remotion-context.js").RemotionContextProviderProps) => JSX.Element;
40
+ readonly CSSUtils: typeof CSSUtils;
41
+ readonly setupEnvVariables: () => void;
42
+ readonly MediaVolumeContext: import("react").Context<MediaVolumeContextValue>;
43
+ readonly SetMediaVolumeContext: import("react").Context<SetMediaVolumeContextValue>;
44
+ readonly validateDurationInFrames: typeof validateDurationInFrames;
45
+ readonly validateFps: typeof validateFps;
46
+ readonly validateDefaultAndInputProps: (defaultProps: unknown, name: "defaultProps" | "inputProps", compositionId: string | null) => void;
47
+ readonly validateDimension: typeof validateDimension;
48
+ readonly getRemotionEnvironment: () => RemotionEnvironment;
49
+ readonly SharedAudioContext: import("react").Context<{
50
50
  registerAudio: (aud: import("./index.js").RemotionAudioProps, audioId: string) => {
51
51
  id: number;
52
52
  props: import("./index.js").RemotionAudioProps;
@@ -62,53 +62,54 @@ export declare const Internals: {
62
62
  playAllAudios: () => void;
63
63
  numberOfAudioTags: number;
64
64
  } | null>;
65
- SharedAudioContextProvider: import("react").FC<{
65
+ readonly SharedAudioContextProvider: import("react").FC<{
66
66
  numberOfAudioTags: number;
67
67
  children: import("react").ReactNode;
68
- component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown> | undefined>> | null;
68
+ component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown>>> | null;
69
69
  }>;
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>[];
70
+ readonly invalidCompositionErrorMessage: string;
71
+ readonly isCompositionIdValid: (id: string) => RegExpMatchArray | null;
72
+ readonly getPreviewDomElement: () => HTMLElement | null;
73
+ readonly compositionsRef: import("react").RefObject<{
74
+ getCompositions: () => import("./CompositionManager.js").TCompMetadataWithCalcFunction<import("zod").AnyZodObject, Record<string, unknown>>[];
75
75
  }>;
76
- DELAY_RENDER_CALLSTACK_TOKEN: string;
77
- portalNode: () => HTMLElement;
78
- waitForRoot: (fn: (comp: import("react").FC<{}>) => void) => () => void;
79
- CanUseRemotionHooksProvider: import("react").FC<{
76
+ readonly DELAY_RENDER_CALLSTACK_TOKEN: "The delayRender was called:";
77
+ readonly portalNode: () => HTMLElement;
78
+ readonly waitForRoot: (fn: (comp: import("react").FC<{}>) => void) => () => void;
79
+ readonly CanUseRemotionHooksProvider: import("react").FC<{
80
80
  children: import("react").ReactNode;
81
81
  }>;
82
- CanUseRemotionHooks: import("react").Context<boolean>;
83
- PrefetchProvider: import("react").FC<{
82
+ readonly CanUseRemotionHooks: import("react").Context<boolean>;
83
+ readonly PrefetchProvider: import("react").FC<{
84
84
  children: import("react").ReactNode;
85
85
  }>;
86
- DurationsContextProvider: import("react").FC<{
86
+ readonly DurationsContextProvider: import("react").FC<{
87
87
  children: import("react").ReactNode;
88
88
  }>;
89
- IsPlayerContextProvider: import("react").FC<{
89
+ readonly IsPlayerContextProvider: import("react").FC<{
90
90
  children?: import("react").ReactNode;
91
91
  }>;
92
- useIsPlayer: () => boolean;
93
- useRemotionEnvironment: () => RemotionEnvironment;
94
- validateFrame: ({ allowFloats, durationInFrames, frame, }: {
92
+ readonly useIsPlayer: () => boolean;
93
+ readonly useRemotionEnvironment: () => RemotionEnvironment;
94
+ readonly validateFrame: ({ allowFloats, durationInFrames, frame, }: {
95
95
  frame: number;
96
96
  durationInFrames: number;
97
97
  allowFloats: boolean;
98
98
  }) => void;
99
- EditorPropsProvider: import("react").FC<{
99
+ readonly EditorPropsProvider: import("react").FC<{
100
100
  children: import("react").ReactNode;
101
101
  }>;
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>;
102
+ readonly EditorPropsContext: import("react").Context<import("./EditorProps.js").EditorPropsContextType>;
103
+ readonly usePreload: (src: string) => string;
104
+ readonly processColor: typeof processColor;
105
+ readonly NonceContext: import("react").Context<import("./nonce.js").TNonceContext>;
106
+ readonly resolveVideoConfig: ({ composition, editorProps: editorPropsOrUndefined, signal, inputProps, }: {
107
+ composition: import("./CompositionManager.js").TCompMetadataWithCalcFunction<import("zod").AnyZodObject, Record<string, unknown>>;
108
108
  editorProps: object;
109
109
  signal: AbortSignal;
110
+ inputProps: Record<string, unknown>;
110
111
  }) => import("./video-config.js").VideoConfig | Promise<import("./video-config.js").VideoConfig>;
111
- useResolvedVideoConfig: (preferredCompositionId: string | null) => ({
112
+ readonly useResolvedVideoConfig: (preferredCompositionId: string | null) => ({
112
113
  type: "loading";
113
114
  } | {
114
115
  type: "success";
@@ -117,15 +118,32 @@ export declare const Internals: {
117
118
  type: "error";
118
119
  error: Error;
119
120
  }) | null;
120
- resolveCompositionsRef: import("react").RefObject<{
121
+ readonly resolveCompositionsRef: import("react").RefObject<{
121
122
  setCurrentRenderModalComposition: (compositionId: string | null) => void;
122
123
  reloadCurrentlySelectedComposition: () => void;
123
124
  }>;
124
- ResolveCompositionConfig: import("react").FC<import("react").PropsWithChildren<{
125
+ readonly ResolveCompositionConfig: import("react").FC<import("react").PropsWithChildren<{
125
126
  children: import("react").ReactNode;
126
127
  }>>;
127
- REMOTION_STUDIO_CONTAINER_ELEMENT: string;
128
- AssetManager: import("react").Context<import("./AssetManager.js").AssetManagerContext>;
129
- bundleName: string;
128
+ readonly REMOTION_STUDIO_CONTAINER_ELEMENT: "__remotion-studio-container";
129
+ readonly AssetManager: import("react").Context<import("./AssetManager.js").AssetManagerContext>;
130
+ readonly bundleName: "bundle.js";
131
+ readonly bundleMapName: "bundle.js.map";
132
+ readonly persistCurrentFrame: (frame: number, composition: string) => void;
133
+ readonly useTimelineSetFrame: () => (u: import("react").SetStateAction<Record<string, number>>) => void;
134
+ readonly serializeJSONWithDate: ({ data, indent, staticBase, }: {
135
+ data: Record<string, unknown>;
136
+ indent: number | undefined;
137
+ staticBase: string | null;
138
+ }) => SerializedJSONWithCustomFields;
139
+ readonly deserializeJSONWithCustomFields: (data: string) => Record<string, unknown>;
140
+ readonly FILE_TOKEN: "remotion-file:";
141
+ readonly DATE_TOKEN: "remotion-date:";
142
+ readonly NativeLayersProvider: import("react").FC<{
143
+ children?: import("react").ReactNode;
144
+ }>;
145
+ readonly ClipComposition: import("react").FC<{
146
+ children?: import("react").ReactNode;
147
+ }>;
130
148
  };
131
- export type { TComposition, Timeline, TCompMetadata, TSequence, TAsset, TimelineContextValue, SetTimelineContextValue, CompProps, CompositionManagerContext, MediaVolumeContextValue, SetMediaVolumeContextValue, RemotionEnvironment, };
149
+ export type { TComposition, Timeline, TCompMetadata, TSequence, TAsset, TimelineContextValue, SetTimelineContextValue, CompProps, CompositionManagerContext, MediaVolumeContextValue, SetMediaVolumeContextValue, RemotionEnvironment, SerializedJSONWithCustomFields, };
@@ -27,6 +27,7 @@ exports.Internals = void 0;
27
27
  const AssetManager_js_1 = require("./AssetManager.js");
28
28
  const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
29
29
  const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
30
+ const Composition_js_1 = require("./Composition.js");
30
31
  const CompositionManager_js_1 = require("./CompositionManager.js");
31
32
  const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
32
33
  const CSSUtils = __importStar(require("./default-css.js"));
@@ -34,8 +35,10 @@ const delay_render_js_1 = require("./delay-render.js");
34
35
  const EditorProps_js_1 = require("./EditorProps.js");
35
36
  const get_environment_js_1 = require("./get-environment.js");
36
37
  const get_preview_dom_element_js_1 = require("./get-preview-dom-element.js");
38
+ const input_props_serialization_js_1 = require("./input-props-serialization.js");
37
39
  const interpolate_colors_js_1 = require("./interpolate-colors.js");
38
40
  const is_player_js_1 = require("./is-player.js");
41
+ const NativeLayers_js_1 = require("./NativeLayers.js");
39
42
  const nonce_js_1 = require("./nonce.js");
40
43
  const portal_node_js_1 = require("./portal-node.js");
41
44
  const prefetch_state_js_1 = require("./prefetch-state.js");
@@ -48,6 +51,7 @@ const SequenceContext_js_1 = require("./SequenceContext.js");
48
51
  const SequenceManager_js_1 = require("./SequenceManager.js");
49
52
  const setup_env_variables_js_1 = require("./setup-env-variables.js");
50
53
  const TimelinePosition = __importStar(require("./timeline-position-state.js"));
54
+ const timeline_position_state_js_1 = require("./timeline-position-state.js");
51
55
  const truthy_js_1 = require("./truthy.js");
52
56
  const use_lazy_component_js_1 = require("./use-lazy-component.js");
53
57
  const use_unsafe_video_config_js_1 = require("./use-unsafe-video-config.js");
@@ -117,4 +121,13 @@ exports.Internals = {
117
121
  REMOTION_STUDIO_CONTAINER_ELEMENT: get_preview_dom_element_js_1.REMOTION_STUDIO_CONTAINER_ELEMENT,
118
122
  AssetManager: AssetManager_js_1.AssetManager,
119
123
  bundleName: 'bundle.js',
124
+ bundleMapName: 'bundle.js.map',
125
+ persistCurrentFrame: timeline_position_state_js_1.persistCurrentFrame,
126
+ useTimelineSetFrame: timeline_position_state_js_1.useTimelineSetFrame,
127
+ serializeJSONWithDate: input_props_serialization_js_1.serializeJSONWithDate,
128
+ deserializeJSONWithCustomFields: input_props_serialization_js_1.deserializeJSONWithCustomFields,
129
+ FILE_TOKEN: input_props_serialization_js_1.FILE_TOKEN,
130
+ DATE_TOKEN: input_props_serialization_js_1.DATE_TOKEN,
131
+ NativeLayersProvider: NativeLayers_js_1.NativeLayersProvider,
132
+ ClipComposition: Composition_js_1.ClipComposition,
120
133
  };
@@ -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]);