@remotion/renderer 4.0.536 → 4.0.538

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.
Files changed (292) hide show
  1. package/dist/aac-priming.d.ts +2 -1
  2. package/dist/assets/apply-tone-frequency.d.ts +2 -1
  3. package/dist/assets/apply-tone-frequency.js +8 -1
  4. package/dist/assets/calculate-asset-positions.js +2 -0
  5. package/dist/assets/convert-assets-to-file-urls.d.ts +2 -1
  6. package/dist/assets/download-and-map-assets-to-file.d.ts +3 -2
  7. package/dist/assets/get-audio-channels.d.ts +3 -2
  8. package/dist/assets/inline-audio-mixing.d.ts +2 -1
  9. package/dist/assets/types.d.ts +2 -1
  10. package/dist/browser/Browser.d.ts +5 -5
  11. package/dist/browser/Browser.js +74 -65
  12. package/dist/browser/BrowserFetcher.d.ts +7 -5
  13. package/dist/browser/BrowserPage.d.ts +4 -4
  14. package/dist/browser/BrowserPage.js +222 -226
  15. package/dist/browser/BrowserRunner.d.ts +2 -1
  16. package/dist/browser/Connection.js +109 -96
  17. package/dist/browser/ConsoleMessage.d.ts +1 -1
  18. package/dist/browser/ConsoleMessage.js +16 -9
  19. package/dist/browser/DOMWorld.d.ts +1 -1
  20. package/dist/browser/DOMWorld.js +91 -77
  21. package/dist/browser/Errors.js +4 -2
  22. package/dist/browser/EventEmitter.js +1 -2
  23. package/dist/browser/ExecutionContext.js +120 -117
  24. package/dist/browser/FrameManager.js +244 -249
  25. package/dist/browser/HTTPRequest.js +22 -11
  26. package/dist/browser/HTTPResponse.js +16 -3
  27. package/dist/browser/JSHandle.js +30 -17
  28. package/dist/browser/LifecycleWatcher.js +128 -122
  29. package/dist/browser/NetworkEventManager.js +40 -31
  30. package/dist/browser/NetworkManager.js +203 -210
  31. package/dist/browser/NodeWebSocketTransport.js +0 -3
  32. package/dist/browser/Target.d.ts +1 -1
  33. package/dist/browser/Target.js +39 -32
  34. package/dist/browser/TaskQueue.js +18 -5
  35. package/dist/browser/TimeoutSettings.js +25 -12
  36. package/dist/browser/browser-download-progress-bar.d.ts +2 -1
  37. package/dist/browser/get-chrome-download-url.d.ts +3 -2
  38. package/dist/browser/handle-failed-resource.d.ts +2 -1
  39. package/dist/call-ffmpeg.d.ts +7 -6
  40. package/dist/can-concat-seamlessly.d.ts +4 -2
  41. package/dist/can-use-parallel-encoding.d.ts +2 -1
  42. package/dist/check-version-requirements.d.ts +2 -1
  43. package/dist/client.d.ts +302 -280
  44. package/dist/client.js +2 -2
  45. package/dist/codec-supports-media.d.ts +4 -3
  46. package/dist/codec.d.ts +1 -1
  47. package/dist/collect-assets.d.ts +1 -1
  48. package/dist/combine-audio.d.ts +4 -2
  49. package/dist/combine-chunks.d.ts +2 -1
  50. package/dist/combine-video-streams.d.ts +4 -2
  51. package/dist/compositor/compositor.d.ts +4 -3
  52. package/dist/compositor/get-executable-path.d.ts +4 -4
  53. package/dist/compress-audio.d.ts +4 -2
  54. package/dist/create-audio.d.ts +4 -2
  55. package/dist/create-silent-audio.d.ts +2 -1
  56. package/dist/crf.d.ts +6 -4
  57. package/dist/cycle-browser-tabs.d.ts +2 -1
  58. package/dist/ensure-browser.d.ts +1 -52
  59. package/dist/error-handling/handle-javascript-exception.d.ts +1 -1
  60. package/dist/error-handling/handle-javascript-exception.js +0 -5
  61. package/dist/error-handling/symbolicateable-error.d.ts +1 -1
  62. package/dist/error-handling/symbolicateable-error.js +0 -4
  63. package/dist/error-handling.js +1 -1
  64. package/dist/esm/client.mjs +306 -238
  65. package/dist/esm/index.mjs +108 -88
  66. package/dist/extract-audio.d.ts +3 -2
  67. package/dist/ffmpeg-args.d.ts +12 -6
  68. package/dist/finalize-fast-start.d.ts +2 -1
  69. package/dist/get-browser-instance.d.ts +6 -4
  70. package/dist/get-codec-name.d.ts +6 -3
  71. package/dist/get-compositions.d.ts +2 -1
  72. package/dist/get-concurrency.d.ts +1 -1
  73. package/dist/get-concurrency.js +1 -1
  74. package/dist/get-duration-from-frame-range.d.ts +1 -1
  75. package/dist/get-extension-from-codec.d.ts +2 -1
  76. package/dist/get-frame-padded-index.d.ts +2 -1
  77. package/dist/get-local-browser-executable.d.ts +4 -2
  78. package/dist/get-port.d.ts +1 -1
  79. package/dist/get-prores-profile-name.d.ts +3 -1
  80. package/dist/get-silent-parts.d.ts +5 -4
  81. package/dist/get-video-metadata.d.ts +4 -3
  82. package/dist/get-video-threads-flag.d.ts +2 -1
  83. package/dist/goto-page-or-throw.d.ts +1 -1
  84. package/dist/guess-extension-for-media.d.ts +2 -1
  85. package/dist/image-format.d.ts +6 -5
  86. package/dist/index.d.ts +213 -440
  87. package/dist/index.js +18 -18
  88. package/dist/is-audio-codec.d.ts +2 -1
  89. package/dist/log-level.d.ts +2 -2
  90. package/dist/logger.d.ts +6 -6
  91. package/dist/make-page.d.ts +5 -3
  92. package/dist/memory/from-macos-sysctl.d.ts +2 -1
  93. package/dist/memory/from-proc-meminfo.d.ts +2 -1
  94. package/dist/memory/get-available-memory.d.ts +2 -1
  95. package/dist/merge-inline-audio-tracks.d.ts +2 -1
  96. package/dist/mux-video-and-audio.d.ts +5 -3
  97. package/dist/offthread-video-server.d.ts +2 -1
  98. package/dist/offthread-video-server.js +6 -4
  99. package/dist/open-browser.d.ts +2 -2
  100. package/dist/options/allow-html-in-canvas.js +1 -2
  101. package/dist/options/api-key.d.ts +1 -1
  102. package/dist/options/api-key.js +1 -3
  103. package/dist/options/ask-ai.js +1 -1
  104. package/dist/options/audio-bitrate.js +1 -9
  105. package/dist/options/audio-codec.d.ts +23 -20
  106. package/dist/options/beep-on-finish.js +1 -1
  107. package/dist/options/benchmark-concurrencies.js +1 -2
  108. package/dist/options/binaries-directory.d.ts +1 -1
  109. package/dist/options/binaries-directory.js +1 -9
  110. package/dist/options/browser-executable.d.ts +1 -1
  111. package/dist/options/browser-executable.js +1 -1
  112. package/dist/options/browser.js +1 -2
  113. package/dist/options/bundle-cache.js +1 -2
  114. package/dist/options/canvas-tabs.js +1 -1
  115. package/dist/options/chrome-mode.d.ts +4 -4
  116. package/dist/options/chrome-mode.js +1 -6
  117. package/dist/options/color-space.d.ts +9 -5
  118. package/dist/options/color-space.js +1 -8
  119. package/dist/options/concurrency.d.ts +1 -1
  120. package/dist/options/concurrency.js +1 -5
  121. package/dist/options/config.js +1 -1
  122. package/dist/options/crf.js +1 -1
  123. package/dist/options/cross-site-isolation.js +1 -2
  124. package/dist/options/dark-mode.js +1 -2
  125. package/dist/options/default-coding-agent.d.ts +2 -2
  126. package/dist/options/default-coding-agent.js +1 -2
  127. package/dist/options/default-editor.d.ts +4 -4
  128. package/dist/options/default-editor.js +1 -3
  129. package/dist/options/default-premount-in-seconds.js +1 -1
  130. package/dist/options/delete-after.d.ts +1 -1
  131. package/dist/options/delete-after.js +1 -11
  132. package/dist/options/disable-shared-memory-capture.js +1 -3
  133. package/dist/options/disable-web-security.d.ts +1 -1
  134. package/dist/options/disable-web-security.js +1 -1
  135. package/dist/options/disallow-parallel-encoding.js +1 -1
  136. package/dist/options/enable-cancellation.js +1 -2
  137. package/dist/options/enable-lambda-insights.js +1 -2
  138. package/dist/options/enable-multiprocess-on-linux.js +1 -13
  139. package/dist/options/encoding-buffer-size.d.ts +4 -2
  140. package/dist/options/encoding-buffer-size.js +1 -3
  141. package/dist/options/encoding-max-rate.d.ts +1 -1
  142. package/dist/options/encoding-max-rate.js +1 -3
  143. package/dist/options/enforce-audio.js +1 -15
  144. package/dist/options/env-file.js +1 -3
  145. package/dist/options/every-nth-frame.d.ts +1 -1
  146. package/dist/options/every-nth-frame.js +1 -6
  147. package/dist/options/experimental-keep-audio-context-alive.js +1 -3
  148. package/dist/options/folder-expiry.d.ts +1 -1
  149. package/dist/options/folder-expiry.js +1 -4
  150. package/dist/options/for-seamless-aac-concatenation.js +1 -3
  151. package/dist/options/force-new-studio.js +1 -1
  152. package/dist/options/frames.d.ts +1 -1
  153. package/dist/options/frames.js +1 -4
  154. package/dist/options/gl.d.ts +6 -6
  155. package/dist/options/gl.js +3 -28
  156. package/dist/options/gop-size.js +1 -3
  157. package/dist/options/hardware-acceleration.d.ts +3 -3
  158. package/dist/options/headless.js +1 -1
  159. package/dist/options/ignore-certificate-errors.d.ts +1 -1
  160. package/dist/options/ignore-certificate-errors.js +1 -1
  161. package/dist/options/image-sequence-pattern.js +1 -5
  162. package/dist/options/image-sequence.js +1 -1
  163. package/dist/options/index.d.ts +91 -72
  164. package/dist/options/index.js +2 -0
  165. package/dist/options/interactivity.js +1 -1
  166. package/dist/options/ipv4.js +1 -1
  167. package/dist/options/is-production.d.ts +1 -1
  168. package/dist/options/is-production.js +1 -4
  169. package/dist/options/jpeg-quality.d.ts +1 -1
  170. package/dist/options/jpeg-quality.js +1 -4
  171. package/dist/options/keyboard-shortcuts.js +1 -1
  172. package/dist/options/latency-hint.d.ts +1 -1
  173. package/dist/options/latency-hint.js +1 -10
  174. package/dist/options/license-key.d.ts +1 -1
  175. package/dist/options/license-key.js +1 -2
  176. package/dist/options/log-level.d.ts +4 -3
  177. package/dist/options/log-level.js +1 -16
  178. package/dist/options/metadata.js +2 -7
  179. package/dist/options/mute.js +1 -1
  180. package/dist/options/no-open.js +1 -1
  181. package/dist/options/number-of-gif-loops.d.ts +1 -1
  182. package/dist/options/number-of-gif-loops.js +1 -13
  183. package/dist/options/number-of-shared-audio-tags.js +1 -1
  184. package/dist/options/offthreadvideo-cache-size.d.ts +1 -1
  185. package/dist/options/offthreadvideo-cache-size.js +1 -11
  186. package/dist/options/offthreadvideo-threads.d.ts +1 -1
  187. package/dist/options/offthreadvideo-threads.js +1 -2
  188. package/dist/options/on-browser-download.d.ts +1 -1
  189. package/dist/options/on-browser-download.js +1 -2
  190. package/dist/options/options-map.d.ts +180 -180
  191. package/dist/options/out-dir.d.ts +1 -1
  192. package/dist/options/out-dir.js +1 -4
  193. package/dist/options/override-duration.js +1 -1
  194. package/dist/options/override-fps.js +1 -1
  195. package/dist/options/override-height.js +1 -1
  196. package/dist/options/override-width.js +1 -1
  197. package/dist/options/overwrite.js +1 -5
  198. package/dist/options/package-manager.d.ts +1 -1
  199. package/dist/options/package-manager.js +1 -12
  200. package/dist/options/pixel-format.d.ts +6 -5
  201. package/dist/options/pixel-format.js +1 -2
  202. package/dist/options/port.js +1 -1
  203. package/dist/options/prefer-lossless.d.ts +1 -1
  204. package/dist/options/prefer-lossless.js +1 -4
  205. package/dist/options/{experimental-tracks.d.ts → preserve-pitch-on-playback.d.ts} +3 -3
  206. package/dist/options/preserve-pitch-on-playback.js +36 -0
  207. package/dist/options/preview-sample-rate.js +1 -3
  208. package/dist/options/props.js +1 -5
  209. package/dist/options/prores-profile.d.ts +2 -2
  210. package/dist/options/prores-profile.js +1 -5
  211. package/dist/options/public-dir.d.ts +1 -1
  212. package/dist/options/public-dir.js +1 -2
  213. package/dist/options/public-license-key.d.ts +1 -1
  214. package/dist/options/public-license-key.js +1 -3
  215. package/dist/options/public-path.d.ts +1 -1
  216. package/dist/options/public-path.js +1 -5
  217. package/dist/options/repro.d.ts +3 -1
  218. package/dist/options/repro.js +1 -1
  219. package/dist/options/rspack.js +1 -1
  220. package/dist/options/runs.js +1 -3
  221. package/dist/options/sample-rate.d.ts +2 -2
  222. package/dist/options/sample-rate.js +1 -2
  223. package/dist/options/scale.js +1 -5
  224. package/dist/options/sequence-activity-limit.js +1 -4
  225. package/dist/options/show-layer-frame-numbers.js +1 -3
  226. package/dist/options/show-premounting.js +1 -2
  227. package/dist/options/skip-skills.js +1 -1
  228. package/dist/options/still-frame.d.ts +1 -1
  229. package/dist/options/still-frame.js +1 -3
  230. package/dist/options/still-image-format.d.ts +3 -2
  231. package/dist/options/still-image-format.js +1 -2
  232. package/dist/options/timeout.d.ts +1 -1
  233. package/dist/options/timeout.js +1 -4
  234. package/dist/options/user-agent.d.ts +1 -1
  235. package/dist/options/user-agent.js +1 -1
  236. package/dist/options/version-flag.js +1 -1
  237. package/dist/options/video-bitrate.js +1 -7
  238. package/dist/options/video-cache-size.d.ts +1 -1
  239. package/dist/options/video-cache-size.js +1 -7
  240. package/dist/options/video-codec.d.ts +9 -7
  241. package/dist/options/video-codec.js +1 -1
  242. package/dist/options/video-image-format.d.ts +6 -5
  243. package/dist/options/video-image-format.js +1 -6
  244. package/dist/options/webhook-custom-data.d.ts +1 -1
  245. package/dist/options/webhook-custom-data.js +1 -1
  246. package/dist/options/webpack-poll.js +1 -1
  247. package/dist/options/x264-preset.d.ts +8 -7
  248. package/dist/options/x264-preset.js +1 -23
  249. package/dist/p-limit.d.ts +1 -1
  250. package/dist/pixel-format.d.ts +4 -3
  251. package/dist/pool.js +0 -2
  252. package/dist/port-config.d.ts +6 -5
  253. package/dist/prespawn-ffmpeg.d.ts +1 -1
  254. package/dist/print-useful-error-message.d.ts +2 -1
  255. package/dist/probe-encoder.d.ts +8 -5
  256. package/dist/probe-shared-memory-capture.d.ts +4 -2
  257. package/dist/prores-profile.d.ts +4 -2
  258. package/dist/puppeteer-evaluate.d.ts +2 -2
  259. package/dist/puppeteer-screenshot.d.ts +4 -3
  260. package/dist/pure.d.ts +12 -15
  261. package/dist/remotion-shared-memory.d.ts +1 -1
  262. package/dist/remotion-shared-memory.js +199 -187
  263. package/dist/render-frame-and-retry-target-close.d.ts +10 -10
  264. package/dist/render-frame-with-option-to-reject.d.ts +7 -5
  265. package/dist/render-frame-with-option-to-reject.js +1 -5
  266. package/dist/render-frame.d.ts +8 -6
  267. package/dist/render-frames.d.ts +1 -40
  268. package/dist/render-has-audio.d.ts +3 -2
  269. package/dist/replace-browser.d.ts +2 -1
  270. package/dist/repro.d.ts +1 -1
  271. package/dist/screenshot-task.d.ts +4 -3
  272. package/dist/seek-to-frame.d.ts +3 -2
  273. package/dist/select-composition.d.ts +1 -20
  274. package/dist/serve-handler/index.d.ts +1 -1
  275. package/dist/serve-handler/range-parser.d.ts +2 -2
  276. package/dist/serve-static.d.ts +2 -1
  277. package/dist/serve-static.js +4 -4
  278. package/dist/set-props-and-env.js +2 -6
  279. package/dist/stringify-ffmpeg-filter.d.ts +2 -1
  280. package/dist/stringify-ffmpeg-filter.js +20 -2
  281. package/dist/take-frame.d.ts +1 -1
  282. package/dist/test-gpu.d.ts +4 -2
  283. package/dist/validate-even-dimensions-with-codec.d.ts +4 -2
  284. package/dist/validate-ffmpeg-override.d.ts +1 -1
  285. package/dist/validate-number-of-gif-loops.d.ts +2 -1
  286. package/dist/validate-output-filename.d.ts +4 -2
  287. package/package.json +16 -16
  288. package/dist/options/experimental-sequence-activity-limit.d.ts +0 -19
  289. package/dist/options/experimental-sequence-activity-limit.js +0 -40
  290. package/dist/options/experimental-sequence-activity.d.ts +0 -19
  291. package/dist/options/experimental-sequence-activity.js +0 -38
  292. package/dist/options/experimental-tracks.js +0 -43
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.EventEmitter = void 0;
7
7
  const mitt_1 = __importDefault(require("./mitt"));
8
8
  class EventEmitter {
9
- emitter;
10
- eventsMap = new Map();
11
9
  constructor() {
10
+ this.eventsMap = new Map();
12
11
  this.emitter = (0, mitt_1.default)(this.eventsMap);
13
12
  }
14
13
  on(event, handler) {
@@ -16,6 +16,12 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
20
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
21
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
22
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
23
+ };
24
+ var _ExecutionContext_instances, _ExecutionContext_evaluate;
19
25
  Object.defineProperty(exports, "__esModule", { value: true });
20
26
  exports.ExecutionContext = exports.EVALUATION_SCRIPT_URL = void 0;
21
27
  const JSHandle_1 = require("./JSHandle");
@@ -23,11 +29,8 @@ const util_1 = require("./util");
23
29
  exports.EVALUATION_SCRIPT_URL = 'pptr://__puppeteer_evaluation_script__';
24
30
  const SOURCE_URL_REGEX = /^[\x20\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
25
31
  class ExecutionContext {
26
- _client;
27
- _world;
28
- _contextId;
29
- _contextName;
30
32
  constructor(client, contextPayload, world) {
33
+ _ExecutionContext_instances.add(this);
31
34
  this._client = client;
32
35
  this._world = world;
33
36
  this._contextId = contextPayload.id;
@@ -37,135 +40,135 @@ class ExecutionContext {
37
40
  return this._world ? this._world.frame() : null;
38
41
  }
39
42
  evaluate(pageFunction, ...args) {
40
- return this.#evaluate(true, pageFunction, ...args);
43
+ return __classPrivateFieldGet(this, _ExecutionContext_instances, "m", _ExecutionContext_evaluate).call(this, true, pageFunction, ...args);
41
44
  }
42
45
  evaluateHandle(pageFunction, ...args) {
43
- return this.#evaluate(false, pageFunction, ...args);
46
+ return __classPrivateFieldGet(this, _ExecutionContext_instances, "m", _ExecutionContext_evaluate).call(this, false, pageFunction, ...args);
44
47
  }
45
- async #evaluate(returnByValue, pageFunction, ...args) {
46
- const suffix = `//# sourceURL=${exports.EVALUATION_SCRIPT_URL}`;
47
- if ((0, util_1.isString)(pageFunction)) {
48
- const contextId = this._contextId;
49
- const expression = pageFunction;
50
- const expressionWithSourceUrl = SOURCE_URL_REGEX.test(expression)
51
- ? expression
52
- : expression + '\n' + suffix;
53
- const { value: { exceptionDetails: _details, result: _remoteObject }, } = await this._client
54
- .send('Runtime.evaluate', {
55
- expression: expressionWithSourceUrl,
56
- contextId,
57
- returnByValue,
58
- awaitPromise: true,
59
- userGesture: true,
60
- })
61
- .catch(rewriteError);
62
- if (_details) {
63
- throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(_details));
64
- }
65
- return returnByValue
66
- ? (0, util_1.valueFromRemoteObject)(_remoteObject)
67
- : (0, JSHandle_1._createJSHandle)(this, _remoteObject);
48
+ }
49
+ exports.ExecutionContext = ExecutionContext;
50
+ _ExecutionContext_instances = new WeakSet(), _ExecutionContext_evaluate = async function _ExecutionContext_evaluate(returnByValue, pageFunction, ...args) {
51
+ const suffix = `//# sourceURL=${exports.EVALUATION_SCRIPT_URL}`;
52
+ if ((0, util_1.isString)(pageFunction)) {
53
+ const contextId = this._contextId;
54
+ const expression = pageFunction;
55
+ const expressionWithSourceUrl = SOURCE_URL_REGEX.test(expression)
56
+ ? expression
57
+ : expression + '\n' + suffix;
58
+ const { value: { exceptionDetails: _details, result: _remoteObject }, } = await this._client
59
+ .send('Runtime.evaluate', {
60
+ expression: expressionWithSourceUrl,
61
+ contextId,
62
+ returnByValue,
63
+ awaitPromise: true,
64
+ userGesture: true,
65
+ })
66
+ .catch(rewriteError);
67
+ if (_details) {
68
+ throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(_details));
69
+ }
70
+ return returnByValue
71
+ ? (0, util_1.valueFromRemoteObject)(_remoteObject)
72
+ : (0, JSHandle_1._createJSHandle)(this, _remoteObject);
73
+ }
74
+ if (typeof pageFunction !== 'function') {
75
+ throw new Error(`Expected to get |string| or |function| as the first argument, but got "${pageFunction}" instead.`);
76
+ }
77
+ let functionText = pageFunction.toString();
78
+ try {
79
+ new Function('(' + functionText + ')');
80
+ }
81
+ catch (error) {
82
+ // This means we might have a function shorthand. Try another
83
+ // time prefixing 'function '.
84
+ if (functionText.startsWith('async ')) {
85
+ functionText =
86
+ 'async function ' + functionText.substring('async '.length);
68
87
  }
69
- if (typeof pageFunction !== 'function') {
70
- throw new Error(`Expected to get |string| or |function| as the first argument, but got "${pageFunction}" instead.`);
88
+ else {
89
+ functionText = 'function ' + functionText;
71
90
  }
72
- let functionText = pageFunction.toString();
73
91
  try {
74
92
  new Function('(' + functionText + ')');
75
93
  }
76
- catch (error) {
77
- // This means we might have a function shorthand. Try another
78
- // time prefixing 'function '.
79
- if (functionText.startsWith('async ')) {
80
- functionText =
81
- 'async function ' + functionText.substring('async '.length);
82
- }
83
- else {
84
- functionText = 'function ' + functionText;
85
- }
86
- try {
87
- new Function('(' + functionText + ')');
88
- }
89
- catch (_error) {
90
- // We tried hard to serialize, but there's a weird beast here.
91
- throw new Error('Passed function is not well-serializable!');
92
- }
94
+ catch (_error) {
95
+ // We tried hard to serialize, but there's a weird beast here.
96
+ throw new Error('Passed function is not well-serializable!');
93
97
  }
94
- let callFunctionOnPromise;
95
- try {
96
- callFunctionOnPromise = this._client.send('Runtime.callFunctionOn', {
97
- functionDeclaration: functionText + '\n' + suffix + '\n',
98
- executionContextId: this._contextId,
99
- arguments: args.map(convertArgument.bind(this)),
100
- returnByValue,
101
- awaitPromise: true,
102
- userGesture: true,
103
- });
98
+ }
99
+ let callFunctionOnPromise;
100
+ try {
101
+ callFunctionOnPromise = this._client.send('Runtime.callFunctionOn', {
102
+ functionDeclaration: functionText + '\n' + suffix + '\n',
103
+ executionContextId: this._contextId,
104
+ arguments: args.map(convertArgument.bind(this)),
105
+ returnByValue,
106
+ awaitPromise: true,
107
+ userGesture: true,
108
+ });
109
+ }
110
+ catch (error) {
111
+ if (error instanceof TypeError &&
112
+ error.message.startsWith('Converting circular structure to JSON')) {
113
+ error.message += ' Recursive objects are not allowed.';
104
114
  }
105
- catch (error) {
106
- if (error instanceof TypeError &&
107
- error.message.startsWith('Converting circular structure to JSON')) {
108
- error.message += ' Recursive objects are not allowed.';
109
- }
110
- throw error;
115
+ throw error;
116
+ }
117
+ const { value: { exceptionDetails, result: remoteObject }, } = await callFunctionOnPromise.catch(rewriteError);
118
+ if (exceptionDetails) {
119
+ throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(exceptionDetails));
120
+ }
121
+ return returnByValue
122
+ ? (0, util_1.valueFromRemoteObject)(remoteObject)
123
+ : (0, JSHandle_1._createJSHandle)(this, remoteObject);
124
+ function convertArgument(arg) {
125
+ if (typeof arg === 'bigint') {
126
+ // eslint-disable-line valid-typeof
127
+ return { unserializableValue: `${arg.toString()}n` };
111
128
  }
112
- const { value: { exceptionDetails, result: remoteObject }, } = await callFunctionOnPromise.catch(rewriteError);
113
- if (exceptionDetails) {
114
- throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(exceptionDetails));
129
+ if (Object.is(arg, -0)) {
130
+ return { unserializableValue: '-0' };
115
131
  }
116
- return returnByValue
117
- ? (0, util_1.valueFromRemoteObject)(remoteObject)
118
- : (0, JSHandle_1._createJSHandle)(this, remoteObject);
119
- function convertArgument(arg) {
120
- if (typeof arg === 'bigint') {
121
- // eslint-disable-line valid-typeof
122
- return { unserializableValue: `${arg.toString()}n` };
123
- }
124
- if (Object.is(arg, -0)) {
125
- return { unserializableValue: '-0' };
126
- }
127
- if (Object.is(arg, Infinity)) {
128
- return { unserializableValue: 'Infinity' };
132
+ if (Object.is(arg, Infinity)) {
133
+ return { unserializableValue: 'Infinity' };
134
+ }
135
+ if (Object.is(arg, -Infinity)) {
136
+ return { unserializableValue: '-Infinity' };
137
+ }
138
+ if (Object.is(arg, NaN)) {
139
+ return { unserializableValue: 'NaN' };
140
+ }
141
+ const objectHandle = arg && arg instanceof JSHandle_1.JSHandle ? arg : null;
142
+ if (objectHandle) {
143
+ if (objectHandle._context !== this) {
144
+ throw new Error('JSHandles can be evaluated only in the context they were created!');
129
145
  }
130
- if (Object.is(arg, -Infinity)) {
131
- return { unserializableValue: '-Infinity' };
146
+ if (objectHandle._disposed) {
147
+ throw new Error('JSHandle is disposed!');
132
148
  }
133
- if (Object.is(arg, NaN)) {
134
- return { unserializableValue: 'NaN' };
149
+ if (objectHandle._remoteObject.unserializableValue) {
150
+ return {
151
+ unserializableValue: objectHandle._remoteObject.unserializableValue,
152
+ };
135
153
  }
136
- const objectHandle = arg && arg instanceof JSHandle_1.JSHandle ? arg : null;
137
- if (objectHandle) {
138
- if (objectHandle._context !== this) {
139
- throw new Error('JSHandles can be evaluated only in the context they were created!');
140
- }
141
- if (objectHandle._disposed) {
142
- throw new Error('JSHandle is disposed!');
143
- }
144
- if (objectHandle._remoteObject.unserializableValue) {
145
- return {
146
- unserializableValue: objectHandle._remoteObject.unserializableValue,
147
- };
148
- }
149
- if (!objectHandle._remoteObject.objectId) {
150
- return { value: objectHandle._remoteObject.value };
151
- }
152
- return { objectId: objectHandle._remoteObject.objectId };
154
+ if (!objectHandle._remoteObject.objectId) {
155
+ return { value: objectHandle._remoteObject.value };
153
156
  }
154
- return { value: arg };
157
+ return { objectId: objectHandle._remoteObject.objectId };
155
158
  }
156
- function rewriteError(error) {
157
- if (error.message.includes('Object reference chain is too long')) {
158
- return { value: { result: { type: 'undefined' } }, size: 1 };
159
- }
160
- if (error.message.includes("Object couldn't be returned by value")) {
161
- return { value: { result: { type: 'undefined' } }, size: 1 };
162
- }
163
- if (error.message.endsWith('Cannot find context with specified id') ||
164
- error.message.endsWith('Inspected target navigated or closed')) {
165
- throw new Error('Execution context was destroyed, most likely because of a navigation.');
166
- }
167
- throw error;
159
+ return { value: arg };
160
+ }
161
+ function rewriteError(error) {
162
+ if (error.message.includes('Object reference chain is too long')) {
163
+ return { value: { result: { type: 'undefined' } }, size: 1 };
168
164
  }
165
+ if (error.message.includes("Object couldn't be returned by value")) {
166
+ return { value: { result: { type: 'undefined' } }, size: 1 };
167
+ }
168
+ if (error.message.endsWith('Cannot find context with specified id') ||
169
+ error.message.endsWith('Inspected target navigated or closed')) {
170
+ throw new Error('Execution context was destroyed, most likely because of a navigation.');
171
+ }
172
+ throw error;
169
173
  }
170
- }
171
- exports.ExecutionContext = ExecutionContext;
174
+ };