Skip to content

πŸŽ₯ Make videos programmatically with React

Add LLM code generation with Vercel AI SDK

ASchwad1b7cff4d9c31
diff --git a/bun.lock b/bun.lock
index a8b66a4912..e95ad519a2 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1411,8 +1411,11 @@
"name": "template-code-generation",
"version": "0.1.0",
"dependencies": {
+ "@ai-sdk/openai": "^2.0.74",
+ "@ai-sdk/react": "^2.0.104",
"@babel/standalone": "^7.28.5",
"@monaco-editor/react": "^4.7.0",
+ "@radix-ui/react-select": "^2.2.6",
"@remotion/bundler": "workspace:*",
"@remotion/cli": "workspace:*",
"@remotion/google-fonts": "workspace:*",
@@ -1421,14 +1424,17 @@
"@remotion/player": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/tailwind-v4": "workspace:*",
- "clsx": "2.1.1",
+ "ai": "^5.0.104",
+ "class-variance-authority": "^0.7.1",
+ "clsx": "^2.1.1",
+ "lucide-react": "^0.555.0",
"monaco-editor": "^0.55.1",
"next": "16.0.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"remotion": "workspace:*",
- "tailwind-merge": "3.0.1",
- "zod": "3.22.3",
+ "tailwind-merge": "^3.4.0",
+ "zod": "^4.1.13",
},
"devDependencies": {
"@eslint/eslintrc": "3.1.0",
@@ -1449,6 +1455,7 @@
"postcss": "8.4.47",
"prettier": "3.6.0",
"tailwindcss": "4.0.3",
+ "tw-animate-css": "^1.4.0",
"typescript": "5.8.2",
"typescript-eslint": "8.46.0",
},
@@ -2183,6 +2190,16 @@
"packages": {
"@aashutoshrathi/word-wrap": ["@aashutoshrathi/[email protected]", "", {}, "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA=="],
+ "@ai-sdk/gateway": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "2.0.0", "@ai-sdk/provider-utils": "3.0.18", "@vercel/oidc": "3.0.5" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-oVAG6q72KsjKlrYdLhWjRO7rcqAR8CjokAbYuyVZoCO4Uh2PH/VzZoxZav71w2ipwlXhHCNaInGYWNs889MMDA=="],
+
+ "@ai-sdk/openai": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "2.0.0", "@ai-sdk/provider-utils": "3.0.18" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-vvsL7rGoBEyQIePs630p31ebLeF+xxwLOrRKeIArHko8w7Wh9Kj3wL4Ns+PCzrEpAij31OKKDcxLQ1dSIg/qMw=="],
+
+ "@ai-sdk/provider": ["@ai-sdk/[email protected]", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-6o7Y2SeO9vFKB8lArHXehNuusnpddKPk7xqL7T2/b+OvXMRIXUO1rR4wcv1hAFUAT9avGZshty3Wlua/XA7TvA=="],
+
+ "@ai-sdk/provider-utils": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "2.0.0", "@standard-schema/spec": "^1.0.0", "eventsource-parser": "^3.0.6" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-ypv1xXMsgGcNKUP+hglKqtdDuMg68nWHucPPAhIENrbFAI+xCHiqPVN8Zllxyv1TNZwGWUghPxJXU+Mqps0YRQ=="],
+
+ "@ai-sdk/react": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider-utils": "3.0.18", "ai": "5.0.104", "swr": "^2.2.5", "throttleit": "2.1.0" }, "peerDependencies": { "react": "^18 || ^19 || ^19.0.0-rc", "zod": "^3.25.76 || ^4.1.8" }, "optionalPeers": ["zod"] }, "sha512-vpRNUwOrHXSsywZuEge78/LPbYMR/3tkBnwijGpIGnORMa/SzYhuVsE+sZBFVo/v0m5K/tg+CXNNvuJrVZ/MBQ=="],
+
"@algolia/abtesting": ["@algolia/[email protected]", "", { "dependencies": { "@algolia/client-common": "5.40.0", "@algolia/requester-browser-xhr": "5.40.0", "@algolia/requester-fetch": "5.40.0", "@algolia/requester-node-http": "5.40.0" } }, "sha512-c4M/Z/KWkEG+RHpZsWKDTTlApXu3fe4vlABNcpankWBhdMe4oPZ/r4JxEr2zKUP6K+BT66tnp8UbHmgOd/vvqQ=="],
"@algolia/autocomplete-core": ["@algolia/[email protected]", "", { "dependencies": { "@algolia/autocomplete-plugin-algolia-insights": "1.17.9", "@algolia/autocomplete-shared": "1.17.9" } }, "sha512-O7BxrpLDPJWWHv/DLA9DRFWs+iY1uOJZkqUwjS5HSZAGcl0hIVCQ97LTLewiZmZ402JYUrun+8NqFP+hCknlbQ=="],
@@ -4183,6 +4200,8 @@
"aggregate-error": ["[email protected]", "", { "dependencies": { "clean-stack": "2.2.0", "indent-string": "4.0.0" } }, "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA=="],
+ "ai": ["[email protected]", "", { "dependencies": { "@ai-sdk/gateway": "2.0.17", "@ai-sdk/provider": "2.0.0", "@ai-sdk/provider-utils": "3.0.18", "@opentelemetry/api": "1.9.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-MZOkL9++nY5PfkpWKBR3Rv+Oygxpb9S16ctv8h91GvrSif7UnNEdPMVZe3bUyMd2djxf0AtBk/csBixP0WwWZQ=="],
+
"ai-improvements": ["ai-improvements@workspace:packages/ai-improvements"],
"ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "3.1.3", "fast-json-stable-stringify": "2.1.0", "json-schema-traverse": "0.4.1", "uri-js": "4.4.1" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="],
@@ -5403,6 +5422,8 @@
"json-parse-even-better-errors": ["[email protected]", "", {}, "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w=="],
+ "json-schema": ["[email protected]", "", {}, "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="],
+
"json-schema-to-ts": ["[email protected]", "", { "dependencies": { "@types/json-schema": "7.0.15", "ts-toolbelt": "6.15.5" } }, "sha512-pR4yQ9DHz6itqswtHCm26mw45FSNfQ9rEQjosaZErhn5J3J2sIViQiz8rDaezjKAhFGpmsoczYVBgGHzFw/stA=="],
"json-schema-traverse": ["[email protected]", "", {}, "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="],
@@ -6639,6 +6660,8 @@
"swc-loader": ["[email protected]", "", { "dependencies": { "@swc/counter": "0.1.3" }, "peerDependencies": { "@swc/core": "1.8.0", "webpack": "5.96.1" } }, "sha512-9Zi9UP2YmDpgmQVbyOPJClY0dwf58JDyDMQ7uRc4krmc72twNI2fvlBWHLqVekBpPc7h5NJkGVT1zNDxFrqhvg=="],
+ "swr": ["[email protected]", "", { "dependencies": { "dequal": "^2.0.3", "use-sync-external-store": "^1.4.0" }, "peerDependencies": { "react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-ZEquQ82QvalqTxhBVv/DlAg2mbmUjF4UgpPg9wwk4ufb9rQnZXh1iKyyKBqV6bQGu1Ie7L1QwSYO07qFIa1p+g=="],
+
"tailwind-merge": ["[email protected]", "", {}, "sha512-kjEBm+pvD+6eAwzJL2Bi+02/9LFLal1Gs61+QB7HvTfQQ0aXwC5LGT8PEt1gS0CWKktKe6ysPTAy3cBC5MeiIg=="],
"tailwindcss": ["[email protected]", "", {}, "sha512-P3nr6WkvKV/ONsTzj6Gb57sWPMX29EPNPopo7+FcpkQaNsrNpZ1pv8QmrYI2RqEKD7mlGqLnGovlcYnBK0IqUA=="],
@@ -6721,6 +6744,8 @@
"three-stdlib": ["[email protected]", "", { "dependencies": { "@types/draco3d": "1.4.2", "@types/offscreencanvas": "2019.7.0", "@types/webxr": "0.5.2", "draco3d": "1.4.3", "fflate": "0.6.10", "potpack": "1.0.1" }, "peerDependencies": { "three": "0.178.0" } }, "sha512-kv0Byb++AXztEGsULgMAs8U2jgUdz6HPpAB/wDJnLiLlaWQX2APHhiTJIN7rqW+Of0eRgcp7jn05U1BsCP3xBA=="],
+ "throttleit": ["[email protected]", "", {}, "sha512-nt6AMGKW1p/70DF/hGBdJB57B8Tspmbp5gfJ8ilhLnt7kkr2ye7hzD6NVG8GGErk2HWF34igrL2CXmNIkzKqKw=="],
+
"through2": ["[email protected]", "", { "dependencies": { "readable-stream": "2.3.8", "xtend": "4.0.2" } }, "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ=="],
"thunky": ["[email protected]", "", {}, "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA=="],
@@ -6811,6 +6836,8 @@
"turbo-windows-arm64": ["[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-1Ty+NwIksQY7AtFUCPrTpcKQE7zmd/f7aRjdT+qkqGFQjIjFYctEtN7qo4vpQPBgCfS1U3ka83A2u/9CfJQ3wQ=="],
+ "tw-animate-css": ["[email protected]", "", {}, "sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ=="],
+
"twoslash": ["[email protected]", "", { "dependencies": { "@typescript/vfs": "1.6.1", "twoslash-protocol": "0.3.1" }, "peerDependencies": { "typescript": "5.8.2" } }, "sha512-OGqMTGvqXTcb92YQdwGfEdK0nZJA64Aj/ChLOelbl3TfYch2IoBST0Yx4C0LQ7Lzyqm9RpgcpgDxeXQIz4p2Kg=="],
"twoslash-cdn": ["[email protected]", "", { "dependencies": { "twoslash": "0.3.1" }, "peerDependencies": { "typescript": "5.8.2" } }, "sha512-JbYbEIG82SlBVD03s7PW+VC5cV9zgWHCtdVkBEc38Kqz8D8ZAgPkthzPAj3isaiJo5xTu/Q/R4NYgihcMVmFXQ=="],
@@ -7105,6 +7132,16 @@
"zwitch": ["[email protected]", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
+ "@ai-sdk/gateway/@vercel/oidc": ["@vercel/[email protected]", "", {}, "sha512-fnYhv671l+eTTp48gB4zEsTW/YtRgRPnkI2nT7x6qw5rkI1Lq2hTmQIpHPgyThI0znLK+vX2n9XxKdXZ7BUbbw=="],
+
+ "@ai-sdk/gateway/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
+
+ "@ai-sdk/openai/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
+
+ "@ai-sdk/provider-utils/eventsource-parser": ["[email protected]", "", {}, "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg=="],
+
+ "@ai-sdk/provider-utils/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
+
"@algolia/autocomplete-preset-algolia/@algolia/client-search": ["@algolia/[email protected]", "", { "dependencies": { "@algolia/client-common": "5.24.0", "@algolia/requester-browser-xhr": "5.24.0", "@algolia/requester-fetch": "5.24.0", "@algolia/requester-node-http": "5.24.0" } }, "sha512-k+nuciQuq7WERNNE+hsx3DX636zIy+9R4xdtvW3PANT2a2BDGOv3fv2mta8+QUMcVTVcGe/Mo3QCb4pc1HNoxA=="],
"@algolia/autocomplete-preset-algolia/algoliasearch": ["[email protected]", "", { "dependencies": { "@algolia/client-abtesting": "5.18.0", "@algolia/client-analytics": "5.18.0", "@algolia/client-common": "5.18.0", "@algolia/client-insights": "5.18.0", "@algolia/client-personalization": "5.18.0", "@algolia/client-query-suggestions": "5.18.0", "@algolia/client-search": "5.18.0", "@algolia/ingestion": "1.18.0", "@algolia/monitoring": "1.18.0", "@algolia/recommend": "5.18.0", "@algolia/requester-browser-xhr": "5.18.0", "@algolia/requester-fetch": "5.18.0", "@algolia/requester-node-http": "5.18.0" } }, "sha512-/tfpK2A4FpS0o+S78o3YSdlqXr0MavJIDlFK3XZrlXLy7vaRXJvW5jYg3v5e/wCaF8y0IpMjkYLhoV6QqfpOgw=="],
@@ -8205,6 +8242,8 @@
"acorn-jsx/acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA=="],
+ "ai/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
+
"ajv-formats/ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "3.1.3", "json-schema-traverse": "1.0.0", "require-from-string": "2.0.2", "uri-js": "4.4.1" } }, "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg=="],
"ansi-align/string-width": ["[email protected]", "", { "dependencies": { "emoji-regex": "8.0.0", "is-fullwidth-code-point": "3.0.0", "strip-ansi": "6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
@@ -9091,18 +9130,26 @@
"template-code-generation/@eslint/js": ["@eslint/[email protected]", "", {}, "sha512-UZ1VpFvXf9J06YG9xQBdnzU+kthors6KjhMAl6f4gH4usHyh31rUf2DLGInT8RFYIReYXNSydgPY0V2LuWgl7A=="],
+ "template-code-generation/@radix-ui/react-select": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/number": "1.1.1", "@radix-ui/primitive": "1.1.3", "@radix-ui/react-collection": "1.1.7", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-direction": "1.1.1", "@radix-ui/react-dismissable-layer": "1.1.11", "@radix-ui/react-focus-guards": "1.1.3", "@radix-ui/react-focus-scope": "1.1.7", "@radix-ui/react-id": "1.1.1", "@radix-ui/react-popper": "1.2.8", "@radix-ui/react-portal": "1.1.9", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-slot": "1.2.3", "@radix-ui/react-use-callback-ref": "1.1.1", "@radix-ui/react-use-controllable-state": "1.2.2", "@radix-ui/react-use-layout-effect": "1.1.1", "@radix-ui/react-use-previous": "1.1.1", "@radix-ui/react-visually-hidden": "1.2.3", "aria-hidden": "^1.2.4", "react-remove-scroll": "^2.6.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-I30RydO+bnn2PQztvo25tswPH+wFBjehVGtmagkU78yMdwTwVf12wnAOF+AeP8S2N8xD+5UPbGhkUfPyvT+mwQ=="],
+
"template-code-generation/@typescript-eslint/eslint-plugin": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/type-utils": "8.46.0", "@typescript-eslint/utils": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.46.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hA8gxBq4ukonVXPy0OKhiaUh/68D0E88GSmtC1iAEnGaieuDi38LhS7jdCHRLi6ErJBNDGCzvh5EnzdPwUc0DA=="],
"template-code-generation/@typescript-eslint/parser": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/types": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-n1H6IcDhmmUEG7TNVSspGmiHHutt7iVKtZwRppD7e04wha5MrkV1h3pti9xQLcCMt6YWsncpoT0HMjkH1FNwWQ=="],
+ "template-code-generation/class-variance-authority": ["[email protected]", "", { "dependencies": { "clsx": "^2.1.1" } }, "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg=="],
+
"template-code-generation/dotenv": ["[email protected]", "", {}, "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="],
- "template-code-generation/tailwind-merge": ["[email protected]", "", {}, "sha512-AvzE8FmSoXC7nC+oU5GlQJbip2UO7tmOhOfQyOmPhrStOGXHU08j8mZEHZ4BmCqY5dWTCo4ClWkNyRNx1wpT0g=="],
+ "template-code-generation/lucide-react": ["[email protected]", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-D8FvHUGbxWBRQM90NZeIyhAvkFfsh3u9ekrMvJ30Z6gnpBHS6HC6ldLg7tL45hwiIz/u66eKDtdA23gwwGsAHA=="],
+
+ "template-code-generation/tailwind-merge": ["[email protected]", "", {}, "sha512-uSaO4gnW+b3Y2aWoWfFpX62vn2sR3skfhbjsEnaBI81WD1wBLlHZe5sWf0AqjksNdYTbGBEd0UasQMT3SNV15g=="],
"template-code-generation/tailwindcss": ["[email protected]", "", {}, "sha512-ImmZF0Lon5RrQpsEAKGxRvHwCvMgSC4XVlFRqmbzTEDb/3wvin9zfEZrMwgsa3yqBbPqahYcVI6lulM2S7IZAA=="],
"template-code-generation/typescript-eslint": ["[email protected]", "", { "dependencies": { "@typescript-eslint/eslint-plugin": "8.46.0", "@typescript-eslint/parser": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/utils": "8.46.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-6+ZrB6y2bT2DX3K+Qd9vn7OFOJR+xSLDj+Aw/N3zBwUt27uTw2sw2TE2+UcY1RiyBZkaGbTkVg9SSdPNUG6aUw=="],
+ "template-code-generation/zod": ["[email protected]", "", {}, "sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig=="],
+
"template-next-app/@eslint/js": ["@eslint/[email protected]", "", {}, "sha512-UZ1VpFvXf9J06YG9xQBdnzU+kthors6KjhMAl6f4gH4usHyh31rUf2DLGInT8RFYIReYXNSydgPY0V2LuWgl7A=="],
"template-next-app/@typescript-eslint/eslint-plugin": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/type-utils": "8.46.0", "@typescript-eslint/utils": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.46.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hA8gxBq4ukonVXPy0OKhiaUh/68D0E88GSmtC1iAEnGaieuDi38LhS7jdCHRLi6ErJBNDGCzvh5EnzdPwUc0DA=="],
@@ -10995,6 +11042,36 @@
"teeny-request/https-proxy-agent/debug": ["[email protected]", "", { "dependencies": { "ms": "2.1.3" } }, "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ=="],
+ "template-code-generation/@radix-ui/react-select/@radix-ui/number": ["@radix-ui/[email protected]", "", {}, "sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/primitive": ["@radix-ui/[email protected]", "", {}, "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-collection": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-slot": "1.2.3" }, "peerDependencies": { "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "react": "19.0.0", "react-dom": "19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-Fh9rGN0MoI4ZFUNyfFVNU4y9LUz93u9/0K+yLgA2bwRojxM8JU1DyvvMBabnZPBgMWREAJvU2jjVzq+LrFUglw=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-compose-refs": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-context": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-jCi/QKUM2r1Ju5a3J64TH2A5SpKAgh0LpknyqdQ4m6DCV0xJ2HG1xARRwNGPQfi1SLdLWZ1OJz6F4OMBBNiGJA=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-direction": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-1UEWRX6jnOA2y4H5WczZ44gOOjTEmlqv1uNW4GAJEO5+bauCBhv8snY65Iw5/VOS/ghKN9gr2KjnLKxrsvoMVw=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-dismissable-layer": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/primitive": "1.1.3", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-callback-ref": "1.1.1", "@radix-ui/react-use-escape-keydown": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-Nqcp+t5cTB8BinFkZgXiMJniQH0PsUt2k51FUhbdfeKvc4ACcG2uQniY/8+h1Yv6Kza4Q7lD7PQV0z0oicE0Mg=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-focus-guards": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-0rFg/Rj2Q62NCm62jZw0QX7a3sz6QCQU0LpZdNrJX8byRGaGVTqbrW9jAoIAHyMQqsNpeZ81YgSizOt5WXq0Pw=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-popper": ["@radix-ui/[email protected]", "", { "dependencies": { "@floating-ui/react-dom": "^2.0.0", "@radix-ui/react-arrow": "1.1.7", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-callback-ref": "1.1.1", "@radix-ui/react-use-layout-effect": "1.1.1", "@radix-ui/react-use-rect": "1.1.1", "@radix-ui/react-use-size": "1.1.1", "@radix-ui/rect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-0NJQ4LFFUuWkE7Oxf0htBKS6zLkkjBH+hM1uk7Ng705ReR8m/uelduy1DBo0PyBXPKVnBA6YBlU94MBGXrSBCw=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-primitive": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-slot": "1.2.3" }, "peerDependencies": { "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "react": "19.0.0", "react-dom": "19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-m9gTwRkhy2lvCPe6QJp4d3G1TYEUHn/FzJUtq9MjH46an1wJU+GdoGC5VLof8RX8Ft/DlpshApkhswDLZzHIcQ=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-use-callback-ref": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-FkBMwD+qbGQeMu1cOHnuGB6x4yzPjho8ap5WtbEJ26umhgqVXbhekKUQO+hZEL1vU92a3wHwdp0HAcqAUF5iDg=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-use-controllable-state": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-use-effect-event": "0.0.2", "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-BjasUjixPFdS+NKkypcyyN5Pmg83Olst0+c6vGov0diwTEo6mgdqVR6hxcEgFuh4QrAs7Rc+9KuGJ9TVCj0Zzg=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-use-layout-effect": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-RbJRS4UWQFkzHTTwVymMTUv8EqYhOp8dOOviLj2ugtTiXRaRQS7GLGxZTLL1jWhMeoSCf5zmcZkqTl9IiYfXcQ=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-use-previous": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-2dHfToCj/pzca2Ck724OZ5L0EVrr3eHRNsG/b3xQJLA2hZpVCS99bLAX+hm1IHXDEnzU6by5z/5MIY794/a8NQ=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-visually-hidden": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.3" }, "peerDependencies": { "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "react": "19.0.0", "react-dom": "19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-pzJq12tEaaIhqjbzpCuv/OypJY/BPavOofm+dbab+MHLajy277+1lLm6JFcGgF5eskJ6mquGirhXY2GD/8u8Ug=="],
+
"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/scope-manager": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0" } }, "sha512-lWETPa9XGcBes4jqAMYD9fW0j4n6hrPtTJwWDmtqgFO/4HF4jmdH/Q6wggTw5qIT5TXjKzbt7GsZUBnWoO3dqw=="],
"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/type-utils": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/utils": "8.46.0", "debug": "^4.3.4", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hy+lvYV1lZpVs2jRaEYvgCblZxUoJiPyCemwbQZ+NGulWkQRy0HRPYAoef/CNSzaLt+MLvMptZsHXHlkEilaeg=="],
@@ -12873,6 +12950,14 @@
"shiki-twoslash/@typescript/twoslash/@typescript/vfs/debug": ["[email protected]", "", { "dependencies": { "ms": "2.1.3" } }, "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ=="],
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-popper/@radix-ui/react-arrow": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.3" }, "peerDependencies": { "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "react": "19.0.0", "react-dom": "19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-F+M1tLhO+mlQaOWspE8Wstg+z6PwxwRd8oQ8IXceWz92kfAmalTRf0EjrouQeo7QssEPfCn05B4Ihs1K9WQ/7w=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-popper/@radix-ui/react-use-rect": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/rect": "1.1.1" }, "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-QTYuDesS0VtuHNNvMh+CjlKJ4LJickCMUAqjlE3+j8w+RlRpwyX3apEQKGFzbZGdo7XNG1tXa+bQqIE7HIXT2w=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-popper/@radix-ui/react-use-size": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-ewrXRDTAqAXlkl6t/fkXWNAhFX9I+CkKlw6zjEwk86RSPKwZr3xpBRso655aqYafwtnbpHLj6toFzmd6xdVptQ=="],
+
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-popper/@radix-ui/rect": ["@radix-ui/[email protected]", "", {}, "sha512-HPwpGIzkl28mWyZqG52jiqDJ12waP11Pa1lGoiyUkIEuMLBP0oeK/C89esbXrxsky5we7dfd8U58nm0SgAWpVw=="],
+
"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/scope-manager/@typescript-eslint/types": ["@typescript-eslint/[email protected]", "", {}, "sha512-bHGGJyVjSE4dJJIO5yyEWt/cHyNwga/zXGJbJJ8TiO01aVREK6gCTu3L+5wrkb1FbDkQ+TKjMNe9R/QQQP9+rA=="],
"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/type-utils/@typescript-eslint/types": ["@typescript-eslint/[email protected]", "", {}, "sha512-bHGGJyVjSE4dJJIO5yyEWt/cHyNwga/zXGJbJJ8TiO01aVREK6gCTu3L+5wrkb1FbDkQ+TKjMNe9R/QQQP9+rA=="],
diff --git a/packages/template-code-generation/components.json b/packages/template-code-generation/components.json
new file mode 100644
index 0000000000..e152499ab4
--- /dev/null
+++ b/packages/template-code-generation/components.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "https://ui.shadcn.com/schema.json",
+ "style": "new-york",
+ "rsc": true,
+ "tsx": true,
+ "tailwind": {
+ "config": "",
+ "css": "styles/global.css",
+ "baseColor": "neutral",
+ "cssVariables": true,
+ "prefix": ""
+ },
+ "iconLibrary": "lucide",
+ "aliases": {
+ "components": "@/components",
+ "utils": "@/lib/utils",
+ "ui": "@/components/ui",
+ "lib": "@/lib",
+ "hooks": "@/hooks"
+ },
+ "registries": {}
+}
diff --git a/packages/template-code-generation/package.json b/packages/template-code-generation/package.json
index 8341fb4bf4..3ce940ae42 100644
--- a/packages/template-code-generation/package.json
+++ b/packages/template-code-generation/package.json
@@ -11,9 +11,11 @@
"deploy": "node deploy.mjs"
},
"dependencies": {
+ "@ai-sdk/openai": "^2.0.74",
+ "@ai-sdk/react": "^2.0.104",
"@babel/standalone": "^7.28.5",
"@monaco-editor/react": "^4.7.0",
- "monaco-editor": "^0.55.1",
+ "@radix-ui/react-select": "^2.2.6",
"@remotion/bundler": "workspace:*",
"@remotion/cli": "workspace:*",
"@remotion/google-fonts": "workspace:*",
@@ -22,33 +24,38 @@
"@remotion/player": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/tailwind-v4": "workspace:*",
- "clsx": "2.1.1",
+ "ai": "^5.0.104",
+ "class-variance-authority": "^0.7.1",
+ "clsx": "^2.1.1",
+ "lucide-react": "^0.555.0",
+ "monaco-editor": "^0.55.1",
"next": "16.0.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"remotion": "workspace:*",
- "tailwind-merge": "3.0.1",
- "zod": "3.22.3"
+ "tailwind-merge": "^3.4.0",
+ "zod": "^4.1.13"
},
"devDependencies": {
- "@tailwindcss/postcss": "4.1.1",
- "@remotion/eslint-plugin": "workspace:*",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.38.0",
+ "@next/eslint-plugin-next": "15.1.6",
+ "@remotion/eslint-plugin": "workspace:*",
+ "@tailwindcss/postcss": "4.1.1",
"@types/node": "20.12.14",
"@types/react": "19.0.0",
"@types/react-dom": "19.0.0",
"@types/web": "0.0.166",
+ "@typescript-eslint/eslint-plugin": "8.46.0",
+ "@typescript-eslint/parser": "8.46.0",
"autoprefixer": "10.4.20",
"dotenv": "16.0.3",
"eslint": "9.19.0",
- "@next/eslint-plugin-next": "15.1.6",
"eslint-config-next": "15.1.6",
- "@typescript-eslint/eslint-plugin": "8.46.0",
- "@typescript-eslint/parser": "8.46.0",
"postcss": "8.4.47",
"prettier": "3.6.0",
"tailwindcss": "4.0.3",
+ "tw-animate-css": "^1.4.0",
"typescript": "5.8.2",
"typescript-eslint": "8.46.0"
}
diff --git a/packages/template-code-generation/src/app/api/generate/route.ts b/packages/template-code-generation/src/app/api/generate/route.ts
new file mode 100644
index 0000000000..0d56a76a36
--- /dev/null
+++ b/packages/template-code-generation/src/app/api/generate/route.ts
@@ -0,0 +1,107 @@
+import { streamText } from "ai";
+import { openai } from "@ai-sdk/openai";
+
+const SYSTEM_PROMPT = `
+You are an expert in generating React components for Remotion animations.
+
+IMPORTANT RULES:
+1. Start the code with a multi-line comment (/* */) containing a 2-3 sentence description of what you're building
+2. Do NOT include any imports - they are provided automatically
+3. Available APIs: React, AbsoluteFill, interpolate, useCurrentFrame, useVideoConfig, spring, Sequence
+4. Use creative animations with smooth transitions
+5. Component should use frame-based animations with interpolate()
+6. Make it visually impressive and modern
+7. Use inline styles for all styling
+8. ALWAYS use fontFamily: 'Inter, sans-serif' for ALL text elements to ensure consistent rendering
+9. Do not define the component name - start directly with the comment, then the code
+
+LAYOUT RULES:
+- For diagrams, charts, flowcharts, or any data visualizations: USE THE FULL WIDTH of the container
+- Ensure diagrams span edge-to-edge with appropriate padding (e.g., padding: 40px)
+- Never constrain diagrams to a small centered box - maximize the visual space
+
+COLOR PALETTE RULES (CRITICAL):
+- Use AT MOST 4 distinct colors in the entire animation
+- Define these colors as constants at the top of the component
+- Reuse these colors consistently throughout all elements
+- Create a cohesive, harmonious color scheme
+- Example:
+ const COLOR_PRIMARY = "#ff6b6b";
+ const COLOR_SECONDARY = "#4ecdc4";
+ const COLOR_ACCENT = "#ffe66d";
+ const COLOR_BACKGROUND = "#1a1a2e";
+
+TEXT CONTENT RULES (CRITICAL):
+- ALL text strings that appear in the animation MUST be defined as constants at the top
+- Never hardcode text directly in JSX - always use variables
+- This allows users to easily edit all text content
+- Use descriptive constant names in UPPER_SNAKE_CASE
+- Example:
+ const TITLE_TEXT = "Espresso Workflow";
+ const SUBTITLE_TEXT = "5-Step Process Flow";
+ const STEP_1_TEXT = "Grind Coffee";
+
+ANIMATION TIMING RULES:
+- Define animation speed/timing parameters as constants that users can adjust
+- Use descriptive names for delays, durations, and speed multipliers
+- This allows users to fine-tune animation pacing without editing code
+- Example:
+ const ANIMATION_SPEED = 1.0; // Speed multiplier (1.0 = normal, 2.0 = 2x faster)
+ const FADE_DURATION = 20; // Duration in frames
+ const ELEMENT_DELAY = 5; // Delay between elements in frames
+ const ROTATION_SPEED = 180; // Degrees of rotation
+
+Example response:
+
+/*
+ * A simple animated greeting with a title that fades in smoothly.
+ * The text uses spring physics for a natural, bouncy appearance.
+ */
+
+const frame = useCurrentFrame();
+// Color palette - max 4 colors
+const COLOR_BACKGROUND = "#0f0f23";
+const COLOR_PRIMARY = "#ff6b6b";
+const COLOR_SECONDARY = "#4ecdc4";
+const COLOR_ACCENT = "#ffe66d";
+
+// Text content - all strings as constants
+const TITLE_TEXT = "Hello World";
+const SUBTITLE_TEXT = "Welcome to the animation";
+
+// Animation timing
+const ANIMATION_SPEED = 1.0;
+const FADE_IN_DURATION = 20;
+const TITLE_DELAY = 10;
+
+// Apply speed multiplier to frame
+const adjustedFrame = frame * ANIMATION_SPEED;
+
+const titleOpacity = interpolate(
+ adjustedFrame,
+ [TITLE_DELAY, TITLE_DELAY + FADE_IN_DURATION],
+ [0, 1],
+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" }
+);
+
+return (
+ <AbsoluteFill style={{backgroundColor: COLOR_BACKGROUND}}>
+ <div style={{color: COLOR_PRIMARY, fontSize: 48, opacity: titleOpacity}}>{TITLE_TEXT}</div>
+ <div style={{color: COLOR_SECONDARY, fontSize: 32}}>{SUBTITLE_TEXT}</div>
+ </AbsoluteFill>
+};
+`;
+
+export async function POST(req: Request) {
+ const { prompt, model = "gpt-4o" } = await req.json();
+
+ const result = streamText({
+ model: openai(model),
+ system: SYSTEM_PROMPT,
+ prompt,
+ });
+
+ console.log("Generating React component with prompt:", prompt, "model:", model);
+
+ return result.toTextStreamResponse();
+}
diff --git a/packages/template-code-generation/src/app/page.tsx b/packages/template-code-generation/src/app/page.tsx
index b9265071c1..f66b99c052 100644
--- a/packages/template-code-generation/src/app/page.tsx
+++ b/packages/template-code-generation/src/app/page.tsx
@@ -5,6 +5,7 @@ import type { NextPage } from "next";
import { ExampleSelector } from "../components/ExampleSelector";
import { CodeEditor } from "../components/CodeEditor";
import { AnimationPlayer } from "../components/AnimationPlayer";
+import { PromptInput } from "../components/PromptInput";
import { examples, RemotionExample } from "../templates";
import { useAnimationState } from "../hooks/useAnimationState";
@@ -12,10 +13,11 @@ const Home: NextPage = () => {
const [selectedExample, setSelectedExample] =
useState<RemotionExample | null>(examples[0] || null);
const [durationInFrames, setDurationInFrames] = useState(
- examples[0]?.durationInFrames || 150
+ examples[0]?.durationInFrames || 150,
);
const [fps, setFps] = useState(examples[0]?.fps || 30);
const [isEditorOpen, setIsEditorOpen] = useState(true);
+ const [isStreaming, setIsStreaming] = useState(false);
const { code, Component, error, isCompiling, setCode, compileCode } =
useAnimationState(examples[0]?.code || "");
@@ -23,6 +25,23 @@ const Home: NextPage = () => {
// Debounce compilation
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const isStreamingRef = useRef(isStreaming);
+ const codeRef = useRef(code);
+
+ useEffect(() => {
+ codeRef.current = code;
+ }, [code]);
+
+ useEffect(() => {
+ const wasStreaming = isStreamingRef.current;
+ isStreamingRef.current = isStreaming;
+
+ // Compile when streaming ends
+ if (wasStreaming && !isStreaming) {
+ compileCode(codeRef.current);
+ }
+ }, [isStreaming, compileCode]);
+
const handleCodeChange = useCallback(
(newCode: string) => {
setCode(newCode);
@@ -32,12 +51,17 @@ const Home: NextPage = () => {
clearTimeout(debounceRef.current);
}
+ // Skip compilation while streaming - will compile when streaming ends
+ if (isStreamingRef.current) {
+ return;
+ }
+
// Set new debounce
debounceRef.current = setTimeout(() => {
compileCode(newCode);
}, 500);
},
- [setCode, compileCode]
+ [setCode, compileCode],
);
const handleExampleSelect = useCallback(
@@ -53,7 +77,7 @@ const Home: NextPage = () => {
}
compileCode(example.code);
},
- [setCode, compileCode]
+ [setCode, compileCode],
);
// Cleanup debounce on unmount
@@ -89,7 +113,7 @@ const Home: NextPage = () => {
value={durationInFrames}
onChange={(e) =>
setDurationInFrames(
- Math.max(1, parseInt(e.target.value) || 1)
+ Math.max(1, parseInt(e.target.value) || 1),
)
}
className="w-20 px-3 py-1.5 rounded border border-[#333] bg-[#1a1a1a] text-white text-sm font-sans"
@@ -104,7 +128,7 @@ const Home: NextPage = () => {
value={fps}
onChange={(e) =>
setFps(
- Math.max(1, Math.min(60, parseInt(e.target.value) || 30))
+ Math.max(1, Math.min(60, parseInt(e.target.value) || 30)),
)
}
className="w-20 px-3 py-1.5 rounded border border-[#333] bg-[#1a1a1a] text-white text-sm font-sans"
@@ -129,9 +153,18 @@ const Home: NextPage = () => {
/>
{isEditorOpen && (
- <CodeEditor code={code} onChange={handleCodeChange} />
+ <CodeEditor
+ code={code}
+ onChange={handleCodeChange}
+ isStreaming={isStreaming}
+ />
)}
</div>
+
+ <PromptInput
+ onCodeGenerated={handleCodeChange}
+ onStreamingChange={setIsStreaming}
+ />
</div>
</div>
);
diff --git a/packages/template-code-generation/src/components/CodeEditor.tsx b/packages/template-code-generation/src/components/CodeEditor.tsx
index 73a76f0c2a..30a58bd60f 100644
--- a/packages/template-code-generation/src/components/CodeEditor.tsx
+++ b/packages/template-code-generation/src/components/CodeEditor.tsx
@@ -1,7 +1,9 @@
"use client";
-import React from "react";
+import React, { useRef, useEffect } from "react";
import dynamic from "next/dynamic";
+import type { Monaco } from "@monaco-editor/react";
+import type { editor } from "monaco-editor";
// Monaco must be loaded client-side only
const MonacoEditor = dynamic(() => import("@monaco-editor/react"), {
@@ -16,28 +18,98 @@ const MonacoEditor = dynamic(() => import("@monaco-editor/react"), {
interface CodeEditorProps {
code: string;
onChange: (value: string) => void;
+ isStreaming?: boolean;
}
const headerText = `// Available Remotion imports:
// Remotion.AbsoluteFill, Remotion.interpolate,
// Remotion.useCurrentFrame, Remotion.useVideoConfig,
-// Remotion.spring, Remotion.Sequence
-//
-// Your code should be an arrow function returning JSX:`;
+// Remotion.spring, Remotion.Sequence`;
+
+export const CodeEditor: React.FC<CodeEditorProps> = ({
+ code,
+ onChange,
+ isStreaming = false,
+}) => {
+ const monacoRef = useRef<Monaco | null>(null);
+ const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
+ const isStreamingRef = useRef(isStreaming);
+
+ // Keep ref in sync with prop and clear markers during streaming
+ useEffect(() => {
+ isStreamingRef.current = isStreaming;
+ }, [isStreaming]);
+
+ // Switch language based on streaming state
+ useEffect(() => {
+ const model = editorRef.current?.getModel();
+ if (model && monacoRef.current) {
+ const language = isStreaming ? "plaintext" : "javascript";
+ monacoRef.current.editor.setModelLanguage(model, language);
+ }
+ }, [isStreaming]);
+
+ // Continuously clear markers while streaming
+ useEffect(() => {
+ if (!isStreaming || !monacoRef.current) return;
+
+ const clearAllMarkers = () => {
+ monacoRef.current?.editor.getModels().forEach((model) => {
+ // Clear markers from all known owners
+ monacoRef.current?.editor.setModelMarkers(model, "javascript", []);
+ monacoRef.current?.editor.setModelMarkers(model, "typescript", []);
+ monacoRef.current?.editor.setModelMarkers(model, "owner", []);
+ });
+ };
+
+ // Clear immediately and on interval while streaming
+ clearAllMarkers();
+ const interval = setInterval(clearAllMarkers, 100);
+
+ return () => clearInterval(interval);
+ }, [isStreaming, code]);
+
+ const handleEditorMount = (
+ editorInstance: editor.IStandaloneCodeEditor,
+ monaco: Monaco,
+ ) => {
+ monacoRef.current = monaco;
+ editorRef.current = editorInstance;
+
+ // Override marker setting to suppress during streaming
+ const originalSetModelMarkers = monaco.editor.setModelMarkers;
+ monaco.editor.setModelMarkers = (model, owner, markers) => {
+ // Check the ref (not the prop) to get current value
+ if (isStreamingRef.current) {
+ return;
+ }
+ originalSetModelMarkers.call(monaco.editor, model, owner, markers);
+ };
+ };
-export const CodeEditor: React.FC<CodeEditorProps> = ({ code, onChange }) => {
return (
<div className="w-[600px] h-full flex flex-col bg-[#1e1e1e] border-l border-[#2a2a2a]">
<div className="p-3 px-4 bg-[#252526] border-b border-[#2a2a2a] font-mono text-xs text-[#6a9955] leading-relaxed whitespace-pre">
{headerText}
</div>
- <div className="flex-1 overflow-hidden">
+ <div className="flex-1 overflow-hidden relative">
+ {isStreaming && (
+ <div className="absolute inset-0 bg-black/40 z-10 flex items-center justify-center pointer-events-none">
+ <div className="flex items-center gap-3 bg-[#1e1e1e] px-4 py-3 rounded-lg border border-[#333]">
+ <div className="w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" />
+ <span className="text-white text-sm font-sans">
+ Generating code...
+ </span>
+ </div>
+ </div>
+ )}
<MonacoEditor
height="100%"
defaultLanguage="javascript"
theme="vs-dark"
value={code}
onChange={(value) => onChange(value || "")}
+ onMount={handleEditorMount}
options={{
minimap: { enabled: false },
fontSize: 14,
diff --git a/packages/template-code-generation/src/components/PromptInput.tsx b/packages/template-code-generation/src/components/PromptInput.tsx
new file mode 100644
index 0000000000..1ad6dfd929
--- /dev/null
+++ b/packages/template-code-generation/src/components/PromptInput.tsx
@@ -0,0 +1,141 @@
+"use client";
+
+import { useState } from "react";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+
+const MODELS = [
+ { id: "gpt-5-mini", name: "GPT-5 Mini" },
+ { id: "gpt-5.1-codex", name: "GPT-5.1 Codex" },
+ { id: "gpt-5.1-codex-mini", name: "GPT-5.1 Codex Mini" },
+ { id: "gpt-5.1", name: "GPT-5.1" },
+] as const;
+
+type ModelId = (typeof MODELS)[number]["id"];
+
+interface PromptInputProps {
+ onCodeGenerated: (code: string) => void;
+ onStreamingChange?: (isStreaming: boolean) => void;
+}
+
+export function PromptInput({ onCodeGenerated, onStreamingChange }: PromptInputProps) {
+ const [prompt, setPrompt] = useState("");
+ const [model, setModel] = useState<ModelId>("gpt-5-mini");
+ const [isLoading, setIsLoading] = useState(false);
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+ if (!prompt.trim() || isLoading) return;
+
+ setIsLoading(true);
+ onStreamingChange?.(true);
+ try {
+ const response = await fetch("/api/generate", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ prompt, model }),
+ });
+
+ if (!response.ok) {
+ throw new Error(`API error: ${response.status}`);
+ }
+
+ const reader = response.body?.getReader();
+ if (!reader) {
+ throw new Error("No response body");
+ }
+
+ const decoder = new TextDecoder();
+ let accumulatedText = "";
+
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+
+ accumulatedText += decoder.decode(value, { stream: true });
+
+ // Strip markdown code block markers and show raw code during streaming
+ let codeToShow = accumulatedText;
+
+ // Remove opening code fence (```tsx, ```jsx, ```, etc.)
+ codeToShow = codeToShow.replace(/^```(?:tsx?|jsx?)?\n?/, "");
+ // Remove closing code fence if present
+ codeToShow = codeToShow.replace(/\n?```\s*$/, "");
+
+ onCodeGenerated(codeToShow.trim());
+ }
+ } catch (error) {
+ console.error("Error generating code:", error);
+ } finally {
+ setIsLoading(false);
+ onStreamingChange?.(false);
+ }
+ };
+
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
+ // Submit on Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux)
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault();
+ handleSubmit(e);
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit} className="flex gap-2 p-4 bg-[#1a1a1a] border-t border-[#2a2a2a]">
+ <textarea
+ value={prompt}
+ onChange={(e) => setPrompt(e.target.value)}
+ onKeyDown={handleKeyDown}
+ placeholder="Describe your animation... (e.g., 'A bouncing ball')"
+ rows={3}
+ className="flex-1 px-4 py-2 rounded border border-[#333] bg-[#0f0f0f] text-white text-sm font-sans placeholder:text-[#666] focus:outline-none focus:border-indigo-500 resize-none min-h-[4.5rem] max-h-[9rem]"
+ disabled={isLoading}
+ />
+ <div className="flex flex-col gap-2">
+ <Select
+ value={model}
+ onValueChange={(value) => setModel(value as ModelId)}
+ disabled={isLoading}
+ >
+ <SelectTrigger className="w-[140px] bg-[#0f0f0f] border-[#333] text-white">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent className="bg-[#1a1a1a] border-[#333]">
+ {MODELS.map((m) => (
+ <SelectItem
+ key={m.id}
+ value={m.id}
+ className="text-white focus:bg-[#333] focus:text-white"
+ >
+ {m.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <button
+ type="submit"
+ disabled={isLoading || !prompt.trim()}
+ className="px-4 py-2 rounded border-none bg-indigo-500 text-white text-sm font-medium cursor-pointer font-sans transition-colors hover:bg-indigo-600 disabled:opacity-50 disabled:cursor-not-allowed flex flex-col items-center gap-1"
+ >
+ {isLoading ? (
+ "Generating..."
+ ) : (
+ <>
+ <span>Generate</span>
+ <span className="flex items-center gap-0.5 text-[10px] text-indigo-200/70">
+ <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">⌘</kbd>
+ <span>+</span>
+ <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">Enter</kbd>
+ </span>
+ </>
+ )}
+ </button>
+ </div>
+ </form>
+ );
+}
diff --git a/packages/template-code-generation/src/components/ui/select.tsx b/packages/template-code-generation/src/components/ui/select.tsx
new file mode 100644
index 0000000000..25e54394d5
--- /dev/null
+++ b/packages/template-code-generation/src/components/ui/select.tsx
@@ -0,0 +1,187 @@
+"use client"
+
+import * as React from "react"
+import * as SelectPrimitive from "@radix-ui/react-select"
+import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+function Select({
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Root>) {
+ return <SelectPrimitive.Root data-slot="select" {...props} />
+}
+
+function SelectGroup({
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Group>) {
+ return <SelectPrimitive.Group data-slot="select-group" {...props} />
+}
+
+function SelectValue({
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Value>) {
+ return <SelectPrimitive.Value data-slot="select-value" {...props} />
+}
+
+function SelectTrigger({
+ className,
+ size = "default",
+ children,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
+ size?: "sm" | "default"
+}) {
+ return (
+ <SelectPrimitive.Trigger
+ data-slot="select-trigger"
+ data-size={size}
+ className={cn(
+ "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <SelectPrimitive.Icon asChild>
+ <ChevronDownIcon className="size-4 opacity-50" />
+ </SelectPrimitive.Icon>
+ </SelectPrimitive.Trigger>
+ )
+}
+
+function SelectContent({
+ className,
+ children,
+ position = "popper",
+ align = "center",
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Content>) {
+ return (
+ <SelectPrimitive.Portal>
+ <SelectPrimitive.Content
+ data-slot="select-content"
+ className={cn(
+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
+ position === "popper" &&
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
+ className
+ )}
+ position={position}
+ align={align}
+ {...props}
+ >
+ <SelectScrollUpButton />
+ <SelectPrimitive.Viewport
+ className={cn(
+ "p-1",
+ position === "popper" &&
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
+ )}
+ >
+ {children}
+ </SelectPrimitive.Viewport>
+ <SelectScrollDownButton />
+ </SelectPrimitive.Content>
+ </SelectPrimitive.Portal>
+ )
+}
+
+function SelectLabel({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Label>) {
+ return (
+ <SelectPrimitive.Label
+ data-slot="select-label"
+ className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
+ {...props}
+ />
+ )
+}
+
+function SelectItem({
+ className,
+ children,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Item>) {
+ return (
+ <SelectPrimitive.Item
+ data-slot="select-item"
+ className={cn(
+ "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
+ className
+ )}
+ {...props}
+ >
+ <span className="absolute right-2 flex size-3.5 items-center justify-center">
+ <SelectPrimitive.ItemIndicator>
+ <CheckIcon className="size-4" />
+ </SelectPrimitive.ItemIndicator>
+ </span>
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
+ </SelectPrimitive.Item>
+ )
+}
+
+function SelectSeparator({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
+ return (
+ <SelectPrimitive.Separator
+ data-slot="select-separator"
+ className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
+ {...props}
+ />
+ )
+}
+
+function SelectScrollUpButton({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
+ return (
+ <SelectPrimitive.ScrollUpButton
+ data-slot="select-scroll-up-button"
+ className={cn(
+ "flex cursor-default items-center justify-center py-1",
+ className
+ )}
+ {...props}
+ >
+ <ChevronUpIcon className="size-4" />
+ </SelectPrimitive.ScrollUpButton>
+ )
+}
+
+function SelectScrollDownButton({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
+ return (
+ <SelectPrimitive.ScrollDownButton
+ data-slot="select-scroll-down-button"
+ className={cn(
+ "flex cursor-default items-center justify-center py-1",
+ className
+ )}
+ {...props}
+ >
+ <ChevronDownIcon className="size-4" />
+ </SelectPrimitive.ScrollDownButton>
+ )
+}
+
+export {
+ Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectLabel,
+ SelectScrollDownButton,
+ SelectScrollUpButton,
+ SelectSeparator,
+ SelectTrigger,
+ SelectValue,
+}
diff --git a/packages/template-code-generation/src/hooks/useCodeCompiler.ts b/packages/template-code-generation/src/hooks/useCodeCompiler.ts
index 5427feffab..6c31b1b546 100644
--- a/packages/template-code-generation/src/hooks/useCodeCompiler.ts
+++ b/packages/template-code-generation/src/hooks/useCodeCompiler.ts
@@ -24,8 +24,12 @@ export function useCodeCompiler() {
}
try {
+ // Wrap the component body in a function BEFORE transpilation
+ // Expected input: just the component body (hooks, variables, and return statement)
+ const wrappedSource = `const DynamicAnimation = () => {\n${code}\n};`;
+
// Transpile JSX/TypeScript to JavaScript using Babel
- const transpiled = Babel.transform(code, {
+ const transpiled = Babel.transform(wrappedSource, {
presets: ["react", "typescript"],
filename: "dynamic-animation.tsx",
});
@@ -44,8 +48,9 @@ export function useCodeCompiler() {
Sequence,
};
- // Create a function that has access to React and Remotion APIs
- // The code should be a function expression that returns a component
+ // Add return statement for the Function constructor
+ const wrappedCode = `${transpiled.code}\nreturn DynamicAnimation;`;
+
const createComponent = new Function(
"React",
"Remotion",
@@ -55,10 +60,7 @@ export function useCodeCompiler() {
"useVideoConfig",
"spring",
"Sequence",
- `
- const DynamicAnimation = ${transpiled.code};
- return DynamicAnimation;
- `
+ wrappedCode,
);
const Component = createComponent(
@@ -69,7 +71,7 @@ export function useCodeCompiler() {
useCurrentFrame,
useVideoConfig,
spring,
- Sequence
+ Sequence,
);
if (typeof Component !== "function") {
diff --git a/packages/template-code-generation/src/lib/utils.ts b/packages/template-code-generation/src/lib/utils.ts
index a5ef193506..bd0c391ddd 100644
--- a/packages/template-code-generation/src/lib/utils.ts
+++ b/packages/template-code-generation/src/lib/utils.ts
@@ -1,6 +1,6 @@
-import { clsx, type ClassValue } from "clsx";
-import { twMerge } from "tailwind-merge";
+import { clsx, type ClassValue } from "clsx"
+import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs));
+ return twMerge(clsx(inputs))
}
diff --git a/packages/template-code-generation/src/templates/index.ts b/packages/template-code-generation/src/templates/index.ts
index 236bd48b15..be3582b38e 100644
--- a/packages/template-code-generation/src/templates/index.ts
+++ b/packages/template-code-generation/src/templates/index.ts
@@ -16,7 +16,7 @@ export const examples: RemotionExample[] = [
category: "Text",
durationInFrames: 240,
fps: 30,
- code: `() => {
+ code: `
const frame = Remotion.useCurrentFrame();
const { fps } = Remotion.useVideoConfig();
@@ -71,8 +71,7 @@ export const examples: RemotionExample[] = [
{words[currentWordIndex]}
</h1>
</Remotion.AbsoluteFill>
- );
-}`,
+ );`,
},
{
id: "chat-messages",
@@ -81,7 +80,7 @@ export const examples: RemotionExample[] = [
category: "Text",
durationInFrames: 180,
fps: 30,
- code: `() => {
+ code: `
const frame = Remotion.useCurrentFrame();
const { fps } = Remotion.useVideoConfig();
@@ -139,8 +138,7 @@ export const examples: RemotionExample[] = [
})}
</div>
</Remotion.AbsoluteFill>
- );
-}`,
+ );`,
},
{
id: "counter-animation",
@@ -149,7 +147,7 @@ export const examples: RemotionExample[] = [
category: "Charts",
durationInFrames: 150,
fps: 30,
- code: `() => {
+ code: `
const frame = Remotion.useCurrentFrame();
const { fps, durationInFrames } = Remotion.useVideoConfig();
@@ -224,8 +222,7 @@ export const examples: RemotionExample[] = [
})}
</div>
</Remotion.AbsoluteFill>
- );
-}`,
+ );`,
},
{
id: "histogram",
@@ -234,7 +231,7 @@ export const examples: RemotionExample[] = [
category: "Charts",
durationInFrames: 120,
fps: 30,
- code: `() => {
+ code: `
const frame = Remotion.useCurrentFrame();
const { fps } = Remotion.useVideoConfig();
@@ -319,8 +316,7 @@ export const examples: RemotionExample[] = [
})}
</div>
</Remotion.AbsoluteFill>
- );
-}`,
+ );`,
},
{
id: "progress-bar",
@@ -329,7 +325,7 @@ export const examples: RemotionExample[] = [
category: "Other",
durationInFrames: 180,
fps: 30,
- code: `() => {
+ code: `
const frame = Remotion.useCurrentFrame();
const { durationInFrames } = Remotion.useVideoConfig();
@@ -405,8 +401,7 @@ export const examples: RemotionExample[] = [
</div>
</div>
</Remotion.AbsoluteFill>
- );
-}`,
+ );`,
},
];
@@ -415,7 +410,7 @@ export function getExampleById(id: string): RemotionExample | undefined {
}
export function getExamplesByCategory(
- category: RemotionExample["category"]
+ category: RemotionExample["category"],
): RemotionExample[] {
return examples.filter((e) => e.category === category);
}
diff --git a/packages/template-code-generation/styles/global.css b/packages/template-code-generation/styles/global.css
index 70ef8303f9..a892389b31 100644
--- a/packages/template-code-generation/styles/global.css
+++ b/packages/template-code-generation/styles/global.css
@@ -1,8 +1,9 @@
@import "tailwindcss";
+@import "tw-animate-css";
+
+@custom-variant dark (&:is(.dark *));
:root {
- --background: #fff;
- --foreground: #000;
--unfocused-border-color: #eaeaea;
--focused-border-color: #666;
@@ -18,14 +19,76 @@
--geist-error: #e00;
--subtitle: #666;
+
+ --radius: 0.625rem;
+
+ --background: oklch(1 0 0);
+
+ --foreground: oklch(0.145 0 0);
+
+ --card: oklch(1 0 0);
+
+ --card-foreground: oklch(0.145 0 0);
+
+ --popover: oklch(1 0 0);
+
+ --popover-foreground: oklch(0.145 0 0);
+
+ --primary: oklch(0.205 0 0);
+
+ --primary-foreground: oklch(0.985 0 0);
+
+ --secondary: oklch(0.97 0 0);
+
+ --secondary-foreground: oklch(0.205 0 0);
+
+ --muted: oklch(0.97 0 0);
+
+ --muted-foreground: oklch(0.556 0 0);
+
+ --accent: oklch(0.97 0 0);
+
+ --accent-foreground: oklch(0.205 0 0);
+
+ --destructive: oklch(0.577 0.245 27.325);
+
+ --border: oklch(0.922 0 0);
+
+ --input: oklch(0.922 0 0);
+
+ --ring: oklch(0.708 0 0);
+
+ --chart-1: oklch(0.646 0.222 41.116);
+
+ --chart-2: oklch(0.6 0.118 184.704);
+
+ --chart-3: oklch(0.398 0.07 227.392);
+
+ --chart-4: oklch(0.828 0.189 84.429);
+
+ --chart-5: oklch(0.769 0.188 70.08);
+
+ --sidebar: oklch(0.985 0 0);
+
+ --sidebar-foreground: oklch(0.145 0 0);
+
+ --sidebar-primary: oklch(0.205 0 0);
+
+ --sidebar-primary-foreground: oklch(0.985 0 0);
+
+ --sidebar-accent: oklch(0.97 0 0);
+
+ --sidebar-accent-foreground: oklch(0.205 0 0);
+
+ --sidebar-border: oklch(0.922 0 0);
+
+ --sidebar-ring: oklch(0.708 0 0);
}
@media (prefers-color-scheme: dark) {
:root {
- --background: #000000;
--unfocused-border-color: #333;
--focused-border-color: #888;
- --foreground: #fff;
--button-disabled-color: #111;
--geist-error: red;
--subtitle: #8d8d8d;
@@ -73,3 +136,84 @@ body {
padding: 0;
overflow: hidden;
}
+
+@theme inline {
+ --radius-sm: calc(var(--radius) - 4px);
+ --radius-md: calc(var(--radius) - 2px);
+ --radius-lg: var(--radius);
+ --radius-xl: calc(var(--radius) + 4px);
+ --color-background: var(--background);
+ --color-foreground: var(--foreground);
+ --color-card: var(--card);
+ --color-card-foreground: var(--card-foreground);
+ --color-popover: var(--popover);
+ --color-popover-foreground: var(--popover-foreground);
+ --color-primary: var(--primary);
+ --color-primary-foreground: var(--primary-foreground);
+ --color-secondary: var(--secondary);
+ --color-secondary-foreground: var(--secondary-foreground);
+ --color-muted: var(--muted);
+ --color-muted-foreground: var(--muted-foreground);
+ --color-accent: var(--accent);
+ --color-accent-foreground: var(--accent-foreground);
+ --color-destructive: var(--destructive);
+ --color-border: var(--border);
+ --color-input: var(--input);
+ --color-ring: var(--ring);
+ --color-chart-1: var(--chart-1);
+ --color-chart-2: var(--chart-2);
+ --color-chart-3: var(--chart-3);
+ --color-chart-4: var(--chart-4);
+ --color-chart-5: var(--chart-5);
+ --color-sidebar: var(--sidebar);
+ --color-sidebar-foreground: var(--sidebar-foreground);
+ --color-sidebar-primary: var(--sidebar-primary);
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
+ --color-sidebar-accent: var(--sidebar-accent);
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
+ --color-sidebar-border: var(--sidebar-border);
+ --color-sidebar-ring: var(--sidebar-ring);
+}
+
+.dark {
+ --background: oklch(0.145 0 0);
+ --foreground: oklch(0.985 0 0);
+ --card: oklch(0.205 0 0);
+ --card-foreground: oklch(0.985 0 0);
+ --popover: oklch(0.205 0 0);
+ --popover-foreground: oklch(0.985 0 0);
+ --primary: oklch(0.922 0 0);
+ --primary-foreground: oklch(0.205 0 0);
+ --secondary: oklch(0.269 0 0);
+ --secondary-foreground: oklch(0.985 0 0);
+ --muted: oklch(0.269 0 0);
+ --muted-foreground: oklch(0.708 0 0);
+ --accent: oklch(0.269 0 0);
+ --accent-foreground: oklch(0.985 0 0);
+ --destructive: oklch(0.704 0.191 22.216);
+ --border: oklch(1 0 0 / 10%);
+ --input: oklch(1 0 0 / 15%);
+ --ring: oklch(0.556 0 0);
+ --chart-1: oklch(0.488 0.243 264.376);
+ --chart-2: oklch(0.696 0.17 162.48);
+ --chart-3: oklch(0.769 0.188 70.08);
+ --chart-4: oklch(0.627 0.265 303.9);
+ --chart-5: oklch(0.645 0.246 16.439);
+ --sidebar: oklch(0.205 0 0);
+ --sidebar-foreground: oklch(0.985 0 0);
+ --sidebar-primary: oklch(0.488 0.243 264.376);
+ --sidebar-primary-foreground: oklch(0.985 0 0);
+ --sidebar-accent: oklch(0.269 0 0);
+ --sidebar-accent-foreground: oklch(0.985 0 0);
+ --sidebar-border: oklch(1 0 0 / 10%);
+ --sidebar-ring: oklch(0.556 0 0);
+}
+
+@layer base {
+ * {
+ @apply border-border outline-ring/50;
+ }
+ body {
+ @apply bg-background text-foreground;
+ }
+}
diff --git a/packages/template-code-generation/tsconfig.json b/packages/template-code-generation/tsconfig.json
index d317bdd4cc..cc5c9de7bf 100644
--- a/packages/template-code-generation/tsconfig.json
+++ b/packages/template-code-generation/tsconfig.json
@@ -23,7 +23,11 @@
"name": "next"
}
],
- "incremental": true
+ "incremental": true,
+ "baseUrl": ".",
+ "paths": {
+ "@/*": ["./src/*"]
+ }
},
"include": [
"next-env.d.ts",