@ryupold/vode 0.13.1 → 1.0.0

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.
@@ -0,0 +1 @@
1
+ "use strict";var V=(()=>{var N=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var n in o)N(t,n,{get:o[n],enumerable:!0})},H=(t,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of G(o))!V.call(t,e)&&e!==n&&N(t,e,{get:()=>o[e],enumerable:!(r=v(o,e))||r.enumerable});return t};var U=t=>H(N({},"__esModule",{value:!0}),t);var kn={};k(kn,{A:()=>z,ABBR:()=>Z,ADDRESS:()=>w,ANIMATE:()=>we,ANIMATEMOTION:()=>to,ANIMATETRANSFORM:()=>eo,ANNOTATION:()=>sn,ANNOTATION_XML:()=>an,AREA:()=>tt,ARTICLE:()=>et,ASIDE:()=>ot,AUDIO:()=>nt,B:()=>rt,BASE:()=>st,BDI:()=>at,BDO:()=>ct,BLOCKQUOTE:()=>it,BODY:()=>pt,BR:()=>Tt,BUTTON:()=>ft,CANVAS:()=>lt,CAPTION:()=>St,CIRCLE:()=>oo,CITE:()=>dt,CLIPPATH:()=>no,CODE:()=>gt,COL:()=>xt,COLGROUP:()=>ut,DATA:()=>yt,DATALIST:()=>Et,DD:()=>mt,DEFS:()=>ro,DEL:()=>ht,DESC:()=>so,DETAILS:()=>At,DFN:()=>Pt,DIALOG:()=>Ct,DIV:()=>Mt,DL:()=>Nt,DT:()=>Ot,ELLIPSE:()=>ao,EM:()=>Rt,EMBED:()=>Lt,FEBLEND:()=>co,FECOLORMATRIX:()=>io,FECOMPONENTTRANSFER:()=>po,FECOMPOSITE:()=>To,FECONVOLVEMATRIX:()=>fo,FEDIFFUSELIGHTING:()=>lo,FEDISPLACEMENTMAP:()=>So,FEDISTANTLIGHT:()=>go,FEDROPSHADOW:()=>xo,FEFLOOD:()=>uo,FEFUNCA:()=>yo,FEFUNCB:()=>Eo,FEFUNCG:()=>mo,FEFUNCR:()=>ho,FEGAUSSIANBLUR:()=>Ao,FEIMAGE:()=>Po,FEMERGE:()=>Co,FEMERGENODE:()=>Mo,FEMORPHOLOGY:()=>No,FEOFFSET:()=>Oo,FEPOINTLIGHT:()=>Ro,FESPECULARLIGHTING:()=>Lo,FESPOTLIGHT:()=>Do,FETILE:()=>bo,FETURBULENCE:()=>Io,FIELDSET:()=>Dt,FIGCAPTION:()=>bt,FIGURE:()=>It,FILTER:()=>Fo,FOOTER:()=>Ft,FOREIGNOBJECT:()=>vo,FORM:()=>vt,G:()=>Go,H1:()=>Gt,H2:()=>Vt,H3:()=>kt,H4:()=>Ht,H5:()=>Ut,H6:()=>jt,HEAD:()=>Bt,HEADER:()=>_t,HGROUP:()=>Kt,HR:()=>Xt,HTML:()=>qt,I:()=>Yt,IFRAME:()=>Wt,IMAGE:()=>Vo,IMG:()=>$t,INPUT:()=>Jt,INS:()=>Qt,KBD:()=>zt,LABEL:()=>Zt,LEGEND:()=>wt,LI:()=>te,LINE:()=>ko,LINEARGRADIENT:()=>Ho,LINK:()=>ee,MACTION:()=>cn,MAIN:()=>oe,MAP:()=>ne,MARK:()=>re,MARKER:()=>Uo,MASK:()=>jo,MATH:()=>pn,MENU:()=>se,MERROR:()=>Tn,META:()=>ae,METADATA:()=>Bo,METER:()=>ce,MFRAC:()=>fn,MI:()=>ln,MMULTISCRIPTS:()=>Sn,MN:()=>dn,MO:()=>gn,MOVER:()=>xn,MPADDED:()=>un,MPATH:()=>_o,MPHANTOM:()=>yn,MPRESCRIPTS:()=>En,MROOT:()=>mn,MROW:()=>hn,MS:()=>An,MSPACE:()=>Pn,MSQRT:()=>Cn,MSTYLE:()=>Mn,MSUB:()=>Nn,MSUBSUP:()=>On,MSUP:()=>Rn,MTABLE:()=>Ln,MTD:()=>Dn,MTEXT:()=>bn,MTR:()=>In,MUNDER:()=>Fn,MUNDEROVER:()=>vn,NAV:()=>ie,NOSCRIPT:()=>pe,OBJECT:()=>Te,OL:()=>fe,OPTGROUP:()=>le,OPTION:()=>Se,OUTPUT:()=>de,P:()=>ge,PATH:()=>Ko,PATTERN:()=>Xo,PICTURE:()=>xe,POLYGON:()=>qo,POLYLINE:()=>Yo,PRE:()=>ue,PROGRESS:()=>ye,Q:()=>Ee,RADIALGRADIENT:()=>Wo,RECT:()=>$o,RP:()=>me,RT:()=>he,RUBY:()=>Ae,S:()=>Pe,SAMP:()=>Ce,SCRIPT:()=>Me,SECTION:()=>Ne,SELECT:()=>Oe,SEMANTICS:()=>Gn,SET:()=>Jo,SLOT:()=>Re,SMALL:()=>Le,SOURCE:()=>De,SPAN:()=>be,STOP:()=>Qo,STRONG:()=>Ie,STYLE:()=>Fe,SUB:()=>ve,SUMMARY:()=>Ge,SUP:()=>Ve,SVG:()=>zo,SWITCH:()=>Zo,SYMBOL:()=>wo,TABLE:()=>ke,TBODY:()=>He,TD:()=>Ue,TEMPLATE:()=>je,TEXT:()=>tn,TEXTAREA:()=>Be,TEXTPATH:()=>en,TFOOT:()=>_e,TH:()=>Ke,THEAD:()=>Xe,TIME:()=>qe,TITLE:()=>Ye,TR:()=>We,TRACK:()=>$e,TSPAN:()=>on,U:()=>Je,UL:()=>Qe,USE:()=>nn,VIDEO:()=>ze,VIEW:()=>rn,WBR:()=>Ze,app:()=>K,child:()=>$,childCount:()=>W,children:()=>A,childrenStart:()=>C,createPatch:()=>B,createState:()=>j,htmlToVode:()=>Vn,memo:()=>X,mergeClass:()=>Y,props:()=>d,tag:()=>q,vode:()=>_});function j(t){return t}function B(t){return t}function _(t,o,...n){if(!t)throw new Error("tag must be a string or vode");return Array.isArray(t)?t:o?[t,o,...n]:[t,...n]}function K(t,o,n,...r){if(!t)throw new Error("container must be a valid HTMLElement");if(!o||typeof o!="object")throw new Error("initialState must be an object");if(typeof n!="function")throw new Error("dom must be a function that returns a vode");let e={};e.stats={lastRenderTime:0,renderCount:0,liveEffectCount:0,patchCount:0,renderPatchCount:0},Object.defineProperty(o,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async c=>{if(!(!c||typeof c!="function"&&typeof c!="object"))if(e.stats.patchCount++,c?.next){let l=c;e.stats.liveEffectCount++;try{let i=await l.next();for(;i.done===!1;){e.stats.liveEffectCount++;try{e.patch(i.value),i=await l.next()}finally{e.stats.liveEffectCount--}}e.patch(i.value)}finally{e.stats.liveEffectCount--}}else if(c.then){e.stats.liveEffectCount++;try{let l=await c;e.patch(l)}finally{e.stats.liveEffectCount--}}else Array.isArray(c)?typeof c[0]=="function"?c.length>1?e.patch(c[0](e.state,...c.slice(1))):e.patch(c[0](e.state)):e.stats.patchCount--:typeof c=="function"?e.patch(c(e.state)):(e.stats.renderPatchCount++,e.q=u(e.q||{},c),e.isRendering||e.render())}}),Object.defineProperty(e,"render",{enumerable:!1,configurable:!0,writable:!1,value:()=>requestAnimationFrame(()=>{if(e.isRendering||!e.q)return;e.isRendering=!0;let c=Date.now();try{e.state=u(e.state,e.q),e.q=null,e.vode=P(e.state,e.patch,t,0,e.vode,n(e.state))}finally{e.isRendering=!1,e.stats.renderCount++,e.stats.lastRenderTime=Date.now()-c,e.q&&e.render()}})}),e.patch=o.patch,e.state=o,e.q=null;let s=t;s._vode=e;let a=n(o);e.vode=a,e.vode=P(o,e.patch,t,0,void 0,a);for(let c of r)e.patch(c);return e.patch}function X(t,o){return o.__memo=t,o}function q(t){return t?Array.isArray(t)?t[0]:typeof t=="string"||t.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function d(t){if(Array.isArray(t)&&t.length>1&&t[1]&&!Array.isArray(t[1])&&typeof t[1]=="object"&&t[1].nodeType!==Node.TEXT_NODE)return t[1]}function Y(t,o){if(!t)return o;if(!o)return t;if(typeof t=="string"&&typeof o=="string"){let n=t.split(" "),r=o.split(" "),e=new Set([...n,...r]);return Array.from(e).join(" ").trim()}else if(typeof t=="string"&&Array.isArray(o)){let n=new Set([...o,...t.split(" ")]);return Array.from(n).join(" ").trim()}else if(Array.isArray(t)&&typeof o=="string"){let n=new Set([...t,...o.split(" ")]);return Array.from(n).join(" ").trim()}else if(Array.isArray(t)&&Array.isArray(o)){let n=new Set([...t,...o]);return Array.from(n).join(" ").trim()}else{if(typeof t=="string"&&typeof o=="object")return{[t]:!0,...o};if(typeof t=="object"&&typeof o=="string")return{...t,[o]:!0};if(typeof t=="object"&&typeof o=="object")return{...t,...o};if(typeof t=="object"&&Array.isArray(o)){let n={...t};for(let r of o)n[r]=!0;return n}else if(Array.isArray(t)&&typeof o=="object"){let n={};for(let r of t)n[r]=!0;for(let r of Object.keys(o))n[r]=o[r];return n}}throw new Error(`cannot merge classes of ${t} (${typeof t}) and ${o} (${typeof o})`)}function A(t){let o=C(t);return o>0?t.slice(o):null}function W(t){return t.length-C(t)}function $(t,o){return t[o+C(t)]}function C(t){return d(t)?2:1}function u(t,o){if(!o)return t;for(let n in o){let r=o[n];if(r&&typeof r=="object"){let e=t[n];e?Array.isArray(r)?t[n]=[...r]:r instanceof Date&&e!==r?t[n]=new Date(r):Array.isArray(e)?t[n]=u({},r):typeof e=="object"?u(t[n],r):t[n]=u({},r):Array.isArray(r)?t[n]=[...r]:r instanceof Date?t[n]=new Date(r):t[n]=u({},r)}else r===void 0?delete t[n]:t[n]=r}return t}function P(t,o,n,r,e,s,a){s=O(t,s,e);let c=!s||typeof s=="number"||typeof s=="boolean";if(s===e||!e&&c)return e;let l=e?.nodeType===Node.TEXT_NODE,i=l?e:e?.node;if(c){i?.onUnmount&&o(i.onUnmount(i)),i?.remove();return}let E=!c&&Q(s),m=!c&&J(s),M=!!s&&typeof s!="string"&&!!(s?.node||s?.nodeType===Node.TEXT_NODE);if(!E&&!m&&!M&&!e)throw new Error("Invalid vode: "+typeof s+" "+JSON.stringify(s));if(M&&E?s=s.wholeText:M&&m&&(s=[...s]),l&&E)return i.nodeValue!==s&&(i.nodeValue=s),e;if(E&&(!i||!l)){let T=document.createTextNode(s);return i?(i.onUnmount&&o(i.onUnmount(i)),i.replaceWith(T)):n.childNodes[r]?n.insertBefore(T,n.childNodes[r]):n.appendChild(T),T}if(m&&(!i||l||e[0]!==s[0])){a=a||s[0]==="svg";let T=a?document.createElementNS("http://www.w3.org/2000/svg",s[0]):document.createElement(s[0]);s.node=T;let y=s;1 in y&&(y[1]=O(t,y[1],void 0));let g=d(s);R(o,T,void 0,g,a),i?(i.onUnmount&&o(i.onUnmount(i)),i.replaceWith(T)):n.childNodes[r]?n.insertBefore(T,n.childNodes[r]):n.appendChild(T);let S=A(s);if(S)for(let f=0;f<S.length;f++){let p=S[f],x=P(t,o,T,f,void 0,p,a);s[g?f+2:f+1]=x}return T.onMount&&o(T.onMount(T)),s}if(!l&&m&&e[0]===s[0]){a=a||s[0]==="svg",s.node=i;let T=s,y=e,g=!1;if(T[1]?.__memo){let p=T[1];if(T[1]=O(t,T[1],y[1]),p!==T[1]){let x=d(s);R(o,i,d(e),x,a),g=!!x}}else{let p=d(s);R(o,i,d(e),p,a),g=!!p}let S=A(s),f=A(e);if(S){for(let p=0;p<S.length;p++){let x=S[p],F=f&&f[p],D=P(t,o,i,p,F,x,a);D&&(s[g?p+2:p+1]=D)}for(let p=S.length;f&&p<f.length;p++)f[p]?.node?f[p].node.remove():f[p]?.nodeType===Node.TEXT_NODE&&f[p].remove()}for(let p=S?.length||0;p<f?.length;p++)f[p]?.node?f[p].node.remove():f[p]?.nodeType===Node.TEXT_NODE&&f[p].remove();return s}}function J(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"}function Q(t){return typeof t=="string"||t?.nodeType===Node.TEXT_NODE}function O(t,o,n){if(typeof o!="function")return o;let r=o?.__memo,e=n?.__memo;if(Array.isArray(r)&&Array.isArray(e)&&r.length===e.length){let a=!0;for(let c=0;c<r.length;c++)if(r[c]!==e[c]){a=!1;break}if(a)return n}let s=b(o,t);return typeof s=="object"&&(s.__memo=o?.__memo),s}function b(t,o){return typeof t=="function"?b(t(o),o):t}function R(t,o,n,r,e){if(!(!r&&!n)){if(n)for(let s in n){let a=n[s],c=r?.[s];a!==c&&(r?r[s]=h(t,o,s,a,c,e):h(t,o,s,a,void 0,e))}if(r&&n){for(let s in r)if(!(s in n)){let a=r[s];r[s]=h(t,o,s,void 0,a,e)}}else if(r)for(let s in r){let a=r[s];r[s]=h(t,o,s,void 0,a,e)}}}function h(t,o,n,r,e,s){if(n==="style")if(!e)o.style.cssText="";else if(r)for(let a in{...r,...e})!r||e[a]!==r[a]?o.style[a]=e[a]:r[a]&&!e[a]&&(o.style[a]=void 0);else for(let a in e)o.style[a]=e[a];else if(n==="class")if(s)if(e){let a=L(e);o.classList.value=a}else o.classList.value="";else if(e){let a=L(e);o.className=a}else o.className="";else if(n[0]==="o"&&n[1]==="n")if(e){let a=null;if(typeof e=="function"){let c=e;a=l=>t([c,l])}else if(Array.isArray(e)){let c=e,l=e[0];c.length>1?a=()=>t([l,...c.slice(1)]):a=i=>t([l,i])}else typeof e=="object"&&(a=()=>t(e));o[n]=a}else o[n]=null;else e!=null&&e!==!1?o.setAttribute(n,e):o.removeAttribute(n);return e}function L(t){return typeof t=="string"?t:Array.isArray(t)?t.map(L).join(" "):typeof t=="object"?Object.keys(t).filter(o=>t[o]).join(" "):""}var z="a",Z="abbr",w="address",tt="area",et="article",ot="aside",nt="audio",rt="b",st="base",at="bdi",ct="bdo",it="blockquote",pt="body",Tt="br",ft="button",lt="canvas",St="caption",dt="cite",gt="code",xt="col",ut="colgroup",yt="data",Et="datalist",mt="dd",ht="del",At="details",Pt="dfn",Ct="dialog",Mt="div",Nt="dl",Ot="dt",Rt="em",Lt="embed",Dt="fieldset",bt="figcaption",It="figure",Ft="footer",vt="form",Gt="h1",Vt="h2",kt="h3",Ht="h4",Ut="h5",jt="h6",Bt="head",_t="header",Kt="hgroup",Xt="hr",qt="html",Yt="i",Wt="iframe",$t="img",Jt="input",Qt="ins",zt="kbd",Zt="label",wt="legend",te="li",ee="link",oe="main",ne="map",re="mark",se="menu",ae="meta",ce="meter",ie="nav",pe="noscript",Te="object",fe="ol",le="optgroup",Se="option",de="output",ge="p",xe="picture",ue="pre",ye="progress",Ee="q",me="rp",he="rt",Ae="ruby",Pe="s",Ce="samp",Me="script",Ne="section",Oe="select",Re="slot",Le="small",De="source",be="span",Ie="strong",Fe="style",ve="sub",Ge="summary",Ve="sup",ke="table",He="tbody",Ue="td",je="template",Be="textarea",_e="tfoot",Ke="th",Xe="thead",qe="time",Ye="title",We="tr",$e="track",Je="u",Qe="ul",ze="video",Ze="wbr",we="animate",to="animateMotion",eo="animateTransform",oo="circle",no="clipPath",ro="defs",so="desc",ao="ellipse",co="feBlend",io="feColorMatrix",po="feComponentTransfer",To="feComposite",fo="feConvolveMatrix",lo="feDiffuseLighting",So="feDisplacementMap",go="feDistantLight",xo="feDropShadow",uo="feFlood",yo="feFuncA",Eo="feFuncB",mo="feFuncG",ho="feFuncR",Ao="feGaussianBlur",Po="feImage",Co="feMerge",Mo="feMergeNode",No="feMorphology",Oo="feOffset",Ro="fePointLight",Lo="feSpecularLighting",Do="feSpotLight",bo="feTile",Io="feTurbulence",Fo="filter",vo="foreignObject",Go="g",Vo="image",ko="line",Ho="linearGradient",Uo="marker",jo="mask",Bo="metadata",_o="mpath",Ko="path",Xo="pattern",qo="polygon",Yo="polyline",Wo="radialGradient",$o="rect",Jo="set",Qo="stop",zo="svg",Zo="switch",wo="symbol",tn="text",en="textPath",on="tspan",nn="use",rn="view",sn="annotation",an="annotation-xml",cn="maction",pn="math",Tn="merror",fn="mfrac",ln="mi",Sn="mmultiscripts",dn="mn",gn="mo",xn="mover",un="mpadded",yn="mphantom",En="mprescripts",mn="mroot",hn="mrow",An="ms",Pn="mspace",Cn="msqrt",Mn="mstyle",Nn="msub",On="msubsup",Rn="msup",Ln="mtable",Dn="mtd",bn="mtext",In="mtr",Fn="munder",vn="munderover",Gn="semantics";function Vn(t){let o=document.createElement("div");o.innerHTML=t.trim();let n=[];for(let r of o.childNodes){let e=I(r);e!=null&&n.push(e)}return n}function I(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent;if(t.nodeType!==Node.ELEMENT_NODE)return;let o=[t.tagName.toLowerCase()];if(t.hasAttributes()){let n={};for(let r of t.attributes)n[r.name]=r.value;o.push(n)}for(let n of t.childNodes){let r=I(n);r&&(typeof r!="string"||r.length>0)&&o.push(r)}return o}return U(kn);})();
@@ -0,0 +1 @@
1
+ function P(f){return f}function h(f){return f}function g(f,D,...L){if(!f)throw new Error("tag must be a string or vode");if(Array.isArray(f))return f;else if(D)return[f,D,...L];else return[f,...L]}function u(f,D,L,...X){if(!f)throw new Error("container must be a valid HTMLElement");if(!D||typeof D!=="object")throw new Error("initialState must be an object");if(typeof L!=="function")throw new Error("dom must be a function that returns a vode");let E={};E.stats={lastRenderTime:0,renderCount:0,liveEffectCount:0,patchCount:0,renderPatchCount:0},Object.defineProperty(D,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(z)=>{if(!z||typeof z!=="function"&&typeof z!=="object")return;if(E.stats.patchCount++,z?.next){let Q=z;E.stats.liveEffectCount++;try{let B=await Q.next();while(B.done===!1){E.stats.liveEffectCount++;try{E.patch(B.value),B=await Q.next()}finally{E.stats.liveEffectCount--}}E.patch(B.value)}finally{E.stats.liveEffectCount--}}else if(z.then){E.stats.liveEffectCount++;try{let Q=await z;E.patch(Q)}finally{E.stats.liveEffectCount--}}else if(Array.isArray(z))if(typeof z[0]==="function")if(z.length>1)E.patch(z[0](E.state,...z.slice(1)));else E.patch(z[0](E.state));else E.stats.patchCount--;else if(typeof z==="function")E.patch(z(E.state));else if(E.stats.renderPatchCount++,E.q=$(E.q||{},z),!E.isRendering)E.render()}}),Object.defineProperty(E,"render",{enumerable:!1,configurable:!0,writable:!1,value:()=>requestAnimationFrame(()=>{if(E.isRendering||!E.q)return;E.isRendering=!0;let z=Date.now();try{E.state=$(E.state,E.q),E.q=null,E.vode=C(E.state,E.patch,f,0,E.vode,L(E.state))}finally{if(E.isRendering=!1,E.stats.renderCount++,E.stats.lastRenderTime=Date.now()-z,E.q)E.render()}})}),E.patch=D.patch,E.state=D,E.q=null;let j=f;j._vode=E;let q=L(D);E.vode=q,E.vode=C(D,E.patch,f,0,void 0,q);for(let z of X)E.patch(z);return E.patch}function c(f,D){return D.__memo=f,D}function v(f){return f?Array.isArray(f)?f[0]:typeof f==="string"||f.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function Z(f){if(Array.isArray(f)&&f.length>1&&f[1]&&!Array.isArray(f[1])){if(typeof f[1]==="object"&&f[1].nodeType!==Node.TEXT_NODE)return f[1]}return}function p(f,D){if(!f)return D;if(!D)return f;if(typeof f==="string"&&typeof D==="string"){let L=f.split(" "),X=D.split(" "),E=new Set([...L,...X]);return Array.from(E).join(" ").trim()}else if(typeof f==="string"&&Array.isArray(D)){let L=new Set([...D,...f.split(" ")]);return Array.from(L).join(" ").trim()}else if(Array.isArray(f)&&typeof D==="string"){let L=new Set([...f,...D.split(" ")]);return Array.from(L).join(" ").trim()}else if(Array.isArray(f)&&Array.isArray(D)){let L=new Set([...f,...D]);return Array.from(L).join(" ").trim()}else if(typeof f==="string"&&typeof D==="object")return{[f]:!0,...D};else if(typeof f==="object"&&typeof D==="string")return{...f,[D]:!0};else if(typeof f==="object"&&typeof D==="object")return{...f,...D};else if(typeof f==="object"&&Array.isArray(D)){let L={...f};for(let X of D)L[X]=!0;return L}else if(Array.isArray(f)&&typeof D==="object"){let L={};for(let X of f)L[X]=!0;for(let X of Object.keys(D))L[X]=D[X];return L}throw new Error(`cannot merge classes of ${f} (${typeof f}) and ${D} (${typeof D})`)}function M(f){let D=x(f);if(D>0)return f.slice(D);return null}function V(f){return f.length-x(f)}function i(f,D){return f[D+x(f)]}function x(f){return Z(f)?2:1}function $(f,D){if(!D)return f;for(let L in D){let X=D[L];if(X&&typeof X==="object"){let E=f[L];if(E)if(Array.isArray(X))f[L]=[...X];else if(X instanceof Date&&E!==X)f[L]=new Date(X);else if(Array.isArray(E))f[L]=$({},X);else if(typeof E==="object")$(f[L],X);else f[L]=$({},X);else if(Array.isArray(X))f[L]=[...X];else if(X instanceof Date)f[L]=new Date(X);else f[L]=$({},X)}else if(X===void 0)delete f[L];else f[L]=X}return f}function C(f,D,L,X,E,j,q){j=I(f,j,E);let z=!j||typeof j==="number"||typeof j==="boolean";if(j===E||!E&&z)return E;let Q=E?.nodeType===Node.TEXT_NODE,B=Q?E:E?.node;if(z){B?.onUnmount&&D(B.onUnmount(B)),B?.remove();return}let O=!z&&k(j),T=!z&&b(j),H=!!j&&typeof j!=="string"&&!!(j?.node||j?.nodeType===Node.TEXT_NODE);if(!O&&!T&&!H&&!E)throw new Error("Invalid vode: "+typeof j+" "+JSON.stringify(j));else if(H&&O)j=j.wholeText;else if(H&&T)j=[...j];if(Q&&O){if(B.nodeValue!==j)B.nodeValue=j;return E}if(O&&(!B||!Q)){let G=document.createTextNode(j);if(B)B.onUnmount&&D(B.onUnmount(B)),B.replaceWith(G);else if(L.childNodes[X])L.insertBefore(G,L.childNodes[X]);else L.appendChild(G);return G}if(T&&(!B||Q||E[0]!==j[0])){q=q||j[0]==="svg";let G=q?document.createElementNS("http://www.w3.org/2000/svg",j[0]):document.createElement(j[0]);j.node=G;let A=j;if(1 in A)A[1]=I(f,A[1],void 0);let W=Z(j);if(K(D,G,void 0,W,q),B)B.onUnmount&&D(B.onUnmount(B)),B.replaceWith(G);else if(L.childNodes[X])L.insertBefore(G,L.childNodes[X]);else L.appendChild(G);let U=M(j);if(U)for(let J=0;J<U.length;J++){let F=U[J],Y=C(f,D,G,J,void 0,F,q);j[W?J+2:J+1]=Y}return G.onMount&&D(G.onMount(G)),j}if(!Q&&T&&E[0]===j[0]){q=q||j[0]==="svg",j.node=B;let G=j,A=E,W=!1;if(G[1]?.__memo){let F=G[1];if(G[1]=I(f,G[1],A[1]),F!==G[1]){let Y=Z(j);K(D,B,Z(E),Y,q),W=!!Y}}else{let F=Z(j);K(D,B,Z(E),F,q),W=!!F}let U=M(j),J=M(E);if(U){for(let F=0;F<U.length;F++){let Y=U[F],_=J&&J[F],N=C(f,D,B,F,_,Y,q);if(N)j[W?F+2:F+1]=N}for(let F=U.length;J&&F<J.length;F++)if(J[F]?.node)J[F].node.remove();else if(J[F]?.nodeType===Node.TEXT_NODE)J[F].remove()}for(let F=U?.length||0;F<J?.length;F++)if(J[F]?.node)J[F].node.remove();else if(J[F]?.nodeType===Node.TEXT_NODE)J[F].remove();return j}return}function b(f){return Array.isArray(f)&&f.length>0&&typeof f[0]==="string"}function k(f){return typeof f==="string"||f?.nodeType===Node.TEXT_NODE}function I(f,D,L){if(typeof D!=="function")return D;let X=D?.__memo,E=L?.__memo;if(Array.isArray(X)&&Array.isArray(E)&&X.length===E.length){let q=!0;for(let z=0;z<X.length;z++)if(X[z]!==E[z]){q=!1;break}if(q)return L}let j=S(D,f);if(typeof j==="object")j.__memo=D?.__memo;return j}function S(f,D){if(typeof f==="function")return S(f(D),D);else return f}function K(f,D,L,X,E){if(!X&&!L)return;if(L)for(let j in L){let q=L[j],z=X?.[j];if(q!==z)if(X)X[j]=R(f,D,j,q,z,E);else R(f,D,j,q,void 0,E)}if(X&&L){for(let j in X)if(!(j in L)){let q=X[j];X[j]=R(f,D,j,void 0,q,E)}}else if(X)for(let j in X){let q=X[j];X[j]=R(f,D,j,void 0,q,E)}}function R(f,D,L,X,E,j){if(L==="style")if(!E)D.style.cssText="";else if(X){for(let q in{...X,...E})if(!X||E[q]!==X[q])D.style[q]=E[q];else if(X[q]&&!E[q])D.style[q]=void 0}else for(let q in E)D.style[q]=E[q];else if(L==="class")if(j)if(E){let q=m(E);D.classList.value=q}else D.classList.value="";else if(E){let q=m(E);D.className=q}else D.className="";else if(L[0]==="o"&&L[1]==="n")if(E){let q=null;if(typeof E==="function"){let z=E;q=(Q)=>f([z,Q])}else if(Array.isArray(E)){let z=E,Q=E[0];if(z.length>1)q=()=>f([Q,...z.slice(1)]);else q=(B)=>f([Q,B])}else if(typeof E==="object")q=()=>f(E);D[L]=q}else D[L]=null;else if(E!==null&&E!==void 0&&E!==!1)D.setAttribute(L,E);else D.removeAttribute(L);return E}function m(f){if(typeof f==="string")return f;else if(Array.isArray(f))return f.map(m).join(" ");else if(typeof f==="object")return Object.keys(f).filter((D)=>f[D]).join(" ");else return""}var s="a",r="abbr",l="address",t="area",n="article",a="aside",d="audio",o="b",e="base",ff="bdi",Ef="bdo",Df="blockquote",Lf="body",Xf="br",jf="button",qf="canvas",zf="caption",Bf="cite",Ff="code",Gf="col",Jf="colgroup",Qf="data",Uf="datalist",Wf="dd",Yf="del",Zf="details",$f="dfn",Af="dialog",Of="div",Tf="dl",Rf="dt",Cf="em",Hf="embed",Mf="fieldset",If="figcaption",Kf="figure",mf="footer",xf="form",Nf="h1",Sf="h2",yf="h3",_f="h4",bf="h5",kf="h6",Pf="head",hf="header",gf="hgroup",uf="hr",cf="html",vf="i",pf="iframe",Vf="img",wf="input",sf="ins",rf="kbd",lf="label",tf="legend",nf="li",af="link",df="main",of="map",ef="mark",fE="menu",EE="meta",DE="meter",LE="nav",XE="noscript",jE="object",qE="ol",zE="optgroup",BE="option",FE="output",GE="p",JE="picture",QE="pre",UE="progress",WE="q",YE="rp",ZE="rt",$E="ruby",AE="s",OE="samp",TE="script",RE="section",CE="select",HE="slot",ME="small",IE="source",KE="span",mE="strong",xE="style",NE="sub",SE="summary",yE="sup",_E="table",bE="tbody",kE="td",PE="template",hE="textarea",gE="tfoot",uE="th",cE="thead",vE="time",pE="title",VE="tr",iE="track",wE="u",sE="ul",rE="video",lE="wbr",tE="animate",nE="animateMotion",aE="animateTransform",dE="circle",oE="clipPath",eE="defs",fD="desc",ED="ellipse",DD="feBlend",LD="feColorMatrix",XD="feComponentTransfer",jD="feComposite",qD="feConvolveMatrix",zD="feDiffuseLighting",BD="feDisplacementMap",FD="feDistantLight",GD="feDropShadow",JD="feFlood",QD="feFuncA",UD="feFuncB",WD="feFuncG",YD="feFuncR",ZD="feGaussianBlur",$D="feImage",AD="feMerge",OD="feMergeNode",TD="feMorphology",RD="feOffset",CD="fePointLight",HD="feSpecularLighting",MD="feSpotLight",ID="feTile",KD="feTurbulence",mD="filter",xD="foreignObject",ND="g",SD="image",yD="line",_D="linearGradient",bD="marker",kD="mask",PD="metadata",hD="mpath",gD="path",uD="pattern",cD="polygon",vD="polyline",pD="radialGradient",VD="rect",iD="set",wD="stop",sD="svg",rD="switch",lD="symbol",tD="text",nD="textPath",aD="tspan",dD="use",oD="view",eD="annotation",fL="annotation-xml",EL="maction",DL="math",LL="merror",XL="mfrac",jL="mi",qL="mmultiscripts",zL="mn",BL="mo",FL="mover",GL="mpadded",JL="mphantom",QL="mprescripts",UL="mroot",WL="mrow",YL="ms",ZL="mspace",$L="msqrt",AL="mstyle",OL="msub",TL="msubsup",RL="msup",CL="mtable",HL="mtd",ML="mtext",IL="mtr",KL="munder",mL="munderover",xL="semantics";function SL(f){let D=document.createElement("div");D.innerHTML=f.trim();let L=[];for(let X of D.childNodes){let E=y(X);if(E!=null)L.push(E)}return L}function y(f){if(f.nodeType===Node.TEXT_NODE)return f.textContent;if(f.nodeType!==Node.ELEMENT_NODE)return;let D=[f.tagName.toLowerCase()];if(f.hasAttributes()){let L={};for(let X of f.attributes)L[X.name]=X.value;D.push(L)}for(let L of f.childNodes){let X=y(L);if(X&&(typeof X!=="string"||X.length>0))D.push(X)}return D}export{g as vode,v as tag,Z as props,p as mergeClass,c as memo,SL as htmlToVode,P as createState,h as createPatch,x as childrenStart,M as children,V as childCount,i as child,u as app,lE as WBR,oD as VIEW,rE as VIDEO,dD as USE,sE as UL,wE as U,aD as TSPAN,iE as TRACK,VE as TR,pE as TITLE,vE as TIME,cE as THEAD,uE as TH,gE as TFOOT,nD as TEXTPATH,hE as TEXTAREA,tD as TEXT,PE as TEMPLATE,kE as TD,bE as TBODY,_E as TABLE,lD as SYMBOL,rD as SWITCH,sD as SVG,yE as SUP,SE as SUMMARY,NE as SUB,xE as STYLE,mE as STRONG,wD as STOP,KE as SPAN,IE as SOURCE,ME as SMALL,HE as SLOT,iD as SET,xL as SEMANTICS,CE as SELECT,RE as SECTION,TE as SCRIPT,OE as SAMP,AE as S,$E as RUBY,ZE as RT,YE as RP,VD as RECT,pD as RADIALGRADIENT,WE as Q,UE as PROGRESS,QE as PRE,vD as POLYLINE,cD as POLYGON,JE as PICTURE,uD as PATTERN,gD as PATH,GE as P,FE as OUTPUT,BE as OPTION,zE as OPTGROUP,qE as OL,jE as OBJECT,XE as NOSCRIPT,LE as NAV,mL as MUNDEROVER,KL as MUNDER,IL as MTR,ML as MTEXT,HL as MTD,CL as MTABLE,RL as MSUP,TL as MSUBSUP,OL as MSUB,AL as MSTYLE,$L as MSQRT,ZL as MSPACE,YL as MS,WL as MROW,UL as MROOT,QL as MPRESCRIPTS,JL as MPHANTOM,hD as MPATH,GL as MPADDED,FL as MOVER,BL as MO,zL as MN,qL as MMULTISCRIPTS,jL as MI,XL as MFRAC,DE as METER,PD as METADATA,EE as META,LL as MERROR,fE as MENU,DL as MATH,kD as MASK,bD as MARKER,ef as MARK,of as MAP,df as MAIN,EL as MACTION,af as LINK,_D as LINEARGRADIENT,yD as LINE,nf as LI,tf as LEGEND,lf as LABEL,rf as KBD,sf as INS,wf as INPUT,Vf as IMG,SD as IMAGE,pf as IFRAME,vf as I,cf as HTML,uf as HR,gf as HGROUP,hf as HEADER,Pf as HEAD,kf as H6,bf as H5,_f as H4,yf as H3,Sf as H2,Nf as H1,ND as G,xf as FORM,xD as FOREIGNOBJECT,mf as FOOTER,mD as FILTER,Kf as FIGURE,If as FIGCAPTION,Mf as FIELDSET,KD as FETURBULENCE,ID as FETILE,MD as FESPOTLIGHT,HD as FESPECULARLIGHTING,CD as FEPOINTLIGHT,RD as FEOFFSET,TD as FEMORPHOLOGY,OD as FEMERGENODE,AD as FEMERGE,$D as FEIMAGE,ZD as FEGAUSSIANBLUR,YD as FEFUNCR,WD as FEFUNCG,UD as FEFUNCB,QD as FEFUNCA,JD as FEFLOOD,GD as FEDROPSHADOW,FD as FEDISTANTLIGHT,BD as FEDISPLACEMENTMAP,zD as FEDIFFUSELIGHTING,qD as FECONVOLVEMATRIX,jD as FECOMPOSITE,XD as FECOMPONENTTRANSFER,LD as FECOLORMATRIX,DD as FEBLEND,Hf as EMBED,Cf as EM,ED as ELLIPSE,Rf as DT,Tf as DL,Of as DIV,Af as DIALOG,$f as DFN,Zf as DETAILS,fD as DESC,Yf as DEL,eE as DEFS,Wf as DD,Uf as DATALIST,Qf as DATA,Jf as COLGROUP,Gf as COL,Ff as CODE,oE as CLIPPATH,Bf as CITE,dE as CIRCLE,zf as CAPTION,qf as CANVAS,jf as BUTTON,Xf as BR,Lf as BODY,Df as BLOCKQUOTE,Ef as BDO,ff as BDI,e as BASE,o as B,d as AUDIO,a as ASIDE,n as ARTICLE,t as AREA,fL as ANNOTATION_XML,eD as ANNOTATION,aE as ANIMATETRANSFORM,nE as ANIMATEMOTION,tE as ANIMATE,l as ADDRESS,r as ABBR,s as A};
package/logo.svg ADDED
@@ -0,0 +1,50 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 40">
2
+ <style>
3
+ text {
4
+ font-weight: bold;
5
+ font-family: "Monaco", monospace;
6
+ color: #2d3748;
7
+ fill: #2d3748;
8
+ }
9
+
10
+ .braces-text {
11
+ font-size: 40px;
12
+ opacity: 0.666;
13
+ stroke: #aaa;
14
+ stroke-width: 1px;
15
+ }
16
+
17
+ .item-text {
18
+ paint-order: stroke;
19
+ stroke: #aaa;
20
+ stroke-width: 1px;
21
+ }
22
+
23
+ .comma-text {
24
+ font-size: 14px;
25
+ paint-order: stroke;
26
+ stroke: #fff;
27
+ stroke-width: 0.5px;
28
+ stroke-linecap: butt;
29
+ stroke-linejoin: miter;
30
+ opacity: 0.333;
31
+ }
32
+ </style>
33
+ <text x="-5%" y="76%" class="braces-text">[</text>
34
+
35
+ <text x="13%" y="76%" font-size="32" class="item-text">V</text>
36
+ <text x="24%" y="76%" class="comma-text">,</text>
37
+
38
+ <g transform="translate(32, -3)">
39
+ <text x="0" y="76%" font-size="20" class="item-text" >{</text>
40
+ <text x="12" y="76%" font-size="20" class="item-text">}</text>
41
+ </g>
42
+ <text x="50" y="76%" class="comma-text">,</text>
43
+
44
+ <text x="58" y="76%" font-size="24" class="item-text">d</text>
45
+ <text x="69" y="76%" class="comma-text">,</text>
46
+
47
+ <text x="76" y="76%" font-size="24" class="item-text">e</text>
48
+
49
+ <text x="83%" y="76%" class="braces-text">]</text>
50
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryupold/vode",
3
- "version": "0.13.1",
3
+ "version": "1.0.0",
4
4
  "description": "Small web framework for minimal websites",
5
5
  "author": "Michael Scherbakow (ryupold)",
6
6
  "license": "MIT",
@@ -22,15 +22,18 @@
22
22
  "homepage": "https://github.com/ryupold/vode#readme",
23
23
  "module": "index.ts",
24
24
  "scripts": {
25
- "build": "bun build index.ts --outfile vode.mjs",
26
- "build-min": "bun build index.ts --outfile vode.min.mjs --minify",
27
- "pack": "rm *.tgz && bun run build && bun pm pack",
25
+ "build": "bun build index.ts --outfile dist/vode.mjs",
26
+ "build-min": "bun build index.ts --outfile dist/vode.min.mjs --minify",
27
+ "build-classic": "esbuild index.ts --outfile=dist/vode.js --bundle --global-name=V",
28
+ "build-classic-min": "esbuild index.ts --outfile=dist/vode.min.js --bundle --global-name=V --minify",
29
+ "release": "bun run build && bun run build-min && bun run build-classic && bun run build-classic-min",
28
30
  "publish": "bun publish --provenance --access public",
29
31
  "clean": "tsc -b --clean",
30
32
  "watch": "tsc -b -w"
31
33
  },
32
34
  "devDependencies": {
33
35
  "bun": "^1.2.18",
36
+ "esbuild": "^0.25.8",
34
37
  "typescript": "^5.8.3"
35
38
  }
36
39
  }
package/src/vode.ts CHANGED
@@ -10,11 +10,11 @@ export type Tag = keyof (HTMLElementTagNameMap & SVGElementTagNameMap & MathMLEl
10
10
  export type Component<S> = (s: S) => ChildVode<S>;
11
11
 
12
12
  export type Patch<S> =
13
- | NoRenderPatch // ignored
14
- | RenderPatch<S>
15
- | Promise<Patch<S>> | Effect<S>; // effects resulting in patches
13
+ | IgnoredPatch // ignored
14
+ | RenderPatch<S> // updates state, causes render
15
+ | Promise<Patch<S>> | Effect<S>; // is executed, awaited, results in patches
16
16
 
17
- export type NoRenderPatch = undefined | null | number | boolean | bigint | string | symbol | void;
17
+ export type IgnoredPatch = undefined | null | number | boolean | bigint | string | symbol | void;
18
18
  export type RenderPatch<S> = {} | DeepPartial<S>;
19
19
  export type DeepPartial<S> = { [P in keyof S]?: S[P] extends Array<infer I> ? Array<DeepPartial<I>> : DeepPartial<S[P]> };
20
20
 
@@ -30,7 +30,7 @@ export type EffectFunction<S> = (state: S, ...args: any[]) => Patch<S>;
30
30
  export type Props<S> = Partial<
31
31
  Omit<HTMLElement,
32
32
  keyof (DocumentFragment & ElementCSSInlineStyle & GlobalEventHandlers)> &
33
- { [K in keyof EventsMap]: Patch<S> } // all on* events
33
+ { [K in keyof EventsMap]: ((state: S, evt: Event) => Patch<S>) | Patch<S> } // all on* events
34
34
  > & {
35
35
  [_: string]: unknown,
36
36
  class?: ClassProp,
@@ -75,12 +75,12 @@ export type ContainerNode<S> = HTMLElement & {
75
75
  * it contains all necessary stuff for the vode app to function.
76
76
  * delete it to clear all resources of the vode app, or remove the container itself */
77
77
  _vode: {
78
- state: PatchableState<S>, // can touch this, but let it be an object
79
- vode: AttachedVode<S>, //don't touch this
80
- patch: Dispatch<S>, // can't touch this
81
- render: () => void, // can't touch this
78
+ state: PatchableState<S>,
79
+ vode: AttachedVode<S>,
80
+ patch: Dispatch<S>,
81
+ render: () => void,
82
82
  q: object | null, // next patch aggregate to be applied
83
- isRendering: boolean, // under no circumstances touch this
83
+ isRendering: boolean,
84
84
  /** stats about the overall patches & last render time */
85
85
  stats: {
86
86
  patchCount: number,
@@ -96,7 +96,7 @@ export type ContainerNode<S> = HTMLElement & {
96
96
  export function createState<S extends object | unknown>(state: S): PatchableState<S> { return state as PatchableState<S>; }
97
97
 
98
98
  /** type safe way to create a patch. useful for type inference and autocompletion. */
99
- export function createPatch<S extends object | unknown>(p: DeepPartial<S> | Effect<S> | NoRenderPatch): typeof p { return p; }
99
+ export function createPatch<S extends object | unknown>(p: DeepPartial<S> | Effect<S> | IgnoredPatch): typeof p { return p; }
100
100
 
101
101
  /** type-safe way to create a vode. useful for type inference and autocompletion.
102
102
  *
File without changes