@midscene/ios 1.0.1-beta-20251202112442.0 → 1.0.1-beta-20251202152706.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 +75 -102
- package/dist/es/index.mjs +12 -16
- package/dist/lib/bin.js +45 -64
- package/dist/lib/index.js +968 -990
- package/package.json +6 -6
- package/static/index.html +1 -1
- package/static/static/css/index.987d3a64.css.map +1 -1
- package/static/static/js/index.6af41395.js +10 -0
- package/static/static/js/index.6af41395.js.map +1 -0
- package/static/static/js/index.b34c1e52.js +0 -10
- package/static/static/js/index.b34c1e52.js.map +0 -1
- /package/static/static/js/{index.b34c1e52.js.LICENSE.txt → index.6af41395.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/*! For license information please see bin.mjs.LICENSE.txt */
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
13
|
-
import * as
|
|
14
|
-
import * as
|
|
15
|
-
import * as
|
|
16
|
-
import * as
|
|
17
|
-
import * as
|
|
2
|
+
import * as __rspack_external_async_hooks from "async_hooks";
|
|
3
|
+
import * as __rspack_external_buffer from "buffer";
|
|
4
|
+
import * as __rspack_external_crypto from "crypto";
|
|
5
|
+
import * as __rspack_external_events from "events";
|
|
6
|
+
import * as __rspack_external_fs from "fs";
|
|
7
|
+
import * as __rspack_external_http from "http";
|
|
8
|
+
import * as __rspack_external_net from "net";
|
|
9
|
+
import * as __rspack_external_os from "os";
|
|
10
|
+
import * as __rspack_external_path from "path";
|
|
11
|
+
import * as __rspack_external_querystring from "querystring";
|
|
12
|
+
import * as __rspack_external_stream from "stream";
|
|
13
|
+
import * as __rspack_external_string_decoder from "string_decoder";
|
|
14
|
+
import * as __rspack_external_tty from "tty";
|
|
15
|
+
import * as __rspack_external_url from "url";
|
|
16
|
+
import * as __rspack_external_util from "util";
|
|
17
|
+
import * as __rspack_external_zlib from "zlib";
|
|
18
18
|
import { createServer } from "node:net";
|
|
19
19
|
import node_path, { dirname, join } from "node:path";
|
|
20
20
|
import { input, select as prompts_select } from "@inquirer/prompts";
|
|
@@ -11278,52 +11278,52 @@ object-assign
|
|
|
11278
11278
|
}
|
|
11279
11279
|
},
|
|
11280
11280
|
async_hooks: function(module) {
|
|
11281
|
-
module.exports =
|
|
11281
|
+
module.exports = __rspack_external_async_hooks;
|
|
11282
11282
|
},
|
|
11283
11283
|
buffer: function(module) {
|
|
11284
|
-
module.exports =
|
|
11284
|
+
module.exports = __rspack_external_buffer;
|
|
11285
11285
|
},
|
|
11286
11286
|
crypto: function(module) {
|
|
11287
|
-
module.exports =
|
|
11287
|
+
module.exports = __rspack_external_crypto;
|
|
11288
11288
|
},
|
|
11289
11289
|
events: function(module) {
|
|
11290
|
-
module.exports =
|
|
11290
|
+
module.exports = __rspack_external_events;
|
|
11291
11291
|
},
|
|
11292
11292
|
fs: function(module) {
|
|
11293
|
-
module.exports =
|
|
11293
|
+
module.exports = __rspack_external_fs;
|
|
11294
11294
|
},
|
|
11295
11295
|
http: function(module) {
|
|
11296
|
-
module.exports =
|
|
11296
|
+
module.exports = __rspack_external_http;
|
|
11297
11297
|
},
|
|
11298
11298
|
net: function(module) {
|
|
11299
|
-
module.exports =
|
|
11299
|
+
module.exports = __rspack_external_net;
|
|
11300
11300
|
},
|
|
11301
11301
|
os: function(module) {
|
|
11302
|
-
module.exports =
|
|
11302
|
+
module.exports = __rspack_external_os;
|
|
11303
11303
|
},
|
|
11304
11304
|
path: function(module) {
|
|
11305
|
-
module.exports =
|
|
11305
|
+
module.exports = __rspack_external_path;
|
|
11306
11306
|
},
|
|
11307
11307
|
querystring: function(module) {
|
|
11308
|
-
module.exports =
|
|
11308
|
+
module.exports = __rspack_external_querystring;
|
|
11309
11309
|
},
|
|
11310
11310
|
stream: function(module) {
|
|
11311
|
-
module.exports =
|
|
11311
|
+
module.exports = __rspack_external_stream;
|
|
11312
11312
|
},
|
|
11313
11313
|
string_decoder: function(module) {
|
|
11314
|
-
module.exports =
|
|
11314
|
+
module.exports = __rspack_external_string_decoder;
|
|
11315
11315
|
},
|
|
11316
11316
|
tty: function(module) {
|
|
11317
|
-
module.exports =
|
|
11317
|
+
module.exports = __rspack_external_tty;
|
|
11318
11318
|
},
|
|
11319
11319
|
url: function(module) {
|
|
11320
|
-
module.exports =
|
|
11320
|
+
module.exports = __rspack_external_url;
|
|
11321
11321
|
},
|
|
11322
11322
|
util: function(module) {
|
|
11323
|
-
module.exports =
|
|
11323
|
+
module.exports = __rspack_external_util;
|
|
11324
11324
|
},
|
|
11325
11325
|
zlib: function(module) {
|
|
11326
|
-
module.exports =
|
|
11326
|
+
module.exports = __rspack_external_zlib;
|
|
11327
11327
|
},
|
|
11328
11328
|
"../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/package.json": function(module) {
|
|
11329
11329
|
module.exports = JSON.parse('{"name":"dotenv","version":"16.4.5","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","lint-readme":"standard-markdown","pretest":"npm run lint && npm run dts-check","test":"tap tests/*.js --100 -Rspec","test:coverage":"tap --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3","decache":"^4.6.1","sinon":"^14.0.1","standard":"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0","tap":"^16.3.0","tar":"^6.1.11","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}');
|
|
@@ -11375,26 +11375,6 @@ function __webpack_require__(moduleId) {
|
|
|
11375
11375
|
module.loaded = true;
|
|
11376
11376
|
return module.exports;
|
|
11377
11377
|
}
|
|
11378
|
-
(()=>{
|
|
11379
|
-
__webpack_require__.n = (module)=>{
|
|
11380
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
11381
|
-
__webpack_require__.d(getter, {
|
|
11382
|
-
a: getter
|
|
11383
|
-
});
|
|
11384
|
-
return getter;
|
|
11385
|
-
};
|
|
11386
|
-
})();
|
|
11387
|
-
(()=>{
|
|
11388
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
11389
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
11390
|
-
enumerable: true,
|
|
11391
|
-
get: definition[key]
|
|
11392
|
-
});
|
|
11393
|
-
};
|
|
11394
|
-
})();
|
|
11395
|
-
(()=>{
|
|
11396
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
11397
|
-
})();
|
|
11398
11378
|
(()=>{
|
|
11399
11379
|
__webpack_require__.nmd = (module)=>{
|
|
11400
11380
|
module.paths = [];
|
|
@@ -11418,13 +11398,13 @@ const validationAPIs = [
|
|
|
11418
11398
|
...validationAPIs
|
|
11419
11399
|
];
|
|
11420
11400
|
const formatErrorMessage = (e)=>{
|
|
11421
|
-
const errorMessage =
|
|
11401
|
+
const errorMessage = e?.message || '';
|
|
11422
11402
|
if (errorMessage.includes('of different extension')) return 'Conflicting extension detected. Please disable the suspicious plugins and refresh the page. Guide: https://midscenejs.com/quick-experience.html#faq';
|
|
11423
11403
|
if (errorMessage.includes('NOT_IMPLEMENTED_AS_DESIGNED')) return 'Further actions cannot be performed in the current environment';
|
|
11424
11404
|
return errorMessage || 'Unknown error';
|
|
11425
11405
|
};
|
|
11426
11406
|
async function parseStructuredParams(action, params, options = {}) {
|
|
11427
|
-
if (!
|
|
11407
|
+
if (!action?.paramSchema || !('shape' in action.paramSchema)) return [
|
|
11428
11408
|
params.prompt || '',
|
|
11429
11409
|
options
|
|
11430
11410
|
];
|
|
@@ -11456,7 +11436,7 @@ async function parseStructuredParams(action, params, options = {}) {
|
|
|
11456
11436
|
];
|
|
11457
11437
|
}
|
|
11458
11438
|
async function executeAction(activeAgent, actionType, actionSpace, value, options) {
|
|
11459
|
-
const action =
|
|
11439
|
+
const action = actionSpace?.find((a)=>a.interfaceAlias === actionType || a.name === actionType);
|
|
11460
11440
|
if (action && 'function' == typeof activeAgent.callActionInActionSpace) if (value.params) {
|
|
11461
11441
|
const parsedParams = await parseStructuredParams(action, value.params, options);
|
|
11462
11442
|
return await activeAgent.callActionInActionSpace(action.name, parsedParams[0]);
|
|
@@ -11476,11 +11456,10 @@ async function executeAction(activeAgent, actionType, actionSpace, value, option
|
|
|
11476
11456
|
{
|
|
11477
11457
|
const prompt = value.prompt;
|
|
11478
11458
|
if ('aiAssert' === actionType) {
|
|
11479
|
-
|
|
11480
|
-
const { pass, thought } = await (null == activeAgent ? void 0 : null == (_activeAgent_aiAssert = activeAgent.aiAssert) ? void 0 : _activeAgent_aiAssert.call(activeAgent, prompt || '', void 0, {
|
|
11459
|
+
const { pass, thought } = await activeAgent?.aiAssert?.(prompt || '', void 0, {
|
|
11481
11460
|
keepRawResponse: true,
|
|
11482
11461
|
...options
|
|
11483
|
-
})
|
|
11462
|
+
}) || {};
|
|
11484
11463
|
return {
|
|
11485
11464
|
pass: pass || false,
|
|
11486
11465
|
thought: thought || ''
|
|
@@ -11491,7 +11470,6 @@ async function executeAction(activeAgent, actionType, actionSpace, value, option
|
|
|
11491
11470
|
}
|
|
11492
11471
|
}
|
|
11493
11472
|
var express = __webpack_require__("../../node_modules/.pnpm/express@4.21.2/node_modules/express/index.js");
|
|
11494
|
-
var express_default = /*#__PURE__*/ __webpack_require__.n(express);
|
|
11495
11473
|
__webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/config.js");
|
|
11496
11474
|
function _define_property(obj, key, value) {
|
|
11497
11475
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -11520,7 +11498,7 @@ class PlaygroundServer {
|
|
|
11520
11498
|
}
|
|
11521
11499
|
initializeApp() {
|
|
11522
11500
|
if (this._initialized) return;
|
|
11523
|
-
this._app.use(
|
|
11501
|
+
this._app.use(express.json({
|
|
11524
11502
|
limit: '50mb'
|
|
11525
11503
|
}));
|
|
11526
11504
|
this._app.use((req, _res, next)=>{
|
|
@@ -11740,9 +11718,8 @@ class PlaygroundServer {
|
|
|
11740
11718
|
});
|
|
11741
11719
|
this._app.get('/interface-info', async (_req, res)=>{
|
|
11742
11720
|
try {
|
|
11743
|
-
var _this_agent_interface_describe, _this_agent_interface;
|
|
11744
11721
|
const type = this.agent.interface.interfaceType || 'Unknown';
|
|
11745
|
-
const description =
|
|
11722
|
+
const description = this.agent.interface.describe?.() || void 0;
|
|
11746
11723
|
res.json({
|
|
11747
11724
|
type,
|
|
11748
11725
|
description
|
|
@@ -11786,7 +11763,7 @@ class PlaygroundServer {
|
|
|
11786
11763
|
this._app.get('/index.html', (_req, res)=>{
|
|
11787
11764
|
this.serveHtmlWithPorts(res);
|
|
11788
11765
|
});
|
|
11789
|
-
this._app.use(
|
|
11766
|
+
this._app.use(express["static"](this.staticPath));
|
|
11790
11767
|
this._app.get('*', (_req, res)=>{
|
|
11791
11768
|
this.serveHtmlWithPorts(res);
|
|
11792
11769
|
});
|
|
@@ -11855,7 +11832,7 @@ class PlaygroundServer {
|
|
|
11855
11832
|
_define_property(this, "_initialized", false);
|
|
11856
11833
|
_define_property(this, "agentFactory", void 0);
|
|
11857
11834
|
_define_property(this, "currentTaskId", null);
|
|
11858
|
-
this._app =
|
|
11835
|
+
this._app = express();
|
|
11859
11836
|
this.tmpDir = getTmpDir();
|
|
11860
11837
|
this.staticPath = staticPath;
|
|
11861
11838
|
this.taskProgressTips = {};
|
|
@@ -12013,9 +11990,8 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
12013
11990
|
this.ensureSession();
|
|
12014
11991
|
debugIOS('Getting active element');
|
|
12015
11992
|
try {
|
|
12016
|
-
var _response_value, _response_value1;
|
|
12017
11993
|
const response = await this.makeRequest('GET', `/session/${this.sessionId}/element/active`);
|
|
12018
|
-
const elementId =
|
|
11994
|
+
const elementId = response.value?.ELEMENT || response.value?.['element-6066-11e4-a52e-4f735466cecf'] || response.ELEMENT || response['element-6066-11e4-a52e-4f735466cecf'];
|
|
12019
11995
|
if (elementId) {
|
|
12020
11996
|
debugIOS(`Got active element ID: ${elementId}`);
|
|
12021
11997
|
return elementId;
|
|
@@ -12177,9 +12153,8 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
12177
12153
|
async getScreenScale() {
|
|
12178
12154
|
this.ensureSession();
|
|
12179
12155
|
try {
|
|
12180
|
-
var _screenResponse_value;
|
|
12181
12156
|
const screenResponse = await this.makeRequest('GET', `/session/${this.sessionId}/wda/screen`);
|
|
12182
|
-
if (
|
|
12157
|
+
if (screenResponse?.value?.scale) {
|
|
12183
12158
|
debugIOS(`Got screen scale from WDA screen endpoint: ${screenResponse.value.scale}`);
|
|
12184
12159
|
return screenResponse.value.scale;
|
|
12185
12160
|
}
|
|
@@ -12280,14 +12255,13 @@ class device_IOSDevice {
|
|
|
12280
12255
|
locate: getMidsceneLocationSchema().describe('The input field to be filled').optional()
|
|
12281
12256
|
}),
|
|
12282
12257
|
call: async (param)=>{
|
|
12283
|
-
var _this_options;
|
|
12284
12258
|
const element = param.locate;
|
|
12285
12259
|
if (element) {
|
|
12286
12260
|
if ('append' !== param.mode) await this.clearInput(element);
|
|
12287
12261
|
}
|
|
12288
12262
|
if ('clear' === param.mode) return;
|
|
12289
12263
|
if (!param || !param.value) return;
|
|
12290
|
-
const autoDismissKeyboard = param.autoDismissKeyboard ??
|
|
12264
|
+
const autoDismissKeyboard = param.autoDismissKeyboard ?? this.options?.autoDismissKeyboard;
|
|
12291
12265
|
await this.typeText(param.value, {
|
|
12292
12266
|
autoDismissKeyboard
|
|
12293
12267
|
});
|
|
@@ -12299,18 +12273,18 @@ class device_IOSDevice {
|
|
|
12299
12273
|
left: element.center[0],
|
|
12300
12274
|
top: element.center[1]
|
|
12301
12275
|
} : void 0;
|
|
12302
|
-
const scrollToEventName =
|
|
12276
|
+
const scrollToEventName = param?.scrollType;
|
|
12303
12277
|
if ('scrollToTop' === scrollToEventName) await this.scrollUntilTop(startingPoint);
|
|
12304
12278
|
else if ('scrollToBottom' === scrollToEventName) await this.scrollUntilBottom(startingPoint);
|
|
12305
12279
|
else if ('scrollToRight' === scrollToEventName) await this.scrollUntilRight(startingPoint);
|
|
12306
12280
|
else if ('scrollToLeft' === scrollToEventName) await this.scrollUntilLeft(startingPoint);
|
|
12307
12281
|
else if ('singleAction' !== scrollToEventName && scrollToEventName) throw new Error(`Unknown scroll event type: ${scrollToEventName}, param: ${JSON.stringify(param)}`);
|
|
12308
12282
|
else {
|
|
12309
|
-
if (
|
|
12283
|
+
if (param?.direction !== 'down' && param && param.direction) if ('up' === param.direction) await this.scrollUp(param.distance || void 0, startingPoint);
|
|
12310
12284
|
else if ('left' === param.direction) await this.scrollLeft(param.distance || void 0, startingPoint);
|
|
12311
12285
|
else if ('right' === param.direction) await this.scrollRight(param.distance || void 0, startingPoint);
|
|
12312
12286
|
else throw new Error(`Unknown scroll direction: ${param.direction}`);
|
|
12313
|
-
else await this.scrollDown(
|
|
12287
|
+
else await this.scrollDown(param?.distance || void 0, startingPoint);
|
|
12314
12288
|
await sleep(500);
|
|
12315
12289
|
}
|
|
12316
12290
|
}),
|
|
@@ -12335,7 +12309,7 @@ class device_IOSDevice {
|
|
|
12335
12309
|
const element = param.locate;
|
|
12336
12310
|
node_assert(element, 'IOSLongPress requires an element to be located');
|
|
12337
12311
|
const [x, y] = element.center;
|
|
12338
|
-
await this.longPress(x, y,
|
|
12312
|
+
await this.longPress(x, y, param?.duration);
|
|
12339
12313
|
}
|
|
12340
12314
|
}),
|
|
12341
12315
|
defineActionClearInput(async (param)=>{
|
|
@@ -12365,7 +12339,7 @@ class device_IOSDevice {
|
|
|
12365
12339
|
await this.wdaManager.start();
|
|
12366
12340
|
await this.wdaBackend.createSession();
|
|
12367
12341
|
const deviceInfo = await this.wdaBackend.getDeviceInfo();
|
|
12368
|
-
if (
|
|
12342
|
+
if (deviceInfo?.udid) {
|
|
12369
12343
|
this.deviceId = deviceInfo.udid;
|
|
12370
12344
|
debugDevice(`Updated device ID to real UDID: ${this.deviceId}`);
|
|
12371
12345
|
}
|
|
@@ -12473,9 +12447,8 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12473
12447
|
await this.wdaBackend.swipe(Math.round(fromX), Math.round(fromY), Math.round(toX), Math.round(toY), duration);
|
|
12474
12448
|
}
|
|
12475
12449
|
async typeText(text, options) {
|
|
12476
|
-
var _this_options;
|
|
12477
12450
|
if (!text) return;
|
|
12478
|
-
const shouldAutoDismissKeyboard =
|
|
12451
|
+
const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
|
|
12479
12452
|
debugDevice(`Typing text: "${text}"`);
|
|
12480
12453
|
try {
|
|
12481
12454
|
await sleep(200);
|
|
@@ -12775,9 +12748,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
12775
12748
|
device_define_property(this, "options", void 0);
|
|
12776
12749
|
this.deviceId = 'pending-connection';
|
|
12777
12750
|
this.options = options;
|
|
12778
|
-
this.customActions =
|
|
12779
|
-
const wdaPort =
|
|
12780
|
-
const wdaHost =
|
|
12751
|
+
this.customActions = options?.customActions;
|
|
12752
|
+
const wdaPort = options?.wdaPort || DEFAULT_WDA_PORT;
|
|
12753
|
+
const wdaHost = options?.wdaHost || 'localhost';
|
|
12781
12754
|
this.wdaBackend = new IOSWebDriverClient({
|
|
12782
12755
|
port: wdaPort,
|
|
12783
12756
|
host: wdaHost
|
|
@@ -12865,7 +12838,7 @@ async function findAvailablePort(startPort) {
|
|
|
12865
12838
|
while(!await isPortAvailable(port)){
|
|
12866
12839
|
attempts++;
|
|
12867
12840
|
if (attempts >= maxAttempts) {
|
|
12868
|
-
console.error(
|
|
12841
|
+
console.error(`❌ Unable to find available port after ${maxAttempts} attempts starting from ${startPort}`);
|
|
12869
12842
|
process.exit(1);
|
|
12870
12843
|
}
|
|
12871
12844
|
port++;
|
|
@@ -12873,7 +12846,7 @@ async function findAvailablePort(startPort) {
|
|
|
12873
12846
|
return port;
|
|
12874
12847
|
}
|
|
12875
12848
|
async function configureWebDriverAgent() {
|
|
12876
|
-
console.log(
|
|
12849
|
+
console.log('🔧 WebDriverAgent Configuration');
|
|
12877
12850
|
console.log(`Default: localhost:${DEFAULT_WDA_PORT}`);
|
|
12878
12851
|
const useDefault = await prompts_select({
|
|
12879
12852
|
message: `Use default WebDriverAgent address (localhost:${DEFAULT_WDA_PORT})?`,
|
|
@@ -12903,7 +12876,7 @@ async function configureWebDriverAgent() {
|
|
|
12903
12876
|
});
|
|
12904
12877
|
const port = Number.parseInt(portInput, 10);
|
|
12905
12878
|
if (Number.isNaN(port) || port < 1 || port > 65535) {
|
|
12906
|
-
console.error(
|
|
12879
|
+
console.error(`❌ Invalid port number. Using default ${DEFAULT_WDA_PORT}.`);
|
|
12907
12880
|
return {
|
|
12908
12881
|
host,
|
|
12909
12882
|
port: DEFAULT_WDA_PORT
|
|
@@ -12928,39 +12901,39 @@ const main = async ()=>{
|
|
|
12928
12901
|
wdaHost: wdaConfig.host,
|
|
12929
12902
|
wdaPort: wdaConfig.port
|
|
12930
12903
|
});
|
|
12931
|
-
console.log(
|
|
12904
|
+
console.log(`🔌 Connecting to WebDriverAgent at ${wdaConfig.host}:${wdaConfig.port}...`);
|
|
12932
12905
|
await device.connect();
|
|
12933
12906
|
connected = true;
|
|
12934
12907
|
const deviceInfo = await device.getConnectedDeviceInfo();
|
|
12935
|
-
console.log(
|
|
12908
|
+
console.log('✅ Connected to WebDriverAgent successfully!');
|
|
12936
12909
|
if (deviceInfo) {
|
|
12937
|
-
console.log(
|
|
12938
|
-
console.log(
|
|
12910
|
+
console.log(`📱 Connected to: ${deviceInfo.name} (${deviceInfo.model})`);
|
|
12911
|
+
console.log(`🔑 Device UDID: ${deviceInfo.udid}`);
|
|
12939
12912
|
}
|
|
12940
12913
|
} catch (error) {
|
|
12941
|
-
console.error(
|
|
12914
|
+
console.error(`❌ Failed to connect to WebDriverAgent: ${error instanceof Error ? error.message : String(error)}`);
|
|
12942
12915
|
const action = await prompts_select({
|
|
12943
12916
|
message: 'What would you like to do?',
|
|
12944
12917
|
choices: [
|
|
12945
12918
|
{
|
|
12946
|
-
name:
|
|
12919
|
+
name: '🔧 Configure different WebDriverAgent address',
|
|
12947
12920
|
value: 'configure'
|
|
12948
12921
|
},
|
|
12949
12922
|
{
|
|
12950
|
-
name:
|
|
12923
|
+
name: '📖 Show setup instructions',
|
|
12951
12924
|
value: 'instructions'
|
|
12952
12925
|
},
|
|
12953
12926
|
{
|
|
12954
|
-
name:
|
|
12927
|
+
name: '🚪 Exit',
|
|
12955
12928
|
value: 'exit'
|
|
12956
12929
|
}
|
|
12957
12930
|
]
|
|
12958
12931
|
});
|
|
12959
12932
|
if ('exit' === action) {
|
|
12960
|
-
console.log(
|
|
12933
|
+
console.log('👋 Goodbye!');
|
|
12961
12934
|
process.exit(0);
|
|
12962
12935
|
} else if ('instructions' === action) console.log(`
|
|
12963
|
-
|
|
12936
|
+
🔧 WebDriverAgent Setup Instructions:
|
|
12964
12937
|
|
|
12965
12938
|
1. Install WebDriverAgent:
|
|
12966
12939
|
npm install appium-webdriveragent
|
|
@@ -12976,8 +12949,8 @@ const main = async ()=>{
|
|
|
12976
12949
|
|
|
12977
12950
|
6. Restart this playground to connect
|
|
12978
12951
|
|
|
12979
|
-
|
|
12980
|
-
|
|
12952
|
+
💡 The WebDriverAgent service is already bound to the device you selected in Xcode.
|
|
12953
|
+
💡 For more details, visit: https://github.com/appium/WebDriverAgent
|
|
12981
12954
|
`);
|
|
12982
12955
|
else if ('configure' === action) wdaConfig = await configureWebDriverAgent();
|
|
12983
12956
|
}
|
|
@@ -12990,16 +12963,16 @@ const main = async ()=>{
|
|
|
12990
12963
|
return new IOSAgent(newDevice);
|
|
12991
12964
|
};
|
|
12992
12965
|
const playgroundServer = new PlaygroundServer(agentFactory, staticDir);
|
|
12993
|
-
console.log(
|
|
12966
|
+
console.log('🚀 Starting server...');
|
|
12994
12967
|
const availablePlaygroundPort = await findAvailablePort(constants_PLAYGROUND_SERVER_PORT);
|
|
12995
|
-
if (availablePlaygroundPort !== constants_PLAYGROUND_SERVER_PORT) console.log(
|
|
12968
|
+
if (availablePlaygroundPort !== constants_PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${constants_PLAYGROUND_SERVER_PORT} is busy, using port ${availablePlaygroundPort} instead`);
|
|
12996
12969
|
await playgroundServer.launch(availablePlaygroundPort);
|
|
12997
12970
|
console.log('');
|
|
12998
|
-
console.log(
|
|
12999
|
-
console.log(
|
|
13000
|
-
console.log(
|
|
13001
|
-
console.log(
|
|
13002
|
-
console.log(
|
|
12971
|
+
console.log('✨ Midscene iOS Playground is ready!');
|
|
12972
|
+
console.log(`🎮 Playground: http://localhost:${playgroundServer.port}`);
|
|
12973
|
+
console.log('📱 Device: WebDriverAgent Connected');
|
|
12974
|
+
console.log(`🔧 WebDriverAgent: ${wdaConfig.host}:${wdaConfig.port}`);
|
|
12975
|
+
console.log(`🔑 Generated Server ID: ${playgroundServer.id}`);
|
|
13003
12976
|
console.log('');
|
|
13004
12977
|
open(`http://localhost:${playgroundServer.port}`);
|
|
13005
12978
|
} catch (error) {
|
package/dist/es/index.mjs
CHANGED
|
@@ -154,9 +154,8 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
154
154
|
this.ensureSession();
|
|
155
155
|
debugIOS('Getting active element');
|
|
156
156
|
try {
|
|
157
|
-
var _response_value, _response_value1;
|
|
158
157
|
const response = await this.makeRequest('GET', `/session/${this.sessionId}/element/active`);
|
|
159
|
-
const elementId =
|
|
158
|
+
const elementId = response.value?.ELEMENT || response.value?.['element-6066-11e4-a52e-4f735466cecf'] || response.ELEMENT || response['element-6066-11e4-a52e-4f735466cecf'];
|
|
160
159
|
if (elementId) {
|
|
161
160
|
debugIOS(`Got active element ID: ${elementId}`);
|
|
162
161
|
return elementId;
|
|
@@ -318,9 +317,8 @@ class IOSWebDriverClient extends WebDriverClient {
|
|
|
318
317
|
async getScreenScale() {
|
|
319
318
|
this.ensureSession();
|
|
320
319
|
try {
|
|
321
|
-
var _screenResponse_value;
|
|
322
320
|
const screenResponse = await this.makeRequest('GET', `/session/${this.sessionId}/wda/screen`);
|
|
323
|
-
if (
|
|
321
|
+
if (screenResponse?.value?.scale) {
|
|
324
322
|
debugIOS(`Got screen scale from WDA screen endpoint: ${screenResponse.value.scale}`);
|
|
325
323
|
return screenResponse.value.scale;
|
|
326
324
|
}
|
|
@@ -421,14 +419,13 @@ class IOSDevice {
|
|
|
421
419
|
locate: getMidsceneLocationSchema().describe('The input field to be filled').optional()
|
|
422
420
|
}),
|
|
423
421
|
call: async (param)=>{
|
|
424
|
-
var _this_options;
|
|
425
422
|
const element = param.locate;
|
|
426
423
|
if (element) {
|
|
427
424
|
if ('append' !== param.mode) await this.clearInput(element);
|
|
428
425
|
}
|
|
429
426
|
if ('clear' === param.mode) return;
|
|
430
427
|
if (!param || !param.value) return;
|
|
431
|
-
const autoDismissKeyboard = param.autoDismissKeyboard ??
|
|
428
|
+
const autoDismissKeyboard = param.autoDismissKeyboard ?? this.options?.autoDismissKeyboard;
|
|
432
429
|
await this.typeText(param.value, {
|
|
433
430
|
autoDismissKeyboard
|
|
434
431
|
});
|
|
@@ -440,18 +437,18 @@ class IOSDevice {
|
|
|
440
437
|
left: element.center[0],
|
|
441
438
|
top: element.center[1]
|
|
442
439
|
} : void 0;
|
|
443
|
-
const scrollToEventName =
|
|
440
|
+
const scrollToEventName = param?.scrollType;
|
|
444
441
|
if ('scrollToTop' === scrollToEventName) await this.scrollUntilTop(startingPoint);
|
|
445
442
|
else if ('scrollToBottom' === scrollToEventName) await this.scrollUntilBottom(startingPoint);
|
|
446
443
|
else if ('scrollToRight' === scrollToEventName) await this.scrollUntilRight(startingPoint);
|
|
447
444
|
else if ('scrollToLeft' === scrollToEventName) await this.scrollUntilLeft(startingPoint);
|
|
448
445
|
else if ('singleAction' !== scrollToEventName && scrollToEventName) throw new Error(`Unknown scroll event type: ${scrollToEventName}, param: ${JSON.stringify(param)}`);
|
|
449
446
|
else {
|
|
450
|
-
if (
|
|
447
|
+
if (param?.direction !== 'down' && param && param.direction) if ('up' === param.direction) await this.scrollUp(param.distance || void 0, startingPoint);
|
|
451
448
|
else if ('left' === param.direction) await this.scrollLeft(param.distance || void 0, startingPoint);
|
|
452
449
|
else if ('right' === param.direction) await this.scrollRight(param.distance || void 0, startingPoint);
|
|
453
450
|
else throw new Error(`Unknown scroll direction: ${param.direction}`);
|
|
454
|
-
else await this.scrollDown(
|
|
451
|
+
else await this.scrollDown(param?.distance || void 0, startingPoint);
|
|
455
452
|
await sleep(500);
|
|
456
453
|
}
|
|
457
454
|
}),
|
|
@@ -476,7 +473,7 @@ class IOSDevice {
|
|
|
476
473
|
const element = param.locate;
|
|
477
474
|
node_assert(element, 'IOSLongPress requires an element to be located');
|
|
478
475
|
const [x, y] = element.center;
|
|
479
|
-
await this.longPress(x, y,
|
|
476
|
+
await this.longPress(x, y, param?.duration);
|
|
480
477
|
}
|
|
481
478
|
}),
|
|
482
479
|
defineActionClearInput(async (param)=>{
|
|
@@ -506,7 +503,7 @@ class IOSDevice {
|
|
|
506
503
|
await this.wdaManager.start();
|
|
507
504
|
await this.wdaBackend.createSession();
|
|
508
505
|
const deviceInfo = await this.wdaBackend.getDeviceInfo();
|
|
509
|
-
if (
|
|
506
|
+
if (deviceInfo?.udid) {
|
|
510
507
|
this.deviceId = deviceInfo.udid;
|
|
511
508
|
debugDevice(`Updated device ID to real UDID: ${this.deviceId}`);
|
|
512
509
|
}
|
|
@@ -614,9 +611,8 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
614
611
|
await this.wdaBackend.swipe(Math.round(fromX), Math.round(fromY), Math.round(toX), Math.round(toY), duration);
|
|
615
612
|
}
|
|
616
613
|
async typeText(text, options) {
|
|
617
|
-
var _this_options;
|
|
618
614
|
if (!text) return;
|
|
619
|
-
const shouldAutoDismissKeyboard =
|
|
615
|
+
const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
|
|
620
616
|
debugDevice(`Typing text: "${text}"`);
|
|
621
617
|
try {
|
|
622
618
|
await sleep(200);
|
|
@@ -916,9 +912,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
916
912
|
_define_property(this, "options", void 0);
|
|
917
913
|
this.deviceId = 'pending-connection';
|
|
918
914
|
this.options = options;
|
|
919
|
-
this.customActions =
|
|
920
|
-
const wdaPort =
|
|
921
|
-
const wdaHost =
|
|
915
|
+
this.customActions = options?.customActions;
|
|
916
|
+
const wdaPort = options?.wdaPort || DEFAULT_WDA_PORT;
|
|
917
|
+
const wdaHost = options?.wdaHost || 'localhost';
|
|
922
918
|
this.wdaBackend = new IOSWebDriverClient({
|
|
923
919
|
port: wdaPort,
|
|
924
920
|
host: wdaHost
|