@remotion/renderer 4.0.212 → 4.0.213

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.
@@ -16,7 +16,6 @@
16
16
  import type { LogLevel } from '../log-level';
17
17
  import type { Page } from './BrowserPage';
18
18
  import type { CDPSession } from './Connection';
19
- import type { Frame as TFrame } from './devtools-types';
20
19
  import { DOMWorld } from './DOMWorld';
21
20
  import type { EvaluateFn, EvaluateFnReturnType, EvaluateHandleFn, SerializableOrJSHandle, UnwrapPromiseLike } from './EvalTypes';
22
21
  import { EventEmitter } from './EventEmitter';
@@ -25,6 +24,7 @@ import type { HTTPResponse } from './HTTPResponse';
25
24
  import type { JSHandle } from './JSHandle';
26
25
  import type { PuppeteerLifeCycleEvent } from './LifecycleWatcher';
27
26
  import { NetworkManager } from './NetworkManager';
27
+ import type { Frame as TFrame } from './devtools-types';
28
28
  export declare const FrameManagerEmittedEvents: {
29
29
  FrameNavigated: symbol;
30
30
  FrameDetached: symbol;
@@ -28,14 +28,14 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
28
28
  var _FrameManager_instances, _FrameManager_page, _FrameManager_networkManager, _FrameManager_frames, _FrameManager_contextIdToContext, _FrameManager_isolatedWorlds, _FrameManager_mainFrame, _FrameManager_client, _FrameManager_onAttachedToTarget, _FrameManager_onDetachedFromTarget, _FrameManager_onLifecycleEvent, _FrameManager_onFrameStartedLoading, _FrameManager_onFrameStoppedLoading, _FrameManager_handleFrameTree, _FrameManager_onFrameAttached, _FrameManager_onFrameNavigated, _FrameManager_onFrameNavigatedWithinDocument, _FrameManager_onFrameDetached, _FrameManager_onExecutionContextCreated, _FrameManager_onExecutionContextDestroyed, _FrameManager_onExecutionContextsCleared, _FrameManager_removeFramesRecursively, _Frame_parentFrame, _Frame_url, _Frame_client;
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.Frame = exports.FrameManager = exports.FrameManagerEmittedEvents = void 0;
31
- const assert_1 = require("./assert");
32
31
  const Connection_1 = require("./Connection");
33
32
  const DOMWorld_1 = require("./DOMWorld");
34
33
  const EventEmitter_1 = require("./EventEmitter");
35
34
  const ExecutionContext_1 = require("./ExecutionContext");
36
- const is_target_closed_err_1 = require("./is-target-closed-err");
37
35
  const LifecycleWatcher_1 = require("./LifecycleWatcher");
38
36
  const NetworkManager_1 = require("./NetworkManager");
37
+ const assert_1 = require("./assert");
38
+ const flaky_errors_1 = require("./flaky-errors");
39
39
  const util_1 = require("./util");
40
40
  const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';
41
41
  exports.FrameManagerEmittedEvents = {
@@ -131,7 +131,7 @@ class FrameManager extends EventEmitter_1.EventEmitter {
131
131
  }
132
132
  catch (error) {
133
133
  // The target might have been closed before the initialization finished.
134
- if ((0, util_1.isErrorLike)(error) && (0, is_target_closed_err_1.isTargetClosedErr)(error)) {
134
+ if ((0, util_1.isErrorLike)(error) && (0, flaky_errors_1.isTargetClosedErr)(error)) {
135
135
  return;
136
136
  }
137
137
  throw error;
@@ -0,0 +1,2 @@
1
+ export declare const isTargetClosedErr: (error: Error | undefined) => boolean | undefined;
2
+ export declare const isFlakyNetworkError: (error: Error | undefined) => boolean | undefined;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFlakyNetworkError = exports.isTargetClosedErr = void 0;
4
+ const isTargetClosedErr = (error) => {
5
+ var _a, _b;
6
+ return (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('Target closed')) ||
7
+ ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('Session closed')));
8
+ };
9
+ exports.isTargetClosedErr = isTargetClosedErr;
10
+ const isFlakyNetworkError = (error) => {
11
+ var _a, _b, _c, _d, _e, _f, _g;
12
+ return (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('ERR_CONNECTION_REFUSED')) ||
13
+ ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('ERR_CONNECTION_RESET')) ||
14
+ ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('ERR_CONNECTION_TIMED_OUT')) ||
15
+ ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('ERR_INTERNET_DISCONNECTED')) ||
16
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.includes('ERR_NAME_RESOLUTION_FAILED')) ||
17
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.includes('ERR_ADDRESS_UNREACHABLE')) ||
18
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.includes('ERR_NETWORK_CHANGED')));
19
+ };
20
+ exports.isFlakyNetworkError = isFlakyNetworkError;
@@ -12,7 +12,7 @@ const download_and_map_assets_to_file_1 = require("./assets/download-and-map-ass
12
12
  const browser_1 = require("./browser");
13
13
  const TimeoutSettings_1 = require("./browser/TimeoutSettings");
14
14
  const browser_download_progress_bar_1 = require("./browser/browser-download-progress-bar");
15
- const is_target_closed_err_1 = require("./browser/is-target-closed-err");
15
+ const flaky_errors_1 = require("./browser/flaky-errors");
16
16
  const compress_assets_1 = require("./compress-assets");
17
17
  const cycle_browser_tabs_1 = require("./cycle-browser-tabs");
18
18
  const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
@@ -310,12 +310,13 @@ const innerRenderFrames = async ({ onFrameUpdate, outputDir, onStart, serialized
310
310
  ]);
311
311
  }
312
312
  catch (err) {
313
- const isTargetClosedError = (0, is_target_closed_err_1.isTargetClosedErr)(err);
313
+ const isTargetClosedError = (0, flaky_errors_1.isTargetClosedErr)(err);
314
314
  const shouldRetryError = (_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes(no_react_1.NoReactInternals.DELAY_RENDER_RETRY_TOKEN);
315
+ const flakyNetworkError = (0, flaky_errors_1.isFlakyNetworkError)(err);
315
316
  if ((0, make_cancel_signal_1.isUserCancelledRender)(err) && !shouldRetryError) {
316
317
  throw err;
317
318
  }
318
- if (!isTargetClosedError && !shouldRetryError) {
319
+ if (!isTargetClosedError && !shouldRetryError && !flakyNetworkError) {
319
320
  throw err;
320
321
  }
321
322
  if (stopped) {
@@ -527,7 +528,7 @@ const internalRenderFramesRaw = ({ browserExecutable, cancelSignal, chromiumOpti
527
528
  // If new browser was opened, then closing the browser as a cleanup.
528
529
  if (puppeteerInstance) {
529
530
  Promise.all(openedPages.map((p) => p.close())).catch((err) => {
530
- if ((0, is_target_closed_err_1.isTargetClosedErr)(err)) {
531
+ if ((0, flaky_errors_1.isTargetClosedErr)(err)) {
531
532
  return;
532
533
  }
533
534
  logger_1.Log.error({ indent, logLevel }, 'Unable to close browser tab', err);
@@ -42,7 +42,9 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
42
42
  // To be determined: Is this a problem with Lambda, or the Chrome version
43
43
  // we are using on Lambda?
44
44
  // We already found out that the problem is not a general Linux problem.
45
- const fromSurface = !process.env.DISABLE_FROM_SURFACE;
45
+ // However, if `fromSurface` is false, the screenshot is limited to 8192x8192 pixels.
46
+ // If the image is larger, always use `fromSurface: true`.
47
+ const fromSurface = !process.env.DISABLE_FROM_SURFACE || height > 8192 || width > 8192;
46
48
  const scaleFactor = fromSurface ? 1 : scale;
47
49
  const { value } = await client.send('Page.captureScreenshot', {
48
50
  format,
@@ -0,0 +1,11 @@
1
+ export declare const streamingKey = "remotion_buffer:";
2
+ export declare const makeStreamer: (onMessage: (statusType: 'success' | 'error', nonce: string, data: Uint8Array) => void) => {
3
+ onData: (data: Uint8Array) => void;
4
+ getOutputBuffer: () => Uint8Array;
5
+ clear: () => void;
6
+ };
7
+ export declare const makeStreamPayloadMessage: ({ status, body, nonce, }: {
8
+ nonce: string;
9
+ status: 0 | 1;
10
+ body: Uint8Array;
11
+ }) => Uint8Array;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeStreamPayloadMessage = exports.makeStreamer = exports.streamingKey = void 0;
4
+ exports.streamingKey = 'remotion_buffer:';
5
+ const magicWordStr = 'remotion_buffer:';
6
+ const makeStreamer = (onMessage) => {
7
+ const separator = new Uint8Array(magicWordStr.length);
8
+ for (let i = 0; i < magicWordStr.length; i++) {
9
+ separator[i] = magicWordStr.charCodeAt(i);
10
+ }
11
+ let unprocessedBuffers = [];
12
+ let outputBuffer = new Uint8Array(0);
13
+ let missingData = null;
14
+ const processInput = () => {
15
+ let separatorIndex = outputBuffer.indexOf(separator[0]); // Start checking for the first byte of the separator
16
+ if (separatorIndex === -1 ||
17
+ outputBuffer
18
+ .subarray(separatorIndex, separatorIndex + separator.length)
19
+ .toString() !== separator.toString()) {
20
+ return;
21
+ }
22
+ separatorIndex += separator.length;
23
+ let nonceString = '';
24
+ let lengthString = '';
25
+ let statusString = '';
26
+ // eslint-disable-next-line no-constant-condition
27
+ while (true) {
28
+ if (separatorIndex > outputBuffer.length - 1) {
29
+ return;
30
+ }
31
+ const nextDigit = outputBuffer[separatorIndex];
32
+ separatorIndex++;
33
+ if (nextDigit === 0x3a) {
34
+ break;
35
+ }
36
+ nonceString += String.fromCharCode(nextDigit);
37
+ }
38
+ // eslint-disable-next-line no-constant-condition
39
+ while (true) {
40
+ if (separatorIndex > outputBuffer.length - 1) {
41
+ return;
42
+ }
43
+ const nextDigit = outputBuffer[separatorIndex];
44
+ separatorIndex++;
45
+ if (nextDigit === 0x3a) {
46
+ break;
47
+ }
48
+ lengthString += String.fromCharCode(nextDigit);
49
+ }
50
+ // eslint-disable-next-line no-constant-condition
51
+ while (true) {
52
+ if (separatorIndex > outputBuffer.length - 1) {
53
+ return;
54
+ }
55
+ const nextDigit = outputBuffer[separatorIndex];
56
+ if (nextDigit === 0x3a) {
57
+ break;
58
+ }
59
+ separatorIndex++;
60
+ statusString += String.fromCharCode(nextDigit);
61
+ }
62
+ const length = Number(lengthString);
63
+ const status = Number(statusString);
64
+ const dataLength = outputBuffer.length - separatorIndex - 1;
65
+ if (dataLength < length) {
66
+ missingData = {
67
+ dataMissing: length - dataLength,
68
+ };
69
+ return;
70
+ }
71
+ const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
72
+ onMessage(status === 1 ? 'error' : 'success', nonceString, data);
73
+ missingData = null;
74
+ outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
75
+ processInput();
76
+ };
77
+ const onData = (data) => {
78
+ unprocessedBuffers.push(data);
79
+ const separatorIndex = data.indexOf(separator[0]);
80
+ if (separatorIndex === -1) {
81
+ if (missingData) {
82
+ missingData.dataMissing -= data.length;
83
+ }
84
+ if (!missingData || missingData.dataMissing > 0) {
85
+ return;
86
+ }
87
+ }
88
+ unprocessedBuffers.unshift(outputBuffer);
89
+ outputBuffer = new Uint8Array(unprocessedBuffers.reduce((acc, val) => acc + val.length, 0));
90
+ let offset = 0;
91
+ for (const buf of unprocessedBuffers) {
92
+ outputBuffer.set(buf, offset);
93
+ offset += buf.length;
94
+ }
95
+ unprocessedBuffers = [];
96
+ processInput();
97
+ };
98
+ return {
99
+ onData,
100
+ getOutputBuffer: () => outputBuffer,
101
+ clear: () => {
102
+ unprocessedBuffers = [];
103
+ outputBuffer = new Uint8Array(0);
104
+ },
105
+ };
106
+ };
107
+ exports.makeStreamer = makeStreamer;
108
+ const makeStreamPayloadMessage = ({ status, body, nonce, }) => {
109
+ const nonceArr = new TextEncoder().encode(nonce);
110
+ const magicWordArr = new TextEncoder().encode(magicWordStr);
111
+ const separatorArr = new TextEncoder().encode(':');
112
+ const bodyLengthArr = new TextEncoder().encode(body.length.toString());
113
+ const statusArr = new TextEncoder().encode(String(status));
114
+ // Calculate total length of new Uint8Array
115
+ const totalLength = nonceArr.length +
116
+ magicWordArr.length +
117
+ separatorArr.length * 3 +
118
+ bodyLengthArr.length +
119
+ statusArr.length +
120
+ body.length;
121
+ // Create a new Uint8Array to hold all combined parts
122
+ const concat = new Uint8Array(totalLength);
123
+ let offset = 0;
124
+ // Function to append data to concat
125
+ const appendToConcat = (data) => {
126
+ concat.set(data, offset);
127
+ offset += data.length;
128
+ };
129
+ // Building the final Uint8Array
130
+ appendToConcat(magicWordArr);
131
+ appendToConcat(nonceArr);
132
+ appendToConcat(separatorArr);
133
+ appendToConcat(bodyLengthArr);
134
+ appendToConcat(separatorArr);
135
+ appendToConcat(statusArr);
136
+ appendToConcat(separatorArr);
137
+ appendToConcat(body);
138
+ return concat;
139
+ };
140
+ exports.makeStreamPayloadMessage = makeStreamPayloadMessage;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/renderer"
4
4
  },
5
5
  "name": "@remotion/renderer",
6
- "version": "4.0.212",
6
+ "version": "4.0.213",
7
7
  "description": "Render Remotion videos using Node.js or Bun",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  "extract-zip": "2.0.1",
19
19
  "source-map": "^0.8.0-beta.0",
20
20
  "ws": "8.17.1",
21
- "remotion": "4.0.212",
22
- "@remotion/streaming": "4.0.212"
21
+ "remotion": "4.0.213",
22
+ "@remotion/streaming": "4.0.213"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=16.8.0",
@@ -34,13 +34,13 @@
34
34
  "@types/ws": "8.5.10"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@remotion/compositor-darwin-x64": "4.0.212",
38
- "@remotion/compositor-darwin-arm64": "4.0.212",
39
- "@remotion/compositor-linux-arm64-gnu": "4.0.212",
40
- "@remotion/compositor-linux-arm64-musl": "4.0.212",
41
- "@remotion/compositor-linux-x64-musl": "4.0.212",
42
- "@remotion/compositor-linux-x64-gnu": "4.0.212",
43
- "@remotion/compositor-win32-x64-msvc": "4.0.212"
37
+ "@remotion/compositor-darwin-arm64": "4.0.213",
38
+ "@remotion/compositor-darwin-x64": "4.0.213",
39
+ "@remotion/compositor-linux-arm64-gnu": "4.0.213",
40
+ "@remotion/compositor-linux-arm64-musl": "4.0.213",
41
+ "@remotion/compositor-linux-x64-gnu": "4.0.213",
42
+ "@remotion/compositor-linux-x64-musl": "4.0.213",
43
+ "@remotion/compositor-win32-x64-msvc": "4.0.213"
44
44
  },
45
45
  "keywords": [
46
46
  "remotion",