🎥 Make videos programmatically with React
progress refactor
Jonny Burger9a56783382d9
diff --git a/packages/lambda/src/functions/helpers/get-cleanup-progress.ts b/packages/lambda/src/functions/helpers/get-cleanup-progress.tsindex 2db788198b..30b8456ba0 100644--- a/packages/lambda/src/functions/helpers/get-cleanup-progress.ts+++ b/packages/lambda/src/functions/helpers/get-cleanup-progress.ts@@ -1,4 +1,5 @@import {_Object} from '@aws-sdk/client-s3';+import {CleanupInfo} from '../../shared/constants';import {getFilesToDelete} from './get-files-to-delete';export const getCleanupProgress = ({@@ -11,11 +12,7 @@ export const getCleanupProgress = ({output: string | null;chunkCount: number;renderId: string;-}): null | {- filesToDelete: number;- filesDeleted: number;- done: boolean;-} => {+}): null | CleanupInfo => {if (output === null) {return null;}diff --git a/packages/lambda/src/functions/index.ts b/packages/lambda/src/functions/index.tsindex 092a9a0b7d..983204dbab 100644--- a/packages/lambda/src/functions/index.ts+++ b/packages/lambda/src/functions/index.ts@@ -5,12 +5,12 @@ import {} from '../shared/constants';import {LambdaReturnValues} from '../shared/return-values';import {fireHandler} from './fire';-import {progressHandler} from './get-progress';import {deleteTmpDir} from './helpers/clean-tmpdir';import {closeBrowser} from './helpers/get-browser-instance';import {getWarm, setWarm} from './helpers/is-warm';import {infoHandler} from './info';import {launchHandler} from './launch';+import {progressHandler} from './progress';import {rendererHandler} from './renderer';import {startHandler} from './start';diff --git a/packages/lambda/src/functions/get-progress.ts b/packages/lambda/src/functions/progress.tssimilarity index 98%rename from packages/lambda/src/functions/get-progress.tsrename to packages/lambda/src/functions/progress.tsindex 02ff2e0610..20343a4fc4 100644--- a/packages/lambda/src/functions/get-progress.ts+++ b/packages/lambda/src/functions/progress.ts@@ -10,6 +10,7 @@ import {outName,RenderMetadata,renderMetadataKey,+ RenderProgress,rendersPrefix,} from '../shared/constants';import {parseLambdaTimingsKey} from '../shared/parse-lambda-timings-key';@@ -52,7 +53,7 @@ const getFinalEncodingStatus = ({export const progressHandler = async (lambdaParams: LambdaPayload,options: Options-) => {+): Promise<RenderProgress> => {if (lambdaParams.type !== LambdaRoutines.status) {throw new TypeError('Expected status type');}@@ -172,7 +173,7 @@ export const progressHandler = async (return {chunks: outputFile ? renderMetadata?.totalChunks ?? 0 : chunks.length,- done: Boolean(output) && cleanup?.done,+ done: Boolean(output && cleanup?.done),encodingStatus: getFinalEncodingStatus({encodingStatus,outputFileExists: Boolean(output),diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex 5fc713ccb0..66a2ca638d 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -202,3 +202,34 @@ export type PostRenderData = {startTime: number;endTime: number;};++type CostsInfo = {+ accruedSoFar: number;+ displayCost: string;+ currency: string;+ disclaimer: string;+};++export type CleanupInfo = {+ done: boolean;+ filesToDelete: number;+ filesDeleted: number;+};++export type RenderProgress = {+ chunks: number;+ done: boolean;+ encodingStatus: EncodingProgress | null;+ costs: CostsInfo;+ renderId: string;+ renderMetadata: RenderMetadata | null;+ bucket: string;+ outputFile: string | null;+ timeToFinish: number | null;+ errors: EnhancedErrorInfo[];+ fatalErrorEncountered: boolean;+ currentTime: number;+ bucketSize: number;+ lambdasInvoked: number;+ cleanup: CleanupInfo | null;+};diff --git a/packages/lambda/src/shared/return-values.ts b/packages/lambda/src/shared/return-values.tsindex 6e532c7acc..d4840c2d01 100644--- a/packages/lambda/src/shared/return-values.ts+++ b/packages/lambda/src/shared/return-values.ts@@ -1,7 +1,7 @@import {fireHandler} from '../functions/fire';-import {progressHandler} from '../functions/get-progress';import {infoHandler} from '../functions/info';import {launchHandler} from '../functions/launch';+import {progressHandler} from '../functions/progress';import {rendererHandler} from '../functions/renderer';import {startHandler} from '../functions/start';import {LambdaRoutines} from './constants';