New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lc2-driver

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lc2-driver - npm Package Compare versions

Comparing version 1.2.8 to 1.2.9

src/event/keymap.js

4

index.js

@@ -107,4 +107,4 @@ const mouse = require('./src/device/mouse');

},
keyup() {
return keyboard.up();
keyup({code}) {
return keyboard.up(code);
},

@@ -111,0 +111,0 @@ keypress({code}) {

{
"name": "lc2-driver",
"version": "1.2.8",
"version": "1.2.9",
"description": "",

@@ -8,3 +8,3 @@ "main": "index.js",

"test": "mocha test/*-spec.js",
"start": "webpack-dev-server --hot --no-info --port 8400 --host 0.0.0.0",
"start": "webpack-dev-server --hot --port 8400 --host 0.0.0.0",
"build": "webpack --config webpack.prod.js --progress"

@@ -11,0 +11,0 @@ },

@@ -82,8 +82,2 @@ const {createUIEvent, createMouseEvent, createKeyboardEvent} = require('./event');

this.element.dispatchEvent(createMouseEvent('mousedown'));
this.element.dispatchEvent(createUIEvent('focus'));
this.element.dispatchEvent(createMouseEvent('mouseup'));
this.element.dispatchEvent(createMouseEvent('click'));
this.element.value = String(value);

@@ -112,6 +106,2 @@

this.element.dispatchEvent(createMouseEvent('mousedown'));
this.element.dispatchEvent(createUIEvent('focus'));
this.element.dispatchEvent(createMouseEvent('mouseup'));
const clickEvent = createMouseEvent('click');

@@ -164,6 +154,2 @@ clickEvent.preventDefault();

this.element.dispatchEvent(createMouseEvent('mousedown'));
this.element.dispatchEvent(createUIEvent('focus'));
this.element.dispatchEvent(createMouseEvent('mouseup'));
this.element.dispatchEvent(createMouseEvent('click'));

@@ -170,0 +156,0 @@ optionElement.dispatchEvent(createMouseEvent('mousedown'));

@@ -10,3 +10,4 @@ /**

const Button = require('../component/button');
const {location, keyboardMap} = require('./mapping');
const {createKeyboardEvent} = require('../../event');
const {page} = require('../../viewport');

@@ -22,13 +23,2 @@ const modifierState = {

const state = {
key: '',
code: '',
location: location.DOM_KEY_LOCATION_STANDARD
};
const readOnlyState = {
keyCode: 0,
which: 0
};
class KeyboardButton extends Button {

@@ -39,11 +29,11 @@ constructor(options) {

down(code) {
return super.down().then(() => {
this.setKeyState(code);
return this.$dispatch('keydown');
return Promise.resolve().then(() => {
return this.$dispatch('keydown', code);
});
}
up() {
return this.$checkReleased().then(() => {
this.$dispatch('keyup');
up(code) {
return Promise.resolve().then(() => {
this.$dispatch('keyup', code);
this.$dispatch('keypress', code);
this.upFn();

@@ -53,44 +43,14 @@ }, this.$stdOut);

press(code) {
return super.down().then(() => {
this.setKeyState(code);
return this.$dispatch('keypress');
}).then(() => {
return this.$checkReleased().then(() => {
this.upFn();
}, this.$stdOut);
});
}
setKeyState(code) {
if(keyboardMap[code] === undefined) {
state.key = state.code = code;
state.location = location.DOM_KEY_LOCATION_STANDARD;
readOnlyState.keyCode = readOnlyState.which = 0;
return;
$dispatch(type, code) {
if (page.focusElement !== null) {
const keyboardEvent = createKeyboardEvent(type, code);
page.focusElement.dispatchEvent(keyboardEvent);
}
state.key = keyboardMap[code].key;
state.code = code;
state.location = keyboardMap[code].location;
readOnlyState.keyCode = readOnlyState.which = keyboardMap[code].keyCode;
}
$dispatch(type) {
keyboard.logicAction(type);
}
}
const keyboard = exports.keyboard = Object.assign(new EventEmitter(), {
state() {
return Object.assign({}, state);
},
readOnlyState() {
return Object.assign({}, readOnlyState);
},
logicAction(type) {
this.emit('handle', type);
},
exports.keyboard = Object.assign(new EventEmitter(), {
keyboard: new KeyboardButton({}),
up() {
return this.keyboard.up();
up(key) {
return this.keyboard.up(key);
},

@@ -101,4 +61,6 @@ down(key) {

press(key) {
return this.keyboard.press(key);
return Promise.resolve()
.then(() => this.down(key))
.then(() => this.up(key));
}
});
const mouse = require('../device/mouse');
const {modifierState, keyboard} = require('../device/keyboard');
const {MouseEvent, UIEvent, KeyboardEvent, FocusEvent} = require('./constructor');
const {queryKeyboardEventMap} = require('./keymap');

@@ -54,3 +55,3 @@ const viewport = {

exports.createKeyboardEvent = function (type) {
exports.createKeyboardEvent = function (type, code) {
if(validKeyboardEvent.indexOf(type) === -1) {

@@ -60,10 +61,12 @@ throw new Error(`Invalid keyboard event type: ${type}`);

const keyState = keyboard.state();
const keyboardEventInitOptions = Object.assign({}, defaultOptions, keyState, modifierState);
const {normal, readOnly} = queryKeyboardEventMap(code);
const keyboardEventInitOptions = Object.assign({}, defaultOptions, normal, modifierState);
const event = new KeyboardEvent(type, keyboardEventInitOptions);
const readOnlyState = keyboard.readOnlyState();
for( let key in readOnlyState) {
for(let key in readOnly) {
delete event[key];
Object.defineProperty(event, key, {value: readOnlyState[key]});
Object.defineProperty(event, key, {value: readOnly[key]});
}
return Object.assign(event, {lc2: true});

@@ -70,0 +73,0 @@ };

'use strict';
const mouse = require('./device/mouse');
const {keyboard} = require('./device/keyboard');
const element = require('./element');
const {createMouseEvent, createKeyboardEvent, createUIEvent, createFocusEvent} = require('./event');
const {createMouseEvent, createUIEvent, createFocusEvent} = require('./event');
const {updateHoverSheet} = require('./hover');

@@ -30,3 +29,3 @@ const driver = require('./emitter');

*/
setFocusElement(element) {
setFocusElement(element = null) {
if (element === this.focusElement) {

@@ -39,3 +38,3 @@ return;

this.focusElement = element && canFocused(element) ? element: null;
this.focusElement = element && canFocused(element) ? element: null;

@@ -111,3 +110,2 @@ this.focusElement && this.focusElement.dispatchEvent(createFocusEvent('focusin'));

dispatchEvent('mousedown');
// target.dispatchEvent(createUIEvent('focus'));
}

@@ -124,6 +122,2 @@ };

keyboard.on('handle', type => {
page.focusElement.dispatchEvent(createKeyboardEvent(type));
});
exports.page = page;

@@ -238,3 +238,3 @@ $(document).ready(function () {

return act.click({selector: _('input')}).then(() => {
return act.keydown('Enter');
return act.keydown({code: 'Enter'});
});

@@ -251,3 +251,3 @@ }, function ($, _) {

return act.click({selector: _('input')}).then(() => {
return act.keyup();
return act.keyup({code: 'Enter'});
});

@@ -260,7 +260,7 @@ }, function ($, _) {

it('keypress', function ($, _) {
document.onkeypress = function(ev) {
document.onkeydown = function(ev) {
keypressCode = ev.keyCode;
};
return act.click({selector: _('input')}).then(() => {
return act.keypress('Enter');
return act.keypress({code: 'Enter'});
});

@@ -267,0 +267,0 @@ }, function ($, _) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc