@remotion/lambda 4.0.36 → 4.0.38

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.
@@ -3,5 +3,8 @@ export declare const planFrameRanges: ({ framesPerLambda, frameRange, everyNthFr
3
3
  frameRange: [number, number];
4
4
  everyNthFrame: number;
5
5
  }) => {
6
- chunks: [number, number][];
6
+ chunks: [
7
+ number,
8
+ number
9
+ ][];
7
10
  };
@@ -4,16 +4,16 @@ declare const streamingPayloadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
4
4
  type: z.ZodLiteral<"render-id-determined">;
5
5
  renderId: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
7
- type: "render-id-determined";
8
7
  renderId: string;
9
- }, {
10
8
  type: "render-id-determined";
9
+ }, {
11
10
  renderId: string;
11
+ type: "render-id-determined";
12
12
  }>]>;
13
13
  export type StreamingPayloads = z.infer<typeof streamingPayloadSchema>;
14
14
  export declare const isStreamingPayload: (str: string) => false | {
15
- type: "render-id-determined";
16
15
  renderId: string;
16
+ type: "render-id-determined";
17
17
  };
18
18
  export declare const sendProgressEvent: (responseStream: ResponseStream, payload: StreamingPayloads) => void;
19
19
  export {};
@@ -0,0 +1,60 @@
1
+ /// <reference types="node" />
2
+ declare const framesRendered: "frames-rendered";
3
+ declare const errorOccurred: "error-occurred";
4
+ declare const renderIdDetermined: "render-id-determined";
5
+ declare const chunkRendered: "chunk-rendered";
6
+ declare const messageTypes: {
7
+ readonly '1': {
8
+ readonly type: "frames-rendered";
9
+ };
10
+ readonly '2': {
11
+ readonly type: "error-occurred";
12
+ };
13
+ readonly '3': {
14
+ readonly type: "render-id-determined";
15
+ };
16
+ readonly '4': {
17
+ readonly type: "chunk-rendered";
18
+ };
19
+ };
20
+ type MessageTypeId = keyof typeof messageTypes;
21
+ type MessageType = (typeof messageTypes)[MessageTypeId]['type'];
22
+ export declare const formatMap: {
23
+ [key in MessageType]: 'json' | 'binary';
24
+ };
25
+ export type StreamingPayload = {
26
+ type: typeof framesRendered;
27
+ payload: {
28
+ frames: number;
29
+ };
30
+ } | {
31
+ type: typeof chunkRendered;
32
+ payload: Buffer;
33
+ } | {
34
+ type: typeof errorOccurred;
35
+ payload: {
36
+ error: string;
37
+ };
38
+ } | {
39
+ type: typeof renderIdDetermined;
40
+ payload: {
41
+ renderId: string;
42
+ };
43
+ };
44
+ export declare const messageTypeIdToMessage: (messageTypeId: MessageTypeId) => MessageType;
45
+ export declare const messageTypeToMessageId: (messageType: MessageType) => MessageTypeId;
46
+ export type OnMessage = (options: {
47
+ successType: 'error' | 'success';
48
+ message: StreamingPayload;
49
+ }) => void;
50
+ export declare const makeStreaming: (options: {
51
+ onMessage: OnMessage;
52
+ }) => {
53
+ addData: (data: Buffer) => void;
54
+ };
55
+ export declare const makePayloadMessage: ({ message, status, }: {
56
+ message: StreamingPayload;
57
+ status: 0 | 1;
58
+ }) => Buffer;
59
+ export type OnStream = (payload: StreamingPayload) => void;
60
+ export {};
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makePayloadMessage = exports.makeStreaming = exports.messageTypeToMessageId = exports.messageTypeIdToMessage = exports.formatMap = void 0;
4
+ const framesRendered = 'frames-rendered';
5
+ const errorOccurred = 'error-occurred';
6
+ const renderIdDetermined = 'render-id-determined';
7
+ const chunkRendered = 'chunk-rendered';
8
+ const messageTypes = {
9
+ '1': { type: framesRendered },
10
+ '2': { type: errorOccurred },
11
+ '3': { type: renderIdDetermined },
12
+ '4': { type: chunkRendered },
13
+ };
14
+ exports.formatMap = {
15
+ [framesRendered]: 'json',
16
+ [errorOccurred]: 'json',
17
+ [renderIdDetermined]: 'json',
18
+ [chunkRendered]: 'binary',
19
+ };
20
+ const messageTypeIdToMessage = (messageTypeId) => {
21
+ const types = messageTypes[messageTypeId];
22
+ if (!types) {
23
+ throw new Error(`Unknown message type id ${messageTypeId}`);
24
+ }
25
+ return types.type;
26
+ };
27
+ exports.messageTypeIdToMessage = messageTypeIdToMessage;
28
+ const messageTypeToMessageId = (messageType) => {
29
+ const id = Object.keys(messageTypes).find((key) => messageTypes[key].type === messageType);
30
+ if (!id) {
31
+ throw new Error(`Unknown message type ${messageType}`);
32
+ }
33
+ return id;
34
+ };
35
+ exports.messageTypeToMessageId = messageTypeToMessageId;
36
+ const magicSeparator = Buffer.from('remotion_buffer:');
37
+ const makeStreaming = (options) => {
38
+ let outputBuffer = Buffer.from('');
39
+ let unprocessedBuffers = [];
40
+ let missingData = null;
41
+ const processInput = () => {
42
+ let separatorIndex = outputBuffer.indexOf(magicSeparator);
43
+ if (separatorIndex === -1) {
44
+ return;
45
+ }
46
+ separatorIndex += magicSeparator.length;
47
+ let messageTypeString = '';
48
+ let lengthString = '';
49
+ let statusString = '';
50
+ // Each message has the structure with `remotion_buffer:{[message_type_id]}:{[length]}`
51
+ // Let's read the buffer to extract the nonce, and if the full length is available,
52
+ // we'll extract the data and pass it to the callback.
53
+ // eslint-disable-next-line no-constant-condition
54
+ while (true) {
55
+ const nextDigit = outputBuffer[separatorIndex];
56
+ // 0x3a is the character ":"
57
+ if (nextDigit === 0x3a) {
58
+ separatorIndex++;
59
+ break;
60
+ }
61
+ separatorIndex++;
62
+ messageTypeString += String.fromCharCode(nextDigit);
63
+ }
64
+ // eslint-disable-next-line no-constant-condition
65
+ while (true) {
66
+ const nextDigit = outputBuffer[separatorIndex];
67
+ if (nextDigit === 0x3a) {
68
+ separatorIndex++;
69
+ break;
70
+ }
71
+ separatorIndex++;
72
+ lengthString += String.fromCharCode(nextDigit);
73
+ }
74
+ // eslint-disable-next-line no-constant-condition
75
+ while (true) {
76
+ const nextDigit = outputBuffer[separatorIndex];
77
+ if (nextDigit === 0x3a) {
78
+ break;
79
+ }
80
+ separatorIndex++;
81
+ statusString += String.fromCharCode(nextDigit);
82
+ }
83
+ const length = Number(lengthString);
84
+ const status = Number(statusString);
85
+ const dataLength = outputBuffer.length - separatorIndex - 1;
86
+ if (dataLength < length) {
87
+ missingData = {
88
+ dataMissing: length - dataLength,
89
+ };
90
+ return;
91
+ }
92
+ const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
93
+ const messageType = (0, exports.messageTypeIdToMessage)(messageTypeString);
94
+ const payload = {
95
+ type: messageType,
96
+ payload: exports.formatMap[messageType] === 'json'
97
+ ? JSON.parse(data.toString('utf-8'))
98
+ : data,
99
+ };
100
+ options.onMessage({
101
+ successType: status === 1 ? 'error' : 'success',
102
+ message: payload,
103
+ });
104
+ missingData = null;
105
+ outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
106
+ processInput();
107
+ };
108
+ return {
109
+ addData: (data) => {
110
+ unprocessedBuffers.push(data);
111
+ const separatorIndex = data.indexOf(magicSeparator);
112
+ if (separatorIndex === -1) {
113
+ if (missingData) {
114
+ missingData.dataMissing -= data.length;
115
+ }
116
+ if (!missingData || missingData.dataMissing > 0) {
117
+ return;
118
+ }
119
+ }
120
+ unprocessedBuffers.unshift(outputBuffer);
121
+ outputBuffer = Buffer.concat(unprocessedBuffers);
122
+ unprocessedBuffers = [];
123
+ processInput();
124
+ },
125
+ };
126
+ };
127
+ exports.makeStreaming = makeStreaming;
128
+ const makePayloadMessage = ({ message, status, }) => {
129
+ const body = exports.formatMap[message.type] === 'json'
130
+ ? Buffer.from(JSON.stringify(message.payload))
131
+ : message.payload;
132
+ const concat = Buffer.concat([
133
+ magicSeparator,
134
+ Buffer.from((0, exports.messageTypeToMessageId)(message.type).toString()),
135
+ Buffer.from(':'),
136
+ Buffer.from(body.length.toString()),
137
+ Buffer.from(':'),
138
+ Buffer.from(String(status)),
139
+ Buffer.from(':'),
140
+ body,
141
+ ]);
142
+ return concat;
143
+ };
144
+ exports.makePayloadMessage = makePayloadMessage;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import https from 'https';
4
2
  import http from 'node:http';
5
3
  import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
@@ -39,6 +39,9 @@ const isFlakyError = (err) => {
39
39
  if (message.includes('RequestTimeout: Your socket connection to the server')) {
40
40
  return true;
41
41
  }
42
+ if (message.includes('waiting for the page to render the React component failed')) {
43
+ return true;
44
+ }
42
45
  return false;
43
46
  };
44
47
  exports.isFlakyError = isFlakyError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.36",
3
+ "version": "4.0.38",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -26,10 +26,10 @@
26
26
  "aws-policies": "^1.0.1",
27
27
  "mime-types": "2.1.34",
28
28
  "zod": "3.21.4",
29
- "@remotion/cli": "4.0.36",
30
- "@remotion/renderer": "4.0.36",
31
- "@remotion/bundler": "4.0.36",
32
- "remotion": "4.0.36"
29
+ "@remotion/cli": "4.0.38",
30
+ "@remotion/renderer": "4.0.38",
31
+ "@remotion/bundler": "4.0.38",
32
+ "remotion": "4.0.38"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.266",
@@ -43,11 +43,11 @@
43
43
  "ts-node": "^10.8.0",
44
44
  "vitest": "0.31.1",
45
45
  "zip-lib": "^0.7.2",
46
- "@remotion/bundler": "4.0.36",
47
- "@remotion/compositor-linux-arm64-gnu": "4.0.36"
46
+ "@remotion/bundler": "4.0.38",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.38"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.0.36"
50
+ "@remotion/bundler": "4.0.38"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
Binary file
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, }: {
4
- serialized: SerializedInputProps;
5
- region: AwsRegion;
6
- bucketName: string;
7
- expectedBucketOwner: string;
8
- }) => Promise<Record<string, unknown>>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeInputProps = void 0;
4
- const io_1 = require("../functions/helpers/io");
5
- const constants_1 = require("./constants");
6
- const stream_to_string_1 = require("./stream-to-string");
7
- const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, }) => {
8
- if (serialized.type === 'payload') {
9
- return JSON.parse(serialized.payload);
10
- }
11
- try {
12
- const response = await (0, io_1.lambdaReadFile)({
13
- bucketName,
14
- expectedBucketOwner,
15
- key: (0, constants_1.inputPropsKey)(serialized.hash),
16
- region,
17
- });
18
- const body = await (0, stream_to_string_1.streamToString)(response);
19
- const payload = JSON.parse(body);
20
- return payload;
21
- }
22
- catch (err) {
23
- throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
24
- }
25
- };
26
- exports.deserializeInputProps = deserializeInputProps;
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const serializeInputProps: ({ inputProps, region, type, userSpecifiedBucketName, }: {
4
- inputProps: Record<string, unknown>;
5
- region: AwsRegion;
6
- type: 'still' | 'video-or-audio';
7
- userSpecifiedBucketName: string | null;
8
- }) => Promise<SerializedInputProps>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeInputProps = void 0;
4
- const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
5
- const io_1 = require("../functions/helpers/io");
6
- const constants_1 = require("./constants");
7
- const random_hash_1 = require("./random-hash");
8
- const serializeInputProps = async ({ inputProps = {}, region, type, userSpecifiedBucketName, }) => {
9
- try {
10
- const payload = JSON.stringify(inputProps);
11
- const hash = (0, random_hash_1.randomHash)();
12
- const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
13
- if (payload.length > MAX_INLINE_PAYLOAD_SIZE) {
14
- console.warn(`Warning: inputProps are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(payload.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size.`);
15
- const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
16
- region,
17
- })).bucketName;
18
- await (0, io_1.lambdaWriteFile)({
19
- body: payload,
20
- bucketName,
21
- region,
22
- customCredentials: null,
23
- downloadBehavior: null,
24
- expectedBucketOwner: null,
25
- key: (0, constants_1.inputPropsKey)(hash),
26
- privacy: 'public',
27
- });
28
- return {
29
- type: 'bucket-url',
30
- hash,
31
- };
32
- }
33
- return {
34
- type: 'payload',
35
- payload,
36
- };
37
- }
38
- catch (err) {
39
- throw new Error('Error serializing inputProps. Check it has no circular references or reduce the size if the object is big.');
40
- }
41
- };
42
- exports.serializeInputProps = serializeInputProps;