Comparing version 0.8.5-rc2 to 0.9.0
1240
dist/index.js
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
@@ -11,3 +9,2 @@ | ||
var uuid = _interopDefault(require('uuid')); | ||
var events = require('events'); | ||
@@ -103,4 +100,3 @@ function _typeof(obj) { | ||
_: function _(_ref) { | ||
var _2 = _ref._, | ||
_val = _ref._val, | ||
var _val = _ref._val, | ||
cp = _ref.cp; | ||
@@ -113,7 +109,7 @@ var uuid$$1 = cp.uuid; | ||
_val = _ref2._val; | ||
var target = get(_2[HOOKS], depth); | ||
var target = get(core[HOOKS], depth); | ||
if (!target) { | ||
target = new Map([[uuid$$1, _val.bind(cp)]]); | ||
set$1(_2[HOOKS], depth, target); | ||
set$1(core[HOOKS], depth, target); | ||
} else { | ||
@@ -127,3 +123,3 @@ target.set(uuid$$1, _val.bind(cp)); | ||
_val = _ref3._val; | ||
var target = get(_2[HOOKS], depth); | ||
var target = get(core[HOOKS], depth); | ||
_val = new Set(_val.map(function (v) { | ||
@@ -135,3 +131,3 @@ return v.bind(cp); | ||
target = new Map([[uuid$$1, _val]]); | ||
set$1(_2[HOOKS], depth, target); | ||
set$1(core[HOOKS], depth, target); | ||
} else { | ||
@@ -165,4 +161,3 @@ target.set(uuid$$1, _val); | ||
_: function _(_ref5) { | ||
var _3 = _ref5._, | ||
_val = _ref5._val, | ||
var _val = _ref5._val, | ||
cp = _ref5.cp; | ||
@@ -175,3 +170,3 @@ var uuid$$1 = cp.uuid; | ||
_val = _ref6._val; | ||
var target = get(_3[HOOKS], depth); | ||
var target = get(core[HOOKS], depth); | ||
if (!target) return; | ||
@@ -203,4 +198,3 @@ target.delete(uuid$$1); | ||
$: function $$$1(_ref8) { | ||
var _ = _ref8._, | ||
_val = _ref8._val; | ||
var _val = _ref8._val; | ||
var cps = Array.isArray(_val) ? _val : [_val]; | ||
@@ -210,7 +204,7 @@ | ||
var cp = typeof component === 'function' ? component({ | ||
_: _ | ||
_: core | ||
}) : component; | ||
var name = cp.name; | ||
if (_[name]) { | ||
if (core[name]) { | ||
console.log("_mount: name \"".concat(name, "\" exists")); | ||
@@ -220,11 +214,5 @@ return; | ||
_[name] = cp; // const onFunction = ({depth, _val}) => { | ||
// set(_[name], depth, _val.bind(_[name])) | ||
// } | ||
// const onObject = ({object, depth}) => { | ||
// scanObject({object, depth, onObject, onFunction}) | ||
// } | ||
// onObject({object: _[name]}) | ||
core[name] = cp; | ||
_.$use(_[name]); | ||
core.$use(core[name]); | ||
}); | ||
@@ -235,4 +223,3 @@ } | ||
$: function $$$1(_ref9) { | ||
var _ = _ref9._, | ||
_val = _ref9._val, | ||
var _val = _ref9._val, | ||
cp = _ref9.cp; | ||
@@ -243,10 +230,9 @@ var cps = Array.isArray(_val) ? _val : [_val]; | ||
var cp = typeof component === 'function' ? component({ | ||
_: _ | ||
_: core | ||
}) : component; | ||
_.$use(cp); | ||
core.$use(cp); | ||
}); | ||
} | ||
}; | ||
var data = {}; | ||
@@ -257,366 +243,8 @@ var hooks = /*#__PURE__*/Object.freeze({ | ||
_mount: _mount, | ||
_run: _run, | ||
data: data | ||
_run: _run | ||
}); | ||
var compose = function compose(middleware) { | ||
return function (ctx, next) { | ||
var index = -1; | ||
return dispatch(0); | ||
function dispatch(i) { | ||
if (i <= index) return Promise.reject(new Error('next() called multiple times')); | ||
index = i; | ||
var fn = middleware[i]; | ||
if (i === middleware.length) fn = next; | ||
if (!fn) return Promise.resolve(); | ||
try { | ||
return Promise.resolve(fn(ctx, function () { | ||
return dispatch(i + 1); | ||
})); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
} | ||
}; | ||
}; | ||
var handleHooks = function handleHooks(_ref) { | ||
var object = _ref.object, | ||
depth = _ref.depth, | ||
key = _ref.key, | ||
_key = _ref._key, | ||
_ = _ref._, | ||
_val = _ref._val, | ||
_object = _ref._object; | ||
var hooks = get(_[HOOKS], key); | ||
hooks instanceof Map && hooks && $M(hooks, function (uuid$$1, h) { | ||
if (h instanceof Set) { | ||
var fns = compose(_toConsumableArray(h)); | ||
fns({ | ||
depth: depth, | ||
_: _, | ||
_key: _key, | ||
_val: _val, | ||
cp: _object | ||
}); | ||
return; | ||
} | ||
h({ | ||
depth: depth, | ||
_: _, | ||
_key: _key, | ||
_val: _val, | ||
cp: _object, | ||
parent: object | ||
}); | ||
}); | ||
}; | ||
var handleEachHooks = function handleEachHooks(_ref2) { | ||
var object = _ref2.object, | ||
depth = _ref2.depth, | ||
_ = _ref2._, | ||
key = _ref2.key, | ||
_key = _ref2._key, | ||
_val = _ref2._val, | ||
_object = _ref2._object; | ||
var hooks = get(_[HOOKS], key); | ||
hooks instanceof Map && hooks && $(_val, function (key, val) { | ||
$M(hooks, function (uuid$$1, h) { | ||
return h({ | ||
depth: depth, | ||
_: _, | ||
_key: key, | ||
_val: val, | ||
cp: _object, | ||
parent: object | ||
}); | ||
}); | ||
}); | ||
}; | ||
var ScanHooks = function ScanHooks(_2) { | ||
return { | ||
onAny: { | ||
any: function any(_ref3) { | ||
var object = _ref3.object, | ||
parentDepth = _ref3.parentDepth, | ||
depth = _ref3.depth, | ||
_key = _ref3._key, | ||
_val = _ref3._val, | ||
_object = _ref3._object; | ||
var key = "".concat(depth); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
_: function _(_ref4) { | ||
var object = _ref4.object, | ||
depth = _ref4.depth, | ||
_key = _ref4._key, | ||
_val = _ref4._val, | ||
_object = _ref4._object; | ||
var key = "".concat(depth, "._"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
}, | ||
onObject: { | ||
O: function O(_ref5) { | ||
var object = _ref5.object, | ||
parentDepth = _ref5.parentDepth, | ||
depth = _ref5.depth, | ||
_key = _ref5._key, | ||
_val = _ref5._val, | ||
_object = _ref5._object; | ||
var key = "".concat(depth, ".O"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$: function $$$1(_ref6) { | ||
var object = _ref6.object, | ||
depth = _ref6.depth, | ||
_key = _ref6._key, | ||
_val = _ref6._val, | ||
_object = _ref6._object; | ||
var key = "".concat(depth, ".$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
O$: function O$(_ref7) { | ||
var object = _ref7.object, | ||
depth = _ref7.depth, | ||
_key = _ref7._key, | ||
_val = _ref7._val, | ||
_object = _ref7._object; | ||
var key = "".concat(depth, ".O$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$O: function $O(_ref8) { | ||
var object = _ref8.object, | ||
parentDepth = _ref8.parentDepth, | ||
depth = _ref8.depth, | ||
_key = _ref8._key, | ||
_val = _ref8._val, | ||
_object = _ref8._object; | ||
var key = "".concat(parentDepth, ".$O"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
}, | ||
onArray: { | ||
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 = "".concat(depth, ".A"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
A$: function A$(_ref10) { | ||
var object = _ref10.object, | ||
parentDepth = _ref10.parentDepth, | ||
depth = _ref10.depth, | ||
_key = _ref10._key, | ||
_val = _ref10._val, | ||
_object = _ref10._object; | ||
var key = "".concat(depth, ".A$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$: function $$$1(_ref11) { | ||
var object = _ref11.object, | ||
depth = _ref11.depth, | ||
_key = _ref11._key, | ||
_val = _ref11._val, | ||
_object = _ref11._object; | ||
var key = "".concat(depth, ".$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$A: function $A(_ref12) { | ||
var object = _ref12.object, | ||
parentDepth = _ref12.parentDepth, | ||
depth = _ref12.depth, | ||
_key = _ref12._key, | ||
_val = _ref12._val, | ||
_object = _ref12._object; | ||
var key = "".concat(parentDepth, ".$A"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
}, | ||
onFunction: { | ||
F: function F(_ref13) { | ||
var object = _ref13.object, | ||
parentDepth = _ref13.parentDepth, | ||
depth = _ref13.depth, | ||
_key = _ref13._key, | ||
_val = _ref13._val, | ||
_object = _ref13._object; | ||
var key = "".concat(depth, ".F"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$F: function $F(_ref14) { | ||
var object = _ref14.object, | ||
parentDepth = _ref14.parentDepth, | ||
depth = _ref14.depth, | ||
_key = _ref14._key, | ||
_val = _ref14._val, | ||
_object = _ref14._object; | ||
var key = "".concat(parentDepth, ".$F"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
}, | ||
onVariable: { | ||
V: function V(_ref15) { | ||
var object = _ref15.object, | ||
parentDepth = _ref15.parentDepth, | ||
depth = _ref15.depth, | ||
_key = _ref15._key, | ||
_val = _ref15._val, | ||
_object = _ref15._object; | ||
var key = "".concat(depth, ".V"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$V: function $V(_ref16) { | ||
var object = _ref16.object, | ||
parentDepth = _ref16.parentDepth, | ||
depth = _ref16.depth, | ||
_key = _ref16._key, | ||
_val = _ref16._val, | ||
_object = _ref16._object; | ||
var key = "".concat(parentDepth, ".$V"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_: _2, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
} | ||
}; | ||
}; | ||
var hooks$1 = function hooks(ctx) { | ||
var keys = ctx._keys; | ||
keys = keys.filter(function (key) { | ||
return key.startsWith('$'); | ||
}); | ||
if (keys.length > 0) { | ||
ctx._hooks = {}; | ||
keys.forEach(function (key) { | ||
var newKey = key.replace(/\$/, ''); | ||
ctx._hooks[newKey] = ctx._object[key]; | ||
}); | ||
} | ||
}; | ||
var compiles = /*#__PURE__*/Object.freeze({ | ||
hooks: hooks$1 | ||
}); | ||
var $str$$1 = JSON.stringify; | ||
var $compile$$1 = function $compile$$1(_object) { | ||
return $exec$$1(_compile$$1, {}, _object); | ||
var $compile$$1 = function $compile$$1(_, _object) { | ||
return $exec$$1(_compile$$1, _, _object); | ||
}; | ||
@@ -628,3 +256,3 @@ var _compile$$1 = function _compile$$1(_, _object) { | ||
}; | ||
$(compiles, function (k, v) { | ||
$(_._compilers, function (k, v) { | ||
v(ctx); | ||
@@ -655,4 +283,2 @@ }); | ||
var _scanHooks = ScanHooks(_); | ||
var BindHook = function BindHook(_ref) { | ||
@@ -668,3 +294,3 @@ var hook = _ref.hook, | ||
if (depth != '' && !validHook && !parentValidHook) return; | ||
var scanHooks = _scanHooks[hook]; | ||
var scanHooks = _._scanHooks[hook]; | ||
scanHooks && $(scanHooks, function (key, shook) { | ||
@@ -709,457 +335,316 @@ shook({ | ||
}; | ||
var $unuse$$1 = function $unuse$$1(_, _object) { | ||
return $exec$$1(_unuse$$1, _, _object); | ||
}; | ||
var _unuse$$1 = function _unuse$$1(_, _object) { | ||
var uuid$$1 = _object.uuid, | ||
_hooks = _object._hooks; | ||
$use$$1(_, { | ||
uuid: uuid$$1, | ||
_unhooks: _hooks | ||
}); | ||
return _; | ||
}; | ||
var _setSimple$$1 = function _setSimple$$1(_, _object) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref2) { | ||
var object = _ref2.object, | ||
depth = _ref2.depth, | ||
_key = _ref2._key, | ||
_val = _ref2._val; | ||
// const compose = middleware => { | ||
// return (ctx, next) => { | ||
// let index = -1 | ||
// return dispatch(0) | ||
// function dispatch(i) { | ||
// if (i <= index) return Promise.reject(new Error('next() called multiple times')) | ||
// index = i | ||
// let fn = middleware[i] | ||
// if (i === middleware.length) fn = next | ||
// if (!fn) return Promise.resolve() | ||
// try { | ||
// return Promise.resolve(fn(ctx, () => dispatch(i + 1))) | ||
// } catch (e) { | ||
// return Promise.reject(e) | ||
// } | ||
// } | ||
// } | ||
// } | ||
if (matchPath.test(_val)) { | ||
var result = get(_, _val); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
var handleHooks = function handleHooks(_ref) { | ||
var object = _ref.object, | ||
depth = _ref.depth, | ||
key = _ref.key, | ||
_key = _ref._key, | ||
_val = _ref._val, | ||
_object = _ref._object; | ||
var hooks = get(core[HOOKS], key); | ||
hooks instanceof Map && hooks && $M(hooks, function (uuid$$1, h) { | ||
if (h instanceof Set) { | ||
var fns = _toConsumableArray(h); | ||
fns({ | ||
depth: depth, | ||
_key: _key, | ||
_val: _val, | ||
cp: _object | ||
}); | ||
} else { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
h({ | ||
depth: depth, | ||
_key: _key, | ||
_val: _val, | ||
cp: _object, | ||
parent: object | ||
}); | ||
} | ||
return; | ||
}; | ||
var onFunction = function onFunction(_ref3) { | ||
var object = _ref3.object, | ||
depth = _ref3.depth, | ||
_key = _ref3._key, | ||
_val = _ref3._val; | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
}; | ||
var onObject = function onObject(_ref4) { | ||
var object = _ref4.object, | ||
depth = _ref4.depth, | ||
_key = _ref4._key, | ||
_val = _ref4._val; | ||
if (Object.keys(object).length === 0) { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
} | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onVariable: onVariable, | ||
onFunction: onFunction, | ||
onArray: onVariable | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; | ||
var _setAdvanced$$1 = function _setAdvanced$$1(_, _object) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref5) { | ||
var object = _ref5.object, | ||
depth = _ref5.depth, | ||
_key = _ref5._key, | ||
_val = _ref5._val; | ||
if (matchPath.test(_val)) { | ||
var result = get(_, _val); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
} else { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
} | ||
return; | ||
}; | ||
var onFunction = function onFunction(_ref6) { | ||
var object = _ref6.object, | ||
depth = _ref6.depth, | ||
_key = _ref6._key, | ||
_val = _ref6._val; | ||
var tar = get(_, depth); | ||
var result = _val({ | ||
tar: tar | ||
var handleEachHooks = function handleEachHooks(_ref2) { | ||
var object = _ref2.object, | ||
depth = _ref2.depth, | ||
key = _ref2.key, | ||
_key = _ref2._key, | ||
_val = _ref2._val, | ||
_object = _ref2._object; | ||
var hooks = get(core[HOOKS], key); | ||
hooks instanceof Map && hooks && $(_val, function (key, val) { | ||
$M(hooks, function (uuid$$1, h) { | ||
return h({ | ||
depth: depth, | ||
_key: key, | ||
_val: val, | ||
cp: _object, | ||
parent: object | ||
}); | ||
}); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
return; | ||
}; | ||
var onObject = function onObject(_ref7) { | ||
var object = _ref7.object, | ||
depth = _ref7.depth, | ||
_key = _ref7._key, | ||
_val = _ref7._val; | ||
if (Object.keys(object).length === 0) { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
} | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onVariable: onVariable, | ||
onFunction: onFunction, | ||
onArray: onVariable | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; | ||
var setMethods$$1 = { | ||
simple: _setSimple$$1, | ||
advanced: _setAdvanced$$1 | ||
}; | ||
var $set$$1 = function $set$$1(_, _object) { | ||
var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref8$type = _ref8.type, | ||
type = _ref8$type === void 0 ? 'simple' : _ref8$type; | ||
return $exec$$1(setMethods$$1[type], _, _object); | ||
}; | ||
var $merge$$1 = function $merge$$1(_array, options) { | ||
var cache = {}; | ||
$(_array, function (key, val) { | ||
$set$$1(cache, val, options); | ||
}); | ||
return cache; | ||
}; | ||
var $get$$1 = function $get$$1(_, _object) { | ||
return $exec$$1(_get$$1, _, _object); | ||
}; | ||
var _get$$1 = function _get$$1(_, args) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref9) { | ||
var object = _ref9.object, | ||
depth = _ref9.depth, | ||
_key = _ref9._key, | ||
_val = _ref9._val; | ||
var result; | ||
if (matchPath.test(_val)) { | ||
result = get(_, _val); | ||
result && set$1(cache, depth, result); | ||
} else { | ||
result = get(_, depth); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
var _scanHooks$$1 = { | ||
onAny: { | ||
any: function any(_ref3) { | ||
var object = _ref3.object, | ||
parentDepth = _ref3.parentDepth, | ||
depth = _ref3.depth, | ||
_key = _ref3._key, | ||
_val = _ref3._val, | ||
_object = _ref3._object; | ||
var key = "".concat(depth); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
_: function _(_ref4) { | ||
var object = _ref4.object, | ||
depth = _ref4.depth, | ||
_key = _ref4._key, | ||
_val = _ref4._val, | ||
_object = _ref4._object; | ||
var key = "".concat(depth, "._"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
return; | ||
}; | ||
var onFunction = function onFunction(_ref10) { | ||
var object = _ref10.object, | ||
depth = _ref10.depth, | ||
_key = _ref10._key, | ||
_val = _ref10._val; | ||
var tar = get(_, depth); | ||
var result = _val({ | ||
tar: tar | ||
}); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
return; | ||
}; | ||
var onObject = function onObject(_ref11) { | ||
var object = _ref11.object, | ||
depth = _ref11.depth, | ||
_key = _ref11._key, | ||
_val = _ref11._val; | ||
if (Object.keys(object).length === 0) { | ||
var result = get(_, depth); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
return; | ||
}, | ||
onObject: { | ||
O: function O(_ref5) { | ||
var object = _ref5.object, | ||
parentDepth = _ref5.parentDepth, | ||
depth = _ref5.depth, | ||
_key = _ref5._key, | ||
_val = _ref5._val, | ||
_object = _ref5._object; | ||
var key = "".concat(depth, ".O"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$: function $$$1(_ref6) { | ||
var object = _ref6.object, | ||
depth = _ref6.depth, | ||
_key = _ref6._key, | ||
_val = _ref6._val, | ||
_object = _ref6._object; | ||
var key = "".concat(depth, ".$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
O$: function O$(_ref7) { | ||
var object = _ref7.object, | ||
depth = _ref7.depth, | ||
_key = _ref7._key, | ||
_val = _ref7._val, | ||
_object = _ref7._object; | ||
var key = "".concat(depth, ".O$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$O: function $O(_ref8) { | ||
var object = _ref8.object, | ||
parentDepth = _ref8.parentDepth, | ||
depth = _ref8.depth, | ||
_key = _ref8._key, | ||
_val = _ref8._val, | ||
_object = _ref8._object; | ||
var key = "".concat(parentDepth, ".$O"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onFunction: onFunction, | ||
onVariable: onVariable, | ||
onArray: onVariable | ||
}); | ||
}; | ||
_typeof(args) === 'object' && onObject({ | ||
object: args, | ||
depth: '' | ||
}); | ||
_typeof(args) !== 'object' && onVariable({ | ||
depth: args | ||
}); | ||
return cache; | ||
}; | ||
var $diff$$1 = function $diff$$1(_, _object) { | ||
return $exec$$1(_diff$$1, _, _object); | ||
}; | ||
var _diff$$1 = function _diff$$1(_, _object) { | ||
var cache = {}; | ||
var onObject = function onObject(_ref12) { | ||
var object = _ref12.object, | ||
depth = _ref12.depth, | ||
_key = _ref12._key, | ||
_val = _ref12._val; | ||
var target = get(_, depth, {}); | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object') { | ||
return; | ||
} | ||
var result = target[key]; | ||
if (result !== val) { | ||
var newDepth = "".concat(depth, ".").concat(key); | ||
set$1(cache, newDepth, val); | ||
} | ||
return; | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; | ||
var $has$$1 = function $has$$1(_, _object) { | ||
return $exec$$1(_has$$1, _, _object); | ||
}; | ||
var _has$$1 = function _has$$1(_, _object) { | ||
var cache = {}; | ||
var onObject = function onObject(_ref13) { | ||
var object = _ref13.object, | ||
depth = _ref13.depth, | ||
_key = _ref13._key, | ||
_val = _ref13._val; | ||
var target = get(_, depth, {}); | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object') { | ||
return; | ||
} | ||
var newDepth = "".concat(depth, ".").concat(key); | ||
var result = target[key]; | ||
result && set$1(cache, newDepth, true); | ||
!result && set$1(cache, newDepth, false); | ||
return; | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; // | ||
var _matchSimple$$1 = function _matchSimple$$1(_, _array) { | ||
console.log(JSON.stringify(_array)); | ||
throw new Error('not implemented'); | ||
}; | ||
var _matchAdvanced$$1 = function _matchAdvanced$$1(_, _object) { | ||
$(_object, function (_key, _val) { | ||
var _JSON$parse = JSON.parse(_key), | ||
invalid = _JSON$parse.invalid, | ||
valid = _JSON$parse.valid, | ||
equal = _JSON$parse.equal, | ||
__get = _JSON$parse.get; | ||
var isinvalid = true; | ||
var isValid = true; | ||
var isEqual = true; | ||
var cache = {}; | ||
invalid && (isinvalid = $invalid$$1(_, invalid)); | ||
valid && (isValid = $valid$$1(_, valid)); | ||
equal && (isEqual = $equal$$1(_, equal)); | ||
if (!isEqual || !isValid || !isinvalid) { | ||
return; | ||
}, | ||
onArray: { | ||
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 = "".concat(depth, ".A"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
A$: function A$(_ref10) { | ||
var object = _ref10.object, | ||
parentDepth = _ref10.parentDepth, | ||
depth = _ref10.depth, | ||
_key = _ref10._key, | ||
_val = _ref10._val, | ||
_object = _ref10._object; | ||
var key = "".concat(depth, ".A$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$: function $$$1(_ref11) { | ||
var object = _ref11.object, | ||
depth = _ref11.depth, | ||
_key = _ref11._key, | ||
_val = _ref11._val, | ||
_object = _ref11._object; | ||
var key = "".concat(depth, ".$"); | ||
handleEachHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$A: function $A(_ref12) { | ||
var object = _ref12.object, | ||
parentDepth = _ref12.parentDepth, | ||
depth = _ref12.depth, | ||
_key = _ref12._key, | ||
_val = _ref12._val, | ||
_object = _ref12._object; | ||
var key = "".concat(parentDepth, ".$A"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
__get && $set$$1(cache, $get$$1(_, __get)); | ||
_val(cache); | ||
}); | ||
}, | ||
onFunction: { | ||
F: function F(_ref13) { | ||
var object = _ref13.object, | ||
parentDepth = _ref13.parentDepth, | ||
depth = _ref13.depth, | ||
_key = _ref13._key, | ||
_val = _ref13._val, | ||
_object = _ref13._object; | ||
var key = "".concat(depth, ".F"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$F: function $F(_ref14) { | ||
var object = _ref14.object, | ||
parentDepth = _ref14.parentDepth, | ||
depth = _ref14.depth, | ||
_key = _ref14._key, | ||
_val = _ref14._val, | ||
_object = _ref14._object; | ||
var key = "".concat(parentDepth, ".$F"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
}, | ||
onVariable: { | ||
V: function V(_ref15) { | ||
var object = _ref15.object, | ||
parentDepth = _ref15.parentDepth, | ||
depth = _ref15.depth, | ||
_key = _ref15._key, | ||
_val = _ref15._val, | ||
_object = _ref15._object; | ||
var key = "".concat(depth, ".V"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
}, | ||
$V: function $V(_ref16) { | ||
var object = _ref16.object, | ||
parentDepth = _ref16.parentDepth, | ||
depth = _ref16.depth, | ||
_key = _ref16._key, | ||
_val = _ref16._val, | ||
_object = _ref16._object; | ||
var key = "".concat(parentDepth, ".$V"); | ||
handleHooks({ | ||
object: object, | ||
depth: depth, | ||
key: key, | ||
_key: _key, | ||
_val: _val, | ||
_object: _object | ||
}); | ||
} | ||
} | ||
}; | ||
var matchMethods$$1 = { | ||
simple: _matchSimple$$1, | ||
advanced: _matchAdvanced$$1 | ||
}; | ||
var $match$$1 = function $match$$1(target, _object) { | ||
var _ref14 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref14$type = _ref14.type, | ||
type = _ref14$type === void 0 ? 'simple' : _ref14$type; | ||
return $exec$$1(matchMethods$$1[type], target, _object); | ||
}; | ||
var $invalid$$1 = function $invalid$$1(_, _object) { | ||
return $exec$$1(_invalid$$1, _, _object); | ||
}; | ||
var _invalid$$1 = function _invalid$$1(_, _object) { | ||
var isinValid = true; | ||
var onObject = function onObject(_ref15) { | ||
var object = _ref15.object, | ||
depth = _ref15.depth, | ||
_key = _ref15._key, | ||
_val = _ref15._val; | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object' || !isinValid) { | ||
return; | ||
} | ||
var newDepth = depth ? "".concat(depth, ".").concat(key) : key; | ||
var target = get(_, newDepth); | ||
if (target) { | ||
isinValid = false; | ||
return; | ||
} | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return isinValid; | ||
}; | ||
var $valid$$1 = function $valid$$1(_, _object) { | ||
return $exec$$1(_valid$$1, _, _object); | ||
}; | ||
var _valid$$1 = function _valid$$1(_, _object) { | ||
var isValid = true; | ||
var onObject = function onObject(_ref16) { | ||
var object = _ref16.object, | ||
depth = _ref16.depth, | ||
_key = _ref16._key, | ||
_val = _ref16._val; | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object' || !isValid) { | ||
return; | ||
} | ||
var newDepth = depth ? "".concat(depth, ".").concat(key) : key; | ||
var target = get(_, newDepth); | ||
if (!target) { | ||
isValid = false; | ||
return; | ||
} | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return isValid; | ||
}; | ||
var $equal$$1 = function $equal$$1(_, _object) { | ||
return $exec$$1(_equal$$1, _, _object); | ||
}; | ||
var _equal$$1 = function _equal$$1(_, _object) { | ||
var isEqual = true; | ||
var onObject = function onObject(_ref17) { | ||
var object = _ref17.object, | ||
depth = _ref17.depth, | ||
_key = _ref17._key, | ||
_val = _ref17._val; | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object' || isEqual) { | ||
return; | ||
} | ||
var newDepth = depth ? "".concat(depth, ".").concat(key) : key; | ||
var target = get(_, newDepth); | ||
if (val !== target) { | ||
isEqual = false; | ||
return; | ||
} | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return isEqual; | ||
}; | ||
var HOOKS = Symbol('hooks'); | ||
@@ -1327,73 +812,24 @@ var matchSlashPath = /\//g; | ||
var assign = Object.assign; | ||
var $core = function $core(_, _object) { | ||
var _assign; | ||
var _core; | ||
var core = (_core = {}, _defineProperty(_core, HOOKS, initHooks()), _defineProperty(_core, "_scanHooks", _scanHooks$$1), _defineProperty(_core, "_compilers", { | ||
hooks: function hooks(ctx) { | ||
var keys = ctx._keys; | ||
keys = keys.filter(function (key) { | ||
return key.startsWith('$'); | ||
}); | ||
assign(_, (_assign = {}, _defineProperty(_assign, HOOKS, initHooks(_)), _defineProperty(_assign, "_events", new events.EventEmitter()), _defineProperty(_assign, "$use", function $use(object) { | ||
_._events.emit('$use', $compile$$1(object)); | ||
if (keys.length > 0) { | ||
ctx._hooks = {}; | ||
keys.forEach(function (key) { | ||
var newKey = key.replace(/\$/, ''); | ||
ctx._hooks[newKey] = ctx._object[key]; | ||
}); | ||
} | ||
} | ||
}), _defineProperty(_core, "$compile", $compile$$1), _defineProperty(_core, "$use", function $use$$2(data) { | ||
$use$$1(core, core.$compile(core, data)); | ||
return _; | ||
}), _defineProperty(_assign, "$unuse", function $unuse(object) { | ||
_._events.emit('$unuse', $compile$$1(object)); | ||
return core; | ||
}), _core); | ||
return _; | ||
}), _assign)); | ||
_._events.on('$use', function (object) { | ||
return $use$$1(_, object); | ||
}); | ||
_._events.on('$unuse', function (object) { | ||
return $unuse$$1(_, object); | ||
}); | ||
_.$use(_object); | ||
return _; | ||
}; | ||
var index = $core(function (_object) { | ||
return $core({}, _object); | ||
}, {}); | ||
exports.uuid = uuid; | ||
exports.$core = $core; | ||
exports.default = index; | ||
exports.HOOKS = HOOKS; | ||
exports.matchSlashPath = matchSlashPath; | ||
exports.matchPath = matchPath; | ||
exports.initHooks = initHooks; | ||
exports.get = get; | ||
exports.set = set$1; | ||
exports.has = has; | ||
exports.$ = $; | ||
exports.$M = $M; | ||
exports.scanObject = scanObject; | ||
exports.$str = $str$$1; | ||
exports.$compile = $compile$$1; | ||
exports._compile = _compile$$1; | ||
exports.$exec = $exec$$1; | ||
exports.$use = $use$$1; | ||
exports._use = _use$$1; | ||
exports.$unuse = $unuse$$1; | ||
exports._unuse = _unuse$$1; | ||
exports._setSimple = _setSimple$$1; | ||
exports._setAdvanced = _setAdvanced$$1; | ||
exports.setMethods = setMethods$$1; | ||
exports.$set = $set$$1; | ||
exports.$merge = $merge$$1; | ||
exports.$get = $get$$1; | ||
exports._get = _get$$1; | ||
exports.$diff = $diff$$1; | ||
exports._diff = _diff$$1; | ||
exports.$has = $has$$1; | ||
exports._has = _has$$1; | ||
exports._matchSimple = _matchSimple$$1; | ||
exports._matchAdvanced = _matchAdvanced$$1; | ||
exports.matchMethods = matchMethods$$1; | ||
exports.$match = $match$$1; | ||
exports.$invalid = $invalid$$1; | ||
exports._invalid = _invalid$$1; | ||
exports.$valid = $valid$$1; | ||
exports._valid = _valid$$1; | ||
exports.$equal = $equal$$1; | ||
exports._equal = _equal$$1; | ||
module.exports = core; |
{ | ||
"name": "menhera", | ||
"version": "0.8.5-rc2", | ||
"version": "0.9.0", | ||
"main": "dist/index.js", | ||
@@ -17,3 +17,3 @@ "license": "MIT", | ||
"babel-preset-stage-3": "^6.24.1", | ||
"bili": "^3.1.0", | ||
"bili": "^3.4.2", | ||
"menhera": "^0.8.1-rc1", | ||
@@ -20,0 +20,0 @@ "menhera-cli": "^0.3.1-rc2" |
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
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
21096
753