@remotion/lambda 4.0.36 → 4.0.37
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.
- package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +4 -1
- package/dist/functions/streaming/streaming.d.ts +7 -0
- package/dist/functions/streaming/streaming.js +99 -0
- package/dist/shared/invoke-webhook.d.ts +0 -2
- package/dist/shared/is-flaky-error.js +3 -0
- package/package.json +8 -8
- package/remotionlambda-arm64.zip +0 -0
- package/dist/shared/deserialize-input-props.d.ts +0 -8
- package/dist/shared/deserialize-input-props.js +0 -26
- package/dist/shared/serialize-input-props.d.ts +0 -8
- package/dist/shared/serialize-input-props.js +0 -42
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type OnMessage = (type: 'error' | 'success', nonce: string, data: Buffer) => void;
|
|
3
|
+
export declare const makeStreaming: (onMessage: OnMessage) => {
|
|
4
|
+
addData: (data: Buffer) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const makePayloadMessage: (nonce: number, data: Buffer, status: 0 | 1) => Buffer;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePayloadMessage = exports.makeStreaming = void 0;
|
|
4
|
+
const makeStreaming = (onMessage) => {
|
|
5
|
+
let outputBuffer = Buffer.from('');
|
|
6
|
+
const separator = Buffer.from('remotion_buffer:');
|
|
7
|
+
let unprocessedBuffers = [];
|
|
8
|
+
let missingData = null;
|
|
9
|
+
const processInput = () => {
|
|
10
|
+
let separatorIndex = outputBuffer.indexOf(separator);
|
|
11
|
+
if (separatorIndex === -1) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
separatorIndex += separator.length;
|
|
15
|
+
let nonceString = '';
|
|
16
|
+
let lengthString = '';
|
|
17
|
+
let statusString = '';
|
|
18
|
+
// Each message from Rust is prefixed with `remotion_buffer;{[nonce]}:{[length]}`
|
|
19
|
+
// Let's read the buffer to extract the nonce, and if the full length is available,
|
|
20
|
+
// we'll extract the data and pass it to the callback.
|
|
21
|
+
// eslint-disable-next-line no-constant-condition
|
|
22
|
+
while (true) {
|
|
23
|
+
const nextDigit = outputBuffer[separatorIndex];
|
|
24
|
+
// 0x3a is the character ":"
|
|
25
|
+
if (nextDigit === 0x3a) {
|
|
26
|
+
separatorIndex++;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
separatorIndex++;
|
|
30
|
+
nonceString += String.fromCharCode(nextDigit);
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line no-constant-condition
|
|
33
|
+
while (true) {
|
|
34
|
+
const nextDigit = outputBuffer[separatorIndex];
|
|
35
|
+
if (nextDigit === 0x3a) {
|
|
36
|
+
separatorIndex++;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
separatorIndex++;
|
|
40
|
+
lengthString += String.fromCharCode(nextDigit);
|
|
41
|
+
}
|
|
42
|
+
// eslint-disable-next-line no-constant-condition
|
|
43
|
+
while (true) {
|
|
44
|
+
const nextDigit = outputBuffer[separatorIndex];
|
|
45
|
+
if (nextDigit === 0x3a) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
separatorIndex++;
|
|
49
|
+
statusString += String.fromCharCode(nextDigit);
|
|
50
|
+
}
|
|
51
|
+
const length = Number(lengthString);
|
|
52
|
+
const status = Number(statusString);
|
|
53
|
+
const dataLength = outputBuffer.length - separatorIndex - 1;
|
|
54
|
+
if (dataLength < length) {
|
|
55
|
+
missingData = {
|
|
56
|
+
dataMissing: length - dataLength,
|
|
57
|
+
};
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
|
|
61
|
+
onMessage(status === 1 ? 'error' : 'success', nonceString, data);
|
|
62
|
+
missingData = null;
|
|
63
|
+
outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
|
|
64
|
+
processInput();
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
addData: (data) => {
|
|
68
|
+
unprocessedBuffers.push(data);
|
|
69
|
+
const separatorIndex = data.indexOf(separator);
|
|
70
|
+
if (separatorIndex === -1) {
|
|
71
|
+
if (missingData) {
|
|
72
|
+
missingData.dataMissing -= data.length;
|
|
73
|
+
}
|
|
74
|
+
if (!missingData || missingData.dataMissing > 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
unprocessedBuffers.unshift(outputBuffer);
|
|
79
|
+
outputBuffer = Buffer.concat(unprocessedBuffers);
|
|
80
|
+
unprocessedBuffers = [];
|
|
81
|
+
processInput();
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
exports.makeStreaming = makeStreaming;
|
|
86
|
+
const makePayloadMessage = (nonce, data, status) => {
|
|
87
|
+
const concat = Buffer.concat([
|
|
88
|
+
Buffer.from('remotion_buffer:'),
|
|
89
|
+
Buffer.from(nonce.toString()),
|
|
90
|
+
Buffer.from(':'),
|
|
91
|
+
Buffer.from(data.length.toString()),
|
|
92
|
+
Buffer.from(':'),
|
|
93
|
+
Buffer.from(String(status)),
|
|
94
|
+
Buffer.from(':'),
|
|
95
|
+
data,
|
|
96
|
+
]);
|
|
97
|
+
return concat;
|
|
98
|
+
};
|
|
99
|
+
exports.makePayloadMessage = makePayloadMessage;
|
|
@@ -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.
|
|
3
|
+
"version": "4.0.37",
|
|
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/
|
|
30
|
-
"@remotion/renderer": "4.0.
|
|
31
|
-
"@remotion/
|
|
32
|
-
"remotion": "4.0.
|
|
29
|
+
"@remotion/bundler": "4.0.37",
|
|
30
|
+
"@remotion/renderer": "4.0.37",
|
|
31
|
+
"@remotion/cli": "4.0.37",
|
|
32
|
+
"remotion": "4.0.37"
|
|
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.
|
|
47
|
-
"@remotion/compositor-linux-arm64-gnu": "4.0.
|
|
46
|
+
"@remotion/bundler": "4.0.37",
|
|
47
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.37"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@remotion/bundler": "4.0.
|
|
50
|
+
"@remotion/bundler": "4.0.37"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
package/remotionlambda-arm64.zip
CHANGED
|
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;
|