Skip to content

Commit 08b43f6

Browse files
committed
fix typedefs and move to the end of thie file.
1 parent 5d1b751 commit 08b43f6

File tree

1 file changed

+37
-60
lines changed

1 file changed

+37
-60
lines changed

lib/commands/record-screen.js

Lines changed: 37 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -335,53 +335,17 @@ export async function windowsStopRecordingScreen (
335335
});
336336
}
337337

338-
/**
339-
* @typedef {Object} StartRecordingOptions
340-
*
341-
* @property {string} videoFilter - The video filter spec to apply for ffmpeg.
342-
* See https://trac.ffmpeg.org/wiki/FilteringGuide for more details on the possible values.
343-
* Example: Set it to `scale=ifnot(gte(iw\,1024)\,iw\,1024):-2` in order to limit the video width
344-
* to 1024px. The height will be adjusted automatically to match the actual ratio.
345-
* @property {number|string} fps [15] - The count of frames per second in the resulting video.
346-
* The greater fps it has the bigger file size is.
347-
* @property {string} preset [veryfast] - One of the supported encoding presets. Possible values are:
348-
* - ultrafast
349-
* - superfast
350-
* - veryfast
351-
* - faster
352-
* - fast
353-
* - medium
354-
* - slow
355-
* - slower
356-
* - veryslow
357-
* A preset is a collection of options that will provide a certain encoding speed to compression ratio.
358-
* A slower preset will provide better compression (compression is quality per filesize).
359-
* This means that, for example, if you target a certain file size or constant bit rate, you will achieve better
360-
* quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264 for more details.
361-
* @property {boolean} captureCursor [false] - Whether to capture the mouse cursor while recording
362-
* the screen
363-
* @property {boolean} captureClicks [false] - Whether to capture mouse clicks while recording the
364-
* screen
365-
* @property {string} audioInput - If set then the given audio input will be used to record the computer audio
366-
* along with the desktop video. The list of available devices could be retrieved using
367-
* `ffmpeg -list_devices true -f dshow -i dummy` command.
368-
* @property {string|number} timeLimit [600] - The maximum recording time, in seconds. The default
369-
* value is 600 seconds (10 minutes).
370-
* @property {boolean} forceRestart [true] - Whether to ignore the call if a screen recording is currently running
371-
* (`false`) or to start a new recording immediately and terminate the existing one if running (`true`).
372-
*/
373-
374338
/**
375339
* Record the display in background while the automated test is running.
376340
* This method requires FFMPEG (https://www.ffmpeg.org/download.html) to be installed
377341
* and present in PATH.
378342
* The resulting video uses H264 codec and is ready to be played by media players built-in into web browsers.
379343
*
380-
* @param {StartRecordingOptions} options - The available options.
344+
* @param {StartRecordingOptions} [options] - The available options.
381345
* @this {import('../driver').WindowsDriver}
382346
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
383347
*/
384-
export async function startRecordingScreen(options) {
348+
export async function startRecordingScreen(options = {}) {
385349
const {
386350
timeLimit,
387351
videoFilter,
@@ -391,7 +355,7 @@ export async function startRecordingScreen(options) {
391355
captureClicks,
392356
audioInput,
393357
forceRestart = true,
394-
} = options ?? {};
358+
} = options;
395359

396360
await this.windowsStartRecordingScreen(
397361
timeLimit,
@@ -405,38 +369,20 @@ export async function startRecordingScreen(options) {
405369
);
406370
}
407371

408-
/**
409-
* @typedef {Object} StopRecordingOptions
410-
*
411-
* @property {string} remotePath - The path to the remote location, where the resulting video should be uploaded.
412-
* The following protocols are supported: http/https, ftp.
413-
* Null or empty string value (the default setting) means the content of resulting
414-
* file should be encoded as Base64 and passed as the endpoint response value.
415-
* An exception will be thrown if the generated media file is too big to
416-
* fit into the available process memory.
417-
* @property {string} user - The name of the user for the remote authentication.
418-
* @property {string} pass - The password for the remote authentication.
419-
* @property {string} method - The http multipart upload method name. The 'PUT' one is used by default.
420-
* @property {Object} headers - Additional headers mapping for multipart http(s) uploads
421-
* @property {string} fileFieldName [file] - The name of the form field, where the file content BLOB should be stored for
422-
* http(s) uploads
423-
* @property {Object[]|[string, string][]} formFields - Additional form fields for multipart http(s) uploads
424-
*/
425-
426372
/**
427373
* Stop recording the screen.
428374
* If no screen recording has been started before then the method returns an empty string.
429375
*
430-
* @param {StopRecordingOptions} options - The available options.
376+
* @param {StopRecordingOptions} [options] - The available options.
431377
* @returns {Promise<string>} Base64-encoded content of the recorded media file if 'remotePath'
432378
* parameter is falsy or an empty string.
433379
* @this {import('../driver').WindowsDriver}
434380
* @throws {Error} If there was an error while getting the name of a media file
435381
* or the file content cannot be uploaded to the remote location
436382
* or screen recording is not supported on the device under test.
437383
*/
438-
export async function stopRecordingScreen(options) {
439-
const {remotePath, user, pass, method, headers, fileFieldName, formFields} = options ?? {};
384+
export async function stopRecordingScreen(options = {}) {
385+
const {remotePath, user, pass, method, headers, fileFieldName, formFields} = options;
440386

441387
return await this.windowsStopRecordingScreen(
442388
remotePath,
@@ -452,3 +398,34 @@ export async function stopRecordingScreen(options) {
452398
/**
453399
* @typedef {import('../driver').WindowsDriver} WindowsDriver
454400
*/
401+
402+
/**
403+
* For detailed explanations of each property,
404+
* please refer to the parameters of the `windowsStartRecordingScreen` function.
405+
*
406+
* @typedef {Object} StartRecordingOptions
407+
*
408+
* @property {string} [videoFilter]
409+
* @property {number|string} [fps=15]
410+
* @property {string} [preset='veryfast']
411+
* @property {boolean} [captureCursor=false]
412+
* @property {boolean} [captureClicks=false]
413+
* @property {string} [audioInput]
414+
* @property {string|number} [timeLimit=600]
415+
* @property {boolean} [forceRestart=true]
416+
*/
417+
418+
/**
419+
* For detailed explanations of each property,
420+
* please refer to the parameters of the `windowsStopRecordingScreen` function.
421+
*
422+
* @typedef {Object} StopRecordingOptions
423+
*
424+
* @property {string} [remotePath]
425+
* @property {string} [user]
426+
* @property {string} [pass]
427+
* @property {string} [method]
428+
* @property {Object} [headers]
429+
* @property {string} [fileFieldName='file']
430+
* @property {Object[]|[string, string][]} [formFields]
431+
*/

0 commit comments

Comments
 (0)