🎥 Make videos programmatically with React
alright
Jonny Burgera334c0af7f49
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsxindex fb6a261a94..c70786f79c 100644--- a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx+++ b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx@@ -106,13 +106,29 @@ export const RenderModalData: React.FC<{const z = useZodIfPossible();- if (!z) {- throw Error('expected zod to be installed');- }+ const schema = useMemo(() => {+ if (!z) {+ return 'no-zod' as const;+ }++ if (!composition.schema) {+ return z.any();+ }- const schema = composition.schema ?? z.any();+ if (!(typeof composition.schema.safeParse === 'function')) {+ throw new Error(+ 'A value which is not a Zod schema was passed to `schema`'+ );+ }++ return composition.schema;+ }, [composition.schema, z]);const zodValidationResult = useMemo(() => {+ if (schema === 'no-zod') {+ return 'no-zod' as const;+ }+return schema.safeParse(inputProps);}, [inputProps, schema]);@@ -208,15 +224,23 @@ export const RenderModalData: React.FC<{);}- const def: Zod.ZodTypeDef = schema._def;- // eslint-disable-next-line @typescript-eslint/no-explicit-any- const typeName = (def as any).typeName as Zod.ZodFirstPartyTypeKind;-- if (!z) {+ if (schema === 'no-zod') {// TODO: Make nicer modal for Zodreturn <div>Install zod</div>;}+ if (!z) {+ throw new Error('expected zod');+ }++ if (zodValidationResult === 'no-zod') {+ throw new Error('expected zod');+ }++ const def: Zod.ZodTypeDef = schema._def;+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ const typeName = (def as any).typeName as Zod.ZodFirstPartyTypeKind;+if (typeName === z.ZodFirstPartyTypeKind.ZodAny) {return <NoSchemaDefined />;}diff --git a/packages/example-without-zod/package.json b/packages/example-without-zod/package.jsonnew file mode 100644index 0000000000..eaaba3af04--- /dev/null+++ b/packages/example-without-zod/package.json@@ -0,0 +1,24 @@+{+ "name": "@remotion/example-without-zod",+ "private": true,+ "version": "3.3.84",+ "description": "",+ "license": "SEE LICENSE IN LICENSE.md",+ "author": "Jonny Burger",+ "main": "dist/index.js",+ "scripts": {+ "start": "remotion preview",+ "build": "tsc -d",+ "render": "remotion render react-svg"+ },+ "dependencies": {+ "remotion": "workspace:*",+ "react": "^18.2.0",+ "react-dom": "^18.2.0",+ "typescript": "^4.7.0"+ },+ "devDependencies": {+ "@types/react": "^18.0.38",+ "@types/react-dom": "^18.0.11"+ }+}diff --git a/packages/example-without-zod/src/comp-type-tests.tsx b/packages/example-without-zod/src/comp-type-tests.tsxnew file mode 100644index 0000000000..a59c5b7846--- /dev/null+++ b/packages/example-without-zod/src/comp-type-tests.tsx@@ -0,0 +1,72 @@+import React from "react";+import { Still } from "remotion";+// Test file just for making sure the types are sound++type MyComponentProps = {+ a: number;+ b: string;+};++function MyComponent(props: MyComponentProps) {+ return (+ <div>+ {props.a} {props.b}+ </div>+ );+}++<Still+ component={MyComponent}+ height={1080}+ width={1080}+ id="comps"+ defaultProps={{ a: 3, b: "2" }}+/>;++<Still+ component={MyComponent}+ height={1080}+ width={1080}+ id="comps"+ // @ts-expect-error C should not be allowed+ defaultProps={{ c: "2" }}+/>;++// React.FC syntax+const MyComponent2: React.FC<{+ c: number;+}> = ({ c }) => {+ return <div>{c}</div>;+};++<Still+ component={MyComponent2}+ height={1080}+ width={1080}+ id="comps"+ defaultProps={{ c: 2 }}+/>;++// React.FC syntax+const MyComponent3: React.FC<{+ a: number;+}> = ({ a }) => {+ return <div>{a}</div>;+};++// No more optional types+// @ts-expect-error Should be a type error+<Still component={MyComponent3} height={1080} width={1080} id="hithere" />;+<Still+ component={MyComponent3}+ height={1080}+ width={1080}+ id="hithere"+ defaultProps={{ a: 2 }}+/>;++const CompWithNoProps: React.FC = () => {+ return <div />;+};++<Still component={CompWithNoProps} height={1080} width={1080} id="no-props" />;diff --git a/packages/example-without-zod/tsconfig.json b/packages/example-without-zod/tsconfig.jsonnew file mode 100644index 0000000000..3d0e8d0b4b--- /dev/null+++ b/packages/example-without-zod/tsconfig.json@@ -0,0 +1,22 @@+{+ "extends": "../tsconfig.settings.json",+ "compilerOptions": {+ "rootDir": "./src",+ "outDir": "./dist",+ "jsx": "react-jsx",+ "skipLibCheck": true,+ "allowSyntheticDefaultImports": true,+ "paths": {+ "lib/*": ["./src/lib/*"]+ }+ },+ "include": ["src"],+ "references": [+ { "path": "../core" },+ { "path": "../media-utils" },+ { "path": "../babel-loader" },+ { "path": "../three" },+ { "path": "../rive" },+ { "path": "../motion-blur" }+ ]+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 15e515f658..fc86cd4008 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -594,6 +594,23 @@ importers:eslint-plugin-react-hooks: [email protected]prettier-plugin-organize-imports: 2.3.4_j2odc4yr77iddtreafyicbq5hi+ packages/example-without-zod:+ specifiers:+ '@types/react': ^18.0.38+ '@types/react-dom': ^18.0.11+ react: ^18.2.0+ react-dom: ^18.2.0+ remotion: workspace:*+ typescript: ^4.7.0+ dependencies:+ react: 18.2.0+ react-dom: [email protected]+ remotion: link:../core+ typescript: 4.9.5+ devDependencies:+ '@types/react': 18.0.38+ '@types/react-dom': 18.0.11+packages/gif:specifiers:'@jonny/eslint-config': 3.0.266@@ -6729,7 +6746,7 @@ packages:peerDependencies:react: '*'dependencies:- '@types/react': 18.0.28+ '@types/react': 18.0.38prop-types: 15.8.1react: 18.0.0dev: false@@ -9465,7 +9482,7 @@ packages:/@types/react-dom/18.0.11:resolution: {integrity: sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==}dependencies:- '@types/react': 18.0.28+ '@types/react': 18.0.38dev: true/@types/react-native/0.69.2:@@ -9502,7 +9519,7 @@ packages:resolution: {integrity: sha512-UvyRy73318QI83haXlaMwmklHHzV9hjl3u71MmM6wYNu0hOVk9NLTa0vGukf8zXUqnwz4O06ig876YSPpeK28A==}dependencies:'@types/history': 4.7.11- '@types/react': 18.0.28+ '@types/react': 18.0.38'@types/react-router': 5.1.17dev: false@@ -9510,7 +9527,7 @@ packages:resolution: {integrity: sha512-RNSXOyb3VyRs/EOGmjBhhGKTbnN6fHWvy5FNLzWfOWOGjgVUKqJZXfpKzLmgoU8h6Hj8mpALj/mbXQASOb92wQ==}dependencies:'@types/history': 4.7.11- '@types/react': 18.0.28+ '@types/react': 18.0.38dev: false/@types/react/18.0.26:@@ -9526,6 +9543,14 @@ packages:'@types/prop-types': 15.7.4'@types/scheduler': 0.16.2csstype: 3.1.1+ dev: true++ /@types/react/18.0.38:+ resolution: {integrity: sha512-ExsidLLSzYj4cvaQjGnQCk4HFfVT9+EZ9XZsQ8Hsrcn8QNgXtpZ3m9vSIC2MWtx7jHictK6wYhQgGh6ic58oOw==}+ dependencies:+ '@types/prop-types': 15.7.4+ '@types/scheduler': 0.16.2+ csstype: 3.1.1/@types/resolve/1.20.2:resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}