🎥 Make videos programmatically with React
awesome
Jonny Burger7fc59d875742
diff --git a/packages/cli/src/on-artifact.ts b/packages/cli/src/on-artifact.tsindex 7fa19e4c81..b8e7659426 100644--- a/packages/cli/src/on-artifact.ts+++ b/packages/cli/src/on-artifact.ts@@ -14,12 +14,18 @@ export const handleOnArtifact = (process.cwd(),artifact.filename.replace('/', path.sep),);- writeFileSync(artifact.filename, artifact.content);++ const stringOrUintArray =+ typeof artifact.content === 'string'+ ? artifact.content+ : new Uint8Array(Object.values(artifact.content));++ writeFileSync(artifact.filename, stringOrUintArray);initialProgress.received.push({absoluteOutputDestination,filename: artifact.filename,- sizeInBytes: artifact.content.length,+ sizeInBytes: stringOrUintArray.length,});};diff --git a/packages/core/src/Artifact.tsx b/packages/core/src/Artifact.tsxindex cca65033b3..28f9fe0446 100644--- a/packages/core/src/Artifact.tsx+++ b/packages/core/src/Artifact.tsx@@ -6,7 +6,7 @@ import {useCurrentFrame} from './use-current-frame';export const Artifact: React.FC<{readonly filename: string;- readonly content: string;+ readonly content: string | Uint8Array;}> = ({filename, content}) => {const {registerRenderAsset, unregisterRenderAsset} =useContext(RenderAssetManager);diff --git a/packages/core/src/CompositionManager.tsx b/packages/core/src/CompositionManager.tsxindex 7bed4510d9..728851aa19 100644--- a/packages/core/src/CompositionManager.tsx+++ b/packages/core/src/CompositionManager.tsx@@ -143,7 +143,7 @@ export type ArtifactAsset = {type: 'artifact';id: string;filename: string;- content: string;+ content: string | Uint8Array;frame: number;};diff --git a/packages/core/src/validation/validate-artifact.ts b/packages/core/src/validation/validate-artifact.tsindex 162e177b09..f3f4232b29 100644--- a/packages/core/src/validation/validate-artifact.ts+++ b/packages/core/src/validation/validate-artifact.ts@@ -19,13 +19,13 @@ export const validateArtifactFilename = (filename: unknown) => {};const validateContent = (content: unknown) => {- if (typeof content !== 'string') {+ if (typeof content !== 'string' && !(content instanceof Uint8Array)) {throw new TypeError(- `The "content" must be a string, but you passed a value of type ${typeof content}`,+ `The "content" must be a string or Uint8Array, but you passed a value of type ${typeof content}`,);}- if (content.trim() === '') {+ if (typeof content === 'string' && content.trim() === '') {throw new Error('The `content` must not be empty');}};diff --git a/packages/example/src/SubtitleArtifact/SubtitleArtifact.tsx b/packages/example/src/SubtitleArtifact/SubtitleArtifact.tsxindex 14ca160c16..fde60d1154 100644--- a/packages/example/src/SubtitleArtifact/SubtitleArtifact.tsx+++ b/packages/example/src/SubtitleArtifact/SubtitleArtifact.tsx@@ -5,6 +5,13 @@ export const SubtitleArtifact: React.FC = () => {const frame = useCurrentFrame();return frame === 0 ? (- <Artifact content="Hello World!" filename="hello.txt" />+ <Artifact+ content={+ new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])+ }+ filename="hello-uint8.txt"+ />+ ) : frame === 1 ? (+ <Artifact content="Hello World" filename="hello.txt" />) : null;};