Socket
Socket
Sign inDemoInstall

rax

Package Overview
Dependencies
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rax - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

dist/rax.min.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).Rax={})}(this,function(t){"use strict";var k={mountID:1,owner:null,isUpdating:!1,rootComponents:{},rootInstances:{},driver:null};function p(t,e,n,r,o){return{type:t,key:e,ref:n,props:r,_owner:o}}function d(t){if(null==t)return t;var e=[];return function t(e,n){if(Array.isArray(e))for(var r=0,o=e.length;r<o;r++)t(e[r],n);else n.push(e)}(t,e),1===e.length&&(e=e[0]),e}var h={key:!0,ref:!0};function f(t,e,n){if(null==t)throw Error("createElement: type should not be null or undefined."+function(){var t=k.owner;if(t){var e=t.getName();if(e)return" Check the render method of `"+e+"`."}return""}());var r,o={},i=null,u=null,a=k.owner;if(null!=e)for(r in i=void 0===e.key?null:e.key+"","string"!=typeof(u=void 0===e.ref?null:e.ref)||a||console.error('createElement: adding a string ref "'+u+'" outside the render method.'),e)h[r]||(o[r]=e[r]);var s=arguments.length-2;if(0<s)if(1!==s||Array.isArray(n)){var c=n;if(1<s){c=Array(s);for(var l=0;l<s;l++)c[l]=arguments[l+2]}o.children=d(c)}else o.children=n;if(t&&t.defaultProps){var f=t.defaultProps;for(r in f)void 0===o[r]&&(o[r]=f[r])}return new p(t,i,u,o,a)}function u(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}var e,a=function(){function t(t,e){this.props=t,this.context=e,this.refs={}}var e=t.prototype;return e.setState=function(t,e){this.updater.setState(this,t,e)},e.forceUpdate=function(t){this.updater.forceUpdate(this,t)},t}(),n=function(r){function t(t,e){var n;return(n=r.call(this,t,e)||this).isPureComponent=!0,n}return u(t,r),t}(a),s=function(){function t(t){this.handlers=[],this.value=t}var e=t.prototype;return e.on=function(t){this.handlers.push(t)},e.off=function(e){this.handlers=this.handlers.filter(function(t){return t!==e})},e.emit=function(){var e=this;this.handlers.forEach(function(t){return t(e.value)})},t}(),c=0;e="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout;var r=null,o=[],i=[];function l(t){0===o.length&&e(v),o.push(t)}function v(){_();var t=o;0!==t.length&&(o=[],t.forEach(function(t){return t()}),r())}function m(t){0===i.length&&e(_),i.push(t)}function _(){var t=i;0!==t.length&&(i=[],t.forEach(function(t){return t()}))}var C=Object.prototype.hasOwnProperty;function g(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function y(t,e){if(g(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(var r=0;r<n.length;r++)if(!C.call(e,n[r])||!g(t[n[r]],e[n[r]]))return!1;return!0}function N(){return k.owner&&k.owner._instance}function x(){var t=N();if(t)return t;throw Error("Hooks can only be called inside a component.")}function w(t,e){if(null===e||t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!g(t[n],e[n]))return!1;return!0}function b(t,e){U(t,e)}function U(t,e,o){var n=x(),r=n.getHookID(),i=n.getHooks();if(e=void 0===e?null:e,i[r]){var u=i[r],a=u.create,s=u.inputs;u.inputs=e,u.prevInputs=s,a.current=t}else{var c=function t(e){if(!e&&o)return m(function(){return t(!0)});var n=t.current;if(n){var r=k.isUpdating;k.isUpdating=!0,l.current=n(),t.current=null,k.isUpdating=r}},l=function t(e){if(!e&&o)return m(function(){return t(!0)});var n=t.current;if(n){var r=k.isUpdating;k.isUpdating=!0,n(),t.current=null,k.isUpdating=r}};c.current=t,i[r]={create:c,destory:l,prevInputs:e,inputs:e},n.didMount.push(c),n.willUnmount.push(l),n.didUpdate.push(function(){var t=i[r],e=t.inputs,n=t.create;null!=e&&w(e,t.prevInputs)||(l(),n())})}}function E(t,e){var n=x(),r=n.getHookID(),o=n.getHooks();(e=void 0===e?null:e,o[r])?null!==e&&w(e,o[r][1])||(o[r]=[t(),e]):o[r]=[t(),e];return o[r][0]}var I=function(){function t(t){this._currentElement=t}var e=t.prototype;return e.initComponent=function(t,e,n){this._parent=t,this._parentInstance=e,this._context=n,this._mountID=k.mountID++},e.destoryComponent=function(){this._currentElement=null,this._nativeNode=null,this._parent=null,this._parentInstance=null,this._context=null,this._instance&&(this._instance._internal=null,this._instance=null)},e.mountComponent=function(t,e,n,r){return this.initComponent(t,e,n),this.mountNativeNode(r),{_internal:this}},e.unmountComponent=function(t){this._nativeNode&&!t&&k.driver.removeChild(this._nativeNode,this._parent),this.destoryComponent()},e.getName=function(){var t=this._currentElement,e=t&&t.type;return e&&e.displayName||e&&e.name||e||t},e.mountNativeNode=function(t){var e=this.getNativeNode(),n=this._parent;t?t(e,n):k.driver.appendChild(e,n)},e.getNativeNode=function(){return null==this._nativeNode&&(this._nativeNode=this.createNativeNode()),this._nativeNode},e.getPublicInstance=function(){return this.getNativeNode()},t}(),R=function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e.prototype.createNativeNode=function(){return k.driver.createEmpty(this)},e}(I),P={update:function(t,e,n){var r=t&&t.ref||null,o=e&&e.ref||null;r!==o&&(null!=r&&this.detach(t._owner,r,n),null!=o&&this.attach(e._owner,o,n))},attach:function(t,e,n){if(!t)return console.error("ref: multiple version of Rax used in project.");var r=n.getPublicInstance();"function"==typeof e?e(r):"object"==typeof e?e.current=r:t._instance.refs[e]=r},detach:function(t,e,n){if("function"==typeof e)e(null);else{var r=n.getPublicInstance();"object"==typeof e&&e.current===r?e.current=null:t._instance.refs[e]===r&&delete t._instance.refs[e]}}};function S(t){var e;return null==t||!1===t||!0===t?e=new k.Empty:Array.isArray(t)?e=new k.Fragment(t):"object"==typeof t&&t.type?e="string"==typeof t.type?new k.Native(t):new k.Composite(t):"string"==typeof t||"number"==typeof t?e=new k.Text(t+""):D(t),e}function D(t){throw Error("Invalid element type: "+t+". (current: "+("object"==typeof t&&Object.keys(t)||typeof t)+")")}function A(t,e){var n=null===t,r=null===e;if(n||r)return n===r;if(Array.isArray(t)&&Array.isArray(e))return!0;var o=typeof t,i=typeof e;return"string"===o||"number"===o?"string"===i||"number"===i:"object"===o&&"object"===i&&t.type===e.type&&t.key===e.key}var j=function(t,e,n){var r=e&&e.key,o="."+n.toString(36);if("string"!=typeof r)return o;var i="$"+r,u=void 0===t[i];return u||console.warn('Encountered two children with the same key "'+r+'".'),u?i:o},H=1,W=function(e){function t(){var t;return(t=e.call(this)||this).element=[],t.rootID=H++,t}u(t,e);var n=t.prototype;return n.getPublicInstance=function(){return this.getRenderedComponent().getPublicInstance()},n.getRenderedComponent=function(){return this._internal._renderedComponent},n.update=function(t){this.element=t,this.forceUpdate()},n.render=function(){return this.element},t}(a),O={set:function(t,e){t.__r||(t.__r=e).rootID&&(k.rootInstances[e.rootID]=e,k.rootComponents[e.rootID]=e._internal)},get:function(t){return t.__r},remove:function(t){var e=this.get(t);e&&(t.__r=null,e.rootID&&(delete k.rootComponents[e.rootID],delete k.rootInstances[e.rootID]))},mount:function(t,e,n){var r=n.parent,o=n.hydrate,i=k.driver;null==e&&(e=i.createBody());var u,a={element:t,container:e,hydrate:o};if(i.beforeRender&&i.beforeRender(a),r){var s=r._internal;u=s._processChildContext(s._context)}var c=this.get(e);if(c&&c.rootID)return u&&(c._internal._penddingContext=u),c.update(t),c;var l=S(f(W)).mountComponent(e,null,u||{});return this.set(e,l),l.update(t),i.afterRender&&i.afterRender(a),l}};function M(t){return Array.isArray(t)||(t=[t]),t}var F="style",T="children",L=/^on[A-Z]/,Q=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.mountComponent=function(t,e,n,r){var o=this;this.initComponent(t,e,n);var i=this._currentElement,u=i.props,a=i.type,s=u.children,c=u.append||"tree";this._prevStyleCopy=Object.assign({},u.style);var l={_internal:this,type:a,props:u};this._instance=l;var f=function(){null!=s&&o.mountChildren(s,n)};return"tree"===c?(f(),this.mountNativeNode(r)):(this.mountNativeNode(r),f()),i&&i.ref&&P.attach(i._owner,i.ref,this),l},n.mountChildren=function(t,e){t=M(t);var n=this.getNativeNode();return this._mountChildren(n,t,e)},n._mountChildren=function(o,t,i,u){var a=this,s=this._renderedChildren={};return t.map(function(t,e){var n=S(t),r=j(s,t,e);return(s[r]=n)._mountIndex=e,n.mountComponent(o,a._instance,i,u)})},n.unmountChildren=function(t){var e=this._renderedChildren;if(e){for(var n in e){e[n].unmountComponent(t)}this._renderedChildren=null}},n.unmountComponent=function(t){if(this._nativeNode){var e=this._currentElement.ref;e&&P.detach(this._currentElement._owner,e,this),O.remove(this._nativeNode),t||k.driver.removeChild(this._nativeNode,this._parent)}this.unmountChildren(t),this._prevStyleCopy=null,this.destoryComponent()},n.updateComponent=function(t,e,n,r){P.update(t,this._currentElement=e,this);var o=e.props;this.updateProperties(t.props,o),this.updateChildren(o.children,r)},n.updateProperties=function(t,e){var n,r,o,i=k.driver,u=this.getNativeNode();for(n in t)if(n!==T&&null!=t[n]&&!e.hasOwnProperty(n))if(n===F){var a=this._prevStyleCopy;for(r in a)(o=o||{})[r]="";this._prevStyleCopy=null}else if(L.test(n)){var s=t[n];"function"==typeof s&&i.removeEventListener(u,n.slice(2).toLowerCase(),s)}else i.removeAttribute(u,n,t[n]);for(n in e){var c=e[n],l=n===F?this._prevStyleCopy:null!=t?t[n]:void 0;if(n!==T&&l!==c&&(null!=c||null!=l))if(n===F)if(c?c=this._prevStyleCopy=Object.assign({},c):this._prevStyleCopy=null,null!=l){for(r in l)c&&c[r]||((o=o||{})[r]="");for(r in c)l[r]!==c[r]&&((o=o||{})[r]=c[r])}else o=c;else if(L.test(n)){var f=n.slice(2).toLowerCase();"function"==typeof l&&i.removeEventListener(u,f,l,e),"function"==typeof c&&i.addEventListener(u,f,c,e)}else null!=c?i.setAttribute(u,n,c):i.removeAttribute(u,n,t[n])}o&&i.setStyle(u,o)},n.updateChildren=function(t,e){var n=this._renderedChildren,i=k.driver;if(null!=t||null!=n){var r,u,o,a={};if(null!=t)for(var s=0,c=(t=M(t)).length;s<c;s++){var l=t[s],f=j(a,l,s),p=n&&n[f],d=p&&p._currentElement,h=p&&p._context;a[f]=null!=p&&A(d,l)?(d===l&&h===e||p.updateComponent(d,l,e,e),p):(p&&(p._unmount=!0),S(l))}if(null!=n)for(var v in n){var m=n[v],_=m._unmount||!a[v];r?_&&m.unmountComponent():(o=_,u=(r=m).getNativeNode(),Array.isArray(u)&&(u=u[0]))}if(null!=a){var C=function(t,e){if(t=M(t),y)for(var n=t.length-1;0<=n;n--)i.insertAfter(t[n],y);else if(u)for(var r=0;r<t.length;r++)i.insertBefore(t[r],u);else if(e)for(var o=0;o<t.length;o++)i.appendChild(t[o],e)},g=0,y=null,N=[];for(var x in a){var w=a[x],b=n&&n[x];if(b===w){var U=b.getNativeNode();b._mountIndex!==g&&C(U)}else{var E=this.getNativeNode();Array.isArray(E)&&(E=this._parent),w.mountComponent(E,this._instance,e,C)}w._mountIndex=g++,y=w.getNativeNode(),N=N.concat(y),Array.isArray(y)&&(y=y[y.length-1])}if(Array.isArray(this._nativeNode)){this._nativeNode.splice(0,this._nativeNode.length);for(var I=0;I<N.length;I++)this._nativeNode.push(N[I])}}o&&r.unmountComponent(),this._renderedChildren=a}},n.createNativeNode=function(){var t=this._instance,e=k.driver.createElement(t.type,t.props,this);return O.set(e,t),e},e}(I),B=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.updateComponent=function(t,e){t!==(e+="")&&(this._currentElement=e,k.driver.updateText(this.getNativeNode(),this._currentElement))},n.createNativeNode=function(){return k.driver.createText(this._currentElement,this)},e}(I),V=function(n){function t(t,e){var r;(r=n.call(this)||this)._render=t,r._hookID=0,r._reRenders=0,r._hooks={},r.didMount=[],r.didUpdate=[],r.willUnmount=[],r.isScheduled=!1,r.shouldUpdate=!1,r._children=null,r.state={},t.forwardRef&&(r.prevForwardRef=r.forwardRef=e);var o=t.compares;return o&&(r.shouldComponentUpdate=function(t){for(var e=!0,n=o.length-1;-1<n;n--)if(e=o[n](r.props,t))break;return!e||r.prevForwardRef!==r.forwardRef}),r}u(t,n);var e=t.prototype;return e.getHooks=function(){return this._hooks},e.getHookID=function(){return++this._hookID},e.readContext=function(t){var e=this,n=t.Provider,r=this._internal._context[n.contextProp];if(r){var o=this._internal._mountID;if(!r[o]){r[o]={};var i=function(t){t!==r[o].renderedContext&&e.update()};r.on(i),this.willUnmount.push(function(){delete r[o],r.off(i)})}return r[o].renderedContext=r.value}return n.defaultValue},e.componentWillMount=function(){this.shouldUpdate=!0},e.componentDidMount=function(){this.didMount.forEach(function(t){return t()})},e.componentWillReceiveProps=function(){this.shouldUpdate=!0},e.componentDidUpdate=function(){this.didUpdate.forEach(function(t){return t()})},e.componentWillUnmount=function(){this.willUnmount.forEach(function(t){return t()})},e.update=function(){this._internal._isPendingForceUpdate=!0,this.setState({})},e.render=function(){this._hookID=0,this._reRenders=0,this.isScheduled=!1;var t=this._render(this.props,this.forwardRef?this.forwardRef:this.context);while(this.isScheduled){if(this._reRenders++,24<this._reRenders)throw Error("Too many re-renders, the number of renders is limited to prevent an infinite loop.");this._hookID=0,this.isScheduled=!1,t=this._render(this.props,this.forwardRef?this.forwardRef:this.context)}return this.shouldUpdate&&(this._children=t,this.shouldUpdate=!1),this._children},t}(a),Z=[];function $(t){return t._pendingCallbacks}function q(t,e){return t._pendingCallbacks=e}function z(t){return t._pendingStateQueue}function G(t,e){if(t)for(var n=0;n<t.length;n++)t[n].call(e)}function J(t){var e=t._internal;if(e){k.isUpdating=!0;var n=$(e);q(e,null);var r=e._currentElement,o=e._context,i=e._penddingContext||o;e._penddingContext=void 0,(z(e)||e._isPendingForceUpdate)&&e.updateComponent(r,r,o,i),G(n,t),k.isUpdating=!1}}function K(t,e){return e._internal._mountID-t._internal._mountID}function X(){if(k.isUpdating)return l(X);var t,e=Z;if(0<e.length){_(),Z=[],1<e.length&&(e=e.sort(K));while(t=e.pop())J(t)}}function Y(t,e){if(Z.indexOf(t)<0&&Z.push(t),e){if(1<Z.length)return;l(X)}else X()}function tt(t,e,n){var r=t._internal;if(r){var o,i;n&&(i=n,($(o=r)||q(o,[])).push(i));var u,a,s=r._renderedComponent;e?(a=e,(z(u=r)||(u._pendingStateQueue=[])).push(a),!r._isPendingState&&s&&Y(t,!0)):(r._isPendingForceUpdate=!0,s&&Y(t))}}r=X;var et={setState:tt,forceUpdate:function(t,e){tt(t,null,e)},runCallbacks:G};function nt(t,e,n){try{return t()}catch(t){n?n(t):rt(e,t)}}function rt(t,e){var n;while(t){var r=t._internal;if("function"==typeof t.componentDidCatch){n=t;break}if(!r||!r._parentInstance)break;t=r._parentInstance}if(n){var o=n._internal;if(o)(o._pendingCallbacks||(o._pendingCallbacks=[])).push(function(){return n.componentDidCatch(e)})}else setTimeout(function(){throw e},0)}var ot=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.mountComponent=function(t,e,n,r){this.initComponent(t,e,n),this._updateCount=0;var o,i,u=this._currentElement,a=u.type,s=u.ref,c=u.props,l=a.prototype,f=this._processContext(n);try{l&&l.render?o=new a(c,f):"function"==typeof a?o=new V(a,s):D(a)}catch(t){return rt(e,t)}o.props=c,o.context=f,o.refs={},o.updater=et;var p=((o._internal=this)._instance=o).state;void 0===p&&(o.state=p=null);var d=null,h=function(t){d=t};o.componentWillMount&&nt(function(){o.componentWillMount()},o,h),null==i&&(o.state=(k.owner=this)._processPendingState(c,f),nt(function(){i=o.render()},o,h),k.owner=null),this._renderedComponent=S(i),this._renderedComponent.mountComponent(this._parent,o,this._processChildContext(n),r),d&&rt(o,d),!u.type.forwardRef&&s&&P.attach(u._owner,s,this),o.componentDidMount&&nt(function(){o.componentDidMount()},o);var v=this._pendingCallbacks;return v&&(this._pendingCallbacks=null,et.runCallbacks(v,o)),o},n.unmountComponent=function(t){var e=this._instance;if(e&&e.componentWillUnmount&&nt(function(){e.componentWillUnmount()},e),null!=this._renderedComponent){var n=this._currentElement,r=n.ref;!n.type.forwardRef&&r&&P.detach(n._owner,r,this),this._renderedComponent.unmountComponent(t),this._renderedComponent=null}this._pendingStateQueue=null,this._isPendingForceUpdate=!1,this.destoryComponent()},n._processContext=function(t){var e=this._currentElement.type.contextTypes;if(!e)return{};var n={};for(var r in e)n[r]=t[r];return n},n._processChildContext=function(t){var e=this._instance,n=e.getChildContext&&e.getChildContext();return n?Object.assign({},t,n):t},n._processPendingState=function(t,e){var n=this._instance,r=this._pendingStateQueue;if(!r)return n.state;this._pendingStateQueue=null;for(var o=Object.assign({},n.state),i=0;i<r.length;i++){var u=r[i];Object.assign(o,"function"==typeof u?u.call(n,o,t,e):u)}return o},n.updateComponent=function(t,e,n,r){var o=this._instance;if(o){var i,u,a=!1;this._context===r?i=o.context:(i=this._processContext(r),a=!0),t===e?u=e.props:(u=e.props,a=!0),a&&o.componentWillReceiveProps&&(this._isPendingState=!0,nt(function(){o.componentWillReceiveProps(u,i)},o),this._isPendingState=!1),this._currentElement.type.forwardRef?(o.prevForwardRef=t.ref,o.forwardRef=e.ref):P.update(t,e,this);var s=!0,c=o.props,l=o.state,f=this._processPendingState(u,i);if(this._isPendingForceUpdate||(o.shouldComponentUpdate?s=nt(function(){return o.shouldComponentUpdate(u,f,i)},o):o.isPureComponent&&(s=!y(c,u)||!y(l,f))),s){this._isPendingForceUpdate=!1;var p=o.context;nt(function(){o.componentWillUpdate&&o.componentWillUpdate(u,f,i)},o),this._currentElement=e,this._context=r,o.props=u,o.state=f,o.context=i,this._updateRenderedComponent(r),nt(function(){o.componentDidUpdate&&o.componentDidUpdate(c,l,p)},o),this._updateCount++}else this._currentElement=e,this._context=r,o.props=u,o.state=f,o.context=i;var d=this._pendingCallbacks;d&&(this._pendingCallbacks=null,et.runCallbacks(d,o))}},n._updateRenderedComponent=function(t){var e,n=this._renderedComponent,r=n._currentElement,o=this._instance;if(k.owner=this,nt(function(){e=o.render()},o),k.owner=null,A(r,e)){var i=n._context,u=this._processChildContext(t);r===e&&i===u||n.updateComponent(r,e,i,u)}else{var a=n.getNativeNode();n.unmountComponent(!0),this._renderedComponent=S(e),this._renderedComponent.mountComponent(this._parent,o,this._processChildContext(t),function(t,e){a=M(a),t=M(t);for(var n,r=k.driver,o=0;o<t.length;o++){var i=t[o];a[o]?r.replaceChild(i,a[o]):n?r.insertAfter(i,n):r.appendChild(i,e),n=i}if(t.length<a.length)for(var u=t.length;u<a.length;u++)r.removeChild(a[u])})}},n.getNativeNode=function(){var t=this._renderedComponent;if(t)return t.getNativeNode()},n.getPublicInstance=function(){var t=this._instance;return t instanceof V?null:t},e}(I),it=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.mountComponent=function(t,e,n,r){this.initComponent(t,e,n);var o={_internal:this};this._instance=o,this.mountChildren(this._currentElement,n);var i=this.getNativeNode();if(r)r(i,t);else for(var u=0;u<i.length;u++)k.driver.appendChild(i[u],t);return o},n.mountChildren=function(t,e){var n=this.getNativeNode();return this._mountChildren(this._parent,t,e,function(t){t=M(t);for(var e=0;e<t.length;e++)n.push(t[e])})},n.unmountComponent=function(t){var e=this._nativeNode;if(e&&(O.remove(e),!t))for(var n=0;n<e.length;n++)k.driver.removeChild(e[n]);this.unmountChildren(!0),this.destoryComponent()},n.updateComponent=function(t,e,n,r){this._currentElement=e,this.updateChildren(this._currentElement,r)},n.createNativeNode=function(){return[]},e}(Q);var ut={Host:k,Instance:O,Element:p,flattenChildren:d};t.createElement=f,t.createContext=function(o){var t,e,i="__context_"+c+++"__",n=function(e){function t(){var t;return(t=e.call(this)||this).emitter=new s(o),t}u(t,e);var n=t.prototype;return n.getChildContext=function(){var t;return(t={})[i]=this.emitter,t},n.componentWillMount=function(){void 0!==this.props.value&&(this.emitter.value=this.props.value)},n.componentWillReceiveProps=function(t){this.props.value!==t.value&&(this.emitter.value=t.value)},n.componentDidUpdate=function(t){this.props.value!==t.value&&this.emitter.emit()},n.render=function(){return this.props.children},t}(a);n.childContextTypes=((t={})[i]=function(){},t),n.contextProp=i,n.defaultValue=o;var r=function(r){function t(t,e){var n;return(n=r.call(this,t,e)||this).state={value:n.readContext(n.context)},n.onUpdate=function(t){return n.state.value!==t&&n.setState({value:t})},n}u(t,r);var e=t.prototype;return e.readContext=function(t){return t[i]?t[i].value:o},e.componentDidMount=function(){this.context[i]&&this.context[i].on(this.onUpdate)},e.componentWillReceiveProps=function(t,e){var n=this.readContext(e);this.state.value!==n&&this.setState({value:n})},e.componentWillUnmount=function(){this.context[i]&&this.context[i].off(this.onUpdate)},e.render=function(){var t=this.props.children,e=Array.isArray(t)?t[0]:t;if("function"==typeof e)return e(this.state.value)},t}(a);return r.contextTypes=((e={})[i]=function(){},e),{Provider:n,Consumer:r}},t.createRef=function(){return{current:null}},t.forwardRef=function(t){return t.forwardRef=!0,t},t.memo=function(t,e){return void 0===e&&(e=y),t.compares?t.compares.push(e):t.compares=[e],t},t.Fragment=function(t){return t.children},t.render=function(t,e,n,r){"function"==typeof n&&(r=n,n=null),function(t){var e=t.driver;if(k.Empty=R,k.Native=Q,k.Text=B,k.Fragment=it,k.Composite=ot,k.driver=e||k.driver,!k.driver)throw Error("Driver not found.")}(n=n||{});var o=O.mount(t,e,n).getPublicInstance();return r&&r.call(o),o},t.Component=a,t.version="1.0.0-beta",t.shared=ut,t.useState=function(t){var r=x(),o=r.getHookID(),i=r.getHooks();i[o]||("function"==typeof t&&(t=t()),i[o]=[t,function(t){k.isUpdating||_();var e=i[o],n=e[2];"function"==typeof t&&(t=t(n)),g(t,n)||(e[2]=t,N()===r?r.isScheduled=!0:r.update())},t]);var e=i[o];return g(e[0],e[2])||(e[0]=e[2],r.shouldUpdate=!0),e},t.useContext=function(t){return x().readContext(t)},t.useEffect=function(t,e){U(t,e,!0)},t.useLayoutEffect=b,t.useRef=function(t){var e=x(),n=e.getHookID(),r=e.getHooks();return r[n]||(r[n]={current:t}),r[n]},t.useCallback=function(t,e){return E(function(){return t},e)},t.useMemo=E,t.useReducer=function(t,e,n){var o=x(),i=o.getHookID(),u=o.getHooks();if(!u[i]){var r=void 0!==n?n(e):e;return u[i]=[r,function(t){k.isUpdating||_();var e=u[i][2];if(N()===o)e.actions.push(t),o.isScheduled=!0;else{var n=e.eagerState,r=(0,e.eagerReducer)(n,t);if(g(r,n))return;e.eagerState=r,e.actions.push(t),o.update()}},{actions:[],eagerReducer:t,eagerState:r}]}var a=u[i],s=a[2],c=a[0];if(0<o._reRenders||s.eagerReducer!=t)for(var l=0;l<s.actions.length;l++)c=t(c,s.actions[l]);else c=s.eagerState;return g(c,a[0])||(a[0]=c,o.shouldUpdate=!0),s.eagerReducer=t,s.eagerState=c,s.actions.length=0,u[i]},t.useImperativeHandle=function(t,e,n){b(function(){return"function"==typeof t?(t(e()),function(){return t(null)}):null!=t?(t.current=e(),function(){t.current=null}):void 0},null!=n?n.concat([t]):null)},t.PureComponent=n,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).Rax={})}(this,function(t){"use strict";var k={mountID:1,owner:null,isUpdating:!1,rootComponents:{},rootInstances:{},driver:null};function p(t,e,n,r,o){return{type:t,key:e,ref:n,props:r,_owner:o}}function d(t){if(null==t)return t;var e=[];return function t(e,n){if(Array.isArray(e))for(var r=0,o=e.length;r<o;r++)t(e[r],n);else n.push(e)}(t,e),1===e.length&&(e=e[0]),e}var h={key:!0,ref:!0};function f(t,e,n){if(null==t)throw Error("createElement: type should not be null or undefined."+function(){var t=k.owner;if(t){var e=t.getName();if(e)return" Check the render method of `"+e+"`."}return""}());var r,o={},i=null,u=null,a=k.owner;if(null!=e)for(r in i=void 0===e.key?null:e.key+"","string"!=typeof(u=void 0===e.ref?null:e.ref)||a||console.error('createElement: adding a string ref "'+u+'" outside the render method.'),e)h[r]||(o[r]=e[r]);var s=arguments.length-2;if(0<s)if(1!==s||Array.isArray(n)){var c=n;if(1<s){c=Array(s);for(var l=0;l<s;l++)c[l]=arguments[l+2]}o.children=d(c)}else o.children=n;if(t&&t.defaultProps){var f=t.defaultProps;for(r in f)void 0===o[r]&&(o[r]=f[r])}return new p(t,i,u,o,a)}function u(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}var e,a=function(){function t(t,e){this.props=t,this.context=e,this.refs={}}var e=t.prototype;return e.setState=function(t,e){this.updater.setState(this,t,e)},e.forceUpdate=function(t){this.updater.forceUpdate(this,t)},t}(),n=function(r){function t(t,e){var n;return(n=r.call(this,t,e)||this).isPureComponent=!0,n}return u(t,r),t}(a),s=function(){function t(t){this.handlers=[],this.value=t}var e=t.prototype;return e.on=function(t){this.handlers.push(t)},e.off=function(e){this.handlers=this.handlers.filter(function(t){return t!==e})},e.emit=function(){var e=this;this.handlers.forEach(function(t){return t(e.value)})},t}(),c=0;e="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout;var r=[],o=[];function i(t){0===r.length&&e(l),r.push(t)}function l(){var t=r;0!==t.length&&(r=[],t.forEach(function(t){return t()}))}function v(t){0===o.length&&e(m),o.push(t)}function m(){var t=o;0!==t.length&&(o=[],t.forEach(function(t){return t()}))}var _=Object.prototype.hasOwnProperty;function C(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function y(t,e){if(C(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(var r=0;r<n.length;r++)if(!_.call(e,n[r])||!C(t[n[r]],e[n[r]]))return!1;return!0}function g(){return k.owner&&k.owner._instance}function N(){var t=g();if(t)return t;throw Error("Hooks can only be called inside a component.")}function x(t,e){if(null===e||t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!C(t[n],e[n]))return!1;return!0}function w(t,e){b(t,e)}function b(t,e,r){var n=N(),o=n.getHookID(),i=n.getHooks();if(e=void 0===e?null:e,i[o]){var u=i[o],a=u.create,s=u.inputs;u.inputs=e,u.prevInputs=s,a.current=t}else{var c=function t(e){if(!e&&r)return v(function(){return t(!0)});var n=t.current;n&&(l.current=n(),t.current=null)},l=function t(e){if(!e&&r)return v(function(){return t(!0)});var n=t.current;n&&(n(),t.current=null)};c.current=t,i[o]={create:c,destory:l,prevInputs:e,inputs:e},n.didMount.push(c),n.willUnmount.push(l),n.didUpdate.push(function(){var t=i[o],e=t.inputs,n=t.create;null!=e&&x(e,t.prevInputs)||(l(),n())})}}function E(t,e){var n=N(),r=n.getHookID(),o=n.getHooks();(e=void 0===e?null:e,o[r])?null!==e&&x(e,o[r][1])||(o[r]=[t(),e]):o[r]=[t(),e];return o[r][0]}var I=function(){function t(t){this._currentElement=t}var e=t.prototype;return e.initComponent=function(t,e,n){this._parent=t,this._parentInstance=e,this._context=n,this._mountID=k.mountID++},e.destoryComponent=function(){this._currentElement=null,this._nativeNode=null,this._parent=null,this._parentInstance=null,this._context=null,this._instance&&(this._instance._internal=null,this._instance=null)},e.mountComponent=function(t,e,n,r){return this.initComponent(t,e,n),this.mountNativeNode(r),{_internal:this}},e.unmountComponent=function(t){this._nativeNode&&!t&&k.driver.removeChild(this._nativeNode,this._parent),this.destoryComponent()},e.getName=function(){var t=this._currentElement,e=t&&t.type;return e&&e.displayName||e&&e.name||e||t},e.mountNativeNode=function(t){var e=this.getNativeNode(),n=this._parent;t?t(e,n):k.driver.appendChild(e,n)},e.getNativeNode=function(){return null==this._nativeNode&&(this._nativeNode=this.createNativeNode()),this._nativeNode},e.getPublicInstance=function(){return this.getNativeNode()},t}(),U=function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e.prototype.createNativeNode=function(){return k.driver.createEmpty(this)},e}(I),R={update:function(t,e,n){var r=t&&t.ref||null,o=e&&e.ref||null;r!==o&&(null!=r&&this.detach(t._owner,r,n),null!=o&&this.attach(e._owner,o,n))},attach:function(t,e,n){if(!t)return console.error("ref: multiple version of Rax used in project.");var r=n.getPublicInstance();"function"==typeof e?e(r):"object"==typeof e?e.current=r:t._instance.refs[e]=r},detach:function(t,e,n){if("function"==typeof e)e(null);else{var r=n.getPublicInstance();"object"==typeof e&&e.current===r?e.current=null:t._instance.refs[e]===r&&delete t._instance.refs[e]}}};function P(t){var e;return null==t||!1===t||!0===t?e=new k.Empty:Array.isArray(t)?e=new k.Fragment(t):"object"==typeof t&&t.type?e="string"==typeof t.type?new k.Native(t):new k.Composite(t):"string"==typeof t||"number"==typeof t?e=new k.Text(t+""):S(t),e}function S(t){throw Error("Invalid element type: "+t+". (current: "+("object"==typeof t&&Object.keys(t)||typeof t)+")")}function D(t,e){var n=null===t,r=null===e;if(n||r)return n===r;if(Array.isArray(t)&&Array.isArray(e))return!0;var o=typeof t,i=typeof e;return"string"===o||"number"===o?"string"===i||"number"===i:"object"===o&&"object"===i&&t.type===e.type&&t.key===e.key}var A=function(t,e,n){var r=e&&e.key,o="."+n.toString(36);if("string"!=typeof r)return o;var i="$"+r,u=void 0===t[i];return u||console.warn('Encountered two children with the same key "'+r+'".'),u?i:o},j=1,H=function(e){function t(){var t;return(t=e.call(this)||this).element=[],t.rootID=j++,t}u(t,e);var n=t.prototype;return n.getPublicInstance=function(){return this.getRenderedComponent().getPublicInstance()},n.getRenderedComponent=function(){return this._internal._renderedComponent},n.update=function(t){this.element=t,this.forceUpdate()},n.render=function(){return this.element},t}(a),W="__r",O={set:function(t,e){t[W]||(t[W]=e).rootID&&(k.rootInstances[e.rootID]=e,k.rootComponents[e.rootID]=e._internal)},get:function(t){return t[W]},remove:function(t){var e=this.get(t);e&&(t[W]=null,e.rootID&&(delete k.rootComponents[e.rootID],delete k.rootInstances[e.rootID]))},mount:function(t,e,n){var r=n.parent,o=n.hydrate,i=k.driver;null==e&&(e=i.createBody());var u,a={element:t,container:e,hydrate:o};if(i.beforeRender&&i.beforeRender(a),r){var s=r._internal;u=s._processChildContext(s._context)}var c=this.get(e);if(c&&c.rootID)return u&&(c._internal._penddingContext=u),c.update(t),c;var l=P(f(H)).mountComponent(e,null,u||{});return this.set(e,l),l.update(t),i.afterRender&&i.afterRender(a),l}};function M(t){return Array.isArray(t)||(t=[t]),t}var F="style",T="children",L=/^on[A-Z]/,Q=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.mountComponent=function(t,e,n,r){var o=this;this.initComponent(t,e,n);var i=this._currentElement,u=i.props,a=i.type,s=u.children,c=u.append||"tree";this._prevStyleCopy=Object.assign({},u.style);var l={_internal:this,type:a,props:u};this._instance=l;var f=function(){null!=s&&o.mountChildren(s,n)};return"tree"===c?(f(),this.mountNativeNode(r)):(this.mountNativeNode(r),f()),i&&i.ref&&R.attach(i._owner,i.ref,this),l},n.mountChildren=function(t,e){t=M(t);var n=this.getNativeNode();return this._mountChildren(n,t,e)},n._mountChildren=function(o,t,i,u){var a=this,s=this._renderedChildren={};return t.map(function(t,e){var n=P(t),r=A(s,t,e);return(s[r]=n)._mountIndex=e,n.mountComponent(o,a._instance,i,u)})},n.unmountChildren=function(t){var e=this._renderedChildren;if(e){for(var n in e){e[n].unmountComponent(t)}this._renderedChildren=null}},n.unmountComponent=function(t){if(this._nativeNode){var e=this._currentElement.ref;e&&R.detach(this._currentElement._owner,e,this),O.remove(this._nativeNode),t||k.driver.removeChild(this._nativeNode,this._parent)}this.unmountChildren(t),this._prevStyleCopy=null,this.destoryComponent()},n.updateComponent=function(t,e,n,r){R.update(t,this._currentElement=e,this);var o=e.props;this.updateProperties(t.props,o),this.updateChildren(o.children,r)},n.updateProperties=function(t,e){var n,r,o,i=k.driver,u=this.getNativeNode();for(n in t)if(n!==T&&null!=t[n]&&!e.hasOwnProperty(n))if(n===F){var a=this._prevStyleCopy;for(r in a)(o=o||{})[r]="";this._prevStyleCopy=null}else if(L.test(n)){var s=t[n];"function"==typeof s&&i.removeEventListener(u,n.slice(2).toLowerCase(),s)}else i.removeAttribute(u,n,t[n]);for(n in e){var c=e[n],l=n===F?this._prevStyleCopy:null!=t?t[n]:void 0;if(n!==T&&l!==c&&(null!=c||null!=l))if(n===F)if(c?c=this._prevStyleCopy=Object.assign({},c):this._prevStyleCopy=null,null!=l){for(r in l)c&&(c[r]||0===c[r])||((o=o||{})[r]="");for(r in c)l[r]!==c[r]&&((o=o||{})[r]=c[r])}else o=c;else if(L.test(n)){var f=n.slice(2).toLowerCase();"function"==typeof l&&i.removeEventListener(u,f,l,e),"function"==typeof c&&i.addEventListener(u,f,c,e)}else null!=c?i.setAttribute(u,n,c):i.removeAttribute(u,n,t[n])}o&&i.setStyle(u,o)},n.updateChildren=function(t,e){var n=this._renderedChildren,i=k.driver;if(null!=t||null!=n){var r,u,o,a={};if(null!=t)for(var s=0,c=(t=M(t)).length;s<c;s++){var l=t[s],f=A(a,l,s),p=n&&n[f],d=p&&p._currentElement,h=p&&p._context;a[f]=null!=p&&D(d,l)?(d===l&&h===e||p.updateComponent(d,l,e,e),p):(p&&(p._unmount=!0),P(l))}if(null!=n)for(var v in n){var m=n[v],_=m._unmount||!a[v];r?_&&m.unmountComponent():(o=_,u=(r=m).getNativeNode(),Array.isArray(u)&&(u=u[0]))}if(null!=a){var C=function(t,e){if(t=M(t),g)for(var n=t.length-1;0<=n;n--)i.insertAfter(t[n],g);else if(u)for(var r=0;r<t.length;r++)i.insertBefore(t[r],u);else if(e)for(var o=0;o<t.length;o++)i.appendChild(t[o],e)},y=0,g=null,N=[];for(var x in a){var w=a[x],b=n&&n[x];if(b===w){var E=b.getNativeNode();b._mountIndex!==y&&C(E)}else{var I=this.getNativeNode();Array.isArray(I)&&(I=this._parent),w.mountComponent(I,this._instance,e,C)}w._mountIndex=y++,g=w.getNativeNode(),N=N.concat(g),Array.isArray(g)&&(g=g[g.length-1])}if(Array.isArray(this._nativeNode)){this._nativeNode.splice(0,this._nativeNode.length);for(var U=0;U<N.length;U++)this._nativeNode.push(N[U])}}o&&r.unmountComponent(),this._renderedChildren=a}},n.createNativeNode=function(){var t=this._instance,e=k.driver.createElement(t.type,t.props,this);return O.set(e,t),e},e}(I),B=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.updateComponent=function(t,e){t!==(e+="")&&(this._currentElement=e,k.driver.updateText(this.getNativeNode(),this._currentElement))},n.createNativeNode=function(){return k.driver.createText(this._currentElement,this)},e}(I),V=function(n){function t(t,e){var r;(r=n.call(this)||this)._render=t,r._hookID=0,r._reRenders=0,r._hooks={},r.didMount=[],r.didUpdate=[],r.willUnmount=[],r.isScheduled=!1,r.shouldUpdate=!1,r._children=null,r.state={},t.forwardRef&&(r.prevForwardRef=r.forwardRef=e);var o=t.compares;return o&&(r.shouldComponentUpdate=function(t){for(var e=!0,n=o.length-1;-1<n;n--)if(e=o[n](r.props,t))break;return!e||r.prevForwardRef!==r.forwardRef}),r}u(t,n);var e=t.prototype;return e.getHooks=function(){return this._hooks},e.getHookID=function(){return++this._hookID},e.readContext=function(t){var e=this,n=t.Provider,r=this._internal._context[n.contextProp];if(r){var o=this._internal._mountID;if(!r[o]){r[o]={};var i=function(t){t!==r[o].renderedContext&&e.update()};r.on(i),this.willUnmount.push(function(){delete r[o],r.off(i)})}return r[o].renderedContext=r.value}return n.defaultValue},e.componentWillMount=function(){this.shouldUpdate=!0},e.componentDidMount=function(){this.didMount.forEach(function(t){return t()})},e.componentWillReceiveProps=function(){this.shouldUpdate=!0},e.componentDidUpdate=function(){this.didUpdate.forEach(function(t){return t()})},e.componentWillUnmount=function(){this.willUnmount.forEach(function(t){return t()})},e.update=function(){this._internal._isPendingForceUpdate=!0,this.setState({})},e.render=function(){this._hookID=0,this._reRenders=0,this.isScheduled=!1;var t=this._render(this.props,this.forwardRef?this.forwardRef:this.context);while(this.isScheduled){if(this._reRenders++,24<this._reRenders)throw Error("Too many re-renders, the number of renders is limited to prevent an infinite loop.");this._hookID=0,this.isScheduled=!1,t=this._render(this.props,this.forwardRef?this.forwardRef:this.context)}return this.shouldUpdate&&(this._children=t,this.shouldUpdate=!1),this._children},t}(a),Z=[];function $(t){return t._pendingCallbacks}function q(t,e){return t._pendingCallbacks=e}function z(t){return t._pendingStateQueue}function G(t,e){if(t)for(var n=0;n<t.length;n++)t[n].call(e)}function J(t){var e=t._internal;if(e){k.isUpdating=!0;var n=$(e);q(e,null);var r=e._currentElement,o=e._context,i=e._penddingContext||o;e._penddingContext=void 0,(z(e)||e._isPendingForceUpdate)&&e.updateComponent(r,r,o,i),G(n,t),k.isUpdating=!1}}function K(t,e){return e._internal._mountID-t._internal._mountID}function X(){if(k.isUpdating)return i(X);var t,e=Z;if(0<e.length){m(),Z=[],1<e.length&&(e=e.sort(K));while(t=e.pop())J(t)}}function Y(t,e){if(Z.indexOf(t)<0&&Z.push(t),e){if(1<Z.length)return;i(X)}else X()}function tt(t,e,n){var r=t._internal;if(r){var o,i;n&&(i=n,($(o=r)||q(o,[])).push(i));var u,a,s=r._renderedComponent;e?(a=e,(z(u=r)||(u._pendingStateQueue=[])).push(a),!r._isPendingState&&s&&Y(t,!0)):(r._isPendingForceUpdate=!0,s&&Y(t))}}var et={setState:function(t,e,n){k.isUpdating||m(),tt(t,e,n)},forceUpdate:function(t,e){tt(t,null,e)},runCallbacks:G};function nt(t,e,n){try{return t()}catch(t){n?n(t):rt(e,t)}}function rt(t,e){var n;while(t){var r=t._internal;if("function"==typeof t.componentDidCatch){n=t;break}if(!r||!r._parentInstance)break;t=r._parentInstance}if(n){var o=n._internal;if(o)(o._pendingCallbacks||(o._pendingCallbacks=[])).push(function(){return n.componentDidCatch(e)})}else setTimeout(function(){throw e},0)}var ot=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.mountComponent=function(t,e,n,r){this.initComponent(t,e,n),this._updateCount=0;var o,i,u=this._currentElement,a=u.type,s=u.ref,c=u.props,l=a.prototype,f=this._processContext(n);try{l&&l.render?o=new a(c,f):"function"==typeof a?o=new V(a,s):S(a)}catch(t){return rt(e,t)}o.props=c,o.context=f,o.refs={},o.updater=et;var p=((o._internal=this)._instance=o).state;void 0===p&&(o.state=p=null);var d=null,h=function(t){d=t};o.componentWillMount&&nt(function(){o.componentWillMount()},o,h),null==i&&(o.state=(k.owner=this)._processPendingState(c,f),nt(function(){i=o.render()},o,h),k.owner=null),this._renderedComponent=P(i),this._renderedComponent.mountComponent(this._parent,o,this._processChildContext(n),r),d&&rt(o,d),!u.type.forwardRef&&s&&R.attach(u._owner,s,this),o.componentDidMount&&nt(function(){o.componentDidMount()},o);var v=this._pendingCallbacks;return v&&(this._pendingCallbacks=null,et.runCallbacks(v,o)),o},n.unmountComponent=function(t){var e=this._instance;if(e&&e.componentWillUnmount&&nt(function(){e.componentWillUnmount()},e),null!=this._renderedComponent){var n=this._currentElement,r=n.ref;!n.type.forwardRef&&r&&R.detach(n._owner,r,this),this._renderedComponent.unmountComponent(t),this._renderedComponent=null}this._pendingStateQueue=null,this._isPendingForceUpdate=!1,this.destoryComponent()},n._processContext=function(t){var e=this._currentElement.type.contextTypes;if(!e)return{};var n={};for(var r in e)n[r]=t[r];return n},n._processChildContext=function(t){var e=this._instance,n=e.getChildContext&&e.getChildContext();return n?Object.assign({},t,n):t},n._processPendingState=function(t,e){var n=this._instance,r=this._pendingStateQueue;if(!r)return n.state;this._pendingStateQueue=null;for(var o=Object.assign({},n.state),i=0;i<r.length;i++){var u=r[i];Object.assign(o,"function"==typeof u?u.call(n,o,t,e):u)}return o},n.updateComponent=function(t,e,n,r){var o=this._instance;if(o){var i,u,a=!1;this._context===r?i=o.context:(i=this._processContext(r),a=!0),t===e?u=e.props:(u=e.props,a=!0),a&&o.componentWillReceiveProps&&(this._isPendingState=!0,nt(function(){o.componentWillReceiveProps(u,i)},o),this._isPendingState=!1),this._currentElement.type.forwardRef?(o.prevForwardRef=t.ref,o.forwardRef=e.ref):R.update(t,e,this);var s=!0,c=o.props,l=o.state,f=this._processPendingState(u,i);if(this._isPendingForceUpdate||(o.shouldComponentUpdate?s=nt(function(){return o.shouldComponentUpdate(u,f,i)},o):o.isPureComponent&&(s=!y(c,u)||!y(l,f))),s){this._isPendingForceUpdate=!1;var p=o.context;nt(function(){o.componentWillUpdate&&o.componentWillUpdate(u,f,i)},o),this._currentElement=e,this._context=r,o.props=u,o.state=f,o.context=i,this._updateRenderedComponent(r),nt(function(){o.componentDidUpdate&&o.componentDidUpdate(c,l,p)},o),this._updateCount++}else this._currentElement=e,this._context=r,o.props=u,o.state=f,o.context=i;var d=this._pendingCallbacks;d&&(this._pendingCallbacks=null,et.runCallbacks(d,o))}},n._updateRenderedComponent=function(t){var e,n=this._renderedComponent,r=n._currentElement,o=this._instance;if(k.owner=this,nt(function(){e=o.render()},o),k.owner=null,D(r,e)){var i=n._context,u=this._processChildContext(t);r===e&&i===u||n.updateComponent(r,e,i,u)}else{var a=n.getNativeNode();n.unmountComponent(!0),this._renderedComponent=P(e),this._renderedComponent.mountComponent(this._parent,o,this._processChildContext(t),function(t,e){a=M(a),t=M(t);for(var n,r=k.driver,o=0;o<t.length;o++){var i=t[o];a[o]?r.replaceChild(i,a[o]):n?r.insertAfter(i,n):r.appendChild(i,e),n=i}if(t.length<a.length)for(var u=t.length;u<a.length;u++)r.removeChild(a[u])})}},n.getNativeNode=function(){var t=this._renderedComponent;if(t)return t.getNativeNode()},n.getPublicInstance=function(){var t=this._instance;return t instanceof V?null:t},e}(I),it=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var n=e.prototype;return n.mountComponent=function(t,e,n,r){this.initComponent(t,e,n);var o={_internal:this};this._instance=o,this.mountChildren(this._currentElement,n);var i=this.getNativeNode();if(r)r(i,t);else for(var u=0;u<i.length;u++)k.driver.appendChild(i[u],t);return o},n.mountChildren=function(t,e){var n=this.getNativeNode();return this._mountChildren(this._parent,t,e,function(t){t=M(t);for(var e=0;e<t.length;e++)n.push(t[e])})},n.unmountComponent=function(t){var e=this._nativeNode;if(e&&(O.remove(e),!t))for(var n=0;n<e.length;n++)k.driver.removeChild(e[n]);this.unmountChildren(!0),this.destoryComponent()},n.updateComponent=function(t,e,n,r){this._currentElement=e,this.updateChildren(this._currentElement,r)},n.createNativeNode=function(){return[]},e}(Q);var ut={Host:k,Instance:O,Element:p,flattenChildren:d};t.createElement=f,t.createContext=function(o){var t,e,i="__context_"+c+++"__",n=function(e){function t(){var t;return(t=e.call(this)||this).emitter=new s(o),t}u(t,e);var n=t.prototype;return n.getChildContext=function(){var t;return(t={})[i]=this.emitter,t},n.componentWillMount=function(){void 0!==this.props.value&&(this.emitter.value=this.props.value)},n.componentWillReceiveProps=function(t){this.props.value!==t.value&&(this.emitter.value=t.value)},n.componentDidUpdate=function(t){this.props.value!==t.value&&this.emitter.emit()},n.render=function(){return this.props.children},t}(a);n.childContextTypes=((t={})[i]=function(){},t),n.contextProp=i,n.defaultValue=o;var r=function(r){function t(t,e){var n;return(n=r.call(this,t,e)||this).state={value:n.readContext(n.context)},n.onUpdate=function(t){return n.state.value!==t&&n.setState({value:t})},n}u(t,r);var e=t.prototype;return e.readContext=function(t){return t[i]?t[i].value:o},e.componentDidMount=function(){this.context[i]&&this.context[i].on(this.onUpdate)},e.componentWillReceiveProps=function(t,e){var n=this.readContext(e);this.state.value!==n&&this.setState({value:n})},e.componentWillUnmount=function(){this.context[i]&&this.context[i].off(this.onUpdate)},e.render=function(){var t=this.props.children,e=Array.isArray(t)?t[0]:t;if("function"==typeof e)return e(this.state.value)},t}(a);return r.contextTypes=((e={})[i]=function(){},e),{Provider:n,Consumer:r}},t.createRef=function(){return{current:null}},t.forwardRef=function(t){return t.forwardRef=!0,t},t.memo=function(t,e){return void 0===e&&(e=y),t.compares?t.compares.push(e):t.compares=[e],t},t.Fragment=function(t){return t.children},t.render=function(t,e,n,r){"function"==typeof n&&(r=n,n=null),function(t){var e=t.driver;if(k.Empty=U,k.Native=Q,k.Text=B,k.Fragment=it,k.Composite=ot,k.driver=e||k.driver,!k.driver)throw Error("Driver not found.")}(n=n||{});var o=O.mount(t,e,n).getPublicInstance();return r&&r.call(o),o},t.Component=a,t.version="1.0.2",t.shared=ut,t.useState=function(t){var r=N(),o=r.getHookID(),i=r.getHooks();i[o]||("function"==typeof t&&(t=t()),i[o]=[t,function(t){k.isUpdating||m();var e=i[o],n=e[2];"function"==typeof t&&(t=t(n)),C(t,n)||(e[2]=t,g()===r?r.isScheduled=!0:r.update())},t]);var e=i[o];return C(e[0],e[2])||(e[0]=e[2],r.shouldUpdate=!0),e},t.useContext=function(t){return N().readContext(t)},t.useEffect=function(t,e){b(t,e,!0)},t.useLayoutEffect=w,t.useRef=function(t){var e=N(),n=e.getHookID(),r=e.getHooks();return r[n]||(r[n]={current:t}),r[n]},t.useCallback=function(t,e){return E(function(){return t},e)},t.useMemo=E,t.useReducer=function(t,e,n){var o=N(),i=o.getHookID(),u=o.getHooks();if(!u[i]){var r=void 0!==n?n(e):e;return u[i]=[r,function(t){k.isUpdating||m();var e=u[i][2];if(g()===o)e.actions.push(t),o.isScheduled=!0;else{var n=e.eagerState,r=(0,e.eagerReducer)(n,t);if(C(r,n))return;e.eagerState=r,e.actions.push(t),o.update()}},{actions:[],eagerReducer:t,eagerState:r}]}var a=u[i],s=a[2],c=a[0];if(0<o._reRenders||s.eagerReducer!=t)for(var l=0;l<s.actions.length;l++)c=t(c,s.actions[l]);else c=s.eagerState;return C(c,a[0])||(a[0]=c,o.shouldUpdate=!0),s.eagerReducer=t,s.eagerState=c,s.actions.length=0,u[i]},t.useImperativeHandle=function(t,e,n){w(function(){return"function"==typeof t?(t(e()),function(){return t(null)}):null!=t?(t.current=e(),function(){t.current=null}):void 0},null!=n?n.concat([t]):null)},t.PureComponent=n,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=rax.min.js.map

@@ -65,3 +65,3 @@ "use strict";

var setState = function setState(newState) {
// Flush effects first when not in effect
// Flush all effects first before update state
if (!_host.default.isUpdating) {

@@ -132,8 +132,4 @@ (0, _scheduler.flushEffect)();

if (current) {
// Set this to true to prevent re-entrancy
var previousIsRendering = _host.default.isUpdating;
_host.default.isUpdating = true;
destory.current = current();
create.current = null;
_host.default.isUpdating = previousIsRendering;
}

@@ -149,8 +145,4 @@ };

if (current) {
// Set this to true to prevent re-entrancy
var previousIsRendering = _host.default.isUpdating;
_host.default.isUpdating = true;
current();
destory.current = null;
_host.default.isUpdating = previousIsRendering;
}

@@ -254,3 +246,3 @@ };

var dispatch = function dispatch(action) {
// Flush effects first when not in effect
// Flush all effects first before update state
if (!_host.default.isUpdating) {

@@ -257,0 +249,0 @@ (0, _scheduler.flushEffect)();

@@ -220,3 +220,3 @@ "use strict";

for (styleName in prevProp) {
if (!nextProp || !nextProp[styleName]) {
if (!nextProp || !nextProp[styleName] && nextProp[styleName] !== 0) {
styleUpdates = styleUpdates || {};

@@ -223,0 +223,0 @@ styleUpdates[styleName] = '';

@@ -8,6 +8,6 @@ "use strict";

exports.flushEffect = flushEffect;
exports.setUpdater = setUpdater;
var scheduler;
if (process.env.NODE_ENV !== 'production') {
// For jest hijack timers
scheduler = function scheduler(callback) {

@@ -20,3 +20,2 @@ setTimeout(callback);

var performUpdate = null;
var updateCallbacks = [];

@@ -35,3 +34,2 @@ var effectCallbacks = []; // Schedule before next render

function flush() {
flushEffect();
var callbacks = updateCallbacks;

@@ -43,5 +41,3 @@

return callback();
}); // Exec callback maybe schedule a work
performUpdate();
});
}

@@ -67,6 +63,2 @@ }

}
}
function setUpdater(handle) {
performUpdate = handle;
}

@@ -152,5 +152,11 @@ "use strict";

(0, _scheduler.setUpdater)(performUpdate);
var Updater = {
setState: requestUpdate,
setState: function setState(component, partialState, callback) {
// Flush all effects first before update state
if (!_host.default.isUpdating) {
(0, _scheduler.flushEffect)();
}
requestUpdate(component, partialState, callback);
},
forceUpdate: function forceUpdate(component, callback) {

@@ -157,0 +163,0 @@ requestUpdate(component, null, callback);

@@ -5,3 +5,3 @@ "use strict";

exports.default = void 0;
var _default = '1.0.0-beta';
var _default = '1.0.2';
exports.default = _default;
{
"name": "rax",
"version": "1.0.1",
"version": "1.0.2",
"description": "A universal React-compatible render engine.",

@@ -5,0 +5,0 @@ "license": "BSD-3-Clause",

@@ -45,3 +45,3 @@ import Host from './vdom/host';

const setState = newState => {
// Flush effects first when not in effect
// Flush all effects first before update state
if (!Host.isUpdating) {

@@ -111,8 +111,4 @@ flushEffect();

if (current) {
// Set this to true to prevent re-entrancy
const previousIsRendering = Host.isUpdating;
Host.isUpdating = true;
destory.current = current();
create.current = null;
Host.isUpdating = previousIsRendering;
}

@@ -125,8 +121,4 @@ };

if (current) {
// Set this to true to prevent re-entrancy
const previousIsRendering = Host.isUpdating;
Host.isUpdating = true;
current();
destory.current = null;
Host.isUpdating = previousIsRendering;
}

@@ -223,3 +215,3 @@ };

const dispatch = action => {
// Flush effects first when not in effect
// Flush all effects first before update state
if (!Host.isUpdating) {

@@ -226,0 +218,0 @@ flushEffect();

@@ -6,5 +6,12 @@ /* eslint-disable react/no-did-mount-set-state */

import renderer from '../renderer';
import { flush } from '../../vdom/scheduler';
describe('renderer', () => {
beforeEach(function() {
jest.useFakeTimers();
});
afterEach(function() {
jest.useRealTimers();
});
it('renders a simple component', () => {

@@ -91,3 +98,3 @@ function Link() {

var component = renderer.create(<MyComponent />);
flush();
jest.runAllTimers();
expect(component.toJSON()).toEqual({

@@ -128,3 +135,3 @@ tagName: 'DIV',

mouse.handleMoose();
flush();
jest.runAllTimers();

@@ -131,0 +138,0 @@ expect(component.toJSON()).toEqual({

import createElement from '../../createElement';
import Component from '../../vdom/component';
import renderer from '../renderer';
import { flush } from '../../vdom/scheduler';

@@ -44,22 +43,33 @@ const STATUS = {

test('Link changes the class when hovered', () => {
const component = renderer.create(
<Link page="https://example.com">Example</Link>
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
describe('snapshot', () => {
beforeEach(function() {
jest.useFakeTimers();
});
// manually trigger the callback
tree.eventListeners.mouseenter();
// re-rendering
tree = component.toJSON();
flush();
expect(tree).toMatchSnapshot();
afterEach(function() {
jest.useRealTimers();
});
// manually trigger the callback
tree.eventListeners.mouseleave();
// re-rendering
tree = component.toJSON();
flush();
expect(tree).toMatchSnapshot();
test('Link changes the class when hovered', () => {
const component = renderer.create(
<Link page="https://example.com">Example</Link>
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
// manually trigger the callback
tree.eventListeners.mouseenter();
jest.runAllTimers();
// re-rendering
tree = component.toJSON();
expect(tree).toMatchSnapshot();
// manually trigger the callback
tree.eventListeners.mouseleave();
jest.runAllTimers();
// re-rendering
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
});

@@ -217,3 +217,3 @@ import Host from './host';

for (styleName in prevProp) {
if (!nextProp || !nextProp[styleName]) {
if (!nextProp || !nextProp[styleName] && nextProp[styleName] !== 0) {
styleUpdates = styleUpdates || {};

@@ -220,0 +220,0 @@ styleUpdates[styleName] = '';

let scheduler;
if (process.env.NODE_ENV !== 'production') {
// For jest hijack timers
scheduler = (callback) => {

@@ -10,3 +11,2 @@ setTimeout(callback);

let performUpdate = null;
let updateCallbacks = [];

@@ -25,3 +25,2 @@ let effectCallbacks = [];

export function flush() {
flushEffect();
let callbacks = updateCallbacks;

@@ -31,4 +30,2 @@ if (callbacks.length !== 0) {

callbacks.forEach(callback => callback());
// Exec callback maybe schedule a work
performUpdate();
}

@@ -51,5 +48,1 @@ }

}
export function setUpdater(handle) {
performUpdate = handle;
}
import Host from './host';
import { flushEffect, schedule, setUpdater } from './scheduler';
import { flushEffect, schedule } from './scheduler';

@@ -150,6 +150,10 @@ // Dirty components store

setUpdater(performUpdate);
const Updater = {
setState: requestUpdate,
setState: function(component, partialState, callback) {
// Flush all effects first before update state
if (!Host.isUpdating) {
flushEffect();
}
requestUpdate(component, partialState, callback);
},
forceUpdate: function(component, callback) {

@@ -156,0 +160,0 @@ requestUpdate(component, null, callback);

@@ -1,1 +0,1 @@

export default '1.0.0-beta';
export default '1.0.2';

Sorry, the diff of this file is too big to display

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc