macaca-android
Advanced tools
Comparing version 1.1.21 to 1.1.22
@@ -8,3 +8,2 @@ 'use strict'; | ||
const _ = require('./helper'); | ||
const keyMap = require('./key-map'); | ||
const pkg = require('../package.json'); | ||
@@ -73,17 +72,33 @@ | ||
/** | ||
see: https://github.com/macacajs/android-unicode#use-in-adb-shell | ||
*/ | ||
controllers.keys = function *(value) { | ||
if (Array.isArray(value)) { | ||
value = value.join('').split(''); | ||
value = value.join(''); | ||
var content = ''; | ||
if (!!~value.indexOf('[ADB_INPUT_TEXT]')) { | ||
value = value.replace('[ADB_INPUT_TEXT]', ''); | ||
content = `am broadcast -a ADB_INPUT_TEXT --es msg '${value}'`; | ||
yield this.adb.shell(content); | ||
} else if (!!~value.indexOf('[ADB_INPUT_CHARS]')) { | ||
value = value.replace('[ADB_INPUT_CHARS]', ''); | ||
content = `am broadcast -a ADB_INPUT_CHARS --eia chars '${value}'`; | ||
yield this.adb.shell(content); | ||
} else if (!!~value.indexOf('[ADB_INPUT_CODE]')) { | ||
value = value.replace('[ADB_INPUT_CODE]', ''); | ||
content = `am broadcast -a ADB_INPUT_CODE --ei code '${value}'`; | ||
yield this.adb.shell(content); | ||
} else if (!!~value.indexOf('[ADB_EDITOR_CODE]')) { | ||
value = value.replace('[ADB_EDITOR_CODE]', ''); | ||
content = `am broadcast -a ADB_EDITOR_CODE --ei code '${value}'`; | ||
yield this.adb.shell(content); | ||
} else { | ||
value = value.split(''); | ||
const keyActions = value.map(key => { | ||
return () => this.adb.input(`text "${key}"`); | ||
}); | ||
yield _.serialTasks.apply(null, keyActions); | ||
} | ||
const keyActions = value.map(key => { | ||
const keyEvent = keyMap[key]; | ||
if (keyEvent) { | ||
return () => this.adb.input(`keyevent ${keyEvent}`); | ||
} else { | ||
return () => this.adb.input(`text "${key}"`); | ||
} | ||
}); | ||
return yield _.serialTasks.apply(null, keyActions); | ||
return null; | ||
}; | ||
@@ -90,0 +105,0 @@ |
{ | ||
"name": "macaca-android", | ||
"version": "1.1.21", | ||
"version": "1.1.22", | ||
"description": "Macaca Android driver", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
22049
12
644