Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

menhera

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

menhera - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1-rc1

311

dist/index.js

@@ -234,44 +234,21 @@ 'use strict';

};
var entity = {
$: function $$$1(_ref10) {
var _ = _ref10._,
_val = _ref10._val,
cp = _ref10.cp;
var _uuid = uuid.v1();
var hooks = /*#__PURE__*/Object.freeze({
_hooks: _hooks,
_unhooks: _unhooks,
_mount: _mount,
_run: _run
});
_val._uuid = _uuid;
var hooks$1 = function hooks(ctx) {
var keys = ctx._keys;
keys = keys.filter(function (key) {
return key.startsWith('$');
});
var onAny = function onAny(_ref11) {
var object = _ref11.object,
depth = _ref11.depth,
_key = _ref11._key,
_val = _ref11._val;
var target = get(_[DATAS], depth);
if (!target) {
target = new Set([_uuid]);
set$1(_[DATAS], depth, target);
} else {
target.add(_uuid, _val);
}
};
var onObject = function onObject(_ref12) {
var object = _ref12.object,
depth = _ref12.depth,
_key = _ref12._key,
_val = _ref12._val;
scanObject({
object: object,
depth: depth,
onObject: onObject,
onAny: onAny
});
};
_[ENTITIES][_uuid] = _val;
onObject({
object: _val,
depth: ''
if (keys.length > 0) {
ctx._hooks = {};
keys.forEach(function (key) {
var newKey = key.replace(/\$/, '');
ctx._hooks[newKey] = ctx._object[key];
});

@@ -281,8 +258,4 @@ }

var hooks = /*#__PURE__*/Object.freeze({
_hooks: _hooks,
_unhooks: _unhooks,
_mount: _mount,
_run: _run,
entity: entity
var compiles = /*#__PURE__*/Object.freeze({
hooks: hooks$1
});

@@ -369,3 +342,3 @@

var useHooks = function useHooks(_2) {
var scanHooks_ = (function (_2) {
return {

@@ -628,3 +601,3 @@ onAny: {

};
};
});

@@ -652,4 +625,5 @@ var $str$$1 = JSON.stringify;

!_object.uuid && (_object.uuid = uuid.v1());
var hooks = useHooks(_);
var _scanHooks = scanHooks_(_);
var BindHook = function BindHook(_ref) {

@@ -664,4 +638,4 @@ var hook = _ref.hook,

if (depth != '' && !validHook) return;
var _hooks = hooks[hook];
_hooks && $(_hooks, function (key, shook) {
var scanHooks = _scanHooks[hook];
scanHooks && $(scanHooks, function (key, shook) {
shook({

@@ -1157,62 +1131,16 @@ hook: hook,

};
var scanMethod = {
simple: _scanSimple$$1
};
var $scan$$1 = function $scan$$1(_, _object, _ref18) {
var _ref18$type = _ref18.type,
type = _ref18$type === void 0 ? 'simple' : _ref18$type;
return $exec$$1(scanMethod[type], _, _object);
};
var _scanSimple$$1 = function _scanSimple$$1(target, _object) {};
var trigger$$1 = function trigger$$1(triggers, _, data) {
var type = _typeof(data);
if (type == 'object') {
if (Array.isArray(data)) {
type = 'array';
}
}
var trigger$$1 = triggers[type];
if (trigger$$1) {
return trigger$$1(_, data) || {};
}
return {};
};
var scan$$1 = function scan$$1(_, _object) {
return trigger$$1(uScan$$1, _, _object);
};
var uScan$$1 = {
string: function string(_, depth) {
var cache = new Set();
var uuids = get(_[DATAS], depth);
uuids.forEach(function (_uuid) {
cache.add(_[ENTITIES][_uuid]);
});
return cache;
},
array: function array(_, depths) {
var cache = {};
depths.forEach(function (depth) {
cache[depth] = uScan$$1.string(_, depth);
});
return cache;
},
object: function object(_, depths) {
var cache = {};
$(depths, function (k, depth) {
cache[k] = uScan$$1.string(_, depth);
});
return cache;
}
};
var HOOKS = Symbol('hooks');
var DATAS = Symbol('datas');
var ENTITIES = Symbol('entities');
var matchSlashPath = /\//g;
var matchPath = /\/|\./;
var compile = function compile(_object) {
var ctx = {
_object: _object,
_keys: Object.keys(_object)
};
$(compiles, function (k, v) {
v(ctx);
});
return Object.assign({}, ctx, ctx._object);
};
var initHooks = function initHooks() {

@@ -1232,5 +1160,2 @@ var cache = {};

};
var initDatas = function initDatas() {
return {};
};
var get = function get(obj, path, def) {

@@ -1381,2 +1306,139 @@ if (matchSlashPath.test(path)) {

var ECS = Symbol('ecs');
var _query = function query(_, datas) {
var _$ECS = _[ECS],
entities = _$ECS.entities,
components = _$ECS.components;
datas = Array.isArray(datas) ? datas : [datas];
var valid = true;
var _entities = new Map();
var cps = datas.map(function (cp) {
return components[cp] || (valid = false);
});
if (!valid) return [];
var _cps = _slicedToArray(cps, 1),
_cps$ = _cps[0],
filter = _cps$ === void 0 ? [] : _cps$;
filter.forEach(function (id) {
cps.forEach(function (c) {
if (!c.has(id)) {
filter.delete(id);
}
});
});
filter.forEach(function (id) {
_entities.set(id, entities[id]);
});
return _entities;
};
var _queryRaw = function queryRaw(_, datas) {
var _$ECS2 = _[ECS],
raws = _$ECS2.raws,
components = _$ECS2.components;
datas = Array.isArray(datas) ? datas : [datas];
var valid = true;
var _entities = new Map();
var cps = datas.map(function (cp) {
return components[cp] || (valid = false);
});
if (!valid) return [];
var _cps2 = _slicedToArray(cps, 1),
_cps2$ = _cps2[0],
filter = _cps2$ === void 0 ? [] : _cps2$;
filter.forEach(function (id) {
cps.forEach(function (c) {
if (!c.has(id)) {
filter.delete(id);
}
});
});
filter.forEach(function (id) {
_entities.set(id, raws[id]);
});
return _entities;
};
var entity = function entity(_ref) {
var _Object$assign;
var _ = _ref._;
Object.assign(_, (_Object$assign = {}, _defineProperty(_Object$assign, ECS, {
raws: {},
entities: {},
components: {}
}), _defineProperty(_Object$assign, "query", function query(_object) {
return _query(_, _object);
}), _defineProperty(_Object$assign, "queryRaw", function queryRaw(_object) {
return _queryRaw(_, _object);
}), _Object$assign));
var _$ECS3 = _[ECS],
entities = _$ECS3.entities,
components = _$ECS3.components,
raws = _$ECS3.raws;
return {
name: 'entity',
$entity: {
$: function $$$1(_ref2) {
var _val = _ref2._val,
cp = _ref2.cp;
var cache = {};
var entitiyID = uuid.v1();
raws[entitiyID] = _val;
var onAny = function onAny(_ref3) {
var object = _ref3.object,
parentDepth = _ref3.parentDepth,
depth = _ref3.depth,
_key = _ref3._key,
_val = _ref3._val;
if (_key === 'val') {
set$1(cache, parentDepth, _val);
}
};
var onObject = function onObject(_ref4) {
var object = _ref4.object,
depth = _ref4.depth,
_key = _ref4._key,
_val = _ref4._val;
scanObject({
object: object,
depth: depth,
onObject: onObject,
onAny: onAny
});
};
onObject({
object: _val,
depth: ''
});
$(cache, function (k, v) {
var target = components[k];
if (!target) {
target = new Set([entitiyID]);
set$1(components, k, target);
} else {
target.add(entitiyID, v);
}
});
entities[entitiyID] = cache;
}
}
};
};
var assign = Object.assign;

@@ -1386,20 +1448,18 @@ var $core = function $core(_, _object) {

assign(_, (_assign = {}, _defineProperty(_assign, HOOKS, initHooks(_)), _defineProperty(_assign, DATAS, initDatas(_)), _defineProperty(_assign, ENTITIES, {}), _defineProperty(_assign, "_events", new events.EventEmitter()), _defineProperty(_assign, "$use", function $use(_object) {
_._events.emit('$use', _object);
assign(_, (_assign = {}, _defineProperty(_assign, HOOKS, initHooks(_)), _defineProperty(_assign, "_events", new events.EventEmitter()), _defineProperty(_assign, "$use", function $use(object) {
_._events.emit('$use', compile(object));
return _;
}), _defineProperty(_assign, "$unuse", function $unuse(_object) {
_._events.emit('$unuse', _object);
}), _defineProperty(_assign, "$unuse", function $unuse(object) {
_._events.emit('$unuse', compile(object));
return _;
}), _defineProperty(_assign, "scan", function scan$$2(_object) {
return scan$$1(_, _object);
}), _assign));
_._events.on('$use', function (_object) {
return $use$$1(_, _object);
_._events.on('$use', function (object) {
return $use$$1(_, object);
});
_._events.on('$unuse', function (_object) {
return $unuse$$1(_, _object);
_._events.on('$unuse', function (object) {
return $unuse$$1(_, object);
});

@@ -1419,8 +1479,6 @@

exports.HOOKS = HOOKS;
exports.DATAS = DATAS;
exports.ENTITIES = ENTITIES;
exports.matchSlashPath = matchSlashPath;
exports.matchPath = matchPath;
exports.compile = compile;
exports.initHooks = initHooks;
exports.initDatas = initDatas;
exports.get = get;

@@ -1459,6 +1517,5 @@ exports.set = set$1;

exports._equal = _equal$$1;
exports.$scan = $scan$$1;
exports._scanSimple = _scanSimple$$1;
exports.trigger = trigger$$1;
exports.scan = scan$$1;
exports.uScan = uScan$$1;
exports.ECS = ECS;
exports.query = _query;
exports.queryRaw = _queryRaw;
exports.entity = entity;
{
"name": "menhera",
"version": "0.8.0",
"version": "0.8.1-rc1",
"main": "dist/index.js",

@@ -15,4 +15,6 @@ "license": "MIT",

"@types/uuid": "^3.4.3",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-3": "^6.24.1",
"bili": "^3.1.0",
"menhera": "^0.7.7",
"menhera": "^0.8.0",
"menhera-cli": "^0.3.1-rc2"

@@ -19,0 +21,0 @@ },

# Menhera
an experimental lovely frame
an experimental lovely framework

@@ -14,18 +14,16 @@ ### Install

```js
import Mhr from "menehra";
import Mhr from 'menhera'
Mhr.$use({
_hooks: {
foo: {
bar: {
test: ({ _val }) => console.log(_val),
testFn: ({ _val }) => console.log(_val())
}
$foo: {
bar: {
test: ({_val}) => console.log(_val),
testFn: ({_val}) => console.log(_val())
}
},
"foo.bar": {
test: "foo bar",
testFn: () => "foo bar"
'foo.bar': {
test: 'foo bar',
testFn: () => 'foo bar'
}
});
})
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc