@ryupold/vode 1.8.5 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +1 -1
- package/.github/workflows/tests.yml +1 -1
- package/README.md +55 -5
- package/dist/vode.cjs.min.js +1 -1
- package/dist/vode.d.ts +5 -0
- package/dist/vode.es5.min.js +1 -1
- package/dist/vode.js +72 -12
- package/dist/vode.min.js +1 -1
- package/dist/vode.min.mjs +1 -1
- package/dist/vode.mjs +72 -12
- package/package.json +1 -1
- package/src/vode.ts +83 -18
- package/test/index.ts +2 -0
- package/test/tests-mount-unmount.ts +1140 -0
package/dist/vode.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=(()=>{var v=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var X=(e,n)=>{for(var s in n)v(e,s,{get:n[s],enumerable:!0})},Y=(e,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of q(n))!w.call(e,t)&&t!==s&&v(e,t,{get:()=>n[t],enumerable:!(a=K(n,t))||a.enumerable});return e};var W=e=>Y(v({},"__esModule",{value:!0}),e);var Wo={};X(Wo,{A:()=>st,ABBR:()=>rt,ADDRESS:()=>ct,ANIMATE:()=>pn,ANIMATEMOTION:()=>fn,ANIMATETRANSFORM:()=>Sn,ANNOTATION:()=>yo,ANNOTATION_XML:()=>go,AREA:()=>it,ARTICLE:()=>lt,ASIDE:()=>pt,AUDIO:()=>ft,B:()=>St,BASE:()=>dt,BDI:()=>ut,BDO:()=>Tt,BLOCKQUOTE:()=>yt,BODY:()=>gt,BR:()=>xt,BUTTON:()=>ht,CANVAS:()=>mt,CAPTION:()=>bt,CIRCLE:()=>dn,CITE:()=>Et,CLIPPATH:()=>un,CODE:()=>Pt,COL:()=>At,COLGROUP:()=>Ct,DATA:()=>Mt,DATALIST:()=>Nt,DD:()=>Rt,DEFS:()=>Tn,DEL:()=>Ot,DESC:()=>yn,DETAILS:()=>Dt,DFN:()=>vt,DIALOG:()=>Lt,DIV:()=>It,DL:()=>Ft,DT:()=>Vt,ELLIPSE:()=>gn,EM:()=>jt,EMBED:()=>Ht,FEBLEND:()=>xn,FECOLORMATRIX:()=>hn,FECOMPONENTTRANSFER:()=>mn,FECOMPOSITE:()=>bn,FECONVOLVEMATRIX:()=>En,FEDIFFUSELIGHTING:()=>Pn,FEDISPLACEMENTMAP:()=>An,FEDISTANTLIGHT:()=>Cn,FEDROPSHADOW:()=>Mn,FEFLOOD:()=>Nn,FEFUNCA:()=>Rn,FEFUNCB:()=>On,FEFUNCG:()=>Dn,FEFUNCR:()=>vn,FEGAUSSIANBLUR:()=>Ln,FEIMAGE:()=>In,FEMERGE:()=>Fn,FEMERGENODE:()=>Vn,FEMORPHOLOGY:()=>jn,FEOFFSET:()=>Hn,FEPOINTLIGHT:()=>Un,FESPECULARLIGHTING:()=>Gn,FESPOTLIGHT:()=>kn,FETILE:()=>_n,FETURBULENCE:()=>Bn,FIELDSET:()=>Ut,FIGCAPTION:()=>Gt,FIGURE:()=>kt,FILTER:()=>Kn,FOOTER:()=>_t,FOREIGNOBJECT:()=>qn,FORM:()=>Bt,G:()=>wn,H1:()=>Kt,H2:()=>qt,H3:()=>wt,H4:()=>Xt,H5:()=>Yt,H6:()=>Wt,HEAD:()=>$t,HEADER:()=>Jt,HGROUP:()=>Qt,HR:()=>zt,HTML:()=>Zt,I:()=>te,IFRAME:()=>ee,IMAGE:()=>Xn,IMG:()=>ne,INPUT:()=>oe,INS:()=>ae,KBD:()=>se,LABEL:()=>re,LEGEND:()=>ce,LI:()=>ie,LINE:()=>Yn,LINEARGRADIENT:()=>Wn,LINK:()=>le,MACTION:()=>xo,MAIN:()=>pe,MAP:()=>fe,MARK:()=>Se,MARKER:()=>$n,MASK:()=>Jn,MATH:()=>ho,MENU:()=>de,MERROR:()=>mo,META:()=>ue,METADATA:()=>Qn,METER:()=>Te,MFRAC:()=>bo,MI:()=>Eo,MMULTISCRIPTS:()=>Po,MN:()=>Ao,MO:()=>Co,MOVER:()=>Mo,MPADDED:()=>No,MPATH:()=>zn,MPHANTOM:()=>Ro,MPRESCRIPTS:()=>Oo,MROOT:()=>Do,MROW:()=>vo,MS:()=>Lo,MSPACE:()=>Io,MSQRT:()=>Fo,MSTYLE:()=>Vo,MSUB:()=>jo,MSUBSUP:()=>Ho,MSUP:()=>Uo,MTABLE:()=>Go,MTD:()=>ko,MTEXT:()=>_o,MTR:()=>Bo,MUNDER:()=>Ko,MUNDEROVER:()=>qo,NAV:()=>ye,NOSCRIPT:()=>ge,OBJECT:()=>xe,OL:()=>he,OPTGROUP:()=>me,OPTION:()=>be,OUTPUT:()=>Ee,P:()=>Pe,PATH:()=>Zn,PATTERN:()=>to,PICTURE:()=>Ae,POLYGON:()=>eo,POLYLINE:()=>no,PRE:()=>Ce,PROGRESS:()=>Me,Q:()=>Ne,RADIALGRADIENT:()=>oo,RECT:()=>ao,RP:()=>Re,RT:()=>Oe,RUBY:()=>De,S:()=>ve,SAMP:()=>Le,SCRIPT:()=>Ie,SEARCH:()=>Fe,SECTION:()=>Ve,SELECT:()=>je,SEMANTICS:()=>wo,SET:()=>so,SLOT:()=>He,SMALL:()=>Ue,SOURCE:()=>Ge,SPAN:()=>ke,STOP:()=>ro,STRONG:()=>_e,STYLE:()=>Be,SUB:()=>Ke,SUMMARY:()=>qe,SUP:()=>we,SVG:()=>co,SWITCH:()=>io,SYMBOL:()=>lo,TABLE:()=>Xe,TBODY:()=>Ye,TD:()=>We,TEMPLATE:()=>$e,TEXT:()=>po,TEXTAREA:()=>Je,TEXTPATH:()=>fo,TFOOT:()=>Qe,TH:()=>ze,THEAD:()=>Ze,TIME:()=>tn,TITLE:()=>en,TR:()=>nn,TRACK:()=>on,TSPAN:()=>So,U:()=>an,UL:()=>sn,USE:()=>uo,VAR:()=>rn,VIDEO:()=>cn,VIEW:()=>To,WBR:()=>ln,app:()=>J,child:()=>nt,childCount:()=>et,children:()=>M,childrenStart:()=>O,context:()=>Yo,createPatch:()=>Z,createState:()=>z,defuse:()=>F,globals:()=>P,hydrate:()=>R,memo:()=>Q,mergeClass:()=>V,mergeProps:()=>Xo,mergeStyle:()=>j,props:()=>A,tag:()=>tt,vode:()=>$});var P={currentViewTransition:void 0,requestAnimationFrame:typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:typeof document<"u"&&typeof document.startViewTransition=="function"?document.startViewTransition.bind(document):null};function $(e,n,...s){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:typeof n=="object"?[e,n,...s]:[e,...s]}function J(e,n,s,...a){if(!e?.parentElement)throw new Error("first argument to app() must be a valid HTMLElement inside the <html></html> document");if(!n||typeof n!="object")throw new Error("second argument to app() must be a state object");if(typeof s!="function")throw new Error("third argument to app() must be a function that returns a vode");let t={};t.syncRenderer=P.requestAnimationFrame,t.asyncRenderer=P.startViewTransition,t.qSync=null,t.qAsync=null,t.stats={lastSyncRenderTime:0,lastAsyncRenderTime:0,syncRenderCount:0,asyncRenderCount:0,liveEffectCount:0,patchCount:0,syncRenderPatchCount:0,asyncRenderPatchCount:0};let o=n;"patch"in n&&typeof n.patch=="function"&&Array.isArray(n.patch.initialPatches)&&(a=[...n.patch.initialPatches,...a]),Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(l,y)=>{if(!(!l||typeof l!="function"&&typeof l!="object"))if(t.stats.patchCount++,l?.next){let f=l;t.stats.liveEffectCount++;try{let u=await f.next();for(;u.done===!1;){t.stats.liveEffectCount++;try{o.patch(u.value,y),u=await f.next()}finally{t.stats.liveEffectCount--}}o.patch(u.value,y)}finally{t.stats.liveEffectCount--}}else if(l.then){t.stats.liveEffectCount++;try{let f=await l;o.patch(f,y)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(l))if(l.length>0)for(let f of l)o.patch(f,!document.hidden&&!!t.asyncRenderer);else{t.qSync=E(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{P.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof l=="function"?o.patch(l(t.state),y):y?(t.stats.asyncRenderPatchCount++,t.qAsync=E(t.qAsync||{},l,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=E(t.qSync||{},l,!1),t.renderSync())}});function r(l){let y=Date.now(),f=s(t.state);t.vode=C(t.state,e.parentElement,0,0,t.vode,f),e.tagName.toUpperCase()!==f[0].toUpperCase()&&(e=t.vode.node,e._vode=t),l||(t.stats.lastSyncRenderTime=Date.now()-y,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let p=r.bind(null,!1),i=r.bind(null,!0);Object.defineProperty(t,"renderSync",{enumerable:!1,configurable:!0,writable:!1,value:()=>{t.isRendering||!t.qSync||(t.isRendering=!0,t.state=E(t.state,t.qSync,!0),t.qSync=null,t.syncRenderer(p))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await P.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let l=Date.now();try{t.state=E(t.state,t.qAsync,!0),t.qAsync=null,P.currentViewTransition=t.asyncRenderer(i),await P.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-l,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=o;let c=e;c._vode=t;let S=Array.from(e.parentElement.children).indexOf(e);t.vode=C(n,e.parentElement,S,S,R(e,!0),s(n));for(let l of a)o.patch(l);return l=>o.patch(l)}function F(e){if(e?._vode){let s=function(t){if(!t?.node)return;let o=A(t);if(o){for(let r in o)r[0]==="o"&&r[1]==="n"&&(t.node[r]=null);t.node.catch=null}if(t.node._vode)F(t.node);else{let r=M(t);if(r)for(let p of r)s(p)}};var n=s;let a=e._vode;delete e._vode,Object.defineProperty(a.state,"patch",{value:void 0}),Object.defineProperty(a,"renderSync",{value:()=>{}}),Object.defineProperty(a,"renderAsync",{value:()=>{}}),s(a.vode)}else for(let s of e.children)F(s)}function R(e,n){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?n?e:e.nodeValue:void 0;if(e.nodeType===Node.ELEMENT_NODE){let a=[e.tagName.toLowerCase()];if(n&&(a.node=e),e?.hasAttributes()){let t={},o=e.attributes;for(let r of o)t[r.name]=r.value;a.push(t)}if(e.hasChildNodes()){let t=[];for(let o of e.childNodes){let r=o&&R(o,n);r?a.push(r):o&&n&&t.push(o)}for(let o of t)o.remove()}return a}else return}function Q(e,n){if(!e||!Array.isArray(e))throw new Error("first argument to memo() must be an array of values to compare");if(typeof n!="function")throw new Error("second argument to memo() must be a function that returns a vode or props object");return n.__memo=e,n}function z(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return"patch"in e||Object.defineProperty(e,"patch",{enumerable:!1,configurable:!0,writable:!1,value:n=>{let s=e;Array.isArray(s.patch.initialPatches)||(s.patch.initialPatches=[]),s.patch.initialPatches.push(n)}}),e}function Z(e){return e}function tt(e){return e?Array.isArray(e)?e[0]:typeof e=="string"||e.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function A(e){if(Array.isArray(e)&&e.length>1&&e[1]&&!Array.isArray(e[1])&&typeof e[1]=="object"&&e[1].nodeType!==Node.TEXT_NODE)return e[1]}function M(e){let n=O(e);return n>0?e.slice(n):null}function et(e){let n=O(e);return n<0?0:e.length-n}function nt(e,n){let s=O(e);if(s>0)return e[n+s]}function O(e){return A(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function E(e,n,s){if(!n)return e;for(let a in n){let t=n[a];if(t&&typeof t=="object"){let o=e[a];o?Array.isArray(t)?e[a]=[...t]:t instanceof Date&&o!==t?e[a]=new Date(t):Array.isArray(o)?e[a]=E({},t,s):typeof o=="object"?E(e[a],t,s):e[a]=E({},t,s):Array.isArray(t)?e[a]=[...t]:t instanceof Date?e[a]=new Date(t):e[a]=E({},t,s)}else t===void 0&&s?delete e[a]:e[a]=t}return e}function C(e,n,s,a,t,o,r){try{o=L(e,o,t);let p=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&p)return t;let i=t?.nodeType===Node.TEXT_NODE,c=i?t:t?.node;if(p){c?.onUnmount&&e.patch(c.onUnmount(c)),c?.remove();return}let S=!p&&at(o),l=!p&&ot(o),y=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!S&&!l&&!y&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(y&&S?o=o.wholeText:y&&l&&(o=[...o]),i&&S)return c.nodeValue!==o&&(c.nodeValue=o),t;if(S&&(!c||!i)){let f=document.createTextNode(o);if(c)c.onUnmount&&e.patch(c.onUnmount(c)),c.replaceWith(f);else{let u=!1;for(let d=a;d<n.childNodes.length;d++){let x=n.childNodes[d];if(x){x.before(f,x),u=!0;break}}u||n.appendChild(f)}return f}if(l&&(!c||i||t[0]!==o[0])){let f=o;1 in f&&(f[1]=L(e,f[1],void 0));let u=A(o);u?.xmlns!==void 0&&(r=u.xmlns);let d=r?document.createElementNS(r,o[0]):document.createElement(o[0]);if(o.node=d,I(e,d,void 0,u,r??null),u&&"catch"in u&&(o.node.catch=null,o.node.removeAttribute("catch")),c)c.onUnmount&&e.patch(c.onUnmount(c)),c.replaceWith(d);else{let h=!1;for(let g=a;g<n.childNodes.length;g++){let T=n.childNodes[g];if(T){T.before(d,T),h=!0;break}}h||n.appendChild(d)}let x=M(o);if(x){let h=u?2:1,g=0;for(let T=0;T<x.length;T++){let m=x[T],b=C(e,d,T,g,void 0,m,r??null);o[T+h]=b,b&&g++}}return d.onMount&&e.patch(d.onMount(d)),o}if(!i&&l&&t[0]===o[0]){o.node=c;let f=o,u=t,d=A(o),x=A(t);if(d?.xmlns!==void 0&&(r=d.xmlns),f[1]?.__memo){let T=f[1];f[1]=L(e,f[1],u[1]),T!==f[1]&&I(e,c,x,d,r)}else I(e,c,x,d,r);d?.catch&&x?.catch!==d.catch&&(o.node.catch=null,o.node.removeAttribute("catch"));let h=M(o),g=M(t);if(h){let T=d?2:1,m=0;for(let b=0;b<h.length;b++){let _=h[b],B=g&&g[b],U=C(e,c,b,m,B,_,r);o[b+T]=U,U&&m++}}if(g){let T=h?h.length:0;for(let m=g.length-1;m>=T;m--)C(e,c,m,m,g[m],void 0,r)}return o}}catch(p){let i=A(o)?.catch;if(i){let c=typeof i=="function"?i(e,p):i;return C(e,n,s,a,R(o?.node||t?.node,!0),c,r)}else throw p}}function ot(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function at(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function L(e,n,s){if(typeof n!="function")return n;let a=n?.__memo,t=s?.__memo;if(Array.isArray(a)&&Array.isArray(t)&&a.length===t.length){let p=!0;for(let i=0;i<a.length;i++)if(a[i]!==t[i]){p=!1;break}if(p)return s}let o=n(e);if(typeof o=="function"&&o?.__memo){let p=o.__memo;if(Array.isArray(p)&&Array.isArray(t)&&p.length===t.length){let c=!0;for(let S=0;S<p.length;S++)if(p[S]!==t[S]){c=!1;break}if(c)return s}let i=o(e);return typeof i=="object"&&(i.__memo=p),i}let r=typeof o=="function"?G(o,e):o;return typeof r=="object"&&(r.__memo=o?.__memo||n?.__memo),r}function G(e,n){return typeof e=="function"?G(e(n),n):e}function I(e,n,s,a,t){if(!a&&!s)return;let o=t!==void 0;if(s)for(let r in s){let p=s[r],i=a?.[r];p!==i&&(a?a[r]=N(e,n,r,p,i,o):N(e,n,r,p,void 0,o))}if(a&&s){for(let r in a)if(!(r in s)){let p=a[r];a[r]=N(e,n,r,void 0,p,o)}}else if(a)for(let r in a){let p=a[r];a[r]=N(e,n,r,void 0,p,o)}}function N(e,n,s,a,t,o){if(s==="style")if(!t)n.style.cssText="";else if(typeof t=="string")a!==t&&(n.style.cssText=t);else if(a&&typeof a=="object"){for(let r in a)t[r]||(n.style[r]=null);for(let r in t){let p=a[r],i=t[r];p!==i&&(n.style[r]=i)}}else for(let r in t)n.style[r]=t[r];else if(s==="class")t?n.setAttribute("class",k(t)):n.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(t){let r=null;if(typeof t=="function"){let p=t;r=i=>e.patch(p(e,i))}else typeof t=="object"&&(r=()=>e.patch(t));n[s]=r}else n[s]=null;else o||(n[s]=t),t==null||t===!1?n.removeAttribute(s):n.setAttribute(s,t);return t}function k(e){return typeof e=="string"?e:Array.isArray(e)?e.map(k).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var st="a",rt="abbr",ct="address",it="area",lt="article",pt="aside",ft="audio",St="b",dt="base",ut="bdi",Tt="bdo",yt="blockquote",gt="body",xt="br",ht="button",mt="canvas",bt="caption",Et="cite",Pt="code",At="col",Ct="colgroup",Mt="data",Nt="datalist",Rt="dd",Ot="del",Dt="details",vt="dfn",Lt="dialog",It="div",Ft="dl",Vt="dt",jt="em",Ht="embed",Ut="fieldset",Gt="figcaption",kt="figure",_t="footer",Bt="form",Kt="h1",qt="h2",wt="h3",Xt="h4",Yt="h5",Wt="h6",$t="head",Jt="header",Qt="hgroup",zt="hr",Zt="html",te="i",ee="iframe",ne="img",oe="input",ae="ins",se="kbd",re="label",ce="legend",ie="li",le="link",pe="main",fe="map",Se="mark",de="menu",ue="meta",Te="meter",ye="nav",ge="noscript",xe="object",he="ol",me="optgroup",be="option",Ee="output",Pe="p",Ae="picture",Ce="pre",Me="progress",Ne="q",Re="rp",Oe="rt",De="ruby",ve="s",Le="samp",Ie="script",Fe="search",Ve="section",je="select",He="slot",Ue="small",Ge="source",ke="span",_e="strong",Be="style",Ke="sub",qe="summary",we="sup",Xe="table",Ye="tbody",We="td",$e="template",Je="textarea",Qe="tfoot",ze="th",Ze="thead",tn="time",en="title",nn="tr",on="track",an="u",sn="ul",rn="var",cn="video",ln="wbr",pn="animate",fn="animateMotion",Sn="animateTransform",dn="circle",un="clipPath",Tn="defs",yn="desc",gn="ellipse",xn="feBlend",hn="feColorMatrix",mn="feComponentTransfer",bn="feComposite",En="feConvolveMatrix",Pn="feDiffuseLighting",An="feDisplacementMap",Cn="feDistantLight",Mn="feDropShadow",Nn="feFlood",Rn="feFuncA",On="feFuncB",Dn="feFuncG",vn="feFuncR",Ln="feGaussianBlur",In="feImage",Fn="feMerge",Vn="feMergeNode",jn="feMorphology",Hn="feOffset",Un="fePointLight",Gn="feSpecularLighting",kn="feSpotLight",_n="feTile",Bn="feTurbulence",Kn="filter",qn="foreignObject",wn="g",Xn="image",Yn="line",Wn="linearGradient",$n="marker",Jn="mask",Qn="metadata",zn="mpath",Zn="path",to="pattern",eo="polygon",no="polyline",oo="radialGradient",ao="rect",so="set",ro="stop",co="svg",io="switch",lo="symbol",po="text",fo="textPath",So="tspan",uo="use",To="view",yo="annotation",go="annotation-xml",xo="maction",ho="math",mo="merror",bo="mfrac",Eo="mi",Po="mmultiscripts",Ao="mn",Co="mo",Mo="mover",No="mpadded",Ro="mphantom",Oo="mprescripts",Do="mroot",vo="mrow",Lo="ms",Io="mspace",Fo="msqrt",Vo="mstyle",jo="msub",Ho="msubsup",Uo="msup",Go="mtable",ko="mtd",_o="mtext",Bo="mtr",Ko="munder",qo="munderover",wo="semantics";function V(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=e[0];for(let s=1;s<e.length;s++){let a=n,t=e[s];if(!a)n=t;else if(t)if(typeof a=="string"&&typeof t=="string"){let o=a.split(" "),r=t.split(" "),p=new Set([...o,...r]);n=Array.from(p).join(" ").trim()}else if(typeof a=="string"&&Array.isArray(t)){let o=new Set([...t,...a.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&typeof t=="string"){let o=new Set([...a,...t.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&Array.isArray(t)){let o=new Set([...a,...t]);n=Array.from(o).join(" ").trim()}else if(typeof a=="string"&&typeof t=="object")n={[a]:!0,...t};else if(typeof a=="object"&&typeof t=="string")n={...a,[t]:!0};else if(typeof a=="object"&&typeof t=="object")n={...a,...t};else if(typeof a=="object"&&Array.isArray(t)){let o={...a};for(let r of t)o[r]=!0;n=o}else if(Array.isArray(a)&&typeof t=="object"){let o={};for(let r of a)o[r]=!0;for(let r of Object.keys(t))o[r]=t[r];n=o}else throw new Error(`cannot merge classes of ${a} (${typeof a}) and ${t} (${typeof t})`);else continue}return n}var D;function j(...e){D||(D=document.createElement("div"));try{let n=D.style;for(let s of e)if(typeof s=="object"&&s!==null)for(let a in s)n[a]=s[a];else typeof s=="string"&&(n.cssText+=";"+s);return n.cssText}finally{D.style.cssText=""}}function Xo(...e){if(e.length===0)return;if(e.length===1)return e[0]||void 0;let n;for(let s of e)if(!(typeof s!="object"||s===null)){n||(n={});for(let a in s)a==="style"?n.style=j(n.style,s.style):a==="class"?n.class=V(n.class,s.class):n[a]=s[a]}return n}function Yo(e){return new H(e,[])}var H=class e{constructor(n,s){this.state=n;this.keys=s;function a(i,c){if(s.length>1){let S=0,l=c[s[S]];for((typeof l!="object"||l===null)&&(c[s[S]]=l={}),S=1;S<s.length-1;S++){let y=l;l=l[s[S]],(typeof l!="object"||l===null)&&(y[s[S]]=l={})}l[s[S]]=i}else s.length===1?typeof c[s[0]]=="object"&&typeof i=="object"?Object.assign(c[s[0]],i):c[s[0]]=i:Object.assign(c,i)}function t(i){let c={};return a(i,c),c}function o(){if(s.length===0)return n;let i=n?n[s[0]]:void 0;for(let c=1;c<s.length&&i;c++)i=i[s[c]];return i}function r(i){a(i,n)}function p(i,c){c?n.patch([t(i)]):n.patch(t(i))}return new Proxy(this,{get:(i,c,S)=>{if(c==="state")return n;if(c==="get")return o;if(c==="put")return r;if(c==="patch")return p;let l=[...i.keys,String(c)];return new e(i.state,l)}})}state;keys;get(){}put(n){}patch(n){}};return W(Wo);})();
|
|
1
|
+
"use strict";var V=(()=>{var j=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(e,n)=>{for(var s in n)j(e,s,{get:n[s],enumerable:!0})},z=(e,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of $(n))!J.call(e,t)&&t!==s&&j(e,t,{get:()=>n[t],enumerable:!(a=W(n,t))||a.enumerable});return e};var Z=e=>z(j({},"__esModule",{value:!0}),e);var Zo={};Q(Zo,{A:()=>pt,ABBR:()=>ft,ADDRESS:()=>St,ANIMATE:()=>Tn,ANIMATEMOTION:()=>yn,ANIMATETRANSFORM:()=>gn,ANNOTATION:()=>bo,ANNOTATION_XML:()=>Eo,AREA:()=>ut,ARTICLE:()=>dt,ASIDE:()=>Tt,AUDIO:()=>yt,B:()=>gt,BASE:()=>xt,BDI:()=>ht,BDO:()=>mt,BLOCKQUOTE:()=>bt,BODY:()=>Et,BR:()=>Pt,BUTTON:()=>At,CANVAS:()=>Ct,CAPTION:()=>Mt,CIRCLE:()=>xn,CITE:()=>Rt,CLIPPATH:()=>hn,CODE:()=>Nt,COL:()=>Ot,COLGROUP:()=>Dt,DATA:()=>vt,DATALIST:()=>Lt,DD:()=>It,DEFS:()=>mn,DEL:()=>Ft,DESC:()=>bn,DETAILS:()=>Vt,DFN:()=>Ht,DIALOG:()=>jt,DIV:()=>Gt,DL:()=>Ut,DT:()=>kt,ELLIPSE:()=>En,EM:()=>_t,EMBED:()=>Bt,FEBLEND:()=>Pn,FECOLORMATRIX:()=>An,FECOMPONENTTRANSFER:()=>Cn,FECOMPOSITE:()=>Mn,FECONVOLVEMATRIX:()=>Rn,FEDIFFUSELIGHTING:()=>Nn,FEDISPLACEMENTMAP:()=>On,FEDISTANTLIGHT:()=>Dn,FEDROPSHADOW:()=>vn,FEFLOOD:()=>Ln,FEFUNCA:()=>In,FEFUNCB:()=>Fn,FEFUNCG:()=>Vn,FEFUNCR:()=>Hn,FEGAUSSIANBLUR:()=>jn,FEIMAGE:()=>Gn,FEMERGE:()=>Un,FEMERGENODE:()=>kn,FEMORPHOLOGY:()=>_n,FEOFFSET:()=>Bn,FEPOINTLIGHT:()=>Kn,FESPECULARLIGHTING:()=>qn,FESPOTLIGHT:()=>wn,FETILE:()=>Xn,FETURBULENCE:()=>Yn,FIELDSET:()=>Kt,FIGCAPTION:()=>qt,FIGURE:()=>wt,FILTER:()=>Wn,FOOTER:()=>Xt,FOREIGNOBJECT:()=>$n,FORM:()=>Yt,G:()=>Jn,H1:()=>Wt,H2:()=>$t,H3:()=>Jt,H4:()=>Qt,H5:()=>zt,H6:()=>Zt,HEAD:()=>te,HEADER:()=>ee,HGROUP:()=>ne,HR:()=>oe,HTML:()=>ae,I:()=>se,IFRAME:()=>re,IMAGE:()=>Qn,IMG:()=>ce,INPUT:()=>ie,INS:()=>le,KBD:()=>pe,LABEL:()=>fe,LEGEND:()=>Se,LI:()=>ue,LINE:()=>zn,LINEARGRADIENT:()=>Zn,LINK:()=>de,MACTION:()=>Po,MAIN:()=>Te,MAP:()=>ye,MARK:()=>ge,MARKER:()=>to,MASK:()=>eo,MATH:()=>Ao,MENU:()=>xe,MERROR:()=>Co,META:()=>he,METADATA:()=>no,METER:()=>me,MFRAC:()=>Mo,MI:()=>Ro,MMULTISCRIPTS:()=>No,MN:()=>Oo,MO:()=>Do,MOVER:()=>vo,MPADDED:()=>Lo,MPATH:()=>oo,MPHANTOM:()=>Io,MPRESCRIPTS:()=>Fo,MROOT:()=>Vo,MROW:()=>Ho,MS:()=>jo,MSPACE:()=>Go,MSQRT:()=>Uo,MSTYLE:()=>ko,MSUB:()=>_o,MSUBSUP:()=>Bo,MSUP:()=>Ko,MTABLE:()=>qo,MTD:()=>wo,MTEXT:()=>Xo,MTR:()=>Yo,MUNDER:()=>Wo,MUNDEROVER:()=>$o,NAV:()=>be,NOSCRIPT:()=>Ee,OBJECT:()=>Pe,OL:()=>Ae,OPTGROUP:()=>Ce,OPTION:()=>Me,OUTPUT:()=>Re,P:()=>Ne,PATH:()=>ao,PATTERN:()=>so,PICTURE:()=>Oe,POLYGON:()=>ro,POLYLINE:()=>co,PRE:()=>De,PROGRESS:()=>ve,Q:()=>Le,RADIALGRADIENT:()=>io,RECT:()=>lo,RP:()=>Ie,RT:()=>Fe,RUBY:()=>Ve,S:()=>He,SAMP:()=>je,SCRIPT:()=>Ge,SEARCH:()=>Ue,SECTION:()=>ke,SELECT:()=>_e,SEMANTICS:()=>Jo,SET:()=>po,SLOT:()=>Be,SMALL:()=>Ke,SOURCE:()=>qe,SPAN:()=>we,STOP:()=>fo,STRONG:()=>Xe,STYLE:()=>Ye,SUB:()=>We,SUMMARY:()=>$e,SUP:()=>Je,SVG:()=>So,SWITCH:()=>uo,SYMBOL:()=>To,TABLE:()=>Qe,TBODY:()=>ze,TD:()=>Ze,TEMPLATE:()=>tn,TEXT:()=>yo,TEXTAREA:()=>en,TEXTPATH:()=>go,TFOOT:()=>nn,TH:()=>on,THEAD:()=>an,TIME:()=>sn,TITLE:()=>rn,TR:()=>cn,TRACK:()=>ln,TSPAN:()=>xo,U:()=>pn,UL:()=>fn,USE:()=>ho,VAR:()=>Sn,VIDEO:()=>un,VIEW:()=>mo,WBR:()=>dn,app:()=>et,child:()=>ct,childCount:()=>rt,children:()=>D,childrenStart:()=>F,context:()=>zo,createPatch:()=>at,createState:()=>ot,defuse:()=>k,globals:()=>M,hydrate:()=>I,memo:()=>nt,mergeClass:()=>_,mergeProps:()=>Qo,mergeStyle:()=>B,props:()=>R,tag:()=>st,vode:()=>tt});var M={currentViewTransition:void 0,requestAnimationFrame:typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:typeof document<"u"&&typeof document.startViewTransition=="function"?document.startViewTransition.bind(document):null};function tt(e,n,...s){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:typeof n=="object"?[e,n,...s]:[e,...s]}function et(e,n,s,...a){if(!e?.parentElement)throw new Error("first argument to app() must be a valid HTMLElement inside the <html></html> document");if(!n||typeof n!="object")throw new Error("second argument to app() must be a state object");if(typeof s!="function")throw new Error("third argument to app() must be a function that returns a vode");let t={};t.syncRenderer=M.requestAnimationFrame,t.asyncRenderer=M.startViewTransition,t.qSync=null,t.qAsync=null,t.stats={lastSyncRenderTime:0,lastAsyncRenderTime:0,syncRenderCount:0,asyncRenderCount:0,liveEffectCount:0,patchCount:0,syncRenderPatchCount:0,asyncRenderPatchCount:0},t.unmounts=[];let o=n;"patch"in n&&typeof n.patch=="function"&&Array.isArray(n.patch.initialPatches)&&(a=[...n.patch.initialPatches,...a]),Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(c,x)=>{if(!(!c||typeof c!="function"&&typeof c!="object"))if(t.stats.patchCount++,c?.next){let h=c;t.stats.liveEffectCount++;try{let A=await h.next();for(;A.done===!1;){t.stats.liveEffectCount++;try{o.patch(A.value,x),A=await h.next()}finally{t.stats.liveEffectCount--}}o.patch(A.value,x)}finally{t.stats.liveEffectCount--}}else if(c.then){t.stats.liveEffectCount++;try{let h=await c;o.patch(h,x)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(c))if(c.length>0)for(let h of c)o.patch(h,!document.hidden&&!!t.asyncRenderer);else{t.qSync=P(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{M.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof c=="function"?o.patch(c(t.state),x):x?(t.stats.asyncRenderPatchCount++,t.qAsync=P(t.qAsync||{},c,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=P(t.qSync||{},c,!1),t.renderSync())}});function r(c){let x=Date.now(),h=s(t.state);t.vode=O(t.state,e.parentElement,0,0,t.vode,h,null,t.unmounts,0),e.tagName.toUpperCase()!==h[0].toUpperCase()&&(e=t.vode.node,e._vode=t),c||(t.stats.lastSyncRenderTime=Date.now()-x,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let l=r.bind(null,!1),i=r.bind(null,!0);Object.defineProperty(t,"renderSync",{enumerable:!1,configurable:!0,writable:!1,value:()=>{t.isRendering||!t.qSync||(t.isRendering=!0,t.state=P(t.state,t.qSync,!0),t.qSync=null,t.syncRenderer(l))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await M.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let c=Date.now();try{t.state=P(t.state,t.qAsync,!0),t.qAsync=null,M.currentViewTransition=t.asyncRenderer(i),await M.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-c,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=o;let p=e;p._vode=t;let f=Array.from(e.parentElement.children).indexOf(e);t.isRendering=!0,t.vode=O(n,e.parentElement,f,f,I(e,!0),s(n),null,t.unmounts,0),t.isRendering=!1,t.qSync&&t.renderSync();for(let c of a)o.patch(c);return c=>o.patch(c)}function k(e){if(e?._vode){let s=function(t){if(!t?.node)return;let o=R(t);if(o){for(let r in o)r[0]==="o"&&r[1]==="n"&&(t.node[r]=null);t.node.catch=null}if(t.node._vode)k(t.node);else{let r=D(t);if(r)for(let l of r)s(l)}};var n=s;let a=e._vode;delete e._vode,Object.defineProperty(a.state,"patch",{value:void 0}),Object.defineProperty(a,"renderSync",{value:()=>{}}),Object.defineProperty(a,"renderAsync",{value:()=>{}}),s(a.vode)}else for(let s of e.children)k(s)}function I(e,n){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?n?e:e.nodeValue:void 0;if(e.nodeType===Node.ELEMENT_NODE){let a=[e.tagName.toLowerCase()];if(n&&(a.node=e),e?.hasAttributes()){let t={},o=e.attributes;for(let r of o)t[r.name]=r.value;a.push(t)}if(e.hasChildNodes()){let t=[];for(let o of e.childNodes){let r=o&&I(o,n);r?a.push(r):o&&n&&t.push(o)}for(let o of t)o.remove()}return a}else return}function nt(e,n){if(!e||!Array.isArray(e))throw new Error("first argument to memo() must be an array of values to compare");if(typeof n!="function")throw new Error("second argument to memo() must be a function that returns a vode or props object");return n.__memo=e,n}function ot(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return"patch"in e||Object.defineProperty(e,"patch",{enumerable:!1,configurable:!0,writable:!1,value:n=>{let s=e;Array.isArray(s.patch.initialPatches)||(s.patch.initialPatches=[]),s.patch.initialPatches.push(n)}}),e}function at(e){return e}function st(e){return e?Array.isArray(e)?e[0]:typeof e=="string"||e.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function R(e){if(Array.isArray(e)&&e.length>1&&e[1]&&!Array.isArray(e[1])&&typeof e[1]=="object"&&e[1].nodeType!==Node.TEXT_NODE)return e[1]}function D(e){let n=F(e);return n>0?e.slice(n):null}function rt(e){let n=F(e);return n<0?0:e.length-n}function ct(e,n){let s=F(e);if(s>0)return e[n+s]}function F(e){return R(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function P(e,n,s){if(!n)return e;for(let a in n){let t=n[a];if(t&&typeof t=="object"){let o=e[a];o?Array.isArray(t)?e[a]=[...t]:t instanceof Date&&o!==t?e[a]=new Date(t):Array.isArray(o)?e[a]=P({},t,s):typeof o=="object"?P(e[a],t,s):e[a]=P({},t,s):Array.isArray(t)?e[a]=[...t]:t instanceof Date?e[a]=new Date(t):e[a]=P({},t,s)}else t===void 0&&s?delete e[a]:e[a]=t}return e}function O(e,n,s,a,t,o,r,l,i){try{o=G(e,o,t);let p=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&p)return t;let f=t?.nodeType===Node.TEXT_NODE,c=f?t:t?.node;if(p){if(!f&&typeof t?.unmountCount=="number"){let y=t.unmountStart,d=t.unmountCount;for(let S=d-1;S>=0;S--){let T=l[y+S];T&&(e.patch(T(e,c)),l[y+S]=null)}}c?.remove();return}let x=!p&<(o),h=!p&&it(o),A=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!x&&!h&&!A&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(A&&x?o=o.wholeText:A&&h&&(o=[...o]),f&&x)return c.nodeValue!==o&&(c.nodeValue=o),t;if(x&&(!c||!f)){let y=document.createTextNode(o);if(c){if(!f&&typeof t?.unmountCount=="number"){let d=t.unmountStart,S=t.unmountCount;for(let T=S-1;T>=0;T--){let C=l[d+T];C&&(e.patch(C(e,c)),l[d+T]=null)}}c.replaceWith(y)}else{let d=!1;for(let S=a;S<n.childNodes.length;S++){let T=n.childNodes[S];if(T){T.before(y,T),d=!0;break}}d||n.appendChild(y)}return y}if(h&&(!c||f||t[0]!==o[0])){let y=o;1 in y&&(y[1]=G(e,y[1],void 0));let d=R(o);d?.xmlns!==void 0&&(r=d.xmlns);let S=r?document.createElementNS(r,o[0]):document.createElement(o[0]);if(o.node=S,U(e,S,void 0,d,r??null),d&&"catch"in d&&(o.node.catch=null,o.node.removeAttribute("catch")),c){if(!f&&typeof t?.unmountCount=="number"){let b=t.unmountStart,g=t.unmountCount;for(let u=g-1;u>=0;u--){let m=l[b+u];m&&(e.patch(m(e,c)),l[b+u]=null)}}l[i]=d?.onUnmount??null,c.replaceWith(S)}else{l[i]=d?.onUnmount??null;let b=!1;for(let g=a;g<n.childNodes.length;g++){let u=n.childNodes[g];if(u){u.before(S,u),b=!0;break}}b||n.appendChild(S)}let T=0,C=i+1,N=D(o);if(N){let b=d?2:1,g=0;for(let u=0;u<N.length;u++){let m=N[u],E=O(e,S,u,g,void 0,m,r??null,l,C);if(o[u+b]=E,E){g++;let v=E.unmountCount||0;T+=v,C+=v}}}return S.onMount&&e.patch(S.onMount(S)),o.unmountCount=1+T,o.unmountStart=i,o}if(!f&&h&&t[0]===o[0]){o.node=c;let y=o,d=t,S=R(o),T=R(t);if(S?.xmlns!==void 0&&(r=S.xmlns),y[1]?.__memo){let u=y[1];y[1]=G(e,y[1],d[1]),u!==y[1]&&U(e,c,T,S,r)}else U(e,c,T,S,r);S?.catch&&T?.catch!==S.catch&&(o.node.catch=null,o.node.removeAttribute("catch")),l[i]=S?.onUnmount??null;let C=0,N=i+1,b=D(o),g=D(t);if(b){let u=S?2:1,m=0;for(let E=0;E<b.length;E++){let v=b[E],Y=g&&g[E],H=O(e,c,E,m,Y,v,r,l,N);if(o[E+u]=H,H){m++;let q=H.unmountCount||0;C+=q,N+=q}}}if(g){let u=b?b.length:0;for(let m=g.length-1;m>=u;m--)O(e,c,m,m,g[m],void 0,r,l,g[m].unmountStart)}return o.unmountCount=1+C,o.unmountStart=i,o}}catch(p){let f=R(o)?.catch;if(f){let c=typeof f=="function"?f(e,p):f;return O(e,n,s,a,I(o?.node||t?.node,!0),c,r,l,i)}else throw p}}function it(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function lt(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function G(e,n,s){if(typeof n!="function")return n;let a=n?.__memo,t=s?.__memo;if(Array.isArray(a)&&Array.isArray(t)&&a.length===t.length){let l=!0;for(let i=0;i<a.length;i++)if(a[i]!==t[i]){l=!1;break}if(l)return s}let o=n(e);if(typeof o=="function"&&o?.__memo){let l=o.__memo;if(Array.isArray(l)&&Array.isArray(t)&&l.length===t.length){let p=!0;for(let f=0;f<l.length;f++)if(l[f]!==t[f]){p=!1;break}if(p)return s}let i=o(e);return typeof i=="object"&&(i.__memo=l),i}let r=typeof o=="function"?w(o,e):o;return typeof r=="object"&&(r.__memo=o?.__memo||n?.__memo),r}function w(e,n){return typeof e=="function"?w(e(n),n):e}function U(e,n,s,a,t){if(!a&&!s)return;let o=t!==void 0;if(s)for(let r in s){let l=s[r],i=a?.[r];l!==i&&(a?a[r]=L(e,n,r,l,i,o):L(e,n,r,l,void 0,o))}if(a&&s){for(let r in a)if(!(r in s)){let l=a[r];a[r]=L(e,n,r,void 0,l,o)}}else if(a)for(let r in a){let l=a[r];a[r]=L(e,n,r,void 0,l,o)}}function L(e,n,s,a,t,o){if(s==="style")if(!t)n.style.cssText="";else if(typeof t=="string")a!==t&&(n.style.cssText=t);else if(a&&typeof a=="object"){for(let r in a)t[r]||(n.style[r]=null);for(let r in t){let l=a[r],i=t[r];l!==i&&(n.style[r]=i)}}else for(let r in t)n.style[r]=t[r];else if(s==="class")t?n.setAttribute("class",X(t)):n.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(t){let r=null;if(typeof t=="function"){let l=t;r=i=>e.patch(l(e,i))}else typeof t=="object"&&(r=()=>e.patch(t));n[s]=r}else n[s]=null;else o||(n[s]=t),t==null||t===!1?n.removeAttribute(s):n.setAttribute(s,t);return t}function X(e){return typeof e=="string"?e:Array.isArray(e)?e.map(X).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var pt="a",ft="abbr",St="address",ut="area",dt="article",Tt="aside",yt="audio",gt="b",xt="base",ht="bdi",mt="bdo",bt="blockquote",Et="body",Pt="br",At="button",Ct="canvas",Mt="caption",Rt="cite",Nt="code",Ot="col",Dt="colgroup",vt="data",Lt="datalist",It="dd",Ft="del",Vt="details",Ht="dfn",jt="dialog",Gt="div",Ut="dl",kt="dt",_t="em",Bt="embed",Kt="fieldset",qt="figcaption",wt="figure",Xt="footer",Yt="form",Wt="h1",$t="h2",Jt="h3",Qt="h4",zt="h5",Zt="h6",te="head",ee="header",ne="hgroup",oe="hr",ae="html",se="i",re="iframe",ce="img",ie="input",le="ins",pe="kbd",fe="label",Se="legend",ue="li",de="link",Te="main",ye="map",ge="mark",xe="menu",he="meta",me="meter",be="nav",Ee="noscript",Pe="object",Ae="ol",Ce="optgroup",Me="option",Re="output",Ne="p",Oe="picture",De="pre",ve="progress",Le="q",Ie="rp",Fe="rt",Ve="ruby",He="s",je="samp",Ge="script",Ue="search",ke="section",_e="select",Be="slot",Ke="small",qe="source",we="span",Xe="strong",Ye="style",We="sub",$e="summary",Je="sup",Qe="table",ze="tbody",Ze="td",tn="template",en="textarea",nn="tfoot",on="th",an="thead",sn="time",rn="title",cn="tr",ln="track",pn="u",fn="ul",Sn="var",un="video",dn="wbr",Tn="animate",yn="animateMotion",gn="animateTransform",xn="circle",hn="clipPath",mn="defs",bn="desc",En="ellipse",Pn="feBlend",An="feColorMatrix",Cn="feComponentTransfer",Mn="feComposite",Rn="feConvolveMatrix",Nn="feDiffuseLighting",On="feDisplacementMap",Dn="feDistantLight",vn="feDropShadow",Ln="feFlood",In="feFuncA",Fn="feFuncB",Vn="feFuncG",Hn="feFuncR",jn="feGaussianBlur",Gn="feImage",Un="feMerge",kn="feMergeNode",_n="feMorphology",Bn="feOffset",Kn="fePointLight",qn="feSpecularLighting",wn="feSpotLight",Xn="feTile",Yn="feTurbulence",Wn="filter",$n="foreignObject",Jn="g",Qn="image",zn="line",Zn="linearGradient",to="marker",eo="mask",no="metadata",oo="mpath",ao="path",so="pattern",ro="polygon",co="polyline",io="radialGradient",lo="rect",po="set",fo="stop",So="svg",uo="switch",To="symbol",yo="text",go="textPath",xo="tspan",ho="use",mo="view",bo="annotation",Eo="annotation-xml",Po="maction",Ao="math",Co="merror",Mo="mfrac",Ro="mi",No="mmultiscripts",Oo="mn",Do="mo",vo="mover",Lo="mpadded",Io="mphantom",Fo="mprescripts",Vo="mroot",Ho="mrow",jo="ms",Go="mspace",Uo="msqrt",ko="mstyle",_o="msub",Bo="msubsup",Ko="msup",qo="mtable",wo="mtd",Xo="mtext",Yo="mtr",Wo="munder",$o="munderover",Jo="semantics";function _(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=e[0];for(let s=1;s<e.length;s++){let a=n,t=e[s];if(!a)n=t;else if(t)if(typeof a=="string"&&typeof t=="string"){let o=a.split(" "),r=t.split(" "),l=new Set([...o,...r]);n=Array.from(l).join(" ").trim()}else if(typeof a=="string"&&Array.isArray(t)){let o=new Set([...t,...a.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&typeof t=="string"){let o=new Set([...a,...t.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&Array.isArray(t)){let o=new Set([...a,...t]);n=Array.from(o).join(" ").trim()}else if(typeof a=="string"&&typeof t=="object")n={[a]:!0,...t};else if(typeof a=="object"&&typeof t=="string")n={...a,[t]:!0};else if(typeof a=="object"&&typeof t=="object")n={...a,...t};else if(typeof a=="object"&&Array.isArray(t)){let o={...a};for(let r of t)o[r]=!0;n=o}else if(Array.isArray(a)&&typeof t=="object"){let o={};for(let r of a)o[r]=!0;for(let r of Object.keys(t))o[r]=t[r];n=o}else throw new Error(`cannot merge classes of ${a} (${typeof a}) and ${t} (${typeof t})`);else continue}return n}var V;function B(...e){V||(V=document.createElement("div"));try{let n=V.style;for(let s of e)if(typeof s=="object"&&s!==null)for(let a in s)n[a]=s[a];else typeof s=="string"&&(n.cssText+=";"+s);return n.cssText}finally{V.style.cssText=""}}function Qo(...e){if(e.length===0)return;if(e.length===1)return e[0]||void 0;let n;for(let s of e)if(!(typeof s!="object"||s===null)){n||(n={});for(let a in s)a==="style"?n.style=B(n.style,s.style):a==="class"?n.class=_(n.class,s.class):n[a]=s[a]}return n}function zo(e){return new K(e,[])}var K=class e{constructor(n,s){this.state=n;this.keys=s;function a(i,p){if(s.length>1){let f=0,c=p[s[f]];for((typeof c!="object"||c===null)&&(p[s[f]]=c={}),f=1;f<s.length-1;f++){let x=c;c=c[s[f]],(typeof c!="object"||c===null)&&(x[s[f]]=c={})}c[s[f]]=i}else s.length===1?typeof p[s[0]]=="object"&&typeof i=="object"?Object.assign(p[s[0]],i):p[s[0]]=i:Object.assign(p,i)}function t(i){let p={};return a(i,p),p}function o(){if(s.length===0)return n;let i=n?n[s[0]]:void 0;for(let p=1;p<s.length&&i;p++)i=i[s[p]];return i}function r(i){a(i,n)}function l(i,p){p?n.patch([t(i)]):n.patch(t(i))}return new Proxy(this,{get:(i,p,f)=>{if(p==="state")return n;if(p==="get")return o;if(p==="put")return r;if(p==="patch")return l;let c=[...i.keys,String(p)];return new e(i.state,c)}})}state;keys;get(){}put(n){}patch(n){}};return Z(Zo);})();
|
package/dist/vode.min.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var P={currentViewTransition:void 0,requestAnimationFrame:typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:typeof document<"u"&&typeof document.startViewTransition=="function"?document.startViewTransition.bind(document):null};function q(e,n,...s){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:typeof n=="object"?[e,n,...s]:[e,...s]}function w(e,n,s,...a){if(!e?.parentElement)throw new Error("first argument to app() must be a valid HTMLElement inside the <html></html> document");if(!n||typeof n!="object")throw new Error("second argument to app() must be a state object");if(typeof s!="function")throw new Error("third argument to app() must be a function that returns a vode");let t={};t.syncRenderer=P.requestAnimationFrame,t.asyncRenderer=P.startViewTransition,t.qSync=null,t.qAsync=null,t.stats={lastSyncRenderTime:0,lastAsyncRenderTime:0,syncRenderCount:0,asyncRenderCount:0,liveEffectCount:0,patchCount:0,syncRenderPatchCount:0,asyncRenderPatchCount:0};let o=n;"patch"in n&&typeof n.patch=="function"&&Array.isArray(n.patch.initialPatches)&&(a=[...n.patch.initialPatches,...a]),Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(l,y)=>{if(!(!l||typeof l!="function"&&typeof l!="object"))if(t.stats.patchCount++,l?.next){let f=l;t.stats.liveEffectCount++;try{let u=await f.next();for(;u.done===!1;){t.stats.liveEffectCount++;try{o.patch(u.value,y),u=await f.next()}finally{t.stats.liveEffectCount--}}o.patch(u.value,y)}finally{t.stats.liveEffectCount--}}else if(l.then){t.stats.liveEffectCount++;try{let f=await l;o.patch(f,y)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(l))if(l.length>0)for(let f of l)o.patch(f,!document.hidden&&!!t.asyncRenderer);else{t.qSync=E(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{P.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof l=="function"?o.patch(l(t.state),y):y?(t.stats.asyncRenderPatchCount++,t.qAsync=E(t.qAsync||{},l,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=E(t.qSync||{},l,!1),t.renderSync())}});function r(l){let y=Date.now(),f=s(t.state);t.vode=C(t.state,e.parentElement,0,0,t.vode,f),e.tagName.toUpperCase()!==f[0].toUpperCase()&&(e=t.vode.node,e._vode=t),l||(t.stats.lastSyncRenderTime=Date.now()-y,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let p=r.bind(null,!1),i=r.bind(null,!0);Object.defineProperty(t,"renderSync",{enumerable:!1,configurable:!0,writable:!1,value:()=>{t.isRendering||!t.qSync||(t.isRendering=!0,t.state=E(t.state,t.qSync,!0),t.qSync=null,t.syncRenderer(p))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await P.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let l=Date.now();try{t.state=E(t.state,t.qAsync,!0),t.qAsync=null,P.currentViewTransition=t.asyncRenderer(i),await P.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-l,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=o;let c=e;c._vode=t;let S=Array.from(e.parentElement.children).indexOf(e);t.vode=C(n,e.parentElement,S,S,v(e,!0),s(n));for(let l of a)o.patch(l);return l=>o.patch(l)}function V(e){if(e?._vode){let s=function(t){if(!t?.node)return;let o=A(t);if(o){for(let r in o)r[0]==="o"&&r[1]==="n"&&(t.node[r]=null);t.node.catch=null}if(t.node._vode)V(t.node);else{let r=N(t);if(r)for(let p of r)s(p)}};var n=s;let a=e._vode;delete e._vode,Object.defineProperty(a.state,"patch",{value:void 0}),Object.defineProperty(a,"renderSync",{value:()=>{}}),Object.defineProperty(a,"renderAsync",{value:()=>{}}),s(a.vode)}else for(let s of e.children)V(s)}function v(e,n){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?n?e:e.nodeValue:void 0;if(e.nodeType===Node.ELEMENT_NODE){let a=[e.tagName.toLowerCase()];if(n&&(a.node=e),e?.hasAttributes()){let t={},o=e.attributes;for(let r of o)t[r.name]=r.value;a.push(t)}if(e.hasChildNodes()){let t=[];for(let o of e.childNodes){let r=o&&v(o,n);r?a.push(r):o&&n&&t.push(o)}for(let o of t)o.remove()}return a}else return}function X(e,n){if(!e||!Array.isArray(e))throw new Error("first argument to memo() must be an array of values to compare");if(typeof n!="function")throw new Error("second argument to memo() must be a function that returns a vode or props object");return n.__memo=e,n}function Y(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return"patch"in e||Object.defineProperty(e,"patch",{enumerable:!1,configurable:!0,writable:!1,value:n=>{let s=e;Array.isArray(s.patch.initialPatches)||(s.patch.initialPatches=[]),s.patch.initialPatches.push(n)}}),e}function W(e){return e}function $(e){return e?Array.isArray(e)?e[0]:typeof e=="string"||e.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function A(e){if(Array.isArray(e)&&e.length>1&&e[1]&&!Array.isArray(e[1])&&typeof e[1]=="object"&&e[1].nodeType!==Node.TEXT_NODE)return e[1]}function N(e){let n=L(e);return n>0?e.slice(n):null}function J(e){let n=L(e);return n<0?0:e.length-n}function Q(e,n){let s=L(e);if(s>0)return e[n+s]}function L(e){return A(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function E(e,n,s){if(!n)return e;for(let a in n){let t=n[a];if(t&&typeof t=="object"){let o=e[a];o?Array.isArray(t)?e[a]=[...t]:t instanceof Date&&o!==t?e[a]=new Date(t):Array.isArray(o)?e[a]=E({},t,s):typeof o=="object"?E(e[a],t,s):e[a]=E({},t,s):Array.isArray(t)?e[a]=[...t]:t instanceof Date?e[a]=new Date(t):e[a]=E({},t,s)}else t===void 0&&s?delete e[a]:e[a]=t}return e}function C(e,n,s,a,t,o,r){try{o=O(e,o,t);let p=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&p)return t;let i=t?.nodeType===Node.TEXT_NODE,c=i?t:t?.node;if(p){c?.onUnmount&&e.patch(c.onUnmount(c)),c?.remove();return}let S=!p&&K(o),l=!p&&B(o),y=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!S&&!l&&!y&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(y&&S?o=o.wholeText:y&&l&&(o=[...o]),i&&S)return c.nodeValue!==o&&(c.nodeValue=o),t;if(S&&(!c||!i)){let f=document.createTextNode(o);if(c)c.onUnmount&&e.patch(c.onUnmount(c)),c.replaceWith(f);else{let u=!1;for(let d=a;d<n.childNodes.length;d++){let x=n.childNodes[d];if(x){x.before(f,x),u=!0;break}}u||n.appendChild(f)}return f}if(l&&(!c||i||t[0]!==o[0])){let f=o;1 in f&&(f[1]=O(e,f[1],void 0));let u=A(o);u?.xmlns!==void 0&&(r=u.xmlns);let d=r?document.createElementNS(r,o[0]):document.createElement(o[0]);if(o.node=d,D(e,d,void 0,u,r??null),u&&"catch"in u&&(o.node.catch=null,o.node.removeAttribute("catch")),c)c.onUnmount&&e.patch(c.onUnmount(c)),c.replaceWith(d);else{let h=!1;for(let g=a;g<n.childNodes.length;g++){let T=n.childNodes[g];if(T){T.before(d,T),h=!0;break}}h||n.appendChild(d)}let x=N(o);if(x){let h=u?2:1,g=0;for(let T=0;T<x.length;T++){let m=x[T],b=C(e,d,T,g,void 0,m,r??null);o[T+h]=b,b&&g++}}return d.onMount&&e.patch(d.onMount(d)),o}if(!i&&l&&t[0]===o[0]){o.node=c;let f=o,u=t,d=A(o),x=A(t);if(d?.xmlns!==void 0&&(r=d.xmlns),f[1]?.__memo){let T=f[1];f[1]=O(e,f[1],u[1]),T!==f[1]&&D(e,c,x,d,r)}else D(e,c,x,d,r);d?.catch&&x?.catch!==d.catch&&(o.node.catch=null,o.node.removeAttribute("catch"));let h=N(o),g=N(t);if(h){let T=d?2:1,m=0;for(let b=0;b<h.length;b++){let k=h[b],_=g&&g[b],F=C(e,c,b,m,_,k,r);o[b+T]=F,F&&m++}}if(g){let T=h?h.length:0;for(let m=g.length-1;m>=T;m--)C(e,c,m,m,g[m],void 0,r)}return o}}catch(p){let i=A(o)?.catch;if(i){let c=typeof i=="function"?i(e,p):i;return C(e,n,s,a,v(o?.node||t?.node,!0),c,r)}else throw p}}function B(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function K(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function O(e,n,s){if(typeof n!="function")return n;let a=n?.__memo,t=s?.__memo;if(Array.isArray(a)&&Array.isArray(t)&&a.length===t.length){let p=!0;for(let i=0;i<a.length;i++)if(a[i]!==t[i]){p=!1;break}if(p)return s}let o=n(e);if(typeof o=="function"&&o?.__memo){let p=o.__memo;if(Array.isArray(p)&&Array.isArray(t)&&p.length===t.length){let c=!0;for(let S=0;S<p.length;S++)if(p[S]!==t[S]){c=!1;break}if(c)return s}let i=o(e);return typeof i=="object"&&(i.__memo=p),i}let r=typeof o=="function"?j(o,e):o;return typeof r=="object"&&(r.__memo=o?.__memo||n?.__memo),r}function j(e,n){return typeof e=="function"?j(e(n),n):e}function D(e,n,s,a,t){if(!a&&!s)return;let o=t!==void 0;if(s)for(let r in s){let p=s[r],i=a?.[r];p!==i&&(a?a[r]=M(e,n,r,p,i,o):M(e,n,r,p,void 0,o))}if(a&&s){for(let r in a)if(!(r in s)){let p=a[r];a[r]=M(e,n,r,void 0,p,o)}}else if(a)for(let r in a){let p=a[r];a[r]=M(e,n,r,void 0,p,o)}}function M(e,n,s,a,t,o){if(s==="style")if(!t)n.style.cssText="";else if(typeof t=="string")a!==t&&(n.style.cssText=t);else if(a&&typeof a=="object"){for(let r in a)t[r]||(n.style[r]=null);for(let r in t){let p=a[r],i=t[r];p!==i&&(n.style[r]=i)}}else for(let r in t)n.style[r]=t[r];else if(s==="class")t?n.setAttribute("class",H(t)):n.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(t){let r=null;if(typeof t=="function"){let p=t;r=i=>e.patch(p(e,i))}else typeof t=="object"&&(r=()=>e.patch(t));n[s]=r}else n[s]=null;else o||(n[s]=t),t==null||t===!1?n.removeAttribute(s):n.setAttribute(s,t);return t}function H(e){return typeof e=="string"?e:Array.isArray(e)?e.map(H).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var Z="a",tt="abbr",et="address",nt="area",ot="article",at="aside",st="audio",rt="b",ct="base",it="bdi",lt="bdo",pt="blockquote",ft="body",St="br",dt="button",ut="canvas",Tt="caption",yt="cite",gt="code",xt="col",ht="colgroup",mt="data",bt="datalist",Et="dd",Pt="del",At="details",Ct="dfn",Mt="dialog",Nt="div",Rt="dl",Ot="dt",Dt="em",vt="embed",Lt="fieldset",It="figcaption",Ft="figure",Vt="footer",jt="form",Ht="h1",Ut="h2",Gt="h3",kt="h4",_t="h5",Bt="h6",Kt="head",qt="header",wt="hgroup",Xt="hr",Yt="html",Wt="i",$t="iframe",Jt="img",Qt="input",zt="ins",Zt="kbd",te="label",ee="legend",ne="li",oe="link",ae="main",se="map",re="mark",ce="menu",ie="meta",le="meter",pe="nav",fe="noscript",Se="object",de="ol",ue="optgroup",Te="option",ye="output",ge="p",xe="picture",he="pre",me="progress",be="q",Ee="rp",Pe="rt",Ae="ruby",Ce="s",Me="samp",Ne="script",Re="search",Oe="section",De="select",ve="slot",Le="small",Ie="source",Fe="span",Ve="strong",je="style",He="sub",Ue="summary",Ge="sup",ke="table",_e="tbody",Be="td",Ke="template",qe="textarea",we="tfoot",Xe="th",Ye="thead",We="time",$e="title",Je="tr",Qe="track",ze="u",Ze="ul",tn="var",en="video",nn="wbr",on="animate",an="animateMotion",sn="animateTransform",rn="circle",cn="clipPath",ln="defs",pn="desc",fn="ellipse",Sn="feBlend",dn="feColorMatrix",un="feComponentTransfer",Tn="feComposite",yn="feConvolveMatrix",gn="feDiffuseLighting",xn="feDisplacementMap",hn="feDistantLight",mn="feDropShadow",bn="feFlood",En="feFuncA",Pn="feFuncB",An="feFuncG",Cn="feFuncR",Mn="feGaussianBlur",Nn="feImage",Rn="feMerge",On="feMergeNode",Dn="feMorphology",vn="feOffset",Ln="fePointLight",In="feSpecularLighting",Fn="feSpotLight",Vn="feTile",jn="feTurbulence",Hn="filter",Un="foreignObject",Gn="g",kn="image",_n="line",Bn="linearGradient",Kn="marker",qn="mask",wn="metadata",Xn="mpath",Yn="path",Wn="pattern",$n="polygon",Jn="polyline",Qn="radialGradient",zn="rect",Zn="set",to="stop",eo="svg",no="switch",oo="symbol",ao="text",so="textPath",ro="tspan",co="use",io="view",lo="annotation",po="annotation-xml",fo="maction",So="math",uo="merror",To="mfrac",yo="mi",go="mmultiscripts",xo="mn",ho="mo",mo="mover",bo="mpadded",Eo="mphantom",Po="mprescripts",Ao="mroot",Co="mrow",Mo="ms",No="mspace",Ro="msqrt",Oo="mstyle",Do="msub",vo="msubsup",Lo="msup",Io="mtable",Fo="mtd",Vo="mtext",jo="mtr",Ho="munder",Uo="munderover",Go="semantics";function U(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=e[0];for(let s=1;s<e.length;s++){let a=n,t=e[s];if(!a)n=t;else if(t)if(typeof a=="string"&&typeof t=="string"){let o=a.split(" "),r=t.split(" "),p=new Set([...o,...r]);n=Array.from(p).join(" ").trim()}else if(typeof a=="string"&&Array.isArray(t)){let o=new Set([...t,...a.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&typeof t=="string"){let o=new Set([...a,...t.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&Array.isArray(t)){let o=new Set([...a,...t]);n=Array.from(o).join(" ").trim()}else if(typeof a=="string"&&typeof t=="object")n={[a]:!0,...t};else if(typeof a=="object"&&typeof t=="string")n={...a,[t]:!0};else if(typeof a=="object"&&typeof t=="object")n={...a,...t};else if(typeof a=="object"&&Array.isArray(t)){let o={...a};for(let r of t)o[r]=!0;n=o}else if(Array.isArray(a)&&typeof t=="object"){let o={};for(let r of a)o[r]=!0;for(let r of Object.keys(t))o[r]=t[r];n=o}else throw new Error(`cannot merge classes of ${a} (${typeof a}) and ${t} (${typeof t})`);else continue}return n}var R;function G(...e){R||(R=document.createElement("div"));try{let n=R.style;for(let s of e)if(typeof s=="object"&&s!==null)for(let a in s)n[a]=s[a];else typeof s=="string"&&(n.cssText+=";"+s);return n.cssText}finally{R.style.cssText=""}}function wo(...e){if(e.length===0)return;if(e.length===1)return e[0]||void 0;let n;for(let s of e)if(!(typeof s!="object"||s===null)){n||(n={});for(let a in s)a==="style"?n.style=G(n.style,s.style):a==="class"?n.class=U(n.class,s.class):n[a]=s[a]}return n}function Yo(e){return new I(e,[])}var I=class e{constructor(n,s){this.state=n;this.keys=s;function a(i,c){if(s.length>1){let S=0,l=c[s[S]];for((typeof l!="object"||l===null)&&(c[s[S]]=l={}),S=1;S<s.length-1;S++){let y=l;l=l[s[S]],(typeof l!="object"||l===null)&&(y[s[S]]=l={})}l[s[S]]=i}else s.length===1?typeof c[s[0]]=="object"&&typeof i=="object"?Object.assign(c[s[0]],i):c[s[0]]=i:Object.assign(c,i)}function t(i){let c={};return a(i,c),c}function o(){if(s.length===0)return n;let i=n?n[s[0]]:void 0;for(let c=1;c<s.length&&i;c++)i=i[s[c]];return i}function r(i){a(i,n)}function p(i,c){c?n.patch([t(i)]):n.patch(t(i))}return new Proxy(this,{get:(i,c,S)=>{if(c==="state")return n;if(c==="get")return o;if(c==="put")return r;if(c==="patch")return p;let l=[...i.keys,String(c)];return new e(i.state,l)}})}state;keys;get(){}put(n){}patch(n){}};export{Z as A,tt as ABBR,et as ADDRESS,on as ANIMATE,an as ANIMATEMOTION,sn as ANIMATETRANSFORM,lo as ANNOTATION,po as ANNOTATION_XML,nt as AREA,ot as ARTICLE,at as ASIDE,st as AUDIO,rt as B,ct as BASE,it as BDI,lt as BDO,pt as BLOCKQUOTE,ft as BODY,St as BR,dt as BUTTON,ut as CANVAS,Tt as CAPTION,rn as CIRCLE,yt as CITE,cn as CLIPPATH,gt as CODE,xt as COL,ht as COLGROUP,mt as DATA,bt as DATALIST,Et as DD,ln as DEFS,Pt as DEL,pn as DESC,At as DETAILS,Ct as DFN,Mt as DIALOG,Nt as DIV,Rt as DL,Ot as DT,fn as ELLIPSE,Dt as EM,vt as EMBED,Sn as FEBLEND,dn as FECOLORMATRIX,un as FECOMPONENTTRANSFER,Tn as FECOMPOSITE,yn as FECONVOLVEMATRIX,gn as FEDIFFUSELIGHTING,xn as FEDISPLACEMENTMAP,hn as FEDISTANTLIGHT,mn as FEDROPSHADOW,bn as FEFLOOD,En as FEFUNCA,Pn as FEFUNCB,An as FEFUNCG,Cn as FEFUNCR,Mn as FEGAUSSIANBLUR,Nn as FEIMAGE,Rn as FEMERGE,On as FEMERGENODE,Dn as FEMORPHOLOGY,vn as FEOFFSET,Ln as FEPOINTLIGHT,In as FESPECULARLIGHTING,Fn as FESPOTLIGHT,Vn as FETILE,jn as FETURBULENCE,Lt as FIELDSET,It as FIGCAPTION,Ft as FIGURE,Hn as FILTER,Vt as FOOTER,Un as FOREIGNOBJECT,jt as FORM,Gn as G,Ht as H1,Ut as H2,Gt as H3,kt as H4,_t as H5,Bt as H6,Kt as HEAD,qt as HEADER,wt as HGROUP,Xt as HR,Yt as HTML,Wt as I,$t as IFRAME,kn as IMAGE,Jt as IMG,Qt as INPUT,zt as INS,Zt as KBD,te as LABEL,ee as LEGEND,ne as LI,_n as LINE,Bn as LINEARGRADIENT,oe as LINK,fo as MACTION,ae as MAIN,se as MAP,re as MARK,Kn as MARKER,qn as MASK,So as MATH,ce as MENU,uo as MERROR,ie as META,wn as METADATA,le as METER,To as MFRAC,yo as MI,go as MMULTISCRIPTS,xo as MN,ho as MO,mo as MOVER,bo as MPADDED,Xn as MPATH,Eo as MPHANTOM,Po as MPRESCRIPTS,Ao as MROOT,Co as MROW,Mo as MS,No as MSPACE,Ro as MSQRT,Oo as MSTYLE,Do as MSUB,vo as MSUBSUP,Lo as MSUP,Io as MTABLE,Fo as MTD,Vo as MTEXT,jo as MTR,Ho as MUNDER,Uo as MUNDEROVER,pe as NAV,fe as NOSCRIPT,Se as OBJECT,de as OL,ue as OPTGROUP,Te as OPTION,ye as OUTPUT,ge as P,Yn as PATH,Wn as PATTERN,xe as PICTURE,$n as POLYGON,Jn as POLYLINE,he as PRE,me as PROGRESS,be as Q,Qn as RADIALGRADIENT,zn as RECT,Ee as RP,Pe as RT,Ae as RUBY,Ce as S,Me as SAMP,Ne as SCRIPT,Re as SEARCH,Oe as SECTION,De as SELECT,Go as SEMANTICS,Zn as SET,ve as SLOT,Le as SMALL,Ie as SOURCE,Fe as SPAN,to as STOP,Ve as STRONG,je as STYLE,He as SUB,Ue as SUMMARY,Ge as SUP,eo as SVG,no as SWITCH,oo as SYMBOL,ke as TABLE,_e as TBODY,Be as TD,Ke as TEMPLATE,ao as TEXT,qe as TEXTAREA,so as TEXTPATH,we as TFOOT,Xe as TH,Ye as THEAD,We as TIME,$e as TITLE,Je as TR,Qe as TRACK,ro as TSPAN,ze as U,Ze as UL,co as USE,tn as VAR,en as VIDEO,io as VIEW,nn as WBR,w as app,Q as child,J as childCount,N as children,L as childrenStart,Yo as context,W as createPatch,Y as createState,V as defuse,P as globals,v as hydrate,X as memo,U as mergeClass,wo as mergeProps,G as mergeStyle,A as props,$ as tag,q as vode};
|
|
1
|
+
var R={currentViewTransition:void 0,requestAnimationFrame:typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:typeof document<"u"&&typeof document.startViewTransition=="function"?document.startViewTransition.bind(document):null};function $(e,n,...s){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:typeof n=="object"?[e,n,...s]:[e,...s]}function J(e,n,s,...a){if(!e?.parentElement)throw new Error("first argument to app() must be a valid HTMLElement inside the <html></html> document");if(!n||typeof n!="object")throw new Error("second argument to app() must be a state object");if(typeof s!="function")throw new Error("third argument to app() must be a function that returns a vode");let t={};t.syncRenderer=R.requestAnimationFrame,t.asyncRenderer=R.startViewTransition,t.qSync=null,t.qAsync=null,t.stats={lastSyncRenderTime:0,lastAsyncRenderTime:0,syncRenderCount:0,asyncRenderCount:0,liveEffectCount:0,patchCount:0,syncRenderPatchCount:0,asyncRenderPatchCount:0},t.unmounts=[];let o=n;"patch"in n&&typeof n.patch=="function"&&Array.isArray(n.patch.initialPatches)&&(a=[...n.patch.initialPatches,...a]),Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(c,x)=>{if(!(!c||typeof c!="function"&&typeof c!="object"))if(t.stats.patchCount++,c?.next){let h=c;t.stats.liveEffectCount++;try{let A=await h.next();for(;A.done===!1;){t.stats.liveEffectCount++;try{o.patch(A.value,x),A=await h.next()}finally{t.stats.liveEffectCount--}}o.patch(A.value,x)}finally{t.stats.liveEffectCount--}}else if(c.then){t.stats.liveEffectCount++;try{let h=await c;o.patch(h,x)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(c))if(c.length>0)for(let h of c)o.patch(h,!document.hidden&&!!t.asyncRenderer);else{t.qSync=P(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{R.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof c=="function"?o.patch(c(t.state),x):x?(t.stats.asyncRenderPatchCount++,t.qAsync=P(t.qAsync||{},c,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=P(t.qSync||{},c,!1),t.renderSync())}});function r(c){let x=Date.now(),h=s(t.state);t.vode=O(t.state,e.parentElement,0,0,t.vode,h,null,t.unmounts,0),e.tagName.toUpperCase()!==h[0].toUpperCase()&&(e=t.vode.node,e._vode=t),c||(t.stats.lastSyncRenderTime=Date.now()-x,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let l=r.bind(null,!1),i=r.bind(null,!0);Object.defineProperty(t,"renderSync",{enumerable:!1,configurable:!0,writable:!1,value:()=>{t.isRendering||!t.qSync||(t.isRendering=!0,t.state=P(t.state,t.qSync,!0),t.qSync=null,t.syncRenderer(l))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await R.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let c=Date.now();try{t.state=P(t.state,t.qAsync,!0),t.qAsync=null,R.currentViewTransition=t.asyncRenderer(i),await R.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-c,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=o;let p=e;p._vode=t;let f=Array.from(e.parentElement.children).indexOf(e);t.isRendering=!0,t.vode=O(n,e.parentElement,f,f,j(e,!0),s(n),null,t.unmounts,0),t.isRendering=!1,t.qSync&&t.renderSync();for(let c of a)o.patch(c);return c=>o.patch(c)}function _(e){if(e?._vode){let s=function(t){if(!t?.node)return;let o=N(t);if(o){for(let r in o)r[0]==="o"&&r[1]==="n"&&(t.node[r]=null);t.node.catch=null}if(t.node._vode)_(t.node);else{let r=L(t);if(r)for(let l of r)s(l)}};var n=s;let a=e._vode;delete e._vode,Object.defineProperty(a.state,"patch",{value:void 0}),Object.defineProperty(a,"renderSync",{value:()=>{}}),Object.defineProperty(a,"renderAsync",{value:()=>{}}),s(a.vode)}else for(let s of e.children)_(s)}function j(e,n){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?n?e:e.nodeValue:void 0;if(e.nodeType===Node.ELEMENT_NODE){let a=[e.tagName.toLowerCase()];if(n&&(a.node=e),e?.hasAttributes()){let t={},o=e.attributes;for(let r of o)t[r.name]=r.value;a.push(t)}if(e.hasChildNodes()){let t=[];for(let o of e.childNodes){let r=o&&j(o,n);r?a.push(r):o&&n&&t.push(o)}for(let o of t)o.remove()}return a}else return}function Q(e,n){if(!e||!Array.isArray(e))throw new Error("first argument to memo() must be an array of values to compare");if(typeof n!="function")throw new Error("second argument to memo() must be a function that returns a vode or props object");return n.__memo=e,n}function z(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return"patch"in e||Object.defineProperty(e,"patch",{enumerable:!1,configurable:!0,writable:!1,value:n=>{let s=e;Array.isArray(s.patch.initialPatches)||(s.patch.initialPatches=[]),s.patch.initialPatches.push(n)}}),e}function Z(e){return e}function tt(e){return e?Array.isArray(e)?e[0]:typeof e=="string"||e.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function N(e){if(Array.isArray(e)&&e.length>1&&e[1]&&!Array.isArray(e[1])&&typeof e[1]=="object"&&e[1].nodeType!==Node.TEXT_NODE)return e[1]}function L(e){let n=G(e);return n>0?e.slice(n):null}function et(e){let n=G(e);return n<0?0:e.length-n}function nt(e,n){let s=G(e);if(s>0)return e[n+s]}function G(e){return N(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function P(e,n,s){if(!n)return e;for(let a in n){let t=n[a];if(t&&typeof t=="object"){let o=e[a];o?Array.isArray(t)?e[a]=[...t]:t instanceof Date&&o!==t?e[a]=new Date(t):Array.isArray(o)?e[a]=P({},t,s):typeof o=="object"?P(e[a],t,s):e[a]=P({},t,s):Array.isArray(t)?e[a]=[...t]:t instanceof Date?e[a]=new Date(t):e[a]=P({},t,s)}else t===void 0&&s?delete e[a]:e[a]=t}return e}function O(e,n,s,a,t,o,r,l,i){try{o=V(e,o,t);let p=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&p)return t;let f=t?.nodeType===Node.TEXT_NODE,c=f?t:t?.node;if(p){if(!f&&typeof t?.unmountCount=="number"){let y=t.unmountStart,d=t.unmountCount;for(let S=d-1;S>=0;S--){let T=l[y+S];T&&(e.patch(T(e,c)),l[y+S]=null)}}c?.remove();return}let x=!p&&W(o),h=!p&&Y(o),A=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!x&&!h&&!A&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(A&&x?o=o.wholeText:A&&h&&(o=[...o]),f&&x)return c.nodeValue!==o&&(c.nodeValue=o),t;if(x&&(!c||!f)){let y=document.createTextNode(o);if(c){if(!f&&typeof t?.unmountCount=="number"){let d=t.unmountStart,S=t.unmountCount;for(let T=S-1;T>=0;T--){let C=l[d+T];C&&(e.patch(C(e,c)),l[d+T]=null)}}c.replaceWith(y)}else{let d=!1;for(let S=a;S<n.childNodes.length;S++){let T=n.childNodes[S];if(T){T.before(y,T),d=!0;break}}d||n.appendChild(y)}return y}if(h&&(!c||f||t[0]!==o[0])){let y=o;1 in y&&(y[1]=V(e,y[1],void 0));let d=N(o);d?.xmlns!==void 0&&(r=d.xmlns);let S=r?document.createElementNS(r,o[0]):document.createElement(o[0]);if(o.node=S,H(e,S,void 0,d,r??null),d&&"catch"in d&&(o.node.catch=null,o.node.removeAttribute("catch")),c){if(!f&&typeof t?.unmountCount=="number"){let b=t.unmountStart,g=t.unmountCount;for(let u=g-1;u>=0;u--){let m=l[b+u];m&&(e.patch(m(e,c)),l[b+u]=null)}}l[i]=d?.onUnmount??null,c.replaceWith(S)}else{l[i]=d?.onUnmount??null;let b=!1;for(let g=a;g<n.childNodes.length;g++){let u=n.childNodes[g];if(u){u.before(S,u),b=!0;break}}b||n.appendChild(S)}let T=0,C=i+1,M=L(o);if(M){let b=d?2:1,g=0;for(let u=0;u<M.length;u++){let m=M[u],E=O(e,S,u,g,void 0,m,r??null,l,C);if(o[u+b]=E,E){g++;let D=E.unmountCount||0;T+=D,C+=D}}}return S.onMount&&e.patch(S.onMount(S)),o.unmountCount=1+T,o.unmountStart=i,o}if(!f&&h&&t[0]===o[0]){o.node=c;let y=o,d=t,S=N(o),T=N(t);if(S?.xmlns!==void 0&&(r=S.xmlns),y[1]?.__memo){let u=y[1];y[1]=V(e,y[1],d[1]),u!==y[1]&&H(e,c,T,S,r)}else H(e,c,T,S,r);S?.catch&&T?.catch!==S.catch&&(o.node.catch=null,o.node.removeAttribute("catch")),l[i]=S?.onUnmount??null;let C=0,M=i+1,b=L(o),g=L(t);if(b){let u=S?2:1,m=0;for(let E=0;E<b.length;E++){let D=b[E],X=g&&g[E],F=O(e,c,E,m,X,D,r,l,M);if(o[E+u]=F,F){m++;let k=F.unmountCount||0;C+=k,M+=k}}}if(g){let u=b?b.length:0;for(let m=g.length-1;m>=u;m--)O(e,c,m,m,g[m],void 0,r,l,g[m].unmountStart)}return o.unmountCount=1+C,o.unmountStart=i,o}}catch(p){let f=N(o)?.catch;if(f){let c=typeof f=="function"?f(e,p):f;return O(e,n,s,a,j(o?.node||t?.node,!0),c,r,l,i)}else throw p}}function Y(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function W(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function V(e,n,s){if(typeof n!="function")return n;let a=n?.__memo,t=s?.__memo;if(Array.isArray(a)&&Array.isArray(t)&&a.length===t.length){let l=!0;for(let i=0;i<a.length;i++)if(a[i]!==t[i]){l=!1;break}if(l)return s}let o=n(e);if(typeof o=="function"&&o?.__memo){let l=o.__memo;if(Array.isArray(l)&&Array.isArray(t)&&l.length===t.length){let p=!0;for(let f=0;f<l.length;f++)if(l[f]!==t[f]){p=!1;break}if(p)return s}let i=o(e);return typeof i=="object"&&(i.__memo=l),i}let r=typeof o=="function"?B(o,e):o;return typeof r=="object"&&(r.__memo=o?.__memo||n?.__memo),r}function B(e,n){return typeof e=="function"?B(e(n),n):e}function H(e,n,s,a,t){if(!a&&!s)return;let o=t!==void 0;if(s)for(let r in s){let l=s[r],i=a?.[r];l!==i&&(a?a[r]=v(e,n,r,l,i,o):v(e,n,r,l,void 0,o))}if(a&&s){for(let r in a)if(!(r in s)){let l=a[r];a[r]=v(e,n,r,void 0,l,o)}}else if(a)for(let r in a){let l=a[r];a[r]=v(e,n,r,void 0,l,o)}}function v(e,n,s,a,t,o){if(s==="style")if(!t)n.style.cssText="";else if(typeof t=="string")a!==t&&(n.style.cssText=t);else if(a&&typeof a=="object"){for(let r in a)t[r]||(n.style[r]=null);for(let r in t){let l=a[r],i=t[r];l!==i&&(n.style[r]=i)}}else for(let r in t)n.style[r]=t[r];else if(s==="class")t?n.setAttribute("class",K(t)):n.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(t){let r=null;if(typeof t=="function"){let l=t;r=i=>e.patch(l(e,i))}else typeof t=="object"&&(r=()=>e.patch(t));n[s]=r}else n[s]=null;else o||(n[s]=t),t==null||t===!1?n.removeAttribute(s):n.setAttribute(s,t);return t}function K(e){return typeof e=="string"?e:Array.isArray(e)?e.map(K).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var at="a",st="abbr",rt="address",ct="area",it="article",lt="aside",pt="audio",ft="b",St="base",ut="bdi",dt="bdo",Tt="blockquote",yt="body",gt="br",xt="button",ht="canvas",mt="caption",bt="cite",Et="code",Pt="col",At="colgroup",Ct="data",Mt="datalist",Rt="dd",Nt="del",Ot="details",Dt="dfn",vt="dialog",Lt="div",It="dl",Ft="dt",Vt="em",Ht="embed",jt="fieldset",Gt="figcaption",Ut="figure",kt="footer",_t="form",Bt="h1",Kt="h2",qt="h3",wt="h4",Xt="h5",Yt="h6",Wt="head",$t="header",Jt="hgroup",Qt="hr",zt="html",Zt="i",te="iframe",ee="img",ne="input",oe="ins",ae="kbd",se="label",re="legend",ce="li",ie="link",le="main",pe="map",fe="mark",Se="menu",ue="meta",de="meter",Te="nav",ye="noscript",ge="object",xe="ol",he="optgroup",me="option",be="output",Ee="p",Pe="picture",Ae="pre",Ce="progress",Me="q",Re="rp",Ne="rt",Oe="ruby",De="s",ve="samp",Le="script",Ie="search",Fe="section",Ve="select",He="slot",je="small",Ge="source",Ue="span",ke="strong",_e="style",Be="sub",Ke="summary",qe="sup",we="table",Xe="tbody",Ye="td",We="template",$e="textarea",Je="tfoot",Qe="th",ze="thead",Ze="time",tn="title",en="tr",nn="track",on="u",an="ul",sn="var",rn="video",cn="wbr",ln="animate",pn="animateMotion",fn="animateTransform",Sn="circle",un="clipPath",dn="defs",Tn="desc",yn="ellipse",gn="feBlend",xn="feColorMatrix",hn="feComponentTransfer",mn="feComposite",bn="feConvolveMatrix",En="feDiffuseLighting",Pn="feDisplacementMap",An="feDistantLight",Cn="feDropShadow",Mn="feFlood",Rn="feFuncA",Nn="feFuncB",On="feFuncG",Dn="feFuncR",vn="feGaussianBlur",Ln="feImage",In="feMerge",Fn="feMergeNode",Vn="feMorphology",Hn="feOffset",jn="fePointLight",Gn="feSpecularLighting",Un="feSpotLight",kn="feTile",_n="feTurbulence",Bn="filter",Kn="foreignObject",qn="g",wn="image",Xn="line",Yn="linearGradient",Wn="marker",$n="mask",Jn="metadata",Qn="mpath",zn="path",Zn="pattern",to="polygon",eo="polyline",no="radialGradient",oo="rect",ao="set",so="stop",ro="svg",co="switch",io="symbol",lo="text",po="textPath",fo="tspan",So="use",uo="view",To="annotation",yo="annotation-xml",go="maction",xo="math",ho="merror",mo="mfrac",bo="mi",Eo="mmultiscripts",Po="mn",Ao="mo",Co="mover",Mo="mpadded",Ro="mphantom",No="mprescripts",Oo="mroot",Do="mrow",vo="ms",Lo="mspace",Io="msqrt",Fo="mstyle",Vo="msub",Ho="msubsup",jo="msup",Go="mtable",Uo="mtd",ko="mtext",_o="mtr",Bo="munder",Ko="munderover",qo="semantics";function q(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=e[0];for(let s=1;s<e.length;s++){let a=n,t=e[s];if(!a)n=t;else if(t)if(typeof a=="string"&&typeof t=="string"){let o=a.split(" "),r=t.split(" "),l=new Set([...o,...r]);n=Array.from(l).join(" ").trim()}else if(typeof a=="string"&&Array.isArray(t)){let o=new Set([...t,...a.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&typeof t=="string"){let o=new Set([...a,...t.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(a)&&Array.isArray(t)){let o=new Set([...a,...t]);n=Array.from(o).join(" ").trim()}else if(typeof a=="string"&&typeof t=="object")n={[a]:!0,...t};else if(typeof a=="object"&&typeof t=="string")n={...a,[t]:!0};else if(typeof a=="object"&&typeof t=="object")n={...a,...t};else if(typeof a=="object"&&Array.isArray(t)){let o={...a};for(let r of t)o[r]=!0;n=o}else if(Array.isArray(a)&&typeof t=="object"){let o={};for(let r of a)o[r]=!0;for(let r of Object.keys(t))o[r]=t[r];n=o}else throw new Error(`cannot merge classes of ${a} (${typeof a}) and ${t} (${typeof t})`);else continue}return n}var I;function w(...e){I||(I=document.createElement("div"));try{let n=I.style;for(let s of e)if(typeof s=="object"&&s!==null)for(let a in s)n[a]=s[a];else typeof s=="string"&&(n.cssText+=";"+s);return n.cssText}finally{I.style.cssText=""}}function Jo(...e){if(e.length===0)return;if(e.length===1)return e[0]||void 0;let n;for(let s of e)if(!(typeof s!="object"||s===null)){n||(n={});for(let a in s)a==="style"?n.style=w(n.style,s.style):a==="class"?n.class=q(n.class,s.class):n[a]=s[a]}return n}function zo(e){return new U(e,[])}var U=class e{constructor(n,s){this.state=n;this.keys=s;function a(i,p){if(s.length>1){let f=0,c=p[s[f]];for((typeof c!="object"||c===null)&&(p[s[f]]=c={}),f=1;f<s.length-1;f++){let x=c;c=c[s[f]],(typeof c!="object"||c===null)&&(x[s[f]]=c={})}c[s[f]]=i}else s.length===1?typeof p[s[0]]=="object"&&typeof i=="object"?Object.assign(p[s[0]],i):p[s[0]]=i:Object.assign(p,i)}function t(i){let p={};return a(i,p),p}function o(){if(s.length===0)return n;let i=n?n[s[0]]:void 0;for(let p=1;p<s.length&&i;p++)i=i[s[p]];return i}function r(i){a(i,n)}function l(i,p){p?n.patch([t(i)]):n.patch(t(i))}return new Proxy(this,{get:(i,p,f)=>{if(p==="state")return n;if(p==="get")return o;if(p==="put")return r;if(p==="patch")return l;let c=[...i.keys,String(p)];return new e(i.state,c)}})}state;keys;get(){}put(n){}patch(n){}};export{at as A,st as ABBR,rt as ADDRESS,ln as ANIMATE,pn as ANIMATEMOTION,fn as ANIMATETRANSFORM,To as ANNOTATION,yo as ANNOTATION_XML,ct as AREA,it as ARTICLE,lt as ASIDE,pt as AUDIO,ft as B,St as BASE,ut as BDI,dt as BDO,Tt as BLOCKQUOTE,yt as BODY,gt as BR,xt as BUTTON,ht as CANVAS,mt as CAPTION,Sn as CIRCLE,bt as CITE,un as CLIPPATH,Et as CODE,Pt as COL,At as COLGROUP,Ct as DATA,Mt as DATALIST,Rt as DD,dn as DEFS,Nt as DEL,Tn as DESC,Ot as DETAILS,Dt as DFN,vt as DIALOG,Lt as DIV,It as DL,Ft as DT,yn as ELLIPSE,Vt as EM,Ht as EMBED,gn as FEBLEND,xn as FECOLORMATRIX,hn as FECOMPONENTTRANSFER,mn as FECOMPOSITE,bn as FECONVOLVEMATRIX,En as FEDIFFUSELIGHTING,Pn as FEDISPLACEMENTMAP,An as FEDISTANTLIGHT,Cn as FEDROPSHADOW,Mn as FEFLOOD,Rn as FEFUNCA,Nn as FEFUNCB,On as FEFUNCG,Dn as FEFUNCR,vn as FEGAUSSIANBLUR,Ln as FEIMAGE,In as FEMERGE,Fn as FEMERGENODE,Vn as FEMORPHOLOGY,Hn as FEOFFSET,jn as FEPOINTLIGHT,Gn as FESPECULARLIGHTING,Un as FESPOTLIGHT,kn as FETILE,_n as FETURBULENCE,jt as FIELDSET,Gt as FIGCAPTION,Ut as FIGURE,Bn as FILTER,kt as FOOTER,Kn as FOREIGNOBJECT,_t as FORM,qn as G,Bt as H1,Kt as H2,qt as H3,wt as H4,Xt as H5,Yt as H6,Wt as HEAD,$t as HEADER,Jt as HGROUP,Qt as HR,zt as HTML,Zt as I,te as IFRAME,wn as IMAGE,ee as IMG,ne as INPUT,oe as INS,ae as KBD,se as LABEL,re as LEGEND,ce as LI,Xn as LINE,Yn as LINEARGRADIENT,ie as LINK,go as MACTION,le as MAIN,pe as MAP,fe as MARK,Wn as MARKER,$n as MASK,xo as MATH,Se as MENU,ho as MERROR,ue as META,Jn as METADATA,de as METER,mo as MFRAC,bo as MI,Eo as MMULTISCRIPTS,Po as MN,Ao as MO,Co as MOVER,Mo as MPADDED,Qn as MPATH,Ro as MPHANTOM,No as MPRESCRIPTS,Oo as MROOT,Do as MROW,vo as MS,Lo as MSPACE,Io as MSQRT,Fo as MSTYLE,Vo as MSUB,Ho as MSUBSUP,jo as MSUP,Go as MTABLE,Uo as MTD,ko as MTEXT,_o as MTR,Bo as MUNDER,Ko as MUNDEROVER,Te as NAV,ye as NOSCRIPT,ge as OBJECT,xe as OL,he as OPTGROUP,me as OPTION,be as OUTPUT,Ee as P,zn as PATH,Zn as PATTERN,Pe as PICTURE,to as POLYGON,eo as POLYLINE,Ae as PRE,Ce as PROGRESS,Me as Q,no as RADIALGRADIENT,oo as RECT,Re as RP,Ne as RT,Oe as RUBY,De as S,ve as SAMP,Le as SCRIPT,Ie as SEARCH,Fe as SECTION,Ve as SELECT,qo as SEMANTICS,ao as SET,He as SLOT,je as SMALL,Ge as SOURCE,Ue as SPAN,so as STOP,ke as STRONG,_e as STYLE,Be as SUB,Ke as SUMMARY,qe as SUP,ro as SVG,co as SWITCH,io as SYMBOL,we as TABLE,Xe as TBODY,Ye as TD,We as TEMPLATE,lo as TEXT,$e as TEXTAREA,po as TEXTPATH,Je as TFOOT,Qe as TH,ze as THEAD,Ze as TIME,tn as TITLE,en as TR,nn as TRACK,fo as TSPAN,on as U,an as UL,So as USE,sn as VAR,rn as VIDEO,uo as VIEW,cn as WBR,J as app,nt as child,et as childCount,L as children,G as childrenStart,zo as context,Z as createPatch,z as createState,_ as defuse,R as globals,j as hydrate,Q as memo,q as mergeClass,Jo as mergeProps,w as mergeStyle,N as props,tt as tag,$ as vode};
|
package/dist/vode.mjs
CHANGED
|
@@ -20,6 +20,7 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
20
20
|
_vode.qSync = null;
|
|
21
21
|
_vode.qAsync = null;
|
|
22
22
|
_vode.stats = { lastSyncRenderTime: 0, lastAsyncRenderTime: 0, syncRenderCount: 0, asyncRenderCount: 0, liveEffectCount: 0, patchCount: 0, syncRenderPatchCount: 0, asyncRenderPatchCount: 0 };
|
|
23
|
+
_vode.unmounts = [];
|
|
23
24
|
const patchableState = state;
|
|
24
25
|
if ("patch" in state && typeof state.patch === "function" && Array.isArray(state.patch.initialPatches)) {
|
|
25
26
|
initialPatches = [...state.patch.initialPatches, ...initialPatches];
|
|
@@ -90,7 +91,7 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
90
91
|
function renderDom(isAsync) {
|
|
91
92
|
const sw = Date.now();
|
|
92
93
|
const vom = dom(_vode.state);
|
|
93
|
-
_vode.vode = render(_vode.state, container.parentElement, 0, 0, _vode.vode, vom);
|
|
94
|
+
_vode.vode = render(_vode.state, container.parentElement, 0, 0, _vode.vode, vom, null, _vode.unmounts, 0);
|
|
94
95
|
if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
|
|
95
96
|
container = _vode.vode.node;
|
|
96
97
|
container._vode = _vode;
|
|
@@ -143,14 +144,20 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
143
144
|
const root = container;
|
|
144
145
|
root._vode = _vode;
|
|
145
146
|
const indexInParent = Array.from(container.parentElement.children).indexOf(container);
|
|
147
|
+
_vode.isRendering = true;
|
|
146
148
|
_vode.vode = render(
|
|
147
149
|
state,
|
|
148
150
|
container.parentElement,
|
|
149
151
|
indexInParent,
|
|
150
152
|
indexInParent,
|
|
151
153
|
hydrate(container, true),
|
|
152
|
-
dom(state)
|
|
154
|
+
dom(state),
|
|
155
|
+
null,
|
|
156
|
+
_vode.unmounts,
|
|
157
|
+
0
|
|
153
158
|
);
|
|
159
|
+
_vode.isRendering = false;
|
|
160
|
+
if (_vode.qSync) _vode.renderSync();
|
|
154
161
|
for (const effect of initialPatches) {
|
|
155
162
|
patchableState.patch(effect);
|
|
156
163
|
}
|
|
@@ -317,7 +324,7 @@ function mergeState(target, source, allowDeletion) {
|
|
|
317
324
|
}
|
|
318
325
|
return target;
|
|
319
326
|
}
|
|
320
|
-
function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmlns) {
|
|
327
|
+
function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmlns, unmounts, unmountStart) {
|
|
321
328
|
try {
|
|
322
329
|
newVode = remember(state, newVode, oldVode);
|
|
323
330
|
const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
|
|
@@ -327,7 +334,17 @@ function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmln
|
|
|
327
334
|
const oldIsText = oldVode?.nodeType === Node.TEXT_NODE;
|
|
328
335
|
const oldNode = oldIsText ? oldVode : oldVode?.node;
|
|
329
336
|
if (isNoVode) {
|
|
330
|
-
|
|
337
|
+
if (!oldIsText && typeof oldVode?.unmountCount === "number") {
|
|
338
|
+
const start = oldVode.unmountStart;
|
|
339
|
+
const count = oldVode.unmountCount;
|
|
340
|
+
for (let i = count - 1; i >= 0; i--) {
|
|
341
|
+
const fn = unmounts[start + i];
|
|
342
|
+
if (fn) {
|
|
343
|
+
state.patch(fn(state, oldNode));
|
|
344
|
+
unmounts[start + i] = null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
331
348
|
oldNode?.remove();
|
|
332
349
|
return void 0;
|
|
333
350
|
}
|
|
@@ -350,7 +367,17 @@ function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmln
|
|
|
350
367
|
if (isText && (!oldNode || !oldIsText)) {
|
|
351
368
|
const text = document.createTextNode(newVode);
|
|
352
369
|
if (oldNode) {
|
|
353
|
-
|
|
370
|
+
if (!oldIsText && typeof oldVode?.unmountCount === "number") {
|
|
371
|
+
const start = oldVode.unmountStart;
|
|
372
|
+
const count = oldVode.unmountCount;
|
|
373
|
+
for (let i = count - 1; i >= 0; i--) {
|
|
374
|
+
const fn = unmounts[start + i];
|
|
375
|
+
if (fn) {
|
|
376
|
+
state.patch(fn(state, oldNode));
|
|
377
|
+
unmounts[start + i] = null;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
354
381
|
oldNode.replaceWith(text);
|
|
355
382
|
} else {
|
|
356
383
|
let inserted = false;
|
|
@@ -383,9 +410,21 @@ function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmln
|
|
|
383
410
|
newVode.node.removeAttribute("catch");
|
|
384
411
|
}
|
|
385
412
|
if (oldNode) {
|
|
386
|
-
|
|
413
|
+
if (!oldIsText && typeof oldVode?.unmountCount === "number") {
|
|
414
|
+
const start = oldVode.unmountStart;
|
|
415
|
+
const count = oldVode.unmountCount;
|
|
416
|
+
for (let i = count - 1; i >= 0; i--) {
|
|
417
|
+
const fn = unmounts[start + i];
|
|
418
|
+
if (fn) {
|
|
419
|
+
state.patch(fn(state, oldNode));
|
|
420
|
+
unmounts[start + i] = null;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
unmounts[unmountStart] = properties?.onUnmount ?? null;
|
|
387
425
|
oldNode.replaceWith(newNode);
|
|
388
426
|
} else {
|
|
427
|
+
unmounts[unmountStart] = properties?.onUnmount ?? null;
|
|
389
428
|
let inserted = false;
|
|
390
429
|
for (let i = indexInParent; i < parent.childNodes.length; i++) {
|
|
391
430
|
const nextSibling = parent.childNodes[i];
|
|
@@ -399,18 +438,27 @@ function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmln
|
|
|
399
438
|
parent.appendChild(newNode);
|
|
400
439
|
}
|
|
401
440
|
}
|
|
441
|
+
let totalChildUnmounts = 0;
|
|
442
|
+
let childUnmountStart = unmountStart + 1;
|
|
402
443
|
const newKids = children(newVode);
|
|
403
444
|
if (newKids) {
|
|
404
445
|
const childOffset = !!properties ? 2 : 1;
|
|
405
446
|
let indexP = 0;
|
|
406
447
|
for (let i = 0; i < newKids.length; i++) {
|
|
407
448
|
const child2 = newKids[i];
|
|
408
|
-
const attached = render(state, newNode, i, indexP, void 0, child2, xmlns ?? null);
|
|
449
|
+
const attached = render(state, newNode, i, indexP, void 0, child2, xmlns ?? null, unmounts, childUnmountStart);
|
|
409
450
|
newVode[i + childOffset] = attached;
|
|
410
|
-
if (attached)
|
|
451
|
+
if (attached) {
|
|
452
|
+
indexP++;
|
|
453
|
+
const childUnmounts = attached.unmountCount || 0;
|
|
454
|
+
totalChildUnmounts += childUnmounts;
|
|
455
|
+
childUnmountStart += childUnmounts;
|
|
456
|
+
}
|
|
411
457
|
}
|
|
412
458
|
}
|
|
413
459
|
newNode.onMount && state.patch(newNode.onMount(newNode));
|
|
460
|
+
newVode.unmountCount = 1 + totalChildUnmounts;
|
|
461
|
+
newVode.unmountStart = unmountStart;
|
|
414
462
|
return newVode;
|
|
415
463
|
}
|
|
416
464
|
if (!oldIsText && isNode && oldVode[0] === newVode[0]) {
|
|
@@ -433,6 +481,9 @@ function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmln
|
|
|
433
481
|
newVode.node["catch"] = null;
|
|
434
482
|
newVode.node.removeAttribute("catch");
|
|
435
483
|
}
|
|
484
|
+
unmounts[unmountStart] = properties?.onUnmount ?? null;
|
|
485
|
+
let totalChildUnmounts = 0;
|
|
486
|
+
let childUnmountStart = unmountStart + 1;
|
|
436
487
|
const newKids = children(newVode);
|
|
437
488
|
const oldKids = children(oldVode);
|
|
438
489
|
if (newKids) {
|
|
@@ -441,17 +492,24 @@ function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmln
|
|
|
441
492
|
for (let i = 0; i < newKids.length; i++) {
|
|
442
493
|
const child2 = newKids[i];
|
|
443
494
|
const oldChild = oldKids && oldKids[i];
|
|
444
|
-
const attached = render(state, oldNode, i, indexP, oldChild, child2, xmlns);
|
|
495
|
+
const attached = render(state, oldNode, i, indexP, oldChild, child2, xmlns, unmounts, childUnmountStart);
|
|
445
496
|
newVode[i + childOffset] = attached;
|
|
446
|
-
if (attached)
|
|
497
|
+
if (attached) {
|
|
498
|
+
indexP++;
|
|
499
|
+
const childUnmounts = attached.unmountCount || 0;
|
|
500
|
+
totalChildUnmounts += childUnmounts;
|
|
501
|
+
childUnmountStart += childUnmounts;
|
|
502
|
+
}
|
|
447
503
|
}
|
|
448
504
|
}
|
|
449
505
|
if (oldKids) {
|
|
450
506
|
const newKidsCount = newKids ? newKids.length : 0;
|
|
451
507
|
for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
|
|
452
|
-
render(state, oldNode, i, i, oldKids[i], void 0, xmlns);
|
|
508
|
+
render(state, oldNode, i, i, oldKids[i], void 0, xmlns, unmounts, oldKids[i].unmountStart);
|
|
453
509
|
}
|
|
454
510
|
}
|
|
511
|
+
newVode.unmountCount = 1 + totalChildUnmounts;
|
|
512
|
+
newVode.unmountStart = unmountStart;
|
|
455
513
|
return newVode;
|
|
456
514
|
}
|
|
457
515
|
} catch (error) {
|
|
@@ -465,7 +523,9 @@ function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmln
|
|
|
465
523
|
indexInParent,
|
|
466
524
|
hydrate(newVode?.node || oldVode?.node, true),
|
|
467
525
|
handledVode,
|
|
468
|
-
xmlns
|
|
526
|
+
xmlns,
|
|
527
|
+
unmounts,
|
|
528
|
+
unmountStart
|
|
469
529
|
);
|
|
470
530
|
} else {
|
|
471
531
|
throw error;
|
package/package.json
CHANGED
package/src/vode.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type JustTagVode = [tag: Tag];
|
|
|
5
5
|
export type ChildVode<S = PatchableState> = Vode<S> | TextVode | NoVode | Component<S>;
|
|
6
6
|
export type TextVode = string & {};
|
|
7
7
|
export type NoVode = undefined | null | number | boolean | bigint | void;
|
|
8
|
-
export type AttachedVode<S> = Vode<S> & { node: ChildNode } | Text & { node?: never };
|
|
8
|
+
export type AttachedVode<S> = Vode<S> & { node: ChildNode, unmountCount: number, unmountStart: number } | Text & { node?: never, unmounts?: never, unmountStart?: never };
|
|
9
9
|
export type Tag = keyof (HTMLElementTagNameMap & SVGElementTagNameMap & MathMLElementTagNameMap) | (string & {});
|
|
10
10
|
export type Component<S> = (s: S) => ChildVode<S>;
|
|
11
11
|
|
|
@@ -97,6 +97,7 @@ export interface ContainerNode<S = PatchableState> extends HTMLElement {
|
|
|
97
97
|
qAsync: {} | undefined | null, // next render-patches to be animated after another
|
|
98
98
|
isRendering: boolean,
|
|
99
99
|
isAnimating: boolean,
|
|
100
|
+
unmounts: (MountFunction<S> | null)[],
|
|
100
101
|
/** stats about the overall patches & last render time */
|
|
101
102
|
stats: {
|
|
102
103
|
patchCount: number,
|
|
@@ -149,6 +150,7 @@ export function app<S extends PatchableState = PatchableState>(
|
|
|
149
150
|
_vode.qSync = null;
|
|
150
151
|
_vode.qAsync = null;
|
|
151
152
|
_vode.stats = { lastSyncRenderTime: 0, lastAsyncRenderTime: 0, syncRenderCount: 0, asyncRenderCount: 0, liveEffectCount: 0, patchCount: 0, syncRenderPatchCount: 0, asyncRenderPatchCount: 0 };
|
|
153
|
+
_vode.unmounts = [];
|
|
152
154
|
|
|
153
155
|
const patchableState = state as PatchableState<S> & { patch: (action: Patch<S>, animate?: boolean) => void };
|
|
154
156
|
|
|
@@ -219,7 +221,7 @@ export function app<S extends PatchableState = PatchableState>(
|
|
|
219
221
|
function renderDom(isAsync: boolean) {
|
|
220
222
|
const sw = Date.now();
|
|
221
223
|
const vom = dom(_vode.state);
|
|
222
|
-
_vode.vode = render<S>(_vode.state, container.parentElement as Element, 0, 0, _vode.vode, vom)!;
|
|
224
|
+
_vode.vode = render<S>(_vode.state, container.parentElement as Element, 0, 0, _vode.vode, vom, null, _vode.unmounts, 0)!;
|
|
223
225
|
|
|
224
226
|
if ((<ContainerNode<S>>container).tagName.toUpperCase() !== (vom[0] as Tag).toUpperCase()) { //the tag name was changed during render -> update reference to vode-app-root
|
|
225
227
|
container = _vode.vode.node as Element;
|
|
@@ -280,14 +282,20 @@ export function app<S extends PatchableState = PatchableState>(
|
|
|
280
282
|
const root = container as ContainerNode<S>;
|
|
281
283
|
root._vode = _vode;
|
|
282
284
|
const indexInParent = Array.from(container.parentElement.children).indexOf(container);
|
|
285
|
+
_vode.isRendering = true;
|
|
283
286
|
_vode.vode = render(
|
|
284
287
|
<S>state,
|
|
285
288
|
container.parentElement,
|
|
286
289
|
indexInParent,
|
|
287
290
|
indexInParent,
|
|
288
291
|
hydrate<S>(container, true) as AttachedVode<S>,
|
|
289
|
-
dom(<S>state)
|
|
292
|
+
dom(<S>state),
|
|
293
|
+
null,
|
|
294
|
+
_vode.unmounts,
|
|
295
|
+
0
|
|
290
296
|
)!;
|
|
297
|
+
_vode.isRendering = false;
|
|
298
|
+
if (_vode.qSync) _vode.renderSync();
|
|
291
299
|
|
|
292
300
|
for (const effect of initialPatches) {
|
|
293
301
|
patchableState.patch(effect);
|
|
@@ -503,14 +511,20 @@ function mergeState(target: any, source: any, allowDeletion: boolean) {
|
|
|
503
511
|
return target;
|
|
504
512
|
};
|
|
505
513
|
|
|
506
|
-
function render<S extends PatchableState>(
|
|
514
|
+
function render<S extends PatchableState>(
|
|
515
|
+
state: S, parent: Element,
|
|
516
|
+
childIndex: number, indexInParent: number,
|
|
517
|
+
oldVode: AttachedVode<S> | undefined, newVode: ChildVode<S>,
|
|
518
|
+
xmlns: string | null,
|
|
519
|
+
unmounts: (MountFunction<S> | null)[], unmountStart: number
|
|
520
|
+
): AttachedVode<S> | undefined {
|
|
507
521
|
try {
|
|
508
522
|
// unwrap component if it is memoized
|
|
509
523
|
newVode = remember(state, newVode, oldVode) as ChildVode<S>;
|
|
510
524
|
|
|
511
525
|
const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
|
|
512
526
|
if (newVode === oldVode || (!oldVode && isNoVode)) {
|
|
513
|
-
return oldVode
|
|
527
|
+
return oldVode as AttachedVode<S>;
|
|
514
528
|
}
|
|
515
529
|
|
|
516
530
|
const oldIsText = (oldVode as Text)?.nodeType === Node.TEXT_NODE;
|
|
@@ -518,7 +532,17 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
518
532
|
|
|
519
533
|
// falsy|text|element(A) -> undefined
|
|
520
534
|
if (isNoVode) {
|
|
521
|
-
(
|
|
535
|
+
if (!oldIsText && typeof (<any>oldVode)?.unmountCount === "number") {
|
|
536
|
+
const start = (<any>oldVode).unmountStart;
|
|
537
|
+
const count = (<any>oldVode).unmountCount;
|
|
538
|
+
for (let i = count - 1; i >= 0; i--) {
|
|
539
|
+
const fn = unmounts[start + i];
|
|
540
|
+
if (fn) {
|
|
541
|
+
state.patch(fn(state, oldNode as HTMLElement & SVGSVGElement & MathMLElement));
|
|
542
|
+
unmounts[start + i] = null;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
522
546
|
oldNode?.remove();
|
|
523
547
|
return undefined;
|
|
524
548
|
}
|
|
@@ -542,13 +566,23 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
542
566
|
if ((<Text>oldNode).nodeValue !== <string>newVode) {
|
|
543
567
|
(<Text>oldNode).nodeValue = <string>newVode;
|
|
544
568
|
}
|
|
545
|
-
return oldVode
|
|
569
|
+
return oldVode as AttachedVode<S>;
|
|
546
570
|
}
|
|
547
571
|
// falsy|element -> text
|
|
548
572
|
if (isText && (!oldNode || !oldIsText)) {
|
|
549
573
|
const text = document.createTextNode(newVode as string)
|
|
550
574
|
if (oldNode) {
|
|
551
|
-
(
|
|
575
|
+
if (!oldIsText && typeof (<any>oldVode)?.unmountCount === "number") {
|
|
576
|
+
const start = (<any>oldVode).unmountStart;
|
|
577
|
+
const count = (<any>oldVode).unmountCount;
|
|
578
|
+
for (let i = count - 1; i >= 0; i--) {
|
|
579
|
+
const fn = unmounts[start + i];
|
|
580
|
+
if (fn) {
|
|
581
|
+
state.patch(fn(state, oldNode as HTMLElement & SVGSVGElement & MathMLElement));
|
|
582
|
+
unmounts[start + i] = null;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
552
586
|
oldNode.replaceWith(text);
|
|
553
587
|
} else {
|
|
554
588
|
let inserted = false;
|
|
@@ -594,9 +628,21 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
594
628
|
}
|
|
595
629
|
|
|
596
630
|
if (oldNode) {
|
|
597
|
-
(
|
|
631
|
+
if (!oldIsText && typeof (<any>oldVode)?.unmountCount === "number") {
|
|
632
|
+
const start = (<any>oldVode).unmountStart;
|
|
633
|
+
const count = (<any>oldVode).unmountCount;
|
|
634
|
+
for (let i = count - 1; i >= 0; i--) {
|
|
635
|
+
const fn = unmounts[start + i];
|
|
636
|
+
if (fn) {
|
|
637
|
+
state.patch(fn(state, oldNode as HTMLElement & SVGSVGElement & MathMLElement));
|
|
638
|
+
unmounts[start + i] = null;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
unmounts[unmountStart] = properties?.onUnmount ?? null;
|
|
598
643
|
oldNode.replaceWith(newNode);
|
|
599
644
|
} else {
|
|
645
|
+
unmounts[unmountStart] = properties?.onUnmount ?? null;
|
|
600
646
|
let inserted = false;
|
|
601
647
|
for (let i = indexInParent; i < parent.childNodes.length; i++) {
|
|
602
648
|
const nextSibling = parent.childNodes[i];
|
|
@@ -611,20 +657,28 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
611
657
|
}
|
|
612
658
|
}
|
|
613
659
|
|
|
660
|
+
let totalChildUnmounts = 0;
|
|
661
|
+
let childUnmountStart = unmountStart + 1;
|
|
614
662
|
const newKids = children(newVode);
|
|
615
663
|
if (newKids) {
|
|
616
664
|
const childOffset = !!properties ? 2 : 1;
|
|
617
665
|
let indexP = 0;
|
|
618
666
|
for (let i = 0; i < newKids.length; i++) {
|
|
619
667
|
const child = newKids[i];
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
(
|
|
623
|
-
|
|
668
|
+
const attached = render(state, newNode as Element, i, indexP, undefined, child, xmlns ?? null, unmounts, childUnmountStart);
|
|
669
|
+
(<Vode<S>>newVode!)[i + childOffset] = <Vode<S> | undefined>attached;
|
|
670
|
+
if (attached) {
|
|
671
|
+
indexP++;
|
|
672
|
+
const childUnmounts = (<any>attached).unmountCount || 0;
|
|
673
|
+
totalChildUnmounts += childUnmounts;
|
|
674
|
+
childUnmountStart += childUnmounts;
|
|
675
|
+
}
|
|
624
676
|
}
|
|
625
677
|
}
|
|
626
678
|
|
|
627
679
|
(<any>newNode).onMount && state.patch((<any>newNode).onMount(newNode));
|
|
680
|
+
(<any>newVode).unmountCount = 1 + totalChildUnmounts;
|
|
681
|
+
(<any>newVode).unmountStart = unmountStart;
|
|
628
682
|
return <AttachedVode<S>>newVode;
|
|
629
683
|
}
|
|
630
684
|
|
|
@@ -656,6 +710,11 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
656
710
|
(<any>newVode).node.removeAttribute('catch');
|
|
657
711
|
}
|
|
658
712
|
|
|
713
|
+
// own unmount slot (always reserved per element)
|
|
714
|
+
unmounts[unmountStart] = properties?.onUnmount ?? null;
|
|
715
|
+
|
|
716
|
+
let totalChildUnmounts = 0;
|
|
717
|
+
let childUnmountStart = unmountStart + 1;
|
|
659
718
|
const newKids = children(newVode);
|
|
660
719
|
const oldKids = children(oldVode) as AttachedVode<S>[];
|
|
661
720
|
if (newKids) {
|
|
@@ -664,20 +723,26 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
664
723
|
for (let i = 0; i < newKids.length; i++) {
|
|
665
724
|
const child = newKids[i];
|
|
666
725
|
const oldChild = oldKids && oldKids[i];
|
|
667
|
-
|
|
668
|
-
const attached = render(state, oldNode as Element, i, indexP, oldChild, child, xmlns);
|
|
726
|
+
const attached = render(state, oldNode as Element, i, indexP, oldChild, child, xmlns, unmounts, childUnmountStart);
|
|
669
727
|
(<Vode<S>>newVode)[i + childOffset] = <Vode<S>>attached;
|
|
670
|
-
if (attached)
|
|
728
|
+
if (attached) {
|
|
729
|
+
indexP++;
|
|
730
|
+
const childUnmounts = (<any>attached).unmountCount || 0;
|
|
731
|
+
totalChildUnmounts += childUnmounts;
|
|
732
|
+
childUnmountStart += childUnmounts;
|
|
733
|
+
}
|
|
671
734
|
}
|
|
672
735
|
}
|
|
673
736
|
|
|
674
737
|
if (oldKids) {
|
|
675
738
|
const newKidsCount = newKids ? newKids.length : 0;
|
|
676
739
|
for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
|
|
677
|
-
render(state, oldNode as Element, i, i, oldKids[i], undefined, xmlns);
|
|
740
|
+
render(state, oldNode as Element, i, i, oldKids[i], undefined, xmlns, unmounts, (<any>oldKids[i]).unmountStart);
|
|
678
741
|
}
|
|
679
742
|
}
|
|
680
743
|
|
|
744
|
+
(<any>newVode).unmountCount = 1 + totalChildUnmounts;
|
|
745
|
+
(<any>newVode).unmountStart = unmountStart;
|
|
681
746
|
return <AttachedVode<S>>newVode;
|
|
682
747
|
}
|
|
683
748
|
} catch (error) {
|
|
@@ -690,7 +755,7 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
690
755
|
return render(state, parent, childIndex, indexInParent,
|
|
691
756
|
hydrate(((<AttachedVode<S>>newVode)?.node || oldVode?.node) as Element, true) as AttachedVode<S>,
|
|
692
757
|
handledVode,
|
|
693
|
-
xmlns);
|
|
758
|
+
xmlns, unmounts, unmountStart);
|
|
694
759
|
} else {
|
|
695
760
|
throw error;
|
|
696
761
|
}
|