Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Configure license from Studio (#9516)

Jonny Burger38e6a9396add
diff --git a/packages/cli/src/studio.ts b/packages/cli/src/studio.ts
index 08b27130ee..cb451fbe6c 100644
--- a/packages/cli/src/studio.ts
+++ b/packages/cli/src/studio.ts
@@ -247,6 +247,7 @@ export const studioCommand = async (
forceNew: forceNewStudioOption.getValue({commandLine: parsedCli}).value,
rspack: useRspack,
getStudioRuntimeConfig,
+ configFile,
});
if (result.type === 'already-running') {
diff --git a/packages/studio-server/src/preview-server/api-routes.ts b/packages/studio-server/src/preview-server/api-routes.ts
index dc2ff91b9b..7bc2aef704 100644
--- a/packages/studio-server/src/preview-server/api-routes.ts
+++ b/packages/studio-server/src/preview-server/api-routes.ts
@@ -48,6 +48,7 @@ import {handleUpdate} from './routes/update-available';
import {updateDefaultPropsHandler} from './routes/update-default-props';
import {updateEffectKeyframeSettingsHandler} from './routes/update-effect-keyframe-settings';
import {updateElementInstallTargetHandler} from './routes/update-element-install-target';
+import {updatePublicLicenseHandler} from './routes/update-public-license';
import {updateSequenceKeyframeSettingsHandler} from './routes/update-sequence-keyframe-settings';
export const allApiRoutes: {
@@ -98,6 +99,7 @@ export const allApiRoutes: {
'/api/delete-static-file': deleteStaticFileHandler,
'/api/rename-static-file': renameStaticFileHandler,
'/api/restart-studio': handleRestartStudio,
+ '/api/update-public-license': updatePublicLicenseHandler,
'/api/install-package': handleInstallPackage,
'/api/insert-jsx-element': insertJsxElementHandler,
'/api/insert-element': insertElementHandler,
diff --git a/packages/studio-server/src/preview-server/api-types.ts b/packages/studio-server/src/preview-server/api-types.ts
index ad8dc35c62..60da295a70 100644
--- a/packages/studio-server/src/preview-server/api-types.ts
+++ b/packages/studio-server/src/preview-server/api-types.ts
@@ -28,4 +28,5 @@ export type ApiHandler<ReqData, ResData> = (params: {
methods: QueueMethods;
publicDir: string;
binariesDirectory: string | null;
+ configFile: string | null;
}) => Promise<ResData>;
diff --git a/packages/studio-server/src/preview-server/handler.ts b/packages/studio-server/src/preview-server/handler.ts
index d992639807..3d15b4192e 100644
--- a/packages/studio-server/src/preview-server/handler.ts
+++ b/packages/studio-server/src/preview-server/handler.ts
@@ -14,6 +14,7 @@ export const handleRequest = async <Req, Res>({
methods,
binariesDirectory,
publicDir,
+ configFile,
}: {
remotionRoot: string;
publicDir: string;
@@ -21,6 +22,7 @@ export const handleRequest = async <Req, Res>({
response: ServerResponse;
entryPoint: string;
binariesDirectory: string | null;
+ configFile: string | null;
handler: ApiHandler<Req, Res>;
logLevel: LogLevel;
methods: QueueMethods;
@@ -49,6 +51,7 @@ export const handleRequest = async <Req, Res>({
methods,
binariesDirectory,
publicDir,
+ configFile,
});
response.end(
diff --git a/packages/studio-server/src/preview-server/routes/update-public-license.ts b/packages/studio-server/src/preview-server/routes/update-public-license.ts
new file mode 100644
index 0000000000..84d1aa28f5
--- /dev/null
+++ b/packages/studio-server/src/preview-server/routes/update-public-license.ts
@@ -0,0 +1,82 @@
+import {readFileSync} from 'node:fs';
+import type {
+ UpdatePublicLicenseRequest,
+ UpdatePublicLicenseResponse,
+} from '@remotion/studio-shared';
+import * as recast from 'recast';
+import {parseAst} from '../../codemods/parse-ast';
+import {writeFileAndNotifyFileWatchers} from '../../file-watcher';
+import type {ApiHandler} from '../api-types';
+
+export const updatePublicLicenseInConfig = ({
+ configContents,
+ publicLicenseKey,
+}: {
+ configContents: string;
+ publicLicenseKey: string;
+}) => {
+ const ast = parseAst(configContents);
+ recast.types.visit(ast.program, {
+ visitExpressionStatement(path) {
+ const {expression} = path.node;
+ if (
+ expression.type === 'CallExpression' &&
+ expression.callee.type === 'MemberExpression' &&
+ !expression.callee.computed &&
+ expression.callee.object.type === 'Identifier' &&
+ expression.callee.object.name === 'Config' &&
+ expression.callee.property.type === 'Identifier' &&
+ expression.callee.property.name === 'setPublicLicenseKey'
+ ) {
+ path.prune();
+ return false;
+ }
+
+ this.traverse(path);
+ },
+ });
+
+ const configWithoutExistingCalls = recast.print(ast, {
+ lineTerminator: '\n',
+ }).code;
+ const separator = configWithoutExistingCalls.endsWith('\n') ? '' : '\n';
+ const escapedPublicLicenseKey = publicLicenseKey
+ .replaceAll('\\', '\\\\')
+ .replaceAll("'", "\\'")
+ .replaceAll('\r', '\\r')
+ .replaceAll('\n', '\\n')
+ .replaceAll('\u2028', '\\u2028')
+ .replaceAll('\u2029', '\\u2029');
+ return `${configWithoutExistingCalls}${separator}Config.setPublicLicenseKey('${escapedPublicLicenseKey}');\n`;
+};
+
+export const updatePublicLicenseHandler: ApiHandler<
+ UpdatePublicLicenseRequest,
+ UpdatePublicLicenseResponse
+> = ({input, configFile}) => {
+ if (configFile === null || configFile === undefined) {
+ return Promise.resolve({
+ success: false,
+ reason: 'No Remotion config file was loaded.',
+ });
+ }
+
+ if (input.publicLicenseKey.length === 0) {
+ return Promise.resolve({
+ success: false,
+ reason: 'The public license key must not be empty.',
+ });
+ }
+
+ const configContents = readFileSync(configFile, 'utf8');
+ writeFileAndNotifyFileWatchers(
+ configFile,
+ updatePublicLicenseInConfig({
+ configContents,
+ publicLicenseKey: input.publicLicenseKey,
+ }),
+ undefined,
+ );
+
+ return Promise.resolve({success: true});
+};
diff --git a/packages/studio-server/src/preview-server/start-server.ts b/packages/studio-server/src/preview-server/start-server.ts
index d10b2d2ed9..0a4e3f1804 100644
--- a/packages/studio-server/src/preview-server/start-server.ts
+++ b/packages/studio-server/src/preview-server/start-server.ts
@@ -70,6 +70,7 @@ export const startServer = async (options: {
forceNew: boolean;
rspack: boolean;
getStudioRuntimeConfig: () => StudioRuntimeConfig;
+ configFile: string | null;
}): Promise<StartServerResult> => {
const desiredPort =
options?.port ??
@@ -177,6 +178,7 @@ export const startServer = async (options: {
getPreviewSampleRate: options.getPreviewSampleRate,
enableCrossSiteIsolation: options.enableCrossSiteIsolation,
getStudioRuntimeConfig: options.getStudioRuntimeConfig,
+ configFile: options.configFile,
});
})
.catch((err) => {
diff --git a/packages/studio-server/src/routes.ts b/packages/studio-server/src/routes.ts
index 4f14ec39fc..0a6057b0a2 100644
--- a/packages/studio-server/src/routes.ts
+++ b/packages/studio-server/src/routes.ts
@@ -595,6 +595,7 @@ export const handleRoutes = ({
getPreviewSampleRate,
enableCrossSiteIsolation,
getStudioRuntimeConfig,
+ configFile,
}: {
staticHash: string;
staticHashPrefix: string;
@@ -619,6 +620,7 @@ export const handleRoutes = ({
getPreviewSampleRate: () => number | null;
enableCrossSiteIsolation: boolean;
getStudioRuntimeConfig: () => StudioRuntimeConfig;
+ configFile: string | null;
}): Promise<void> => {
const url = new URL(request.url as string, 'http://localhost');
@@ -690,6 +692,7 @@ export const handleRoutes = ({
methods,
binariesDirectory,
publicDir,
+ configFile,
});
}
}
diff --git a/packages/studio-server/src/start-studio.ts b/packages/studio-server/src/start-studio.ts
index 58d677252f..49f82e4930 100644
--- a/packages/studio-server/src/start-studio.ts
+++ b/packages/studio-server/src/start-studio.ts
@@ -60,6 +60,7 @@ export const startStudio = async ({
forceNew,
rspack,
getStudioRuntimeConfig,
+ configFile,
}: {
browserArgs: string;
browserFlag: string;
@@ -92,6 +93,7 @@ export const startStudio = async ({
forceNew: boolean;
rspack: boolean;
getStudioRuntimeConfig: () => StudioRuntimeConfig;
+ configFile: string | null;
}): Promise<StartStudioResult> => {
try {
if (typeof Bun === 'undefined') {
@@ -173,6 +175,7 @@ export const startStudio = async ({
forceNew,
rspack,
getStudioRuntimeConfig,
+ configFile,
});
if (result.type === 'already-running') {
diff --git a/packages/studio-server/src/test/apply-codemod.test.ts b/packages/studio-server/src/test/apply-codemod.test.ts
index cdb825dfb3..548b84b472 100644
--- a/packages/studio-server/src/test/apply-codemod.test.ts
+++ b/packages/studio-server/src/test/apply-codemod.test.ts
@@ -321,6 +321,7 @@ const getHandlerOptions = <T>({
},
publicDir: remotionRoot,
binariesDirectory: null,
+ configFile: null,
});
const runCompositionCodemodUndoRedoTest = async ({
diff --git a/packages/studio-server/src/test/download-remote-asset.test.ts b/packages/studio-server/src/test/download-remote-asset.test.ts
index 5958b03e2b..0551189543 100644
--- a/packages/studio-server/src/test/download-remote-asset.test.ts
+++ b/packages/studio-server/src/test/download-remote-asset.test.ts
@@ -67,6 +67,7 @@ test('follows validated redirects for remote assets', async () => {
try {
const response = await downloadRemoteAssetHandler({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
input: {url: 'https://93.184.216.34/raw-link'},
logLevel: 'info',
@@ -135,6 +136,7 @@ test('blocks redirects to private IP addresses', async () => {
await expect(
downloadRemoteAssetHandler({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
input: {url: 'https://93.184.216.34/raw-link'},
logLevel: 'info',
diff --git a/packages/studio-server/src/test/file-source-route.test.ts b/packages/studio-server/src/test/file-source-route.test.ts
index a01fff164c..5ee5368ec3 100644
--- a/packages/studio-server/src/test/file-source-route.test.ts
+++ b/packages/studio-server/src/test/file-source-route.test.ts
@@ -69,6 +69,7 @@ test('serves file source from an origin-less GET request', async () => {
await handleRoutes({
binariesDirectory: null,
+ configFile: null,
enableCrossSiteIsolation: false,
entryPoint: '',
getAudioLatencyHint: () => null,
diff --git a/packages/studio-server/src/test/handler.test.ts b/packages/studio-server/src/test/handler.test.ts
index e006d5e3ea..22b3da4bf4 100644
--- a/packages/studio-server/src/test/handler.test.ts
+++ b/packages/studio-server/src/test/handler.test.ts
@@ -59,6 +59,7 @@ test('rejects cross-origin API requests before calling the handler', async () =>
await expect(
handleRequest({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
handler: () => {
didCallHandler = true;
@@ -90,6 +91,7 @@ test('allows same-origin API requests from non-local peers', async () => {
await handleRequest({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
handler: ({input}) => {
return Promise.resolve({input});
@@ -129,6 +131,7 @@ test('rejects API requests without an Origin header before calling the handler',
await expect(
handleRequest({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
handler: () => {
didCallHandler = true;
@@ -160,6 +163,7 @@ test('allows GET API requests without an Origin header', async () => {
await handleRequest({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
handler: ({input}) => {
return Promise.resolve({input});
@@ -197,6 +201,7 @@ test('allows HEAD API requests without an Origin header', async () => {
await handleRequest({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
handler: ({input}) => {
return Promise.resolve({input});
@@ -236,6 +241,7 @@ test('rejects requests with a mismatched Origin scheme before calling the handle
await expect(
handleRequest({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
handler: () => {
didCallHandler = true;
@@ -267,6 +273,7 @@ test('allows same-origin API requests', async () => {
await handleRequest({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
handler: ({input}) => {
return Promise.resolve({input});
diff --git a/packages/studio-server/src/test/resolve-composition-component.test.ts b/packages/studio-server/src/test/resolve-composition-component.test.ts
index 47a4a1c28a..65bba7b42c 100644
--- a/packages/studio-server/src/test/resolve-composition-component.test.ts
+++ b/packages/studio-server/src/test/resolve-composition-component.test.ts
@@ -1855,6 +1855,7 @@ test('rejects composition insertion requests that traverse out of the project ro
},
publicDir: tempDir,
binariesDirectory: null,
+ configFile: null,
});
expect(response.success).toBe(false);
diff --git a/packages/studio-server/src/test/save-sequence-props.test.ts b/packages/studio-server/src/test/save-sequence-props.test.ts
index 10f4205133..e46b5aff00 100644
--- a/packages/studio-server/src/test/save-sequence-props.test.ts
+++ b/packages/studio-server/src/test/save-sequence-props.test.ts
@@ -188,6 +188,7 @@ export const Comp = () => {
},
publicDir: '',
binariesDirectory: null,
+ configFile: null,
});
const output = readFileSync(filePath, 'utf-8');
@@ -300,6 +301,7 @@ export const Comp = () => {
},
publicDir: '',
binariesDirectory: null,
+ configFile: null,
});
const output = readFileSync(filePath, 'utf-8');
diff --git a/packages/studio-server/src/test/split-jsx-sequence.test.ts b/packages/studio-server/src/test/split-jsx-sequence.test.ts
index 02f38e7046..57f66353de 100644
--- a/packages/studio-server/src/test/split-jsx-sequence.test.ts
+++ b/packages/studio-server/src/test/split-jsx-sequence.test.ts
@@ -185,6 +185,7 @@ const getHandlerOptions = <T>({
},
publicDir: remotionRoot,
binariesDirectory: null,
+ configFile: null,
});
test('splitJsxSequenceHandler writes success and failure responses', async () => {
diff --git a/packages/studio-server/src/test/update-element-install-target.test.ts b/packages/studio-server/src/test/update-element-install-target.test.ts
index f5adeaace4..527595c5e6 100644
--- a/packages/studio-server/src/test/update-element-install-target.test.ts
+++ b/packages/studio-server/src/test/update-element-install-target.test.ts
@@ -27,6 +27,7 @@ const callHandler = ({
}) => {
return updateElementInstallTargetHandler({
binariesDirectory: null,
+ configFile: null,
entryPoint: '',
input,
logLevel: 'info',
diff --git a/packages/studio-server/src/test/update-public-license.test.ts b/packages/studio-server/src/test/update-public-license.test.ts
new file mode 100644
index 0000000000..604ee8d429
--- /dev/null
+++ b/packages/studio-server/src/test/update-public-license.test.ts
@@ -0,0 +1,70 @@
+import {expect, test} from 'bun:test';
+import {updatePublicLicenseInConfig} from '../preview-server/routes/update-public-license';
+
+test('appends the free license to the config on a new line', () => {
+ expect(
+ updatePublicLicenseInConfig({
+ configContents: "import {Config} from '@remotion/cli/config';\n",
+ publicLicenseKey: 'free-license',
+ }),
+ ).toBe(
+ "import {Config} from '@remotion/cli/config';\nConfig.setPublicLicenseKey('free-license');\n",
+ );
+});
+
+test('escapes a public license key before adding it to the config', () => {
+ expect(
+ updatePublicLicenseInConfig({
+ configContents: "import {Config} from '@remotion/cli/config';",
+ publicLicenseKey: "rm_pub_'quoted",
+ }),
+ ).toBe(
+ "import {Config} from '@remotion/cli/config';\nConfig.setPublicLicenseKey('rm_pub_\\'quoted');\n",
+ );
+});
+
+test('replaces all existing public license key calls', () => {
+ expect(
+ updatePublicLicenseInConfig({
+ configContents: [
+ "import {Config} from '@remotion/cli/config';",
+ "Config.setPublicLicenseKey('free-license');",
+ 'Config.setPublicLicenseKey(',
+ "\t'rm_pub_old',",
+ ');',
+ 'Config.setOverwriteOutput(true);',
+ '',
+ ].join('\n'),
+ publicLicenseKey: 'rm_pub_new',
+ }),
+ ).toBe(
+ [
+ "import {Config} from '@remotion/cli/config';",
+ 'Config.setOverwriteOutput(true);',
+ "Config.setPublicLicenseKey('rm_pub_new');",
+ '',
+ ].join('\n'),
+ );
+});
+
+test('preserves commented and string references to the setter', () => {
+ expect(
+ updatePublicLicenseInConfig({
+ configContents: [
+ "import {Config} from '@remotion/cli/config';",
+ "// Config.setPublicLicenseKey('commented');",
+ 'const example = "Config.setPublicLicenseKey(\'example\');";',
+ '',
+ ].join('\n'),
+ publicLicenseKey: 'free-license',
+ }),
+ ).toBe(
+ [
+ "import {Config} from '@remotion/cli/config';",
+ "// Config.setPublicLicenseKey('commented');",
+ 'const example = "Config.setPublicLicenseKey(\'example\');";',
+ "Config.setPublicLicenseKey('free-license');",
+ '',
+ ].join('\n'),
+ );
+});
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index 21b9769e2f..e25fe5400a 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -840,6 +840,18 @@ export type ProjectInfoResponse = {
export type RestartStudioRequest = {};
export type RestartStudioResponse = {};
+export type UpdatePublicLicenseRequest = {
+ publicLicenseKey: string;
+};
+export type UpdatePublicLicenseResponse =
+ | {
+ success: true;
+ }
+ | {
+ success: false;
+ reason: string;
+ };
+
export type InstallPackageRequest = {
packageNames: string[];
};
@@ -1003,6 +1015,10 @@ export type ApiRoutes = {
RenameStaticFileResponse
>;
'/api/restart-studio': ReqAndRes<RestartStudioRequest, RestartStudioResponse>;
+ '/api/update-public-license': ReqAndRes<
+ UpdatePublicLicenseRequest,
+ UpdatePublicLicenseResponse
+ >;
'/api/install-package': ReqAndRes<
InstallPackageRequest,
InstallPackageResponse
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.ts
index 266f3547e7..946f4e68a4 100644
--- a/packages/studio-shared/src/index.ts
+++ b/packages/studio-shared/src/index.ts
@@ -106,6 +106,8 @@ export {
UpdateEffectKeyframeSettingsResponse,
UpdateElementInstallTargetRequest,
UpdateElementInstallTargetResponse,
+ UpdatePublicLicenseRequest,
+ UpdatePublicLicenseResponse,
UpdateSequenceKeyframeSettingsRequest,
UpdateSequenceKeyframeSettingsResponse,
type AddEffectKeyframe,
diff --git a/packages/studio/src/components/Checkbox.tsx b/packages/studio/src/components/Checkbox.tsx
index 3b68a32413..20e5e10e59 100644
--- a/packages/studio/src/components/Checkbox.tsx
+++ b/packages/studio/src/components/Checkbox.tsx
@@ -2,7 +2,6 @@ import React, {useEffect, useMemo, useRef} from 'react';
import {
INPUT_BACKGROUND,
BLACK_ALPHA_60,
- LIGHT_TEXT,
TRANSPARENT,
WHITE,
} from '../helpers/colors';
@@ -51,7 +50,7 @@ export const Checkbox: React.FC<{
() => ({
width: bulletSize,
height: bulletSize,
- backgroundColor: LIGHT_TEXT,
+ backgroundColor: WHITE,
borderRadius: '50%',
}),
[bulletSize],
diff --git a/packages/studio/src/components/ConfigureLicenseModal.tsx b/packages/studio/src/components/ConfigureLicenseModal.tsx
new file mode 100644
index 0000000000..6957285cbb
--- /dev/null
+++ b/packages/studio/src/components/ConfigureLicenseModal.tsx
@@ -0,0 +1,338 @@
+import React, {
+ useCallback,
+ useContext,
+ useEffect,
+ useMemo,
+ useState,
+} from 'react';
+import {LIGHT_TEXT, WHITE} from '../helpers/colors';
+import {ModalsContext} from '../state/modals';
+import {callApi} from './call-api';
+import {Checkbox} from './Checkbox';
+import {Row, Spacing} from './layout';
+import {
+ fetchLicenseKeyDetails,
+ hasActiveCompanyLicense,
+ LicenseKeyDetailsDisplay,
+ type LicenseKeyDetails,
+ validateLicenseKey,
+} from './LicenseKeyValidation';
+import {ModalButton} from './ModalButton';
+import {ModalContainer} from './ModalContainer';
+import {ModalFooterContainer} from './ModalFooter';
+import {ModalHeader} from './ModalHeader';
+import {RemotionInput} from './NewComposition/RemInput';
+import {ValidationMessage} from './NewComposition/ValidationMessage';
+
+type LicenseType = 'free' | 'company' | null;
+
+const content: React.CSSProperties = {
+ padding: 16,
+ width: 540,
+ maxWidth: 'calc(100vw - 40px)',
+};
+
+const description: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontFamily: 'sans-serif',
+ fontSize: 14,
+ lineHeight: 1.5,
+ margin: 0,
+ marginTop: 10,
+};
+
+const descriptionLink: React.CSSProperties = {
+ color: WHITE,
+ fontFamily: 'sans-serif',
+ fontSize: 14,
+ lineHeight: '21px',
+};
+
+const checkboxRow: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
+ cursor: 'pointer',
+ marginTop: 5,
+ marginBottom: 5,
+};
+
+const checkboxLabel: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontFamily: 'sans-serif',
+ fontSize: 14,
+ lineHeight: '20px',
+ cursor: 'pointer',
+ userSelect: 'none',
+};
+
+const inputLabel: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ display: 'block',
+ fontFamily: 'sans-serif',
+ fontSize: 13,
+ lineHeight: '20px',
+ marginBottom: 6,
+ marginTop: 10,
+};
+
+export const ConfigureLicenseModal: React.FC<{
+ readonly initialPublicLicenseKey: string | null;
+}> = ({initialPublicLicenseKey}) => {
+ const {setSelectedModal} = useContext(ModalsContext);
+ const initialLicenseType: LicenseType =
+ initialPublicLicenseKey === 'free-license'
+ ? 'free'
+ : initialPublicLicenseKey === null
+ ? null
+ : 'company';
+ const [licenseType, setLicenseType] =
+ useState<LicenseType>(initialLicenseType);
+ const [companyLicenseKey, setCompanyLicenseKey] = useState<string>(
+ initialLicenseType === 'company' ? (initialPublicLicenseKey ?? '') : '',
+ );
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const [isValidatingLicenseKey, setIsValidatingLicenseKey] = useState(false);
+ const [remoteValidationMessage, setRemoteValidationMessage] = useState<
+ string | null
+ >(null);
+ const [licenseKeyDetails, setLicenseKeyDetails] =
+ useState<LicenseKeyDetails | null>(null);
+
+ const dismiss = useCallback(() => {
+ setSelectedModal(null);
+ }, [setSelectedModal]);
+
+ const chooseFreeLicense = useCallback(() => {
+ setLicenseType('free');
+ setError(null);
+ }, []);
+
+ const chooseCompanyLicense = useCallback(() => {
+ setLicenseType('company');
+ setError(null);
+ }, []);
+
+ const publicLicenseKey = useMemo(() => {
+ if (licenseType === 'free') {
+ return 'free-license';
+ }
+
+ if (licenseType === 'company') {
+ return companyLicenseKey.trim();
+ }
+
+ return '';
+ }, [companyLicenseKey, licenseType]);
+
+ const localLicenseKeyValidation = useMemo(
+ () => validateLicenseKey(companyLicenseKey.trim()),
+ [companyLicenseKey],
+ );
+
+ useEffect(() => {
+ let cancelled = false;
+
+ setLicenseKeyDetails(null);
+ setRemoteValidationMessage(null);
+
+ if (licenseType !== 'company' || !localLicenseKeyValidation.valid) {
+ setIsValidatingLicenseKey(false);
+ return () => {
+ cancelled = true;
+ };
+ }
+
+ setIsValidatingLicenseKey(true);
+ fetchLicenseKeyDetails(companyLicenseKey.trim())
+ .then((details) => {
+ if (cancelled) {
+ return;
+ }
+
+ setIsValidatingLicenseKey(false);
+ if (details.isValid) {
+ setLicenseKeyDetails(details);
+ } else {
+ setRemoteValidationMessage(
+ 'License key is invalid or has been reset',
+ );
+ }
+ })
+ .catch(() => {
+ if (cancelled) {
+ return;
+ }
+
+ setIsValidatingLicenseKey(false);
+ setRemoteValidationMessage('Failed to fetch license key details');
+ });
+
+ return () => {
+ cancelled = true;
+ };
+ }, [companyLicenseKey, licenseType, localLicenseKeyValidation.valid]);
+
+ const companyLicenseKeyIsValid =
+ localLicenseKeyValidation.valid &&
+ licenseKeyDetails?.isValid === true &&
+ !isValidatingLicenseKey;
+
+ const submit = useCallback(async () => {
+ if (publicLicenseKey.length === 0) {
+ setError(
+ licenseType === null
+ ? 'Select a license type.'
+ : 'Enter your public license key.',
+ );
+ return;
+ }
+
+ if (licenseType === 'company' && !companyLicenseKeyIsValid) {
+ return;
+ }
+
+ setIsSubmitting(true);
+ setError(null);
+ try {
+ const response = await callApi('/api/update-public-license', {
+ publicLicenseKey,
+ });
+ if (!response.success) {
+ setError(response.reason);
+ setIsSubmitting(false);
+ return;
+ }
+
+ dismiss();
+ } catch (err) {
+ setError((err as Error).message);
+ setIsSubmitting(false);
+ }
+ }, [companyLicenseKeyIsValid, dismiss, licenseType, publicLicenseKey]);
+
+ return (
+ <ModalContainer onEscape={dismiss} onOutsideClick={dismiss}>
+ <ModalHeader title="Configure License" onClose={dismiss} />
+ <div style={content}>
+ <p style={description}>
+ Remotion is free if you are an individual or company with a headcount
+ of 3 or less. See{' '}
+ <a style={descriptionLink} href="https://remotion.dev/license">
+ LICENSE.md
+ </a>
+ .
+ </p>
+ <Spacing y={2} />
+ <div style={checkboxRow} onClick={chooseFreeLicense}>
+ <Checkbox
+ checked={licenseType === 'free'}
+ onChange={chooseFreeLicense}
+ name="free-license"
+ rounded
+ />
+ <Spacing x={1} />
+ <div style={checkboxLabel}>I am eligible for the Free License</div>
+ </div>
+ <div style={checkboxRow} onClick={chooseCompanyLicense}>
+ <Checkbox
+ checked={licenseType === 'company'}
+ onChange={chooseCompanyLicense}
+ name="company-license"
+ rounded
+ />
+ <Spacing x={1} />
+ <div style={checkboxLabel}>I need a Company License</div>
+ </div>
+ {licenseType === 'company' ? (
+ <>
+ <p style={description}>
+ Visit{' '}
+ <a style={descriptionLink} href="https://remotion.pro/license">
+ remotion.pro/license
+ </a>{' '}
+ to obtain a license key. Enter the public license key from
+ {' "License Keys".'}
+ </p>
+ <label style={inputLabel}>
+ Public license key
+ <RemotionInput
+ status={
+ localLicenseKeyValidation.message ||
+ remoteValidationMessage ||
+ (licenseKeyDetails !== null &&
+ !hasActiveCompanyLicense(licenseKeyDetails))
+ ? 'error'
+ : 'ok'
+ }
+ rightAlign={false}
+ value={companyLicenseKey}
+ onChange={(event) => {
+ setCompanyLicenseKey(event.target.value);
+ setError(null);
+ }}
+ placeholder="rm_pub_..."
+ autoFocus
+ />
+ </label>
+ {localLicenseKeyValidation.message ? (
+ <>
+ <Spacing y={1} />
+ <ValidationMessage
+ message={localLicenseKeyValidation.message}
+ align="flex-start"
+ type="error"
+ />
+ </>
+ ) : null}
+ {remoteValidationMessage ? (
+ <>
+ <Spacing y={1} />
+ <ValidationMessage
+ message={remoteValidationMessage}
+ align="flex-start"
+ type="error"
+ />
+ </>
+ ) : null}
+ {isValidatingLicenseKey ? (
+ <>
+ <Spacing y={1} />
+ <p style={description}>Loading license key details...</p>
+ </>
+ ) : null}
+ {licenseKeyDetails ? (
+ <LicenseKeyDetailsDisplay details={licenseKeyDetails} />
+ ) : null}
+ </>
+ ) : null}
+ {error ? (
+ <>
+ <Spacing y={1.5} />
+ <ValidationMessage
+ message={error}
+ align="flex-start"
+ type="error"
+ />
+ </>
+ ) : null}
+ </div>
+ <ModalFooterContainer>
+ <Row justify="flex-end">
+ <ModalButton
+ onClick={submit}
+ disabled={
+ isSubmitting ||
+ publicLicenseKey.length === 0 ||
+ (licenseType === 'company' && !companyLicenseKeyIsValid)
+ }
+ autoFocus={licenseType !== 'company'}
+ >
+ {isSubmitting ? 'Submitting...' : 'Submit and reload'}
+ </ModalButton>
+ </Row>
+ </ModalFooterContainer>
+ </ModalContainer>
+ );
+};
diff --git a/packages/studio/src/components/LicenseKeyValidation.tsx b/packages/studio/src/components/LicenseKeyValidation.tsx
new file mode 100644
index 0000000000..71db244512
--- /dev/null
+++ b/packages/studio/src/components/LicenseKeyValidation.tsx
@@ -0,0 +1,181 @@
+import React from 'react';
+import {FAIL_COLOR} from '../helpers/colors';
+import {CheckCircleFilled} from '../icons/check-circle-filled';
+import {InspectorInlineAction} from './InspectorPanel/common';
+
+const LICENSE_KEY_LENGTH = 55;
+const LICENSE_KEY_PREFIX = 'rm_pub_';
+const PRO_HOST = 'https://www.remotion.pro';
+
+export type LicenseKeyDetails = {
+ readonly isValid: boolean;
+ readonly hasActiveSubscription: boolean | null;
+ readonly projectName: string;
+ readonly projectSlug: string;
+};
+
+export const hasActiveCompanyLicense = (details: LicenseKeyDetails) => {
+ return details.hasActiveSubscription === true;
+};
+
+export type LicenseKeyValidationResult = {
+ readonly valid: boolean;
+ readonly message: string | null;
+};
+
+export const validateLicenseKey = (key: string): LicenseKeyValidationResult => {
+ if (key.length === 0) {
+ return {valid: false, message: null};
+ }
+
+ if (!key.startsWith(LICENSE_KEY_PREFIX)) {
+ return {
+ valid: false,
+ message: `License key must start with "${LICENSE_KEY_PREFIX}"`,
+ };
+ }
+
+ const afterPrefix = key.slice(LICENSE_KEY_PREFIX.length);
+ if (!/^[a-zA-Z0-9]*$/.test(afterPrefix)) {
+ return {
+ valid: false,
+ message:
+ 'License key must contain only alphanumeric characters after the prefix',
+ };
+ }
+
+ if (key.length !== LICENSE_KEY_LENGTH) {
+ return {
+ valid: false,
+ message: `License key must be ${LICENSE_KEY_LENGTH} characters long`,
+ };
+ }
+
+ return {valid: true, message: null};
+};
+
+export const fetchLicenseKeyDetails = async (
+ licenseKey: string,
+): Promise<LicenseKeyDetails> => {
+ const response = await fetch(`${PRO_HOST}/api/validate-license-key`, {
+ method: 'POST',
+ body: JSON.stringify({
+ licenseKey,
+ }),
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ });
+
+ return response.json();
+};
+
+const actionStyle: React.CSSProperties = {
+ cursor: 'pointer',
+ marginLeft: 0,
+ marginRight: 0,
+ width: '100%',
+};
+
+const actionContent: React.CSSProperties = {
+ alignItems: 'center',
+ color: 'inherit',
+ display: 'flex',
+ fontFamily: 'sans-serif',
+ fontSize: 13,
+ gap: 8,
+ lineHeight: '18px',
+ minWidth: 0,
+ width: '100%',
+};
+
+const actionText: React.CSSProperties = {
+ color: 'inherit',
+ flex: 1,
+ fontFamily: 'sans-serif',
+ fontSize: 13,
+ lineHeight: '18px',
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+const actionLabel: React.CSSProperties = {
+ color: 'inherit',
+ flexShrink: 0,
+ fontFamily: 'sans-serif',
+ fontSize: 13,
+ lineHeight: '18px',
+};
+
+const inactiveLicenseText: React.CSSProperties = {
+ ...actionText,
+ color: FAIL_COLOR,
+};
+
+const iconStyle: React.CSSProperties = {
+ width: 14,
+ height: 14,
+ flexShrink: 0,
+};
+
+const ErrorIcon: React.FC = () => {
+ return (
+ <svg style={iconStyle} viewBox="0 0 512 512">
+ <path
+ fill={FAIL_COLOR}
+ d="M0 160V352L160 512H352L512 352V160L352 0H160L0 160zm353.9 32l-17 17-47 47 47 47 17 17L320 353.9l-17-17-47-47-47 47-17 17L158.1 320l17-17 47-47-47-47-17-17L192 158.1l17 17 47 47 47-47 17-17L353.9 192z"
+ />
+ </svg>
+ );
+};
+
+export const LicenseKeyDetailsDisplay: React.FC<{
+ readonly details: LicenseKeyDetails;
+}> = ({details}) => {
+ const projectUrl = `${PRO_HOST}/projects/${details.projectSlug}`;
+ const usageUrl = `${projectUrl}/usage#client-renders-usage`;
+ const hasActiveLicense = hasActiveCompanyLicense(details);
+
+ return (
+ <div>
+ <InspectorInlineAction
+ disabled={false}
+ onClick={() => window.open(usageUrl, '_blank', 'noopener,noreferrer')}
+ renderIcon={(color) => (
+ <CheckCircleFilled style={{...iconStyle, fill: color}} />
+ )}
+ style={actionStyle}
+ title="View license usage"
+ >
+ <span style={actionContent}>
+ <span style={actionText}>Belongs to {details.projectName}</span>
+ <span style={actionLabel}>View usage</span>
+ </span>
+ </InspectorInlineAction>
+ <InspectorInlineAction
+ disabled={false}
+ onClick={() => window.open(projectUrl, '_blank', 'noopener,noreferrer')}
+ renderIcon={(color) =>
+ hasActiveLicense ? (
+ <CheckCircleFilled style={{...iconStyle, fill: color}} />
+ ) : (
+ <ErrorIcon />
+ )
+ }
+ style={actionStyle}
+ title="Manage Company License"
+ >
+ <span style={actionContent}>
+ <span style={hasActiveLicense ? actionText : inactiveLicenseText}>
+ {hasActiveLicense
+ ? 'Active Company License'
+ : 'No active Company License'}
+ </span>
+ <span style={actionLabel}>Manage</span>
+ </span>
+ </InspectorInlineAction>
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/Modals.tsx b/packages/studio/src/components/Modals.tsx
index 6129b35ffb..a5409302c0 100644
--- a/packages/studio/src/components/Modals.tsx
+++ b/packages/studio/src/components/Modals.tsx
@@ -3,6 +3,7 @@ import {StudioServerConnectionCtx} from '../helpers/client-id';
import {getStudioAskAIEnabled} from '../helpers/studio-runtime-config';
import {ModalsContext} from '../state/modals';
import {AskAiModal} from './AskAiModal';
+import {ConfigureLicenseModal} from './ConfigureLicenseModal';
import {ConfirmationDialog} from './ConfirmationDialog';
import {EffectPickerModal} from './EffectPickerModal';
import {InstallPackageModal} from './InstallPackage';
@@ -77,6 +78,11 @@ export const Modals: React.FC<{
{modalContextType && modalContextType.type === 'input-props-override' && (
<OverrideInputPropsModal />
)}
+ {modalContextType && modalContextType.type === 'configure-license' && (
+ <ConfigureLicenseModal
+ initialPublicLicenseKey={modalContextType.initialPublicLicenseKey}
+ />
+ )}
{modalContextType && modalContextType.type === 'web-render' && (
<WebRenderModalWithLoader {...modalContextType} />
)}
diff --git a/packages/studio/src/components/RenderButton.tsx b/packages/studio/src/components/RenderButton.tsx
index d84a2f2e83..e81ae5e52e 100644
--- a/packages/studio/src/components/RenderButton.tsx
+++ b/packages/studio/src/components/RenderButton.tsx
@@ -363,7 +363,6 @@ export const RenderButton: React.FC<{
inFrameMark: inFrame,
outFrameMark: outFrame,
initialLogLevel: defaults.logLevel as LogLevel,
- initialLicenseKey: defaults.publicLicenseKey,
initialStillImageFormat:
defaults.stillImageFormat as RenderStillOnWebImageFormat,
initialScale: defaults.scale,
diff --git a/packages/studio/src/components/RenderModal/WebRenderModal.tsx b/packages/studio/src/components/RenderModal/WebRenderModal.tsx
index 6f30b64c16..305216258d 100644
--- a/packages/studio/src/components/RenderModal/WebRenderModal.tsx
+++ b/packages/studio/src/components/RenderModal/WebRenderModal.tsx
@@ -60,14 +60,12 @@ import {useEncodableVideoCodecs} from './use-encodable-video-codecs';
import {WebRenderModalAdvanced} from './WebRenderModalAdvanced';
import {WebRenderModalAudio} from './WebRenderModalAudio';
import {WebRenderModalBasic} from './WebRenderModalBasic';
-import {WebRenderModalLicense} from './WebRenderModalLicense';
import {WebRenderModalPicture} from './WebRenderModalPicture';
type WebRenderModalProps = {
readonly compositionId: string;
readonly initialFrame: number;
readonly initialLogLevel: LogLevel;
- readonly initialLicenseKey: string | null;
readonly defaultProps: Record<string, unknown>;
readonly inFrameMark: number | null;
readonly outFrameMark: number | null;
@@ -90,13 +88,7 @@ type WebRenderModalProps = {
export type RenderType = 'still' | 'video' | 'audio';
-type TabType =
- | 'general'
- | 'data'
- | 'picture'
- | 'audio'
- | 'advanced'
- | 'license';
+type TabType = 'general' | 'data' | 'picture' | 'audio' | 'advanced';
const invalidCharacters = ['?', '*', '+', ':', '%'];
@@ -174,7 +166,6 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
inFrameMark,
outFrameMark,
initialLogLevel,
- initialLicenseKey,
initialStillImageFormat,
initialDefaultOutName,
initialScale,
@@ -201,6 +192,13 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
);
}
+ const renderDefaults = window.remotion_renderDefaults;
+ if (!renderDefaults) {
+ throw new Error('Render defaults are not available');
+ }
+
+ const {publicLicenseKey} = renderDefaults;
+
const {
resolved: {result: resolvedComposition},
unresolved: unresolvedComposition,
@@ -273,8 +271,6 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
const [muted, setMuted] = useState(initialMuted ?? false);
const [scale, setScale] = useState(initialScale ?? 1);
- const [licenseKey, setLicenseKey] = useState(initialLicenseKey);
-
const [pageResponsiveness, setPageResponsiveness] =
useState<WebRendererPageResponsiveness>(
initialPageResponsiveness ?? 'medium',
@@ -547,7 +543,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
delayRenderTimeout,
mediaCacheSizeInBytes,
logLevel,
- licenseKey,
+ licenseKey: publicLicenseKey,
scale,
},
compositionRef,
@@ -575,7 +571,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
delayRenderTimeout,
mediaCacheSizeInBytes,
logLevel,
- licenseKey,
+ licenseKey: publicLicenseKey,
scale,
pageResponsiveness,
},
@@ -605,7 +601,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
delayRenderTimeout,
mediaCacheSizeInBytes,
logLevel,
- licenseKey,
+ publicLicenseKey,
container,
effectiveVideoCodec,
effectiveAudioCodec,
@@ -698,8 +694,13 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
</VerticalTab>
<VerticalTab
style={horizontalTab}
- selected={tab === 'license'}
- onClick={() => setTab('license')}
+ selected={false}
+ onClick={() =>
+ setSelectedModal({
+ type: 'configure-license',
+ initialPublicLicenseKey: publicLicenseKey,
+ })
+ }
>
<div style={iconContainer}>
<CertificateIcon style={icon} />
@@ -785,13 +786,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
pageResponsiveness={pageResponsiveness}
setPageResponsiveness={setPageResponsiveness}
/>
- ) : (
- <WebRenderModalLicense
- licenseKey={licenseKey}
- setLicenseKey={setLicenseKey}
- initialPublicLicenseKey={initialLicenseKey}
- />
- )}
+ ) : null}
</div>
</div>
</div>
diff --git a/packages/studio/src/components/RenderModal/WebRenderModalLicense.tsx b/packages/studio/src/components/RenderModal/WebRenderModalLicense.tsx
deleted file mode 100644
index 4b44a9596a..0000000000
--- a/packages/studio/src/components/RenderModal/WebRenderModalLicense.tsx
+++ /dev/null
@@ -1,339 +0,0 @@
-import React, {useCallback, useEffect, useState} from 'react';
-import {
- BLUE,
- INPUT_BACKGROUND,
- BLACK_ALPHA_60,
- LIGHT_TEXT,
- WHITE,
-} from '../../helpers/colors';
-import {Checkbox} from '../Checkbox';
-import {Spacing} from '../layout';
-import {RemotionInput} from '../NewComposition/RemInput';
-import {ValidationMessage} from '../NewComposition/ValidationMessage';
-import type {LicenseKeyDetails} from './WebRenderModalLicenseKeyDetails';
-import {
- WebRenderModalLicenseKeyDetails,
- fetchLicenseKeyDetails,
-} from './WebRenderModalLicenseKeyDetails';
-
-type WebRenderModalLicenseProps = {
- readonly licenseKey: string | null;
- readonly setLicenseKey: React.Dispatch<React.SetStateAction<string | null>>;
- readonly initialPublicLicenseKey: string | null;
-};
-
-export const row: React.CSSProperties = {
- display: 'flex',
- flexDirection: 'row',
- paddingLeft: 16,
- paddingRight: 16,
-};
-
-const tabContainer: React.CSSProperties = {
- flex: 1,
-};
-
-const descriptionStyle: React.CSSProperties = {
- color: LIGHT_TEXT,
- fontSize: 14,
- fontFamily: 'sans-serif',
- paddingLeft: 16,
- paddingRight: 16,
- paddingTop: 16,
- paddingBottom: 8,
- lineHeight: 1.5,
-};
-
-const paddedDescriptionStyle: React.CSSProperties = {
- color: LIGHT_TEXT,
- fontSize: 14,
- fontFamily: 'sans-serif',
- padding: 9,
- border: '1px solid ' + BLACK_ALPHA_60,
- borderRadius: 8,
- lineHeight: 1.5,
- marginLeft: 16,
- marginRight: 16,
-};
-
-const descriptionLink: React.CSSProperties = {
- color: WHITE,
- fontSize: 14,
-};
-
-const checkboxLabel: React.CSSProperties = {
- fontSize: 14,
- lineHeight: '40px',
- color: LIGHT_TEXT,
- flex: 1,
- fontFamily: 'sans-serif',
- cursor: 'pointer',
- userSelect: 'none',
-};
-
-const inputStyle: React.CSSProperties = {
- minWidth: 250,
-};
-
-const justifyCenter: React.CSSProperties = {
- display: 'flex',
- alignItems: 'center',
- gap: 10,
- flex: 1,
-};
-
-const codeStyle: React.CSSProperties = {
- fontSize: 14,
- fontFamily: 'monospace',
- color: BLUE,
-};
-
-const codeLine: React.CSSProperties = {
- fontSize: 14,
- fontFamily: 'monospace',
- color: LIGHT_TEXT,
- backgroundColor: INPUT_BACKGROUND,
- padding: 6,
- borderRadius: 3,
- marginTop: 6,
- overflowX: 'auto',
- maxWidth: '100%',
-};
-
-const codeLineSmall: React.CSSProperties = {
- ...codeLine,
- fontSize: 11,
-};
-
-const LICENSE_KEY_LENGTH = 55;
-const LICENSE_KEY_PREFIX = 'rm_pub_';
-
-type LicenseKeyValidation = {
- valid: boolean;
- message: string | null;
- details: LicenseKeyDetails | null;
-};
-
-const validateLicenseKey = (key: string): LicenseKeyValidation => {
- if (key.length === 0) {
- return {valid: false, message: null, details: null};
- }
-
- if (!key.startsWith(LICENSE_KEY_PREFIX)) {
- return {
- valid: false,
- message: `License key must start with "${LICENSE_KEY_PREFIX}"`,
- details: null,
- };
- }
-
- const afterPrefix = key.slice(LICENSE_KEY_PREFIX.length);
- if (!/^[a-zA-Z0-9]*$/.test(afterPrefix)) {
- return {
- valid: false,
- message:
- 'License key must contain only alphanumeric characters after the prefix',
- details: null,
- };
- }
-
- if (key.length !== LICENSE_KEY_LENGTH) {
- return {
- valid: false,
- message: `License key must be ${LICENSE_KEY_LENGTH} characters long`,
- details: null,
- };
- }
-
- return {valid: true, message: null, details: null};
-};
-
-export const WebRenderModalLicense: React.FC<WebRenderModalLicenseProps> = ({
- licenseKey,
- setLicenseKey,
- initialPublicLicenseKey,
-}) => {
- const [licenseValidation, setLicenseValidation] =
- useState<LicenseKeyValidation>({valid: true, message: null, details: null});
- const [isLoading, setIsLoading] = useState(false);
-
- useEffect(() => {
- if (licenseKey === null || licenseKey === 'free-license') {
- return setLicenseValidation({
- valid: true,
- message: null,
- details: null,
- });
- }
-
- const validation = validateLicenseKey(licenseKey);
- if (!validation.valid) {
- return setLicenseValidation(validation);
- }
-
- setLicenseValidation({valid: true, message: null, details: null});
- setIsLoading(true);
- fetchLicenseKeyDetails(licenseKey)
- .then((details) => {
- setIsLoading(false);
- if (details.isValid) {
- setLicenseValidation({valid: true, message: null, details});
- } else {
- setLicenseValidation({
- valid: false,
- message: 'License key is invalid or has been reset',
- details: null,
- });
- }
- })
- .catch(() => {
- setIsLoading(false);
- setLicenseValidation({
- valid: false,
- message: 'Failed to fetch license key details',
- details: null,
- });
- });
- }, [licenseKey]);
-
- const onFreeLicenseChange = useCallback(() => {
- setLicenseKey('free-license');
- }, [setLicenseKey]);
-
- const onCompanyLicenseChange = useCallback(() => {
- setLicenseKey(initialPublicLicenseKey ?? '');
- }, [initialPublicLicenseKey, setLicenseKey]);
-
- const onLicenseKeyChange: React.ChangeEventHandler<HTMLInputElement> =
- useCallback(
- (e) => {
- setLicenseKey(e.target.value);
- },
- [setLicenseKey],
- );
-
- return (
- <div style={tabContainer}>
- <div style={descriptionStyle}>
- Remotion is free if you are an individual or company with a headcount of
- 3 or less. See{' '}
- <a style={descriptionLink} href="https://remotion.dev/license">
- LICENSE.md
- </a>
- .
- </div>
- <div style={row}>
- <div style={justifyCenter}>
- <Checkbox
- checked={licenseKey === 'free-license'}
- onChange={onFreeLicenseChange}
- name="free-license"
- rounded
- />
- <div style={checkboxLabel} onClick={onFreeLicenseChange}>
- I am eligible for the Free License, {"don't"} print a warning
- </div>
- </div>
- </div>
- {licenseKey === 'free-license' ? (
- <div style={paddedDescriptionStyle}>
- Enjoy Remotion! Add the following to{' '}
- <code style={codeStyle}>remotion.config.ts</code> to persist this
- setting:
- <div style={codeLine}>
- {"Config.setPublicLicenseKey('free-license');"}
- </div>
- </div>
- ) : null}
- <div style={row}>
- <div style={justifyCenter}>
- <Checkbox
- checked={licenseKey !== 'free-license' && licenseKey !== null}
- onChange={onCompanyLicenseChange}
- name="company-license"
- rounded
- />
-
- <div style={checkboxLabel} onClick={onCompanyLicenseChange}>
- I have a Company License
- </div>
- </div>
- </div>
- {licenseKey !== 'free-license' && licenseKey !== null ? (
- <div style={paddedDescriptionStyle}>
- Add your public license key from{' '}
- <a
- href="https://remotion.pro/dashboard"
- target="_blank"
- style={descriptionLink}
- >
- remotion.pro
- </a>{' '}
- below.
- <Spacing y={1} block />
- <RemotionInput
- value={licenseKey}
- onChange={onLicenseKeyChange}
- placeholder="remotion.pro public license key (starts with rm_pub_)"
- status={
- licenseValidation.valid || licenseKey.length === 0
- ? 'ok'
- : 'error'
- }
- rightAlign={false}
- style={inputStyle}
- autoFocus
- />
- {licenseValidation.message ? (
- <>
- <Spacing y={1} block />
- <ValidationMessage
- message={licenseValidation.message}
- align="flex-start"
- type="error"
- />
- </>
- ) : null}
- {licenseValidation.valid && licenseKey.length > 0 ? (
- <>
- <Spacing y={1} block />
- Add the following to{' '}
- <code style={codeStyle}>remotion.config.ts</code> to persist this
- setting:
- <div style={codeLineSmall}>
- {"Config.setPublicLicenseKey('" + licenseKey + "');"}
- </div>
- </>
- ) : null}
- {isLoading && (
- <>
- <Spacing y={1} block />
- Loading license key details...
- </>
- )}
- {licenseValidation.details && (
- <>
- <Spacing y={1} block />
- <WebRenderModalLicenseKeyDetails
- details={licenseValidation.details}
- />
- </>
- )}
- </div>
- ) : null}
- {licenseKey === null ? (
- <div style={descriptionStyle}>
- If you are not eligible for the free license, you need to obtain a{' '}
- <a
- style={descriptionLink}
- target="_blank"
- href="https://remotion.pro/license"
- >
- Company License
- </a>
- .
- </div>
- ) : null}
- </div>
- );
-};
diff --git a/packages/studio/src/components/RenderModal/WebRenderModalLicenseKeyDetails.tsx b/packages/studio/src/components/RenderModal/WebRenderModalLicenseKeyDetails.tsx
deleted file mode 100644
index a4387b2d4a..0000000000
--- a/packages/studio/src/components/RenderModal/WebRenderModalLicenseKeyDetails.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import React from 'react';
-import {LIGHT_TEXT, WARNING_COLOR} from '../../helpers/colors';
-import {CheckCircleFilled} from '../../icons/check-circle-filled';
-import {WarningTriangle} from '../NewComposition/ValidationMessage';
-
-const textStyle: React.CSSProperties = {
- color: LIGHT_TEXT,
- fontSize: 14,
- fontFamily: 'sans-serif',
- lineHeight: 1.5,
- display: 'flex',
- alignItems: 'center',
-};
-
-const linkStyle: React.CSSProperties = {
- fontSize: 14,
- fontFamily: 'sans-serif',
- lineHeight: 1.5,
- cursor: 'pointer',
-};
-
-const bulletStyle: React.CSSProperties = {
- display: 'flex',
- alignItems: 'center',
- gap: 6,
-};
-
-const icon: React.CSSProperties = {
- width: 14,
- height: 14,
- flexShrink: 0,
-};
-
-export type LicenseKeyDetails = {
- readonly isValid: boolean;
- readonly hasActiveSubscription: boolean;
- readonly projectName: string;
- readonly projectSlug: string;
-};
-
-type WebRenderModalLicenseKeyDetailsProps = {
- readonly details: LicenseKeyDetails;
-};
-
-const PRO_HOST = 'https://remotion.pro';
-
-export const fetchLicenseKeyDetails = async (
- licenseKey: string,
-): Promise<LicenseKeyDetails> => {
- const response = await fetch(`${PRO_HOST}/api/validate-license-key`, {
- method: 'POST',
- body: JSON.stringify({
- licenseKey,
- }),
- headers: {
- 'Content-Type': 'application/json',
- },
- });
- return response.json();
-};
-
-export const WebRenderModalLicenseKeyDetails: React.FC<
- WebRenderModalLicenseKeyDetailsProps
-> = ({details}) => {
- return (
- <div>
- <div style={bulletStyle}>
- <CheckCircleFilled style={{...icon, fill: LIGHT_TEXT}} />
- <div style={textStyle}>
- Belongs to&nbsp;
- <a
- href={`${PRO_HOST}/projects/${details.projectSlug}`}
- target="_blank"
- style={linkStyle}
- >
- {details.projectName}
- </a>
- &nbsp;-&nbsp;
- <a
- href={`${PRO_HOST}/projects/${details.projectSlug}/usage#client-renders-usage`}
- target="_blank"
- style={linkStyle}
- >
- View usage
- </a>
- </div>
- </div>
-
- {details.hasActiveSubscription ? (
- <div style={bulletStyle}>
- <CheckCircleFilled style={{...icon, fill: LIGHT_TEXT}} />
- <div style={textStyle}>Active Company License</div>
- </div>
- ) : (
- <div style={bulletStyle}>
- <WarningTriangle
- type="warning"
- style={{...icon, fill: WARNING_COLOR}}
- />
- <div style={textStyle}>No active Company License</div>
- </div>
- )}
- </div>
- );
-};
diff --git a/packages/studio/src/helpers/retry-payload.ts b/packages/studio/src/helpers/retry-payload.ts
index 08572e8680..33e205a06f 100644
--- a/packages/studio/src/helpers/retry-payload.ts
+++ b/packages/studio/src/helpers/retry-payload.ts
@@ -208,7 +208,6 @@ export const makeClientRetryPayload = (
compositionId: job.compositionId,
initialFrame: job.type === 'client-still' ? job.frame : 0,
initialLogLevel: job.logLevel,
- initialLicenseKey: job.licenseKey,
defaultProps: job.inputProps,
inFrameMark: job.type === 'client-video' ? job.startFrame : null,
outFrameMark: job.type === 'client-video' ? job.endFrame : null,
diff --git a/packages/studio/src/helpers/use-menu-structure.tsx b/packages/studio/src/helpers/use-menu-structure.tsx
index 60a609b21a..196846fac2 100644
--- a/packages/studio/src/helpers/use-menu-structure.tsx
+++ b/packages/studio/src/helpers/use-menu-structure.tsx
@@ -359,18 +359,21 @@ export const useMenuStructure = (
{
id: 'license',
value: 'license',
- label: 'License',
+ label: 'Configure License...',
onClick: () => {
closeMenu();
- openExternal(
- 'https://github.com/remotion-dev/remotion/blob/main/LICENSE.md',
- );
+ setSelectedModal({
+ type: 'configure-license',
+ initialPublicLicenseKey:
+ window.remotion_renderDefaults?.publicLicenseKey ?? null,
+ });
},
type: 'item' as const,
keyHint: null,
leftItem: null,
subMenu: null,
- quickSwitcherLabel: 'Help: License',
+ quickSwitcherLabel: 'Configure License...',
+ disabled: readOnlyStudio || type !== 'connected',
},
{
id: 'acknowledgements',
diff --git a/packages/studio/src/state/modals.ts b/packages/studio/src/state/modals.ts
index 14910e90b8..1298ce3092 100644
--- a/packages/studio/src/state/modals.ts
+++ b/packages/studio/src/state/modals.ts
@@ -50,7 +50,6 @@ export type WebRenderModalState = {
initialKeyframeIntervalInSeconds: number | null;
initialTransparent: boolean | null;
initialMuted: boolean | null;
- initialLicenseKey: string | null;
initialMediaCacheSizeInBytes: number | null;
initialPageResponsiveness: WebRendererPageResponsiveness;
};
@@ -179,6 +178,10 @@ export type ModalState =
| {
type: 'input-props-override';
}
+ | {
+ type: 'configure-license';
+ initialPublicLicenseKey: string | null;
+ }
| RenderModalState
| WebRenderModalState
| {
diff --git a/packages/studio/src/test/license-key-validation.test.ts b/packages/studio/src/test/license-key-validation.test.ts
new file mode 100644
index 0000000000..46a45540a2
--- /dev/null
+++ b/packages/studio/src/test/license-key-validation.test.ts
@@ -0,0 +1,51 @@
+import {expect, test} from 'bun:test';
+import {
+ hasActiveCompanyLicense,
+ type LicenseKeyDetails,
+ validateLicenseKey,
+} from '../components/LicenseKeyValidation';
+
+const validLicenseKey = `rm_pub_${'a'.repeat(48)}`;
+
+test('accepts a correctly formatted public license key', () => {
+ expect(validateLicenseKey(validLicenseKey)).toEqual({
+ valid: true,
+ message: null,
+ });
+});
+
+test('requires the public license key prefix', () => {
+ expect(validateLicenseKey('invalid')).toEqual({
+ valid: false,
+ message: 'License key must start with "rm_pub_"',
+ });
+});
+
+test('requires an alphanumeric public license key payload', () => {
+ expect(validateLicenseKey(`rm_pub_${'a'.repeat(47)}!`)).toEqual({
+ valid: false,
+ message:
+ 'License key must contain only alphanumeric characters after the prefix',
+ });
+});
+
+test('requires a 55-character public license key', () => {
+ expect(validateLicenseKey('rm_pub_short')).toEqual({
+ valid: false,
+ message: 'License key must be 55 characters long',
+ });
+});
+
+test('treats a null subscription as no active Company License', () => {
+ const details: LicenseKeyDetails = {
+ isValid: true,
+ hasActiveSubscription: null,
+ projectName: 'Test project',
+ projectSlug: 'test-project',
+ };
+
+ expect(hasActiveCompanyLicense(details)).toBe(false);
+ expect(
+ hasActiveCompanyLicense({...details, hasActiveSubscription: true}),
+ ).toBe(true);
+});