Skip to content

🎥 Make videos programmatically with React

no react internals

Jonny Burger398f70a26df0
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 7abb348e0c..9cf173fd56 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -31,7 +31,6 @@ import {
import type {RemotionEnvironment} from './get-remotion-environment.js';
import {getRemotionEnvironment} from './get-remotion-environment.js';
import type {SerializedJSONWithCustomFields} from './input-props-serialization.js';
-import {DATE_TOKEN, FILE_TOKEN} from './input-props-serialization.js';
import {IsPlayerContextProvider, useIsPlayer} from './is-player.js';
import {NativeLayersProvider} from './NativeLayers.js';
import {NonceContext} from './nonce.js';
@@ -143,8 +142,6 @@ export const Internals = {
RenderAssetManager,
persistCurrentFrame,
useTimelineSetFrame,
- FILE_TOKEN,
- DATE_TOKEN,
NativeLayersProvider,
ClipComposition,
isIosSafari,
diff --git a/packages/core/src/no-react.ts b/packages/core/src/no-react.ts
index 48ce38776c..6a81eed547 100644
--- a/packages/core/src/no-react.ts
+++ b/packages/core/src/no-react.ts
@@ -17,6 +17,7 @@ import {
deserializeJSONWithCustomFields,
serializeJSONWithDate,
} from './input-props-serialization';
+import {DATE_TOKEN, FILE_TOKEN} from './input-props-serialization.js';
import {colorNames, processColor} from './interpolate-colors';
import {truthy} from './truthy';
import {ENABLE_V5_BREAKING_CHANGES} from './v5-flag';
@@ -49,4 +50,6 @@ export const NoReactInternals = {
MIN_NODE_VERSION: ENABLE_V5_BREAKING_CHANGES ? 18 : 16,
MIN_BUN_VERSION: ENABLE_V5_BREAKING_CHANGES ? '1.1.3' : '1.0.3',
colorNames,
+ DATE_TOKEN,
+ FILE_TOKEN,
};
diff --git a/packages/lambda/src/shared/compress-props.ts b/packages/lambda/src/shared/compress-props.ts
index 9fc09fd3aa..5f3ea2c85f 100644
--- a/packages/lambda/src/shared/compress-props.ts
+++ b/packages/lambda/src/shared/compress-props.ts
@@ -1,10 +1,10 @@
+import {NoReactInternals} from 'remotion/no-react';
import {internalGetOrCreateBucket} from '../api/get-or-create-bucket';
import type {AwsRegion} from '../client';
import {lambdaReadFile, lambdaWriteFile} from '../functions/helpers/io';
import type {SerializedInputProps} from './constants';
import {inputPropsKey, resolvedPropsKey} from './constants';
import {randomHash} from './random-hash';
-import {serializeJSONWithDate} from './serialize-props';
import {streamToString} from './stream-to-string';
import {MAX_WEBHOOK_CUSTOM_DATA_SIZE} from './validate-webhook';
@@ -23,7 +23,7 @@ export const serializeOrThrow = (
propsType: PropsType,
) => {
try {
- const payload = serializeJSONWithDate({
+ const payload = NoReactInternals.serializeJSONWithDate({
indent: undefined,
staticBase: null,
data: inputProps,
diff --git a/packages/lambda/src/shared/serialize-props.ts b/packages/lambda/src/shared/serialize-props.ts
deleted file mode 100644
index f4e310d4b6..0000000000
--- a/packages/lambda/src/shared/serialize-props.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-// Must keep this file in sync with the one in packages/core/src/input-props-serialization.ts!
-
-type SerializedJSONWithCustomFields = {
- serializedString: string;
- customDateUsed: boolean;
- customFileUsed: boolean;
- mapUsed: boolean;
- setUsed: boolean;
-};
-
-const DATE_TOKEN = 'remotion-date:';
-export const FILE_TOKEN = 'remotion-file:';
-
-export const serializeJSONWithDate = ({
- data,
- indent,
- staticBase,
-}: {
- data: Record<string, unknown>;
- indent: number | undefined;
- staticBase: string | null;
-}): SerializedJSONWithCustomFields => {
- let customDateUsed = false;
- let customFileUsed = false;
- let mapUsed = false;
- let setUsed = false;
-
- const serializedString = JSON.stringify(
- data,
- function (key, value) {
- const item = (this as Record<string, unknown>)[key];
- if (item instanceof Date) {
- customDateUsed = true;
- return `${DATE_TOKEN}${item.toISOString()}`;
- }
-
- if (item instanceof Map) {
- mapUsed = true;
- return value;
- }
-
- if (item instanceof Set) {
- setUsed = true;
- return value;
- }
-
- if (
- typeof item === 'string' &&
- staticBase !== null &&
- item.startsWith(staticBase)
- ) {
- customFileUsed = true;
- return `${FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
- }
-
- return value;
- },
- indent,
- );
-
- return {serializedString, customDateUsed, customFileUsed, mapUsed, setUsed};
-};
diff --git a/packages/studio-shared/src/stringify-default-props.ts b/packages/studio-shared/src/stringify-default-props.ts
index 3c961081d6..2bbb14c02c 100644
--- a/packages/studio-shared/src/stringify-default-props.ts
+++ b/packages/studio-shared/src/stringify-default-props.ts
@@ -1,4 +1,4 @@
-import {Internals} from 'remotion';
+import {NoReactInternals} from 'remotion/no-react';
export type EnumPath = (string | number)[];
@@ -35,15 +35,21 @@ export const stringifyDefaultProps = ({
return `${item}__ADD_AS_CONST__`;
}
- if (typeof item === 'string' && item.startsWith(Internals.FILE_TOKEN)) {
+ if (
+ typeof item === 'string' &&
+ item.startsWith(NoReactInternals.FILE_TOKEN)
+ ) {
return `__REMOVEQUOTE____WRAP_IN_STATIC_FILE_START__${decodeURIComponent(
- item.replace(Internals.FILE_TOKEN, ''),
+ item.replace(NoReactInternals.FILE_TOKEN, ''),
)}__WRAP_IN_STATIC_FILE_END____REMOVEQUOTE__`;
}
- if (typeof item === 'string' && item.startsWith(Internals.DATE_TOKEN)) {
+ if (
+ typeof item === 'string' &&
+ item.startsWith(NoReactInternals.DATE_TOKEN)
+ ) {
return `__REMOVEQUOTE____WRAP_IN_DATE_START__${decodeURIComponent(
- item.replace(Internals.DATE_TOKEN, ''),
+ item.replace(NoReactInternals.DATE_TOKEN, ''),
)}__WRAP_IN_DATE_END____REMOVEQUOTE__`;
}