Comparing version 0.4.2 to 0.4.4
@@ -21,10 +21,4 @@ "use strict"; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Menhera = function Menhera(parms) { | ||
_classCallCheck(this, Menhera); | ||
(0, _menhera.core)({ _: this, parms: parms }); | ||
}; | ||
exports.default = Menhera; | ||
exports.default = function (parms) { | ||
return (0, _menhera.core)({ _: {}, parms: parms }); | ||
}; |
@@ -8,4 +8,2 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
var _plugins = require("./plugins"); | ||
@@ -26,9 +24,3 @@ | ||
_.hooks._mount = [_plugins._mount]; | ||
_.$use = function (parms) { | ||
Object.keys(parms).forEach(function (_key) { | ||
(0, _utils.bindHook)({ _: _, _key: _key, cp: parms }); | ||
}); | ||
}; | ||
_.$use = (0, _plugins.$use)({ _: _ }); | ||
_.$use({ | ||
@@ -42,5 +34,4 @@ _hooks: function _hooks() { | ||
}); | ||
_.$use(parms); | ||
return _; | ||
}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports._data = exports._methods = exports._command = exports._config = exports._mount = exports._hooks = undefined; | ||
exports._data = exports._methods = exports._command = exports._config = exports._mount = exports._hooks = exports.$use = undefined; | ||
@@ -15,7 +15,16 @@ 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 _hooks = exports._hooks = function _hooks(_ref) { | ||
var _ = _ref._, | ||
_key = _ref._key, | ||
_val = _ref._val, | ||
cp = _ref.cp; | ||
var $use = exports.$use = function $use(_ref) { | ||
var _ = _ref._; | ||
return function (parms) { | ||
Object.keys(parms).forEach(function (_key) { | ||
(0, _utils.bindHook)({ _: _, _key: _key, cp: parms }); | ||
}); | ||
}; | ||
}; | ||
var _hooks = exports._hooks = function _hooks(_ref2) { | ||
var _ = _ref2._, | ||
_key = _ref2._key, | ||
_val = _ref2._val, | ||
cp = _ref2.cp; | ||
var _iteratorNormalCompletion = true; | ||
@@ -26,9 +35,9 @@ var _didIteratorError = false; | ||
try { | ||
for (var _iterator = Object.entries(_val())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _ref2 = _step.value; | ||
for (var _iterator = Object.entries(_val.bind(cp)())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _ref3 = _step.value; | ||
var _ref3 = _slicedToArray(_ref2, 2); | ||
var _ref4 = _slicedToArray(_ref3, 2); | ||
var key = _ref3[0]; | ||
var val = _ref3[1]; | ||
var key = _ref4[0]; | ||
var val = _ref4[1]; | ||
@@ -58,7 +67,7 @@ if (val) { | ||
var _mount = exports._mount = function _mount(_ref4) { | ||
var _ = _ref4._, | ||
_key = _ref4._key, | ||
_val = _ref4._val, | ||
cp = _ref4.cp; | ||
var _mount = exports._mount = function _mount(_ref5) { | ||
var _ = _ref5._, | ||
_key = _ref5._key, | ||
_val = _ref5._val, | ||
cp = _ref5.cp; | ||
var _$config$lifeCycle = _.config.lifeCycle, | ||
@@ -72,11 +81,11 @@ lifeCycle = _$config$lifeCycle === undefined ? [] : _$config$lifeCycle; | ||
for (var _iterator2 = Object.entries(_val)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var _ref5 = _step2.value; | ||
var _ref6 = _step2.value; | ||
var _ref6 = _slicedToArray(_ref5, 2); | ||
var _ref7 = _slicedToArray(_ref6, 2); | ||
var key = _ref6[0]; | ||
var components = _ref6[1]; | ||
var key = _ref7[0]; | ||
var components = _ref7[1]; | ||
components.forEach(function () { | ||
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(component) { | ||
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(component) { | ||
var cp, name; | ||
@@ -114,3 +123,3 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
return function (_x) { | ||
return _ref7.apply(this, arguments); | ||
return _ref8.apply(this, arguments); | ||
}; | ||
@@ -135,11 +144,3 @@ }()); | ||
var _config = exports._config = function _config(_ref8) { | ||
var _ = _ref8._, | ||
_key = _ref8._key, | ||
_val = _ref8._val, | ||
cp = _ref8.cp; | ||
_.config = (0, _utils.ConfigMerger)(_.config, _val); | ||
}; | ||
var _command = exports._command = function _command(_ref9) { | ||
var _config = exports._config = function _config(_ref9) { | ||
var _ = _ref9._, | ||
@@ -149,2 +150,10 @@ _key = _ref9._key, | ||
cp = _ref9.cp; | ||
_.config = (0, _utils.ConfigMerger)(_.config, _val); | ||
}; | ||
var _command = exports._command = function _command(_ref10) { | ||
var _ = _ref10._, | ||
_key = _ref10._key, | ||
_val = _ref10._val, | ||
cp = _ref10.cp; | ||
var run = _val.run; | ||
@@ -157,3 +166,3 @@ | ||
Object.values(_.components).forEach(function () { | ||
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(cp) { | ||
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(cp) { | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
@@ -187,3 +196,3 @@ while (1) { | ||
return function (_x2) { | ||
return _ref10.apply(this, arguments); | ||
return _ref11.apply(this, arguments); | ||
}; | ||
@@ -194,7 +203,7 @@ }()); | ||
var _methods = exports._methods = function _methods(_ref11) { | ||
var _ = _ref11._, | ||
_key = _ref11._key, | ||
_val = _ref11._val, | ||
cp = _ref11.cp; | ||
var _methods = exports._methods = function _methods(_ref12) { | ||
var _ = _ref12._, | ||
_key = _ref12._key, | ||
_val = _ref12._val, | ||
cp = _ref12.cp; | ||
var _iteratorNormalCompletion3 = true; | ||
@@ -206,8 +215,8 @@ var _didIteratorError3 = false; | ||
for (var _iterator3 = Object.entries(_val)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var _ref12 = _step3.value; | ||
var _ref13 = _step3.value; | ||
var _ref13 = _slicedToArray(_ref12, 2); | ||
var _ref14 = _slicedToArray(_ref13, 2); | ||
var key = _ref13[0]; | ||
var val = _ref13[1]; | ||
var key = _ref14[0]; | ||
var val = _ref14[1]; | ||
@@ -236,7 +245,7 @@ if (!cp[key]) { | ||
var _data = exports._data = function _data(_ref14) { | ||
var _ = _ref14._, | ||
_key = _ref14._key, | ||
_val = _ref14._val, | ||
cp = _ref14.cp; | ||
var _data = exports._data = function _data(_ref15) { | ||
var _ = _ref15._, | ||
_key = _ref15._key, | ||
_val = _ref15._val, | ||
cp = _ref15.cp; | ||
@@ -250,8 +259,8 @@ var props = _val.bind(cp)(); | ||
for (var _iterator4 = Object.entries(props)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
var _ref15 = _step4.value; | ||
var _ref16 = _step4.value; | ||
var _ref16 = _slicedToArray(_ref15, 2); | ||
var _ref17 = _slicedToArray(_ref16, 2); | ||
var key = _ref16[0]; | ||
var val = _ref16[1]; | ||
var key = _ref17[0]; | ||
var val = _ref17[1]; | ||
@@ -258,0 +267,0 @@ if (!cp[key]) { |
{ | ||
"name": "menhera", | ||
"version": "0.4.2", | ||
"version": "0.4.4", | ||
"main": "dist", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -11,3 +11,3 @@ # Menhera | ||
import { EventEmitter } from "events"; | ||
import Menhera, { Optional } from "menhera"; | ||
import Menhera, { _methods, _data } from "menhera"; | ||
import minimist from "minimist"; | ||
@@ -23,3 +23,3 @@ | ||
}, | ||
start() { | ||
awake() { | ||
let { _, ...flags } = minimist(process.argv.slice(2)); | ||
@@ -31,15 +31,13 @@ let [command = "*", ...inputs] = _; | ||
}, | ||
_hooks() { | ||
return { | ||
onCli({ _key, _val, cp }) { | ||
for (let [key, val] of Object.entries(_val)) { | ||
const { exec } = val; | ||
this.structs[key] = val; | ||
if (exec) { | ||
this.Event.on(key, exec.bind(cp)); | ||
} | ||
_hooks: () => ({ | ||
onCli({ _key, _val, cp }) { | ||
for (let [key, val] of Object.entries(_val)) { | ||
const { exec } = val; | ||
this.structs[key] = val; | ||
if (exec) { | ||
this.Event.on(key, exec.bind(cp)); | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
}) | ||
}; | ||
@@ -64,7 +62,8 @@ | ||
const _ = new Menhera({ | ||
_hooks: () => ({ | ||
_methods, | ||
_data | ||
}), | ||
_mount: { | ||
_: [...Optional, CLI, cliTest] | ||
}, | ||
_command: { | ||
run: false | ||
cli: [CLI, cliTest] | ||
} | ||
@@ -71,0 +70,0 @@ }).$use({ |
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
0
12859
72