appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
77 lines • 2.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZipConduitClient = void 0;
const logger_1 = require("../logger");
/**
* Thin wrapper around the RemoteXPC streaming `zip_conduit` service.
*
* `zip_conduit` streams an `.ipa` straight into the on-device installer, avoiding the separate AFC upload +
* `installation_proxy` round trip. It is RemoteXPC-only (iOS/tvOS 18+ with an
* active tunnel) and only accepts `.ipa` archives, so callers must keep a
* fallback for unpacked `.app` bundles and older devices.
*/
class ZipConduitClient {
service;
_log;
_lastLoggedProgress;
constructor(service, _log = logger_1.log) {
this.service = service;
this._log = _log;
}
/**
* Create a zip_conduit client for the device
*
* @param udid - Device UDID
* @param logger - Optional logger
* @returns A connected client, or `null` when zip_conduit is unavailable
*/
static async create(udid, logger = logger_1.log, facade) {
const service = facade
? await facade.attemptService('zip_conduit', (Services) => {
if (typeof Services.startZipConduitService !== 'function') {
throw new Error('startZipConduitService is not available');
}
return Services.startZipConduitService(udid);
})
: null;
if (!service) {
return null;
}
return new ZipConduitClient(service, logger);
}
/**
* Stream-install an `.ipa`. Handles both fresh installs and upgrades; the
* device resolves the target by bundle id from the archive contents, so no
* separate upgrade call is needed.
*
* @param ipaPath - Absolute path to the local `.ipa`
* @param opts - Install options
*/
async install(ipaPath, opts = {}) {
this._lastLoggedProgress = undefined;
await this.service.install(ipaPath, {
timeoutMs: opts.timeoutMs,
progress: ({ percent, status }) => this.logInstallProgress(percent, status),
});
}
/**
* Close the underlying socket.
*/
async close() {
try {
this.service.close();
}
catch (err) {
this._log.debug(`Error closing zip_conduit service: ${err.message}`);
}
}
logInstallProgress(percent, status) {
if (percent === this._lastLoggedProgress?.percent && status === this._lastLoggedProgress?.status) {
return;
}
this._lastLoggedProgress = { percent, status };
this._log.debug(`App install progress: ${percent}%${status ? ` (${status})` : ''}`);
}
}
exports.ZipConduitClient = ZipConduitClient;
//# sourceMappingURL=zip-conduit-client.js.map