Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

forgo

Package Overview
Dependencies
Maintainers
0
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forgo - npm Package Compare versions

Comparing version 4.1.5 to 4.1.6

2

dist/forgo.min.js

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

var fe=Object.defineProperty,be=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var Z=(t,r,p)=>r in t?fe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):t[r]=p,F=(t,r)=>{for(var p in r||(r={}))he.call(r,p)&&Z(t,p,r[p]);if($)for(var p of $(r))Ee.call(r,p)&&Z(t,p,r[p]);return t},k=(t,r)=>be(t,Te(r));var A={};var ye=["ref","dangerouslySetInnerHTML"],ve=Symbol.for("FORGO_FRAGMENT");var xe="http://www.w3.org/2000/svg",Ne=-1;var W=1,j=3,z=8,N={mount(t,r){t.__internal.eventListeners.mount.forEach(p=>p(r,t))},unmount(t,r){t.__internal.eventListeners.unmount.forEach(p=>p(r,t))},shouldUpdate(t,r,p){return t.__internal.eventListeners.shouldUpdate.length===0?!0:t.__internal.eventListeners.shouldUpdate.map(h=>h(r,p,t)).some(Boolean)},afterRender(t,r,p){t.__internal.eventListeners.afterRender.forEach(h=>h(r,p,t))}},S=class{constructor(r){this.__internal={registeredMethods:r,unmounted:!1,eventListeners:{afterRender:[],mount:[],unmount:[],shouldUpdate:[]},element:{componentIndex:Ne}}}update(r){return Ce(this.__internal.element,r)}mount(r){this.__internal.eventListeners.mount.push(r)}unmount(r){this.__internal.eventListeners.unmount.push(r)}shouldUpdate(r){this.__internal.eventListeners.shouldUpdate.push(r)}afterRender(r){this.__internal.eventListeners.afterRender.push(r)}};function L(t,r,...p){var E;r=r!=null?r:{},r.children=p.length>1?H(Array.from(p)):p.length===1?H(p[0]):void 0;let h=(E=r.key)!=null?E:void 0;return{type:t,props:r,key:h,__is_forgo_element__:!0}}var Ae=L;function Pe(t,r){return p=>{if(t.__forgo===void 0||t.__forgo.deleted===!1)return r(p)}}function re(t){var J;let r=t;r.__internal=(J=r.__internal)!=null?J:{Text:r.window.Text,HTMLElement:r.window.HTMLElement};function p(n,e,o,l){if(Array.isArray(n)||K(n))return oe(H(n),e,o,l);if(V(n)){if(_e(n))return E(n,e,o,l);{let d=y(n,e,o,l);return d.pendingMounts.forEach(g=>g()),d.pendingMounts.length=0,d}}else return h(n,e,o)}function h(n,e,o){var g;let l;n==null?l=r.document.createComment("null component render"):l=r.document.createTextNode(Fe(n));let d;if(e.type==="new-component"){let m=e.parentElement.childNodes;if(e.length){let i=m[e.currentNodeIndex];if(i.nodeType===j||i.nodeType===z)i.replaceWith(l),d=(g=x(i))==null?void 0:g.components;else{let s=m[e.currentNodeIndex];e.parentElement.insertBefore(l,s)}}else if(m.length===0||e.currentNodeIndex===0)e.parentElement.prepend(l);else{let i=m[e.currentNodeIndex];e.parentElement.insertBefore(l,i)}}return U(n,l,!0,o),R(o,d),{nodes:[l],pendingMounts:[()=>G(o,d)]}}function E(n,e,o,l){if(e.type==="detached")return m(void 0,null);{let i=e.parentElement.childNodes;if(e.length){let s=se(n,e.parentElement,e.currentNodeIndex,e.length);if(s.found)return g(s.index,i,e)}return m(e.parentElement,i[e.currentNodeIndex])}function d(i){if(n.props.dangerouslySetInnerHTML)i.innerHTML=n.props.dangerouslySetInnerHTML.__html;else{let s=H([n.props.children]).filter(c=>c!=null),a=Array.from(i.childNodes).findIndex(c=>x(c)),u=a===-1?0:a;for(let c of s){let{nodes:f}=p(c,{type:"new-component",parentElement:i,currentNodeIndex:u,length:i.childNodes.length-u},[],l);if(f.length){for(;i.childNodes[u]!==f[f.length-1];)u+=1;for(u+=1;u<i.childNodes.length&&!x(i.childNodes[u]);)u+=1}}P(i.childNodes,u,i.childNodes.length)}}function g(i,s,a){var f;P(s,a.currentNodeIndex,i);let u=s[a.currentNodeIndex],c=(f=x(u))==null?void 0:f.components;return U(n,u,!1,o),d(u),D(u,o),R(o,c),{nodes:[u],pendingMounts:[()=>G(o,c)]}}function m(i,s){let a=ue(n,i);return i&&i.insertBefore(a,s),n.props.ref&&(n.props.ref.value=a),U(n,a,!0,o),d(a),R(o,void 0),{nodes:[a],pendingMounts:[()=>G(o,void 0)]}}}function y(n,e,o,l){function d(s,a,u){let c=a[s],b=X(c).components[i];if(P(a,u.currentNodeIndex,s),N.shouldUpdate(b.component,n.props,b.props)){let T=k(F({},b),{props:n.props}),v=T.component.__internal.registeredMethods.render(n.props,T.component),C=o.concat(T),O=b.component.__internal.element.node,pe=T.component.__internal.registeredMethods.error?T.component:void 0,me=m(n.props,C,pe,()=>{let ce={type:"new-component",currentNodeIndex:u.currentNodeIndex,length:T.nodes.length,parentElement:u.parentElement};return Y(v,ce,C,T,l)});return N.afterRender(T.component,n.props,O),me}else{let T=q(u.parentElement.childNodes,b.component.__internal.element.node);return{nodes:I(u.parentElement.childNodes,T,T+b.nodes.length),pendingMounts:[]}}}function g(){let s=n.type,a=Me(s,s(n.props));a.__internal.element.componentIndex=i;let u=a.__internal.registeredMethods.error?a:void 0,c={key:n.key,ctor:s,component:a,props:n.props,nodes:[],isMounted:!1},f=o.concat(c);return m(n.props,f,u,()=>{let b=a.__internal.registeredMethods.render(n.props,a),T=e.type==="detached"?e:{type:"new-component",currentNodeIndex:e.currentNodeIndex,length:l?e.length:0,parentElement:e.parentElement},v=p(b,T,f,l);return c.nodes=v.nodes,c.component.__internal.element.node=v.nodes[0],N.afterRender(a,n.props,void 0),v})}function m(s,a,u,c){try{return c()}catch(f){if(u!=null&&u.__internal.registeredMethods.error){let b=u.__internal.registeredMethods.error(s,f,u);return p(b,e,a,l)}else throw f}}let i=o.length;if(e.type!=="detached"&&e.length&&!l){let s=e.parentElement.childNodes,a=ie(n,e.parentElement,e.currentNodeIndex,e.length,o.length);if(a.found)return d(a.index,s,e)}return g()}function Y(n,e,o,l,d){let g=e.parentElement.childNodes.length,m=p(n,e,o,d),i=e.parentElement.childNodes.length,s=g+m.nodes.length-i,a=e.currentNodeIndex+m.nodes.length,u=P(e.parentElement.childNodes,a,a+l.nodes.length-s),c=m.nodes.length>0?o:[];for(let f of u){let b=x(f);if(b){let T=B(c,b.components);b.components=b.components.slice(T)}}return l.nodes=m.nodes,l.component.__internal.element.node=m.nodes[0],m}function oe(n,e,o,l){let d=H(n);if(e.type==="detached")throw new Error("Arrays and fragments cannot be rendered at the top level.");{let g={nodes:[],pendingMounts:[]},m=e.currentNodeIndex,i=e.length;for(let s of d){let a=e.parentElement.childNodes.length,u=k(F({},e),{currentNodeIndex:m,length:i}),c=p(s,u,o,l);g.nodes.push(...c.nodes),g.pendingMounts.push(...c.pendingMounts);let f=e.parentElement.childNodes.length,b=a+c.nodes.length-f;m+=c.nodes.length,i-=b}return g}}function P(n,e,o){let l=[],d=I(n,e,o);if(d.length){let g=d[0].parentElement,m=w(g);for(let i of d)x(i)&&(i.remove(),l.push(i),m.push({node:i}))}return l}function D(n,e){let o=w(n);for(let{node:l}of o){let d=x(l);if(d){d.deleted=!0;let g=d.components;R(e,g)}}He(n)}function B(n,e){let o=0;for(let l of n)if(e.length>o){if(e[o].component!==l.component)break;o++}else break;return o}function R(n,e){if(!e)return;let o=!1,l=B(n,e);for(let d=l;d<e.length;d++){let g=e[d],m=g.component;(o||g.nodes.every(i=>{if(i.isConnected){let s=X(i);return s.components[d]===void 0||s.components[d].component!==g.component}else return!0}))&&(m.__internal.unmounted||(m.__internal.unmounted=!0,N.unmount(m,g.props)),o=!0)}}function G(n,e){let o=e?B(n,e):0;for(let l=o;l<n.length;l++){let d=n[l];d.isMounted||(d.isMounted=!0,N.mount(d.component,d.props))}}function se(n,e,o,l){let d=e.childNodes;for(let g=o;g<o+l;g++){let m=d[g];if(te(m)){let i=x(m);if(!i)continue;if(n.key!==void 0&&(i==null?void 0:i.key)===n.key)return{found:!0,index:g};if(m.tagName.toLowerCase()===n.type&&(i===void 0||i.key===void 0))return{found:!0,index:g}}}if(n.key!==void 0){let g=w(e);for(let m=0;m<g.length;m++){let{node:i}=g[m],s=x(i);if((s==null?void 0:s.key)===n.key){g.splice(m,1);let a=d[o];return _(a)?e.appendChild(i):e.insertBefore(i,a),{found:!0,index:o}}}}return{found:!1}}function ie(n,e,o,l,d){let g=e.childNodes;for(let i=o;i<o+l;i++){let s=g[i],a=x(s);if(a&&a.components.length>d){if(n.key!==void 0){if(a.components[d].ctor===n.type&&a.components[d].key===n.key)return{found:!0,index:i}}else if(a.components[d].ctor===n.type)return{found:!0,index:i}}}function m(i,s,a){let u=x(i);return!!(u&&u.components.length>a&&u.components[a].ctor===s.type&&u.components[a].key===s.key)}if(n.key!==void 0){let i=w(e);for(let s=0;s<i.length;s++){let{node:a}=i[s];if(m(a,n,d)){let u=[a];for(let f=s+1;f<i.length;f++){let{node:b}=i[f];m(b,n,d)&&u.push(b)}i.splice(s,u.length);let c=g[o];if(_(c))for(let f of u)e.appendChild(f);else for(let f of u)e.insertBefore(f,c);return{found:!0,index:o}}}}return{found:!1}}function U(n,e,o,l){var d;if(l.length>0&&(l[l.length-1].component.__internal.element.node=e),V(n)){let g=x(e);if(g&&g.props)for(let s in g.props)s in n.props||s!=="children"&&s!=="xmlns"&&(e.nodeType===j||e.nodeType===z||e instanceof r.__internal.HTMLElement&&s in e?delete e[s]:e.removeAttribute(s));else if(!o&&te(e)&&e.hasAttributes()){let s=Array.from(e.attributes);for(let a of s){let u=a.name;u in n.props||e.removeAttribute(u)}}let m=Object.entries(n.props);for(let[s,a]of m)if(!ye.includes(s)&&((d=g==null?void 0:g.props)==null?void 0:d[s])!==a&&s!=="children"&&s!=="xmlns")if(e.nodeType===j||e.nodeType===z)e[s]=a;else if(e instanceof r.__internal.HTMLElement)if(s==="style"){if(g===void 0||g.style===void 0||g.style!==n.props.style){let u=Re(n.props.style);e.style.cssText!==u&&(e.style.cssText=u)}}else s==="onblur"?e[s]=Pe(e,a):s in e?e[s]=a:e.setAttribute(s,a);else typeof a=="string"?e.setAttribute(s,a):e[s]=a;let i={key:n.key,props:n.props,components:l};ee(e,i)}else ee(e,{components:l})}function de(n,e){let o=ne(e)?r.document.querySelector(e):e;if(_(o))throw new Error(`The mount() function was called on a non-element (${typeof e=="string"?e:e==null?void 0:e.tagName}).`);if(o.nodeType!==W)throw new Error("The container argument to the mount() function should be an HTML element.");let l=o.childNodes.length>0,d=p(n,{type:"new-component",currentNodeIndex:0,length:o.childNodes.length,parentElement:o},[],l);if(d.nodes.length<o.childNodes.length){let g=I(o.childNodes,d.nodes.length,o.childNodes.length);for(let m of g)m.remove()}return d}function ae(n){let e=ne(n)?r.document.querySelector(n):n;if(_(e))throw new Error(`The unmount() function was called on a non-element (${typeof n=="string"?n:n==null?void 0:n.tagName}).`);if(e.nodeType!==W)throw new Error("The container argument to the unmount() function should be an HTML element.");P(e.childNodes,0,e.childNodes.length),D(e,[])}function le(n){let e=p(n,{type:"detached"},[],!1);return{node:e.nodes[0],nodes:e.nodes}}function ge(n,e){if(!(n!=null&&n.node))throw new Error("Missing node information in rerender() argument.");let o=n.node.parentElement;if(o!==null){let l=X(n.node),d=l.components[n.componentIndex],g=e!=null?e:d.props;if(!N.shouldUpdate(d.component,g,d.props)){let T=q(o.childNodes,n.node);return{nodes:I(o.childNodes,T,T+d.nodes.length),pendingMounts:[]}}let m=k(F({},d),{props:g}),i=l.components.slice(0,n.componentIndex),s=i.concat(m),a=d.component.__internal.element.node,u=d.component.__internal.registeredMethods.render(g,d.component),f={type:"new-component",currentNodeIndex:q(o.childNodes,n.node),length:d.nodes.length,parentElement:o},b=Y(u,f,s,m,!1);for(let T=0;T<i.length;T++){let v=i[T],C=v.nodes.findIndex(O=>O===d.nodes[0]);v.nodes=v.nodes.slice(0,C).concat(b.nodes).concat(v.nodes.slice(C+d.nodes.length)),v.nodes.length>0&&(v.component.__internal.element.node=v.nodes[0])}return D(o,b.nodes.length>0?s:[]),N.afterRender(d.component,g,a),b}else return{nodes:[],pendingMounts:[]}}function ue(n,e){let o=n.props.xmlns!==void 0?n.props.xmlns:n.type==="svg"?xe:e?e.namespaceURI:null;return n.props.is!==void 0?o!==null?r.document.createElementNS(o,n.type,{is:n.props.is}):r.document.createElement(n.type,{is:n.props.is}):o!==null?r.document.createElementNS(o,n.type):r.document.createElement(n.type)}return{mount:de,unmount:ae,render:le,rerender:ge}}var Q=globalThis!==void 0?globalThis:window,M=re({window:Q,document:Q.document});function we(t){M=re(t)}function Ie(t,r){return M.mount(t,r)}function Le(t){return M.unmount(t)}function De(t){return M.render(t)}function Ce(t,r){return M.rerender(t,r)}function H(t){function r(p,h=[]){let E=Array.isArray(p)?p:K(p)?Array.isArray(p.props.children)?p.props.children:_(p.props.children)?[]:[p.props.children]:[p];for(let y of E)Array.isArray(y)||K(y)?r(y,h):h.push(y);return h}return r(t,[])}function Fe(t){return t.toString()}function V(t){return t!=null&&t.__is_forgo_element__===!0}function _e(t){return V(t)&&typeof t.type=="string"}function K(t){return t!=null&&t.type===ve}function x(t){return t.__forgo}function X(t){if(t.__forgo)return t.__forgo;throw new Error("Missing forgo state on node.")}function ee(t,r){t.__forgo=r}function w(t){return t.__forgo_deletedNodes||(t.__forgo_deletedNodes=[]),t.__forgo_deletedNodes}function He(t){t.__forgo_deletedNodes&&(t.__forgo_deletedNodes=[])}var Se=t=>{let r=E=>({get element(){return E.__internal.element},update(y){return E.update(y)}}),p={render(E,y){return t.render(E,r(y))}};t.error&&(p.error=(E,y)=>t.error(E,Object.assign(r(h),{error:y})));let h=new S(F({},p));return t.mount&&h.mount(E=>{t.mount(E,r(h))}),t.unmount&&h.unmount(E=>{t.unmount(E,r(h))}),t.afterRender&&h.afterRender((E,y)=>{t.afterRender(E,Object.assign(r(h),{previousNode:y}))}),t.shouldUpdate&&h.shouldUpdate((E,y)=>t.shouldUpdate(E,y)),h};function Me(t,r){if(!(r instanceof S)&&Reflect.has(r,"render"))return Se(r);if(!(r instanceof S))throw new Error(`${t.name||"Unnamed"} component constructor must return an instance of the Component class`);return r}function _(t){return t==null}function ne(t){return typeof t=="string"}function te(t){return t.nodeType===W}function Re(t){return typeof t=="string"?t:t==null?"":Object.keys(t).reduce((r,p)=>r+p.split(/(?=[A-Z])/).join("-").toLowerCase()+":"+t[p]+";","")}function I(t,r,p){return Array.from(t).slice(r,p)}function q(t,r){return r?Array.from(t).indexOf(r):-1}(r=>r.JSX=A)(L||(L={}));export{S as Component,ve as Fragment,A as JSX,L as createElement,re as createForgoInstance,x as getForgoState,Ae as h,Se as legacyComponentSyntaxCompat,Ie as mount,De as render,Ce as rerender,we as setCustomEnv,ee as setForgoState,Le as unmount};
var fe=Object.defineProperty,be=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var Z=(t,r,p)=>r in t?fe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):t[r]=p,F=(t,r)=>{for(var p in r||(r={}))he.call(r,p)&&Z(t,p,r[p]);if($)for(var p of $(r))Ee.call(r,p)&&Z(t,p,r[p]);return t},k=(t,r)=>be(t,Te(r));var A={};var ye=["ref","dangerouslySetInnerHTML"],ve=Symbol.for("FORGO_FRAGMENT");var xe="http://www.w3.org/2000/svg",Ne=-1;var W=1,j=3,z=8,N={mount(t,r){t.__internal.eventListeners.mount.forEach(p=>p(r,t))},unmount(t,r){t.__internal.eventListeners.unmount.forEach(p=>p(r,t))},shouldUpdate(t,r,p){return t.__internal.eventListeners.shouldUpdate.length===0?!0:t.__internal.eventListeners.shouldUpdate.map(h=>h(r,p,t)).some(Boolean)},afterRender(t,r,p){t.__internal.eventListeners.afterRender.forEach(h=>h(r,p,t))}},S=class{constructor(r){this.__internal={registeredMethods:r,unmounted:!1,eventListeners:{afterRender:[],mount:[],unmount:[],shouldUpdate:[]},element:{componentIndex:Ne}}}update(r){return Ce(this.__internal.element,r)}mount(r){this.__internal.eventListeners.mount.push(r)}unmount(r){this.__internal.eventListeners.unmount.push(r)}shouldUpdate(r){this.__internal.eventListeners.shouldUpdate.push(r)}afterRender(r){this.__internal.eventListeners.afterRender.push(r)}};function L(t,r,...p){var E;r=r!=null?r:{},r.children=p.length>1?H(Array.from(p)):p.length===1?H(p[0]):void 0;let h=(E=r.key)!=null?E:void 0;return{type:t,props:r,key:h,__is_forgo_element__:!0}}var Ae=L;function Pe(t,r){return p=>{if(t.__forgo===void 0||!t.__forgo.deleted)return r(p)}}function re(t){var J;let r=t;r.__internal=(J=r.__internal)!=null?J:{Text:r.window.Text,HTMLElement:r.window.HTMLElement};function p(n,e,o,l){if(Array.isArray(n)||K(n))return oe(H(n),e,o,l);if(V(n)){if(_e(n))return E(n,e,o,l);{let d=y(n,e,o,l);return d.pendingMounts.forEach(g=>g()),d.pendingMounts.length=0,d}}else return h(n,e,o)}function h(n,e,o){var g;let l;n==null?l=r.document.createComment("null component render"):l=r.document.createTextNode(Fe(n));let d;if(e.type==="new-component"){let m=e.parentElement.childNodes;if(e.length){let i=m[e.currentNodeIndex];if(i.nodeType===j||i.nodeType===z)i.replaceWith(l),d=(g=x(i))==null?void 0:g.components;else{let s=m[e.currentNodeIndex];e.parentElement.insertBefore(l,s)}}else if(m.length===0||e.currentNodeIndex===0)e.parentElement.prepend(l);else{let i=m[e.currentNodeIndex];e.parentElement.insertBefore(l,i)}}return U(n,l,!0,o),R(o,d),{nodes:[l],pendingMounts:[()=>G(o,d)]}}function E(n,e,o,l){if(e.type==="detached")return m(void 0,null);{let i=e.parentElement.childNodes;if(e.length){let s=se(n,e.parentElement,e.currentNodeIndex,e.length);if(s.found)return g(s.index,i,e)}return m(e.parentElement,i[e.currentNodeIndex])}function d(i){if(n.props.dangerouslySetInnerHTML)i.innerHTML=n.props.dangerouslySetInnerHTML.__html;else{let s=H([n.props.children]).filter(c=>c!=null),a=Array.from(i.childNodes).findIndex(c=>x(c)),u=a===-1?0:a;for(let c of s){let{nodes:f}=p(c,{type:"new-component",parentElement:i,currentNodeIndex:u,length:i.childNodes.length-u},[],l);if(f.length){for(;i.childNodes[u]!==f[f.length-1];)u+=1;for(u+=1;u<i.childNodes.length&&!x(i.childNodes[u]);)u+=1}}P(i.childNodes,u,i.childNodes.length)}}function g(i,s,a){var f;P(s,a.currentNodeIndex,i);let u=s[a.currentNodeIndex],c=(f=x(u))==null?void 0:f.components;return U(n,u,!1,o),d(u),D(u,o),R(o,c),{nodes:[u],pendingMounts:[()=>G(o,c)]}}function m(i,s){let a=ue(n,i);return i&&i.insertBefore(a,s),n.props.ref&&(n.props.ref.value=a),U(n,a,!0,o),d(a),R(o,void 0),{nodes:[a],pendingMounts:[()=>G(o,void 0)]}}}function y(n,e,o,l){function d(s,a,u){let c=a[s],b=X(c).components[i];if(P(a,u.currentNodeIndex,s),N.shouldUpdate(b.component,n.props,b.props)){let T=k(F({},b),{props:n.props}),v=T.component.__internal.registeredMethods.render(n.props,T.component),C=o.concat(T),O=b.component.__internal.element.node,pe=T.component.__internal.registeredMethods.error?T.component:void 0,me=m(n.props,C,pe,()=>{let ce={type:"new-component",currentNodeIndex:u.currentNodeIndex,length:T.nodes.length,parentElement:u.parentElement};return Y(v,ce,C,T,l)});return N.afterRender(T.component,n.props,O),me}else{let T=q(u.parentElement.childNodes,b.component.__internal.element.node);return{nodes:I(u.parentElement.childNodes,T,T+b.nodes.length),pendingMounts:[]}}}function g(){let s=n.type,a=Me(s,s(n.props));a.__internal.element.componentIndex=i;let u=a.__internal.registeredMethods.error?a:void 0,c={key:n.key,ctor:s,component:a,props:n.props,nodes:[],isMounted:!1},f=o.concat(c);return m(n.props,f,u,()=>{let b=a.__internal.registeredMethods.render(n.props,a),T=e.type==="detached"?e:{type:"new-component",currentNodeIndex:e.currentNodeIndex,length:l?e.length:0,parentElement:e.parentElement},v=p(b,T,f,l);return c.nodes=v.nodes,c.component.__internal.element.node=v.nodes[0],N.afterRender(a,n.props,void 0),v})}function m(s,a,u,c){try{return c()}catch(f){if(u!=null&&u.__internal.registeredMethods.error){let b=u.__internal.registeredMethods.error(s,f,u);return p(b,e,a,l)}else throw f}}let i=o.length;if(e.type!=="detached"&&e.length&&!l){let s=e.parentElement.childNodes,a=ie(n,e.parentElement,e.currentNodeIndex,e.length,o.length);if(a.found)return d(a.index,s,e)}return g()}function Y(n,e,o,l,d){let g=e.parentElement.childNodes.length,m=p(n,e,o,d),i=e.parentElement.childNodes.length,s=g+m.nodes.length-i,a=e.currentNodeIndex+m.nodes.length,u=P(e.parentElement.childNodes,a,a+l.nodes.length-s),c=m.nodes.length>0?o:[];for(let f of u){let b=x(f);if(b){let T=B(c,b.components);b.components=b.components.slice(T)}}return l.nodes=m.nodes,l.component.__internal.element.node=m.nodes[0],m}function oe(n,e,o,l){let d=H(n);if(e.type==="detached")throw new Error("Arrays and fragments cannot be rendered at the top level.");{let g={nodes:[],pendingMounts:[]},m=e.currentNodeIndex,i=e.length;for(let s of d){let a=e.parentElement.childNodes.length,u=k(F({},e),{currentNodeIndex:m,length:i}),c=p(s,u,o,l);g.nodes.push(...c.nodes),g.pendingMounts.push(...c.pendingMounts);let f=e.parentElement.childNodes.length,b=a+c.nodes.length-f;m+=c.nodes.length,i-=b}return g}}function P(n,e,o){let l=[],d=I(n,e,o);if(d.length){let g=d[0].parentElement,m=w(g);for(let i of d)x(i)&&(i.remove(),l.push(i),m.push({node:i}))}return l}function D(n,e){let o=w(n);for(let{node:l}of o){let d=x(l);if(d){d.deleted=!0;let g=d.components;R(e,g)}}He(n)}function B(n,e){let o=0;for(let l of n)if(e.length>o){if(e[o].component!==l.component)break;o++}else break;return o}function R(n,e){if(!e)return;let o=!1,l=B(n,e);for(let d=l;d<e.length;d++){let g=e[d],m=g.component;(o||g.nodes.every(i=>{if(i.isConnected){let s=X(i);return s.components[d]===void 0||s.components[d].component!==g.component}else return!0}))&&(m.__internal.unmounted||(m.__internal.unmounted=!0,N.unmount(m,g.props)),o=!0)}}function G(n,e){let o=e?B(n,e):0;for(let l=o;l<n.length;l++){let d=n[l];d.isMounted||(d.isMounted=!0,N.mount(d.component,d.props))}}function se(n,e,o,l){let d=e.childNodes;for(let g=o;g<o+l;g++){let m=d[g];if(te(m)){let i=x(m);if(!i)continue;if(n.key!==void 0&&(i==null?void 0:i.key)===n.key)return{found:!0,index:g};if(m.tagName.toLowerCase()===n.type&&(i===void 0||i.key===void 0))return{found:!0,index:g}}}if(n.key!==void 0){let g=w(e);for(let m=0;m<g.length;m++){let{node:i}=g[m],s=x(i);if((s==null?void 0:s.key)===n.key){g.splice(m,1);let a=d[o];return _(a)?e.appendChild(i):e.insertBefore(i,a),{found:!0,index:o}}}}return{found:!1}}function ie(n,e,o,l,d){let g=e.childNodes;for(let i=o;i<o+l;i++){let s=g[i],a=x(s);if(a&&a.components.length>d){if(n.key!==void 0){if(a.components[d].ctor===n.type&&a.components[d].key===n.key)return{found:!0,index:i}}else if(a.components[d].ctor===n.type)return{found:!0,index:i}}}function m(i,s,a){let u=x(i);return!!(u&&u.components.length>a&&u.components[a].ctor===s.type&&u.components[a].key===s.key)}if(n.key!==void 0){let i=w(e);for(let s=0;s<i.length;s++){let{node:a}=i[s];if(m(a,n,d)){let u=[a];for(let f=s+1;f<i.length;f++){let{node:b}=i[f];m(b,n,d)&&u.push(b)}i.splice(s,u.length);let c=g[o];if(_(c))for(let f of u)e.appendChild(f);else for(let f of u)e.insertBefore(f,c);return{found:!0,index:o}}}}return{found:!1}}function U(n,e,o,l){var d;if(l.length>0&&(l[l.length-1].component.__internal.element.node=e),V(n)){let g=x(e);if(g&&g.props)for(let s in g.props)s in n.props||s!=="children"&&s!=="xmlns"&&(e.nodeType===j||e.nodeType===z||e instanceof r.__internal.HTMLElement&&s in e?delete e[s]:e.removeAttribute(s));else if(!o&&te(e)&&e.hasAttributes()){let s=Array.from(e.attributes);for(let a of s){let u=a.name;u in n.props||e.removeAttribute(u)}}let m=Object.entries(n.props);for(let[s,a]of m)if(!ye.includes(s)&&((d=g==null?void 0:g.props)==null?void 0:d[s])!==a&&s!=="children"&&s!=="xmlns")if(e.nodeType===j||e.nodeType===z)e[s]=a;else if(e instanceof r.__internal.HTMLElement)if(s==="style"){if(g===void 0||g.style===void 0||g.style!==n.props.style){let u=Re(n.props.style);e.style.cssText!==u&&(e.style.cssText=u)}}else s==="onblur"?e[s]=Pe(e,a):s in e?e[s]=a:e.setAttribute(s,a);else typeof a=="string"?e.setAttribute(s,a):e[s]=a;let i={key:n.key,props:n.props,components:l};ee(e,i)}else ee(e,{components:l})}function de(n,e){let o=ne(e)?r.document.querySelector(e):e;if(_(o))throw new Error(`The mount() function was called on a non-element (${typeof e=="string"?e:e==null?void 0:e.tagName}).`);if(o.nodeType!==W)throw new Error("The container argument to the mount() function should be an HTML element.");let l=o.childNodes.length>0,d=p(n,{type:"new-component",currentNodeIndex:0,length:o.childNodes.length,parentElement:o},[],l);if(d.nodes.length<o.childNodes.length){let g=I(o.childNodes,d.nodes.length,o.childNodes.length);for(let m of g)m.remove()}return d}function ae(n){let e=ne(n)?r.document.querySelector(n):n;if(_(e))throw new Error(`The unmount() function was called on a non-element (${typeof n=="string"?n:n==null?void 0:n.tagName}).`);if(e.nodeType!==W)throw new Error("The container argument to the unmount() function should be an HTML element.");P(e.childNodes,0,e.childNodes.length),D(e,[])}function le(n){let e=p(n,{type:"detached"},[],!1);return{node:e.nodes[0],nodes:e.nodes}}function ge(n,e){if(!(n!=null&&n.node))throw new Error("Missing node information in rerender() argument.");let o=n.node.parentElement;if(o!==null){let l=X(n.node),d=l.components[n.componentIndex],g=e!=null?e:d.props;if(!N.shouldUpdate(d.component,g,d.props)){let T=q(o.childNodes,n.node);return{nodes:I(o.childNodes,T,T+d.nodes.length),pendingMounts:[]}}let m=k(F({},d),{props:g}),i=l.components.slice(0,n.componentIndex),s=i.concat(m),a=d.component.__internal.element.node,u=d.component.__internal.registeredMethods.render(g,d.component),f={type:"new-component",currentNodeIndex:q(o.childNodes,n.node),length:d.nodes.length,parentElement:o},b=Y(u,f,s,m,!1);for(let T=0;T<i.length;T++){let v=i[T],C=v.nodes.findIndex(O=>O===d.nodes[0]);v.nodes=v.nodes.slice(0,C).concat(b.nodes).concat(v.nodes.slice(C+d.nodes.length)),v.nodes.length>0&&(v.component.__internal.element.node=v.nodes[0])}return D(o,b.nodes.length>0?s:[]),N.afterRender(d.component,g,a),b}else return{nodes:[],pendingMounts:[]}}function ue(n,e){let o=n.props.xmlns!==void 0?n.props.xmlns:n.type==="svg"?xe:e?e.namespaceURI:null;return n.props.is!==void 0?o!==null?r.document.createElementNS(o,n.type,{is:n.props.is}):r.document.createElement(n.type,{is:n.props.is}):o!==null?r.document.createElementNS(o,n.type):r.document.createElement(n.type)}return{mount:de,unmount:ae,render:le,rerender:ge}}var Q=globalThis!==void 0?globalThis:window,M=re({window:Q,document:Q.document});function we(t){M=re(t)}function Ie(t,r){return M.mount(t,r)}function Le(t){return M.unmount(t)}function De(t){return M.render(t)}function Ce(t,r){return M.rerender(t,r)}function H(t){function r(p,h=[]){let E=Array.isArray(p)?p:K(p)?Array.isArray(p.props.children)?p.props.children:_(p.props.children)?[]:[p.props.children]:[p];for(let y of E)Array.isArray(y)||K(y)?r(y,h):h.push(y);return h}return r(t,[])}function Fe(t){return t.toString()}function V(t){return t!=null&&t.__is_forgo_element__===!0}function _e(t){return V(t)&&typeof t.type=="string"}function K(t){return t!=null&&t.type===ve}function x(t){return t.__forgo}function X(t){if(t.__forgo)return t.__forgo;throw new Error("Missing forgo state on node.")}function ee(t,r){t.__forgo=r}function w(t){return t.__forgo_deletedNodes||(t.__forgo_deletedNodes=[]),t.__forgo_deletedNodes}function He(t){t.__forgo_deletedNodes&&(t.__forgo_deletedNodes=[])}var Se=t=>{let r=E=>({get element(){return E.__internal.element},update(y){return E.update(y)}}),p={render(E,y){return t.render(E,r(y))}};t.error&&(p.error=(E,y)=>t.error(E,Object.assign(r(h),{error:y})));let h=new S(F({},p));return t.mount&&h.mount(E=>{t.mount(E,r(h))}),t.unmount&&h.unmount(E=>{t.unmount(E,r(h))}),t.afterRender&&h.afterRender((E,y)=>{t.afterRender(E,Object.assign(r(h),{previousNode:y}))}),t.shouldUpdate&&h.shouldUpdate((E,y)=>t.shouldUpdate(E,y)),h};function Me(t,r){if(!(r instanceof S)&&Reflect.has(r,"render"))return Se(r);if(!(r instanceof S))throw new Error(`${t.name||"Unnamed"} component constructor must return an instance of the Component class`);return r}function _(t){return t==null}function ne(t){return typeof t=="string"}function te(t){return t.nodeType===W}function Re(t){return typeof t=="string"?t:t==null?"":Object.keys(t).reduce((r,p)=>r+p.split(/(?=[A-Z])/).join("-").toLowerCase()+":"+t[p]+";","")}function I(t,r,p){return Array.from(t).slice(r,p)}function q(t,r){return r?Array.from(t).indexOf(r):-1}(r=>r.JSX=A)(L||(L={}));export{S as Component,ve as Fragment,A as JSX,L as createElement,re as createForgoInstance,x as getForgoState,Ae as h,Se as legacyComponentSyntaxCompat,Ie as mount,De as render,Ce as rerender,we as setCustomEnv,ee as setForgoState,Le as unmount};
//# sourceMappingURL=forgo.min.js.map
{
"name": "forgo",
"version": "4.1.5",
"version": "4.1.6",
"main": "./dist/forgo.min.js",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc