vue-functions
Advanced tools
Comparing version 2.0.0 to 2.0.1-beta
/*! | ||
* vue-functions v2.0.0 | ||
* (c) phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/ | ||
* vue-functions v2.0.1 | ||
* (c) phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/ | ||
'use strict'; | ||
@@ -10,321 +10,4 @@ | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
var hp = require('helper-js'); | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
} | ||
var _marked = | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(iterateALL); // local store | ||
function isObject(v) { | ||
return Object.prototype.toString.call(v) === '[object Object]'; | ||
} | ||
function isFunction(v) { | ||
return typeof v === 'function'; | ||
} | ||
function isPromise(v) { | ||
return Object.prototype.toString.call(v) === '[object Promise]'; | ||
} | ||
function arrayRemove(arr, v) { | ||
var index; | ||
var count = 0; | ||
while ((index = arr.indexOf(v)) > -1) { | ||
arr.splice(index, 1); | ||
count++; | ||
} | ||
return count; | ||
} | ||
function iterateALL(val) { | ||
var opt, | ||
i, | ||
info, | ||
_i7, | ||
_Object$keys2, | ||
key, | ||
_info, | ||
_i8, | ||
_info2, | ||
keys, | ||
_i9, | ||
_keys2, | ||
_key2, | ||
_info3, | ||
_args = arguments; | ||
return regeneratorRuntime.wrap(function iterateALL$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
opt = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
if (opt.reverse) { | ||
_context.next = 30; | ||
break; | ||
} | ||
if (!(val.length != null)) { | ||
_context.next = 14; | ||
break; | ||
} | ||
i = 0; | ||
case 4: | ||
if (!(i < val.length)) { | ||
_context.next = 12; | ||
break; | ||
} | ||
info = { | ||
value: val[i], | ||
index: i | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(info))) { | ||
_context.next = 9; | ||
break; | ||
} | ||
_context.next = 9; | ||
return info; | ||
case 9: | ||
i++; | ||
_context.next = 4; | ||
break; | ||
case 12: | ||
_context.next = 28; | ||
break; | ||
case 14: | ||
if (!isObject(val)) { | ||
_context.next = 27; | ||
break; | ||
} | ||
_i7 = 0, _Object$keys2 = Object.keys(val); | ||
case 16: | ||
if (!(_i7 < _Object$keys2.length)) { | ||
_context.next = 25; | ||
break; | ||
} | ||
key = _Object$keys2[_i7]; | ||
_info = { | ||
value: val[key], | ||
key: key | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(_info))) { | ||
_context.next = 22; | ||
break; | ||
} | ||
_context.next = 22; | ||
return _info; | ||
case 22: | ||
_i7++; | ||
_context.next = 16; | ||
break; | ||
case 25: | ||
_context.next = 28; | ||
break; | ||
case 27: | ||
throw 'Unsupported type'; | ||
case 28: | ||
_context.next = 58; | ||
break; | ||
case 30: | ||
if (!(val.length != null)) { | ||
_context.next = 42; | ||
break; | ||
} | ||
_i8 = val.length - 1; | ||
case 32: | ||
if (!(_i8 >= 0)) { | ||
_context.next = 40; | ||
break; | ||
} | ||
_info2 = { | ||
value: val[_i8], | ||
index: _i8 | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(_info2))) { | ||
_context.next = 37; | ||
break; | ||
} | ||
_context.next = 37; | ||
return _info2; | ||
case 37: | ||
_i8--; | ||
_context.next = 32; | ||
break; | ||
case 40: | ||
_context.next = 58; | ||
break; | ||
case 42: | ||
if (!isObject(val)) { | ||
_context.next = 57; | ||
break; | ||
} | ||
keys = Object.keys(val); | ||
keys.reverse(); | ||
_i9 = 0, _keys2 = keys; | ||
case 46: | ||
if (!(_i9 < _keys2.length)) { | ||
_context.next = 55; | ||
break; | ||
} | ||
_key2 = _keys2[_i9]; | ||
_info3 = { | ||
value: val[_key2], | ||
key: _key2 | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(_info3))) { | ||
_context.next = 52; | ||
break; | ||
} | ||
_context.next = 52; | ||
return _info3; | ||
case 52: | ||
_i9++; | ||
_context.next = 46; | ||
break; | ||
case 55: | ||
_context.next = 58; | ||
break; | ||
case 57: | ||
throw 'Unsupported type'; | ||
case 58: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _marked); | ||
} // source: http://stackoverflow.com/questions/8817394/javascript-get-deep-value-from-object-by-passing-path-to-it-as-string | ||
function joinFunctionsByNext(funcs) { | ||
var next = function next() {}; | ||
var _iteratorNormalCompletion5 = true; | ||
var _didIteratorError5 = false; | ||
var _iteratorError5 = undefined; | ||
try { | ||
for (var _iterator5 = iterateALL(funcs, { | ||
reverse: true | ||
})[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { | ||
var func = _step5.value.value; | ||
var currentNext = next; | ||
next = wrapFuncWithNext(func, currentNext); | ||
} | ||
} catch (err) { | ||
_didIteratorError5 = true; | ||
_iteratorError5 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) { | ||
_iterator5["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError5) { | ||
throw _iteratorError5; | ||
} | ||
} | ||
} | ||
return next; | ||
function wrapFuncWithNext(func, next) { | ||
return function () { | ||
for (var _len5 = arguments.length, args = new Array(_len5), _key7 = 0; _key7 < _len5; _key7++) { | ||
args[_key7] = arguments[_key7]; | ||
} | ||
return func.apply(void 0, [next].concat(args)); | ||
}; | ||
} | ||
} // promise | ||
function onDOM(el, name, handler) { | ||
for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key8 = 3; _key8 < _len6; _key8++) { | ||
args[_key8 - 3] = arguments[_key8]; | ||
} | ||
if (el.addEventListener) { | ||
// 所有主流浏览器,除了 IE 8 及更早 IE版本 | ||
el.addEventListener.apply(el, [name, handler].concat(args)); | ||
} else if (el.attachEvent) { | ||
// IE 8 及更早 IE 版本 | ||
el.attachEvent.apply(el, ["on".concat(name), handler].concat(args)); | ||
} | ||
} | ||
function offDOM(el, name, handler) { | ||
for (var _len7 = arguments.length, args = new Array(_len7 > 3 ? _len7 - 3 : 0), _key9 = 3; _key9 < _len7; _key9++) { | ||
args[_key9 - 3] = arguments[_key9]; | ||
} | ||
if (el.removeEventListener) { | ||
// 所有主流浏览器,除了 IE 8 及更早 IE版本 | ||
el.removeEventListener.apply(el, [name, handler].concat(args)); | ||
} else if (el.detachEvent) { | ||
// IE 8 及更早 IE 版本 | ||
el.detachEvent.apply(el, ["on".concat(name), handler].concat(args)); | ||
} | ||
} | ||
var _marked$1 = | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(iterateObjectWithoutDollarDash); | ||
/** | ||
@@ -341,3 +24,3 @@ * [updatablePropsEvenUnbound description] | ||
function updatablePropsEvenUnbound(props) { | ||
if (isFunction(props)) { | ||
if (hp.isFunction(props)) { | ||
props = props(); | ||
@@ -359,5 +42,3 @@ } else { | ||
if (!prop.$localSetter) { | ||
prop.$localSetter = function (value) { | ||
return value; | ||
}; | ||
prop.$localSetter = value => value; | ||
} // make standardProp | ||
@@ -368,3 +49,3 @@ | ||
standardProps[name] = standardProp; | ||
Object.keys(props[name]).forEach(function (key) { | ||
Object.keys(props[name]).forEach(key => { | ||
if (key[0] !== '$') { | ||
@@ -391,4 +72,3 @@ standardProp[key] = prop[key]; | ||
for (var _i = 0, _Object$keys = Object.keys(props); _i < _Object$keys.length; _i++) { | ||
var _name = _Object$keys[_i]; | ||
for (var _name of Object.keys(props)) { | ||
t.localValueOfUpdatableProps[_name] = this[_name]; | ||
@@ -400,8 +80,7 @@ } | ||
var _loop2 = function _loop2() { | ||
var name = _Object$keys2[_i2]; | ||
var prop = props[name]; | ||
var _loop2 = function _loop2(_name2) { | ||
var prop = props[_name2]; | ||
component.watch[name] = function (value) { | ||
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this); | ||
component.watch[_name2] = function (value) { | ||
this.localValueOfUpdatableProps[_name2] = prop.$localSetter(value, this); | ||
}; | ||
@@ -411,19 +90,21 @@ | ||
component.computed[localName] = { | ||
get: function get() { | ||
return this.localValueOfUpdatableProps[name]; | ||
get() { | ||
return this.localValueOfUpdatableProps[_name2]; | ||
}, | ||
set: function set(value) { | ||
if (name === 'value') { | ||
set(value) { | ||
if (_name2 === 'value') { | ||
this.$emit('input', value); | ||
} else { | ||
this.$emit("update:".concat(name), value); | ||
this.$emit("update:".concat(_name2), value); | ||
} | ||
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this); | ||
this.localValueOfUpdatableProps[_name2] = prop.$localSetter(value, this); | ||
} | ||
}; | ||
}; | ||
for (var _i2 = 0, _Object$keys2 = Object.keys(props); _i2 < _Object$keys2.length; _i2++) { | ||
_loop2(); | ||
for (var _name2 of Object.keys(props)) { | ||
_loop2(_name2); | ||
} | ||
@@ -446,5 +127,3 @@ | ||
function destroy() { | ||
destroies.forEach(function (f) { | ||
return f(); | ||
}); | ||
destroies.forEach(f => f()); | ||
destroies = []; | ||
@@ -456,5 +135,3 @@ } | ||
var first = true; | ||
var unwatch = vm.$watch(function () { | ||
return getter.call(vm, exec); | ||
}, function (value2) { | ||
var unwatch = vm.$watch(() => getter.call(vm, exec), value2 => { | ||
value = value2; | ||
@@ -482,3 +159,3 @@ | ||
var getterExecuted = function getterExecuted(value) { | ||
var getterExecuted = value => { | ||
if (localCount !== count) { | ||
@@ -499,3 +176,3 @@ // expired | ||
if (isPromise(result)) { | ||
if (hp.isPromise(result)) { | ||
result.then(getterExecuted); | ||
@@ -511,5 +188,5 @@ } else { | ||
var update = function update() { | ||
var update = () => { | ||
var getter = handler.call(vm, oldValue); | ||
unwatch = vm.$watch(getter, function (value) { | ||
unwatch = vm.$watch(getter, value => { | ||
unwatch(); | ||
@@ -522,48 +199,19 @@ oldValue = value; | ||
update(); | ||
return function () { | ||
return unwatch && unwatch(); | ||
}; | ||
return () => unwatch && unwatch(); | ||
} | ||
function iterateObjectWithoutDollarDash(obj) { | ||
var key, start; | ||
return regeneratorRuntime.wrap(function iterateObjectWithoutDollarDash$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.t0 = regeneratorRuntime.keys(obj); | ||
function* iterateObjectWithoutDollarDash(obj) { | ||
for (var key in obj) { | ||
var start = key.substr(0, 1); | ||
case 1: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 9; | ||
break; | ||
} | ||
key = _context.t1.value; | ||
start = key.substr(0, 1); | ||
if (!(start !== '$' && start !== '_')) { | ||
_context.next = 7; | ||
break; | ||
} | ||
_context.next = 7; | ||
return { | ||
key: key, | ||
value: obj[key] | ||
}; | ||
case 7: | ||
_context.next = 1; | ||
break; | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
if (start !== '$' && start !== '_') { | ||
yield { | ||
key, | ||
value: obj[key] | ||
}; | ||
} | ||
}, _marked$1); | ||
} | ||
} // add reactive `windowSize` | ||
var windowSize = { | ||
data: function data() { | ||
data() { | ||
return { | ||
@@ -578,4 +226,5 @@ windowSize: { | ||
}, | ||
methods: { | ||
updateWindowSize: function updateWindowSize() { | ||
updateWindowSize() { | ||
Object.assign(this.windowSize, { | ||
@@ -588,17 +237,18 @@ innerWidth: window.innerWidth, | ||
} | ||
}, | ||
created: function created() { | ||
var _this = this; | ||
this._windowSize_onresize = function () { | ||
_this.updateWindowSize(); | ||
_this.$emit('window-resize'); | ||
created() { | ||
this._windowSize_onresize = () => { | ||
this.updateWindowSize(); | ||
this.$emit('window-resize'); | ||
}; | ||
onDOM(window, 'resize', this._windowSize_onresize); | ||
hp.onDOM(window, 'resize', this._windowSize_onresize); | ||
}, | ||
beforeDestroy: function beforeDestroy() { | ||
offDOM(window, 'resize', this._windowSize_onresize); | ||
beforeDestroy() { | ||
hp.offDOM(window, 'resize', this._windowSize_onresize); | ||
} | ||
}; | ||
@@ -608,3 +258,3 @@ function registerPreventURLChange(Vue, router, msg) { | ||
var msg0 = "It looks like you have been editing something.\nIf you leave before saving, your changes will be lost."; | ||
router.beforeEach(function (to, from, next) { | ||
router.beforeEach((to, from, next) => { | ||
if (preventRouter) { | ||
@@ -622,3 +272,3 @@ if (window.confirm(msg || msg0)) { | ||
var beforeunload = function beforeunload(e) { | ||
var beforeunload = e => { | ||
var confirmationMessage = msg || msg0; | ||
@@ -630,3 +280,3 @@ e.returnValue = confirmationMessage; // Gecko, Trident, Chrome 34+ | ||
Vue.preventURLChange = Vue.prototype.$preventURLChange = function (msg2) { | ||
Vue.preventURLChange = Vue.prototype.$preventURLChange = msg2 => { | ||
if (msg2 != null) { | ||
@@ -642,3 +292,3 @@ msg = msg2; | ||
Vue.allowURLChange = Vue.prototype.$allowURLChange = function () { | ||
Vue.allowURLChange = Vue.prototype.$allowURLChange = () => { | ||
preventRouter = false; | ||
@@ -652,3 +302,3 @@ window.removeEventListener("beforeunload", beforeunload); | ||
// get hooks in this._hooks, without which in props | ||
_getNonPropHooksByName: function _getNonPropHooksByName(name) { | ||
_getNonPropHooksByName(name) { | ||
if (this._hooks) { | ||
@@ -658,3 +308,4 @@ return this._hooks[name]; | ||
}, | ||
addHook: function addHook(name, func) { | ||
addHook(name, func) { | ||
if (!this._getNonPropHooksByName(name)) { | ||
@@ -672,17 +323,20 @@ if (!this._hooks) { | ||
}, | ||
removeHook: function removeHook(name, func) { | ||
removeHook(name, func) { | ||
var hooks = this._getNonPropHooksByName(name); | ||
if (hooks) { | ||
arrayRemove(hooks, func); | ||
hp.arrayRemove(hooks, func); | ||
} | ||
}, | ||
hasHook: function hasHook(name) { | ||
hasHook(name) { | ||
return this._getNonPropHooksByName(name) || this[name]; | ||
}, | ||
executeHook: function executeHook(name, args) { | ||
executeHook(name, args) { | ||
var hooks = this._getNonPropHooksByName(name).slice(); | ||
if (hooks) { | ||
if (this[name] && isFunction(this[name])) { | ||
if (this[name] && hp.isFunction(this[name])) { | ||
hooks.push(function (next) { | ||
@@ -693,9 +347,10 @@ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
return this[name].apply(this, args); | ||
return this[name](...args); | ||
}); | ||
} | ||
return joinFunctionsByNext(hooks).apply(void 0, _toConsumableArray(args)); | ||
return hp.joinFunctionsByNext(hooks)(...args); | ||
} | ||
} | ||
} | ||
@@ -702,0 +357,0 @@ }; |
/*! | ||
* vue-functions v2.0.0 | ||
* (c) phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/ | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
* vue-functions v2.0.1 | ||
* (c) phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/ | ||
import { isFunction, isPromise, onDOM, offDOM, arrayRemove, joinFunctionsByNext } from 'helper-js'; | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
} | ||
var _marked = | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(iterateALL); // local store | ||
function isObject(v) { | ||
return Object.prototype.toString.call(v) === '[object Object]'; | ||
} | ||
function isFunction(v) { | ||
return typeof v === 'function'; | ||
} | ||
function isPromise(v) { | ||
return Object.prototype.toString.call(v) === '[object Promise]'; | ||
} | ||
function arrayRemove(arr, v) { | ||
var index; | ||
var count = 0; | ||
while ((index = arr.indexOf(v)) > -1) { | ||
arr.splice(index, 1); | ||
count++; | ||
} | ||
return count; | ||
} | ||
function iterateALL(val) { | ||
var opt, | ||
i, | ||
info, | ||
_i7, | ||
_Object$keys2, | ||
key, | ||
_info, | ||
_i8, | ||
_info2, | ||
keys, | ||
_i9, | ||
_keys2, | ||
_key2, | ||
_info3, | ||
_args = arguments; | ||
return regeneratorRuntime.wrap(function iterateALL$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
opt = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
if (opt.reverse) { | ||
_context.next = 30; | ||
break; | ||
} | ||
if (!(val.length != null)) { | ||
_context.next = 14; | ||
break; | ||
} | ||
i = 0; | ||
case 4: | ||
if (!(i < val.length)) { | ||
_context.next = 12; | ||
break; | ||
} | ||
info = { | ||
value: val[i], | ||
index: i | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(info))) { | ||
_context.next = 9; | ||
break; | ||
} | ||
_context.next = 9; | ||
return info; | ||
case 9: | ||
i++; | ||
_context.next = 4; | ||
break; | ||
case 12: | ||
_context.next = 28; | ||
break; | ||
case 14: | ||
if (!isObject(val)) { | ||
_context.next = 27; | ||
break; | ||
} | ||
_i7 = 0, _Object$keys2 = Object.keys(val); | ||
case 16: | ||
if (!(_i7 < _Object$keys2.length)) { | ||
_context.next = 25; | ||
break; | ||
} | ||
key = _Object$keys2[_i7]; | ||
_info = { | ||
value: val[key], | ||
key: key | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(_info))) { | ||
_context.next = 22; | ||
break; | ||
} | ||
_context.next = 22; | ||
return _info; | ||
case 22: | ||
_i7++; | ||
_context.next = 16; | ||
break; | ||
case 25: | ||
_context.next = 28; | ||
break; | ||
case 27: | ||
throw 'Unsupported type'; | ||
case 28: | ||
_context.next = 58; | ||
break; | ||
case 30: | ||
if (!(val.length != null)) { | ||
_context.next = 42; | ||
break; | ||
} | ||
_i8 = val.length - 1; | ||
case 32: | ||
if (!(_i8 >= 0)) { | ||
_context.next = 40; | ||
break; | ||
} | ||
_info2 = { | ||
value: val[_i8], | ||
index: _i8 | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(_info2))) { | ||
_context.next = 37; | ||
break; | ||
} | ||
_context.next = 37; | ||
return _info2; | ||
case 37: | ||
_i8--; | ||
_context.next = 32; | ||
break; | ||
case 40: | ||
_context.next = 58; | ||
break; | ||
case 42: | ||
if (!isObject(val)) { | ||
_context.next = 57; | ||
break; | ||
} | ||
keys = Object.keys(val); | ||
keys.reverse(); | ||
_i9 = 0, _keys2 = keys; | ||
case 46: | ||
if (!(_i9 < _keys2.length)) { | ||
_context.next = 55; | ||
break; | ||
} | ||
_key2 = _keys2[_i9]; | ||
_info3 = { | ||
value: val[_key2], | ||
key: _key2 | ||
}; | ||
if (!(!opt.exclude || !opt.exclude(_info3))) { | ||
_context.next = 52; | ||
break; | ||
} | ||
_context.next = 52; | ||
return _info3; | ||
case 52: | ||
_i9++; | ||
_context.next = 46; | ||
break; | ||
case 55: | ||
_context.next = 58; | ||
break; | ||
case 57: | ||
throw 'Unsupported type'; | ||
case 58: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _marked); | ||
} // source: http://stackoverflow.com/questions/8817394/javascript-get-deep-value-from-object-by-passing-path-to-it-as-string | ||
function joinFunctionsByNext(funcs) { | ||
var next = function next() {}; | ||
var _iteratorNormalCompletion5 = true; | ||
var _didIteratorError5 = false; | ||
var _iteratorError5 = undefined; | ||
try { | ||
for (var _iterator5 = iterateALL(funcs, { | ||
reverse: true | ||
})[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { | ||
var func = _step5.value.value; | ||
var currentNext = next; | ||
next = wrapFuncWithNext(func, currentNext); | ||
} | ||
} catch (err) { | ||
_didIteratorError5 = true; | ||
_iteratorError5 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) { | ||
_iterator5["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError5) { | ||
throw _iteratorError5; | ||
} | ||
} | ||
} | ||
return next; | ||
function wrapFuncWithNext(func, next) { | ||
return function () { | ||
for (var _len5 = arguments.length, args = new Array(_len5), _key7 = 0; _key7 < _len5; _key7++) { | ||
args[_key7] = arguments[_key7]; | ||
} | ||
return func.apply(void 0, [next].concat(args)); | ||
}; | ||
} | ||
} // promise | ||
function onDOM(el, name, handler) { | ||
for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key8 = 3; _key8 < _len6; _key8++) { | ||
args[_key8 - 3] = arguments[_key8]; | ||
} | ||
if (el.addEventListener) { | ||
// 所有主流浏览器,除了 IE 8 及更早 IE版本 | ||
el.addEventListener.apply(el, [name, handler].concat(args)); | ||
} else if (el.attachEvent) { | ||
// IE 8 及更早 IE 版本 | ||
el.attachEvent.apply(el, ["on".concat(name), handler].concat(args)); | ||
} | ||
} | ||
function offDOM(el, name, handler) { | ||
for (var _len7 = arguments.length, args = new Array(_len7 > 3 ? _len7 - 3 : 0), _key9 = 3; _key9 < _len7; _key9++) { | ||
args[_key9 - 3] = arguments[_key9]; | ||
} | ||
if (el.removeEventListener) { | ||
// 所有主流浏览器,除了 IE 8 及更早 IE版本 | ||
el.removeEventListener.apply(el, [name, handler].concat(args)); | ||
} else if (el.detachEvent) { | ||
// IE 8 及更早 IE 版本 | ||
el.detachEvent.apply(el, ["on".concat(name), handler].concat(args)); | ||
} | ||
} | ||
var _marked$1 = | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(iterateObjectWithoutDollarDash); | ||
/** | ||
@@ -353,5 +36,3 @@ * [updatablePropsEvenUnbound description] | ||
if (!prop.$localSetter) { | ||
prop.$localSetter = function (value) { | ||
return value; | ||
}; | ||
prop.$localSetter = value => value; | ||
} // make standardProp | ||
@@ -362,3 +43,3 @@ | ||
standardProps[name] = standardProp; | ||
Object.keys(props[name]).forEach(function (key) { | ||
Object.keys(props[name]).forEach(key => { | ||
if (key[0] !== '$') { | ||
@@ -385,4 +66,3 @@ standardProp[key] = prop[key]; | ||
for (var _i = 0, _Object$keys = Object.keys(props); _i < _Object$keys.length; _i++) { | ||
var _name = _Object$keys[_i]; | ||
for (var _name of Object.keys(props)) { | ||
t.localValueOfUpdatableProps[_name] = this[_name]; | ||
@@ -394,8 +74,7 @@ } | ||
var _loop2 = function _loop2() { | ||
var name = _Object$keys2[_i2]; | ||
var prop = props[name]; | ||
var _loop2 = function _loop2(_name2) { | ||
var prop = props[_name2]; | ||
component.watch[name] = function (value) { | ||
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this); | ||
component.watch[_name2] = function (value) { | ||
this.localValueOfUpdatableProps[_name2] = prop.$localSetter(value, this); | ||
}; | ||
@@ -405,19 +84,21 @@ | ||
component.computed[localName] = { | ||
get: function get() { | ||
return this.localValueOfUpdatableProps[name]; | ||
get() { | ||
return this.localValueOfUpdatableProps[_name2]; | ||
}, | ||
set: function set(value) { | ||
if (name === 'value') { | ||
set(value) { | ||
if (_name2 === 'value') { | ||
this.$emit('input', value); | ||
} else { | ||
this.$emit("update:".concat(name), value); | ||
this.$emit("update:".concat(_name2), value); | ||
} | ||
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this); | ||
this.localValueOfUpdatableProps[_name2] = prop.$localSetter(value, this); | ||
} | ||
}; | ||
}; | ||
for (var _i2 = 0, _Object$keys2 = Object.keys(props); _i2 < _Object$keys2.length; _i2++) { | ||
_loop2(); | ||
for (var _name2 of Object.keys(props)) { | ||
_loop2(_name2); | ||
} | ||
@@ -440,5 +121,3 @@ | ||
function destroy() { | ||
destroies.forEach(function (f) { | ||
return f(); | ||
}); | ||
destroies.forEach(f => f()); | ||
destroies = []; | ||
@@ -450,5 +129,3 @@ } | ||
var first = true; | ||
var unwatch = vm.$watch(function () { | ||
return getter.call(vm, exec); | ||
}, function (value2) { | ||
var unwatch = vm.$watch(() => getter.call(vm, exec), value2 => { | ||
value = value2; | ||
@@ -476,3 +153,3 @@ | ||
var getterExecuted = function getterExecuted(value) { | ||
var getterExecuted = value => { | ||
if (localCount !== count) { | ||
@@ -504,5 +181,5 @@ // expired | ||
var update = function update() { | ||
var update = () => { | ||
var getter = handler.call(vm, oldValue); | ||
unwatch = vm.$watch(getter, function (value) { | ||
unwatch = vm.$watch(getter, value => { | ||
unwatch(); | ||
@@ -515,48 +192,19 @@ oldValue = value; | ||
update(); | ||
return function () { | ||
return unwatch && unwatch(); | ||
}; | ||
return () => unwatch && unwatch(); | ||
} | ||
function iterateObjectWithoutDollarDash(obj) { | ||
var key, start; | ||
return regeneratorRuntime.wrap(function iterateObjectWithoutDollarDash$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.t0 = regeneratorRuntime.keys(obj); | ||
function* iterateObjectWithoutDollarDash(obj) { | ||
for (var key in obj) { | ||
var start = key.substr(0, 1); | ||
case 1: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 9; | ||
break; | ||
} | ||
key = _context.t1.value; | ||
start = key.substr(0, 1); | ||
if (!(start !== '$' && start !== '_')) { | ||
_context.next = 7; | ||
break; | ||
} | ||
_context.next = 7; | ||
return { | ||
key: key, | ||
value: obj[key] | ||
}; | ||
case 7: | ||
_context.next = 1; | ||
break; | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
if (start !== '$' && start !== '_') { | ||
yield { | ||
key, | ||
value: obj[key] | ||
}; | ||
} | ||
}, _marked$1); | ||
} | ||
} // add reactive `windowSize` | ||
var windowSize = { | ||
data: function data() { | ||
data() { | ||
return { | ||
@@ -571,4 +219,5 @@ windowSize: { | ||
}, | ||
methods: { | ||
updateWindowSize: function updateWindowSize() { | ||
updateWindowSize() { | ||
Object.assign(this.windowSize, { | ||
@@ -581,10 +230,9 @@ innerWidth: window.innerWidth, | ||
} | ||
}, | ||
created: function created() { | ||
var _this = this; | ||
this._windowSize_onresize = function () { | ||
_this.updateWindowSize(); | ||
_this.$emit('window-resize'); | ||
created() { | ||
this._windowSize_onresize = () => { | ||
this.updateWindowSize(); | ||
this.$emit('window-resize'); | ||
}; | ||
@@ -594,5 +242,7 @@ | ||
}, | ||
beforeDestroy: function beforeDestroy() { | ||
beforeDestroy() { | ||
offDOM(window, 'resize', this._windowSize_onresize); | ||
} | ||
}; | ||
@@ -602,3 +252,3 @@ function registerPreventURLChange(Vue, router, msg) { | ||
var msg0 = "It looks like you have been editing something.\nIf you leave before saving, your changes will be lost."; | ||
router.beforeEach(function (to, from, next) { | ||
router.beforeEach((to, from, next) => { | ||
if (preventRouter) { | ||
@@ -616,3 +266,3 @@ if (window.confirm(msg || msg0)) { | ||
var beforeunload = function beforeunload(e) { | ||
var beforeunload = e => { | ||
var confirmationMessage = msg || msg0; | ||
@@ -624,3 +274,3 @@ e.returnValue = confirmationMessage; // Gecko, Trident, Chrome 34+ | ||
Vue.preventURLChange = Vue.prototype.$preventURLChange = function (msg2) { | ||
Vue.preventURLChange = Vue.prototype.$preventURLChange = msg2 => { | ||
if (msg2 != null) { | ||
@@ -636,3 +286,3 @@ msg = msg2; | ||
Vue.allowURLChange = Vue.prototype.$allowURLChange = function () { | ||
Vue.allowURLChange = Vue.prototype.$allowURLChange = () => { | ||
preventRouter = false; | ||
@@ -646,3 +296,3 @@ window.removeEventListener("beforeunload", beforeunload); | ||
// get hooks in this._hooks, without which in props | ||
_getNonPropHooksByName: function _getNonPropHooksByName(name) { | ||
_getNonPropHooksByName(name) { | ||
if (this._hooks) { | ||
@@ -652,3 +302,4 @@ return this._hooks[name]; | ||
}, | ||
addHook: function addHook(name, func) { | ||
addHook(name, func) { | ||
if (!this._getNonPropHooksByName(name)) { | ||
@@ -666,3 +317,4 @@ if (!this._hooks) { | ||
}, | ||
removeHook: function removeHook(name, func) { | ||
removeHook(name, func) { | ||
var hooks = this._getNonPropHooksByName(name); | ||
@@ -674,6 +326,8 @@ | ||
}, | ||
hasHook: function hasHook(name) { | ||
hasHook(name) { | ||
return this._getNonPropHooksByName(name) || this[name]; | ||
}, | ||
executeHook: function executeHook(name, args) { | ||
executeHook(name, args) { | ||
var hooks = this._getNonPropHooksByName(name).slice(); | ||
@@ -688,9 +342,10 @@ | ||
return this[name].apply(this, args); | ||
return this[name](...args); | ||
}); | ||
} | ||
return joinFunctionsByNext(hooks).apply(void 0, _toConsumableArray(args)); | ||
return joinFunctionsByNext(hooks)(...args); | ||
} | ||
} | ||
} | ||
@@ -697,0 +352,0 @@ }; |
/*! | ||
* vue-functions v2.0.0 | ||
* (c) phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).vueFunctions={})}(this,(function(e){"use strict";function t(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var n=regeneratorRuntime.mark(a);function r(e){return"[object Object]"===Object.prototype.toString.call(e)}function o(e){return"function"==typeof e}function a(e){var t,o,a,i,c,u,s,l,f,h,d,p,v,w,b=arguments;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if((t=b.length>1&&void 0!==b[1]?b[1]:{}).reverse){n.next=30;break}if(null==e.length){n.next=14;break}o=0;case 4:if(!(o<e.length)){n.next=12;break}if(a={value:e[o],index:o},t.exclude&&t.exclude(a)){n.next=9;break}return n.next=9,a;case 9:o++,n.next=4;break;case 12:n.next=28;break;case 14:if(!r(e)){n.next=27;break}i=0,c=Object.keys(e);case 16:if(!(i<c.length)){n.next=25;break}if(u=c[i],s={value:e[u],key:u},t.exclude&&t.exclude(s)){n.next=22;break}return n.next=22,s;case 22:i++,n.next=16;break;case 25:n.next=28;break;case 27:throw"Unsupported type";case 28:n.next=58;break;case 30:if(null==e.length){n.next=42;break}l=e.length-1;case 32:if(!(l>=0)){n.next=40;break}if(f={value:e[l],index:l},t.exclude&&t.exclude(f)){n.next=37;break}return n.next=37,f;case 37:l--,n.next=32;break;case 40:n.next=58;break;case 42:if(!r(e)){n.next=57;break}(h=Object.keys(e)).reverse(),d=0,p=h;case 46:if(!(d<p.length)){n.next=55;break}if(v=p[d],w={value:e[v],key:v},t.exclude&&t.exclude(w)){n.next=52;break}return n.next=52,w;case 52:d++,n.next=46;break;case 55:n.next=58;break;case 57:throw"Unsupported type";case 58:case"end":return n.stop()}}),n)}var i=regeneratorRuntime.mark(c);function c(e){var t,n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=regeneratorRuntime.keys(e);case 1:if((r.t1=r.t0()).done){r.next=9;break}if(t=r.t1.value,"$"===(n=t.substr(0,1))||"_"===n){r.next=7;break}return r.next=7,{key:t,value:e[t]};case 7:r.next=1;break;case 9:case"end":return r.stop()}}),i)}var u={data:function(){return{windowSize:{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight}}},methods:{updateWindowSize:function(){Object.assign(this.windowSize,{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight})}},created:function(){var e=this;this._windowSize_onresize=function(){e.updateWindowSize(),e.$emit("window-resize")},function(e,t,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];e.addEventListener?e.addEventListener.apply(e,[t,n].concat(o)):e.attachEvent&&e.attachEvent.apply(e,["on".concat(t),n].concat(o))}(window,"resize",this._windowSize_onresize)},beforeDestroy:function(){!function(e,t,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];e.removeEventListener?e.removeEventListener.apply(e,[t,n].concat(o)):e.detachEvent&&e.detachEvent.apply(e,["on".concat(t),n].concat(o))}(window,"resize",this._windowSize_onresize)}};var s={methods:{_getNonPropHooksByName:function(e){if(this._hooks)return this._hooks[e]},addHook:function(e,t){this._getNonPropHooksByName(e)||(this._hooks||(this._hooks={}),this._hooks[e]||(this._hooks[e]=[])),this._hooks[e].push(t)},removeHook:function(e,t){var n=this._getNonPropHooksByName(e);n&&function(e,t){for(var n,r=0;(n=e.indexOf(t))>-1;)e.splice(n,1),r++}(n,t)},hasHook:function(e){return this._getNonPropHooksByName(e)||this[e]},executeHook:function(e,n){var r=this._getNonPropHooksByName(e).slice();if(r)return this[e]&&o(this[e])&&r.push((function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return this[e].apply(this,r)})),function(e){var t=function(){},n=!0,r=!1,o=void 0;try{for(var i,c=a(e,{reverse:!0})[Symbol.iterator]();!(n=(i=c.next()).done);n=!0){t=u(i.value.value,t)}}catch(e){r=!0,o=e}finally{try{n||null==c.return||c.return()}finally{if(r)throw o}}return t;function u(e,t){return function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.apply(void 0,[t].concat(r))}}}(r).apply(void 0,t(n))}}};e.doWatch=function(e,t){var n,r;return function o(){var a=t.call(e,n);r=e.$watch(a,(function(e){r(),n=e,o()}))}(),function(){return r&&r()}},e.hookHelper=s,e.isPropTrue=function(e){return""===e||e},e.iterateObjectWithoutDollarDash=c,e.registerPreventURLChange=function(e,t,n){var r=!1,o="It looks like you have been editing something.\nIf you leave before saving, your changes will be lost.";t.beforeEach((function(t,a,i){r?window.confirm(n||o)?(e.allowURLChange(),i()):i(!1):i()}));var a=function(e){var t=n||o;return e.returnValue=t,t};e.preventURLChange=e.prototype.$preventURLChange=function(e){null!=e&&(n=e),r||(r=!0,window.addEventListener("beforeunload",a))},e.allowURLChange=e.prototype.$allowURLChange=function(){r=!1,window.removeEventListener("beforeunload",a)}},e.updatablePropsEvenUnbound=function(e){e=o(e)?e():Object.assign({},e);var t={},n=function(n){var r=e[n];r.$localName||(r.$localName="localProps_".concat(n)),r.$localSetter||(r.$localSetter=function(e){return e});var o={};t[n]=o,Object.keys(e[n]).forEach((function(e){"$"!==e[0]&&(o[e]=r[e])}))};for(var r in e)n(r);for(var a={props:t,computed:{},watch:{},data:function(){for(var t={localValueOfUpdatableProps:{}},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];t.localValueOfUpdatableProps[o]=this[o]}return t}},i=function(){var t=u[c],n=e[t];a.watch[t]=function(e){this.localValueOfUpdatableProps[t]=n.$localSetter(e,this)};var r=n.$localName;a.computed[r]={get:function(){return this.localValueOfUpdatableProps[t]},set:function(e){"value"===t?this.$emit("input",e):this.$emit("update:".concat(t),e),this.localValueOfUpdatableProps[t]=n.$localSetter(e,this)}}},c=0,u=Object.keys(e);c<u.length;c++)i();return a},e.watchAsync=function(e,t,n,r){var o,a,i=[],c=-1;return l(),u;function u(){i.forEach((function(e){return e()})),i=[]}function s(t,n){var r,o=!0,a=e.$watch((function(){return t.call(e,s)}),(function(e){r=e,o?o=!1:l()}),{immediate:!0,deep:n&&n.deep});return i.push(a),r}function l(){u();var i=t.call(e,s),l=++c;a=o;var f,h=function(t){l===c&&(0===l?r&&r.immediate&&n.call(e,t,a):n.call(e,t,a))};f=i,"[object Promise]"===Object.prototype.toString.call(f)?i.then(h):h(i)}},e.windowSize=u,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=vue-functions.min.js.map | ||
* vue-functions v2.0.1 | ||
* (c) phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).vueFunctions={})}(this,(function(t){"use strict";var e=function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}};var r=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)};var n=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")};var o=function(t){return e(t)||r(t)||n()};function i(t,e){return t(e={exports:{}},e.exports),e.exports}var a=i((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return _()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=m(a,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var f=u(t,e,r);if("normal"===f.type){if(n=r.done?"completed":"suspendedYield",f.arg===s)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(n="completed",r.method="throw",r.arg=f.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var s={};function f(){}function l(){}function h(){}var p={};p[o]=function(){return this};var d=Object.getPrototypeOf,v=d&&d(d(L([])));v&&v!==e&&r.call(v,o)&&(p=v);var y=h.prototype=f.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function w(t){var e;this._invoke=function(n,o){function i(){return new Promise((function(e,i){!function e(n,o,i,a){var c=u(t[n],t,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?Promise.resolve(f.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return e("throw",t,i,a)}))}a(c.arg)}(n,o,e,i)}))}return e=e?e.then(i,i):i()}}function m(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,m(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:_}}function _(){return{value:void 0,done:!0}}return l.prototype=y.constructor=h,h.constructor=l,h[a]=l.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,a in t||(t[a]="GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o){var i=new w(c(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(y),y[a]="Generator",y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),s},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}})),c=(i((function(t){function e(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(r)}t.exports=e})),i((function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(r)}t.exports=e})));var u=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t},s=(i((function(t){function e(r,n,o){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,r){var n=u(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r):o.value}},e(r,n,o||r)}t.exports=e})),i((function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(r,n)}t.exports=e})),i((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return _()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=m(a,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var f=u(t,e,r);if("normal"===f.type){if(n=r.done?"completed":"suspendedYield",f.arg===s)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(n="completed",r.method="throw",r.arg=f.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var s={};function f(){}function l(){}function h(){}var p={};p[o]=function(){return this};var d=Object.getPrototypeOf,v=d&&d(d(L([])));v&&v!==e&&r.call(v,o)&&(p=v);var y=h.prototype=f.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function w(t){var e;this._invoke=function(n,o){function i(){return new Promise((function(e,i){!function e(n,o,i,a){var c=u(t[n],t,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?Promise.resolve(f.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return e("throw",t,i,a)}))}a(c.arg)}(n,o,e,i)}))}return e=e?e.then(i,i):i()}}function m(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,m(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:_}}function _(){return{value:void 0,done:!0}}return l.prototype=y.constructor=h,h.constructor=l,h[a]=l.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,a in t||(t[a]="GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o){var i=new w(c(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(y),y[a]="Generator",y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),s},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}))),f=s.mark(p);function l(t){return"[object Object]"===Object.prototype.toString.call(t)}function h(t){return"function"==typeof t}function p(t){var e,r,n,o,i,a,c,u,h,p,d,v,y,g,w=arguments;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if((e=w.length>1&&void 0!==w[1]?w[1]:{}).reverse){s.next=30;break}if(null==t.length){s.next=14;break}r=0;case 4:if(!(r<t.length)){s.next=12;break}if(n={value:t[r],index:r},e.exclude&&e.exclude(n)){s.next=9;break}return s.next=9,n;case 9:r++,s.next=4;break;case 12:s.next=28;break;case 14:if(!l(t)){s.next=27;break}o=0,i=Object.keys(t);case 16:if(!(o<i.length)){s.next=25;break}if(a=i[o],c={value:t[a],key:a},e.exclude&&e.exclude(c)){s.next=22;break}return s.next=22,c;case 22:o++,s.next=16;break;case 25:s.next=28;break;case 27:throw"Unsupported type";case 28:s.next=58;break;case 30:if(null==t.length){s.next=42;break}u=t.length-1;case 32:if(!(u>=0)){s.next=40;break}if(h={value:t[u],index:u},e.exclude&&e.exclude(h)){s.next=37;break}return s.next=37,h;case 37:u--,s.next=32;break;case 40:s.next=58;break;case 42:if(!l(t)){s.next=57;break}(p=Object.keys(t)).reverse(),d=0,v=p;case 46:if(!(d<v.length)){s.next=55;break}if(y=v[d],g={value:t[y],key:y},e.exclude&&e.exclude(g)){s.next=52;break}return s.next=52,g;case 52:d++,s.next=46;break;case 55:s.next=58;break;case 57:throw"Unsupported type";case 58:case"end":return s.stop()}}),f)}var d=a.mark(v);function v(t){var e,r;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=a.keys(t);case 1:if((n.t1=n.t0()).done){n.next=9;break}if(e=n.t1.value,"$"===(r=e.substr(0,1))||"_"===r){n.next=7;break}return n.next=7,{key:e,value:t[e]};case 7:n.next=1;break;case 9:case"end":return n.stop()}}),d)}var y={data:function(){return{windowSize:{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight}}},methods:{updateWindowSize:function(){Object.assign(this.windowSize,{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight})}},created:function(){var t=this;this._windowSize_onresize=function(){t.updateWindowSize(),t.$emit("window-resize")},function(t,e,r){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];t.addEventListener?t.addEventListener.apply(t,[e,r].concat(o)):t.attachEvent&&t.attachEvent.apply(t,["on".concat(e),r].concat(o))}(window,"resize",this._windowSize_onresize)},beforeDestroy:function(){!function(t,e,r){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];t.removeEventListener?t.removeEventListener.apply(t,[e,r].concat(o)):t.detachEvent&&t.detachEvent.apply(t,["on".concat(e),r].concat(o))}(window,"resize",this._windowSize_onresize)}};var g={methods:{_getNonPropHooksByName:function(t){if(this._hooks)return this._hooks[t]},addHook:function(t,e){this._getNonPropHooksByName(t)||(this._hooks||(this._hooks={}),this._hooks[t]||(this._hooks[t]=[])),this._hooks[t].push(e)},removeHook:function(t,e){var r=this._getNonPropHooksByName(t);r&&function(t,e){for(var r,n=0;(r=t.indexOf(e))>-1;)t.splice(r,1),n++}(r,e)},hasHook:function(t){return this._getNonPropHooksByName(t)||this[t]},executeHook:function(t,e){var r=this._getNonPropHooksByName(t).slice();if(r)return this[t]&&h(this[t])&&r.push((function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return this[t].apply(this,n)})),function(t){var e=function(){},r=!0,n=!1,o=void 0;try{for(var i,a=p(t,{reverse:!0})[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){e=c(i.value.value,e)}}catch(t){n=!0,o=t}finally{try{r||null==a.return||a.return()}finally{if(n)throw o}}return e;function c(t,e){return function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return t.apply(void 0,[e].concat(n))}}}(r).apply(void 0,o(e))}}};t.doWatch=function(t,e){var r,n;return function o(){var i=e.call(t,r);n=t.$watch(i,(function(t){n(),r=t,o()}))}(),function(){return n&&n()}},t.hookHelper=g,t.isPropTrue=function(t){return""===t||t},t.iterateObjectWithoutDollarDash=v,t.registerPreventURLChange=function(t,e,r){var n=!1,o="It looks like you have been editing something.\nIf you leave before saving, your changes will be lost.";e.beforeEach((function(e,i,a){n?window.confirm(r||o)?(t.allowURLChange(),a()):a(!1):a()}));var i=function(t){var e=r||o;return t.returnValue=e,e};t.preventURLChange=t.prototype.$preventURLChange=function(t){null!=t&&(r=t),n||(n=!0,window.addEventListener("beforeunload",i))},t.allowURLChange=t.prototype.$allowURLChange=function(){n=!1,window.removeEventListener("beforeunload",i)}},t.updatablePropsEvenUnbound=function(t){t=h(t)?t():Object.assign({},t);var e={},r=function(r){var n=t[r];n.$localName||(n.$localName="localProps_".concat(r)),n.$localSetter||(n.$localSetter=function(t){return t});var o={};e[r]=o,Object.keys(t[r]).forEach((function(t){"$"!==t[0]&&(o[t]=n[t])}))};for(var n in t)r(n);for(var o={props:e,computed:{},watch:{},data:function(){for(var e={localValueOfUpdatableProps:{}},r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];e.localValueOfUpdatableProps[o]=this[o]}return e}},i=function(){var e=c[a],r=t[e];o.watch[e]=function(t){this.localValueOfUpdatableProps[e]=r.$localSetter(t,this)};var n=r.$localName;o.computed[n]={get:function(){return this.localValueOfUpdatableProps[e]},set:function(t){"value"===e?this.$emit("input",t):this.$emit("update:".concat(e),t),this.localValueOfUpdatableProps[e]=r.$localSetter(t,this)}}},a=0,c=Object.keys(t);a<c.length;a++)i();return o},t.watchAsync=function(t,e,r,n){var o=[],i=-1;return u(),a;function a(){o.forEach((function(t){return t()})),o=[]}function c(e,r){var n,i=!0,a=t.$watch((function(){return e.call(t,c)}),(function(t){n=t,i?i=!1:u()}),{immediate:!0,deep:r&&r.deep});return o.push(a),n}function u(){a();var o=e.call(t,c),u=++i;void 0;var s,f=function(e){u===i&&(0===u?n&&n.immediate&&r.call(t,e,void 0):r.call(t,e,void 0))};s=o,"[object Promise]"===Object.prototype.toString.call(s)?o.then(f):f(o)}},t.windowSize=y,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "vue-functions", | ||
"version": "2.0.0", | ||
"version": "2.0.1-beta", | ||
"description": "", | ||
@@ -12,4 +12,5 @@ "main": "dist/vue-functions.cjs.js", | ||
"build": "node scripts/build.js", | ||
"dev": "node scripts/build.js --watch", | ||
"build-test": "rollup -c" | ||
"dev": "rollup -w -c scripts/config.js --environment TARGET:umd", | ||
"build:esm": "rollup -c scripts/config.js --environment TARGET:esm", | ||
"dev:esm": "rollup -w -c scripts/config.js --environment TARGET:esm" | ||
}, | ||
@@ -26,8 +27,9 @@ "author": "phphe <phphe@outlook.com> (https://github.com/phphe)", | ||
"devDependencies": { | ||
"rollup-helper": "^2.0.1" | ||
"rollup-helper": "^2.0.11" | ||
}, | ||
"dependencies": { | ||
"helper-js": "^1.4.15" | ||
"@babel/runtime": "^7.7.7", | ||
"helper-js": "^1.4.21-beta" | ||
}, | ||
"license": "MIT" | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2515
109695
2
7
2
1
+ Added@babel/runtime@^7.7.7
Updatedhelper-js@^1.4.21-beta