Comparing version 2.0.6 to 2.0.7
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="2.0.7"></a> | ||
## [2.0.7](https://github.com/zerkalica/lom_atom/compare/v2.0.6...v2.0.7) (2017-11-06) | ||
<a name="2.0.6"></a> | ||
@@ -7,0 +12,0 @@ ## [2.0.6](https://github.com/zerkalica/lom_atom/compare/v2.0.5...v2.0.6) (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; | ||
} | ||
// eslint-disable-line | ||
@@ -12,56 +34,4 @@ var ATOM_FORCE_NONE = 0; | ||
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 throwOnAccess = { | ||
get: function get$$1(target) { | ||
get: function get(target) { | ||
throw target.valueOf(); | ||
@@ -76,9 +46,14 @@ }, | ||
} | ||
var AtomWait = function (_Error) { | ||
inheritsLoose(AtomWait, _Error); | ||
var AtomWait = | ||
/*#__PURE__*/ | ||
function (_Error) { | ||
_inheritsLoose(AtomWait, _Error); | ||
function AtomWait() { | ||
function AtomWait(message) { | ||
var _this; | ||
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Wait...'; | ||
if (message === void 0) { | ||
message = 'Wait...'; | ||
} | ||
_this = _Error.call(this, message) || this // $FlowFixMe new.target | ||
@@ -124,6 +99,9 @@ ; | ||
var done = Symbol('lom_conform_done'); | ||
function conform(target, source, isComponent) { | ||
var stack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
function conform(target, source, isComponent, stack) { | ||
if (stack === void 0) { | ||
stack = []; | ||
} | ||
if (target === source) return source; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
if (isComponent || !target || typeof target !== 'object' || !source || typeof source !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
target[done] = true; | ||
@@ -160,6 +138,19 @@ var conformHandler = handlers.get(target.constructor); | ||
var Atom = function () { | ||
var Atom = | ||
/*#__PURE__*/ | ||
function () { | ||
function Atom(field, owner, context, hostAtoms, key, keyHash, isComponent) { | ||
this.status = void 0; | ||
this.field = void 0; | ||
this.owner = void 0; | ||
this.current = void 0; | ||
this._next = void 0; | ||
this._suggested = void 0; | ||
this.key = void 0; | ||
this.isComponent = void 0; | ||
this._masters = null; | ||
this._slaves = null; | ||
this._context = void 0; | ||
this._hostAtoms = void 0; | ||
this._keyHash = void 0; | ||
this._keyHash = keyHash; | ||
@@ -178,3 +169,5 @@ this.key = key; | ||
Atom.prototype.toString = function toString() { | ||
var _proto = Atom.prototype; | ||
_proto.toString = function toString() { | ||
var hc = this.owner.constructor; | ||
@@ -185,7 +178,7 @@ var k = this.key; | ||
Atom.prototype.toJSON = function toJSON() { | ||
_proto.toJSON = function toJSON() { | ||
return this.current; | ||
}; | ||
Atom.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
if (this.status === ATOM_STATUS_DESTROYED) return; | ||
@@ -214,3 +207,3 @@ | ||
Atom.prototype._get = function _get(force) { | ||
_proto._get = function _get$$1(force) { | ||
var slave = this._context.last; | ||
@@ -240,3 +233,3 @@ | ||
Atom.prototype.value = function value(next, force) { | ||
_proto.value = function value(next, force) { | ||
if (next === undefined) return this._get(force); | ||
@@ -256,3 +249,3 @@ if (force === ATOM_FORCE_CACHE) return this._push(next); | ||
Atom.prototype.actualize = function actualize() { | ||
_proto.actualize = function actualize() { | ||
if (this.status === ATOM_STATUS_PULLING) { | ||
@@ -279,3 +272,3 @@ throw new Error("Cyclic atom dependency of " + String(this)); | ||
Atom.prototype._push = function _push(nextRaw) { | ||
_proto._push = function _push(nextRaw) { | ||
this.status = ATOM_STATUS_ACTUAL; | ||
@@ -305,3 +298,3 @@ | ||
Atom.prototype._pull = function _pull(force) { | ||
_proto._pull = function _pull(force) { | ||
if (this._masters) { | ||
@@ -311,3 +304,3 @@ this._masters.forEach(disleadThis, this); | ||
var newValue = void 0; | ||
var newValue; | ||
this.status = ATOM_STATUS_PULLING; | ||
@@ -333,3 +326,3 @@ var context = this._context; | ||
Atom.prototype.dislead = function dislead(slave) { | ||
_proto.dislead = function dislead(slave) { | ||
var slaves = this._slaves; | ||
@@ -348,3 +341,3 @@ | ||
Atom.prototype._checkSlaves = function _checkSlaves() { | ||
_proto._checkSlaves = function _checkSlaves() { | ||
if (this._slaves) { | ||
@@ -357,3 +350,3 @@ this._slaves.forEach(checkSlave); | ||
Atom.prototype.check = function check() { | ||
_proto.check = function check() { | ||
if (this.status === ATOM_STATUS_ACTUAL) { | ||
@@ -366,3 +359,3 @@ this.status = ATOM_STATUS_CHECKING; | ||
Atom.prototype.obsolete = function obsolete() { | ||
_proto.obsolete = function obsolete() { | ||
if (this.status !== ATOM_STATUS_OBSOLETE) { | ||
@@ -375,3 +368,3 @@ this.status = ATOM_STATUS_OBSOLETE; | ||
Atom.prototype.addMaster = function addMaster(master) { | ||
_proto.addMaster = function addMaster(master) { | ||
if (!this._masters) { | ||
@@ -384,5 +377,5 @@ this._masters = new Set(); | ||
createClass(Atom, [{ | ||
_createClass(Atom, [{ | ||
key: "displayName", | ||
get: function get$$1() { | ||
get: function get() { | ||
return this.toString(); | ||
@@ -408,22 +401,28 @@ } | ||
var BaseLogger = function () { | ||
var BaseLogger = | ||
/*#__PURE__*/ | ||
function () { | ||
function BaseLogger() {} | ||
BaseLogger.prototype.create = function create(owner, field, key, namespace) {}; | ||
var _proto = BaseLogger.prototype; | ||
BaseLogger.prototype.onDestruct = function onDestruct(atom, namespace) {}; | ||
_proto.create = function create(owner, field, key, namespace) {}; | ||
BaseLogger.prototype.sync = function sync() {}; | ||
_proto.onDestruct = function onDestruct(atom, namespace) {}; | ||
BaseLogger.prototype.status = function status(_status, atom, namespace) {}; | ||
_proto.sync = function sync() {}; | ||
BaseLogger.prototype.error = function error(atom, err, namespace) {}; | ||
_proto.status = function status(_status, atom, namespace) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
_proto.error = function error(atom, err, namespace) {}; | ||
_proto.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
return BaseLogger; | ||
}(); | ||
var ConsoleLogger = function (_BaseLogger) { | ||
inheritsLoose(ConsoleLogger, _BaseLogger); | ||
var ConsoleLogger = | ||
/*#__PURE__*/ | ||
function (_BaseLogger) { | ||
_inheritsLoose(ConsoleLogger, _BaseLogger); | ||
@@ -434,15 +433,17 @@ function ConsoleLogger() { | ||
ConsoleLogger.prototype.sync = function sync() { | ||
var _proto2 = ConsoleLogger.prototype; | ||
_proto2.sync = function sync() { | ||
console.log('sync'); | ||
}; | ||
ConsoleLogger.prototype.status = function status(_status2, atom, namespace) { | ||
_proto2.status = function status(_status2, atom, namespace) { | ||
console.log(namespace, _status2, atom.displayName); | ||
}; | ||
ConsoleLogger.prototype.error = function error(atom, err, namespace) { | ||
_proto2.error = function error(atom, err, namespace) { | ||
console.log(namespace, 'error', atom.displayName, err); | ||
}; | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
_proto2.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
console.log(namespace, isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
@@ -454,5 +455,7 @@ }; | ||
var Context = function () { | ||
var Context = | ||
/*#__PURE__*/ | ||
function () { | ||
function Context() { | ||
var _this2 = this; | ||
var _this = this; | ||
@@ -468,6 +471,6 @@ this.last = null; | ||
this.__run = function () { | ||
if (_this2._scheduled) { | ||
_this2._scheduled = false; | ||
if (_this._scheduled) { | ||
_this._scheduled = false; | ||
_this2._run(); | ||
_this._run(); | ||
} | ||
@@ -480,3 +483,5 @@ }; | ||
Context.prototype.create = function create(atom) { | ||
var _proto3 = Context.prototype; | ||
_proto3.create = function create(atom) { | ||
this._owners.set(atom, atom.owner); | ||
@@ -489,5 +494,6 @@ | ||
Context.prototype._destroyValue = function _destroyValue(atom, from) { | ||
if (from && !(from instanceof Error) && _typeof(from) === 'object' && typeof from.destructor === 'function' && this._owners.get(from) === atom) { | ||
_proto3._destroyValue = function _destroyValue(atom, from) { | ||
if (typeof from === 'object' && this._owners.get(from) === atom) { | ||
try { | ||
from.destructor(); | ||
@@ -503,3 +509,3 @@ } catch (e) { | ||
Context.prototype.destroyHost = function destroyHost(atom) { | ||
_proto3.destroyHost = function destroyHost(atom) { | ||
this._destroyValue(atom, atom.current); | ||
@@ -512,10 +518,10 @@ | ||
Context.prototype.setLogger = function setLogger(logger) { | ||
_proto3.setLogger = function setLogger(logger) { | ||
this._logger = logger; | ||
}; | ||
Context.prototype.newValue = function newValue(atom, from, to, isActualize) { | ||
_proto3.newValue = function newValue(atom, from, to, isActualize) { | ||
this._destroyValue(atom, from); | ||
if (to && !(to instanceof Error) && _typeof(to) === 'object' && typeof to.destructor === 'function') { | ||
if (to && typeof to === 'object' && !(to instanceof Error) && typeof to.destructor === 'function') { | ||
this._owners.set(to, atom); | ||
@@ -535,3 +541,3 @@ } | ||
Context.prototype.proposeToPull = function proposeToPull(atom) { | ||
_proto3.proposeToPull = function proposeToPull(atom) { | ||
if (this._logger !== undefined) { | ||
@@ -546,3 +552,3 @@ this._logger.status('proposeToPull', atom, this._namespace); | ||
Context.prototype.proposeToReap = function proposeToReap(atom) { | ||
_proto3.proposeToReap = function proposeToReap(atom) { | ||
if (this._logger !== undefined) { | ||
@@ -557,7 +563,7 @@ this._logger.status('proposeToReap', atom, this._namespace); | ||
Context.prototype.unreap = function unreap(atom) { | ||
_proto3.unreap = function unreap(atom) { | ||
this._reaping.delete(atom); | ||
}; | ||
Context.prototype._schedule = function _schedule() { | ||
_proto3._schedule = function _schedule() { | ||
if (!this._scheduled) { | ||
@@ -569,3 +575,3 @@ scheduleNative(this.__run); | ||
Context.prototype._run = function _run() { | ||
_proto3._run = function _run() { | ||
this._schedule(); | ||
@@ -608,3 +614,3 @@ | ||
Context.prototype.beginTransaction = function beginTransaction(namespace) { | ||
_proto3.beginTransaction = function beginTransaction(namespace) { | ||
var result = this._namespace; | ||
@@ -616,3 +622,3 @@ this._namespace = namespace; | ||
Context.prototype.endTransaction = function endTransaction(prev) { | ||
_proto3.endTransaction = function endTransaction(prev) { | ||
this._namespace = prev; | ||
@@ -646,3 +652,3 @@ | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -674,9 +680,9 @@ } | ||
function createGetSetHandler(get$$1, set$$1) { | ||
function createGetSetHandler(get, set) { | ||
return function getSetHandler(next) { | ||
if (next === undefined) { | ||
return get$$1.call(this); | ||
return get.call(this); | ||
} | ||
set$$1.call(this, next); | ||
set.call(this, next); | ||
return next; | ||
@@ -717,3 +723,3 @@ }; | ||
Object.defineProperty(proto, name + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -725,3 +731,3 @@ } | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
var atom = hostAtoms.get(this); | ||
@@ -738,3 +744,3 @@ | ||
}, | ||
set: function set$$1(val) { | ||
set: function set(val) { | ||
var atom = hostAtoms.get(this); | ||
@@ -761,3 +767,3 @@ | ||
var value = params[key]; | ||
result += "." + key + ":" + (_typeof(value) === 'object' ? JSON.stringify(value) : value); | ||
result += "." + key + ":" + (typeof value === 'object' ? JSON.stringify(value) : value); | ||
} | ||
@@ -771,3 +777,3 @@ | ||
if (params instanceof Array) return JSON.stringify(params); | ||
if (_typeof(params) === 'object') return getKeyFromObj(params); | ||
if (typeof params === 'object') return getKeyFromObj(params); | ||
return '' + params; | ||
@@ -787,3 +793,3 @@ } | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -824,4 +830,6 @@ } | ||
function memkey() { | ||
if (arguments.length === 3) { | ||
return memKeyMethod(arguments[0], arguments[1], arguments[2]); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return memKeyMethod(args[0], args[1], args[2]); | ||
} | ||
@@ -834,3 +842,3 @@ | ||
var forceProxyOpts = { | ||
get: function get$$1(t, name) { | ||
get: function get(t, name) { | ||
var forceFn = t[name + "*"]; | ||
@@ -846,3 +854,3 @@ | ||
}, | ||
set: function set$$1(t, name, val) { | ||
set: function set(t, name, val) { | ||
if (t[name + "*"] === undefined) { | ||
@@ -863,3 +871,3 @@ // get/set handler | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
var proxy = proxyMap.get(this); | ||
@@ -884,7 +892,8 @@ | ||
function action() { | ||
var result = void 0; | ||
var result; | ||
var oldNamespace = context.beginTransaction(name); | ||
var args = arguments; | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: | ||
@@ -895,23 +904,23 @@ result = t[hk](); | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
result = t[hk](args[0]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
result = t[hk](args[0], args[1]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
result = t[hk](args[0], args[1], args[2]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
result = t[hk](args[0], args[1], args[2], args[3]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
result = t[hk](args[0], args[1], args[2], args[3], args[4]); | ||
break; | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
result = t[hk].apply(t, args); | ||
} | ||
@@ -933,7 +942,8 @@ } finally { | ||
function action() { | ||
var result = void 0; | ||
var result; | ||
var oldNamespace = context.beginTransaction(name); | ||
var args = arguments; | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: | ||
@@ -944,23 +954,23 @@ result = fn(); | ||
case 1: | ||
result = fn(arguments[0]); | ||
result = fn(args[0]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
result = fn(args[0], args[1]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
result = fn(args[0], args[1], args[2]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
result = fn(args[0], args[1], args[2], args[3]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
result = fn(args[0], args[1], args[2], args[3], args[4]); | ||
break; | ||
default: | ||
result = fn.apply(null, arguments); | ||
result = fn.apply(null, args); | ||
} | ||
@@ -990,3 +1000,3 @@ } finally { | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
if (definingProperty) { | ||
@@ -1009,11 +1019,15 @@ return this[hk]; | ||
function action() { | ||
if (arguments.length === 3) { | ||
return actionMethod(arguments[0], arguments[1], arguments[2], defaultContext); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return actionMethod(args[0], args[1], args[2], defaultContext); | ||
} | ||
return createActionFn(arguments[0], arguments[1], defaultContext); | ||
return createActionFn(args[0], args[1], defaultContext); | ||
} | ||
function mem() { | ||
if (arguments.length === 3) { | ||
return arguments[2].value === undefined ? memProp(arguments[0], arguments[1], arguments[2]) : memMethod(arguments[0], arguments[1], arguments[2]); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return args[2].value === undefined ? memProp(args[0], args[1], args[2]) : memMethod(args[0], args[1], args[2]); | ||
} | ||
@@ -1020,0 +1034,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; | ||
} | ||
// eslint-disable-line | ||
@@ -17,56 +39,4 @@ var ATOM_FORCE_NONE = 0; | ||
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 throwOnAccess = { | ||
get: function get$$1(target) { | ||
get: function get(target) { | ||
throw target.valueOf(); | ||
@@ -81,9 +51,14 @@ }, | ||
} | ||
var AtomWait = function (_Error) { | ||
inheritsLoose(AtomWait, _Error); | ||
var AtomWait = | ||
/*#__PURE__*/ | ||
function (_Error) { | ||
_inheritsLoose(AtomWait, _Error); | ||
function AtomWait() { | ||
function AtomWait(message) { | ||
var _this; | ||
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Wait...'; | ||
if (message === void 0) { | ||
message = 'Wait...'; | ||
} | ||
_this = _Error.call(this, message) || this // $FlowFixMe new.target | ||
@@ -129,6 +104,9 @@ ; | ||
var done = Symbol('lom_conform_done'); | ||
function conform(target, source, isComponent) { | ||
var stack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
function conform(target, source, isComponent, stack) { | ||
if (stack === void 0) { | ||
stack = []; | ||
} | ||
if (target === source) return source; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
if (isComponent || !target || typeof target !== 'object' || !source || typeof source !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
target[done] = true; | ||
@@ -165,6 +143,19 @@ var conformHandler = handlers.get(target.constructor); | ||
var Atom = function () { | ||
var Atom = | ||
/*#__PURE__*/ | ||
function () { | ||
function Atom(field, owner, context, hostAtoms, key, keyHash, isComponent) { | ||
this.status = void 0; | ||
this.field = void 0; | ||
this.owner = void 0; | ||
this.current = void 0; | ||
this._next = void 0; | ||
this._suggested = void 0; | ||
this.key = void 0; | ||
this.isComponent = void 0; | ||
this._masters = null; | ||
this._slaves = null; | ||
this._context = void 0; | ||
this._hostAtoms = void 0; | ||
this._keyHash = void 0; | ||
this._keyHash = keyHash; | ||
@@ -183,3 +174,5 @@ this.key = key; | ||
Atom.prototype.toString = function toString() { | ||
var _proto = Atom.prototype; | ||
_proto.toString = function toString() { | ||
var hc = this.owner.constructor; | ||
@@ -190,7 +183,7 @@ var k = this.key; | ||
Atom.prototype.toJSON = function toJSON() { | ||
_proto.toJSON = function toJSON() { | ||
return this.current; | ||
}; | ||
Atom.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
if (this.status === ATOM_STATUS_DESTROYED) return; | ||
@@ -219,3 +212,3 @@ | ||
Atom.prototype._get = function _get(force) { | ||
_proto._get = function _get$$1(force) { | ||
var slave = this._context.last; | ||
@@ -245,3 +238,3 @@ | ||
Atom.prototype.value = function value(next, force) { | ||
_proto.value = function value(next, force) { | ||
if (next === undefined) return this._get(force); | ||
@@ -261,3 +254,3 @@ if (force === ATOM_FORCE_CACHE) return this._push(next); | ||
Atom.prototype.actualize = function actualize() { | ||
_proto.actualize = function actualize() { | ||
if (this.status === ATOM_STATUS_PULLING) { | ||
@@ -284,3 +277,3 @@ throw new Error("Cyclic atom dependency of " + String(this)); | ||
Atom.prototype._push = function _push(nextRaw) { | ||
_proto._push = function _push(nextRaw) { | ||
this.status = ATOM_STATUS_ACTUAL; | ||
@@ -310,3 +303,3 @@ | ||
Atom.prototype._pull = function _pull(force) { | ||
_proto._pull = function _pull(force) { | ||
if (this._masters) { | ||
@@ -316,3 +309,3 @@ this._masters.forEach(disleadThis, this); | ||
var newValue = void 0; | ||
var newValue; | ||
this.status = ATOM_STATUS_PULLING; | ||
@@ -338,3 +331,3 @@ var context = this._context; | ||
Atom.prototype.dislead = function dislead(slave) { | ||
_proto.dislead = function dislead(slave) { | ||
var slaves = this._slaves; | ||
@@ -353,3 +346,3 @@ | ||
Atom.prototype._checkSlaves = function _checkSlaves() { | ||
_proto._checkSlaves = function _checkSlaves() { | ||
if (this._slaves) { | ||
@@ -362,3 +355,3 @@ this._slaves.forEach(checkSlave); | ||
Atom.prototype.check = function check() { | ||
_proto.check = function check() { | ||
if (this.status === ATOM_STATUS_ACTUAL) { | ||
@@ -371,3 +364,3 @@ this.status = ATOM_STATUS_CHECKING; | ||
Atom.prototype.obsolete = function obsolete() { | ||
_proto.obsolete = function obsolete() { | ||
if (this.status !== ATOM_STATUS_OBSOLETE) { | ||
@@ -380,3 +373,3 @@ this.status = ATOM_STATUS_OBSOLETE; | ||
Atom.prototype.addMaster = function addMaster(master) { | ||
_proto.addMaster = function addMaster(master) { | ||
if (!this._masters) { | ||
@@ -389,5 +382,5 @@ this._masters = new Set(); | ||
createClass(Atom, [{ | ||
_createClass(Atom, [{ | ||
key: "displayName", | ||
get: function get$$1() { | ||
get: function get() { | ||
return this.toString(); | ||
@@ -413,22 +406,28 @@ } | ||
var BaseLogger = function () { | ||
var BaseLogger = | ||
/*#__PURE__*/ | ||
function () { | ||
function BaseLogger() {} | ||
BaseLogger.prototype.create = function create(owner, field, key, namespace) {}; | ||
var _proto = BaseLogger.prototype; | ||
BaseLogger.prototype.onDestruct = function onDestruct(atom, namespace) {}; | ||
_proto.create = function create(owner, field, key, namespace) {}; | ||
BaseLogger.prototype.sync = function sync() {}; | ||
_proto.onDestruct = function onDestruct(atom, namespace) {}; | ||
BaseLogger.prototype.status = function status(_status, atom, namespace) {}; | ||
_proto.sync = function sync() {}; | ||
BaseLogger.prototype.error = function error(atom, err, namespace) {}; | ||
_proto.status = function status(_status, atom, namespace) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
_proto.error = function error(atom, err, namespace) {}; | ||
_proto.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
return BaseLogger; | ||
}(); | ||
var ConsoleLogger = function (_BaseLogger) { | ||
inheritsLoose(ConsoleLogger, _BaseLogger); | ||
var ConsoleLogger = | ||
/*#__PURE__*/ | ||
function (_BaseLogger) { | ||
_inheritsLoose(ConsoleLogger, _BaseLogger); | ||
@@ -439,15 +438,17 @@ function ConsoleLogger() { | ||
ConsoleLogger.prototype.sync = function sync() { | ||
var _proto2 = ConsoleLogger.prototype; | ||
_proto2.sync = function sync() { | ||
console.log('sync'); | ||
}; | ||
ConsoleLogger.prototype.status = function status(_status2, atom, namespace) { | ||
_proto2.status = function status(_status2, atom, namespace) { | ||
console.log(namespace, _status2, atom.displayName); | ||
}; | ||
ConsoleLogger.prototype.error = function error(atom, err, namespace) { | ||
_proto2.error = function error(atom, err, namespace) { | ||
console.log(namespace, 'error', atom.displayName, err); | ||
}; | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
_proto2.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
console.log(namespace, isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
@@ -459,5 +460,7 @@ }; | ||
var Context = function () { | ||
var Context = | ||
/*#__PURE__*/ | ||
function () { | ||
function Context() { | ||
var _this2 = this; | ||
var _this = this; | ||
@@ -473,6 +476,6 @@ this.last = null; | ||
this.__run = function () { | ||
if (_this2._scheduled) { | ||
_this2._scheduled = false; | ||
if (_this._scheduled) { | ||
_this._scheduled = false; | ||
_this2._run(); | ||
_this._run(); | ||
} | ||
@@ -485,3 +488,5 @@ }; | ||
Context.prototype.create = function create(atom) { | ||
var _proto3 = Context.prototype; | ||
_proto3.create = function create(atom) { | ||
this._owners.set(atom, atom.owner); | ||
@@ -494,5 +499,6 @@ | ||
Context.prototype._destroyValue = function _destroyValue(atom, from) { | ||
if (from && !(from instanceof Error) && _typeof(from) === 'object' && typeof from.destructor === 'function' && this._owners.get(from) === atom) { | ||
_proto3._destroyValue = function _destroyValue(atom, from) { | ||
if (typeof from === 'object' && this._owners.get(from) === atom) { | ||
try { | ||
from.destructor(); | ||
@@ -508,3 +514,3 @@ } catch (e) { | ||
Context.prototype.destroyHost = function destroyHost(atom) { | ||
_proto3.destroyHost = function destroyHost(atom) { | ||
this._destroyValue(atom, atom.current); | ||
@@ -517,10 +523,10 @@ | ||
Context.prototype.setLogger = function setLogger(logger) { | ||
_proto3.setLogger = function setLogger(logger) { | ||
this._logger = logger; | ||
}; | ||
Context.prototype.newValue = function newValue(atom, from, to, isActualize) { | ||
_proto3.newValue = function newValue(atom, from, to, isActualize) { | ||
this._destroyValue(atom, from); | ||
if (to && !(to instanceof Error) && _typeof(to) === 'object' && typeof to.destructor === 'function') { | ||
if (to && typeof to === 'object' && !(to instanceof Error) && typeof to.destructor === 'function') { | ||
this._owners.set(to, atom); | ||
@@ -540,3 +546,3 @@ } | ||
Context.prototype.proposeToPull = function proposeToPull(atom) { | ||
_proto3.proposeToPull = function proposeToPull(atom) { | ||
if (this._logger !== undefined) { | ||
@@ -551,3 +557,3 @@ this._logger.status('proposeToPull', atom, this._namespace); | ||
Context.prototype.proposeToReap = function proposeToReap(atom) { | ||
_proto3.proposeToReap = function proposeToReap(atom) { | ||
if (this._logger !== undefined) { | ||
@@ -562,7 +568,7 @@ this._logger.status('proposeToReap', atom, this._namespace); | ||
Context.prototype.unreap = function unreap(atom) { | ||
_proto3.unreap = function unreap(atom) { | ||
this._reaping.delete(atom); | ||
}; | ||
Context.prototype._schedule = function _schedule() { | ||
_proto3._schedule = function _schedule() { | ||
if (!this._scheduled) { | ||
@@ -574,3 +580,3 @@ scheduleNative(this.__run); | ||
Context.prototype._run = function _run() { | ||
_proto3._run = function _run() { | ||
this._schedule(); | ||
@@ -613,3 +619,3 @@ | ||
Context.prototype.beginTransaction = function beginTransaction(namespace) { | ||
_proto3.beginTransaction = function beginTransaction(namespace) { | ||
var result = this._namespace; | ||
@@ -621,3 +627,3 @@ this._namespace = namespace; | ||
Context.prototype.endTransaction = function endTransaction(prev) { | ||
_proto3.endTransaction = function endTransaction(prev) { | ||
this._namespace = prev; | ||
@@ -651,3 +657,3 @@ | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -679,9 +685,9 @@ } | ||
function createGetSetHandler(get$$1, set$$1) { | ||
function createGetSetHandler(get, set) { | ||
return function getSetHandler(next) { | ||
if (next === undefined) { | ||
return get$$1.call(this); | ||
return get.call(this); | ||
} | ||
set$$1.call(this, next); | ||
set.call(this, next); | ||
return next; | ||
@@ -722,3 +728,3 @@ }; | ||
Object.defineProperty(proto, name + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -730,3 +736,3 @@ } | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
var atom = hostAtoms.get(this); | ||
@@ -743,3 +749,3 @@ | ||
}, | ||
set: function set$$1(val) { | ||
set: function set(val) { | ||
var atom = hostAtoms.get(this); | ||
@@ -766,3 +772,3 @@ | ||
var value = params[key]; | ||
result += "." + key + ":" + (_typeof(value) === 'object' ? JSON.stringify(value) : value); | ||
result += "." + key + ":" + (typeof value === 'object' ? JSON.stringify(value) : value); | ||
} | ||
@@ -776,3 +782,3 @@ | ||
if (params instanceof Array) return JSON.stringify(params); | ||
if (_typeof(params) === 'object') return getKeyFromObj(params); | ||
if (typeof params === 'object') return getKeyFromObj(params); | ||
return '' + params; | ||
@@ -792,3 +798,3 @@ } | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -829,4 +835,6 @@ } | ||
function memkey() { | ||
if (arguments.length === 3) { | ||
return memKeyMethod(arguments[0], arguments[1], arguments[2]); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return memKeyMethod(args[0], args[1], args[2]); | ||
} | ||
@@ -839,3 +847,3 @@ | ||
var forceProxyOpts = { | ||
get: function get$$1(t, name) { | ||
get: function get(t, name) { | ||
var forceFn = t[name + "*"]; | ||
@@ -851,3 +859,3 @@ | ||
}, | ||
set: function set$$1(t, name, val) { | ||
set: function set(t, name, val) { | ||
if (t[name + "*"] === undefined) { | ||
@@ -868,3 +876,3 @@ // get/set handler | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
var proxy = proxyMap.get(this); | ||
@@ -889,7 +897,8 @@ | ||
function action() { | ||
var result = void 0; | ||
var result; | ||
var oldNamespace = context.beginTransaction(name); | ||
var args = arguments; | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: | ||
@@ -900,23 +909,23 @@ result = t[hk](); | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
result = t[hk](args[0]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
result = t[hk](args[0], args[1]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
result = t[hk](args[0], args[1], args[2]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
result = t[hk](args[0], args[1], args[2], args[3]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
result = t[hk](args[0], args[1], args[2], args[3], args[4]); | ||
break; | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
result = t[hk].apply(t, args); | ||
} | ||
@@ -938,7 +947,8 @@ } finally { | ||
function action() { | ||
var result = void 0; | ||
var result; | ||
var oldNamespace = context.beginTransaction(name); | ||
var args = arguments; | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: | ||
@@ -949,23 +959,23 @@ result = fn(); | ||
case 1: | ||
result = fn(arguments[0]); | ||
result = fn(args[0]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
result = fn(args[0], args[1]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
result = fn(args[0], args[1], args[2]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
result = fn(args[0], args[1], args[2], args[3]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
result = fn(args[0], args[1], args[2], args[3], args[4]); | ||
break; | ||
default: | ||
result = fn.apply(null, arguments); | ||
result = fn.apply(null, args); | ||
} | ||
@@ -995,3 +1005,3 @@ } finally { | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
if (definingProperty) { | ||
@@ -1014,11 +1024,15 @@ return this[hk]; | ||
function action() { | ||
if (arguments.length === 3) { | ||
return actionMethod(arguments[0], arguments[1], arguments[2], defaultContext); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return actionMethod(args[0], args[1], args[2], defaultContext); | ||
} | ||
return createActionFn(arguments[0], arguments[1], defaultContext); | ||
return createActionFn(args[0], args[1], defaultContext); | ||
} | ||
function mem() { | ||
if (arguments.length === 3) { | ||
return arguments[2].value === undefined ? memProp(arguments[0], arguments[1], arguments[2]) : memMethod(arguments[0], arguments[1], arguments[2]); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return args[2].value === undefined ? memProp(args[0], args[1], args[2]) : memMethod(args[0], args[1], args[2]); | ||
} | ||
@@ -1025,0 +1039,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; | ||
} | ||
// eslint-disable-line | ||
@@ -19,56 +41,4 @@ var ATOM_FORCE_NONE = 0; | ||
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 throwOnAccess = { | ||
get: function get$$1(target) { | ||
get: function get(target) { | ||
throw target.valueOf(); | ||
@@ -83,9 +53,14 @@ }, | ||
} | ||
var AtomWait = function (_Error) { | ||
inheritsLoose(AtomWait, _Error); | ||
var AtomWait = | ||
/*#__PURE__*/ | ||
function (_Error) { | ||
_inheritsLoose(AtomWait, _Error); | ||
function AtomWait() { | ||
function AtomWait(message) { | ||
var _this; | ||
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Wait...'; | ||
if (message === void 0) { | ||
message = 'Wait...'; | ||
} | ||
_this = _Error.call(this, message) || this // $FlowFixMe new.target | ||
@@ -131,6 +106,9 @@ ; | ||
var done = Symbol('lom_conform_done'); | ||
function conform(target, source, isComponent) { | ||
var stack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
function conform(target, source, isComponent, stack) { | ||
if (stack === void 0) { | ||
stack = []; | ||
} | ||
if (target === source) return source; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
if (isComponent || !target || typeof target !== 'object' || !source || typeof source !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
target[done] = true; | ||
@@ -167,6 +145,19 @@ var conformHandler = handlers.get(target.constructor); | ||
var Atom = function () { | ||
var Atom = | ||
/*#__PURE__*/ | ||
function () { | ||
function Atom(field, owner, context, hostAtoms, key, keyHash, isComponent) { | ||
this.status = void 0; | ||
this.field = void 0; | ||
this.owner = void 0; | ||
this.current = void 0; | ||
this._next = void 0; | ||
this._suggested = void 0; | ||
this.key = void 0; | ||
this.isComponent = void 0; | ||
this._masters = null; | ||
this._slaves = null; | ||
this._context = void 0; | ||
this._hostAtoms = void 0; | ||
this._keyHash = void 0; | ||
this._keyHash = keyHash; | ||
@@ -185,3 +176,5 @@ this.key = key; | ||
Atom.prototype.toString = function toString() { | ||
var _proto = Atom.prototype; | ||
_proto.toString = function toString() { | ||
var hc = this.owner.constructor; | ||
@@ -192,7 +185,7 @@ var k = this.key; | ||
Atom.prototype.toJSON = function toJSON() { | ||
_proto.toJSON = function toJSON() { | ||
return this.current; | ||
}; | ||
Atom.prototype.destructor = function destructor() { | ||
_proto.destructor = function destructor() { | ||
if (this.status === ATOM_STATUS_DESTROYED) return; | ||
@@ -221,3 +214,3 @@ | ||
Atom.prototype._get = function _get(force) { | ||
_proto._get = function _get$$1(force) { | ||
var slave = this._context.last; | ||
@@ -247,3 +240,3 @@ | ||
Atom.prototype.value = function value(next, force) { | ||
_proto.value = function value(next, force) { | ||
if (next === undefined) return this._get(force); | ||
@@ -263,3 +256,3 @@ if (force === ATOM_FORCE_CACHE) return this._push(next); | ||
Atom.prototype.actualize = function actualize() { | ||
_proto.actualize = function actualize() { | ||
if (this.status === ATOM_STATUS_PULLING) { | ||
@@ -286,3 +279,3 @@ throw new Error("Cyclic atom dependency of " + String(this)); | ||
Atom.prototype._push = function _push(nextRaw) { | ||
_proto._push = function _push(nextRaw) { | ||
this.status = ATOM_STATUS_ACTUAL; | ||
@@ -312,3 +305,3 @@ | ||
Atom.prototype._pull = function _pull(force) { | ||
_proto._pull = function _pull(force) { | ||
if (this._masters) { | ||
@@ -318,3 +311,3 @@ this._masters.forEach(disleadThis, this); | ||
var newValue = void 0; | ||
var newValue; | ||
this.status = ATOM_STATUS_PULLING; | ||
@@ -340,3 +333,3 @@ var context = this._context; | ||
Atom.prototype.dislead = function dislead(slave) { | ||
_proto.dislead = function dislead(slave) { | ||
var slaves = this._slaves; | ||
@@ -355,3 +348,3 @@ | ||
Atom.prototype._checkSlaves = function _checkSlaves() { | ||
_proto._checkSlaves = function _checkSlaves() { | ||
if (this._slaves) { | ||
@@ -364,3 +357,3 @@ this._slaves.forEach(checkSlave); | ||
Atom.prototype.check = function check() { | ||
_proto.check = function check() { | ||
if (this.status === ATOM_STATUS_ACTUAL) { | ||
@@ -373,3 +366,3 @@ this.status = ATOM_STATUS_CHECKING; | ||
Atom.prototype.obsolete = function obsolete() { | ||
_proto.obsolete = function obsolete() { | ||
if (this.status !== ATOM_STATUS_OBSOLETE) { | ||
@@ -382,3 +375,3 @@ this.status = ATOM_STATUS_OBSOLETE; | ||
Atom.prototype.addMaster = function addMaster(master) { | ||
_proto.addMaster = function addMaster(master) { | ||
if (!this._masters) { | ||
@@ -391,5 +384,5 @@ this._masters = new Set(); | ||
createClass(Atom, [{ | ||
_createClass(Atom, [{ | ||
key: "displayName", | ||
get: function get$$1() { | ||
get: function get() { | ||
return this.toString(); | ||
@@ -415,22 +408,28 @@ } | ||
var BaseLogger = function () { | ||
var BaseLogger = | ||
/*#__PURE__*/ | ||
function () { | ||
function BaseLogger() {} | ||
BaseLogger.prototype.create = function create(owner, field, key, namespace) {}; | ||
var _proto = BaseLogger.prototype; | ||
BaseLogger.prototype.onDestruct = function onDestruct(atom, namespace) {}; | ||
_proto.create = function create(owner, field, key, namespace) {}; | ||
BaseLogger.prototype.sync = function sync() {}; | ||
_proto.onDestruct = function onDestruct(atom, namespace) {}; | ||
BaseLogger.prototype.status = function status(_status, atom, namespace) {}; | ||
_proto.sync = function sync() {}; | ||
BaseLogger.prototype.error = function error(atom, err, namespace) {}; | ||
_proto.status = function status(_status, atom, namespace) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
_proto.error = function error(atom, err, namespace) {}; | ||
_proto.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
return BaseLogger; | ||
}(); | ||
var ConsoleLogger = function (_BaseLogger) { | ||
inheritsLoose(ConsoleLogger, _BaseLogger); | ||
var ConsoleLogger = | ||
/*#__PURE__*/ | ||
function (_BaseLogger) { | ||
_inheritsLoose(ConsoleLogger, _BaseLogger); | ||
@@ -441,15 +440,17 @@ function ConsoleLogger() { | ||
ConsoleLogger.prototype.sync = function sync() { | ||
var _proto2 = ConsoleLogger.prototype; | ||
_proto2.sync = function sync() { | ||
console.log('sync'); | ||
}; | ||
ConsoleLogger.prototype.status = function status(_status2, atom, namespace) { | ||
_proto2.status = function status(_status2, atom, namespace) { | ||
console.log(namespace, _status2, atom.displayName); | ||
}; | ||
ConsoleLogger.prototype.error = function error(atom, err, namespace) { | ||
_proto2.error = function error(atom, err, namespace) { | ||
console.log(namespace, 'error', atom.displayName, err); | ||
}; | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
_proto2.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
console.log(namespace, isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
@@ -461,5 +462,7 @@ }; | ||
var Context = function () { | ||
var Context = | ||
/*#__PURE__*/ | ||
function () { | ||
function Context() { | ||
var _this2 = this; | ||
var _this = this; | ||
@@ -475,6 +478,6 @@ this.last = null; | ||
this.__run = function () { | ||
if (_this2._scheduled) { | ||
_this2._scheduled = false; | ||
if (_this._scheduled) { | ||
_this._scheduled = false; | ||
_this2._run(); | ||
_this._run(); | ||
} | ||
@@ -487,3 +490,5 @@ }; | ||
Context.prototype.create = function create(atom) { | ||
var _proto3 = Context.prototype; | ||
_proto3.create = function create(atom) { | ||
this._owners.set(atom, atom.owner); | ||
@@ -496,5 +501,6 @@ | ||
Context.prototype._destroyValue = function _destroyValue(atom, from) { | ||
if (from && !(from instanceof Error) && _typeof(from) === 'object' && typeof from.destructor === 'function' && this._owners.get(from) === atom) { | ||
_proto3._destroyValue = function _destroyValue(atom, from) { | ||
if (typeof from === 'object' && this._owners.get(from) === atom) { | ||
try { | ||
from.destructor(); | ||
@@ -510,3 +516,3 @@ } catch (e) { | ||
Context.prototype.destroyHost = function destroyHost(atom) { | ||
_proto3.destroyHost = function destroyHost(atom) { | ||
this._destroyValue(atom, atom.current); | ||
@@ -519,10 +525,10 @@ | ||
Context.prototype.setLogger = function setLogger(logger) { | ||
_proto3.setLogger = function setLogger(logger) { | ||
this._logger = logger; | ||
}; | ||
Context.prototype.newValue = function newValue(atom, from, to, isActualize) { | ||
_proto3.newValue = function newValue(atom, from, to, isActualize) { | ||
this._destroyValue(atom, from); | ||
if (to && !(to instanceof Error) && _typeof(to) === 'object' && typeof to.destructor === 'function') { | ||
if (to && typeof to === 'object' && !(to instanceof Error) && typeof to.destructor === 'function') { | ||
this._owners.set(to, atom); | ||
@@ -542,3 +548,3 @@ } | ||
Context.prototype.proposeToPull = function proposeToPull(atom) { | ||
_proto3.proposeToPull = function proposeToPull(atom) { | ||
if (this._logger !== undefined) { | ||
@@ -553,3 +559,3 @@ this._logger.status('proposeToPull', atom, this._namespace); | ||
Context.prototype.proposeToReap = function proposeToReap(atom) { | ||
_proto3.proposeToReap = function proposeToReap(atom) { | ||
if (this._logger !== undefined) { | ||
@@ -564,7 +570,7 @@ this._logger.status('proposeToReap', atom, this._namespace); | ||
Context.prototype.unreap = function unreap(atom) { | ||
_proto3.unreap = function unreap(atom) { | ||
this._reaping.delete(atom); | ||
}; | ||
Context.prototype._schedule = function _schedule() { | ||
_proto3._schedule = function _schedule() { | ||
if (!this._scheduled) { | ||
@@ -576,3 +582,3 @@ scheduleNative(this.__run); | ||
Context.prototype._run = function _run() { | ||
_proto3._run = function _run() { | ||
this._schedule(); | ||
@@ -615,3 +621,3 @@ | ||
Context.prototype.beginTransaction = function beginTransaction(namespace) { | ||
_proto3.beginTransaction = function beginTransaction(namespace) { | ||
var result = this._namespace; | ||
@@ -623,3 +629,3 @@ this._namespace = namespace; | ||
Context.prototype.endTransaction = function endTransaction(prev) { | ||
_proto3.endTransaction = function endTransaction(prev) { | ||
this._namespace = prev; | ||
@@ -653,3 +659,3 @@ | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -681,9 +687,9 @@ } | ||
function createGetSetHandler(get$$1, set$$1) { | ||
function createGetSetHandler(get, set) { | ||
return function getSetHandler(next) { | ||
if (next === undefined) { | ||
return get$$1.call(this); | ||
return get.call(this); | ||
} | ||
set$$1.call(this, next); | ||
set.call(this, next); | ||
return next; | ||
@@ -724,3 +730,3 @@ }; | ||
Object.defineProperty(proto, name + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -732,3 +738,3 @@ } | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
var atom = hostAtoms.get(this); | ||
@@ -745,3 +751,3 @@ | ||
}, | ||
set: function set$$1(val) { | ||
set: function set(val) { | ||
var atom = hostAtoms.get(this); | ||
@@ -768,3 +774,3 @@ | ||
var value = params[key]; | ||
result += "." + key + ":" + (_typeof(value) === 'object' ? JSON.stringify(value) : value); | ||
result += "." + key + ":" + (typeof value === 'object' ? JSON.stringify(value) : value); | ||
} | ||
@@ -778,3 +784,3 @@ | ||
if (params instanceof Array) return JSON.stringify(params); | ||
if (_typeof(params) === 'object') return getKeyFromObj(params); | ||
if (typeof params === 'object') return getKeyFromObj(params); | ||
return '' + params; | ||
@@ -794,3 +800,3 @@ } | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
get: function get() { | ||
return hostAtoms.get(this); | ||
@@ -831,4 +837,6 @@ } | ||
function memkey() { | ||
if (arguments.length === 3) { | ||
return memKeyMethod(arguments[0], arguments[1], arguments[2]); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return memKeyMethod(args[0], args[1], args[2]); | ||
} | ||
@@ -841,3 +849,3 @@ | ||
var forceProxyOpts = { | ||
get: function get$$1(t, name) { | ||
get: function get(t, name) { | ||
var forceFn = t[name + "*"]; | ||
@@ -853,3 +861,3 @@ | ||
}, | ||
set: function set$$1(t, name, val) { | ||
set: function set(t, name, val) { | ||
if (t[name + "*"] === undefined) { | ||
@@ -870,3 +878,3 @@ // get/set handler | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
var proxy = proxyMap.get(this); | ||
@@ -891,7 +899,8 @@ | ||
function action() { | ||
var result = void 0; | ||
var result; | ||
var oldNamespace = context.beginTransaction(name); | ||
var args = arguments; | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: | ||
@@ -902,23 +911,23 @@ result = t[hk](); | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
result = t[hk](args[0]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
result = t[hk](args[0], args[1]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
result = t[hk](args[0], args[1], args[2]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
result = t[hk](args[0], args[1], args[2], args[3]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
result = t[hk](args[0], args[1], args[2], args[3], args[4]); | ||
break; | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
result = t[hk].apply(t, args); | ||
} | ||
@@ -940,7 +949,8 @@ } finally { | ||
function action() { | ||
var result = void 0; | ||
var result; | ||
var oldNamespace = context.beginTransaction(name); | ||
var args = arguments; | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: | ||
@@ -951,23 +961,23 @@ result = fn(); | ||
case 1: | ||
result = fn(arguments[0]); | ||
result = fn(args[0]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
result = fn(args[0], args[1]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
result = fn(args[0], args[1], args[2]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
result = fn(args[0], args[1], args[2], args[3]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
result = fn(args[0], args[1], args[2], args[3], args[4]); | ||
break; | ||
default: | ||
result = fn.apply(null, arguments); | ||
result = fn.apply(null, args); | ||
} | ||
@@ -997,3 +1007,3 @@ } finally { | ||
configurable: descr.configurable, | ||
get: function get$$1() { | ||
get: function get() { | ||
if (definingProperty) { | ||
@@ -1016,11 +1026,15 @@ return this[hk]; | ||
function action() { | ||
if (arguments.length === 3) { | ||
return actionMethod(arguments[0], arguments[1], arguments[2], defaultContext); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return actionMethod(args[0], args[1], args[2], defaultContext); | ||
} | ||
return createActionFn(arguments[0], arguments[1], defaultContext); | ||
return createActionFn(args[0], args[1], defaultContext); | ||
} | ||
function mem() { | ||
if (arguments.length === 3) { | ||
return arguments[2].value === undefined ? memProp(arguments[0], arguments[1], arguments[2]) : memMethod(arguments[0], arguments[1], arguments[2]); | ||
var args = arguments; | ||
if (args.length === 3) { | ||
return args[2].value === undefined ? memProp(args[0], args[1], args[2]) : memMethod(args[0], args[1], args[2]); | ||
} | ||
@@ -1027,0 +1041,0 @@ |
{ | ||
"name": "lom_atom", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "Alternative implementation of eigenmethod mol_atom state management library", | ||
@@ -54,9 +54,9 @@ "publishConfig": { | ||
"devDependencies": { | ||
"babel-plugin-external-helpers": "^7.0.0-alpha.17", | ||
"babel-plugin-transform-class-properties": "^7.0.0-alpha.17", | ||
"babel-plugin-transform-decorators": "^7.0.0-alpha.17", | ||
"babel-preset-es2015": "^7.0.0-alpha.17", | ||
"babel-preset-flow": "^7.0.0-alpha.17", | ||
"babel-register": "^7.0.0-alpha.17", | ||
"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", | ||
@@ -67,5 +67,4 @@ "flow-bin": "^0.58.0", | ||
"rollup": "^0.48.2", | ||
"rollup-plugin-babel": "=3.0.0-alpha.17", | ||
"rollup-plugin-babel": "^4.0.0-beta.0", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"source-map-support": "^0.5.0", | ||
"standard-version": "^4.2.0", | ||
@@ -72,0 +71,0 @@ "uglify-es": "^3.1.6" |
import babel from 'rollup-plugin-babel' | ||
import uglify from 'rollup-plugin-uglify' | ||
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 = { | ||
@@ -18,2 +27,3 @@ warnings: true, | ||
mangle: { | ||
properties: false, | ||
toplevel: true | ||
@@ -27,3 +37,3 @@ } | ||
plugins: [ | ||
babel(babelrc()) | ||
babel(babelrc) | ||
].concat(process.env.UGLIFY === '1' ? [uglify(uglifyOpts, minify)] : []), | ||
@@ -30,0 +40,0 @@ output: [ |
@@ -62,3 +62,3 @@ // @flow | ||
_namespace: string = '$' | ||
_owners: WeakMap<Object, Object> = new WeakMap() | ||
_owners: WeakMap<?Object, Object> = new WeakMap() | ||
@@ -72,12 +72,9 @@ create<V>(atom: IAtomInt): V | void { | ||
_destroyValue<V>(atom: IAtom<V>, from?: V | Error) { | ||
_destroyValue<V>(atom: IAtom<V>, from?: mixed) { | ||
if ( | ||
from | ||
&& !(from instanceof Error) | ||
&& typeof from === 'object' | ||
&& typeof from.destructor === 'function' | ||
typeof from === 'object' | ||
&& this._owners.get(from) === atom | ||
) { | ||
try { | ||
from.destructor() | ||
;(from: any).destructor() | ||
} catch(e) { | ||
@@ -103,7 +100,7 @@ console.error(e) | ||
newValue<V>(atom: IAtom<V>, from?: V | Error, to: V | Error, isActualize?: boolean) { | ||
this._destroyValue(atom, (from: any)) | ||
this._destroyValue(atom, from) | ||
if ( | ||
to | ||
&& typeof to === 'object' | ||
&& !(to instanceof Error) | ||
&& typeof to === 'object' | ||
&& typeof to.destructor === 'function' | ||
@@ -110,0 +107,0 @@ ) { |
@@ -211,4 +211,5 @@ // @flow | ||
export function memkey() { | ||
if (arguments.length === 3) { | ||
return memKeyMethod(arguments[0], arguments[1], arguments[2]) | ||
const args = arguments | ||
if (args.length === 3) { | ||
return memKeyMethod(args[0], args[1], args[2]) | ||
} | ||
@@ -287,11 +288,12 @@ | ||
const oldNamespace = context.beginTransaction(name) | ||
const args = arguments | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: result = t[hk](); break | ||
case 1: result = t[hk](arguments[0]); break | ||
case 2: result = t[hk](arguments[0], arguments[1]); break | ||
case 3: result = t[hk](arguments[0], arguments[1], arguments[2]); break | ||
case 4: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); break | ||
case 5: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break | ||
default: result = t[hk].apply(t, arguments) | ||
case 1: result = t[hk](args[0]); break | ||
case 2: result = t[hk](args[0], args[1]); break | ||
case 3: result = t[hk](args[0], args[1], args[2]); break | ||
case 4: result = t[hk](args[0], args[1], args[2], args[3]); break | ||
case 5: result = t[hk](args[0], args[1], args[2], args[3], args[4]); break | ||
default: result = t[hk].apply(t, args) | ||
} | ||
@@ -314,11 +316,12 @@ } finally { | ||
const oldNamespace = context.beginTransaction(name) | ||
const args = arguments | ||
try { | ||
switch (arguments.length) { | ||
switch (args.length) { | ||
case 0: result = fn(); break | ||
case 1: result = fn(arguments[0]); break | ||
case 2: result = fn(arguments[0], arguments[1]); break | ||
case 3: result = fn(arguments[0], arguments[1], arguments[2]); break | ||
case 4: result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); break | ||
case 5: result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break | ||
default: result = fn.apply(null, arguments) | ||
case 1: result = fn(args[0]); break | ||
case 2: result = fn(args[0], args[1]); break | ||
case 3: result = fn(args[0], args[1], args[2]); break | ||
case 4: result = fn(args[0], args[1], args[2], args[3]); break | ||
case 5: result = fn(args[0], args[1], args[2], args[3], args[4]); break | ||
default: result = fn.apply(null, args) | ||
} | ||
@@ -377,7 +380,8 @@ } finally { | ||
export function action() { | ||
if (arguments.length === 3) { | ||
return actionMethod(arguments[0], arguments[1], arguments[2], defaultContext) | ||
const args = arguments | ||
if (args.length === 3) { | ||
return actionMethod(args[0], args[1], args[2], defaultContext) | ||
} | ||
return createActionFn(arguments[0], arguments[1], defaultContext) | ||
return createActionFn(args[0], args[1], defaultContext) | ||
} | ||
@@ -393,6 +397,7 @@ | ||
export default function mem() { | ||
if (arguments.length === 3) { | ||
return arguments[2].value === undefined | ||
? memProp(arguments[0], arguments[1], arguments[2]) | ||
: memMethod(arguments[0], arguments[1], arguments[2]) | ||
const args = arguments | ||
if (args.length === 3) { | ||
return args[2].value === undefined | ||
? memProp(args[0], args[1], args[2]) | ||
: memMethod(args[0], args[1], args[2]) | ||
} | ||
@@ -399,0 +404,0 @@ |
@@ -6,3 +6,3 @@ // @flow | ||
const throwOnAccess = { | ||
get(target: Error) { | ||
get<V: Object>(target: Error): V { | ||
throw target.valueOf() | ||
@@ -9,0 +9,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
345410
16
3613