@midscene/ios 1.0.1-beta-20251029093754.0 → 1.0.1-beta-20251103074550.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/dist/es/bin.mjs +99 -17
- package/dist/es/index.mjs +99 -17
- package/dist/lib/bin.js +99 -17
- package/dist/lib/index.js +99 -17
- package/dist/types/index.d.ts +85 -1
- package/package.json +6 -5
- package/static/index.html +1 -1
- package/static/static/js/index.44fb18ac.js +19 -0
- package/static/static/js/index.44fb18ac.js.map +1 -0
- package/static/static/js/index.846ec190.js +0 -19
- package/static/static/js/index.846ec190.js.map +0 -1
- /package/static/static/js/{index.846ec190.js.LICENSE.txt → index.44fb18ac.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -11999,6 +11999,49 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
11999
11999
|
debugIOS(`Warning: Key "${key}" is not supported on iOS platform`);
|
|
12000
12000
|
throw new Error(`Key "${key}" is not supported on iOS platform`);
|
|
12001
12001
|
}
|
|
12002
|
+
async getActiveElement() {
|
|
12003
|
+
this.ensureSession();
|
|
12004
|
+
debugIOS('Getting active element');
|
|
12005
|
+
try {
|
|
12006
|
+
var _response_value, _response_value1;
|
|
12007
|
+
const response = await this.makeRequest('GET', `/session/${this.sessionId}/element/active`);
|
|
12008
|
+
const elementId = (null == (_response_value = response.value) ? void 0 : _response_value.ELEMENT) || (null == (_response_value1 = response.value) ? void 0 : _response_value1['element-6066-11e4-a52e-4f735466cecf']) || response.ELEMENT || response['element-6066-11e4-a52e-4f735466cecf'];
|
|
12009
|
+
if (elementId) {
|
|
12010
|
+
debugIOS(`Got active element ID: ${elementId}`);
|
|
12011
|
+
return elementId;
|
|
12012
|
+
}
|
|
12013
|
+
debugIOS('No active element found');
|
|
12014
|
+
return null;
|
|
12015
|
+
} catch (error) {
|
|
12016
|
+
debugIOS(`Failed to get active element: ${error}`);
|
|
12017
|
+
return null;
|
|
12018
|
+
}
|
|
12019
|
+
}
|
|
12020
|
+
async clearElement(elementId) {
|
|
12021
|
+
this.ensureSession();
|
|
12022
|
+
debugIOS(`Clearing element: ${elementId}`);
|
|
12023
|
+
try {
|
|
12024
|
+
await this.makeRequest('POST', `/session/${this.sessionId}/element/${elementId}/clear`);
|
|
12025
|
+
debugIOS('Element cleared successfully');
|
|
12026
|
+
} catch (error) {
|
|
12027
|
+
debugIOS(`Failed to clear element: ${error}`);
|
|
12028
|
+
throw new Error(`Failed to clear element: ${error}`);
|
|
12029
|
+
}
|
|
12030
|
+
}
|
|
12031
|
+
async clearActiveElement() {
|
|
12032
|
+
try {
|
|
12033
|
+
const elementId = await this.getActiveElement();
|
|
12034
|
+
if (!elementId) {
|
|
12035
|
+
debugIOS('No active element to clear');
|
|
12036
|
+
return false;
|
|
12037
|
+
}
|
|
12038
|
+
await this.clearElement(elementId);
|
|
12039
|
+
return true;
|
|
12040
|
+
} catch (error) {
|
|
12041
|
+
debugIOS(`Failed to clear active element: ${error}`);
|
|
12042
|
+
return false;
|
|
12043
|
+
}
|
|
12044
|
+
}
|
|
12002
12045
|
normalizeKeyName(key) {
|
|
12003
12046
|
return key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
|
|
12004
12047
|
}
|
|
@@ -12146,6 +12189,10 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
12146
12189
|
debugIOS(`Failed to apply iOS session configuration: ${error}`);
|
|
12147
12190
|
}
|
|
12148
12191
|
}
|
|
12192
|
+
async executeRequest(method, endpoint, data) {
|
|
12193
|
+
this.ensureSession();
|
|
12194
|
+
return this.makeRequest(method, endpoint, data);
|
|
12195
|
+
}
|
|
12149
12196
|
}
|
|
12150
12197
|
function device_define_property(obj, key, value) {
|
|
12151
12198
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -12158,7 +12205,12 @@ function device_define_property(obj, key, value) {
|
|
|
12158
12205
|
return obj;
|
|
12159
12206
|
}
|
|
12160
12207
|
const debugDevice = getDebug('ios:device');
|
|
12161
|
-
const
|
|
12208
|
+
const WDA_HTTP_METHODS = [
|
|
12209
|
+
'GET',
|
|
12210
|
+
'POST',
|
|
12211
|
+
'DELETE',
|
|
12212
|
+
'PUT'
|
|
12213
|
+
];
|
|
12162
12214
|
class device_IOSDevice {
|
|
12163
12215
|
actionSpace() {
|
|
12164
12216
|
const defaultActions = [
|
|
@@ -12267,9 +12319,11 @@ class device_IOSDevice {
|
|
|
12267
12319
|
await this.clearInput(element);
|
|
12268
12320
|
})
|
|
12269
12321
|
];
|
|
12322
|
+
const platformSpecificActions = Object.values(createPlatformActions(this));
|
|
12270
12323
|
const customActions = this.customActions || [];
|
|
12271
12324
|
return [
|
|
12272
12325
|
...defaultActions,
|
|
12326
|
+
...platformSpecificActions,
|
|
12273
12327
|
...customActions
|
|
12274
12328
|
];
|
|
12275
12329
|
}
|
|
@@ -12367,19 +12421,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12367
12421
|
if (!element) return;
|
|
12368
12422
|
await this.tap(element.center[0], element.center[1]);
|
|
12369
12423
|
await sleep(100);
|
|
12370
|
-
|
|
12371
|
-
|
|
12372
|
-
|
|
12373
|
-
await this.wdaBackend.typeText(BackspaceChar);
|
|
12374
|
-
} catch (error2) {
|
|
12375
|
-
debugDevice(`Method 1 failed, trying method 2: ${error2}`);
|
|
12376
|
-
try {
|
|
12377
|
-
const backspaces = Array(100).fill(BackspaceChar).join('');
|
|
12378
|
-
await this.wdaBackend.typeText(backspaces);
|
|
12379
|
-
} catch (error3) {
|
|
12380
|
-
debugDevice(`All clear methods failed: ${error3}`);
|
|
12381
|
-
}
|
|
12382
|
-
}
|
|
12424
|
+
debugDevice('Attempting to clear input with WebDriver Clear API');
|
|
12425
|
+
const cleared = await this.wdaBackend.clearActiveElement();
|
|
12426
|
+
cleared ? debugDevice('Successfully cleared input with WebDriver Clear API') : debugDevice('WebDriver Clear API returned false (no active element or clear failed)');
|
|
12383
12427
|
}
|
|
12384
12428
|
async url() {
|
|
12385
12429
|
return '';
|
|
@@ -12667,6 +12711,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12667
12711
|
throw new Error(`Failed to open URL via Safari: ${error}`);
|
|
12668
12712
|
}
|
|
12669
12713
|
}
|
|
12714
|
+
async runWdaRequest(method, endpoint, data) {
|
|
12715
|
+
return await this.wdaBackend.executeRequest(method, endpoint, data);
|
|
12716
|
+
}
|
|
12670
12717
|
async destroy() {
|
|
12671
12718
|
if (this.destroyed) return;
|
|
12672
12719
|
try {
|
|
@@ -12702,13 +12749,48 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12702
12749
|
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost);
|
|
12703
12750
|
}
|
|
12704
12751
|
}
|
|
12752
|
+
const runWdaRequestParamSchema = z.object({
|
|
12753
|
+
method: z["enum"](WDA_HTTP_METHODS).describe('HTTP method (GET, POST, DELETE, PUT)'),
|
|
12754
|
+
endpoint: z.string().describe('WebDriver API endpoint'),
|
|
12755
|
+
data: z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
12756
|
+
});
|
|
12757
|
+
const launchParamSchema = z.string().describe('App bundle ID or URL to launch');
|
|
12758
|
+
const createPlatformActions = (device)=>({
|
|
12759
|
+
RunWdaRequest: defineAction({
|
|
12760
|
+
name: 'RunWdaRequest',
|
|
12761
|
+
description: 'Execute WebDriverAgent API request directly on iOS device',
|
|
12762
|
+
interfaceAlias: 'runWdaRequest',
|
|
12763
|
+
paramSchema: runWdaRequestParamSchema,
|
|
12764
|
+
call: async (param)=>await device.runWdaRequest(param.method, param.endpoint, param.data)
|
|
12765
|
+
}),
|
|
12766
|
+
Launch: defineAction({
|
|
12767
|
+
name: 'Launch',
|
|
12768
|
+
description: 'Launch an iOS app or URL',
|
|
12769
|
+
interfaceAlias: 'launch',
|
|
12770
|
+
paramSchema: launchParamSchema,
|
|
12771
|
+
call: async (param)=>{
|
|
12772
|
+
await device.launch(param);
|
|
12773
|
+
}
|
|
12774
|
+
})
|
|
12775
|
+
});
|
|
12705
12776
|
promisify(exec);
|
|
12706
12777
|
getDebug('ios:utils');
|
|
12778
|
+
function agent_define_property(obj, key, value) {
|
|
12779
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
12780
|
+
value: value,
|
|
12781
|
+
enumerable: true,
|
|
12782
|
+
configurable: true,
|
|
12783
|
+
writable: true
|
|
12784
|
+
});
|
|
12785
|
+
else obj[key] = value;
|
|
12786
|
+
return obj;
|
|
12787
|
+
}
|
|
12707
12788
|
getDebug('ios:agent');
|
|
12708
12789
|
class IOSAgent extends Agent {
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12790
|
+
constructor(device, opts){
|
|
12791
|
+
super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runWdaRequest", void 0);
|
|
12792
|
+
this.launch = this.wrapActionInActionSpace('Launch');
|
|
12793
|
+
this.runWdaRequest = this.wrapActionInActionSpace('RunWdaRequest');
|
|
12712
12794
|
}
|
|
12713
12795
|
}
|
|
12714
12796
|
async function isPortAvailable(port) {
|
package/dist/es/index.mjs
CHANGED
|
@@ -150,6 +150,49 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
150
150
|
debugIOS(`Warning: Key "${key}" is not supported on iOS platform`);
|
|
151
151
|
throw new Error(`Key "${key}" is not supported on iOS platform`);
|
|
152
152
|
}
|
|
153
|
+
async getActiveElement() {
|
|
154
|
+
this.ensureSession();
|
|
155
|
+
debugIOS('Getting active element');
|
|
156
|
+
try {
|
|
157
|
+
var _response_value, _response_value1;
|
|
158
|
+
const response = await this.makeRequest('GET', `/session/${this.sessionId}/element/active`);
|
|
159
|
+
const elementId = (null == (_response_value = response.value) ? void 0 : _response_value.ELEMENT) || (null == (_response_value1 = response.value) ? void 0 : _response_value1['element-6066-11e4-a52e-4f735466cecf']) || response.ELEMENT || response['element-6066-11e4-a52e-4f735466cecf'];
|
|
160
|
+
if (elementId) {
|
|
161
|
+
debugIOS(`Got active element ID: ${elementId}`);
|
|
162
|
+
return elementId;
|
|
163
|
+
}
|
|
164
|
+
debugIOS('No active element found');
|
|
165
|
+
return null;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
debugIOS(`Failed to get active element: ${error}`);
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async clearElement(elementId) {
|
|
172
|
+
this.ensureSession();
|
|
173
|
+
debugIOS(`Clearing element: ${elementId}`);
|
|
174
|
+
try {
|
|
175
|
+
await this.makeRequest('POST', `/session/${this.sessionId}/element/${elementId}/clear`);
|
|
176
|
+
debugIOS('Element cleared successfully');
|
|
177
|
+
} catch (error) {
|
|
178
|
+
debugIOS(`Failed to clear element: ${error}`);
|
|
179
|
+
throw new Error(`Failed to clear element: ${error}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async clearActiveElement() {
|
|
183
|
+
try {
|
|
184
|
+
const elementId = await this.getActiveElement();
|
|
185
|
+
if (!elementId) {
|
|
186
|
+
debugIOS('No active element to clear');
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
await this.clearElement(elementId);
|
|
190
|
+
return true;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
debugIOS(`Failed to clear active element: ${error}`);
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
153
196
|
normalizeKeyName(key) {
|
|
154
197
|
return key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
|
|
155
198
|
}
|
|
@@ -297,6 +340,10 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
297
340
|
debugIOS(`Failed to apply iOS session configuration: ${error}`);
|
|
298
341
|
}
|
|
299
342
|
}
|
|
343
|
+
async executeRequest(method, endpoint, data) {
|
|
344
|
+
this.ensureSession();
|
|
345
|
+
return this.makeRequest(method, endpoint, data);
|
|
346
|
+
}
|
|
300
347
|
}
|
|
301
348
|
function _define_property(obj, key, value) {
|
|
302
349
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -309,7 +356,12 @@ function _define_property(obj, key, value) {
|
|
|
309
356
|
return obj;
|
|
310
357
|
}
|
|
311
358
|
const debugDevice = getDebug('ios:device');
|
|
312
|
-
const
|
|
359
|
+
const WDA_HTTP_METHODS = [
|
|
360
|
+
'GET',
|
|
361
|
+
'POST',
|
|
362
|
+
'DELETE',
|
|
363
|
+
'PUT'
|
|
364
|
+
];
|
|
313
365
|
class IOSDevice {
|
|
314
366
|
actionSpace() {
|
|
315
367
|
const defaultActions = [
|
|
@@ -418,9 +470,11 @@ class IOSDevice {
|
|
|
418
470
|
await this.clearInput(element);
|
|
419
471
|
})
|
|
420
472
|
];
|
|
473
|
+
const platformSpecificActions = Object.values(createPlatformActions(this));
|
|
421
474
|
const customActions = this.customActions || [];
|
|
422
475
|
return [
|
|
423
476
|
...defaultActions,
|
|
477
|
+
...platformSpecificActions,
|
|
424
478
|
...customActions
|
|
425
479
|
];
|
|
426
480
|
}
|
|
@@ -518,19 +572,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
518
572
|
if (!element) return;
|
|
519
573
|
await this.tap(element.center[0], element.center[1]);
|
|
520
574
|
await sleep(100);
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
await this.wdaBackend.typeText(BackspaceChar);
|
|
525
|
-
} catch (error2) {
|
|
526
|
-
debugDevice(`Method 1 failed, trying method 2: ${error2}`);
|
|
527
|
-
try {
|
|
528
|
-
const backspaces = Array(100).fill(BackspaceChar).join('');
|
|
529
|
-
await this.wdaBackend.typeText(backspaces);
|
|
530
|
-
} catch (error3) {
|
|
531
|
-
debugDevice(`All clear methods failed: ${error3}`);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
575
|
+
debugDevice('Attempting to clear input with WebDriver Clear API');
|
|
576
|
+
const cleared = await this.wdaBackend.clearActiveElement();
|
|
577
|
+
cleared ? debugDevice('Successfully cleared input with WebDriver Clear API') : debugDevice('WebDriver Clear API returned false (no active element or clear failed)');
|
|
534
578
|
}
|
|
535
579
|
async url() {
|
|
536
580
|
return '';
|
|
@@ -818,6 +862,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
818
862
|
throw new Error(`Failed to open URL via Safari: ${error}`);
|
|
819
863
|
}
|
|
820
864
|
}
|
|
865
|
+
async runWdaRequest(method, endpoint, data) {
|
|
866
|
+
return await this.wdaBackend.executeRequest(method, endpoint, data);
|
|
867
|
+
}
|
|
821
868
|
async destroy() {
|
|
822
869
|
if (this.destroyed) return;
|
|
823
870
|
try {
|
|
@@ -853,6 +900,30 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
853
900
|
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost);
|
|
854
901
|
}
|
|
855
902
|
}
|
|
903
|
+
const runWdaRequestParamSchema = z.object({
|
|
904
|
+
method: z["enum"](WDA_HTTP_METHODS).describe('HTTP method (GET, POST, DELETE, PUT)'),
|
|
905
|
+
endpoint: z.string().describe('WebDriver API endpoint'),
|
|
906
|
+
data: z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
907
|
+
});
|
|
908
|
+
const launchParamSchema = z.string().describe('App bundle ID or URL to launch');
|
|
909
|
+
const createPlatformActions = (device)=>({
|
|
910
|
+
RunWdaRequest: defineAction({
|
|
911
|
+
name: 'RunWdaRequest',
|
|
912
|
+
description: 'Execute WebDriverAgent API request directly on iOS device',
|
|
913
|
+
interfaceAlias: 'runWdaRequest',
|
|
914
|
+
paramSchema: runWdaRequestParamSchema,
|
|
915
|
+
call: async (param)=>await device.runWdaRequest(param.method, param.endpoint, param.data)
|
|
916
|
+
}),
|
|
917
|
+
Launch: defineAction({
|
|
918
|
+
name: 'Launch',
|
|
919
|
+
description: 'Launch an iOS app or URL',
|
|
920
|
+
interfaceAlias: 'launch',
|
|
921
|
+
paramSchema: launchParamSchema,
|
|
922
|
+
call: async (param)=>{
|
|
923
|
+
await device.launch(param);
|
|
924
|
+
}
|
|
925
|
+
})
|
|
926
|
+
});
|
|
856
927
|
const execAsync = promisify(exec);
|
|
857
928
|
const debugUtils = getDebug('ios:utils');
|
|
858
929
|
function checkMacOSPlatform() {
|
|
@@ -899,11 +970,22 @@ async function checkIOSEnvironment() {
|
|
|
899
970
|
};
|
|
900
971
|
}
|
|
901
972
|
}
|
|
973
|
+
function agent_define_property(obj, key, value) {
|
|
974
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
975
|
+
value: value,
|
|
976
|
+
enumerable: true,
|
|
977
|
+
configurable: true,
|
|
978
|
+
writable: true
|
|
979
|
+
});
|
|
980
|
+
else obj[key] = value;
|
|
981
|
+
return obj;
|
|
982
|
+
}
|
|
902
983
|
const debugAgent = getDebug('ios:agent');
|
|
903
984
|
class IOSAgent extends Agent {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
985
|
+
constructor(device, opts){
|
|
986
|
+
super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runWdaRequest", void 0);
|
|
987
|
+
this.launch = this.wrapActionInActionSpace('Launch');
|
|
988
|
+
this.runWdaRequest = this.wrapActionInActionSpace('RunWdaRequest');
|
|
907
989
|
}
|
|
908
990
|
}
|
|
909
991
|
async function agentFromWebDriverAgent(opts) {
|
package/dist/lib/bin.js
CHANGED
|
@@ -12137,6 +12137,49 @@ var __webpack_exports__ = {};
|
|
|
12137
12137
|
debugIOS(`Warning: Key "${key}" is not supported on iOS platform`);
|
|
12138
12138
|
throw new Error(`Key "${key}" is not supported on iOS platform`);
|
|
12139
12139
|
}
|
|
12140
|
+
async getActiveElement() {
|
|
12141
|
+
this.ensureSession();
|
|
12142
|
+
debugIOS('Getting active element');
|
|
12143
|
+
try {
|
|
12144
|
+
var _response_value, _response_value1;
|
|
12145
|
+
const response = await this.makeRequest('GET', `/session/${this.sessionId}/element/active`);
|
|
12146
|
+
const elementId = (null == (_response_value = response.value) ? void 0 : _response_value.ELEMENT) || (null == (_response_value1 = response.value) ? void 0 : _response_value1['element-6066-11e4-a52e-4f735466cecf']) || response.ELEMENT || response['element-6066-11e4-a52e-4f735466cecf'];
|
|
12147
|
+
if (elementId) {
|
|
12148
|
+
debugIOS(`Got active element ID: ${elementId}`);
|
|
12149
|
+
return elementId;
|
|
12150
|
+
}
|
|
12151
|
+
debugIOS('No active element found');
|
|
12152
|
+
return null;
|
|
12153
|
+
} catch (error) {
|
|
12154
|
+
debugIOS(`Failed to get active element: ${error}`);
|
|
12155
|
+
return null;
|
|
12156
|
+
}
|
|
12157
|
+
}
|
|
12158
|
+
async clearElement(elementId) {
|
|
12159
|
+
this.ensureSession();
|
|
12160
|
+
debugIOS(`Clearing element: ${elementId}`);
|
|
12161
|
+
try {
|
|
12162
|
+
await this.makeRequest('POST', `/session/${this.sessionId}/element/${elementId}/clear`);
|
|
12163
|
+
debugIOS('Element cleared successfully');
|
|
12164
|
+
} catch (error) {
|
|
12165
|
+
debugIOS(`Failed to clear element: ${error}`);
|
|
12166
|
+
throw new Error(`Failed to clear element: ${error}`);
|
|
12167
|
+
}
|
|
12168
|
+
}
|
|
12169
|
+
async clearActiveElement() {
|
|
12170
|
+
try {
|
|
12171
|
+
const elementId = await this.getActiveElement();
|
|
12172
|
+
if (!elementId) {
|
|
12173
|
+
debugIOS('No active element to clear');
|
|
12174
|
+
return false;
|
|
12175
|
+
}
|
|
12176
|
+
await this.clearElement(elementId);
|
|
12177
|
+
return true;
|
|
12178
|
+
} catch (error) {
|
|
12179
|
+
debugIOS(`Failed to clear active element: ${error}`);
|
|
12180
|
+
return false;
|
|
12181
|
+
}
|
|
12182
|
+
}
|
|
12140
12183
|
normalizeKeyName(key) {
|
|
12141
12184
|
return key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
|
|
12142
12185
|
}
|
|
@@ -12284,6 +12327,10 @@ var __webpack_exports__ = {};
|
|
|
12284
12327
|
debugIOS(`Failed to apply iOS session configuration: ${error}`);
|
|
12285
12328
|
}
|
|
12286
12329
|
}
|
|
12330
|
+
async executeRequest(method, endpoint, data) {
|
|
12331
|
+
this.ensureSession();
|
|
12332
|
+
return this.makeRequest(method, endpoint, data);
|
|
12333
|
+
}
|
|
12287
12334
|
}
|
|
12288
12335
|
function device_define_property(obj, key, value) {
|
|
12289
12336
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -12296,7 +12343,12 @@ var __webpack_exports__ = {};
|
|
|
12296
12343
|
return obj;
|
|
12297
12344
|
}
|
|
12298
12345
|
const debugDevice = (0, logger_namespaceObject.getDebug)('ios:device');
|
|
12299
|
-
const
|
|
12346
|
+
const WDA_HTTP_METHODS = [
|
|
12347
|
+
'GET',
|
|
12348
|
+
'POST',
|
|
12349
|
+
'DELETE',
|
|
12350
|
+
'PUT'
|
|
12351
|
+
];
|
|
12300
12352
|
class device_IOSDevice {
|
|
12301
12353
|
actionSpace() {
|
|
12302
12354
|
const defaultActions = [
|
|
@@ -12405,9 +12457,11 @@ var __webpack_exports__ = {};
|
|
|
12405
12457
|
await this.clearInput(element);
|
|
12406
12458
|
})
|
|
12407
12459
|
];
|
|
12460
|
+
const platformSpecificActions = Object.values(createPlatformActions(this));
|
|
12408
12461
|
const customActions = this.customActions || [];
|
|
12409
12462
|
return [
|
|
12410
12463
|
...defaultActions,
|
|
12464
|
+
...platformSpecificActions,
|
|
12411
12465
|
...customActions
|
|
12412
12466
|
];
|
|
12413
12467
|
}
|
|
@@ -12505,19 +12559,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12505
12559
|
if (!element) return;
|
|
12506
12560
|
await this.tap(element.center[0], element.center[1]);
|
|
12507
12561
|
await (0, utils_namespaceObject.sleep)(100);
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
await this.wdaBackend.typeText(BackspaceChar);
|
|
12512
|
-
} catch (error2) {
|
|
12513
|
-
debugDevice(`Method 1 failed, trying method 2: ${error2}`);
|
|
12514
|
-
try {
|
|
12515
|
-
const backspaces = Array(100).fill(BackspaceChar).join('');
|
|
12516
|
-
await this.wdaBackend.typeText(backspaces);
|
|
12517
|
-
} catch (error3) {
|
|
12518
|
-
debugDevice(`All clear methods failed: ${error3}`);
|
|
12519
|
-
}
|
|
12520
|
-
}
|
|
12562
|
+
debugDevice('Attempting to clear input with WebDriver Clear API');
|
|
12563
|
+
const cleared = await this.wdaBackend.clearActiveElement();
|
|
12564
|
+
cleared ? debugDevice('Successfully cleared input with WebDriver Clear API') : debugDevice('WebDriver Clear API returned false (no active element or clear failed)');
|
|
12521
12565
|
}
|
|
12522
12566
|
async url() {
|
|
12523
12567
|
return '';
|
|
@@ -12805,6 +12849,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12805
12849
|
throw new Error(`Failed to open URL via Safari: ${error}`);
|
|
12806
12850
|
}
|
|
12807
12851
|
}
|
|
12852
|
+
async runWdaRequest(method, endpoint, data) {
|
|
12853
|
+
return await this.wdaBackend.executeRequest(method, endpoint, data);
|
|
12854
|
+
}
|
|
12808
12855
|
async destroy() {
|
|
12809
12856
|
if (this.destroyed) return;
|
|
12810
12857
|
try {
|
|
@@ -12840,15 +12887,50 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12840
12887
|
this.wdaManager = webdriver_namespaceObject.WDAManager.getInstance(wdaPort, wdaHost);
|
|
12841
12888
|
}
|
|
12842
12889
|
}
|
|
12890
|
+
const runWdaRequestParamSchema = core_namespaceObject.z.object({
|
|
12891
|
+
method: core_namespaceObject.z["enum"](WDA_HTTP_METHODS).describe('HTTP method (GET, POST, DELETE, PUT)'),
|
|
12892
|
+
endpoint: core_namespaceObject.z.string().describe('WebDriver API endpoint'),
|
|
12893
|
+
data: core_namespaceObject.z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
12894
|
+
});
|
|
12895
|
+
const launchParamSchema = core_namespaceObject.z.string().describe('App bundle ID or URL to launch');
|
|
12896
|
+
const createPlatformActions = (device)=>({
|
|
12897
|
+
RunWdaRequest: (0, device_namespaceObject.defineAction)({
|
|
12898
|
+
name: 'RunWdaRequest',
|
|
12899
|
+
description: 'Execute WebDriverAgent API request directly on iOS device',
|
|
12900
|
+
interfaceAlias: 'runWdaRequest',
|
|
12901
|
+
paramSchema: runWdaRequestParamSchema,
|
|
12902
|
+
call: async (param)=>await device.runWdaRequest(param.method, param.endpoint, param.data)
|
|
12903
|
+
}),
|
|
12904
|
+
Launch: (0, device_namespaceObject.defineAction)({
|
|
12905
|
+
name: 'Launch',
|
|
12906
|
+
description: 'Launch an iOS app or URL',
|
|
12907
|
+
interfaceAlias: 'launch',
|
|
12908
|
+
paramSchema: launchParamSchema,
|
|
12909
|
+
call: async (param)=>{
|
|
12910
|
+
await device.launch(param);
|
|
12911
|
+
}
|
|
12912
|
+
})
|
|
12913
|
+
});
|
|
12843
12914
|
require("node:os");
|
|
12844
12915
|
const external_node_util_namespaceObject = require("node:util");
|
|
12845
12916
|
(0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.exec);
|
|
12846
12917
|
(0, logger_namespaceObject.getDebug)('ios:utils');
|
|
12918
|
+
function agent_define_property(obj, key, value) {
|
|
12919
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
12920
|
+
value: value,
|
|
12921
|
+
enumerable: true,
|
|
12922
|
+
configurable: true,
|
|
12923
|
+
writable: true
|
|
12924
|
+
});
|
|
12925
|
+
else obj[key] = value;
|
|
12926
|
+
return obj;
|
|
12927
|
+
}
|
|
12847
12928
|
(0, logger_namespaceObject.getDebug)('ios:agent');
|
|
12848
12929
|
class IOSAgent extends agent_namespaceObject.Agent {
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12930
|
+
constructor(device, opts){
|
|
12931
|
+
super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runWdaRequest", void 0);
|
|
12932
|
+
this.launch = this.wrapActionInActionSpace('Launch');
|
|
12933
|
+
this.runWdaRequest = this.wrapActionInActionSpace('RunWdaRequest');
|
|
12852
12934
|
}
|
|
12853
12935
|
}
|
|
12854
12936
|
async function isPortAvailable(port) {
|