@remotion/renderer 3.0.31 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/browser/NetworkManager.js +1 -5
  2. package/dist/combine-videos.d.ts +2 -1
  3. package/dist/combine-videos.js +8 -2
  4. package/dist/convert-number-of-gif-loops-to-ffmpeg.d.ts +1 -0
  5. package/dist/convert-number-of-gif-loops-to-ffmpeg.js +17 -0
  6. package/dist/ensure-frames-in-order.d.ts +1 -1
  7. package/dist/ensure-frames-in-order.js +3 -2
  8. package/dist/ensure-presentation-timestamp.d.ts +1 -1
  9. package/dist/ensure-presentation-timestamp.js +9 -10
  10. package/dist/extract-frame-from-video.js +4 -2
  11. package/dist/get-codec-name.js +3 -0
  12. package/dist/get-duration-from-frame-range.d.ts +1 -2
  13. package/dist/get-duration-from-frame-range.js +13 -9
  14. package/dist/get-extension-from-codec.d.ts +1 -1
  15. package/dist/get-extension-from-codec.js +5 -0
  16. package/dist/index.d.ts +4 -3
  17. package/dist/index.js +3 -1
  18. package/dist/mime-types.d.ts +1 -1
  19. package/dist/mime-types.js +2 -2
  20. package/dist/prespawn-ffmpeg.js +2 -2
  21. package/dist/render-frames.d.ts +1 -0
  22. package/dist/render-frames.js +12 -16
  23. package/dist/render-media.d.ts +2 -0
  24. package/dist/render-media.js +11 -4
  25. package/dist/render-still.js +1 -1
  26. package/dist/stitch-frames-to-video.d.ts +1 -0
  27. package/dist/stitch-frames-to-video.js +32 -22
  28. package/dist/validate-output-filename.js +5 -0
  29. package/package.json +8 -10
  30. package/tsconfig.json +2 -1
  31. package/vitest.config.ts +8 -0
  32. package/dist/abort.d.ts +0 -7
  33. package/dist/abort.js +0 -20
  34. package/dist/assets/cleanup-assets.d.ts +0 -2
  35. package/dist/assets/cleanup-assets.js +0 -2
  36. package/dist/browser/ConnectionTransport.d.ts +0 -21
  37. package/dist/browser/ConnectionTransport.js +0 -17
  38. package/dist/browser/EmulationManager.d.ts +0 -7
  39. package/dist/browser/EmulationManager.js +0 -40
  40. package/dist/browser/Page.d.ts +0 -74
  41. package/dist/browser/Page.js +0 -283
  42. package/dist/browser/compat.d.ts +0 -2
  43. package/dist/browser/compat.js +0 -17
  44. package/dist/browser/environment.d.ts +0 -16
  45. package/dist/browser/environment.js +0 -19
  46. package/dist/browser/ws.d.ts +0 -287
  47. package/dist/browser/ws.js +0 -21
  48. package/dist/cancel.d.ts +0 -7
  49. package/dist/cancel.js +0 -25
  50. package/dist/ensure-faststart.d.ts +0 -1
  51. package/dist/ensure-faststart.js +0 -14
  52. package/dist/faststart/atom.d.ts +0 -35
  53. package/dist/faststart/atom.js +0 -138
  54. package/dist/faststart/index.d.ts +0 -0
  55. package/dist/faststart/index.js +0 -1
  56. package/dist/faststart/options.d.ts +0 -6
  57. package/dist/faststart/options.js +0 -2
  58. package/dist/faststart/qt-faststart.d.ts +0 -18
  59. package/dist/faststart/qt-faststart.js +0 -66
  60. package/dist/faststart/update-chunk-offsets.d.ts +0 -10
  61. package/dist/faststart/update-chunk-offsets.js +0 -114
  62. package/dist/faststart/util.d.ts +0 -9
  63. package/dist/faststart/util.js +0 -34
  64. package/dist/get-duration-of-asset.d.ts +0 -7
  65. package/dist/get-duration-of-asset.js +0 -36
  66. package/dist/is-vp9-video.d.ts +0 -3
  67. package/dist/is-vp9-video.js +0 -24
  68. package/dist/offthread/index.d.ts +0 -0
  69. package/dist/offthread/index.js +0 -1
  70. package/dist/render-gif.d.ts +0 -2
  71. package/dist/render-gif.js +0 -242
  72. package/dist/serve-handler/glob-slash.d.ts +0 -1
  73. package/dist/serve-handler/glob-slash.js +0 -12
  74. package/dist/should-use-vp9-decoder.d.ts +0 -0
  75. package/dist/should-use-vp9-decoder.js +0 -1
  76. package/dist/stitch-frames-to-gif.d.ts +0 -8
  77. package/dist/stitch-frames-to-gif.js +0 -128
  78. package/dist/validate-fps-for-gif.d.ts +0 -2
  79. package/dist/validate-fps-for-gif.js +0 -9
  80. package/dist/validate-offthreadvideo-image-format.d.ts +0 -1
  81. package/dist/validate-offthreadvideo-image-format.js +0 -15
  82. package/dist/ws/buffer-util.d.ts +0 -10
  83. package/dist/ws/buffer-util.js +0 -123
  84. package/dist/ws/constants.d.ts +0 -10
  85. package/dist/ws/constants.js +0 -13
  86. package/dist/ws/event-target.d.ts +0 -155
  87. package/dist/ws/event-target.js +0 -203
  88. package/dist/ws/extension.d.ts +0 -16
  89. package/dist/ws/extension.js +0 -232
  90. package/dist/ws/limiter.d.ts +0 -34
  91. package/dist/ws/limiter.js +0 -41
  92. package/dist/ws/permessage_deflate.d.ts +0 -152
  93. package/dist/ws/permessage_deflate.js +0 -409
@@ -12,6 +12,8 @@ const remotion_1 = require("remotion");
12
12
  const calculate_asset_positions_1 = require("./assets/calculate-asset-positions");
13
13
  const convert_assets_to_file_urls_1 = require("./assets/convert-assets-to-file-urls");
14
14
  const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
15
+ const codec_supports_media_1 = require("./codec-supports-media");
16
+ const convert_number_of_gif_loops_to_ffmpeg_1 = require("./convert-number-of-gif-loops-to-ffmpeg");
15
17
  const delete_directory_1 = require("./delete-directory");
16
18
  const get_audio_codec_name_1 = require("./get-audio-codec-name");
17
19
  const get_codec_name_1 = require("./get-codec-name");
@@ -71,10 +73,9 @@ const getAssetsData = async ({ assets, downloadDir, onDownload, fps, expectedFra
71
73
  return outName;
72
74
  };
73
75
  const spawnFfmpeg = async (options) => {
74
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
76
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
75
77
  remotion_1.Internals.validateDimension(options.height, 'height', 'passed to `stitchFramesToVideo()`');
76
78
  remotion_1.Internals.validateDimension(options.width, 'width', 'passed to `stitchFramesToVideo()`');
77
- remotion_1.Internals.validateFps(options.fps, 'passed to `stitchFramesToVideo()`');
78
79
  const codec = (_a = options.codec) !== null && _a !== void 0 ? _a : remotion_1.Internals.DEFAULT_CODEC;
79
80
  (0, validate_even_dimensions_with_codec_1.validateEvenDimensionsWithCodec)({
80
81
  width: options.width,
@@ -82,13 +83,14 @@ const spawnFfmpeg = async (options) => {
82
83
  codec,
83
84
  scale: 1,
84
85
  });
86
+ remotion_1.Internals.validateFps(options.fps, 'in `stitchFramesToVideo()`', codec);
85
87
  const crf = (_b = options.crf) !== null && _b !== void 0 ? _b : remotion_1.Internals.getDefaultCrfForCodec(codec);
86
88
  const pixelFormat = (_c = options.pixelFormat) !== null && _c !== void 0 ? _c : remotion_1.Internals.DEFAULT_PIXEL_FORMAT;
87
89
  await (0, validate_ffmpeg_1.validateFfmpeg)((_d = options.ffmpegExecutable) !== null && _d !== void 0 ? _d : null);
88
90
  const encoderName = (0, get_codec_name_1.getCodecName)(codec);
89
91
  const audioCodecName = (0, get_audio_codec_name_1.getAudioCodecName)(codec);
90
92
  const proResProfileName = (0, get_prores_profile_name_1.getProResProfileName)(codec, options.proResProfile);
91
- const isAudioOnly = encoderName === null;
93
+ const mediaSupport = (0, codec_supports_media_1.codecSupportsMedia)(codec);
92
94
  const supportsCrf = encoderName && codec !== 'prores';
93
95
  const tempFile = options.outputLocation
94
96
  ? null
@@ -102,7 +104,7 @@ const spawnFfmpeg = async (options) => {
102
104
  console.log('[verbose] crf', crf);
103
105
  }
104
106
  console.log('[verbose] codec', codec);
105
- console.log('[verbose] isAudioOnly', isAudioOnly);
107
+ console.log('[verbose] isAudioOnly', mediaSupport.audio && !mediaSupport.video);
106
108
  console.log('[verbose] proResProfileName', proResProfileName);
107
109
  }
108
110
  remotion_1.Internals.validateSelectedCrfAndCodecCombination(crf, codec);
@@ -113,18 +115,20 @@ const spawnFfmpeg = async (options) => {
113
115
  const totalFrameProgress = 0.5 * preStitchProgress * expectedFrames + muxProgress * 0.5;
114
116
  (_a = options.onProgress) === null || _a === void 0 ? void 0 : _a.call(options, Math.round(totalFrameProgress));
115
117
  };
116
- const audio = await getAssetsData({
117
- assets: options.assetsInfo.assets,
118
- downloadDir: options.assetsInfo.downloadDir,
119
- onDownload: options.onDownload,
120
- fps: options.fps,
121
- expectedFrames,
122
- verbose: (_f = options.verbose) !== null && _f !== void 0 ? _f : false,
123
- ffmpegExecutable: (_g = options.ffmpegExecutable) !== null && _g !== void 0 ? _g : null,
124
- ffprobeExecutable: (_h = options.ffprobeExecutable) !== null && _h !== void 0 ? _h : null,
125
- onProgress: (prog) => updateProgress(prog, 0),
126
- });
127
- if (isAudioOnly) {
118
+ const audio = mediaSupport.audio
119
+ ? await getAssetsData({
120
+ assets: options.assetsInfo.assets,
121
+ downloadDir: options.assetsInfo.downloadDir,
122
+ onDownload: options.onDownload,
123
+ fps: options.fps,
124
+ expectedFrames,
125
+ verbose: (_f = options.verbose) !== null && _f !== void 0 ? _f : false,
126
+ ffmpegExecutable: (_g = options.ffmpegExecutable) !== null && _g !== void 0 ? _g : null,
127
+ ffprobeExecutable: (_h = options.ffprobeExecutable) !== null && _h !== void 0 ? _h : null,
128
+ onProgress: (prog) => updateProgress(prog, 0),
129
+ })
130
+ : null;
131
+ if (mediaSupport.audio && !mediaSupport.video) {
128
132
  if (!audioCodecName) {
129
133
  throw new TypeError('exporting audio but has no audio codec name. Report this in the Remotion repo.');
130
134
  }
@@ -160,11 +164,17 @@ const spawnFfmpeg = async (options) => {
160
164
  ['-start_number', String(options.assetsInfo.firstFrameIndex)],
161
165
  ['-i', options.assetsInfo.imageSequenceName],
162
166
  ]),
163
- ['-i', audio],
167
+ audio ? ['-i', audio] : null,
168
+ ((_p = options.numberOfGifLoops) !== null && _p !== void 0 ? _p : null) === null
169
+ ? null
170
+ : [
171
+ '-loop',
172
+ (0, convert_number_of_gif_loops_to_ffmpeg_1.convertNumberOfGifLoopsToFfmpegSyntax)((_q = options.numberOfGifLoops) !== null && _q !== void 0 ? _q : null),
173
+ ],
164
174
  // -c:v is the same as -vcodec as -codec:video
165
175
  // and specified the video codec.
166
176
  ['-c:v', encoderName],
167
- ...(((_p = options.internalOptions) === null || _p === void 0 ? void 0 : _p.preEncodedFileLocation)
177
+ ...(((_r = options.internalOptions) === null || _r === void 0 ? void 0 : _r.preEncodedFileLocation)
168
178
  ? []
169
179
  : [
170
180
  proResProfileName ? ['-profile:v', proResProfileName] : null,
@@ -187,22 +197,22 @@ const spawnFfmpeg = async (options) => {
187
197
  [`Made with Remotion`, packageJson ? packageJson.version : null].join(' '),
188
198
  ],
189
199
  options.force ? '-y' : null,
190
- (_q = options.outputLocation) !== null && _q !== void 0 ? _q : tempFile,
200
+ (_s = options.outputLocation) !== null && _s !== void 0 ? _s : tempFile,
191
201
  ];
192
202
  if (options.verbose) {
193
203
  console.log('Generated FFMPEG command:');
194
204
  console.log(ffmpegArgs);
195
205
  }
196
206
  const ffmpegString = ffmpegArgs.flat(2).filter(Boolean);
197
- const task = (0, execa_1.default)((_r = options.ffmpegExecutable) !== null && _r !== void 0 ? _r : 'ffmpeg', ffmpegString, {
207
+ const task = (0, execa_1.default)((_t = options.ffmpegExecutable) !== null && _t !== void 0 ? _t : 'ffmpeg', ffmpegString, {
198
208
  cwd: options.dir,
199
209
  });
200
- (_s = options.cancelSignal) === null || _s === void 0 ? void 0 : _s.call(options, () => {
210
+ (_u = options.cancelSignal) === null || _u === void 0 ? void 0 : _u.call(options, () => {
201
211
  task.kill();
202
212
  });
203
213
  let ffmpegOutput = '';
204
214
  let isFinished = false;
205
- (_t = task.stderr) === null || _t === void 0 ? void 0 : _t.on('data', (data) => {
215
+ (_v = task.stderr) === null || _v === void 0 ? void 0 : _v.on('data', (data) => {
206
216
  var _a;
207
217
  const str = data.toString();
208
218
  ffmpegOutput += str;
@@ -48,5 +48,10 @@ const validateOutputFilename = (codec, extension) => {
48
48
  throw new TypeError("When using the 'wav' codec, the output location must end in .wav.");
49
49
  }
50
50
  }
51
+ if (codec === 'gif') {
52
+ if (extension !== 'gif') {
53
+ throw new TypeError('When using the GIF codec, the output filename must end in .gif.');
54
+ }
55
+ }
51
56
  };
52
57
  exports.validateOutputFilename = validateOutputFilename;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "3.0.31",
3
+ "version": "3.1.0",
4
4
  "description": "Renderer for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "sideEffects": false,
8
8
  "scripts": {
9
9
  "lint": "eslint src --ext ts,tsx",
10
- "test": "jest --runInBand",
10
+ "test": "vitest --run",
11
11
  "watch": "tsc -w",
12
12
  "build": "tsc -d"
13
13
  },
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "execa": "5.1.1",
24
24
  "extract-zip": "2.0.1",
25
- "remotion": "3.0.31",
25
+ "remotion": "3.1.0",
26
26
  "source-map": "^0.8.0-beta.0",
27
27
  "ws": "8.7.0"
28
28
  },
@@ -32,21 +32,19 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@jonny/eslint-config": "3.0.266",
35
- "@testing-library/dom": "^8.7.2",
36
- "@testing-library/react": "13.1.1",
37
- "@types/jest": "^27.4.0",
35
+ "@testing-library/dom": "^8.16.0",
36
+ "@testing-library/react": "13.3.0",
38
37
  "@types/node": "^16.7.5",
39
38
  "@types/progress": "2.0.5",
40
39
  "@types/react": "18.0.1",
41
40
  "@types/react-dom": "18.0.0",
42
41
  "eslint": "8.13.0",
43
- "jest": "^27.2.4",
44
42
  "prettier": "^2.0.5",
45
43
  "prettier-plugin-organize-imports": "^2.3.4",
46
44
  "react": "18.0.0",
47
45
  "react-dom": "18.0.0",
48
- "ts-jest": "^27.0.5",
49
- "typescript": "^4.7.0"
46
+ "typescript": "^4.7.0",
47
+ "vitest": "^0.18.0"
50
48
  },
51
49
  "keywords": [
52
50
  "remotion",
@@ -59,5 +57,5 @@
59
57
  "publishConfig": {
60
58
  "access": "public"
61
59
  },
62
- "gitHead": "9342296ce1634b8b7b6dbdaee810a961f6922516"
60
+ "gitHead": "482c66127662171577aa427f10fe265fa1bc933b"
63
61
  }
package/tsconfig.json CHANGED
@@ -5,5 +5,6 @@
5
5
  "rootDir": "src",
6
6
  "outDir": "dist"
7
7
  },
8
- "references": [{"path": "../core"}, {"path": "../bundler"}]
8
+ "references": [{"path": "../core"}, {"path": "../bundler"}],
9
+ "exclude": ["vitest.config.ts", "dist"]
9
10
  }
@@ -0,0 +1,8 @@
1
+ import {defineConfig} from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ testTimeout: 90000,
6
+ maxConcurrency: 2,
7
+ },
8
+ });
package/dist/abort.d.ts DELETED
@@ -1,7 +0,0 @@
1
- declare type Callback = () => void;
2
- export declare type CancelSignal = (callback: Callback) => void;
3
- export declare const getCancelSignal: () => {
4
- cancelSignal: CancelSignal;
5
- cancel: () => void;
6
- };
7
- export {};
package/dist/abort.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCancelSignal = void 0;
4
- const getCancelSignal = () => {
5
- const callbacks = [];
6
- let cancelled = false;
7
- return {
8
- cancelSignal: (callback) => callbacks.push(callback),
9
- cancel: () => {
10
- if (cancelled) {
11
- return;
12
- }
13
- callbacks.forEach((cb) => {
14
- cb();
15
- });
16
- cancelled = true;
17
- },
18
- };
19
- };
20
- exports.getCancelSignal = getCancelSignal;
@@ -1,2 +0,0 @@
1
- export declare type RenderCleanupFn = () => Promise<void>;
2
- export declare type AddRenderCleanupFunction = (cleanup: RenderCleanupFn) => void;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +0,0 @@
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 interface ConnectionTransport {
17
- send(message: string): void;
18
- close(): void;
19
- onmessage?: (message: string) => void;
20
- onclose?: () => void;
21
- }
@@ -1,17 +0,0 @@
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 });
@@ -1,7 +0,0 @@
1
- import { CDPSession } from './Connection';
2
- import { Viewport } from './PuppeteerViewport';
3
- export declare class EmulationManager {
4
- #private;
5
- constructor(client: CDPSession);
6
- emulateViewport(viewport: Viewport): Promise<void>;
7
- }
@@ -1,40 +0,0 @@
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();
@@ -1,74 +0,0 @@
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 type { Browser } from './Browser';
17
- import type { CDPSession } from './Connection';
18
- import { ConsoleMessage } from './ConsoleMessage';
19
- import type { EvaluateFn, EvaluateFnReturnType, EvaluateHandleFn, SerializableOrJSHandle, UnwrapPromiseLike } from './EvalTypes';
20
- import { EventEmitter } from './EventEmitter';
21
- import type { Frame } from './FrameManager';
22
- import type { HTTPResponse } from './HTTPResponse';
23
- import type { JSHandle } from './JSHandle';
24
- import type { Viewport } from './PuppeteerViewport';
25
- import type { Target } from './Target';
26
- import { TaskQueue } from './TaskQueue';
27
- interface WaitForOptions {
28
- timeout?: number;
29
- }
30
- interface PageEventObject {
31
- console: ConsoleMessage;
32
- error: Error;
33
- }
34
- export declare class Page extends EventEmitter {
35
- #private;
36
- static _create(client: CDPSession, target: Target, defaultViewport: Viewport, browser: Browser): Promise<Page>;
37
- browser: Browser;
38
- screenshotTaskQueue: TaskQueue;
39
- constructor(client: CDPSession, target: Target, browser: Browser);
40
- /**
41
- * Listen to page events.
42
- */
43
- on<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
44
- once<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
45
- off<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
46
- /**
47
- * @returns A target this page was created from.
48
- */
49
- target(): Target;
50
- _client(): CDPSession;
51
- /**
52
- * @returns The page's main frame.
53
- * @remarks
54
- * Page is guaranteed to have a main frame which persists during navigations.
55
- */
56
- mainFrame(): Frame;
57
- setViewport(viewport: Viewport): Promise<void>;
58
- setDefaultNavigationTimeout(timeout: number): void;
59
- setDefaultTimeout(timeout: number): void;
60
- evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>;
61
- url(): string;
62
- goto(url: string, options?: WaitForOptions & {
63
- referer?: string;
64
- }): Promise<HTTPResponse | null>;
65
- bringToFront(): Promise<void>;
66
- evaluate<T extends EvaluateFn>(pageFunction: T, ...args: SerializableOrJSHandle[]): Promise<UnwrapPromiseLike<EvaluateFnReturnType<T>>>;
67
- evaluateOnNewDocument(pageFunction: Function | string, ...args: unknown[]): Promise<void>;
68
- close(options?: {
69
- runBeforeUnload?: boolean;
70
- }): Promise<void>;
71
- isClosed(): boolean;
72
- waitForFunction(browser: Browser, pageFunction: Function | string, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
73
- }
74
- export {};