@appium/base-driver 8.7.2 → 9.0.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.
- package/build/lib/basedriver/capabilities.d.ts +11 -163
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/capabilities.js +354 -236
- package/build/lib/basedriver/capabilities.js.map +1 -1
- package/build/lib/basedriver/commands/event.d.ts +7 -6
- package/build/lib/basedriver/commands/event.d.ts.map +1 -1
- package/build/lib/basedriver/commands/event.js +55 -35
- package/build/lib/basedriver/commands/event.js.map +1 -1
- package/build/lib/basedriver/commands/execute.d.ts +7 -6
- package/build/lib/basedriver/commands/execute.d.ts.map +1 -1
- package/build/lib/basedriver/commands/execute.js +66 -58
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/basedriver/commands/find.d.ts +9 -7
- package/build/lib/basedriver/commands/find.d.ts.map +1 -1
- package/build/lib/basedriver/commands/find.js +102 -54
- package/build/lib/basedriver/commands/find.js.map +1 -1
- package/build/lib/basedriver/commands/index.d.ts +3 -7
- package/build/lib/basedriver/commands/index.d.ts.map +1 -1
- package/build/lib/basedriver/commands/index.js +30 -33
- package/build/lib/basedriver/commands/index.js.map +1 -1
- package/build/lib/basedriver/commands/log.d.ts +8 -9
- package/build/lib/basedriver/commands/log.d.ts.map +1 -1
- package/build/lib/basedriver/commands/log.js +54 -38
- package/build/lib/basedriver/commands/log.js.map +1 -1
- package/build/lib/basedriver/commands/session.d.ts +7 -6
- package/build/lib/basedriver/commands/session.d.ts.map +1 -1
- package/build/lib/basedriver/commands/session.js +46 -39
- package/build/lib/basedriver/commands/session.js.map +1 -1
- package/build/lib/basedriver/commands/settings.d.ts +7 -7
- package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
- package/build/lib/basedriver/commands/settings.js +35 -28
- package/build/lib/basedriver/commands/settings.js.map +1 -1
- package/build/lib/basedriver/commands/timeout.d.ts +7 -5
- package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +144 -162
- package/build/lib/basedriver/commands/timeout.js.map +1 -1
- package/build/lib/basedriver/core.d.ts +6 -157
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +361 -230
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/desired-caps.js +80 -110
- package/build/lib/basedriver/desired-caps.js.map +1 -1
- package/build/lib/basedriver/device-settings.js +57 -62
- package/build/lib/basedriver/device-settings.js.map +1 -1
- package/build/lib/basedriver/driver.d.ts +21 -267
- package/build/lib/basedriver/driver.d.ts.map +1 -1
- package/build/lib/basedriver/driver.js +362 -258
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/basedriver/helpers.js +500 -495
- package/build/lib/basedriver/helpers.js.map +1 -1
- package/build/lib/basedriver/logger.d.ts +1 -1
- package/build/lib/basedriver/logger.d.ts.map +1 -1
- package/build/lib/basedriver/logger.js +5 -15
- package/build/lib/basedriver/logger.js.map +1 -1
- package/build/lib/constants.js +14 -14
- package/build/lib/constants.js.map +1 -1
- package/build/lib/express/crash.js +8 -15
- package/build/lib/express/crash.js.map +1 -1
- package/build/lib/express/express-logging.js +49 -59
- package/build/lib/express/express-logging.js.map +1 -1
- package/build/lib/express/idempotency.js +125 -177
- package/build/lib/express/idempotency.js.map +1 -1
- package/build/lib/express/logger.d.ts +1 -1
- package/build/lib/express/logger.d.ts.map +1 -1
- package/build/lib/express/logger.js +5 -15
- package/build/lib/express/logger.js.map +1 -1
- package/build/lib/express/middleware.js +82 -107
- package/build/lib/express/middleware.js.map +1 -1
- package/build/lib/express/server.d.ts +17 -5
- package/build/lib/express/server.d.ts.map +1 -1
- package/build/lib/express/server.js +259 -224
- package/build/lib/express/server.js.map +1 -1
- package/build/lib/express/static.js +64 -81
- package/build/lib/express/static.js.map +1 -1
- package/build/lib/express/websocket.js +115 -87
- package/build/lib/express/websocket.js.map +1 -1
- package/build/lib/helpers/capabilities.d.ts +1 -59
- package/build/lib/helpers/capabilities.d.ts.map +1 -1
- package/build/lib/helpers/capabilities.js +72 -69
- package/build/lib/helpers/capabilities.js.map +1 -1
- package/build/lib/index.js +64 -180
- package/build/lib/index.js.map +1 -1
- package/build/lib/jsonwp-proxy/protocol-converter.js +215 -227
- package/build/lib/jsonwp-proxy/protocol-converter.js.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.js +355 -393
- package/build/lib/jsonwp-proxy/proxy.js.map +1 -1
- package/build/lib/jsonwp-status/status.js +119 -130
- package/build/lib/jsonwp-status/status.js.map +1 -1
- package/build/lib/protocol/errors.d.ts +135 -32
- package/build/lib/protocol/errors.d.ts.map +1 -1
- package/build/lib/protocol/errors.js +871 -919
- package/build/lib/protocol/errors.js.map +1 -1
- package/build/lib/protocol/helpers.js +37 -37
- package/build/lib/protocol/helpers.js.map +1 -1
- package/build/lib/protocol/index.js +22 -109
- package/build/lib/protocol/index.js.map +1 -1
- package/build/lib/protocol/protocol.js +394 -350
- package/build/lib/protocol/protocol.js.map +1 -1
- package/build/lib/protocol/routes.d.ts +1238 -4
- package/build/lib/protocol/routes.d.ts.map +1 -1
- package/build/lib/protocol/routes.js +964 -1327
- package/build/lib/protocol/routes.js.map +1 -1
- package/build/lib/protocol/validators.js +32 -39
- package/build/lib/protocol/validators.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/basedriver/capabilities.js +80 -39
- package/lib/basedriver/commands/event.js +10 -5
- package/lib/basedriver/commands/execute.js +14 -9
- package/lib/basedriver/commands/find.js +18 -12
- package/lib/basedriver/commands/index.js +21 -16
- package/lib/basedriver/commands/log.js +24 -18
- package/lib/basedriver/commands/session.js +10 -5
- package/lib/basedriver/commands/settings.js +9 -6
- package/lib/basedriver/commands/timeout.js +10 -4
- package/lib/basedriver/core.js +2 -3
- package/lib/basedriver/driver.js +29 -18
- package/lib/express/server.js +6 -3
- package/lib/protocol/errors.js +155 -44
- package/lib/protocol/routes.js +11 -7
- package/package.json +14 -16
|
@@ -1,96 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.STATIC_DIR = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _path = _interopRequireDefault(require("path"));
|
|
15
|
-
|
|
16
|
-
var _logger = _interopRequireDefault(require("./logger"));
|
|
17
|
-
|
|
18
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
19
|
-
|
|
20
|
-
var _support = require("@appium/support");
|
|
21
|
-
|
|
22
|
-
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
let STATIC_DIR = _path.default.resolve(__dirname, '..', '..', '..', 'static');
|
|
27
|
-
|
|
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.STATIC_DIR = exports.welcome = exports.guineaPigAppBanner = exports.guineaPigScrollable = exports.guineaPig = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const support_1 = require("@appium/support");
|
|
11
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
|
12
|
+
let STATIC_DIR = path_1.default.resolve(__dirname, '..', '..', '..', 'static');
|
|
28
13
|
exports.STATIC_DIR = STATIC_DIR;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
if (lodash_1.default.isNull(path_1.default.resolve(__dirname).match(/build[/\\]lib[/\\]express$/))) {
|
|
15
|
+
// in some contexts we are not in the build directory,
|
|
16
|
+
// so we don't want to go back the extra level
|
|
17
|
+
exports.STATIC_DIR = STATIC_DIR = path_1.default.resolve(__dirname, '..', '..', 'static');
|
|
32
18
|
}
|
|
33
|
-
|
|
34
19
|
async function guineaPigTemplate(req, res, page) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
res.cookie('guineacookie2', 'cookié2', {
|
|
61
|
-
path: '/'
|
|
62
|
-
});
|
|
63
|
-
res.cookie('guineacookie3', 'cant access this', {
|
|
64
|
-
domain: '.blargimarg.com',
|
|
65
|
-
path: '/'
|
|
66
|
-
});
|
|
67
|
-
res.send((await getTemplate(page))(params));
|
|
20
|
+
const delay = parseInt(req.params.delay || req.query.delay || 0, 10);
|
|
21
|
+
const throwError = req.params.throwError || req.query.throwError || '';
|
|
22
|
+
let params = {
|
|
23
|
+
throwError,
|
|
24
|
+
serverTime: new Date(),
|
|
25
|
+
userAgent: req.headers['user-agent'],
|
|
26
|
+
comment: 'None',
|
|
27
|
+
};
|
|
28
|
+
if (req.method === 'POST') {
|
|
29
|
+
params.comment = req.body.comments || params.comment;
|
|
30
|
+
}
|
|
31
|
+
logger_1.default.debug(`Sending guinea pig response with params: ${JSON.stringify(params)}`);
|
|
32
|
+
if (delay) {
|
|
33
|
+
logger_1.default.debug(`Waiting ${delay}ms before responding`);
|
|
34
|
+
await bluebird_1.default.delay(delay);
|
|
35
|
+
}
|
|
36
|
+
res.set('content-type', 'text/html');
|
|
37
|
+
res.cookie('guineacookie1', 'i am a cookie value', { path: '/' });
|
|
38
|
+
res.cookie('guineacookie2', 'cookié2', { path: '/' });
|
|
39
|
+
res.cookie('guineacookie3', 'cant access this', {
|
|
40
|
+
domain: '.blargimarg.com',
|
|
41
|
+
path: '/',
|
|
42
|
+
});
|
|
43
|
+
res.send((await getTemplate(page))(params));
|
|
68
44
|
}
|
|
69
|
-
|
|
45
|
+
/*
|
|
46
|
+
* Dynamic page mapped to /test/guinea-pig
|
|
47
|
+
*/
|
|
70
48
|
async function guineaPig(req, res) {
|
|
71
|
-
|
|
49
|
+
return await guineaPigTemplate(req, res, 'guinea-pig.html');
|
|
72
50
|
}
|
|
73
|
-
|
|
51
|
+
exports.guineaPig = guineaPig;
|
|
52
|
+
/*
|
|
53
|
+
* Dynamic page mapped to /test/guinea-pig-scrollable
|
|
54
|
+
*/
|
|
74
55
|
async function guineaPigScrollable(req, res) {
|
|
75
|
-
|
|
56
|
+
return await guineaPigTemplate(req, res, 'guinea-pig-scrollable.html');
|
|
76
57
|
}
|
|
77
|
-
|
|
58
|
+
exports.guineaPigScrollable = guineaPigScrollable;
|
|
59
|
+
/*
|
|
60
|
+
* Dynamic page mapped to /test/guinea-pig-app-banner
|
|
61
|
+
*/
|
|
78
62
|
async function guineaPigAppBanner(req, res) {
|
|
79
|
-
|
|
63
|
+
return await guineaPigTemplate(req, res, 'guinea-pig-app-banner.html');
|
|
80
64
|
}
|
|
81
|
-
|
|
65
|
+
exports.guineaPigAppBanner = guineaPigAppBanner;
|
|
66
|
+
/*
|
|
67
|
+
* Dynamic page mapped to /welcome
|
|
68
|
+
*/
|
|
82
69
|
async function welcome(req, res) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
_logger.default.debug(`Sending welcome response with params: ${JSON.stringify(params)}`);
|
|
88
|
-
|
|
89
|
-
res.send((await getTemplate('welcome.html'))(params));
|
|
70
|
+
let params = { message: "Let's browse!" };
|
|
71
|
+
logger_1.default.debug(`Sending welcome response with params: ${JSON.stringify(params)}`);
|
|
72
|
+
res.send((await getTemplate('welcome.html'))(params));
|
|
90
73
|
}
|
|
91
|
-
|
|
74
|
+
exports.welcome = welcome;
|
|
92
75
|
async function getTemplate(templateName) {
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
let content = await support_1.fs.readFile(path_1.default.resolve(STATIC_DIR, 'test', templateName));
|
|
77
|
+
return lodash_1.default.template(content.toString());
|
|
95
78
|
}
|
|
96
|
-
//# sourceMappingURL=
|
|
79
|
+
//# sourceMappingURL=static.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.js","
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot":"","sources":["../../../lib/express/static.js"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,sDAA2B;AAC3B,oDAAuB;AACvB,6CAAmC;AACnC,wDAAyB;AAEzB,IAAI,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAqEA,gCAAU;AApE/E,IAAI,gBAAC,CAAC,MAAM,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,EAAE;IACzE,sDAAsD;IACtD,8CAA8C;IAC9C,qBAAA,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;CAC5D;AAED,KAAK,UAAU,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI;IAC7C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACrE,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,GAAG,CA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BO,8BAAS;AA5BjB;;GAEG;AACH,KAAK,UAAU,mBAAmB,CAAC,GAAG,EAAE,GAAG;IACzC,OAAO,MAAM,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,4BAA4B,CAAC,CAAC;AACzE,CAAC;AAuBkB,kDAAmB;AArBtC;;GAEG;AACH,KAAK,UAAU,kBAAkB,CAAC,GAAG,EAAE,GAAG;IACxC,OAAO,MAAM,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,4BAA4B,CAAC,CAAC;AACzE,CAAC;AAgBuC,gDAAkB;AAd1D;;GAEG;AACH,KAAK,UAAU,OAAO,CAAC,GAAG,EAAE,GAAG;IAC7B,IAAI,MAAM,GAAG,EAAC,OAAO,EAAE,eAAe,EAAC,CAAC;IACxC,gBAAG,CAAC,KAAK,CAAC,yCAAyC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACxD,CAAC;AAO2D,0BAAO;AALnE,KAAK,UAAU,WAAW,CAAC,YAAY;IACrC,IAAI,OAAO,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAChF,OAAO,gBAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,100 +1,128 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.DEFAULT_WS_PATHNAME_PREFIX = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
require("source-map-support/register");
|
|
13
|
-
|
|
14
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
15
|
-
|
|
16
|
-
var _url = require("url");
|
|
17
|
-
|
|
18
|
-
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
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.DEFAULT_WS_PATHNAME_PREFIX = exports.getWebSocketHandlers = exports.removeAllWebSocketHandlers = exports.removeWebSocketHandler = exports.addWebSocketHandler = void 0;
|
|
7
|
+
/* eslint-disable require-await */
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const url_1 = require("url");
|
|
10
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
|
22
11
|
const DEFAULT_WS_PATHNAME_PREFIX = '/ws';
|
|
23
12
|
exports.DEFAULT_WS_PATHNAME_PREFIX = DEFAULT_WS_PATHNAME_PREFIX;
|
|
24
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Adds websocket handler to express server instance.
|
|
15
|
+
* It is expected this function is called in Express
|
|
16
|
+
* server instance context.
|
|
17
|
+
*
|
|
18
|
+
* @this {AppiumServer} - An instance of express HTTP server.
|
|
19
|
+
* @param {string} handlerPathname - Web socket endpoint path starting with
|
|
20
|
+
* a single slash character. It is recommended to always add
|
|
21
|
+
* DEFAULT_WS_PATHNAME_PREFIX to all web socket pathnames.
|
|
22
|
+
* @param {import('ws').Server} handlerServer - WebSocket server instance. See
|
|
23
|
+
* https://github.com/websockets/ws/pull/885 for more details
|
|
24
|
+
* on how to configure the handler properly.
|
|
25
|
+
* @returns {Promise<void>}
|
|
26
|
+
*/
|
|
25
27
|
async function addWebSocketHandler(handlerPathname, handlerServer) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.webSocketsMapping[handlerPathname] = handlerServer;
|
|
28
|
+
const server = /** @type {AppiumServer} */ (this);
|
|
29
|
+
if (lodash_1.default.isUndefined(this.webSocketsMapping)) {
|
|
30
|
+
server.webSocketsMapping = {};
|
|
31
|
+
// https://github.com/websockets/ws/pull/885
|
|
32
|
+
server.on('upgrade', (request, socket, head) => {
|
|
33
|
+
let currentPathname;
|
|
34
|
+
try {
|
|
35
|
+
// @ts-expect-error
|
|
36
|
+
currentPathname = new url_1.URL(request.url).pathname;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
currentPathname = request.url;
|
|
40
|
+
}
|
|
41
|
+
for (const [pathname, wsServer] of lodash_1.default.toPairs(server.webSocketsMapping)) {
|
|
42
|
+
if (currentPathname === pathname) {
|
|
43
|
+
wsServer.handleUpgrade(request, socket, head, (ws) => {
|
|
44
|
+
wsServer.emit('connection', ws, request);
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
socket.destroy();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
this.webSocketsMapping[handlerPathname] = handlerServer;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
exports.addWebSocketHandler = addWebSocketHandler;
|
|
55
|
+
/**
|
|
56
|
+
* Returns web socket handlers registered for the given server
|
|
57
|
+
* instance.
|
|
58
|
+
* It is expected this function is called in Express
|
|
59
|
+
* server instance context.
|
|
60
|
+
*
|
|
61
|
+
* @this {AppiumServer}
|
|
62
|
+
* @param {string?} [keysFilter] - Only include pathnames with given
|
|
63
|
+
* `keysFilter` value if set. All pairs will be included by default.
|
|
64
|
+
* @returns {Promise<Record<string, import('ws').Server>>} pathnames to websocket server instances mapping matching the search criteria or an empty object otherwise.
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line require-await
|
|
55
67
|
async function getWebSocketHandlers(keysFilter = null) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return _lodash.default.toPairs(this.webSocketsMapping).reduce((acc, [pathname, wsServer]) => {
|
|
61
|
-
if (!_lodash.default.isString(keysFilter) || pathname.includes(keysFilter)) {
|
|
62
|
-
acc[pathname] = wsServer;
|
|
68
|
+
if (lodash_1.default.isEmpty(this.webSocketsMapping)) {
|
|
69
|
+
return {};
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
return lodash_1.default.toPairs(this.webSocketsMapping).reduce((acc, [pathname, wsServer]) => {
|
|
72
|
+
if (!lodash_1.default.isString(keysFilter) || pathname.includes(keysFilter)) {
|
|
73
|
+
acc[pathname] = wsServer;
|
|
74
|
+
}
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
67
77
|
}
|
|
68
|
-
|
|
78
|
+
exports.getWebSocketHandlers = getWebSocketHandlers;
|
|
79
|
+
/**
|
|
80
|
+
* Removes existing websocket handler from express server instance.
|
|
81
|
+
* The call is ignored if the given `handlerPathname` handler
|
|
82
|
+
* is not present in the handlers list.
|
|
83
|
+
* It is expected this function is called in Express
|
|
84
|
+
* server instance context.
|
|
85
|
+
* @this {AppiumServer}
|
|
86
|
+
* @param {string} handlerPathname - Websocket endpoint path.
|
|
87
|
+
* @returns {Promise<boolean>} true if the handlerPathname was found and deleted
|
|
88
|
+
*/
|
|
89
|
+
// eslint-disable-next-line require-await
|
|
69
90
|
async function removeWebSocketHandler(handlerPathname) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!wsServer) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
wsServer.close();
|
|
80
|
-
|
|
81
|
-
for (const client of wsServer.clients || []) {
|
|
82
|
-
client.terminate();
|
|
91
|
+
const wsServer = this.webSocketsMapping?.[handlerPathname];
|
|
92
|
+
if (!wsServer) {
|
|
93
|
+
return false;
|
|
83
94
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
try {
|
|
96
|
+
wsServer.close();
|
|
97
|
+
for (const client of wsServer.clients || []) {
|
|
98
|
+
client.terminate();
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
catch (ign) {
|
|
103
|
+
// ignore
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
delete this.webSocketsMapping[handlerPathname];
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
91
109
|
}
|
|
92
|
-
|
|
110
|
+
exports.removeWebSocketHandler = removeWebSocketHandler;
|
|
111
|
+
/**
|
|
112
|
+
* Removes all existing websocket handler from express server instance.
|
|
113
|
+
* It is expected this function is called in Express
|
|
114
|
+
* server instance context.
|
|
115
|
+
* @this {AppiumServer}
|
|
116
|
+
* @returns {Promise<boolean>} true if at least one handler has been deleted
|
|
117
|
+
*/
|
|
93
118
|
async function removeAllWebSocketHandlers() {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return _lodash.default.some(await _bluebird.default.all(_lodash.default.keys(this.webSocketsMapping).map(pathname => this.removeWebSocketHandler(pathname))));
|
|
119
|
+
if (lodash_1.default.isEmpty(this.webSocketsMapping)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return lodash_1.default.some(await bluebird_1.default.all(lodash_1.default.keys(this.webSocketsMapping).map((pathname) => this.removeWebSocketHandler(pathname))));
|
|
99
123
|
}
|
|
100
|
-
|
|
124
|
+
exports.removeAllWebSocketHandlers = removeAllWebSocketHandlers;
|
|
125
|
+
/**
|
|
126
|
+
* @typedef {import('@appium/types').AppiumServer} AppiumServer
|
|
127
|
+
*/
|
|
128
|
+
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../lib/express/websocket.js"],"names":[],"mappings":";;;;;;AAAA,kCAAkC;AAClC,oDAAuB;AACvB,6BAAwB;AACxB,wDAAyB;AAEzB,MAAM,0BAA0B,GAAG,KAAK,CAAC;AA2HvC,gEAA0B;AAzH5B;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,mBAAmB,CAAC,eAAe,EAAE,aAAa;IAC/D,MAAM,MAAM,GAAG,2BAA2B,CAAC,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,gBAAC,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;QACzC,MAAM,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC9B,4CAA4C;QAC5C,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YAC7C,IAAI,eAAe,CAAC;YACpB,IAAI;gBACF,mBAAmB;gBACnB,eAAe,GAAG,IAAI,SAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;aACjD;YAAC,MAAM;gBACN,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;aAC/B;YACD,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,gBAAC,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;gBACtE,IAAI,eAAe,KAAK,QAAQ,EAAE;oBAChC,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,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AC;SACpB;QACD,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,GAAG,EAAE;QACZ,SAAS;KACV;YAAS;QACR,OAAO,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;KAChD;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAuBC,wDAAsB;AArBxB;;;;;;GAMG;AACH,KAAK,UAAU,0BAA0B;IACvC,IAAI,gBAAC,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;QACrC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,gBAAC,CAAC,IAAI,CACX,MAAM,kBAAC,CAAC,GAAG,CACT,gBAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CACxF,CACF,CAAC;AACJ,CAAC;AAKC,gEAA0B;AAK5B;;GAEG"}
|
|
@@ -2,65 +2,7 @@ export type Constraints = import('@appium/types').Constraints;
|
|
|
2
2
|
export type AppiumLogger = import('@appium/types').AppiumLogger;
|
|
3
3
|
export type StringRecord = import('@appium/types').StringRecord;
|
|
4
4
|
export type BaseDriverCapConstraints = import('@appium/types').BaseDriverCapConstraints;
|
|
5
|
-
export type Capabilities<C extends Readonly<Record<string, import("@appium/types").Constraint>> =
|
|
6
|
-
readonly platformName: {
|
|
7
|
-
readonly presence: true;
|
|
8
|
-
readonly isString: true;
|
|
9
|
-
};
|
|
10
|
-
readonly app: {
|
|
11
|
-
readonly isString: true;
|
|
12
|
-
};
|
|
13
|
-
readonly deviceName: {
|
|
14
|
-
readonly isString: true;
|
|
15
|
-
};
|
|
16
|
-
readonly platformVersion: {
|
|
17
|
-
readonly isString: true;
|
|
18
|
-
};
|
|
19
|
-
readonly newCommandTimeout: {
|
|
20
|
-
readonly isNumber: true;
|
|
21
|
-
};
|
|
22
|
-
readonly automationName: {
|
|
23
|
-
readonly isString: true;
|
|
24
|
-
};
|
|
25
|
-
readonly autoLaunch: {
|
|
26
|
-
readonly isBoolean: true;
|
|
27
|
-
};
|
|
28
|
-
readonly udid: {
|
|
29
|
-
readonly isString: true;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @template {Constraints} C
|
|
34
|
-
* @param {any} oldCaps
|
|
35
|
-
* @param {C} desiredCapConstraints
|
|
36
|
-
* @param {AppiumLogger} log
|
|
37
|
-
* @returns {Capabilities<C>}
|
|
38
|
-
*/
|
|
39
|
-
readonly orientation: {
|
|
40
|
-
readonly inclusion: readonly ["LANDSCAPE", "PORTRAIT"];
|
|
41
|
-
};
|
|
42
|
-
readonly autoWebview: {
|
|
43
|
-
readonly isBoolean: true;
|
|
44
|
-
};
|
|
45
|
-
readonly noReset: {
|
|
46
|
-
readonly isBoolean: true;
|
|
47
|
-
};
|
|
48
|
-
readonly fullReset: {
|
|
49
|
-
readonly isBoolean: true;
|
|
50
|
-
};
|
|
51
|
-
readonly language: {
|
|
52
|
-
readonly isString: true;
|
|
53
|
-
};
|
|
54
|
-
readonly locale: {
|
|
55
|
-
readonly isString: true;
|
|
56
|
-
};
|
|
57
|
-
readonly eventTimings: {
|
|
58
|
-
readonly isBoolean: true;
|
|
59
|
-
};
|
|
60
|
-
readonly printPageSourceOnFindFailure: {
|
|
61
|
-
readonly isBoolean: true;
|
|
62
|
-
};
|
|
63
|
-
}, Extra extends void | import("@appium/types").StringRecord = void> = import('@appium/types').Capabilities<C, Extra>;
|
|
5
|
+
export type Capabilities<C extends Readonly<Record<string, import("@appium/types").Constraint>> = typeof import("@appium/types").BASE_DESIRED_CAP_CONSTRAINTS, Extra extends void | import("@appium/types").StringRecord = void> = import('@appium/types').Capabilities<C, Extra>;
|
|
64
6
|
export function isW3cCaps(caps: any): boolean;
|
|
65
7
|
/**
|
|
66
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../lib/helpers/capabilities.js"],"names":[],"mappings":"0BA8Ea,OAAO,eAAe,EAAE,WAAW;2BACnC,OAAO,eAAe,EAAE,YAAY;2BACpC,OAAO,eAAe,EAAE,YAAY;uCACpC,OAAO,eAAe,EAAE,wBAAwB
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../lib/helpers/capabilities.js"],"names":[],"mappings":"0BA8Ea,OAAO,eAAe,EAAE,WAAW;2BACnC,OAAO,eAAe,EAAE,YAAY;2BACpC,OAAO,eAAe,EAAE,YAAY;uCACpC,OAAO,eAAe,EAAE,wBAAwB;mOAMhD,OAAO,eAAe,EAAE,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC;AAnF3D,8CAoBC;AAED;;;;;;;GAOG;AACH,yGALW,GAAG,iCAEH,YAAY,gEA0CtB"}
|