Comparing version 0.9.0-alpha3 to 0.9.0-alpha4
@@ -1,1 +0,1 @@ | ||
var e={key:1,ref:1},t={className:"class",htmlFor:"for",acceptCharset:"accept-charset",httpEquiv:"http-equiv"},n={doubleclick:"dblclick"},r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,o="http://www.w3.org/1999/xlink";function i(e){return e.nodeName.toLowerCase()}function a(e){return null==e}var s=0;function u(){return s++}function c(e){e.__brahmosData={events:{}}}function d(e,t){var n,r={};for(n in e)"key"===n||"ref"===n&&!t||(r[n]=e[n]);return r}function p(e,t){for(var n=Object.keys(e),r=0,o=n.length;r<o;r++){var i=n[r];t(i,e[i])}}function f(e){Array.isArray(e)||(e=[e]);for(var t=e.length-1;t>=0;t--){var n=e[t];n.parentNode.removeChild(n)}}function l(e){return Array.prototype.slice.call(e)}function h(e,t,n){t=void 0===t?null:t;var r=function(e){var t=e instanceof NodeList;if(e instanceof Node)return e;if(Array.isArray(e)||t){for(var n=document.createDocumentFragment(),r=0;e[r];)n.appendChild(e[r]),t||(r+=1);return n}return document.createTextNode(e)}(n),o=r instanceof DocumentFragment?l(r.childNodes):r;return e.insertBefore(r,t),o}function v(e,t){return t?t.nextSibling:e.firstChild}function m(e,t,n){if(e[t])return e[t].apply(e,n)}function y(e){var t=e.parentNode,n=document.createTextNode("");return t.insertBefore(n,e),n}var g=Promise.resolve();function b(e){return g.then(e)}function T(){return u()+"-"+1e6*Math.random()}var _={transitionId:"",tryCount:0,transitionState:"timedOut"},S={transitionId:T(),tryCount:0,transitionState:"timedOut"};function C(e){var t=e.transitionState;return"start"===t||"resolved"===t||"timedOut"===t}function I(e){var t=e.transitionState;return"completed"===t||"timedOut"===t}function D(e,t){return t=t||_,e.root.currentTransition||t}function N(e){return e.pendingTransitions.find(C)}var k="js",w=_;function x(){return k}function E(){return w}function U(e,t){k=e,t(),b((function(){k="js"}))}function A(e,t){var n=w;w=e,U("transition",t),w=n}function P(){return"transition"===k?"deferred":"sync"}function F(e){return"deferred"===e?"pendingDeferredUpdates":"pendingSyncUpdates"}function M(e){var t=e.root.updateType,n=e.nodeInstance.__brahmosData,r=D(e).transitionId;return n[F(t)].filter((function(e){return e.transitionId===r}))}function O(e){A(S,e)}function j(e){U("immediate_action",e)}var L,R=Symbol("tag"),H=Symbol("tag-element"),V=Symbol("class-component"),W=Symbol("functional-component"),z=Symbol("attribute");function q(e){var t=e.nodeType;return t===R||t===H}function B(e){var t=e.nodeType;return t===V||t===W}function $(e){return"string"==typeof e||"number"==typeof e}function G(e){return!(a(e)||"boolean"==typeof e)}function J(e,t){var n=e&&e.key;if(""===n&&e&&q(e)){for(var r=e.values,o=0,i=r.length;o<i;o++){var a=r[o];if(void 0!==a.key){n=""+a.key;break}}e.key=void 0===n?"":""+n}return""===n?""+t:n}function K(e,t,n){return{nodeType:null,key:n,added:!1,ref:null,portalContainer:null,type:null,props:e,element:"",values:t,template:null}}function Q(){return L}function X(e){return"deferred"===e?"lastDeferredCompleteTime":"lastCompleteTime"}function Y(e){return"deferred"===e?"deferredUpdateTime":"updateTime"}function Z(e,t){for(var n=Y(t),r=u();e;)e[n]=r,e=e.parent}function ee(e,t,n){t===n?n.child=e:t.sibling=e,e.parent=n}function te(e,t){e.hasUncommittedEffect=t,e.root.hasUncommittedEffect=!0}function ne(e,t,n,r){var o=e.root,i=e.node,a=e.part,s=e.nodeInstance,c=e.child,d=Y(o.updateType);return t?(t.node=i,t.part=a,t.createdAt=u()):function(e,t){e&&(e.alternate=t);t.alternate=e}(e,t=ie(o,i,a)),e.shouldTearDown=!1,t.nodeInstance=s,t.child=c,t[d]=r[d],ee(t,n,r),t}function re(e,t){return e===t?e.child:e.sibling}function oe(e){var t=e.child;if("sync"!==e.root.updateType)for(var n;t;){n=ne(t,t.alternate,n||e,e),t=t.sibling}}function ie(e,t,n){return t&&t.portalContainer&&(n.parentNode=t.portalContainer),{node:t,nodeInstance:null,root:e,parent:null,child:null,sibling:null,part:n,alternate:null,context:null,childFiberError:null,isSvgPart:!1,deferredUpdateTime:0,updateTime:0,processedTime:0,createdAt:u(),shouldTearDown:!1,hasUncommittedEffect:0}}function ae(e,t,n,r,o){var i,s,u,c=r.root,d=Y(c.updateType);return n&&!a(n.node)&&!a(e)&&(s=e,u=n.node,$(s)&&$(u)||s.nodeType===z||Array.isArray(s)&&Array.isArray(u)||B(s)&&s.type===u.type||q(s)&&s.template===u.template)?((i=ne(n,n.alternate,r,o)).node=e,i.part=t):(i=ie(c,e,t),n&&pe(n)),ee(i,r,o),i.processedTime=0,i[d]=o[d],i.context=o.context,i.isSvgPart=o.isSvgPart,i}function se(e,t,n){return e&&e[n]>=t}function ue(e,t,n){if(e){for(;e&&!se(e,t,n);)e=e.sibling;return e}}function ce(e,t,n,r){var o,i=ue(e.child,n,r);if(i)return i;for(;!(o=ue(e.sibling,n,r));)if((e=e.parent)===t)return e;return o}function de(e){return e.__brahmosData.fiber}function pe(e){e.shouldTearDown=!0,e.root.tearDownFibers.push(e)}var fe=1;function le(e){return function(t){var n=de(e),r=n.root.updateType;e.context!==t&&Z(n,r)}}function he(e){var t="cC"+fe++,n=function(e){function t(t){e.call(this,t),this.subs=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.shouldComponentUpdate=function(e){return this.props.value!==e.value&&this.subs.forEach((function(t){return t(e.value)})),!0},t.prototype.sub=function(e){var t=this.subs,n=le(e);t.push(n);var r=e.componentWillUnmount;e.componentWillUnmount=function(){t.splice(t.indexOf(n),1),r&&r()}},t.prototype.render=function(){return this.props.children},t}(gt);n.__ccId=t;var r=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children(this.context)},t}(gt),o={id:t,defaultValue:e,Provider:n,Consumer:r};return r.contextType=o,o}function ve(){return Q().nodeInstance}function me(e){e.deferredHooks=e.syncHooks.map((function(e,t){return Array.isArray(e)?[].concat(e):e.transitionId?e:Object.assign({},e)}))}function ye(e,t){var n=t.syncHooks,r=t.deferredHooks;return"sync"===e?n:r}function ge(e){var t=e.nodeInstance;return ye(e.root.updateType,t)}function be(e,t,n){return"deferred"!==e||n.deferredHooks.length||me(n),ye(e,n)[t]}function Te(e,t){if(!e||!t||e.length!==t.length)return!0;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!0;return!1}function _e(e,t,n){void 0===t&&(t=function(e){return!1}),void 0===n&&(n=function(e){return e});var r=Q(),o=r.nodeInstance,i=o.pointer,a=ge(r),s=a[i];return s&&!t(s)||(s=e(),a[i]=s),o.pointer+=1,n(s)}function Se(e,t){var n=ve(),r=n.pointer;return _e((function(){return"function"==typeof e&&(e=e()),[e,function(e){var o=P(),i=be(o,r,n),a=i[0],s=t(e,a),u=F(o),c={transitionId:E().transitionId,updater:function(){be(o,r,n)[0]=t(e,i[0])}};n.__brahmosData[u].push(c),function(e,t,n){Object.is(t,n)||yt(e)}(n,s,a)}]}))}function Ce(e){return Se(e,(function(e,t){return"function"==typeof e&&(e=e(t)),e}))}function Ie(e){return _e((function(){return{current:e}}))}function De(e,t,n){return Se(n?function(){return n(t)}:t,(function(t,n){return e(n,t)}))}function Ne(e,t){return _e((function(){return{value:e(),dependencies:t}}),(function(e){return Te(t,e.dependencies)}),(function(e){return e.value}))}function ke(e,t){return Ne((function(){return e}),t)}function we(e,t){var n=Q(),r=n.nodeInstance,o=r.pointer,i=ge(n),a=i[o]||{animationFrame:null,cleanEffect:null},s=Object.assign({},a,{isDependenciesChanged:Te(t,a.dependencies),dependencies:t,effect:function(){s.isDependenciesChanged&&e(s)}});i[o]=s,r.pointer+=1}function xe(e,t){we((function(t){cancelAnimationFrame(t.animationFrame),t.animationFrame=requestAnimationFrame((function(){setTimeout((function(){t.cleanEffect=e()}))}))}),t)}function Ee(e,t){we((function(t){t.cleanEffect=e()}),t)}function Ue(e){var t=Q(),n=t.nodeInstance,r=t.context,o=e.id,i=e.defaultValue,a=r[o],s=a?a.props.value:i;return Ee((function(){if(a){var e=a.subs,t=le(n);return e.push(t),function(){e.splice(e.indexOf(t),1)}}}),[]),n.context=s,s}function Ae(e){e.timeoutMs;var t=ve();return _e((function(){var e={transitionId:T(),tryCount:0,isPending:!1,transitionTimeout:null,pendingSuspense:[],transitionState:"initial",clearTimeout:function(){clearTimeout(e.transitionTimeout)},updatePendingState:function(n,r){e.isPending=n,t.__brahmosData.isDirty=!0;var o=function(){yt(t)};"transition"===r?A(e,o):U(r,o)},startTransition:function(n){var r=x(),o=de(t).root;e.transitionState="start",e.pendingSuspense=[],e.clearTimeout(),A(e,n),o.lastDeferredCompleteTime<o.deferredUpdateTime&&e.updatePendingState(!0,r)}};return e}),void 0,(function(e){return[e.startTransition,e.isPending]}))}function Pe(e,t){for(var n=ge(e),r=0,o=n.length;r<o;r++){var i=n[r];i.cleanEffect&&(i.isDependenciesChanged||t)&&i.cleanEffect(),i.clearTimeout&&t&&i.clearTimeout()}}function Fe(e){var t;return(t={syncHooks:[],deferredHooks:[],pointer:0,__render:function(t){var n,r,o;n=Q(),r=n.nodeInstance,o=n.root.updateType,r.pointer=0,"deferred"===o&&me(r),M(n).forEach((function(e){return e.updater()}));var i=e(t);return this.__brahmosData.nodes=i,i}}).__brahmosData={pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,isDirty:!1,mounted:!1},t}function Me(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function Oe(e){for(var t=e.root;(e=e.parent)&&!(e.nodeInstance instanceof gt&&(e.nodeInstance.componentDidCatch||e.node.type.getDerivedStateFromError));)if(e===t)return null;return e}function je(e){var t=e.root;e.nodeInstance.__brahmosData.isDirty=!0,t.retryFiber=e}function Le(e){var t,n=e.node,r=e.part,o=e.root,i=e.childFiberError,a=n.type,s=n.nodeType,u=n.props;void 0===u&&(u={});var c="deferred"===o.updateType,d=!0,p=!1,f=s===V;!function(e){var t=e.root,n=e.child,r=e.alternate;n&&n.createdAt>t.lastCompleteTime&&(e.child=r&&r.child)}(e);var l=e.nodeInstance,h=!1;l||(l=f?new a(u):Fe(a),e.nodeInstance=l,h=!0);var v=l.__brahmosData,y=function(e){var t=e.node.type,n=e.nodeInstance,r=e.parent,o=e.context,i=t.__ccId,a=r.context||{};if(!i)return a;if(o)return o;var s=Object.create(a);return s[i]=n,s}(e);if(e.context=y,f){var g=v.committedValues,b=v.memoizedValues;h&&(g.state=l.state);var T=g.props,_=g.state;b&&c&&(T=(t=b).props,_=t.state,p=!0),l.props=T,l.state=_;var S=l.shouldComponentUpdate,C=_,I=M(e);I.length&&(C=function(e,t){return t.reduce((function(e,t){var n=t.state;return"function"==typeof n&&(n=n(e)),Object.assign({},e,n)}),e)}(_,I));var D=!h&&o.forcedUpdateWith!==l,N=m(a,"getDerivedStateFromProps",[u,C]),k=i?m(a,"getDerivedStateFromError",[i.error]):void 0;(N||k)&&(C=Object.assign({},C,N,k)),I.forEach((function(e){var t=e.callback;t&&t(C)})),l.isPureReactComponent&&D&&(d=!Me(C,_)||!Me(u,T)),S&&d&&D&&(d=S.call(l,u,C));var w=a.contextType;if(w){var x=w.id,E=w.defaultValue,U=y[x],A=U?U.props.value:E;U&&h&&U.sub(l),l.context=A}l.state=C,l.props=u,c&&(v.memoizedValues={state:C,props:u})}else h||Pe(e);if(d){try{!function(e){L=e}(e),ae(i&&!a.getDerivedStateFromError?null:l.__render(u),r,e.child,e,e)}catch(t){var P=Oe(e);if("function"==typeof t.then){var F=_t(e);if(!F)throw new Error("Rendering which got suspended can't be used outside of suspense.");F.nodeInstance.handleSuspender(t,F),je(F)}else{if(!P||P.childFiberError)throw t;var O=function(e){var t=e.node.type;return{componentStack:"The above error occurred in the <"+(t.displayName||t.name)+"> component:"}}(e);console.error(t),console.error(O.componentStack),P.childFiberError={error:t,errorInfo:O},je(P)}return}te(e,2)}else if(p){var j=e.child;j&&j.node===v.nodes||(ae(v.nodes,r,j,e,e),te(e,2))}else oe(e)}var Re=/[<>"]/g,He=/(^|\s)([^\s"'=<]+)(?=[\s=>])/g;var Ve=function(e){this.strings=e,this.template=null,this.svgTemplate=null,this.partsMeta=[]};Ve.prototype.create=function(e){e&&this.svgTemplate||this.template||(this.partsMeta=this.getPartsMeta(),this.createTemplate(e))},Ve.prototype.getPartsMeta=function(){for(var e,t,n=this.strings,r=[],o=[],i=function(i,a){for(var s=n[i],u=void 0,c=void 0,d=void 0,p=void 0,f=void 0,l=function(){var e=s.substring(p||0,f||s.length);r.push.apply(r,function(e){for(var t,n=[];null!==(t=He.exec(e));){t[2]&&n.push(t[2])}return n}(e))};null!==(u=Re.exec(s));)"<"!==u[0]||t?'"'===u[0]?t=!t:e&&">"===u[0]&&!t&&(e=!1,f=u.index,void 0===p&&l()):(e=!0,r=[],p=u.index,f=void 0);e&&l(),e?c=!0:d=!0,i<a-1&&o.push({tagAttrs:r,attrIndex:r.length,isAttribute:c,isNode:d})},a=0,s=n.length;a<s;a++)i(a,s);return o},Ve.prototype.createTemplate=function(e){for(var t=this.partsMeta,n=this.strings,r=document.createElement("template"),o="",i=0,a=n.length-1;i<a;i++){var s=n[i];o=t[i].isNode?o+s+"\x3c!--{{brahmos}}--\x3e":o+s+"data-brahmos-attr"}o+=n[n.length-1],r.innerHTML=e?"<svg>"+o+"</svg>":o,e&&function(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}(r.content.firstChild),this[e?"svgTemplate":"template"]=r};var We=function(e,t){this.templateResult=e,e.create(t),this.fragment=this.createNode(t),this.parts=this.getParts(),this.domNodes=l(this.fragment.childNodes),this.patched=!1};function ze(e,t,n){return n<=e.lastIndexOf(t)}function qe(n,r,o){for(var i=o,a=o.child,s=function(s,c){var d=n[s],f=r[s],l=d.isAttribute,h=d.isNode,v=void 0;if(l){for(var m=d.domNode,y={},g=void 0;d&&m===d.domNode;)p(r[s],(function(n,r){var o=t[n];ze(d.tagAttrs,o,d.attrIndex)||e[n]?"ref"===n&&(g=r):y[n]=r})),d=n[++s];s--,d=n[s],v={nodeType:z,attributes:y,ref:g}}else h&&(v=f);i=ae(v,d,a,i,o),a=a&&a.sibling,u=s},u=0,c=n.length;u<c;u++)s(u)}function Be(e){var t=e.node,n=e.part,r=e.alternate,o=e.parent.context,i=r&&r.node,a=t.values,s=t.nodeType===H,u=e.isSvgPart||s&&"svg"===t.element;e.isSvgPart=u;var d=e.nodeInstance;d||(d=s?function(e,t){var n=e.element,r=e.values,o=t?document.createElementNS("http://www.w3.org/2000/svg",n):document.createElement(n);return c(o),{fragment:o,nodes:[o],parts:[{isAttribute:!0,tagAttrs:[],attrIndex:0,domNode:o},{parentNode:o,isNode:!0}],values:r}}(t,u):new We(t.template,u),e.nodeInstance=d),s||d.patchParts(n),t!==i?qe(d.parts,a,e):oe(e),te(e,2),e.context=o}function $e(e){var t=e.type,n=i(e);return"input"!==n||"radio"!==t&&"checkbox"!==t?"input"===n||"select"===n||"textarea"===n?"value":void 0:"checked"}function Ge(e,t,n,r){t=t||{},p(e,(function(e,n){var o=t[e];n!==o&&r(e,n,o)})),p(t,(function(t,o){void 0===e[t]&&r(t,n,o)}))}function Je(e,t,a,s,u){if(function(e){return 0===e.indexOf("on")}(t)){var c=function(e){return e.replace("on","").toLowerCase()}(t);c=function(e,t){var r=i(t);return n[e]?n[e]:"input"===r&&"change"===e?"input":e}(c,e);var d=function(e,t,n){var r=e.__brahmosData.events,o=r[t];return o?(o.handler=n,o.patched):((o=r[t]={handler:n,patched:null}).patched=function(e){var t=this;o.handler&&j((function(){o.handler.call(t,e)}))},o.patched)}(e,t,a);s&&!a?e.removeEventListener(c,d):!s&&a&&e.addEventListener(c,d)}else if("style"===t){var p=e.style;Ge(a,s,"",(function(e,t){"-"===e[0]?p.setProperty(e,t):p[e]="number"==typeof t&&!1===r.test(e)?t+"px":t}))}else if("dangerouslySetInnerHTML"===t){var f=s&&s.__html,l=a&&a.__html;l!==f&&(e.innerHTML=null==l?"":l)}else if(t in e&&!u){var h=$e(e);h?function(e,t,n,r){"checked"===e?"checked"===n?(t.checked=r,t.checkedProp=r):"defaultChecked"===n&&void 0===t.checkedProp?t.checked=r:t[n]=r:"value"===e&&("value"===n?(t.value=r,t.valueProp=r):"defaultValue"===n&&void 0===t.valueProp?t.value=r:t[n]=r)}(h,e,t,a):e[t]=null==a?"":a}else{var v=t.replace(/^xlink:?/,""),m=null==a||!1===a;t!==v?(v=v.toLowerCase(),m?e.removeAttributeNS(o,v):e.setAttributeNS(o,v,a)):m?e.removeAttribute(t):e.setAttribute(t,a)}}function Ke(e,t,n,r){Ge(t,n,null,(function(t,n,o){Je(e,t,n,o,r)})),function(e){var t=$e(e);if(t){var n=e[t+"Prop"],r=e[t];void 0!==n&&n!==r&&(e[t]=n)}}(e)}function Qe(e){function t(t){return e(d(t,!1),t.ref)}return t.__isForwardRef=!0,t}function Xe(){return{current:null}}function Ye(e,t){var n=typeof e;"function"===n?e(t):"object"===n&&(e.current=t)}function Ze(e,t){var n=t.domNodes;e.__brahmosLastArrayDom=n[n.length-1]}function et(e){var t=e.previousSibling;return e.isArrayNode&&(t=0===e.nodeIndex?t:e.parentNode.__brahmosLastArrayDom),t}function tt(e,t){var n=e.part;if(n.isArrayNode){var r=n.nodeIndex,o=n.parentNode,i=t.part.nodeIndex,a=function(e){for(;e.node&&!q(e.node);)e=e.child;return e}(e),s=a.nodeInstance,u=a!==e&&a.hasUncommittedEffect;if(s&&!u){if(r!==i){var c=s.domNodes,d=et(n),p=v(o,d),f=c[0];f&&f.previousSibling!==d&&f!==p&&h(o,p,c)}Ze(o,s)}}}function nt(e){var t=e.node,n=e.nodeInstance,r=e.root,o=e.childFiberError,i=r.updateType,a=t.nodeType,s=t.ref,u=n.__brahmosData;if(a===V){var c=n.props,d=n.state,p=u.committedValues,f=u.lastSnapshot,l=p.props,h=p.state;l?m(n,"componentDidUpdate",[l,h,f]):m(n,"componentDidMount"),o&&(m(n,"componentDidCatch",[o.error,o.errorInfo]),e.childFiberError=null),s&&Ye(s,n),p.props=c,p.state=d,u.memoizedValues=null}else if(function(e){for(var t=ge(e),n=0,r=t.length;n<r;n++){var o=t[n];o.effect&&o.effect()}}(e),"deferred"===i){var v=n.syncHooks,y=n.deferredHooks;n.deferredHooks=v,n.syncHooks=y}u.mounted=!0,u.fiber=e}function rt(e){e.tearDownFibers=[],e.postCommitEffects=[],e.hasUncommittedEffect=!1,e.resetRenderCallbacks()}function ot(e){var t=e.currentTransition,n=e.pendingTransitions,r=n.indexOf(t);-1!==r&&n.splice(r,1)}function it(e){var t=e.node,n=e.alternate,r=t&&B(t);r&&n&&tt(e,n),2===e.hasUncommittedEffect&&($(t)?function(e){var t=e.part,n=e.node,r=e.alternate,o=t.parentNode,i=v(o,t.previousSibling);r?i.nodeValue=n:h(o,i,n)}(e):q(t)?function(e){var t=e.part,n=e.nodeInstance,r=e.alternate,o=t.parentNode;if(r)tt(e,r);else{var i=v(o,et(t));n.domNodes=h(o,i,n.fragment),Ze(o,n)}}(e):r?function(e){var t=e.node,n=e.nodeInstance,r=e.root,o=r.updateType,i=t.nodeType,a=n.__brahmosData;if(i===V){var s=a.committedValues,u=s.props,c=s.state;a.lastSnapshot=m(n,"getSnapshotBeforeUpdate",[u,c])}var d=D(e).transitionId,p=F(o);a[p]=a[p].filter((function(e){return e.transitionId!==d})),a.isDirty=!1,r.postCommitEffects.push(e)}(e):t.nodeType===z&&function(e){var t=e.part,n=e.node,r=e.alternate,o=e.isSvgPart,i=t.domNode,a=n.attributes,s=n.ref;Ke(i,a,r&&r.node.attributes,o),s&&Ye(s,i)}(e),e.hasUncommittedEffect=!1),n&&function(e){e.node=null,e.nodeInstance=null,e.child=null,e.sibling=null}(n)}function at(e,t,n,r){var o=(e.part.parentNode===t.parentNode||!n)&&r,i=e.node;i&&i.portalContainer&&(o=!0),st(e,o)}function st(e,t){var n=e.node,r=e.part,o=e.nodeInstance;if(G(n)){var i=q(n),a=e.child;if(a)for(at(a,r,i,t);a.sibling;)at(a=a.sibling,r,i,t);if($(n)&&t){f(v(r.parentNode,r.previousSibling))}else{var s=n.ref;if(s&&Ye(s,null),o)if(i){var u=o.domNodes;t&&f(u)}else B(n)&&o.__brahmosData.mounted&&(n.nodeType===V?m(o,"componentWillUnmount"):Pe(e,!0))}}}function ut(e){e.tearDownFibers.forEach((function(e){e.shouldTearDown&&st(e,!0)})),e.tearDownFibers=[]}We.prototype.createNode=function(e){var t=this.templateResult,n=t.template,r=t.svgTemplate,o=e?r:n;return document.importNode(o.content,!0)},We.prototype.createWalker=function(e){return document.createTreeWalker(e,129,null,!1)},We.prototype.isBrahmosCommentNode=function(e){return e&&8===e.nodeType&&"{{brahmos}}"===e.textContent},We.prototype.getParts=function(){for(var e=this.fragment,t=this.templateResult,n=this.isBrahmosCommentNode,r=t.partsMeta,o=this.createWalker(e),i=0,a=r[i],s=[],u=[],d=function(){i++,a=r[i]};o.nextNode();){var p=o.currentNode,l=p.nodeType,h=p.parentNode;if(1===l&&p.hasAttribute("data-brahmos-attr")){p.removeAttribute("data-brahmos-attr");for(var v=a.tagAttrs;a&&a.isAttribute&&a.tagAttrs===v;)s.push(Object.assign({},a,{domNode:p})),d();c(p)}else if(n(p)){var m=p.previousSibling;n(m)&&(m=y(p)),s.push(Object.assign({},a,{parentNode:h,previousSibling:m})),d(),u.push(p)}}return f(u),s},We.prototype.patchParts=function(e){var t=this.parts,n=e.parentNode,r=e.previousSibling;if(!this.patched){for(var o=0,i=t.length;o<i;o++){var a=t[o];a.isNode&&a.parentNode instanceof DocumentFragment&&(a.parentNode=n,a.previousSibling=a.previousSibling||r)}this.patched=!0}};var ct;function dt(e){return ct+e-performance.now()}!function e(){requestAnimationFrame((function(t){ct=t,e()}))}();var pt=function(){return 1};function ft(e){var t=e.node,n=e.alternate;if(G(t)){var r=function(e){var t=e.node,n=e.nodeInstance;return!(!B(t)||!n)&&(!!M(e).length||n.__brahmosData.isDirty)}(e);!e.processedTime||r?($(t)?function(e){var t=e.node,n=e.alternate;t!==(n&&n.node)&&te(e,2)}(e):Array.isArray(t)?function(e){for(var t=e.node,n=e.part,r=e,o=n.parentNode,i=n.previousSibling,a=new Map,s=0,u=e;u=re(u,e);){var c=J(u.node,s);a.set(c,u),s++}e.child=null,t.forEach((function(t,n){var s=J(t,n),u=a.get(s);u&&a.delete(s);var c=r;(r=ae(t,{parentNode:o,previousSibling:i,a:void 0,isArrayNode:!0,nodeIndex:n},u,c,e)).sibling=null,u&&u.part.nodeIndex!==n&&(te(r,1),0!==n&&te(c,1))})),a.forEach((function(e){pe(e)})),te(e,2)}(e):q(t)?Be(e):B(t)?Le(e):t.nodeType===z&&te(e,2),e.processedTime=u()):oe(e)}else n&&pe(n)}function lt(e){var t=e.updateType,n=e.current,r=X(t);ut(e);var o=function(e){for(var t=e.updateType,n=e.wip,r=e.current,o=Y(t),i=e[X(t)],a=[],s="sync"===t?r:n;s;){var u=s.createdAt,c=s.node,d=s.child,p=s.hasUncommittedEffect,f=s[o],l=u>i,h=p||f>i;if(p&&a.push(s),l&&(d&&d.parent!==s&&(d.parent=s),c&&B(c)&&(s.nodeInstance.__brahmosData.fiber=s)),d&&h)s=d;else{for(;s!==e&&!s.sibling;)s=s.parent;s=s.sibling}}return a}(e);e[r]=e.lastCompleteTime=u(),"deferred"===t&&(e.current=e.wip,e.wip=n),function(e,t){for(var n=0,r=t.length;n<r;n++)it(t[n]);for(var o=e.postCommitEffects,i=o.length-1;i>=0;i--)nt(o[i]);ot(e),rt(e),e.requestIdleHandle=null,e.forcedUpdateWith=null}(e,o)}function ht(e,t){var n=e.root,r=n.updateType,o=n.currentTransition,i=X(r),a=Y(r),s=n[i],u=!function(e){return"immediate_action"===e.updateSource}(n);!function(e,t,n){var r=e.scheduleId;if(r&&clearTimeout(r),t){var o=dt(16);e.scheduleId=setTimeout((function(){var t=e.currentTransition,r=t?t.tryCount:0,o=t===S?200:500,i=Math.min(25,r);n(r>o?pt:function(){return dt(5+i)})}),o)}else n(pt)}(n,u,(function(r){for(;e!==t;){if(!(r()>0))return void ht(e,t);ft(e);var i=n.retryFiber;i?(e=i,t=n,n.retryFiber=null):e=ce(e,t,s,a)}var u,c;n.callRenderCallbacks(),o&&("timedOut"!==(c=(u=o).transitionState)&&"suspended"!==c&&(u.isPending?(u.clearTimeout(),u.updatePendingState(!1,"transition")):u.transitionState="completed"),o.tryCount=0,!n.hasUncommittedEffect&&I(o)&&ot(n)),function(e){return"transition"!==e.updateSource||e.lastCompleteTime>=e.updateTime&&e.hasUncommittedEffect&&I(e.currentTransition)}(n)&<(n),N(n)&&U("transition",(function(){n.updateSource="transition",vt(n)}))}))}function vt(e){var t=N(e);t&&(e.updateType="deferred",rt(e),e.currentTransition=t,t.tryCount+=1,e.wip=ne(e.current,e.wip,e,e),ht(e.wip,e))}function mt(e){var t=e.root,n=e.parent;t.updateType="sync",t.currentTransition=null,rt(t),ht(e,n)}function yt(e){var t=de(e),n=t.root,r=x(),o=E(),i=P();if(Z(t,i),"transition"===r){var a=n.pendingTransitions,s=o===S?"unshift":"push";a.includes(o)||a[s](o)}n.batchUpdates[r]||(n.batchUpdates[r]=b((function(){if(n.batchUpdates[r]=null,n.updateSource=r,n.lastCompleteTime<n.updateTime){var e="sync"===n.updateType&&n.requestIdleHandle;mt("immediate_action"===r&&!e?t:n.current)}else vt(n)})))}var gt=function(e){this.props=e,this.state=void 0,this.__brahmosData={lastSnapshot:null,pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,mounted:!1,committedValues:{},memoizedValues:null,isDirty:!1},this.context=void 0};gt.prototype.setState=function(e,t,n){var r=P(),o={state:e,transitionId:E().transitionId,callback:t},i=F(r);this.__brahmosData[i].push(o),yt(this)},gt.prototype.forceUpdate=function(e){var t=this.__brahmosData.fiber;t&&(t.root.forcedUpdateWith=this,this.__brahmosData.isDirty=!0,yt(this),e&&e(this.state))},gt.prototype.__render=function(){var e=this.render();return this.__brahmosData.nodes=e,e};var bt=function(e){function t(t){e.call(this,t),this.isPureReactComponent=!0}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(gt);function Tt(e,t,n){if("string"==typeof e)return function(e,t,n){var r=K(null,[t,n],"");return r.element=e,r.nodeType=H,r}(e,t,n);var r=Object.assign({},e.defaultProps,d(t,e.__isForwardRef),{children:n});e.__loadLazyComponent&&e.__loadLazyComponent();var o=t.key;void 0===o&&(o="");var i=t.ref,a=function(e){return e.prototype instanceof gt}(e),s=K(r,null,""+o);return s.nodeType=a?V:W,s.type=e,s.ref=a?i:null,s}function _t(e,t){for(var n=e.root,r=e.nodeInstance;!(r instanceof wt||t&&r instanceof kt);){if((e=e.parent)===n)return null;r=e.nodeInstance}return e}function St(e){var t=e.parentSuspenseManager;return t&&t.isSuspenseList?t:null}function Ct(e,t){var n=e.nodeInstance;if(!n)return null;var r=n.suspenseManagers,o=t.transitionId,i=r[o];return i||(i=r[o]=new Dt(e,t)),i}function It(e){e.__brahmosData.isDirty=!0}var Dt=function(e,t){var n=e.nodeInstance;this.fiber=e,this.component=n,this.transition=t,this.childManagers=[],this.suspender=null,this.isSuspenseList=n instanceof kt;var r=_t(e.parent,!0);this.parentSuspenseManager=r&&Ct(r,t),this.rootSuspenseManager=null,this.recordChildSuspense(),this.handleSuspense=this.handleSuspense.bind(this)};function Nt(e){var t=D(Q(),S);return"resolved"!==t.transitionState||t.pendingSuspense.includes(e)||(t=S),t}Dt.prototype.recordChildSuspense=function(){var e=this.parentSuspenseManager;e?(e.childManagers.push(this),this.rootSuspenseManager=e.rootSuspenseManager):this.rootSuspenseManager=this},Dt.prototype.addRootToProcess=function(){var e=this.rootSuspenseManager;Q().root.afterRender(e.handleSuspense)},Dt.prototype.suspend=function(e){this.suspender=e,this.addRootToProcess()},Dt.prototype.handleSuspense=function(){var e=this.component,t=this.suspender;return e instanceof kt?this.handleSuspenseList():Promise.resolve(t).then(this.resolve.bind(this,t))},Dt.prototype.isUnresolved=function(){return this.isSuspenseList?this.childManagers.some((function(e){return e.isUnresolved()})):this.suspender},Dt.prototype.shouldShowFallback=function(){var e=St(this);if(!e)return!0;var t=e.component,n=e.childManagers,r=t.props.tail;if(St(e)&&!e.shouldShowFallback())return!1;if("collapsed"===r)for(var o=0,i=n.length;o<i;o++){var a=n[o];if("collapsed"===r&&a.isUnresolved())return a===this}return"hidden"!==r},Dt.prototype.resolve=function(e){var t=this,n=this.component,r=this.transition,o=this.suspender,i=this.childManagers,a=r.pendingSuspense||[];if(e===o)if(o){this.suspender=null,It(this.component);var s="timedOut"===r.transitionState,u=a.filter((function(e){return e.suspenseManagers[r.transitionId].suspender})).length;s||u||(r.transitionState="resolved");var c=function(){var e=n;de(n)||(e=t.fiber.root.wip.nodeInstance),yt(e)};setTimeout((function(){s||!a.includes(n)?O(c):A(r,c)}),Date.now()%100)}else i.forEach((function(e){e.handleSuspense()}))},Dt.prototype.getChildrenSuspenders=function(){var e=[];return this.childManagers.forEach((function(t){t.isSuspenseList?e=e.concat(t.getChildrenSuspenders()):t.suspender&&e.push(t.suspender)})),e},Dt.prototype.handleSuspenseList=function(){var e=this.component,t=this.childManagers,n=e.props,r=n.revealOrder;void 0===r&&(r="together");var o=n.tail,i=function(e,t){return e.then((function(){return"forwards"===r&&"collapsed"===o&&function(e){var t=de(e.component);e.isUnresolved()&&t&&(It(e.component),Z(t,"deferred"))}(t),t.handleSuspense()}))},a=Promise.all(this.getChildrenSuspenders());if("together"===r)a.then((function(){t.forEach((function(e){return e.handleSuspense()}))}));else if("forwards"===r)for(var s=Promise.resolve(),u=0,c=t.length;u<c;u++)s=i(s,t[u]);else if("backwards"===r)for(var d=Promise.resolve(),p=t.length-1;p>=0;p--)d=i(d,t[p]);return a};var kt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children},t}(gt),wt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.handleSuspender=function(e,t){var n=Nt(this),r=Ct(t,n);I(n)||(n.pendingSuspense.includes(this)||n.pendingSuspense.push(this),n.transitionState="suspended"),r.suspend(e)},t.prototype.render=function(){var e=Nt(this),t=Ct(Q(),e),n=!t.suspender,r=this.props,o=r.fallback,i=r.children;return n?i:t.shouldShowFallback()?o:null},t}(gt),xt=function(e){var t,n=Qe((function(e,n){return Tt(t.read().default,Object.assign({},e,{ref:n}),e.children)}));return n.__loadLazyComponent=function(){var n,r,o,i;t||(n=e(),o="pending",i=n.then((function(e){o="success",r=e}),(function(e){o="error",r=e})),t={read:function(){if("pending"===o)throw i;if("error"===o)throw r;if("success"===o)return r}})},n};function Et(e){return e.children}function Ut(e,t){var n,r,o=t.__rootFiber;if(o)(n=o.current).node.props.children=e,n.processedTime=0,Z(n);else{var i=Tt(Et,{},e);r=[],(n=ie(o={updateType:"sync",updateSource:"js",scheduleId:0,domNode:t,forcedUpdateWith:null,current:null,wip:null,child:null,retryFiber:null,currentTransition:null,hasUncommittedEffect:!1,pendingTransitions:[],tearDownFibers:[],postCommitEffects:[],batchUpdates:{},lastDeferredCompleteTime:0,lastCompleteTime:0,deferredUpdateTime:0,updateTime:0,afterRender:function(e){r.includes(e)||r.push(e)},callRenderCallbacks:function(){for(var e=0,t=r.length;e<t;e++)r[e]()},resetRenderCallbacks:function(){r=[]}},i,{parentNode:t,isNode:!0})).parent=o,o.current=n,t.__rootFiber=o}j((function(){o.updateSource=x(),mt(n)}))}var At=new WeakMap;function Pt(e,t){var n=K(null,t,"");return n.nodeType=R,n.template=e,n}function Ft(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];var r=At.get(e);return r||(r=new Ve(e),At.set(e,r)),Pt(r,t)}function Mt(e,t){return e&&(e.portalContainer=t),e}function Ot(e){var t=e.__rootFiber;return!!t&&(pe(t.current),ut(t),e.__rootFiber=void 0,!0)}var jt={createElement:Tt,render:Ut,Component:gt,PureComponent:bt,html:Ft,useState:Ce,useEffect:xe,useRef:Ie,useReducer:De,useMemo:Ne,useCallback:ke,useLayoutEffect:Ee,useContext:Ue,useTransition:Ae,createContext:he,forwardRef:Qe,createRef:Xe,createPortal:Mt,unmountComponentAtNode:Ot,Suspense:wt,SuspenseList:kt,lazy:xt,unstable_deferredUpdates:O,unstable_syncUpdates:j};export default jt;export{gt as Component,bt as PureComponent,wt as Suspense,kt as SuspenseList,he as createContext,Tt as createElement,Mt as createPortal,Xe as createRef,Qe as forwardRef,Ft as html,xt as lazy,Ut as render,Ot as unmountComponentAtNode,O as unstable_deferredUpdates,j as unstable_syncUpdates,ke as useCallback,Ue as useContext,xe as useEffect,Ee as useLayoutEffect,Ne as useMemo,De as useReducer,Ie as useRef,Ce as useState,Ae as useTransition}; | ||
var e={key:1,ref:1},t={className:"class",htmlFor:"for",acceptCharset:"accept-charset",httpEquiv:"http-equiv"},n={doubleclick:"dblclick"},r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,o="http://www.w3.org/1999/xlink";function i(e){return e.nodeName.toLowerCase()}function a(e){return null==e}var s=0;function u(){return s++}function c(e){e.__brahmosData={events:{}}}function d(e,t){var n,r={};for(n in e)"key"===n||"ref"===n&&!t||(r[n]=e[n]);return r}function p(e,t){for(var n=Object.keys(e),r=0,o=n.length;r<o;r++){var i=n[r];t(i,e[i])}}function f(e){Array.isArray(e)||(e=[e]);for(var t=e.length-1;t>=0;t--){var n=e[t];n.parentNode.removeChild(n)}}function l(e){return Array.prototype.slice.call(e)}function h(e,t,n){t=void 0===t?null:t;var r=function(e){var t=e instanceof NodeList;if(e instanceof Node)return e;if(Array.isArray(e)||t){for(var n=document.createDocumentFragment(),r=0;e[r];)n.appendChild(e[r]),t||(r+=1);return n}return document.createTextNode(e)}(n),o=r instanceof DocumentFragment?l(r.childNodes):r;return e.insertBefore(r,t),o}function v(e,t){return t?t.nextSibling:e.firstChild}function m(e,t,n){if(e[t])return e[t].apply(e,n)}function y(e){var t=e.parentNode,n=document.createTextNode("");return t.insertBefore(n,e),n}var g=Promise.resolve();function b(e){return g.then(e)}function T(){return u()+"-"+1e6*Math.random()}var _={transitionId:"",tryCount:0,transitionState:"timedOut"},S={transitionId:T(),tryCount:0,transitionState:"timedOut"};function C(e){var t=e.transitionState;return"start"===t||"resolved"===t||"timedOut"===t}function I(e){var t=e.transitionState;return"completed"===t||"timedOut"===t}function D(e,t){return t=t||_,e.root.currentTransition||t}function N(e){return e.pendingTransitions.find(C)}var k="js",w=_;function x(){return k}function E(){return w}function U(e,t){k=e,t(),b((function(){k="js"}))}function A(e,t){var n=w;w=e,U("transition",t),w=n}function P(){return"transition"===k?"deferred":"sync"}function F(e){return"deferred"===e?"pendingDeferredUpdates":"pendingSyncUpdates"}function M(e){var t=e.root.updateType,n=e.nodeInstance.__brahmosData,r=D(e).transitionId;return n[F(t)].filter((function(e){return e.transitionId===r}))}function O(e){A(S,e)}function j(e){U("immediate_action",e)}var L,R=Symbol("tag"),H=Symbol("tag-element"),V=Symbol("class-component"),W=Symbol("functional-component"),z=Symbol("attribute");function q(e){var t=e.nodeType;return t===R||t===H}function B(e){var t=e.nodeType;return t===V||t===W}function $(e){return"string"==typeof e||"number"==typeof e}function G(e){return!(a(e)||"boolean"==typeof e)}function J(e,t){var n=e&&e.key;if(""===n&&e&&q(e)){for(var r=e.values,o=0,i=r.length;o<i;o++){var a=r[o];if(void 0!==a.key){n=""+a.key;break}}e.key=void 0===n?"":""+n}return""===n?""+t:n}function K(e,t,n){return{nodeType:null,key:n,added:!1,ref:null,portalContainer:null,type:null,props:e,element:"",values:t,template:null}}function Q(){return L}function X(e){return"deferred"===e?"lastDeferredCompleteTime":"lastCompleteTime"}function Y(e){return"deferred"===e?"deferredUpdateTime":"updateTime"}function Z(e,t){for(var n=Y(t),r=u();e;)e[n]=r,e=e.parent}function ee(e,t,n){t===n?n.child=e:t.sibling=e,e.parent=n}function te(e,t){e.hasUncommittedEffect=t,e.root.hasUncommittedEffect=!0}function ne(e,t,n,r){var o=e.root,i=e.node,a=e.part,s=e.nodeInstance,c=e.child,d=Y(o.updateType);return t?(t.node=i,t.part=a,t.createdAt=u()):function(e,t){e&&(e.alternate=t);t.alternate=e}(e,t=ie(o,i,a)),e.shouldTearDown=!1,t.nodeInstance=s,t.child=c,t[d]=r[d],ee(t,n,r),t}function re(e,t){return e===t?e.child:e.sibling}function oe(e){var t=e.child;if("sync"!==e.root.updateType)for(var n;t;){n=ne(t,t.alternate,n||e,e),t=t.sibling}}function ie(e,t,n){return t&&t.portalContainer&&(n.parentNode=t.portalContainer),{node:t,nodeInstance:null,root:e,parent:null,child:null,sibling:null,part:n,alternate:null,context:null,childFiberError:null,isSvgPart:!1,deferredUpdateTime:0,updateTime:0,processedTime:0,createdAt:u(),shouldTearDown:!1,hasUncommittedEffect:0}}function ae(e,t,n,r,o){var i,s,u,c=r.root,d=Y(c.updateType);return n&&!a(n.node)&&!a(e)&&(s=e,u=n.node,$(s)&&$(u)||s.nodeType===z||Array.isArray(s)&&Array.isArray(u)||B(s)&&s.type===u.type||q(s)&&s.template===u.template)?((i=ne(n,n.alternate,r,o)).node=e,i.part=t):(i=ie(c,e,t),n&&pe(n)),ee(i,r,o),i.processedTime=0,i[d]=o[d],i.context=o.context,i.isSvgPart=o.isSvgPart,i}function se(e,t,n){return e&&e[n]>=t}function ue(e,t,n){if(e){for(;e&&!se(e,t,n);)e=e.sibling;return e}}function ce(e,t,n,r){var o,i=ue(e.child,n,r);if(i)return i;for(;!(o=ue(e.sibling,n,r));)if((e=e.parent)===t)return e;return o}function de(e){return e.__brahmosData.fiber}function pe(e){e.shouldTearDown=!0,e.root.tearDownFibers.push(e)}var fe=1;function le(e){return function(t){var n=de(e),r=n.root.updateType;e.context!==t&&Z(n,r)}}function he(e){var t="cC"+fe++,n=function(e){function t(t){e.call(this,t),this.subs=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.shouldComponentUpdate=function(e){return this.props.value!==e.value&&this.subs.forEach((function(t){return t(e.value)})),!0},t.prototype.sub=function(e){var t=this.subs,n=le(e);t.push(n);var r=e.componentWillUnmount;e.componentWillUnmount=function(){t.splice(t.indexOf(n),1),r&&r()}},t.prototype.render=function(){return this.props.children},t}(gt);n.__ccId=t;var r=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children(this.context)},t}(gt),o={id:t,defaultValue:e,Provider:n,Consumer:r};return r.contextType=o,o}function ve(){return Q().nodeInstance}function me(e){e.deferredHooks=e.syncHooks.map((function(e,t){return Array.isArray(e)?[].concat(e):e.transitionId?e:Object.assign({},e)}))}function ye(e,t){var n=t.syncHooks,r=t.deferredHooks;return"sync"===e?n:r}function ge(e){var t=e.nodeInstance;return ye(e.root.updateType,t)}function be(e,t,n){return"deferred"!==e||n.deferredHooks.length||me(n),ye(e,n)[t]}function Te(e,t){if(!e||!t||e.length!==t.length)return!0;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!0;return!1}function _e(e,t,n){void 0===t&&(t=function(e){return!1}),void 0===n&&(n=function(e){return e});var r=Q(),o=r.nodeInstance,i=o.pointer,a=ge(r),s=a[i];return s&&!t(s)||(s=e(),a[i]=s),o.pointer+=1,n(s)}function Se(e,t){var n=ve(),r=n.pointer;return _e((function(){return"function"==typeof e&&(e=e()),[e,function(e){var o=P(),i=be(o,r,n),a=i[0],s=t(e,a),u=F(o),c={transitionId:E().transitionId,updater:function(){be(o,r,n)[0]=t(e,i[0])}};n.__brahmosData[u].push(c),function(e,t,n){Object.is(t,n)||yt(e)}(n,s,a)}]}))}function Ce(e){return Se(e,(function(e,t){return"function"==typeof e&&(e=e(t)),e}))}function Ie(e){return _e((function(){return{current:e}}))}function De(e,t,n){return Se(n?function(){return n(t)}:t,(function(t,n){return e(n,t)}))}function Ne(e,t){return _e((function(){return{value:e(),dependencies:t}}),(function(e){return Te(t,e.dependencies)}),(function(e){return e.value}))}function ke(e,t){return Ne((function(){return e}),t)}function we(e,t){var n=Q(),r=n.nodeInstance,o=r.pointer,i=ge(n),a=i[o]||{animationFrame:null,cleanEffect:null},s=Object.assign({},a,{isDependenciesChanged:Te(t,a.dependencies),dependencies:t,effect:function(){s.isDependenciesChanged&&e(s)}});i[o]=s,r.pointer+=1}function xe(e,t){we((function(t){cancelAnimationFrame(t.animationFrame),t.animationFrame=requestAnimationFrame((function(){setTimeout((function(){t.cleanEffect=e()}))}))}),t)}function Ee(e,t){we((function(t){t.cleanEffect=e()}),t)}function Ue(e){var t=Q(),n=t.nodeInstance,r=t.context,o=e.id,i=e.defaultValue,a=r[o],s=a?a.props.value:i;return Ee((function(){if(a){var e=a.subs,t=le(n);return e.push(t),function(){e.splice(e.indexOf(t),1)}}}),[]),n.context=s,s}function Ae(e){var t=e.timeoutMs,n=ve();return _e((function(){var e={transitionId:T(),tryCount:0,isPending:!1,transitionTimeout:null,pendingSuspense:[],transitionState:"initial",clearTimeout:function(){clearTimeout(e.transitionTimeout)},updatePendingState:function(t,r){e.isPending=t,n.__brahmosData.isDirty=!0;var o=function(){yt(n)};"transition"===r?A(e,o):U(r,o)},startTransition:function(r){var o=x(),i=de(n).root;e.transitionState="start",e.pendingSuspense=[],e.clearTimeout(),A(e,r),i.lastDeferredCompleteTime<i.deferredUpdateTime&&e.updatePendingState(!0,o),e.transitionTimeout=setTimeout((function(){e.transitionState="timedOut",e.updatePendingState(!1,"transition")}),t)}};return e}),void 0,(function(e){return[e.startTransition,e.isPending]}))}function Pe(e,t){for(var n=ge(e),r=0,o=n.length;r<o;r++){var i=n[r];i.cleanEffect&&(i.isDependenciesChanged||t)&&i.cleanEffect(),i.clearTimeout&&t&&i.clearTimeout()}}function Fe(e){var t;return(t={syncHooks:[],deferredHooks:[],pointer:0,__render:function(t){var n,r,o;n=Q(),r=n.nodeInstance,o=n.root.updateType,r.pointer=0,"deferred"===o&&me(r),M(n).forEach((function(e){return e.updater()}));var i=e(t);return this.__brahmosData.nodes=i,i}}).__brahmosData={pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,isDirty:!1,mounted:!1},t}function Me(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function Oe(e){for(var t=e.root;(e=e.parent)&&!(e.nodeInstance instanceof gt&&(e.nodeInstance.componentDidCatch||e.node.type.getDerivedStateFromError));)if(e===t)return null;return e}function je(e){var t=e.root;e.nodeInstance.__brahmosData.isDirty=!0,t.retryFiber=e}function Le(e){var t,n=e.node,r=e.part,o=e.root,i=e.childFiberError,a=n.type,s=n.nodeType,u=n.props;void 0===u&&(u={});var c="deferred"===o.updateType,d=!0,p=!1,f=s===V;!function(e){var t=e.root,n=e.child,r=e.alternate;n&&n.createdAt>t.lastCompleteTime&&(e.child=r&&r.child)}(e);var l=e.nodeInstance,h=!1;l||(l=f?new a(u):Fe(a),e.nodeInstance=l,h=!0);var v=l.__brahmosData,y=function(e){var t=e.node.type,n=e.nodeInstance,r=e.parent,o=e.context,i=t.__ccId,a=r.context||{};if(!i)return a;if(o)return o;var s=Object.create(a);return s[i]=n,s}(e);if(e.context=y,f){var g=v.committedValues,b=v.memoizedValues;h&&(g.state=l.state);var T=g.props,_=g.state;b&&c&&(T=(t=b).props,_=t.state,p=!0),l.props=T,l.state=_;var S=l.shouldComponentUpdate,C=_,I=M(e);I.length&&(C=function(e,t){return t.reduce((function(e,t){var n=t.state;return"function"==typeof n&&(n=n(e)),Object.assign({},e,n)}),e)}(_,I));var D=!h&&o.forcedUpdateWith!==l,N=m(a,"getDerivedStateFromProps",[u,C]),k=i?m(a,"getDerivedStateFromError",[i.error]):void 0;(N||k)&&(C=Object.assign({},C,N,k)),I.forEach((function(e){var t=e.callback;t&&t(C)})),l.isPureReactComponent&&D&&(d=!Me(C,_)||!Me(u,T)),S&&d&&D&&(d=S.call(l,u,C));var w=a.contextType;if(w){var x=w.id,E=w.defaultValue,U=y[x],A=U?U.props.value:E;U&&h&&U.sub(l),l.context=A}l.state=C,l.props=u,c&&(v.memoizedValues={state:C,props:u})}else h||Pe(e);if(d){try{!function(e){L=e}(e),ae(i&&!a.getDerivedStateFromError?null:l.__render(u),r,e.child,e,e)}catch(t){var P=Oe(e);if("function"==typeof t.then){var F=_t(e);if(!F)throw new Error("Rendering which got suspended can't be used outside of suspense.");F.nodeInstance.handleSuspender(t,F),je(F)}else{if(!P||P.childFiberError)throw t;var O=function(e){var t=e.node.type;return{componentStack:"The above error occurred in the <"+(t.displayName||t.name)+"> component:"}}(e);console.error(t),console.error(O.componentStack),P.childFiberError={error:t,errorInfo:O},je(P)}return}te(e,2)}else if(p){var j=e.child;j&&j.node===v.nodes||(ae(v.nodes,r,j,e,e),te(e,2))}else oe(e)}var Re=/[<>"]/g,He=/(^|\s)([^\s"'=<]+)(?=[\s=>])/g;var Ve=function(e){this.strings=e,this.template=null,this.svgTemplate=null,this.partsMeta=[]};Ve.prototype.create=function(e){e&&this.svgTemplate||this.template||(this.partsMeta=this.getPartsMeta(),this.createTemplate(e))},Ve.prototype.getPartsMeta=function(){for(var e,t,n=this.strings,r=[],o=[],i=function(i,a){for(var s=n[i],u=void 0,c=void 0,d=void 0,p=void 0,f=void 0,l=function(){var e=s.substring(p||0,f||s.length);r.push.apply(r,function(e){for(var t,n=[];null!==(t=He.exec(e));){t[2]&&n.push(t[2])}return n}(e))};null!==(u=Re.exec(s));)"<"!==u[0]||t?'"'===u[0]?t=!t:e&&">"===u[0]&&!t&&(e=!1,f=u.index,void 0===p&&l()):(e=!0,r=[],p=u.index,f=void 0);e&&l(),e?c=!0:d=!0,i<a-1&&o.push({tagAttrs:r,attrIndex:r.length,isAttribute:c,isNode:d})},a=0,s=n.length;a<s;a++)i(a,s);return o},Ve.prototype.createTemplate=function(e){for(var t=this.partsMeta,n=this.strings,r=document.createElement("template"),o="",i=0,a=n.length-1;i<a;i++){var s=n[i];o=t[i].isNode?o+s+"\x3c!--{{brahmos}}--\x3e":o+s+"data-brahmos-attr"}o+=n[n.length-1],r.innerHTML=e?"<svg>"+o+"</svg>":o,e&&function(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}(r.content.firstChild),this[e?"svgTemplate":"template"]=r};var We=function(e,t){this.templateResult=e,e.create(t),this.fragment=this.createNode(t),this.parts=this.getParts(),this.domNodes=l(this.fragment.childNodes),this.patched=!1};function ze(e,t,n){return n<=e.lastIndexOf(t)}function qe(n,r,o){for(var i=o,a=o.child,s=function(s,c){var d=n[s],f=r[s],l=d.isAttribute,h=d.isNode,v=void 0;if(l){for(var m=d.domNode,y={},g=void 0;d&&m===d.domNode;)p(r[s],(function(n,r){var o=t[n];ze(d.tagAttrs,o,d.attrIndex)||e[n]?"ref"===n&&(g=r):y[n]=r})),d=n[++s];s--,d=n[s],v={nodeType:z,attributes:y,ref:g}}else h&&(v=f);i=ae(v,d,a,i,o),a=a&&a.sibling,u=s},u=0,c=n.length;u<c;u++)s(u)}function Be(e){var t=e.node,n=e.part,r=e.alternate,o=e.parent.context,i=r&&r.node,a=t.values,s=t.nodeType===H,u=e.isSvgPart||s&&"svg"===t.element;e.isSvgPart=u;var d=e.nodeInstance;d||(d=s?function(e,t){var n=e.element,r=e.values,o=t?document.createElementNS("http://www.w3.org/2000/svg",n):document.createElement(n);return c(o),{fragment:o,nodes:[o],parts:[{isAttribute:!0,tagAttrs:[],attrIndex:0,domNode:o},{parentNode:o,isNode:!0}],values:r}}(t,u):new We(t.template,u),e.nodeInstance=d),s||d.patchParts(n),t!==i?qe(d.parts,a,e):oe(e),te(e,2),e.context=o}function $e(e){var t=e.type,n=i(e);return"input"!==n||"radio"!==t&&"checkbox"!==t?"input"===n||"select"===n||"textarea"===n?"value":void 0:"checked"}function Ge(e,t,n,r){t=t||{},p(e,(function(e,n){var o=t[e];n!==o&&r(e,n,o)})),p(t,(function(t,o){void 0===e[t]&&r(t,n,o)}))}function Je(e,t,a,s,u){if(function(e){return 0===e.indexOf("on")}(t)){var c=function(e){return e.replace("on","").toLowerCase()}(t);c=function(e,t){var r=i(t);return n[e]?n[e]:"input"===r&&"change"===e?"input":e}(c,e);var d=function(e,t,n){var r=e.__brahmosData.events,o=r[t];return o?(o.handler=n,o.patched):((o=r[t]={handler:n,patched:null}).patched=function(e){var t=this;o.handler&&j((function(){o.handler.call(t,e)}))},o.patched)}(e,t,a);s&&!a?e.removeEventListener(c,d):!s&&a&&e.addEventListener(c,d)}else if("style"===t){var p=e.style;Ge(a,s,"",(function(e,t){"-"===e[0]?p.setProperty(e,t):p[e]="number"==typeof t&&!1===r.test(e)?t+"px":t}))}else if("dangerouslySetInnerHTML"===t){var f=s&&s.__html,l=a&&a.__html;l!==f&&(e.innerHTML=null==l?"":l)}else if(t in e&&!u){var h=$e(e);h?function(e,t,n,r){"checked"===e?"checked"===n?(t.checked=r,t.checkedProp=r):"defaultChecked"===n&&void 0===t.checkedProp?t.checked=r:t[n]=r:"value"===e&&("value"===n?(t.value=r,t.valueProp=r):"defaultValue"===n&&void 0===t.valueProp?t.value=r:t[n]=r)}(h,e,t,a):e[t]=null==a?"":a}else{var v=t.replace(/^xlink:?/,""),m=null==a||!1===a;t!==v?(v=v.toLowerCase(),m?e.removeAttributeNS(o,v):e.setAttributeNS(o,v,a)):m?e.removeAttribute(t):e.setAttribute(t,a)}}function Ke(e,t,n,r){Ge(t,n,null,(function(t,n,o){Je(e,t,n,o,r)})),function(e){var t=$e(e);if(t){var n=e[t+"Prop"],r=e[t];void 0!==n&&n!==r&&(e[t]=n)}}(e)}function Qe(e){function t(t){return e(d(t,!1),t.ref)}return t.__isForwardRef=!0,t}function Xe(){return{current:null}}function Ye(e,t){var n=typeof e;"function"===n?e(t):"object"===n&&(e.current=t)}function Ze(e,t){var n=t.domNodes;e.__brahmosLastArrayDom=n[n.length-1]}function et(e){var t=e.previousSibling;return e.isArrayNode&&(t=0===e.nodeIndex?t:e.parentNode.__brahmosLastArrayDom),t}function tt(e,t){var n=e.part;if(n.isArrayNode){var r=n.nodeIndex,o=n.parentNode,i=t.part.nodeIndex,a=function(e){for(;e.node&&!q(e.node);)e=e.child;return e}(e),s=a.nodeInstance,u=a!==e&&a.hasUncommittedEffect;if(s&&!u){if(r!==i){var c=s.domNodes,d=et(n),p=v(o,d),f=c[0];f&&f.previousSibling!==d&&f!==p&&h(o,p,c)}Ze(o,s)}}}function nt(e){var t=e.node,n=e.nodeInstance,r=e.root,o=e.childFiberError,i=r.updateType,a=t.nodeType,s=t.ref,u=n.__brahmosData;if(a===V){var c=n.props,d=n.state,p=u.committedValues,f=u.lastSnapshot,l=p.props,h=p.state;l?m(n,"componentDidUpdate",[l,h,f]):m(n,"componentDidMount"),o&&(m(n,"componentDidCatch",[o.error,o.errorInfo]),e.childFiberError=null),s&&Ye(s,n),p.props=c,p.state=d,u.memoizedValues=null}else if(function(e){for(var t=ge(e),n=0,r=t.length;n<r;n++){var o=t[n];o.effect&&o.effect()}}(e),"deferred"===i){var v=n.syncHooks,y=n.deferredHooks;n.deferredHooks=v,n.syncHooks=y}u.mounted=!0,u.fiber=e}function rt(e){e.tearDownFibers=[],e.postCommitEffects=[],e.hasUncommittedEffect=!1,e.resetRenderCallbacks()}function ot(e){var t=e.currentTransition,n=e.pendingTransitions,r=n.indexOf(t);-1!==r&&n.splice(r,1)}function it(e){var t=e.node,n=e.alternate,r=t&&B(t);r&&n&&tt(e,n),2===e.hasUncommittedEffect&&($(t)?function(e){var t=e.part,n=e.node,r=e.alternate,o=t.parentNode,i=v(o,t.previousSibling);r?i.nodeValue=n:h(o,i,n)}(e):q(t)?function(e){var t=e.part,n=e.nodeInstance,r=e.alternate,o=t.parentNode;if(r)tt(e,r);else{var i=v(o,et(t));n.domNodes=h(o,i,n.fragment),Ze(o,n)}}(e):r?function(e){var t=e.node,n=e.nodeInstance,r=e.root,o=r.updateType,i=t.nodeType,a=n.__brahmosData;if(i===V){var s=a.committedValues,u=s.props,c=s.state;a.lastSnapshot=m(n,"getSnapshotBeforeUpdate",[u,c])}var d=D(e).transitionId,p=F(o);a[p]=a[p].filter((function(e){return e.transitionId!==d})),a.isDirty=!1,r.postCommitEffects.push(e)}(e):t.nodeType===z&&function(e){var t=e.part,n=e.node,r=e.alternate,o=e.isSvgPart,i=t.domNode,a=n.attributes,s=n.ref;Ke(i,a,r&&r.node.attributes,o),s&&Ye(s,i)}(e),e.hasUncommittedEffect=!1),n&&function(e){e.node=null,e.nodeInstance=null,e.child=null,e.sibling=null}(n)}function at(e,t,n,r){var o=(e.part.parentNode===t.parentNode||!n)&&r,i=e.node;i&&i.portalContainer&&(o=!0),st(e,o)}function st(e,t){var n=e.node,r=e.part,o=e.nodeInstance;if(G(n)){var i=q(n),a=e.child;if(a)for(at(a,r,i,t);a.sibling;)at(a=a.sibling,r,i,t);if($(n)&&t){f(v(r.parentNode,r.previousSibling))}else{var s=n.ref;if(s&&Ye(s,null),o)if(i){var u=o.domNodes;t&&f(u)}else B(n)&&o.__brahmosData.mounted&&(n.nodeType===V?m(o,"componentWillUnmount"):Pe(e,!0))}}}function ut(e){e.tearDownFibers.forEach((function(e){e.shouldTearDown&&st(e,!0)})),e.tearDownFibers=[]}We.prototype.createNode=function(e){var t=this.templateResult,n=t.template,r=t.svgTemplate,o=e?r:n;return document.importNode(o.content,!0)},We.prototype.createWalker=function(e){return document.createTreeWalker(e,129,null,!1)},We.prototype.isBrahmosCommentNode=function(e){return e&&8===e.nodeType&&"{{brahmos}}"===e.textContent},We.prototype.getParts=function(){for(var e=this.fragment,t=this.templateResult,n=this.isBrahmosCommentNode,r=t.partsMeta,o=this.createWalker(e),i=0,a=r[i],s=[],u=[],d=function(){i++,a=r[i]};o.nextNode();){var p=o.currentNode,l=p.nodeType,h=p.parentNode;if(1===l&&p.hasAttribute("data-brahmos-attr")){p.removeAttribute("data-brahmos-attr");for(var v=a.tagAttrs;a&&a.isAttribute&&a.tagAttrs===v;)s.push(Object.assign({},a,{domNode:p})),d();c(p)}else if(n(p)){var m=p.previousSibling;n(m)&&(m=y(p)),s.push(Object.assign({},a,{parentNode:h,previousSibling:m})),d(),u.push(p)}}return f(u),s},We.prototype.patchParts=function(e){var t=this.parts,n=e.parentNode,r=e.previousSibling;if(!this.patched){for(var o=0,i=t.length;o<i;o++){var a=t[o];a.isNode&&a.parentNode instanceof DocumentFragment&&(a.parentNode=n,a.previousSibling=a.previousSibling||r)}this.patched=!0}};var ct;function dt(e){return ct+e-performance.now()}!function e(){requestAnimationFrame((function(t){ct=t,e()}))}();var pt=function(){return 1};function ft(e){var t=e.node,n=e.alternate;if(G(t)){var r=function(e){var t=e.node,n=e.nodeInstance;return!(!B(t)||!n)&&(!!M(e).length||n.__brahmosData.isDirty)}(e);!e.processedTime||r?($(t)?function(e){var t=e.node,n=e.alternate;t!==(n&&n.node)&&te(e,2)}(e):Array.isArray(t)?function(e){for(var t=e.node,n=e.part,r=e,o=n.parentNode,i=n.previousSibling,a=new Map,s=0,u=e;u=re(u,e);){var c=J(u.node,s);a.set(c,u),s++}e.child=null,t.forEach((function(t,n){var s=J(t,n),u=a.get(s);u&&a.delete(s);var c=r;(r=ae(t,{parentNode:o,previousSibling:i,a:void 0,isArrayNode:!0,nodeIndex:n},u,c,e)).sibling=null,u&&u.part.nodeIndex!==n&&(te(r,1),0!==n&&te(c,1))})),a.forEach((function(e){pe(e)})),te(e,2)}(e):q(t)?Be(e):B(t)?Le(e):t.nodeType===z&&te(e,2),e.processedTime=u()):oe(e)}else n&&pe(n)}function lt(e){var t=e.updateType,n=e.current,r=X(t);ut(e);var o=function(e){for(var t=e.updateType,n=e.wip,r=e.current,o=Y(t),i=e[X(t)],a=[],s="sync"===t?r:n;s;){var u=s.createdAt,c=s.node,d=s.child,p=s.hasUncommittedEffect,f=s[o],l=u>i,h=p||f>i;if(p&&a.push(s),l&&(d&&d.parent!==s&&(d.parent=s),c&&B(c)&&(s.nodeInstance.__brahmosData.fiber=s)),d&&h)s=d;else{for(;s!==e&&!s.sibling;)s=s.parent;s=s.sibling}}return a}(e);e[r]=e.lastCompleteTime=u(),"deferred"===t&&(e.current=e.wip,e.wip=n),function(e,t){for(var n=0,r=t.length;n<r;n++)it(t[n]);for(var o=e.postCommitEffects,i=o.length-1;i>=0;i--)nt(o[i]);ot(e),rt(e),e.requestIdleHandle=null,e.forcedUpdateWith=null}(e,o)}function ht(e,t){var n=e.root,r=n.updateType,o=n.currentTransition,i=X(r),a=Y(r),s=n[i],u=!function(e){return"immediate_action"===e.updateSource}(n);!function(e,t,n){var r=e.scheduleId;if(r&&clearTimeout(r),t){var o=dt(16),i=o>2?0:o+1;e.scheduleId=setTimeout((function(){var t=e.currentTransition,r=t?t.tryCount:0,o=t===S?300:600,i=Math.min(30,5+r);n(r>o?pt:function(){return dt(i)})}),i)}else n(pt)}(n,u,(function(r){for(;e!==t;){if(!(r()>0))return void ht(e,t);ft(e);var i=n.retryFiber;i?(e=i,t=n,n.retryFiber=null):e=ce(e,t,s,a)}var u,c;n.callRenderCallbacks(),o&&("timedOut"!==(c=(u=o).transitionState)&&"suspended"!==c&&(u.isPending?(u.clearTimeout(),u.updatePendingState(!1,"transition")):u.transitionState="completed"),o.tryCount=0,!n.hasUncommittedEffect&&I(o)&&ot(n)),function(e){return"transition"!==e.updateSource||e.lastCompleteTime>=e.updateTime&&e.hasUncommittedEffect&&I(e.currentTransition)}(n)&<(n),N(n)&&U("transition",(function(){n.updateSource="transition",vt(n)}))}))}function vt(e){var t=N(e);t&&(e.updateType="deferred",rt(e),e.currentTransition=t,t.tryCount+=1,e.wip=ne(e.current,e.wip,e,e),ht(e.wip,e))}function mt(e){var t=e.root,n=e.parent;t.updateType="sync",t.currentTransition=null,rt(t),ht(e,n)}function yt(e){var t=de(e),n=t.root,r=x(),o=E(),i=P();if(Z(t,i),"transition"===r){var a=n.pendingTransitions,s=o===S?"unshift":"push";a.includes(o)||a[s](o)}n.batchUpdates[r]||(n.batchUpdates[r]=b((function(){if(n.batchUpdates[r]=null,n.updateSource=r,n.lastCompleteTime<n.updateTime){var e="sync"===n.updateType&&n.requestIdleHandle;mt("immediate_action"===r&&!e?t:n.current)}else vt(n)})))}var gt=function(e){this.props=e,this.state=void 0,this.__brahmosData={lastSnapshot:null,pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,mounted:!1,committedValues:{},memoizedValues:null,isDirty:!1},this.context=void 0};gt.prototype.setState=function(e,t,n){var r=P(),o={state:e,transitionId:E().transitionId,callback:t},i=F(r);this.__brahmosData[i].push(o),yt(this)},gt.prototype.forceUpdate=function(e){var t=this.__brahmosData.fiber;t&&(t.root.forcedUpdateWith=this,this.__brahmosData.isDirty=!0,yt(this),e&&e(this.state))},gt.prototype.__render=function(){var e=this.render();return this.__brahmosData.nodes=e,e};var bt=function(e){function t(t){e.call(this,t),this.isPureReactComponent=!0}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(gt);function Tt(e,t,n){if("string"==typeof e)return function(e,t,n){var r=K(null,[t,n],"");return r.element=e,r.nodeType=H,r}(e,t,n);var r=Object.assign({},e.defaultProps,d(t,e.__isForwardRef),{children:n});e.__loadLazyComponent&&e.__loadLazyComponent();var o=t.key;void 0===o&&(o="");var i=t.ref,a=function(e){return e.prototype instanceof gt}(e),s=K(r,null,""+o);return s.nodeType=a?V:W,s.type=e,s.ref=a?i:null,s}function _t(e,t){for(var n=e.root,r=e.nodeInstance;!(r instanceof wt||t&&r instanceof kt);){if((e=e.parent)===n)return null;r=e.nodeInstance}return e}function St(e){var t=e.parentSuspenseManager;return t&&t.isSuspenseList?t:null}function Ct(e,t){var n=e.nodeInstance;if(!n)return null;var r=n.suspenseManagers,o=t.transitionId,i=r[o];return i||(i=r[o]=new Dt(e,t)),i}function It(e){e.__brahmosData.isDirty=!0}var Dt=function(e,t){var n=e.nodeInstance;this.fiber=e,this.component=n,this.transition=t,this.childManagers=[],this.suspender=null,this.isSuspenseList=n instanceof kt;var r=_t(e.parent,!0);this.parentSuspenseManager=r&&Ct(r,t),this.rootSuspenseManager=null,this.recordChildSuspense(),this.handleSuspense=this.handleSuspense.bind(this)};function Nt(e){var t=D(Q(),S);return"resolved"!==t.transitionState||t.pendingSuspense.includes(e)||(t=S),t}Dt.prototype.recordChildSuspense=function(){var e=this.parentSuspenseManager;e?(e.childManagers.push(this),this.rootSuspenseManager=e.rootSuspenseManager):this.rootSuspenseManager=this},Dt.prototype.addRootToProcess=function(){var e=this.rootSuspenseManager;Q().root.afterRender(e.handleSuspense)},Dt.prototype.suspend=function(e){this.suspender=e,this.addRootToProcess()},Dt.prototype.handleSuspense=function(){var e=this.component,t=this.suspender;return e instanceof kt?this.handleSuspenseList():Promise.resolve(t).then(this.resolve.bind(this,t))},Dt.prototype.isUnresolved=function(){return this.isSuspenseList?this.childManagers.some((function(e){return e.isUnresolved()})):this.suspender},Dt.prototype.shouldShowFallback=function(){var e=St(this);if(!e)return!0;var t=e.component,n=e.childManagers,r=t.props.tail;if(St(e)&&!e.shouldShowFallback())return!1;if("collapsed"===r)for(var o=0,i=n.length;o<i;o++){var a=n[o];if("collapsed"===r&&a.isUnresolved())return a===this}return"hidden"!==r},Dt.prototype.resolve=function(e){var t=this,n=this.component,r=this.transition,o=this.suspender,i=this.childManagers,a=r.pendingSuspense||[];if(e===o)if(o){this.suspender=null,It(this.component);var s="timedOut"===r.transitionState,u=a.filter((function(e){return e.suspenseManagers[r.transitionId].suspender})).length;s||u||(r.transitionState="resolved");var c=function(){var e=n;de(n)||(e=t.fiber.root.wip.nodeInstance),yt(e)};setTimeout((function(){s||!a.includes(n)?O(c):A(r,c)}),Date.now()%100)}else i.forEach((function(e){e.handleSuspense()}))},Dt.prototype.getChildrenSuspenders=function(){var e=[];return this.childManagers.forEach((function(t){t.isSuspenseList?e=e.concat(t.getChildrenSuspenders()):t.suspender&&e.push(t.suspender)})),e},Dt.prototype.handleSuspenseList=function(){var e=this.component,t=this.childManagers,n=e.props,r=n.revealOrder;void 0===r&&(r="together");var o=n.tail,i=function(e,t){return e.then((function(){return"forwards"===r&&"collapsed"===o&&function(e){var t=de(e.component);e.isUnresolved()&&t&&(It(e.component),Z(t,"deferred"))}(t),t.handleSuspense()}))},a=Promise.all(this.getChildrenSuspenders());if("together"===r)a.then((function(){t.forEach((function(e){return e.handleSuspense()}))}));else if("forwards"===r)for(var s=Promise.resolve(),u=0,c=t.length;u<c;u++)s=i(s,t[u]);else if("backwards"===r)for(var d=Promise.resolve(),p=t.length-1;p>=0;p--)d=i(d,t[p]);return a};var kt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children},t}(gt),wt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.handleSuspender=function(e,t){var n=Nt(this),r=Ct(t,n);I(n)||(n.pendingSuspense.includes(this)||n.pendingSuspense.push(this),n.transitionState="suspended"),r.suspend(e)},t.prototype.render=function(){var e=Nt(this),t=Ct(Q(),e),n=!t.suspender,r=this.props,o=r.fallback,i=r.children;return n?i:t.shouldShowFallback()?o:null},t}(gt),xt=function(e){var t,n=Qe((function(e,n){return Tt(t.read().default,Object.assign({},e,{ref:n}),e.children)}));return n.__loadLazyComponent=function(){var n,r,o,i;t||(n=e(),o="pending",i=n.then((function(e){o="success",r=e}),(function(e){o="error",r=e})),t={read:function(){if("pending"===o)throw i;if("error"===o)throw r;if("success"===o)return r}})},n};function Et(e){return e.children}function Ut(e,t){var n,r,o=t.__rootFiber;if(o)(n=o.current).node.props.children=e,n.processedTime=0,Z(n);else{var i=Tt(Et,{},e);r=[],(n=ie(o={updateType:"sync",updateSource:"js",scheduleId:0,domNode:t,forcedUpdateWith:null,current:null,wip:null,child:null,retryFiber:null,currentTransition:null,hasUncommittedEffect:!1,pendingTransitions:[],tearDownFibers:[],postCommitEffects:[],batchUpdates:{},lastDeferredCompleteTime:0,lastCompleteTime:0,deferredUpdateTime:0,updateTime:0,afterRender:function(e){r.includes(e)||r.push(e)},callRenderCallbacks:function(){for(var e=0,t=r.length;e<t;e++)r[e]()},resetRenderCallbacks:function(){r=[]}},i,{parentNode:t,isNode:!0})).parent=o,o.current=n,t.__rootFiber=o}j((function(){o.updateSource=x(),mt(n)}))}var At=new WeakMap;function Pt(e,t){var n=K(null,t,"");return n.nodeType=R,n.template=e,n}function Ft(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];var r=At.get(e);return r||(r=new Ve(e),At.set(e,r)),Pt(r,t)}function Mt(e,t){return e&&(e.portalContainer=t),e}function Ot(e){var t=e.__rootFiber;return!!t&&(pe(t.current),ut(t),e.__rootFiber=void 0,!0)}var jt={createElement:Tt,render:Ut,Component:gt,PureComponent:bt,html:Ft,useState:Ce,useEffect:xe,useRef:Ie,useReducer:De,useMemo:Ne,useCallback:ke,useLayoutEffect:Ee,useContext:Ue,useTransition:Ae,createContext:he,forwardRef:Qe,createRef:Xe,createPortal:Mt,unmountComponentAtNode:Ot,Suspense:wt,SuspenseList:kt,lazy:xt,unstable_deferredUpdates:O,unstable_syncUpdates:j};export default jt;export{gt as Component,bt as PureComponent,wt as Suspense,kt as SuspenseList,he as createContext,Tt as createElement,Mt as createPortal,Xe as createRef,Qe as forwardRef,Ft as html,xt as lazy,Ut as render,Ot as unmountComponentAtNode,O as unstable_deferredUpdates,j as unstable_syncUpdates,ke as useCallback,Ue as useContext,xe as useEffect,Ee as useLayoutEffect,Ne as useMemo,De as useReducer,Ie as useRef,Ce as useState,Ae as useTransition}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Brahmos={})}(this,(function(e){"use strict";var t={key:1,ref:1},n={className:"class",htmlFor:"for",acceptCharset:"accept-charset",httpEquiv:"http-equiv"},r={doubleclick:"dblclick"},o=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,i="http://www.w3.org/1999/xlink";function a(e){return e.nodeName.toLowerCase()}function s(e){return null==e}var u=0;function c(){return u++}function d(e){e.__brahmosData={events:{}}}function f(e,t){var n,r={};for(n in e)"key"===n||"ref"===n&&!t||(r[n]=e[n]);return r}function p(e,t){for(var n=Object.keys(e),r=0,o=n.length;r<o;r++){var i=n[r];t(i,e[i])}}function l(e){Array.isArray(e)||(e=[e]);for(var t=e.length-1;t>=0;t--){var n=e[t];n.parentNode.removeChild(n)}}function h(e){return Array.prototype.slice.call(e)}function v(e,t,n){t=void 0===t?null:t;var r=function(e){var t=e instanceof NodeList;if(e instanceof Node)return e;if(Array.isArray(e)||t){for(var n=document.createDocumentFragment(),r=0;e[r];)n.appendChild(e[r]),t||(r+=1);return n}return document.createTextNode(e)}(n),o=r instanceof DocumentFragment?h(r.childNodes):r;return e.insertBefore(r,t),o}function m(e,t){return t?t.nextSibling:e.firstChild}function y(e,t,n){if(e[t])return e[t].apply(e,n)}function g(e){var t=e.parentNode,n=document.createTextNode("");return t.insertBefore(n,e),n}var b=Promise.resolve();function _(e){return b.then(e)}function T(){return c()+"-"+1e6*Math.random()}var S={transitionId:"",tryCount:0,transitionState:"timedOut"},C={transitionId:T(),tryCount:0,transitionState:"timedOut"};function I(e){var t=e.transitionState;return"start"===t||"resolved"===t||"timedOut"===t}function D(e){var t=e.transitionState;return"completed"===t||"timedOut"===t}function N(e,t){return t=t||S,e.root.currentTransition||t}function k(e){return e.pendingTransitions.find(I)}var w="js",x=S;function E(){return w}function U(){return x}function P(e,t){w=e,t(),_((function(){w="js"}))}function A(e,t){var n=x;x=e,P("transition",t),x=n}function F(){return"transition"===w?"deferred":"sync"}function M(e){return"deferred"===e?"pendingDeferredUpdates":"pendingSyncUpdates"}function O(e){var t=e.root.updateType,n=e.nodeInstance.__brahmosData,r=N(e).transitionId;return n[M(t)].filter((function(e){return e.transitionId===r}))}function j(e){A(C,e)}function L(e){P("immediate_action",e)}var R,H=Symbol("tag"),V=Symbol("tag-element"),W=Symbol("class-component"),z=Symbol("functional-component"),B=Symbol("attribute");function q(e){var t=e.nodeType;return t===H||t===V}function $(e){var t=e.nodeType;return t===W||t===z}function G(e){return"string"==typeof e||"number"==typeof e}function J(e){return!(s(e)||"boolean"==typeof e)}function K(e,t){var n=e&&e.key;if(""===n&&e&&q(e)){for(var r=e.values,o=0,i=r.length;o<i;o++){var a=r[o];if(void 0!==a.key){n=""+a.key;break}}e.key=void 0===n?"":""+n}return""===n?""+t:n}function Q(e,t,n){return{nodeType:null,key:n,added:!1,ref:null,portalContainer:null,type:null,props:e,element:"",values:t,template:null}}function X(){return R}function Y(e){return"deferred"===e?"lastDeferredCompleteTime":"lastCompleteTime"}function Z(e){return"deferred"===e?"deferredUpdateTime":"updateTime"}function ee(e,t){for(var n=Z(t),r=c();e;)e[n]=r,e=e.parent}function te(e,t,n){t===n?n.child=e:t.sibling=e,e.parent=n}function ne(e,t){e.hasUncommittedEffect=t,e.root.hasUncommittedEffect=!0}function re(e,t,n,r){var o=e.root,i=e.node,a=e.part,s=e.nodeInstance,u=e.child,d=Z(o.updateType);return t?(t.node=i,t.part=a,t.createdAt=c()):function(e,t){e&&(e.alternate=t);t.alternate=e}(e,t=ae(o,i,a)),e.shouldTearDown=!1,t.nodeInstance=s,t.child=u,t[d]=r[d],te(t,n,r),t}function oe(e,t){return e===t?e.child:e.sibling}function ie(e){var t=e.child;if("sync"!==e.root.updateType)for(var n;t;){n=re(t,t.alternate,n||e,e),t=t.sibling}}function ae(e,t,n){return t&&t.portalContainer&&(n.parentNode=t.portalContainer),{node:t,nodeInstance:null,root:e,parent:null,child:null,sibling:null,part:n,alternate:null,context:null,childFiberError:null,isSvgPart:!1,deferredUpdateTime:0,updateTime:0,processedTime:0,createdAt:c(),shouldTearDown:!1,hasUncommittedEffect:0}}function se(e,t,n,r,o){var i,a,u,c=r.root,d=Z(c.updateType);return n&&!s(n.node)&&!s(e)&&(a=e,u=n.node,G(a)&&G(u)||a.nodeType===B||Array.isArray(a)&&Array.isArray(u)||$(a)&&a.type===u.type||q(a)&&a.template===u.template)?((i=re(n,n.alternate,r,o)).node=e,i.part=t):(i=ae(c,e,t),n&&pe(n)),te(i,r,o),i.processedTime=0,i[d]=o[d],i.context=o.context,i.isSvgPart=o.isSvgPart,i}function ue(e,t,n){return e&&e[n]>=t}function ce(e,t,n){if(e){for(;e&&!ue(e,t,n);)e=e.sibling;return e}}function de(e,t,n,r){var o,i=ce(e.child,n,r);if(i)return i;for(;!(o=ce(e.sibling,n,r));)if((e=e.parent)===t)return e;return o}function fe(e){return e.__brahmosData.fiber}function pe(e){e.shouldTearDown=!0,e.root.tearDownFibers.push(e)}var le=1;function he(e){return function(t){var n=fe(e),r=n.root.updateType;e.context!==t&&ee(n,r)}}function ve(e){var t="cC"+le++,n=function(e){function t(t){e.call(this,t),this.subs=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.shouldComponentUpdate=function(e){return this.props.value!==e.value&&this.subs.forEach((function(t){return t(e.value)})),!0},t.prototype.sub=function(e){var t=this.subs,n=he(e);t.push(n);var r=e.componentWillUnmount;e.componentWillUnmount=function(){t.splice(t.indexOf(n),1),r&&r()}},t.prototype.render=function(){return this.props.children},t}(bt);n.__ccId=t;var r=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children(this.context)},t}(bt),o={id:t,defaultValue:e,Provider:n,Consumer:r};return r.contextType=o,o}function me(){return X().nodeInstance}function ye(e){e.deferredHooks=e.syncHooks.map((function(e,t){return Array.isArray(e)?[].concat(e):e.transitionId?e:Object.assign({},e)}))}function ge(e,t){var n=t.syncHooks,r=t.deferredHooks;return"sync"===e?n:r}function be(e){var t=e.nodeInstance;return ge(e.root.updateType,t)}function _e(e,t,n){return"deferred"!==e||n.deferredHooks.length||ye(n),ge(e,n)[t]}function Te(e,t){if(!e||!t||e.length!==t.length)return!0;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!0;return!1}function Se(e,t,n){void 0===t&&(t=function(e){return!1}),void 0===n&&(n=function(e){return e});var r=X(),o=r.nodeInstance,i=o.pointer,a=be(r),s=a[i];return s&&!t(s)||(s=e(),a[i]=s),o.pointer+=1,n(s)}function Ce(e,t){var n=me(),r=n.pointer;return Se((function(){return"function"==typeof e&&(e=e()),[e,function(e){var o=F(),i=_e(o,r,n),a=i[0],s=t(e,a),u=M(o),c={transitionId:U().transitionId,updater:function(){_e(o,r,n)[0]=t(e,i[0])}};n.__brahmosData[u].push(c),function(e,t,n){Object.is(t,n)||gt(e)}(n,s,a)}]}))}function Ie(e){return Ce(e,(function(e,t){return"function"==typeof e&&(e=e(t)),e}))}function De(e){return Se((function(){return{current:e}}))}function Ne(e,t,n){return Ce(n?function(){return n(t)}:t,(function(t,n){return e(n,t)}))}function ke(e,t){return Se((function(){return{value:e(),dependencies:t}}),(function(e){return Te(t,e.dependencies)}),(function(e){return e.value}))}function we(e,t){return ke((function(){return e}),t)}function xe(e,t){var n=X(),r=n.nodeInstance,o=r.pointer,i=be(n),a=i[o]||{animationFrame:null,cleanEffect:null},s=Object.assign({},a,{isDependenciesChanged:Te(t,a.dependencies),dependencies:t,effect:function(){s.isDependenciesChanged&&e(s)}});i[o]=s,r.pointer+=1}function Ee(e,t){xe((function(t){cancelAnimationFrame(t.animationFrame),t.animationFrame=requestAnimationFrame((function(){setTimeout((function(){t.cleanEffect=e()}))}))}),t)}function Ue(e,t){xe((function(t){t.cleanEffect=e()}),t)}function Pe(e){var t=X(),n=t.nodeInstance,r=t.context,o=e.id,i=e.defaultValue,a=r[o],s=a?a.props.value:i;return Ue((function(){if(a){var e=a.subs,t=he(n);return e.push(t),function(){e.splice(e.indexOf(t),1)}}}),[]),n.context=s,s}function Ae(e){e.timeoutMs;var t=me();return Se((function(){var e={transitionId:T(),tryCount:0,isPending:!1,transitionTimeout:null,pendingSuspense:[],transitionState:"initial",clearTimeout:function(){clearTimeout(e.transitionTimeout)},updatePendingState:function(n,r){e.isPending=n,t.__brahmosData.isDirty=!0;var o=function(){gt(t)};"transition"===r?A(e,o):P(r,o)},startTransition:function(n){var r=E(),o=fe(t).root;e.transitionState="start",e.pendingSuspense=[],e.clearTimeout(),A(e,n),o.lastDeferredCompleteTime<o.deferredUpdateTime&&e.updatePendingState(!0,r)}};return e}),void 0,(function(e){return[e.startTransition,e.isPending]}))}function Fe(e,t){for(var n=be(e),r=0,o=n.length;r<o;r++){var i=n[r];i.cleanEffect&&(i.isDependenciesChanged||t)&&i.cleanEffect(),i.clearTimeout&&t&&i.clearTimeout()}}function Me(e){var t;return(t={syncHooks:[],deferredHooks:[],pointer:0,__render:function(t){var n,r,o;n=X(),r=n.nodeInstance,o=n.root.updateType,r.pointer=0,"deferred"===o&&ye(r),O(n).forEach((function(e){return e.updater()}));var i=e(t);return this.__brahmosData.nodes=i,i}}).__brahmosData={pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,isDirty:!1,mounted:!1},t}function Oe(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function je(e){for(var t=e.root;(e=e.parent)&&!(e.nodeInstance instanceof bt&&(e.nodeInstance.componentDidCatch||e.node.type.getDerivedStateFromError));)if(e===t)return null;return e}function Le(e){var t=e.root;e.nodeInstance.__brahmosData.isDirty=!0,t.retryFiber=e}function Re(e){var t,n=e.node,r=e.part,o=e.root,i=e.childFiberError,a=n.type,s=n.nodeType,u=n.props;void 0===u&&(u={});var c="deferred"===o.updateType,d=!0,f=!1,p=s===W;!function(e){var t=e.root,n=e.child,r=e.alternate;n&&n.createdAt>t.lastCompleteTime&&(e.child=r&&r.child)}(e);var l=e.nodeInstance,h=!1;l||(l=p?new a(u):Me(a),e.nodeInstance=l,h=!0);var v=l.__brahmosData,m=function(e){var t=e.node.type,n=e.nodeInstance,r=e.parent,o=e.context,i=t.__ccId,a=r.context||{};if(!i)return a;if(o)return o;var s=Object.create(a);return s[i]=n,s}(e);if(e.context=m,p){var g=v.committedValues,b=v.memoizedValues;h&&(g.state=l.state);var _=g.props,T=g.state;b&&c&&(_=(t=b).props,T=t.state,f=!0),l.props=_,l.state=T;var S=l.shouldComponentUpdate,C=T,I=O(e);I.length&&(C=function(e,t){return t.reduce((function(e,t){var n=t.state;return"function"==typeof n&&(n=n(e)),Object.assign({},e,n)}),e)}(T,I));var D=!h&&o.forcedUpdateWith!==l,N=y(a,"getDerivedStateFromProps",[u,C]),k=i?y(a,"getDerivedStateFromError",[i.error]):void 0;(N||k)&&(C=Object.assign({},C,N,k)),I.forEach((function(e){var t=e.callback;t&&t(C)})),l.isPureReactComponent&&D&&(d=!Oe(C,T)||!Oe(u,_)),S&&d&&D&&(d=S.call(l,u,C));var w=a.contextType;if(w){var x=w.id,E=w.defaultValue,U=m[x],P=U?U.props.value:E;U&&h&&U.sub(l),l.context=P}l.state=C,l.props=u,c&&(v.memoizedValues={state:C,props:u})}else h||Fe(e);if(d){try{!function(e){R=e}(e),se(i&&!a.getDerivedStateFromError?null:l.__render(u),r,e.child,e,e)}catch(t){var A=je(e);if("function"==typeof t.then){var F=St(e);if(!F)throw new Error("Rendering which got suspended can't be used outside of suspense.");F.nodeInstance.handleSuspender(t,F),Le(F)}else{if(!A||A.childFiberError)throw t;var M=function(e){var t=e.node.type;return{componentStack:"The above error occurred in the <"+(t.displayName||t.name)+"> component:"}}(e);console.error(t),console.error(M.componentStack),A.childFiberError={error:t,errorInfo:M},Le(A)}return}ne(e,2)}else if(f){var j=e.child;j&&j.node===v.nodes||(se(v.nodes,r,j,e,e),ne(e,2))}else ie(e)}var He=/[<>"]/g,Ve=/(^|\s)([^\s"'=<]+)(?=[\s=>])/g;var We=function(e){this.strings=e,this.template=null,this.svgTemplate=null,this.partsMeta=[]};We.prototype.create=function(e){e&&this.svgTemplate||this.template||(this.partsMeta=this.getPartsMeta(),this.createTemplate(e))},We.prototype.getPartsMeta=function(){for(var e,t,n=this.strings,r=[],o=[],i=function(i,a){for(var s=n[i],u=void 0,c=void 0,d=void 0,f=void 0,p=void 0,l=function(){var e=s.substring(f||0,p||s.length);r.push.apply(r,function(e){for(var t,n=[];null!==(t=Ve.exec(e));){t[2]&&n.push(t[2])}return n}(e))};null!==(u=He.exec(s));)"<"!==u[0]||t?'"'===u[0]?t=!t:e&&">"===u[0]&&!t&&(e=!1,p=u.index,void 0===f&&l()):(e=!0,r=[],f=u.index,p=void 0);e&&l(),e?c=!0:d=!0,i<a-1&&o.push({tagAttrs:r,attrIndex:r.length,isAttribute:c,isNode:d})},a=0,s=n.length;a<s;a++)i(a,s);return o},We.prototype.createTemplate=function(e){for(var t=this.partsMeta,n=this.strings,r=document.createElement("template"),o="",i=0,a=n.length-1;i<a;i++){var s=n[i];o=t[i].isNode?o+s+"\x3c!--{{brahmos}}--\x3e":o+s+"data-brahmos-attr"}o+=n[n.length-1],r.innerHTML=e?"<svg>"+o+"</svg>":o,e&&function(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}(r.content.firstChild),this[e?"svgTemplate":"template"]=r};var ze=function(e,t){this.templateResult=e,e.create(t),this.fragment=this.createNode(t),this.parts=this.getParts(),this.domNodes=h(this.fragment.childNodes),this.patched=!1};function Be(e,t,n){return n<=e.lastIndexOf(t)}function qe(e,r,o){for(var i=o,a=o.child,s=function(s,c){var d=e[s],f=r[s],l=d.isAttribute,h=d.isNode,v=void 0;if(l){for(var m=d.domNode,y={},g=void 0;d&&m===d.domNode;)p(r[s],(function(e,r){var o=n[e];Be(d.tagAttrs,o,d.attrIndex)||t[e]?"ref"===e&&(g=r):y[e]=r})),d=e[++s];s--,d=e[s],v={nodeType:B,attributes:y,ref:g}}else h&&(v=f);i=se(v,d,a,i,o),a=a&&a.sibling,u=s},u=0,c=e.length;u<c;u++)s(u)}function $e(e){var t=e.node,n=e.part,r=e.alternate,o=e.parent.context,i=r&&r.node,a=t.values,s=t.nodeType===V,u=e.isSvgPart||s&&"svg"===t.element;e.isSvgPart=u;var c=e.nodeInstance;c||(c=s?function(e,t){var n=e.element,r=e.values,o=t?document.createElementNS("http://www.w3.org/2000/svg",n):document.createElement(n);return d(o),{fragment:o,nodes:[o],parts:[{isAttribute:!0,tagAttrs:[],attrIndex:0,domNode:o},{parentNode:o,isNode:!0}],values:r}}(t,u):new ze(t.template,u),e.nodeInstance=c),s||c.patchParts(n),t!==i?qe(c.parts,a,e):ie(e),ne(e,2),e.context=o}function Ge(e){var t=e.type,n=a(e);return"input"!==n||"radio"!==t&&"checkbox"!==t?"input"===n||"select"===n||"textarea"===n?"value":void 0:"checked"}function Je(e,t,n,r){t=t||{},p(e,(function(e,n){var o=t[e];n!==o&&r(e,n,o)})),p(t,(function(t,o){void 0===e[t]&&r(t,n,o)}))}function Ke(e,t,n,s,u){if(function(e){return 0===e.indexOf("on")}(t)){var c=function(e){return e.replace("on","").toLowerCase()}(t);c=function(e,t){var n=a(t);return r[e]?r[e]:"input"===n&&"change"===e?"input":e}(c,e);var d=function(e,t,n){var r=e.__brahmosData.events,o=r[t];return o?(o.handler=n,o.patched):((o=r[t]={handler:n,patched:null}).patched=function(e){var t=this;o.handler&&L((function(){o.handler.call(t,e)}))},o.patched)}(e,t,n);s&&!n?e.removeEventListener(c,d):!s&&n&&e.addEventListener(c,d)}else if("style"===t){var f=e.style;Je(n,s,"",(function(e,t){"-"===e[0]?f.setProperty(e,t):f[e]="number"==typeof t&&!1===o.test(e)?t+"px":t}))}else if("dangerouslySetInnerHTML"===t){var p=s&&s.__html,l=n&&n.__html;l!==p&&(e.innerHTML=null==l?"":l)}else if(t in e&&!u){var h=Ge(e);h?function(e,t,n,r){"checked"===e?"checked"===n?(t.checked=r,t.checkedProp=r):"defaultChecked"===n&&void 0===t.checkedProp?t.checked=r:t[n]=r:"value"===e&&("value"===n?(t.value=r,t.valueProp=r):"defaultValue"===n&&void 0===t.valueProp?t.value=r:t[n]=r)}(h,e,t,n):e[t]=null==n?"":n}else{var v=t.replace(/^xlink:?/,""),m=null==n||!1===n;t!==v?(v=v.toLowerCase(),m?e.removeAttributeNS(i,v):e.setAttributeNS(i,v,n)):m?e.removeAttribute(t):e.setAttribute(t,n)}}function Qe(e,t,n,r){Je(t,n,null,(function(t,n,o){Ke(e,t,n,o,r)})),function(e){var t=Ge(e);if(t){var n=e[t+"Prop"],r=e[t];void 0!==n&&n!==r&&(e[t]=n)}}(e)}function Xe(e){function t(t){return e(f(t,!1),t.ref)}return t.__isForwardRef=!0,t}function Ye(){return{current:null}}function Ze(e,t){var n=typeof e;"function"===n?e(t):"object"===n&&(e.current=t)}function et(e,t){var n=t.domNodes;e.__brahmosLastArrayDom=n[n.length-1]}function tt(e){var t=e.previousSibling;return e.isArrayNode&&(t=0===e.nodeIndex?t:e.parentNode.__brahmosLastArrayDom),t}function nt(e,t){var n=e.part;if(n.isArrayNode){var r=n.nodeIndex,o=n.parentNode,i=t.part.nodeIndex,a=function(e){for(;e.node&&!q(e.node);)e=e.child;return e}(e),s=a.nodeInstance,u=a!==e&&a.hasUncommittedEffect;if(s&&!u){if(r!==i){var c=s.domNodes,d=tt(n),f=m(o,d),p=c[0];p&&p.previousSibling!==d&&p!==f&&v(o,f,c)}et(o,s)}}}function rt(e){var t=e.node,n=e.nodeInstance,r=e.root,o=e.childFiberError,i=r.updateType,a=t.nodeType,s=t.ref,u=n.__brahmosData;if(a===W){var c=n.props,d=n.state,f=u.committedValues,p=u.lastSnapshot,l=f.props,h=f.state;l?y(n,"componentDidUpdate",[l,h,p]):y(n,"componentDidMount"),o&&(y(n,"componentDidCatch",[o.error,o.errorInfo]),e.childFiberError=null),s&&Ze(s,n),f.props=c,f.state=d,u.memoizedValues=null}else if(function(e){for(var t=be(e),n=0,r=t.length;n<r;n++){var o=t[n];o.effect&&o.effect()}}(e),"deferred"===i){var v=n.syncHooks,m=n.deferredHooks;n.deferredHooks=v,n.syncHooks=m}u.mounted=!0,u.fiber=e}function ot(e){e.tearDownFibers=[],e.postCommitEffects=[],e.hasUncommittedEffect=!1,e.resetRenderCallbacks()}function it(e){var t=e.currentTransition,n=e.pendingTransitions,r=n.indexOf(t);-1!==r&&n.splice(r,1)}function at(e){var t=e.node,n=e.alternate,r=t&&$(t);r&&n&&nt(e,n),2===e.hasUncommittedEffect&&(G(t)?function(e){var t=e.part,n=e.node,r=e.alternate,o=t.parentNode,i=m(o,t.previousSibling);r?i.nodeValue=n:v(o,i,n)}(e):q(t)?function(e){var t=e.part,n=e.nodeInstance,r=e.alternate,o=t.parentNode;if(r)nt(e,r);else{var i=m(o,tt(t));n.domNodes=v(o,i,n.fragment),et(o,n)}}(e):r?function(e){var t=e.node,n=e.nodeInstance,r=e.root,o=r.updateType,i=t.nodeType,a=n.__brahmosData;if(i===W){var s=a.committedValues,u=s.props,c=s.state;a.lastSnapshot=y(n,"getSnapshotBeforeUpdate",[u,c])}var d=N(e).transitionId,f=M(o);a[f]=a[f].filter((function(e){return e.transitionId!==d})),a.isDirty=!1,r.postCommitEffects.push(e)}(e):t.nodeType===B&&function(e){var t=e.part,n=e.node,r=e.alternate,o=e.isSvgPart,i=t.domNode,a=n.attributes,s=n.ref;Qe(i,a,r&&r.node.attributes,o),s&&Ze(s,i)}(e),e.hasUncommittedEffect=!1),n&&function(e){e.node=null,e.nodeInstance=null,e.child=null,e.sibling=null}(n)}function st(e,t,n,r){var o=(e.part.parentNode===t.parentNode||!n)&&r,i=e.node;i&&i.portalContainer&&(o=!0),ut(e,o)}function ut(e,t){var n=e.node,r=e.part,o=e.nodeInstance;if(J(n)){var i=q(n),a=e.child;if(a)for(st(a,r,i,t);a.sibling;)st(a=a.sibling,r,i,t);if(G(n)&&t){l(m(r.parentNode,r.previousSibling))}else{var s=n.ref;if(s&&Ze(s,null),o)if(i){var u=o.domNodes;t&&l(u)}else $(n)&&o.__brahmosData.mounted&&(n.nodeType===W?y(o,"componentWillUnmount"):Fe(e,!0))}}}function ct(e){e.tearDownFibers.forEach((function(e){e.shouldTearDown&&ut(e,!0)})),e.tearDownFibers=[]}ze.prototype.createNode=function(e){var t=this.templateResult,n=t.template,r=t.svgTemplate,o=e?r:n;return document.importNode(o.content,!0)},ze.prototype.createWalker=function(e){return document.createTreeWalker(e,129,null,!1)},ze.prototype.isBrahmosCommentNode=function(e){return e&&8===e.nodeType&&"{{brahmos}}"===e.textContent},ze.prototype.getParts=function(){for(var e=this.fragment,t=this.templateResult,n=this.isBrahmosCommentNode,r=t.partsMeta,o=this.createWalker(e),i=0,a=r[i],s=[],u=[],c=function(){i++,a=r[i]};o.nextNode();){var f=o.currentNode,p=f.nodeType,h=f.parentNode;if(1===p&&f.hasAttribute("data-brahmos-attr")){f.removeAttribute("data-brahmos-attr");for(var v=a.tagAttrs;a&&a.isAttribute&&a.tagAttrs===v;)s.push(Object.assign({},a,{domNode:f})),c();d(f)}else if(n(f)){var m=f.previousSibling;n(m)&&(m=g(f)),s.push(Object.assign({},a,{parentNode:h,previousSibling:m})),c(),u.push(f)}}return l(u),s},ze.prototype.patchParts=function(e){var t=this.parts,n=e.parentNode,r=e.previousSibling;if(!this.patched){for(var o=0,i=t.length;o<i;o++){var a=t[o];a.isNode&&a.parentNode instanceof DocumentFragment&&(a.parentNode=n,a.previousSibling=a.previousSibling||r)}this.patched=!0}};var dt;function ft(e){return dt+e-performance.now()}!function e(){requestAnimationFrame((function(t){dt=t,e()}))}();var pt=function(){return 1};function lt(e){var t=e.node,n=e.alternate;if(J(t)){var r=function(e){var t=e.node,n=e.nodeInstance;return!(!$(t)||!n)&&(!!O(e).length||n.__brahmosData.isDirty)}(e);!e.processedTime||r?(G(t)?function(e){var t=e.node,n=e.alternate;t!==(n&&n.node)&&ne(e,2)}(e):Array.isArray(t)?function(e){for(var t=e.node,n=e.part,r=e,o=n.parentNode,i=n.previousSibling,a=new Map,s=0,u=e;u=oe(u,e);){var c=K(u.node,s);a.set(c,u),s++}e.child=null,t.forEach((function(t,n){var s=K(t,n),u=a.get(s);u&&a.delete(s);var c=r;(r=se(t,{parentNode:o,previousSibling:i,a:void 0,isArrayNode:!0,nodeIndex:n},u,c,e)).sibling=null,u&&u.part.nodeIndex!==n&&(ne(r,1),0!==n&&ne(c,1))})),a.forEach((function(e){pe(e)})),ne(e,2)}(e):q(t)?$e(e):$(t)?Re(e):t.nodeType===B&&ne(e,2),e.processedTime=c()):ie(e)}else n&&pe(n)}function ht(e){var t=e.updateType,n=e.current,r=Y(t);ct(e);var o=function(e){for(var t=e.updateType,n=e.wip,r=e.current,o=Z(t),i=e[Y(t)],a=[],s="sync"===t?r:n;s;){var u=s.createdAt,c=s.node,d=s.child,f=s.hasUncommittedEffect,p=s[o],l=u>i,h=f||p>i;if(f&&a.push(s),l&&(d&&d.parent!==s&&(d.parent=s),c&&$(c)&&(s.nodeInstance.__brahmosData.fiber=s)),d&&h)s=d;else{for(;s!==e&&!s.sibling;)s=s.parent;s=s.sibling}}return a}(e);e[r]=e.lastCompleteTime=c(),"deferred"===t&&(e.current=e.wip,e.wip=n),function(e,t){for(var n=0,r=t.length;n<r;n++)at(t[n]);for(var o=e.postCommitEffects,i=o.length-1;i>=0;i--)rt(o[i]);it(e),ot(e),e.requestIdleHandle=null,e.forcedUpdateWith=null}(e,o)}function vt(e,t){var n=e.root,r=n.updateType,o=n.currentTransition,i=Y(r),a=Z(r),s=n[i],u=!function(e){return"immediate_action"===e.updateSource}(n);!function(e,t,n){var r=e.scheduleId;if(r&&clearTimeout(r),t){var o=ft(16);e.scheduleId=setTimeout((function(){var t=e.currentTransition,r=t?t.tryCount:0,o=t===C?200:500,i=Math.min(25,r);n(r>o?pt:function(){return ft(5+i)})}),o)}else n(pt)}(n,u,(function(r){for(;e!==t;){if(!(r()>0))return void vt(e,t);lt(e);var i=n.retryFiber;i?(e=i,t=n,n.retryFiber=null):e=de(e,t,s,a)}var u,c;n.callRenderCallbacks(),o&&("timedOut"!==(c=(u=o).transitionState)&&"suspended"!==c&&(u.isPending?(u.clearTimeout(),u.updatePendingState(!1,"transition")):u.transitionState="completed"),o.tryCount=0,!n.hasUncommittedEffect&&D(o)&&it(n)),function(e){return"transition"!==e.updateSource||e.lastCompleteTime>=e.updateTime&&e.hasUncommittedEffect&&D(e.currentTransition)}(n)&&ht(n),k(n)&&P("transition",(function(){n.updateSource="transition",mt(n)}))}))}function mt(e){var t=k(e);t&&(e.updateType="deferred",ot(e),e.currentTransition=t,t.tryCount+=1,e.wip=re(e.current,e.wip,e,e),vt(e.wip,e))}function yt(e){var t=e.root,n=e.parent;t.updateType="sync",t.currentTransition=null,ot(t),vt(e,n)}function gt(e){var t=fe(e),n=t.root,r=E(),o=U(),i=F();if(ee(t,i),"transition"===r){var a=n.pendingTransitions,s=o===C?"unshift":"push";a.includes(o)||a[s](o)}n.batchUpdates[r]||(n.batchUpdates[r]=_((function(){if(n.batchUpdates[r]=null,n.updateSource=r,n.lastCompleteTime<n.updateTime){var e="sync"===n.updateType&&n.requestIdleHandle;yt("immediate_action"===r&&!e?t:n.current)}else mt(n)})))}var bt=function(e){this.props=e,this.state=void 0,this.__brahmosData={lastSnapshot:null,pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,mounted:!1,committedValues:{},memoizedValues:null,isDirty:!1},this.context=void 0};bt.prototype.setState=function(e,t,n){var r=F(),o={state:e,transitionId:U().transitionId,callback:t},i=M(r);this.__brahmosData[i].push(o),gt(this)},bt.prototype.forceUpdate=function(e){var t=this.__brahmosData.fiber;t&&(t.root.forcedUpdateWith=this,this.__brahmosData.isDirty=!0,gt(this),e&&e(this.state))},bt.prototype.__render=function(){var e=this.render();return this.__brahmosData.nodes=e,e};var _t=function(e){function t(t){e.call(this,t),this.isPureReactComponent=!0}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(bt);function Tt(e,t,n){if("string"==typeof e)return function(e,t,n){var r=Q(null,[t,n],"");return r.element=e,r.nodeType=V,r}(e,t,n);var r=Object.assign({},e.defaultProps,f(t,e.__isForwardRef),{children:n});e.__loadLazyComponent&&e.__loadLazyComponent();var o=t.key;void 0===o&&(o="");var i=t.ref,a=function(e){return e.prototype instanceof bt}(e),s=Q(r,null,""+o);return s.nodeType=a?W:z,s.type=e,s.ref=a?i:null,s}function St(e,t){for(var n=e.root,r=e.nodeInstance;!(r instanceof xt||t&&r instanceof wt);){if((e=e.parent)===n)return null;r=e.nodeInstance}return e}function Ct(e){var t=e.parentSuspenseManager;return t&&t.isSuspenseList?t:null}function It(e,t){var n=e.nodeInstance;if(!n)return null;var r=n.suspenseManagers,o=t.transitionId,i=r[o];return i||(i=r[o]=new Nt(e,t)),i}function Dt(e){e.__brahmosData.isDirty=!0}var Nt=function(e,t){var n=e.nodeInstance;this.fiber=e,this.component=n,this.transition=t,this.childManagers=[],this.suspender=null,this.isSuspenseList=n instanceof wt;var r=St(e.parent,!0);this.parentSuspenseManager=r&&It(r,t),this.rootSuspenseManager=null,this.recordChildSuspense(),this.handleSuspense=this.handleSuspense.bind(this)};function kt(e){var t=N(X(),C);return"resolved"!==t.transitionState||t.pendingSuspense.includes(e)||(t=C),t}Nt.prototype.recordChildSuspense=function(){var e=this.parentSuspenseManager;e?(e.childManagers.push(this),this.rootSuspenseManager=e.rootSuspenseManager):this.rootSuspenseManager=this},Nt.prototype.addRootToProcess=function(){var e=this.rootSuspenseManager;X().root.afterRender(e.handleSuspense)},Nt.prototype.suspend=function(e){this.suspender=e,this.addRootToProcess()},Nt.prototype.handleSuspense=function(){var e=this.component,t=this.suspender;return e instanceof wt?this.handleSuspenseList():Promise.resolve(t).then(this.resolve.bind(this,t))},Nt.prototype.isUnresolved=function(){return this.isSuspenseList?this.childManagers.some((function(e){return e.isUnresolved()})):this.suspender},Nt.prototype.shouldShowFallback=function(){var e=Ct(this);if(!e)return!0;var t=e.component,n=e.childManagers,r=t.props.tail;if(Ct(e)&&!e.shouldShowFallback())return!1;if("collapsed"===r)for(var o=0,i=n.length;o<i;o++){var a=n[o];if("collapsed"===r&&a.isUnresolved())return a===this}return"hidden"!==r},Nt.prototype.resolve=function(e){var t=this,n=this.component,r=this.transition,o=this.suspender,i=this.childManagers,a=r.pendingSuspense||[];if(e===o)if(o){this.suspender=null,Dt(this.component);var s="timedOut"===r.transitionState,u=a.filter((function(e){return e.suspenseManagers[r.transitionId].suspender})).length;s||u||(r.transitionState="resolved");var c=function(){var e=n;fe(n)||(e=t.fiber.root.wip.nodeInstance),gt(e)};setTimeout((function(){s||!a.includes(n)?j(c):A(r,c)}),Date.now()%100)}else i.forEach((function(e){e.handleSuspense()}))},Nt.prototype.getChildrenSuspenders=function(){var e=[];return this.childManagers.forEach((function(t){t.isSuspenseList?e=e.concat(t.getChildrenSuspenders()):t.suspender&&e.push(t.suspender)})),e},Nt.prototype.handleSuspenseList=function(){var e=this.component,t=this.childManagers,n=e.props,r=n.revealOrder;void 0===r&&(r="together");var o=n.tail,i=function(e,t){return e.then((function(){return"forwards"===r&&"collapsed"===o&&function(e){var t=fe(e.component);e.isUnresolved()&&t&&(Dt(e.component),ee(t,"deferred"))}(t),t.handleSuspense()}))},a=Promise.all(this.getChildrenSuspenders());if("together"===r)a.then((function(){t.forEach((function(e){return e.handleSuspense()}))}));else if("forwards"===r)for(var s=Promise.resolve(),u=0,c=t.length;u<c;u++)s=i(s,t[u]);else if("backwards"===r)for(var d=Promise.resolve(),f=t.length-1;f>=0;f--)d=i(d,t[f]);return a};var wt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children},t}(bt),xt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.handleSuspender=function(e,t){var n=kt(this),r=It(t,n);D(n)||(n.pendingSuspense.includes(this)||n.pendingSuspense.push(this),n.transitionState="suspended"),r.suspend(e)},t.prototype.render=function(){var e=kt(this),t=It(X(),e),n=!t.suspender,r=this.props,o=r.fallback,i=r.children;return n?i:t.shouldShowFallback()?o:null},t}(bt),Et=function(e){var t,n=Xe((function(e,n){return Tt(t.read().default,Object.assign({},e,{ref:n}),e.children)}));return n.__loadLazyComponent=function(){var n,r,o,i;t||(n=e(),o="pending",i=n.then((function(e){o="success",r=e}),(function(e){o="error",r=e})),t={read:function(){if("pending"===o)throw i;if("error"===o)throw r;if("success"===o)return r}})},n};function Ut(e){return e.children}function Pt(e,t){var n,r,o=t.__rootFiber;if(o)(n=o.current).node.props.children=e,n.processedTime=0,ee(n);else{var i=Tt(Ut,{},e);r=[],(n=ae(o={updateType:"sync",updateSource:"js",scheduleId:0,domNode:t,forcedUpdateWith:null,current:null,wip:null,child:null,retryFiber:null,currentTransition:null,hasUncommittedEffect:!1,pendingTransitions:[],tearDownFibers:[],postCommitEffects:[],batchUpdates:{},lastDeferredCompleteTime:0,lastCompleteTime:0,deferredUpdateTime:0,updateTime:0,afterRender:function(e){r.includes(e)||r.push(e)},callRenderCallbacks:function(){for(var e=0,t=r.length;e<t;e++)r[e]()},resetRenderCallbacks:function(){r=[]}},i,{parentNode:t,isNode:!0})).parent=o,o.current=n,t.__rootFiber=o}L((function(){o.updateSource=E(),yt(n)}))}var At=new WeakMap;function Ft(e,t){var n=Q(null,t,"");return n.nodeType=H,n.template=e,n}function Mt(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];var r=At.get(e);return r||(r=new We(e),At.set(e,r)),Ft(r,t)}function Ot(e,t){return e&&(e.portalContainer=t),e}function jt(e){var t=e.__rootFiber;return!!t&&(pe(t.current),ct(t),e.__rootFiber=void 0,!0)}var Lt={createElement:Tt,render:Pt,Component:bt,PureComponent:_t,html:Mt,useState:Ie,useEffect:Ee,useRef:De,useReducer:Ne,useMemo:ke,useCallback:we,useLayoutEffect:Ue,useContext:Pe,useTransition:Ae,createContext:ve,forwardRef:Xe,createRef:Ye,createPortal:Ot,unmountComponentAtNode:jt,Suspense:xt,SuspenseList:wt,lazy:Et,unstable_deferredUpdates:j,unstable_syncUpdates:L};e.Component=bt,e.PureComponent=_t,e.Suspense=xt,e.SuspenseList=wt,e.createContext=ve,e.createElement=Tt,e.createPortal=Ot,e.createRef=Ye,e.default=Lt,e.forwardRef=Xe,e.html=Mt,e.lazy=Et,e.render=Pt,e.unmountComponentAtNode=jt,e.unstable_deferredUpdates=j,e.unstable_syncUpdates=L,e.useCallback=we,e.useContext=Pe,e.useEffect=Ee,e.useLayoutEffect=Ue,e.useMemo=ke,e.useReducer=Ne,e.useRef=De,e.useState=Ie,e.useTransition=Ae,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Brahmos={})}(this,(function(e){"use strict";var t={key:1,ref:1},n={className:"class",htmlFor:"for",acceptCharset:"accept-charset",httpEquiv:"http-equiv"},r={doubleclick:"dblclick"},o=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,i="http://www.w3.org/1999/xlink";function a(e){return e.nodeName.toLowerCase()}function s(e){return null==e}var u=0;function c(){return u++}function d(e){e.__brahmosData={events:{}}}function f(e,t){var n,r={};for(n in e)"key"===n||"ref"===n&&!t||(r[n]=e[n]);return r}function p(e,t){for(var n=Object.keys(e),r=0,o=n.length;r<o;r++){var i=n[r];t(i,e[i])}}function l(e){Array.isArray(e)||(e=[e]);for(var t=e.length-1;t>=0;t--){var n=e[t];n.parentNode.removeChild(n)}}function h(e){return Array.prototype.slice.call(e)}function v(e,t,n){t=void 0===t?null:t;var r=function(e){var t=e instanceof NodeList;if(e instanceof Node)return e;if(Array.isArray(e)||t){for(var n=document.createDocumentFragment(),r=0;e[r];)n.appendChild(e[r]),t||(r+=1);return n}return document.createTextNode(e)}(n),o=r instanceof DocumentFragment?h(r.childNodes):r;return e.insertBefore(r,t),o}function m(e,t){return t?t.nextSibling:e.firstChild}function y(e,t,n){if(e[t])return e[t].apply(e,n)}function g(e){var t=e.parentNode,n=document.createTextNode("");return t.insertBefore(n,e),n}var b=Promise.resolve();function T(e){return b.then(e)}function S(){return c()+"-"+1e6*Math.random()}var _={transitionId:"",tryCount:0,transitionState:"timedOut"},C={transitionId:S(),tryCount:0,transitionState:"timedOut"};function I(e){var t=e.transitionState;return"start"===t||"resolved"===t||"timedOut"===t}function D(e){var t=e.transitionState;return"completed"===t||"timedOut"===t}function N(e,t){return t=t||_,e.root.currentTransition||t}function k(e){return e.pendingTransitions.find(I)}var w="js",x=_;function E(){return w}function U(){return x}function P(e,t){w=e,t(),T((function(){w="js"}))}function A(e,t){var n=x;x=e,P("transition",t),x=n}function F(){return"transition"===w?"deferred":"sync"}function M(e){return"deferred"===e?"pendingDeferredUpdates":"pendingSyncUpdates"}function O(e){var t=e.root.updateType,n=e.nodeInstance.__brahmosData,r=N(e).transitionId;return n[M(t)].filter((function(e){return e.transitionId===r}))}function j(e){A(C,e)}function L(e){P("immediate_action",e)}var R,H=Symbol("tag"),V=Symbol("tag-element"),W=Symbol("class-component"),z=Symbol("functional-component"),B=Symbol("attribute");function q(e){var t=e.nodeType;return t===H||t===V}function $(e){var t=e.nodeType;return t===W||t===z}function G(e){return"string"==typeof e||"number"==typeof e}function J(e){return!(s(e)||"boolean"==typeof e)}function K(e,t){var n=e&&e.key;if(""===n&&e&&q(e)){for(var r=e.values,o=0,i=r.length;o<i;o++){var a=r[o];if(void 0!==a.key){n=""+a.key;break}}e.key=void 0===n?"":""+n}return""===n?""+t:n}function Q(e,t,n){return{nodeType:null,key:n,added:!1,ref:null,portalContainer:null,type:null,props:e,element:"",values:t,template:null}}function X(){return R}function Y(e){return"deferred"===e?"lastDeferredCompleteTime":"lastCompleteTime"}function Z(e){return"deferred"===e?"deferredUpdateTime":"updateTime"}function ee(e,t){for(var n=Z(t),r=c();e;)e[n]=r,e=e.parent}function te(e,t,n){t===n?n.child=e:t.sibling=e,e.parent=n}function ne(e,t){e.hasUncommittedEffect=t,e.root.hasUncommittedEffect=!0}function re(e,t,n,r){var o=e.root,i=e.node,a=e.part,s=e.nodeInstance,u=e.child,d=Z(o.updateType);return t?(t.node=i,t.part=a,t.createdAt=c()):function(e,t){e&&(e.alternate=t);t.alternate=e}(e,t=ae(o,i,a)),e.shouldTearDown=!1,t.nodeInstance=s,t.child=u,t[d]=r[d],te(t,n,r),t}function oe(e,t){return e===t?e.child:e.sibling}function ie(e){var t=e.child;if("sync"!==e.root.updateType)for(var n;t;){n=re(t,t.alternate,n||e,e),t=t.sibling}}function ae(e,t,n){return t&&t.portalContainer&&(n.parentNode=t.portalContainer),{node:t,nodeInstance:null,root:e,parent:null,child:null,sibling:null,part:n,alternate:null,context:null,childFiberError:null,isSvgPart:!1,deferredUpdateTime:0,updateTime:0,processedTime:0,createdAt:c(),shouldTearDown:!1,hasUncommittedEffect:0}}function se(e,t,n,r,o){var i,a,u,c=r.root,d=Z(c.updateType);return n&&!s(n.node)&&!s(e)&&(a=e,u=n.node,G(a)&&G(u)||a.nodeType===B||Array.isArray(a)&&Array.isArray(u)||$(a)&&a.type===u.type||q(a)&&a.template===u.template)?((i=re(n,n.alternate,r,o)).node=e,i.part=t):(i=ae(c,e,t),n&&pe(n)),te(i,r,o),i.processedTime=0,i[d]=o[d],i.context=o.context,i.isSvgPart=o.isSvgPart,i}function ue(e,t,n){return e&&e[n]>=t}function ce(e,t,n){if(e){for(;e&&!ue(e,t,n);)e=e.sibling;return e}}function de(e,t,n,r){var o,i=ce(e.child,n,r);if(i)return i;for(;!(o=ce(e.sibling,n,r));)if((e=e.parent)===t)return e;return o}function fe(e){return e.__brahmosData.fiber}function pe(e){e.shouldTearDown=!0,e.root.tearDownFibers.push(e)}var le=1;function he(e){return function(t){var n=fe(e),r=n.root.updateType;e.context!==t&&ee(n,r)}}function ve(e){var t="cC"+le++,n=function(e){function t(t){e.call(this,t),this.subs=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.shouldComponentUpdate=function(e){return this.props.value!==e.value&&this.subs.forEach((function(t){return t(e.value)})),!0},t.prototype.sub=function(e){var t=this.subs,n=he(e);t.push(n);var r=e.componentWillUnmount;e.componentWillUnmount=function(){t.splice(t.indexOf(n),1),r&&r()}},t.prototype.render=function(){return this.props.children},t}(bt);n.__ccId=t;var r=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children(this.context)},t}(bt),o={id:t,defaultValue:e,Provider:n,Consumer:r};return r.contextType=o,o}function me(){return X().nodeInstance}function ye(e){e.deferredHooks=e.syncHooks.map((function(e,t){return Array.isArray(e)?[].concat(e):e.transitionId?e:Object.assign({},e)}))}function ge(e,t){var n=t.syncHooks,r=t.deferredHooks;return"sync"===e?n:r}function be(e){var t=e.nodeInstance;return ge(e.root.updateType,t)}function Te(e,t,n){return"deferred"!==e||n.deferredHooks.length||ye(n),ge(e,n)[t]}function Se(e,t){if(!e||!t||e.length!==t.length)return!0;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!0;return!1}function _e(e,t,n){void 0===t&&(t=function(e){return!1}),void 0===n&&(n=function(e){return e});var r=X(),o=r.nodeInstance,i=o.pointer,a=be(r),s=a[i];return s&&!t(s)||(s=e(),a[i]=s),o.pointer+=1,n(s)}function Ce(e,t){var n=me(),r=n.pointer;return _e((function(){return"function"==typeof e&&(e=e()),[e,function(e){var o=F(),i=Te(o,r,n),a=i[0],s=t(e,a),u=M(o),c={transitionId:U().transitionId,updater:function(){Te(o,r,n)[0]=t(e,i[0])}};n.__brahmosData[u].push(c),function(e,t,n){Object.is(t,n)||gt(e)}(n,s,a)}]}))}function Ie(e){return Ce(e,(function(e,t){return"function"==typeof e&&(e=e(t)),e}))}function De(e){return _e((function(){return{current:e}}))}function Ne(e,t,n){return Ce(n?function(){return n(t)}:t,(function(t,n){return e(n,t)}))}function ke(e,t){return _e((function(){return{value:e(),dependencies:t}}),(function(e){return Se(t,e.dependencies)}),(function(e){return e.value}))}function we(e,t){return ke((function(){return e}),t)}function xe(e,t){var n=X(),r=n.nodeInstance,o=r.pointer,i=be(n),a=i[o]||{animationFrame:null,cleanEffect:null},s=Object.assign({},a,{isDependenciesChanged:Se(t,a.dependencies),dependencies:t,effect:function(){s.isDependenciesChanged&&e(s)}});i[o]=s,r.pointer+=1}function Ee(e,t){xe((function(t){cancelAnimationFrame(t.animationFrame),t.animationFrame=requestAnimationFrame((function(){setTimeout((function(){t.cleanEffect=e()}))}))}),t)}function Ue(e,t){xe((function(t){t.cleanEffect=e()}),t)}function Pe(e){var t=X(),n=t.nodeInstance,r=t.context,o=e.id,i=e.defaultValue,a=r[o],s=a?a.props.value:i;return Ue((function(){if(a){var e=a.subs,t=he(n);return e.push(t),function(){e.splice(e.indexOf(t),1)}}}),[]),n.context=s,s}function Ae(e){var t=e.timeoutMs,n=me();return _e((function(){var e={transitionId:S(),tryCount:0,isPending:!1,transitionTimeout:null,pendingSuspense:[],transitionState:"initial",clearTimeout:function(){clearTimeout(e.transitionTimeout)},updatePendingState:function(t,r){e.isPending=t,n.__brahmosData.isDirty=!0;var o=function(){gt(n)};"transition"===r?A(e,o):P(r,o)},startTransition:function(r){var o=E(),i=fe(n).root;e.transitionState="start",e.pendingSuspense=[],e.clearTimeout(),A(e,r),i.lastDeferredCompleteTime<i.deferredUpdateTime&&e.updatePendingState(!0,o),e.transitionTimeout=setTimeout((function(){e.transitionState="timedOut",e.updatePendingState(!1,"transition")}),t)}};return e}),void 0,(function(e){return[e.startTransition,e.isPending]}))}function Fe(e,t){for(var n=be(e),r=0,o=n.length;r<o;r++){var i=n[r];i.cleanEffect&&(i.isDependenciesChanged||t)&&i.cleanEffect(),i.clearTimeout&&t&&i.clearTimeout()}}function Me(e){var t;return(t={syncHooks:[],deferredHooks:[],pointer:0,__render:function(t){var n,r,o;n=X(),r=n.nodeInstance,o=n.root.updateType,r.pointer=0,"deferred"===o&&ye(r),O(n).forEach((function(e){return e.updater()}));var i=e(t);return this.__brahmosData.nodes=i,i}}).__brahmosData={pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,isDirty:!1,mounted:!1},t}function Oe(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function je(e){for(var t=e.root;(e=e.parent)&&!(e.nodeInstance instanceof bt&&(e.nodeInstance.componentDidCatch||e.node.type.getDerivedStateFromError));)if(e===t)return null;return e}function Le(e){var t=e.root;e.nodeInstance.__brahmosData.isDirty=!0,t.retryFiber=e}function Re(e){var t,n=e.node,r=e.part,o=e.root,i=e.childFiberError,a=n.type,s=n.nodeType,u=n.props;void 0===u&&(u={});var c="deferred"===o.updateType,d=!0,f=!1,p=s===W;!function(e){var t=e.root,n=e.child,r=e.alternate;n&&n.createdAt>t.lastCompleteTime&&(e.child=r&&r.child)}(e);var l=e.nodeInstance,h=!1;l||(l=p?new a(u):Me(a),e.nodeInstance=l,h=!0);var v=l.__brahmosData,m=function(e){var t=e.node.type,n=e.nodeInstance,r=e.parent,o=e.context,i=t.__ccId,a=r.context||{};if(!i)return a;if(o)return o;var s=Object.create(a);return s[i]=n,s}(e);if(e.context=m,p){var g=v.committedValues,b=v.memoizedValues;h&&(g.state=l.state);var T=g.props,S=g.state;b&&c&&(T=(t=b).props,S=t.state,f=!0),l.props=T,l.state=S;var _=l.shouldComponentUpdate,C=S,I=O(e);I.length&&(C=function(e,t){return t.reduce((function(e,t){var n=t.state;return"function"==typeof n&&(n=n(e)),Object.assign({},e,n)}),e)}(S,I));var D=!h&&o.forcedUpdateWith!==l,N=y(a,"getDerivedStateFromProps",[u,C]),k=i?y(a,"getDerivedStateFromError",[i.error]):void 0;(N||k)&&(C=Object.assign({},C,N,k)),I.forEach((function(e){var t=e.callback;t&&t(C)})),l.isPureReactComponent&&D&&(d=!Oe(C,S)||!Oe(u,T)),_&&d&&D&&(d=_.call(l,u,C));var w=a.contextType;if(w){var x=w.id,E=w.defaultValue,U=m[x],P=U?U.props.value:E;U&&h&&U.sub(l),l.context=P}l.state=C,l.props=u,c&&(v.memoizedValues={state:C,props:u})}else h||Fe(e);if(d){try{!function(e){R=e}(e),se(i&&!a.getDerivedStateFromError?null:l.__render(u),r,e.child,e,e)}catch(t){var A=je(e);if("function"==typeof t.then){var F=_t(e);if(!F)throw new Error("Rendering which got suspended can't be used outside of suspense.");F.nodeInstance.handleSuspender(t,F),Le(F)}else{if(!A||A.childFiberError)throw t;var M=function(e){var t=e.node.type;return{componentStack:"The above error occurred in the <"+(t.displayName||t.name)+"> component:"}}(e);console.error(t),console.error(M.componentStack),A.childFiberError={error:t,errorInfo:M},Le(A)}return}ne(e,2)}else if(f){var j=e.child;j&&j.node===v.nodes||(se(v.nodes,r,j,e,e),ne(e,2))}else ie(e)}var He=/[<>"]/g,Ve=/(^|\s)([^\s"'=<]+)(?=[\s=>])/g;var We=function(e){this.strings=e,this.template=null,this.svgTemplate=null,this.partsMeta=[]};We.prototype.create=function(e){e&&this.svgTemplate||this.template||(this.partsMeta=this.getPartsMeta(),this.createTemplate(e))},We.prototype.getPartsMeta=function(){for(var e,t,n=this.strings,r=[],o=[],i=function(i,a){for(var s=n[i],u=void 0,c=void 0,d=void 0,f=void 0,p=void 0,l=function(){var e=s.substring(f||0,p||s.length);r.push.apply(r,function(e){for(var t,n=[];null!==(t=Ve.exec(e));){t[2]&&n.push(t[2])}return n}(e))};null!==(u=He.exec(s));)"<"!==u[0]||t?'"'===u[0]?t=!t:e&&">"===u[0]&&!t&&(e=!1,p=u.index,void 0===f&&l()):(e=!0,r=[],f=u.index,p=void 0);e&&l(),e?c=!0:d=!0,i<a-1&&o.push({tagAttrs:r,attrIndex:r.length,isAttribute:c,isNode:d})},a=0,s=n.length;a<s;a++)i(a,s);return o},We.prototype.createTemplate=function(e){for(var t=this.partsMeta,n=this.strings,r=document.createElement("template"),o="",i=0,a=n.length-1;i<a;i++){var s=n[i];o=t[i].isNode?o+s+"\x3c!--{{brahmos}}--\x3e":o+s+"data-brahmos-attr"}o+=n[n.length-1],r.innerHTML=e?"<svg>"+o+"</svg>":o,e&&function(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}(r.content.firstChild),this[e?"svgTemplate":"template"]=r};var ze=function(e,t){this.templateResult=e,e.create(t),this.fragment=this.createNode(t),this.parts=this.getParts(),this.domNodes=h(this.fragment.childNodes),this.patched=!1};function Be(e,t,n){return n<=e.lastIndexOf(t)}function qe(e,r,o){for(var i=o,a=o.child,s=function(s,c){var d=e[s],f=r[s],l=d.isAttribute,h=d.isNode,v=void 0;if(l){for(var m=d.domNode,y={},g=void 0;d&&m===d.domNode;)p(r[s],(function(e,r){var o=n[e];Be(d.tagAttrs,o,d.attrIndex)||t[e]?"ref"===e&&(g=r):y[e]=r})),d=e[++s];s--,d=e[s],v={nodeType:B,attributes:y,ref:g}}else h&&(v=f);i=se(v,d,a,i,o),a=a&&a.sibling,u=s},u=0,c=e.length;u<c;u++)s(u)}function $e(e){var t=e.node,n=e.part,r=e.alternate,o=e.parent.context,i=r&&r.node,a=t.values,s=t.nodeType===V,u=e.isSvgPart||s&&"svg"===t.element;e.isSvgPart=u;var c=e.nodeInstance;c||(c=s?function(e,t){var n=e.element,r=e.values,o=t?document.createElementNS("http://www.w3.org/2000/svg",n):document.createElement(n);return d(o),{fragment:o,nodes:[o],parts:[{isAttribute:!0,tagAttrs:[],attrIndex:0,domNode:o},{parentNode:o,isNode:!0}],values:r}}(t,u):new ze(t.template,u),e.nodeInstance=c),s||c.patchParts(n),t!==i?qe(c.parts,a,e):ie(e),ne(e,2),e.context=o}function Ge(e){var t=e.type,n=a(e);return"input"!==n||"radio"!==t&&"checkbox"!==t?"input"===n||"select"===n||"textarea"===n?"value":void 0:"checked"}function Je(e,t,n,r){t=t||{},p(e,(function(e,n){var o=t[e];n!==o&&r(e,n,o)})),p(t,(function(t,o){void 0===e[t]&&r(t,n,o)}))}function Ke(e,t,n,s,u){if(function(e){return 0===e.indexOf("on")}(t)){var c=function(e){return e.replace("on","").toLowerCase()}(t);c=function(e,t){var n=a(t);return r[e]?r[e]:"input"===n&&"change"===e?"input":e}(c,e);var d=function(e,t,n){var r=e.__brahmosData.events,o=r[t];return o?(o.handler=n,o.patched):((o=r[t]={handler:n,patched:null}).patched=function(e){var t=this;o.handler&&L((function(){o.handler.call(t,e)}))},o.patched)}(e,t,n);s&&!n?e.removeEventListener(c,d):!s&&n&&e.addEventListener(c,d)}else if("style"===t){var f=e.style;Je(n,s,"",(function(e,t){"-"===e[0]?f.setProperty(e,t):f[e]="number"==typeof t&&!1===o.test(e)?t+"px":t}))}else if("dangerouslySetInnerHTML"===t){var p=s&&s.__html,l=n&&n.__html;l!==p&&(e.innerHTML=null==l?"":l)}else if(t in e&&!u){var h=Ge(e);h?function(e,t,n,r){"checked"===e?"checked"===n?(t.checked=r,t.checkedProp=r):"defaultChecked"===n&&void 0===t.checkedProp?t.checked=r:t[n]=r:"value"===e&&("value"===n?(t.value=r,t.valueProp=r):"defaultValue"===n&&void 0===t.valueProp?t.value=r:t[n]=r)}(h,e,t,n):e[t]=null==n?"":n}else{var v=t.replace(/^xlink:?/,""),m=null==n||!1===n;t!==v?(v=v.toLowerCase(),m?e.removeAttributeNS(i,v):e.setAttributeNS(i,v,n)):m?e.removeAttribute(t):e.setAttribute(t,n)}}function Qe(e,t,n,r){Je(t,n,null,(function(t,n,o){Ke(e,t,n,o,r)})),function(e){var t=Ge(e);if(t){var n=e[t+"Prop"],r=e[t];void 0!==n&&n!==r&&(e[t]=n)}}(e)}function Xe(e){function t(t){return e(f(t,!1),t.ref)}return t.__isForwardRef=!0,t}function Ye(){return{current:null}}function Ze(e,t){var n=typeof e;"function"===n?e(t):"object"===n&&(e.current=t)}function et(e,t){var n=t.domNodes;e.__brahmosLastArrayDom=n[n.length-1]}function tt(e){var t=e.previousSibling;return e.isArrayNode&&(t=0===e.nodeIndex?t:e.parentNode.__brahmosLastArrayDom),t}function nt(e,t){var n=e.part;if(n.isArrayNode){var r=n.nodeIndex,o=n.parentNode,i=t.part.nodeIndex,a=function(e){for(;e.node&&!q(e.node);)e=e.child;return e}(e),s=a.nodeInstance,u=a!==e&&a.hasUncommittedEffect;if(s&&!u){if(r!==i){var c=s.domNodes,d=tt(n),f=m(o,d),p=c[0];p&&p.previousSibling!==d&&p!==f&&v(o,f,c)}et(o,s)}}}function rt(e){var t=e.node,n=e.nodeInstance,r=e.root,o=e.childFiberError,i=r.updateType,a=t.nodeType,s=t.ref,u=n.__brahmosData;if(a===W){var c=n.props,d=n.state,f=u.committedValues,p=u.lastSnapshot,l=f.props,h=f.state;l?y(n,"componentDidUpdate",[l,h,p]):y(n,"componentDidMount"),o&&(y(n,"componentDidCatch",[o.error,o.errorInfo]),e.childFiberError=null),s&&Ze(s,n),f.props=c,f.state=d,u.memoizedValues=null}else if(function(e){for(var t=be(e),n=0,r=t.length;n<r;n++){var o=t[n];o.effect&&o.effect()}}(e),"deferred"===i){var v=n.syncHooks,m=n.deferredHooks;n.deferredHooks=v,n.syncHooks=m}u.mounted=!0,u.fiber=e}function ot(e){e.tearDownFibers=[],e.postCommitEffects=[],e.hasUncommittedEffect=!1,e.resetRenderCallbacks()}function it(e){var t=e.currentTransition,n=e.pendingTransitions,r=n.indexOf(t);-1!==r&&n.splice(r,1)}function at(e){var t=e.node,n=e.alternate,r=t&&$(t);r&&n&&nt(e,n),2===e.hasUncommittedEffect&&(G(t)?function(e){var t=e.part,n=e.node,r=e.alternate,o=t.parentNode,i=m(o,t.previousSibling);r?i.nodeValue=n:v(o,i,n)}(e):q(t)?function(e){var t=e.part,n=e.nodeInstance,r=e.alternate,o=t.parentNode;if(r)nt(e,r);else{var i=m(o,tt(t));n.domNodes=v(o,i,n.fragment),et(o,n)}}(e):r?function(e){var t=e.node,n=e.nodeInstance,r=e.root,o=r.updateType,i=t.nodeType,a=n.__brahmosData;if(i===W){var s=a.committedValues,u=s.props,c=s.state;a.lastSnapshot=y(n,"getSnapshotBeforeUpdate",[u,c])}var d=N(e).transitionId,f=M(o);a[f]=a[f].filter((function(e){return e.transitionId!==d})),a.isDirty=!1,r.postCommitEffects.push(e)}(e):t.nodeType===B&&function(e){var t=e.part,n=e.node,r=e.alternate,o=e.isSvgPart,i=t.domNode,a=n.attributes,s=n.ref;Qe(i,a,r&&r.node.attributes,o),s&&Ze(s,i)}(e),e.hasUncommittedEffect=!1),n&&function(e){e.node=null,e.nodeInstance=null,e.child=null,e.sibling=null}(n)}function st(e,t,n,r){var o=(e.part.parentNode===t.parentNode||!n)&&r,i=e.node;i&&i.portalContainer&&(o=!0),ut(e,o)}function ut(e,t){var n=e.node,r=e.part,o=e.nodeInstance;if(J(n)){var i=q(n),a=e.child;if(a)for(st(a,r,i,t);a.sibling;)st(a=a.sibling,r,i,t);if(G(n)&&t){l(m(r.parentNode,r.previousSibling))}else{var s=n.ref;if(s&&Ze(s,null),o)if(i){var u=o.domNodes;t&&l(u)}else $(n)&&o.__brahmosData.mounted&&(n.nodeType===W?y(o,"componentWillUnmount"):Fe(e,!0))}}}function ct(e){e.tearDownFibers.forEach((function(e){e.shouldTearDown&&ut(e,!0)})),e.tearDownFibers=[]}ze.prototype.createNode=function(e){var t=this.templateResult,n=t.template,r=t.svgTemplate,o=e?r:n;return document.importNode(o.content,!0)},ze.prototype.createWalker=function(e){return document.createTreeWalker(e,129,null,!1)},ze.prototype.isBrahmosCommentNode=function(e){return e&&8===e.nodeType&&"{{brahmos}}"===e.textContent},ze.prototype.getParts=function(){for(var e=this.fragment,t=this.templateResult,n=this.isBrahmosCommentNode,r=t.partsMeta,o=this.createWalker(e),i=0,a=r[i],s=[],u=[],c=function(){i++,a=r[i]};o.nextNode();){var f=o.currentNode,p=f.nodeType,h=f.parentNode;if(1===p&&f.hasAttribute("data-brahmos-attr")){f.removeAttribute("data-brahmos-attr");for(var v=a.tagAttrs;a&&a.isAttribute&&a.tagAttrs===v;)s.push(Object.assign({},a,{domNode:f})),c();d(f)}else if(n(f)){var m=f.previousSibling;n(m)&&(m=g(f)),s.push(Object.assign({},a,{parentNode:h,previousSibling:m})),c(),u.push(f)}}return l(u),s},ze.prototype.patchParts=function(e){var t=this.parts,n=e.parentNode,r=e.previousSibling;if(!this.patched){for(var o=0,i=t.length;o<i;o++){var a=t[o];a.isNode&&a.parentNode instanceof DocumentFragment&&(a.parentNode=n,a.previousSibling=a.previousSibling||r)}this.patched=!0}};var dt;function ft(e){return dt+e-performance.now()}!function e(){requestAnimationFrame((function(t){dt=t,e()}))}();var pt=function(){return 1};function lt(e){var t=e.node,n=e.alternate;if(J(t)){var r=function(e){var t=e.node,n=e.nodeInstance;return!(!$(t)||!n)&&(!!O(e).length||n.__brahmosData.isDirty)}(e);!e.processedTime||r?(G(t)?function(e){var t=e.node,n=e.alternate;t!==(n&&n.node)&&ne(e,2)}(e):Array.isArray(t)?function(e){for(var t=e.node,n=e.part,r=e,o=n.parentNode,i=n.previousSibling,a=new Map,s=0,u=e;u=oe(u,e);){var c=K(u.node,s);a.set(c,u),s++}e.child=null,t.forEach((function(t,n){var s=K(t,n),u=a.get(s);u&&a.delete(s);var c=r;(r=se(t,{parentNode:o,previousSibling:i,a:void 0,isArrayNode:!0,nodeIndex:n},u,c,e)).sibling=null,u&&u.part.nodeIndex!==n&&(ne(r,1),0!==n&&ne(c,1))})),a.forEach((function(e){pe(e)})),ne(e,2)}(e):q(t)?$e(e):$(t)?Re(e):t.nodeType===B&&ne(e,2),e.processedTime=c()):ie(e)}else n&&pe(n)}function ht(e){var t=e.updateType,n=e.current,r=Y(t);ct(e);var o=function(e){for(var t=e.updateType,n=e.wip,r=e.current,o=Z(t),i=e[Y(t)],a=[],s="sync"===t?r:n;s;){var u=s.createdAt,c=s.node,d=s.child,f=s.hasUncommittedEffect,p=s[o],l=u>i,h=f||p>i;if(f&&a.push(s),l&&(d&&d.parent!==s&&(d.parent=s),c&&$(c)&&(s.nodeInstance.__brahmosData.fiber=s)),d&&h)s=d;else{for(;s!==e&&!s.sibling;)s=s.parent;s=s.sibling}}return a}(e);e[r]=e.lastCompleteTime=c(),"deferred"===t&&(e.current=e.wip,e.wip=n),function(e,t){for(var n=0,r=t.length;n<r;n++)at(t[n]);for(var o=e.postCommitEffects,i=o.length-1;i>=0;i--)rt(o[i]);it(e),ot(e),e.requestIdleHandle=null,e.forcedUpdateWith=null}(e,o)}function vt(e,t){var n=e.root,r=n.updateType,o=n.currentTransition,i=Y(r),a=Z(r),s=n[i],u=!function(e){return"immediate_action"===e.updateSource}(n);!function(e,t,n){var r=e.scheduleId;if(r&&clearTimeout(r),t){var o=ft(16),i=o>2?0:o+1;e.scheduleId=setTimeout((function(){var t=e.currentTransition,r=t?t.tryCount:0,o=t===C?300:600,i=Math.min(30,5+r);n(r>o?pt:function(){return ft(i)})}),i)}else n(pt)}(n,u,(function(r){for(;e!==t;){if(!(r()>0))return void vt(e,t);lt(e);var i=n.retryFiber;i?(e=i,t=n,n.retryFiber=null):e=de(e,t,s,a)}var u,c;n.callRenderCallbacks(),o&&("timedOut"!==(c=(u=o).transitionState)&&"suspended"!==c&&(u.isPending?(u.clearTimeout(),u.updatePendingState(!1,"transition")):u.transitionState="completed"),o.tryCount=0,!n.hasUncommittedEffect&&D(o)&&it(n)),function(e){return"transition"!==e.updateSource||e.lastCompleteTime>=e.updateTime&&e.hasUncommittedEffect&&D(e.currentTransition)}(n)&&ht(n),k(n)&&P("transition",(function(){n.updateSource="transition",mt(n)}))}))}function mt(e){var t=k(e);t&&(e.updateType="deferred",ot(e),e.currentTransition=t,t.tryCount+=1,e.wip=re(e.current,e.wip,e,e),vt(e.wip,e))}function yt(e){var t=e.root,n=e.parent;t.updateType="sync",t.currentTransition=null,ot(t),vt(e,n)}function gt(e){var t=fe(e),n=t.root,r=E(),o=U(),i=F();if(ee(t,i),"transition"===r){var a=n.pendingTransitions,s=o===C?"unshift":"push";a.includes(o)||a[s](o)}n.batchUpdates[r]||(n.batchUpdates[r]=T((function(){if(n.batchUpdates[r]=null,n.updateSource=r,n.lastCompleteTime<n.updateTime){var e="sync"===n.updateType&&n.requestIdleHandle;yt("immediate_action"===r&&!e?t:n.current)}else mt(n)})))}var bt=function(e){this.props=e,this.state=void 0,this.__brahmosData={lastSnapshot:null,pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,mounted:!1,committedValues:{},memoizedValues:null,isDirty:!1},this.context=void 0};bt.prototype.setState=function(e,t,n){var r=F(),o={state:e,transitionId:U().transitionId,callback:t},i=M(r);this.__brahmosData[i].push(o),gt(this)},bt.prototype.forceUpdate=function(e){var t=this.__brahmosData.fiber;t&&(t.root.forcedUpdateWith=this,this.__brahmosData.isDirty=!0,gt(this),e&&e(this.state))},bt.prototype.__render=function(){var e=this.render();return this.__brahmosData.nodes=e,e};var Tt=function(e){function t(t){e.call(this,t),this.isPureReactComponent=!0}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(bt);function St(e,t,n){if("string"==typeof e)return function(e,t,n){var r=Q(null,[t,n],"");return r.element=e,r.nodeType=V,r}(e,t,n);var r=Object.assign({},e.defaultProps,f(t,e.__isForwardRef),{children:n});e.__loadLazyComponent&&e.__loadLazyComponent();var o=t.key;void 0===o&&(o="");var i=t.ref,a=function(e){return e.prototype instanceof bt}(e),s=Q(r,null,""+o);return s.nodeType=a?W:z,s.type=e,s.ref=a?i:null,s}function _t(e,t){for(var n=e.root,r=e.nodeInstance;!(r instanceof xt||t&&r instanceof wt);){if((e=e.parent)===n)return null;r=e.nodeInstance}return e}function Ct(e){var t=e.parentSuspenseManager;return t&&t.isSuspenseList?t:null}function It(e,t){var n=e.nodeInstance;if(!n)return null;var r=n.suspenseManagers,o=t.transitionId,i=r[o];return i||(i=r[o]=new Nt(e,t)),i}function Dt(e){e.__brahmosData.isDirty=!0}var Nt=function(e,t){var n=e.nodeInstance;this.fiber=e,this.component=n,this.transition=t,this.childManagers=[],this.suspender=null,this.isSuspenseList=n instanceof wt;var r=_t(e.parent,!0);this.parentSuspenseManager=r&&It(r,t),this.rootSuspenseManager=null,this.recordChildSuspense(),this.handleSuspense=this.handleSuspense.bind(this)};function kt(e){var t=N(X(),C);return"resolved"!==t.transitionState||t.pendingSuspense.includes(e)||(t=C),t}Nt.prototype.recordChildSuspense=function(){var e=this.parentSuspenseManager;e?(e.childManagers.push(this),this.rootSuspenseManager=e.rootSuspenseManager):this.rootSuspenseManager=this},Nt.prototype.addRootToProcess=function(){var e=this.rootSuspenseManager;X().root.afterRender(e.handleSuspense)},Nt.prototype.suspend=function(e){this.suspender=e,this.addRootToProcess()},Nt.prototype.handleSuspense=function(){var e=this.component,t=this.suspender;return e instanceof wt?this.handleSuspenseList():Promise.resolve(t).then(this.resolve.bind(this,t))},Nt.prototype.isUnresolved=function(){return this.isSuspenseList?this.childManagers.some((function(e){return e.isUnresolved()})):this.suspender},Nt.prototype.shouldShowFallback=function(){var e=Ct(this);if(!e)return!0;var t=e.component,n=e.childManagers,r=t.props.tail;if(Ct(e)&&!e.shouldShowFallback())return!1;if("collapsed"===r)for(var o=0,i=n.length;o<i;o++){var a=n[o];if("collapsed"===r&&a.isUnresolved())return a===this}return"hidden"!==r},Nt.prototype.resolve=function(e){var t=this,n=this.component,r=this.transition,o=this.suspender,i=this.childManagers,a=r.pendingSuspense||[];if(e===o)if(o){this.suspender=null,Dt(this.component);var s="timedOut"===r.transitionState,u=a.filter((function(e){return e.suspenseManagers[r.transitionId].suspender})).length;s||u||(r.transitionState="resolved");var c=function(){var e=n;fe(n)||(e=t.fiber.root.wip.nodeInstance),gt(e)};setTimeout((function(){s||!a.includes(n)?j(c):A(r,c)}),Date.now()%100)}else i.forEach((function(e){e.handleSuspense()}))},Nt.prototype.getChildrenSuspenders=function(){var e=[];return this.childManagers.forEach((function(t){t.isSuspenseList?e=e.concat(t.getChildrenSuspenders()):t.suspender&&e.push(t.suspender)})),e},Nt.prototype.handleSuspenseList=function(){var e=this.component,t=this.childManagers,n=e.props,r=n.revealOrder;void 0===r&&(r="together");var o=n.tail,i=function(e,t){return e.then((function(){return"forwards"===r&&"collapsed"===o&&function(e){var t=fe(e.component);e.isUnresolved()&&t&&(Dt(e.component),ee(t,"deferred"))}(t),t.handleSuspense()}))},a=Promise.all(this.getChildrenSuspenders());if("together"===r)a.then((function(){t.forEach((function(e){return e.handleSuspense()}))}));else if("forwards"===r)for(var s=Promise.resolve(),u=0,c=t.length;u<c;u++)s=i(s,t[u]);else if("backwards"===r)for(var d=Promise.resolve(),f=t.length-1;f>=0;f--)d=i(d,t[f]);return a};var wt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children},t}(bt),xt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.handleSuspender=function(e,t){var n=kt(this),r=It(t,n);D(n)||(n.pendingSuspense.includes(this)||n.pendingSuspense.push(this),n.transitionState="suspended"),r.suspend(e)},t.prototype.render=function(){var e=kt(this),t=It(X(),e),n=!t.suspender,r=this.props,o=r.fallback,i=r.children;return n?i:t.shouldShowFallback()?o:null},t}(bt),Et=function(e){var t,n=Xe((function(e,n){return St(t.read().default,Object.assign({},e,{ref:n}),e.children)}));return n.__loadLazyComponent=function(){var n,r,o,i;t||(n=e(),o="pending",i=n.then((function(e){o="success",r=e}),(function(e){o="error",r=e})),t={read:function(){if("pending"===o)throw i;if("error"===o)throw r;if("success"===o)return r}})},n};function Ut(e){return e.children}function Pt(e,t){var n,r,o=t.__rootFiber;if(o)(n=o.current).node.props.children=e,n.processedTime=0,ee(n);else{var i=St(Ut,{},e);r=[],(n=ae(o={updateType:"sync",updateSource:"js",scheduleId:0,domNode:t,forcedUpdateWith:null,current:null,wip:null,child:null,retryFiber:null,currentTransition:null,hasUncommittedEffect:!1,pendingTransitions:[],tearDownFibers:[],postCommitEffects:[],batchUpdates:{},lastDeferredCompleteTime:0,lastCompleteTime:0,deferredUpdateTime:0,updateTime:0,afterRender:function(e){r.includes(e)||r.push(e)},callRenderCallbacks:function(){for(var e=0,t=r.length;e<t;e++)r[e]()},resetRenderCallbacks:function(){r=[]}},i,{parentNode:t,isNode:!0})).parent=o,o.current=n,t.__rootFiber=o}L((function(){o.updateSource=E(),yt(n)}))}var At=new WeakMap;function Ft(e,t){var n=Q(null,t,"");return n.nodeType=H,n.template=e,n}function Mt(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];var r=At.get(e);return r||(r=new We(e),At.set(e,r)),Ft(r,t)}function Ot(e,t){return e&&(e.portalContainer=t),e}function jt(e){var t=e.__rootFiber;return!!t&&(pe(t.current),ct(t),e.__rootFiber=void 0,!0)}var Lt={createElement:St,render:Pt,Component:bt,PureComponent:Tt,html:Mt,useState:Ie,useEffect:Ee,useRef:De,useReducer:Ne,useMemo:ke,useCallback:we,useLayoutEffect:Ue,useContext:Pe,useTransition:Ae,createContext:ve,forwardRef:Xe,createRef:Ye,createPortal:Ot,unmountComponentAtNode:jt,Suspense:xt,SuspenseList:wt,lazy:Et,unstable_deferredUpdates:j,unstable_syncUpdates:L};e.Component=bt,e.PureComponent=Tt,e.Suspense=xt,e.SuspenseList=wt,e.createContext=ve,e.createElement=St,e.createPortal=Ot,e.createRef=Ye,e.default=Lt,e.forwardRef=Xe,e.html=Mt,e.lazy=Et,e.render=Pt,e.unmountComponentAtNode=jt,e.unstable_deferredUpdates=j,e.unstable_syncUpdates=L,e.useCallback=we,e.useContext=Pe,e.useEffect=Ee,e.useLayoutEffect=Ue,e.useMemo=ke,e.useReducer=Ne,e.useRef=De,e.useState=Ie,e.useTransition=Ae,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Brahmos={})}(this,(function(e){"use strict";var t={key:1,ref:1},n={className:"class",htmlFor:"for",acceptCharset:"accept-charset",httpEquiv:"http-equiv"},r={doubleclick:"dblclick"},o=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,i="http://www.w3.org/1999/xlink";function a(e){return e.nodeName.toLowerCase()}function s(e){return null==e}var u=0;function c(){return u++}function d(e){e.__brahmosData={events:{}}}function f(e,t){var n,r={};for(n in e)"key"===n||"ref"===n&&!t||(r[n]=e[n]);return r}function p(e,t){for(var n=Object.keys(e),r=0,o=n.length;r<o;r++){var i=n[r];t(i,e[i])}}function l(e){Array.isArray(e)||(e=[e]);for(var t=e.length-1;t>=0;t--){var n=e[t];n.parentNode.removeChild(n)}}function h(e){return Array.prototype.slice.call(e)}function v(e,t,n){t=void 0===t?null:t;var r=function(e){var t=e instanceof NodeList;if(e instanceof Node)return e;if(Array.isArray(e)||t){for(var n=document.createDocumentFragment(),r=0;e[r];)n.appendChild(e[r]),t||(r+=1);return n}return document.createTextNode(e)}(n),o=r instanceof DocumentFragment?h(r.childNodes):r;return e.insertBefore(r,t),o}function m(e,t){return t?t.nextSibling:e.firstChild}function y(e,t,n){if(e[t])return e[t].apply(e,n)}function g(e){var t=e.parentNode,n=document.createTextNode("");return t.insertBefore(n,e),n}var b=Promise.resolve();function _(e){return b.then(e)}function T(){return c()+"-"+1e6*Math.random()}var S={transitionId:"",tryCount:0,transitionState:"timedOut"},C={transitionId:T(),tryCount:0,transitionState:"timedOut"};function I(e){var t=e.transitionState;return"start"===t||"resolved"===t||"timedOut"===t}function D(e){var t=e.transitionState;return"completed"===t||"timedOut"===t}function N(e,t){return t=t||S,e.root.currentTransition||t}function k(e){return e.pendingTransitions.find(I)}var w="js",x=S;function E(){return w}function U(){return x}function P(e,t){w=e,t(),_((function(){w="js"}))}function A(e,t){var n=x;x=e,P("transition",t),x=n}function F(){return"transition"===w?"deferred":"sync"}function M(e){return"deferred"===e?"pendingDeferredUpdates":"pendingSyncUpdates"}function O(e){var t=e.root.updateType,n=e.nodeInstance.__brahmosData,r=N(e).transitionId;return n[M(t)].filter((function(e){return e.transitionId===r}))}function j(e){A(C,e)}function L(e){P("immediate_action",e)}var R,H=Symbol("tag"),V=Symbol("tag-element"),W=Symbol("class-component"),z=Symbol("functional-component"),B=Symbol("attribute");function q(e){var t=e.nodeType;return t===H||t===V}function $(e){var t=e.nodeType;return t===W||t===z}function G(e){return"string"==typeof e||"number"==typeof e}function J(e){return!(s(e)||"boolean"==typeof e)}function K(e,t){var n=e&&e.key;if(""===n&&e&&q(e)){for(var r=e.values,o=0,i=r.length;o<i;o++){var a=r[o];if(void 0!==a.key){n=""+a.key;break}}e.key=void 0===n?"":""+n}return""===n?""+t:n}function Q(e,t,n){return{nodeType:null,key:n,added:!1,ref:null,portalContainer:null,type:null,props:e,element:"",values:t,template:null}}function X(){return R}function Y(e){return"deferred"===e?"lastDeferredCompleteTime":"lastCompleteTime"}function Z(e){return"deferred"===e?"deferredUpdateTime":"updateTime"}function ee(e,t){for(var n=Z(t),r=c();e;)e[n]=r,e=e.parent}function te(e,t,n){t===n?n.child=e:t.sibling=e,e.parent=n}function ne(e,t){e.hasUncommittedEffect=t,e.root.hasUncommittedEffect=!0}function re(e,t,n,r){var o=e.root,i=e.node,a=e.part,s=e.nodeInstance,u=e.child,d=Z(o.updateType);return t?(t.node=i,t.part=a,t.createdAt=c()):function(e,t){e&&(e.alternate=t);t.alternate=e}(e,t=ae(o,i,a)),e.shouldTearDown=!1,t.nodeInstance=s,t.child=u,t[d]=r[d],te(t,n,r),t}function oe(e,t){return e===t?e.child:e.sibling}function ie(e){var t=e.child;if("sync"!==e.root.updateType)for(var n;t;){n=re(t,t.alternate,n||e,e),t=t.sibling}}function ae(e,t,n){return t&&t.portalContainer&&(n.parentNode=t.portalContainer),{node:t,nodeInstance:null,root:e,parent:null,child:null,sibling:null,part:n,alternate:null,context:null,childFiberError:null,isSvgPart:!1,deferredUpdateTime:0,updateTime:0,processedTime:0,createdAt:c(),shouldTearDown:!1,hasUncommittedEffect:0}}function se(e,t,n,r,o){var i,a,u,c=r.root,d=Z(c.updateType);return n&&!s(n.node)&&!s(e)&&(a=e,u=n.node,G(a)&&G(u)||a.nodeType===B||Array.isArray(a)&&Array.isArray(u)||$(a)&&a.type===u.type||q(a)&&a.template===u.template)?((i=re(n,n.alternate,r,o)).node=e,i.part=t):(i=ae(c,e,t),n&&pe(n)),te(i,r,o),i.processedTime=0,i[d]=o[d],i.context=o.context,i.isSvgPart=o.isSvgPart,i}function ue(e,t,n){return e&&e[n]>=t}function ce(e,t,n){if(e){for(;e&&!ue(e,t,n);)e=e.sibling;return e}}function de(e,t,n,r){var o,i=ce(e.child,n,r);if(i)return i;for(;!(o=ce(e.sibling,n,r));)if((e=e.parent)===t)return e;return o}function fe(e){return e.__brahmosData.fiber}function pe(e){e.shouldTearDown=!0,e.root.tearDownFibers.push(e)}var le=1;function he(e){return function(t){var n=fe(e),r=n.root.updateType;e.context!==t&&ee(n,r)}}function ve(e){var t="cC"+le++,n=function(e){function t(t){e.call(this,t),this.subs=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.shouldComponentUpdate=function(e){return this.props.value!==e.value&&this.subs.forEach((function(t){return t(e.value)})),!0},t.prototype.sub=function(e){var t=this.subs,n=he(e);t.push(n);var r=e.componentWillUnmount;e.componentWillUnmount=function(){t.splice(t.indexOf(n),1),r&&r()}},t.prototype.render=function(){return this.props.children},t}(bt);n.__ccId=t;var r=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children(this.context)},t}(bt),o={id:t,defaultValue:e,Provider:n,Consumer:r};return r.contextType=o,o}function me(){return X().nodeInstance}function ye(e){e.deferredHooks=e.syncHooks.map((function(e,t){return Array.isArray(e)?[].concat(e):e.transitionId?e:Object.assign({},e)}))}function ge(e,t){var n=t.syncHooks,r=t.deferredHooks;return"sync"===e?n:r}function be(e){var t=e.nodeInstance;return ge(e.root.updateType,t)}function _e(e,t,n){return"deferred"!==e||n.deferredHooks.length||ye(n),ge(e,n)[t]}function Te(e,t){if(!e||!t||e.length!==t.length)return!0;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!0;return!1}function Se(e,t,n){void 0===t&&(t=function(e){return!1}),void 0===n&&(n=function(e){return e});var r=X(),o=r.nodeInstance,i=o.pointer,a=be(r),s=a[i];return s&&!t(s)||(s=e(),a[i]=s),o.pointer+=1,n(s)}function Ce(e,t){var n=me(),r=n.pointer;return Se((function(){return"function"==typeof e&&(e=e()),[e,function(e){var o=F(),i=_e(o,r,n),a=i[0],s=t(e,a),u=M(o),c={transitionId:U().transitionId,updater:function(){_e(o,r,n)[0]=t(e,i[0])}};n.__brahmosData[u].push(c),function(e,t,n){Object.is(t,n)||gt(e)}(n,s,a)}]}))}function Ie(e){return Ce(e,(function(e,t){return"function"==typeof e&&(e=e(t)),e}))}function De(e){return Se((function(){return{current:e}}))}function Ne(e,t,n){return Ce(n?function(){return n(t)}:t,(function(t,n){return e(n,t)}))}function ke(e,t){return Se((function(){return{value:e(),dependencies:t}}),(function(e){return Te(t,e.dependencies)}),(function(e){return e.value}))}function we(e,t){return ke((function(){return e}),t)}function xe(e,t){var n=X(),r=n.nodeInstance,o=r.pointer,i=be(n),a=i[o]||{animationFrame:null,cleanEffect:null},s=Object.assign({},a,{isDependenciesChanged:Te(t,a.dependencies),dependencies:t,effect:function(){s.isDependenciesChanged&&e(s)}});i[o]=s,r.pointer+=1}function Ee(e,t){xe((function(t){cancelAnimationFrame(t.animationFrame),t.animationFrame=requestAnimationFrame((function(){setTimeout((function(){t.cleanEffect=e()}))}))}),t)}function Ue(e,t){xe((function(t){t.cleanEffect=e()}),t)}function Pe(e){var t=X(),n=t.nodeInstance,r=t.context,o=e.id,i=e.defaultValue,a=r[o],s=a?a.props.value:i;return Ue((function(){if(a){var e=a.subs,t=he(n);return e.push(t),function(){e.splice(e.indexOf(t),1)}}}),[]),n.context=s,s}function Ae(e){e.timeoutMs;var t=me();return Se((function(){var e={transitionId:T(),tryCount:0,isPending:!1,transitionTimeout:null,pendingSuspense:[],transitionState:"initial",clearTimeout:function(){clearTimeout(e.transitionTimeout)},updatePendingState:function(n,r){e.isPending=n,t.__brahmosData.isDirty=!0;var o=function(){gt(t)};"transition"===r?A(e,o):P(r,o)},startTransition:function(n){var r=E(),o=fe(t).root;e.transitionState="start",e.pendingSuspense=[],e.clearTimeout(),A(e,n),o.lastDeferredCompleteTime<o.deferredUpdateTime&&e.updatePendingState(!0,r)}};return e}),void 0,(function(e){return[e.startTransition,e.isPending]}))}function Fe(e,t){for(var n=be(e),r=0,o=n.length;r<o;r++){var i=n[r];i.cleanEffect&&(i.isDependenciesChanged||t)&&i.cleanEffect(),i.clearTimeout&&t&&i.clearTimeout()}}function Me(e){var t;return(t={syncHooks:[],deferredHooks:[],pointer:0,__render:function(t){var n,r,o;n=X(),r=n.nodeInstance,o=n.root.updateType,r.pointer=0,"deferred"===o&&ye(r),O(n).forEach((function(e){return e.updater()}));var i=e(t);return this.__brahmosData.nodes=i,i}}).__brahmosData={pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,isDirty:!1,mounted:!1},t}function Oe(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function je(e){for(var t=e.root;(e=e.parent)&&!(e.nodeInstance instanceof bt&&(e.nodeInstance.componentDidCatch||e.node.type.getDerivedStateFromError));)if(e===t)return null;return e}function Le(e){var t=e.root;e.nodeInstance.__brahmosData.isDirty=!0,t.retryFiber=e}function Re(e){var t,n=e.node,r=e.part,o=e.root,i=e.childFiberError,a=n.type,s=n.nodeType,u=n.props;void 0===u&&(u={});var c="deferred"===o.updateType,d=!0,f=!1,p=s===W;!function(e){var t=e.root,n=e.child,r=e.alternate;n&&n.createdAt>t.lastCompleteTime&&(e.child=r&&r.child)}(e);var l=e.nodeInstance,h=!1;l||(l=p?new a(u):Me(a),e.nodeInstance=l,h=!0);var v=l.__brahmosData,m=function(e){var t=e.node.type,n=e.nodeInstance,r=e.parent,o=e.context,i=t.__ccId,a=r.context||{};if(!i)return a;if(o)return o;var s=Object.create(a);return s[i]=n,s}(e);if(e.context=m,p){var g=v.committedValues,b=v.memoizedValues;h&&(g.state=l.state);var _=g.props,T=g.state;b&&c&&(_=(t=b).props,T=t.state,f=!0),l.props=_,l.state=T;var S=l.shouldComponentUpdate,C=T,I=O(e);I.length&&(C=function(e,t){return t.reduce((function(e,t){var n=t.state;return"function"==typeof n&&(n=n(e)),Object.assign({},e,n)}),e)}(T,I));var D=!h&&o.forcedUpdateWith!==l,N=y(a,"getDerivedStateFromProps",[u,C]),k=i?y(a,"getDerivedStateFromError",[i.error]):void 0;(N||k)&&(C=Object.assign({},C,N,k)),I.forEach((function(e){var t=e.callback;t&&t(C)})),l.isPureReactComponent&&D&&(d=!Oe(C,T)||!Oe(u,_)),S&&d&&D&&(d=S.call(l,u,C));var w=a.contextType;if(w){var x=w.id,E=w.defaultValue,U=m[x],P=U?U.props.value:E;U&&h&&U.sub(l),l.context=P}l.state=C,l.props=u,c&&(v.memoizedValues={state:C,props:u})}else h||Fe(e);if(d){try{!function(e){R=e}(e),se(i&&!a.getDerivedStateFromError?null:l.__render(u),r,e.child,e,e)}catch(t){var A=je(e);if("function"==typeof t.then){var F=St(e);if(!F)throw new Error("Rendering which got suspended can't be used outside of suspense.");F.nodeInstance.handleSuspender(t,F),Le(F)}else{if(!A||A.childFiberError)throw t;var M=function(e){var t=e.node.type;return{componentStack:"The above error occurred in the <"+(t.displayName||t.name)+"> component:"}}(e);console.error(t),console.error(M.componentStack),A.childFiberError={error:t,errorInfo:M},Le(A)}return}ne(e,2)}else if(f){var j=e.child;j&&j.node===v.nodes||(se(v.nodes,r,j,e,e),ne(e,2))}else ie(e)}var He=/[<>"]/g,Ve=/(^|\s)([^\s"'=<]+)(?=[\s=>])/g;var We=function(e){this.strings=e,this.template=null,this.svgTemplate=null,this.partsMeta=[]};We.prototype.create=function(e){e&&this.svgTemplate||this.template||(this.partsMeta=this.getPartsMeta(),this.createTemplate(e))},We.prototype.getPartsMeta=function(){for(var e,t,n=this.strings,r=[],o=[],i=function(i,a){for(var s=n[i],u=void 0,c=void 0,d=void 0,f=void 0,p=void 0,l=function(){var e=s.substring(f||0,p||s.length);r.push.apply(r,function(e){for(var t,n=[];null!==(t=Ve.exec(e));){t[2]&&n.push(t[2])}return n}(e))};null!==(u=He.exec(s));)"<"!==u[0]||t?'"'===u[0]?t=!t:e&&">"===u[0]&&!t&&(e=!1,p=u.index,void 0===f&&l()):(e=!0,r=[],f=u.index,p=void 0);e&&l(),e?c=!0:d=!0,i<a-1&&o.push({tagAttrs:r,attrIndex:r.length,isAttribute:c,isNode:d})},a=0,s=n.length;a<s;a++)i(a,s);return o},We.prototype.createTemplate=function(e){for(var t=this.partsMeta,n=this.strings,r=document.createElement("template"),o="",i=0,a=n.length-1;i<a;i++){var s=n[i];o=t[i].isNode?o+s+"\x3c!--{{brahmos}}--\x3e":o+s+"data-brahmos-attr"}o+=n[n.length-1],r.innerHTML=e?"<svg>"+o+"</svg>":o,e&&function(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}(r.content.firstChild),this[e?"svgTemplate":"template"]=r};var ze=function(e,t){this.templateResult=e,e.create(t),this.fragment=this.createNode(t),this.parts=this.getParts(),this.domNodes=h(this.fragment.childNodes),this.patched=!1};function Be(e,t,n){return n<=e.lastIndexOf(t)}function qe(e,r,o){for(var i=o,a=o.child,s=function(s,c){var d=e[s],f=r[s],l=d.isAttribute,h=d.isNode,v=void 0;if(l){for(var m=d.domNode,y={},g=void 0;d&&m===d.domNode;)p(r[s],(function(e,r){var o=n[e];Be(d.tagAttrs,o,d.attrIndex)||t[e]?"ref"===e&&(g=r):y[e]=r})),d=e[++s];s--,d=e[s],v={nodeType:B,attributes:y,ref:g}}else h&&(v=f);i=se(v,d,a,i,o),a=a&&a.sibling,u=s},u=0,c=e.length;u<c;u++)s(u)}function $e(e){var t=e.node,n=e.part,r=e.alternate,o=e.parent.context,i=r&&r.node,a=t.values,s=t.nodeType===V,u=e.isSvgPart||s&&"svg"===t.element;e.isSvgPart=u;var c=e.nodeInstance;c||(c=s?function(e,t){var n=e.element,r=e.values,o=t?document.createElementNS("http://www.w3.org/2000/svg",n):document.createElement(n);return d(o),{fragment:o,nodes:[o],parts:[{isAttribute:!0,tagAttrs:[],attrIndex:0,domNode:o},{parentNode:o,isNode:!0}],values:r}}(t,u):new ze(t.template,u),e.nodeInstance=c),s||c.patchParts(n),t!==i?qe(c.parts,a,e):ie(e),ne(e,2),e.context=o}function Ge(e){var t=e.type,n=a(e);return"input"!==n||"radio"!==t&&"checkbox"!==t?"input"===n||"select"===n||"textarea"===n?"value":void 0:"checked"}function Je(e,t,n,r){t=t||{},p(e,(function(e,n){var o=t[e];n!==o&&r(e,n,o)})),p(t,(function(t,o){void 0===e[t]&&r(t,n,o)}))}function Ke(e,t,n,s,u){if(function(e){return 0===e.indexOf("on")}(t)){var c=function(e){return e.replace("on","").toLowerCase()}(t);c=function(e,t){var n=a(t);return r[e]?r[e]:"input"===n&&"change"===e?"input":e}(c,e);var d=function(e,t,n){var r=e.__brahmosData.events,o=r[t];return o?(o.handler=n,o.patched):((o=r[t]={handler:n,patched:null}).patched=function(e){var t=this;o.handler&&L((function(){o.handler.call(t,e)}))},o.patched)}(e,t,n);s&&!n?e.removeEventListener(c,d):!s&&n&&e.addEventListener(c,d)}else if("style"===t){var f=e.style;Je(n,s,"",(function(e,t){"-"===e[0]?f.setProperty(e,t):f[e]="number"==typeof t&&!1===o.test(e)?t+"px":t}))}else if("dangerouslySetInnerHTML"===t){var p=s&&s.__html,l=n&&n.__html;l!==p&&(e.innerHTML=null==l?"":l)}else if(t in e&&!u){var h=Ge(e);h?function(e,t,n,r){"checked"===e?"checked"===n?(t.checked=r,t.checkedProp=r):"defaultChecked"===n&&void 0===t.checkedProp?t.checked=r:t[n]=r:"value"===e&&("value"===n?(t.value=r,t.valueProp=r):"defaultValue"===n&&void 0===t.valueProp?t.value=r:t[n]=r)}(h,e,t,n):e[t]=null==n?"":n}else{var v=t.replace(/^xlink:?/,""),m=null==n||!1===n;t!==v?(v=v.toLowerCase(),m?e.removeAttributeNS(i,v):e.setAttributeNS(i,v,n)):m?e.removeAttribute(t):e.setAttribute(t,n)}}function Qe(e,t,n,r){Je(t,n,null,(function(t,n,o){Ke(e,t,n,o,r)})),function(e){var t=Ge(e);if(t){var n=e[t+"Prop"],r=e[t];void 0!==n&&n!==r&&(e[t]=n)}}(e)}function Xe(e){function t(t){return e(f(t,!1),t.ref)}return t.__isForwardRef=!0,t}function Ye(){return{current:null}}function Ze(e,t){var n=typeof e;"function"===n?e(t):"object"===n&&(e.current=t)}function et(e,t){var n=t.domNodes;e.__brahmosLastArrayDom=n[n.length-1]}function tt(e){var t=e.previousSibling;return e.isArrayNode&&(t=0===e.nodeIndex?t:e.parentNode.__brahmosLastArrayDom),t}function nt(e,t){var n=e.part;if(n.isArrayNode){var r=n.nodeIndex,o=n.parentNode,i=t.part.nodeIndex,a=function(e){for(;e.node&&!q(e.node);)e=e.child;return e}(e),s=a.nodeInstance,u=a!==e&&a.hasUncommittedEffect;if(s&&!u){if(r!==i){var c=s.domNodes,d=tt(n),f=m(o,d),p=c[0];p&&p.previousSibling!==d&&p!==f&&v(o,f,c)}et(o,s)}}}function rt(e){var t=e.node,n=e.nodeInstance,r=e.root,o=e.childFiberError,i=r.updateType,a=t.nodeType,s=t.ref,u=n.__brahmosData;if(a===W){var c=n.props,d=n.state,f=u.committedValues,p=u.lastSnapshot,l=f.props,h=f.state;l?y(n,"componentDidUpdate",[l,h,p]):y(n,"componentDidMount"),o&&(y(n,"componentDidCatch",[o.error,o.errorInfo]),e.childFiberError=null),s&&Ze(s,n),f.props=c,f.state=d,u.memoizedValues=null}else if(function(e){for(var t=be(e),n=0,r=t.length;n<r;n++){var o=t[n];o.effect&&o.effect()}}(e),"deferred"===i){var v=n.syncHooks,m=n.deferredHooks;n.deferredHooks=v,n.syncHooks=m}u.mounted=!0,u.fiber=e}function ot(e){e.tearDownFibers=[],e.postCommitEffects=[],e.hasUncommittedEffect=!1,e.resetRenderCallbacks()}function it(e){var t=e.currentTransition,n=e.pendingTransitions,r=n.indexOf(t);-1!==r&&n.splice(r,1)}function at(e){var t=e.node,n=e.alternate,r=t&&$(t);r&&n&&nt(e,n),2===e.hasUncommittedEffect&&(G(t)?function(e){var t=e.part,n=e.node,r=e.alternate,o=t.parentNode,i=m(o,t.previousSibling);r?i.nodeValue=n:v(o,i,n)}(e):q(t)?function(e){var t=e.part,n=e.nodeInstance,r=e.alternate,o=t.parentNode;if(r)nt(e,r);else{var i=m(o,tt(t));n.domNodes=v(o,i,n.fragment),et(o,n)}}(e):r?function(e){var t=e.node,n=e.nodeInstance,r=e.root,o=r.updateType,i=t.nodeType,a=n.__brahmosData;if(i===W){var s=a.committedValues,u=s.props,c=s.state;a.lastSnapshot=y(n,"getSnapshotBeforeUpdate",[u,c])}var d=N(e).transitionId,f=M(o);a[f]=a[f].filter((function(e){return e.transitionId!==d})),a.isDirty=!1,r.postCommitEffects.push(e)}(e):t.nodeType===B&&function(e){var t=e.part,n=e.node,r=e.alternate,o=e.isSvgPart,i=t.domNode,a=n.attributes,s=n.ref;Qe(i,a,r&&r.node.attributes,o),s&&Ze(s,i)}(e),e.hasUncommittedEffect=!1),n&&function(e){e.node=null,e.nodeInstance=null,e.child=null,e.sibling=null}(n)}function st(e,t,n,r){var o=(e.part.parentNode===t.parentNode||!n)&&r,i=e.node;i&&i.portalContainer&&(o=!0),ut(e,o)}function ut(e,t){var n=e.node,r=e.part,o=e.nodeInstance;if(J(n)){var i=q(n),a=e.child;if(a)for(st(a,r,i,t);a.sibling;)st(a=a.sibling,r,i,t);if(G(n)&&t){l(m(r.parentNode,r.previousSibling))}else{var s=n.ref;if(s&&Ze(s,null),o)if(i){var u=o.domNodes;t&&l(u)}else $(n)&&o.__brahmosData.mounted&&(n.nodeType===W?y(o,"componentWillUnmount"):Fe(e,!0))}}}function ct(e){e.tearDownFibers.forEach((function(e){e.shouldTearDown&&ut(e,!0)})),e.tearDownFibers=[]}ze.prototype.createNode=function(e){var t=this.templateResult,n=t.template,r=t.svgTemplate,o=e?r:n;return document.importNode(o.content,!0)},ze.prototype.createWalker=function(e){return document.createTreeWalker(e,129,null,!1)},ze.prototype.isBrahmosCommentNode=function(e){return e&&8===e.nodeType&&"{{brahmos}}"===e.textContent},ze.prototype.getParts=function(){for(var e=this.fragment,t=this.templateResult,n=this.isBrahmosCommentNode,r=t.partsMeta,o=this.createWalker(e),i=0,a=r[i],s=[],u=[],c=function(){i++,a=r[i]};o.nextNode();){var f=o.currentNode,p=f.nodeType,h=f.parentNode;if(1===p&&f.hasAttribute("data-brahmos-attr")){f.removeAttribute("data-brahmos-attr");for(var v=a.tagAttrs;a&&a.isAttribute&&a.tagAttrs===v;)s.push(Object.assign({},a,{domNode:f})),c();d(f)}else if(n(f)){var m=f.previousSibling;n(m)&&(m=g(f)),s.push(Object.assign({},a,{parentNode:h,previousSibling:m})),c(),u.push(f)}}return l(u),s},ze.prototype.patchParts=function(e){var t=this.parts,n=e.parentNode,r=e.previousSibling;if(!this.patched){for(var o=0,i=t.length;o<i;o++){var a=t[o];a.isNode&&a.parentNode instanceof DocumentFragment&&(a.parentNode=n,a.previousSibling=a.previousSibling||r)}this.patched=!0}};var dt;function ft(e){return dt+e-performance.now()}!function e(){requestAnimationFrame((function(t){dt=t,e()}))}();var pt=function(){return 1};function lt(e){var t=e.node,n=e.alternate;if(J(t)){var r=function(e){var t=e.node,n=e.nodeInstance;return!(!$(t)||!n)&&(!!O(e).length||n.__brahmosData.isDirty)}(e);!e.processedTime||r?(G(t)?function(e){var t=e.node,n=e.alternate;t!==(n&&n.node)&&ne(e,2)}(e):Array.isArray(t)?function(e){for(var t=e.node,n=e.part,r=e,o=n.parentNode,i=n.previousSibling,a=new Map,s=0,u=e;u=oe(u,e);){var c=K(u.node,s);a.set(c,u),s++}e.child=null,t.forEach((function(t,n){var s=K(t,n),u=a.get(s);u&&a.delete(s);var c=r;(r=se(t,{parentNode:o,previousSibling:i,a:void 0,isArrayNode:!0,nodeIndex:n},u,c,e)).sibling=null,u&&u.part.nodeIndex!==n&&(ne(r,1),0!==n&&ne(c,1))})),a.forEach((function(e){pe(e)})),ne(e,2)}(e):q(t)?$e(e):$(t)?Re(e):t.nodeType===B&&ne(e,2),e.processedTime=c()):ie(e)}else n&&pe(n)}function ht(e){var t=e.updateType,n=e.current,r=Y(t);ct(e);var o=function(e){for(var t=e.updateType,n=e.wip,r=e.current,o=Z(t),i=e[Y(t)],a=[],s="sync"===t?r:n;s;){var u=s.createdAt,c=s.node,d=s.child,f=s.hasUncommittedEffect,p=s[o],l=u>i,h=f||p>i;if(f&&a.push(s),l&&(d&&d.parent!==s&&(d.parent=s),c&&$(c)&&(s.nodeInstance.__brahmosData.fiber=s)),d&&h)s=d;else{for(;s!==e&&!s.sibling;)s=s.parent;s=s.sibling}}return a}(e);e[r]=e.lastCompleteTime=c(),"deferred"===t&&(e.current=e.wip,e.wip=n),function(e,t){for(var n=0,r=t.length;n<r;n++)at(t[n]);for(var o=e.postCommitEffects,i=o.length-1;i>=0;i--)rt(o[i]);it(e),ot(e),e.requestIdleHandle=null,e.forcedUpdateWith=null}(e,o)}function vt(e,t){var n=e.root,r=n.updateType,o=n.currentTransition,i=Y(r),a=Z(r),s=n[i],u=!function(e){return"immediate_action"===e.updateSource}(n);!function(e,t,n){var r=e.scheduleId;if(r&&clearTimeout(r),t){var o=ft(16);e.scheduleId=setTimeout((function(){var t=e.currentTransition,r=t?t.tryCount:0,o=t===C?200:500,i=Math.min(25,r);n(r>o?pt:function(){return ft(5+i)})}),o)}else n(pt)}(n,u,(function(r){for(;e!==t;){if(!(r()>0))return void vt(e,t);lt(e);var i=n.retryFiber;i?(e=i,t=n,n.retryFiber=null):e=de(e,t,s,a)}var u,c;n.callRenderCallbacks(),o&&("timedOut"!==(c=(u=o).transitionState)&&"suspended"!==c&&(u.isPending?(u.clearTimeout(),u.updatePendingState(!1,"transition")):u.transitionState="completed"),o.tryCount=0,!n.hasUncommittedEffect&&D(o)&&it(n)),function(e){return"transition"!==e.updateSource||e.lastCompleteTime>=e.updateTime&&e.hasUncommittedEffect&&D(e.currentTransition)}(n)&&ht(n),k(n)&&P("transition",(function(){n.updateSource="transition",mt(n)}))}))}function mt(e){var t=k(e);t&&(e.updateType="deferred",ot(e),e.currentTransition=t,t.tryCount+=1,e.wip=re(e.current,e.wip,e,e),vt(e.wip,e))}function yt(e){var t=e.root,n=e.parent;t.updateType="sync",t.currentTransition=null,ot(t),vt(e,n)}function gt(e){var t=fe(e),n=t.root,r=E(),o=U(),i=F();if(ee(t,i),"transition"===r){var a=n.pendingTransitions,s=o===C?"unshift":"push";a.includes(o)||a[s](o)}n.batchUpdates[r]||(n.batchUpdates[r]=_((function(){if(n.batchUpdates[r]=null,n.updateSource=r,n.lastCompleteTime<n.updateTime){var e="sync"===n.updateType&&n.requestIdleHandle;yt("immediate_action"===r&&!e?t:n.current)}else mt(n)})))}var bt=function(e){this.props=e,this.state=void 0,this.__brahmosData={lastSnapshot:null,pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,mounted:!1,committedValues:{},memoizedValues:null,isDirty:!1},this.context=void 0};bt.prototype.setState=function(e,t,n){var r=F(),o={state:e,transitionId:U().transitionId,callback:t},i=M(r);this.__brahmosData[i].push(o),gt(this)},bt.prototype.forceUpdate=function(e){var t=this.__brahmosData.fiber;t&&(t.root.forcedUpdateWith=this,this.__brahmosData.isDirty=!0,gt(this),e&&e(this.state))},bt.prototype.__render=function(){var e=this.render();return this.__brahmosData.nodes=e,e};var _t=function(e){function t(t){e.call(this,t),this.isPureReactComponent=!0}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(bt);function Tt(e,t,n){if("string"==typeof e)return function(e,t,n){var r=Q(null,[t,n],"");return r.element=e,r.nodeType=V,r}(e,t,n);var r=Object.assign({},e.defaultProps,f(t,e.__isForwardRef),{children:n});e.__loadLazyComponent&&e.__loadLazyComponent();var o=t.key;void 0===o&&(o="");var i=t.ref,a=function(e){return e.prototype instanceof bt}(e),s=Q(r,null,""+o);return s.nodeType=a?W:z,s.type=e,s.ref=a?i:null,s}function St(e,t){for(var n=e.root,r=e.nodeInstance;!(r instanceof xt||t&&r instanceof wt);){if((e=e.parent)===n)return null;r=e.nodeInstance}return e}function Ct(e){var t=e.parentSuspenseManager;return t&&t.isSuspenseList?t:null}function It(e,t){var n=e.nodeInstance;if(!n)return null;var r=n.suspenseManagers,o=t.transitionId,i=r[o];return i||(i=r[o]=new Nt(e,t)),i}function Dt(e){e.__brahmosData.isDirty=!0}var Nt=function(e,t){var n=e.nodeInstance;this.fiber=e,this.component=n,this.transition=t,this.childManagers=[],this.suspender=null,this.isSuspenseList=n instanceof wt;var r=St(e.parent,!0);this.parentSuspenseManager=r&&It(r,t),this.rootSuspenseManager=null,this.recordChildSuspense(),this.handleSuspense=this.handleSuspense.bind(this)};function kt(e){var t=N(X(),C);return"resolved"!==t.transitionState||t.pendingSuspense.includes(e)||(t=C),t}Nt.prototype.recordChildSuspense=function(){var e=this.parentSuspenseManager;e?(e.childManagers.push(this),this.rootSuspenseManager=e.rootSuspenseManager):this.rootSuspenseManager=this},Nt.prototype.addRootToProcess=function(){var e=this.rootSuspenseManager;X().root.afterRender(e.handleSuspense)},Nt.prototype.suspend=function(e){this.suspender=e,this.addRootToProcess()},Nt.prototype.handleSuspense=function(){var e=this.component,t=this.suspender;return e instanceof wt?this.handleSuspenseList():Promise.resolve(t).then(this.resolve.bind(this,t))},Nt.prototype.isUnresolved=function(){return this.isSuspenseList?this.childManagers.some((function(e){return e.isUnresolved()})):this.suspender},Nt.prototype.shouldShowFallback=function(){var e=Ct(this);if(!e)return!0;var t=e.component,n=e.childManagers,r=t.props.tail;if(Ct(e)&&!e.shouldShowFallback())return!1;if("collapsed"===r)for(var o=0,i=n.length;o<i;o++){var a=n[o];if("collapsed"===r&&a.isUnresolved())return a===this}return"hidden"!==r},Nt.prototype.resolve=function(e){var t=this,n=this.component,r=this.transition,o=this.suspender,i=this.childManagers,a=r.pendingSuspense||[];if(e===o)if(o){this.suspender=null,Dt(this.component);var s="timedOut"===r.transitionState,u=a.filter((function(e){return e.suspenseManagers[r.transitionId].suspender})).length;s||u||(r.transitionState="resolved");var c=function(){var e=n;fe(n)||(e=t.fiber.root.wip.nodeInstance),gt(e)};setTimeout((function(){s||!a.includes(n)?j(c):A(r,c)}),Date.now()%100)}else i.forEach((function(e){e.handleSuspense()}))},Nt.prototype.getChildrenSuspenders=function(){var e=[];return this.childManagers.forEach((function(t){t.isSuspenseList?e=e.concat(t.getChildrenSuspenders()):t.suspender&&e.push(t.suspender)})),e},Nt.prototype.handleSuspenseList=function(){var e=this.component,t=this.childManagers,n=e.props,r=n.revealOrder;void 0===r&&(r="together");var o=n.tail,i=function(e,t){return e.then((function(){return"forwards"===r&&"collapsed"===o&&function(e){var t=fe(e.component);e.isUnresolved()&&t&&(Dt(e.component),ee(t,"deferred"))}(t),t.handleSuspense()}))},a=Promise.all(this.getChildrenSuspenders());if("together"===r)a.then((function(){t.forEach((function(e){return e.handleSuspense()}))}));else if("forwards"===r)for(var s=Promise.resolve(),u=0,c=t.length;u<c;u++)s=i(s,t[u]);else if("backwards"===r)for(var d=Promise.resolve(),f=t.length-1;f>=0;f--)d=i(d,t[f]);return a};var wt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children},t}(bt),xt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.handleSuspender=function(e,t){var n=kt(this),r=It(t,n);D(n)||(n.pendingSuspense.includes(this)||n.pendingSuspense.push(this),n.transitionState="suspended"),r.suspend(e)},t.prototype.render=function(){var e=kt(this),t=It(X(),e),n=!t.suspender,r=this.props,o=r.fallback,i=r.children;return n?i:t.shouldShowFallback()?o:null},t}(bt),Et=function(e){var t,n=Xe((function(e,n){return Tt(t.read().default,Object.assign({},e,{ref:n}),e.children)}));return n.__loadLazyComponent=function(){var n,r,o,i;t||(n=e(),o="pending",i=n.then((function(e){o="success",r=e}),(function(e){o="error",r=e})),t={read:function(){if("pending"===o)throw i;if("error"===o)throw r;if("success"===o)return r}})},n};function Ut(e){return e.children}function Pt(e,t){var n,r,o=t.__rootFiber;if(o)(n=o.current).node.props.children=e,n.processedTime=0,ee(n);else{var i=Tt(Ut,{},e);r=[],(n=ae(o={updateType:"sync",updateSource:"js",scheduleId:0,domNode:t,forcedUpdateWith:null,current:null,wip:null,child:null,retryFiber:null,currentTransition:null,hasUncommittedEffect:!1,pendingTransitions:[],tearDownFibers:[],postCommitEffects:[],batchUpdates:{},lastDeferredCompleteTime:0,lastCompleteTime:0,deferredUpdateTime:0,updateTime:0,afterRender:function(e){r.includes(e)||r.push(e)},callRenderCallbacks:function(){for(var e=0,t=r.length;e<t;e++)r[e]()},resetRenderCallbacks:function(){r=[]}},i,{parentNode:t,isNode:!0})).parent=o,o.current=n,t.__rootFiber=o}L((function(){o.updateSource=E(),yt(n)}))}var At=new WeakMap;function Ft(e,t){var n=Q(null,t,"");return n.nodeType=H,n.template=e,n}function Mt(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];var r=At.get(e);return r||(r=new We(e),At.set(e,r)),Ft(r,t)}function Ot(e,t){return e&&(e.portalContainer=t),e}function jt(e){var t=e.__rootFiber;return!!t&&(pe(t.current),ct(t),e.__rootFiber=void 0,!0)}var Lt={createElement:Tt,render:Pt,Component:bt,PureComponent:_t,html:Mt,useState:Ie,useEffect:Ee,useRef:De,useReducer:Ne,useMemo:ke,useCallback:we,useLayoutEffect:Ue,useContext:Pe,useTransition:Ae,createContext:ve,forwardRef:Xe,createRef:Ye,createPortal:Ot,unmountComponentAtNode:jt,Suspense:xt,SuspenseList:wt,lazy:Et,unstable_deferredUpdates:j,unstable_syncUpdates:L};e.Component=bt,e.PureComponent=_t,e.Suspense=xt,e.SuspenseList=wt,e.createContext=ve,e.createElement=Tt,e.createPortal=Ot,e.createRef=Ye,e.default=Lt,e.forwardRef=Xe,e.html=Mt,e.lazy=Et,e.render=Pt,e.unmountComponentAtNode=jt,e.unstable_deferredUpdates=j,e.unstable_syncUpdates=L,e.useCallback=we,e.useContext=Pe,e.useEffect=Ee,e.useLayoutEffect=Ue,e.useMemo=ke,e.useReducer=Ne,e.useRef=De,e.useState=Ie,e.useTransition=Ae,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Brahmos={})}(this,(function(e){"use strict";var t={key:1,ref:1},n={className:"class",htmlFor:"for",acceptCharset:"accept-charset",httpEquiv:"http-equiv"},r={doubleclick:"dblclick"},o=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,i="http://www.w3.org/1999/xlink";function a(e){return e.nodeName.toLowerCase()}function s(e){return null==e}var u=0;function c(){return u++}function d(e){e.__brahmosData={events:{}}}function f(e,t){var n,r={};for(n in e)"key"===n||"ref"===n&&!t||(r[n]=e[n]);return r}function p(e,t){for(var n=Object.keys(e),r=0,o=n.length;r<o;r++){var i=n[r];t(i,e[i])}}function l(e){Array.isArray(e)||(e=[e]);for(var t=e.length-1;t>=0;t--){var n=e[t];n.parentNode.removeChild(n)}}function h(e){return Array.prototype.slice.call(e)}function v(e,t,n){t=void 0===t?null:t;var r=function(e){var t=e instanceof NodeList;if(e instanceof Node)return e;if(Array.isArray(e)||t){for(var n=document.createDocumentFragment(),r=0;e[r];)n.appendChild(e[r]),t||(r+=1);return n}return document.createTextNode(e)}(n),o=r instanceof DocumentFragment?h(r.childNodes):r;return e.insertBefore(r,t),o}function m(e,t){return t?t.nextSibling:e.firstChild}function y(e,t,n){if(e[t])return e[t].apply(e,n)}function g(e){var t=e.parentNode,n=document.createTextNode("");return t.insertBefore(n,e),n}var b=Promise.resolve();function T(e){return b.then(e)}function S(){return c()+"-"+1e6*Math.random()}var _={transitionId:"",tryCount:0,transitionState:"timedOut"},C={transitionId:S(),tryCount:0,transitionState:"timedOut"};function I(e){var t=e.transitionState;return"start"===t||"resolved"===t||"timedOut"===t}function D(e){var t=e.transitionState;return"completed"===t||"timedOut"===t}function N(e,t){return t=t||_,e.root.currentTransition||t}function k(e){return e.pendingTransitions.find(I)}var w="js",x=_;function E(){return w}function U(){return x}function P(e,t){w=e,t(),T((function(){w="js"}))}function A(e,t){var n=x;x=e,P("transition",t),x=n}function F(){return"transition"===w?"deferred":"sync"}function M(e){return"deferred"===e?"pendingDeferredUpdates":"pendingSyncUpdates"}function O(e){var t=e.root.updateType,n=e.nodeInstance.__brahmosData,r=N(e).transitionId;return n[M(t)].filter((function(e){return e.transitionId===r}))}function j(e){A(C,e)}function L(e){P("immediate_action",e)}var R,H=Symbol("tag"),V=Symbol("tag-element"),W=Symbol("class-component"),z=Symbol("functional-component"),B=Symbol("attribute");function q(e){var t=e.nodeType;return t===H||t===V}function $(e){var t=e.nodeType;return t===W||t===z}function G(e){return"string"==typeof e||"number"==typeof e}function J(e){return!(s(e)||"boolean"==typeof e)}function K(e,t){var n=e&&e.key;if(""===n&&e&&q(e)){for(var r=e.values,o=0,i=r.length;o<i;o++){var a=r[o];if(void 0!==a.key){n=""+a.key;break}}e.key=void 0===n?"":""+n}return""===n?""+t:n}function Q(e,t,n){return{nodeType:null,key:n,added:!1,ref:null,portalContainer:null,type:null,props:e,element:"",values:t,template:null}}function X(){return R}function Y(e){return"deferred"===e?"lastDeferredCompleteTime":"lastCompleteTime"}function Z(e){return"deferred"===e?"deferredUpdateTime":"updateTime"}function ee(e,t){for(var n=Z(t),r=c();e;)e[n]=r,e=e.parent}function te(e,t,n){t===n?n.child=e:t.sibling=e,e.parent=n}function ne(e,t){e.hasUncommittedEffect=t,e.root.hasUncommittedEffect=!0}function re(e,t,n,r){var o=e.root,i=e.node,a=e.part,s=e.nodeInstance,u=e.child,d=Z(o.updateType);return t?(t.node=i,t.part=a,t.createdAt=c()):function(e,t){e&&(e.alternate=t);t.alternate=e}(e,t=ae(o,i,a)),e.shouldTearDown=!1,t.nodeInstance=s,t.child=u,t[d]=r[d],te(t,n,r),t}function oe(e,t){return e===t?e.child:e.sibling}function ie(e){var t=e.child;if("sync"!==e.root.updateType)for(var n;t;){n=re(t,t.alternate,n||e,e),t=t.sibling}}function ae(e,t,n){return t&&t.portalContainer&&(n.parentNode=t.portalContainer),{node:t,nodeInstance:null,root:e,parent:null,child:null,sibling:null,part:n,alternate:null,context:null,childFiberError:null,isSvgPart:!1,deferredUpdateTime:0,updateTime:0,processedTime:0,createdAt:c(),shouldTearDown:!1,hasUncommittedEffect:0}}function se(e,t,n,r,o){var i,a,u,c=r.root,d=Z(c.updateType);return n&&!s(n.node)&&!s(e)&&(a=e,u=n.node,G(a)&&G(u)||a.nodeType===B||Array.isArray(a)&&Array.isArray(u)||$(a)&&a.type===u.type||q(a)&&a.template===u.template)?((i=re(n,n.alternate,r,o)).node=e,i.part=t):(i=ae(c,e,t),n&&pe(n)),te(i,r,o),i.processedTime=0,i[d]=o[d],i.context=o.context,i.isSvgPart=o.isSvgPart,i}function ue(e,t,n){return e&&e[n]>=t}function ce(e,t,n){if(e){for(;e&&!ue(e,t,n);)e=e.sibling;return e}}function de(e,t,n,r){var o,i=ce(e.child,n,r);if(i)return i;for(;!(o=ce(e.sibling,n,r));)if((e=e.parent)===t)return e;return o}function fe(e){return e.__brahmosData.fiber}function pe(e){e.shouldTearDown=!0,e.root.tearDownFibers.push(e)}var le=1;function he(e){return function(t){var n=fe(e),r=n.root.updateType;e.context!==t&&ee(n,r)}}function ve(e){var t="cC"+le++,n=function(e){function t(t){e.call(this,t),this.subs=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.shouldComponentUpdate=function(e){return this.props.value!==e.value&&this.subs.forEach((function(t){return t(e.value)})),!0},t.prototype.sub=function(e){var t=this.subs,n=he(e);t.push(n);var r=e.componentWillUnmount;e.componentWillUnmount=function(){t.splice(t.indexOf(n),1),r&&r()}},t.prototype.render=function(){return this.props.children},t}(bt);n.__ccId=t;var r=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children(this.context)},t}(bt),o={id:t,defaultValue:e,Provider:n,Consumer:r};return r.contextType=o,o}function me(){return X().nodeInstance}function ye(e){e.deferredHooks=e.syncHooks.map((function(e,t){return Array.isArray(e)?[].concat(e):e.transitionId?e:Object.assign({},e)}))}function ge(e,t){var n=t.syncHooks,r=t.deferredHooks;return"sync"===e?n:r}function be(e){var t=e.nodeInstance;return ge(e.root.updateType,t)}function Te(e,t,n){return"deferred"!==e||n.deferredHooks.length||ye(n),ge(e,n)[t]}function Se(e,t){if(!e||!t||e.length!==t.length)return!0;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!0;return!1}function _e(e,t,n){void 0===t&&(t=function(e){return!1}),void 0===n&&(n=function(e){return e});var r=X(),o=r.nodeInstance,i=o.pointer,a=be(r),s=a[i];return s&&!t(s)||(s=e(),a[i]=s),o.pointer+=1,n(s)}function Ce(e,t){var n=me(),r=n.pointer;return _e((function(){return"function"==typeof e&&(e=e()),[e,function(e){var o=F(),i=Te(o,r,n),a=i[0],s=t(e,a),u=M(o),c={transitionId:U().transitionId,updater:function(){Te(o,r,n)[0]=t(e,i[0])}};n.__brahmosData[u].push(c),function(e,t,n){Object.is(t,n)||gt(e)}(n,s,a)}]}))}function Ie(e){return Ce(e,(function(e,t){return"function"==typeof e&&(e=e(t)),e}))}function De(e){return _e((function(){return{current:e}}))}function Ne(e,t,n){return Ce(n?function(){return n(t)}:t,(function(t,n){return e(n,t)}))}function ke(e,t){return _e((function(){return{value:e(),dependencies:t}}),(function(e){return Se(t,e.dependencies)}),(function(e){return e.value}))}function we(e,t){return ke((function(){return e}),t)}function xe(e,t){var n=X(),r=n.nodeInstance,o=r.pointer,i=be(n),a=i[o]||{animationFrame:null,cleanEffect:null},s=Object.assign({},a,{isDependenciesChanged:Se(t,a.dependencies),dependencies:t,effect:function(){s.isDependenciesChanged&&e(s)}});i[o]=s,r.pointer+=1}function Ee(e,t){xe((function(t){cancelAnimationFrame(t.animationFrame),t.animationFrame=requestAnimationFrame((function(){setTimeout((function(){t.cleanEffect=e()}))}))}),t)}function Ue(e,t){xe((function(t){t.cleanEffect=e()}),t)}function Pe(e){var t=X(),n=t.nodeInstance,r=t.context,o=e.id,i=e.defaultValue,a=r[o],s=a?a.props.value:i;return Ue((function(){if(a){var e=a.subs,t=he(n);return e.push(t),function(){e.splice(e.indexOf(t),1)}}}),[]),n.context=s,s}function Ae(e){var t=e.timeoutMs,n=me();return _e((function(){var e={transitionId:S(),tryCount:0,isPending:!1,transitionTimeout:null,pendingSuspense:[],transitionState:"initial",clearTimeout:function(){clearTimeout(e.transitionTimeout)},updatePendingState:function(t,r){e.isPending=t,n.__brahmosData.isDirty=!0;var o=function(){gt(n)};"transition"===r?A(e,o):P(r,o)},startTransition:function(r){var o=E(),i=fe(n).root;e.transitionState="start",e.pendingSuspense=[],e.clearTimeout(),A(e,r),i.lastDeferredCompleteTime<i.deferredUpdateTime&&e.updatePendingState(!0,o),e.transitionTimeout=setTimeout((function(){e.transitionState="timedOut",e.updatePendingState(!1,"transition")}),t)}};return e}),void 0,(function(e){return[e.startTransition,e.isPending]}))}function Fe(e,t){for(var n=be(e),r=0,o=n.length;r<o;r++){var i=n[r];i.cleanEffect&&(i.isDependenciesChanged||t)&&i.cleanEffect(),i.clearTimeout&&t&&i.clearTimeout()}}function Me(e){var t;return(t={syncHooks:[],deferredHooks:[],pointer:0,__render:function(t){var n,r,o;n=X(),r=n.nodeInstance,o=n.root.updateType,r.pointer=0,"deferred"===o&&ye(r),O(n).forEach((function(e){return e.updater()}));var i=e(t);return this.__brahmosData.nodes=i,i}}).__brahmosData={pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,isDirty:!1,mounted:!1},t}function Oe(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function je(e){for(var t=e.root;(e=e.parent)&&!(e.nodeInstance instanceof bt&&(e.nodeInstance.componentDidCatch||e.node.type.getDerivedStateFromError));)if(e===t)return null;return e}function Le(e){var t=e.root;e.nodeInstance.__brahmosData.isDirty=!0,t.retryFiber=e}function Re(e){var t,n=e.node,r=e.part,o=e.root,i=e.childFiberError,a=n.type,s=n.nodeType,u=n.props;void 0===u&&(u={});var c="deferred"===o.updateType,d=!0,f=!1,p=s===W;!function(e){var t=e.root,n=e.child,r=e.alternate;n&&n.createdAt>t.lastCompleteTime&&(e.child=r&&r.child)}(e);var l=e.nodeInstance,h=!1;l||(l=p?new a(u):Me(a),e.nodeInstance=l,h=!0);var v=l.__brahmosData,m=function(e){var t=e.node.type,n=e.nodeInstance,r=e.parent,o=e.context,i=t.__ccId,a=r.context||{};if(!i)return a;if(o)return o;var s=Object.create(a);return s[i]=n,s}(e);if(e.context=m,p){var g=v.committedValues,b=v.memoizedValues;h&&(g.state=l.state);var T=g.props,S=g.state;b&&c&&(T=(t=b).props,S=t.state,f=!0),l.props=T,l.state=S;var _=l.shouldComponentUpdate,C=S,I=O(e);I.length&&(C=function(e,t){return t.reduce((function(e,t){var n=t.state;return"function"==typeof n&&(n=n(e)),Object.assign({},e,n)}),e)}(S,I));var D=!h&&o.forcedUpdateWith!==l,N=y(a,"getDerivedStateFromProps",[u,C]),k=i?y(a,"getDerivedStateFromError",[i.error]):void 0;(N||k)&&(C=Object.assign({},C,N,k)),I.forEach((function(e){var t=e.callback;t&&t(C)})),l.isPureReactComponent&&D&&(d=!Oe(C,S)||!Oe(u,T)),_&&d&&D&&(d=_.call(l,u,C));var w=a.contextType;if(w){var x=w.id,E=w.defaultValue,U=m[x],P=U?U.props.value:E;U&&h&&U.sub(l),l.context=P}l.state=C,l.props=u,c&&(v.memoizedValues={state:C,props:u})}else h||Fe(e);if(d){try{!function(e){R=e}(e),se(i&&!a.getDerivedStateFromError?null:l.__render(u),r,e.child,e,e)}catch(t){var A=je(e);if("function"==typeof t.then){var F=_t(e);if(!F)throw new Error("Rendering which got suspended can't be used outside of suspense.");F.nodeInstance.handleSuspender(t,F),Le(F)}else{if(!A||A.childFiberError)throw t;var M=function(e){var t=e.node.type;return{componentStack:"The above error occurred in the <"+(t.displayName||t.name)+"> component:"}}(e);console.error(t),console.error(M.componentStack),A.childFiberError={error:t,errorInfo:M},Le(A)}return}ne(e,2)}else if(f){var j=e.child;j&&j.node===v.nodes||(se(v.nodes,r,j,e,e),ne(e,2))}else ie(e)}var He=/[<>"]/g,Ve=/(^|\s)([^\s"'=<]+)(?=[\s=>])/g;var We=function(e){this.strings=e,this.template=null,this.svgTemplate=null,this.partsMeta=[]};We.prototype.create=function(e){e&&this.svgTemplate||this.template||(this.partsMeta=this.getPartsMeta(),this.createTemplate(e))},We.prototype.getPartsMeta=function(){for(var e,t,n=this.strings,r=[],o=[],i=function(i,a){for(var s=n[i],u=void 0,c=void 0,d=void 0,f=void 0,p=void 0,l=function(){var e=s.substring(f||0,p||s.length);r.push.apply(r,function(e){for(var t,n=[];null!==(t=Ve.exec(e));){t[2]&&n.push(t[2])}return n}(e))};null!==(u=He.exec(s));)"<"!==u[0]||t?'"'===u[0]?t=!t:e&&">"===u[0]&&!t&&(e=!1,p=u.index,void 0===f&&l()):(e=!0,r=[],f=u.index,p=void 0);e&&l(),e?c=!0:d=!0,i<a-1&&o.push({tagAttrs:r,attrIndex:r.length,isAttribute:c,isNode:d})},a=0,s=n.length;a<s;a++)i(a,s);return o},We.prototype.createTemplate=function(e){for(var t=this.partsMeta,n=this.strings,r=document.createElement("template"),o="",i=0,a=n.length-1;i<a;i++){var s=n[i];o=t[i].isNode?o+s+"\x3c!--{{brahmos}}--\x3e":o+s+"data-brahmos-attr"}o+=n[n.length-1],r.innerHTML=e?"<svg>"+o+"</svg>":o,e&&function(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}(r.content.firstChild),this[e?"svgTemplate":"template"]=r};var ze=function(e,t){this.templateResult=e,e.create(t),this.fragment=this.createNode(t),this.parts=this.getParts(),this.domNodes=h(this.fragment.childNodes),this.patched=!1};function Be(e,t,n){return n<=e.lastIndexOf(t)}function qe(e,r,o){for(var i=o,a=o.child,s=function(s,c){var d=e[s],f=r[s],l=d.isAttribute,h=d.isNode,v=void 0;if(l){for(var m=d.domNode,y={},g=void 0;d&&m===d.domNode;)p(r[s],(function(e,r){var o=n[e];Be(d.tagAttrs,o,d.attrIndex)||t[e]?"ref"===e&&(g=r):y[e]=r})),d=e[++s];s--,d=e[s],v={nodeType:B,attributes:y,ref:g}}else h&&(v=f);i=se(v,d,a,i,o),a=a&&a.sibling,u=s},u=0,c=e.length;u<c;u++)s(u)}function $e(e){var t=e.node,n=e.part,r=e.alternate,o=e.parent.context,i=r&&r.node,a=t.values,s=t.nodeType===V,u=e.isSvgPart||s&&"svg"===t.element;e.isSvgPart=u;var c=e.nodeInstance;c||(c=s?function(e,t){var n=e.element,r=e.values,o=t?document.createElementNS("http://www.w3.org/2000/svg",n):document.createElement(n);return d(o),{fragment:o,nodes:[o],parts:[{isAttribute:!0,tagAttrs:[],attrIndex:0,domNode:o},{parentNode:o,isNode:!0}],values:r}}(t,u):new ze(t.template,u),e.nodeInstance=c),s||c.patchParts(n),t!==i?qe(c.parts,a,e):ie(e),ne(e,2),e.context=o}function Ge(e){var t=e.type,n=a(e);return"input"!==n||"radio"!==t&&"checkbox"!==t?"input"===n||"select"===n||"textarea"===n?"value":void 0:"checked"}function Je(e,t,n,r){t=t||{},p(e,(function(e,n){var o=t[e];n!==o&&r(e,n,o)})),p(t,(function(t,o){void 0===e[t]&&r(t,n,o)}))}function Ke(e,t,n,s,u){if(function(e){return 0===e.indexOf("on")}(t)){var c=function(e){return e.replace("on","").toLowerCase()}(t);c=function(e,t){var n=a(t);return r[e]?r[e]:"input"===n&&"change"===e?"input":e}(c,e);var d=function(e,t,n){var r=e.__brahmosData.events,o=r[t];return o?(o.handler=n,o.patched):((o=r[t]={handler:n,patched:null}).patched=function(e){var t=this;o.handler&&L((function(){o.handler.call(t,e)}))},o.patched)}(e,t,n);s&&!n?e.removeEventListener(c,d):!s&&n&&e.addEventListener(c,d)}else if("style"===t){var f=e.style;Je(n,s,"",(function(e,t){"-"===e[0]?f.setProperty(e,t):f[e]="number"==typeof t&&!1===o.test(e)?t+"px":t}))}else if("dangerouslySetInnerHTML"===t){var p=s&&s.__html,l=n&&n.__html;l!==p&&(e.innerHTML=null==l?"":l)}else if(t in e&&!u){var h=Ge(e);h?function(e,t,n,r){"checked"===e?"checked"===n?(t.checked=r,t.checkedProp=r):"defaultChecked"===n&&void 0===t.checkedProp?t.checked=r:t[n]=r:"value"===e&&("value"===n?(t.value=r,t.valueProp=r):"defaultValue"===n&&void 0===t.valueProp?t.value=r:t[n]=r)}(h,e,t,n):e[t]=null==n?"":n}else{var v=t.replace(/^xlink:?/,""),m=null==n||!1===n;t!==v?(v=v.toLowerCase(),m?e.removeAttributeNS(i,v):e.setAttributeNS(i,v,n)):m?e.removeAttribute(t):e.setAttribute(t,n)}}function Qe(e,t,n,r){Je(t,n,null,(function(t,n,o){Ke(e,t,n,o,r)})),function(e){var t=Ge(e);if(t){var n=e[t+"Prop"],r=e[t];void 0!==n&&n!==r&&(e[t]=n)}}(e)}function Xe(e){function t(t){return e(f(t,!1),t.ref)}return t.__isForwardRef=!0,t}function Ye(){return{current:null}}function Ze(e,t){var n=typeof e;"function"===n?e(t):"object"===n&&(e.current=t)}function et(e,t){var n=t.domNodes;e.__brahmosLastArrayDom=n[n.length-1]}function tt(e){var t=e.previousSibling;return e.isArrayNode&&(t=0===e.nodeIndex?t:e.parentNode.__brahmosLastArrayDom),t}function nt(e,t){var n=e.part;if(n.isArrayNode){var r=n.nodeIndex,o=n.parentNode,i=t.part.nodeIndex,a=function(e){for(;e.node&&!q(e.node);)e=e.child;return e}(e),s=a.nodeInstance,u=a!==e&&a.hasUncommittedEffect;if(s&&!u){if(r!==i){var c=s.domNodes,d=tt(n),f=m(o,d),p=c[0];p&&p.previousSibling!==d&&p!==f&&v(o,f,c)}et(o,s)}}}function rt(e){var t=e.node,n=e.nodeInstance,r=e.root,o=e.childFiberError,i=r.updateType,a=t.nodeType,s=t.ref,u=n.__brahmosData;if(a===W){var c=n.props,d=n.state,f=u.committedValues,p=u.lastSnapshot,l=f.props,h=f.state;l?y(n,"componentDidUpdate",[l,h,p]):y(n,"componentDidMount"),o&&(y(n,"componentDidCatch",[o.error,o.errorInfo]),e.childFiberError=null),s&&Ze(s,n),f.props=c,f.state=d,u.memoizedValues=null}else if(function(e){for(var t=be(e),n=0,r=t.length;n<r;n++){var o=t[n];o.effect&&o.effect()}}(e),"deferred"===i){var v=n.syncHooks,m=n.deferredHooks;n.deferredHooks=v,n.syncHooks=m}u.mounted=!0,u.fiber=e}function ot(e){e.tearDownFibers=[],e.postCommitEffects=[],e.hasUncommittedEffect=!1,e.resetRenderCallbacks()}function it(e){var t=e.currentTransition,n=e.pendingTransitions,r=n.indexOf(t);-1!==r&&n.splice(r,1)}function at(e){var t=e.node,n=e.alternate,r=t&&$(t);r&&n&&nt(e,n),2===e.hasUncommittedEffect&&(G(t)?function(e){var t=e.part,n=e.node,r=e.alternate,o=t.parentNode,i=m(o,t.previousSibling);r?i.nodeValue=n:v(o,i,n)}(e):q(t)?function(e){var t=e.part,n=e.nodeInstance,r=e.alternate,o=t.parentNode;if(r)nt(e,r);else{var i=m(o,tt(t));n.domNodes=v(o,i,n.fragment),et(o,n)}}(e):r?function(e){var t=e.node,n=e.nodeInstance,r=e.root,o=r.updateType,i=t.nodeType,a=n.__brahmosData;if(i===W){var s=a.committedValues,u=s.props,c=s.state;a.lastSnapshot=y(n,"getSnapshotBeforeUpdate",[u,c])}var d=N(e).transitionId,f=M(o);a[f]=a[f].filter((function(e){return e.transitionId!==d})),a.isDirty=!1,r.postCommitEffects.push(e)}(e):t.nodeType===B&&function(e){var t=e.part,n=e.node,r=e.alternate,o=e.isSvgPart,i=t.domNode,a=n.attributes,s=n.ref;Qe(i,a,r&&r.node.attributes,o),s&&Ze(s,i)}(e),e.hasUncommittedEffect=!1),n&&function(e){e.node=null,e.nodeInstance=null,e.child=null,e.sibling=null}(n)}function st(e,t,n,r){var o=(e.part.parentNode===t.parentNode||!n)&&r,i=e.node;i&&i.portalContainer&&(o=!0),ut(e,o)}function ut(e,t){var n=e.node,r=e.part,o=e.nodeInstance;if(J(n)){var i=q(n),a=e.child;if(a)for(st(a,r,i,t);a.sibling;)st(a=a.sibling,r,i,t);if(G(n)&&t){l(m(r.parentNode,r.previousSibling))}else{var s=n.ref;if(s&&Ze(s,null),o)if(i){var u=o.domNodes;t&&l(u)}else $(n)&&o.__brahmosData.mounted&&(n.nodeType===W?y(o,"componentWillUnmount"):Fe(e,!0))}}}function ct(e){e.tearDownFibers.forEach((function(e){e.shouldTearDown&&ut(e,!0)})),e.tearDownFibers=[]}ze.prototype.createNode=function(e){var t=this.templateResult,n=t.template,r=t.svgTemplate,o=e?r:n;return document.importNode(o.content,!0)},ze.prototype.createWalker=function(e){return document.createTreeWalker(e,129,null,!1)},ze.prototype.isBrahmosCommentNode=function(e){return e&&8===e.nodeType&&"{{brahmos}}"===e.textContent},ze.prototype.getParts=function(){for(var e=this.fragment,t=this.templateResult,n=this.isBrahmosCommentNode,r=t.partsMeta,o=this.createWalker(e),i=0,a=r[i],s=[],u=[],c=function(){i++,a=r[i]};o.nextNode();){var f=o.currentNode,p=f.nodeType,h=f.parentNode;if(1===p&&f.hasAttribute("data-brahmos-attr")){f.removeAttribute("data-brahmos-attr");for(var v=a.tagAttrs;a&&a.isAttribute&&a.tagAttrs===v;)s.push(Object.assign({},a,{domNode:f})),c();d(f)}else if(n(f)){var m=f.previousSibling;n(m)&&(m=g(f)),s.push(Object.assign({},a,{parentNode:h,previousSibling:m})),c(),u.push(f)}}return l(u),s},ze.prototype.patchParts=function(e){var t=this.parts,n=e.parentNode,r=e.previousSibling;if(!this.patched){for(var o=0,i=t.length;o<i;o++){var a=t[o];a.isNode&&a.parentNode instanceof DocumentFragment&&(a.parentNode=n,a.previousSibling=a.previousSibling||r)}this.patched=!0}};var dt;function ft(e){return dt+e-performance.now()}!function e(){requestAnimationFrame((function(t){dt=t,e()}))}();var pt=function(){return 1};function lt(e){var t=e.node,n=e.alternate;if(J(t)){var r=function(e){var t=e.node,n=e.nodeInstance;return!(!$(t)||!n)&&(!!O(e).length||n.__brahmosData.isDirty)}(e);!e.processedTime||r?(G(t)?function(e){var t=e.node,n=e.alternate;t!==(n&&n.node)&&ne(e,2)}(e):Array.isArray(t)?function(e){for(var t=e.node,n=e.part,r=e,o=n.parentNode,i=n.previousSibling,a=new Map,s=0,u=e;u=oe(u,e);){var c=K(u.node,s);a.set(c,u),s++}e.child=null,t.forEach((function(t,n){var s=K(t,n),u=a.get(s);u&&a.delete(s);var c=r;(r=se(t,{parentNode:o,previousSibling:i,a:void 0,isArrayNode:!0,nodeIndex:n},u,c,e)).sibling=null,u&&u.part.nodeIndex!==n&&(ne(r,1),0!==n&&ne(c,1))})),a.forEach((function(e){pe(e)})),ne(e,2)}(e):q(t)?$e(e):$(t)?Re(e):t.nodeType===B&&ne(e,2),e.processedTime=c()):ie(e)}else n&&pe(n)}function ht(e){var t=e.updateType,n=e.current,r=Y(t);ct(e);var o=function(e){for(var t=e.updateType,n=e.wip,r=e.current,o=Z(t),i=e[Y(t)],a=[],s="sync"===t?r:n;s;){var u=s.createdAt,c=s.node,d=s.child,f=s.hasUncommittedEffect,p=s[o],l=u>i,h=f||p>i;if(f&&a.push(s),l&&(d&&d.parent!==s&&(d.parent=s),c&&$(c)&&(s.nodeInstance.__brahmosData.fiber=s)),d&&h)s=d;else{for(;s!==e&&!s.sibling;)s=s.parent;s=s.sibling}}return a}(e);e[r]=e.lastCompleteTime=c(),"deferred"===t&&(e.current=e.wip,e.wip=n),function(e,t){for(var n=0,r=t.length;n<r;n++)at(t[n]);for(var o=e.postCommitEffects,i=o.length-1;i>=0;i--)rt(o[i]);it(e),ot(e),e.requestIdleHandle=null,e.forcedUpdateWith=null}(e,o)}function vt(e,t){var n=e.root,r=n.updateType,o=n.currentTransition,i=Y(r),a=Z(r),s=n[i],u=!function(e){return"immediate_action"===e.updateSource}(n);!function(e,t,n){var r=e.scheduleId;if(r&&clearTimeout(r),t){var o=ft(16),i=o>2?0:o+1;e.scheduleId=setTimeout((function(){var t=e.currentTransition,r=t?t.tryCount:0,o=t===C?300:600,i=Math.min(30,5+r);n(r>o?pt:function(){return ft(i)})}),i)}else n(pt)}(n,u,(function(r){for(;e!==t;){if(!(r()>0))return void vt(e,t);lt(e);var i=n.retryFiber;i?(e=i,t=n,n.retryFiber=null):e=de(e,t,s,a)}var u,c;n.callRenderCallbacks(),o&&("timedOut"!==(c=(u=o).transitionState)&&"suspended"!==c&&(u.isPending?(u.clearTimeout(),u.updatePendingState(!1,"transition")):u.transitionState="completed"),o.tryCount=0,!n.hasUncommittedEffect&&D(o)&&it(n)),function(e){return"transition"!==e.updateSource||e.lastCompleteTime>=e.updateTime&&e.hasUncommittedEffect&&D(e.currentTransition)}(n)&&ht(n),k(n)&&P("transition",(function(){n.updateSource="transition",mt(n)}))}))}function mt(e){var t=k(e);t&&(e.updateType="deferred",ot(e),e.currentTransition=t,t.tryCount+=1,e.wip=re(e.current,e.wip,e,e),vt(e.wip,e))}function yt(e){var t=e.root,n=e.parent;t.updateType="sync",t.currentTransition=null,ot(t),vt(e,n)}function gt(e){var t=fe(e),n=t.root,r=E(),o=U(),i=F();if(ee(t,i),"transition"===r){var a=n.pendingTransitions,s=o===C?"unshift":"push";a.includes(o)||a[s](o)}n.batchUpdates[r]||(n.batchUpdates[r]=T((function(){if(n.batchUpdates[r]=null,n.updateSource=r,n.lastCompleteTime<n.updateTime){var e="sync"===n.updateType&&n.requestIdleHandle;yt("immediate_action"===r&&!e?t:n.current)}else mt(n)})))}var bt=function(e){this.props=e,this.state=void 0,this.__brahmosData={lastSnapshot:null,pendingSyncUpdates:[],pendingDeferredUpdates:[],fiber:null,nodes:null,mounted:!1,committedValues:{},memoizedValues:null,isDirty:!1},this.context=void 0};bt.prototype.setState=function(e,t,n){var r=F(),o={state:e,transitionId:U().transitionId,callback:t},i=M(r);this.__brahmosData[i].push(o),gt(this)},bt.prototype.forceUpdate=function(e){var t=this.__brahmosData.fiber;t&&(t.root.forcedUpdateWith=this,this.__brahmosData.isDirty=!0,gt(this),e&&e(this.state))},bt.prototype.__render=function(){var e=this.render();return this.__brahmosData.nodes=e,e};var Tt=function(e){function t(t){e.call(this,t),this.isPureReactComponent=!0}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(bt);function St(e,t,n){if("string"==typeof e)return function(e,t,n){var r=Q(null,[t,n],"");return r.element=e,r.nodeType=V,r}(e,t,n);var r=Object.assign({},e.defaultProps,f(t,e.__isForwardRef),{children:n});e.__loadLazyComponent&&e.__loadLazyComponent();var o=t.key;void 0===o&&(o="");var i=t.ref,a=function(e){return e.prototype instanceof bt}(e),s=Q(r,null,""+o);return s.nodeType=a?W:z,s.type=e,s.ref=a?i:null,s}function _t(e,t){for(var n=e.root,r=e.nodeInstance;!(r instanceof xt||t&&r instanceof wt);){if((e=e.parent)===n)return null;r=e.nodeInstance}return e}function Ct(e){var t=e.parentSuspenseManager;return t&&t.isSuspenseList?t:null}function It(e,t){var n=e.nodeInstance;if(!n)return null;var r=n.suspenseManagers,o=t.transitionId,i=r[o];return i||(i=r[o]=new Nt(e,t)),i}function Dt(e){e.__brahmosData.isDirty=!0}var Nt=function(e,t){var n=e.nodeInstance;this.fiber=e,this.component=n,this.transition=t,this.childManagers=[],this.suspender=null,this.isSuspenseList=n instanceof wt;var r=_t(e.parent,!0);this.parentSuspenseManager=r&&It(r,t),this.rootSuspenseManager=null,this.recordChildSuspense(),this.handleSuspense=this.handleSuspense.bind(this)};function kt(e){var t=N(X(),C);return"resolved"!==t.transitionState||t.pendingSuspense.includes(e)||(t=C),t}Nt.prototype.recordChildSuspense=function(){var e=this.parentSuspenseManager;e?(e.childManagers.push(this),this.rootSuspenseManager=e.rootSuspenseManager):this.rootSuspenseManager=this},Nt.prototype.addRootToProcess=function(){var e=this.rootSuspenseManager;X().root.afterRender(e.handleSuspense)},Nt.prototype.suspend=function(e){this.suspender=e,this.addRootToProcess()},Nt.prototype.handleSuspense=function(){var e=this.component,t=this.suspender;return e instanceof wt?this.handleSuspenseList():Promise.resolve(t).then(this.resolve.bind(this,t))},Nt.prototype.isUnresolved=function(){return this.isSuspenseList?this.childManagers.some((function(e){return e.isUnresolved()})):this.suspender},Nt.prototype.shouldShowFallback=function(){var e=Ct(this);if(!e)return!0;var t=e.component,n=e.childManagers,r=t.props.tail;if(Ct(e)&&!e.shouldShowFallback())return!1;if("collapsed"===r)for(var o=0,i=n.length;o<i;o++){var a=n[o];if("collapsed"===r&&a.isUnresolved())return a===this}return"hidden"!==r},Nt.prototype.resolve=function(e){var t=this,n=this.component,r=this.transition,o=this.suspender,i=this.childManagers,a=r.pendingSuspense||[];if(e===o)if(o){this.suspender=null,Dt(this.component);var s="timedOut"===r.transitionState,u=a.filter((function(e){return e.suspenseManagers[r.transitionId].suspender})).length;s||u||(r.transitionState="resolved");var c=function(){var e=n;fe(n)||(e=t.fiber.root.wip.nodeInstance),gt(e)};setTimeout((function(){s||!a.includes(n)?j(c):A(r,c)}),Date.now()%100)}else i.forEach((function(e){e.handleSuspense()}))},Nt.prototype.getChildrenSuspenders=function(){var e=[];return this.childManagers.forEach((function(t){t.isSuspenseList?e=e.concat(t.getChildrenSuspenders()):t.suspender&&e.push(t.suspender)})),e},Nt.prototype.handleSuspenseList=function(){var e=this.component,t=this.childManagers,n=e.props,r=n.revealOrder;void 0===r&&(r="together");var o=n.tail,i=function(e,t){return e.then((function(){return"forwards"===r&&"collapsed"===o&&function(e){var t=fe(e.component);e.isUnresolved()&&t&&(Dt(e.component),ee(t,"deferred"))}(t),t.handleSuspense()}))},a=Promise.all(this.getChildrenSuspenders());if("together"===r)a.then((function(){t.forEach((function(e){return e.handleSuspense()}))}));else if("forwards"===r)for(var s=Promise.resolve(),u=0,c=t.length;u<c;u++)s=i(s,t[u]);else if("backwards"===r)for(var d=Promise.resolve(),f=t.length-1;f>=0;f--)d=i(d,t[f]);return a};var wt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){return this.props.children},t}(bt),xt=function(e){function t(t){e.call(this,t),this.suspenseManagers={}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.handleSuspender=function(e,t){var n=kt(this),r=It(t,n);D(n)||(n.pendingSuspense.includes(this)||n.pendingSuspense.push(this),n.transitionState="suspended"),r.suspend(e)},t.prototype.render=function(){var e=kt(this),t=It(X(),e),n=!t.suspender,r=this.props,o=r.fallback,i=r.children;return n?i:t.shouldShowFallback()?o:null},t}(bt),Et=function(e){var t,n=Xe((function(e,n){return St(t.read().default,Object.assign({},e,{ref:n}),e.children)}));return n.__loadLazyComponent=function(){var n,r,o,i;t||(n=e(),o="pending",i=n.then((function(e){o="success",r=e}),(function(e){o="error",r=e})),t={read:function(){if("pending"===o)throw i;if("error"===o)throw r;if("success"===o)return r}})},n};function Ut(e){return e.children}function Pt(e,t){var n,r,o=t.__rootFiber;if(o)(n=o.current).node.props.children=e,n.processedTime=0,ee(n);else{var i=St(Ut,{},e);r=[],(n=ae(o={updateType:"sync",updateSource:"js",scheduleId:0,domNode:t,forcedUpdateWith:null,current:null,wip:null,child:null,retryFiber:null,currentTransition:null,hasUncommittedEffect:!1,pendingTransitions:[],tearDownFibers:[],postCommitEffects:[],batchUpdates:{},lastDeferredCompleteTime:0,lastCompleteTime:0,deferredUpdateTime:0,updateTime:0,afterRender:function(e){r.includes(e)||r.push(e)},callRenderCallbacks:function(){for(var e=0,t=r.length;e<t;e++)r[e]()},resetRenderCallbacks:function(){r=[]}},i,{parentNode:t,isNode:!0})).parent=o,o.current=n,t.__rootFiber=o}L((function(){o.updateSource=E(),yt(n)}))}var At=new WeakMap;function Ft(e,t){var n=Q(null,t,"");return n.nodeType=H,n.template=e,n}function Mt(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];var r=At.get(e);return r||(r=new We(e),At.set(e,r)),Ft(r,t)}function Ot(e,t){return e&&(e.portalContainer=t),e}function jt(e){var t=e.__rootFiber;return!!t&&(pe(t.current),ct(t),e.__rootFiber=void 0,!0)}var Lt={createElement:St,render:Pt,Component:bt,PureComponent:Tt,html:Mt,useState:Ie,useEffect:Ee,useRef:De,useReducer:Ne,useMemo:ke,useCallback:we,useLayoutEffect:Ue,useContext:Pe,useTransition:Ae,createContext:ve,forwardRef:Xe,createRef:Ye,createPortal:Ot,unmountComponentAtNode:jt,Suspense:xt,SuspenseList:wt,lazy:Et,unstable_deferredUpdates:j,unstable_syncUpdates:L};e.Component=bt,e.PureComponent=Tt,e.Suspense=xt,e.SuspenseList=wt,e.createContext=ve,e.createElement=St,e.createPortal=Ot,e.createRef=Ye,e.default=Lt,e.forwardRef=Xe,e.html=Mt,e.lazy=Et,e.render=Pt,e.unmountComponentAtNode=jt,e.unstable_deferredUpdates=j,e.unstable_syncUpdates=L,e.useCallback=we,e.useContext=Pe,e.useEffect=Ee,e.useLayoutEffect=Ue,e.useMemo=ke,e.useReducer=Ne,e.useRef=De,e.useState=Ie,e.useTransition=Ae,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.isRenderableNode = isRenderableNode; | ||
exports.getKey = getKey; | ||
exports.brahmosNode = brahmosNode; | ||
@@ -57,3 +58,42 @@ exports.ATTRIBUTE_NODE = exports.FUNCTIONAL_COMPONENT_NODE = exports.CLASS_COMPONENT_NODE = exports.TAG_ELEMENT_NODE = exports.TAG_NODE = void 0; | ||
} | ||
/** | ||
* Get the key of looped node | ||
*/ | ||
function getKey(node, index) { | ||
/** | ||
* Get the key from node directly if not | ||
* found search key on the values | ||
*/ | ||
var key = node && node.key; | ||
if (key === '' && node && isTagNode(node)) { | ||
/** | ||
* TODO: This might be buggy, it can give key from any node, | ||
* not necessarily key from the root node. | ||
*/ | ||
var values = node.values; | ||
for (var i = 0, ln = values.length; i < ln; i++) { | ||
var value = values[i]; | ||
if (value.key !== undefined) { | ||
key = '' + value.key; | ||
break; | ||
} | ||
} // store the calculated key on node so we don't have to search next time on same node | ||
node.key = key === undefined ? '' : '' + key; | ||
} | ||
/** | ||
* if key is defined use key or else use index as key. | ||
* Also key should always be a string | ||
*/ | ||
return key === '' ? '' + index : key; | ||
} | ||
function brahmosNode(props, values, key) { | ||
@@ -66,2 +106,3 @@ return { | ||
ref: null, | ||
portalContainer: null, | ||
@@ -71,8 +112,2 @@ /** Component specific properties */ | ||
props: props, | ||
componentInstance: null, | ||
portalContainer: null, | ||
mountHandler: null, | ||
prevProps: null, | ||
prevState: null, | ||
lastSnapshot: undefined, | ||
@@ -82,5 +117,4 @@ /** tag node specific properties */ | ||
values: values, | ||
templateNode: null, | ||
template: null | ||
}; | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
}); | ||
exports.isClassComponent = isClassComponent; | ||
exports.PureComponent = exports.Component = void 0; | ||
@@ -21,6 +22,8 @@ | ||
var _render = require("./render"); | ||
var _reRender = _interopRequireDefault(require("./reRender")); | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _updateUtils = require("./updateUtils"); | ||
var _configs = require("./configs"); | ||
var Component = | ||
@@ -33,11 +36,14 @@ /*#__PURE__*/ | ||
this.state = undefined; | ||
this.__pendingSyncUpdates = []; | ||
this.__pendingDeferredUpdates = []; | ||
this[_configs.BRAHMOS_DATA_KEY] = { | ||
lastSnapshot: null, | ||
pendingSyncUpdates: [], | ||
pendingDeferredUpdates: [], | ||
fiber: null, | ||
nodes: null, | ||
mounted: false, | ||
committedValues: {}, | ||
memoizedValues: null, | ||
isDirty: false | ||
}; | ||
this.context = undefined; | ||
this.__fiber = null; | ||
this.__componentNode = null; | ||
this.__nodes = null; | ||
this.__lastNode = null; | ||
this.__mounted = false; | ||
this.__brahmosNode = null; | ||
} | ||
@@ -48,3 +54,3 @@ | ||
value: function setState(newState, callback, type) { | ||
var updateType = (0, _updateMetaUtils.getUpdateType)(); | ||
var updateType = (0, _updateUtils.getUpdateType)(); | ||
/** | ||
@@ -61,8 +67,10 @@ * When setState is called batch all the state changes | ||
state: newState, | ||
transitionId: _updateMetaUtils.currentTransition.transitionId, | ||
transitionId: (0, _updateUtils.getCurrentTransition)().transitionId, | ||
callback: callback | ||
}; | ||
var pendingUpdateKey = (0, _updateMetaUtils.getPendingUpdatesKey)(updateType); | ||
this[pendingUpdateKey].push(stateMeta); | ||
(0, _render.reRender)(this); | ||
var pendingUpdateKey = (0, _updateUtils.getPendingUpdatesKey)(updateType); | ||
this[_configs.BRAHMOS_DATA_KEY][pendingUpdateKey].push(stateMeta); | ||
(0, _reRender["default"])(this); | ||
} | ||
@@ -72,8 +80,11 @@ }, { | ||
value: function forceUpdate(callback) { | ||
var _this = this; | ||
var brahmosData = this[_configs.BRAHMOS_DATA_KEY]; // if there is no fiber (when component is not mounted) we don't need to do anything | ||
(0, _updateMetaUtils.withUpdateSource)(_updateMetaUtils.UPDATE_SOURCE_FORCE_UPDATE, function () { | ||
(0, _render.reRender)(); | ||
if (callback) callback(_this.state); | ||
}); | ||
var fiber = brahmosData.fiber; | ||
if (!fiber) return; // keep the track of component through which force update is started | ||
fiber.root.forcedUpdateWith = this; | ||
this[_configs.BRAHMOS_DATA_KEY].isDirty = true; | ||
(0, _reRender["default"])(this); | ||
if (callback) callback(this.state); | ||
} | ||
@@ -86,3 +97,3 @@ }, { | ||
this.__nodes = nodes; | ||
this[_configs.BRAHMOS_DATA_KEY].nodes = nodes; | ||
return nodes; | ||
@@ -96,2 +107,6 @@ } | ||
function isClassComponent(element) { | ||
return element.prototype instanceof Component; | ||
} | ||
var PureComponent = | ||
@@ -102,5 +117,9 @@ /*#__PURE__*/ | ||
function PureComponent() { | ||
function PureComponent(props) { | ||
var _this; | ||
(0, _classCallCheck2["default"])(this, PureComponent); | ||
return (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(PureComponent).apply(this, arguments)); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(PureComponent).call(this, props)); | ||
_this.isPureReactComponent = true; | ||
return _this; | ||
} | ||
@@ -107,0 +126,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.XLINK_NS = exports.IS_NON_DIMENSIONAL = exports.RENAMED_EVENTS = exports.MODIFIED_ATTRIBUTES = exports.RESERVED_ATTRIBUTES = void 0; | ||
exports.EFFECT_TYPE_OTHER = exports.EFFECT_TYPE_PLACEMENT = exports.EFFECT_TYPE_NONE = exports.UPDATE_SOURCE_TRANSITION = exports.UPDATE_SOURCE_IMMEDIATE_ACTION = exports.UPDATE_SOURCE_DEFAULT = exports.UPDATE_TYPE_DEFERRED = exports.UPDATE_TYPE_SYNC = exports.LAST_ARRAY_DOM_KEY = exports.BRAHMOS_DATA_KEY = exports.XLINK_NS = exports.IS_NON_DIMENSIONAL = exports.SUSPENSE_REVEAL_INTERVAL = exports.RENAMED_EVENTS = exports.MODIFIED_ATTRIBUTES = exports.RESERVED_ATTRIBUTES = void 0; | ||
// reserved props which cannot be forward to component props | ||
@@ -24,2 +24,5 @@ var RESERVED_ATTRIBUTES = { | ||
}; | ||
exports.RENAMED_EVENTS = RENAMED_EVENTS; | ||
var SUSPENSE_REVEAL_INTERVAL = 100; // in ms | ||
/** | ||
@@ -29,3 +32,3 @@ * Regex taken from Preact. (https://github.com/preactjs/preact/blob/master/src/constants.js) | ||
exports.RENAMED_EVENTS = RENAMED_EVENTS; | ||
exports.SUSPENSE_REVEAL_INTERVAL = SUSPENSE_REVEAL_INTERVAL; | ||
var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i; | ||
@@ -38,2 +41,32 @@ /** | ||
var XLINK_NS = 'http://www.w3.org/1999/xlink'; | ||
exports.XLINK_NS = XLINK_NS; | ||
/** | ||
* Brahmos data key which shouldn't be touched | ||
*/ | ||
exports.XLINK_NS = XLINK_NS; | ||
var BRAHMOS_DATA_KEY = '__brahmosData'; | ||
exports.BRAHMOS_DATA_KEY = BRAHMOS_DATA_KEY; | ||
var LAST_ARRAY_DOM_KEY = '__brahmosLastArrayDom'; | ||
/** update type related constants */ | ||
exports.LAST_ARRAY_DOM_KEY = LAST_ARRAY_DOM_KEY; | ||
var UPDATE_TYPE_SYNC = 'sync'; | ||
exports.UPDATE_TYPE_SYNC = UPDATE_TYPE_SYNC; | ||
var UPDATE_TYPE_DEFERRED = 'deferred'; | ||
/** Update source related constants */ | ||
exports.UPDATE_TYPE_DEFERRED = UPDATE_TYPE_DEFERRED; | ||
var UPDATE_SOURCE_DEFAULT = 'js'; | ||
exports.UPDATE_SOURCE_DEFAULT = UPDATE_SOURCE_DEFAULT; | ||
var UPDATE_SOURCE_IMMEDIATE_ACTION = 'immediate_action'; | ||
exports.UPDATE_SOURCE_IMMEDIATE_ACTION = UPDATE_SOURCE_IMMEDIATE_ACTION; | ||
var UPDATE_SOURCE_TRANSITION = 'transition'; | ||
/** Effect type ENUMS */ | ||
exports.UPDATE_SOURCE_TRANSITION = UPDATE_SOURCE_TRANSITION; | ||
var EFFECT_TYPE_NONE = 0; | ||
exports.EFFECT_TYPE_NONE = EFFECT_TYPE_NONE; | ||
var EFFECT_TYPE_PLACEMENT = 1; | ||
exports.EFFECT_TYPE_PLACEMENT = EFFECT_TYPE_PLACEMENT; | ||
var EFFECT_TYPE_OTHER = 2; | ||
exports.EFFECT_TYPE_OTHER = EFFECT_TYPE_OTHER; |
@@ -21,5 +21,5 @@ "use strict"; | ||
var _Component3 = require("./Component"); | ||
var _circularDep = require("./circularDep"); | ||
var _render = require("./render"); | ||
var _fiber = require("./fiber"); | ||
@@ -31,10 +31,11 @@ var ctxId = 1; | ||
/** | ||
* NOTE: This might have to be changed when async rendering is in place | ||
* just set the correct update time on subscribed component, | ||
* and then workloop will take care of updating them. | ||
*/ | ||
setTimeout(function () { | ||
if (component.context !== value && component.__mounted) { | ||
component.context = value; | ||
(0, _render.reRender)(component); | ||
} | ||
}); | ||
var fiber = (0, _fiber.getFiberFromComponent)(component); | ||
var updateType = fiber.root.updateType; // update time only when context value has been changed | ||
if (component.context !== value) { | ||
(0, _fiber.setUpdateTime)(fiber, updateType); | ||
} | ||
}; | ||
@@ -93,3 +94,3 @@ } | ||
return Provider; | ||
}(_Component3.Component); // add metadata for provider | ||
}(_circularDep.Component); // add metadata for provider | ||
@@ -120,5 +121,4 @@ | ||
return Consumer; | ||
}(_Component3.Component); | ||
}(_circularDep.Component); | ||
; | ||
var context = { | ||
@@ -125,0 +125,0 @@ id: id, |
@@ -15,2 +15,4 @@ "use strict"; | ||
var _circularDep = require("./circularDep"); | ||
var _brahmosNode = require("./brahmosNode"); | ||
@@ -43,9 +45,8 @@ | ||
var props = _objectSpread({}, element.defaultProps, {}, (0, _utils.omit)(configs, { | ||
key: 1, | ||
ref: !element.__isForwardRef | ||
}), { | ||
var props = _objectSpread({}, element.defaultProps, {}, (0, _utils.getNormalizedProps)(configs, element.__isForwardRef), { | ||
children: children | ||
}); | ||
}); // if the element is a lazy component, start fetching the underlying component | ||
if (element.__loadLazyComponent) element.__loadLazyComponent(); | ||
var _configs$key = configs.key, | ||
@@ -55,3 +56,3 @@ key = _configs$key === void 0 ? '' : _configs$key, | ||
var _isClassComponent = (0, _utils.isClassComponent)(element); | ||
var _isClassComponent = (0, _circularDep.isClassComponent)(element); | ||
@@ -58,0 +59,0 @@ var node = (0, _brahmosNode.brahmosNode)(props, null, '' + key); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,4 +8,2 @@ value: true | ||
var _render = _interopRequireDefault(require("./render")); | ||
/** | ||
@@ -18,6 +14,5 @@ * Render children outside the main DOM hierarchy of | ||
function createPortal(child, container) { | ||
// mark the child node as ported node | ||
child.portalContainer = container; | ||
(0, _render["default"])(child, container); // We need to return the rendered child node so that life cycles are handled properly on render flow | ||
// add portal container information in child | ||
// which we can use for forming the part | ||
if (child) child.portalContainer = container; | ||
return child; | ||
@@ -24,0 +19,0 @@ } |
@@ -8,3 +8,5 @@ "use strict"; | ||
}); | ||
exports.resetEffectList = resetEffectList; | ||
exports.resetEffectProperties = resetEffectProperties; | ||
exports.removeTransitionFromRoot = removeTransitionFromRoot; | ||
exports.preCommitBookkeeping = preCommitBookkeeping; | ||
exports["default"] = effectLoop; | ||
@@ -18,3 +20,3 @@ | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _updateUtils = require("./updateUtils"); | ||
@@ -25,2 +27,8 @@ var _hooks = require("./hooks"); | ||
var _configs = require("./configs"); | ||
var _fiber2 = require("./fiber"); | ||
var _refs = require("./refs"); | ||
/** | ||
@@ -31,47 +39,74 @@ * Updater to handle text node | ||
var part = fiber.part, | ||
node = fiber.node; | ||
node = fiber.node, | ||
alternate = fiber.alternate; | ||
var parentNode = part.parentNode, | ||
previousSibling = part.previousSibling, | ||
nextSibling = part.nextSibling; | ||
previousSibling = part.previousSibling; | ||
/** | ||
* get the last text node | ||
* As we always override the text node and don't change the position of | ||
* text node, Always send nextSibling as null to getCurrentNode | ||
* So we always pick the text node based on previousSibling | ||
* or parentNode (if prevSibling is null). | ||
* Get the next sibling before which we need to append the text node. | ||
*/ | ||
var textNode = (0, _utils.getCurrentNode)(parentNode, previousSibling, null); | ||
var nextSibling = (0, _utils.getNextSibling)(parentNode, previousSibling); | ||
/** | ||
* The nextSibling will point to text node if the tag fiber is already rendered | ||
* In which case we just have to update the node value of the nextSibling | ||
*/ | ||
if (!textNode) { | ||
if (alternate) { | ||
// if we have text node just update the text node | ||
nextSibling.nodeValue = node; | ||
} else { | ||
// add nodes at the right location | ||
textNode = (0, _utils.insertBefore)(parentNode, nextSibling, node); | ||
} else { | ||
// if we have text node just update the text node | ||
textNode.textContent = node; | ||
(0, _utils.insertBefore)(parentNode, nextSibling, node); | ||
} | ||
} | ||
return textNode; | ||
function getTagChild(fiber) { | ||
while (fiber.node && !(0, _brahmosNode.isTagNode)(fiber.node)) { | ||
fiber = fiber.child; | ||
} | ||
return fiber; | ||
} | ||
function updateExistingNode(templateNode, part, oldPart, root) { | ||
// if it is not a part of array item, no need to rearrange | ||
function setLastItemInParentDOM(parentNode, nodeInstance) { | ||
var domNodes = nodeInstance.domNodes; | ||
parentNode[_configs.LAST_ARRAY_DOM_KEY] = domNodes[domNodes.length - 1]; | ||
} | ||
function getCorrectPreviousSibling(part) { | ||
var previousSibling = part.previousSibling; | ||
if (part.isArrayNode) { | ||
previousSibling = part.nodeIndex === 0 ? previousSibling : part.parentNode[_configs.LAST_ARRAY_DOM_KEY]; | ||
} | ||
return previousSibling; | ||
} | ||
function reArrangeExistingNode(fiber, alternate) { | ||
var part = fiber.part; | ||
if (!part.isArrayNode) return; | ||
var domNodes = templateNode.domNodes; | ||
var nodeIndex = part.nodeIndex, | ||
parentNode = part.parentNode, | ||
previousSibling = part.previousSibling; | ||
var oldNodeIndex = oldPart.nodeIndex; // if the item position on last render and current render is same, no need to rearrange | ||
parentNode = part.parentNode; | ||
var oldNodeIndex = alternate.part.nodeIndex; | ||
var tagChild = getTagChild(fiber); | ||
var nodeInstance = tagChild.nodeInstance; // if there is no nodeInstance or if tagChild has pendingEffects bail out from rearrange in component level | ||
if (nodeIndex === oldNodeIndex) return; // if it is first item append it after the previous sibling or else append it after last rendered element. | ||
var componentChildHasEffect = tagChild !== fiber && tagChild.hasUncommittedEffect; | ||
if (!nodeInstance || componentChildHasEffect) return; // if the item position on last render and current render is not same, then do a rearrange | ||
var appendAfter = nodeIndex === 0 ? previousSibling : root.lastArrayDOM; // get the element before which we have to add the new node | ||
if (nodeIndex !== oldNodeIndex) { | ||
var domNodes = nodeInstance.domNodes; | ||
var previousSibling = getCorrectPreviousSibling(part); | ||
var nextSibling = (0, _utils.getNextSibling)(parentNode, previousSibling); // if there is dom node and it isn't in correct place rearrange the nodes | ||
var appendBefore = appendAfter ? appendAfter.nextSibling : parentNode.firstChild; // if there is dom node and it isn't in correct place rearrange the nodes | ||
var firstDOMNode = domNodes[0]; | ||
var firstDOMNode = domNodes[0]; | ||
if (firstDOMNode && firstDOMNode.previousSibling !== previousSibling && firstDOMNode !== nextSibling) { | ||
(0, _utils.insertBefore)(parentNode, nextSibling, domNodes); | ||
} | ||
} // set the last item of domNodes in parentNode | ||
if (firstDOMNode && firstDOMNode.previousSibling !== appendAfter && firstDOMNode !== appendBefore) { | ||
(0, _utils.insertBefore)(parentNode, appendBefore, domNodes); | ||
} | ||
setLastItemInParentDOM(parentNode, nodeInstance); | ||
} | ||
@@ -81,20 +116,21 @@ | ||
var part = fiber.part, | ||
templateNode = fiber.node.templateNode, | ||
alternate = fiber.alternate, | ||
root = fiber.root; | ||
var parentNode = part.parentNode, | ||
nextSibling = part.nextSibling; // if the alternate node is there rearrange the element if required, or else just add the new node | ||
nodeInstance = fiber.nodeInstance, | ||
alternate = fiber.alternate; | ||
var parentNode = part.parentNode; // if the alternate node is there rearrange the element if required, or else just add the new node | ||
if (alternate) { | ||
updateExistingNode(templateNode, part, alternate.part, root); | ||
reArrangeExistingNode(fiber, alternate); | ||
} else { | ||
var previousSibling = getCorrectPreviousSibling(part); | ||
var nextSibling = (0, _utils.getNextSibling)(parentNode, previousSibling); | ||
/** | ||
* when we add nodes first time | ||
* and we are rendering as fragment it means the fragment might have childNodes | ||
* which templateNode does not have, so for such cases we should reset nodeList on templateNode; | ||
* which nodeInstance does not have, so for such cases we should reset nodeList on nodeInstance; | ||
*/ | ||
templateNode.domNodes = (0, _utils.insertBefore)(parentNode, nextSibling, templateNode.fragment); | ||
nodeInstance.domNodes = (0, _utils.insertBefore)(parentNode, nextSibling, nodeInstance.fragment); // set the last item of domNodes in parentNode | ||
setLastItemInParentDOM(parentNode, nodeInstance); | ||
} | ||
root.lastArrayDOM = templateNode.domNodes[templateNode.domNodes.length - 1]; | ||
} | ||
@@ -104,28 +140,25 @@ | ||
var node = fiber.node, | ||
nodeInstance = fiber.nodeInstance, | ||
root = fiber.root; | ||
var updateType = root.updateType, | ||
pendingTransitions = root.pendingTransitions; | ||
var componentInstance = node.componentInstance, | ||
nodeType = node.nodeType, | ||
prevProps = node.prevProps, | ||
prevState = node.prevState; | ||
var updateType = root.updateType; | ||
var nodeType = node.nodeType; | ||
var brahmosData = nodeInstance[_configs.BRAHMOS_DATA_KEY]; | ||
if (nodeType === _brahmosNode.CLASS_COMPONENT_NODE) { | ||
node.lastSnapshot = (0, _utils.callLifeCycle)(componentInstance, 'getSnapshotBeforeUpdate', [prevProps, prevState]); | ||
} // remove all the transitions with current transition id as its already flushed | ||
var _brahmosData$committe = brahmosData.committedValues, | ||
prevProps = _brahmosData$committe.props, | ||
prevState = _brahmosData$committe.state; | ||
brahmosData.lastSnapshot = (0, _utils.callLifeCycle)(nodeInstance, 'getSnapshotBeforeUpdate', [prevProps, prevState]); | ||
} // remove all the pending updates associated with current transition | ||
var currentTransition = (0, _transitionUtils.getTransitionFromFiber)(componentInstance.__fiber); | ||
var currentTransitionId = currentTransition.transitionId; | ||
var pendingUpdatesKey = (0, _updateMetaUtils.getPendingUpdatesKey)(updateType); | ||
componentInstance[pendingUpdatesKey] = componentInstance[pendingUpdatesKey].filter(function (stateMeta) { | ||
return stateMeta.transitionId !== currentTransitionId; | ||
}); // remove the currentTransition from the pending transition | ||
var _getTransitionFromFib = (0, _transitionUtils.getTransitionFromFiber)(fiber), | ||
transitionId = _getTransitionFromFib.transitionId; | ||
var currentTransitionIndex = pendingTransitions.indexOf(currentTransition); | ||
var pendingUpdatesKey = (0, _updateUtils.getPendingUpdatesKey)(updateType); | ||
brahmosData[pendingUpdatesKey] = brahmosData[pendingUpdatesKey].filter(function (stateMeta) { | ||
return stateMeta.transitionId !== transitionId; | ||
}); // reset isDirty flag | ||
if (currentTransitionIndex !== -1) { | ||
pendingTransitions.splice(currentTransitionIndex, 1); | ||
} | ||
brahmosData.isDirty = false; | ||
root.postCommitEffects.push(fiber); | ||
@@ -135,10 +168,19 @@ } | ||
function handleComponentPostCommitEffect(fiber) { | ||
var node = fiber.node; | ||
var componentInstance = node.componentInstance, | ||
nodeType = node.nodeType, | ||
prevProps = node.prevProps, | ||
prevState = node.prevState, | ||
lastSnapshot = node.lastSnapshot; | ||
var node = fiber.node, | ||
nodeInstance = fiber.nodeInstance, | ||
root = fiber.root, | ||
childFiberError = fiber.childFiberError; | ||
var updateType = root.updateType; | ||
var nodeType = node.nodeType, | ||
ref = node.ref; | ||
var brahmosData = nodeInstance[_configs.BRAHMOS_DATA_KEY]; | ||
if (nodeType === _brahmosNode.CLASS_COMPONENT_NODE) { | ||
var props = nodeInstance.props, | ||
state = nodeInstance.state; | ||
var committedValues = brahmosData.committedValues, | ||
lastSnapshot = brahmosData.lastSnapshot; // get the previous state and prevProps | ||
var prevProps = committedValues.props, | ||
prevState = committedValues.state; | ||
/** | ||
@@ -148,11 +190,37 @@ * if it is first time rendered call componentDidMount or else call componentDidUpdate | ||
*/ | ||
if (!prevProps) { | ||
(0, _utils.callLifeCycle)(componentInstance, 'componentDidMount'); | ||
(0, _utils.callLifeCycle)(nodeInstance, 'componentDidMount'); | ||
} else { | ||
(0, _utils.callLifeCycle)(componentInstance, 'componentDidUpdate', [prevProps, prevState, lastSnapshot]); | ||
(0, _utils.callLifeCycle)(nodeInstance, 'componentDidUpdate', [prevProps, prevState, lastSnapshot]); | ||
} | ||
if (childFiberError) { | ||
(0, _utils.callLifeCycle)(nodeInstance, 'componentDidCatch', [childFiberError.error, childFiberError.errorInfo]); // reset the error | ||
fiber.childFiberError = null; | ||
} // if the component node has ref call the ref with the node instance | ||
if (ref) (0, _refs.setRef)(ref, nodeInstance); // after commit is done set the current prop and state on committed values | ||
committedValues.props = props; | ||
committedValues.state = state; | ||
brahmosData.memoizedValues = null; | ||
} else { | ||
// call effects of functional component | ||
(0, _hooks.runEffects)(componentInstance); | ||
} | ||
(0, _hooks.runEffects)(fiber); // switch deferred hooks array and syncHooks hooks array, if it is deferred state update | ||
if (updateType === _configs.UPDATE_TYPE_DEFERRED) { | ||
var syncHooks = nodeInstance.syncHooks, | ||
deferredHooks = nodeInstance.deferredHooks; | ||
nodeInstance.deferredHooks = syncHooks; | ||
nodeInstance.syncHooks = deferredHooks; | ||
} | ||
} // mark component as mounted | ||
brahmosData.mounted = true; // add fiber reference on component instance, so the component is aware of its fiber | ||
brahmosData.fiber = fiber; | ||
} | ||
@@ -163,26 +231,57 @@ | ||
node = fiber.node, | ||
alternate = fiber.alternate; | ||
alternate = fiber.alternate, | ||
isSvgPart = fiber.isSvgPart; | ||
var domNode = part.domNode; | ||
var attributes = node.attributes; | ||
var attributes = node.attributes, | ||
ref = node.ref; | ||
var oldAttributes = alternate && alternate.node.attributes; // TODO: Fix svg case | ||
(0, _updateAttribute["default"])(domNode, attributes, oldAttributes, false); // Handle value resets | ||
(0, _updateAttribute["default"])(domNode, attributes, oldAttributes, isSvgPart); // set ref if present | ||
if (ref) (0, _refs.setRef)(ref, domNode); | ||
} | ||
function resetEffectList(root) { | ||
root.lastEffectFiber = root; | ||
root.nextEffect = null; | ||
function resetEffectProperties(root) { | ||
root.tearDownFibers = []; | ||
root.postCommitEffects = []; | ||
root.lastArrayDOM = null; | ||
root.hasUncommittedEffect = false; // reset after render callbacks | ||
root.resetRenderCallbacks(); | ||
} | ||
/** | ||
* reset properties which are not required in future | ||
* of alternate fiber so those property values can be garbage collected | ||
*/ | ||
function effectLoop(root) { | ||
var fiber = root.nextEffect, | ||
postCommitEffects = root.postCommitEffects; | ||
while (fiber) { | ||
var _fiber = fiber, | ||
node = _fiber.node; | ||
function resetAlternate(alternate) { | ||
alternate.node = null; | ||
alternate.nodeInstance = null; | ||
alternate.child = null; | ||
alternate.sibling = null; | ||
} | ||
function removeTransitionFromRoot(root) { | ||
var currentTransition = root.currentTransition, | ||
pendingTransitions = root.pendingTransitions; | ||
var currentTransitionIndex = pendingTransitions.indexOf(currentTransition); | ||
if (currentTransitionIndex !== -1) { | ||
pendingTransitions.splice(currentTransitionIndex, 1); | ||
} | ||
} | ||
function handleFiberEffect(fiber) { | ||
var node = fiber.node, | ||
alternate = fiber.alternate; | ||
var _isComponentNode = node && (0, _brahmosNode.isComponentNode)(node); // if the fiber is part of an array and requires rearrange then do it | ||
if (_isComponentNode && alternate) { | ||
reArrangeExistingNode(fiber, alternate); | ||
} // if node has uncommitted effect, handle the effect | ||
if (fiber.hasUncommittedEffect === _configs.EFFECT_TYPE_OTHER) { | ||
if ((0, _brahmosNode.isPrimitiveNode)(node)) { | ||
@@ -192,21 +291,108 @@ updateTextNode(fiber); | ||
updateTagNode(fiber); // TODO: Handle rearrange type of effect | ||
} else if ((0, _brahmosNode.isComponentNode)(node)) { | ||
} else if (_isComponentNode) { | ||
handleComponentEffect(fiber); | ||
} else if (node.nodeType === _brahmosNode.ATTRIBUTE_NODE) { | ||
handleAttributeEffect(fiber); | ||
} // reset the hasUncommittedEffect flag | ||
fiber.hasUncommittedEffect = false; | ||
} | ||
/** | ||
* once the fiber is committed, we can remove child and sibling link from alternate, | ||
* so unused child and sibling fiber (if not linked as alternate of any current node) | ||
* can be garbage collected | ||
*/ | ||
if (alternate) { | ||
resetAlternate(alternate); | ||
} | ||
} | ||
/** | ||
* Fix pointers on fibers, and return the fibers with effects | ||
*/ | ||
function preCommitBookkeeping(root) { | ||
var updateType = root.updateType, | ||
wip = root.wip, | ||
current = root.current; | ||
var updateTimeKey = (0, _fiber2.getUpdateTimeKey)(updateType); | ||
var lastCompleteTime = root[(0, _fiber2.getLastCompleteTimeKey)(updateType)]; | ||
var fibersWithEffect = []; | ||
var fiber = updateType === _configs.UPDATE_TYPE_SYNC ? current : wip; | ||
while (fiber) { | ||
var _fiber = fiber, | ||
createdAt = _fiber.createdAt, | ||
node = _fiber.node, | ||
child = _fiber.child, | ||
hasUncommittedEffect = _fiber.hasUncommittedEffect; | ||
var updateTime = fiber[updateTimeKey]; | ||
var fiberIsNew = createdAt > lastCompleteTime; | ||
var hierarchyHasUpdates = hasUncommittedEffect || updateTime > lastCompleteTime; | ||
if (hasUncommittedEffect) { | ||
// push fiber in new fiber list | ||
fibersWithEffect.push(fiber); | ||
} // correct the references | ||
if (fiberIsNew) { | ||
/** | ||
* if child is there and it does not point back to correct parent | ||
* set the pointer back to parent. This can happen if the fiber is new | ||
* but the child is an existing fiber. This can happen when we haven't | ||
* processed fiber and just cloned from the current tree | ||
* We don't do this during rendering phase to not disturb the current tree | ||
*/ | ||
if (child && child.parent !== fiber) child.parent = fiber; | ||
/** | ||
* If fiber is new and it is a component node we will need update the fiber | ||
* reference in the component node | ||
*/ | ||
if (node && (0, _brahmosNode.isComponentNode)(node)) { | ||
fiber.nodeInstance[_configs.BRAHMOS_DATA_KEY].fiber = fiber; | ||
} | ||
} | ||
/** | ||
* do a depth first traversal, | ||
* go to child fiber only if the fiber is new, if its not | ||
* it means no child has updates | ||
*/ | ||
var nextEffect = fiber.nextEffect; // reset effect key of that fiber. | ||
fiber.nextEffect = null; | ||
fiber = nextEffect; | ||
} // after applying the effects run all the post effects | ||
if (child && hierarchyHasUpdates) fiber = child;else { | ||
while (fiber !== root && !fiber.sibling) { | ||
fiber = fiber.parent; | ||
} | ||
fiber = fiber.sibling; | ||
} | ||
} | ||
for (var i = postCommitEffects.length - 1; i >= 0; i--) { | ||
handleComponentPostCommitEffect(postCommitEffects[i]); | ||
} // once all effect has been processed update root's last effect node and reset lastArrayDOM and postCommitEffects | ||
return fibersWithEffect; | ||
} | ||
function effectLoop(root, fibersWithEffect) { | ||
// loop on new fibers hand call if effect needs to be called | ||
for (var i = 0, ln = fibersWithEffect.length; i < ln; i++) { | ||
handleFiberEffect(fibersWithEffect[i]); | ||
} | ||
resetEffectList(root); | ||
var postCommitEffects = root.postCommitEffects; // after applying the effects run all the post effects | ||
for (var _i = postCommitEffects.length - 1; _i >= 0; _i--) { | ||
handleComponentPostCommitEffect(postCommitEffects[_i]); | ||
} // remove the current transition from pending transition | ||
removeTransitionFromRoot(root); // once all effect has been processed update root's last effect node and postCommitEffects | ||
resetEffectProperties(root); // clear the requestIdleHandle abd force update node from root only after the effect | ||
root.requestIdleHandle = null; | ||
root.forcedUpdateWith = null; | ||
} |
241
lib/fiber.js
@@ -6,6 +6,8 @@ "use strict"; | ||
}); | ||
exports.setCurrentFiber = setCurrentFiber; | ||
exports.getCurrentFiber = getCurrentFiber; | ||
exports.setCurrentComponentFiber = setCurrentComponentFiber; | ||
exports.getCurrentComponentFiber = getCurrentComponentFiber; | ||
exports.getLastCompleteTimeKey = getLastCompleteTimeKey; | ||
exports.getUpdateTimeKey = getUpdateTimeKey; | ||
exports.setUpdateTime = setUpdateTime; | ||
exports.markPendingEffect = markPendingEffect; | ||
exports.cloneCurrentFiber = cloneCurrentFiber; | ||
@@ -16,32 +18,31 @@ exports.getNextChildFiber = getNextChildFiber; | ||
exports.createFiber = createFiber; | ||
exports.link = link; | ||
exports.linkEffect = linkEffect; | ||
exports.addAlternates = addAlternates; | ||
exports.createAndLink = createAndLink; | ||
exports.createCurrentAndLink = createCurrentAndLink; | ||
exports.getNextFiber = getNextFiber; | ||
exports.fibers = void 0; | ||
exports.getFiberFromComponent = getFiberFromComponent; | ||
exports.resetToCommittedChild = resetToCommittedChild; | ||
exports.markToTearDown = markToTearDown; | ||
var _brahmosNode = require("./brahmosNode"); | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _configs = require("./configs"); | ||
var fibers = { | ||
workInProgress: null, | ||
current: null, | ||
currentFiber: null | ||
}; | ||
exports.fibers = fibers; | ||
var currentFiber; | ||
var _utils = require("./utils"); | ||
function setCurrentFiber(fiber) { | ||
currentFiber = fiber; | ||
var currentComponentFiber; | ||
function setCurrentComponentFiber(fiber) { | ||
currentComponentFiber = fiber; | ||
} | ||
function getCurrentFiber() { | ||
return currentFiber; | ||
function getCurrentComponentFiber() { | ||
return currentComponentFiber; | ||
} | ||
function getLastCompleteTimeKey(type) { | ||
return type === _configs.UPDATE_TYPE_DEFERRED ? 'lastDeferredCompleteTime' : 'lastCompleteTime'; | ||
} | ||
function getUpdateTimeKey(type) { | ||
return type === _updateMetaUtils.UPDATE_TYPE_DEFERRED ? 'deferredUpdateTime' : 'updateTime'; | ||
return type === _configs.UPDATE_TYPE_DEFERRED ? 'deferredUpdateTime' : 'updateTime'; | ||
} | ||
@@ -51,3 +52,3 @@ | ||
var key = getUpdateTimeKey(type); | ||
var time = performance.now(); | ||
var time = (0, _utils.now)(); | ||
@@ -69,12 +70,20 @@ while (fiber) { | ||
fiber.parent = parentFiber; | ||
} // function to mark pending effects on the fiber and root | ||
function markPendingEffect(fiber, effectType) { | ||
fiber.hasUncommittedEffect = effectType; | ||
fiber.root.hasUncommittedEffect = true; | ||
} | ||
function cloneCurrentFiber(fiber, wipFiber, refFiber, parentFiber) { | ||
var node = fiber.node, | ||
var root = fiber.root, | ||
node = fiber.node, | ||
part = fiber.part, | ||
child = fiber.child, | ||
sibling = fiber.sibling; | ||
nodeInstance = fiber.nodeInstance, | ||
child = fiber.child; | ||
var updateTimeKey = getUpdateTimeKey(root.updateType); | ||
if (!wipFiber) { | ||
wipFiber = createFiber(fiber.root, node, part); // add fibers as each others alternate | ||
wipFiber = createFiber(root, node, part); // add fibers as each others alternate | ||
@@ -85,11 +94,33 @@ addAlternates(fiber, wipFiber); | ||
wipFiber.part = part; | ||
/** | ||
* As the cloned node is treated as new fiber, reset the createdAt time | ||
*/ | ||
wipFiber.createdAt = (0, _utils.now)(); | ||
} | ||
/** | ||
* add the current child and sibling to wipFiber | ||
* When we are cloning a fiber we should prevent the fiber to tear down | ||
* A fiber can be marked for tearDown but after suspend (through suspense) / or error boundaries | ||
* it can be used again making the tear down stale. | ||
*/ | ||
fiber.shouldTearDown = false; // add the nodeInstance to cloned fiber | ||
wipFiber.nodeInstance = nodeInstance; | ||
/** | ||
* Add the current child to wipFiber. | ||
* This is required so that new fiber is pointing to the existing child fiber | ||
* Note: We don't need to copy sibling as it will be set by loop, from where ever | ||
* the cloneMethod is called. | ||
* So make sure clone method is not called for only a single child if there multiple child. | ||
* */ | ||
wipFiber.child = child; | ||
wipFiber.sibling = sibling; // link the new fiber to its parent or it's previous sibling | ||
/** | ||
* We should add update times from parent fiber. | ||
*/ | ||
wipFiber[updateTimeKey] = parentFiber[updateTimeKey]; // link the new fiber to its parent or it's previous sibling | ||
linkFiber(wipFiber, refFiber, parentFiber); | ||
@@ -108,3 +139,2 @@ return wipFiber; | ||
* No need to clone children if the updateType is sync, | ||
* also do not clone children if the children are already newer fiber than the parent | ||
*/ | ||
@@ -123,8 +153,7 @@ | ||
* If it doesn't have any alternate node it means this is a new node, | ||
* so need to clone them again | ||
* so need to create them again | ||
*/ | ||
var _child = child, | ||
alternate = _child.alternate; | ||
cloneCurrentFiber(child, alternate, lastChild || parent, parent); | ||
lastChild = child; | ||
lastChild = cloneCurrentFiber(child, alternate, lastChild || fiber, fiber); | ||
child = child.sibling; | ||
@@ -135,11 +164,15 @@ } | ||
function createHostFiber(domNode) { | ||
var rootFiber = { | ||
var afterRenderCallbacks = []; | ||
return { | ||
updateType: 'sync', | ||
updateSource: 'js', | ||
scheduleId: 0, | ||
domNode: domNode, | ||
idleCallback: null, | ||
forcedUpdateWith: null, | ||
current: null, | ||
wip: null, | ||
lastEffectFiber: null, | ||
lastSuspenseFiber: null, | ||
preventSchedule: false, | ||
child: null, | ||
retryFiber: null, | ||
currentTransition: null, | ||
hasUncommittedEffect: false, | ||
pendingTransitions: [], | ||
@@ -149,17 +182,34 @@ tearDownFibers: [], | ||
batchUpdates: {}, | ||
nextEffect: null, | ||
alternate: null, | ||
lastDeferredCompleteTime: 0, | ||
lastCompleteTime: 0, | ||
deferredUpdateTime: 0, | ||
updateTime: 0 | ||
}; // check if this has any performance hit | ||
updateTime: 0, | ||
rootFiber.lastEffectFiber = rootFiber; | ||
return rootFiber; | ||
/** After render utils */ | ||
afterRender: function afterRender(cb) { | ||
// if the callback is not already added add the callback | ||
if (!afterRenderCallbacks.includes(cb)) { | ||
afterRenderCallbacks.push(cb); | ||
} | ||
}, | ||
callRenderCallbacks: function callRenderCallbacks() { | ||
for (var i = 0, ln = afterRenderCallbacks.length; i < ln; i++) { | ||
afterRenderCallbacks[i](); | ||
} | ||
}, | ||
resetRenderCallbacks: function resetRenderCallbacks() { | ||
afterRenderCallbacks = []; | ||
} | ||
}; | ||
} | ||
function createFiber(root, node, part) { | ||
// if a node is ported node, update the part information | ||
if (node && node.portalContainer) { | ||
part.parentNode = node.portalContainer; | ||
} | ||
return { | ||
node: node, | ||
nodeInstance: null, | ||
root: root, | ||
@@ -174,38 +224,14 @@ parent: null, | ||
// Points to the context applicable for that fiber | ||
suspense: null, | ||
errorBoundary: null, | ||
isSVG: false, | ||
nextEffect: null, | ||
childFiberError: null, | ||
isSvgPart: false, | ||
deferredUpdateTime: 0, | ||
updateTime: 0, | ||
processedTime: 0 // processedTime 0 signifies it needs processing | ||
processedTime: 0, | ||
// processedTime 0 signifies it needs processing | ||
createdAt: (0, _utils.now)(), | ||
shouldTearDown: false, | ||
hasUncommittedEffect: _configs.EFFECT_TYPE_NONE | ||
}; | ||
} // create a linked list through parent and child | ||
function link(parent, children) { | ||
var lastChild = null; | ||
for (var i = children.length - 1; i >= 0; i--) { | ||
var child = children[i]; | ||
child.sibling = lastChild; | ||
child.parent = parent; | ||
} | ||
parent.child = lastChild; | ||
} | ||
/** | ||
* link fibers with effect | ||
*/ | ||
function linkEffect(fiber) { | ||
var root = fiber.root; // to the last effect fiber link the fiber as next effect | ||
root.lastEffectFiber.nextEffect = fiber; // store fiber as last fiber with effect | ||
root.lastEffectFiber = fiber; | ||
} | ||
/** | ||
* add to fibers as alternate to each other | ||
@@ -228,3 +254,3 @@ */ | ||
if (currentFiber && shouldClone(node, currentFiber.node)) { | ||
if (currentFiber && !(0, _utils.isNil)(currentFiber.node) && !(0, _utils.isNil)(node) && shouldClone(node, currentFiber.node)) { | ||
fiber = cloneCurrentFiber(currentFiber, currentFiber.alternate, refFiber, parentFiber); // assign new node and part to the fiber | ||
@@ -238,3 +264,3 @@ | ||
if (currentFiber) { | ||
root.tearDownFibers.push(currentFiber); | ||
markToTearDown(currentFiber); | ||
} | ||
@@ -248,13 +274,6 @@ } | ||
fiber.context = parentFiber.context; | ||
fiber.isSVG = parentFiber.isSVG; | ||
fiber.suspense = parentFiber.suspense; | ||
fiber.errorBoundary = parentFiber.errorBoundary; | ||
fiber.isSvgPart = parentFiber.isSvgPart; | ||
return fiber; | ||
} | ||
function createCurrentAndLink(node, part, refFiber, parentFiber) { | ||
var currentFiber = getNextChildFiber(refFiber, parentFiber); | ||
return createAndLink(node, part, currentFiber, refFiber, parentFiber); | ||
} | ||
function shouldClone(newNode, oldNode) { | ||
@@ -306,2 +325,56 @@ return (// if it is primitive node and old node is also primitive we can clone the previous fiber | ||
return sibling; | ||
} | ||
} | ||
/** Function to get fiber from the component */ | ||
function getFiberFromComponent(component) { | ||
return component[_configs.BRAHMOS_DATA_KEY].fiber; | ||
} | ||
/** | ||
* Function to reset child to committed fiber. | ||
* This is a usual case when we interrupt workLoop, the fiber might be pointing to | ||
* the wrong uncommitted fiber, in which case we reset it to the alternate | ||
* (which points to the committed one) | ||
*/ | ||
function resetToCommittedChild(fiber) { | ||
var root = fiber.root, | ||
child = fiber.child, | ||
alternate = fiber.alternate; | ||
/** | ||
* if the child fiber is created but not committed yet, | ||
* reset the child fiber to alternate child | ||
*/ | ||
if (child && child.createdAt > root.lastCompleteTime) { | ||
fiber.child = alternate && alternate.child; | ||
} | ||
} | ||
/** | ||
* function to push a fiber for tearDown | ||
*/ | ||
function markToTearDown(fiber) { | ||
fiber.shouldTearDown = true; | ||
fiber.root.tearDownFibers.push(fiber); | ||
} // NOTE: Delete this function | ||
// window.getBrokenLink = (fiber) => { | ||
// const current = fiber.root.current; | ||
// fiber = current; | ||
// while (fiber) { | ||
// if (fiber.child && fiber.child.parent !== fiber) return fiber; | ||
// fiber = fiber.child; | ||
// } | ||
// }; | ||
// window.belongsTo = (fiber) => { | ||
// while (fiber) { | ||
// if (fiber.parent === fiber.root.wip) { | ||
// return 'wip'; | ||
// } else if (fiber.parent === fiber.root.current) { | ||
// return 'current'; | ||
// } | ||
// fiber = fiber.parent; | ||
// } | ||
// }; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,18 +10,27 @@ value: true | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _hooks = require("./hooks"); | ||
var _configs = require("./configs"); | ||
function functionalComponentInstance(FuncComponent) { | ||
return { | ||
return (0, _defineProperty2["default"])({ | ||
syncHooks: [], | ||
deferredHooks: [], | ||
__pendingSyncUpdates: [], | ||
__pendingDeferredUpdates: [], | ||
__fiber: null, | ||
pointer: 0, | ||
__render: function __render(props) { | ||
(0, _hooks.setCurrentComponent)(this); | ||
(0, _hooks.prepareHooksForRender)(this); | ||
var nodes = FuncComponent(props); | ||
this.__nodes = nodes; | ||
this[_configs.BRAHMOS_DATA_KEY].nodes = nodes; | ||
return nodes; | ||
} | ||
}; | ||
}, _configs.BRAHMOS_DATA_KEY, { | ||
pendingSyncUpdates: [], | ||
pendingDeferredUpdates: [], | ||
fiber: null, | ||
nodes: null, | ||
isDirty: false, | ||
mounted: false | ||
}); | ||
} |
207
lib/hooks.js
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.setCurrentComponent = setCurrentComponent; | ||
exports.prepareHooksForRender = prepareHooksForRender; | ||
exports.useState = useState; | ||
@@ -27,3 +27,3 @@ exports.useRef = useRef; | ||
var _render = require("./render"); | ||
var _reRender = _interopRequireDefault(require("./reRender")); | ||
@@ -34,6 +34,10 @@ var _createContext = require("./createContext"); | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _configs = require("./configs"); | ||
var _updateUtils = require("./updateUtils"); | ||
var _transitionUtils = require("./transitionUtils"); | ||
var _fiber = require("./fiber"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -43,13 +47,4 @@ | ||
/** | ||
* TODO: Rename currentComponent to currentComponentInstance | ||
* and component to component | ||
*/ | ||
var currentComponent; | ||
/** | ||
* get updateType from component | ||
*/ | ||
function getUpdateTypeFromComponent(component) { | ||
return component.__fiber.root.updateType; | ||
function getCurrentComponent() { | ||
return (0, _fiber.getCurrentComponentFiber)().nodeInstance; | ||
} | ||
@@ -61,6 +56,12 @@ /** | ||
function cloneHooks(hooks) { | ||
return hooks.map(function (hook) { | ||
function cloneHooks(component) { | ||
component.deferredHooks = component.syncHooks.map(function (hook, index) { | ||
if (Array.isArray(hook)) { | ||
return (0, _toConsumableArray2["default"])(hook); | ||
} else if (hook.transitionId) { | ||
/** | ||
* Transition hooks are shared across sync and deferred hooks, | ||
* so use the same instance of hook don't clone it | ||
*/ | ||
return hook; | ||
} | ||
@@ -79,5 +80,15 @@ | ||
deferredHooks = component.deferredHooks; | ||
return updateType === _updateMetaUtils.UPDATE_TYPE_SYNC ? syncHooks : deferredHooks; | ||
return updateType === _configs.UPDATE_TYPE_SYNC ? syncHooks : deferredHooks; | ||
} | ||
/** | ||
* Get the current hooks array from the fiber | ||
*/ | ||
function getHooksListFromFiber(fiber) { | ||
var nodeInstance = fiber.nodeInstance, | ||
updateType = fiber.root.updateType; | ||
return getHooksList(updateType, nodeInstance); | ||
} | ||
/** | ||
* Get current hook, based on the type of update we are doing | ||
@@ -89,6 +100,13 @@ * If it is inside transition of deferred update we need deferredHooksList, | ||
function getCurrentHook(updateType, component) { | ||
var pointer = component.pointer; | ||
function getCurrentHook(updateType, hookIndex, component) { | ||
/** | ||
* if deferred hooks is not populated clone from the syncHooks | ||
* This will happen if the component has never been rendered in deferred mode. | ||
*/ | ||
if (updateType === _configs.UPDATE_TYPE_DEFERRED && !component.deferredHooks.length) { | ||
cloneHooks(component); | ||
} | ||
var hooks = getHooksList(updateType, component); | ||
return hooks[pointer]; | ||
return hooks[hookIndex]; | ||
} | ||
@@ -117,3 +135,3 @@ /** | ||
if (!Object.is(state, lastState)) { | ||
(0, _render.reRender)(component); | ||
(0, _reRender["default"])(component); | ||
} | ||
@@ -136,6 +154,6 @@ } | ||
}; | ||
var _currentComponent = currentComponent, | ||
pointer = _currentComponent.pointer; | ||
var updateType = getUpdateTypeFromComponent(currentComponent); | ||
var hooks = getHooksList(updateType, currentComponent); | ||
var fiber = (0, _fiber.getCurrentComponentFiber)(); | ||
var component = fiber.nodeInstance; | ||
var pointer = component.pointer; | ||
var hooks = getHooksListFromFiber(fiber); | ||
var hook = hooks[pointer]; // if hook is not there initialize and add it to the pointer | ||
@@ -149,22 +167,18 @@ | ||
currentComponent.pointer += 1; | ||
component.pointer += 1; | ||
return reduce(hook); | ||
} | ||
/** | ||
* Method to set the current component while rendering the components | ||
*/ | ||
function setCurrentComponent(component) { | ||
currentComponent = component; | ||
function prepareHooksForRender() { | ||
var fiber = (0, _fiber.getCurrentComponentFiber)(); | ||
var component = fiber.nodeInstance, | ||
updateType = fiber.root.updateType; | ||
component.pointer = 0; // based on update type clone the hooks to deferred hooks | ||
var updateType = getUpdateTypeFromComponent(component); | ||
if (updateType === _updateMetaUtils.UPDATE_TYPE_DEFERRED) { | ||
component.deferredHooks = cloneHooks(component.hooks); | ||
if (updateType === _configs.UPDATE_TYPE_DEFERRED) { | ||
cloneHooks(component); | ||
} // call all the pending update before trying to render, | ||
var pendingUpdates = (0, _updateMetaUtils.getPendingUpdates)(updateType, component); | ||
var pendingUpdates = (0, _updateUtils.getPendingUpdates)(fiber); | ||
pendingUpdates.forEach(function (task) { | ||
@@ -180,3 +194,4 @@ return task.updater(); | ||
function useStateBase(initialState, getNewState) { | ||
var component = currentComponent; | ||
var component = getCurrentComponent(); | ||
var hookIndex = component.pointer; | ||
return getHook(function () { | ||
@@ -188,15 +203,22 @@ /** | ||
var hook = [initialState, function (param) { | ||
var updateType = (0, _updateMetaUtils.getUpdateType)(); | ||
var currentHook = getCurrentHook(updateType, component); | ||
var updateType = (0, _updateUtils.getUpdateType)(); | ||
var currentHook = getCurrentHook(updateType, hookIndex, component); | ||
var lastState = currentHook[0]; | ||
var state = getNewState(param, lastState); | ||
var pendingUpdatesKey = (0, _updateMetaUtils.getPendingUpdatesKey)(updateType); | ||
var pendingUpdatesKey = (0, _updateUtils.getPendingUpdatesKey)(updateType); | ||
var stateMeta = { | ||
transitionId: _updateMetaUtils.currentTransition.transitionId, | ||
transitionId: (0, _updateUtils.getCurrentTransition)().transitionId, | ||
updater: function updater() { | ||
// call getNewState again as currentHook[0] might change if there are multiple setState | ||
currentHook[0] = getNewState(param, currentHook[0]); | ||
/** | ||
* get the hook again inside, as the reference of currentHook might change | ||
* if we clone sync hook to deferred hook | ||
*/ | ||
var stateHook = getCurrentHook(updateType, hookIndex, component); // call getNewState again as currentHook[0] might change if there are multiple setState | ||
stateHook[0] = getNewState(param, currentHook[0]); | ||
} | ||
}; | ||
component[pendingUpdatesKey].push(stateMeta); | ||
component[_configs.BRAHMOS_DATA_KEY][pendingUpdatesKey].push(stateMeta); | ||
reRenderComponentIfRequired(component, state, lastState); | ||
@@ -291,5 +313,6 @@ }]; | ||
function useEffectBase(effectHandler, dependencies) { | ||
var _currentComponent2 = currentComponent, | ||
pointer = _currentComponent2.pointer, | ||
hooks = _currentComponent2.hooks; | ||
var fiber = (0, _fiber.getCurrentComponentFiber)(); | ||
var component = fiber.nodeInstance; | ||
var pointer = component.pointer; | ||
var hooks = getHooksListFromFiber(fiber); | ||
var lastHook = hooks[pointer] || { | ||
@@ -312,3 +335,3 @@ animationFrame: null, | ||
hooks[pointer] = hook; | ||
currentComponent.pointer += 1; | ||
component.pointer += 1; | ||
} | ||
@@ -356,6 +379,8 @@ /** | ||
function useContext(Context) { | ||
var _getCurrentComponentF = (0, _fiber.getCurrentComponentFiber)(), | ||
component = _getCurrentComponentF.nodeInstance, | ||
context = _getCurrentComponentF.context; | ||
var id = Context.id, | ||
defaultValue = Context.defaultValue; | ||
var _currentComponent3 = currentComponent, | ||
context = _currentComponent3.__context; | ||
var provider = context[id]; | ||
@@ -367,3 +392,3 @@ var value = provider ? provider.props.value : defaultValue; | ||
var subs = provider.subs; | ||
var callback = (0, _createContext.getConsumerCallback)(currentComponent); | ||
var callback = (0, _createContext.getConsumerCallback)(component); | ||
subs.push(callback); | ||
@@ -376,3 +401,3 @@ return function () { | ||
currentComponent.context = value; | ||
component.context = value; | ||
return value; | ||
@@ -387,3 +412,3 @@ } | ||
var timeoutMs = _ref.timeoutMs; | ||
var component = currentComponent; | ||
var component = getCurrentComponent(); | ||
return getHook(function () { | ||
@@ -395,16 +420,48 @@ /** | ||
transitionId: (0, _utils.getUniqueId)(), | ||
tryCount: 0, | ||
isPending: false, | ||
transitionTimeout: null, | ||
pendingSuspense: [], | ||
transitionState: _transitionUtils.TRANSITION_STATE_INITIAL, | ||
suspendCount: 0, | ||
resetIsPending: function resetIsPending() { | ||
var currentHook = getCurrentHook(_updateMetaUtils.UPDATE_TYPE_DEFERRED, component); | ||
clearTimeout: function (_clearTimeout) { | ||
function clearTimeout() { | ||
return _clearTimeout.apply(this, arguments); | ||
} | ||
clearTimeout.toString = function () { | ||
return _clearTimeout.toString(); | ||
}; | ||
return clearTimeout; | ||
}(function () { | ||
clearTimeout(hook.transitionTimeout); | ||
currentHook.isPending = false; | ||
}), | ||
updatePendingState: function updatePendingState(isPending, updateSource) { | ||
hook.isPending = isPending; // mark component to force update as isPending is not treated as state | ||
component[_configs.BRAHMOS_DATA_KEY].isDirty = true; | ||
var reRenderCb = function reRenderCb() { | ||
(0, _reRender["default"])(component); | ||
}; | ||
if (updateSource === _configs.UPDATE_SOURCE_TRANSITION) { | ||
(0, _updateUtils.withTransition)(hook, reRenderCb); | ||
} else { | ||
(0, _updateUtils.withUpdateSource)(updateSource, reRenderCb); | ||
} | ||
}, | ||
startTransition: function startTransition(cb) { | ||
var currentHook = getCurrentHook(_updateMetaUtils.UPDATE_TYPE_DEFERRED, component); | ||
var root = component.__fiber.root; // set the transitionId globally so that state updates can get the transition id | ||
var initialUpdateSource = (0, _updateUtils.getCurrentUpdateSource)(); | ||
(0, _updateMetaUtils.withTransition)(currentHook, cb); | ||
var _getFiberFromComponen = (0, _fiber.getFiberFromComponent)(component), | ||
root = _getFiberFromComponen.root; // reset the transitionState and pending suspense | ||
hook.transitionState = _transitionUtils.TRANSITION_STATE_START; | ||
hook.pendingSuspense = []; // clear pending timeout | ||
hook.clearTimeout(); // set the transitionId globally so that state updates can get the transition id | ||
(0, _updateUtils.withTransition)(hook, cb); | ||
/** | ||
@@ -415,7 +472,4 @@ * If cb does not have any setState, we don't have to unnecessary | ||
if (root.lastDeferredCompleteTime > root.deferredUpdateTime) { | ||
currentHook.isPending = true; | ||
currentHook.transitionState = _transitionUtils.TRANSITION_STATE_PENDING; // after setting isPending we will have to re-render the component | ||
(0, _render.reRender)(component); | ||
if (root.lastDeferredCompleteTime < root.deferredUpdateTime) { | ||
hook.updatePendingState(true, initialUpdateSource); | ||
} | ||
@@ -427,6 +481,5 @@ /** | ||
currentHook.transitionTimeout = setTimeout(function () { | ||
currentHook.transitionState = _transitionUtils.TRANSITION_STATE_TIMED_OUT; | ||
currentHook.isPending = false; | ||
(0, _render.reRender)(component); | ||
hook.transitionTimeout = setTimeout(function () { | ||
hook.transitionState = _transitionUtils.TRANSITION_STATE_TIMED_OUT; | ||
hook.updatePendingState(false, _configs.UPDATE_SOURCE_TRANSITION); | ||
}, timeoutMs); | ||
@@ -447,5 +500,4 @@ } | ||
function runEffects(component) { | ||
var updateType = getUpdateTypeFromComponent(component); | ||
var hooks = getHooksList(updateType, component); | ||
function runEffects(fiber) { | ||
var hooks = getHooksListFromFiber(fiber); | ||
@@ -465,5 +517,4 @@ for (var i = 0, ln = hooks.length; i < ln; i++) { | ||
function cleanEffects(component, unmount) { | ||
var updateType = getUpdateTypeFromComponent(component); | ||
var hooks = getHooksList(updateType, component); | ||
function cleanEffects(fiber, unmount) { | ||
var hooks = getHooksListFromFiber(fiber); | ||
@@ -478,6 +529,6 @@ for (var i = 0, ln = hooks.length; i < ln; i++) { | ||
if (hook.resetIsPending && unmount) { | ||
hook.resetIsPending(); | ||
if (hook.clearTimeout && unmount) { | ||
hook.clearTimeout(); | ||
} | ||
} | ||
} |
@@ -8,42 +8,42 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "createElement", { | ||
Object.defineProperty(exports, "Component", { | ||
enumerable: true, | ||
get: function get() { | ||
return _createElement.createElement; | ||
return _circularDep.Component; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createPortal", { | ||
Object.defineProperty(exports, "PureComponent", { | ||
enumerable: true, | ||
get: function get() { | ||
return _createPortal["default"]; | ||
return _circularDep.PureComponent; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Suspense", { | ||
Object.defineProperty(exports, "createElement", { | ||
enumerable: true, | ||
get: function get() { | ||
return _Suspense.Suspense; | ||
return _circularDep.createElement; | ||
} | ||
}); | ||
Object.defineProperty(exports, "lazy", { | ||
Object.defineProperty(exports, "Suspense", { | ||
enumerable: true, | ||
get: function get() { | ||
return _Suspense.lazy; | ||
return _circularDep.Suspense; | ||
} | ||
}); | ||
Object.defineProperty(exports, "render", { | ||
Object.defineProperty(exports, "SuspenseList", { | ||
enumerable: true, | ||
get: function get() { | ||
return _render["default"]; | ||
return _circularDep.SuspenseList; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Component", { | ||
Object.defineProperty(exports, "lazy", { | ||
enumerable: true, | ||
get: function get() { | ||
return _Component.Component; | ||
return _circularDep.lazy; | ||
} | ||
}); | ||
Object.defineProperty(exports, "PureComponent", { | ||
Object.defineProperty(exports, "render", { | ||
enumerable: true, | ||
get: function get() { | ||
return _Component.PureComponent; | ||
return _render["default"]; | ||
} | ||
@@ -57,2 +57,8 @@ }); | ||
}); | ||
Object.defineProperty(exports, "createPortal", { | ||
enumerable: true, | ||
get: function get() { | ||
return _createPortal["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useState", { | ||
@@ -106,2 +112,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "useTransition", { | ||
enumerable: true, | ||
get: function get() { | ||
return _hooks.useTransition; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createContext", { | ||
@@ -134,19 +146,21 @@ enumerable: true, | ||
get: function get() { | ||
return _deferredUpdates.deferredUpdates; | ||
return _updateUtils.deferredUpdates; | ||
} | ||
}); | ||
Object.defineProperty(exports, "unstable_syncUpdates", { | ||
enumerable: true, | ||
get: function get() { | ||
return _updateUtils.syncUpdates; | ||
} | ||
}); | ||
exports["default"] = void 0; | ||
var _createElement = require("./createElement"); | ||
var _circularDep = require("./circularDep"); | ||
var _createPortal = _interopRequireDefault(require("./createPortal")); | ||
var _Suspense = require("./Suspense"); | ||
var _render = _interopRequireDefault(require("./render")); | ||
var _Component = require("./Component"); | ||
var _tags = require("./tags"); | ||
var _createPortal = _interopRequireDefault(require("./createPortal")); | ||
var _hooks = require("./hooks"); | ||
@@ -160,14 +174,12 @@ | ||
var _deferredUpdates = require("./deferredUpdates"); | ||
var _updateUtils = require("./updateUtils"); | ||
/** Portal */ | ||
/** Component classes, Suspense and lazy */ | ||
/** Suspense and lazy */ | ||
/** render methods */ | ||
/** Component classes */ | ||
/** React lit tags */ | ||
/** Portal */ | ||
/** Hooks */ | ||
@@ -183,6 +195,6 @@ | ||
var Brahmos = { | ||
createElement: _createElement.createElement, | ||
createElement: _circularDep.createElement, | ||
render: _render["default"], | ||
Component: _Component.Component, | ||
PureComponent: _Component.PureComponent, | ||
Component: _circularDep.Component, | ||
PureComponent: _circularDep.PureComponent, | ||
html: _tags.html, | ||
@@ -197,2 +209,3 @@ useState: _hooks.useState, | ||
useContext: _hooks.useContext, | ||
useTransition: _hooks.useTransition, | ||
createContext: _createContext["default"], | ||
@@ -203,7 +216,9 @@ forwardRef: _refs.forwardRef, | ||
unmountComponentAtNode: _unmountComponentAtNode["default"], | ||
Suspense: _Suspense.Suspense, | ||
lazy: _Suspense.lazy, | ||
unstable_deferredUpdates: _deferredUpdates.deferredUpdates | ||
Suspense: _circularDep.Suspense, | ||
SuspenseList: _circularDep.SuspenseList, | ||
lazy: _circularDep.lazy, | ||
unstable_deferredUpdates: _updateUtils.deferredUpdates, | ||
unstable_syncUpdates: _updateUtils.syncUpdates | ||
}; | ||
var _default = Brahmos; | ||
exports["default"] = _default; |
@@ -10,13 +10,13 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
var _brahmosNode = require("./brahmosNode"); | ||
var _configs = require("./configs"); | ||
// handle array nodes | ||
function processArrayFiber(fiber) { | ||
var nodes = fiber.node, | ||
part = fiber.part, | ||
root = fiber.root; | ||
part = fiber.part; | ||
var refFiber = fiber; | ||
var parentNode = part.parentNode, | ||
previousSibling = part.previousSibling, | ||
nextSibling = part.nextSibling; | ||
previousSibling = part.previousSibling; | ||
var childKeyMap = new Map(); | ||
@@ -30,3 +30,3 @@ var i = 0; | ||
while (childFiber = (0, _fiber.getNextChildFiber)(childFiber, fiber)) { | ||
var key = (0, _utils.getKey)(childFiber.node, i); | ||
var key = (0, _brahmosNode.getKey)(childFiber.node, i); | ||
childKeyMap.set(key, childFiber); | ||
@@ -43,31 +43,49 @@ i++; | ||
fiber.child = null; | ||
nodes.forEach(function (node, index) { | ||
var key = (0, _brahmosNode.getKey)(node, index); | ||
var currentFiber = childKeyMap.get(key); | ||
for (var _i = 0, ln = nodes.length; _i < ln; _i++) { | ||
var node = nodes[_i]; | ||
var _key = (0, _utils.getKey)(node, _i); | ||
var currentFiber = childKeyMap.get(_key); | ||
if (currentFiber) { | ||
// reset the sibling of current fiber as sibling has to be decided by loop on node | ||
currentFiber.sibling = null; // delete the currentFiber from map, so we can use map to remove pending elements | ||
// delete the currentFiber from map, so we can use map to remove pending elements | ||
childKeyMap["delete"](key); | ||
} | ||
childKeyMap["delete"](_key); | ||
} // create fiber if required and link it | ||
var previousFiber = refFiber; // create fiber if required and link it | ||
refFiber = (0, _fiber.createAndLink)(node, { | ||
parentNode: parentNode, | ||
previousSibling: previousSibling, | ||
nextSibling: nextSibling, | ||
/** | ||
* Surprisingly an undefined dummy property increases V8 performance. | ||
* We remove nextSibling which when being undefined was running faster | ||
* Looks like inlining and deopt issue. But still have to figure out why | ||
* undefined property changed anything | ||
* Inlining this whole body inside processFiber was not giving issue without | ||
* undefined property | ||
*/ | ||
a: undefined, | ||
isArrayNode: true, | ||
nodeIndex: _i | ||
}, currentFiber, refFiber, fiber); | ||
} // mark non used node to tear down | ||
nodeIndex: index | ||
}, currentFiber, previousFiber, fiber); // reset the sibling fiber on the ref fiber. This will be set on next iteration of loop. | ||
refFiber.sibling = null; | ||
/** | ||
* if current fiber nodeIndex is different than new index,or if it is a new fiber without any alternate | ||
* mark fiber and its previous fiber to have uncommitted placement effect | ||
*/ | ||
if (currentFiber && currentFiber.part.nodeIndex !== index) { | ||
(0, _fiber.markPendingEffect)(refFiber, _configs.EFFECT_TYPE_PLACEMENT); // mark the previous fiber as well having the placement effect, as it makes it easier to | ||
// rearrange the dom nodes | ||
if (index !== 0) (0, _fiber.markPendingEffect)(previousFiber, _configs.EFFECT_TYPE_PLACEMENT); | ||
} | ||
}); // mark non used node to tear down | ||
childKeyMap.forEach(function (fiber) { | ||
root.tearDownFibers.push(fiber); | ||
}); | ||
(0, _fiber.markToTearDown)(fiber); | ||
}); // mark the array fiber for handling effects | ||
(0, _fiber.markPendingEffect)(fiber, _configs.EFFECT_TYPE_OTHER); | ||
} |
@@ -8,3 +8,4 @@ "use strict"; | ||
}); | ||
exports.getUpdatedState = getUpdatedState; | ||
exports.getErrorBoundaryFiber = getErrorBoundaryFiber; | ||
exports.getErrorInfo = getErrorInfo; | ||
exports["default"] = processComponentFiber; | ||
@@ -14,3 +15,3 @@ | ||
var _fiber = require("./fiber"); | ||
var _fiber2 = require("./fiber"); | ||
@@ -21,3 +22,3 @@ var _functionalComponentInstance = _interopRequireDefault(require("./functionalComponentInstance")); | ||
var _Component = require("./Component"); | ||
var _circularDep = require("./circularDep"); | ||
@@ -28,6 +29,10 @@ var _hooks = require("./hooks"); | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _updateUtils = require("./updateUtils"); | ||
var _shallowEqual = _interopRequireDefault(require("./helpers/shallowEqual")); | ||
var _configs = require("./configs"); | ||
var _Component = require("./Component"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -37,6 +42,26 @@ | ||
function getCurrentContext(fiber, isReused) { | ||
var _fiber$node = fiber.node, | ||
Component = _fiber$node.type, | ||
componentInstance = _fiber$node.componentInstance, | ||
function getErrorBoundaryFiber(fiber) { | ||
var _fiber = fiber, | ||
root = _fiber.root; | ||
while ((fiber = fiber.parent) && !(fiber.nodeInstance instanceof _Component.Component && (fiber.nodeInstance.componentDidCatch || fiber.node.type.getDerivedStateFromError))) { | ||
if (fiber === root) return null; | ||
} | ||
return fiber; | ||
} | ||
function getErrorInfo(fiber) { | ||
var Component = fiber.node.type; | ||
var componentName = Component.displayName || Component.name; | ||
var error = "The above error occurred in the <".concat(componentName, "> component:"); // TODO: write error stack information here. | ||
return { | ||
componentStack: error | ||
}; | ||
} | ||
function getCurrentContext(fiber) { | ||
var Component = fiber.node.type, | ||
nodeInstance = fiber.nodeInstance, | ||
parent = fiber.parent, | ||
@@ -46,17 +71,17 @@ currentContext = fiber.context; // if component has createContext index, we treat it as provider | ||
var __ccId = Component.__ccId; | ||
var context = parent.context; // if component is not a provider return the same context | ||
var context = parent.context || {}; // if component is not a provider return the same context | ||
if (!__ccId) return context; | ||
/** | ||
* if there is a context on fiber node and the componentInstance | ||
* if there is a context on fiber node and the nodeInstance | ||
* is reused we can always return that context, | ||
* if provider in parent hierarchy is changed, the whole child hierarchy will | ||
* be different and componentInstance are not reused. | ||
* be different and nodeInstance are not reused. | ||
*/ | ||
if (currentContext && isReused) return currentContext; // for new provider instance create a new context extending the parent context | ||
if (currentContext) return currentContext; // for new provider instance create a new context extending the parent context | ||
var newContext = Object.create(context); // store the componentInstance | ||
var newContext = Object.create(context); // store the nodeInstance | ||
newContext[__ccId] = componentInstance; | ||
newContext[__ccId] = nodeInstance; | ||
return newContext; | ||
@@ -71,2 +96,12 @@ } | ||
}, prevState); | ||
} // method to reset work loop to a fiber of given component | ||
function resetLoopToComponentsFiber(fiber) { | ||
var root = fiber.root, | ||
nodeInstance = fiber.nodeInstance; // mark component as dirty, so it can be rendered again | ||
nodeInstance[_configs.BRAHMOS_DATA_KEY].isDirty = true; // set the alternate fiber as retry fiber, as | ||
root.retryFiber = fiber; | ||
} | ||
@@ -77,57 +112,38 @@ | ||
part = fiber.part, | ||
alternate = fiber.alternate; | ||
var updateType = fiber.root.updateType; | ||
root = fiber.root, | ||
childFiberError = fiber.childFiberError; | ||
var Component = node.type, | ||
nodeType = node.nodeType, | ||
_node$props = node.props, | ||
props = _node$props === void 0 ? {} : _node$props, | ||
ref = node.ref; | ||
var isFirstRender = false; | ||
var isReused = false; | ||
props = _node$props === void 0 ? {} : _node$props; | ||
var isDeferredUpdate = root.updateType === _configs.UPDATE_TYPE_DEFERRED; | ||
var shouldUpdate = true; | ||
var usedMemoizedValue = false; | ||
var isClassComponent = nodeType === _brahmosNode.CLASS_COMPONENT_NODE; | ||
/** | ||
* If an alternate fiber is present it means the parent is rendered, | ||
* but the fiber can reuse the previous instance | ||
* | ||
* Note: alternate fiber may not be present if parent never re-renders, but in which case | ||
* node will already have componentInstance and the processing of fiber is happening due to | ||
* state change and not parent render. | ||
* Reset the fiber children to a committed child | ||
*/ | ||
if (alternate) { | ||
node.componentInstance = alternate.node.componentInstance; | ||
} | ||
(0, _fiber2.resetToCommittedChild)(fiber); | ||
/** If Component instance is not present on node create a new instance */ | ||
var nodeInstance = fiber.nodeInstance; | ||
var isFirstRender = false; | ||
var componentInstance = node.componentInstance; | ||
var firstRender; | ||
if (!componentInstance) { | ||
if (!nodeInstance) { | ||
// create an instance of the component | ||
componentInstance = isClassComponent ? new Component(props) : (0, _functionalComponentInstance["default"])(Component); // keep the reference of instance to the node. | ||
nodeInstance = isClassComponent ? new Component(props) : (0, _functionalComponentInstance["default"])(Component); // keep the reference of instance to the node. | ||
node.componentInstance = componentInstance; | ||
firstRender = true; | ||
fiber.nodeInstance = nodeInstance; | ||
isFirstRender = true; | ||
} | ||
var _componentInstance = componentInstance, | ||
prevProps = _componentInstance.props, | ||
prevState = _componentInstance.state; // add fiber reference on component instance, so the component is aware of its fiber | ||
var brahmosData = nodeInstance[_configs.BRAHMOS_DATA_KEY]; // get current context | ||
componentInstance.__fiber = fiber; // store previous props and prevState in node if it's not a first time render for the component | ||
var context = getCurrentContext(fiber); // store context in fiber | ||
if (!firstRender) { | ||
node.prevProps = prevProps; | ||
node.prevState = prevState; | ||
} // get current context | ||
var context = getCurrentContext(fiber, isReused); // store context in fiber | ||
fiber.context = context; | ||
/** | ||
* If it is a class component, | ||
* associate state, props, context and ref | ||
* associate state, props to component instance | ||
* and call all the life cycle method which comes before rendering. | ||
@@ -137,10 +153,37 @@ */ | ||
if (isClassComponent) { | ||
var _componentInstance2 = componentInstance, | ||
shouldComponentUpdate = _componentInstance2.shouldComponentUpdate; | ||
var pendingUpdates = (0, _updateMetaUtils.getPendingUpdates)(updateType, componentInstance); | ||
var state = getUpdatedState(prevState, pendingUpdates); | ||
var checkShouldUpdate = !isFirstRender; // call getDerivedStateFromProps hook with the unCommitted state | ||
var committedValues = brahmosData.committedValues, | ||
memoizedValues = brahmosData.memoizedValues; // if it is first render we should store the initial state on committedValues | ||
state = _objectSpread({}, state, {}, (0, _utils.callLifeCycle)(Component, 'getDerivedStateFromProps', [props, state])); // call callbacks of setState with new state | ||
if (isFirstRender) committedValues.state = nodeInstance.state; | ||
var prevProps = committedValues.props, | ||
prevState = committedValues.state; | ||
if (memoizedValues && isDeferredUpdate) { | ||
prevProps = memoizedValues.props; | ||
prevState = memoizedValues.state; | ||
usedMemoizedValue = true; | ||
} // | ||
/** | ||
* reset the component instance values to prevProps and prevState, | ||
* The state and prop value might have been effected by deferred rendering | ||
* For sync render it should point to previous committed value, and for | ||
* deferred render it should point to memoized values | ||
*/ | ||
nodeInstance.props = prevProps; | ||
nodeInstance.state = prevState; | ||
var _nodeInstance = nodeInstance, | ||
shouldComponentUpdate = _nodeInstance.shouldComponentUpdate; | ||
var state = prevState; // apply the pending updates in state if | ||
var pendingUpdates = (0, _updateUtils.getPendingUpdates)(fiber); | ||
if (pendingUpdates.length) state = getUpdatedState(prevState, pendingUpdates); | ||
var checkShouldUpdate = !isFirstRender && root.forcedUpdateWith !== nodeInstance; // call getDerivedStateFromProps lifecycle with the unCommitted state and apply the derivedState on state | ||
var derivedState = (0, _utils.callLifeCycle)(Component, 'getDerivedStateFromProps', [props, state]); | ||
var derivedErrorState = childFiberError ? (0, _utils.callLifeCycle)(Component, 'getDerivedStateFromError', [childFiberError.error]) : undefined; | ||
if (derivedState || derivedErrorState) state = _objectSpread({}, state, {}, derivedState, {}, derivedErrorState); // call callbacks of setState with new state | ||
pendingUpdates.forEach(function (_ref2) { | ||
@@ -155,3 +198,3 @@ var callback = _ref2.callback; | ||
if (componentInstance instanceof _Component.PureComponent && checkShouldUpdate) { | ||
if (nodeInstance.isPureReactComponent && checkShouldUpdate) { | ||
shouldUpdate = !(0, _shallowEqual["default"])(state, prevState) || !(0, _shallowEqual["default"])(props, prevProps); | ||
@@ -167,3 +210,3 @@ } | ||
if (shouldComponentUpdate && shouldUpdate && checkShouldUpdate) { | ||
shouldUpdate = shouldComponentUpdate.call(componentInstance, props, state); | ||
shouldUpdate = shouldComponentUpdate.call(nodeInstance, props, state); | ||
} | ||
@@ -176,3 +219,2 @@ /** | ||
var contextType = Component.contextType; | ||
var contextValue; | ||
@@ -183,19 +225,26 @@ if (contextType) { | ||
var provider = context[id]; | ||
contextValue = provider ? provider.props.value : defaultValue; // if it is a first render subscribe component for provider value change | ||
var contextValue = provider ? provider.props.value : defaultValue; // if it is a first render subscribe component for provider value change | ||
if (provider && isFirstRender) { | ||
provider.sub(componentInstance); | ||
provider.sub(nodeInstance); | ||
} | ||
nodeInstance.context = contextValue; | ||
} // set the new state, props, context and reset uncommitted state | ||
componentInstance.state = state; | ||
componentInstance.props = props; | ||
componentInstance.context = contextValue; | ||
componentInstance.__unCommittedState = undefined; | ||
} else if (!firstRender) { | ||
nodeInstance.state = state; | ||
nodeInstance.props = props; // store the state and props on memoized value as well | ||
if (isDeferredUpdate) { | ||
brahmosData.memoizedValues = { | ||
state: state, | ||
props: props | ||
}; | ||
} | ||
} else if (!isFirstRender) { | ||
// for functional component call cleanEffect only on second render | ||
// alternate will be set on second render | ||
// NOTE: This is buggy, cleanEffects should be called before commit phase, check the behavior of react. | ||
(0, _hooks.cleanEffects)(componentInstance); | ||
(0, _hooks.cleanEffects)(fiber); | ||
} // render the nodes | ||
@@ -206,14 +255,76 @@ | ||
try { | ||
var childNodes = componentInstance.__render(props); | ||
// set the current component fiber we are processing | ||
(0, _fiber2.setCurrentComponentFiber)(fiber); // if the component is error boundary and it does not have getDerivedStateFromError, render null | ||
(0, _fiber.createCurrentAndLink)(childNodes, part, fiber, fiber); | ||
} catch (err) { | ||
console.log(err); // TODO: handle error boundaries | ||
var hasNonHandledError = childFiberError && !Component.getDerivedStateFromError; | ||
var childNodes = hasNonHandledError ? null : nodeInstance.__render(props); // component will always return a single node so we can pass the previous child as current fiber | ||
(0, _fiber2.createAndLink)(childNodes, part, fiber.child, fiber, fiber); | ||
} catch (error) { | ||
var errorBoundary = getErrorBoundaryFiber(fiber); // TODO: handle error boundaries | ||
// if error is a suspender, handle the suspender in suspense component | ||
// TODO: this is very basic case for suspender, add better code to check if it is a suspender | ||
if (typeof error.then === 'function') { | ||
var suspenseFiber = (0, _circularDep.getClosestSuspenseFiber)(fiber); | ||
/** | ||
* if there is no suspense in parent hierarchy throw error that suspender can't be | ||
* used outside of suspense | ||
* TODO: think for better message | ||
*/ | ||
if (!suspenseFiber) { | ||
throw new Error("Rendering which got suspended can't be used outside of suspense."); | ||
} | ||
suspenseFiber.nodeInstance.handleSuspender(error, suspenseFiber); // reset the work loop to suspense fiber | ||
resetLoopToComponentsFiber(suspenseFiber); | ||
/** | ||
* else if there is any error boundary handle the error in error boundary | ||
* It should not handle error if its already been handled once | ||
*/ | ||
} else if (errorBoundary && !errorBoundary.childFiberError) { | ||
var errorInfo = getErrorInfo(fiber); // log the error and retry rendering | ||
console.error(error); | ||
console.error(errorInfo.componentStack); | ||
errorBoundary.childFiberError = { | ||
error: error, | ||
errorInfo: errorInfo | ||
}; // reset the work loop to errorBoundary fiber | ||
resetLoopToComponentsFiber(errorBoundary); // else throw error | ||
} else { | ||
throw error; | ||
} | ||
return; | ||
} // mark that the fiber has uncommitted effects | ||
(0, _fiber2.markPendingEffect)(fiber, _configs.EFFECT_TYPE_OTHER); | ||
/** | ||
* If we are using memoized values and shouldUpdate is false, | ||
* we might have some pending nodes from last render, in which case | ||
* we should create new child fibers with pending nodes. | ||
*/ | ||
} else if (usedMemoizedValue) { | ||
var child = fiber.child; | ||
if (!child || child.node !== brahmosData.nodes) { | ||
(0, _fiber2.createAndLink)(brahmosData.nodes, part, child, fiber, fiber); // mark that the fiber has uncommitted effects | ||
(0, _fiber2.markPendingEffect)(fiber, _configs.EFFECT_TYPE_OTHER); | ||
} | ||
/** | ||
* if we don't need to update the child fibers, we should clone the child fiber from current tree | ||
* But if had memoized props and states and no update is required, it means we already are | ||
* pointing to correct child fibers, in which case we shouldn't clone the child | ||
*/ | ||
(0, _fiber.linkEffect)(fiber); | ||
} else { | ||
// clone the existing nodes | ||
(0, _fiber.cloneChildrenFibers)(fiber); | ||
(0, _fiber2.cloneChildrenFibers)(fiber); | ||
} | ||
} |
@@ -41,2 +41,3 @@ "use strict"; | ||
var refFiber = parentFiber; | ||
var oldChildFiber = parentFiber.child; | ||
@@ -68,4 +69,3 @@ var _loop = function _loop(_i, ln) { | ||
// Note only functional refs are supported | ||
refValue = attrValue; // TODO: Handle refs | ||
// setRef(attrValue, domNode); | ||
refValue = attrValue; | ||
} | ||
@@ -88,5 +88,8 @@ }); | ||
*/ | ||
// get the current old fiber | ||
refFiber = (0, _fiber.createCurrentAndLink)(node, part, refFiber, parentFiber); | ||
refFiber = (0, _fiber.createAndLink)(node, part, oldChildFiber, refFiber, parentFiber); // set the next old child to oldChildFiber | ||
oldChildFiber = oldChildFiber && oldChildFiber.sibling; | ||
i = _i; | ||
@@ -105,4 +108,4 @@ }; | ||
function processTagFiber(fiber) { | ||
var node = fiber.node, | ||
part = fiber.part, | ||
var node = fiber.node; | ||
var part = fiber.part, | ||
alternate = fiber.alternate, | ||
@@ -117,10 +120,4 @@ context = fiber.parent.context; | ||
fiber.isSvgPart = isSvgPart; // if new node and old node share same template we can reuse the templateNode instance | ||
if (oldNode && oldNode.template === node.template) { | ||
node.templateNode = oldNode.templateNode; | ||
oldNode.isReused = true; | ||
} | ||
var templateNode = node.templateNode; | ||
fiber.isSvgPart = isSvgPart; | ||
var nodeInstance = fiber.nodeInstance; | ||
/** | ||
@@ -131,17 +128,24 @@ * if you don't get the old template node it means you have to render the node first time | ||
if (!templateNode) { | ||
templateNode = isTagElement ? (0, _TagNode["default"])(node, isSvgPart) : new _TemplateNode["default"](node.template, isSvgPart); // add templateNode to node so we can access it on next updates | ||
if (!nodeInstance) { | ||
nodeInstance = isTagElement ? (0, _TagNode["default"])(node, isSvgPart) : new _TemplateNode["default"](node.template, isSvgPart); // add nodeInstance to node so we can access it on next updates | ||
node.templateNode = templateNode; | ||
} else if (!isTagElement) { | ||
/** | ||
* if any of templateNode part does not have proper parent node and its not first render | ||
* patch the part information using the current node's part | ||
*/ | ||
templateNode.patchParts(part); | ||
fiber.nodeInstance = nodeInstance; | ||
} | ||
/** | ||
* if any of nodeInstance part does not have proper parent node and its not first render | ||
* patch the part information using the current node's part | ||
* This can happen if the parent node is fragment, or it is the first or last item | ||
*/ | ||
if (!isTagElement) { | ||
nodeInstance.patchParts(part); | ||
} | ||
/** | ||
* Associate parts to fiber. | ||
* No need to perform this of node and oldNode are same | ||
* No need to perform this if node and oldNode are same | ||
* This will only happen when we are just doing position change | ||
* In which case just clone the children fibers | ||
* CHECK: Will there be ever any case where node is same as oldNode | ||
* and process is called. | ||
*/ | ||
@@ -151,9 +155,11 @@ | ||
if (node !== oldNode) { | ||
partsToFiber(templateNode.parts, values, fiber); | ||
} // mark this node to be updated or to get appended as a effect | ||
partsToFiber(nodeInstance.parts, values, fiber); | ||
} else { | ||
(0, _fiber.cloneChildrenFibers)(fiber); | ||
} // mark that the fiber has uncommitted effects | ||
(0, _fiber.linkEffect)(fiber); // attach context on fiber | ||
(0, _fiber.markPendingEffect)(fiber, _configs.EFFECT_TYPE_OTHER); // attach context on fiber | ||
fiber.context = context; | ||
} |
@@ -10,2 +10,4 @@ "use strict"; | ||
var _configs = require("./configs"); | ||
function processTextFiber(fiber) { | ||
@@ -17,4 +19,5 @@ var node = fiber.node, | ||
if (node !== oldNode) { | ||
(0, _fiber.linkEffect)(fiber); | ||
// mark that the fiber has uncommitted effects | ||
(0, _fiber.markPendingEffect)(fiber, _configs.EFFECT_TYPE_OTHER); | ||
} | ||
} |
@@ -14,3 +14,3 @@ "use strict"; | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _updateUtils = require("./updateUtils"); | ||
@@ -101,7 +101,3 @@ var _configs = require("./configs"); | ||
if (eventHandlerObj.handler) { | ||
/** | ||
* set update source as event which will make sure things | ||
* are rendered and committed synchronously | ||
*/ | ||
(0, _updateMetaUtils.withUpdateSource)(_updateMetaUtils.UPDATE_SOURCE_EVENT, function () { | ||
(0, _updateUtils.syncUpdates)(function () { | ||
eventHandlerObj.handler.call(_this, event); | ||
@@ -108,0 +104,0 @@ }); |
@@ -14,12 +14,9 @@ "use strict"; | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _utils = require("./utils"); | ||
function forwardRef(Component) { | ||
function forwardRefComponent(_ref) { | ||
var ref = _ref.ref, | ||
props = (0, _objectWithoutProperties2["default"])(_ref, ["ref"]); | ||
return Component(props, ref); | ||
function forwardRefComponent(props) { | ||
return Component((0, _utils.getNormalizedProps)(props, false), props.ref); | ||
} | ||
; | ||
forwardRefComponent.__isForwardRef = true; | ||
@@ -26,0 +23,0 @@ return forwardRefComponent; |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,10 +7,5 @@ value: true | ||
exports["default"] = render; | ||
exports.reRender = reRender; | ||
var Brahmos = _interopRequireWildcard(require("./createElement")); | ||
var _circularDep = require("./circularDep"); | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _transitionUtils = require("./transitionUtils"); | ||
var _fiber = require("./fiber"); | ||
@@ -22,3 +15,3 @@ | ||
var _utils = require("./utils"); | ||
var _updateUtils = require("./updateUtils"); | ||
@@ -35,7 +28,2 @@ function BrahmosRootComponent(_ref) { | ||
function render(node, target) { | ||
var rootNode = Brahmos.createElement(BrahmosRootComponent, {}, node); | ||
var part = { | ||
parentNode: target, | ||
isNode: true | ||
}; | ||
var rootFiber = target.__rootFiber; | ||
@@ -45,2 +33,7 @@ var fiber; | ||
if (!rootFiber) { | ||
var rootNode = (0, _circularDep.createElement)(BrahmosRootComponent, {}, node); | ||
var part = { | ||
parentNode: target, | ||
isNode: true | ||
}; | ||
rootFiber = (0, _fiber.createHostFiber)(target); | ||
@@ -54,73 +47,23 @@ fiber = (0, _fiber.createFiber)(rootFiber, rootNode, part); // make the rootFiber parent of fiber | ||
target.__rootFiber = rootFiber; | ||
/** | ||
* do not schedule in first render | ||
* NOTE: This will also affect sync setStates inside componentDidMount, or useEffects. | ||
* This is expected to prevent multiple repaints | ||
*/ | ||
rootFiber.preventSchedule = true; | ||
} else { | ||
/** | ||
* TODO: Check this part of logic looks incorrect | ||
* if we are calling render method again, start again, | ||
* no need to clone the root fiber as it will always be different | ||
* Update the children in BrahmosRootComponent node and also reset the processedTime | ||
* so it can processed again. | ||
*/ | ||
fiber = rootFiber.current; | ||
fiber.node.props.children = node; | ||
fiber.processedTime = 0; | ||
fiber.node = rootNode; | ||
(0, _fiber.setUpdateTime)(fiber); | ||
} | ||
(0, _workLoop.doSyncProcessing)(rootFiber.current); | ||
(0, _utils.afterCurrentStack)(function () { | ||
// reset preventSchedule after render | ||
rootFiber.preventSchedule = false; | ||
}); | ||
} | ||
/** | ||
* Method to rerender a given component | ||
* In case of reRender, start from the root, | ||
* clone the current fiber to wip, and use the wip which is pointing | ||
* to children of current tree. | ||
*/ | ||
function reRender(component) { | ||
var fiber = component.__fiber; | ||
var root = fiber.root; // set updateTime on fiber parent hierarchy based on updateType | ||
var updateType = (0, _updateMetaUtils.getUpdateType)(); | ||
(0, _fiber.setUpdateTime)(fiber, updateType); // if the update source is transition add the transition in pending transition | ||
if (_updateMetaUtils.updateSource === _updateMetaUtils.UPDATE_SOURCE_TRANSITION) { | ||
var pendingTransitions = root.pendingTransitions; | ||
/** | ||
* If it is predefined deferred transition, we need to add current transition | ||
* as first item as PREDEFINED_TRANSITION_DEFERRED has more priority | ||
* or else add it in last of pendingTransitions | ||
*/ | ||
var arrayAddMethod = _updateMetaUtils.currentTransition === _transitionUtils.PREDEFINED_TRANSITION_DEFERRED ? 'unshift' : 'push'; // add the current transition to pending transition if it isn't already there. | ||
if (!pendingTransitions.includes(_updateMetaUtils.currentTransition)) { | ||
pendingTransitions[arrayAddMethod](_updateMetaUtils.currentTransition); | ||
} | ||
} | ||
/** | ||
* if there is already a batch update happening, early return | ||
* as all the state change will be covered with that batch update | ||
* do not schedule in render | ||
* NOTE: This will also affect sync setStates inside componentDidMount, or useEffects. | ||
* This is expected to prevent multiple repaints | ||
*/ | ||
if (root.batchUpdates[_updateMetaUtils.updateSource]) return; | ||
root.batchUpdates[_updateMetaUtils.updateSource] = (0, _utils.afterCurrentStack)(function () { | ||
// reset batch update so it can start taking new updates | ||
root.batchUpdates[_updateMetaUtils.updateSource] = null; | ||
root.updateSource = _updateMetaUtils.updateSource; // if there is any work to done, perform the work else do deferred processing | ||
if (root.lastCompleteTime < root.updateTime) { | ||
(0, _workLoop.doSyncProcessing)(_updateMetaUtils.updateSource === _updateMetaUtils.UPDATE_SOURCE_EVENT ? fiber : root.current); | ||
} else { | ||
(0, _workLoop.doDeferredProcessing)(root); | ||
} | ||
(0, _updateUtils.syncUpdates)(function () { | ||
rootFiber.updateSource = (0, _updateUtils.getCurrentUpdateSource)(); | ||
(0, _workLoop.doSyncProcessing)(fiber); | ||
}); | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.schedule = schedule; | ||
exports["default"] = schedule; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _transitionUtils = require("./transitionUtils"); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var RENDER_CYCLE_TIME = 5; | ||
var lastFrameTime; | ||
var _brahmosNode = require("./brahmosNode"); | ||
function updateFrameTime() { | ||
requestAnimationFrame(function (time) { | ||
lastFrameTime = time; | ||
updateFrameTime(); | ||
}); | ||
} | ||
var threads = []; | ||
updateFrameTime(); | ||
var Thread = | ||
/*#__PURE__*/ | ||
function () { | ||
function Thread(node) { | ||
(0, _classCallCheck2["default"])(this, Thread); | ||
this.node = node; | ||
this.currentNode = node; | ||
this.processed = false; | ||
this.flushed = false; | ||
this.idleCallback = null; | ||
} | ||
function frameRemainingTime(allowedTime) { | ||
return lastFrameTime + allowedTime - performance.now(); | ||
} | ||
(0, _createClass2["default"])(Thread, [{ | ||
key: "restart", | ||
value: function restart() { | ||
this.currentNode = this.node; | ||
this.domEffects = []; | ||
this.componentEffects = []; | ||
this.stop(); | ||
this.start(); | ||
} | ||
}, { | ||
key: "start", | ||
value: function start() { | ||
var _this = this; | ||
var timedOutRemaining = function timedOutRemaining() { | ||
return 1; | ||
}; | ||
this.idleCallback = requestIdleCallback(function (_ref) { | ||
var didTimeout = _ref.didTimeout, | ||
timeRemaining = _ref.timeRemaining; | ||
function schedule(root, shouldSchedule, cb) { | ||
var scheduleId = root.scheduleId; | ||
if (scheduleId) clearTimeout(scheduleId); | ||
if (timeRemaining() || didTimeout) { | ||
_this.walk(timeRemaining, didTimeout); | ||
} else { | ||
_this.start(); | ||
} | ||
}, 1000); | ||
} | ||
}, { | ||
key: "walk", | ||
value: function walk(timeRemaining, didTimeout) { | ||
var current = this.currentNode; | ||
var root = this.node; | ||
if (shouldSchedule) { | ||
var timeOutTime = frameRemainingTime(16); | ||
root.scheduleId = setTimeout(function () { | ||
var currentTransition = root.currentTransition; | ||
var tryCount = currentTransition ? currentTransition.tryCount : 0; | ||
var maxAllowedRetry = currentTransition === _transitionUtils.PREDEFINED_TRANSITION_DEFERRED ? 500 : 500; | ||
var additionalTime = Math.min(25, tryCount); | ||
while ((timeRemaining() || didTimeout) && current !== root) { | ||
// process the current node | ||
this.process(current); | ||
var child = current.child; // if there's a child, set it as the current node to process | ||
var timeRemaining = function timeRemaining() { | ||
return frameRemainingTime(RENDER_CYCLE_TIME + additionalTime); | ||
}; | ||
if (child) { | ||
current = child; | ||
continue; | ||
} // if the current node is the root node we don't need to loop further, exit from here | ||
if (current === root) { | ||
return; | ||
} // keep going up until we find the sibling | ||
while (!current.sibling) { | ||
/** | ||
* if the parent node of current is root, | ||
* it means we didn't find any sibling to process so return from there | ||
*/ | ||
if (!current.parent || current.parent === root) { | ||
return; | ||
} // set the parent as the current node | ||
current = current.parent; | ||
} // if found, set the sibling as the current node | ||
current = current.sibling; | ||
} | ||
} | ||
}, { | ||
key: "process", | ||
value: function process(node) { | ||
if ((0, _brahmosNode.isComponentNode)(node) && node.dirty) {} else if ((0, _brahmosNode.isTagNode)(node)) {} | ||
} | ||
}, { | ||
key: "flushEffects", | ||
value: function flushEffects() { | ||
var domEffects = this.domEffects, | ||
componentEffects = this.componentEffects, | ||
snapshotEffects = this.snapshotEffects; // flush all the snapshot effects first | ||
for (var i = 0, ln = snapshotEffects.length; i < ln; i++) { | ||
var node = snapshotEffects[i]; | ||
node.snapshotEffect(); // reset the effect on node | ||
node.snapshotEffect = undefined; | ||
} // then flush all the dom effects | ||
for (var _i = 0, _ln = domEffects.length; _i < _ln; _i++) { | ||
var _node = domEffects[_i]; | ||
_node.domEffects(); // reset the effect on node | ||
_node.domEffects = undefined; | ||
} // then flush all the component effects in reverse order | ||
for (var _i2 = componentEffects.length - 1; _i2 >= 0; _i2--) { | ||
var _node2 = componentEffects[_i2]; | ||
_node2.componentEffects(); // reset the effect on node | ||
_node2.componentEffects = undefined; | ||
} // after flushing the effect remove the thread from current running thread | ||
threads.splice(); | ||
} | ||
}, { | ||
key: "stop", | ||
value: function stop() { | ||
cancelIdleCallback(this.idleCallback); | ||
} | ||
}]); | ||
return Thread; | ||
}(); | ||
function schedule(node) { | ||
// in first phase just check if the changes called on existing node | ||
for (var i = 0, ln = threads.length; i < ln; i++) { | ||
var currentThread = threads[i]; | ||
if (currentThread.node === node) { | ||
currentThread.restart(); | ||
return; | ||
} | ||
cb(tryCount > maxAllowedRetry ? timedOutRemaining : timeRemaining); | ||
}, timeOutTime); | ||
return; | ||
} | ||
var thread = new Thread(node); | ||
var pushThread = false; // check if thread is child or parent of already running thread | ||
for (var _i3 = 0, _ln2 = threads.length; _i3 < _ln2; _i3++) { | ||
var _currentThread = threads[_i3]; | ||
var currentNode = _currentThread.node; | ||
/** | ||
* If a node is a child of already running thread | ||
* No need to add a new thread just restart the parent thread | ||
*/ | ||
if (currentNode.level > node.level && (0, _brahmosNode.haveRelation)(node, currentNode)) { | ||
_currentThread.restart(); | ||
return; | ||
/** | ||
* If the node is parent of already running thread stop those threads | ||
* and add the parent thread | ||
*/ | ||
} else if (currentNode.level < node.level && (0, _brahmosNode.haveRelation)(currentNode, node)) { | ||
threads.splice(_i3, 1); | ||
_i3 -= 1; // mark thread to be added on the thread list | ||
pushThread = true; | ||
/** | ||
* If two threads are on same level it means they might be sibling in which | ||
* case both threads are unrelated, and can be marked to pushed. | ||
*/ | ||
} else if (currentNode.level === node.level) { | ||
pushThread = true; | ||
} | ||
} // if thread is marked to be pushed, add it on thread list and start the thread | ||
if (pushThread) { | ||
threads.push(thread); | ||
thread.start(); | ||
} | ||
cb(timedOutRemaining); | ||
} |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -10,10 +8,8 @@ | ||
}); | ||
exports.lazy = exports.Suspense = void 0; | ||
exports.getClosestSuspenseFiber = getClosestSuspenseFiber; | ||
exports.getClosestSuspenseListManager = getClosestSuspenseListManager; | ||
exports.lazy = exports.Suspense = exports.SuspenseList = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
@@ -25,10 +21,22 @@ | ||
var Brahmos = _interopRequireWildcard(require("./createElement")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _Component2 = require("./Component"); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _circularDep = require("./circularDep"); | ||
var _refs = require("./refs"); | ||
var _createContext2 = _interopRequireDefault(require("./createContext")); | ||
var _utils = require("./utils"); | ||
var _transitionUtils = require("./transitionUtils"); | ||
var _updateUtils = require("./updateUtils"); | ||
var _reRender = _interopRequireDefault(require("./reRender")); | ||
var _configs = require("./configs"); | ||
var _fiber3 = require("./fiber"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -38,75 +46,406 @@ | ||
var _createContext = (0, _createContext2["default"])(), | ||
Provider = _createContext.Provider, | ||
Consumer = _createContext.Consumer; | ||
function getClosestSuspenseFiber(fiber, includeSuspenseList) { | ||
var _fiber = fiber, | ||
root = _fiber.root; | ||
var _fiber2 = fiber, | ||
nodeInstance = _fiber2.nodeInstance; | ||
var Suspense = | ||
while (!(nodeInstance instanceof Suspense || | ||
/* eslint-disable no-unmodified-loop-condition */ | ||
includeSuspenseList && nodeInstance instanceof SuspenseList)) { | ||
fiber = fiber.parent; | ||
if (fiber === root) return null; | ||
nodeInstance = fiber.nodeInstance; | ||
} | ||
return fiber; | ||
} | ||
function getClosestSuspenseListManager(manager) { | ||
var parentSuspenseManager = manager.parentSuspenseManager; | ||
return parentSuspenseManager && parentSuspenseManager.isSuspenseList ? parentSuspenseManager : null; | ||
} | ||
function getSuspenseManager(fiber, transition) { | ||
var component = fiber.nodeInstance; | ||
if (!component) return null; | ||
var suspenseManagers = component.suspenseManagers; | ||
var transitionId = transition.transitionId; | ||
var suspenseManager = suspenseManagers[transitionId]; | ||
if (!suspenseManager) { | ||
suspenseManager = suspenseManagers[transitionId] = new SuspenseManager(fiber, transition); | ||
} | ||
return suspenseManager; | ||
} | ||
function markComponentDirty(component) { | ||
component[_configs.BRAHMOS_DATA_KEY].isDirty = true; | ||
} | ||
function markManagerDirty(manager) { | ||
var fiber = (0, _fiber3.getFiberFromComponent)(manager.component); | ||
if (manager.isUnresolved() && fiber) { | ||
markComponentDirty(manager.component); | ||
(0, _fiber3.setUpdateTime)(fiber, _configs.UPDATE_TYPE_DEFERRED); | ||
} | ||
} | ||
var SuspenseManager = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2["default"])(Suspense, _Component); | ||
function () { | ||
function SuspenseManager(fiber, transition) { | ||
(0, _classCallCheck2["default"])(this, SuspenseManager); | ||
var nodeInstance = fiber.nodeInstance; | ||
this.fiber = fiber; // this is just for reference for suspense which gets resolved before committed | ||
function Suspense(props) { | ||
var _this; | ||
this.component = nodeInstance; | ||
this.transition = transition; | ||
this.childManagers = []; | ||
this.suspender = null; | ||
this.isSuspenseList = nodeInstance instanceof SuspenseList; | ||
var parentSuspenseFiber = getClosestSuspenseFiber(fiber.parent, true); | ||
this.parentSuspenseManager = parentSuspenseFiber && getSuspenseManager(parentSuspenseFiber, transition); | ||
this.rootSuspenseManager = null; | ||
this.recordChildSuspense(); // bind handleSuspense | ||
(0, _classCallCheck2["default"])(this, Suspense); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Suspense).call(this, props)); | ||
_this.state = { | ||
resolved: true | ||
}; | ||
_this.lazyElements = []; | ||
return _this; | ||
this.handleSuspense = this.handleSuspense.bind(this); | ||
} | ||
(0, _createClass2["default"])(Suspense, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.handlePromise(); | ||
(0, _createClass2["default"])(SuspenseManager, [{ | ||
key: "recordChildSuspense", | ||
value: function recordChildSuspense() { | ||
var parentSuspenseManager = this.parentSuspenseManager; | ||
if (parentSuspenseManager) { | ||
parentSuspenseManager.childManagers.push(this); | ||
this.rootSuspenseManager = parentSuspenseManager.rootSuspenseManager; | ||
} else { | ||
this.rootSuspenseManager = this; | ||
} | ||
} | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate() { | ||
this.handlePromise(); | ||
key: "addRootToProcess", | ||
value: function addRootToProcess() { | ||
var rootSuspenseManager = this.rootSuspenseManager; | ||
var _getCurrentComponentF = (0, _fiber3.getCurrentComponentFiber)(), | ||
root = _getCurrentComponentF.root; | ||
root.afterRender(rootSuspenseManager.handleSuspense); | ||
} | ||
}, { | ||
key: "handlePromise", | ||
value: function handlePromise() { | ||
var _this2 = this; | ||
key: "suspend", | ||
value: function suspend(suspender) { | ||
this.suspender = suspender; // mark root suspense to process | ||
var lazyElements = this.lazyElements; | ||
if (!lazyElements.length) return; | ||
this.addRootToProcess(); | ||
} | ||
}, { | ||
key: "handleSuspense", | ||
value: function handleSuspense() { | ||
var component = this.component, | ||
suspender = this.suspender; | ||
var isSuspenseList = component instanceof SuspenseList; | ||
if (isSuspenseList) { | ||
return this.handleSuspenseList(); | ||
} | ||
return Promise.resolve(suspender).then(this.resolve.bind(this, suspender)); | ||
} | ||
}, { | ||
key: "isUnresolved", | ||
value: function isUnresolved() { | ||
// if the manager is a suspense list, check if any of the child is unresolved | ||
// or in case of suspense if has a suspender it means its unresolved. | ||
if (this.isSuspenseList) { | ||
return this.childManagers.some(function (manager) { | ||
return manager.isUnresolved(); | ||
}); | ||
} else { | ||
return this.suspender; | ||
} | ||
} | ||
}, { | ||
key: "shouldShowFallback", | ||
value: function shouldShowFallback() { | ||
var suspenseListManager = getClosestSuspenseListManager(this); // if there is no closest suspense list manager then return true | ||
if (!suspenseListManager) return true; | ||
var suspenseList = suspenseListManager.component, | ||
siblingManagers = suspenseListManager.childManagers; | ||
var tail = suspenseList.props.tail; // get the parent of suspenseListManger | ||
var parentSuspenseListManager = getClosestSuspenseListManager(suspenseListManager); | ||
/** | ||
* If there are lazy elements wait for all of the lazy element to get resolved | ||
* and then show children. | ||
* If suspense list has another parent suspense list, and the suspense list | ||
* is marked to not show fallback return false | ||
* | ||
* Or else in case of collapsed show the fallback on the first unresolved suspense. | ||
*/ | ||
Promise.all(lazyElements).then(function (res) { | ||
_this2.lazyElements = []; | ||
if (parentSuspenseListManager && !suspenseListManager.shouldShowFallback()) { | ||
return false; | ||
} else if (tail === 'collapsed') { | ||
for (var i = 0, ln = siblingManagers.length; i < ln; i++) { | ||
var manager = siblingManagers[i]; | ||
/** | ||
* If any of previous manager is suspended and which is not same as the manager | ||
* we are testing then return false | ||
*/ | ||
_this2.setState({ | ||
resolved: true | ||
if (tail === 'collapsed' && manager.isUnresolved()) { | ||
return manager === this; | ||
} | ||
} | ||
} | ||
return tail !== 'hidden'; | ||
} | ||
}, { | ||
key: "resolve", | ||
value: function resolve(resolvedWithSuspender) { | ||
var _this = this; | ||
var component = this.component, | ||
transition = this.transition, | ||
suspender = this.suspender, | ||
childManagers = this.childManagers; | ||
var pendingSuspense = transition.pendingSuspense || []; | ||
/** | ||
* if it is resolved with different suspender then current suspender | ||
* Then no nee to process further | ||
*/ | ||
if (resolvedWithSuspender !== suspender) return; | ||
/** | ||
* if there isn't any suspender, child managers may have suspender | ||
* Loop on child manager and handle their suspense | ||
*/ | ||
if (!suspender) { | ||
childManagers.forEach(function (manager) { | ||
manager.handleSuspense(); | ||
}); | ||
return; | ||
} // mark the suspense to be resolved and component as dirty | ||
this.suspender = null; | ||
markComponentDirty(this.component); | ||
var transitionTimedOut = transition.transitionState === _transitionUtils.TRANSITION_STATE_TIMED_OUT; // Get the unresolved suspense for the transition. | ||
var transitionHasUnresolvedSuspense = pendingSuspense.filter(function (suspense) { | ||
return suspense.suspenseManagers[transition.transitionId].suspender; | ||
}).length; | ||
/** | ||
* set transition state as resolved if transition is not timed out and it doesn't | ||
* have any unresolved sibling | ||
*/ | ||
if (!transitionTimedOut && !transitionHasUnresolvedSuspense) { | ||
transition.transitionState = _transitionUtils.TRANSITION_STATE_RESOLVED; | ||
} | ||
/** | ||
* If the transition is timed out or the suspense is not part of | ||
* the transition pendingSuspense list we need to do normal deferred rendering | ||
* Otherwise do re-render with the transition. | ||
*/ | ||
var doSuspenseRerender = function doSuspenseRerender() { | ||
var targetComponent = component; | ||
/** | ||
* If there is no fiber reference on the component, it means suspense is resolved before commit. | ||
* In which case there must be some parent which has pending update. | ||
* So we just need to restart deferred workLoop, which we can do by rerendering from wip fiber. | ||
*/ | ||
if (!(0, _fiber3.getFiberFromComponent)(component)) targetComponent = _this.fiber.root.wip.nodeInstance; | ||
(0, _reRender["default"])(targetComponent); | ||
}; // trigger rerender on specific intervals | ||
setTimeout(function () { | ||
if (transitionTimedOut || !pendingSuspense.includes(component)) { | ||
(0, _updateUtils.deferredUpdates)(doSuspenseRerender); | ||
} else { | ||
(0, _updateUtils.withTransition)(transition, doSuspenseRerender); | ||
} | ||
}, Date.now() % _configs.SUSPENSE_REVEAL_INTERVAL); | ||
} | ||
}, { | ||
key: "getChildrenSuspenders", | ||
value: function getChildrenSuspenders() { | ||
var childSuspenders = []; | ||
this.childManagers.forEach(function (manager) { | ||
if (manager.isSuspenseList) { | ||
childSuspenders = childSuspenders.concat(manager.getChildrenSuspenders()); | ||
} else if (manager.suspender) { | ||
childSuspenders.push(manager.suspender); | ||
} | ||
}); | ||
return childSuspenders; | ||
} | ||
}, { | ||
key: "handleSuspenseList", | ||
value: function handleSuspenseList() { | ||
var component = this.component, | ||
childManagers = this.childManagers; | ||
var _component$props = component.props, | ||
_component$props$reve = _component$props.revealOrder, | ||
revealOrder = _component$props$reve === void 0 ? 'together' : _component$props$reve, | ||
tail = _component$props.tail; // resolve the child managers based on reveal order | ||
var handleManagerInOrder = function handleManagerInOrder(promise, manager) { | ||
return promise.then(function () { | ||
/** | ||
* If we are doing forward reveal order and have mentioned | ||
* tail to be collapsed we need to mark the next manager as dirty | ||
* so that the next component can show loading state | ||
*/ | ||
if (revealOrder === 'forwards' && tail === 'collapsed') { | ||
markManagerDirty(manager); | ||
} | ||
return manager.handleSuspense(); | ||
}); | ||
}; | ||
/** | ||
* Create a promise which resolves after all the child managers are resolved | ||
*/ | ||
var allSuspenderPromise = Promise.all(this.getChildrenSuspenders()); | ||
/** | ||
* If reveal order is together we resolve all the manager only | ||
* when all the suspenders are resolved. | ||
* | ||
* In case of forwards and backwards the managers need to resolved | ||
* in the provided order event the promise resolves concurrently | ||
*/ | ||
if (revealOrder === 'together') { | ||
allSuspenderPromise.then(function () { | ||
childManagers.forEach(function (manager) { | ||
return manager.handleSuspense(); | ||
}); | ||
}); | ||
} else if (revealOrder === 'forwards') { | ||
var promise = Promise.resolve(); | ||
for (var i = 0, ln = childManagers.length; i < ln; i++) { | ||
promise = handleManagerInOrder(promise, childManagers[i]); | ||
} | ||
} else if (revealOrder === 'backwards') { | ||
var _promise = Promise.resolve(); | ||
for (var _i = childManagers.length - 1; _i >= 0; _i--) { | ||
_promise = handleManagerInOrder(_promise, childManagers[_i]); | ||
} | ||
} | ||
return allSuspenderPromise; | ||
} | ||
}]); | ||
return SuspenseManager; | ||
}(); | ||
function getActiveTransition(component) { | ||
var fiber = (0, _fiber3.getCurrentComponentFiber)(); | ||
var transition = (0, _transitionUtils.getTransitionFromFiber)(fiber, _transitionUtils.PREDEFINED_TRANSITION_DEFERRED); | ||
/** | ||
* If the transition is resolved and pendingSuspense does not include the instance | ||
* then use the predefined deferred transition as transition | ||
* This will happen only when called through handleSuspense | ||
*/ | ||
if (transition.transitionState === _transitionUtils.TRANSITION_STATE_RESOLVED && !transition.pendingSuspense.includes(component)) { | ||
transition = _transitionUtils.PREDEFINED_TRANSITION_DEFERRED; | ||
} | ||
return transition; | ||
} | ||
var SuspenseList = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2["default"])(SuspenseList, _Component); | ||
function SuspenseList(props) { | ||
var _this2; | ||
(0, _classCallCheck2["default"])(this, SuspenseList); | ||
_this2 = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(SuspenseList).call(this, props)); | ||
_this2.suspenseManagers = {}; | ||
return _this2; | ||
} | ||
(0, _createClass2["default"])(SuspenseList, [{ | ||
key: "render", | ||
value: function render() { | ||
var lazyElements = this.lazyElements; | ||
var _this$props = this.props, | ||
fallback = _this$props.fallback, | ||
children = _this$props.children; | ||
var resolved = this.state.resolved; | ||
return this.props.children; | ||
} | ||
}]); | ||
return SuspenseList; | ||
}(_circularDep.Component); | ||
exports.SuspenseList = SuspenseList; | ||
var Suspense = | ||
/*#__PURE__*/ | ||
function (_Component2) { | ||
(0, _inherits2["default"])(Suspense, _Component2); | ||
function Suspense(props) { | ||
var _this3; | ||
(0, _classCallCheck2["default"])(this, Suspense); | ||
_this3 = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Suspense).call(this, props)); | ||
_this3.suspenseManagers = {}; | ||
return _this3; | ||
} | ||
(0, _createClass2["default"])(Suspense, [{ | ||
key: "handleSuspender", | ||
value: function handleSuspender(suspender, suspenseFiber) { | ||
var transition = getActiveTransition(this); | ||
var suspenseManager = getSuspenseManager(suspenseFiber, transition); | ||
/** | ||
* Show fallback till all promise are resolved, and if there are no promise | ||
* just show the children | ||
* We pass an array of lazyElement through provider so all lazy elements can | ||
* add itself to suspense so that suspense can wait for them to resolved. | ||
* Mark current transition as suspended | ||
* only if transition is not completed or timed out. | ||
*/ | ||
return Brahmos.createElement(Provider, { | ||
value: lazyElements | ||
}, resolved ? children : fallback); | ||
if (!(0, _transitionUtils.isTransitionCompleted)(transition)) { | ||
/** | ||
* Add current suspense to pending suspense | ||
*/ | ||
if (!transition.pendingSuspense.includes(this)) { | ||
transition.pendingSuspense.push(this); | ||
} // Mark the transition as suspended | ||
transition.transitionState = _transitionUtils.TRANSITION_STATE_SUSPENDED; | ||
} | ||
suspenseManager.suspend(suspender); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var transition = getActiveTransition(this); | ||
var fiber = (0, _fiber3.getCurrentComponentFiber)(); | ||
var suspenseManager = getSuspenseManager(fiber, transition); | ||
var resolved = !suspenseManager.suspender; | ||
var _this$props = this.props, | ||
fallback = _this$props.fallback, | ||
children = _this$props.children; | ||
if (resolved) return children;else if (suspenseManager.shouldShowFallback()) return fallback;else return null; | ||
} | ||
}]); | ||
return Suspense; | ||
}(_Component2.Component); | ||
}(_circularDep.Component); | ||
@@ -116,24 +455,17 @@ exports.Suspense = Suspense; | ||
var lazy = function lazy(lazyCallback) { | ||
var Component; | ||
return (0, _refs.forwardRef)(function (props, ref) { | ||
return Brahmos.createElement(Consumer, {}, function (lazyElements) { | ||
/** | ||
* if lazy component is already loaded just render it, | ||
* if not pass the lazy promise to the suspense, so it is aware of promise being resolved. | ||
*/ | ||
if (Component) { | ||
return Brahmos.createElement(Component, _objectSpread({}, props, { | ||
ref: ref | ||
})); | ||
} else { | ||
var promise = lazyCallback(); | ||
promise.then(function (Comp) { | ||
Component = Comp["default"] || Comp; | ||
}); | ||
lazyElements.push(promise); | ||
} | ||
}); | ||
}); | ||
var componentSuspender; | ||
var LazyComponent = (0, _refs.forwardRef)(function (props, ref) { | ||
var ComponentModule = componentSuspender.read(); | ||
return (0, _circularDep.createElement)(ComponentModule["default"], _objectSpread({}, props, { | ||
ref: ref | ||
}), props.children); | ||
}); // assign a method to lazy load to start loading during createElement call | ||
LazyComponent.__loadLazyComponent = function () { | ||
if (!componentSuspender) componentSuspender = (0, _utils.getPromiseSuspendedValue)(lazyCallback()); | ||
}; | ||
return LazyComponent; | ||
}; | ||
exports.lazy = lazy; |
@@ -12,4 +12,2 @@ "use strict"; | ||
var _mountAndEffectQueue = require("./mountAndEffectQueue"); | ||
var _refs = require("./refs"); | ||
@@ -19,96 +17,85 @@ | ||
function handleUnmount(node) { | ||
var componentInstance = node.componentInstance, | ||
ref = node.ref, | ||
mountHandler = node.mountHandler; | ||
var _configs = require("./configs"); | ||
function tearDownChild(child, part, _isTagNode, removeDOM) { | ||
/** | ||
* If node is mounted and | ||
* if node is classComponent We may have to call componentWillUnmount lifecycle method | ||
* In case of functional component we have to clean all the effects for that component | ||
* if we got a tag to remove for child nodes we don't need to remove those | ||
* nodes in child fibers as it will be remove by current fiber | ||
* Note, some child node can be outside of the dom boundary a TagNode is covering | ||
* So we should check if the parent node of the child is not same as the tagNode. | ||
*/ | ||
var _removeDOM = child.part.parentNode !== part.parentNode && _isTagNode ? false : removeDOM; // if a child is portal then we should keep the remove dom to true | ||
if (componentInstance && componentInstance.__mounted) { | ||
if (node.nodeType === _brahmosNode.CLASS_COMPONENT_NODE) { | ||
(0, _utils.callLifeCycle)(componentInstance, 'componentWillUnmount'); // set the ref as null of a class component | ||
(0, _refs.setRef)(ref, null); // and for functional component remove effects | ||
} else { | ||
(0, _hooks.cleanEffects)(componentInstance, true); | ||
} | ||
} else if (mountHandler) { | ||
/** | ||
* If node is not mounted remove the mount handlers from the mount queue | ||
*/ | ||
(0, _mountAndEffectQueue.removeHandler)(node.mountHandler); | ||
var node = child.node; | ||
if (node && node.portalContainer) { | ||
_removeDOM = true; | ||
} | ||
/** | ||
* loop over child nodes and tear it down as well | ||
*/ | ||
tearDownFiber(child, _removeDOM); | ||
} | ||
if (Array.isArray(node)) { | ||
for (var i = 0, ln = node.length; i < ln; i++) { | ||
tearDownNode(node[i]); | ||
} | ||
} else if ((0, _brahmosNode.isTagNode)(node)) { | ||
var values = node.values, | ||
_node$templateNode = node.templateNode, | ||
parts = _node$templateNode.parts, | ||
domNodes = _node$templateNode.domNodes; | ||
function tearDownFiber(fiber, removeDOM) { | ||
var node = fiber.node, | ||
part = fiber.part, | ||
nodeInstance = fiber.nodeInstance; // bail out shouldTearDown is false or if node is non-renderable node | ||
for (var _i = 0, _ln = parts.length; _i < _ln; _i++) { | ||
var part = parts[_i]; | ||
var value = values[_i]; // if part is node than tear down the node value | ||
if (!(0, _brahmosNode.isRenderableNode)(node)) return; // recurse to the children and tear them down first | ||
if (part.isNode) { | ||
tearDownNode(value); | ||
} // if part is attribute type look for ref attribute and set the ref as null | ||
var _isTagNode = (0, _brahmosNode.isTagNode)(node); | ||
var child = fiber.child; | ||
if (part.isAttribute) { | ||
(0, _utils.loopEntries)(value, function (attrName, attrValue) { | ||
if (attrName === 'ref') { | ||
(0, _refs.setRef)(attrValue, null); | ||
} | ||
}); | ||
} | ||
} // remove all the elements of templateNode | ||
if (child) { | ||
tearDownChild(child, part, _isTagNode, removeDOM); | ||
while (child.sibling) { | ||
child = child.sibling; | ||
tearDownChild(child, part, _isTagNode, removeDOM); | ||
} | ||
} // if it is primitive node we need to delete the text node associated with it | ||
(0, _utils.remove)(domNodes); // remove the template node | ||
node.templateNode = null; // call the ref methods of attribute parts | ||
} else if ((0, _brahmosNode.isComponentNode)(node)) { | ||
tearDownNode(componentInstance.__nodes); // mark componentInstance as unmounted | ||
componentInstance.__mounted = false; // remove the componentInstance from node; | ||
node.componentInstance = null; | ||
if ((0, _brahmosNode.isPrimitiveNode)(node) && removeDOM) { | ||
var textNode = (0, _utils.getNextSibling)(part.parentNode, part.previousSibling); | ||
(0, _utils.remove)(textNode); | ||
return; | ||
} | ||
} | ||
function tearDownNode(node, part) { | ||
// bail out if node is non-renderable node or if the node is reused (It might be on different index ) | ||
if (!(0, _brahmosNode.isRenderableNode)(node) || node.isReused) return; | ||
var ref = node.ref; | ||
/** | ||
* in case of portal nodes the passed part information will be incorrect | ||
* as the node is ported to a different dom node. | ||
* In such case take create part information based on portalContainer | ||
* We have to only handle tag, component and attributes, | ||
* as tag has elements to remove, attribute fiber can have ref to unset | ||
* and component can have ref and lifecycle method to call. | ||
* | ||
* Text nodes will be remove by removing its parent tag node. So no | ||
* need to handle text node separately | ||
*/ | ||
var portalContainer = node.portalContainer; | ||
/** | ||
* This will cover ATTRIBUTE_NODE as well, so no need to handle them separately | ||
*/ | ||
if (portalContainer) { | ||
part = { | ||
parentNode: portalContainer, | ||
isNode: true | ||
}; | ||
} // call componentWillUnmount Lifecycle | ||
if (ref) { | ||
(0, _refs.setRef)(ref, null); | ||
} // if there is no nodeInstance it means its not rendered yet so no need do anything on that | ||
// NOTE: This has to be after ref logic as attribute nodes do not have nodeInstance but setRef has to be done | ||
handleUnmount(node); // // if part is defined it means we need to delete all nodes on a given part | ||
// if (part) { | ||
// const { parentNode, previousSibling, nextSibling } = part; | ||
// deleteNodesBetween(parentNode, previousSibling, nextSibling); | ||
// } | ||
if (!nodeInstance) return; // if it is a tag node remove the dom elements added by tag node | ||
if (_isTagNode) { | ||
var domNodes = nodeInstance.domNodes; // remove all the elements of nodeInstance | ||
if (removeDOM) (0, _utils.remove)(domNodes); | ||
} // if its a component node and is mounted then call lifecycle methods | ||
else if ((0, _brahmosNode.isComponentNode)(node) && nodeInstance[_configs.BRAHMOS_DATA_KEY].mounted) { | ||
// for class component call componentWillUnmount and for functional comp clean effects | ||
if (node.nodeType === _brahmosNode.CLASS_COMPONENT_NODE) { | ||
(0, _utils.callLifeCycle)(nodeInstance, 'componentWillUnmount'); | ||
} else { | ||
(0, _hooks.cleanEffects)(fiber, true); | ||
} | ||
} | ||
} | ||
@@ -118,12 +105,8 @@ | ||
var tearDownFibers = root.tearDownFibers; | ||
tearDownFibers.forEach(function (fiber) { | ||
// only tear down those fibers which are marked for tear down | ||
if (fiber.shouldTearDown) tearDownFiber(fiber, true); | ||
}); // rest the tear down fibers | ||
for (var i = 0, ln = tearDownFibers.length; i < ln; i++) { | ||
var _tearDownFibers$i = tearDownFibers[i], | ||
node = _tearDownFibers$i.node, | ||
part = _tearDownFibers$i.part; | ||
tearDownNode(node, part); | ||
} // rest the tear down fibers | ||
root.tearDownFibers = []; | ||
} |
@@ -117,13 +117,11 @@ "use strict"; | ||
/** | ||
* If the node is a node marker add previous sibling and next sibling | ||
* detail so later we can find the exact place where value has to come | ||
* If the node is a node marker add previous sibling and parentNode details | ||
* so later we can find the exact place where value has to come | ||
*/ | ||
/** | ||
* Wrap the element with a text node if previous or next sibling | ||
* is Brahmos comment node. This makes locating dynamic part much | ||
* easier. | ||
* Add a dummy text node before if the previous element is a Brahmos comment node | ||
* This makes locating dynamic part easier | ||
*/ | ||
var previousSibling = current.previousSibling, | ||
nextSibling = current.nextSibling; | ||
var previousSibling = current.previousSibling; | ||
@@ -134,11 +132,6 @@ if (isBrahmosCommentNode(previousSibling)) { | ||
if (isBrahmosCommentNode(nextSibling)) { | ||
nextSibling = (0, _utils.createEmptyTextNode)(current); | ||
} | ||
parts.push(_objectSpread({}, partMeta, { | ||
// Spread object is slow, but bublejs compiles it to Object.assign which is optimized | ||
parentNode: parentNode, | ||
previousSibling: previousSibling, | ||
nextSibling: nextSibling | ||
previousSibling: previousSibling | ||
})); | ||
@@ -159,3 +152,2 @@ goToNextPart(); // add the comment node to the remove list | ||
var parentNode = nodePart.parentNode, | ||
nextSibling = nodePart.nextSibling, | ||
previousSibling = nodePart.previousSibling; | ||
@@ -169,3 +161,2 @@ if (this.patched) return; | ||
part.parentNode = parentNode; | ||
part.nextSibling = part.nextSibling || nextSibling; | ||
part.previousSibling = part.previousSibling || previousSibling; | ||
@@ -172,0 +163,0 @@ } |
@@ -6,20 +6,30 @@ "use strict"; | ||
}); | ||
exports.isTransitionCompleted = isTransitionCompleted; | ||
exports.isTransitionResolved = isTransitionResolved; | ||
exports.setTransitionComplete = setTransitionComplete; | ||
exports.getTransitionFromFiber = getTransitionFromFiber; | ||
exports.getFirstPendingTransition = getFirstPendingTransition; | ||
exports.PREDEFINED_TRANSITION_DEFERRED = exports.PREDEFINED_TRANSITION_SYNC = exports.TRANSITION_STATE_COMPLETED = exports.TRANSITION_STATE_SUSPENDED = exports.TRANSITION_STATE_TIMED_OUT = exports.TRANSITION_STATE_PENDING = exports.TRANSITION_STATE_INITIAL = void 0; | ||
exports.getFirstTransitionToProcess = getFirstTransitionToProcess; | ||
exports.isCustomTransition = isCustomTransition; | ||
exports.PREDEFINED_TRANSITION_DEFERRED = exports.PREDEFINED_TRANSITION_SYNC = exports.TRANSITION_STATE_TIMED_OUT = exports.TRANSITION_STATE_COMPLETED = exports.TRANSITION_STATE_RESOLVED = exports.TRANSITION_STATE_SUSPENDED = exports.TRANSITION_STATE_START = exports.TRANSITION_STATE_INITIAL = void 0; | ||
var _utils = require("./utils"); | ||
var _configs = require("./configs"); | ||
var TRANSITION_STATE_INITIAL = 'initial'; | ||
exports.TRANSITION_STATE_INITIAL = TRANSITION_STATE_INITIAL; | ||
var TRANSITION_STATE_PENDING = 'pending'; | ||
exports.TRANSITION_STATE_PENDING = TRANSITION_STATE_PENDING; | ||
var TRANSITION_STATE_TIMED_OUT = 'timedOut'; | ||
exports.TRANSITION_STATE_TIMED_OUT = TRANSITION_STATE_TIMED_OUT; | ||
var TRANSITION_STATE_START = 'start'; | ||
exports.TRANSITION_STATE_START = TRANSITION_STATE_START; | ||
var TRANSITION_STATE_SUSPENDED = 'suspended'; | ||
exports.TRANSITION_STATE_SUSPENDED = TRANSITION_STATE_SUSPENDED; | ||
var TRANSITION_STATE_RESOLVED = 'resolved'; | ||
exports.TRANSITION_STATE_RESOLVED = TRANSITION_STATE_RESOLVED; | ||
var TRANSITION_STATE_COMPLETED = 'completed'; | ||
exports.TRANSITION_STATE_COMPLETED = TRANSITION_STATE_COMPLETED; | ||
var TRANSITION_STATE_TIMED_OUT = 'timedOut'; | ||
exports.TRANSITION_STATE_TIMED_OUT = TRANSITION_STATE_TIMED_OUT; | ||
var PREDEFINED_TRANSITION_SYNC = { | ||
transitionId: '' | ||
transitionId: '', | ||
tryCount: 0, | ||
transitionState: TRANSITION_STATE_TIMED_OUT | ||
}; | ||
@@ -29,5 +39,40 @@ exports.PREDEFINED_TRANSITION_SYNC = PREDEFINED_TRANSITION_SYNC; | ||
transitionId: (0, _utils.getUniqueId)(), | ||
isPending: false, | ||
tryCount: 0, | ||
transitionState: TRANSITION_STATE_TIMED_OUT | ||
}; | ||
exports.PREDEFINED_TRANSITION_DEFERRED = PREDEFINED_TRANSITION_DEFERRED; | ||
function shouldProcessTransition(transition) { | ||
var transitionState = transition.transitionState; | ||
return transitionState === TRANSITION_STATE_START || transitionState === TRANSITION_STATE_RESOLVED || transitionState === TRANSITION_STATE_TIMED_OUT; | ||
} | ||
function isTransitionCompleted(transition) { | ||
var transitionState = transition.transitionState; | ||
return transitionState === TRANSITION_STATE_COMPLETED || transitionState === TRANSITION_STATE_TIMED_OUT; | ||
} | ||
function isTransitionResolved(transition) { | ||
var transitionState = transition.transitionState; // send true, on either the transition is resolved or completed | ||
return transitionState === TRANSITION_STATE_RESOLVED || isTransitionCompleted(transition); | ||
} | ||
function setTransitionComplete(transition) { | ||
var transitionState = transition.transitionState; | ||
if (transitionState !== TRANSITION_STATE_TIMED_OUT && transitionState !== TRANSITION_STATE_SUSPENDED) { | ||
/** | ||
* If transition is in pending state, first reset the isPending state | ||
* and then on next render cycle mark transition as completed | ||
* so that isPending and transition changes can be shown on one commit phase | ||
*/ | ||
if (transition.isPending) { | ||
transition.clearTimeout(); | ||
transition.updatePendingState(false, _configs.UPDATE_SOURCE_TRANSITION); | ||
} else { | ||
transition.transitionState = TRANSITION_STATE_COMPLETED; | ||
} | ||
} | ||
} | ||
/** | ||
@@ -37,7 +82,7 @@ * get current transition id from the current rendering | ||
exports.PREDEFINED_TRANSITION_DEFERRED = PREDEFINED_TRANSITION_DEFERRED; | ||
function getTransitionFromFiber(fiber) { | ||
var currentTransition = fiber.root.currentTransition; | ||
return currentTransition || PREDEFINED_TRANSITION_SYNC; | ||
function getTransitionFromFiber(fiber, defaultTransition) { | ||
defaultTransition = defaultTransition || PREDEFINED_TRANSITION_SYNC; // if there is currentTransition return that or else return SYNC transition | ||
return fiber.root.currentTransition || defaultTransition; | ||
} | ||
@@ -49,7 +94,13 @@ /** | ||
function getFirstPendingTransition(root) { | ||
function getFirstTransitionToProcess(root) { | ||
var pendingTransitions = root.pendingTransitions; | ||
return pendingTransitions.find(function (transition) { | ||
return transition.transitionState === TRANSITION_STATE_PENDING; | ||
}); | ||
return pendingTransitions.find(shouldProcessTransition); | ||
} | ||
/** | ||
* function to check if a transition is a custom transition | ||
*/ | ||
function isCustomTransition(transition) { | ||
return !!transition.startTransition; | ||
} |
@@ -12,10 +12,17 @@ "use strict"; | ||
var _fiber = require("./fiber"); | ||
function unmountComponentAtNode(container) { | ||
/** | ||
* if container has a brahmosNode, it will be tear down. | ||
*/ | ||
if (container.__brahmosNode) { | ||
(0, _tearDown["default"])(container.__brahmosNode, { | ||
parentNode: container | ||
}); | ||
* Most of the time we only to unmount component from the root elem | ||
* TODO: Should we support unmounting from any element rendered by react itself. Check if React allows that | ||
*/ | ||
var root = container.__rootFiber; | ||
if (root) { | ||
// tear down the current tree | ||
(0, _fiber.markToTearDown)(root.current); | ||
(0, _tearDown["default"])(root); // remove the __rootFiber reference | ||
container.__rootFiber = undefined; | ||
return true; | ||
@@ -22,0 +29,0 @@ } |
152
lib/utils.js
@@ -14,15 +14,13 @@ "use strict"; | ||
exports.isNil = isNil; | ||
exports.now = now; | ||
exports.addDataContainer = addDataContainer; | ||
exports.omit = omit; | ||
exports.getNormalizedProps = getNormalizedProps; | ||
exports.loopEntries = loopEntries; | ||
exports.remove = remove; | ||
exports.getKey = getKey; | ||
exports.isClassComponent = isClassComponent; | ||
exports.toArray = toArray; | ||
exports.lastItem = lastItem; | ||
exports.changeToNode = changeToNode; | ||
exports.deleteNodesBetween = deleteNodesBetween; | ||
exports.insertBefore = insertBefore; | ||
exports.unwrap = unwrap; | ||
exports.getCurrentNode = getCurrentNode; | ||
exports.getNextSibling = getNextSibling; | ||
exports.mergeState = mergeState; | ||
@@ -33,2 +31,3 @@ exports.callLifeCycle = callLifeCycle; | ||
exports.getUniqueId = getUniqueId; | ||
exports.getPromiseSuspendedValue = getPromiseSuspendedValue; | ||
@@ -39,6 +38,2 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _Component = require("./Component"); | ||
var _brahmosNode = require("./brahmosNode"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -80,2 +75,15 @@ | ||
return val === undefined || val === null; | ||
} | ||
/** | ||
* function to return artificial time, we are using counter | ||
* instead of time as Date.now or performance.now is little slower than just a counter | ||
* Note: when we add support for SSR, we should have a way to reset the initial time to | ||
* not let this initialTime grow infinitely | ||
*/ | ||
var initialTime = 0; | ||
function now() { | ||
return initialTime++; | ||
} // add brahmos data container to domNode | ||
@@ -87,3 +95,2 @@ | ||
domNode.__brahmosData = { | ||
attributes: {}, | ||
events: {} | ||
@@ -93,13 +100,12 @@ }; | ||
/** | ||
* A smaller utility to omit keys from objects | ||
* function to separate props, key and ref | ||
*/ | ||
function omit(obj, keys) { | ||
function getNormalizedProps(props, includeRef) { | ||
var newObj = {}; | ||
var objKeys = Object.keys(obj); | ||
var key; | ||
for (var i = 0, l = objKeys.length; i < l; i++) { | ||
var key = objKeys[i]; | ||
if (!keys[key]) newObj[key] = obj[key]; | ||
for (key in props) { | ||
if (key !== 'key' && (key !== 'ref' || includeRef)) newObj[key] = props[key]; | ||
} | ||
@@ -137,45 +143,2 @@ | ||
/** | ||
* Get the key of looped node | ||
*/ | ||
function getKey(node, index) { | ||
/** | ||
* Get the key from node directly if not | ||
* found search key on the values | ||
*/ | ||
var key = node && node.key; | ||
if (key === '' && node && (0, _brahmosNode.isTagNode)(node)) { | ||
/** | ||
* TODO: This might be buggy, it can give key from any node, | ||
* not necessarily key from the root node. | ||
*/ | ||
var values = node.values; | ||
for (var i = 0, ln = values.length; i < ln; i++) { | ||
var value = values[i]; | ||
if (value.key !== undefined) { | ||
key = '' + value.key; | ||
break; | ||
} | ||
} // store the calculated key on node so we don't have to search next time on same node | ||
node.key = key === undefined ? '' : '' + key; | ||
} | ||
/** | ||
* if key is defined use key or else use index as key. | ||
* Also key should always be a string | ||
*/ | ||
return key === '' ? '' + index : key; | ||
} | ||
function isClassComponent(element) { | ||
return element.prototype instanceof _Component.Component; | ||
} | ||
/** | ||
* Convert an array like object to array | ||
@@ -224,29 +187,2 @@ */ | ||
/** | ||
* Function to delete all child nodes of a parent between start and end node | ||
*/ | ||
function deleteNodesBetween(parent, start, end) { | ||
// If both start and end is null, it means we want to clear all the children | ||
if (!start && !end) { | ||
parent.innerHTML = ''; | ||
return; | ||
} | ||
var node; | ||
if (!start) { | ||
node = parent.firstChild; | ||
} else { | ||
node = start.nextSibling; | ||
} | ||
while (node && node !== end) { | ||
var _node = node, | ||
nextSibling = _node.nextSibling; | ||
parent.removeChild(node); | ||
node = nextSibling; | ||
} | ||
} | ||
/** | ||
* Function to add child nodes before endNode, if it is not defined or null | ||
@@ -284,16 +220,7 @@ * It will add nodes on the last | ||
parent.removeChild(el); | ||
} | ||
/** | ||
* Get the node reference based on previousSibling, nextSibling or parentNode | ||
*/ | ||
} // function to get next sibling based on parent node and previous sibling | ||
function getCurrentNode(parentNode, previousSibling, nextSibling) { | ||
if (previousSibling) { | ||
return previousSibling.nextSibling; | ||
} else if (nextSibling) { | ||
return nextSibling.previousSibling; | ||
} else { | ||
return parentNode.firstChild; | ||
} | ||
function getNextSibling(parentNode, previousSibling) { | ||
return previousSibling ? previousSibling.nextSibling : parentNode.firstChild; | ||
} | ||
@@ -353,3 +280,30 @@ /** | ||
function getUniqueId() { | ||
return performance.now() + '-' + Math.random() * 1000000; | ||
return now() + '-' + Math.random() * 1000000; | ||
} | ||
/** | ||
* Method to get a promise which support suspension of rendering | ||
*/ | ||
function getPromiseSuspendedValue(promise) { | ||
var status = 'pending'; | ||
var result; | ||
var suspender = promise.then(function (r) { | ||
status = 'success'; | ||
result = r; | ||
}, function (e) { | ||
status = 'error'; | ||
result = e; | ||
}); | ||
return { | ||
read: function read() { | ||
if (status === 'pending') { | ||
throw suspender; | ||
} else if (status === 'error') { | ||
throw result; | ||
} else if (status === 'success') { | ||
return result; | ||
} | ||
} | ||
}; | ||
} |
@@ -10,3 +10,2 @@ "use strict"; | ||
}); | ||
exports.schedule = schedule; | ||
exports.processFiber = processFiber; | ||
@@ -20,2 +19,4 @@ exports["default"] = workLoop; | ||
var _configs = require("./configs"); | ||
var _processComponentFiber = _interopRequireDefault(require("./processComponentFiber")); | ||
@@ -29,3 +30,3 @@ | ||
var _updateMetaUtils = require("./updateMetaUtils"); | ||
var _updateUtils = require("./updateUtils"); | ||
@@ -40,26 +41,16 @@ var _transitionUtils = require("./transitionUtils"); | ||
var TIME_REQUIRE_TO_PROCESS_FIBER = 2; | ||
var _utils = require("./utils"); | ||
function schedule(shouldSchedule, cb) { | ||
if (shouldSchedule) { | ||
return requestIdleCallback(cb, { | ||
timeout: 1000 | ||
}); | ||
} | ||
var _schedular = _interopRequireDefault(require("./schedular")); | ||
cb(); | ||
} | ||
function fiberHasUnprocessedUpdates(fiber) { | ||
var node = fiber.node, | ||
root = fiber.root; | ||
var updateType = root.updateType; | ||
var componentInstance = node.componentInstance; | ||
nodeInstance = fiber.nodeInstance; | ||
/** | ||
* Return if node is not component type or if it is component | ||
* which is yet to mount (componentInstance will be null in such case) | ||
* which is yet to mount (nodeInstance will be null in such case) | ||
*/ | ||
if (!componentInstance) return false; | ||
return !!(0, _updateMetaUtils.getPendingUpdates)(updateType, componentInstance).length; | ||
if (!((0, _brahmosNode.isComponentNode)(node) && nodeInstance)) return false; | ||
return !!(0, _updateUtils.getPendingUpdates)(fiber).length || nodeInstance[_configs.BRAHMOS_DATA_KEY].isDirty; | ||
} | ||
@@ -69,7 +60,6 @@ | ||
var node = fiber.node, | ||
root = fiber.root, | ||
alternate = fiber.alternate; // if new node is null mark old node to tear down | ||
if (!(0, _brahmosNode.isRenderableNode)(node) && alternate) { | ||
root.tearDownFibers.push(alternate); | ||
if (!(0, _brahmosNode.isRenderableNode)(node)) { | ||
if (alternate) (0, _fiber2.markToTearDown)(alternate); | ||
return; | ||
@@ -101,15 +91,22 @@ } | ||
} else if (node.nodeType === _brahmosNode.ATTRIBUTE_NODE) { | ||
(0, _fiber2.linkEffect)(fiber); | ||
// nothing to on process phase, just mark that the fiber has uncommitted effects | ||
(0, _fiber2.markPendingEffect)(fiber, _configs.EFFECT_TYPE_OTHER); | ||
} // after processing, set the processedTime to the fiber | ||
fiber.processedTime = performance.now(); | ||
fiber.processedTime = (0, _utils.now)(); | ||
} | ||
function shouldCommit(root) { | ||
if (root.updateSource === _updateMetaUtils.UPDATE_SOURCE_TRANSITION) { | ||
var transitionState = root.currentTransition.transitionState; | ||
return transitionState === _transitionUtils.TRANSITION_STATE_COMPLETED || transitionState === _transitionUtils.TRANSITION_STATE_TIMED_OUT; | ||
} | ||
// if the update source is transition check if transition is completed | ||
if (root.updateSource === _configs.UPDATE_SOURCE_TRANSITION) { | ||
/** | ||
* all sync changes should be committed before committing transition, | ||
* for a transition to be committed it shouldn't have any pending commits | ||
* if not no need to run the commit phase | ||
*/ | ||
return root.lastCompleteTime >= root.updateTime && root.hasUncommittedEffect && (0, _transitionUtils.isTransitionCompleted)(root.currentTransition); | ||
} // otherwise return true for sync commits | ||
return true; | ||
@@ -123,23 +120,36 @@ } | ||
function commitChanges(root, onComplete) { | ||
var lastCompleteTimeKey = root.updateType === 'deferred' ? 'lastDeferredCompleteTime' : 'lastCompleteTime'; // tearDown old nodes | ||
function commitChanges(root) { | ||
var updateType = root.updateType, | ||
current = root.current; | ||
var lastCompleteTimeKey = (0, _fiber2.getLastCompleteTimeKey)(updateType); // tearDown old nodes | ||
(0, _tearDown["default"])(root); | ||
var fibersWithEffect = (0, _effectLoop.preCommitBookkeeping)(root); | ||
/** | ||
* set the last updated time for render | ||
* NOTE: We do it before effect loop so setStates in effect are aware of last render finish | ||
* NOTE: We do it before effect loop so if there is | ||
* setStates in effect updateTime for setState should not | ||
* fall behind the complete time | ||
* | ||
* Also, lastCompleteTime should be marked always | ||
* weather its deferred or sync updates | ||
*/ | ||
root[lastCompleteTimeKey] = performance.now(); // when we are done with processing all fiber run effect loop | ||
root[lastCompleteTimeKey] = root.lastCompleteTime = (0, _utils.now)(); // if it deferred swap the wip and current tree | ||
(0, _effectLoop["default"])(root); | ||
if (onComplete) onComplete(); | ||
if (updateType === _configs.UPDATE_TYPE_DEFERRED) { | ||
root.current = root.wip; | ||
root.wip = current; | ||
} // After correcting the tree flush the effects on new fibers | ||
(0, _effectLoop["default"])(root, fibersWithEffect); | ||
} | ||
function workLoop(fiber, topFiber, onComplete) { | ||
function workLoop(fiber, topFiber) { | ||
var _fiber = fiber, | ||
root = _fiber.root; | ||
var updateType = root.updateType, | ||
updateSource = root.updateSource; | ||
var lastCompleteTimeKey = updateType === 'deferred' ? 'lastDeferredCompleteTime' : 'lastCompleteTime'; | ||
currentTransition = root.currentTransition; | ||
var lastCompleteTimeKey = (0, _fiber2.getLastCompleteTimeKey)(updateType); | ||
var updateTimeKey = (0, _fiber2.getUpdateTimeKey)(updateType); | ||
@@ -153,6 +163,4 @@ var lastCompleteTime = root[lastCompleteTimeKey]; | ||
var shouldSchedule = !(0, _updateMetaUtils.shouldPreventSchedule)(root); // cancel the previous requestIdle handle | ||
if (root.requestIdleHandle) cancelIdleCallback(root.requestIdleHandle); | ||
root.requestIdleHandle = schedule(shouldSchedule, function (deadline) { | ||
var shouldSchedule = !(0, _updateUtils.shouldPreventSchedule)(root); | ||
(0, _schedular["default"])(root, shouldSchedule, function (timeRemaining) { | ||
while (fiber !== topFiber) { | ||
@@ -166,19 +174,53 @@ // process the current fiber which will return the next fiber | ||
*/ | ||
if (!shouldSchedule || deadline.didTimeout || deadline.timeRemaining() >= TIME_REQUIRE_TO_PROCESS_FIBER) { | ||
// if (deadline) console.log(deadline.timeRemaining()); | ||
if (timeRemaining() > 0) { | ||
processFiber(fiber); | ||
fiber = (0, _fiber2.getNextFiber)(fiber, topFiber, lastCompleteTime, updateTimeKey); | ||
/** | ||
* if the fiber jump due to suspense or error boundary, | ||
* we need to use that as next fiber. We also need to reset | ||
* topFiber to root, as the retry fiber can be in upper hierarchy | ||
*/ | ||
var retryFiber = root.retryFiber; | ||
if (retryFiber) { | ||
fiber = retryFiber; | ||
topFiber = root; | ||
root.retryFiber = null; | ||
} else { | ||
fiber = (0, _fiber2.getNextFiber)(fiber, topFiber, lastCompleteTime, updateTimeKey); | ||
} | ||
} else { | ||
// if we are out of time schedule work for next fiber | ||
workLoop(fiber, topFiber, onComplete); | ||
workLoop(fiber, topFiber); | ||
return; | ||
} | ||
} // call all the render callbacks | ||
root.callRenderCallbacks(); | ||
if (currentTransition) { | ||
// set transition complete if it is not on suspended or timed out state | ||
(0, _transitionUtils.setTransitionComplete)(currentTransition); // reset try count | ||
currentTransition.tryCount = 0; | ||
/** | ||
* if transition is completed and it does not have any effect to commit, we should remove the | ||
* transition from pending transition | ||
*/ | ||
if (!root.hasUncommittedEffect && (0, _transitionUtils.isTransitionCompleted)(currentTransition)) { | ||
(0, _effectLoop.removeTransitionFromRoot)(root); | ||
} | ||
} | ||
if (shouldCommit(root)) { | ||
commitChanges(root, onComplete); | ||
commitChanges(root); | ||
} // check if there are any pending transition, if yes try rendering them | ||
if ((0, _transitionUtils.getFirstPendingTransition)(root)) { | ||
(0, _updateMetaUtils.withUpdateSource)(_updateMetaUtils.UPDATE_SOURCE_TRANSITION, function () { | ||
if ((0, _transitionUtils.getFirstTransitionToProcess)(root)) { | ||
(0, _updateUtils.withUpdateSource)(_configs.UPDATE_SOURCE_TRANSITION, function () { | ||
root.updateSource = _configs.UPDATE_SOURCE_TRANSITION; | ||
doDeferredProcessing(root); | ||
@@ -192,16 +234,12 @@ }); | ||
// if there is no deferred work or pending transition return | ||
var pendingTransition = (0, _transitionUtils.getFirstPendingTransition)(root); | ||
if (root.lastDeferredCompleteTime >= root.deferredUpdateTime || !pendingTransition) return; | ||
var pendingTransition = (0, _transitionUtils.getFirstTransitionToProcess)(root); | ||
if (!pendingTransition) return; | ||
root.updateType = 'deferred'; // reset the effect list before starting new one | ||
(0, _effectLoop.resetEffectList)(root); // if the update source is transition set the current transition | ||
(0, _effectLoop.resetEffectProperties)(root); // set the pending transition as current transition | ||
root.currentTransition = root.updateSource === _updateMetaUtils.UPDATE_SOURCE_TRANSITION ? pendingTransition : null; | ||
root.currentTransition = pendingTransition; | ||
pendingTransition.tryCount += 1; | ||
root.wip = (0, _fiber2.cloneCurrentFiber)(root.current, root.wip, root, root); | ||
workLoop(root.wip, root, function () { | ||
// after flushing effects (onComplete) swap wip and current | ||
var current = root.current; | ||
root.current = root.wip; | ||
root.wip = current; | ||
}); | ||
workLoop(root.wip, root); | ||
} | ||
@@ -212,5 +250,7 @@ | ||
parent = fiber.parent; | ||
root.updateType = 'sync'; // reset the effect list before starting new one | ||
root.updateType = 'sync'; // set current transition as null for sync processing | ||
(0, _effectLoop.resetEffectList)(root); | ||
root.currentTransition = null; // reset the effect list before starting new one | ||
(0, _effectLoop.resetEffectProperties)(root); | ||
workLoop(fiber, parent); | ||
@@ -217,0 +257,0 @@ } |
{ | ||
"name": "brahmos", | ||
"version": "0.9.0-alpha3", | ||
"version": "0.9.0-alpha4", | ||
"description": "Super charged UI library with modern React API and native templates.", | ||
@@ -5,0 +5,0 @@ "main": "dist/brahmos.js", |
@@ -8,2 +8,6 @@ <p align="center"> | ||
## Installation | ||
[Create a New Brahmos App](https://www.npmjs.com/package/create-brahmos-app) if you're looking for a powerful JavaScript toolchain. | ||
## Features | ||
@@ -80,3 +84,3 @@ - Lightweight and Fast. | ||
</ul> | ||
</form>`(); | ||
</form>`; | ||
} | ||
@@ -89,3 +93,3 @@ } | ||
Tagged template literals also have a unique property where the reference of the literal part (array of static strings) remain the same for every call of that tag with a given template. | ||
Taking advantage of this behaviour Brahmos uses literal parts as a cache key to keep the intermediate states to avoid the work done to process a template literal again. | ||
Taking advantage of this behavior Brahmos uses literal parts as a cache key to keep the intermediate states to avoid the work done to process a template literal again. | ||
@@ -101,17 +105,13 @@ Tagged template is natively supported by the browser, unlike the React's JSX which has to be transformed to React.createElement calls. So the output generated to run Brahmos has a smaller footprint than the output generated for the react. | ||
Todo MVC with Brahmos | ||
[https://s-yadav.github.io/brahmos-todo-mvc](https://s-yadav.github.io/brahmos-todo-mvc) | ||
[https://brahmosjs.github.io/brahmos-todo-mvc](https://brahmosjs.github.io/brahmos-todo-mvc) | ||
## Slack Channel | ||
https://brahmoscommunity.slack.com/join/shared_invite/enQtNjYxODIzMzA3NTg3LWY5ZWY4ZjczNThhMTZjN2Q3NTNmMTBjNjVlZGM5ZWMzNDIyYWI2OTUwMTZiOGQ5MjEwN2Q0ZGRkM2UxZjFiZTM | ||
https://join.slack.com/t/brahmoscommunity/shared_invite/enQtODM5NDMwODgwMzQyLTc4YjJlZjY3Mzk1ODJkNTRkODljYjhmM2NhMGIxNzFjMjZjODk0MmVjZTVkNmE5Y2MwYzZkMzk5NTUxYmI5OWE | ||
## Progress | ||
- [x] Component and props | ||
- [x] States and setState | ||
- [x] Functional Component and props | ||
- [x] List | ||
- [x] Keyed list | ||
- [x] Babel Plugin to transpile JSX to tagged template | ||
- [x] Class components with all life cycle methods (Except deprecated methods) | ||
- [x] Functional Component | ||
- [x] List and Keyed list | ||
- [x] Synthetic input events - onChange support | ||
- [x] Babel Plugin to transpile JSX to tagged template | ||
- [x] Life cycle methods (Only non deprecated methods) | ||
- [x] PureComponent | ||
- [x] Hooks | ||
@@ -121,2 +121,4 @@ - [x] Context API | ||
- [x] SVG Support | ||
- [x] Suspense, Lazy, Suspense for data fetch, Suspense List | ||
- [x] Concurrent Mode | ||
- [ ] React Utilities and Methods | ||
@@ -123,0 +125,0 @@ - [ ] Handle server rendering |
334913
62
6071
125