remotion 4.0.0-alpha8 → 4.0.0-alpha9

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.
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType, PropsWithChildren } from 'react';
2
2
  import React from 'react';
3
- import type { z } from 'zod';
3
+ import type { AnyZodObject } from 'zod';
4
4
  import type { PropsIfHasProps } from './props-if-has-props.js';
5
5
  declare type LooseComponentType<T> = ComponentType<T> | ((props: T) => React.ReactNode);
6
6
  export declare type CompProps<Props> = {
@@ -10,13 +10,13 @@ export declare type CompProps<Props> = {
10
10
  } | {
11
11
  component: LooseComponentType<Props>;
12
12
  };
13
- export declare type StillProps<Schema extends z.ZodTypeAny, Props> = {
13
+ export declare type StillProps<Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined> = {
14
14
  width: number;
15
15
  height: number;
16
16
  id: string;
17
17
  schema?: Schema;
18
18
  } & CompProps<Props> & PropsIfHasProps<Schema, Props>;
19
- export declare type CompositionProps<Schema extends z.ZodTypeAny, Props> = StillProps<Schema, Props> & {
19
+ export declare type CompositionProps<Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined> = StillProps<Schema, Props> & {
20
20
  fps: number;
21
21
  durationInFrames: number;
22
22
  };
@@ -24,6 +24,6 @@ export declare type CompositionProps<Schema extends z.ZodTypeAny, Props> = Still
24
24
  * @description This component is used to register a video to make it renderable and make it show in the sidebar, in dev mode.
25
25
  * @see [Documentation](https://www.remotion.dev/docs/composition)
26
26
  */
27
- export declare const Composition: <Schema extends z.ZodTypeAny, Props>({ width, height, fps, durationInFrames, id, defaultProps, schema, ...compProps }: CompositionProps<Schema, Props>) => React.ReactPortal | null;
27
+ export declare const Composition: <Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined>({ width, height, fps, durationInFrames, id, defaultProps, schema, ...compProps }: CompositionProps<Schema, Props>) => React.ReactPortal | null;
28
28
  export declare const ClipComposition: React.FC<PropsWithChildren>;
29
29
  export {};
@@ -19,6 +19,7 @@ const portal_node_js_1 = require("./portal-node.js");
19
19
  const use_lazy_component_js_1 = require("./use-lazy-component.js");
20
20
  const use_video_js_1 = require("./use-video.js");
21
21
  const validate_composition_id_js_1 = require("./validation/validate-composition-id.js");
22
+ const validate_default_props_js_1 = require("./validation/validate-default-props.js");
22
23
  const validate_dimensions_js_1 = require("./validation/validate-dimensions.js");
23
24
  const validate_duration_in_frames_js_1 = require("./validation/validate-duration-in-frames.js");
24
25
  const validate_fps_js_1 = require("./validation/validate-fps.js");
@@ -64,6 +65,7 @@ const Composition = ({ width, height, fps, durationInFrames, id, defaultProps, s
64
65
  allowFloats: false,
65
66
  });
66
67
  (0, validate_fps_js_1.validateFps)(fps, 'as a prop of the <Composition/> component', false);
68
+ (0, validate_default_props_js_1.validateDefaultAndInputProps)(defaultProps, 'defaultProps', id);
67
69
  registerComposition({
68
70
  durationInFrames,
69
71
  fps,
@@ -1,9 +1,9 @@
1
1
  import type { ComponentType, LazyExoticComponent } from 'react';
2
2
  import React from 'react';
3
- import type { z } from 'zod';
3
+ import type { AnyZodObject } from 'zod';
4
4
  import type { TFolder } from './Folder.js';
5
5
  import type { PropsIfHasProps } from './props-if-has-props.js';
6
- export declare type TComposition<Schema extends z.ZodTypeAny, Props> = {
6
+ export declare type TComposition<Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined> = {
7
7
  width: number;
8
8
  height: number;
9
9
  fps: number;
@@ -15,11 +15,11 @@ export declare type TComposition<Schema extends z.ZodTypeAny, Props> = {
15
15
  nonce: number;
16
16
  schema: Schema | null;
17
17
  } & PropsIfHasProps<Schema, Props>;
18
- export declare type AnyComposition = TComposition<z.ZodTypeAny, unknown>;
19
- export declare type TCompMetadata<Schema extends z.ZodTypeAny, Props> = Pick<TComposition<Schema, Props>, 'id' | 'height' | 'width' | 'fps' | 'durationInFrames' | 'defaultProps'>;
20
- export declare type AnyCompMetadata = TCompMetadata<z.ZodTypeAny, unknown>;
21
- export declare type SmallTCompMetadata<T extends z.ZodTypeAny, Props> = Pick<TComposition<T, Props>, 'id' | 'height' | 'width' | 'fps' | 'durationInFrames'> & Partial<Pick<TComposition<T, Props>, 'defaultProps'>>;
22
- export declare type AnySmallCompMetadata = SmallTCompMetadata<z.ZodTypeAny, unknown>;
18
+ export declare type AnyComposition = TComposition<AnyZodObject, Record<string, unknown> | undefined>;
19
+ export declare type TCompMetadata<Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined> = Pick<TComposition<Schema, Props>, 'id' | 'height' | 'width' | 'fps' | 'durationInFrames' | 'defaultProps'>;
20
+ export declare type AnyCompMetadata = TCompMetadata<AnyZodObject, Record<string, unknown> | undefined>;
21
+ export declare type SmallTCompMetadata<T extends AnyZodObject, Props extends Record<string, unknown> | undefined> = Pick<TComposition<T, Props>, 'id' | 'height' | 'width' | 'fps' | 'durationInFrames'> & Partial<Pick<TComposition<T, Props>, 'defaultProps'>>;
22
+ export declare type AnySmallCompMetadata = SmallTCompMetadata<AnyZodObject, Record<string, unknown> | undefined>;
23
23
  declare type EnhancedTSequenceData = {
24
24
  type: 'sequence';
25
25
  } | {
@@ -66,7 +66,7 @@ export declare type TAsset = {
66
66
  declare type BaseMetadata = Pick<AnyCompMetadata, 'durationInFrames' | 'fps' | 'defaultProps' | 'height' | 'width'>;
67
67
  export declare type CompositionManagerContext = {
68
68
  compositions: AnyComposition[];
69
- registerComposition: <Schema extends z.ZodTypeAny, Props>(comp: TComposition<Schema, Props>) => void;
69
+ registerComposition: <Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined>(comp: TComposition<Schema, Props>) => void;
70
70
  unregisterComposition: (name: string) => void;
71
71
  registerFolder: (name: string, parent: string | null) => void;
72
72
  unregisterFolder: (name: string, parent: string | null) => void;
@@ -84,7 +84,7 @@ export declare type CompositionManagerContext = {
84
84
  };
85
85
  export declare const CompositionManager: React.Context<CompositionManagerContext>;
86
86
  export declare const compositionsRef: React.RefObject<{
87
- getCompositions: () => TCompMetadata<z.ZodTypeAny, unknown>[];
87
+ getCompositions: () => TCompMetadata<AnyZodObject, Record<string, unknown> | undefined>[];
88
88
  }>;
89
89
  export declare const CompositionManagerProvider: React.FC<{
90
90
  children: React.ReactNode;
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- declare type Props = Record<string, object>;
2
+ declare type Props = Record<string, Record<string, unknown>>;
3
3
  export declare type EditorPropsContextType = {
4
4
  props: Props;
5
5
  updateProps: (options: {
6
6
  id: string;
7
- defaultProps: object;
8
- newProps: object;
7
+ defaultProps: Record<string, unknown>;
8
+ newProps: Record<string, unknown> | ((oldProps: Record<string, unknown>) => Record<string, unknown>);
9
9
  }) => void;
10
10
  };
11
11
  export declare const EditorPropsContext: React.Context<EditorPropsContextType>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import type { z } from 'zod';
2
+ import type { AnyZodObject } from 'zod';
3
3
  import type { StillProps } from './Composition.js';
4
4
  /**
5
5
  * @description A <Still /> is a <Composition /> that is only 1 frame long.
6
6
  * @see [Documentation](https://www.remotion.dev/docs/still)
7
7
  */
8
- export declare const Still: <Schema extends z.ZodTypeAny, Props>(props: StillProps<Schema, Props>) => React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
8
+ export declare const Still: <Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined>(props: StillProps<Schema, Props>) => React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
@@ -40,7 +40,7 @@ export declare type BundleState = {
40
40
  } | {
41
41
  type: 'composition';
42
42
  compositionName: string;
43
- compositionDefaultProps: unknown;
43
+ compositionDefaultProps: Record<string, unknown>;
44
44
  compositionHeight: number;
45
45
  compositionDurationInFrames: number;
46
46
  compositionWidth: number;
@@ -23,13 +23,13 @@ export declare const Internals: {
23
23
  width: number;
24
24
  fps: number;
25
25
  durationInFrames: number;
26
- defaultProps?: unknown;
26
+ defaultProps?: Record<string, unknown> | undefined;
27
27
  id: string;
28
28
  folderName: string | null;
29
29
  parentFolderName: string | null;
30
- component: import("react").LazyExoticComponent<import("react").ComponentType<unknown>>;
30
+ component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown> | undefined>>;
31
31
  nonce: number;
32
- schema: import("zod").ZodTypeAny | null;
32
+ schema: import("zod").AnyZodObject | null;
33
33
  } | null;
34
34
  getRoot: () => import("react").FC<{}> | null;
35
35
  useMediaVolumeState: () => readonly [number, (u: number) => void];
@@ -52,6 +52,7 @@ export declare const Internals: {
52
52
  allowFloats: boolean;
53
53
  }) => void;
54
54
  validateFps: (fps: number, location: string, isGif: boolean) => void;
55
+ validateDefaultAndInputProps: (defaultProps: unknown, name: "defaultProps" | "inputProps", compositionId: string | null) => void;
55
56
  validateDimension: (amount: number, nameOfProp: string, location: string) => void;
56
57
  getRemotionEnvironment: () => RemotionEnvironment;
57
58
  SharedAudioContext: import("react").Context<{
@@ -79,7 +80,7 @@ export declare const Internals: {
79
80
  isCompositionIdValid: (id: string) => RegExpMatchArray | null;
80
81
  getPreviewDomElement: () => HTMLElement | null;
81
82
  compositionsRef: import("react").RefObject<{
82
- getCompositions: () => TCompMetadata<import("zod").ZodTypeAny, unknown>[];
83
+ getCompositions: () => TCompMetadata<import("zod").AnyZodObject, Record<string, unknown> | undefined>[];
83
84
  }>;
84
85
  DELAY_RENDER_CALLSTACK_TOKEN: string;
85
86
  portalNode: () => HTMLElement;
@@ -49,6 +49,7 @@ const use_unsafe_video_config_js_1 = require("./use-unsafe-video-config.js");
49
49
  const use_video_js_1 = require("./use-video.js");
50
50
  const validate_frame_js_1 = require("./validate-frame.js");
51
51
  const validate_composition_id_js_1 = require("./validation/validate-composition-id.js");
52
+ const validate_default_props_js_1 = require("./validation/validate-default-props.js");
52
53
  const validate_dimensions_js_1 = require("./validation/validate-dimensions.js");
53
54
  const validate_duration_in_frames_js_1 = require("./validation/validate-duration-in-frames.js");
54
55
  const validate_fps_js_1 = require("./validation/validate-fps.js");
@@ -79,6 +80,7 @@ exports.Internals = {
79
80
  SetMediaVolumeContext: volume_position_state_js_1.SetMediaVolumeContext,
80
81
  validateDurationInFrames: validate_duration_in_frames_js_1.validateDurationInFrames,
81
82
  validateFps: validate_fps_js_1.validateFps,
83
+ validateDefaultAndInputProps: validate_default_props_js_1.validateDefaultAndInputProps,
82
84
  validateDimension: validate_dimensions_js_1.validateDimension,
83
85
  getRemotionEnvironment: get_environment_js_1.getRemotionEnvironment,
84
86
  SharedAudioContext: shared_audio_tags_js_1.SharedAudioContext,
@@ -1,5 +1,5 @@
1
- import type { z } from 'zod';
2
- export declare type PropsIfHasProps<Schema extends z.ZodTypeAny, Props> = z.ZodTypeAny extends Schema ? {} extends Props ? {
1
+ import type { AnyZodObject, z } from 'zod';
2
+ export declare type PropsIfHasProps<Schema extends AnyZodObject, Props extends Record<string, unknown> | undefined> = AnyZodObject extends Schema ? {} extends Props ? {
3
3
  defaultProps?: Props;
4
4
  } : {
5
5
  defaultProps: Props;
@@ -50,15 +50,14 @@ function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durati
50
50
  throw new Error('did not calculate natural duration, this is an error with Remotion. Please report');
51
51
  },
52
52
  };
53
- const frame = reverse
53
+ const frame = (reverse
54
54
  ? (passedDurationInFrames !== null && passedDurationInFrames !== void 0 ? passedDurationInFrames : naturalDurationGetter.get()) - passedFrame
55
- : passedFrame;
55
+ : passedFrame) - delay;
56
56
  const spr = (0, spring_utils_js_1.springCalculation)({
57
57
  fps,
58
- frame: (passedDurationInFrames === undefined
58
+ frame: passedDurationInFrames === undefined
59
59
  ? frame
60
- : frame / (passedDurationInFrames / naturalDurationGetter.get())) -
61
- delay,
60
+ : frame / (passedDurationInFrames / naturalDurationGetter.get()),
62
61
  config,
63
62
  from,
64
63
  to,
@@ -4,11 +4,11 @@ export declare const useVideo: () => {
4
4
  width: number;
5
5
  fps: number;
6
6
  durationInFrames: number;
7
- defaultProps?: unknown;
7
+ defaultProps?: Record<string, unknown> | undefined;
8
8
  id: string;
9
9
  folderName: string | null;
10
10
  parentFolderName: string | null;
11
- component: import("react").LazyExoticComponent<import("react").ComponentType<unknown>>;
11
+ component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown> | undefined>>;
12
12
  nonce: number;
13
- schema: import("zod").ZodTypeAny | null;
13
+ schema: import("zod").AnyZodObject | null;
14
14
  } | null;
@@ -0,0 +1 @@
1
+ export declare const validateDefaultAndInputProps: (defaultProps: unknown, name: 'defaultProps' | 'inputProps', compositionId: string | null) => void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateDefaultAndInputProps = void 0;
4
+ const validateDefaultAndInputProps = (defaultProps, name, compositionId) => {
5
+ if (!defaultProps) {
6
+ return;
7
+ }
8
+ if (typeof defaultProps !== 'object') {
9
+ throw new Error(`"${name}" must be an object, but you passed a value of type ${typeof defaultProps}`);
10
+ }
11
+ if (Array.isArray(defaultProps)) {
12
+ throw new Error(`"${name}" must be an object, an array was passed ${compositionId ? `for composition "${compositionId}"` : ''}`);
13
+ }
14
+ };
15
+ exports.validateDefaultAndInputProps = validateDefaultAndInputProps;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.0-alpha8";
1
+ export declare const VERSION = "4.0.0-alpha9";
@@ -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.0.0-alpha8';
5
+ exports.VERSION = '4.0.0-alpha9';
@@ -58,7 +58,7 @@ function truthy(value) {
58
58
  }
59
59
 
60
60
  // Automatically generated on publish
61
- const VERSION = '4.0.0-alpha8';
61
+ const VERSION = '4.0.0-alpha9';
62
62
 
63
63
  const checkMultipleRemotionVersions = () => {
64
64
  if (typeof globalThis === 'undefined') {
@@ -2140,6 +2140,18 @@ const getRegex = () => /^([a-zA-Z0-9-])+$/g;
2140
2140
  const isCompositionIdValid = (id) => id.match(getRegex());
2141
2141
  const invalidCompositionErrorMessage = `Composition ID must match ${String(getRegex())}`;
2142
2142
 
2143
+ const validateDefaultAndInputProps = (defaultProps, name, compositionId) => {
2144
+ if (!defaultProps) {
2145
+ return;
2146
+ }
2147
+ if (typeof defaultProps !== 'object') {
2148
+ throw new Error(`"${name}" must be an object, but you passed a value of type ${typeof defaultProps}`);
2149
+ }
2150
+ if (Array.isArray(defaultProps)) {
2151
+ throw new Error(`"${name}" must be an object, an array was passed ${compositionId ? `for composition "${compositionId}"` : ''}`);
2152
+ }
2153
+ };
2154
+
2143
2155
  const validateDimension = (amount, nameOfProp, location) => {
2144
2156
  if (typeof amount !== 'number') {
2145
2157
  throw new Error(`The "${nameOfProp}" prop ${location} must be a number, but you passed a value of type ${typeof amount}`);
@@ -2218,6 +2230,7 @@ const Composition = ({ width, height, fps, durationInFrames, id, defaultProps, s
2218
2230
  allowFloats: false,
2219
2231
  });
2220
2232
  validateFps(fps, 'as a prop of the <Composition/> component', false);
2233
+ validateDefaultAndInputProps(defaultProps, 'defaultProps', id);
2221
2234
  registerComposition({
2222
2235
  durationInFrames,
2223
2236
  fps,
@@ -3290,6 +3303,7 @@ const Internals = {
3290
3303
  SetMediaVolumeContext,
3291
3304
  validateDurationInFrames,
3292
3305
  validateFps,
3306
+ validateDefaultAndInputProps,
3293
3307
  validateDimension,
3294
3308
  getRemotionEnvironment,
3295
3309
  SharedAudioContext,
@@ -3614,15 +3628,14 @@ function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durati
3614
3628
  throw new Error('did not calculate natural duration, this is an error with Remotion. Please report');
3615
3629
  },
3616
3630
  };
3617
- const frame = reverse
3631
+ const frame = (reverse
3618
3632
  ? (passedDurationInFrames !== null && passedDurationInFrames !== void 0 ? passedDurationInFrames : naturalDurationGetter.get()) - passedFrame
3619
- : passedFrame;
3633
+ : passedFrame) - delay;
3620
3634
  const spr = springCalculation({
3621
3635
  fps,
3622
- frame: (passedDurationInFrames === undefined
3636
+ frame: passedDurationInFrames === undefined
3623
3637
  ? frame
3624
- : frame / (passedDurationInFrames / naturalDurationGetter.get())) -
3625
- delay,
3638
+ : frame / (passedDurationInFrames / naturalDurationGetter.get()),
3626
3639
  config,
3627
3640
  from,
3628
3641
  to,
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.0-alpha8';
2
+ const VERSION = '4.0.0-alpha9';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.0-alpha8",
3
+ "version": "4.0.0-alpha9",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "@jonny/eslint-config": "3.0.273",
22
22
  "@rollup/plugin-typescript": "^8.2.0",
23
23
  "@testing-library/react": "14.0.0",
24
- "@types/node": "^16.7.5",
24
+ "@types/node": "18.14.6",
25
25
  "@types/react": "18.0.26",
26
26
  "@types/react-dom": "18.0.10",
27
27
  "@vitejs/plugin-react": "^2.0.0",
@@ -35,8 +35,8 @@
35
35
  "rimraf": "^3.0.2",
36
36
  "rollup": "^2.70.1",
37
37
  "typescript": "^4.7.0",
38
- "vitest": "0.24.3",
39
- "webpack": "5.76.1",
38
+ "vitest": "0.31.1",
39
+ "webpack": "5.83.1",
40
40
  "zod": "3.21.4"
41
41
  },
42
42
  "keywords": [
@@ -72,9 +72,10 @@
72
72
  }
73
73
  },
74
74
  "scripts": {
75
+ "formatting": "prettier src --check",
75
76
  "lint": "eslint src --ext ts,tsx",
76
77
  "test": "vitest --run",
77
- "build": "rollup --config rollup-version.config.js && rollup --config rollup.config.js && tsc -d",
78
+ "build": "tsc -d && rollup --config rollup-version.config.js && rollup --config rollup.config.js",
78
79
  "watch": "tsc -w"
79
80
  }
80
81
  }