electrum-events
Advanced tools
Comparing version 1.3.0 to 1.4.0
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,2 +7,4 @@ value: true | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _getTextSelection = require('electrum-utils/src/get-text-selection.js'); | ||
@@ -16,4 +16,2 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -33,3 +31,3 @@ | ||
var EventHandlers = function () { | ||
let EventHandlers = function () { | ||
function EventHandlers(obj, bus) { | ||
@@ -39,8 +37,4 @@ _classCallCheck(this, EventHandlers); | ||
this._obj = obj; | ||
this._valueGetter = function (target) { | ||
return target.value; | ||
}; | ||
this._statesGetter = function (target) { | ||
return getStates(target); | ||
}; | ||
this._valueGetter = target => target.value; | ||
this._statesGetter = target => getStates(target); | ||
this._obj._eventHandlers = this; | ||
@@ -51,5 +45,3 @@ | ||
} else { | ||
this._busGetter = function () { | ||
return bus; | ||
}; | ||
this._busGetter = () => bus; | ||
} | ||
@@ -71,7 +63,3 @@ } | ||
value: function handleClick(ev) { | ||
var _this = this; | ||
this.notify(ev, function (e) { | ||
return _this.forwardDispatchEvent(e, 'action'); | ||
}); | ||
this.notify(ev, e => this.forwardDispatchEvent(e, 'action')); | ||
ev.stopPropagation(); | ||
@@ -82,10 +70,4 @@ } | ||
value: function handleFocus(ev) { | ||
var _this2 = this; | ||
this.notify(ev, function (e) { | ||
return _this2.forwardNotifyEvent(e, 'focus'); | ||
}); | ||
this.notify(ev, function (e) { | ||
return _this2.forwardDispatchEvent(e, 'focus'); | ||
}); | ||
this.notify(ev, e => this.forwardNotifyEvent(e, 'focus')); | ||
this.notify(ev, e => this.forwardDispatchEvent(e, 'focus')); | ||
ev.stopPropagation(); | ||
@@ -96,7 +78,3 @@ } | ||
value: function handleChange(ev) { | ||
var _this3 = this; | ||
this.notify(ev, function (e) { | ||
return _this3.forwardNotifyEvent(e, 'change'); | ||
}); | ||
this.notify(ev, e => this.forwardNotifyEvent(e, 'change')); | ||
ev.stopPropagation(); | ||
@@ -108,7 +86,3 @@ ev.preventDefault(); | ||
value: function handleKeyDown(ev) { | ||
var _this4 = this; | ||
this.notify(ev, function (e) { | ||
return _this4.forwardNotifyEvent(e, 'key-down'); | ||
}); | ||
this.notify(ev, e => this.forwardNotifyEvent(e, 'key-down')); | ||
} | ||
@@ -118,7 +92,3 @@ }, { | ||
value: function handleKeyUp(ev) { | ||
var _this5 = this; | ||
this.notify(ev, function (e) { | ||
return _this5.forwardNotifyEvent(e, 'key-up'); | ||
}); | ||
this.notify(ev, e => this.forwardNotifyEvent(e, 'key-up')); | ||
} | ||
@@ -128,7 +98,3 @@ }, { | ||
value: function handleKeyPress(ev) { | ||
var _this6 = this; | ||
this.notify(ev, function (e) { | ||
return _this6.forwardNotifyEvent(e, 'key-press'); | ||
}); | ||
this.notify(ev, e => this.forwardNotifyEvent(e, 'key-press')); | ||
} | ||
@@ -138,7 +104,3 @@ }, { | ||
value: function handleSelect(ev) { | ||
var _this7 = this; | ||
this.notify(ev, function (e) { | ||
return _this7.forwardNotifyEvent(e, 'select'); | ||
}); | ||
this.notify(ev, e => this.forwardNotifyEvent(e, 'select')); | ||
} | ||
@@ -159,6 +121,6 @@ }, { | ||
this.log(ev, source); | ||
var bus = this.bus; | ||
const bus = this.bus; | ||
if (bus && 'notify' in bus) { | ||
var target = ev.target; | ||
bus.notify.apply(bus, [this.props, this.getValue(target)].concat(_toConsumableArray(this.getStates(target)))); | ||
const target = ev.target; | ||
bus.notify(this.props, this.getValue(target), ...this.getStates(target)); | ||
} | ||
@@ -170,3 +132,3 @@ } | ||
this.log(ev, source); | ||
var bus = this.bus; | ||
const bus = this.bus; | ||
if (bus && 'dispatch' in bus) { | ||
@@ -183,3 +145,3 @@ bus.dispatch(this.props, source); | ||
} else { | ||
console.log(source + ': %O', ev); | ||
console.log(`${ source }: %O`, ev); | ||
} | ||
@@ -190,3 +152,3 @@ } | ||
key: 'component', | ||
get: function get() { | ||
get: function () { | ||
return this._obj; | ||
@@ -196,3 +158,3 @@ } | ||
key: 'props', | ||
get: function get() { | ||
get: function () { | ||
return this._obj.props; | ||
@@ -202,3 +164,3 @@ } | ||
key: 'bus', | ||
get: function get() { | ||
get: function () { | ||
return this._busGetter(this.props); | ||
@@ -208,6 +170,6 @@ } | ||
key: 'debug', | ||
get: function get() { | ||
get: function () { | ||
return !!this._debug; | ||
}, | ||
set: function set(value) { | ||
set: function (value) { | ||
this._debug = value; | ||
@@ -218,24 +180,20 @@ } | ||
value: function inject(obj, bus) { | ||
var eh = new EventHandlers(obj, bus); | ||
const eh = new EventHandlers(obj, bus); | ||
if (obj.getValue) { | ||
eh._valueGetter = function (target) { | ||
return obj.getValue(target); | ||
}; | ||
eh._valueGetter = target => obj.getValue(target); | ||
} | ||
if (obj.getStates) { | ||
eh._statesGetter = function (target) { | ||
return obj.getStates(target); | ||
}; | ||
eh._statesGetter = target => obj.getStates(target); | ||
} | ||
var existingOnFocus = obj.onFocus; | ||
var existingOnChange = obj.onChange; | ||
var existingOnKeyDown = obj.onKeyDown; | ||
var existingOnKeyPress = obj.onKeyPress; | ||
var existingOnKeyUp = obj.onKeyUp; | ||
var existingOnSelect = obj.onSelect; | ||
var existingOnClick = obj.onClick; | ||
const existingOnFocus = obj.onFocus; | ||
const existingOnChange = obj.onChange; | ||
const existingOnKeyDown = obj.onKeyDown; | ||
const existingOnKeyPress = obj.onKeyPress; | ||
const existingOnKeyUp = obj.onKeyUp; | ||
const existingOnSelect = obj.onSelect; | ||
const existingOnClick = obj.onClick; | ||
obj.onFocus = function (e) { | ||
obj.onFocus = e => { | ||
/* jshint expr: true */ | ||
@@ -245,3 +203,3 @@ existingOnFocus && existingOnFocus.call(obj, e); | ||
}; | ||
obj.onClick = function (e) { | ||
obj.onClick = e => { | ||
/* jshint expr: true */ | ||
@@ -251,3 +209,3 @@ existingOnClick && existingOnClick.call(obj, e); | ||
}; | ||
obj.onChange = function (e) { | ||
obj.onChange = e => { | ||
/* jshint expr: true */ | ||
@@ -257,3 +215,3 @@ existingOnChange && existingOnChange.call(obj, e); | ||
}; | ||
obj.onKeyDown = function (e) { | ||
obj.onKeyDown = e => { | ||
/* jshint expr: true */ | ||
@@ -263,3 +221,3 @@ existingOnKeyDown && existingOnKeyDown.call(obj, e); | ||
}; | ||
obj.onKeyUp = function (e) { | ||
obj.onKeyUp = e => { | ||
/* jshint expr: true */ | ||
@@ -269,3 +227,3 @@ existingOnKeyUp && existingOnKeyUp.call(obj, e); | ||
}; | ||
obj.onKeyPress = function (e) { | ||
obj.onKeyPress = e => { | ||
/* jshint expr: true */ | ||
@@ -275,3 +233,3 @@ existingOnKeyPress && existingOnKeyPress.call(obj, e); | ||
}; | ||
obj.onSelect = function (e) { | ||
obj.onSelect = e => { | ||
/* jshint expr: true */ | ||
@@ -278,0 +236,0 @@ existingOnSelect && existingOnSelect.call(obj, e); |
@@ -6,10 +6,10 @@ 'use strict'; | ||
}); | ||
exports.EventHandlers = undefined; | ||
var _eventHandlers = require('./event-handlers.js'); | ||
Object.defineProperty(exports, 'EventHandlers', { | ||
enumerable: true, | ||
get: function get() { | ||
return _eventHandlers.default; | ||
} | ||
}); | ||
var _eventHandlers2 = _interopRequireDefault(_eventHandlers); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.EventHandlers = _eventHandlers2.default; |
{ | ||
"name": "electrum-events", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Electrum Events forwards web component events to the bus.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"compile": "babel -d lib/ src/", | ||
"babel": "babel --quiet --out-dir lib src && babel --quiet --out-dir lib.test src.test", | ||
"clean": "rimraf ./lib && rimraf ./lib.test", | ||
"compile": "npm run clean && require-self && npm run babel", | ||
"mocha": "mocha lib.test/**/*.js", | ||
"prepublish": "npm run compile", | ||
"test": "mocha src/test/**/*.js" | ||
"test": "npm run compile && npm run mocha" | ||
}, | ||
@@ -28,15 +31,8 @@ "repository": { | ||
"devDependencies": { | ||
"babel-cli": "^6.4.5", | ||
"babel-core": "^6.4.5", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-preset-react": "^6.3.13", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"chai": "^3.4.1", | ||
"jsdom": "^7.2.2", | ||
"mai-chai": "^1.1.2", | ||
"mocha": "^2.4.2", | ||
"path": "^0.12.7", | ||
"react": "^0.14.6", | ||
"react-dom": "^0.14.6" | ||
"babel-env": "^1.1.0", | ||
"mai-chai": "^2.4.0", | ||
"react": "^0.14.7", | ||
"react-dom": "^0.14.7", | ||
"require-self": "^0.1.0" | ||
} | ||
} |
'use strict'; | ||
export {default as EventHandlers} from './event-handlers.js'; | ||
import EventHandlers from './event-handlers.js'; | ||
export {EventHandlers}; |
@@ -9,2 +9,3 @@ /*globals __dirname */ | ||
babelConfig.babel = babel; | ||
module.exports = function (wallaby) { | ||
@@ -14,7 +15,6 @@ return { | ||
{pattern: 'test/test-helper.js'}, | ||
{pattern: 'src/utils/**/*.js'}, | ||
{pattern: 'src/*.js'} | ||
{pattern: 'src/**/*.js'} | ||
], | ||
tests: [ | ||
{pattern: 'src/test/**/*.js'}, | ||
{pattern: 'src.test/**/*.js'}, | ||
], | ||
@@ -29,6 +29,27 @@ compilers: { | ||
}, | ||
bootstrap: function () { | ||
bootstrap: function (wallaby) { | ||
// See http://wallabyjs.com/docs/config/bootstrap.html | ||
var path = require ('path'); | ||
var sep = path.sep; | ||
console.log ('Setup wallaby'); | ||
var sep = require ('path').sep; | ||
// Ensure that we can require self (just like what module 'require-self' | ||
// does), but remapping by default the path to './src' rather than './lib' | ||
// as specified by package "main". | ||
// See https://github.com/wallabyjs/public/issues/453 | ||
var packageConfig = require (path.join (wallaby.localProjectDir, 'package.json')); | ||
var packageName = packageConfig.name; | ||
var modulePrototype = require ('module').Module.prototype; | ||
if (!modulePrototype._originalRequire) { | ||
modulePrototype._originalRequire = modulePrototype.require; | ||
modulePrototype.require = function (filePath) { | ||
if (filePath === packageName) { | ||
return modulePrototype._originalRequire.call (this, path.join (wallaby.projectCacheDir, 'src')); | ||
} else { | ||
return modulePrototype._originalRequire.call (this, filePath); | ||
} | ||
}; | ||
} | ||
// Remove react from the require.cache, or else some code might not get | ||
@@ -43,2 +64,3 @@ // executed when editing the source code. | ||
}); | ||
// Include the test helper, which sets up the document and window objects | ||
@@ -45,0 +67,0 @@ // as globals: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30225
5
617
3