reactive-di
Advanced tools
Comparing version 5.0.2 to 5.0.3
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="5.0.3"></a> | ||
## [5.0.3](https://github.com/zerkalica/reactive-di/compare/v5.0.2...v5.0.3) (2017-11-06) | ||
<a name="5.0.2"></a> | ||
@@ -7,0 +12,0 @@ ## [5.0.2](https://github.com/zerkalica/reactive-di/compare/v5.0.1...v5.0.2) (2017-11-04) |
@@ -0,1 +1,23 @@ | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
var ATOM_FORCE_NONE = 0; | ||
@@ -7,4 +29,9 @@ var ATOM_FORCE_CACHE = 1; | ||
var DisposableSheet = function () { | ||
var DisposableSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
function DisposableSheet(key, sheet, remover) { | ||
this.__lom_remover = void 0; | ||
this.__lom_sheet = void 0; | ||
this.__lom_key = void 0; | ||
this.__lom_key = key; | ||
@@ -21,3 +48,5 @@ this.__lom_sheet = sheet; | ||
DisposableSheet.prototype.destructor = function destructor() { | ||
var _proto = DisposableSheet.prototype; | ||
_proto.destructor = function destructor() { | ||
this.__lom_remover.remove(this); | ||
@@ -29,4 +58,7 @@ }; | ||
var SheetManager = function () { | ||
var SheetManager = | ||
/*#__PURE__*/ | ||
function () { | ||
function SheetManager(sheetProcessor) { | ||
this._sheetProcessor = void 0; | ||
this._cache = new Map(); | ||
@@ -36,3 +68,5 @@ this._sheetProcessor = sheetProcessor; | ||
SheetManager.prototype.sheet = function sheet(key, css, memoized) { | ||
var _proto2 = SheetManager.prototype; | ||
_proto2.sheet = function sheet(key, css, memoized) { | ||
var result = memoized ? null : this._cache.get(key); | ||
@@ -55,3 +89,3 @@ | ||
SheetManager.prototype.remove = function remove(sheet) { | ||
_proto2.remove = function remove(sheet) { | ||
this._cache.delete(sheet.__lom_key); | ||
@@ -106,54 +140,2 @@ | ||
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; | ||
}; | ||
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; | ||
}; | ||
}(); | ||
var inheritsLoose = function (subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
}; | ||
var _class2; | ||
@@ -166,2 +148,3 @@ var _temp; | ||
var Alias = function Alias(dest) { | ||
this.dest = void 0; | ||
dest[rdiId] = '' + ++depId; | ||
@@ -171,4 +154,10 @@ this.dest = dest; | ||
var Injector = (_temp = _class2 = function () { | ||
var Injector = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function () { | ||
function Injector(items, sheetProcessor, state, displayName, instance, cache) { | ||
this.displayName = void 0; | ||
this.instance = void 0; | ||
this._cache = void 0; | ||
this._state = void 0; | ||
this._resolved = false; | ||
@@ -216,11 +205,13 @@ this._listeners = undefined; | ||
Injector.prototype.toString = function toString() { | ||
var _proto = Injector.prototype; | ||
_proto.toString = function toString() { | ||
return this.displayName; | ||
}; | ||
Injector.prototype.toJSON = function toJSON() { | ||
_proto.toJSON = function toJSON() { | ||
return this._cache; | ||
}; | ||
Injector.prototype.value = function value(key) { | ||
_proto.value = function value(key) { | ||
var id = key[rdiId]; | ||
@@ -241,3 +232,3 @@ | ||
if (state && _typeof(state) === 'object') { | ||
if (state && typeof state === 'object') { | ||
for (var prop in state) { | ||
@@ -255,3 +246,3 @@ | ||
Injector.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
this._cache = undefined; | ||
@@ -261,3 +252,3 @@ this._listeners = undefined; | ||
Injector.prototype.invoke = function invoke(key) { | ||
_proto.invoke = function invoke(key) { | ||
var isFn = key.theme; | ||
@@ -297,3 +288,3 @@ var deps = key.deps; | ||
default: | ||
return key.apply(undefined, a); | ||
return key.apply(void 0, a); | ||
} | ||
@@ -329,3 +320,3 @@ } | ||
Injector.prototype.alias = function alias(key, rawId) { | ||
_proto.alias = function alias(key, rawId) { | ||
var id = rawId; | ||
@@ -347,3 +338,3 @@ | ||
Injector.prototype.invokeWithProps = function invokeWithProps(key, props, propsChanged) { | ||
_proto.invokeWithProps = function invokeWithProps(key, props, propsChanged) { | ||
var deps = key.deps || (key._r === undefined ? undefined : key._r[1]); | ||
@@ -393,11 +384,11 @@ | ||
default: | ||
return key.apply(undefined, [props].concat(a)); | ||
return key.apply(void 0, [props].concat(a)); | ||
} | ||
}; | ||
Injector.prototype.copy = function copy(displayName, instance, items) { | ||
_proto.copy = function copy(displayName, instance, items) { | ||
return new Injector(items, null, this._state, this.displayName + '.' + displayName, instance, Object.create(this._cache)); | ||
}; | ||
Injector.prototype.resolve = function resolve(argDeps) { | ||
_proto.resolve = function resolve(argDeps) { | ||
var result = []; | ||
@@ -410,3 +401,3 @@ if (argDeps === undefined) return result; | ||
if (_typeof(argDep) === 'object') { | ||
if (typeof argDep === 'object') { | ||
var obj = {}; | ||
@@ -481,9 +472,14 @@ | ||
function createReactWrapper(BaseComponent, defaultFromError, detached) { | ||
var _class; | ||
function createReactWrapper(BaseComponent, defaultFromError, detached, rootInjector) { | ||
var _class, _class2, _temp; | ||
var rootInjector = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Injector(); | ||
var AtomizedComponent = (_class = function (_BaseComponent) { | ||
inheritsLoose(AtomizedComponent, _BaseComponent); | ||
if (rootInjector === void 0) { | ||
rootInjector = new Injector(); | ||
} | ||
var AtomizedComponent = (_class = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function (_BaseComponent) { | ||
_inheritsLoose(AtomizedComponent, _BaseComponent); | ||
function AtomizedComponent(props, reactContext) { | ||
@@ -493,3 +489,7 @@ var _this; | ||
_this = _BaseComponent.call(this, props, reactContext) || this; | ||
_this.props = void 0; | ||
_this._propsChanged = true; | ||
_this._injector = void 0; | ||
_this._keys = void 0; | ||
_this._render = void 0; | ||
_this._el = undefined; | ||
@@ -504,7 +504,9 @@ _this._keys = props ? Object.keys(props) : undefined; | ||
AtomizedComponent.prototype.toString = function toString() { | ||
var _proto = AtomizedComponent.prototype; | ||
_proto.toString = function toString() { | ||
return this._injector.displayName; | ||
}; | ||
AtomizedComponent.prototype.shouldComponentUpdate = function shouldComponentUpdate(props) { | ||
_proto.shouldComponentUpdate = function shouldComponentUpdate(props) { | ||
var keys = this._keys; | ||
@@ -527,3 +529,3 @@ if (!keys) return false; | ||
AtomizedComponent.prototype.componentWillUnmount = function componentWillUnmount() { | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
this._el = undefined; | ||
@@ -544,4 +546,4 @@ this._keys = undefined; | ||
AtomizedComponent.prototype.r = function r(element, force) { | ||
var data = void 0; | ||
_proto.r = function r(element, force) { | ||
var data; | ||
var render = this._render; | ||
@@ -572,9 +574,9 @@ var prevContext = Injector.parentContext; | ||
AtomizedComponent.prototype.render = function render() { | ||
_proto.render = function render() { | ||
return this._el === undefined ? this.r(undefined, this._propsChanged ? ATOM_FORCE_CACHE : ATOM_FORCE_NONE) : this._el; | ||
}; | ||
createClass(AtomizedComponent, [{ | ||
_createClass(AtomizedComponent, [{ | ||
key: "displayName", | ||
get: function get$$1() { | ||
get: function get() { | ||
return this.toString(); | ||
@@ -584,3 +586,3 @@ } | ||
return AtomizedComponent; | ||
}(BaseComponent), (_applyDecoratedDescriptor(_class.prototype, "r", [detached], Object.getOwnPropertyDescriptor(_class.prototype, "r"), _class.prototype)), _class); | ||
}(BaseComponent), _class2.displayName = void 0, _class2.render = void 0, _class2.instance = void 0, _temp), (_applyDecoratedDescriptor(_class.prototype, "r", [detached], Object.getOwnPropertyDescriptor(_class.prototype, "r"), _class.prototype)), _class); | ||
return function reactWrapper(render) { | ||
@@ -604,21 +606,23 @@ var displayName = render.displayName || render.name; | ||
function lomCreateElement() { | ||
var el = arguments[0]; | ||
var attrs = arguments[1]; | ||
var newEl = void 0; | ||
var args = arguments; | ||
var attrs = args[1]; | ||
var el = args[0]; | ||
var newEl; | ||
var isAtomic = typeof el === 'function' && el.constructor.render === undefined; | ||
var id = attrs ? attrs.id : undefined; | ||
var id = attrs ? attrs._id || attrs.id : undefined; | ||
var parentContext = Injector.parentContext; | ||
if (isAtomic) { | ||
if (!attrs) { | ||
attrs = { | ||
__lom_ctx: Injector.parentContext | ||
}; | ||
} else { | ||
attrs.__lom_ctx = Injector.parentContext; | ||
} | ||
if (Injector.parentContext !== undefined) { | ||
newEl = Injector.parentContext.alias(el, id); | ||
if (parentContext !== undefined) { | ||
newEl = parentContext.alias(el, id); | ||
if (newEl === null) return null; | ||
if (newEl !== undefined) el = newEl; | ||
if (!attrs) { | ||
attrs = { | ||
__lom_ctx: parentContext | ||
}; | ||
} else { | ||
attrs.__lom_ctx = parentContext; | ||
} | ||
} | ||
@@ -632,4 +636,4 @@ | ||
} else { | ||
if (Injector.parentContext !== undefined && id) { | ||
newEl = Injector.parentContext.alias(el, id); | ||
if (parentContext !== undefined && id) { | ||
newEl = parentContext.alias(el, id); | ||
if (newEl === null) return null; | ||
@@ -642,3 +646,3 @@ if (newEl !== undefined) el = newEl; | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 2: | ||
@@ -648,34 +652,34 @@ return createElement(newEl, attrs); | ||
case 3: | ||
return createElement(newEl, attrs, arguments[2]); | ||
return createElement(newEl, attrs, args[2]); | ||
case 4: | ||
return createElement(newEl, attrs, arguments[2], arguments[3]); | ||
return createElement(newEl, attrs, args[2], args[3]); | ||
case 5: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4]); | ||
case 6: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5]); | ||
case 7: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6]); | ||
case 8: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6], args[7]); | ||
case 9: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6], args[7], args[8]); | ||
default: | ||
if (isAtomic === false) { | ||
return createElement.apply(null, arguments); | ||
return createElement.apply(null, args); | ||
} | ||
var args = [newEl, attrs]; | ||
var newArgs = [newEl, attrs]; | ||
for (var i = 2, l = arguments.length; i < l; i++) { | ||
args.push(arguments[i]); | ||
for (var i = 2, l = args.length; i < l; i++) { | ||
newArgs.push(args[i]); | ||
} | ||
return createElement.apply(null, args); | ||
return createElement.apply(null, newArgs); | ||
} | ||
@@ -690,3 +694,3 @@ } | ||
if (_typeof(fn) === 'object') { | ||
if (typeof fn === 'object') { | ||
var cons = fn.constructor; | ||
@@ -746,8 +750,17 @@ return cons.displayName || cons.name; | ||
function createMobxDetached(Reaction) { | ||
var LomReaction = function () { | ||
var LomReaction = | ||
/*#__PURE__*/ | ||
function () { | ||
function LomReaction(name, host, propName, reactions) { | ||
var _this = this; | ||
this._reaction = void 0; | ||
this._handler = void 0; | ||
this._cache = void 0; | ||
this._propName = void 0; | ||
this._host = void 0; | ||
this._reactions = void 0; | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._track = void 0; | ||
this._cache = undefined; | ||
@@ -769,3 +782,5 @@ this._host = host; | ||
LomReaction.prototype._onInvalidate = function _onInvalidate() { | ||
var _proto = LomReaction.prototype; | ||
_proto._onInvalidate = function _onInvalidate() { | ||
this._cache = undefined; | ||
@@ -775,7 +790,7 @@ this.value(); | ||
LomReaction.prototype.__track = function __track() { | ||
_proto.__track = function __track() { | ||
this._cache = this._host[this._propName](this._next, this._force); | ||
}; | ||
LomReaction.prototype.value = function value(next, force) { | ||
_proto.value = function value(next, force) { | ||
if (this._cache === undefined || force) { | ||
@@ -794,3 +809,3 @@ this._next = next; | ||
LomReaction.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
this._reaction.dispose(); | ||
@@ -797,0 +812,0 @@ |
@@ -5,2 +5,24 @@ 'use strict'; | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
var ATOM_FORCE_NONE = 0; | ||
@@ -12,4 +34,9 @@ var ATOM_FORCE_CACHE = 1; | ||
var DisposableSheet = function () { | ||
var DisposableSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
function DisposableSheet(key, sheet, remover) { | ||
this.__lom_remover = void 0; | ||
this.__lom_sheet = void 0; | ||
this.__lom_key = void 0; | ||
this.__lom_key = key; | ||
@@ -26,3 +53,5 @@ this.__lom_sheet = sheet; | ||
DisposableSheet.prototype.destructor = function destructor() { | ||
var _proto = DisposableSheet.prototype; | ||
_proto.destructor = function destructor() { | ||
this.__lom_remover.remove(this); | ||
@@ -34,4 +63,7 @@ }; | ||
var SheetManager = function () { | ||
var SheetManager = | ||
/*#__PURE__*/ | ||
function () { | ||
function SheetManager(sheetProcessor) { | ||
this._sheetProcessor = void 0; | ||
this._cache = new Map(); | ||
@@ -41,3 +73,5 @@ this._sheetProcessor = sheetProcessor; | ||
SheetManager.prototype.sheet = function sheet(key, css, memoized) { | ||
var _proto2 = SheetManager.prototype; | ||
_proto2.sheet = function sheet(key, css, memoized) { | ||
var result = memoized ? null : this._cache.get(key); | ||
@@ -60,3 +94,3 @@ | ||
SheetManager.prototype.remove = function remove(sheet) { | ||
_proto2.remove = function remove(sheet) { | ||
this._cache.delete(sheet.__lom_key); | ||
@@ -111,54 +145,2 @@ | ||
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; | ||
}; | ||
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; | ||
}; | ||
}(); | ||
var inheritsLoose = function (subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
}; | ||
var _class2; | ||
@@ -171,2 +153,3 @@ var _temp; | ||
var Alias = function Alias(dest) { | ||
this.dest = void 0; | ||
dest[rdiId] = '' + ++depId; | ||
@@ -176,4 +159,10 @@ this.dest = dest; | ||
var Injector = (_temp = _class2 = function () { | ||
var Injector = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function () { | ||
function Injector(items, sheetProcessor, state, displayName, instance, cache) { | ||
this.displayName = void 0; | ||
this.instance = void 0; | ||
this._cache = void 0; | ||
this._state = void 0; | ||
this._resolved = false; | ||
@@ -221,11 +210,13 @@ this._listeners = undefined; | ||
Injector.prototype.toString = function toString() { | ||
var _proto = Injector.prototype; | ||
_proto.toString = function toString() { | ||
return this.displayName; | ||
}; | ||
Injector.prototype.toJSON = function toJSON() { | ||
_proto.toJSON = function toJSON() { | ||
return this._cache; | ||
}; | ||
Injector.prototype.value = function value(key) { | ||
_proto.value = function value(key) { | ||
var id = key[rdiId]; | ||
@@ -246,3 +237,3 @@ | ||
if (state && _typeof(state) === 'object') { | ||
if (state && typeof state === 'object') { | ||
for (var prop in state) { | ||
@@ -260,3 +251,3 @@ | ||
Injector.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
this._cache = undefined; | ||
@@ -266,3 +257,3 @@ this._listeners = undefined; | ||
Injector.prototype.invoke = function invoke(key) { | ||
_proto.invoke = function invoke(key) { | ||
var isFn = key.theme; | ||
@@ -302,3 +293,3 @@ var deps = key.deps; | ||
default: | ||
return key.apply(undefined, a); | ||
return key.apply(void 0, a); | ||
} | ||
@@ -334,3 +325,3 @@ } | ||
Injector.prototype.alias = function alias(key, rawId) { | ||
_proto.alias = function alias(key, rawId) { | ||
var id = rawId; | ||
@@ -352,3 +343,3 @@ | ||
Injector.prototype.invokeWithProps = function invokeWithProps(key, props, propsChanged) { | ||
_proto.invokeWithProps = function invokeWithProps(key, props, propsChanged) { | ||
var deps = key.deps || (key._r === undefined ? undefined : key._r[1]); | ||
@@ -398,11 +389,11 @@ | ||
default: | ||
return key.apply(undefined, [props].concat(a)); | ||
return key.apply(void 0, [props].concat(a)); | ||
} | ||
}; | ||
Injector.prototype.copy = function copy(displayName, instance, items) { | ||
_proto.copy = function copy(displayName, instance, items) { | ||
return new Injector(items, null, this._state, this.displayName + '.' + displayName, instance, Object.create(this._cache)); | ||
}; | ||
Injector.prototype.resolve = function resolve(argDeps) { | ||
_proto.resolve = function resolve(argDeps) { | ||
var result = []; | ||
@@ -415,3 +406,3 @@ if (argDeps === undefined) return result; | ||
if (_typeof(argDep) === 'object') { | ||
if (typeof argDep === 'object') { | ||
var obj = {}; | ||
@@ -486,9 +477,14 @@ | ||
function createReactWrapper(BaseComponent, defaultFromError, detached) { | ||
var _class; | ||
function createReactWrapper(BaseComponent, defaultFromError, detached, rootInjector) { | ||
var _class, _class2, _temp; | ||
var rootInjector = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Injector(); | ||
var AtomizedComponent = (_class = function (_BaseComponent) { | ||
inheritsLoose(AtomizedComponent, _BaseComponent); | ||
if (rootInjector === void 0) { | ||
rootInjector = new Injector(); | ||
} | ||
var AtomizedComponent = (_class = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function (_BaseComponent) { | ||
_inheritsLoose(AtomizedComponent, _BaseComponent); | ||
function AtomizedComponent(props, reactContext) { | ||
@@ -498,3 +494,7 @@ var _this; | ||
_this = _BaseComponent.call(this, props, reactContext) || this; | ||
_this.props = void 0; | ||
_this._propsChanged = true; | ||
_this._injector = void 0; | ||
_this._keys = void 0; | ||
_this._render = void 0; | ||
_this._el = undefined; | ||
@@ -509,7 +509,9 @@ _this._keys = props ? Object.keys(props) : undefined; | ||
AtomizedComponent.prototype.toString = function toString() { | ||
var _proto = AtomizedComponent.prototype; | ||
_proto.toString = function toString() { | ||
return this._injector.displayName; | ||
}; | ||
AtomizedComponent.prototype.shouldComponentUpdate = function shouldComponentUpdate(props) { | ||
_proto.shouldComponentUpdate = function shouldComponentUpdate(props) { | ||
var keys = this._keys; | ||
@@ -532,3 +534,3 @@ if (!keys) return false; | ||
AtomizedComponent.prototype.componentWillUnmount = function componentWillUnmount() { | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
this._el = undefined; | ||
@@ -549,4 +551,4 @@ this._keys = undefined; | ||
AtomizedComponent.prototype.r = function r(element, force) { | ||
var data = void 0; | ||
_proto.r = function r(element, force) { | ||
var data; | ||
var render = this._render; | ||
@@ -577,9 +579,9 @@ var prevContext = Injector.parentContext; | ||
AtomizedComponent.prototype.render = function render() { | ||
_proto.render = function render() { | ||
return this._el === undefined ? this.r(undefined, this._propsChanged ? ATOM_FORCE_CACHE : ATOM_FORCE_NONE) : this._el; | ||
}; | ||
createClass(AtomizedComponent, [{ | ||
_createClass(AtomizedComponent, [{ | ||
key: "displayName", | ||
get: function get$$1() { | ||
get: function get() { | ||
return this.toString(); | ||
@@ -589,3 +591,3 @@ } | ||
return AtomizedComponent; | ||
}(BaseComponent), (_applyDecoratedDescriptor(_class.prototype, "r", [detached], Object.getOwnPropertyDescriptor(_class.prototype, "r"), _class.prototype)), _class); | ||
}(BaseComponent), _class2.displayName = void 0, _class2.render = void 0, _class2.instance = void 0, _temp), (_applyDecoratedDescriptor(_class.prototype, "r", [detached], Object.getOwnPropertyDescriptor(_class.prototype, "r"), _class.prototype)), _class); | ||
return function reactWrapper(render) { | ||
@@ -609,21 +611,23 @@ var displayName = render.displayName || render.name; | ||
function lomCreateElement() { | ||
var el = arguments[0]; | ||
var attrs = arguments[1]; | ||
var newEl = void 0; | ||
var args = arguments; | ||
var attrs = args[1]; | ||
var el = args[0]; | ||
var newEl; | ||
var isAtomic = typeof el === 'function' && el.constructor.render === undefined; | ||
var id = attrs ? attrs.id : undefined; | ||
var id = attrs ? attrs._id || attrs.id : undefined; | ||
var parentContext = Injector.parentContext; | ||
if (isAtomic) { | ||
if (!attrs) { | ||
attrs = { | ||
__lom_ctx: Injector.parentContext | ||
}; | ||
} else { | ||
attrs.__lom_ctx = Injector.parentContext; | ||
} | ||
if (Injector.parentContext !== undefined) { | ||
newEl = Injector.parentContext.alias(el, id); | ||
if (parentContext !== undefined) { | ||
newEl = parentContext.alias(el, id); | ||
if (newEl === null) return null; | ||
if (newEl !== undefined) el = newEl; | ||
if (!attrs) { | ||
attrs = { | ||
__lom_ctx: parentContext | ||
}; | ||
} else { | ||
attrs.__lom_ctx = parentContext; | ||
} | ||
} | ||
@@ -637,4 +641,4 @@ | ||
} else { | ||
if (Injector.parentContext !== undefined && id) { | ||
newEl = Injector.parentContext.alias(el, id); | ||
if (parentContext !== undefined && id) { | ||
newEl = parentContext.alias(el, id); | ||
if (newEl === null) return null; | ||
@@ -647,3 +651,3 @@ if (newEl !== undefined) el = newEl; | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 2: | ||
@@ -653,34 +657,34 @@ return createElement(newEl, attrs); | ||
case 3: | ||
return createElement(newEl, attrs, arguments[2]); | ||
return createElement(newEl, attrs, args[2]); | ||
case 4: | ||
return createElement(newEl, attrs, arguments[2], arguments[3]); | ||
return createElement(newEl, attrs, args[2], args[3]); | ||
case 5: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4]); | ||
case 6: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5]); | ||
case 7: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6]); | ||
case 8: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6], args[7]); | ||
case 9: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6], args[7], args[8]); | ||
default: | ||
if (isAtomic === false) { | ||
return createElement.apply(null, arguments); | ||
return createElement.apply(null, args); | ||
} | ||
var args = [newEl, attrs]; | ||
var newArgs = [newEl, attrs]; | ||
for (var i = 2, l = arguments.length; i < l; i++) { | ||
args.push(arguments[i]); | ||
for (var i = 2, l = args.length; i < l; i++) { | ||
newArgs.push(args[i]); | ||
} | ||
return createElement.apply(null, args); | ||
return createElement.apply(null, newArgs); | ||
} | ||
@@ -695,3 +699,3 @@ } | ||
if (_typeof(fn) === 'object') { | ||
if (typeof fn === 'object') { | ||
var cons = fn.constructor; | ||
@@ -751,8 +755,17 @@ return cons.displayName || cons.name; | ||
function createMobxDetached(Reaction) { | ||
var LomReaction = function () { | ||
var LomReaction = | ||
/*#__PURE__*/ | ||
function () { | ||
function LomReaction(name, host, propName, reactions) { | ||
var _this = this; | ||
this._reaction = void 0; | ||
this._handler = void 0; | ||
this._cache = void 0; | ||
this._propName = void 0; | ||
this._host = void 0; | ||
this._reactions = void 0; | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._track = void 0; | ||
this._cache = undefined; | ||
@@ -774,3 +787,5 @@ this._host = host; | ||
LomReaction.prototype._onInvalidate = function _onInvalidate() { | ||
var _proto = LomReaction.prototype; | ||
_proto._onInvalidate = function _onInvalidate() { | ||
this._cache = undefined; | ||
@@ -780,7 +795,7 @@ this.value(); | ||
LomReaction.prototype.__track = function __track() { | ||
_proto.__track = function __track() { | ||
this._cache = this._host[this._propName](this._next, this._force); | ||
}; | ||
LomReaction.prototype.value = function value(next, force) { | ||
_proto.value = function value(next, force) { | ||
if (this._cache === undefined || force) { | ||
@@ -799,3 +814,3 @@ this._next = next; | ||
LomReaction.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
this._reaction.dispose(); | ||
@@ -802,0 +817,0 @@ |
@@ -7,2 +7,24 @@ (function (global, factory) { | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
var ATOM_FORCE_NONE = 0; | ||
@@ -14,4 +36,9 @@ var ATOM_FORCE_CACHE = 1; | ||
var DisposableSheet = function () { | ||
var DisposableSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
function DisposableSheet(key, sheet, remover) { | ||
this.__lom_remover = void 0; | ||
this.__lom_sheet = void 0; | ||
this.__lom_key = void 0; | ||
this.__lom_key = key; | ||
@@ -28,3 +55,5 @@ this.__lom_sheet = sheet; | ||
DisposableSheet.prototype.destructor = function destructor() { | ||
var _proto = DisposableSheet.prototype; | ||
_proto.destructor = function destructor() { | ||
this.__lom_remover.remove(this); | ||
@@ -36,4 +65,7 @@ }; | ||
var SheetManager = function () { | ||
var SheetManager = | ||
/*#__PURE__*/ | ||
function () { | ||
function SheetManager(sheetProcessor) { | ||
this._sheetProcessor = void 0; | ||
this._cache = new Map(); | ||
@@ -43,3 +75,5 @@ this._sheetProcessor = sheetProcessor; | ||
SheetManager.prototype.sheet = function sheet(key, css, memoized) { | ||
var _proto2 = SheetManager.prototype; | ||
_proto2.sheet = function sheet(key, css, memoized) { | ||
var result = memoized ? null : this._cache.get(key); | ||
@@ -62,3 +96,3 @@ | ||
SheetManager.prototype.remove = function remove(sheet) { | ||
_proto2.remove = function remove(sheet) { | ||
this._cache.delete(sheet.__lom_key); | ||
@@ -113,54 +147,2 @@ | ||
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; | ||
}; | ||
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; | ||
}; | ||
}(); | ||
var inheritsLoose = function (subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
}; | ||
var _class2; | ||
@@ -173,2 +155,3 @@ var _temp; | ||
var Alias = function Alias(dest) { | ||
this.dest = void 0; | ||
dest[rdiId] = '' + ++depId; | ||
@@ -178,4 +161,10 @@ this.dest = dest; | ||
var Injector = (_temp = _class2 = function () { | ||
var Injector = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function () { | ||
function Injector(items, sheetProcessor, state, displayName, instance, cache) { | ||
this.displayName = void 0; | ||
this.instance = void 0; | ||
this._cache = void 0; | ||
this._state = void 0; | ||
this._resolved = false; | ||
@@ -223,11 +212,13 @@ this._listeners = undefined; | ||
Injector.prototype.toString = function toString() { | ||
var _proto = Injector.prototype; | ||
_proto.toString = function toString() { | ||
return this.displayName; | ||
}; | ||
Injector.prototype.toJSON = function toJSON() { | ||
_proto.toJSON = function toJSON() { | ||
return this._cache; | ||
}; | ||
Injector.prototype.value = function value(key) { | ||
_proto.value = function value(key) { | ||
var id = key[rdiId]; | ||
@@ -248,3 +239,3 @@ | ||
if (state && _typeof(state) === 'object') { | ||
if (state && typeof state === 'object') { | ||
for (var prop in state) { | ||
@@ -262,3 +253,3 @@ | ||
Injector.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
this._cache = undefined; | ||
@@ -268,3 +259,3 @@ this._listeners = undefined; | ||
Injector.prototype.invoke = function invoke(key) { | ||
_proto.invoke = function invoke(key) { | ||
var isFn = key.theme; | ||
@@ -304,3 +295,3 @@ var deps = key.deps; | ||
default: | ||
return key.apply(undefined, a); | ||
return key.apply(void 0, a); | ||
} | ||
@@ -336,3 +327,3 @@ } | ||
Injector.prototype.alias = function alias(key, rawId) { | ||
_proto.alias = function alias(key, rawId) { | ||
var id = rawId; | ||
@@ -354,3 +345,3 @@ | ||
Injector.prototype.invokeWithProps = function invokeWithProps(key, props, propsChanged) { | ||
_proto.invokeWithProps = function invokeWithProps(key, props, propsChanged) { | ||
var deps = key.deps || (key._r === undefined ? undefined : key._r[1]); | ||
@@ -400,11 +391,11 @@ | ||
default: | ||
return key.apply(undefined, [props].concat(a)); | ||
return key.apply(void 0, [props].concat(a)); | ||
} | ||
}; | ||
Injector.prototype.copy = function copy(displayName, instance, items) { | ||
_proto.copy = function copy(displayName, instance, items) { | ||
return new Injector(items, null, this._state, this.displayName + '.' + displayName, instance, Object.create(this._cache)); | ||
}; | ||
Injector.prototype.resolve = function resolve(argDeps) { | ||
_proto.resolve = function resolve(argDeps) { | ||
var result = []; | ||
@@ -417,3 +408,3 @@ if (argDeps === undefined) return result; | ||
if (_typeof(argDep) === 'object') { | ||
if (typeof argDep === 'object') { | ||
var obj = {}; | ||
@@ -488,9 +479,14 @@ | ||
function createReactWrapper(BaseComponent, defaultFromError, detached) { | ||
var _class; | ||
function createReactWrapper(BaseComponent, defaultFromError, detached, rootInjector) { | ||
var _class, _class2, _temp; | ||
var rootInjector = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Injector(); | ||
var AtomizedComponent = (_class = function (_BaseComponent) { | ||
inheritsLoose(AtomizedComponent, _BaseComponent); | ||
if (rootInjector === void 0) { | ||
rootInjector = new Injector(); | ||
} | ||
var AtomizedComponent = (_class = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function (_BaseComponent) { | ||
_inheritsLoose(AtomizedComponent, _BaseComponent); | ||
function AtomizedComponent(props, reactContext) { | ||
@@ -500,3 +496,7 @@ var _this; | ||
_this = _BaseComponent.call(this, props, reactContext) || this; | ||
_this.props = void 0; | ||
_this._propsChanged = true; | ||
_this._injector = void 0; | ||
_this._keys = void 0; | ||
_this._render = void 0; | ||
_this._el = undefined; | ||
@@ -511,7 +511,9 @@ _this._keys = props ? Object.keys(props) : undefined; | ||
AtomizedComponent.prototype.toString = function toString() { | ||
var _proto = AtomizedComponent.prototype; | ||
_proto.toString = function toString() { | ||
return this._injector.displayName; | ||
}; | ||
AtomizedComponent.prototype.shouldComponentUpdate = function shouldComponentUpdate(props) { | ||
_proto.shouldComponentUpdate = function shouldComponentUpdate(props) { | ||
var keys = this._keys; | ||
@@ -534,3 +536,3 @@ if (!keys) return false; | ||
AtomizedComponent.prototype.componentWillUnmount = function componentWillUnmount() { | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
this._el = undefined; | ||
@@ -551,4 +553,4 @@ this._keys = undefined; | ||
AtomizedComponent.prototype.r = function r(element, force) { | ||
var data = void 0; | ||
_proto.r = function r(element, force) { | ||
var data; | ||
var render = this._render; | ||
@@ -579,9 +581,9 @@ var prevContext = Injector.parentContext; | ||
AtomizedComponent.prototype.render = function render() { | ||
_proto.render = function render() { | ||
return this._el === undefined ? this.r(undefined, this._propsChanged ? ATOM_FORCE_CACHE : ATOM_FORCE_NONE) : this._el; | ||
}; | ||
createClass(AtomizedComponent, [{ | ||
_createClass(AtomizedComponent, [{ | ||
key: "displayName", | ||
get: function get$$1() { | ||
get: function get() { | ||
return this.toString(); | ||
@@ -591,3 +593,3 @@ } | ||
return AtomizedComponent; | ||
}(BaseComponent), (_applyDecoratedDescriptor(_class.prototype, "r", [detached], Object.getOwnPropertyDescriptor(_class.prototype, "r"), _class.prototype)), _class); | ||
}(BaseComponent), _class2.displayName = void 0, _class2.render = void 0, _class2.instance = void 0, _temp), (_applyDecoratedDescriptor(_class.prototype, "r", [detached], Object.getOwnPropertyDescriptor(_class.prototype, "r"), _class.prototype)), _class); | ||
return function reactWrapper(render) { | ||
@@ -611,21 +613,23 @@ var displayName = render.displayName || render.name; | ||
function lomCreateElement() { | ||
var el = arguments[0]; | ||
var attrs = arguments[1]; | ||
var newEl = void 0; | ||
var args = arguments; | ||
var attrs = args[1]; | ||
var el = args[0]; | ||
var newEl; | ||
var isAtomic = typeof el === 'function' && el.constructor.render === undefined; | ||
var id = attrs ? attrs.id : undefined; | ||
var id = attrs ? attrs._id || attrs.id : undefined; | ||
var parentContext = Injector.parentContext; | ||
if (isAtomic) { | ||
if (!attrs) { | ||
attrs = { | ||
__lom_ctx: Injector.parentContext | ||
}; | ||
} else { | ||
attrs.__lom_ctx = Injector.parentContext; | ||
} | ||
if (Injector.parentContext !== undefined) { | ||
newEl = Injector.parentContext.alias(el, id); | ||
if (parentContext !== undefined) { | ||
newEl = parentContext.alias(el, id); | ||
if (newEl === null) return null; | ||
if (newEl !== undefined) el = newEl; | ||
if (!attrs) { | ||
attrs = { | ||
__lom_ctx: parentContext | ||
}; | ||
} else { | ||
attrs.__lom_ctx = parentContext; | ||
} | ||
} | ||
@@ -639,4 +643,4 @@ | ||
} else { | ||
if (Injector.parentContext !== undefined && id) { | ||
newEl = Injector.parentContext.alias(el, id); | ||
if (parentContext !== undefined && id) { | ||
newEl = parentContext.alias(el, id); | ||
if (newEl === null) return null; | ||
@@ -649,3 +653,3 @@ if (newEl !== undefined) el = newEl; | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 2: | ||
@@ -655,34 +659,34 @@ return createElement(newEl, attrs); | ||
case 3: | ||
return createElement(newEl, attrs, arguments[2]); | ||
return createElement(newEl, attrs, args[2]); | ||
case 4: | ||
return createElement(newEl, attrs, arguments[2], arguments[3]); | ||
return createElement(newEl, attrs, args[2], args[3]); | ||
case 5: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4]); | ||
case 6: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5]); | ||
case 7: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6]); | ||
case 8: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6], args[7]); | ||
case 9: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]); | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5], args[6], args[7], args[8]); | ||
default: | ||
if (isAtomic === false) { | ||
return createElement.apply(null, arguments); | ||
return createElement.apply(null, args); | ||
} | ||
var args = [newEl, attrs]; | ||
var newArgs = [newEl, attrs]; | ||
for (var i = 2, l = arguments.length; i < l; i++) { | ||
args.push(arguments[i]); | ||
for (var i = 2, l = args.length; i < l; i++) { | ||
newArgs.push(args[i]); | ||
} | ||
return createElement.apply(null, args); | ||
return createElement.apply(null, newArgs); | ||
} | ||
@@ -697,3 +701,3 @@ } | ||
if (_typeof(fn) === 'object') { | ||
if (typeof fn === 'object') { | ||
var cons = fn.constructor; | ||
@@ -753,8 +757,17 @@ return cons.displayName || cons.name; | ||
function createMobxDetached(Reaction) { | ||
var LomReaction = function () { | ||
var LomReaction = | ||
/*#__PURE__*/ | ||
function () { | ||
function LomReaction(name, host, propName, reactions) { | ||
var _this = this; | ||
this._reaction = void 0; | ||
this._handler = void 0; | ||
this._cache = void 0; | ||
this._propName = void 0; | ||
this._host = void 0; | ||
this._reactions = void 0; | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._track = void 0; | ||
this._cache = undefined; | ||
@@ -776,3 +789,5 @@ this._host = host; | ||
LomReaction.prototype._onInvalidate = function _onInvalidate() { | ||
var _proto = LomReaction.prototype; | ||
_proto._onInvalidate = function _onInvalidate() { | ||
this._cache = undefined; | ||
@@ -782,7 +797,7 @@ this.value(); | ||
LomReaction.prototype.__track = function __track() { | ||
_proto.__track = function __track() { | ||
this._cache = this._host[this._propName](this._next, this._force); | ||
}; | ||
LomReaction.prototype.value = function value(next, force) { | ||
_proto.value = function value(next, force) { | ||
if (this._cache === undefined || force) { | ||
@@ -801,3 +816,3 @@ this._next = next; | ||
LomReaction.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
this._reaction.dispose(); | ||
@@ -804,0 +819,0 @@ |
{ | ||
"name": "reactive-di", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"description": "Reactive dependency injection", | ||
@@ -56,12 +56,12 @@ "publishConfig": { | ||
"devDependencies": { | ||
"babel-plugin-external-helpers": "^7.0.0-alpha.19", | ||
"babel-plugin-transform-class-properties": "^7.0.0-alpha.19", | ||
"babel-plugin-transform-decorators": "^7.0.0-alpha.19", | ||
"babel-preset-es2015": "^7.0.0-alpha.19", | ||
"babel-preset-flow": "^7.0.0-alpha.19", | ||
"babel-register": "^7.0.0-alpha.19", | ||
"babelrc-rollup": "^3.0.0", | ||
"@babel/core": "^7.0.0-beta.31", | ||
"@babel/plugin-external-helpers": "^7.0.0-beta.31", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.31", | ||
"@babel/plugin-proposal-decorators": "^7.0.0-beta.31", | ||
"@babel/plugin-transform-flow-strip-types": "^7.0.0-beta.31", | ||
"@babel/preset-es2015": "^7.0.0-beta.31", | ||
"@babel/register": "^7.0.0-beta.31", | ||
"chokidar-cli": "^1.2.0", | ||
"flow-bin": "^0.58.0", | ||
"lom_atom": "^2.0.6", | ||
"lom_atom": "^2.0.7", | ||
"mobx": "^3.3.1", | ||
@@ -73,3 +73,3 @@ "mocha": "^4.0.1", | ||
"rollup": "^0.48.2", | ||
"rollup-plugin-babel": "=3.0.0-alpha.17", | ||
"rollup-plugin-babel": "^4.0.0-beta.0", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
@@ -79,4 +79,3 @@ "rollup-plugin-uglify": "^2.0.1", | ||
"uglify-es": "^3.1.6" | ||
}, | ||
"dependencies": {} | ||
} | ||
} |
@@ -6,7 +6,15 @@ import babel from 'rollup-plugin-babel' | ||
import {minify} from 'uglify-es' | ||
import babelrc from 'babelrc-rollup' | ||
import fs from 'fs' | ||
import path from 'path' | ||
const pkg = JSON.parse(fs.readFileSync('./package.json')) | ||
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'))) | ||
const babelrc = JSON.parse(fs.readFileSync(path.join(__dirname, '.babelrc'))) | ||
const magic = 'commonjs' | ||
babelrc.babelrc = false | ||
babelrc.plugins = babelrc.plugins.map( | ||
plugin => (Array.isArray(plugin) ? (plugin[0] || ''): plugin).indexOf(magic) >= 0 ? null : plugin | ||
).filter(Boolean) | ||
const uglifyOpts = { | ||
@@ -30,3 +38,3 @@ warnings: true, | ||
resolve(), | ||
babel(babelrc()) | ||
babel(babelrc) | ||
].concat(process.env.UGLIFY === '1' ? [uglify(uglifyOpts, minify)] : []), | ||
@@ -33,0 +41,0 @@ output: [ |
@@ -11,17 +11,19 @@ // @flow | ||
function lomCreateElement() { | ||
let el = arguments[0] | ||
let attrs: ?Object = arguments[1] | ||
const args = arguments | ||
let attrs = args[1] | ||
let el = args[0] | ||
let newEl | ||
const isAtomic = typeof el === 'function' && el.constructor.render === undefined | ||
const id = attrs ? attrs.id : undefined | ||
const id: string | void = attrs ? attrs._id || attrs.id : undefined | ||
const parentContext: Injector | void = Injector.parentContext | ||
if (isAtomic) { | ||
if (!attrs) { | ||
attrs = {__lom_ctx: Injector.parentContext} | ||
} else { | ||
attrs.__lom_ctx = Injector.parentContext | ||
} | ||
if (Injector.parentContext !== undefined) { | ||
newEl = Injector.parentContext.alias(el, id) | ||
if (parentContext !== undefined) { | ||
newEl = parentContext.alias(el, id) | ||
if (newEl === null) return null | ||
if (newEl !== undefined) el = newEl | ||
if (!attrs) { | ||
attrs = {__lom_ctx: parentContext} | ||
} else { | ||
attrs.__lom_ctx = parentContext | ||
} | ||
} | ||
@@ -34,4 +36,4 @@ | ||
} else { | ||
if (Injector.parentContext !== undefined && id) { | ||
newEl = Injector.parentContext.alias(el, id) | ||
if (parentContext !== undefined && id) { | ||
newEl = parentContext.alias(el, id) | ||
if (newEl === null) return null | ||
@@ -42,32 +44,31 @@ if (newEl !== undefined) el = newEl | ||
} | ||
switch(arguments.length) { | ||
switch(args.length) { | ||
case 2: | ||
return createElement(newEl, attrs) | ||
case 3: | ||
return createElement(newEl, attrs, arguments[2]) | ||
return createElement(newEl, attrs, args[2]) | ||
case 4: | ||
return createElement(newEl, attrs, arguments[2], arguments[3]) | ||
return createElement(newEl, attrs, args[2], args[3]) | ||
case 5: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4]) | ||
return createElement(newEl, attrs, args[2], args[3], args[4]) | ||
case 6: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], arguments[4], arguments[5]) | ||
return createElement(newEl, attrs, args[2], args[3], args[4], args[5]) | ||
case 7: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], | ||
arguments[4], arguments[5], arguments[6]) | ||
return createElement(newEl, attrs, args[2], args[3], | ||
args[4], args[5], args[6]) | ||
case 8: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], | ||
arguments[4], arguments[5], arguments[6], arguments[7]) | ||
return createElement(newEl, attrs, args[2], args[3], | ||
args[4], args[5], args[6], args[7]) | ||
case 9: | ||
return createElement(newEl, attrs, arguments[2], arguments[3], | ||
arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]) | ||
return createElement(newEl, attrs, args[2], args[3], | ||
args[4], args[5], args[6], args[7], args[8]) | ||
default: | ||
if (isAtomic === false) { | ||
return createElement.apply(null, arguments) | ||
return createElement.apply(null, args) | ||
} | ||
const args = [newEl, attrs] | ||
for (let i = 2, l = arguments.length; i < l; i++) { | ||
args.push(arguments[i]) | ||
const newArgs = [newEl, attrs] | ||
for (let i = 2, l = args.length; i < l; i++) { | ||
newArgs.push(args[i]) | ||
} | ||
return createElement.apply(null, args) | ||
return createElement.apply(null, newArgs) | ||
} | ||
@@ -74,0 +75,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
304732
2709