Skip to content

Commit 3333dc8

Browse files
authored
Merge pull request #6164 from remotion-dev/web-render-modal-license
2 parents 2f3f0e6 + 06f0e92 commit 3333dc8

File tree

18 files changed

+459
-9
lines changed

18 files changed

+459
-9
lines changed

packages/cli/src/config/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ const {
132132
enableCrossSiteIsolationOption,
133133
imageSequencePatternOption,
134134
darkModeOption,
135+
publicLicenseKeyOption,
135136
} = BrowserSafeApis.options;
136137

137138
declare global {
@@ -535,6 +536,12 @@ declare global {
535536
* @param pattern The pattern string, e.g. 'frame_[frame].[ext]'.
536537
*/
537538
readonly setImageSequencePattern: (pattern: string | null) => void;
539+
/**
540+
* Set the public license key for your company license.
541+
* Obtain it from the "Usage" tab on https://remotion.pro
542+
* Pass "free-license" if you are eligible for the free license.
543+
*/
544+
readonly setPublicLicenseKey: (key: string | null) => void;
538545
}
539546
}
540547

@@ -715,6 +722,7 @@ export const Config: FlatConfig = {
715722
setImageSequencePattern: imageSequencePatternOption.setConfig,
716723
setHardwareAcceleration: hardwareAccelerationOption.setConfig,
717724
setEnableCrossSiteIsolation: enableCrossSiteIsolationOption.setConfig,
725+
setPublicLicenseKey: publicLicenseKeyOption.setConfig,
718726
};
719727

720728
export const ConfigInternals = {

packages/cli/src/get-render-defaults.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const {
3131
chromeModeOption,
3232
mediaCacheSizeInBytesOption,
3333
darkModeOption,
34+
publicLicenseKeyOption,
3435
} = BrowserSafeApis.options;
3536

3637
export const getRenderDefaults = (): RenderDefaults => {
@@ -116,6 +117,9 @@ export const getRenderDefaults = (): RenderDefaults => {
116117
const mediaCacheSizeInBytes = mediaCacheSizeInBytesOption.getValue({
117118
commandLine: parsedCli,
118119
}).value;
120+
const publicLicenseKey = publicLicenseKeyOption.getValue({
121+
commandLine: parsedCli,
122+
}).value;
119123

120124
const everyNthFrame = ConfigInternals.getEveryNthFrame();
121125
const stillImageFormat = ConfigInternals.getUserPreferredStillImageFormat();
@@ -173,5 +177,6 @@ export const getRenderDefaults = (): RenderDefaults => {
173177
hardwareAcceleration,
174178
chromeMode,
175179
mediaCacheSizeInBytes,
180+
publicLicenseKey,
176181
};
177182
};

packages/cli/src/parse-command-line.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const {
3434
publicPathOption,
3535
audioLatencyHintOption,
3636
darkModeOption,
37+
publicLicenseKeyOption,
3738
} = BrowserSafeApis.options;
3839

3940
export type CommandLineOptions = {
@@ -115,6 +116,8 @@ export type CommandLineOptions = {
115116
>;
116117
repro: boolean;
117118
'image-sequence-pattern': string;
119+
'license-key': string;
120+
[publicLicenseKeyOption.cliFlag]: string;
118121
};
119122

120123
export const parseCommandLine = () => {
@@ -186,6 +189,17 @@ export const parseCommandLine = () => {
186189
);
187190
}
188191

192+
if (
193+
parsedCli['license-key'] &&
194+
parsedCli['license-key'].startsWith('rm_pub_')
195+
) {
196+
Config.setPublicLicenseKey(parsedCli['license-key']);
197+
}
198+
199+
if (parsedCli['public-license-key']) {
200+
Config.setPublicLicenseKey(parsedCli['public-license-key']);
201+
}
202+
189203
if (typeof parsedCli.quality !== 'undefined') {
190204
Log.warn(
191205
{indent: false, logLevel: 'info'},

packages/docs/docs/cli/studio.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,11 @@ npx remotion studio --ipv4
106106
```sh
107107
npx remotion studio --enable-cross-site-isolation
108108
```
109+
110+
### `--public-license-key`<AvailableFrom v="4.0.398" />
111+
112+
<Options id="public-license-key" />
113+
114+
```sh
115+
npx remotion studio --public-license-key="your-license-key"
116+
```

packages/docs/docs/config.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,20 @@ Using this feature is discouraged. Before using it, we want to make you aware of
871871
Before you use this hack, reach out to the Remotion team on [Discord](https://remotion.dev/discord) and ask us if we are open to implement the feature you need in a clean way - we often do implement new features quickly based on users feedback.
872872
:::
873873

874+
## `setPublicLicenseKey()`<AvailableFrom v="4.0.398" />
875+
876+
<Options id="public-license-key" />
877+
<br />
878+
<br />
879+
880+
```ts twoslash title="remotion.config.ts"
881+
import {Config} from '@remotion/cli/config';
882+
// ---cut---
883+
Config.setPublicLicenseKey('your-license-key');
884+
```
885+
886+
The [command line flag](/docs/cli/studio#--public-license-key) `--public-license-key` will take precedence over this option.
887+
874888
## ~~`setQuality()`~~
875889

876890
Renamed to `setJpegQuality` in `v4.0.0`.

packages/renderer/src/options/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import type {AnyRemotionOption} from './option';
3535
import {overwriteOption} from './overwrite';
3636
import {preferLosslessAudioOption} from './prefer-lossless';
3737
import {publicDirOption} from './public-dir';
38+
import {publicLicenseKeyOption} from './public-license-key';
3839
import {publicPathOption} from './public-path';
3940
import {reproOption} from './repro';
4041
import {scaleOption} from './scale';
@@ -95,6 +96,7 @@ export const allOptions = {
9596
imageSequencePatternOption,
9697
mediaCacheSizeInBytesOption,
9798
darkModeOption,
99+
publicLicenseKeyOption,
98100
};
99101

100102
export type AvailableOptions = keyof typeof allOptions;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type {AnyRemotionOption} from './option';
2+
3+
const cliFlag = 'public-license-key' as const;
4+
5+
let currentPublicLicenseKey: string | null = null;
6+
7+
export const publicLicenseKeyOption = {
8+
name: 'Public License Key',
9+
cliFlag,
10+
description: () => (
11+
<>
12+
The public license key for your company license, obtained from the "Usage"
13+
tab on <a href="https://remotion.pro/dashboard">remotion.pro</a>. If you
14+
are eligible for the free license, pass "free-license".
15+
</>
16+
),
17+
ssrName: 'publicLicenseKey' as const,
18+
docLink: 'https://www.remotion.dev/docs/licensing',
19+
getValue: ({commandLine}) => {
20+
if (commandLine[cliFlag] !== undefined) {
21+
return {
22+
source: 'cli',
23+
value: commandLine[cliFlag] as string | null,
24+
};
25+
}
26+
27+
if (currentPublicLicenseKey !== null) {
28+
return {
29+
source: 'config',
30+
value: currentPublicLicenseKey,
31+
};
32+
}
33+
34+
return {
35+
source: 'default',
36+
value: null,
37+
};
38+
},
39+
setConfig: (value: string | null) => {
40+
if (value && value !== 'free-license' && !value.startsWith('rm_pub_')) {
41+
throw new Error(
42+
'Invalid public license key. It must start with "rm_pub_" or be "free-license".',
43+
);
44+
}
45+
46+
currentPublicLicenseKey = value;
47+
},
48+
type: null as string | null,
49+
} satisfies AnyRemotionOption<string | null>;

packages/studio-shared/src/render-defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export type RenderDefaults = {
5555
metadata: Record<string, string> | null;
5656
hardwareAcceleration: HardwareAccelerationOption;
5757
chromeMode: ChromeMode;
58+
publicLicenseKey: string | null;
5859
};
5960

6061
declare global {

packages/studio/src/components/Checkbox.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, {useMemo} from 'react';
1+
import React, {useEffect, useMemo, useRef} from 'react';
22
import {
33
INPUT_BACKGROUND,
44
INPUT_BORDER_COLOR_UNHOVERED,
5+
LIGHT_TEXT,
56
} from '../helpers/colors';
67
import {Checkmark} from '../icons/Checkmark';
78

@@ -13,6 +14,13 @@ const background: React.CSSProperties = {
1314
position: 'relative',
1415
};
1516

17+
const bullet: React.CSSProperties = {
18+
width: 10,
19+
height: 10,
20+
backgroundColor: LIGHT_TEXT,
21+
borderRadius: '50%',
22+
};
23+
1624
const box: React.CSSProperties = {
1725
display: 'flex',
1826
justifyContent: 'center',
@@ -30,8 +38,10 @@ export const Checkbox: React.FC<{
3038
readonly checked: boolean;
3139
readonly onChange: React.ChangeEventHandler<HTMLInputElement>;
3240
readonly name: string;
41+
readonly rounded?: boolean;
3342
readonly disabled?: boolean;
34-
}> = ({checked, onChange, disabled, name}) => {
43+
}> = ({checked, onChange, disabled, name, rounded}) => {
44+
const ref = useRef<HTMLInputElement>(null);
3545
const input: React.CSSProperties = useMemo(() => {
3646
return {
3747
appearance: 'none',
@@ -46,17 +56,30 @@ export const Checkbox: React.FC<{
4656
};
4757
}, [disabled]);
4858

59+
useEffect(() => {
60+
if (ref.current) {
61+
ref.current.style.setProperty(
62+
'border-radius',
63+
rounded ? '50%' : '0%',
64+
'important',
65+
);
66+
}
67+
}, [rounded]);
68+
4969
return (
5070
<div style={background}>
5171
<input
72+
ref={ref}
5273
style={input}
5374
type={'checkbox'}
5475
checked={checked}
5576
onChange={onChange}
5677
disabled={disabled}
5778
name={name}
5879
/>
59-
<div style={box}>{checked ? <Checkmark /> : null}</div>
80+
<div style={box}>
81+
{checked ? rounded ? <div style={bullet} /> : <Checkmark /> : null}
82+
</div>
6083
</div>
6184
);
6285
};

packages/studio/src/components/Modals.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const Modals: React.FC<{
4848
inFrameMark={modalContextType.inFrameMark}
4949
outFrameMark={modalContextType.outFrameMark}
5050
initialLogLevel={modalContextType.initialLogLevel}
51+
initialLicenseKey={modalContextType.initialLicenseKey}
5152
/>
5253
)}
5354
{modalContextType &&

0 commit comments

Comments
 (0)