@remotion/lambda 3.1.8 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,11 +43,11 @@ const makeLayerPublic = async () => {
43
43
  const { Version, LayerArn } = await (0, aws_clients_1.getLambdaClient)(region).send(new client_lambda_1.PublishLayerVersionCommand({
44
44
  Content: {
45
45
  S3Bucket: 'remotionlambda-binaries-' + region,
46
- S3Key: `remotion-layer-${layer}-v6-${architecture}.zip`,
46
+ S3Key: `remotion-layer-${layer}-v7-${architecture}.zip`,
47
47
  },
48
48
  LayerName: layerName,
49
49
  LicenseInfo: layer === 'chromium'
50
- ? 'Chromium 101, compiled from source. Read Chromium License: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/LICENSE'
50
+ ? 'Chromium 104, compiled from source. Read Chromium License: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/LICENSE'
51
51
  : layer === 'ffmpeg'
52
52
  ? 'Compiled from FFMPEG source. Read FFMPEG license: https://ffmpeg.org/legal.html'
53
53
  : 'Contains Noto Sans font. Read Noto Sans License: https://fonts.google.com/noto/specimen/Noto+Sans/about',
@@ -31,6 +31,11 @@ const presignUrl = async ({ region, bucketName, objectKey, checkIfObjectExists =
31
31
  if (err.name === 'NotFound') {
32
32
  return null;
33
33
  }
34
+ if (err.message === 'UnknownError' ||
35
+ err.$metadata
36
+ .httpStatusCode === 403) {
37
+ throw new Error(`Unable to access item "${objectKey}" from bucket "${bucketName}". You must have permission for both "s3:GetObject" and "s3:ListBucket" actions.`);
38
+ }
34
39
  throw err;
35
40
  }
36
41
  }
@@ -27,45 +27,54 @@ const validate_serveurl_1 = require("../shared/validate-serveurl");
27
27
  * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
28
28
  */
29
29
  const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec, imageFormat, crf, envVariables, pixelFormat, proResProfile, quality, region, maxRetries, composition, framesPerLambda, privacy, logLevel, frameRange, outName, timeoutInMilliseconds, chromiumOptions, scale, numberOfGifLoops, everyNthFrame, concurrencyPerLambda, downloadBehavior, }) => {
30
+ var _a;
30
31
  const actualCodec = (0, validate_lambda_codec_1.validateLambdaCodec)(codec);
31
32
  (0, validate_serveurl_1.validateServeUrl)(serveUrl);
32
33
  (0, validate_frames_per_lambda_1.validateFramesPerLambda)(framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null);
33
34
  (0, validate_download_behavior_1.validateDownloadBehavior)(downloadBehavior);
34
35
  const realServeUrl = await (0, convert_to_serve_url_1.convertToServeUrl)(serveUrl, region);
35
- const res = await (0, call_lambda_1.callLambda)({
36
- functionName,
37
- type: constants_1.LambdaRoutines.start,
38
- payload: {
39
- framesPerLambda: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
40
- composition,
41
- serveUrl: realServeUrl,
42
- inputProps,
43
- codec: actualCodec,
44
- imageFormat,
45
- crf,
46
- envVariables,
47
- pixelFormat,
48
- proResProfile,
49
- quality,
50
- maxRetries,
51
- privacy,
52
- logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
53
- frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
54
- outName: outName !== null && outName !== void 0 ? outName : null,
55
- timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
56
- chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
57
- scale: scale !== null && scale !== void 0 ? scale : 1,
58
- everyNthFrame: everyNthFrame !== null && everyNthFrame !== void 0 ? everyNthFrame : 1,
59
- numberOfGifLoops: numberOfGifLoops !== null && numberOfGifLoops !== void 0 ? numberOfGifLoops : 0,
60
- concurrencyPerLambda: concurrencyPerLambda !== null && concurrencyPerLambda !== void 0 ? concurrencyPerLambda : 1,
61
- downloadBehavior: downloadBehavior !== null && downloadBehavior !== void 0 ? downloadBehavior : { type: 'play-in-browser' },
62
- },
63
- region,
64
- });
65
- return {
66
- renderId: res.renderId,
67
- bucketName: res.bucketName,
68
- };
36
+ try {
37
+ const res = await (0, call_lambda_1.callLambda)({
38
+ functionName,
39
+ type: constants_1.LambdaRoutines.start,
40
+ payload: {
41
+ framesPerLambda: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
42
+ composition,
43
+ serveUrl: realServeUrl,
44
+ inputProps,
45
+ codec: actualCodec,
46
+ imageFormat,
47
+ crf,
48
+ envVariables,
49
+ pixelFormat,
50
+ proResProfile,
51
+ quality,
52
+ maxRetries,
53
+ privacy,
54
+ logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
55
+ frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
56
+ outName: outName !== null && outName !== void 0 ? outName : null,
57
+ timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
58
+ chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
59
+ scale: scale !== null && scale !== void 0 ? scale : 1,
60
+ everyNthFrame: everyNthFrame !== null && everyNthFrame !== void 0 ? everyNthFrame : 1,
61
+ numberOfGifLoops: numberOfGifLoops !== null && numberOfGifLoops !== void 0 ? numberOfGifLoops : 0,
62
+ concurrencyPerLambda: concurrencyPerLambda !== null && concurrencyPerLambda !== void 0 ? concurrencyPerLambda : 1,
63
+ downloadBehavior: downloadBehavior !== null && downloadBehavior !== void 0 ? downloadBehavior : { type: 'play-in-browser' },
64
+ },
65
+ region,
66
+ });
67
+ return {
68
+ renderId: res.renderId,
69
+ bucketName: res.bucketName,
70
+ };
71
+ }
72
+ catch (err) {
73
+ if ((_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('UnrecognizedClientException')) {
74
+ throw new Error('UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception');
75
+ }
76
+ throw err;
77
+ }
69
78
  };
70
79
  exports.renderMediaOnLambda = renderMediaOnLambda;
71
80
  /**
@@ -21,36 +21,45 @@ const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
21
21
  * @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
22
22
  */
23
23
  const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, }) => {
24
+ var _a;
24
25
  const realServeUrl = await (0, convert_to_serve_url_1.convertToServeUrl)(serveUrl, region);
25
- const res = await (0, call_lambda_1.callLambda)({
26
- functionName,
27
- type: constants_1.LambdaRoutines.still,
28
- payload: {
29
- composition,
30
- serveUrl: realServeUrl,
31
- inputProps,
32
- imageFormat,
33
- envVariables,
34
- quality,
35
- maxRetries: maxRetries !== null && maxRetries !== void 0 ? maxRetries : constants_1.DEFAULT_MAX_RETRIES,
36
- frame: frame !== null && frame !== void 0 ? frame : 0,
37
- privacy,
38
- attempt: 1,
39
- logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
40
- outName: outName !== null && outName !== void 0 ? outName : null,
41
- timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
42
- chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
43
- scale: scale !== null && scale !== void 0 ? scale : 1,
44
- downloadBehavior: downloadBehavior !== null && downloadBehavior !== void 0 ? downloadBehavior : { type: 'play-in-browser' },
45
- },
46
- region,
47
- });
48
- return {
49
- estimatedPrice: res.estimatedPrice,
50
- url: res.output,
51
- sizeInBytes: res.size,
52
- bucketName: res.bucketName,
53
- renderId: res.renderId,
54
- };
26
+ try {
27
+ const res = await (0, call_lambda_1.callLambda)({
28
+ functionName,
29
+ type: constants_1.LambdaRoutines.still,
30
+ payload: {
31
+ composition,
32
+ serveUrl: realServeUrl,
33
+ inputProps,
34
+ imageFormat,
35
+ envVariables,
36
+ quality,
37
+ maxRetries: maxRetries !== null && maxRetries !== void 0 ? maxRetries : constants_1.DEFAULT_MAX_RETRIES,
38
+ frame: frame !== null && frame !== void 0 ? frame : 0,
39
+ privacy,
40
+ attempt: 1,
41
+ logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
42
+ outName: outName !== null && outName !== void 0 ? outName : null,
43
+ timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
44
+ chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
45
+ scale: scale !== null && scale !== void 0 ? scale : 1,
46
+ downloadBehavior: downloadBehavior !== null && downloadBehavior !== void 0 ? downloadBehavior : { type: 'play-in-browser' },
47
+ },
48
+ region,
49
+ });
50
+ return {
51
+ estimatedPrice: res.estimatedPrice,
52
+ url: res.output,
53
+ sizeInBytes: res.size,
54
+ bucketName: res.bucketName,
55
+ renderId: res.renderId,
56
+ };
57
+ }
58
+ catch (err) {
59
+ if ((_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('UnrecognizedClientException')) {
60
+ throw new Error('UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception');
61
+ }
62
+ throw err;
63
+ }
55
64
  };
56
65
  exports.renderStillOnLambda = renderStillOnLambda;
@@ -41,7 +41,13 @@ const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata
41
41
  const renderSize = contents
42
42
  .map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
43
43
  .reduce((a, b) => a + b, 0);
44
- const { timeToInvokeLambdas } = (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)(contents, renderId, renderMetadata.startedDate);
44
+ const { timeToInvokeLambdas } = (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)({
45
+ contents,
46
+ renderId,
47
+ estimatedRenderLambdaInvokations: renderMetadata.estimatedRenderLambdaInvokations,
48
+ startDate: renderMetadata.startedDate,
49
+ checkIfAllLambdasWereInvoked: false,
50
+ });
45
51
  const retriesInfo = (0, get_retry_stats_1.getRetryStats)({ contents, renderId });
46
52
  if (timeToInvokeLambdas === null) {
47
53
  throw new Error('should have timing for all lambdas');
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findOutputFileInBucket = void 0;
4
4
  const client_s3_1 = require("@aws-sdk/client-s3");
5
+ const suggested_policy_1 = require("../../api/iam-validation/suggested-policy");
5
6
  const aws_clients_1 = require("../../shared/aws-clients");
6
7
  const expected_out_name_1 = require("./expected-out-name");
7
8
  const get_output_url_from_metadata_1 = require("./get-output-url-from-metadata");
@@ -26,6 +27,11 @@ const findOutputFileInBucket = async ({ region, renderMetadata, bucketName, }) =
26
27
  if (err.name === 'NotFound') {
27
28
  return null;
28
29
  }
30
+ if (err.message === 'UnknownError' ||
31
+ err.$metadata
32
+ .httpStatusCode === 403) {
33
+ throw new Error(`Unable to access item "${expectedOutData.key}" from bucket "${expectedOutData.renderBucketName}". The "${suggested_policy_1.ROLE_NAME}" role must have permission for both "s3:GetObject" and "s3:ListBucket" actions.`);
34
+ }
29
35
  throw err;
30
36
  }
31
37
  };
@@ -3,4 +3,10 @@ export declare type LambdaInvokeStats = {
3
3
  timeToInvokeLambdas: number | null;
4
4
  lambdasInvoked: number;
5
5
  };
6
- export declare const getLambdasInvokedStats: (contents: _Object[], renderId: string, startDate: number | null) => LambdaInvokeStats;
6
+ export declare const getLambdasInvokedStats: ({ contents, renderId, estimatedRenderLambdaInvokations, startDate, checkIfAllLambdasWereInvoked, }: {
7
+ contents: _Object[];
8
+ renderId: string;
9
+ estimatedRenderLambdaInvokations: number | null;
10
+ startDate: number | null;
11
+ checkIfAllLambdasWereInvoked: boolean;
12
+ }) => LambdaInvokeStats;
@@ -2,11 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLambdasInvokedStats = void 0;
4
4
  const constants_1 = require("../../shared/constants");
5
+ const parse_lambda_initialized_key_1 = require("../../shared/parse-lambda-initialized-key");
5
6
  const min_max_1 = require("./min-max");
6
- const getLambdasInvokedStats = (contents, renderId, startDate) => {
7
+ const getLambdasInvokedStats = ({ contents, renderId, estimatedRenderLambdaInvokations, startDate, checkIfAllLambdasWereInvoked, }) => {
7
8
  var _a;
8
- const lambdasInvoked = contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaInitializedPrefix)(renderId)); });
9
- const timeToInvokeLambdas = startDate === null
9
+ const lambdasInvoked = contents
10
+ .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaInitializedPrefix)(renderId)); })
11
+ .filter((c) => (0, parse_lambda_initialized_key_1.parseLambdaInitializedKey)(c.Key).attempt === 1);
12
+ const allLambdasInvoked = !checkIfAllLambdasWereInvoked ||
13
+ lambdasInvoked.length === estimatedRenderLambdaInvokations;
14
+ const timeToInvokeLambdas = !allLambdasInvoked || startDate === null
10
15
  ? null
11
16
  : ((_a = (0, min_max_1.max)(lambdasInvoked.map((l) => { var _a; return (_a = l.LastModified) === null || _a === void 0 ? void 0 : _a.getTime(); }))) !== null && _a !== void 0 ? _a : 0) - startDate;
12
17
  return {
@@ -23,7 +23,7 @@ const get_time_to_finish_1 = require("./get-time-to-finish");
23
23
  const inspect_errors_1 = require("./inspect-errors");
24
24
  const io_1 = require("./io");
25
25
  const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region, memorySizeInMb, timeoutInMiliseconds, }) => {
26
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
27
27
  const postRenderData = await (0, get_post_render_data_1.getPostRenderData)({
28
28
  bucketName,
29
29
  region,
@@ -135,7 +135,13 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
135
135
  const renderSize = contents
136
136
  .map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
137
137
  .reduce((a, b) => a + b, 0);
138
- const lambdasInvokedStats = (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)(contents, renderId, (_g = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.startedDate) !== null && _g !== void 0 ? _g : null);
138
+ const lambdasInvokedStats = (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)({
139
+ contents,
140
+ renderId,
141
+ estimatedRenderLambdaInvokations: (_g = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.estimatedRenderLambdaInvokations) !== null && _g !== void 0 ? _g : null,
142
+ startDate: (_h = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.startedDate) !== null && _h !== void 0 ? _h : null,
143
+ checkIfAllLambdasWereInvoked: true,
144
+ });
139
145
  const retriesInfo = (0, get_retry_stats_1.getRetryStats)({
140
146
  contents,
141
147
  renderId,
@@ -147,7 +153,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
147
153
  lambdaInvokeStatus: lambdasInvokedStats,
148
154
  });
149
155
  const chunkCount = outputFile
150
- ? (_h = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _h !== void 0 ? _h : 0
156
+ ? (_j = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _j !== void 0 ? _j : 0
151
157
  : chunks.length;
152
158
  // We add a 20 second buffer for it, since AWS timeshifts can be quite a lot. Once it's 20sec over the limit, we consider it timed out
153
159
  const isBeyondTimeout = renderMetadata &&
@@ -178,7 +184,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
178
184
  renderId,
179
185
  renderMetadata,
180
186
  bucket: bucketName,
181
- outputFile: (_j = outputFile === null || outputFile === void 0 ? void 0 : outputFile.url) !== null && _j !== void 0 ? _j : null,
187
+ outputFile: (_k = outputFile === null || outputFile === void 0 ? void 0 : outputFile.url) !== null && _k !== void 0 ? _k : null,
182
188
  timeToFinish,
183
189
  errors: allErrors,
184
190
  fatalErrorEncountered: allErrors.some((f) => f.isFatal && !f.willRetry),
@@ -193,7 +199,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
193
199
  type: 'absolute-time',
194
200
  })
195
201
  : null,
196
- timeToInvokeLambdas: (_k = encodingStatus === null || encodingStatus === void 0 ? void 0 : encodingStatus.timeToInvoke) !== null && _k !== void 0 ? _k : lambdasInvokedStats.timeToInvokeLambdas,
202
+ timeToInvokeLambdas: (_l = encodingStatus === null || encodingStatus === void 0 ? void 0 : encodingStatus.timeToInvoke) !== null && _l !== void 0 ? _l : lambdasInvokedStats.timeToInvokeLambdas,
197
203
  overallProgress: (0, get_overall_progress_1.getOverallProgress)({
198
204
  cleanup: cleanup ? cleanup.filesDeleted / cleanup.minFilesToDelete : 0,
199
205
  encoding: finalEncodingStatus && renderMetadata
@@ -39,6 +39,27 @@ const timer_1 = require("./helpers/timer");
39
39
  const validate_composition_1 = require("./helpers/validate-composition");
40
40
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
41
41
  const write_post_render_data_1 = require("./helpers/write-post-render-data");
42
+ const callFunctionWithRetry = async (payload, retries = 0) => {
43
+ try {
44
+ await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
45
+ FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
46
+ // @ts-expect-error
47
+ Payload: JSON.stringify(payload),
48
+ InvocationType: 'Event',
49
+ }), {});
50
+ }
51
+ catch (err) {
52
+ if (err.name === 'ResourceConflictException') {
53
+ if (retries > 10) {
54
+ throw err;
55
+ }
56
+ await new Promise((resolve) => {
57
+ setTimeout(resolve, 1000);
58
+ });
59
+ return callFunctionWithRetry(payload, retries + 1);
60
+ }
61
+ }
62
+ };
42
63
  const innerLaunchHandler = async (params, options) => {
43
64
  var _a, _b;
44
65
  if (params.type !== constants_1.LambdaRoutines.launch) {
@@ -167,12 +188,7 @@ const innerLaunchHandler = async (params, options) => {
167
188
  });
168
189
  await Promise.all(lambdaPayloads.map(async (payload, index) => {
169
190
  const callingLambdaTimer = (0, timer_1.timer)('Calling chunk ' + index);
170
- await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
171
- FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
172
- // @ts-expect-error
173
- Payload: JSON.stringify(payload),
174
- InvocationType: 'Event',
175
- }), {});
191
+ await callFunctionWithRetry(payload);
176
192
  callingLambdaTimer.end();
177
193
  }));
178
194
  reqSend.end();
@@ -295,7 +311,13 @@ const innerLaunchHandler = async (params, options) => {
295
311
  framesEncoded: frameCount.length,
296
312
  totalFrames: frameCount.length,
297
313
  doneIn: encodingStop ? encodingStop - encodingStart : null,
298
- timeToInvoke: (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)(contents, params.renderId, renderMetadata.startedDate).timeToInvokeLambdas,
314
+ timeToInvoke: (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)({
315
+ contents,
316
+ renderId: params.renderId,
317
+ estimatedRenderLambdaInvokations: renderMetadata.estimatedRenderLambdaInvokations,
318
+ checkIfAllLambdasWereInvoked: false,
319
+ startDate: renderMetadata.startedDate,
320
+ }).timeToInvokeLambdas,
299
321
  };
300
322
  const finalEncodingProgressProm = (0, io_1.lambdaWriteFile)({
301
323
  bucketName: params.bucketName,
@@ -21,7 +21,7 @@ export declare const COMMAND_NOT_FOUND = "Command not found";
21
21
  export declare const DEFAULT_REGION: AwsRegion;
22
22
  export declare const DEFAULT_MAX_RETRIES = 1;
23
23
  export declare const MAX_FUNCTIONS_PER_RENDER = 200;
24
- export declare const DEFAULT_EPHEMERAL_STORAGE_IN_MB = 512;
24
+ export declare const DEFAULT_EPHEMERAL_STORAGE_IN_MB = 2048;
25
25
  export declare const MIN_EPHEMERAL_STORAGE_IN_MB = 512;
26
26
  export declare const MAX_EPHEMERAL_STORAGE_IN_MB = 10240;
27
27
  export declare const DEFAULT_OUTPUT_PRIVACY: Privacy;
@@ -224,7 +224,7 @@ export declare type RenderMetadata = {
224
224
  renderId: string;
225
225
  outName: OutNameInput | undefined;
226
226
  };
227
- export declare type LambdaVersions = '2022-07-28' | '2022-07-27' | '2022-07-25' | '2022-07-23' | '2022-07-20' | '2022-07-18' | '2022-07-15' | '2022-07-14' | '2022-07-12' | '2022-07-10' | '2022-07-09' | '2022-07-08' | '2022-07-04' | '2022-06-30' | '2022-06-29' | '2022-06-25' | '2022-06-22' | '2022-06-21' | '2022-06-14' | '2022-06-08' | '2022-06-07' | '2022-06-02' | '2022-05-31' | '2022-05-28' | '2022-05-27' | '2022-05-19' | '2022-05-16' | '2022-05-11' | '2022-05-07' | '2022-05-06' | '2022-05-03' | '2022-04-20' | '2022-04-19' | '2022-04-18' | '2022-04-09' | '2022-04-08' | '2022-04-05' | '2022-04-02' | '2022-03-29' | '2022-03-17' | '2022-03-02' | '2022-03-01' | '2022-02-27' | '2022-02-14' | '2022-02-12' | '2022-02-09' | '2022-02-08' | '2022-02-07' | '2022-02-06' | '2022-02-05' | '2022-02-04' | '2022-02-03' | '2022-01-23' | '2022-01-19' | '2022-01-11' | '2022-01-10' | '2022-01-09' | '2022-01-06' | '2022-01-05' | '2021-12-22' | '2021-12-17' | '2021-12-16' | '2021-12-15' | '2021-12-14' | '2021-12-13' | '2021-12-11' | '2021-12-10' | '2021-12-04' | '2021-11-29' | '2021-11-27' | '2021-11-24' | '2021-11-22' | '2021-11-19' | '2021-11-18' | '2021-11-15' | '2021-11-12' | '2021-11-10' | '2021-11-01' | '2021-10-29' | '2021-10-27' | '2021-10-21' | '2021-10-19' | '2021-10-07' | '2021-10-03' | '2021-10-01' | '2021-09-15' | '2021-09-06' | '2021-08-06' | '2021-07-14' | '2021-07-05' | '2021-07-02' | '2021-06-23' | 'n/a';
227
+ export declare type LambdaVersions = '2022-08-08' | '2022-08-04' | '2022-08-02' | '2022-08-01' | '2022-07-28' | '2022-07-27' | '2022-07-25' | '2022-07-23' | '2022-07-20' | '2022-07-18' | '2022-07-15' | '2022-07-14' | '2022-07-12' | '2022-07-10' | '2022-07-09' | '2022-07-08' | '2022-07-04' | '2022-06-30' | '2022-06-29' | '2022-06-25' | '2022-06-22' | '2022-06-21' | '2022-06-14' | '2022-06-08' | '2022-06-07' | '2022-06-02' | '2022-05-31' | '2022-05-28' | '2022-05-27' | '2022-05-19' | '2022-05-16' | '2022-05-11' | '2022-05-07' | '2022-05-06' | '2022-05-03' | '2022-04-20' | '2022-04-19' | '2022-04-18' | '2022-04-09' | '2022-04-08' | '2022-04-05' | '2022-04-02' | '2022-03-29' | '2022-03-17' | '2022-03-02' | '2022-03-01' | '2022-02-27' | '2022-02-14' | '2022-02-12' | '2022-02-09' | '2022-02-08' | '2022-02-07' | '2022-02-06' | '2022-02-05' | '2022-02-04' | '2022-02-03' | '2022-01-23' | '2022-01-19' | '2022-01-11' | '2022-01-10' | '2022-01-09' | '2022-01-06' | '2022-01-05' | '2021-12-22' | '2021-12-17' | '2021-12-16' | '2021-12-15' | '2021-12-14' | '2021-12-13' | '2021-12-11' | '2021-12-10' | '2021-12-04' | '2021-11-29' | '2021-11-27' | '2021-11-24' | '2021-11-22' | '2021-11-19' | '2021-11-18' | '2021-11-15' | '2021-11-12' | '2021-11-10' | '2021-11-01' | '2021-10-29' | '2021-10-27' | '2021-10-21' | '2021-10-19' | '2021-10-07' | '2021-10-03' | '2021-10-01' | '2021-09-15' | '2021-09-06' | '2021-08-06' | '2021-07-14' | '2021-07-05' | '2021-07-02' | '2021-06-23' | 'n/a';
228
228
  export declare const CURRENT_VERSION: LambdaVersions;
229
229
  export declare type PostRenderData = {
230
230
  cost: {
@@ -15,7 +15,7 @@ exports.COMMAND_NOT_FOUND = 'Command not found';
15
15
  exports.DEFAULT_REGION = 'us-east-1';
16
16
  exports.DEFAULT_MAX_RETRIES = 1;
17
17
  exports.MAX_FUNCTIONS_PER_RENDER = 200;
18
- exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = 512;
18
+ exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = 2048;
19
19
  exports.MIN_EPHEMERAL_STORAGE_IN_MB = 512;
20
20
  exports.MAX_EPHEMERAL_STORAGE_IN_MB = 10240;
21
21
  exports.DEFAULT_OUTPUT_PRIVACY = 'public';
@@ -84,6 +84,6 @@ var LambdaRoutines;
84
84
  LambdaRoutines["renderer"] = "renderer";
85
85
  LambdaRoutines["still"] = "still";
86
86
  })(LambdaRoutines = exports.LambdaRoutines || (exports.LambdaRoutines = {}));
87
- exports.CURRENT_VERSION = '2022-07-28';
87
+ exports.CURRENT_VERSION = '2022-08-08';
88
88
  exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = 'L-B99A9384';
89
89
  exports.LAMBDA_BURST_LIMIT_QUOTA = 'L-548AE339';
@@ -7,141 +7,141 @@ exports.hostedLayers = {
7
7
  'ap-northeast-1': [
8
8
  {
9
9
  layerArn: 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-fonts-arm64',
10
- version: 1,
10
+ version: 2,
11
11
  },
12
12
  {
13
13
  layerArn: 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-ffmpeg-arm64',
14
- version: 5,
14
+ version: 6,
15
15
  },
16
16
  {
17
17
  layerArn: 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-chromium-arm64',
18
- version: 5,
18
+ version: 6,
19
19
  },
20
20
  ],
21
21
  'ap-south-1': [
22
22
  {
23
23
  layerArn: 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-fonts-arm64',
24
- version: 1,
24
+ version: 2,
25
25
  },
26
26
  {
27
27
  layerArn: 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-ffmpeg-arm64',
28
- version: 5,
28
+ version: 6,
29
29
  },
30
30
  {
31
31
  layerArn: 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-chromium-arm64',
32
- version: 5,
32
+ version: 6,
33
33
  },
34
34
  ],
35
35
  'ap-southeast-1': [
36
36
  {
37
37
  layerArn: 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-fonts-arm64',
38
- version: 1,
38
+ version: 2,
39
39
  },
40
40
  {
41
41
  layerArn: 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-ffmpeg-arm64',
42
- version: 5,
42
+ version: 6,
43
43
  },
44
44
  {
45
45
  layerArn: 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-chromium-arm64',
46
- version: 5,
46
+ version: 6,
47
47
  },
48
48
  ],
49
49
  'ap-southeast-2': [
50
50
  {
51
51
  layerArn: 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-fonts-arm64',
52
- version: 1,
52
+ version: 2,
53
53
  },
54
54
  {
55
55
  layerArn: 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-ffmpeg-arm64',
56
- version: 5,
56
+ version: 6,
57
57
  },
58
58
  {
59
59
  layerArn: 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-chromium-arm64',
60
- version: 5,
60
+ version: 6,
61
61
  },
62
62
  ],
63
63
  'eu-central-1': [
64
64
  {
65
65
  layerArn: 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-fonts-arm64',
66
- version: 1,
66
+ version: 2,
67
67
  },
68
68
  {
69
69
  layerArn: 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-ffmpeg-arm64',
70
- version: 5,
70
+ version: 6,
71
71
  },
72
72
  {
73
73
  layerArn: 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-chromium-arm64',
74
- version: 5,
74
+ version: 6,
75
75
  },
76
76
  ],
77
77
  'eu-west-1': [
78
78
  {
79
79
  layerArn: 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-fonts-arm64',
80
- version: 1,
80
+ version: 2,
81
81
  },
82
82
  {
83
83
  layerArn: 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-ffmpeg-arm64',
84
- version: 5,
84
+ version: 6,
85
85
  },
86
86
  {
87
87
  layerArn: 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-chromium-arm64',
88
- version: 5,
88
+ version: 6,
89
89
  },
90
90
  ],
91
91
  'eu-west-2': [
92
92
  {
93
93
  layerArn: 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-fonts-arm64',
94
- version: 1,
94
+ version: 2,
95
95
  },
96
96
  {
97
97
  layerArn: 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-ffmpeg-arm64',
98
- version: 5,
98
+ version: 6,
99
99
  },
100
100
  {
101
101
  layerArn: 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-chromium-arm64',
102
- version: 5,
102
+ version: 6,
103
103
  },
104
104
  ],
105
105
  'us-east-1': [
106
106
  {
107
107
  layerArn: 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-fonts-arm64',
108
- version: 1,
108
+ version: 2,
109
109
  },
110
110
  {
111
111
  layerArn: 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-ffmpeg-arm64',
112
- version: 9,
112
+ version: 10,
113
113
  },
114
114
  {
115
115
  layerArn: 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-chromium-arm64',
116
- version: 9,
116
+ version: 10,
117
117
  },
118
118
  ],
119
119
  'us-east-2': [
120
120
  {
121
121
  layerArn: 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-fonts-arm64',
122
- version: 1,
122
+ version: 2,
123
123
  },
124
124
  {
125
125
  layerArn: 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-ffmpeg-arm64',
126
- version: 5,
126
+ version: 6,
127
127
  },
128
128
  {
129
129
  layerArn: 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-chromium-arm64',
130
- version: 5,
130
+ version: 6,
131
131
  },
132
132
  ],
133
133
  'us-west-2': [
134
134
  {
135
135
  layerArn: 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-fonts-arm64',
136
- version: 1,
136
+ version: 2,
137
137
  },
138
138
  {
139
139
  layerArn: 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-ffmpeg-arm64',
140
- version: 5,
140
+ version: 6,
141
141
  },
142
142
  {
143
143
  layerArn: 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-chromium-arm64',
144
- version: 5,
144
+ version: 6,
145
145
  },
146
146
  ],
147
147
  },
@@ -149,141 +149,141 @@ exports.hostedLayers = {
149
149
  'ap-northeast-1': [
150
150
  {
151
151
  layerArn: 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-fonts-x86_64',
152
- version: 1,
152
+ version: 2,
153
153
  },
154
154
  {
155
155
  layerArn: 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
156
- version: 5,
156
+ version: 6,
157
157
  },
158
158
  {
159
159
  layerArn: 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-chromium-x86_64',
160
- version: 5,
160
+ version: 6,
161
161
  },
162
162
  ],
163
163
  'ap-south-1': [
164
164
  {
165
165
  layerArn: 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-fonts-x86_64',
166
- version: 1,
166
+ version: 2,
167
167
  },
168
168
  {
169
169
  layerArn: 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
170
- version: 5,
170
+ version: 6,
171
171
  },
172
172
  {
173
173
  layerArn: 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-chromium-x86_64',
174
- version: 5,
174
+ version: 6,
175
175
  },
176
176
  ],
177
177
  'ap-southeast-1': [
178
178
  {
179
179
  layerArn: 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-fonts-x86_64',
180
- version: 1,
180
+ version: 2,
181
181
  },
182
182
  {
183
183
  layerArn: 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
184
- version: 5,
184
+ version: 6,
185
185
  },
186
186
  {
187
187
  layerArn: 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-chromium-x86_64',
188
- version: 5,
188
+ version: 6,
189
189
  },
190
190
  ],
191
191
  'ap-southeast-2': [
192
192
  {
193
193
  layerArn: 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-fonts-x86_64',
194
- version: 1,
194
+ version: 2,
195
195
  },
196
196
  {
197
197
  layerArn: 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
198
- version: 5,
198
+ version: 6,
199
199
  },
200
200
  {
201
201
  layerArn: 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-chromium-x86_64',
202
- version: 5,
202
+ version: 6,
203
203
  },
204
204
  ],
205
205
  'eu-central-1': [
206
206
  {
207
207
  layerArn: 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-fonts-x86_64',
208
- version: 1,
208
+ version: 2,
209
209
  },
210
210
  {
211
211
  layerArn: 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
212
- version: 5,
212
+ version: 6,
213
213
  },
214
214
  {
215
215
  layerArn: 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-chromium-x86_64',
216
- version: 5,
216
+ version: 6,
217
217
  },
218
218
  ],
219
219
  'eu-west-1': [
220
220
  {
221
221
  layerArn: 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-fonts-x86_64',
222
- version: 1,
222
+ version: 2,
223
223
  },
224
224
  {
225
225
  layerArn: 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
226
- version: 5,
226
+ version: 6,
227
227
  },
228
228
  {
229
229
  layerArn: 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-chromium-x86_64',
230
- version: 5,
230
+ version: 6,
231
231
  },
232
232
  ],
233
233
  'eu-west-2': [
234
234
  {
235
235
  layerArn: 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-fonts-x86_64',
236
- version: 1,
236
+ version: 2,
237
237
  },
238
238
  {
239
239
  layerArn: 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
240
- version: 5,
240
+ version: 6,
241
241
  },
242
242
  {
243
243
  layerArn: 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-chromium-x86_64',
244
- version: 5,
244
+ version: 6,
245
245
  },
246
246
  ],
247
247
  'us-east-1': [
248
248
  {
249
249
  layerArn: 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-fonts-x86_64',
250
- version: 1,
250
+ version: 2,
251
251
  },
252
252
  {
253
253
  layerArn: 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
254
- version: 9,
254
+ version: 10,
255
255
  },
256
256
  {
257
257
  layerArn: 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-chromium-x86_64',
258
- version: 9,
258
+ version: 10,
259
259
  },
260
260
  ],
261
261
  'us-east-2': [
262
262
  {
263
263
  layerArn: 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-fonts-x86_64',
264
- version: 1,
264
+ version: 2,
265
265
  },
266
266
  {
267
267
  layerArn: 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
268
- version: 5,
268
+ version: 6,
269
269
  },
270
270
  {
271
271
  layerArn: 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-chromium-x86_64',
272
- version: 5,
272
+ version: 6,
273
273
  },
274
274
  ],
275
275
  'us-west-2': [
276
276
  {
277
277
  layerArn: 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-fonts-x86_64',
278
- version: 1,
278
+ version: 2,
279
279
  },
280
280
  {
281
281
  layerArn: 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-ffmpeg-x86_64',
282
- version: 5,
282
+ version: 6,
283
283
  },
284
284
  {
285
285
  layerArn: 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-chromium-x86_64',
286
- version: 5,
286
+ version: 6,
287
287
  },
288
288
  ],
289
289
  },
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- declare const lambdaCodecs: readonly ["h264-mkv", "h264", "vp8", "mp3", "aac", "wav", "gif"];
1
+ declare const lambdaCodecs: readonly ["h264-mkv", "h264", "vp8", "mp3", "aac", "wav", "gif", "prores"];
2
2
  export declare type LambdaCodec = typeof lambdaCodecs[number];
3
3
  export declare const validateLambdaCodec: (codec: unknown) => LambdaCodec;
4
4
  export {};
@@ -9,6 +9,7 @@ const lambdaCodecs = [
9
9
  'aac',
10
10
  'wav',
11
11
  'gif',
12
+ 'prores',
12
13
  ];
13
14
  const validateLambdaCodec = (codec) => {
14
15
  if (typeof codec !== 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "3.1.8",
3
+ "version": "3.2.0",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -32,12 +32,12 @@
32
32
  "@aws-sdk/client-service-quotas": "3.58.0",
33
33
  "@aws-sdk/lib-storage": "3.58.0",
34
34
  "@aws-sdk/s3-request-presigner": "3.58.0",
35
- "@remotion/bundler": "3.1.8",
36
- "@remotion/cli": "3.1.8",
37
- "@remotion/renderer": "3.1.8",
35
+ "@remotion/bundler": "3.2.0",
36
+ "@remotion/cli": "3.2.0",
37
+ "@remotion/renderer": "3.2.0",
38
38
  "aws-policies": "^1.0.1",
39
39
  "mime-types": "2.1.34",
40
- "remotion": "3.1.8"
40
+ "remotion": "3.2.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=16.8.0",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "57f34a02b0f830053f92af426a6b70b6824f887e"
65
+ "gitHead": "47b188161a9e922a247eaa998e72d37af9137707"
66
66
  }
Binary file
@@ -1,6 +0,0 @@
1
- export declare const formatBytes: (number: number, options?: Intl.NumberFormatOptions & {
2
- locale: string;
3
- bits?: boolean;
4
- binary?: boolean;
5
- signed: boolean;
6
- }) => string;
@@ -1,103 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatBytes = void 0;
4
- const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
5
- const BIBYTE_UNITS = [
6
- 'B',
7
- 'kiB',
8
- 'MiB',
9
- 'GiB',
10
- 'TiB',
11
- 'PiB',
12
- 'EiB',
13
- 'ZiB',
14
- 'YiB',
15
- ];
16
- const BIT_UNITS = [
17
- 'b',
18
- 'kbit',
19
- 'Mbit',
20
- 'Gbit',
21
- 'Tbit',
22
- 'Pbit',
23
- 'Ebit',
24
- 'Zbit',
25
- 'Ybit',
26
- ];
27
- const BIBIT_UNITS = [
28
- 'b',
29
- 'kibit',
30
- 'Mibit',
31
- 'Gibit',
32
- 'Tibit',
33
- 'Pibit',
34
- 'Eibit',
35
- 'Zibit',
36
- 'Yibit',
37
- ];
38
- /*
39
- Formats the given number using `Number#toLocaleString`.
40
- - If locale is a string, the value is expected to be a locale-key (for example: `de`).
41
- - If locale is true, the system default locale is used for translation.
42
- - If no value for locale is specified, the number is returned unmodified.
43
- */
44
- const toLocaleString = (number, locale, options) => {
45
- if (typeof locale === 'string' || Array.isArray(locale)) {
46
- return number.toLocaleString(locale, options);
47
- }
48
- if (locale === true || options !== undefined) {
49
- return number.toLocaleString(undefined, options);
50
- }
51
- return String(number);
52
- };
53
- const formatBytes = (number, options = {
54
- locale: 'en-US',
55
- signed: false,
56
- maximumFractionDigits: 1,
57
- }) => {
58
- if (!Number.isFinite(number)) {
59
- throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
60
- }
61
- options = { bits: false, binary: false, ...options };
62
- const UNITS = options.bits
63
- ? options.binary
64
- ? BIBIT_UNITS
65
- : BIT_UNITS
66
- : options.binary
67
- ? BIBYTE_UNITS
68
- : BYTE_UNITS;
69
- if (options.signed && number === 0) {
70
- return `0 $ {
71
- UNITS[0]
72
- }`;
73
- }
74
- const isNegative = number < 0;
75
- const prefix = isNegative ? '-' : options.signed ? '+' : '';
76
- if (isNegative) {
77
- number = -number;
78
- }
79
- let localeOptions;
80
- if (options.minimumFractionDigits !== undefined) {
81
- localeOptions = {
82
- minimumFractionDigits: options.minimumFractionDigits,
83
- };
84
- }
85
- if (options.maximumFractionDigits !== undefined) {
86
- localeOptions = {
87
- maximumFractionDigits: options.maximumFractionDigits,
88
- ...localeOptions,
89
- };
90
- }
91
- if (number < 1) {
92
- const numString = toLocaleString(number, options.locale, localeOptions);
93
- return prefix + numString + ' ' + UNITS[0];
94
- }
95
- const exponent = Math.min(Math.floor(options.binary
96
- ? Math.log(number) / Math.log(1024)
97
- : Math.log10(number) / 3), UNITS.length - 1);
98
- number /= (options.binary ? 1024 : 1000) ** exponent;
99
- const numberString = toLocaleString(Number(number), options.locale, localeOptions);
100
- const unit = UNITS[exponent];
101
- return prefix + numberString + ' ' + unit;
102
- };
103
- exports.formatBytes = formatBytes;
@@ -1 +0,0 @@
1
- export declare const chunk: <T>(input: T[], size: number) => T[][];
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chunk = void 0;
4
- const chunk = (input, size) => {
5
- return input.reduce((arr, item, idx) => {
6
- return idx % size === 0
7
- ? [...arr, [item]]
8
- : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]];
9
- }, []);
10
- };
11
- exports.chunk = chunk;