Skip to content

🎥 Make videos programmatically with React

fix bases

Jonny Burger73794aaa57e6
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx
index 380baa7a92..ecd5f8a572 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx
@@ -145,7 +145,11 @@ export const RenderModalData: React.FC<{
}
const value = inputProps ?? {};
- return serializeJSONWithDate(value, 2);
+ return serializeJSONWithDate({
+ data: value,
+ indent: 2,
+ staticBase: window.remotion_staticBase,
+ });
}, [inJSONEditor, inputProps]);
const cliProps = getInputProps();
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/input-props-serialization.ts b/packages/cli/src/editor/components/RenderModal/SchemaEditor/input-props-serialization.ts
index 38e415cca9..f350ef9dba 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/input-props-serialization.ts
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/input-props-serialization.ts
@@ -7,10 +7,15 @@ export type SerializedJSONWithCustomFields = {
const DATE_TOKEN = 'remotion-date:';
export const FILE_TOKEN = 'remotion-file:';
-export const serializeJSONWithDate = (
- data: unknown,
- indent: number | undefined
-): SerializedJSONWithCustomFields => {
+export const serializeJSONWithDate = ({
+ data,
+ indent,
+ staticBase,
+}: {
+ data: unknown;
+ indent: number | undefined;
+ staticBase: string;
+}): SerializedJSONWithCustomFields => {
let customDateUsed = false;
let customFileUsed = false;
@@ -23,15 +28,9 @@ export const serializeJSONWithDate = (
return `${DATE_TOKEN}${item.toISOString()}`;
}
- if (
- typeof item === 'string' &&
- item.startsWith(window.remotion_staticBase)
- ) {
+ if (typeof item === 'string' && item.startsWith(staticBase)) {
customFileUsed = true;
- return `${FILE_TOKEN}${item.replace(
- window.remotion_staticBase + '/',
- ''
- )}`;
+ return `${FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
}
return value;
diff --git a/packages/cli/src/editor/components/RenderQueue/actions.ts b/packages/cli/src/editor/components/RenderQueue/actions.ts
index 7b66f4741c..b56071f820 100644
--- a/packages/cli/src/editor/components/RenderQueue/actions.ts
+++ b/packages/cli/src/editor/components/RenderQueue/actions.ts
@@ -221,8 +221,11 @@ export const updateDefaultProps = (
) => {
return callApi('/api/update-default-props', {
compositionId,
- defaultProps: serializeJSONWithDate(defaultProps, undefined)
- .serializedString,
+ defaultProps: serializeJSONWithDate({
+ data: defaultProps,
+ indent: undefined,
+ staticBase: window.remotion_staticBase,
+ }).serializedString,
enumPaths,
});
};
diff --git a/packages/cli/src/test/date-serialization.test.ts b/packages/cli/src/test/date-serialization.test.ts
index c4be467568..dc28e33457 100644
--- a/packages/cli/src/test/date-serialization.test.ts
+++ b/packages/cli/src/test/date-serialization.test.ts
@@ -7,7 +7,11 @@ import {
test('date serialization', () => {
const date = {data: new Date(), hi: 'there'};
- const {serializedString, customDateUsed} = serializeJSONWithDate(date, 2);
+ const {serializedString, customDateUsed} = serializeJSONWithDate({
+ data: date,
+ indent: 2,
+ staticBase: '/static',
+ });
expect(customDateUsed).toEqual(true);
const deserialized = deserializeJSONWithCustomFields(serializedString);
@@ -16,6 +20,10 @@ test('date serialization', () => {
});
test('No date used', () => {
- const {customDateUsed} = serializeJSONWithDate({a: 'hi'}, 2);
+ const {customDateUsed} = serializeJSONWithDate({
+ data: {a: 'hi'},
+ indent: 2,
+ staticBase: '/static',
+ });
expect(customDateUsed).toEqual(false);
});
diff --git a/packages/cli/src/test/snapshots/root-after.tsx b/packages/cli/src/test/snapshots/root-after.tsx
index 02d8cc3932..4e47c416eb 100644
--- a/packages/cli/src/test/snapshots/root-after.tsx
+++ b/packages/cli/src/test/snapshots/root-after.tsx
@@ -32,7 +32,7 @@ export const Root: React.FC = () => {
width={1080}
id="Comp3"
defaultProps={{
- abc: 'def' as const,
+ abc: 'def',
newDate: new Date('2022-01-02T00:00:00.000Z'),
}}
/>