Skip to content

🎥 Make videos programmatically with React

basics work

Patric Salvisberg4328325d932c
diff --git a/packages/cli/src/editor/components/RenderQueue/actions.ts b/packages/cli/src/editor/components/RenderQueue/actions.ts
index ef98c2c25f..e57b139a2a 100644
--- a/packages/cli/src/editor/components/RenderQueue/actions.ts
+++ b/packages/cli/src/editor/components/RenderQueue/actions.ts
@@ -243,6 +243,7 @@ export const cancelRenderJob = (job: RenderJob) => {
};
export const updateAvailable = (signal: AbortSignal) => {
+ console.log('calling updateAvailable');
return callApi('/api/update-available', {}, signal);
};
diff --git a/packages/cli/src/editor/components/UpdateCheck.tsx b/packages/cli/src/editor/components/UpdateCheck.tsx
index 0a0e06d74e..8b78cccac9 100644
--- a/packages/cli/src/editor/components/UpdateCheck.tsx
+++ b/packages/cli/src/editor/components/UpdateCheck.tsx
@@ -1,6 +1,12 @@
-import React, {useCallback, useContext, useEffect, useState} from 'react';
+import React, {
+ useCallback,
+ useContext,
+ useEffect,
+ useMemo,
+ useState,
+} from 'react';
import type {PackageManager} from '../../preview-server/get-package-manager';
-import {BLUE} from '../helpers/colors';
+import {BLUE, FAIL_COLOR} from '../helpers/colors';
import {ModalsContext} from '../state/modals';
import {useZIndex} from '../state/z-index';
import {updateAvailable} from './RenderQueue/actions';
@@ -23,11 +29,22 @@ const buttonStyle: React.CSSProperties = {
fontSize: 14,
};
+export type Bug = {
+ title: string;
+ description: string;
+ link: string;
+ versions: string[];
+};
+
export const UpdateCheck = () => {
const [info, setInfo] = useState<UpdateInfo | null>(null);
const {setSelectedModal} = useContext(ModalsContext);
const {tabIndex} = useZIndex();
+ const [knownBugs, setKnownBugs] = useState<Bug[] | null>(null);
+ const hasKnownBugs = useMemo(() => {
+ return knownBugs && knownBugs.length > 0;
+ }, [knownBugs]);
const checkForUpdates = useCallback(() => {
const controller = new AbortController();
@@ -53,6 +70,19 @@ export const UpdateCheck = () => {
};
}, [checkForUpdates]);
+ useEffect(() => {
+ if (!info) {
+ return;
+ }
+
+ fetch(
+ `https://latest-stable-release.vercel.app/api/version?query=${info.currentVersion}`,
+ ).then(async (res) => {
+ const {body} = await res.json();
+ setKnownBugs(body);
+ });
+ }, [info]);
+
const openModal = useCallback(() => {
setSelectedModal({
type: 'update',
@@ -60,22 +90,29 @@ export const UpdateCheck = () => {
});
}, [info, setSelectedModal]);
- if (!info) {
- return null;
- }
+ const dynButtonStyle: React.CSSProperties = useMemo(() => {
+ return {
+ ...buttonStyle,
+ color: hasKnownBugs ? FAIL_COLOR : BLUE,
+ };
+ }, [hasKnownBugs]);
+
+ // if (!info) {
+ // return null;
+ // }
- if (!info.updateAvailable) {
- return null;
- }
+ // if (!info.updateAvailable) {
+ // return null;
+ // }
return (
<button
tabIndex={tabIndex}
- style={buttonStyle}
+ style={dynButtonStyle}
onClick={openModal}
type="button"
>
- Update available!
+ {hasKnownBugs ? 'This version has known bugs!' : 'Update available!'}
</button>
);
};
diff --git a/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx b/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx
index 85c85e17df..e052462736 100644
--- a/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx
+++ b/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx
@@ -1,4 +1,10 @@
-import React, {useCallback, useContext} from 'react';
+import React, {
+ useCallback,
+ useContext,
+ useEffect,
+ useMemo,
+ useState,
+} from 'react';
import {SELECTED_BACKGROUND} from '../../helpers/colors';
import {copyText} from '../../helpers/copy-text';
import {ModalsContext} from '../../state/modals';
@@ -7,7 +13,7 @@ import {Flex, Row, Spacing} from '../layout';
import {ModalContainer} from '../ModalContainer';
import {NewCompHeader} from '../ModalHeader';
import {sendErrorNotification} from '../Notifications/NotificationCenter';
-import type {UpdateInfo} from '../UpdateCheck';
+import type {Bug, UpdateInfo} from '../UpdateCheck';
const container: React.CSSProperties = {
padding: 20,
@@ -39,20 +45,35 @@ export const UpdateModal: React.FC<{
info: UpdateInfo;
}> = ({info}) => {
const {setSelectedModal} = useContext(ModalsContext);
-
+ const [knownBugs, setKnownBugs] = useState<Bug[] | null>(null);
const onQuit = useCallback(() => {
setSelectedModal(null);
}, [setSelectedModal]);
+ const hasKnownBugs = useMemo(() => {
+ return knownBugs && knownBugs?.length > 0;
+ }, [knownBugs]);
const command = commands[info.packageManager];
+ useEffect(() => {
+ fetch(
+ `https://latest-stable-release.vercel.app/api/version?query=${info.currentVersion}`,
+ ).then(async (res) => {
+ const {body} = await res.json();
+ setKnownBugs(body);
+ });
+ }, [info.currentVersion]);
return (
<ModalContainer onOutsideClick={onQuit} onEscape={onQuit}>
<NewCompHeader title="Update available" />
<div style={container}>
- <p>
- A new update for Remotion is available! Run the following command:
- </p>
+ {hasKnownBugs ? (
+ <p>There are known bugs in {info.currentVersion}. Upgrade now</p>
+ ) : (
+ <p>
+ A new update for Remotion is availale! Run the following command:
+ </p>
+ )}
<Row align="center">
<Flex>
<pre
diff --git a/packages/cli/src/preview-server/routes/update-available.ts b/packages/cli/src/preview-server/routes/update-available.ts
index aeba43edae..5f87b3f813 100644
--- a/packages/cli/src/preview-server/routes/update-available.ts
+++ b/packages/cli/src/preview-server/routes/update-available.ts
@@ -10,5 +10,6 @@ export const handleUpdate: ApiHandler<
UpdateAvailableResponse
> = async ({remotionRoot}) => {
const data = await isUpdateAvailableWithTimeout(remotionRoot);
+
return data;
};
diff --git a/packages/cli/src/preview-server/update-available.ts b/packages/cli/src/preview-server/update-available.ts
index dd19a1fee5..263b5621f9 100644
--- a/packages/cli/src/preview-server/update-available.ts
+++ b/packages/cli/src/preview-server/update-available.ts
@@ -11,6 +11,7 @@ const isUpdateAvailable = async ({
currentVersion: string;
}): Promise<UpdateAvailableResponse> => {
const latest = await getLatestRemotionVersion();
+
const pkgManager = getPackageManager(remotionRoot, undefined);
return {
diff --git a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar
index 0239077e42..c7cef750f4 100644
Binary files a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar differ