@remotion/renderer 4.0.405 → 4.0.406
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/assets/apply-tone-frequency.d.ts +1 -2
- package/dist/assets/convert-assets-to-file-urls.d.ts +1 -2
- package/dist/assets/download-and-map-assets-to-file.d.ts +2 -3
- package/dist/assets/download-and-map-assets-to-file.js +1 -0
- package/dist/assets/download-file.d.ts +1 -0
- package/dist/assets/download-file.js +17 -1
- package/dist/assets/download-map.d.ts +1 -0
- package/dist/assets/download-map.js +2 -0
- package/dist/assets/get-audio-channels.d.ts +2 -3
- package/dist/assets/inline-audio-mixing.d.ts +1 -2
- package/dist/browser/Browser.d.ts +5 -5
- package/dist/browser/Browser.js +65 -74
- package/dist/browser/BrowserFetcher.d.ts +3 -5
- package/dist/browser/BrowserFetcher.js +1 -0
- package/dist/browser/BrowserPage.d.ts +4 -4
- package/dist/browser/BrowserPage.js +223 -218
- package/dist/browser/BrowserRunner.d.ts +1 -2
- package/dist/browser/Connection.js +99 -112
- package/dist/browser/ConsoleMessage.d.ts +1 -1
- package/dist/browser/ConsoleMessage.js +9 -16
- package/dist/browser/DOMWorld.d.ts +1 -1
- package/dist/browser/DOMWorld.js +75 -89
- package/dist/browser/Errors.js +2 -4
- package/dist/browser/EventEmitter.js +2 -1
- package/dist/browser/ExecutionContext.js +117 -120
- package/dist/browser/FrameManager.js +249 -244
- package/dist/browser/HTTPRequest.js +11 -22
- package/dist/browser/HTTPResponse.js +3 -16
- package/dist/browser/JSHandle.js +17 -30
- package/dist/browser/LifecycleWatcher.js +122 -128
- package/dist/browser/NetworkEventManager.js +31 -40
- package/dist/browser/NetworkManager.js +210 -203
- package/dist/browser/NodeWebSocketTransport.js +3 -0
- package/dist/browser/Target.d.ts +1 -1
- package/dist/browser/Target.js +32 -39
- package/dist/browser/TaskQueue.js +5 -18
- package/dist/browser/TimeoutSettings.js +12 -25
- package/dist/browser/browser-download-progress-bar.d.ts +1 -2
- package/dist/browser/handle-failed-resource.d.ts +1 -2
- package/dist/browser/handle-failed-resource.js +4 -3
- package/dist/call-ffmpeg.d.ts +4 -5
- package/dist/can-concat-seamlessly.d.ts +2 -4
- package/dist/can-use-parallel-encoding.d.ts +1 -2
- package/dist/check-version-requirements.d.ts +1 -2
- package/dist/client.d.ts +181 -181
- package/dist/codec-supports-media.d.ts +3 -4
- package/dist/collect-assets.d.ts +1 -1
- package/dist/combine-audio.d.ts +2 -4
- package/dist/combine-chunks.d.ts +1 -2
- package/dist/combine-video-streams.d.ts +2 -4
- package/dist/compositor/compositor.d.ts +2 -3
- package/dist/compositor/get-executable-path.d.ts +3 -3
- package/dist/compress-audio.d.ts +2 -4
- package/dist/create-audio.d.ts +2 -4
- package/dist/create-silent-audio.d.ts +1 -2
- package/dist/crf.d.ts +4 -6
- package/dist/cycle-browser-tabs.d.ts +1 -2
- package/dist/ensure-browser.d.ts +44 -1
- package/dist/error-handling/handle-javascript-exception.d.ts +1 -1
- package/dist/error-handling/handle-javascript-exception.js +7 -1
- package/dist/error-handling/symbolicateable-error.d.ts +1 -1
- package/dist/error-handling/symbolicateable-error.js +4 -0
- package/dist/error-handling.js +1 -1
- package/dist/esm/client.mjs +7 -2
- package/dist/esm/index.mjs +28 -4
- package/dist/extract-audio.d.ts +2 -3
- package/dist/ffmpeg-args.d.ts +6 -12
- package/dist/get-browser-instance.d.ts +4 -6
- package/dist/get-codec-name.d.ts +3 -6
- package/dist/get-compositions.d.ts +1 -1
- package/dist/get-concurrency.d.ts +1 -1
- package/dist/get-extension-from-codec.d.ts +2 -3
- package/dist/get-frame-padded-index.d.ts +1 -2
- package/dist/get-local-browser-executable.d.ts +2 -4
- package/dist/get-prores-profile-name.d.ts +1 -3
- package/dist/get-silent-parts.d.ts +4 -5
- package/dist/get-video-metadata.d.ts +3 -4
- package/dist/get-video-threads-flag.d.ts +1 -2
- package/dist/goto-page-or-throw.d.ts +1 -1
- package/dist/guess-extension-for-media.d.ts +2 -3
- package/dist/image-format.d.ts +2 -3
- package/dist/index.d.ts +173 -172
- package/dist/index.js +16 -16
- package/dist/is-audio-codec.d.ts +1 -2
- package/dist/log-level.d.ts +1 -1
- package/dist/logger.d.ts +6 -6
- package/dist/make-page.d.ts +2 -4
- package/dist/memory/from-proc-meminfo.d.ts +1 -2
- package/dist/memory/get-available-memory.d.ts +1 -2
- package/dist/mime-types.js +2 -1
- package/dist/mux-video-and-audio.d.ts +2 -3
- package/dist/offthread-video-server.d.ts +1 -2
- package/dist/offthread-video-server.js +4 -6
- package/dist/open-browser.d.ts +1 -1
- package/dist/open-browser.js +6 -5
- package/dist/options/api-key.js +3 -1
- package/dist/options/audio-bitrate.js +9 -1
- package/dist/options/audio-codec.d.ts +10 -13
- package/dist/options/beep-on-finish.js +1 -1
- package/dist/options/binaries-directory.js +9 -1
- package/dist/options/chrome-mode.d.ts +3 -3
- package/dist/options/chrome-mode.js +6 -1
- package/dist/options/color-space.d.ts +5 -9
- package/dist/options/color-space.js +7 -1
- package/dist/options/crf.js +1 -1
- package/dist/options/cross-site-isolation.js +2 -1
- package/dist/options/dark-mode.js +2 -1
- package/dist/options/delete-after.js +11 -1
- package/dist/options/disallow-parallel-encoding.js +1 -1
- package/dist/options/enable-lambda-insights.js +2 -1
- package/dist/options/enable-multiprocess-on-linux.js +13 -1
- package/dist/options/encoding-buffer-size.js +3 -1
- package/dist/options/encoding-max-rate.js +3 -1
- package/dist/options/enforce-audio.js +1 -1
- package/dist/options/folder-expiry.js +4 -1
- package/dist/options/for-seamless-aac-concatenation.js +3 -1
- package/dist/options/gl.d.ts +6 -6
- package/dist/options/gl.js +28 -2
- package/dist/options/hardware-acceleration.d.ts +2 -2
- package/dist/options/headless.js +4 -1
- package/dist/options/image-sequence-pattern.js +5 -1
- package/dist/options/index.d.ts +25 -25
- package/dist/options/jpeg-quality.js +1 -1
- package/dist/options/latency-hint.js +10 -1
- package/dist/options/license-key.js +2 -1
- package/dist/options/log-level.d.ts +3 -4
- package/dist/options/log-level.js +16 -1
- package/dist/options/metadata.js +7 -2
- package/dist/options/mute.js +1 -1
- package/dist/options/number-of-gif-loops.js +13 -1
- package/dist/options/offthreadvideo-cache-size.js +11 -1
- package/dist/options/offthreadvideo-threads.js +2 -1
- package/dist/options/on-browser-download.js +2 -1
- package/dist/options/options-map.d.ts +93 -93
- package/dist/options/overwrite.js +5 -1
- package/dist/options/prefer-lossless.js +4 -1
- package/dist/options/public-dir.js +2 -1
- package/dist/options/public-license-key.js +3 -1
- package/dist/options/public-path.js +7 -1
- package/dist/options/repro.js +1 -1
- package/dist/options/scale.js +5 -1
- package/dist/options/timeout.js +4 -1
- package/dist/options/video-bitrate.js +7 -1
- package/dist/options/video-cache-size.js +8 -1
- package/dist/options/video-codec.d.ts +6 -6
- package/dist/options/video-codec.js +1 -1
- package/dist/options/webhook-custom-data.js +1 -1
- package/dist/options/x264-preset.d.ts +5 -6
- package/dist/options/x264-preset.js +23 -1
- package/dist/p-limit.d.ts +1 -1
- package/dist/pixel-format.d.ts +2 -3
- package/dist/pool.js +2 -0
- package/dist/port-config.d.ts +5 -6
- package/dist/prespawn-ffmpeg.js +5 -4
- package/dist/prestitcher-memory-usage.d.ts +1 -2
- package/dist/print-useful-error-message.d.ts +1 -2
- package/dist/prores-profile.d.ts +2 -4
- package/dist/puppeteer-evaluate.d.ts +2 -2
- package/dist/puppeteer-screenshot.d.ts +3 -4
- package/dist/pure.d.ts +5 -5
- package/dist/render-frame-and-retry-target-close.d.ts +8 -8
- package/dist/render-frame-with-option-to-reject.d.ts +4 -6
- package/dist/render-frame.d.ts +8 -8
- package/dist/render-has-audio.d.ts +2 -3
- package/dist/render-media.js +2 -1
- package/dist/replace-browser.d.ts +1 -2
- package/dist/repro.d.ts +1 -1
- package/dist/screenshot-task.d.ts +3 -4
- package/dist/seek-to-frame.d.ts +2 -3
- package/dist/serve-handler/index.d.ts +1 -1
- package/dist/serve-handler/range-parser.d.ts +2 -2
- package/dist/serve-static.d.ts +1 -2
- package/dist/set-props-and-env.js +3 -1
- package/dist/stringify-ffmpeg-filter.d.ts +1 -2
- package/dist/take-frame.d.ts +1 -2
- package/dist/test-gpu.d.ts +2 -4
- package/dist/validate-even-dimensions-with-codec.d.ts +2 -4
- package/dist/validate-ffmpeg-override.d.ts +1 -1
- package/dist/validate-number-of-gif-loops.d.ts +1 -2
- package/dist/validate-output-filename.d.ts +2 -4
- 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 =
|
|
47
|
-
this.transport.onclose =
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
|
172
|
+
return this.#connection;
|
|
185
173
|
}
|
|
186
174
|
send(method, ...paramArgs) {
|
|
187
|
-
if (!
|
|
188
|
-
return Promise.reject(new Error(`Protocol error (${method}): Session closed. Most likely the ${
|
|
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 =
|
|
193
|
-
sessionId:
|
|
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 (
|
|
200
|
-
for (const callback of
|
|
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
|
-
|
|
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 ?
|
|
204
|
+
const callback = object.id ? this.#callbacks.get(object.id) : undefined;
|
|
217
205
|
if (object.id && callback) {
|
|
218
|
-
|
|
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
|
-
|
|
235
|
-
for (const callback of
|
|
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
|
-
|
|
226
|
+
this.#callbacks.clear();
|
|
239
227
|
this.emit(exports.CDPSessionEmittedEvents.Disconnected);
|
|
240
228
|
}
|
|
241
229
|
id() {
|
|
242
|
-
return
|
|
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
|
-
|
|
32
|
+
this.#stackTraceLocations = stackTraceLocations;
|
|
39
33
|
this.logLevel = logLevel;
|
|
40
34
|
this.tag = tag;
|
|
41
35
|
}
|
|
42
36
|
stackTrace() {
|
|
43
|
-
return
|
|
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;
|
package/dist/browser/DOMWorld.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
34
|
+
this.#frame = frame;
|
|
47
35
|
this._setContext(null);
|
|
48
36
|
}
|
|
49
37
|
frame() {
|
|
50
|
-
return
|
|
38
|
+
return this.#frame;
|
|
51
39
|
}
|
|
52
40
|
_setContext(context) {
|
|
53
41
|
var _a;
|
|
54
42
|
if (context) {
|
|
55
|
-
(0, assert_1.assert)(
|
|
56
|
-
(_a =
|
|
57
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
})
|
|
51
|
+
this.#contextPromise = new Promise((fulfill) => {
|
|
52
|
+
this.#contextResolveCallback = fulfill;
|
|
53
|
+
});
|
|
66
54
|
}
|
|
67
55
|
}
|
|
68
56
|
_hasContext() {
|
|
69
|
-
return !
|
|
57
|
+
return !this.#contextResolveCallback;
|
|
70
58
|
}
|
|
71
59
|
_detach() {
|
|
72
|
-
|
|
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 (
|
|
79
|
-
throw new Error(`Execution context is not available in detached frame "${
|
|
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 (
|
|
69
|
+
if (this.#contextPromise === null) {
|
|
82
70
|
throw new Error(`Execution content promise is missing`);
|
|
83
71
|
}
|
|
84
|
-
return
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
141
|
-
|
|
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
|
-
|
|
148
|
-
return
|
|
149
|
-
}, options.timeout)
|
|
128
|
+
this.#timeoutTimer = setTimeout(() => {
|
|
129
|
+
return this.#reject(timeoutError);
|
|
130
|
+
}, options.timeout);
|
|
150
131
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
144
|
+
this.#terminated = true;
|
|
158
145
|
if (error) {
|
|
159
|
-
|
|
146
|
+
this.#reject(error);
|
|
160
147
|
}
|
|
161
|
-
|
|
148
|
+
this.#cleanup();
|
|
162
149
|
}
|
|
163
150
|
async rerun() {
|
|
164
|
-
|
|
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
|
|
169
|
-
if (
|
|
154
|
+
const context = await this.#domWorld.executionContext();
|
|
155
|
+
if (this.#terminated || runCount !== this.#runCount) {
|
|
170
156
|
return;
|
|
171
157
|
}
|
|
172
|
-
if (
|
|
158
|
+
if (this.#terminated || runCount !== this.#runCount) {
|
|
173
159
|
return;
|
|
174
160
|
}
|
|
175
161
|
try {
|
|
176
|
-
success = await context.evaluateHandle(waitForPredicatePageFunction,
|
|
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 (
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
217
|
+
this.#resolve(success);
|
|
232
218
|
}
|
|
233
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
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);
|
package/dist/browser/Errors.js
CHANGED
|
@@ -27,9 +27,7 @@ class TimeoutError extends CustomError {
|
|
|
27
27
|
}
|
|
28
28
|
exports.TimeoutError = TimeoutError;
|
|
29
29
|
class ProtocolError extends CustomError {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.originalMessage = '';
|
|
33
|
-
}
|
|
30
|
+
code;
|
|
31
|
+
originalMessage = '';
|
|
34
32
|
}
|
|
35
33
|
exports.ProtocolError = ProtocolError;
|