rewrite devtools package

This commit is contained in:
Christian Bromann 2022-05-16 14:56:48 +02:00
parent ad29355f76
commit 0441aea615
46 changed files with 446 additions and 112 deletions

View file

@ -1,7 +1,7 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'unicorn'],
extends: [
'eslint:recommended'
],
@ -34,7 +34,8 @@ module.exports = {
'object-curly-spacing': ['error', 'always'],
'keyword-spacing':['error'],
'require-atomic-updates': 0,
'linebreak-style': ['error', 'unix']
'linebreak-style': ['error', 'unix'],
'unicorn/prefer-node-protocol': ['error', { 'checkRequire': true }]
},
overrides: [{
files: ['*.ts'],

View file

@ -21,7 +21,7 @@ declare const querySelectorShadowDom: {
locatorStrategy: ExecuteMethod
}
declare module "query-selector-shadow-dom/plugins/puppeteer" {
declare module "query-selector-shadow-dom/plugins/puppeteer/index.js" {
export = querySelectorShadowDom
}

308
package-lock.json generated
View file

@ -34,7 +34,8 @@
"del": "^6.0.0",
"depcheck": "^1.4.3",
"ejs": "^3.1.6",
"eslint": "^8.10.0",
"eslint": "^8.15.0",
"eslint-plugin-unicorn": "^42.0.0",
"husky": "^8.0.1",
"inquirer": "^8.2.1",
"jest": "^28.0.3",
@ -4540,6 +4541,18 @@
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"dev": true
},
"node_modules/builtin-modules": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
"dev": true,
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/builtins": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz",
@ -4929,6 +4942,27 @@
"integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==",
"dev": true
},
"node_modules/clean-regexp": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz",
"integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==",
"dev": true,
"dependencies": {
"escape-string-regexp": "^1.0.5"
},
"engines": {
"node": ">=4"
}
},
"node_modules/clean-regexp/node_modules/escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true,
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/clean-stack": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
@ -6744,6 +6778,114 @@
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint-plugin-unicorn": {
"version": "42.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-42.0.0.tgz",
"integrity": "sha512-ixBsbhgWuxVaNlPTT8AyfJMlhyC5flCJFjyK3oKE8TRrwBnaHvUbuIkCM1lqg8ryYrFStL/T557zfKzX4GKSlg==",
"dev": true,
"dependencies": {
"@babel/helper-validator-identifier": "^7.15.7",
"ci-info": "^3.3.0",
"clean-regexp": "^1.0.0",
"eslint-utils": "^3.0.0",
"esquery": "^1.4.0",
"indent-string": "^4.0.0",
"is-builtin-module": "^3.1.0",
"lodash": "^4.17.21",
"pluralize": "^8.0.0",
"read-pkg-up": "^7.0.1",
"regexp-tree": "^0.1.24",
"safe-regex": "^2.1.1",
"semver": "^7.3.5",
"strip-indent": "^3.0.0"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1"
},
"peerDependencies": {
"eslint": ">=8.8.0"
}
},
"node_modules/eslint-plugin-unicorn/node_modules/hosted-git-info": {
"version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
"node_modules/eslint-plugin-unicorn/node_modules/normalize-package-data": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
"integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
"dev": true,
"dependencies": {
"hosted-git-info": "^2.1.4",
"resolve": "^1.10.0",
"semver": "2 || 3 || 4 || 5",
"validate-npm-package-license": "^3.0.1"
}
},
"node_modules/eslint-plugin-unicorn/node_modules/normalize-package-data/node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true,
"bin": {
"semver": "bin/semver"
}
},
"node_modules/eslint-plugin-unicorn/node_modules/read-pkg": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
"integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==",
"dev": true,
"dependencies": {
"@types/normalize-package-data": "^2.4.0",
"normalize-package-data": "^2.5.0",
"parse-json": "^5.0.0",
"type-fest": "^0.6.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/eslint-plugin-unicorn/node_modules/read-pkg-up": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz",
"integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==",
"dev": true,
"dependencies": {
"find-up": "^4.1.0",
"read-pkg": "^5.2.0",
"type-fest": "^0.8.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-plugin-unicorn/node_modules/read-pkg/node_modules/type-fest": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz",
"integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/eslint-plugin-unicorn/node_modules/type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
@ -8306,6 +8448,18 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-builtin-module": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.1.0.tgz",
"integrity": "sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==",
"dev": true,
"dependencies": {
"builtin-modules": "^3.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/is-callable": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz",
@ -12278,6 +12432,15 @@
"semver-compare": "^1.0.0"
}
},
"node_modules/pluralize": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz",
"integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==",
"dev": true,
"engines": {
"node": ">=4"
}
},
"node_modules/postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@ -13186,6 +13349,15 @@
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true
},
"node_modules/safe-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz",
"integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==",
"dev": true,
"dependencies": {
"regexp-tree": "~0.1.1"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
@ -18832,6 +19004,12 @@
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"dev": true
},
"builtin-modules": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
"dev": true
},
"builtins": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz",
@ -19130,6 +19308,23 @@
"integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==",
"dev": true
},
"clean-regexp": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz",
"integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5"
},
"dependencies": {
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
}
}
},
"clean-stack": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
@ -20495,6 +20690,93 @@
}
}
},
"eslint-plugin-unicorn": {
"version": "42.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-42.0.0.tgz",
"integrity": "sha512-ixBsbhgWuxVaNlPTT8AyfJMlhyC5flCJFjyK3oKE8TRrwBnaHvUbuIkCM1lqg8ryYrFStL/T557zfKzX4GKSlg==",
"dev": true,
"requires": {
"@babel/helper-validator-identifier": "^7.15.7",
"ci-info": "^3.3.0",
"clean-regexp": "^1.0.0",
"eslint-utils": "^3.0.0",
"esquery": "^1.4.0",
"indent-string": "^4.0.0",
"is-builtin-module": "^3.1.0",
"lodash": "^4.17.21",
"pluralize": "^8.0.0",
"read-pkg-up": "^7.0.1",
"regexp-tree": "^0.1.24",
"safe-regex": "^2.1.1",
"semver": "^7.3.5",
"strip-indent": "^3.0.0"
},
"dependencies": {
"hosted-git-info": {
"version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
"normalize-package-data": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
"integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
"dev": true,
"requires": {
"hosted-git-info": "^2.1.4",
"resolve": "^1.10.0",
"semver": "2 || 3 || 4 || 5",
"validate-npm-package-license": "^3.0.1"
},
"dependencies": {
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
}
}
},
"read-pkg": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
"integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==",
"dev": true,
"requires": {
"@types/normalize-package-data": "^2.4.0",
"normalize-package-data": "^2.5.0",
"parse-json": "^5.0.0",
"type-fest": "^0.6.0"
},
"dependencies": {
"type-fest": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz",
"integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==",
"dev": true
}
}
},
"read-pkg-up": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz",
"integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==",
"dev": true,
"requires": {
"find-up": "^4.1.0",
"read-pkg": "^5.2.0",
"type-fest": "^0.8.1"
}
},
"type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true
}
}
},
"eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
@ -21641,6 +21923,15 @@
"has-tostringtag": "^1.0.0"
}
},
"is-builtin-module": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.1.0.tgz",
"integrity": "sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==",
"dev": true,
"requires": {
"builtin-modules": "^3.0.0"
}
},
"is-callable": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz",
@ -24730,6 +25021,12 @@
"semver-compare": "^1.0.0"
}
},
"pluralize": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz",
"integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==",
"dev": true
},
"postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@ -25408,6 +25705,15 @@
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true
},
"safe-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz",
"integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==",
"dev": true,
"requires": {
"regexp-tree": "~0.1.1"
}
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",

View file

@ -86,7 +86,8 @@
"del": "^6.0.0",
"depcheck": "^1.4.3",
"ejs": "^3.1.6",
"eslint": "^8.10.0",
"eslint": "^8.15.0",
"eslint-plugin-unicorn": "^42.0.0",
"husky": "^8.0.1",
"inquirer": "^8.2.1",
"jest": "^28.0.3",

View file

@ -5,12 +5,9 @@
"author": "Christian Bromann <mail@bromann.dev>",
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/devtools",
"license": "MIT",
"main": "./build/index",
"engines": {
"node": "^16.13 || >=18"
},
"types": "./build/index.d.ts",
"typeScriptVersion": "3.8.3",
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"
@ -21,6 +18,20 @@
"bugs": {
"url": "https://github.com/webdriverio/webdriverio/issues"
},
"main": "./build/index.cjs.js",
"type": "module",
"module": "./build/index.js",
"exports": {
".": [
{
"import": "./build/index.js",
"require": "./build/index.cjs.js"
},
"./build/index.cjs.js"
]
},
"types": "./build/index.d.ts",
"typeScriptVersion": "3.8.3",
"dependencies": {
"@types/node": "^18.0.0",
"@types/ua-parser-js": "^0.7.33",

View file

@ -1,5 +1,5 @@
import { v4 as uuidv4 } from 'uuid'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,7 +1,6 @@
import command from '../scripts/createWindow.js'
import type DevToolsDriver from '../devtoolsdriver'
import command from '../scripts/createWindow'
const WINDOW_FEATURES = 'menubar=1,toolbar=1,location=1,resizable=1,scrollbars=1'
const NEW_PAGE_URL = 'about:blank'
const DEFAULT_WINDOW_TYPE = 'tab'

View file

@ -1,5 +1,5 @@
import command from '../scripts/elementClear'
import { getStaleElementError } from '../utils'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,6 +1,6 @@
import getElementTagName from './getElementTagName'
import selectOptionScript from '../scripts/selectOption'
import { getStaleElementError } from '../utils'
import getElementTagName from './getElementTagName.js'
import selectOptionScript from '../scripts/selectOption.js'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,8 +1,8 @@
import path from 'path'
import path from 'node:path'
import { UNICODE_CHARACTERS } from '@wdio/utils'
import type { KeyInput } from 'puppeteer-core'
import { getStaleElementError } from '../utils'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,6 +1,6 @@
import command from '../scripts/executeAsyncScript'
import { transformExecuteArgs, transformExecuteResult } from '../utils'
import { SERIALIZE_PROPERTY, SERIALIZE_FLAG } from '../constants'
import command from '../scripts/executeAsyncScript.js'
import { transformExecuteArgs, transformExecuteResult } from '../utils.js'
import { SERIALIZE_PROPERTY, SERIALIZE_FLAG } from '../constants.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,6 +1,6 @@
import command from '../scripts/executeScript'
import { transformExecuteArgs, transformExecuteResult } from '../utils'
import { SERIALIZE_PROPERTY, SERIALIZE_FLAG } from '../constants'
import command from '../scripts/executeScript.js'
import { transformExecuteArgs, transformExecuteResult } from '../utils.js'
import { SERIALIZE_PROPERTY, SERIALIZE_FLAG } from '../constants.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants'
import { findElement as findElementUtil } from '../utils'
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants.js'
import { findElement as findElementUtil } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants'
import { findElement, getStaleElementError } from '../utils'
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants.js'
import { findElement, getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,4 +1,4 @@
import findElementFromElement from './findElementFromElement'
import findElementFromElement from './findElementFromElement.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants'
import { findElements as findElementsUtil } from '../utils'
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants.js'
import { findElements as findElementsUtil } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants'
import { findElements, getStaleElementError } from '../utils'
import { SUPPORTED_SELECTOR_STRATEGIES } from '../constants.js'
import { findElements, getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,4 +1,4 @@
import findElementsFromElement from './findElementsFromElement'
import findElementsFromElement from './findElementsFromElement.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,7 +1,7 @@
import findElement from './findElement'
import command from '../scripts/getActiveElement'
import cleanUp from '../scripts/cleanUpSerializationSelector'
import { SERIALIZE_PROPERTY } from '../constants'
import findElement from './findElement.js'
import command from '../scripts/getActiveElement.js'
import cleanUp from '../scripts/cleanUpSerializationSelector.js'
import { SERIALIZE_PROPERTY } from '../constants.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import command from '../scripts/getElementAttribute'
import { getStaleElementError } from '../utils'
import command from '../scripts/getElementAttribute.js'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import command from '../scripts/getElementCSSValue'
import { getStaleElementError } from '../utils'
import command from '../scripts/getElementCSSValue.js'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,4 +1,4 @@
import { getStaleElementError } from '../utils'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import command from '../scripts/getElementRect'
import { getStaleElementError } from '../utils'
import command from '../scripts/getElementRect.js'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import { getStaleElementError } from '../utils'
import { SHADOW_ELEMENT_KEY } from '../constants'
import { getStaleElementError } from '../utils.js'
import { SHADOW_ELEMENT_KEY } from '../constants.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import command from '../scripts/getElementTagName'
import { getStaleElementError } from '../utils'
import command from '../scripts/getElementTagName.js'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import command from '../scripts/getElementText'
import { getStaleElementError } from '../utils'
import command from '../scripts/getElementText.js'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,4 +1,4 @@
import command from '../scripts/getUrl'
import command from '../scripts/getUrl.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,4 +1,4 @@
import { DEFAULT_WIDTH, DEFAULT_HEIGHT } from '../constants'
import { DEFAULT_WIDTH, DEFAULT_HEIGHT } from '../constants.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,4 +1,4 @@
import getElementAttribute from './getElementAttribute'
import getElementAttribute from './getElementAttribute.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import getElementProperty from './getElementProperty'
import getElementTagName from './getElementTagName'
import getElementProperty from './getElementProperty.js'
import getElementTagName from './getElementTagName.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,8 +1,8 @@
import os from 'os'
import os from 'node:os'
import { v4 as uuidv4 } from 'uuid'
import launch from '../launcher'
import { sessionMap } from '../index'
import launch from '../launcher.js'
import { sessionMap } from '../index.js'
import type { ExtendedCapabilities } from '../types'
import type DevToolsDriver from '../devtoolsdriver'

View file

@ -1,9 +1,9 @@
import { keyDefinitions, KeyInput } from 'puppeteer-core/lib/cjs/puppeteer/common/USKeyboardLayout'
import type { Keyboard, Mouse } from 'puppeteer-core/lib/cjs/puppeteer/common/Input'
import { keyDefinitions, KeyInput } from 'puppeteer-core/lib/cjs/puppeteer/common/USKeyboardLayout.js'
import type { Keyboard, Mouse } from 'puppeteer-core/lib/cjs/puppeteer/common/Input.js'
import getElementRect from './getElementRect'
import { ELEMENT_KEY } from '../constants'
import { sleep } from '../utils'
import getElementRect from './getElementRect.js'
import { ELEMENT_KEY } from '../constants.js'
import { sleep } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
const KEY = 'key'

View file

@ -1,5 +1,7 @@
import path from 'path'
import path from 'node:path'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const puppeteerPath = require.resolve('puppeteer-core')
const puppeteerPkg = require(`${path.dirname(puppeteerPath)}/package.json`)

View file

@ -1,9 +1,9 @@
import type { Page } from 'puppeteer-core/lib/cjs/puppeteer/common/Page'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager'
import type { Page } from 'puppeteer-core/lib/cjs/puppeteer/common/Page.js'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js'
import type { ElementReference } from '@wdio/protocols'
import { ELEMENT_KEY } from '../constants'
import { getStaleElementError } from '../utils'
import { ELEMENT_KEY } from '../constants.js'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,5 @@
import type { Page } from 'puppeteer-core/lib/cjs/puppeteer/common/Page'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager'
import type { Page } from 'puppeteer-core/lib/cjs/puppeteer/common/Page.js'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,4 +1,4 @@
import { getStaleElementError } from '../utils'
import { getStaleElementError } from '../utils.js'
import type DevToolsDriver from '../devtoolsdriver'
/**

View file

@ -1,5 +1,6 @@
import fs from 'fs'
import path from 'path'
import fs from 'node:fs'
import path from 'node:path'
import { createRequire } from 'node:module'
import { v4 as uuidv4 } from 'uuid'
import logger from '@wdio/logger'
@ -10,11 +11,12 @@ import type { Target } from 'puppeteer-core/lib/cjs/puppeteer/common/Target'
import type { CommandEndpoint } from '@wdio/protocols'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager'
import ElementStore from './elementstore'
import { validate, sanitizeError } from './utils'
import { DEFAULT_IMPLICIT_TIMEOUT, DEFAULT_PAGELOAD_TIMEOUT, DEFAULT_SCRIPT_TIMEOUT } from './constants'
import ElementStore from './elementstore.js'
import { validate, sanitizeError } from './utils.js'
import { DEFAULT_IMPLICIT_TIMEOUT, DEFAULT_PAGELOAD_TIMEOUT, DEFAULT_SCRIPT_TIMEOUT } from './constants.js'
const log = logger('devtools')
const require = createRequire(import.meta.url)
export default class DevToolsDriver {
commands: Record<string, Function> = {}

View file

@ -1,5 +1,5 @@
import type { ElementHandle } from 'puppeteer-core/lib/cjs/puppeteer/common/JSHandle'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager'
import type { ElementHandle } from 'puppeteer-core/lib/cjs/puppeteer/common/JSHandle.js'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js'
export default class ElementStore {
private _index = 0

View file

@ -5,13 +5,14 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
import path from 'path'
import os from 'node:os'
import path from 'node:path'
import { execSync } from 'node:child_process'
import { getEdgePath } from 'edge-paths'
import { execSync } from 'child_process'
import { canAccess } from '@wdio/utils'
import { sort, findByWhich } from '../utils'
import { darwinGetAppPaths, darwinGetInstallations } from './finder'
import { sort, findByWhich } from '../utils.js'
import { darwinGetAppPaths, darwinGetInstallations } from './finder.js'
const newLineRegex = /\r?\n/
const EDGE_BINARY_NAMES = ['edge', 'msedge', 'microsoftedge']
@ -59,7 +60,7 @@ function linux() {
// 1. Look into the directories where .desktop are saved on gnome based distros
const desktopInstallationFolders = [
path.join(require('os').homedir(), '.local/share/applications/'),
path.join(os.homedir(), '.local/share/applications/'),
'/usr/share/applications/',
]
desktopInstallationFolders.forEach(folder => {

View file

@ -1,5 +1,5 @@
import path from 'path'
import { execSync } from 'child_process'
import path from 'node:path'
import { execSync } from 'node:child_process'
import { canAccess } from '@wdio/utils'

View file

@ -5,12 +5,13 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
import path from 'path'
import { execSync } from 'child_process'
import os from 'node:os'
import path from 'node:path'
import { execSync } from 'node:child_process'
import { canAccess } from '@wdio/utils'
import { sort, findByWhich } from '../utils'
import { darwinGetAppPaths, darwinGetInstallations } from './finder'
import { sort, findByWhich } from '../utils.js'
import { darwinGetAppPaths, darwinGetInstallations } from './finder.js'
const newLineRegex = /\r?\n/
@ -62,7 +63,7 @@ function linux() {
// 1. Look into the directories where .desktop are saved on gnome based distros
const desktopInstallationFolders = [
path.join(require('os').homedir(), '.local/share/applications/'),
path.join(os.homedir(), '.local/share/applications/'),
'/usr/share/applications/',
]
desktopInstallationFolders.forEach(folder => {

View file

@ -1,5 +1,5 @@
import edgeFinder from './edge'
import firefoxFinder from './firefox'
import edgeFinder from './edge.js'
import firefoxFinder from './firefox.js'
export default (browserName: 'firefox' | 'edge', platform: NodeJS.Platform) => {
const finder = {

View file

@ -1,5 +1,5 @@
import os from 'os'
import path from 'path'
import os from 'node:os'
import path from 'node:path'
import UAParser from 'ua-parser-js'
import { v4 as uuidv4 } from 'uuid'
@ -10,10 +10,10 @@ import type { CommandEndpoint } from '@wdio/protocols'
import type { Options, Capabilities } from '@wdio/types'
import type { Browser } from 'puppeteer-core/lib/cjs/puppeteer/common/Browser'
import DevToolsDriver from './devtoolsdriver'
import launch from './launcher'
import { DEFAULTS, SUPPORTED_BROWSER, VENDOR_PREFIX } from './constants'
import { getPrototype, patchDebug } from './utils'
import DevToolsDriver from './devtoolsdriver.js'
import launch from './launcher.js'
import { DEFAULTS, SUPPORTED_BROWSER, VENDOR_PREFIX } from './constants.js'
import { getPrototype, patchDebug } from './utils.js'
import type {
Client,
AttachOptions,
@ -179,7 +179,7 @@ export default class DevTools {
}
export { SUPPORTED_BROWSER }
export * from './types'
export * from './types.js'
declare global {
namespace WebdriverIO {

View file

@ -3,10 +3,10 @@ import puppeteer from 'puppeteer-core'
import logger from '@wdio/logger'
import type { Browser } from 'puppeteer-core/lib/cjs/puppeteer/common/Browser'
import type { Capabilities } from '@wdio/types'
import { QueryHandler } from 'query-selector-shadow-dom/plugins/puppeteer'
import { QueryHandler } from 'query-selector-shadow-dom/plugins/puppeteer/index.js'
import browserFinder from './finder'
import { getPages } from './utils'
import browserFinder from './finder/index.js'
import { getPages } from './utils.js'
import {
CHROME_NAMES,
FIREFOX_NAMES,
@ -21,7 +21,7 @@ import {
CHANNEL_FIREFOX_NIGHTLY,
CHANNEL_FIREFOX_TRUNK,
BROWSER_ERROR_MESSAGES
} from './constants'
} from './constants.js'
import type { ExtendedCapabilities, DevToolsOptions } from './types'
const log = logger('devtools')

View file

@ -1,20 +1,23 @@
import fs from 'fs'
import path from 'path'
import { execFileSync } from 'child_process'
import fs from 'node:fs'
import path from 'node:path'
import { createRequire } from 'node:module'
import { execFileSync } from 'node:child_process'
import logger from '@wdio/logger'
import { commandCallStructure, isValidParameter, getArgumentType, canAccess } from '@wdio/utils'
import { WebDriverProtocol, CommandParameters, CommandPathVariables, ElementReference } from '@wdio/protocols'
import type { Logger } from '@wdio/logger'
import type { Logger } from '@wdio/logger/build/node'
import type { ElementHandle } from 'puppeteer-core/lib/cjs/puppeteer/common/JSHandle'
import type { Browser } from 'puppeteer-core/lib/cjs/puppeteer/common/Browser'
import type { Frame } from 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager'
import type { Page } from 'puppeteer-core/lib/cjs/puppeteer/common/Page'
import cleanUp from './scripts/cleanUpSerializationSelector'
import { ELEMENT_KEY, SERIALIZE_PROPERTY, SERIALIZE_FLAG, ERROR_MESSAGES, PPTR_LOG_PREFIX } from './constants'
import cleanUp from './scripts/cleanUpSerializationSelector.js'
import { ELEMENT_KEY, SERIALIZE_PROPERTY, SERIALIZE_FLAG, ERROR_MESSAGES, PPTR_LOG_PREFIX } from './constants.js'
import type { Priorities } from './finder/firefox'
import type DevToolsDriver from './devtoolsdriver'
const require = createRequire(import.meta.url)
const log = logger('devtools')
export const validate = function (
@ -108,7 +111,7 @@ export async function findElement (
*/
const implicitTimeout = this.timeouts.get('implicit')
const waitForFn = using === 'xpath' ? (context as Page | Frame).waitForXPath : (context as Page | Frame).waitForSelector
if (implicitTimeout && waitForFn) {
if (implicitTimeout) {
await waitForFn.call(context, value, { timeout: implicitTimeout })
}
@ -148,7 +151,7 @@ export async function findElements (
*/
const implicitTimeout = this.timeouts.get('implicit')
const waitForFn = using === 'xpath' ? (context as Page | Frame).waitForXPath : (context as Page | Frame).waitForSelector
if (implicitTimeout && waitForFn) {
if (implicitTimeout) {
await waitForFn.call(context, value, { timeout: implicitTimeout })
}
@ -320,7 +323,7 @@ export function findByWhich (executables: string[], priorities: Priorities[]) {
/**
* monkey patch debug package to log CDP messages from Puppeteer
*/
export function patchDebug (scoppedLogger: Logger) {
export async function patchDebug (scoppedLogger: Logger) {
/**
* log puppeteer messages
*/

View file

@ -15,6 +15,13 @@
"require": "./build/index.cjs.js"
},
"./build/index.cjs.js"
],
"./node": [
{
"import": "./build/node.js",
"require": "./build/node.cjs.js"
},
"./build/node.cjs.js"
]
},
"types": "./build/index.d.ts",