@appium/base-driver 9.14.0 → 9.15.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/LICENSE +201 -0
- package/build/lib/basedriver/core.d.ts +4 -10
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +4 -68
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/extension-core.d.ts +16 -0
- package/build/lib/basedriver/extension-core.d.ts.map +1 -0
- package/build/lib/basedriver/extension-core.js +103 -0
- package/build/lib/basedriver/extension-core.js.map +1 -0
- package/build/lib/basedriver/helpers.d.ts +2 -2
- package/build/lib/basedriver/helpers.d.ts.map +1 -1
- package/build/lib/basedriver/helpers.js +1 -1
- package/build/lib/index.d.ts +2 -0
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +5 -1
- package/build/lib/index.js.map +1 -1
- package/lib/basedriver/core.ts +6 -96
- package/lib/basedriver/extension-core.ts +128 -0
- package/lib/basedriver/helpers.js +1 -1
- package/lib/index.js +3 -0
- package/package.json +5 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { AppiumLogger, Constraints, Core, Driver, DriverOpts, EventHistory, HTTPMethod, InitialOpts, Protocol, RouteMatcher, StringRecord
|
|
1
|
+
import type { AppiumLogger, Constraints, Core, Driver, DriverOpts, EventHistory, HTTPMethod, InitialOpts, Protocol, RouteMatcher, StringRecord } from '@appium/types';
|
|
2
2
|
import AsyncLock from 'async-lock';
|
|
3
3
|
import { DeviceSettings } from './device-settings';
|
|
4
4
|
import * as helpers from './helpers';
|
|
5
|
-
|
|
5
|
+
import { ExtensionCore } from './extension-core';
|
|
6
|
+
export declare class DriverCore<const C extends Constraints, Settings extends StringRecord = StringRecord> extends ExtensionCore implements Core<C, Settings> {
|
|
6
7
|
/**
|
|
7
8
|
* Make the basedriver version available so for any driver which inherits from this package, we
|
|
8
9
|
* know which version of basedriver it inherited from
|
|
@@ -31,9 +32,8 @@ export declare class DriverCore<const C extends Constraints, Settings extends St
|
|
|
31
32
|
managedDrivers: Driver[];
|
|
32
33
|
noCommandTimer: NodeJS.Timeout | null;
|
|
33
34
|
protected _eventHistory: EventHistory;
|
|
34
|
-
eventEmitter: NodeJS.EventEmitter;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* TODO: remove this._log and use this.log instead
|
|
37
37
|
*/
|
|
38
38
|
protected _log: AppiumLogger;
|
|
39
39
|
shutdownUnexpectedly: boolean;
|
|
@@ -47,11 +47,7 @@ export declare class DriverCore<const C extends Constraints, Settings extends St
|
|
|
47
47
|
*/
|
|
48
48
|
settings: DeviceSettings<Settings>;
|
|
49
49
|
protocol?: Protocol;
|
|
50
|
-
bidiEventSubs: Record<string, string[]>;
|
|
51
|
-
doesSupportBidi: boolean;
|
|
52
|
-
bidiCommands: BidiModuleMap;
|
|
53
50
|
constructor(opts?: InitialOpts, shouldValidateCaps?: boolean);
|
|
54
|
-
get log(): AppiumLogger;
|
|
55
51
|
/**
|
|
56
52
|
* Set a callback handler if needed to execute a custom piece of code
|
|
57
53
|
* when the driver is shut down unexpectedly. Multiple calls to this method
|
|
@@ -160,7 +156,5 @@ export declare class DriverCore<const C extends Constraints, Settings extends St
|
|
|
160
156
|
addManagedDriver(driver: Driver): void;
|
|
161
157
|
getManagedDrivers(): Driver<Constraints, StringRecord, StringRecord, import("@appium/types").DefaultCreateSessionResult<Constraints>, void, StringRecord>[];
|
|
162
158
|
clearNewCommandTimeout(): Promise<void>;
|
|
163
|
-
updateBidiCommands(cmds: BidiModuleMap): void;
|
|
164
|
-
executeBidiCommand(bidiCmd: string, bidiParams: StringRecord): Promise<BiDiResultData>;
|
|
165
159
|
}
|
|
166
160
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../lib/basedriver/core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../lib/basedriver/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,MAAM,EACN,UAAU,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,SAAS,MAAM,YAAY,CAAC;AAQnC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAS/C,qBAAa,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,SAAS,YAAY,GAAG,YAAY,CAC/F,SAAQ,aAAc,YAAW,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC;IAElD;;;OAGG;IACH,MAAM,CAAC,WAAW,SAA0B;IAE5C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAEpB,WAAW,EAAE,WAAW,CAAC;IAEzB,OAAO,EAAE,OAAO,OAAO,CAAC;IAExB;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB,sBAAsB,EAAE,OAAO,CAAC;IAEhC,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB,YAAY,EAAE,MAAM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C,IAAI,EAAE,MAAM;IAIjC;;;;;OAKG;IACH,oBAAoB,CAAC,IAAI,EAAE,MAAM;IAWjC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,UAAQ;IAe5D;;;;;;;OAOG;IACH,IAAI,YAAY,IAAI,MAAM,GAAG,IAAI,CAEhC;IAGD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAKvC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE;IAKpD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIpC;;;;;;;;;;;;OAYG;IAEH,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO;IAoB5F;;;OAGG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM;IAI/B,iBAAiB;IAIX,sBAAsB;CAO7B"}
|
|
@@ -37,24 +37,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.DriverCore = void 0;
|
|
40
|
-
const support_1 = require("@appium/support");
|
|
41
40
|
const async_lock_1 = __importDefault(require("async-lock"));
|
|
42
41
|
const lodash_1 = __importDefault(require("lodash"));
|
|
43
|
-
const node_events_1 = require("node:events");
|
|
44
42
|
const node_os_1 = __importDefault(require("node:os"));
|
|
45
43
|
const constants_1 = require("../constants");
|
|
46
44
|
const protocol_1 = require("../protocol");
|
|
47
45
|
const device_settings_1 = require("./device-settings");
|
|
48
46
|
const helpers = __importStar(require("./helpers"));
|
|
49
|
-
const
|
|
47
|
+
const extension_core_1 = require("./extension-core");
|
|
50
48
|
const NEW_COMMAND_TIMEOUT_MS = 60 * 1000;
|
|
51
49
|
const ON_UNEXPECTED_SHUTDOWN_EVENT = 'onUnexpectedShutdown';
|
|
52
50
|
const ALL_DRIVERS_MATCH = '*';
|
|
53
51
|
const FEATURE_NAME_SEPARATOR = ':';
|
|
54
|
-
class DriverCore {
|
|
52
|
+
class DriverCore extends extension_core_1.ExtensionCore {
|
|
55
53
|
constructor(opts = {}, shouldValidateCaps = true) {
|
|
56
|
-
|
|
57
|
-
this._log =
|
|
54
|
+
super();
|
|
55
|
+
this._log = this.log; // TODO: remove references to this._log and use this.log instead
|
|
58
56
|
// setup state
|
|
59
57
|
this.opts = opts;
|
|
60
58
|
// use a custom tmp dir to avoid losing data and app when computer is
|
|
@@ -77,15 +75,9 @@ class DriverCore {
|
|
|
77
75
|
this.managedDrivers = [];
|
|
78
76
|
this.noCommandTimer = null;
|
|
79
77
|
this._eventHistory = { commands: [] };
|
|
80
|
-
this.eventEmitter = new node_events_1.EventEmitter();
|
|
81
78
|
this.shutdownUnexpectedly = false;
|
|
82
79
|
this.commandsQueueGuard = new async_lock_1.default();
|
|
83
80
|
this.settings = new device_settings_1.DeviceSettings();
|
|
84
|
-
this.bidiEventSubs = {};
|
|
85
|
-
this.doesSupportBidi = false;
|
|
86
|
-
}
|
|
87
|
-
get log() {
|
|
88
|
-
return this._log;
|
|
89
81
|
}
|
|
90
82
|
/**
|
|
91
83
|
* Set a callback handler if needed to execute a custom piece of code
|
|
@@ -332,62 +324,6 @@ class DriverCore {
|
|
|
332
324
|
this.noCommandTimer = null;
|
|
333
325
|
}
|
|
334
326
|
}
|
|
335
|
-
updateBidiCommands(cmds) {
|
|
336
|
-
const overlappingKeys = lodash_1.default.intersection(Object.keys(cmds), Object.keys(this.bidiCommands));
|
|
337
|
-
if (overlappingKeys.length) {
|
|
338
|
-
this.log.warn(`Overwriting existing bidi modules: ${JSON.stringify(overlappingKeys)}. This may not be intended!`);
|
|
339
|
-
}
|
|
340
|
-
this.bidiCommands = {
|
|
341
|
-
...this.bidiCommands,
|
|
342
|
-
...cmds,
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
async executeBidiCommand(bidiCmd, bidiParams) {
|
|
346
|
-
const [moduleName, methodName] = bidiCmd.split('.');
|
|
347
|
-
// if we don't get a valid format for bidi command name, reject
|
|
348
|
-
if (!moduleName || !methodName) {
|
|
349
|
-
throw new protocol_1.errors.UnknownCommandError(`Did not receive a valid BiDi module and method name ` +
|
|
350
|
-
`of the form moduleName.methodName. Instead received ` +
|
|
351
|
-
`'${moduleName}.${methodName}'`);
|
|
352
|
-
}
|
|
353
|
-
// if the command module or method isn't part of our spec, reject
|
|
354
|
-
if (!this.bidiCommands[moduleName] || !this.bidiCommands[moduleName][methodName]) {
|
|
355
|
-
throw new protocol_1.errors.UnknownCommandError();
|
|
356
|
-
}
|
|
357
|
-
const { command, params } = this.bidiCommands[moduleName][methodName];
|
|
358
|
-
// if the command method isn't part of our spec, also reject
|
|
359
|
-
if (!command) {
|
|
360
|
-
throw new protocol_1.errors.UnknownCommandError();
|
|
361
|
-
}
|
|
362
|
-
// If the driver doesn't have this command, it must not be implemented
|
|
363
|
-
if (!this[command]) {
|
|
364
|
-
throw new protocol_1.errors.NotYetImplementedError();
|
|
365
|
-
}
|
|
366
|
-
// TODO improve param parsing and error messages along the lines of what we have in the http
|
|
367
|
-
// handlers
|
|
368
|
-
const args = [];
|
|
369
|
-
if (params?.required?.length) {
|
|
370
|
-
for (const requiredParam of params.required) {
|
|
371
|
-
if (lodash_1.default.isUndefined(bidiParams[requiredParam])) {
|
|
372
|
-
throw new protocol_1.errors.InvalidArgumentError(`The ${requiredParam} parameter was required but you omitted it`);
|
|
373
|
-
}
|
|
374
|
-
args.push(bidiParams[requiredParam]);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
if (params?.optional?.length) {
|
|
378
|
-
for (const optionalParam of params.optional) {
|
|
379
|
-
args.push(bidiParams[optionalParam]);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
const logParams = lodash_1.default.truncate(JSON.stringify(bidiParams), { length: constants_1.MAX_LOG_BODY_LENGTH });
|
|
383
|
-
this.log.debug(`Executing bidi command '${bidiCmd}' with params ${logParams} by passing to driver ` +
|
|
384
|
-
`method '${command}'`);
|
|
385
|
-
const response = await this[command](...args);
|
|
386
|
-
const finalResponse = lodash_1.default.isUndefined(response) ? {} : response;
|
|
387
|
-
this.log.debug(`Responding to bidi command '${bidiCmd}' with ` +
|
|
388
|
-
`${lodash_1.default.truncate(JSON.stringify(finalResponse), { length: constants_1.MAX_LOG_BODY_LENGTH })}`);
|
|
389
|
-
return finalResponse;
|
|
390
|
-
}
|
|
391
327
|
}
|
|
392
328
|
exports.DriverCore = DriverCore;
|
|
393
329
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../lib/basedriver/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../lib/basedriver/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,4DAAmC;AACnC,oDAAuB;AACvB,sDAAyB;AACzB,4CAGsB;AACtB,0CAAmC;AACnC,uDAAiD;AACjD,mDAAqC;AACrC,qDAA+C;AAE/C,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzC,MAAM,4BAA4B,GAAG,sBAAsB,CAAC;AAE5D,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,MAAa,UACX,SAAQ,8BAAa;IAmErB,YAAY,OAAiC,EAAE,EAAE,kBAAkB,GAAG,IAAI;QACxE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,gEAAgE;QAGtF,cAAc;QACd,IAAI,CAAC,IAAI,GAAG,IAAqB,CAAC;QAElC,qEAAqE;QACrE,YAAY;QACZ,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,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,CAAC,CAAC;YACvE,CAAC;YACD,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,gBAAC,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACvF,IAAI,WAAW,KAAK,MAAM,IAAI,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;gBACjE,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,MAAc;QAC7B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,sBAAsB;QAC1B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC;IACH,CAAC;;AA9XH,gCAgYC;AA7XC;;;GAGG;AACI,sBAAW,GAAG,OAAO,CAAC,cAAc,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AppiumLogger, BidiModuleMap, BiDiResultData, StringRecord } from '@appium/types';
|
|
2
|
+
export declare class ExtensionCore {
|
|
3
|
+
bidiEventSubs: Record<string, string[]>;
|
|
4
|
+
bidiCommands: BidiModuleMap;
|
|
5
|
+
_logPrefix?: string;
|
|
6
|
+
protected _log: AppiumLogger;
|
|
7
|
+
readonly eventEmitter: NodeJS.EventEmitter;
|
|
8
|
+
constructor(logPrefix?: string);
|
|
9
|
+
get log(): AppiumLogger;
|
|
10
|
+
updateLogPrefix(logPrefix: string): void;
|
|
11
|
+
updateBidiCommands(cmds: BidiModuleMap): void;
|
|
12
|
+
doesBidiCommandExist(moduleName: string, methodName: string): boolean;
|
|
13
|
+
ensureBidiCommandExists(moduleName: string, methodName: string): void;
|
|
14
|
+
executeBidiCommand(bidiCmd: string, bidiParams: StringRecord, next?: () => Promise<any>, driver?: ExtensionCore): Promise<BiDiResultData>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=extension-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-core.d.ts","sourceRoot":"","sources":["../../../lib/basedriver/extension-core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACb,MAAM,eAAe,CAAC;AASvB,qBAAa,aAAa;IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,YAAY,EAAE,aAAa,CAAkC;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC;IAE7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC;gBAG/B,SAAS,CAAC,EAAE,MAAM;IAM9B,IAAI,GAAG,IAAI,YAAY,CAKtB;IAED,eAAe,CAAC,SAAS,EAAE,MAAM;IAIjC,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAW7C,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;IASrE,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IA2B/D,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;CAsChJ"}
|
|
@@ -0,0 +1,103 @@
|
|
|
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.ExtensionCore = void 0;
|
|
7
|
+
const support_1 = require("@appium/support");
|
|
8
|
+
const node_events_1 = require("node:events");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const protocol_1 = require("../protocol");
|
|
11
|
+
const bidi_commands_1 = require("../protocol/bidi-commands");
|
|
12
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
13
|
+
const helpers_1 = require("./helpers");
|
|
14
|
+
class ExtensionCore {
|
|
15
|
+
constructor(logPrefix) {
|
|
16
|
+
this.bidiCommands = bidi_commands_1.BIDI_COMMANDS;
|
|
17
|
+
this._logPrefix = logPrefix;
|
|
18
|
+
this.bidiEventSubs = {};
|
|
19
|
+
this.eventEmitter = new node_events_1.EventEmitter();
|
|
20
|
+
}
|
|
21
|
+
get log() {
|
|
22
|
+
if (!this._log) {
|
|
23
|
+
this.updateLogPrefix(this._logPrefix ?? (0, helpers_1.generateDriverLogPrefix)(this));
|
|
24
|
+
}
|
|
25
|
+
return this._log;
|
|
26
|
+
}
|
|
27
|
+
updateLogPrefix(logPrefix) {
|
|
28
|
+
this._log = support_1.logger.getLogger(logPrefix);
|
|
29
|
+
}
|
|
30
|
+
updateBidiCommands(cmds) {
|
|
31
|
+
const overlappingKeys = lodash_1.default.intersection(Object.keys(cmds), Object.keys(this.bidiCommands));
|
|
32
|
+
if (overlappingKeys.length) {
|
|
33
|
+
this.log.warn(`Overwriting existing bidi modules: ${JSON.stringify(overlappingKeys)}. This may not be intended!`);
|
|
34
|
+
}
|
|
35
|
+
this.bidiCommands = {
|
|
36
|
+
...this.bidiCommands,
|
|
37
|
+
...cmds,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
doesBidiCommandExist(moduleName, methodName) {
|
|
41
|
+
try {
|
|
42
|
+
this.ensureBidiCommandExists(moduleName, methodName);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
ensureBidiCommandExists(moduleName, methodName) {
|
|
50
|
+
// if we don't get a valid format for bidi command name, reject
|
|
51
|
+
if (!moduleName || !methodName) {
|
|
52
|
+
throw new protocol_1.errors.UnknownCommandError(`Did not receive a valid BiDi module and method name ` +
|
|
53
|
+
`of the form moduleName.methodName. Instead received ` +
|
|
54
|
+
`'${moduleName}.${methodName}'`);
|
|
55
|
+
}
|
|
56
|
+
// if the command module or method isn't part of our spec, reject
|
|
57
|
+
if (!this.bidiCommands[moduleName] || !this.bidiCommands[moduleName][methodName]) {
|
|
58
|
+
throw new protocol_1.errors.UnknownCommandError();
|
|
59
|
+
}
|
|
60
|
+
const { command } = this.bidiCommands[moduleName][methodName];
|
|
61
|
+
// if the command method isn't part of our spec, also reject
|
|
62
|
+
if (!command) {
|
|
63
|
+
throw new protocol_1.errors.UnknownCommandError();
|
|
64
|
+
}
|
|
65
|
+
// If the driver doesn't have this command, it must not be implemented
|
|
66
|
+
if (!this[command]) {
|
|
67
|
+
throw new protocol_1.errors.NotYetImplementedError();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async executeBidiCommand(bidiCmd, bidiParams, next, driver) {
|
|
71
|
+
const handlerType = (next && driver) ? 'plugin' : 'driver';
|
|
72
|
+
const [moduleName, methodName] = bidiCmd.split('.');
|
|
73
|
+
this.ensureBidiCommandExists(moduleName, methodName);
|
|
74
|
+
const { command, params } = this.bidiCommands[moduleName][methodName];
|
|
75
|
+
// TODO improve param parsing and error messages along the lines of what we have in the http
|
|
76
|
+
// handlers
|
|
77
|
+
const args = [];
|
|
78
|
+
if (params?.required?.length) {
|
|
79
|
+
for (const requiredParam of params.required) {
|
|
80
|
+
if (lodash_1.default.isUndefined(bidiParams[requiredParam])) {
|
|
81
|
+
throw new protocol_1.errors.InvalidArgumentError(`The ${requiredParam} parameter was required but you omitted it`);
|
|
82
|
+
}
|
|
83
|
+
args.push(bidiParams[requiredParam]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (params?.optional?.length) {
|
|
87
|
+
for (const optionalParam of params.optional) {
|
|
88
|
+
args.push(bidiParams[optionalParam]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const logParams = lodash_1.default.truncate(JSON.stringify(bidiParams), { length: constants_1.MAX_LOG_BODY_LENGTH });
|
|
92
|
+
this.log.debug(`Executing bidi command '${bidiCmd}' with params ${logParams} by passing to ${handlerType} ` +
|
|
93
|
+
`method '${command}'`);
|
|
94
|
+
// call the handler with the signature appropriate to extension type (plugin or driver)
|
|
95
|
+
const response = (next && driver) ? await this[command](next, driver, ...args) : await this[command](...args);
|
|
96
|
+
const finalResponse = lodash_1.default.isUndefined(response) ? {} : response;
|
|
97
|
+
this.log.debug(`Responding to bidi command '${bidiCmd}' with ` +
|
|
98
|
+
`${lodash_1.default.truncate(JSON.stringify(finalResponse), { length: constants_1.MAX_LOG_BODY_LENGTH })}`);
|
|
99
|
+
return finalResponse;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.ExtensionCore = ExtensionCore;
|
|
103
|
+
//# sourceMappingURL=extension-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-core.js","sourceRoot":"","sources":["../../../lib/basedriver/extension-core.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAuC;AACvC,6CAAyC;AAOzC,4CAEsB;AACtB,0CAAmC;AACnC,6DAAwD;AACxD,oDAAuB;AACvB,uCAAkD;AAElD,MAAa,aAAa;IASxB,YAAY,SAAkB;QAP9B,iBAAY,GAAkB,6BAA8B,CAAC;QAQ3D,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,0BAAY,EAAE,CAAC;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,EAAE,+BAAmB,EAAC,CAAC,EAAE,CAC9E,CAAC;QACF,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AA/GD,sCA+GC"}
|
|
@@ -30,12 +30,12 @@ export function parseCapsArray(cap: string | Array<string>): any[];
|
|
|
30
30
|
/**
|
|
31
31
|
* Generate a string that uniquely describes driver instance
|
|
32
32
|
*
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {object} obj driver instance
|
|
34
34
|
* @param {string?} [sessionId=null] session identifier (if exists).
|
|
35
35
|
* This parameter is deprecated and is not used.
|
|
36
36
|
* @returns {string}
|
|
37
37
|
*/
|
|
38
|
-
export function generateDriverLogPrefix(obj:
|
|
38
|
+
export function generateDriverLogPrefix(obj: object, sessionId?: string | null): string;
|
|
39
39
|
export const BASEDRIVER_VER: string;
|
|
40
40
|
declare const _default: {
|
|
41
41
|
configureApp: typeof configureApp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../lib/basedriver/helpers.js"],"names":[],"mappings":"AA+DA;;;;GAIG;AACH,kCAHW,MAAM,YACN,MAAM,GAAC,MAAM,EAAE,GAAC,OAAO,eAAe,EAAE,mBAAmB,gBAuQrE;AAED;;;GAGG;AACH,uCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,qCAJW,GAAC,4CA2BX;AAED;;;;;GAKG;AACH,oCAFW,MAAM,GAAC,KAAK,QAAQ,SAoB9B;AAED;;;;;;;GAOG;AAEH,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../lib/basedriver/helpers.js"],"names":[],"mappings":"AA+DA;;;;GAIG;AACH,kCAHW,MAAM,YACN,MAAM,GAAC,MAAM,EAAE,GAAC,OAAO,eAAe,EAAE,mBAAmB,gBAuQrE;AAED;;;GAGG;AACH,uCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,qCAJW,GAAC,4CA2BX;AAED;;;;;GAKG;AACH,oCAFW,MAAM,GAAC,KAAK,QAAQ,SAoB9B;AAED;;;;;;;GAOG;AAEH,6CANW,MAAM,cACN,MAAM,OAAC,GAEL,MAAM,CAKlB;;;;;;;;;;;kBAwTa,IAAI,OAAC;eACL,OAAO;YACP,MAAM,OAAC;UACP,MAAM,OAAC;;;;;;;;;YAKP,MAAM;;;;YACN,OAAO,QAAQ,EAAE,QAAQ;;;;aACzB,OAAO,OAAO,EAAE,uBAAuB,GAAG,OAAO,OAAO,EAAE,oBAAoB"}
|
|
@@ -379,7 +379,7 @@ function parseCapsArray(cap) {
|
|
|
379
379
|
/**
|
|
380
380
|
* Generate a string that uniquely describes driver instance
|
|
381
381
|
*
|
|
382
|
-
* @param {
|
|
382
|
+
* @param {object} obj driver instance
|
|
383
383
|
* @param {string?} [sessionId=null] session identifier (if exists).
|
|
384
384
|
* This parameter is deprecated and is not used.
|
|
385
385
|
* @returns {string}
|
package/build/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { ExtensionCore } from "./basedriver/extension-core";
|
|
1
2
|
export { DriverCore } from "./basedriver/core";
|
|
2
3
|
export { DeviceSettings } from "./basedriver/device-settings";
|
|
3
4
|
export { BaseDriver };
|
|
@@ -6,6 +7,7 @@ export * from "./protocol";
|
|
|
6
7
|
export { errorFromMJSONWPStatusCode as errorFromCode } from "./protocol";
|
|
7
8
|
export { STATIC_DIR } from "./express/static";
|
|
8
9
|
export { DEFAULT_WS_PATHNAME_PREFIX } from "./express/websocket";
|
|
10
|
+
export { generateDriverLogPrefix } from "./basedriver/helpers";
|
|
9
11
|
export type ServerOpts = import("./express/server").ServerOpts;
|
|
10
12
|
import { BaseDriver } from './basedriver/driver';
|
|
11
13
|
export { MAX_LOG_BODY_LENGTH, DEFAULT_BASE_PATH, PROTOCOLS, W3C_ELEMENT_KEY } from "./constants";
|
package/build/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";;;;;;;;;;yBAsDa,OAAO,kBAAkB,EAAE,UAAU;2BAzCzB,qBAAqB"}
|
package/build/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.DEFAULT_WS_PATHNAME_PREFIX = exports.promoteAppiumOptionsForObject = exports.promoteAppiumOptions = exports.validateCaps = exports.isStandardCap = exports.processCapabilities = exports.STANDARD_CAPS = exports.PREFIXED_APPIUM_OPTS_CAP = exports.statusCodes = exports.getSummaryByCode = exports.WebDriverProxy = exports.JWProxy = exports.normalizeBasePath = exports.server = exports.STATIC_DIR = exports.errorFromCode = exports.W3C_ELEMENT_KEY = exports.PROTOCOLS = exports.DEFAULT_BASE_PATH = exports.MAX_LOG_BODY_LENGTH = exports.BaseDriver = exports.DeviceSettings = exports.DriverCore = void 0;
|
|
20
|
+
exports.generateDriverLogPrefix = exports.DEFAULT_WS_PATHNAME_PREFIX = exports.promoteAppiumOptionsForObject = exports.promoteAppiumOptions = exports.validateCaps = exports.isStandardCap = exports.processCapabilities = exports.STANDARD_CAPS = exports.PREFIXED_APPIUM_OPTS_CAP = exports.statusCodes = exports.getSummaryByCode = exports.WebDriverProxy = exports.JWProxy = exports.normalizeBasePath = exports.server = exports.STATIC_DIR = exports.errorFromCode = exports.W3C_ELEMENT_KEY = exports.PROTOCOLS = exports.DEFAULT_BASE_PATH = exports.MAX_LOG_BODY_LENGTH = exports.BaseDriver = exports.DeviceSettings = exports.DriverCore = exports.ExtensionCore = void 0;
|
|
21
21
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
22
22
|
try {
|
|
23
23
|
bluebird_1.default.config({
|
|
@@ -29,6 +29,8 @@ catch {
|
|
|
29
29
|
// cancellation not being able to be enabled after promise has been configured
|
|
30
30
|
}
|
|
31
31
|
// BaseDriver exports
|
|
32
|
+
var extension_core_1 = require("./basedriver/extension-core");
|
|
33
|
+
Object.defineProperty(exports, "ExtensionCore", { enumerable: true, get: function () { return extension_core_1.ExtensionCore; } });
|
|
32
34
|
const driver_1 = require("./basedriver/driver");
|
|
33
35
|
Object.defineProperty(exports, "BaseDriver", { enumerable: true, get: function () { return driver_1.BaseDriver; } });
|
|
34
36
|
var core_1 = require("./basedriver/core");
|
|
@@ -73,6 +75,8 @@ Object.defineProperty(exports, "promoteAppiumOptionsForObject", { enumerable: tr
|
|
|
73
75
|
// Web socket helpers
|
|
74
76
|
var websocket_1 = require("./express/websocket");
|
|
75
77
|
Object.defineProperty(exports, "DEFAULT_WS_PATHNAME_PREFIX", { enumerable: true, get: function () { return websocket_1.DEFAULT_WS_PATHNAME_PREFIX; } });
|
|
78
|
+
var helpers_1 = require("./basedriver/helpers");
|
|
79
|
+
Object.defineProperty(exports, "generateDriverLogPrefix", { enumerable: true, get: function () { return helpers_1.generateDriverLogPrefix; } });
|
|
76
80
|
/**
|
|
77
81
|
* @typedef {import('./express/server').ServerOpts} ServerOpts
|
|
78
82
|
*/
|
package/build/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,wDAAyB;AAEzB,IAAI,CAAC;IACH,kBAAC,CAAC,MAAM,CAAC;QACP,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;AACL,CAAC;AAAC,MAAM,CAAC;IACP,0FAA0F;IAC1F,8EAA8E;AAChF,CAAC;AAED,qBAAqB;AACrB,gDAA+C;AAIvC,2FAJA,mBAAU,OAIA;AAHlB,0CAA6C;AAArC,kGAAA,UAAU,OAAA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U,OAIA;AAHlB,0CAA6C;AAArC,kGAAA,UAAU,OAAA;AAClB,gEAA4D;AAApD,iHAAA,cAAc,OAAA;AAGtB,kBAAe,mBAAU,CAAC;AAC1B,yCAA+F;AAAvF,gHAAA,mBAAmB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,4GAAA,eAAe,OAAA;AAE1E,kBAAkB;AAClB,6CAA2B;AAC3B,uCAAuE;AAA/D,yGAAA,0BAA0B,OAAiB;AAEnD,kBAAkB;AAClB,2CAA4C;AAApC,oGAAA,UAAU,OAAA;AAClB,2CAA2D;AAAnD,gGAAA,MAAM,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAEjC,uBAAuB;AACvB,sFAAsF;AACtF,8CAA6C;AAArC,gGAAA,OAAO,OAAA;AACf,8CAA+D;AAAvD,uGAAA,OAAO,OAAkB;AAEjC,wBAAwB;AACxB,iDAA8E;AAAtE,0GAAA,gBAAgB,OAAA;AAAE,qGAAA,KAAK,OAAe;AAE9C,0BAA0B;AAC1B,0DAQmC;AAPjC,wHAAA,wBAAwB,OAAA;AACxB,6GAAA,aAAa,OAAA;AACb,mHAAA,mBAAmB,OAAA;AACnB,6GAAA,aAAa,OAAA;AACb,4GAAA,YAAY,OAAA;AACZ,oHAAA,oBAAoB,OAAA;AACpB,6HAAA,6BAA6B,OAAA;AAG/B,qBAAqB;AACrB,iDAA+D;AAAvD,uHAAA,0BAA0B,OAAA;AAElC,gDAA6D;AAArD,kHAAA,uBAAuB,OAAA;AAE/B;;GAEG"}
|
package/lib/basedriver/core.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {logger} from '@appium/support';
|
|
2
1
|
import type {
|
|
3
2
|
AppiumLogger,
|
|
4
3
|
Constraints,
|
|
@@ -11,22 +10,18 @@ import type {
|
|
|
11
10
|
Protocol,
|
|
12
11
|
RouteMatcher,
|
|
13
12
|
StringRecord,
|
|
14
|
-
BidiModuleMap,
|
|
15
|
-
BiDiResultData,
|
|
16
13
|
} from '@appium/types';
|
|
17
14
|
import AsyncLock from 'async-lock';
|
|
18
15
|
import _ from 'lodash';
|
|
19
|
-
import {EventEmitter} from 'node:events';
|
|
20
16
|
import os from 'node:os';
|
|
21
17
|
import {
|
|
22
18
|
DEFAULT_BASE_PATH,
|
|
23
19
|
PROTOCOLS,
|
|
24
|
-
MAX_LOG_BODY_LENGTH,
|
|
25
20
|
} from '../constants';
|
|
26
21
|
import {errors} from '../protocol';
|
|
27
22
|
import {DeviceSettings} from './device-settings';
|
|
28
23
|
import * as helpers from './helpers';
|
|
29
|
-
import {
|
|
24
|
+
import {ExtensionCore} from './extension-core';
|
|
30
25
|
|
|
31
26
|
const NEW_COMMAND_TIMEOUT_MS = 60 * 1000;
|
|
32
27
|
|
|
@@ -36,7 +31,7 @@ const ALL_DRIVERS_MATCH = '*';
|
|
|
36
31
|
const FEATURE_NAME_SEPARATOR = ':';
|
|
37
32
|
|
|
38
33
|
export class DriverCore<const C extends Constraints, Settings extends StringRecord = StringRecord>
|
|
39
|
-
implements Core<C, Settings>
|
|
34
|
+
extends ExtensionCore implements Core<C, Settings>
|
|
40
35
|
{
|
|
41
36
|
/**
|
|
42
37
|
* Make the basedriver version available so for any driver which inherits from this package, we
|
|
@@ -82,11 +77,8 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
|
|
|
82
77
|
|
|
83
78
|
protected _eventHistory: EventHistory;
|
|
84
79
|
|
|
85
|
-
// used to handle driver events
|
|
86
|
-
eventEmitter: NodeJS.EventEmitter;
|
|
87
|
-
|
|
88
80
|
/**
|
|
89
|
-
*
|
|
81
|
+
* TODO: remove this._log and use this.log instead
|
|
90
82
|
*/
|
|
91
83
|
protected _log: AppiumLogger;
|
|
92
84
|
|
|
@@ -106,14 +98,10 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
|
|
|
106
98
|
|
|
107
99
|
protocol?: Protocol;
|
|
108
100
|
|
|
109
|
-
bidiEventSubs: Record<string, string[]>;
|
|
110
|
-
|
|
111
|
-
doesSupportBidi: boolean;
|
|
112
|
-
|
|
113
|
-
bidiCommands: BidiModuleMap = BIDI_COMMANDS as BidiModuleMap;
|
|
114
|
-
|
|
115
101
|
constructor(opts: InitialOpts = <InitialOpts>{}, shouldValidateCaps = true) {
|
|
116
|
-
|
|
102
|
+
super();
|
|
103
|
+
this._log = this.log; // TODO: remove references to this._log and use this.log instead
|
|
104
|
+
|
|
117
105
|
|
|
118
106
|
// setup state
|
|
119
107
|
this.opts = opts as DriverOpts<C>;
|
|
@@ -141,16 +129,9 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
|
|
|
141
129
|
this.managedDrivers = [];
|
|
142
130
|
this.noCommandTimer = null;
|
|
143
131
|
this._eventHistory = {commands: []};
|
|
144
|
-
this.eventEmitter = new EventEmitter();
|
|
145
132
|
this.shutdownUnexpectedly = false;
|
|
146
133
|
this.commandsQueueGuard = new AsyncLock();
|
|
147
134
|
this.settings = new DeviceSettings();
|
|
148
|
-
this.bidiEventSubs = {};
|
|
149
|
-
this.doesSupportBidi = false;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
get log() {
|
|
153
|
-
return this._log;
|
|
154
135
|
}
|
|
155
136
|
|
|
156
137
|
/**
|
|
@@ -433,75 +414,4 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
|
|
|
433
414
|
}
|
|
434
415
|
}
|
|
435
416
|
|
|
436
|
-
updateBidiCommands(cmds: BidiModuleMap): void {
|
|
437
|
-
const overlappingKeys = _.intersection(Object.keys(cmds), Object.keys(this.bidiCommands));
|
|
438
|
-
if (overlappingKeys.length) {
|
|
439
|
-
this.log.warn(`Overwriting existing bidi modules: ${JSON.stringify(overlappingKeys)}. This may not be intended!`);
|
|
440
|
-
}
|
|
441
|
-
this.bidiCommands = {
|
|
442
|
-
...this.bidiCommands,
|
|
443
|
-
...cmds,
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
async executeBidiCommand(bidiCmd: string, bidiParams: StringRecord): Promise<BiDiResultData> {
|
|
448
|
-
const [moduleName, methodName] = bidiCmd.split('.');
|
|
449
|
-
|
|
450
|
-
// if we don't get a valid format for bidi command name, reject
|
|
451
|
-
if (!moduleName || !methodName) {
|
|
452
|
-
throw new errors.UnknownCommandError(
|
|
453
|
-
`Did not receive a valid BiDi module and method name ` +
|
|
454
|
-
`of the form moduleName.methodName. Instead received ` +
|
|
455
|
-
`'${moduleName}.${methodName}'`,
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
// if the command module or method isn't part of our spec, reject
|
|
461
|
-
if (!this.bidiCommands[moduleName] || !this.bidiCommands[moduleName][methodName]) {
|
|
462
|
-
throw new errors.UnknownCommandError();
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
const {command, params} = this.bidiCommands[moduleName][methodName];
|
|
466
|
-
// if the command method isn't part of our spec, also reject
|
|
467
|
-
if (!command) {
|
|
468
|
-
throw new errors.UnknownCommandError();
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// If the driver doesn't have this command, it must not be implemented
|
|
472
|
-
if (!this[command]) {
|
|
473
|
-
throw new errors.NotYetImplementedError();
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// TODO improve param parsing and error messages along the lines of what we have in the http
|
|
477
|
-
// handlers
|
|
478
|
-
const args: any[] = [];
|
|
479
|
-
if (params?.required?.length) {
|
|
480
|
-
for (const requiredParam of params.required) {
|
|
481
|
-
if (_.isUndefined(bidiParams[requiredParam])) {
|
|
482
|
-
throw new errors.InvalidArgumentError(
|
|
483
|
-
`The ${requiredParam} parameter was required but you omitted it`,
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
args.push(bidiParams[requiredParam]);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
if (params?.optional?.length) {
|
|
490
|
-
for (const optionalParam of params.optional) {
|
|
491
|
-
args.push(bidiParams[optionalParam]);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
const logParams = _.truncate(JSON.stringify(bidiParams), {length: MAX_LOG_BODY_LENGTH});
|
|
495
|
-
this.log.debug(
|
|
496
|
-
`Executing bidi command '${bidiCmd}' with params ${logParams} by passing to driver ` +
|
|
497
|
-
`method '${command}'`,
|
|
498
|
-
);
|
|
499
|
-
const response = await this[command](...args);
|
|
500
|
-
const finalResponse = _.isUndefined(response) ? {} : response;
|
|
501
|
-
this.log.debug(
|
|
502
|
-
`Responding to bidi command '${bidiCmd}' with ` +
|
|
503
|
-
`${_.truncate(JSON.stringify(finalResponse), {length: MAX_LOG_BODY_LENGTH})}`
|
|
504
|
-
);
|
|
505
|
-
return finalResponse;
|
|
506
|
-
}
|
|
507
417
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {logger} from '@appium/support';
|
|
2
|
+
import {EventEmitter} from 'node:events';
|
|
3
|
+
import type {
|
|
4
|
+
AppiumLogger,
|
|
5
|
+
BidiModuleMap,
|
|
6
|
+
BiDiResultData,
|
|
7
|
+
StringRecord,
|
|
8
|
+
} from '@appium/types';
|
|
9
|
+
import {
|
|
10
|
+
MAX_LOG_BODY_LENGTH,
|
|
11
|
+
} from '../constants';
|
|
12
|
+
import {errors} from '../protocol';
|
|
13
|
+
import {BIDI_COMMANDS} from '../protocol/bidi-commands';
|
|
14
|
+
import _ from 'lodash';
|
|
15
|
+
import {generateDriverLogPrefix} from './helpers';
|
|
16
|
+
|
|
17
|
+
export class ExtensionCore {
|
|
18
|
+
bidiEventSubs: Record<string, string[]>;
|
|
19
|
+
bidiCommands: BidiModuleMap = BIDI_COMMANDS as BidiModuleMap;
|
|
20
|
+
_logPrefix?: string;
|
|
21
|
+
protected _log: AppiumLogger;
|
|
22
|
+
// used to handle driver events
|
|
23
|
+
readonly eventEmitter: NodeJS.EventEmitter;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
constructor(logPrefix?: string) {
|
|
27
|
+
this._logPrefix = logPrefix;
|
|
28
|
+
this.bidiEventSubs = {};
|
|
29
|
+
this.eventEmitter = new EventEmitter();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get log(): AppiumLogger {
|
|
33
|
+
if (!this._log) {
|
|
34
|
+
this.updateLogPrefix(this._logPrefix ?? generateDriverLogPrefix(this));
|
|
35
|
+
}
|
|
36
|
+
return this._log;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
updateLogPrefix(logPrefix: string) {
|
|
40
|
+
this._log = logger.getLogger(logPrefix);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
updateBidiCommands(cmds: BidiModuleMap): void {
|
|
44
|
+
const overlappingKeys = _.intersection(Object.keys(cmds), Object.keys(this.bidiCommands));
|
|
45
|
+
if (overlappingKeys.length) {
|
|
46
|
+
this.log.warn(`Overwriting existing bidi modules: ${JSON.stringify(overlappingKeys)}. This may not be intended!`);
|
|
47
|
+
}
|
|
48
|
+
this.bidiCommands = {
|
|
49
|
+
...this.bidiCommands,
|
|
50
|
+
...cmds,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
doesBidiCommandExist(moduleName: string, methodName: string): boolean {
|
|
55
|
+
try {
|
|
56
|
+
this.ensureBidiCommandExists(moduleName, methodName);
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ensureBidiCommandExists(moduleName: string, methodName: string): void {
|
|
64
|
+
// if we don't get a valid format for bidi command name, reject
|
|
65
|
+
if (!moduleName || !methodName) {
|
|
66
|
+
throw new errors.UnknownCommandError(
|
|
67
|
+
`Did not receive a valid BiDi module and method name ` +
|
|
68
|
+
`of the form moduleName.methodName. Instead received ` +
|
|
69
|
+
`'${moduleName}.${methodName}'`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// if the command module or method isn't part of our spec, reject
|
|
74
|
+
if (!this.bidiCommands[moduleName] || !this.bidiCommands[moduleName][methodName]) {
|
|
75
|
+
throw new errors.UnknownCommandError();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const {command} = this.bidiCommands[moduleName][methodName];
|
|
79
|
+
// if the command method isn't part of our spec, also reject
|
|
80
|
+
if (!command) {
|
|
81
|
+
throw new errors.UnknownCommandError();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// If the driver doesn't have this command, it must not be implemented
|
|
85
|
+
if (!this[command]) {
|
|
86
|
+
throw new errors.NotYetImplementedError();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async executeBidiCommand(bidiCmd: string, bidiParams: StringRecord, next?: () => Promise<any>, driver?: ExtensionCore): Promise<BiDiResultData> {
|
|
91
|
+
const handlerType = (next && driver) ? 'plugin' : 'driver';
|
|
92
|
+
const [moduleName, methodName] = bidiCmd.split('.');
|
|
93
|
+
this.ensureBidiCommandExists(moduleName, methodName);
|
|
94
|
+
const {command, params} = this.bidiCommands[moduleName][methodName];
|
|
95
|
+
|
|
96
|
+
// TODO improve param parsing and error messages along the lines of what we have in the http
|
|
97
|
+
// handlers
|
|
98
|
+
const args: any[] = [];
|
|
99
|
+
if (params?.required?.length) {
|
|
100
|
+
for (const requiredParam of params.required) {
|
|
101
|
+
if (_.isUndefined(bidiParams[requiredParam])) {
|
|
102
|
+
throw new errors.InvalidArgumentError(
|
|
103
|
+
`The ${requiredParam} parameter was required but you omitted it`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
args.push(bidiParams[requiredParam]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (params?.optional?.length) {
|
|
110
|
+
for (const optionalParam of params.optional) {
|
|
111
|
+
args.push(bidiParams[optionalParam]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const logParams = _.truncate(JSON.stringify(bidiParams), {length: MAX_LOG_BODY_LENGTH});
|
|
115
|
+
this.log.debug(
|
|
116
|
+
`Executing bidi command '${bidiCmd}' with params ${logParams} by passing to ${handlerType} ` +
|
|
117
|
+
`method '${command}'`,
|
|
118
|
+
);
|
|
119
|
+
// call the handler with the signature appropriate to extension type (plugin or driver)
|
|
120
|
+
const response = (next && driver) ? await this[command](next, driver, ...args) : await this[command](...args);
|
|
121
|
+
const finalResponse = _.isUndefined(response) ? {} : response;
|
|
122
|
+
this.log.debug(
|
|
123
|
+
`Responding to bidi command '${bidiCmd}' with ` +
|
|
124
|
+
`${_.truncate(JSON.stringify(finalResponse), {length: MAX_LOG_BODY_LENGTH})}`
|
|
125
|
+
);
|
|
126
|
+
return finalResponse;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -401,7 +401,7 @@ export function parseCapsArray(cap) {
|
|
|
401
401
|
/**
|
|
402
402
|
* Generate a string that uniquely describes driver instance
|
|
403
403
|
*
|
|
404
|
-
* @param {
|
|
404
|
+
* @param {object} obj driver instance
|
|
405
405
|
* @param {string?} [sessionId=null] session identifier (if exists).
|
|
406
406
|
* This parameter is deprecated and is not used.
|
|
407
407
|
* @returns {string}
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ try {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
// BaseDriver exports
|
|
13
|
+
export {ExtensionCore} from './basedriver/extension-core';
|
|
13
14
|
import {BaseDriver} from './basedriver/driver';
|
|
14
15
|
export {DriverCore} from './basedriver/core';
|
|
15
16
|
export {DeviceSettings} from './basedriver/device-settings';
|
|
@@ -48,6 +49,8 @@ export {
|
|
|
48
49
|
// Web socket helpers
|
|
49
50
|
export {DEFAULT_WS_PATHNAME_PREFIX} from './express/websocket';
|
|
50
51
|
|
|
52
|
+
export {generateDriverLogPrefix} from './basedriver/helpers';
|
|
53
|
+
|
|
51
54
|
/**
|
|
52
55
|
* @typedef {import('./express/server').ServerOpts} ServerOpts
|
|
53
56
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/base-driver",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.15.0",
|
|
4
4
|
"description": "Base driver class for Appium drivers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"test:types": "tsd"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@appium/support": "^6.0.
|
|
48
|
-
"@appium/types": "^0.
|
|
47
|
+
"@appium/support": "^6.0.3",
|
|
48
|
+
"@appium/types": "^0.24.0",
|
|
49
49
|
"@colors/colors": "1.6.0",
|
|
50
50
|
"@types/async-lock": "1.4.2",
|
|
51
51
|
"@types/bluebird": "3.5.42",
|
|
52
52
|
"@types/express": "5.0.0",
|
|
53
|
-
"@types/lodash": "4.17.
|
|
53
|
+
"@types/lodash": "4.17.14",
|
|
54
54
|
"@types/method-override": "3.0.0",
|
|
55
55
|
"@types/serve-favicon": "2.5.7",
|
|
56
56
|
"async-lock": "1.4.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "a7ce83e169e101ae497bab11204a73703fd54e99",
|
|
84
84
|
"tsd": {
|
|
85
85
|
"directory": "test/types"
|
|
86
86
|
}
|