🎥 Make videos programmatically with React
update templates
Jonny Burgerba618234f706
diff --git a/TESTING.md b/TESTING.mddeleted file mode 100644index 08e9a8a9d0..0000000000--- a/TESTING.md+++ /dev/null@@ -1,7 +0,0 @@-# Testing--For general information concerning contribution, please consult [CONTRIBUTION.md](./CONTRIBUTING.md).--### Running tests--There are tests in each package as well as end-to-end tests in the root of the monorepo. Run `pnpm test` in a package, or in the root to run all tests.diff --git a/packages/create-video/src/templates.tsx b/packages/create-video/src/templates.tsxindex 5c0cae1d7c..b5cab7c0f0 100644--- a/packages/create-video/src/templates.tsx+++ b/packages/create-video/src/templates.tsx@@ -401,8 +401,8 @@ export const FEATURED_TEMPLATES: Template[] = [defaultBranch: 'main',featuredOnHomePage: null,previewURL: null,- templateInMonorepo: null,- allowEnableTailwind: false,+ templateInMonorepo: 'template-stargazer',+ allowEnableTailwind: true,},{homePageLabel: 'TikTok',diff --git a/packages/template-code-hike/.prettierrc b/packages/template-code-hike/.prettierrcindex a8d69b60cb..8222cbaae8 100644--- a/packages/template-code-hike/.prettierrc+++ b/packages/template-code-hike/.prettierrc@@ -1,13 +1,5 @@{- "singleQuote": true,- "bracketSpacing": false,- "useTabs": true,- "overrides": [- {- "files": ["*.yml"],- "options": {- "singleQuote": false- }- }- ]+ "singleQuote": false,+ "bracketSpacing": true,+ "useTabs": false}diff --git a/packages/template-code-hike/src/CodeTransition.tsx b/packages/template-code-hike/src/CodeTransition.tsxindex 682c11fd4a..0a6a5b4e74 100644--- a/packages/template-code-hike/src/CodeTransition.tsx+++ b/packages/template-code-hike/src/CodeTransition.tsx@@ -1,96 +1,96 @@-import {Easing, interpolate} from 'remotion';-import {continueRender, delayRender, useCurrentFrame} from 'remotion';-import {Pre, HighlightedCode, AnnotationHandler} from 'codehike/code';-import React, {useEffect, useLayoutEffect, useMemo, useState} from 'react';+import { Easing, interpolate } from "remotion";+import { continueRender, delayRender, useCurrentFrame } from "remotion";+import { Pre, HighlightedCode, AnnotationHandler } from "codehike/code";+import React, { useEffect, useLayoutEffect, useMemo, useState } from "react";import {- calculateTransitions,- getStartingSnapshot,- TokenTransitionsSnapshot,-} from 'codehike/utils/token-transitions';-import {applyStyle} from './utils';-import {callout} from './annotations/Callout';+ calculateTransitions,+ getStartingSnapshot,+ TokenTransitionsSnapshot,+} from "codehike/utils/token-transitions";+import { applyStyle } from "./utils";+import { callout } from "./annotations/Callout";-import {tokenTransitions} from './annotations/InlineToken';-import {errorInline, errorMessage} from './annotations/Error';-import {fontFamily, fontSize, tabSize} from './font';+import { tokenTransitions } from "./annotations/InlineToken";+import { errorInline, errorMessage } from "./annotations/Error";+import { fontFamily, fontSize, tabSize } from "./font";export function CodeTransition({- oldCode,- newCode,- durationInFrames = 30,+ oldCode,+ newCode,+ durationInFrames = 30,}: {- oldCode: HighlightedCode | null;- newCode: HighlightedCode;- durationInFrames?: number;+ oldCode: HighlightedCode | null;+ newCode: HighlightedCode;+ durationInFrames?: number;}) {- const frame = useCurrentFrame();+ const frame = useCurrentFrame();- const ref = React.useRef<HTMLPreElement>(null);- const [oldSnapshot, setOldSnapshot] =- useState<TokenTransitionsSnapshot | null>(null);- const [handle] = React.useState(() => delayRender());+ const ref = React.useRef<HTMLPreElement>(null);+ const [oldSnapshot, setOldSnapshot] =+ useState<TokenTransitionsSnapshot | null>(null);+ const [handle] = React.useState(() => delayRender());- const prevCode: HighlightedCode = useMemo(() => {- return oldCode || {...newCode, tokens: [], annotations: []};- }, [newCode, oldCode]);+ const prevCode: HighlightedCode = useMemo(() => {+ return oldCode || { ...newCode, tokens: [], annotations: [] };+ }, [newCode, oldCode]);- const code = useMemo(() => {- return oldSnapshot ? newCode : prevCode;- }, [newCode, prevCode, oldSnapshot]);+ const code = useMemo(() => {+ return oldSnapshot ? newCode : prevCode;+ }, [newCode, prevCode, oldSnapshot]);- useEffect(() => {- if (!oldSnapshot) {- setOldSnapshot(getStartingSnapshot(ref.current!));- }- }, [oldSnapshot]);+ useEffect(() => {+ if (!oldSnapshot) {+ setOldSnapshot(getStartingSnapshot(ref.current!));+ }+ }, [oldSnapshot]);- // eslint-disable-next-line react-hooks/exhaustive-deps- useLayoutEffect(() => {- if (!oldSnapshot) {- setOldSnapshot(getStartingSnapshot(ref.current!));- return;- }- const transitions = calculateTransitions(ref.current!, oldSnapshot);- transitions.forEach(({element, keyframes, options}) => {- const delay = durationInFrames * options.delay;- const duration = durationInFrames * options.duration;- const linearProgress = interpolate(- frame,- [delay, delay + duration],- [0, 1],- {- extrapolateLeft: 'clamp',- extrapolateRight: 'clamp',- },- );- const progress = interpolate(linearProgress, [0, 1], [0, 1], {- easing: Easing.bezier(0.17, 0.67, 0.76, 0.91),- });+ // eslint-disable-next-line react-hooks/exhaustive-deps+ useLayoutEffect(() => {+ if (!oldSnapshot) {+ setOldSnapshot(getStartingSnapshot(ref.current!));+ return;+ }+ const transitions = calculateTransitions(ref.current!, oldSnapshot);+ transitions.forEach(({ element, keyframes, options }) => {+ const delay = durationInFrames * options.delay;+ const duration = durationInFrames * options.duration;+ const linearProgress = interpolate(+ frame,+ [delay, delay + duration],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ );+ const progress = interpolate(linearProgress, [0, 1], [0, 1], {+ easing: Easing.bezier(0.17, 0.67, 0.76, 0.91),+ });- applyStyle({- element,- keyframes,- progress,- linearProgress,- });- });- continueRender(handle);- });+ applyStyle({+ element,+ keyframes,+ progress,+ linearProgress,+ });+ });+ continueRender(handle);+ });- const handlers: AnnotationHandler[] = useMemo(() => {- return [tokenTransitions, callout, errorInline, errorMessage];- }, []);+ const handlers: AnnotationHandler[] = useMemo(() => {+ return [tokenTransitions, callout, errorInline, errorMessage];+ }, []);- const style: React.CSSProperties = useMemo(() => {- return {- position: 'relative',- fontSize,- lineHeight: 1.5,- fontFamily,- tabSize,- };- }, []);+ const style: React.CSSProperties = useMemo(() => {+ return {+ position: "relative",+ fontSize,+ lineHeight: 1.5,+ fontFamily,+ tabSize,+ };+ }, []);- return <Pre ref={ref} code={code} handlers={handlers} style={style} />;+ return <Pre ref={ref} code={code} handlers={handlers} style={style} />;}diff --git a/packages/template-code-hike/src/Main.tsx b/packages/template-code-hike/src/Main.tsxindex 5a7b3f6b61..978e8732eb 100644--- a/packages/template-code-hike/src/Main.tsx+++ b/packages/template-code-hike/src/Main.tsx@@ -1,74 +1,74 @@-import {AbsoluteFill, Series, useVideoConfig} from 'remotion';-import {ProgressBar} from './ProgressBar';-import {CodeTransition} from './CodeTransition';-import {HighlightedCode} from 'codehike/code';-import {ThemeColors, ThemeProvider} from './calculate-metadata/theme';-import {useMemo} from 'react';-import {RefreshOnCodeChange} from './ReloadOnCodeChange';-import {verticalPadding} from './font';+import { AbsoluteFill, Series, useVideoConfig } from "remotion";+import { ProgressBar } from "./ProgressBar";+import { CodeTransition } from "./CodeTransition";+import { HighlightedCode } from "codehike/code";+import { ThemeColors, ThemeProvider } from "./calculate-metadata/theme";+import { useMemo } from "react";+import { RefreshOnCodeChange } from "./ReloadOnCodeChange";+import { verticalPadding } from "./font";export type Props = {- steps: HighlightedCode[] | null;- themeColors: ThemeColors | null;- codeWidth: number | null;+ steps: HighlightedCode[] | null;+ themeColors: ThemeColors | null;+ codeWidth: number | null;};-export const Main: React.FC<Props> = ({steps, themeColors, codeWidth}) => {- if (!steps) {- throw new Error('Steps are not defined');- }+export const Main: React.FC<Props> = ({ steps, themeColors, codeWidth }) => {+ if (!steps) {+ throw new Error("Steps are not defined");+ }- const {durationInFrames} = useVideoConfig();- const stepDuration = durationInFrames / steps.length;- const transitionDuration = 30;+ const { durationInFrames } = useVideoConfig();+ const stepDuration = durationInFrames / steps.length;+ const transitionDuration = 30;- if (!themeColors) {- throw new Error('Theme colors are not defined');- }+ if (!themeColors) {+ throw new Error("Theme colors are not defined");+ }- const outerStyle: React.CSSProperties = useMemo(() => {- return {- backgroundColor: themeColors.background,- };- }, [themeColors]);+ const outerStyle: React.CSSProperties = useMemo(() => {+ return {+ backgroundColor: themeColors.background,+ };+ }, [themeColors]);- const style: React.CSSProperties = useMemo(() => {- return {- padding: `${verticalPadding}px 0px`,- };- }, []);+ const style: React.CSSProperties = useMemo(() => {+ return {+ padding: `${verticalPadding}px 0px`,+ };+ }, []);- return (- <ThemeProvider themeColors={themeColors}>- <AbsoluteFill style={outerStyle}>- <AbsoluteFill- style={{- width: codeWidth || '100%',- margin: 'auto',- }}- >- <ProgressBar steps={steps} />- <AbsoluteFill style={style}>- <Series>- {steps.map((step, index) => (- <Series.Sequence- key={index}- layout="none"- durationInFrames={stepDuration}- name={step.meta}- >- <CodeTransition- oldCode={steps[index - 1]}- newCode={step}- durationInFrames={transitionDuration}- />- </Series.Sequence>- ))}- </Series>- </AbsoluteFill>- </AbsoluteFill>- </AbsoluteFill>- <RefreshOnCodeChange />- </ThemeProvider>- );+ return (+ <ThemeProvider themeColors={themeColors}>+ <AbsoluteFill style={outerStyle}>+ <AbsoluteFill+ style={{+ width: codeWidth || "100%",+ margin: "auto",+ }}+ >+ <ProgressBar steps={steps} />+ <AbsoluteFill style={style}>+ <Series>+ {steps.map((step, index) => (+ <Series.Sequence+ key={index}+ layout="none"+ durationInFrames={stepDuration}+ name={step.meta}+ >+ <CodeTransition+ oldCode={steps[index - 1]}+ newCode={step}+ durationInFrames={transitionDuration}+ />+ </Series.Sequence>+ ))}+ </Series>+ </AbsoluteFill>+ </AbsoluteFill>+ </AbsoluteFill>+ <RefreshOnCodeChange />+ </ThemeProvider>+ );};diff --git a/packages/template-code-hike/src/ProgressBar.tsx b/packages/template-code-hike/src/ProgressBar.tsxindex 559d7f1161..6719ff058a 100644--- a/packages/template-code-hike/src/ProgressBar.tsx+++ b/packages/template-code-hike/src/ProgressBar.tsx@@ -1,77 +1,77 @@-import {useMemo} from 'react';-import {useCurrentFrame, useVideoConfig} from 'remotion';-import {useThemeColors} from './calculate-metadata/theme';-import React from 'react';+import { useMemo } from "react";+import { useCurrentFrame, useVideoConfig } from "remotion";+import { useThemeColors } from "./calculate-metadata/theme";+import React from "react";const Step: React.FC<{- index: number;- currentStep: number;- currentStepProgress: number;-}> = ({index, currentStep, currentStepProgress}) => {- const themeColors = useThemeColors();+ index: number;+ currentStep: number;+ currentStepProgress: number;+}> = ({ index, currentStep, currentStepProgress }) => {+ const themeColors = useThemeColors();- const outer: React.CSSProperties = useMemo(() => {- return {- backgroundColor:- themeColors.editor.lineHighlightBackground ??- themeColors.editor.rangeHighlightBackground,- borderRadius: 6,- overflow: 'hidden',- height: '100%',- flex: 1,- };- }, [themeColors]);+ const outer: React.CSSProperties = useMemo(() => {+ return {+ backgroundColor:+ themeColors.editor.lineHighlightBackground ??+ themeColors.editor.rangeHighlightBackground,+ borderRadius: 6,+ overflow: "hidden",+ height: "100%",+ flex: 1,+ };+ }, [themeColors]);- const inner: React.CSSProperties = useMemo(() => {- return {- height: '100%',- backgroundColor: themeColors.icon.foreground,- width:- index > currentStep- ? 0- : index === currentStep- ? currentStepProgress * 100 + '%'- : '100%',- };- }, [themeColors.icon.foreground, index, currentStep, currentStepProgress]);+ const inner: React.CSSProperties = useMemo(() => {+ return {+ height: "100%",+ backgroundColor: themeColors.icon.foreground,+ width:+ index > currentStep+ ? 0+ : index === currentStep+ ? currentStepProgress * 100 + "%"+ : "100%",+ };+ }, [themeColors.icon.foreground, index, currentStep, currentStepProgress]);- return (- <div style={outer}>- <div style={inner} />- </div>- );+ return (+ <div style={outer}>+ <div style={inner} />+ </div>+ );};-export function ProgressBar({steps}: {steps: unknown[]}) {- const frame = useCurrentFrame();- const {durationInFrames} = useVideoConfig();+export function ProgressBar({ steps }: { steps: unknown[] }) {+ const frame = useCurrentFrame();+ const { durationInFrames } = useVideoConfig();- const stepDuration = durationInFrames / steps.length;- const currentStep = Math.floor(frame / stepDuration);- const currentStepProgress = (frame % stepDuration) / stepDuration;+ const stepDuration = durationInFrames / steps.length;+ const currentStep = Math.floor(frame / stepDuration);+ const currentStepProgress = (frame % stepDuration) / stepDuration;- const container: React.CSSProperties = useMemo(() => {- return {- position: 'absolute',- top: 48,- height: 6,- left: 0,- right: 0,- display: 'flex',- gap: 12,- };- }, []);+ const container: React.CSSProperties = useMemo(() => {+ return {+ position: "absolute",+ top: 48,+ height: 6,+ left: 0,+ right: 0,+ display: "flex",+ gap: 12,+ };+ }, []);- return (- <div style={container}>- {steps.map((_, index) => (- <Step- key={index}- currentStep={currentStep}- currentStepProgress={currentStepProgress}- index={index}- />- ))}- </div>- );+ return (+ <div style={container}>+ {steps.map((_, index) => (+ <Step+ key={index}+ currentStep={currentStep}+ currentStepProgress={currentStepProgress}+ index={index}+ />+ ))}+ </div>+ );}diff --git a/packages/template-code-hike/src/ReloadOnCodeChange.tsx b/packages/template-code-hike/src/ReloadOnCodeChange.tsxindex e452015762..741effb9bb 100644--- a/packages/template-code-hike/src/ReloadOnCodeChange.tsx+++ b/packages/template-code-hike/src/ReloadOnCodeChange.tsx@@ -1,31 +1,31 @@-import {getStaticFiles, reevaluateComposition} from '@remotion/studio';-import {useState} from 'react';-import React, {useEffect} from 'react';-import {watchPublicFolder} from '@remotion/studio';+import { getStaticFiles, reevaluateComposition } from "@remotion/studio";+import { useState } from "react";+import React, { useEffect } from "react";+import { watchPublicFolder } from "@remotion/studio";const getCurrentHash = () => {- const files = getStaticFiles();- const codeFiles = files.filter((file) => file.name.startsWith('code'));- const contents = codeFiles.map((file) => file.src + file.lastModified);- return contents.join('');+ const files = getStaticFiles();+ const codeFiles = files.filter((file) => file.name.startsWith("code"));+ const contents = codeFiles.map((file) => file.src + file.lastModified);+ return contents.join("");};export const RefreshOnCodeChange: React.FC = () => {- const [files, setFiles] = useState(getCurrentHash());+ const [files, setFiles] = useState(getCurrentHash());- useEffect(() => {- const {cancel} = watchPublicFolder(() => {- const hash = getCurrentHash();- if (hash !== files) {- setFiles(hash);- reevaluateComposition();- }- });+ useEffect(() => {+ const { cancel } = watchPublicFolder(() => {+ const hash = getCurrentHash();+ if (hash !== files) {+ setFiles(hash);+ reevaluateComposition();+ }+ });- return () => {- cancel();- };- }, [files]);+ return () => {+ cancel();+ };+ }, [files]);- return null;+ return null;};diff --git a/packages/template-code-hike/src/Root.tsx b/packages/template-code-hike/src/Root.tsxindex 92b5a93b0e..dd812e2182 100644--- a/packages/template-code-hike/src/Root.tsx+++ b/packages/template-code-hike/src/Root.tsx@@ -1,27 +1,27 @@-import {Composition} from 'remotion';-import {Main} from './Main';+import { Composition } from "remotion";+import { Main } from "./Main";-import {calculateMetadata} from './calculate-metadata/calculate-metadata';-import {schema} from './calculate-metadata/schema';+import { calculateMetadata } from "./calculate-metadata/calculate-metadata";+import { schema } from "./calculate-metadata/schema";export const RemotionRoot = () => {- return (- <Composition- id="Main"- component={Main}- defaultProps={{- steps: null,- themeColors: null,- theme: 'github-dark' as const,- codeWidth: null,- width: {- type: 'auto',- },- }}- fps={30}- height={1080}- calculateMetadata={calculateMetadata}- schema={schema}- />- );+ return (+ <Composition+ id="Main"+ component={Main}+ defaultProps={{+ steps: null,+ themeColors: null,+ theme: "github-dark" as const,+ codeWidth: null,+ width: {+ type: "auto",+ },+ }}+ fps={30}+ height={1080}+ calculateMetadata={calculateMetadata}+ schema={schema}+ />+ );};diff --git a/packages/template-code-hike/src/annotations/Callout.tsx b/packages/template-code-hike/src/annotations/Callout.tsxindex a9bb8cedd3..a1c09c1842 100644--- a/packages/template-code-hike/src/annotations/Callout.tsx+++ b/packages/template-code-hike/src/annotations/Callout.tsx@@ -1,75 +1,78 @@import {- InlineAnnotation,- AnnotationHandler,- InnerLine,- Pre,-} from 'codehike/code';-import {interpolate, useCurrentFrame} from 'remotion';-import {useThemeColors} from '../calculate-metadata/theme';-import {mix, readableColor} from 'polished';+ InlineAnnotation,+ AnnotationHandler,+ InnerLine,+ Pre,+} from "codehike/code";+import { interpolate, useCurrentFrame } from "remotion";+import { useThemeColors } from "../calculate-metadata/theme";+import { mix, readableColor } from "polished";export const callout: AnnotationHandler = {- name: 'callout',- transform: (annotation: InlineAnnotation) => {- const {name, query, lineNumber, fromColumn, toColumn, data} = annotation;- return {- name,- query,- fromLineNumber: lineNumber,- toLineNumber: lineNumber,- data: {...data, column: (fromColumn + toColumn) / 2},- };- },- AnnotatedLine: ({annotation, ...props}) => {- const {column, codeblock} = annotation.data;- const {indentation} = props;- const frame = useCurrentFrame();+ name: "callout",+ transform: (annotation: InlineAnnotation) => {+ const { name, query, lineNumber, fromColumn, toColumn, data } = annotation;+ return {+ name,+ query,+ fromLineNumber: lineNumber,+ toLineNumber: lineNumber,+ data: { ...data, column: (fromColumn + toColumn) / 2 },+ };+ },+ AnnotatedLine: ({ annotation, ...props }) => {+ const { column, codeblock } = annotation.data;+ const { indentation } = props;+ const frame = useCurrentFrame();- const opacity = interpolate(frame, [25, 35], [0, 1], {- extrapolateLeft: 'clamp',- extrapolateRight: 'clamp',- });+ const opacity = interpolate(frame, [25, 35], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });- const themeColors = useThemeColors();+ const themeColors = useThemeColors();- const color = readableColor(themeColors.background);- const calloutColor = mix(0.08, color, themeColors.background);+ const color = readableColor(themeColors.background);+ const calloutColor = mix(0.08, color, themeColors.background);- return (- <>- <InnerLine merge={props} />- <div- style={{- opacity,- minWidth: `${column + 4}ch`,- marginLeft: `${indentation}ch`,- width: 'fit-content',- backgroundColor: calloutColor,- padding: '1rem 2rem',- position: 'relative',- marginTop: '0.25rem',- whiteSpace: 'pre-wrap',- color: themeColors.editor.foreground,- }}- >- <div- style={{- left: `${column - indentation - 1}ch`,- position: 'absolute',- width: '1rem',- height: '1rem',- transform: 'rotate(45deg) translateY(-50%)',- top: '-2px',- backgroundColor: calloutColor,- }}- />- {codeblock ? (- <Pre code={codeblock} style={{margin: 0, fontFamily: 'inherit'}} />- ) : (- annotation.data.children || annotation.query- )}- </div>- </>- );- },+ return (+ <>+ <InnerLine merge={props} />+ <div+ style={{+ opacity,+ minWidth: `${column + 4}ch`,+ marginLeft: `${indentation}ch`,+ width: "fit-content",+ backgroundColor: calloutColor,+ padding: "1rem 2rem",+ position: "relative",+ marginTop: "0.25rem",+ whiteSpace: "pre-wrap",+ color: themeColors.editor.foreground,+ }}+ >+ <div+ style={{+ left: `${column - indentation - 1}ch`,+ position: "absolute",+ width: "1rem",+ height: "1rem",+ transform: "rotate(45deg) translateY(-50%)",+ top: "-2px",+ backgroundColor: calloutColor,+ }}+ />+ {codeblock ? (+ <Pre+ code={codeblock}+ style={{ margin: 0, fontFamily: "inherit" }}+ />+ ) : (+ annotation.data.children || annotation.query+ )}+ </div>+ </>+ );+ },};diff --git a/packages/template-code-hike/src/annotations/Error.tsx b/packages/template-code-hike/src/annotations/Error.tsxindex 2163f99c37..8b1d6e94bc 100644--- a/packages/template-code-hike/src/annotations/Error.tsx+++ b/packages/template-code-hike/src/annotations/Error.tsx@@ -1,76 +1,76 @@-import {InlineAnnotation, AnnotationHandler, InnerToken} from 'codehike/code';-import {interpolate, useCurrentFrame} from 'remotion';-import {useThemeColors} from '../calculate-metadata/theme';-import {mix, readableColor} from 'polished';+import { InlineAnnotation, AnnotationHandler, InnerToken } from "codehike/code";+import { interpolate, useCurrentFrame } from "remotion";+import { useThemeColors } from "../calculate-metadata/theme";+import { mix, readableColor } from "polished";export const errorInline: AnnotationHandler = {- name: 'error',- transform: (annotation: InlineAnnotation) => {- const {query, lineNumber, data} = annotation;- return [- annotation,- {- name: 'error-message',- query,- fromLineNumber: lineNumber,- toLineNumber: lineNumber,- data,- },- ];- },- Inline: ({children}) => (- <span- style={{- // @ts-expect-error - React types- '--decoration': 'underline wavy red',- }}- >- {children}- </span>- ),- Token: (props) => {- return (- <InnerToken- merge={props}- style={{- textDecoration: 'var(--decoration)',- }}- />- );- },+ name: "error",+ transform: (annotation: InlineAnnotation) => {+ const { query, lineNumber, data } = annotation;+ return [+ annotation,+ {+ name: "error-message",+ query,+ fromLineNumber: lineNumber,+ toLineNumber: lineNumber,+ data,+ },+ ];+ },+ Inline: ({ children }) => (+ <span+ style={{+ // @ts-expect-error - React types+ "--decoration": "underline wavy red",+ }}+ >+ {children}+ </span>+ ),+ Token: (props) => {+ return (+ <InnerToken+ merge={props}+ style={{+ textDecoration: "var(--decoration)",+ }}+ />+ );+ },};export const errorMessage: AnnotationHandler = {- name: 'error-message',- Block: ({annotation, children}) => {- const frame = useCurrentFrame();- const opacity = interpolate(frame, [25, 35], [0, 1], {- extrapolateLeft: 'clamp',- extrapolateRight: 'clamp',- });- const themeColors = useThemeColors();+ name: "error-message",+ Block: ({ annotation, children }) => {+ const frame = useCurrentFrame();+ const opacity = interpolate(frame, [25, 35], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const themeColors = useThemeColors();- const color = readableColor(themeColors.background);- const calloutColor = mix(0.08, color, themeColors.background);+ const color = readableColor(themeColors.background);+ const calloutColor = mix(0.08, color, themeColors.background);- return (- <>- {children}- <div- style={{- opacity,- borderLeft: '4px solid red',- marginLeft: '-1rem',- backgroundColor: calloutColor,- padding: '1rem 2rem',- marginTop: '0.5rem',- whiteSpace: 'pre-wrap',- color: themeColors.editor.foreground,- }}- >- {annotation.data.children || annotation.query}- </div>- </>- );- },+ return (+ <>+ {children}+ <div+ style={{+ opacity,+ borderLeft: "4px solid red",+ marginLeft: "-1rem",+ backgroundColor: calloutColor,+ padding: "1rem 2rem",+ marginTop: "0.5rem",+ whiteSpace: "pre-wrap",+ color: themeColors.editor.foreground,+ }}+ >+ {annotation.data.children || annotation.query}+ </div>+ </>+ );+ },};diff --git a/packages/template-code-hike/src/annotations/InlineToken.tsx b/packages/template-code-hike/src/annotations/InlineToken.tsxindex a08150adf7..988458ce60 100644--- a/packages/template-code-hike/src/annotations/InlineToken.tsx+++ b/packages/template-code-hike/src/annotations/InlineToken.tsx@@ -1,8 +1,8 @@-import {AnnotationHandler, InnerToken} from 'codehike/code';+import { AnnotationHandler, InnerToken } from "codehike/code";export const tokenTransitions: AnnotationHandler = {- name: 'token-transitions',- Token: ({...props}) => (- <InnerToken merge={props} style={{display: 'inline-block'}} />- ),+ name: "token-transitions",+ Token: ({ ...props }) => (+ <InnerToken merge={props} style={{ display: "inline-block" }} />+ ),};diff --git a/packages/template-code-hike/src/calculate-metadata/calculate-metadata.tsx b/packages/template-code-hike/src/calculate-metadata/calculate-metadata.tsxindex a360b0afa4..5ba0cb74e0 100644--- a/packages/template-code-hike/src/calculate-metadata/calculate-metadata.tsx+++ b/packages/template-code-hike/src/calculate-metadata/calculate-metadata.tsx@@ -1,69 +1,69 @@-import {z} from 'zod';-import {CalculateMetadataFunction} from 'remotion';-import {getThemeColors} from '@code-hike/lighter';-import {Props} from '../Main';-import {schema} from './schema';-import {processSnippet} from './process-snippet';-import {getFiles} from './get-files';-import {measureText} from '@remotion/layout-utils';+import { z } from "zod";+import { CalculateMetadataFunction } from "remotion";+import { getThemeColors } from "@code-hike/lighter";+import { Props } from "../Main";+import { schema } from "./schema";+import { processSnippet } from "./process-snippet";+import { getFiles } from "./get-files";+import { measureText } from "@remotion/layout-utils";import {- fontFamily,- fontSize,- horizontalPadding,- tabSize,- waitUntilDone,-} from '../font';-import {HighlightedCode} from 'codehike/code';+ fontFamily,+ fontSize,+ horizontalPadding,+ tabSize,+ waitUntilDone,+} from "../font";+import { HighlightedCode } from "codehike/code";export const calculateMetadata: CalculateMetadataFunction<- Props & z.infer<typeof schema>-> = async ({props}) => {- const contents = await getFiles();+ Props & z.infer<typeof schema>+> = async ({ props }) => {+ const contents = await getFiles();- await waitUntilDone();- const widthPerCharacter = measureText({- text: 'A',- fontFamily,- fontSize,- validateFontIsLoaded: true,- }).width;+ await waitUntilDone();+ const widthPerCharacter = measureText({+ text: "A",+ fontFamily,+ fontSize,+ validateFontIsLoaded: true,+ }).width;- const maxCharacters = Math.max(- ...contents- .map(({value}) => value.split('\n'))- .flat()- .map((value) => value.replaceAll('\t', ' '.repeat(tabSize)).length)- .flat(),- );- const codeWidth = widthPerCharacter * maxCharacters;+ const maxCharacters = Math.max(+ ...contents+ .map(({ value }) => value.split("\n"))+ .flat()+ .map((value) => value.replaceAll("\t", " ".repeat(tabSize)).length)+ .flat(),+ );+ const codeWidth = widthPerCharacter * maxCharacters;- const defaultStepDuration = 90;+ const defaultStepDuration = 90;- const themeColors = await getThemeColors(props.theme);+ const themeColors = await getThemeColors(props.theme);- const twoSlashedCode: HighlightedCode[] = [];- for (const snippet of contents) {- twoSlashedCode.push(await processSnippet(snippet, props.theme));- }+ const twoSlashedCode: HighlightedCode[] = [];+ for (const snippet of contents) {+ twoSlashedCode.push(await processSnippet(snippet, props.theme));+ }- const naturalWidth = codeWidth + horizontalPadding * 2;- const divisibleByTwo = Math.ceil(naturalWidth / 2) * 2; // MP4 requires an even width+ const naturalWidth = codeWidth + horizontalPadding * 2;+ const divisibleByTwo = Math.ceil(naturalWidth / 2) * 2; // MP4 requires an even width- const minimumWidth = props.width.type === 'fixed' ? 0 : 1080;- const minimumWidthApplied = Math.max(minimumWidth, divisibleByTwo);+ const minimumWidth = props.width.type === "fixed" ? 0 : 1080;+ const minimumWidthApplied = Math.max(minimumWidth, divisibleByTwo);- return {- durationInFrames: contents.length * defaultStepDuration,- width:- props.width.type === 'fixed'- ? Math.max(minimumWidthApplied, props.width.value)- : minimumWidthApplied,- props: {- theme: props.theme,- width: props.width,- steps: twoSlashedCode,- themeColors,- codeWidth,- },- };+ return {+ durationInFrames: contents.length * defaultStepDuration,+ width:+ props.width.type === "fixed"+ ? Math.max(minimumWidthApplied, props.width.value)+ : minimumWidthApplied,+ props: {+ theme: props.theme,+ width: props.width,+ steps: twoSlashedCode,+ themeColors,+ codeWidth,+ },+ };};diff --git a/packages/template-code-hike/src/calculate-metadata/get-files.ts b/packages/template-code-hike/src/calculate-metadata/get-files.tsindex ba26d332ee..f028ae93cb 100644--- a/packages/template-code-hike/src/calculate-metadata/get-files.ts+++ b/packages/template-code-hike/src/calculate-metadata/get-files.ts@@ -1,20 +1,20 @@-import {getStaticFiles} from '@remotion/studio';+import { getStaticFiles } from "@remotion/studio";export type PublicFolderFile = {- filename: string;- value: string;+ filename: string;+ value: string;};export const getFiles = async () => {- const files = getStaticFiles();- const codeFiles = files.filter((file) => file.name.startsWith('code'));+ const files = getStaticFiles();+ const codeFiles = files.filter((file) => file.name.startsWith("code"));- const contents = codeFiles.map(async (file): Promise<PublicFolderFile> => {- const contents = await fetch(file.src);- const text = await contents.text();+ const contents = codeFiles.map(async (file): Promise<PublicFolderFile> => {+ const contents = await fetch(file.src);+ const text = await contents.text();- return {filename: file.name, value: text};- });+ return { filename: file.name, value: text };+ });- return Promise.all(contents);+ return Promise.all(contents);};diff --git a/packages/template-code-hike/src/calculate-metadata/process-snippet.ts b/packages/template-code-hike/src/calculate-metadata/process-snippet.tsindex 7bd80c4d59..4f9fe01be2 100644--- a/packages/template-code-hike/src/calculate-metadata/process-snippet.ts+++ b/packages/template-code-hike/src/calculate-metadata/process-snippet.ts@@ -1,72 +1,72 @@-import {highlight} from 'codehike/code';-import {createTwoslashFromCDN} from 'twoslash-cdn';-import {PublicFolderFile} from './get-files';-import {Theme} from './theme';-import {CompilerOptions, JsxEmit, ScriptTarget} from 'typescript';+import { highlight } from "codehike/code";+import { createTwoslashFromCDN } from "twoslash-cdn";+import { PublicFolderFile } from "./get-files";+import { Theme } from "./theme";+import { CompilerOptions, JsxEmit, ScriptTarget } from "typescript";const compilerOptions: CompilerOptions = {- lib: ['dom', 'es2023'],- jsx: JsxEmit.ReactJSX,- target: ScriptTarget.ES2023,+ lib: ["dom", "es2023"],+ jsx: JsxEmit.ReactJSX,+ target: ScriptTarget.ES2023,};const twoslash = createTwoslashFromCDN({- compilerOptions,+ compilerOptions,});export const processSnippet = async (step: PublicFolderFile, theme: Theme) => {- const splitted = step.filename.split('.');- const extension = splitted[splitted.length - 1];+ const splitted = step.filename.split(".");+ const extension = splitted[splitted.length - 1];- const twoslashResult =- extension === 'ts' || extension === 'tsx'- ? await twoslash.run(step.value, extension, {- compilerOptions,- })- : null;+ const twoslashResult =+ extension === "ts" || extension === "tsx"+ ? await twoslash.run(step.value, extension, {+ compilerOptions,+ })+ : null;- const highlighted = await highlight(- {- lang: extension,- meta: '',- value: twoslashResult ? twoslashResult.code : step.value,- },- theme,- );+ const highlighted = await highlight(+ {+ lang: extension,+ meta: "",+ value: twoslashResult ? twoslashResult.code : step.value,+ },+ theme,+ );- if (!twoslashResult) {- return highlighted;- }+ if (!twoslashResult) {+ return highlighted;+ }- // If it is TypeScript code, let's also generate callouts (^?) and errors- for (const {text, line, character, length} of twoslashResult.queries) {- const codeblock = await highlight(- {value: text, lang: 'ts', meta: 'callout'},- theme,- );- highlighted.annotations.push({- name: 'callout',- query: text,- lineNumber: line + 1,- data: {- character,- codeblock,- },- fromColumn: character,- toColumn: character + length,- });- }+ // If it is TypeScript code, let's also generate callouts (^?) and errors+ for (const { text, line, character, length } of twoslashResult.queries) {+ const codeblock = await highlight(+ { value: text, lang: "ts", meta: "callout" },+ theme,+ );+ highlighted.annotations.push({+ name: "callout",+ query: text,+ lineNumber: line + 1,+ data: {+ character,+ codeblock,+ },+ fromColumn: character,+ toColumn: character + length,+ });+ }- for (const {text, line, character, length} of twoslashResult.errors) {- highlighted.annotations.push({- name: 'error',- query: text,- lineNumber: line + 1,- data: {character},- fromColumn: character,- toColumn: character + length,- });- }+ for (const { text, line, character, length } of twoslashResult.errors) {+ highlighted.annotations.push({+ name: "error",+ query: text,+ lineNumber: line + 1,+ data: { character },+ fromColumn: character,+ toColumn: character + length,+ });+ }- return highlighted;+ return highlighted;};diff --git a/packages/template-code-hike/src/calculate-metadata/schema.ts b/packages/template-code-hike/src/calculate-metadata/schema.tsindex 60bc473fc7..99b2d8231f 100644--- a/packages/template-code-hike/src/calculate-metadata/schema.ts+++ b/packages/template-code-hike/src/calculate-metadata/schema.ts@@ -1,17 +1,17 @@-import {z} from 'zod';-import {themeSchema} from './theme';+import { z } from "zod";+import { themeSchema } from "./theme";-export const width = z.discriminatedUnion('type', [- z.object({- type: z.literal('auto'),- }),- z.object({- type: z.literal('fixed'),- value: z.number().step(1),- }),+export const width = z.discriminatedUnion("type", [+ z.object({+ type: z.literal("auto"),+ }),+ z.object({+ type: z.literal("fixed"),+ value: z.number().step(1),+ }),]);export const schema = z.object({- theme: themeSchema,- width,+ theme: themeSchema,+ width,});diff --git a/packages/template-code-hike/src/calculate-metadata/theme.tsx b/packages/template-code-hike/src/calculate-metadata/theme.tsxindex b40c0880c5..043b55a290 100644--- a/packages/template-code-hike/src/calculate-metadata/theme.tsx+++ b/packages/template-code-hike/src/calculate-metadata/theme.tsx@@ -1,32 +1,32 @@-import {z} from 'zod';-import {getThemeColors} from '@code-hike/lighter';-import React from 'react';+import { z } from "zod";+import { getThemeColors } from "@code-hike/lighter";+import React from "react";export type ThemeColors = Awaited<ReturnType<typeof getThemeColors>>;export const themeSchema = z.enum([- 'dark-plus',- 'dracula-soft',- 'dracula',- 'github-dark',- 'github-dark-dimmed',- 'github-light',- 'light-plus',- 'material-darker',- 'material-default',- 'material-lighter',- 'material-ocean',- 'material-palenight',- 'min-dark',- 'min-light',- 'monokai',- 'nord',- 'one-dark-pro',- 'poimandres',- 'slack-dark',- 'slack-ochin',- 'solarized-dark',- 'solarized-light',+ "dark-plus",+ "dracula-soft",+ "dracula",+ "github-dark",+ "github-dark-dimmed",+ "github-light",+ "light-plus",+ "material-darker",+ "material-default",+ "material-lighter",+ "material-ocean",+ "material-palenight",+ "min-dark",+ "min-light",+ "monokai",+ "nord",+ "one-dark-pro",+ "poimandres",+ "slack-dark",+ "slack-ochin",+ "solarized-dark",+ "solarized-light",]);export type Theme = z.infer<typeof themeSchema>;@@ -34,24 +34,24 @@ export type Theme = z.infer<typeof themeSchema>;export const ThemeColorsContext = React.createContext<ThemeColors | null>(null);export const useThemeColors = () => {- const themeColors = React.useContext(ThemeColorsContext);- if (!themeColors) {- throw new Error('ThemeColorsContext not found');- }+ const themeColors = React.useContext(ThemeColorsContext);+ if (!themeColors) {+ throw new Error("ThemeColorsContext not found");+ }- return themeColors;+ return themeColors;};export const ThemeProvider = ({- children,- themeColors,+ children,+ themeColors,}: {- children: React.ReactNode;- themeColors: ThemeColors;+ children: React.ReactNode;+ themeColors: ThemeColors;}) => {- return (- <ThemeColorsContext.Provider value={themeColors}>- {children}- </ThemeColorsContext.Provider>- );+ return (+ <ThemeColorsContext.Provider value={themeColors}>+ {children}+ </ThemeColorsContext.Provider>+ );};diff --git a/packages/template-code-hike/src/font.ts b/packages/template-code-hike/src/font.tsindex d8718357cf..10d7e4ea9e 100644--- a/packages/template-code-hike/src/font.ts+++ b/packages/template-code-hike/src/font.ts@@ -1,6 +1,6 @@-import {loadFont} from '@remotion/google-fonts/RobotoMono';+import { loadFont } from "@remotion/google-fonts/RobotoMono";-export const {fontFamily, waitUntilDone} = loadFont();+export const { fontFamily, waitUntilDone } = loadFont();export const fontSize = 40;export const tabSize = 3;export const horizontalPadding = 60;diff --git a/packages/template-code-hike/src/index.ts b/packages/template-code-hike/src/index.tsindex d831f7b0f1..f31c790edb 100644--- a/packages/template-code-hike/src/index.ts+++ b/packages/template-code-hike/src/index.ts@@ -1,4 +1,4 @@-import {registerRoot} from 'remotion';-import {RemotionRoot} from './Root';+import { registerRoot } from "remotion";+import { RemotionRoot } from "./Root";registerRoot(RemotionRoot);diff --git a/packages/template-code-hike/src/utils.ts b/packages/template-code-hike/src/utils.tsindex 53583a930f..2d6fdfd8e1 100644--- a/packages/template-code-hike/src/utils.ts+++ b/packages/template-code-hike/src/utils.ts@@ -1,26 +1,26 @@-import {TokenTransition} from 'codehike/utils/token-transitions';-import {interpolate, interpolateColors} from 'remotion';+import { TokenTransition } from "codehike/utils/token-transitions";+import { interpolate, interpolateColors } from "remotion";export function applyStyle({- element,- keyframes,- progress,- linearProgress,+ element,+ keyframes,+ progress,+ linearProgress,}: {- element: HTMLElement;- keyframes: TokenTransition['keyframes'];- progress: number;- linearProgress: number;+ element: HTMLElement;+ keyframes: TokenTransition["keyframes"];+ progress: number;+ linearProgress: number;}) {- const {translateX, translateY, color, opacity} = keyframes;+ const { translateX, translateY, color, opacity } = keyframes;- if (opacity) {- element.style.opacity = linearProgress.toString();- }- if (color) {- element.style.color = interpolateColors(progress, [0, 1], color);- }- const x = translateX ? interpolate(progress, [0, 1], translateX) : 0;- const y = translateY ? interpolate(progress, [0, 1], translateY) : 0;- element.style.translate = `${x}px ${y}px`;+ if (opacity) {+ element.style.opacity = linearProgress.toString();+ }+ if (color) {+ element.style.color = interpolateColors(progress, [0, 1], color);+ }+ const x = translateX ? interpolate(progress, [0, 1], translateX) : 0;+ const y = translateY ? interpolate(progress, [0, 1], translateY) : 0;+ element.style.translate = `${x}px ${y}px`;}diff --git a/packages/template-skia/.prettierrc b/packages/template-skia/.prettierrcindex 542f4a0d74..dfc8cb62bd 100644--- a/packages/template-skia/.prettierrc+++ b/packages/template-skia/.prettierrc@@ -1,5 +1,5 @@{- "singleQuote": true,- "bracketSpacing": false,- "useTabs": true+ "useTabs": false,+ "bracketSpacing": true,+ "tabWidth": 2}diff --git a/packages/template-skia/src/AssetManager.tsx b/packages/template-skia/src/AssetManager.tsxindex 5b84a439fc..14bfeeac54 100644--- a/packages/template-skia/src/AssetManager.tsx+++ b/packages/template-skia/src/AssetManager.tsx@@ -1,7 +1,7 @@-import type {SkData, SkImage, SkTypeface} from '@shopify/react-native-skia';-import {Skia} from '@shopify/react-native-skia';-import type {ReactNode} from 'react';-import {useContext, createContext, useState, useEffect} from 'react';+import type { SkData, SkImage, SkTypeface } from "@shopify/react-native-skia";+import { Skia } from "@shopify/react-native-skia";+import type { ReactNode } from "react";+import { useContext, createContext, useState, useEffect } from "react";type ImagesToLoad = Record<string, ReturnType<typeof require>>;type TypefacesToLoad = Record<string, ReturnType<typeof require>>;@@ -9,91 +9,91 @@ type Images = Record<string, SkImage>;type TypeFaces = Record<string, SkTypeface>;interface TAssetManagerContext {- images: Images;- typefaces: TypeFaces;+ images: Images;+ typefaces: TypeFaces;}const AssetManagerContext = createContext<TAssetManagerContext | null>(null);interface RemotionCanvasProps {- images: ImagesToLoad;- typefaces: TypefacesToLoad;- children: ReactNode;+ images: ImagesToLoad;+ typefaces: TypefacesToLoad;+ children: ReactNode;}const useAssetManager = () => {- const assetManager = useContext(AssetManagerContext);- if (!assetManager) {- throw new Error('Could not find the asset manager');- }- return assetManager;+ const assetManager = useContext(AssetManagerContext);+ if (!assetManager) {+ throw new Error("Could not find the asset manager");+ }+ return assetManager;};export const useTypefaces = () => {- const assetManager = useAssetManager();- return assetManager.typefaces;+ const assetManager = useAssetManager();+ return assetManager.typefaces;};export const useImages = () => {- const assetManager = useAssetManager();- return assetManager.images;+ const assetManager = useAssetManager();+ return assetManager.images;};const resolveAsset = async <T,>(- type: 'image' | 'typeface',- name: string,- asset: ReturnType<typeof require>,- factory: (data: SkData) => T,+ type: "image" | "typeface",+ name: string,+ asset: ReturnType<typeof require>,+ factory: (data: SkData) => T,) => {- const data = await Skia.Data.fromURI(asset);- return {- type,- name,- data: factory(data),- };+ const data = await Skia.Data.fromURI(asset);+ return {+ type,+ name,+ data: factory(data),+ };};export const AssetManager = ({- children,- images: imagesToLoad,- typefaces: typefacesToLoad,+ children,+ images: imagesToLoad,+ typefaces: typefacesToLoad,}: RemotionCanvasProps) => {- const [assetMgr, setAssetMgr] = useState<TAssetManagerContext | null>(null);- useEffect(() => {- (async () => {- const assets = await Promise.all([- ...Object.keys(imagesToLoad).map((name) =>- resolveAsset('image', name, imagesToLoad[name], (data: SkData) =>- Skia.Image.MakeImageFromEncoded(data),- ),- ),- ...Object.keys(typefacesToLoad).map((name) =>- resolveAsset(- 'typeface',- name,- typefacesToLoad[name],- (data: SkData) => Skia.Typeface.MakeFreeTypeFaceFromData(data),- ),- ),- ]);- const images: Images = {};- const typefaces: TypeFaces = {};- assets.forEach((asset) => {- if (asset.type === 'image') {- images[asset.name] = asset.data as SkImage;- } else {- typefaces[asset.name] = asset.data as SkTypeface;- }- });- setAssetMgr({images, typefaces});- })();- }, [imagesToLoad, typefacesToLoad]);- if (assetMgr === null) {- return null;- }- return (- <AssetManagerContext.Provider value={assetMgr}>- {children}- </AssetManagerContext.Provider>- );+ const [assetMgr, setAssetMgr] = useState<TAssetManagerContext | null>(null);+ useEffect(() => {+ (async () => {+ const assets = await Promise.all([+ ...Object.keys(imagesToLoad).map((name) =>+ resolveAsset("image", name, imagesToLoad[name], (data: SkData) =>+ Skia.Image.MakeImageFromEncoded(data),+ ),+ ),+ ...Object.keys(typefacesToLoad).map((name) =>+ resolveAsset(+ "typeface",+ name,+ typefacesToLoad[name],+ (data: SkData) => Skia.Typeface.MakeFreeTypeFaceFromData(data),+ ),+ ),+ ]);+ const images: Images = {};+ const typefaces: TypeFaces = {};+ assets.forEach((asset) => {+ if (asset.type === "image") {+ images[asset.name] = asset.data as SkImage;+ } else {+ typefaces[asset.name] = asset.data as SkTypeface;+ }+ });+ setAssetMgr({ images, typefaces });+ })();+ }, [imagesToLoad, typefacesToLoad]);+ if (assetMgr === null) {+ return null;+ }+ return (+ <AssetManagerContext.Provider value={assetMgr}>+ {children}+ </AssetManagerContext.Provider>+ );};diff --git a/packages/template-skia/src/Drawing.tsx b/packages/template-skia/src/Drawing.tsxindex 3f6c68f027..aad014ed8b 100644--- a/packages/template-skia/src/Drawing.tsx+++ b/packages/template-skia/src/Drawing.tsx@@ -1,26 +1,26 @@-import {Skia, Text} from '@shopify/react-native-skia';-import React from 'react';-import {useVideoConfig} from 'remotion';-import {useTypefaces} from './AssetManager';-import {SkiaNeon} from './SkiaNeon';+import { Skia, Text } from "@shopify/react-native-skia";+import React from "react";+import { useVideoConfig } from "remotion";+import { useTypefaces } from "./AssetManager";+import { SkiaNeon } from "./SkiaNeon";export const Drawing: React.FC<{- color1: string;- color2: string;-}> = ({color1, color2}) => {- const {width, height} = useVideoConfig();- const typefaces = useTypefaces();- const smallFont = Skia.Font(typefaces.Roboto, 30);- return (- <>- <SkiaNeon color1={color1} color2={color2} />- <Text- x={width / 2 - 270}- y={height * 0.9}- font={smallFont}- text="Edit src/HelloSkia.tsx and save to refresh."- color="white"- />- </>- );+ color1: string;+ color2: string;+}> = ({ color1, color2 }) => {+ const { width, height } = useVideoConfig();+ const typefaces = useTypefaces();+ const smallFont = Skia.Font(typefaces.Roboto, 30);+ return (+ <>+ <SkiaNeon color1={color1} color2={color2} />+ <Text+ x={width / 2 - 270}+ y={height * 0.9}+ font={smallFont}+ text="Edit src/HelloSkia.tsx and save to refresh."+ color="white"+ />+ </>+ );};diff --git a/packages/template-skia/src/HelloSkia.tsx b/packages/template-skia/src/HelloSkia.tsxindex 03bda21b26..a2396e1778 100644--- a/packages/template-skia/src/HelloSkia.tsx+++ b/packages/template-skia/src/HelloSkia.tsx@@ -1,41 +1,41 @@-import {SkiaCanvas} from '@remotion/skia';-import {useFont} from '@shopify/react-native-skia';-import {staticFile, useVideoConfig} from 'remotion';-import {AssetManager} from './AssetManager';-import {Drawing} from './Drawing';-import {z} from 'zod';-import {zColor} from '@remotion/zod-types';+import { SkiaCanvas } from "@remotion/skia";+import { useFont } from "@shopify/react-native-skia";+import { staticFile, useVideoConfig } from "remotion";+import { AssetManager } from "./AssetManager";+import { Drawing } from "./Drawing";+import { z } from "zod";+import { zColor } from "@remotion/zod-types";-const roboto = staticFile('Roboto-Bold.ttf');+const roboto = staticFile("Roboto-Bold.ttf");export const helloSkiaSchema = z.object({- color1: zColor(),- color2: zColor(),+ color1: zColor(),+ color2: zColor(),});export const HelloSkia: React.FC<z.infer<typeof helloSkiaSchema>> = ({- color1,- color2,+ color1,+ color2,}) => {- const {height, width} = useVideoConfig();+ const { height, width } = useVideoConfig();- const bigFont = useFont(roboto, 64);- const smallFont = useFont(roboto, 30);+ const bigFont = useFont(roboto, 64);+ const smallFont = useFont(roboto, 30);- if (bigFont === null || smallFont === null) {- return null;- }+ if (bigFont === null || smallFont === null) {+ return null;+ }- return (- <SkiaCanvas height={height} width={width}>- <AssetManager- images={[]}- typefaces={{- Roboto: roboto,- }}- >- <Drawing color1={color1} color2={color2} />- </AssetManager>- </SkiaCanvas>- );+ return (+ <SkiaCanvas height={height} width={width}>+ <AssetManager+ images={[]}+ typefaces={{+ Roboto: roboto,+ }}+ >+ <Drawing color1={color1} color2={color2} />+ </AssetManager>+ </SkiaCanvas>+ );};diff --git a/packages/template-skia/src/Root.tsx b/packages/template-skia/src/Root.tsxindex 7c27c77eaa..a2a32025b0 100644--- a/packages/template-skia/src/Root.tsx+++ b/packages/template-skia/src/Root.tsx@@ -1,21 +1,21 @@-import {Composition} from 'remotion';-import {HelloSkia, helloSkiaSchema} from './HelloSkia';+import { Composition } from "remotion";+import { HelloSkia, helloSkiaSchema } from "./HelloSkia";// Each <Composition> is an entry in the sidebar!export const RemotionRoot: React.FC = () => {- return (- <>- <Composition- id="HelloSkia"- component={HelloSkia}- durationInFrames={150}- fps={30}- width={1920}- height={1080}- schema={helloSkiaSchema}- defaultProps={{color1: '#0d81ed', color2: '#c14dff'}}- />- </>- );+ return (+ <>+ <Composition+ id="HelloSkia"+ component={HelloSkia}+ durationInFrames={150}+ fps={30}+ width={1920}+ height={1080}+ schema={helloSkiaSchema}+ defaultProps={{ color1: "#0d81ed", color2: "#c14dff" }}+ />+ </>+ );};diff --git a/packages/template-skia/src/SkiaNeon.tsx b/packages/template-skia/src/SkiaNeon.tsxindex 3cd9d953e5..ff03164a41 100644--- a/packages/template-skia/src/SkiaNeon.tsx+++ b/packages/template-skia/src/SkiaNeon.tsx@@ -1,25 +1,25 @@-import {useMemo} from 'react';+import { useMemo } from "react";import {- Blur,- Fill,- fitbox,- Group,- LinearGradient,- mix,- Paint,- Path,- processTransform2d,- rect,- Skia,- topLeft,- topRight,-} from '@shopify/react-native-skia';-import React from 'react';-import {interpolate, useCurrentFrame, useVideoConfig} from 'remotion';+ Blur,+ Fill,+ fitbox,+ Group,+ LinearGradient,+ mix,+ Paint,+ Path,+ processTransform2d,+ rect,+ Skia,+ topLeft,+ topRight,+} from "@shopify/react-native-skia";+import React from "react";+import { interpolate, useCurrentFrame, useVideoConfig } from "remotion";const CLAMP = {- extrapolateLeft: 'clamp',- extrapolateRight: 'clamp',+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",} as const;const PADDING = 200;const src = rect(0, 0, 2630, 1325);@@ -29,136 +29,136 @@ const duration = 15;export const durationInFrames = 500;export const SkiaNeon: React.FC<{- color1: string;- color2: string;-}> = ({color1, color2}) => {- const config = useVideoConfig();- const frame = useCurrentFrame();+ color1: string;+ color2: string;+}> = ({ color1, color2 }) => {+ const config = useVideoConfig();+ const frame = useCurrentFrame();- const defaultPath = useMemo(() => {- return [- {- path: 'M337 1240.85C255.37 1240.85 172.05 1218.91 95.1298 1176.32C66.9098 1160.69 56.6998 1125.15 72.3198 1096.92C87.9498 1068.7 123.49 1058.49 151.72 1074.11C234.05 1119.7 324.75 1134.72 407.1 1116.45C477.65 1100.79 536.83 1061.09 565.4 1010.25C617.62 917.33 559.54 810.94 410.02 725.65C336.2 683.54 280.74 631.74 245.18 571.68C212.25 516.07 197.94 455.14 203.79 395.47C213.51 296.33 278.64 212.57 369.71 182.08C421.12 164.87 556.28 141.83 700.95 299.09C722.79 322.83 721.25 359.78 697.51 381.62C673.77 403.46 636.82 401.92 614.98 378.18C545.69 302.86 469.82 271.77 406.8 292.85C359.34 308.74 325.29 353.49 320.06 406.85C316.65 441.64 325.52 478.05 345.71 512.15C370.81 554.54 411.93 592.23 467.91 624.16C574.82 685.15 646.14 757.33 679.89 838.69C711.63 915.24 707.15 996.48 667.25 1067.47C622 1147.98 536.41 1207.39 432.43 1230.48C401.23 1237.4 369.25 1240.83 337.02 1240.83L337 1240.85Z',- colors: [color1, color2],- index: 0,- },- {- path: 'M1138.92 165.17C1125.9 125.9 1100.15 98.6697 1066.34 88.2997C1066.14 88.2397 1065.95 88.1797 1065.75 88.1197C1065.49 88.0397 1065.23 87.9497 1064.96 87.8797C1064.64 87.7897 1064.32 87.7097 1064 87.6297C1063.73 87.5597 1063.46 87.4697 1063.18 87.3997C1062.87 87.3197 1062.55 87.2497 1062.24 87.1697C1062.15 87.1497 1062.05 87.1197 1061.96 87.0997C1040.54 81.8797 1007.17 81.1697 967.75 106.09C891.72 154.14 830.47 272.56 799.7 430.97C799.68 431.07 799.66 431.18 799.64 431.28C769.5 591.02 751.09 706.7 731.14 858.61C722.6 870.22 713.82 881.99 704.78 893.95C685.33 919.69 690.42 956.31 716.16 975.77C716.19 975.8 716.23 975.82 716.26 975.85C709.28 1032.39 701.81 1094.79 693.38 1165.81C689.58 1197.84 712.46 1226.89 744.5 1230.7C746.84 1230.98 749.16 1231.12 751.46 1231.11C780.64 1231.11 805.86 1209.28 809.39 1179.58C822.37 1070.29 833.06 981.6 843.14 903.34C960.33 741.27 1045.64 593.18 1097.09 462.37C1146.92 335.67 1161.39 232.9 1138.93 165.18L1138.92 165.17ZM1032.19 245.01C1031.2 271.29 1024.98 317.02 1000.98 385.66C980.77 443.45 945.19 525.07 882.67 631.12C891.9 575.39 902.18 517.89 914.4 453.08C934.24 351.05 963.83 289.29 985.17 255.44C1003.33 226.64 1019.19 212.04 1029.05 205.47C1031.03 212.97 1032.92 225.48 1032.19 245V245.01Z',- colors: [color1, color2],- index: 1,- },- {- path: 'M1246.01 751.92C1216.67 697.39 1154.11 667.2 1078.76 671.2C1022.69 674.16 969.23 694.8 924.14 730.88C811.16 821.29 767.19 948.76 720.64 1083.72C712.89 1106.19 704.87 1129.44 696.42 1152.91C685.49 1183.26 701.24 1216.73 731.59 1227.66C738.13 1230.01 744.81 1231.13 751.38 1231.13C775.31 1231.13 797.76 1216.31 806.34 1192.49C815.06 1168.28 823.21 1144.66 831.08 1121.82C852.41 1059.97 871.6 1004.37 895.37 955.61C903.22 971.03 917.79 982.83 936.08 986.46C968.61 992.9 999.52 996.13 1028.64 996.13C1059.83 996.13 1088.95 992.43 1115.77 985.04C1165.24 971.41 1205.23 945.47 1231.42 910.02C1266.98 861.89 1272.57 801.32 1246.01 751.95V751.92ZM1137.47 840.57C1116.69 868.69 1058.83 891.67 958.78 871.85C955.24 871.15 951.71 870.8 948.23 870.75C962.59 853.1 978.69 836.86 997.14 822.09C1023.04 801.36 1053.4 789.53 1084.93 787.86C1113.56 786.36 1135.88 793.79 1143.14 807.28C1148.14 816.57 1146.02 829.02 1137.47 840.58V840.57Z',- colors: [color1, color2],- index: 2,- },- {- path: 'M1167.59 1233.04C1136.47 1233.04 1108.1 1223.88 1084.19 1205.9C1064.31 1190.94 1048.84 1170.33 1039.46 1146.27C1029.78 1121.46 1023.59 1098.02 1018.13 1077.33C1002.02 1016.32 997.16 997.91 936.65 986.55C904.94 980.6 884.07 950.07 890.02 918.37C895.97 886.66 926.51 865.79 958.2 871.74C1091.27 896.72 1113.34 980.33 1131.08 1047.52C1135.97 1066.04 1141.03 1085.2 1148.29 1103.8C1149.76 1107.57 1151.94 1110.68 1154.42 1112.55C1156.37 1114.01 1162.32 1118.48 1179.67 1114.84C1228.36 1104.61 1296.65 1044.56 1320.74 1001.66C1321.59 1000.14 1322.51 998.66 1323.49 997.23C1376.98 919.19 1420.98 830.07 1463.53 743.88C1469.6 731.58 1475.65 719.32 1481.71 707.14C1496.07 678.25 1531.13 666.47 1560.01 680.83C1588.9 695.19 1600.67 730.25 1586.32 759.13C1580.31 771.22 1574.3 783.38 1568.28 795.59C1524.27 884.74 1478.77 976.9 1421.22 1061.26C1402.19 1094.21 1370.6 1130.22 1334.14 1160.47C1303.75 1185.69 1256.44 1218.07 1203.69 1229.16C1191.33 1231.76 1179.26 1233.05 1167.59 1233.05V1233.04Z',- colors: [color1, color2],- index: 3,- },- {- path: 'M1601.65 572.24C1636.16 572.24 1664.14 544.262 1664.14 509.75C1664.14 475.237 1636.16 447.26 1601.65 447.26C1567.14 447.26 1539.16 475.237 1539.16 509.75C1539.16 544.262 1567.14 572.24 1601.65 572.24Z',- colors: [color1, color2],- index: 3,- },- {- path: 'M1511.21 1238.1C1503.01 1238.1 1494.83 1237.45 1486.7 1236.04C1443.64 1228.58 1409.99 1201.23 1391.95 1159.04C1376.17 1122.15 1372.12 1074.7 1379.55 1013.96C1379.76 1012.21 1380.06 1010.47 1380.43 1008.75C1395.57 938.52 1428.06 841.28 1479.76 711.5C1491.7 681.53 1525.66 666.92 1555.64 678.86C1585.61 690.8 1600.22 724.77 1588.28 754.74C1540.36 875.03 1509.05 967.87 1495.19 1030.76C1489.42 1080.34 1495.29 1103.59 1499.35 1113.1C1502.38 1120.19 1504.16 1120.5 1506.63 1120.93C1523.36 1123.86 1569.02 1110.02 1626.23 1060.1C1677.06 1015.74 1715.89 960.521 1725.14 919.401C1741 848.951 1781.33 784.81 1838.73 738.79C1893.38 694.98 1959.88 669.801 2025.97 667.901C2084.23 666.231 2138.75 682.72 2183.55 715.6C2231.88 751.08 2267.59 805.29 2286.8 872.37C2295.68 903.38 2277.74 935.72 2246.73 944.61C2215.72 953.48 2183.38 935.55 2174.49 904.54C2143.84 797.5 2070.38 783.53 2029.34 784.68C1954.14 786.85 1861.91 843.79 1839.12 945.06C1824.33 1010.77 1773.46 1086.68 1703.05 1148.13C1670.37 1176.65 1590.67 1238.1 1511.21 1238.11V1238.1Z',- colors: [color1, color2],- index: 4,- },- {- path: 'M2286.16 675.26C2255.06 666.73 2222.91 685.03 2214.38 716.14L2211.32 727.28C2210.46 730.42 2209.58 733.63 2208.68 736.87C2200.66 729.13 2192.19 721.97 2183.29 715.46C2138.39 682.59 2083.77 666.15 2025.4 667.91C1959.3 669.9 1892.86 695.12 1838.31 738.92C1780.97 784.96 1740.77 849.11 1725.11 919.55C1724.83 920.81 1724.59 922.09 1724.39 923.36C1708.24 1028.61 1737.66 1118.39 1807.24 1176.16C1839.86 1203.25 1880.49 1221.91 1924.71 1230.12H1924.73C1942.3 1233.39 1960.16 1235 1978.09 1235C2027.12 1235 2076.58 1222.94 2121.39 1199.62C2125.2 1197.64 2129.03 1195.54 2132.77 1193.37C2209.9 1148.71 2262.85 1068.33 2274.42 978.37C2284.09 903.15 2307.12 819.41 2323.93 758.26L2327.01 747.04C2335.54 715.93 2317.24 683.79 2286.13 675.26H2286.16ZM2074.25 1092.27C2072.03 1093.56 2069.77 1094.8 2067.51 1095.98C2029.31 1115.86 1986.18 1122.72 1946.08 1115.27H1946.07C1921.4 1110.69 1899.2 1100.67 1881.88 1086.28C1844.95 1055.62 1830.34 1006.11 1839.58 943.03C1862.75 843.16 1954.15 786.92 2028.92 784.67C2068.42 783.5 2137.85 796.27 2170.53 891.91C2165.76 915.72 2161.62 939.79 2158.58 963.47C2151.62 1017.58 2120.1 1065.72 2074.25 1092.27V1092.27Z',- colors: [color1, color2],- index: 5,- },- {- path: 'M2307.12 1230.36C2239.76 1230.36 2179.25 1184.68 2161.93 1116.04C2134.29 1006.54 2179.86 841.33 2210.02 732C2211.53 726.54 2212.99 721.24 2214.39 716.14C2222.92 685.03 2255.06 666.72 2286.17 675.26C2317.28 683.79 2335.58 715.93 2327.05 747.04C2325.64 752.2 2324.16 757.55 2322.64 763.07C2297.39 854.63 2255.12 1007.86 2275.21 1087.45C2279.75 1105.43 2296.98 1116.54 2314.43 1112.73C2357.91 1103.27 2416.67 1052.05 2457.32 988.17C2474.64 960.95 2510.74 952.94 2537.96 970.25C2565.18 987.57 2573.2 1023.67 2555.88 1050.89C2530.23 1091.2 2498.67 1128.31 2464.63 1158.21C2423.02 1194.74 2380.85 1217.85 2339.27 1226.89C2328.49 1229.24 2317.73 1230.36 2307.14 1230.36H2307.12Z',- colors: [color1, color2],- index: 6,- },- ];- }, [color1, color2]);+ const defaultPath = useMemo(() => {+ return [+ {+ path: "M337 1240.85C255.37 1240.85 172.05 1218.91 95.1298 1176.32C66.9098 1160.69 56.6998 1125.15 72.3198 1096.92C87.9498 1068.7 123.49 1058.49 151.72 1074.11C234.05 1119.7 324.75 1134.72 407.1 1116.45C477.65 1100.79 536.83 1061.09 565.4 1010.25C617.62 917.33 559.54 810.94 410.02 725.65C336.2 683.54 280.74 631.74 245.18 571.68C212.25 516.07 197.94 455.14 203.79 395.47C213.51 296.33 278.64 212.57 369.71 182.08C421.12 164.87 556.28 141.83 700.95 299.09C722.79 322.83 721.25 359.78 697.51 381.62C673.77 403.46 636.82 401.92 614.98 378.18C545.69 302.86 469.82 271.77 406.8 292.85C359.34 308.74 325.29 353.49 320.06 406.85C316.65 441.64 325.52 478.05 345.71 512.15C370.81 554.54 411.93 592.23 467.91 624.16C574.82 685.15 646.14 757.33 679.89 838.69C711.63 915.24 707.15 996.48 667.25 1067.47C622 1147.98 536.41 1207.39 432.43 1230.48C401.23 1237.4 369.25 1240.83 337.02 1240.83L337 1240.85Z",+ colors: [color1, color2],+ index: 0,+ },+ {+ path: "M1138.92 165.17C1125.9 125.9 1100.15 98.6697 1066.34 88.2997C1066.14 88.2397 1065.95 88.1797 1065.75 88.1197C1065.49 88.0397 1065.23 87.9497 1064.96 87.8797C1064.64 87.7897 1064.32 87.7097 1064 87.6297C1063.73 87.5597 1063.46 87.4697 1063.18 87.3997C1062.87 87.3197 1062.55 87.2497 1062.24 87.1697C1062.15 87.1497 1062.05 87.1197 1061.96 87.0997C1040.54 81.8797 1007.17 81.1697 967.75 106.09C891.72 154.14 830.47 272.56 799.7 430.97C799.68 431.07 799.66 431.18 799.64 431.28C769.5 591.02 751.09 706.7 731.14 858.61C722.6 870.22 713.82 881.99 704.78 893.95C685.33 919.69 690.42 956.31 716.16 975.77C716.19 975.8 716.23 975.82 716.26 975.85C709.28 1032.39 701.81 1094.79 693.38 1165.81C689.58 1197.84 712.46 1226.89 744.5 1230.7C746.84 1230.98 749.16 1231.12 751.46 1231.11C780.64 1231.11 805.86 1209.28 809.39 1179.58C822.37 1070.29 833.06 981.6 843.14 903.34C960.33 741.27 1045.64 593.18 1097.09 462.37C1146.92 335.67 1161.39 232.9 1138.93 165.18L1138.92 165.17ZM1032.19 245.01C1031.2 271.29 1024.98 317.02 1000.98 385.66C980.77 443.45 945.19 525.07 882.67 631.12C891.9 575.39 902.18 517.89 914.4 453.08C934.24 351.05 963.83 289.29 985.17 255.44C1003.33 226.64 1019.19 212.04 1029.05 205.47C1031.03 212.97 1032.92 225.48 1032.19 245V245.01Z",+ colors: [color1, color2],+ index: 1,+ },+ {+ path: "M1246.01 751.92C1216.67 697.39 1154.11 667.2 1078.76 671.2C1022.69 674.16 969.23 694.8 924.14 730.88C811.16 821.29 767.19 948.76 720.64 1083.72C712.89 1106.19 704.87 1129.44 696.42 1152.91C685.49 1183.26 701.24 1216.73 731.59 1227.66C738.13 1230.01 744.81 1231.13 751.38 1231.13C775.31 1231.13 797.76 1216.31 806.34 1192.49C815.06 1168.28 823.21 1144.66 831.08 1121.82C852.41 1059.97 871.6 1004.37 895.37 955.61C903.22 971.03 917.79 982.83 936.08 986.46C968.61 992.9 999.52 996.13 1028.64 996.13C1059.83 996.13 1088.95 992.43 1115.77 985.04C1165.24 971.41 1205.23 945.47 1231.42 910.02C1266.98 861.89 1272.57 801.32 1246.01 751.95V751.92ZM1137.47 840.57C1116.69 868.69 1058.83 891.67 958.78 871.85C955.24 871.15 951.71 870.8 948.23 870.75C962.59 853.1 978.69 836.86 997.14 822.09C1023.04 801.36 1053.4 789.53 1084.93 787.86C1113.56 786.36 1135.88 793.79 1143.14 807.28C1148.14 816.57 1146.02 829.02 1137.47 840.58V840.57Z",+ colors: [color1, color2],+ index: 2,+ },+ {+ path: "M1167.59 1233.04C1136.47 1233.04 1108.1 1223.88 1084.19 1205.9C1064.31 1190.94 1048.84 1170.33 1039.46 1146.27C1029.78 1121.46 1023.59 1098.02 1018.13 1077.33C1002.02 1016.32 997.16 997.91 936.65 986.55C904.94 980.6 884.07 950.07 890.02 918.37C895.97 886.66 926.51 865.79 958.2 871.74C1091.27 896.72 1113.34 980.33 1131.08 1047.52C1135.97 1066.04 1141.03 1085.2 1148.29 1103.8C1149.76 1107.57 1151.94 1110.68 1154.42 1112.55C1156.37 1114.01 1162.32 1118.48 1179.67 1114.84C1228.36 1104.61 1296.65 1044.56 1320.74 1001.66C1321.59 1000.14 1322.51 998.66 1323.49 997.23C1376.98 919.19 1420.98 830.07 1463.53 743.88C1469.6 731.58 1475.65 719.32 1481.71 707.14C1496.07 678.25 1531.13 666.47 1560.01 680.83C1588.9 695.19 1600.67 730.25 1586.32 759.13C1580.31 771.22 1574.3 783.38 1568.28 795.59C1524.27 884.74 1478.77 976.9 1421.22 1061.26C1402.19 1094.21 1370.6 1130.22 1334.14 1160.47C1303.75 1185.69 1256.44 1218.07 1203.69 1229.16C1191.33 1231.76 1179.26 1233.05 1167.59 1233.05V1233.04Z",+ colors: [color1, color2],+ index: 3,+ },+ {+ path: "M1601.65 572.24C1636.16 572.24 1664.14 544.262 1664.14 509.75C1664.14 475.237 1636.16 447.26 1601.65 447.26C1567.14 447.26 1539.16 475.237 1539.16 509.75C1539.16 544.262 1567.14 572.24 1601.65 572.24Z",+ colors: [color1, color2],+ index: 3,+ },+ {+ path: "M1511.21 1238.1C1503.01 1238.1 1494.83 1237.45 1486.7 1236.04C1443.64 1228.58 1409.99 1201.23 1391.95 1159.04C1376.17 1122.15 1372.12 1074.7 1379.55 1013.96C1379.76 1012.21 1380.06 1010.47 1380.43 1008.75C1395.57 938.52 1428.06 841.28 1479.76 711.5C1491.7 681.53 1525.66 666.92 1555.64 678.86C1585.61 690.8 1600.22 724.77 1588.28 754.74C1540.36 875.03 1509.05 967.87 1495.19 1030.76C1489.42 1080.34 1495.29 1103.59 1499.35 1113.1C1502.38 1120.19 1504.16 1120.5 1506.63 1120.93C1523.36 1123.86 1569.02 1110.02 1626.23 1060.1C1677.06 1015.74 1715.89 960.521 1725.14 919.401C1741 848.951 1781.33 784.81 1838.73 738.79C1893.38 694.98 1959.88 669.801 2025.97 667.901C2084.23 666.231 2138.75 682.72 2183.55 715.6C2231.88 751.08 2267.59 805.29 2286.8 872.37C2295.68 903.38 2277.74 935.72 2246.73 944.61C2215.72 953.48 2183.38 935.55 2174.49 904.54C2143.84 797.5 2070.38 783.53 2029.34 784.68C1954.14 786.85 1861.91 843.79 1839.12 945.06C1824.33 1010.77 1773.46 1086.68 1703.05 1148.13C1670.37 1176.65 1590.67 1238.1 1511.21 1238.11V1238.1Z",+ colors: [color1, color2],+ index: 4,+ },+ {+ path: "M2286.16 675.26C2255.06 666.73 2222.91 685.03 2214.38 716.14L2211.32 727.28C2210.46 730.42 2209.58 733.63 2208.68 736.87C2200.66 729.13 2192.19 721.97 2183.29 715.46C2138.39 682.59 2083.77 666.15 2025.4 667.91C1959.3 669.9 1892.86 695.12 1838.31 738.92C1780.97 784.96 1740.77 849.11 1725.11 919.55C1724.83 920.81 1724.59 922.09 1724.39 923.36C1708.24 1028.61 1737.66 1118.39 1807.24 1176.16C1839.86 1203.25 1880.49 1221.91 1924.71 1230.12H1924.73C1942.3 1233.39 1960.16 1235 1978.09 1235C2027.12 1235 2076.58 1222.94 2121.39 1199.62C2125.2 1197.64 2129.03 1195.54 2132.77 1193.37C2209.9 1148.71 2262.85 1068.33 2274.42 978.37C2284.09 903.15 2307.12 819.41 2323.93 758.26L2327.01 747.04C2335.54 715.93 2317.24 683.79 2286.13 675.26H2286.16ZM2074.25 1092.27C2072.03 1093.56 2069.77 1094.8 2067.51 1095.98C2029.31 1115.86 1986.18 1122.72 1946.08 1115.27H1946.07C1921.4 1110.69 1899.2 1100.67 1881.88 1086.28C1844.95 1055.62 1830.34 1006.11 1839.58 943.03C1862.75 843.16 1954.15 786.92 2028.92 784.67C2068.42 783.5 2137.85 796.27 2170.53 891.91C2165.76 915.72 2161.62 939.79 2158.58 963.47C2151.62 1017.58 2120.1 1065.72 2074.25 1092.27V1092.27Z",+ colors: [color1, color2],+ index: 5,+ },+ {+ path: "M2307.12 1230.36C2239.76 1230.36 2179.25 1184.68 2161.93 1116.04C2134.29 1006.54 2179.86 841.33 2210.02 732C2211.53 726.54 2212.99 721.24 2214.39 716.14C2222.92 685.03 2255.06 666.72 2286.17 675.26C2317.28 683.79 2335.58 715.93 2327.05 747.04C2325.64 752.2 2324.16 757.55 2322.64 763.07C2297.39 854.63 2255.12 1007.86 2275.21 1087.45C2279.75 1105.43 2296.98 1116.54 2314.43 1112.73C2357.91 1103.27 2416.67 1052.05 2457.32 988.17C2474.64 960.95 2510.74 952.94 2537.96 970.25C2565.18 987.57 2573.2 1023.67 2555.88 1050.89C2530.23 1091.2 2498.67 1128.31 2464.63 1158.21C2423.02 1194.74 2380.85 1217.85 2339.27 1226.89C2328.49 1229.24 2317.73 1230.36 2307.14 1230.36H2307.12Z",+ colors: [color1, color2],+ index: 6,+ },+ ];+ }, [color1, color2]);- const dst = rect(- PADDING,- PADDING,- config.width - PADDING * 2,- config.height - PADDING * 2,- );- const progresses = [- interpolate(frame, [0, duration], [0, 1], CLAMP),- interpolate(frame, [duration, 2 * duration], [0, 1], CLAMP),- interpolate(frame, [2 * duration, 3 * duration], [0, 1], CLAMP),- interpolate(frame, [3 * duration, 4 * duration], [0, 1], CLAMP),- interpolate(frame, [4 * duration, 5 * duration], [0, 1], CLAMP),- interpolate(frame, [5 * duration, 6 * duration], [0, 1], CLAMP),- interpolate(frame, [6 * duration, 7 * duration], [0, 1], CLAMP),- ];+ const dst = rect(+ PADDING,+ PADDING,+ config.width - PADDING * 2,+ config.height - PADDING * 2,+ );+ const progresses = [+ interpolate(frame, [0, duration], [0, 1], CLAMP),+ interpolate(frame, [duration, 2 * duration], [0, 1], CLAMP),+ interpolate(frame, [2 * duration, 3 * duration], [0, 1], CLAMP),+ interpolate(frame, [3 * duration, 4 * duration], [0, 1], CLAMP),+ interpolate(frame, [4 * duration, 5 * duration], [0, 1], CLAMP),+ interpolate(frame, [5 * duration, 6 * duration], [0, 1], CLAMP),+ interpolate(frame, [6 * duration, 7 * duration], [0, 1], CLAMP),+ ];- const paths = defaultPath.map((def) => {- const path = Skia.Path.MakeFromSVGString(def.path)!;- path.transform(processTransform2d(fitbox('contain', src, dst)));- const bounds = path.computeTightBounds();- const {colors} = def;- return {- path,- bounds,- colors,- progress: progresses[def.index]!,- };- });- const b1 = 8;- const b2 = 1.75;- const progress8 = progresses[progresses.length - 1]!;- const blur1 = mix(progress8, b1 * 2, b1);- const blur2 = mix(progress8, b2 * 2, b2);- return (- <>- <Fill color="black" />- {paths.map(({path, colors, bounds, progress}, i) => (- <React.Fragment key={i}>- <Group clip={path}>- <Fill color={`rgba(0,0,0, ${progress})`} />- </Group>- <Path- path={path}- color="transparent"- strokeCap="round"- strokeJoin="round"- end={progress}- >- <Paint style="stroke" strokeWidth={15}>- <LinearGradient- colors={colors}- start={topLeft(bounds)}- end={topRight(bounds)}- />- <Blur- blur={interpolate(progress, [0, 0.5, 1], [0, blur1 * 2, blur1])}- />- </Paint>- <Paint style="stroke" strokeWidth={4}>- <LinearGradient- colors={colors}- start={topLeft(bounds)}- end={topRight(bounds)}- />- <Blur- blur={interpolate(progress, [0, 0.5, 1], [0, blur2 * 2, blur2])}- />- </Paint>- <Paint style="stroke" strokeWidth={1}>- <LinearGradient- colors={colors}- start={topLeft(bounds)}- end={topRight(bounds)}- />- </Paint>- <Paint style="stroke" strokeWidth={2.5} color="white" />- </Path>- </React.Fragment>- ))}- </>- );+ const paths = defaultPath.map((def) => {+ const path = Skia.Path.MakeFromSVGString(def.path)!;+ path.transform(processTransform2d(fitbox("contain", src, dst)));+ const bounds = path.computeTightBounds();+ const { colors } = def;+ return {+ path,+ bounds,+ colors,+ progress: progresses[def.index]!,+ };+ });+ const b1 = 8;+ const b2 = 1.75;+ const progress8 = progresses[progresses.length - 1]!;+ const blur1 = mix(progress8, b1 * 2, b1);+ const blur2 = mix(progress8, b2 * 2, b2);+ return (+ <>+ <Fill color="black" />+ {paths.map(({ path, colors, bounds, progress }, i) => (+ <React.Fragment key={i}>+ <Group clip={path}>+ <Fill color={`rgba(0,0,0, ${progress})`} />+ </Group>+ <Path+ path={path}+ color="transparent"+ strokeCap="round"+ strokeJoin="round"+ end={progress}+ >+ <Paint style="stroke" strokeWidth={15}>+ <LinearGradient+ colors={colors}+ start={topLeft(bounds)}+ end={topRight(bounds)}+ />+ <Blur+ blur={interpolate(progress, [0, 0.5, 1], [0, blur1 * 2, blur1])}+ />+ </Paint>+ <Paint style="stroke" strokeWidth={4}>+ <LinearGradient+ colors={colors}+ start={topLeft(bounds)}+ end={topRight(bounds)}+ />+ <Blur+ blur={interpolate(progress, [0, 0.5, 1], [0, blur2 * 2, blur2])}+ />+ </Paint>+ <Paint style="stroke" strokeWidth={1}>+ <LinearGradient+ colors={colors}+ start={topLeft(bounds)}+ end={topRight(bounds)}+ />+ </Paint>+ <Paint style="stroke" strokeWidth={2.5} color="white" />+ </Path>+ </React.Fragment>+ ))}+ </>+ );};diff --git a/packages/template-skia/src/index.ts b/packages/template-skia/src/index.tsindex ed706723a4..080329db73 100644--- a/packages/template-skia/src/index.ts+++ b/packages/template-skia/src/index.ts@@ -1,8 +1,8 @@-import {LoadSkia} from '@shopify/react-native-skia/src/web';-import {registerRoot} from 'remotion';+import { LoadSkia } from "@shopify/react-native-skia/src/web";+import { registerRoot } from "remotion";(async () => {- await LoadSkia();- const {RemotionRoot} = await import('./Root');- registerRoot(RemotionRoot);+ await LoadSkia();+ const { RemotionRoot } = await import("./Root");+ registerRoot(RemotionRoot);})();diff --git a/packages/template-stargazer/.eslintrc b/packages/template-stargazer/.eslintrcnew file mode 100644index 0000000000..67f9fd93c1--- /dev/null+++ b/packages/template-stargazer/.eslintrc@@ -0,0 +1,3 @@+{+ "extends": "@remotion",+}diff --git a/packages/template-stargazer/.gitignore b/packages/template-stargazer/.gitignorenew file mode 100644index 0000000000..3bea3d0450--- /dev/null+++ b/packages/template-stargazer/.gitignore@@ -0,0 +1,7 @@+node_modules+dist+.DS_Store+todo.md+.env++builddiff --git a/packages/template-stargazer/.prettierrc b/packages/template-stargazer/.prettierrcnew file mode 100644index 0000000000..37d5071748--- /dev/null+++ b/packages/template-stargazer/.prettierrc@@ -0,0 +1,5 @@+{+ "useTabs": false,+ "bracketSpacing": true,+ "tabWidth": 2+}diff --git a/packages/template-stargazer/README.md b/packages/template-stargazer/README.mdnew file mode 100644index 0000000000..9c633947c2--- /dev/null+++ b/packages/template-stargazer/README.md@@ -0,0 +1,67 @@+Your repo reached a stars milestone? Celebrate with a video of your stargazers!++## Example++https://user-images.githubusercontent.com/1911623/121809549-93342a80-cc33-11eb-88ff-e45f8b6dace4.mp4?width=200++## There are 2 ways to make your Stargazer video.++1. Make your Video locally+2. Make your Video using Github Actions (Easy)++## Make your own video (local)++1. [Use this repo as a template](https://github.com/pomber/stargazer/generate)++2. Go to https://github.com/settings/personal-access-tokens/new and create a token with default settings. Create a `.env` file and add it:++```+REMOTION_GITHUB_TOKEN=github_pat_...+```++3. Install dependencies:++```+npm i+```++4. Start the preview:++```+npm start+```++5. Open the right sidebar, enter your repo name and click "Render".++## Make your own video (GitHub Actions)++1. Fork this repo+ <img src="https://user-images.githubusercontent.com/1911623/121809008-75fe5c80-cc31-11eb-8f44-5df6183deca5.png" width="720"/>++2. Go to Actions of the forked repo.+ <img src="https://user-images.githubusercontent.com/1911623/121809050-ae059f80-cc31-11eb-9af9-2aa05a24bc7f.png" width="720"/>++3. Click on `I understand my workforce, go ahead and enable them `+ <img src="https://user-images.githubusercontent.com/1911623/121809098-e1482e80-cc31-11eb-9ffc-e4d34f419fb1.png" width="720"/>++4. Go to the render video option in the workforce.+ <img src="https://user-images.githubusercontent.com/1911623/121809174-1e142580-cc32-11eb-84cc-c5aa19698fc1.png" width="720"/>++5. Over here enter the details of the repo for which you want to make the Stargazer video.+ <img src="https://user-images.githubusercontent.com/1911623/121809216-54ea3b80-cc32-11eb-8b22-7d74306adb9e.png" width="720"/>++6. Here you can see the progress of the rendering video.+ <img src="https://user-images.githubusercontent.com/1911623/121809344-cf1ac000-cc32-11eb-93c3-cc6e58ff7988.png" width="720"/>++7. By clicking on this you can get your Stargazer video.+ <img src="https://user-images.githubusercontent.com/1911623/121809394-fb364100-cc32-11eb-8a82-e9a6d25f37cf.png" width="720"/>++## Credits++Made with [Remotion](https://www.remotion.dev/)++## License++The code in this repository: Licensed under MIT.+The Remotion framework (a dependency of this project): Normally, companies need to obtain a paid license.+However, creating videos of this template [is accepted](https://github.com/pomber/stargazer/issues/19#issuecomment-1868469783) without needing a company license.diff --git a/packages/template-stargazer/package.json b/packages/template-stargazer/package.jsonnew file mode 100644index 0000000000..f79f095c12--- /dev/null+++ b/packages/template-stargazer/package.json@@ -0,0 +1,26 @@+{+ "name": "template-stargazer",+ "version": "1.0.0",+ "scripts": {+ "start": "remotion studio",+ "build": "remotion render main out/Main.mp4 --log verbose",+ "test": "eslint src --ext ts,tsx,js,jsx && tsc"+ },+ "license": "UNLICENSED",+ "dependencies": {+ "@remotion/bundler": "workspace:*",+ "@remotion/cli": "workspace:*",+ "@remotion/renderer": "workspace:*",+ "react": "18.3.1",+ "react-dom": "18.3.1",+ "remotion": "workspace:*",+ "zod": "3.22.3"+ },+ "devDependencies": {+ "@remotion/eslint-config": "workspace:*",+ "@types/react": "18.3.1",+ "eslint": "8.56.0",+ "prettier": "3.3.3",+ "typescript": "5.6.2"+ }+}diff --git a/packages/template-stargazer/remotion.config.ts b/packages/template-stargazer/remotion.config.tsnew file mode 100644index 0000000000..f7020242c6--- /dev/null+++ b/packages/template-stargazer/remotion.config.ts@@ -0,0 +1,9 @@+import { Config } from "@remotion/cli/config";++/**+ * Note: When using the Node.JS APIs, the config file+ * doesn't apply. Instead, pass options directly to the APIs+ */++Config.setVideoImageFormat("jpeg");+Config.setDelayRenderTimeoutInMilliseconds(1200000);diff --git a/packages/template-stargazer/src/Content.tsx b/packages/template-stargazer/src/Content.tsxnew file mode 100644index 0000000000..fc382d7a10--- /dev/null+++ b/packages/template-stargazer/src/Content.tsx@@ -0,0 +1,162 @@+import { Img, useVideoConfig } from "remotion";+import { Stargazer } from "./cache";+import { RepoHeader } from "./repo-header";++const W = 1280 / 2.5;+const H = 720 / 2.5;++export function Content({+ stargazers,+ repoOrg,+ repoName,+ progress,+}: {+ stargazers: Stargazer[];+ repoOrg: string;+ repoName: string;+ progress: number;+}) {+ const gap = 102;+ const startY = 76 - gap;+ const dy = progress * gap;+ const { width } = useVideoConfig();++ return (+ <div+ style={{+ flex: 1,+ backgroundColor: "#f6f8fa",+ position: "relative",+ maxWidth: W,+ maxHeight: H,+ minHeight: H,+ transformOrigin: "top left",+ transform: `scale(${width / W})`,+ }}+ >+ {stargazers.map((stargazer, index) => {+ const isHidden = Math.abs(index - progress) > 3;+ const grow = 0;+ const opacity = Math.min(0.1 + progress - index, 1);+ return isHidden ? null : (+ <StarBox+ key={stargazer.login}+ avatarUrl={stargazer.avatarUrl}+ name={stargazer.name}+ date={stargazer.date}+ repoName={repoName}+ y={startY - gap * index + dy}+ grow={grow}+ opacity={opacity}+ starNumber={index + 1}+ />+ );+ })}++ <RepoHeader stars={Math.round(progress)} org={repoOrg} name={repoName} />+ </div>+ );+}++function StarBox({+ avatarUrl,+ name,+ date,+ repoName,+ y,+ starNumber,+ grow,+ opacity,+}: {+ avatarUrl: string;+ name: string;+ date: string;+ repoName: string;+ y: number;+ starNumber: number;+ grow: number;+ opacity: number;+}) {+ const d = new Date(date);+ const dateString = d.toLocaleDateString("en-US", {+ month: "short",+ day: "2-digit",+ year: "numeric",+ });++ return (+ <div+ style={{+ background: "white",+ border: "1px solid #e1e4e8",+ borderRadius: 6,+ padding: 12,+ display: "flex",+ position: "absolute",+ opacity,+ top: 0,+ right: 24,+ left: 24,+ height: 88,+ minHeight: 88,+ maxHeight: 88,+ transform: `translateY(${y}px) scale(${1 + grow * 0.07})`,+ }}+ >+ <Img+ width="64"+ height="64"+ src={avatarUrl}+ style={{ borderRadius: "50%" }}+ />+ <div+ style={{+ display: "flex",+ flexDirection: "column",+ marginLeft: "12px",+ flex: 1,+ maxWidth: 560,+ minWidth: 0,+ }}+ >+ <h3+ style={{+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ maxWidth: 360,+ fontWeight: 400,+ }}+ >+ {name}+ </h3>+ <div+ style={{+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ starred <b>{repoName}</b>{" "}+ <span style={{ color: "#586069" }}>on {dateString}</span>+ </div>+ </div>+ <div+ style={{+ width: 64,+ height: 64,+ display: "flex",+ flexDirection: "column",+ justifyContent: "center",+ alignItems: "center",+ }}+ >+ <span style={{ fontSize: "0.8em", color: "#586069" }}>Star</span>+ <div style={{ fontSize: "1.2em" }}>+ <span style={{ fontSize: "1em", color: "#586069" }}>#</span>+ {starNumber}+ </div>+ </div>+ </div>+ );+}diff --git a/packages/template-stargazer/src/Main.tsx b/packages/template-stargazer/src/Main.tsxnew file mode 100644index 0000000000..cdfb9ada35--- /dev/null+++ b/packages/template-stargazer/src/Main.tsx@@ -0,0 +1,45 @@+import { useCurrentFrame, useVideoConfig } from "remotion";+import { z } from "zod";+import { Stargazer } from "./cache";+import { Content } from "./Content";+import { getProgress } from "./utils";++export const mainSchema = z.object({+ repoOrg: z.string(),+ repoName: z.string(),+ starCount: z.number().step(1),+ duration: z.number().step(1),+});++type SchemaProps = z.infer<typeof mainSchema>;++export type MainProps = SchemaProps & {+ stargazers: Stargazer[] | null;+};++export function Main({ repoOrg, repoName, stargazers }: MainProps) {+ const frame = useCurrentFrame();+ const { fps, durationInFrames } = useVideoConfig();++ const extraEnding = fps;++ if (!stargazers) {+ return null;+ }++ const progress = getProgress(+ frame,+ durationInFrames - extraEnding,+ stargazers.length,+ fps,+ );++ return (+ <Content+ stargazers={stargazers}+ repoOrg={repoOrg}+ repoName={repoName}+ progress={progress}+ />+ );+}diff --git a/packages/template-stargazer/src/Root.tsx b/packages/template-stargazer/src/Root.tsxnew file mode 100644index 0000000000..22349b33bd--- /dev/null+++ b/packages/template-stargazer/src/Root.tsx@@ -0,0 +1,51 @@+import { useCallback } from "react";+import { CalculateMetadataFunction, Composition } from "remotion";+import { Main, MainProps, mainSchema } from "./Main";+import { fetchStargazers } from "./fetch/fetch-data";+import { waitForNoInput } from "./wait-for-no-input";++const FPS = 30;++export function RemotionVideo() {+ const calculateMetadata: CalculateMetadataFunction<MainProps> = useCallback(+ async ({ props, abortSignal }) => {+ await waitForNoInput(abortSignal, 500);++ const stargazers = await fetchStargazers({+ repoOrg: props.repoOrg,+ repoName: props.repoName,+ starCount: props.starCount,+ abortSignal,+ });++ return {+ props: {+ ...props,+ stargazers,+ },+ durationInFrames: props.duration * FPS,+ };+ },+ [],+ );++ return (+ <Composition+ id="main"+ component={Main}+ durationInFrames={15 * FPS}+ fps={FPS}+ width={960}+ height={540}+ schema={mainSchema}+ calculateMetadata={calculateMetadata}+ defaultProps={{+ repoOrg: "code-hike",+ repoName: "codehike",+ starCount: 100,+ duration: 15,+ stargazers: null,+ }}+ />+ );+}diff --git a/packages/template-stargazer/src/cache.ts b/packages/template-stargazer/src/cache.tsnew file mode 100644index 0000000000..20c430428d--- /dev/null+++ b/packages/template-stargazer/src/cache.ts@@ -0,0 +1,68 @@+export type QueryResult = {+ cursor: string;+ results: Stargazer[];+};++export type Stargazer = {+ avatarUrl: string;+ name: string;+ date: string;+ login: string;+};++const makeKey = ({+ count,+ cursor,+ repoName,+ repoOrg,+}: {+ repoOrg: string;+ repoName: string;+ count: number;+ cursor: string | null;+}) => {+ return ["__stargazer", repoOrg, repoName, count, cursor].join("-");+};++export const saveResult = ({+ count,+ cursor,+ repoName,+ repoOrg,+ result,+}: {+ repoOrg: string;+ repoName: string;+ count: number;+ cursor: string | null;+ result: QueryResult;+}) => {+ try {+ const key = makeKey({ count, cursor, repoName, repoOrg });+ window.localStorage.setItem(key, JSON.stringify(result));+ } catch (err) {+ // If quota is exceeded, don't cache+ if (!(err as Error).message.toLowerCase().includes("quota")) {+ throw err;+ }+ }+};++export const getFromCache = ({+ count,+ cursor,+ repoName,+ repoOrg,+}: {+ repoOrg: string;+ repoName: string;+ count: number;+ cursor: string | null;+}): QueryResult | null => {+ const key = makeKey({ count, cursor, repoName, repoOrg });+ const value = window.localStorage.getItem(key);+ if (!value) {+ return null;+ }+ return JSON.parse(value);+};diff --git a/packages/template-stargazer/src/fetch/fetch-data.ts b/packages/template-stargazer/src/fetch/fetch-data.tsnew file mode 100644index 0000000000..9690892b29--- /dev/null+++ b/packages/template-stargazer/src/fetch/fetch-data.ts@@ -0,0 +1,71 @@+import { QueryResult, Stargazer } from "../cache";+import { fetchViaGraphQl } from "./via-graphql";+import { fetchPageViaRest, REST_PER_PAGE } from "./via-rest";++export async function fetchStargazers({+ repoOrg,+ repoName,+ starCount,+ abortSignal,+}: {+ repoOrg: string;+ repoName: string;+ starCount: number;+ abortSignal: AbortSignal;+}) {+ let allStargazers: Stargazer[] = [];++ console.log("Fetching stars...");+ if (!process.env.REMOTION_GITHUB_TOKEN) {+ console.error(+ "No REMOTION_GITHUB_TOKEN environment variable found. Using the GitHub REST API instead of GraphQL, which has a lower rate-limit and does not show the star dates.",+ );++ let page = 0;++ for (let i = 0; i < Math.ceil(starCount / REST_PER_PAGE); i++) {+ const stars = await fetchPageViaRest({+ abortSignal,+ page,+ repoName,+ repoOrg,+ });+ if (stars.length === 0) {+ break;+ }+ allStargazers = [...allStargazers, ...stars];+ console.log(`Fetched ${allStargazers.length} stars`);+ if (allStargazers.length >= starCount) {+ allStargazers = allStargazers.slice(0, starCount);+ break;+ }+ page++;+ }+ return allStargazers;+ }+ let starsLeft = starCount;+ let cursor = null;++ while (starsLeft > 0) {+ const count = Math.min(starsLeft, 100);+ const result = (await fetchViaGraphQl({+ repoOrg,+ repoName,+ count,+ cursor,+ abortSignal,+ })) as QueryResult;++ const { cursor: newCursor, results } = result;+ allStargazers = [...allStargazers, ...results];+ console.log(`Fetched ${allStargazers.length} stars`);+ cursor = newCursor;+ if (results.length < count) {+ starsLeft = 0;+ } else {+ starsLeft -= results.length;+ }+ }++ return allStargazers;+}diff --git a/packages/template-stargazer/src/fetch/via-graphql.ts b/packages/template-stargazer/src/fetch/via-graphql.tsnew file mode 100644index 0000000000..e3b34de1ab--- /dev/null+++ b/packages/template-stargazer/src/fetch/via-graphql.ts@@ -0,0 +1,114 @@+import { QueryResult, Stargazer, getFromCache, saveResult } from "../cache";++type Edge = {+ starredAt: string;+ node: {+ avatarUrl: string;+ name?: string;+ login: string;+ };+ cursor: string;+};++type ApiError =+ | {+ type: "RATE_LIMITED";+ message: string;+ }+ | {+ type: string;+ message: string;+ };++type GitHubApiResponse =+ | {+ data: {+ repository: {+ stargazers: {+ edges: Edge[];+ };+ };+ };+ }+ | {+ errors: ApiError[];+ };++export const fetchViaGraphQl = async ({+ count,+ cursor,+ repoName,+ repoOrg,+ abortSignal,+}: {+ repoOrg: string;+ repoName: string;+ count: number;+ cursor: string | null;+ abortSignal: AbortSignal;+}): Promise<QueryResult> => {+ const cache = getFromCache({ repoOrg, repoName, count, cursor });+ if (cache) {+ return cache;+ }+ const query = `{+ repository(owner: "${repoOrg}", name: "${repoName}") {+ stargazers(first: ${count}${cursor ? `, after: "${cursor}"` : ""}) {+ edges {+ starredAt+ node {+ avatarUrl+ name+ login+ }+ cursor+ }+ }+ }+ }`;++ const res = await fetch("https://api.github.com/graphql", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ authorization: `token ${process.env.REMOTION_GITHUB_TOKEN}`,+ },+ signal: abortSignal,+ body: JSON.stringify({ query }),+ });++ if (!res.ok) {+ const textResponse = await res.text();+ throw Error(`HTTP ${res.status} ${res.statusText}: ${textResponse}`);+ }++ const json = (await res.json()) as GitHubApiResponse;++ if ("errors" in json) {+ if (json.errors[0].type === "RATE_LIMITED") {+ console.error("Rate limit exceeded, waiting 1 minute...");+ await new Promise((resolve) => {+ setTimeout(resolve, 60 * 1000);+ });+ return fetchViaGraphQl({ repoOrg, repoName, count, cursor, abortSignal });+ }+ throw new Error(JSON.stringify(json.errors));+ }++ const { edges } = json.data.repository.stargazers;+ const lastCursor = edges[edges.length - 1].cursor;++ const page: Stargazer[] = edges.map((edge) => {+ return {+ avatarUrl: edge.node.avatarUrl,+ date: edge.starredAt,+ name: edge.node.name || edge.node.login,+ login: edge.node.login,+ };+ });++ const result = { cursor: lastCursor, results: page };+ saveResult({ repoOrg, repoName, count, cursor, result });++ return result;+};diff --git a/packages/template-stargazer/src/fetch/via-rest.ts b/packages/template-stargazer/src/fetch/via-rest.tsnew file mode 100644index 0000000000..5ea83162d8--- /dev/null+++ b/packages/template-stargazer/src/fetch/via-rest.ts@@ -0,0 +1,55 @@+import { Stargazer } from "../cache";++export const REST_PER_PAGE = 100;++type GitHubApiResponse = {+ starred_at: string;+ user: {+ login: string;+ avatar_url: string;+ };+}[];++export const fetchPageViaRest = async ({+ abortSignal,+ page,+ repoName,+ repoOrg,+}: {+ repoOrg: string;+ repoName: string;+ page: number;+ abortSignal: AbortSignal;+}): Promise<Stargazer[]> => {+ const url = `https://api.github.com/repos/${repoOrg}/${repoName}/stargazers?per_page=${REST_PER_PAGE}&page=${page}`;+ const res = await fetch(url, {+ headers: {+ Accept: "application/vnd.github.v3.star+json",+ ...(process.env.REMOTION_GITHUB_TOKEN && {+ Authorization: `Bearer ${process.env.REMOTION_GITHUB_TOKEN}`,+ }),+ },+ signal: abortSignal,+ });+ const rateLimitHit = res.status === 403 || res.status === 429;+ if (rateLimitHit) {+ console.error("GitHub REST API rate limit hit. Waiting 1 minute...");+ await new Promise((resolve) => {+ setTimeout(resolve, 60 * 1000);+ });+ return fetchPageViaRest({ repoOrg, repoName, page, abortSignal });+ }++ const json = (await res.json()) as GitHubApiResponse;+ if (!res.ok) {+ throw new Error(`HTTP ${res.status} ${res.statusText} (${url})`);+ }+ return json.map((item) => {+ return {+ avatarUrl: item.user.avatar_url,+ login: item.user.login,+ name: item.user.login,+ date: item.starred_at,+ };+ });+};diff --git a/packages/template-stargazer/src/gh-styles.css b/packages/template-stargazer/src/gh-styles.cssnew file mode 100644index 0000000000..7732b6943e--- /dev/null+++ b/packages/template-stargazer/src/gh-styles.css@@ -0,0 +1,290 @@+.break-word {+ word-break: break-word;+ word-wrap: break-word;+ overflow-wrap: break-word;+}++.text-normal {+ font-weight: 400;+}++.f3 {+ font-size: 20px !important;+}++.octicon-repo {+ width: 0.8em;+ height: 0.8em;+}++.mrx {+ margin-right: 0.4em;+}++.flex-items-center {+ align-items: center !important;+}+.flex-wrap {+ flex-wrap: wrap !important;+}++.flex-self-stretch {+ align-self: stretch !important;+}++.mx-1 {+ margin-right: 4px !important;+ margin-left: 4px !important;+}++.flex-self-stretch {+ align-self: stretch !important;+}+.color-text-secondary {+ color: #586069 !important;+}++.mr-2 {+ margin-right: 8px !important;+}++.flex-self-stretch {+ align-self: stretch !important;+}+b,+strong {+ font-weight: 600;+}++a {+ color: #0366d6;+ text-decoration: none;+}+.d-flex {+ display: flex !important;+}+.flex-items-center {+ align-items: center !important;+}++.flex-wrap {+ flex-wrap: wrap !important;+}+svg:not(:root) {+ overflow: hidden;+}+.mr-2 {+ margin-right: 8px !important;+}+.color-text-secondary {+ color: #586069 !important;+}+.octicon {+ display: inline-block;+ overflow: visible !important;+ vertical-align: text-bottom;+ fill: currentColor;+}++body:not(.full-width) div.application-main main > div.hide-full-screen > * > * {+ margin-left: 0px !important;+}+.mr-3 {+ margin-right: 16px !important;+}+.min-width-0 {+ min-width: 0 !important;+}+.width-fit {+ max-width: 100% !important;+}+.flex-auto {+ flex: auto !important;+}+* {+ box-sizing: border-box;+}+.flex-shrink-0 {+ flex-shrink: 0 !important;+}+.d-md-inline {+ display: inline !important;+}+.pagehead-actions > li:last-child {+ margin-right: 0;+}++.pagehead-actions > li {+ float: left;+ margin: 0 10px 0 0;+ font-size: 11px;+ color: var(--color-text-primary);+ list-style-type: none;+}+.d-block {+ display: block !important;+}+form {+ display: block;+ margin-top: 0em;+}+button {+ cursor: pointer;+ border-radius: 0;+}+button,+input,+select,+textarea {+ font-family: inherit;+ font-size: inherit;+ line-height: inherit;+}+button,+select {+ text-transform: none;+}+button,+input {+ overflow: visible;+}+button,+input,+select,+textarea {+ font: inherit;+ margin: 0;+}+ol,+ul {+ padding-left: 0;+ margin-top: 0;+ margin-bottom: 0;+}+h1 {+ display: block;+ font-size: 2em;+ margin-block-start: 0.67em;+ margin-block-end: 0.67em;+ margin-inline-start: 0px;+ margin-inline-end: 0px;+ font-weight: bold;+}+h1,+h2,+h3,+h4,+h5,+h6 {+ margin-top: 0;+ margin-bottom: 0;+}++.starring-container.on .starred,+.starring-container .unstarred {+ display: block;+}+.btn-sm .octicon {+ vertical-align: text-top;+}+.btn .octicon {+ margin-right: 4px;+ color: var(--color-text-tertiary);+ vertical-align: text-bottom;+}+svg:not(:root) {+ overflow: hidden;+}+.mr-1 {+ margin-right: 4px !important;+}++.social-count {+ position: relative;+ float: left;+ padding: 3px 12px;+ font-size: 12px;+ font-weight: 600;+ line-height: 20px;+ color: var(--color-text-primary);+ vertical-align: middle;+ background-color: var(--color-social-count-bg);+ border: 1px solid var(--color-btn-border);+ border-left: 0;+ border-top-right-radius: 6px;+ border-bottom-right-radius: 6px;+ box-shadow: var(--color-shadow-small), var(--color-shadow-highlight);+ font-variant-numeric: tabular-nums;+}++.btn {+ position: relative;+ display: inline-block;+ padding: 5px 16px;+ font-size: 14px;+ font-weight: 500;+ line-height: 20px;+ white-space: nowrap;+ vertical-align: middle;+ cursor: pointer;+ -webkit-user-select: none;+ -moz-user-select: none;+ -ms-user-select: none;+ user-select: none;+ border: 1px solid;+ border-radius: 6px;+ -webkit-appearance: none;+ -moz-appearance: none;+ appearance: none;+}+.btn {+ color: var(--color-btn-text);+ background-color: var(--color-btn-bg);+ border-color: var(--color-btn-border);+ box-shadow: var(--color-btn-shadow), var(--color-btn-inset-shadow);+ transition: 0.2s cubic-bezier(0.3, 0, 0.5, 1);+ transition-property: color, background-color, border-color;+}+.btn-sm {+ padding: 3px 12px;+ font-size: 12px;+ line-height: 20px;+}+.btn-with-count {+ float: left;+ border-top-right-radius: 0;+ border-bottom-right-radius: 0;+}+.btn .octicon {+ margin-right: 4px;+ color: var(--color-text-tertiary);+ vertical-align: text-bottom;+}+.btn-sm .octicon {+ vertical-align: text-top;+}++body {+ font-family:+ -apple-system,+ BlinkMacSystemFont,+ Segoe UI,+ Arial,+ Noto Sans,+ Noto Sans CJK SC,+ sans-serif,+ Apple Color Emoji,+ Segoe UI Emoji,+ Noto Color Emoji;+ line-height: 1.5;+ --color-text-primary: #24292e;+ --color-text-tertiary: #6a737d;+ --color-social-count-bg: #ffff;+ --color-btn-border: #1b1f2326;+ --color-btn-text: #24292e;+ --color-btn-bg: #fafbfc;+ --color-shadow-small: 0 1px 0 rgba(27, 31, 35, 0.04);+ --color-shadow-highlight: inset 0 1px 0 hsla(0, 0%, 100%, 0.25);+ --color-border-secondary: #ebedef;+ background-color: #f6f8fa;+}diff --git a/packages/template-stargazer/src/index.ts b/packages/template-stargazer/src/index.tsnew file mode 100644index 0000000000..556dae4d83--- /dev/null+++ b/packages/template-stargazer/src/index.ts@@ -0,0 +1,4 @@+import { registerRoot } from "remotion";+import { RemotionVideo } from "./Root";++registerRoot(RemotionVideo);diff --git a/packages/template-stargazer/src/repo-header.tsx b/packages/template-stargazer/src/repo-header.tsxnew file mode 100644index 0000000000..e64d3db486--- /dev/null+++ b/packages/template-stargazer/src/repo-header.tsx@@ -0,0 +1,112 @@+import "./gh-styles.css";++export function RepoHeader({+ stars,+ org,+ name,+}: {+ stars: number;+ org: string;+ name: string;+}) {+ return (+ <div+ className="d-flex mb-3 px-3 px-md-4 px-lg-5"+ style={{+ padding: "16px 24px",+ boxShadow: "inset 0 -1px 0 var(--color-border-secondary)",+ backgroundColor: "white",+ position: "absolute",+ top: 0,+ right: 0,+ left: 0,+ height: 70,+ minHeight: 70,+ maxHeight: 70,+ }}+ >+ <div className="flex-auto min-width-0 width-fit mr-3">+ <h1+ className="d-flex flex-items-center break-word f3 text-normal"+ style={{+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ display: "flex",+ flexDirection: "row",+ flexWrap: "nowrap",+ alignItems: "center",+ }}+ >+ <svg+ className="octicon octicon-repo color-text-secondary mrx"+ viewBox="0 0 16 16"+ width="16"+ height="16"+ style={{+ marginTop: 5,+ }}+ >+ <path+ fillRule="evenodd"+ d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"+ />+ </svg>+ <span className="author flex-self-stretch url fn" itemProp="author">+ <a className="" rel="author">+ {org}+ </a>+ </span>+ <span className="mx-1 flex-self-stretch color-text-secondary">/</span>+ <a+ itemProp="name"+ className="mr-2 flex-self-stretch"+ style={{+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ display: "inline-block",+ fontWeight: 500,+ }}+ >+ {name}+ </a>+ </h1>+ </div>+ <ul+ className="pagehead-actions flex-shrink-0 d-none d-md-inline"+ style={{ padding: "2px 0" }}+ >+ <li>+ <div className="d-block js-toggler-container js-social-container starring-container ">+ <div className="unstarred">+ <div className="btn btn-sm btn-with-count">+ <svg+ aria-hidden="true"+ viewBox="0 0 16 16"+ version="1.1"+ data-view-component="true"+ height="16"+ width="16"+ className="octicon octicon-star mr-1"+ >+ <path+ fillRule="evenodd"+ d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"+ />+ </svg>+ <span data-view-component="true">Star</span>+ </div>{" "}+ <a+ className="social-count"+ style={{ minWidth: 52, textAlign: "center" }}+ >+ {stars}+ </a>+ </div>+ </div>+ </li>+ </ul>+ </div>+ );+}diff --git a/packages/template-stargazer/src/utils.ts b/packages/template-stargazer/src/utils.tsnew file mode 100644index 0000000000..1c42fc871d--- /dev/null+++ b/packages/template-stargazer/src/utils.ts@@ -0,0 +1,96 @@+const { sqrt, exp, sin, cos } = Math;++export function getProgress(+ frame: number,+ totalFrames: number,+ totalStars: number,+ fps: number,+) {+ const table = getTable(totalFrames, totalStars, fps);+ if (frame >= table.length - 1) {+ return totalStars;+ }+ return table[frame][2];+}++function getTable(totalFrames: number, totalStars: number, fps: number) {+ const table = [];+ let px = 0;+ let pv = 0;+ for (let frame = 0; frame < totalFrames; frame++) {+ const target = Math.ceil(+ easeInOutCubic(frame / (totalFrames - 1)) * totalStars,+ );+ const { x, v } = customSpring({+ x0: px,+ v0: pv,+ t0: 0,+ t: 1000 / fps,+ k: 170, // Stiffness+ c: 26, // Damping+ m: 1, // Mass+ X: target,+ });+ px = x;+ pv = v;+ table.push([frame, target, x]);+ }+ return table;+}+function easeInOutCubic(x: number) {+ return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;+}++// From https://github.com/pomber/use-spring/blob/master/src/spring.ts+function customSpring({+ x0,+ v0,+ t0,+ t,+ k,+ c,+ m,+ X,+}: {+ x0: number;+ v0: number;+ t0: number;+ t: number;+ k: number;+ c: number;+ m: number;+ X: number;+}) {+ const dx = x0 - X;+ const dt = (t - t0) / 1000;+ const radicand = c * c - 4 * k * m;+ if (radicand > 0) {+ const rp = (-c + sqrt(radicand)) / (2 * m);+ const rn = (-c - sqrt(radicand)) / (2 * m);+ const a = (dx * rp - v0) / (rp - rn);+ const b = (v0 - dx * rn) / (rp - rn);+ return {+ x: X + a * exp(rn * dt) + b * exp(rp * dt),+ v: a * rn * exp(rn * dt) + b * rp * exp(rp * dt),+ };+ }+ if (radicand < 0) {+ const r = -c / (2 * m);+ const s = sqrt(-radicand) / (2 * m);+ const a = dx;+ const b = (v0 - r * dx) / s;+ return {+ x: X + exp(r * dt) * (a * cos(s * dt) + b * sin(s * dt)),+ v:+ exp(r * dt) *+ ((b * s + a * r) * cos(s * dt) - (a * s - b * r) * sin(s * dt)),+ };+ }+ const r = -c / (2 * m);+ const a = dx;+ const b = v0 - r * dx;+ return {+ x: X + (a + b * dt) * exp(r * dt),+ v: (b + a * r + b * r * dt) * exp(r * dt),+ };+}diff --git a/packages/template-stargazer/src/wait-for-no-input.ts b/packages/template-stargazer/src/wait-for-no-input.tsnew file mode 100644index 0000000000..7d30a2dfaf--- /dev/null+++ b/packages/template-stargazer/src/wait-for-no-input.ts@@ -0,0 +1,25 @@+import { getRemotionEnvironment } from "remotion";++export const waitForNoInput = (signal: AbortSignal, ms: number) => {+ // Don't wait during rendering+ if (getRemotionEnvironment().isRendering) {+ return Promise.resolve();+ }++ if (signal.aborted) {+ return Promise.reject(new Error("stale"));+ }++ return Promise.race<void>([+ new Promise<void>((_, reject) => {+ signal.addEventListener("abort", () => {+ reject(new Error("stale"));+ });+ }),+ new Promise<void>((resolve) => {+ setTimeout(() => {+ resolve();+ }, ms);+ }),+ ]);+};diff --git a/packages/template-stargazer/tsconfig.json b/packages/template-stargazer/tsconfig.jsonnew file mode 100644index 0000000000..900990487a--- /dev/null+++ b/packages/template-stargazer/tsconfig.json@@ -0,0 +1,16 @@+{+ "compilerOptions": {+ "target": "ES2018",+ "module": "commonjs",+ "jsx": "react-jsx",+ "outDir": "./dist",+ "strict": true,+ "noEmit": true,+ "lib": ["es2015", "DOM"],+ "esModuleInterop": true,+ "skipLibCheck": true,+ "forceConsistentCasingInFileNames": true,+ "strictNullChecks": true,+ "noUnusedLocals": true+ }+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 99c33a0886..f9fa6f85bf 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -2212,6 +2212,46 @@ importers:specifier: 5.6.2version: 5.6.2+ packages/template-stargazer:+ dependencies:+ '@remotion/bundler':+ specifier: workspace:*+ version: link:../bundler+ '@remotion/cli':+ specifier: workspace:*+ version: link:../cli+ '@remotion/renderer':+ specifier: workspace:*+ version: link:../renderer+ react:+ specifier: 18.3.1+ version: 18.3.1+ react-dom:+ specifier: 18.3.1+ version: 18.3.1([email protected])+ remotion:+ specifier: workspace:*+ version: link:../core+ zod:+ specifier: 3.22.3+ version: 3.22.3+ devDependencies:+ '@remotion/eslint-config':+ specifier: workspace:*+ version: link:../eslint-config+ '@types/react':+ specifier: 18.3.1+ version: 18.3.1+ eslint:+ specifier: 8.56.0+ version: 8.56.0+ prettier:+ specifier: 3.3.3+ version: 3.3.3+ typescript:+ specifier: 5.6.2+ version: 5.6.2+packages/template-still:dependencies:'@aws-sdk/client-s3':diff --git a/tsconfig.json b/tsconfig.jsonindex 977fe556b5..8fb92b4a19 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -159,6 +159,9 @@{"path": "./packages/template-audiogram"},+ {+ "path": "./packages/template-stargazer"+ },{"path": "./packages/studio"},