From 4b3c220c0c609802924b7b6ff9a4dfa7a98eb5f4 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Sun, 7 Apr 2024 21:48:06 +0200 Subject: [PATCH] feat: Add types for WDA caps and settings (#885) --- index.js | 22 ---------------------- index.ts | 7 +++++++ lib/types.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 +++-- tsconfig.json | 2 +- 5 files changed, 61 insertions(+), 25 deletions(-) delete mode 100644 index.js create mode 100644 index.ts create mode 100644 lib/types.ts diff --git a/index.js b/index.js deleted file mode 100644 index 3513d683b..000000000 --- a/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import * as dependencies from './lib/check-dependencies'; -import * as proxies from './lib/no-session-proxy'; -import * as driver from './lib/webdriveragent'; -import * as constants from './lib/constants'; -import * as utils from './lib/utils'; - - -const { checkForDependencies, bundleWDASim } = dependencies; -const { NoSessionProxy } = proxies; -const { WebDriverAgent } = driver; -const { WDA_BASE_URL, WDA_RUNNER_BUNDLE_ID, PROJECT_FILE } = constants; -const { resetTestProcesses, BOOTSTRAP_PATH } = utils; - -export { - WebDriverAgent, - NoSessionProxy, - checkForDependencies, bundleWDASim, - resetTestProcesses, - BOOTSTRAP_PATH, - WDA_RUNNER_BUNDLE_ID, PROJECT_FILE, - WDA_BASE_URL, -}; diff --git a/index.ts b/index.ts new file mode 100644 index 000000000..d8e3996bd --- /dev/null +++ b/index.ts @@ -0,0 +1,7 @@ +export { checkForDependencies, bundleWDASim } from './lib/check-dependencies'; +export { NoSessionProxy } from './lib/no-session-proxy'; +export { WebDriverAgent } from './lib/webdriveragent'; +export { WDA_BASE_URL, WDA_RUNNER_BUNDLE_ID, PROJECT_FILE } from './lib/constants'; +export { resetTestProcesses, BOOTSTRAP_PATH } from './lib/utils'; + +export * from './lib/types'; diff --git a/lib/types.ts b/lib/types.ts new file mode 100644 index 000000000..3c6a22538 --- /dev/null +++ b/lib/types.ts @@ -0,0 +1,50 @@ +// WebDriverAgentLib/Utilities/FBSettings.h +export interface WDASettings { + elementResponseAttribute?: string; + shouldUseCompactResponses?: boolean; + mjpegServerScreenshotQuality?: number; + mjpegServerFramerate?: number; + screenshotQuality?: number; + elementResponseAttributes?: string; + mjpegScalingFactor?: number; + mjpegFixOrientation?: boolean; + keyboardAutocorrection?: boolean; + keyboardPrediction?: boolean; + customSnapshotTimeout?: number; + snapshotMaxDepth?: number; + useFirstMatch?: boolean; + boundElementsByIndex?: boolean; + reduceMotion?: boolean; + defaultActiveApplication?: string; + activeAppDetectionPoint?: string; + includeNonModalElements?: boolean; + defaultAlertAction?: 'accept' | 'dismiss'; + acceptAlertButtonSelector?: string; + dismissAlertButtonSelector?: string; + screenshotOrientation?: 'auto' | 'portrait' | 'portraitUpsideDown' | 'landscapeRight' | 'landscapeLeft' + waitForIdleTimeout?: number; + animationCoolOffTimeout?: number; +} + +// WebDriverAgentLib/Utilities/FBCapabilities.h +export interface WDACapabilities { + bundleId?: string; + initialUrl?: string; + arguments?: string[]; + environment?: Record; + eventloopIdleDelaySec?: number; + shouldWaitForQuiescence?: boolean; + shouldUseTestManagerForVisibilityDetection?: boolean; + maxTypingFrequency?: number; + shouldUseSingletonTestManager?: boolean; + waitForIdleTimeout?: number; + shouldUseCompactResponses?: number; + elementResponseFields?: unknown; + disableAutomaticScreenshots?: boolean; + shouldTerminateApp?: boolean; + forceAppLaunch?: boolean; + useNativeCachingStrategy?: boolean; + forceSimulatorSoftwareKeyboardPresence?: boolean; + defaultAlertAction?: 'accept' | 'dismiss'; + appLaunchStateTimeoutSec?: number; +} diff --git a/package.json b/package.json index 54ba7aa1d..0bca8c797 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "8.4.0", "description": "Package bundling WebDriverAgent", "main": "./build/index.js", + "types": "./build/index.d.ts", "scripts": { "build": "tsc -b", "dev": "npm run build -- --watch", @@ -100,9 +101,9 @@ "teen_process": "^2.0.0" }, "files": [ - "index.js", + "index.ts", "lib", - "build/index.js", + "build/index.*", "build/lib", "Scripts/build.sh", "Scripts/fetch-prebuilt-wda.js", diff --git a/tsconfig.json b/tsconfig.json index 33d83ef45..678d20ad0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "checkJs": true }, "include": [ - "index.js", + "index.ts", "lib" ] }