UNPKG

appium-android-driver

Version:

Android UiAutomator and Chrome support for Appium

58 lines 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.makeObsoleteContextUpdatedEvent = exports.makeContextUpdatedEvent = void 0; exports.makeLogEntryAddedEvent = makeLogEntryAddedEvent; const helpers_1 = require("../context/helpers"); const constants_1 = require("./constants"); function toContextUpdatedEvent(method, contextName) { return { method, params: { name: contextName, type: contextName === helpers_1.NATIVE_WIN ? 'NATIVE' : 'WEB', }, }; } const makeContextUpdatedEvent = (contextName, domain) => toContextUpdatedEvent((0, constants_1.CONTEXT_UPDATED_EVENT)(domain), contextName); exports.makeContextUpdatedEvent = makeContextUpdatedEvent; /** * @deprecated Use {@link makeContextUpdatedEvent} instead */ const makeObsoleteContextUpdatedEvent = (contextName) => toContextUpdatedEvent(constants_1.CONTEXT_UPDATED_EVENT_OBSOLETE, contextName); exports.makeObsoleteContextUpdatedEvent = makeObsoleteContextUpdatedEvent; /** * Builds a BiDi `log.entryAdded` event from a logcat entry. * * @param entry - Raw log line from the device * @param context - Active session context name * @param type - Log entry classification passed through to the event */ function makeLogEntryAddedEvent(entry, context, type) { return { context, method: constants_1.LOG_ENTRY_ADDED_EVENT, params: { type, level: adjustLogLevel(entry.level), source: { realm: '', context, }, text: entry.message, timestamp: entry.timestamp, }, }; } function adjustLogLevel(originalLevel) { const originalLevelLc = originalLevel?.toLowerCase(); switch (originalLevelLc) { case 'debug': case 'info': case 'warn': case 'error': return originalLevelLc; default: return 'info'; } } //# sourceMappingURL=models.js.map