Comparing version 1.1.8 to 1.1.9
@@ -16,3 +16,3 @@ 'use strict'; | ||
var CHILDREN = "children"; | ||
var KARET_LIFT = "karet-lift"; | ||
var LIFT = "karet-lift"; | ||
var DD_REF = "$$ref"; | ||
@@ -33,8 +33,11 @@ | ||
Component$1.call(this, props); | ||
this.at = 0; | ||
}, Component$1, { | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
this.componentWillUnmount(); | ||
this.at = 0; | ||
this.doSubscribe(nextProps); | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
this.at = 0; | ||
this.doSubscribe(this.props); | ||
@@ -64,3 +67,3 @@ } | ||
_this.rendered = e.value || null; | ||
_this.forceUpdate(); | ||
_this.at && _this.forceUpdate(); | ||
break; | ||
@@ -90,5 +93,5 @@ case ERROR: | ||
function renderChildren(children, at, values) { | ||
function renderChildren(children, self, values) { | ||
if (isObs(children)) { | ||
return values[++at[0]]; | ||
return values[self.at++]; | ||
} else if (infestines.isArray(children)) { | ||
@@ -100,5 +103,5 @@ var newChildren = children; | ||
if (isObs(childI)) { | ||
newChildI = values[++at[0]]; | ||
newChildI = values[self.at++]; | ||
} else if (infestines.isArray(childI)) { | ||
newChildI = renderChildren(childI, at, values); | ||
newChildI = renderChildren(childI, self, values); | ||
} | ||
@@ -116,3 +119,3 @@ if (newChildI !== childI) { | ||
function renderStyle(style, at, values) { | ||
function renderStyle(style, self, values) { | ||
var newStyle = undefined; | ||
@@ -129,3 +132,3 @@ for (var i in style) { | ||
} | ||
newStyle[i] = values[++at[0]]; | ||
newStyle[i] = values[self.at++]; | ||
} else if (newStyle) { | ||
@@ -138,3 +141,5 @@ newStyle[i] = styleI; | ||
function _render(props, values) { | ||
function _render(self, values) { | ||
var props = self.props; | ||
var type = null; | ||
@@ -144,3 +149,3 @@ var newProps = null; | ||
var at = [-1]; | ||
self.at = 0; | ||
@@ -150,3 +155,3 @@ for (var key in props) { | ||
if (CHILDREN === key) { | ||
newChildren = renderChildren(val, at, values); | ||
newChildren = renderChildren(val, self, values); | ||
} else if ("$$type" === key) { | ||
@@ -156,9 +161,9 @@ type = props[key]; | ||
newProps = newProps || {}; | ||
newProps.ref = isObs(val) ? values[++at[0]] : val; | ||
newProps.ref = isObs(val) ? values[self.at++] : val; | ||
} else if (isObs(val)) { | ||
newProps = newProps || {}; | ||
newProps[key] = values[++at[0]]; | ||
newProps[key] = values[self.at++]; | ||
} else if (STYLE === key) { | ||
newProps = newProps || {}; | ||
newProps.style = renderStyle(val, at, values) || val; | ||
newProps.style = renderStyle(val, self, values) || val; | ||
} else { | ||
@@ -226,3 +231,3 @@ newProps = newProps || {}; | ||
values[idx] = value; | ||
self.forceUpdate(); | ||
self.at && self.forceUpdate(); | ||
} | ||
@@ -275,3 +280,3 @@ break; | ||
this.values = this; | ||
var handlers = function handlers(e) { | ||
forEachInProps(props, this.handlers = function (e) { | ||
switch (e.type) { | ||
@@ -283,3 +288,3 @@ case VALUE: | ||
_this2.values = value; | ||
_this2.forceUpdate(); | ||
_this2.at && _this2.forceUpdate(); | ||
} | ||
@@ -296,5 +301,3 @@ break; | ||
} | ||
}; | ||
this.handlers = handlers; | ||
forEachInProps(props, handlers, onAny1); | ||
}, onAny1); | ||
break; | ||
@@ -312,3 +315,3 @@ } | ||
if (value === this) return null; | ||
return _render(this.props, [value]); | ||
return _render(this, [value]); | ||
} else { | ||
@@ -318,3 +321,3 @@ var values = this.values; | ||
if (values[i] === this) return null; | ||
}return _render(this.props, values); | ||
}return _render(this, values); | ||
} | ||
@@ -356,3 +359,3 @@ } | ||
var val = props[key]; | ||
if ("ref" === key) newProps[DD_REF] = val;else if (KARET_LIFT !== key) newProps[key] = val; | ||
if ("ref" === key) newProps[DD_REF] = val;else if (LIFT !== key) newProps[key] = val; | ||
} | ||
@@ -369,8 +372,8 @@ return newProps; | ||
var props = args[1] || infestines.object0; | ||
if (infestines.isString(type) || props[KARET_LIFT]) { | ||
if (infestines.isString(type) || props[LIFT]) { | ||
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) { | ||
args[1] = filterProps(type, props); | ||
args[0] = FromClass; | ||
} else if (props[KARET_LIFT]) { | ||
args[1] = infestines.dissocPartialU(KARET_LIFT, props) || infestines.object0; | ||
} else if (props[LIFT]) { | ||
args[1] = infestines.dissocPartialU(LIFT, props) || infestines.object0; | ||
} | ||
@@ -377,0 +380,0 @@ } |
@@ -13,3 +13,3 @@ import { Component, createElement } from 'react'; | ||
var CHILDREN = "children"; | ||
var KARET_LIFT = "karet-lift"; | ||
var LIFT = "karet-lift"; | ||
var DD_REF = "$$ref"; | ||
@@ -30,8 +30,11 @@ | ||
Component$1.call(this, props); | ||
this.at = 0; | ||
}, Component$1, { | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
this.componentWillUnmount(); | ||
this.at = 0; | ||
this.doSubscribe(nextProps); | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
this.at = 0; | ||
this.doSubscribe(this.props); | ||
@@ -61,3 +64,3 @@ } | ||
_this.rendered = e.value || null; | ||
_this.forceUpdate(); | ||
_this.at && _this.forceUpdate(); | ||
break; | ||
@@ -87,5 +90,5 @@ case ERROR: | ||
function renderChildren(children, at, values) { | ||
function renderChildren(children, self, values) { | ||
if (isObs(children)) { | ||
return values[++at[0]]; | ||
return values[self.at++]; | ||
} else if (isArray(children)) { | ||
@@ -97,5 +100,5 @@ var newChildren = children; | ||
if (isObs(childI)) { | ||
newChildI = values[++at[0]]; | ||
newChildI = values[self.at++]; | ||
} else if (isArray(childI)) { | ||
newChildI = renderChildren(childI, at, values); | ||
newChildI = renderChildren(childI, self, values); | ||
} | ||
@@ -113,3 +116,3 @@ if (newChildI !== childI) { | ||
function renderStyle(style, at, values) { | ||
function renderStyle(style, self, values) { | ||
var newStyle = undefined; | ||
@@ -126,3 +129,3 @@ for (var i in style) { | ||
} | ||
newStyle[i] = values[++at[0]]; | ||
newStyle[i] = values[self.at++]; | ||
} else if (newStyle) { | ||
@@ -135,3 +138,5 @@ newStyle[i] = styleI; | ||
function _render(props, values) { | ||
function _render(self, values) { | ||
var props = self.props; | ||
var type = null; | ||
@@ -141,3 +146,3 @@ var newProps = null; | ||
var at = [-1]; | ||
self.at = 0; | ||
@@ -147,3 +152,3 @@ for (var key in props) { | ||
if (CHILDREN === key) { | ||
newChildren = renderChildren(val, at, values); | ||
newChildren = renderChildren(val, self, values); | ||
} else if ("$$type" === key) { | ||
@@ -153,9 +158,9 @@ type = props[key]; | ||
newProps = newProps || {}; | ||
newProps.ref = isObs(val) ? values[++at[0]] : val; | ||
newProps.ref = isObs(val) ? values[self.at++] : val; | ||
} else if (isObs(val)) { | ||
newProps = newProps || {}; | ||
newProps[key] = values[++at[0]]; | ||
newProps[key] = values[self.at++]; | ||
} else if (STYLE === key) { | ||
newProps = newProps || {}; | ||
newProps.style = renderStyle(val, at, values) || val; | ||
newProps.style = renderStyle(val, self, values) || val; | ||
} else { | ||
@@ -223,3 +228,3 @@ newProps = newProps || {}; | ||
values[idx] = value; | ||
self.forceUpdate(); | ||
self.at && self.forceUpdate(); | ||
} | ||
@@ -272,3 +277,3 @@ break; | ||
this.values = this; | ||
var handlers = function handlers(e) { | ||
forEachInProps(props, this.handlers = function (e) { | ||
switch (e.type) { | ||
@@ -280,3 +285,3 @@ case VALUE: | ||
_this2.values = value; | ||
_this2.forceUpdate(); | ||
_this2.at && _this2.forceUpdate(); | ||
} | ||
@@ -293,5 +298,3 @@ break; | ||
} | ||
}; | ||
this.handlers = handlers; | ||
forEachInProps(props, handlers, onAny1); | ||
}, onAny1); | ||
break; | ||
@@ -309,3 +312,3 @@ } | ||
if (value === this) return null; | ||
return _render(this.props, [value]); | ||
return _render(this, [value]); | ||
} else { | ||
@@ -315,3 +318,3 @@ var values = this.values; | ||
if (values[i] === this) return null; | ||
}return _render(this.props, values); | ||
}return _render(this, values); | ||
} | ||
@@ -353,3 +356,3 @@ } | ||
var val = props[key]; | ||
if ("ref" === key) newProps[DD_REF] = val;else if (KARET_LIFT !== key) newProps[key] = val; | ||
if ("ref" === key) newProps[DD_REF] = val;else if (LIFT !== key) newProps[key] = val; | ||
} | ||
@@ -366,8 +369,8 @@ return newProps; | ||
var props = args[1] || object0; | ||
if (isString(type) || props[KARET_LIFT]) { | ||
if (isString(type) || props[LIFT]) { | ||
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) { | ||
args[1] = filterProps(type, props); | ||
args[0] = FromClass; | ||
} else if (props[KARET_LIFT]) { | ||
args[1] = dissocPartialU(KARET_LIFT, props) || object0; | ||
} else if (props[LIFT]) { | ||
args[1] = dissocPartialU(LIFT, props) || object0; | ||
} | ||
@@ -374,0 +377,0 @@ } |
@@ -14,3 +14,3 @@ (function (global, factory) { | ||
var CHILDREN = "children"; | ||
var KARET_LIFT = "karet-lift"; | ||
var LIFT = "karet-lift"; | ||
var DD_REF = "$$ref"; | ||
@@ -31,8 +31,11 @@ | ||
Component$1.call(this, props); | ||
this.at = 0; | ||
}, Component$1, { | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
this.componentWillUnmount(); | ||
this.at = 0; | ||
this.doSubscribe(nextProps); | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
this.at = 0; | ||
this.doSubscribe(this.props); | ||
@@ -62,3 +65,3 @@ } | ||
_this.rendered = e.value || null; | ||
_this.forceUpdate(); | ||
_this.at && _this.forceUpdate(); | ||
break; | ||
@@ -88,5 +91,5 @@ case ERROR: | ||
function renderChildren(children, at, values) { | ||
function renderChildren(children, self, values) { | ||
if (isObs(children)) { | ||
return values[++at[0]]; | ||
return values[self.at++]; | ||
} else if (infestines.isArray(children)) { | ||
@@ -98,5 +101,5 @@ var newChildren = children; | ||
if (isObs(childI)) { | ||
newChildI = values[++at[0]]; | ||
newChildI = values[self.at++]; | ||
} else if (infestines.isArray(childI)) { | ||
newChildI = renderChildren(childI, at, values); | ||
newChildI = renderChildren(childI, self, values); | ||
} | ||
@@ -114,3 +117,3 @@ if (newChildI !== childI) { | ||
function renderStyle(style, at, values) { | ||
function renderStyle(style, self, values) { | ||
var newStyle = undefined; | ||
@@ -127,3 +130,3 @@ for (var i in style) { | ||
} | ||
newStyle[i] = values[++at[0]]; | ||
newStyle[i] = values[self.at++]; | ||
} else if (newStyle) { | ||
@@ -136,3 +139,5 @@ newStyle[i] = styleI; | ||
function _render(props, values) { | ||
function _render(self, values) { | ||
var props = self.props; | ||
var type = null; | ||
@@ -142,3 +147,3 @@ var newProps = null; | ||
var at = [-1]; | ||
self.at = 0; | ||
@@ -148,3 +153,3 @@ for (var key in props) { | ||
if (CHILDREN === key) { | ||
newChildren = renderChildren(val, at, values); | ||
newChildren = renderChildren(val, self, values); | ||
} else if ("$$type" === key) { | ||
@@ -154,9 +159,9 @@ type = props[key]; | ||
newProps = newProps || {}; | ||
newProps.ref = isObs(val) ? values[++at[0]] : val; | ||
newProps.ref = isObs(val) ? values[self.at++] : val; | ||
} else if (isObs(val)) { | ||
newProps = newProps || {}; | ||
newProps[key] = values[++at[0]]; | ||
newProps[key] = values[self.at++]; | ||
} else if (STYLE === key) { | ||
newProps = newProps || {}; | ||
newProps.style = renderStyle(val, at, values) || val; | ||
newProps.style = renderStyle(val, self, values) || val; | ||
} else { | ||
@@ -224,3 +229,3 @@ newProps = newProps || {}; | ||
values[idx] = value; | ||
self.forceUpdate(); | ||
self.at && self.forceUpdate(); | ||
} | ||
@@ -273,3 +278,3 @@ break; | ||
this.values = this; | ||
var handlers = function handlers(e) { | ||
forEachInProps(props, this.handlers = function (e) { | ||
switch (e.type) { | ||
@@ -281,3 +286,3 @@ case VALUE: | ||
_this2.values = value; | ||
_this2.forceUpdate(); | ||
_this2.at && _this2.forceUpdate(); | ||
} | ||
@@ -294,5 +299,3 @@ break; | ||
} | ||
}; | ||
this.handlers = handlers; | ||
forEachInProps(props, handlers, onAny1); | ||
}, onAny1); | ||
break; | ||
@@ -310,3 +313,3 @@ } | ||
if (value === this) return null; | ||
return _render(this.props, [value]); | ||
return _render(this, [value]); | ||
} else { | ||
@@ -316,3 +319,3 @@ var values = this.values; | ||
if (values[i] === this) return null; | ||
}return _render(this.props, values); | ||
}return _render(this, values); | ||
} | ||
@@ -354,3 +357,3 @@ } | ||
var val = props[key]; | ||
if ("ref" === key) newProps[DD_REF] = val;else if (KARET_LIFT !== key) newProps[key] = val; | ||
if ("ref" === key) newProps[DD_REF] = val;else if (LIFT !== key) newProps[key] = val; | ||
} | ||
@@ -367,8 +370,8 @@ return newProps; | ||
var props = args[1] || infestines.object0; | ||
if (infestines.isString(type) || props[KARET_LIFT]) { | ||
if (infestines.isString(type) || props[LIFT]) { | ||
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) { | ||
args[1] = filterProps(type, props); | ||
args[0] = FromClass; | ||
} else if (props[KARET_LIFT]) { | ||
args[1] = infestines.dissocPartialU(KARET_LIFT, props) || infestines.object0; | ||
} else if (props[LIFT]) { | ||
args[1] = infestines.dissocPartialU(LIFT, props) || infestines.object0; | ||
} | ||
@@ -375,0 +378,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("kefir"),require("infestines")):"function"==typeof define&&define.amd?define(["exports","react","kefir","infestines"],r):r(e.karet=e.karet||{},e.React,e.Kefir,e.I)}(this,function(e,r,n,t){"use strict";function i(e,r,n){if(W(e))return n[++r[0]];if(t.isArray(e)){for(var a=e,s=0,l=e.length;s<l;++s){var o=e[s],u=o;W(o)?u=n[++r[0]]:t.isArray(o)&&(u=i(o,r,n)),u!==o&&(a===e&&(a=e.slice(0)),a[s]=u)}return a}return e}function a(e,r,n){var t=void 0;for(var i in e){var a=e[i];if(W(a)){if(!t){t={};for(var s in e){if(s===i)break;t[s]=e[s]}}t[i]=n[++r[0]]}else t&&(t[i]=a)}return t||e}function s(e,r){var n=null,t=null,s=null,l=[-1];for(var o in e){var u=e[o];g===o?s=i(u,l,r):"$$type"===o?n=e[o]:w===o?(t=t||{},t.ref=W(u)?r[++l[0]]:u):W(u)?(t=t||{},t[o]=r[++l[0]]):A===o?(t=t||{},t.style=a(u,l,r)||u):(t=t||{},t[o]=u)}return s instanceof Array?$.apply(null,[n,t].concat(s)):s?$(n,t,s):$(n,t)}function l(e,r,n){for(var i=0,a=e.length;i<a;++i){var s=e[i];W(s)?n(r,s):t.isArray(s)&&l(s,r,n)}}function o(e,r,n){for(var i in e){var a=e[i];if(W(a))n(r,a);else if(g===i)t.isArray(a)&&l(a,r,n);else if(A===i)for(var s in a){var o=a[s];W(o)&&n(r,o)}}}function u(e){e.values+=1}function f(e,r){r.offAny(e)}function c(e,r){var n=e.pop();n&&r.offAny(n)}function v(e,r){r.onAny(e)}function h(e,r){var n=function r(n){for(var t=e.handlers,i=0;t[i]!==r;)++i;switch(n.type){case k:var a=n.value,s=e.values;s[i]!==a&&(s[i]=a,e.forceUpdate());break;case m:throw n.value;default:t[i]=null;var l=t.length;if(l!==e.values.length)return;for(var o=0;o<l;++o)if(t[o])return;e.handlers=null}};e.handlers.push(n),r.onAny(n)}function d(e,r){for(var n=r.length;e<n;++e){var i=r[e];if(W(i)||t.isArray(i)&&d(0,i))return!0}return!1}function p(e){for(var r in e){var n=e[r];if(W(n))return!0;if(g===r){if(t.isArray(n)&&d(0,n))return!0}else if(A===r)for(var i in n)if(W(n[i]))return!0}return!1}function b(e,r){var n={$$type:e};for(var t in r){var i=r[t];"ref"===t?n[w]=i:U!==t&&(n[t]=i)}return n}function y(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r[0],a=r[1]||t.object0;return(t.isString(i)||a[U])&&(d(2,r)||p(a)?(r[1]=b(i,a),r[0]=x):a[U]&&(r[1]=t.dissocPartialU(U,a)||t.object0)),$.apply(void 0,r)}var k="value",m="error",A="style",g="children",U="karet-lift",w="$$ref",$=r.createElement,S=r.Component,W=function(e){return e instanceof n.Observable},j=t.inherit(function(e){S.call(this,e)},S,{componentWillReceiveProps:function(e){this.componentWillUnmount(),this.doSubscribe(e)},componentWillMount:function(){this.doSubscribe(this.props)}}),P=t.inherit(function(e){j.call(this,e),this.callback=this.rendered=null},j,{componentWillUnmount:function(){var e=this.callback;e&&this.props.observable.offAny(e)},doSubscribe:function(e){var r=this,n=e.observable;if(W(n)){var t=function(e){switch(e.type){case k:r.rendered=e.value||null,r.forceUpdate();break;case m:throw e.value;case"end":r.callback=null}};this.callback=t,n.onAny(t)}else this.rendered=n||null},render:function(){return this.rendered}}),q=function(e){return $(P,{observable:e})},x=t.inherit(function(e){j.call(this,e),this.values=this,this.handlers=null},j,{componentWillUnmount:function(){var e=this.handlers;e instanceof Function?o(this.props,e,f):e&&o(this.props,e.reverse(),c)},doSubscribe:function(e){var r=this;this.values=0,o(e,this,u);var n=this.values;switch(n){case 0:this.values=t.array0;break;case 1:this.values=this;var i=function(e){switch(e.type){case k:var n=e.value;r.values!==n&&(r.values=n,r.forceUpdate());break;case m:throw e.value;default:r.values=[r.values],r.handlers=null}};this.handlers=i,o(e,i,v);break;default:this.values=Array(n).fill(this),this.handlers=[],o(e,this,h)}},render:function(){if(this.handlers instanceof Function){var e=this.values;return e===this?null:s(this.props,[e])}for(var r=this.values,n=0,t=r.length;n<t;++n)if(r[n]===this)return null;return s(this.props,r)}}),C=t.assocPartialU("createElement",y,r),E=function(e){return function(r){return $(x,b(e,r))}};e.fromKefir=q,e.default=C,e.fromClass=E,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("kefir"),require("infestines")):"function"==typeof define&&define.amd?define(["exports","react","kefir","infestines"],r):r(e.karet=e.karet||{},e.React,e.Kefir,e.I)}(this,function(e,r,n,t){"use strict";function i(e,r,n){if(W(e))return n[r.at++];if(t.isArray(e)){for(var a=e,s=0,l=e.length;s<l;++s){var o=e[s],u=o;W(o)?u=n[r.at++]:t.isArray(o)&&(u=i(o,r,n)),u!==o&&(a===e&&(a=e.slice(0)),a[s]=u)}return a}return e}function a(e,r,n){var t=void 0;for(var i in e){var a=e[i];if(W(a)){if(!t){t={};for(var s in e){if(s===i)break;t[s]=e[s]}}t[i]=n[r.at++]}else t&&(t[i]=a)}return t||e}function s(e,r){var n=e.props,t=null,s=null,l=null;e.at=0;for(var o in n){var u=n[o];g===o?l=i(u,e,r):"$$type"===o?t=n[o]:w===o?(s=s||{},s.ref=W(u)?r[e.at++]:u):W(u)?(s=s||{},s[o]=r[e.at++]):A===o?(s=s||{},s.style=a(u,e,r)||u):(s=s||{},s[o]=u)}return l instanceof Array?$.apply(null,[t,s].concat(l)):l?$(t,s,l):$(t,s)}function l(e,r,n){for(var i=0,a=e.length;i<a;++i){var s=e[i];W(s)?n(r,s):t.isArray(s)&&l(s,r,n)}}function o(e,r,n){for(var i in e){var a=e[i];if(W(a))n(r,a);else if(g===i)t.isArray(a)&&l(a,r,n);else if(A===i)for(var s in a){var o=a[s];W(o)&&n(r,o)}}}function u(e){e.values+=1}function f(e,r){r.offAny(e)}function c(e,r){var n=e.pop();n&&r.offAny(n)}function h(e,r){r.onAny(e)}function v(e,r){var n=function r(n){for(var t=e.handlers,i=0;t[i]!==r;)++i;switch(n.type){case k:var a=n.value,s=e.values;s[i]!==a&&(s[i]=a,e.at&&e.forceUpdate());break;case m:throw n.value;default:t[i]=null;var l=t.length;if(l!==e.values.length)return;for(var o=0;o<l;++o)if(t[o])return;e.handlers=null}};e.handlers.push(n),r.onAny(n)}function d(e,r){for(var n=r.length;e<n;++e){var i=r[e];if(W(i)||t.isArray(i)&&d(0,i))return!0}return!1}function p(e){for(var r in e){var n=e[r];if(W(n))return!0;if(g===r){if(t.isArray(n)&&d(0,n))return!0}else if(A===r)for(var i in n)if(W(n[i]))return!0}return!1}function b(e,r){var n={$$type:e};for(var t in r){var i=r[t];"ref"===t?n[w]=i:U!==t&&(n[t]=i)}return n}function y(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r[0],a=r[1]||t.object0;return(t.isString(i)||a[U])&&(d(2,r)||p(a)?(r[1]=b(i,a),r[0]=x):a[U]&&(r[1]=t.dissocPartialU(U,a)||t.object0)),$.apply(void 0,r)}var k="value",m="error",A="style",g="children",U="karet-lift",w="$$ref",$=r.createElement,S=r.Component,W=function(e){return e instanceof n.Observable},j=t.inherit(function(e){S.call(this,e),this.at=0},S,{componentWillReceiveProps:function(e){this.componentWillUnmount(),this.at=0,this.doSubscribe(e)},componentWillMount:function(){this.at=0,this.doSubscribe(this.props)}}),P=t.inherit(function(e){j.call(this,e),this.callback=this.rendered=null},j,{componentWillUnmount:function(){var e=this.callback;e&&this.props.observable.offAny(e)},doSubscribe:function(e){var r=this,n=e.observable;if(W(n)){var t=function(e){switch(e.type){case k:r.rendered=e.value||null,r.at&&r.forceUpdate();break;case m:throw e.value;case"end":r.callback=null}};this.callback=t,n.onAny(t)}else this.rendered=n||null},render:function(){return this.rendered}}),q=function(e){return $(P,{observable:e})},x=t.inherit(function(e){j.call(this,e),this.values=this,this.handlers=null},j,{componentWillUnmount:function(){var e=this.handlers;e instanceof Function?o(this.props,e,f):e&&o(this.props,e.reverse(),c)},doSubscribe:function(e){var r=this;this.values=0,o(e,this,u);var n=this.values;switch(n){case 0:this.values=t.array0;break;case 1:this.values=this,o(e,this.handlers=function(e){switch(e.type){case k:var n=e.value;r.values!==n&&(r.values=n,r.at&&r.forceUpdate());break;case m:throw e.value;default:r.values=[r.values],r.handlers=null}},h);break;default:this.values=Array(n).fill(this),this.handlers=[],o(e,this,v)}},render:function(){if(this.handlers instanceof Function){var e=this.values;return e===this?null:s(this,[e])}for(var r=this.values,n=0,t=r.length;n<t;++n)if(r[n]===this)return null;return s(this,r)}}),C=t.assocPartialU("createElement",y,r),E=function(e){return function(r){return $(x,b(e,r))}};e.fromKefir=q,e.default=C,e.fromClass=E,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "karet", | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"description": "Karet is a library that allows you to embed Kefir observables into React VDOM", | ||
@@ -5,0 +5,0 @@ "module": "dist/karet.es.js", |
@@ -20,3 +20,3 @@ import * as React from "react" | ||
const CHILDREN = "children" | ||
const KARET_LIFT = "karet-lift" | ||
const LIFT = "karet-lift" | ||
const DD_REF = "$$ref" | ||
@@ -35,8 +35,11 @@ | ||
Component.call(this, props) | ||
this.at = 0 | ||
}, Component, { | ||
componentWillReceiveProps(nextProps) { | ||
this.componentWillUnmount() | ||
this.at = 0 | ||
this.doSubscribe(nextProps) | ||
}, | ||
componentWillMount() { | ||
this.at = 0 | ||
this.doSubscribe(this.props) | ||
@@ -64,3 +67,3 @@ } | ||
this.rendered = e.value || null | ||
this.forceUpdate() | ||
this.at && this.forceUpdate() | ||
break | ||
@@ -88,5 +91,5 @@ case ERROR: | ||
function renderChildren(children, at, values) { | ||
function renderChildren(children, self, values) { | ||
if (isObs(children)) { | ||
return values[++at[0]] | ||
return values[self.at++] | ||
} else if (isArray(children)) { | ||
@@ -98,5 +101,5 @@ let newChildren = children | ||
if (isObs(childI)) { | ||
newChildI = values[++at[0]] | ||
newChildI = values[self.at++] | ||
} else if (isArray(childI)) { | ||
newChildI = renderChildren(childI, at, values) | ||
newChildI = renderChildren(childI, self, values) | ||
} | ||
@@ -115,3 +118,3 @@ if (newChildI !== childI) { | ||
function renderStyle(style, at, values) { | ||
function renderStyle(style, self, values) { | ||
let newStyle = undefined | ||
@@ -129,3 +132,3 @@ for (const i in style) { | ||
} | ||
newStyle[i] = values[++at[0]] | ||
newStyle[i] = values[self.at++] | ||
} else if (newStyle) { | ||
@@ -138,3 +141,5 @@ newStyle[i] = styleI | ||
function render(props, values) { | ||
function render(self, values) { | ||
const props = self.props | ||
let type = null | ||
@@ -144,3 +149,3 @@ let newProps = null | ||
const at = [-1] | ||
self.at = 0 | ||
@@ -150,3 +155,3 @@ for (const key in props) { | ||
if (CHILDREN === key) { | ||
newChildren = renderChildren(val, at, values) | ||
newChildren = renderChildren(val, self, values) | ||
} else if ("$$type" === key) { | ||
@@ -156,9 +161,9 @@ type = props[key] | ||
newProps = newProps || {} | ||
newProps.ref = isObs(val) ? values[++at[0]] : val | ||
newProps.ref = isObs(val) ? values[self.at++] : val | ||
} else if (isObs(val)) { | ||
newProps = newProps || {} | ||
newProps[key] = values[++at[0]] | ||
newProps[key] = values[self.at++] | ||
} else if (STYLE === key) { | ||
newProps = newProps || {} | ||
newProps.style = renderStyle(val, at, values) || val | ||
newProps.style = renderStyle(val, self, values) || val | ||
} else { | ||
@@ -229,3 +234,3 @@ newProps = newProps || {} | ||
values[idx] = value | ||
self.forceUpdate() | ||
self.at && self.forceUpdate() | ||
} | ||
@@ -275,3 +280,3 @@ break | ||
this.values = this | ||
const handlers = e => { | ||
forEachInProps(props, this.handlers = e => { | ||
switch (e.type) { | ||
@@ -282,3 +287,3 @@ case VALUE: { | ||
this.values = value | ||
this.forceUpdate() | ||
this.at && this.forceUpdate() | ||
} | ||
@@ -293,5 +298,3 @@ break | ||
} | ||
} | ||
this.handlers = handlers | ||
forEachInProps(props, handlers, onAny1) | ||
}, onAny1) | ||
break | ||
@@ -310,3 +313,3 @@ } | ||
return null | ||
return render(this.props, [value]) | ||
return render(this, [value]) | ||
} else { | ||
@@ -317,3 +320,3 @@ const values = this.values | ||
return null | ||
return render(this.props, values) | ||
return render(this, values) | ||
} | ||
@@ -359,3 +362,3 @@ } | ||
newProps[DD_REF] = val | ||
else if (KARET_LIFT !== key) | ||
else if (LIFT !== key) | ||
newProps[key] = val | ||
@@ -369,8 +372,8 @@ } | ||
const props = args[1] || object0 | ||
if (isString(type) || props[KARET_LIFT]) { | ||
if (isString(type) || props[LIFT]) { | ||
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) { | ||
args[1] = filterProps(type, props) | ||
args[0] = FromClass | ||
} else if (props[KARET_LIFT]) { | ||
args[1] = dissocPartialU(KARET_LIFT, props) || object0 | ||
} else if (props[LIFT]) { | ||
args[1] = dissocPartialU(LIFT, props) || object0 | ||
} | ||
@@ -377,0 +380,0 @@ } |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
95088
1412
1