Comparing version 0.1.5 to 0.1.6
@@ -7,4 +7,2 @@ "use strict"; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -35,3 +33,3 @@ | ||
var initConfig = { | ||
components: [_plugins.Observer, _plugins.Event], | ||
components: [], | ||
lifeCycle: ["awake", "start"] | ||
@@ -66,3 +64,3 @@ }; | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(component) { | ||
var comp, name; | ||
var cp, name; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -72,8 +70,8 @@ while (1) { | ||
case 0: | ||
comp = typeof component === "function" ? component(_) : component; | ||
name = comp.name; | ||
cp = typeof component === "function" ? component(_) : component; | ||
name = cp.name; | ||
_.components[name] = comp; | ||
_.components[name] = cp; | ||
_context.t0 = comp[awake]; | ||
_context.t0 = cp[awake]; | ||
@@ -86,41 +84,14 @@ if (!_context.t0) { | ||
_context.next = 7; | ||
return comp[awake](); | ||
return cp[awake](); | ||
case 7: | ||
_context.next = 9; | ||
return Object.keys(comp).forEach(function (prop) { | ||
if (typeof _[prop] === "function") { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = Object.entries(comp[prop])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _ref2 = _step.value; | ||
var _ref3 = _slicedToArray(_ref2, 2); | ||
var _name = _ref3[0]; | ||
var value = _ref3[1]; | ||
if (typeof value === "function") { | ||
_[prop]({ name: _name, event: value }); | ||
} else { | ||
_[prop]({ name: _name, props: value }); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
return Object.keys(cp).forEach(function (prop) { | ||
var hook = _[prop]; | ||
if (Array.isArray(hook)) { | ||
hook.forEach(function (h) { | ||
(0, _utils.bindHook)({ hook: h, prop: prop, cp: cp }); | ||
}); | ||
} else { | ||
(0, _utils.bindHook)({ hook: hook, prop: prop, cp: cp }); | ||
} | ||
@@ -132,3 +103,3 @@ }); | ||
lifeCycles.forEach(function (key) { | ||
comp[key] && comp[key](); | ||
cp[key] && cp[key](); | ||
}); | ||
@@ -135,0 +106,0 @@ |
@@ -7,2 +7,4 @@ "use strict"; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -27,2 +29,51 @@ | ||
return cache; | ||
}; | ||
var bindHook = exports.bindHook = function bindHook(_ref) { | ||
var hook = _ref.hook, | ||
cp = _ref.cp, | ||
prop = _ref.prop; | ||
var name = cp.name; | ||
if (typeof hook === "function") { | ||
if (_typeof(cp[prop]) === "object") { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = Object.entries(cp[prop])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _ref2 = _step.value; | ||
var _ref3 = _slicedToArray(_ref2, 2); | ||
var _name = _ref3[0]; | ||
var value = _ref3[1]; | ||
if (typeof value === "function") { | ||
hook({ name: _name, event: value, cp: cp }); | ||
} else { | ||
hook({ name: _name, props: value, cp: cp }); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
} else if (typeof cp[prop] === "function") { | ||
hook({ name: name, event: cp[prop], cp: cp }); | ||
} else { | ||
hook({ name: name, props: cp[prop], cp: cp }); | ||
} | ||
} | ||
}; |
{ | ||
"name": "menhera", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"main": "dist", | ||
@@ -5,0 +5,0 @@ "files": [ |
10712
223