@remotion/renderer 4.0.405 → 4.0.407

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 (181) hide show
  1. package/dist/assets/apply-tone-frequency.d.ts +1 -2
  2. package/dist/assets/convert-assets-to-file-urls.d.ts +1 -2
  3. package/dist/assets/download-and-map-assets-to-file.d.ts +2 -3
  4. package/dist/assets/download-and-map-assets-to-file.js +1 -0
  5. package/dist/assets/download-file.d.ts +1 -0
  6. package/dist/assets/download-file.js +16 -1
  7. package/dist/assets/download-map.d.ts +1 -0
  8. package/dist/assets/download-map.js +2 -0
  9. package/dist/assets/get-audio-channels.d.ts +2 -3
  10. package/dist/assets/inline-audio-mixing.d.ts +1 -2
  11. package/dist/browser/Browser.d.ts +5 -5
  12. package/dist/browser/Browser.js +65 -74
  13. package/dist/browser/BrowserFetcher.d.ts +3 -5
  14. package/dist/browser/BrowserFetcher.js +1 -0
  15. package/dist/browser/BrowserPage.d.ts +4 -4
  16. package/dist/browser/BrowserPage.js +223 -218
  17. package/dist/browser/BrowserRunner.d.ts +1 -2
  18. package/dist/browser/Connection.js +99 -112
  19. package/dist/browser/ConsoleMessage.d.ts +1 -1
  20. package/dist/browser/ConsoleMessage.js +9 -16
  21. package/dist/browser/DOMWorld.d.ts +1 -1
  22. package/dist/browser/DOMWorld.js +75 -89
  23. package/dist/browser/Errors.js +2 -4
  24. package/dist/browser/EventEmitter.js +2 -1
  25. package/dist/browser/ExecutionContext.js +117 -120
  26. package/dist/browser/FrameManager.js +249 -244
  27. package/dist/browser/HTTPRequest.js +11 -22
  28. package/dist/browser/HTTPResponse.js +3 -16
  29. package/dist/browser/JSHandle.js +17 -30
  30. package/dist/browser/LifecycleWatcher.js +122 -128
  31. package/dist/browser/NetworkEventManager.js +31 -40
  32. package/dist/browser/NetworkManager.js +210 -203
  33. package/dist/browser/NodeWebSocketTransport.js +3 -0
  34. package/dist/browser/Target.d.ts +1 -1
  35. package/dist/browser/Target.js +32 -39
  36. package/dist/browser/TaskQueue.js +5 -18
  37. package/dist/browser/TimeoutSettings.js +12 -25
  38. package/dist/browser/browser-download-progress-bar.d.ts +1 -2
  39. package/dist/browser/handle-failed-resource.d.ts +1 -2
  40. package/dist/browser/handle-failed-resource.js +4 -3
  41. package/dist/call-ffmpeg.d.ts +4 -5
  42. package/dist/can-concat-seamlessly.d.ts +2 -4
  43. package/dist/can-use-parallel-encoding.d.ts +1 -2
  44. package/dist/check-version-requirements.d.ts +1 -2
  45. package/dist/client.d.ts +181 -181
  46. package/dist/codec-supports-media.d.ts +3 -4
  47. package/dist/collect-assets.d.ts +1 -1
  48. package/dist/combine-audio.d.ts +2 -4
  49. package/dist/combine-chunks.d.ts +1 -2
  50. package/dist/combine-video-streams.d.ts +2 -4
  51. package/dist/compositor/compositor.d.ts +2 -3
  52. package/dist/compositor/get-executable-path.d.ts +3 -3
  53. package/dist/compress-audio.d.ts +2 -4
  54. package/dist/create-audio.d.ts +2 -4
  55. package/dist/create-silent-audio.d.ts +1 -2
  56. package/dist/crf.d.ts +4 -6
  57. package/dist/cycle-browser-tabs.d.ts +1 -2
  58. package/dist/ensure-browser.d.ts +44 -1
  59. package/dist/error-handling/handle-javascript-exception.d.ts +1 -1
  60. package/dist/error-handling/handle-javascript-exception.js +7 -1
  61. package/dist/error-handling/symbolicateable-error.d.ts +1 -1
  62. package/dist/error-handling/symbolicateable-error.js +4 -0
  63. package/dist/error-handling.js +1 -1
  64. package/dist/esm/client.mjs +7 -2
  65. package/dist/esm/index.mjs +28 -4
  66. package/dist/extract-audio.d.ts +2 -3
  67. package/dist/ffmpeg-args.d.ts +6 -12
  68. package/dist/get-browser-instance.d.ts +4 -6
  69. package/dist/get-codec-name.d.ts +3 -6
  70. package/dist/get-compositions.d.ts +1 -1
  71. package/dist/get-concurrency.d.ts +1 -1
  72. package/dist/get-extension-from-codec.d.ts +2 -3
  73. package/dist/get-frame-padded-index.d.ts +1 -2
  74. package/dist/get-local-browser-executable.d.ts +2 -4
  75. package/dist/get-prores-profile-name.d.ts +1 -3
  76. package/dist/get-silent-parts.d.ts +4 -5
  77. package/dist/get-video-metadata.d.ts +3 -4
  78. package/dist/get-video-threads-flag.d.ts +1 -2
  79. package/dist/goto-page-or-throw.d.ts +1 -1
  80. package/dist/guess-extension-for-media.d.ts +2 -3
  81. package/dist/image-format.d.ts +2 -3
  82. package/dist/index.d.ts +173 -172
  83. package/dist/index.js +16 -16
  84. package/dist/is-audio-codec.d.ts +1 -2
  85. package/dist/log-level.d.ts +1 -1
  86. package/dist/logger.d.ts +6 -6
  87. package/dist/make-page.d.ts +2 -4
  88. package/dist/memory/from-proc-meminfo.d.ts +1 -2
  89. package/dist/memory/get-available-memory.d.ts +1 -2
  90. package/dist/mime-types.js +2 -1
  91. package/dist/mux-video-and-audio.d.ts +2 -3
  92. package/dist/offthread-video-server.d.ts +1 -2
  93. package/dist/offthread-video-server.js +4 -6
  94. package/dist/open-browser.d.ts +1 -1
  95. package/dist/open-browser.js +6 -5
  96. package/dist/options/api-key.js +3 -1
  97. package/dist/options/audio-bitrate.js +9 -1
  98. package/dist/options/audio-codec.d.ts +10 -13
  99. package/dist/options/beep-on-finish.js +1 -1
  100. package/dist/options/binaries-directory.js +9 -1
  101. package/dist/options/chrome-mode.d.ts +3 -3
  102. package/dist/options/chrome-mode.js +6 -1
  103. package/dist/options/color-space.d.ts +5 -9
  104. package/dist/options/color-space.js +7 -1
  105. package/dist/options/crf.js +1 -1
  106. package/dist/options/cross-site-isolation.js +2 -1
  107. package/dist/options/dark-mode.js +2 -1
  108. package/dist/options/delete-after.js +11 -1
  109. package/dist/options/disallow-parallel-encoding.js +1 -1
  110. package/dist/options/enable-lambda-insights.js +2 -1
  111. package/dist/options/enable-multiprocess-on-linux.js +13 -1
  112. package/dist/options/encoding-buffer-size.js +3 -1
  113. package/dist/options/encoding-max-rate.js +3 -1
  114. package/dist/options/enforce-audio.js +1 -1
  115. package/dist/options/folder-expiry.js +4 -1
  116. package/dist/options/for-seamless-aac-concatenation.js +3 -1
  117. package/dist/options/gl.d.ts +6 -6
  118. package/dist/options/gl.js +28 -2
  119. package/dist/options/hardware-acceleration.d.ts +2 -2
  120. package/dist/options/headless.js +4 -1
  121. package/dist/options/image-sequence-pattern.js +5 -1
  122. package/dist/options/index.d.ts +25 -25
  123. package/dist/options/jpeg-quality.js +1 -1
  124. package/dist/options/latency-hint.js +10 -1
  125. package/dist/options/license-key.js +2 -1
  126. package/dist/options/log-level.d.ts +3 -4
  127. package/dist/options/log-level.js +16 -1
  128. package/dist/options/metadata.js +7 -2
  129. package/dist/options/mute.js +1 -1
  130. package/dist/options/number-of-gif-loops.js +13 -1
  131. package/dist/options/offthreadvideo-cache-size.js +11 -1
  132. package/dist/options/offthreadvideo-threads.js +2 -1
  133. package/dist/options/on-browser-download.js +2 -1
  134. package/dist/options/options-map.d.ts +93 -93
  135. package/dist/options/overwrite.js +5 -1
  136. package/dist/options/prefer-lossless.js +4 -1
  137. package/dist/options/public-dir.js +2 -1
  138. package/dist/options/public-license-key.js +3 -1
  139. package/dist/options/public-path.js +7 -1
  140. package/dist/options/repro.js +1 -1
  141. package/dist/options/scale.js +5 -1
  142. package/dist/options/timeout.js +4 -1
  143. package/dist/options/video-bitrate.js +7 -1
  144. package/dist/options/video-cache-size.js +8 -1
  145. package/dist/options/video-codec.d.ts +6 -6
  146. package/dist/options/video-codec.js +1 -1
  147. package/dist/options/webhook-custom-data.js +1 -1
  148. package/dist/options/x264-preset.d.ts +5 -6
  149. package/dist/options/x264-preset.js +23 -1
  150. package/dist/p-limit.d.ts +1 -1
  151. package/dist/pixel-format.d.ts +2 -3
  152. package/dist/pool.js +2 -0
  153. package/dist/port-config.d.ts +5 -6
  154. package/dist/prespawn-ffmpeg.js +5 -4
  155. package/dist/prestitcher-memory-usage.d.ts +1 -2
  156. package/dist/print-useful-error-message.d.ts +1 -2
  157. package/dist/prores-profile.d.ts +2 -4
  158. package/dist/puppeteer-evaluate.d.ts +2 -2
  159. package/dist/puppeteer-screenshot.d.ts +3 -4
  160. package/dist/pure.d.ts +5 -5
  161. package/dist/render-frame-and-retry-target-close.d.ts +8 -8
  162. package/dist/render-frame-with-option-to-reject.d.ts +4 -6
  163. package/dist/render-frame.d.ts +8 -8
  164. package/dist/render-has-audio.d.ts +2 -3
  165. package/dist/render-media.js +2 -1
  166. package/dist/replace-browser.d.ts +1 -2
  167. package/dist/repro.d.ts +1 -1
  168. package/dist/screenshot-task.d.ts +3 -4
  169. package/dist/seek-to-frame.d.ts +2 -3
  170. package/dist/serve-handler/index.d.ts +1 -1
  171. package/dist/serve-handler/range-parser.d.ts +2 -2
  172. package/dist/serve-static.d.ts +1 -2
  173. package/dist/set-props-and-env.js +3 -1
  174. package/dist/stringify-ffmpeg-filter.d.ts +1 -2
  175. package/dist/take-frame.d.ts +1 -2
  176. package/dist/test-gpu.d.ts +2 -4
  177. package/dist/validate-even-dimensions-with-codec.d.ts +2 -4
  178. package/dist/validate-ffmpeg-override.d.ts +1 -1
  179. package/dist/validate-number-of-gif-loops.d.ts +1 -2
  180. package/dist/validate-output-filename.d.ts +2 -4
  181. package/package.json +16 -14
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
- 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");
5
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
- };
7
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
- if (kind === "m") throw new TypeError("Private method is not writable");
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
- };
13
- var _Connection_instances, _Connection_lastId, _Connection_sessions, _Connection_closed, _Connection_callbacks, _Connection_onMessage, _Connection_onClose, _CDPSession_sessionId, _CDPSession_targetType, _CDPSession_callbacks, _CDPSession_connection;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.CDPSession = exports.CDPSessionEmittedEvents = exports.Connection = void 0;
16
4
  /**
@@ -35,22 +23,22 @@ const ConnectionEmittedEvents = {
35
23
  Disconnected: Symbol('Connection.Disconnected'),
36
24
  };
37
25
  class Connection extends EventEmitter_1.EventEmitter {
26
+ transport;
27
+ #lastId = 0;
28
+ #sessions = new Map();
29
+ #closed = false;
30
+ #callbacks = new Map();
38
31
  constructor(transport) {
39
32
  super();
40
- _Connection_instances.add(this);
41
- _Connection_lastId.set(this, 0);
42
- _Connection_sessions.set(this, new Map());
43
- _Connection_closed.set(this, false);
44
- _Connection_callbacks.set(this, new Map());
45
33
  this.transport = transport;
46
- this.transport.onmessage = __classPrivateFieldGet(this, _Connection_instances, "m", _Connection_onMessage).bind(this);
47
- this.transport.onclose = __classPrivateFieldGet(this, _Connection_instances, "m", _Connection_onClose).bind(this);
34
+ this.transport.onmessage = this.#onMessage.bind(this);
35
+ this.transport.onclose = this.#onClose.bind(this);
48
36
  }
49
37
  static fromSession(session) {
50
38
  return session.connection();
51
39
  }
52
40
  session(sessionId) {
53
- return __classPrivateFieldGet(this, _Connection_sessions, "f").get(sessionId) || null;
41
+ return this.#sessions.get(sessionId) || null;
54
42
  }
55
43
  send(method, ...paramArgs) {
56
44
  // There is only ever 1 param arg passed, but the Protocol defines it as an
@@ -63,7 +51,7 @@ class Connection extends EventEmitter_1.EventEmitter {
63
51
  const id = this._rawSend({ method, params });
64
52
  return new Promise((resolve, reject) => {
65
53
  var _a;
66
- __classPrivateFieldGet(this, _Connection_callbacks, "f").set(id, {
54
+ this.#callbacks.set(id, {
67
55
  resolve,
68
56
  reject,
69
57
  method,
@@ -74,14 +62,79 @@ class Connection extends EventEmitter_1.EventEmitter {
74
62
  });
75
63
  }
76
64
  _rawSend(message) {
77
- var _a;
78
- const id = __classPrivateFieldSet(this, _Connection_lastId, (_a = __classPrivateFieldGet(this, _Connection_lastId, "f"), ++_a), "f");
65
+ const id = ++this.#lastId;
79
66
  const stringifiedMessage = JSON.stringify({ ...message, id });
80
67
  this.transport.send(stringifiedMessage);
81
68
  return id;
82
69
  }
70
+ #onMessage(message) {
71
+ const object = JSON.parse(message);
72
+ if (object.method === 'Target.attachedToTarget') {
73
+ const { sessionId } = object.params;
74
+ const session = new CDPSession(this, object.params.targetInfo.type, sessionId);
75
+ this.#sessions.set(sessionId, session);
76
+ this.emit('sessionattached', session);
77
+ const parentSession = this.#sessions.get(object.sessionId);
78
+ if (parentSession) {
79
+ parentSession.emit('sessionattached', session);
80
+ }
81
+ }
82
+ else if (object.method === 'Target.detachedFromTarget') {
83
+ const session = this.#sessions.get(object.params.sessionId);
84
+ if (session) {
85
+ session._onClosed();
86
+ this.#sessions.delete(object.params.sessionId);
87
+ this.emit('sessiondetached', session);
88
+ const parentSession = this.#sessions.get(object.sessionId);
89
+ if (parentSession) {
90
+ parentSession.emit('sessiondetached', session);
91
+ }
92
+ }
93
+ }
94
+ if (object.sessionId) {
95
+ const session = this.#sessions.get(object.sessionId);
96
+ if (session) {
97
+ session._onMessage(object, message.length);
98
+ }
99
+ }
100
+ else if (object.id) {
101
+ const callback = this.#callbacks.get(object.id);
102
+ // Callbacks could be all rejected if someone has called `.dispose()`.
103
+ if (callback) {
104
+ this.#callbacks.delete(object.id);
105
+ if (object.error) {
106
+ callback.reject(createProtocolError(callback.method, object));
107
+ }
108
+ else if (callback.returnSize) {
109
+ callback.resolve({ value: object.result, size: message.length });
110
+ }
111
+ else {
112
+ callback.resolve(object.result);
113
+ }
114
+ }
115
+ }
116
+ else {
117
+ this.emit(object.method, object.params);
118
+ }
119
+ }
120
+ #onClose() {
121
+ if (this.#closed) {
122
+ return;
123
+ }
124
+ this.transport.onmessage = undefined;
125
+ this.transport.onclose = undefined;
126
+ for (const callback of this.#callbacks.values()) {
127
+ callback.reject(rewriteError(new Errors_1.ProtocolError(), `Protocol error (${callback.method}): Target closed. https://www.remotion.dev/docs/target-closed`));
128
+ }
129
+ this.#callbacks.clear();
130
+ for (const session of this.#sessions.values()) {
131
+ session._onClosed();
132
+ }
133
+ this.#sessions.clear();
134
+ this.emit(ConnectionEmittedEvents.Disconnected);
135
+ }
83
136
  dispose() {
84
- __classPrivateFieldGet(this, _Connection_instances, "m", _Connection_onClose).call(this);
137
+ this.#onClose();
85
138
  this.transport.close();
86
139
  }
87
140
  /**
@@ -93,7 +146,7 @@ class Connection extends EventEmitter_1.EventEmitter {
93
146
  targetId: targetInfo.targetId,
94
147
  flatten: true,
95
148
  });
96
- const session = __classPrivateFieldGet(this, _Connection_sessions, "f").get(sessionId);
149
+ const session = this.#sessions.get(sessionId);
97
150
  if (!session) {
98
151
  throw new Error('CDPSession creation failed.');
99
152
  }
@@ -101,108 +154,43 @@ class Connection extends EventEmitter_1.EventEmitter {
101
154
  }
102
155
  }
103
156
  exports.Connection = Connection;
104
- _Connection_lastId = new WeakMap(), _Connection_sessions = new WeakMap(), _Connection_closed = new WeakMap(), _Connection_callbacks = new WeakMap(), _Connection_instances = new WeakSet(), _Connection_onMessage = function _Connection_onMessage(message) {
105
- const object = JSON.parse(message);
106
- if (object.method === 'Target.attachedToTarget') {
107
- const { sessionId } = object.params;
108
- const session = new CDPSession(this, object.params.targetInfo.type, sessionId);
109
- __classPrivateFieldGet(this, _Connection_sessions, "f").set(sessionId, session);
110
- this.emit('sessionattached', session);
111
- const parentSession = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.sessionId);
112
- if (parentSession) {
113
- parentSession.emit('sessionattached', session);
114
- }
115
- }
116
- else if (object.method === 'Target.detachedFromTarget') {
117
- const session = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.params.sessionId);
118
- if (session) {
119
- session._onClosed();
120
- __classPrivateFieldGet(this, _Connection_sessions, "f").delete(object.params.sessionId);
121
- this.emit('sessiondetached', session);
122
- const parentSession = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.sessionId);
123
- if (parentSession) {
124
- parentSession.emit('sessiondetached', session);
125
- }
126
- }
127
- }
128
- if (object.sessionId) {
129
- const session = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.sessionId);
130
- if (session) {
131
- session._onMessage(object, message.length);
132
- }
133
- }
134
- else if (object.id) {
135
- const callback = __classPrivateFieldGet(this, _Connection_callbacks, "f").get(object.id);
136
- // Callbacks could be all rejected if someone has called `.dispose()`.
137
- if (callback) {
138
- __classPrivateFieldGet(this, _Connection_callbacks, "f").delete(object.id);
139
- if (object.error) {
140
- callback.reject(createProtocolError(callback.method, object));
141
- }
142
- else if (callback.returnSize) {
143
- callback.resolve({ value: object.result, size: message.length });
144
- }
145
- else {
146
- callback.resolve(object.result);
147
- }
148
- }
149
- }
150
- else {
151
- this.emit(object.method, object.params);
152
- }
153
- }, _Connection_onClose = function _Connection_onClose() {
154
- if (__classPrivateFieldGet(this, _Connection_closed, "f")) {
155
- return;
156
- }
157
- this.transport.onmessage = undefined;
158
- this.transport.onclose = undefined;
159
- for (const callback of __classPrivateFieldGet(this, _Connection_callbacks, "f").values()) {
160
- callback.reject(rewriteError(new Errors_1.ProtocolError(), `Protocol error (${callback.method}): Target closed. https://www.remotion.dev/docs/target-closed`));
161
- }
162
- __classPrivateFieldGet(this, _Connection_callbacks, "f").clear();
163
- for (const session of __classPrivateFieldGet(this, _Connection_sessions, "f").values()) {
164
- session._onClosed();
165
- }
166
- __classPrivateFieldGet(this, _Connection_sessions, "f").clear();
167
- this.emit(ConnectionEmittedEvents.Disconnected);
168
- };
169
157
  exports.CDPSessionEmittedEvents = {
170
158
  Disconnected: Symbol('CDPSession.Disconnected'),
171
159
  };
172
160
  class CDPSession extends EventEmitter_1.EventEmitter {
161
+ #sessionId;
162
+ #targetType;
163
+ #callbacks = new Map();
164
+ #connection;
173
165
  constructor(connection, targetType, sessionId) {
174
166
  super();
175
- _CDPSession_sessionId.set(this, void 0);
176
- _CDPSession_targetType.set(this, void 0);
177
- _CDPSession_callbacks.set(this, new Map());
178
- _CDPSession_connection.set(this, void 0);
179
- __classPrivateFieldSet(this, _CDPSession_connection, connection, "f");
180
- __classPrivateFieldSet(this, _CDPSession_targetType, targetType, "f");
181
- __classPrivateFieldSet(this, _CDPSession_sessionId, sessionId, "f");
167
+ this.#connection = connection;
168
+ this.#targetType = targetType;
169
+ this.#sessionId = sessionId;
182
170
  }
183
171
  connection() {
184
- return __classPrivateFieldGet(this, _CDPSession_connection, "f");
172
+ return this.#connection;
185
173
  }
186
174
  send(method, ...paramArgs) {
187
- if (!__classPrivateFieldGet(this, _CDPSession_connection, "f")) {
188
- return Promise.reject(new Error(`Protocol error (${method}): Session closed. Most likely the ${__classPrivateFieldGet(this, _CDPSession_targetType, "f")} has been closed.`));
175
+ if (!this.#connection) {
176
+ return Promise.reject(new Error(`Protocol error (${method}): Session closed. Most likely the ${this.#targetType} has been closed.`));
189
177
  }
190
178
  // See the comment in Connection#send explaining why we do this.
191
179
  const params = paramArgs.length ? paramArgs[0] : undefined;
192
- const id = __classPrivateFieldGet(this, _CDPSession_connection, "f")._rawSend({
193
- sessionId: __classPrivateFieldGet(this, _CDPSession_sessionId, "f"),
180
+ const id = this.#connection._rawSend({
181
+ sessionId: this.#sessionId,
194
182
  method,
195
183
  params,
196
184
  });
197
185
  return new Promise((resolve, reject) => {
198
186
  var _a;
199
- if (__classPrivateFieldGet(this, _CDPSession_callbacks, "f").size > 100) {
200
- for (const callback of __classPrivateFieldGet(this, _CDPSession_callbacks, "f").values()) {
187
+ if (this.#callbacks.size > 100) {
188
+ for (const callback of this.#callbacks.values()) {
201
189
  logger_1.Log.info({ indent: false, logLevel: 'info' }, callback.fn);
202
190
  }
203
191
  throw new Error('Leak detected: Too many callbacks');
204
192
  }
205
- __classPrivateFieldGet(this, _CDPSession_callbacks, "f").set(id, {
193
+ this.#callbacks.set(id, {
206
194
  resolve,
207
195
  reject,
208
196
  method,
@@ -213,9 +201,9 @@ class CDPSession extends EventEmitter_1.EventEmitter {
213
201
  });
214
202
  }
215
203
  _onMessage(object, size) {
216
- const callback = object.id ? __classPrivateFieldGet(this, _CDPSession_callbacks, "f").get(object.id) : undefined;
204
+ const callback = object.id ? this.#callbacks.get(object.id) : undefined;
217
205
  if (object.id && callback) {
218
- __classPrivateFieldGet(this, _CDPSession_callbacks, "f").delete(object.id);
206
+ this.#callbacks.delete(object.id);
219
207
  if (object.error) {
220
208
  callback.reject(createProtocolError(callback.method, object));
221
209
  }
@@ -231,19 +219,18 @@ class CDPSession extends EventEmitter_1.EventEmitter {
231
219
  }
232
220
  }
233
221
  _onClosed() {
234
- __classPrivateFieldSet(this, _CDPSession_connection, undefined, "f");
235
- for (const callback of __classPrivateFieldGet(this, _CDPSession_callbacks, "f").values()) {
222
+ this.#connection = undefined;
223
+ for (const callback of this.#callbacks.values()) {
236
224
  callback.reject(rewriteError(new Errors_1.ProtocolError(), `Protocol error (${callback.method}): Target closed. https://www.remotion.dev/docs/target-closed`));
237
225
  }
238
- __classPrivateFieldGet(this, _CDPSession_callbacks, "f").clear();
226
+ this.#callbacks.clear();
239
227
  this.emit(exports.CDPSessionEmittedEvents.Disconnected);
240
228
  }
241
229
  id() {
242
- return __classPrivateFieldGet(this, _CDPSession_sessionId, "f");
230
+ return this.#sessionId;
243
231
  }
244
232
  }
245
233
  exports.CDPSession = CDPSession;
246
- _CDPSession_sessionId = new WeakMap(), _CDPSession_targetType = new WeakMap(), _CDPSession_callbacks = new WeakMap(), _CDPSession_connection = new WeakMap();
247
234
  function createProtocolError(method, object) {
248
235
  let message = `Protocol error (${method}): ${object.error.message}`;
249
236
  if ('data' in object.error) {
@@ -29,7 +29,7 @@ export declare class ConsoleMessage {
29
29
  previewString: string;
30
30
  logLevel: LogLevel;
31
31
  tag: string | null;
32
- constructor({ type, text, args, stackTraceLocations, previewString, logLevel, tag, }: {
32
+ constructor({ type, text, args, stackTraceLocations, previewString, logLevel, tag }: {
33
33
  type: ConsoleMessageType;
34
34
  text: string;
35
35
  args: JSHandle[];
@@ -14,34 +14,27 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
18
- if (kind === "m") throw new TypeError("Private method is not writable");
19
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
20
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
21
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
22
- };
23
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
24
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
25
- 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");
26
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
27
- };
28
- var _ConsoleMessage_stackTraceLocations;
29
17
  Object.defineProperty(exports, "__esModule", { value: true });
30
18
  exports.ConsoleMessage = void 0;
31
19
  class ConsoleMessage {
20
+ type;
21
+ text;
22
+ args;
23
+ previewString;
24
+ #stackTraceLocations;
25
+ logLevel;
26
+ tag;
32
27
  constructor({ type, text, args, stackTraceLocations, previewString, logLevel, tag, }) {
33
- _ConsoleMessage_stackTraceLocations.set(this, void 0);
34
28
  this.type = type;
35
29
  this.text = text;
36
30
  this.args = args;
37
31
  this.previewString = previewString;
38
- __classPrivateFieldSet(this, _ConsoleMessage_stackTraceLocations, stackTraceLocations, "f");
32
+ this.#stackTraceLocations = stackTraceLocations;
39
33
  this.logLevel = logLevel;
40
34
  this.tag = tag;
41
35
  }
42
36
  stackTrace() {
43
- return __classPrivateFieldGet(this, _ConsoleMessage_stackTraceLocations, "f");
37
+ return this.#stackTraceLocations;
44
38
  }
45
39
  }
46
40
  exports.ConsoleMessage = ConsoleMessage;
47
- _ConsoleMessage_stackTraceLocations = new WeakMap();
@@ -29,7 +29,7 @@ export declare class DOMWorld {
29
29
  executionContext(): Promise<ExecutionContext>;
30
30
  evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>;
31
31
  evaluate<T extends EvaluateFn>(pageFunction: T, ...args: SerializableOrJSHandle[]): Promise<UnwrapPromiseLike<EvaluateFnReturnType<T>>>;
32
- waitForFunction({ browser, timeout, pageFunction, title, }: {
32
+ waitForFunction({ browser, timeout, pageFunction, title }: {
33
33
  browser: HeadlessBrowser;
34
34
  timeout: number | null;
35
35
  pageFunction: Function | string;
@@ -14,74 +14,62 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
- 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");
20
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
- };
22
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
23
- if (kind === "m") throw new TypeError("Private method is not writable");
24
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
25
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
26
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
27
- };
28
- var _DOMWorld_frame, _DOMWorld_contextPromise, _DOMWorld_contextResolveCallback, _DOMWorld_detached, _DOMWorld_waitTasks, _WaitTask_instances, _WaitTask_domWorld, _WaitTask_timeout, _WaitTask_predicateBody, _WaitTask_args, _WaitTask_runCount, _WaitTask_resolve, _WaitTask_reject, _WaitTask_timeoutTimer, _WaitTask_terminated, _WaitTask_browser, _WaitTask_cleanup;
29
17
  Object.defineProperty(exports, "__esModule", { value: true });
30
18
  exports.DOMWorld = void 0;
31
19
  const assert_1 = require("./assert");
32
20
  const Errors_1 = require("./Errors");
33
21
  const util_1 = require("./util");
34
22
  class DOMWorld {
23
+ #frame;
24
+ #contextPromise = null;
25
+ #contextResolveCallback = null;
26
+ #detached = false;
27
+ #waitTasks = new Set();
35
28
  get _waitTasks() {
36
- return __classPrivateFieldGet(this, _DOMWorld_waitTasks, "f");
29
+ return this.#waitTasks;
37
30
  }
38
31
  constructor(frame) {
39
- _DOMWorld_frame.set(this, void 0);
40
- _DOMWorld_contextPromise.set(this, null);
41
- _DOMWorld_contextResolveCallback.set(this, null);
42
- _DOMWorld_detached.set(this, false);
43
- _DOMWorld_waitTasks.set(this, new Set());
44
32
  // Keep own reference to client because it might differ from the FrameManager's
45
33
  // client for OOP iframes.
46
- __classPrivateFieldSet(this, _DOMWorld_frame, frame, "f");
34
+ this.#frame = frame;
47
35
  this._setContext(null);
48
36
  }
49
37
  frame() {
50
- return __classPrivateFieldGet(this, _DOMWorld_frame, "f");
38
+ return this.#frame;
51
39
  }
52
40
  _setContext(context) {
53
41
  var _a;
54
42
  if (context) {
55
- (0, assert_1.assert)(__classPrivateFieldGet(this, _DOMWorld_contextResolveCallback, "f"), 'Execution Context has already been set.');
56
- (_a = __classPrivateFieldGet(this, _DOMWorld_contextResolveCallback, "f")) === null || _a === void 0 ? void 0 : _a.call(null, context);
57
- __classPrivateFieldSet(this, _DOMWorld_contextResolveCallback, null, "f");
43
+ (0, assert_1.assert)(this.#contextResolveCallback, 'Execution Context has already been set.');
44
+ (_a = this.#contextResolveCallback) === null || _a === void 0 ? void 0 : _a.call(null, context);
45
+ this.#contextResolveCallback = null;
58
46
  for (const waitTask of this._waitTasks) {
59
47
  waitTask.rerun();
60
48
  }
61
49
  }
62
50
  else {
63
- __classPrivateFieldSet(this, _DOMWorld_contextPromise, new Promise((fulfill) => {
64
- __classPrivateFieldSet(this, _DOMWorld_contextResolveCallback, fulfill, "f");
65
- }), "f");
51
+ this.#contextPromise = new Promise((fulfill) => {
52
+ this.#contextResolveCallback = fulfill;
53
+ });
66
54
  }
67
55
  }
68
56
  _hasContext() {
69
- return !__classPrivateFieldGet(this, _DOMWorld_contextResolveCallback, "f");
57
+ return !this.#contextResolveCallback;
70
58
  }
71
59
  _detach() {
72
- __classPrivateFieldSet(this, _DOMWorld_detached, true, "f");
60
+ this.#detached = true;
73
61
  for (const waitTask of this._waitTasks) {
74
62
  waitTask.terminate(new Error('waitForFunction failed: frame got detached.'));
75
63
  }
76
64
  }
77
65
  executionContext() {
78
- if (__classPrivateFieldGet(this, _DOMWorld_detached, "f")) {
79
- throw new Error(`Execution context is not available in detached frame "${__classPrivateFieldGet(this, _DOMWorld_frame, "f").url()}" (are you trying to evaluate?)`);
66
+ if (this.#detached) {
67
+ throw new Error(`Execution context is not available in detached frame "${this.#frame.url()}" (are you trying to evaluate?)`);
80
68
  }
81
- if (__classPrivateFieldGet(this, _DOMWorld_contextPromise, "f") === null) {
69
+ if (this.#contextPromise === null) {
82
70
  throw new Error(`Execution content promise is missing`);
83
71
  }
84
- return __classPrivateFieldGet(this, _DOMWorld_contextPromise, "f");
72
+ return this.#contextPromise;
85
73
  }
86
74
  async evaluateHandle(pageFunction, ...args) {
87
75
  const context = await this.executionContext();
@@ -103,82 +91,80 @@ class DOMWorld {
103
91
  }
104
92
  }
105
93
  exports.DOMWorld = DOMWorld;
106
- _DOMWorld_frame = new WeakMap(), _DOMWorld_contextPromise = new WeakMap(), _DOMWorld_contextResolveCallback = new WeakMap(), _DOMWorld_detached = new WeakMap(), _DOMWorld_waitTasks = new WeakMap();
107
94
  const noop = () => undefined;
108
95
  class WaitTask {
96
+ #domWorld;
97
+ #timeout;
98
+ #predicateBody;
99
+ #args;
100
+ #runCount = 0;
101
+ #resolve = noop;
102
+ #reject = noop;
103
+ #timeoutTimer;
104
+ #terminated = false;
105
+ #browser;
106
+ promise;
109
107
  constructor(options) {
110
- _WaitTask_instances.add(this);
111
- _WaitTask_domWorld.set(this, void 0);
112
- _WaitTask_timeout.set(this, void 0);
113
- _WaitTask_predicateBody.set(this, void 0);
114
- _WaitTask_args.set(this, void 0);
115
- _WaitTask_runCount.set(this, 0);
116
- _WaitTask_resolve.set(this, noop);
117
- _WaitTask_reject.set(this, noop);
118
- _WaitTask_timeoutTimer.set(this, void 0);
119
- _WaitTask_terminated.set(this, false);
120
- _WaitTask_browser.set(this, void 0);
121
- this.onBrowserClose = () => {
122
- return this.terminate(new Error('Browser was closed'));
123
- };
124
- this.onBrowserCloseSilent = () => {
125
- return this.terminate(null);
126
- };
127
108
  function getPredicateBody(predicateBody) {
128
109
  if ((0, util_1.isString)(predicateBody)) {
129
110
  return `return (${predicateBody});`;
130
111
  }
131
112
  return `return (${predicateBody})(...args);`;
132
113
  }
133
- __classPrivateFieldSet(this, _WaitTask_domWorld, options.domWorld, "f");
134
- __classPrivateFieldSet(this, _WaitTask_timeout, options.timeout, "f");
135
- __classPrivateFieldSet(this, _WaitTask_predicateBody, getPredicateBody(options.predicateBody), "f");
136
- __classPrivateFieldSet(this, _WaitTask_args, options.args, "f");
137
- __classPrivateFieldSet(this, _WaitTask_runCount, 0, "f");
138
- __classPrivateFieldGet(this, _WaitTask_domWorld, "f")._waitTasks.add(this);
114
+ this.#domWorld = options.domWorld;
115
+ this.#timeout = options.timeout;
116
+ this.#predicateBody = getPredicateBody(options.predicateBody);
117
+ this.#args = options.args;
118
+ this.#runCount = 0;
119
+ this.#domWorld._waitTasks.add(this);
139
120
  this.promise = new Promise((resolve, reject) => {
140
- __classPrivateFieldSet(this, _WaitTask_resolve, resolve, "f");
141
- __classPrivateFieldSet(this, _WaitTask_reject, reject, "f");
121
+ this.#resolve = resolve;
122
+ this.#reject = reject;
142
123
  });
143
124
  // Since page navigation requires us to re-install the pageScript, we should track
144
125
  // timeout on our end.
145
126
  if (options.timeout) {
146
127
  const timeoutError = new Errors_1.TimeoutError(`waiting for ${options.title} failed: timeout ${options.timeout}ms exceeded`);
147
- __classPrivateFieldSet(this, _WaitTask_timeoutTimer, setTimeout(() => {
148
- return __classPrivateFieldGet(this, _WaitTask_reject, "f").call(this, timeoutError);
149
- }, options.timeout), "f");
128
+ this.#timeoutTimer = setTimeout(() => {
129
+ return this.#reject(timeoutError);
130
+ }, options.timeout);
150
131
  }
151
- __classPrivateFieldSet(this, _WaitTask_browser, options.browser, "f");
152
- __classPrivateFieldGet(this, _WaitTask_browser, "f").on("closed" /* BrowserEmittedEvents.Closed */, this.onBrowserClose);
153
- __classPrivateFieldGet(this, _WaitTask_browser, "f").on("closed-silent" /* BrowserEmittedEvents.ClosedSilent */, this.onBrowserCloseSilent);
132
+ this.#browser = options.browser;
133
+ this.#browser.on("closed" /* BrowserEmittedEvents.Closed */, this.onBrowserClose);
134
+ this.#browser.on("closed-silent" /* BrowserEmittedEvents.ClosedSilent */, this.onBrowserCloseSilent);
154
135
  this.rerun();
155
136
  }
137
+ onBrowserClose = () => {
138
+ return this.terminate(new Error('Browser was closed'));
139
+ };
140
+ onBrowserCloseSilent = () => {
141
+ return this.terminate(null);
142
+ };
156
143
  terminate(error) {
157
- __classPrivateFieldSet(this, _WaitTask_terminated, true, "f");
144
+ this.#terminated = true;
158
145
  if (error) {
159
- __classPrivateFieldGet(this, _WaitTask_reject, "f").call(this, error);
146
+ this.#reject(error);
160
147
  }
161
- __classPrivateFieldGet(this, _WaitTask_instances, "m", _WaitTask_cleanup).call(this);
148
+ this.#cleanup();
162
149
  }
163
150
  async rerun() {
164
- var _a;
165
- const runCount = __classPrivateFieldSet(this, _WaitTask_runCount, (_a = __classPrivateFieldGet(this, _WaitTask_runCount, "f"), ++_a), "f");
151
+ const runCount = ++this.#runCount;
166
152
  let success = null;
167
153
  let error = null;
168
- const context = await __classPrivateFieldGet(this, _WaitTask_domWorld, "f").executionContext();
169
- if (__classPrivateFieldGet(this, _WaitTask_terminated, "f") || runCount !== __classPrivateFieldGet(this, _WaitTask_runCount, "f")) {
154
+ const context = await this.#domWorld.executionContext();
155
+ if (this.#terminated || runCount !== this.#runCount) {
170
156
  return;
171
157
  }
172
- if (__classPrivateFieldGet(this, _WaitTask_terminated, "f") || runCount !== __classPrivateFieldGet(this, _WaitTask_runCount, "f")) {
158
+ if (this.#terminated || runCount !== this.#runCount) {
173
159
  return;
174
160
  }
175
161
  try {
176
- success = await context.evaluateHandle(waitForPredicatePageFunction, __classPrivateFieldGet(this, _WaitTask_predicateBody, "f"), __classPrivateFieldGet(this, _WaitTask_timeout, "f"), ...__classPrivateFieldGet(this, _WaitTask_args, "f"));
162
+ success = await context.evaluateHandle(waitForPredicatePageFunction, this.#predicateBody, this.#timeout, ...this.#args);
177
163
  }
178
164
  catch (error_) {
179
165
  error = error_;
180
166
  }
181
- if (__classPrivateFieldGet(this, _WaitTask_terminated, "f") || runCount !== __classPrivateFieldGet(this, _WaitTask_runCount, "f")) {
167
+ if (this.#terminated || runCount !== this.#runCount) {
182
168
  if (success) {
183
169
  await success.dispose();
184
170
  }
@@ -188,7 +174,7 @@ class WaitTask {
188
174
  // If the frame's execution context has already changed, `frame.evaluate` will
189
175
  // throw an error - ignore this predicate run altogether.
190
176
  if (!error &&
191
- (await __classPrivateFieldGet(this, _WaitTask_domWorld, "f")
177
+ (await this.#domWorld
192
178
  .evaluate((s) => {
193
179
  return !s;
194
180
  }, success)
@@ -222,28 +208,28 @@ class WaitTask {
222
208
  if (error.message.includes('Cannot find context with specified id')) {
223
209
  return;
224
210
  }
225
- __classPrivateFieldGet(this, _WaitTask_reject, "f").call(this, error);
211
+ this.#reject(error);
226
212
  }
227
213
  else {
228
214
  if (!success) {
229
215
  throw new Error('Assertion: result handle is not available');
230
216
  }
231
- __classPrivateFieldGet(this, _WaitTask_resolve, "f").call(this, success);
217
+ this.#resolve(success);
232
218
  }
233
- __classPrivateFieldGet(this, _WaitTask_instances, "m", _WaitTask_cleanup).call(this);
234
- }
235
- }
236
- _WaitTask_domWorld = new WeakMap(), _WaitTask_timeout = new WeakMap(), _WaitTask_predicateBody = new WeakMap(), _WaitTask_args = new WeakMap(), _WaitTask_runCount = new WeakMap(), _WaitTask_resolve = new WeakMap(), _WaitTask_reject = new WeakMap(), _WaitTask_timeoutTimer = new WeakMap(), _WaitTask_terminated = new WeakMap(), _WaitTask_browser = new WeakMap(), _WaitTask_instances = new WeakSet(), _WaitTask_cleanup = function _WaitTask_cleanup() {
237
- if (__classPrivateFieldGet(this, _WaitTask_timeoutTimer, "f") !== undefined) {
238
- clearTimeout(__classPrivateFieldGet(this, _WaitTask_timeoutTimer, "f"));
219
+ this.#cleanup();
239
220
  }
240
- __classPrivateFieldGet(this, _WaitTask_browser, "f").off("closed" /* BrowserEmittedEvents.Closed */, this.onBrowserClose);
241
- __classPrivateFieldGet(this, _WaitTask_browser, "f").off("closed-silent" /* BrowserEmittedEvents.ClosedSilent */, this.onBrowserCloseSilent);
242
- if (__classPrivateFieldGet(this, _WaitTask_domWorld, "f")._waitTasks.size > 100) {
243
- throw new Error('Leak detected: Too many WaitTasks');
221
+ #cleanup() {
222
+ if (this.#timeoutTimer !== undefined) {
223
+ clearTimeout(this.#timeoutTimer);
224
+ }
225
+ this.#browser.off("closed" /* BrowserEmittedEvents.Closed */, this.onBrowserClose);
226
+ this.#browser.off("closed-silent" /* BrowserEmittedEvents.ClosedSilent */, this.onBrowserCloseSilent);
227
+ if (this.#domWorld._waitTasks.size > 100) {
228
+ throw new Error('Leak detected: Too many WaitTasks');
229
+ }
230
+ this.#domWorld._waitTasks.delete(this);
244
231
  }
245
- __classPrivateFieldGet(this, _WaitTask_domWorld, "f")._waitTasks.delete(this);
246
- };
232
+ }
247
233
  function waitForPredicatePageFunction(predicateBody, timeout, ...args) {
248
234
  // eslint-disable-next-line no-new-func
249
235
  const predicate = new Function('...args', predicateBody);
@@ -27,9 +27,7 @@ class TimeoutError extends CustomError {
27
27
  }
28
28
  exports.TimeoutError = TimeoutError;
29
29
  class ProtocolError extends CustomError {
30
- constructor() {
31
- super(...arguments);
32
- this.originalMessage = '';
33
- }
30
+ code;
31
+ originalMessage = '';
34
32
  }
35
33
  exports.ProtocolError = ProtocolError;