@wdio/utils 7.20.3 → 7.20.8-alpha.504

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 (36) hide show
  1. package/build/constants.d.ts +75 -75
  2. package/build/constants.d.ts.map +1 -1
  3. package/build/constants.js +1 -4
  4. package/build/envDetector.js +5 -13
  5. package/build/index.d.ts +11 -11
  6. package/build/index.d.ts.map +1 -1
  7. package/build/index.js +21 -39
  8. package/build/initialisePlugin.d.ts +2 -2
  9. package/build/initialisePlugin.d.ts.map +1 -1
  10. package/build/initialisePlugin.js +7 -13
  11. package/build/initialiseServices.d.ts +3 -3
  12. package/build/initialiseServices.d.ts.map +1 -1
  13. package/build/initialiseServices.js +9 -17
  14. package/build/monad.d.ts +4 -1
  15. package/build/monad.d.ts.map +1 -1
  16. package/build/monad.js +18 -17
  17. package/build/shim.d.ts +1 -27
  18. package/build/shim.d.ts.map +1 -1
  19. package/build/shim.js +18 -184
  20. package/build/test-framework/errorHandler.js +1 -5
  21. package/build/test-framework/index.d.ts +2 -2
  22. package/build/test-framework/index.d.ts.map +1 -1
  23. package/build/test-framework/index.js +3 -7
  24. package/build/test-framework/testFnWrapper.d.ts +1 -1
  25. package/build/test-framework/testFnWrapper.d.ts.map +1 -1
  26. package/build/test-framework/testFnWrapper.js +10 -27
  27. package/build/test-framework/testInterfaceWrapper.d.ts +3 -4
  28. package/build/test-framework/testInterfaceWrapper.d.ts.map +1 -1
  29. package/build/test-framework/testInterfaceWrapper.js +19 -26
  30. package/build/test-framework/types.d.ts +1 -2
  31. package/build/test-framework/types.d.ts.map +1 -1
  32. package/build/test-framework/types.js +1 -2
  33. package/build/utils.d.ts +2 -2
  34. package/build/utils.d.ts.map +1 -1
  35. package/build/utils.js +26 -48
  36. package/package.json +11 -8
@@ -3,80 +3,80 @@
3
3
  * https://w3c.github.io/webdriver/webdriver-spec.html#character-types
4
4
  */
5
5
  export declare const UNICODE_CHARACTERS: {
6
- NULL: string;
7
- Unidentified: string;
8
- Cancel: string;
9
- Help: string;
10
- Backspace: string;
11
- 'Back space': string;
12
- Tab: string;
13
- Clear: string;
14
- Return: string;
15
- Enter: string;
16
- Shift: string;
17
- Control: string;
18
- 'Control Left': string;
19
- 'Control Right': string;
20
- Alt: string;
21
- Pause: string;
22
- Escape: string;
23
- Space: string;
24
- ' ': string;
25
- PageUp: string;
26
- Pageup: string;
27
- Page_Up: string;
28
- PageDown: string;
29
- Pagedown: string;
30
- Page_Down: string;
31
- End: string;
32
- Home: string;
33
- ArrowLeft: string;
34
- 'Left arrow': string;
35
- Arrow_Left: string;
36
- ArrowUp: string;
37
- 'Up arrow': string;
38
- Arrow_Up: string;
39
- ArrowRight: string;
40
- 'Right arrow': string;
41
- Arrow_Right: string;
42
- ArrowDown: string;
43
- 'Down arrow': string;
44
- Arrow_Down: string;
45
- Insert: string;
46
- Delete: string;
47
- Semicolon: string;
48
- Equals: string;
49
- 'Numpad 0': string;
50
- 'Numpad 1': string;
51
- 'Numpad 2': string;
52
- 'Numpad 3': string;
53
- 'Numpad 4': string;
54
- 'Numpad 5': string;
55
- 'Numpad 6': string;
56
- 'Numpad 7': string;
57
- 'Numpad 8': string;
58
- 'Numpad 9': string;
59
- Multiply: string;
60
- Add: string;
61
- Separator: string;
62
- Subtract: string;
63
- Decimal: string;
64
- Divide: string;
65
- F1: string;
66
- F2: string;
67
- F3: string;
68
- F4: string;
69
- F5: string;
70
- F6: string;
71
- F7: string;
72
- F8: string;
73
- F9: string;
74
- F10: string;
75
- F11: string;
76
- F12: string;
77
- Command: string;
78
- Meta: string;
79
- ZenkakuHankaku: string;
80
- Zenkaku_Hankaku: string;
6
+ readonly NULL: "";
7
+ readonly Unidentified: "";
8
+ readonly Cancel: "";
9
+ readonly Help: "";
10
+ readonly Backspace: "";
11
+ readonly 'Back space': "";
12
+ readonly Tab: "";
13
+ readonly Clear: "";
14
+ readonly Return: "";
15
+ readonly Enter: "";
16
+ readonly Shift: "";
17
+ readonly Control: "";
18
+ readonly 'Control Left': "";
19
+ readonly 'Control Right': "";
20
+ readonly Alt: "";
21
+ readonly Pause: "";
22
+ readonly Escape: "";
23
+ readonly Space: "";
24
+ readonly ' ': "";
25
+ readonly PageUp: "";
26
+ readonly Pageup: "";
27
+ readonly Page_Up: "";
28
+ readonly PageDown: "";
29
+ readonly Pagedown: "";
30
+ readonly Page_Down: "";
31
+ readonly End: "";
32
+ readonly Home: "";
33
+ readonly ArrowLeft: "";
34
+ readonly 'Left arrow': "";
35
+ readonly Arrow_Left: "";
36
+ readonly ArrowUp: "";
37
+ readonly 'Up arrow': "";
38
+ readonly Arrow_Up: "";
39
+ readonly ArrowRight: "";
40
+ readonly 'Right arrow': "";
41
+ readonly Arrow_Right: "";
42
+ readonly ArrowDown: "";
43
+ readonly 'Down arrow': "";
44
+ readonly Arrow_Down: "";
45
+ readonly Insert: "";
46
+ readonly Delete: "";
47
+ readonly Semicolon: "";
48
+ readonly Equals: "";
49
+ readonly 'Numpad 0': "";
50
+ readonly 'Numpad 1': "";
51
+ readonly 'Numpad 2': "";
52
+ readonly 'Numpad 3': "";
53
+ readonly 'Numpad 4': "";
54
+ readonly 'Numpad 5': "";
55
+ readonly 'Numpad 6': "";
56
+ readonly 'Numpad 7': "";
57
+ readonly 'Numpad 8': "";
58
+ readonly 'Numpad 9': "";
59
+ readonly Multiply: "";
60
+ readonly Add: "";
61
+ readonly Separator: "";
62
+ readonly Subtract: "";
63
+ readonly Decimal: "";
64
+ readonly Divide: "";
65
+ readonly F1: "";
66
+ readonly F2: "";
67
+ readonly F3: "";
68
+ readonly F4: "";
69
+ readonly F5: "";
70
+ readonly F6: "";
71
+ readonly F7: "";
72
+ readonly F8: "";
73
+ readonly F9: "";
74
+ readonly F10: "";
75
+ readonly F11: "";
76
+ readonly F12: "";
77
+ readonly Command: "";
78
+ readonly Meta: "";
79
+ readonly ZenkakuHankaku: "";
80
+ readonly Zenkaku_Hankaku: "";
81
81
  };
82
82
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4E9B,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4ErB,CAAA"}
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UNICODE_CHARACTERS = void 0;
4
1
  /**
5
2
  * unicode characters
6
3
  * https://w3c.github.io/webdriver/webdriver-spec.html#character-types
7
4
  */
8
- exports.UNICODE_CHARACTERS = {
5
+ export const UNICODE_CHARACTERS = {
9
6
  'NULL': '\uE000',
10
7
  'Unidentified': '\uE000',
11
8
  'Cancel': '\uE001',
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webdriverEnvironmentDetector = exports.devtoolsEnvironmentDetector = exports.sessionEnvironmentDetector = exports.capabilitiesEnvironmentDetector = exports.isW3C = void 0;
4
1
  const MOBILE_BROWSER_NAMES = ['ipad', 'iphone', 'android'];
5
2
  const MOBILE_CAPABILITIES = [
6
3
  'appium-version', 'appiumVersion', 'device-type', 'deviceType',
@@ -11,7 +8,7 @@ const MOBILE_CAPABILITIES = [
11
8
  * @param {Object} capabilities caps of session response
12
9
  * @return {Boolean} true if W3C (browser)
13
10
  */
14
- function isW3C(capabilities) {
11
+ export function isW3C(capabilities) {
15
12
  /**
16
13
  * JSONWire protocol doesn't return a property `capabilities`.
17
14
  * Also check for Appium response as it is using JSONWire protocol for most of the part.
@@ -41,7 +38,6 @@ function isW3C(capabilities) {
41
38
  (capabilities.platformVersion || Object.prototype.hasOwnProperty.call(capabilities, 'setWindowRect')));
42
39
  return Boolean(hasW3CCaps || isAppium);
43
40
  }
44
- exports.isW3C = isW3C;
45
41
  /**
46
42
  * check if session is run by Chromedriver
47
43
  * @param {Object} capabilities caps of session response
@@ -160,19 +156,18 @@ function isSeleniumStandalone(capabilities) {
160
156
  * @param {string=} automationProtocol `devtools`
161
157
  * @return {Object} object with environment flags
162
158
  */
163
- function capabilitiesEnvironmentDetector(capabilities, automationProtocol) {
159
+ export function capabilitiesEnvironmentDetector(capabilities, automationProtocol) {
164
160
  return automationProtocol === 'devtools'
165
161
  ? devtoolsEnvironmentDetector(capabilities)
166
162
  : webdriverEnvironmentDetector(capabilities);
167
163
  }
168
- exports.capabilitiesEnvironmentDetector = capabilitiesEnvironmentDetector;
169
164
  /**
170
165
  * returns information about the environment when the session is created
171
166
  * @param {Object} capabilities caps of session response
172
167
  * @param {Object} requestedCapabilities
173
168
  * @return {Object} object with environment flags
174
169
  */
175
- function sessionEnvironmentDetector({ capabilities, requestedCapabilities }) {
170
+ export function sessionEnvironmentDetector({ capabilities, requestedCapabilities }) {
176
171
  return {
177
172
  isW3C: isW3C(capabilities),
178
173
  isChrome: isChrome(capabilities),
@@ -184,13 +179,12 @@ function sessionEnvironmentDetector({ capabilities, requestedCapabilities }) {
184
179
  isSeleniumStandalone: isSeleniumStandalone(capabilities)
185
180
  };
186
181
  }
187
- exports.sessionEnvironmentDetector = sessionEnvironmentDetector;
188
182
  /**
189
183
  * returns information about the environment when `devtools` protocol is used
190
184
  * @param {Object} capabilities caps of session response
191
185
  * @return {Object} object with environment flags
192
186
  */
193
- function devtoolsEnvironmentDetector({ browserName }) {
187
+ export function devtoolsEnvironmentDetector({ browserName }) {
194
188
  return {
195
189
  isDevTools: true,
196
190
  isW3C: true,
@@ -203,14 +197,13 @@ function devtoolsEnvironmentDetector({ browserName }) {
203
197
  isSeleniumStandalone: false,
204
198
  };
205
199
  }
206
- exports.devtoolsEnvironmentDetector = devtoolsEnvironmentDetector;
207
200
  /**
208
201
  * returns information about the environment before the session is created
209
202
  * `isW3C`, `isSeleniumStandalone` cannot be detected
210
203
  * @param {Object} capabilities caps provided by user
211
204
  * @return {Object} object with environment flags
212
205
  */
213
- function webdriverEnvironmentDetector(capabilities) {
206
+ export function webdriverEnvironmentDetector(capabilities) {
214
207
  return {
215
208
  isChrome: isChrome(capabilities),
216
209
  isFirefox: isFirefox(capabilities),
@@ -220,4 +213,3 @@ function webdriverEnvironmentDetector(capabilities) {
220
213
  isSauce: isSauce(capabilities)
221
214
  };
222
215
  }
223
- exports.webdriverEnvironmentDetector = webdriverEnvironmentDetector;
package/build/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import initialisePlugin from './initialisePlugin';
2
- import { initialiseWorkerService, initialiseLauncherService } from './initialiseServices';
3
- import webdriverMonad from './monad';
4
- import { commandCallStructure, isValidParameter, getArgumentType, safeRequire, isFunctionAsync, transformCommandLogResult, canAccess, sleep } from './utils';
5
- import { wrapCommand, runFnInFiberContext, executeHooksWithArgs, hasWdioSyncSupport, executeSync, executeAsync } from './shim';
6
- import { testFnWrapper, runTestInFiberContext } from './test-framework';
7
- import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector, devtoolsEnvironmentDetector } from './envDetector';
8
- import { UNICODE_CHARACTERS } from './constants';
9
- export { initialisePlugin, initialiseLauncherService, initialiseWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeRequire, canAccess, sleep,
1
+ import initialisePlugin from './initialisePlugin.js';
2
+ import { initialiseWorkerService, initialiseLauncherService } from './initialiseServices.js';
3
+ import webdriverMonad from './monad.js';
4
+ import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, canAccess, sleep } from './utils.js';
5
+ import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js';
6
+ import { testFnWrapper, runTestInFiberContext } from './test-framework/index.js';
7
+ import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector, devtoolsEnvironmentDetector } from './envDetector.js';
8
+ import { UNICODE_CHARACTERS } from './constants.js';
9
+ export { initialisePlugin, initialiseLauncherService, initialiseWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, canAccess, sleep,
10
10
  /**
11
- * wdio-sync shim
11
+ * runner shim
12
12
  */
13
- wrapCommand, executeSync, executeAsync, runFnInFiberContext, runTestInFiberContext, testFnWrapper, executeHooksWithArgs, hasWdioSyncSupport,
13
+ wrapCommand, executeAsync, runTestInFiberContext, testFnWrapper, executeHooksWithArgs,
14
14
  /**
15
15
  * environmentDetector
16
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACzF,OAAO,cAAc,MAAM,SAAS,CAAA;AACpC,OAAO,EACH,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EACpE,eAAe,EAAE,yBAAyB,EAAE,SAAS,EAAE,KAAK,EAC/D,MAAM,SAAS,CAAA;AAChB,OAAO,EACH,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EACtD,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAChD,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EACH,KAAK,EAAE,+BAA+B,EACtC,0BAA0B,EAAE,2BAA2B,EAC1D,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EACH,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,SAAS,EACT,KAAK;AAEL;;GAEG;AACH,WAAW,EACX,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,kBAAkB;AAElB;;GAEG;AACH,KAAK,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,2BAA2B;AAE3B;;GAEG;AACH,kBAAkB,EACrB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,gBAAgB,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAC5F,OAAO,cAAc,MAAM,YAAY,CAAA;AACvC,OAAO,EACH,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EACnE,eAAe,EAAE,yBAAyB,EAAE,SAAS,EAAE,KAAK,EAC/D,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,EACH,KAAK,EAAE,+BAA+B,EACtC,0BAA0B,EAAE,2BAA2B,EAC1D,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,EACH,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,SAAS,EACT,KAAK;AAEL;;GAEG;AACH,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,oBAAoB;AAEpB;;GAEG;AACH,KAAK,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,2BAA2B;AAE3B;;GAEG;AACH,kBAAkB,EACrB,CAAA"}
package/build/index.js CHANGED
@@ -1,40 +1,22 @@
1
- "use strict";
2
1
  /* istanbul ignore file */
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.UNICODE_CHARACTERS = exports.devtoolsEnvironmentDetector = exports.capabilitiesEnvironmentDetector = exports.sessionEnvironmentDetector = exports.isW3C = exports.hasWdioSyncSupport = exports.executeHooksWithArgs = exports.testFnWrapper = exports.runTestInFiberContext = exports.runFnInFiberContext = exports.executeAsync = exports.executeSync = exports.wrapCommand = exports.sleep = exports.canAccess = exports.safeRequire = exports.getArgumentType = exports.isValidParameter = exports.commandCallStructure = exports.webdriverMonad = exports.transformCommandLogResult = exports.isFunctionAsync = exports.initialiseWorkerService = exports.initialiseLauncherService = exports.initialisePlugin = void 0;
8
- const initialisePlugin_1 = __importDefault(require("./initialisePlugin"));
9
- exports.initialisePlugin = initialisePlugin_1.default;
10
- const initialiseServices_1 = require("./initialiseServices");
11
- Object.defineProperty(exports, "initialiseWorkerService", { enumerable: true, get: function () { return initialiseServices_1.initialiseWorkerService; } });
12
- Object.defineProperty(exports, "initialiseLauncherService", { enumerable: true, get: function () { return initialiseServices_1.initialiseLauncherService; } });
13
- const monad_1 = __importDefault(require("./monad"));
14
- exports.webdriverMonad = monad_1.default;
15
- const utils_1 = require("./utils");
16
- Object.defineProperty(exports, "commandCallStructure", { enumerable: true, get: function () { return utils_1.commandCallStructure; } });
17
- Object.defineProperty(exports, "isValidParameter", { enumerable: true, get: function () { return utils_1.isValidParameter; } });
18
- Object.defineProperty(exports, "getArgumentType", { enumerable: true, get: function () { return utils_1.getArgumentType; } });
19
- Object.defineProperty(exports, "safeRequire", { enumerable: true, get: function () { return utils_1.safeRequire; } });
20
- Object.defineProperty(exports, "isFunctionAsync", { enumerable: true, get: function () { return utils_1.isFunctionAsync; } });
21
- Object.defineProperty(exports, "transformCommandLogResult", { enumerable: true, get: function () { return utils_1.transformCommandLogResult; } });
22
- Object.defineProperty(exports, "canAccess", { enumerable: true, get: function () { return utils_1.canAccess; } });
23
- Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
24
- const shim_1 = require("./shim");
25
- Object.defineProperty(exports, "wrapCommand", { enumerable: true, get: function () { return shim_1.wrapCommand; } });
26
- Object.defineProperty(exports, "runFnInFiberContext", { enumerable: true, get: function () { return shim_1.runFnInFiberContext; } });
27
- Object.defineProperty(exports, "executeHooksWithArgs", { enumerable: true, get: function () { return shim_1.executeHooksWithArgs; } });
28
- Object.defineProperty(exports, "hasWdioSyncSupport", { enumerable: true, get: function () { return shim_1.hasWdioSyncSupport; } });
29
- Object.defineProperty(exports, "executeSync", { enumerable: true, get: function () { return shim_1.executeSync; } });
30
- Object.defineProperty(exports, "executeAsync", { enumerable: true, get: function () { return shim_1.executeAsync; } });
31
- const test_framework_1 = require("./test-framework");
32
- Object.defineProperty(exports, "testFnWrapper", { enumerable: true, get: function () { return test_framework_1.testFnWrapper; } });
33
- Object.defineProperty(exports, "runTestInFiberContext", { enumerable: true, get: function () { return test_framework_1.runTestInFiberContext; } });
34
- const envDetector_1 = require("./envDetector");
35
- Object.defineProperty(exports, "isW3C", { enumerable: true, get: function () { return envDetector_1.isW3C; } });
36
- Object.defineProperty(exports, "capabilitiesEnvironmentDetector", { enumerable: true, get: function () { return envDetector_1.capabilitiesEnvironmentDetector; } });
37
- Object.defineProperty(exports, "sessionEnvironmentDetector", { enumerable: true, get: function () { return envDetector_1.sessionEnvironmentDetector; } });
38
- Object.defineProperty(exports, "devtoolsEnvironmentDetector", { enumerable: true, get: function () { return envDetector_1.devtoolsEnvironmentDetector; } });
39
- const constants_1 = require("./constants");
40
- Object.defineProperty(exports, "UNICODE_CHARACTERS", { enumerable: true, get: function () { return constants_1.UNICODE_CHARACTERS; } });
2
+ import initialisePlugin from './initialisePlugin.js';
3
+ import { initialiseWorkerService, initialiseLauncherService } from './initialiseServices.js';
4
+ import webdriverMonad from './monad.js';
5
+ import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, canAccess, sleep } from './utils.js';
6
+ import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js';
7
+ import { testFnWrapper, runTestInFiberContext } from './test-framework/index.js';
8
+ import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector, devtoolsEnvironmentDetector } from './envDetector.js';
9
+ import { UNICODE_CHARACTERS } from './constants.js';
10
+ export { initialisePlugin, initialiseLauncherService, initialiseWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, canAccess, sleep,
11
+ /**
12
+ * runner shim
13
+ */
14
+ wrapCommand, executeAsync, runTestInFiberContext, testFnWrapper, executeHooksWithArgs,
15
+ /**
16
+ * environmentDetector
17
+ */
18
+ isW3C, sessionEnvironmentDetector, capabilitiesEnvironmentDetector, devtoolsEnvironmentDetector,
19
+ /**
20
+ * constants
21
+ */
22
+ UNICODE_CHARACTERS };
@@ -1,9 +1,9 @@
1
- import { Services } from '@wdio/types';
1
+ import type { Services } from '@wdio/types';
2
2
  /**
3
3
  * initialise WebdriverIO compliant plugins like reporter or services in the following way:
4
4
  * 1. if package name is scoped (starts with "@"), require scoped package name
5
5
  * 2. otherwise try to require "@wdio/<name>-<type>"
6
6
  * 3. otherwise try to require "wdio-<name>-<type>"
7
7
  */
8
- export default function initialisePlugin(name: string, type?: string): Services.ServicePlugin | Services.RunnerPlugin;
8
+ export default function initialisePlugin(name: string, type?: string): Promise<Services.ServicePlugin | Services.RunnerPlugin>;
9
9
  //# sourceMappingURL=initialisePlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialisePlugin.d.ts","sourceRoot":"","sources":["../src/initialisePlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAItC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,YAAY,CAqCrH"}
1
+ {"version":3,"file":"initialisePlugin.d.ts","sourceRoot":"","sources":["../src/initialisePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAI3C;;;;;GAKG;AACH,wBAA8B,gBAAgB,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,YAAY,CAAC,CAqCpI"}
@@ -1,22 +1,17 @@
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
- const path_1 = __importDefault(require("path"));
7
- const utils_1 = require("./utils");
1
+ import path from 'node:path';
2
+ import { safeImport } from './utils.js';
8
3
  /**
9
4
  * initialise WebdriverIO compliant plugins like reporter or services in the following way:
10
5
  * 1. if package name is scoped (starts with "@"), require scoped package name
11
6
  * 2. otherwise try to require "@wdio/<name>-<type>"
12
7
  * 3. otherwise try to require "wdio-<name>-<type>"
13
8
  */
14
- function initialisePlugin(name, type) {
9
+ export default async function initialisePlugin(name, type) {
15
10
  /**
16
11
  * directly import packages that are scoped or start with an absolute path
17
12
  */
18
- if (name[0] === '@' || path_1.default.isAbsolute(name)) {
19
- const service = (0, utils_1.safeRequire)(name);
13
+ if (name[0] === '@' || path.isAbsolute(name)) {
14
+ const service = await safeImport(name);
20
15
  if (service) {
21
16
  return service;
22
17
  }
@@ -27,14 +22,14 @@ function initialisePlugin(name, type) {
27
22
  /**
28
23
  * check for scoped version of plugin first (e.g. @wdio/sauce-service)
29
24
  */
30
- const scopedPlugin = (0, utils_1.safeRequire)(`@wdio/${name.toLowerCase()}-${type}`);
25
+ const scopedPlugin = await safeImport(`@wdio/${name.toLowerCase()}-${type}`);
31
26
  if (scopedPlugin) {
32
27
  return scopedPlugin;
33
28
  }
34
29
  /**
35
30
  * check for old type of
36
31
  */
37
- const plugin = (0, utils_1.safeRequire)(`wdio-${name.toLowerCase()}-${type}`);
32
+ const plugin = await safeImport(`wdio-${name.toLowerCase()}-${type}`);
38
33
  if (plugin) {
39
34
  return plugin;
40
35
  }
@@ -42,4 +37,3 @@ function initialisePlugin(name, type) {
42
37
  `"@wdio/${name.toLowerCase()}-${type}" nor as community package ` +
43
38
  `"wdio-${name.toLowerCase()}-${type}". Please make sure you have it installed!`);
44
39
  }
45
- exports.default = initialisePlugin;
@@ -7,10 +7,10 @@ import type { Capabilities, Services, Options } from '@wdio/types';
7
7
  * as a list of services that don't need to be
8
8
  * required in the worker
9
9
  */
10
- export declare function initialiseLauncherService(config: Omit<Options.Testrunner, 'capabilities' | keyof Services.HookFunctions>, caps: Capabilities.DesiredCapabilities): {
10
+ export declare function initialiseLauncherService(config: Omit<Options.Testrunner, 'capabilities' | keyof Services.HookFunctions>, caps: Capabilities.DesiredCapabilities): Promise<{
11
11
  ignoredWorkerServices: string[];
12
12
  launcherServices: Services.ServiceInstance[];
13
- };
13
+ }>;
14
14
  /**
15
15
  * initialise services for worker instance
16
16
  * @param {Object} config wdio config
@@ -19,5 +19,5 @@ export declare function initialiseLauncherService(config: Omit<Options.Testrunne
19
19
  * as they don't export a service for it
20
20
  * @return {Object[]} list if worker initiated worker services
21
21
  */
22
- export declare function initialiseWorkerService(config: Options.Testrunner, caps: Capabilities.DesiredCapabilities, ignoredWorkerServices?: string[]): Services.ServiceInstance[];
22
+ export declare function initialiseWorkerService(config: Options.Testrunner, caps: Capabilities.DesiredCapabilities, ignoredWorkerServices?: string[]): Promise<Services.ServiceInstance[]>;
23
23
  //# sourceMappingURL=initialiseServices.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialiseServices.d.ts","sourceRoot":"","sources":["../src/initialiseServices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAqFlE;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,mBAAmB;;;EAiDjK;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACnC,MAAM,EAAE,OAAO,CAAC,UAAU,EAC1B,IAAI,EAAE,YAAY,CAAC,mBAAmB,EACtC,qBAAqB,GAAE,MAAM,EAAO,GACrC,QAAQ,CAAC,eAAe,EAAE,CA6B5B"}
1
+ {"version":3,"file":"initialiseServices.d.ts","sourceRoot":"","sources":["../src/initialiseServices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAqFlE;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,mBAAmB;;;GAiDvK;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,OAAO,CAAC,UAAU,EAC1B,IAAI,EAAE,YAAY,CAAC,mBAAmB,EACtC,qBAAqB,GAAE,MAAM,EAAO,GACrC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,CA6BrC"}
@@ -1,19 +1,13 @@
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.initialiseWorkerService = exports.initialiseLauncherService = void 0;
7
- const logger_1 = __importDefault(require("@wdio/logger"));
8
- const initialisePlugin_1 = __importDefault(require("./initialisePlugin"));
9
- const log = (0, logger_1.default)('@wdio/utils:initialiseServices');
1
+ import logger from '@wdio/logger';
2
+ import initialisePlugin from './initialisePlugin.js';
3
+ const log = logger('@wdio/utils:initialiseServices');
10
4
  /**
11
5
  * Maps list of services of a config file into a list of actionable objects
12
6
  * @param {Object} config config of running session
13
7
  * @param {Object} caps capabilities of running session
14
8
  * @return {[(Object|Class), Object][]} list of services with their config objects
15
9
  */
16
- function initialiseServices(services) {
10
+ async function initialiseServices(services) {
17
11
  const initialisedServices = [];
18
12
  for (let [serviceName, serviceConfig = {}] of services) {
19
13
  /**
@@ -56,7 +50,7 @@ function initialiseServices(services) {
56
50
  * ```
57
51
  */
58
52
  log.debug(`initialise service "${serviceName}" as NPM package`);
59
- const service = (0, initialisePlugin_1.default)(serviceName, 'service');
53
+ const service = await initialisePlugin(serviceName, 'service');
60
54
  initialisedServices.push([service, serviceConfig, serviceName]);
61
55
  }
62
56
  return initialisedServices;
@@ -79,11 +73,11 @@ function sanitizeServiceArray(service) {
79
73
  * as a list of services that don't need to be
80
74
  * required in the worker
81
75
  */
82
- function initialiseLauncherService(config, caps) {
76
+ export async function initialiseLauncherService(config, caps) {
83
77
  const ignoredWorkerServices = [];
84
78
  const launcherServices = [];
85
79
  try {
86
- const services = initialiseServices(config.services.map(sanitizeServiceArray));
80
+ const services = await initialiseServices(config.services.map(sanitizeServiceArray));
87
81
  for (const [service, serviceConfig, serviceName] of services) {
88
82
  /**
89
83
  * add custom services as object or function
@@ -123,7 +117,6 @@ function initialiseLauncherService(config, caps) {
123
117
  }
124
118
  return { ignoredWorkerServices, launcherServices };
125
119
  }
126
- exports.initialiseLauncherService = initialiseLauncherService;
127
120
  /**
128
121
  * initialise services for worker instance
129
122
  * @param {Object} config wdio config
@@ -132,12 +125,12 @@ exports.initialiseLauncherService = initialiseLauncherService;
132
125
  * as they don't export a service for it
133
126
  * @return {Object[]} list if worker initiated worker services
134
127
  */
135
- function initialiseWorkerService(config, caps, ignoredWorkerServices = []) {
128
+ export async function initialiseWorkerService(config, caps, ignoredWorkerServices = []) {
136
129
  const workerServices = config.services
137
130
  .map(sanitizeServiceArray)
138
131
  .filter(([serviceName]) => !ignoredWorkerServices.includes(serviceName));
139
132
  try {
140
- const services = initialiseServices(workerServices);
133
+ const services = await initialiseServices(workerServices);
141
134
  return services.map(([service, serviceConfig, serviceName]) => {
142
135
  /**
143
136
  * add object service
@@ -159,4 +152,3 @@ function initialiseWorkerService(config, caps, ignoredWorkerServices = []) {
159
152
  return [];
160
153
  }
161
154
  }
162
- exports.initialiseWorkerService = initialiseWorkerService;
package/build/monad.d.ts CHANGED
@@ -1,8 +1,11 @@
1
+ import { EventEmitter } from 'node:events';
1
2
  interface PropertiesObject {
2
3
  [key: string | symbol]: PropertyDescriptor;
3
4
  }
4
5
  export default function WebDriver(options: Record<string, any>, modifier?: Function, propertiesObject?: PropertiesObject): {
5
- (this: void, sessionId: string, commandWrapper?: Function): any;
6
+ (this: void, sessionId: string, commandWrapper?: Function, eventMiddleware?: {
7
+ socket: Partial<EventEmitter>;
8
+ }): any;
6
9
  /**
7
10
  * Enhance monad prototype with function
8
11
  * @param {String} name name of function to attach to prototype
@@ -1 +1 @@
1
- {"version":3,"file":"monad.d.ts","sourceRoot":"","sources":["../src/monad.ts"],"names":[],"mappings":"AAYA,UAAU,gBAAgB;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,CAAA;CAC7C;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAE,gBAAqB;WAkBpG,IAAI,aAAa,MAAM,mBAAmB,QAAQ;IA+GvE;;;;;;OAMG;eACyB,MAAM,QAAQ,QAAQ,SAAS,OAAO,MAAM,EAAE,GAAG,CAAC,gBAAgB,QAAQ;EAqCzG"}
1
+ {"version":3,"file":"monad.d.ts","sourceRoot":"","sources":["../src/monad.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAU1C,UAAU,gBAAgB;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,CAAA;CAC7C;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAE,gBAAqB;WAkBpG,IAAI,aAAa,MAAM,mBAAmB,QAAQ,oBAAoB;QAAE,MAAM,EAAE,QAAQ,YAAY,CAAC,CAAA;KAAE;IAmH5H;;;;;;OAMG;eACyB,MAAM,QAAQ,QAAQ,SAAS,OAAO,MAAM,EAAE,GAAG,CAAC,gBAAgB,QAAQ;EA4CzG"}
package/build/monad.js CHANGED
@@ -1,32 +1,29 @@
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
- const events_1 = require("events");
7
- const logger_1 = __importDefault(require("@wdio/logger"));
8
- const utils_1 = require("./utils");
1
+ import { EventEmitter } from 'node:events';
2
+ import logger from '@wdio/logger';
3
+ import { commandCallStructure, overwriteElementCommands } from './utils.js';
9
4
  const SCOPE_TYPES = {
10
5
  browser: /* istanbul ignore next */ function Browser() { },
11
6
  element: /* istanbul ignore next */ function Element() { }
12
7
  };
13
- function WebDriver(options, modifier, propertiesObject = {}) {
14
- var _a;
8
+ export default function WebDriver(options, modifier, propertiesObject = {}) {
15
9
  /**
16
10
  * In order to allow named scopes for elements we have to propagate that
17
11
  * info within the `propertiesObject` object. This doesn't have any functional
18
12
  * advantages just provides better description of objects when debugging them
19
13
  */
20
- const scopeType = SCOPE_TYPES[((_a = propertiesObject.scope) === null || _a === void 0 ? void 0 : _a.value) || 'browser'];
14
+ const scopeType = SCOPE_TYPES[propertiesObject.scope?.value || 'browser'];
21
15
  delete propertiesObject.scope;
22
16
  const prototype = Object.create(scopeType.prototype);
23
- const log = (0, logger_1.default)('webdriver');
24
- const eventHandler = new events_1.EventEmitter();
17
+ const log = logger('webdriver');
18
+ const eventHandler = new EventEmitter();
25
19
  const EVENTHANDLER_FUNCTIONS = Object.getPrototypeOf(eventHandler);
26
20
  /**
27
21
  * WebDriver monad
28
22
  */
29
- function unit(sessionId, commandWrapper) {
23
+ function unit(sessionId, commandWrapper, eventMiddleware) {
24
+ if (eventMiddleware) {
25
+ prototype.eventMiddleware = eventMiddleware;
26
+ }
30
27
  /**
31
28
  * capabilities attached to the instance prototype not being shown if
32
29
  * logging the instance
@@ -50,7 +47,7 @@ function WebDriver(options, modifier, propertiesObject = {}) {
50
47
  /**
51
48
  * overwrite native element commands with user defined
52
49
  */
53
- utils_1.overwriteElementCommands.call(this, propertiesObject);
50
+ overwriteElementCommands.call(this, propertiesObject);
54
51
  /**
55
52
  * assign propertiesObject to itself so the client can be recreated
56
53
  */
@@ -138,7 +135,7 @@ function WebDriver(options, modifier, propertiesObject = {}) {
138
135
  */
139
136
  unit.lift = function (name, func, proto, origCommand) {
140
137
  (proto || prototype)[name] = function next(...args) {
141
- log.info('COMMAND', (0, utils_1.commandCallStructure)(name, args));
138
+ log.info('COMMAND', commandCallStructure(name, args));
142
139
  /**
143
140
  * set name of function for better error stack
144
141
  */
@@ -163,9 +160,13 @@ function WebDriver(options, modifier, propertiesObject = {}) {
163
160
  for (let eventCommand in EVENTHANDLER_FUNCTIONS) {
164
161
  prototype[eventCommand] = function (...args) {
165
162
  eventHandler[eventCommand](...args);
163
+ if (prototype.eventMiddleware) {
164
+ if (typeof prototype.eventMiddleware[eventCommand] === 'function') {
165
+ prototype.eventMiddleware.socket[eventCommand](...args);
166
+ }
167
+ }
166
168
  return this;
167
169
  };
168
170
  }
169
171
  return unit;
170
172
  }
171
- exports.default = WebDriver;