🎥 Make videos programmatically with React
alright
Jonny Burgerefa1cfa6a081
diff --git a/packages/bundler/src/error-overlay/react-overlay/utils/open-in-editor.ts b/packages/bundler/src/error-overlay/react-overlay/utils/open-in-editor.tsindex fbe3325ac0..a83a7e78b0 100644--- a/packages/bundler/src/error-overlay/react-overlay/utils/open-in-editor.ts+++ b/packages/bundler/src/error-overlay/react-overlay/utils/open-in-editor.ts@@ -179,7 +179,7 @@ function getArgumentsForLineNumber(}}-function guessEditor(): [string | null, ...string[]] {+export function guessEditor(): [string | null, ...string[]] {// We can find out which editor is currently running by:// `ps x` on macOS and Linux// `Get-Process` on Windows@@ -241,7 +241,11 @@ function guessEditor(): [string | null, ...string[]] {}let _childProcess: ChildProcess | null = null;-function launchEditor(fileName: string, lineNumber: number, colNumber: number) {+export function launchEditor(+ fileName: string,+ lineNumber: number,+ colNumber: number+) {if (!fs.existsSync(fileName)) {return;}@@ -345,5 +349,3 @@ function launchEditor(fileName: string, lineNumber: number, colNumber: number) {console.log('Error opening file in editor', fileName, error.message);});}--module.exports = launchEditor;diff --git a/packages/bundler/src/error-overlay/remotion-overlay/CodeFrame.tsx b/packages/bundler/src/error-overlay/remotion-overlay/CodeFrame.tsxindex 262de9e6a0..ff41d7dd28 100644--- a/packages/bundler/src/error-overlay/remotion-overlay/CodeFrame.tsx+++ b/packages/bundler/src/error-overlay/remotion-overlay/CodeFrame.tsx@@ -3,6 +3,7 @@ import {ScriptLine} from '../react-overlay/utils/stack-frame';const frame: React.CSSProperties = {backgroundColor: '#070707',+ marginBottom: 20,};const lineNumber: React.CSSProperties = {diff --git a/packages/bundler/src/error-overlay/remotion-overlay/ErrorDisplay.tsx b/packages/bundler/src/error-overlay/remotion-overlay/ErrorDisplay.tsxindex fe8f1dd6ae..8ee49021fc 100644--- a/packages/bundler/src/error-overlay/remotion-overlay/ErrorDisplay.tsx+++ b/packages/bundler/src/error-overlay/remotion-overlay/ErrorDisplay.tsx@@ -7,17 +7,25 @@ const container: React.CSSProperties = {maxWidth: 1000,marginLeft: 'auto',marginRight: 'auto',- fontFamily: 'sans-serif',+ fontFamily: 'SF Pro Text, sans-serif',paddingTop: '5vh',};const title: React.CSSProperties = {fontSize: '1.5em',fontWeight: 'bold',+ lineHeight: 1.5,+};++const errName: React.CSSProperties = {+ fontSize: '0.8em',+ background: 'linear-gradient(90deg,#4290f5,#42e9f5)',+ WebkitBackgroundClip: 'text',+ WebkitTextFillColor: 'transparent',+ display: 'inline-block',};const stack: React.CSSProperties = {- backgroundColor: 'black',marginTop: 17,overflowX: 'scroll',marginBottom: '10vh',@@ -37,7 +45,9 @@ export const ErrorDisplay: React.FC<{return (<div style={container}><div style={title}>- {display.error.name}: {display.error.message}+ <span style={errName}>{display.error.name}</span>+ <br />+ {display.error.message}</div><div style={stack}>{display.stackFrames.map((s, i) => {diff --git a/packages/bundler/src/error-overlay/remotion-overlay/StackFrame.tsx b/packages/bundler/src/error-overlay/remotion-overlay/StackFrame.tsxindex 050161ccf7..627c8fcedd 100644--- a/packages/bundler/src/error-overlay/remotion-overlay/StackFrame.tsx+++ b/packages/bundler/src/error-overlay/remotion-overlay/StackFrame.tsx@@ -17,6 +17,8 @@ const header: React.CSSProperties = {display: 'flex',flexDirection: 'row',alignItems: 'center',+ borderBottom: '1px solid rgb(66, 144, 245)',+ backgroundColor: 'black',};const left: React.CSSProperties = {diff --git a/packages/bundler/src/start-server.ts b/packages/bundler/src/start-server.tsindex ef62edfbb5..1ef6b242f8 100644--- a/packages/bundler/src/start-server.ts+++ b/packages/bundler/src/start-server.ts@@ -14,6 +14,11 @@ import {isUpdateAvailableWithTimeout} from './update-available';import {webpackConfig} from './webpack-config';import crypto from 'crypto';import {indexHtml} from './static-preview';+import {+ guessEditor,+ launchEditor,+} from './error-overlay/react-overlay/utils/open-in-editor';+import {StackFrame} from './error-overlay/react-overlay/utils/stack-frame';export const startServer = async (entry: string,@@ -79,6 +84,18 @@ export const startServer = async (});});+ app.post('/api/open-in-editor', (req, res) => {+ const body = req.body as StackFrame;+ launchEditor(+ body._originalFileName as string,+ body._originalLineNumber as number,+ body._originalColumnNumber as number+ );+ res.json({+ success: true,+ });+ });+app.use('favicon.png', (req, res) => {res.sendFile(path.join(__dirname, '..', 'web', 'favicon.png'));});@@ -92,6 +109,10 @@ export const startServer = async (const port = await getDesiredPort(desiredPort, 3000, 3100);+ console.log(guessEditor);+ const edit = guessEditor();+ console.log(edit);+app.listen(port);return port;};