🎥 Make videos programmatically with React
warning about maps
Jonny Burger1106c96bb676
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsxindex ecd5f8a572..0c7c2901ff 100644--- a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx+++ b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx@@ -302,6 +302,7 @@ export const RenderModalData: React.FC<{customFileUsed: serializedJSON ? serializedJSON.customFileUsed : false,inJSONEditor,propsEditType,+ jsMapUsed: serializedJSON ? serializedJSON.mapUsed : false,});}, [canSaveDefaultProps,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.tsindex f350ef9dba..1ef4e1f71f 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@@ -2,6 +2,7 @@ export type SerializedJSONWithCustomFields = {serializedString: string;customDateUsed: boolean;customFileUsed: boolean;+ mapUsed: boolean;};const DATE_TOKEN = 'remotion-date:';@@ -18,6 +19,7 @@ export const serializeJSONWithDate = ({}): SerializedJSONWithCustomFields => {let customDateUsed = false;let customFileUsed = false;+ let mapUsed = false;const serializedString = JSON.stringify(data,@@ -28,6 +30,11 @@ export const serializeJSONWithDate = ({return `${DATE_TOKEN}${item.toISOString()}`;}+ if (item instanceof Map) {+ mapUsed = true;+ return value;+ }+if (typeof item === 'string' && item.startsWith(staticBase)) {customFileUsed = true;return `${FILE_TOKEN}${item.replace(staticBase + '/', '')}`;@@ -37,7 +44,7 @@ export const serializeJSONWithDate = ({},indent);- return {serializedString, customDateUsed, customFileUsed};+ return {serializedString, customDateUsed, customFileUsed, mapUsed};};export const deserializeJSONWithCustomFields = (data: string) => {diff --git a/packages/cli/src/editor/components/RenderModal/get-render-modal-warnings.ts b/packages/cli/src/editor/components/RenderModal/get-render-modal-warnings.tsindex 8e977f7458..d194c5faba 100644--- a/packages/cli/src/editor/components/RenderModal/get-render-modal-warnings.ts+++ b/packages/cli/src/editor/components/RenderModal/get-render-modal-warnings.ts@@ -56,11 +56,20 @@ const staticFileUsed = (used: boolean | undefined, inJSONEditor: boolean) => {return null;};+const mapUsed = (used: boolean | undefined, inJSONEditor: boolean) => {+ if (used && inJSONEditor) {+ return 'A `Map` was used in the schema which can not be serialized to JSON.';+ }++ return null;+};+export const getRenderModalWarnings = ({cliProps,canSaveDefaultProps,isCustomDateUsed,customFileUsed,+ jsMapUsed,inJSONEditor,propsEditType,}: {@@ -68,6 +77,7 @@ export const getRenderModalWarnings = ({canSaveDefaultProps: TypeCanSaveState;isCustomDateUsed: boolean;customFileUsed: boolean;+ jsMapUsed: boolean;inJSONEditor: boolean;propsEditType: PropsEditType;}) => {@@ -76,5 +86,6 @@ export const getRenderModalWarnings = ({getCannotSaveDefaultProps(canSaveDefaultProps),customDateUsed(isCustomDateUsed, inJSONEditor),staticFileUsed(customFileUsed, inJSONEditor),+ mapUsed(jsMapUsed, inJSONEditor),].filter(truthy);};diff --git a/packages/cli/src/test/date-serialization.test.ts b/packages/cli/src/test/json-serialization.test.tssimilarity index 56%rename from packages/cli/src/test/date-serialization.test.tsrename to packages/cli/src/test/json-serialization.test.tsindex dc28e33457..4b039d2a29 100644--- a/packages/cli/src/test/date-serialization.test.ts+++ b/packages/cli/src/test/json-serialization.test.ts@@ -7,12 +7,14 @@ import {test('date serialization', () => {const date = {data: new Date(), hi: 'there'};- const {serializedString, customDateUsed} = serializeJSONWithDate({- data: date,- indent: 2,- staticBase: '/static',- });+ const {serializedString, customDateUsed, customFileUsed} =+ serializeJSONWithDate({+ data: date,+ indent: 2,+ staticBase: '/static',+ });expect(customDateUsed).toEqual(true);+ expect(customFileUsed).toEqual(false);const deserialized = deserializeJSONWithCustomFields(serializedString);@@ -20,10 +22,21 @@ test('date serialization', () => {});test('No date used', () => {- const {customDateUsed} = serializeJSONWithDate({+ const {customDateUsed, customFileUsed, mapUsed} = serializeJSONWithDate({data: {a: 'hi'},indent: 2,staticBase: '/static',});expect(customDateUsed).toEqual(false);+ expect(customFileUsed).toEqual(false);+ expect(mapUsed).toEqual(false);+});++test('Map used', () => {+ const {mapUsed} = serializeJSONWithDate({+ data: {a: 'hi', map: new Map()},+ indent: 2,+ staticBase: '/static',+ });+ expect(mapUsed).toEqual(true);});