appium-android-driver
Version:
Android UiAutomator and Chrome support for Appium
32 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WEBVIEWS_DETAILS_CACHE = void 0;
exports.toDetailsCacheKey = toDetailsCacheKey;
exports.getWebviewDetails = getWebviewDetails;
const lru_cache_1 = require("lru-cache");
exports.WEBVIEWS_DETAILS_CACHE = new lru_cache_1.LRUCache({
max: 100,
updateAgeOnGet: true,
});
/**
* Generates a cache key for webview details based on the device ID and webview name.
*
* @param adb - The ADB instance (may be null/undefined)
* @param webview - The webview name
* @returns A cache key string in the format `deviceId:webview`
*/
function toDetailsCacheKey(adb, webview) {
return `${adb?.curDeviceId}:${webview}`;
}
/**
* Retrieves web view details previously cached by `getWebviews` call.
*
* @param adb - The ADB instance (may be null/undefined)
* @param webview - The webview name
* @returns The cached webview details, or undefined if not found
*/
function getWebviewDetails(adb, webview) {
const key = toDetailsCacheKey(adb, webview);
return exports.WEBVIEWS_DETAILS_CACHE.get(key);
}
//# sourceMappingURL=cache.js.map