-
Notifications
You must be signed in to change notification settings - Fork 0
/
anm.umd.js
2 lines (2 loc) · 11.4 KB
/
anm.umd.js
1
2
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.anm=n():e.anm=n()}(window,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t.r(n);var o={children:!0,ref:!0,key:!0};function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.eventNameToHandlers={}}var n,t,r;return n=e,(t=[{key:"on",value:function(e,n){this.eventNameToHandlers[e]||(this.eventNameToHandlers[e]=[]),this.eventNameToHandlers[e].push(n)}},{key:"off",value:function(e,n){if(this.eventNameToHandlers[e]){for(var t=this.eventNameToHandlers[e],r=[],o=0;o<t.length;o++)t[o]===n&&r.push(o);for(var i=r.length-1;i>-1;i--)t.splice(r[i],1)}}},{key:"emit",value:function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];this.eventNameToHandlers[e]&&this.eventNameToHandlers[e].forEach(function(e){e.apply(void 0,t)})}}])&&i(n.prototype,t),r&&i(n,r),e}(),p=new f,c=window.requestAnimationFrame?window.requestAnimationFrame:window.Promise?function(e){return new Promise(function(n,t){try{e(),n()}catch(e){t(e)}})}:window.setTimeout;function a(e){return"number"==typeof e}l(document.createAttributeNS);function u(e){return"string"==typeof e}function l(e){return"function"==typeof e}Array.isArray;function s(e){return null==e}function d(e){return e.startsWith("on")}function y(e,n){if("onDoubleClick"===n)n="ondblclick";else if("onTouchTap"===n)n="onclick";else if("onChange"===n){var t=e.nodeName&&e.nodeName.toLowerCase(),r=e.type;("input"===t&&/text|password/.test(r)||"textarea"===t)&&(n="oninput")}else n=n.toLowerCase();return n}function m(e,n,t){var r=y(e,n);r in e?e[r]=t:e.addEventListener(r.slice(2),t)}function v(e,n,t){var r=y(e,n);r in e?e[r]=null:e.removeEventListener(r.slice(2),t)}var h=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function b(e,n,t){if(!(s(t)||a(t)&&isNaN(t)))return"float"===n?(e.cssFloat=t,void(e.styleFloat=t)):void(e[n]=!a(t)||h.test(n)?t:t+"px");e[n]=""}function g(e,n,t){try{e[n]=t}catch(e){}}var N=new f,S=[];function w(e){N.emit("add",e)}function x(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function A(e,n){var t=e.rendered;if(t.vtype!==n.vtype||"component"===t.vtype&&t.component.original!==n.component.original||t.component!==n.component){_(t);var r=O(n);return e.domNode.parentElement.replaceChild(r,e.domNode),e.domNode=r,e.props.ref&&e.props.ref(r),void(e.rendered=n)}"dom"===t.vtype&&"dom"===n.vtype&&t.component===n.component&&E(t.domNode,t,t.props,n.props),T(t,t.children,n.children),M(e)}function E(e,n,t,r){for(var i in t)if(!o[i]){var f=t[i];s(r[i])&&(d(i)?v(e,i,f):"dangerouslySetInnerHTML"===i?e.textContent="":"className"===i?e.removeAttribute("class"):e.removeAttribute(i))}for(var p in r){var c=t[p],a=r[p];if((c!==a||"value"===p)&&("className"===p&&(p="class"),!o[p]))if("class"===p)e.className=a;else if("dangerouslySetInnerHTML"===p){var y=c&&c.__html,h=a&&a.__html;y===h||s(h)||(e.innerHTML=h)}else if(d(p)&&c!==a&&l(a))v(e,p,c),m(e,p,a);else if("style"===p){var g=e.style;if(u(a))g.cssText=a;else if(s(c)||u(c))for(var N in a){b(g,N,a[N])}else{for(var S in a){var w=a[S];w!==c[S]&&b(g,S,w)}for(var x in c)s(a[x])&&(g[x]="")}}else if("list"!==p&&"type"!==p&&p in e){try{e[p]=a||""}catch(e){}a||e.removeAttribute(p)}else a||e.removeAttribute(p)}n.props=r}function T(e,n,t){var r=e.domNode,o=n.length,i=t.length;if(0===o){var f=!0,p=!1,c=void 0;try{for(var a,u=t[Symbol.iterator]();!(f=(a=u.next()).done);f=!0){var l=a.value;O(l),r.appendChild(l.domNode)}}catch(e){p=!0,c=e}finally{try{f||null==u.return||u.return()}finally{if(p)throw c}}}else if(0===i){r.textContent="";var s=!0,d=!1,y=void 0;try{for(var m,v=n[Symbol.iterator]();!(s=(m=v.next()).done);s=!0){_(m.value)}}catch(e){d=!0,y=e}finally{try{s||null==v.return||v.return()}finally{if(d)throw y}}}else{for(var h=Math.min(o,i),b=0;b<h;){var g=n[b];j(t[b],g,t,b,e),b++}if(o<i)for(b=h;b<i;b++)null!==r&&(O(t[b]),r.appendChild(t[b].domNode));else if(o>i)for(b=h;b<o;b++)r.removeChild(n[b].domNode),_(n[b])}e.children=t}function j(e,n,t,r,o){var i;e.rendered||"component"!==e.vtype||("component"===n.vtype&&n.component.original===e.component.original?e.rendered=n.component(e.props):e.rendered=e.component(e.props)),"component"===n.vtype&&"component"===e.vtype?(A(n,e.rendered),n.props=e.props,t[r]=n,"component"===(i=e).vtype&&w(function(){return p.emit("unmount",i.id)})):n.vtype!==e.vtype||"text"===n.vtype&&"text"===e.vtype&&n.component!==e.component||"dom"===n.vtype&&"dom"===e.vtype&&n.component!==e.component?(O(e),e.parent=o,o.domNode.replaceChild(e.domNode,n.domNode),_(n)):"dom"===n.vtype&&"dom"===e.vtype?(E(n.domNode,n,n.props,e.props),T(n,n.children,e.children),t[r]=n,_(e)):"text"===n.vtype&&"text"===e.vtype&&(t[r]=n)}function _(e){w(function(){if("text"!==e.vtype)for(var n=[e];n.length>0;){var t=n.pop();t.id&&p.emit("unmount",t.id),n.push.apply(n,x(t.children.filter(function(e){return"text"!==e.vtype})))}})}function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}N.on("add",function(e){S.push(e)}),setInterval(function(){S.forEach(function(e){return e()}),S.splice(0,S.length)},1e3/60);var H={};function O(e){var n;if("text"===e.vtype)n=document.createTextNode(e.component);else if("dom"===e.vtype){var t=n=document.createElement(e.component);for(var r in e.props)if(!(r in o))if(d(r))m(t,r,e.props[r]);else if("style"===r)for(var i in e.props.style)b(t.style,i,e.props.style[i]);else"className"===r||"class"===r?t.className=e.props[r]:"dangerouslySetInnerHTML"===r&&"string"==typeof e.props.dangerouslySetInnerHTML.__html?t.innerHTML=e.props.dangerouslySetInnerHTML.__html:g(t,r,e.props[r]);var f=!0,p=!1,c=void 0;try{for(var a,u=e.children[Symbol.iterator]();!(f=(a=u.next()).done);f=!0){var l=a.value;n.appendChild(O(l))}}catch(e){p=!0,c=e}finally{try{f||null==u.return||u.return()}finally{if(p)throw c}}}else{if("component"!==e.vtype)throw"invalid type";H[e.id]=e;var s=e.component(e.props);e.rendered=s,L(e),n=O(s),M(e)}return e.domNode=n,e.props.ref&&e.props.ref(n),n._vnode=e,e.domNode}function k(e){c(function(){if(H[e]&&"component"===H[e].vtype){var n=H[e];if(n.domNode){L(n);var t=n.component(n.props);A(n,t)}}})}function M(e){if(("object"===C(e)&&"component"===e.vtype&&H[e.id]||"number"==typeof e&&H[e]&&"component"===H[e].vtype)&&(e="number"==typeof e?H[e]:e).pendingEffects)for(;e.pendingEffects.length>0;){var n=e.pendingEffects.pop()();n&&(e.pendingEffectReturns||(e.pendingEffectReturns=[]),e.pendingEffectReturns.push(n))}}function L(e){if(("object"===C(e)&&"component"===e.vtype&&H[e.id]||"number"==typeof e&&H[e]&&"component"===H[e].vtype)&&(e="number"==typeof e?H[e]:e).pendingEffectReturns)for(;e.pendingEffectReturns.length>0;){e.pendingEffectReturns.pop()()}}p.on("unmount",function(e){H[e]&&H[e].pendingEffectReturns&&H[e].pendingEffectReturns.forEach(function(e){return e()}),delete H[e]});var I=1;var P,R,F,q={};function J(e){var n=P,t=R;R++,q[n]||(q[n]={states:{length:0},effects:{length:0}});var r=q[n];return r.states[t]||(r.states.length++,r.states[t]={state:e}),[r.states[t].state,function(e){r.states[t].state=e,k(n)}]}function z(e,n){var t=P,r=F;F++,q[t]||(q[t]={states:{length:0},effects:{length:0}});var o=q[t];o.effects[r]||(o.effects.length++,o.effects[r]={});var i=o.effects[r];(!n||n&&!function(e,n){var t=Array.isArray(e),r=Array.isArray(n);if(t&&!r)return!1;if(!t&&r)return!1;if(t||r){if(n=n,(e=e).length!==n.length)return!1;for(var o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}return!1}(i.inputs,n))&&(!function(e,n){if(H[e]&&"component"===H[e].vtype){var t=H[e];t.pendingEffects||(t.pendingEffects=[]),t.pendingEffects.push(n)}}(t,e),i.inputs=n)}function D(e){return(D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function W(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function $(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length,o=new Array(t>2?t-2:0),i=2;i<t;i++)o[i-2]=arguments[i];n||(n={}),n.key&&"string"!=typeof n.key&&(n.key=JSON.stringify(n.key));var f,p,c=Array.isArray(n.children);if(n.children&&!c?n.children=[n.children]:n.children||(n.children=o),n.children=o=n.children.filter(function(e){return!s(e)}).reduce(function(e,n){return Array.isArray(n)?e.push.apply(e,W(n)):e.push(n),e},[]),"string"==typeof e)f={vtype:"dom",component:e,children:o,props:n};else{if("function"!=typeof e)throw"invalid type";var a=I++,u=function(n){return function(e){P=e,R=0,F=0}(a),e(n)};u.original=e,f={id:a,vtype:"component",component:u,children:o,props:n}}for(var l=0;l<o.length;l++)"string"==typeof o[l]?o[l]={vtype:"text",component:o[l],children:[],props:{}}:"boolean"!=typeof o[l]&&"number"!=typeof o[l]&&"bigint"!=typeof o[l]&&"symbol"!==D(o[l])&&void 0!==o[l]&&("object"===r(p=o[l])&&p.vtype&&p.component)||(o[l]={vtype:"text",component:JSON.stringify(o[l])||"",children:[],props:{}}),o[l].parent=f;return f}function B(e,n,t){if(n._vnode){var r=n._vnode;if("component"===r.vtype&&"component"===e.vtype&&r.component.original===e.component.original)return e.rendered||(e.rendered=e.component(e.props)),A(r,e.rendered),void(t&&t());_(r),n.removeChild(r.domNode)}O(e),n.appendChild(e.domNode),t&&t()}p.on("unmount",function(e){return delete q[e]}),t.d(n,"h",function(){return G}),t.d(n,"createElement",function(){return $}),t.d(n,"render",function(){return B}),t.d(n,"useState",function(){return J}),t.d(n,"useEffect",function(){return z});var G=$}])});
//# sourceMappingURL=anm.umd.js.map