@appium/base-driver 8.2.2 → 8.3.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.js +3 -1
- package/build/lib/basedriver/commands/find.js +4 -11
- package/build/lib/basedriver/commands/log.js +3 -6
- package/build/lib/basedriver/commands/session.js +18 -27
- package/build/lib/basedriver/commands/settings.js +4 -8
- package/build/lib/basedriver/commands/timeout.js +10 -15
- package/build/lib/basedriver/device-settings.js +14 -2
- package/build/lib/basedriver/driver.js +25 -23
- package/build/lib/basedriver/helpers.js +140 -84
- package/build/lib/express/express-logging.js +2 -2
- package/build/lib/express/idempotency.js +2 -2
- package/build/lib/helpers/capabilities.js +39 -0
- package/build/lib/index.js +7 -7
- package/build/lib/jsonwp-proxy/protocol-converter.js +19 -16
- package/build/lib/jsonwp-proxy/proxy.js +20 -16
- package/build/lib/protocol/errors.js +4 -2
- package/build/lib/protocol/helpers.js +3 -20
- package/build/lib/protocol/protocol.js +44 -45
- package/build/lib/protocol/routes.js +67 -1
- package/build/test/basedriver/capabilities-specs.js +43 -1
- package/build/test/basedriver/capability-specs.js +126 -167
- package/build/test/basedriver/commands/log-specs.js +12 -5
- package/build/test/basedriver/driver-tests.js +11 -14
- package/build/test/basedriver/helpers-specs.js +5 -1
- package/build/test/basedriver/timeout-specs.js +7 -9
- package/build/test/express/server-e2e-specs.js +10 -5
- package/build/test/express/server-specs.js +22 -16
- package/build/test/express/static-specs.js +10 -5
- package/build/test/jsonwp-proxy/proxy-e2e-specs.js +1 -2
- package/build/test/jsonwp-proxy/proxy-specs.js +1 -6
- package/build/test/protocol/fake-driver.js +12 -15
- package/build/test/protocol/protocol-e2e-specs.js +49 -103
- package/build/test/protocol/routes-specs.js +2 -2
- package/lib/basedriver/capabilities.js +3 -0
- package/lib/basedriver/commands/find.js +3 -6
- package/lib/basedriver/commands/log.js +2 -4
- package/lib/basedriver/commands/session.js +21 -22
- package/lib/basedriver/commands/settings.js +3 -5
- package/lib/basedriver/commands/timeout.js +9 -10
- package/lib/basedriver/device-settings.js +10 -1
- package/lib/basedriver/driver.js +29 -16
- package/lib/basedriver/helpers.js +201 -83
- package/lib/express/express-logging.js +1 -1
- package/lib/express/idempotency.js +1 -1
- package/lib/helpers/capabilities.js +25 -0
- package/lib/index.js +6 -4
- package/lib/jsonwp-proxy/protocol-converter.js +15 -18
- package/lib/jsonwp-proxy/proxy.js +17 -15
- package/lib/protocol/errors.js +1 -1
- package/lib/protocol/helpers.js +5 -25
- package/lib/protocol/protocol.js +43 -54
- package/lib/protocol/routes.js +60 -1
- package/package.json +29 -22
- package/test/basedriver/capabilities-specs.js +34 -2
- package/test/basedriver/capability-specs.js +120 -146
- package/test/basedriver/commands/log-specs.js +12 -3
- package/test/basedriver/driver-tests.js +12 -7
- package/test/basedriver/helpers-specs.js +4 -0
- package/test/basedriver/timeout-specs.js +6 -11
- package/build/lib/protocol/sessions-cache.js +0 -88
- package/lib/protocol/sessions-cache.js +0 -74
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import LRU from 'lru-cache';
|
|
2
|
-
import { logger } from '@appium/support';
|
|
3
|
-
import { PROTOCOLS } from '../constants';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const GENERIC_PROTOCOL = 'GENERIC';
|
|
7
|
-
const mjsonwpLog = logger.getLogger('MJSONWP');
|
|
8
|
-
const w3cLog = logger.getLogger('W3C');
|
|
9
|
-
const genericProtocolLog = logger.getLogger(GENERIC_PROTOCOL);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class SessionsCache {
|
|
13
|
-
constructor (max) {
|
|
14
|
-
this._cache = new LRU({ max });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getLogger (sessionId, protocol) {
|
|
18
|
-
if (sessionId) {
|
|
19
|
-
if (this._cache.has(sessionId)) {
|
|
20
|
-
const value = this._cache.get(sessionId);
|
|
21
|
-
if (value.logger) {
|
|
22
|
-
return value.logger;
|
|
23
|
-
}
|
|
24
|
-
protocol = protocol || value.protocol;
|
|
25
|
-
}
|
|
26
|
-
// Always create a new logger instance for ids
|
|
27
|
-
// that are not in the current sessions list,
|
|
28
|
-
// so we can still see such ids as prefixes
|
|
29
|
-
return logger.getLogger(`${protocol || GENERIC_PROTOCOL} ` +
|
|
30
|
-
`(${sessionId.substring(0, Math.min(sessionId.length, 8))})`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Fall back to protocol name-only logger if session id is unknown
|
|
34
|
-
switch (protocol) {
|
|
35
|
-
case PROTOCOLS.W3C:
|
|
36
|
-
return w3cLog;
|
|
37
|
-
case PROTOCOLS.MJSONWP:
|
|
38
|
-
return mjsonwpLog;
|
|
39
|
-
default:
|
|
40
|
-
return genericProtocolLog;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getProtocol (sessionId) {
|
|
45
|
-
return (this._cache.get(sessionId) || {}).protocol;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
putSession (sessionId, value) {
|
|
49
|
-
if (sessionId && value) {
|
|
50
|
-
this._cache.set(sessionId, {
|
|
51
|
-
protocol: value,
|
|
52
|
-
// We don't want to cache the logger instance for each random session id in the cache
|
|
53
|
-
// in order to save memory. Instead we only cache loggers for valid ids that
|
|
54
|
-
// are returned by `createSession` call and reset them after `deleteSession` is called
|
|
55
|
-
logger: this.getLogger(sessionId, value),
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
resetLogger (sessionId) {
|
|
62
|
-
if (this._cache.has(sessionId)) {
|
|
63
|
-
this._cache.get(sessionId).logger = null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// This cache is useful when a session gets terminated
|
|
69
|
-
// and removed from the sessions list in the umbrella driver,
|
|
70
|
-
// but the client still tries to send a command to this session id.
|
|
71
|
-
// So we know how to properly wrap the error message for it
|
|
72
|
-
const SESSIONS_CACHE = new SessionsCache(100);
|
|
73
|
-
|
|
74
|
-
export default SESSIONS_CACHE;
|