@remotion/renderer 4.0.0-fastlambda.8 → 4.0.0-lambda.3
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/cleanup-assets.d.ts +2 -0
- package/dist/assets/cleanup-assets.js +2 -0
- package/dist/assets/download-and-map-assets-to-file.d.ts +6 -0
- package/dist/assets/download-and-map-assets-to-file.js +46 -19
- package/dist/assets/ffmpeg-volume-expression.d.ts +2 -1
- package/dist/assets/ffmpeg-volume-expression.js +15 -12
- package/dist/assets/get-audio-channels.d.ts +5 -2
- package/dist/assets/get-audio-channels.js +15 -4
- package/dist/browser/Accessibility.d.ts +175 -0
- package/dist/browser/Accessibility.js +423 -0
- package/dist/browser/AriaQueryHandler.d.ts +20 -0
- package/dist/browser/AriaQueryHandler.js +108 -0
- package/dist/browser/Browser.d.ts +209 -0
- package/dist/browser/Browser.js +402 -0
- package/dist/browser/BrowserConnector.d.ts +26 -0
- package/dist/browser/BrowserConnector.js +49 -0
- package/dist/browser/BrowserFetcher.d.ts +89 -0
- package/dist/browser/BrowserFetcher.js +512 -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 +55 -0
- package/dist/browser/ConsoleMessage.js +75 -0
- package/dist/browser/Coverage.d.ts +180 -0
- package/dist/browser/Coverage.js +371 -0
- package/dist/browser/DOMWorld.d.ts +50 -0
- package/dist/browser/DOMWorld.js +280 -0
- package/dist/browser/Debug.d.ts +19 -0
- package/dist/browser/Debug.js +42 -0
- package/dist/browser/DeviceDescriptors.d.ts +40 -0
- package/dist/browser/DeviceDescriptors.js +1407 -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 +35 -0
- package/dist/browser/ExecutionContext.js +190 -0
- package/dist/browser/FileChooser.d.ts +56 -0
- package/dist/browser/FileChooser.js +86 -0
- package/dist/browser/FrameManager.d.ts +96 -0
- package/dist/browser/FrameManager.js +512 -0
- package/dist/browser/HTTPRequest.d.ts +42 -0
- package/dist/browser/HTTPRequest.js +82 -0
- package/dist/browser/HTTPResponse.d.ts +100 -0
- package/dist/browser/HTTPResponse.js +196 -0
- package/dist/browser/Input.d.ts +355 -0
- package/dist/browser/Input.js +592 -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/NetworkConditions.d.ts +26 -0
- package/dist/browser/NetworkConditions.js +33 -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 +284 -0
- package/dist/browser/NodeWebSocketTransport.d.ts +11 -0
- package/dist/browser/NodeWebSocketTransport.js +90 -0
- package/dist/browser/PDFOptions.d.ts +165 -0
- package/dist/browser/PDFOptions.js +34 -0
- package/dist/browser/PipeTransport.d.ts +10 -0
- package/dist/browser/PipeTransport.js +86 -0
- package/dist/browser/Product.d.ts +16 -0
- package/dist/browser/Product.js +17 -0
- package/dist/browser/Puppeteer.d.ts +35 -0
- package/dist/browser/Puppeteer.js +17 -0
- package/dist/browser/PuppeteerNode.d.ts +92 -0
- package/dist/browser/PuppeteerNode.js +143 -0
- package/dist/browser/PuppeteerViewport.d.ts +5 -0
- package/dist/browser/PuppeteerViewport.js +2 -0
- package/dist/browser/QueryHandler.d.ts +64 -0
- package/dist/browser/QueryHandler.js +183 -0
- package/dist/browser/ScreenshotOptions.d.ts +14 -0
- package/dist/browser/ScreenshotOptions.js +2 -0
- package/dist/browser/SecurityDetails.d.ts +55 -0
- package/dist/browser/SecurityDetails.js +95 -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/Tracing.d.ts +45 -0
- package/dist/browser/Tracing.js +136 -0
- package/dist/browser/USKeyboardLayout.d.ts +39 -0
- package/dist/browser/USKeyboardLayout.js +406 -0
- package/dist/browser/WebWorker.d.ts +96 -0
- package/dist/browser/WebWorker.js +122 -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 +140 -0
- package/dist/browser/dialog.d.ts +70 -0
- package/dist/browser/dialog.js +114 -0
- package/dist/browser/environment.d.ts +16 -0
- package/dist/browser/environment.js +19 -0
- package/dist/browser/fetch.d.ts +16 -0
- package/dist/browser/fetch.js +46 -0
- package/dist/browser/find-up.d.ts +4 -0
- package/dist/browser/find-up.js +85 -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/page.d.ts +78 -0
- package/dist/browser/page.js +277 -0
- package/dist/browser/pkg-dir.d.ts +3 -0
- package/dist/browser/pkg-dir.js +13 -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/calculate-ffmpeg-filters.js +2 -2
- package/dist/combine-videos.d.ts +2 -1
- package/dist/combine-videos.js +8 -1
- package/dist/cycle-browser-tabs.d.ts +2 -1
- package/dist/cycle-browser-tabs.js +9 -2
- 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 +11 -0
- package/dist/extract-frame-from-video.js +197 -0
- package/dist/frame-to-ffmpeg-timestamp.d.ts +1 -0
- package/dist/frame-to-ffmpeg-timestamp.js +8 -0
- package/dist/get-compositions.d.ts +5 -2
- package/dist/get-compositions.js +23 -5
- package/dist/get-duration-of-asset.d.ts +7 -0
- package/dist/get-duration-of-asset.js +36 -0
- package/dist/get-port.js +26 -24
- package/dist/index.d.ts +33 -9
- package/dist/index.js +14 -5
- package/dist/is-beyond-last-frame.d.ts +2 -0
- package/dist/is-beyond-last-frame.js +12 -0
- package/dist/last-frame-from-video-cache.d.ts +10 -0
- package/dist/last-frame-from-video-cache.js +50 -0
- package/dist/make-assets-download-dir.js +6 -1
- package/dist/make-cancel-signal.d.ts +7 -0
- package/dist/make-cancel-signal.js +25 -0
- package/dist/merge-audio-track.js +2 -2
- package/dist/offthread-video-server.d.ts +14 -0
- package/dist/offthread-video-server.js +67 -0
- package/dist/open-browser.d.ts +6 -6
- package/dist/open-browser.js +24 -20
- package/dist/prepare-server.d.ts +13 -2
- package/dist/prepare-server.js +35 -5
- package/dist/preprocess-audio-track.d.ts +1 -0
- package/dist/preprocess-audio-track.js +2 -2
- package/dist/prespawn-ffmpeg.d.ts +2 -0
- package/dist/prespawn-ffmpeg.js +10 -9
- package/dist/provide-screenshot.js +1 -1
- package/dist/puppeteer-screenshot.js +5 -1
- package/dist/render-frames.d.ts +6 -1
- package/dist/render-frames.js +96 -37
- package/dist/render-media.d.ts +12 -2
- package/dist/render-media.js +127 -54
- package/dist/render-still.d.ts +14 -4
- package/dist/render-still.js +58 -19
- package/dist/serve-handler/glob-slash.d.ts +1 -0
- package/dist/serve-handler/glob-slash.js +12 -0
- package/dist/serve-handler/index.d.ts +4 -0
- package/dist/serve-handler/index.js +205 -0
- package/dist/serve-handler/is-path-inside.d.ts +1 -0
- package/dist/serve-handler/is-path-inside.js +27 -0
- package/dist/serve-handler/range-parser.d.ts +13 -0
- package/dist/serve-handler/range-parser.js +57 -0
- package/dist/serve-static.d.ts +10 -3
- package/dist/serve-static.js +22 -4
- package/dist/set-props-and-env.d.ts +3 -1
- package/dist/set-props-and-env.js +28 -6
- package/dist/stitch-frames-to-video.d.ts +4 -1
- package/dist/stitch-frames-to-video.js +36 -15
- package/dist/stringify-ffmpeg-filter.js +3 -0
- package/dist/tmp-dir.js +5 -1
- package/dist/validate-fps-for-gif.d.ts +2 -0
- package/dist/validate-fps-for-gif.js +9 -0
- package/package.json +6 -7
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _EmulationManager_client;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.EmulationManager = void 0;
|
|
16
|
+
class EmulationManager {
|
|
17
|
+
constructor(client) {
|
|
18
|
+
_EmulationManager_client.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _EmulationManager_client, client, "f");
|
|
20
|
+
}
|
|
21
|
+
async emulateViewport(viewport) {
|
|
22
|
+
const { height, width } = viewport;
|
|
23
|
+
const { deviceScaleFactor } = viewport;
|
|
24
|
+
const screenOrientation = {
|
|
25
|
+
angle: 0,
|
|
26
|
+
type: 'portraitPrimary',
|
|
27
|
+
};
|
|
28
|
+
await Promise.all([
|
|
29
|
+
__classPrivateFieldGet(this, _EmulationManager_client, "f").send('Emulation.setDeviceMetricsOverride', {
|
|
30
|
+
mobile: false,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
deviceScaleFactor,
|
|
34
|
+
screenOrientation,
|
|
35
|
+
}),
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.EmulationManager = EmulationManager;
|
|
40
|
+
_EmulationManager_client = new WeakMap();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2018 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
|
+
declare class CustomError extends Error {
|
|
17
|
+
constructor(message?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class TimeoutError extends CustomError {
|
|
20
|
+
}
|
|
21
|
+
export declare class ProtocolError extends CustomError {
|
|
22
|
+
code?: number;
|
|
23
|
+
originalMessage: string;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2018 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 });
|
|
18
|
+
exports.ProtocolError = exports.TimeoutError = void 0;
|
|
19
|
+
class CustomError extends Error {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = this.constructor.name;
|
|
23
|
+
Error.captureStackTrace(this, this.constructor);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class TimeoutError extends CustomError {
|
|
27
|
+
}
|
|
28
|
+
exports.TimeoutError = TimeoutError;
|
|
29
|
+
class ProtocolError extends CustomError {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.originalMessage = '';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ProtocolError = ProtocolError;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { JSHandle } from './JSHandle';
|
|
17
|
+
export declare type EvaluateFn<T = any, U = any, V = any> = string | ((arg1: T, ...args: U[]) => V);
|
|
18
|
+
export declare type UnwrapPromiseLike<T> = T extends PromiseLike<infer U> ? U : T;
|
|
19
|
+
export declare type EvaluateFnReturnType<T extends EvaluateFn> = T extends (...args: any[]) => infer R ? R : any;
|
|
20
|
+
export declare type EvaluateHandleFn = string | ((...args: any[]) => any);
|
|
21
|
+
declare type Serializable = number | string | boolean | null | bigint | JSONArray | JSONObject;
|
|
22
|
+
declare type JSONArray = readonly Serializable[];
|
|
23
|
+
interface JSONObject {
|
|
24
|
+
[key: string]: Serializable;
|
|
25
|
+
}
|
|
26
|
+
export declare type SerializableOrJSHandle = Serializable | JSHandle;
|
|
27
|
+
export {};
|
|
@@ -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,70 @@
|
|
|
1
|
+
import { EventType, Handler } from './mitt';
|
|
2
|
+
export interface CommonEventEmitter {
|
|
3
|
+
on(event: EventType, handler: Handler): CommonEventEmitter;
|
|
4
|
+
off(event: EventType, handler: Handler): CommonEventEmitter;
|
|
5
|
+
addListener(event: EventType, handler: Handler): CommonEventEmitter;
|
|
6
|
+
removeListener(event: EventType, handler: Handler): CommonEventEmitter;
|
|
7
|
+
emit(event: EventType, eventData?: unknown): boolean;
|
|
8
|
+
once(event: EventType, handler: Handler): CommonEventEmitter;
|
|
9
|
+
listenerCount(event: string): number;
|
|
10
|
+
removeAllListeners(event?: EventType): CommonEventEmitter;
|
|
11
|
+
}
|
|
12
|
+
export declare class EventEmitter implements CommonEventEmitter {
|
|
13
|
+
private emitter;
|
|
14
|
+
private eventsMap;
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Bind an event listener to fire when an event occurs.
|
|
18
|
+
* @param event - the event type you'd like to listen to. Can be a string or symbol.
|
|
19
|
+
* @param handler - the function to be called when the event occurs.
|
|
20
|
+
* @returns `this` to enable you to chain method calls.
|
|
21
|
+
*/
|
|
22
|
+
on(event: EventType, handler: Handler): EventEmitter;
|
|
23
|
+
/**
|
|
24
|
+
* Remove an event listener from firing.
|
|
25
|
+
* @param event - the event type you'd like to stop listening to.
|
|
26
|
+
* @param handler - the function that should be removed.
|
|
27
|
+
* @returns `this` to enable you to chain method calls.
|
|
28
|
+
*/
|
|
29
|
+
off(event: EventType, handler: Handler): EventEmitter;
|
|
30
|
+
/**
|
|
31
|
+
* Remove an event listener.
|
|
32
|
+
* @deprecated please use {@link EventEmitter.off} instead.
|
|
33
|
+
*/
|
|
34
|
+
removeListener(event: EventType, handler: Handler): EventEmitter;
|
|
35
|
+
/**
|
|
36
|
+
* Add an event listener.
|
|
37
|
+
* @deprecated please use {@link EventEmitter.on} instead.
|
|
38
|
+
*/
|
|
39
|
+
addListener(event: EventType, handler: Handler): EventEmitter;
|
|
40
|
+
/**
|
|
41
|
+
* Emit an event and call any associated listeners.
|
|
42
|
+
*
|
|
43
|
+
* @param event - the event you'd like to emit
|
|
44
|
+
* @param eventData - any data you'd like to emit with the event
|
|
45
|
+
* @returns `true` if there are any listeners, `false` if there are not.
|
|
46
|
+
*/
|
|
47
|
+
emit(event: EventType, eventData?: unknown): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Like `on` but the listener will only be fired once and then it will be removed.
|
|
50
|
+
* @param event - the event you'd like to listen to
|
|
51
|
+
* @param handler - the handler function to run when the event occurs
|
|
52
|
+
* @returns `this` to enable you to chain method calls.
|
|
53
|
+
*/
|
|
54
|
+
once(event: EventType, handler: Handler): EventEmitter;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the number of listeners for a given event.
|
|
57
|
+
*
|
|
58
|
+
* @param event - the event to get the listener count for
|
|
59
|
+
* @returns the number of listeners bound to the given event
|
|
60
|
+
*/
|
|
61
|
+
listenerCount(event: EventType): number;
|
|
62
|
+
/**
|
|
63
|
+
* Removes all listeners. If given an event argument, it will remove only
|
|
64
|
+
* listeners for that event.
|
|
65
|
+
* @param event - the event to remove listeners for.
|
|
66
|
+
* @returns `this` to enable you to chain method calls.
|
|
67
|
+
*/
|
|
68
|
+
removeAllListeners(event?: EventType): EventEmitter;
|
|
69
|
+
private eventListenersCount;
|
|
70
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EventEmitter = void 0;
|
|
7
|
+
const mitt_1 = __importDefault(require("./mitt"));
|
|
8
|
+
class EventEmitter {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.eventsMap = new Map();
|
|
11
|
+
this.emitter = (0, mitt_1.default)(this.eventsMap);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Bind an event listener to fire when an event occurs.
|
|
15
|
+
* @param event - the event type you'd like to listen to. Can be a string or symbol.
|
|
16
|
+
* @param handler - the function to be called when the event occurs.
|
|
17
|
+
* @returns `this` to enable you to chain method calls.
|
|
18
|
+
*/
|
|
19
|
+
on(event, handler) {
|
|
20
|
+
this.emitter.on(event, handler);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Remove an event listener from firing.
|
|
25
|
+
* @param event - the event type you'd like to stop listening to.
|
|
26
|
+
* @param handler - the function that should be removed.
|
|
27
|
+
* @returns `this` to enable you to chain method calls.
|
|
28
|
+
*/
|
|
29
|
+
off(event, handler) {
|
|
30
|
+
this.emitter.off(event, handler);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Remove an event listener.
|
|
35
|
+
* @deprecated please use {@link EventEmitter.off} instead.
|
|
36
|
+
*/
|
|
37
|
+
removeListener(event, handler) {
|
|
38
|
+
this.off(event, handler);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Add an event listener.
|
|
43
|
+
* @deprecated please use {@link EventEmitter.on} instead.
|
|
44
|
+
*/
|
|
45
|
+
addListener(event, handler) {
|
|
46
|
+
this.on(event, handler);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Emit an event and call any associated listeners.
|
|
51
|
+
*
|
|
52
|
+
* @param event - the event you'd like to emit
|
|
53
|
+
* @param eventData - any data you'd like to emit with the event
|
|
54
|
+
* @returns `true` if there are any listeners, `false` if there are not.
|
|
55
|
+
*/
|
|
56
|
+
emit(event, eventData) {
|
|
57
|
+
this.emitter.emit(event, eventData);
|
|
58
|
+
return this.eventListenersCount(event) > 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Like `on` but the listener will only be fired once and then it will be removed.
|
|
62
|
+
* @param event - the event you'd like to listen to
|
|
63
|
+
* @param handler - the handler function to run when the event occurs
|
|
64
|
+
* @returns `this` to enable you to chain method calls.
|
|
65
|
+
*/
|
|
66
|
+
once(event, handler) {
|
|
67
|
+
const onceHandler = (eventData) => {
|
|
68
|
+
handler(eventData);
|
|
69
|
+
this.off(event, onceHandler);
|
|
70
|
+
};
|
|
71
|
+
return this.on(event, onceHandler);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets the number of listeners for a given event.
|
|
75
|
+
*
|
|
76
|
+
* @param event - the event to get the listener count for
|
|
77
|
+
* @returns the number of listeners bound to the given event
|
|
78
|
+
*/
|
|
79
|
+
listenerCount(event) {
|
|
80
|
+
return this.eventListenersCount(event);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Removes all listeners. If given an event argument, it will remove only
|
|
84
|
+
* listeners for that event.
|
|
85
|
+
* @param event - the event to remove listeners for.
|
|
86
|
+
* @returns `this` to enable you to chain method calls.
|
|
87
|
+
*/
|
|
88
|
+
removeAllListeners(event) {
|
|
89
|
+
if (event) {
|
|
90
|
+
this.eventsMap.delete(event);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.eventsMap.clear();
|
|
94
|
+
}
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
eventListenersCount(event) {
|
|
98
|
+
var _a;
|
|
99
|
+
return ((_a = this.eventsMap.get(event)) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.EventEmitter = EventEmitter;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2017 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 { Protocol } from 'devtools-protocol';
|
|
17
|
+
import { CDPSession } from './Connection';
|
|
18
|
+
import { DOMWorld } from './DOMWorld';
|
|
19
|
+
import { EvaluateHandleFn, SerializableOrJSHandle } from './EvalTypes';
|
|
20
|
+
import { Frame } from './FrameManager';
|
|
21
|
+
import { ElementHandle, JSHandle } from './JSHandle';
|
|
22
|
+
export declare const EVALUATION_SCRIPT_URL = "pptr://__puppeteer_evaluation_script__";
|
|
23
|
+
export declare class ExecutionContext {
|
|
24
|
+
#private;
|
|
25
|
+
_client: CDPSession;
|
|
26
|
+
_world: DOMWorld;
|
|
27
|
+
_contextId: number;
|
|
28
|
+
_contextName: string;
|
|
29
|
+
constructor(client: CDPSession, contextPayload: Protocol.Runtime.ExecutionContextDescription, world: DOMWorld);
|
|
30
|
+
frame(): Frame | null;
|
|
31
|
+
evaluate<ReturnType>(pageFunction: Function | string, ...args: unknown[]): Promise<ReturnType>;
|
|
32
|
+
evaluateHandle<HandleType extends JSHandle | ElementHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandleType>;
|
|
33
|
+
_adoptBackendNodeId(backendNodeId?: Protocol.DOM.BackendNodeId): Promise<ElementHandle>;
|
|
34
|
+
_adoptElementHandle(elementHandle: ElementHandle): Promise<ElementHandle>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-new-func */
|
|
3
|
+
/* eslint-disable no-new */
|
|
4
|
+
/**
|
|
5
|
+
* Copyright 2017 Google Inc. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
20
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
21
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
22
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
23
|
+
};
|
|
24
|
+
var _ExecutionContext_instances, _ExecutionContext_evaluate;
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ExecutionContext = exports.EVALUATION_SCRIPT_URL = void 0;
|
|
27
|
+
const assert_1 = require("./assert");
|
|
28
|
+
const JSHandle_1 = require("./JSHandle");
|
|
29
|
+
const util_1 = require("./util");
|
|
30
|
+
exports.EVALUATION_SCRIPT_URL = 'pptr://__puppeteer_evaluation_script__';
|
|
31
|
+
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
|
|
32
|
+
class ExecutionContext {
|
|
33
|
+
constructor(client, contextPayload, world) {
|
|
34
|
+
_ExecutionContext_instances.add(this);
|
|
35
|
+
this._client = client;
|
|
36
|
+
this._world = world;
|
|
37
|
+
this._contextId = contextPayload.id;
|
|
38
|
+
this._contextName = contextPayload.name;
|
|
39
|
+
}
|
|
40
|
+
frame() {
|
|
41
|
+
return this._world ? this._world.frame() : null;
|
|
42
|
+
}
|
|
43
|
+
evaluate(pageFunction, ...args) {
|
|
44
|
+
return __classPrivateFieldGet(this, _ExecutionContext_instances, "m", _ExecutionContext_evaluate).call(this, true, pageFunction, ...args);
|
|
45
|
+
}
|
|
46
|
+
evaluateHandle(pageFunction, ...args) {
|
|
47
|
+
return __classPrivateFieldGet(this, _ExecutionContext_instances, "m", _ExecutionContext_evaluate).call(this, false, pageFunction, ...args);
|
|
48
|
+
}
|
|
49
|
+
async _adoptBackendNodeId(backendNodeId) {
|
|
50
|
+
const { object } = await this._client.send('DOM.resolveNode', {
|
|
51
|
+
backendNodeId,
|
|
52
|
+
executionContextId: this._contextId,
|
|
53
|
+
});
|
|
54
|
+
return (0, JSHandle_1._createJSHandle)(this, object);
|
|
55
|
+
}
|
|
56
|
+
async _adoptElementHandle(elementHandle) {
|
|
57
|
+
(0, assert_1.assert)(elementHandle.executionContext() !== this, 'Cannot adopt handle that already belongs to this execution context');
|
|
58
|
+
(0, assert_1.assert)(this._world, 'Cannot adopt handle without DOMWorld');
|
|
59
|
+
const nodeInfo = await this._client.send('DOM.describeNode', {
|
|
60
|
+
objectId: elementHandle._remoteObject.objectId,
|
|
61
|
+
});
|
|
62
|
+
return this._adoptBackendNodeId(nodeInfo.node.backendNodeId);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ExecutionContext = ExecutionContext;
|
|
66
|
+
_ExecutionContext_instances = new WeakSet(), _ExecutionContext_evaluate = async function _ExecutionContext_evaluate(returnByValue, pageFunction, ...args) {
|
|
67
|
+
const suffix = `//# sourceURL=${exports.EVALUATION_SCRIPT_URL}`;
|
|
68
|
+
if ((0, util_1.isString)(pageFunction)) {
|
|
69
|
+
const contextId = this._contextId;
|
|
70
|
+
const expression = pageFunction;
|
|
71
|
+
const expressionWithSourceUrl = SOURCE_URL_REGEX.test(expression)
|
|
72
|
+
? expression
|
|
73
|
+
: expression + '\n' + suffix;
|
|
74
|
+
const { exceptionDetails: _details, result: _remoteObject } = await this._client
|
|
75
|
+
.send('Runtime.evaluate', {
|
|
76
|
+
expression: expressionWithSourceUrl,
|
|
77
|
+
contextId,
|
|
78
|
+
returnByValue,
|
|
79
|
+
awaitPromise: true,
|
|
80
|
+
userGesture: true,
|
|
81
|
+
})
|
|
82
|
+
.catch(rewriteError);
|
|
83
|
+
if (_details) {
|
|
84
|
+
throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(_details));
|
|
85
|
+
}
|
|
86
|
+
return returnByValue
|
|
87
|
+
? (0, util_1.valueFromRemoteObject)(_remoteObject)
|
|
88
|
+
: (0, JSHandle_1._createJSHandle)(this, _remoteObject);
|
|
89
|
+
}
|
|
90
|
+
if (typeof pageFunction !== 'function') {
|
|
91
|
+
throw new Error(`Expected to get |string| or |function| as the first argument, but got "${pageFunction}" instead.`);
|
|
92
|
+
}
|
|
93
|
+
let functionText = pageFunction.toString();
|
|
94
|
+
try {
|
|
95
|
+
new Function('(' + functionText + ')');
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// This means we might have a function shorthand. Try another
|
|
99
|
+
// time prefixing 'function '.
|
|
100
|
+
if (functionText.startsWith('async ')) {
|
|
101
|
+
functionText =
|
|
102
|
+
'async function ' + functionText.substring('async '.length);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
functionText = 'function ' + functionText;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
new Function('(' + functionText + ')');
|
|
109
|
+
}
|
|
110
|
+
catch (_error) {
|
|
111
|
+
// We tried hard to serialize, but there's a weird beast here.
|
|
112
|
+
throw new Error('Passed function is not well-serializable!');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let callFunctionOnPromise;
|
|
116
|
+
try {
|
|
117
|
+
callFunctionOnPromise = this._client.send('Runtime.callFunctionOn', {
|
|
118
|
+
functionDeclaration: functionText + '\n' + suffix + '\n',
|
|
119
|
+
executionContextId: this._contextId,
|
|
120
|
+
arguments: args.map(convertArgument.bind(this)),
|
|
121
|
+
returnByValue,
|
|
122
|
+
awaitPromise: true,
|
|
123
|
+
userGesture: true,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (error instanceof TypeError &&
|
|
128
|
+
error.message.startsWith('Converting circular structure to JSON')) {
|
|
129
|
+
error.message += ' Recursive objects are not allowed.';
|
|
130
|
+
}
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
const { exceptionDetails, result: remoteObject } = await callFunctionOnPromise.catch(rewriteError);
|
|
134
|
+
if (exceptionDetails) {
|
|
135
|
+
throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(exceptionDetails));
|
|
136
|
+
}
|
|
137
|
+
return returnByValue
|
|
138
|
+
? (0, util_1.valueFromRemoteObject)(remoteObject)
|
|
139
|
+
: (0, JSHandle_1._createJSHandle)(this, remoteObject);
|
|
140
|
+
function convertArgument(arg) {
|
|
141
|
+
if (typeof arg === 'bigint') {
|
|
142
|
+
// eslint-disable-line valid-typeof
|
|
143
|
+
return { unserializableValue: `${arg.toString()}n` };
|
|
144
|
+
}
|
|
145
|
+
if (Object.is(arg, -0)) {
|
|
146
|
+
return { unserializableValue: '-0' };
|
|
147
|
+
}
|
|
148
|
+
if (Object.is(arg, Infinity)) {
|
|
149
|
+
return { unserializableValue: 'Infinity' };
|
|
150
|
+
}
|
|
151
|
+
if (Object.is(arg, -Infinity)) {
|
|
152
|
+
return { unserializableValue: '-Infinity' };
|
|
153
|
+
}
|
|
154
|
+
if (Object.is(arg, NaN)) {
|
|
155
|
+
return { unserializableValue: 'NaN' };
|
|
156
|
+
}
|
|
157
|
+
const objectHandle = arg && arg instanceof JSHandle_1.JSHandle ? arg : null;
|
|
158
|
+
if (objectHandle) {
|
|
159
|
+
if (objectHandle._context !== this) {
|
|
160
|
+
throw new Error('JSHandles can be evaluated only in the context they were created!');
|
|
161
|
+
}
|
|
162
|
+
if (objectHandle._disposed) {
|
|
163
|
+
throw new Error('JSHandle is disposed!');
|
|
164
|
+
}
|
|
165
|
+
if (objectHandle._remoteObject.unserializableValue) {
|
|
166
|
+
return {
|
|
167
|
+
unserializableValue: objectHandle._remoteObject.unserializableValue,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (!objectHandle._remoteObject.objectId) {
|
|
171
|
+
return { value: objectHandle._remoteObject.value };
|
|
172
|
+
}
|
|
173
|
+
return { objectId: objectHandle._remoteObject.objectId };
|
|
174
|
+
}
|
|
175
|
+
return { value: arg };
|
|
176
|
+
}
|
|
177
|
+
function rewriteError(error) {
|
|
178
|
+
if (error.message.includes('Object reference chain is too long')) {
|
|
179
|
+
return { result: { type: 'undefined' } };
|
|
180
|
+
}
|
|
181
|
+
if (error.message.includes("Object couldn't be returned by value")) {
|
|
182
|
+
return { result: { type: 'undefined' } };
|
|
183
|
+
}
|
|
184
|
+
if (error.message.endsWith('Cannot find context with specified id') ||
|
|
185
|
+
error.message.endsWith('Inspected target navigated or closed')) {
|
|
186
|
+
throw new Error('Execution context was destroyed, most likely because of a navigation.');
|
|
187
|
+
}
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { Protocol } from 'devtools-protocol';
|
|
17
|
+
import { ElementHandle } from './JSHandle';
|
|
18
|
+
/**
|
|
19
|
+
* File choosers let you react to the page requesting for a file.
|
|
20
|
+
* @remarks
|
|
21
|
+
* `FileChooser` objects are returned via the `page.waitForFileChooser` method.
|
|
22
|
+
* @example
|
|
23
|
+
* An example of using `FileChooser`:
|
|
24
|
+
* ```js
|
|
25
|
+
* const [fileChooser] = await Promise.all([
|
|
26
|
+
* page.waitForFileChooser(),
|
|
27
|
+
* page.click('#upload-file-button'), // some button that triggers file selection
|
|
28
|
+
* ]);
|
|
29
|
+
* await fileChooser.accept(['/tmp/myfile.pdf']);
|
|
30
|
+
* ```
|
|
31
|
+
* **NOTE** In browsers, only one file chooser can be opened at a time.
|
|
32
|
+
* All file choosers must be accepted or canceled. Not doing so will prevent
|
|
33
|
+
* subsequent file choosers from appearing.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare class FileChooser {
|
|
37
|
+
#private;
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
constructor(element: ElementHandle, event: Protocol.Page.FileChooserOpenedEvent);
|
|
42
|
+
/**
|
|
43
|
+
* Whether file chooser allow for {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-multiple | multiple} file selection.
|
|
44
|
+
*/
|
|
45
|
+
isMultiple(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Accept the file chooser request with given paths.
|
|
48
|
+
* @param filePaths - If some of the `filePaths` are relative paths,
|
|
49
|
+
* then they are resolved relative to the {@link https://nodejs.org/api/process.html#process_process_cwd | current working directory}.
|
|
50
|
+
*/
|
|
51
|
+
accept(filePaths: string[]): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Closes the file chooser without selecting any files.
|
|
54
|
+
*/
|
|
55
|
+
cancel(): void;
|
|
56
|
+
}
|