From 717506f62129b526f3c1240280deaf848b839423 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Sun, 18 Mar 2018 12:03:02 +0800 Subject: [PATCH] Rebuild code. --- .babelrc | 6 + .gitignore | 4 +- .npmignore | 7 +- .postcssrc | 8 + README.md | 4 +- bower.json | 24 - src/hotkeys.js => dist/hotkeys.common.js | 394 +++++----- dist/hotkeys.common.min.js | 2 + dist/hotkeys.js | 672 +++++++++--------- dist/hotkeys.min.js | 5 +- dist/hotkeys.min.map | 1 - index.js | 6 + package.json | 56 +- scripts/build.js | 101 +++ scripts/watch.js | 35 + src/.babelrc | 8 + src/main.js | 254 +++++++ src/utils.js | 45 ++ src/var.js | 50 ++ test/hotkeys.js | 305 -------- test/hotkeys.test.js | 1 - test/index.html | 42 +- test/run.js | 0 website/App.js | 116 +++ website/assets/bg.jpg | Bin 0 -> 21072 bytes website/components/Footer.js | 8 + website/components/Footer.less | 5 + website/components/GithubCorner.js | 17 + website/components/GithubCorner.less | 32 + website/components/GithubShields.js | 20 + website/components/GithubShields.less | 8 + website/components/KeyBoard.js | 109 +++ website/components/KeyBoard.less | 248 +++++++ website/components/Markdown/index.js | 43 ++ .../components/Markdown/styles/default.less | 216 ++++++ website/components/Markdown/styles/index.less | 25 + .../Markdown/styles/javascript.less | 34 + website/doc.md | 246 +++++++ website/index.html | 13 + website/index.js | 6 + website/styles/index.less | 77 ++ website/styles/reset.less | 44 ++ 42 files changed, 2344 insertions(+), 953 deletions(-) create mode 100644 .babelrc create mode 100644 .postcssrc delete mode 100644 bower.json rename src/hotkeys.js => dist/hotkeys.common.js (70%) create mode 100644 dist/hotkeys.common.min.js delete mode 100644 dist/hotkeys.min.map create mode 100644 index.js create mode 100644 scripts/build.js create mode 100644 scripts/watch.js create mode 100644 src/.babelrc create mode 100644 src/main.js create mode 100644 src/utils.js create mode 100644 src/var.js delete mode 100644 test/hotkeys.js delete mode 100644 test/hotkeys.test.js create mode 100644 test/run.js create mode 100644 website/App.js create mode 100644 website/assets/bg.jpg create mode 100644 website/components/Footer.js create mode 100644 website/components/Footer.less create mode 100644 website/components/GithubCorner.js create mode 100644 website/components/GithubCorner.less create mode 100644 website/components/GithubShields.js create mode 100644 website/components/GithubShields.less create mode 100644 website/components/KeyBoard.js create mode 100644 website/components/KeyBoard.less create mode 100644 website/components/Markdown/index.js create mode 100644 website/components/Markdown/styles/default.less create mode 100644 website/components/Markdown/styles/index.less create mode 100644 website/components/Markdown/styles/javascript.less create mode 100644 website/doc.md create mode 100644 website/index.html create mode 100644 website/index.js create mode 100644 website/styles/index.less create mode 100644 website/styles/reset.less diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..449f9e7 --- /dev/null +++ b/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + "env", + "react" + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4d30e2a..7ee3d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ npm-debug.log -node_modules/ +node_modules +build +.cache .idea/ package-lock.json yarn.lock diff --git a/.npmignore b/.npmignore index cca96b7..7959eff 100644 --- a/.npmignore +++ b/.npmignore @@ -1,8 +1,9 @@ -dist/hotkeys.js -dist/hotkeys.min.map -bower.json .gitignore +.cache +scripts test +build package-lock.json +rollup.config.js yarn.lock src diff --git a/.postcssrc b/.postcssrc new file mode 100644 index 0000000..a4f291a --- /dev/null +++ b/.postcssrc @@ -0,0 +1,8 @@ +{ + "modules": true, + "plugins": { + "autoprefixer": { + "grid": true + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index f082739..e99870f 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ hotkeys('shift+a,alt+d, w', function(e){ ## 定义快捷键 ```js -// 定义a快捷键 +// 定义 F5 快捷键 hotkeys('f5', function(event,handler){ //event.srcElement: input //event.target: input @@ -206,7 +206,7 @@ hotkeys.deleteScope('scope1'); **获取** 区域范围标记 ```js -hotkeys.getScope('scope1'); +hotkeys.getScope(); ``` **设置** 区域范围标记 diff --git a/bower.json b/bower.json deleted file mode 100644 index 2a31e15..0000000 --- a/bower.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "hotkeys-js", - "description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.", - "main": "dist/hotkeys.js", - "homepage": "https://github.com/jaywcjlove/hotkeys", - "authors": [ - "jaywcjlove <398188662@qq.com>" - ], - "license": "MIT", - "keywords": [ - "key", - "keys", - "keybind", - "keyboard", - "shortcuts" - ], - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} diff --git a/src/hotkeys.js b/dist/hotkeys.common.js similarity index 70% rename from src/hotkeys.js rename to dist/hotkeys.common.js index fe69d4b..72f14e2 100644 --- a/src/hotkeys.js +++ b/dist/hotkeys.common.js @@ -1,52 +1,73 @@ -//IE对indexOf方法的支持 -if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function (obj) { - for (var i = 0; i < this.length; i++) if (this[i] === obj) return i; +'use strict'; - return -1; - }; +const isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; + +// 绑定事件 +function addEvent(object, event, method) { + if (object.addEventListener) { + object.addEventListener(event, method, false); + } else if (object.attachEvent) { + object.attachEvent('on' + event, function () { method(window.event); }); + } } -// IE对lastIndexOf方法的支持 -if (!Array.prototype.lastIndexOf) { - Array.prototype.lastIndexOf = function (obj) { - for (var i = this.length - 1; i >= 0; i--) if (this[i] === obj) return i; +// 修饰键转换成对应的键码 +function getMods(modifier, key) { + var mods = key.slice(0, key.length - 1); + for (var i = 0; i < mods.length; i++) mods[i] = modifier[mods[i].toLowerCase()]; + return mods; +} - return -1; + +// 处理传的key字符串转换成数组 +function getKeys(key) { + if (!key) key = ''; + var keys, index; + + key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等 + keys = key.split(','); // 同时设置多个快捷键,以','分割 + index = keys.lastIndexOf(''); + + // 快捷键可能包含',',需特殊处理 + for (; index >= 0;) { + keys[index - 1] += ','; + keys.splice(index, 1); + index = keys.lastIndexOf(''); } + + return keys; } -var _api, // 对外API - isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false, - _keyMap = { // 特殊键 - backspace: 8, tab: 9, clear: 12, - enter: 13, 'return': 13, - esc: 27, escape: 27, space: 32, - left: 37, up: 38, right: 39, down: 40, - del: 46, 'delete': 46, - ins: 45, 'insert': 45, - home: 36, end: 35, - pageup: 33, pagedown: 34, '⇪': 20, 'capslock': 20, - ',': 188, '.': 190, '/': 191, - '`': 192, '-': isff ? 173 : 189, '=': isff ? 61 : 187, - ';': isff ? 59 : 186, '\'': 222, - '[': 219, ']': 221, '\\': 220 - }, - _scope = 'all', //默认热键范围 - _modifier = { //修饰键 - '⇧': 16, shift: 16, - '⌥': 18, alt: 18, option: 18, - '⌃': 17, ctrl: 17, control: 17, - '⌘': isff ? 224 : 91, cmd: isff ? 224 : 91, command: isff ? 224 : 91 - }, - _downKeys = [], // 记录摁下的绑定键 - modifierMap = { - 16: 'shiftKey', - 18: 'altKey', - 17: 'ctrlKey' - }, - _mods = { 16: false, 18: false, 17: false }, - _handlers = {}; +const _keyMap = { // 特殊键 + backspace: 8, tab: 9, clear: 12, + enter: 13, 'return': 13, + esc: 27, escape: 27, space: 32, + left: 37, up: 38, right: 39, down: 40, + del: 46, 'delete': 46, + ins: 45, 'insert': 45, + home: 36, end: 35, + pageup: 33, pagedown: 34, '⇪': 20, 'capslock': 20, + ',': 188, '.': 190, '/': 191, + '`': 192, '-': isff ? 173 : 189, '=': isff ? 61 : 187, + ';': isff ? 59 : 186, '\'': 222, + '[': 219, ']': 221, '\\': 220 +}; + +const _modifier = { //修饰键 + '⇧': 16, shift: 16, + '⌥': 18, alt: 18, option: 18, + '⌃': 17, ctrl: 17, control: 17, + '⌘': isff ? 224 : 91, cmd: isff ? 224 : 91, command: isff ? 224 : 91 +}; +const _downKeys = []; // 记录摁下的绑定键 +const modifierMap = { + 16: 'shiftKey', + 18: 'altKey', + 17: 'ctrlKey' +}; +const _mods = { 16: false, 18: false, 17: false }; +const _handlers = {}; + // F1~F12 特殊键 for (var k = 1; k < 20; k++) { @@ -57,22 +78,22 @@ for (var k = 1; k < 20; k++) { modifierMap[isff ? 224 : 91] = 'metaKey'; _mods[isff ? 224 : 91] = false; +let _scope = 'all'; //默认热键范围 // 返回键码 -function code(x) { return _keyMap[x.toLowerCase()] || x.toUpperCase().charCodeAt(0); } +const code = (x) => _keyMap[x.toLowerCase()] || x.toUpperCase().charCodeAt(0); // 设置获取当前范围(默认为'所有') function setScope(scope) { _scope = scope || 'all'; } - // 获取当前范围 function getScope() { return _scope || 'all'; } +// 获取摁下绑定键的键值 +function getPressedKeyCodes() { return _downKeys.slice(0); } -// 绑定事件 -function addEvent(object, event, method) { - if (object.addEventListener) { - object.addEventListener(event, method, false); - } else if (object.attachEvent) { - object.attachEvent('on' + event, function () { method(window.event); }); - } +// 表单控件控件判断 返回 Boolean +function filter(event) { + var tagName = (event.target || event.srcElement).tagName; + // 忽略这些标签情况下快捷键无效 + return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'); } // 判断摁下的键是否为某个键,返回true或者false @@ -84,96 +105,55 @@ function isPressed(keyCode) { return _downKeys.indexOf(keyCode) !== -1; } -// 获取摁下绑定键的键值 -function getPressedKeyCodes() { return _downKeys.slice(0); } - -// 处理keydown事件 -function dispatch(event) { - var key = event.keyCode || event.which || event.charCode, - scope, - asterisk = _handlers['*']; - - // 搜集绑定的键 - if (_downKeys.indexOf(key) === -1) _downKeys.push(key); - - // Gecko(Firefox)的command键值224,在Webkit(Chrome)中保持一致 - // Webkit左右command键值不一样 - if (key === 93 || key === 224) key = 91; - if (key in _mods) { - _mods[key] = true; - - // 将特殊字符的key注册到 hotkeys 上 - for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = true; - - if (!asterisk) return; - } - - // 将modifierMap里面的修饰键绑定到event中 - for (var e in _mods) _mods[e] = event[modifierMap[e]]; +// 循环删除handlers中的所有 scope(范围) +function deleteScope(scope, newScope) { + let handlers; + let i; - // 表单控件过滤 默认表单控件不触发快捷键 - if (!hotkeys.filter.call(this, event)) return; + // 没有指定scope,获取scope + if (!scope) scope = getScope(); - // 获取范围 默认为all - scope = getScope(); + for (let key in _handlers) { + handlers = _handlers[key]; - // 对任何快捷键都需要做的处理 - if (asterisk) { - for (i = 0; i < asterisk.length; i++) { - if (asterisk[i].scope === scope) eventHandler(event, asterisk[i], scope); + for (i = 0; i < handlers.length;) { + if (handlers[i].scope === scope) handlers.splice(i, 1); + else i++; } } - // key 不在_handlers中返回 - if (!(key in _handlers)) return; - - for (var i = 0; i < _handlers[key].length; i++) { - // 找到处理内容 - eventHandler(event, _handlers[key][i], scope); - } + // 如果scope被删除,将scope重置为all + if (getScope() === scope) setScope(newScope || 'all'); } -// 对监听对应快捷键的回调函数进行处理 -function eventHandler(event, handler, scope) { - var modifiersMatch; +// 清除修饰键 +function clearModifier(event) { + let key = event.keyCode || event.which || event.charCode; + let i = _downKeys.indexOf(key); - // 看它是否在当前范围 - if (handler.scope === scope || handler.scope === 'all') { - //检查是否匹配修饰符(如果有返回true) - modifiersMatch = handler.mods.length > 0; + // 从列表中清除按压过的键 + if (i >= 0) _downKeys.splice(i, 1); - for (var y in _mods) { - if ( - (!_mods[y] && handler.mods.indexOf(+y) > -1) || - (_mods[y] && handler.mods.indexOf(+y) === -1) - ) modifiersMatch = false; - } + // 修饰键 shiftKey altKey ctrlKey (command||metaKey) 清除 + if (key === 93 || key === 224) key = 91; + if (key in _mods) { + _mods[key] = false; - // 调用处理程序,如果是修饰键不做处理 - if ( - (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || - modifiersMatch || - handler.shortcut === '*' - ) { - if (handler.method(event, handler) === false) { - if (event.preventDefault) event.preventDefault(); - else event.returnValue = false; - if (event.stopPropagation) event.stopPropagation(); - if (event.cancelBubble) event.cancelBubble = true; - } - } + // 将修饰键重置为false + for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = false; } } + // 解除绑定某个范围的快捷键 function unbind(key, scope) { - var multipleKeys = getKeys(key), + let multipleKeys = getKeys(key), keys, mods = [], obj; - for (var i = 0; i < multipleKeys.length; i++) { + for (let i = 0; i < multipleKeys.length; i++) { // 将组合快捷键拆分为数组 keys = multipleKeys[i].split('+'); @@ -192,7 +172,7 @@ function unbind(key, scope) { // 清空 handlers 中数据, // 让触发快捷键键之后没有事件执行到达解除快捷键绑定的目的 - for (var r = 0; r < _handlers[key].length; r++) { + for (let r = 0; r < _handlers[key].length; r++) { obj = _handlers[key][r]; // 判断是否在范围内并且键值相同 @@ -204,122 +184,107 @@ function unbind(key, scope) { } } -// 循环删除handlers中的所有 scope(范围) -function deleteScope(scope, newScope) { - var key, - handlers, - i; - // 没有指定scope,获取scope - if (!scope) scope = getScope(); +// 对监听对应快捷键的回调函数进行处理 +function eventHandler(event, handler, scope) { + let modifiersMatch; - for (key in _handlers) { - handlers = _handlers[key]; + // 看它是否在当前范围 + if (handler.scope === scope || handler.scope === 'all') { + //检查是否匹配修饰符(如果有返回true) + modifiersMatch = handler.mods.length > 0; - for (i = 0; i < handlers.length;) { - if (handlers[i].scope === scope) handlers.splice(i, 1); - else i++; + for (let y in _mods) { + if ( + (!_mods[y] && handler.mods.indexOf(+y) > -1) || + (_mods[y] && handler.mods.indexOf(+y) === -1) + ) modifiersMatch = false; } - } - - // 如果scope被删除,将scope重置为all - if (getScope() === scope) setScope(newScope || 'all'); -} - -//比较修饰键的数组 -function compareArray(a1, a2) { - var arr1 = a1.length >= a2.length ? a1 : a2 - var arr2 = a1.length >= a2.length ? a2 : a1 - for (var i = 0; i < arr1.length; i++) { - if (arr2.indexOf(arr1[i]) === -1) return false; + // 调用处理程序,如果是修饰键不做处理 + if ( + (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || + modifiersMatch || + handler.shortcut === '*' + ) { + if (handler.method(event, handler) === false) { + if (event.preventDefault) event.preventDefault(); + else event.returnValue = false; + if (event.stopPropagation) event.stopPropagation(); + if (event.cancelBubble) event.cancelBubble = true; + } + } } - - return true; } -// 表单控件控件判断 返回 Boolean -function filter(event) { - var tagName = (event.target || event.srcElement).tagName; - - // 忽略这些标签情况下快捷键无效 - return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'); -} -// 修饰键转换成对应的键码 -function getMods(key) { - var mods = key.slice(0, key.length - 1); +// 处理keydown事件 +function dispatch(event) { + var key = event.keyCode || event.which || event.charCode, + scope, + asterisk = _handlers['*']; - for (var i = 0; i < mods.length; i++) mods[i] = _modifier[mods[i].toLowerCase()]; + // 搜集绑定的键 + if (_downKeys.indexOf(key) === -1) _downKeys.push(key); - return mods; -} + // Gecko(Firefox)的command键值224,在Webkit(Chrome)中保持一致 + // Webkit左右command键值不一样 + if (key === 93 || key === 224) key = 91; -// 处理传的key字符串转换成数组 -function getKeys(key) { - if (!key) key = ''; - var keys, index; + if (key in _mods) { + _mods[key] = true; - key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等 - keys = key.split(','); // 同时设置多个快捷键,以','分割 - index = keys.lastIndexOf(''); + // 将特殊字符的key注册到 hotkeys 上 + for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = true; - // 快捷键可能包含',',需特殊处理 - for (; index >= 0;) { - keys[index - 1] += ','; - keys.splice(index, 1); - index = keys.lastIndexOf(''); + if (!asterisk) return; } - return keys; -} + // 将modifierMap里面的修饰键绑定到event中 + for (var e in _mods) _mods[e] = event[modifierMap[e]]; + console.log('_downKeys:', _mods, _downKeys); -// 在全局document上设置快捷键 -if (typeof document !== 'undefined') { - addEvent(document, "keydown", function (event) { - dispatch(event); - }); - addEvent(document, "keyup", function (event) { - clearModifier(event); - }); -} + // 表单控件过滤 默认表单控件不触发快捷键 + if (!hotkeys.filter.call(this, event)) return; -// 清除修饰键 -function clearModifier(event) { - var key = event.keyCode || event.which || event.charCode, - i = _downKeys.indexOf(key); + // 获取范围 默认为all + scope = getScope(); - // 从列表中清除按压过的键 - if (i >= 0) _downKeys.splice(i, 1); + // 对任何快捷键都需要做的处理 + if (asterisk) { + for (i = 0; i < asterisk.length; i++) { + if (asterisk[i].scope === scope) eventHandler(event, asterisk[i], scope); + } + } - // 修饰键 shiftKey altKey ctrlKey (command||metaKey) 清除 - if (key === 93 || key === 224) key = 91; - if (key in _mods) { - _mods[key] = false; + // key 不在_handlers中返回 + if (!(key in _handlers)) return; - // 将修饰键重置为false - for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = false; + for (var i = 0; i < _handlers[key].length; i++) { + // 找到处理内容 + eventHandler(event, _handlers[key][i], scope); } } -// 主体hotkeys函数 function hotkeys(key, scope, method) { - var keys = getKeys(key), // 需要处理的快捷键列表 - mods = [], - i = 0; + let keys = getKeys(key); // 需要处理的快捷键列表 + let mods = []; + let i = 0; + // 对为设定范围的判断 if (method === undefined) { method = scope; scope = 'all'; // scope默认为all,所有范围都有效 } + // 对于每个快捷键进行处理 for (; i < keys.length; i++) { key = keys[i].split('+'); // 按键列表 mods = []; // 如果是组合快捷键取得组合快捷键 - if (key.length > 1) mods = getMods(key); + if (key.length > 1) mods = getMods(_modifier, key); // 将非修饰键转化为键码 key = key[key.length - 1]; @@ -329,29 +294,31 @@ function hotkeys(key, scope, method) { if (!(key in _handlers)) _handlers[key] = []; _handlers[key].push({ + scope, mods, shortcut: keys[i], - scope: scope, method: method, key: keys[i], - mods: mods }); } } -_api = { - setScope: setScope, - getScope: getScope, - deleteScope: deleteScope, - getPressedKeyCodes: getPressedKeyCodes, - isPressed: isPressed, - filter: filter, - unbind: unbind -}; +// 在全局document上设置快捷键 +if (typeof document !== 'undefined') { + addEvent(document, "keydown", (e) => { + dispatch(e); + }); + addEvent(document, "keyup", (e) => { + clearModifier(e); + }); +} + +const _api = { setScope, getScope, deleteScope, getPressedKeyCodes, isPressed, filter, unbind }; for (var a in _api) hotkeys[a] = _api[a]; + if (typeof window !== 'undefined') { var _hotkeys = window.hotkeys; - hotkeys.noConflict = function (deep) { + hotkeys.noConflict = (deep) => { if (deep && window.hotkeys === hotkeys) { window.hotkeys = _hotkeys; } @@ -359,6 +326,5 @@ if (typeof window !== 'undefined') { }; window.hotkeys = hotkeys; } -window.hotkeys = hotkeys; -return hotkeys; +module.exports = hotkeys; diff --git a/dist/hotkeys.common.min.js b/dist/hotkeys.common.min.js new file mode 100644 index 0000000..498b1d6 --- /dev/null +++ b/dist/hotkeys.common.min.js @@ -0,0 +1,2 @@ +/*! hotkeys-js v3.0.0 | MIT (c) 2018 kenny wang | */ +"use strict";var isff="undefined"!=typeof navigator&&0 - * https://github.com/jaywcjlove/hotkeys.git - * - * Licensed under the MIT license. - */ -(function(f) { - if (typeof exports === "object" && typeof module !== "undefined") { - module.exports = f(); - } else if (typeof define === "function" && define.amd) { - define([], f); - } else { - var g; - if (typeof window !== "undefined") { - g = window; - } else if (typeof global !== "undefined") { - g = global; - } else if (typeof self !== "undefined") { - g = self; - } else { - g = this; - } - g.hotkeys = f(); +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.hotkeys = factory()); +}(this, (function () { 'use strict'; + +const isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; + +// 绑定事件 +function addEvent(object, event, method) { + if (object.addEventListener) { + object.addEventListener(event, method, false); + } else if (object.attachEvent) { + object.attachEvent('on' + event, function () { method(window.event); }); + } +} + +// 修饰键转换成对应的键码 +function getMods(modifier, key) { + var mods = key.slice(0, key.length - 1); + for (var i = 0; i < mods.length; i++) mods[i] = modifier[mods[i].toLowerCase()]; + return mods; +} + + +// 处理传的key字符串转换成数组 +function getKeys(key) { + if (!key) key = ''; + var keys, index; + + key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等 + keys = key.split(','); // 同时设置多个快捷键,以','分割 + index = keys.lastIndexOf(''); + + // 快捷键可能包含',',需特殊处理 + for (; index >= 0;) { + keys[index - 1] += ','; + keys.splice(index, 1); + index = keys.lastIndexOf(''); + } + + return keys; +} + +const _keyMap = { // 特殊键 + backspace: 8, tab: 9, clear: 12, + enter: 13, 'return': 13, + esc: 27, escape: 27, space: 32, + left: 37, up: 38, right: 39, down: 40, + del: 46, 'delete': 46, + ins: 45, 'insert': 45, + home: 36, end: 35, + pageup: 33, pagedown: 34, '⇪': 20, 'capslock': 20, + ',': 188, '.': 190, '/': 191, + '`': 192, '-': isff ? 173 : 189, '=': isff ? 61 : 187, + ';': isff ? 59 : 186, '\'': 222, + '[': 219, ']': 221, '\\': 220 +}; + +const _modifier = { //修饰键 + '⇧': 16, shift: 16, + '⌥': 18, alt: 18, option: 18, + '⌃': 17, ctrl: 17, control: 17, + '⌘': isff ? 224 : 91, cmd: isff ? 224 : 91, command: isff ? 224 : 91 +}; +const _downKeys = []; // 记录摁下的绑定键 +const modifierMap = { + 16: 'shiftKey', + 18: 'altKey', + 17: 'ctrlKey' +}; +const _mods = { 16: false, 18: false, 17: false }; +const _handlers = {}; + + +// F1~F12 特殊键 +for (var k = 1; k < 20; k++) { + _keyMap['f' + k] = 111 + k; +} + +// 兼容Firefox处理 +modifierMap[isff ? 224 : 91] = 'metaKey'; +_mods[isff ? 224 : 91] = false; + +let _scope = 'all'; //默认热键范围 +// 返回键码 +const code = (x) => _keyMap[x.toLowerCase()] || x.toUpperCase().charCodeAt(0); + +// 设置获取当前范围(默认为'所有') +function setScope(scope) { _scope = scope || 'all'; } +// 获取当前范围 +function getScope() { return _scope || 'all'; } +// 获取摁下绑定键的键值 +function getPressedKeyCodes() { return _downKeys.slice(0); } + +// 表单控件控件判断 返回 Boolean +function filter(event) { + var tagName = (event.target || event.srcElement).tagName; + // 忽略这些标签情况下快捷键无效 + return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'); +} + +// 判断摁下的键是否为某个键,返回true或者false +function isPressed(keyCode) { + if (typeof (keyCode) === 'string') { + keyCode = code(keyCode); // 转换成键码 + } + + return _downKeys.indexOf(keyCode) !== -1; +} + + +// 循环删除handlers中的所有 scope(范围) +function deleteScope(scope, newScope) { + let handlers; + let i; + + // 没有指定scope,获取scope + if (!scope) scope = getScope(); + + for (let key in _handlers) { + handlers = _handlers[key]; + + for (i = 0; i < handlers.length;) { + if (handlers[i].scope === scope) handlers.splice(i, 1); + else i++; } -})(function() { - var define, module, exports; - //IE对indexOf方法的支持 - if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function(obj) { - for (var i = 0; i < this.length; i++) if (this[i] === obj) return i; - return -1; - }; + } + + // 如果scope被删除,将scope重置为all + if (getScope() === scope) setScope(newScope || 'all'); +} + +// 清除修饰键 +function clearModifier(event) { + let key = event.keyCode || event.which || event.charCode; + let i = _downKeys.indexOf(key); + + // 从列表中清除按压过的键 + if (i >= 0) _downKeys.splice(i, 1); + + // 修饰键 shiftKey altKey ctrlKey (command||metaKey) 清除 + if (key === 93 || key === 224) key = 91; + if (key in _mods) { + _mods[key] = false; + + // 将修饰键重置为false + for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = false; + } +} + + +// 解除绑定某个范围的快捷键 +function unbind(key, scope) { + let multipleKeys = getKeys(key), + keys, + mods = [], + obj; + + for (let i = 0; i < multipleKeys.length; i++) { + // 将组合快捷键拆分为数组 + keys = multipleKeys[i].split('+'); + + // 记录每个组合键中的修饰键的键码 返回数组 + if (keys.length > 1) mods = getMods(keys); + + // 获取除修饰键外的键值key + key = keys[keys.length - 1]; + key = key === '*' ? '*' : code(key); + + // 判断是否传入范围,没有就获取范围 + if (!scope) scope = getScope(); + + // 如何key不在 _handlers 中返回不做处理 + if (!_handlers[key]) return; + + // 清空 handlers 中数据, + // 让触发快捷键键之后没有事件执行到达解除快捷键绑定的目的 + for (let r = 0; r < _handlers[key].length; r++) { + obj = _handlers[key][r]; + + // 判断是否在范围内并且键值相同 + if ( + obj.scope === scope && + compareArray(obj.mods, mods) + ) _handlers[key][r] = {}; } - // IE对lastIndexOf方法的支持 - if (!Array.prototype.lastIndexOf) { - Array.prototype.lastIndexOf = function(obj) { - for (var i = this.length - 1; i >= 0; i--) if (this[i] === obj) return i; - return -1; - }; + } +} + + +// 对监听对应快捷键的回调函数进行处理 +function eventHandler(event, handler, scope) { + let modifiersMatch; + + // 看它是否在当前范围 + if (handler.scope === scope || handler.scope === 'all') { + //检查是否匹配修饰符(如果有返回true) + modifiersMatch = handler.mods.length > 0; + + for (let y in _mods) { + if ( + (!_mods[y] && handler.mods.indexOf(+y) > -1) || + (_mods[y] && handler.mods.indexOf(+y) === -1) + ) modifiersMatch = false; } - var _api, // 对外API - isff = typeof navigator !== "undefined" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : false, _keyMap = { - // 特殊键 - backspace: 8, - tab: 9, - clear: 12, - enter: 13, - return: 13, - esc: 27, - escape: 27, - space: 32, - left: 37, - up: 38, - right: 39, - down: 40, - del: 46, - delete: 46, - ins: 45, - insert: 45, - home: 36, - end: 35, - pageup: 33, - pagedown: 34, - "⇪": 20, - capslock: 20, - ",": 188, - ".": 190, - "/": 191, - "`": 192, - "-": isff ? 173 : 189, - "=": isff ? 61 : 187, - ";": isff ? 59 : 186, - "'": 222, - "[": 219, - "]": 221, - "\\": 220 - }, _scope = "all", //默认热键范围 - _modifier = { - //修饰键 - "⇧": 16, - shift: 16, - "⌥": 18, - alt: 18, - option: 18, - "⌃": 17, - ctrl: 17, - control: 17, - "⌘": isff ? 224 : 91, - cmd: isff ? 224 : 91, - command: isff ? 224 : 91 - }, _downKeys = [], // 记录摁下的绑定键 - modifierMap = { - 16: "shiftKey", - 18: "altKey", - 17: "ctrlKey" - }, _mods = { - 16: false, - 18: false, - 17: false - }, _handlers = {}; - // F1~F12 特殊键 - for (var k = 1; k < 20; k++) { - _keyMap["f" + k] = 111 + k; + + // 调用处理程序,如果是修饰键不做处理 + if ( + (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || + modifiersMatch || + handler.shortcut === '*' + ) { + if (handler.method(event, handler) === false) { + if (event.preventDefault) event.preventDefault(); + else event.returnValue = false; + if (event.stopPropagation) event.stopPropagation(); + if (event.cancelBubble) event.cancelBubble = true; + } } - // 兼容Firefox处理 - modifierMap[isff ? 224 : 91] = "metaKey"; - _mods[isff ? 224 : 91] = false; - // 返回键码 - function code(x) { - return _keyMap[x.toLowerCase()] || x.toUpperCase().charCodeAt(0); + } +} + + +// 处理keydown事件 +function dispatch(event) { + var key = event.keyCode || event.which || event.charCode, + scope, + asterisk = _handlers['*']; + + // 搜集绑定的键 + if (_downKeys.indexOf(key) === -1) _downKeys.push(key); + + // Gecko(Firefox)的command键值224,在Webkit(Chrome)中保持一致 + // Webkit左右command键值不一样 + if (key === 93 || key === 224) key = 91; + + if (key in _mods) { + _mods[key] = true; + + // 将特殊字符的key注册到 hotkeys 上 + for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = true; + + if (!asterisk) return; + } + + // 将modifierMap里面的修饰键绑定到event中 + for (var e in _mods) _mods[e] = event[modifierMap[e]]; + console.log('_downKeys:', _mods, _downKeys); + + // 表单控件过滤 默认表单控件不触发快捷键 + if (!hotkeys.filter.call(this, event)) return; + + // 获取范围 默认为all + scope = getScope(); + + // 对任何快捷键都需要做的处理 + if (asterisk) { + for (i = 0; i < asterisk.length; i++) { + if (asterisk[i].scope === scope) eventHandler(event, asterisk[i], scope); } - // 设置获取当前范围(默认为'所有') - function setScope(scope) { - _scope = scope || "all"; + } + + // key 不在_handlers中返回 + if (!(key in _handlers)) return; + + for (var i = 0; i < _handlers[key].length; i++) { + // 找到处理内容 + eventHandler(event, _handlers[key][i], scope); + } +} + +function hotkeys(key, scope, method) { + let keys = getKeys(key); // 需要处理的快捷键列表 + let mods = []; + let i = 0; + + + // 对为设定范围的判断 + if (method === undefined) { + method = scope; + scope = 'all'; // scope默认为all,所有范围都有效 + } + + // 对于每个快捷键进行处理 + for (; i < keys.length; i++) { + key = keys[i].split('+'); // 按键列表 + mods = []; + + // 如果是组合快捷键取得组合快捷键 + if (key.length > 1) mods = getMods(_modifier, key); + + // 将非修饰键转化为键码 + key = key[key.length - 1]; + key = key === '*' ? '*' : code(key); // *表示匹配所有快捷键 + + // 判断key是否在_handlers中,不在就赋一个空数组 + if (!(key in _handlers)) _handlers[key] = []; + + _handlers[key].push({ + scope, mods, + shortcut: keys[i], + method: method, + key: keys[i], + }); + } +} + + +// 在全局document上设置快捷键 +if (typeof document !== 'undefined') { + addEvent(document, "keydown", (e) => { + dispatch(e); + }); + addEvent(document, "keyup", (e) => { + clearModifier(e); + }); +} + +const _api = { setScope, getScope, deleteScope, getPressedKeyCodes, isPressed, filter, unbind }; +for (var a in _api) hotkeys[a] = _api[a]; + +if (typeof window !== 'undefined') { + var _hotkeys = window.hotkeys; + hotkeys.noConflict = (deep) => { + if (deep && window.hotkeys === hotkeys) { + window.hotkeys = _hotkeys; } - // 获取当前范围 - function getScope() { - return _scope || "all"; - } - // 绑定事件 - function addEvent(object, event, method) { - if (object.addEventListener) { - object.addEventListener(event, method, false); - } else if (object.attachEvent) { - object.attachEvent("on" + event, function() { - method(window.event); - }); - } - } - // 判断摁下的键是否为某个键,返回true或者false - function isPressed(keyCode) { - if (typeof keyCode === "string") { - keyCode = code(keyCode); - // 转换成键码 - } - return _downKeys.indexOf(keyCode) !== -1; - } - // 获取摁下绑定键的键值 - function getPressedKeyCodes() { - return _downKeys.slice(0); - } - // 处理keydown事件 - function dispatch(event) { - var key = event.keyCode || event.which || event.charCode, scope, asterisk = _handlers["*"]; - // 搜集绑定的键 - if (_downKeys.indexOf(key) === -1) _downKeys.push(key); - // Gecko(Firefox)的command键值224,在Webkit(Chrome)中保持一致 - // Webkit左右command键值不一样 - if (key === 93 || key === 224) key = 91; - if (key in _mods) { - _mods[key] = true; - // 将特殊字符的key注册到 hotkeys 上 - for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = true; - if (!asterisk) return; - } - // 将modifierMap里面的修饰键绑定到event中 - for (var e in _mods) _mods[e] = event[modifierMap[e]]; - // 表单控件过滤 默认表单控件不触发快捷键 - if (!hotkeys.filter.call(this, event)) return; - // 获取范围 默认为all - scope = getScope(); - // 对任何快捷键都需要做的处理 - if (asterisk) { - for (i = 0; i < asterisk.length; i++) { - if (asterisk[i].scope === scope) eventHandler(event, asterisk[i], scope); - } - } - // key 不在_handlers中返回 - if (!(key in _handlers)) return; - for (var i = 0; i < _handlers[key].length; i++) { - // 找到处理内容 - eventHandler(event, _handlers[key][i], scope); - } - } - // 对监听对应快捷键的回调函数进行处理 - function eventHandler(event, handler, scope) { - var modifiersMatch; - // 看它是否在当前范围 - if (handler.scope === scope || handler.scope === "all") { - //检查是否匹配修饰符(如果有返回true) - modifiersMatch = handler.mods.length > 0; - for (var y in _mods) { - if (!_mods[y] && handler.mods.indexOf(+y) > -1 || _mods[y] && handler.mods.indexOf(+y) === -1) modifiersMatch = false; - } - // 调用处理程序,如果是修饰键不做处理 - if (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91] || modifiersMatch || handler.shortcut === "*") { - if (handler.method(event, handler) === false) { - if (event.preventDefault) event.preventDefault(); else event.returnValue = false; - if (event.stopPropagation) event.stopPropagation(); - if (event.cancelBubble) event.cancelBubble = true; - } - } - } - } - // 解除绑定某个范围的快捷键 - function unbind(key, scope) { - var multipleKeys = getKeys(key), keys, mods = [], obj; - for (var i = 0; i < multipleKeys.length; i++) { - // 将组合快捷键拆分为数组 - keys = multipleKeys[i].split("+"); - // 记录每个组合键中的修饰键的键码 返回数组 - if (keys.length > 1) mods = getMods(keys); - // 获取除修饰键外的键值key - key = keys[keys.length - 1]; - key = key === "*" ? "*" : code(key); - // 判断是否传入范围,没有就获取范围 - if (!scope) scope = getScope(); - // 如何key不在 _handlers 中返回不做处理 - if (!_handlers[key]) return; - // 清空 handlers 中数据, - // 让触发快捷键键之后没有事件执行到达解除快捷键绑定的目的 - for (var r = 0; r < _handlers[key].length; r++) { - obj = _handlers[key][r]; - // 判断是否在范围内并且键值相同 - if (obj.scope === scope && compareArray(obj.mods, mods)) _handlers[key][r] = {}; - } - } - } - // 循环删除handlers中的所有 scope(范围) - function deleteScope(scope, newScope) { - var key, handlers, i; - // 没有指定scope,获取scope - if (!scope) scope = getScope(); - for (key in _handlers) { - handlers = _handlers[key]; - for (i = 0; i < handlers.length; ) { - if (handlers[i].scope === scope) handlers.splice(i, 1); else i++; - } - } - // 如果scope被删除,将scope重置为all - if (getScope() === scope) setScope(newScope || "all"); - } - //比较修饰键的数组 - function compareArray(a1, a2) { - var arr1 = a1.length >= a2.length ? a1 : a2; - var arr2 = a1.length >= a2.length ? a2 : a1; - for (var i = 0; i < arr1.length; i++) { - if (arr2.indexOf(arr1[i]) === -1) return false; - } - return true; - } - // 表单控件控件判断 返回 Boolean - function filter(event) { - var tagName = (event.target || event.srcElement).tagName; - // 忽略这些标签情况下快捷键无效 - return !(tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA"); - } - // 修饰键转换成对应的键码 - function getMods(key) { - var mods = key.slice(0, key.length - 1); - for (var i = 0; i < mods.length; i++) mods[i] = _modifier[mods[i].toLowerCase()]; - return mods; - } - // 处理传的key字符串转换成数组 - function getKeys(key) { - if (!key) key = ""; - var keys, index; - key = key.replace(/\s/g, ""); - // 匹配任何空白字符,包括空格、制表符、换页符等等 - keys = key.split(","); - // 同时设置多个快捷键,以','分割 - index = keys.lastIndexOf(""); - // 快捷键可能包含',',需特殊处理 - for (;index >= 0; ) { - keys[index - 1] += ","; - keys.splice(index, 1); - index = keys.lastIndexOf(""); - } - return keys; - } - // 在全局document上设置快捷键 - if (typeof document !== "undefined") { - addEvent(document, "keydown", function(event) { - dispatch(event); - }); - addEvent(document, "keyup", function(event) { - clearModifier(event); - }); - } - // 清除修饰键 - function clearModifier(event) { - var key = event.keyCode || event.which || event.charCode, i = _downKeys.indexOf(key); - // 从列表中清除按压过的键 - if (i >= 0) _downKeys.splice(i, 1); - // 修饰键 shiftKey altKey ctrlKey (command||metaKey) 清除 - if (key === 93 || key === 224) key = 91; - if (key in _mods) { - _mods[key] = false; - // 将修饰键重置为false - for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = false; - } - } - // 主体hotkeys函数 - function hotkeys(key, scope, method) { - var keys = getKeys(key), // 需要处理的快捷键列表 - mods = [], i = 0; - // 对为设定范围的判断 - if (method === undefined) { - method = scope; - scope = "all"; - // scope默认为all,所有范围都有效 - } - // 对于每个快捷键进行处理 - for (;i < keys.length; i++) { - key = keys[i].split("+"); - // 按键列表 - mods = []; - // 如果是组合快捷键取得组合快捷键 - if (key.length > 1) mods = getMods(key); - // 将非修饰键转化为键码 - key = key[key.length - 1]; - key = key === "*" ? "*" : code(key); - // *表示匹配所有快捷键 - // 判断key是否在_handlers中,不在就赋一个空数组 - if (!(key in _handlers)) _handlers[key] = []; - _handlers[key].push({ - shortcut: keys[i], - scope: scope, - method: method, - key: keys[i], - mods: mods - }); - } - } - _api = { - setScope: setScope, - getScope: getScope, - deleteScope: deleteScope, - getPressedKeyCodes: getPressedKeyCodes, - isPressed: isPressed, - filter: filter, - unbind: unbind - }; - for (var a in _api) hotkeys[a] = _api[a]; - if (typeof window !== "undefined") { - var _hotkeys = window.hotkeys; - hotkeys.noConflict = function(deep) { - if (deep && window.hotkeys === hotkeys) { - window.hotkeys = _hotkeys; - } - return hotkeys; - }; - window.hotkeys = hotkeys; - } - window.hotkeys = hotkeys; return hotkeys; -}); + }; + window.hotkeys = hotkeys; +} + +return hotkeys; + +}))); diff --git a/dist/hotkeys.min.js b/dist/hotkeys.min.js index 3ac7260..9b11b02 100644 --- a/dist/hotkeys.min.js +++ b/dist/hotkeys.min.js @@ -1,3 +1,2 @@ -/*! hotkeys-js v2.0.9 | MIT (c) 2018 kenny wang | https://github.com/jaywcjlove/hotkeys.git */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).hotkeys=e()}}(function(){Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var n=0;n=0;n--)if(this[n]===e)return n;return-1});for(var e,n="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0,t={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,"⇪":20,capslock:20,",":188,".":190,"/":191,"`":192,"-":n?173:189,"=":n?61:187,";":n?59:186,"'":222,"[":219,"]":221,"\\":220},o="all",r={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":n?224:91,cmd:n?224:91,command:n?224:91},i=[],f={16:"shiftKey",18:"altKey",17:"ctrlKey"},a={16:!1,18:!1,17:!1},l={},d=1;d<20;d++)t["f"+d]=111+d;function s(e){return t[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)}function c(e){o=e||"all"}function u(){return o||"all"}function p(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent&&e.attachEvent("on"+n,function(){t(window.event)})}function h(e,n,t){var o;if(n.scope===t||"all"===n.scope){for(var r in o=n.mods.length>0,a)(!a[r]&&n.mods.indexOf(+r)>-1||a[r]&&-1===n.mods.indexOf(+r))&&(o=!1);(0!==n.mods.length||a[16]||a[18]||a[17]||a[91])&&!o&&"*"!==n.shortcut||!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function g(e,n){for(var t=e.length>=n.length?e:n,o=e.length>=n.length?n:e,r=0;r=0;)n[t-1]+=",",n.splice(t,1),t=n.lastIndexOf("");return n}function w(e,n,t){var o=v(e),r=[],i=0;for(void 0===t&&(t=n,n="all");i1&&(r=y(e)),(e="*"===(e=e[e.length-1])?"*":s(e))in l||(l[e]=[]),l[e].push({shortcut:o[i],scope:n,method:t,key:o[i],mods:r})}for(var m in f[n?224:91]="metaKey",a[n?224:91]=!1,"undefined"!=typeof document&&(p(document,"keydown",function(e){!function(e){var n,t=e.keyCode||e.which||e.charCode,o=l["*"];if(-1===i.indexOf(t)&&i.push(t),93!==t&&224!==t||(t=91),t in a){for(var d in a[t]=!0,r)r[d]===t&&(w[d]=!0);if(!o)return}for(var s in a)a[s]=e[f[s]];if(w.filter.call(this,e)){if(n=u(),o)for(c=0;c=0&&i.splice(t,1);93!==n&&224!==n||(n=91);if(n in a)for(var o in a[n]=!1,r)r[o]===n&&(w[o]=!1)}(e)})),e={setScope:c,getScope:u,deleteScope:function(e,n){var t,o,r;for(t in e||(e=u()),l)for(o=l[t],r=0;r1&&(i=y(t)),e="*"===(e=t[t.length-1])?"*":s(e),n||(n=u()),!l[e])return;for(var a=0;a | */ +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.hotkeys=n()}(this,function(){"use strict";var e="undefined"!=typeof navigator&&0", - "main": "dist/hotkeys.min.js", + "version": "3.0.0", + "main": "index.js", "scripts": { - "build:test": "browserify test/hotkeys.js | uglifyjs --compress --mangle > test/hotkeys.test.js", - "build:min": "umd hotkeys src/hotkeys.js | uglifyjs -mc | bannerjs -o > dist/hotkeys.min.js", - "build:dist": "umd hotkeys src/hotkeys.js | bannerjs -m | uglifyjs -b beautify=true --comments 'all' > dist/hotkeys.js ", - "build": "npm run build:min && npm run build:dist", - "test": "npm run build:test && ssr", - "watch": "onchange 'src/hotkeys.js' -v -- npm run build " + "build": "node scripts/build.js", + "watch": "node scripts/watch.js", + "pretest": "npm run build", + "doc:dev": "NODE_ENV=development parcel website/index.html --out-dir build/website --no-cache", + "doc:build": "NODE_ENV=production parcel build website/index.html --out-dir build/website --public-url ./ --no-cache" }, "keywords": [ "hotkey", @@ -23,21 +21,31 @@ "shortcuts", "keypress" ], - "repository": { - "type": "git", - "url": "https://github.com/jaywcjlove/hotkeys.git" - }, + "author": "kenny wong ", + "license": "MIT", + "dependencies": {}, "devDependencies": { + "autoprefixer": "^8.1.0", + "babel-core": "^6.26.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-env": "^1.6.1", + "babel-preset-react": "^6.24.1", "bannerjs": "^1.0.5", - "browserify": "^14.4.0", - "jsdom": "^11.1.0", - "onchange": "^3.2.1", - "ssr": "^1.1.1", - "tape": "^4.8.0", - "tape-dom": "0.0.12", - "uglify-js": "^3.0.27", - "umd": "^3.0.1" - }, - "license": "MIT", - "dependencies": {} + "classnames": "^2.2.5", + "colors-cli": "^1.0.13", + "highlight.js": "^9.12.0", + "less": "^3.0.1", + "parcel-bundler": "^1.6.2", + "parcel-plugin-markdown-string": "^1.3.1", + "postcss-modules": "^1.1.0", + "react": "^16.2.0", + "react-dom": "^16.2.0", + "react-markdown": "^3.3.0", + "rollup": "^0.57.0", + "rollup-plugin-babel": "^3.0.3", + "rollup-plugin-commonjs": "^9.1.0", + "rollup-plugin-node-resolve": "^3.2.0", + "uglify-js": "^3.3.15", + "zlib": "^1.0.5" + } } diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 0000000..eac1c26 --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,101 @@ +const fs = require('fs'); +const path = require('path'); +const rollup = require('rollup'); +const babel = require('rollup-plugin-babel'); +const resolve = require('rollup-plugin-node-resolve'); +const commonjs = require('rollup-plugin-commonjs'); +const banner = require('bannerjs'); +const zlib = require('zlib'); +const pkg = require('../package.json'); +const uglify = require('uglify-js'); +require('colors-cli/toxic'); + +// see below for details on the options +const inputOptions = { + input: 'src/main.js', + plugins: [ + resolve(), // so Rollup can find `ms` + commonjs(), // so Rollup can convert `ms` to an ES module + babel({ + exclude: 'node_modules/**' // 只编译我们的源代码 + }) + ] +}; + +const outputOptions = { + file: pkg.unpkg, + sourcemap: false, + format: 'umd', + name: 'hotkeys', + banner: banner.multibanner() +}; + +async function build() { + // create a bundle + const bundle = await rollup.rollup(inputOptions); + + const uglifyOption = { + 'compress': { + 'pure_getters': true, + 'unsafe': true, + 'unsafe_comps': true, + 'warnings': false + }, + 'output': { + 'ascii_only': true, + } + } + + // console.log(bundle.imports); // an array of external dependencies + // console.log(bundle.exports); // an array of names exported by the entry point + // console.log(bundle.modules); // an array of module objects + + const umd = await bundle.generate({ + format: 'umd', + name: 'hotkeys', + banner: banner.multibanner() + }); + + const umdMinified = banner.onebanner() + '\n' + uglify.minify(umd.code, uglifyOption).code; + const common = await bundle.generate({ + format: 'cjs', + name: 'hotkeys', + banner: banner.multibanner() + }); + const commonMinified = banner.onebanner() + '\n' + uglify.minify(common.code, uglifyOption).code; + + write('dist/hotkeys.js', umd.code) + .then(() => write('dist/hotkeys.min.js', umdMinified, true)) + .then(() => write('dist/hotkeys.common.js', common.code)) + .then(() => write('dist/hotkeys.common.min.js', commonMinified, true)); + +} + +build(); + +function write(dest, code, zip) { + return new Promise(function (resolve, reject) { + function report(extra) { + console.log((path.relative(process.cwd(), dest)).blue_bt + ' ' + getSize(code).green_bt + (extra || '')) + resolve() + } + if (!fs.existsSync(path.dirname(dest))) { + fs.mkdirSync(path.dirname(dest)); + } + fs.writeFile(dest, code, function (err) { + if (err) return reject(err) + if (zip) { + zlib.gzip(code, (err, zipped) => { + if (err) return reject(err) + report(' (gzipped: ' + getSize(zipped).green_bt + ')') + }) + } else { + report() + } + }) + }) +} + +function getSize(code) { + return (code.length / 1024).toFixed(2) + 'kb' +} \ No newline at end of file diff --git a/scripts/watch.js b/scripts/watch.js new file mode 100644 index 0000000..dcb0b01 --- /dev/null +++ b/scripts/watch.js @@ -0,0 +1,35 @@ +const path = require('path'); +const rollup = require('rollup'); +const pkg = require('../package.json'); +require('colors-cli/toxic'); + +const watchOptions = { + input: 'src/main.js', + + output: [ + { file: 'dist/hotkeys.common.js', name: 'hotkeys', format: 'cjs' }, + { file: 'dist/hotkeys.js', name: 'hotkeys', format: 'umd' } + ] +}; +const watcher = rollup.watch(watchOptions); + +watcher.on('event', event => { + // event.code can be one of: + // START — the watcher is (re)starting + // BUNDLE_START — building an individual bundle + // BUNDLE_END — finished building a bundle + // END — finished building all bundles + // ERROR — encountered an error while bundling + // FATAL — encountered an unrecoverable error + if (event.code === 'BUNDLE_END') { + event.output.map(function (item) { + console.log('bundles '.x39 + `${event.input} → ${item.replace(process.cwd() + path.sep, '')}`.blue_bt); + }) + console.log(`duration ${event.duration}ms\n`.green) + } else if (event.code === 'END') { + console.log('waiting for changes... '); + } +}); + +// stop watching +// watcher.close(); \ No newline at end of file diff --git a/src/.babelrc b/src/.babelrc new file mode 100644 index 0000000..a039539 --- /dev/null +++ b/src/.babelrc @@ -0,0 +1,8 @@ +{ + "presets": [ + ["env", { + "modules": false + }] + ], + "plugins": ["external-helpers"] +} \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..6244c2b --- /dev/null +++ b/src/main.js @@ -0,0 +1,254 @@ +import { addEvent, getMods, getKeys } from './utils'; +import { _keyMap, _modifier, _downKeys, modifierMap, _mods, _handlers } from './var'; + + +let _scope = 'all'; //默认热键范围 +// 返回键码 +const code = (x) => _keyMap[x.toLowerCase()] || x.toUpperCase().charCodeAt(0); + +// 设置获取当前范围(默认为'所有') +function setScope(scope) { _scope = scope || 'all'; } +// 获取当前范围 +function getScope() { return _scope || 'all'; } +// 获取摁下绑定键的键值 +function getPressedKeyCodes() { return _downKeys.slice(0); } + +// 表单控件控件判断 返回 Boolean +function filter(event) { + var tagName = (event.target || event.srcElement).tagName; + // 忽略这些标签情况下快捷键无效 + return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'); +} + +// 判断摁下的键是否为某个键,返回true或者false +function isPressed(keyCode) { + if (typeof (keyCode) === 'string') { + keyCode = code(keyCode); // 转换成键码 + } + + return _downKeys.indexOf(keyCode) !== -1; +} + + +// 循环删除handlers中的所有 scope(范围) +function deleteScope(scope, newScope) { + let handlers; + let i; + + // 没有指定scope,获取scope + if (!scope) scope = getScope(); + + for (let key in _handlers) { + handlers = _handlers[key]; + + for (i = 0; i < handlers.length;) { + if (handlers[i].scope === scope) handlers.splice(i, 1); + else i++; + } + } + + // 如果scope被删除,将scope重置为all + if (getScope() === scope) setScope(newScope || 'all'); +} + +// 清除修饰键 +function clearModifier(event) { + let key = event.keyCode || event.which || event.charCode; + let i = _downKeys.indexOf(key); + + // 从列表中清除按压过的键 + if (i >= 0) _downKeys.splice(i, 1); + + // 修饰键 shiftKey altKey ctrlKey (command||metaKey) 清除 + if (key === 93 || key === 224) key = 91; + if (key in _mods) { + _mods[key] = false; + + // 将修饰键重置为false + for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = false; + } +} + + +// 解除绑定某个范围的快捷键 +function unbind(key, scope) { + let multipleKeys = getKeys(key), + keys, + mods = [], + obj; + + for (let i = 0; i < multipleKeys.length; i++) { + // 将组合快捷键拆分为数组 + keys = multipleKeys[i].split('+'); + + // 记录每个组合键中的修饰键的键码 返回数组 + if (keys.length > 1) mods = getMods(keys); + + // 获取除修饰键外的键值key + key = keys[keys.length - 1]; + key = key === '*' ? '*' : code(key); + + // 判断是否传入范围,没有就获取范围 + if (!scope) scope = getScope(); + + // 如何key不在 _handlers 中返回不做处理 + if (!_handlers[key]) return; + + // 清空 handlers 中数据, + // 让触发快捷键键之后没有事件执行到达解除快捷键绑定的目的 + for (let r = 0; r < _handlers[key].length; r++) { + obj = _handlers[key][r]; + + // 判断是否在范围内并且键值相同 + if ( + obj.scope === scope && + compareArray(obj.mods, mods) + ) _handlers[key][r] = {}; + } + } +} + + +// 对监听对应快捷键的回调函数进行处理 +function eventHandler(event, handler, scope) { + let modifiersMatch; + + // 看它是否在当前范围 + if (handler.scope === scope || handler.scope === 'all') { + //检查是否匹配修饰符(如果有返回true) + modifiersMatch = handler.mods.length > 0; + + for (let y in _mods) { + if ( + (!_mods[y] && handler.mods.indexOf(+y) > -1) || + (_mods[y] && handler.mods.indexOf(+y) === -1) + ) modifiersMatch = false; + } + + // 调用处理程序,如果是修饰键不做处理 + if ( + (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || + modifiersMatch || + handler.shortcut === '*' + ) { + if (handler.method(event, handler) === false) { + if (event.preventDefault) event.preventDefault(); + else event.returnValue = false; + if (event.stopPropagation) event.stopPropagation(); + if (event.cancelBubble) event.cancelBubble = true; + } + } + } +} + + +// 处理keydown事件 +function dispatch(event) { + var key = event.keyCode || event.which || event.charCode, + scope, + asterisk = _handlers['*']; + + // 搜集绑定的键 + if (_downKeys.indexOf(key) === -1) _downKeys.push(key); + + // Gecko(Firefox)的command键值224,在Webkit(Chrome)中保持一致 + // Webkit左右command键值不一样 + if (key === 93 || key === 224) key = 91; + + if (key in _mods) { + _mods[key] = true; + + // 将特殊字符的key注册到 hotkeys 上 + for (var k in _modifier) if (_modifier[k] === key) hotkeys[k] = true; + + if (!asterisk) return; + } + + // 将modifierMap里面的修饰键绑定到event中 + for (var e in _mods) _mods[e] = event[modifierMap[e]]; + console.log('_downKeys:', _mods, _downKeys); + + // 表单控件过滤 默认表单控件不触发快捷键 + if (!hotkeys.filter.call(this, event)) return; + + // 获取范围 默认为all + scope = getScope(); + + // 对任何快捷键都需要做的处理 + if (asterisk) { + for (i = 0; i < asterisk.length; i++) { + if (asterisk[i].scope === scope) eventHandler(event, asterisk[i], scope); + } + } + + // key 不在_handlers中返回 + if (!(key in _handlers)) return; + + for (var i = 0; i < _handlers[key].length; i++) { + // 找到处理内容 + eventHandler(event, _handlers[key][i], scope); + } +} + +function hotkeys(key, scope, method) { + let keys = getKeys(key); // 需要处理的快捷键列表 + let mods = []; + let i = 0; + + + // 对为设定范围的判断 + if (method === undefined) { + method = scope; + scope = 'all'; // scope默认为all,所有范围都有效 + } + + // 对于每个快捷键进行处理 + for (; i < keys.length; i++) { + key = keys[i].split('+'); // 按键列表 + mods = []; + + // 如果是组合快捷键取得组合快捷键 + if (key.length > 1) mods = getMods(_modifier, key); + + // 将非修饰键转化为键码 + key = key[key.length - 1]; + key = key === '*' ? '*' : code(key); // *表示匹配所有快捷键 + + // 判断key是否在_handlers中,不在就赋一个空数组 + if (!(key in _handlers)) _handlers[key] = []; + + _handlers[key].push({ + scope, mods, + shortcut: keys[i], + method: method, + key: keys[i], + }); + } +} + + +// 在全局document上设置快捷键 +if (typeof document !== 'undefined') { + addEvent(document, "keydown", (e) => { + dispatch(e); + }); + addEvent(document, "keyup", (e) => { + clearModifier(e); + }); +} + +const _api = { setScope, getScope, deleteScope, getPressedKeyCodes, isPressed, filter, unbind }; +for (var a in _api) hotkeys[a] = _api[a]; + +if (typeof window !== 'undefined') { + var _hotkeys = window.hotkeys; + hotkeys.noConflict = (deep) => { + if (deep && window.hotkeys === hotkeys) { + window.hotkeys = _hotkeys; + } + return hotkeys; + }; + window.hotkeys = hotkeys; +} + +export default hotkeys; \ No newline at end of file diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..663e925 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,45 @@ +const isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; + +// 绑定事件 +function addEvent(object, event, method) { + if (object.addEventListener) { + object.addEventListener(event, method, false); + } else if (object.attachEvent) { + object.attachEvent('on' + event, function () { method(window.event); }); + } +} + +// 修饰键转换成对应的键码 +function getMods(modifier, key) { + var mods = key.slice(0, key.length - 1); + for (var i = 0; i < mods.length; i++) mods[i] = modifier[mods[i].toLowerCase()]; + return mods; +} + + +// 处理传的key字符串转换成数组 +function getKeys(key) { + if (!key) key = ''; + var keys, index; + + key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等 + keys = key.split(','); // 同时设置多个快捷键,以','分割 + index = keys.lastIndexOf(''); + + // 快捷键可能包含',',需特殊处理 + for (; index >= 0;) { + keys[index - 1] += ','; + keys.splice(index, 1); + index = keys.lastIndexOf(''); + } + + return keys; +} + + +export { + isff, + getMods, + getKeys, + addEvent +} \ No newline at end of file diff --git a/src/var.js b/src/var.js new file mode 100644 index 0000000..577ecca --- /dev/null +++ b/src/var.js @@ -0,0 +1,50 @@ +import { isff } from './utils'; + +const _keyMap = { // 特殊键 + backspace: 8, tab: 9, clear: 12, + enter: 13, 'return': 13, + esc: 27, escape: 27, space: 32, + left: 37, up: 38, right: 39, down: 40, + del: 46, 'delete': 46, + ins: 45, 'insert': 45, + home: 36, end: 35, + pageup: 33, pagedown: 34, '⇪': 20, 'capslock': 20, + ',': 188, '.': 190, '/': 191, + '`': 192, '-': isff ? 173 : 189, '=': isff ? 61 : 187, + ';': isff ? 59 : 186, '\'': 222, + '[': 219, ']': 221, '\\': 220 +} + +const _modifier = { //修饰键 + '⇧': 16, shift: 16, + '⌥': 18, alt: 18, option: 18, + '⌃': 17, ctrl: 17, control: 17, + '⌘': isff ? 224 : 91, cmd: isff ? 224 : 91, command: isff ? 224 : 91 +}; +const _downKeys = []; // 记录摁下的绑定键 +const modifierMap = { + 16: 'shiftKey', + 18: 'altKey', + 17: 'ctrlKey' +}; +const _mods = { 16: false, 18: false, 17: false }; +const _handlers = {}; + + +// F1~F12 特殊键 +for (var k = 1; k < 20; k++) { + _keyMap['f' + k] = 111 + k; +} + +// 兼容Firefox处理 +modifierMap[isff ? 224 : 91] = 'metaKey'; +_mods[isff ? 224 : 91] = false; + +export { + _keyMap, + _modifier, + _downKeys, + modifierMap, + _mods, + _handlers, +} \ No newline at end of file diff --git a/test/hotkeys.js b/test/hotkeys.js deleted file mode 100644 index cc66f5c..0000000 --- a/test/hotkeys.js +++ /dev/null @@ -1,305 +0,0 @@ -var tape = require('tape'); -require('tape-dom')(tape); -var hotkeys = require('../dist/hotkeys.js'); -var isff = navigator.userAgent.toLowerCase().indexOf('firefox') > 0; - -// 模拟键盘摁键 -// http://output.jsbin.com/awenaq/3 -function __triggerKeyboardEvent(el, keyCode, opt) { - var eventObj = document.createEventObject ? - document.createEventObject() : document.createEvent("Events"); - - if (eventObj.initEvent) { - eventObj.initEvent("keydown", true, true); - } - - eventObj.keyCode = keyCode; - eventObj.which = keyCode; - - if (opt) { - for (var a in opt) { - eventObj[a] = opt[a]; - } - } - - el.dispatchEvent ? el.dispatchEvent(eventObj) : el.fireEvent("onkeydown", eventObj); -} - - -tape('hotkeys 单元测试', function (t) { - - hotkeys('w', function(e){ - t.equal(e.keyCode, 87, '单个按键 w keyCode == 87'); - }); - __triggerKeyboardEvent(document.body, 87); - - hotkeys('enter', function(e){ - t.equal(e.keyCode, 13, '单个特殊键按键 enter,enter验证 keyCode == 13'); - }); - hotkeys('return', function(e){ - t.equal(e.keyCode, 13, '单个特殊键按键 return,return验证 keyCode == 13'); - }); - __triggerKeyboardEvent(document.body, 13); - - - hotkeys('space', function(e){ - t.equal(e.keyCode, 32, '单个特殊键按键 space,space验证 keyCode == 32'); - }); - __triggerKeyboardEvent(document.body, 32); - - hotkeys('backspace', function(e){ - t.equal(e.keyCode, 8, '单个特殊键按键 backspace,backspace 验证 keyCode == 8'); - }); - __triggerKeyboardEvent(document.body, 8); - - hotkeys('tab', function(e){ - t.equal(e.keyCode, 9, '单个特殊键按键 tab,tab 验证 keyCode == 9'); - }); - __triggerKeyboardEvent(document.body, 9); - - hotkeys('clear', function(e){ - t.equal(e.keyCode, 12, '单个特殊键按键 clear,clear 验证 keyCode == 12'); - }); - __triggerKeyboardEvent(document.body, 12); - - hotkeys(',', function(e){ - t.equal(e.keyCode, 188, '单个特殊键按键 , ,, 验证 keyCode == 188'); - }); - __triggerKeyboardEvent(document.body, 188); - - hotkeys('.', function(e){ - t.equal(e.keyCode, 190, '单个特殊键按键 . ,. 验证 keyCode == 190'); - }); - __triggerKeyboardEvent(document.body, 190); - - hotkeys('.', function(e){ - t.equal(e.keyCode, 190, '单个特殊键按键 . ,. 验证 keyCode == 190'); - }); - __triggerKeyboardEvent(document.body, 190); - - hotkeys('/', function(e){ - t.equal(e.keyCode, 191, '单个特殊键按键 / ,/ 验证 keyCode == 191'); - }); - __triggerKeyboardEvent(document.body, 191); - - hotkeys('`', function(e){ - t.equal(e.keyCode, 192, '单个特殊键按键 ` ,` 验证 keyCode == 192'); - }); - __triggerKeyboardEvent(document.body, 192); - - hotkeys('-', function(e){ - t.equal(e.keyCode, isff?173:189, '单个特殊键按键 -,- 验证 keyCode == 火狐?173:189'); - }); - __triggerKeyboardEvent(document.body, isff?173:189); - - hotkeys('=', function(e){ - t.equal(e.keyCode, isff?61:187, '单个特殊键按键 =,= 验证 keyCode == 火狐?61:187'); - }); - __triggerKeyboardEvent(document.body, isff?61:187); - - hotkeys(';', function(e){ - t.equal(e.keyCode, isff?59:186, '单个特殊键按键 ; ,; 验证 keyCode == 火狐?59:186'); - }); - __triggerKeyboardEvent(document.body, isff?59:186); - - hotkeys("\'".toString(), function(e){ - t.equal(e.keyCode, 222, "单个特殊键按键 \' ,\' 验证 keyCode == 222 "); - }); - __triggerKeyboardEvent(document.body, 222); - - hotkeys("\\".toString(), function(e){ - t.equal(e.keyCode, 220, "单个特殊键按键 \\ ,\\ 验证 keyCode == 220 "); - }); - __triggerKeyboardEvent(document.body, 220); - - hotkeys("[".toString(), function(e){ - t.equal(e.keyCode, 219, "单个特殊键按键 [ ,[ 验证 keyCode == 219 "); - }); - __triggerKeyboardEvent(document.body, 219); - - hotkeys("]".toString(), function(e){ - t.equal(e.keyCode, 221, "单个特殊键按键 ] ,] 验证 keyCode == 221 "); - }); - __triggerKeyboardEvent(document.body, 221); - - hotkeys('left', function(e){ - t.equal(e.keyCode, 37, '单个特殊键按键 left,left 验证 keyCode == 37'); - }); - __triggerKeyboardEvent(document.body, 37); - - hotkeys('up', function(e){ - t.equal(e.keyCode, 38, '单个特殊键按键 up,up 验证 keyCode == 38'); - }); - __triggerKeyboardEvent(document.body, 38); - - hotkeys('del', function(e){ - t.equal(e.keyCode, 46, '单个特殊键按键 del,del 验证 keyCode == 46'); - }); - hotkeys('delete', function(e){ - t.equal(e.keyCode, 46, '单个特殊键按键 delete,delete 验证 keyCode == 46'); - }); - __triggerKeyboardEvent(document.body, 46); - - hotkeys('home', function(e){ - t.equal(e.keyCode, 36, '单个特殊键按键 home,home 验证 keyCode == 36'); - }); - __triggerKeyboardEvent(document.body, 36); - - hotkeys('pageup', function(e){ - t.equal(e.keyCode, 33, '单个特殊键按键 pageup,pageup 验证 keyCode == 33'); - }); - __triggerKeyboardEvent(document.body, 33); - - hotkeys('pagedown', function(e){ - t.equal(e.keyCode, 34, '单个特殊键按键 pagedown,pagedown 验证 keyCode == 34'); - }); - __triggerKeyboardEvent(document.body, 34); - - - hotkeys('end', function(e){ - t.equal(e.keyCode, 35, '单个特殊键按键 end,end 验证 keyCode == 35'); - }); - __triggerKeyboardEvent(document.body, 35); - - - hotkeys('right', function(e){ - t.equal(e.keyCode, 39, '单个特殊键按键 right,right 验证 keyCode == 39'); - }); - __triggerKeyboardEvent(document.body, 39); - - hotkeys('down', function(e){ - t.equal(e.keyCode, 40, '单个特殊键按键 down,down 验证 keyCode == 40'); - }); - __triggerKeyboardEvent(document.body, 40); - - hotkeys('esc', function(e){ - t.equal(e.keyCode, 27, '单个特殊键按键 esc,esc 验证 keyCode == 27'); - }); - hotkeys('escape', function(e){ - t.equal(e.keyCode, 27, '单个特殊键按键 escape,escape 验证 keyCode == 27'); - }); - __triggerKeyboardEvent(document.body, 27); - - - hotkeys('CapsLock', function(e){ - t.equal(e.keyCode, 20, '单个特殊键按键 CapsLock,CapsLock验证 keyCode == 20'); - }); - hotkeys('⇪', function(e){ - t.equal(e.keyCode, 20, '单个特殊键按键 ⇪,⇪验证 keyCode == 20'); - }); - __triggerKeyboardEvent(document.body, 20); - - - hotkeys('⌘+d', function(e){ - t.equal(e.keyCode, 82, '组合键 ⌘+d,d验证 keyCode == 82'); - t.equal(e.metaKey, true, '组合键 ⌘+d,alt验证 metaKey == true'); - return false; - }); - __triggerKeyboardEvent(document.body, 82,{ - metaKey:true - }); - - hotkeys('alt+d', function(e){ - t.equal(e.keyCode, 68, '组合键 alt+d,d验证 keyCode == 68'); - t.equal(e.altKey, true, '组合键 alt+d,alt验证 altKey == true'); - }); - __triggerKeyboardEvent(document.body, 68,{ - altKey:true - }); - - hotkeys('shift+a', function(e){ - t.equal(e.keyCode, 65, '组合键 shift+a,a验证 keyCode == 65'); - t.equal(e.shiftKey, true, '组合键 shift+a,shift验证 shiftKey == true'); - }); - __triggerKeyboardEvent(document.body, 65,{ - shiftKey:true - }); - - hotkeys('⇧+a', function(e){ - t.equal(e.keyCode, 65, '组合键 ⇧+a,a验证 keyCode == 65'); - t.equal(e.shiftKey, true, '组合键 ⇧+a,⇧验证 shiftKey == true'); - }); - __triggerKeyboardEvent(document.body, 65,{ - shiftKey:true - }); - - hotkeys('⌘+a', function(e){ - t.equal(e.keyCode, 65, '组合键 ⌘+a,a验证 keyCode == 65'); - t.equal(e.metaKey, true, '组合键 ⌘+a,⌘验证 metaKey == true'); - }); - __triggerKeyboardEvent(document.body, 65,{ - metaKey:true - }); - - hotkeys('⌃+a', function(e){ - t.equal(e.keyCode, 65, '组合键 ⌃+a,a验证 keyCode == 65'); - t.equal(e.ctrlKey, true, '组合键 ⌃+a,⌃验证 ctrlKey == true'); - }); - __triggerKeyboardEvent(document.body, 65,{ - ctrlKey:true - }); - hotkeys.unbind("⌃+a") - - hotkeys('⌥+a', function(e){ - t.equal(e.keyCode, 65, '组合键 ⌥+a,a验证 keyCode == 65'); - t.equal(e.altKey, true, '组合键 ⌥+a,⌥验证 altKey == true'); - }); - __triggerKeyboardEvent(document.body, 65,{ - altKey:true - }); - - hotkeys('ctrl+,,ctrl+d', function (e) { - t.equal(e.keyCode, 188, '组合键 ctrl+,,,验证 keyCode == 65'); - t.equal(e.ctrlKey, true, '组合键 ctrl+,,ctrl验证 ctrlKey == true'); - }); - __triggerKeyboardEvent(document.body, 188, { - ctrlKey: true - }); - hotkeys.unbind("ctrl+,,ctrl+d") - - hotkeys('Ctrl+A', function (e) { - t.equal(e.keyCode, 65, '大小写组合键 Ctrl+A,A验证 keyCode == 65'); - t.equal(e.ctrlKey, true, '大小写组合键 Ctrl+A,Ctrl验证 ctrlKey == true'); - }); - __triggerKeyboardEvent(document.body, 65, { - ctrlKey: true - }); - hotkeys.unbind("Ctrl+A") - - hotkeys('CTRL+A', function (e) { - t.equal(e.keyCode, 65, '大小写组合键 CTRL+A,A验证 keyCode == 65'); - t.equal(e.ctrlKey, true, '大小写组合键 CTRL+A,CTRL验证 ctrlKey == true'); - }); - __triggerKeyboardEvent(document.body, 65, { - ctrlKey: true - }); - hotkeys.unbind("CTRL+A") - - hotkeys('⌃+a',function(){ - t.equal(hotkeys.getScope(), 'all', ' 验证 getScope() == all'); - }); - __triggerKeyboardEvent(document.body, 65,{ - ctrlKey:true - }); - hotkeys.unbind("⌃+a") - - hotkeys('⌃+a','scope1',function(){ - t.equal(hotkeys.getScope(), 'scope1', ' 验证 getScope() == scope1'); - }); - __triggerKeyboardEvent(document.body, 65,{ - ctrlKey:true - }); - - hotkeys('⌃+a','scope2',function(){ - t.equal(hotkeys.getScope(), 'scope2', ' 验证 getScope() == scope2'); - }); - hotkeys.setScope('scope1'); - __triggerKeyboardEvent(document.body, 65,{ - ctrlKey:true - }); - hotkeys.setScope('scope2'); - __triggerKeyboardEvent(document.body, 65,{ - ctrlKey:true - }); - -}); diff --git a/test/hotkeys.test.js b/test/hotkeys.test.js deleted file mode 100644 index dcf96de..0000000 --- a/test/hotkeys.test.js +++ /dev/null @@ -1 +0,0 @@ -!function(){return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r||t)},l,l.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s=0;e--)if(this[e]===t)return e;return-1});for(var t,e="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0,r={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,"⇪":20,capslock:20,",":188,".":190,"/":191,"`":192,"-":e?173:189,"=":e?61:187,";":e?59:186,"'":222,"[":219,"]":221,"\\":220},n="all",i={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":e?224:91,cmd:e?224:91,command:e?224:91},o=[],s={16:"shiftKey",18:"altKey",17:"ctrlKey"},a={16:!1,18:!1,17:!1},u={},f=1;f<20;f++)r["f"+f]=111+f;function l(t){return r[t.toLowerCase()]||t.toUpperCase().charCodeAt(0)}function c(t){n=t||"all"}function h(){return n||"all"}function p(t,e,r){t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent&&t.attachEvent("on"+e,function(){r(window.event)})}function d(t,e,r){var n;if(e.scope===r||"all"===e.scope){for(var i in n=e.mods.length>0,a)(!a[i]&&e.mods.indexOf(+i)>-1||a[i]&&-1===e.mods.indexOf(+i))&&(n=!1);(0!==e.mods.length||a[16]||a[18]||a[17]||a[91])&&!n&&"*"!==e.shortcut||!1===e.method(t,e)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0))}}function g(t,e){for(var r=t.length>=e.length?t:e,n=t.length>=e.length?e:t,i=0;i=0;)e[r-1]+=",",e.splice(r,1),r=e.lastIndexOf("");return e}function m(t,e,r){var n=b(t),i=[],o=0;for(void 0===r&&(r=e,e="all");o1&&(i=y(t)),(t="*"===(t=t[t.length-1])?"*":l(t))in u||(u[t]=[]),u[t].push({shortcut:n[o],scope:e,method:r,key:n[o],mods:i})}for(var v in s[e?224:91]="metaKey",a[e?224:91]=!1,"undefined"!=typeof document&&(p(document,"keydown",function(t){!function(t){var e,r=t.keyCode||t.which||t.charCode,n=u["*"];if(-1===o.indexOf(r)&&o.push(r),93!==r&&224!==r||(r=91),r in a){for(var f in a[r]=!0,i)i[f]===r&&(m[f]=!0);if(!n)return}for(var l in a)a[l]=t[s[l]];if(m.filter.call(this,t)){if(e=h(),n)for(c=0;c=0&&o.splice(r,1);93!==e&&224!==e||(e=91);if(e in a)for(var n in a[e]=!1,i)i[n]===e&&(m[n]=!1)}(t)})),t={setScope:c,getScope:h,deleteScope:function(t,e){var r,n,i;for(r in t||(t=h()),u)for(n=u[r],i=0;i1&&(o=y(r)),t="*"===(t=r[r.length-1])?"*":l(t),e||(e=h()),!u[t])return;for(var a=0;a0?u-4:u;var l=0;for(e=0;e>16&255,a[l++]=n>>8&255,a[l++]=255&n;2===s?(n=i[t.charCodeAt(e)]<<2|i[t.charCodeAt(e+1)]>>4,a[l++]=255&n):1===s&&(n=i[t.charCodeAt(e)]<<10|i[t.charCodeAt(e+1)]<<4|i[t.charCodeAt(e+2)]>>2,a[l++]=n>>8&255,a[l++]=255&n);return a},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o="",s=[],a=0,u=r-i;au?u:a+16383));1===i?(e=t[r-1],o+=n[e>>2],o+=n[e<<4&63],o+="=="):2===i&&(e=(t[r-2]<<8)+t[r-1],o+=n[e>>10],o+=n[e>>4&63],o+=n[e<<2&63],o+="=");return s.push(o),s.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function l(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){},{}],4:[function(t,e,r){arguments[4][3][0].apply(r,arguments)},{dup:3}],5:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(t>o)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=a.prototype,e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(t)}return u(t,e,r)}function u(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return B(t)?function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function p(t,e){if(a.isBuffer(t))return t.length;if(N(t)||B(t))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(t).length;default:if(n)return L(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),R(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var l=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var c=!0,h=0;hi&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s239?4:f>223?3:f>191?2:1;if(i+c<=r)switch(c){case 1:f<128&&(l=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(l=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=c}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return x(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t,e,r,n,i){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(o,s),f=this.slice(n,i),l=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,s,a,u,f,l,c,h,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return h=e,p=r,I(L(t,(c=this).length-h),c,h,p);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return u=this,f=e,l=r,I(D(t),u,f,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,I(function(t,e){for(var r,n,i,o=[],s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-s),o,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function x(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function A(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,o){return e=+e,r>>>=0,o||A(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||A(t,0,r,8),i.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||j(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||j(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function D(t){return n.toByteArray(function(t){if((t=t.trim().replace(O,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function I(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function B(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function N(t){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(t)}function R(t){return t!=t}},{"base64-js":2,ieee754:27}],6:[function(t,e,r){(function(t){function e(t){return Object.prototype.toString.call(t)}r.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===e(t)},r.isBoolean=function(t){return"boolean"==typeof t},r.isNull=function(t){return null===t},r.isNullOrUndefined=function(t){return null==t},r.isNumber=function(t){return"number"==typeof t},r.isString=function(t){return"string"==typeof t},r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=function(t){return void 0===t},r.isRegExp=function(t){return"[object RegExp]"===e(t)},r.isObject=function(t){return"object"==typeof t&&null!==t},r.isDate=function(t){return"[object Date]"===e(t)},r.isError=function(t){return"[object Error]"===e(t)||t instanceof Error},r.isFunction=function(t){return"function"==typeof t},r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t.isBuffer}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":29}],7:[function(t,e,r){var n=Array.prototype.slice,i=t("./lib/keys.js"),o=t("./lib/is_arguments.js"),s=e.exports=function(t,e,r){return r||(r={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=typeof t&&"object"!=typeof e?r.strict?t===e:t==e:function(t,e,r){var f,l;if(a(t)||a(e))return!1;if(t.prototype!==e.prototype)return!1;if(o(t))return!!o(e)&&(t=n.call(t),e=n.call(e),s(t,e,r));if(u(t)){if(!u(e))return!1;if(t.length!==e.length)return!1;for(f=0;f=0;f--)if(c[f]!=h[f])return!1;for(f=c.length-1;f>=0;f--)if(l=c[f],!s(t[l],e[l],r))return!1;return typeof t==typeof e}(t,e,r))};function a(t){return null==t}function u(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}},{"./lib/is_arguments.js":8,"./lib/keys.js":9}],8:[function(t,e,r){var n="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();function i(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}(r=e.exports=n?i:o).supported=i,r.unsupported=o},{}],9:[function(t,e,r){function n(t){var e=[];for(var r in t)e.push(r);return e}(e.exports="function"==typeof Object.keys?Object.keys:n).shim=n},{}],10:[function(t,e,r){"use strict";var n=t("object-keys"),i=t("foreach"),o="function"==typeof Symbol&&"symbol"==typeof Symbol(),s=Object.prototype.toString,a=Object.defineProperty&&function(){var t={};try{for(var e in Object.defineProperty(t,"x",{enumerable:!1,value:t}),t)return!1;return t.x===t}catch(t){return!1}}(),u=function(t,e,r,n){var i;e in t&&("function"!=typeof(i=n)||"[object Function]"!==s.call(i)||!n())||(a?Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:r,writable:!0}):t[e]=r)},f=function(t,e){var r=arguments.length>2?arguments[2]:{},s=n(e);o&&(s=s.concat(Object.getOwnPropertySymbols(e))),i(s,function(n){u(t,n,e[n],r[n])})};f.supportsDescriptors=!!a,e.exports=f},{foreach:21,"object-keys":34}],11:[function(t,e,r){e.exports=function(){for(var t=0;t>0},ToUint32:function(t){return this.ToNumber(t)>>>0},ToUint16:function(t){var e=this.ToNumber(t);if(n(e)||0===e||!i(e))return 0;var r=o(e)*Math.floor(Math.abs(e));return s(r,65536)},ToString:function(t){return String(t)},ToObject:function(t){return this.CheckObjectCoercible(t),Object(t)},CheckObjectCoercible:function(t,e){if(null==t)throw new TypeError(e||"Cannot call method on "+t);return t},IsCallable:a,SameValue:function(t,e){return t===e?0!==t||1/t==1/e:n(t)&&n(e)},Type:function(t){return null===t?"Null":void 0===t?"Undefined":"function"==typeof t||"object"==typeof t?"Object":"number"==typeof t?"Number":"boolean"==typeof t?"Boolean":"string"==typeof t?"String":void 0},IsPropertyDescriptor:function(t){if("Object"!==this.Type(t))return!1;var e={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var r in t)if(f(t,r)&&!e[r])return!1;var n=f(t,"[[Value]]"),i=f(t,"[[Get]]")||f(t,"[[Set]]");if(n&&i)throw new TypeError("Property Descriptors may not be both accessor and data descriptors");return!0},IsAccessorDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!f(t,"[[Get]]")&&!f(t,"[[Set]]"))},IsDataDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!f(t,"[[Value]]")&&!f(t,"[[Writable]]"))},IsGenericDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!this.IsAccessorDescriptor(t)&&!this.IsDataDescriptor(t)},FromPropertyDescriptor:function(t){if(void 0===t)return t;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");if(this.IsDataDescriptor(t))return{value:t["[[Value]]"],writable:!!t["[[Writable]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};if(this.IsAccessorDescriptor(t))return{get:t["[[Get]]"],set:t["[[Set]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};throw new TypeError("FromPropertyDescriptor must be called with a fully populated Property Descriptor")},ToPropertyDescriptor:function(t){if("Object"!==this.Type(t))throw new TypeError("ToPropertyDescriptor requires an object");var e={};if(f(t,"enumerable")&&(e["[[Enumerable]]"]=this.ToBoolean(t.enumerable)),f(t,"configurable")&&(e["[[Configurable]]"]=this.ToBoolean(t.configurable)),f(t,"value")&&(e["[[Value]]"]=t.value),f(t,"writable")&&(e["[[Writable]]"]=this.ToBoolean(t.writable)),f(t,"get")){var r=t.get;if(void 0!==r&&!this.IsCallable(r))throw new TypeError("getter must be a function");e["[[Get]]"]=r}if(f(t,"set")){var n=t.set;if(void 0!==n&&!this.IsCallable(n))throw new TypeError("setter must be a function");e["[[Set]]"]=n}if((f(e,"[[Get]]")||f(e,"[[Set]]"))&&(f(e,"[[Value]]")||f(e,"[[Writable]]")))throw new TypeError("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e}};e.exports=l},{"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/mod":15,"./helpers/sign":16,"es-to-primitive/es5":17,has:26,"is-callable":30}],13:[function(t,e,r){var n=Number.isNaN||function(t){return t!=t};e.exports=Number.isFinite||function(t){return"number"==typeof t&&!n(t)&&t!==1/0&&t!==-1/0}},{}],14:[function(t,e,r){e.exports=Number.isNaN||function(t){return t!=t}},{}],15:[function(t,e,r){e.exports=function(t,e){var r=t%e;return Math.floor(r>=0?r:r+e)}},{}],16:[function(t,e,r){e.exports=function(t){return t>=0?1:-1}},{}],17:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=t("./helpers/isPrimitive"),o=t("is-callable"),s=function(t,e){var r=e||("[object Date]"===n.call(t)?String:Number);if(r===String||r===Number){var s,a,u=r===String?["toString","valueOf"]:["valueOf","toString"];for(a=0;a0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],20:[function(t,e,r){var n=t("is-function");e.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");arguments.length<3&&(r=this);"[object Array]"===i.call(t)?function(t,e,r){for(var n=0,i=t.length;ne.length?t:e,s=t.length>e.length?e:t,a=o.indexOf(s);if(-1!=a)return i=[[1,o.substring(0,a)],[0,s],[1,o.substring(a+s.length)]],t.length>e.length&&(i[0][0]=i[2][0]=-1),i;if(1==s.length)return[[-1,t],[1,e]];var u=this.diff_halfMatch_(t,e);if(u){var f=u[0],l=u[1],c=u[2],h=u[3],p=u[4],d=this.diff_main(f,c,r,n),g=this.diff_main(l,h,r,n);return d.concat([[0,p]],g)}return r&&t.length>100&&e.length>100?this.diff_lineMode_(t,e,n):this.diff_bisect_(t,e,n)},n.prototype.diff_lineMode_=function(t,e,r){t=(l=this.diff_linesToChars_(t,e)).chars1,e=l.chars2;var n=l.lineArray,i=this.diff_main(t,e,!1,r);this.diff_charsToLines_(i,n),this.diff_cleanupSemantic(i),i.push([0,""]);for(var o=0,s=0,a=0,u="",f="";o=1&&a>=1){i.splice(o-s-a,s+a),o=o-s-a;for(var l,c=(l=this.diff_main(u,f,!1,r)).length-1;c>=0;c--)i.splice(o,0,l[c]);o+=l.length}a=0,s=0,u="",f=""}o++}return i.pop(),i},n.prototype.diff_bisect_=function(t,e,r){for(var n=t.length,i=e.length,o=Math.ceil((n+i)/2),s=o,a=2*o,u=new Array(a),f=new Array(a),l=0;lr);b++){for(var m=-b+p;m<=b-d;m+=2){for(var v=s+m,w=(S=m==-b||m!=b&&u[v-1]n)d+=2;else if(w>i)p+=2;else if(h){if((k=s+c-m)>=0&&k=(x=n-f[k]))return this.diff_bisectSplit_(t,e,S,w,r)}}for(var _=-b+g;_<=b-y;_+=2){for(var x,k=s+_,E=(x=_==-b||_!=b&&f[k-1]n)y+=2;else if(E>i)g+=2;else if(!h){if((v=s+c-_)>=0&&v=(x=n-x))return this.diff_bisectSplit_(t,e,S,w,r)}}}}return[[-1,t],[1,e]]},n.prototype.diff_bisectSplit_=function(t,e,r,n,i){var o=t.substring(0,r),s=e.substring(0,n),a=t.substring(r),u=e.substring(n),f=this.diff_main(o,s,!1,i),l=this.diff_main(a,u,!1,i);return f.concat(l)},n.prototype.diff_linesToChars_=function(t,e){var r=[],n={};function i(t){for(var e="",i=0,o=-1,s=r.length;on?t=t.substring(r-n):re.length?t:e,n=t.length>e.length?e:t;if(r.length<4||2*n.length=t.length?[n,o,s,a,l]:null}var s,a,u,f,l,c=o(r,n,Math.ceil(r.length/4)),h=o(r,n,Math.ceil(r.length/2));return c||h?(s=h?c&&c[4].length>h[4].length?c:h:c,t.length>e.length?(a=s[0],u=s[1],f=s[2],l=s[3]):(f=s[0],l=s[1],a=s[2],u=s[3]),[a,u,f,l,s[4]]):null},n.prototype.diff_cleanupSemantic=function(t){for(var e=!1,r=[],n=0,i=null,o=0,s=0,a=0,u=0,f=0;o0?r[n-1]:-1,s=0,a=0,u=0,f=0,i=null,e=!0)),o++;for(e&&this.diff_cleanupMerge(t),this.diff_cleanupSemanticLossless(t),o=1;o=p?(h>=l.length/2||h>=c.length/2)&&(t.splice(o,0,[0,c.substring(0,h)]),t[o-1][1]=l.substring(0,l.length-h),t[o+1][1]=c.substring(h),o++):(p>=l.length/2||p>=c.length/2)&&(t.splice(o,0,[0,l.substring(0,p)]),t[o-1][0]=1,t[o-1][1]=c.substring(0,c.length-p),t[o+1][0]=-1,t[o+1][1]=l.substring(p),o++),o++}o++}},n.prototype.diff_cleanupSemanticLossless=function(t){function e(t,e){if(!t||!e)return 6;var r=t.charAt(t.length-1),i=e.charAt(0),o=r.match(n.nonAlphaNumericRegex_),s=i.match(n.nonAlphaNumericRegex_),a=o&&r.match(n.whitespaceRegex_),u=s&&i.match(n.whitespaceRegex_),f=a&&r.match(n.linebreakRegex_),l=u&&i.match(n.linebreakRegex_),c=f&&t.match(n.blanklineEndRegex_),h=l&&e.match(n.blanklineStartRegex_);return c||h?5:f||l?4:o&&!a&&u?3:a||u?2:o||s?1:0}for(var r=1;r=h&&(h=p,f=i,l=o,c=s)}t[r-1][1]!=f&&(f?t[r-1][1]=f:(t.splice(r-1,1),r--),t[r][1]=l,c?t[r+1][1]=c:(t.splice(r+1,1),r--))}r++}},n.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,n.whitespaceRegex_=/\s/,n.linebreakRegex_=/[\r\n]/,n.blanklineEndRegex_=/\n\r?\n$/,n.blanklineStartRegex_=/^\r?\n\r?\n/,n.prototype.diff_cleanupEfficiency=function(t){for(var e=!1,r=[],n=0,i=null,o=0,s=!1,a=!1,u=!1,f=!1;o0?r[n-1]:-1,u=f=!1),e=!0)),o++;e&&this.diff_cleanupMerge(t)},n.prototype.diff_cleanupMerge=function(t){t.push([0,""]);for(var e,r=0,n=0,i=0,o="",s="";r1?(0!==n&&0!==i&&(0!==(e=this.diff_commonPrefix(s,o))&&(r-n-i>0&&0==t[r-n-i-1][0]?t[r-n-i-1][1]+=s.substring(0,e):(t.splice(0,0,[0,s.substring(0,e)]),r++),s=s.substring(e),o=o.substring(e)),0!==(e=this.diff_commonSuffix(s,o))&&(t[r][1]=s.substring(s.length-e)+t[r][1],s=s.substring(0,s.length-e),o=o.substring(0,o.length-e))),0===n?t.splice(r-i,n+i,[1,s]):0===i?t.splice(r-n,n+i,[-1,o]):t.splice(r-n-i,n+i,[-1,o],[1,s]),r=r-n-i+(n?1:0)+(i?1:0)+1):0!==r&&0==t[r-1][0]?(t[r-1][1]+=t[r][1],t.splice(r,1)):r++,i=0,n=0,o="",s=""}""===t[t.length-1][1]&&t.pop();var a=!1;for(r=1;re));r++)o=n,s=i;return t.length!=r&&-1===t[r][0]?s:s+(e-o)},n.prototype.diff_prettyHtml=function(t){for(var e=[],r=/&/g,n=//g,o=/\n/g,s=0;s");switch(a){case 1:e[s]=''+u+"";break;case-1:e[s]=''+u+"";break;case 0:e[s]=""+u+""}}return e.join("")},n.prototype.diff_text1=function(t){for(var e=[],r=0;rthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var n=this.match_alphabet_(e),i=this;function o(t,n){var o=t/e.length,s=Math.abs(r-n);return i.Match_Distance?o+s/i.Match_Distance:s?1:o}var s=this.Match_Threshold,a=t.indexOf(e,r);-1!=a&&(s=Math.min(o(0,a),s),-1!=(a=t.lastIndexOf(e,r+e.length))&&(s=Math.min(o(0,a),s)));var u,f,l=1<=d;b--){var m=n[t.charAt(b-1)];if(y[b]=0===p?(y[b+1]<<1|1)&m:(y[b+1]<<1|1)&m|(c[b+1]|c[b])<<1|1|c[b+1],y[b]&l){var v=o(p,b-1);if(v<=s){if(s=v,!((a=b-1)>r))break;d=Math.max(1,2*r-a)}}}if(o(p+1,r)>s)break;c=y}return a},n.prototype.match_alphabet_=function(t){for(var e={},r=0;r2&&(this.diff_cleanupSemantic(o),this.diff_cleanupEfficiency(o));else if(t&&"object"==typeof t&&void 0===e&&void 0===r)o=t,i=this.diff_text1(o);else if("string"==typeof t&&e&&"object"==typeof e&&void 0===r)i=t,o=e;else{if("string"!=typeof t||"string"!=typeof e||!r||"object"!=typeof r)throw new Error("Unknown call format to patch_make.");i=t,o=r}if(0===o.length)return[];for(var s=[],a=new n.patch_obj,u=0,f=0,l=0,c=i,h=i,p=0;p=2*this.Patch_Margin&&u&&(this.patch_addContext_(a,c),s.push(a),a=new n.patch_obj,u=0,c=h,f=l)}1!==d&&(f+=g.length),-1!==d&&(l+=g.length)}return u&&(this.patch_addContext_(a,c),s.push(a)),s},n.prototype.patch_deepCopy=function(t){for(var e=[],r=0;rthis.Match_MaxBits?-1!=(s=this.match_main(e,f.substring(0,this.Match_MaxBits),u))&&(-1==(l=this.match_main(e,f.substring(f.length-this.Match_MaxBits),u+f.length-this.Match_MaxBits))||s>=l)&&(s=-1):s=this.match_main(e,f,u),-1==s)i[o]=!1,n-=t[o].length2-t[o].length1;else if(i[o]=!0,n=s-u,f==(a=-1==l?e.substring(s,s+f.length):e.substring(s,l+this.Match_MaxBits)))e=e.substring(0,s)+this.diff_text2(t[o].diffs)+e.substring(s+f.length);else{var c=this.diff_main(f,a,!1);if(f.length>this.Match_MaxBits&&this.diff_levenshtein(c)/f.length>this.Patch_DeleteThreshold)i[o]=!1;else{this.diff_cleanupSemanticLossless(c);for(var h,p=0,d=0;do[0][1].length){var s=e-o[0][1].length;o[0][1]=r.substring(o[0][1].length)+o[0][1],i.start1-=s,i.start2-=s,i.length1+=s,i.length2+=s}if(0==(o=(i=t[t.length-1]).diffs).length||0!=o[o.length-1][0])o.push([0,r]),i.length1+=e,i.length2+=e;else if(e>o[o.length-1][1].length){s=e-o[o.length-1][1].length;o[o.length-1][1]+=r.substring(0,s),i.length1+=s,i.length2+=s}return r},n.prototype.patch_splitMax=function(t){for(var e=this.Match_MaxBits,r=0;r2*e?(u.length1+=c.length,o+=c.length,f=!1,u.diffs.push([l,c]),i.diffs.shift()):(c=c.substring(0,e-u.length1-this.Patch_Margin),u.length1+=c.length,o+=c.length,0===l?(u.length2+=c.length,s+=c.length):f=!1,u.diffs.push([l,c]),c==i.diffs[0][1]?i.diffs.shift():i.diffs[0][1]=i.diffs[0][1].substring(c.length))}a=(a=this.diff_text2(u.diffs)).substring(a.length-this.Patch_Margin);var h=this.diff_text1(i.diffs).substring(0,this.Patch_Margin);""!==h&&(u.length1+=h.length,u.length2+=h.length,0!==u.diffs.length&&0===u.diffs[u.diffs.length-1][0]?u.diffs[u.diffs.length-1][1]+=h:u.diffs.push([0,h])),f||t.splice(++r,0,u)}}},n.prototype.patch_toText=function(t){for(var e=[],r=0;r>1,l=-7,c=r?i-1:0,h=r?-1:1,p=t[e+c];for(c+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+c],c+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+c],c+=h,l-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=f}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,f=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?h/u:h*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=l?(a=0,s=l):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,f-=8);t[r+p-d]|=128*g}},{}],28:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],29:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||"function"==typeof(e=t).readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))||!!t._isBuffer);var e}},{}],30:[function(t,e,r){"use strict";var n=Function.prototype.toString,i=/^\s*class /,o=function(t){try{var e=n.call(t).replace(/\/\/.*\n/g,"").replace(/\/\*[.\s\S]*\*\//g,"").replace(/\n/gm," ").replace(/ {2}/g," ");return i.test(e)}catch(t){return!1}},s=Object.prototype.toString,a="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;e.exports=function(t){if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(a)return function(t){try{return!o(t)&&(n.call(t),!0)}catch(t){return!1}}(t);if(o(t))return!1;var e=s.call(t);return"[object Function]"===e||"[object GeneratorFunction]"===e}},{}],31:[function(t,e,r){e.exports=function(t){var e=n.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)};var n=Object.prototype.toString},{}],32:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],33:[function(t,e,r){var n="function"==typeof Map&&Map.prototype,i=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,o=n&&i&&"function"==typeof i.get?i.get:null,s=n&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,u=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,f=a&&u&&"function"==typeof u.get?u.get:null,l=a&&Set.prototype.forEach,c=Boolean.prototype.valueOf,h=Object.prototype.toString;function p(t){return"[object Array]"===y(t)}e.exports=function t(e,r,n,i){if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return"'"+e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,b)+"'";if("number"==typeof e)return 0===e?1/0/e>0?"0":"-0":String(e);r||(r={});var a,u=void 0===r.depth?5:r.depth;if(void 0===n&&(n=0),n>=u&&u>0&&"object"==typeof e)return"[Object]";if(void 0===i)i=[];else if(function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;r=0)return"[Circular]";function h(e,o){return o&&(i=i.slice()).push(o),t(e,r,n+1,i)}if("function"==typeof e){var d=function(t){if(t.name)return t.name;var e=String(t).match(/^function\s*([\w$]+)/);if(e)return e[1]}(e);return"[Function"+(d?": "+d:"")+"]"}if("[object Symbol]"===y(e)){var g=Symbol.prototype.toString.call(e);return"object"==typeof e?m(g):g}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(e)){for(var _="<"+String(e.nodeName).toLowerCase(),x=e.attributes||[],k=0;k"}if(p(e))return 0===e.length?"[]":"[ "+w(e,h).join(", ")+" ]";if("[object Error]"===y(e))return 0===(E=w(e,h)).length?"["+String(e)+"]":"{ ["+String(e)+"] "+E.join(", ")+" }";if("object"==typeof e&&"function"==typeof e.inspect)return e.inspect();if(function(t){if(!o)return!1;try{o.call(t);try{f.call(t)}catch(t){return!0}return t instanceof Map}catch(t){}return!1}(e)){var E=[];return s.call(e,function(t,r){E.push(h(r,e)+" => "+h(t,e))}),v("Map",o.call(e),E)}if(function(t){if(!f)return!1;try{f.call(t);try{o.call(t)}catch(t){return!0}return t instanceof Set}catch(t){}return!1}(e)){E=[];return l.call(e,function(t){E.push(h(t,e))}),v("Set",f.call(e),E)}if("[object Number]"===y(e))return m(Number(e));if("[object Boolean]"===y(e))return m(c.call(e));if("[object String]"===y(e))return m(h(String(e)));if("[object Date]"!==y(e)&&"[object RegExp]"!==y(e)){var S=w(e,h);return 0===S.length?"{}":"{ "+S.join(", ")+" }"}return String(e)};var d=Object.prototype.hasOwnProperty||function(t){return t in this};function g(t,e){return d.call(t,e)}function y(t){return h.call(t)}function b(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+e.toString(16)}function m(t){return"Object("+t+")"}function v(t,e,r){return t+" ("+e+") {"+r.join(", ")+"}"}function w(t,e){var r=p(t),n=[];if(r){n.length=t.length;for(var i=0;i0&&!n.call(t,0))for(var g=0;g0)for(var y=0;y=0&&"[object Function]"===n.call(t.callee)),r}},{}],36:[function(t,e,r){(function(t){function e(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(t){return n.exec(t).slice(1)};function o(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n=-1&&!n;i--){var s=i>=0?arguments[i]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(r=s+"/"+r,n="/"===s.charAt(0))}return(n?"/":"")+(r=e(o(r.split("/"),function(t){return!!t}),!n).join("/"))||"."},r.normalize=function(t){var n=r.isAbsolute(t),i="/"===s(t,-1);return(t=e(o(t.split("/"),function(t){return!!t}),!n).join("/"))||n||(t="."),t&&i&&(t+="/"),(n?"/":"")+t},r.isAbsolute=function(t){return"/"===t.charAt(0)},r.join=function(){var t=Array.prototype.slice.call(arguments,0);return r.normalize(o(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},r.relative=function(t,e){function n(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=r.resolve(t).substr(1),e=r.resolve(e).substr(1);for(var i=n(t.split("/")),o=n(e.split("/")),s=Math.min(i.length,o.length),a=s,u=0;u1)for(var r=1;r0?("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===f.prototype||(s=e,e=f.from(s)),n?u.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,u,e,!0):u.ended?t.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?_(t,u,e,!1):C(t,u)):_(t,u,e,!1))):n||(u.reading=!1));return!(a=u).ended&&(a.needReadable||a.lengthe.highWaterMark&&(e.highWaterMark=((r=t)>=x?r=x:(r--,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r++),r)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0));var r}function E(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i(S,t):S(t))}function S(t){p("emit readable"),t.emit("readable"),M(t)}function C(t,e){e.readingMore||(e.readingMore=!0,i(j,t,e))}function j(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=f.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function q(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i(L,e,t))}function L(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function D(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?q(this):E(this),null;if(0===(t=k(t,e))&&e.ended)return 0===e.length&&q(this),null;var n,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t0?O(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&q(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,p("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?l:w;function f(e,r){p("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",m),t.removeListener("finish",v),t.removeListener("drain",h),t.removeListener("error",b),t.removeListener("unpipe",f),n.removeListener("end",l),n.removeListener("end",w),n.removeListener("data",y),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function l(){p("onend"),t.end()}o.endEmitted?i(u):n.once("end",u),t.on("unpipe",f);var c,h=(c=n,function(){var t=c._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(c,"data")&&(t.flowing=!0,M(c))});t.on("drain",h);var d=!1;var g=!1;function y(e){p("ondata"),g=!1,!1!==t.write(e)||g||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==D(o.pipes,t))&&!d&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,g=!0),n.pause())}function b(e){p("onerror",e),w(),t.removeListener("error",b),0===a(t,"error")&&t.emit("error",e)}function m(){t.removeListener("finish",v),w()}function v(){p("onfinish"),t.removeListener("close",m),w()}function w(){p("unpipe"),n.unpipe(t)}return n.on("data",y),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",b),t.once("close",m),t.once("finish",v),t.emit("pipe",n),o.flowing||(p("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?setImmediate:i;b.WritableState=y;var u=t("core-util-is");u.inherits=t("inherits");var f={deprecate:t("util-deprecate")},l=t("./internal/streams/stream"),c=t("safe-buffer").Buffer,h=n.Uint8Array||function(){};var p,d=t("./internal/streams/destroy");function g(){}function y(e,r){s=s||t("./_stream_duplex"),e=e||{},this.objectMode=!!e.objectMode,r instanceof s&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,u=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===e.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if(p=r,p.writing=!1,p.writecb=null,p.length-=p.writelen,p.writelen=0,e)u=t,f=r,l=n,c=e,h=o,--f.pendingcb,l?(i(h,c),i(k,u,f),u._writableState.errorEmitted=!0,u.emit("error",c)):(h(c),u._writableState.errorEmitted=!0,u.emit("error",c),k(u,f));else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?a(v,t,r,s,o):v(t,r,s,o)}var u,f,l,c,h;var p}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function b(e){if(s=s||t("./_stream_duplex"),!(p.call(b,this)||this instanceof s))return new b(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),l.call(this)}function m(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function v(t,e,r,n){var i,o;r||(i=t,0===(o=e).length&&o.needDrain&&(o.needDrain=!1,i.emit("drain"))),e.pendingcb--,n(),k(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,m(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e)}else{for(;r;){var f=r.chunk,l=r.encoding,c=r.callback;if(m(t,e,!1,e.objectMode?1:f.length,f,l,c),r=r.next,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequestCount=0,e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),k(t,e)})}function k(t,e){var r,n,o=_(e);return o&&(r=t,(n=e).prefinished||n.finalCalled||("function"==typeof r._final?(n.pendingcb++,n.finalCalled=!0,i(x,r,n)):(n.prefinished=!0,r.emit("prefinish"))),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),o}u.inherits(b,l),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(t){return!!p.call(this,t)||t&&t._writableState instanceof y}})):p=function(t){return t instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(t,e,r){var n,o,s,a,u,f,l,p,d,y,b,v=this._writableState,w=!1,_=(n=t,(c.isBuffer(n)||n instanceof h)&&!v.objectMode);return _&&!c.isBuffer(t)&&(o=t,t=c.from(o)),"function"==typeof e&&(r=e,e=null),_?e="buffer":e||(e=v.defaultEncoding),"function"!=typeof r&&(r=g),v.ended?(d=this,y=r,b=new Error("write after end"),d.emit("error",b),i(y,b)):(_||(s=this,a=v,f=r,l=!0,p=!1,null===(u=t)?p=new TypeError("May not write null values to stream"):"string"==typeof u||void 0===u||a.objectMode||(p=new TypeError("Invalid non-string/buffer chunk")),p&&(s.emit("error",p),i(f,p),l=!1),l))&&(v.pendingcb++,w=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},b.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,k(t,e),r&&(e.finished?i(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),b.prototype.destroy=d.destroy,b.prototype._undestroy=d.undestroy,b.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":40,"./internal/streams/destroy":46,"./internal/streams/stream":47,_process:38,"core-util-is":6,inherits:28,"process-nextick-args":37,"safe-buffer":53,"util-deprecate":67}],45:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e,r,i,o=n.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,r=o,i=a,e.copy(r,i),a+=s.data.length,s=s.next;return o},t}()},{"safe-buffer":53}],46:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;o||s?e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n(i,this,t):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}))},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":37}],47:[function(t,e,r){e.exports=t("events").EventEmitter},{events:19}],48:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":49}],49:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":40,"./lib/_stream_passthrough.js":41,"./lib/_stream_readable.js":42,"./lib/_stream_transform.js":43,"./lib/_stream_writable.js":44}],50:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":49}],51:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":44}],52:[function(t,e,r){(function(r){var n=t("through"),i="undefined"!=typeof setImmediate?setImmediate:r.nextTick;e.exports=function(t,e){var r=n(t,e);r.pause();var o=r.resume,s=r.pause,a=!1;return r.pause=function(){return a=!0,s.apply(this,arguments)},r.resume=function(){return a=!1,o.apply(this,arguments)},i(function(){a||r.resume()}),r}}).call(this,t("_process"))},{_process:38,through:66}],53:[function(t,e,r){var n=t("buffer"),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,r),r.Buffer=s),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:5}],54:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function f(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",f),t.removeListener("error",f),r.removeListener("end",l),r.removeListener("close",l),t.removeListener("close",l)}return r.on("error",f),t.on("error",f),r.on("end",l),r.on("close",l),t.on("close",l),t.emit("pipe",r),t}},{events:19,inherits:28,"readable-stream/duplex.js":39,"readable-stream/passthrough.js":48,"readable-stream/readable.js":49,"readable-stream/transform.js":50,"readable-stream/writable.js":51}],55:[function(t,e,r){"use strict";var n=t("function-bind"),i=t("es-abstract/es5"),o=n.call(Function.call,String.prototype.replace),s=/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/,a=/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/;e.exports=function(){var t=i.ToString(i.CheckObjectCoercible(this));return o(o(t,s,""),a,"")}},{"es-abstract/es5":12,"function-bind":23}],56:[function(t,e,r){"use strict";var n=t("function-bind"),i=t("define-properties"),o=t("./implementation"),s=t("./polyfill"),a=t("./shim"),u=n.call(Function.call,s());i(u,{getPolyfill:s,implementation:o,shim:a}),e.exports=u},{"./implementation":55,"./polyfill":57,"./shim":58,"define-properties":10,"function-bind":23}],57:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function(){return String.prototype.trim&&"​"==="​".trim()?String.prototype.trim:n}},{"./implementation":55}],58:[function(t,e,r){"use strict";var n=t("define-properties"),i=t("./polyfill");e.exports=function(){var t=i();return n(String.prototype,{trim:t},{trim:function(){return String.prototype.trim!==t}}),t}},{"./polyfill":57,"define-properties":10}],59:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=f,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=c,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function f(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function l(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function c(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}r.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":53}],60:[function(t,e,r){"use strict";var n,i,o=new(t("googlediff")),s=t("./tape_css");function a(t,e){var r=t.actual,n=t.expected;r&&n&&"object"==typeof r&&"object"==typeof n&&(r=JSON.stringify(r),n=JSON.stringify(n));var i=document.createElement("SPAN");i.setAttribute("class","actual"),i.appendChild(document.createTextNode(r)),e.appendChild(i);var s=document.createElement("SPAN");if(s.setAttribute("class","expected"),s.appendChild(document.createTextNode(n)),e.appendChild(s),t.file){var a=document.createElement("SPAN");a.setAttribute("class","line");var u=/\/([^\/]+)$/.exec(t.file)[1];a.appendChild(document.createTextNode(u)),e.appendChild(a),console.warn(t.error.stack)}if(r&&n&&r.constructor==String&&n.constructor==String){var f=document.createElement("P");f.setAttribute("class","diff"),f.innerHTML=function(t,e){var r=o.diff_main(e,t);o.diff_cleanupSemantic(r);var n,i="";return r.forEach(function(t){switch(t[0]){case 0:n="span";break;case 1:n="ins";break;case-1:n="del"}i+="<"+n+">"+t[1]+""}),i}(r,n),e.appendChild(f)}}function u(t){if("test"===t.type)i=function(t){var e=document.createElement("DIV");e.id=t.id,e.setAttribute("class","test");var r=document.createElement("P");return r.setAttribute("class","name"),r.appendChild(document.createTextNode(t.name)),e.appendChild(r),i=e,n.appendChild(e),e}(t);else if("assert"===t.type){var e=function(t,e){var r=document.createElement("P");r.setAttribute("class","assert "+(t.ok?"ok":"fail"));var n=document.createElement("SPAN");if(n.setAttribute("class","ok"),n.appendChild(document.createTextNode(t.ok?"OK":"FAIL")),r.appendChild(n),t.name){var i=document.createElement("SPAN");i.setAttribute("class","name"),i.appendChild(document.createTextNode(t.name)),r.appendChild(i)}return e.appendChild(r),r.scrollIntoView({block:"end",behavior:"smooth"}),r}(t,i);t.ok||a(t,e)}else"end"===t.type?(u=i,(f=document.createElement("P")).setAttribute("class","end"),u.appendChild(f),i=i.parentNode):t.constructor===String?(r=t,o=i,(s=document.createElement("P")).setAttribute("class","comment"),s.appendChild(document.createTextNode(r)),o.appendChild(s)):console.warn("tape-dom row",t.type,t);var r,o,s,u,f}function f(t){t.createStream({objectMode:!0}).on("data",u)}function l(){var t=document.createElement("style");t.setAttribute("type","text/css");var e=document.createTextNode(s);t.appendChild(e),document.head.appendChild(t)}function c(t){return"object"==typeof window&&(l(),f(t)),c}"object"==typeof document&&((n=document.getElementById("tests"))||((n=document.createElement("div")).setAttribute("id","tests"),document.body.appendChild(n)),i=n),c.installCSS=l,c.stream=f,e.exports=c},{"./tape_css":61,googlediff:24}],61:[function(t,e,r){"use strict";e.exports="div.test{width:100%;border-top:1px dotted grey;margin-top:1em;background:#eef;font-weight:700;margin-bottom:1em}div#tests{margin-bottom:5em}p.assert{margin-top:0;margin-bottom:0;font-weight:400;width:100%}p.assert.ok{background:#efe;color:grey}p.assert.fail{background:#faa}p.comment{background:#eef;color:grey;font-style:italic;margin-top:.2em;margin-bottom:.2em;padding-left:2.4em}p.end{border-bottom:1px dotted grey;margin-top:1em;background:#eef;margin-top:.2em;margin-bottom:.2em}p.diff{background:#ffe;margin-top:0;margin-bottom:0;padding-top:.25em;padding-bottom:.25em;padding-left:4em;font-weight:400;white-space:pre-wrap}ins{background:#afa}del{background:#faa;text-decoration:strike}span.ok{font-weight:700}span.actual,span.expected,span.name{padding-left:1em;font-style:italic;max-width:25em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block}p.assert.fail span.name{color:#555}span.expected:before{content:'!=';padding-right:1em}span.line{padding-left:1em;float:right;text-align:right;overflow:hidden;text-overflow:ellipsis;font-family:monospace;color:#888}"},{}],62:[function(t,e,r){(function(n){var i=t("defined"),o=t("./lib/default_stream"),s=t("./lib/test"),a=t("./lib/results"),u=t("through"),f=void 0!==n&&n&&"function"==typeof n.on&&!0!==n.browser,l=void 0!==n&&n&&"function"==typeof n.exit;"undefined"!=typeof setImmediate?setImmediate:n.nextTick;function c(t){t||(t={});var e=a();!1!==t.autoclose&&e.once("done",function(){e.close()});var r=function(t,n,i){var o=new s(t,n,i);return r._tests.push(o),function t(e){e.on("test",function(e){t(e)}),e.on("result",function(t){t.ok||"string"==typeof t||(r._exitCode=1)})}(o),e.push(o),o};r._results=e,r._tests=[],r.createStream=function(t){return e.createStream(t)},r.onFinish=function(t){e.on("done",t)};var n=!1;return r.only=function(){if(n)throw new Error("there can only be one only test");n=!0;var t=r.apply(null,arguments);return e.only(t),t},r._exitCode=0,r.close=function(){e.close()},r}(r=e.exports=function(){var t,e=function(){return r().apply(this,arguments)};return e.only=function(){return r().only.apply(this,arguments)},e.createStream=function(e){if(e||(e={}),!t){var n=u();return r({stream:n,objectMode:e.objectMode}),n}return t.createStream(e)},e.onFinish=function(){return r().onFinish.apply(this,arguments)},e.getHarness=r,e;function r(e){return e||(e={}),e.autoclose=!f,t||(t=function(t){t||(t={});var e=c({autoclose:i(t.autoclose,!1)}),r=e.createStream({objectMode:t.objectMode}),s=r.pipe(t.stream||o());f&&s.on("error",function(t){e._exitCode=1});var a=!1;if(r.on("end",function(){a=!0}),!1===t.exit)return e;if(!f||!l)return e;return n.on("exit",function(t){if(0===t){if(!a)for(var r=e._results._only,i=0;i65||y(o)||y(s)?(r+=" expected: |-\n "+o+"\n",r+=" actual: |-\n "+s+"\n"):(r+=i+"expected: "+o+"\n",r+=i+"actual: "+s+"\n")}t.at&&(r+=i+"at: "+t.at+"\n");var a=t.actual&&t.actual.stack,f=t.error&&t.error.stack,c=n(a,f);if(c){var h=String(c).split("\n");r+=i+"stack: |-\n";for(var p=0;p=1&&t&&this.ifError(t),this.calledEnd&&this.fail(".end() called twice"),this.calledEnd=!0,this._end()},b.prototype._end=function(t){var e=this;if(this._progeny.length){var r=this._progeny.shift();return r.on("end",function(){e._end()}),void r.run()}this.ended||this.emit("end");var n=this._pendingAsserts();!this._planError&&void 0!==this._plan&&n&&(this._planError=!0,this.fail("plan != count",{expected:this._plan,actual:this.assertCount})),this.ended=!0},b.prototype._exit=function(){void 0===this._plan||this._planError||this.assertCount===this._plan?this.ended||this.fail("test exited without ending",{exiting:!0}):(this._planError=!0,this.fail("plan != count",{expected:this._plan,actual:this.assertCount,exiting:!0}))},b.prototype._pendingAsserts=function(){return void 0===this._plan?1:this._plan-(this._progeny.length+this.assertCount)},b.prototype._assert=function(t,e){var r=this,i=e.extra||{},a={id:r.assertCount++,ok:Boolean(t),skip:o(i.skip,e.skip),name:o(i.message,e.message,"(unnamed assert)"),operator:o(i.operator,e.operator),objectPrintDepth:r._objectPrintDepth};if((f(e,"actual")||f(i,"actual"))&&(a.actual=o(i.actual,e.actual)),(f(e,"expected")||f(i,"expected"))&&(a.expected=o(i.expected,e.expected)),this._ok=Boolean(this._ok&&t),t||(a.error=o(i.error,e.error,new Error(a.name))),!t)for(var u=(new Error("exception").stack||"").split("\n"),l=s.dirname(n)+s.sep,c=0;c0;function s(t,e,r){var n=document.createEventObject?document.createEventObject():document.createEvent("Events");if(n.initEvent&&n.initEvent("keydown",!0,!0),n.keyCode=e,n.which=e,r)for(var i in r)n[i]=r[i];t.dispatchEvent?t.dispatchEvent(n):t.fireEvent("onkeydown",n)}n("hotkeys 单元测试",function(t){i("w",function(e){t.equal(e.keyCode,87,"单个按键 w keyCode == 87")}),s(document.body,87),i("enter",function(e){t.equal(e.keyCode,13,"单个特殊键按键 enter,enter验证 keyCode == 13")}),i("return",function(e){t.equal(e.keyCode,13,"单个特殊键按键 return,return验证 keyCode == 13")}),s(document.body,13),i("space",function(e){t.equal(e.keyCode,32,"单个特殊键按键 space,space验证 keyCode == 32")}),s(document.body,32),i("backspace",function(e){t.equal(e.keyCode,8,"单个特殊键按键 backspace,backspace 验证 keyCode == 8")}),s(document.body,8),i("tab",function(e){t.equal(e.keyCode,9,"单个特殊键按键 tab,tab 验证 keyCode == 9")}),s(document.body,9),i("clear",function(e){t.equal(e.keyCode,12,"单个特殊键按键 clear,clear 验证 keyCode == 12")}),s(document.body,12),i(",",function(e){t.equal(e.keyCode,188,"单个特殊键按键 , ,, 验证 keyCode == 188")}),s(document.body,188),i(".",function(e){t.equal(e.keyCode,190,"单个特殊键按键 . ,. 验证 keyCode == 190")}),s(document.body,190),i(".",function(e){t.equal(e.keyCode,190,"单个特殊键按键 . ,. 验证 keyCode == 190")}),s(document.body,190),i("/",function(e){t.equal(e.keyCode,191,"单个特殊键按键 / ,/ 验证 keyCode == 191")}),s(document.body,191),i("`",function(e){t.equal(e.keyCode,192,"单个特殊键按键 ` ,` 验证 keyCode == 192")}),s(document.body,192),i("-",function(e){t.equal(e.keyCode,o?173:189,"单个特殊键按键 -,- 验证 keyCode == 火狐?173:189")}),s(document.body,o?173:189),i("=",function(e){t.equal(e.keyCode,o?61:187,"单个特殊键按键 =,= 验证 keyCode == 火狐?61:187")}),s(document.body,o?61:187),i(";",function(e){t.equal(e.keyCode,o?59:186,"单个特殊键按键 ; ,; 验证 keyCode == 火狐?59:186")}),s(document.body,o?59:186),i("'".toString(),function(e){t.equal(e.keyCode,222,"单个特殊键按键 ' ,' 验证 keyCode == 222 ")}),s(document.body,222),i("\\".toString(),function(e){t.equal(e.keyCode,220,"单个特殊键按键 \\ ,\\ 验证 keyCode == 220 ")}),s(document.body,220),i("[".toString(),function(e){t.equal(e.keyCode,219,"单个特殊键按键 [ ,[ 验证 keyCode == 219 ")}),s(document.body,219),i("]".toString(),function(e){t.equal(e.keyCode,221,"单个特殊键按键 ] ,] 验证 keyCode == 221 ")}),s(document.body,221),i("left",function(e){t.equal(e.keyCode,37,"单个特殊键按键 left,left 验证 keyCode == 37")}),s(document.body,37),i("up",function(e){t.equal(e.keyCode,38,"单个特殊键按键 up,up 验证 keyCode == 38")}),s(document.body,38),i("del",function(e){t.equal(e.keyCode,46,"单个特殊键按键 del,del 验证 keyCode == 46")}),i("delete",function(e){t.equal(e.keyCode,46,"单个特殊键按键 delete,delete 验证 keyCode == 46")}),s(document.body,46),i("home",function(e){t.equal(e.keyCode,36,"单个特殊键按键 home,home 验证 keyCode == 36")}),s(document.body,36),i("pageup",function(e){t.equal(e.keyCode,33,"单个特殊键按键 pageup,pageup 验证 keyCode == 33")}),s(document.body,33),i("pagedown",function(e){t.equal(e.keyCode,34,"单个特殊键按键 pagedown,pagedown 验证 keyCode == 34")}),s(document.body,34),i("end",function(e){t.equal(e.keyCode,35,"单个特殊键按键 end,end 验证 keyCode == 35")}),s(document.body,35),i("right",function(e){t.equal(e.keyCode,39,"单个特殊键按键 right,right 验证 keyCode == 39")}),s(document.body,39),i("down",function(e){t.equal(e.keyCode,40,"单个特殊键按键 down,down 验证 keyCode == 40")}),s(document.body,40),i("esc",function(e){t.equal(e.keyCode,27,"单个特殊键按键 esc,esc 验证 keyCode == 27")}),i("escape",function(e){t.equal(e.keyCode,27,"单个特殊键按键 escape,escape 验证 keyCode == 27")}),s(document.body,27),i("CapsLock",function(e){t.equal(e.keyCode,20,"单个特殊键按键 CapsLock,CapsLock验证 keyCode == 20")}),i("⇪",function(e){t.equal(e.keyCode,20,"单个特殊键按键 ⇪,⇪验证 keyCode == 20")}),s(document.body,20),i("⌘+d",function(e){return t.equal(e.keyCode,82,"组合键 ⌘+d,d验证 keyCode == 82"),t.equal(e.metaKey,!0,"组合键 ⌘+d,alt验证 metaKey == true"),!1}),s(document.body,82,{metaKey:!0}),i("alt+d",function(e){t.equal(e.keyCode,68,"组合键 alt+d,d验证 keyCode == 68"),t.equal(e.altKey,!0,"组合键 alt+d,alt验证 altKey == true")}),s(document.body,68,{altKey:!0}),i("shift+a",function(e){t.equal(e.keyCode,65,"组合键 shift+a,a验证 keyCode == 65"),t.equal(e.shiftKey,!0,"组合键 shift+a,shift验证 shiftKey == true")}),s(document.body,65,{shiftKey:!0}),i("⇧+a",function(e){t.equal(e.keyCode,65,"组合键 ⇧+a,a验证 keyCode == 65"),t.equal(e.shiftKey,!0,"组合键 ⇧+a,⇧验证 shiftKey == true")}),s(document.body,65,{shiftKey:!0}),i("⌘+a",function(e){t.equal(e.keyCode,65,"组合键 ⌘+a,a验证 keyCode == 65"),t.equal(e.metaKey,!0,"组合键 ⌘+a,⌘验证 metaKey == true")}),s(document.body,65,{metaKey:!0}),i("⌃+a",function(e){t.equal(e.keyCode,65,"组合键 ⌃+a,a验证 keyCode == 65"),t.equal(e.ctrlKey,!0,"组合键 ⌃+a,⌃验证 ctrlKey == true")}),s(document.body,65,{ctrlKey:!0}),i.unbind("⌃+a"),i("⌥+a",function(e){t.equal(e.keyCode,65,"组合键 ⌥+a,a验证 keyCode == 65"),t.equal(e.altKey,!0,"组合键 ⌥+a,⌥验证 altKey == true")}),s(document.body,65,{altKey:!0}),i("ctrl+,,ctrl+d",function(e){t.equal(e.keyCode,188,"组合键 ctrl+,,,验证 keyCode == 65"),t.equal(e.ctrlKey,!0,"组合键 ctrl+,,ctrl验证 ctrlKey == true")}),s(document.body,188,{ctrlKey:!0}),i.unbind("ctrl+,,ctrl+d"),i("Ctrl+A",function(e){t.equal(e.keyCode,65,"大小写组合键 Ctrl+A,A验证 keyCode == 65"),t.equal(e.ctrlKey,!0,"大小写组合键 Ctrl+A,Ctrl验证 ctrlKey == true")}),s(document.body,65,{ctrlKey:!0}),i.unbind("Ctrl+A"),i("CTRL+A",function(e){t.equal(e.keyCode,65,"大小写组合键 CTRL+A,A验证 keyCode == 65"),t.equal(e.ctrlKey,!0,"大小写组合键 CTRL+A,CTRL验证 ctrlKey == true")}),s(document.body,65,{ctrlKey:!0}),i.unbind("CTRL+A"),i("⌃+a",function(){t.equal(i.getScope(),"all"," 验证 getScope() == all")}),s(document.body,65,{ctrlKey:!0}),i.unbind("⌃+a"),i("⌃+a","scope1",function(){t.equal(i.getScope(),"scope1"," 验证 getScope() == scope1")}),s(document.body,65,{ctrlKey:!0}),i("⌃+a","scope2",function(){t.equal(i.getScope(),"scope2"," 验证 getScope() == scope2")}),i.setScope("scope1"),s(document.body,65,{ctrlKey:!0}),i.setScope("scope2"),s(document.body,65,{ctrlKey:!0})})},{"../dist/hotkeys.js":1,tape:62,"tape-dom":60}]},{},[68]); diff --git a/test/index.html b/test/index.html index 0081dba..83e1c0e 100644 --- a/test/index.html +++ b/test/index.html @@ -1,37 +1,15 @@ - - + + - - hotkeys - + + hotkeys.js - A robust Javascript library for capturing keyboard input. + + + -
- - +
+ + \ No newline at end of file diff --git a/test/run.js b/test/run.js new file mode 100644 index 0000000..e69de29 diff --git a/website/App.js b/website/App.js new file mode 100644 index 0000000..a5f8bf1 --- /dev/null +++ b/website/App.js @@ -0,0 +1,116 @@ +import React, { Component } from 'react'; +import GithubCorner from './components/GithubCorner'; +import KeyBoard from './components/KeyBoard'; +import Footer from './components/Footer'; +import Markdown from './components/Markdown'; +import GithubShields from './components/GithubShields'; +import styles from './styles/index.less'; +import DocumentStr from './doc.md'; +import hotkeys from '../dist/hotkeys.common'; + +export default class App extends Component { + constructor() { + super(); + this.state = { + keyCode: [], + keyStr: [], + } + this.onKeyUpEvent = this.onKeyUpEvent.bind(this); + } + componentDidMount() { + const { keyCode } = this.state; + document.addEventListener('keyup', this.onKeyUpEvent); + function pkeys(keys, key) { + if (keys.indexOf(key) === -1) keys.push(key); + return keys; + } + function pkeysStr(keysStr, key) { + if (keysStr.indexOf(key) === -1) keysStr.push(key); + return keysStr; + } + hotkeys('*', (evn) => { + evn.preventDefault() + const keys = []; + const keyStr = []; + if (hotkeys.shift) pkeys(keys,16), pkeysStr(keyStr,'shift'); + if (hotkeys.ctrl) pkeys(keys,17), pkeysStr(keyStr,'ctrl'); + if (hotkeys.alt) pkeys(keys,18), pkeysStr(keyStr,'alt'); + if (hotkeys.control) pkeys(keys,17), pkeysStr(keyStr,'control'); + if (hotkeys.command) pkeys(keys,91), pkeysStr(keyStr,'command'); + keyStr.push(evn.keyCode); + if (keys.indexOf(evn.keyCode) === -1) keys.push(evn.keyCode); + this.setState({ keyCode: keys, keyStr }); + }); + return false; + } + componentWillUnmount() { + document.removeEventListener('keyup', this.onKeyUpEvent); + } + onKeyUpEvent() { + this.setState({ keyCode: [], keyStr: [] }); + } + onKeyBoardMouseDown(item) { + if (item.keycode > -1) { + this.setState({ keyStr: [item.keycode] }); + } + } + onKeyBoardMouseUp(item) { + this.setState({ keyStr: [] }); + } + render() { + const { keyCode, keyStr } = this.state; + return ( +
+ {keyStr.length > -1 && ( +
+ {keyStr.map((item, idx) => {item})} +
+ )} + +
+
HotKeys.js
+ +
A robust Javascript library for capturing keyboard input and key combinations entered. It has no dependencies. Try to press your keyboard, The following button will highlight.
+
+ + + +
+
+ ) + } +} \ No newline at end of file diff --git a/website/assets/bg.jpg b/website/assets/bg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0accad6c8ee74deea8f7a32d47dd79a164e30a99 GIT binary patch literal 21072 zcmZU)2UJsO)HQt5D;Pq6gc=|~gn$H)CTch}an!MV*LnZ-z3W^5vlfs9F6)-_oU_l~`}~~v`4S*|?cJ6P z0DgX!02=t;^>YEx@XSfrz7K!^aPVUe0Q`IpsIwDy#wP)ZQt%VV&!<2>0R6uU2EKy9 z!S66Q0{&|ukcj^l5{W{gQ79w^gT-Pn`2Tl7U@#a0j=&(17&ROQr?x^JTq{=m_ecNV z5B&eU`+tx7zwdrZ0Sz?78p41kB+}@YfKi24GBNvQ7RDwu8lGx@!tLOe;_KJqodp_js8_TGaUe{fnQI03JLN zssYmg)&pO^8GN3}reqQf18_|bBb8L*@R0+DsT92!f%zjgp+g?OlXj^tF@fiWBu3O0 zH6f8-3dVuwDaOf6N7}~bUg&}Y^*|1Z(h1C(j-!nhF%>g=&4rSza}dV8df%|LJ1-6i z^Xk+6AxN63!0yuJ4hI9R^BX7F0EF@8UG|~7ZODY;t;W7?4J%B-yh_RuKwim;IN`KL z{gcjK_#W8Zui{R3|2&~Xi)N9pL}cTI1PXG9{ll*ZcJ5AEd)ObzJm5TQyPSZ~Fkys|0az6CW zv3DuS62yK^+Q9@{7#wB9Tg2%woSekxkBTUD6h~9SZ+rXJD6@6YB);0QscUXt_cYUQ za*}@=oT-eu+0s$ETinh{p(T3f&sJUGF;qasem@pKhsVJs~;5dI9&j zcqw*A!WBVDh3pzu+!9yHq@7d0dmgnx zdqB?cHeJdb4yYn+$sOk(W1a4D_Df8Du?As!<+)J9G8i=zF*I?Rx^hf36wD&Yj@xC+ z6KrR^dZ%)7p?nt(!v{Dpf)fRu*e!ln`P_F?9V06#Ar2}eT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OW#AkxdRN?&|OO%%Lo( zX4|~}>W>5gnGTUIJCZ$GT|1F=@eQ-Dg63JUTi!5d67Yyg$}s7z^P*=j6qnd|>6(Pi z)qKqwD{G8c=A&b`C?* z`A){EE)(oas_~vT%$pzOe|_!FQY(0mSf}RpwZ1FDNckG}LO)M?0G{`&h5NG&(JNB76n{{dc@Lqz}p literal 0 HcmV?d00001 diff --git a/website/components/Footer.js b/website/components/Footer.js new file mode 100644 index 0000000..08e14e0 --- /dev/null +++ b/website/components/Footer.js @@ -0,0 +1,8 @@ +import React from 'react'; +import style from './Footer.less'; + +export default function Footer({ name, href, year}) { + return ( +
© {name} {year}
+ ) +} \ No newline at end of file diff --git a/website/components/Footer.less b/website/components/Footer.less new file mode 100644 index 0000000..4193f7b --- /dev/null +++ b/website/components/Footer.less @@ -0,0 +1,5 @@ +.footer { + text-align: center; + padding: 15px 0 100px 0; + font-size: 12px; +} \ No newline at end of file diff --git a/website/components/GithubCorner.js b/website/components/GithubCorner.js new file mode 100644 index 0000000..64972c1 --- /dev/null +++ b/website/components/GithubCorner.js @@ -0,0 +1,17 @@ +import React from 'react'; +import styles from './GithubCorner.less'; + +export default function GithubCorner({ url }) { + if (!url) { + return null; + } + return ( + + + + + + + + ) +} \ No newline at end of file diff --git a/website/components/GithubCorner.less b/website/components/GithubCorner.less new file mode 100644 index 0000000..f1aa5ee --- /dev/null +++ b/website/components/GithubCorner.less @@ -0,0 +1,32 @@ + +a.corner { + position: fixed; + top: 0; + right: 0; + svg { + fill:#e1e1e1; + color:#000; + position:absolute; + top:0; + border:0; + right:0; + z-index:99; + width:4.375rem; + height:4.375rem; + } + &:hover .octo-arm { + animation:octocat-wave 560ms ease-in-out; + } +} + +@keyframes octocat-wave { + 0%,100% { + transform:rotate(0); + } + 20%,60% { + transform:rotate(-25deg); + } + 40%,80% { + transform:rotate(10deg); + } +} \ No newline at end of file diff --git a/website/components/GithubShields.js b/website/components/GithubShields.js new file mode 100644 index 0000000..80a167a --- /dev/null +++ b/website/components/GithubShields.js @@ -0,0 +1,20 @@ +import React from 'react'; +import styles from './GithubShields.less' + +// source = [ +// { +// href: 'https://github.com/jaywcjlove/hotkeys/network', +// img: 'https://img.shields.io/github/forks/jaywcjlove/hotkeys.svg?style=social' +// }, +// ] +export default function GithubShields({ source }) { + return ( +
+ {source.map((item, idx) => ( + + + + ))} +
+ ); +} \ No newline at end of file diff --git a/website/components/GithubShields.less b/website/components/GithubShields.less new file mode 100644 index 0000000..d455e97 --- /dev/null +++ b/website/components/GithubShields.less @@ -0,0 +1,8 @@ + +.shields { + padding: 60px 0 0 0; + text-align:center; + a + a{ + margin-left: 10px; + } +} \ No newline at end of file diff --git a/website/components/KeyBoard.js b/website/components/KeyBoard.js new file mode 100644 index 0000000..bbe28dc --- /dev/null +++ b/website/components/KeyBoard.js @@ -0,0 +1,109 @@ +import React from 'react'; +import classNames from 'classnames'; + +import styles from './KeyBoard.less'; + +const keyCode = [ + { keycode: 27, name: ["esc"] }, + { keycode: 112, name: ["F1"] }, + { keycode: 113, name: ["F2"] }, + { keycode: 114, name: ["F3"] }, + { keycode: 115, name: ["F4"] }, + { keycode: 116, name: ["F5"] }, + { keycode: 117, name: ["F6"] }, + { keycode: 118, name: ["F7"] }, + { keycode: 119, name: ["F8"] }, + { keycode: 120, name: ["F9"] }, + { keycode: 121, name: ["F10"] }, + { keycode: 122, name: ["F11"] }, + { keycode: 123, name: ["F12"] }, + { keycode: -1, name: ["〇"] }, + { keycode: 192, name: ["~", "`"] }, + { keycode: 49, name: ["!", "1"] }, + { keycode: 50, name: ["@", "2"] }, + { keycode: 51, name: ["#", "3"] }, + { keycode: 52, name: ["$", "4"] }, + { keycode: 53, name: ["%", "5"] }, + { keycode: 54, name: ["^", "6"] }, + { keycode: 55, name: ["&", "7"] }, + { keycode: 56, name: ["*", "8"] }, + { keycode: 57, name: ["(", "9"] }, + { keycode: 48, name: [")", "0"] }, + { keycode: 189, name: ["_", "-"] }, + { keycode: 187, name: ["+", ": "] }, + { keycode: 8, name: ["delete"] }, + { keycode: 9, name: ["tab"] }, + { keycode: 81, name: ["Q"] }, + { keycode: 87, name: ["W"] }, + { keycode: 69, name: ["E"] }, + { keycode: 82, name: ["R"] }, + { keycode: 84, name: ["T"] }, + { keycode: 89, name: ["Y"] }, + { keycode: 85, name: ["U"] }, + { keycode: 73, name: ["I"] }, + { keycode: 79, name: ["O"] }, + { keycode: 80, name: ["P"] }, + { keycode: 219, name: ["{", "["] }, + { keycode: 221, name: ["}", "]"] }, + { keycode: 220, name: ["|", "\\"] }, + { keycode: 20, name: ["", "CapsLock"] }, + { keycode: 65, name: ["A"] }, + { keycode: 83, name: ["S"] }, + { keycode: 68, name: ["D"] }, + { keycode: 70, name: ["F"] }, + { keycode: 71, name: ["G"] }, + { keycode: 72, name: ["H"] }, + { keycode: 74, name: ["J"] }, + { keycode: 75, name: ["K"] }, + { keycode: 76, name: ["L"] }, + { keycode: 186, name: [":", ";"] }, + { keycode: 222, name: ["\"", "'"] }, + { keycode: 13, name: ["enter", "return"] }, + { keycode: 16, name: ["⇧"] }, + { keycode: 90, name: ["Z"] }, + { keycode: 88, name: ["X"] }, + { keycode: 67, name: ["C"] }, + { keycode: 86, name: ["V"] }, + { keycode: 66, name: ["B"] }, + { keycode: 78, name: ["N"] }, + { keycode: 77, name: ["M"] }, + { keycode: 188, name: ["<", ","] }, + { keycode: 190, name: [">", "."] }, + { keycode: 191, name: ["?", "/"] }, + { keycode: 16, name: ["⇧"] }, + { keycode: -1, name: ["fn"] }, + { keycode: 17, name: ["control"] }, + { keycode: 18, name: ["alt", "option"] }, + { keycode: 91, name: ["command"] }, + { keycode: 32, name: [""] }, + { keycode: 93, name: ["command"] }, + { keycode: 18, name: ["alt", "option"] }, + { keycode: 37, name: ["◀"] }, + { keycode: 38, name: ["▲"] }, + { keycode: 39, name: ["▶"] }, + { keycode: 40, name: ["▼"] }, +]; + +export default function KeyBoard({ keyCode: keyCodeNum, onMouseDown, onMouseUp }) { + // console.log('keyCodeNum:', keyCodeNum) + return ( +
+
    + {keyCode.map((item, idx) => { + const name = item.name.map((item, _idx) => {item}); + return ( +
  • onMouseDown(item)} + onMouseUp={() => onMouseUp(item)} + className={classNames({ pressed: keyCodeNum.indexOf(item.keycode) > -1})} + data-key={item.keycode} + > + {name} +
  • + ) + })} +
+
+ ) +} \ No newline at end of file diff --git a/website/components/KeyBoard.less b/website/components/KeyBoard.less new file mode 100644 index 0000000..77be9e1 --- /dev/null +++ b/website/components/KeyBoard.less @@ -0,0 +1,248 @@ + +.keyboard { + height: 394px; + border-radius: 10px; + border: 1px solid #C9C9C9; + background: #F2F2F2; + box-shadow: 2px 0px 2px #E2E2E2 inset,-2px 2px 3px #E2E2E2 inset,1px -0px 0px #C1C1C1 inset,0px -2px 3px #C1C1C1 inset; + user-select: none; + position: relative; + top: -66; + width: 995px; + margin: 0 auto; + ul { + width: 992px; + margin-top: 9px; + padding-left: 11px; + position: relative; + float: left; + } + li { + width: 62px; + height: 62px; + float: left; + margin-right: 5px; + margin-bottom: 5px; + background: #151515; + color: rgb(200,200,200); + text-align: center; + line-height: 62px; + font-size: 12px; + border-radius: 8px; + border: 1px solid #3A3A3A; + box-shadow: 1px 0px 0px rgb(0,0,0),0px 1px 0px rgb(0,0,0),-1px 0px 0px rgb(0,0,0),0px -1px 0px rgb(0,0,0); + user-select: none; + cursor: pointer; + position: relative; + &:active, &:global(.pressed) { + color:#52F800; + background-color: #100068; + border:1px solid #332376; + } + &:nth-child(1) { + width: 99px; + height: 28px; + line-height: 28px; + text-indent: 1em; + text-align: left; + } + &:nth-child(2), + &:nth-child(3), + &:nth-child(4), + &:nth-child(5), + &:nth-child(6), + &:nth-child(7), + &:nth-child(8), + &:nth-child(9), + &:nth-child(10), + &:nth-child(11), + &:nth-child(12), + &:nth-child(13), + &:nth-child(14) { + width: 60px; + height: 28px; + line-height: 28px; + } + &:nth-child(15), + &:nth-child(16), + &:nth-child(17), + &:nth-child(18), + &:nth-child(19), + &:nth-child(20), + &:nth-child(21), + &:nth-child(22), + &:nth-child(23), + &:nth-child(24), + &:nth-child(25), + &:nth-child(26), + &:nth-child(27), + &:nth-child(40), + &:nth-child(41), + &:nth-child(42), + &:nth-child(53), + &:nth-child(54), + &:nth-child(64), + &:nth-child(65), + &:nth-child(66) { + padding: 7px 0; + height: 48px; + } + } +} + + +.keyboard li:nth-child(15) span, +.keyboard li:nth-child(16) span, +.keyboard li:nth-child(17) span, +.keyboard li:nth-child(18) span, +.keyboard li:nth-child(19) span, +.keyboard li:nth-child(20) span, +.keyboard li:nth-child(21) span, +.keyboard li:nth-child(22) span, +.keyboard li:nth-child(23) span, +.keyboard li:nth-child(24) span, +.keyboard li:nth-child(25) span, +.keyboard li:nth-child(26) span, +.keyboard li:nth-child(27) span, +.keyboard li:nth-child(40) span, +.keyboard li:nth-child(41) span, +.keyboard li:nth-child(42) span, +.keyboard li:nth-child(53) span, +.keyboard li:nth-child(54) span, +.keyboard li:nth-child(64) span, +.keyboard li:nth-child(65) span, +.keyboard li:nth-child(66) span { + line-height: 23px; + height: 23px; + width: 100%; + float: left; + font-size:14px; +} +.keyboard li:nth-child(28) span, +.keyboard li:nth-child(55) span, +.keyboard li:nth-child(67) span { + line-height: 14px; + margin-top: 43px; + float: right; + margin-right: 8px; +} +//字母键 +.keyboard li:nth-child(30), +.keyboard li:nth-child(31), +.keyboard li:nth-child(32), +.keyboard li:nth-child(33), +.keyboard li:nth-child(34), +.keyboard li:nth-child(35), +.keyboard li:nth-child(36), +.keyboard li:nth-child(37), +.keyboard li:nth-child(38), +.keyboard li:nth-child(39), +.keyboard li:nth-child(44), +.keyboard li:nth-child(45), +.keyboard li:nth-child(46), +.keyboard li:nth-child(47), +.keyboard li:nth-child(48), +.keyboard li:nth-child(49), +.keyboard li:nth-child(50), +.keyboard li:nth-child(51), +.keyboard li:nth-child(52), +.keyboard li:nth-child(57), +.keyboard li:nth-child(58), +.keyboard li:nth-child(59), +.keyboard li:nth-child(60), +.keyboard li:nth-child(61), +.keyboard li:nth-child(62), +.keyboard li:nth-child(63) { + font-size: 18px; + line-height: 64px; +} + +.keyboard li:nth-child(29) span, +.keyboard li:nth-child(43) span, +.keyboard li:nth-child(56) span, +.keyboard li:nth-child(68) span, +.keyboard li:nth-child(69) span, +.keyboard li:nth-child(70) span, +.keyboard li:nth-child(71) span, +.keyboard li:nth-child(73) span, +.keyboard li:nth-child(74) span { + line-height: 14px; + margin-top: 43px; + text-indent: 5px; + float: left; +} +.keyboard li:nth-child(28), +.keyboard li:nth-child(29) { + width: 73px; +} +.keyboard li:nth-child(43), +.keyboard li:nth-child(55) { + width: 102px; +} +.keyboard { + li:nth-child(43) { + &:active { + span:first-child { + background:#52f800; + } + } + span:first-child { + position: absolute; + top: -36px; + left: 5px; + width: 6px; + height: 6px; + background: #fff; + border-radius: 3px; + } + } +} +.keyboard li:nth-child(55) span:first-child, +.keyboard li:nth-child(70) span:first-child { + position: absolute; + right: 0px; + top: -37px; + font-size: 12px; + line-height: 12px; +} +.keyboard li:nth-child(70) span:first-child { + left: 0px; + text-align: left; +} +.keyboard li:nth-child(74) span:first-child { + position: absolute; + left: 0; + top: -37px; + font-size: 12px; + line-height: 12px; +} +.keyboard li:nth-child(56) { + width: 136px; +} +.keyboard li:nth-child(67) { + width: 137px; +} +.keyboard li:nth-child(71), +.keyboard li:nth-child(73) { + width: 70px; +} +.keyboard li:nth-child(72) { + width: 333px; +} + +.keyboard li:nth-child(76), +.keyboard li:nth-child(78) { + height: 29px; + line-height: 29px; +} +.keyboard li:nth-child(76) { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} +.keyboard li:nth-child(78) { + border-top-left-radius: 0; + border-top-right-radius: 0; + position: absolute; + bottom: 0; + right: 84px; +} diff --git a/website/components/Markdown/index.js b/website/components/Markdown/index.js new file mode 100644 index 0000000..28c7781 --- /dev/null +++ b/website/components/Markdown/index.js @@ -0,0 +1,43 @@ +import React, { Component } from 'react'; +import ReactDOM from 'react-dom'; +import ReactMarkdown from 'react-markdown'; +import hljs from 'highlight.js'; +import classNames from 'classnames'; +import styles from './styles/index.less'; + +hljs.configure({ + tabReplace: ' ', // 2 spaces + classPrefix: '', // don't append class prefix +}); + +export default class Markdown extends Component { + componentDidMount() { + let code = ReactDOM.findDOMNode(this); + code = code.getElementsByTagName('code'); + for (let i = 0; i < code.length; i += 1) { + if (code[i].parentNode && code[i].parentNode.tagName === 'PRE') { + hljs.highlightBlock(code[i]); + } + } + } + render() { + const { source }= this.props; + return ( + { + if (node.type === 'html') { + if (//.test(node.value)) return false; + // const scriptValue = node.value.match(/(.*?)<\/script>/ig); + // node.value.replace(/(.*?)<\/script>/, (te) => { + // console.log('te:', te); + // }); + } + return node; + }} + /> + ) + } +} \ No newline at end of file diff --git a/website/components/Markdown/styles/default.less b/website/components/Markdown/styles/default.less new file mode 100644 index 0000000..2e0a4e2 --- /dev/null +++ b/website/components/Markdown/styles/default.less @@ -0,0 +1,216 @@ +code { + font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; + word-wrap: normal; +} +code:not(.hljs){ + padding: 0.2em 0.4em 0.08em 0.4em; + margin: 0; + font-size: 85%; + background-color: rgba(27, 31, 35, 0.07); + border-radius: 3px; +} +// code.hljs { +// padding: 16px; +// font-size: 95%; +// line-height: 1.5; +// display: block; +// text-shadow: 0 1px #fff; +// } +pre code { + padding: 16px; + font-size: 95%; + line-height: 1.5; + display: block; + text-shadow: 0 1px #fff; +} +pre { + margin-bottom: 18px; + max-height: 35em; + position: relative; + overflow: auto; + background-color: #F0F0F0; + border-radius: 3px; +} +pre code { + background: none; + font-size: 1em; + overflow-wrap: normal; + white-space: inherit; +} +ul, ol { + padding-left: 2em; +} +dl { + padding: 0; + dt { + padding: 0; + margin-top: 16px; + font-size: 14px; + font-style: italic; + font-weight: 600; + } +} +li + li { + margin-top: 3px; +} +a { + color: #0366d6; +} +p { + margin-bottom: 10px; +} +blockquote { + margin: 0; + padding: 0 1em; + margin-bottom: 10px; + color: #6a737d; + border-left: 0.25em solid #dfe2e5; + & >:first-child { + margin-top: 0; + } + & >:last-child { + margin-bottom: 0; + } +} +hr { + height: 0.25em; + padding: 0; + margin: 24px 0; + background-color: #e1e4e8; + border: 0; +} + +h1 tt,h1 code,h2 tt,h2 code,h3 tt,h3 code,h4 tt,h4 code,h5 tt,h5 code,h6 tt,h6 code { + font-size: inherit +} + +h1 { + padding-bottom: 0.3em; + font-size: 2em; + border-bottom: 1px solid #cecece; + margin-bottom: 10px; +} + +h2 { + margin-bottom: 10px; + padding-bottom: 0.3em; + font-size: 1.5em; + border-bottom: 1px solid #cecece; +} + +h3 { + margin-bottom: 10px; + font-size: 1.25em +} + +h4 { + margin-bottom: 8px; + font-size: 1em +} + +h5 { + margin-bottom: 8px; + font-size: 0.875em +} + +h6 { + margin-bottom: 5px; + font-size: 0.85em; + color: #6a737d +} + +table { + border-collapse: collapse; + border-spacing: 0; + width: 100%; + display: block; + width: 100%; +} + +table th { + font-weight: 600; +} + +table th,table td { + padding: 6px 13px; + border: 1px solid #dfe2e5; +} + +table tr { + background-color: #fff; + border-top: 1px solid #c6cbd1; +} + +table tr:nth-child(2n) { + background-color: #f6f8fa; +} + +table img { + background-color: transparent; +} + +img { + max-width: 100%; + box-sizing: content-box; + background-color: #fff; + vertical-align: middle; +} + +img[align=right] { + padding-left: 20px; +} + +img[align=left] { + padding-right: 20px; +} + +.comment,.quote{ + color:#998; +} +.keyword,.selector-tag,.subst{ + color:#333;font-weight:bold; +} +.number,.literal,.variable,.template-variable,.tag .attr{ + color:#008080; +} +.string,.doctag{ + color:#d14; +} +.title,.section,.selector-id{ + color:#900;font-weight:bold; +} +.subst{ + font-weight:normal; +} +.type,.class .title{ + color:#458;font-weight:bold; +} +.tag,.name,.attribute{ + color:#000098; + font-weight:normal; +} +.regexp,.link{ + color:#009926; +} +.symbol,.bullet{ + color:#990073; +} +.built_in,.builtin-name{ + color:#0086b3; +} +.meta{ + color:#999;font-weight:bold; +} +.deletion{ + background:#fdd; +} +.addition{ + background:#dfd; +} +.emphasis{ + font-style:italic; +} +.strong{ + font-weight:bold; +} + diff --git a/website/components/Markdown/styles/index.less b/website/components/Markdown/styles/index.less new file mode 100644 index 0000000..3f285e9 --- /dev/null +++ b/website/components/Markdown/styles/index.less @@ -0,0 +1,25 @@ +.markdown { + padding: 0 20px 20px; + max-width: 995px; + margin: 0 auto; + font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace; + font-size: 14px; + line-height: 1.5; + word-wrap: break-word; + color: #24292e; + & >*:first-child { + margin-top: 0 !important + } + + & >*:last-child { + margin-bottom: 0 !important + } + :global { + @import "./default.less"; + // @import "./xml.less"; + // @import "./swift.less"; + // @import "./diff.less"; + // @import "./css.less"; + @import "./javascript.less"; + } +} \ No newline at end of file diff --git a/website/components/Markdown/styles/javascript.less b/website/components/Markdown/styles/javascript.less new file mode 100644 index 0000000..ad9a21b --- /dev/null +++ b/website/components/Markdown/styles/javascript.less @@ -0,0 +1,34 @@ +.language-jsx, .language-js,.language-javascript{ + .keyword, .selector-tag { + color: #b111bf; + font-weight: 600; + } + .subst { + color: #0000ca; + } + .title, .section { + color: #4e00dc; + font-weight: normal; + } + .string, .doctag { + color: #d73a49; + } + .attr { + color: #0000ca; + } + .class .keyword{ + color: #008cd4; + } + .function { + color: #0000ca; + .params { + color: #008cd4; + } + } +} +.language-json { + color: #444; + .attr { + color: #0000ca; + } +} \ No newline at end of file diff --git a/website/doc.md b/website/doc.md new file mode 100644 index 0000000..a443d28 --- /dev/null +++ b/website/doc.md @@ -0,0 +1,246 @@ +HotKeys.js is an input capture library with some very special features, it is easy to pick up and use, has a reasonable footprint (~3kb), and has no dependencies. It should not interfere with any JavaScript libraries or frameworks. + + +## USAGE + +You will need `Node.js` installed on your system. + +```shell +$ npm install hotkeys-js --save +``` + +``` +import hotkeys from 'hotkeys-js'; +``` + +Or manually download and link **hotkeys.js** in your HTML: + +```js + +``` + +### Used in React + +[react-hotkeys](https://github.com/jaywcjlove/react-hotkeys) is the React component that listen to keydown and keyup keyboard events, defining and dispatching keyboard shortcuts. + +```shell +$ npm install react-hot-keys --save +``` + +Detailed use method please see its documentation [react-hotkeys](https://github.com/jaywcjlove/react-hotkeys). + +## Browser Support + +Mousetrap has been tested and should work in. + +```shell +Internet Explorer 6+ +Safari +Firefox +Chrome +``` + +## DEFINING SHORTCUTS + +One global method is exposed, key which defines shortcuts when called directly. + +```js +hotkeys('f5', function(event, handler){ + // Prevent the default refresh event under WIDNOWS system + event.preventDefault() + alert('you pressed F5!') +}); + +hotkeys('a', function(event,handler){ + //event.srcElement: input + //event.target: input + if(event.target === "input"){ + alert('you pressed a!') + } + alert('you pressed a!') +}); + +hotkeys('ctrl+a,ctrl+b,r,f', function(event,handler){ + switch(handler.key){ + case "ctrl+a":alert('you pressed ctrl+a!');break; + case "ctrl+b":alert('you pressed ctrl+b!');break; + case "r":alert('you pressed r!');break; + case "f":alert('you pressed f!');break; + } +}); + +hotkeys('*','wcj', function(e){ + console.log('do something',e); +}); +``` + +## API REFERENCE + +Asterisk "*" + +Modifier key judgments + +```js +hotkeys('*','wcj', function(e){ + if(hotkeys.shift) console.log('shift is pressed!'); + if(hotkeys.ctrl) console.log('shift is pressed! '); + if(hotkeys.alt) console.log('shift is pressed! '); +}); +``` + +### setScope + +Use the `hotkeys.setScope` method to set scope. + +```js +// define shortcuts with a scope +hotkeys('ctrl+o, ctrl+alt+enter', 'issues', function(){ + console.log('do something'); +}); +hotkeys('o, enter', 'files', function(){ + console.log('do something else'); +}); + +// set the scope (only 'all' and 'issues' shortcuts will be honored) +hotkeys.setScope('issues'); // default scope is 'all' +``` + +### getScope + +Use the `hotkeys.getScope` method to get scope. + +```js +hotkeys.getScope(); +``` + +### deleteScope + +Use the `hotkeys.deleteScope` method to delete set scope. + +```js +hotkeys.deleteScope('issues'); +``` + +### unbind + +Similar to defining shortcuts, they can be unbound using `hotkeys.unbind`. + +```js +// unbind 'a' handler +hotkeys.unbind('a'); + +// unbind a hotkeys only for a single scope +// when no scope is specified it defaults to the current scope (hotkeys.getScope()) +hotkeys.unbind('o, enter', 'issues'); +hotkeys.unbind('o, enter', 'files'); +``` + +### isPressed + +Other key queries. For example, `hotkeys.isPressed(77)` is true if the `M` key is currently pressed. + +```js +hotkeys('a', function(){ + console.log(hotkeys.isPressed("a")); //=> true + console.log(hotkeys.isPressed("A")); //=> true + console.log(hotkeys.isPressed(65)); //=> true +}); +``` + +### getPressedKeyCodes + +returns an array of key codes currently pressed. + +```js +hotkeys('command+ctrl+shift+a,f', function(){ + console.log(hotkeys.getPressedKeyCodes()); //=> [17, 65] or [70] +}) +``` + +### filter + +`INPUT` `SELECT` `TEXTAREA` default does not handle. +`Hotkeys.filter` to return to the `true` shortcut keys set to play a role, `flase` shortcut keys set up failure. + +```js +hotkeys.filter = function(event){ + return true; +} +//How to add the filter to edit labels.
+//"contentEditable" Older browsers that do not support drops +hotkeys.filter = function(event) { + var tagName = (event.target || event.srcElement).tagName; + return !(tagName.isContentEditable || tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA'); +} + +hotkeys.filter = function(event){ + var tagName = (event.target || event.srcElement).tagName; + hotkeys.setScope(/^(INPUT|TEXTAREA|SELECT)$/.test(tagName) ? 'input' : 'other'); + return true; +} +``` + +### noConflict + +Relinquish HotKeys’s control of the `hotkeys` variable. + +```js +var k = hotkeys.noConflict(); +k('a', function() { + console.log("do something") +}); + +hotkeys() +// -->Uncaught TypeError: hotkeys is not a function(anonymous function) +// @ VM2170:2InjectedScript._evaluateOn +// @ VM2165:883InjectedScript._evaluateAndWrap +// @ VM2165:816InjectedScript.evaluate @ VM2165:682 +``` + +### SUPPORTED KEYS + +HotKeys understands the following modifiers: `⇧`, `shift`, `option`, `⌥`, `alt`, `ctrl`, `control`, `command`, and `⌘`. + +The following special keys can be used for shortcuts: backspace, tab, clear, enter, return, esc, escape, space, up, down, left, right, home, end, pageup, pagedown, del, delete and f1 through f19. + +`⌘` Command() +`⌃` Control +`⌥` Option(alt) +`⇧` Shift +`⇪` Caps Lock(Capital) +~~`fn` Does not support fn~~ +`↩︎` return/Enter space + +## Development + +To develop, run the self-reloading build, Get the code: + +```shell +$ git https://github.com/jaywcjlove/hotkeys.git +$ cd hotkeys # Into the directory +$ npm install # or yarn install +``` + +To develop, run the self-reloading build: + +```shell +$ npm run watch +``` + +Run Document Website Environment. + +```shell +$ npm run doc:dev +``` + +## License + +[MIT © Kenny Wong](https://kossnocorp.mit-license.org/) + +```bash + __ __ __ + | |--..-----.| |_ | |--..-----..--.--..-----. + | || _ || _|| < | -__|| | ||__ --| + |__|__||_____||____||__|__||_____||___ ||_____| + |_____| +``` \ No newline at end of file diff --git a/website/index.html b/website/index.html new file mode 100644 index 0000000..a5ecbe9 --- /dev/null +++ b/website/index.html @@ -0,0 +1,13 @@ + + + + hotkeys.js - A robust Javascript library for capturing keyboard input. + + + + +
+ + + + \ No newline at end of file diff --git a/website/index.js b/website/index.js new file mode 100644 index 0000000..72d347c --- /dev/null +++ b/website/index.js @@ -0,0 +1,6 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; +import './styles/reset.less'; + +ReactDOM.render(, document.getElementById('root')); \ No newline at end of file diff --git a/website/styles/index.less b/website/styles/index.less new file mode 100644 index 0000000..425f270 --- /dev/null +++ b/website/styles/index.less @@ -0,0 +1,77 @@ +.keyCodeInfo { + position: fixed; + bottom: 10px; + left: 10px; + span + span { + margin-left: 10px; + } + span { + display: inline-block; + background: #eff0f2; + border-radius: 3px; + padding: 5px 10px; + border-top: 1px solid #f5f5f5; + box-shadow: inset 0 0 25px #e8e8e8, 0 1px 0 #c3c3c3, 0 2px 0 #c9c9c9, 0 2px 3px #333; + text-shadow: 0px 1px 0px #f5f5f5; + } +} + +.header { + background-color: #292929; + padding: 74px 0 80px 0; + .title { + text-align: center; + font-size: 53px; + font-weight: bold; + color: #fff; + text-shadow: -3px -3px 0 #676767, -3px -3px 0 #676767, -3px -3px 0 #676767, -2px -2px 0 #676767, -2px -2px 0 #676767, -1px -1px 0 #676767; + } + .lang { + text-align: center; + padding-top: 20px; + a { + color: #fff; + margin: 0 5px; + } + } + .info { + padding: 25px 0 27px 0; + text-align: center; + font-size: 23px; + line-height: 29px; + color: #878787; + max-width: 702px; + margin: 0 auto; + } + .github { + text-align: center; + padding: 60px 0 22px 0; + a + a { + margin-left: 10px; + } + button { + position: relative; + display: inline-block; + border: 1px solid #ddd; + border-bottom-color: #bbb; + padding: 9px 15px; + font-family: Helvetica, arial, freesans, clean, sans-serif; + font-size: 12px; + font-weight: bold; + color: #666; + text-shadow: 0 1px rgba(255, 255, 255, 0.9); + cursor: pointer; + border-radius: 3px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + background: whitesmoke; + background-image: linear-gradient(-90deg, whitesmoke 0%, #e5e5e5 100%); + &:hover { + color: #337797; + border: 1px solid #CBE3EE; + border-bottom-color: #97C7DD; + background: #f0f7fa; + background-image: -webkit-linear-gradient(-90deg, #f0f7fa 0%, #d8eaf2 100%); + } + } + } +} \ No newline at end of file diff --git a/website/styles/reset.less b/website/styles/reset.less new file mode 100644 index 0000000..fd63017 --- /dev/null +++ b/website/styles/reset.less @@ -0,0 +1,44 @@ +html { + font-size: 14px; + background: #e0e0e0; +} +/* margin */ +body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, img, form, applet, fieldset, legend, button, input, textarea, th, table, tr, td{ + margin: 0; + padding: 0; + border: none; +} + +/* body */ +body { + font-family: "微软雅黑"; + font-size: 12px; + color:#535353; + position: relative; + font-family: "PingHei","Lucida Grande", "Lucida Sans Unicode", "STHeitiSC-Light", "Helvetica","Arial","Verdana","sans-serif"; + background: #f8f8f8 url(../assets/bg.jpg) repeat top left; +} + + +body, div, fieldset, form, h1, h2, h3, h4, h5, h6, html, p { + -webkit-text-size-adjust: none +} + +/* img */ +img { + padding: 0; + margin: 0; + vertical-align: top; + border: none; +} + + +/* div */ +li,ul { + list-style: none; + margin: 0 auto; + padding: 0 auto; + display: block; + font-family: "Vrinda"; + user-select: none; +} \ No newline at end of file