@remotion/renderer 3.0.19 → 3.0.22
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/get-audio-channels.d.ts +4 -2
- package/dist/assets/get-audio-channels.js +14 -3
- package/dist/browser/Browser.d.ts +209 -0
- package/dist/browser/Browser.js +402 -0
- package/dist/browser/BrowserConnector.d.ts +19 -0
- package/dist/browser/BrowserConnector.js +17 -0
- package/dist/browser/BrowserFetcher.d.ts +89 -0
- package/dist/browser/BrowserFetcher.js +492 -0
- package/dist/browser/BrowserRunner.d.ts +39 -0
- package/dist/browser/BrowserRunner.js +308 -0
- package/dist/browser/Connection.d.ts +49 -0
- package/dist/browser/Connection.js +262 -0
- package/dist/browser/ConnectionTransport.d.ts +21 -0
- package/dist/browser/ConnectionTransport.js +17 -0
- package/dist/browser/ConsoleMessage.d.ts +31 -0
- package/dist/browser/ConsoleMessage.js +48 -0
- package/dist/browser/DOMWorld.d.ts +50 -0
- package/dist/browser/DOMWorld.js +280 -0
- package/dist/browser/EmulationManager.d.ts +7 -0
- package/dist/browser/EmulationManager.js +40 -0
- package/dist/browser/Errors.d.ts +25 -0
- package/dist/browser/Errors.js +35 -0
- package/dist/browser/EvalTypes.d.ts +27 -0
- package/dist/browser/EvalTypes.js +17 -0
- package/dist/browser/EventEmitter.d.ts +70 -0
- package/dist/browser/EventEmitter.js +102 -0
- package/dist/browser/ExecutionContext.d.ts +33 -0
- package/dist/browser/ExecutionContext.js +174 -0
- package/dist/browser/FrameManager.d.ts +96 -0
- package/dist/browser/FrameManager.js +512 -0
- package/dist/browser/HTTPRequest.d.ts +28 -0
- package/dist/browser/HTTPRequest.js +37 -0
- package/dist/browser/HTTPResponse.d.ts +22 -0
- package/dist/browser/HTTPResponse.js +33 -0
- package/dist/browser/JSHandle.d.ts +36 -0
- package/dist/browser/JSHandle.js +93 -0
- package/dist/browser/LaunchOptions.d.ts +117 -0
- package/dist/browser/LaunchOptions.js +17 -0
- package/dist/browser/Launcher.d.ts +9 -0
- package/dist/browser/Launcher.js +602 -0
- package/dist/browser/LifecycleWatcher.d.ts +29 -0
- package/dist/browser/LifecycleWatcher.js +193 -0
- package/dist/browser/NetworkEventManager.d.ts +35 -0
- package/dist/browser/NetworkEventManager.js +128 -0
- package/dist/browser/NetworkManager.d.ts +36 -0
- package/dist/browser/NetworkManager.js +280 -0
- package/dist/browser/NodeWebSocketTransport.d.ts +17 -0
- package/dist/browser/NodeWebSocketTransport.js +90 -0
- package/dist/browser/Page.d.ts +74 -0
- package/dist/browser/Page.js +282 -0
- package/dist/browser/Product.d.ts +16 -0
- package/dist/browser/Product.js +17 -0
- package/dist/browser/PuppeteerNode.d.ts +89 -0
- package/dist/browser/PuppeteerNode.js +135 -0
- package/dist/browser/PuppeteerViewport.d.ts +5 -0
- package/dist/browser/PuppeteerViewport.js +2 -0
- package/dist/browser/ScreenshotOptions.d.ts +14 -0
- package/dist/browser/ScreenshotOptions.js +2 -0
- package/dist/browser/Target.d.ts +61 -0
- package/dist/browser/Target.js +146 -0
- package/dist/browser/TaskQueue.d.ts +20 -0
- package/dist/browser/TaskQueue.js +47 -0
- package/dist/browser/TimeoutSettings.d.ts +23 -0
- package/dist/browser/TimeoutSettings.js +62 -0
- package/dist/browser/assert.d.ts +21 -0
- package/dist/browser/assert.js +29 -0
- package/dist/browser/compat.d.ts +2 -0
- package/dist/browser/compat.js +17 -0
- package/dist/browser/create-browser-fetcher.d.ts +17 -0
- package/dist/browser/create-browser-fetcher.js +127 -0
- package/dist/browser/environment.d.ts +16 -0
- package/dist/browser/environment.js +19 -0
- package/dist/browser/get-download-destination.d.ts +1 -0
- package/dist/browser/get-download-destination.js +38 -0
- package/dist/browser/mitt/index.d.ts +22 -0
- package/dist/browser/mitt/index.js +49 -0
- package/dist/browser/node.d.ts +2 -0
- package/dist/browser/node.js +9 -0
- package/dist/browser/revisions.d.ts +21 -0
- package/dist/browser/revisions.js +22 -0
- package/dist/browser/util.d.ts +46 -0
- package/dist/browser/util.js +161 -0
- package/dist/ensure-presentation-timestamp.d.ts +1 -0
- package/dist/ensure-presentation-timestamp.js +57 -0
- package/dist/extract-frame-from-video.d.ts +4 -5
- package/dist/extract-frame-from-video.js +58 -27
- package/dist/index.d.ts +24 -0
- package/dist/index.js +11 -0
- package/dist/is-vp9-video.d.ts +3 -0
- package/dist/is-vp9-video.js +24 -0
- package/dist/last-frame-from-video-cache.d.ts +4 -3
- package/dist/last-frame-from-video-cache.js +9 -6
- package/dist/offthread-video-server.d.ts +2 -1
- package/dist/offthread-video-server.js +14 -3
- package/dist/open-browser.js +1 -2
- package/dist/prepare-server.js +11 -0
- package/dist/serve-handler/index.js +1 -8
- package/dist/should-use-vp9-decoder.d.ts +0 -0
- package/dist/should-use-vp9-decoder.js +1 -0
- package/dist/validate-offthreadvideo-image-format.d.ts +1 -0
- package/dist/validate-offthreadvideo-image-format.js +15 -0
- package/package.json +3 -3
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2017 Google Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
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 _Page_instances, _Page_closed, _Page_client, _Page_target, _Page_timeoutSettings, _Page_frameManager, _Page_pageBindings, _Page_initialize, _Page_onTargetCrashed, _Page_onLogEntryAdded, _Page_onConsoleAPI, _Page_onBindingCalled, _Page_addConsoleMessage;
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.Page = void 0;
|
|
31
|
+
const assert_1 = require("./assert");
|
|
32
|
+
const ConsoleMessage_1 = require("./ConsoleMessage");
|
|
33
|
+
const EventEmitter_1 = require("./EventEmitter");
|
|
34
|
+
const FrameManager_1 = require("./FrameManager");
|
|
35
|
+
const JSHandle_1 = require("./JSHandle");
|
|
36
|
+
const TaskQueue_1 = require("./TaskQueue");
|
|
37
|
+
const TimeoutSettings_1 = require("./TimeoutSettings");
|
|
38
|
+
const util_1 = require("./util");
|
|
39
|
+
class Page extends EventEmitter_1.EventEmitter {
|
|
40
|
+
constructor(client, target) {
|
|
41
|
+
super();
|
|
42
|
+
_Page_instances.add(this);
|
|
43
|
+
_Page_closed.set(this, false);
|
|
44
|
+
_Page_client.set(this, void 0);
|
|
45
|
+
_Page_target.set(this, void 0);
|
|
46
|
+
_Page_timeoutSettings.set(this, new TimeoutSettings_1.TimeoutSettings());
|
|
47
|
+
_Page_frameManager.set(this, void 0);
|
|
48
|
+
_Page_pageBindings.set(this, new Map());
|
|
49
|
+
__classPrivateFieldSet(this, _Page_client, client, "f");
|
|
50
|
+
__classPrivateFieldSet(this, _Page_target, target, "f");
|
|
51
|
+
__classPrivateFieldSet(this, _Page_frameManager, new FrameManager_1.FrameManager(client, this, __classPrivateFieldGet(this, _Page_timeoutSettings, "f")), "f");
|
|
52
|
+
this.screenshotTaskQueue = new TaskQueue_1.TaskQueue();
|
|
53
|
+
client.on('Target.attachedToTarget', (event) => {
|
|
54
|
+
switch (event.targetInfo.type) {
|
|
55
|
+
case 'iframe':
|
|
56
|
+
break;
|
|
57
|
+
case 'worker':
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
// If we don't detach from service workers, they will never die.
|
|
61
|
+
// We still want to attach to workers for emitting events.
|
|
62
|
+
// We still want to attach to iframes so sessions may interact with them.
|
|
63
|
+
// We detach from all other types out of an abundance of caution.
|
|
64
|
+
// See https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypePage%5B%5D%22
|
|
65
|
+
// for the complete list of available types.
|
|
66
|
+
client
|
|
67
|
+
.send('Target.detachFromTarget', {
|
|
68
|
+
sessionId: event.sessionId,
|
|
69
|
+
})
|
|
70
|
+
.catch((err) => console.log(err));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
client.on('Runtime.consoleAPICalled', (event) => {
|
|
74
|
+
return __classPrivateFieldGet(this, _Page_instances, "m", _Page_onConsoleAPI).call(this, event);
|
|
75
|
+
});
|
|
76
|
+
client.on('Runtime.bindingCalled', (event) => {
|
|
77
|
+
return __classPrivateFieldGet(this, _Page_instances, "m", _Page_onBindingCalled).call(this, event);
|
|
78
|
+
});
|
|
79
|
+
client.on('Inspector.targetCrashed', () => {
|
|
80
|
+
return __classPrivateFieldGet(this, _Page_instances, "m", _Page_onTargetCrashed).call(this);
|
|
81
|
+
});
|
|
82
|
+
client.on('Log.entryAdded', (event) => {
|
|
83
|
+
return __classPrivateFieldGet(this, _Page_instances, "m", _Page_onLogEntryAdded).call(this, event);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
static async _create(client, target, defaultViewport) {
|
|
87
|
+
const page = new Page(client, target);
|
|
88
|
+
await __classPrivateFieldGet(page, _Page_instances, "m", _Page_initialize).call(page);
|
|
89
|
+
await page.setViewport(defaultViewport);
|
|
90
|
+
return page;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Listen to page events.
|
|
94
|
+
*/
|
|
95
|
+
// Note: this method exists to define event typings and handle
|
|
96
|
+
// proper wireup of cooperative request interception. Actual event listening and
|
|
97
|
+
// dispatching is delegated to EventEmitter.
|
|
98
|
+
on(eventName, handler) {
|
|
99
|
+
return super.on(eventName, handler);
|
|
100
|
+
}
|
|
101
|
+
once(eventName, handler) {
|
|
102
|
+
// Note: this method only exists to define the types; we delegate the impl
|
|
103
|
+
// to EventEmitter.
|
|
104
|
+
return super.once(eventName, handler);
|
|
105
|
+
}
|
|
106
|
+
off(eventName, handler) {
|
|
107
|
+
return super.off(eventName, handler);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @returns A target this page was created from.
|
|
111
|
+
*/
|
|
112
|
+
target() {
|
|
113
|
+
return __classPrivateFieldGet(this, _Page_target, "f");
|
|
114
|
+
}
|
|
115
|
+
_client() {
|
|
116
|
+
return __classPrivateFieldGet(this, _Page_client, "f");
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @returns The page's main frame.
|
|
120
|
+
* @remarks
|
|
121
|
+
* Page is guaranteed to have a main frame which persists during navigations.
|
|
122
|
+
*/
|
|
123
|
+
mainFrame() {
|
|
124
|
+
return __classPrivateFieldGet(this, _Page_frameManager, "f").mainFrame();
|
|
125
|
+
}
|
|
126
|
+
setViewport(viewport) {
|
|
127
|
+
return __classPrivateFieldGet(this, _Page_client, "f").send('Emulation.setDeviceMetricsOverride', {
|
|
128
|
+
mobile: false,
|
|
129
|
+
width: viewport.width,
|
|
130
|
+
height: viewport.height,
|
|
131
|
+
deviceScaleFactor: viewport.deviceScaleFactor,
|
|
132
|
+
screenOrientation: {
|
|
133
|
+
angle: 0,
|
|
134
|
+
type: 'portraitPrimary',
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
setDefaultNavigationTimeout(timeout) {
|
|
139
|
+
__classPrivateFieldGet(this, _Page_timeoutSettings, "f").setDefaultNavigationTimeout(timeout);
|
|
140
|
+
}
|
|
141
|
+
setDefaultTimeout(timeout) {
|
|
142
|
+
__classPrivateFieldGet(this, _Page_timeoutSettings, "f").setDefaultTimeout(timeout);
|
|
143
|
+
}
|
|
144
|
+
async evaluateHandle(pageFunction, ...args) {
|
|
145
|
+
const context = await this.mainFrame().executionContext();
|
|
146
|
+
return context.evaluateHandle(pageFunction, ...args);
|
|
147
|
+
}
|
|
148
|
+
url() {
|
|
149
|
+
return this.mainFrame().url();
|
|
150
|
+
}
|
|
151
|
+
goto(url, options = {}) {
|
|
152
|
+
return __classPrivateFieldGet(this, _Page_frameManager, "f").mainFrame().goto(url, options);
|
|
153
|
+
}
|
|
154
|
+
async bringToFront() {
|
|
155
|
+
await __classPrivateFieldGet(this, _Page_client, "f").send('Page.bringToFront');
|
|
156
|
+
}
|
|
157
|
+
evaluate(pageFunction, ...args) {
|
|
158
|
+
return __classPrivateFieldGet(this, _Page_frameManager, "f").mainFrame().evaluate(pageFunction, ...args);
|
|
159
|
+
}
|
|
160
|
+
async evaluateOnNewDocument(pageFunction, ...args) {
|
|
161
|
+
const source = (0, util_1.evaluationString)(pageFunction, ...args);
|
|
162
|
+
await __classPrivateFieldGet(this, _Page_client, "f").send('Page.addScriptToEvaluateOnNewDocument', {
|
|
163
|
+
source,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async close(options = { runBeforeUnload: undefined }) {
|
|
167
|
+
const connection = __classPrivateFieldGet(this, _Page_client, "f").connection();
|
|
168
|
+
(0, assert_1.assert)(connection, 'Protocol error: Connection closed. Most likely the page has been closed.');
|
|
169
|
+
const runBeforeUnload = Boolean(options.runBeforeUnload);
|
|
170
|
+
if (runBeforeUnload) {
|
|
171
|
+
await __classPrivateFieldGet(this, _Page_client, "f").send('Page.close');
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
await connection.send('Target.closeTarget', {
|
|
175
|
+
targetId: __classPrivateFieldGet(this, _Page_target, "f")._targetId,
|
|
176
|
+
});
|
|
177
|
+
await __classPrivateFieldGet(this, _Page_target, "f")._isClosedPromise;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
isClosed() {
|
|
181
|
+
return __classPrivateFieldGet(this, _Page_closed, "f");
|
|
182
|
+
}
|
|
183
|
+
waitForFunction(pageFunction, ...args) {
|
|
184
|
+
return this.mainFrame().waitForFunction(pageFunction, ...args);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.Page = Page;
|
|
188
|
+
_Page_closed = new WeakMap(), _Page_client = new WeakMap(), _Page_target = new WeakMap(), _Page_timeoutSettings = new WeakMap(), _Page_frameManager = new WeakMap(), _Page_pageBindings = new WeakMap(), _Page_instances = new WeakSet(), _Page_initialize = async function _Page_initialize() {
|
|
189
|
+
await Promise.all([
|
|
190
|
+
__classPrivateFieldGet(this, _Page_frameManager, "f").initialize(),
|
|
191
|
+
__classPrivateFieldGet(this, _Page_client, "f").send('Target.setAutoAttach', {
|
|
192
|
+
autoAttach: true,
|
|
193
|
+
waitForDebuggerOnStart: false,
|
|
194
|
+
flatten: true,
|
|
195
|
+
}),
|
|
196
|
+
__classPrivateFieldGet(this, _Page_client, "f").send('Performance.enable'),
|
|
197
|
+
__classPrivateFieldGet(this, _Page_client, "f").send('Log.enable'),
|
|
198
|
+
]);
|
|
199
|
+
}, _Page_onTargetCrashed = function _Page_onTargetCrashed() {
|
|
200
|
+
this.emit('error', new Error('Page crashed!'));
|
|
201
|
+
}, _Page_onLogEntryAdded = function _Page_onLogEntryAdded(event) {
|
|
202
|
+
const { level, text, args, source, url, lineNumber } = event.entry;
|
|
203
|
+
if (args) {
|
|
204
|
+
args.map((arg) => {
|
|
205
|
+
return (0, util_1.releaseObject)(__classPrivateFieldGet(this, _Page_client, "f"), arg);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (source !== 'worker') {
|
|
209
|
+
this.emit("console" /* PageEmittedEvents.Console */, new ConsoleMessage_1.ConsoleMessage(level, text, [], [{ url, lineNumber }]));
|
|
210
|
+
}
|
|
211
|
+
}, _Page_onConsoleAPI = function _Page_onConsoleAPI(event) {
|
|
212
|
+
if (event.executionContextId === 0) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const context = __classPrivateFieldGet(this, _Page_frameManager, "f").executionContextById(event.executionContextId, __classPrivateFieldGet(this, _Page_client, "f"));
|
|
216
|
+
const values = event.args.map((arg) => {
|
|
217
|
+
return (0, JSHandle_1._createJSHandle)(context, arg);
|
|
218
|
+
});
|
|
219
|
+
__classPrivateFieldGet(this, _Page_instances, "m", _Page_addConsoleMessage).call(this, event.type, values, event.stackTrace);
|
|
220
|
+
}, _Page_onBindingCalled = async function _Page_onBindingCalled(event) {
|
|
221
|
+
let payload;
|
|
222
|
+
try {
|
|
223
|
+
payload = JSON.parse(event.payload);
|
|
224
|
+
}
|
|
225
|
+
catch (_a) {
|
|
226
|
+
// The binding was either called by something in the page or it was
|
|
227
|
+
// called before our wrapper was initialized.
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const { type, name, seq, args } = payload;
|
|
231
|
+
if (type !== 'exposedFun' || !__classPrivateFieldGet(this, _Page_pageBindings, "f").has(name)) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
let expression = null;
|
|
235
|
+
try {
|
|
236
|
+
const pageBinding = __classPrivateFieldGet(this, _Page_pageBindings, "f").get(name);
|
|
237
|
+
(0, assert_1.assert)(pageBinding);
|
|
238
|
+
const result = await pageBinding(...args);
|
|
239
|
+
expression = (0, util_1.pageBindingDeliverResultString)(name, seq, result);
|
|
240
|
+
}
|
|
241
|
+
catch (_error) {
|
|
242
|
+
if ((0, util_1.isErrorLike)(_error)) {
|
|
243
|
+
expression = (0, util_1.pageBindingDeliverErrorString)(name, seq, _error.message, _error.stack);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
expression = (0, util_1.pageBindingDeliverErrorValueString)(name, seq, _error);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
__classPrivateFieldGet(this, _Page_client, "f").send('Runtime.evaluate', {
|
|
250
|
+
expression,
|
|
251
|
+
contextId: event.executionContextId,
|
|
252
|
+
});
|
|
253
|
+
}, _Page_addConsoleMessage = function _Page_addConsoleMessage(eventType, args, stackTrace) {
|
|
254
|
+
if (!this.listenerCount("console" /* PageEmittedEvents.Console */)) {
|
|
255
|
+
args.forEach((arg) => {
|
|
256
|
+
return arg.dispose();
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const textTokens = [];
|
|
261
|
+
for (const arg of args) {
|
|
262
|
+
const remoteObject = arg._remoteObject;
|
|
263
|
+
if (remoteObject.objectId) {
|
|
264
|
+
textTokens.push(arg.toString());
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
textTokens.push((0, util_1.valueFromRemoteObject)(remoteObject));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const stackTraceLocations = [];
|
|
271
|
+
if (stackTrace) {
|
|
272
|
+
for (const callFrame of stackTrace.callFrames) {
|
|
273
|
+
stackTraceLocations.push({
|
|
274
|
+
url: callFrame.url,
|
|
275
|
+
lineNumber: callFrame.lineNumber,
|
|
276
|
+
columnNumber: callFrame.columnNumber,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const message = new ConsoleMessage_1.ConsoleMessage(eventType, textTokens.join(' '), args, stackTraceLocations);
|
|
281
|
+
this.emit("console" /* PageEmittedEvents.Console */, message);
|
|
282
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2020 Google Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare type Product = 'chrome' | 'firefox';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2020 Google Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2020 Google Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Browser } from './Browser';
|
|
17
|
+
import { BrowserConnectOptions } from './BrowserConnector';
|
|
18
|
+
import { BrowserFetcher, BrowserFetcherOptions } from './BrowserFetcher';
|
|
19
|
+
import { ProductLauncher } from './Launcher';
|
|
20
|
+
import { BrowserLaunchArgumentOptions, LaunchOptions } from './LaunchOptions';
|
|
21
|
+
import { Product } from './Product';
|
|
22
|
+
interface PuppeteerLaunchOptions extends LaunchOptions, BrowserLaunchArgumentOptions, BrowserConnectOptions {
|
|
23
|
+
product?: Product;
|
|
24
|
+
extraPrefsFirefox?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export declare class PuppeteerNode {
|
|
27
|
+
#private;
|
|
28
|
+
_preferredRevision: string;
|
|
29
|
+
constructor(settings: {
|
|
30
|
+
preferredRevision: string;
|
|
31
|
+
productName?: Product;
|
|
32
|
+
});
|
|
33
|
+
get _productName(): Product | undefined;
|
|
34
|
+
set _productName(name: Product | undefined);
|
|
35
|
+
/**
|
|
36
|
+
* Launches puppeteer and launches a browser instance with given arguments
|
|
37
|
+
* and options when specified.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
|
|
43
|
+
* ```js
|
|
44
|
+
* const browser = await puppeteer.launch({
|
|
45
|
+
* ignoreDefaultArgs: ['--mute-audio']
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* **NOTE** Puppeteer can also be used to control the Chrome browser,
|
|
50
|
+
* but it works best with the version of Chromium it is bundled with.
|
|
51
|
+
* There is no guarantee it will work with any other version.
|
|
52
|
+
* Use `executablePath` option with extreme caution.
|
|
53
|
+
* If Google Chrome (rather than Chromium) is preferred, a {@link https://www.google.com/chrome/browser/canary.html | Chrome Canary} or {@link https://www.chromium.org/getting-involved/dev-channel | Dev Channel} build is suggested.
|
|
54
|
+
* In `puppeteer.launch([options])`, any mention of Chromium also applies to Chrome.
|
|
55
|
+
* See {@link https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/ | this article} for a description of the differences between Chromium and Chrome. {@link https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md | This article} describes some differences for Linux users.
|
|
56
|
+
*
|
|
57
|
+
* @param options - Set of configurable options to set on the browser.
|
|
58
|
+
* @returns Promise which resolves to browser instance.
|
|
59
|
+
*/
|
|
60
|
+
launch(options: PuppeteerLaunchOptions): Promise<Browser>;
|
|
61
|
+
/**
|
|
62
|
+
* @remarks
|
|
63
|
+
*
|
|
64
|
+
* **NOTE** `puppeteer.executablePath()` is affected by the `PUPPETEER_EXECUTABLE_PATH`
|
|
65
|
+
* and `PUPPETEER_CHROMIUM_REVISION` environment variables.
|
|
66
|
+
*
|
|
67
|
+
* @returns A path where Puppeteer expects to find the bundled browser.
|
|
68
|
+
* The browser binary might not be there if the download was skipped with
|
|
69
|
+
* the `PUPPETEER_SKIP_DOWNLOAD` environment variable.
|
|
70
|
+
*/
|
|
71
|
+
executablePath(channel?: string): string;
|
|
72
|
+
get _launcher(): ProductLauncher;
|
|
73
|
+
/**
|
|
74
|
+
* The name of the browser that is under automation (`"chrome"` or `"firefox"`)
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* The product is set by the `PUPPETEER_PRODUCT` environment variable or the `product`
|
|
78
|
+
* option in `puppeteer.launch([options])` and defaults to `chrome`.
|
|
79
|
+
* Firefox support is experimental.
|
|
80
|
+
*/
|
|
81
|
+
get product(): string;
|
|
82
|
+
/**
|
|
83
|
+
* @param options - Set of configurable options to specify the settings
|
|
84
|
+
* of the BrowserFetcher.
|
|
85
|
+
* @returns A new BrowserFetcher instance.
|
|
86
|
+
*/
|
|
87
|
+
createBrowserFetcher(options: BrowserFetcherOptions): BrowserFetcher;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2020 Google Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
var _PuppeteerNode_lazyLauncher, _PuppeteerNode_productName;
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.PuppeteerNode = void 0;
|
|
34
|
+
const BrowserFetcher_1 = require("./BrowserFetcher");
|
|
35
|
+
const Launcher_1 = __importDefault(require("./Launcher"));
|
|
36
|
+
const revisions_1 = require("./revisions");
|
|
37
|
+
class PuppeteerNode {
|
|
38
|
+
constructor(settings) {
|
|
39
|
+
_PuppeteerNode_lazyLauncher.set(this, void 0);
|
|
40
|
+
_PuppeteerNode_productName.set(this, void 0);
|
|
41
|
+
const { preferredRevision, productName } = settings;
|
|
42
|
+
__classPrivateFieldSet(this, _PuppeteerNode_productName, productName, "f");
|
|
43
|
+
this._preferredRevision = preferredRevision;
|
|
44
|
+
this.launch = this.launch.bind(this);
|
|
45
|
+
this.executablePath = this.executablePath.bind(this);
|
|
46
|
+
this.createBrowserFetcher = this.createBrowserFetcher.bind(this);
|
|
47
|
+
}
|
|
48
|
+
get _productName() {
|
|
49
|
+
return __classPrivateFieldGet(this, _PuppeteerNode_productName, "f");
|
|
50
|
+
}
|
|
51
|
+
set _productName(name) {
|
|
52
|
+
__classPrivateFieldSet(this, _PuppeteerNode_productName, name, "f");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Launches puppeteer and launches a browser instance with given arguments
|
|
56
|
+
* and options when specified.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
|
|
62
|
+
* ```js
|
|
63
|
+
* const browser = await puppeteer.launch({
|
|
64
|
+
* ignoreDefaultArgs: ['--mute-audio']
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* **NOTE** Puppeteer can also be used to control the Chrome browser,
|
|
69
|
+
* but it works best with the version of Chromium it is bundled with.
|
|
70
|
+
* There is no guarantee it will work with any other version.
|
|
71
|
+
* Use `executablePath` option with extreme caution.
|
|
72
|
+
* If Google Chrome (rather than Chromium) is preferred, a {@link https://www.google.com/chrome/browser/canary.html | Chrome Canary} or {@link https://www.chromium.org/getting-involved/dev-channel | Dev Channel} build is suggested.
|
|
73
|
+
* In `puppeteer.launch([options])`, any mention of Chromium also applies to Chrome.
|
|
74
|
+
* See {@link https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/ | this article} for a description of the differences between Chromium and Chrome. {@link https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md | This article} describes some differences for Linux users.
|
|
75
|
+
*
|
|
76
|
+
* @param options - Set of configurable options to set on the browser.
|
|
77
|
+
* @returns Promise which resolves to browser instance.
|
|
78
|
+
*/
|
|
79
|
+
launch(options) {
|
|
80
|
+
if (options.product) {
|
|
81
|
+
this._productName = options.product;
|
|
82
|
+
}
|
|
83
|
+
return this._launcher.launch(options);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @remarks
|
|
87
|
+
*
|
|
88
|
+
* **NOTE** `puppeteer.executablePath()` is affected by the `PUPPETEER_EXECUTABLE_PATH`
|
|
89
|
+
* and `PUPPETEER_CHROMIUM_REVISION` environment variables.
|
|
90
|
+
*
|
|
91
|
+
* @returns A path where Puppeteer expects to find the bundled browser.
|
|
92
|
+
* The browser binary might not be there if the download was skipped with
|
|
93
|
+
* the `PUPPETEER_SKIP_DOWNLOAD` environment variable.
|
|
94
|
+
*/
|
|
95
|
+
executablePath(channel) {
|
|
96
|
+
return this._launcher.executablePath(channel);
|
|
97
|
+
}
|
|
98
|
+
get _launcher() {
|
|
99
|
+
if (!__classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f") ||
|
|
100
|
+
__classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f").product !== this._productName) {
|
|
101
|
+
switch (this._productName) {
|
|
102
|
+
case 'firefox':
|
|
103
|
+
this._preferredRevision = revisions_1.PUPPETEER_REVISIONS.firefox;
|
|
104
|
+
break;
|
|
105
|
+
case 'chrome':
|
|
106
|
+
default:
|
|
107
|
+
this._preferredRevision = revisions_1.PUPPETEER_REVISIONS.chromium;
|
|
108
|
+
}
|
|
109
|
+
// eslint-disable-next-line new-cap
|
|
110
|
+
__classPrivateFieldSet(this, _PuppeteerNode_lazyLauncher, (0, Launcher_1.default)(this._preferredRevision, this._productName), "f");
|
|
111
|
+
}
|
|
112
|
+
return __classPrivateFieldGet(this, _PuppeteerNode_lazyLauncher, "f");
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The name of the browser that is under automation (`"chrome"` or `"firefox"`)
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* The product is set by the `PUPPETEER_PRODUCT` environment variable or the `product`
|
|
119
|
+
* option in `puppeteer.launch([options])` and defaults to `chrome`.
|
|
120
|
+
* Firefox support is experimental.
|
|
121
|
+
*/
|
|
122
|
+
get product() {
|
|
123
|
+
return this._launcher.product;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @param options - Set of configurable options to specify the settings
|
|
127
|
+
* of the BrowserFetcher.
|
|
128
|
+
* @returns A new BrowserFetcher instance.
|
|
129
|
+
*/
|
|
130
|
+
createBrowserFetcher(options) {
|
|
131
|
+
return new BrowserFetcher_1.BrowserFetcher(options);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.PuppeteerNode = PuppeteerNode;
|
|
135
|
+
_PuppeteerNode_lazyLauncher = new WeakMap(), _PuppeteerNode_productName = new WeakMap();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ScreenshotClip {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ScreenshotOptions {
|
|
8
|
+
type: 'png' | 'jpeg';
|
|
9
|
+
path?: string;
|
|
10
|
+
clip?: ScreenshotClip;
|
|
11
|
+
quality?: number;
|
|
12
|
+
omitBackground: boolean;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2019 Google Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Protocol } from 'devtools-protocol';
|
|
17
|
+
import { Browser, BrowserContext } from './Browser';
|
|
18
|
+
import { CDPSession } from './Connection';
|
|
19
|
+
import { Page } from './Page';
|
|
20
|
+
import { Viewport } from './PuppeteerViewport';
|
|
21
|
+
export declare class Target {
|
|
22
|
+
#private;
|
|
23
|
+
_initializedPromise: Promise<boolean>;
|
|
24
|
+
_initializedCallback: (x: boolean) => void;
|
|
25
|
+
_isClosedPromise: Promise<void>;
|
|
26
|
+
_closedCallback: () => void;
|
|
27
|
+
_isInitialized: boolean;
|
|
28
|
+
_targetId: string;
|
|
29
|
+
constructor(targetInfo: Protocol.Target.TargetInfo, browserContext: BrowserContext, sessionFactory: () => Promise<CDPSession>, defaultViewport: Viewport);
|
|
30
|
+
/**
|
|
31
|
+
* Creates a Chrome Devtools Protocol session attached to the target.
|
|
32
|
+
*/
|
|
33
|
+
createCDPSession(): Promise<CDPSession>;
|
|
34
|
+
_getTargetInfo(): Protocol.Target.TargetInfo;
|
|
35
|
+
/**
|
|
36
|
+
* If the target is not of type `"page"` or `"background_page"`, returns `null`.
|
|
37
|
+
*/
|
|
38
|
+
page(): Promise<Page | null>;
|
|
39
|
+
url(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Identifies what kind of target this is.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
*
|
|
45
|
+
* See {@link https://developer.chrome.com/extensions/background_pages | docs} for more info about background pages.
|
|
46
|
+
*/
|
|
47
|
+
type(): 'page' | 'background_page' | 'service_worker' | 'shared_worker' | 'other' | 'browser' | 'webview';
|
|
48
|
+
/**
|
|
49
|
+
* Get the browser the target belongs to.
|
|
50
|
+
*/
|
|
51
|
+
browser(): Browser;
|
|
52
|
+
/**
|
|
53
|
+
* Get the browser context the target belongs to.
|
|
54
|
+
*/
|
|
55
|
+
browserContext(): BrowserContext;
|
|
56
|
+
/**
|
|
57
|
+
* Get the target that opened this target. Top-level targets return `null`.
|
|
58
|
+
*/
|
|
59
|
+
opener(): Target | undefined;
|
|
60
|
+
_targetInfoChanged(targetInfo: Protocol.Target.TargetInfo): void;
|
|
61
|
+
}
|