Comparing version
468
dist/core.js
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports._data = exports._mount = exports._hooks = exports.$get = exports.$set = exports.$use = exports.$core = undefined; | ||
exports._mount = exports._hooks = exports.$get = exports.$set = exports.$use = exports.$core = undefined; | ||
@@ -23,4 +23,20 @@ var _regenerator = require("babel-runtime/regenerator"); | ||
var _lodash = require("lodash"); | ||
var _scan = require("./utils/scan"); | ||
var scan = _interopRequireWildcard(_scan); | ||
var _hooks2 = require("./utils/hooks"); | ||
var initHooks = _interopRequireWildcard(_hooks2); | ||
var _lodash = require("lodash.get"); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _lodash3 = require("lodash.set"); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -31,7 +47,9 @@ | ||
_.hooks._hooks = { _: [_hooks] }; | ||
_.ObjectHooks = ObjectHooks(_); | ||
_.ArrayHooks = ArrayHooks(_); | ||
_.AnyHooks = AnyHooks(_); | ||
_.FunctionHooks = FunctionHooks(_); | ||
_.VariableHooks = VariableHooks(_); | ||
(0, _utils.$)(initHooks, function (key, val) { | ||
_.hooks[key] = val(_); | ||
}); | ||
_.scan = {}; | ||
(0, _utils.$)(scan, function (key, val) { | ||
_.scan[key] = val(_); | ||
}); | ||
_.$use = function (_object) { | ||
@@ -51,279 +69,11 @@ return $use(_, _object); | ||
var AnyHooks = function AnyHooks(_2) { | ||
return { | ||
any: function any(_ref) { | ||
var object = _ref.object, | ||
parentDepth = _ref.parentDepth, | ||
depth = _ref.depth, | ||
_key = _ref._key, | ||
_val = _ref._val, | ||
_object = _ref._object; | ||
var key = "" + depth; | ||
var hooks = (0, _lodash.get)(_2.hooks, key, []); | ||
hooks.length > 0 && hooks.forEach(function (h) { | ||
return h({ _: _2, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
}, | ||
_: function _(_ref2) { | ||
var object = _ref2.object, | ||
depth = _ref2.depth, | ||
_key = _ref2._key, | ||
_val = _ref2._val, | ||
_object = _ref2._object; | ||
var __ = depth + "._"; | ||
var _Hooks = (0, _lodash.get)(_2.hooks, __, []); | ||
_Hooks.length > 0 && _Hooks.forEach(function (h) { | ||
return h({ _: _2, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
} | ||
}; | ||
}; | ||
var ObjectHooks = function ObjectHooks(_) { | ||
return { | ||
O: function O(_ref3) { | ||
var object = _ref3.object, | ||
parentDepth = _ref3.parentDepth, | ||
depth = _ref3.depth, | ||
_key = _ref3._key, | ||
_val = _ref3._val, | ||
_object = _ref3._object; | ||
var key = depth + ".O"; | ||
var hooks = (0, _lodash.get)(_.hooks, key, []); | ||
hooks.length > 0 && hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
}, | ||
$: function $(_ref4) { | ||
var object = _ref4.object, | ||
depth = _ref4.depth, | ||
_key = _ref4._key, | ||
_val = _ref4._val, | ||
_object = _ref4._object; | ||
var key = depth + ".$"; | ||
var hooks = (0, _lodash.get)(_.hooks, key, []); | ||
hooks.length > 0 && (0, _utils.$)(_val, function (key, val) { | ||
hooks.forEach(function (h) { | ||
return h({ _: _, _key: key, _val: val, cp: _object }); | ||
}); | ||
}); | ||
}, | ||
O$: function O$(_ref5) { | ||
var object = _ref5.object, | ||
depth = _ref5.depth, | ||
_key = _ref5._key, | ||
_val = _ref5._val, | ||
_object = _ref5._object; | ||
var key = depth + ".O$"; | ||
var hooks = (0, _lodash.get)(_.hooks, key, []); | ||
hooks.length > 0 && (0, _utils.$)(_val, function (key, val) { | ||
hooks.forEach(function (h) { | ||
return h({ _: _, _key: key, _val: val, cp: _object }); | ||
}); | ||
}); | ||
}, | ||
$O: function $O(_ref6) { | ||
var object = _ref6.object, | ||
parentDepth = _ref6.parentDepth, | ||
depth = _ref6.depth, | ||
_key = _ref6._key, | ||
_val = _ref6._val, | ||
_object = _ref6._object; | ||
var key = parentDepth + ".$O"; | ||
var $hooks = (0, _lodash.get)(_.hooks, key, []); | ||
$hooks.length > 0 && $hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
} | ||
}; | ||
}; | ||
var ArrayHooks = function ArrayHooks(_) { | ||
return { | ||
A: function A(_ref7) { | ||
var object = _ref7.object, | ||
parentDepth = _ref7.parentDepth, | ||
depth = _ref7.depth, | ||
_key = _ref7._key, | ||
_val = _ref7._val, | ||
_object = _ref7._object; | ||
var key = depth + ".A"; | ||
var hooks = (0, _lodash.get)(_.hooks, key, []); | ||
hooks.length > 0 && hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
}, | ||
A$: function A$(_ref8) { | ||
var object = _ref8.object, | ||
parentDepth = _ref8.parentDepth, | ||
depth = _ref8.depth, | ||
_key = _ref8._key, | ||
_val = _ref8._val, | ||
_object = _ref8._object; | ||
var key = depth + ".A$"; | ||
var hooks = (0, _lodash.get)(_.hooks, key, []); | ||
hooks.length > 0 && _val.forEach(function (val, i) { | ||
hooks.forEach(function (h) { | ||
return h({ _: _, i: i, _val: val, cp: _object }); | ||
}); | ||
}); | ||
}, | ||
$A: function $A(_ref9) { | ||
var object = _ref9.object, | ||
parentDepth = _ref9.parentDepth, | ||
depth = _ref9.depth, | ||
_key = _ref9._key, | ||
_val = _ref9._val, | ||
_object = _ref9._object; | ||
var key = parentDepth + ".$A"; | ||
var $hooks = (0, _lodash.get)(_.hooks, key, []); | ||
$hooks.length > 0 && $hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
} | ||
}; | ||
}; | ||
var FunctionHooks = function FunctionHooks(_) { | ||
return { | ||
F: function F(_ref10) { | ||
var object = _ref10.object, | ||
parentDepth = _ref10.parentDepth, | ||
depth = _ref10.depth, | ||
_key = _ref10._key, | ||
_val = _ref10._val, | ||
_object = _ref10._object; | ||
var key = depth + ".F"; | ||
var hooks = (0, _lodash.get)(_.hooks, key, []); | ||
hooks.length > 0 && hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
}, | ||
$F: function $F(_ref11) { | ||
var object = _ref11.object, | ||
parentDepth = _ref11.parentDepth, | ||
depth = _ref11.depth, | ||
_key = _ref11._key, | ||
_val = _ref11._val, | ||
_object = _ref11._object; | ||
var key = parentDepth + ".$F"; | ||
var $hooks = (0, _lodash.get)(_.hooks, key, []); | ||
$hooks.length > 0 && $hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
} | ||
}; | ||
}; | ||
var VariableHooks = function VariableHooks(_) { | ||
return { | ||
V: function V(_ref12) { | ||
var object = _ref12.object, | ||
parentDepth = _ref12.parentDepth, | ||
depth = _ref12.depth, | ||
_key = _ref12._key, | ||
_val = _ref12._val, | ||
_object = _ref12._object; | ||
var key = depth + ".V"; | ||
var hooks = (0, _lodash.get)(_.hooks, key, []); | ||
hooks.length > 0 && hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
}, | ||
$V: function $V(_ref13) { | ||
var object = _ref13.object, | ||
parentDepth = _ref13.parentDepth, | ||
depth = _ref13.depth, | ||
_key = _ref13._key, | ||
_val = _ref13._val, | ||
_object = _ref13._object; | ||
var key = parentDepth + ".$V"; | ||
var $hooks = (0, _lodash.get)(_.hooks, key, []); | ||
$hooks.length > 0 && $hooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
} | ||
}; | ||
}; | ||
var $use = exports.$use = function $use(_, _object) { | ||
var onFunction = function onFunction(_ref14) { | ||
var object = _ref14.object, | ||
depth = _ref14.depth, | ||
parentDepth = _ref14.parentDepth, | ||
_key = _ref14._key, | ||
_val = _ref14._val; | ||
(0, _utils.$)(_.FunctionHooks, function (key, hook) { | ||
hook({ object: object, parentDepth: parentDepth, depth: depth, _key: _key, _val: _val, _object: _object }); | ||
}); | ||
}; | ||
var onArray = function onArray(_ref15) { | ||
var object = _ref15.object, | ||
depth = _ref15.depth, | ||
parentDepth = _ref15.parentDepth, | ||
_key = _ref15._key, | ||
_val = _ref15._val; | ||
(0, _utils.$)(_.ArrayHooks, function (key, hook) { | ||
hook({ object: object, parentDepth: parentDepth, depth: depth, _key: _key, _val: _val, _object: _object }); | ||
}); | ||
}; | ||
var onAny = function onAny(_ref16) { | ||
var object = _ref16.object, | ||
depth = _ref16.depth, | ||
parentDepth = _ref16.parentDepth, | ||
_key = _ref16._key, | ||
_val = _ref16._val; | ||
(0, _utils.$)(_.AnyHooks, function (key, hook) { | ||
hook({ object: object, parentDepth: parentDepth, depth: depth, _key: _key, _val: _val, _object: _object }); | ||
}); | ||
}; | ||
var onVariable = function onVariable(_ref17) { | ||
var object = _ref17.object, | ||
depth = _ref17.depth, | ||
parentDepth = _ref17.parentDepth, | ||
_key = _ref17._key, | ||
_val = _ref17._val; | ||
(0, _utils.$)(_.VariableHooks, function (key, hook) { | ||
hook({ object: object, parentDepth: parentDepth, depth: depth, _key: _key, _val: _val, _object: _object }); | ||
}); | ||
}; | ||
var onObject = function onObject(_ref18) { | ||
var object = _ref18.object, | ||
depth = _ref18.depth, | ||
parentDepth = _ref18.parentDepth, | ||
_key = _ref18._key, | ||
_val = _ref18._val; | ||
(0, _utils.$)(_.ObjectHooks, function (key, hook) { | ||
hook({ object: object, parentDepth: parentDepth, depth: depth, _key: _key, _val: _val, _object: _object }); | ||
}); | ||
(0, _utils.scanObject)({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onVariable: onVariable, | ||
onFunction: onFunction, | ||
onArray: onArray, | ||
onAny: onAny | ||
}); | ||
}; | ||
if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") { | ||
onObject({ object: _object, depth: "" }); | ||
_.scan.$use(_object); | ||
} | ||
if (Array.isArray(_object)) { | ||
_object.forEach(function (o) { | ||
_.scan.$use(o); | ||
}); | ||
} | ||
return _; | ||
@@ -333,131 +83,20 @@ }; | ||
var $set = exports.$set = function $set(_, _object) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref19) { | ||
var object = _ref19.object, | ||
depth = _ref19.depth, | ||
_key = _ref19._key, | ||
_val = _ref19._val; | ||
(0, _lodash.set)(_, depth, _val); | ||
(0, _lodash.set)(cache, depth, _val); | ||
}; | ||
var onFunction = function onFunction(_ref20) { | ||
var object = _ref20.object, | ||
depth = _ref20.depth, | ||
_key = _ref20._key, | ||
_val = _ref20._val; | ||
var tar = (0, _lodash.get)(_, depth); | ||
var result = _val({ tar: tar }); | ||
(0, _lodash.set)(_, depth, result); | ||
(0, _lodash.set)(cache, depth, result); | ||
}; | ||
var onObject = function onObject(_ref21) { | ||
var object = _ref21.object, | ||
depth = _ref21.depth, | ||
_key = _ref21._key, | ||
_val = _ref21._val; | ||
(0, _utils.scanObject)({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onVariable: onVariable, | ||
onFunction: onFunction, | ||
onArray: onVariable | ||
}); | ||
}; | ||
if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") { | ||
onObject({ object: _object, depth: "" }); | ||
return _.scan.$set(_object); | ||
} | ||
return cache; | ||
}; | ||
var $get = exports.$get = function $get(_, _object) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref22) { | ||
var object = _ref22.object, | ||
depth = _ref22.depth, | ||
_key = _ref22._key, | ||
_val = _ref22._val; | ||
var result = (0, _lodash.get)(_, depth); | ||
result && (0, _lodash.set)(cache, depth, result); | ||
!result && (0, _lodash.set)(cache, depth, _val); | ||
}; | ||
var onFunction = function onFunction(_ref23) { | ||
var object = _ref23.object, | ||
depth = _ref23.depth, | ||
_key = _ref23._key, | ||
_val = _ref23._val; | ||
var tar = (0, _lodash.get)(_, depth); | ||
var result = _val({ tar: tar }); | ||
result && (0, _lodash.set)(cache, depth, result); | ||
!result && (0, _lodash.set)(cache, depth, _val); | ||
}; | ||
var onObject = function onObject(_ref24) { | ||
var object = _ref24.object, | ||
depth = _ref24.depth, | ||
_key = _ref24._key, | ||
_val = _ref24._val; | ||
(0, _utils.scanObject)({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onFunction: onFunction, | ||
onVariable: onVariable, | ||
onArray: onVariable | ||
}); | ||
}; | ||
if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") { | ||
onObject({ object: _object, depth: "" }); | ||
return _.scan.$get(_object); | ||
} | ||
return cache; | ||
}; | ||
var _hooks = exports._hooks = function _hooks(_ref25) { | ||
var _ = _ref25._, | ||
_key = _ref25._key, | ||
_val = _ref25._val, | ||
cp = _ref25.cp; | ||
var _hooks = exports._hooks = function _hooks(_ref) { | ||
var _ = _ref._, | ||
_val = _ref._val, | ||
cp = _ref.cp; | ||
var onFunction = function onFunction(_ref26) { | ||
var depth = _ref26.depth, | ||
_val = _ref26._val; | ||
var target = (0, _lodash.get)(_.hooks, depth, []); | ||
if (!target.includes(_val.bind(cp))) { | ||
target.push(_val.bind(cp)); | ||
(0, _lodash.set)(_.hooks, depth, target); | ||
} | ||
}; | ||
var onVariable = function onVariable(_ref27) { | ||
var depth = _ref27.depth, | ||
_val = _ref27._val; | ||
if (Array.isArray(_val)) { | ||
_val.forEach(function (val) { | ||
if (typeof val === "function") { | ||
onFunction({ depth: depth, _val: val }); | ||
} | ||
}); | ||
} | ||
}; | ||
var onObject = function onObject(_ref28) { | ||
var object = _ref28.object, | ||
depth = _ref28.depth, | ||
_key = _ref28._key, | ||
_val = _ref28._val; | ||
(0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onFunction: onFunction, onVariable: onVariable }); | ||
}; | ||
if ((typeof _val === "undefined" ? "undefined" : (0, _typeof3.default)(_val)) === "object") { | ||
onObject({ object: _val, depth: "" }); | ||
_.scan._hook(_val, cp); | ||
} | ||
@@ -467,12 +106,12 @@ }; | ||
var _mount = exports._mount = { | ||
$: function $(_ref29) { | ||
$: function $(_ref2) { | ||
var _this = this; | ||
var _ = _ref29._, | ||
_val = _ref29._val, | ||
cp = _ref29.cp; | ||
var _ = _ref2._, | ||
_val = _ref2._val, | ||
cp = _ref2.cp; | ||
var cps = Array.isArray(_val) ? _val : [_val]; | ||
cps.forEach(function () { | ||
var _ref30 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(component) { | ||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(component) { | ||
var cp, name; | ||
@@ -507,25 +146,6 @@ return _regenerator2.default.wrap(function _callee$(_context) { | ||
return function (_x) { | ||
return _ref30.apply(this, arguments); | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}()); | ||
} | ||
}; | ||
var _data = exports._data = { | ||
_F: function _F(_ref31) { | ||
var _val = _ref31._val, | ||
cp = _ref31.cp; | ||
var datas = _val.bind(cp)(); | ||
(0, _utils.$)(datas, function (key, val) { | ||
cp[key] = val; | ||
}); | ||
}, | ||
$: function $(_ref32) { | ||
var _key = _ref32._key, | ||
_val = _ref32._val, | ||
cp = _ref32.cp; | ||
cp[_key] = _val; | ||
} | ||
}; |
@@ -76,6 +76,14 @@ "use strict"; | ||
var newDepth = depth ? depth + ("." + _key) : _key; | ||
onAny && onAny({ object: object, depth: newDepth, parentDepth: parentDepth, _key: _key, _val: _val }); | ||
onAny && onAny({ | ||
hook: "onAny", | ||
object: object, | ||
depth: newDepth, | ||
parentDepth: parentDepth, | ||
_key: _key, | ||
_val: _val | ||
}); | ||
if (_val) { | ||
if (typeof _val === "function") { | ||
onFunction && onFunction({ | ||
hook: "onFunction", | ||
object: object, | ||
@@ -90,2 +98,3 @@ depth: newDepth, | ||
onArray && onArray({ | ||
hook: "onArray", | ||
object: object, | ||
@@ -99,2 +108,3 @@ depth: newDepth, | ||
onObject && onObject({ | ||
hook: "onObject", | ||
object: object[_key], | ||
@@ -109,2 +119,3 @@ depth: newDepth, | ||
onVariable && onVariable({ | ||
hook: "onVariable", | ||
object: object, | ||
@@ -119,2 +130,3 @@ depth: newDepth, | ||
onVariable && onVariable({ | ||
hook: "onVariable", | ||
object: object, | ||
@@ -121,0 +133,0 @@ depth: newDepth, |
{ | ||
"name": "menhera", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"main": "dist", | ||
@@ -19,8 +19,8 @@ "files": [ | ||
"babel-preset-stage-3": "^6.24.1", | ||
"menhera": "^0.6.1-rc6" | ||
"menhera": "^0.6.2" | ||
}, | ||
"dependencies": { | ||
"@types/lodash": "^4.14.104", | ||
"lodash": "^4.17.5" | ||
"lodash.get": "^4.4.2", | ||
"lodash.set": "^4.3.2" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # Menhera |
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
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
23803
-31.61%7
-22.22%616
-34.68%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed