@midscene/ios 1.13.3 → 1.13.4-beta-20260924030824.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 +21 -6
- package/dist/es/cli.mjs +12 -3
- package/dist/es/index.mjs +28 -7
- package/dist/lib/bin.js +21 -6
- package/dist/lib/cli.js +12 -3
- package/dist/lib/index.js +27 -6
- package/dist/types/index.d.ts +1 -1
- package/package.json +5 -5
- package/static/index.html +1 -1
- package/static/static/js/index.e149e49f.js +875 -0
- package/static/static/js/index.e149e49f.js.map +1 -0
- package/static/static/js/index.0723f7fd.js +0 -875
- package/static/static/js/index.0723f7fd.js.map +0 -1
- /package/static/static/js/{index.0723f7fd.js.LICENSE.txt → index.e149e49f.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import node_path from "node:path";
|
|
|
2
2
|
import { createMjpegPreviewDescriptor, definePlaygroundPlatform, launchPreparedPlaygroundPlatform } from "@midscene/playground";
|
|
3
3
|
import { DEFAULT_WDA_PORT, PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
|
|
4
4
|
import { findAvailablePort } from "@midscene/shared/node";
|
|
5
|
+
import { WDAManager, WebDriverClient, normalizeWebDriverBaseUrl } from "@midscene/webdriver";
|
|
5
6
|
import { Agent } from "@midscene/core/agent";
|
|
6
7
|
import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE } from "@midscene/shared/env";
|
|
7
8
|
import { getDebug } from "@midscene/shared/logger";
|
|
@@ -11,7 +12,6 @@ import { z } from "@midscene/core";
|
|
|
11
12
|
import { createDefaultMobileActions, defineAction, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
|
|
12
13
|
import { sleep } from "@midscene/core/utils";
|
|
13
14
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
14
|
-
import { WDAManager, WebDriverClient } from "@midscene/webdriver";
|
|
15
15
|
import { createAgentTestRunnerNodeDefinition } from "@midscene/core/agent/test";
|
|
16
16
|
import { z as v4_z } from "zod/v4";
|
|
17
17
|
const defaultAppNameMapping = {
|
|
@@ -1653,11 +1653,14 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1653
1653
|
this.wdaBackend = new IOSWebDriverClient({
|
|
1654
1654
|
port: wdaPort,
|
|
1655
1655
|
host: wdaHost,
|
|
1656
|
+
...options?.wdaBaseUrl !== void 0 ? {
|
|
1657
|
+
baseUrl: options.wdaBaseUrl
|
|
1658
|
+
} : {},
|
|
1656
1659
|
...options?.sessionId ? {
|
|
1657
1660
|
sessionId: options.sessionId
|
|
1658
1661
|
} : {}
|
|
1659
1662
|
});
|
|
1660
|
-
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost);
|
|
1663
|
+
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost, options?.wdaBaseUrl);
|
|
1661
1664
|
this.mjpegStreamUrl = `http://${wdaHost}:${mjpegPort}`;
|
|
1662
1665
|
if (options?.wdaMjpegFrameSource?.enabled) this.openFrameSource = ()=>this.openMjpegFrameSource();
|
|
1663
1666
|
}
|
|
@@ -1930,6 +1933,13 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
1930
1933
|
defaultValue: DEFAULT_WDA_PORT,
|
|
1931
1934
|
placeholder: DEFAULT_WDA_PORT.toString()
|
|
1932
1935
|
},
|
|
1936
|
+
{
|
|
1937
|
+
key: 'baseUrl',
|
|
1938
|
+
label: 'WebDriverAgent base URL (optional)',
|
|
1939
|
+
type: 'text',
|
|
1940
|
+
required: false,
|
|
1941
|
+
placeholder: 'https://gateway.example/device/wda'
|
|
1942
|
+
},
|
|
1933
1943
|
{
|
|
1934
1944
|
key: 'sessionId',
|
|
1935
1945
|
label: 'WebDriverAgent session ID',
|
|
@@ -1941,21 +1951,26 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
1941
1951
|
};
|
|
1942
1952
|
},
|
|
1943
1953
|
async createSession (input) {
|
|
1954
|
+
const baseUrl = 'string' == typeof input?.baseUrl && input.baseUrl.trim() ? normalizeWebDriverBaseUrl(input.baseUrl.trim()) : void 0;
|
|
1944
1955
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1945
|
-
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
1956
|
+
const port = baseUrl ? DEFAULT_WDA_PORT : 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
1946
1957
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1947
1958
|
const sessionId = 'string' == typeof input?.sessionId && input.sessionId.trim() ? input.sessionId.trim() : void 0;
|
|
1948
1959
|
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1949
1960
|
...options?.getAgentOptions?.(),
|
|
1950
1961
|
wdaHost: host,
|
|
1951
1962
|
wdaPort: port,
|
|
1963
|
+
...baseUrl ? {
|
|
1964
|
+
wdaBaseUrl: baseUrl
|
|
1965
|
+
} : {},
|
|
1952
1966
|
...sessionId ? {
|
|
1953
1967
|
sessionId
|
|
1954
1968
|
} : {}
|
|
1955
1969
|
});
|
|
1956
1970
|
const agent = await connectAgent();
|
|
1957
1971
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1958
|
-
const
|
|
1972
|
+
const gatewayUrl = baseUrl ? new URL(baseUrl) : void 0;
|
|
1973
|
+
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : gatewayUrl ? `${gatewayUrl.host} (WDA gateway)` : `${host}:${port}`;
|
|
1959
1974
|
return {
|
|
1960
1975
|
agent,
|
|
1961
1976
|
agentFactory: connectAgent,
|
|
@@ -1964,8 +1979,8 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
1964
1979
|
}),
|
|
1965
1980
|
displayName,
|
|
1966
1981
|
metadata: {
|
|
1967
|
-
wdaHost: host,
|
|
1968
|
-
wdaPort: port,
|
|
1982
|
+
wdaHost: gatewayUrl?.hostname ?? host,
|
|
1983
|
+
wdaPort: gatewayUrl ? Number(gatewayUrl.port || ('https:' === gatewayUrl.protocol ? 443 : 80)) : port,
|
|
1969
1984
|
...sessionId ? {
|
|
1970
1985
|
sessionId
|
|
1971
1986
|
} : {},
|
package/dist/es/cli.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createReportCliCommands, z } from "@midscene/core";
|
|
2
2
|
import { reportCLIError, runToolsCLI } from "@midscene/shared/cli";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
3
4
|
import { agentBehaviorInitArgShape, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/agent-tools/agent-behavior-init-args";
|
|
4
5
|
import { BaseMidsceneTools } from "@midscene/shared/agent-tools/base-tools";
|
|
5
6
|
import { getDebug } from "@midscene/shared/logger";
|
|
@@ -1653,11 +1654,14 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1653
1654
|
this.wdaBackend = new IOSWebDriverClient({
|
|
1654
1655
|
port: wdaPort,
|
|
1655
1656
|
host: wdaHost,
|
|
1657
|
+
...options?.wdaBaseUrl !== void 0 ? {
|
|
1658
|
+
baseUrl: options.wdaBaseUrl
|
|
1659
|
+
} : {},
|
|
1656
1660
|
...options?.sessionId ? {
|
|
1657
1661
|
sessionId: options.sessionId
|
|
1658
1662
|
} : {}
|
|
1659
1663
|
});
|
|
1660
|
-
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost);
|
|
1664
|
+
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost, options?.wdaBaseUrl);
|
|
1661
1665
|
this.mjpegStreamUrl = `http://${wdaHost}:${mjpegPort}`;
|
|
1662
1666
|
if (options?.wdaMjpegFrameSource?.enabled) this.openFrameSource = ()=>this.openMjpegFrameSource();
|
|
1663
1667
|
}
|
|
@@ -1893,6 +1897,7 @@ function agent_tools_define_property(obj, key, value) {
|
|
|
1893
1897
|
}
|
|
1894
1898
|
const agent_tools_debug = getDebug('agent-tools:ios');
|
|
1895
1899
|
const iosInitArgShape = {
|
|
1900
|
+
wdaBaseUrl: z.string().optional().describe('Full WebDriverAgent API base URL, including gateway path prefix'),
|
|
1896
1901
|
wdaHost: z.string().optional().describe('WebDriverAgent host, defaults to localhost'),
|
|
1897
1902
|
wdaPort: z.number().optional().describe('WebDriverAgent port'),
|
|
1898
1903
|
sessionId: z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
|
|
@@ -1903,6 +1908,10 @@ const iosInitArgShape = {
|
|
|
1903
1908
|
...agentBehaviorInitArgShape
|
|
1904
1909
|
};
|
|
1905
1910
|
function getTargetIdentity(initArgs) {
|
|
1911
|
+
if (initArgs?.wdaBaseUrl) {
|
|
1912
|
+
const fingerprint = createHash('sha256').update(`${initArgs.wdaBaseUrl}\0${initArgs.sessionId ?? ''}`).digest('hex').slice(0, 12);
|
|
1913
|
+
return `wda-${fingerprint}`;
|
|
1914
|
+
}
|
|
1906
1915
|
if (initArgs?.wdaHost || initArgs?.wdaPort || initArgs?.sessionId) {
|
|
1907
1916
|
const wdaHost = initArgs.wdaHost ?? 'localhost';
|
|
1908
1917
|
const wdaPort = initArgs.wdaPort ?? 'default';
|
|
@@ -1929,7 +1938,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
|
|
|
1929
1938
|
this.agent = void 0;
|
|
1930
1939
|
}
|
|
1931
1940
|
if (this.agent) return this.agent;
|
|
1932
|
-
agent_tools_debug('Creating iOS agent with WebDriverAgent options
|
|
1941
|
+
agent_tools_debug('Creating iOS agent with WebDriverAgent options');
|
|
1933
1942
|
const reportOptions = this.readCliReportAgentOptions();
|
|
1934
1943
|
this.agent = await agentFromWebDriverAgent({
|
|
1935
1944
|
autoDismissKeyboard: false,
|
|
@@ -1996,7 +2005,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
|
|
|
1996
2005
|
const tools = new IOSMidsceneTools();
|
|
1997
2006
|
runToolsCLI(tools, 'midscene-ios', {
|
|
1998
2007
|
stripPrefix: 'ios_',
|
|
1999
|
-
version: "1.13.
|
|
2008
|
+
version: "1.13.4-beta-20260924030824.0",
|
|
2000
2009
|
extraCommands: createReportCliCommands()
|
|
2001
2010
|
}).catch((e)=>{
|
|
2002
2011
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -6,11 +6,12 @@ import { DEFAULT_WDA_PORT, PLAYGROUND_SERVER_PORT } from "@midscene/shared/const
|
|
|
6
6
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
7
7
|
import { getDebug } from "@midscene/shared/logger";
|
|
8
8
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
9
|
-
import { WDAManager, WebDriverClient } from "@midscene/webdriver";
|
|
9
|
+
import { WDAManager, WebDriverClient, normalizeWebDriverBaseUrl } from "@midscene/webdriver";
|
|
10
10
|
import { Agent } from "@midscene/core/agent";
|
|
11
11
|
import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE, overrideAIConfig } from "@midscene/shared/env";
|
|
12
12
|
import { createAgentTestRunnerNodeDefinition } from "@midscene/core/agent/test";
|
|
13
13
|
import { z as v4_z } from "zod/v4";
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
14
15
|
import { agentBehaviorInitArgShape, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/agent-tools/agent-behavior-init-args";
|
|
15
16
|
import { BaseMidsceneTools } from "@midscene/shared/agent-tools/base-tools";
|
|
16
17
|
import { exec } from "node:child_process";
|
|
@@ -1474,11 +1475,14 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1474
1475
|
this.wdaBackend = new IOSWebDriverClient({
|
|
1475
1476
|
port: wdaPort,
|
|
1476
1477
|
host: wdaHost,
|
|
1478
|
+
...options?.wdaBaseUrl !== void 0 ? {
|
|
1479
|
+
baseUrl: options.wdaBaseUrl
|
|
1480
|
+
} : {},
|
|
1477
1481
|
...options?.sessionId ? {
|
|
1478
1482
|
sessionId: options.sessionId
|
|
1479
1483
|
} : {}
|
|
1480
1484
|
});
|
|
1481
|
-
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost);
|
|
1485
|
+
this.wdaManager = WDAManager.getInstance(wdaPort, wdaHost, options?.wdaBaseUrl);
|
|
1482
1486
|
this.mjpegStreamUrl = `http://${wdaHost}:${mjpegPort}`;
|
|
1483
1487
|
if (options?.wdaMjpegFrameSource?.enabled) this.openFrameSource = ()=>this.openMjpegFrameSource();
|
|
1484
1488
|
}
|
|
@@ -1898,6 +1902,7 @@ function agent_tools_define_property(obj, key, value) {
|
|
|
1898
1902
|
}
|
|
1899
1903
|
const agent_tools_debug = getDebug('agent-tools:ios');
|
|
1900
1904
|
const iosInitArgShape = {
|
|
1905
|
+
wdaBaseUrl: z.string().optional().describe('Full WebDriverAgent API base URL, including gateway path prefix'),
|
|
1901
1906
|
wdaHost: z.string().optional().describe('WebDriverAgent host, defaults to localhost'),
|
|
1902
1907
|
wdaPort: z.number().optional().describe('WebDriverAgent port'),
|
|
1903
1908
|
sessionId: z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
|
|
@@ -1908,6 +1913,10 @@ const iosInitArgShape = {
|
|
|
1908
1913
|
...agentBehaviorInitArgShape
|
|
1909
1914
|
};
|
|
1910
1915
|
function getTargetIdentity(initArgs) {
|
|
1916
|
+
if (initArgs?.wdaBaseUrl) {
|
|
1917
|
+
const fingerprint = createHash('sha256').update(`${initArgs.wdaBaseUrl}\0${initArgs.sessionId ?? ''}`).digest('hex').slice(0, 12);
|
|
1918
|
+
return `wda-${fingerprint}`;
|
|
1919
|
+
}
|
|
1911
1920
|
if (initArgs?.wdaHost || initArgs?.wdaPort || initArgs?.sessionId) {
|
|
1912
1921
|
const wdaHost = initArgs.wdaHost ?? 'localhost';
|
|
1913
1922
|
const wdaPort = initArgs.wdaPort ?? 'default';
|
|
@@ -1934,7 +1943,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
|
|
|
1934
1943
|
this.agent = void 0;
|
|
1935
1944
|
}
|
|
1936
1945
|
if (this.agent) return this.agent;
|
|
1937
|
-
agent_tools_debug('Creating iOS agent with WebDriverAgent options
|
|
1946
|
+
agent_tools_debug('Creating iOS agent with WebDriverAgent options');
|
|
1938
1947
|
const reportOptions = this.readCliReportAgentOptions();
|
|
1939
1948
|
this.agent = await agentFromWebDriverAgent({
|
|
1940
1949
|
autoDismissKeyboard: false,
|
|
@@ -2093,6 +2102,13 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
2093
2102
|
defaultValue: DEFAULT_WDA_PORT,
|
|
2094
2103
|
placeholder: DEFAULT_WDA_PORT.toString()
|
|
2095
2104
|
},
|
|
2105
|
+
{
|
|
2106
|
+
key: 'baseUrl',
|
|
2107
|
+
label: 'WebDriverAgent base URL (optional)',
|
|
2108
|
+
type: 'text',
|
|
2109
|
+
required: false,
|
|
2110
|
+
placeholder: 'https://gateway.example/device/wda'
|
|
2111
|
+
},
|
|
2096
2112
|
{
|
|
2097
2113
|
key: 'sessionId',
|
|
2098
2114
|
label: 'WebDriverAgent session ID',
|
|
@@ -2104,21 +2120,26 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
2104
2120
|
};
|
|
2105
2121
|
},
|
|
2106
2122
|
async createSession (input) {
|
|
2123
|
+
const baseUrl = 'string' == typeof input?.baseUrl && input.baseUrl.trim() ? normalizeWebDriverBaseUrl(input.baseUrl.trim()) : void 0;
|
|
2107
2124
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
2108
|
-
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
2125
|
+
const port = baseUrl ? DEFAULT_WDA_PORT : 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
2109
2126
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
2110
2127
|
const sessionId = 'string' == typeof input?.sessionId && input.sessionId.trim() ? input.sessionId.trim() : void 0;
|
|
2111
2128
|
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
2112
2129
|
...options?.getAgentOptions?.(),
|
|
2113
2130
|
wdaHost: host,
|
|
2114
2131
|
wdaPort: port,
|
|
2132
|
+
...baseUrl ? {
|
|
2133
|
+
wdaBaseUrl: baseUrl
|
|
2134
|
+
} : {},
|
|
2115
2135
|
...sessionId ? {
|
|
2116
2136
|
sessionId
|
|
2117
2137
|
} : {}
|
|
2118
2138
|
});
|
|
2119
2139
|
const agent = await connectAgent();
|
|
2120
2140
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
2121
|
-
const
|
|
2141
|
+
const gatewayUrl = baseUrl ? new URL(baseUrl) : void 0;
|
|
2142
|
+
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : gatewayUrl ? `${gatewayUrl.host} (WDA gateway)` : `${host}:${port}`;
|
|
2122
2143
|
return {
|
|
2123
2144
|
agent,
|
|
2124
2145
|
agentFactory: connectAgent,
|
|
@@ -2127,8 +2148,8 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
2127
2148
|
}),
|
|
2128
2149
|
displayName,
|
|
2129
2150
|
metadata: {
|
|
2130
|
-
wdaHost: host,
|
|
2131
|
-
wdaPort: port,
|
|
2151
|
+
wdaHost: gatewayUrl?.hostname ?? host,
|
|
2152
|
+
wdaPort: gatewayUrl ? Number(gatewayUrl.port || ('https:' === gatewayUrl.protocol ? 443 : 80)) : port,
|
|
2132
2153
|
...sessionId ? {
|
|
2133
2154
|
sessionId
|
|
2134
2155
|
} : {},
|
package/dist/lib/bin.js
CHANGED
|
@@ -141,6 +141,7 @@ var __webpack_exports__ = {};
|
|
|
141
141
|
const playground_namespaceObject = require("@midscene/playground");
|
|
142
142
|
const constants_namespaceObject = require("@midscene/shared/constants");
|
|
143
143
|
const node_namespaceObject = require("@midscene/shared/node");
|
|
144
|
+
const webdriver_namespaceObject = require("@midscene/webdriver");
|
|
144
145
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
145
146
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
146
147
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
@@ -335,7 +336,6 @@ var __webpack_exports__ = {};
|
|
|
335
336
|
const device_namespaceObject = require("@midscene/core/device");
|
|
336
337
|
const core_utils_namespaceObject = require("@midscene/core/utils");
|
|
337
338
|
const img_namespaceObject = require("@midscene/shared/img");
|
|
338
|
-
const webdriver_namespaceObject = require("@midscene/webdriver");
|
|
339
339
|
const keyboardAccessoryToolbarGeometry = {
|
|
340
340
|
minHeight: 24,
|
|
341
341
|
maxHeight: 80,
|
|
@@ -1791,11 +1791,14 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1791
1791
|
this.wdaBackend = new IOSWebDriverClient({
|
|
1792
1792
|
port: wdaPort,
|
|
1793
1793
|
host: wdaHost,
|
|
1794
|
+
...options?.wdaBaseUrl !== void 0 ? {
|
|
1795
|
+
baseUrl: options.wdaBaseUrl
|
|
1796
|
+
} : {},
|
|
1794
1797
|
...options?.sessionId ? {
|
|
1795
1798
|
sessionId: options.sessionId
|
|
1796
1799
|
} : {}
|
|
1797
1800
|
});
|
|
1798
|
-
this.wdaManager = webdriver_namespaceObject.WDAManager.getInstance(wdaPort, wdaHost);
|
|
1801
|
+
this.wdaManager = webdriver_namespaceObject.WDAManager.getInstance(wdaPort, wdaHost, options?.wdaBaseUrl);
|
|
1799
1802
|
this.mjpegStreamUrl = `http://${wdaHost}:${mjpegPort}`;
|
|
1800
1803
|
if (options?.wdaMjpegFrameSource?.enabled) this.openFrameSource = ()=>this.openMjpegFrameSource();
|
|
1801
1804
|
}
|
|
@@ -1973,6 +1976,13 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1973
1976
|
defaultValue: constants_namespaceObject.DEFAULT_WDA_PORT,
|
|
1974
1977
|
placeholder: constants_namespaceObject.DEFAULT_WDA_PORT.toString()
|
|
1975
1978
|
},
|
|
1979
|
+
{
|
|
1980
|
+
key: 'baseUrl',
|
|
1981
|
+
label: 'WebDriverAgent base URL (optional)',
|
|
1982
|
+
type: 'text',
|
|
1983
|
+
required: false,
|
|
1984
|
+
placeholder: 'https://gateway.example/device/wda'
|
|
1985
|
+
},
|
|
1976
1986
|
{
|
|
1977
1987
|
key: 'sessionId',
|
|
1978
1988
|
label: 'WebDriverAgent session ID',
|
|
@@ -1984,21 +1994,26 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1984
1994
|
};
|
|
1985
1995
|
},
|
|
1986
1996
|
async createSession (input) {
|
|
1997
|
+
const baseUrl = 'string' == typeof input?.baseUrl && input.baseUrl.trim() ? (0, webdriver_namespaceObject.normalizeWebDriverBaseUrl)(input.baseUrl.trim()) : void 0;
|
|
1987
1998
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1988
|
-
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
1999
|
+
const port = baseUrl ? constants_namespaceObject.DEFAULT_WDA_PORT : 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
1989
2000
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1990
2001
|
const sessionId = 'string' == typeof input?.sessionId && input.sessionId.trim() ? input.sessionId.trim() : void 0;
|
|
1991
2002
|
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1992
2003
|
...options?.getAgentOptions?.(),
|
|
1993
2004
|
wdaHost: host,
|
|
1994
2005
|
wdaPort: port,
|
|
2006
|
+
...baseUrl ? {
|
|
2007
|
+
wdaBaseUrl: baseUrl
|
|
2008
|
+
} : {},
|
|
1995
2009
|
...sessionId ? {
|
|
1996
2010
|
sessionId
|
|
1997
2011
|
} : {}
|
|
1998
2012
|
});
|
|
1999
2013
|
const agent = await connectAgent();
|
|
2000
2014
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
2001
|
-
const
|
|
2015
|
+
const gatewayUrl = baseUrl ? new URL(baseUrl) : void 0;
|
|
2016
|
+
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : gatewayUrl ? `${gatewayUrl.host} (WDA gateway)` : `${host}:${port}`;
|
|
2002
2017
|
return {
|
|
2003
2018
|
agent,
|
|
2004
2019
|
agentFactory: connectAgent,
|
|
@@ -2007,8 +2022,8 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
2007
2022
|
}),
|
|
2008
2023
|
displayName,
|
|
2009
2024
|
metadata: {
|
|
2010
|
-
wdaHost: host,
|
|
2011
|
-
wdaPort: port,
|
|
2025
|
+
wdaHost: gatewayUrl?.hostname ?? host,
|
|
2026
|
+
wdaPort: gatewayUrl ? Number(gatewayUrl.port || ('https:' === gatewayUrl.protocol ? 443 : 80)) : port,
|
|
2012
2027
|
...sessionId ? {
|
|
2013
2028
|
sessionId
|
|
2014
2029
|
} : {},
|
package/dist/lib/cli.js
CHANGED
|
@@ -138,6 +138,7 @@ var __webpack_exports__ = {};
|
|
|
138
138
|
(()=>{
|
|
139
139
|
const core_namespaceObject = require("@midscene/core");
|
|
140
140
|
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
141
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
141
142
|
const agent_behavior_init_args_namespaceObject = require("@midscene/shared/agent-tools/agent-behavior-init-args");
|
|
142
143
|
const base_tools_namespaceObject = require("@midscene/shared/agent-tools/base-tools");
|
|
143
144
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
@@ -1790,11 +1791,14 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1790
1791
|
this.wdaBackend = new IOSWebDriverClient({
|
|
1791
1792
|
port: wdaPort,
|
|
1792
1793
|
host: wdaHost,
|
|
1794
|
+
...options?.wdaBaseUrl !== void 0 ? {
|
|
1795
|
+
baseUrl: options.wdaBaseUrl
|
|
1796
|
+
} : {},
|
|
1793
1797
|
...options?.sessionId ? {
|
|
1794
1798
|
sessionId: options.sessionId
|
|
1795
1799
|
} : {}
|
|
1796
1800
|
});
|
|
1797
|
-
this.wdaManager = webdriver_namespaceObject.WDAManager.getInstance(wdaPort, wdaHost);
|
|
1801
|
+
this.wdaManager = webdriver_namespaceObject.WDAManager.getInstance(wdaPort, wdaHost, options?.wdaBaseUrl);
|
|
1798
1802
|
this.mjpegStreamUrl = `http://${wdaHost}:${mjpegPort}`;
|
|
1799
1803
|
if (options?.wdaMjpegFrameSource?.enabled) this.openFrameSource = ()=>this.openMjpegFrameSource();
|
|
1800
1804
|
}
|
|
@@ -1935,6 +1939,7 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1935
1939
|
}
|
|
1936
1940
|
const agent_tools_debug = (0, logger_namespaceObject.getDebug)('agent-tools:ios');
|
|
1937
1941
|
const iosInitArgShape = {
|
|
1942
|
+
wdaBaseUrl: core_namespaceObject.z.string().optional().describe('Full WebDriverAgent API base URL, including gateway path prefix'),
|
|
1938
1943
|
wdaHost: core_namespaceObject.z.string().optional().describe('WebDriverAgent host, defaults to localhost'),
|
|
1939
1944
|
wdaPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent port'),
|
|
1940
1945
|
sessionId: core_namespaceObject.z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
|
|
@@ -1945,6 +1950,10 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1945
1950
|
...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
|
|
1946
1951
|
};
|
|
1947
1952
|
function getTargetIdentity(initArgs) {
|
|
1953
|
+
if (initArgs?.wdaBaseUrl) {
|
|
1954
|
+
const fingerprint = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(`${initArgs.wdaBaseUrl}\0${initArgs.sessionId ?? ''}`).digest('hex').slice(0, 12);
|
|
1955
|
+
return `wda-${fingerprint}`;
|
|
1956
|
+
}
|
|
1948
1957
|
if (initArgs?.wdaHost || initArgs?.wdaPort || initArgs?.sessionId) {
|
|
1949
1958
|
const wdaHost = initArgs.wdaHost ?? 'localhost';
|
|
1950
1959
|
const wdaPort = initArgs.wdaPort ?? 'default';
|
|
@@ -1971,7 +1980,7 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1971
1980
|
this.agent = void 0;
|
|
1972
1981
|
}
|
|
1973
1982
|
if (this.agent) return this.agent;
|
|
1974
|
-
agent_tools_debug('Creating iOS agent with WebDriverAgent options
|
|
1983
|
+
agent_tools_debug('Creating iOS agent with WebDriverAgent options');
|
|
1975
1984
|
const reportOptions = this.readCliReportAgentOptions();
|
|
1976
1985
|
this.agent = await agentFromWebDriverAgent({
|
|
1977
1986
|
autoDismissKeyboard: false,
|
|
@@ -2038,7 +2047,7 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
2038
2047
|
const tools = new IOSMidsceneTools();
|
|
2039
2048
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-ios', {
|
|
2040
2049
|
stripPrefix: 'ios_',
|
|
2041
|
-
version: "1.13.
|
|
2050
|
+
version: "1.13.4-beta-20260924030824.0",
|
|
2042
2051
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
2043
2052
|
}).catch((e)=>{
|
|
2044
2053
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -1631,11 +1631,14 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1631
1631
|
this.wdaBackend = new IOSWebDriverClient({
|
|
1632
1632
|
port: wdaPort,
|
|
1633
1633
|
host: wdaHost,
|
|
1634
|
+
...options?.wdaBaseUrl !== void 0 ? {
|
|
1635
|
+
baseUrl: options.wdaBaseUrl
|
|
1636
|
+
} : {},
|
|
1634
1637
|
...options?.sessionId ? {
|
|
1635
1638
|
sessionId: options.sessionId
|
|
1636
1639
|
} : {}
|
|
1637
1640
|
});
|
|
1638
|
-
this.wdaManager = webdriver_namespaceObject.WDAManager.getInstance(wdaPort, wdaHost);
|
|
1641
|
+
this.wdaManager = webdriver_namespaceObject.WDAManager.getInstance(wdaPort, wdaHost, options?.wdaBaseUrl);
|
|
1639
1642
|
this.mjpegStreamUrl = `http://${wdaHost}:${mjpegPort}`;
|
|
1640
1643
|
if (options?.wdaMjpegFrameSource?.enabled) this.openFrameSource = ()=>this.openMjpegFrameSource();
|
|
1641
1644
|
}
|
|
@@ -1950,6 +1953,7 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1950
1953
|
await device.connect();
|
|
1951
1954
|
return new IOSAgent(device, opts);
|
|
1952
1955
|
}
|
|
1956
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
1953
1957
|
const agent_behavior_init_args_namespaceObject = require("@midscene/shared/agent-tools/agent-behavior-init-args");
|
|
1954
1958
|
const base_tools_namespaceObject = require("@midscene/shared/agent-tools/base-tools");
|
|
1955
1959
|
function agent_tools_define_property(obj, key, value) {
|
|
@@ -1964,6 +1968,7 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1964
1968
|
}
|
|
1965
1969
|
const agent_tools_debug = (0, logger_namespaceObject.getDebug)('agent-tools:ios');
|
|
1966
1970
|
const iosInitArgShape = {
|
|
1971
|
+
wdaBaseUrl: core_namespaceObject.z.string().optional().describe('Full WebDriverAgent API base URL, including gateway path prefix'),
|
|
1967
1972
|
wdaHost: core_namespaceObject.z.string().optional().describe('WebDriverAgent host, defaults to localhost'),
|
|
1968
1973
|
wdaPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent port'),
|
|
1969
1974
|
sessionId: core_namespaceObject.z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
|
|
@@ -1974,6 +1979,10 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
1974
1979
|
...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
|
|
1975
1980
|
};
|
|
1976
1981
|
function getTargetIdentity(initArgs) {
|
|
1982
|
+
if (initArgs?.wdaBaseUrl) {
|
|
1983
|
+
const fingerprint = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(`${initArgs.wdaBaseUrl}\0${initArgs.sessionId ?? ''}`).digest('hex').slice(0, 12);
|
|
1984
|
+
return `wda-${fingerprint}`;
|
|
1985
|
+
}
|
|
1977
1986
|
if (initArgs?.wdaHost || initArgs?.wdaPort || initArgs?.sessionId) {
|
|
1978
1987
|
const wdaHost = initArgs.wdaHost ?? 'localhost';
|
|
1979
1988
|
const wdaPort = initArgs.wdaPort ?? 'default';
|
|
@@ -2000,7 +2009,7 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
2000
2009
|
this.agent = void 0;
|
|
2001
2010
|
}
|
|
2002
2011
|
if (this.agent) return this.agent;
|
|
2003
|
-
agent_tools_debug('Creating iOS agent with WebDriverAgent options
|
|
2012
|
+
agent_tools_debug('Creating iOS agent with WebDriverAgent options');
|
|
2004
2013
|
const reportOptions = this.readCliReportAgentOptions();
|
|
2005
2014
|
this.agent = await agentFromWebDriverAgent({
|
|
2006
2015
|
autoDismissKeyboard: false,
|
|
@@ -2166,6 +2175,13 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
2166
2175
|
defaultValue: constants_namespaceObject.DEFAULT_WDA_PORT,
|
|
2167
2176
|
placeholder: constants_namespaceObject.DEFAULT_WDA_PORT.toString()
|
|
2168
2177
|
},
|
|
2178
|
+
{
|
|
2179
|
+
key: 'baseUrl',
|
|
2180
|
+
label: 'WebDriverAgent base URL (optional)',
|
|
2181
|
+
type: 'text',
|
|
2182
|
+
required: false,
|
|
2183
|
+
placeholder: 'https://gateway.example/device/wda'
|
|
2184
|
+
},
|
|
2169
2185
|
{
|
|
2170
2186
|
key: 'sessionId',
|
|
2171
2187
|
label: 'WebDriverAgent session ID',
|
|
@@ -2177,21 +2193,26 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
2177
2193
|
};
|
|
2178
2194
|
},
|
|
2179
2195
|
async createSession (input) {
|
|
2196
|
+
const baseUrl = 'string' == typeof input?.baseUrl && input.baseUrl.trim() ? (0, webdriver_namespaceObject.normalizeWebDriverBaseUrl)(input.baseUrl.trim()) : void 0;
|
|
2180
2197
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
2181
|
-
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
2198
|
+
const port = baseUrl ? constants_namespaceObject.DEFAULT_WDA_PORT : 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
2182
2199
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
2183
2200
|
const sessionId = 'string' == typeof input?.sessionId && input.sessionId.trim() ? input.sessionId.trim() : void 0;
|
|
2184
2201
|
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
2185
2202
|
...options?.getAgentOptions?.(),
|
|
2186
2203
|
wdaHost: host,
|
|
2187
2204
|
wdaPort: port,
|
|
2205
|
+
...baseUrl ? {
|
|
2206
|
+
wdaBaseUrl: baseUrl
|
|
2207
|
+
} : {},
|
|
2188
2208
|
...sessionId ? {
|
|
2189
2209
|
sessionId
|
|
2190
2210
|
} : {}
|
|
2191
2211
|
});
|
|
2192
2212
|
const agent = await connectAgent();
|
|
2193
2213
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
2194
|
-
const
|
|
2214
|
+
const gatewayUrl = baseUrl ? new URL(baseUrl) : void 0;
|
|
2215
|
+
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : gatewayUrl ? `${gatewayUrl.host} (WDA gateway)` : `${host}:${port}`;
|
|
2195
2216
|
return {
|
|
2196
2217
|
agent,
|
|
2197
2218
|
agentFactory: connectAgent,
|
|
@@ -2200,8 +2221,8 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
|
|
|
2200
2221
|
}),
|
|
2201
2222
|
displayName,
|
|
2202
2223
|
metadata: {
|
|
2203
|
-
wdaHost: host,
|
|
2204
|
-
wdaPort: port,
|
|
2224
|
+
wdaHost: gatewayUrl?.hostname ?? host,
|
|
2225
|
+
wdaPort: gatewayUrl ? Number(gatewayUrl.port || ('https:' === gatewayUrl.protocol ? 443 : 80)) : port,
|
|
2205
2226
|
...sessionId ? {
|
|
2206
2227
|
sessionId
|
|
2207
2228
|
} : {},
|
package/dist/types/index.d.ts
CHANGED
|
@@ -221,7 +221,7 @@ export declare class IOSDevice implements AbstractInterface {
|
|
|
221
221
|
destroy(): Promise<void>;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
declare type IOSInitArgs = AgentBehaviorInitArgs & Pick<IOSDeviceOpt, 'wdaHost' | 'wdaPort' | 'sessionId' | 'wdaMjpegPort' | 'wdaMjpegFrameSource'>;
|
|
224
|
+
declare type IOSInitArgs = AgentBehaviorInitArgs & Pick<IOSDeviceOpt, 'wdaBaseUrl' | 'wdaHost' | 'wdaPort' | 'sessionId' | 'wdaMjpegPort' | 'wdaMjpegFrameSource'>;
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
227
|
* iOS-specific tools manager
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/ios",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.4-beta-20260924030824.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/midscene.git",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"@inquirer/prompts": "^7.8.6",
|
|
50
50
|
"open": "10.1.0",
|
|
51
51
|
"zod": "^3.25.1",
|
|
52
|
-
"@midscene/
|
|
53
|
-
"@midscene/
|
|
54
|
-
"@midscene/
|
|
55
|
-
"@midscene/
|
|
52
|
+
"@midscene/core": "1.13.4-beta-20260924030824.0",
|
|
53
|
+
"@midscene/webdriver": "1.13.4-beta-20260924030824.0",
|
|
54
|
+
"@midscene/shared": "1.13.4-beta-20260924030824.0",
|
|
55
|
+
"@midscene/playground": "1.13.4-beta-20260924030824.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@rslib/core": "^0.18.3",
|
package/static/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.8bb5dc6e.js"></script><script defer src="/static/js/652.6a7cf351.js"></script><script defer src="/static/js/index.
|
|
1
|
+
<!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.8bb5dc6e.js"></script><script defer src="/static/js/652.6a7cf351.js"></script><script defer src="/static/js/index.e149e49f.js"></script><link href="/static/css/index.67caac18.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|