@appium/base-driver 8.2.4 → 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.
Files changed (51) hide show
  1. package/build/lib/basedriver/commands/find.js +4 -11
  2. package/build/lib/basedriver/commands/log.js +3 -6
  3. package/build/lib/basedriver/commands/session.js +18 -27
  4. package/build/lib/basedriver/commands/settings.js +4 -8
  5. package/build/lib/basedriver/commands/timeout.js +10 -15
  6. package/build/lib/basedriver/device-settings.js +14 -2
  7. package/build/lib/basedriver/driver.js +22 -20
  8. package/build/lib/basedriver/helpers.js +9 -9
  9. package/build/lib/express/express-logging.js +2 -2
  10. package/build/lib/express/idempotency.js +2 -2
  11. package/build/lib/helpers/capabilities.js +39 -0
  12. package/build/lib/index.js +3 -5
  13. package/build/lib/jsonwp-proxy/protocol-converter.js +18 -12
  14. package/build/lib/jsonwp-proxy/proxy.js +19 -12
  15. package/build/lib/protocol/protocol.js +36 -27
  16. package/build/lib/protocol/routes.js +67 -1
  17. package/build/test/basedriver/capabilities-specs.js +43 -1
  18. package/build/test/basedriver/capability-specs.js +126 -167
  19. package/build/test/basedriver/commands/log-specs.js +12 -5
  20. package/build/test/basedriver/driver-tests.js +11 -14
  21. package/build/test/basedriver/timeout-specs.js +7 -9
  22. package/build/test/express/server-e2e-specs.js +10 -5
  23. package/build/test/express/server-specs.js +22 -16
  24. package/build/test/express/static-specs.js +10 -5
  25. package/build/test/protocol/fake-driver.js +12 -15
  26. package/build/test/protocol/protocol-e2e-specs.js +16 -10
  27. package/build/test/protocol/routes-specs.js +2 -2
  28. package/lib/basedriver/commands/find.js +3 -6
  29. package/lib/basedriver/commands/log.js +2 -4
  30. package/lib/basedriver/commands/session.js +21 -22
  31. package/lib/basedriver/commands/settings.js +3 -5
  32. package/lib/basedriver/commands/timeout.js +9 -10
  33. package/lib/basedriver/device-settings.js +10 -1
  34. package/lib/basedriver/driver.js +25 -12
  35. package/lib/basedriver/helpers.js +13 -11
  36. package/lib/express/express-logging.js +1 -1
  37. package/lib/express/idempotency.js +1 -1
  38. package/lib/helpers/capabilities.js +25 -0
  39. package/lib/index.js +2 -2
  40. package/lib/jsonwp-proxy/protocol-converter.js +14 -13
  41. package/lib/jsonwp-proxy/proxy.js +16 -12
  42. package/lib/protocol/protocol.js +34 -29
  43. package/lib/protocol/routes.js +60 -1
  44. package/package.json +29 -22
  45. package/test/basedriver/capabilities-specs.js +34 -2
  46. package/test/basedriver/capability-specs.js +120 -146
  47. package/test/basedriver/commands/log-specs.js +12 -3
  48. package/test/basedriver/driver-tests.js +12 -7
  49. package/test/basedriver/timeout-specs.js +6 -11
  50. package/build/lib/protocol/sessions-cache.js +0 -88
  51. 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;